*** empty log message ***
[emacs.git] / lisp / gnus / gnus-sum.el
blob024230c50745083e053490658fff5918d93702e9
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; 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 2, or (at your option)
13 ;; 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; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Commentary:
27 ;;; Code:
29 (eval-when-compile (require 'cl))
31 (require 'gnus)
32 (require 'gnus-group)
33 (require 'gnus-spec)
34 (require 'gnus-range)
35 (require 'gnus-int)
36 (require 'gnus-undo)
37 (require 'gnus-util)
38 (require 'mm-decode)
39 ;; Recursive :-(.
40 ;; (require 'gnus-art)
41 (require 'nnoo)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'mm-uu-dissect "mm-uu")
46 (defcustom gnus-kill-summary-on-exit t
47 "*If non-nil, kill the summary buffer when you exit from it.
48 If nil, the summary will become a \"*Dead Summary*\" buffer, and
49 it will be killed sometime later."
50 :group 'gnus-summary-exit
51 :type 'boolean)
53 (defcustom gnus-fetch-old-headers nil
54 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
55 If an unread article in the group refers to an older, already read (or
56 just marked as read) article, the old article will not normally be
57 displayed in the Summary buffer. If this variable is non-nil, Gnus
58 will attempt to grab the headers to the old articles, and thereby
59 build complete threads. If it has the value `some', only enough
60 headers to connect otherwise loose threads will be displayed. This
61 variable can also be a number. In that case, no more than that number
62 of old headers will be fetched. If it has the value `invisible', all
63 old headers will be fetched, but none will be displayed.
65 The server has to support NOV for any of this to work."
66 :group 'gnus-thread
67 :type '(choice (const :tag "off" nil)
68 (const some)
69 number
70 (sexp :menu-tag "other" t)))
72 (defcustom gnus-refer-thread-limit 200
73 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
74 If t, fetch all the available old headers."
75 :group 'gnus-thread
76 :type '(choice number
77 (sexp :menu-tag "other" t)))
79 (defcustom gnus-summary-make-false-root 'adopt
80 "*nil means that Gnus won't gather loose threads.
81 If the root of a thread has expired or been read in a previous
82 session, the information necessary to build a complete thread has been
83 lost. Instead of having many small sub-threads from this original thread
84 scattered all over the summary buffer, Gnus can gather them.
86 If non-nil, Gnus will try to gather all loose sub-threads from an
87 original thread into one large thread.
89 If this variable is non-nil, it should be one of `none', `adopt',
90 `dummy' or `empty'.
92 If this variable is `none', Gnus will not make a false root, but just
93 present the sub-threads after another.
94 If this variable is `dummy', Gnus will create a dummy root that will
95 have all the sub-threads as children.
96 If this variable is `adopt', Gnus will make one of the \"children\"
97 the parent and mark all the step-children as such.
98 If this variable is `empty', the \"children\" are printed with empty
99 subject fields. (Or rather, they will be printed with a string
100 given by the `gnus-summary-same-subject' variable.)"
101 :group 'gnus-thread
102 :type '(choice (const :tag "off" nil)
103 (const none)
104 (const dummy)
105 (const adopt)
106 (const empty)))
108 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
109 "*A regexp to match subjects to be excluded from loose thread gathering.
110 As loose thread gathering is done on subjects only, that means that
111 there can be many false gatherings performed. By rooting out certain
112 common subjects, gathering might become saner."
113 :group 'gnus-thread
114 :type 'regexp)
116 (defcustom gnus-summary-gather-subject-limit nil
117 "*Maximum length of subject comparisons when gathering loose threads.
118 Use nil to compare full subjects. Setting this variable to a low
119 number will help gather threads that have been corrupted by
120 newsreaders chopping off subject lines, but it might also mean that
121 unrelated articles that have subject that happen to begin with the
122 same few characters will be incorrectly gathered.
124 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
125 comparing subjects."
126 :group 'gnus-thread
127 :type '(choice (const :tag "off" nil)
128 (const fuzzy)
129 (sexp :menu-tag "on" t)))
131 (defcustom gnus-simplify-subject-functions nil
132 "List of functions taking a string argument that simplify subjects.
133 The functions are applied recursively.
135 Useful functions to put in this list include: `gnus-simplify-subject-re',
136 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
137 :group 'gnus-thread
138 :type '(repeat function))
140 (defcustom gnus-simplify-ignored-prefixes nil
141 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
142 :group 'gnus-thread
143 :type '(choice (const :tag "off" nil)
144 regexp))
146 (defcustom gnus-build-sparse-threads nil
147 "*If non-nil, fill in the gaps in threads.
148 If `some', only fill in the gaps that are needed to tie loose threads
149 together. If `more', fill in all leaf nodes that Gnus can find. If
150 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
151 :group 'gnus-thread
152 :type '(choice (const :tag "off" nil)
153 (const some)
154 (const more)
155 (sexp :menu-tag "all" t)))
157 (defcustom gnus-summary-thread-gathering-function
158 'gnus-gather-threads-by-subject
159 "*Function used for gathering loose threads.
160 There are two pre-defined functions: `gnus-gather-threads-by-subject',
161 which only takes Subjects into consideration; and
162 `gnus-gather-threads-by-references', which compared the References
163 headers of the articles to find matches."
164 :group 'gnus-thread
165 :type '(radio (function-item gnus-gather-threads-by-subject)
166 (function-item gnus-gather-threads-by-references)
167 (function :tag "other")))
169 (defcustom gnus-summary-same-subject ""
170 "*String indicating that the current article has the same subject as the previous.
171 This variable will only be used if the value of
172 `gnus-summary-make-false-root' is `empty'."
173 :group 'gnus-summary-format
174 :type 'string)
176 (defcustom gnus-summary-goto-unread t
177 "*If t, many commands will go to the next unread article.
178 This applies to marking commands as well as other commands that
179 \"naturally\" select the next article, like, for instance, `SPC' at
180 the end of an article.
182 If nil, the marking commands do NOT go to the next unread article
183 \(they go to the next article instead). If `never', commands that
184 usually go to the next unread article, will go to the next article,
185 whether it is read or not."
186 :group 'gnus-summary-marks
187 :link '(custom-manual "(gnus)Setting Marks")
188 :type '(choice (const :tag "off" nil)
189 (const never)
190 (sexp :menu-tag "on" t)))
192 (defcustom gnus-summary-default-score 0
193 "*Default article score level.
194 All scores generated by the score files will be added to this score.
195 If this variable is nil, scoring will be disabled."
196 :group 'gnus-score-default
197 :type '(choice (const :tag "disable")
198 integer))
200 (defcustom gnus-summary-zcore-fuzz 0
201 "*Fuzziness factor for the zcore in the summary buffer.
202 Articles with scores closer than this to `gnus-summary-default-score'
203 will not be marked."
204 :group 'gnus-summary-format
205 :type 'integer)
207 (defcustom gnus-simplify-subject-fuzzy-regexp nil
208 "*Strings to be removed when doing fuzzy matches.
209 This can either be a regular expression or list of regular expressions
210 that will be removed from subject strings if fuzzy subject
211 simplification is selected."
212 :group 'gnus-thread
213 :type '(repeat regexp))
215 (defcustom gnus-show-threads t
216 "*If non-nil, display threads in summary mode."
217 :group 'gnus-thread
218 :type 'boolean)
220 (defcustom gnus-thread-hide-subtree nil
221 "*If non-nil, hide all threads initially.
222 If threads are hidden, you have to run the command
223 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
224 to expose hidden threads."
225 :group 'gnus-thread
226 :type 'boolean)
228 (defcustom gnus-thread-hide-killed t
229 "*If non-nil, hide killed threads automatically."
230 :group 'gnus-thread
231 :type 'boolean)
233 (defcustom gnus-thread-ignore-subject t
234 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
235 If nil, articles that have different subjects from their parents will
236 start separate threads."
237 :group 'gnus-thread
238 :type 'boolean)
240 (defcustom gnus-thread-operation-ignore-subject t
241 "*If non-nil, subjects will be ignored when doing thread commands.
242 This affects commands like `gnus-summary-kill-thread' and
243 `gnus-summary-lower-thread'.
245 If this variable is nil, articles in the same thread with different
246 subjects will not be included in the operation in question. If this
247 variable is `fuzzy', only articles that have subjects that are fuzzily
248 equal will be included."
249 :group 'gnus-thread
250 :type '(choice (const :tag "off" nil)
251 (const fuzzy)
252 (sexp :tag "on" t)))
254 (defcustom gnus-thread-indent-level 4
255 "*Number that says how much each sub-thread should be indented."
256 :group 'gnus-thread
257 :type 'integer)
259 (defcustom gnus-auto-extend-newsgroup t
260 "*If non-nil, extend newsgroup forward and backward when requested."
261 :group 'gnus-summary-choose
262 :type 'boolean)
264 (defcustom gnus-auto-select-first t
265 "*If nil, don't select the first unread article when entering a group.
266 If this variable is `best', select the highest-scored unread article
267 in the group. If t, select the first unread article.
269 This variable can also be a function to place point on a likely
270 subject line. Useful values include `gnus-summary-first-unread-subject',
271 `gnus-summary-first-unread-article' and
272 `gnus-summary-best-unread-article'.
274 If you want to prevent automatic selection of the first unread article
275 in some newsgroups, set the variable to nil in
276 `gnus-select-group-hook'."
277 :group 'gnus-group-select
278 :type '(choice (const :tag "none" nil)
279 (const best)
280 (sexp :menu-tag "first" t)
281 (function-item gnus-summary-first-unread-subject)
282 (function-item gnus-summary-first-unread-article)
283 (function-item gnus-summary-best-unread-article)))
285 (defcustom gnus-auto-select-next t
286 "*If non-nil, offer to go to the next group from the end of the previous.
287 If the value is t and the next newsgroup is empty, Gnus will exit
288 summary mode and go back to group mode. If the value is neither nil
289 nor t, Gnus will select the following unread newsgroup. In
290 particular, if the value is the symbol `quietly', the next unread
291 newsgroup will be selected without any confirmation, and if it is
292 `almost-quietly', the next group will be selected without any
293 confirmation if you are located on the last article in the group.
294 Finally, if this variable is `slightly-quietly', the `Z n' command
295 will go to the next group without confirmation."
296 :group 'gnus-summary-maneuvering
297 :type '(choice (const :tag "off" nil)
298 (const quietly)
299 (const almost-quietly)
300 (const slightly-quietly)
301 (sexp :menu-tag "on" t)))
303 (defcustom gnus-auto-select-same nil
304 "*If non-nil, select the next article with the same subject.
305 If there are no more articles with the same subject, go to
306 the first unread article."
307 :group 'gnus-summary-maneuvering
308 :type 'boolean)
310 (defcustom gnus-summary-check-current nil
311 "*If non-nil, consider the current article when moving.
312 The \"unread\" movement commands will stay on the same line if the
313 current article is unread."
314 :group 'gnus-summary-maneuvering
315 :type 'boolean)
317 (defcustom gnus-auto-center-summary t
318 "*If non-nil, always center the current summary buffer.
319 In particular, if `vertical' do only vertical recentering. If non-nil
320 and non-`vertical', do both horizontal and vertical recentering."
321 :group 'gnus-summary-maneuvering
322 :type '(choice (const :tag "none" nil)
323 (const vertical)
324 (integer :tag "height")
325 (sexp :menu-tag "both" t)))
327 (defcustom gnus-show-all-headers nil
328 "*If non-nil, don't hide any headers."
329 :group 'gnus-article-hiding
330 :group 'gnus-article-headers
331 :type 'boolean)
333 (defcustom gnus-summary-ignore-duplicates nil
334 "*If non-nil, ignore articles with identical Message-ID headers."
335 :group 'gnus-summary
336 :type 'boolean)
338 (defcustom gnus-single-article-buffer t
339 "*If non-nil, display all articles in the same buffer.
340 If nil, each group will get its own article buffer."
341 :group 'gnus-article-various
342 :type 'boolean)
344 (defcustom gnus-break-pages t
345 "*If non-nil, do page breaking on articles.
346 The page delimiter is specified by the `gnus-page-delimiter'
347 variable."
348 :group 'gnus-article-various
349 :type 'boolean)
351 (defcustom gnus-move-split-methods nil
352 "*Variable used to suggest where articles are to be moved to.
353 It uses the same syntax as the `gnus-split-methods' variable."
354 :group 'gnus-summary-mail
355 :type '(repeat (choice (list :value (fun) function)
356 (cons :value ("" "") regexp (repeat string))
357 (sexp :value nil))))
359 (defcustom gnus-unread-mark ? ;Whitespace
360 "*Mark used for unread articles."
361 :group 'gnus-summary-marks
362 :type 'character)
364 (defcustom gnus-ticked-mark ?!
365 "*Mark used for ticked articles."
366 :group 'gnus-summary-marks
367 :type 'character)
369 (defcustom gnus-dormant-mark ??
370 "*Mark used for dormant articles."
371 :group 'gnus-summary-marks
372 :type 'character)
374 (defcustom gnus-del-mark ?r
375 "*Mark used for del'd articles."
376 :group 'gnus-summary-marks
377 :type 'character)
379 (defcustom gnus-read-mark ?R
380 "*Mark used for read articles."
381 :group 'gnus-summary-marks
382 :type 'character)
384 (defcustom gnus-expirable-mark ?E
385 "*Mark used for expirable articles."
386 :group 'gnus-summary-marks
387 :type 'character)
389 (defcustom gnus-killed-mark ?K
390 "*Mark used for killed articles."
391 :group 'gnus-summary-marks
392 :type 'character)
394 (defcustom gnus-souped-mark ?F
395 "*Mark used for killed articles."
396 :group 'gnus-summary-marks
397 :type 'character)
399 (defcustom gnus-kill-file-mark ?X
400 "*Mark used for articles killed by kill files."
401 :group 'gnus-summary-marks
402 :type 'character)
404 (defcustom gnus-low-score-mark ?Y
405 "*Mark used for articles with a low score."
406 :group 'gnus-summary-marks
407 :type 'character)
409 (defcustom gnus-catchup-mark ?C
410 "*Mark used for articles that are caught up."
411 :group 'gnus-summary-marks
412 :type 'character)
414 (defcustom gnus-replied-mark ?A
415 "*Mark used for articles that have been replied to."
416 :group 'gnus-summary-marks
417 :type 'character)
419 (defcustom gnus-cached-mark ?*
420 "*Mark used for articles that are in the cache."
421 :group 'gnus-summary-marks
422 :type 'character)
424 (defcustom gnus-saved-mark ?S
425 "*Mark used for articles that have been saved to."
426 :group 'gnus-summary-marks
427 :type 'character)
429 (defcustom gnus-ancient-mark ?O
430 "*Mark used for ancient articles."
431 :group 'gnus-summary-marks
432 :type 'character)
434 (defcustom gnus-sparse-mark ?Q
435 "*Mark used for sparsely reffed articles."
436 :group 'gnus-summary-marks
437 :type 'character)
439 (defcustom gnus-canceled-mark ?G
440 "*Mark used for canceled articles."
441 :group 'gnus-summary-marks
442 :type 'character)
444 (defcustom gnus-duplicate-mark ?M
445 "*Mark used for duplicate articles."
446 :group 'gnus-summary-marks
447 :type 'character)
449 (defcustom gnus-undownloaded-mark ?@
450 "*Mark used for articles that weren't downloaded."
451 :group 'gnus-summary-marks
452 :type 'character)
454 (defcustom gnus-downloadable-mark ?%
455 "*Mark used for articles that are to be downloaded."
456 :group 'gnus-summary-marks
457 :type 'character)
459 (defcustom gnus-unsendable-mark ?=
460 "*Mark used for articles that won't be sent."
461 :group 'gnus-summary-marks
462 :type 'character)
464 (defcustom gnus-score-over-mark ?+
465 "*Score mark used for articles with high scores."
466 :group 'gnus-summary-marks
467 :type 'character)
469 (defcustom gnus-score-below-mark ?-
470 "*Score mark used for articles with low scores."
471 :group 'gnus-summary-marks
472 :type 'character)
474 (defcustom gnus-empty-thread-mark ? ;Whitespace
475 "*There is no thread under the article."
476 :group 'gnus-summary-marks
477 :type 'character)
479 (defcustom gnus-not-empty-thread-mark ?=
480 "*There is a thread under the article."
481 :group 'gnus-summary-marks
482 :type 'character)
484 (defcustom gnus-view-pseudo-asynchronously nil
485 "*If non-nil, Gnus will view pseudo-articles asynchronously."
486 :group 'gnus-extract-view
487 :type 'boolean)
489 (defcustom gnus-auto-expirable-marks
490 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
491 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
492 gnus-souped-mark gnus-duplicate-mark)
493 "*The list of marks converted into expiration if a group is auto-expirable."
494 :version "21.1"
495 :group 'gnus-summary
496 :type '(repeat character))
498 (defcustom gnus-inhibit-user-auto-expire t
499 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
500 :version "21.1"
501 :group 'gnus-summary
502 :type 'boolean)
504 (defcustom gnus-view-pseudos nil
505 "*If `automatic', pseudo-articles will be viewed automatically.
506 If `not-confirm', pseudos will be viewed automatically, and the user
507 will not be asked to confirm the command."
508 :group 'gnus-extract-view
509 :type '(choice (const :tag "off" nil)
510 (const automatic)
511 (const not-confirm)))
513 (defcustom gnus-view-pseudos-separately t
514 "*If non-nil, one pseudo-article will be created for each file to be viewed.
515 If nil, all files that use the same viewing command will be given as a
516 list of parameters to that command."
517 :group 'gnus-extract-view
518 :type 'boolean)
520 (defcustom gnus-insert-pseudo-articles t
521 "*If non-nil, insert pseudo-articles when decoding articles."
522 :group 'gnus-extract-view
523 :type 'boolean)
525 (defcustom gnus-summary-dummy-line-format
526 " %(: :%) %S\n"
527 "*The format specification for the dummy roots in the summary buffer.
528 It works along the same lines as a normal formatting string,
529 with some simple extensions.
531 %S The subject"
532 :group 'gnus-threading
533 :type 'string)
535 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
536 "*The format specification for the summary mode line.
537 It works along the same lines as a normal formatting string,
538 with some simple extensions:
540 %G Group name
541 %p Unprefixed group name
542 %A Current article number
543 %z Current article score
544 %V Gnus version
545 %U Number of unread articles in the group
546 %e Number of unselected articles in the group
547 %Z A string with unread/unselected article counts
548 %g Shortish group name
549 %S Subject of the current article
550 %u User-defined spec
551 %s Current score file name
552 %d Number of dormant articles
553 %r Number of articles that have been marked as read in this session
554 %E Number of articles expunged by the score files"
555 :group 'gnus-summary-format
556 :type 'string)
558 (defcustom gnus-list-identifiers nil
559 "Regexp that matches list identifiers to be removed from subject.
560 This can also be a list of regexps."
561 :version "21.1"
562 :group 'gnus-summary-format
563 :group 'gnus-article-hiding
564 :type '(choice (const :tag "none" nil)
565 (regexp :value ".*")
566 (repeat :value (".*") regexp)))
568 (defcustom gnus-summary-mark-below 0
569 "*Mark all articles with a score below this variable as read.
570 This variable is local to each summary buffer and usually set by the
571 score file."
572 :group 'gnus-score-default
573 :type 'integer)
575 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
576 "*List of functions used for sorting articles in the summary buffer.
577 This variable is only used when not using a threaded display."
578 :group 'gnus-summary-sort
579 :type '(repeat (choice (function-item gnus-article-sort-by-number)
580 (function-item gnus-article-sort-by-author)
581 (function-item gnus-article-sort-by-subject)
582 (function-item gnus-article-sort-by-date)
583 (function-item gnus-article-sort-by-score)
584 (function :tag "other"))))
586 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
587 "*List of functions used for sorting threads in the summary buffer.
588 By default, threads are sorted by article number.
590 Each function takes two threads and return non-nil if the first thread
591 should be sorted before the other. If you use more than one function,
592 the primary sort function should be the last. You should probably
593 always include `gnus-thread-sort-by-number' in the list of sorting
594 functions -- preferably first.
596 Ready-made functions include `gnus-thread-sort-by-number',
597 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
598 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
599 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
600 :group 'gnus-summary-sort
601 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
602 (function-item gnus-thread-sort-by-author)
603 (function-item gnus-thread-sort-by-subject)
604 (function-item gnus-thread-sort-by-date)
605 (function-item gnus-thread-sort-by-score)
606 (function-item gnus-thread-sort-by-total-score)
607 (function :tag "other"))))
609 (defcustom gnus-thread-score-function '+
610 "*Function used for calculating the total score of a thread.
612 The function is called with the scores of the article and each
613 subthread and should then return the score of the thread.
615 Some functions you can use are `+', `max', or `min'."
616 :group 'gnus-summary-sort
617 :type 'function)
619 (defcustom gnus-summary-expunge-below nil
620 "All articles that have a score less than this variable will be expunged.
621 This variable is local to the summary buffers."
622 :group 'gnus-score-default
623 :type '(choice (const :tag "off" nil)
624 integer))
626 (defcustom gnus-thread-expunge-below nil
627 "All threads that have a total score less than this variable will be expunged.
628 See `gnus-thread-score-function' for en explanation of what a
629 \"thread score\" is.
631 This variable is local to the summary buffers."
632 :group 'gnus-threading
633 :group 'gnus-score-default
634 :type '(choice (const :tag "off" nil)
635 integer))
637 (defcustom gnus-summary-mode-hook nil
638 "*A hook for Gnus summary mode.
639 This hook is run before any variables are set in the summary buffer."
640 :options '(turn-on-gnus-mailing-list-mode)
641 :group 'gnus-summary-various
642 :type 'hook)
644 (defcustom gnus-summary-menu-hook nil
645 "*Hook run after the creation of the summary mode menu."
646 :group 'gnus-summary-visual
647 :type 'hook)
649 (defcustom gnus-summary-exit-hook nil
650 "*A hook called on exit from the summary buffer.
651 It will be called with point in the group buffer."
652 :group 'gnus-summary-exit
653 :type 'hook)
655 (defcustom gnus-summary-prepare-hook nil
656 "*A hook called after the summary buffer has been generated.
657 If you want to modify the summary buffer, you can use this hook."
658 :group 'gnus-summary-various
659 :type 'hook)
661 (defcustom gnus-summary-prepared-hook nil
662 "*A hook called as the last thing after the summary buffer has been generated."
663 :group 'gnus-summary-various
664 :type 'hook)
666 (defcustom gnus-summary-generate-hook nil
667 "*A hook run just before generating the summary buffer.
668 This hook is commonly used to customize threading variables and the
669 like."
670 :group 'gnus-summary-various
671 :type 'hook)
673 (defcustom gnus-select-group-hook nil
674 "*A hook called when a newsgroup is selected.
676 If you'd like to simplify subjects like the
677 `gnus-summary-next-same-subject' command does, you can use the
678 following hook:
680 (setq gnus-select-group-hook
681 (list
682 (lambda ()
683 (mapcar (lambda (header)
684 (mail-header-set-subject
685 header
686 (gnus-simplify-subject
687 (mail-header-subject header) 're-only)))
688 gnus-newsgroup-headers))))"
689 :group 'gnus-group-select
690 :type 'hook)
692 (defcustom gnus-select-article-hook nil
693 "*A hook called when an article is selected."
694 :group 'gnus-summary-choose
695 :type 'hook)
697 (defcustom gnus-visual-mark-article-hook
698 (list 'gnus-highlight-selected-summary)
699 "*Hook run after selecting an article in the summary buffer.
700 It is meant to be used for highlighting the article in some way. It
701 is not run if `gnus-visual' is nil."
702 :group 'gnus-summary-visual
703 :type 'hook)
705 (defcustom gnus-parse-headers-hook nil
706 "*A hook called before parsing the headers."
707 :group 'gnus-various
708 :type 'hook)
710 (defcustom gnus-exit-group-hook nil
711 "*A hook called when exiting summary mode.
712 This hook is not called from the non-updating exit commands like `Q'."
713 :group 'gnus-various
714 :type 'hook)
716 (defcustom gnus-summary-update-hook
717 (list 'gnus-summary-highlight-line)
718 "*A hook called when a summary line is changed.
719 The hook will not be called if `gnus-visual' is nil.
721 The default function `gnus-summary-highlight-line' will
722 highlight the line according to the `gnus-summary-highlight'
723 variable."
724 :group 'gnus-summary-visual
725 :type 'hook)
727 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
728 "*A hook called when an article is selected for the first time.
729 The hook is intended to mark an article as read (or unread)
730 automatically when it is selected."
731 :group 'gnus-summary-choose
732 :type 'hook)
734 (defcustom gnus-group-no-more-groups-hook nil
735 "*A hook run when returning to group mode having no more (unread) groups."
736 :group 'gnus-group-select
737 :type 'hook)
739 (defcustom gnus-ps-print-hook nil
740 "*A hook run before ps-printing something from Gnus."
741 :group 'gnus-summary
742 :type 'hook)
744 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
745 "Face used for highlighting the current article in the summary buffer."
746 :group 'gnus-summary-visual
747 :type 'face)
749 (defcustom gnus-summary-highlight
750 '(((= mark gnus-canceled-mark)
751 . gnus-summary-cancelled-face)
752 ((and (> score default)
753 (or (= mark gnus-dormant-mark)
754 (= mark gnus-ticked-mark)))
755 . gnus-summary-high-ticked-face)
756 ((and (< score default)
757 (or (= mark gnus-dormant-mark)
758 (= mark gnus-ticked-mark)))
759 . gnus-summary-low-ticked-face)
760 ((or (= mark gnus-dormant-mark)
761 (= mark gnus-ticked-mark))
762 . gnus-summary-normal-ticked-face)
763 ((and (> score default) (= mark gnus-ancient-mark))
764 . gnus-summary-high-ancient-face)
765 ((and (< score default) (= mark gnus-ancient-mark))
766 . gnus-summary-low-ancient-face)
767 ((= mark gnus-ancient-mark)
768 . gnus-summary-normal-ancient-face)
769 ((and (> score default) (= mark gnus-unread-mark))
770 . gnus-summary-high-unread-face)
771 ((and (< score default) (= mark gnus-unread-mark))
772 . gnus-summary-low-unread-face)
773 ((= mark gnus-unread-mark)
774 . gnus-summary-normal-unread-face)
775 ((and (> score default) (memq mark (list gnus-downloadable-mark
776 gnus-undownloaded-mark)))
777 . gnus-summary-high-unread-face)
778 ((and (< score default) (memq mark (list gnus-downloadable-mark
779 gnus-undownloaded-mark)))
780 . gnus-summary-low-unread-face)
781 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
782 . gnus-summary-normal-unread-face)
783 ((> score default)
784 . gnus-summary-high-read-face)
785 ((< score default)
786 . gnus-summary-low-read-face)
788 . gnus-summary-normal-read-face))
789 "*Controls the highlighting of summary buffer lines.
791 A list of (FORM . FACE) pairs. When deciding how a particular summary
792 line should be displayed, each form is evaluated. The content of the
793 face field after the first true form is used. You can change how those
794 summary lines are displayed, by editing the face field.
796 You can use the following variables in the FORM field.
798 score: The articles score
799 default: The default article score.
800 below: The score below which articles are automatically marked as read.
801 mark: The articles mark."
802 :group 'gnus-summary-visual
803 :type '(repeat (cons (sexp :tag "Form" nil)
804 face)))
806 (defcustom gnus-alter-header-function nil
807 "Function called to allow alteration of article header structures.
808 The function is called with one parameter, the article header vector,
809 which it may alter in any way."
810 :type '(choice (const :tag "None" nil)
811 function)
812 :group 'gnus-summary)
814 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
815 "Variable that says which function should be used to decode a string with encoded words.")
817 (defcustom gnus-extra-headers nil
818 "*Extra headers to parse."
819 :version "21.1"
820 :group 'gnus-summary
821 :type '(repeat symbol))
823 (defcustom gnus-ignored-from-addresses
824 (and user-mail-address (regexp-quote user-mail-address))
825 "*Regexp of From headers that may be suppressed in favor of To headers."
826 :version "21.1"
827 :group 'gnus-summary
828 :type 'regexp)
830 (defcustom gnus-group-charset-alist
831 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
832 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
833 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
834 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
835 ("^relcom\\>" koi8-r)
836 ("^fido7\\>" koi8-r)
837 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
838 ("^israel\\>" iso-8859-1)
839 ("^han\\>" euc-kr)
840 ("^alt.chinese.text.big5\\>" chinese-big5)
841 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
842 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
843 (".*" iso-8859-1))
844 "Alist of regexps (to match group names) and default charsets to be used when reading."
845 :type '(repeat (list (regexp :tag "Group")
846 (symbol :tag "Charset")))
847 :group 'gnus-charset)
849 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
850 "List of charsets that should be ignored.
851 When these charsets are used in the \"charset\" parameter, the
852 default charset will be used instead."
853 :version "21.1"
854 :type '(repeat symbol)
855 :group 'gnus-charset)
857 (defcustom gnus-group-ignored-charsets-alist
858 '(("alt\\.chinese\\.text" iso-8859-1))
859 "Alist of regexps (to match group names) and charsets that should be ignored.
860 When these charsets are used in the \"charset\" parameter, the
861 default charset will be used instead."
862 :type '(repeat (cons (regexp :tag "Group")
863 (repeat symbol)))
864 :group 'gnus-charset)
866 (defcustom gnus-group-highlight-words-alist nil
867 "Alist of group regexps and highlight regexps.
868 This variable uses the same syntax as `gnus-emphasis-alist'."
869 :version "21.1"
870 :type '(repeat (cons (regexp :tag "Group")
871 (repeat (list (regexp :tag "Highlight regexp")
872 (number :tag "Group for entire word" 0)
873 (number :tag "Group for displayed part" 0)
874 (symbol :tag "Face"
875 gnus-emphasis-highlight-words)))))
876 :group 'gnus-summary-visual)
878 (defcustom gnus-summary-show-article-charset-alist
880 "Alist of number and charset.
881 The article will be shown with the charset corresponding to the
882 numbered argument.
883 For example: ((1 . cn-gb-2312) (2 . big5))."
884 :version "21.1"
885 :type '(repeat (cons (number :tag "Argument" 1)
886 (symbol :tag "Charset")))
887 :group 'gnus-charset)
889 (defcustom gnus-preserve-marks t
890 "Whether marks are preserved when moving, copying and respooling messages."
891 :version "21.1"
892 :type 'boolean
893 :group 'gnus-summary-marks)
895 (defcustom gnus-alter-articles-to-read-function nil
896 "Function to be called to alter the list of articles to be selected."
897 :type '(choice (const nil) function)
898 :group 'gnus-summary)
900 (defcustom gnus-orphan-score nil
901 "*All orphans get this score added. Set in the score file."
902 :group 'gnus-score-default
903 :type '(choice (const nil)
904 integer))
906 (defcustom gnus-summary-save-parts-default-mime "image/.*"
907 "*A regexp to match MIME parts when saving multiple parts of a message
908 with gnus-summary-save-parts (X m). This regexp will be used by default
909 when prompting the user for which type of files to save."
910 :group 'gnus-summary
911 :type 'regexp)
914 ;;; Internal variables
916 (defvar gnus-article-mime-handles nil)
917 (defvar gnus-article-decoded-p nil)
918 (defvar gnus-scores-exclude-files nil)
919 (defvar gnus-page-broken nil)
920 (defvar gnus-inhibit-mime-unbuttonizing nil)
922 (defvar gnus-original-article nil)
923 (defvar gnus-article-internal-prepare-hook nil)
924 (defvar gnus-newsgroup-process-stack nil)
926 (defvar gnus-thread-indent-array nil)
927 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
928 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
929 "Function called to sort the articles within a thread after it has been gathered together.")
931 (defvar gnus-summary-save-parts-type-history nil)
932 (defvar gnus-summary-save-parts-last-directory nil)
934 ;; Avoid highlighting in kill files.
935 (defvar gnus-summary-inhibit-highlight nil)
936 (defvar gnus-newsgroup-selected-overlay nil)
937 (defvar gnus-inhibit-limiting nil)
938 (defvar gnus-newsgroup-adaptive-score-file nil)
939 (defvar gnus-current-score-file nil)
940 (defvar gnus-current-move-group nil)
941 (defvar gnus-current-copy-group nil)
942 (defvar gnus-current-crosspost-group nil)
944 (defvar gnus-newsgroup-dependencies nil)
945 (defvar gnus-newsgroup-adaptive nil)
946 (defvar gnus-summary-display-article-function nil)
947 (defvar gnus-summary-highlight-line-function nil
948 "Function called after highlighting a summary line.")
950 (defvar gnus-summary-line-format-alist
951 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
952 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
953 (?s gnus-tmp-subject-or-nil ?s)
954 (?n gnus-tmp-name ?s)
955 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
957 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
958 gnus-tmp-from) ?s)
959 (?F gnus-tmp-from ?s)
960 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
961 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
962 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
963 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
964 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
965 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
966 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
967 (?L gnus-tmp-lines ?d)
968 (?I gnus-tmp-indentation ?s)
969 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
970 (?R gnus-tmp-replied ?c)
971 (?\[ gnus-tmp-opening-bracket ?c)
972 (?\] gnus-tmp-closing-bracket ?c)
973 (?\> (make-string gnus-tmp-level ? ) ?s)
974 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
975 (?i gnus-tmp-score ?d)
976 (?z gnus-tmp-score-char ?c)
977 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
978 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
979 (?U gnus-tmp-unread ?c)
980 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
981 (?t (gnus-summary-number-of-articles-in-thread
982 (and (boundp 'thread) (car thread)) gnus-tmp-level)
984 (?e (gnus-summary-number-of-articles-in-thread
985 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
987 (?u gnus-tmp-user-defined ?s)
988 (?P (gnus-pick-line-number) ?d))
989 "An alist of format specifications that can appear in summary lines.
990 These are paired with what variables they correspond with, along with
991 the type of the variable (string, integer, character, etc).")
993 (defvar gnus-summary-dummy-line-format-alist
994 `((?S gnus-tmp-subject ?s)
995 (?N gnus-tmp-number ?d)
996 (?u gnus-tmp-user-defined ?s)))
998 (defvar gnus-summary-mode-line-format-alist
999 `((?G gnus-tmp-group-name ?s)
1000 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1001 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1002 (?A gnus-tmp-article-number ?d)
1003 (?Z gnus-tmp-unread-and-unselected ?s)
1004 (?V gnus-version ?s)
1005 (?U gnus-tmp-unread-and-unticked ?d)
1006 (?S gnus-tmp-subject ?s)
1007 (?e gnus-tmp-unselected ?d)
1008 (?u gnus-tmp-user-defined ?s)
1009 (?d (length gnus-newsgroup-dormant) ?d)
1010 (?t (length gnus-newsgroup-marked) ?d)
1011 (?r (length gnus-newsgroup-reads) ?d)
1012 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1013 (?E gnus-newsgroup-expunged-tally ?d)
1014 (?s (gnus-current-score-file-nondirectory) ?s)))
1016 (defvar gnus-last-search-regexp nil
1017 "Default regexp for article search command.")
1019 (defvar gnus-last-shell-command nil
1020 "Default shell command on article.")
1022 (defvar gnus-newsgroup-begin nil)
1023 (defvar gnus-newsgroup-end nil)
1024 (defvar gnus-newsgroup-last-rmail nil)
1025 (defvar gnus-newsgroup-last-mail nil)
1026 (defvar gnus-newsgroup-last-folder nil)
1027 (defvar gnus-newsgroup-last-file nil)
1028 (defvar gnus-newsgroup-auto-expire nil)
1029 (defvar gnus-newsgroup-active nil)
1031 (defvar gnus-newsgroup-data nil)
1032 (defvar gnus-newsgroup-data-reverse nil)
1033 (defvar gnus-newsgroup-limit nil)
1034 (defvar gnus-newsgroup-limits nil)
1036 (defvar gnus-newsgroup-unreads nil
1037 "List of unread articles in the current newsgroup.")
1039 (defvar gnus-newsgroup-unselected nil
1040 "List of unselected unread articles in the current newsgroup.")
1042 (defvar gnus-newsgroup-reads nil
1043 "Alist of read articles and article marks in the current newsgroup.")
1045 (defvar gnus-newsgroup-expunged-tally nil)
1047 (defvar gnus-newsgroup-marked nil
1048 "List of ticked articles in the current newsgroup (a subset of unread art).")
1050 (defvar gnus-newsgroup-killed nil
1051 "List of ranges of articles that have been through the scoring process.")
1053 (defvar gnus-newsgroup-cached nil
1054 "List of articles that come from the article cache.")
1056 (defvar gnus-newsgroup-saved nil
1057 "List of articles that have been saved.")
1059 (defvar gnus-newsgroup-kill-headers nil)
1061 (defvar gnus-newsgroup-replied nil
1062 "List of articles that have been replied to in the current newsgroup.")
1064 (defvar gnus-newsgroup-expirable nil
1065 "List of articles in the current newsgroup that can be expired.")
1067 (defvar gnus-newsgroup-processable nil
1068 "List of articles in the current newsgroup that can be processed.")
1070 (defvar gnus-newsgroup-downloadable nil
1071 "List of articles in the current newsgroup that can be processed.")
1073 (defvar gnus-newsgroup-undownloaded nil
1074 "List of articles in the current newsgroup that haven't been downloaded..")
1076 (defvar gnus-newsgroup-unsendable nil
1077 "List of articles in the current newsgroup that won't be sent.")
1079 (defvar gnus-newsgroup-bookmarks nil
1080 "List of articles in the current newsgroup that have bookmarks.")
1082 (defvar gnus-newsgroup-dormant nil
1083 "List of dormant articles in the current newsgroup.")
1085 (defvar gnus-newsgroup-scored nil
1086 "List of scored articles in the current newsgroup.")
1088 (defvar gnus-newsgroup-headers nil
1089 "List of article headers in the current newsgroup.")
1091 (defvar gnus-newsgroup-threads nil)
1093 (defvar gnus-newsgroup-prepared nil
1094 "Whether the current group has been prepared properly.")
1096 (defvar gnus-newsgroup-ancient nil
1097 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1099 (defvar gnus-newsgroup-sparse nil)
1101 (defvar gnus-current-article nil)
1102 (defvar gnus-article-current nil)
1103 (defvar gnus-current-headers nil)
1104 (defvar gnus-have-all-headers nil)
1105 (defvar gnus-last-article nil)
1106 (defvar gnus-newsgroup-history nil)
1107 (defvar gnus-newsgroup-charset nil)
1108 (defvar gnus-newsgroup-ephemeral-charset nil)
1109 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1111 (defconst gnus-summary-local-variables
1112 '(gnus-newsgroup-name
1113 gnus-newsgroup-begin gnus-newsgroup-end
1114 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1115 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1116 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1117 gnus-newsgroup-unselected gnus-newsgroup-marked
1118 gnus-newsgroup-reads gnus-newsgroup-saved
1119 gnus-newsgroup-replied gnus-newsgroup-expirable
1120 gnus-newsgroup-processable gnus-newsgroup-killed
1121 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1122 gnus-newsgroup-unsendable
1123 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1124 gnus-newsgroup-headers gnus-newsgroup-threads
1125 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1126 gnus-current-article gnus-current-headers gnus-have-all-headers
1127 gnus-last-article gnus-article-internal-prepare-hook
1128 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1129 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1130 gnus-thread-expunge-below
1131 gnus-score-alist gnus-current-score-file
1132 (gnus-summary-expunge-below . global)
1133 (gnus-summary-mark-below . global)
1134 (gnus-orphan-score . global)
1135 gnus-newsgroup-active gnus-scores-exclude-files
1136 gnus-newsgroup-history gnus-newsgroup-ancient
1137 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1138 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1139 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1140 (gnus-newsgroup-expunged-tally . 0)
1141 gnus-cache-removable-articles gnus-newsgroup-cached
1142 gnus-newsgroup-data gnus-newsgroup-data-reverse
1143 gnus-newsgroup-limit gnus-newsgroup-limits
1144 gnus-newsgroup-charset)
1145 "Variables that are buffer-local to the summary buffers.")
1147 ;; Byte-compiler warning.
1148 (eval-when-compile (defvar gnus-article-mode-map))
1150 ;; MIME stuff.
1152 (defvar gnus-decode-encoded-word-methods
1153 '(mail-decode-encoded-word-string)
1154 "List of methods used to decode encoded words.
1156 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1157 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1158 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1159 whose names match REGEXP.
1161 For example:
1162 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1163 mail-decode-encoded-word-string
1164 (\"chinese\" . rfc1843-decode-string))")
1166 (defvar gnus-decode-encoded-word-methods-cache nil)
1168 (defun gnus-multi-decode-encoded-word-string (string)
1169 "Apply the functions from `gnus-encoded-word-methods' that match."
1170 (unless (and gnus-decode-encoded-word-methods-cache
1171 (eq gnus-newsgroup-name
1172 (car gnus-decode-encoded-word-methods-cache)))
1173 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1174 (mapcar (lambda (x)
1175 (if (symbolp x)
1176 (nconc gnus-decode-encoded-word-methods-cache (list x))
1177 (if (and gnus-newsgroup-name
1178 (string-match (car x) gnus-newsgroup-name))
1179 (nconc gnus-decode-encoded-word-methods-cache
1180 (list (cdr x))))))
1181 gnus-decode-encoded-word-methods))
1182 (let ((xlist gnus-decode-encoded-word-methods-cache))
1183 (pop xlist)
1184 (while xlist
1185 (setq string (funcall (pop xlist) string))))
1186 string)
1188 ;; Subject simplification.
1190 (defun gnus-simplify-whitespace (str)
1191 "Remove excessive whitespace from STR."
1192 (let ((mystr str))
1193 ;; Multiple spaces.
1194 (while (string-match "[ \t][ \t]+" mystr)
1195 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1197 (substring mystr (match-end 0)))))
1198 ;; Leading spaces.
1199 (when (string-match "^[ \t]+" mystr)
1200 (setq mystr (substring mystr (match-end 0))))
1201 ;; Trailing spaces.
1202 (when (string-match "[ \t]+$" mystr)
1203 (setq mystr (substring mystr 0 (match-beginning 0))))
1204 mystr))
1206 (defsubst gnus-simplify-subject-re (subject)
1207 "Remove \"Re:\" from subject lines."
1208 (if (string-match "^[Rr][Ee]: *" subject)
1209 (substring subject (match-end 0))
1210 subject))
1212 (defun gnus-simplify-subject (subject &optional re-only)
1213 "Remove `Re:' and words in parentheses.
1214 If RE-ONLY is non-nil, strip leading `Re:'s only."
1215 (let ((case-fold-search t)) ;Ignore case.
1216 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1217 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1218 (setq subject (substring subject (match-end 0))))
1219 ;; Remove uninteresting prefixes.
1220 (when (and (not re-only)
1221 gnus-simplify-ignored-prefixes
1222 (string-match gnus-simplify-ignored-prefixes subject))
1223 (setq subject (substring subject (match-end 0))))
1224 ;; Remove words in parentheses from end.
1225 (unless re-only
1226 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1227 (setq subject (substring subject 0 (match-beginning 0)))))
1228 ;; Return subject string.
1229 subject))
1231 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1232 ;; all whitespace.
1233 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1234 (goto-char (point-min))
1235 (while (re-search-forward regexp nil t)
1236 (replace-match (or newtext ""))))
1238 (defun gnus-simplify-buffer-fuzzy ()
1239 "Simplify string in the buffer fuzzily.
1240 The string in the accessible portion of the current buffer is simplified.
1241 It is assumed to be a single-line subject.
1242 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1243 matter is removed. Additional things can be deleted by setting
1244 `gnus-simplify-subject-fuzzy-regexp'."
1245 (let ((case-fold-search t)
1246 (modified-tick))
1247 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1249 (while (not (eq modified-tick (buffer-modified-tick)))
1250 (setq modified-tick (buffer-modified-tick))
1251 (cond
1252 ((listp gnus-simplify-subject-fuzzy-regexp)
1253 (mapcar 'gnus-simplify-buffer-fuzzy-step
1254 gnus-simplify-subject-fuzzy-regexp))
1255 (gnus-simplify-subject-fuzzy-regexp
1256 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1257 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1258 (gnus-simplify-buffer-fuzzy-step
1259 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1260 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1262 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1263 (gnus-simplify-buffer-fuzzy-step " +" " ")
1264 (gnus-simplify-buffer-fuzzy-step " $")
1265 (gnus-simplify-buffer-fuzzy-step "^ +")))
1267 (defun gnus-simplify-subject-fuzzy (subject)
1268 "Simplify a subject string fuzzily.
1269 See `gnus-simplify-buffer-fuzzy' for details."
1270 (save-excursion
1271 (gnus-set-work-buffer)
1272 (let ((case-fold-search t))
1273 ;; Remove uninteresting prefixes.
1274 (when (and gnus-simplify-ignored-prefixes
1275 (string-match gnus-simplify-ignored-prefixes subject))
1276 (setq subject (substring subject (match-end 0))))
1277 (insert subject)
1278 (inline (gnus-simplify-buffer-fuzzy))
1279 (buffer-string))))
1281 (defsubst gnus-simplify-subject-fully (subject)
1282 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1283 (cond
1284 (gnus-simplify-subject-functions
1285 (gnus-map-function gnus-simplify-subject-functions subject))
1286 ((null gnus-summary-gather-subject-limit)
1287 (gnus-simplify-subject-re subject))
1288 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1289 (gnus-simplify-subject-fuzzy subject))
1290 ((numberp gnus-summary-gather-subject-limit)
1291 (gnus-limit-string (gnus-simplify-subject-re subject)
1292 gnus-summary-gather-subject-limit))
1294 subject)))
1296 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1297 "Check whether two subjects are equal.
1298 If optional argument simple-first is t, first argument is already
1299 simplified."
1300 (cond
1301 ((null simple-first)
1302 (equal (gnus-simplify-subject-fully s1)
1303 (gnus-simplify-subject-fully s2)))
1305 (equal s1
1306 (gnus-simplify-subject-fully s2)))))
1308 (defun gnus-summary-bubble-group ()
1309 "Increase the score of the current group.
1310 This is a handy function to add to `gnus-summary-exit-hook' to
1311 increase the score of each group you read."
1312 (gnus-group-add-score gnus-newsgroup-name))
1316 ;;; Gnus summary mode
1319 (put 'gnus-summary-mode 'mode-class 'special)
1321 (defvar gnus-article-commands-menu)
1323 (when t
1324 ;; Non-orthogonal keys
1326 (gnus-define-keys gnus-summary-mode-map
1327 " " gnus-summary-next-page
1328 "\177" gnus-summary-prev-page
1329 [delete] gnus-summary-prev-page
1330 [backspace] gnus-summary-prev-page
1331 "\r" gnus-summary-scroll-up
1332 "\M-\r" gnus-summary-scroll-down
1333 "n" gnus-summary-next-unread-article
1334 "p" gnus-summary-prev-unread-article
1335 "N" gnus-summary-next-article
1336 "P" gnus-summary-prev-article
1337 "\M-\C-n" gnus-summary-next-same-subject
1338 "\M-\C-p" gnus-summary-prev-same-subject
1339 "\M-n" gnus-summary-next-unread-subject
1340 "\M-p" gnus-summary-prev-unread-subject
1341 "." gnus-summary-first-unread-article
1342 "," gnus-summary-best-unread-article
1343 "\M-s" gnus-summary-search-article-forward
1344 "\M-r" gnus-summary-search-article-backward
1345 "<" gnus-summary-beginning-of-article
1346 ">" gnus-summary-end-of-article
1347 "j" gnus-summary-goto-article
1348 "^" gnus-summary-refer-parent-article
1349 "\M-^" gnus-summary-refer-article
1350 "u" gnus-summary-tick-article-forward
1351 "!" gnus-summary-tick-article-forward
1352 "U" gnus-summary-tick-article-backward
1353 "d" gnus-summary-mark-as-read-forward
1354 "D" gnus-summary-mark-as-read-backward
1355 "E" gnus-summary-mark-as-expirable
1356 "\M-u" gnus-summary-clear-mark-forward
1357 "\M-U" gnus-summary-clear-mark-backward
1358 "k" gnus-summary-kill-same-subject-and-select
1359 "\C-k" gnus-summary-kill-same-subject
1360 "\M-\C-k" gnus-summary-kill-thread
1361 "\M-\C-l" gnus-summary-lower-thread
1362 "e" gnus-summary-edit-article
1363 "#" gnus-summary-mark-as-processable
1364 "\M-#" gnus-summary-unmark-as-processable
1365 "\M-\C-t" gnus-summary-toggle-threads
1366 "\M-\C-s" gnus-summary-show-thread
1367 "\M-\C-h" gnus-summary-hide-thread
1368 "\M-\C-f" gnus-summary-next-thread
1369 "\M-\C-b" gnus-summary-prev-thread
1370 [(meta down)] gnus-summary-next-thread
1371 [(meta up)] gnus-summary-prev-thread
1372 "\M-\C-u" gnus-summary-up-thread
1373 "\M-\C-d" gnus-summary-down-thread
1374 "&" gnus-summary-execute-command
1375 "c" gnus-summary-catchup-and-exit
1376 "\C-w" gnus-summary-mark-region-as-read
1377 "\C-t" gnus-summary-toggle-truncation
1378 "?" gnus-summary-mark-as-dormant
1379 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1380 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1381 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1382 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1383 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1384 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1385 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1386 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1387 "=" gnus-summary-expand-window
1388 "\C-x\C-s" gnus-summary-reselect-current-group
1389 "\M-g" gnus-summary-rescan-group
1390 "w" gnus-summary-stop-page-breaking
1391 "\C-c\C-r" gnus-summary-caesar-message
1392 "f" gnus-summary-followup
1393 "F" gnus-summary-followup-with-original
1394 "C" gnus-summary-cancel-article
1395 "r" gnus-summary-reply
1396 "R" gnus-summary-reply-with-original
1397 "\C-c\C-f" gnus-summary-mail-forward
1398 "o" gnus-summary-save-article
1399 "\C-o" gnus-summary-save-article-mail
1400 "|" gnus-summary-pipe-output
1401 "\M-k" gnus-summary-edit-local-kill
1402 "\M-K" gnus-summary-edit-global-kill
1403 ;; "V" gnus-version
1404 "\C-c\C-d" gnus-summary-describe-group
1405 "q" gnus-summary-exit
1406 "Q" gnus-summary-exit-no-update
1407 "\C-c\C-i" gnus-info-find-node
1408 gnus-mouse-2 gnus-mouse-pick-article
1409 "m" gnus-summary-mail-other-window
1410 "a" gnus-summary-post-news
1411 "x" gnus-summary-limit-to-unread
1412 "s" gnus-summary-isearch-article
1413 "t" gnus-summary-toggle-header
1414 "g" gnus-summary-show-article
1415 "l" gnus-summary-goto-last-article
1416 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1417 "\C-d" gnus-summary-enter-digest-group
1418 "\M-\C-d" gnus-summary-read-document
1419 "\M-\C-e" gnus-summary-edit-parameters
1420 "\M-\C-a" gnus-summary-customize-parameters
1421 "\C-c\C-b" gnus-bug
1422 "*" gnus-cache-enter-article
1423 "\M-*" gnus-cache-remove-article
1424 "\M-&" gnus-summary-universal-argument
1425 "\C-l" gnus-recenter
1426 "I" gnus-summary-increase-score
1427 "L" gnus-summary-lower-score
1428 "\M-i" gnus-symbolic-argument
1429 "h" gnus-summary-select-article-buffer
1431 "b" gnus-article-view-part
1432 "\M-t" gnus-summary-toggle-display-buttonized
1434 "V" gnus-summary-score-map
1435 "X" gnus-uu-extract-map
1436 "S" gnus-summary-send-map)
1438 ;; Sort of orthogonal keymap
1439 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1440 "t" gnus-summary-tick-article-forward
1441 "!" gnus-summary-tick-article-forward
1442 "d" gnus-summary-mark-as-read-forward
1443 "r" gnus-summary-mark-as-read-forward
1444 "c" gnus-summary-clear-mark-forward
1445 " " gnus-summary-clear-mark-forward
1446 "e" gnus-summary-mark-as-expirable
1447 "x" gnus-summary-mark-as-expirable
1448 "?" gnus-summary-mark-as-dormant
1449 "b" gnus-summary-set-bookmark
1450 "B" gnus-summary-remove-bookmark
1451 "#" gnus-summary-mark-as-processable
1452 "\M-#" gnus-summary-unmark-as-processable
1453 "S" gnus-summary-limit-include-expunged
1454 "C" gnus-summary-catchup
1455 "H" gnus-summary-catchup-to-here
1456 "\C-c" gnus-summary-catchup-all
1457 "k" gnus-summary-kill-same-subject-and-select
1458 "K" gnus-summary-kill-same-subject
1459 "P" gnus-uu-mark-map)
1461 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1462 "c" gnus-summary-clear-above
1463 "u" gnus-summary-tick-above
1464 "m" gnus-summary-mark-above
1465 "k" gnus-summary-kill-below)
1467 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1468 "/" gnus-summary-limit-to-subject
1469 "n" gnus-summary-limit-to-articles
1470 "w" gnus-summary-pop-limit
1471 "s" gnus-summary-limit-to-subject
1472 "a" gnus-summary-limit-to-author
1473 "u" gnus-summary-limit-to-unread
1474 "m" gnus-summary-limit-to-marks
1475 "M" gnus-summary-limit-exclude-marks
1476 "v" gnus-summary-limit-to-score
1477 "*" gnus-summary-limit-include-cached
1478 "D" gnus-summary-limit-include-dormant
1479 "T" gnus-summary-limit-include-thread
1480 "d" gnus-summary-limit-exclude-dormant
1481 "t" gnus-summary-limit-to-age
1482 "x" gnus-summary-limit-to-extra
1483 "E" gnus-summary-limit-include-expunged
1484 "c" gnus-summary-limit-exclude-childless-dormant
1485 "C" gnus-summary-limit-mark-excluded-as-read)
1487 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1488 "n" gnus-summary-next-unread-article
1489 "p" gnus-summary-prev-unread-article
1490 "N" gnus-summary-next-article
1491 "P" gnus-summary-prev-article
1492 "\C-n" gnus-summary-next-same-subject
1493 "\C-p" gnus-summary-prev-same-subject
1494 "\M-n" gnus-summary-next-unread-subject
1495 "\M-p" gnus-summary-prev-unread-subject
1496 "f" gnus-summary-first-unread-article
1497 "b" gnus-summary-best-unread-article
1498 "j" gnus-summary-goto-article
1499 "g" gnus-summary-goto-subject
1500 "l" gnus-summary-goto-last-article
1501 "o" gnus-summary-pop-article)
1503 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1504 "k" gnus-summary-kill-thread
1505 "l" gnus-summary-lower-thread
1506 "i" gnus-summary-raise-thread
1507 "T" gnus-summary-toggle-threads
1508 "t" gnus-summary-rethread-current
1509 "^" gnus-summary-reparent-thread
1510 "s" gnus-summary-show-thread
1511 "S" gnus-summary-show-all-threads
1512 "h" gnus-summary-hide-thread
1513 "H" gnus-summary-hide-all-threads
1514 "n" gnus-summary-next-thread
1515 "p" gnus-summary-prev-thread
1516 "u" gnus-summary-up-thread
1517 "o" gnus-summary-top-thread
1518 "d" gnus-summary-down-thread
1519 "#" gnus-uu-mark-thread
1520 "\M-#" gnus-uu-unmark-thread)
1522 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1523 "g" gnus-summary-prepare
1524 "c" gnus-summary-insert-cached-articles)
1526 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1527 "c" gnus-summary-catchup-and-exit
1528 "C" gnus-summary-catchup-all-and-exit
1529 "E" gnus-summary-exit-no-update
1530 "Q" gnus-summary-exit
1531 "Z" gnus-summary-exit
1532 "n" gnus-summary-catchup-and-goto-next-group
1533 "R" gnus-summary-reselect-current-group
1534 "G" gnus-summary-rescan-group
1535 "N" gnus-summary-next-group
1536 "s" gnus-summary-save-newsrc
1537 "P" gnus-summary-prev-group)
1539 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1540 " " gnus-summary-next-page
1541 "n" gnus-summary-next-page
1542 "\177" gnus-summary-prev-page
1543 [delete] gnus-summary-prev-page
1544 "p" gnus-summary-prev-page
1545 "\r" gnus-summary-scroll-up
1546 "\M-\r" gnus-summary-scroll-down
1547 "<" gnus-summary-beginning-of-article
1548 ">" gnus-summary-end-of-article
1549 "b" gnus-summary-beginning-of-article
1550 "e" gnus-summary-end-of-article
1551 "^" gnus-summary-refer-parent-article
1552 "r" gnus-summary-refer-parent-article
1553 "D" gnus-summary-enter-digest-group
1554 "R" gnus-summary-refer-references
1555 "T" gnus-summary-refer-thread
1556 "g" gnus-summary-show-article
1557 "s" gnus-summary-isearch-article
1558 "P" gnus-summary-print-article
1559 "t" gnus-article-babel)
1561 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1562 "b" gnus-article-add-buttons
1563 "B" gnus-article-add-buttons-to-head
1564 "o" gnus-article-treat-overstrike
1565 "e" gnus-article-emphasize
1566 "w" gnus-article-fill-cited-article
1567 "Q" gnus-article-fill-long-lines
1568 "C" gnus-article-capitalize-sentences
1569 "c" gnus-article-remove-cr
1570 "q" gnus-article-de-quoted-unreadable
1571 "6" gnus-article-de-base64-unreadable
1572 "Z" gnus-article-decode-HZ
1573 "h" gnus-article-wash-html
1574 "f" gnus-article-display-x-face
1575 "l" gnus-summary-stop-page-breaking
1576 "r" gnus-summary-caesar-message
1577 "t" gnus-summary-toggle-header
1578 "v" gnus-summary-verbose-headers
1579 "H" gnus-article-strip-headers-in-body
1580 "d" gnus-article-treat-dumbquotes)
1582 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1583 "a" gnus-article-hide
1584 "h" gnus-article-hide-headers
1585 "b" gnus-article-hide-boring-headers
1586 "s" gnus-article-hide-signature
1587 "c" gnus-article-hide-citation
1588 "C" gnus-article-hide-citation-in-followups
1589 "l" gnus-article-hide-list-identifiers
1590 "p" gnus-article-hide-pgp
1591 "B" gnus-article-strip-banner
1592 "P" gnus-article-hide-pem
1593 "\C-c" gnus-article-hide-citation-maybe)
1595 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1596 "a" gnus-article-highlight
1597 "h" gnus-article-highlight-headers
1598 "c" gnus-article-highlight-citation
1599 "s" gnus-article-highlight-signature)
1601 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1602 "w" gnus-article-decode-mime-words
1603 "c" gnus-article-decode-charset
1604 "v" gnus-mime-view-all-parts
1605 "b" gnus-article-view-part)
1607 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1608 "z" gnus-article-date-ut
1609 "u" gnus-article-date-ut
1610 "l" gnus-article-date-local
1611 "e" gnus-article-date-lapsed
1612 "o" gnus-article-date-original
1613 "i" gnus-article-date-iso8601
1614 "s" gnus-article-date-user)
1616 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1617 "t" gnus-article-remove-trailing-blank-lines
1618 "l" gnus-article-strip-leading-blank-lines
1619 "m" gnus-article-strip-multiple-blank-lines
1620 "a" gnus-article-strip-blank-lines
1621 "A" gnus-article-strip-all-blank-lines
1622 "s" gnus-article-strip-leading-space
1623 "e" gnus-article-strip-trailing-space)
1625 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1626 "v" gnus-version
1627 "f" gnus-summary-fetch-faq
1628 "d" gnus-summary-describe-group
1629 "h" gnus-summary-describe-briefly
1630 "i" gnus-info-find-node)
1632 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1633 "e" gnus-summary-expire-articles
1634 "\M-\C-e" gnus-summary-expire-articles-now
1635 "\177" gnus-summary-delete-article
1636 [delete] gnus-summary-delete-article
1637 [backspace] gnus-summary-delete-article
1638 "m" gnus-summary-move-article
1639 "r" gnus-summary-respool-article
1640 "w" gnus-summary-edit-article
1641 "c" gnus-summary-copy-article
1642 "B" gnus-summary-crosspost-article
1643 "q" gnus-summary-respool-query
1644 "t" gnus-summary-respool-trace
1645 "i" gnus-summary-import-article
1646 "p" gnus-summary-article-posted-p)
1648 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1649 "o" gnus-summary-save-article
1650 "m" gnus-summary-save-article-mail
1651 "F" gnus-summary-write-article-file
1652 "r" gnus-summary-save-article-rmail
1653 "f" gnus-summary-save-article-file
1654 "b" gnus-summary-save-article-body-file
1655 "h" gnus-summary-save-article-folder
1656 "v" gnus-summary-save-article-vm
1657 "p" gnus-summary-pipe-output
1658 "s" gnus-soup-add-article)
1660 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1661 "b" gnus-summary-display-buttonized
1662 "m" gnus-summary-repair-multipart
1663 "v" gnus-article-view-part
1664 "o" gnus-article-save-part
1665 "c" gnus-article-copy-part
1666 "e" gnus-article-externalize-part
1667 "i" gnus-article-inline-part
1668 "|" gnus-article-pipe-part))
1670 (defun gnus-summary-make-menu-bar ()
1671 (gnus-turn-off-edit-menu 'summary)
1673 (unless (boundp 'gnus-summary-misc-menu)
1675 (easy-menu-define
1676 gnus-summary-kill-menu gnus-summary-mode-map ""
1677 (cons
1678 "Score"
1679 (nconc
1680 (list
1681 ["Enter score..." gnus-summary-score-entry t]
1682 ["Customize" gnus-score-customize t])
1683 (gnus-make-score-map 'increase)
1684 (gnus-make-score-map 'lower)
1685 '(("Mark"
1686 ["Kill below" gnus-summary-kill-below t]
1687 ["Mark above" gnus-summary-mark-above t]
1688 ["Tick above" gnus-summary-tick-above t]
1689 ["Clear above" gnus-summary-clear-above t])
1690 ["Current score" gnus-summary-current-score t]
1691 ["Set score" gnus-summary-set-score t]
1692 ["Switch current score file..." gnus-score-change-score-file t]
1693 ["Set mark below..." gnus-score-set-mark-below t]
1694 ["Set expunge below..." gnus-score-set-expunge-below t]
1695 ["Edit current score file" gnus-score-edit-current-scores t]
1696 ["Edit score file" gnus-score-edit-file t]
1697 ["Trace score" gnus-score-find-trace t]
1698 ["Find words" gnus-score-find-favourite-words t]
1699 ["Rescore buffer" gnus-summary-rescore t]
1700 ["Increase score..." gnus-summary-increase-score t]
1701 ["Lower score..." gnus-summary-lower-score t]))))
1703 ;; Define both the Article menu in the summary buffer and the equivalent
1704 ;; Commands menu in the article buffer here for consistency.
1705 (let ((innards
1706 '(("Hide"
1707 ["All" gnus-article-hide t]
1708 ["Headers" gnus-article-hide-headers t]
1709 ["Signature" gnus-article-hide-signature t]
1710 ["Citation" gnus-article-hide-citation t]
1711 ["List identifiers" gnus-article-hide-list-identifiers t]
1712 ["PGP" gnus-article-hide-pgp t]
1713 ["Banner" gnus-article-strip-banner t]
1714 ["Boring headers" gnus-article-hide-boring-headers t])
1715 ("Highlight"
1716 ["All" gnus-article-highlight t]
1717 ["Headers" gnus-article-highlight-headers t]
1718 ["Signature" gnus-article-highlight-signature t]
1719 ["Citation" gnus-article-highlight-citation t])
1720 ("MIME"
1721 ["Words" gnus-article-decode-mime-words t]
1722 ["Charset" gnus-article-decode-charset t]
1723 ["QP" gnus-article-de-quoted-unreadable t]
1724 ["Base64" gnus-article-de-base64-unreadable t]
1725 ["View all" gnus-mime-view-all-parts t])
1726 ("Date"
1727 ["Local" gnus-article-date-local t]
1728 ["ISO8601" gnus-article-date-iso8601 t]
1729 ["UT" gnus-article-date-ut t]
1730 ["Original" gnus-article-date-original t]
1731 ["Lapsed" gnus-article-date-lapsed t]
1732 ["User-defined" gnus-article-date-user t])
1733 ("Washing"
1734 ("Remove Blanks"
1735 ["Leading" gnus-article-strip-leading-blank-lines t]
1736 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1737 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1738 ["All of the above" gnus-article-strip-blank-lines t]
1739 ["All" gnus-article-strip-all-blank-lines t]
1740 ["Leading space" gnus-article-strip-leading-space t]
1741 ["Trailing space" gnus-article-strip-trailing-space t])
1742 ["Overstrike" gnus-article-treat-overstrike t]
1743 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1744 ["Emphasis" gnus-article-emphasize t]
1745 ["Word wrap" gnus-article-fill-cited-article t]
1746 ["Fill long lines" gnus-article-fill-long-lines t]
1747 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1748 ["CR" gnus-article-remove-cr t]
1749 ["Show X-Face" gnus-article-display-x-face t]
1750 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1751 ["Base64" gnus-article-de-base64-unreadable t]
1752 ["Rot 13" gnus-summary-caesar-message
1753 :help "\"Caesar rotate\" article by 13"]
1754 ["Unix pipe" gnus-summary-pipe-message t]
1755 ["Add buttons" gnus-article-add-buttons t]
1756 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1757 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1758 ["Verbose header" gnus-summary-verbose-headers t]
1759 ["Toggle header" gnus-summary-toggle-header t]
1760 ["Html" gnus-article-wash-html t]
1761 ["HZ" gnus-article-decode-HZ t])
1762 ("Output"
1763 ["Save in default format" gnus-summary-save-article
1764 :help "Save article using default method"]
1765 ["Save in file" gnus-summary-save-article-file
1766 :help "Save article in file"]
1767 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1768 ["Save in MH folder" gnus-summary-save-article-folder t]
1769 ["Save in VM folder" gnus-summary-save-article-vm t]
1770 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1771 ["Save body in file" gnus-summary-save-article-body-file t]
1772 ["Pipe through a filter" gnus-summary-pipe-output t]
1773 ["Add to SOUP packet" gnus-soup-add-article t]
1774 ["Print" gnus-summary-print-article t])
1775 ("Backend"
1776 ["Respool article..." gnus-summary-respool-article t]
1777 ["Move article..." gnus-summary-move-article
1778 (gnus-check-backend-function
1779 'request-move-article gnus-newsgroup-name)]
1780 ["Copy article..." gnus-summary-copy-article t]
1781 ["Crosspost article..." gnus-summary-crosspost-article
1782 (gnus-check-backend-function
1783 'request-replace-article gnus-newsgroup-name)]
1784 ["Import file..." gnus-summary-import-article t]
1785 ["Check if posted" gnus-summary-article-posted-p t]
1786 ["Edit article" gnus-summary-edit-article
1787 (not (gnus-group-read-only-p))]
1788 ["Delete article" gnus-summary-delete-article
1789 (gnus-check-backend-function
1790 'request-expire-articles gnus-newsgroup-name)]
1791 ["Query respool" gnus-summary-respool-query t]
1792 ["Trace respool" gnus-summary-respool-trace t]
1793 ["Delete expirable articles" gnus-summary-expire-articles-now
1794 (gnus-check-backend-function
1795 'request-expire-articles gnus-newsgroup-name)])
1796 ("Extract"
1797 ["Uudecode" gnus-uu-decode-uu
1798 :help "Decode uuencoded article(s)"]
1799 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1800 ["Unshar" gnus-uu-decode-unshar t]
1801 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1802 ["Save" gnus-uu-decode-save t]
1803 ["Binhex" gnus-uu-decode-binhex t]
1804 ["Postscript" gnus-uu-decode-postscript t])
1805 ("Cache"
1806 ["Enter article" gnus-cache-enter-article t]
1807 ["Remove article" gnus-cache-remove-article t])
1808 ["Translate" gnus-article-babel t]
1809 ["Select article buffer" gnus-summary-select-article-buffer t]
1810 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1811 ["Isearch article..." gnus-summary-isearch-article t]
1812 ["Beginning of the article" gnus-summary-beginning-of-article t]
1813 ["End of the article" gnus-summary-end-of-article t]
1814 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1815 ["Fetch referenced articles" gnus-summary-refer-references t]
1816 ["Fetch current thread" gnus-summary-refer-thread t]
1817 ["Fetch article with id..." gnus-summary-refer-article t]
1818 ["Redisplay" gnus-summary-show-article t])))
1819 (easy-menu-define
1820 gnus-summary-article-menu gnus-summary-mode-map ""
1821 (cons "Article" innards))
1823 (if (not (keymapp gnus-summary-article-menu))
1824 (easy-menu-define
1825 gnus-article-commands-menu gnus-article-mode-map ""
1826 (cons "Commands" innards))
1827 ;; in Emacs, don't share menu.
1828 (setq gnus-article-commands-menu
1829 (copy-keymap gnus-summary-article-menu))
1830 (define-key gnus-article-mode-map [menu-bar commands]
1831 (cons "Commands" gnus-article-commands-menu))))
1833 (easy-menu-define
1834 gnus-summary-thread-menu gnus-summary-mode-map ""
1835 '("Threads"
1836 ["Toggle threading" gnus-summary-toggle-threads t]
1837 ["Hide threads" gnus-summary-hide-all-threads t]
1838 ["Show threads" gnus-summary-show-all-threads t]
1839 ["Hide thread" gnus-summary-hide-thread t]
1840 ["Show thread" gnus-summary-show-thread t]
1841 ["Go to next thread" gnus-summary-next-thread t]
1842 ["Go to previous thread" gnus-summary-prev-thread t]
1843 ["Go down thread" gnus-summary-down-thread t]
1844 ["Go up thread" gnus-summary-up-thread t]
1845 ["Top of thread" gnus-summary-top-thread t]
1846 ["Mark thread as read" gnus-summary-kill-thread t]
1847 ["Lower thread score" gnus-summary-lower-thread t]
1848 ["Raise thread score" gnus-summary-raise-thread t]
1849 ["Rethread current" gnus-summary-rethread-current t]))
1851 (easy-menu-define
1852 gnus-summary-post-menu gnus-summary-mode-map ""
1853 '("Post"
1854 ["Post an article" gnus-summary-post-news
1855 :help "Post an article"]
1856 ["Followup" gnus-summary-followup
1857 :help "Post followup to this article"]
1858 ["Followup and yank" gnus-summary-followup-with-original
1859 :help "Post followup to this article, quoting its contents"]
1860 ["Supersede article" gnus-summary-supersede-article t]
1861 ["Cancel article" gnus-summary-cancel-article
1862 :help "Cancel an article you posted"]
1863 ["Reply" gnus-summary-reply t]
1864 ["Reply and yank" gnus-summary-reply-with-original t]
1865 ["Wide reply" gnus-summary-wide-reply t]
1866 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1867 :help "Mail a reply, quoting this article"]
1868 ["Mail forward" gnus-summary-mail-forward t]
1869 ["Post forward" gnus-summary-post-forward t]
1870 ["Digest and mail" gnus-uu-digest-mail-forward t]
1871 ["Digest and post" gnus-uu-digest-post-forward t]
1872 ["Resend message" gnus-summary-resend-message t]
1873 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1874 ["Send a mail" gnus-summary-mail-other-window t]
1875 ["Uuencode and post" gnus-uu-post-news
1876 :help "Post a uuencoded article"]
1877 ["Followup via news" gnus-summary-followup-to-mail t]
1878 ["Followup via news and yank"
1879 gnus-summary-followup-to-mail-with-original t]
1880 ;;("Draft"
1881 ;;["Send" gnus-summary-send-draft t]
1882 ;;["Send bounced" gnus-resend-bounced-mail t])
1885 (easy-menu-define
1886 gnus-summary-misc-menu gnus-summary-mode-map ""
1887 '("Misc"
1888 ("Mark Read"
1889 ["Mark as read" gnus-summary-mark-as-read-forward t]
1890 ["Mark same subject and select"
1891 gnus-summary-kill-same-subject-and-select t]
1892 ["Mark same subject" gnus-summary-kill-same-subject t]
1893 ["Catchup" gnus-summary-catchup
1894 :help "Mark unread articles in this group as read"]
1895 ["Catchup all" gnus-summary-catchup-all t]
1896 ["Catchup to here" gnus-summary-catchup-to-here t]
1897 ["Catchup region" gnus-summary-mark-region-as-read t]
1898 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1899 ("Mark Various"
1900 ["Tick" gnus-summary-tick-article-forward t]
1901 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1902 ["Remove marks" gnus-summary-clear-mark-forward t]
1903 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1904 ["Set bookmark" gnus-summary-set-bookmark t]
1905 ["Remove bookmark" gnus-summary-remove-bookmark t])
1906 ("Mark Limit"
1907 ["Marks..." gnus-summary-limit-to-marks t]
1908 ["Subject..." gnus-summary-limit-to-subject t]
1909 ["Author..." gnus-summary-limit-to-author t]
1910 ["Age..." gnus-summary-limit-to-age t]
1911 ["Extra..." gnus-summary-limit-to-extra t]
1912 ["Score" gnus-summary-limit-to-score t]
1913 ["Unread" gnus-summary-limit-to-unread t]
1914 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1915 ["Articles" gnus-summary-limit-to-articles t]
1916 ["Pop limit" gnus-summary-pop-limit t]
1917 ["Show dormant" gnus-summary-limit-include-dormant t]
1918 ["Hide childless dormant"
1919 gnus-summary-limit-exclude-childless-dormant t]
1920 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1921 ["Hide marked" gnus-summary-limit-exclude-marks t]
1922 ["Show expunged" gnus-summary-show-all-expunged t])
1923 ("Process Mark"
1924 ["Set mark" gnus-summary-mark-as-processable t]
1925 ["Remove mark" gnus-summary-unmark-as-processable t]
1926 ["Remove all marks" gnus-summary-unmark-all-processable t]
1927 ["Mark above" gnus-uu-mark-over t]
1928 ["Mark series" gnus-uu-mark-series t]
1929 ["Mark region" gnus-uu-mark-region t]
1930 ["Unmark region" gnus-uu-unmark-region t]
1931 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1932 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1933 ["Mark all" gnus-uu-mark-all t]
1934 ["Mark buffer" gnus-uu-mark-buffer t]
1935 ["Mark sparse" gnus-uu-mark-sparse t]
1936 ["Mark thread" gnus-uu-mark-thread t]
1937 ["Unmark thread" gnus-uu-unmark-thread t]
1938 ("Process Mark Sets"
1939 ["Kill" gnus-summary-kill-process-mark t]
1940 ["Yank" gnus-summary-yank-process-mark
1941 gnus-newsgroup-process-stack]
1942 ["Save" gnus-summary-save-process-mark t]))
1943 ("Scroll article"
1944 ["Page forward" gnus-summary-next-page
1945 :help "Show next page of article"]
1946 ["Page backward" gnus-summary-prev-page
1947 :help "Show previous page of article"]
1948 ["Line forward" gnus-summary-scroll-up t])
1949 ("Move"
1950 ["Next unread article" gnus-summary-next-unread-article t]
1951 ["Previous unread article" gnus-summary-prev-unread-article t]
1952 ["Next article" gnus-summary-next-article t]
1953 ["Previous article" gnus-summary-prev-article t]
1954 ["Next unread subject" gnus-summary-next-unread-subject t]
1955 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1956 ["Next article same subject" gnus-summary-next-same-subject t]
1957 ["Previous article same subject" gnus-summary-prev-same-subject t]
1958 ["First unread article" gnus-summary-first-unread-article t]
1959 ["Best unread article" gnus-summary-best-unread-article t]
1960 ["Go to subject number..." gnus-summary-goto-subject t]
1961 ["Go to article number..." gnus-summary-goto-article t]
1962 ["Go to the last article" gnus-summary-goto-last-article t]
1963 ["Pop article off history" gnus-summary-pop-article t])
1964 ("Sort"
1965 ["Sort by number" gnus-summary-sort-by-number t]
1966 ["Sort by author" gnus-summary-sort-by-author t]
1967 ["Sort by subject" gnus-summary-sort-by-subject t]
1968 ["Sort by date" gnus-summary-sort-by-date t]
1969 ["Sort by score" gnus-summary-sort-by-score t]
1970 ["Sort by lines" gnus-summary-sort-by-lines t]
1971 ["Sort by characters" gnus-summary-sort-by-chars t])
1972 ("Help"
1973 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1974 ["Describe group" gnus-summary-describe-group t]
1975 ["Read manual" gnus-info-find-node t])
1976 ("Modes"
1977 ["Pick and read" gnus-pick-mode t]
1978 ["Binary" gnus-binary-mode t])
1979 ("Regeneration"
1980 ["Regenerate" gnus-summary-prepare t]
1981 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1982 ["Toggle threading" gnus-summary-toggle-threads t])
1983 ["Filter articles..." gnus-summary-execute-command t]
1984 ["Run command on subjects..." gnus-summary-universal-argument t]
1985 ["Search articles forward..." gnus-summary-search-article-forward t]
1986 ["Search articles backward..." gnus-summary-search-article-backward t]
1987 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1988 ["Expand window" gnus-summary-expand-window t]
1989 ["Expire expirable articles" gnus-summary-expire-articles
1990 (gnus-check-backend-function
1991 'request-expire-articles gnus-newsgroup-name)]
1992 ["Edit local kill file" gnus-summary-edit-local-kill t]
1993 ["Edit main kill file" gnus-summary-edit-global-kill t]
1994 ["Edit group parameters" gnus-summary-edit-parameters t]
1995 ["Customize group parameters" gnus-summary-customize-parameters t]
1996 ["Send a bug report" gnus-bug t]
1997 ("Exit"
1998 ["Catchup and exit" gnus-summary-catchup-and-exit
1999 :help "Mark unread articles in this group as read, then exit"]
2000 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2001 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2002 ["Exit group" gnus-summary-exit
2003 :help "Exit current group, return to group selection mode"]
2004 ["Exit group without updating" gnus-summary-exit-no-update t]
2005 ["Exit and goto next group" gnus-summary-next-group t]
2006 ["Exit and goto prev group" gnus-summary-prev-group t]
2007 ["Reselect group" gnus-summary-reselect-current-group t]
2008 ["Rescan group" gnus-summary-rescan-group t]
2009 ["Update dribble" gnus-summary-save-newsrc t])))
2011 (gnus-run-hooks 'gnus-summary-menu-hook)))
2013 (defvar gnus-summary-tool-bar-map nil)
2015 ;; Emacs 21 tool bar. Should be no-op otherwise.
2016 ;; NB: A new function tool-bar-local-item-from-menu is added in Emacs
2017 ;; 21.2.50+. Considering many users use Emacs 21, use
2018 ;; tool-bar-add-item-from-menu here.
2019 (defun gnus-summary-make-tool-bar ()
2020 (if (and
2021 (condition-case nil (require 'tool-bar) (error nil))
2022 (fboundp 'tool-bar-add-item-from-menu)
2023 (default-value 'tool-bar-mode)
2024 (not gnus-summary-tool-bar-map))
2025 (setq gnus-summary-tool-bar-map
2026 (let ((tool-bar-map (make-sparse-keymap)))
2027 (tool-bar-add-item-from-menu
2028 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2029 (tool-bar-add-item-from-menu
2030 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2031 (tool-bar-add-item-from-menu
2032 'gnus-summary-post-news "post" gnus-summary-mode-map)
2033 (tool-bar-add-item-from-menu
2034 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2035 (tool-bar-add-item-from-menu
2036 'gnus-summary-followup "followup" gnus-summary-mode-map)
2037 (tool-bar-add-item-from-menu
2038 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2039 (tool-bar-add-item-from-menu
2040 'gnus-summary-reply "reply" gnus-summary-mode-map)
2041 (tool-bar-add-item-from-menu
2042 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2043 (tool-bar-add-item-from-menu
2044 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2045 (tool-bar-add-item-from-menu
2046 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2047 (tool-bar-add-item-from-menu
2048 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2049 (tool-bar-add-item-from-menu
2050 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2051 (tool-bar-add-item-from-menu
2052 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2053 (tool-bar-add-item-from-menu
2054 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2055 (tool-bar-add-item-from-menu
2056 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2057 tool-bar-map)))
2058 (if gnus-summary-tool-bar-map
2059 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2061 (defun gnus-score-set-default (var value)
2062 "A version of set that updates the GNU Emacs menu-bar."
2063 (set var value)
2064 ;; It is the message that forces the active status to be updated.
2065 (message ""))
2067 (defun gnus-make-score-map (type)
2068 "Make a summary score map of type TYPE."
2069 (if t
2071 (let ((headers '(("author" "from" string)
2072 ("subject" "subject" string)
2073 ("article body" "body" string)
2074 ("article head" "head" string)
2075 ("xref" "xref" string)
2076 ("extra header" "extra" string)
2077 ("lines" "lines" number)
2078 ("followups to author" "followup" string)))
2079 (types '((number ("less than" <)
2080 ("greater than" >)
2081 ("equal" =))
2082 (string ("substring" s)
2083 ("exact string" e)
2084 ("fuzzy string" f)
2085 ("regexp" r))))
2086 (perms '(("temporary" (current-time-string))
2087 ("permanent" nil)
2088 ("immediate" now)))
2089 header)
2090 (list
2091 (apply
2092 'nconc
2093 (list
2094 (if (eq type 'lower)
2095 "Lower score"
2096 "Increase score"))
2097 (let (outh)
2098 (while headers
2099 (setq header (car headers))
2100 (setq outh
2101 (cons
2102 (apply
2103 'nconc
2104 (list (car header))
2105 (let ((ts (cdr (assoc (nth 2 header) types)))
2106 outt)
2107 (while ts
2108 (setq outt
2109 (cons
2110 (apply
2111 'nconc
2112 (list (caar ts))
2113 (let ((ps perms)
2114 outp)
2115 (while ps
2116 (setq outp
2117 (cons
2118 (vector
2119 (caar ps)
2120 (list
2121 'gnus-summary-score-entry
2122 (nth 1 header)
2123 (if (or (string= (nth 1 header)
2124 "head")
2125 (string= (nth 1 header)
2126 "body"))
2128 (list 'gnus-summary-header
2129 (nth 1 header)))
2130 (list 'quote (nth 1 (car ts)))
2131 (list 'gnus-score-delta-default
2132 nil)
2133 (nth 1 (car ps))
2136 outp))
2137 (setq ps (cdr ps)))
2138 (list (nreverse outp))))
2139 outt))
2140 (setq ts (cdr ts)))
2141 (list (nreverse outt))))
2142 outh))
2143 (setq headers (cdr headers)))
2144 (list (nreverse outh))))))))
2148 (defun gnus-summary-mode (&optional group)
2149 "Major mode for reading articles.
2151 All normal editing commands are switched off.
2152 \\<gnus-summary-mode-map>
2153 Each line in this buffer represents one article. To read an
2154 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2155 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2156 respectively.
2158 You can also post articles and send mail from this buffer. To
2159 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2160 of an article, type `\\[gnus-summary-reply]'.
2162 There are approx. one gazillion commands you can execute in this
2163 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2165 The following commands are available:
2167 \\{gnus-summary-mode-map}"
2168 (interactive)
2169 (kill-all-local-variables)
2170 (when (gnus-visual-p 'summary-menu 'menu)
2171 (gnus-summary-make-menu-bar)
2172 (gnus-summary-make-tool-bar))
2173 (gnus-summary-make-local-variables)
2174 (gnus-make-thread-indent-array)
2175 (gnus-simplify-mode-line)
2176 (setq major-mode 'gnus-summary-mode)
2177 (setq mode-name "Summary")
2178 (make-local-variable 'minor-mode-alist)
2179 (use-local-map gnus-summary-mode-map)
2180 (buffer-disable-undo)
2181 (setq buffer-read-only t) ;Disable modification
2182 (setq truncate-lines t)
2183 (setq selective-display t)
2184 (setq selective-display-ellipses t) ;Display `...'
2185 (gnus-summary-set-display-table)
2186 (gnus-set-default-directory)
2187 (setq gnus-newsgroup-name group)
2188 (make-local-variable 'gnus-summary-line-format)
2189 (make-local-variable 'gnus-summary-line-format-spec)
2190 (make-local-variable 'gnus-summary-dummy-line-format)
2191 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2192 (make-local-variable 'gnus-summary-mark-positions)
2193 (make-local-hook 'pre-command-hook)
2194 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2195 (gnus-run-hooks 'gnus-summary-mode-hook)
2196 (mm-enable-multibyte)
2197 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2198 (gnus-update-summary-mark-positions))
2200 (defun gnus-summary-make-local-variables ()
2201 "Make all the local summary buffer variables."
2202 (let (global)
2203 (dolist (local gnus-summary-local-variables)
2204 (if (consp local)
2205 (progn
2206 (if (eq (cdr local) 'global)
2207 ;; Copy the global value of the variable.
2208 (setq global (symbol-value (car local)))
2209 ;; Use the value from the list.
2210 (setq global (eval (cdr local))))
2211 (set (make-local-variable (car local)) global))
2212 ;; Simple nil-valued local variable.
2213 (set (make-local-variable local) nil)))))
2215 (defun gnus-summary-clear-local-variables ()
2216 (let ((locals gnus-summary-local-variables))
2217 (while locals
2218 (if (consp (car locals))
2219 (and (vectorp (caar locals))
2220 (set (caar locals) nil))
2221 (and (vectorp (car locals))
2222 (set (car locals) nil)))
2223 (setq locals (cdr locals)))))
2225 ;; Summary data functions.
2227 (defmacro gnus-data-number (data)
2228 `(car ,data))
2230 (defmacro gnus-data-set-number (data number)
2231 `(setcar ,data ,number))
2233 (defmacro gnus-data-mark (data)
2234 `(nth 1 ,data))
2236 (defmacro gnus-data-set-mark (data mark)
2237 `(setcar (nthcdr 1 ,data) ,mark))
2239 (defmacro gnus-data-pos (data)
2240 `(nth 2 ,data))
2242 (defmacro gnus-data-set-pos (data pos)
2243 `(setcar (nthcdr 2 ,data) ,pos))
2245 (defmacro gnus-data-header (data)
2246 `(nth 3 ,data))
2248 (defmacro gnus-data-set-header (data header)
2249 `(setf (nth 3 ,data) ,header))
2251 (defmacro gnus-data-level (data)
2252 `(nth 4 ,data))
2254 (defmacro gnus-data-unread-p (data)
2255 `(= (nth 1 ,data) gnus-unread-mark))
2257 (defmacro gnus-data-read-p (data)
2258 `(/= (nth 1 ,data) gnus-unread-mark))
2260 (defmacro gnus-data-pseudo-p (data)
2261 `(consp (nth 3 ,data)))
2263 (defmacro gnus-data-find (number)
2264 `(assq ,number gnus-newsgroup-data))
2266 (defmacro gnus-data-find-list (number &optional data)
2267 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2268 (memq (assq ,number bdata)
2269 bdata)))
2271 (defmacro gnus-data-make (number mark pos header level)
2272 `(list ,number ,mark ,pos ,header ,level))
2274 (defun gnus-data-enter (after-article number mark pos header level offset)
2275 (let ((data (gnus-data-find-list after-article)))
2276 (unless data
2277 (error "No such article: %d" after-article))
2278 (setcdr data (cons (gnus-data-make number mark pos header level)
2279 (cdr data)))
2280 (setq gnus-newsgroup-data-reverse nil)
2281 (gnus-data-update-list (cddr data) offset)))
2283 (defun gnus-data-enter-list (after-article list &optional offset)
2284 (when list
2285 (let ((data (and after-article (gnus-data-find-list after-article)))
2286 (ilist list))
2287 (if (not (or data
2288 after-article))
2289 (let ((odata gnus-newsgroup-data))
2290 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2291 (when offset
2292 (gnus-data-update-list odata offset)))
2293 ;; Find the last element in the list to be spliced into the main
2294 ;; list.
2295 (while (cdr list)
2296 (setq list (cdr list)))
2297 (if (not data)
2298 (progn
2299 (setcdr list gnus-newsgroup-data)
2300 (setq gnus-newsgroup-data ilist)
2301 (when offset
2302 (gnus-data-update-list (cdr list) offset)))
2303 (setcdr list (cdr data))
2304 (setcdr data ilist)
2305 (when offset
2306 (gnus-data-update-list (cdr list) offset))))
2307 (setq gnus-newsgroup-data-reverse nil))))
2309 (defun gnus-data-remove (article &optional offset)
2310 (let ((data gnus-newsgroup-data))
2311 (if (= (gnus-data-number (car data)) article)
2312 (progn
2313 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2314 gnus-newsgroup-data-reverse nil)
2315 (when offset
2316 (gnus-data-update-list gnus-newsgroup-data offset)))
2317 (while (cdr data)
2318 (when (= (gnus-data-number (cadr data)) article)
2319 (setcdr data (cddr data))
2320 (when offset
2321 (gnus-data-update-list (cdr data) offset))
2322 (setq data nil
2323 gnus-newsgroup-data-reverse nil))
2324 (setq data (cdr data))))))
2326 (defmacro gnus-data-list (backward)
2327 `(if ,backward
2328 (or gnus-newsgroup-data-reverse
2329 (setq gnus-newsgroup-data-reverse
2330 (reverse gnus-newsgroup-data)))
2331 gnus-newsgroup-data))
2333 (defun gnus-data-update-list (data offset)
2334 "Add OFFSET to the POS of all data entries in DATA."
2335 (setq gnus-newsgroup-data-reverse nil)
2336 (while data
2337 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2338 (setq data (cdr data))))
2340 (defun gnus-summary-article-pseudo-p (article)
2341 "Say whether this article is a pseudo article or not."
2342 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2344 (defmacro gnus-summary-article-sparse-p (article)
2345 "Say whether this article is a sparse article or not."
2346 `(memq ,article gnus-newsgroup-sparse))
2348 (defmacro gnus-summary-article-ancient-p (article)
2349 "Say whether this article is a sparse article or not."
2350 `(memq ,article gnus-newsgroup-ancient))
2352 (defun gnus-article-parent-p (number)
2353 "Say whether this article is a parent or not."
2354 (let ((data (gnus-data-find-list number)))
2355 (and (cdr data) ; There has to be an article after...
2356 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2357 (gnus-data-level (nth 1 data))))))
2359 (defun gnus-article-children (number)
2360 "Return a list of all children to NUMBER."
2361 (let* ((data (gnus-data-find-list number))
2362 (level (gnus-data-level (car data)))
2363 children)
2364 (setq data (cdr data))
2365 (while (and data
2366 (= (gnus-data-level (car data)) (1+ level)))
2367 (push (gnus-data-number (car data)) children)
2368 (setq data (cdr data)))
2369 children))
2371 (defmacro gnus-summary-skip-intangible ()
2372 "If the current article is intangible, then jump to a different article."
2373 '(let ((to (get-text-property (point) 'gnus-intangible)))
2374 (and to (gnus-summary-goto-subject to))))
2376 (defmacro gnus-summary-article-intangible-p ()
2377 "Say whether this article is intangible or not."
2378 '(get-text-property (point) 'gnus-intangible))
2380 (defun gnus-article-read-p (article)
2381 "Say whether ARTICLE is read or not."
2382 (not (or (memq article gnus-newsgroup-marked)
2383 (memq article gnus-newsgroup-unreads)
2384 (memq article gnus-newsgroup-unselected)
2385 (memq article gnus-newsgroup-dormant))))
2387 ;; Some summary mode macros.
2389 (defmacro gnus-summary-article-number ()
2390 "The article number of the article on the current line.
2391 If there isn't an article number here, then we return the current
2392 article number."
2393 '(progn
2394 (gnus-summary-skip-intangible)
2395 (or (get-text-property (point) 'gnus-number)
2396 (gnus-summary-last-subject))))
2398 (defmacro gnus-summary-article-header (&optional number)
2399 "Return the header of article NUMBER."
2400 `(gnus-data-header (gnus-data-find
2401 ,(or number '(gnus-summary-article-number)))))
2403 (defmacro gnus-summary-thread-level (&optional number)
2404 "Return the level of thread that starts with article NUMBER."
2405 `(if (and (eq gnus-summary-make-false-root 'dummy)
2406 (get-text-property (point) 'gnus-intangible))
2408 (gnus-data-level (gnus-data-find
2409 ,(or number '(gnus-summary-article-number))))))
2411 (defmacro gnus-summary-article-mark (&optional number)
2412 "Return the mark of article NUMBER."
2413 `(gnus-data-mark (gnus-data-find
2414 ,(or number '(gnus-summary-article-number)))))
2416 (defmacro gnus-summary-article-pos (&optional number)
2417 "Return the position of the line of article NUMBER."
2418 `(gnus-data-pos (gnus-data-find
2419 ,(or number '(gnus-summary-article-number)))))
2421 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2422 (defmacro gnus-summary-article-subject (&optional number)
2423 "Return current subject string or nil if nothing."
2424 `(let ((headers
2425 ,(if number
2426 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2427 '(gnus-data-header (assq (gnus-summary-article-number)
2428 gnus-newsgroup-data)))))
2429 (and headers
2430 (vectorp headers)
2431 (mail-header-subject headers))))
2433 (defmacro gnus-summary-article-score (&optional number)
2434 "Return current article score."
2435 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2436 gnus-newsgroup-scored))
2437 gnus-summary-default-score 0))
2439 (defun gnus-summary-article-children (&optional number)
2440 "Return a list of article numbers that are children of article NUMBER."
2441 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2442 (level (gnus-data-level (car data)))
2443 l children)
2444 (while (and (setq data (cdr data))
2445 (> (setq l (gnus-data-level (car data))) level))
2446 (and (= (1+ level) l)
2447 (push (gnus-data-number (car data))
2448 children)))
2449 (nreverse children)))
2451 (defun gnus-summary-article-parent (&optional number)
2452 "Return the article number of the parent of article NUMBER."
2453 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2454 (gnus-data-list t)))
2455 (level (gnus-data-level (car data))))
2456 (if (zerop level)
2457 () ; This is a root.
2458 ;; We search until we find an article with a level less than
2459 ;; this one. That function has to be the parent.
2460 (while (and (setq data (cdr data))
2461 (not (< (gnus-data-level (car data)) level))))
2462 (and data (gnus-data-number (car data))))))
2464 (defun gnus-unread-mark-p (mark)
2465 "Say whether MARK is the unread mark."
2466 (= mark gnus-unread-mark))
2468 (defun gnus-read-mark-p (mark)
2469 "Say whether MARK is one of the marks that mark as read.
2470 This is all marks except unread, ticked, dormant, and expirable."
2471 (not (or (= mark gnus-unread-mark)
2472 (= mark gnus-ticked-mark)
2473 (= mark gnus-dormant-mark)
2474 (= mark gnus-expirable-mark))))
2476 (defmacro gnus-article-mark (number)
2477 "Return the MARK of article NUMBER.
2478 This macro should only be used when computing the mark the \"first\"
2479 time; i.e., when generating the summary lines. After that,
2480 `gnus-summary-article-mark' should be used to examine the
2481 marks of articles."
2482 `(cond
2483 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2484 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2485 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2486 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2487 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2488 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2489 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2490 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2491 gnus-ancient-mark))))
2493 ;; Saving hidden threads.
2495 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2496 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2498 (defmacro gnus-save-hidden-threads (&rest forms)
2499 "Save hidden threads, eval FORMS, and restore the hidden threads."
2500 (let ((config (make-symbol "config")))
2501 `(let ((,config (gnus-hidden-threads-configuration)))
2502 (unwind-protect
2503 (save-excursion
2504 ,@forms)
2505 (gnus-restore-hidden-threads-configuration ,config)))))
2507 (defun gnus-data-compute-positions ()
2508 "Compute the positions of all articles."
2509 (setq gnus-newsgroup-data-reverse nil)
2510 (let ((data gnus-newsgroup-data))
2511 (save-excursion
2512 (gnus-save-hidden-threads
2513 (gnus-summary-show-all-threads)
2514 (goto-char (point-min))
2515 (while data
2516 (while (get-text-property (point) 'gnus-intangible)
2517 (forward-line 1))
2518 (gnus-data-set-pos (car data) (+ (point) 3))
2519 (setq data (cdr data))
2520 (forward-line 1))))))
2522 (defun gnus-hidden-threads-configuration ()
2523 "Return the current hidden threads configuration."
2524 (save-excursion
2525 (let (config)
2526 (goto-char (point-min))
2527 (while (search-forward "\r" nil t)
2528 (push (1- (point)) config))
2529 config)))
2531 (defun gnus-restore-hidden-threads-configuration (config)
2532 "Restore hidden threads configuration from CONFIG."
2533 (save-excursion
2534 (let (point buffer-read-only)
2535 (while (setq point (pop config))
2536 (when (and (< point (point-max))
2537 (goto-char point)
2538 (eq (char-after) ?\n))
2539 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2541 ;; Various summary mode internalish functions.
2543 (defun gnus-mouse-pick-article (e)
2544 (interactive "e")
2545 (mouse-set-point e)
2546 (gnus-summary-next-page nil t))
2548 (defun gnus-summary-set-display-table ()
2549 "Change the display table.
2550 Odd characters have a tendency to mess
2551 up nicely formatted displays - we make all possible glyphs
2552 display only a single character."
2554 ;; We start from the standard display table, if any.
2555 (let ((table (or (copy-sequence standard-display-table)
2556 (make-display-table)))
2557 (i 32))
2558 ;; Nix out all the control chars...
2559 (while (>= (setq i (1- i)) 0)
2560 (aset table i [??]))
2561 ;; ... but not newline and cr, of course. (cr is necessary for the
2562 ;; selective display).
2563 (aset table ?\n nil)
2564 (aset table ?\r nil)
2565 ;; We keep TAB as well.
2566 (aset table ?\t nil)
2567 ;; We nix out any glyphs over 126 that are not set already.
2568 (let ((i 256))
2569 (while (>= (setq i (1- i)) 127)
2570 ;; Only modify if the entry is nil.
2571 (unless (aref table i)
2572 (aset table i [??]))))
2573 (setq buffer-display-table table)))
2575 (defun gnus-summary-setup-buffer (group)
2576 "Initialize summary buffer."
2577 (let ((buffer (concat "*Summary " group "*")))
2578 (if (get-buffer buffer)
2579 (progn
2580 (set-buffer buffer)
2581 (setq gnus-summary-buffer (current-buffer))
2582 (not gnus-newsgroup-prepared))
2583 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2584 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2585 (gnus-summary-mode group)
2586 (when gnus-carpal
2587 (gnus-carpal-setup-buffer 'summary))
2588 (unless gnus-single-article-buffer
2589 (make-local-variable 'gnus-article-buffer)
2590 (make-local-variable 'gnus-article-current)
2591 (make-local-variable 'gnus-original-article-buffer))
2592 (setq gnus-newsgroup-name group)
2593 t)))
2595 (defun gnus-set-global-variables ()
2596 "Set the global equivalents of the buffer-local variables.
2597 They are set to the latest values they had. These reflect the summary
2598 buffer that was in action when the last article was fetched."
2599 (when (eq major-mode 'gnus-summary-mode)
2600 (setq gnus-summary-buffer (current-buffer))
2601 (let ((name gnus-newsgroup-name)
2602 (marked gnus-newsgroup-marked)
2603 (unread gnus-newsgroup-unreads)
2604 (headers gnus-current-headers)
2605 (data gnus-newsgroup-data)
2606 (summary gnus-summary-buffer)
2607 (article-buffer gnus-article-buffer)
2608 (original gnus-original-article-buffer)
2609 (gac gnus-article-current)
2610 (reffed gnus-reffed-article-number)
2611 (score-file gnus-current-score-file)
2612 (default-charset gnus-newsgroup-charset))
2613 (save-excursion
2614 (set-buffer gnus-group-buffer)
2615 (setq gnus-newsgroup-name name
2616 gnus-newsgroup-marked marked
2617 gnus-newsgroup-unreads unread
2618 gnus-current-headers headers
2619 gnus-newsgroup-data data
2620 gnus-article-current gac
2621 gnus-summary-buffer summary
2622 gnus-article-buffer article-buffer
2623 gnus-original-article-buffer original
2624 gnus-reffed-article-number reffed
2625 gnus-current-score-file score-file
2626 gnus-newsgroup-charset default-charset)
2627 ;; The article buffer also has local variables.
2628 (when (gnus-buffer-live-p gnus-article-buffer)
2629 (set-buffer gnus-article-buffer)
2630 (setq gnus-summary-buffer summary))))))
2632 (defun gnus-summary-article-unread-p (article)
2633 "Say whether ARTICLE is unread or not."
2634 (memq article gnus-newsgroup-unreads))
2636 (defun gnus-summary-first-article-p (&optional article)
2637 "Return whether ARTICLE is the first article in the buffer."
2638 (if (not (setq article (or article (gnus-summary-article-number))))
2640 (eq article (caar gnus-newsgroup-data))))
2642 (defun gnus-summary-last-article-p (&optional article)
2643 "Return whether ARTICLE is the last article in the buffer."
2644 (if (not (setq article (or article (gnus-summary-article-number))))
2645 ;; All non-existent numbers are the last article. :-)
2647 (not (cdr (gnus-data-find-list article)))))
2649 (defun gnus-make-thread-indent-array ()
2650 (let ((n 200))
2651 (unless (and gnus-thread-indent-array
2652 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2653 (setq gnus-thread-indent-array (make-vector 201 "")
2654 gnus-thread-indent-array-level gnus-thread-indent-level)
2655 (while (>= n 0)
2656 (aset gnus-thread-indent-array n
2657 (make-string (* n gnus-thread-indent-level) ? ))
2658 (setq n (1- n))))))
2660 (defun gnus-update-summary-mark-positions ()
2661 "Compute where the summary marks are to go."
2662 (save-excursion
2663 (when (gnus-buffer-exists-p gnus-summary-buffer)
2664 (set-buffer gnus-summary-buffer))
2665 (let ((gnus-replied-mark 129)
2666 (gnus-score-below-mark 130)
2667 (gnus-score-over-mark 130)
2668 (gnus-download-mark 131)
2669 (spec gnus-summary-line-format-spec)
2670 gnus-visual pos)
2671 (save-excursion
2672 (gnus-set-work-buffer)
2673 (let ((gnus-summary-line-format-spec spec)
2674 (gnus-newsgroup-downloadable '((0 . t))))
2675 (gnus-summary-insert-line
2676 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2677 (goto-char (point-min))
2678 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2679 (- (point) (point-min) 1)))))
2680 (goto-char (point-min))
2681 (push (cons 'replied (and (search-forward "\201" nil t)
2682 (- (point) (point-min) 1)))
2683 pos)
2684 (goto-char (point-min))
2685 (push (cons 'score (and (search-forward "\202" nil t)
2686 (- (point) (point-min) 1)))
2687 pos)
2688 (goto-char (point-min))
2689 (push (cons 'download
2690 (and (search-forward "\203" nil t)
2691 (- (point) (point-min) 1)))
2692 pos)))
2693 (setq gnus-summary-mark-positions pos))))
2695 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2696 "Insert a dummy root in the summary buffer."
2697 (beginning-of-line)
2698 (gnus-add-text-properties
2699 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2700 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2702 (defun gnus-summary-from-or-to-or-newsgroups (header)
2703 (let ((to (cdr (assq 'To (mail-header-extra header))))
2704 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2705 (mail-parse-charset gnus-newsgroup-charset)
2706 (mail-parse-ignored-charsets
2707 (save-excursion (set-buffer gnus-summary-buffer)
2708 gnus-newsgroup-ignored-charsets)))
2709 (cond
2710 ((and to
2711 gnus-ignored-from-addresses
2712 (string-match gnus-ignored-from-addresses
2713 (mail-header-from header)))
2714 (concat "-> "
2715 (or (car (funcall gnus-extract-address-components
2716 (funcall
2717 gnus-decode-encoded-word-function to)))
2718 (funcall gnus-decode-encoded-word-function to))))
2719 ((and newsgroups
2720 gnus-ignored-from-addresses
2721 (string-match gnus-ignored-from-addresses
2722 (mail-header-from header)))
2723 (concat "=> " newsgroups))
2725 (or (car (funcall gnus-extract-address-components
2726 (mail-header-from header)))
2727 (mail-header-from header))))))
2729 (defun gnus-summary-insert-line (gnus-tmp-header
2730 gnus-tmp-level gnus-tmp-current
2731 gnus-tmp-unread gnus-tmp-replied
2732 gnus-tmp-expirable gnus-tmp-subject-or-nil
2733 &optional gnus-tmp-dummy gnus-tmp-score
2734 gnus-tmp-process)
2735 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2736 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2737 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2738 (gnus-tmp-score-char
2739 (if (or (null gnus-summary-default-score)
2740 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2741 gnus-summary-zcore-fuzz))
2742 ? ;Whitespace
2743 (if (< gnus-tmp-score gnus-summary-default-score)
2744 gnus-score-below-mark gnus-score-over-mark)))
2745 (gnus-tmp-replied
2746 (cond (gnus-tmp-process gnus-process-mark)
2747 ((memq gnus-tmp-current gnus-newsgroup-cached)
2748 gnus-cached-mark)
2749 (gnus-tmp-replied gnus-replied-mark)
2750 ((memq gnus-tmp-current gnus-newsgroup-saved)
2751 gnus-saved-mark)
2752 (t gnus-unread-mark)))
2753 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2754 (gnus-tmp-name
2755 (cond
2756 ((string-match "<[^>]+> *$" gnus-tmp-from)
2757 (let ((beg (match-beginning 0)))
2758 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2759 (substring gnus-tmp-from (1+ (match-beginning 0))
2760 (1- (match-end 0))))
2761 (substring gnus-tmp-from 0 beg))))
2762 ((string-match "(.+)" gnus-tmp-from)
2763 (substring gnus-tmp-from
2764 (1+ (match-beginning 0)) (1- (match-end 0))))
2765 (t gnus-tmp-from)))
2766 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2767 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2768 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2769 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2770 (buffer-read-only nil))
2771 (when (string= gnus-tmp-name "")
2772 (setq gnus-tmp-name gnus-tmp-from))
2773 (unless (numberp gnus-tmp-lines)
2774 (setq gnus-tmp-lines 0))
2775 (gnus-put-text-property
2776 (point)
2777 (progn (eval gnus-summary-line-format-spec) (point))
2778 'gnus-number gnus-tmp-number)
2779 (when (gnus-visual-p 'summary-highlight 'highlight)
2780 (forward-line -1)
2781 (gnus-run-hooks 'gnus-summary-update-hook)
2782 (forward-line 1))))
2784 (defun gnus-summary-update-line (&optional dont-update)
2785 "Update summary line after change."
2786 (when (and gnus-summary-default-score
2787 (not gnus-summary-inhibit-highlight))
2788 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2789 (article (gnus-summary-article-number))
2790 (score (gnus-summary-article-score article)))
2791 (unless dont-update
2792 (if (and gnus-summary-mark-below
2793 (< (gnus-summary-article-score)
2794 gnus-summary-mark-below))
2795 ;; This article has a low score, so we mark it as read.
2796 (when (memq article gnus-newsgroup-unreads)
2797 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2798 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2799 ;; This article was previously marked as read on account
2800 ;; of a low score, but now it has risen, so we mark it as
2801 ;; unread.
2802 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2803 (gnus-summary-update-mark
2804 (if (or (null gnus-summary-default-score)
2805 (<= (abs (- score gnus-summary-default-score))
2806 gnus-summary-zcore-fuzz))
2807 ? ;Whitespace
2808 (if (< score gnus-summary-default-score)
2809 gnus-score-below-mark gnus-score-over-mark))
2810 'score))
2811 ;; Do visual highlighting.
2812 (when (gnus-visual-p 'summary-highlight 'highlight)
2813 (gnus-run-hooks 'gnus-summary-update-hook)))))
2815 (defvar gnus-tmp-new-adopts nil)
2817 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2818 "Return the number of articles in THREAD.
2819 This may be 0 in some cases -- if none of the articles in
2820 the thread are to be displayed."
2821 (let* ((number
2822 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2823 (cond
2824 ((not (listp thread))
2826 ((and (consp thread) (cdr thread))
2827 (apply
2828 '+ 1 (mapcar
2829 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2830 ((null thread)
2832 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2834 (t 0))))
2835 (when (and level (zerop level) gnus-tmp-new-adopts)
2836 (incf number
2837 (apply '+ (mapcar
2838 'gnus-summary-number-of-articles-in-thread
2839 gnus-tmp-new-adopts))))
2840 (if char
2841 (if (> number 1) gnus-not-empty-thread-mark
2842 gnus-empty-thread-mark)
2843 number)))
2845 (defun gnus-summary-set-local-parameters (group)
2846 "Go through the local params of GROUP and set all variable specs in that list."
2847 (let ((params (gnus-group-find-parameter group))
2848 elem)
2849 (while params
2850 (setq elem (car params)
2851 params (cdr params))
2852 (and (consp elem) ; Has to be a cons.
2853 (consp (cdr elem)) ; The cdr has to be a list.
2854 (symbolp (car elem)) ; Has to be a symbol in there.
2855 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2856 (ignore-errors ; So we set it.
2857 (make-local-variable (car elem))
2858 (set (car elem) (eval (nth 1 elem))))))))
2860 (defun gnus-summary-read-group (group &optional show-all no-article
2861 kill-buffer no-display backward
2862 select-articles)
2863 "Start reading news in newsgroup GROUP.
2864 If SHOW-ALL is non-nil, already read articles are also listed.
2865 If NO-ARTICLE is non-nil, no article is selected initially.
2866 If NO-DISPLAY, don't generate a summary buffer."
2867 (let (result)
2868 (while (and group
2869 (null (setq result
2870 (let ((gnus-auto-select-next nil))
2871 (or (gnus-summary-read-group-1
2872 group show-all no-article
2873 kill-buffer no-display
2874 select-articles)
2875 (setq show-all nil
2876 select-articles nil)))))
2877 (eq gnus-auto-select-next 'quietly))
2878 (set-buffer gnus-group-buffer)
2879 ;; The entry function called above goes to the next
2880 ;; group automatically, so we go two groups back
2881 ;; if we are searching for the previous group.
2882 (when backward
2883 (gnus-group-prev-unread-group 2))
2884 (if (not (equal group (gnus-group-group-name)))
2885 (setq group (gnus-group-group-name))
2886 (setq group nil)))
2887 result))
2889 (defun gnus-summary-read-group-1 (group show-all no-article
2890 kill-buffer no-display
2891 &optional select-articles)
2892 ;; Killed foreign groups can't be entered.
2893 (when (and (not (gnus-group-native-p group))
2894 (not (gnus-gethash group gnus-newsrc-hashtb)))
2895 (error "Dead non-native groups can't be entered"))
2896 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2897 (let* ((new-group (gnus-summary-setup-buffer group))
2898 (quit-config (gnus-group-quit-config group))
2899 (did-select (and new-group (gnus-select-newsgroup
2900 group show-all select-articles))))
2901 (cond
2902 ;; This summary buffer exists already, so we just select it.
2903 ((not new-group)
2904 (gnus-set-global-variables)
2905 (when kill-buffer
2906 (gnus-kill-or-deaden-summary kill-buffer))
2907 (gnus-configure-windows 'summary 'force)
2908 (gnus-set-mode-line 'summary)
2909 (gnus-summary-position-point)
2910 (message "")
2912 ;; We couldn't select this group.
2913 ((null did-select)
2914 (when (and (eq major-mode 'gnus-summary-mode)
2915 (not (equal (current-buffer) kill-buffer)))
2916 (kill-buffer (current-buffer))
2917 (if (not quit-config)
2918 (progn
2919 ;; Update the info -- marks might need to be removed,
2920 ;; for instance.
2921 (gnus-summary-update-info)
2922 (set-buffer gnus-group-buffer)
2923 (gnus-group-jump-to-group group)
2924 (gnus-group-next-unread-group 1))
2925 (gnus-handle-ephemeral-exit quit-config)))
2926 (gnus-message 3 "Can't select group")
2927 nil)
2928 ;; The user did a `C-g' while prompting for number of articles,
2929 ;; so we exit this group.
2930 ((eq did-select 'quit)
2931 (and (eq major-mode 'gnus-summary-mode)
2932 (not (equal (current-buffer) kill-buffer))
2933 (kill-buffer (current-buffer)))
2934 (when kill-buffer
2935 (gnus-kill-or-deaden-summary kill-buffer))
2936 (if (not quit-config)
2937 (progn
2938 (set-buffer gnus-group-buffer)
2939 (gnus-group-jump-to-group group)
2940 (gnus-group-next-unread-group 1)
2941 (gnus-configure-windows 'group 'force))
2942 (gnus-handle-ephemeral-exit quit-config))
2943 ;; Finally signal the quit.
2944 (signal 'quit nil))
2945 ;; The group was successfully selected.
2947 (gnus-set-global-variables)
2948 ;; Save the active value in effect when the group was entered.
2949 (setq gnus-newsgroup-active
2950 (gnus-copy-sequence
2951 (gnus-active gnus-newsgroup-name)))
2952 ;; You can change the summary buffer in some way with this hook.
2953 (gnus-run-hooks 'gnus-select-group-hook)
2954 ;; Set any local variables in the group parameters.
2955 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2956 (gnus-update-format-specifications
2957 nil 'summary 'summary-mode 'summary-dummy)
2958 (gnus-update-summary-mark-positions)
2959 ;; Do score processing.
2960 (when gnus-use-scoring
2961 (gnus-possibly-score-headers))
2962 ;; Check whether to fill in the gaps in the threads.
2963 (when gnus-build-sparse-threads
2964 (gnus-build-sparse-threads))
2965 ;; Find the initial limit.
2966 (if gnus-show-threads
2967 (if show-all
2968 (let ((gnus-newsgroup-dormant nil))
2969 (gnus-summary-initial-limit show-all))
2970 (gnus-summary-initial-limit show-all))
2971 ;; When unthreaded, all articles are always shown.
2972 (setq gnus-newsgroup-limit
2973 (mapcar
2974 (lambda (header) (mail-header-number header))
2975 gnus-newsgroup-headers)))
2976 ;; Generate the summary buffer.
2977 (unless no-display
2978 (gnus-summary-prepare))
2979 (when gnus-use-trees
2980 (gnus-tree-open group)
2981 (setq gnus-summary-highlight-line-function
2982 'gnus-tree-highlight-article))
2983 ;; If the summary buffer is empty, but there are some low-scored
2984 ;; articles or some excluded dormants, we include these in the
2985 ;; buffer.
2986 (when (and (zerop (buffer-size))
2987 (not no-display))
2988 (cond (gnus-newsgroup-dormant
2989 (gnus-summary-limit-include-dormant))
2990 ((and gnus-newsgroup-scored show-all)
2991 (gnus-summary-limit-include-expunged t))))
2992 ;; Function `gnus-apply-kill-file' must be called in this hook.
2993 (gnus-run-hooks 'gnus-apply-kill-hook)
2994 (if (and (zerop (buffer-size))
2995 (not no-display))
2996 (progn
2997 ;; This newsgroup is empty.
2998 (gnus-summary-catchup-and-exit nil t)
2999 (gnus-message 6 "No unread news")
3000 (when kill-buffer
3001 (gnus-kill-or-deaden-summary kill-buffer))
3002 ;; Return nil from this function.
3003 nil)
3004 ;; Hide conversation thread subtrees. We cannot do this in
3005 ;; gnus-summary-prepare-hook since kill processing may not
3006 ;; work with hidden articles.
3007 (and gnus-show-threads
3008 gnus-thread-hide-subtree
3009 (gnus-summary-hide-all-threads))
3010 (when kill-buffer
3011 (gnus-kill-or-deaden-summary kill-buffer))
3012 ;; Show first unread article if requested.
3013 (if (and (not no-article)
3014 (not no-display)
3015 gnus-newsgroup-unreads
3016 gnus-auto-select-first)
3017 (progn
3018 (gnus-configure-windows 'summary)
3019 (cond
3020 ((eq gnus-auto-select-first 'best)
3021 (gnus-summary-best-unread-article))
3022 ((eq gnus-auto-select-first t)
3023 (gnus-summary-first-unread-article))
3024 ((gnus-functionp gnus-auto-select-first)
3025 (funcall gnus-auto-select-first))))
3026 ;; Don't select any articles, just move point to the first
3027 ;; article in the group.
3028 (goto-char (point-min))
3029 (gnus-summary-position-point)
3030 (gnus-configure-windows 'summary 'force)
3031 (gnus-set-mode-line 'summary))
3032 (when (get-buffer-window gnus-group-buffer t)
3033 ;; Gotta use windows, because recenter does weird stuff if
3034 ;; the current buffer ain't the displayed window.
3035 (let ((owin (selected-window)))
3036 (select-window (get-buffer-window gnus-group-buffer t))
3037 (when (gnus-group-goto-group group)
3038 (recenter))
3039 (select-window owin)))
3040 ;; Mark this buffer as "prepared".
3041 (setq gnus-newsgroup-prepared t)
3042 (gnus-run-hooks 'gnus-summary-prepared-hook)
3043 t)))))
3045 (defun gnus-summary-prepare ()
3046 "Generate the summary buffer."
3047 (interactive)
3048 (let ((buffer-read-only nil))
3049 (erase-buffer)
3050 (setq gnus-newsgroup-data nil
3051 gnus-newsgroup-data-reverse nil)
3052 (gnus-run-hooks 'gnus-summary-generate-hook)
3053 ;; Generate the buffer, either with threads or without.
3054 (when gnus-newsgroup-headers
3055 (gnus-summary-prepare-threads
3056 (if gnus-show-threads
3057 (gnus-sort-gathered-threads
3058 (funcall gnus-summary-thread-gathering-function
3059 (gnus-sort-threads
3060 (gnus-cut-threads (gnus-make-threads)))))
3061 ;; Unthreaded display.
3062 (gnus-sort-articles gnus-newsgroup-headers))))
3063 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3064 ;; Call hooks for modifying summary buffer.
3065 (goto-char (point-min))
3066 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3068 (defsubst gnus-general-simplify-subject (subject)
3069 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3070 (setq subject
3071 (cond
3072 ;; Truncate the subject.
3073 (gnus-simplify-subject-functions
3074 (gnus-map-function gnus-simplify-subject-functions subject))
3075 ((numberp gnus-summary-gather-subject-limit)
3076 (setq subject (gnus-simplify-subject-re subject))
3077 (if (> (length subject) gnus-summary-gather-subject-limit)
3078 (substring subject 0 gnus-summary-gather-subject-limit)
3079 subject))
3080 ;; Fuzzily simplify it.
3081 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3082 (gnus-simplify-subject-fuzzy subject))
3083 ;; Just remove the leading "Re:".
3085 (gnus-simplify-subject-re subject))))
3087 (if (and gnus-summary-gather-exclude-subject
3088 (string-match gnus-summary-gather-exclude-subject subject))
3089 nil ; This article shouldn't be gathered
3090 subject))
3092 (defun gnus-summary-simplify-subject-query ()
3093 "Query where the respool algorithm would put this article."
3094 (interactive)
3095 (gnus-summary-select-article)
3096 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3098 (defun gnus-gather-threads-by-subject (threads)
3099 "Gather threads by looking at Subject headers."
3100 (if (not gnus-summary-make-false-root)
3101 threads
3102 (let ((hashtb (gnus-make-hashtable 1024))
3103 (prev threads)
3104 (result threads)
3105 subject hthread whole-subject)
3106 (while threads
3107 (setq subject (gnus-general-simplify-subject
3108 (setq whole-subject (mail-header-subject
3109 (caar threads)))))
3110 (when subject
3111 (if (setq hthread (gnus-gethash subject hashtb))
3112 (progn
3113 ;; We enter a dummy root into the thread, if we
3114 ;; haven't done that already.
3115 (unless (stringp (caar hthread))
3116 (setcar hthread (list whole-subject (car hthread))))
3117 ;; We add this new gathered thread to this gathered
3118 ;; thread.
3119 (setcdr (car hthread)
3120 (nconc (cdar hthread) (list (car threads))))
3121 ;; Remove it from the list of threads.
3122 (setcdr prev (cdr threads))
3123 (setq threads prev))
3124 ;; Enter this thread into the hash table.
3125 (gnus-sethash subject threads hashtb)))
3126 (setq prev threads)
3127 (setq threads (cdr threads)))
3128 result)))
3130 (defun gnus-gather-threads-by-references (threads)
3131 "Gather threads by looking at References headers."
3132 (let ((idhashtb (gnus-make-hashtable 1024))
3133 (thhashtb (gnus-make-hashtable 1024))
3134 (prev threads)
3135 (result threads)
3136 ids references id gthread gid entered ref)
3137 (while threads
3138 (when (setq references (mail-header-references (caar threads)))
3139 (setq id (mail-header-id (caar threads))
3140 ids (gnus-split-references references)
3141 entered nil)
3142 (while (setq ref (pop ids))
3143 (setq ids (delete ref ids))
3144 (if (not (setq gid (gnus-gethash ref idhashtb)))
3145 (progn
3146 (gnus-sethash ref id idhashtb)
3147 (gnus-sethash id threads thhashtb))
3148 (setq gthread (gnus-gethash gid thhashtb))
3149 (unless entered
3150 ;; We enter a dummy root into the thread, if we
3151 ;; haven't done that already.
3152 (unless (stringp (caar gthread))
3153 (setcar gthread (list (mail-header-subject (caar gthread))
3154 (car gthread))))
3155 ;; We add this new gathered thread to this gathered
3156 ;; thread.
3157 (setcdr (car gthread)
3158 (nconc (cdar gthread) (list (car threads)))))
3159 ;; Add it into the thread hash table.
3160 (gnus-sethash id gthread thhashtb)
3161 (setq entered t)
3162 ;; Remove it from the list of threads.
3163 (setcdr prev (cdr threads))
3164 (setq threads prev))))
3165 (setq prev threads)
3166 (setq threads (cdr threads)))
3167 result))
3169 (defun gnus-sort-gathered-threads (threads)
3170 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3171 (let ((result threads))
3172 (while threads
3173 (when (stringp (caar threads))
3174 (setcdr (car threads)
3175 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3176 (setq threads (cdr threads)))
3177 result))
3179 (defun gnus-thread-loop-p (root thread)
3180 "Say whether ROOT is in THREAD."
3181 (let ((stack (list thread))
3182 (infloop 0)
3184 (while (setq thread (pop stack))
3185 (setq th (cdr thread))
3186 (while (and th
3187 (not (eq (caar th) root)))
3188 (pop th))
3189 (if th
3190 ;; We have found a loop.
3191 (let (ref-dep)
3192 (setcdr thread (delq (car th) (cdr thread)))
3193 (if (boundp (setq ref-dep (intern "none"
3194 gnus-newsgroup-dependencies)))
3195 (setcdr (symbol-value ref-dep)
3196 (nconc (cdr (symbol-value ref-dep))
3197 (list (car th))))
3198 (set ref-dep (list nil (car th))))
3199 (setq infloop 1
3200 stack nil))
3201 ;; Push all the subthreads onto the stack.
3202 (push (cdr thread) stack)))
3203 infloop))
3205 (defun gnus-make-threads ()
3206 "Go through the dependency hashtb and find the roots. Return all threads."
3207 (let (threads)
3208 (while (catch 'infloop
3209 (mapatoms
3210 (lambda (refs)
3211 ;; Deal with self-referencing References loops.
3212 (when (and (car (symbol-value refs))
3213 (not (zerop
3214 (apply
3216 (mapcar
3217 (lambda (thread)
3218 (gnus-thread-loop-p
3219 (car (symbol-value refs)) thread))
3220 (cdr (symbol-value refs)))))))
3221 (setq threads nil)
3222 (throw 'infloop t))
3223 (unless (car (symbol-value refs))
3224 ;; These threads do not refer back to any other articles,
3225 ;; so they're roots.
3226 (setq threads (append (cdr (symbol-value refs)) threads))))
3227 gnus-newsgroup-dependencies)))
3228 threads))
3230 ;; Build the thread tree.
3231 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3232 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3234 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3235 if it was already present.
3237 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3238 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3239 Message-IDs will be renamed be renamed to a unique Message-ID before
3240 being entered.
3242 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3243 (let* ((id (mail-header-id header))
3244 (id-dep (and id (intern id dependencies)))
3245 ref ref-dep ref-header)
3246 ;; Enter this `header' in the `dependencies' table.
3247 (cond
3248 ((not id-dep)
3249 (setq header nil))
3250 ;; The first two cases do the normal part: enter a new `header'
3251 ;; in the `dependencies' table.
3252 ((not (boundp id-dep))
3253 (set id-dep (list header)))
3254 ((null (car (symbol-value id-dep)))
3255 (setcar (symbol-value id-dep) header))
3257 ;; From here the `header' was already present in the
3258 ;; `dependencies' table.
3259 (force-new
3260 ;; Overrides an existing entry;
3261 ;; just set the header part of the entry.
3262 (setcar (symbol-value id-dep) header))
3264 ;; Renames the existing `header' to a unique Message-ID.
3265 ((not gnus-summary-ignore-duplicates)
3266 ;; An article with this Message-ID has already been seen.
3267 ;; We rename the Message-ID.
3268 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3269 (list header))
3270 (mail-header-set-id header id))
3272 ;; The last case ignores an existing entry, except it adds any
3273 ;; additional Xrefs (in case the two articles came from different
3274 ;; servers.
3275 ;; Also sets `header' to `nil' meaning that the `dependencies'
3276 ;; table was *not* modified.
3278 (mail-header-set-xref
3279 (car (symbol-value id-dep))
3280 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3282 (or (mail-header-xref header) "")))
3283 (setq header nil)))
3285 (when header
3286 ;; First check if that we are not creating a References loop.
3287 (setq ref (gnus-parent-id (mail-header-references header)))
3288 (while (and ref
3289 (setq ref-dep (intern-soft ref dependencies))
3290 (boundp ref-dep)
3291 (setq ref-header (car (symbol-value ref-dep))))
3292 (if (string= id ref)
3293 ;; Yuk! This is a reference loop. Make the article be a
3294 ;; root article.
3295 (progn
3296 (mail-header-set-references (car (symbol-value id-dep)) "none")
3297 (setq ref nil))
3298 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3299 (setq ref (gnus-parent-id (mail-header-references header)))
3300 (setq ref-dep (intern (or ref "none") dependencies))
3301 (if (boundp ref-dep)
3302 (setcdr (symbol-value ref-dep)
3303 (nconc (cdr (symbol-value ref-dep))
3304 (list (symbol-value id-dep))))
3305 (set ref-dep (list nil (symbol-value id-dep)))))
3306 header))
3308 (defun gnus-build-sparse-threads ()
3309 (let ((headers gnus-newsgroup-headers)
3310 (mail-parse-charset gnus-newsgroup-charset)
3311 (gnus-summary-ignore-duplicates t)
3312 header references generation relations
3313 subject child end new-child date)
3314 ;; First we create an alist of generations/relations, where
3315 ;; generations is how much we trust the relation, and the relation
3316 ;; is parent/child.
3317 (gnus-message 7 "Making sparse threads...")
3318 (save-excursion
3319 (nnheader-set-temp-buffer " *gnus sparse threads*")
3320 (while (setq header (pop headers))
3321 (when (and (setq references (mail-header-references header))
3322 (not (string= references "")))
3323 (insert references)
3324 (setq child (mail-header-id header)
3325 subject (mail-header-subject header)
3326 date (mail-header-date header)
3327 generation 0)
3328 (while (search-backward ">" nil t)
3329 (setq end (1+ (point)))
3330 (when (search-backward "<" nil t)
3331 (setq new-child (buffer-substring (point) end))
3332 (push (list (incf generation)
3333 child (setq child new-child)
3334 subject date)
3335 relations)))
3336 (when child
3337 (push (list (1+ generation) child nil subject) relations))
3338 (erase-buffer)))
3339 (kill-buffer (current-buffer)))
3340 ;; Sort over trustworthiness.
3341 (mapcar
3342 (lambda (relation)
3343 (when (gnus-dependencies-add-header
3344 (make-full-mail-header
3345 gnus-reffed-article-number
3346 (nth 3 relation) "" (or (nth 4 relation) "")
3347 (nth 1 relation)
3348 (or (nth 2 relation) "") 0 0 "")
3349 gnus-newsgroup-dependencies nil)
3350 (push gnus-reffed-article-number gnus-newsgroup-limit)
3351 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3352 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3353 gnus-newsgroup-reads)
3354 (decf gnus-reffed-article-number)))
3355 (sort relations 'car-less-than-car))
3356 (gnus-message 7 "Making sparse threads...done")))
3358 (defun gnus-build-old-threads ()
3359 ;; Look at all the articles that refer back to old articles, and
3360 ;; fetch the headers for the articles that aren't there. This will
3361 ;; build complete threads - if the roots haven't been expired by the
3362 ;; server, that is.
3363 (let ((mail-parse-charset gnus-newsgroup-charset)
3364 id heads)
3365 (mapatoms
3366 (lambda (refs)
3367 (when (not (car (symbol-value refs)))
3368 (setq heads (cdr (symbol-value refs)))
3369 (while heads
3370 (if (memq (mail-header-number (caar heads))
3371 gnus-newsgroup-dormant)
3372 (setq heads (cdr heads))
3373 (setq id (symbol-name refs))
3374 (while (and (setq id (gnus-build-get-header id))
3375 (not (car (gnus-id-to-thread id)))))
3376 (setq heads nil)))))
3377 gnus-newsgroup-dependencies)))
3379 ;; This function has to be called with point after the article number
3380 ;; on the beginning of the line.
3381 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3382 (let ((eol (gnus-point-at-eol))
3383 (buffer (current-buffer))
3384 header)
3386 ;; overview: [num subject from date id refs chars lines misc]
3387 (unwind-protect
3388 (progn
3389 (narrow-to-region (point) eol)
3390 (unless (eobp)
3391 (forward-char))
3393 (setq header
3394 (make-full-mail-header
3395 number ; number
3396 (funcall gnus-decode-encoded-word-function
3397 (nnheader-nov-field)) ; subject
3398 (funcall gnus-decode-encoded-word-function
3399 (nnheader-nov-field)) ; from
3400 (nnheader-nov-field) ; date
3401 (nnheader-nov-read-message-id) ; id
3402 (nnheader-nov-field) ; refs
3403 (nnheader-nov-read-integer) ; chars
3404 (nnheader-nov-read-integer) ; lines
3405 (unless (eobp)
3406 (if (looking-at "Xref: ")
3407 (goto-char (match-end 0)))
3408 (nnheader-nov-field)) ; Xref
3409 (nnheader-nov-parse-extra)))) ; extra
3411 (widen))
3413 (when gnus-alter-header-function
3414 (funcall gnus-alter-header-function header))
3415 (gnus-dependencies-add-header header dependencies force-new)))
3417 (defun gnus-build-get-header (id)
3418 "Look through the buffer of NOV lines and find the header to ID.
3419 Enter this line into the dependencies hash table, and return
3420 the id of the parent article (if any)."
3421 (let ((deps gnus-newsgroup-dependencies)
3422 found header)
3423 (prog1
3424 (save-excursion
3425 (set-buffer nntp-server-buffer)
3426 (let ((case-fold-search nil))
3427 (goto-char (point-min))
3428 (while (and (not found)
3429 (search-forward id nil t))
3430 (beginning-of-line)
3431 (setq found (looking-at
3432 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3433 (regexp-quote id))))
3434 (or found (beginning-of-line 2)))
3435 (when found
3436 (beginning-of-line)
3437 (and
3438 (setq header (gnus-nov-parse-line
3439 (read (current-buffer)) deps))
3440 (gnus-parent-id (mail-header-references header))))))
3441 (when header
3442 (let ((number (mail-header-number header)))
3443 (push number gnus-newsgroup-limit)
3444 (push header gnus-newsgroup-headers)
3445 (if (memq number gnus-newsgroup-unselected)
3446 (progn
3447 (push number gnus-newsgroup-unreads)
3448 (setq gnus-newsgroup-unselected
3449 (delq number gnus-newsgroup-unselected)))
3450 (push number gnus-newsgroup-ancient)))))))
3452 (defun gnus-build-all-threads ()
3453 "Read all the headers."
3454 (let ((gnus-summary-ignore-duplicates t)
3455 (mail-parse-charset gnus-newsgroup-charset)
3456 (dependencies gnus-newsgroup-dependencies)
3457 header article)
3458 (save-excursion
3459 (set-buffer nntp-server-buffer)
3460 (let ((case-fold-search nil))
3461 (goto-char (point-min))
3462 (while (not (eobp))
3463 (ignore-errors
3464 (setq article (read (current-buffer))
3465 header (gnus-nov-parse-line article dependencies)))
3466 (when header
3467 (save-excursion
3468 (set-buffer gnus-summary-buffer)
3469 (push header gnus-newsgroup-headers)
3470 (if (memq (setq article (mail-header-number header))
3471 gnus-newsgroup-unselected)
3472 (progn
3473 (push article gnus-newsgroup-unreads)
3474 (setq gnus-newsgroup-unselected
3475 (delq article gnus-newsgroup-unselected)))
3476 (push article gnus-newsgroup-ancient)))
3477 (forward-line 1)))))))
3479 (defun gnus-summary-update-article-line (article header)
3480 "Update the line for ARTICLE using HEADERS."
3481 (let* ((id (mail-header-id header))
3482 (thread (gnus-id-to-thread id)))
3483 (unless thread
3484 (error "Article in no thread"))
3485 ;; Update the thread.
3486 (setcar thread header)
3487 (gnus-summary-goto-subject article)
3488 (let* ((datal (gnus-data-find-list article))
3489 (data (car datal))
3490 (length (when (cdr datal)
3491 (- (gnus-data-pos data)
3492 (gnus-data-pos (cadr datal)))))
3493 (buffer-read-only nil)
3494 (level (gnus-summary-thread-level)))
3495 (gnus-delete-line)
3496 (gnus-summary-insert-line
3497 header level nil (gnus-article-mark article)
3498 (memq article gnus-newsgroup-replied)
3499 (memq article gnus-newsgroup-expirable)
3500 ;; Only insert the Subject string when it's different
3501 ;; from the previous Subject string.
3502 (if (and
3503 gnus-show-threads
3504 (gnus-subject-equal
3505 (condition-case ()
3506 (mail-header-subject
3507 (gnus-data-header
3508 (cadr
3509 (gnus-data-find-list
3510 article
3511 (gnus-data-list t)))))
3512 ;; Error on the side of excessive subjects.
3513 (error ""))
3514 (mail-header-subject header)))
3516 (mail-header-subject header))
3517 nil (cdr (assq article gnus-newsgroup-scored))
3518 (memq article gnus-newsgroup-processable))
3519 (when length
3520 (gnus-data-update-list
3521 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3523 (defun gnus-summary-update-article (article &optional iheader)
3524 "Update ARTICLE in the summary buffer."
3525 (set-buffer gnus-summary-buffer)
3526 (let* ((header (gnus-summary-article-header article))
3527 (id (mail-header-id header))
3528 (data (gnus-data-find article))
3529 (thread (gnus-id-to-thread id))
3530 (references (mail-header-references header))
3531 (parent
3532 (gnus-id-to-thread
3533 (or (gnus-parent-id
3534 (when (and references
3535 (not (equal "" references)))
3536 references))
3537 "none")))
3538 (buffer-read-only nil)
3539 (old (car thread)))
3540 (when thread
3541 (unless iheader
3542 (setcar thread nil)
3543 (when parent
3544 (delq thread parent)))
3545 (if (gnus-summary-insert-subject id header)
3546 ;; Set the (possibly) new article number in the data structure.
3547 (gnus-data-set-number data (gnus-id-to-article id))
3548 (setcar thread old)
3549 nil))))
3551 (defun gnus-rebuild-thread (id &optional line)
3552 "Rebuild the thread containing ID.
3553 If LINE, insert the rebuilt thread starting on line LINE."
3554 (let ((buffer-read-only nil)
3555 old-pos current thread data)
3556 (if (not gnus-show-threads)
3557 (setq thread (list (car (gnus-id-to-thread id))))
3558 ;; Get the thread this article is part of.
3559 (setq thread (gnus-remove-thread id)))
3560 (setq old-pos (gnus-point-at-bol))
3561 (setq current (save-excursion
3562 (and (re-search-backward "[\r\n]" nil t)
3563 (gnus-summary-article-number))))
3564 ;; If this is a gathered thread, we have to go some re-gathering.
3565 (when (stringp (car thread))
3566 (let ((subject (car thread))
3567 roots thr)
3568 (setq thread (cdr thread))
3569 (while thread
3570 (unless (memq (setq thr (gnus-id-to-thread
3571 (gnus-root-id
3572 (mail-header-id (caar thread)))))
3573 roots)
3574 (push thr roots))
3575 (setq thread (cdr thread)))
3576 ;; We now have all (unique) roots.
3577 (if (= (length roots) 1)
3578 ;; All the loose roots are now one solid root.
3579 (setq thread (car roots))
3580 (setq thread (cons subject (gnus-sort-threads roots))))))
3581 (let (threads)
3582 ;; We then insert this thread into the summary buffer.
3583 (when line
3584 (goto-char (point-min))
3585 (forward-line (1- line)))
3586 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3587 (if gnus-show-threads
3588 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3589 (gnus-summary-prepare-unthreaded thread))
3590 (setq data (nreverse gnus-newsgroup-data))
3591 (setq threads gnus-newsgroup-threads))
3592 ;; We splice the new data into the data structure.
3593 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3594 ;;!!! then we want to insert at the beginning of the buffer.
3595 ;;!!! That happens to be true with Gnus now, but that may
3596 ;;!!! change in the future. Perhaps.
3597 (gnus-data-enter-list
3598 (if line nil current) data (- (point) old-pos))
3599 (setq gnus-newsgroup-threads
3600 (nconc threads gnus-newsgroup-threads))
3601 (gnus-data-compute-positions))))
3603 (defun gnus-number-to-header (number)
3604 "Return the header for article NUMBER."
3605 (let ((headers gnus-newsgroup-headers))
3606 (while (and headers
3607 (not (= number (mail-header-number (car headers)))))
3608 (pop headers))
3609 (when headers
3610 (car headers))))
3612 (defun gnus-parent-headers (in-headers &optional generation)
3613 "Return the headers of the GENERATIONeth parent of HEADERS."
3614 (unless generation
3615 (setq generation 1))
3616 (let ((parent t)
3617 (headers in-headers)
3618 references)
3619 (while (and parent
3620 (not (zerop generation))
3621 (setq references (mail-header-references headers)))
3622 (setq headers (if (and references
3623 (setq parent (gnus-parent-id references)))
3624 (car (gnus-id-to-thread parent))
3625 nil))
3626 (decf generation))
3627 (and (not (eq headers in-headers))
3628 headers)))
3630 (defun gnus-id-to-thread (id)
3631 "Return the (sub-)thread where ID appears."
3632 (gnus-gethash id gnus-newsgroup-dependencies))
3634 (defun gnus-id-to-article (id)
3635 "Return the article number of ID."
3636 (let ((thread (gnus-id-to-thread id)))
3637 (when (and thread
3638 (car thread))
3639 (mail-header-number (car thread)))))
3641 (defun gnus-id-to-header (id)
3642 "Return the article headers of ID."
3643 (car (gnus-id-to-thread id)))
3645 (defun gnus-article-displayed-root-p (article)
3646 "Say whether ARTICLE is a root(ish) article."
3647 (let ((level (gnus-summary-thread-level article))
3648 (refs (mail-header-references (gnus-summary-article-header article)))
3649 particle)
3650 (cond
3651 ((null level) nil)
3652 ((zerop level) t)
3653 ((null refs) t)
3654 ((null (gnus-parent-id refs)) t)
3655 ((and (= 1 level)
3656 (null (setq particle (gnus-id-to-article
3657 (gnus-parent-id refs))))
3658 (null (gnus-summary-thread-level particle)))))))
3660 (defun gnus-root-id (id)
3661 "Return the id of the root of the thread where ID appears."
3662 (let (last-id prev)
3663 (while (and id (setq prev (car (gnus-id-to-thread id))))
3664 (setq last-id id
3665 id (gnus-parent-id (mail-header-references prev))))
3666 last-id))
3668 (defun gnus-articles-in-thread (thread)
3669 "Return the list of articles in THREAD."
3670 (cons (mail-header-number (car thread))
3671 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3673 (defun gnus-remove-thread (id &optional dont-remove)
3674 "Remove the thread that has ID in it."
3675 (let (headers thread last-id)
3676 ;; First go up in this thread until we find the root.
3677 (setq last-id (gnus-root-id id)
3678 headers (message-flatten-list (gnus-id-to-thread last-id)))
3679 ;; We have now found the real root of this thread. It might have
3680 ;; been gathered into some loose thread, so we have to search
3681 ;; through the threads to find the thread we wanted.
3682 (let ((threads gnus-newsgroup-threads)
3683 sub)
3684 (while threads
3685 (setq sub (car threads))
3686 (if (stringp (car sub))
3687 ;; This is a gathered thread, so we look at the roots
3688 ;; below it to find whether this article is in this
3689 ;; gathered root.
3690 (progn
3691 (setq sub (cdr sub))
3692 (while sub
3693 (when (member (caar sub) headers)
3694 (setq thread (car threads)
3695 threads nil
3696 sub nil))
3697 (setq sub (cdr sub))))
3698 ;; It's an ordinary thread, so we check it.
3699 (when (eq (car sub) (car headers))
3700 (setq thread sub
3701 threads nil)))
3702 (setq threads (cdr threads)))
3703 ;; If this article is in no thread, then it's a root.
3704 (if thread
3705 (unless dont-remove
3706 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3707 (setq thread (gnus-id-to-thread last-id)))
3708 (when thread
3709 (prog1
3710 thread ; We return this thread.
3711 (unless dont-remove
3712 (if (stringp (car thread))
3713 (progn
3714 ;; If we use dummy roots, then we have to remove the
3715 ;; dummy root as well.
3716 (when (eq gnus-summary-make-false-root 'dummy)
3717 ;; We go to the dummy root by going to
3718 ;; the first sub-"thread", and then one line up.
3719 (gnus-summary-goto-article
3720 (mail-header-number (caadr thread)))
3721 (forward-line -1)
3722 (gnus-delete-line)
3723 (gnus-data-compute-positions))
3724 (setq thread (cdr thread))
3725 (while thread
3726 (gnus-remove-thread-1 (car thread))
3727 (setq thread (cdr thread))))
3728 (gnus-remove-thread-1 thread))))))))
3730 (defun gnus-remove-thread-1 (thread)
3731 "Remove the thread THREAD recursively."
3732 (let ((number (mail-header-number (pop thread)))
3734 (setq thread (reverse thread))
3735 (while thread
3736 (gnus-remove-thread-1 (pop thread)))
3737 (when (setq d (gnus-data-find number))
3738 (goto-char (gnus-data-pos d))
3739 (gnus-summary-show-thread)
3740 (gnus-data-remove
3741 number
3742 (- (gnus-point-at-bol)
3743 (prog1
3744 (1+ (gnus-point-at-eol))
3745 (gnus-delete-line)))))))
3747 (defun gnus-sort-threads-1 (threads func)
3748 (sort (mapcar (lambda (thread)
3749 (cons (car thread)
3750 (and (cdr thread)
3751 (gnus-sort-threads-1 (cdr thread) func))))
3752 threads) func))
3754 (defun gnus-sort-threads (threads)
3755 "Sort THREADS."
3756 (if (not gnus-thread-sort-functions)
3757 threads
3758 (gnus-message 8 "Sorting threads...")
3759 (prog1
3760 (gnus-sort-threads-1
3761 threads
3762 (gnus-make-sort-function gnus-thread-sort-functions))
3763 (gnus-message 8 "Sorting threads...done"))))
3765 (defun gnus-sort-articles (articles)
3766 "Sort ARTICLES."
3767 (when gnus-article-sort-functions
3768 (gnus-message 7 "Sorting articles...")
3769 (prog1
3770 (setq gnus-newsgroup-headers
3771 (sort articles (gnus-make-sort-function
3772 gnus-article-sort-functions)))
3773 (gnus-message 7 "Sorting articles...done"))))
3775 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3776 (defmacro gnus-thread-header (thread)
3777 "Return header of first article in THREAD.
3778 Note that THREAD must never, ever be anything else than a variable -
3779 using some other form will lead to serious barfage."
3780 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3781 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3782 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3783 (vector thread) 2))
3785 (defsubst gnus-article-sort-by-number (h1 h2)
3786 "Sort articles by article number."
3787 (< (mail-header-number h1)
3788 (mail-header-number h2)))
3790 (defun gnus-thread-sort-by-number (h1 h2)
3791 "Sort threads by root article number."
3792 (gnus-article-sort-by-number
3793 (gnus-thread-header h1) (gnus-thread-header h2)))
3795 (defsubst gnus-article-sort-by-lines (h1 h2)
3796 "Sort articles by article Lines header."
3797 (< (mail-header-lines h1)
3798 (mail-header-lines h2)))
3800 (defun gnus-thread-sort-by-lines (h1 h2)
3801 "Sort threads by root article Lines header."
3802 (gnus-article-sort-by-lines
3803 (gnus-thread-header h1) (gnus-thread-header h2)))
3805 (defsubst gnus-article-sort-by-chars (h1 h2)
3806 "Sort articles by octet length."
3807 (< (mail-header-chars h1)
3808 (mail-header-chars h2)))
3810 (defun gnus-thread-sort-by-chars (h1 h2)
3811 "Sort threads by root article octet length."
3812 (gnus-article-sort-by-chars
3813 (gnus-thread-header h1) (gnus-thread-header h2)))
3815 (defsubst gnus-article-sort-by-author (h1 h2)
3816 "Sort articles by root author."
3817 (string-lessp
3818 (let ((extract (funcall
3819 gnus-extract-address-components
3820 (mail-header-from h1))))
3821 (or (car extract) (cadr extract) ""))
3822 (let ((extract (funcall
3823 gnus-extract-address-components
3824 (mail-header-from h2))))
3825 (or (car extract) (cadr extract) ""))))
3827 (defun gnus-thread-sort-by-author (h1 h2)
3828 "Sort threads by root author."
3829 (gnus-article-sort-by-author
3830 (gnus-thread-header h1) (gnus-thread-header h2)))
3832 (defsubst gnus-article-sort-by-subject (h1 h2)
3833 "Sort articles by root subject."
3834 (string-lessp
3835 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3836 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3838 (defun gnus-thread-sort-by-subject (h1 h2)
3839 "Sort threads by root subject."
3840 (gnus-article-sort-by-subject
3841 (gnus-thread-header h1) (gnus-thread-header h2)))
3843 (defsubst gnus-article-sort-by-date (h1 h2)
3844 "Sort articles by root article date."
3845 (time-less-p
3846 (gnus-date-get-time (mail-header-date h1))
3847 (gnus-date-get-time (mail-header-date h2))))
3849 (defun gnus-thread-sort-by-date (h1 h2)
3850 "Sort threads by root article date."
3851 (gnus-article-sort-by-date
3852 (gnus-thread-header h1) (gnus-thread-header h2)))
3854 (defsubst gnus-article-sort-by-score (h1 h2)
3855 "Sort articles by root article score.
3856 Unscored articles will be counted as having a score of zero."
3857 (> (or (cdr (assq (mail-header-number h1)
3858 gnus-newsgroup-scored))
3859 gnus-summary-default-score 0)
3860 (or (cdr (assq (mail-header-number h2)
3861 gnus-newsgroup-scored))
3862 gnus-summary-default-score 0)))
3864 (defun gnus-thread-sort-by-score (h1 h2)
3865 "Sort threads by root article score."
3866 (gnus-article-sort-by-score
3867 (gnus-thread-header h1) (gnus-thread-header h2)))
3869 (defun gnus-thread-sort-by-total-score (h1 h2)
3870 "Sort threads by the sum of all scores in the thread.
3871 Unscored articles will be counted as having a score of zero."
3872 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3874 (defun gnus-thread-total-score (thread)
3875 ;; This function find the total score of THREAD.
3876 (cond ((null thread)
3878 ((consp thread)
3879 (if (stringp (car thread))
3880 (apply gnus-thread-score-function 0
3881 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3882 (gnus-thread-total-score-1 thread)))
3884 (gnus-thread-total-score-1 (list thread)))))
3886 (defun gnus-thread-total-score-1 (root)
3887 ;; This function find the total score of the thread below ROOT.
3888 (setq root (car root))
3889 (apply gnus-thread-score-function
3890 (or (append
3891 (mapcar 'gnus-thread-total-score
3892 (cdr (gnus-id-to-thread (mail-header-id root))))
3893 (when (> (mail-header-number root) 0)
3894 (list (or (cdr (assq (mail-header-number root)
3895 gnus-newsgroup-scored))
3896 gnus-summary-default-score 0))))
3897 (list gnus-summary-default-score)
3898 '(0))))
3900 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3901 (defvar gnus-tmp-prev-subject nil)
3902 (defvar gnus-tmp-false-parent nil)
3903 (defvar gnus-tmp-root-expunged nil)
3904 (defvar gnus-tmp-dummy-line nil)
3906 (eval-when-compile (defvar gnus-tmp-header))
3907 (defun gnus-extra-header (type &optional header)
3908 "Return the extra header of TYPE."
3909 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3910 ""))
3912 (defun gnus-summary-prepare-threads (threads)
3913 "Prepare summary buffer from THREADS and indentation LEVEL.
3914 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3915 or a straight list of headers."
3916 (gnus-message 7 "Generating summary...")
3918 (setq gnus-newsgroup-threads threads)
3919 (beginning-of-line)
3921 (let ((gnus-tmp-level 0)
3922 (default-score (or gnus-summary-default-score 0))
3923 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3924 thread number subject stack state gnus-tmp-gathered beg-match
3925 new-roots gnus-tmp-new-adopts thread-end
3926 gnus-tmp-header gnus-tmp-unread
3927 gnus-tmp-replied gnus-tmp-subject-or-nil
3928 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3929 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3930 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3932 (setq gnus-tmp-prev-subject nil)
3934 (if (vectorp (car threads))
3935 ;; If this is a straight (sic) list of headers, then a
3936 ;; threaded summary display isn't required, so we just create
3937 ;; an unthreaded one.
3938 (gnus-summary-prepare-unthreaded threads)
3940 ;; Do the threaded display.
3942 (while (or threads stack gnus-tmp-new-adopts new-roots)
3944 (if (and (= gnus-tmp-level 0)
3945 (or (not stack)
3946 (= (caar stack) 0))
3947 (not gnus-tmp-false-parent)
3948 (or gnus-tmp-new-adopts new-roots))
3949 (if gnus-tmp-new-adopts
3950 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3951 thread (list (car gnus-tmp-new-adopts))
3952 gnus-tmp-header (caar thread)
3953 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3954 (when new-roots
3955 (setq thread (list (car new-roots))
3956 gnus-tmp-header (caar thread)
3957 new-roots (cdr new-roots))))
3959 (if threads
3960 ;; If there are some threads, we do them before the
3961 ;; threads on the stack.
3962 (setq thread threads
3963 gnus-tmp-header (caar thread))
3964 ;; There were no current threads, so we pop something off
3965 ;; the stack.
3966 (setq state (car stack)
3967 gnus-tmp-level (car state)
3968 thread (cdr state)
3969 stack (cdr stack)
3970 gnus-tmp-header (caar thread))))
3972 (setq gnus-tmp-false-parent nil)
3973 (setq gnus-tmp-root-expunged nil)
3974 (setq thread-end nil)
3976 (if (stringp gnus-tmp-header)
3977 ;; The header is a dummy root.
3978 (cond
3979 ((eq gnus-summary-make-false-root 'adopt)
3980 ;; We let the first article adopt the rest.
3981 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3982 (cddar thread)))
3983 (setq gnus-tmp-gathered
3984 (nconc (mapcar
3985 (lambda (h) (mail-header-number (car h)))
3986 (cddar thread))
3987 gnus-tmp-gathered))
3988 (setq thread (cons (list (caar thread)
3989 (cadar thread))
3990 (cdr thread)))
3991 (setq gnus-tmp-level -1
3992 gnus-tmp-false-parent t))
3993 ((eq gnus-summary-make-false-root 'empty)
3994 ;; We print adopted articles with empty subject fields.
3995 (setq gnus-tmp-gathered
3996 (nconc (mapcar
3997 (lambda (h) (mail-header-number (car h)))
3998 (cddar thread))
3999 gnus-tmp-gathered))
4000 (setq gnus-tmp-level -1))
4001 ((eq gnus-summary-make-false-root 'dummy)
4002 ;; We remember that we probably want to output a dummy
4003 ;; root.
4004 (setq gnus-tmp-dummy-line gnus-tmp-header)
4005 (setq gnus-tmp-prev-subject gnus-tmp-header))
4007 ;; We do not make a root for the gathered
4008 ;; sub-threads at all.
4009 (setq gnus-tmp-level -1)))
4011 (setq number (mail-header-number gnus-tmp-header)
4012 subject (mail-header-subject gnus-tmp-header))
4014 (cond
4015 ;; If the thread has changed subject, we might want to make
4016 ;; this subthread into a root.
4017 ((and (null gnus-thread-ignore-subject)
4018 (not (zerop gnus-tmp-level))
4019 gnus-tmp-prev-subject
4020 (not (inline
4021 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4022 (setq new-roots (nconc new-roots (list (car thread)))
4023 thread-end t
4024 gnus-tmp-header nil))
4025 ;; If the article lies outside the current limit,
4026 ;; then we do not display it.
4027 ((not (memq number gnus-newsgroup-limit))
4028 (setq gnus-tmp-gathered
4029 (nconc (mapcar
4030 (lambda (h) (mail-header-number (car h)))
4031 (cdar thread))
4032 gnus-tmp-gathered))
4033 (setq gnus-tmp-new-adopts (if (cdar thread)
4034 (append gnus-tmp-new-adopts
4035 (cdar thread))
4036 gnus-tmp-new-adopts)
4037 thread-end t
4038 gnus-tmp-header nil)
4039 (when (zerop gnus-tmp-level)
4040 (setq gnus-tmp-root-expunged t)))
4041 ;; Perhaps this article is to be marked as read?
4042 ((and gnus-summary-mark-below
4043 (< (or (cdr (assq number gnus-newsgroup-scored))
4044 default-score)
4045 gnus-summary-mark-below)
4046 ;; Don't touch sparse articles.
4047 (not (gnus-summary-article-sparse-p number))
4048 (not (gnus-summary-article-ancient-p number)))
4049 (setq gnus-newsgroup-unreads
4050 (delq number gnus-newsgroup-unreads))
4051 (if gnus-newsgroup-auto-expire
4052 (push number gnus-newsgroup-expirable)
4053 (push (cons number gnus-low-score-mark)
4054 gnus-newsgroup-reads))))
4056 (when gnus-tmp-header
4057 ;; We may have an old dummy line to output before this
4058 ;; article.
4059 (when (and gnus-tmp-dummy-line
4060 (gnus-subject-equal
4061 gnus-tmp-dummy-line
4062 (mail-header-subject gnus-tmp-header)))
4063 (gnus-summary-insert-dummy-line
4064 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4065 (setq gnus-tmp-dummy-line nil))
4067 ;; Compute the mark.
4068 (setq gnus-tmp-unread (gnus-article-mark number))
4070 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4071 gnus-tmp-header gnus-tmp-level)
4072 gnus-newsgroup-data)
4074 ;; Actually insert the line.
4075 (setq
4076 gnus-tmp-subject-or-nil
4077 (cond
4078 ((and gnus-thread-ignore-subject
4079 gnus-tmp-prev-subject
4080 (not (inline (gnus-subject-equal
4081 gnus-tmp-prev-subject subject))))
4082 subject)
4083 ((zerop gnus-tmp-level)
4084 (if (and (eq gnus-summary-make-false-root 'empty)
4085 (memq number gnus-tmp-gathered)
4086 gnus-tmp-prev-subject
4087 (inline (gnus-subject-equal
4088 gnus-tmp-prev-subject subject)))
4089 gnus-summary-same-subject
4090 subject))
4091 (t gnus-summary-same-subject)))
4092 (if (and (eq gnus-summary-make-false-root 'adopt)
4093 (= gnus-tmp-level 1)
4094 (memq number gnus-tmp-gathered))
4095 (setq gnus-tmp-opening-bracket ?\<
4096 gnus-tmp-closing-bracket ?\>)
4097 (setq gnus-tmp-opening-bracket ?\[
4098 gnus-tmp-closing-bracket ?\]))
4099 (setq
4100 gnus-tmp-indentation
4101 (aref gnus-thread-indent-array gnus-tmp-level)
4102 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4103 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4104 gnus-summary-default-score 0)
4105 gnus-tmp-score-char
4106 (if (or (null gnus-summary-default-score)
4107 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4108 gnus-summary-zcore-fuzz))
4109 ? ;Whitespace
4110 (if (< gnus-tmp-score gnus-summary-default-score)
4111 gnus-score-below-mark gnus-score-over-mark))
4112 gnus-tmp-replied
4113 (cond ((memq number gnus-newsgroup-processable)
4114 gnus-process-mark)
4115 ((memq number gnus-newsgroup-cached)
4116 gnus-cached-mark)
4117 ((memq number gnus-newsgroup-replied)
4118 gnus-replied-mark)
4119 ((memq number gnus-newsgroup-saved)
4120 gnus-saved-mark)
4121 (t gnus-unread-mark))
4122 gnus-tmp-from (mail-header-from gnus-tmp-header)
4123 gnus-tmp-name
4124 (cond
4125 ((string-match "<[^>]+> *$" gnus-tmp-from)
4126 (setq beg-match (match-beginning 0))
4127 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4128 (substring gnus-tmp-from (1+ (match-beginning 0))
4129 (1- (match-end 0))))
4130 (substring gnus-tmp-from 0 beg-match)))
4131 ((string-match "(.+)" gnus-tmp-from)
4132 (substring gnus-tmp-from
4133 (1+ (match-beginning 0)) (1- (match-end 0))))
4134 (t gnus-tmp-from)))
4135 (when (string= gnus-tmp-name "")
4136 (setq gnus-tmp-name gnus-tmp-from))
4137 (unless (numberp gnus-tmp-lines)
4138 (setq gnus-tmp-lines 0))
4139 (gnus-put-text-property
4140 (point)
4141 (progn (eval gnus-summary-line-format-spec) (point))
4142 'gnus-number number)
4143 (when gnus-visual-p
4144 (forward-line -1)
4145 (gnus-run-hooks 'gnus-summary-update-hook)
4146 (forward-line 1))
4148 (setq gnus-tmp-prev-subject subject)))
4150 (when (nth 1 thread)
4151 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4152 (incf gnus-tmp-level)
4153 (setq threads (if thread-end nil (cdar thread)))
4154 (unless threads
4155 (setq gnus-tmp-level 0)))))
4156 (gnus-message 7 "Generating summary...done"))
4158 (defun gnus-summary-prepare-unthreaded (headers)
4159 "Generate an unthreaded summary buffer based on HEADERS."
4160 (let (header number mark)
4162 (beginning-of-line)
4164 (while headers
4165 ;; We may have to root out some bad articles...
4166 (when (memq (setq number (mail-header-number
4167 (setq header (pop headers))))
4168 gnus-newsgroup-limit)
4169 ;; Mark article as read when it has a low score.
4170 (when (and gnus-summary-mark-below
4171 (< (or (cdr (assq number gnus-newsgroup-scored))
4172 gnus-summary-default-score 0)
4173 gnus-summary-mark-below)
4174 (not (gnus-summary-article-ancient-p number)))
4175 (setq gnus-newsgroup-unreads
4176 (delq number gnus-newsgroup-unreads))
4177 (if gnus-newsgroup-auto-expire
4178 (push number gnus-newsgroup-expirable)
4179 (push (cons number gnus-low-score-mark)
4180 gnus-newsgroup-reads)))
4182 (setq mark (gnus-article-mark number))
4183 (push (gnus-data-make number mark (1+ (point)) header 0)
4184 gnus-newsgroup-data)
4185 (gnus-summary-insert-line
4186 header 0 number
4187 mark (memq number gnus-newsgroup-replied)
4188 (memq number gnus-newsgroup-expirable)
4189 (mail-header-subject header) nil
4190 (cdr (assq number gnus-newsgroup-scored))
4191 (memq number gnus-newsgroup-processable))))))
4193 (defun gnus-summary-remove-list-identifiers ()
4194 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4195 (let ((regexp (if (stringp gnus-list-identifiers)
4196 gnus-list-identifiers
4197 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4198 (dolist (header gnus-newsgroup-headers)
4199 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4200 " *\\)\\)+\\(Re: +\\)?\\)")
4201 (mail-header-subject header))
4202 (mail-header-set-subject
4203 header (concat (substring (mail-header-subject header)
4204 0 (match-beginning 1))
4206 (match-string 3 (mail-header-subject header))
4207 (match-string 5 (mail-header-subject header)))
4208 (substring (mail-header-subject header)
4209 (match-end 1))))))))
4211 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4212 "Select newsgroup GROUP.
4213 If READ-ALL is non-nil, all articles in the group are selected.
4214 If SELECT-ARTICLES, only select those articles from GROUP."
4215 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4216 ;;!!! Dirty hack; should be removed.
4217 (gnus-summary-ignore-duplicates
4218 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4220 gnus-summary-ignore-duplicates))
4221 (info (nth 2 entry))
4222 articles fetched-articles cached)
4224 (unless (gnus-check-server
4225 (set (make-local-variable 'gnus-current-select-method)
4226 (gnus-find-method-for-group group)))
4227 (error "Couldn't open server"))
4229 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4230 (gnus-activate-group group) ; Or we can activate it...
4231 (progn ; Or we bug out.
4232 (when (equal major-mode 'gnus-summary-mode)
4233 (kill-buffer (current-buffer)))
4234 (error "Couldn't request group %s: %s"
4235 group (gnus-status-message group))))
4237 (unless (gnus-request-group group t)
4238 (when (equal major-mode 'gnus-summary-mode)
4239 (kill-buffer (current-buffer)))
4240 (error "Couldn't request group %s: %s"
4241 group (gnus-status-message group)))
4243 (setq gnus-newsgroup-name group)
4244 (setq gnus-newsgroup-unselected nil)
4245 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4246 (gnus-summary-setup-default-charset)
4248 ;; Adjust and set lists of article marks.
4249 (when info
4250 (gnus-adjust-marked-articles info))
4252 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4253 (when (gnus-virtual-group-p group)
4254 (setq cached gnus-newsgroup-cached))
4256 (setq gnus-newsgroup-unreads
4257 (gnus-set-difference
4258 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4259 gnus-newsgroup-dormant))
4261 (setq gnus-newsgroup-processable nil)
4263 (gnus-update-read-articles group gnus-newsgroup-unreads)
4265 (if (setq articles select-articles)
4266 (setq gnus-newsgroup-unselected
4267 (gnus-sorted-intersection
4268 gnus-newsgroup-unreads
4269 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4270 (setq articles (gnus-articles-to-read group read-all)))
4272 (cond
4273 ((null articles)
4274 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4275 'quit)
4276 ((eq articles 0) nil)
4278 ;; Init the dependencies hash table.
4279 (setq gnus-newsgroup-dependencies
4280 (gnus-make-hashtable (length articles)))
4281 (gnus-set-global-variables)
4282 ;; Retrieve the headers and read them in.
4283 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4284 (setq gnus-newsgroup-headers
4285 (if (eq 'nov
4286 (setq gnus-headers-retrieved-by
4287 (gnus-retrieve-headers
4288 articles gnus-newsgroup-name
4289 ;; We might want to fetch old headers, but
4290 ;; not if there is only 1 article.
4291 (and (or (and
4292 (not (eq gnus-fetch-old-headers 'some))
4293 (not (numberp gnus-fetch-old-headers)))
4294 (> (length articles) 1))
4295 gnus-fetch-old-headers))))
4296 (gnus-get-newsgroup-headers-xover
4297 articles nil nil gnus-newsgroup-name t)
4298 (gnus-get-newsgroup-headers)))
4299 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4301 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4302 (when cached
4303 (setq gnus-newsgroup-cached cached))
4305 ;; Suppress duplicates?
4306 (when gnus-suppress-duplicates
4307 (gnus-dup-suppress-articles))
4309 ;; Set the initial limit.
4310 (setq gnus-newsgroup-limit (copy-sequence articles))
4311 ;; Remove canceled articles from the list of unread articles.
4312 (setq gnus-newsgroup-unreads
4313 (gnus-set-sorted-intersection
4314 gnus-newsgroup-unreads
4315 (setq fetched-articles
4316 (mapcar (lambda (headers) (mail-header-number headers))
4317 gnus-newsgroup-headers))))
4318 ;; Removed marked articles that do not exist.
4319 (gnus-update-missing-marks
4320 (gnus-sorted-complement fetched-articles articles))
4321 ;; We might want to build some more threads first.
4322 (when (and gnus-fetch-old-headers
4323 (eq gnus-headers-retrieved-by 'nov))
4324 (if (eq gnus-fetch-old-headers 'invisible)
4325 (gnus-build-all-threads)
4326 (gnus-build-old-threads)))
4327 ;; Let the Gnus agent mark articles as read.
4328 (when gnus-agent
4329 (gnus-agent-get-undownloaded-list))
4330 ;; Remove list identifiers from subject
4331 (when gnus-list-identifiers
4332 (gnus-summary-remove-list-identifiers))
4333 ;; Check whether auto-expire is to be done in this group.
4334 (setq gnus-newsgroup-auto-expire
4335 (gnus-group-auto-expirable-p group))
4336 ;; Set up the article buffer now, if necessary.
4337 (unless gnus-single-article-buffer
4338 (gnus-article-setup-buffer))
4339 ;; First and last article in this newsgroup.
4340 (when gnus-newsgroup-headers
4341 (setq gnus-newsgroup-begin
4342 (mail-header-number (car gnus-newsgroup-headers))
4343 gnus-newsgroup-end
4344 (mail-header-number
4345 (gnus-last-element gnus-newsgroup-headers))))
4346 ;; GROUP is successfully selected.
4347 (or gnus-newsgroup-headers t)))))
4349 (defun gnus-articles-to-read (group &optional read-all)
4350 "Find out what articles the user wants to read."
4351 (let* ((articles
4352 ;; Select all articles if `read-all' is non-nil, or if there
4353 ;; are no unread articles.
4354 (if (or read-all
4355 (and (zerop (length gnus-newsgroup-marked))
4356 (zerop (length gnus-newsgroup-unreads)))
4357 (eq (gnus-group-find-parameter group 'display)
4358 'all))
4360 (gnus-uncompress-range (gnus-active group))
4361 (gnus-cache-articles-in-group group))
4362 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4363 (copy-sequence gnus-newsgroup-unreads))
4364 '<)))
4365 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4366 (scored (length scored-list))
4367 (number (length articles))
4368 (marked (+ (length gnus-newsgroup-marked)
4369 (length gnus-newsgroup-dormant)))
4370 (select
4371 (cond
4372 ((numberp read-all)
4373 read-all)
4375 (condition-case ()
4376 (cond
4377 ((and (or (<= scored marked) (= scored number))
4378 (numberp gnus-large-newsgroup)
4379 (> number gnus-large-newsgroup))
4380 (let ((input
4381 (read-string
4382 (format
4383 "How many articles from %s (default %d): "
4384 (gnus-limit-string gnus-newsgroup-name 35)
4385 number))))
4386 (if (string-match "^[ \t]*$" input) number input)))
4387 ((and (> scored marked) (< scored number)
4388 (> (- scored number) 20))
4389 (let ((input
4390 (read-string
4391 (format "%s %s (%d scored, %d total): "
4392 "How many articles from"
4393 group scored number))))
4394 (if (string-match "^[ \t]*$" input)
4395 number input)))
4396 (t number))
4397 (quit
4398 (message "Quit getting the articles to read")
4399 nil))))))
4400 (setq select (if (stringp select) (string-to-number select) select))
4401 (if (or (null select) (zerop select))
4402 select
4403 (if (and (not (zerop scored)) (<= (abs select) scored))
4404 (progn
4405 (setq articles (sort scored-list '<))
4406 (setq number (length articles)))
4407 (setq articles (copy-sequence articles)))
4409 (when (< (abs select) number)
4410 (if (< select 0)
4411 ;; Select the N oldest articles.
4412 (setcdr (nthcdr (1- (abs select)) articles) nil)
4413 ;; Select the N most recent articles.
4414 (setq articles (nthcdr (- number select) articles))))
4415 (setq gnus-newsgroup-unselected
4416 (gnus-sorted-intersection
4417 gnus-newsgroup-unreads
4418 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4419 (when gnus-alter-articles-to-read-function
4420 (setq gnus-newsgroup-unreads
4421 (sort
4422 (funcall gnus-alter-articles-to-read-function
4423 gnus-newsgroup-name gnus-newsgroup-unreads)
4424 '<)))
4425 articles)))
4427 (defun gnus-killed-articles (killed articles)
4428 (let (out)
4429 (while articles
4430 (when (inline (gnus-member-of-range (car articles) killed))
4431 (push (car articles) out))
4432 (setq articles (cdr articles)))
4433 out))
4435 (defun gnus-uncompress-marks (marks)
4436 "Uncompress the mark ranges in MARKS."
4437 (let ((uncompressed '(score bookmark))
4438 out)
4439 (while marks
4440 (if (memq (caar marks) uncompressed)
4441 (push (car marks) out)
4442 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4443 (setq marks (cdr marks)))
4444 out))
4446 (defun gnus-adjust-marked-articles (info)
4447 "Set all article lists and remove all marks that are no longer valid."
4448 (let* ((marked-lists (gnus-info-marks info))
4449 (active (gnus-active (gnus-info-group info)))
4450 (min (car active))
4451 (max (cdr active))
4452 (types gnus-article-mark-lists)
4453 (uncompressed '(score bookmark killed))
4454 marks var articles article mark)
4456 (while marked-lists
4457 (setq marks (pop marked-lists))
4458 (set (setq var (intern (format "gnus-newsgroup-%s"
4459 (car (rassq (setq mark (car marks))
4460 types)))))
4461 (if (memq (car marks) uncompressed) (cdr marks)
4462 (gnus-uncompress-range (cdr marks))))
4464 (setq articles (symbol-value var))
4466 ;; All articles have to be subsets of the active articles.
4467 (cond
4468 ;; Adjust "simple" lists.
4469 ((memq mark '(tick dormant expire reply save))
4470 (while articles
4471 (when (or (< (setq article (pop articles)) min) (> article max))
4472 (set var (delq article (symbol-value var))))))
4473 ;; Adjust assocs.
4474 ((memq mark uncompressed)
4475 (when (not (listp (cdr (symbol-value var))))
4476 (set var (list (symbol-value var))))
4477 (when (not (listp (cdr articles)))
4478 (setq articles (list articles)))
4479 (while articles
4480 (when (or (not (consp (setq article (pop articles))))
4481 (< (car article) min)
4482 (> (car article) max))
4483 (set var (delq article (symbol-value var))))))))))
4485 (defun gnus-update-missing-marks (missing)
4486 "Go through the list of MISSING articles and remove them from the mark lists."
4487 (when missing
4488 (let ((types gnus-article-mark-lists)
4489 var m)
4490 ;; Go through all types.
4491 (while types
4492 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4493 (when (symbol-value var)
4494 ;; This list has articles. So we delete all missing articles
4495 ;; from it.
4496 (setq m missing)
4497 (while m
4498 (set var (delq (pop m) (symbol-value var)))))))))
4500 (defun gnus-update-marks ()
4501 "Enter the various lists of marked articles into the newsgroup info list."
4502 (let ((types gnus-article-mark-lists)
4503 (info (gnus-get-info gnus-newsgroup-name))
4504 (uncompressed '(score bookmark killed))
4505 type list newmarked symbol delta-marks)
4506 (when info
4507 ;; Add all marks lists to the list of marks lists.
4508 (while (setq type (pop types))
4509 (setq list (symbol-value
4510 (setq symbol
4511 (intern (format "gnus-newsgroup-%s"
4512 (car type))))))
4514 (when list
4515 ;; Get rid of the entries of the articles that have the
4516 ;; default score.
4517 (when (and (eq (cdr type) 'score)
4518 gnus-save-score
4519 list)
4520 (let* ((arts list)
4521 (prev (cons nil list))
4522 (all prev))
4523 (while arts
4524 (if (or (not (consp (car arts)))
4525 (= (cdar arts) gnus-summary-default-score))
4526 (setcdr prev (cdr arts))
4527 (setq prev arts))
4528 (setq arts (cdr arts)))
4529 (setq list (cdr all)))))
4531 (unless (memq (cdr type) uncompressed)
4532 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4534 (when (gnus-check-backend-function
4535 'request-set-mark gnus-newsgroup-name)
4536 ;; propagate flags to server, with the following exceptions:
4537 ;; uncompressed:s are not proper flags (they are cons cells)
4538 ;; cache is a internal gnus flag
4539 ;; download are local to one gnus installation (well)
4540 ;; unsend are for nndraft groups only
4541 ;; xxx: generality of this? this suits nnimap anyway
4542 (unless (memq (cdr type) (append '(cache download unsend)
4543 uncompressed))
4544 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4545 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4546 (add (gnus-remove-from-range
4547 (gnus-copy-sequence list) old)))
4548 (when add
4549 (push (list add 'add (list (cdr type))) delta-marks))
4550 (when del
4551 (push (list del 'del (list (cdr type))) delta-marks)))))
4553 (when list
4554 (push (cons (cdr type) list) newmarked)))
4556 (when delta-marks
4557 (unless (gnus-check-group gnus-newsgroup-name)
4558 (error "Can't open server for %s" gnus-newsgroup-name))
4559 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4561 ;; Enter these new marks into the info of the group.
4562 (if (nthcdr 3 info)
4563 (setcar (nthcdr 3 info) newmarked)
4564 ;; Add the marks lists to the end of the info.
4565 (when newmarked
4566 (setcdr (nthcdr 2 info) (list newmarked))))
4568 ;; Cut off the end of the info if there's nothing else there.
4569 (let ((i 5))
4570 (while (and (> i 2)
4571 (not (nth i info)))
4572 (when (nthcdr (decf i) info)
4573 (setcdr (nthcdr i info) nil)))))))
4575 (defun gnus-set-mode-line (where)
4576 "Set the mode line of the article or summary buffers.
4577 If WHERE is `summary', the summary mode line format will be used."
4578 ;; Is this mode line one we keep updated?
4579 (when (and (memq where gnus-updated-mode-lines)
4580 (symbol-value
4581 (intern (format "gnus-%s-mode-line-format-spec" where))))
4582 (let (mode-string)
4583 (save-excursion
4584 ;; We evaluate this in the summary buffer since these
4585 ;; variables are buffer-local to that buffer.
4586 (set-buffer gnus-summary-buffer)
4587 ;; We bind all these variables that are used in the `eval' form
4588 ;; below.
4589 (let* ((mformat (symbol-value
4590 (intern
4591 (format "gnus-%s-mode-line-format-spec" where))))
4592 (gnus-tmp-group-name (gnus-group-name-decode
4593 gnus-newsgroup-name
4594 (gnus-group-name-charset
4596 gnus-newsgroup-name)))
4597 (gnus-tmp-article-number (or gnus-current-article 0))
4598 (gnus-tmp-unread gnus-newsgroup-unreads)
4599 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4600 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4601 (gnus-tmp-unread-and-unselected
4602 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4603 (zerop gnus-tmp-unselected))
4605 ((zerop gnus-tmp-unselected)
4606 (format "{%d more}" gnus-tmp-unread-and-unticked))
4607 (t (format "{%d(+%d) more}"
4608 gnus-tmp-unread-and-unticked
4609 gnus-tmp-unselected))))
4610 (gnus-tmp-subject
4611 (if (and gnus-current-headers
4612 (vectorp gnus-current-headers))
4613 (gnus-mode-string-quote
4614 (mail-header-subject gnus-current-headers))
4615 ""))
4616 bufname-length max-len
4617 gnus-tmp-header);; passed as argument to any user-format-funcs
4618 (setq mode-string (eval mformat))
4619 (setq bufname-length (if (string-match "%b" mode-string)
4620 (- (length
4621 (buffer-name
4622 (if (eq where 'summary)
4624 (get-buffer gnus-article-buffer))))
4627 (setq max-len (max 4 (if gnus-mode-non-string-length
4628 (- (window-width)
4629 gnus-mode-non-string-length
4630 bufname-length)
4631 (length mode-string))))
4632 ;; We might have to chop a bit of the string off...
4633 (when (> (length mode-string) max-len)
4634 (setq mode-string
4635 (concat (truncate-string-to-width mode-string (- max-len 3))
4636 "...")))
4637 ;; Pad the mode string a bit.
4638 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4639 ;; Update the mode line.
4640 (setq mode-line-buffer-identification
4641 (gnus-mode-line-buffer-identification (list mode-string)))
4642 (set-buffer-modified-p t))))
4644 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4645 "Go through the HEADERS list and add all Xrefs to a hash table.
4646 The resulting hash table is returned, or nil if no Xrefs were found."
4647 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4648 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4649 (xref-hashtb (gnus-make-hashtable))
4650 start group entry number xrefs header)
4651 (while headers
4652 (setq header (pop headers))
4653 (when (and (setq xrefs (mail-header-xref header))
4654 (not (memq (setq number (mail-header-number header))
4655 unreads)))
4656 (setq start 0)
4657 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4658 (setq start (match-end 0))
4659 (setq group (if prefix
4660 (concat prefix (substring xrefs (match-beginning 1)
4661 (match-end 1)))
4662 (substring xrefs (match-beginning 1) (match-end 1))))
4663 (setq number
4664 (string-to-int (substring xrefs (match-beginning 2)
4665 (match-end 2))))
4666 (if (setq entry (gnus-gethash group xref-hashtb))
4667 (setcdr entry (cons number (cdr entry)))
4668 (gnus-sethash group (cons number nil) xref-hashtb)))))
4669 (and start xref-hashtb)))
4671 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4672 "Look through all the headers and mark the Xrefs as read."
4673 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4674 name entry info xref-hashtb idlist method nth4)
4675 (save-excursion
4676 (set-buffer gnus-group-buffer)
4677 (when (setq xref-hashtb
4678 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4679 (mapatoms
4680 (lambda (group)
4681 (unless (string= from-newsgroup (setq name (symbol-name group)))
4682 (setq idlist (symbol-value group))
4683 ;; Dead groups are not updated.
4684 (and (prog1
4685 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4686 info (nth 2 entry))
4687 (when (stringp (setq nth4 (gnus-info-method info)))
4688 (setq nth4 (gnus-server-to-method nth4))))
4689 ;; Only do the xrefs if the group has the same
4690 ;; select method as the group we have just read.
4691 (or (gnus-methods-equal-p
4692 nth4 (gnus-find-method-for-group from-newsgroup))
4693 virtual
4694 (equal nth4 (setq method (gnus-find-method-for-group
4695 from-newsgroup)))
4696 (and (equal (car nth4) (car method))
4697 (equal (nth 1 nth4) (nth 1 method))))
4698 gnus-use-cross-reference
4699 (or (not (eq gnus-use-cross-reference t))
4700 virtual
4701 ;; Only do cross-references on subscribed
4702 ;; groups, if that is what is wanted.
4703 (<= (gnus-info-level info) gnus-level-subscribed))
4704 (gnus-group-make-articles-read name idlist))))
4705 xref-hashtb)))))
4707 (defun gnus-compute-read-articles (group articles)
4708 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4709 (info (nth 2 entry))
4710 (active (gnus-active group))
4711 ninfo)
4712 (when entry
4713 ;; First peel off all invalid article numbers.
4714 (when active
4715 (let ((ids articles)
4716 id first)
4717 (while (setq id (pop ids))
4718 (when (and first (> id (cdr active)))
4719 ;; We'll end up in this situation in one particular
4720 ;; obscure situation. If you re-scan a group and get
4721 ;; a new article that is cross-posted to a different
4722 ;; group that has not been re-scanned, you might get
4723 ;; crossposted article that has a higher number than
4724 ;; Gnus believes possible. So we re-activate this
4725 ;; group as well. This might mean doing the
4726 ;; crossposting thingy will *increase* the number
4727 ;; of articles in some groups. Tsk, tsk.
4728 (setq active (or (gnus-activate-group group) active)))
4729 (when (or (> id (cdr active))
4730 (< id (car active)))
4731 (setq articles (delq id articles))))))
4732 ;; If the read list is nil, we init it.
4733 (if (and active
4734 (null (gnus-info-read info))
4735 (> (car active) 1))
4736 (setq ninfo (cons 1 (1- (car active))))
4737 (setq ninfo (gnus-info-read info)))
4738 ;; Then we add the read articles to the range.
4739 (gnus-add-to-range
4740 ninfo (setq articles (sort articles '<))))))
4742 (defun gnus-group-make-articles-read (group articles)
4743 "Update the info of GROUP to say that ARTICLES are read."
4744 (let* ((num 0)
4745 (entry (gnus-gethash group gnus-newsrc-hashtb))
4746 (info (nth 2 entry))
4747 (active (gnus-active group))
4748 range)
4749 (when entry
4750 (setq range (gnus-compute-read-articles group articles))
4751 (save-excursion
4752 (set-buffer gnus-group-buffer)
4753 (gnus-undo-register
4754 `(progn
4755 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4756 (gnus-info-set-read ',info ',(gnus-info-read info))
4757 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4758 (gnus-group-update-group ,group t))))
4759 ;; Add the read articles to the range.
4760 (gnus-info-set-read info range)
4761 ;; Then we have to re-compute how many unread
4762 ;; articles there are in this group.
4763 (when active
4764 (cond
4765 ((not range)
4766 (setq num (- (1+ (cdr active)) (car active))))
4767 ((not (listp (cdr range)))
4768 (setq num (- (cdr active) (- (1+ (cdr range))
4769 (car range)))))
4771 (while range
4772 (if (numberp (car range))
4773 (setq num (1+ num))
4774 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4775 (setq range (cdr range)))
4776 (setq num (- (cdr active) num))))
4777 ;; Update the number of unread articles.
4778 (setcar entry num)
4779 ;; Update the group buffer.
4780 (gnus-group-update-group group t)))))
4782 (defvar gnus-newsgroup-none-id 0)
4784 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4785 (let ((cur nntp-server-buffer)
4786 (dependencies
4787 (or dependencies
4788 (save-excursion (set-buffer gnus-summary-buffer)
4789 gnus-newsgroup-dependencies)))
4790 headers id end ref
4791 (mail-parse-charset gnus-newsgroup-charset)
4792 (mail-parse-ignored-charsets
4793 (save-excursion (condition-case nil
4794 (set-buffer gnus-summary-buffer)
4795 (error))
4796 gnus-newsgroup-ignored-charsets)))
4797 (save-excursion
4798 (set-buffer nntp-server-buffer)
4799 ;; Translate all TAB characters into SPACE characters.
4800 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4801 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4802 (gnus-run-hooks 'gnus-parse-headers-hook)
4803 (let ((case-fold-search t)
4804 in-reply-to header p lines chars)
4805 (goto-char (point-min))
4806 ;; Search to the beginning of the next header. Error messages
4807 ;; do not begin with 2 or 3.
4808 (while (re-search-forward "^[23][0-9]+ " nil t)
4809 (setq id nil
4810 ref nil)
4811 ;; This implementation of this function, with nine
4812 ;; search-forwards instead of the one re-search-forward and
4813 ;; a case (which basically was the old function) is actually
4814 ;; about twice as fast, even though it looks messier. You
4815 ;; can't have everything, I guess. Speed and elegance
4816 ;; doesn't always go hand in hand.
4817 (setq
4818 header
4819 (vector
4820 ;; Number.
4821 (prog1
4822 (read cur)
4823 (end-of-line)
4824 (setq p (point))
4825 (narrow-to-region (point)
4826 (or (and (search-forward "\n.\n" nil t)
4827 (- (point) 2))
4828 (point))))
4829 ;; Subject.
4830 (progn
4831 (goto-char p)
4832 (if (search-forward "\nsubject: " nil t)
4833 (funcall gnus-decode-encoded-word-function
4834 (nnheader-header-value))
4835 "(none)"))
4836 ;; From.
4837 (progn
4838 (goto-char p)
4839 (if (or (search-forward "\nfrom: " nil t)
4840 (search-forward "\nfrom:" nil t))
4841 (funcall gnus-decode-encoded-word-function
4842 (nnheader-header-value))
4843 "(nobody)"))
4844 ;; Date.
4845 (progn
4846 (goto-char p)
4847 (if (search-forward "\ndate: " nil t)
4848 (nnheader-header-value) ""))
4849 ;; Message-ID.
4850 (progn
4851 (goto-char p)
4852 (setq id (if (re-search-forward
4853 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4854 ;; We do it this way to make sure the Message-ID
4855 ;; is (somewhat) syntactically valid.
4856 (buffer-substring (match-beginning 1)
4857 (match-end 1))
4858 ;; If there was no message-id, we just fake one
4859 ;; to make subsequent routines simpler.
4860 (nnheader-generate-fake-message-id))))
4861 ;; References.
4862 (progn
4863 (goto-char p)
4864 (if (search-forward "\nreferences: " nil t)
4865 (progn
4866 (setq end (point))
4867 (prog1
4868 (nnheader-header-value)
4869 (setq ref
4870 (buffer-substring
4871 (progn
4872 (end-of-line)
4873 (search-backward ">" end t)
4874 (1+ (point)))
4875 (progn
4876 (search-backward "<" end t)
4877 (point))))))
4878 ;; Get the references from the in-reply-to header if there
4879 ;; were no references and the in-reply-to header looks
4880 ;; promising.
4881 (if (and (search-forward "\nin-reply-to: " nil t)
4882 (setq in-reply-to (nnheader-header-value))
4883 (string-match "<[^>]+>" in-reply-to))
4884 (let (ref2)
4885 (setq ref (substring in-reply-to (match-beginning 0)
4886 (match-end 0)))
4887 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4888 (setq ref2 (substring in-reply-to (match-beginning 0)
4889 (match-end 0)))
4890 (when (> (length ref2) (length ref))
4891 (setq ref ref2)))
4892 ref)
4893 (setq ref nil))))
4894 ;; Chars.
4895 (progn
4896 (goto-char p)
4897 (if (search-forward "\nchars: " nil t)
4898 (if (numberp (setq chars (ignore-errors (read cur))))
4899 chars 0)
4901 ;; Lines.
4902 (progn
4903 (goto-char p)
4904 (if (search-forward "\nlines: " nil t)
4905 (if (numberp (setq lines (ignore-errors (read cur))))
4906 lines 0)
4908 ;; Xref.
4909 (progn
4910 (goto-char p)
4911 (and (search-forward "\nxref: " nil t)
4912 (nnheader-header-value)))
4913 ;; Extra.
4914 (when gnus-extra-headers
4915 (let ((extra gnus-extra-headers)
4916 out)
4917 (while extra
4918 (goto-char p)
4919 (when (search-forward
4920 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4921 (push (cons (car extra) (nnheader-header-value))
4922 out))
4923 (pop extra))
4924 out))))
4925 (when (equal id ref)
4926 (setq ref nil))
4928 (when gnus-alter-header-function
4929 (funcall gnus-alter-header-function header)
4930 (setq id (mail-header-id header)
4931 ref (gnus-parent-id (mail-header-references header))))
4933 (when (setq header
4934 (gnus-dependencies-add-header
4935 header dependencies force-new))
4936 (push header headers))
4937 (goto-char (point-max))
4938 (widen))
4939 (nreverse headers)))))
4941 ;; Goes through the xover lines and returns a list of vectors
4942 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4943 force-new dependencies
4944 group also-fetch-heads)
4945 "Parse the news overview data in the server buffer.
4946 Return a list of headers that match SEQUENCE (see
4947 `nntp-retrieve-headers')."
4948 ;; Get the Xref when the users reads the articles since most/some
4949 ;; NNTP servers do not include Xrefs when using XOVER.
4950 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4951 (let ((mail-parse-charset gnus-newsgroup-charset)
4952 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4953 (cur nntp-server-buffer)
4954 (dependencies (or dependencies gnus-newsgroup-dependencies))
4955 number headers header)
4956 (save-excursion
4957 (set-buffer nntp-server-buffer)
4958 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4959 ;; Allow the user to mangle the headers before parsing them.
4960 (gnus-run-hooks 'gnus-parse-headers-hook)
4961 (goto-char (point-min))
4962 (while (not (eobp))
4963 (condition-case ()
4964 (while (and sequence (not (eobp)))
4965 (setq number (read cur))
4966 (while (and sequence
4967 (< (car sequence) number))
4968 (setq sequence (cdr sequence)))
4969 (and sequence
4970 (eq number (car sequence))
4971 (progn
4972 (setq sequence (cdr sequence))
4973 (setq header (inline
4974 (gnus-nov-parse-line
4975 number dependencies force-new))))
4976 (push header headers))
4977 (forward-line 1))
4978 (error
4979 (gnus-error 4 "Strange nov line (%d)"
4980 (count-lines (point-min) (point)))))
4981 (forward-line 1))
4982 ;; A common bug in inn is that if you have posted an article and
4983 ;; then retrieves the active file, it will answer correctly --
4984 ;; the new article is included. However, a NOV entry for the
4985 ;; article may not have been generated yet, so this may fail.
4986 ;; We work around this problem by retrieving the last few
4987 ;; headers using HEAD.
4988 (if (or (not also-fetch-heads)
4989 (not sequence))
4990 ;; We (probably) got all the headers.
4991 (nreverse headers)
4992 (let ((gnus-nov-is-evil t))
4993 (nconc
4994 (nreverse headers)
4995 (when (gnus-retrieve-headers sequence group)
4996 (gnus-get-newsgroup-headers))))))))
4998 (defun gnus-article-get-xrefs ()
4999 "Fill in the Xref value in `gnus-current-headers', if necessary.
5000 This is meant to be called in `gnus-article-internal-prepare-hook'."
5001 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5002 gnus-current-headers)))
5003 (or (not gnus-use-cross-reference)
5004 (not headers)
5005 (and (mail-header-xref headers)
5006 (not (string= (mail-header-xref headers) "")))
5007 (let ((case-fold-search t)
5008 xref)
5009 (save-restriction
5010 (nnheader-narrow-to-headers)
5011 (goto-char (point-min))
5012 (when (or (and (not (eobp))
5013 (eq (downcase (char-after)) ?x)
5014 (looking-at "Xref:"))
5015 (search-forward "\nXref:" nil t))
5016 (goto-char (1+ (match-end 0)))
5017 (setq xref (buffer-substring (point)
5018 (progn (end-of-line) (point))))
5019 (mail-header-set-xref headers xref)))))))
5021 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5022 "Find article ID and insert the summary line for that article.
5023 OLD-HEADER can either be a header or a line number to insert
5024 the subject line on."
5025 (let* ((line (and (numberp old-header) old-header))
5026 (old-header (and (vectorp old-header) old-header))
5027 (header (cond ((and old-header use-old-header)
5028 old-header)
5029 ((and (numberp id)
5030 (gnus-number-to-header id))
5031 (gnus-number-to-header id))
5033 (gnus-read-header id))))
5034 (number (and (numberp id) id))
5036 (when header
5037 ;; Rebuild the thread that this article is part of and go to the
5038 ;; article we have fetched.
5039 (when (and (not gnus-show-threads)
5040 old-header)
5041 (when (and number
5042 (setq d (gnus-data-find (mail-header-number old-header))))
5043 (goto-char (gnus-data-pos d))
5044 (gnus-data-remove
5045 number
5046 (- (gnus-point-at-bol)
5047 (prog1
5048 (1+ (gnus-point-at-eol))
5049 (gnus-delete-line))))))
5050 (when old-header
5051 (mail-header-set-number header (mail-header-number old-header)))
5052 (setq gnus-newsgroup-sparse
5053 (delq (setq number (mail-header-number header))
5054 gnus-newsgroup-sparse))
5055 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5056 (push number gnus-newsgroup-limit)
5057 (gnus-rebuild-thread (mail-header-id header) line)
5058 (gnus-summary-goto-subject number nil t))
5059 (when (and (numberp number)
5060 (> number 0))
5061 ;; We have to update the boundaries even if we can't fetch the
5062 ;; article if ID is a number -- so that the next `P' or `N'
5063 ;; command will fetch the previous (or next) article even
5064 ;; if the one we tried to fetch this time has been canceled.
5065 (when (> number gnus-newsgroup-end)
5066 (setq gnus-newsgroup-end number))
5067 (when (< number gnus-newsgroup-begin)
5068 (setq gnus-newsgroup-begin number))
5069 (setq gnus-newsgroup-unselected
5070 (delq number gnus-newsgroup-unselected)))
5071 ;; Report back a success?
5072 (and header (mail-header-number header))))
5074 ;;; Process/prefix in the summary buffer
5076 (defun gnus-summary-work-articles (n)
5077 "Return a list of articles to be worked upon.
5078 The prefix argument, the list of process marked articles, and the
5079 current article will be taken into consideration."
5080 (save-excursion
5081 (set-buffer gnus-summary-buffer)
5082 (cond
5084 ;; A numerical prefix has been given.
5085 (setq n (prefix-numeric-value n))
5086 (let ((backward (< n 0))
5087 (n (abs (prefix-numeric-value n)))
5088 articles article)
5089 (save-excursion
5090 (while
5091 (and (> n 0)
5092 (push (setq article (gnus-summary-article-number))
5093 articles)
5094 (if backward
5095 (gnus-summary-find-prev nil article)
5096 (gnus-summary-find-next nil article)))
5097 (decf n)))
5098 (nreverse articles)))
5099 ((and (gnus-region-active-p) (mark))
5100 (message "region active")
5101 ;; Work on the region between point and mark.
5102 (let ((max (max (point) (mark)))
5103 articles article)
5104 (save-excursion
5105 (goto-char (min (min (point) (mark))))
5106 (while
5107 (and
5108 (push (setq article (gnus-summary-article-number)) articles)
5109 (gnus-summary-find-next nil article)
5110 (< (point) max)))
5111 (nreverse articles))))
5112 (gnus-newsgroup-processable
5113 ;; There are process-marked articles present.
5114 ;; Save current state.
5115 (gnus-summary-save-process-mark)
5116 ;; Return the list.
5117 (reverse gnus-newsgroup-processable))
5119 ;; Just return the current article.
5120 (list (gnus-summary-article-number))))))
5122 (defmacro gnus-summary-iterate (arg &rest forms)
5123 "Iterate over the process/prefixed articles and do FORMS.
5124 ARG is the interactive prefix given to the command. FORMS will be
5125 executed with point over the summary line of the articles."
5126 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5127 `(let ((,articles (gnus-summary-work-articles ,arg)))
5128 (while ,articles
5129 (gnus-summary-goto-subject (car ,articles))
5130 ,@forms
5131 (pop ,articles)))))
5133 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5134 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5136 (defun gnus-summary-save-process-mark ()
5137 "Push the current set of process marked articles on the stack."
5138 (interactive)
5139 (push (copy-sequence gnus-newsgroup-processable)
5140 gnus-newsgroup-process-stack))
5142 (defun gnus-summary-kill-process-mark ()
5143 "Push the current set of process marked articles on the stack and unmark."
5144 (interactive)
5145 (gnus-summary-save-process-mark)
5146 (gnus-summary-unmark-all-processable))
5148 (defun gnus-summary-yank-process-mark ()
5149 "Pop the last process mark state off the stack and restore it."
5150 (interactive)
5151 (unless gnus-newsgroup-process-stack
5152 (error "Empty mark stack"))
5153 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5155 (defun gnus-summary-process-mark-set (set)
5156 "Make SET into the current process marked articles."
5157 (gnus-summary-unmark-all-processable)
5158 (while set
5159 (gnus-summary-set-process-mark (pop set))))
5161 ;;; Searching and stuff
5163 (defun gnus-summary-search-group (&optional backward use-level)
5164 "Search for next unread newsgroup.
5165 If optional argument BACKWARD is non-nil, search backward instead."
5166 (save-excursion
5167 (set-buffer gnus-group-buffer)
5168 (when (gnus-group-search-forward
5169 backward nil (if use-level (gnus-group-group-level) nil))
5170 (gnus-group-group-name))))
5172 (defun gnus-summary-best-group (&optional exclude-group)
5173 "Find the name of the best unread group.
5174 If EXCLUDE-GROUP, do not go to this group."
5175 (save-excursion
5176 (set-buffer gnus-group-buffer)
5177 (save-excursion
5178 (gnus-group-best-unread-group exclude-group))))
5180 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5181 (if backward (gnus-summary-find-prev)
5182 (let* ((dummy (gnus-summary-article-intangible-p))
5183 (article (or article (gnus-summary-article-number)))
5184 (arts (gnus-data-find-list article))
5185 result)
5186 (when (and (not dummy)
5187 (or (not gnus-summary-check-current)
5188 (not unread)
5189 (not (gnus-data-unread-p (car arts)))))
5190 (setq arts (cdr arts)))
5191 (when (setq result
5192 (if unread
5193 (progn
5194 (while arts
5195 (when (or (and undownloaded
5196 (eq gnus-undownloaded-mark
5197 (gnus-data-mark (car arts))))
5198 (gnus-data-unread-p (car arts)))
5199 (setq result (car arts)
5200 arts nil))
5201 (setq arts (cdr arts)))
5202 result)
5203 (car arts)))
5204 (goto-char (gnus-data-pos result))
5205 (gnus-data-number result)))))
5207 (defun gnus-summary-find-prev (&optional unread article)
5208 (let* ((eobp (eobp))
5209 (article (or article (gnus-summary-article-number)))
5210 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5211 result)
5212 (when (and (not eobp)
5213 (or (not gnus-summary-check-current)
5214 (not unread)
5215 (not (gnus-data-unread-p (car arts)))))
5216 (setq arts (cdr arts)))
5217 (when (setq result
5218 (if unread
5219 (progn
5220 (while arts
5221 (when (gnus-data-unread-p (car arts))
5222 (setq result (car arts)
5223 arts nil))
5224 (setq arts (cdr arts)))
5225 result)
5226 (car arts)))
5227 (goto-char (gnus-data-pos result))
5228 (gnus-data-number result))))
5230 (defun gnus-summary-find-subject (subject &optional unread backward article)
5231 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5232 (article (or article (gnus-summary-article-number)))
5233 (articles (gnus-data-list backward))
5234 (arts (gnus-data-find-list article articles))
5235 result)
5236 (when (or (not gnus-summary-check-current)
5237 (not unread)
5238 (not (gnus-data-unread-p (car arts))))
5239 (setq arts (cdr arts)))
5240 (while arts
5241 (and (or (not unread)
5242 (gnus-data-unread-p (car arts)))
5243 (vectorp (gnus-data-header (car arts)))
5244 (gnus-subject-equal
5245 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5246 (setq result (car arts)
5247 arts nil))
5248 (setq arts (cdr arts)))
5249 (and result
5250 (goto-char (gnus-data-pos result))
5251 (gnus-data-number result))))
5253 (defun gnus-summary-search-forward (&optional unread subject backward)
5254 "Search forward for an article.
5255 If UNREAD, look for unread articles. If SUBJECT, look for
5256 articles with that subject. If BACKWARD, search backward instead."
5257 (cond (subject (gnus-summary-find-subject subject unread backward))
5258 (backward (gnus-summary-find-prev unread))
5259 (t (gnus-summary-find-next unread))))
5261 (defun gnus-recenter (&optional n)
5262 "Center point in window and redisplay frame.
5263 Also do horizontal recentering."
5264 (interactive "P")
5265 (when (and gnus-auto-center-summary
5266 (not (eq gnus-auto-center-summary 'vertical)))
5267 (gnus-horizontal-recenter))
5268 (recenter n))
5270 (defun gnus-summary-recenter ()
5271 "Center point in the summary window.
5272 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5273 displayed, no centering will be performed."
5274 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5275 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5276 (interactive)
5277 (let* ((top (cond ((< (window-height) 4) 0)
5278 ((< (window-height) 7) 1)
5279 (t (if (numberp gnus-auto-center-summary)
5280 gnus-auto-center-summary
5281 2))))
5282 (height (1- (window-height)))
5283 (bottom (save-excursion (goto-char (point-max))
5284 (forward-line (- height))
5285 (point)))
5286 (window (get-buffer-window (current-buffer))))
5287 ;; The user has to want it.
5288 (when gnus-auto-center-summary
5289 (when (get-buffer-window gnus-article-buffer)
5290 ;; Only do recentering when the article buffer is displayed,
5291 ;; Set the window start to either `bottom', which is the biggest
5292 ;; possible valid number, or the second line from the top,
5293 ;; whichever is the least.
5294 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5295 (if (> bottom top-pos)
5296 ;; Keep the second line from the top visible
5297 (set-window-start window top-pos t)
5298 ;; Try to keep the bottom line visible; if it's partially
5299 ;; obscured, either scroll one more line to make it fully
5300 ;; visible, or revert to using TOP-POS.
5301 (save-excursion
5302 (goto-char (point-max))
5303 (forward-line -1)
5304 (let ((last-line-start (point)))
5305 (goto-char bottom)
5306 (set-window-start window (point) t)
5307 (when (not (pos-visible-in-window-p last-line-start window))
5308 (forward-line 1)
5309 (set-window-start window (min (point) top-pos) t)))))))
5310 ;; Do horizontal recentering while we're at it.
5311 (when (and (get-buffer-window (current-buffer) t)
5312 (not (eq gnus-auto-center-summary 'vertical)))
5313 (let ((selected (selected-window)))
5314 (select-window (get-buffer-window (current-buffer) t))
5315 (gnus-summary-position-point)
5316 (gnus-horizontal-recenter)
5317 (select-window selected))))))
5319 (defun gnus-summary-jump-to-group (newsgroup)
5320 "Move point to NEWSGROUP in group mode buffer."
5321 ;; Keep update point of group mode buffer if visible.
5322 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5323 (save-window-excursion
5324 ;; Take care of tree window mode.
5325 (when (get-buffer-window gnus-group-buffer)
5326 (pop-to-buffer gnus-group-buffer))
5327 (gnus-group-jump-to-group newsgroup))
5328 (save-excursion
5329 ;; Take care of tree window mode.
5330 (if (get-buffer-window gnus-group-buffer)
5331 (pop-to-buffer gnus-group-buffer)
5332 (set-buffer gnus-group-buffer))
5333 (gnus-group-jump-to-group newsgroup))))
5335 ;; This function returns a list of article numbers based on the
5336 ;; difference between the ranges of read articles in this group and
5337 ;; the range of active articles.
5338 (defun gnus-list-of-unread-articles (group)
5339 (let* ((read (gnus-info-read (gnus-get-info group)))
5340 (active (or (gnus-active group) (gnus-activate-group group)))
5341 (last (cdr active))
5342 first nlast unread)
5343 ;; If none are read, then all are unread.
5344 (if (not read)
5345 (setq first (car active))
5346 ;; If the range of read articles is a single range, then the
5347 ;; first unread article is the article after the last read
5348 ;; article. Sounds logical, doesn't it?
5349 (if (and (not (listp (cdr read)))
5350 (or (< (car read) (car active))
5351 (progn (setq read (list read))
5352 nil)))
5353 (setq first (max (car active) (1+ (cdr read))))
5354 ;; `read' is a list of ranges.
5355 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5356 (caar read)))
5358 (setq first (car active)))
5359 (while read
5360 (when first
5361 (while (< first nlast)
5362 (push first unread)
5363 (setq first (1+ first))))
5364 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5365 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5366 (setq read (cdr read)))))
5367 ;; And add the last unread articles.
5368 (while (<= first last)
5369 (push first unread)
5370 (setq first (1+ first)))
5371 ;; Return the list of unread articles.
5372 (delq 0 (nreverse unread))))
5374 (defun gnus-list-of-read-articles (group)
5375 "Return a list of unread, unticked and non-dormant articles."
5376 (let* ((info (gnus-get-info group))
5377 (marked (gnus-info-marks info))
5378 (active (gnus-active group)))
5379 (and info active
5380 (gnus-set-difference
5381 (gnus-sorted-complement
5382 (gnus-uncompress-range active)
5383 (gnus-list-of-unread-articles group))
5384 (append
5385 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5386 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5388 ;; Various summary commands
5390 (defun gnus-summary-select-article-buffer ()
5391 "Reconfigure windows to show article buffer."
5392 (interactive)
5393 (if (not (gnus-buffer-live-p gnus-article-buffer))
5394 (error "There is no article buffer for this summary buffer")
5395 (gnus-configure-windows 'article)
5396 (select-window (get-buffer-window gnus-article-buffer))))
5398 (defun gnus-summary-universal-argument (arg)
5399 "Perform any operation on all articles that are process/prefixed."
5400 (interactive "P")
5401 (let ((articles (gnus-summary-work-articles arg))
5402 func article)
5403 (if (eq
5404 (setq
5405 func
5406 (key-binding
5407 (read-key-sequence
5408 (substitute-command-keys
5409 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5410 'undefined)
5411 (gnus-error 1 "Undefined key")
5412 (save-excursion
5413 (while articles
5414 (gnus-summary-goto-subject (setq article (pop articles)))
5415 (let (gnus-newsgroup-processable)
5416 (command-execute func))
5417 (gnus-summary-remove-process-mark article)))))
5418 (gnus-summary-position-point))
5420 (defun gnus-summary-toggle-truncation (&optional arg)
5421 "Toggle truncation of summary lines.
5422 With arg, turn line truncation on if arg is positive."
5423 (interactive "P")
5424 (setq truncate-lines
5425 (if (null arg) (not truncate-lines)
5426 (> (prefix-numeric-value arg) 0)))
5427 (redraw-display))
5429 (defun gnus-summary-reselect-current-group (&optional all rescan)
5430 "Exit and then reselect the current newsgroup.
5431 The prefix argument ALL means to select all articles."
5432 (interactive "P")
5433 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5434 (error "Ephemeral groups can't be reselected"))
5435 (let ((current-subject (gnus-summary-article-number))
5436 (group gnus-newsgroup-name))
5437 (setq gnus-newsgroup-begin nil)
5438 (gnus-summary-exit)
5439 ;; We have to adjust the point of group mode buffer because
5440 ;; point was moved to the next unread newsgroup by exiting.
5441 (gnus-summary-jump-to-group group)
5442 (when rescan
5443 (save-excursion
5444 (gnus-group-get-new-news-this-group 1)))
5445 (gnus-group-read-group all t)
5446 (gnus-summary-goto-subject current-subject nil t)))
5448 (defun gnus-summary-rescan-group (&optional all)
5449 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5450 (interactive "P")
5451 (gnus-summary-reselect-current-group all t))
5453 (defun gnus-summary-update-info (&optional non-destructive)
5454 (save-excursion
5455 (let ((group gnus-newsgroup-name))
5456 (when group
5457 (when gnus-newsgroup-kill-headers
5458 (setq gnus-newsgroup-killed
5459 (gnus-compress-sequence
5460 (nconc
5461 (gnus-set-sorted-intersection
5462 (gnus-uncompress-range gnus-newsgroup-killed)
5463 (setq gnus-newsgroup-unselected
5464 (sort gnus-newsgroup-unselected '<)))
5465 (setq gnus-newsgroup-unreads
5466 (sort gnus-newsgroup-unreads '<)))
5467 t)))
5468 (unless (listp (cdr gnus-newsgroup-killed))
5469 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5470 (let ((headers gnus-newsgroup-headers))
5471 ;; Set the new ranges of read articles.
5472 (save-excursion
5473 (set-buffer gnus-group-buffer)
5474 (gnus-undo-force-boundary))
5475 (gnus-update-read-articles
5476 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5477 ;; Set the current article marks.
5478 (let ((gnus-newsgroup-scored
5479 (if (and (not gnus-save-score)
5480 (not non-destructive))
5482 gnus-newsgroup-scored)))
5483 (save-excursion
5484 (gnus-update-marks)))
5485 ;; Do the cross-ref thing.
5486 (when gnus-use-cross-reference
5487 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5488 ;; Do not switch windows but change the buffer to work.
5489 (set-buffer gnus-group-buffer)
5490 (unless (gnus-ephemeral-group-p group)
5491 (gnus-group-update-group group)))))))
5493 (defun gnus-summary-save-newsrc (&optional force)
5494 "Save the current number of read/marked articles in the dribble buffer.
5495 The dribble buffer will then be saved.
5496 If FORCE (the prefix), also save the .newsrc file(s)."
5497 (interactive "P")
5498 (gnus-summary-update-info t)
5499 (if force
5500 (gnus-save-newsrc-file)
5501 (gnus-dribble-save)))
5503 (defun gnus-summary-exit (&optional temporary)
5504 "Exit reading current newsgroup, and then return to group selection mode.
5505 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5506 (interactive)
5507 (gnus-set-global-variables)
5508 (when (gnus-buffer-live-p gnus-article-buffer)
5509 (save-excursion
5510 (set-buffer gnus-article-buffer)
5511 (mm-destroy-parts gnus-article-mime-handles)
5512 ;; Set it to nil for safety reason.
5513 (setq gnus-article-mime-handle-alist nil)
5514 (setq gnus-article-mime-handles nil)))
5515 (gnus-kill-save-kill-buffer)
5516 (gnus-async-halt-prefetch)
5517 (let* ((group gnus-newsgroup-name)
5518 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5519 (mode major-mode)
5520 (group-point nil)
5521 (buf (current-buffer)))
5522 (unless quit-config
5523 ;; Do adaptive scoring, and possibly save score files.
5524 (when gnus-newsgroup-adaptive
5525 (gnus-score-adaptive))
5526 (when gnus-use-scoring
5527 (gnus-score-save)))
5528 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5529 ;; If we have several article buffers, we kill them at exit.
5530 (unless gnus-single-article-buffer
5531 (gnus-kill-buffer gnus-original-article-buffer)
5532 (setq gnus-article-current nil))
5533 (when gnus-use-cache
5534 (gnus-cache-possibly-remove-articles)
5535 (gnus-cache-save-buffers))
5536 (gnus-async-prefetch-remove-group group)
5537 (when gnus-suppress-duplicates
5538 (gnus-dup-enter-articles))
5539 (when gnus-use-trees
5540 (gnus-tree-close group))
5541 (when gnus-use-cache
5542 (gnus-cache-write-active))
5543 ;; Remove entries for this group.
5544 (nnmail-purge-split-history (gnus-group-real-name group))
5545 ;; Make all changes in this group permanent.
5546 (unless quit-config
5547 (gnus-run-hooks 'gnus-exit-group-hook)
5548 (gnus-summary-update-info))
5549 (gnus-close-group group)
5550 ;; Make sure where we were, and go to next newsgroup.
5551 (set-buffer gnus-group-buffer)
5552 (unless quit-config
5553 (gnus-group-jump-to-group group))
5554 (gnus-run-hooks 'gnus-summary-exit-hook)
5555 (unless (or quit-config
5556 ;; If this group has disappeared from the summary
5557 ;; buffer, don't skip forwards.
5558 (not (string= group (gnus-group-group-name))))
5559 (gnus-group-next-unread-group 1))
5560 (setq group-point (point))
5561 (if temporary
5562 nil ;Nothing to do.
5563 ;; If we have several article buffers, we kill them at exit.
5564 (unless gnus-single-article-buffer
5565 (gnus-kill-buffer gnus-article-buffer)
5566 (gnus-kill-buffer gnus-original-article-buffer)
5567 (setq gnus-article-current nil))
5568 (set-buffer buf)
5569 (if (not gnus-kill-summary-on-exit)
5570 (gnus-deaden-summary)
5571 ;; We set all buffer-local variables to nil. It is unclear why
5572 ;; this is needed, but if we don't, buffer-local variables are
5573 ;; not garbage-collected, it seems. This would the lead to en
5574 ;; ever-growing Emacs.
5575 (gnus-summary-clear-local-variables)
5576 (when (get-buffer gnus-article-buffer)
5577 (bury-buffer gnus-article-buffer))
5578 ;; We clear the global counterparts of the buffer-local
5579 ;; variables as well, just to be on the safe side.
5580 (set-buffer gnus-group-buffer)
5581 (gnus-summary-clear-local-variables)
5582 ;; Return to group mode buffer.
5583 (when (eq mode 'gnus-summary-mode)
5584 (gnus-kill-buffer buf)))
5585 (setq gnus-current-select-method gnus-select-method)
5586 (pop-to-buffer gnus-group-buffer)
5587 (if (not quit-config)
5588 (progn
5589 (goto-char group-point)
5590 (gnus-configure-windows 'group 'force))
5591 (gnus-handle-ephemeral-exit quit-config))
5592 ;; Clear the current group name.
5593 (unless quit-config
5594 (setq gnus-newsgroup-name nil)))))
5596 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5597 (defun gnus-summary-exit-no-update (&optional no-questions)
5598 "Quit reading current newsgroup without updating read article info."
5599 (interactive)
5600 (let* ((group gnus-newsgroup-name)
5601 (quit-config (gnus-group-quit-config group)))
5602 (when (or no-questions
5603 gnus-expert-user
5604 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5605 (gnus-async-halt-prefetch)
5606 (mapcar 'funcall
5607 (delq 'gnus-summary-expire-articles
5608 (copy-sequence gnus-summary-prepare-exit-hook)))
5609 (when (gnus-buffer-live-p gnus-article-buffer)
5610 (save-excursion
5611 (set-buffer gnus-article-buffer)
5612 (mm-destroy-parts gnus-article-mime-handles)
5613 ;; Set it to nil for safety reason.
5614 (setq gnus-article-mime-handle-alist nil)
5615 (setq gnus-article-mime-handles nil)))
5616 ;; If we have several article buffers, we kill them at exit.
5617 (unless gnus-single-article-buffer
5618 (gnus-kill-buffer gnus-article-buffer)
5619 (gnus-kill-buffer gnus-original-article-buffer)
5620 (setq gnus-article-current nil))
5621 (if (not gnus-kill-summary-on-exit)
5622 (gnus-deaden-summary)
5623 (gnus-close-group group)
5624 (gnus-summary-clear-local-variables)
5625 (set-buffer gnus-group-buffer)
5626 (gnus-summary-clear-local-variables)
5627 (when (get-buffer gnus-summary-buffer)
5628 (kill-buffer gnus-summary-buffer)))
5629 (unless gnus-single-article-buffer
5630 (setq gnus-article-current nil))
5631 (when gnus-use-trees
5632 (gnus-tree-close group))
5633 (gnus-async-prefetch-remove-group group)
5634 (when (get-buffer gnus-article-buffer)
5635 (bury-buffer gnus-article-buffer))
5636 ;; Return to the group buffer.
5637 (gnus-configure-windows 'group 'force)
5638 ;; Clear the current group name.
5639 (setq gnus-newsgroup-name nil)
5640 (when (equal (gnus-group-group-name) group)
5641 (gnus-group-next-unread-group 1))
5642 (when quit-config
5643 (gnus-handle-ephemeral-exit quit-config)))))
5645 (defun gnus-handle-ephemeral-exit (quit-config)
5646 "Handle movement when leaving an ephemeral group.
5647 The state which existed when entering the ephemeral is reset."
5648 (if (not (buffer-name (car quit-config)))
5649 (gnus-configure-windows 'group 'force)
5650 (set-buffer (car quit-config))
5651 (cond ((eq major-mode 'gnus-summary-mode)
5652 (gnus-set-global-variables))
5653 ((eq major-mode 'gnus-article-mode)
5654 (save-excursion
5655 ;; The `gnus-summary-buffer' variable may point
5656 ;; to the old summary buffer when using a single
5657 ;; article buffer.
5658 (unless (gnus-buffer-live-p gnus-summary-buffer)
5659 (set-buffer gnus-group-buffer))
5660 (set-buffer gnus-summary-buffer)
5661 (gnus-set-global-variables))))
5662 (if (or (eq (cdr quit-config) 'article)
5663 (eq (cdr quit-config) 'pick))
5664 (progn
5665 ;; The current article may be from the ephemeral group
5666 ;; thus it is best that we reload this article
5667 (gnus-summary-show-article)
5668 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5669 (gnus-configure-windows 'pick 'force)
5670 (gnus-configure-windows (cdr quit-config) 'force)))
5671 (gnus-configure-windows (cdr quit-config) 'force))
5672 (when (eq major-mode 'gnus-summary-mode)
5673 (gnus-summary-next-subject 1 nil t)
5674 (gnus-summary-recenter)
5675 (gnus-summary-position-point))))
5677 ;;; Dead summaries.
5679 (defvar gnus-dead-summary-mode-map nil)
5681 (unless gnus-dead-summary-mode-map
5682 (setq gnus-dead-summary-mode-map (make-keymap))
5683 (suppress-keymap gnus-dead-summary-mode-map)
5684 (substitute-key-definition
5685 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5686 (let ((keys '("\C-d" "\r" "\177" [delete])))
5687 (while keys
5688 (define-key gnus-dead-summary-mode-map
5689 (pop keys) 'gnus-summary-wake-up-the-dead))))
5691 (defvar gnus-dead-summary-mode nil
5692 "Minor mode for Gnus summary buffers.")
5694 (defun gnus-dead-summary-mode (&optional arg)
5695 "Minor mode for Gnus summary buffers."
5696 (interactive "P")
5697 (when (eq major-mode 'gnus-summary-mode)
5698 (make-local-variable 'gnus-dead-summary-mode)
5699 (setq gnus-dead-summary-mode
5700 (if (null arg) (not gnus-dead-summary-mode)
5701 (> (prefix-numeric-value arg) 0)))
5702 (when gnus-dead-summary-mode
5703 (gnus-add-minor-mode
5704 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5706 (defun gnus-deaden-summary ()
5707 "Make the current summary buffer into a dead summary buffer."
5708 ;; Kill any previous dead summary buffer.
5709 (when (and gnus-dead-summary
5710 (buffer-name gnus-dead-summary))
5711 (save-excursion
5712 (set-buffer gnus-dead-summary)
5713 (when gnus-dead-summary-mode
5714 (kill-buffer (current-buffer)))))
5715 ;; Make this the current dead summary.
5716 (setq gnus-dead-summary (current-buffer))
5717 (gnus-dead-summary-mode 1)
5718 (let ((name (buffer-name)))
5719 (when (string-match "Summary" name)
5720 (rename-buffer
5721 (concat (substring name 0 (match-beginning 0)) "Dead "
5722 (substring name (match-beginning 0)))
5724 (bury-buffer))))
5726 (defun gnus-kill-or-deaden-summary (buffer)
5727 "Kill or deaden the summary BUFFER."
5728 (save-excursion
5729 (when (and (buffer-name buffer)
5730 (not gnus-single-article-buffer))
5731 (save-excursion
5732 (set-buffer buffer)
5733 (gnus-kill-buffer gnus-article-buffer)
5734 (gnus-kill-buffer gnus-original-article-buffer)))
5735 (cond (gnus-kill-summary-on-exit
5736 (when (and gnus-use-trees
5737 (gnus-buffer-exists-p buffer))
5738 (save-excursion
5739 (set-buffer buffer)
5740 (gnus-tree-close gnus-newsgroup-name)))
5741 (gnus-kill-buffer buffer))
5742 ((gnus-buffer-exists-p buffer)
5743 (save-excursion
5744 (set-buffer buffer)
5745 (gnus-deaden-summary))))))
5747 (defun gnus-summary-wake-up-the-dead (&rest args)
5748 "Wake up the dead summary buffer."
5749 (interactive)
5750 (gnus-dead-summary-mode -1)
5751 (let ((name (buffer-name)))
5752 (when (string-match "Dead " name)
5753 (rename-buffer
5754 (concat (substring name 0 (match-beginning 0))
5755 (substring name (match-end 0)))
5756 t)))
5757 (gnus-message 3 "This dead summary is now alive again"))
5759 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5760 (defun gnus-summary-fetch-faq (&optional faq-dir)
5761 "Fetch the FAQ for the current group.
5762 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5763 in."
5764 (interactive
5765 (list
5766 (when current-prefix-arg
5767 (completing-read
5768 "FAQ dir: " (and (listp gnus-group-faq-directory)
5769 (mapcar (lambda (file) (list file))
5770 gnus-group-faq-directory))))))
5771 (let (gnus-faq-buffer)
5772 (when (setq gnus-faq-buffer
5773 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5774 (gnus-configure-windows 'summary-faq))))
5776 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5777 (defun gnus-summary-describe-group (&optional force)
5778 "Describe the current newsgroup."
5779 (interactive "P")
5780 (gnus-group-describe-group force gnus-newsgroup-name))
5782 (defun gnus-summary-describe-briefly ()
5783 "Describe summary mode commands briefly."
5784 (interactive)
5785 (gnus-message 6 (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")))
5787 ;; Walking around group mode buffer from summary mode.
5789 (defun gnus-summary-next-group (&optional no-article target-group backward)
5790 "Exit current newsgroup and then select next unread newsgroup.
5791 If prefix argument NO-ARTICLE is non-nil, no article is selected
5792 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5793 previous group instead."
5794 (interactive "P")
5795 ;; Stop pre-fetching.
5796 (gnus-async-halt-prefetch)
5797 (let ((current-group gnus-newsgroup-name)
5798 (current-buffer (current-buffer))
5799 entered)
5800 ;; First we semi-exit this group to update Xrefs and all variables.
5801 ;; We can't do a real exit, because the window conf must remain
5802 ;; the same in case the user is prompted for info, and we don't
5803 ;; want the window conf to change before that...
5804 (gnus-summary-exit t)
5805 (while (not entered)
5806 ;; Then we find what group we are supposed to enter.
5807 (set-buffer gnus-group-buffer)
5808 (gnus-group-jump-to-group current-group)
5809 (setq target-group
5810 (or target-group
5811 (if (eq gnus-keep-same-level 'best)
5812 (gnus-summary-best-group gnus-newsgroup-name)
5813 (gnus-summary-search-group backward gnus-keep-same-level))))
5814 (if (not target-group)
5815 ;; There are no further groups, so we return to the group
5816 ;; buffer.
5817 (progn
5818 (gnus-message 5 "Returning to the group buffer")
5819 (setq entered t)
5820 (when (gnus-buffer-live-p current-buffer)
5821 (set-buffer current-buffer)
5822 (gnus-summary-exit))
5823 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5824 ;; We try to enter the target group.
5825 (gnus-group-jump-to-group target-group)
5826 (let ((unreads (gnus-group-group-unread)))
5827 (if (and (or (eq t unreads)
5828 (and unreads (not (zerop unreads))))
5829 (gnus-summary-read-group
5830 target-group nil no-article
5831 (and (buffer-name current-buffer) current-buffer)
5832 nil backward))
5833 (setq entered t)
5834 (setq current-group target-group
5835 target-group nil)))))))
5837 (defun gnus-summary-prev-group (&optional no-article)
5838 "Exit current newsgroup and then select previous unread newsgroup.
5839 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5840 (interactive "P")
5841 (gnus-summary-next-group no-article nil t))
5843 ;; Walking around summary lines.
5845 (defun gnus-summary-first-subject (&optional unread undownloaded)
5846 "Go to the first unread subject.
5847 If UNREAD is non-nil, go to the first unread article.
5848 Returns the article selected or nil if there are no unread articles."
5849 (interactive "P")
5850 (prog1
5851 (cond
5852 ;; Empty summary.
5853 ((null gnus-newsgroup-data)
5854 (gnus-message 3 "No articles in the group")
5855 nil)
5856 ;; Pick the first article.
5857 ((not unread)
5858 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5859 (gnus-data-number (car gnus-newsgroup-data)))
5860 ;; No unread articles.
5861 ((null gnus-newsgroup-unreads)
5862 (gnus-message 3 "No more unread articles")
5863 nil)
5864 ;; Find the first unread article.
5866 (let ((data gnus-newsgroup-data))
5867 (while (and data
5868 (and (not (and undownloaded
5869 (eq gnus-undownloaded-mark
5870 (gnus-data-mark (car data)))))
5871 (not (gnus-data-unread-p (car data)))))
5872 (setq data (cdr data)))
5873 (when data
5874 (goto-char (gnus-data-pos (car data)))
5875 (gnus-data-number (car data))))))
5876 (gnus-summary-position-point)))
5878 (defun gnus-summary-next-subject (n &optional unread dont-display)
5879 "Go to next N'th summary line.
5880 If N is negative, go to the previous N'th subject line.
5881 If UNREAD is non-nil, only unread articles are selected.
5882 The difference between N and the actual number of steps taken is
5883 returned."
5884 (interactive "p")
5885 (let ((backward (< n 0))
5886 (n (abs n)))
5887 (while (and (> n 0)
5888 (if backward
5889 (gnus-summary-find-prev unread)
5890 (gnus-summary-find-next unread)))
5891 (unless (zerop (setq n (1- n)))
5892 (gnus-summary-show-thread)))
5893 (when (/= 0 n)
5894 (gnus-message 7 "No more%s articles"
5895 (if unread " unread" "")))
5896 (unless dont-display
5897 (gnus-summary-recenter)
5898 (gnus-summary-position-point))
5901 (defun gnus-summary-next-unread-subject (n)
5902 "Go to next N'th unread summary line."
5903 (interactive "p")
5904 (gnus-summary-next-subject n t))
5906 (defun gnus-summary-prev-subject (n &optional unread)
5907 "Go to previous N'th summary line.
5908 If optional argument UNREAD is non-nil, only unread article is selected."
5909 (interactive "p")
5910 (gnus-summary-next-subject (- n) unread))
5912 (defun gnus-summary-prev-unread-subject (n)
5913 "Go to previous N'th unread summary line."
5914 (interactive "p")
5915 (gnus-summary-next-subject (- n) t))
5917 (defun gnus-summary-goto-subject (article &optional force silent)
5918 "Go the subject line of ARTICLE.
5919 If FORCE, also allow jumping to articles not currently shown."
5920 (interactive "nArticle number: ")
5921 (let ((b (point))
5922 (data (gnus-data-find article)))
5923 ;; We read in the article if we have to.
5924 (and (not data)
5925 force
5926 (gnus-summary-insert-subject
5927 article
5928 (if (or (numberp force) (vectorp force)) force)
5930 (setq data (gnus-data-find article)))
5931 (goto-char b)
5932 (if (not data)
5933 (progn
5934 (unless silent
5935 (gnus-message 3 "Can't find article %d" article))
5936 nil)
5937 (goto-char (gnus-data-pos data))
5938 (gnus-summary-position-point)
5939 article)))
5941 ;; Walking around summary lines with displaying articles.
5943 (defun gnus-summary-expand-window (&optional arg)
5944 "Make the summary buffer take up the entire Emacs frame.
5945 Given a prefix, will force an `article' buffer configuration."
5946 (interactive "P")
5947 (if arg
5948 (gnus-configure-windows 'article 'force)
5949 (gnus-configure-windows 'summary 'force)))
5951 (defun gnus-summary-display-article (article &optional all-header)
5952 "Display ARTICLE in article buffer."
5953 (when (gnus-buffer-live-p gnus-article-buffer)
5954 (with-current-buffer gnus-article-buffer
5955 (mm-enable-multibyte)))
5956 (gnus-set-global-variables)
5957 (if (null article)
5959 (prog1
5960 (if gnus-summary-display-article-function
5961 (funcall gnus-summary-display-article-function article all-header)
5962 (gnus-article-prepare article all-header))
5963 (gnus-run-hooks 'gnus-select-article-hook)
5964 (when (and gnus-current-article
5965 (not (zerop gnus-current-article)))
5966 (gnus-summary-goto-subject gnus-current-article))
5967 (gnus-summary-recenter)
5968 (when (and gnus-use-trees gnus-show-threads)
5969 (gnus-possibly-generate-tree article)
5970 (gnus-highlight-selected-tree article))
5971 ;; Successfully display article.
5972 (gnus-article-set-window-start
5973 (cdr (assq article gnus-newsgroup-bookmarks))))))
5975 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5976 "Select the current article.
5977 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5978 non-nil, the article will be re-fetched even if it already present in
5979 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5980 be displayed."
5981 ;; Make sure we are in the summary buffer to work around bbdb bug.
5982 (unless (eq major-mode 'gnus-summary-mode)
5983 (set-buffer gnus-summary-buffer))
5984 (let ((article (or article (gnus-summary-article-number)))
5985 (all-headers (not (not all-headers))) ;Must be t or nil.
5986 gnus-summary-display-article-function)
5987 (and (not pseudo)
5988 (gnus-summary-article-pseudo-p article)
5989 (error "This is a pseudo-article"))
5990 (save-excursion
5991 (set-buffer gnus-summary-buffer)
5992 (if (or (and gnus-single-article-buffer
5993 (or (null gnus-current-article)
5994 (null gnus-article-current)
5995 (null (get-buffer gnus-article-buffer))
5996 (not (eq article (cdr gnus-article-current)))
5997 (not (equal (car gnus-article-current)
5998 gnus-newsgroup-name))))
5999 (and (not gnus-single-article-buffer)
6000 (or (null gnus-current-article)
6001 (not (eq gnus-current-article article))))
6002 force)
6003 ;; The requested article is different from the current article.
6004 (progn
6005 (gnus-summary-display-article article all-headers)
6006 (when (gnus-buffer-live-p gnus-article-buffer)
6007 (with-current-buffer gnus-article-buffer
6008 (if (not gnus-article-decoded-p) ;; a local variable
6009 (mm-disable-multibyte))))
6010 (when (or all-headers gnus-show-all-headers)
6011 (gnus-article-show-all-headers))
6012 (gnus-article-set-window-start
6013 (cdr (assq article gnus-newsgroup-bookmarks)))
6014 article)
6015 (when (or all-headers gnus-show-all-headers)
6016 (gnus-article-show-all-headers))
6017 'old))))
6019 (defun gnus-summary-set-current-mark (&optional current-mark)
6020 "Obsolete function."
6021 nil)
6023 (defun gnus-summary-next-article (&optional unread subject backward push)
6024 "Select the next article.
6025 If UNREAD, only unread articles are selected.
6026 If SUBJECT, only articles with SUBJECT are selected.
6027 If BACKWARD, the previous article is selected instead of the next."
6028 (interactive "P")
6029 (cond
6030 ;; Is there such an article?
6031 ((and (gnus-summary-search-forward unread subject backward)
6032 (or (gnus-summary-display-article (gnus-summary-article-number))
6033 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6034 (gnus-summary-position-point))
6035 ;; If not, we try the first unread, if that is wanted.
6036 ((and subject
6037 gnus-auto-select-same
6038 (gnus-summary-first-unread-article))
6039 (gnus-summary-position-point)
6040 (gnus-message 6 "Wrapped"))
6041 ;; Try to get next/previous article not displayed in this group.
6042 ((and gnus-auto-extend-newsgroup
6043 (not unread) (not subject))
6044 (gnus-summary-goto-article
6045 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6046 nil (count-lines (point-min) (point))))
6047 ;; Go to next/previous group.
6049 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6050 (gnus-summary-jump-to-group gnus-newsgroup-name))
6051 (let ((cmd last-command-char)
6052 (point
6053 (save-excursion
6054 (set-buffer gnus-group-buffer)
6055 (point)))
6056 (group
6057 (if (eq gnus-keep-same-level 'best)
6058 (gnus-summary-best-group gnus-newsgroup-name)
6059 (gnus-summary-search-group backward gnus-keep-same-level))))
6060 ;; For some reason, the group window gets selected. We change
6061 ;; it back.
6062 (select-window (get-buffer-window (current-buffer)))
6063 ;; Select next unread newsgroup automagically.
6064 (cond
6065 ((or (not gnus-auto-select-next)
6066 (not cmd))
6067 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6068 ((or (eq gnus-auto-select-next 'quietly)
6069 (and (eq gnus-auto-select-next 'slightly-quietly)
6070 push)
6071 (and (eq gnus-auto-select-next 'almost-quietly)
6072 (gnus-summary-last-article-p)))
6073 ;; Select quietly.
6074 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6075 (gnus-summary-exit)
6076 (gnus-message 7 "No more%s articles (%s)..."
6077 (if unread " unread" "")
6078 (if group (concat "selecting " group)
6079 "exiting"))
6080 (gnus-summary-next-group nil group backward)))
6082 (when (gnus-key-press-event-p last-input-event)
6083 (gnus-summary-walk-group-buffer
6084 gnus-newsgroup-name cmd unread backward point))))))))
6086 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6087 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6088 (?\C-p (gnus-group-prev-unread-group 1))))
6089 (cursor-in-echo-area t)
6090 keve key group ended)
6091 (save-excursion
6092 (set-buffer gnus-group-buffer)
6093 (goto-char start)
6094 (setq group
6095 (if (eq gnus-keep-same-level 'best)
6096 (gnus-summary-best-group gnus-newsgroup-name)
6097 (gnus-summary-search-group backward gnus-keep-same-level))))
6098 (while (not ended)
6099 (gnus-message
6100 5 "No more%s articles%s" (if unread " unread" "")
6101 (if (and group
6102 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6103 (format " (Type %s for %s [%s])"
6104 (single-key-description cmd) group
6105 (car (gnus-gethash group gnus-newsrc-hashtb)))
6106 (format " (Type %s to exit %s)"
6107 (single-key-description cmd)
6108 gnus-newsgroup-name)))
6109 ;; Confirm auto selection.
6110 (setq key (car (setq keve (gnus-read-event-char))))
6111 (setq ended t)
6112 (cond
6113 ((assq key keystrokes)
6114 (let ((obuf (current-buffer)))
6115 (switch-to-buffer gnus-group-buffer)
6116 (when group
6117 (gnus-group-jump-to-group group))
6118 (eval (cadr (assq key keystrokes)))
6119 (setq group (gnus-group-group-name))
6120 (switch-to-buffer obuf))
6121 (setq ended nil))
6122 ((equal key cmd)
6123 (if (or (not group)
6124 (gnus-ephemeral-group-p gnus-newsgroup-name))
6125 (gnus-summary-exit)
6126 (gnus-summary-next-group nil group backward)))
6128 (push (cdr keve) unread-command-events))))))
6130 (defun gnus-summary-next-unread-article ()
6131 "Select unread article after current one."
6132 (interactive)
6133 (gnus-summary-next-article
6134 (or (not (eq gnus-summary-goto-unread 'never))
6135 (gnus-summary-last-article-p (gnus-summary-article-number)))
6136 (and gnus-auto-select-same
6137 (gnus-summary-article-subject))))
6139 (defun gnus-summary-prev-article (&optional unread subject)
6140 "Select the article after the current one.
6141 If UNREAD is non-nil, only unread articles are selected."
6142 (interactive "P")
6143 (gnus-summary-next-article unread subject t))
6145 (defun gnus-summary-prev-unread-article ()
6146 "Select unread article before current one."
6147 (interactive)
6148 (gnus-summary-prev-article
6149 (or (not (eq gnus-summary-goto-unread 'never))
6150 (gnus-summary-first-article-p (gnus-summary-article-number)))
6151 (and gnus-auto-select-same
6152 (gnus-summary-article-subject))))
6154 (defun gnus-summary-next-page (&optional lines circular)
6155 "Show next page of the selected article.
6156 If at the end of the current article, select the next article.
6157 LINES says how many lines should be scrolled up.
6159 If CIRCULAR is non-nil, go to the start of the article instead of
6160 selecting the next article when reaching the end of the current
6161 article."
6162 (interactive "P")
6163 (setq gnus-summary-buffer (current-buffer))
6164 (gnus-set-global-variables)
6165 (let ((article (gnus-summary-article-number))
6166 (article-window (get-buffer-window gnus-article-buffer t))
6167 endp)
6168 ;; If the buffer is empty, we have no article.
6169 (unless article
6170 (error "No article to select"))
6171 (gnus-configure-windows 'article)
6172 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6173 (if (and (eq gnus-summary-goto-unread 'never)
6174 (not (gnus-summary-last-article-p article)))
6175 (gnus-summary-next-article)
6176 (gnus-summary-next-unread-article))
6177 (if (or (null gnus-current-article)
6178 (null gnus-article-current)
6179 (/= article (cdr gnus-article-current))
6180 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6181 ;; Selected subject is different from current article's.
6182 (gnus-summary-display-article article)
6183 (when article-window
6184 (gnus-eval-in-buffer-window gnus-article-buffer
6185 (setq endp (gnus-article-next-page lines)))
6186 (when endp
6187 (cond (circular
6188 (gnus-summary-beginning-of-article))
6189 (lines
6190 (gnus-message 3 "End of message"))
6191 ((null lines)
6192 (if (and (eq gnus-summary-goto-unread 'never)
6193 (not (gnus-summary-last-article-p article)))
6194 (gnus-summary-next-article)
6195 (gnus-summary-next-unread-article))))))))
6196 (gnus-summary-recenter)
6197 (gnus-summary-position-point)))
6199 (defun gnus-summary-prev-page (&optional lines move)
6200 "Show previous page of selected article.
6201 Argument LINES specifies lines to be scrolled down.
6202 If MOVE, move to the previous unread article if point is at
6203 the beginning of the buffer."
6204 (interactive "P")
6205 (let ((article (gnus-summary-article-number))
6206 (article-window (get-buffer-window gnus-article-buffer t))
6207 endp)
6208 (gnus-configure-windows 'article)
6209 (if (or (null gnus-current-article)
6210 (null gnus-article-current)
6211 (/= article (cdr gnus-article-current))
6212 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6213 ;; Selected subject is different from current article's.
6214 (gnus-summary-display-article article)
6215 (gnus-summary-recenter)
6216 (when article-window
6217 (gnus-eval-in-buffer-window gnus-article-buffer
6218 (setq endp (gnus-article-prev-page lines)))
6219 (when (and move endp)
6220 (cond (lines
6221 (gnus-message 3 "Beginning of message"))
6222 ((null lines)
6223 (if (and (eq gnus-summary-goto-unread 'never)
6224 (not (gnus-summary-first-article-p article)))
6225 (gnus-summary-prev-article)
6226 (gnus-summary-prev-unread-article))))))))
6227 (gnus-summary-position-point))
6229 (defun gnus-summary-prev-page-or-article (&optional lines)
6230 "Show previous page of selected article.
6231 Argument LINES specifies lines to be scrolled down.
6232 If at the beginning of the article, go to the next article."
6233 (interactive "P")
6234 (gnus-summary-prev-page lines t))
6236 (defun gnus-summary-scroll-up (lines)
6237 "Scroll up (or down) one line current article.
6238 Argument LINES specifies lines to be scrolled up (or down if negative)."
6239 (interactive "p")
6240 (gnus-configure-windows 'article)
6241 (gnus-summary-show-thread)
6242 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6243 (gnus-eval-in-buffer-window gnus-article-buffer
6244 (cond ((> lines 0)
6245 (when (gnus-article-next-page lines)
6246 (gnus-message 3 "End of message")))
6247 ((< lines 0)
6248 (gnus-article-prev-page (- lines))))))
6249 (gnus-summary-recenter)
6250 (gnus-summary-position-point))
6252 (defun gnus-summary-scroll-down (lines)
6253 "Scroll down (or up) one line current article.
6254 Argument LINES specifies lines to be scrolled down (or up if negative)."
6255 (interactive "p")
6256 (gnus-summary-scroll-up (- lines)))
6258 (defun gnus-summary-next-same-subject ()
6259 "Select next article which has the same subject as current one."
6260 (interactive)
6261 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6263 (defun gnus-summary-prev-same-subject ()
6264 "Select previous article which has the same subject as current one."
6265 (interactive)
6266 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6268 (defun gnus-summary-next-unread-same-subject ()
6269 "Select next unread article which has the same subject as current one."
6270 (interactive)
6271 (gnus-summary-next-article t (gnus-summary-article-subject)))
6273 (defun gnus-summary-prev-unread-same-subject ()
6274 "Select previous unread article which has the same subject as current one."
6275 (interactive)
6276 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6278 (defun gnus-summary-first-unread-article ()
6279 "Select the first unread article.
6280 Return nil if there are no unread articles."
6281 (interactive)
6282 (prog1
6283 (when (gnus-summary-first-subject t)
6284 (gnus-summary-show-thread)
6285 (gnus-summary-first-subject t)
6286 (gnus-summary-display-article (gnus-summary-article-number)))
6287 (gnus-summary-position-point)))
6289 (defun gnus-summary-first-unread-subject ()
6290 "Place the point on the subject line of the first unread article.
6291 Return nil if there are no unread articles."
6292 (interactive)
6293 (prog1
6294 (when (gnus-summary-first-subject t)
6295 (gnus-summary-show-thread)
6296 (gnus-summary-first-subject t))
6297 (gnus-summary-position-point)))
6299 (defun gnus-summary-first-article ()
6300 "Select the first article.
6301 Return nil if there are no articles."
6302 (interactive)
6303 (prog1
6304 (when (gnus-summary-first-subject)
6305 (gnus-summary-show-thread)
6306 (gnus-summary-first-subject)
6307 (gnus-summary-display-article (gnus-summary-article-number)))
6308 (gnus-summary-position-point)))
6310 (defun gnus-summary-best-unread-article ()
6311 "Select the unread article with the highest score."
6312 (interactive)
6313 (let ((best -1000000)
6314 (data gnus-newsgroup-data)
6315 article score)
6316 (while data
6317 (and (gnus-data-unread-p (car data))
6318 (> (setq score
6319 (gnus-summary-article-score (gnus-data-number (car data))))
6320 best)
6321 (setq best score
6322 article (gnus-data-number (car data))))
6323 (setq data (cdr data)))
6324 (prog1
6325 (if article
6326 (gnus-summary-goto-article article)
6327 (error "No unread articles"))
6328 (gnus-summary-position-point))))
6330 (defun gnus-summary-last-subject ()
6331 "Go to the last displayed subject line in the group."
6332 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6333 (when article
6334 (gnus-summary-goto-subject article))))
6336 (defun gnus-summary-goto-article (article &optional all-headers force)
6337 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6338 If ALL-HEADERS is non-nil, no header lines are hidden.
6339 If FORCE, go to the article even if it isn't displayed. If FORCE
6340 is a number, it is the line the article is to be displayed on."
6341 (interactive
6342 (list
6343 (completing-read
6344 "Article number or Message-ID: "
6345 (mapcar (lambda (number) (list (int-to-string number)))
6346 gnus-newsgroup-limit))
6347 current-prefix-arg
6349 (prog1
6350 (if (and (stringp article)
6351 (string-match "@" article))
6352 (gnus-summary-refer-article article)
6353 (when (stringp article)
6354 (setq article (string-to-number article)))
6355 (if (gnus-summary-goto-subject article force)
6356 (gnus-summary-display-article article all-headers)
6357 (gnus-message 4 "Couldn't go to article %s" article) nil))
6358 (gnus-summary-position-point)))
6360 (defun gnus-summary-goto-last-article ()
6361 "Go to the previously read article."
6362 (interactive)
6363 (prog1
6364 (when gnus-last-article
6365 (gnus-summary-goto-article gnus-last-article nil t))
6366 (gnus-summary-position-point)))
6368 (defun gnus-summary-pop-article (number)
6369 "Pop one article off the history and go to the previous.
6370 NUMBER articles will be popped off."
6371 (interactive "p")
6372 (let (to)
6373 (setq gnus-newsgroup-history
6374 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6375 (if to
6376 (gnus-summary-goto-article (car to) nil t)
6377 (error "Article history empty")))
6378 (gnus-summary-position-point))
6380 ;; Summary commands and functions for limiting the summary buffer.
6382 (defun gnus-summary-limit-to-articles (n)
6383 "Limit the summary buffer to the next N articles.
6384 If not given a prefix, use the process marked articles instead."
6385 (interactive "P")
6386 (prog1
6387 (let ((articles (gnus-summary-work-articles n)))
6388 (setq gnus-newsgroup-processable nil)
6389 (gnus-summary-limit articles))
6390 (gnus-summary-position-point)))
6392 (defun gnus-summary-pop-limit (&optional total)
6393 "Restore the previous limit.
6394 If given a prefix, remove all limits."
6395 (interactive "P")
6396 (when total
6397 (setq gnus-newsgroup-limits
6398 (list (mapcar (lambda (h) (mail-header-number h))
6399 gnus-newsgroup-headers))))
6400 (unless gnus-newsgroup-limits
6401 (error "No limit to pop"))
6402 (prog1
6403 (gnus-summary-limit nil 'pop)
6404 (gnus-summary-position-point)))
6406 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6407 "Limit the summary buffer to articles that have subjects that match a regexp.
6408 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6409 (interactive
6410 (list (read-string (if current-prefix-arg
6411 "Exclude subject (regexp): "
6412 "Limit to subject (regexp): "))
6413 nil current-prefix-arg))
6414 (unless header
6415 (setq header "subject"))
6416 (when (not (equal "" subject))
6417 (prog1
6418 (let ((articles (gnus-summary-find-matching
6419 (or header "subject") subject 'all nil nil
6420 not-matching)))
6421 (unless articles
6422 (error "Found no matches for \"%s\"" subject))
6423 (gnus-summary-limit articles))
6424 (gnus-summary-position-point))))
6426 (defun gnus-summary-limit-to-author (from &optional not-matching)
6427 "Limit the summary buffer to articles that have authors that match a regexp.
6428 If NOT-MATCHING, excluding articles that have authors that match a regexp."
6429 (interactive
6430 (list (read-string (if current-prefix-arg
6431 "Exclude author (regexp): "
6432 "Limit to author (regexp): "))
6433 current-prefix-arg))
6434 (gnus-summary-limit-to-subject from "from" not-matching))
6436 (defun gnus-summary-limit-to-age (age &optional younger-p)
6437 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6438 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6439 articles that are younger than AGE days."
6440 (interactive
6441 (let ((younger current-prefix-arg)
6442 (days-got nil)
6443 days)
6444 (while (not days-got)
6445 (setq days (if younger
6446 (read-string "Limit to articles within (in days): ")
6447 (read-string "Limit to articles old than (in days): ")))
6448 (when (> (length days) 0)
6449 (setq days (read days)))
6450 (if (numberp days)
6451 (setq days-got t)
6452 (message "Please enter a number.")
6453 (sleep-for 1)))
6454 (list days younger)))
6455 (prog1
6456 (let ((data gnus-newsgroup-data)
6457 (cutoff (days-to-time age))
6458 articles d date is-younger)
6459 (while (setq d (pop data))
6460 (when (and (vectorp (gnus-data-header d))
6461 (setq date (mail-header-date (gnus-data-header d))))
6462 (setq is-younger (time-less-p
6463 (time-since (condition-case ()
6464 (date-to-time date)
6465 (error '(0 0))))
6466 cutoff))
6467 (when (if younger-p
6468 is-younger
6469 (not is-younger))
6470 (push (gnus-data-number d) articles))))
6471 (gnus-summary-limit (nreverse articles)))
6472 (gnus-summary-position-point)))
6474 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
6475 "Limit the summary buffer to articles that match an 'extra' header."
6476 (interactive
6477 (let ((header
6478 (intern
6479 (gnus-completing-read
6480 (symbol-name (car gnus-extra-headers))
6481 (if current-prefix-arg
6482 "Exclude extra header:"
6483 "Limit extra header:")
6484 (mapcar (lambda (x)
6485 (cons (symbol-name x) x))
6486 gnus-extra-headers)
6488 t))))
6489 (list header
6490 (read-string (format "%s header %s (regexp): "
6491 (if current-prefix-arg "Exclude" "Limit to")
6492 header))
6493 current-prefix-arg)))
6494 (when (not (equal "" regexp))
6495 (prog1
6496 (let ((articles (gnus-summary-find-matching
6497 (cons 'extra header) regexp 'all nil nil
6498 not-matching)))
6499 (unless articles
6500 (error "Found no matches for \"%s\"" regexp))
6501 (gnus-summary-limit articles))
6502 (gnus-summary-position-point))))
6504 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6505 (make-obsolete
6506 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6508 (defun gnus-summary-limit-to-unread (&optional all)
6509 "Limit the summary buffer to articles that are not marked as read.
6510 If ALL is non-nil, limit strictly to unread articles."
6511 (interactive "P")
6512 (if all
6513 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6514 (gnus-summary-limit-to-marks
6515 ;; Concat all the marks that say that an article is read and have
6516 ;; those removed.
6517 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6518 gnus-killed-mark gnus-kill-file-mark
6519 gnus-low-score-mark gnus-expirable-mark
6520 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6521 gnus-duplicate-mark gnus-souped-mark)
6522 'reverse)))
6524 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6525 (make-obsolete 'gnus-summary-delete-marked-with
6526 'gnus-summary-limit-exclude-marks)
6528 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6529 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6530 If REVERSE, limit the summary buffer to articles that are marked
6531 with MARKS. MARKS can either be a string of marks or a list of marks.
6532 Returns how many articles were removed."
6533 (interactive "sMarks: ")
6534 (gnus-summary-limit-to-marks marks t))
6536 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6537 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6538 If REVERSE (the prefix), limit the summary buffer to articles that are
6539 not marked with MARKS. MARKS can either be a string of marks or a
6540 list of marks.
6541 Returns how many articles were removed."
6542 (interactive "sMarks: \nP")
6543 (prog1
6544 (let ((data gnus-newsgroup-data)
6545 (marks (if (listp marks) marks
6546 (append marks nil))) ; Transform to list.
6547 articles)
6548 (while data
6549 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6550 (memq (gnus-data-mark (car data)) marks))
6551 (push (gnus-data-number (car data)) articles))
6552 (setq data (cdr data)))
6553 (gnus-summary-limit articles))
6554 (gnus-summary-position-point)))
6556 (defun gnus-summary-limit-to-score (&optional score)
6557 "Limit to articles with score at or above SCORE."
6558 (interactive "P")
6559 (setq score (if score
6560 (prefix-numeric-value score)
6561 (or gnus-summary-default-score 0)))
6562 (let ((data gnus-newsgroup-data)
6563 articles)
6564 (while data
6565 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6566 score)
6567 (push (gnus-data-number (car data)) articles))
6568 (setq data (cdr data)))
6569 (prog1
6570 (gnus-summary-limit articles)
6571 (gnus-summary-position-point))))
6573 (defun gnus-summary-limit-include-thread (id)
6574 "Display all the hidden articles that in the current thread."
6575 (interactive (list (mail-header-id (gnus-summary-article-header))))
6576 (let ((articles (gnus-articles-in-thread
6577 (gnus-id-to-thread (gnus-root-id id)))))
6578 (prog1
6579 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6580 (gnus-summary-position-point))))
6582 (defun gnus-summary-limit-include-dormant ()
6583 "Display all the hidden articles that are marked as dormant.
6584 Note that this command only works on a subset of the articles currently
6585 fetched for this group."
6586 (interactive)
6587 (unless gnus-newsgroup-dormant
6588 (error "There are no dormant articles in this group"))
6589 (prog1
6590 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6591 (gnus-summary-position-point)))
6593 (defun gnus-summary-limit-exclude-dormant ()
6594 "Hide all dormant articles."
6595 (interactive)
6596 (prog1
6597 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6598 (gnus-summary-position-point)))
6600 (defun gnus-summary-limit-exclude-childless-dormant ()
6601 "Hide all dormant articles that have no children."
6602 (interactive)
6603 (let ((data (gnus-data-list t))
6604 articles d children)
6605 ;; Find all articles that are either not dormant or have
6606 ;; children.
6607 (while (setq d (pop data))
6608 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6609 (and (setq children
6610 (gnus-article-children (gnus-data-number d)))
6611 (let (found)
6612 (while children
6613 (when (memq (car children) articles)
6614 (setq children nil
6615 found t))
6616 (pop children))
6617 found)))
6618 (push (gnus-data-number d) articles)))
6619 ;; Do the limiting.
6620 (prog1
6621 (gnus-summary-limit articles)
6622 (gnus-summary-position-point))))
6624 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6625 "Mark all unread excluded articles as read.
6626 If ALL, mark even excluded ticked and dormants as read."
6627 (interactive "P")
6628 (let ((articles (gnus-sorted-complement
6629 (sort
6630 (mapcar (lambda (h) (mail-header-number h))
6631 gnus-newsgroup-headers)
6633 (sort gnus-newsgroup-limit '<)))
6634 article)
6635 (setq gnus-newsgroup-unreads
6636 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6637 (if all
6638 (setq gnus-newsgroup-dormant nil
6639 gnus-newsgroup-marked nil
6640 gnus-newsgroup-reads
6641 (nconc
6642 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6643 gnus-newsgroup-reads))
6644 (while (setq article (pop articles))
6645 (unless (or (memq article gnus-newsgroup-dormant)
6646 (memq article gnus-newsgroup-marked))
6647 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6649 (defun gnus-summary-limit (articles &optional pop)
6650 (if pop
6651 ;; We pop the previous limit off the stack and use that.
6652 (setq articles (car gnus-newsgroup-limits)
6653 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6654 ;; We use the new limit, so we push the old limit on the stack.
6655 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6656 ;; Set the limit.
6657 (setq gnus-newsgroup-limit articles)
6658 (let ((total (length gnus-newsgroup-data))
6659 (data (gnus-data-find-list (gnus-summary-article-number)))
6660 (gnus-summary-mark-below nil) ; Inhibit this.
6661 found)
6662 ;; This will do all the work of generating the new summary buffer
6663 ;; according to the new limit.
6664 (gnus-summary-prepare)
6665 ;; Hide any threads, possibly.
6666 (and gnus-show-threads
6667 gnus-thread-hide-subtree
6668 (gnus-summary-hide-all-threads))
6669 ;; Try to return to the article you were at, or one in the
6670 ;; neighborhood.
6671 (when data
6672 ;; We try to find some article after the current one.
6673 (while data
6674 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6675 (setq data nil
6676 found t))
6677 (setq data (cdr data))))
6678 (unless found
6679 ;; If there is no data, that means that we were after the last
6680 ;; article. The same goes when we can't find any articles
6681 ;; after the current one.
6682 (goto-char (point-max))
6683 (gnus-summary-find-prev))
6684 (gnus-set-mode-line 'summary)
6685 ;; We return how many articles were removed from the summary
6686 ;; buffer as a result of the new limit.
6687 (- total (length gnus-newsgroup-data))))
6689 (defsubst gnus-invisible-cut-children (threads)
6690 (let ((num 0))
6691 (while threads
6692 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6693 (incf num))
6694 (pop threads))
6695 (< num 2)))
6697 (defsubst gnus-cut-thread (thread)
6698 "Go forwards in the thread until we find an article that we want to display."
6699 (when (or (eq gnus-fetch-old-headers 'some)
6700 (eq gnus-fetch-old-headers 'invisible)
6701 (numberp gnus-fetch-old-headers)
6702 (eq gnus-build-sparse-threads 'some)
6703 (eq gnus-build-sparse-threads 'more))
6704 ;; Deal with old-fetched headers and sparse threads.
6705 (while (and
6706 thread
6708 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6709 (gnus-summary-article-ancient-p
6710 (mail-header-number (car thread))))
6711 (if (or (<= (length (cdr thread)) 1)
6712 (eq gnus-fetch-old-headers 'invisible))
6713 (setq gnus-newsgroup-limit
6714 (delq (mail-header-number (car thread))
6715 gnus-newsgroup-limit)
6716 thread (cadr thread))
6717 (when (gnus-invisible-cut-children (cdr thread))
6718 (let ((th (cdr thread)))
6719 (while th
6720 (if (memq (mail-header-number (caar th))
6721 gnus-newsgroup-limit)
6722 (setq thread (car th)
6723 th nil)
6724 (setq th (cdr th))))))))))
6725 thread)
6727 (defun gnus-cut-threads (threads)
6728 "Cut off all uninteresting articles from the beginning of threads."
6729 (when (or (eq gnus-fetch-old-headers 'some)
6730 (eq gnus-fetch-old-headers 'invisible)
6731 (numberp gnus-fetch-old-headers)
6732 (eq gnus-build-sparse-threads 'some)
6733 (eq gnus-build-sparse-threads 'more))
6734 (let ((th threads))
6735 (while th
6736 (setcar th (gnus-cut-thread (car th)))
6737 (setq th (cdr th)))))
6738 ;; Remove nixed out threads.
6739 (delq nil threads))
6741 (defun gnus-summary-initial-limit (&optional show-if-empty)
6742 "Figure out what the initial limit is supposed to be on group entry.
6743 This entails weeding out unwanted dormants, low-scored articles,
6744 fetch-old-headers verbiage, and so on."
6745 ;; Most groups have nothing to remove.
6746 (if (or gnus-inhibit-limiting
6747 (and (null gnus-newsgroup-dormant)
6748 (not (eq gnus-fetch-old-headers 'some))
6749 (not (numberp gnus-fetch-old-headers))
6750 (not (eq gnus-fetch-old-headers 'invisible))
6751 (null gnus-summary-expunge-below)
6752 (not (eq gnus-build-sparse-threads 'some))
6753 (not (eq gnus-build-sparse-threads 'more))
6754 (null gnus-thread-expunge-below)
6755 (not gnus-use-nocem)))
6756 () ; Do nothing.
6757 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6758 (setq gnus-newsgroup-limit nil)
6759 (mapatoms
6760 (lambda (node)
6761 (unless (car (symbol-value node))
6762 ;; These threads have no parents -- they are roots.
6763 (let ((nodes (cdr (symbol-value node)))
6764 thread)
6765 (while nodes
6766 (if (and gnus-thread-expunge-below
6767 (< (gnus-thread-total-score (car nodes))
6768 gnus-thread-expunge-below))
6769 (gnus-expunge-thread (pop nodes))
6770 (setq thread (pop nodes))
6771 (gnus-summary-limit-children thread))))))
6772 gnus-newsgroup-dependencies)
6773 ;; If this limitation resulted in an empty group, we might
6774 ;; pop the previous limit and use it instead.
6775 (when (and (not gnus-newsgroup-limit)
6776 show-if-empty)
6777 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6778 gnus-newsgroup-limit))
6780 (defun gnus-summary-limit-children (thread)
6781 "Return 1 if this subthread is visible and 0 if it is not."
6782 ;; First we get the number of visible children to this thread. This
6783 ;; is done by recursing down the thread using this function, so this
6784 ;; will really go down to a leaf article first, before slowly
6785 ;; working its way up towards the root.
6786 (when thread
6787 (let ((children
6788 (if (cdr thread)
6789 (apply '+ (mapcar 'gnus-summary-limit-children
6790 (cdr thread)))
6792 (number (mail-header-number (car thread)))
6793 score)
6794 (if (and
6795 (not (memq number gnus-newsgroup-marked))
6797 ;; If this article is dormant and has absolutely no visible
6798 ;; children, then this article isn't visible.
6799 (and (memq number gnus-newsgroup-dormant)
6800 (zerop children))
6801 ;; If this is "fetch-old-headered" and there is no
6802 ;; visible children, then we don't want this article.
6803 (and (or (eq gnus-fetch-old-headers 'some)
6804 (numberp gnus-fetch-old-headers))
6805 (gnus-summary-article-ancient-p number)
6806 (zerop children))
6807 ;; If this is "fetch-old-headered" and `invisible', then
6808 ;; we don't want this article.
6809 (and (eq gnus-fetch-old-headers 'invisible)
6810 (gnus-summary-article-ancient-p number))
6811 ;; If this is a sparsely inserted article with no children,
6812 ;; we don't want it.
6813 (and (eq gnus-build-sparse-threads 'some)
6814 (gnus-summary-article-sparse-p number)
6815 (zerop children))
6816 ;; If we use expunging, and this article is really
6817 ;; low-scored, then we don't want this article.
6818 (when (and gnus-summary-expunge-below
6819 (< (setq score
6820 (or (cdr (assq number gnus-newsgroup-scored))
6821 gnus-summary-default-score))
6822 gnus-summary-expunge-below))
6823 ;; We increase the expunge-tally here, but that has
6824 ;; nothing to do with the limits, really.
6825 (incf gnus-newsgroup-expunged-tally)
6826 ;; We also mark as read here, if that's wanted.
6827 (when (and gnus-summary-mark-below
6828 (< score gnus-summary-mark-below))
6829 (setq gnus-newsgroup-unreads
6830 (delq number gnus-newsgroup-unreads))
6831 (if gnus-newsgroup-auto-expire
6832 (push number gnus-newsgroup-expirable)
6833 (push (cons number gnus-low-score-mark)
6834 gnus-newsgroup-reads)))
6836 ;; Check NoCeM things.
6837 (if (and gnus-use-nocem
6838 (gnus-nocem-unwanted-article-p
6839 (mail-header-id (car thread))))
6840 (progn
6841 (setq gnus-newsgroup-unreads
6842 (delq number gnus-newsgroup-unreads))
6843 t))))
6844 ;; Nope, invisible article.
6846 ;; Ok, this article is to be visible, so we add it to the limit
6847 ;; and return 1.
6848 (push number gnus-newsgroup-limit)
6849 1))))
6851 (defun gnus-expunge-thread (thread)
6852 "Mark all articles in THREAD as read."
6853 (let* ((number (mail-header-number (car thread))))
6854 (incf gnus-newsgroup-expunged-tally)
6855 ;; We also mark as read here, if that's wanted.
6856 (setq gnus-newsgroup-unreads
6857 (delq number gnus-newsgroup-unreads))
6858 (if gnus-newsgroup-auto-expire
6859 (push number gnus-newsgroup-expirable)
6860 (push (cons number gnus-low-score-mark)
6861 gnus-newsgroup-reads)))
6862 ;; Go recursively through all subthreads.
6863 (mapcar 'gnus-expunge-thread (cdr thread)))
6865 ;; Summary article oriented commands
6867 (defun gnus-summary-refer-parent-article (n)
6868 "Refer parent article N times.
6869 If N is negative, go to ancestor -N instead.
6870 The difference between N and the number of articles fetched is returned."
6871 (interactive "p")
6872 (let ((skip 1)
6873 error header ref)
6874 (when (not (natnump n))
6875 (setq skip (abs n)
6876 n 1))
6877 (while (and (> n 0)
6878 (not error))
6879 (setq header (gnus-summary-article-header))
6880 (if (and (eq (mail-header-number header)
6881 (cdr gnus-article-current))
6882 (equal gnus-newsgroup-name
6883 (car gnus-article-current)))
6884 ;; If we try to find the parent of the currently
6885 ;; displayed article, then we take a look at the actual
6886 ;; References header, since this is slightly more
6887 ;; reliable than the References field we got from the
6888 ;; server.
6889 (save-excursion
6890 (set-buffer gnus-original-article-buffer)
6891 (nnheader-narrow-to-headers)
6892 (unless (setq ref (message-fetch-field "references"))
6893 (setq ref (message-fetch-field "in-reply-to")))
6894 (widen))
6895 (setq ref
6896 ;; It's not the current article, so we take a bet on
6897 ;; the value we got from the server.
6898 (mail-header-references header)))
6899 (if (and ref
6900 (not (equal ref "")))
6901 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6902 (gnus-message 1 "Couldn't find parent"))
6903 (gnus-message 1 "No references in article %d"
6904 (gnus-summary-article-number))
6905 (setq error t))
6906 (decf n))
6907 (gnus-summary-position-point)
6910 (defun gnus-summary-refer-references ()
6911 "Fetch all articles mentioned in the References header.
6912 Return the number of articles fetched."
6913 (interactive)
6914 (let ((ref (mail-header-references (gnus-summary-article-header)))
6915 (current (gnus-summary-article-number))
6916 (n 0))
6917 (if (or (not ref)
6918 (equal ref ""))
6919 (error "No References in the current article")
6920 ;; For each Message-ID in the References header...
6921 (while (string-match "<[^>]*>" ref)
6922 (incf n)
6923 ;; ... fetch that article.
6924 (gnus-summary-refer-article
6925 (prog1 (match-string 0 ref)
6926 (setq ref (substring ref (match-end 0))))))
6927 (gnus-summary-goto-subject current)
6928 (gnus-summary-position-point)
6929 n)))
6931 (defun gnus-summary-refer-thread (&optional limit)
6932 "Fetch all articles in the current thread.
6933 If LIMIT (the numerical prefix), fetch that many old headers instead
6934 of what's specified by the `gnus-refer-thread-limit' variable."
6935 (interactive "P")
6936 (let ((id (mail-header-id (gnus-summary-article-header)))
6937 (limit (if limit (prefix-numeric-value limit)
6938 gnus-refer-thread-limit)))
6939 ;; We want to fetch LIMIT *old* headers, but we also have to
6940 ;; re-fetch all the headers in the current buffer, because many of
6941 ;; them may be undisplayed. So we adjust LIMIT.
6942 (when (numberp limit)
6943 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6944 (unless (eq gnus-fetch-old-headers 'invisible)
6945 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6946 ;; Retrieve the headers and read them in.
6947 (if (eq (gnus-retrieve-headers
6948 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6949 'nov)
6950 (gnus-build-all-threads)
6951 (error "Can't fetch thread from backends that don't support NOV"))
6952 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6953 (gnus-summary-limit-include-thread id)))
6955 (defun gnus-summary-refer-article (message-id)
6956 "Fetch an article specified by MESSAGE-ID."
6957 (interactive "sMessage-ID: ")
6958 (when (and (stringp message-id)
6959 (not (zerop (length message-id))))
6960 ;; Construct the correct Message-ID if necessary.
6961 ;; Suggested by tale@pawl.rpi.edu.
6962 (unless (string-match "^<" message-id)
6963 (setq message-id (concat "<" message-id)))
6964 (unless (string-match ">$" message-id)
6965 (setq message-id (concat message-id ">")))
6966 (let* ((header (gnus-id-to-header message-id))
6967 (sparse (and header
6968 (gnus-summary-article-sparse-p
6969 (mail-header-number header))
6970 (memq (mail-header-number header)
6971 gnus-newsgroup-limit)))
6972 number)
6973 (cond
6974 ;; If the article is present in the buffer we just go to it.
6975 ((and header
6976 (or (not (gnus-summary-article-sparse-p
6977 (mail-header-number header)))
6978 sparse))
6979 (prog1
6980 (gnus-summary-goto-article
6981 (mail-header-number header) nil t)
6982 (when sparse
6983 (gnus-summary-update-article (mail-header-number header)))))
6985 ;; We fetch the article.
6986 (catch 'found
6987 (dolist (gnus-override-method (gnus-refer-article-methods))
6988 (gnus-check-server gnus-override-method)
6989 ;; Fetch the header, and display the article.
6990 (when (setq number (gnus-summary-insert-subject message-id))
6991 (gnus-summary-select-article nil nil nil number)
6992 (throw 'found t)))
6993 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6995 (defun gnus-refer-article-methods ()
6996 "Return a list of referable methods."
6997 (cond
6998 ;; No method, so we default to current and native.
6999 ((null gnus-refer-article-method)
7000 (list gnus-current-select-method gnus-select-method))
7001 ;; Current.
7002 ((eq 'current gnus-refer-article-method)
7003 (list gnus-current-select-method))
7004 ;; List of select methods.
7005 ((not (and (symbolp (car gnus-refer-article-method))
7006 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7007 (let (out)
7008 (dolist (method gnus-refer-article-method)
7009 (push (if (eq 'current method)
7010 gnus-current-select-method
7011 method)
7012 out))
7013 (nreverse out)))
7014 ;; One single select method.
7016 (list gnus-refer-article-method))))
7018 (defun gnus-summary-edit-parameters ()
7019 "Edit the group parameters of the current group."
7020 (interactive)
7021 (gnus-group-edit-group gnus-newsgroup-name 'params))
7023 (defun gnus-summary-customize-parameters ()
7024 "Customize the group parameters of the current group."
7025 (interactive)
7026 (gnus-group-customize gnus-newsgroup-name))
7028 (defun gnus-summary-enter-digest-group (&optional force)
7029 "Enter an nndoc group based on the current article.
7030 If FORCE, force a digest interpretation. If not, try
7031 to guess what the document format is."
7032 (interactive "P")
7033 (let ((conf gnus-current-window-configuration))
7034 (save-excursion
7035 (gnus-summary-select-article))
7036 (setq gnus-current-window-configuration conf)
7037 (let* ((name (format "%s-%d"
7038 (gnus-group-prefixed-name
7039 gnus-newsgroup-name (list 'nndoc ""))
7040 (save-excursion
7041 (set-buffer gnus-summary-buffer)
7042 gnus-current-article)))
7043 (ogroup gnus-newsgroup-name)
7044 (params (append (gnus-info-params (gnus-get-info ogroup))
7045 (list (cons 'to-group ogroup))
7046 (list (cons 'save-article-group ogroup))))
7047 (case-fold-search t)
7048 (buf (current-buffer))
7049 dig to-address)
7050 (save-excursion
7051 (set-buffer gnus-original-article-buffer)
7052 ;; Have the digest group inherit the main mail address of
7053 ;; the parent article.
7054 (when (setq to-address (or (message-fetch-field "reply-to")
7055 (message-fetch-field "from")))
7056 (setq params (append
7057 (list (cons 'to-address
7058 (funcall gnus-decode-encoded-word-function
7059 to-address))))))
7060 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7061 (insert-buffer-substring gnus-original-article-buffer)
7062 ;; Remove lines that may lead nndoc to misinterpret the
7063 ;; document type.
7064 (narrow-to-region
7065 (goto-char (point-min))
7066 (or (search-forward "\n\n" nil t) (point)))
7067 (goto-char (point-min))
7068 (delete-matching-lines "^Path:\\|^From ")
7069 (widen))
7070 (unwind-protect
7071 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7072 (gnus-newsgroup-ephemeral-ignored-charsets
7073 gnus-newsgroup-ignored-charsets))
7074 (gnus-group-read-ephemeral-group
7075 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7076 (nndoc-article-type
7077 ,(if force 'mbox 'guess))) t))
7078 ;; Make all postings to this group go to the parent group.
7079 (nconc (gnus-info-params (gnus-get-info name))
7080 params)
7081 ;; Couldn't select this doc group.
7082 (switch-to-buffer buf)
7083 (gnus-set-global-variables)
7084 (gnus-configure-windows 'summary)
7085 (gnus-message 3 "Article couldn't be entered?"))
7086 (kill-buffer dig)))))
7088 (defun gnus-summary-read-document (n)
7089 "Open a new group based on the current article(s).
7090 This will allow you to read digests and other similar
7091 documents as newsgroups.
7092 Obeys the standard process/prefix convention."
7093 (interactive "P")
7094 (let* ((articles (gnus-summary-work-articles n))
7095 (ogroup gnus-newsgroup-name)
7096 (params (append (gnus-info-params (gnus-get-info ogroup))
7097 (list (cons 'to-group ogroup))))
7098 article group egroup groups vgroup)
7099 (while (setq article (pop articles))
7100 (setq group (format "%s-%d" gnus-newsgroup-name article))
7101 (gnus-summary-remove-process-mark article)
7102 (when (gnus-summary-display-article article)
7103 (save-excursion
7104 (with-temp-buffer
7105 (insert-buffer-substring gnus-original-article-buffer)
7106 ;; Remove some headers that may lead nndoc to make
7107 ;; the wrong guess.
7108 (message-narrow-to-head)
7109 (goto-char (point-min))
7110 (delete-matching-lines "^\\(Path\\):\\|^From ")
7111 (widen)
7112 (if (setq egroup
7113 (gnus-group-read-ephemeral-group
7114 group `(nndoc ,group (nndoc-address ,(current-buffer))
7115 (nndoc-article-type guess))
7116 t nil t))
7117 (progn
7118 ;; Make all postings to this group go to the parent group.
7119 (nconc (gnus-info-params (gnus-get-info egroup))
7120 params)
7121 (push egroup groups))
7122 ;; Couldn't select this doc group.
7123 (gnus-error 3 "Article couldn't be entered"))))))
7124 ;; Now we have selected all the documents.
7125 (cond
7126 ((not groups)
7127 (error "None of the articles could be interpreted as documents"))
7128 ((gnus-group-read-ephemeral-group
7129 (setq vgroup (format
7130 "nnvirtual:%s-%s" gnus-newsgroup-name
7131 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7132 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7134 (cons (current-buffer) 'summary)))
7136 (error "Couldn't select virtual nndoc group")))))
7138 (defun gnus-summary-isearch-article (&optional regexp-p)
7139 "Do incremental search forward on the current article.
7140 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7141 (interactive "P")
7142 (gnus-summary-select-article)
7143 (gnus-configure-windows 'article)
7144 (gnus-eval-in-buffer-window gnus-article-buffer
7145 (save-restriction
7146 (widen)
7147 (isearch-forward regexp-p))))
7149 (defun gnus-summary-search-article-forward (regexp &optional backward)
7150 "Search for an article containing REGEXP forward.
7151 If BACKWARD, search backward instead."
7152 (interactive
7153 (list (read-string
7154 (format "Search article %s (regexp%s): "
7155 (if current-prefix-arg "backward" "forward")
7156 (if gnus-last-search-regexp
7157 (concat ", default " gnus-last-search-regexp)
7158 "")))
7159 current-prefix-arg))
7160 (if (string-equal regexp "")
7161 (setq regexp (or gnus-last-search-regexp ""))
7162 (setq gnus-last-search-regexp regexp))
7163 (if (gnus-summary-search-article regexp backward)
7164 (gnus-summary-show-thread)
7165 (error "Search failed: \"%s\"" regexp)))
7167 (defun gnus-summary-search-article-backward (regexp)
7168 "Search for an article containing REGEXP backward."
7169 (interactive
7170 (list (read-string
7171 (format "Search article backward (regexp%s): "
7172 (if gnus-last-search-regexp
7173 (concat ", default " gnus-last-search-regexp)
7174 "")))))
7175 (gnus-summary-search-article-forward regexp 'backward))
7177 (defun gnus-summary-search-article (regexp &optional backward)
7178 "Search for an article containing REGEXP.
7179 Optional argument BACKWARD means do search for backward.
7180 `gnus-select-article-hook' is not called during the search."
7181 ;; We have to require this here to make sure that the following
7182 ;; dynamic binding isn't shadowed by autoloading.
7183 (require 'gnus-async)
7184 (require 'gnus-art)
7185 (let ((gnus-select-article-hook nil) ;Disable hook.
7186 (gnus-article-prepare-hook nil)
7187 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7188 (gnus-use-article-prefetch nil)
7189 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7190 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7191 (sum (current-buffer))
7192 (gnus-display-mime-function nil)
7193 (found nil)
7194 point)
7195 (gnus-save-hidden-threads
7196 (gnus-summary-select-article)
7197 (set-buffer gnus-article-buffer)
7198 (goto-char (window-point (get-buffer-window (current-buffer))))
7199 (when backward
7200 (forward-line -1))
7201 (while (not found)
7202 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7203 (if (if backward
7204 (re-search-backward regexp nil t)
7205 (re-search-forward regexp nil t))
7206 ;; We found the regexp.
7207 (progn
7208 (setq found 'found)
7209 (beginning-of-line)
7210 (set-window-start
7211 (get-buffer-window (current-buffer))
7212 (point))
7213 (forward-line 1)
7214 (set-window-point
7215 (get-buffer-window (current-buffer))
7216 (point))
7217 (set-buffer sum)
7218 (setq point (point)))
7219 ;; We didn't find it, so we go to the next article.
7220 (set-buffer sum)
7221 (setq found 'not)
7222 (while (eq found 'not)
7223 (if (not (if backward (gnus-summary-find-prev)
7224 (gnus-summary-find-next)))
7225 ;; No more articles.
7226 (setq found t)
7227 ;; Select the next article and adjust point.
7228 (unless (gnus-summary-article-sparse-p
7229 (gnus-summary-article-number))
7230 (setq found nil)
7231 (gnus-summary-select-article)
7232 (set-buffer gnus-article-buffer)
7233 (widen)
7234 (goto-char (if backward (point-max) (point-min))))))))
7235 (gnus-message 7 ""))
7236 ;; Return whether we found the regexp.
7237 (when (eq found 'found)
7238 (goto-char point)
7239 (gnus-summary-show-thread)
7240 (gnus-summary-goto-subject gnus-current-article)
7241 (gnus-summary-position-point)
7242 t)))
7244 (defun gnus-summary-find-matching (header regexp &optional backward unread
7245 not-case-fold not-matching)
7246 "Return a list of all articles that match REGEXP on HEADER.
7247 The search stars on the current article and goes forwards unless
7248 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7249 If UNREAD is non-nil, only unread articles will
7250 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7251 in the comparisons. If NOT-MATCHING, return a list of all articles that
7252 not match REGEXP on HEADER."
7253 (let ((case-fold-search (not not-case-fold))
7254 articles d func)
7255 (if (consp header)
7256 (if (eq (car header) 'extra)
7257 (setq func
7258 `(lambda (h)
7259 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7260 "")))
7261 (error "%s is an invalid header" header))
7262 (unless (fboundp (intern (concat "mail-header-" header)))
7263 (error "%s is not a valid header" header))
7264 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7265 (dolist (d (if (eq backward 'all)
7266 gnus-newsgroup-data
7267 (gnus-data-find-list
7268 (gnus-summary-article-number)
7269 (gnus-data-list backward))))
7270 (when (and (or (not unread) ; We want all articles...
7271 (gnus-data-unread-p d)) ; Or just unreads.
7272 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7273 (if not-matching
7274 (not (string-match
7275 regexp
7276 (funcall func (gnus-data-header d))))
7277 (string-match regexp
7278 (funcall func (gnus-data-header d)))))
7279 (push (gnus-data-number d) articles))) ; Success!
7280 (nreverse articles)))
7282 (defun gnus-summary-execute-command (header regexp command &optional backward)
7283 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7284 If HEADER is an empty string (or nil), the match is done on the entire
7285 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7286 (interactive
7287 (list (let ((completion-ignore-case t))
7288 (completing-read
7289 "Header name: "
7290 (mapcar (lambda (string) (list string))
7291 '("Number" "Subject" "From" "Lines" "Date"
7292 "Message-ID" "Xref" "References" "Body"))
7293 nil 'require-match))
7294 (read-string "Regexp: ")
7295 (read-key-sequence "Command: ")
7296 current-prefix-arg))
7297 (when (equal header "Body")
7298 (setq header ""))
7299 ;; Hidden thread subtrees must be searched as well.
7300 (gnus-summary-show-all-threads)
7301 ;; We don't want to change current point nor window configuration.
7302 (save-excursion
7303 (save-window-excursion
7304 (gnus-message 6 "Executing %s..." (key-description command))
7305 ;; We'd like to execute COMMAND interactively so as to give arguments.
7306 (gnus-execute header regexp
7307 `(call-interactively ',(key-binding command))
7308 backward)
7309 (gnus-message 6 "Executing %s...done" (key-description command)))))
7311 (defun gnus-summary-beginning-of-article ()
7312 "Scroll the article back to the beginning."
7313 (interactive)
7314 (gnus-summary-select-article)
7315 (gnus-configure-windows 'article)
7316 (gnus-eval-in-buffer-window gnus-article-buffer
7317 (widen)
7318 (goto-char (point-min))
7319 (when gnus-page-broken
7320 (gnus-narrow-to-page))))
7322 (defun gnus-summary-end-of-article ()
7323 "Scroll to the end of the article."
7324 (interactive)
7325 (gnus-summary-select-article)
7326 (gnus-configure-windows 'article)
7327 (gnus-eval-in-buffer-window gnus-article-buffer
7328 (widen)
7329 (goto-char (point-max))
7330 (recenter -3)
7331 (when gnus-page-broken
7332 (gnus-narrow-to-page))))
7334 (defun gnus-summary-print-article (&optional filename n)
7335 "Generate and print a PostScript image of the N next (mail) articles.
7337 If N is negative, print the N previous articles. If N is nil and articles
7338 have been marked with the process mark, print these instead.
7340 If the optional first argument FILENAME is nil, send the image to the
7341 printer. If FILENAME is a string, save the PostScript image in a file with
7342 that name. If FILENAME is a number, prompt the user for the name of the file
7343 to save in."
7344 (interactive (list (ps-print-preprint current-prefix-arg)))
7345 (dolist (article (gnus-summary-work-articles n))
7346 (gnus-summary-select-article nil nil 'pseudo article)
7347 (gnus-eval-in-buffer-window gnus-article-buffer
7348 (let ((buffer (generate-new-buffer " *print*")))
7349 (unwind-protect
7350 (progn
7351 (copy-to-buffer buffer (point-min) (point-max))
7352 (set-buffer buffer)
7353 (gnus-article-delete-invisible-text)
7354 (let ((ps-left-header
7355 (list
7356 (concat "("
7357 (mail-header-subject gnus-current-headers) ")")
7358 (concat "("
7359 (mail-header-from gnus-current-headers) ")")))
7360 (ps-right-header
7361 (list
7362 "/pagenumberstring load"
7363 (concat "("
7364 (mail-header-date gnus-current-headers) ")"))))
7365 (gnus-run-hooks 'gnus-ps-print-hook)
7366 (save-excursion
7367 (ps-spool-buffer-with-faces))))
7368 (kill-buffer buffer))))
7369 (gnus-summary-remove-process-mark article))
7370 (ps-despool filename))
7372 (defun gnus-summary-show-article (&optional arg)
7373 "Force re-fetching of the current article.
7374 If ARG (the prefix) is a number, show the article with the charset
7375 defined in `gnus-summary-show-article-charset-alist', or the charset
7376 inputed.
7377 If ARG (the prefix) is non-nil and not a number, show the raw article
7378 without any article massaging functions being run."
7379 (interactive "P")
7380 (cond
7381 ((numberp arg)
7382 (let ((gnus-newsgroup-charset
7383 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7384 (read-coding-system "Charset: ")))
7385 (gnus-newsgroup-ignored-charsets 'gnus-all))
7386 (gnus-summary-select-article nil 'force)))
7387 ((not arg)
7388 ;; Select the article the normal way.
7389 (gnus-summary-select-article nil 'force))
7391 ;; We have to require this here to make sure that the following
7392 ;; dynamic binding isn't shadowed by autoloading.
7393 (require 'gnus-async)
7394 (require 'gnus-art)
7395 ;; Bind the article treatment functions to nil.
7396 (let ((gnus-have-all-headers t)
7397 gnus-article-prepare-hook
7398 gnus-article-decode-hook
7399 gnus-display-mime-function
7400 gnus-break-pages)
7401 ;; Destroy any MIME parts.
7402 (when (gnus-buffer-live-p gnus-article-buffer)
7403 (save-excursion
7404 (set-buffer gnus-article-buffer)
7405 (mm-destroy-parts gnus-article-mime-handles)
7406 ;; Set it to nil for safety reason.
7407 (setq gnus-article-mime-handle-alist nil)
7408 (setq gnus-article-mime-handles nil)))
7409 (gnus-summary-select-article nil 'force))))
7410 (gnus-summary-goto-subject gnus-current-article)
7411 (gnus-summary-position-point))
7413 (defun gnus-summary-verbose-headers (&optional arg)
7414 "Toggle permanent full header display.
7415 If ARG is a positive number, turn header display on.
7416 If ARG is a negative number, turn header display off."
7417 (interactive "P")
7418 (setq gnus-show-all-headers
7419 (cond ((or (not (numberp arg))
7420 (zerop arg))
7421 (not gnus-show-all-headers))
7422 ((natnump arg)
7423 t)))
7424 (gnus-summary-show-article))
7426 (defun gnus-summary-toggle-header (&optional arg)
7427 "Show the headers if they are hidden, or hide them if they are shown.
7428 If ARG is a positive number, show the entire header.
7429 If ARG is a negative number, hide the unwanted header lines."
7430 (interactive "P")
7431 (save-excursion
7432 (set-buffer gnus-article-buffer)
7433 (save-restriction
7434 (let* ((buffer-read-only nil)
7435 (inhibit-point-motion-hooks t)
7436 hidden s e)
7437 (setq hidden
7438 (if (numberp arg)
7439 (>= arg 0)
7440 (save-restriction
7441 (article-narrow-to-head)
7442 (gnus-article-hidden-text-p 'headers))))
7443 (goto-char (point-min))
7444 (when (search-forward "\n\n" nil t)
7445 (delete-region (point-min) (1- (point))))
7446 (goto-char (point-min))
7447 (with-current-buffer gnus-original-article-buffer
7448 (goto-char (setq s (point-min)))
7449 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7450 (insert-buffer-substring gnus-original-article-buffer s e)
7451 (save-restriction
7452 (narrow-to-region (point-min) (point))
7453 (article-decode-encoded-words)
7454 (if hidden
7455 (let ((gnus-treat-hide-headers nil)
7456 (gnus-treat-hide-boring-headers nil))
7457 (setq gnus-article-wash-types
7458 (delq 'headers gnus-article-wash-types))
7459 (gnus-treat-article 'head))
7460 (gnus-treat-article 'head)))
7461 (gnus-set-mode-line 'article)))))
7463 (defun gnus-summary-show-all-headers ()
7464 "Make all header lines visible."
7465 (interactive)
7466 (gnus-article-show-all-headers))
7468 (defun gnus-summary-caesar-message (&optional arg)
7469 "Caesar rotate the current article by 13.
7470 The numerical prefix specifies how many places to rotate each letter
7471 forward."
7472 (interactive "P")
7473 (gnus-summary-select-article)
7474 (let ((mail-header-separator ""))
7475 (gnus-eval-in-buffer-window gnus-article-buffer
7476 (save-restriction
7477 (widen)
7478 (let ((start (window-start))
7479 buffer-read-only)
7480 (message-caesar-buffer-body arg)
7481 (set-window-start (get-buffer-window (current-buffer)) start))))))
7483 (defun gnus-summary-stop-page-breaking ()
7484 "Stop page breaking in the current article."
7485 (interactive)
7486 (gnus-summary-select-article)
7487 (gnus-eval-in-buffer-window gnus-article-buffer
7488 (widen)
7489 (when (gnus-visual-p 'page-marker)
7490 (let ((buffer-read-only nil))
7491 (gnus-remove-text-with-property 'gnus-prev)
7492 (gnus-remove-text-with-property 'gnus-next))
7493 (setq gnus-page-broken nil))))
7495 (defun gnus-summary-move-article (&optional n to-newsgroup
7496 select-method action)
7497 "Move the current article to a different newsgroup.
7498 If N is a positive number, move the N next articles.
7499 If N is a negative number, move the N previous articles.
7500 If N is nil and any articles have been marked with the process mark,
7501 move those articles instead.
7502 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7503 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7504 re-spool using this method.
7506 For this function to work, both the current newsgroup and the
7507 newsgroup that you want to move to have to support the `request-move'
7508 and `request-accept' functions.
7510 ACTION can be either `move' (the default), `crosspost' or `copy'."
7511 (interactive "P")
7512 (unless action
7513 (setq action 'move))
7514 ;; Disable marking as read.
7515 (let (gnus-mark-article-hook)
7516 (save-window-excursion
7517 (gnus-summary-select-article)))
7518 ;; Check whether the source group supports the required functions.
7519 (cond ((and (eq action 'move)
7520 (not (gnus-check-backend-function
7521 'request-move-article gnus-newsgroup-name)))
7522 (error "The current group does not support article moving"))
7523 ((and (eq action 'crosspost)
7524 (not (gnus-check-backend-function
7525 'request-replace-article gnus-newsgroup-name)))
7526 (error "The current group does not support article editing")))
7527 (let ((articles (gnus-summary-work-articles n))
7528 (prefix (if (gnus-check-backend-function
7529 'request-move-article gnus-newsgroup-name)
7530 (gnus-group-real-prefix gnus-newsgroup-name)
7531 ""))
7532 (names '((move "Move" "Moving")
7533 (copy "Copy" "Copying")
7534 (crosspost "Crosspost" "Crossposting")))
7535 (copy-buf (save-excursion
7536 (nnheader-set-temp-buffer " *copy article*")))
7537 art-group to-method new-xref article to-groups)
7538 (unless (assq action names)
7539 (error "Unknown action %s" action))
7540 ;; Read the newsgroup name.
7541 (when (and (not to-newsgroup)
7542 (not select-method))
7543 (setq to-newsgroup
7544 (gnus-read-move-group-name
7545 (cadr (assq action names))
7546 (symbol-value (intern (format "gnus-current-%s-group" action)))
7547 articles prefix))
7548 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7549 (setq to-method (or select-method
7550 (gnus-server-to-method
7551 (gnus-group-method to-newsgroup))))
7552 ;; Check the method we are to move this article to...
7553 (unless (gnus-check-backend-function
7554 'request-accept-article (car to-method))
7555 (error "%s does not support article copying" (car to-method)))
7556 (unless (gnus-check-server to-method)
7557 (error "Can't open server %s" (car to-method)))
7558 (gnus-message 6 "%s to %s: %s..."
7559 (caddr (assq action names))
7560 (or (car select-method) to-newsgroup) articles)
7561 (while articles
7562 (setq article (pop articles))
7563 (setq
7564 art-group
7565 (cond
7566 ;; Move the article.
7567 ((eq action 'move)
7568 ;; Remove this article from future suppression.
7569 (gnus-dup-unsuppress-article article)
7570 (gnus-request-move-article
7571 article ; Article to move
7572 gnus-newsgroup-name ; From newsgroup
7573 (nth 1 (gnus-find-method-for-group
7574 gnus-newsgroup-name)) ; Server
7575 (list 'gnus-request-accept-article
7576 to-newsgroup (list 'quote select-method)
7577 (not articles) t) ; Accept form
7578 (not articles))) ; Only save nov last time
7579 ;; Copy the article.
7580 ((eq action 'copy)
7581 (save-excursion
7582 (set-buffer copy-buf)
7583 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7584 (gnus-request-accept-article
7585 to-newsgroup select-method (not articles) t))))
7586 ;; Crosspost the article.
7587 ((eq action 'crosspost)
7588 (let ((xref (message-tokenize-header
7589 (mail-header-xref (gnus-summary-article-header article))
7590 " ")))
7591 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7592 ":" article))
7593 (unless xref
7594 (setq xref (list (system-name))))
7595 (setq new-xref
7596 (concat
7597 (mapconcat 'identity
7598 (delete "Xref:" (delete new-xref xref))
7599 " ")
7600 " " new-xref))
7601 (save-excursion
7602 (set-buffer copy-buf)
7603 ;; First put the article in the destination group.
7604 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7605 (when (consp (setq art-group
7606 (gnus-request-accept-article
7607 to-newsgroup select-method (not articles))))
7608 (setq new-xref (concat new-xref " " (car art-group)
7609 ":" (cdr art-group)))
7610 ;; Now we have the new Xrefs header, so we insert
7611 ;; it and replace the new article.
7612 (nnheader-replace-header "Xref" new-xref)
7613 (gnus-request-replace-article
7614 (cdr art-group) to-newsgroup (current-buffer))
7615 art-group))))))
7616 (cond
7617 ((not art-group)
7618 (gnus-message 1 "Couldn't %s article %s: %s"
7619 (cadr (assq action names)) article
7620 (nnheader-get-report (car to-method))))
7621 ((eq art-group 'junk)
7622 (when (eq action 'move)
7623 (gnus-summary-mark-article article gnus-canceled-mark)
7624 (gnus-message 4 "Deleted article %s" article)))
7626 (let* ((pto-group (gnus-group-prefixed-name
7627 (car art-group) to-method))
7628 (entry
7629 (gnus-gethash pto-group gnus-newsrc-hashtb))
7630 (info (nth 2 entry))
7631 (to-group (gnus-info-group info))
7632 to-marks)
7633 ;; Update the group that has been moved to.
7634 (when (and info
7635 (memq action '(move copy)))
7636 (unless (member to-group to-groups)
7637 (push to-group to-groups))
7639 (unless (memq article gnus-newsgroup-unreads)
7640 (push 'read to-marks)
7641 (gnus-info-set-read
7642 info (gnus-add-to-range (gnus-info-read info)
7643 (list (cdr art-group)))))
7645 ;; See whether the article is to be put in the cache.
7646 (let ((marks gnus-article-mark-lists)
7647 (to-article (cdr art-group)))
7649 ;; Enter the article into the cache in the new group,
7650 ;; if that is required.
7651 (when gnus-use-cache
7652 (gnus-cache-possibly-enter-article
7653 to-group to-article
7654 (memq article gnus-newsgroup-marked)
7655 (memq article gnus-newsgroup-dormant)
7656 (memq article gnus-newsgroup-unreads)))
7658 (when gnus-preserve-marks
7659 ;; Copy any marks over to the new group.
7660 (when (and (equal to-group gnus-newsgroup-name)
7661 (not (memq article gnus-newsgroup-unreads)))
7662 ;; Mark this article as read in this group.
7663 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7664 (setcdr (gnus-active to-group) to-article)
7665 (setcdr gnus-newsgroup-active to-article))
7667 (while marks
7668 (when (memq article (symbol-value
7669 (intern (format "gnus-newsgroup-%s"
7670 (caar marks)))))
7671 (push (cdar marks) to-marks)
7672 ;; If the other group is the same as this group,
7673 ;; then we have to add the mark to the list.
7674 (when (equal to-group gnus-newsgroup-name)
7675 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7676 (cons to-article
7677 (symbol-value
7678 (intern (format "gnus-newsgroup-%s"
7679 (caar marks)))))))
7680 ;; Copy the marks to other group.
7681 (gnus-add-marked-articles
7682 to-group (cdar marks) (list to-article) info))
7683 (setq marks (cdr marks)))
7685 (gnus-request-set-mark to-group (list (list (list to-article)
7686 'set
7687 to-marks))))
7689 (gnus-dribble-enter
7690 (concat "(gnus-group-set-info '"
7691 (gnus-prin1-to-string (gnus-get-info to-group))
7692 ")"))))
7694 ;; Update the Xref header in this article to point to
7695 ;; the new crossposted article we have just created.
7696 (when (eq action 'crosspost)
7697 (save-excursion
7698 (set-buffer copy-buf)
7699 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7700 (nnheader-replace-header "Xref" new-xref)
7701 (gnus-request-replace-article
7702 article gnus-newsgroup-name (current-buffer)))))
7704 ;;;!!!Why is this necessary?
7705 (set-buffer gnus-summary-buffer)
7707 (gnus-summary-goto-subject article)
7708 (when (eq action 'move)
7709 (gnus-summary-mark-article article gnus-canceled-mark))))
7710 (gnus-summary-remove-process-mark article))
7711 ;; Re-activate all groups that have been moved to.
7712 (while to-groups
7713 (save-excursion
7714 (set-buffer gnus-group-buffer)
7715 (when (gnus-group-goto-group (car to-groups) t)
7716 (gnus-group-get-new-news-this-group 1 t))
7717 (pop to-groups)))
7719 (gnus-kill-buffer copy-buf)
7720 (gnus-summary-position-point)
7721 (gnus-set-mode-line 'summary)))
7723 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7724 "Move the current article to a different newsgroup.
7725 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7726 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7727 re-spool using this method."
7728 (interactive "P")
7729 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7731 (defun gnus-summary-crosspost-article (&optional n)
7732 "Crosspost the current article to some other group."
7733 (interactive "P")
7734 (gnus-summary-move-article n nil nil 'crosspost))
7736 (defcustom gnus-summary-respool-default-method nil
7737 "Default method for respooling an article.
7738 If nil, use to the current newsgroup method."
7739 :type '(choice (gnus-select-method :value (nnml ""))
7740 (const nil))
7741 :group 'gnus-summary-mail)
7743 (defun gnus-summary-respool-article (&optional n method)
7744 "Respool the current article.
7745 The article will be squeezed through the mail spooling process again,
7746 which means that it will be put in some mail newsgroup or other
7747 depending on `nnmail-split-methods'.
7748 If N is a positive number, respool the N next articles.
7749 If N is a negative number, respool the N previous articles.
7750 If N is nil and any articles have been marked with the process mark,
7751 respool those articles instead.
7753 Respooling can be done both from mail groups and \"real\" newsgroups.
7754 In the former case, the articles in question will be moved from the
7755 current group into whatever groups they are destined to. In the
7756 latter case, they will be copied into the relevant groups."
7757 (interactive
7758 (list current-prefix-arg
7759 (let* ((methods (gnus-methods-using 'respool))
7760 (methname
7761 (symbol-name (or gnus-summary-respool-default-method
7762 (car (gnus-find-method-for-group
7763 gnus-newsgroup-name)))))
7764 (method
7765 (gnus-completing-read
7766 methname "What backend do you want to use when respooling?"
7767 methods nil t nil 'gnus-mail-method-history))
7769 (cond
7770 ((zerop (length (setq ms (gnus-servers-using-backend
7771 (intern method)))))
7772 (list (intern method) ""))
7773 ((= 1 (length ms))
7774 (car ms))
7776 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7777 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7778 ms-alist))))))))
7779 (unless method
7780 (error "No method given for respooling"))
7781 (if (assoc (symbol-name
7782 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7783 (gnus-methods-using 'respool))
7784 (gnus-summary-move-article n nil method)
7785 (gnus-summary-copy-article n nil method)))
7787 (defun gnus-summary-import-article (file)
7788 "Import an arbitrary file into a mail newsgroup."
7789 (interactive "fImport file: ")
7790 (let ((group gnus-newsgroup-name)
7791 (now (current-time))
7792 atts lines)
7793 (unless (gnus-check-backend-function 'request-accept-article group)
7794 (error "%s does not support article importing" group))
7795 (or (file-readable-p file)
7796 (not (file-regular-p file))
7797 (error "Can't read %s" file))
7798 (save-excursion
7799 (set-buffer (gnus-get-buffer-create " *import file*"))
7800 (erase-buffer)
7801 (nnheader-insert-file-contents file)
7802 (goto-char (point-min))
7803 (unless (nnheader-article-p)
7804 ;; This doesn't look like an article, so we fudge some headers.
7805 (setq atts (file-attributes file)
7806 lines (count-lines (point-min) (point-max)))
7807 (insert "From: " (read-string "From: ") "\n"
7808 "Subject: " (read-string "Subject: ") "\n"
7809 "Date: " (message-make-date (nth 5 atts))
7810 "\n"
7811 "Message-ID: " (message-make-message-id) "\n"
7812 "Lines: " (int-to-string lines) "\n"
7813 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7814 (gnus-request-accept-article group nil t)
7815 (kill-buffer (current-buffer)))))
7817 (defun gnus-summary-article-posted-p ()
7818 "Say whether the current (mail) article is available from news as well.
7819 This will be the case if the article has both been mailed and posted."
7820 (interactive)
7821 (let ((id (mail-header-references (gnus-summary-article-header)))
7822 (gnus-override-method (car (gnus-refer-article-methods))))
7823 (if (gnus-request-head id "")
7824 (gnus-message 2 "The current message was found on %s"
7825 gnus-override-method)
7826 (gnus-message 2 "The current message couldn't be found on %s"
7827 gnus-override-method)
7828 nil)))
7830 (defun gnus-summary-expire-articles (&optional now)
7831 "Expire all articles that are marked as expirable in the current group."
7832 (interactive)
7833 (when (gnus-check-backend-function
7834 'request-expire-articles gnus-newsgroup-name)
7835 ;; This backend supports expiry.
7836 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7837 (expirable (if total
7838 (progn
7839 ;; We need to update the info for
7840 ;; this group for `gnus-list-of-read-articles'
7841 ;; to give us the right answer.
7842 (gnus-run-hooks 'gnus-exit-group-hook)
7843 (gnus-summary-update-info)
7844 (gnus-list-of-read-articles gnus-newsgroup-name))
7845 (setq gnus-newsgroup-expirable
7846 (sort gnus-newsgroup-expirable '<))))
7847 (expiry-wait (if now 'immediate
7848 (gnus-group-find-parameter
7849 gnus-newsgroup-name 'expiry-wait)))
7850 (nnmail-expiry-target
7851 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7852 nnmail-expiry-target))
7854 (when expirable
7855 ;; There are expirable articles in this group, so we run them
7856 ;; through the expiry process.
7857 (gnus-message 6 "Expiring articles...")
7858 (unless (gnus-check-group gnus-newsgroup-name)
7859 (error "Can't open server for %s" gnus-newsgroup-name))
7860 ;; The list of articles that weren't expired is returned.
7861 (save-excursion
7862 (if expiry-wait
7863 (let ((nnmail-expiry-wait-function nil)
7864 (nnmail-expiry-wait expiry-wait))
7865 (setq es (gnus-request-expire-articles
7866 expirable gnus-newsgroup-name)))
7867 (setq es (gnus-request-expire-articles
7868 expirable gnus-newsgroup-name))))
7869 (unless total
7870 (setq gnus-newsgroup-expirable es))
7871 ;; We go through the old list of expirable, and mark all
7872 ;; really expired articles as nonexistent.
7873 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7874 (let ((gnus-use-cache nil))
7875 (while expirable
7876 (unless (memq (car expirable) es)
7877 (when (gnus-data-find (car expirable))
7878 (gnus-summary-mark-article
7879 (car expirable) gnus-canceled-mark)))
7880 (setq expirable (cdr expirable)))))
7881 (gnus-message 6 "Expiring articles...done")))))
7883 (defun gnus-summary-expire-articles-now ()
7884 "Expunge all expirable articles in the current group.
7885 This means that *all* articles that are marked as expirable will be
7886 deleted forever, right now."
7887 (interactive)
7888 (or gnus-expert-user
7889 (gnus-yes-or-no-p
7890 "Are you really, really, really sure you want to delete all these messages? ")
7891 (error "Phew!"))
7892 (gnus-summary-expire-articles t))
7894 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7895 (defun gnus-summary-delete-article (&optional n)
7896 "Delete the N next (mail) articles.
7897 This command actually deletes articles. This is not a marking
7898 command. The article will disappear forever from your life, never to
7899 return.
7900 If N is negative, delete backwards.
7901 If N is nil and articles have been marked with the process mark,
7902 delete these instead."
7903 (interactive "P")
7904 (unless (gnus-check-backend-function 'request-expire-articles
7905 gnus-newsgroup-name)
7906 (error "The current newsgroup does not support article deletion"))
7907 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7908 (error "Couldn't open server"))
7909 ;; Compute the list of articles to delete.
7910 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7911 not-deleted)
7912 (if (and gnus-novice-user
7913 (not (gnus-yes-or-no-p
7914 (format "Do you really want to delete %s forever? "
7915 (if (> (length articles) 1)
7916 (format "these %s articles" (length articles))
7917 "this article")))))
7919 ;; Delete the articles.
7920 (setq not-deleted (gnus-request-expire-articles
7921 articles gnus-newsgroup-name 'force))
7922 (while articles
7923 (gnus-summary-remove-process-mark (car articles))
7924 ;; The backend might not have been able to delete the article
7925 ;; after all.
7926 (unless (memq (car articles) not-deleted)
7927 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7928 (setq articles (cdr articles)))
7929 (when not-deleted
7930 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7931 (gnus-summary-position-point)
7932 (gnus-set-mode-line 'summary)
7933 not-deleted))
7935 (defun gnus-summary-edit-article (&optional arg)
7936 "Edit the current article.
7937 This will have permanent effect only in mail groups.
7938 If ARG is nil, edit the decoded articles.
7939 If ARG is 1, edit the raw articles.
7940 If ARG is 2, edit the raw articles even in read-only groups.
7941 Otherwise, allow editing of articles even in read-only
7942 groups."
7943 (interactive "P")
7944 (let (force raw)
7945 (cond
7946 ((null arg))
7947 ((eq arg 1) (setq raw t))
7948 ((eq arg 2) (setq raw t
7949 force t))
7950 (t (setq force t)))
7951 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
7952 (error "Can't edit the raw article in group nndraft:drafts"))
7953 (save-excursion
7954 (set-buffer gnus-summary-buffer)
7955 (let ((mail-parse-charset gnus-newsgroup-charset)
7956 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7957 (gnus-set-global-variables)
7958 (when (and (not force)
7959 (gnus-group-read-only-p))
7960 (error "The current newsgroup does not support article editing"))
7961 (gnus-summary-show-article t)
7962 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
7963 (with-current-buffer gnus-article-buffer
7964 (mm-enable-multibyte)))
7965 (if (equal gnus-newsgroup-name "nndraft:drafts")
7966 (setq raw t))
7967 (gnus-article-edit-article
7968 (if raw 'ignore
7969 #'(lambda ()
7970 (let ((mbl mml-buffer-list))
7971 (setq mml-buffer-list nil)
7972 (mime-to-mml)
7973 (make-local-hook 'kill-buffer-hook)
7974 (let ((mml-buffer-list mml-buffer-list))
7975 (setq mml-buffer-list mbl)
7976 (make-local-variable 'mml-buffer-list))
7977 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
7978 `(lambda (no-highlight)
7979 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7980 (mail-parse-ignored-charsets
7981 ',gnus-newsgroup-ignored-charsets))
7982 ,(if (not raw) '(progn
7983 (mml-to-mime)
7984 (mml-destroy-buffers)
7985 (remove-hook 'kill-buffer-hook
7986 'mml-destroy-buffers t)
7987 (kill-local-variable 'mml-buffer-list)))
7988 (gnus-summary-edit-article-done
7989 ,(or (mail-header-references gnus-current-headers) "")
7990 ,(gnus-group-read-only-p)
7991 ,gnus-summary-buffer no-highlight))))))))
7993 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7995 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7996 no-highlight)
7997 "Make edits to the current article permanent."
7998 (interactive)
7999 ;; Replace the article.
8000 (let ((buf (current-buffer)))
8001 (with-temp-buffer
8002 (insert-buffer-substring buf)
8003 (if (and (not read-only)
8004 (not (gnus-request-replace-article
8005 (cdr gnus-article-current) (car gnus-article-current)
8006 (current-buffer) t)))
8007 (error "Couldn't replace article")
8008 ;; Update the summary buffer.
8009 (if (and references
8010 (equal (message-tokenize-header references " ")
8011 (message-tokenize-header
8012 (or (message-fetch-field "references") "") " ")))
8013 ;; We only have to update this line.
8014 (save-excursion
8015 (save-restriction
8016 (message-narrow-to-head)
8017 (let ((head (buffer-string))
8018 header)
8019 (with-temp-buffer
8020 (insert (format "211 %d Article retrieved.\n"
8021 (cdr gnus-article-current)))
8022 (insert head)
8023 (insert ".\n")
8024 (let ((nntp-server-buffer (current-buffer)))
8025 (setq header (car (gnus-get-newsgroup-headers
8026 (save-excursion
8027 (set-buffer gnus-summary-buffer)
8028 gnus-newsgroup-dependencies)
8029 t))))
8030 (save-excursion
8031 (set-buffer gnus-summary-buffer)
8032 (gnus-data-set-header
8033 (gnus-data-find (cdr gnus-article-current))
8034 header)
8035 (gnus-summary-update-article-line
8036 (cdr gnus-article-current) header))))))
8037 ;; Update threads.
8038 (set-buffer (or buffer gnus-summary-buffer))
8039 (gnus-summary-update-article (cdr gnus-article-current)))
8040 ;; Prettify the article buffer again.
8041 (unless no-highlight
8042 (save-excursion
8043 (set-buffer gnus-article-buffer)
8044 ;;;!!! Fix this -- article should be rehighlighted.
8045 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8046 (set-buffer gnus-original-article-buffer)
8047 (gnus-request-article
8048 (cdr gnus-article-current)
8049 (car gnus-article-current) (current-buffer))))
8050 ;; Prettify the summary buffer line.
8051 (when (gnus-visual-p 'summary-highlight 'highlight)
8052 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8054 (defun gnus-summary-edit-wash (key)
8055 "Perform editing command KEY in the article buffer."
8056 (interactive
8057 (list
8058 (progn
8059 (message "%s" (concat (this-command-keys) "- "))
8060 (read-char))))
8061 (message "")
8062 (gnus-summary-edit-article)
8063 (execute-kbd-macro (concat (this-command-keys) key))
8064 (gnus-article-edit-done))
8066 ;;; Respooling
8068 (defun gnus-summary-respool-query (&optional silent trace)
8069 "Query where the respool algorithm would put this article."
8070 (interactive)
8071 (let (gnus-mark-article-hook)
8072 (gnus-summary-select-article)
8073 (save-excursion
8074 (set-buffer gnus-original-article-buffer)
8075 (save-restriction
8076 (message-narrow-to-head)
8077 (let ((groups (nnmail-article-group 'identity trace)))
8078 (unless silent
8079 (if groups
8080 (message "This message would go to %s"
8081 (mapconcat 'car groups ", "))
8082 (message "This message would go to no groups"))
8083 groups))))))
8085 (defun gnus-summary-respool-trace ()
8086 "Trace where the respool algorithm would put this article.
8087 Display a buffer showing all fancy splitting patterns which matched."
8088 (interactive)
8089 (gnus-summary-respool-query nil t))
8091 ;; Summary marking commands.
8093 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8094 "Mark articles which has the same subject as read, and then select the next.
8095 If UNMARK is positive, remove any kind of mark.
8096 If UNMARK is negative, tick articles."
8097 (interactive "P")
8098 (when unmark
8099 (setq unmark (prefix-numeric-value unmark)))
8100 (let ((count
8101 (gnus-summary-mark-same-subject
8102 (gnus-summary-article-subject) unmark)))
8103 ;; Select next unread article. If auto-select-same mode, should
8104 ;; select the first unread article.
8105 (gnus-summary-next-article t (and gnus-auto-select-same
8106 (gnus-summary-article-subject)))
8107 (gnus-message 7 "%d article%s marked as %s"
8108 count (if (= count 1) " is" "s are")
8109 (if unmark "unread" "read"))))
8111 (defun gnus-summary-kill-same-subject (&optional unmark)
8112 "Mark articles which has the same subject as read.
8113 If UNMARK is positive, remove any kind of mark.
8114 If UNMARK is negative, tick articles."
8115 (interactive "P")
8116 (when unmark
8117 (setq unmark (prefix-numeric-value unmark)))
8118 (let ((count
8119 (gnus-summary-mark-same-subject
8120 (gnus-summary-article-subject) unmark)))
8121 ;; If marked as read, go to next unread subject.
8122 (when (null unmark)
8123 ;; Go to next unread subject.
8124 (gnus-summary-next-subject 1 t))
8125 (gnus-message 7 "%d articles are marked as %s"
8126 count (if unmark "unread" "read"))))
8128 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8129 "Mark articles with same SUBJECT as read, and return marked number.
8130 If optional argument UNMARK is positive, remove any kinds of marks.
8131 If optional argument UNMARK is negative, mark articles as unread instead."
8132 (let ((count 1))
8133 (save-excursion
8134 (cond
8135 ((null unmark) ; Mark as read.
8136 (while (and
8137 (progn
8138 (gnus-summary-mark-article-as-read gnus-killed-mark)
8139 (gnus-summary-show-thread) t)
8140 (gnus-summary-find-subject subject))
8141 (setq count (1+ count))))
8142 ((> unmark 0) ; Tick.
8143 (while (and
8144 (progn
8145 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8146 (gnus-summary-show-thread) t)
8147 (gnus-summary-find-subject subject))
8148 (setq count (1+ count))))
8149 (t ; Mark as unread.
8150 (while (and
8151 (progn
8152 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8153 (gnus-summary-show-thread) t)
8154 (gnus-summary-find-subject subject))
8155 (setq count (1+ count)))))
8156 (gnus-set-mode-line 'summary)
8157 ;; Return the number of marked articles.
8158 count)))
8160 (defun gnus-summary-mark-as-processable (n &optional unmark)
8161 "Set the process mark on the next N articles.
8162 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8163 the process mark instead. The difference between N and the actual
8164 number of articles marked is returned."
8165 (interactive "p")
8166 (let ((backward (< n 0))
8167 (n (abs n)))
8168 (while (and
8169 (> n 0)
8170 (if unmark
8171 (gnus-summary-remove-process-mark
8172 (gnus-summary-article-number))
8173 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8174 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8175 (setq n (1- n)))
8176 (when (/= 0 n)
8177 (gnus-message 7 "No more articles"))
8178 (gnus-summary-recenter)
8179 (gnus-summary-position-point)
8182 (defun gnus-summary-unmark-as-processable (n)
8183 "Remove the process mark from the next N articles.
8184 If N is negative, unmark backward instead. The difference between N and
8185 the actual number of articles unmarked is returned."
8186 (interactive "p")
8187 (gnus-summary-mark-as-processable n t))
8189 (defun gnus-summary-unmark-all-processable ()
8190 "Remove the process mark from all articles."
8191 (interactive)
8192 (save-excursion
8193 (while gnus-newsgroup-processable
8194 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8195 (gnus-summary-position-point))
8197 (defun gnus-summary-mark-as-expirable (n)
8198 "Mark N articles forward as expirable.
8199 If N is negative, mark backward instead. The difference between N and
8200 the actual number of articles marked is returned."
8201 (interactive "p")
8202 (gnus-summary-mark-forward n gnus-expirable-mark))
8204 (defun gnus-summary-mark-article-as-replied (article)
8205 "Mark ARTICLE replied and update the summary line."
8206 (push article gnus-newsgroup-replied)
8207 (let ((buffer-read-only nil))
8208 (when (gnus-summary-goto-subject article nil t)
8209 (gnus-summary-update-secondary-mark article))))
8211 (defun gnus-summary-set-bookmark (article)
8212 "Set a bookmark in current article."
8213 (interactive (list (gnus-summary-article-number)))
8214 (when (or (not (get-buffer gnus-article-buffer))
8215 (not gnus-current-article)
8216 (not gnus-article-current)
8217 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8218 (error "No current article selected"))
8219 ;; Remove old bookmark, if one exists.
8220 (let ((old (assq article gnus-newsgroup-bookmarks)))
8221 (when old
8222 (setq gnus-newsgroup-bookmarks
8223 (delq old gnus-newsgroup-bookmarks))))
8224 ;; Set the new bookmark, which is on the form
8225 ;; (article-number . line-number-in-body).
8226 (push
8227 (cons article
8228 (save-excursion
8229 (set-buffer gnus-article-buffer)
8230 (count-lines
8231 (min (point)
8232 (save-excursion
8233 (goto-char (point-min))
8234 (search-forward "\n\n" nil t)
8235 (point)))
8236 (point))))
8237 gnus-newsgroup-bookmarks)
8238 (gnus-message 6 "A bookmark has been added to the current article."))
8240 (defun gnus-summary-remove-bookmark (article)
8241 "Remove the bookmark from the current article."
8242 (interactive (list (gnus-summary-article-number)))
8243 ;; Remove old bookmark, if one exists.
8244 (let ((old (assq article gnus-newsgroup-bookmarks)))
8245 (if old
8246 (progn
8247 (setq gnus-newsgroup-bookmarks
8248 (delq old gnus-newsgroup-bookmarks))
8249 (gnus-message 6 "Removed bookmark."))
8250 (gnus-message 6 "No bookmark in current article."))))
8252 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8253 (defun gnus-summary-mark-as-dormant (n)
8254 "Mark N articles forward as dormant.
8255 If N is negative, mark backward instead. The difference between N and
8256 the actual number of articles marked is returned."
8257 (interactive "p")
8258 (gnus-summary-mark-forward n gnus-dormant-mark))
8260 (defun gnus-summary-set-process-mark (article)
8261 "Set the process mark on ARTICLE and update the summary line."
8262 (setq gnus-newsgroup-processable
8263 (cons article
8264 (delq article gnus-newsgroup-processable)))
8265 (when (gnus-summary-goto-subject article)
8266 (gnus-summary-show-thread)
8267 (gnus-summary-goto-subject article)
8268 (gnus-summary-update-secondary-mark article)))
8270 (defun gnus-summary-remove-process-mark (article)
8271 "Remove the process mark from ARTICLE and update the summary line."
8272 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8273 (when (gnus-summary-goto-subject article)
8274 (gnus-summary-show-thread)
8275 (gnus-summary-goto-subject article)
8276 (gnus-summary-update-secondary-mark article)))
8278 (defun gnus-summary-set-saved-mark (article)
8279 "Set the process mark on ARTICLE and update the summary line."
8280 (push article gnus-newsgroup-saved)
8281 (when (gnus-summary-goto-subject article)
8282 (gnus-summary-update-secondary-mark article)))
8284 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8285 "Mark N articles as read forwards.
8286 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8287 The difference between N and the actual number of articles marked is
8288 returned.
8289 If NO-EXPIRE, auto-expiry will be inhibited."
8290 (interactive "p")
8291 (gnus-summary-show-thread)
8292 (let ((backward (< n 0))
8293 (gnus-summary-goto-unread
8294 (and gnus-summary-goto-unread
8295 (not (eq gnus-summary-goto-unread 'never))
8296 (not (memq mark (list gnus-unread-mark
8297 gnus-ticked-mark gnus-dormant-mark)))))
8298 (n (abs n))
8299 (mark (or mark gnus-del-mark)))
8300 (while (and (> n 0)
8301 (gnus-summary-mark-article nil mark no-expire)
8302 (zerop (gnus-summary-next-subject
8303 (if backward -1 1)
8304 (and gnus-summary-goto-unread
8305 (not (eq gnus-summary-goto-unread 'never)))
8306 t)))
8307 (setq n (1- n)))
8308 (when (/= 0 n)
8309 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8310 (gnus-summary-recenter)
8311 (gnus-summary-position-point)
8312 (gnus-set-mode-line 'summary)
8315 (defun gnus-summary-mark-article-as-read (mark)
8316 "Mark the current article quickly as read with MARK."
8317 (let ((article (gnus-summary-article-number)))
8318 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8319 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8320 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8321 (push (cons article mark) gnus-newsgroup-reads)
8322 ;; Possibly remove from cache, if that is used.
8323 (when gnus-use-cache
8324 (gnus-cache-enter-remove-article article))
8325 ;; Allow the backend to change the mark.
8326 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8327 ;; Check for auto-expiry.
8328 (when (and gnus-newsgroup-auto-expire
8329 (memq mark gnus-auto-expirable-marks))
8330 (setq mark gnus-expirable-mark)
8331 ;; Let the backend know about the mark change.
8332 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8333 (push article gnus-newsgroup-expirable))
8334 ;; Set the mark in the buffer.
8335 (gnus-summary-update-mark mark 'unread)
8338 (defun gnus-summary-mark-article-as-unread (mark)
8339 "Mark the current article quickly as unread with MARK."
8340 (let* ((article (gnus-summary-article-number))
8341 (old-mark (gnus-summary-article-mark article)))
8342 ;; Allow the backend to change the mark.
8343 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8344 (if (eq mark old-mark)
8346 (if (<= article 0)
8347 (progn
8348 (gnus-error 1 "Can't mark negative article numbers")
8349 nil)
8350 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8351 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8352 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8353 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8354 (cond ((= mark gnus-ticked-mark)
8355 (push article gnus-newsgroup-marked))
8356 ((= mark gnus-dormant-mark)
8357 (push article gnus-newsgroup-dormant))
8359 (push article gnus-newsgroup-unreads)))
8360 (gnus-pull article gnus-newsgroup-reads)
8362 ;; See whether the article is to be put in the cache.
8363 (and gnus-use-cache
8364 (vectorp (gnus-summary-article-header article))
8365 (save-excursion
8366 (gnus-cache-possibly-enter-article
8367 gnus-newsgroup-name article
8368 (= mark gnus-ticked-mark)
8369 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8371 ;; Fix the mark.
8372 (gnus-summary-update-mark mark 'unread)
8373 t))))
8375 (defun gnus-summary-mark-article (&optional article mark no-expire)
8376 "Mark ARTICLE with MARK. MARK can be any character.
8377 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8378 `??' (dormant) and `?E' (expirable).
8379 If MARK is nil, then the default character `?r' is used.
8380 If ARTICLE is nil, then the article on the current line will be
8381 marked.
8382 If NO-EXPIRE, auto-expiry will be inhibited."
8383 ;; The mark might be a string.
8384 (when (stringp mark)
8385 (setq mark (aref mark 0)))
8386 ;; If no mark is given, then we check auto-expiring.
8387 (when (null mark)
8388 (setq mark gnus-del-mark))
8389 (when (and (not no-expire)
8390 gnus-newsgroup-auto-expire
8391 (memq mark gnus-auto-expirable-marks))
8392 (setq mark gnus-expirable-mark))
8393 (let ((article (or article (gnus-summary-article-number)))
8394 (old-mark (gnus-summary-article-mark article)))
8395 ;; Allow the backend to change the mark.
8396 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8397 (if (eq mark old-mark)
8399 (unless article
8400 (error "No article on current line"))
8401 (if (not (if (or (= mark gnus-unread-mark)
8402 (= mark gnus-ticked-mark)
8403 (= mark gnus-dormant-mark))
8404 (gnus-mark-article-as-unread article mark)
8405 (gnus-mark-article-as-read article mark)))
8407 ;; See whether the article is to be put in the cache.
8408 (and gnus-use-cache
8409 (not (= mark gnus-canceled-mark))
8410 (vectorp (gnus-summary-article-header article))
8411 (save-excursion
8412 (gnus-cache-possibly-enter-article
8413 gnus-newsgroup-name article
8414 (= mark gnus-ticked-mark)
8415 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8417 (when (gnus-summary-goto-subject article nil t)
8418 (let ((buffer-read-only nil))
8419 (gnus-summary-show-thread)
8420 ;; Fix the mark.
8421 (gnus-summary-update-mark mark 'unread)
8422 t))))))
8424 (defun gnus-summary-update-secondary-mark (article)
8425 "Update the secondary (read, process, cache) mark."
8426 (gnus-summary-update-mark
8427 (cond ((memq article gnus-newsgroup-processable)
8428 gnus-process-mark)
8429 ((memq article gnus-newsgroup-cached)
8430 gnus-cached-mark)
8431 ((memq article gnus-newsgroup-replied)
8432 gnus-replied-mark)
8433 ((memq article gnus-newsgroup-saved)
8434 gnus-saved-mark)
8435 (t gnus-unread-mark))
8436 'replied)
8437 (when (gnus-visual-p 'summary-highlight 'highlight)
8438 (gnus-run-hooks 'gnus-summary-update-hook))
8441 (defun gnus-summary-update-mark (mark type)
8442 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8443 (buffer-read-only nil))
8444 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8445 (when forward
8446 (when (looking-at "\r")
8447 (incf forward))
8448 (when (<= (+ forward (point)) (point-max))
8449 ;; Go to the right position on the line.
8450 (goto-char (+ forward (point)))
8451 ;; Replace the old mark with the new mark.
8452 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8453 ;; Optionally update the marks by some user rule.
8454 (when (eq type 'unread)
8455 (gnus-data-set-mark
8456 (gnus-data-find (gnus-summary-article-number)) mark)
8457 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8459 (defun gnus-mark-article-as-read (article &optional mark)
8460 "Enter ARTICLE in the pertinent lists and remove it from others."
8461 ;; Make the article expirable.
8462 (let ((mark (or mark gnus-del-mark)))
8463 (if (= mark gnus-expirable-mark)
8464 (push article gnus-newsgroup-expirable)
8465 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8466 ;; Remove from unread and marked lists.
8467 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8468 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8469 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8470 (push (cons article mark) gnus-newsgroup-reads)
8471 ;; Possibly remove from cache, if that is used.
8472 (when gnus-use-cache
8473 (gnus-cache-enter-remove-article article))
8476 (defun gnus-mark-article-as-unread (article &optional mark)
8477 "Enter ARTICLE in the pertinent lists and remove it from others."
8478 (let ((mark (or mark gnus-ticked-mark)))
8479 (if (<= article 0)
8480 (progn
8481 (gnus-error 1 "Can't mark negative article numbers")
8482 nil)
8483 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8484 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8485 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8486 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8488 ;; Unsuppress duplicates?
8489 (when gnus-suppress-duplicates
8490 (gnus-dup-unsuppress-article article))
8492 (cond ((= mark gnus-ticked-mark)
8493 (push article gnus-newsgroup-marked))
8494 ((= mark gnus-dormant-mark)
8495 (push article gnus-newsgroup-dormant))
8497 (push article gnus-newsgroup-unreads)))
8498 (gnus-pull article gnus-newsgroup-reads)
8499 t)))
8501 (defalias 'gnus-summary-mark-as-unread-forward
8502 'gnus-summary-tick-article-forward)
8503 (make-obsolete 'gnus-summary-mark-as-unread-forward
8504 'gnus-summary-tick-article-forward)
8505 (defun gnus-summary-tick-article-forward (n)
8506 "Tick N articles forwards.
8507 If N is negative, tick backwards instead.
8508 The difference between N and the number of articles ticked is returned."
8509 (interactive "p")
8510 (gnus-summary-mark-forward n gnus-ticked-mark))
8512 (defalias 'gnus-summary-mark-as-unread-backward
8513 'gnus-summary-tick-article-backward)
8514 (make-obsolete 'gnus-summary-mark-as-unread-backward
8515 'gnus-summary-tick-article-backward)
8516 (defun gnus-summary-tick-article-backward (n)
8517 "Tick N articles backwards.
8518 The difference between N and the number of articles ticked is returned."
8519 (interactive "p")
8520 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8522 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8523 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8524 (defun gnus-summary-tick-article (&optional article clear-mark)
8525 "Mark current article as unread.
8526 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8527 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8528 (interactive)
8529 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8530 gnus-ticked-mark)))
8532 (defun gnus-summary-mark-as-read-forward (n)
8533 "Mark N articles as read forwards.
8534 If N is negative, mark backwards instead.
8535 The difference between N and the actual number of articles marked is
8536 returned."
8537 (interactive "p")
8538 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8540 (defun gnus-summary-mark-as-read-backward (n)
8541 "Mark the N articles as read backwards.
8542 The difference between N and the actual number of articles marked is
8543 returned."
8544 (interactive "p")
8545 (gnus-summary-mark-forward
8546 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8548 (defun gnus-summary-mark-as-read (&optional article mark)
8549 "Mark current article as read.
8550 ARTICLE specifies the article to be marked as read.
8551 MARK specifies a string to be inserted at the beginning of the line."
8552 (gnus-summary-mark-article article mark))
8554 (defun gnus-summary-clear-mark-forward (n)
8555 "Clear marks from N articles forward.
8556 If N is negative, clear backward instead.
8557 The difference between N and the number of marks cleared is returned."
8558 (interactive "p")
8559 (gnus-summary-mark-forward n gnus-unread-mark))
8561 (defun gnus-summary-clear-mark-backward (n)
8562 "Clear marks from N articles backward.
8563 The difference between N and the number of marks cleared is returned."
8564 (interactive "p")
8565 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8567 (defun gnus-summary-mark-unread-as-read ()
8568 "Intended to be used by `gnus-summary-mark-article-hook'."
8569 (when (memq gnus-current-article gnus-newsgroup-unreads)
8570 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8572 (defun gnus-summary-mark-read-and-unread-as-read ()
8573 "Intended to be used by `gnus-summary-mark-article-hook'."
8574 (let ((mark (gnus-summary-article-mark)))
8575 (when (or (gnus-unread-mark-p mark)
8576 (gnus-read-mark-p mark))
8577 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8579 (defun gnus-summary-mark-region-as-read (point mark all)
8580 "Mark all unread articles between point and mark as read.
8581 If given a prefix, mark all articles between point and mark as read,
8582 even ticked and dormant ones."
8583 (interactive "r\nP")
8584 (save-excursion
8585 (let (article)
8586 (goto-char point)
8587 (beginning-of-line)
8588 (while (and
8589 (< (point) mark)
8590 (progn
8591 (when (or all
8592 (memq (setq article (gnus-summary-article-number))
8593 gnus-newsgroup-unreads))
8594 (gnus-summary-mark-article article gnus-del-mark))
8596 (gnus-summary-find-next))))))
8598 (defun gnus-summary-mark-below (score mark)
8599 "Mark articles with score less than SCORE with MARK."
8600 (interactive "P\ncMark: ")
8601 (setq score (if score
8602 (prefix-numeric-value score)
8603 (or gnus-summary-default-score 0)))
8604 (save-excursion
8605 (set-buffer gnus-summary-buffer)
8606 (goto-char (point-min))
8607 (while
8608 (progn
8609 (and (< (gnus-summary-article-score) score)
8610 (gnus-summary-mark-article nil mark))
8611 (gnus-summary-find-next)))))
8613 (defun gnus-summary-kill-below (&optional score)
8614 "Mark articles with score below SCORE as read."
8615 (interactive "P")
8616 (gnus-summary-mark-below score gnus-killed-mark))
8618 (defun gnus-summary-clear-above (&optional score)
8619 "Clear all marks from articles with score above SCORE."
8620 (interactive "P")
8621 (gnus-summary-mark-above score gnus-unread-mark))
8623 (defun gnus-summary-tick-above (&optional score)
8624 "Tick all articles with score above SCORE."
8625 (interactive "P")
8626 (gnus-summary-mark-above score gnus-ticked-mark))
8628 (defun gnus-summary-mark-above (score mark)
8629 "Mark articles with score over SCORE with MARK."
8630 (interactive "P\ncMark: ")
8631 (setq score (if score
8632 (prefix-numeric-value score)
8633 (or gnus-summary-default-score 0)))
8634 (save-excursion
8635 (set-buffer gnus-summary-buffer)
8636 (goto-char (point-min))
8637 (while (and (progn
8638 (when (> (gnus-summary-article-score) score)
8639 (gnus-summary-mark-article nil mark))
8641 (gnus-summary-find-next)))))
8643 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8644 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8645 (defun gnus-summary-limit-include-expunged (&optional no-error)
8646 "Display all the hidden articles that were expunged for low scores."
8647 (interactive)
8648 (let ((buffer-read-only nil))
8649 (let ((scored gnus-newsgroup-scored)
8650 headers h)
8651 (while scored
8652 (unless (gnus-summary-goto-subject (caar scored))
8653 (and (setq h (gnus-summary-article-header (caar scored)))
8654 (< (cdar scored) gnus-summary-expunge-below)
8655 (push h headers)))
8656 (setq scored (cdr scored)))
8657 (if (not headers)
8658 (when (not no-error)
8659 (error "No expunged articles hidden"))
8660 (goto-char (point-min))
8661 (gnus-summary-prepare-unthreaded (nreverse headers))
8662 (goto-char (point-min))
8663 (gnus-summary-position-point)
8664 t))))
8666 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8667 "Mark all unread articles in this newsgroup as read.
8668 If prefix argument ALL is non-nil, ticked and dormant articles will
8669 also be marked as read.
8670 If QUIETLY is non-nil, no questions will be asked.
8671 If TO-HERE is non-nil, it should be a point in the buffer. All
8672 articles before this point will be marked as read.
8673 Note that this function will only catch up the unread article
8674 in the current summary buffer limitation.
8675 The number of articles marked as read is returned."
8676 (interactive "P")
8677 (prog1
8678 (save-excursion
8679 (when (or quietly
8680 (not gnus-interactive-catchup) ;Without confirmation?
8681 gnus-expert-user
8682 (gnus-y-or-n-p
8683 (if all
8684 "Mark absolutely all articles as read? "
8685 "Mark all unread articles as read? ")))
8686 (if (and not-mark
8687 (not gnus-newsgroup-adaptive)
8688 (not gnus-newsgroup-auto-expire)
8689 (not gnus-suppress-duplicates)
8690 (or (not gnus-use-cache)
8691 (eq gnus-use-cache 'passive)))
8692 (progn
8693 (when all
8694 (setq gnus-newsgroup-marked nil
8695 gnus-newsgroup-dormant nil))
8696 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8697 ;; We actually mark all articles as canceled, which we
8698 ;; have to do when using auto-expiry or adaptive scoring.
8699 (gnus-summary-show-all-threads)
8700 (when (gnus-summary-first-subject (not all) t)
8701 (while (and
8702 (if to-here (< (point) to-here) t)
8703 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8704 (gnus-summary-find-next (not all) nil nil t))))
8705 (gnus-set-mode-line 'summary))
8707 (gnus-summary-position-point)))
8709 (defun gnus-summary-catchup-to-here (&optional all)
8710 "Mark all unticked articles before the current one as read.
8711 If ALL is non-nil, also mark ticked and dormant articles as read."
8712 (interactive "P")
8713 (save-excursion
8714 (gnus-save-hidden-threads
8715 (let ((beg (point)))
8716 ;; We check that there are unread articles.
8717 (when (or all (gnus-summary-find-prev))
8718 (gnus-summary-catchup all t beg)))))
8719 (gnus-summary-position-point))
8721 (defun gnus-summary-catchup-all (&optional quietly)
8722 "Mark all articles in this newsgroup as read."
8723 (interactive "P")
8724 (gnus-summary-catchup t quietly))
8726 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8727 "Mark all unread articles in this group as read, then exit.
8728 If prefix argument ALL is non-nil, all articles are marked as read."
8729 (interactive "P")
8730 (when (gnus-summary-catchup all quietly nil 'fast)
8731 ;; Select next newsgroup or exit.
8732 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8733 (eq gnus-auto-select-next 'quietly))
8734 (gnus-summary-next-group nil)
8735 (gnus-summary-exit))))
8737 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8738 "Mark all articles in this newsgroup as read, and then exit."
8739 (interactive "P")
8740 (gnus-summary-catchup-and-exit t quietly))
8742 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8743 "Mark all articles in this group as read and select the next group.
8744 If given a prefix, mark all articles, unread as well as ticked, as
8745 read."
8746 (interactive "P")
8747 (save-excursion
8748 (gnus-summary-catchup all))
8749 (gnus-summary-next-group))
8752 ;;; with article
8755 (defmacro gnus-with-article (article &rest forms)
8756 "Select ARTICLE and perform FORMS in the original article buffer.
8757 Then replace the article with the result."
8758 `(progn
8759 ;; We don't want the article to be marked as read.
8760 (let (gnus-mark-article-hook)
8761 (gnus-summary-select-article t t nil ,article))
8762 (set-buffer gnus-original-article-buffer)
8763 ,@forms
8764 (if (not (gnus-check-backend-function
8765 'request-replace-article (car gnus-article-current)))
8766 (gnus-message 5 "Read-only group; not replacing")
8767 (unless (gnus-request-replace-article
8768 ,article (car gnus-article-current)
8769 (current-buffer) t)
8770 (error "Couldn't replace article")))
8771 ;; The cache and backlog have to be flushed somewhat.
8772 (when gnus-keep-backlog
8773 (gnus-backlog-remove-article
8774 (car gnus-article-current) (cdr gnus-article-current)))
8775 (when gnus-use-cache
8776 (gnus-cache-update-article
8777 (car gnus-article-current) (cdr gnus-article-current)))))
8779 (put 'gnus-with-article 'lisp-indent-function 1)
8780 (put 'gnus-with-article 'edebug-form-spec '(form body))
8782 ;; Thread-based commands.
8784 (defun gnus-summary-articles-in-thread (&optional article)
8785 "Return a list of all articles in the current thread.
8786 If ARTICLE is non-nil, return all articles in the thread that starts
8787 with that article."
8788 (let* ((article (or article (gnus-summary-article-number)))
8789 (data (gnus-data-find-list article))
8790 (top-level (gnus-data-level (car data)))
8791 (top-subject
8792 (cond ((null gnus-thread-operation-ignore-subject)
8793 (gnus-simplify-subject-re
8794 (mail-header-subject (gnus-data-header (car data)))))
8795 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8796 (gnus-simplify-subject-fuzzy
8797 (mail-header-subject (gnus-data-header (car data)))))
8798 (t nil)))
8799 (end-point (save-excursion
8800 (if (gnus-summary-go-to-next-thread)
8801 (point) (point-max))))
8802 articles)
8803 (while (and data
8804 (< (gnus-data-pos (car data)) end-point))
8805 (when (or (not top-subject)
8806 (string= top-subject
8807 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8808 (gnus-simplify-subject-fuzzy
8809 (mail-header-subject
8810 (gnus-data-header (car data))))
8811 (gnus-simplify-subject-re
8812 (mail-header-subject
8813 (gnus-data-header (car data)))))))
8814 (push (gnus-data-number (car data)) articles))
8815 (unless (and (setq data (cdr data))
8816 (> (gnus-data-level (car data)) top-level))
8817 (setq data nil)))
8818 ;; Return the list of articles.
8819 (nreverse articles)))
8821 (defun gnus-summary-rethread-current ()
8822 "Rethread the thread the current article is part of."
8823 (interactive)
8824 (let* ((gnus-show-threads t)
8825 (article (gnus-summary-article-number))
8826 (id (mail-header-id (gnus-summary-article-header)))
8827 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8828 (unless id
8829 (error "No article on the current line"))
8830 (gnus-rebuild-thread id)
8831 (gnus-summary-goto-subject article)))
8833 (defun gnus-summary-reparent-thread ()
8834 "Make the current article child of the marked (or previous) article.
8836 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8837 is non-nil or the Subject: of both articles are the same."
8838 (interactive)
8839 (unless (not (gnus-group-read-only-p))
8840 (error "The current newsgroup does not support article editing"))
8841 (unless (<= (length gnus-newsgroup-processable) 1)
8842 (error "No more than one article may be marked"))
8843 (save-window-excursion
8844 (let ((gnus-article-buffer " *reparent*")
8845 (current-article (gnus-summary-article-number))
8846 ;; First grab the marked article, otherwise one line up.
8847 (parent-article (if (not (null gnus-newsgroup-processable))
8848 (car gnus-newsgroup-processable)
8849 (save-excursion
8850 (if (eq (forward-line -1) 0)
8851 (gnus-summary-article-number)
8852 (error "Beginning of summary buffer"))))))
8853 (unless (not (eq current-article parent-article))
8854 (error "An article may not be self-referential"))
8855 (let ((message-id (mail-header-id
8856 (gnus-summary-article-header parent-article))))
8857 (unless (and message-id (not (equal message-id "")))
8858 (error "No message-id in desired parent"))
8859 (gnus-with-article current-article
8860 (save-restriction
8861 (goto-char (point-min))
8862 (message-narrow-to-head)
8863 (if (re-search-forward "^References: " nil t)
8864 (progn
8865 (re-search-forward "^[^ \t]" nil t)
8866 (forward-line -1)
8867 (end-of-line)
8868 (insert " " message-id))
8869 (insert "References: " message-id "\n"))))
8870 (set-buffer gnus-summary-buffer)
8871 (gnus-summary-unmark-all-processable)
8872 (gnus-summary-update-article current-article)
8873 (gnus-summary-rethread-current)
8874 (gnus-message 3 "Article %d is now the child of article %d"
8875 current-article parent-article)))))
8877 (defun gnus-summary-toggle-threads (&optional arg)
8878 "Toggle showing conversation threads.
8879 If ARG is positive number, turn showing conversation threads on."
8880 (interactive "P")
8881 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8882 (setq gnus-show-threads
8883 (if (null arg) (not gnus-show-threads)
8884 (> (prefix-numeric-value arg) 0)))
8885 (gnus-summary-prepare)
8886 (gnus-summary-goto-subject current)
8887 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8888 (gnus-summary-position-point)))
8890 (defun gnus-summary-show-all-threads ()
8891 "Show all threads."
8892 (interactive)
8893 (save-excursion
8894 (let ((buffer-read-only nil))
8895 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8896 (gnus-summary-position-point))
8898 (defun gnus-summary-show-thread ()
8899 "Show thread subtrees.
8900 Returns nil if no thread was there to be shown."
8901 (interactive)
8902 (let ((buffer-read-only nil)
8903 (orig (point))
8904 ;; first goto end then to beg, to have point at beg after let
8905 (end (progn (end-of-line) (point)))
8906 (beg (progn (beginning-of-line) (point))))
8907 (prog1
8908 ;; Any hidden lines here?
8909 (search-forward "\r" end t)
8910 (subst-char-in-region beg end ?\^M ?\n t)
8911 (goto-char orig)
8912 (gnus-summary-position-point))))
8914 (defun gnus-summary-hide-all-threads ()
8915 "Hide all thread subtrees."
8916 (interactive)
8917 (save-excursion
8918 (goto-char (point-min))
8919 (gnus-summary-hide-thread)
8920 (while (zerop (gnus-summary-next-thread 1 t))
8921 (gnus-summary-hide-thread)))
8922 (gnus-summary-position-point))
8924 (defun gnus-summary-hide-thread ()
8925 "Hide thread subtrees.
8926 Returns nil if no threads were there to be hidden."
8927 (interactive)
8928 (let ((buffer-read-only nil)
8929 (start (point))
8930 (article (gnus-summary-article-number)))
8931 (goto-char start)
8932 ;; Go forward until either the buffer ends or the subthread
8933 ;; ends.
8934 (when (and (not (eobp))
8935 (or (zerop (gnus-summary-next-thread 1 t))
8936 (goto-char (point-max))))
8937 (prog1
8938 (if (and (> (point) start)
8939 (search-backward "\n" start t))
8940 (progn
8941 (subst-char-in-region start (point) ?\n ?\^M)
8942 (gnus-summary-goto-subject article))
8943 (goto-char start)
8944 nil)))))
8946 (defun gnus-summary-go-to-next-thread (&optional previous)
8947 "Go to the same level (or less) next thread.
8948 If PREVIOUS is non-nil, go to previous thread instead.
8949 Return the article number moved to, or nil if moving was impossible."
8950 (let ((level (gnus-summary-thread-level))
8951 (way (if previous -1 1))
8952 (beg (point)))
8953 (forward-line way)
8954 (while (and (not (eobp))
8955 (< level (gnus-summary-thread-level)))
8956 (forward-line way))
8957 (if (eobp)
8958 (progn
8959 (goto-char beg)
8960 nil)
8961 (setq beg (point))
8962 (prog1
8963 (gnus-summary-article-number)
8964 (goto-char beg)))))
8966 (defun gnus-summary-next-thread (n &optional silent)
8967 "Go to the same level next N'th thread.
8968 If N is negative, search backward instead.
8969 Returns the difference between N and the number of skips actually
8970 done.
8972 If SILENT, don't output messages."
8973 (interactive "p")
8974 (let ((backward (< n 0))
8975 (n (abs n)))
8976 (while (and (> n 0)
8977 (gnus-summary-go-to-next-thread backward))
8978 (decf n))
8979 (unless silent
8980 (gnus-summary-position-point))
8981 (when (and (not silent) (/= 0 n))
8982 (gnus-message 7 "No more threads"))
8985 (defun gnus-summary-prev-thread (n)
8986 "Go to the same level previous N'th thread.
8987 Returns the difference between N and the number of skips actually
8988 done."
8989 (interactive "p")
8990 (gnus-summary-next-thread (- n)))
8992 (defun gnus-summary-go-down-thread ()
8993 "Go down one level in the current thread."
8994 (let ((children (gnus-summary-article-children)))
8995 (when children
8996 (gnus-summary-goto-subject (car children)))))
8998 (defun gnus-summary-go-up-thread ()
8999 "Go up one level in the current thread."
9000 (let ((parent (gnus-summary-article-parent)))
9001 (when parent
9002 (gnus-summary-goto-subject parent))))
9004 (defun gnus-summary-down-thread (n)
9005 "Go down thread N steps.
9006 If N is negative, go up instead.
9007 Returns the difference between N and how many steps down that were
9008 taken."
9009 (interactive "p")
9010 (let ((up (< n 0))
9011 (n (abs n)))
9012 (while (and (> n 0)
9013 (if up (gnus-summary-go-up-thread)
9014 (gnus-summary-go-down-thread)))
9015 (setq n (1- n)))
9016 (gnus-summary-position-point)
9017 (when (/= 0 n)
9018 (gnus-message 7 "Can't go further"))
9021 (defun gnus-summary-up-thread (n)
9022 "Go up thread N steps.
9023 If N is negative, go up instead.
9024 Returns the difference between N and how many steps down that were
9025 taken."
9026 (interactive "p")
9027 (gnus-summary-down-thread (- n)))
9029 (defun gnus-summary-top-thread ()
9030 "Go to the top of the thread."
9031 (interactive)
9032 (while (gnus-summary-go-up-thread))
9033 (gnus-summary-article-number))
9035 (defun gnus-summary-kill-thread (&optional unmark)
9036 "Mark articles under current thread as read.
9037 If the prefix argument is positive, remove any kinds of marks.
9038 If the prefix argument is negative, tick articles instead."
9039 (interactive "P")
9040 (when unmark
9041 (setq unmark (prefix-numeric-value unmark)))
9042 (let ((articles (gnus-summary-articles-in-thread)))
9043 (save-excursion
9044 ;; Expand the thread.
9045 (gnus-summary-show-thread)
9046 ;; Mark all the articles.
9047 (while articles
9048 (gnus-summary-goto-subject (car articles))
9049 (cond ((null unmark)
9050 (gnus-summary-mark-article-as-read gnus-killed-mark))
9051 ((> unmark 0)
9052 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9054 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9055 (setq articles (cdr articles))))
9056 ;; Hide killed subtrees.
9057 (and (null unmark)
9058 gnus-thread-hide-killed
9059 (gnus-summary-hide-thread))
9060 ;; If marked as read, go to next unread subject.
9061 (when (null unmark)
9062 ;; Go to next unread subject.
9063 (gnus-summary-next-subject 1 t)))
9064 (gnus-set-mode-line 'summary))
9066 ;; Summary sorting commands
9068 (defun gnus-summary-sort-by-number (&optional reverse)
9069 "Sort the summary buffer by article number.
9070 Argument REVERSE means reverse order."
9071 (interactive "P")
9072 (gnus-summary-sort 'number reverse))
9074 (defun gnus-summary-sort-by-author (&optional reverse)
9075 "Sort the summary buffer by author name alphabetically.
9076 If `case-fold-search' is non-nil, case of letters is ignored.
9077 Argument REVERSE means reverse order."
9078 (interactive "P")
9079 (gnus-summary-sort 'author reverse))
9081 (defun gnus-summary-sort-by-subject (&optional reverse)
9082 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9083 If `case-fold-search' is non-nil, case of letters is ignored.
9084 Argument REVERSE means reverse order."
9085 (interactive "P")
9086 (gnus-summary-sort 'subject reverse))
9088 (defun gnus-summary-sort-by-date (&optional reverse)
9089 "Sort the summary buffer by date.
9090 Argument REVERSE means reverse order."
9091 (interactive "P")
9092 (gnus-summary-sort 'date reverse))
9094 (defun gnus-summary-sort-by-score (&optional reverse)
9095 "Sort the summary buffer by score.
9096 Argument REVERSE means reverse order."
9097 (interactive "P")
9098 (gnus-summary-sort 'score reverse))
9100 (defun gnus-summary-sort-by-lines (&optional reverse)
9101 "Sort the summary buffer by the number of lines.
9102 Argument REVERSE means reverse order."
9103 (interactive "P")
9104 (gnus-summary-sort 'lines reverse))
9106 (defun gnus-summary-sort-by-chars (&optional reverse)
9107 "Sort the summary buffer by article length.
9108 Argument REVERSE means reverse order."
9109 (interactive "P")
9110 (gnus-summary-sort 'chars reverse))
9112 (defun gnus-summary-sort (predicate reverse)
9113 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9114 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9115 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9116 (gnus-thread-sort-functions
9117 (if (not reverse)
9118 thread
9119 `(lambda (t1 t2)
9120 (,thread t2 t1))))
9121 (gnus-sort-gathered-threads-function
9122 gnus-thread-sort-functions)
9123 (gnus-article-sort-functions
9124 (if (not reverse)
9125 article
9126 `(lambda (t1 t2)
9127 (,article t2 t1))))
9128 (buffer-read-only)
9129 (gnus-summary-prepare-hook nil))
9130 ;; We do the sorting by regenerating the threads.
9131 (gnus-summary-prepare)
9132 ;; Hide subthreads if needed.
9133 (when (and gnus-show-threads gnus-thread-hide-subtree)
9134 (gnus-summary-hide-all-threads))))
9136 ;; Summary saving commands.
9138 (defun gnus-summary-save-article (&optional n not-saved)
9139 "Save the current article using the default saver function.
9140 If N is a positive number, save the N next articles.
9141 If N is a negative number, save the N previous articles.
9142 If N is nil and any articles have been marked with the process mark,
9143 save those articles instead.
9144 The variable `gnus-default-article-saver' specifies the saver function."
9145 (interactive "P")
9146 (let* ((articles (gnus-summary-work-articles n))
9147 (save-buffer (save-excursion
9148 (nnheader-set-temp-buffer " *Gnus Save*")))
9149 (num (length articles))
9150 header file)
9151 (dolist (article articles)
9152 (setq header (gnus-summary-article-header article))
9153 (if (not (vectorp header))
9154 ;; This is a pseudo-article.
9155 (if (assq 'name header)
9156 (gnus-copy-file (cdr (assq 'name header)))
9157 (gnus-message 1 "Article %d is unsaveable" article))
9158 ;; This is a real article.
9159 (save-window-excursion
9160 (let ((gnus-display-mime-function nil)
9161 (gnus-article-prepare-hook nil))
9162 (gnus-summary-select-article t nil nil article)))
9163 (save-excursion
9164 (set-buffer save-buffer)
9165 (erase-buffer)
9166 (insert-buffer-substring gnus-original-article-buffer))
9167 (setq file (gnus-article-save save-buffer file num))
9168 (gnus-summary-remove-process-mark article)
9169 (unless not-saved
9170 (gnus-summary-set-saved-mark article))))
9171 (gnus-kill-buffer save-buffer)
9172 (gnus-summary-position-point)
9173 (gnus-set-mode-line 'summary)
9176 (defun gnus-summary-pipe-output (&optional arg)
9177 "Pipe the current article to a subprocess.
9178 If N is a positive number, pipe the N next articles.
9179 If N is a negative number, pipe the N previous articles.
9180 If N is nil and any articles have been marked with the process mark,
9181 pipe those articles instead."
9182 (interactive "P")
9183 (require 'gnus-art)
9184 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9185 (gnus-summary-save-article arg t))
9186 (gnus-configure-windows 'pipe))
9188 (defun gnus-summary-save-article-mail (&optional arg)
9189 "Append the current article to an mail file.
9190 If N is a positive number, save the N next articles.
9191 If N is a negative number, save the N previous articles.
9192 If N is nil and any articles have been marked with the process mark,
9193 save those articles instead."
9194 (interactive "P")
9195 (require 'gnus-art)
9196 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9197 (gnus-summary-save-article arg)))
9199 (defun gnus-summary-save-article-rmail (&optional arg)
9200 "Append the current article to an rmail file.
9201 If N is a positive number, save the N next articles.
9202 If N is a negative number, save the N previous articles.
9203 If N is nil and any articles have been marked with the process mark,
9204 save those articles instead."
9205 (interactive "P")
9206 (require 'gnus-art)
9207 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9208 (gnus-summary-save-article arg)))
9210 (defun gnus-summary-save-article-file (&optional arg)
9211 "Append the current article to a file.
9212 If N is a positive number, save the N next articles.
9213 If N is a negative number, save the N previous articles.
9214 If N is nil and any articles have been marked with the process mark,
9215 save those articles instead."
9216 (interactive "P")
9217 (require 'gnus-art)
9218 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9219 (gnus-summary-save-article arg)))
9221 (defun gnus-summary-write-article-file (&optional arg)
9222 "Write the current article to a file, deleting the previous file.
9223 If N is a positive number, save the N next articles.
9224 If N is a negative number, save the N previous articles.
9225 If N is nil and any articles have been marked with the process mark,
9226 save those articles instead."
9227 (interactive "P")
9228 (require 'gnus-art)
9229 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9230 (gnus-summary-save-article arg)))
9232 (defun gnus-summary-save-article-body-file (&optional arg)
9233 "Append the current article body to a file.
9234 If N is a positive number, save the N next articles.
9235 If N is a negative number, save the N previous articles.
9236 If N is nil and any articles have been marked with the process mark,
9237 save those articles instead."
9238 (interactive "P")
9239 (require 'gnus-art)
9240 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9241 (gnus-summary-save-article arg)))
9243 (defun gnus-summary-pipe-message (program)
9244 "Pipe the current article through PROGRAM."
9245 (interactive "sProgram: ")
9246 (gnus-summary-select-article)
9247 (let ((mail-header-separator ""))
9248 (gnus-eval-in-buffer-window gnus-article-buffer
9249 (save-restriction
9250 (widen)
9251 (let ((start (window-start))
9252 buffer-read-only)
9253 (message-pipe-buffer-body program)
9254 (set-window-start (get-buffer-window (current-buffer)) start))))))
9256 (defun gnus-get-split-value (methods)
9257 "Return a value based on the split METHODS."
9258 (let (split-name method result match)
9259 (when methods
9260 (save-excursion
9261 (set-buffer gnus-original-article-buffer)
9262 (save-restriction
9263 (nnheader-narrow-to-headers)
9264 (while (and methods (not split-name))
9265 (goto-char (point-min))
9266 (setq method (pop methods))
9267 (setq match (car method))
9268 (when (cond
9269 ((stringp match)
9270 ;; Regular expression.
9271 (ignore-errors
9272 (re-search-forward match nil t)))
9273 ((gnus-functionp match)
9274 ;; Function.
9275 (save-restriction
9276 (widen)
9277 (setq result (funcall match gnus-newsgroup-name))))
9278 ((consp match)
9279 ;; Form.
9280 (save-restriction
9281 (widen)
9282 (setq result (eval match)))))
9283 (setq split-name (cdr method))
9284 (cond ((stringp result)
9285 (push (expand-file-name
9286 result gnus-article-save-directory)
9287 split-name))
9288 ((consp result)
9289 (setq split-name (append result split-name)))))))))
9290 (nreverse split-name)))
9292 (defun gnus-valid-move-group-p (group)
9293 (and (boundp group)
9294 (symbol-name group)
9295 (symbol-value group)
9296 (gnus-get-function (gnus-find-method-for-group
9297 (symbol-name group)) 'request-accept-article t)))
9299 (defun gnus-read-move-group-name (prompt default articles prefix)
9300 "Read a group name."
9301 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9302 (minibuffer-confirm-incomplete nil) ; XEmacs
9303 (prom
9304 (format "%s %s to:"
9305 prompt
9306 (if (> (length articles) 1)
9307 (format "these %d articles" (length articles))
9308 "this article")))
9309 (to-newsgroup
9310 (cond
9311 ((null split-name)
9312 (gnus-completing-read default prom
9313 gnus-active-hashtb
9314 'gnus-valid-move-group-p
9315 nil prefix
9316 'gnus-group-history))
9317 ((= 1 (length split-name))
9318 (gnus-completing-read (car split-name) prom
9319 gnus-active-hashtb
9320 'gnus-valid-move-group-p
9321 nil nil
9322 'gnus-group-history))
9324 (gnus-completing-read nil prom
9325 (mapcar (lambda (el) (list el))
9326 (nreverse split-name))
9327 nil nil nil
9328 'gnus-group-history))))
9329 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9330 (when to-newsgroup
9331 (if (or (string= to-newsgroup "")
9332 (string= to-newsgroup prefix))
9333 (setq to-newsgroup default))
9334 (unless to-newsgroup
9335 (error "No group name entered"))
9336 (or (gnus-active to-newsgroup)
9337 (gnus-activate-group to-newsgroup nil nil to-method)
9338 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9339 to-newsgroup))
9340 (or (and (gnus-request-create-group to-newsgroup to-method)
9341 (gnus-activate-group
9342 to-newsgroup nil nil to-method)
9343 (gnus-subscribe-group to-newsgroup))
9344 (error "Couldn't create group %s" to-newsgroup)))
9345 (error "No such group: %s" to-newsgroup)))
9346 to-newsgroup))
9348 (defun gnus-summary-save-parts (type dir n &optional reverse)
9349 "Save parts matching TYPE to DIR.
9350 If REVERSE, save parts that do not match TYPE."
9351 (interactive
9352 (list (read-string "Save parts of type: "
9353 (or (car gnus-summary-save-parts-type-history)
9354 gnus-summary-save-parts-default-mime)
9355 'gnus-summary-save-parts-type-history)
9356 (setq gnus-summary-save-parts-last-directory
9357 (read-file-name "Save to directory: "
9358 gnus-summary-save-parts-last-directory
9359 nil t))
9360 current-prefix-arg))
9361 (gnus-summary-iterate n
9362 (let ((gnus-display-mime-function nil)
9363 (gnus-inhibit-treatment t))
9364 (gnus-summary-select-article))
9365 (save-excursion
9366 (set-buffer gnus-article-buffer)
9367 (let ((handles (or gnus-article-mime-handles
9368 (mm-dissect-buffer) (mm-uu-dissect))))
9369 (when handles
9370 (gnus-summary-save-parts-1 type dir handles reverse)
9371 (unless gnus-article-mime-handles ;; Don't destroy this case.
9372 (mm-destroy-parts handles)))))))
9374 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9375 (if (stringp (car handle))
9376 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9377 (cdr handle))
9378 (when (if reverse
9379 (not (string-match type (mm-handle-media-type handle)))
9380 (string-match type (mm-handle-media-type handle)))
9381 (let ((file (expand-file-name
9382 (file-name-nondirectory
9384 (mail-content-type-get
9385 (mm-handle-disposition handle) 'filename)
9386 (concat gnus-newsgroup-name
9387 "." (number-to-string
9388 (cdr gnus-article-current)))))
9389 dir)))
9390 (unless (file-exists-p file)
9391 (mm-save-part-to-file handle file))))))
9393 ;; Summary extract commands
9395 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9396 (let ((buffer-read-only nil)
9397 (article (gnus-summary-article-number))
9398 after-article b e)
9399 (unless (gnus-summary-goto-subject article)
9400 (error "No such article: %d" article))
9401 (gnus-summary-position-point)
9402 ;; If all commands are to be bunched up on one line, we collect
9403 ;; them here.
9404 (unless gnus-view-pseudos-separately
9405 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9406 files action)
9407 (while ps
9408 (setq action (cdr (assq 'action (car ps))))
9409 (setq files (list (cdr (assq 'name (car ps)))))
9410 (while (and ps (cdr ps)
9411 (string= (or action "1")
9412 (or (cdr (assq 'action (cadr ps))) "2")))
9413 (push (cdr (assq 'name (cadr ps))) files)
9414 (setcdr ps (cddr ps)))
9415 (when files
9416 (when (not (string-match "%s" action))
9417 (push " " files))
9418 (push " " files)
9419 (when (assq 'execute (car ps))
9420 (setcdr (assq 'execute (car ps))
9421 (funcall (if (string-match "%s" action)
9422 'format 'concat)
9423 action
9424 (mapconcat
9425 (lambda (f)
9426 (if (equal f " ")
9428 (mm-quote-arg f)))
9429 files " ")))))
9430 (setq ps (cdr ps)))))
9431 (if (and gnus-view-pseudos (not not-view))
9432 (while pslist
9433 (when (assq 'execute (car pslist))
9434 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9435 (eq gnus-view-pseudos 'not-confirm)))
9436 (setq pslist (cdr pslist)))
9437 (save-excursion
9438 (while pslist
9439 (setq after-article (or (cdr (assq 'article (car pslist)))
9440 (gnus-summary-article-number)))
9441 (gnus-summary-goto-subject after-article)
9442 (forward-line 1)
9443 (setq b (point))
9444 (insert " " (file-name-nondirectory
9445 (cdr (assq 'name (car pslist))))
9446 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9447 (setq e (point))
9448 (forward-line -1) ; back to `b'
9449 (gnus-add-text-properties
9450 b (1- e) (list 'gnus-number gnus-reffed-article-number
9451 gnus-mouse-face-prop gnus-mouse-face))
9452 (gnus-data-enter
9453 after-article gnus-reffed-article-number
9454 gnus-unread-mark b (car pslist) 0 (- e b))
9455 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9456 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9457 (setq pslist (cdr pslist)))))))
9459 (defun gnus-pseudos< (p1 p2)
9460 (let ((c1 (cdr (assq 'action p1)))
9461 (c2 (cdr (assq 'action p2))))
9462 (and c1 c2 (string< c1 c2))))
9464 (defun gnus-request-pseudo-article (props)
9465 (cond ((assq 'execute props)
9466 (gnus-execute-command (cdr (assq 'execute props)))))
9467 (let ((gnus-current-article (gnus-summary-article-number)))
9468 (gnus-run-hooks 'gnus-mark-article-hook)))
9470 (defun gnus-execute-command (command &optional automatic)
9471 (save-excursion
9472 (gnus-article-setup-buffer)
9473 (set-buffer gnus-article-buffer)
9474 (setq buffer-read-only nil)
9475 (let ((command (if automatic command
9476 (read-string "Command: " (cons command 0)))))
9477 (erase-buffer)
9478 (insert "$ " command "\n\n")
9479 (if gnus-view-pseudo-asynchronously
9480 (start-process "gnus-execute" (current-buffer) shell-file-name
9481 shell-command-switch command)
9482 (call-process shell-file-name nil t nil
9483 shell-command-switch command)))))
9485 ;; Summary kill commands.
9487 (defun gnus-summary-edit-global-kill (article)
9488 "Edit the \"global\" kill file."
9489 (interactive (list (gnus-summary-article-number)))
9490 (gnus-group-edit-global-kill article))
9492 (defun gnus-summary-edit-local-kill ()
9493 "Edit a local kill file applied to the current newsgroup."
9494 (interactive)
9495 (setq gnus-current-headers (gnus-summary-article-header))
9496 (gnus-group-edit-local-kill
9497 (gnus-summary-article-number) gnus-newsgroup-name))
9499 ;;; Header reading.
9501 (defun gnus-read-header (id &optional header)
9502 "Read the headers of article ID and enter them into the Gnus system."
9503 (let ((group gnus-newsgroup-name)
9504 (gnus-override-method
9506 gnus-override-method
9507 (and (gnus-news-group-p gnus-newsgroup-name)
9508 (car (gnus-refer-article-methods)))))
9509 where)
9510 ;; First we check to see whether the header in question is already
9511 ;; fetched.
9512 (if (stringp id)
9513 ;; This is a Message-ID.
9514 (setq header (or header (gnus-id-to-header id)))
9515 ;; This is an article number.
9516 (setq header (or header (gnus-summary-article-header id))))
9517 (if (and header
9518 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9519 ;; We have found the header.
9520 header
9521 ;; If this is a sparse article, we have to nix out its
9522 ;; previous entry in the thread hashtb.
9523 (when (and header
9524 (gnus-summary-article-sparse-p (mail-header-number header)))
9525 (let* ((parent (gnus-parent-id (mail-header-references header)))
9526 (thread (and parent (gnus-id-to-thread parent))))
9527 (when thread
9528 (delq (assq header thread) thread))))
9529 ;; We have to really fetch the header to this article.
9530 (save-excursion
9531 (set-buffer nntp-server-buffer)
9532 (when (setq where (gnus-request-head id group))
9533 (nnheader-fold-continuation-lines)
9534 (goto-char (point-max))
9535 (insert ".\n")
9536 (goto-char (point-min))
9537 (insert "211 ")
9538 (princ (cond
9539 ((numberp id) id)
9540 ((cdr where) (cdr where))
9541 (header (mail-header-number header))
9542 (t gnus-reffed-article-number))
9543 (current-buffer))
9544 (insert " Article retrieved.\n"))
9545 (if (or (not where)
9546 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9547 () ; Malformed head.
9548 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9549 (when (and (stringp id)
9550 (not (string= (gnus-group-real-name group)
9551 (car where))))
9552 ;; If we fetched by Message-ID and the article came
9553 ;; from a different group, we fudge some bogus article
9554 ;; numbers for this article.
9555 (mail-header-set-number header gnus-reffed-article-number))
9556 (save-excursion
9557 (set-buffer gnus-summary-buffer)
9558 (decf gnus-reffed-article-number)
9559 (gnus-remove-header (mail-header-number header))
9560 (push header gnus-newsgroup-headers)
9561 (setq gnus-current-headers header)
9562 (push (mail-header-number header) gnus-newsgroup-limit)))
9563 header)))))
9565 (defun gnus-remove-header (number)
9566 "Remove header NUMBER from `gnus-newsgroup-headers'."
9567 (if (and gnus-newsgroup-headers
9568 (= number (mail-header-number (car gnus-newsgroup-headers))))
9569 (pop gnus-newsgroup-headers)
9570 (let ((headers gnus-newsgroup-headers))
9571 (while (and (cdr headers)
9572 (not (= number (mail-header-number (cadr headers)))))
9573 (pop headers))
9574 (when (cdr headers)
9575 (setcdr headers (cddr headers))))))
9578 ;;; summary highlights
9581 (defun gnus-highlight-selected-summary ()
9582 "Highlight selected article in summary buffer."
9583 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9584 (when gnus-summary-selected-face
9585 (save-excursion
9586 (let* ((beg (progn (beginning-of-line) (point)))
9587 (end (progn (end-of-line) (point)))
9588 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9589 (from (if (get-text-property beg gnus-mouse-face-prop)
9591 (or (next-single-property-change
9592 beg gnus-mouse-face-prop nil end)
9593 beg)))
9595 (if (= from end)
9596 (- from 2)
9597 (or (next-single-property-change
9598 from gnus-mouse-face-prop nil end)
9599 end))))
9600 ;; If no mouse-face prop on line we will have to = from = end,
9601 ;; so we highlight the entire line instead.
9602 (when (= (+ to 2) from)
9603 (setq from beg)
9604 (setq to end))
9605 (if gnus-newsgroup-selected-overlay
9606 ;; Move old overlay.
9607 (gnus-move-overlay
9608 gnus-newsgroup-selected-overlay from to (current-buffer))
9609 ;; Create new overlay.
9610 (gnus-overlay-put
9611 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9612 'face gnus-summary-selected-face))))))
9614 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9615 (defun gnus-summary-highlight-line ()
9616 "Highlight current line according to `gnus-summary-highlight'."
9617 (let* ((list gnus-summary-highlight)
9618 (p (point))
9619 (end (progn (end-of-line) (point)))
9620 ;; now find out where the line starts and leave point there.
9621 (beg (progn (beginning-of-line) (point)))
9622 (article (gnus-summary-article-number))
9623 (score (or (cdr (assq (or article gnus-current-article)
9624 gnus-newsgroup-scored))
9625 gnus-summary-default-score 0))
9626 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9627 (inhibit-read-only t))
9628 ;; Eval the cars of the lists until we find a match.
9629 (let ((default gnus-summary-default-score))
9630 (while (and list
9631 (not (eval (caar list))))
9632 (setq list (cdr list))))
9633 (let ((face (cdar list)))
9634 (unless (eq face (get-text-property beg 'face))
9635 (gnus-put-text-property-excluding-characters-with-faces
9636 beg end 'face
9637 (setq face (if (boundp face) (symbol-value face) face)))
9638 (when gnus-summary-highlight-line-function
9639 (funcall gnus-summary-highlight-line-function article face))))
9640 (goto-char p)))
9642 (defun gnus-update-read-articles (group unread &optional compute)
9643 "Update the list of read articles in GROUP."
9644 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9645 (entry (gnus-gethash group gnus-newsrc-hashtb))
9646 (info (nth 2 entry))
9647 (prev 1)
9648 (unread (sort (copy-sequence unread) '<))
9649 read)
9650 (if (or (not info) (not active))
9651 ;; There is no info on this group if it was, in fact,
9652 ;; killed. Gnus stores no information on killed groups, so
9653 ;; there's nothing to be done.
9654 ;; One could store the information somewhere temporarily,
9655 ;; perhaps... Hmmm...
9657 ;; Remove any negative articles numbers.
9658 (while (and unread (< (car unread) 0))
9659 (setq unread (cdr unread)))
9660 ;; Remove any expired article numbers
9661 (while (and unread (< (car unread) (car active)))
9662 (setq unread (cdr unread)))
9663 ;; Compute the ranges of read articles by looking at the list of
9664 ;; unread articles.
9665 (while unread
9666 (when (/= (car unread) prev)
9667 (push (if (= prev (1- (car unread))) prev
9668 (cons prev (1- (car unread))))
9669 read))
9670 (setq prev (1+ (car unread)))
9671 (setq unread (cdr unread)))
9672 (when (<= prev (cdr active))
9673 (push (cons prev (cdr active)) read))
9674 (setq read (if (> (length read) 1) (nreverse read) read))
9675 (if compute
9676 read
9677 (save-excursion
9678 (let (setmarkundo)
9679 ;; Propagate the read marks to the backend.
9680 (when (gnus-check-backend-function 'request-set-mark group)
9681 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9682 (add (gnus-remove-from-range read (gnus-info-read info))))
9683 (when (or add del)
9684 (unless (gnus-check-group group)
9685 (error "Can't open server for %s" group))
9686 (gnus-request-set-mark
9687 group (delq nil (list (if add (list add 'add '(read)))
9688 (if del (list del 'del '(read))))))
9689 (setq setmarkundo
9690 `(gnus-request-set-mark
9691 ,group
9692 ',(delq nil (list
9693 (if del (list del 'add '(read)))
9694 (if add (list add 'del '(read))))))))))
9695 (set-buffer gnus-group-buffer)
9696 (gnus-undo-register
9697 `(progn
9698 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9699 (gnus-info-set-read ',info ',(gnus-info-read info))
9700 (gnus-get-unread-articles-in-group ',info
9701 (gnus-active ,group))
9702 (gnus-group-update-group ,group t)
9703 ,setmarkundo))))
9704 ;; Enter this list into the group info.
9705 (gnus-info-set-read info read)
9706 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9707 (gnus-get-unread-articles-in-group info (gnus-active group))
9708 t))))
9710 (defun gnus-offer-save-summaries ()
9711 "Offer to save all active summary buffers."
9712 (save-excursion
9713 (let ((buflist (buffer-list))
9714 buffers bufname)
9715 ;; Go through all buffers and find all summaries.
9716 (while buflist
9717 (and (setq bufname (buffer-name (car buflist)))
9718 (string-match "Summary" bufname)
9719 (save-excursion
9720 (set-buffer bufname)
9721 ;; We check that this is, indeed, a summary buffer.
9722 (and (eq major-mode 'gnus-summary-mode)
9723 ;; Also make sure this isn't bogus.
9724 gnus-newsgroup-prepared
9725 ;; Also make sure that this isn't a dead summary buffer.
9726 (not gnus-dead-summary-mode)))
9727 (push bufname buffers))
9728 (setq buflist (cdr buflist)))
9729 ;; Go through all these summary buffers and offer to save them.
9730 (when buffers
9731 (map-y-or-n-p
9732 "Update summary buffer %s? "
9733 (lambda (buf)
9734 (switch-to-buffer buf)
9735 (gnus-summary-exit))
9736 buffers)))))
9738 (defun gnus-summary-setup-default-charset ()
9739 "Setup newsgroup default charset."
9740 (if (equal gnus-newsgroup-name "nndraft:drafts")
9741 (setq gnus-newsgroup-charset nil)
9742 (let* ((name (and gnus-newsgroup-name
9743 (gnus-group-real-name gnus-newsgroup-name)))
9744 (ignored-charsets
9745 (or gnus-newsgroup-ephemeral-ignored-charsets
9746 (append
9747 (and gnus-newsgroup-name
9748 (or (gnus-group-find-parameter gnus-newsgroup-name
9749 'ignored-charsets t)
9750 (let ((alist gnus-group-ignored-charsets-alist)
9751 elem (charsets nil))
9752 (while (setq elem (pop alist))
9753 (when (and name
9754 (string-match (car elem) name))
9755 (setq alist nil
9756 charsets (cdr elem))))
9757 charsets)))
9758 gnus-newsgroup-ignored-charsets))))
9759 (setq gnus-newsgroup-charset
9760 (or gnus-newsgroup-ephemeral-charset
9761 (and gnus-newsgroup-name
9762 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9763 (let ((alist gnus-group-charset-alist)
9764 elem charset)
9765 (while (setq elem (pop alist))
9766 (when (and name
9767 (string-match (car elem) name))
9768 (setq alist nil
9769 charset (cadr elem))))
9770 charset)))
9771 gnus-default-charset))
9772 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9773 ignored-charsets))))
9776 ;;; Mime Commands
9779 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9780 "Display the current article buffer fully MIME-buttonized.
9781 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9782 treated as multipart/mixed."
9783 (interactive "P")
9784 (require 'gnus-art)
9785 (let ((gnus-unbuttonized-mime-types nil)
9786 (gnus-mime-display-multipart-as-mixed show-all-parts))
9787 (gnus-summary-show-article)))
9789 (defun gnus-summary-repair-multipart (article)
9790 "Add a Content-Type header to a multipart article without one."
9791 (interactive (list (gnus-summary-article-number)))
9792 (gnus-with-article article
9793 (message-narrow-to-head)
9794 (goto-char (point-max))
9795 (widen)
9796 (when (search-forward "\n--" nil t)
9797 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9798 (message-narrow-to-head)
9799 (message-remove-header "Mime-Version")
9800 (message-remove-header "Content-Type")
9801 (goto-char (point-max))
9802 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9803 separator))
9804 (insert "Mime-Version: 1.0\n")
9805 (widen))))
9806 (let (gnus-mark-article-hook)
9807 (gnus-summary-select-article t t nil article)))
9809 (defun gnus-summary-toggle-display-buttonized ()
9810 "Toggle the buttonizing of the article buffer."
9811 (interactive)
9812 (require 'gnus-art)
9813 (if (setq gnus-inhibit-mime-unbuttonizing
9814 (not gnus-inhibit-mime-unbuttonizing))
9815 (let ((gnus-unbuttonized-mime-types nil))
9816 (gnus-summary-show-article))
9817 (gnus-summary-show-article)))
9820 ;;; Generic summary marking commands
9823 (defvar gnus-summary-marking-alist
9824 '((read gnus-del-mark "d")
9825 (unread gnus-unread-mark "u")
9826 (ticked gnus-ticked-mark "!")
9827 (dormant gnus-dormant-mark "?")
9828 (expirable gnus-expirable-mark "e"))
9829 "An alist of names/marks/keystrokes.")
9831 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9832 (defvar gnus-summary-mark-map)
9834 (defun gnus-summary-make-all-marking-commands ()
9835 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9836 (dolist (elem gnus-summary-marking-alist)
9837 (apply 'gnus-summary-make-marking-command elem)))
9839 (defun gnus-summary-make-marking-command (name mark keystroke)
9840 (let ((map (make-sparse-keymap)))
9841 (define-key gnus-summary-generic-mark-map keystroke map)
9842 (dolist (lway `((next "next" next nil "n")
9843 (next-unread "next unread" next t "N")
9844 (prev "previous" prev nil "p")
9845 (prev-unread "previous unread" prev t "P")
9846 (nomove "" nil nil ,keystroke)))
9847 (let ((func (gnus-summary-make-marking-command-1
9848 mark (car lway) lway name)))
9849 (setq func (eval func))
9850 (define-key map (nth 4 lway) func)))))
9852 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9853 `(defun ,(intern
9854 (format "gnus-summary-put-mark-as-%s%s"
9855 name (if (eq way 'nomove)
9857 (concat "-" (symbol-name way)))))
9859 ,(format
9860 "Mark the current article as %s%s.
9861 If N, the prefix, then repeat N times.
9862 If N is negative, move in reverse order.
9863 The difference between N and the actual number of articles marked is
9864 returned."
9865 name (cadr lway))
9866 (interactive "p")
9867 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9869 (defun gnus-summary-generic-mark (n mark move unread)
9870 "Mark N articles with MARK."
9871 (unless (eq major-mode 'gnus-summary-mode)
9872 (error "This command can only be used in the summary buffer"))
9873 (gnus-summary-show-thread)
9874 (let ((nummove
9875 (cond
9876 ((eq move 'next) 1)
9877 ((eq move 'prev) -1)
9878 (t 0))))
9879 (if (zerop nummove)
9880 (setq n 1)
9881 (when (< n 0)
9882 (setq n (abs n)
9883 nummove (* -1 nummove))))
9884 (while (and (> n 0)
9885 (gnus-summary-mark-article nil mark)
9886 (zerop (gnus-summary-next-subject nummove unread t)))
9887 (setq n (1- n)))
9888 (when (/= 0 n)
9889 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9890 (gnus-summary-recenter)
9891 (gnus-summary-position-point)
9892 (gnus-set-mode-line 'summary)
9895 (gnus-summary-make-all-marking-commands)
9897 (gnus-ems-redefine)
9899 (provide 'gnus-sum)
9901 (run-hooks 'gnus-sum-load-hook)
9903 ;;; gnus-sum.el ends here