deactive->inactive, inactivate->deactivate spelling fixes (Bug#10150)
[emacs.git] / lisp / gnus / gnus-sum.el
blob06f17bcf646b8c467e0bd9ddfd496373669a34ef
1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2012 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;;; Code:
27 ;; For Emacs <22.2 and XEmacs.
28 (eval-and-compile
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30 (eval-when-compile
31 (require 'cl))
32 (eval-when-compile
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
39 (require 'gnus)
40 (require 'gnus-group)
41 (require 'gnus-spec)
42 (require 'gnus-range)
43 (require 'gnus-int)
44 (require 'gnus-undo)
45 (require 'gnus-util)
46 (require 'gmm-utils)
47 (require 'mm-decode)
48 (require 'nnoo)
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
70 :type 'boolean)
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
78 :type 'boolean)
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
84 :version "24.1"
85 :type 'boolean)
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
100 The server has to support NOV for any of this to work.
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
106 :group 'gnus-thread
107 :type '(choice (const :tag "off" nil)
108 (const :tag "on" t)
109 (const some)
110 (const invisible)
111 number
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
117 :group 'gnus-thread
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
124 current group."
125 :version "24.1"
126 :group 'gnus-thread
127 :type 'boolean)
129 (defcustom gnus-summary-make-false-root 'adopt
130 "*nil means that Gnus won't gather loose threads.
131 If the root of a thread has expired or been read in a previous
132 session, the information necessary to build a complete thread has been
133 lost. Instead of having many small sub-threads from this original thread
134 scattered all over the summary buffer, Gnus can gather them.
136 If non-nil, Gnus will try to gather all loose sub-threads from an
137 original thread into one large thread.
139 If this variable is non-nil, it should be one of `none', `adopt',
140 `dummy' or `empty'.
142 If this variable is `none', Gnus will not make a false root, but just
143 present the sub-threads after another.
144 If this variable is `dummy', Gnus will create a dummy root that will
145 have all the sub-threads as children.
146 If this variable is `adopt', Gnus will make one of the \"children\"
147 the parent and mark all the step-children as such.
148 If this variable is `empty', the \"children\" are printed with empty
149 subject fields. (Or rather, they will be printed with a string
150 given by the `gnus-summary-same-subject' variable.)"
151 :group 'gnus-thread
152 :type '(choice (const :tag "off" nil)
153 (const none)
154 (const dummy)
155 (const adopt)
156 (const empty)))
158 (defcustom gnus-summary-make-false-root-always nil
159 "Always make a false dummy root."
160 :version "22.1"
161 :group 'gnus-thread
162 :type 'boolean)
164 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
165 "*A regexp to match subjects to be excluded from loose thread gathering.
166 As loose thread gathering is done on subjects only, that means that
167 there can be many false gatherings performed. By rooting out certain
168 common subjects, gathering might become saner."
169 :group 'gnus-thread
170 :type 'regexp)
172 (defcustom gnus-summary-gather-subject-limit nil
173 "*Maximum length of subject comparisons when gathering loose threads.
174 Use nil to compare full subjects. Setting this variable to a low
175 number will help gather threads that have been corrupted by
176 newsreaders chopping off subject lines, but it might also mean that
177 unrelated articles that have subject that happen to begin with the
178 same few characters will be incorrectly gathered.
180 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
181 comparing subjects."
182 :group 'gnus-thread
183 :type '(choice (const :tag "off" nil)
184 (const fuzzy)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-simplify-subject-functions nil
188 "List of functions taking a string argument that simplify subjects.
189 The functions are applied recursively.
191 Useful functions to put in this list include:
192 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
193 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
194 :group 'gnus-thread
195 :type '(repeat function))
197 (defcustom gnus-simplify-ignored-prefixes nil
198 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
199 :group 'gnus-thread
200 :type '(choice (const :tag "off" nil)
201 regexp))
203 (defcustom gnus-build-sparse-threads nil
204 "*If non-nil, fill in the gaps in threads.
205 If `some', only fill in the gaps that are needed to tie loose threads
206 together. If `more', fill in all leaf nodes that Gnus can find. If
207 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
208 :group 'gnus-thread
209 :type '(choice (const :tag "off" nil)
210 (const some)
211 (const more)
212 (sexp :menu-tag "all" t)))
214 (defcustom gnus-summary-thread-gathering-function
215 'gnus-gather-threads-by-subject
216 "*Function used for gathering loose threads.
217 There are two pre-defined functions: `gnus-gather-threads-by-subject',
218 which only takes Subjects into consideration; and
219 `gnus-gather-threads-by-references', which compared the References
220 headers of the articles to find matches."
221 :group 'gnus-thread
222 :type '(radio (function-item gnus-gather-threads-by-subject)
223 (function-item gnus-gather-threads-by-references)
224 (function :tag "other")))
226 (defcustom gnus-summary-same-subject ""
227 "*String indicating that the current article has the same subject as the previous.
228 This variable will only be used if the value of
229 `gnus-summary-make-false-root' is `empty'."
230 :group 'gnus-summary-format
231 :type 'string)
233 (defcustom gnus-summary-goto-unread nil
234 "*If t, many commands will go to the next unread article.
235 This applies to marking commands as well as other commands that
236 \"naturally\" select the next article, like, for instance, `SPC' at
237 the end of an article.
239 If nil, the marking commands do NOT go to the next unread article
240 \(they go to the next article instead). If `never', commands that
241 usually go to the next unread article, will go to the next article,
242 whether it is read or not."
243 :version "24.1"
244 :group 'gnus-summary-marks
245 :link '(custom-manual "(gnus)Setting Marks")
246 :type '(choice (const :tag "off" nil)
247 (const never)
248 (sexp :menu-tag "on" t)))
250 (defcustom gnus-summary-default-score 0
251 "*Default article score level.
252 All scores generated by the score files will be added to this score.
253 If this variable is nil, scoring will be disabled."
254 :group 'gnus-score-default
255 :type '(choice (const :tag "disable")
256 integer))
258 (defcustom gnus-summary-default-high-score 0
259 "*Default threshold for a high scored article.
260 An article will be highlighted as high scored if its score is greater
261 than this score."
262 :version "22.1"
263 :group 'gnus-score-default
264 :type 'integer)
266 (defcustom gnus-summary-default-low-score 0
267 "*Default threshold for a low scored article.
268 An article will be highlighted as low scored if its score is smaller
269 than this score."
270 :version "22.1"
271 :group 'gnus-score-default
272 :type 'integer)
274 (defcustom gnus-summary-zcore-fuzz 0
275 "*Fuzziness factor for the zcore in the summary buffer.
276 Articles with scores closer than this to `gnus-summary-default-score'
277 will not be marked."
278 :group 'gnus-summary-format
279 :type 'integer)
281 (defcustom gnus-simplify-subject-fuzzy-regexp nil
282 "*Strings to be removed when doing fuzzy matches.
283 This can either be a regular expression or list of regular expressions
284 that will be removed from subject strings if fuzzy subject
285 simplification is selected."
286 :group 'gnus-thread
287 :type '(repeat regexp))
289 (defcustom gnus-show-threads t
290 "*If non-nil, display threads in summary mode."
291 :group 'gnus-thread
292 :type 'boolean)
294 (defcustom gnus-thread-hide-subtree nil
295 "*If non-nil, hide all threads initially.
296 This can be a predicate specifier which says which threads to hide.
297 If threads are hidden, you have to run the command
298 `gnus-summary-show-thread' by hand or select an article."
299 :group 'gnus-thread
300 :type '(radio (sexp :format "Non-nil\n"
301 :match (lambda (widget value)
302 (not (or (consp value) (functionp value))))
303 :value t)
304 (const nil)
305 (sexp :tag "Predicate specifier")))
307 (defcustom gnus-thread-hide-killed t
308 "*If non-nil, hide killed threads automatically."
309 :group 'gnus-thread
310 :type 'boolean)
312 (defcustom gnus-thread-ignore-subject t
313 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
314 If nil, articles that have different subjects from their parents will
315 start separate threads."
316 :group 'gnus-thread
317 :type 'boolean)
319 (defcustom gnus-thread-operation-ignore-subject t
320 "*If non-nil, subjects will be ignored when doing thread commands.
321 This affects commands like `gnus-summary-kill-thread' and
322 `gnus-summary-lower-thread'.
324 If this variable is nil, articles in the same thread with different
325 subjects will not be included in the operation in question. If this
326 variable is `fuzzy', only articles that have subjects that are fuzzily
327 equal will be included."
328 :group 'gnus-thread
329 :type '(choice (const :tag "off" nil)
330 (const fuzzy)
331 (sexp :tag "on" t)))
333 (defcustom gnus-thread-indent-level 4
334 "*Number that says how much each sub-thread should be indented."
335 :group 'gnus-thread
336 :type 'integer)
338 (defcustom gnus-auto-extend-newsgroup t
339 "*If non-nil, extend newsgroup forward and backward when requested."
340 :group 'gnus-summary-choose
341 :type 'boolean)
343 (defcustom gnus-auto-select-first t
344 "If non-nil, select an article on group entry.
345 An article is selected automatically when entering a group
346 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
347 `gnus-summary-catchup-and-goto-next-group'.
349 Which article is selected is controlled by the variable
350 `gnus-auto-select-subject'.
352 If you want to prevent automatic selection of articles in some
353 newsgroups, set the variable to nil in `gnus-select-group-hook'."
354 ;; Commands include...
355 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
358 :group 'gnus-group-select
359 :type '(choice (const :tag "none" nil)
360 (sexp :menu-tag "first" t)))
362 (defcustom gnus-auto-select-subject 'unseen-or-unread
363 "*Says what subject to place under point when entering a group.
365 This variable can either be the symbols `first' (place point on the
366 first subject), `unread' (place point on the subject line of the first
367 unread article), `best' (place point on the subject line of the
368 highest-scored article), `unseen' (place point on the subject line of
369 the first unseen article), `unseen-or-unread' (place point on the subject
370 line of the first unseen article or, if all articles have been seen, on the
371 subject line of the first unread article), or a function to be called to
372 place point on some subject line."
373 :version "24.1"
374 :group 'gnus-group-select
375 :type '(choice (const best)
376 (const unread)
377 (const first)
378 (const unseen)
379 (const unseen-or-unread)
380 (function :tag "Function to call")))
382 (defcustom gnus-auto-select-next t
383 "*If non-nil, offer to go to the next group from the end of the previous.
384 If the value is t and the next newsgroup is empty, Gnus will exit
385 summary mode and go back to group mode. If the value is neither nil
386 nor t, Gnus will select the following unread newsgroup. In
387 particular, if the value is the symbol `quietly', the next unread
388 newsgroup will be selected without any confirmation, and if it is
389 `almost-quietly', the next group will be selected without any
390 confirmation if you are located on the last article in the group.
391 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
392 will go to the next group without confirmation."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "off" nil)
395 (const quietly)
396 (const almost-quietly)
397 (const slightly-quietly)
398 (sexp :menu-tag "on" t)))
400 (defcustom gnus-auto-select-same nil
401 "*If non-nil, select the next article with the same subject.
402 If there are no more articles with the same subject, go to
403 the first unread article."
404 :group 'gnus-summary-maneuvering
405 :type 'boolean)
407 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
408 "What article should be selected after exiting an ephemeral group.
409 Valid values include:
411 `next'
412 Select the next article.
413 `next-unread'
414 Select the next unread article.
415 `next-noselect'
416 Move the cursor to the next article. This is the default.
417 `next-unread-noselect'
418 Move the cursor to the next unread article.
420 If it has any other value or there is no next (unread) article, the
421 article selected before entering to the ephemeral group will appear."
422 :version "23.1" ;; No Gnus
423 :group 'gnus-summary-maneuvering
424 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
425 (const next) (const next-unread)
426 (const next-noselect) (const next-unread-noselect)
427 (sexp :tag "other" :value nil)))
429 (defcustom gnus-auto-goto-ignores 'unfetched
430 "*Says how to handle unfetched articles when maneuvering.
432 This variable can either be the symbols nil (maneuver to any
433 article), `undownloaded' (maneuvering while unplugged ignores articles
434 that have not been fetched), `always-undownloaded' (maneuvering always
435 ignores articles that have not been fetched), `unfetched' (maneuvering
436 ignores articles whose headers have not been fetched).
438 NOTE: The list of unfetched articles will always be nil when plugged
439 and, when unplugged, a subset of the undownloaded article list."
440 :version "22.1"
441 :group 'gnus-summary-maneuvering
442 :type '(choice (const :tag "None" nil)
443 (const :tag "Undownloaded when unplugged" undownloaded)
444 (const :tag "Undownloaded" always-undownloaded)
445 (const :tag "Unfetched" unfetched)))
447 (defcustom gnus-summary-check-current nil
448 "*If non-nil, consider the current article when moving.
449 The \"unread\" movement commands will stay on the same line if the
450 current article is unread."
451 :group 'gnus-summary-maneuvering
452 :type 'boolean)
454 (defcustom gnus-auto-center-summary
455 (max (or (bound-and-true-p scroll-margin) 0) 2)
456 "*If non-nil, always center the current summary buffer.
457 In particular, if `vertical' do only vertical recentering. If non-nil
458 and non-`vertical', do both horizontal and vertical recentering."
459 :group 'gnus-summary-maneuvering
460 :type '(choice (const :tag "none" nil)
461 (const vertical)
462 (integer :tag "height")
463 (sexp :menu-tag "both" t)))
465 (defcustom gnus-auto-center-group t
466 "If non-nil, always center the group buffer."
467 :group 'gnus-summary-maneuvering
468 :type 'boolean)
470 (defcustom gnus-show-all-headers nil
471 "*If non-nil, don't hide any headers."
472 :group 'gnus-article-hiding
473 :group 'gnus-article-headers
474 :type 'boolean)
476 (defcustom gnus-summary-ignore-duplicates nil
477 "*If non-nil, ignore articles with identical Message-ID headers."
478 :group 'gnus-summary
479 :type 'boolean)
481 (defcustom gnus-single-article-buffer nil
482 "*If non-nil, display all articles in the same buffer.
483 If nil, each group will get its own article buffer."
484 :version "24.1"
485 :group 'gnus-article-various
486 :type 'boolean)
488 (defcustom gnus-widen-article-window nil
489 "If non-nil, selecting the article buffer will display only the article buffer."
490 :version "24.1"
491 :group 'gnus-article-various
492 :type 'boolean)
494 (defcustom gnus-break-pages t
495 "*If non-nil, do page breaking on articles.
496 The page delimiter is specified by the `gnus-page-delimiter'
497 variable."
498 :group 'gnus-article-various
499 :type 'boolean)
501 (defcustom gnus-move-split-methods nil
502 "*Variable used to suggest where articles are to be moved to.
503 It uses the same syntax as the `gnus-split-methods' variable.
504 However, whereas `gnus-split-methods' specifies file names as targets,
505 this variable specifies group names."
506 :group 'gnus-summary-mail
507 :type '(repeat (choice (list :value (fun) function)
508 (cons :value ("" "") regexp (repeat string))
509 (sexp :value nil))))
511 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
512 "Function used to compute default prefix for article move/copy/etc prompts.
513 The function should take one argument, a group name, and return a
514 string with the suggested prefix."
515 :group 'gnus-summary-mail
516 :type 'function)
518 ;; FIXME: Although the custom type is `character' for the following variables,
519 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
521 (defcustom gnus-unread-mark ? ;Whitespace
522 "*Mark used for unread articles."
523 :group 'gnus-summary-marks
524 :type 'character)
526 (defcustom gnus-ticked-mark ?!
527 "*Mark used for ticked articles."
528 :group 'gnus-summary-marks
529 :type 'character)
531 (defcustom gnus-dormant-mark ??
532 "*Mark used for dormant articles."
533 :group 'gnus-summary-marks
534 :type 'character)
536 (defcustom gnus-del-mark ?r
537 "*Mark used for del'd articles."
538 :group 'gnus-summary-marks
539 :type 'character)
541 (defcustom gnus-read-mark ?R
542 "*Mark used for read articles."
543 :group 'gnus-summary-marks
544 :type 'character)
546 (defcustom gnus-expirable-mark ?E
547 "*Mark used for expirable articles."
548 :group 'gnus-summary-marks
549 :type 'character)
551 (defcustom gnus-killed-mark ?K
552 "*Mark used for killed articles."
553 :group 'gnus-summary-marks
554 :type 'character)
556 (defcustom gnus-spam-mark ?$
557 "*Mark used for spam articles."
558 :version "22.1"
559 :group 'gnus-summary-marks
560 :type 'character)
562 (defcustom gnus-kill-file-mark ?X
563 "*Mark used for articles killed by kill files."
564 :group 'gnus-summary-marks
565 :type 'character)
567 (defcustom gnus-low-score-mark ?Y
568 "*Mark used for articles with a low score."
569 :group 'gnus-summary-marks
570 :type 'character)
572 (defcustom gnus-catchup-mark ?C
573 "*Mark used for articles that are caught up."
574 :group 'gnus-summary-marks
575 :type 'character)
577 (defcustom gnus-replied-mark ?A
578 "*Mark used for articles that have been replied to."
579 :group 'gnus-summary-marks
580 :type 'character)
582 (defcustom gnus-forwarded-mark ?F
583 "*Mark used for articles that have been forwarded."
584 :version "22.1"
585 :group 'gnus-summary-marks
586 :type 'character)
588 (defcustom gnus-recent-mark ?N
589 "*Mark used for articles that are recent."
590 :version "22.1"
591 :group 'gnus-summary-marks
592 :type 'character)
594 (defcustom gnus-cached-mark ?*
595 "*Mark used for articles that are in the cache."
596 :group 'gnus-summary-marks
597 :type 'character)
599 (defcustom gnus-saved-mark ?S
600 "*Mark used for articles that have been saved."
601 :group 'gnus-summary-marks
602 :type 'character)
604 (defcustom gnus-unseen-mark ?.
605 "*Mark used for articles that haven't been seen."
606 :version "22.1"
607 :group 'gnus-summary-marks
608 :type 'character)
610 (defcustom gnus-no-mark ? ;Whitespace
611 "*Mark used for articles that have no other secondary mark."
612 :version "22.1"
613 :group 'gnus-summary-marks
614 :type 'character)
616 (defcustom gnus-ancient-mark ?O
617 "*Mark used for ancient articles."
618 :group 'gnus-summary-marks
619 :type 'character)
621 (defcustom gnus-sparse-mark ?Q
622 "*Mark used for sparsely reffed articles."
623 :group 'gnus-summary-marks
624 :type 'character)
626 (defcustom gnus-canceled-mark ?G
627 "*Mark used for canceled articles."
628 :group 'gnus-summary-marks
629 :type 'character)
631 (defcustom gnus-duplicate-mark ?M
632 "*Mark used for duplicate articles."
633 :group 'gnus-summary-marks
634 :type 'character)
636 (defcustom gnus-undownloaded-mark ?-
637 "*Mark used for articles that weren't downloaded."
638 :version "22.1"
639 :group 'gnus-summary-marks
640 :type 'character)
642 (defcustom gnus-downloaded-mark ?+
643 "*Mark used for articles that were downloaded."
644 :group 'gnus-summary-marks
645 :type 'character)
647 (defcustom gnus-downloadable-mark ?%
648 "*Mark used for articles that are to be downloaded."
649 :group 'gnus-summary-marks
650 :type 'character)
652 (defcustom gnus-unsendable-mark ?=
653 "*Mark used for articles that won't be sent."
654 :group 'gnus-summary-marks
655 :type 'character)
657 (defcustom gnus-score-over-mark ?+
658 "*Score mark used for articles with high scores."
659 :group 'gnus-summary-marks
660 :type 'character)
662 (defcustom gnus-score-below-mark ?-
663 "*Score mark used for articles with low scores."
664 :group 'gnus-summary-marks
665 :type 'character)
667 (defcustom gnus-empty-thread-mark ? ;Whitespace
668 "*There is no thread under the article."
669 :group 'gnus-summary-marks
670 :type 'character)
672 (defcustom gnus-not-empty-thread-mark ?=
673 "*There is a thread under the article."
674 :group 'gnus-summary-marks
675 :type 'character)
677 (defcustom gnus-view-pseudo-asynchronously nil
678 "*If non-nil, Gnus will view pseudo-articles asynchronously."
679 :group 'gnus-extract-view
680 :type 'boolean)
682 (defcustom gnus-auto-expirable-marks
683 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
684 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
685 gnus-duplicate-mark)
686 "*The list of marks converted into expiration if a group is auto-expirable."
687 :version "24.1"
688 :group 'gnus-summary
689 :type '(repeat character))
691 (defcustom gnus-inhibit-user-auto-expire t
692 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
693 :version "21.1"
694 :group 'gnus-summary
695 :type 'boolean)
697 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
698 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
699 If nil, the expirable marks will be unchanged except that the marks
700 will be removed when copying or moving articles to a group that has
701 not turned auto-expire on. If non-nil, articles that have been read
702 will be marked as expirable when being copied or moved to a group in
703 which auto-expire is turned on."
704 :version "23.2"
705 :type 'boolean
706 :group 'gnus-summary-marks)
708 (defcustom gnus-view-pseudos nil
709 "*If `automatic', pseudo-articles will be viewed automatically.
710 If `not-confirm', pseudos will be viewed automatically, and the user
711 will not be asked to confirm the command."
712 :group 'gnus-extract-view
713 :type '(choice (const :tag "off" nil)
714 (const automatic)
715 (const not-confirm)))
717 (defcustom gnus-view-pseudos-separately t
718 "*If non-nil, one pseudo-article will be created for each file to be viewed.
719 If nil, all files that use the same viewing command will be given as a
720 list of parameters to that command."
721 :group 'gnus-extract-view
722 :type 'boolean)
724 (defcustom gnus-insert-pseudo-articles t
725 "*If non-nil, insert pseudo-articles when decoding articles."
726 :group 'gnus-extract-view
727 :type 'boolean)
729 (defcustom gnus-summary-dummy-line-format
730 " %(: :%) %S\n"
731 "*The format specification for the dummy roots in the summary buffer.
732 It works along the same lines as a normal formatting string,
733 with some simple extensions.
735 %S The subject
737 General format specifiers can also be used.
738 See `(gnus)Formatting Variables'."
739 :link '(custom-manual "(gnus)Formatting Variables")
740 :group 'gnus-threading
741 :type 'string)
743 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
744 "*The format specification for the summary mode line.
745 It works along the same lines as a normal formatting string,
746 with some simple extensions:
748 %G Group name
749 %p Unprefixed group name
750 %A Current article number
751 %z Current article score
752 %V Gnus version
753 %U Number of unread articles in the group
754 %e Number of unselected articles in the group
755 %Z A string with unread/unselected article counts
756 %g Shortish group name
757 %S Subject of the current article
758 %u User-defined spec
759 %s Current score file name
760 %d Number of dormant articles
761 %r Number of articles that have been marked as read in this session
762 %E Number of articles expunged by the score files"
763 :group 'gnus-summary-format
764 :type 'string)
766 (defcustom gnus-list-identifiers nil
767 "Regexp that matches list identifiers to be removed from subject.
768 This can also be a list of regexps."
769 :version "21.1"
770 :group 'gnus-summary-format
771 :group 'gnus-article-hiding
772 :type '(choice (const :tag "none" nil)
773 (regexp :value ".*")
774 (repeat :value (".*") regexp)))
776 (defcustom gnus-summary-mark-below 0
777 "*Mark all articles with a score below this variable as read.
778 This variable is local to each summary buffer and usually set by the
779 score file."
780 :group 'gnus-score-default
781 :type 'integer)
783 (defun gnus-widget-reversible-match (widget value)
784 "Ignoring WIDGET, convert VALUE to internal form.
785 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
786 ;; (debug value)
787 (or (symbolp value)
788 (and (listp value)
789 (eq (length value) 2)
790 (eq (nth 0 value) 'not)
791 (symbolp (nth 1 value)))))
793 (defun gnus-widget-reversible-to-internal (widget value)
794 "Ignoring WIDGET, convert VALUE to internal form.
795 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
796 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
797 ;; (debug value)
798 (if (atom value)
799 (list value nil)
800 (list (nth 1 value) t)))
802 (defun gnus-widget-reversible-to-external (widget value)
803 "Ignoring WIDGET, convert VALUE to external form.
804 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
805 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
806 ;; (debug value)
807 (if (nth 1 value)
808 (list 'not (nth 0 value))
809 (nth 0 value)))
811 (define-widget 'gnus-widget-reversible 'group
812 "A `group' that convert values."
813 :match 'gnus-widget-reversible-match
814 :value-to-internal 'gnus-widget-reversible-to-internal
815 :value-to-external 'gnus-widget-reversible-to-external)
817 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
818 "*List of functions used for sorting articles in the summary buffer.
820 Each function takes two articles and returns non-nil if the first
821 article should be sorted before the other. If you use more than one
822 function, the primary sort function should be the last. You should
823 probably always include `gnus-article-sort-by-number' in the list of
824 sorting functions -- preferably first. Also note that sorting by date
825 is often much slower than sorting by number, and the sorting order is
826 very similar. (Sorting by date means sorting by the time the message
827 was sent, sorting by number means sorting by arrival time.)
829 Each item can also be a list `(not F)' where F is a function;
830 this reverses the sort order.
832 Ready-made functions include `gnus-article-sort-by-number',
833 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
834 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
835 and `gnus-article-sort-by-score'.
837 When threading is turned on, the variable `gnus-thread-sort-functions'
838 controls how articles are sorted."
839 :group 'gnus-summary-sort
840 :type '(repeat (gnus-widget-reversible
841 (choice (function-item gnus-article-sort-by-number)
842 (function-item gnus-article-sort-by-author)
843 (function-item gnus-article-sort-by-subject)
844 (function-item gnus-article-sort-by-date)
845 (function-item gnus-article-sort-by-score)
846 (function-item gnus-article-sort-by-random)
847 (function :tag "other"))
848 (boolean :tag "Reverse order"))))
851 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
852 "*List of functions used for sorting threads in the summary buffer.
853 By default, threads are sorted by article number.
855 Each function takes two threads and returns non-nil if the first
856 thread should be sorted before the other. If you use more than one
857 function, the primary sort function should be the last. You should
858 probably always include `gnus-thread-sort-by-number' in the list of
859 sorting functions -- preferably first. Also note that sorting by date
860 is often much slower than sorting by number, and the sorting order is
861 very similar. (Sorting by date means sorting by the time the message
862 was sent, sorting by number means sorting by arrival time.)
864 Each list item can also be a list `(not F)' where F is a
865 function; this specifies reversed sort order.
867 Ready-made functions include `gnus-thread-sort-by-number',
868 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
869 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
870 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
871 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
872 and `gnus-thread-sort-by-total-score' (see
873 `gnus-thread-score-function').
875 When threading is turned off, the variable
876 `gnus-article-sort-functions' controls how articles are sorted."
877 :group 'gnus-summary-sort
878 :type '(repeat
879 (gnus-widget-reversible
880 (choice (function-item gnus-thread-sort-by-number)
881 (function-item gnus-thread-sort-by-author)
882 (function-item gnus-thread-sort-by-recipient)
883 (function-item gnus-thread-sort-by-subject)
884 (function-item gnus-thread-sort-by-date)
885 (function-item gnus-thread-sort-by-score)
886 (function-item gnus-thread-sort-by-most-recent-number)
887 (function-item gnus-thread-sort-by-most-recent-date)
888 (function-item gnus-thread-sort-by-random)
889 (function-item gnus-thread-sort-by-total-score)
890 (function :tag "other"))
891 (boolean :tag "Reverse order"))))
893 (defcustom gnus-thread-score-function '+
894 "*Function used for calculating the total score of a thread.
896 The function is called with the scores of the article and each
897 subthread and should then return the score of the thread.
899 Some functions you can use are `+', `max', or `min'."
900 :group 'gnus-summary-sort
901 :type 'function)
903 (defcustom gnus-summary-expunge-below nil
904 "All articles that have a score less than this variable will be expunged.
905 This variable is local to the summary buffers."
906 :group 'gnus-score-default
907 :type '(choice (const :tag "off" nil)
908 integer))
910 (defcustom gnus-thread-expunge-below nil
911 "All threads that have a total score less than this variable will be expunged.
912 See `gnus-thread-score-function' for en explanation of what a
913 \"thread score\" is.
915 This variable is local to the summary buffers."
916 :group 'gnus-threading
917 :group 'gnus-score-default
918 :type '(choice (const :tag "off" nil)
919 integer))
921 (defcustom gnus-summary-mode-hook nil
922 "*A hook for Gnus summary mode.
923 This hook is run before any variables are set in the summary buffer."
924 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
925 :group 'gnus-summary-various
926 :type 'hook)
928 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
929 (when (featurep 'xemacs)
930 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
931 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
932 (add-hook 'gnus-summary-mode-hook
933 'gnus-xmas-switch-horizontal-scrollbar-off))
935 (defcustom gnus-summary-menu-hook nil
936 "*Hook run after the creation of the summary mode menu."
937 :group 'gnus-summary-visual
938 :type 'hook)
940 (defcustom gnus-summary-exit-hook nil
941 "*A hook called on exit from the summary buffer.
942 It will be called with point in the group buffer."
943 :group 'gnus-summary-exit
944 :type 'hook)
946 (defcustom gnus-summary-prepare-hook nil
947 "*A hook called after the summary buffer has been generated.
948 If you want to modify the summary buffer, you can use this hook."
949 :group 'gnus-summary-various
950 :type 'hook)
952 (defcustom gnus-summary-prepared-hook nil
953 "*A hook called as the last thing after the summary buffer has been generated."
954 :group 'gnus-summary-various
955 :type 'hook)
957 (defcustom gnus-summary-generate-hook nil
958 "*A hook run just before generating the summary buffer.
959 This hook is commonly used to customize threading variables and the
960 like."
961 :group 'gnus-summary-various
962 :type 'hook)
964 (defcustom gnus-select-group-hook nil
965 "*A hook called when a newsgroup is selected.
967 If you'd like to simplify subjects like the
968 `gnus-summary-next-same-subject' command does, you can use the
969 following hook:
971 (add-hook gnus-select-group-hook
972 (lambda ()
973 (mapcar (lambda (header)
974 (mail-header-set-subject
975 header
976 (gnus-simplify-subject
977 (mail-header-subject header) 're-only)))
978 gnus-newsgroup-headers)))"
979 :group 'gnus-group-select
980 :type 'hook)
982 (defcustom gnus-select-article-hook nil
983 "*A hook called when an article is selected."
984 :group 'gnus-summary-choose
985 :options '(gnus-agent-fetch-selected-article)
986 :type 'hook)
988 (defcustom gnus-visual-mark-article-hook
989 (list 'gnus-highlight-selected-summary)
990 "*Hook run after selecting an article in the summary buffer.
991 It is meant to be used for highlighting the article in some way. It
992 is not run if `gnus-visual' is nil."
993 :group 'gnus-summary-visual
994 :type 'hook)
996 (defcustom gnus-parse-headers-hook nil
997 "*A hook called before parsing the headers."
998 :group 'gnus-various
999 :type 'hook)
1001 (defcustom gnus-exit-group-hook nil
1002 "*A hook called when exiting summary mode.
1003 This hook is not called from the non-updating exit commands like `Q'."
1004 :group 'gnus-various
1005 :type 'hook)
1007 (defcustom gnus-summary-update-hook nil
1008 "*A hook called when a summary line is changed.
1009 The hook will not be called if `gnus-visual' is nil.
1011 The default function `gnus-summary-highlight-line' will
1012 highlight the line according to the `gnus-summary-highlight'
1013 variable."
1014 :group 'gnus-summary-visual
1015 :type 'hook)
1017 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1018 "*A hook called when an article is selected for the first time.
1019 The hook is intended to mark an article as read (or unread)
1020 automatically when it is selected."
1021 :group 'gnus-summary-choose
1022 :type 'hook)
1024 (defcustom gnus-group-no-more-groups-hook nil
1025 "*A hook run when returning to group mode having no more (unread) groups."
1026 :group 'gnus-group-select
1027 :type 'hook)
1029 (defcustom gnus-ps-print-hook nil
1030 "*A hook run before ps-printing something from Gnus."
1031 :group 'gnus-summary
1032 :type 'hook)
1034 (defcustom gnus-summary-article-move-hook nil
1035 "*A hook called after an article is moved, copied, respooled, or crossposted."
1036 :version "22.1"
1037 :group 'gnus-summary
1038 :type 'hook)
1040 (defcustom gnus-summary-article-delete-hook nil
1041 "*A hook called after an article is deleted."
1042 :version "22.1"
1043 :group 'gnus-summary
1044 :type 'hook)
1046 (defcustom gnus-summary-article-expire-hook nil
1047 "*A hook called after an article is expired."
1048 :version "22.1"
1049 :group 'gnus-summary
1050 :type 'hook)
1052 (defcustom gnus-summary-display-arrow
1053 (and (fboundp 'display-graphic-p)
1054 (display-graphic-p))
1055 "*If non-nil, display an arrow highlighting the current article."
1056 :version "22.1"
1057 :group 'gnus-summary
1058 :type 'boolean)
1060 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1061 "Face used for highlighting the current article in the summary buffer."
1062 :group 'gnus-summary-visual
1063 :type 'face)
1065 (defvar gnus-tmp-downloaded nil)
1067 (defcustom gnus-summary-highlight
1068 '(((eq mark gnus-canceled-mark)
1069 . gnus-summary-cancelled)
1070 ((and uncached (> score default-high))
1071 . gnus-summary-high-undownloaded)
1072 ((and uncached (< score default-low))
1073 . gnus-summary-low-undownloaded)
1074 (uncached
1075 . gnus-summary-normal-undownloaded)
1076 ((and (> score default-high)
1077 (or (eq mark gnus-dormant-mark)
1078 (eq mark gnus-ticked-mark)))
1079 . gnus-summary-high-ticked)
1080 ((and (< score default-low)
1081 (or (eq mark gnus-dormant-mark)
1082 (eq mark gnus-ticked-mark)))
1083 . gnus-summary-low-ticked)
1084 ((or (eq mark gnus-dormant-mark)
1085 (eq mark gnus-ticked-mark))
1086 . gnus-summary-normal-ticked)
1087 ((and (> score default-high) (eq mark gnus-ancient-mark))
1088 . gnus-summary-high-ancient)
1089 ((and (< score default-low) (eq mark gnus-ancient-mark))
1090 . gnus-summary-low-ancient)
1091 ((eq mark gnus-ancient-mark)
1092 . gnus-summary-normal-ancient)
1093 ((and (> score default-high) (eq mark gnus-unread-mark))
1094 . gnus-summary-high-unread)
1095 ((and (< score default-low) (eq mark gnus-unread-mark))
1096 . gnus-summary-low-unread)
1097 ((eq mark gnus-unread-mark)
1098 . gnus-summary-normal-unread)
1099 ((> score default-high)
1100 . gnus-summary-high-read)
1101 ((< score default-low)
1102 . gnus-summary-low-read)
1104 . gnus-summary-normal-read))
1105 "*Controls the highlighting of summary buffer lines.
1107 A list of (FORM . FACE) pairs. When deciding how a particular
1108 summary line should be displayed, each form is evaluated. The content
1109 of the face field after the first true form is used. You can change
1110 how those summary lines are displayed, by editing the face field.
1112 You can use the following variables in the FORM field.
1114 score: The article's score.
1115 default: The default article score.
1116 default-high: The default score for high scored articles.
1117 default-low: The default score for low scored articles.
1118 below: The score below which articles are automatically marked as read.
1119 mark: The article's mark.
1120 uncached: Non-nil if the article is uncached."
1121 :group 'gnus-summary-visual
1122 :type '(repeat (cons (sexp :tag "Form" nil)
1123 face)))
1124 (put 'gnus-summary-highlight 'risky-local-variable t)
1126 (defcustom gnus-alter-header-function nil
1127 "Function called to allow alteration of article header structures.
1128 The function is called with one parameter, the article header vector,
1129 which it may alter in any way."
1130 :type '(choice (const :tag "None" nil)
1131 function)
1132 :group 'gnus-summary)
1134 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1135 "Function used to decode a string with encoded words.")
1137 (defvar gnus-decode-encoded-address-function
1138 'mail-decode-encoded-address-string
1139 "Function used to decode addresses with encoded words.")
1141 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
1142 "*Extra headers to parse."
1143 :version "24.1" ; added Cc Keywords Gcc
1144 :group 'gnus-summary
1145 :type '(repeat symbol))
1147 (defcustom gnus-ignored-from-addresses
1148 (and user-mail-address
1149 (not (string= user-mail-address ""))
1150 (regexp-quote user-mail-address))
1151 "*From headers that may be suppressed in favor of To headers.
1152 This can be a regexp or a list of regexps."
1153 :version "21.1"
1154 :group 'gnus-summary
1155 :type '(choice regexp
1156 (repeat :tag "Regexp List" regexp)))
1158 (defsubst gnus-ignored-from-addresses ()
1159 (gmm-regexp-concat gnus-ignored-from-addresses))
1161 (defcustom gnus-summary-to-prefix "-> "
1162 "*String prefixed to the To field in the summary line when
1163 using `gnus-ignored-from-addresses'."
1164 :version "22.1"
1165 :group 'gnus-summary
1166 :type 'string)
1168 (defcustom gnus-summary-newsgroup-prefix "=> "
1169 "*String prefixed to the Newsgroup field in the summary
1170 line when using `gnus-ignored-from-addresses'."
1171 :version "22.1"
1172 :group 'gnus-summary
1173 :type 'string)
1175 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1176 "List of charsets that should be ignored.
1177 When these charsets are used in the \"charset\" parameter, the
1178 default charset will be used instead."
1179 :version "21.1"
1180 :type '(repeat symbol)
1181 :group 'gnus-charset)
1183 (defcustom gnus-newsgroup-maximum-articles nil
1184 "The maximum number of articles a newsgroup.
1185 If this is a number, old articles in a newsgroup exceeding this number
1186 are silently ignored. If it is nil, no article is ignored. Note that
1187 setting this variable to a number might prevent you from reading very
1188 old articles."
1189 :group 'gnus-group-select
1190 :version "22.2"
1191 :type '(choice (const :tag "No limit" nil)
1192 integer))
1194 (gnus-define-group-parameter
1195 ignored-charsets
1196 :type list
1197 :function-document
1198 "Return the ignored charsets of GROUP."
1199 :variable gnus-group-ignored-charsets-alist
1200 :variable-default
1201 '(("alt\\.chinese\\.text" iso-8859-1))
1202 :variable-document
1203 "Alist of regexps (to match group names) and charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead."
1206 :variable-group gnus-charset
1207 :variable-type '(repeat (cons (regexp :tag "Group")
1208 (repeat symbol)))
1209 :parameter-type '(choice :tag "Ignored charsets"
1210 :value nil
1211 (repeat (symbol)))
1212 :parameter-document "\
1213 List of charsets that should be ignored.
1215 When these charsets are used in the \"charset\" parameter, the
1216 default charset will be used instead.")
1218 (defcustom gnus-group-highlight-words-alist nil
1219 "Alist of group regexps and highlight regexps.
1220 This variable uses the same syntax as `gnus-emphasis-alist'."
1221 :version "21.1"
1222 :type '(repeat (cons (regexp :tag "Group")
1223 (repeat (list (regexp :tag "Highlight regexp")
1224 (number :tag "Group for entire word" 0)
1225 (number :tag "Group for displayed part" 0)
1226 (symbol :tag "Face"
1227 gnus-emphasis-highlight-words)))))
1228 :group 'gnus-summary-visual)
1230 (defcustom gnus-summary-show-article-charset-alist
1232 "Alist of number and charset.
1233 The article will be shown with the charset corresponding to the
1234 numbered argument.
1235 For example: ((1 . cn-gb-2312) (2 . big5))."
1236 :version "21.1"
1237 :type '(repeat (cons (number :tag "Argument" 1)
1238 (symbol :tag "Charset")))
1239 :group 'gnus-charset)
1241 (defcustom gnus-preserve-marks t
1242 "Whether marks are preserved when moving, copying and respooling messages."
1243 :version "21.1"
1244 :type 'boolean
1245 :group 'gnus-summary-marks)
1247 (defcustom gnus-alter-articles-to-read-function nil
1248 "Function to be called to alter the list of articles to be selected."
1249 :type '(choice (const nil) function)
1250 :group 'gnus-summary)
1252 (defcustom gnus-orphan-score nil
1253 "*All orphans get this score added. Set in the score file."
1254 :group 'gnus-score-default
1255 :type '(choice (const nil)
1256 integer))
1258 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1259 "*A regexp to match MIME parts when saving multiple parts of a
1260 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1261 This regexp will be used by default when prompting the user for which
1262 type of files to save."
1263 :group 'gnus-summary
1264 :type 'regexp)
1266 (defcustom gnus-read-all-available-headers nil
1267 "Whether Gnus should parse all headers made available to it.
1268 This is mostly relevant for slow back ends where the user may
1269 wish to widen the summary buffer to include all headers
1270 that were fetched."
1271 :version "22.1"
1272 :group 'gnus-summary
1273 :type '(choice boolean regexp))
1275 (defcustom gnus-summary-pipe-output-default-command nil
1276 "Command (and optional arguments) used to pipe article to subprocess.
1277 This will be used as the default command if it is non-nil. The value
1278 will be updated if you modify it when executing the command
1279 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1280 :version "23.1" ;; No Gnus
1281 :group 'gnus-summary
1282 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1284 (defcustom gnus-summary-muttprint-program "muttprint"
1285 "Command (and optional arguments) used to run Muttprint.
1286 The value will be updated if you modify it when executing the command
1287 `gnus-summary-muttprint'."
1288 :version "22.1"
1289 :group 'gnus-summary
1290 :type 'string)
1292 (defcustom gnus-article-loose-mime t
1293 "If non-nil, don't require MIME-Version header.
1294 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1295 supply the MIME-Version header or deliberately strip it from the mail.
1296 If non-nil (the default), Gnus will treat some articles as MIME
1297 even if the MIME-Version header is missing."
1298 :version "22.1"
1299 :type 'boolean
1300 :group 'gnus-article-mime)
1302 (defcustom gnus-article-emulate-mime t
1303 "If non-nil, use MIME emulation for uuencode and the like.
1304 This means that Gnus will search message bodies for text that look
1305 like uuencoded bits, yEncoded bits, and so on, and present that using
1306 the normal Gnus MIME machinery."
1307 :version "22.1"
1308 :type 'boolean
1309 :group 'gnus-article-mime)
1311 ;;; Internal variables
1313 (defvar gnus-summary-display-cache nil)
1314 (defvar gnus-article-mime-handles nil)
1315 (defvar gnus-article-decoded-p nil)
1316 (defvar gnus-article-charset nil)
1317 (defvar gnus-article-ignored-charsets nil)
1318 (defvar gnus-scores-exclude-files nil)
1319 (defvar gnus-page-broken nil)
1321 (defvar gnus-original-article nil)
1322 (defvar gnus-article-internal-prepare-hook nil)
1323 (defvar gnus-newsgroup-process-stack nil)
1325 (defvar gnus-thread-indent-array nil)
1326 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1327 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1328 "Function called to sort the articles within a thread after it has been gathered together.")
1330 (defvar gnus-summary-save-parts-type-history nil)
1331 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1333 ;; Avoid highlighting in kill files.
1334 (defvar gnus-summary-inhibit-highlight nil)
1335 (defvar gnus-newsgroup-selected-overlay nil)
1336 (defvar gnus-inhibit-limiting nil)
1337 (defvar gnus-newsgroup-adaptive-score-file nil)
1338 (defvar gnus-current-score-file nil)
1339 (defvar gnus-current-move-group nil)
1340 (defvar gnus-current-copy-group nil)
1341 (defvar gnus-current-crosspost-group nil)
1342 (defvar gnus-newsgroup-display nil)
1344 (defvar gnus-newsgroup-dependencies nil)
1345 (defvar gnus-newsgroup-adaptive nil)
1346 (defvar gnus-summary-display-article-function nil)
1347 (defvar gnus-summary-highlight-line-function nil
1348 "Function called after highlighting a summary line.")
1350 (defvar gnus-summary-line-format-alist
1351 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1352 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1353 (?s gnus-tmp-subject-or-nil ?s)
1354 (?n gnus-tmp-name ?s)
1355 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1357 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1358 gnus-tmp-from) ?s)
1359 (?F gnus-tmp-from ?s)
1360 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1361 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1362 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1363 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1364 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1365 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1366 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1367 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1368 (?L gnus-tmp-lines ?s)
1369 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1370 0) ?d)
1371 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1372 "") ?s)
1373 (?g (or (gnus-group-short-name
1374 (nnir-article-group (mail-header-number gnus-tmp-header)))
1375 "") ?s)
1376 (?O gnus-tmp-downloaded ?c)
1377 (?I gnus-tmp-indentation ?s)
1378 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1379 (?R gnus-tmp-replied ?c)
1380 (?\[ gnus-tmp-opening-bracket ?c)
1381 (?\] gnus-tmp-closing-bracket ?c)
1382 (?\> (make-string gnus-tmp-level ? ) ?s)
1383 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1384 (?i gnus-tmp-score ?d)
1385 (?z gnus-tmp-score-char ?c)
1386 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1387 (?U gnus-tmp-unread ?c)
1388 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1390 (?t (gnus-summary-number-of-articles-in-thread
1391 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1393 (?e (gnus-summary-number-of-articles-in-thread
1394 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1396 (?u gnus-tmp-user-defined ?s)
1397 (?P (gnus-pick-line-number) ?d)
1398 (?B gnus-tmp-thread-tree-header-string ?s)
1399 (user-date (gnus-user-date
1400 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1401 "An alist of format specifications that can appear in summary lines.
1402 These are paired with what variables they correspond with, along with
1403 the type of the variable (string, integer, character, etc).")
1405 (defvar gnus-summary-dummy-line-format-alist
1406 `((?S gnus-tmp-subject ?s)
1407 (?N gnus-tmp-number ?d)
1408 (?u gnus-tmp-user-defined ?s)))
1410 (defvar gnus-summary-mode-line-format-alist
1411 `((?G gnus-tmp-group-name ?s)
1412 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1413 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1414 (?A gnus-tmp-article-number ?d)
1415 (?Z gnus-tmp-unread-and-unselected ?s)
1416 (?V gnus-version ?s)
1417 (?U gnus-tmp-unread-and-unticked ?d)
1418 (?S gnus-tmp-subject ?s)
1419 (?e gnus-tmp-unselected ?d)
1420 (?u gnus-tmp-user-defined ?s)
1421 (?d (length gnus-newsgroup-dormant) ?d)
1422 (?t (length gnus-newsgroup-marked) ?d)
1423 (?h (length gnus-newsgroup-spam-marked) ?d)
1424 (?r (length gnus-newsgroup-reads) ?d)
1425 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1426 (?E gnus-newsgroup-expunged-tally ?d)
1427 (?s (gnus-current-score-file-nondirectory) ?s)))
1429 ;; This is here rather than in gnus-art for compilation reasons.
1430 (defvar gnus-article-mode-line-format-alist
1431 (nconc '((?w (gnus-article-wash-status) ?s)
1432 (?m (gnus-article-mime-part-status) ?s))
1433 gnus-summary-mode-line-format-alist))
1435 (defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1438 (defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1441 (defvar gnus-newsgroup-agentized nil
1442 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1443 (defvar gnus-newsgroup-begin nil)
1444 (defvar gnus-newsgroup-end nil)
1445 (defvar gnus-newsgroup-last-rmail nil)
1446 (defvar gnus-newsgroup-last-mail nil)
1447 (defvar gnus-newsgroup-last-folder nil)
1448 (defvar gnus-newsgroup-last-file nil)
1449 (defvar gnus-newsgroup-last-directory nil)
1450 (defvar gnus-newsgroup-auto-expire nil)
1451 (defvar gnus-newsgroup-active nil)
1452 (defvar gnus-newsgroup-highest nil)
1454 (defvar gnus-newsgroup-data nil)
1455 (defvar gnus-newsgroup-data-reverse nil)
1456 (defvar gnus-newsgroup-limit nil)
1457 (defvar gnus-newsgroup-limits nil)
1458 (defvar gnus-summary-use-undownloaded-faces nil)
1460 (defvar gnus-newsgroup-unreads nil
1461 "Sorted list of unread articles in the current newsgroup.")
1463 (defvar gnus-newsgroup-unselected nil
1464 "Sorted list of unselected unread articles in the current newsgroup.")
1466 (defvar gnus-newsgroup-reads nil
1467 "Alist of read articles and article marks in the current newsgroup.")
1469 (defvar gnus-newsgroup-expunged-tally nil)
1471 (defvar gnus-newsgroup-marked nil
1472 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1474 (defvar gnus-newsgroup-spam-marked nil
1475 "List of ranges of articles that have been marked as spam.")
1477 (defvar gnus-newsgroup-killed nil
1478 "List of ranges of articles that have been through the scoring process.")
1480 (defvar gnus-newsgroup-cached nil
1481 "Sorted list of articles that come from the article cache.")
1483 (defvar gnus-newsgroup-saved nil
1484 "List of articles that have been saved.")
1486 (defvar gnus-newsgroup-kill-headers nil)
1488 (defvar gnus-newsgroup-replied nil
1489 "List of articles that have been replied to in the current newsgroup.")
1491 (defvar gnus-newsgroup-forwarded nil
1492 "List of articles that have been forwarded in the current newsgroup.")
1494 (defvar gnus-newsgroup-expirable nil
1495 "Sorted list of articles in the current newsgroup that can be expired.")
1497 (defvar gnus-newsgroup-processable nil
1498 "List of articles in the current newsgroup that can be processed.")
1500 (defvar gnus-newsgroup-downloadable nil
1501 "Sorted list of articles in the current newsgroup that can be processed.")
1503 (defvar gnus-newsgroup-unfetched nil
1504 "Sorted list of articles in the current newsgroup whose headers have
1505 not been fetched into the agent.
1507 This list will always be a subset of gnus-newsgroup-undownloaded.")
1509 (defvar gnus-newsgroup-undownloaded nil
1510 "List of articles in the current newsgroup that haven't been downloaded.")
1512 (defvar gnus-newsgroup-unsendable nil
1513 "List of articles in the current newsgroup that won't be sent.")
1515 (defvar gnus-newsgroup-bookmarks nil
1516 "List of articles in the current newsgroup that have bookmarks.")
1518 (defvar gnus-newsgroup-dormant nil
1519 "Sorted list of dormant articles in the current newsgroup.")
1521 (defvar gnus-newsgroup-unseen nil
1522 "List of unseen articles in the current newsgroup.")
1524 (defvar gnus-newsgroup-seen nil
1525 "Range of seen articles in the current newsgroup.")
1527 (defvar gnus-newsgroup-articles nil
1528 "List of articles in the current newsgroup.")
1530 (defvar gnus-newsgroup-scored nil
1531 "List of scored articles in the current newsgroup.")
1533 (defvar gnus-newsgroup-headers nil
1534 "List of article headers in the current newsgroup.")
1536 (defvar gnus-newsgroup-threads nil)
1538 (defvar gnus-newsgroup-prepared nil
1539 "Whether the current group has been prepared properly.")
1541 (defvar gnus-newsgroup-ancient nil
1542 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1544 (defvar gnus-newsgroup-sparse nil)
1546 (defvar gnus-current-article nil)
1547 (defvar gnus-article-current nil)
1548 (defvar gnus-current-headers nil)
1549 (defvar gnus-have-all-headers nil)
1550 (defvar gnus-last-article nil)
1551 (defvar gnus-newsgroup-history nil)
1552 (defvar gnus-newsgroup-charset nil)
1553 (defvar gnus-newsgroup-ephemeral-charset nil)
1554 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1556 (defvar gnus-article-before-search nil)
1558 (defvar gnus-summary-local-variables
1559 '(gnus-newsgroup-name
1561 ;; Marks lists
1562 gnus-newsgroup-unreads
1563 gnus-newsgroup-unselected
1564 gnus-newsgroup-marked
1565 gnus-newsgroup-spam-marked
1566 gnus-newsgroup-reads
1567 gnus-newsgroup-saved
1568 gnus-newsgroup-replied
1569 gnus-newsgroup-forwarded
1570 gnus-newsgroup-expirable
1571 gnus-newsgroup-killed
1572 gnus-newsgroup-unseen
1573 gnus-newsgroup-seen
1574 gnus-newsgroup-cached
1575 gnus-newsgroup-downloadable
1576 gnus-newsgroup-undownloaded
1577 gnus-newsgroup-unsendable
1579 gnus-newsgroup-begin gnus-newsgroup-end
1580 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1581 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1582 gnus-newsgroup-last-directory
1583 gnus-newsgroup-auto-expire
1584 gnus-newsgroup-processable
1585 gnus-newsgroup-unfetched
1586 gnus-newsgroup-articles
1587 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1588 gnus-newsgroup-headers gnus-newsgroup-threads
1589 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1590 gnus-current-article gnus-current-headers gnus-have-all-headers
1591 gnus-last-article gnus-article-internal-prepare-hook
1592 (gnus-summary-article-delete-hook . global)
1593 (gnus-summary-article-move-hook . global)
1594 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1595 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1596 gnus-thread-expunge-below
1597 gnus-score-alist gnus-current-score-file
1598 (gnus-summary-expunge-below . global)
1599 (gnus-summary-mark-below . global)
1600 (gnus-orphan-score . global)
1601 gnus-newsgroup-active gnus-scores-exclude-files
1602 gnus-newsgroup-highest
1603 gnus-newsgroup-history gnus-newsgroup-ancient
1604 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1605 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1606 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1607 (gnus-newsgroup-expunged-tally . 0)
1608 gnus-cache-removable-articles
1609 gnus-newsgroup-data gnus-newsgroup-data-reverse
1610 gnus-newsgroup-limit gnus-newsgroup-limits
1611 gnus-newsgroup-charset gnus-newsgroup-display
1612 gnus-summary-use-undownloaded-faces)
1613 "Variables that are buffer-local to the summary buffers.")
1615 (defvar gnus-newsgroup-variables nil
1616 "A list of variables that have separate values in different newsgroups.
1617 A list of newsgroup (summary buffer) local variables, or cons of
1618 variables and their default expressions to be evalled (when the default
1619 values are not nil), that should be made global while the summary buffer
1620 is active.
1622 Note: The default expressions will be evaluated (using function `eval')
1623 before assignment to the local variable rather than just assigned to it.
1624 If the default expression is the symbol `global', that symbol will not
1625 be evaluated but the global value of the local variable will be used
1626 instead.
1628 These variables can be used to set variables in the group parameters
1629 while still allowing them to affect operations done in other buffers.
1630 For example:
1632 \(setq gnus-newsgroup-variables
1633 '(message-use-followup-to
1634 (gnus-visible-headers .
1635 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1638 (eval-when-compile
1639 ;; Bind features so that require will believe that gnus-sum has
1640 ;; already been loaded (avoids infinite recursion)
1641 (let ((features (cons 'gnus-sum features)))
1642 (require 'gnus-art)))
1644 ;; MIME stuff.
1646 (defvar gnus-decode-encoded-word-methods
1647 '(mail-decode-encoded-word-string)
1648 "List of methods used to decode encoded words.
1650 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1651 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1652 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1653 whose names match REGEXP.
1655 For example:
1656 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1657 mail-decode-encoded-word-string
1658 (\"chinese\" . rfc1843-decode-string))")
1660 (defvar gnus-decode-encoded-word-methods-cache nil)
1662 (defun gnus-multi-decode-encoded-word-string (string)
1663 "Apply the functions from `gnus-encoded-word-methods' that match."
1664 (unless (and gnus-decode-encoded-word-methods-cache
1665 (eq gnus-newsgroup-name
1666 (car gnus-decode-encoded-word-methods-cache)))
1667 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1668 (dolist (method gnus-decode-encoded-word-methods)
1669 (if (symbolp method)
1670 (nconc gnus-decode-encoded-word-methods-cache (list method))
1671 (if (and gnus-newsgroup-name
1672 (string-match (car method) gnus-newsgroup-name))
1673 (nconc gnus-decode-encoded-word-methods-cache
1674 (list (cdr method)))))))
1675 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1676 (setq string (funcall method string))))
1678 ;; Subject simplification.
1680 (defun gnus-simplify-whitespace (str)
1681 "Remove excessive whitespace from STR."
1682 ;; Multiple spaces.
1683 (while (string-match "[ \t][ \t]+" str)
1684 (setq str (concat (substring str 0 (match-beginning 0))
1686 (substring str (match-end 0)))))
1687 ;; Leading spaces.
1688 (when (string-match "^[ \t]+" str)
1689 (setq str (substring str (match-end 0))))
1690 ;; Trailing spaces.
1691 (when (string-match "[ \t]+$" str)
1692 (setq str (substring str 0 (match-beginning 0))))
1693 str)
1695 (defun gnus-simplify-all-whitespace (str)
1696 "Remove all whitespace from STR."
1697 (while (string-match "[ \t\n]+" str)
1698 (setq str (replace-match "" nil nil str)))
1699 str)
1701 (defsubst gnus-simplify-subject-re (subject)
1702 "Remove \"Re:\" from subject lines."
1703 (if (string-match message-subject-re-regexp subject)
1704 (substring subject (match-end 0))
1705 subject))
1707 (defun gnus-simplify-subject (subject &optional re-only)
1708 "Remove `Re:' and words in parentheses.
1709 If RE-ONLY is non-nil, strip leading `Re:'s only."
1710 (let ((case-fold-search t)) ;Ignore case.
1711 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1712 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1713 (setq subject (substring subject (match-end 0))))
1714 ;; Remove uninteresting prefixes.
1715 (when (and (not re-only)
1716 gnus-simplify-ignored-prefixes
1717 (string-match gnus-simplify-ignored-prefixes subject))
1718 (setq subject (substring subject (match-end 0))))
1719 ;; Remove words in parentheses from end.
1720 (unless re-only
1721 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1722 (setq subject (substring subject 0 (match-beginning 0)))))
1723 ;; Return subject string.
1724 subject))
1726 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1727 ;; all whitespace.
1728 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1729 (goto-char (point-min))
1730 (while (re-search-forward regexp nil t)
1731 (replace-match (or newtext ""))))
1733 (defun gnus-simplify-buffer-fuzzy (regexp)
1734 "Simplify string in the buffer fuzzily.
1735 The string in the accessible portion of the current buffer is simplified.
1736 It is assumed to be a single-line subject.
1737 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1738 matter is removed. Additional things can be deleted by setting
1739 `gnus-simplify-subject-fuzzy-regexp'."
1740 (let ((case-fold-search t)
1741 (modified-tick))
1742 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1744 (while (not (eq modified-tick (buffer-modified-tick)))
1745 (setq modified-tick (buffer-modified-tick))
1746 (cond
1747 ((listp regexp)
1748 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1749 (regexp
1750 (gnus-simplify-buffer-fuzzy-step regexp)))
1751 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1752 (gnus-simplify-buffer-fuzzy-step
1753 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1754 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1756 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1757 (gnus-simplify-buffer-fuzzy-step " +" " ")
1758 (gnus-simplify-buffer-fuzzy-step " $")
1759 (gnus-simplify-buffer-fuzzy-step "^ +")))
1761 (defun gnus-simplify-subject-fuzzy (subject)
1762 "Simplify a subject string fuzzily.
1763 See `gnus-simplify-buffer-fuzzy' for details."
1764 (save-excursion
1765 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1766 (gnus-set-work-buffer)
1767 (let ((case-fold-search t))
1768 ;; Remove uninteresting prefixes.
1769 (when (and gnus-simplify-ignored-prefixes
1770 (string-match gnus-simplify-ignored-prefixes subject))
1771 (setq subject (substring subject (match-end 0))))
1772 (insert subject)
1773 (inline (gnus-simplify-buffer-fuzzy regexp))
1774 (buffer-string)))))
1776 (defsubst gnus-simplify-subject-fully (subject)
1777 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1778 (cond
1779 (gnus-simplify-subject-functions
1780 (gnus-map-function gnus-simplify-subject-functions subject))
1781 ((null gnus-summary-gather-subject-limit)
1782 (gnus-simplify-subject-re subject))
1783 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1784 (gnus-simplify-subject-fuzzy subject))
1785 ((numberp gnus-summary-gather-subject-limit)
1786 (truncate-string-to-width (gnus-simplify-subject-re subject)
1787 gnus-summary-gather-subject-limit))
1789 subject)))
1791 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1792 "Check whether two subjects are equal.
1793 If optional argument SIMPLE-FIRST is t, first argument is already
1794 simplified."
1795 (cond
1796 ((null simple-first)
1797 (equal (gnus-simplify-subject-fully s1)
1798 (gnus-simplify-subject-fully s2)))
1800 (equal s1
1801 (gnus-simplify-subject-fully s2)))))
1803 (defun gnus-summary-bubble-group ()
1804 "Increase the score of the current group.
1805 This is a handy function to add to `gnus-summary-exit-hook' to
1806 increase the score of each group you read."
1807 (gnus-group-add-score gnus-newsgroup-name))
1811 ;;; Gnus summary mode
1814 (put 'gnus-summary-mode 'mode-class 'special)
1816 (defvar gnus-article-commands-menu)
1818 ;; Non-orthogonal keys
1820 (gnus-define-keys gnus-summary-mode-map
1821 " " gnus-summary-next-page
1822 "\177" gnus-summary-prev-page
1823 [delete] gnus-summary-prev-page
1824 [backspace] gnus-summary-prev-page
1825 "\r" gnus-summary-scroll-up
1826 "\M-\r" gnus-summary-scroll-down
1827 "n" gnus-summary-next-unread-article
1828 "p" gnus-summary-prev-unread-article
1829 "N" gnus-summary-next-article
1830 "P" gnus-summary-prev-article
1831 "\M-\C-n" gnus-summary-next-same-subject
1832 "\M-\C-p" gnus-summary-prev-same-subject
1833 "\M-n" gnus-summary-next-unread-subject
1834 "\M-p" gnus-summary-prev-unread-subject
1835 "." gnus-summary-first-unread-article
1836 "," gnus-summary-best-unread-article
1837 "\M-s" gnus-summary-search-article-forward
1838 "\M-r" gnus-summary-search-article-backward
1839 "\M-S" gnus-summary-repeat-search-article-forward
1840 "\M-R" gnus-summary-repeat-search-article-backward
1841 "<" gnus-summary-beginning-of-article
1842 ">" gnus-summary-end-of-article
1843 "j" gnus-summary-goto-article
1844 "^" gnus-summary-refer-parent-article
1845 "\M-^" gnus-summary-refer-article
1846 "u" gnus-summary-tick-article-forward
1847 "!" gnus-summary-tick-article-forward
1848 "U" gnus-summary-tick-article-backward
1849 "d" gnus-summary-mark-as-read-forward
1850 "D" gnus-summary-mark-as-read-backward
1851 "E" gnus-summary-mark-as-expirable
1852 "\M-u" gnus-summary-clear-mark-forward
1853 "\M-U" gnus-summary-clear-mark-backward
1854 "k" gnus-summary-kill-same-subject-and-select
1855 "\C-k" gnus-summary-kill-same-subject
1856 "\M-\C-k" gnus-summary-kill-thread
1857 "\M-\C-l" gnus-summary-lower-thread
1858 "e" gnus-summary-edit-article
1859 "#" gnus-summary-mark-as-processable
1860 "\M-#" gnus-summary-unmark-as-processable
1861 "\M-\C-t" gnus-summary-toggle-threads
1862 "\M-\C-s" gnus-summary-show-thread
1863 "\M-\C-h" gnus-summary-hide-thread
1864 "\M-\C-f" gnus-summary-next-thread
1865 "\M-\C-b" gnus-summary-prev-thread
1866 [(meta down)] gnus-summary-next-thread
1867 [(meta up)] gnus-summary-prev-thread
1868 "\M-\C-u" gnus-summary-up-thread
1869 "\M-\C-d" gnus-summary-down-thread
1870 "&" gnus-summary-execute-command
1871 "c" gnus-summary-catchup-and-exit
1872 "\C-w" gnus-summary-mark-region-as-read
1873 "\C-t" gnus-summary-toggle-truncation
1874 "?" gnus-summary-mark-as-dormant
1875 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1876 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1877 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1878 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1879 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1880 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1881 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1882 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1883 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1884 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1885 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1886 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1887 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1888 "=" gnus-summary-expand-window
1889 "\C-x\C-s" gnus-summary-reselect-current-group
1890 "\M-g" gnus-summary-rescan-group
1891 "\C-c\C-r" gnus-summary-caesar-message
1892 "f" gnus-summary-followup
1893 "F" gnus-summary-followup-with-original
1894 "C" gnus-summary-cancel-article
1895 "r" gnus-summary-reply
1896 "R" gnus-summary-reply-with-original
1897 "\C-c\C-f" gnus-summary-mail-forward
1898 "o" gnus-summary-save-article
1899 "\C-o" gnus-summary-save-article-mail
1900 "|" gnus-summary-pipe-output
1901 "\M-k" gnus-summary-edit-local-kill
1902 "\M-K" gnus-summary-edit-global-kill
1903 ;; "V" gnus-version
1904 "\C-c\C-d" gnus-summary-describe-group
1905 "q" gnus-summary-exit
1906 "Q" gnus-summary-exit-no-update
1907 "\C-c\C-i" gnus-info-find-node
1908 gnus-mouse-2 gnus-mouse-pick-article
1909 [follow-link] mouse-face
1910 "m" gnus-summary-mail-other-window
1911 "a" gnus-summary-post-news
1912 "x" gnus-summary-limit-to-unread
1913 "s" gnus-summary-isearch-article
1914 [tab] gnus-summary-widget-forward
1915 [backtab] gnus-summary-widget-backward
1916 "t" gnus-summary-toggle-header
1917 "g" gnus-summary-show-article
1918 "l" gnus-summary-goto-last-article
1919 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1920 "\C-d" gnus-summary-enter-digest-group
1921 "\M-\C-d" gnus-summary-read-document
1922 "\M-\C-e" gnus-summary-edit-parameters
1923 "\M-\C-a" gnus-summary-customize-parameters
1924 "\C-c\C-b" gnus-bug
1925 "*" gnus-cache-enter-article
1926 "\M-*" gnus-cache-remove-article
1927 "\M-&" gnus-summary-universal-argument
1928 "\C-l" gnus-recenter
1929 "I" gnus-summary-increase-score
1930 "L" gnus-summary-lower-score
1931 "\M-i" gnus-symbolic-argument
1932 "h" gnus-summary-select-article-buffer
1934 "b" gnus-article-view-part
1935 "\M-t" gnus-summary-toggle-display-buttonized
1937 "V" gnus-summary-score-map
1938 "X" gnus-uu-extract-map
1939 "S" gnus-summary-send-map)
1941 ;; Sort of orthogonal keymap
1942 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1943 "t" gnus-summary-tick-article-forward
1944 "!" gnus-summary-tick-article-forward
1945 "d" gnus-summary-mark-as-read-forward
1946 "r" gnus-summary-mark-as-read-forward
1947 "c" gnus-summary-clear-mark-forward
1948 " " gnus-summary-clear-mark-forward
1949 "e" gnus-summary-mark-as-expirable
1950 "x" gnus-summary-mark-as-expirable
1951 "?" gnus-summary-mark-as-dormant
1952 "b" gnus-summary-set-bookmark
1953 "B" gnus-summary-remove-bookmark
1954 "#" gnus-summary-mark-as-processable
1955 "\M-#" gnus-summary-unmark-as-processable
1956 "S" gnus-summary-limit-include-expunged
1957 "C" gnus-summary-catchup
1958 "H" gnus-summary-catchup-to-here
1959 "h" gnus-summary-catchup-from-here
1960 "\C-c" gnus-summary-catchup-all
1961 "k" gnus-summary-kill-same-subject-and-select
1962 "K" gnus-summary-kill-same-subject
1963 "P" gnus-uu-mark-map)
1965 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1966 "c" gnus-summary-clear-above
1967 "u" gnus-summary-tick-above
1968 "m" gnus-summary-mark-above
1969 "k" gnus-summary-kill-below)
1971 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1972 "/" gnus-summary-limit-to-subject
1973 "n" gnus-summary-limit-to-articles
1974 "b" gnus-summary-limit-to-bodies
1975 "h" gnus-summary-limit-to-headers
1976 "w" gnus-summary-pop-limit
1977 "s" gnus-summary-limit-to-subject
1978 "a" gnus-summary-limit-to-author
1979 "u" gnus-summary-limit-to-unread
1980 "m" gnus-summary-limit-to-marks
1981 "M" gnus-summary-limit-exclude-marks
1982 "v" gnus-summary-limit-to-score
1983 "*" gnus-summary-limit-include-cached
1984 "D" gnus-summary-limit-include-dormant
1985 "T" gnus-summary-limit-include-thread
1986 "d" gnus-summary-limit-exclude-dormant
1987 "t" gnus-summary-limit-to-age
1988 "." gnus-summary-limit-to-unseen
1989 "x" gnus-summary-limit-to-extra
1990 "p" gnus-summary-limit-to-display-predicate
1991 "E" gnus-summary-limit-include-expunged
1992 "c" gnus-summary-limit-exclude-childless-dormant
1993 "C" gnus-summary-limit-mark-excluded-as-read
1994 "o" gnus-summary-insert-old-articles
1995 "N" gnus-summary-insert-new-articles
1996 "S" gnus-summary-limit-to-singletons
1997 "r" gnus-summary-limit-to-replied
1998 "R" gnus-summary-limit-to-recipient
1999 "A" gnus-summary-limit-to-address)
2001 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2002 "n" gnus-summary-next-unread-article
2003 "p" gnus-summary-prev-unread-article
2004 "N" gnus-summary-next-article
2005 "P" gnus-summary-prev-article
2006 "\C-n" gnus-summary-next-same-subject
2007 "\C-p" gnus-summary-prev-same-subject
2008 "\M-n" gnus-summary-next-unread-subject
2009 "\M-p" gnus-summary-prev-unread-subject
2010 "f" gnus-summary-first-unread-article
2011 "b" gnus-summary-best-unread-article
2012 "j" gnus-summary-goto-article
2013 "g" gnus-summary-goto-subject
2014 "l" gnus-summary-goto-last-article
2015 "o" gnus-summary-pop-article)
2017 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2018 "k" gnus-summary-kill-thread
2019 "E" gnus-summary-expire-thread
2020 "l" gnus-summary-lower-thread
2021 "i" gnus-summary-raise-thread
2022 "T" gnus-summary-toggle-threads
2023 "t" gnus-summary-rethread-current
2024 "^" gnus-summary-reparent-thread
2025 "\M-^" gnus-summary-reparent-children
2026 "s" gnus-summary-show-thread
2027 "S" gnus-summary-show-all-threads
2028 "h" gnus-summary-hide-thread
2029 "H" gnus-summary-hide-all-threads
2030 "n" gnus-summary-next-thread
2031 "p" gnus-summary-prev-thread
2032 "u" gnus-summary-up-thread
2033 "o" gnus-summary-top-thread
2034 "d" gnus-summary-down-thread
2035 "#" gnus-uu-mark-thread
2036 "\M-#" gnus-uu-unmark-thread)
2038 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2039 "g" gnus-summary-prepare
2040 "c" gnus-summary-insert-cached-articles
2041 "d" gnus-summary-insert-dormant-articles
2042 "t" gnus-summary-insert-ticked-articles)
2044 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2045 "c" gnus-summary-catchup-and-exit
2046 "C" gnus-summary-catchup-all-and-exit
2047 "E" gnus-summary-exit-no-update
2048 "Q" gnus-summary-exit
2049 "Z" gnus-summary-exit
2050 "n" gnus-summary-catchup-and-goto-next-group
2051 "p" gnus-summary-catchup-and-goto-prev-group
2052 "R" gnus-summary-reselect-current-group
2053 "G" gnus-summary-rescan-group
2054 "N" gnus-summary-next-group
2055 "s" gnus-summary-save-newsrc
2056 "P" gnus-summary-prev-group)
2058 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2059 " " gnus-summary-next-page
2060 "n" gnus-summary-next-page
2061 "\177" gnus-summary-prev-page
2062 [delete] gnus-summary-prev-page
2063 "p" gnus-summary-prev-page
2064 "\r" gnus-summary-scroll-up
2065 "\M-\r" gnus-summary-scroll-down
2066 "<" gnus-summary-beginning-of-article
2067 ">" gnus-summary-end-of-article
2068 "b" gnus-summary-beginning-of-article
2069 "e" gnus-summary-end-of-article
2070 "^" gnus-summary-refer-parent-article
2071 "r" gnus-summary-refer-parent-article
2072 "C" gnus-summary-show-complete-article
2073 "D" gnus-summary-enter-digest-group
2074 "R" gnus-summary-refer-references
2075 "T" gnus-summary-refer-thread
2076 "W" gnus-warp-to-article
2077 "g" gnus-summary-show-article
2078 "s" gnus-summary-isearch-article
2079 [tab] gnus-summary-widget-forward
2080 [backtab] gnus-summary-widget-backward
2081 "P" gnus-summary-print-article
2082 "S" gnus-sticky-article
2083 "M" gnus-mailing-list-insinuate
2084 "t" gnus-article-babel)
2086 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2087 "b" gnus-article-add-buttons
2088 "B" gnus-article-add-buttons-to-head
2089 "o" gnus-article-treat-overstrike
2090 "e" gnus-article-emphasize
2091 "w" gnus-article-fill-cited-article
2092 "Q" gnus-article-fill-long-lines
2093 "L" gnus-article-toggle-truncate-lines
2094 "C" gnus-article-capitalize-sentences
2095 "c" gnus-article-remove-cr
2096 "q" gnus-article-de-quoted-unreadable
2097 "6" gnus-article-de-base64-unreadable
2098 "Z" gnus-article-decode-HZ
2099 "A" gnus-article-treat-ansi-sequences
2100 "h" gnus-article-wash-html
2101 "u" gnus-article-unsplit-urls
2102 "s" gnus-summary-force-verify-and-decrypt
2103 "f" gnus-article-display-x-face
2104 "l" gnus-summary-stop-page-breaking
2105 "r" gnus-summary-caesar-message
2106 "m" gnus-summary-morse-message
2107 "t" gnus-summary-toggle-header
2108 "g" gnus-treat-smiley
2109 "v" gnus-summary-verbose-headers
2110 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2111 "p" gnus-article-verify-x-pgp-sig
2112 "d" gnus-article-treat-dumbquotes
2113 "U" gnus-article-treat-non-ascii
2114 "i" gnus-summary-idna-message)
2116 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2117 ;; mnemonic: deuglif*Y*
2118 "u" gnus-article-outlook-unwrap-lines
2119 "a" gnus-article-outlook-repair-attribution
2120 "c" gnus-article-outlook-rearrange-citation
2121 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2123 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2124 "a" gnus-article-hide
2125 "h" gnus-article-hide-headers
2126 "b" gnus-article-hide-boring-headers
2127 "s" gnus-article-hide-signature
2128 "c" gnus-article-hide-citation
2129 "C" gnus-article-hide-citation-in-followups
2130 "l" gnus-article-hide-list-identifiers
2131 "B" gnus-article-strip-banner
2132 "P" gnus-article-hide-pem
2133 "\C-c" gnus-article-hide-citation-maybe)
2135 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2136 "a" gnus-article-highlight
2137 "h" gnus-article-highlight-headers
2138 "c" gnus-article-highlight-citation
2139 "s" gnus-article-highlight-signature)
2141 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2142 "f" gnus-article-treat-fold-headers
2143 "u" gnus-article-treat-unfold-headers
2144 "n" gnus-article-treat-fold-newsgroups)
2146 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2147 "x" gnus-article-display-x-face
2148 "d" gnus-article-display-face
2149 "s" gnus-treat-smiley
2150 "D" gnus-article-remove-images
2151 "W" gnus-article-show-images
2152 "f" gnus-treat-from-picon
2153 "m" gnus-treat-mail-picon
2154 "n" gnus-treat-newsgroups-picon
2155 "g" gnus-treat-from-gravatar
2156 "h" gnus-treat-mail-gravatar)
2158 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2159 "w" gnus-article-decode-mime-words
2160 "c" gnus-article-decode-charset
2161 "v" gnus-mime-view-all-parts
2162 "b" gnus-article-view-part)
2164 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2165 "z" gnus-article-date-ut
2166 "u" gnus-article-date-ut
2167 "l" gnus-article-date-local
2168 "p" gnus-article-date-english
2169 "e" gnus-article-date-lapsed
2170 "o" gnus-article-date-original
2171 "i" gnus-article-date-iso8601
2172 "s" gnus-article-date-user)
2174 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2175 "t" gnus-article-remove-trailing-blank-lines
2176 "l" gnus-article-strip-leading-blank-lines
2177 "m" gnus-article-strip-multiple-blank-lines
2178 "a" gnus-article-strip-blank-lines
2179 "A" gnus-article-strip-all-blank-lines
2180 "s" gnus-article-strip-leading-space
2181 "e" gnus-article-strip-trailing-space
2182 "w" gnus-article-remove-leading-whitespace)
2184 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2185 "v" gnus-version
2186 "d" gnus-summary-describe-group
2187 "h" gnus-summary-describe-briefly
2188 "i" gnus-info-find-node)
2190 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2191 "e" gnus-summary-expire-articles
2192 "\M-\C-e" gnus-summary-expire-articles-now
2193 "\177" gnus-summary-delete-article
2194 [delete] gnus-summary-delete-article
2195 [backspace] gnus-summary-delete-article
2196 "m" gnus-summary-move-article
2197 "r" gnus-summary-respool-article
2198 "w" gnus-summary-edit-article
2199 "c" gnus-summary-copy-article
2200 "B" gnus-summary-crosspost-article
2201 "q" gnus-summary-respool-query
2202 "t" gnus-summary-respool-trace
2203 "i" gnus-summary-import-article
2204 "I" gnus-summary-create-article
2205 "p" gnus-summary-article-posted-p)
2207 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2208 "o" gnus-summary-save-article
2209 "m" gnus-summary-save-article-mail
2210 "F" gnus-summary-write-article-file
2211 "r" gnus-summary-save-article-rmail
2212 "f" gnus-summary-save-article-file
2213 "b" gnus-summary-save-article-body-file
2214 "B" gnus-summary-write-article-body-file
2215 "h" gnus-summary-save-article-folder
2216 "v" gnus-summary-save-article-vm
2217 "p" gnus-summary-pipe-output
2218 "P" gnus-summary-muttprint)
2220 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2221 "b" gnus-summary-display-buttonized
2222 "m" gnus-summary-repair-multipart
2223 "v" gnus-article-view-part
2224 "o" gnus-article-save-part
2225 "O" gnus-article-save-part-and-strip
2226 "r" gnus-article-replace-part
2227 "d" gnus-article-delete-part
2228 "t" gnus-article-view-part-as-type
2229 "j" gnus-article-jump-to-part
2230 "c" gnus-article-copy-part
2231 "C" gnus-article-view-part-as-charset
2232 "e" gnus-article-view-part-externally
2233 "H" gnus-article-browse-html-article
2234 "E" gnus-article-encrypt-body
2235 "i" gnus-article-inline-part
2236 "|" gnus-article-pipe-part)
2238 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2239 "p" gnus-summary-mark-as-processable
2240 "u" gnus-summary-unmark-as-processable
2241 "U" gnus-summary-unmark-all-processable
2242 "v" gnus-uu-mark-over
2243 "s" gnus-uu-mark-series
2244 "r" gnus-uu-mark-region
2245 "g" gnus-uu-unmark-region
2246 "R" gnus-uu-mark-by-regexp
2247 "G" gnus-uu-unmark-by-regexp
2248 "t" gnus-uu-mark-thread
2249 "T" gnus-uu-unmark-thread
2250 "a" gnus-uu-mark-all
2251 "b" gnus-uu-mark-buffer
2252 "S" gnus-uu-mark-sparse
2253 "k" gnus-summary-kill-process-mark
2254 "y" gnus-summary-yank-process-mark
2255 "w" gnus-summary-save-process-mark
2256 "i" gnus-uu-invert-processable)
2258 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2259 ;;"x" gnus-uu-extract-any
2260 "m" gnus-summary-save-parts
2261 "u" gnus-uu-decode-uu
2262 "U" gnus-uu-decode-uu-and-save
2263 "s" gnus-uu-decode-unshar
2264 "S" gnus-uu-decode-unshar-and-save
2265 "o" gnus-uu-decode-save
2266 "O" gnus-uu-decode-save
2267 "b" gnus-uu-decode-binhex
2268 "B" gnus-uu-decode-binhex
2269 "Y" gnus-uu-decode-yenc
2270 "p" gnus-uu-decode-postscript
2271 "P" gnus-uu-decode-postscript-and-save)
2273 (gnus-define-keys
2274 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2275 "u" gnus-uu-decode-uu-view
2276 "U" gnus-uu-decode-uu-and-save-view
2277 "s" gnus-uu-decode-unshar-view
2278 "S" gnus-uu-decode-unshar-and-save-view
2279 "o" gnus-uu-decode-save-view
2280 "O" gnus-uu-decode-save-view
2281 "b" gnus-uu-decode-binhex-view
2282 "B" gnus-uu-decode-binhex-view
2283 "p" gnus-uu-decode-postscript-view
2284 "P" gnus-uu-decode-postscript-and-save-view)
2286 (defvar gnus-article-post-menu nil)
2288 (defconst gnus-summary-menu-maxlen 20)
2290 (defun gnus-summary-menu-split (menu)
2291 ;; If we have lots of elements, divide them into groups of 20
2292 ;; and make a pane (or submenu) for each one.
2293 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2294 (let ((menu menu) sublists next
2295 (i 1))
2296 (while menu
2297 ;; Pull off the next gnus-summary-menu-maxlen elements
2298 ;; and make them the next element of sublist.
2299 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2300 (if next
2301 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2302 nil))
2303 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2304 (aref (car (last menu)) 0)) menu)
2305 sublists))
2306 (setq i (1+ i))
2307 (setq menu next))
2308 (nreverse sublists))
2309 ;; Few elements--put them all in one pane.
2310 menu))
2312 (defun gnus-summary-make-menu-bar ()
2313 (gnus-turn-off-edit-menu 'summary)
2315 (unless (boundp 'gnus-summary-misc-menu)
2317 (easy-menu-define
2318 gnus-summary-kill-menu gnus-summary-mode-map ""
2319 (cons
2320 "Score"
2321 (nconc
2322 (list
2323 ["Customize" gnus-score-customize t])
2324 (gnus-make-score-map 'increase)
2325 (gnus-make-score-map 'lower)
2326 '(("Mark"
2327 ["Kill below" gnus-summary-kill-below t]
2328 ["Mark above" gnus-summary-mark-above t]
2329 ["Tick above" gnus-summary-tick-above t]
2330 ["Clear above" gnus-summary-clear-above t])
2331 ["Current score" gnus-summary-current-score t]
2332 ["Set score" gnus-summary-set-score t]
2333 ["Switch current score file..." gnus-score-change-score-file t]
2334 ["Set mark below..." gnus-score-set-mark-below t]
2335 ["Set expunge below..." gnus-score-set-expunge-below t]
2336 ["Edit current score file" gnus-score-edit-current-scores t]
2337 ["Edit score file..." gnus-score-edit-file t]
2338 ["Trace score" gnus-score-find-trace t]
2339 ["Find words" gnus-score-find-favourite-words t]
2340 ["Rescore buffer" gnus-summary-rescore t]
2341 ["Increase score..." gnus-summary-increase-score t]
2342 ["Lower score..." gnus-summary-lower-score t]))))
2344 ;; Define both the Article menu in the summary buffer and the
2345 ;; equivalent Commands menu in the article buffer here for
2346 ;; consistency.
2347 (let ((innards
2348 `(("Hide"
2349 ["All" gnus-article-hide t]
2350 ["Headers" gnus-article-hide-headers t]
2351 ["Signature" gnus-article-hide-signature t]
2352 ["Citation" gnus-article-hide-citation t]
2353 ["List identifiers" gnus-article-hide-list-identifiers t]
2354 ["Banner" gnus-article-strip-banner t]
2355 ["Boring headers" gnus-article-hide-boring-headers t])
2356 ("Highlight"
2357 ["All" gnus-article-highlight t]
2358 ["Headers" gnus-article-highlight-headers t]
2359 ["Signature" gnus-article-highlight-signature t]
2360 ["Citation" gnus-article-highlight-citation t])
2361 ("MIME"
2362 ["Words" gnus-article-decode-mime-words t]
2363 ["Charset" gnus-article-decode-charset t]
2364 ["QP" gnus-article-de-quoted-unreadable t]
2365 ["Base64" gnus-article-de-base64-unreadable t]
2366 ["View MIME buttons" gnus-summary-display-buttonized t]
2367 ["View all" gnus-mime-view-all-parts t]
2368 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2369 ["Encrypt body" gnus-article-encrypt-body
2370 :active (not (gnus-group-read-only-p))
2371 ,@(if (featurep 'xemacs) nil
2372 '(:help "Encrypt the message body on disk"))]
2373 ["Extract all parts..." gnus-summary-save-parts t]
2374 ("Multipart"
2375 ["Repair multipart" gnus-summary-repair-multipart t]
2376 ["Pipe part..." gnus-article-pipe-part t]
2377 ["Inline part" gnus-article-inline-part t]
2378 ["View part as type..." gnus-article-view-part-as-type t]
2379 ["Encrypt body" gnus-article-encrypt-body
2380 :active (not (gnus-group-read-only-p))
2381 ,@(if (featurep 'xemacs) nil
2382 '(:help "Encrypt the message body on disk"))]
2383 ["View part externally" gnus-article-view-part-externally t]
2384 ["View HTML parts in browser" gnus-article-browse-html-article t]
2385 ["View part with charset..." gnus-article-view-part-as-charset t]
2386 ["Copy part" gnus-article-copy-part t]
2387 ["Save part..." gnus-article-save-part t]
2388 ["View part" gnus-article-view-part t]))
2389 ("Date"
2390 ["Local" gnus-article-date-local t]
2391 ["ISO8601" gnus-article-date-iso8601 t]
2392 ["UT" gnus-article-date-ut t]
2393 ["Original" gnus-article-date-original t]
2394 ["Lapsed" gnus-article-date-lapsed t]
2395 ["User-defined" gnus-article-date-user t])
2396 ("Display"
2397 ["Remove images" gnus-article-remove-images t]
2398 ["Toggle smiley" gnus-treat-smiley t]
2399 ["Show X-Face" gnus-article-display-x-face t]
2400 ["Show picons in From" gnus-treat-from-picon t]
2401 ["Show picons in mail headers" gnus-treat-mail-picon t]
2402 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2403 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2404 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2405 ("View as different encoding"
2406 ,@(gnus-summary-menu-split
2407 (mapcar
2408 (lambda (cs)
2409 ;; Since easymenu under Emacs doesn't allow
2410 ;; lambda forms for menu commands, we should
2411 ;; provide intern'ed function symbols.
2412 (let ((command (intern (format "\
2413 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2414 (fset command
2415 `(lambda ()
2416 (interactive)
2417 (let ((gnus-summary-show-article-charset-alist
2418 '((1 . ,cs))))
2419 (gnus-summary-show-article 1))))
2420 `[,(symbol-name cs) ,command t]))
2421 (sort (if (fboundp 'coding-system-list)
2422 (coding-system-list)
2423 (mapcar 'car mm-mime-mule-charset-alist))
2424 'string<)))))
2425 ("Washing"
2426 ("Remove Blanks"
2427 ["Leading" gnus-article-strip-leading-blank-lines t]
2428 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2429 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2430 ["All of the above" gnus-article-strip-blank-lines t]
2431 ["All" gnus-article-strip-all-blank-lines t]
2432 ["Leading space" gnus-article-strip-leading-space t]
2433 ["Trailing space" gnus-article-strip-trailing-space t]
2434 ["Leading space in headers"
2435 gnus-article-remove-leading-whitespace t])
2436 ["Overstrike" gnus-article-treat-overstrike t]
2437 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2438 ["Non-ASCII" gnus-article-treat-non-ascii t]
2439 ["Emphasis" gnus-article-emphasize t]
2440 ["Word wrap" gnus-article-fill-cited-article t]
2441 ["Fill long lines" gnus-article-fill-long-lines t]
2442 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2443 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2444 ["Remove CR" gnus-article-remove-cr t]
2445 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2446 ["Base64" gnus-article-de-base64-unreadable t]
2447 ["Rot 13" gnus-summary-caesar-message
2448 ,@(if (featurep 'xemacs) '(t)
2449 '(:help "\"Caesar rotate\" article by 13"))]
2450 ["De-IDNA" gnus-summary-idna-message t]
2451 ["Morse decode" gnus-summary-morse-message t]
2452 ["Unix pipe..." gnus-summary-pipe-message t]
2453 ["Add buttons" gnus-article-add-buttons t]
2454 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2455 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2456 ["Verbose header" gnus-summary-verbose-headers t]
2457 ["Toggle header" gnus-summary-toggle-header t]
2458 ["Unfold headers" gnus-article-treat-unfold-headers t]
2459 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2460 ["Html" gnus-article-wash-html t]
2461 ["Unsplit URLs" gnus-article-unsplit-urls t]
2462 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2463 ["Decode HZ" gnus-article-decode-HZ t]
2464 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2465 ("(Outlook) Deuglify"
2466 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2467 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2468 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2469 ["Full (Outlook) deuglify"
2470 gnus-article-outlook-deuglify-article t])
2472 ("Output"
2473 ["Save in default format..." gnus-summary-save-article
2474 ,@(if (featurep 'xemacs) '(t)
2475 '(:help "Save article using default method"))]
2476 ["Save in file..." gnus-summary-save-article-file
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Save article in file"))]
2479 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2480 ["Save in MH folder..." gnus-summary-save-article-folder t]
2481 ["Save in VM folder..." gnus-summary-save-article-vm t]
2482 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2483 ["Save body in file..." gnus-summary-save-article-body-file t]
2484 ["Pipe through a filter..." gnus-summary-pipe-output t]
2485 ["Print with Muttprint..." gnus-summary-muttprint t]
2486 ["Print" gnus-summary-print-article
2487 ,@(if (featurep 'xemacs) '(t)
2488 '(:help "Generate and print a PostScript image"))])
2489 ("Copy, move,... (Backend)"
2490 ,@(if (featurep 'xemacs) nil
2491 '(:help "Copying, moving, expiring articles..."))
2492 ["Respool article..." gnus-summary-respool-article t]
2493 ["Move article..." gnus-summary-move-article
2494 (gnus-check-backend-function
2495 'request-move-article gnus-newsgroup-name)]
2496 ["Copy article..." gnus-summary-copy-article t]
2497 ["Crosspost article..." gnus-summary-crosspost-article
2498 (gnus-check-backend-function
2499 'request-replace-article gnus-newsgroup-name)]
2500 ["Import file..." gnus-summary-import-article
2501 (gnus-check-backend-function
2502 'request-accept-article gnus-newsgroup-name)]
2503 ["Create article..." gnus-summary-create-article
2504 (gnus-check-backend-function
2505 'request-accept-article gnus-newsgroup-name)]
2506 ["Check if posted" gnus-summary-article-posted-p t]
2507 ["Edit article" gnus-summary-edit-article
2508 (not (gnus-group-read-only-p))]
2509 ["Delete article" gnus-summary-delete-article
2510 (gnus-check-backend-function
2511 'request-expire-articles gnus-newsgroup-name)]
2512 ["Query respool" gnus-summary-respool-query t]
2513 ["Trace respool" gnus-summary-respool-trace t]
2514 ["Delete expirable articles" gnus-summary-expire-articles-now
2515 (gnus-check-backend-function
2516 'request-expire-articles gnus-newsgroup-name)])
2517 ("Extract"
2518 ["Uudecode" gnus-uu-decode-uu
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Decode uuencoded article(s)"))]
2521 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2522 ["Unshar" gnus-uu-decode-unshar t]
2523 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2524 ["Save" gnus-uu-decode-save t]
2525 ["Binhex" gnus-uu-decode-binhex t]
2526 ["PostScript" gnus-uu-decode-postscript t]
2527 ["All MIME parts" gnus-summary-save-parts t])
2528 ("Cache"
2529 ["Enter article" gnus-cache-enter-article t]
2530 ["Remove article" gnus-cache-remove-article t])
2531 ["Translate" gnus-article-babel t]
2532 ["Select article buffer" gnus-summary-select-article-buffer t]
2533 ["Make article buffer sticky" gnus-sticky-article t]
2534 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2535 ["Isearch article..." gnus-summary-isearch-article t]
2536 ["Beginning of the article" gnus-summary-beginning-of-article t]
2537 ["End of the article" gnus-summary-end-of-article t]
2538 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2539 ["Fetch referenced articles" gnus-summary-refer-references t]
2540 ["Fetch current thread" gnus-summary-refer-thread t]
2541 ["Fetch article with id..." gnus-summary-refer-article t]
2542 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2543 ["Redisplay" gnus-summary-show-article t]
2544 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2545 (easy-menu-define
2546 gnus-summary-article-menu gnus-summary-mode-map ""
2547 (cons "Article" innards))
2549 (if (not (keymapp gnus-summary-article-menu))
2550 (easy-menu-define
2551 gnus-article-commands-menu gnus-article-mode-map ""
2552 (cons "Commands" innards))
2553 ;; in Emacs, don't share menu.
2554 (setq gnus-article-commands-menu
2555 (copy-keymap gnus-summary-article-menu))
2556 (define-key gnus-article-mode-map [menu-bar commands]
2557 (cons "Commands" gnus-article-commands-menu))))
2559 (easy-menu-define
2560 gnus-summary-thread-menu gnus-summary-mode-map ""
2561 '("Threads"
2562 ["Find all messages in thread" gnus-summary-refer-thread t]
2563 ["Toggle threading" gnus-summary-toggle-threads t]
2564 ["Hide threads" gnus-summary-hide-all-threads t]
2565 ["Show threads" gnus-summary-show-all-threads t]
2566 ["Hide thread" gnus-summary-hide-thread t]
2567 ["Show thread" gnus-summary-show-thread t]
2568 ["Go to next thread" gnus-summary-next-thread t]
2569 ["Go to previous thread" gnus-summary-prev-thread t]
2570 ["Go down thread" gnus-summary-down-thread t]
2571 ["Go up thread" gnus-summary-up-thread t]
2572 ["Top of thread" gnus-summary-top-thread t]
2573 ["Mark thread as read" gnus-summary-kill-thread t]
2574 ["Mark thread as expired" gnus-summary-expire-thread t]
2575 ["Lower thread score" gnus-summary-lower-thread t]
2576 ["Raise thread score" gnus-summary-raise-thread t]
2577 ["Rethread current" gnus-summary-rethread-current t]))
2579 (easy-menu-define
2580 gnus-summary-post-menu gnus-summary-mode-map ""
2581 `("Post"
2582 ["Send a message (mail or news)" gnus-summary-post-news
2583 ,@(if (featurep 'xemacs) '(t)
2584 '(:help "Compose a new message (mail or news)"))]
2585 ["Followup" gnus-summary-followup
2586 ,@(if (featurep 'xemacs) '(t)
2587 '(:help "Post followup to this article"))]
2588 ["Followup and yank" gnus-summary-followup-with-original
2589 ,@(if (featurep 'xemacs) '(t)
2590 '(:help "Post followup to this article, quoting its contents"))]
2591 ["Supersede article" gnus-summary-supersede-article t]
2592 ["Cancel article" gnus-summary-cancel-article
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Cancel an article you posted"))]
2595 ["Reply" gnus-summary-reply t]
2596 ["Reply and yank" gnus-summary-reply-with-original t]
2597 ["Wide reply" gnus-summary-wide-reply t]
2598 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2599 ,@(if (featurep 'xemacs) '(t)
2600 '(:help "Mail a reply, quoting this article"))]
2601 ["Very wide reply" gnus-summary-very-wide-reply t]
2602 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2603 ,@(if (featurep 'xemacs) '(t)
2604 '(:help "Mail a very wide reply, quoting this article"))]
2605 ["Mail forward" gnus-summary-mail-forward t]
2606 ["Post forward" gnus-summary-post-forward t]
2607 ["Digest and mail" gnus-uu-digest-mail-forward t]
2608 ["Digest and post" gnus-uu-digest-post-forward t]
2609 ["Resend message" gnus-summary-resend-message t]
2610 ["Resend message edit" gnus-summary-resend-message-edit t]
2611 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2612 ["Send a mail" gnus-summary-mail-other-window t]
2613 ["Create a local message" gnus-summary-news-other-window t]
2614 ["Uuencode and post" gnus-uu-post-news
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Post a uuencoded article"))]
2617 ["Followup via news" gnus-summary-followup-to-mail t]
2618 ["Followup via news and yank"
2619 gnus-summary-followup-to-mail-with-original t]
2620 ["Strip signature on reply"
2621 (lambda ()
2622 (interactive)
2623 (if (not (memq message-cite-function
2624 '(message-cite-original-without-signature
2625 message-cite-original)))
2626 ;; Stupid workaround for XEmacs not honoring :visible.
2627 (message "Can't toggle this value of `message-cite-function'")
2628 (setq message-cite-function
2629 (if (eq message-cite-function
2630 'message-cite-original-without-signature)
2631 'message-cite-original
2632 'message-cite-original-without-signature))))
2633 ;; XEmacs barfs on :visible.
2634 ,@(if (featurep 'xemacs) nil
2635 '(:visible (memq message-cite-function
2636 '(message-cite-original-without-signature
2637 message-cite-original))))
2638 :style toggle
2639 :selected (eq message-cite-function
2640 'message-cite-original-without-signature)
2641 ,@(if (featurep 'xemacs) nil
2642 '(:help "Strip signature from cited article when replying."))]
2643 ;;("Draft"
2644 ;;["Send" gnus-summary-send-draft t]
2645 ;;["Send bounced" gnus-resend-bounced-mail t])
2648 (cond
2649 ((not (keymapp gnus-summary-post-menu))
2650 (setq gnus-article-post-menu gnus-summary-post-menu))
2651 ((not gnus-article-post-menu)
2652 ;; Don't share post menu.
2653 (setq gnus-article-post-menu
2654 (copy-keymap gnus-summary-post-menu))))
2655 (define-key gnus-article-mode-map [menu-bar post]
2656 (cons "Post" gnus-article-post-menu))
2658 (easy-menu-define
2659 gnus-summary-misc-menu gnus-summary-mode-map ""
2660 `("Gnus"
2661 ("Mark Read"
2662 ["Mark as read" gnus-summary-mark-as-read-forward t]
2663 ["Mark same subject and select"
2664 gnus-summary-kill-same-subject-and-select t]
2665 ["Mark same subject" gnus-summary-kill-same-subject t]
2666 ["Catchup" gnus-summary-catchup
2667 ,@(if (featurep 'xemacs) '(t)
2668 '(:help "Mark unread articles in this group as read"))]
2669 ["Catchup all" gnus-summary-catchup-all t]
2670 ["Catchup to here" gnus-summary-catchup-to-here t]
2671 ["Catchup from here" gnus-summary-catchup-from-here t]
2672 ["Catchup region" gnus-summary-mark-region-as-read
2673 (gnus-mark-active-p)]
2674 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2675 ("Mark Various"
2676 ["Tick" gnus-summary-tick-article-forward t]
2677 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2678 ["Remove marks" gnus-summary-clear-mark-forward t]
2679 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2680 ["Set bookmark" gnus-summary-set-bookmark t]
2681 ["Remove bookmark" gnus-summary-remove-bookmark t])
2682 ("Limit to"
2683 ["Marks..." gnus-summary-limit-to-marks t]
2684 ["Subject..." gnus-summary-limit-to-subject t]
2685 ["Author..." gnus-summary-limit-to-author t]
2686 ["Recipient..." gnus-summary-limit-to-recipient t]
2687 ["Address..." gnus-summary-limit-to-address t]
2688 ["Age..." gnus-summary-limit-to-age t]
2689 ["Extra..." gnus-summary-limit-to-extra t]
2690 ["Score..." gnus-summary-limit-to-score t]
2691 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2692 ["Unread" gnus-summary-limit-to-unread t]
2693 ["Unseen" gnus-summary-limit-to-unseen t]
2694 ["Singletons" gnus-summary-limit-to-singletons t]
2695 ["Replied" gnus-summary-limit-to-replied t]
2696 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2697 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2698 ["Pop limit" gnus-summary-pop-limit t]
2699 ["Show dormant" gnus-summary-limit-include-dormant t]
2700 ["Hide childless dormant"
2701 gnus-summary-limit-exclude-childless-dormant t]
2702 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2703 ["Hide marked" gnus-summary-limit-exclude-marks t]
2704 ["Show expunged" gnus-summary-limit-include-expunged t])
2705 ("Process Mark"
2706 ["Set mark" gnus-summary-mark-as-processable t]
2707 ["Remove mark" gnus-summary-unmark-as-processable t]
2708 ["Remove all marks" gnus-summary-unmark-all-processable t]
2709 ["Invert marks" gnus-uu-invert-processable t]
2710 ["Mark above" gnus-uu-mark-over t]
2711 ["Mark series" gnus-uu-mark-series t]
2712 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2713 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2714 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2715 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2716 ["Mark all" gnus-uu-mark-all t]
2717 ["Mark buffer" gnus-uu-mark-buffer t]
2718 ["Mark sparse" gnus-uu-mark-sparse t]
2719 ["Mark thread" gnus-uu-mark-thread t]
2720 ["Unmark thread" gnus-uu-unmark-thread t]
2721 ("Process Mark Sets"
2722 ["Kill" gnus-summary-kill-process-mark t]
2723 ["Yank" gnus-summary-yank-process-mark
2724 gnus-newsgroup-process-stack]
2725 ["Save" gnus-summary-save-process-mark t]
2726 ["Run command on marked..." gnus-summary-universal-argument t]))
2727 ("Registry Marks")
2728 ("Scroll article"
2729 ["Page forward" gnus-summary-next-page
2730 ,@(if (featurep 'xemacs) '(t)
2731 '(:help "Show next page of article"))]
2732 ["Page backward" gnus-summary-prev-page
2733 ,@(if (featurep 'xemacs) '(t)
2734 '(:help "Show previous page of article"))]
2735 ["Line forward" gnus-summary-scroll-up t])
2736 ("Move"
2737 ["Next unread article" gnus-summary-next-unread-article t]
2738 ["Previous unread article" gnus-summary-prev-unread-article t]
2739 ["Next article" gnus-summary-next-article t]
2740 ["Previous article" gnus-summary-prev-article t]
2741 ["Next unread subject" gnus-summary-next-unread-subject t]
2742 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2743 ["Next article same subject" gnus-summary-next-same-subject t]
2744 ["Previous article same subject" gnus-summary-prev-same-subject t]
2745 ["First unread article" gnus-summary-first-unread-article t]
2746 ["Best unread article" gnus-summary-best-unread-article t]
2747 ["Go to subject number..." gnus-summary-goto-subject t]
2748 ["Go to article number..." gnus-summary-goto-article t]
2749 ["Go to the last article" gnus-summary-goto-last-article t]
2750 ["Pop article off history" gnus-summary-pop-article t])
2751 ("Sort"
2752 ["Sort by number" gnus-summary-sort-by-number t]
2753 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2754 ["Sort by author" gnus-summary-sort-by-author t]
2755 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2756 ["Sort by subject" gnus-summary-sort-by-subject t]
2757 ["Sort by date" gnus-summary-sort-by-date t]
2758 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2759 ["Sort by score" gnus-summary-sort-by-score t]
2760 ["Sort by lines" gnus-summary-sort-by-lines t]
2761 ["Sort by characters" gnus-summary-sort-by-chars t]
2762 ["Randomize" gnus-summary-sort-by-random t]
2763 ["Original sort" gnus-summary-sort-by-original t])
2764 ("Help"
2765 ["Describe group" gnus-summary-describe-group t]
2766 ["Read manual" gnus-info-find-node t])
2767 ("Modes"
2768 ["Pick and read" gnus-pick-mode t]
2769 ["Binary" gnus-binary-mode t])
2770 ("Regeneration"
2771 ["Regenerate" gnus-summary-prepare t]
2772 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2773 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2774 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2775 ["Toggle threading" gnus-summary-toggle-threads t])
2776 ["See old articles" gnus-summary-insert-old-articles t]
2777 ["See new articles" gnus-summary-insert-new-articles t]
2778 ["Filter articles..." gnus-summary-execute-command t]
2779 ["Run command on articles..." gnus-summary-universal-argument t]
2780 ["Search articles forward..." gnus-summary-search-article-forward t]
2781 ["Search articles backward..." gnus-summary-search-article-backward t]
2782 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2783 ["Expand window" gnus-summary-expand-window t]
2784 ["Expire expirable articles" gnus-summary-expire-articles
2785 (gnus-check-backend-function
2786 'request-expire-articles gnus-newsgroup-name)]
2787 ["Edit local kill file" gnus-summary-edit-local-kill t]
2788 ["Edit main kill file" gnus-summary-edit-global-kill t]
2789 ["Edit group parameters" gnus-summary-edit-parameters t]
2790 ["Customize group parameters" gnus-summary-customize-parameters t]
2791 ["Send a bug report" gnus-bug t]
2792 ("Exit"
2793 ["Catchup and exit" gnus-summary-catchup-and-exit
2794 ,@(if (featurep 'xemacs) '(t)
2795 '(:help "Mark unread articles in this group as read, then exit"))]
2796 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2797 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2798 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2799 ["Exit group" gnus-summary-exit
2800 ,@(if (featurep 'xemacs) '(t)
2801 '(:help "Exit current group, return to group selection mode"))]
2802 ["Exit group without updating" gnus-summary-exit-no-update t]
2803 ["Exit and goto next group" gnus-summary-next-group t]
2804 ["Exit and goto prev group" gnus-summary-prev-group t]
2805 ["Reselect group" gnus-summary-reselect-current-group t]
2806 ["Rescan group" gnus-summary-rescan-group t]
2807 ["Update dribble" gnus-summary-save-newsrc t])))
2809 (gnus-run-hooks 'gnus-summary-menu-hook)))
2811 (defvar gnus-summary-tool-bar-map nil)
2813 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2814 ;; affect _new_ message buffers. We might add a function that walks thru all
2815 ;; summary-mode buffers and force the update.
2816 (defun gnus-summary-tool-bar-update (&optional symbol value)
2817 "Update summary mode toolbar.
2818 Setter function for custom variables."
2819 (setq-default gnus-summary-tool-bar-map nil)
2820 (when symbol
2821 ;; When used as ":set" function:
2822 (set-default symbol value))
2823 (when (gnus-buffer-live-p gnus-summary-buffer)
2824 (with-current-buffer gnus-summary-buffer
2825 (gnus-summary-make-tool-bar))))
2827 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2828 'gnus-summary-tool-bar-gnome
2829 'gnus-summary-tool-bar-retro)
2830 "Specifies the Gnus summary tool bar.
2832 It can be either a list or a symbol referring to a list. See
2833 `gmm-tool-bar-from-list' for the format of the list. The
2834 default key map is `gnus-summary-mode-map'.
2836 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2837 `gnus-summary-tool-bar-retro'."
2838 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2839 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2840 (repeat :tag "User defined list" gmm-tool-bar-item)
2841 (symbol))
2842 :version "23.1" ;; No Gnus
2843 :initialize 'custom-initialize-default
2844 :set 'gnus-summary-tool-bar-update
2845 :group 'gnus-summary)
2847 (defcustom gnus-summary-tool-bar-gnome
2848 '((gnus-summary-post-news "mail/compose" nil)
2849 (gnus-summary-insert-new-articles "mail/inbox" nil
2850 :visible (or (not gnus-agent)
2851 gnus-plugged))
2852 (gnus-summary-reply-with-original "mail/reply")
2853 (gnus-summary-reply "mail/reply" nil :visible nil)
2854 (gnus-summary-followup-with-original "mail/reply-all")
2855 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2856 (gnus-summary-mail-forward "mail/forward")
2857 (gnus-summary-save-article "mail/save")
2858 (gnus-summary-search-article-forward "search" nil :visible nil)
2859 (gnus-summary-print-article "print")
2860 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2861 ;; Some new commands that may need more suitable icons:
2862 (gnus-summary-save-newsrc "save" nil :visible nil)
2863 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2864 (gnus-summary-prev-article "left-arrow")
2865 (gnus-summary-next-article "right-arrow")
2866 (gnus-summary-next-page "next-page")
2867 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2869 ;; Maybe some sort-by-... could be added:
2870 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2871 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2872 (gnus-summary-mark-as-expirable
2873 "delete" nil
2874 :visible (gnus-check-backend-function 'request-expire-articles
2875 gnus-newsgroup-name))
2876 (gnus-summary-mark-as-spam
2877 "mail/spam" t
2878 :visible (and (fboundp 'spam-group-ham-contents-p)
2879 (spam-group-ham-contents-p gnus-newsgroup-name))
2880 :help "Mark as spam")
2881 (gnus-summary-mark-as-read-forward
2882 "mail/not-spam" nil
2883 :visible (and (fboundp 'spam-group-spam-contents-p)
2884 (spam-group-spam-contents-p gnus-newsgroup-name)))
2886 (gnus-summary-exit "exit")
2887 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2888 (gnus-info-find-node "help"))
2889 "List of functions for the summary tool bar (GNOME style).
2891 See `gmm-tool-bar-from-list' for the format of the list."
2892 :type '(repeat gmm-tool-bar-item)
2893 :version "23.1" ;; No Gnus
2894 :initialize 'custom-initialize-default
2895 :set 'gnus-summary-tool-bar-update
2896 :group 'gnus-summary)
2898 (defcustom gnus-summary-tool-bar-retro
2899 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2900 (gnus-summary-next-unread-article "gnus/next-ur")
2901 (gnus-summary-post-news "gnus/post")
2902 (gnus-summary-followup-with-original "gnus/fuwo")
2903 (gnus-summary-followup "gnus/followup")
2904 (gnus-summary-reply-with-original "gnus/reply-wo")
2905 (gnus-summary-reply "gnus/reply")
2906 (gnus-summary-caesar-message "gnus/rot13")
2907 (gnus-uu-decode-uu "gnus/uu-decode")
2908 (gnus-summary-save-article-file "gnus/save-aif")
2909 (gnus-summary-save-article "gnus/save-art")
2910 (gnus-uu-post-news "gnus/uu-post")
2911 (gnus-summary-catchup "gnus/catchup")
2912 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2913 (gnus-summary-exit "gnus/exit-summ")
2914 ;; Some new command that may need more suitable icons:
2915 (gnus-summary-print-article "gnus/print" nil :visible nil)
2916 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2917 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2918 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2919 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2920 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2921 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2923 (gnus-info-find-node "gnus/help" nil :visible nil))
2924 "List of functions for the summary tool bar (retro look).
2926 See `gmm-tool-bar-from-list' for the format of the list."
2927 :type '(repeat gmm-tool-bar-item)
2928 :version "23.1" ;; No Gnus
2929 :initialize 'custom-initialize-default
2930 :set 'gnus-summary-tool-bar-update
2931 :group 'gnus-summary)
2933 (defcustom gnus-summary-tool-bar-zap-list t
2934 "List of icon items from the global tool bar.
2935 These items are not displayed in the Gnus summary mode tool bar.
2937 See `gmm-tool-bar-from-list' for the format of the list."
2938 :type 'gmm-tool-bar-zap-list
2939 :version "23.1" ;; No Gnus
2940 :initialize 'custom-initialize-default
2941 :set 'gnus-summary-tool-bar-update
2942 :group 'gnus-summary)
2944 (defvar image-load-path)
2945 (defvar tool-bar-map)
2947 (defun gnus-summary-make-tool-bar (&optional force)
2948 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2949 When FORCE, rebuild the tool bar."
2950 (when (and (not (featurep 'xemacs))
2951 (boundp 'tool-bar-mode)
2952 tool-bar-mode
2953 (or (not gnus-summary-tool-bar-map) force))
2954 (let* ((load-path
2955 (gmm-image-load-path-for-library "gnus"
2956 "mail/save.xpm"
2957 nil t))
2958 (image-load-path (cons (car load-path)
2959 (when (boundp 'image-load-path)
2960 image-load-path)))
2961 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2962 gnus-summary-tool-bar-zap-list
2963 'gnus-summary-mode-map)))
2964 (when map
2965 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2966 ;; uses its value.
2967 (setq gnus-summary-tool-bar-map map))))
2968 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2970 (defun gnus-make-score-map (type)
2971 "Make a summary score map of type TYPE."
2972 (if t
2974 (let ((headers '(("author" "from" string)
2975 ("subject" "subject" string)
2976 ("article body" "body" string)
2977 ("article head" "head" string)
2978 ("xref" "xref" string)
2979 ("extra header" "extra" string)
2980 ("lines" "lines" number)
2981 ("followups to author" "followup" string)))
2982 (types '((number ("less than" <)
2983 ("greater than" >)
2984 ("equal" =))
2985 (string ("substring" s)
2986 ("exact string" e)
2987 ("fuzzy string" f)
2988 ("regexp" r))))
2989 (perms '(("temporary" (current-time-string))
2990 ("permanent" nil)
2991 ("immediate" now)))
2992 header)
2993 (list
2994 (apply
2995 'nconc
2996 (list
2997 (if (eq type 'lower)
2998 "Lower score"
2999 "Increase score"))
3000 (let (outh)
3001 (while headers
3002 (setq header (car headers))
3003 (setq outh
3004 (cons
3005 (apply
3006 'nconc
3007 (list (car header))
3008 (let ((ts (cdr (assoc (nth 2 header) types)))
3009 outt)
3010 (while ts
3011 (setq outt
3012 (cons
3013 (apply
3014 'nconc
3015 (list (caar ts))
3016 (let ((ps perms)
3017 outp)
3018 (while ps
3019 (setq outp
3020 (cons
3021 (vector
3022 (caar ps)
3023 (list
3024 'gnus-summary-score-entry
3025 (nth 1 header)
3026 (if (or (string= (nth 1 header)
3027 "head")
3028 (string= (nth 1 header)
3029 "body"))
3031 (list 'gnus-summary-header
3032 (nth 1 header)))
3033 (list 'quote (nth 1 (car ts)))
3034 (list 'gnus-score-delta-default
3035 nil)
3036 (nth 1 (car ps))
3039 outp))
3040 (setq ps (cdr ps)))
3041 (list (nreverse outp))))
3042 outt))
3043 (setq ts (cdr ts)))
3044 (list (nreverse outt))))
3045 outh))
3046 (setq headers (cdr headers)))
3047 (list (nreverse outh))))))))
3050 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3051 (defvar bookmark-make-record-function)
3053 (defvar bidi-paragraph-direction)
3055 (defun gnus-summary-mode (&optional group)
3056 "Major mode for reading articles.
3058 All normal editing commands are switched off.
3059 \\<gnus-summary-mode-map>
3060 Each line in this buffer represents one article. To read an
3061 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3062 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3063 respectively.
3065 You can also post articles and send mail from this buffer. To
3066 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3067 of an article, type `\\[gnus-summary-reply]'.
3069 There are approx. one gazillion commands you can execute in this
3070 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3072 The following commands are available:
3074 \\{gnus-summary-mode-map}"
3075 (interactive)
3076 (kill-all-local-variables)
3077 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3078 (gnus-summary-make-local-variables))
3079 (gnus-summary-make-local-variables)
3080 (setq gnus-newsgroup-name group)
3081 (when (gnus-visual-p 'summary-menu 'menu)
3082 (gnus-summary-make-menu-bar)
3083 (gnus-summary-make-tool-bar))
3084 (gnus-make-thread-indent-array)
3085 (gnus-simplify-mode-line)
3086 (setq major-mode 'gnus-summary-mode)
3087 (setq mode-name "Summary")
3088 (use-local-map gnus-summary-mode-map)
3089 (buffer-disable-undo)
3090 (setq buffer-read-only t ;Disable modification
3091 show-trailing-whitespace nil)
3092 (setq truncate-lines t)
3093 ;; Force paragraph direction to be left-to-right. Don't make it
3094 ;; bound globally in old Emacsen and XEmacsen.
3095 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3096 (add-to-invisibility-spec '(gnus-sum . t))
3097 (gnus-summary-set-display-table)
3098 (gnus-set-default-directory)
3099 (make-local-variable 'gnus-summary-line-format)
3100 (make-local-variable 'gnus-summary-line-format-spec)
3101 (make-local-variable 'gnus-summary-dummy-line-format)
3102 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3103 (make-local-variable 'gnus-summary-mark-positions)
3104 (gnus-make-local-hook 'pre-command-hook)
3105 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3106 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3107 (turn-on-gnus-mailing-list-mode)
3108 (mm-enable-multibyte)
3109 (set (make-local-variable 'bookmark-make-record-function)
3110 'gnus-summary-bookmark-make-record)
3111 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3112 (gnus-update-summary-mark-positions))
3114 (defun gnus-summary-make-local-variables ()
3115 "Make all the local summary buffer variables."
3116 (let (global)
3117 (dolist (local gnus-summary-local-variables)
3118 (if (consp local)
3119 (progn
3120 (if (eq (cdr local) 'global)
3121 ;; Copy the global value of the variable.
3122 (setq global (symbol-value (car local)))
3123 ;; Use the value from the list.
3124 (setq global (eval (cdr local))))
3125 (set (make-local-variable (car local)) global))
3126 ;; Simple nil-valued local variable.
3127 (set (make-local-variable local) nil)))))
3129 ;; Summary data functions.
3131 (defmacro gnus-data-number (data)
3132 `(car ,data))
3134 (defmacro gnus-data-set-number (data number)
3135 `(setcar ,data ,number))
3137 (defmacro gnus-data-mark (data)
3138 `(nth 1 ,data))
3140 (defmacro gnus-data-set-mark (data mark)
3141 `(setcar (nthcdr 1 ,data) ,mark))
3143 (defmacro gnus-data-pos (data)
3144 `(nth 2 ,data))
3146 (defmacro gnus-data-set-pos (data pos)
3147 `(setcar (nthcdr 2 ,data) ,pos))
3149 (defmacro gnus-data-header (data)
3150 `(nth 3 ,data))
3152 (defmacro gnus-data-set-header (data header)
3153 `(setf (nth 3 ,data) ,header))
3155 (defmacro gnus-data-level (data)
3156 `(nth 4 ,data))
3158 (defmacro gnus-data-unread-p (data)
3159 `(= (nth 1 ,data) gnus-unread-mark))
3161 (defmacro gnus-data-read-p (data)
3162 `(/= (nth 1 ,data) gnus-unread-mark))
3164 (defmacro gnus-data-pseudo-p (data)
3165 `(consp (nth 3 ,data)))
3167 (defmacro gnus-data-find (number)
3168 `(assq ,number gnus-newsgroup-data))
3170 (defmacro gnus-data-find-list (number &optional data)
3171 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3172 (memq (assq ,number bdata)
3173 bdata)))
3175 (defmacro gnus-data-make (number mark pos header level)
3176 `(list ,number ,mark ,pos ,header ,level))
3178 (defun gnus-data-enter (after-article number mark pos header level offset)
3179 (let ((data (gnus-data-find-list after-article)))
3180 (unless data
3181 (error "No such article: %d" after-article))
3182 (setcdr data (cons (gnus-data-make number mark pos header level)
3183 (cdr data)))
3184 (setq gnus-newsgroup-data-reverse nil)
3185 (gnus-data-update-list (cddr data) offset)))
3187 (defun gnus-data-enter-list (after-article list &optional offset)
3188 (when list
3189 (let ((data (and after-article (gnus-data-find-list after-article)))
3190 (ilist list))
3191 (if (not (or data
3192 after-article))
3193 (let ((odata gnus-newsgroup-data))
3194 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3195 (when offset
3196 (gnus-data-update-list odata offset)))
3197 ;; Find the last element in the list to be spliced into the main
3198 ;; list.
3199 (setq list (last list))
3200 (if (not data)
3201 (progn
3202 (setcdr list gnus-newsgroup-data)
3203 (setq gnus-newsgroup-data ilist)
3204 (when offset
3205 (gnus-data-update-list (cdr list) offset)))
3206 (setcdr list (cdr data))
3207 (setcdr data ilist)
3208 (when offset
3209 (gnus-data-update-list (cdr list) offset))))
3210 (setq gnus-newsgroup-data-reverse nil))))
3212 (defun gnus-data-remove (article &optional offset)
3213 (let ((data gnus-newsgroup-data))
3214 (if (= (gnus-data-number (car data)) article)
3215 (progn
3216 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3217 gnus-newsgroup-data-reverse nil)
3218 (when offset
3219 (gnus-data-update-list gnus-newsgroup-data offset)))
3220 (while (cdr data)
3221 (when (= (gnus-data-number (cadr data)) article)
3222 (setcdr data (cddr data))
3223 (when offset
3224 (gnus-data-update-list (cdr data) offset))
3225 (setq data nil
3226 gnus-newsgroup-data-reverse nil))
3227 (setq data (cdr data))))))
3229 (defmacro gnus-data-list (backward)
3230 `(if ,backward
3231 (or gnus-newsgroup-data-reverse
3232 (setq gnus-newsgroup-data-reverse
3233 (reverse gnus-newsgroup-data)))
3234 gnus-newsgroup-data))
3236 (defun gnus-data-update-list (data offset)
3237 "Add OFFSET to the POS of all data entries in DATA."
3238 (setq gnus-newsgroup-data-reverse nil)
3239 (while data
3240 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3241 (setq data (cdr data))))
3243 (defun gnus-summary-article-pseudo-p (article)
3244 "Say whether this article is a pseudo article or not."
3245 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3247 (defmacro gnus-summary-article-sparse-p (article)
3248 "Say whether this article is a sparse article or not."
3249 `(memq ,article gnus-newsgroup-sparse))
3251 (defmacro gnus-summary-article-ancient-p (article)
3252 "Say whether this article is a sparse article or not."
3253 `(memq ,article gnus-newsgroup-ancient))
3255 (defun gnus-article-children (number)
3256 "Return a list of all children to NUMBER."
3257 (let* ((data (gnus-data-find-list number))
3258 (level (gnus-data-level (car data)))
3259 children)
3260 (setq data (cdr data))
3261 (while (and data
3262 (= (gnus-data-level (car data)) (1+ level)))
3263 (push (gnus-data-number (car data)) children)
3264 (setq data (cdr data)))
3265 children))
3267 (defmacro gnus-summary-skip-intangible ()
3268 "If the current article is intangible, then jump to a different article."
3269 '(let ((to (get-text-property (point) 'gnus-intangible)))
3270 (and to (gnus-summary-goto-subject to))))
3272 (defmacro gnus-summary-article-intangible-p ()
3273 "Say whether this article is intangible or not."
3274 '(get-text-property (point) 'gnus-intangible))
3276 ;; Some summary mode macros.
3278 (defmacro gnus-summary-article-number ()
3279 "The article number of the article on the current line.
3280 If there isn't an article number here, then we return the current
3281 article number."
3282 '(progn
3283 (gnus-summary-skip-intangible)
3284 (or (get-text-property (point) 'gnus-number)
3285 (gnus-summary-last-subject))))
3287 (defmacro gnus-summary-article-header (&optional number)
3288 "Return the header of article NUMBER."
3289 `(gnus-data-header (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3292 (defmacro gnus-summary-thread-level (&optional number)
3293 "Return the level of thread that starts with article NUMBER."
3294 `(if (and (eq gnus-summary-make-false-root 'dummy)
3295 (get-text-property (point) 'gnus-intangible))
3297 (gnus-data-level (gnus-data-find
3298 ,(or number '(gnus-summary-article-number))))))
3300 (defmacro gnus-summary-article-mark (&optional number)
3301 "Return the mark of article NUMBER."
3302 `(gnus-data-mark (gnus-data-find
3303 ,(or number '(gnus-summary-article-number)))))
3305 (defmacro gnus-summary-article-pos (&optional number)
3306 "Return the position of the line of article NUMBER."
3307 `(gnus-data-pos (gnus-data-find
3308 ,(or number '(gnus-summary-article-number)))))
3310 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3311 (defmacro gnus-summary-article-subject (&optional number)
3312 "Return current subject string or nil if nothing."
3313 `(let ((headers
3314 ,(if number
3315 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3316 '(gnus-data-header (assq (gnus-summary-article-number)
3317 gnus-newsgroup-data)))))
3318 (and headers
3319 (vectorp headers)
3320 (mail-header-subject headers))))
3322 (defmacro gnus-summary-article-score (&optional number)
3323 "Return current article score."
3324 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3325 gnus-newsgroup-scored))
3326 gnus-summary-default-score 0))
3328 (defun gnus-summary-article-children (&optional number)
3329 "Return a list of article numbers that are children of article NUMBER."
3330 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3331 (level (gnus-data-level (car data)))
3332 l children)
3333 (while (and (setq data (cdr data))
3334 (> (setq l (gnus-data-level (car data))) level))
3335 (and (= (1+ level) l)
3336 (push (gnus-data-number (car data))
3337 children)))
3338 (nreverse children)))
3340 (defun gnus-summary-article-parent (&optional number)
3341 "Return the article number of the parent of article NUMBER."
3342 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3343 (gnus-data-list t)))
3344 (level (gnus-data-level (car data))))
3345 (if (zerop level)
3346 () ; This is a root.
3347 ;; We search until we find an article with a level less than
3348 ;; this one. That function has to be the parent.
3349 (while (and (setq data (cdr data))
3350 (not (< (gnus-data-level (car data)) level))))
3351 (and data (gnus-data-number (car data))))))
3353 (defun gnus-unread-mark-p (mark)
3354 "Say whether MARK is the unread mark."
3355 (= mark gnus-unread-mark))
3357 (defun gnus-read-mark-p (mark)
3358 "Say whether MARK is one of the marks that mark as read.
3359 This is all marks except unread, ticked, dormant, and expirable."
3360 (not (or (= mark gnus-unread-mark)
3361 (= mark gnus-ticked-mark)
3362 (= mark gnus-spam-mark)
3363 (= mark gnus-dormant-mark)
3364 (= mark gnus-expirable-mark))))
3366 (defmacro gnus-article-mark (number)
3367 "Return the MARK of article NUMBER.
3368 This macro should only be used when computing the mark the \"first\"
3369 time; i.e., when generating the summary lines. After that,
3370 `gnus-summary-article-mark' should be used to examine the
3371 marks of articles."
3372 `(cond
3373 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3374 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3375 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3376 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3377 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3378 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3379 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3380 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3381 gnus-ancient-mark))))
3383 ;; Saving hidden threads.
3385 (defmacro gnus-save-hidden-threads (&rest forms)
3386 "Save hidden threads, eval FORMS, and restore the hidden threads."
3387 (let ((config (make-symbol "config")))
3388 `(let ((,config (gnus-hidden-threads-configuration)))
3389 (unwind-protect
3390 (save-excursion
3391 ,@forms)
3392 (gnus-restore-hidden-threads-configuration ,config)))))
3393 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3394 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3396 (defun gnus-data-compute-positions ()
3397 "Compute the positions of all articles."
3398 (setq gnus-newsgroup-data-reverse nil)
3399 (let ((data gnus-newsgroup-data))
3400 (save-excursion
3401 (gnus-save-hidden-threads
3402 (gnus-summary-show-all-threads)
3403 (goto-char (point-min))
3404 (while data
3405 (while (get-text-property (point) 'gnus-intangible)
3406 (forward-line 1))
3407 (gnus-data-set-pos (car data) (+ (point) 3))
3408 (setq data (cdr data))
3409 (forward-line 1))))))
3411 (defun gnus-hidden-threads-configuration ()
3412 "Return the current hidden threads configuration."
3413 (save-excursion
3414 (let (config)
3415 (goto-char (point-min))
3416 (while (not (eobp))
3417 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3418 (push (save-excursion (forward-line 0) (point)) config))
3419 (forward-line 1))
3420 config)))
3422 (defun gnus-restore-hidden-threads-configuration (config)
3423 "Restore hidden threads configuration from CONFIG."
3424 (save-excursion
3425 (let (point (inhibit-read-only t))
3426 (while (setq point (pop config))
3427 (goto-char point)
3428 (gnus-summary-hide-thread)))))
3430 ;; Various summary mode internalish functions.
3432 (defun gnus-mouse-pick-article (e)
3433 (interactive "e")
3434 (mouse-set-point e)
3435 (gnus-summary-next-page nil t))
3437 (defun gnus-summary-set-display-table ()
3438 "Change the display table.
3439 Odd characters have a tendency to mess
3440 up nicely formatted displays - we make all possible glyphs
3441 display only a single character."
3443 ;; We start from the standard display table, if any.
3444 (let ((table (or (copy-sequence standard-display-table)
3445 (make-display-table)))
3446 (i 32))
3447 ;; Nix out all the control chars...
3448 (while (>= (setq i (1- i)) 0)
3449 (gnus-put-display-table i [??] table))
3450 ;; ... but not newline and cr, of course. (cr is necessary for the
3451 ;; selective display).
3452 (gnus-put-display-table ?\n nil table)
3453 (gnus-put-display-table ?\r nil table)
3454 ;; We keep TAB as well.
3455 (gnus-put-display-table ?\t nil table)
3456 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3457 ;; Emacs 23 (unicode), that are not set already.
3458 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3460 256)))
3461 (while (>= (setq i (1- i)) 127)
3462 ;; Only modify if the entry is nil.
3463 (unless (gnus-get-display-table i table)
3464 (gnus-put-display-table i [??] table))))
3465 (setq buffer-display-table table)))
3467 (defun gnus-summary-set-article-display-arrow (pos)
3468 "Update the overlay arrow to point to line at position POS."
3469 (when gnus-summary-display-arrow
3470 (make-local-variable 'overlay-arrow-position)
3471 (make-local-variable 'overlay-arrow-string)
3472 (save-excursion
3473 (goto-char pos)
3474 (beginning-of-line)
3475 (unless overlay-arrow-position
3476 (setq overlay-arrow-position (make-marker)))
3477 (setq overlay-arrow-string "=>"
3478 overlay-arrow-position (set-marker overlay-arrow-position
3479 (point)
3480 (current-buffer))))))
3482 (defun gnus-summary-setup-buffer (group)
3483 "Initialize summary buffer.
3484 If the setup was successful, non-nil is returned."
3485 (let ((buffer (gnus-summary-buffer-name group))
3486 (dead-name (concat "*Dead Summary "
3487 (gnus-group-decoded-name group) "*")))
3488 ;; If a dead summary buffer exists, we kill it.
3489 (when (gnus-buffer-live-p dead-name)
3490 (gnus-kill-buffer dead-name))
3491 (if (get-buffer buffer)
3492 (progn
3493 (set-buffer buffer)
3494 (setq gnus-summary-buffer (current-buffer))
3495 (not gnus-newsgroup-prepared))
3496 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3497 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3498 (gnus-summary-mode group)
3499 (when (gnus-group-quit-config group)
3500 (set (make-local-variable 'gnus-single-article-buffer) nil))
3501 (make-local-variable 'gnus-article-buffer)
3502 (make-local-variable 'gnus-article-current)
3503 (make-local-variable 'gnus-original-article-buffer)
3504 (setq gnus-newsgroup-name group)
3505 ;; Set any local variables in the group parameters.
3506 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3507 t)))
3509 (defun gnus-set-global-variables ()
3510 "Set the global equivalents of the buffer-local variables.
3511 They are set to the latest values they had. These reflect the summary
3512 buffer that was in action when the last article was fetched."
3513 (when (eq major-mode 'gnus-summary-mode)
3514 (setq gnus-summary-buffer (current-buffer))
3515 (let ((name gnus-newsgroup-name)
3516 (marked gnus-newsgroup-marked)
3517 (spam gnus-newsgroup-spam-marked)
3518 (unread gnus-newsgroup-unreads)
3519 (headers gnus-current-headers)
3520 (data gnus-newsgroup-data)
3521 (summary gnus-summary-buffer)
3522 (article-buffer gnus-article-buffer)
3523 (original gnus-original-article-buffer)
3524 (gac gnus-article-current)
3525 (reffed gnus-reffed-article-number)
3526 (score-file gnus-current-score-file)
3527 (default-charset gnus-newsgroup-charset)
3528 vlist)
3529 (let ((locals gnus-newsgroup-variables))
3530 (while locals
3531 (if (consp (car locals))
3532 (push (eval (caar locals)) vlist)
3533 (push (eval (car locals)) vlist))
3534 (setq locals (cdr locals)))
3535 (setq vlist (nreverse vlist)))
3536 (with-temp-buffer
3537 (setq gnus-newsgroup-name name
3538 gnus-newsgroup-marked marked
3539 gnus-newsgroup-spam-marked spam
3540 gnus-newsgroup-unreads unread
3541 gnus-current-headers headers
3542 gnus-newsgroup-data data
3543 gnus-article-current gac
3544 gnus-summary-buffer summary
3545 gnus-article-buffer article-buffer
3546 gnus-original-article-buffer original
3547 gnus-reffed-article-number reffed
3548 gnus-current-score-file score-file
3549 gnus-newsgroup-charset default-charset)
3550 (let ((locals gnus-newsgroup-variables))
3551 (while locals
3552 (if (consp (car locals))
3553 (set (caar locals) (pop vlist))
3554 (set (car locals) (pop vlist)))
3555 (setq locals (cdr locals))))
3556 ;; The article buffer also has local variables.
3557 (when (gnus-buffer-live-p gnus-article-buffer)
3558 (set-buffer gnus-article-buffer)
3559 (setq gnus-summary-buffer summary))))))
3561 (defun gnus-summary-article-unread-p (article)
3562 "Say whether ARTICLE is unread or not."
3563 (memq article gnus-newsgroup-unreads))
3565 (defun gnus-summary-first-article-p (&optional article)
3566 "Return whether ARTICLE is the first article in the buffer."
3567 (if (not (setq article (or article (gnus-summary-article-number))))
3569 (eq article (caar gnus-newsgroup-data))))
3571 (defun gnus-summary-last-article-p (&optional article)
3572 "Return whether ARTICLE is the last article in the buffer."
3573 (if (not (setq article (or article (gnus-summary-article-number))))
3574 ;; All non-existent numbers are the last article. :-)
3576 (not (cdr (gnus-data-find-list article)))))
3578 (defun gnus-make-thread-indent-array (&optional n)
3579 (when (or n
3580 (progn (setq n 200) nil)
3581 (null gnus-thread-indent-array)
3582 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3583 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3584 gnus-thread-indent-array-level gnus-thread-indent-level)
3585 (while (>= n 0)
3586 (aset gnus-thread-indent-array n
3587 (make-string (* n gnus-thread-indent-level) ? ))
3588 (setq n (1- n)))))
3590 (defun gnus-update-summary-mark-positions ()
3591 "Compute where the summary marks are to go."
3592 (save-excursion
3593 (when (gnus-buffer-exists-p gnus-summary-buffer)
3594 (set-buffer gnus-summary-buffer))
3595 (let ((spec gnus-summary-line-format-spec)
3596 pos)
3597 (save-excursion
3598 (gnus-set-work-buffer)
3599 (let ((gnus-tmp-unread ?Z)
3600 (gnus-replied-mark ?Z)
3601 (gnus-score-below-mark ?Z)
3602 (gnus-score-over-mark ?Z)
3603 (gnus-undownloaded-mark ?Z)
3604 (gnus-summary-line-format-spec spec)
3605 (gnus-newsgroup-downloadable '(0))
3606 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3607 case-fold-search ignores)
3608 ;; Here, all marks are bound to Z.
3609 (gnus-summary-insert-line header
3610 0 nil t gnus-tmp-unread t nil "" nil 1)
3611 (goto-char (point-min))
3612 ;; Memorize the positions of the same characters as dummy marks.
3613 (while (re-search-forward "[A-D]" nil t)
3614 (push (point) ignores))
3615 (erase-buffer)
3616 ;; We use A-D as dummy marks in order to know column positions
3617 ;; where marks should be inserted.
3618 (setq gnus-tmp-unread ?A
3619 gnus-replied-mark ?B
3620 gnus-score-below-mark ?C
3621 gnus-score-over-mark ?C
3622 gnus-undownloaded-mark ?D)
3623 (gnus-summary-insert-line header
3624 0 nil t gnus-tmp-unread t nil "" nil 1)
3625 ;; Ignore characters which aren't dummy marks.
3626 (dolist (p ignores)
3627 (delete-region (goto-char (1- p)) p)
3628 (insert ?Z))
3629 (goto-char (point-min))
3630 (setq pos (list (cons 'unread
3631 (and (search-forward "A" nil t)
3632 (- (point) (point-min) 1)))))
3633 (goto-char (point-min))
3634 (push (cons 'replied (and (search-forward "B" nil t)
3635 (- (point) (point-min) 1)))
3636 pos)
3637 (goto-char (point-min))
3638 (push (cons 'score (and (search-forward "C" nil t)
3639 (- (point) (point-min) 1)))
3640 pos)
3641 (goto-char (point-min))
3642 (push (cons 'download (and (search-forward "D" nil t)
3643 (- (point) (point-min) 1)))
3644 pos)))
3645 (setq gnus-summary-mark-positions pos))))
3647 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3648 "Insert a dummy root in the summary buffer."
3649 (beginning-of-line)
3650 (gnus-add-text-properties
3651 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3652 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3654 (defun gnus-summary-extract-address-component (from)
3655 (or (car (funcall gnus-extract-address-components from))
3656 from))
3658 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3659 (let ((mail-parse-charset gnus-newsgroup-charset)
3660 (ignored-from-addresses (gnus-ignored-from-addresses))
3661 ; Is it really necessary to do this next part for each summary line?
3662 ; Luckily, doesn't seem to slow things down much.
3663 (mail-parse-ignored-charsets
3664 (with-current-buffer gnus-summary-buffer
3665 gnus-newsgroup-ignored-charsets)))
3667 (and ignored-from-addresses
3668 (string-match ignored-from-addresses gnus-tmp-from)
3669 (let ((extra-headers (mail-header-extra header))
3671 newsgroups)
3672 (cond
3673 ((setq to (cdr (assq 'To extra-headers)))
3674 (concat gnus-summary-to-prefix
3675 (inline
3676 (gnus-summary-extract-address-component
3677 (funcall gnus-decode-encoded-address-function to)))))
3678 ((setq newsgroups
3680 (cdr (assq 'Newsgroups extra-headers))
3681 (and
3682 (memq 'Newsgroups gnus-extra-headers)
3683 (eq (car (gnus-find-method-for-group
3684 gnus-newsgroup-name)) 'nntp)
3685 (gnus-group-real-name gnus-newsgroup-name))))
3686 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3687 (gnus-string-mark-left-to-right
3688 (inline
3689 (gnus-summary-extract-address-component gnus-tmp-from))))))
3691 (defun gnus-summary-insert-line (gnus-tmp-header
3692 gnus-tmp-level gnus-tmp-current
3693 undownloaded gnus-tmp-unread gnus-tmp-replied
3694 gnus-tmp-expirable gnus-tmp-subject-or-nil
3695 &optional gnus-tmp-dummy gnus-tmp-score
3696 gnus-tmp-process)
3697 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3698 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3699 gnus-tmp-level)))
3700 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3701 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3702 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3703 (gnus-tmp-score-char
3704 (if (or (null gnus-summary-default-score)
3705 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3706 gnus-summary-zcore-fuzz))
3707 ? ;Whitespace
3708 (if (< gnus-tmp-score gnus-summary-default-score)
3709 gnus-score-below-mark gnus-score-over-mark)))
3710 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3711 (gnus-tmp-replied
3712 (cond (gnus-tmp-process gnus-process-mark)
3713 ((memq gnus-tmp-current gnus-newsgroup-cached)
3714 gnus-cached-mark)
3715 (gnus-tmp-replied gnus-replied-mark)
3716 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3717 gnus-forwarded-mark)
3718 ((memq gnus-tmp-current gnus-newsgroup-saved)
3719 gnus-saved-mark)
3720 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3721 gnus-unseen-mark)
3722 (t gnus-no-mark)))
3723 (gnus-tmp-downloaded
3724 (cond (undownloaded
3725 gnus-undownloaded-mark)
3726 (gnus-newsgroup-agentized
3727 gnus-downloaded-mark)
3729 gnus-no-mark)))
3730 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3731 (gnus-tmp-name
3732 (cond
3733 ((string-match "<[^>]+> *$" gnus-tmp-from)
3734 (let ((beg (match-beginning 0)))
3735 (or (and (string-match "^\".+\"" gnus-tmp-from)
3736 (substring gnus-tmp-from 1 (1- (match-end 0))))
3737 (substring gnus-tmp-from 0 beg))))
3738 ((string-match "(.+)" gnus-tmp-from)
3739 (substring gnus-tmp-from
3740 (1+ (match-beginning 0)) (1- (match-end 0))))
3741 (t gnus-tmp-from)))
3742 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3743 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3744 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3745 (inhibit-read-only t))
3746 (when (string= gnus-tmp-name "")
3747 (setq gnus-tmp-name gnus-tmp-from))
3748 (unless (numberp gnus-tmp-lines)
3749 (setq gnus-tmp-lines -1))
3750 (if (= gnus-tmp-lines -1)
3751 (setq gnus-tmp-lines "?")
3752 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3753 (condition-case ()
3754 (gnus-put-text-property
3755 (point)
3756 (progn (eval gnus-summary-line-format-spec) (point))
3757 'gnus-number gnus-tmp-number)
3758 (error (gnus-message 5 "Error updating the summary line")))
3759 (when (gnus-visual-p 'summary-highlight 'highlight)
3760 (forward-line -1)
3761 (gnus-summary-highlight-line)
3762 (gnus-run-hooks 'gnus-summary-update-hook)
3763 (forward-line 1))))
3765 (defun gnus-summary-update-line (&optional dont-update)
3766 "Update summary line after change."
3767 (when (and gnus-summary-default-score
3768 (not gnus-summary-inhibit-highlight))
3769 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3770 (article (gnus-summary-article-number))
3771 (score (gnus-summary-article-score article)))
3772 (unless dont-update
3773 (if (and gnus-summary-mark-below
3774 (< (gnus-summary-article-score)
3775 gnus-summary-mark-below))
3776 ;; This article has a low score, so we mark it as read.
3777 (when (memq article gnus-newsgroup-unreads)
3778 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3779 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3780 ;; This article was previously marked as read on account
3781 ;; of a low score, but now it has risen, so we mark it as
3782 ;; unread.
3783 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3784 (gnus-summary-update-mark
3785 (if (or (null gnus-summary-default-score)
3786 (<= (abs (- score gnus-summary-default-score))
3787 gnus-summary-zcore-fuzz))
3788 ? ;Whitespace
3789 (if (< score gnus-summary-default-score)
3790 gnus-score-below-mark gnus-score-over-mark))
3791 'score))
3792 ;; Do visual highlighting.
3793 (when (gnus-visual-p 'summary-highlight 'highlight)
3794 (gnus-summary-highlight-line)
3795 (gnus-run-hooks 'gnus-summary-update-hook)))))
3797 (defvar gnus-tmp-new-adopts nil)
3799 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3800 "Return the number of articles in THREAD.
3801 This may be 0 in some cases -- if none of the articles in
3802 the thread are to be displayed."
3803 (let* ((number
3804 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3805 (cond
3806 ((not (listp thread))
3808 ((and (consp thread) (cdr thread))
3809 (apply
3810 '+ 1 (mapcar
3811 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3812 ((null thread)
3814 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3816 (t 0))))
3817 (when (and level (zerop level) gnus-tmp-new-adopts)
3818 (incf number
3819 (apply '+ (mapcar
3820 'gnus-summary-number-of-articles-in-thread
3821 gnus-tmp-new-adopts))))
3822 (if char
3823 (if (> number 1) gnus-not-empty-thread-mark
3824 gnus-empty-thread-mark)
3825 number)))
3827 (defsubst gnus-summary-line-message-size (head)
3828 "Return pretty-printed version of message size.
3829 This function is intended to be used in
3830 `gnus-summary-line-format-alist'."
3831 (let ((c (or (mail-header-chars head) -1)))
3832 (cond ((< c 0) "n/a") ; chars not available
3833 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3834 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3835 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3836 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3838 (defcustom gnus-user-date-format-alist
3839 '(((gnus-seconds-today) . "Today, %H:%M")
3840 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3841 (604800 . "%A %H:%M") ; That's one week
3842 ((gnus-seconds-month) . "%A %d")
3843 ((gnus-seconds-year) . "%B %d")
3844 (t . "%b %d %Y")) ; This one is used when no other
3845 ; does match
3846 "Specifies date format depending on age of article.
3847 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3848 seconds) or a Lisp expression evaluating to a number. When the age of
3849 the article is less than this number, then use `format-time-string'
3850 with the corresponding FORMAT for displaying the date of the article.
3851 If AGE is not a number or a Lisp expression evaluating to a
3852 non-number, then the corresponding FORMAT is used as a default value.
3854 Note that the list is processed from the beginning, so it should be
3855 sorted by ascending AGE. Also note that items following the first
3856 non-number AGE will be ignored.
3858 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3859 and `gnus-seconds-year' in the AGE spec. They return the number of
3860 seconds passed since the start of today, of this month, of this year,
3861 respectively."
3862 :version "24.1"
3863 :group 'gnus-summary-format
3864 :type '(alist :key-type sexp :value-type string))
3866 (defun gnus-user-date (messy-date)
3867 "Format the messy-date according to `gnus-user-date-format-alist'.
3868 Returns \" ? \" if there's bad input or if another error occurs.
3869 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3870 (condition-case ()
3871 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3872 (now (gnus-float-time))
3873 ;;If we don't find something suitable we'll use this one
3874 (my-format "%b %d '%y"))
3875 (let* ((difference (- now messy-date))
3876 (templist gnus-user-date-format-alist)
3877 (top (eval (caar templist))))
3878 (while (if (numberp top) (< top difference) (not top))
3879 (progn
3880 (setq templist (cdr templist))
3881 (setq top (eval (caar templist)))))
3882 (if (stringp (cdr (car templist)))
3883 (setq my-format (cdr (car templist)))))
3884 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3885 (error " ? ")))
3887 (defun gnus-summary-set-local-parameters (group)
3888 "Go through the local params of GROUP and set all variable specs in that list."
3889 (let ((vars '(quit-config active))) ; Ignore things that aren't
3890 ; really variables.
3891 (dolist (elem (gnus-group-find-parameter group))
3892 (and (consp elem) ; Has to be a cons.
3893 (consp (cdr elem)) ; The cdr has to be a list.
3894 (symbolp (car elem)) ; Has to be a symbol in there.
3895 (not (memq (car elem) vars))
3896 (ignore-errors
3897 (push (car elem) vars)
3898 ;; Variables like `gnus-show-threads' that are globally
3899 ;; bound, if used as group parameters, need to get to be
3900 ;; buffer-local, whereas just parameters like `gcc-self',
3901 ;; `timestamp', etc. should not be bound as variables.
3902 (if (boundp (car elem))
3903 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3904 (eval (nth 1 elem))))))))
3906 (defun gnus-summary-read-group (group &optional show-all no-article
3907 kill-buffer no-display backward
3908 select-articles)
3909 "Start reading news in newsgroup GROUP.
3910 If SHOW-ALL is non-nil, already read articles are also listed.
3911 If NO-ARTICLE is non-nil, no article is selected initially.
3912 If NO-DISPLAY, don't generate the summary buffer contents.
3913 If KILL-BUFFER, it should be a buffer that's killed once the new
3914 summary buffer has been generated.
3915 If BACKWARD, move point to the previous group in the group buffer
3916 If SELECT-ARTICLES, only select those articles from GROUP."
3917 (let (result)
3918 (while (and group
3919 (null (setq result
3920 (let ((gnus-auto-select-next nil))
3921 (or (gnus-summary-read-group-1
3922 group show-all no-article
3923 kill-buffer no-display
3924 select-articles)
3925 (setq show-all nil
3926 select-articles nil)))))
3927 (eq gnus-auto-select-next 'quietly))
3928 (set-buffer gnus-group-buffer)
3929 ;; The entry function called above goes to the next
3930 ;; group automatically, so we go two groups back
3931 ;; if we are searching for the previous group.
3932 (when backward
3933 (gnus-group-prev-unread-group 2))
3934 (if (not (equal group (gnus-group-group-name)))
3935 (setq group (gnus-group-group-name))
3936 (setq group nil)))
3937 result))
3939 (defun gnus-summary-read-group-1 (group show-all no-article
3940 kill-buffer no-display
3941 &optional select-articles)
3942 ;; Killed foreign groups can't be entered.
3943 ;; (when (and (not (gnus-group-native-p group))
3944 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3945 ;; (error "Dead non-native groups can't be entered"))
3946 (gnus-message 7 "Retrieving newsgroup: %s..."
3947 (gnus-group-decoded-name group))
3948 (let* ((new-group (gnus-summary-setup-buffer group))
3949 (quit-config (gnus-group-quit-config group))
3950 (did-select (and new-group (gnus-select-newsgroup
3951 group show-all select-articles))))
3952 (cond
3953 ;; This summary buffer exists already, so we just select it.
3954 ((not new-group)
3955 (gnus-set-global-variables)
3956 (when kill-buffer
3957 (gnus-kill-or-deaden-summary kill-buffer))
3958 (gnus-configure-windows 'summary 'force)
3959 (gnus-set-mode-line 'summary)
3960 (gnus-summary-position-point)
3961 (message "")
3963 ;; We couldn't select this group.
3964 ((null did-select)
3965 (when (and (eq major-mode 'gnus-summary-mode)
3966 (not (equal (current-buffer) kill-buffer)))
3967 (kill-buffer (current-buffer))
3968 (if (not quit-config)
3969 (progn
3970 ;; Update the info -- marks might need to be removed,
3971 ;; for instance.
3972 (gnus-summary-update-info)
3973 (set-buffer gnus-group-buffer)
3974 (gnus-group-jump-to-group group)
3975 (gnus-group-next-unread-group 1))
3976 (gnus-handle-ephemeral-exit quit-config)))
3977 (if (null (gnus-list-of-unread-articles group))
3978 (gnus-message 3 "Group %s contains no messages" group)
3979 (gnus-message 3 "Can't select group"))
3980 nil)
3981 ;; The user did a `C-g' while prompting for number of articles,
3982 ;; so we exit this group.
3983 ((eq did-select 'quit)
3984 (and (eq major-mode 'gnus-summary-mode)
3985 (not (equal (current-buffer) kill-buffer))
3986 (kill-buffer (current-buffer)))
3987 (when kill-buffer
3988 (gnus-kill-or-deaden-summary kill-buffer))
3989 (if (not quit-config)
3990 (progn
3991 (set-buffer gnus-group-buffer)
3992 (gnus-group-jump-to-group group)
3993 (gnus-configure-windows 'group 'force))
3994 (gnus-handle-ephemeral-exit quit-config))
3995 ;; Finally signal the quit.
3996 (signal 'quit nil))
3997 ;; The group was successfully selected.
3999 (gnus-set-global-variables)
4000 ;; Save the active value in effect when the group was entered.
4001 (setq gnus-newsgroup-active
4002 (gnus-copy-sequence
4003 (gnus-active gnus-newsgroup-name)))
4004 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4005 ;; You can change the summary buffer in some way with this hook.
4006 (gnus-run-hooks 'gnus-select-group-hook)
4007 (when (memq 'summary (gnus-update-format-specifications
4008 nil 'summary 'summary-mode 'summary-dummy))
4009 ;; The format specification for the summary line was updated,
4010 ;; so we need to update the mark positions as well.
4011 (gnus-update-summary-mark-positions))
4012 ;; Do score processing.
4013 (when gnus-use-scoring
4014 (gnus-possibly-score-headers))
4015 ;; Check whether to fill in the gaps in the threads.
4016 (when gnus-build-sparse-threads
4017 (gnus-build-sparse-threads))
4018 ;; Find the initial limit.
4019 (if show-all
4020 (let ((gnus-newsgroup-dormant nil))
4021 (gnus-summary-initial-limit show-all))
4022 (gnus-summary-initial-limit show-all))
4023 ;; Generate the summary buffer.
4024 (unless no-display
4025 (gnus-summary-prepare))
4026 (when gnus-use-trees
4027 (gnus-tree-open group)
4028 (setq gnus-summary-highlight-line-function
4029 'gnus-tree-highlight-article))
4030 ;; If the summary buffer is empty, but there are some low-scored
4031 ;; articles or some excluded dormants, we include these in the
4032 ;; buffer.
4033 (when (and (zerop (buffer-size))
4034 (not no-display))
4035 (cond (gnus-newsgroup-dormant
4036 (gnus-summary-limit-include-dormant))
4037 ((and gnus-newsgroup-scored show-all)
4038 (gnus-summary-limit-include-expunged t))))
4039 ;; Function `gnus-apply-kill-file' must be called in this hook.
4040 (gnus-run-hooks 'gnus-apply-kill-hook)
4041 (if (and (zerop (buffer-size))
4042 (not no-display))
4043 (progn
4044 ;; This newsgroup is empty.
4045 (gnus-summary-catchup-and-exit nil t)
4046 (gnus-message 6 "No unread news")
4047 (when kill-buffer
4048 (gnus-kill-or-deaden-summary kill-buffer))
4049 ;; Return nil from this function.
4050 nil)
4051 ;; Hide conversation thread subtrees. We cannot do this in
4052 ;; gnus-summary-prepare-hook since kill processing may not
4053 ;; work with hidden articles.
4054 (gnus-summary-maybe-hide-threads)
4055 (gnus-configure-windows 'summary)
4056 (when kill-buffer
4057 (gnus-kill-or-deaden-summary kill-buffer))
4058 (gnus-summary-auto-select-subject)
4059 ;; Show first unread article if requested.
4060 (if (and (not no-article)
4061 (not no-display)
4062 gnus-newsgroup-unreads
4063 gnus-auto-select-first)
4064 (progn
4065 (let ((art (gnus-summary-article-number)))
4066 (unless (and (not gnus-plugged)
4067 (or (memq art gnus-newsgroup-undownloaded)
4068 (memq art gnus-newsgroup-downloadable)))
4069 (gnus-summary-goto-article art))))
4070 ;; Don't select any articles.
4071 (gnus-summary-position-point)
4072 (gnus-configure-windows 'summary 'force)
4073 (gnus-set-mode-line 'summary))
4074 (when (and gnus-auto-center-group
4075 (get-buffer-window gnus-group-buffer t))
4076 ;; Gotta use windows, because recenter does weird stuff if
4077 ;; the current buffer ain't the displayed window.
4078 (let ((owin (selected-window)))
4079 (select-window (get-buffer-window gnus-group-buffer t))
4080 (when (gnus-group-goto-group group)
4081 (recenter))
4082 (select-window owin)))
4083 ;; Mark this buffer as "prepared".
4084 (setq gnus-newsgroup-prepared t)
4085 (gnus-run-hooks 'gnus-summary-prepared-hook)
4086 (unless (gnus-ephemeral-group-p group)
4087 (gnus-group-update-group group nil t))
4088 t)))))
4090 (defun gnus-summary-auto-select-subject ()
4091 "Select the subject line on initial group entry."
4092 (goto-char (point-min))
4093 (cond
4094 ((eq gnus-auto-select-subject 'best)
4095 (gnus-summary-best-unread-subject))
4096 ((eq gnus-auto-select-subject 'unread)
4097 (gnus-summary-first-unread-subject))
4098 ((eq gnus-auto-select-subject 'unseen)
4099 (gnus-summary-first-unseen-subject))
4100 ((eq gnus-auto-select-subject 'unseen-or-unread)
4101 (gnus-summary-first-unseen-or-unread-subject))
4102 ((eq gnus-auto-select-subject 'first)
4103 ;; Do nothing.
4105 ((functionp gnus-auto-select-subject)
4106 (funcall gnus-auto-select-subject))))
4108 (defun gnus-summary-prepare ()
4109 "Generate the summary buffer."
4110 (interactive)
4111 (let ((inhibit-read-only t))
4112 (erase-buffer)
4113 (setq gnus-newsgroup-data nil
4114 gnus-newsgroup-data-reverse nil)
4115 (gnus-run-hooks 'gnus-summary-generate-hook)
4116 ;; Generate the buffer, either with threads or without.
4117 (when gnus-newsgroup-headers
4118 (gnus-summary-prepare-threads
4119 (if gnus-show-threads
4120 (gnus-sort-gathered-threads
4121 (funcall gnus-summary-thread-gathering-function
4122 (gnus-sort-threads
4123 (gnus-cut-threads (gnus-make-threads)))))
4124 ;; Unthreaded display.
4125 (gnus-sort-articles gnus-newsgroup-headers))))
4126 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4127 ;; Call hooks for modifying summary buffer.
4128 (goto-char (point-min))
4129 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4131 (defsubst gnus-general-simplify-subject (subject)
4132 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4133 (setq subject
4134 (cond
4135 ;; Truncate the subject.
4136 (gnus-simplify-subject-functions
4137 (gnus-map-function gnus-simplify-subject-functions subject))
4138 ((numberp gnus-summary-gather-subject-limit)
4139 (setq subject (gnus-simplify-subject-re subject))
4140 (if (> (length subject) gnus-summary-gather-subject-limit)
4141 (substring subject 0 gnus-summary-gather-subject-limit)
4142 subject))
4143 ;; Fuzzily simplify it.
4144 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4145 (gnus-simplify-subject-fuzzy subject))
4146 ;; Just remove the leading "Re:".
4148 (gnus-simplify-subject-re subject))))
4150 (if (and gnus-summary-gather-exclude-subject
4151 (string-match gnus-summary-gather-exclude-subject subject))
4152 nil ; This article shouldn't be gathered
4153 subject))
4155 (defun gnus-summary-simplify-subject-query ()
4156 "Query where the respool algorithm would put this article."
4157 (interactive)
4158 (gnus-summary-select-article)
4159 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4161 (defun gnus-gather-threads-by-subject (threads)
4162 "Gather threads by looking at Subject headers."
4163 (if (not gnus-summary-make-false-root)
4164 threads
4165 (let ((hashtb (gnus-make-hashtable 1024))
4166 (prev threads)
4167 (result threads)
4168 subject hthread whole-subject)
4169 (while threads
4170 (setq subject (gnus-general-simplify-subject
4171 (setq whole-subject (mail-header-subject
4172 (caar threads)))))
4173 (when subject
4174 (if (setq hthread (gnus-gethash subject hashtb))
4175 (progn
4176 ;; We enter a dummy root into the thread, if we
4177 ;; haven't done that already.
4178 (unless (stringp (caar hthread))
4179 (setcar hthread (list whole-subject (car hthread))))
4180 ;; We add this new gathered thread to this gathered
4181 ;; thread.
4182 (setcdr (car hthread)
4183 (nconc (cdar hthread) (list (car threads))))
4184 ;; Remove it from the list of threads.
4185 (setcdr prev (cdr threads))
4186 (setq threads prev))
4187 ;; Enter this thread into the hash table.
4188 (gnus-sethash subject
4189 (if gnus-summary-make-false-root-always
4190 (progn
4191 ;; If you want a dummy root above all
4192 ;; threads...
4193 (setcar threads (list whole-subject
4194 (car threads)))
4195 threads)
4196 threads)
4197 hashtb)))
4198 (setq prev threads)
4199 (setq threads (cdr threads)))
4200 result)))
4202 (defun gnus-gather-threads-by-references (threads)
4203 "Gather threads by looking at References headers."
4204 (let ((idhashtb (gnus-make-hashtable 1024))
4205 (thhashtb (gnus-make-hashtable 1024))
4206 (prev threads)
4207 (result threads)
4208 ids references id gthread gid entered ref)
4209 (while threads
4210 (when (setq references (mail-header-references (caar threads)))
4211 (setq id (mail-header-id (caar threads))
4212 ids (inline (gnus-split-references references))
4213 entered nil)
4214 (while (setq ref (pop ids))
4215 (setq ids (delete ref ids))
4216 (if (not (setq gid (gnus-gethash ref idhashtb)))
4217 (progn
4218 (gnus-sethash ref id idhashtb)
4219 (gnus-sethash id threads thhashtb))
4220 (setq gthread (gnus-gethash gid thhashtb))
4221 (unless entered
4222 ;; We enter a dummy root into the thread, if we
4223 ;; haven't done that already.
4224 (unless (stringp (caar gthread))
4225 (setcar gthread (list (mail-header-subject (caar gthread))
4226 (car gthread))))
4227 ;; We add this new gathered thread to this gathered
4228 ;; thread.
4229 (setcdr (car gthread)
4230 (nconc (cdar gthread) (list (car threads)))))
4231 ;; Add it into the thread hash table.
4232 (gnus-sethash id gthread thhashtb)
4233 (setq entered t)
4234 ;; Remove it from the list of threads.
4235 (setcdr prev (cdr threads))
4236 (setq threads prev))))
4237 (setq prev threads)
4238 (setq threads (cdr threads)))
4239 result))
4241 (defun gnus-sort-gathered-threads (threads)
4242 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4243 (let ((result threads))
4244 (while threads
4245 (when (stringp (caar threads))
4246 (setcdr (car threads)
4247 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4248 (setq threads (cdr threads)))
4249 result))
4251 (defun gnus-thread-loop-p (root thread)
4252 "Say whether ROOT is in THREAD."
4253 (let ((stack (list thread))
4254 (infloop 0)
4256 (while (setq thread (pop stack))
4257 (setq th (cdr thread))
4258 (while (and th
4259 (not (eq (caar th) root)))
4260 (pop th))
4261 (if th
4262 ;; We have found a loop.
4263 (let (ref-dep)
4264 (setcdr thread (delq (car th) (cdr thread)))
4265 (if (boundp (setq ref-dep (intern "none"
4266 gnus-newsgroup-dependencies)))
4267 (setcdr (symbol-value ref-dep)
4268 (nconc (cdr (symbol-value ref-dep))
4269 (list (car th))))
4270 (set ref-dep (list nil (car th))))
4271 (setq infloop 1
4272 stack nil))
4273 ;; Push all the subthreads onto the stack.
4274 (push (cdr thread) stack)))
4275 infloop))
4277 (defun gnus-make-threads ()
4278 "Go through the dependency hashtb and find the roots. Return all threads."
4279 (let (threads)
4280 (while (catch 'infloop
4281 (mapatoms
4282 (lambda (refs)
4283 ;; Deal with self-referencing References loops.
4284 (when (and (car (symbol-value refs))
4285 (not (zerop
4286 (apply
4288 (mapcar
4289 (lambda (thread)
4290 (gnus-thread-loop-p
4291 (car (symbol-value refs)) thread))
4292 (cdr (symbol-value refs)))))))
4293 (setq threads nil)
4294 (throw 'infloop t))
4295 (unless (car (symbol-value refs))
4296 ;; These threads do not refer back to any other
4297 ;; articles, so they're roots.
4298 (setq threads (append (cdr (symbol-value refs)) threads))))
4299 gnus-newsgroup-dependencies)))
4300 threads))
4302 ;; Build the thread tree.
4303 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4304 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4306 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4307 if it was already present.
4309 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4310 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4311 Message-IDs will be renamed to a unique Message-ID before being
4312 entered.
4314 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4315 (let* ((id (mail-header-id header))
4316 (id-dep (and id (intern id dependencies)))
4317 parent-id ref ref-dep ref-header replaced)
4318 ;; Enter this `header' in the `dependencies' table.
4319 (cond
4320 ((not id-dep)
4321 (setq header nil))
4322 ;; The first two cases do the normal part: enter a new `header'
4323 ;; in the `dependencies' table.
4324 ((not (boundp id-dep))
4325 (set id-dep (list header)))
4326 ((null (car (symbol-value id-dep)))
4327 (setcar (symbol-value id-dep) header))
4329 ;; From here the `header' was already present in the
4330 ;; `dependencies' table.
4331 (force-new
4332 ;; Overrides an existing entry;
4333 ;; just set the header part of the entry.
4334 (setcar (symbol-value id-dep) header)
4335 (setq replaced t))
4337 ;; Renames the existing `header' to a unique Message-ID.
4338 ((not gnus-summary-ignore-duplicates)
4339 ;; An article with this Message-ID has already been seen.
4340 ;; We rename the Message-ID.
4341 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4342 (list header))
4343 (mail-header-set-id header id))
4345 ;; The last case ignores an existing entry, except it adds any
4346 ;; additional Xrefs (in case the two articles came from different
4347 ;; servers.
4348 ;; Also sets `header' to `nil' meaning that the `dependencies'
4349 ;; table was *not* modified.
4351 (mail-header-set-xref
4352 (car (symbol-value id-dep))
4353 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4355 (or (mail-header-xref header) "")))
4356 (setq header nil)))
4358 (when (and header (not replaced))
4359 ;; First check that we are not creating a References loop.
4360 (setq parent-id (gnus-parent-id (mail-header-references header)))
4361 (setq ref parent-id)
4362 (while (and ref
4363 (setq ref-dep (intern-soft ref dependencies))
4364 (boundp ref-dep)
4365 (setq ref-header (car (symbol-value ref-dep))))
4366 (if (string= id ref)
4367 ;; Yuk! This is a reference loop. Make the article be a
4368 ;; root article.
4369 (progn
4370 (mail-header-set-references (car (symbol-value id-dep)) "none")
4371 (setq ref nil)
4372 (setq parent-id nil))
4373 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4374 (setq ref-dep (intern (or parent-id "none") dependencies))
4375 (if (boundp ref-dep)
4376 (setcdr (symbol-value ref-dep)
4377 (nconc (cdr (symbol-value ref-dep))
4378 (list (symbol-value id-dep))))
4379 (set ref-dep (list nil (symbol-value id-dep)))))
4380 header))
4382 (defun gnus-extract-message-id-from-in-reply-to (string)
4383 (if (string-match "<[^>]+>" string)
4384 (substring string (match-beginning 0) (match-end 0))
4385 nil))
4387 (defun gnus-build-sparse-threads ()
4388 (let ((headers gnus-newsgroup-headers)
4389 (mail-parse-charset gnus-newsgroup-charset)
4390 (gnus-summary-ignore-duplicates t)
4391 header references generation relations
4392 subject child end new-child date)
4393 ;; First we create an alist of generations/relations, where
4394 ;; generations is how much we trust the relation, and the relation
4395 ;; is parent/child.
4396 (gnus-message 7 "Making sparse threads...")
4397 (save-excursion
4398 (nnheader-set-temp-buffer " *gnus sparse threads*")
4399 (while (setq header (pop headers))
4400 (when (and (setq references (mail-header-references header))
4401 (not (string= references "")))
4402 (insert references)
4403 (setq child (mail-header-id header)
4404 subject (mail-header-subject header)
4405 date (mail-header-date header)
4406 generation 0)
4407 (while (search-backward ">" nil t)
4408 (setq end (1+ (point)))
4409 (when (search-backward "<" nil t)
4410 (setq new-child (buffer-substring (point) end))
4411 (push (list (incf generation)
4412 child (setq child new-child)
4413 subject date)
4414 relations)))
4415 (when child
4416 (push (list (1+ generation) child nil subject) relations))
4417 (erase-buffer)))
4418 (kill-buffer (current-buffer)))
4419 ;; Sort over trustworthiness.
4420 (dolist (relation (sort relations 'car-less-than-car))
4421 (when (gnus-dependencies-add-header
4422 (make-full-mail-header
4423 gnus-reffed-article-number
4424 (nth 3 relation) "" (or (nth 4 relation) "")
4425 (nth 1 relation)
4426 (or (nth 2 relation) "") 0 0 "")
4427 gnus-newsgroup-dependencies nil)
4428 (push gnus-reffed-article-number gnus-newsgroup-limit)
4429 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4430 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4431 gnus-newsgroup-reads)
4432 (decf gnus-reffed-article-number)))
4433 (gnus-message 7 "Making sparse threads...done")))
4435 (defun gnus-build-old-threads ()
4436 ;; Look at all the articles that refer back to old articles, and
4437 ;; fetch the headers for the articles that aren't there. This will
4438 ;; build complete threads - if the roots haven't been expired by the
4439 ;; server, that is.
4440 (let ((mail-parse-charset gnus-newsgroup-charset)
4441 id heads)
4442 (mapatoms
4443 (lambda (refs)
4444 (when (not (car (symbol-value refs)))
4445 (setq heads (cdr (symbol-value refs)))
4446 (while heads
4447 (if (memq (mail-header-number (caar heads))
4448 gnus-newsgroup-dormant)
4449 (setq heads (cdr heads))
4450 (setq id (symbol-name refs))
4451 (while (and (setq id (gnus-build-get-header id))
4452 (not (car (gnus-id-to-thread id)))))
4453 (setq heads nil)))))
4454 gnus-newsgroup-dependencies)))
4456 (defsubst gnus-remove-odd-characters (string)
4457 "Translate STRING into something that doesn't contain weird characters."
4458 (mm-subst-char-in-string
4459 ?\r ?\-
4460 (mm-subst-char-in-string ?\n ?\- string t) t))
4462 ;; This function has to be called with point after the article number
4463 ;; on the beginning of the line.
4464 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4465 (let ((eol (point-at-eol))
4466 (buffer (current-buffer))
4467 header references in-reply-to)
4469 ;; overview: [num subject from date id refs chars lines misc]
4470 (unwind-protect
4471 (let (x)
4472 (narrow-to-region (point) eol)
4473 (unless (eobp)
4474 (forward-char))
4476 (setq header
4477 (make-full-mail-header
4478 number ; number
4479 (condition-case () ; subject
4480 (gnus-remove-odd-characters
4481 (funcall gnus-decode-encoded-word-function
4482 (setq x (nnheader-nov-field))))
4483 (error x))
4484 (condition-case () ; from
4485 (gnus-remove-odd-characters
4486 (funcall gnus-decode-encoded-address-function
4487 (setq x (nnheader-nov-field))))
4488 (error x))
4489 (nnheader-nov-field) ; date
4490 (nnheader-nov-read-message-id number) ; id
4491 (setq references (nnheader-nov-field)) ; refs
4492 (nnheader-nov-read-integer) ; chars
4493 (nnheader-nov-read-integer) ; lines
4494 (unless (eobp)
4495 (if (looking-at "Xref: ")
4496 (goto-char (match-end 0)))
4497 (nnheader-nov-field)) ; Xref
4498 (nnheader-nov-parse-extra)))) ; extra
4500 (widen))
4502 (when (and (string= references "")
4503 (setq in-reply-to (mail-header-extra header))
4504 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4505 (mail-header-set-references
4506 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4508 (when gnus-alter-header-function
4509 (funcall gnus-alter-header-function header))
4510 (gnus-dependencies-add-header header dependencies force-new)))
4512 (defun gnus-build-get-header (id)
4513 "Look through the buffer of NOV lines and find the header to ID.
4514 Enter this line into the dependencies hash table, and return
4515 the id of the parent article (if any)."
4516 (let ((deps gnus-newsgroup-dependencies)
4517 found header)
4518 (prog1
4519 (with-current-buffer nntp-server-buffer
4520 (let ((case-fold-search nil))
4521 (goto-char (point-min))
4522 (while (and (not found)
4523 (search-forward id nil t))
4524 (beginning-of-line)
4525 (setq found (looking-at
4526 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4527 (regexp-quote id))))
4528 (or found (beginning-of-line 2)))
4529 (when found
4530 (beginning-of-line)
4531 (and
4532 (setq header (gnus-nov-parse-line
4533 (read (current-buffer)) deps))
4534 (gnus-parent-id (mail-header-references header))))))
4535 (when header
4536 (let ((number (mail-header-number header)))
4537 (push number gnus-newsgroup-limit)
4538 (push header gnus-newsgroup-headers)
4539 (if (memq number gnus-newsgroup-unselected)
4540 (progn
4541 (setq gnus-newsgroup-unreads
4542 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4543 number))
4544 (setq gnus-newsgroup-unselected
4545 (delq number gnus-newsgroup-unselected)))
4546 (push number gnus-newsgroup-ancient)))))))
4548 (defun gnus-build-all-threads ()
4549 "Read all the headers."
4550 (let ((gnus-summary-ignore-duplicates t)
4551 (mail-parse-charset gnus-newsgroup-charset)
4552 (dependencies gnus-newsgroup-dependencies)
4553 header article)
4554 (with-current-buffer nntp-server-buffer
4555 (let ((case-fold-search nil))
4556 (goto-char (point-min))
4557 (while (not (eobp))
4558 (ignore-errors
4559 (setq article (read (current-buffer))
4560 header (gnus-nov-parse-line article dependencies t)))
4561 (when header
4562 (with-current-buffer gnus-summary-buffer
4563 (push header gnus-newsgroup-headers)
4564 (if (memq (setq article (mail-header-number header))
4565 gnus-newsgroup-unselected)
4566 (progn
4567 (setq gnus-newsgroup-unreads
4568 (gnus-add-to-sorted-list
4569 gnus-newsgroup-unreads article))
4570 (setq gnus-newsgroup-unselected
4571 (delq article gnus-newsgroup-unselected)))
4572 (push article gnus-newsgroup-ancient)))
4573 (forward-line 1)))))))
4575 (defun gnus-summary-update-article-line (article header)
4576 "Update the line for ARTICLE using HEADER."
4577 (let* ((id (mail-header-id header))
4578 (thread (gnus-id-to-thread id)))
4579 (unless thread
4580 (error "Article in no thread"))
4581 ;; Update the thread.
4582 (setcar thread header)
4583 (gnus-summary-goto-subject article)
4584 (let* ((datal (gnus-data-find-list article))
4585 (data (car datal))
4586 (inhibit-read-only t)
4587 (level (gnus-summary-thread-level)))
4588 (gnus-delete-line)
4589 (let ((inserted (- (point)
4590 (progn
4591 (gnus-summary-insert-line
4592 header level nil
4593 (memq article gnus-newsgroup-undownloaded)
4594 (gnus-article-mark article)
4595 (memq article gnus-newsgroup-replied)
4596 (memq article gnus-newsgroup-expirable)
4597 ;; Only insert the Subject string when it's different
4598 ;; from the previous Subject string.
4599 (if (and
4600 gnus-show-threads
4601 (gnus-subject-equal
4602 (condition-case ()
4603 (mail-header-subject
4604 (gnus-data-header
4605 (cadr
4606 (gnus-data-find-list
4607 article
4608 (gnus-data-list t)))))
4609 ;; Error on the side of excessive subjects.
4610 (error ""))
4611 (mail-header-subject header)))
4613 (mail-header-subject header))
4614 nil (cdr (assq article gnus-newsgroup-scored))
4615 (memq article gnus-newsgroup-processable))
4616 (point)))))
4617 (when (cdr datal)
4618 (gnus-data-update-list
4619 (cdr datal)
4620 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4622 (defun gnus-summary-update-article (article &optional iheader)
4623 "Update ARTICLE in the summary buffer."
4624 (set-buffer gnus-summary-buffer)
4625 (let* ((header (gnus-summary-article-header article))
4626 (id (mail-header-id header))
4627 (data (gnus-data-find article))
4628 (thread (gnus-id-to-thread id))
4629 (references (mail-header-references header))
4630 (parent
4631 (gnus-id-to-thread
4632 (or (gnus-parent-id
4633 (when (and references
4634 (not (equal "" references)))
4635 references))
4636 "none")))
4637 (inhibit-read-only t)
4638 (old (car thread)))
4639 (when thread
4640 (unless iheader
4641 (setcar thread nil)
4642 (when parent
4643 (delq thread parent)))
4644 (if (gnus-summary-insert-subject id header)
4645 ;; Set the (possibly) new article number in the data structure.
4646 (gnus-data-set-number data (gnus-id-to-article id))
4647 (setcar thread old)
4648 nil))))
4650 (defun gnus-rebuild-thread (id &optional line)
4651 "Rebuild the thread containing ID.
4652 If LINE, insert the rebuilt thread starting on line LINE."
4653 (let ((inhibit-read-only t)
4654 old-pos current thread data)
4655 (if (not gnus-show-threads)
4656 (setq thread (list (car (gnus-id-to-thread id))))
4657 ;; Get the thread this article is part of.
4658 (setq thread (gnus-remove-thread id)))
4659 (setq old-pos (point-at-bol))
4660 (setq current (save-excursion
4661 (and (re-search-backward "[\r\n]" nil t)
4662 (gnus-summary-article-number))))
4663 ;; If this is a gathered thread, we have to go some re-gathering.
4664 (when (stringp (car thread))
4665 (let ((subject (car thread))
4666 roots thr)
4667 (setq thread (cdr thread))
4668 (while thread
4669 (unless (memq (setq thr (gnus-id-to-thread
4670 (gnus-root-id
4671 (mail-header-id (caar thread)))))
4672 roots)
4673 (push thr roots))
4674 (setq thread (cdr thread)))
4675 ;; We now have all (unique) roots.
4676 (if (= (length roots) 1)
4677 ;; All the loose roots are now one solid root.
4678 (setq thread (car roots))
4679 (setq thread (cons subject (gnus-sort-threads roots))))))
4680 (let (threads)
4681 ;; We then insert this thread into the summary buffer.
4682 (when line
4683 (goto-char (point-min))
4684 (forward-line (1- line)))
4685 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4686 (if gnus-show-threads
4687 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4688 (gnus-summary-prepare-unthreaded thread))
4689 (setq data (nreverse gnus-newsgroup-data))
4690 (setq threads gnus-newsgroup-threads))
4691 ;; We splice the new data into the data structure.
4692 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4693 ;;!!! then we want to insert at the beginning of the buffer.
4694 ;;!!! That happens to be true with Gnus now, but that may
4695 ;;!!! change in the future. Perhaps.
4696 (gnus-data-enter-list
4697 (if line nil current) data (- (point) old-pos))
4698 (setq gnus-newsgroup-threads
4699 (nconc threads gnus-newsgroup-threads))
4700 (gnus-data-compute-positions))))
4702 (defun gnus-number-to-header (number)
4703 "Return the header for article NUMBER."
4704 (let ((headers gnus-newsgroup-headers))
4705 (while (and headers
4706 (not (= number (mail-header-number (car headers)))))
4707 (pop headers))
4708 (when headers
4709 (car headers))))
4711 (defun gnus-parent-headers (in-headers &optional generation)
4712 "Return the headers of the GENERATIONth parent of HEADERS."
4713 (unless generation
4714 (setq generation 1))
4715 (let ((parent t)
4716 (headers in-headers)
4717 references)
4718 (while (and parent
4719 (not (zerop generation))
4720 (setq references (mail-header-references headers)))
4721 (setq headers (if (and references
4722 (setq parent (gnus-parent-id references)))
4723 (car (gnus-id-to-thread parent))
4724 nil))
4725 (decf generation))
4726 (and (not (eq headers in-headers))
4727 headers)))
4729 (defun gnus-id-to-thread (id)
4730 "Return the (sub-)thread where ID appears."
4731 (gnus-gethash id gnus-newsgroup-dependencies))
4733 (defun gnus-id-to-article (id)
4734 "Return the article number of ID."
4735 (let ((thread (gnus-id-to-thread id)))
4736 (when (and thread
4737 (car thread))
4738 (mail-header-number (car thread)))))
4740 (defun gnus-id-to-header (id)
4741 "Return the article headers of ID."
4742 (car (gnus-id-to-thread id)))
4744 (defun gnus-article-displayed-root-p (article)
4745 "Say whether ARTICLE is a root(ish) article."
4746 (let ((level (gnus-summary-thread-level article))
4747 (refs (mail-header-references (gnus-summary-article-header article)))
4748 particle)
4749 (cond
4750 ((null level) nil)
4751 ((zerop level) t)
4752 ((null refs) t)
4753 ((null (gnus-parent-id refs)) t)
4754 ((and (= 1 level)
4755 (null (setq particle (gnus-id-to-article
4756 (gnus-parent-id refs))))
4757 (null (gnus-summary-thread-level particle)))))))
4759 (defun gnus-root-id (id)
4760 "Return the id of the root of the thread where ID appears."
4761 (let (last-id prev)
4762 (while (and id (setq prev (car (gnus-id-to-thread id))))
4763 (setq last-id id
4764 id (gnus-parent-id (mail-header-references prev))))
4765 last-id))
4767 (defun gnus-articles-in-thread (thread)
4768 "Return the list of articles in THREAD."
4769 (cons (mail-header-number (car thread))
4770 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4772 (defun gnus-remove-thread (id &optional dont-remove)
4773 "Remove the thread that has ID in it."
4774 (let (headers thread last-id)
4775 ;; First go up in this thread until we find the root.
4776 (setq last-id (gnus-root-id id)
4777 headers (message-flatten-list (gnus-id-to-thread last-id)))
4778 ;; We have now found the real root of this thread. It might have
4779 ;; been gathered into some loose thread, so we have to search
4780 ;; through the threads to find the thread we wanted.
4781 (let ((threads gnus-newsgroup-threads)
4782 sub)
4783 (while threads
4784 (setq sub (car threads))
4785 (if (stringp (car sub))
4786 ;; This is a gathered thread, so we look at the roots
4787 ;; below it to find whether this article is in this
4788 ;; gathered root.
4789 (progn
4790 (setq sub (cdr sub))
4791 (while sub
4792 (when (member (caar sub) headers)
4793 (setq thread (car threads)
4794 threads nil
4795 sub nil))
4796 (setq sub (cdr sub))))
4797 ;; It's an ordinary thread, so we check it.
4798 (when (eq (car sub) (car headers))
4799 (setq thread sub
4800 threads nil)))
4801 (setq threads (cdr threads)))
4802 ;; If this article is in no thread, then it's a root.
4803 (if thread
4804 (unless dont-remove
4805 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4806 (setq thread (gnus-id-to-thread last-id)))
4807 (when thread
4808 (prog1
4809 thread ; We return this thread.
4810 (unless dont-remove
4811 (if (stringp (car thread))
4812 (progn
4813 ;; If we use dummy roots, then we have to remove the
4814 ;; dummy root as well.
4815 (when (eq gnus-summary-make-false-root 'dummy)
4816 ;; We go to the dummy root by going to
4817 ;; the first sub-"thread", and then one line up.
4818 (gnus-summary-goto-article
4819 (mail-header-number (caadr thread)))
4820 (forward-line -1)
4821 (gnus-delete-line)
4822 (gnus-data-compute-positions))
4823 (setq thread (cdr thread))
4824 (while thread
4825 (gnus-remove-thread-1 (car thread))
4826 (setq thread (cdr thread))))
4827 (gnus-remove-thread-1 thread))))))))
4829 (defun gnus-remove-thread-1 (thread)
4830 "Remove the thread THREAD recursively."
4831 (let ((number (mail-header-number (pop thread)))
4833 (setq thread (reverse thread))
4834 (while thread
4835 (gnus-remove-thread-1 (pop thread)))
4836 (when (setq d (gnus-data-find number))
4837 (goto-char (gnus-data-pos d))
4838 (gnus-summary-show-thread)
4839 (gnus-data-remove
4840 number
4841 (- (point-at-bol)
4842 (prog1
4843 (1+ (point-at-eol))
4844 (gnus-delete-line)))))))
4846 (defun gnus-sort-threads-recursive (threads func)
4847 (sort (mapcar (lambda (thread)
4848 (cons (car thread)
4849 (and (cdr thread)
4850 (gnus-sort-threads-recursive (cdr thread) func))))
4851 threads) func))
4853 (defun gnus-sort-threads-loop (threads func)
4854 (let* ((superthread (cons nil threads))
4855 (stack (list (cons superthread threads)))
4856 remaining-threads thread)
4857 (while stack
4858 (setq remaining-threads (cdr (car stack)))
4859 (if remaining-threads
4860 (progn (setq thread (car remaining-threads))
4861 (setcdr (car stack) (cdr remaining-threads))
4862 (if (cdr thread)
4863 (push (cons thread (cdr thread)) stack)))
4864 (setq thread (caar stack))
4865 (setcdr thread (sort (cdr thread) func))
4866 (pop stack)))
4867 (cdr superthread)))
4869 (defun gnus-sort-threads (threads)
4870 "Sort THREADS."
4871 (if (not gnus-thread-sort-functions)
4872 threads
4873 (gnus-message 8 "Sorting threads...")
4874 (prog1
4875 (condition-case nil
4876 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4877 (gnus-sort-threads-recursive
4878 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4879 ;; Even after binding max-lisp-eval-depth, the recursive
4880 ;; sorter might fail for very long threads. In that case,
4881 ;; try using a (less well-tested) non-recursive sorter.
4882 (error (gnus-message 9 "Sorting threads with loop...")
4883 (gnus-sort-threads-loop
4884 threads (gnus-make-sort-function
4885 gnus-thread-sort-functions))))
4886 (gnus-message 8 "Sorting threads...done"))))
4888 (defun gnus-sort-articles (articles)
4889 "Sort ARTICLES."
4890 (when gnus-article-sort-functions
4891 (gnus-message 7 "Sorting articles...")
4892 (prog1
4893 (setq gnus-newsgroup-headers
4894 (sort articles (gnus-make-sort-function
4895 gnus-article-sort-functions)))
4896 (gnus-message 7 "Sorting articles...done"))))
4898 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4899 (defmacro gnus-thread-header (thread)
4900 "Return header of first article in THREAD.
4901 Note that THREAD must never, ever be anything else than a variable -
4902 using some other form will lead to serious barfage."
4903 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4904 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4905 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4906 (vector thread) 2))
4908 (defsubst gnus-article-sort-by-number (h1 h2)
4909 "Sort articles by article number."
4910 (< (mail-header-number h1)
4911 (mail-header-number h2)))
4913 (defun gnus-thread-sort-by-number (h1 h2)
4914 "Sort threads by root article number."
4915 (gnus-article-sort-by-number
4916 (gnus-thread-header h1) (gnus-thread-header h2)))
4918 (defsubst gnus-article-sort-by-random (h1 h2)
4919 "Sort articles randomly."
4920 (zerop (random 2)))
4922 (defun gnus-thread-sort-by-random (h1 h2)
4923 "Sort threads randomly."
4924 (gnus-article-sort-by-random
4925 (gnus-thread-header h1) (gnus-thread-header h2)))
4927 (defsubst gnus-article-sort-by-lines (h1 h2)
4928 "Sort articles by article Lines header."
4929 (< (mail-header-lines h1)
4930 (mail-header-lines h2)))
4932 (defun gnus-thread-sort-by-lines (h1 h2)
4933 "Sort threads by root article Lines header."
4934 (gnus-article-sort-by-lines
4935 (gnus-thread-header h1) (gnus-thread-header h2)))
4937 (defsubst gnus-article-sort-by-chars (h1 h2)
4938 "Sort articles by octet length."
4939 (< (mail-header-chars h1)
4940 (mail-header-chars h2)))
4942 (defun gnus-thread-sort-by-chars (h1 h2)
4943 "Sort threads by root article octet length."
4944 (gnus-article-sort-by-chars
4945 (gnus-thread-header h1) (gnus-thread-header h2)))
4947 (defsubst gnus-article-sort-by-author (h1 h2)
4948 "Sort articles by root author."
4949 (gnus-string<
4950 (let ((extract (funcall
4951 gnus-extract-address-components
4952 (mail-header-from h1))))
4953 (or (car extract) (cadr extract) ""))
4954 (let ((extract (funcall
4955 gnus-extract-address-components
4956 (mail-header-from h2))))
4957 (or (car extract) (cadr extract) ""))))
4959 (defun gnus-thread-sort-by-author (h1 h2)
4960 "Sort threads by root author."
4961 (gnus-article-sort-by-author
4962 (gnus-thread-header h1) (gnus-thread-header h2)))
4964 (defsubst gnus-article-sort-by-recipient (h1 h2)
4965 "Sort articles by recipient."
4966 (gnus-string<
4967 (let ((extract (funcall
4968 gnus-extract-address-components
4969 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4970 (or (car extract) (cadr extract)))
4971 (let ((extract (funcall
4972 gnus-extract-address-components
4973 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4974 (or (car extract) (cadr extract)))))
4976 (defun gnus-thread-sort-by-recipient (h1 h2)
4977 "Sort threads by root recipient."
4978 (gnus-article-sort-by-recipient
4979 (gnus-thread-header h1) (gnus-thread-header h2)))
4981 (defsubst gnus-article-sort-by-subject (h1 h2)
4982 "Sort articles by root subject."
4983 (gnus-string<
4984 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4985 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4987 (defun gnus-thread-sort-by-subject (h1 h2)
4988 "Sort threads by root subject."
4989 (gnus-article-sort-by-subject
4990 (gnus-thread-header h1) (gnus-thread-header h2)))
4992 (defsubst gnus-article-sort-by-date (h1 h2)
4993 "Sort articles by root article date."
4994 (time-less-p
4995 (gnus-date-get-time (mail-header-date h1))
4996 (gnus-date-get-time (mail-header-date h2))))
4998 (defun gnus-thread-sort-by-date (h1 h2)
4999 "Sort threads by root article date."
5000 (gnus-article-sort-by-date
5001 (gnus-thread-header h1) (gnus-thread-header h2)))
5003 (defsubst gnus-article-sort-by-score (h1 h2)
5004 "Sort articles by root article score.
5005 Unscored articles will be counted as having a score of zero."
5006 (> (or (cdr (assq (mail-header-number h1)
5007 gnus-newsgroup-scored))
5008 gnus-summary-default-score 0)
5009 (or (cdr (assq (mail-header-number h2)
5010 gnus-newsgroup-scored))
5011 gnus-summary-default-score 0)))
5013 (defun gnus-thread-sort-by-score (h1 h2)
5014 "Sort threads by root article score."
5015 (gnus-article-sort-by-score
5016 (gnus-thread-header h1) (gnus-thread-header h2)))
5018 (defun gnus-thread-sort-by-total-score (h1 h2)
5019 "Sort threads by the sum of all scores in the thread.
5020 Unscored articles will be counted as having a score of zero."
5021 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5023 (defun gnus-thread-total-score (thread)
5024 ;; This function find the total score of THREAD.
5025 (cond
5026 ((null thread)
5028 ((consp thread)
5029 (if (stringp (car thread))
5030 (apply gnus-thread-score-function 0
5031 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5032 (gnus-thread-total-score-1 thread)))
5034 (gnus-thread-total-score-1 (list thread)))))
5036 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5037 "Sort articles by number."
5038 (gnus-article-sort-by-number h1 h2))
5040 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5041 "Sort threads such that the thread with the most recently arrived article comes first."
5042 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5044 (defun gnus-thread-highest-number (thread)
5045 "Return the highest article number in THREAD."
5046 (apply 'max (mapcar (lambda (header)
5047 (mail-header-number header))
5048 (message-flatten-list thread))))
5050 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5051 "Sort articles by number."
5052 (gnus-article-sort-by-date h1 h2))
5054 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5055 "Sort threads such that the thread with the most recently dated article comes first."
5056 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5058 ; Since this is called not only to sort the top-level threads, but
5059 ; also in recursive sorts to order the articles within a thread, each
5060 ; article will be processed many times. Thus it speeds things up
5061 ; quite a bit to use gnus-date-get-time, which caches the time value.
5062 (defun gnus-thread-latest-date (thread)
5063 "Return the highest article date in THREAD."
5064 (apply 'max
5065 (mapcar (lambda (header) (gnus-float-time
5066 (gnus-date-get-time
5067 (mail-header-date header))))
5068 (message-flatten-list thread))))
5070 (defun gnus-thread-total-score-1 (root)
5071 ;; This function find the total score of the thread below ROOT.
5072 (setq root (car root))
5073 (apply gnus-thread-score-function
5074 (or (append
5075 (mapcar 'gnus-thread-total-score
5076 (cdr (gnus-id-to-thread (mail-header-id root))))
5077 (when (> (mail-header-number root) 0)
5078 (list (or (cdr (assq (mail-header-number root)
5079 gnus-newsgroup-scored))
5080 gnus-summary-default-score 0))))
5081 (list gnus-summary-default-score)
5082 '(0))))
5084 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5085 (defvar gnus-tmp-prev-subject nil)
5086 (defvar gnus-tmp-false-parent nil)
5087 (defvar gnus-tmp-root-expunged nil)
5088 (defvar gnus-tmp-dummy-line nil)
5090 (defun gnus-extra-header (type &optional header)
5091 "Return the extra header of TYPE."
5092 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5093 ""))
5095 (defvar gnus-tmp-thread-tree-header-string "")
5097 (defcustom gnus-sum-thread-tree-root "> "
5098 "With %B spec, used for the root of a thread.
5099 If nil, use subject instead."
5100 :version "22.1"
5101 :type '(radio (const :format "%v " nil) string)
5102 :group 'gnus-thread)
5104 (defcustom gnus-sum-thread-tree-false-root "> "
5105 "With %B spec, used for a false root of a thread.
5106 If nil, use subject instead."
5107 :version "22.1"
5108 :type '(radio (const :format "%v " nil) string)
5109 :group 'gnus-thread)
5111 (defcustom gnus-sum-thread-tree-single-indent ""
5112 "With %B spec, used for a thread with just one message.
5113 If nil, use subject instead."
5114 :version "22.1"
5115 :type '(radio (const :format "%v " nil) string)
5116 :group 'gnus-thread)
5118 (defcustom gnus-sum-thread-tree-vertical "| "
5119 "With %B spec, used for drawing a vertical line."
5120 :version "22.1"
5121 :type 'string
5122 :group 'gnus-thread)
5124 (defcustom gnus-sum-thread-tree-indent " "
5125 "With %B spec, used for indenting."
5126 :version "22.1"
5127 :type 'string
5128 :group 'gnus-thread)
5130 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5131 "With %B spec, used for a leaf with brothers."
5132 :version "22.1"
5133 :type 'string
5134 :group 'gnus-thread)
5136 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5137 "With %B spec, used for a leaf without brothers."
5138 :version "22.1"
5139 :type 'string
5140 :group 'gnus-thread)
5142 (defcustom gnus-summary-display-while-building nil
5143 "If non-nil, show and update the summary buffer as it's being built.
5144 If the value is t, update the buffer after every line is inserted. If
5145 the value is an integer (N), update the display every N lines."
5146 :version "22.1"
5147 :group 'gnus-thread
5148 :type '(choice (const :tag "off" nil)
5149 number
5150 (const :tag "frequently" t)))
5152 (defun gnus-summary-prepare-threads (threads)
5153 "Prepare summary buffer from THREADS and indentation LEVEL.
5154 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5155 or a straight list of headers."
5156 (gnus-message 7 "Generating summary...")
5158 (setq gnus-newsgroup-threads threads)
5159 (beginning-of-line)
5161 (let ((gnus-tmp-level 0)
5162 (default-score (or gnus-summary-default-score 0))
5163 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5164 (building-line-count gnus-summary-display-while-building)
5165 (building-count (integerp gnus-summary-display-while-building))
5166 thread number subject stack state gnus-tmp-gathered beg-match
5167 new-roots gnus-tmp-new-adopts thread-end simp-subject
5168 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5169 gnus-tmp-replied gnus-tmp-subject-or-nil
5170 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5171 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5172 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5173 tree-stack)
5175 (setq gnus-tmp-prev-subject nil
5176 gnus-tmp-thread-tree-header-string "")
5178 (if (vectorp (car threads))
5179 ;; If this is a straight (sic) list of headers, then a
5180 ;; threaded summary display isn't required, so we just create
5181 ;; an unthreaded one.
5182 (gnus-summary-prepare-unthreaded threads)
5184 ;; Do the threaded display.
5186 (if gnus-summary-display-while-building
5187 (switch-to-buffer (buffer-name)))
5188 (while (or threads stack gnus-tmp-new-adopts new-roots)
5190 (if (and (= gnus-tmp-level 0)
5191 (or (not stack)
5192 (= (caar stack) 0))
5193 (not gnus-tmp-false-parent)
5194 (or gnus-tmp-new-adopts new-roots))
5195 (if gnus-tmp-new-adopts
5196 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5197 thread (list (car gnus-tmp-new-adopts))
5198 gnus-tmp-header (caar thread)
5199 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5200 (when new-roots
5201 (setq thread (list (car new-roots))
5202 gnus-tmp-header (caar thread)
5203 new-roots (cdr new-roots))))
5205 (if threads
5206 ;; If there are some threads, we do them before the
5207 ;; threads on the stack.
5208 (setq thread threads
5209 gnus-tmp-header (caar thread))
5210 ;; There were no current threads, so we pop something off
5211 ;; the stack.
5212 (setq state (car stack)
5213 gnus-tmp-level (car state)
5214 tree-stack (cadr state)
5215 thread (caddr state)
5216 stack (cdr stack)
5217 gnus-tmp-header (caar thread))))
5219 (setq gnus-tmp-false-parent nil)
5220 (setq gnus-tmp-root-expunged nil)
5221 (setq thread-end nil)
5223 (if (stringp gnus-tmp-header)
5224 ;; The header is a dummy root.
5225 (cond
5226 ((eq gnus-summary-make-false-root 'adopt)
5227 ;; We let the first article adopt the rest.
5228 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5229 (cddar thread)))
5230 (setq gnus-tmp-gathered
5231 (nconc (mapcar
5232 (lambda (h) (mail-header-number (car h)))
5233 (cddar thread))
5234 gnus-tmp-gathered))
5235 (setq thread (cons (list (caar thread)
5236 (cadar thread))
5237 (cdr thread)))
5238 (setq gnus-tmp-level -1
5239 gnus-tmp-false-parent t))
5240 ((eq gnus-summary-make-false-root 'empty)
5241 ;; We print adopted articles with empty subject fields.
5242 (setq gnus-tmp-gathered
5243 (nconc (mapcar
5244 (lambda (h) (mail-header-number (car h)))
5245 (cddar thread))
5246 gnus-tmp-gathered))
5247 (setq gnus-tmp-level -1))
5248 ((eq gnus-summary-make-false-root 'dummy)
5249 ;; We remember that we probably want to output a dummy
5250 ;; root.
5251 (setq gnus-tmp-dummy-line gnus-tmp-header)
5252 (setq gnus-tmp-prev-subject gnus-tmp-header))
5254 ;; We do not make a root for the gathered
5255 ;; sub-threads at all.
5256 (setq gnus-tmp-level -1)))
5258 (setq number (mail-header-number gnus-tmp-header)
5259 subject (mail-header-subject gnus-tmp-header)
5260 simp-subject (gnus-simplify-subject-fully subject))
5262 (cond
5263 ;; If the thread has changed subject, we might want to make
5264 ;; this subthread into a root.
5265 ((and (null gnus-thread-ignore-subject)
5266 (not (zerop gnus-tmp-level))
5267 gnus-tmp-prev-subject
5268 (not (string= gnus-tmp-prev-subject simp-subject)))
5269 (setq new-roots (nconc new-roots (list (car thread)))
5270 thread-end t
5271 gnus-tmp-header nil))
5272 ;; If the article lies outside the current limit,
5273 ;; then we do not display it.
5274 ((not (memq number gnus-newsgroup-limit))
5275 (setq gnus-tmp-gathered
5276 (nconc (mapcar
5277 (lambda (h) (mail-header-number (car h)))
5278 (cdar thread))
5279 gnus-tmp-gathered))
5280 (setq gnus-tmp-new-adopts (if (cdar thread)
5281 (append gnus-tmp-new-adopts
5282 (cdar thread))
5283 gnus-tmp-new-adopts)
5284 thread-end t
5285 gnus-tmp-header nil)
5286 (when (zerop gnus-tmp-level)
5287 (setq gnus-tmp-root-expunged t)))
5288 ;; Perhaps this article is to be marked as read?
5289 ((and gnus-summary-mark-below
5290 (< (or (cdr (assq number gnus-newsgroup-scored))
5291 default-score)
5292 gnus-summary-mark-below)
5293 ;; Don't touch sparse articles.
5294 (not (gnus-summary-article-sparse-p number))
5295 (not (gnus-summary-article-ancient-p number)))
5296 (setq gnus-newsgroup-unreads
5297 (delq number gnus-newsgroup-unreads))
5298 (if gnus-newsgroup-auto-expire
5299 (setq gnus-newsgroup-expirable
5300 (gnus-add-to-sorted-list
5301 gnus-newsgroup-expirable number))
5302 (push (cons number gnus-low-score-mark)
5303 gnus-newsgroup-reads))))
5305 (when gnus-tmp-header
5306 ;; We may have an old dummy line to output before this
5307 ;; article.
5308 (when (and gnus-tmp-dummy-line
5309 (gnus-subject-equal
5310 gnus-tmp-dummy-line
5311 (mail-header-subject gnus-tmp-header)))
5312 (gnus-summary-insert-dummy-line
5313 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5314 (setq gnus-tmp-dummy-line nil))
5316 ;; Compute the mark.
5317 (setq gnus-tmp-unread (gnus-article-mark number))
5319 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5320 gnus-tmp-header gnus-tmp-level)
5321 gnus-newsgroup-data)
5323 ;; Actually insert the line.
5324 (setq
5325 gnus-tmp-subject-or-nil
5326 (cond
5327 ((and gnus-thread-ignore-subject
5328 gnus-tmp-prev-subject
5329 (not (string= gnus-tmp-prev-subject simp-subject)))
5330 subject)
5331 ((zerop gnus-tmp-level)
5332 (if (and (eq gnus-summary-make-false-root 'empty)
5333 (memq number gnus-tmp-gathered)
5334 gnus-tmp-prev-subject
5335 (string= gnus-tmp-prev-subject simp-subject))
5336 gnus-summary-same-subject
5337 subject))
5338 (t gnus-summary-same-subject)))
5339 (if (and (eq gnus-summary-make-false-root 'adopt)
5340 (= gnus-tmp-level 1)
5341 (memq number gnus-tmp-gathered))
5342 (setq gnus-tmp-opening-bracket ?\<
5343 gnus-tmp-closing-bracket ?\>)
5344 (setq gnus-tmp-opening-bracket ?\[
5345 gnus-tmp-closing-bracket ?\]))
5346 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5347 (gnus-make-thread-indent-array
5348 (max (* 2 (length gnus-thread-indent-array))
5349 gnus-tmp-level)))
5350 (setq
5351 gnus-tmp-indentation
5352 (aref gnus-thread-indent-array gnus-tmp-level)
5353 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5354 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5355 gnus-summary-default-score 0)
5356 gnus-tmp-score-char
5357 (if (or (null gnus-summary-default-score)
5358 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5359 gnus-summary-zcore-fuzz))
5360 ? ;Whitespace
5361 (if (< gnus-tmp-score gnus-summary-default-score)
5362 gnus-score-below-mark gnus-score-over-mark))
5363 gnus-tmp-replied
5364 (cond ((memq number gnus-newsgroup-processable)
5365 gnus-process-mark)
5366 ((memq number gnus-newsgroup-cached)
5367 gnus-cached-mark)
5368 ((memq number gnus-newsgroup-replied)
5369 gnus-replied-mark)
5370 ((memq number gnus-newsgroup-forwarded)
5371 gnus-forwarded-mark)
5372 ((memq number gnus-newsgroup-saved)
5373 gnus-saved-mark)
5374 ((memq number gnus-newsgroup-unseen)
5375 gnus-unseen-mark)
5376 (t gnus-no-mark))
5377 gnus-tmp-downloaded
5378 (cond ((memq number gnus-newsgroup-undownloaded)
5379 gnus-undownloaded-mark)
5380 (gnus-newsgroup-agentized
5381 gnus-downloaded-mark)
5383 gnus-no-mark))
5384 gnus-tmp-from (mail-header-from gnus-tmp-header)
5385 gnus-tmp-name
5386 (cond
5387 ((string-match "<[^>]+> *$" gnus-tmp-from)
5388 (setq beg-match (match-beginning 0))
5389 (or (and (string-match "^\".+\"" gnus-tmp-from)
5390 (substring gnus-tmp-from 1 (1- (match-end 0))))
5391 (substring gnus-tmp-from 0 beg-match)))
5392 ((string-match "(.+)" gnus-tmp-from)
5393 (substring gnus-tmp-from
5394 (1+ (match-beginning 0)) (1- (match-end 0))))
5395 (t gnus-tmp-from))
5397 ;; Do the %B string
5398 gnus-tmp-thread-tree-header-string
5399 (cond
5400 ((not gnus-show-threads) "")
5401 ((zerop gnus-tmp-level)
5402 (cond ((cdar thread)
5403 (or gnus-sum-thread-tree-root subject))
5404 (gnus-tmp-new-adopts
5405 (or gnus-sum-thread-tree-false-root subject))
5407 (or gnus-sum-thread-tree-single-indent subject))))
5409 (concat (apply 'concat
5410 (mapcar (lambda (item)
5411 (if (= item 1)
5412 gnus-sum-thread-tree-vertical
5413 gnus-sum-thread-tree-indent))
5414 (cdr (reverse tree-stack))))
5415 (if (nth 1 thread)
5416 gnus-sum-thread-tree-leaf-with-other
5417 gnus-sum-thread-tree-single-leaf)))))
5418 (when (string= gnus-tmp-name "")
5419 (setq gnus-tmp-name gnus-tmp-from))
5420 (unless (numberp gnus-tmp-lines)
5421 (setq gnus-tmp-lines -1))
5422 (if (= gnus-tmp-lines -1)
5423 (setq gnus-tmp-lines "?")
5424 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5425 (gnus-put-text-property
5426 (point)
5427 (progn (eval gnus-summary-line-format-spec) (point))
5428 'gnus-number number)
5429 (when gnus-visual-p
5430 (forward-line -1)
5431 (gnus-summary-highlight-line)
5432 (when gnus-summary-update-hook
5433 (gnus-run-hooks 'gnus-summary-update-hook))
5434 (forward-line 1))
5436 (setq gnus-tmp-prev-subject simp-subject)))
5438 (when (nth 1 thread)
5439 (push (list (max 0 gnus-tmp-level)
5440 (copy-sequence tree-stack)
5441 (nthcdr 1 thread))
5442 stack))
5443 (push (if (nth 1 thread) 1 0) tree-stack)
5444 (incf gnus-tmp-level)
5445 (setq threads (if thread-end nil (cdar thread)))
5446 (if gnus-summary-display-while-building
5447 (if building-count
5448 (progn
5449 ;; use a set frequency
5450 (setq building-line-count (1- building-line-count))
5451 (when (= building-line-count 0)
5452 (sit-for 0)
5453 (setq building-line-count
5454 gnus-summary-display-while-building)))
5455 ;; always
5456 (sit-for 0)))
5457 (unless threads
5458 (setq gnus-tmp-level 0)))))
5459 (gnus-message 7 "Generating summary...done"))
5461 (defun gnus-summary-prepare-unthreaded (headers)
5462 "Generate an unthreaded summary buffer based on HEADERS."
5463 (let (header number mark)
5465 (beginning-of-line)
5467 (while headers
5468 ;; We may have to root out some bad articles...
5469 (when (memq (setq number (mail-header-number
5470 (setq header (pop headers))))
5471 gnus-newsgroup-limit)
5472 ;; Mark article as read when it has a low score.
5473 (when (and gnus-summary-mark-below
5474 (< (or (cdr (assq number gnus-newsgroup-scored))
5475 gnus-summary-default-score 0)
5476 gnus-summary-mark-below)
5477 (not (gnus-summary-article-ancient-p number)))
5478 (setq gnus-newsgroup-unreads
5479 (delq number gnus-newsgroup-unreads))
5480 (if gnus-newsgroup-auto-expire
5481 (push number gnus-newsgroup-expirable)
5482 (push (cons number gnus-low-score-mark)
5483 gnus-newsgroup-reads)))
5485 (setq mark (gnus-article-mark number))
5486 (push (gnus-data-make number mark (1+ (point)) header 0)
5487 gnus-newsgroup-data)
5488 (gnus-summary-insert-line
5489 header 0 number
5490 (memq number gnus-newsgroup-undownloaded)
5491 mark (memq number gnus-newsgroup-replied)
5492 (memq number gnus-newsgroup-expirable)
5493 (mail-header-subject header) nil
5494 (cdr (assq number gnus-newsgroup-scored))
5495 (memq number gnus-newsgroup-processable))))))
5497 (defun gnus-group-get-list-identifiers (group)
5498 "Get list identifier regexp for GROUP."
5499 (or (gnus-parameter-list-identifier group)
5500 (if (consp gnus-list-identifiers)
5501 (mapconcat 'identity gnus-list-identifiers " *\\|")
5502 gnus-list-identifiers)))
5504 (defun gnus-summary-remove-list-identifiers ()
5505 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5506 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5507 changed subject)
5508 (when regexp
5509 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5510 (dolist (header gnus-newsgroup-headers)
5511 (setq subject (mail-header-subject header)
5512 changed nil)
5513 (while (string-match regexp subject)
5514 (setq subject
5515 (concat (substring subject 0 (match-beginning 1))
5516 (substring subject (match-end 0)))
5517 changed t))
5518 (when changed
5519 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5520 (setq subject
5521 (concat (substring subject 0 (match-beginning 1))
5522 (substring subject (match-end 1)))))
5523 (mail-header-set-subject header subject))))))
5525 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5526 "Fetch headers of ARTICLES."
5527 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5528 (gnus-message 7 "Fetching headers for %s..." name)
5529 (prog1
5530 (if (eq 'nov
5531 (setq gnus-headers-retrieved-by
5532 (gnus-retrieve-headers
5533 articles gnus-newsgroup-name
5534 (or limit
5535 ;; We might want to fetch old headers, but
5536 ;; not if there is only 1 article.
5537 (and (or (and
5538 (not (eq gnus-fetch-old-headers 'some))
5539 (not (numberp gnus-fetch-old-headers)))
5540 (> (length articles) 1))
5541 gnus-fetch-old-headers)))))
5542 (gnus-get-newsgroup-headers-xover
5543 articles force-new dependencies gnus-newsgroup-name t)
5544 (gnus-get-newsgroup-headers dependencies force-new))
5545 (gnus-message 7 "Fetching headers for %s...done" name))))
5547 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5548 "Select newsgroup GROUP.
5549 If READ-ALL is non-nil, all articles in the group are selected.
5550 If SELECT-ARTICLES, only select those articles from GROUP."
5551 (let* ((entry (gnus-group-entry group))
5552 ;;!!! Dirty hack; should be removed.
5553 (gnus-summary-ignore-duplicates
5554 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5556 gnus-summary-ignore-duplicates))
5557 (info (nth 2 entry))
5558 charset articles fetched-articles cached)
5560 (unless (gnus-check-server
5561 (set (make-local-variable 'gnus-current-select-method)
5562 (gnus-find-method-for-group group)))
5563 (error "Couldn't open server"))
5564 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5566 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5567 (gnus-activate-group group) ; Or we can activate it...
5568 (progn ; Or we bug out.
5569 (when (equal major-mode 'gnus-summary-mode)
5570 (gnus-kill-buffer (current-buffer)))
5571 (error
5572 "Couldn't activate group %s: %s"
5573 (mm-decode-coding-string group charset)
5574 (mm-decode-coding-string (gnus-status-message group) charset))))
5576 (unless (gnus-request-group group t)
5577 (when (equal major-mode 'gnus-summary-mode)
5578 (gnus-kill-buffer (current-buffer)))
5579 (error "Couldn't request group %s: %s"
5580 (mm-decode-coding-string group charset)
5581 (mm-decode-coding-string (gnus-status-message group) charset)))
5583 (when (and gnus-agent
5584 (gnus-active group))
5585 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5587 (setq gnus-summary-use-undownloaded-faces
5588 (gnus-agent-find-parameter
5589 group
5590 'agent-enable-undownloaded-faces)))
5592 (setq gnus-newsgroup-name group
5593 gnus-newsgroup-unselected nil
5594 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5596 (let ((display (gnus-group-find-parameter group 'display)))
5597 (setq gnus-newsgroup-display
5598 (cond
5599 ((not (zerop (or (car-safe read-all) 0)))
5600 ;; The user entered the group with C-u SPC/RET, let's show
5601 ;; all articles.
5602 'gnus-not-ignore)
5603 ((eq display 'all)
5604 'gnus-not-ignore)
5605 ((arrayp display)
5606 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5607 ((numberp display)
5608 ;; The following is probably the "correct" solution, but
5609 ;; it makes Gnus fetch all headers and then limit the
5610 ;; articles (which is slow), so instead we hack the
5611 ;; select-articles parameter instead. -- Simon Josefsson
5612 ;; <jas@kth.se>
5614 ;; (gnus-byte-compile
5615 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5616 ;; display)))))
5617 (setq select-articles
5618 (gnus-uncompress-range
5619 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5620 (if (> tmp 0)
5623 (cdr (gnus-active group)))))
5624 nil)
5626 nil))))
5628 (gnus-summary-setup-default-charset)
5630 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5631 (when (gnus-virtual-group-p group)
5632 (setq cached gnus-newsgroup-cached))
5634 (setq gnus-newsgroup-unreads
5635 (gnus-sorted-ndifference
5636 (gnus-sorted-ndifference gnus-newsgroup-unreads
5637 gnus-newsgroup-marked)
5638 gnus-newsgroup-dormant))
5640 (setq gnus-newsgroup-processable nil)
5642 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5644 ;; Adjust and set lists of article marks.
5645 (when info
5646 (gnus-adjust-marked-articles info))
5647 (if (setq articles select-articles)
5648 (setq gnus-newsgroup-unselected
5649 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5650 (setq articles (gnus-articles-to-read group read-all)))
5652 (cond
5653 ((null articles)
5654 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5655 'quit)
5656 ((eq articles 0) nil)
5658 ;; Init the dependencies hash table.
5659 (setq gnus-newsgroup-dependencies
5660 (gnus-make-hashtable (length articles)))
5661 (if (gnus-buffer-live-p gnus-group-buffer)
5662 (gnus-set-global-variables)
5663 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5664 ;; Retrieve the headers and read them in.
5666 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5668 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5669 (when cached
5670 (setq gnus-newsgroup-cached cached))
5672 ;; Suppress duplicates?
5673 (when gnus-suppress-duplicates
5674 (gnus-dup-suppress-articles))
5676 ;; Set the initial limit.
5677 (setq gnus-newsgroup-limit (copy-sequence articles))
5678 ;; Remove canceled articles from the list of unread articles.
5679 (setq fetched-articles
5680 (mapcar (lambda (headers) (mail-header-number headers))
5681 gnus-newsgroup-headers))
5682 (setq gnus-newsgroup-articles fetched-articles)
5683 (setq gnus-newsgroup-unreads
5684 (gnus-sorted-nintersection
5685 gnus-newsgroup-unreads fetched-articles))
5686 (gnus-compute-unseen-list)
5688 ;; Removed marked articles that do not exist.
5689 (gnus-update-missing-marks
5690 (gnus-sorted-difference articles fetched-articles))
5691 ;; We might want to build some more threads first.
5692 (when (and gnus-fetch-old-headers
5693 (eq gnus-headers-retrieved-by 'nov))
5694 (if (eq gnus-fetch-old-headers 'invisible)
5695 (gnus-build-all-threads)
5696 (gnus-build-old-threads)))
5697 ;; Let the Gnus agent mark articles as read.
5698 (when gnus-agent
5699 (gnus-agent-get-undownloaded-list))
5700 ;; Remove list identifiers from subject
5701 (gnus-summary-remove-list-identifiers)
5702 ;; Check whether auto-expire is to be done in this group.
5703 (setq gnus-newsgroup-auto-expire
5704 (and (gnus-group-auto-expirable-p group)
5705 (not (gnus-group-read-only-p group))))
5706 ;; Set up the article buffer now, if necessary.
5707 (unless (and gnus-single-article-buffer
5708 (equal gnus-article-buffer "*Article*"))
5709 (gnus-article-setup-buffer))
5710 ;; First and last article in this newsgroup.
5711 (when gnus-newsgroup-headers
5712 (setq gnus-newsgroup-begin
5713 (mail-header-number (car gnus-newsgroup-headers))
5714 gnus-newsgroup-end
5715 (mail-header-number
5716 (gnus-last-element gnus-newsgroup-headers))))
5717 ;; GROUP is successfully selected.
5718 (or gnus-newsgroup-headers t)))))
5720 (defun gnus-compute-unseen-list ()
5721 ;; The `seen' marks are treated specially.
5722 (if (not gnus-newsgroup-seen)
5723 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5724 (setq gnus-newsgroup-unseen
5725 (gnus-inverse-list-range-intersection
5726 gnus-newsgroup-articles gnus-newsgroup-seen))))
5728 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5730 (defun gnus-summary-display-make-predicate (display)
5731 (require 'gnus-agent)
5732 (when (= (length display) 1)
5733 (setq display (car display)))
5734 (unless gnus-summary-display-cache
5735 (dolist (elem (append '((unread . unread)
5736 (read . read)
5737 (unseen . unseen))
5738 gnus-article-mark-lists))
5739 (push (cons (cdr elem)
5740 (gnus-byte-compile ;Why bother?
5741 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5742 gnus-summary-display-cache)))
5743 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5744 (gnus-category-predicate-cache gnus-summary-display-cache))
5745 (gnus-get-predicate display)))
5747 ;; Uses the dynamically bound `gnus-number' variable.
5748 (defvar gnus-number)
5749 (defun gnus-article-marked-p (type &optional article)
5750 (let ((article (or article gnus-number)))
5751 (cond
5752 ((eq type 'tick)
5753 (memq article gnus-newsgroup-marked))
5754 ((eq type 'spam)
5755 (memq article gnus-newsgroup-spam-marked))
5756 ((eq type 'unsend)
5757 (memq article gnus-newsgroup-unsendable))
5758 ((eq type 'undownload)
5759 (memq article gnus-newsgroup-undownloaded))
5760 ((eq type 'download)
5761 (memq article gnus-newsgroup-downloadable))
5762 ((eq type 'unread)
5763 (memq article gnus-newsgroup-unreads))
5764 ((eq type 'read)
5765 (memq article gnus-newsgroup-reads))
5766 ((eq type 'dormant)
5767 (memq article gnus-newsgroup-dormant) )
5768 ((eq type 'expire)
5769 (memq article gnus-newsgroup-expirable))
5770 ((eq type 'reply)
5771 (memq article gnus-newsgroup-replied))
5772 ((eq type 'killed)
5773 (memq article gnus-newsgroup-killed))
5774 ((eq type 'bookmark)
5775 (assq article gnus-newsgroup-bookmarks))
5776 ((eq type 'score)
5777 (assq article gnus-newsgroup-scored))
5778 ((eq type 'save)
5779 (memq article gnus-newsgroup-saved))
5780 ((eq type 'cache)
5781 (memq article gnus-newsgroup-cached))
5782 ((eq type 'forward)
5783 (memq article gnus-newsgroup-forwarded))
5784 ((eq type 'seen)
5785 (not (memq article gnus-newsgroup-unseen)))
5786 (t t))))
5788 (defun gnus-articles-to-read (group &optional read-all)
5789 "Find out what articles the user wants to read."
5790 (let* ((only-read-p t)
5791 (articles
5792 ;; Select all articles if `read-all' is non-nil, or if there
5793 ;; are no unread articles.
5794 (if (or read-all
5795 (and (zerop (length gnus-newsgroup-marked))
5796 (zerop (length gnus-newsgroup-unreads)))
5797 ;; Fetch all if the predicate is non-nil.
5798 gnus-newsgroup-display)
5799 ;; We want to select the headers for all the articles in
5800 ;; the group, so we select either all the active
5801 ;; articles in the group, or (if that's nil), the
5802 ;; articles in the cache.
5804 (if gnus-newsgroup-maximum-articles
5805 (let ((active (gnus-active group)))
5806 (gnus-uncompress-range
5807 (cons (max (car active)
5808 (- (cdr active)
5809 gnus-newsgroup-maximum-articles
5810 -1))
5811 (cdr active))))
5812 (gnus-uncompress-range (gnus-active group)))
5813 (gnus-cache-articles-in-group group))
5814 ;; Select only the "normal" subset of articles.
5815 (setq only-read-p nil)
5816 (gnus-sorted-nunion
5817 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5818 gnus-newsgroup-unreads)))
5819 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5820 (scored (length scored-list))
5821 (number (length articles))
5822 (marked (+ (length gnus-newsgroup-marked)
5823 (length gnus-newsgroup-dormant)))
5824 (select
5825 (cond
5826 ((numberp read-all)
5827 read-all)
5828 ((numberp gnus-newsgroup-display)
5829 gnus-newsgroup-display)
5831 (condition-case ()
5832 (cond
5833 ((and (or (<= scored marked) (= scored number))
5834 (numberp gnus-large-newsgroup)
5835 (> number gnus-large-newsgroup))
5836 (let* ((cursor-in-echo-area nil)
5837 (initial (gnus-parameter-large-newsgroup-initial
5838 gnus-newsgroup-name))
5839 (default (if only-read-p
5840 (or initial gnus-large-newsgroup)
5841 number))
5842 (input
5843 (read-string
5844 (if only-read-p
5845 (format
5846 "How many articles from %s (available %d, default %d): "
5847 (gnus-group-decoded-name
5848 (gnus-group-real-name gnus-newsgroup-name))
5849 number default)
5850 (format
5851 "How many articles from %s (%d default): "
5852 (gnus-group-decoded-name
5853 (gnus-group-real-name gnus-newsgroup-name))
5854 default))
5857 (number-to-string default))))
5858 (if (string-match "^[ \t]*$" input) number input)))
5859 ((and (> scored marked) (< scored number)
5860 (> (- scored number) 20))
5861 (let ((input
5862 (read-string
5863 (format "%s %s (%d scored, %d total): "
5864 "How many articles from"
5865 (gnus-group-decoded-name
5866 (gnus-group-real-name gnus-newsgroup-name))
5867 scored number))))
5868 (if (string-match "^[ \t]*$" input)
5869 number input)))
5870 (t number))
5871 (quit
5872 (message "Quit getting the articles to read")
5873 nil))))))
5874 (setq select (if (stringp select) (string-to-number select) select))
5875 (if (or (null select) (zerop select))
5876 select
5877 (if (and (not (zerop scored)) (<= (abs select) scored))
5878 (progn
5879 (setq articles (sort scored-list '<))
5880 (setq number (length articles)))
5881 (setq articles (copy-sequence articles)))
5883 (when (< (abs select) number)
5884 (if (< select 0)
5885 ;; Select the N oldest articles.
5886 (setcdr (nthcdr (1- (abs select)) articles) nil)
5887 ;; Select the N most recent articles.
5888 (setq articles (nthcdr (- number select) articles))))
5889 (setq gnus-newsgroup-unselected
5890 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5891 (when gnus-alter-articles-to-read-function
5892 (setq articles
5893 (sort
5894 (funcall gnus-alter-articles-to-read-function
5895 gnus-newsgroup-name articles)
5896 '<)))
5897 articles)))
5899 (defun gnus-killed-articles (killed articles)
5900 (let (out)
5901 (while articles
5902 (when (inline (gnus-member-of-range (car articles) killed))
5903 (push (car articles) out))
5904 (setq articles (cdr articles)))
5905 out))
5907 (defun gnus-article-mark-to-type (mark)
5908 "Return the type of MARK."
5909 (or (cadr (assq mark gnus-article-special-mark-lists))
5910 'list))
5912 (defun gnus-article-unpropagatable-p (mark)
5913 "Return whether MARK should be propagated to back end."
5914 (memq mark gnus-article-unpropagated-mark-lists))
5916 (defun gnus-adjust-marked-articles (info)
5917 "Set all article lists and remove all marks that are no longer valid."
5918 (let* ((marked-lists (gnus-info-marks info))
5919 (active (gnus-active (gnus-info-group info)))
5920 (min (car active))
5921 (max (cdr active))
5922 (types gnus-article-mark-lists)
5923 marks var articles article mark mark-type
5924 bgn end)
5925 ;; Hack to avoid adjusting marks for imap.
5926 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5927 'nnimap)
5928 (setq min 1))
5930 (dolist (marks marked-lists)
5931 (setq mark (car marks)
5932 mark-type (gnus-article-mark-to-type mark)
5933 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5934 ;; We set the variable according to the type of the marks list,
5935 ;; and then adjust the marks to a subset of the active articles.
5936 (cond
5937 ;; Adjust "simple" lists - compressed yet unsorted
5938 ((eq mark-type 'list)
5939 ;; Simultaneously uncompress and clip to active range
5940 ;; See gnus-uncompress-range for a description of possible marks
5941 (let (l lh)
5942 (if (not (cadr marks))
5943 (set var nil)
5944 (setq articles (if (numberp (cddr marks))
5945 (list (cdr marks))
5946 (cdr marks))
5947 lh (cons nil nil)
5948 l lh)
5950 (while (setq article (pop articles))
5951 (cond ((consp article)
5952 (setq bgn (max (car article) min)
5953 end (min (cdr article) max))
5954 (while (<= bgn end)
5955 (setq l (setcdr l (cons bgn nil))
5956 bgn (1+ bgn))))
5957 ((and (<= min article)
5958 (>= max article))
5959 (setq l (setcdr l (cons article nil))))))
5960 (set var (cdr lh)))))
5961 ;; Adjust assocs.
5962 ((eq mark-type 'tuple)
5963 (set var (setq articles (cdr marks)))
5964 (when (not (listp (cdr (symbol-value var))))
5965 (set var (list (symbol-value var))))
5966 (when (not (listp (cdr articles)))
5967 (setq articles (list articles)))
5968 (while articles
5969 (when (or (not (consp (setq article (pop articles))))
5970 (< (car article) min)
5971 (> (car article) max))
5972 (set var (delq article (symbol-value var))))))
5973 ;; Adjust ranges (sloppily).
5974 ((eq mark-type 'range)
5975 (cond
5976 ((eq mark 'seen)
5977 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5978 ;; It should be (seen (NUM1 . NUM2)).
5979 (when (numberp (cddr marks))
5980 (setcdr marks (list (cdr marks))))
5981 (setq articles (cdr marks))
5982 (while (and articles
5983 (or (and (consp (car articles))
5984 (> min (cdar articles)))
5985 (and (numberp (car articles))
5986 (> min (car articles)))))
5987 (pop articles))
5988 (set var articles))))))))
5990 (defun gnus-update-missing-marks (missing)
5991 "Go through the list of MISSING articles and remove them from the mark lists."
5992 (when missing
5993 (let (var m)
5994 ;; Go through all types.
5995 (dolist (elem gnus-article-mark-lists)
5996 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5997 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5998 (when (symbol-value var)
5999 ;; This list has articles. So we delete all missing
6000 ;; articles from it.
6001 (setq m missing)
6002 (while m
6003 (set var (delq (pop m) (symbol-value var))))))))))
6005 (defun gnus-update-marks ()
6006 "Enter the various lists of marked articles into the newsgroup info list."
6007 (let ((types gnus-article-mark-lists)
6008 (info (gnus-get-info gnus-newsgroup-name))
6009 type list newmarked symbol delta-marks)
6010 (when info
6011 ;; Add all marks lists to the list of marks lists.
6012 (while (setq type (pop types))
6013 (setq list (symbol-value
6014 (setq symbol
6015 (intern (format "gnus-newsgroup-%s" (car type))))))
6017 (when list
6018 ;; Get rid of the entries of the articles that have the
6019 ;; default score.
6020 (when (and (eq (cdr type) 'score)
6021 gnus-save-score
6022 list)
6023 (let* ((arts list)
6024 (prev (cons nil list))
6025 (all prev))
6026 (while arts
6027 (if (or (not (consp (car arts)))
6028 (= (cdar arts) gnus-summary-default-score))
6029 (setcdr prev (cdr arts))
6030 (setq prev arts))
6031 (setq arts (cdr arts)))
6032 (setq list (cdr all)))))
6034 (when (eq (cdr type) 'seen)
6035 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6037 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6038 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6040 (when (and (gnus-check-backend-function
6041 'request-set-mark gnus-newsgroup-name)
6042 (not (gnus-article-unpropagatable-p (cdr type))))
6043 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6044 ;; Don't do anything about marks for articles we
6045 ;; didn't actually get any headers for.
6046 (del
6047 (gnus-list-range-intersection
6048 gnus-newsgroup-articles
6049 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6050 (add
6051 (gnus-list-range-intersection
6052 gnus-newsgroup-articles
6053 (gnus-remove-from-range
6054 (gnus-copy-sequence list) old))))
6055 (when add
6056 (push (list add 'add (list (cdr type))) delta-marks))
6057 (when del
6058 ;; Don't delete marks from outside the active range.
6059 ;; This shouldn't happen, but is a sanity check.
6060 (setq del (gnus-sorted-range-intersection
6061 (gnus-active gnus-newsgroup-name) del))
6062 (push (list del 'del (list (cdr type))) delta-marks))))
6064 (when list
6065 (push (cons (cdr type) list) newmarked)))
6067 (when delta-marks
6068 (unless (gnus-check-group gnus-newsgroup-name)
6069 (error "Can't open server for %s" gnus-newsgroup-name))
6070 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6072 ;; Enter these new marks into the info of the group.
6073 (if (nthcdr 3 info)
6074 (setcar (nthcdr 3 info) newmarked)
6075 ;; Add the marks lists to the end of the info.
6076 (when newmarked
6077 (setcdr (nthcdr 2 info) (list newmarked))))
6079 ;; Cut off the end of the info if there's nothing else there.
6080 (let ((i 5))
6081 (while (and (> i 2)
6082 (not (nth i info)))
6083 (when (nthcdr (decf i) info)
6084 (setcdr (nthcdr i info) nil)))))))
6086 (defun gnus-set-mode-line (where)
6087 "Set the mode line of the article or summary buffers.
6088 If WHERE is `summary', the summary mode line format will be used."
6089 ;; Is this mode line one we keep updated?
6090 (when (and (memq where gnus-updated-mode-lines)
6091 (symbol-value
6092 (intern (format "gnus-%s-mode-line-format-spec" where))))
6093 (let (mode-string)
6094 ;; We evaluate this in the summary buffer since these
6095 ;; variables are buffer-local to that buffer.
6096 (with-current-buffer gnus-summary-buffer
6097 ;; We bind all these variables that are used in the `eval' form
6098 ;; below.
6099 (let* ((mformat (symbol-value
6100 (intern
6101 (format "gnus-%s-mode-line-format-spec" where))))
6102 (gnus-tmp-group-name (gnus-mode-string-quote
6103 (gnus-group-decoded-name
6104 gnus-newsgroup-name)))
6105 (gnus-tmp-article-number (or gnus-current-article 0))
6106 (gnus-tmp-unread gnus-newsgroup-unreads)
6107 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6108 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6109 (gnus-tmp-unread-and-unselected
6110 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6111 (zerop gnus-tmp-unselected))
6113 ((zerop gnus-tmp-unselected)
6114 (format "{%d more}" gnus-tmp-unread-and-unticked))
6115 (t (format "{%d(+%d) more}"
6116 gnus-tmp-unread-and-unticked
6117 gnus-tmp-unselected))))
6118 (gnus-tmp-subject
6119 (if (and gnus-current-headers
6120 (vectorp gnus-current-headers))
6121 (gnus-mode-string-quote
6122 (mail-header-subject gnus-current-headers))
6123 ""))
6124 bufname-length max-len
6125 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6126 (setq mode-string (eval mformat))
6127 (setq bufname-length (if (string-match "%b" mode-string)
6128 (- (length
6129 (buffer-name
6130 (if (eq where 'summary)
6132 (get-buffer gnus-article-buffer))))
6135 (setq max-len (max 4 (if gnus-mode-non-string-length
6136 (- (window-width)
6137 gnus-mode-non-string-length
6138 bufname-length)
6139 (length mode-string))))
6140 ;; We might have to chop a bit of the string off...
6141 (when (> (length mode-string) max-len)
6142 (setq mode-string
6143 (concat (truncate-string-to-width mode-string (- max-len 3))
6144 "...")))))
6145 ;; Update the mode line.
6146 (setq mode-line-buffer-identification
6147 (gnus-mode-line-buffer-identification (list mode-string)))
6148 (set-buffer-modified-p t))))
6150 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6151 "Go through the HEADERS list and add all Xrefs to a hash table.
6152 The resulting hash table is returned, or nil if no Xrefs were found."
6153 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6154 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6155 (xref-hashtb (gnus-make-hashtable))
6156 start group entry number xrefs header)
6157 (while headers
6158 (setq header (pop headers))
6159 (when (and (setq xrefs (mail-header-xref header))
6160 (not (memq (setq number (mail-header-number header))
6161 unreads)))
6162 (setq start 0)
6163 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6164 (setq start (match-end 0))
6165 (setq group (if prefix
6166 (concat prefix (substring xrefs (match-beginning 1)
6167 (match-end 1)))
6168 (substring xrefs (match-beginning 1) (match-end 1))))
6169 (setq number
6170 (string-to-number (substring xrefs (match-beginning 2)
6171 (match-end 2))))
6172 (if (setq entry (gnus-gethash group xref-hashtb))
6173 (setcdr entry (cons number (cdr entry)))
6174 (gnus-sethash group (cons number nil) xref-hashtb)))))
6175 (and start xref-hashtb)))
6177 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6178 "Look through all the headers and mark the Xrefs as read."
6179 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6180 name info xref-hashtb idlist method nth4)
6181 (with-current-buffer gnus-group-buffer
6182 (when (setq xref-hashtb
6183 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6184 (mapatoms
6185 (lambda (group)
6186 (unless (string= from-newsgroup (setq name (symbol-name group)))
6187 (setq idlist (symbol-value group))
6188 ;; Dead groups are not updated.
6189 (and (prog1
6190 (setq info (gnus-get-info name))
6191 (when (stringp (setq nth4 (gnus-info-method info)))
6192 (setq nth4 (gnus-server-to-method nth4))))
6193 ;; Only do the xrefs if the group has the same
6194 ;; select method as the group we have just read.
6195 (or (gnus-methods-equal-p
6196 nth4 (gnus-find-method-for-group from-newsgroup))
6197 virtual
6198 (equal nth4 (setq method (gnus-find-method-for-group
6199 from-newsgroup)))
6200 (and (equal (car nth4) (car method))
6201 (equal (nth 1 nth4) (nth 1 method))))
6202 gnus-use-cross-reference
6203 (or (not (eq gnus-use-cross-reference t))
6204 virtual
6205 ;; Only do cross-references on subscribed
6206 ;; groups, if that is what is wanted.
6207 (<= (gnus-info-level info) gnus-level-subscribed))
6208 (gnus-group-make-articles-read name idlist))))
6209 xref-hashtb)))))
6211 (defun gnus-compute-read-articles (group articles)
6212 (let* ((entry (gnus-group-entry group))
6213 (info (nth 2 entry))
6214 (active (gnus-active group))
6215 ninfo)
6216 (when entry
6217 ;; First peel off all invalid article numbers.
6218 (when active
6219 (let ((ids articles)
6220 id first)
6221 (while (setq id (pop ids))
6222 (when (and first (> id (cdr active)))
6223 ;; We'll end up in this situation in one particular
6224 ;; obscure situation. If you re-scan a group and get
6225 ;; a new article that is cross-posted to a different
6226 ;; group that has not been re-scanned, you might get
6227 ;; crossposted article that has a higher number than
6228 ;; Gnus believes possible. So we re-activate this
6229 ;; group as well. This might mean doing the
6230 ;; crossposting thingy will *increase* the number
6231 ;; of articles in some groups. Tsk, tsk.
6232 (setq active (or (gnus-activate-group group) active)))
6233 (when (or (> id (cdr active))
6234 (< id (car active)))
6235 (setq articles (delq id articles))))))
6236 ;; If the read list is nil, we init it.
6237 (if (and active
6238 (null (gnus-info-read info))
6239 (> (car active) 1))
6240 (setq ninfo (cons 1 (1- (car active))))
6241 (setq ninfo (gnus-info-read info)))
6242 ;; Then we add the read articles to the range.
6243 (gnus-add-to-range
6244 ninfo (setq articles (sort articles '<))))))
6246 (defun gnus-group-make-articles-read (group articles)
6247 "Update the info of GROUP to say that ARTICLES are read."
6248 (let* ((num 0)
6249 (entry (gnus-group-entry group))
6250 (info (nth 2 entry))
6251 (active (gnus-active group))
6252 (set-marks
6253 (gnus-method-option-p
6254 (gnus-find-method-for-group group)
6255 'server-marks))
6256 range)
6257 (if (not entry)
6258 ;; Group that Gnus doesn't know exists, but still allow the
6259 ;; backend to set marks.
6260 (when set-marks
6261 (gnus-request-set-mark
6262 group (list (list (gnus-compress-sequence (sort articles #'<))
6263 'add '(read)))))
6264 ;; Normal, subscribed groups.
6265 (setq range (gnus-compute-read-articles group articles))
6266 (with-current-buffer gnus-group-buffer
6267 (gnus-undo-register
6268 `(progn
6269 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6270 (gnus-info-set-read ',info ',(gnus-info-read info))
6271 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6272 (when ,set-marks
6273 (gnus-request-set-mark
6274 ,group (list (list ',range 'del '(read)))))
6275 (gnus-group-update-group ,group t))))
6276 ;; Add the read articles to the range.
6277 (gnus-info-set-read info range)
6278 (when set-marks
6279 (gnus-request-set-mark group (list (list range 'add '(read)))))
6280 ;; Then we have to re-compute how many unread
6281 ;; articles there are in this group.
6282 (when active
6283 (cond
6284 ((not range)
6285 (setq num (- (1+ (cdr active)) (car active))))
6286 ((not (listp (cdr range)))
6287 (setq num (- (cdr active) (- (1+ (cdr range))
6288 (car range)))))
6290 (while range
6291 (if (numberp (car range))
6292 (setq num (1+ num))
6293 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6294 (setq range (cdr range)))
6295 (setq num (- (cdr active) num))))
6296 ;; Update the number of unread articles.
6297 (setcar entry num)
6298 ;; Update the group buffer.
6299 (unless (gnus-ephemeral-group-p group)
6300 (gnus-group-update-group group t))))))
6302 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6303 (let ((cur nntp-server-buffer)
6304 (dependencies
6305 (or dependencies
6306 (with-current-buffer gnus-summary-buffer
6307 gnus-newsgroup-dependencies)))
6308 headers id end ref number
6309 (mail-parse-charset gnus-newsgroup-charset)
6310 (mail-parse-ignored-charsets
6311 (save-current-buffer (condition-case nil
6312 (set-buffer gnus-summary-buffer)
6313 (error))
6314 gnus-newsgroup-ignored-charsets)))
6315 (with-current-buffer nntp-server-buffer
6316 ;; Translate all TAB characters into SPACE characters.
6317 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6318 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6319 (ietf-drums-unfold-fws)
6320 (gnus-run-hooks 'gnus-parse-headers-hook)
6321 (let ((case-fold-search t)
6322 in-reply-to header p lines chars)
6323 (goto-char (point-min))
6324 ;; Search to the beginning of the next header. Error messages
6325 ;; do not begin with 2 or 3.
6326 (while (re-search-forward "^[23][0-9]+ " nil t)
6327 (setq id nil
6328 ref nil)
6329 ;; This implementation of this function, with nine
6330 ;; search-forwards instead of the one re-search-forward and
6331 ;; a case (which basically was the old function) is actually
6332 ;; about twice as fast, even though it looks messier. You
6333 ;; can't have everything, I guess. Speed and elegance
6334 ;; doesn't always go hand in hand.
6335 (setq
6336 header
6337 (vector
6338 ;; Number.
6339 (prog1
6340 (setq number (read cur))
6341 (end-of-line)
6342 (setq p (point))
6343 (narrow-to-region (point)
6344 (or (and (search-forward "\n.\n" nil t)
6345 (- (point) 2))
6346 (point))))
6347 ;; Subject.
6348 (progn
6349 (goto-char p)
6350 (if (search-forward "\nsubject:" nil t)
6351 (funcall gnus-decode-encoded-word-function
6352 (nnheader-header-value))
6353 "(none)"))
6354 ;; From.
6355 (progn
6356 (goto-char p)
6357 (if (search-forward "\nfrom:" nil t)
6358 (funcall gnus-decode-encoded-address-function
6359 (nnheader-header-value))
6360 "(nobody)"))
6361 ;; Date.
6362 (progn
6363 (goto-char p)
6364 (if (search-forward "\ndate:" nil t)
6365 (nnheader-header-value) ""))
6366 ;; Message-ID.
6367 (progn
6368 (goto-char p)
6369 (setq id (if (re-search-forward
6370 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6371 ;; We do it this way to make sure the Message-ID
6372 ;; is (somewhat) syntactically valid.
6373 (buffer-substring (match-beginning 1)
6374 (match-end 1))
6375 ;; If there was no message-id, we just fake one
6376 ;; to make subsequent routines simpler.
6377 (nnheader-generate-fake-message-id number))))
6378 ;; References.
6379 (progn
6380 (goto-char p)
6381 (if (search-forward "\nreferences:" nil t)
6382 (progn
6383 (setq end (point))
6384 (prog1
6385 (nnheader-header-value)
6386 (setq ref
6387 (buffer-substring
6388 (progn
6389 (end-of-line)
6390 (search-backward ">" end t)
6391 (1+ (point)))
6392 (progn
6393 (search-backward "<" end t)
6394 (point))))))
6395 ;; Get the references from the in-reply-to header if there
6396 ;; were no references and the in-reply-to header looks
6397 ;; promising.
6398 (if (and (search-forward "\nin-reply-to:" nil t)
6399 (setq in-reply-to (nnheader-header-value))
6400 (string-match "<[^>]+>" in-reply-to))
6401 (let (ref2)
6402 (setq ref (substring in-reply-to (match-beginning 0)
6403 (match-end 0)))
6404 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6405 (setq ref2 (substring in-reply-to (match-beginning 0)
6406 (match-end 0)))
6407 (when (> (length ref2) (length ref))
6408 (setq ref ref2)))
6409 ref)
6410 (setq ref nil))))
6411 ;; Chars.
6412 (progn
6413 (goto-char p)
6414 (if (search-forward "\nchars: " nil t)
6415 (if (numberp (setq chars (ignore-errors (read cur))))
6416 chars -1)
6417 -1))
6418 ;; Lines.
6419 (progn
6420 (goto-char p)
6421 (if (search-forward "\nlines: " nil t)
6422 (if (numberp (setq lines (ignore-errors (read cur))))
6423 lines -1)
6424 -1))
6425 ;; Xref.
6426 (progn
6427 (goto-char p)
6428 (and (search-forward "\nxref:" nil t)
6429 (nnheader-header-value)))
6430 ;; Extra.
6431 (when gnus-extra-headers
6432 (let ((extra gnus-extra-headers)
6433 out)
6434 (while extra
6435 (goto-char p)
6436 (when (search-forward
6437 (concat "\n" (symbol-name (car extra)) ":") nil t)
6438 (push (cons (car extra) (nnheader-header-value))
6439 out))
6440 (pop extra))
6441 out))))
6442 (when (equal id ref)
6443 (setq ref nil))
6445 (when gnus-alter-header-function
6446 (funcall gnus-alter-header-function header)
6447 (setq id (mail-header-id header)
6448 ref (gnus-parent-id (mail-header-references header))))
6450 (when (setq header
6451 (gnus-dependencies-add-header
6452 header dependencies force-new))
6453 (push header headers))
6454 (goto-char (point-max))
6455 (widen))
6456 (nreverse headers)))))
6458 ;; Goes through the xover lines and returns a list of vectors
6459 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6460 force-new dependencies
6461 group also-fetch-heads)
6462 "Parse the news overview data in the server buffer.
6463 Return a list of headers that match SEQUENCE (see
6464 `nntp-retrieve-headers')."
6465 ;; Get the Xref when the users reads the articles since most/some
6466 ;; NNTP servers do not include Xrefs when using XOVER.
6467 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6468 (let ((mail-parse-charset gnus-newsgroup-charset)
6469 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6470 (cur nntp-server-buffer)
6471 (dependencies (or dependencies gnus-newsgroup-dependencies))
6472 (allp (cond
6473 ((eq gnus-read-all-available-headers t)
6475 ((and (stringp gnus-read-all-available-headers)
6476 group)
6477 (string-match gnus-read-all-available-headers group))
6479 nil)))
6480 number headers header)
6481 (with-current-buffer nntp-server-buffer
6482 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6483 ;; Allow the user to mangle the headers before parsing them.
6484 (gnus-run-hooks 'gnus-parse-headers-hook)
6485 (goto-char (point-min))
6486 (gnus-parse-without-error
6487 (while (and (or sequence allp)
6488 (not (eobp)))
6489 (setq number (read cur))
6490 (when (not allp)
6491 (while (and sequence
6492 (< (car sequence) number))
6493 (setq sequence (cdr sequence))))
6494 (when (and (or allp
6495 (and sequence
6496 (eq number (car sequence))))
6497 (progn
6498 (setq sequence (cdr sequence))
6499 (setq header (inline
6500 (gnus-nov-parse-line
6501 number dependencies force-new)))))
6502 (push header headers))
6503 (forward-line 1)))
6504 ;; A common bug in inn is that if you have posted an article and
6505 ;; then retrieves the active file, it will answer correctly --
6506 ;; the new article is included. However, a NOV entry for the
6507 ;; article may not have been generated yet, so this may fail.
6508 ;; We work around this problem by retrieving the last few
6509 ;; headers using HEAD.
6510 (if (or (not also-fetch-heads)
6511 (not sequence))
6512 ;; We (probably) got all the headers.
6513 (nreverse headers)
6514 (let ((gnus-nov-is-evil t))
6515 (nconc
6516 (nreverse headers)
6517 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6518 (gnus-get-newsgroup-headers))))))))
6520 (defun gnus-article-get-xrefs ()
6521 "Fill in the Xref value in `gnus-current-headers', if necessary.
6522 This is meant to be called in `gnus-article-internal-prepare-hook'."
6523 (let ((headers (with-current-buffer gnus-summary-buffer
6524 gnus-current-headers)))
6525 (or (not gnus-use-cross-reference)
6526 (not headers)
6527 (and (mail-header-xref headers)
6528 (not (string= (mail-header-xref headers) "")))
6529 (let ((case-fold-search t)
6530 xref)
6531 (save-restriction
6532 (nnheader-narrow-to-headers)
6533 (goto-char (point-min))
6534 (when (or (and (not (eobp))
6535 (eq (downcase (char-after)) ?x)
6536 (looking-at "Xref:"))
6537 (search-forward "\nXref:" nil t))
6538 (goto-char (1+ (match-end 0)))
6539 (setq xref (buffer-substring (point) (point-at-eol)))
6540 (mail-header-set-xref headers xref)))))))
6542 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6543 "Find article ID and insert the summary line for that article.
6544 OLD-HEADER can either be a header or a line number to insert
6545 the subject line on.
6546 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6547 and OLD-HEADER will be used when the summary line is inserted,
6548 too, instead of trying to fetch new headers."
6549 (let* ((line (and (numberp old-header) old-header))
6550 (old-header (and (vectorp old-header) old-header))
6551 (header (cond ((and old-header use-old-header)
6552 old-header)
6553 ((and (numberp id)
6554 (gnus-number-to-header id))
6555 (gnus-number-to-header id))
6557 (gnus-read-header id))))
6558 (number (and (numberp id) id))
6560 (when header
6561 ;; Rebuild the thread that this article is part of and go to the
6562 ;; article we have fetched.
6563 (when (and (not gnus-show-threads)
6564 old-header)
6565 (when (and number
6566 (setq d (gnus-data-find (mail-header-number old-header))))
6567 (goto-char (gnus-data-pos d))
6568 (gnus-data-remove
6569 number
6570 (- (point-at-bol)
6571 (prog1
6572 (1+ (point-at-eol))
6573 (gnus-delete-line))))))
6574 ;; Remove list identifiers from subject.
6575 (let ((gnus-newsgroup-headers (list header)))
6576 (gnus-summary-remove-list-identifiers))
6577 (when old-header
6578 (mail-header-set-number header (mail-header-number old-header)))
6579 (setq gnus-newsgroup-sparse
6580 (delq (setq number (mail-header-number header))
6581 gnus-newsgroup-sparse))
6582 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6583 (push number gnus-newsgroup-limit)
6584 (gnus-rebuild-thread (mail-header-id header) line)
6585 (gnus-summary-goto-subject number nil t))
6586 (when (and (numberp number)
6587 (> number 0))
6588 ;; We have to update the boundaries even if we can't fetch the
6589 ;; article if ID is a number -- so that the next `P' or `N'
6590 ;; command will fetch the previous (or next) article even
6591 ;; if the one we tried to fetch this time has been canceled.
6592 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6593 (setq gnus-newsgroup-end number))
6594 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6595 (setq gnus-newsgroup-begin number))
6596 (setq gnus-newsgroup-unselected
6597 (delq number gnus-newsgroup-unselected)))
6598 ;; Report back a success?
6599 (and header (mail-header-number header))))
6601 ;;; Process/prefix in the summary buffer
6603 (defun gnus-summary-work-articles (n)
6604 "Return a list of articles to be worked upon.
6605 The prefix argument, the list of process marked articles, and the
6606 current article will be taken into consideration."
6607 (with-current-buffer gnus-summary-buffer
6608 (cond
6610 ;; A numerical prefix has been given.
6611 (setq n (prefix-numeric-value n))
6612 (let ((backward (< n 0))
6613 (n (abs (prefix-numeric-value n)))
6614 articles article)
6615 (save-excursion
6616 (while
6617 (and (> n 0)
6618 (push (setq article (gnus-summary-article-number))
6619 articles)
6620 (if backward
6621 (gnus-summary-find-prev nil article)
6622 (gnus-summary-find-next nil article)))
6623 (decf n)))
6624 (nreverse articles)))
6625 ((and (gnus-region-active-p) (mark))
6626 (message "region active")
6627 ;; Work on the region between point and mark.
6628 (let ((max (max (point) (mark)))
6629 articles article)
6630 (save-excursion
6631 (goto-char (min (point) (mark)))
6632 (while
6633 (and
6634 (push (setq article (gnus-summary-article-number)) articles)
6635 (gnus-summary-find-next nil article)
6636 (< (point) max)))
6637 (nreverse articles))))
6638 (gnus-newsgroup-processable
6639 ;; There are process-marked articles present.
6640 ;; Save current state.
6641 (gnus-summary-save-process-mark)
6642 ;; Return the list.
6643 (reverse gnus-newsgroup-processable))
6645 ;; Just return the current article.
6646 (list (gnus-summary-article-number))))))
6648 (defmacro gnus-summary-iterate (arg &rest forms)
6649 "Iterate over the process/prefixed articles and do FORMS.
6650 ARG is the interactive prefix given to the command. FORMS will be
6651 executed with point over the summary line of the articles."
6652 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6653 `(let ((,articles (gnus-summary-work-articles ,arg)))
6654 (while ,articles
6655 (gnus-summary-goto-subject (car ,articles))
6656 ,@forms
6657 (pop ,articles)))))
6659 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6660 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6662 (defun gnus-summary-save-process-mark ()
6663 "Push the current set of process marked articles on the stack."
6664 (interactive)
6665 (push (copy-sequence gnus-newsgroup-processable)
6666 gnus-newsgroup-process-stack))
6668 (defun gnus-summary-kill-process-mark ()
6669 "Push the current set of process marked articles on the stack and unmark."
6670 (interactive)
6671 (gnus-summary-save-process-mark)
6672 (gnus-summary-unmark-all-processable))
6674 (defun gnus-summary-yank-process-mark ()
6675 "Pop the last process mark state off the stack and restore it."
6676 (interactive)
6677 (unless gnus-newsgroup-process-stack
6678 (error "Empty mark stack"))
6679 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6681 (defun gnus-summary-process-mark-set (set)
6682 "Make SET into the current process marked articles."
6683 (gnus-summary-unmark-all-processable)
6684 (mapc 'gnus-summary-set-process-mark set))
6686 ;;; Searching and stuff
6688 (defun gnus-summary-search-group (&optional backward use-level)
6689 "Search for next unread newsgroup.
6690 If optional argument BACKWARD is non-nil, search backward instead."
6691 (with-current-buffer gnus-group-buffer
6692 (when (gnus-group-search-forward
6693 backward nil (if use-level (gnus-group-group-level) nil))
6694 (gnus-group-group-name))))
6696 (defun gnus-summary-best-group (&optional exclude-group)
6697 "Find the name of the best unread group.
6698 If EXCLUDE-GROUP, do not go to this group."
6699 (with-current-buffer gnus-group-buffer
6700 (save-excursion
6701 (gnus-group-best-unread-group exclude-group))))
6703 (defun gnus-summary-find-next (&optional unread article backward)
6704 (if backward
6705 (gnus-summary-find-prev unread article)
6706 (let* ((dummy (gnus-summary-article-intangible-p))
6707 (article (or article (gnus-summary-article-number)))
6708 (data (gnus-data-find-list article))
6709 result)
6710 (when (and (not dummy)
6711 (or (not gnus-summary-check-current)
6712 (not unread)
6713 (not (gnus-data-unread-p (car data)))))
6714 (setq data (cdr data)))
6715 (when (setq result
6716 (if unread
6717 (progn
6718 (while data
6719 (unless (memq (gnus-data-number (car data))
6720 (cond
6721 ((eq gnus-auto-goto-ignores
6722 'always-undownloaded)
6723 gnus-newsgroup-undownloaded)
6724 (gnus-plugged
6725 nil)
6726 ((eq gnus-auto-goto-ignores
6727 'unfetched)
6728 gnus-newsgroup-unfetched)
6729 ((eq gnus-auto-goto-ignores
6730 'undownloaded)
6731 gnus-newsgroup-undownloaded)))
6732 (when (gnus-data-unread-p (car data))
6733 (setq result (car data)
6734 data nil)))
6735 (setq data (cdr data)))
6736 result)
6737 (car data)))
6738 (goto-char (gnus-data-pos result))
6739 (gnus-data-number result)))))
6741 (defun gnus-summary-find-prev (&optional unread article)
6742 (let* ((eobp (eobp))
6743 (article (or article (gnus-summary-article-number)))
6744 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6745 result)
6746 (when (and (not eobp)
6747 (or (not gnus-summary-check-current)
6748 (not unread)
6749 (not (gnus-data-unread-p (car data)))))
6750 (setq data (cdr data)))
6751 (when (setq result
6752 (if unread
6753 (progn
6754 (while data
6755 (unless (memq (gnus-data-number (car data))
6756 (cond
6757 ((eq gnus-auto-goto-ignores
6758 'always-undownloaded)
6759 gnus-newsgroup-undownloaded)
6760 (gnus-plugged
6761 nil)
6762 ((eq gnus-auto-goto-ignores
6763 'unfetched)
6764 gnus-newsgroup-unfetched)
6765 ((eq gnus-auto-goto-ignores
6766 'undownloaded)
6767 gnus-newsgroup-undownloaded)))
6768 (when (gnus-data-unread-p (car data))
6769 (setq result (car data)
6770 data nil)))
6771 (setq data (cdr data)))
6772 result)
6773 (car data)))
6774 (goto-char (gnus-data-pos result))
6775 (gnus-data-number result))))
6777 (defun gnus-summary-find-subject (subject &optional unread backward article)
6778 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6779 (article (or article (gnus-summary-article-number)))
6780 (articles (gnus-data-list backward))
6781 (arts (gnus-data-find-list article articles))
6782 result)
6783 (when (or (not gnus-summary-check-current)
6784 (not unread)
6785 (not (gnus-data-unread-p (car arts))))
6786 (setq arts (cdr arts)))
6787 (while arts
6788 (and (or (not unread)
6789 (gnus-data-unread-p (car arts)))
6790 (vectorp (gnus-data-header (car arts)))
6791 (gnus-subject-equal
6792 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6793 (setq result (car arts)
6794 arts nil))
6795 (setq arts (cdr arts)))
6796 (and result
6797 (goto-char (gnus-data-pos result))
6798 (gnus-data-number result))))
6800 (defun gnus-summary-search-forward (&optional unread subject backward)
6801 "Search forward for an article.
6802 If UNREAD, look for unread articles. If SUBJECT, look for
6803 articles with that subject. If BACKWARD, search backward instead."
6804 (cond (subject (gnus-summary-find-subject subject unread backward))
6805 (backward (gnus-summary-find-prev unread))
6806 (t (gnus-summary-find-next unread))))
6808 (defun gnus-recenter (&optional n)
6809 "Center point in window and redisplay frame.
6810 Also do horizontal recentering."
6811 (interactive "P")
6812 (when (and gnus-auto-center-summary
6813 (not (eq gnus-auto-center-summary 'vertical)))
6814 (gnus-horizontal-recenter))
6815 (if (fboundp 'recenter-top-bottom)
6816 (recenter-top-bottom n)
6817 (recenter n)))
6819 (put 'gnus-recenter 'isearch-scroll t)
6821 (defun gnus-forward-line-ignore-invisible (n)
6822 "Move N lines forward (backward if N is negative).
6823 Like forward-line, but skip over (and don't count) invisible lines."
6824 (let (done)
6825 (while (and (> n 0) (not done))
6826 ;; If the following character is currently invisible,
6827 ;; skip all characters with that same `invisible' property value.
6828 (while (gnus-invisible-p (point))
6829 (goto-char (gnus-next-char-property-change (point))))
6830 (forward-line 1)
6831 (if (eobp)
6832 (setq done t)
6833 (setq n (1- n))))
6834 (while (and (< n 0) (not done))
6835 (forward-line -1)
6836 (if (bobp) (setq done t)
6837 (setq n (1+ n))
6838 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6839 (goto-char (gnus-previous-char-property-change (point))))))))
6841 (defun gnus-summary-recenter ()
6842 "Center point in the summary window.
6843 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6844 displayed, no centering will be performed."
6845 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6846 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6847 (interactive)
6848 ;; The user has to want it.
6849 (when gnus-auto-center-summary
6850 (let* ((top (cond ((< (window-height) 4) 0)
6851 ((< (window-height) 7) 1)
6852 (t (if (numberp gnus-auto-center-summary)
6853 gnus-auto-center-summary
6854 (/ (1- (window-height)) 2)))))
6855 (height (1- (window-height)))
6856 (bottom (save-excursion
6857 (goto-char (point-max))
6858 (gnus-forward-line-ignore-invisible (- height))
6859 (point)))
6860 (window (get-buffer-window (current-buffer))))
6861 (when (get-buffer-window gnus-article-buffer)
6862 ;; Only do recentering when the article buffer is displayed,
6863 ;; Set the window start to either `bottom', which is the biggest
6864 ;; possible valid number, or the second line from the top,
6865 ;; whichever is the least.
6866 (let ((top-pos (save-excursion
6867 (gnus-forward-line-ignore-invisible (- top))
6868 (point))))
6869 (if (> bottom top-pos)
6870 ;; Keep the second line from the top visible
6871 (set-window-start window top-pos)
6872 ;; Try to keep the bottom line visible; if it's partially
6873 ;; obscured, either scroll one more line to make it fully
6874 ;; visible, or revert to using TOP-POS.
6875 (save-excursion
6876 (goto-char (point-max))
6877 (gnus-forward-line-ignore-invisible -1)
6878 (let ((last-line-start (point)))
6879 (goto-char bottom)
6880 (set-window-start window (point) t)
6881 (when (not (pos-visible-in-window-p last-line-start window))
6882 (gnus-forward-line-ignore-invisible 1)
6883 (set-window-start window (min (point) top-pos) t)))))))
6884 ;; Do horizontal recentering while we're at it.
6885 (when (and (get-buffer-window (current-buffer) t)
6886 (not (eq gnus-auto-center-summary 'vertical)))
6887 (let ((selected (selected-window)))
6888 (select-window (get-buffer-window (current-buffer) t))
6889 (gnus-summary-position-point)
6890 (gnus-horizontal-recenter)
6891 (select-window selected))))))
6893 (defun gnus-summary-jump-to-group (newsgroup)
6894 "Move point to NEWSGROUP in group mode buffer."
6895 ;; Keep update point of group mode buffer if visible.
6896 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6897 (save-window-excursion
6898 ;; Take care of tree window mode.
6899 (when (get-buffer-window gnus-group-buffer)
6900 (pop-to-buffer gnus-group-buffer))
6901 (gnus-group-jump-to-group newsgroup))
6902 (save-excursion
6903 ;; Take care of tree window mode.
6904 (if (get-buffer-window gnus-group-buffer 0)
6905 (pop-to-buffer gnus-group-buffer)
6906 (set-buffer gnus-group-buffer))
6907 (gnus-group-jump-to-group newsgroup))))
6909 ;; This function returns a list of article numbers based on the
6910 ;; difference between the ranges of read articles in this group and
6911 ;; the range of active articles.
6912 (defun gnus-list-of-unread-articles (group)
6913 (let* ((read (gnus-info-read (gnus-get-info group)))
6914 (active (or (gnus-active group) (gnus-activate-group group)))
6915 (last (or (cdr active)
6916 (error "Group %s couldn't be activated " group)))
6917 (bottom (if gnus-newsgroup-maximum-articles
6918 (max (car active)
6919 (- last gnus-newsgroup-maximum-articles -1))
6920 (car active)))
6921 first nlast unread)
6922 ;; If none are read, then all are unread.
6923 (if (not read)
6924 (setq first bottom)
6925 ;; If the range of read articles is a single range, then the
6926 ;; first unread article is the article after the last read
6927 ;; article. Sounds logical, doesn't it?
6928 (if (and (not (listp (cdr read)))
6929 (or (< (car read) bottom)
6930 (progn (setq read (list read))
6931 nil)))
6932 (setq first (max bottom (1+ (cdr read))))
6933 ;; `read' is a list of ranges.
6934 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6935 (caar read)))
6937 (setq first bottom))
6938 (while read
6939 (when first
6940 (while (< first nlast)
6941 (setq unread (cons first unread)
6942 first (1+ first))))
6943 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6944 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6945 (setq read (cdr read)))))
6946 ;; And add the last unread articles.
6947 (while (<= first last)
6948 (setq unread (cons first unread)
6949 first (1+ first)))
6950 ;; Return the list of unread articles.
6951 (delq 0 (nreverse unread))))
6953 (defun gnus-list-of-read-articles (group)
6954 "Return a list of unread, unticked and non-dormant articles."
6955 (let* ((info (gnus-get-info group))
6956 (marked (gnus-info-marks info))
6957 (active (gnus-active group)))
6958 (and info active
6959 (gnus-list-range-difference
6960 (gnus-list-range-difference
6961 (gnus-sorted-complement
6962 (gnus-uncompress-range
6963 (if gnus-newsgroup-maximum-articles
6964 (cons (max (car active)
6965 (- (cdr active)
6966 gnus-newsgroup-maximum-articles
6967 -1))
6968 (cdr active))
6969 active))
6970 (gnus-list-of-unread-articles group))
6971 (cdr (assq 'dormant marked)))
6972 (cdr (assq 'tick marked))))))
6974 ;; This function returns a sequence of article numbers based on the
6975 ;; difference between the ranges of read articles in this group and
6976 ;; the range of active articles.
6977 (defun gnus-sequence-of-unread-articles (group)
6978 (let* ((read (gnus-info-read (gnus-get-info group)))
6979 (active (or (gnus-active group) (gnus-activate-group group)))
6980 (last (cdr active))
6981 (bottom (if gnus-newsgroup-maximum-articles
6982 (max (car active)
6983 (- last gnus-newsgroup-maximum-articles -1))
6984 (car active)))
6985 first nlast unread)
6986 ;; If none are read, then all are unread.
6987 (if (not read)
6988 (setq first bottom)
6989 ;; If the range of read articles is a single range, then the
6990 ;; first unread article is the article after the last read
6991 ;; article. Sounds logical, doesn't it?
6992 (if (and (not (listp (cdr read)))
6993 (or (< (car read) bottom)
6994 (progn (setq read (list read))
6995 nil)))
6996 (setq first (max bottom (1+ (cdr read))))
6997 ;; `read' is a list of ranges.
6998 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6999 (caar read)))
7001 (setq first bottom))
7002 (while read
7003 (when first
7004 (push (cons first nlast) unread))
7005 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7006 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7007 (setq read (cdr read)))))
7008 ;; And add the last unread articles.
7009 (cond ((not (and first last))
7010 nil)
7011 ((< first last)
7012 (push (cons first last) unread))
7013 ((= first last)
7014 (push first unread)))
7015 ;; Return the sequence of unread articles.
7016 (delq 0 (nreverse unread))))
7018 ;; Various summary commands
7020 (defun gnus-summary-select-article-buffer ()
7021 "Reconfigure windows to show the article buffer.
7022 If `gnus-widen-article-window' is set, show only the article
7023 buffer."
7024 (interactive)
7025 (if (not (gnus-buffer-live-p gnus-article-buffer))
7026 (error "There is no article buffer for this summary buffer")
7027 (unless (get-buffer-window gnus-article-buffer)
7028 (gnus-summary-show-article))
7029 (gnus-configure-windows
7030 (if gnus-widen-article-window
7031 'only-article
7032 'article)
7034 (select-window (get-buffer-window gnus-article-buffer))))
7036 (defun gnus-summary-universal-argument (arg)
7037 "Perform any operation on all articles that are process/prefixed."
7038 (interactive "P")
7039 (let ((articles (gnus-summary-work-articles arg))
7040 func article)
7041 (if (eq
7042 (setq
7043 func
7044 (key-binding
7045 (read-key-sequence
7046 (substitute-command-keys
7047 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7048 'undefined)
7049 (gnus-error 1 "Undefined key")
7050 (save-excursion
7051 (while articles
7052 (gnus-summary-goto-subject (setq article (pop articles)))
7053 (let (gnus-newsgroup-processable)
7054 (command-execute func))
7055 (gnus-summary-remove-process-mark article)))))
7056 (gnus-summary-position-point))
7058 (defun gnus-summary-toggle-truncation (&optional arg)
7059 "Toggle truncation of summary lines.
7060 With ARG, turn line truncation on if ARG is positive."
7061 (interactive "P")
7062 (setq truncate-lines
7063 (if (null arg) (not truncate-lines)
7064 (> (prefix-numeric-value arg) 0)))
7065 (redraw-display))
7067 (defun gnus-summary-find-for-reselect ()
7068 "Return the number of an article to stay on across a reselect.
7069 The current article is considered, then following articles, then previous
7070 articles. An article is sought which is not canceled and isn't a temporary
7071 insertion from another group. If there's no such then return a dummy 0."
7072 (let (found)
7073 (dolist (rev '(nil t))
7074 (unless found ; don't demand the reverse list if we don't need it
7075 (let ((data (gnus-data-find-list
7076 (gnus-summary-article-number) (gnus-data-list rev))))
7077 (while (and data (not found))
7078 (if (and (< 0 (gnus-data-number (car data)))
7079 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7080 (setq found (gnus-data-number (car data))))
7081 (setq data (cdr data))))))
7082 (or found 0)))
7084 (defun gnus-summary-reselect-current-group (&optional all rescan)
7085 "Exit and then reselect the current newsgroup.
7086 The prefix argument ALL means to select all articles."
7087 (interactive "P")
7088 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7089 (error "Ephemeral groups can't be reselected"))
7090 (let ((current-subject (gnus-summary-find-for-reselect))
7091 (group gnus-newsgroup-name))
7092 (setq gnus-newsgroup-begin nil)
7093 (gnus-summary-exit nil 'leave-hidden)
7094 ;; We have to adjust the point of group mode buffer because
7095 ;; point was moved to the next unread newsgroup by exiting.
7096 (gnus-summary-jump-to-group group)
7097 (when rescan
7098 (save-excursion
7099 (gnus-group-get-new-news-this-group 1)))
7100 (gnus-group-read-group all t)
7101 (gnus-summary-goto-subject current-subject nil t)))
7103 (defun gnus-summary-rescan-group (&optional all)
7104 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7105 (interactive "P")
7106 (let ((config gnus-current-window-configuration))
7107 (gnus-summary-reselect-current-group all t)
7108 (gnus-configure-windows config)
7109 (when (eq config 'article)
7110 (gnus-summary-select-article))))
7112 (defun gnus-summary-update-info (&optional non-destructive)
7113 (save-excursion
7114 (let ((group gnus-newsgroup-name))
7115 (when group
7116 (when gnus-newsgroup-kill-headers
7117 (setq gnus-newsgroup-killed
7118 (gnus-compress-sequence
7119 (gnus-sorted-union
7120 (gnus-list-range-intersection
7121 gnus-newsgroup-unselected gnus-newsgroup-killed)
7122 gnus-newsgroup-unreads)
7123 t)))
7124 (unless (listp (cdr gnus-newsgroup-killed))
7125 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7126 (let ((headers gnus-newsgroup-headers)
7127 (ephemeral-p (gnus-ephemeral-group-p group))
7128 info)
7129 (unless ephemeral-p
7130 (setq info (copy-sequence (gnus-get-info group))
7131 info (delq (gnus-info-params info) info)))
7132 ;; Set the new ranges of read articles.
7133 (with-current-buffer gnus-group-buffer
7134 (gnus-undo-force-boundary))
7135 (gnus-update-read-articles
7136 group (gnus-sorted-union
7137 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7138 ;; Set the current article marks.
7139 (let ((gnus-newsgroup-scored
7140 (if (and (not gnus-save-score)
7141 (not non-destructive))
7143 gnus-newsgroup-scored)))
7144 (save-excursion
7145 (gnus-update-marks)))
7146 ;; Do the cross-ref thing.
7147 (when gnus-use-cross-reference
7148 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7149 ;; Do not switch windows but change the buffer to work.
7150 (set-buffer gnus-group-buffer)
7151 (unless ephemeral-p
7152 (gnus-group-update-group
7153 group nil
7154 (equal info
7155 (setq info (copy-sequence (gnus-get-info group))
7156 info (delq (gnus-info-params info) info))))))))))
7158 (defun gnus-summary-save-newsrc (&optional force)
7159 "Save the current number of read/marked articles in the dribble buffer.
7160 The dribble buffer will then be saved.
7161 If FORCE (the prefix), also save the .newsrc file(s)."
7162 (interactive "P")
7163 (gnus-summary-update-info t)
7164 (if force
7165 (gnus-save-newsrc-file)
7166 (gnus-dribble-save)))
7168 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7170 (defun gnus-summary-exit (&optional temporary leave-hidden)
7171 "Exit reading current newsgroup, and then return to group selection mode.
7172 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7173 (interactive)
7174 (gnus-set-global-variables)
7175 (when (gnus-buffer-live-p gnus-article-buffer)
7176 (with-current-buffer gnus-article-buffer
7177 (mm-destroy-parts gnus-article-mime-handles)
7178 ;; Set it to nil for safety reason.
7179 (setq gnus-article-mime-handle-alist nil)
7180 (setq gnus-article-mime-handles nil)))
7181 (gnus-kill-save-kill-buffer)
7182 (gnus-async-halt-prefetch)
7183 (let* ((group gnus-newsgroup-name)
7184 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7185 (gnus-group-is-exiting-p t)
7186 (article-buffer gnus-article-buffer)
7187 (original-article-buffer gnus-original-article-buffer)
7188 (mode major-mode)
7189 (group-point nil)
7190 (buf (current-buffer))
7191 ;; `gnus-single-article-buffer' is nil buffer-locally in
7192 ;; ephemeral group of which summary buffer will be killed,
7193 ;; but the global value may be non-nil.
7194 (single-article-buffer gnus-single-article-buffer))
7195 (unless quit-config
7196 ;; Do adaptive scoring, and possibly save score files.
7197 (when gnus-newsgroup-adaptive
7198 (gnus-score-adaptive))
7199 (when gnus-use-scoring
7200 (gnus-score-save)))
7201 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7202 (when gnus-use-cache
7203 (gnus-cache-possibly-remove-articles)
7204 (gnus-cache-save-buffers))
7205 (gnus-async-prefetch-remove-group group)
7206 (when gnus-suppress-duplicates
7207 (gnus-dup-enter-articles))
7208 (when gnus-use-trees
7209 (gnus-tree-close group))
7210 (when gnus-use-cache
7211 (gnus-cache-write-active))
7212 ;; Remove entries for this group.
7213 (nnmail-purge-split-history (gnus-group-real-name group))
7214 ;; Make all changes in this group permanent.
7215 (unless quit-config
7216 (gnus-run-hooks 'gnus-exit-group-hook)
7217 (gnus-summary-update-info))
7218 (gnus-close-group group)
7219 ;; Make sure where we were, and go to next newsgroup.
7220 (when (buffer-live-p (get-buffer gnus-group-buffer))
7221 (set-buffer gnus-group-buffer))
7222 (unless quit-config
7223 (gnus-group-jump-to-group group))
7224 (gnus-run-hooks 'gnus-summary-exit-hook)
7225 (unless (or quit-config
7226 (not gnus-summary-next-group-on-exit)
7227 ;; If this group has disappeared from the summary
7228 ;; buffer, don't skip forwards.
7229 (not (string= group (gnus-group-group-name))))
7230 (gnus-group-next-unread-group 1))
7231 (setq group-point (point))
7232 (if temporary
7233 nil ;Nothing to do.
7234 (set-buffer buf)
7235 (if (not gnus-kill-summary-on-exit)
7236 (progn
7237 (gnus-deaden-summary)
7238 (setq mode nil))
7239 (when (get-buffer gnus-article-buffer)
7240 (bury-buffer gnus-article-buffer))
7241 ;; Return to group mode buffer.
7242 (when (eq mode 'gnus-summary-mode)
7243 (gnus-kill-buffer buf)))
7245 (setq gnus-current-select-method gnus-select-method)
7246 (when (gnus-buffer-live-p gnus-group-buffer)
7247 (set-buffer gnus-group-buffer))
7248 (if quit-config
7249 (gnus-handle-ephemeral-exit quit-config)
7250 (goto-char group-point)
7251 ;; If gnus-group-buffer is already displayed, make sure we also move
7252 ;; the cursor in the window that displays it.
7253 (let ((win (get-buffer-window (current-buffer) 0)))
7254 (if win (set-window-point win (point))))
7255 (unless leave-hidden
7256 (gnus-configure-windows 'group 'force)))
7258 ;; If we have several article buffers, we kill them at exit.
7259 (unless single-article-buffer
7260 (when (gnus-buffer-live-p article-buffer)
7261 (with-current-buffer article-buffer
7262 ;; Don't kill sticky article buffers
7263 (unless (eq major-mode 'gnus-sticky-article-mode)
7264 (gnus-kill-buffer article-buffer)
7265 (setq gnus-article-current nil))))
7266 (gnus-kill-buffer original-article-buffer))
7268 ;; Clear the current group name.
7269 (unless quit-config
7270 (setq gnus-newsgroup-name nil)))))
7272 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7273 (defun gnus-summary-exit-no-update (&optional no-questions)
7274 "Quit reading current newsgroup without updating read article info."
7275 (interactive)
7276 (let* ((group gnus-newsgroup-name)
7277 (gnus-group-is-exiting-p t)
7278 (gnus-group-is-exiting-without-update-p t)
7279 (quit-config (gnus-group-quit-config group)))
7280 (when (or no-questions
7281 gnus-expert-user
7282 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7283 (gnus-async-halt-prefetch)
7284 (run-hooks 'gnus-summary-prepare-exit-hook)
7285 (when (gnus-buffer-live-p gnus-article-buffer)
7286 (with-current-buffer gnus-article-buffer
7287 (gnus-article-stop-animations)
7288 (gnus-stop-downloads)
7289 (mm-destroy-parts gnus-article-mime-handles)
7290 ;; Set it to nil for safety reason.
7291 (setq gnus-article-mime-handle-alist nil)
7292 (setq gnus-article-mime-handles nil)))
7293 ;; If we have several article buffers, we kill them at exit.
7294 (unless gnus-single-article-buffer
7295 (gnus-kill-buffer gnus-article-buffer)
7296 (gnus-kill-buffer gnus-original-article-buffer)
7297 (setq gnus-article-current nil))
7298 ;; Return to the group buffer.
7299 (if (not gnus-kill-summary-on-exit)
7300 (progn
7301 (gnus-deaden-summary)
7302 (gnus-configure-windows 'group 'force))
7303 (gnus-configure-windows 'group 'force)
7304 (gnus-close-group group)
7305 (gnus-kill-buffer gnus-summary-buffer))
7306 (unless gnus-single-article-buffer
7307 (setq gnus-article-current nil))
7308 (when gnus-use-trees
7309 (gnus-tree-close group))
7310 (gnus-async-prefetch-remove-group group)
7311 (when (get-buffer gnus-article-buffer)
7312 (bury-buffer gnus-article-buffer))
7313 ;; Clear the current group name.
7314 (setq gnus-newsgroup-name nil)
7315 (unless (gnus-ephemeral-group-p group)
7316 (gnus-group-update-group group nil t))
7317 (when (equal (gnus-group-group-name) group)
7318 (gnus-group-next-unread-group 1))
7319 (when quit-config
7320 (gnus-handle-ephemeral-exit quit-config)))))
7322 (defun gnus-handle-ephemeral-exit (quit-config)
7323 "Handle movement when leaving an ephemeral group.
7324 The state which existed when entering the ephemeral is reset."
7325 (if (not (buffer-live-p (car quit-config)))
7326 (when (gnus-buffer-live-p gnus-group-buffer)
7327 (gnus-configure-windows 'group 'force))
7328 (set-buffer (car quit-config))
7329 (unless (eq (cdr quit-config) 'group)
7330 (setq gnus-current-select-method
7331 (gnus-find-method-for-group gnus-newsgroup-name)))
7332 (cond ((eq major-mode 'gnus-summary-mode)
7333 (gnus-set-global-variables))
7334 ((eq major-mode 'gnus-article-mode)
7335 (save-current-buffer
7336 ;; The `gnus-summary-buffer' variable may point
7337 ;; to the old summary buffer when using a single
7338 ;; article buffer.
7339 (unless (gnus-buffer-live-p gnus-summary-buffer)
7340 (set-buffer gnus-group-buffer))
7341 (set-buffer gnus-summary-buffer)
7342 (gnus-set-global-variables))))
7343 (if (or (eq (cdr quit-config) 'article)
7344 (eq (cdr quit-config) 'pick))
7345 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7346 (gnus-configure-windows 'pick 'force)
7347 (gnus-configure-windows (cdr quit-config) 'force))
7348 (gnus-configure-windows (cdr quit-config) 'force))
7349 (when (eq major-mode 'gnus-summary-mode)
7350 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7351 next-unread-noselect))
7352 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7353 'next-noselect)
7354 (gnus-summary-next-subject 1 nil t))
7355 ((eq gnus-auto-select-on-ephemeral-exit
7356 'next-unread-noselect)
7357 (gnus-summary-next-subject 1 t t))))
7358 ;; Hide the article buffer which displays the article different
7359 ;; from the one that the cursor points to in the summary buffer.
7360 (gnus-configure-windows 'summary 'force))
7361 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7362 (gnus-summary-next-subject 1))
7363 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7364 (gnus-summary-next-subject 1 t))))
7365 (gnus-summary-recenter)
7366 (gnus-summary-position-point))))
7368 ;;; Dead summaries.
7370 (defvar gnus-dead-summary-mode-map
7371 (let ((map (make-keymap)))
7372 (suppress-keymap map)
7373 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7374 (dolist (key '("\C-d" "\r" "\177" [delete]))
7375 (define-key map key 'gnus-summary-wake-up-the-dead))
7376 (dolist (key '("q" "Q"))
7377 (define-key map key 'bury-buffer))
7378 map))
7380 (define-minor-mode gnus-dead-summary-mode
7381 "Minor mode for Gnus summary buffers."
7382 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7383 (unless (derived-mode-p 'gnus-summary-mode)
7384 (setq gnus-dead-summary-mode nil)))
7386 (defun gnus-deaden-summary ()
7387 "Make the current summary buffer into a dead summary buffer."
7388 ;; Kill any previous dead summary buffer.
7389 (when (and gnus-dead-summary
7390 (buffer-name gnus-dead-summary))
7391 (with-current-buffer gnus-dead-summary
7392 (when gnus-dead-summary-mode
7393 (kill-buffer (current-buffer)))))
7394 ;; Make this the current dead summary.
7395 (setq gnus-dead-summary (current-buffer))
7396 (gnus-dead-summary-mode 1)
7397 (let ((name (buffer-name)))
7398 (when (string-match "Summary" name)
7399 (rename-buffer
7400 (concat (substring name 0 (match-beginning 0)) "Dead "
7401 (substring name (match-beginning 0)))
7403 (bury-buffer))))
7405 (defun gnus-kill-or-deaden-summary (buffer)
7406 "Kill or deaden the summary BUFFER."
7407 (save-excursion
7408 (when (and (buffer-name buffer)
7409 (not gnus-single-article-buffer))
7410 (with-current-buffer buffer
7411 (gnus-kill-buffer gnus-article-buffer)
7412 (gnus-kill-buffer gnus-original-article-buffer)))
7413 (cond
7414 ;; Kill the buffer.
7415 (gnus-kill-summary-on-exit
7416 (when (and gnus-use-trees
7417 (gnus-buffer-exists-p buffer))
7418 (with-current-buffer buffer
7419 (gnus-tree-close gnus-newsgroup-name)))
7420 (gnus-kill-buffer buffer))
7421 ;; Deaden the buffer.
7422 ((gnus-buffer-exists-p buffer)
7423 (with-current-buffer buffer
7424 (gnus-deaden-summary))))))
7426 (defun gnus-summary-wake-up-the-dead (&rest args)
7427 "Wake up the dead summary buffer."
7428 (interactive)
7429 (gnus-dead-summary-mode -1)
7430 (let ((name (buffer-name)))
7431 (when (string-match "Dead " name)
7432 (rename-buffer
7433 (concat (substring name 0 (match-beginning 0))
7434 (substring name (match-end 0)))
7435 t)))
7436 (gnus-message 3 "This dead summary is now alive again"))
7438 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7439 (defun gnus-summary-describe-group (&optional force)
7440 "Describe the current newsgroup."
7441 (interactive "P")
7442 (gnus-group-describe-group force gnus-newsgroup-name))
7444 (defun gnus-summary-describe-briefly ()
7445 "Describe summary mode commands briefly."
7446 (interactive)
7447 (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")))
7449 ;; Walking around group mode buffer from summary mode.
7451 (defun gnus-summary-next-group (&optional no-article target-group backward)
7452 "Exit current newsgroup and then select next unread newsgroup.
7453 If prefix argument NO-ARTICLE is non-nil, no article is selected
7454 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7455 previous group instead."
7456 (interactive "P")
7457 ;; Stop pre-fetching.
7458 (gnus-async-halt-prefetch)
7459 (let ((current-group gnus-newsgroup-name)
7460 (current-buffer (current-buffer))
7461 entered)
7462 ;; First we semi-exit this group to update Xrefs and all variables.
7463 ;; We can't do a real exit, because the window conf must remain
7464 ;; the same in case the user is prompted for info, and we don't
7465 ;; want the window conf to change before that...
7466 (gnus-summary-exit t)
7467 (while (not entered)
7468 ;; Then we find what group we are supposed to enter.
7469 (set-buffer gnus-group-buffer)
7470 (gnus-group-jump-to-group current-group)
7471 (setq target-group
7472 (or target-group
7473 (if (eq gnus-keep-same-level 'best)
7474 (gnus-summary-best-group gnus-newsgroup-name)
7475 (gnus-summary-search-group backward gnus-keep-same-level))))
7476 (if (not target-group)
7477 ;; There are no further groups, so we return to the group
7478 ;; buffer.
7479 (progn
7480 (gnus-message 5 "Returning to the group buffer")
7481 (setq entered t)
7482 (when (gnus-buffer-live-p current-buffer)
7483 (set-buffer current-buffer)
7484 (gnus-summary-exit))
7485 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7486 ;; We try to enter the target group.
7487 (gnus-group-jump-to-group target-group)
7488 (let ((unreads (gnus-group-group-unread)))
7489 (if (and (or (eq t unreads)
7490 (and unreads (not (zerop unreads))))
7491 (gnus-summary-read-group
7492 target-group nil no-article
7493 (and (buffer-name current-buffer) current-buffer)
7494 nil backward))
7495 (setq entered t)
7496 (setq current-group target-group
7497 target-group nil)))))))
7499 (defun gnus-summary-prev-group (&optional no-article)
7500 "Exit current newsgroup and then select previous unread newsgroup.
7501 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7502 (interactive "P")
7503 (gnus-summary-next-group no-article nil t))
7505 ;; Walking around summary lines.
7507 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7508 "Go to the first subject satisfying any non-nil constraint.
7509 If UNREAD is non-nil, the article should be unread.
7510 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7511 If UNSEEN is non-nil, the article should be unseen as well as unread.
7512 Returns the article selected or nil if there are no matching articles."
7513 (interactive "P")
7514 (cond
7515 ;; Empty summary.
7516 ((null gnus-newsgroup-data)
7517 (gnus-message 3 "No articles in the group")
7518 nil)
7519 ;; Pick the first article.
7520 ((not (or unread undownloaded unseen))
7521 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7522 (gnus-data-number (car gnus-newsgroup-data)))
7523 ;; Find the first unread article.
7525 (let ((data gnus-newsgroup-data))
7526 (while (and data
7527 (let ((num (gnus-data-number (car data))))
7528 (or (memq num gnus-newsgroup-unfetched)
7529 (not (or (and unread
7530 (memq num gnus-newsgroup-unreads))
7531 (and undownloaded
7532 (memq num gnus-newsgroup-undownloaded))
7533 (and unseen
7534 (memq num gnus-newsgroup-unseen)
7535 (memq num gnus-newsgroup-unreads)))))))
7536 (setq data (cdr data)))
7537 (prog1
7538 (if data
7539 (progn
7540 (goto-char (gnus-data-pos (car data)))
7541 (gnus-data-number (car data)))
7542 (gnus-message 3 "No more%s articles"
7543 (let* ((r (when unread " unread"))
7544 (d (when undownloaded " undownloaded"))
7545 (s (when unseen " unseen"))
7546 (l (delq nil (list r d s))))
7547 (cond ((= 3 (length l))
7548 (concat r "," d ", or" s))
7549 ((= 2 (length l))
7550 (concat (car l) ", or" (cadr l)))
7551 ((= 1 (length l))
7552 (car l))
7554 ""))))
7557 (gnus-summary-position-point))))))
7559 (defun gnus-summary-next-subject (n &optional unread dont-display)
7560 "Go to next N'th summary line.
7561 If N is negative, go to the previous N'th subject line.
7562 If UNREAD is non-nil, only unread articles are selected.
7563 The difference between N and the actual number of steps taken is
7564 returned."
7565 (interactive "p")
7566 (let ((backward (< n 0))
7567 (n (abs n)))
7568 (while (and (> n 0)
7569 (if backward
7570 (gnus-summary-find-prev unread)
7571 (gnus-summary-find-next unread)))
7572 (unless (zerop (setq n (1- n)))
7573 (gnus-summary-show-thread)))
7574 (when (/= 0 n)
7575 (gnus-message 7 "No more%s articles"
7576 (if unread " unread" "")))
7577 (unless dont-display
7578 (gnus-summary-recenter)
7579 (gnus-summary-position-point))
7582 (defun gnus-summary-next-unread-subject (n)
7583 "Go to next N'th unread summary line."
7584 (interactive "p")
7585 (gnus-summary-next-subject n t))
7587 (defun gnus-summary-prev-subject (n &optional unread)
7588 "Go to previous N'th summary line.
7589 If optional argument UNREAD is non-nil, only unread article is selected."
7590 (interactive "p")
7591 (gnus-summary-next-subject (- n) unread))
7593 (defun gnus-summary-prev-unread-subject (n)
7594 "Go to previous N'th unread summary line."
7595 (interactive "p")
7596 (gnus-summary-next-subject (- n) t))
7598 (defun gnus-summary-goto-subjects (articles)
7599 "Insert the subject header for ARTICLES in the current buffer."
7600 (save-excursion
7601 (dolist (article articles)
7602 (gnus-summary-goto-subject article t)))
7603 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7604 (gnus-summary-position-point))
7606 (defun gnus-summary-goto-subject (article &optional force silent)
7607 "Go to the subject line of ARTICLE.
7608 If FORCE, also allow jumping to articles not currently shown."
7609 (interactive "nArticle number: ")
7610 (unless (numberp article)
7611 (error "Article %s is not a number" article))
7612 (let ((b (point))
7613 (data (gnus-data-find article)))
7614 ;; We read in the article if we have to.
7615 (and (not data)
7616 force
7617 (gnus-summary-insert-subject
7618 article
7619 (if (or (numberp force) (vectorp force)) force)
7621 (setq data (gnus-data-find article)))
7622 (goto-char b)
7623 (if (not data)
7624 (progn
7625 (unless silent
7626 (gnus-message 3 "Can't find article %d" article))
7627 nil)
7628 (let ((pt (gnus-data-pos data)))
7629 (goto-char pt)
7630 (gnus-summary-set-article-display-arrow pt))
7631 (gnus-summary-position-point)
7632 article)))
7634 ;; Walking around summary lines with displaying articles.
7636 (defun gnus-summary-expand-window (&optional arg)
7637 "Make the summary buffer take up the entire Emacs frame.
7638 Given a prefix, will force an `article' buffer configuration."
7639 (interactive "P")
7640 (if arg
7641 (gnus-configure-windows 'article 'force)
7642 (gnus-configure-windows 'summary 'force)))
7644 (defun gnus-summary-display-article (article &optional all-header)
7645 "Display ARTICLE in article buffer."
7646 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7647 (with-current-buffer gnus-article-buffer
7648 (eq major-mode 'gnus-article-mode)))
7649 (gnus-article-setup-buffer))
7650 (gnus-set-global-variables)
7651 (with-current-buffer gnus-article-buffer
7652 (setq gnus-article-charset gnus-newsgroup-charset)
7653 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7654 (mm-enable-multibyte))
7655 (if (null article)
7657 (prog1
7658 (if gnus-summary-display-article-function
7659 (funcall gnus-summary-display-article-function article all-header)
7660 (gnus-article-prepare article all-header))
7661 (gnus-run-hooks 'gnus-select-article-hook)
7662 (when (and gnus-current-article
7663 (not (zerop gnus-current-article)))
7664 (gnus-summary-goto-subject gnus-current-article))
7665 (gnus-summary-recenter)
7666 (when (and gnus-use-trees gnus-show-threads)
7667 (gnus-possibly-generate-tree article)
7668 (gnus-highlight-selected-tree article))
7669 ;; Successfully display article.
7670 (gnus-article-set-window-start
7671 (cdr (assq article gnus-newsgroup-bookmarks))))))
7673 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7674 "Select the current article.
7675 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7676 non-nil, the article will be re-fetched even if it already present in
7677 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7678 be displayed."
7679 ;; Make sure we are in the summary buffer to work around bbdb bug.
7680 (unless (eq major-mode 'gnus-summary-mode)
7681 (set-buffer gnus-summary-buffer))
7682 (let ((article (or article (gnus-summary-article-number)))
7683 (all-headers (not (not all-headers))) ;Must be t or nil.
7684 gnus-summary-display-article-function)
7685 (and (not pseudo)
7686 (gnus-summary-article-pseudo-p article)
7687 (error "This is a pseudo-article"))
7688 (with-current-buffer gnus-summary-buffer
7689 (if (or (and gnus-single-article-buffer
7690 (or (null gnus-current-article)
7691 (null gnus-article-current)
7692 (null (get-buffer gnus-article-buffer))
7693 (not (eq article (cdr gnus-article-current)))
7694 (not (equal (car gnus-article-current)
7695 gnus-newsgroup-name))
7696 (not (get-buffer gnus-original-article-buffer))))
7697 (and (not gnus-single-article-buffer)
7698 (or (null gnus-current-article)
7699 (not (get-buffer gnus-original-article-buffer))
7700 (not (eq gnus-current-article article))))
7701 force)
7702 ;; The requested article is different from the current article.
7703 (progn
7704 (gnus-summary-display-article article all-headers)
7705 (when (gnus-buffer-live-p gnus-article-buffer)
7706 (with-current-buffer gnus-article-buffer
7707 (if (not gnus-article-decoded-p) ;; a local variable
7708 (mm-disable-multibyte))))
7709 (gnus-article-set-window-start
7710 (cdr (assq article gnus-newsgroup-bookmarks)))
7711 article)
7712 'old))))
7714 (defun gnus-summary-force-verify-and-decrypt ()
7715 "Display buttons for signed/encrypted parts and verify/decrypt them."
7716 (interactive)
7717 (let ((mm-verify-option 'known)
7718 (mm-decrypt-option 'known)
7719 (gnus-article-emulate-mime t)
7720 (gnus-buttonized-mime-types (append (list "multipart/signed"
7721 "multipart/encrypted")
7722 gnus-buttonized-mime-types)))
7723 (gnus-summary-select-article nil 'force)))
7725 (defun gnus-summary-next-article (&optional unread subject backward push)
7726 "Select the next article.
7727 If UNREAD, only unread articles are selected.
7728 If SUBJECT, only articles with SUBJECT are selected.
7729 If BACKWARD, the previous article is selected instead of the next."
7730 (interactive "P")
7731 ;; Make sure we are in the summary buffer.
7732 (unless (eq major-mode 'gnus-summary-mode)
7733 (set-buffer gnus-summary-buffer))
7734 (cond
7735 ;; Is there such an article?
7736 ((and (gnus-summary-search-forward unread subject backward)
7737 (or (gnus-summary-display-article (gnus-summary-article-number))
7738 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7739 (gnus-summary-position-point))
7740 ;; If not, we try the first unread, if that is wanted.
7741 ((and subject
7742 gnus-auto-select-same
7743 (gnus-summary-first-unread-article))
7744 (gnus-summary-position-point)
7745 (gnus-message 6 "Wrapped"))
7746 ;; Try to get next/previous article not displayed in this group.
7747 ((and gnus-auto-extend-newsgroup
7748 (not unread) (not subject))
7749 (gnus-summary-goto-article
7750 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7751 nil (count-lines (point-min) (point))))
7752 ;; Go to next/previous group.
7754 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7755 (gnus-summary-jump-to-group gnus-newsgroup-name))
7756 (let ((cmd (if (featurep 'xemacs)
7757 last-command-char
7758 last-command-event))
7759 (point
7760 (with-current-buffer gnus-group-buffer
7761 (point)))
7762 (current-summary (current-buffer))
7763 (group
7764 (if (eq gnus-keep-same-level 'best)
7765 (gnus-summary-best-group gnus-newsgroup-name)
7766 (gnus-summary-search-group backward gnus-keep-same-level))))
7767 ;; Select next unread newsgroup automagically.
7768 (cond
7769 ((or (not gnus-auto-select-next)
7770 (not cmd))
7771 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7772 ((or (eq gnus-auto-select-next 'quietly)
7773 (and (eq gnus-auto-select-next 'slightly-quietly)
7774 push)
7775 (and (eq gnus-auto-select-next 'almost-quietly)
7776 (gnus-summary-last-article-p)))
7777 ;; Select quietly.
7778 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7779 (gnus-summary-exit)
7780 (gnus-message 7 "No more%s articles (%s)..."
7781 (if unread " unread" "")
7782 (if group (concat "selecting " group)
7783 "exiting"))
7784 (gnus-summary-next-group nil group backward)))
7786 (when (gnus-key-press-event-p last-input-event)
7787 ;; Somehow or other, we may now have selected a different
7788 ;; window. Make point go back to the summary buffer.
7789 (when (eq current-summary (current-buffer))
7790 ;; FIXME: This burps when get-buffer-window returns nil.
7791 (select-window (get-buffer-window current-summary 0)))
7792 (gnus-summary-walk-group-buffer
7793 gnus-newsgroup-name cmd unread backward point))))))))
7795 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7796 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7797 (?\C-p (gnus-group-prev-unread-group 1))))
7798 (cursor-in-echo-area t)
7799 keve key group ended prompt)
7800 (with-current-buffer gnus-group-buffer
7801 (goto-char start)
7802 (setq group
7803 (if (eq gnus-keep-same-level 'best)
7804 (gnus-summary-best-group gnus-newsgroup-name)
7805 (gnus-summary-search-group backward gnus-keep-same-level))))
7806 (while (not ended)
7807 (setq prompt
7808 (format
7809 "No more%s articles%s " (if unread " unread" "")
7810 (if (and group
7811 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7812 (format " (Type %s for %s [%s])"
7813 (single-key-description cmd)
7814 (gnus-group-decoded-name group)
7815 (gnus-group-unread group))
7816 (format " (Type %s to exit %s)"
7817 (single-key-description cmd)
7818 (gnus-group-decoded-name gnus-newsgroup-name)))))
7819 ;; Confirm auto selection.
7820 (setq key (car (setq keve (gnus-read-event-char prompt)))
7821 ended t)
7822 (cond
7823 ((assq key keystrokes)
7824 (let ((obuf (current-buffer)))
7825 (switch-to-buffer gnus-group-buffer)
7826 (when group
7827 (gnus-group-jump-to-group group))
7828 (eval (cadr (assq key keystrokes)))
7829 (setq group (gnus-group-group-name))
7830 (switch-to-buffer obuf))
7831 (setq ended nil))
7832 ((equal key cmd)
7833 (if (or (not group)
7834 (gnus-ephemeral-group-p gnus-newsgroup-name))
7835 (gnus-summary-exit)
7836 (gnus-summary-next-group nil group backward)))
7838 (push (cdr keve) unread-command-events))))))
7840 (defun gnus-summary-next-unread-article ()
7841 "Select unread article after current one."
7842 (interactive)
7843 (gnus-summary-next-article
7844 (or (not (eq gnus-summary-goto-unread 'never))
7845 (gnus-summary-last-article-p (gnus-summary-article-number)))
7846 (and gnus-auto-select-same
7847 (gnus-summary-article-subject))))
7849 (defun gnus-summary-prev-article (&optional unread subject)
7850 "Select the article before the current one.
7851 If UNREAD is non-nil, only unread articles are selected."
7852 (interactive "P")
7853 (gnus-summary-next-article unread subject t))
7855 (defun gnus-summary-prev-unread-article ()
7856 "Select unread article before current one."
7857 (interactive)
7858 (gnus-summary-prev-article
7859 (or (not (eq gnus-summary-goto-unread 'never))
7860 (gnus-summary-first-article-p (gnus-summary-article-number)))
7861 (and gnus-auto-select-same
7862 (gnus-summary-article-subject))))
7864 (defun gnus-summary-next-page (&optional lines circular stop)
7865 "Show next page of the selected article.
7866 If at the end of the current article, select the next article.
7867 LINES says how many lines should be scrolled up.
7869 If CIRCULAR is non-nil, go to the start of the article instead of
7870 selecting the next article when reaching the end of the current
7871 article.
7873 If STOP is non-nil, just stop when reaching the end of the message.
7875 Also see the variable `gnus-article-skip-boring'."
7876 (interactive "P")
7877 (setq gnus-summary-buffer (current-buffer))
7878 (gnus-set-global-variables)
7879 (let ((article (gnus-summary-article-number))
7880 (article-window (get-buffer-window gnus-article-buffer t))
7881 endp)
7882 ;; If the buffer is empty, we have no article.
7883 (unless article
7884 (error "No article to select"))
7885 (gnus-configure-windows 'article)
7886 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7887 (if (and (eq gnus-summary-goto-unread 'never)
7888 (not (gnus-summary-last-article-p article)))
7889 (gnus-summary-next-article)
7890 (gnus-summary-next-unread-article))
7891 (if (or (null gnus-current-article)
7892 (null gnus-article-current)
7893 (/= article (cdr gnus-article-current))
7894 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7895 ;; Selected subject is different from current article's.
7896 (gnus-summary-display-article article)
7897 (when article-window
7898 (gnus-eval-in-buffer-window gnus-article-buffer
7899 (setq endp (or (gnus-article-next-page lines)
7900 (gnus-article-only-boring-p))))
7901 (when endp
7902 (cond ((or stop gnus-summary-stop-at-end-of-message)
7903 (gnus-message 3 "End of message"))
7904 (circular
7905 (gnus-summary-beginning-of-article))
7906 (lines
7907 (gnus-message 3 "End of message"))
7908 ((null lines)
7909 (if (and (eq gnus-summary-goto-unread 'never)
7910 (not (gnus-summary-last-article-p article)))
7911 (gnus-summary-next-article)
7912 (gnus-summary-next-unread-article))))))))
7913 (gnus-summary-recenter)
7914 (gnus-summary-position-point)))
7916 (defun gnus-summary-prev-page (&optional lines move)
7917 "Show previous page of selected article.
7918 Argument LINES specifies lines to be scrolled down.
7919 If MOVE, move to the previous unread article if point is at
7920 the beginning of the buffer."
7921 (interactive "P")
7922 (let ((article (gnus-summary-article-number))
7923 (article-window (get-buffer-window gnus-article-buffer t))
7924 endp)
7925 (gnus-configure-windows 'article)
7926 (if (or (null gnus-current-article)
7927 (null gnus-article-current)
7928 (/= article (cdr gnus-article-current))
7929 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7930 ;; Selected subject is different from current article's.
7931 (gnus-summary-display-article article)
7932 (gnus-summary-recenter)
7933 (when article-window
7934 (gnus-eval-in-buffer-window gnus-article-buffer
7935 (setq endp (gnus-article-prev-page lines)))
7936 (when (and move endp)
7937 (cond (lines
7938 (gnus-message 3 "Beginning of message"))
7939 ((null lines)
7940 (if (and (eq gnus-summary-goto-unread 'never)
7941 (not (gnus-summary-first-article-p article)))
7942 (gnus-summary-prev-article)
7943 (gnus-summary-prev-unread-article))))))))
7944 (gnus-summary-position-point))
7946 (defun gnus-summary-prev-page-or-article (&optional lines)
7947 "Show previous page of selected article.
7948 Argument LINES specifies lines to be scrolled down.
7949 If at the beginning of the article, go to the next article."
7950 (interactive "P")
7951 (gnus-summary-prev-page lines t))
7953 (defun gnus-summary-scroll-up (lines)
7954 "Scroll up (or down) one line current article.
7955 Argument LINES specifies lines to be scrolled up (or down if negative).
7956 If no article is selected, then the current article will be selected first."
7957 (interactive "p")
7958 (gnus-configure-windows 'article)
7959 (gnus-summary-show-thread)
7960 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7961 (gnus-eval-in-buffer-window gnus-article-buffer
7962 (cond ((> lines 0)
7963 (when (gnus-article-next-page lines)
7964 (gnus-message 3 "End of message")))
7965 ((< lines 0)
7966 (gnus-article-prev-page (- lines))))))
7967 (gnus-summary-recenter)
7968 (gnus-summary-position-point))
7970 (defun gnus-summary-scroll-down (lines)
7971 "Scroll down (or up) one line current article.
7972 Argument LINES specifies lines to be scrolled down (or up if negative).
7973 If no article is selected, then the current article will be selected first."
7974 (interactive "p")
7975 (gnus-summary-scroll-up (- lines)))
7977 (defun gnus-summary-next-same-subject ()
7978 "Select next article which has the same subject as current one."
7979 (interactive)
7980 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7982 (defun gnus-summary-prev-same-subject ()
7983 "Select previous article which has the same subject as current one."
7984 (interactive)
7985 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7987 (defun gnus-summary-next-unread-same-subject ()
7988 "Select next unread article which has the same subject as current one."
7989 (interactive)
7990 (gnus-summary-next-article t (gnus-summary-article-subject)))
7992 (defun gnus-summary-prev-unread-same-subject ()
7993 "Select previous unread article which has the same subject as current one."
7994 (interactive)
7995 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7997 (defun gnus-summary-first-unread-article ()
7998 "Select the first unread article.
7999 Return nil if there are no unread articles."
8000 (interactive)
8001 (prog1
8002 (when (gnus-summary-first-subject t)
8003 (gnus-summary-show-thread)
8004 (gnus-summary-first-subject t)
8005 (gnus-summary-display-article (gnus-summary-article-number)))
8006 (gnus-summary-position-point)))
8008 (defun gnus-summary-first-unread-subject ()
8009 "Place the point on the subject line of the first unread article.
8010 Return nil if there are no unread articles."
8011 (interactive)
8012 (prog1
8013 (when (gnus-summary-first-subject t)
8014 (gnus-summary-show-thread)
8015 (gnus-summary-first-subject t))
8016 (gnus-summary-position-point)))
8018 (defun gnus-summary-first-unseen-subject ()
8019 "Place the point on the subject line of the first unseen article.
8020 Return nil if there are no unseen articles."
8021 (interactive)
8022 (prog1
8023 (when (gnus-summary-first-subject nil nil t)
8024 (gnus-summary-show-thread)
8025 (gnus-summary-first-subject nil nil t))
8026 (gnus-summary-position-point)))
8028 (defun gnus-summary-first-unseen-or-unread-subject ()
8029 "Place the point on the subject line of the first unseen and unread article.
8030 If all article have been seen, on the subject line of the first unread
8031 article."
8032 (interactive)
8033 (prog1
8034 (unless (when (gnus-summary-first-subject nil nil t)
8035 (gnus-summary-show-thread)
8036 (gnus-summary-first-subject nil nil t))
8037 (when (gnus-summary-first-subject t)
8038 (gnus-summary-show-thread)
8039 (gnus-summary-first-subject t)))
8040 (gnus-summary-position-point)))
8042 (defun gnus-summary-first-article ()
8043 "Select the first article.
8044 Return nil if there are no articles."
8045 (interactive)
8046 (prog1
8047 (when (gnus-summary-first-subject)
8048 (gnus-summary-show-thread)
8049 (gnus-summary-first-subject)
8050 (gnus-summary-display-article (gnus-summary-article-number)))
8051 (gnus-summary-position-point)))
8053 (defun gnus-summary-best-unread-article (&optional arg)
8054 "Select the unread article with the highest score.
8055 If given a prefix argument, select the next unread article that has a
8056 score higher than the default score."
8057 (interactive "P")
8058 (let ((article (if arg
8059 (gnus-summary-better-unread-subject)
8060 (gnus-summary-best-unread-subject))))
8061 (if article
8062 (gnus-summary-goto-article article)
8063 (error "No unread articles"))))
8065 (defun gnus-summary-best-unread-subject ()
8066 "Select the unread subject with the highest score."
8067 (interactive)
8068 (let ((best -1000000)
8069 (data gnus-newsgroup-data)
8070 article score)
8071 (while data
8072 (and (gnus-data-unread-p (car data))
8073 (> (setq score
8074 (gnus-summary-article-score (gnus-data-number (car data))))
8075 best)
8076 (setq best score
8077 article (gnus-data-number (car data))))
8078 (setq data (cdr data)))
8079 (when article
8080 (gnus-summary-goto-subject article))
8081 (gnus-summary-position-point)
8082 article))
8084 (defun gnus-summary-better-unread-subject ()
8085 "Select the first unread subject that has a score over the default score."
8086 (interactive)
8087 (let ((data gnus-newsgroup-data)
8088 article score)
8089 (while (and (setq article (gnus-data-number (car data)))
8090 (or (gnus-data-read-p (car data))
8091 (not (> (gnus-summary-article-score article)
8092 gnus-summary-default-score))))
8093 (setq data (cdr data)))
8094 (when article
8095 (gnus-summary-goto-subject article))
8096 (gnus-summary-position-point)
8097 article))
8099 (defun gnus-summary-last-subject ()
8100 "Go to the last displayed subject line in the group."
8101 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8102 (when article
8103 (gnus-summary-goto-subject article))))
8105 (defun gnus-summary-goto-article (article &optional all-headers force)
8106 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8107 If ALL-HEADERS is non-nil, no header lines are hidden.
8108 If FORCE, go to the article even if it isn't displayed. If FORCE
8109 is a number, it is the line the article is to be displayed on."
8110 (interactive
8111 (list
8112 (gnus-completing-read
8113 "Article number or Message-ID"
8114 (mapcar 'int-to-string gnus-newsgroup-limit))
8115 current-prefix-arg
8117 (prog1
8118 (if (and (stringp article)
8119 (string-match "@\\|%40" article))
8120 (gnus-summary-refer-article article)
8121 (when (stringp article)
8122 (setq article (string-to-number article)))
8123 (if (gnus-summary-goto-subject article force)
8124 (gnus-summary-display-article article all-headers)
8125 (gnus-message 4 "Couldn't go to article %s" article) nil))
8126 (gnus-summary-position-point)))
8128 (defun gnus-summary-goto-last-article ()
8129 "Go to the previously read article."
8130 (interactive)
8131 (prog1
8132 (when gnus-last-article
8133 (gnus-summary-goto-article gnus-last-article nil t))
8134 (gnus-summary-position-point)))
8136 (defun gnus-summary-pop-article (number)
8137 "Pop one article off the history and go to the previous.
8138 NUMBER articles will be popped off."
8139 (interactive "p")
8140 (let (to)
8141 (setq gnus-newsgroup-history
8142 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8143 (if to
8144 (gnus-summary-goto-article (car to) nil t)
8145 (error "Article history empty")))
8146 (gnus-summary-position-point))
8148 ;; Summary commands and functions for limiting the summary buffer.
8150 (defun gnus-summary-limit-to-articles (n)
8151 "Limit the summary buffer to the next N articles.
8152 If not given a prefix, use the process marked articles instead."
8153 (interactive "P")
8154 (prog1
8155 (let ((articles (gnus-summary-work-articles n)))
8156 (setq gnus-newsgroup-processable nil)
8157 (gnus-summary-limit articles))
8158 (gnus-summary-position-point)))
8160 (defun gnus-summary-pop-limit (&optional total)
8161 "Restore the previous limit.
8162 If given a prefix, remove all limits."
8163 (interactive "P")
8164 (when total
8165 (setq gnus-newsgroup-limits
8166 (list (mapcar (lambda (h) (mail-header-number h))
8167 gnus-newsgroup-headers))))
8168 (unless gnus-newsgroup-limits
8169 (error "No limit to pop"))
8170 (prog1
8171 (gnus-summary-limit nil 'pop)
8172 (gnus-summary-position-point)))
8174 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8175 "Limit the summary buffer to articles that have subjects that match a regexp.
8176 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8177 (interactive
8178 (list (read-string (if current-prefix-arg
8179 "Exclude subject (regexp): "
8180 "Limit to subject (regexp): "))
8181 nil current-prefix-arg))
8182 (unless header
8183 (setq header "subject"))
8184 (when (not (equal "" subject))
8185 (prog1
8186 (let ((articles (gnus-summary-find-matching
8187 (or header "subject") subject 'all nil nil
8188 not-matching)))
8189 (unless articles
8190 (error "Found no matches for \"%s\"" subject))
8191 (gnus-summary-limit articles))
8192 (gnus-summary-position-point))))
8194 (defun gnus-summary-limit-to-author (from &optional not-matching)
8195 "Limit the summary buffer to articles that have authors that match a regexp.
8196 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8197 (interactive
8198 (list (let* ((header (gnus-summary-article-header))
8199 (default (and header (car (mail-header-parse-address
8200 (mail-header-from header))))))
8201 (read-string (concat (if current-prefix-arg
8202 "Exclude author (regexp"
8203 "Limit to author (regexp")
8204 (if default
8205 (concat ", default \"" default "\"): ")
8206 "): "))
8207 nil nil
8208 default))
8209 current-prefix-arg))
8210 (gnus-summary-limit-to-subject from "from" not-matching))
8212 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8213 "Limit the summary buffer to articles with the given RECIPIENT.
8215 If NOT-MATCHING, exclude RECIPIENT.
8217 To and Cc headers are checked. You need to include them in
8218 `nnmail-extra-headers'."
8219 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8220 (interactive
8221 (list (read-string (format "%s recipient (regexp): "
8222 (if current-prefix-arg "Exclude" "Limit to")))
8223 current-prefix-arg))
8224 (when (not (equal "" recipient))
8225 (prog1 (let* ((to
8226 (if (memq 'To nnmail-extra-headers)
8227 (gnus-summary-find-matching
8228 (cons 'extra 'To) recipient 'all nil nil
8229 not-matching)
8230 (gnus-message
8231 1 "`To' isn't present in `nnmail-extra-headers'")
8232 (sit-for 1)
8233 nil))
8235 (if (memq 'Cc nnmail-extra-headers)
8236 (gnus-summary-find-matching
8237 (cons 'extra 'Cc) recipient 'all nil nil
8238 not-matching)
8239 (gnus-message
8240 1 "`Cc' isn't present in `nnmail-extra-headers'")
8241 (sit-for 1)
8242 nil))
8243 (articles
8244 (if not-matching
8245 ;; We need the numbers that are in both lists:
8246 (mapcar (lambda (a)
8247 (and (memq a to) a))
8249 (nconc to cc))))
8250 (unless articles
8251 (error "Found no matches for \"%s\"" recipient))
8252 (gnus-summary-limit articles))
8253 (gnus-summary-position-point))))
8255 (defun gnus-summary-limit-to-address (address &optional not-matching)
8256 "Limit the summary buffer to articles with the given ADDRESS.
8258 If NOT-MATCHING, exclude ADDRESS.
8260 To, Cc and From headers are checked. You need to include `To' and `Cc'
8261 in `nnmail-extra-headers'."
8262 (interactive
8263 (list (read-string (format "%s address (regexp): "
8264 (if current-prefix-arg "Exclude" "Limit to")))
8265 current-prefix-arg))
8266 (when (not (equal "" address))
8267 (prog1 (let* ((to
8268 (if (memq 'To nnmail-extra-headers)
8269 (gnus-summary-find-matching
8270 (cons 'extra 'To) address 'all nil nil
8271 not-matching)
8272 (gnus-message
8273 1 "`To' isn't present in `nnmail-extra-headers'")
8274 (sit-for 1)
8277 (if (memq 'Cc nnmail-extra-headers)
8278 (gnus-summary-find-matching
8279 (cons 'extra 'Cc) address 'all nil nil
8280 not-matching)
8281 (gnus-message
8282 1 "`Cc' isn't present in `nnmail-extra-headers'")
8283 (sit-for 1)
8285 (from
8286 (gnus-summary-find-matching "from" address
8287 'all nil nil not-matching))
8288 (articles
8289 (if not-matching
8290 ;; We need the numbers that are in all lists:
8291 (if (eq cc t)
8292 (if (eq to t)
8293 from
8294 (mapcar (lambda (a) (car (memq a from))) to))
8295 (if (eq to t)
8296 (mapcar (lambda (a) (car (memq a from))) cc)
8297 (mapcar (lambda (a) (car (memq a from)))
8298 (mapcar (lambda (a) (car (memq a to)))
8299 cc))))
8300 (nconc (if (eq to t) nil to)
8301 (if (eq cc t) nil cc)
8302 from))))
8303 (unless articles
8304 (error "Found no matches for \"%s\"" address))
8305 (gnus-summary-limit articles))
8306 (gnus-summary-position-point))))
8308 (defun gnus-summary-limit-strange-charsets-predicate (header)
8309 (when (fboundp 'char-charset)
8310 (let ((string (concat (mail-header-subject header)
8311 (mail-header-from header)))
8312 charset found)
8313 (dotimes (i (1- (length string)))
8314 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8315 (when (string-match "unicode\\|big\\|japanese" charset)
8316 (setq found t)))
8317 found)))
8319 (defun gnus-summary-limit-to-predicate (predicate)
8320 "Limit to articles where PREDICATE returns non-nil.
8321 PREDICATE will be called with the header structures of the
8322 articles."
8323 (let ((articles nil)
8324 (case-fold-search t))
8325 (dolist (header gnus-newsgroup-headers)
8326 (when (funcall predicate header)
8327 (push (mail-header-number header) articles)))
8328 (gnus-summary-limit (nreverse articles))))
8330 (defun gnus-summary-limit-to-age (age &optional younger-p)
8331 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8332 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8333 articles that are younger than AGE days."
8334 (interactive
8335 (let ((younger current-prefix-arg)
8336 (days-got nil)
8337 days)
8338 (while (not days-got)
8339 (setq days (if younger
8340 (read-string "Limit to articles younger than (in days, older when negative): ")
8341 (read-string
8342 "Limit to articles older than (in days, younger when negative): ")))
8343 (when (> (length days) 0)
8344 (setq days (read days)))
8345 (if (numberp days)
8346 (progn
8347 (setq days-got t)
8348 (when (< days 0)
8349 (setq younger (not younger))
8350 (setq days (* days -1))))
8351 (message "Please enter a number.")
8352 (sleep-for 1)))
8353 (list days younger)))
8354 (prog1
8355 (let ((data gnus-newsgroup-data)
8356 (cutoff (days-to-time age))
8357 articles d date is-younger)
8358 (while (setq d (pop data))
8359 (when (and (vectorp (gnus-data-header d))
8360 (setq date (mail-header-date (gnus-data-header d))))
8361 (setq is-younger (time-less-p
8362 (time-since (gnus-date-get-time date))
8363 cutoff))
8364 (when (if younger-p
8365 is-younger
8366 (not is-younger))
8367 (push (gnus-data-number d) articles))))
8368 (gnus-summary-limit (nreverse articles)))
8369 (gnus-summary-position-point)))
8371 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8372 "Limit the summary buffer to articles that match an 'extra' header."
8373 (interactive
8374 (let ((header
8375 (intern
8376 (gnus-completing-read
8377 (if current-prefix-arg
8378 "Exclude extra header"
8379 "Limit extra header")
8380 (mapcar 'symbol-name gnus-extra-headers)
8381 t nil nil
8382 (symbol-name (car gnus-extra-headers))))))
8383 (list header
8384 (read-string (format "%s header %s (regexp): "
8385 (if current-prefix-arg "Exclude" "Limit to")
8386 header))
8387 current-prefix-arg)))
8388 (when (not (equal "" regexp))
8389 (prog1
8390 (let ((articles (gnus-summary-find-matching
8391 (cons 'extra header) regexp 'all nil nil
8392 not-matching)))
8393 (unless articles
8394 (error "Found no matches for \"%s\"" regexp))
8395 (gnus-summary-limit articles))
8396 (gnus-summary-position-point))))
8398 (defun gnus-summary-limit-to-display-predicate ()
8399 "Limit the summary buffer to the predicated in the `display' group parameter."
8400 (interactive)
8401 (unless gnus-newsgroup-display
8402 (error "There is no `display' group parameter"))
8403 (let (articles)
8404 (dolist (gnus-number gnus-newsgroup-articles)
8405 (when (funcall gnus-newsgroup-display)
8406 (push gnus-number articles)))
8407 (gnus-summary-limit articles))
8408 (gnus-summary-position-point))
8410 (defun gnus-summary-limit-to-unread (&optional all)
8411 "Limit the summary buffer to articles that are not marked as read.
8412 If ALL is non-nil, limit strictly to unread articles."
8413 (interactive "P")
8414 (if all
8415 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8416 (gnus-summary-limit-to-marks
8417 ;; Concat all the marks that say that an article is read and have
8418 ;; those removed.
8419 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8420 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8421 gnus-low-score-mark gnus-expirable-mark
8422 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8423 gnus-duplicate-mark)
8424 'reverse)))
8426 (defun gnus-summary-limit-to-headers (match &optional reverse)
8427 "Limit the summary buffer to articles that have headers that match MATCH.
8428 If REVERSE (the prefix), limit to articles that don't match."
8429 (interactive "sMatch headers (regexp): \nP")
8430 (gnus-summary-limit-to-bodies match reverse t))
8432 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8433 "Limit the summary buffer to articles that have bodies that match MATCH.
8434 If REVERSE (the prefix), limit to articles that don't match."
8435 (interactive "sMatch body (regexp): \nP")
8436 (let ((articles nil)
8437 (gnus-select-article-hook nil) ;Disable hook.
8438 (gnus-article-prepare-hook nil)
8439 (gnus-use-article-prefetch nil)
8440 (gnus-keep-backlog nil)
8441 (gnus-break-pages nil)
8442 (gnus-summary-display-arrow nil)
8443 (gnus-updated-mode-lines nil)
8444 (gnus-auto-center-summary nil)
8445 (gnus-display-mime-function nil))
8446 (dolist (data gnus-newsgroup-data)
8447 (let (gnus-mark-article-hook)
8448 (gnus-summary-select-article t t nil (gnus-data-number data)))
8449 (with-current-buffer gnus-article-buffer
8450 (article-goto-body)
8451 (let* ((case-fold-search t)
8452 (found (if headersp
8453 (re-search-backward match nil t)
8454 (re-search-forward match nil t))))
8455 (when (or (and found
8456 (not reverse))
8457 (and (not found)
8458 reverse))
8459 (push (gnus-data-number data) articles)))))
8460 (if (not articles)
8461 (message "No messages matched")
8462 (gnus-summary-limit articles)))
8463 (gnus-summary-position-point))
8465 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8466 "Limit the summary buffer to articles that aren't part on any thread.
8467 If THREADSP (the prefix), limit to articles that are in threads."
8468 (interactive "P")
8469 (let ((articles nil)
8470 thread-articles
8471 threads)
8472 (dolist (thread gnus-newsgroup-threads)
8473 (if (stringp (car thread))
8474 (dolist (thread (cdr thread))
8475 (push thread threads))
8476 (push thread threads)))
8477 (dolist (thread threads)
8478 (setq thread-articles (gnus-articles-in-thread thread))
8479 (when (or (and threadsp
8480 (> (length thread-articles) 1))
8481 (and (not threadsp)
8482 (= (length thread-articles) 1)))
8483 (setq articles (nconc thread-articles articles))))
8484 (if (not articles)
8485 (message "No messages matched")
8486 (gnus-summary-limit articles))
8487 (gnus-summary-position-point)))
8489 (defun gnus-summary-limit-to-replied (&optional unreplied)
8490 "Limit the summary buffer to replied articles.
8491 If UNREPLIED (the prefix), limit to unreplied articles."
8492 (interactive "P")
8493 (if unreplied
8494 (gnus-summary-limit
8495 (gnus-set-difference gnus-newsgroup-articles
8496 gnus-newsgroup-replied))
8497 (gnus-summary-limit gnus-newsgroup-replied))
8498 (gnus-summary-position-point))
8500 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8501 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8502 If REVERSE, limit the summary buffer to articles that are marked
8503 with MARKS. MARKS can either be a string of marks or a list of marks.
8504 Returns how many articles were removed."
8505 (interactive "sMarks: ")
8506 (gnus-summary-limit-to-marks marks t))
8508 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8509 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8510 If REVERSE (the prefix), limit the summary buffer to articles that are
8511 not marked with MARKS. MARKS can either be a string of marks or a
8512 list of marks.
8513 Returns how many articles were removed."
8514 (interactive "sMarks: \nP")
8515 (prog1
8516 (let ((data gnus-newsgroup-data)
8517 (marks (if (listp marks) marks
8518 (append marks nil))) ; Transform to list.
8519 articles)
8520 (while data
8521 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8522 (memq (gnus-data-mark (car data)) marks))
8523 (push (gnus-data-number (car data)) articles))
8524 (setq data (cdr data)))
8525 (gnus-summary-limit articles))
8526 (gnus-summary-position-point)))
8528 (defun gnus-summary-limit-to-score (score)
8529 "Limit to articles with score at or above SCORE."
8530 (interactive "NLimit to articles with score of at least: ")
8531 (let ((data gnus-newsgroup-data)
8532 articles)
8533 (while data
8534 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8535 score)
8536 (push (gnus-data-number (car data)) articles))
8537 (setq data (cdr data)))
8538 (prog1
8539 (gnus-summary-limit articles)
8540 (gnus-summary-position-point))))
8542 (defun gnus-summary-limit-to-unseen ()
8543 "Limit to unseen articles."
8544 (interactive)
8545 (prog1
8546 (gnus-summary-limit gnus-newsgroup-unseen)
8547 (gnus-summary-position-point)))
8549 (defun gnus-summary-limit-include-thread (id)
8550 "Display all the hidden articles that is in the thread with ID in it.
8551 When called interactively, ID is the Message-ID of the current
8552 article."
8553 (interactive (list (mail-header-id (gnus-summary-article-header))))
8554 (let ((articles (gnus-articles-in-thread
8555 (gnus-id-to-thread (gnus-root-id id))))
8556 ;;we REALLY want the whole thread---this prevents cut-threads
8557 ;;from removing the thread we want to include.
8558 (gnus-fetch-old-headers nil)
8559 (gnus-build-sparse-threads nil))
8560 (prog1
8561 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8562 (gnus-summary-limit-include-matching-articles
8563 "subject"
8564 (regexp-quote (gnus-simplify-subject-re
8565 (mail-header-subject (gnus-id-to-header id)))))
8566 (gnus-summary-position-point))))
8568 (defun gnus-summary-limit-include-matching-articles (header regexp)
8569 "Display all the hidden articles that have HEADERs that match REGEXP."
8570 (interactive (list (read-string "Match on header: ")
8571 (read-string "Regexp: ")))
8572 (let ((articles (gnus-find-matching-articles header regexp)))
8573 (prog1
8574 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8575 (gnus-summary-position-point))))
8577 (defun gnus-summary-insert-dormant-articles ()
8578 "Insert all the dormant articles for this group into the current buffer."
8579 (interactive)
8580 (let ((gnus-verbose (max 6 gnus-verbose)))
8581 (if (not gnus-newsgroup-dormant)
8582 (gnus-message 3 "No dormant articles for this group")
8583 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8585 (defun gnus-summary-insert-ticked-articles ()
8586 "Insert ticked articles for this group into the current buffer."
8587 (interactive)
8588 (let ((gnus-verbose (max 6 gnus-verbose)))
8589 (if (not gnus-newsgroup-marked)
8590 (gnus-message 3 "No ticked articles for this group")
8591 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8593 (defun gnus-summary-limit-include-dormant ()
8594 "Display all the hidden articles that are marked as dormant.
8595 Note that this command only works on a subset of the articles currently
8596 fetched for this group."
8597 (interactive)
8598 (unless gnus-newsgroup-dormant
8599 (error "There are no dormant articles in this group"))
8600 (prog1
8601 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8602 (gnus-summary-position-point)))
8604 (defun gnus-summary-include-articles (articles)
8605 "Fetch the headers for ARTICLES and then display the summary lines."
8606 (let ((gnus-inhibit-demon t)
8607 (gnus-agent nil)
8608 (gnus-read-all-available-headers t))
8609 (setq gnus-newsgroup-headers
8610 (gnus-merge
8611 'list gnus-newsgroup-headers
8612 (gnus-fetch-headers articles nil t)
8613 'gnus-article-sort-by-number))
8614 (setq gnus-newsgroup-articles
8615 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8616 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8618 (defun gnus-summary-limit-exclude-dormant ()
8619 "Hide all dormant articles."
8620 (interactive)
8621 (prog1
8622 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8623 (gnus-summary-position-point)))
8625 (defun gnus-summary-limit-exclude-childless-dormant ()
8626 "Hide all dormant articles that have no children."
8627 (interactive)
8628 (let ((data (gnus-data-list t))
8629 articles d children)
8630 ;; Find all articles that are either not dormant or have
8631 ;; children.
8632 (while (setq d (pop data))
8633 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8634 (and (setq children
8635 (gnus-article-children (gnus-data-number d)))
8636 (let (found)
8637 (while children
8638 (when (memq (car children) articles)
8639 (setq children nil
8640 found t))
8641 (pop children))
8642 found)))
8643 (push (gnus-data-number d) articles)))
8644 ;; Do the limiting.
8645 (prog1
8646 (gnus-summary-limit articles)
8647 (gnus-summary-position-point))))
8649 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8650 "Mark all unread excluded articles as read.
8651 If ALL, mark even excluded ticked and dormants as read."
8652 (interactive "P")
8653 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8654 (let ((articles (gnus-sorted-ndifference
8655 (sort
8656 (mapcar (lambda (h) (mail-header-number h))
8657 gnus-newsgroup-headers)
8659 gnus-newsgroup-limit))
8660 article)
8661 (setq gnus-newsgroup-unreads
8662 (gnus-sorted-intersection gnus-newsgroup-unreads
8663 gnus-newsgroup-limit))
8664 (if all
8665 (setq gnus-newsgroup-dormant nil
8666 gnus-newsgroup-marked nil
8667 gnus-newsgroup-reads
8668 (nconc
8669 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8670 gnus-newsgroup-reads))
8671 (while (setq article (pop articles))
8672 (unless (or (memq article gnus-newsgroup-dormant)
8673 (memq article gnus-newsgroup-marked))
8674 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8676 (defun gnus-summary-limit (articles &optional pop)
8677 (if pop
8678 ;; We pop the previous limit off the stack and use that.
8679 (setq articles (car gnus-newsgroup-limits)
8680 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8681 ;; We use the new limit, so we push the old limit on the stack.
8682 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8683 ;; Set the limit.
8684 (setq gnus-newsgroup-limit articles)
8685 (let ((total (length gnus-newsgroup-data))
8686 (data (gnus-data-find-list (gnus-summary-article-number)))
8687 (gnus-summary-mark-below nil) ; Inhibit this.
8688 found)
8689 ;; This will do all the work of generating the new summary buffer
8690 ;; according to the new limit.
8691 (gnus-summary-prepare)
8692 ;; Hide any threads, possibly.
8693 (gnus-summary-maybe-hide-threads)
8694 ;; Try to return to the article you were at, or one in the
8695 ;; neighborhood.
8696 (when data
8697 ;; We try to find some article after the current one.
8698 (while data
8699 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8700 (setq data nil
8701 found t))
8702 (setq data (cdr data))))
8703 (unless found
8704 ;; If there is no data, that means that we were after the last
8705 ;; article. The same goes when we can't find any articles
8706 ;; after the current one.
8707 (goto-char (point-max))
8708 (gnus-summary-find-prev))
8709 (gnus-set-mode-line 'summary)
8710 ;; We return how many articles were removed from the summary
8711 ;; buffer as a result of the new limit.
8712 (- total (length gnus-newsgroup-data))))
8714 (defsubst gnus-invisible-cut-children (threads)
8715 (let ((num 0))
8716 (while threads
8717 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8718 (incf num))
8719 (pop threads))
8720 (< num 2)))
8722 (defsubst gnus-cut-thread (thread)
8723 "Go forwards in the thread until we find an article that we want to display."
8724 (when (or (eq gnus-fetch-old-headers 'some)
8725 (eq gnus-fetch-old-headers 'invisible)
8726 (numberp gnus-fetch-old-headers)
8727 (eq gnus-build-sparse-threads 'some)
8728 (eq gnus-build-sparse-threads 'more))
8729 ;; Deal with old-fetched headers and sparse threads.
8730 (while (and
8731 thread
8733 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8734 (gnus-summary-article-ancient-p
8735 (mail-header-number (car thread))))
8736 (if (or (<= (length (cdr thread)) 1)
8737 (eq gnus-fetch-old-headers 'invisible))
8738 (setq gnus-newsgroup-limit
8739 (delq (mail-header-number (car thread))
8740 gnus-newsgroup-limit)
8741 thread (cadr thread))
8742 (when (gnus-invisible-cut-children (cdr thread))
8743 (let ((th (cdr thread)))
8744 (while th
8745 (if (memq (mail-header-number (caar th))
8746 gnus-newsgroup-limit)
8747 (setq thread (car th)
8748 th nil)
8749 (setq th (cdr th))))))))))
8750 thread)
8752 (defun gnus-cut-threads (threads)
8753 "Cut off all uninteresting articles from the beginning of THREADS."
8754 (when (or (eq gnus-fetch-old-headers 'some)
8755 (eq gnus-fetch-old-headers 'invisible)
8756 (numberp gnus-fetch-old-headers)
8757 (eq gnus-build-sparse-threads 'some)
8758 (eq gnus-build-sparse-threads 'more))
8759 (let ((th threads))
8760 (while th
8761 (setcar th (gnus-cut-thread (car th)))
8762 (setq th (cdr th)))))
8763 ;; Remove nixed out threads.
8764 (delq nil threads))
8766 (defun gnus-summary-initial-limit (&optional show-if-empty)
8767 "Figure out what the initial limit is supposed to be on group entry.
8768 This entails weeding out unwanted dormants, low-scored articles,
8769 fetch-old-headers verbiage, and so on."
8770 ;; Most groups have nothing to remove.
8771 (unless (or gnus-inhibit-limiting
8772 (and (null gnus-newsgroup-dormant)
8773 (eq gnus-newsgroup-display 'gnus-not-ignore)
8774 (not (eq gnus-fetch-old-headers 'some))
8775 (not (numberp gnus-fetch-old-headers))
8776 (not (eq gnus-fetch-old-headers 'invisible))
8777 (null gnus-summary-expunge-below)
8778 (not (eq gnus-build-sparse-threads 'some))
8779 (not (eq gnus-build-sparse-threads 'more))
8780 (null gnus-thread-expunge-below)))
8781 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8782 (setq gnus-newsgroup-limit nil)
8783 (mapatoms
8784 (lambda (node)
8785 (unless (car (symbol-value node))
8786 ;; These threads have no parents -- they are roots.
8787 (let ((nodes (cdr (symbol-value node)))
8788 thread)
8789 (while nodes
8790 (if (and gnus-thread-expunge-below
8791 (< (gnus-thread-total-score (car nodes))
8792 gnus-thread-expunge-below))
8793 (gnus-expunge-thread (pop nodes))
8794 (setq thread (pop nodes))
8795 (gnus-summary-limit-children thread))))))
8796 gnus-newsgroup-dependencies)
8797 ;; If this limitation resulted in an empty group, we might
8798 ;; pop the previous limit and use it instead.
8799 (when (and (not gnus-newsgroup-limit)
8800 show-if-empty)
8801 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8802 gnus-newsgroup-limit))
8804 (defun gnus-summary-limit-children (thread)
8805 "Return 1 if this subthread is visible and 0 if it is not."
8806 ;; First we get the number of visible children to this thread. This
8807 ;; is done by recursing down the thread using this function, so this
8808 ;; will really go down to a leaf article first, before slowly
8809 ;; working its way up towards the root.
8810 (when thread
8811 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8812 (children
8813 (if (cdr thread)
8814 (apply '+ (mapcar 'gnus-summary-limit-children
8815 (cdr thread)))
8817 (number (mail-header-number (car thread)))
8818 score)
8819 (if (and
8820 (not (memq number gnus-newsgroup-marked))
8822 ;; If this article is dormant and has absolutely no visible
8823 ;; children, then this article isn't visible.
8824 (and (memq number gnus-newsgroup-dormant)
8825 (zerop children))
8826 ;; If this is "fetch-old-headered" and there is no
8827 ;; visible children, then we don't want this article.
8828 (and (or (eq gnus-fetch-old-headers 'some)
8829 (numberp gnus-fetch-old-headers))
8830 (gnus-summary-article-ancient-p number)
8831 (zerop children))
8832 ;; If this is "fetch-old-headered" and `invisible', then
8833 ;; we don't want this article.
8834 (and (eq gnus-fetch-old-headers 'invisible)
8835 (gnus-summary-article-ancient-p number))
8836 ;; If this is a sparsely inserted article with no children,
8837 ;; we don't want it.
8838 (and (eq gnus-build-sparse-threads 'some)
8839 (gnus-summary-article-sparse-p number)
8840 (zerop children))
8841 ;; If we use expunging, and this article is really
8842 ;; low-scored, then we don't want this article.
8843 (when (and gnus-summary-expunge-below
8844 (< (setq score
8845 (or (cdr (assq number gnus-newsgroup-scored))
8846 gnus-summary-default-score))
8847 gnus-summary-expunge-below))
8848 ;; We increase the expunge-tally here, but that has
8849 ;; nothing to do with the limits, really.
8850 (incf gnus-newsgroup-expunged-tally)
8851 ;; We also mark as read here, if that's wanted.
8852 (when (and gnus-summary-mark-below
8853 (< score gnus-summary-mark-below))
8854 (setq gnus-newsgroup-unreads
8855 (delq number gnus-newsgroup-unreads))
8856 (if gnus-newsgroup-auto-expire
8857 (push number gnus-newsgroup-expirable)
8858 (push (cons number gnus-low-score-mark)
8859 gnus-newsgroup-reads)))
8861 ;; Do the `display' group parameter.
8862 (and gnus-newsgroup-display
8863 (let ((gnus-number number))
8864 (not (funcall gnus-newsgroup-display))))))
8865 ;; Nope, invisible article.
8867 ;; Ok, this article is to be visible, so we add it to the limit
8868 ;; and return 1.
8869 (push number gnus-newsgroup-limit)
8870 1))))
8872 (defun gnus-expunge-thread (thread)
8873 "Mark all articles in THREAD as read."
8874 (let* ((number (mail-header-number (car thread))))
8875 (incf gnus-newsgroup-expunged-tally)
8876 ;; We also mark as read here, if that's wanted.
8877 (setq gnus-newsgroup-unreads
8878 (delq number gnus-newsgroup-unreads))
8879 (if gnus-newsgroup-auto-expire
8880 (push number gnus-newsgroup-expirable)
8881 (push (cons number gnus-low-score-mark)
8882 gnus-newsgroup-reads)))
8883 ;; Go recursively through all subthreads.
8884 (mapcar 'gnus-expunge-thread (cdr thread)))
8886 ;; Summary article oriented commands
8888 (defun gnus-summary-refer-parent-article (n)
8889 "Refer parent article N times.
8890 If N is negative, go to ancestor -N instead.
8891 The difference between N and the number of articles fetched is returned."
8892 (interactive "p")
8893 (let ((skip 1)
8894 error header ref)
8895 (when (not (natnump n))
8896 (setq skip (abs n)
8897 n 1))
8898 (while (and (> n 0)
8899 (not error))
8900 (setq header (gnus-summary-article-header))
8901 (if (and (eq (mail-header-number header)
8902 (cdr gnus-article-current))
8903 (equal gnus-newsgroup-name
8904 (car gnus-article-current)))
8905 ;; If we try to find the parent of the currently
8906 ;; displayed article, then we take a look at the actual
8907 ;; References header, since this is slightly more
8908 ;; reliable than the References field we got from the
8909 ;; server.
8910 (with-current-buffer gnus-original-article-buffer
8911 (nnheader-narrow-to-headers)
8912 (unless (setq ref (message-fetch-field "references"))
8913 (when (setq ref (message-fetch-field "in-reply-to"))
8914 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8915 (widen))
8916 (setq ref
8917 ;; It's not the current article, so we take a bet on
8918 ;; the value we got from the server.
8919 (mail-header-references header)))
8920 (if (and ref
8921 (not (equal ref "")))
8922 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8923 (gnus-message 1 "Couldn't find parent"))
8924 (gnus-message 1 "No references in article %d"
8925 (gnus-summary-article-number))
8926 (setq error t))
8927 (decf n))
8928 (gnus-summary-position-point)
8931 (defun gnus-summary-refer-references ()
8932 "Fetch all articles mentioned in the References header.
8933 Return the number of articles fetched."
8934 (interactive)
8935 (let ((ref (mail-header-references (gnus-summary-article-header)))
8936 (current (gnus-summary-article-number))
8937 (n 0))
8938 (if (or (not ref)
8939 (equal ref ""))
8940 (error "No References in the current article")
8941 ;; For each Message-ID in the References header...
8942 (while (string-match "<[^>]*>" ref)
8943 (incf n)
8944 ;; ... fetch that article.
8945 (gnus-summary-refer-article
8946 (prog1 (match-string 0 ref)
8947 (setq ref (substring ref (match-end 0))))))
8948 (gnus-summary-goto-subject current)
8949 (gnus-summary-position-point)
8950 n)))
8952 (defun gnus-delete-duplicate-headers (headers)
8953 ;; First remove leading duplicates.
8954 (while (and (> (length headers) 1)
8955 (= (mail-header-number (car headers))
8956 (mail-header-number (cadr headers))))
8957 (pop headers))
8958 ;; Then the rest.
8959 (let ((result headers))
8960 (while (> (length headers) 1)
8961 (if (= (mail-header-number (car headers))
8962 (mail-header-number (cadr headers)))
8963 (setcdr headers (cddr headers))
8964 (pop headers)))
8965 result))
8967 (defun gnus-summary-refer-thread (&optional limit)
8968 "Fetch all articles in the current thread. For backends that
8969 know how to search for threads (currently only 'nnimap) a
8970 non-numeric prefix arg will use nnir to search the entire
8971 server; without a prefix arg only the current group is
8972 searched. If the variable `gnus-refer-thread-use-nnir' is
8973 non-nil the prefix arg has the reverse meaning. If no
8974 backend-specific 'request-thread function is available fetch
8975 LIMIT (the numerical prefix) old headers. If LIMIT is
8976 non-numeric or nil fetch the number specified by the
8977 `gnus-refer-thread-limit' variable."
8978 (interactive "P")
8979 (gnus-warp-to-article)
8980 (let* ((header (gnus-summary-article-header))
8981 (id (mail-header-id header))
8982 (gnus-inhibit-demon t)
8983 (gnus-summary-ignore-duplicates t)
8984 (gnus-read-all-available-headers t)
8985 (gnus-refer-thread-use-nnir
8986 (if (and (not (null limit)) (listp limit))
8987 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
8988 (new-headers
8989 (if (gnus-check-backend-function
8990 'request-thread gnus-newsgroup-name)
8991 (gnus-request-thread header gnus-newsgroup-name)
8992 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
8993 gnus-refer-thread-limit))
8994 (last (if (numberp limit)
8995 (min (+ (mail-header-number header)
8996 limit)
8997 gnus-newsgroup-highest)
8998 gnus-newsgroup-highest))
8999 (subject (gnus-simplify-subject
9000 (mail-header-subject header)))
9001 (refs (split-string (or (mail-header-references header)
9002 "")))
9003 (gnus-parse-headers-hook
9004 `(lambda () (goto-char (point-min))
9005 (keep-lines
9006 (regexp-opt ',(append refs (list id subject)))))))
9007 (gnus-fetch-headers (list last) (if (numberp limit)
9008 (* 2 limit) limit) t))))
9009 article-ids)
9010 (when (listp new-headers)
9011 (dolist (header new-headers)
9012 (push (mail-header-number header) article-ids)
9013 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9014 (push (mail-header-number header) gnus-newsgroup-unreads)
9015 (setq gnus-newsgroup-unselected
9016 (delete (mail-header-number header)
9017 gnus-newsgroup-unselected))))
9018 (setq gnus-newsgroup-headers
9019 (gnus-delete-duplicate-headers
9020 (gnus-merge
9021 'list gnus-newsgroup-headers new-headers
9022 'gnus-article-sort-by-number)))
9023 (setq gnus-newsgroup-articles
9024 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9025 (gnus-summary-limit-include-thread id)))
9026 (gnus-summary-show-thread))
9028 (defun gnus-summary-refer-article (message-id)
9029 "Fetch an article specified by MESSAGE-ID."
9030 (interactive "sMessage-ID: ")
9031 (gnus-warp-to-article)
9032 (when (and (stringp message-id)
9033 (not (zerop (length message-id))))
9034 (setq message-id (gnus-replace-in-string message-id " " ""))
9035 ;; Construct the correct Message-ID if necessary.
9036 ;; Suggested by tale@pawl.rpi.edu.
9037 (unless (string-match "^<" message-id)
9038 (setq message-id (concat "<" message-id)))
9039 (unless (string-match ">$" message-id)
9040 (setq message-id (concat message-id ">")))
9041 ;; People often post MIDs from URLs, so unhex it:
9042 (unless (string-match "@" message-id)
9043 (setq message-id (gnus-url-unhex-string message-id)))
9044 (let* ((header (gnus-id-to-header message-id))
9045 (sparse (and header
9046 (gnus-summary-article-sparse-p
9047 (mail-header-number header))
9048 (memq (mail-header-number header)
9049 gnus-newsgroup-limit)))
9050 number)
9051 (cond
9052 ;; If the article is present in the buffer we just go to it.
9053 ((and header
9054 (or (not (gnus-summary-article-sparse-p
9055 (mail-header-number header)))
9056 sparse))
9057 (prog1
9058 (gnus-summary-goto-article
9059 (mail-header-number header) nil t)
9060 (when sparse
9061 (gnus-summary-update-article (mail-header-number header)))))
9063 ;; We fetch the article.
9064 (catch 'found
9065 (dolist (gnus-override-method (gnus-refer-article-methods))
9066 (when (and (gnus-check-server gnus-override-method)
9067 ;; Fetch the header,
9068 (setq number (gnus-summary-insert-subject message-id)))
9069 ;; and display the article.
9070 (gnus-summary-select-article nil nil nil number)
9071 (throw 'found t)))
9072 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9074 (defun gnus-refer-article-methods ()
9075 "Return a list of referable methods."
9076 (cond
9077 ;; No method, so we default to current and native.
9078 ((null gnus-refer-article-method)
9079 (list gnus-current-select-method gnus-select-method))
9080 ;; Current.
9081 ((eq 'current gnus-refer-article-method)
9082 (list gnus-current-select-method))
9083 ;; List of select methods.
9084 ((not (and (symbolp (car gnus-refer-article-method))
9085 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9086 (let (out)
9087 (dolist (method gnus-refer-article-method)
9088 (push (if (eq 'current method)
9089 gnus-current-select-method
9090 (if (eq 'nnir (car method))
9091 (list
9092 'nnir
9093 (or (cadr method)
9094 (gnus-method-to-server gnus-current-select-method)))
9095 method))
9096 out))
9097 (nreverse out)))
9098 ;; One single select method.
9100 (list gnus-refer-article-method))))
9102 (defun gnus-summary-edit-parameters ()
9103 "Edit the group parameters of the current group."
9104 (interactive)
9105 (gnus-group-edit-group gnus-newsgroup-name 'params))
9107 (defun gnus-summary-customize-parameters ()
9108 "Customize the group parameters of the current group."
9109 (interactive)
9110 (gnus-group-customize gnus-newsgroup-name))
9112 (defun gnus-summary-enter-digest-group (&optional force)
9113 "Enter an nndoc group based on the current article.
9114 If FORCE, force a digest interpretation. If not, try to guess
9115 what the document format is.
9117 To control what happens when you exit the group, see the
9118 `gnus-auto-select-on-ephemeral-exit' variable."
9119 (interactive "P")
9120 (let ((conf gnus-current-window-configuration))
9121 (save-window-excursion
9122 (save-excursion
9123 (let (gnus-article-prepare-hook
9124 gnus-display-mime-function
9125 gnus-break-pages)
9126 (gnus-summary-select-article))))
9127 (setq gnus-current-window-configuration conf)
9128 (let* ((name (format "%s-%d"
9129 (gnus-group-prefixed-name
9130 gnus-newsgroup-name (list 'nndoc ""))
9131 (with-current-buffer gnus-summary-buffer
9132 gnus-current-article)))
9133 (ogroup gnus-newsgroup-name)
9134 (params (append (gnus-info-params (gnus-get-info ogroup))
9135 (list (cons 'to-group ogroup))
9136 (list (cons 'parent-group ogroup))
9137 (list (cons 'save-article-group ogroup))))
9138 (case-fold-search t)
9139 (buf (current-buffer))
9140 dig to-address)
9141 (with-current-buffer gnus-original-article-buffer
9142 ;; Have the digest group inherit the main mail address of
9143 ;; the parent article.
9144 (when (setq to-address (or (gnus-fetch-field "reply-to")
9145 (gnus-fetch-field "from")))
9146 (setq params
9147 (append
9148 (list (cons 'to-address
9149 (funcall gnus-decode-encoded-address-function
9150 to-address))))))
9151 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9152 (insert-buffer-substring gnus-original-article-buffer)
9153 ;; Remove lines that may lead nndoc to misinterpret the
9154 ;; document type.
9155 (narrow-to-region
9156 (goto-char (point-min))
9157 (or (search-forward "\n\n" nil t) (point)))
9158 (goto-char (point-min))
9159 (delete-matching-lines "^Path:\\|^From ")
9160 (widen))
9161 (unwind-protect
9162 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
9163 (gnus-newsgroup-ephemeral-ignored-charsets
9164 gnus-newsgroup-ignored-charsets))
9165 (gnus-group-read-ephemeral-group
9166 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9167 (nndoc-article-type
9168 ,(if force 'mbox 'guess)))
9169 t nil nil nil
9170 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9171 "ADAPT")))))
9172 ;; Make all postings to this group go to the parent group.
9173 (nconc (gnus-info-params (gnus-get-info name))
9174 params)
9175 ;; Couldn't select this doc group.
9176 (switch-to-buffer buf)
9177 (gnus-set-global-variables)
9178 (gnus-configure-windows 'summary)
9179 (gnus-message 3 "Article couldn't be entered?"))
9180 (kill-buffer dig)))))
9182 (defun gnus-summary-read-document (n)
9183 "Open a new group based on the current article(s).
9184 This will allow you to read digests and other similar
9185 documents as newsgroups.
9186 Obeys the standard process/prefix convention."
9187 (interactive "P")
9188 (let* ((ogroup gnus-newsgroup-name)
9189 (params (append (gnus-info-params (gnus-get-info ogroup))
9190 (list (cons 'to-group ogroup))))
9191 group egroup groups vgroup)
9192 (dolist (article (gnus-summary-work-articles n))
9193 (setq group (format "%s-%d" gnus-newsgroup-name article))
9194 (gnus-summary-remove-process-mark article)
9195 (when (gnus-summary-display-article article)
9196 (save-excursion ;;What for?
9197 (with-temp-buffer
9198 (insert-buffer-substring gnus-original-article-buffer)
9199 ;; Remove some headers that may lead nndoc to make
9200 ;; the wrong guess.
9201 (message-narrow-to-head)
9202 (goto-char (point-min))
9203 (delete-matching-lines "^Path:\\|^From ")
9204 (widen)
9205 (if (setq egroup
9206 (gnus-group-read-ephemeral-group
9207 group `(nndoc ,group (nndoc-address ,(current-buffer))
9208 (nndoc-article-type guess))
9209 t nil t))
9210 (progn
9211 ;; Make all postings to this group go to the parent group.
9212 (nconc (gnus-info-params (gnus-get-info egroup))
9213 params)
9214 (push egroup groups))
9215 ;; Couldn't select this doc group.
9216 (gnus-error 3 "Article couldn't be entered"))))))
9217 ;; Now we have selected all the documents.
9218 (cond
9219 ((not groups)
9220 (error "None of the articles could be interpreted as documents"))
9221 ((gnus-group-read-ephemeral-group
9222 (setq vgroup (format
9223 "nnvirtual:%s-%s" gnus-newsgroup-name
9224 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9225 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9227 (cons (current-buffer) 'summary)))
9229 (error "Couldn't select virtual nndoc group")))))
9231 (defun gnus-summary-widget-forward (arg)
9232 "Move point to the next field or button in the article.
9233 With optional ARG, move across that many fields."
9234 (interactive "p")
9235 (gnus-summary-select-article)
9236 (gnus-configure-windows 'article)
9237 (select-window (gnus-get-buffer-window gnus-article-buffer))
9238 (widget-forward arg))
9240 (defun gnus-summary-widget-backward (arg)
9241 "Move point to the previous field or button in the article.
9242 With optional ARG, move across that many fields."
9243 (interactive "p")
9244 (gnus-summary-select-article)
9245 (gnus-configure-windows 'article)
9246 (select-window (gnus-get-buffer-window gnus-article-buffer))
9247 (unless (widget-at (point))
9248 (goto-char (point-max)))
9249 (widget-backward arg))
9251 (defun gnus-summary-isearch-article (&optional regexp-p)
9252 "Do incremental search forward on the current article.
9253 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9254 (interactive "P")
9255 (gnus-summary-select-article)
9256 (gnus-configure-windows 'article)
9257 (gnus-eval-in-buffer-window gnus-article-buffer
9258 (save-restriction
9259 (widen)
9260 (isearch-forward regexp-p))))
9262 (defun gnus-summary-repeat-search-article-forward ()
9263 "Repeat the previous search forwards."
9264 (interactive)
9265 (unless gnus-last-search-regexp
9266 (error "No previous search"))
9267 (gnus-summary-search-article-forward gnus-last-search-regexp))
9269 (defun gnus-summary-repeat-search-article-backward ()
9270 "Repeat the previous search backwards."
9271 (interactive)
9272 (unless gnus-last-search-regexp
9273 (error "No previous search"))
9274 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9276 (defun gnus-summary-search-article-forward (regexp &optional backward)
9277 "Search for an article containing REGEXP forward.
9278 If BACKWARD, search backward instead."
9279 (interactive
9280 (list (read-string
9281 (format "Search article %s (regexp%s): "
9282 (if current-prefix-arg "backward" "forward")
9283 (if gnus-last-search-regexp
9284 (concat ", default " gnus-last-search-regexp)
9285 "")))
9286 current-prefix-arg))
9287 (if (string-equal regexp "")
9288 (setq regexp (or gnus-last-search-regexp ""))
9289 (setq gnus-last-search-regexp regexp)
9290 (setq gnus-article-before-search gnus-current-article))
9291 ;; Intentionally set gnus-last-article.
9292 (setq gnus-last-article gnus-article-before-search)
9293 (let ((gnus-last-article gnus-last-article))
9294 (if (gnus-summary-search-article regexp backward)
9295 (gnus-summary-show-thread)
9296 (signal 'search-failed (list regexp)))))
9298 (defun gnus-summary-search-article-backward (regexp)
9299 "Search for an article containing REGEXP backward."
9300 (interactive
9301 (list (read-string
9302 (format "Search article backward (regexp%s): "
9303 (if gnus-last-search-regexp
9304 (concat ", default " gnus-last-search-regexp)
9305 "")))))
9306 (gnus-summary-search-article-forward regexp 'backward))
9308 (defun gnus-summary-search-article (regexp &optional backward)
9309 "Search for an article containing REGEXP.
9310 Optional argument BACKWARD means do search for backward.
9311 `gnus-select-article-hook' is not called during the search."
9312 ;; We have to require this here to make sure that the following
9313 ;; dynamic binding isn't shadowed by autoloading.
9314 (require 'gnus-async)
9315 (require 'gnus-art)
9316 (let ((gnus-select-article-hook nil) ;Disable hook.
9317 (gnus-article-prepare-hook nil)
9318 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9319 (gnus-use-article-prefetch nil)
9320 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9321 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9322 (gnus-visual nil)
9323 (gnus-keep-backlog nil)
9324 (gnus-break-pages nil)
9325 (gnus-summary-display-arrow nil)
9326 (gnus-updated-mode-lines nil)
9327 (gnus-auto-center-summary nil)
9328 (sum (current-buffer))
9329 (gnus-display-mime-function nil)
9330 (found nil)
9331 point)
9332 (gnus-save-hidden-threads
9333 (gnus-summary-select-article)
9334 (set-buffer gnus-article-buffer)
9335 (goto-char (window-point (get-buffer-window (current-buffer))))
9336 (when backward
9337 (forward-line -1))
9338 (while (not found)
9339 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9340 (if (if backward
9341 (re-search-backward regexp nil t)
9342 (re-search-forward regexp nil t))
9343 ;; We found the regexp.
9344 (progn
9345 (setq found 'found)
9346 (beginning-of-line)
9347 (set-window-start
9348 (get-buffer-window (current-buffer))
9349 (point))
9350 (forward-line 1)
9351 (set-window-point
9352 (get-buffer-window (current-buffer))
9353 (point))
9354 (set-buffer sum)
9355 (setq point (point)))
9356 ;; We didn't find it, so we go to the next article.
9357 (set-buffer sum)
9358 (setq found 'not)
9359 (while (eq found 'not)
9360 (if (not (if backward (gnus-summary-find-prev)
9361 (gnus-summary-find-next)))
9362 ;; No more articles.
9363 (setq found t)
9364 ;; Select the next article and adjust point.
9365 (unless (gnus-summary-article-sparse-p
9366 (gnus-summary-article-number))
9367 (setq found nil)
9368 (gnus-summary-select-article)
9369 (set-buffer gnus-article-buffer)
9370 (widen)
9371 (goto-char (if backward (point-max) (point-min))))))))
9372 (gnus-message 7 ""))
9373 ;; Return whether we found the regexp.
9374 (when (eq found 'found)
9375 (goto-char point)
9376 (gnus-summary-show-thread)
9377 (gnus-summary-goto-subject gnus-current-article)
9378 (gnus-summary-position-point)
9379 t)))
9381 (defun gnus-find-matching-articles (header regexp)
9382 "Return a list of all articles that match REGEXP on HEADER.
9383 This search includes all articles in the current group that Gnus has
9384 fetched headers for, whether they are displayed or not."
9385 (let ((articles nil)
9386 ;; Can't eta-reduce because it's a macro.
9387 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9388 (case-fold-search t))
9389 (dolist (header gnus-newsgroup-headers)
9390 (when (string-match regexp (funcall func header))
9391 (push (mail-header-number header) articles)))
9392 (nreverse articles)))
9394 (defun gnus-summary-find-matching (header regexp &optional backward unread
9395 not-case-fold not-matching)
9396 "Return a list of all articles that match REGEXP on HEADER.
9397 The search stars on the current article and goes forwards unless
9398 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9399 If UNREAD is non-nil, only unread articles will
9400 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9401 in the comparisons. If NOT-MATCHING, return a list of all articles that
9402 not match REGEXP on HEADER."
9403 (let ((case-fold-search (not not-case-fold))
9404 articles d func)
9405 (if (consp header)
9406 (if (eq (car header) 'extra)
9407 (setq func
9408 `(lambda (h)
9409 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9410 "")))
9411 (error "%s is an invalid header" header))
9412 (unless (fboundp (intern (concat "mail-header-" header)))
9413 (error "%s is not a valid header" header))
9414 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9415 (dolist (d (if (eq backward 'all)
9416 gnus-newsgroup-data
9417 (gnus-data-find-list
9418 (gnus-summary-article-number)
9419 (gnus-data-list backward))))
9420 (when (and (or (not unread) ; We want all articles...
9421 (gnus-data-unread-p d)) ; Or just unreads.
9422 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9423 (if not-matching
9424 (not (string-match
9425 regexp
9426 (funcall func (gnus-data-header d))))
9427 (string-match regexp
9428 (funcall func (gnus-data-header d)))))
9429 (push (gnus-data-number d) articles))) ; Success!
9430 (nreverse articles)))
9432 (defun gnus-summary-execute-command (header regexp command &optional backward)
9433 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9434 If HEADER is an empty string (or nil), the match is done on the entire
9435 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9436 (interactive
9437 (list (let ((completion-ignore-case t))
9438 (gnus-completing-read
9439 "Header name"
9440 (mapcar 'symbol-name
9441 (append
9442 '(Number Subject From Lines Date
9443 Message-ID Xref References Body)
9444 gnus-extra-headers))
9445 'require-match))
9446 (read-string "Regexp: ")
9447 (read-key-sequence "Command: ")
9448 current-prefix-arg))
9449 (when (equal header "Body")
9450 (setq header ""))
9451 ;; Hidden thread subtrees must be searched as well.
9452 (gnus-summary-show-all-threads)
9453 ;; We don't want to change current point nor window configuration.
9454 (save-excursion
9455 (save-window-excursion
9456 (let (gnus-visual
9457 gnus-treat-strip-trailing-blank-lines
9458 gnus-treat-strip-leading-blank-lines
9459 gnus-treat-strip-multiple-blank-lines
9460 gnus-treat-hide-boring-headers
9461 gnus-treat-fold-newsgroups
9462 gnus-article-prepare-hook)
9463 (gnus-message 6 "Executing %s..." (key-description command))
9464 ;; We'd like to execute COMMAND interactively so as to give arguments.
9465 (gnus-execute header regexp
9466 `(call-interactively ',(key-binding command))
9467 backward)
9468 (gnus-message 6 "Executing %s...done" (key-description command))))))
9470 (defun gnus-summary-beginning-of-article ()
9471 "Scroll the article back to the beginning."
9472 (interactive)
9473 (gnus-summary-select-article)
9474 (gnus-configure-windows 'article)
9475 (gnus-eval-in-buffer-window gnus-article-buffer
9476 (widen)
9477 (goto-char (point-min))
9478 (when gnus-break-pages
9479 (gnus-narrow-to-page))))
9481 (defun gnus-summary-end-of-article ()
9482 "Scroll to the end of the article."
9483 (interactive)
9484 (gnus-summary-select-article)
9485 (gnus-configure-windows 'article)
9486 (gnus-eval-in-buffer-window gnus-article-buffer
9487 (widen)
9488 (goto-char (point-max))
9489 (recenter -3)
9490 (when gnus-break-pages
9491 (gnus-narrow-to-page))))
9493 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9494 "Truncate to LEN and quote all \"(\"'s in STRING."
9495 (gnus-replace-in-string (if (and len (> (length string) len))
9496 (substring string 0 len)
9497 string)
9498 "[()]" "\\\\\\&"))
9500 (defun gnus-summary-print-article (&optional filename n)
9501 "Generate and print a PostScript image of the process-marked (mail) articles.
9503 If used interactively, print the current article if none are
9504 process-marked. With prefix arg, prompt the user for the name of the
9505 file to save in.
9507 When used from Lisp, accept two optional args FILENAME and N. N means
9508 to print the next N articles. If N is negative, print the N previous
9509 articles. If N is nil and articles have been marked with the process
9510 mark, print these instead.
9512 If the optional first argument FILENAME is nil, send the image to the
9513 printer. If FILENAME is a string, save the PostScript image in a file with
9514 that name. If FILENAME is a number, prompt the user for the name of the file
9515 to save in."
9516 (interactive (list (ps-print-preprint current-prefix-arg)))
9517 (dolist (article (gnus-summary-work-articles n))
9518 (gnus-summary-select-article nil nil 'pseudo article)
9519 (gnus-eval-in-buffer-window gnus-article-buffer
9520 (gnus-print-buffer))
9521 (gnus-summary-remove-process-mark article))
9522 (ps-despool filename))
9524 (defun gnus-print-buffer ()
9525 (let ((ps-left-header
9526 (list
9527 (concat "("
9528 (gnus-summary-print-truncate-and-quote
9529 (mail-header-subject gnus-current-headers)
9530 66) ")")
9531 (concat "("
9532 (gnus-summary-print-truncate-and-quote
9533 (mail-header-from gnus-current-headers)
9534 45) ")")))
9535 (ps-right-header
9536 (list
9537 "/pagenumberstring load"
9538 (concat "("
9539 (mail-header-date gnus-current-headers) ")"))))
9540 (gnus-run-hooks 'gnus-ps-print-hook)
9541 (save-excursion
9542 (if ps-print-color-p
9543 (ps-spool-buffer-with-faces)
9544 (ps-spool-buffer)))))
9546 (defun gnus-summary-show-complete-article ()
9547 "Show a complete version of the current article.
9548 This is only useful if you're looking at a partial version of the
9549 article currently."
9550 (interactive)
9551 (let ((gnus-keep-backlog nil)
9552 (gnus-use-cache nil)
9553 (gnus-agent nil)
9554 (variable (intern
9555 (format "%s-fetch-partial-articles"
9556 (car (gnus-find-method-for-group
9557 gnus-newsgroup-name)))
9558 obarray))
9559 old-val)
9560 (unwind-protect
9561 (progn
9562 (setq old-val (symbol-value variable))
9563 (set variable nil)
9564 (gnus-flush-original-article-buffer)
9565 (gnus-summary-show-article))
9566 (set variable old-val))))
9568 (defun gnus-summary-show-article (&optional arg)
9569 "Force redisplaying of the current article.
9570 If ARG (the prefix) is a number, show the article with the charset
9571 defined in `gnus-summary-show-article-charset-alist', or the charset
9572 input.
9573 If ARG (the prefix) is non-nil and not a number, show the article,
9574 but without running any of the article treatment functions
9575 article. Normally, the keystroke is `C-u g'. When using `C-u
9576 C-u g', show the raw article."
9577 (interactive "P")
9578 (cond
9579 ((numberp arg)
9580 (gnus-summary-show-article t)
9581 (let ((gnus-newsgroup-charset
9582 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9583 (mm-read-coding-system
9584 "View as charset: " ;; actually it is coding system.
9585 (with-current-buffer gnus-article-buffer
9586 (mm-detect-coding-region (point) (point-max))))))
9587 (gnus-newsgroup-ignored-charsets 'gnus-all))
9588 (gnus-summary-select-article nil 'force)
9589 (let ((deps gnus-newsgroup-dependencies)
9590 head header lines)
9591 (with-current-buffer gnus-original-article-buffer
9592 (save-restriction
9593 (message-narrow-to-head)
9594 (setq head (buffer-string))
9595 (goto-char (point-min))
9596 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9597 (goto-char (point-max))
9598 (widen)
9599 (setq lines (1- (count-lines (point) (point-max))))))
9600 (with-temp-buffer
9601 (insert (format "211 %d Article retrieved.\n"
9602 (cdr gnus-article-current)))
9603 (insert head)
9604 (if lines (insert (format "Lines: %d\n" lines)))
9605 (insert ".\n")
9606 (let ((nntp-server-buffer (current-buffer)))
9607 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9608 (gnus-data-set-header
9609 (gnus-data-find (cdr gnus-article-current))
9610 header)
9611 (gnus-summary-update-article-line
9612 (cdr gnus-article-current) header)
9613 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9614 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9615 ((not arg)
9616 ;; Select the article the normal way.
9617 (if (eq mm-text-html-renderer 'shr)
9618 (progn
9619 (require 'shr)
9620 (let ((shr-ignore-cache t))
9621 (gnus-summary-select-article nil 'force)))
9622 (gnus-summary-select-article nil 'force)))
9623 ((equal arg '(16))
9624 ;; C-u C-u g
9625 (let ((gnus-inhibit-article-treatments t))
9626 (gnus-summary-select-article nil 'force)))
9628 ;; We have to require this here to make sure that the following
9629 ;; dynamic binding isn't shadowed by autoloading.
9630 (require 'gnus-async)
9631 (require 'gnus-art)
9632 ;; Bind the article treatment functions to nil.
9633 (let ((gnus-have-all-headers t)
9634 gnus-article-prepare-hook
9635 gnus-article-decode-hook
9636 gnus-display-mime-function
9637 gnus-break-pages)
9638 ;; Destroy any MIME parts.
9639 (when (gnus-buffer-live-p gnus-article-buffer)
9640 (with-current-buffer gnus-article-buffer
9641 (gnus-article-stop-animations)
9642 (gnus-stop-downloads)
9643 (mm-destroy-parts gnus-article-mime-handles)
9644 ;; Set it to nil for safety reason.
9645 (setq gnus-article-mime-handle-alist nil)
9646 (setq gnus-article-mime-handles nil)))
9647 (gnus-summary-select-article nil 'force))))
9648 (gnus-summary-goto-subject gnus-current-article)
9649 (gnus-summary-position-point))
9651 (defun gnus-summary-show-raw-article ()
9652 "Show the raw article without any article massaging functions being run."
9653 (interactive)
9654 (gnus-summary-show-article t))
9656 (defun gnus-summary-verbose-headers (&optional arg)
9657 "Toggle permanent full header display.
9658 If ARG is a positive number, turn header display on.
9659 If ARG is a negative number, turn header display off."
9660 (interactive "P")
9661 (setq gnus-show-all-headers
9662 (cond ((or (not (numberp arg))
9663 (zerop arg))
9664 (not gnus-show-all-headers))
9665 ((natnump arg)
9666 t)))
9667 (gnus-summary-show-article))
9669 (defun gnus-summary-toggle-header (&optional arg)
9670 "Show the headers if they are hidden, or hide them if they are shown.
9671 If ARG is a positive number, show the entire header.
9672 If ARG is a negative number, hide the unwanted header lines."
9673 (interactive "P")
9674 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9675 (get-buffer-window gnus-article-buffer t))))
9676 (with-current-buffer gnus-article-buffer
9677 (widen)
9678 (article-narrow-to-head)
9679 (let* ((inhibit-read-only t)
9680 (inhibit-point-motion-hooks t)
9681 (hidden (if (numberp arg)
9682 (>= arg 0)
9683 (or (not (looking-at "[^ \t\n]+:"))
9684 (gnus-article-hidden-text-p 'headers))))
9685 s e)
9686 (delete-region (point-min) (point-max))
9687 (with-current-buffer gnus-original-article-buffer
9688 (goto-char (setq s (point-min)))
9689 (setq e (if (search-forward "\n\n" nil t)
9690 (1- (point))
9691 (point-max))))
9692 (insert-buffer-substring gnus-original-article-buffer s e)
9693 (run-hooks 'gnus-article-decode-hook)
9694 (if hidden
9695 (let ((gnus-treat-hide-headers nil)
9696 (gnus-treat-hide-boring-headers nil))
9697 (gnus-delete-wash-type 'headers)
9698 (gnus-treat-article 'head))
9699 (gnus-treat-article 'head))
9700 (widen)
9701 (if window
9702 (set-window-start window (goto-char (point-min))))
9703 (if gnus-break-pages
9704 (gnus-narrow-to-page)
9705 (when (gnus-visual-p 'page-marker)
9706 (let ((inhibit-read-only t))
9707 (gnus-remove-text-with-property 'gnus-prev)
9708 (gnus-remove-text-with-property 'gnus-next))))
9709 (gnus-set-mode-line 'article)))))
9711 (defun gnus-summary-show-all-headers ()
9712 "Make all header lines visible."
9713 (interactive)
9714 (gnus-summary-toggle-header 1))
9716 (defun gnus-summary-caesar-message (&optional arg)
9717 "Caesar rotate the current article by 13.
9718 With a non-numerical prefix, also rotate headers. A numerical
9719 prefix specifies how many places to rotate each letter forward."
9720 (interactive "P")
9721 (gnus-summary-select-article)
9722 (let ((mail-header-separator ""))
9723 (gnus-eval-in-buffer-window gnus-article-buffer
9724 (save-restriction
9725 (widen)
9726 (let ((start (window-start))
9727 (inhibit-read-only t))
9728 (if (equal arg '(4))
9729 (message-caesar-buffer-body nil t)
9730 (message-caesar-buffer-body arg))
9731 (set-window-start (get-buffer-window (current-buffer)) start)))))
9732 ;; Create buttons and stuff...
9733 (gnus-treat-article nil))
9735 (declare-function idna-to-unicode "ext:idna" (str))
9737 (defun gnus-summary-idna-message (&optional arg)
9738 "Decode IDNA encoded domain names in the current articles.
9739 IDNA encoded domain names looks like `xn--bar'. If a string
9740 remain unencoded after running this function, it is likely an
9741 invalid IDNA string (`xn--bar' is invalid).
9743 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9744 installed for this command to work."
9745 (interactive "P")
9746 (if (not (and (condition-case nil (require 'idna)
9747 (file-error))
9748 (mm-coding-system-p 'utf-8)
9749 (executable-find (symbol-value 'idna-program))))
9750 (gnus-message
9751 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9752 (gnus-summary-select-article)
9753 (let ((mail-header-separator ""))
9754 (gnus-eval-in-buffer-window gnus-article-buffer
9755 (save-restriction
9756 (widen)
9757 (let ((start (window-start))
9758 buffer-read-only)
9759 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9760 (replace-match (idna-to-unicode (match-string 1))))
9761 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9763 (defun gnus-summary-morse-message (&optional arg)
9764 "Morse decode the current article."
9765 (interactive "P")
9766 (gnus-summary-select-article)
9767 (let ((mail-header-separator ""))
9768 (gnus-eval-in-buffer-window gnus-article-buffer
9769 (save-excursion
9770 (save-restriction
9771 (widen)
9772 (let ((pos (window-start))
9773 (inhibit-read-only t))
9774 (goto-char (point-min))
9775 (when (message-goto-body)
9776 (gnus-narrow-to-body))
9777 (goto-char (point-min))
9778 (while (search-forward "·" (point-max) t)
9779 (replace-match "."))
9780 (unmorse-region (point-min) (point-max))
9781 (widen)
9782 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9784 (defun gnus-summary-stop-page-breaking ()
9785 "Stop page breaking in the current article."
9786 (interactive)
9787 (gnus-summary-select-article)
9788 (gnus-eval-in-buffer-window gnus-article-buffer
9789 (widen)
9790 (when (gnus-visual-p 'page-marker)
9791 (let ((inhibit-read-only t))
9792 (gnus-remove-text-with-property 'gnus-prev)
9793 (gnus-remove-text-with-property 'gnus-next))
9794 (setq gnus-page-broken nil))))
9796 (defun gnus-summary-move-article (&optional n to-newsgroup
9797 select-method action)
9798 "Move the current article to a different newsgroup.
9799 If N is a positive number, move the N next articles.
9800 If N is a negative number, move the N previous articles.
9801 If N is nil and any articles have been marked with the process mark,
9802 move those articles instead.
9803 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9804 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9805 re-spool using this method.
9807 When called interactively with TO-NEWSGROUP being nil, the value of
9808 the variable `gnus-move-split-methods' is used for finding a default
9809 for the target newsgroup.
9811 For this function to work, both the current newsgroup and the
9812 newsgroup that you want to move to have to support the `request-move'
9813 and `request-accept' functions.
9815 ACTION can be either `move' (the default), `crosspost' or `copy'."
9816 (interactive "P")
9817 (unless action
9818 (setq action 'move))
9819 ;; Check whether the source group supports the required functions.
9820 (cond ((and (eq action 'move)
9821 (not (gnus-check-backend-function
9822 'request-move-article gnus-newsgroup-name)))
9823 (error "The current group does not support article moving"))
9824 ((and (eq action 'crosspost)
9825 (not (gnus-check-backend-function
9826 'request-replace-article gnus-newsgroup-name)))
9827 (error "The current group does not support article editing")))
9828 (let ((articles (gnus-summary-work-articles n))
9829 (prefix (if (gnus-check-backend-function
9830 'request-move-article gnus-newsgroup-name)
9831 (funcall gnus-move-group-prefix-function
9832 gnus-newsgroup-name)
9833 ""))
9834 (names '((move "Move" "Moving")
9835 (copy "Copy" "Copying")
9836 (crosspost "Crosspost" "Crossposting")))
9837 (copy-buf (save-excursion
9838 (nnheader-set-temp-buffer " *copy article*")))
9839 art-group to-method new-xref article to-groups
9840 articles-to-update-marks encoded)
9841 (unless (assq action names)
9842 (error "Unknown action %s" action))
9843 ;; Read the newsgroup name.
9844 (when (and (not to-newsgroup)
9845 (not select-method))
9846 (if (and gnus-move-split-methods
9847 (not
9848 (and (memq gnus-current-article articles)
9849 (gnus-buffer-live-p gnus-original-article-buffer))))
9850 ;; When `gnus-move-split-methods' is non-nil, we have to
9851 ;; select an article to give `gnus-read-move-group-name' an
9852 ;; opportunity to suggest an appropriate default. However,
9853 ;; we needn't render or mark the article.
9854 (let ((gnus-display-mime-function nil)
9855 (gnus-article-prepare-hook nil)
9856 (gnus-mark-article-hook nil))
9857 (gnus-summary-select-article nil nil nil (car articles))))
9858 (setq to-newsgroup (gnus-read-move-group-name
9859 (cadr (assq action names))
9860 (symbol-value
9861 (intern (format "gnus-current-%s-group" action)))
9862 articles prefix)
9863 encoded to-newsgroup
9864 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9865 (set (intern (format "gnus-current-%s-group" action))
9866 (mm-decode-coding-string
9867 to-newsgroup
9868 (gnus-group-name-charset to-method to-newsgroup))))
9869 (unless to-method
9870 (setq to-method (or select-method
9871 (gnus-server-to-method
9872 (gnus-group-method to-newsgroup)))))
9873 (setq to-newsgroup
9874 (or encoded
9875 (and to-newsgroup
9876 (mm-encode-coding-string
9877 to-newsgroup
9878 (gnus-group-name-charset to-method to-newsgroup)))))
9879 ;; Check the method we are to move this article to...
9880 (unless (gnus-check-backend-function
9881 'request-accept-article (car to-method))
9882 (error "%s does not support article copying" (car to-method)))
9883 (unless (gnus-check-server to-method)
9884 (error "Can't open server %s" (car to-method)))
9885 (gnus-message 6 "%s to %s: %s..."
9886 (caddr (assq action names))
9887 (or (car select-method)
9888 (gnus-group-decoded-name to-newsgroup))
9889 articles)
9890 (while articles
9891 (setq article (pop articles))
9892 ;; Set any marks that may have changed in the summary buffer.
9893 (when gnus-preserve-marks
9894 (gnus-summary-push-marks-to-backend article))
9895 (setq
9896 art-group
9897 (cond
9898 ;; Move the article.
9899 ((eq action 'move)
9900 ;; Remove this article from future suppression.
9901 (gnus-dup-unsuppress-article article)
9902 (let* ((from-method (gnus-find-method-for-group
9903 gnus-newsgroup-name))
9904 (to-method (or select-method
9905 (gnus-find-method-for-group to-newsgroup)))
9906 (move-is-internal (gnus-server-equal from-method to-method)))
9907 (gnus-request-move-article
9908 article ; Article to move
9909 gnus-newsgroup-name ; From newsgroup
9910 (nth 1 (gnus-find-method-for-group
9911 gnus-newsgroup-name)) ; Server
9912 (list 'gnus-request-accept-article
9913 to-newsgroup (list 'quote select-method)
9914 (not articles) t) ; Accept form
9915 (not articles) ; Only save nov last time
9916 (and move-is-internal
9917 to-newsgroup ; Not respooling
9918 ; Is this move internal?
9919 (gnus-group-real-name to-newsgroup)))))
9920 ;; Copy the article.
9921 ((eq action 'copy)
9922 (with-current-buffer copy-buf
9923 (when (gnus-request-article-this-buffer article
9924 gnus-newsgroup-name)
9925 (save-restriction
9926 (nnheader-narrow-to-headers)
9927 (dolist (hdr gnus-copy-article-ignored-headers)
9928 (message-remove-header hdr t)))
9929 (gnus-request-accept-article
9930 to-newsgroup select-method (not articles) t))))
9931 ;; Crosspost the article.
9932 ((eq action 'crosspost)
9933 (let ((xref (message-tokenize-header
9934 (mail-header-xref (gnus-summary-article-header
9935 article))
9936 " ")))
9937 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9938 ":" (number-to-string article)))
9939 (unless xref
9940 (setq xref (list (system-name))))
9941 (setq new-xref
9942 (concat
9943 (mapconcat 'identity
9944 (delete "Xref:" (delete new-xref xref))
9945 " ")
9946 " " new-xref))
9947 (with-current-buffer copy-buf
9948 ;; First put the article in the destination group.
9949 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9950 (when (consp (setq art-group
9951 (gnus-request-accept-article
9952 to-newsgroup select-method (not articles)
9953 t)))
9954 (setq new-xref (concat new-xref " " (car art-group)
9956 (number-to-string (cdr art-group))))
9957 ;; Now we have the new Xrefs header, so we insert
9958 ;; it and replace the new article.
9959 (nnheader-replace-header "Xref" new-xref)
9960 (gnus-request-replace-article
9961 (cdr art-group) to-newsgroup (current-buffer) t)
9962 art-group))))))
9963 (cond
9964 ((not art-group)
9965 (gnus-message 1 "Couldn't %s article %s: %s"
9966 (cadr (assq action names)) article
9967 (nnheader-get-report (car to-method))))
9968 ((eq art-group 'junk)
9969 (when (eq action 'move)
9970 (gnus-summary-mark-article article gnus-canceled-mark)
9971 (gnus-message 4 "Deleted article %s" article)
9972 ;; run the delete hook
9973 (run-hook-with-args 'gnus-summary-article-delete-hook
9974 action
9975 (gnus-data-header
9976 (assoc article (gnus-data-list nil)))
9977 gnus-newsgroup-name nil
9978 select-method)))
9980 (let* ((pto-group (gnus-group-prefixed-name
9981 (car art-group) to-method))
9982 (info (gnus-get-info pto-group))
9983 (to-group (gnus-info-group info))
9984 to-marks)
9985 ;; Update the group that has been moved to.
9986 (when (and info
9987 (memq action '(move copy)))
9988 (unless (member to-group to-groups)
9989 (push to-group to-groups))
9991 (when (and (not (memq article gnus-newsgroup-unreads))
9992 (cdr art-group))
9993 (push 'read to-marks)
9994 (gnus-info-set-read
9995 info (gnus-add-to-range (gnus-info-read info)
9996 (list (cdr art-group)))))
9998 ;; See whether the article is to be put in the cache.
9999 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10000 (marks (if expirable
10001 gnus-article-mark-lists
10002 (delete '(expirable . expire)
10003 (copy-sequence
10004 gnus-article-mark-lists))))
10005 (to-article (cdr art-group)))
10007 ;; Enter the article into the cache in the new group,
10008 ;; if that is required.
10009 (when (and to-article
10010 gnus-use-cache)
10011 (gnus-cache-possibly-enter-article
10012 to-group to-article
10013 (memq article gnus-newsgroup-marked)
10014 (memq article gnus-newsgroup-dormant)
10015 (memq article gnus-newsgroup-unreads)))
10017 (when (and gnus-preserve-marks
10018 to-article)
10019 ;; Copy any marks over to the new group.
10020 (when (and (equal to-group gnus-newsgroup-name)
10021 (not (memq article gnus-newsgroup-unreads)))
10022 ;; Mark this article as read in this group.
10023 (push (cons to-article gnus-read-mark)
10024 gnus-newsgroup-reads)
10025 ;; Increase the active status of this group.
10026 (setcdr (gnus-active to-group) to-article)
10027 (setcdr gnus-newsgroup-active to-article))
10029 (while marks
10030 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10031 (when (memq article (symbol-value
10032 (intern (format "gnus-newsgroup-%s"
10033 (caar marks)))))
10034 (push (cdar marks) to-marks)
10035 ;; If the other group is the same as this group,
10036 ;; then we have to add the mark to the list.
10037 (when (equal to-group gnus-newsgroup-name)
10038 (set (intern (format "gnus-newsgroup-%s"
10039 (caar marks)))
10040 (cons to-article
10041 (symbol-value
10042 (intern (format "gnus-newsgroup-%s"
10043 (caar marks)))))))
10044 ;; Copy the marks to other group.
10045 (gnus-add-marked-articles
10046 to-group (cdar marks) (list to-article) info)))
10047 (setq marks (cdr marks)))
10049 (when (and expirable
10050 gnus-mark-copied-or-moved-articles-as-expirable
10051 (not (memq 'expire to-marks)))
10052 ;; Mark this article as expirable.
10053 (push 'expire to-marks)
10054 (when (equal to-group gnus-newsgroup-name)
10055 (push to-article gnus-newsgroup-expirable))
10056 ;; Copy the expirable mark to other group.
10057 (gnus-add-marked-articles
10058 to-group 'expire (list to-article) info))
10060 (when (and to-marks
10061 (gnus-method-option-p
10062 (gnus-find-method-for-group to-group)
10063 'server-marks))
10064 (gnus-request-set-mark
10065 to-group (list (list (list to-article) 'add to-marks)))))
10067 (gnus-dribble-enter
10068 (concat "(gnus-group-set-info '"
10069 (gnus-prin1-to-string (gnus-get-info to-group))
10070 ")")
10071 (concat "^(gnus-group-set-info '(\""
10072 (regexp-quote to-group) "\""))))
10074 ;; Update the Xref header in this article to point to
10075 ;; the new crossposted article we have just created.
10076 (when (eq action 'crosspost)
10077 (with-current-buffer copy-buf
10078 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10079 (nnheader-replace-header "Xref" new-xref)
10080 (gnus-request-replace-article
10081 article gnus-newsgroup-name (current-buffer) t)))
10083 ;; run the move/copy/crosspost/respool hook
10084 (run-hook-with-args 'gnus-summary-article-move-hook
10085 action
10086 (gnus-data-header
10087 (assoc article (gnus-data-list nil)))
10088 gnus-newsgroup-name
10089 to-newsgroup
10090 select-method))
10092 ;;;!!!Why is this necessary?
10093 (set-buffer gnus-summary-buffer)
10095 (when (eq action 'move)
10096 (save-excursion
10097 (gnus-summary-goto-subject article)
10098 (gnus-summary-mark-article article gnus-canceled-mark)))))
10099 (push article articles-to-update-marks))
10101 (save-excursion
10102 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10103 ;; Re-activate all groups that have been moved to.
10104 (with-current-buffer gnus-group-buffer
10105 (let ((gnus-group-marked to-groups))
10106 (gnus-group-get-new-news-this-group nil t)))
10108 (gnus-kill-buffer copy-buf)
10109 (gnus-summary-position-point)
10110 (gnus-set-mode-line 'summary)))
10112 (defun gnus-summary-push-marks-to-backend (article)
10113 (let ((set nil)
10114 (marks gnus-article-mark-lists))
10115 (unless (memq article gnus-newsgroup-unreads)
10116 (push 'read set))
10117 (while marks
10118 (when (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10119 (memq article (symbol-value
10120 (intern (format "gnus-newsgroup-%s"
10121 (caar marks))))))
10122 (push (cdar marks) set))
10123 (pop marks))
10124 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)))))
10126 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10127 "Copy the current article to some other group.
10128 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10129 When called interactively, if TO-NEWSGROUP is nil, use the value of
10130 the variable `gnus-move-split-methods' for finding a default target
10131 newsgroup.
10132 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10133 re-spool using this method."
10134 (interactive "P")
10135 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10137 (defun gnus-summary-crosspost-article (&optional n)
10138 "Crosspost the current article to some other group."
10139 (interactive "P")
10140 (gnus-summary-move-article n nil nil 'crosspost))
10142 (defcustom gnus-summary-respool-default-method nil
10143 "Default method type for respooling an article.
10144 If nil, use to the current newsgroup method."
10145 :type 'symbol
10146 :group 'gnus-summary-mail)
10148 (defun gnus-summary-respool-article (&optional n method)
10149 "Respool the current article.
10150 The article will be squeezed through the mail spooling process again,
10151 which means that it will be put in some mail newsgroup or other
10152 depending on `nnmail-split-methods'.
10153 If N is a positive number, respool the N next articles.
10154 If N is a negative number, respool the N previous articles.
10155 If N is nil and any articles have been marked with the process mark,
10156 respool those articles instead.
10158 Respooling can be done both from mail groups and \"real\" newsgroups.
10159 In the former case, the articles in question will be moved from the
10160 current group into whatever groups they are destined to. In the
10161 latter case, they will be copied into the relevant groups."
10162 (interactive
10163 (list current-prefix-arg
10164 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10165 (methname
10166 (symbol-name (or gnus-summary-respool-default-method
10167 (car (gnus-find-method-for-group
10168 gnus-newsgroup-name)))))
10169 (method
10170 (gnus-completing-read
10171 "Backend to use when respooling"
10172 methods t nil 'gnus-mail-method-history methname))
10174 (cond
10175 ((zerop (length (setq ms (gnus-servers-using-backend
10176 (intern method)))))
10177 (list (intern method) ""))
10178 ((= 1 (length ms))
10179 (car ms))
10181 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10182 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10183 ms-alist))))))))
10184 (unless method
10185 (error "No method given for respooling"))
10186 (if (assoc (symbol-name
10187 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10188 (gnus-methods-using 'respool))
10189 (gnus-summary-move-article n nil method)
10190 (gnus-summary-copy-article n nil method)))
10192 (defun gnus-summary-import-article (file &optional edit)
10193 "Import an arbitrary file into a mail newsgroup."
10194 (interactive "fImport file: \nP")
10195 (let ((group gnus-newsgroup-name)
10196 (now (current-time))
10197 atts lines group-art)
10198 (unless (gnus-check-backend-function 'request-accept-article group)
10199 (error "%s does not support article importing" group))
10200 (or (file-readable-p file)
10201 (not (file-regular-p file))
10202 (error "Can't read %s" file))
10203 (with-current-buffer (gnus-get-buffer-create " *import file*")
10204 (erase-buffer)
10205 (nnheader-insert-file-contents file)
10206 (goto-char (point-min))
10207 (if (nnheader-article-p)
10208 (save-restriction
10209 (goto-char (point-min))
10210 (search-forward "\n\n" nil t)
10211 (narrow-to-region (point-min) (1- (point)))
10212 (goto-char (point-min))
10213 (unless (re-search-forward "^date:" nil t)
10214 (goto-char (point-max))
10215 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10216 ;; This doesn't look like an article, so we fudge some headers.
10217 (setq atts (file-attributes file)
10218 lines (count-lines (point-min) (point-max)))
10219 (insert "From: " (read-string "From: ") "\n"
10220 "Subject: " (read-string "Subject: ") "\n"
10221 "Date: " (message-make-date (nth 5 atts)) "\n"
10222 "Message-ID: " (message-make-message-id) "\n"
10223 "Lines: " (int-to-string lines) "\n"
10224 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10225 (setq group-art (gnus-request-accept-article group nil t))
10226 (kill-buffer (current-buffer)))
10227 (setq gnus-newsgroup-active (gnus-activate-group group))
10228 (forward-line 1)
10229 (gnus-summary-goto-article (cdr group-art) nil t)
10230 (when edit
10231 (gnus-summary-edit-article))))
10233 (defun gnus-summary-create-article ()
10234 "Create an article in a mail newsgroup."
10235 (interactive)
10236 (let ((group gnus-newsgroup-name)
10237 (now (current-time))
10238 group-art)
10239 (unless (gnus-check-backend-function 'request-accept-article group)
10240 (error "%s does not support article importing" group))
10241 (with-current-buffer (gnus-get-buffer-create " *import file*")
10242 (erase-buffer)
10243 (goto-char (point-min))
10244 ;; This doesn't look like an article, so we fudge some headers.
10245 (insert "From: " (read-string "From: ") "\n"
10246 "Subject: " (read-string "Subject: ") "\n"
10247 "Date: " (message-make-date now) "\n"
10248 "Message-ID: " (message-make-message-id) "\n")
10249 (setq group-art (gnus-request-accept-article group nil t))
10250 (kill-buffer (current-buffer)))
10251 (setq gnus-newsgroup-active (gnus-activate-group group))
10252 (forward-line 1)
10253 (gnus-summary-goto-article (cdr group-art) nil t)
10254 (gnus-summary-edit-article)))
10256 (defun gnus-summary-article-posted-p ()
10257 "Say whether the current (mail) article is available from news as well.
10258 This will be the case if the article has both been mailed and posted."
10259 (interactive)
10260 (let ((id (mail-header-references (gnus-summary-article-header)))
10261 (gnus-override-method (car (gnus-refer-article-methods))))
10262 (if (gnus-request-head id "")
10263 (gnus-message 2 "The current message was found on %s"
10264 gnus-override-method)
10265 (gnus-message 2 "The current message couldn't be found on %s"
10266 gnus-override-method)
10267 nil)))
10269 (defun gnus-summary-expire-articles (&optional now)
10270 "Expire all articles that are marked as expirable in the current group."
10271 (interactive)
10272 (when (and (not gnus-group-is-exiting-without-update-p)
10273 (gnus-check-backend-function
10274 'request-expire-articles gnus-newsgroup-name))
10275 ;; This backend supports expiry.
10276 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10277 (expirable (if total
10278 (progn
10279 ;; We need to update the info for
10280 ;; this group for `gnus-list-of-read-articles'
10281 ;; to give us the right answer.
10282 (gnus-run-hooks 'gnus-exit-group-hook)
10283 (gnus-summary-update-info)
10284 (gnus-list-of-read-articles gnus-newsgroup-name))
10285 (setq gnus-newsgroup-expirable
10286 (sort gnus-newsgroup-expirable '<))))
10287 (expiry-wait (if now 'immediate
10288 (gnus-group-find-parameter
10289 gnus-newsgroup-name 'expiry-wait)))
10290 (nnmail-expiry-target
10291 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10292 nnmail-expiry-target))
10294 (when expirable
10295 ;; There are expirable articles in this group, so we run them
10296 ;; through the expiry process.
10297 (gnus-message 6 "Expiring articles...")
10298 (when (gnus-check-group gnus-newsgroup-name)
10299 ;; The list of articles that weren't expired is returned.
10300 (save-excursion
10301 (if expiry-wait
10302 (let ((nnmail-expiry-wait-function nil)
10303 (nnmail-expiry-wait expiry-wait))
10304 (setq es (gnus-request-expire-articles
10305 expirable gnus-newsgroup-name)))
10306 (setq es (gnus-request-expire-articles
10307 expirable gnus-newsgroup-name)))
10308 (unless total
10309 (setq gnus-newsgroup-expirable es))
10310 ;; We go through the old list of expirable, and mark all
10311 ;; really expired articles as nonexistent.
10312 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10313 (let ((gnus-use-cache nil))
10314 (dolist (article expirable)
10315 (when (and (not (memq article es))
10316 (gnus-data-find article))
10317 (gnus-summary-mark-article article gnus-canceled-mark)
10318 (run-hook-with-args 'gnus-summary-article-expire-hook
10319 'delete
10320 (gnus-data-header
10321 (assoc article (gnus-data-list nil)))
10322 gnus-newsgroup-name
10324 nil)))))))
10325 (gnus-message 6 "Expiring articles...done")))))
10327 (defun gnus-summary-expire-articles-now ()
10328 "Expunge all expirable articles in the current group.
10329 This means that *all* articles that are marked as expirable will be
10330 deleted forever, right now."
10331 (interactive)
10332 (or gnus-expert-user
10333 (gnus-yes-or-no-p
10334 "Are you really, really sure you want to delete all expirable messages? ")
10335 (error "Phew!"))
10336 (gnus-summary-expire-articles t))
10338 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10339 (defun gnus-summary-delete-article (&optional n)
10340 "Delete the N next (mail) articles.
10341 This command actually deletes articles. This is not a marking
10342 command. The article will disappear forever from your life, never to
10343 return.
10345 If N is negative, delete backwards.
10346 If N is nil and articles have been marked with the process mark,
10347 delete these instead.
10349 If `gnus-novice-user' is non-nil you will be asked for
10350 confirmation before the articles are deleted."
10351 (interactive "P")
10352 (unless (gnus-check-backend-function 'request-expire-articles
10353 gnus-newsgroup-name)
10354 (error "The current newsgroup does not support article deletion"))
10355 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10356 (error "Couldn't open server"))
10357 ;; Compute the list of articles to delete.
10358 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10359 (nnmail-expiry-target 'delete)
10360 not-deleted)
10361 (if (and gnus-novice-user
10362 (not (gnus-yes-or-no-p
10363 (format "Do you really want to delete %s forever? "
10364 (if (> (length articles) 1)
10365 (format "these %s articles" (length articles))
10366 "this article")))))
10368 ;; Delete the articles.
10369 (setq not-deleted (gnus-request-expire-articles
10370 articles gnus-newsgroup-name 'force))
10371 (save-excursion
10372 (while articles
10373 (gnus-summary-remove-process-mark (car articles))
10374 ;; The backend might not have been able to delete the article
10375 ;; after all.
10376 (unless (memq (car articles) not-deleted)
10377 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10378 (let* ((article (car articles))
10379 (ghead (gnus-data-header
10380 (assoc article (gnus-data-list nil)))))
10381 (run-hook-with-args 'gnus-summary-article-delete-hook
10382 'delete ghead gnus-newsgroup-name nil
10383 nil)))
10384 (setq articles (cdr articles))))
10385 (when not-deleted
10386 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10387 (gnus-summary-position-point)
10388 (gnus-set-mode-line 'summary)
10389 not-deleted))
10391 (defun gnus-summary-edit-article (&optional arg)
10392 "Edit the current article.
10393 This will have permanent effect only in mail groups.
10394 If ARG is nil, edit the decoded articles.
10395 If ARG is 1, edit the raw articles.
10396 If ARG is 2, edit the raw articles even in read-only groups.
10397 If ARG is 3, edit the articles with the current handles.
10398 Otherwise, allow editing of articles even in read-only
10399 groups."
10400 (interactive "P")
10401 (let (force raw current-handles)
10402 (cond
10403 ((null arg))
10404 ((eq arg 1)
10405 (setq raw t))
10406 ((eq arg 2)
10407 (setq raw t
10408 force t))
10409 ((eq arg 3)
10410 (setq current-handles
10411 (and (gnus-buffer-live-p gnus-article-buffer)
10412 (with-current-buffer gnus-article-buffer
10413 (prog1
10414 gnus-article-mime-handles
10415 (setq gnus-article-mime-handles nil))))))
10417 (setq force t)))
10418 (when (and raw (not force)
10419 (member gnus-newsgroup-name '("nndraft:delayed"
10420 "nndraft:drafts"
10421 "nndraft:queue")))
10422 (error "Can't edit the raw article in group %s"
10423 gnus-newsgroup-name))
10424 (with-current-buffer gnus-summary-buffer
10425 (let ((mail-parse-charset gnus-newsgroup-charset)
10426 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10427 (gnus-set-global-variables)
10428 (when (and (not force)
10429 (gnus-group-read-only-p))
10430 (error "The current newsgroup does not support article editing"))
10431 (gnus-summary-show-article t)
10432 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10433 (with-current-buffer gnus-article-buffer
10434 (mm-enable-multibyte)))
10435 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10436 (setq raw t))
10437 (gnus-article-edit-article
10438 (if raw 'ignore
10439 `(lambda ()
10440 (let ((mbl mml-buffer-list))
10441 (setq mml-buffer-list nil)
10442 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10443 (mime-to-mml ,'current-handles))
10444 (let ((mbl1 mml-buffer-list))
10445 (setq mml-buffer-list mbl)
10446 (set (make-local-variable 'mml-buffer-list) mbl1))
10447 (gnus-make-local-hook 'kill-buffer-hook)
10448 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10449 `(lambda (no-highlight)
10450 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10451 (message-options message-options)
10452 (message-options-set-recipient)
10453 (mail-parse-ignored-charsets
10454 ',gnus-newsgroup-ignored-charsets)
10455 (rfc2047-header-encoding-alist
10456 ',(let ((charset (gnus-group-name-charset
10457 (gnus-find-method-for-group
10458 gnus-newsgroup-name)
10459 gnus-newsgroup-name)))
10460 (append (list (cons "Newsgroups" charset)
10461 (cons "Followup-To" charset)
10462 (cons "Xref" charset))
10463 rfc2047-header-encoding-alist))))
10464 ,(if (not raw) '(progn
10465 (mml-to-mime)
10466 (mml-destroy-buffers)
10467 (remove-hook 'kill-buffer-hook
10468 'mml-destroy-buffers t)
10469 (kill-local-variable 'mml-buffer-list)))
10470 (gnus-summary-edit-article-done
10471 ,(or (mail-header-references gnus-current-headers) "")
10472 ,(gnus-group-read-only-p)
10473 ,gnus-summary-buffer no-highlight))))))))
10475 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10477 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10478 no-highlight)
10479 "Make edits to the current article permanent."
10480 (interactive)
10481 (save-excursion
10482 ;; The buffer restriction contains the entire article if it exists.
10483 (when (article-goto-body)
10484 (let ((lines (count-lines (point) (point-max)))
10485 (length (- (point-max) (point)))
10486 (case-fold-search t)
10487 (body (copy-marker (point))))
10488 (goto-char (point-min))
10489 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10490 (delete-region (match-beginning 1) (match-end 1))
10491 (insert (number-to-string length)))
10492 (goto-char (point-min))
10493 (when (re-search-forward
10494 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10495 (delete-region (match-beginning 1) (match-end 1))
10496 (insert (number-to-string length)))
10497 (goto-char (point-min))
10498 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10499 (delete-region (match-beginning 1) (match-end 1))
10500 (insert (number-to-string lines))))))
10501 ;; Replace the article.
10502 (let ((buf (current-buffer))
10503 (article (cdr gnus-article-current))
10504 replace-result)
10505 (with-temp-buffer
10506 (insert-buffer-substring buf)
10507 (if (and (not read-only)
10508 (not (setq replace-result
10509 (gnus-request-replace-article
10510 article (car gnus-article-current)
10511 (current-buffer) t))))
10512 (error "Couldn't replace article")
10513 ;; If we got a number back, then that's the new article number
10514 ;; for this article. Otherwise, the article number didn't change.
10515 (when (numberp replace-result)
10516 (with-current-buffer gnus-summary-buffer
10517 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10518 (gnus-summary-limit gnus-newsgroup-limit)
10519 (setq article replace-result)
10520 (gnus-summary-goto-subject article t)))
10521 ;; Update the summary buffer.
10522 (if (and references
10523 (equal (message-tokenize-header references " ")
10524 (message-tokenize-header
10525 (or (message-fetch-field "references") "") " ")))
10526 ;; We only have to update this line.
10527 (save-excursion
10528 (save-restriction
10529 (message-narrow-to-head)
10530 (let ((head (buffer-substring-no-properties
10531 (point-min) (point-max)))
10532 header)
10533 (with-temp-buffer
10534 (insert (format "211 %d Article retrieved.\n" article))
10535 (insert head)
10536 (insert ".\n")
10537 (let ((nntp-server-buffer (current-buffer)))
10538 (setq header (car (gnus-get-newsgroup-headers nil t))))
10539 (with-current-buffer gnus-summary-buffer
10540 (gnus-data-set-header (gnus-data-find article) header)
10541 (gnus-summary-update-article-line article header)
10542 (if (gnus-summary-goto-subject article nil t)
10543 (gnus-summary-update-secondary-mark article)))))))
10544 ;; Update threads.
10545 (set-buffer (or buffer gnus-summary-buffer))
10546 (gnus-summary-update-article article)
10547 (if (gnus-summary-goto-subject article nil t)
10548 (gnus-summary-update-secondary-mark article)))
10549 ;; Prettify the article buffer again.
10550 (unless no-highlight
10551 (with-current-buffer gnus-article-buffer
10552 ;;!!! Fix this -- article should be rehighlighted.
10553 ;;(gnus-run-hooks 'gnus-article-display-hook)
10554 (set-buffer gnus-original-article-buffer)
10555 (gnus-request-article
10556 article (car gnus-article-current) (current-buffer))))
10557 ;; Prettify the summary buffer line.
10558 (when (gnus-visual-p 'summary-highlight 'highlight)
10559 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10561 (defun gnus-summary-edit-wash (key)
10562 "Perform editing command KEY in the article buffer."
10563 (interactive
10564 (list
10565 (progn
10566 (message "%s" (concat (this-command-keys) "- "))
10567 (read-char))))
10568 (message "")
10569 (gnus-summary-edit-article)
10570 (execute-kbd-macro (concat (this-command-keys) key))
10571 (gnus-article-edit-done))
10573 ;;; Respooling
10575 (defun gnus-summary-respool-query (&optional silent trace)
10576 "Query where the respool algorithm would put this article."
10577 (interactive)
10578 (let (gnus-mark-article-hook)
10579 (gnus-summary-select-article)
10580 (with-current-buffer gnus-original-article-buffer
10581 (let ((groups (nnmail-article-group 'identity trace)))
10582 (unless silent
10583 (if groups
10584 (message "This message would go to %s"
10585 (mapconcat 'car groups ", "))
10586 (message "This message would go to no groups"))
10587 groups)))))
10589 (defun gnus-summary-respool-trace ()
10590 "Trace where the respool algorithm would put this article.
10591 Display a buffer showing all fancy splitting patterns which matched."
10592 (interactive)
10593 (gnus-summary-respool-query nil t))
10595 ;; Summary marking commands.
10597 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10598 "Mark articles which has the same subject as read, and then select the next.
10599 If UNMARK is positive, remove any kind of mark.
10600 If UNMARK is negative, tick articles."
10601 (interactive "P")
10602 (when unmark
10603 (setq unmark (prefix-numeric-value unmark)))
10604 (let ((count
10605 (gnus-summary-mark-same-subject
10606 (gnus-summary-article-subject) unmark)))
10607 ;; Select next unread article. If auto-select-same mode, should
10608 ;; select the first unread article.
10609 (gnus-summary-next-article t (and gnus-auto-select-same
10610 (gnus-summary-article-subject)))
10611 (gnus-message 7 "%d article%s marked as %s"
10612 count (if (= count 1) " is" "s are")
10613 (if unmark "unread" "read"))))
10615 (defun gnus-summary-kill-same-subject (&optional unmark)
10616 "Mark articles which has the same subject as read.
10617 If UNMARK is positive, remove any kind of mark.
10618 If UNMARK is negative, tick articles."
10619 (interactive "P")
10620 (when unmark
10621 (setq unmark (prefix-numeric-value unmark)))
10622 (let ((count
10623 (gnus-summary-mark-same-subject
10624 (gnus-summary-article-subject) unmark)))
10625 ;; If marked as read, go to next unread subject.
10626 (when (null unmark)
10627 ;; Go to next unread subject.
10628 (gnus-summary-next-subject 1 t))
10629 (gnus-message 7 "%d articles are marked as %s"
10630 count (if unmark "unread" "read"))))
10632 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10633 "Mark articles with same SUBJECT as read, and return marked number.
10634 If optional argument UNMARK is positive, remove any kinds of marks.
10635 If optional argument UNMARK is negative, mark articles as unread instead."
10636 (let ((count 1))
10637 (save-excursion
10638 (cond
10639 ((null unmark) ; Mark as read.
10640 (while (and
10641 (progn
10642 (gnus-summary-mark-article-as-read gnus-killed-mark)
10643 (gnus-summary-show-thread) t)
10644 (gnus-summary-find-subject subject))
10645 (setq count (1+ count))))
10646 ((> unmark 0) ; Tick.
10647 (while (and
10648 (progn
10649 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10650 (gnus-summary-show-thread) t)
10651 (gnus-summary-find-subject subject))
10652 (setq count (1+ count))))
10653 (t ; Mark as unread.
10654 (while (and
10655 (progn
10656 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10657 (gnus-summary-show-thread) t)
10658 (gnus-summary-find-subject subject))
10659 (setq count (1+ count)))))
10660 (gnus-set-mode-line 'summary)
10661 ;; Return the number of marked articles.
10662 count)))
10664 (defun gnus-summary-mark-as-processable (n &optional unmark)
10665 "Set the process mark on the next N articles.
10666 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10667 the process mark instead. The difference between N and the actual
10668 number of articles marked is returned."
10669 (interactive "P")
10670 (if (and (null n) (gnus-region-active-p))
10671 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10672 (setq n (prefix-numeric-value n))
10673 (let ((backward (< n 0))
10674 (n (abs n)))
10675 (while (and
10676 (> n 0)
10677 (if unmark
10678 (gnus-summary-remove-process-mark
10679 (gnus-summary-article-number))
10680 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10681 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10682 (setq n (1- n)))
10683 (when (/= 0 n)
10684 (gnus-message 7 "No more articles"))
10685 (gnus-summary-recenter)
10686 (gnus-summary-position-point)
10687 n)))
10689 (defun gnus-summary-unmark-as-processable (n)
10690 "Remove the process mark from the next N articles.
10691 If N is negative, unmark backward instead. The difference between N and
10692 the actual number of articles unmarked is returned."
10693 (interactive "P")
10694 (gnus-summary-mark-as-processable n t))
10696 (defun gnus-summary-unmark-all-processable ()
10697 "Remove the process mark from all articles."
10698 (interactive)
10699 (save-excursion
10700 (while gnus-newsgroup-processable
10701 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10702 (gnus-summary-position-point))
10704 (defun gnus-summary-add-mark (article type)
10705 "Mark ARTICLE with a mark of TYPE."
10706 (let ((vtype (car (assq type gnus-article-mark-lists)))
10707 var)
10708 (if (not vtype)
10709 (error "No such mark type: %s" type)
10710 (setq var (intern (format "gnus-newsgroup-%s" type)))
10711 (set var (cons article (symbol-value var)))
10712 (if (memq type '(processable cached replied forwarded recent saved))
10713 (gnus-summary-update-secondary-mark article)
10714 ;;; !!! This is bogus. We should find out what primary
10715 ;;; !!! mark we want to set.
10716 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10718 (defun gnus-summary-mark-as-expirable (n)
10719 "Mark N articles forward as expirable.
10720 If N is negative, mark backward instead. The difference between N and
10721 the actual number of articles marked is returned."
10722 (interactive "p")
10723 (gnus-summary-mark-forward n gnus-expirable-mark))
10725 (defun gnus-summary-mark-as-spam (n)
10726 "Mark N articles forward as spam.
10727 If N is negative, mark backward instead. The difference between N and
10728 the actual number of articles marked is returned."
10729 (interactive "p")
10730 (gnus-summary-mark-forward n gnus-spam-mark))
10732 (defun gnus-summary-mark-article-as-replied (article)
10733 "Mark ARTICLE as replied to and update the summary line.
10734 ARTICLE can also be a list of articles."
10735 (interactive (list (gnus-summary-article-number)))
10736 (let ((articles (if (listp article) article (list article))))
10737 (dolist (article articles)
10738 (unless (numberp article)
10739 (error "%s is not a number" article))
10740 (push article gnus-newsgroup-replied)
10741 (let ((inhibit-read-only t))
10742 (when (gnus-summary-goto-subject article nil t)
10743 (gnus-summary-update-secondary-mark article))))))
10745 (defun gnus-summary-mark-article-as-forwarded (article)
10746 "Mark ARTICLE as forwarded and update the summary line.
10747 ARTICLE can also be a list of articles."
10748 (let ((articles (if (listp article) article (list article))))
10749 (dolist (article articles)
10750 (push article gnus-newsgroup-forwarded)
10751 (let ((inhibit-read-only t))
10752 (when (gnus-summary-goto-subject article nil t)
10753 (gnus-summary-update-secondary-mark article))))))
10755 (defun gnus-summary-set-bookmark (article)
10756 "Set a bookmark in current article."
10757 (interactive (list (gnus-summary-article-number)))
10758 (when (or (not (get-buffer gnus-article-buffer))
10759 (not gnus-current-article)
10760 (not gnus-article-current)
10761 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10762 (error "No current article selected"))
10763 ;; Remove old bookmark, if one exists.
10764 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10765 ;; Set the new bookmark, which is on the form
10766 ;; (article-number . line-number-in-body).
10767 (push
10768 (cons article
10769 (with-current-buffer gnus-article-buffer
10770 (count-lines
10771 (min (point)
10772 (save-excursion
10773 (article-goto-body)
10774 (point)))
10775 (point))))
10776 gnus-newsgroup-bookmarks)
10777 (gnus-message 6 "A bookmark has been added to the current article."))
10779 (defun gnus-summary-remove-bookmark (article)
10780 "Remove the bookmark from the current article."
10781 (interactive (list (gnus-summary-article-number)))
10782 ;; Remove old bookmark, if one exists.
10783 (if (not (assq article gnus-newsgroup-bookmarks))
10784 (gnus-message 6 "No bookmark in current article.")
10785 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10786 (gnus-message 6 "Removed bookmark.")))
10788 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10789 (defun gnus-summary-mark-as-dormant (n)
10790 "Mark N articles forward as dormant.
10791 If N is negative, mark backward instead. The difference between N and
10792 the actual number of articles marked is returned."
10793 (interactive "p")
10794 (gnus-summary-mark-forward n gnus-dormant-mark))
10796 (defun gnus-summary-set-process-mark (article)
10797 "Set the process mark on ARTICLE and update the summary line."
10798 (setq gnus-newsgroup-processable
10799 (cons article
10800 (delq article gnus-newsgroup-processable)))
10801 (when (gnus-summary-goto-subject article)
10802 (gnus-summary-show-thread)
10803 (gnus-summary-goto-subject article)
10804 (gnus-summary-update-secondary-mark article)))
10806 (defun gnus-summary-remove-process-mark (&rest articles)
10807 "Remove the process mark from ARTICLES and update the summary line."
10808 (dolist (article articles)
10809 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10810 (when (gnus-summary-goto-subject article)
10811 (gnus-summary-show-thread)
10812 (gnus-summary-goto-subject article)
10813 (gnus-summary-update-secondary-mark article)))
10816 (defun gnus-summary-set-saved-mark (article)
10817 "Set the process mark on ARTICLE and update the summary line."
10818 (push article gnus-newsgroup-saved)
10819 (when (gnus-summary-goto-subject article)
10820 (gnus-summary-update-secondary-mark article)))
10822 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10823 "Mark N articles as read forwards.
10824 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10825 The difference between N and the actual number of articles marked is
10826 returned.
10827 If NO-EXPIRE, auto-expiry will be inhibited."
10828 (interactive "p")
10829 (gnus-summary-show-thread)
10830 (let ((backward (< n 0))
10831 (gnus-summary-goto-unread
10832 (and gnus-summary-goto-unread
10833 (not (eq gnus-summary-goto-unread 'never))
10834 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10835 gnus-ticked-mark gnus-dormant-mark)))))
10836 (n (abs n))
10837 (mark (or mark gnus-del-mark)))
10838 (while (and (> n 0)
10839 (gnus-summary-mark-article nil mark no-expire)
10840 (zerop (gnus-summary-next-subject
10841 (if backward -1 1)
10842 (and gnus-summary-goto-unread
10843 (not (eq gnus-summary-goto-unread 'never)))
10844 t)))
10845 (setq n (1- n)))
10846 (when (/= 0 n)
10847 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10848 (gnus-summary-recenter)
10849 (gnus-summary-position-point)
10850 (gnus-set-mode-line 'summary)
10853 (defun gnus-summary-mark-article-as-read (mark)
10854 "Mark the current article quickly as read with MARK."
10855 (let ((article (gnus-summary-article-number)))
10856 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10857 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10858 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10859 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10860 (push (cons article mark) gnus-newsgroup-reads)
10861 ;; Possibly remove from cache, if that is used.
10862 (when gnus-use-cache
10863 (gnus-cache-enter-remove-article article))
10864 ;; Allow the backend to change the mark.
10865 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10866 ;; Check for auto-expiry.
10867 (when (and gnus-newsgroup-auto-expire
10868 (memq mark gnus-auto-expirable-marks))
10869 (setq mark gnus-expirable-mark)
10870 ;; Let the backend know about the mark change.
10871 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10872 (push article gnus-newsgroup-expirable))
10873 ;; Set the mark in the buffer.
10874 (gnus-summary-update-mark mark 'unread)
10877 (defun gnus-summary-mark-article-as-unread (mark)
10878 "Mark the current article quickly as unread with MARK."
10879 (let* ((article (gnus-summary-article-number))
10880 (old-mark (gnus-summary-article-mark article)))
10881 ;; Allow the backend to change the mark.
10882 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10883 (if (eq mark old-mark)
10885 (if (<= article 0)
10886 (progn
10887 (gnus-error 1 "Can't mark negative article numbers")
10888 nil)
10889 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10890 (setq gnus-newsgroup-spam-marked
10891 (delq article gnus-newsgroup-spam-marked))
10892 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10893 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10894 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10895 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10896 (cond ((= mark gnus-ticked-mark)
10897 (setq gnus-newsgroup-marked
10898 (gnus-add-to-sorted-list gnus-newsgroup-marked
10899 article)))
10900 ((= mark gnus-spam-mark)
10901 (setq gnus-newsgroup-spam-marked
10902 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10903 article)))
10904 ((= mark gnus-dormant-mark)
10905 (setq gnus-newsgroup-dormant
10906 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10907 article)))
10909 (setq gnus-newsgroup-unreads
10910 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10911 article))))
10912 (gnus-alist-pull article gnus-newsgroup-reads)
10914 ;; See whether the article is to be put in the cache.
10915 (and gnus-use-cache
10916 (vectorp (gnus-summary-article-header article))
10917 (save-excursion
10918 (gnus-cache-possibly-enter-article
10919 gnus-newsgroup-name article
10920 (= mark gnus-ticked-mark)
10921 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10923 ;; Fix the mark.
10924 (gnus-summary-update-mark mark 'unread)
10925 t))))
10927 (defun gnus-summary-mark-article (&optional article mark no-expire)
10928 "Mark ARTICLE with MARK. MARK can be any character.
10929 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10930 `??' (dormant) and `?E' (expirable).
10931 If MARK is nil, then the default character `?r' is used.
10932 If ARTICLE is nil, then the article on the current line will be
10933 marked.
10934 If NO-EXPIRE, auto-expiry will be inhibited."
10935 ;; The mark might be a string.
10936 (when (stringp mark)
10937 (setq mark (aref mark 0)))
10938 ;; If no mark is given, then we check auto-expiring.
10939 (when (null mark)
10940 (setq mark gnus-del-mark))
10941 (when (and (not no-expire)
10942 gnus-newsgroup-auto-expire
10943 (memq mark gnus-auto-expirable-marks))
10944 (setq mark gnus-expirable-mark))
10945 (let ((article (or article (gnus-summary-article-number)))
10946 (old-mark (gnus-summary-article-mark article)))
10947 ;; Allow the backend to change the mark.
10948 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10949 (if (eq mark old-mark)
10951 (unless article
10952 (error "No article on current line"))
10953 (if (not (if (or (= mark gnus-unread-mark)
10954 (= mark gnus-ticked-mark)
10955 (= mark gnus-spam-mark)
10956 (= mark gnus-dormant-mark))
10957 (gnus-mark-article-as-unread article mark)
10958 (gnus-mark-article-as-read article mark)))
10960 ;; See whether the article is to be put in the cache.
10961 (and gnus-use-cache
10962 (not (= mark gnus-canceled-mark))
10963 (vectorp (gnus-summary-article-header article))
10964 (save-excursion
10965 (gnus-cache-possibly-enter-article
10966 gnus-newsgroup-name article
10967 (= mark gnus-ticked-mark)
10968 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10970 (when (gnus-summary-goto-subject article nil t)
10971 (let ((inhibit-read-only t))
10972 (gnus-summary-show-thread)
10973 ;; Fix the mark.
10974 (gnus-summary-update-mark mark 'unread)
10975 t))))))
10977 (defun gnus-summary-update-secondary-mark (article)
10978 "Update the secondary (read, process, cache) mark."
10979 (gnus-summary-update-mark
10980 (cond ((memq article gnus-newsgroup-processable)
10981 gnus-process-mark)
10982 ((memq article gnus-newsgroup-cached)
10983 gnus-cached-mark)
10984 ((memq article gnus-newsgroup-replied)
10985 gnus-replied-mark)
10986 ((memq article gnus-newsgroup-forwarded)
10987 gnus-forwarded-mark)
10988 ((memq article gnus-newsgroup-saved)
10989 gnus-saved-mark)
10990 ((memq article gnus-newsgroup-unseen)
10991 gnus-unseen-mark)
10992 (t gnus-no-mark))
10993 'replied)
10994 (when (gnus-visual-p 'summary-highlight 'highlight)
10995 (gnus-summary-highlight-line)
10996 (gnus-run-hooks 'gnus-summary-update-hook))
10999 (defun gnus-summary-update-download-mark (article)
11000 "Update the download mark."
11001 (gnus-summary-update-mark
11002 (cond ((memq article gnus-newsgroup-undownloaded)
11003 gnus-undownloaded-mark)
11004 (gnus-newsgroup-agentized
11005 gnus-downloaded-mark)
11007 gnus-no-mark))
11008 'download)
11009 (gnus-summary-update-line t)
11012 (defun gnus-summary-update-mark (mark type)
11013 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11014 (inhibit-read-only t))
11015 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11016 (when forward
11017 (when (looking-at "\r")
11018 (incf forward))
11019 (when (<= (+ forward (point)) (point-max))
11020 ;; Go to the right position on the line.
11021 (goto-char (+ forward (point)))
11022 ;; Replace the old mark with the new mark.
11023 (let ((to-insert
11024 (mm-subst-char-in-string
11025 (char-after) mark
11026 (buffer-substring (point) (1+ (point))))))
11027 (delete-region (point) (1+ (point)))
11028 (insert to-insert))
11029 ;; Optionally update the marks by some user rule.
11030 (when (eq type 'unread)
11031 (gnus-data-set-mark
11032 (gnus-data-find (gnus-summary-article-number)) mark)
11033 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11035 (defun gnus-mark-article-as-read (article &optional mark)
11036 "Enter ARTICLE in the pertinent lists and remove it from others."
11037 ;; Make the article expirable.
11038 (let ((mark (or mark gnus-del-mark)))
11039 (setq gnus-newsgroup-expirable
11040 (if (= mark gnus-expirable-mark)
11041 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11042 (delq article gnus-newsgroup-expirable)))
11043 ;; Remove from unread and marked lists.
11044 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11045 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11046 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11047 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11048 (push (cons article mark) gnus-newsgroup-reads)
11049 ;; Possibly remove from cache, if that is used.
11050 (when gnus-use-cache
11051 (gnus-cache-enter-remove-article article))
11054 (defun gnus-mark-article-as-unread (article &optional mark)
11055 "Enter ARTICLE in the pertinent lists and remove it from others."
11056 (let ((mark (or mark gnus-ticked-mark)))
11057 (if (<= article 0)
11058 (progn
11059 (gnus-error 1 "Can't mark negative article numbers")
11060 nil)
11061 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11062 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11063 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11064 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11065 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11067 ;; Unsuppress duplicates?
11068 (when gnus-suppress-duplicates
11069 (gnus-dup-unsuppress-article article))
11071 (cond ((= mark gnus-ticked-mark)
11072 (setq gnus-newsgroup-marked
11073 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11074 ((= mark gnus-spam-mark)
11075 (setq gnus-newsgroup-spam-marked
11076 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11077 article)))
11078 ((= mark gnus-dormant-mark)
11079 (setq gnus-newsgroup-dormant
11080 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11082 (setq gnus-newsgroup-unreads
11083 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11084 (gnus-alist-pull article gnus-newsgroup-reads)
11085 t)))
11087 (defun gnus-summary-tick-article-forward (n)
11088 "Tick N articles forwards.
11089 If N is negative, tick backwards instead.
11090 The difference between N and the number of articles ticked is returned."
11091 (interactive "p")
11092 (gnus-summary-mark-forward n gnus-ticked-mark))
11094 (defun gnus-summary-tick-article-backward (n)
11095 "Tick N articles backwards.
11096 The difference between N and the number of articles ticked is returned."
11097 (interactive "p")
11098 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11100 (defun gnus-summary-tick-article (&optional article clear-mark)
11101 "Mark current article as unread.
11102 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11103 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11104 (interactive)
11105 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11106 gnus-ticked-mark)))
11108 (defun gnus-summary-mark-as-read-forward (n)
11109 "Mark N articles as read forwards.
11110 If N is negative, mark backwards instead.
11111 The difference between N and the actual number of articles marked is
11112 returned."
11113 (interactive "p")
11114 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11116 (defun gnus-summary-mark-as-read-backward (n)
11117 "Mark the N articles as read backwards.
11118 The difference between N and the actual number of articles marked is
11119 returned."
11120 (interactive "p")
11121 (gnus-summary-mark-forward
11122 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11124 (defun gnus-summary-mark-as-read (&optional article mark)
11125 "Mark current article as read.
11126 ARTICLE specifies the article to be marked as read.
11127 MARK specifies a string to be inserted at the beginning of the line."
11128 (gnus-summary-mark-article article mark))
11130 (defun gnus-summary-clear-mark-forward (n)
11131 "Clear marks from N articles forward.
11132 If N is negative, clear backward instead.
11133 The difference between N and the number of marks cleared is returned."
11134 (interactive "p")
11135 (gnus-summary-mark-forward n gnus-unread-mark))
11137 (defun gnus-summary-clear-mark-backward (n)
11138 "Clear marks from N articles backward.
11139 The difference between N and the number of marks cleared is returned."
11140 (interactive "p")
11141 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11143 (defun gnus-summary-mark-unread-as-read ()
11144 "Intended to be used by `gnus-mark-article-hook'."
11145 (when (memq gnus-current-article gnus-newsgroup-unreads)
11146 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11148 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11149 "Intended to be used by `gnus-mark-article-hook'."
11150 (let ((mark (gnus-summary-article-mark)))
11151 (when (or (gnus-unread-mark-p mark)
11152 (gnus-read-mark-p mark))
11153 (gnus-summary-mark-article gnus-current-article
11154 (or new-mark gnus-read-mark)))))
11156 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11157 "Intended to be used by `gnus-mark-article-hook'."
11158 (let ((mark (gnus-summary-article-mark)))
11159 (when (or (gnus-unread-mark-p mark)
11160 (gnus-read-mark-p mark))
11161 (gnus-summary-mark-article (gnus-summary-article-number)
11162 (or new-mark gnus-read-mark)))))
11164 (defun gnus-summary-mark-unread-as-ticked ()
11165 "Intended to be used by `gnus-mark-article-hook'."
11166 (when (memq gnus-current-article gnus-newsgroup-unreads)
11167 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11169 (defun gnus-summary-mark-region-as-read (point mark all)
11170 "Mark all unread articles between point and mark as read.
11171 If given a prefix, mark all articles between point and mark as read,
11172 even ticked and dormant ones."
11173 (interactive "r\nP")
11174 (save-excursion
11175 (let (article)
11176 (goto-char point)
11177 (beginning-of-line)
11178 (while (and
11179 (< (point) mark)
11180 (progn
11181 (when (or all
11182 (memq (setq article (gnus-summary-article-number))
11183 gnus-newsgroup-unreads))
11184 (gnus-summary-mark-article article gnus-del-mark))
11186 (gnus-summary-find-next))))))
11188 (defun gnus-summary-mark-below (score mark)
11189 "Mark articles with score less than SCORE with MARK."
11190 (interactive "P\ncMark: ")
11191 (setq score (if score
11192 (prefix-numeric-value score)
11193 (or gnus-summary-default-score 0)))
11194 (with-current-buffer gnus-summary-buffer
11195 (goto-char (point-min))
11196 (while
11197 (progn
11198 (and (< (gnus-summary-article-score) score)
11199 (gnus-summary-mark-article nil mark))
11200 (gnus-summary-find-next)))))
11202 (defun gnus-summary-kill-below (&optional score)
11203 "Mark articles with score below SCORE as read."
11204 (interactive "P")
11205 (gnus-summary-mark-below score gnus-killed-mark))
11207 (defun gnus-summary-clear-above (&optional score)
11208 "Clear all marks from articles with score above SCORE."
11209 (interactive "P")
11210 (gnus-summary-mark-above score gnus-unread-mark))
11212 (defun gnus-summary-tick-above (&optional score)
11213 "Tick all articles with score above SCORE."
11214 (interactive "P")
11215 (gnus-summary-mark-above score gnus-ticked-mark))
11217 (defun gnus-summary-mark-above (score mark)
11218 "Mark articles with score over SCORE with MARK."
11219 (interactive "P\ncMark: ")
11220 (setq score (if score
11221 (prefix-numeric-value score)
11222 (or gnus-summary-default-score 0)))
11223 (with-current-buffer gnus-summary-buffer
11224 (goto-char (point-min))
11225 (while (and (progn
11226 (when (> (gnus-summary-article-score) score)
11227 (gnus-summary-mark-article nil mark))
11229 (gnus-summary-find-next)))))
11231 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11232 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11233 (defun gnus-summary-limit-include-expunged (&optional no-error)
11234 "Display all the hidden articles that were expunged for low scores."
11235 (interactive)
11236 (let ((inhibit-read-only t))
11237 (let ((scored gnus-newsgroup-scored)
11238 headers h)
11239 (while scored
11240 (unless (gnus-summary-article-header (caar scored))
11241 (and (setq h (gnus-number-to-header (caar scored)))
11242 (< (cdar scored) gnus-summary-expunge-below)
11243 (push h headers)))
11244 (setq scored (cdr scored)))
11245 (if (not headers)
11246 (when (not no-error)
11247 (error "No expunged articles hidden"))
11248 (goto-char (point-min))
11249 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11250 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11251 (dolist (x headers)
11252 (push (mail-header-number x) gnus-newsgroup-limit))
11253 (gnus-summary-prepare-unthreaded (nreverse headers))
11254 (goto-char (point-min))
11255 (gnus-summary-position-point)
11256 t))))
11258 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11259 "Mark all unread articles in this newsgroup as read.
11260 If prefix argument ALL is non-nil, ticked and dormant articles will
11261 also be marked as read.
11262 If QUIETLY is non-nil, no questions will be asked.
11264 If TO-HERE is non-nil, it should be a point in the buffer. All
11265 articles before (after, if REVERSE is set) this point will be marked
11266 as read.
11268 Note that this function will only catch up the unread article
11269 in the current summary buffer limitation.
11271 The number of articles marked as read is returned."
11272 (interactive "P")
11273 (prog1
11274 (save-excursion
11275 (when (or quietly
11276 (not gnus-interactive-catchup) ;Without confirmation?
11277 gnus-expert-user
11278 (gnus-y-or-n-p
11279 (if all
11280 "Mark absolutely all articles as read? "
11281 "Mark all unread articles as read? ")))
11282 (if (and not-mark
11283 (not gnus-newsgroup-adaptive)
11284 (not gnus-newsgroup-auto-expire)
11285 (not gnus-suppress-duplicates)
11286 (or (not gnus-use-cache)
11287 (eq gnus-use-cache 'passive)))
11288 (progn
11289 (when all
11290 (setq gnus-newsgroup-marked nil
11291 gnus-newsgroup-spam-marked nil
11292 gnus-newsgroup-dormant nil))
11293 (setq gnus-newsgroup-unreads
11294 (gnus-sorted-nunion
11295 (gnus-sorted-intersection gnus-newsgroup-unreads
11296 gnus-newsgroup-downloadable)
11297 (gnus-sorted-difference gnus-newsgroup-unfetched
11298 gnus-newsgroup-cached))))
11299 ;; We actually mark all articles as canceled, which we
11300 ;; have to do when using auto-expiry or adaptive scoring.
11301 (gnus-summary-show-all-threads)
11302 (if (and to-here reverse)
11303 (progn
11304 (goto-char to-here)
11305 (gnus-summary-mark-current-read-and-unread-as-read
11306 gnus-catchup-mark)
11307 (while (gnus-summary-find-next (not all))
11308 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11309 (when (gnus-summary-first-subject (not all))
11310 (while (and
11311 (if to-here (< (point) to-here) t)
11312 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11313 (gnus-summary-find-next (not all))))))
11314 (gnus-set-mode-line 'summary))
11316 (gnus-summary-position-point)))
11318 (defun gnus-summary-catchup-to-here (&optional all)
11319 "Mark all unticked articles before the current one as read.
11320 If ALL is non-nil, also mark ticked and dormant articles as read."
11321 (interactive "P")
11322 (save-excursion
11323 (gnus-save-hidden-threads
11324 (let ((beg (point)))
11325 ;; We check that there are unread articles.
11326 (when (or all (gnus-summary-find-prev))
11327 (gnus-summary-catchup all t beg)))))
11328 (gnus-summary-position-point))
11330 (defun gnus-summary-catchup-from-here (&optional all)
11331 "Mark all unticked articles after (and including) the current one as read.
11332 If ALL is non-nil, also mark ticked and dormant articles as read."
11333 (interactive "P")
11334 (save-excursion
11335 (gnus-save-hidden-threads
11336 (let ((beg (point)))
11337 ;; We check that there are unread articles.
11338 (when (or all (gnus-summary-find-next))
11339 (gnus-summary-catchup all t beg nil t)))))
11340 (gnus-summary-position-point))
11342 (defun gnus-summary-catchup-all (&optional quietly)
11343 "Mark all articles in this newsgroup as read.
11344 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11345 instead, which marks only unread articles as read."
11346 (interactive "P")
11347 (gnus-summary-catchup t quietly))
11349 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11350 "Mark all unread articles in this group as read, then exit.
11351 If prefix argument ALL is non-nil, all articles are marked as read.
11352 If QUIETLY is non-nil, no questions will be asked."
11353 (interactive "P")
11354 (when (gnus-summary-catchup all quietly nil 'fast)
11355 ;; Select next newsgroup or exit.
11356 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11357 (eq gnus-auto-select-next 'quietly))
11358 (gnus-summary-next-group nil)
11359 (gnus-summary-exit))))
11361 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11362 "Mark all articles in this newsgroup as read, and then exit.
11363 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11364 instead, which marks only unread articles as read."
11365 (interactive "P")
11366 (gnus-summary-catchup-and-exit t quietly))
11368 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11369 "Mark all articles in this group as read and select the next group.
11370 If given a prefix, mark all articles, unread as well as ticked, as
11371 read."
11372 (interactive "P")
11373 (save-excursion
11374 (gnus-summary-catchup all))
11375 (gnus-summary-next-group))
11377 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11378 "Mark all articles in this group as read and select the previous group.
11379 If given a prefix, mark all articles, unread as well as ticked, as
11380 read."
11381 (interactive "P")
11382 (save-excursion
11383 (gnus-summary-catchup all))
11384 (gnus-summary-next-group nil nil t))
11387 ;;; with article
11390 (defmacro gnus-with-article (article &rest forms)
11391 "Select ARTICLE and perform FORMS in the original article buffer.
11392 Then replace the article with the result."
11393 `(progn
11394 ;; We don't want the article to be marked as read.
11395 (let (gnus-mark-article-hook)
11396 (gnus-summary-select-article t t nil ,article))
11397 (set-buffer gnus-original-article-buffer)
11398 ,@forms
11399 (if (not (gnus-check-backend-function
11400 'request-replace-article (car gnus-article-current)))
11401 (gnus-message 5 "Read-only group; not replacing")
11402 (unless (gnus-request-replace-article
11403 ,article (car gnus-article-current)
11404 (current-buffer) t)
11405 (error "Couldn't replace article")))
11406 ;; The cache and backlog have to be flushed somewhat.
11407 (when gnus-keep-backlog
11408 (gnus-backlog-remove-article
11409 (car gnus-article-current) (cdr gnus-article-current)))
11410 (when gnus-use-cache
11411 (gnus-cache-update-article
11412 (car gnus-article-current) (cdr gnus-article-current)))))
11414 (put 'gnus-with-article 'lisp-indent-function 1)
11415 (put 'gnus-with-article 'edebug-form-spec '(form body))
11417 ;; Thread-based commands.
11419 (defun gnus-summary-articles-in-thread (&optional article)
11420 "Return a list of all articles in the current thread.
11421 If ARTICLE is non-nil, return all articles in the thread that starts
11422 with that article."
11423 (let* ((article (or article (gnus-summary-article-number)))
11424 (data (gnus-data-find-list article))
11425 (top-level (gnus-data-level (car data)))
11426 (top-subject
11427 (cond ((null gnus-thread-operation-ignore-subject)
11428 (gnus-simplify-subject-re
11429 (mail-header-subject (gnus-data-header (car data)))))
11430 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11431 (gnus-simplify-subject-fuzzy
11432 (mail-header-subject (gnus-data-header (car data)))))
11433 (t nil)))
11434 (end-point (save-excursion
11435 (goto-char (gnus-data-pos (car data)))
11436 (if (gnus-summary-go-to-next-thread)
11437 (point) (point-max))))
11438 articles)
11439 (while (and data
11440 (< (gnus-data-pos (car data)) end-point))
11441 (when (or (not top-subject)
11442 (string= top-subject
11443 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11444 (gnus-simplify-subject-fuzzy
11445 (mail-header-subject
11446 (gnus-data-header (car data))))
11447 (gnus-simplify-subject-re
11448 (mail-header-subject
11449 (gnus-data-header (car data)))))))
11450 (push (gnus-data-number (car data)) articles))
11451 (unless (and (setq data (cdr data))
11452 (> (gnus-data-level (car data)) top-level))
11453 (setq data nil)))
11454 ;; Return the list of articles.
11455 (nreverse articles)))
11457 (defun gnus-summary-rethread-current ()
11458 "Rethread the thread the current article is part of."
11459 (interactive)
11460 (let* ((gnus-show-threads t)
11461 (article (gnus-summary-article-number))
11462 (id (mail-header-id (gnus-summary-article-header)))
11463 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11464 (unless id
11465 (error "No article on the current line"))
11466 (gnus-rebuild-thread id)
11467 (gnus-summary-goto-subject article)))
11469 (defun gnus-summary-reparent-thread ()
11470 "Make the current article child of the marked (or previous) article.
11472 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11473 is non-nil or the Subject: of both articles are the same."
11474 (interactive)
11475 (unless (not (gnus-group-read-only-p))
11476 (error "The current newsgroup does not support article editing"))
11477 (unless (<= (length gnus-newsgroup-processable) 1)
11478 (error "No more than one article may be marked"))
11479 (let ((child (gnus-summary-article-number))
11480 ;; First grab the marked article, otherwise one line up.
11481 (parent (if (not (null gnus-newsgroup-processable))
11482 (car gnus-newsgroup-processable)
11483 (save-excursion
11484 (if (eq (forward-line -1) 0)
11485 (gnus-summary-article-number)
11486 (error "Beginning of summary buffer"))))))
11487 (gnus-summary-reparent-children parent (list child))))
11489 (defun gnus-summary-reparent-children (parent children)
11490 "Make PARENT the parent of CHILDREN.
11491 When called interactively, PARENT is the current article and CHILDREN
11492 are the process-marked articles."
11493 (interactive
11494 (list (gnus-summary-article-number)
11495 (gnus-summary-work-articles nil)))
11496 (dolist (child children)
11497 (save-window-excursion
11498 (let ((gnus-article-buffer " *reparent*"))
11499 (unless (not (eq parent child))
11500 (error "An article may not be self-referential"))
11501 (let ((message-id (mail-header-id
11502 (gnus-summary-article-header parent))))
11503 (unless (and message-id (not (equal message-id "")))
11504 (error "No message-id in desired parent"))
11505 (gnus-with-article child
11506 (save-restriction
11507 (goto-char (point-min))
11508 (message-narrow-to-head)
11509 (if (re-search-forward "^References: " nil t)
11510 (progn
11511 (re-search-forward "^[^ \t]" nil t)
11512 (forward-line -1)
11513 (end-of-line)
11514 (insert " " message-id))
11515 (insert "References: " message-id "\n"))))
11516 (set-buffer gnus-summary-buffer)
11517 (gnus-summary-unmark-all-processable)
11518 (gnus-summary-update-article child)
11519 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11520 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11521 (gnus-summary-rethread-current)
11522 (gnus-message 3 "Article %d is now the child of article %d"
11523 child parent))))))
11525 (defun gnus-summary-toggle-threads (&optional arg)
11526 "Toggle showing conversation threads.
11527 If ARG is positive number, turn showing conversation threads on."
11528 (interactive "P")
11529 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11530 (setq gnus-show-threads
11531 (if (null arg) (not gnus-show-threads)
11532 (> (prefix-numeric-value arg) 0)))
11533 (gnus-summary-prepare)
11534 (gnus-summary-goto-subject current)
11535 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11536 (gnus-summary-position-point)))
11538 (eval-and-compile
11539 (if (fboundp 'remove-overlays)
11540 (defalias 'gnus-remove-overlays 'remove-overlays)
11541 (defun gnus-remove-overlays (beg end name val)
11542 "Clear BEG and END of overlays whose property NAME has value VAL.
11543 For compatibility with XEmacs."
11544 (dolist (ov (gnus-overlays-in beg end))
11545 (when (eq (gnus-overlay-get ov name) val)
11546 (gnus-delete-overlay ov))))))
11548 (defun gnus-summary-show-all-threads ()
11549 "Show all threads."
11550 (interactive)
11551 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11552 (gnus-summary-position-point))
11554 (defsubst gnus-summary--inv (p)
11555 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11557 (defun gnus-summary-show-thread ()
11558 "Show thread subtrees.
11559 Returns nil if no thread was there to be shown."
11560 (interactive)
11561 (let* ((orig (point))
11562 (end (point-at-eol))
11563 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11564 ;; Leave point at bol
11565 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11566 (eoi (when end
11567 (if (fboundp 'next-single-char-property-change)
11568 ;; Note: XEmacs version of n-s-c-p-c may return nil
11569 (or (next-single-char-property-change end 'invisible)
11570 (point-max))
11571 (while (progn
11572 (end-of-line 2)
11573 (and (not (eobp))
11574 (eq (get-char-property (point) 'invisible)
11575 'gnus-sum))))
11576 (point)))))
11577 (when eoi
11578 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11579 (goto-char orig)
11580 (gnus-summary-position-point)
11581 eoi)))
11583 (defun gnus-summary-maybe-hide-threads ()
11584 "If requested, hide the threads that should be hidden."
11585 (when (and gnus-show-threads
11586 gnus-thread-hide-subtree)
11587 (gnus-summary-hide-all-threads
11588 (if (or (consp gnus-thread-hide-subtree)
11589 (functionp gnus-thread-hide-subtree))
11590 (gnus-make-predicate gnus-thread-hide-subtree)
11591 nil))))
11593 ;;; Hiding predicates.
11595 (defun gnus-article-unread-p (header)
11596 (memq (mail-header-number header) gnus-newsgroup-unreads))
11598 (defun gnus-article-unseen-p (header)
11599 (memq (mail-header-number header) gnus-newsgroup-unseen))
11601 (defun gnus-map-articles (predicate articles)
11602 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11603 (apply 'gnus-or (mapcar predicate
11604 (mapcar (lambda (number)
11605 (gnus-summary-article-header number))
11606 articles))))
11608 (defun gnus-summary-hide-all-threads (&optional predicate)
11609 "Hide all thread subtrees.
11610 If PREDICATE is supplied, threads that satisfy this predicate
11611 will not be hidden."
11612 (interactive)
11613 (save-excursion
11614 (goto-char (point-min))
11615 (let ((end nil)
11616 (count 0))
11617 (while (not end)
11618 (incf count)
11619 (when (zerop (mod count 1000))
11620 (message "Hiding all threads... %d" count))
11621 (when (or (not predicate)
11622 (gnus-map-articles
11623 predicate (gnus-summary-article-children)))
11624 (gnus-summary-hide-thread))
11625 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11626 (gnus-summary-position-point))
11628 (defun gnus-summary-hide-thread ()
11629 "Hide thread subtrees.
11630 If PREDICATE is supplied, threads that satisfy this predicate
11631 will not be hidden.
11632 Returns nil if no threads were there to be hidden."
11633 (interactive)
11634 (let ((start (point))
11635 (starteol (line-end-position))
11636 (article (gnus-summary-article-number)))
11637 (goto-char start)
11638 ;; Go forward until either the buffer ends or the subthread ends.
11639 (when (and (not (eobp))
11640 (or (zerop (gnus-summary-next-thread 1 t))
11641 (goto-char (point-max))))
11642 (if (and (> (point) start)
11643 ;; FIXME: this should actually search for a non-invisible \n.
11644 (search-backward "\n" start t))
11645 (progn
11646 (when (> (point) starteol)
11647 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11648 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11649 (gnus-overlay-put ol 'invisible 'gnus-sum)
11650 (gnus-overlay-put ol 'evaporate t)))
11651 (gnus-summary-goto-subject article)
11652 (when (> start (point))
11653 (message "Hiding the thread moved us backwards, aborting!")
11654 (goto-char (point-max))))
11655 (goto-char start)
11656 nil))))
11658 (defun gnus-summary-go-to-next-thread (&optional previous)
11659 "Go to the same level (or less) next thread.
11660 If PREVIOUS is non-nil, go to previous thread instead.
11661 Return the article number moved to, or nil if moving was impossible."
11662 (let ((level (gnus-summary-thread-level))
11663 (way (if previous -1 1))
11664 (beg (point)))
11665 (forward-line way)
11666 (while (and (not (eobp))
11667 (< level (gnus-summary-thread-level)))
11668 (forward-line way))
11669 (if (eobp)
11670 (progn
11671 (goto-char beg)
11672 nil)
11673 (setq beg (point))
11674 (prog1
11675 (gnus-summary-article-number)
11676 (goto-char beg)))))
11678 (defun gnus-summary-next-thread (n &optional silent)
11679 "Go to the same level next N'th thread.
11680 If N is negative, search backward instead.
11681 Returns the difference between N and the number of skips actually
11682 done.
11684 If SILENT, don't output messages."
11685 (interactive "p")
11686 (let ((backward (< n 0))
11687 (n (abs n)))
11688 (while (and (> n 0)
11689 (gnus-summary-go-to-next-thread backward))
11690 (decf n))
11691 (unless silent
11692 (gnus-summary-position-point))
11693 (when (and (not silent) (/= 0 n))
11694 (gnus-message 7 "No more threads"))
11697 (defun gnus-summary-prev-thread (n)
11698 "Go to the same level previous N'th thread.
11699 Returns the difference between N and the number of skips actually
11700 done."
11701 (interactive "p")
11702 (gnus-summary-next-thread (- n)))
11704 (defun gnus-summary-go-down-thread ()
11705 "Go down one level in the current thread."
11706 (let ((children (gnus-summary-article-children)))
11707 (when children
11708 (gnus-summary-goto-subject (car children)))))
11710 (defun gnus-summary-go-up-thread ()
11711 "Go up one level in the current thread."
11712 (let ((parent (gnus-summary-article-parent)))
11713 (when parent
11714 (gnus-summary-goto-subject parent))))
11716 (defun gnus-summary-down-thread (n)
11717 "Go down thread N steps.
11718 If N is negative, go up instead.
11719 Returns the difference between N and how many steps down that were
11720 taken."
11721 (interactive "p")
11722 (let ((up (< n 0))
11723 (n (abs n)))
11724 (while (and (> n 0)
11725 (if up (gnus-summary-go-up-thread)
11726 (gnus-summary-go-down-thread)))
11727 (setq n (1- n)))
11728 (gnus-summary-position-point)
11729 (when (/= 0 n)
11730 (gnus-message 7 "Can't go further"))
11733 (defun gnus-summary-up-thread (n)
11734 "Go up thread N steps.
11735 If N is negative, go down instead.
11736 Returns the difference between N and how many steps down that were
11737 taken."
11738 (interactive "p")
11739 (gnus-summary-down-thread (- n)))
11741 (defun gnus-summary-top-thread ()
11742 "Go to the top of the thread."
11743 (interactive)
11744 (while (gnus-summary-go-up-thread))
11745 (gnus-summary-article-number))
11747 (defun gnus-summary-expire-thread ()
11748 "Mark articles under current thread as expired."
11749 (interactive)
11750 (gnus-summary-kill-thread 0))
11752 (defun gnus-summary-kill-thread (&optional unmark)
11753 "Mark articles under current thread as read.
11754 If the prefix argument is positive, remove any kinds of marks.
11755 If the prefix argument is zero, mark thread as expired.
11756 If the prefix argument is negative, tick articles instead."
11757 (interactive "P")
11758 (when unmark
11759 (setq unmark (prefix-numeric-value unmark)))
11760 (let ((articles (gnus-summary-articles-in-thread))
11761 (hide (or (null unmark) (= unmark 0))))
11762 (save-excursion
11763 ;; Expand the thread.
11764 (gnus-summary-show-thread)
11765 ;; Mark all the articles.
11766 (while articles
11767 (gnus-summary-goto-subject (car articles))
11768 (cond ((null unmark)
11769 (gnus-summary-mark-article-as-read gnus-killed-mark))
11770 ((> unmark 0)
11771 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11772 ((= unmark 0)
11773 (gnus-summary-mark-article nil gnus-expirable-mark))
11775 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11776 (setq articles (cdr articles))))
11777 ;; Hide killed subtrees when hide is true.
11778 (and hide
11779 gnus-thread-hide-killed
11780 (gnus-summary-hide-thread))
11781 ;; If hide is t, go to next unread subject.
11782 (when hide
11783 ;; Go to next unread subject.
11784 (gnus-summary-next-subject 1 t)))
11785 (gnus-set-mode-line 'summary))
11787 ;; Summary sorting commands
11789 (defun gnus-summary-sort-by-number (&optional reverse)
11790 "Sort the summary buffer by article number.
11791 Argument REVERSE means reverse order."
11792 (interactive "P")
11793 (gnus-summary-sort 'number reverse))
11795 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11796 "Sort the summary buffer by most recent article number.
11797 Argument REVERSE means reverse order."
11798 (interactive "P")
11799 (gnus-summary-sort 'most-recent-number reverse))
11801 (defun gnus-summary-sort-by-random (&optional reverse)
11802 "Randomize the order in the summary buffer.
11803 Argument REVERSE means to randomize in reverse order."
11804 (interactive "P")
11805 (gnus-summary-sort 'random reverse))
11807 (defun gnus-summary-sort-by-author (&optional reverse)
11808 "Sort the summary buffer by author name alphabetically.
11809 If `case-fold-search' is non-nil, case of letters is ignored.
11810 Argument REVERSE means reverse order."
11811 (interactive "P")
11812 (gnus-summary-sort 'author reverse))
11814 (defun gnus-summary-sort-by-recipient (&optional reverse)
11815 "Sort the summary buffer by recipient name alphabetically.
11816 If `case-fold-search' is non-nil, case of letters is ignored.
11817 Argument REVERSE means reverse order."
11818 (interactive "P")
11819 (gnus-summary-sort 'recipient reverse))
11821 (defun gnus-summary-sort-by-subject (&optional reverse)
11822 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11823 If `case-fold-search' is non-nil, case of letters is ignored.
11824 Argument REVERSE means reverse order."
11825 (interactive "P")
11826 (gnus-summary-sort 'subject reverse))
11828 (defun gnus-summary-sort-by-date (&optional reverse)
11829 "Sort the summary buffer by date.
11830 Argument REVERSE means reverse order."
11831 (interactive "P")
11832 (gnus-summary-sort 'date reverse))
11834 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11835 "Sort the summary buffer by most recent date.
11836 Argument REVERSE means reverse order."
11837 (interactive "P")
11838 (gnus-summary-sort 'most-recent-date reverse))
11840 (defun gnus-summary-sort-by-score (&optional reverse)
11841 "Sort the summary buffer by score.
11842 Argument REVERSE means reverse order."
11843 (interactive "P")
11844 (gnus-summary-sort 'score reverse))
11846 (defun gnus-summary-sort-by-lines (&optional reverse)
11847 "Sort the summary buffer by the number of lines.
11848 Argument REVERSE means reverse order."
11849 (interactive "P")
11850 (gnus-summary-sort 'lines reverse))
11852 (defun gnus-summary-sort-by-chars (&optional reverse)
11853 "Sort the summary buffer by article length.
11854 Argument REVERSE means reverse order."
11855 (interactive "P")
11856 (gnus-summary-sort 'chars reverse))
11858 (defun gnus-summary-sort-by-original (&optional reverse)
11859 "Sort the summary buffer using the default sorting method.
11860 Argument REVERSE means reverse order."
11861 (interactive "P")
11862 (let* ((inhibit-read-only t)
11863 (gnus-summary-prepare-hook nil))
11864 ;; We do the sorting by regenerating the threads.
11865 (gnus-summary-prepare)
11866 ;; Hide subthreads if needed.
11867 (gnus-summary-maybe-hide-threads)))
11869 (defun gnus-summary-sort (predicate reverse)
11870 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11871 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11872 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11873 (gnus-thread-sort-functions
11874 (if (not reverse)
11875 thread
11876 `(lambda (t1 t2)
11877 (,thread t2 t1))))
11878 (gnus-sort-gathered-threads-function
11879 gnus-thread-sort-functions)
11880 (gnus-article-sort-functions
11881 (if (not reverse)
11882 article
11883 `(lambda (t1 t2)
11884 (,article t2 t1))))
11885 (inhibit-read-only t)
11886 (gnus-summary-prepare-hook nil))
11887 ;; We do the sorting by regenerating the threads.
11888 (gnus-summary-prepare)
11889 ;; Hide subthreads if needed.
11890 (gnus-summary-maybe-hide-threads)))
11892 ;; Summary saving commands.
11894 (defun gnus-summary-save-article (&optional n not-saved)
11895 "Save the current article using the default saver function.
11896 If N is a positive number, save the N next articles.
11897 If N is a negative number, save the N previous articles.
11898 If N is nil and any articles have been marked with the process mark,
11899 save those articles instead.
11900 The variable `gnus-default-article-saver' specifies the saver function.
11902 If the optional second argument NOT-SAVED is non-nil, articles saved
11903 will not be marked as saved."
11904 (interactive "P")
11905 (require 'gnus-art)
11906 (let* ((articles (gnus-summary-work-articles n))
11907 (save-buffer (save-excursion
11908 (nnheader-set-temp-buffer " *Gnus Save*")))
11909 (num (length articles))
11910 ;; Whether to save decoded articles or raw articles.
11911 (decode (when gnus-article-save-coding-system
11912 (get gnus-default-article-saver :decode)))
11913 ;; When saving many articles in a single file, use the other
11914 ;; function to save articles other than the first one.
11915 (saver2 (get gnus-default-article-saver :function))
11916 (gnus-prompt-before-saving (if saver2
11918 gnus-prompt-before-saving))
11919 (gnus-default-article-saver gnus-default-article-saver)
11920 header file)
11921 (dolist (article articles)
11922 (setq header (gnus-summary-article-header article))
11923 (if (not (vectorp header))
11924 ;; This is a pseudo-article.
11925 (if (assq 'name header)
11926 (gnus-copy-file (cdr (assq 'name header)))
11927 (gnus-message 1 "Article %d is unsavable" article))
11928 ;; This is a real article.
11929 (save-window-excursion
11930 (gnus-summary-select-article decode decode nil article)
11931 (gnus-summary-goto-subject article))
11932 (with-current-buffer save-buffer
11933 (erase-buffer)
11934 (insert-buffer-substring (if decode
11935 gnus-article-buffer
11936 gnus-original-article-buffer)))
11937 (setq file (gnus-article-save save-buffer file num))
11938 (gnus-summary-remove-process-mark article)
11939 (unless not-saved
11940 (gnus-summary-set-saved-mark article)))
11941 (when saver2
11942 (setq gnus-default-article-saver saver2
11943 saver2 nil)))
11944 (gnus-kill-buffer save-buffer)
11945 (gnus-summary-position-point)
11946 (gnus-set-mode-line 'summary)
11949 (defun gnus-summary-pipe-output (&optional n sym)
11950 "Pipe the current article to a subprocess.
11951 If N is a positive number, pipe the N next articles.
11952 If N is a negative number, pipe the N previous articles.
11953 If N is nil and any articles have been marked with the process mark,
11954 pipe those articles instead.
11955 The default command to which articles are piped is specified by the
11956 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11957 will be prompted for the command.
11959 The properties `:decode' and `:headers' that are put to the function
11960 symbol `gnus-summary-save-in-pipe' control whether this function
11961 decodes articles and what headers to keep (see the doc string for the
11962 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11963 is neither omitted nor the symbol `r', force including all headers
11964 regardless of the `:headers' property. If it is the symbol `r',
11965 articles that are not decoded and include all headers will be piped
11966 no matter what the properties `:decode' and `:headers' are."
11967 (interactive (gnus-interactive "P\ny"))
11968 (require 'gnus-art)
11969 (let* ((articles (gnus-summary-work-articles n))
11970 (result-buffer "*Shell Command Output*")
11971 (all-headers (not (memq sym '(nil r))))
11972 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11973 (raw (eq sym 'r))
11974 (headers (get 'gnus-summary-save-in-pipe :headers))
11975 command result)
11976 (unless (numberp (car articles))
11977 (error "No article to pipe"))
11978 (setq command (gnus-read-shell-command
11979 (concat "Shell command on "
11980 (if (cdr articles)
11981 (format "these %d articles" (length articles))
11982 "this article")
11983 ": ")
11984 gnus-summary-pipe-output-default-command))
11985 (when (string-equal command "")
11986 (error "A command is required"))
11987 (when all-headers
11988 (put 'gnus-summary-save-in-pipe :headers nil))
11989 (unwind-protect
11990 (while articles
11991 (gnus-summary-goto-subject (pop articles))
11992 (save-window-excursion (gnus-summary-save-in-pipe command raw))
11993 (when (and (get-buffer result-buffer)
11994 (not (zerop (buffer-size (get-buffer result-buffer)))))
11995 (setq result (concat result (with-current-buffer result-buffer
11996 (buffer-string))))))
11997 (put 'gnus-summary-save-in-pipe :headers headers))
11998 (unless (zerop (length result))
11999 (if (with-current-buffer (get-buffer-create result-buffer)
12000 (erase-buffer)
12001 (insert result)
12002 (prog1
12003 (and (= (count-lines (point-min) (point)) 1)
12004 (progn
12005 (end-of-line 0)
12006 (<= (current-column)
12007 (window-width (minibuffer-window)))))
12008 (goto-char (point-min))))
12009 (message "%s" (substring result 0 -1))
12010 (message nil)
12011 (gnus-configure-windows 'pipe)))))
12013 (defun gnus-summary-save-article-mail (&optional arg)
12014 "Append the current article to a Unix mail box file.
12015 If N is a positive number, save the N next articles.
12016 If N is a negative number, save the N previous articles.
12017 If N is nil and any articles have been marked with the process mark,
12018 save those articles instead."
12019 (interactive "P")
12020 (require 'gnus-art)
12021 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12022 (gnus-summary-save-article arg)))
12024 (defun gnus-summary-save-article-rmail (&optional arg)
12025 "Append the current article to an rmail file.
12026 If N is a positive number, save the N next articles.
12027 If N is a negative number, save the N previous articles.
12028 If N is nil and any articles have been marked with the process mark,
12029 save those articles instead."
12030 (interactive "P")
12031 (require 'gnus-art)
12032 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12033 (gnus-summary-save-article arg)))
12035 (defun gnus-summary-save-article-file (&optional arg)
12036 "Append the current article to a file.
12037 If N is a positive number, save the N next articles.
12038 If N is a negative number, save the N previous articles.
12039 If N is nil and any articles have been marked with the process mark,
12040 save those articles instead."
12041 (interactive "P")
12042 (require 'gnus-art)
12043 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12044 (gnus-summary-save-article arg)))
12046 (defun gnus-summary-write-article-file (&optional arg)
12047 "Write the current article to a file, deleting the previous file.
12048 If N is a positive number, save the N next articles.
12049 If N is a negative number, save the N previous articles.
12050 If N is nil and any articles have been marked with the process mark,
12051 save those articles instead."
12052 (interactive "P")
12053 (require 'gnus-art)
12054 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12055 (gnus-summary-save-article arg)))
12057 (defun gnus-summary-save-article-body-file (&optional arg)
12058 "Append the current article body to a file.
12059 If N is a positive number, save the N next articles.
12060 If N is a negative number, save the N previous articles.
12061 If N is nil and any articles have been marked with the process mark,
12062 save those articles instead."
12063 (interactive "P")
12064 (require 'gnus-art)
12065 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12066 (gnus-summary-save-article arg)))
12068 (defun gnus-summary-write-article-body-file (&optional arg)
12069 "Write the current article body to a file, deleting the previous file.
12070 If N is a positive number, save the N next articles.
12071 If N is a negative number, save the N previous articles.
12072 If N is nil and any articles have been marked with the process mark,
12073 save those articles instead."
12074 (interactive "P")
12075 (require 'gnus-art)
12076 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12077 (gnus-summary-save-article arg)))
12079 (defun gnus-summary-muttprint (&optional arg)
12080 "Print the current article using Muttprint.
12081 If N is a positive number, save the N next articles.
12082 If N is a negative number, save the N previous articles.
12083 If N is nil and any articles have been marked with the process mark,
12084 save those articles instead."
12085 (interactive "P")
12086 (require 'gnus-art)
12087 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12088 (gnus-summary-save-article arg t)))
12090 (defun gnus-summary-pipe-message (program)
12091 "Pipe the current article through PROGRAM."
12092 (interactive "sProgram: ")
12093 (gnus-summary-select-article)
12094 (let ((mail-header-separator ""))
12095 (gnus-eval-in-buffer-window gnus-article-buffer
12096 (save-restriction
12097 (widen)
12098 (let ((start (window-start))
12099 (inhibit-read-only t))
12100 (message-pipe-buffer-body program)
12101 (set-window-start (get-buffer-window (current-buffer)) start))))))
12103 (defun gnus-get-split-value (methods)
12104 "Return a value based on the split METHODS."
12105 (let (split-name method result match)
12106 (when methods
12107 (with-current-buffer gnus-original-article-buffer
12108 (save-restriction
12109 (nnheader-narrow-to-headers)
12110 (while (and methods (not split-name))
12111 (goto-char (point-min))
12112 (setq method (pop methods))
12113 (setq match (car method))
12114 (when (cond
12115 ((stringp match)
12116 ;; Regular expression.
12117 (ignore-errors
12118 (re-search-forward match nil t)))
12119 ((functionp match)
12120 ;; Function.
12121 (save-restriction
12122 (widen)
12123 (setq result (funcall match gnus-newsgroup-name))))
12124 ((consp match)
12125 ;; Form.
12126 (save-restriction
12127 (widen)
12128 (setq result (eval match)))))
12129 (setq split-name (cdr method))
12130 (cond ((stringp result)
12131 (push (expand-file-name
12132 result gnus-article-save-directory)
12133 split-name))
12134 ((consp result)
12135 (setq split-name (append result split-name)))))))))
12136 (nreverse split-name)))
12138 (defun gnus-valid-move-group-p (group)
12139 (and (symbolp group)
12140 (boundp group)
12141 (symbol-name group)
12142 (symbol-value group)
12143 (gnus-get-function (gnus-find-method-for-group
12144 (symbol-name group)) 'request-accept-article t)))
12146 (defun gnus-read-move-group-name (prompt default articles prefix)
12147 "Read a group name."
12148 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12149 (minibuffer-confirm-incomplete nil) ; XEmacs
12150 (prom
12151 (format "%s %s to"
12152 prompt
12153 (if (> (length articles) 1)
12154 (format "these %d articles" (length articles))
12155 "this article")))
12156 (to-newsgroup
12157 (cond
12158 ((null split-name)
12159 (gnus-group-completing-read
12160 prom
12161 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12162 nil prefix nil default))
12163 ((= 1 (length split-name))
12164 (gnus-group-completing-read
12165 prom
12166 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12167 nil prefix 'gnus-group-history (car split-name)))
12169 (gnus-completing-read
12170 prom (nreverse split-name) nil nil 'gnus-group-history))))
12171 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12172 encoded)
12173 (when to-newsgroup
12174 (if (or (string= to-newsgroup "")
12175 (string= to-newsgroup prefix))
12176 (setq to-newsgroup default))
12177 (unless to-newsgroup
12178 (error "No group name entered"))
12179 (setq encoded (mm-encode-coding-string
12180 to-newsgroup
12181 (gnus-group-name-charset to-method to-newsgroup)))
12182 (or (gnus-active encoded)
12183 (gnus-activate-group encoded nil nil to-method)
12184 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12185 to-newsgroup))
12186 (or (and (gnus-request-create-group encoded to-method)
12187 (gnus-activate-group encoded nil nil to-method)
12188 (gnus-subscribe-group encoded))
12189 (error "Couldn't create group %s" to-newsgroup)))
12190 (error "No such group: %s" to-newsgroup))
12191 encoded)))
12193 (defvar gnus-summary-save-parts-counter)
12194 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12196 (defun gnus-summary-save-parts (type dir n &optional reverse)
12197 "Save parts matching TYPE to DIR.
12198 If REVERSE, save parts that do not match TYPE."
12199 (interactive
12200 (list (read-string "Save parts of type: "
12201 (or (car gnus-summary-save-parts-type-history)
12202 gnus-summary-save-parts-default-mime)
12203 'gnus-summary-save-parts-type-history)
12204 (setq gnus-summary-save-parts-last-directory
12205 (read-directory-name "Save to directory: "
12206 gnus-summary-save-parts-last-directory
12207 nil t))
12208 current-prefix-arg))
12209 (gnus-summary-iterate n
12210 (let ((gnus-display-mime-function nil)
12211 gnus-article-prepare-hook
12212 gnus-article-decode-hook
12213 gnus-display-mime-function
12214 gnus-break-pages
12215 (gnus-inhibit-treatment t))
12216 (gnus-summary-select-article))
12217 (with-current-buffer gnus-article-buffer
12218 (let ((handles (or gnus-article-mime-handles
12219 (mm-dissect-buffer nil gnus-article-loose-mime)
12220 (and gnus-article-emulate-mime
12221 (mm-uu-dissect))))
12222 (gnus-summary-save-parts-counter 1))
12223 (when handles
12224 (gnus-summary-save-parts-1 type dir handles reverse)
12225 (unless gnus-article-mime-handles ;; Don't destroy this case.
12226 (mm-destroy-parts handles)))))))
12228 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12229 (if (stringp (car handle))
12230 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12231 (cdr handle))
12232 (when (if reverse
12233 (not (string-match type (mm-handle-media-type handle)))
12234 (string-match type (mm-handle-media-type handle)))
12235 (let ((file (expand-file-name
12236 (gnus-map-function
12237 mm-file-name-rewrite-functions
12238 (file-name-nondirectory
12240 (mm-handle-filename handle)
12241 (format "%s.%d.%d" gnus-newsgroup-name
12242 (cdr gnus-article-current)
12243 gnus-summary-save-parts-counter))))
12244 dir)))
12245 (incf gnus-summary-save-parts-counter)
12246 (unless (file-exists-p file)
12247 (mm-save-part-to-file handle file))))))
12249 ;; Summary extract commands
12251 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12252 (let ((inhibit-read-only t)
12253 (article (gnus-summary-article-number))
12254 after-article b e)
12255 (unless (gnus-summary-goto-subject article)
12256 (error "No such article: %d" article))
12257 (gnus-summary-position-point)
12258 ;; If all commands are to be bunched up on one line, we collect
12259 ;; them here.
12260 (unless gnus-view-pseudos-separately
12261 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12262 files action)
12263 (while ps
12264 (setq action (cdr (assq 'action (car ps))))
12265 (setq files (list (cdr (assq 'name (car ps)))))
12266 (while (and ps (cdr ps)
12267 (string= (or action "1")
12268 (or (cdr (assq 'action (cadr ps))) "2")))
12269 (push (cdr (assq 'name (cadr ps))) files)
12270 (setcdr ps (cddr ps)))
12271 (when files
12272 (when (not (string-match "%s" action))
12273 (push " " files))
12274 (push " " files)
12275 (when (assq 'execute (car ps))
12276 (setcdr (assq 'execute (car ps))
12277 (funcall (if (string-match "%s" action)
12278 'format 'concat)
12279 action
12280 (mapconcat
12281 (lambda (f)
12282 (if (equal f " ")
12284 (shell-quote-argument f)))
12285 files " ")))))
12286 (setq ps (cdr ps)))))
12287 (if (and gnus-view-pseudos (not not-view))
12288 (while pslist
12289 (when (assq 'execute (car pslist))
12290 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12291 (eq gnus-view-pseudos 'not-confirm)))
12292 (setq pslist (cdr pslist)))
12293 (save-excursion
12294 (while pslist
12295 (setq after-article (or (cdr (assq 'article (car pslist)))
12296 (gnus-summary-article-number)))
12297 (gnus-summary-goto-subject after-article)
12298 (forward-line 1)
12299 (setq b (point))
12300 (insert " " (file-name-nondirectory
12301 (cdr (assq 'name (car pslist))))
12302 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12303 (setq e (point))
12304 (forward-line -1) ; back to `b'
12305 (gnus-add-text-properties
12306 b (1- e) (list 'gnus-number gnus-reffed-article-number
12307 gnus-mouse-face-prop gnus-mouse-face))
12308 (gnus-data-enter
12309 after-article gnus-reffed-article-number
12310 gnus-unread-mark b (car pslist) 0 (- e b))
12311 (setq gnus-newsgroup-unreads
12312 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12313 gnus-reffed-article-number))
12314 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12315 (setq pslist (cdr pslist)))))))
12317 (defun gnus-pseudos< (p1 p2)
12318 (let ((c1 (cdr (assq 'action p1)))
12319 (c2 (cdr (assq 'action p2))))
12320 (and c1 c2 (string< c1 c2))))
12322 (defun gnus-request-pseudo-article (props)
12323 (cond ((assq 'execute props)
12324 (gnus-execute-command (cdr (assq 'execute props)))))
12325 (let ((gnus-current-article (gnus-summary-article-number)))
12326 (gnus-run-hooks 'gnus-mark-article-hook)))
12328 (defun gnus-execute-command (command &optional automatic)
12329 (save-excursion
12330 (gnus-article-setup-buffer)
12331 (set-buffer gnus-article-buffer)
12332 (setq buffer-read-only nil)
12333 (let ((command (if automatic command
12334 (read-string "Command: " (cons command 0)))))
12335 (erase-buffer)
12336 (insert "$ " command "\n\n")
12337 (if gnus-view-pseudo-asynchronously
12338 (start-process "gnus-execute" (current-buffer) shell-file-name
12339 shell-command-switch command)
12340 (call-process shell-file-name nil t nil
12341 shell-command-switch command)))))
12343 ;; Summary kill commands.
12345 (defun gnus-summary-edit-global-kill (article)
12346 "Edit the \"global\" kill file."
12347 (interactive (list (gnus-summary-article-number)))
12348 (gnus-group-edit-global-kill article))
12350 (defun gnus-summary-edit-local-kill ()
12351 "Edit a local kill file applied to the current newsgroup."
12352 (interactive)
12353 (setq gnus-current-headers (gnus-summary-article-header))
12354 (gnus-group-edit-local-kill
12355 (gnus-summary-article-number) gnus-newsgroup-name))
12357 ;;; Header reading.
12359 (defun gnus-read-header (id &optional header)
12360 "Read the headers of article ID and enter them into the Gnus system."
12361 (let ((group gnus-newsgroup-name)
12362 (gnus-override-method
12364 gnus-override-method
12365 (and (gnus-news-group-p gnus-newsgroup-name)
12366 (car (gnus-refer-article-methods)))))
12367 where)
12368 ;; First we check to see whether the header in question is already
12369 ;; fetched.
12370 (if (stringp id)
12371 ;; This is a Message-ID.
12372 (setq header (or header (gnus-id-to-header id)))
12373 ;; This is an article number.
12374 (setq header (or header (gnus-summary-article-header id))))
12375 (if (and header
12376 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12377 ;; We have found the header.
12378 header
12379 ;; We have to really fetch the header to this article.
12380 (with-current-buffer nntp-server-buffer
12381 (when (setq where (gnus-request-head id group))
12382 (nnheader-fold-continuation-lines)
12383 (goto-char (point-max))
12384 (insert ".\n")
12385 (goto-char (point-min))
12386 (insert "211 ")
12387 (princ (cond
12388 ((numberp id) id)
12389 ((cdr where) (cdr where))
12390 (header (mail-header-number header))
12391 (t gnus-reffed-article-number))
12392 (current-buffer))
12393 (insert " Article retrieved.\n"))
12394 (if (or (not where)
12395 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12396 () ; Malformed head.
12397 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12398 (when (and (bound-and-true-p gnus-registry-enabled)
12399 (not (gnus-ephemeral-group-p (car where))))
12400 (gnus-registry-handle-action
12401 (mail-header-id header) nil
12402 (gnus-group-prefixed-name (car where) gnus-override-method)
12403 (mail-header-subject header)
12404 (mail-header-from header)))
12405 (when (and (stringp id)
12407 (not (string= (gnus-group-real-name group)
12408 (car where)))
12409 (not (gnus-server-equal gnus-override-method
12410 (gnus-group-method group)))))
12411 ;; If we fetched by Message-ID and the article came from
12412 ;; a different group (or server), we fudge some bogus
12413 ;; article numbers for this article.
12414 (mail-header-set-number header gnus-reffed-article-number))
12415 (with-current-buffer gnus-summary-buffer
12416 (decf gnus-reffed-article-number)
12417 (gnus-remove-header (mail-header-number header))
12418 (push header gnus-newsgroup-headers)
12419 (setq gnus-current-headers header)
12420 (push (mail-header-number header) gnus-newsgroup-limit)))
12421 header)))))
12423 (defun gnus-remove-header (number)
12424 "Remove header NUMBER from `gnus-newsgroup-headers'."
12425 (if (and gnus-newsgroup-headers
12426 (= number (mail-header-number (car gnus-newsgroup-headers))))
12427 (pop gnus-newsgroup-headers)
12428 (let ((headers gnus-newsgroup-headers))
12429 (while (and (cdr headers)
12430 (not (= number (mail-header-number (cadr headers)))))
12431 (pop headers))
12432 (when (cdr headers)
12433 (setcdr headers (cddr headers))))))
12436 ;;; summary highlights
12439 (defun gnus-highlight-selected-summary ()
12440 "Highlight selected article in summary buffer."
12441 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12442 (when gnus-summary-selected-face
12443 (save-excursion
12444 (let* ((beg (point-at-bol))
12445 (end (point-at-eol))
12446 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12447 (from (if (get-text-property beg gnus-mouse-face-prop)
12449 (or (next-single-property-change
12450 beg gnus-mouse-face-prop nil end)
12451 beg)))
12453 (if (= from end)
12454 (- from 2)
12455 (or (next-single-property-change
12456 from gnus-mouse-face-prop nil end)
12457 end))))
12458 ;; If no mouse-face prop on line we will have to = from = end,
12459 ;; so we highlight the entire line instead.
12460 (when (= (+ to 2) from)
12461 (setq from beg)
12462 (setq to end))
12463 (if gnus-newsgroup-selected-overlay
12464 ;; Move old overlay.
12465 (gnus-move-overlay
12466 gnus-newsgroup-selected-overlay from to (current-buffer))
12467 ;; Create new overlay.
12468 (gnus-overlay-put
12469 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12470 'face gnus-summary-selected-face))))))
12472 (defvar gnus-summary-highlight-line-cached nil)
12473 (defvar gnus-summary-highlight-line-trigger nil)
12475 (defun gnus-summary-highlight-line-0 ()
12476 (if (and (eq gnus-summary-highlight-line-trigger
12477 gnus-summary-highlight)
12478 gnus-summary-highlight-line-cached)
12479 gnus-summary-highlight-line-cached
12480 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12481 gnus-summary-highlight-line-cached
12482 (let* ((cond (list 'cond))
12483 (c cond)
12484 (list gnus-summary-highlight))
12485 (while list
12486 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12487 nil))
12488 (setq c (cdr c)
12489 list (cdr list)))
12490 (gnus-byte-compile (list 'lambda nil cond))))))
12492 (defun gnus-summary-highlight-line ()
12493 "Highlight current line according to `gnus-summary-highlight'."
12494 (let* ((beg (point-at-bol))
12495 (article (or (gnus-summary-article-number) gnus-current-article))
12496 (score (or (cdr (assq article
12497 gnus-newsgroup-scored))
12498 gnus-summary-default-score 0))
12499 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12500 (inhibit-read-only t)
12501 (default gnus-summary-default-score)
12502 (default-high gnus-summary-default-high-score)
12503 (default-low gnus-summary-default-low-score)
12504 (uncached (and gnus-summary-use-undownloaded-faces
12505 (memq article gnus-newsgroup-undownloaded)
12506 (not (memq article gnus-newsgroup-cached)))))
12507 (let ((face (funcall (gnus-summary-highlight-line-0))))
12508 (unless (eq face (get-text-property beg 'face))
12509 (gnus-put-text-property-excluding-characters-with-faces
12510 beg (point-at-eol) 'face
12511 (setq face (if (boundp face) (symbol-value face) face)))
12512 (when gnus-summary-highlight-line-function
12513 (funcall gnus-summary-highlight-line-function article face))))))
12515 (defun gnus-update-read-articles (group unread &optional compute)
12516 "Update the list of read articles in GROUP.
12517 UNREAD is a sorted list."
12518 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12519 (info (gnus-get-info group))
12520 (prev 1)
12521 read)
12522 (if (or (not info) (not active))
12523 ;; There is no info on this group if it was, in fact,
12524 ;; killed. Gnus stores no information on killed groups, so
12525 ;; there's nothing to be done.
12526 ;; One could store the information somewhere temporarily,
12527 ;; perhaps... Hmmm...
12529 ;; Remove any negative articles numbers.
12530 (while (and unread (< (car unread) 0))
12531 (setq unread (cdr unread)))
12532 ;; Remove any expired article numbers
12533 (while (and unread (< (car unread) (car active)))
12534 (setq unread (cdr unread)))
12535 ;; Compute the ranges of read articles by looking at the list of
12536 ;; unread articles.
12537 (while unread
12538 (when (/= (car unread) prev)
12539 (push (if (= prev (1- (car unread))) prev
12540 (cons prev (1- (car unread))))
12541 read))
12542 (setq prev (1+ (car unread)))
12543 (setq unread (cdr unread)))
12544 (when (<= prev (cdr active))
12545 (push (cons prev (cdr active)) read))
12546 (setq read (if (> (length read) 1) (nreverse read) read))
12547 (if compute
12548 read
12549 (save-excursion
12550 (let (setmarkundo)
12551 ;; Propagate the read marks to the backend.
12552 (when (and (gnus-method-option-p
12553 (gnus-find-method-for-group group)
12554 'server-marks)
12555 (gnus-check-backend-function 'request-set-mark group))
12556 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12557 (add (gnus-remove-from-range read (gnus-info-read info))))
12558 (when (or add del)
12559 (unless (gnus-check-group group)
12560 (error "Can't open server for %s" group))
12561 (gnus-request-set-mark
12562 group (delq nil (list (if add (list add 'add '(read)))
12563 (if del (list del 'del '(read))))))
12564 (setq setmarkundo
12565 `(gnus-request-set-mark
12566 ,group
12567 ',(delq nil (list
12568 (if del (list del 'add '(read)))
12569 (if add (list add 'del '(read))))))))))
12570 (set-buffer gnus-group-buffer)
12571 (gnus-undo-register
12572 `(progn
12573 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12574 (gnus-info-set-read ',info ',(gnus-info-read info))
12575 (gnus-get-unread-articles-in-group ',info
12576 (gnus-active ,group))
12577 (gnus-group-update-group ,group t)
12578 ,setmarkundo))))
12579 ;; Enter this list into the group info.
12580 (gnus-info-set-read info read)
12581 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12582 (gnus-get-unread-articles-in-group info (gnus-active group))
12583 t))))
12585 (defun gnus-offer-save-summaries ()
12586 "Offer to save all active summary buffers."
12587 (let (buffers)
12588 ;; Go through all buffers and find all summaries.
12589 (dolist (buffer (buffer-list))
12590 (when (and (setq buffer (buffer-name buffer))
12591 (string-match "Summary" buffer)
12592 (with-current-buffer buffer
12593 ;; We check that this is, indeed, a summary buffer.
12594 (and (eq major-mode 'gnus-summary-mode)
12595 ;; Also make sure this isn't bogus.
12596 gnus-newsgroup-prepared
12597 ;; Also make sure that this isn't a
12598 ;; dead summary buffer.
12599 (not gnus-dead-summary-mode))))
12600 (push buffer buffers)))
12601 ;; Go through all these summary buffers and offer to save them.
12602 (when buffers
12603 (save-excursion
12604 (if (eq gnus-interactive-exit 'quiet)
12605 (dolist (buffer buffers)
12606 (switch-to-buffer buffer)
12607 (gnus-summary-exit))
12608 (map-y-or-n-p
12609 "Update summary buffer %s? "
12610 (lambda (buf)
12611 (switch-to-buffer buf)
12612 (gnus-summary-exit))
12613 buffers))))))
12615 (defun gnus-summary-setup-default-charset ()
12616 "Setup newsgroup default charset."
12617 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12618 (setq gnus-newsgroup-charset nil)
12619 (let* ((ignored-charsets
12620 (or gnus-newsgroup-ephemeral-ignored-charsets
12621 (append
12622 (and gnus-newsgroup-name
12623 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12624 gnus-newsgroup-ignored-charsets))))
12625 (setq gnus-newsgroup-charset
12626 (or gnus-newsgroup-ephemeral-charset
12627 (and gnus-newsgroup-name
12628 (gnus-parameter-charset gnus-newsgroup-name))
12629 gnus-default-charset))
12630 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12631 ignored-charsets))))
12634 ;;; Mime Commands
12637 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12638 "Display the current article buffer fully MIME-buttonized.
12639 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12640 treated as multipart/mixed."
12641 (interactive "P")
12642 (require 'gnus-art)
12643 (let ((gnus-unbuttonized-mime-types nil)
12644 (gnus-mime-display-multipart-as-mixed show-all-parts))
12645 (gnus-summary-show-article)))
12647 (defun gnus-summary-repair-multipart (article)
12648 "Add a Content-Type header to a multipart article without one."
12649 (interactive (list (gnus-summary-article-number)))
12650 (gnus-with-article article
12651 (message-narrow-to-head)
12652 (message-remove-header "Mime-Version")
12653 (goto-char (point-max))
12654 (insert "Mime-Version: 1.0\n")
12655 (widen)
12656 (when (search-forward "\n--" nil t)
12657 (let ((separator (buffer-substring (point) (point-at-eol))))
12658 (message-narrow-to-head)
12659 (message-remove-header "Content-Type")
12660 (goto-char (point-max))
12661 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12662 separator))
12663 (widen))))
12664 (let (gnus-mark-article-hook)
12665 (gnus-summary-select-article t t nil article)))
12667 (defun gnus-summary-toggle-display-buttonized ()
12668 "Toggle the buttonizing of the article buffer."
12669 (interactive)
12670 (require 'gnus-art)
12671 (if (setq gnus-inhibit-mime-unbuttonizing
12672 (not gnus-inhibit-mime-unbuttonizing))
12673 (let ((gnus-unbuttonized-mime-types nil))
12674 (gnus-summary-show-article))
12675 (gnus-summary-show-article)))
12678 ;;; Generic summary marking commands
12681 (defvar gnus-summary-marking-alist
12682 '((read gnus-del-mark "d")
12683 (unread gnus-unread-mark "u")
12684 (ticked gnus-ticked-mark "!")
12685 (dormant gnus-dormant-mark "?")
12686 (expirable gnus-expirable-mark "e"))
12687 "An alist of names/marks/keystrokes.")
12689 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12690 (defvar gnus-summary-mark-map)
12692 (defun gnus-summary-make-all-marking-commands ()
12693 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12694 (dolist (elem gnus-summary-marking-alist)
12695 (apply 'gnus-summary-make-marking-command elem)))
12697 (defun gnus-summary-make-marking-command (name mark keystroke)
12698 (let ((map (make-sparse-keymap)))
12699 (define-key gnus-summary-generic-mark-map keystroke map)
12700 (dolist (lway `((next "next" next nil "n")
12701 (next-unread "next unread" next t "N")
12702 (prev "previous" prev nil "p")
12703 (prev-unread "previous unread" prev t "P")
12704 (nomove "" nil nil ,keystroke)))
12705 (let ((func (gnus-summary-make-marking-command-1
12706 mark (car lway) lway name)))
12707 (setq func (eval func))
12708 (define-key map (nth 4 lway) func)))))
12710 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12711 `(defun ,(intern
12712 (format "gnus-summary-put-mark-as-%s%s"
12713 name (if (eq way 'nomove)
12715 (concat "-" (symbol-name way)))))
12717 ,(format
12718 "Mark the current article as %s%s.
12719 If N, the prefix, then repeat N times.
12720 If N is negative, move in reverse order.
12721 The difference between N and the actual number of articles marked is
12722 returned."
12723 name (cadr lway))
12724 (interactive "p")
12725 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12727 (defun gnus-summary-generic-mark (n mark move unread)
12728 "Mark N articles with MARK."
12729 (unless (eq major-mode 'gnus-summary-mode)
12730 (error "This command can only be used in the summary buffer"))
12731 (gnus-summary-show-thread)
12732 (let ((nummove
12733 (cond
12734 ((eq move 'next) 1)
12735 ((eq move 'prev) -1)
12736 (t 0))))
12737 (if (zerop nummove)
12738 (setq n 1)
12739 (when (< n 0)
12740 (setq n (abs n)
12741 nummove (* -1 nummove))))
12742 (while (and (> n 0)
12743 (gnus-summary-mark-article nil mark)
12744 (zerop (gnus-summary-next-subject nummove unread t)))
12745 (setq n (1- n)))
12746 (when (/= 0 n)
12747 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12748 (gnus-summary-recenter)
12749 (gnus-summary-position-point)
12750 (gnus-set-mode-line 'summary)
12753 (defun gnus-summary-insert-articles (articles)
12754 (when (setq articles
12755 (gnus-sorted-difference articles
12756 (mapcar (lambda (h)
12757 (mail-header-number h))
12758 gnus-newsgroup-headers)))
12759 (setq gnus-newsgroup-headers
12760 (gnus-merge 'list
12761 gnus-newsgroup-headers
12762 (gnus-fetch-headers articles)
12763 'gnus-article-sort-by-number))
12764 (setq gnus-newsgroup-articles
12765 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12766 ;; Suppress duplicates?
12767 (when gnus-suppress-duplicates
12768 (gnus-dup-suppress-articles))
12770 (if (and gnus-fetch-old-headers
12771 (eq gnus-headers-retrieved-by 'nov))
12772 ;; We might want to build some more threads first.
12773 (if (eq gnus-fetch-old-headers 'invisible)
12774 (gnus-build-all-threads)
12775 (gnus-build-old-threads))
12776 ;; Mark the inserted articles that are unread as unread.
12777 (setq gnus-newsgroup-unreads
12778 (gnus-sorted-nunion
12779 gnus-newsgroup-unreads
12780 (gnus-sorted-nintersection
12781 (gnus-list-of-unread-articles gnus-newsgroup-name)
12782 articles)))
12783 ;; Mark the inserted articles as selected so that the information
12784 ;; of the marks having been changed by a user may be updated when
12785 ;; exiting this group. See `gnus-summary-update-info'.
12786 (dolist (art articles)
12787 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12788 ;; Let the Gnus agent mark articles as read.
12789 (when gnus-agent
12790 (gnus-agent-get-undownloaded-list))
12791 ;; Remove list identifiers from subject
12792 (gnus-summary-remove-list-identifiers)
12793 ;; First and last article in this newsgroup.
12794 (when gnus-newsgroup-headers
12795 (setq gnus-newsgroup-begin
12796 (mail-header-number (car gnus-newsgroup-headers))
12797 gnus-newsgroup-end
12798 (mail-header-number
12799 (gnus-last-element gnus-newsgroup-headers))))
12800 (when gnus-use-scoring
12801 (gnus-possibly-score-headers))))
12803 (defun gnus-summary-insert-old-articles (&optional all)
12804 "Insert all old articles in this group.
12805 If ALL is non-nil, already read articles become readable.
12806 If ALL is a number, fetch this number of articles."
12807 (interactive "P")
12808 (prog1
12809 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12810 older len)
12811 (setq older
12812 ;; Some nntp servers lie about their active range. When
12813 ;; this happens, the active range can be in the millions.
12814 ;; Use a compressed range to avoid creating a huge list.
12815 (gnus-range-difference (list gnus-newsgroup-active) old))
12816 (setq len (gnus-range-length older))
12817 (cond
12818 ((null older) nil)
12819 ((numberp all)
12820 (if (< all len)
12821 (let ((older-range (nreverse older)))
12822 (setq older nil)
12824 (while (> all 0)
12825 (let* ((r (pop older-range))
12826 (min (if (numberp r) r (car r)))
12827 (max (if (numberp r) r (cdr r))))
12828 (while (and (<= min max)
12829 (> all 0))
12830 (push max older)
12831 (setq all (1- all)
12832 max (1- max))))))
12833 (setq older (gnus-uncompress-range older))))
12834 (all
12835 (setq older (gnus-uncompress-range older)))
12837 (when (and (numberp gnus-large-newsgroup)
12838 (> len gnus-large-newsgroup))
12839 (let* ((cursor-in-echo-area nil)
12840 (initial (gnus-parameter-large-newsgroup-initial
12841 gnus-newsgroup-name))
12842 (input
12843 (read-string
12844 (format
12845 "How many articles from %s (%s %d): "
12846 (gnus-group-decoded-name gnus-newsgroup-name)
12847 (if initial "max" "default")
12848 len)
12849 nil nil
12850 (and initial
12851 (number-to-string initial)))))
12852 (unless (string-match "^[ \t]*$" input)
12853 (setq all (string-to-number input))
12854 (if (< all len)
12855 (let ((older-range (nreverse older)))
12856 (setq older nil)
12858 (while (> all 0)
12859 (let* ((r (pop older-range))
12860 (min (if (numberp r) r (car r)))
12861 (max (if (numberp r) r (cdr r))))
12862 (while (and (<= min max)
12863 (> all 0))
12864 (push max older)
12865 (setq all (1- all)
12866 max (1- max))))))))))
12867 (setq older (gnus-uncompress-range older))))
12868 (if (not older)
12869 (message "No old news.")
12870 (gnus-summary-insert-articles older)
12871 (gnus-summary-limit (gnus-sorted-nunion old older))))
12872 (gnus-summary-position-point)))
12874 (defun gnus-summary-insert-new-articles ()
12875 "Insert all new articles in this group."
12876 (interactive)
12877 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12878 (old-high gnus-newsgroup-highest)
12879 (nnmail-fetched-sources (list t))
12880 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12881 i new)
12882 (unless new-active
12883 (error "Couldn't fetch new data"))
12884 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12885 (setq i (cdr gnus-newsgroup-active)
12886 gnus-newsgroup-highest i)
12887 (while (> i old-high)
12888 (push i new)
12889 (decf i))
12890 (if (not new)
12891 (message "No gnus is bad news")
12892 (gnus-summary-insert-articles new)
12893 (setq gnus-newsgroup-unreads
12894 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12895 (gnus-summary-limit (gnus-sorted-nunion old new))))
12896 (gnus-summary-position-point))
12898 ;;; Bookmark support for Gnus.
12899 (declare-function bookmark-make-record-default
12900 "bookmark" (&optional no-file no-context posn))
12901 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12902 (declare-function bookmark-default-handler "bookmark" (bmk))
12903 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12904 (defvar bookmark-yank-point)
12905 (defvar bookmark-current-buffer)
12907 (defun gnus-summary-bookmark-make-record ()
12908 "Make a bookmark entry for a Gnus summary buffer."
12909 (let (pos buf)
12910 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12911 (save-restriction ; FIXME is it necessary to widen?
12912 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12913 (setq buf "art") ; We are recording bookmark from article buffer.
12914 (setq bookmark-yank-point (point))
12915 (setq bookmark-current-buffer (current-buffer))
12916 (gnus-article-show-summary)) ; Go back in summary buffer.
12917 ;; We are now recording bookmark from summary buffer.
12918 (unless buf (setq buf "sum"))
12919 (let* ((subject (elt (gnus-summary-article-header) 1))
12920 (grp (car gnus-article-current))
12921 (art (cdr gnus-article-current))
12922 (head (gnus-summary-article-header art))
12923 (id (mail-header-id head)))
12924 `(,subject
12925 ,@(condition-case nil
12926 (bookmark-make-record-default 'no-file 'no-context pos)
12927 (wrong-number-of-arguments
12928 (bookmark-make-record-default 'point-only)))
12929 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12930 (group . ,grp) (article . ,art)
12931 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12933 ;;;###autoload
12934 (defun gnus-summary-bookmark-jump (bookmark)
12935 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12936 BOOKMARK is a bookmark name or a bookmark record."
12937 (let ((group (bookmark-prop-get bookmark 'group))
12938 (article (bookmark-prop-get bookmark 'article))
12939 (id (bookmark-prop-get bookmark 'message-id))
12940 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12941 (gnus-fetch-group group (list article))
12942 (gnus-summary-insert-cached-articles)
12943 (gnus-summary-goto-article id nil 'force)
12944 ;; FIXME we have to wait article buffer is ready (only large buffer)
12945 ;; Is there a better solution to know that?
12946 ;; If we don't wait `bookmark-default-handler' will have no chance
12947 ;; to set position. However there is no error, just wrong pos.
12948 (sit-for 1)
12949 (when (string= buf "Gnus-art")
12950 (other-window 1))
12951 (bookmark-default-handler
12952 `(""
12953 (buffer . ,(current-buffer))
12954 . ,(bookmark-get-bookmark-record bookmark)))))
12956 (gnus-summary-make-all-marking-commands)
12958 (gnus-ems-redefine)
12960 (provide 'gnus-sum)
12962 (run-hooks 'gnus-sum-load-hook)
12964 ;; Local Variables:
12965 ;; coding: iso-8859-1
12966 ;; End:
12968 ;;; gnus-sum.el ends here