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>
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)
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.
29 (eval-when-compile (require 'cl))
40 ;; (require 'gnus-art)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
45 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
46 (autoload 'mm-uu-dissect "mm-uu")
48 (defcustom gnus-kill-summary-on-exit t
49 "*If non-nil, kill the summary buffer when you exit from it.
50 If nil, the summary will become a \"*Dead Summary*\" buffer, and
51 it will be killed sometime later."
52 :group 'gnus-summary-exit
55 (defcustom gnus-fetch-old-headers nil
56 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
57 If an unread article in the group refers to an older, already read (or
58 just marked as read) article, the old article will not normally be
59 displayed in the Summary buffer. If this variable is non-nil, Gnus
60 will attempt to grab the headers to the old articles, and thereby
61 build complete threads. If it has the value `some', only enough
62 headers to connect otherwise loose threads will be displayed. This
63 variable can also be a number. In that case, no more than that number
64 of old headers will be fetched. If it has the value `invisible', all
65 old headers will be fetched, but none will be displayed.
67 The server has to support NOV for any of this to work."
69 :type '(choice (const :tag "off" nil)
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-refer-thread-limit 200
75 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
76 If t, fetch all the available old headers."
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-summary-make-false-root 'adopt
82 "*nil means that Gnus won't gather loose threads.
83 If the root of a thread has expired or been read in a previous
84 session, the information necessary to build a complete thread has been
85 lost. Instead of having many small sub-threads from this original thread
86 scattered all over the summary buffer, Gnus can gather them.
88 If non-nil, Gnus will try to gather all loose sub-threads from an
89 original thread into one large thread.
91 If this variable is non-nil, it should be one of `none', `adopt',
94 If this variable is `none', Gnus will not make a false root, but just
95 present the sub-threads after another.
96 If this variable is `dummy', Gnus will create a dummy root that will
97 have all the sub-threads as children.
98 If this variable is `adopt', Gnus will make one of the \"children\"
99 the parent and mark all the step-children as such.
100 If this variable is `empty', the \"children\" are printed with empty
101 subject fields. (Or rather, they will be printed with a string
102 given by the `gnus-summary-same-subject' variable.)"
104 :type '(choice (const :tag "off" nil)
110 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
111 "*A regexp to match subjects to be excluded from loose thread gathering.
112 As loose thread gathering is done on subjects only, that means that
113 there can be many false gatherings performed. By rooting out certain
114 common subjects, gathering might become saner."
118 (defcustom gnus-summary-gather-subject-limit nil
119 "*Maximum length of subject comparisons when gathering loose threads.
120 Use nil to compare full subjects. Setting this variable to a low
121 number will help gather threads that have been corrupted by
122 newsreaders chopping off subject lines, but it might also mean that
123 unrelated articles that have subject that happen to begin with the
124 same few characters will be incorrectly gathered.
126 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
129 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "on" t)))
133 (defcustom gnus-simplify-subject-functions nil
134 "List of functions taking a string argument that simplify subjects.
135 The functions are applied recursively.
137 Useful functions to put in this list include: `gnus-simplify-subject-re',
138 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
140 :type '(repeat function))
142 (defcustom gnus-simplify-ignored-prefixes nil
143 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
145 :type '(choice (const :tag "off" nil)
148 (defcustom gnus-build-sparse-threads nil
149 "*If non-nil, fill in the gaps in threads.
150 If `some', only fill in the gaps that are needed to tie loose threads
151 together. If `more', fill in all leaf nodes that Gnus can find. If
152 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
154 :type '(choice (const :tag "off" nil)
157 (sexp :menu-tag "all" t)))
159 (defcustom gnus-summary-thread-gathering-function
160 'gnus-gather-threads-by-subject
161 "*Function used for gathering loose threads.
162 There are two pre-defined functions: `gnus-gather-threads-by-subject',
163 which only takes Subjects into consideration; and
164 `gnus-gather-threads-by-references', which compared the References
165 headers of the articles to find matches."
167 :type '(radio (function-item gnus-gather-threads-by-subject)
168 (function-item gnus-gather-threads-by-references)
169 (function :tag "other")))
171 (defcustom gnus-summary-same-subject ""
172 "*String indicating that the current article has the same subject as the previous.
173 This variable will only be used if the value of
174 `gnus-summary-make-false-root' is `empty'."
175 :group 'gnus-summary-format
178 (defcustom gnus-summary-goto-unread t
179 "*If t, many commands will go to the next unread article.
180 This applies to marking commands as well as other commands that
181 \"naturally\" select the next article, like, for instance, `SPC' at
182 the end of an article.
184 If nil, the marking commands do NOT go to the next unread article
185 (they go to the next article instead). If `never', commands that
186 usually go to the next unread article, will go to the next article,
187 whether it is read or not."
188 :group 'gnus-summary-marks
189 :link '(custom-manual "(gnus)Setting Marks")
190 :type '(choice (const :tag "off" nil)
192 (sexp :menu-tag "on" t)))
194 (defcustom gnus-summary-default-score 0
195 "*Default article score level.
196 All scores generated by the score files will be added to this score.
197 If this variable is nil, scoring will be disabled."
198 :group 'gnus-score-default
199 :type '(choice (const :tag "disable")
202 (defcustom gnus-summary-default-high-score 0
203 "*Default threshold for a high scored article.
204 An article will be highlighted as high scored if its score is greater
206 :group 'gnus-score-default
209 (defcustom gnus-summary-default-low-score 0
210 "*Default threshold for a low scored article.
211 An article will be highlighted as low scored if its score is smaller
213 :group 'gnus-score-default
216 (defcustom gnus-summary-zcore-fuzz 0
217 "*Fuzziness factor for the zcore in the summary buffer.
218 Articles with scores closer than this to `gnus-summary-default-score'
220 :group 'gnus-summary-format
223 (defcustom gnus-simplify-subject-fuzzy-regexp nil
224 "*Strings to be removed when doing fuzzy matches.
225 This can either be a regular expression or list of regular expressions
226 that will be removed from subject strings if fuzzy subject
227 simplification is selected."
229 :type '(repeat regexp))
231 (defcustom gnus-show-threads t
232 "*If non-nil, display threads in summary mode."
236 (defcustom gnus-thread-hide-subtree nil
237 "*If non-nil, hide all threads initially.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If nil, don't select the first unread article when entering a group.
282 If this variable is `best', select the highest-scored unread article
283 in the group. If t, select the first unread article.
285 This variable can also be a function to place point on a likely
286 subject line. Useful values include `gnus-summary-first-unread-subject',
287 `gnus-summary-first-unread-article' and
288 `gnus-summary-best-unread-article'.
290 If you want to prevent automatic selection of the first unread article
291 in some newsgroups, set the variable to nil in
292 `gnus-select-group-hook'."
293 :group 'gnus-group-select
294 :type '(choice (const :tag "none" nil)
296 (sexp :menu-tag "first" t)
297 (function-item gnus-summary-first-unread-subject)
298 (function-item gnus-summary-first-unread-article)
299 (function-item gnus-summary-best-unread-article)))
301 (defcustom gnus-auto-select-next t
302 "*If non-nil, offer to go to the next group from the end of the previous.
303 If the value is t and the next newsgroup is empty, Gnus will exit
304 summary mode and go back to group mode. If the value is neither nil
305 nor t, Gnus will select the following unread newsgroup. In
306 particular, if the value is the symbol `quietly', the next unread
307 newsgroup will be selected without any confirmation, and if it is
308 `almost-quietly', the next group will be selected without any
309 confirmation if you are located on the last article in the group.
310 Finally, if this variable is `slightly-quietly', the `Z n' command
311 will go to the next group without confirmation."
312 :group 'gnus-summary-maneuvering
313 :type '(choice (const :tag "off" nil)
315 (const almost-quietly)
316 (const slightly-quietly)
317 (sexp :menu-tag "on" t)))
319 (defcustom gnus-auto-select-same nil
320 "*If non-nil, select the next article with the same subject.
321 If there are no more articles with the same subject, go to
322 the first unread article."
323 :group 'gnus-summary-maneuvering
326 (defcustom gnus-summary-check-current nil
327 "*If non-nil, consider the current article when moving.
328 The \"unread\" movement commands will stay on the same line if the
329 current article is unread."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-auto-center-summary t
334 "*If non-nil, always center the current summary buffer.
335 In particular, if `vertical' do only vertical recentering. If non-nil
336 and non-`vertical', do both horizontal and vertical recentering."
337 :group 'gnus-summary-maneuvering
338 :type '(choice (const :tag "none" nil)
340 (integer :tag "height")
341 (sexp :menu-tag "both" t)))
343 (defcustom gnus-show-all-headers nil
344 "*If non-nil, don't hide any headers."
345 :group 'gnus-article-hiding
346 :group 'gnus-article-headers
349 (defcustom gnus-summary-ignore-duplicates nil
350 "*If non-nil, ignore articles with identical Message-ID headers."
354 (defcustom gnus-single-article-buffer t
355 "*If non-nil, display all articles in the same buffer.
356 If nil, each group will get its own article buffer."
357 :group 'gnus-article-various
360 (defcustom gnus-break-pages t
361 "*If non-nil, do page breaking on articles.
362 The page delimiter is specified by the `gnus-page-delimiter'
364 :group 'gnus-article-various
367 (defcustom gnus-move-split-methods nil
368 "*Variable used to suggest where articles are to be moved to.
369 It uses the same syntax as the `gnus-split-methods' variable.
370 However, whereas `gnus-split-methods' specifies file names as targets,
371 this variable specifies group names."
372 :group 'gnus-summary-mail
373 :type '(repeat (choice (list :value (fun) function)
374 (cons :value ("" "") regexp (repeat string))
377 (defcustom gnus-unread-mark ? ;Whitespace
378 "*Mark used for unread articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-ticked-mark ?!
383 "*Mark used for ticked articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-dormant-mark ??
388 "*Mark used for dormant articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-del-mark ?r
393 "*Mark used for del'd articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-read-mark ?R
398 "*Mark used for read articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-expirable-mark ?E
403 "*Mark used for expirable articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-killed-mark ?K
408 "*Mark used for killed articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-souped-mark ?F
413 "*Mark used for souped articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-kill-file-mark ?X
418 "*Mark used for articles killed by kill files."
419 :group 'gnus-summary-marks
422 (defcustom gnus-low-score-mark ?Y
423 "*Mark used for articles with a low score."
424 :group 'gnus-summary-marks
427 (defcustom gnus-catchup-mark ?C
428 "*Mark used for articles that are caught up."
429 :group 'gnus-summary-marks
432 (defcustom gnus-replied-mark ?A
433 "*Mark used for articles that have been replied to."
434 :group 'gnus-summary-marks
437 (defcustom gnus-forwarded-mark ?F
438 "*Mark used for articles that have been forwarded."
439 :group 'gnus-summary-marks
442 (defcustom gnus-recent-mark ?N
443 "*Mark used for articles that are recent."
444 :group 'gnus-summary-marks
447 (defcustom gnus-cached-mark ?*
448 "*Mark used for articles that are in the cache."
449 :group 'gnus-summary-marks
452 (defcustom gnus-saved-mark ?S
453 "*Mark used for articles that have been saved."
454 :group 'gnus-summary-marks
457 (defcustom gnus-unseen-mark ?.
458 "*Mark used for articles that haven't been seen."
459 :group 'gnus-summary-marks
462 (defcustom gnus-no-mark ? ;Whitespace
463 "*Mark used for articles that have no other secondary mark."
464 :group 'gnus-summary-marks
467 (defcustom gnus-ancient-mark ?O
468 "*Mark used for ancient articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-sparse-mark ?Q
473 "*Mark used for sparsely reffed articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-canceled-mark ?G
478 "*Mark used for canceled articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-duplicate-mark ?M
483 "*Mark used for duplicate articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-undownloaded-mark ?@
488 "*Mark used for articles that weren't downloaded."
489 :group 'gnus-summary-marks
492 (defcustom gnus-downloadable-mark ?%
493 "*Mark used for articles that are to be downloaded."
494 :group 'gnus-summary-marks
497 (defcustom gnus-unsendable-mark ?=
498 "*Mark used for articles that won't be sent."
499 :group 'gnus-summary-marks
502 (defcustom gnus-score-over-mark ?+
503 "*Score mark used for articles with high scores."
504 :group 'gnus-summary-marks
507 (defcustom gnus-score-below-mark ?-
508 "*Score mark used for articles with low scores."
509 :group 'gnus-summary-marks
512 (defcustom gnus-empty-thread-mark ? ;Whitespace
513 "*There is no thread under the article."
514 :group 'gnus-summary-marks
517 (defcustom gnus-not-empty-thread-mark ?=
518 "*There is a thread under the article."
519 :group 'gnus-summary-marks
522 (defcustom gnus-view-pseudo-asynchronously nil
523 "*If non-nil, Gnus will view pseudo-articles asynchronously."
524 :group 'gnus-extract-view
527 (defcustom gnus-auto-expirable-marks
528 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
529 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
530 gnus-souped-mark gnus-duplicate-mark)
531 "*The list of marks converted into expiration if a group is auto-expirable."
534 :type '(repeat character))
536 (defcustom gnus-inhibit-user-auto-expire t
537 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
542 (defcustom gnus-view-pseudos nil
543 "*If `automatic', pseudo-articles will be viewed automatically.
544 If `not-confirm', pseudos will be viewed automatically, and the user
545 will not be asked to confirm the command."
546 :group 'gnus-extract-view
547 :type '(choice (const :tag "off" nil)
549 (const not-confirm)))
551 (defcustom gnus-view-pseudos-separately t
552 "*If non-nil, one pseudo-article will be created for each file to be viewed.
553 If nil, all files that use the same viewing command will be given as a
554 list of parameters to that command."
555 :group 'gnus-extract-view
558 (defcustom gnus-insert-pseudo-articles t
559 "*If non-nil, insert pseudo-articles when decoding articles."
560 :group 'gnus-extract-view
563 (defcustom gnus-summary-dummy-line-format
565 "*The format specification for the dummy roots in the summary buffer.
566 It works along the same lines as a normal formatting string,
567 with some simple extensions.
570 :group 'gnus-threading
573 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
574 "*The format specification for the summary mode line.
575 It works along the same lines as a normal formatting string,
576 with some simple extensions:
579 %p Unprefixed group name
580 %A Current article number
581 %z Current article score
583 %U Number of unread articles in the group
584 %e Number of unselected articles in the group
585 %Z A string with unread/unselected article counts
586 %g Shortish group name
587 %S Subject of the current article
589 %s Current score file name
590 %d Number of dormant articles
591 %r Number of articles that have been marked as read in this session
592 %E Number of articles expunged by the score files"
593 :group 'gnus-summary-format
596 (defcustom gnus-list-identifiers nil
597 "Regexp that matches list identifiers to be removed from subject.
598 This can also be a list of regexps."
600 :group 'gnus-summary-format
601 :group 'gnus-article-hiding
602 :type '(choice (const :tag "none" nil)
604 (repeat :value (".*") regexp)))
606 (defcustom gnus-summary-mark-below 0
607 "*Mark all articles with a score below this variable as read.
608 This variable is local to each summary buffer and usually set by the
610 :group 'gnus-score-default
613 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
614 "*List of functions used for sorting articles in the summary buffer.
616 Each function takes two articles and returns non-nil if the first
617 article should be sorted before the other. If you use more than one
618 function, the primary sort function should be the last. You should
619 probably always include `gnus-article-sort-by-number' in the list of
620 sorting functions -- preferably first. Also note that sorting by date
621 is often much slower than sorting by number, and the sorting order is
622 very similar. (Sorting by date means sorting by the time the message
623 was sent, sorting by number means sorting by arrival time.)
625 Ready-made functions include `gnus-article-sort-by-number',
626 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
627 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
629 When threading is turned on, the variable `gnus-thread-sort-functions'
630 controls how articles are sorted."
631 :group 'gnus-summary-sort
632 :type '(repeat (choice (function-item gnus-article-sort-by-number)
633 (function-item gnus-article-sort-by-author)
634 (function-item gnus-article-sort-by-subject)
635 (function-item gnus-article-sort-by-date)
636 (function-item gnus-article-sort-by-score)
637 (function :tag "other"))))
639 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
640 "*List of functions used for sorting threads in the summary buffer.
641 By default, threads are sorted by article number.
643 Each function takes two threads and returns non-nil if the first
644 thread should be sorted before the other. If you use more than one
645 function, the primary sort function should be the last. You should
646 probably always include `gnus-thread-sort-by-number' in the list of
647 sorting functions -- preferably first. Also note that sorting by date
648 is often much slower than sorting by number, and the sorting order is
649 very similar. (Sorting by date means sorting by the time the message
650 was sent, sorting by number means sorting by arrival time.)
652 Ready-made functions include `gnus-thread-sort-by-number',
653 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
654 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
655 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
657 When threading is turned off, the variable
658 `gnus-article-sort-functions' controls how articles are sorted."
659 :group 'gnus-summary-sort
660 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
661 (function-item gnus-thread-sort-by-author)
662 (function-item gnus-thread-sort-by-subject)
663 (function-item gnus-thread-sort-by-date)
664 (function-item gnus-thread-sort-by-score)
665 (function-item gnus-thread-sort-by-total-score)
666 (function :tag "other"))))
668 (defcustom gnus-thread-score-function '+
669 "*Function used for calculating the total score of a thread.
671 The function is called with the scores of the article and each
672 subthread and should then return the score of the thread.
674 Some functions you can use are `+', `max', or `min'."
675 :group 'gnus-summary-sort
678 (defcustom gnus-summary-expunge-below nil
679 "All articles that have a score less than this variable will be expunged.
680 This variable is local to the summary buffers."
681 :group 'gnus-score-default
682 :type '(choice (const :tag "off" nil)
685 (defcustom gnus-thread-expunge-below nil
686 "All threads that have a total score less than this variable will be expunged.
687 See `gnus-thread-score-function' for en explanation of what a
690 This variable is local to the summary buffers."
691 :group 'gnus-threading
692 :group 'gnus-score-default
693 :type '(choice (const :tag "off" nil)
696 (defcustom gnus-summary-mode-hook nil
697 "*A hook for Gnus summary mode.
698 This hook is run before any variables are set in the summary buffer."
699 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
700 :group 'gnus-summary-various
703 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
704 (when (featurep 'xemacs)
705 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
706 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
707 (add-hook 'gnus-summary-mode-hook
708 'gnus-xmas-switch-horizontal-scrollbar-off))
710 (defcustom gnus-summary-menu-hook nil
711 "*Hook run after the creation of the summary mode menu."
712 :group 'gnus-summary-visual
715 (defcustom gnus-summary-exit-hook nil
716 "*A hook called on exit from the summary buffer.
717 It will be called with point in the group buffer."
718 :group 'gnus-summary-exit
721 (defcustom gnus-summary-prepare-hook nil
722 "*A hook called after the summary buffer has been generated.
723 If you want to modify the summary buffer, you can use this hook."
724 :group 'gnus-summary-various
727 (defcustom gnus-summary-prepared-hook nil
728 "*A hook called as the last thing after the summary buffer has been generated."
729 :group 'gnus-summary-various
732 (defcustom gnus-summary-generate-hook nil
733 "*A hook run just before generating the summary buffer.
734 This hook is commonly used to customize threading variables and the
736 :group 'gnus-summary-various
739 (defcustom gnus-select-group-hook nil
740 "*A hook called when a newsgroup is selected.
742 If you'd like to simplify subjects like the
743 `gnus-summary-next-same-subject' command does, you can use the
746 (setq gnus-select-group-hook
749 (mapcar (lambda (header)
750 (mail-header-set-subject
752 (gnus-simplify-subject
753 (mail-header-subject header) 're-only)))
754 gnus-newsgroup-headers))))"
755 :group 'gnus-group-select
758 (defcustom gnus-select-article-hook nil
759 "*A hook called when an article is selected."
760 :group 'gnus-summary-choose
763 (defcustom gnus-visual-mark-article-hook
764 (list 'gnus-highlight-selected-summary)
765 "*Hook run after selecting an article in the summary buffer.
766 It is meant to be used for highlighting the article in some way. It
767 is not run if `gnus-visual' is nil."
768 :group 'gnus-summary-visual
771 (defcustom gnus-parse-headers-hook nil
772 "*A hook called before parsing the headers."
776 (defcustom gnus-exit-group-hook nil
777 "*A hook called when exiting summary mode.
778 This hook is not called from the non-updating exit commands like `Q'."
782 (defcustom gnus-summary-update-hook
783 (list 'gnus-summary-highlight-line)
784 "*A hook called when a summary line is changed.
785 The hook will not be called if `gnus-visual' is nil.
787 The default function `gnus-summary-highlight-line' will
788 highlight the line according to the `gnus-summary-highlight'
790 :group 'gnus-summary-visual
793 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
794 "*A hook called when an article is selected for the first time.
795 The hook is intended to mark an article as read (or unread)
796 automatically when it is selected."
797 :group 'gnus-summary-choose
800 (defcustom gnus-group-no-more-groups-hook nil
801 "*A hook run when returning to group mode having no more (unread) groups."
802 :group 'gnus-group-select
805 (defcustom gnus-ps-print-hook nil
806 "*A hook run before ps-printing something from Gnus."
810 (defcustom gnus-summary-display-arrow
811 (and (fboundp 'display-graphic-p)
813 "*If non-nil, display an arrow highlighting the current article."
818 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
819 "Face used for highlighting the current article in the summary buffer."
820 :group 'gnus-summary-visual
823 (defcustom gnus-summary-highlight
824 '(((= mark gnus-canceled-mark)
825 . gnus-summary-cancelled-face)
826 ((and (> score default-high)
827 (or (= mark gnus-dormant-mark)
828 (= mark gnus-ticked-mark)))
829 . gnus-summary-high-ticked-face)
830 ((and (< score default-low)
831 (or (= mark gnus-dormant-mark)
832 (= mark gnus-ticked-mark)))
833 . gnus-summary-low-ticked-face)
834 ((or (= mark gnus-dormant-mark)
835 (= mark gnus-ticked-mark))
836 . gnus-summary-normal-ticked-face)
837 ((and (> score default-high) (= mark gnus-ancient-mark))
838 . gnus-summary-high-ancient-face)
839 ((and (< score default-low) (= mark gnus-ancient-mark))
840 . gnus-summary-low-ancient-face)
841 ((= mark gnus-ancient-mark)
842 . gnus-summary-normal-ancient-face)
843 ((and (> score default-high) (= mark gnus-unread-mark))
844 . gnus-summary-high-unread-face)
845 ((and (< score default-low) (= mark gnus-unread-mark))
846 . gnus-summary-low-unread-face)
847 ((= mark gnus-unread-mark)
848 . gnus-summary-normal-unread-face)
849 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
850 gnus-undownloaded-mark)))
851 . gnus-summary-high-unread-face)
852 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
853 gnus-undownloaded-mark)))
854 . gnus-summary-low-unread-face)
855 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
856 (memq article gnus-newsgroup-unreads))
857 . gnus-summary-normal-unread-face)
858 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
859 . gnus-summary-normal-read-face)
860 ((> score default-high)
861 . gnus-summary-high-read-face)
862 ((< score default-low)
863 . gnus-summary-low-read-face)
865 . gnus-summary-normal-read-face))
866 "*Controls the highlighting of summary buffer lines.
868 A list of (FORM . FACE) pairs. When deciding how a a particular
869 summary line should be displayed, each form is evaluated. The content
870 of the face field after the first true form is used. You can change
871 how those summary lines are displayed, by editing the face field.
873 You can use the following variables in the FORM field.
875 score: The article's score
876 default: The default article score.
877 default-high: The default score for high scored articles.
878 default-low: The default score for low scored articles.
879 below: The score below which articles are automatically marked as read.
880 mark: The articles mark."
881 :group 'gnus-summary-visual
882 :type '(repeat (cons (sexp :tag "Form" nil)
885 (defcustom gnus-alter-header-function nil
886 "Function called to allow alteration of article header structures.
887 The function is called with one parameter, the article header vector,
888 which it may alter in any way.")
890 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
891 "Variable that says which function should be used to decode a string with encoded words.")
893 (defcustom gnus-extra-headers nil
894 "*Extra headers to parse."
897 :type '(repeat symbol))
899 (defcustom gnus-ignored-from-addresses
900 (and user-mail-address (regexp-quote user-mail-address))
901 "*Regexp of From headers that may be suppressed in favor of To headers."
906 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
907 "List of charsets that should be ignored.
908 When these charsets are used in the \"charset\" parameter, the
909 default charset will be used instead."
911 :type '(repeat symbol)
912 :group 'gnus-charset)
914 (gnus-define-group-parameter
918 "Return the ignored charsets of GROUP."
919 :variable gnus-group-ignored-charsets-alist
921 '(("alt\\.chinese\\.text" iso-8859-1))
923 "Alist of regexps (to match group names) and charsets that should be ignored.
924 When these charsets are used in the \"charset\" parameter, the
925 default charset will be used instead."
926 :variable-group gnus-charset
927 :variable-type '(repeat (cons (regexp :tag "Group")
929 :parameter-type '(choice :tag "Ignored charsets"
932 :parameter-document "\
933 List of charsets that should be ignored.
935 When these charsets are used in the \"charset\" parameter, the
936 default charset will be used instead.")
938 (defcustom gnus-group-highlight-words-alist nil
939 "Alist of group regexps and highlight regexps.
940 This variable uses the same syntax as `gnus-emphasis-alist'."
942 :type '(repeat (cons (regexp :tag "Group")
943 (repeat (list (regexp :tag "Highlight regexp")
944 (number :tag "Group for entire word" 0)
945 (number :tag "Group for displayed part" 0)
947 gnus-emphasis-highlight-words)))))
948 :group 'gnus-summary-visual)
950 (defcustom gnus-summary-show-article-charset-alist
952 "Alist of number and charset.
953 The article will be shown with the charset corresponding to the
955 For example: ((1 . cn-gb-2312) (2 . big5))."
957 :type '(repeat (cons (number :tag "Argument" 1)
958 (symbol :tag "Charset")))
959 :group 'gnus-charset)
961 (defcustom gnus-preserve-marks t
962 "Whether marks are preserved when moving, copying and respooling messages."
965 :group 'gnus-summary-marks)
967 (defcustom gnus-alter-articles-to-read-function nil
968 "Function to be called to alter the list of articles to be selected."
969 :type '(choice (const nil) function)
970 :group 'gnus-summary)
972 (defcustom gnus-orphan-score nil
973 "*All orphans get this score added. Set in the score file."
974 :group 'gnus-score-default
975 :type '(choice (const nil)
978 (defcustom gnus-summary-save-parts-default-mime "image/.*"
979 "*A regexp to match MIME parts when saving multiple parts of a message
980 with gnus-summary-save-parts (X m). This regexp will be used by default
981 when prompting the user for which type of files to save."
986 (defcustom gnus-summary-save-parts-default-mime "image/.*"
987 "*A regexp to match MIME parts when saving multiple parts of a message
988 with gnus-summary-save-parts (X m). This regexp will be used by default
989 when prompting the user for which type of files to save."
993 (defcustom gnus-read-all-available-headers nil
994 "Whether Gnus should parse all headers made available to it.
995 This is mostly relevant for slow backends where the user may
996 wish to widen the summary buffer to include all headers
997 that were fetched. Say, for nnultimate groups."
999 :type '(choice boolean regexp))
1001 ;;; Internal variables
1003 (defvar gnus-summary-display-cache nil)
1004 (defvar gnus-article-mime-handles nil)
1005 (defvar gnus-article-decoded-p nil)
1006 (defvar gnus-article-charset nil)
1007 (defvar gnus-article-ignored-charsets nil)
1008 (defvar gnus-scores-exclude-files nil)
1009 (defvar gnus-page-broken nil)
1010 (defvar gnus-inhibit-mime-unbuttonizing nil)
1012 (defvar gnus-original-article nil)
1013 (defvar gnus-article-internal-prepare-hook nil)
1014 (defvar gnus-newsgroup-process-stack nil)
1016 (defvar gnus-thread-indent-array nil)
1017 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1018 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1019 "Function called to sort the articles within a thread after it has been gathered together.")
1021 (defvar gnus-summary-save-parts-type-history nil)
1022 (defvar gnus-summary-save-parts-last-directory nil)
1024 (defvar gnus-summary-save-parts-type-history nil)
1025 (defvar gnus-summary-save-parts-last-directory nil)
1027 ;; Avoid highlighting in kill files.
1028 (defvar gnus-summary-inhibit-highlight nil)
1029 (defvar gnus-newsgroup-selected-overlay nil)
1030 (defvar gnus-inhibit-limiting nil)
1031 (defvar gnus-newsgroup-adaptive-score-file nil)
1032 (defvar gnus-current-score-file nil)
1033 (defvar gnus-current-move-group nil)
1034 (defvar gnus-current-copy-group nil)
1035 (defvar gnus-current-crosspost-group nil)
1036 (defvar gnus-newsgroup-display nil)
1038 (defvar gnus-newsgroup-dependencies nil)
1039 (defvar gnus-newsgroup-adaptive nil)
1040 (defvar gnus-summary-display-article-function nil)
1041 (defvar gnus-summary-highlight-line-function nil
1042 "Function called after highlighting a summary line.")
1044 (defvar gnus-summary-line-format-alist
1045 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1046 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1047 (?s gnus-tmp-subject-or-nil ?s)
1048 (?n gnus-tmp-name ?s)
1049 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1051 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1053 (?F gnus-tmp-from ?s)
1054 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1055 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1056 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1057 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1058 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1059 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1060 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1061 (?L gnus-tmp-lines ?s)
1062 (?I gnus-tmp-indentation ?s)
1063 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1064 (?R gnus-tmp-replied ?c)
1065 (?\[ gnus-tmp-opening-bracket ?c)
1066 (?\] gnus-tmp-closing-bracket ?c)
1067 (?\> (make-string gnus-tmp-level ? ) ?s)
1068 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1069 (?i gnus-tmp-score ?d)
1070 (?z gnus-tmp-score-char ?c)
1071 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1072 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1073 (?U gnus-tmp-unread ?c)
1074 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1076 (?t (gnus-summary-number-of-articles-in-thread
1077 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1079 (?e (gnus-summary-number-of-articles-in-thread
1080 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1082 (?u gnus-tmp-user-defined ?s)
1083 (?P (gnus-pick-line-number) ?d)
1084 (?B gnus-tmp-thread-tree-header-string ?s)
1085 (user-date (gnus-user-date
1086 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1087 "An alist of format specifications that can appear in summary lines.
1088 These are paired with what variables they correspond with, along with
1089 the type of the variable (string, integer, character, etc).")
1091 (defvar gnus-summary-dummy-line-format-alist
1092 `((?S gnus-tmp-subject ?s)
1093 (?N gnus-tmp-number ?d)
1094 (?u gnus-tmp-user-defined ?s)))
1096 (defvar gnus-summary-mode-line-format-alist
1097 `((?G gnus-tmp-group-name ?s)
1098 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1099 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1100 (?A gnus-tmp-article-number ?d)
1101 (?Z gnus-tmp-unread-and-unselected ?s)
1102 (?V gnus-version ?s)
1103 (?U gnus-tmp-unread-and-unticked ?d)
1104 (?S gnus-tmp-subject ?s)
1105 (?e gnus-tmp-unselected ?d)
1106 (?u gnus-tmp-user-defined ?s)
1107 (?d (length gnus-newsgroup-dormant) ?d)
1108 (?t (length gnus-newsgroup-marked) ?d)
1109 (?r (length gnus-newsgroup-reads) ?d)
1110 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1111 (?E gnus-newsgroup-expunged-tally ?d)
1112 (?s (gnus-current-score-file-nondirectory) ?s)))
1114 (defvar gnus-last-search-regexp nil
1115 "Default regexp for article search command.")
1117 (defvar gnus-last-shell-command nil
1118 "Default shell command on article.")
1120 (defvar gnus-newsgroup-begin nil)
1121 (defvar gnus-newsgroup-end nil)
1122 (defvar gnus-newsgroup-last-rmail nil)
1123 (defvar gnus-newsgroup-last-mail nil)
1124 (defvar gnus-newsgroup-last-folder nil)
1125 (defvar gnus-newsgroup-last-file nil)
1126 (defvar gnus-newsgroup-auto-expire nil)
1127 (defvar gnus-newsgroup-active nil)
1129 (defvar gnus-newsgroup-data nil)
1130 (defvar gnus-newsgroup-data-reverse nil)
1131 (defvar gnus-newsgroup-limit nil)
1132 (defvar gnus-newsgroup-limits nil)
1134 (defvar gnus-newsgroup-unreads nil
1135 "List of unread articles in the current newsgroup.")
1137 (defvar gnus-newsgroup-unselected nil
1138 "List of unselected unread articles in the current newsgroup.")
1140 (defvar gnus-newsgroup-reads nil
1141 "Alist of read articles and article marks in the current newsgroup.")
1143 (defvar gnus-newsgroup-expunged-tally nil)
1145 (defvar gnus-newsgroup-marked nil
1146 "List of ticked articles in the current newsgroup (a subset of unread art).")
1148 (defvar gnus-newsgroup-killed nil
1149 "List of ranges of articles that have been through the scoring process.")
1151 (defvar gnus-newsgroup-cached nil
1152 "List of articles that come from the article cache.")
1154 (defvar gnus-newsgroup-saved nil
1155 "List of articles that have been saved.")
1157 (defvar gnus-newsgroup-kill-headers nil)
1159 (defvar gnus-newsgroup-replied nil
1160 "List of articles that have been replied to in the current newsgroup.")
1162 (defvar gnus-newsgroup-forwarded nil
1163 "List of articles that have been forwarded in the current newsgroup.")
1165 (defvar gnus-newsgroup-recent nil
1166 "List of articles that have are recent in the current newsgroup.")
1168 (defvar gnus-newsgroup-expirable nil
1169 "List of articles in the current newsgroup that can be expired.")
1171 (defvar gnus-newsgroup-processable nil
1172 "List of articles in the current newsgroup that can be processed.")
1174 (defvar gnus-newsgroup-downloadable nil
1175 "List of articles in the current newsgroup that can be processed.")
1177 (defvar gnus-newsgroup-undownloaded nil
1178 "List of articles in the current newsgroup that haven't been downloaded..")
1180 (defvar gnus-newsgroup-unsendable nil
1181 "List of articles in the current newsgroup that won't be sent.")
1183 (defvar gnus-newsgroup-bookmarks nil
1184 "List of articles in the current newsgroup that have bookmarks.")
1186 (defvar gnus-newsgroup-dormant nil
1187 "List of dormant articles in the current newsgroup.")
1189 (defvar gnus-newsgroup-unseen nil
1190 "List of unseen articles in the current newsgroup.")
1192 (defvar gnus-newsgroup-seen nil
1193 "Range of seen articles in the current newsgroup.")
1195 (defvar gnus-newsgroup-articles nil
1196 "List of articles in the current newsgroup.")
1198 (defvar gnus-newsgroup-scored nil
1199 "List of scored articles in the current newsgroup.")
1201 (defvar gnus-newsgroup-headers nil
1202 "List of article headers in the current newsgroup.")
1204 (defvar gnus-newsgroup-threads nil)
1206 (defvar gnus-newsgroup-prepared nil
1207 "Whether the current group has been prepared properly.")
1209 (defvar gnus-newsgroup-ancient nil
1210 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1212 (defvar gnus-newsgroup-sparse nil)
1214 (defvar gnus-current-article nil)
1215 (defvar gnus-article-current nil)
1216 (defvar gnus-current-headers nil)
1217 (defvar gnus-have-all-headers nil)
1218 (defvar gnus-last-article nil)
1219 (defvar gnus-newsgroup-history nil)
1220 (defvar gnus-newsgroup-charset nil)
1221 (defvar gnus-newsgroup-ephemeral-charset nil)
1222 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1224 (defvar gnus-article-before-search nil)
1226 (defconst gnus-summary-local-variables
1227 '(gnus-newsgroup-name
1228 gnus-newsgroup-begin gnus-newsgroup-end
1229 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1230 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1231 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1232 gnus-newsgroup-unselected gnus-newsgroup-marked
1233 gnus-newsgroup-reads gnus-newsgroup-saved
1234 gnus-newsgroup-replied gnus-newsgroup-forwarded
1235 gnus-newsgroup-recent
1236 gnus-newsgroup-expirable
1237 gnus-newsgroup-processable gnus-newsgroup-killed
1238 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1239 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1240 gnus-newsgroup-seen gnus-newsgroup-articles
1241 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1242 gnus-newsgroup-headers gnus-newsgroup-threads
1243 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1244 gnus-current-article gnus-current-headers gnus-have-all-headers
1245 gnus-last-article gnus-article-internal-prepare-hook
1246 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1247 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1248 gnus-thread-expunge-below
1249 gnus-score-alist gnus-current-score-file
1250 (gnus-summary-expunge-below . global)
1251 (gnus-summary-mark-below . global)
1252 (gnus-orphan-score . global)
1253 gnus-newsgroup-active gnus-scores-exclude-files
1254 gnus-newsgroup-history gnus-newsgroup-ancient
1255 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1256 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1257 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1258 (gnus-newsgroup-expunged-tally . 0)
1259 gnus-cache-removable-articles gnus-newsgroup-cached
1260 gnus-newsgroup-data gnus-newsgroup-data-reverse
1261 gnus-newsgroup-limit gnus-newsgroup-limits
1262 gnus-newsgroup-charset gnus-newsgroup-display)
1263 "Variables that are buffer-local to the summary buffers.")
1265 (defvar gnus-newsgroup-variables nil
1266 "A list of variables that have separate values in different newsgroups.
1267 A list of newsgroup (summary buffer) local variables, or cons of
1268 variables and their default values (when the default values are not
1269 nil), that should be made global while the summary buffer is active.
1270 These variables can be used to set variables in the group parameters
1271 while still allowing them to affect operations done in other
1272 buffers. For example:
1274 (setq gnus-newsgroup-variables
1275 '(message-use-followup-to
1276 (gnus-visible-headers .
1277 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1280 ;; Byte-compiler warning.
1281 (eval-when-compile (defvar gnus-article-mode-map))
1285 (defvar gnus-decode-encoded-word-methods
1286 '(mail-decode-encoded-word-string)
1287 "List of methods used to decode encoded words.
1289 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1290 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1291 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1292 whose names match REGEXP.
1295 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1296 mail-decode-encoded-word-string
1297 (\"chinese\" . rfc1843-decode-string))")
1299 (defvar gnus-decode-encoded-word-methods-cache nil)
1301 (defun gnus-multi-decode-encoded-word-string (string)
1302 "Apply the functions from `gnus-encoded-word-methods' that match."
1303 (unless (and gnus-decode-encoded-word-methods-cache
1304 (eq gnus-newsgroup-name
1305 (car gnus-decode-encoded-word-methods-cache)))
1306 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1309 (nconc gnus-decode-encoded-word-methods-cache (list x))
1310 (if (and gnus-newsgroup-name
1311 (string-match (car x) gnus-newsgroup-name))
1312 (nconc gnus-decode-encoded-word-methods-cache
1314 gnus-decode-encoded-word-methods))
1315 (let ((xlist gnus-decode-encoded-word-methods-cache))
1318 (setq string (funcall (pop xlist) string))))
1321 ;; Subject simplification.
1323 (defun gnus-simplify-whitespace (str)
1324 "Remove excessive whitespace from STR."
1327 (while (string-match "[ \t][ \t]+" mystr)
1328 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1330 (substring mystr (match-end 0)))))
1332 (when (string-match "^[ \t]+" mystr)
1333 (setq mystr (substring mystr (match-end 0))))
1335 (when (string-match "[ \t]+$" mystr)
1336 (setq mystr (substring mystr 0 (match-beginning 0))))
1339 (defsubst gnus-simplify-subject-re (subject)
1340 "Remove \"Re:\" from subject lines."
1341 (if (string-match message-subject-re-regexp subject)
1342 (substring subject (match-end 0))
1345 (defun gnus-simplify-subject (subject &optional re-only)
1346 "Remove `Re:' and words in parentheses.
1347 If RE-ONLY is non-nil, strip leading `Re:'s only."
1348 (let ((case-fold-search t)) ;Ignore case.
1349 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1350 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1351 (setq subject (substring subject (match-end 0))))
1352 ;; Remove uninteresting prefixes.
1353 (when (and (not re-only)
1354 gnus-simplify-ignored-prefixes
1355 (string-match gnus-simplify-ignored-prefixes subject))
1356 (setq subject (substring subject (match-end 0))))
1357 ;; Remove words in parentheses from end.
1359 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1360 (setq subject (substring subject 0 (match-beginning 0)))))
1361 ;; Return subject string.
1364 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1366 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1367 (goto-char (point-min))
1368 (while (re-search-forward regexp nil t)
1369 (replace-match (or newtext ""))))
1371 (defun gnus-simplify-buffer-fuzzy ()
1372 "Simplify string in the buffer fuzzily.
1373 The string in the accessible portion of the current buffer is simplified.
1374 It is assumed to be a single-line subject.
1375 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1376 matter is removed. Additional things can be deleted by setting
1377 `gnus-simplify-subject-fuzzy-regexp'."
1378 (let ((case-fold-search t)
1380 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1382 (while (not (eq modified-tick (buffer-modified-tick)))
1383 (setq modified-tick (buffer-modified-tick))
1385 ((listp gnus-simplify-subject-fuzzy-regexp)
1386 (mapcar 'gnus-simplify-buffer-fuzzy-step
1387 gnus-simplify-subject-fuzzy-regexp))
1388 (gnus-simplify-subject-fuzzy-regexp
1389 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1390 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1391 (gnus-simplify-buffer-fuzzy-step
1392 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1393 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1395 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1396 (gnus-simplify-buffer-fuzzy-step " +" " ")
1397 (gnus-simplify-buffer-fuzzy-step " $")
1398 (gnus-simplify-buffer-fuzzy-step "^ +")))
1400 (defun gnus-simplify-subject-fuzzy (subject)
1401 "Simplify a subject string fuzzily.
1402 See `gnus-simplify-buffer-fuzzy' for details."
1404 (gnus-set-work-buffer)
1405 (let ((case-fold-search t))
1406 ;; Remove uninteresting prefixes.
1407 (when (and gnus-simplify-ignored-prefixes
1408 (string-match gnus-simplify-ignored-prefixes subject))
1409 (setq subject (substring subject (match-end 0))))
1411 (inline (gnus-simplify-buffer-fuzzy))
1414 (defsubst gnus-simplify-subject-fully (subject)
1415 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1417 (gnus-simplify-subject-functions
1418 (gnus-map-function gnus-simplify-subject-functions subject))
1419 ((null gnus-summary-gather-subject-limit)
1420 (gnus-simplify-subject-re subject))
1421 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1422 (gnus-simplify-subject-fuzzy subject))
1423 ((numberp gnus-summary-gather-subject-limit)
1424 (gnus-limit-string (gnus-simplify-subject-re subject)
1425 gnus-summary-gather-subject-limit))
1429 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1430 "Check whether two subjects are equal.
1431 If optional argument simple-first is t, first argument is already
1434 ((null simple-first)
1435 (equal (gnus-simplify-subject-fully s1)
1436 (gnus-simplify-subject-fully s2)))
1439 (gnus-simplify-subject-fully s2)))))
1441 (defun gnus-summary-bubble-group ()
1442 "Increase the score of the current group.
1443 This is a handy function to add to `gnus-summary-exit-hook' to
1444 increase the score of each group you read."
1445 (gnus-group-add-score gnus-newsgroup-name))
1449 ;;; Gnus summary mode
1452 (put 'gnus-summary-mode 'mode-class 'special)
1454 (defvar gnus-article-commands-menu)
1457 ;; Non-orthogonal keys
1459 (gnus-define-keys gnus-summary-mode-map
1460 " " gnus-summary-next-page
1461 "\177" gnus-summary-prev-page
1462 [delete] gnus-summary-prev-page
1463 [backspace] gnus-summary-prev-page
1464 "\r" gnus-summary-scroll-up
1465 "\M-\r" gnus-summary-scroll-down
1466 "n" gnus-summary-next-unread-article
1467 "p" gnus-summary-prev-unread-article
1468 "N" gnus-summary-next-article
1469 "P" gnus-summary-prev-article
1470 "\M-\C-n" gnus-summary-next-same-subject
1471 "\M-\C-p" gnus-summary-prev-same-subject
1472 "\M-n" gnus-summary-next-unread-subject
1473 "\M-p" gnus-summary-prev-unread-subject
1474 "." gnus-summary-first-unread-article
1475 "," gnus-summary-best-unread-article
1476 "\M-s" gnus-summary-search-article-forward
1477 "\M-r" gnus-summary-search-article-backward
1478 "<" gnus-summary-beginning-of-article
1479 ">" gnus-summary-end-of-article
1480 "j" gnus-summary-goto-article
1481 "^" gnus-summary-refer-parent-article
1482 "\M-^" gnus-summary-refer-article
1483 "u" gnus-summary-tick-article-forward
1484 "!" gnus-summary-tick-article-forward
1485 "U" gnus-summary-tick-article-backward
1486 "d" gnus-summary-mark-as-read-forward
1487 "D" gnus-summary-mark-as-read-backward
1488 "E" gnus-summary-mark-as-expirable
1489 "\M-u" gnus-summary-clear-mark-forward
1490 "\M-U" gnus-summary-clear-mark-backward
1491 "k" gnus-summary-kill-same-subject-and-select
1492 "\C-k" gnus-summary-kill-same-subject
1493 "\M-\C-k" gnus-summary-kill-thread
1494 "\M-\C-l" gnus-summary-lower-thread
1495 "e" gnus-summary-edit-article
1496 "#" gnus-summary-mark-as-processable
1497 "\M-#" gnus-summary-unmark-as-processable
1498 "\M-\C-t" gnus-summary-toggle-threads
1499 "\M-\C-s" gnus-summary-show-thread
1500 "\M-\C-h" gnus-summary-hide-thread
1501 "\M-\C-f" gnus-summary-next-thread
1502 "\M-\C-b" gnus-summary-prev-thread
1503 [(meta down)] gnus-summary-next-thread
1504 [(meta up)] gnus-summary-prev-thread
1505 "\M-\C-u" gnus-summary-up-thread
1506 "\M-\C-d" gnus-summary-down-thread
1507 "&" gnus-summary-execute-command
1508 "c" gnus-summary-catchup-and-exit
1509 "\C-w" gnus-summary-mark-region-as-read
1510 "\C-t" gnus-summary-toggle-truncation
1511 "?" gnus-summary-mark-as-dormant
1512 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1513 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1514 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1515 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1516 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1517 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1518 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1519 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1520 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1521 "=" gnus-summary-expand-window
1522 "\C-x\C-s" gnus-summary-reselect-current-group
1523 "\M-g" gnus-summary-rescan-group
1524 "w" gnus-summary-stop-page-breaking
1525 "\C-c\C-r" gnus-summary-caesar-message
1526 "f" gnus-summary-followup
1527 "F" gnus-summary-followup-with-original
1528 "C" gnus-summary-cancel-article
1529 "r" gnus-summary-reply
1530 "R" gnus-summary-reply-with-original
1531 "\C-c\C-f" gnus-summary-mail-forward
1532 "o" gnus-summary-save-article
1533 "\C-o" gnus-summary-save-article-mail
1534 "|" gnus-summary-pipe-output
1535 "\M-k" gnus-summary-edit-local-kill
1536 "\M-K" gnus-summary-edit-global-kill
1538 "\C-c\C-d" gnus-summary-describe-group
1539 "q" gnus-summary-exit
1540 "Q" gnus-summary-exit-no-update
1541 "\C-c\C-i" gnus-info-find-node
1542 gnus-mouse-2 gnus-mouse-pick-article
1543 "m" gnus-summary-mail-other-window
1544 "a" gnus-summary-post-news
1545 "x" gnus-summary-limit-to-unread
1546 "s" gnus-summary-isearch-article
1547 "t" gnus-summary-toggle-header
1548 "g" gnus-summary-show-article
1549 "l" gnus-summary-goto-last-article
1550 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1551 "\C-d" gnus-summary-enter-digest-group
1552 "\M-\C-d" gnus-summary-read-document
1553 "\M-\C-e" gnus-summary-edit-parameters
1554 "\M-\C-a" gnus-summary-customize-parameters
1556 "*" gnus-cache-enter-article
1557 "\M-*" gnus-cache-remove-article
1558 "\M-&" gnus-summary-universal-argument
1559 "\C-l" gnus-recenter
1560 "I" gnus-summary-increase-score
1561 "L" gnus-summary-lower-score
1562 "\M-i" gnus-symbolic-argument
1563 "h" gnus-summary-select-article-buffer
1565 "b" gnus-article-view-part
1566 "\M-t" gnus-summary-toggle-display-buttonized
1568 "V" gnus-summary-score-map
1569 "X" gnus-uu-extract-map
1570 "S" gnus-summary-send-map)
1572 ;; Sort of orthogonal keymap
1573 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1574 "t" gnus-summary-tick-article-forward
1575 "!" gnus-summary-tick-article-forward
1576 "d" gnus-summary-mark-as-read-forward
1577 "r" gnus-summary-mark-as-read-forward
1578 "c" gnus-summary-clear-mark-forward
1579 " " gnus-summary-clear-mark-forward
1580 "e" gnus-summary-mark-as-expirable
1581 "x" gnus-summary-mark-as-expirable
1582 "?" gnus-summary-mark-as-dormant
1583 "b" gnus-summary-set-bookmark
1584 "B" gnus-summary-remove-bookmark
1585 "#" gnus-summary-mark-as-processable
1586 "\M-#" gnus-summary-unmark-as-processable
1587 "S" gnus-summary-limit-include-expunged
1588 "C" gnus-summary-catchup
1589 "H" gnus-summary-catchup-to-here
1590 "h" gnus-summary-catchup-from-here
1591 "\C-c" gnus-summary-catchup-all
1592 "k" gnus-summary-kill-same-subject-and-select
1593 "K" gnus-summary-kill-same-subject
1594 "P" gnus-uu-mark-map)
1596 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1597 "c" gnus-summary-clear-above
1598 "u" gnus-summary-tick-above
1599 "m" gnus-summary-mark-above
1600 "k" gnus-summary-kill-below)
1602 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1603 "/" gnus-summary-limit-to-subject
1604 "n" gnus-summary-limit-to-articles
1605 "w" gnus-summary-pop-limit
1606 "s" gnus-summary-limit-to-subject
1607 "a" gnus-summary-limit-to-author
1608 "u" gnus-summary-limit-to-unread
1609 "m" gnus-summary-limit-to-marks
1610 "M" gnus-summary-limit-exclude-marks
1611 "v" gnus-summary-limit-to-score
1612 "*" gnus-summary-limit-include-cached
1613 "D" gnus-summary-limit-include-dormant
1614 "T" gnus-summary-limit-include-thread
1615 "d" gnus-summary-limit-exclude-dormant
1616 "t" gnus-summary-limit-to-age
1617 "x" gnus-summary-limit-to-extra
1618 "p" gnus-summary-limit-to-display-predicate
1619 "E" gnus-summary-limit-include-expunged
1620 "c" gnus-summary-limit-exclude-childless-dormant
1621 "C" gnus-summary-limit-mark-excluded-as-read
1622 "o" gnus-summary-insert-old-articles
1623 "N" gnus-summary-insert-new-articles)
1625 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1626 "n" gnus-summary-next-unread-article
1627 "p" gnus-summary-prev-unread-article
1628 "N" gnus-summary-next-article
1629 "P" gnus-summary-prev-article
1630 "\C-n" gnus-summary-next-same-subject
1631 "\C-p" gnus-summary-prev-same-subject
1632 "\M-n" gnus-summary-next-unread-subject
1633 "\M-p" gnus-summary-prev-unread-subject
1634 "f" gnus-summary-first-unread-article
1635 "b" gnus-summary-best-unread-article
1636 "j" gnus-summary-goto-article
1637 "g" gnus-summary-goto-subject
1638 "l" gnus-summary-goto-last-article
1639 "o" gnus-summary-pop-article)
1641 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1642 "k" gnus-summary-kill-thread
1643 "l" gnus-summary-lower-thread
1644 "i" gnus-summary-raise-thread
1645 "T" gnus-summary-toggle-threads
1646 "t" gnus-summary-rethread-current
1647 "^" gnus-summary-reparent-thread
1648 "s" gnus-summary-show-thread
1649 "S" gnus-summary-show-all-threads
1650 "h" gnus-summary-hide-thread
1651 "H" gnus-summary-hide-all-threads
1652 "n" gnus-summary-next-thread
1653 "p" gnus-summary-prev-thread
1654 "u" gnus-summary-up-thread
1655 "o" gnus-summary-top-thread
1656 "d" gnus-summary-down-thread
1657 "#" gnus-uu-mark-thread
1658 "\M-#" gnus-uu-unmark-thread)
1660 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1661 "g" gnus-summary-prepare
1662 "c" gnus-summary-insert-cached-articles)
1664 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1665 "c" gnus-summary-catchup-and-exit
1666 "C" gnus-summary-catchup-all-and-exit
1667 "E" gnus-summary-exit-no-update
1668 "Q" gnus-summary-exit
1669 "Z" gnus-summary-exit
1670 "n" gnus-summary-catchup-and-goto-next-group
1671 "R" gnus-summary-reselect-current-group
1672 "G" gnus-summary-rescan-group
1673 "N" gnus-summary-next-group
1674 "s" gnus-summary-save-newsrc
1675 "P" gnus-summary-prev-group)
1677 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1678 " " gnus-summary-next-page
1679 "n" gnus-summary-next-page
1680 "\177" gnus-summary-prev-page
1681 [delete] gnus-summary-prev-page
1682 "p" gnus-summary-prev-page
1683 "\r" gnus-summary-scroll-up
1684 "\M-\r" gnus-summary-scroll-down
1685 "<" gnus-summary-beginning-of-article
1686 ">" gnus-summary-end-of-article
1687 "b" gnus-summary-beginning-of-article
1688 "e" gnus-summary-end-of-article
1689 "^" gnus-summary-refer-parent-article
1690 "r" gnus-summary-refer-parent-article
1691 "D" gnus-summary-enter-digest-group
1692 "R" gnus-summary-refer-references
1693 "T" gnus-summary-refer-thread
1694 "g" gnus-summary-show-article
1695 "s" gnus-summary-isearch-article
1696 "P" gnus-summary-print-article
1697 "M" gnus-mailing-list-insinuate
1698 "t" gnus-article-babel)
1700 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1701 "b" gnus-article-add-buttons
1702 "B" gnus-article-add-buttons-to-head
1703 "o" gnus-article-treat-overstrike
1704 "e" gnus-article-emphasize
1705 "w" gnus-article-fill-cited-article
1706 "Q" gnus-article-fill-long-lines
1707 "C" gnus-article-capitalize-sentences
1708 "c" gnus-article-remove-cr
1709 "q" gnus-article-de-quoted-unreadable
1710 "6" gnus-article-de-base64-unreadable
1711 "Z" gnus-article-decode-HZ
1712 "h" gnus-article-wash-html
1713 "s" gnus-summary-force-verify-and-decrypt
1714 "f" gnus-article-display-x-face
1715 "l" gnus-summary-stop-page-breaking
1716 "r" gnus-summary-caesar-message
1717 "t" gnus-summary-toggle-header
1718 "g" gnus-summary-toggle-smiley
1719 "v" gnus-summary-verbose-headers
1720 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1721 "p" gnus-article-verify-x-pgp-sig
1722 "d" gnus-article-treat-dumbquotes)
1724 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1725 "a" gnus-article-hide
1726 "h" gnus-article-hide-headers
1727 "b" gnus-article-hide-boring-headers
1728 "s" gnus-article-hide-signature
1729 "c" gnus-article-hide-citation
1730 "C" gnus-article-hide-citation-in-followups
1731 "l" gnus-article-hide-list-identifiers
1732 "p" gnus-article-hide-pgp
1733 "B" gnus-article-strip-banner
1734 "P" gnus-article-hide-pem
1735 "\C-c" gnus-article-hide-citation-maybe)
1737 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1738 "a" gnus-article-highlight
1739 "h" gnus-article-highlight-headers
1740 "c" gnus-article-highlight-citation
1741 "s" gnus-article-highlight-signature)
1743 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1744 "w" gnus-article-decode-mime-words
1745 "c" gnus-article-decode-charset
1746 "v" gnus-mime-view-all-parts
1747 "b" gnus-article-view-part)
1749 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1750 "z" gnus-article-date-ut
1751 "u" gnus-article-date-ut
1752 "l" gnus-article-date-local
1753 "p" gnus-article-date-english
1754 "e" gnus-article-date-lapsed
1755 "o" gnus-article-date-original
1756 "i" gnus-article-date-iso8601
1757 "s" gnus-article-date-user)
1759 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1760 "t" gnus-article-remove-trailing-blank-lines
1761 "l" gnus-article-strip-leading-blank-lines
1762 "m" gnus-article-strip-multiple-blank-lines
1763 "a" gnus-article-strip-blank-lines
1764 "A" gnus-article-strip-all-blank-lines
1765 "s" gnus-article-strip-leading-space
1766 "e" gnus-article-strip-trailing-space
1767 "w" gnus-article-remove-leading-whitespace)
1769 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1771 "f" gnus-summary-fetch-faq
1772 "d" gnus-summary-describe-group
1773 "h" gnus-summary-describe-briefly
1774 "i" gnus-info-find-node)
1776 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1777 "e" gnus-summary-expire-articles
1778 "\M-\C-e" gnus-summary-expire-articles-now
1779 "\177" gnus-summary-delete-article
1780 [delete] gnus-summary-delete-article
1781 [backspace] gnus-summary-delete-article
1782 "m" gnus-summary-move-article
1783 "r" gnus-summary-respool-article
1784 "w" gnus-summary-edit-article
1785 "c" gnus-summary-copy-article
1786 "B" gnus-summary-crosspost-article
1787 "q" gnus-summary-respool-query
1788 "t" gnus-summary-respool-trace
1789 "i" gnus-summary-import-article
1790 "I" gnus-summary-create-article
1791 "p" gnus-summary-article-posted-p)
1793 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1794 "o" gnus-summary-save-article
1795 "m" gnus-summary-save-article-mail
1796 "F" gnus-summary-write-article-file
1797 "r" gnus-summary-save-article-rmail
1798 "f" gnus-summary-save-article-file
1799 "b" gnus-summary-save-article-body-file
1800 "h" gnus-summary-save-article-folder
1801 "v" gnus-summary-save-article-vm
1802 "p" gnus-summary-pipe-output
1803 "s" gnus-soup-add-article)
1805 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1806 "b" gnus-summary-display-buttonized
1807 "m" gnus-summary-repair-multipart
1808 "v" gnus-article-view-part
1809 "o" gnus-article-save-part
1810 "c" gnus-article-copy-part
1811 "C" gnus-article-view-part-as-charset
1812 "e" gnus-article-externalize-part
1813 "E" gnus-article-encrypt-body
1814 "i" gnus-article-inline-part
1815 "|" gnus-article-pipe-part))
1817 (defvar gnus-article-post-menu nil)
1819 (defun gnus-summary-make-menu-bar ()
1820 (gnus-turn-off-edit-menu 'summary)
1822 (unless (boundp 'gnus-summary-misc-menu)
1825 gnus-summary-kill-menu gnus-summary-mode-map ""
1830 ["Customize" gnus-score-customize t])
1831 (gnus-make-score-map 'increase)
1832 (gnus-make-score-map 'lower)
1834 ["Kill below" gnus-summary-kill-below t]
1835 ["Mark above" gnus-summary-mark-above t]
1836 ["Tick above" gnus-summary-tick-above t]
1837 ["Clear above" gnus-summary-clear-above t])
1838 ["Current score" gnus-summary-current-score t]
1839 ["Set score" gnus-summary-set-score t]
1840 ["Switch current score file..." gnus-score-change-score-file t]
1841 ["Set mark below..." gnus-score-set-mark-below t]
1842 ["Set expunge below..." gnus-score-set-expunge-below t]
1843 ["Edit current score file" gnus-score-edit-current-scores t]
1844 ["Edit score file" gnus-score-edit-file t]
1845 ["Trace score" gnus-score-find-trace t]
1846 ["Find words" gnus-score-find-favourite-words t]
1847 ["Rescore buffer" gnus-summary-rescore t]
1848 ["Increase score..." gnus-summary-increase-score t]
1849 ["Lower score..." gnus-summary-lower-score t]))))
1851 ;; Define both the Article menu in the summary buffer and the equivalent
1852 ;; Commands menu in the article buffer here for consistency.
1855 ["All" gnus-article-hide t]
1856 ["Headers" gnus-article-hide-headers t]
1857 ["Signature" gnus-article-hide-signature t]
1858 ["Citation" gnus-article-hide-citation t]
1859 ["List identifiers" gnus-article-hide-list-identifiers t]
1860 ["PGP" gnus-article-hide-pgp t]
1861 ["Banner" gnus-article-strip-banner t]
1862 ["Boring headers" gnus-article-hide-boring-headers t])
1864 ["All" gnus-article-highlight t]
1865 ["Headers" gnus-article-highlight-headers t]
1866 ["Signature" gnus-article-highlight-signature t]
1867 ["Citation" gnus-article-highlight-citation t])
1869 ["Words" gnus-article-decode-mime-words t]
1870 ["Charset" gnus-article-decode-charset t]
1871 ["QP" gnus-article-de-quoted-unreadable t]
1872 ["Base64" gnus-article-de-base64-unreadable t]
1873 ["View all" gnus-mime-view-all-parts t]
1874 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1875 ["Encrypt body" gnus-article-encrypt-body t])
1877 ["Local" gnus-article-date-local t]
1878 ["ISO8601" gnus-article-date-iso8601 t]
1879 ["UT" gnus-article-date-ut t]
1880 ["Original" gnus-article-date-original t]
1881 ["Lapsed" gnus-article-date-lapsed t]
1882 ["User-defined" gnus-article-date-user t])
1885 ["Leading" gnus-article-strip-leading-blank-lines t]
1886 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1887 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1888 ["All of the above" gnus-article-strip-blank-lines t]
1889 ["All" gnus-article-strip-all-blank-lines t]
1890 ["Leading space" gnus-article-strip-leading-space t]
1891 ["Trailing space" gnus-article-strip-trailing-space t]
1892 ["Leading space in headers"
1893 gnus-article-remove-leading-whitespace t])
1894 ["Overstrike" gnus-article-treat-overstrike t]
1895 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1896 ["Emphasis" gnus-article-emphasize t]
1897 ["Word wrap" gnus-article-fill-cited-article t]
1898 ["Fill long lines" gnus-article-fill-long-lines t]
1899 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1900 ["CR" gnus-article-remove-cr t]
1901 ["Show X-Face" gnus-article-display-x-face t]
1902 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1903 ["Base64" gnus-article-de-base64-unreadable t]
1904 ["Rot 13" gnus-summary-caesar-message
1905 ,@(if (featurep 'xemacs) '(t)
1906 '(:help "\"Caesar rotate\" article by 13"))]
1907 ["Unix pipe" gnus-summary-pipe-message t]
1908 ["Add buttons" gnus-article-add-buttons t]
1909 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1910 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1911 ["Verbose header" gnus-summary-verbose-headers t]
1912 ["Toggle header" gnus-summary-toggle-header t]
1913 ["Toggle smiley" gnus-summary-toggle-smiley t]
1914 ["Html" gnus-article-wash-html t]
1915 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1916 ["HZ" gnus-article-decode-HZ t])
1918 ["Save in default format" gnus-summary-save-article
1919 ,@(if (featurep 'xemacs) '(t)
1920 '(:help "Save article using default method"))]
1921 ["Save in file" gnus-summary-save-article-file
1922 ,@(if (featurep 'xemacs) '(t)
1923 '(:help "Save article in file"))]
1924 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1925 ["Save in MH folder" gnus-summary-save-article-folder t]
1926 ["Save in VM folder" gnus-summary-save-article-vm t]
1927 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1928 ["Save body in file" gnus-summary-save-article-body-file t]
1929 ["Pipe through a filter" gnus-summary-pipe-output t]
1930 ["Add to SOUP packet" gnus-soup-add-article t]
1931 ["Print" gnus-summary-print-article t])
1933 ["Respool article..." gnus-summary-respool-article t]
1934 ["Move article..." gnus-summary-move-article
1935 (gnus-check-backend-function
1936 'request-move-article gnus-newsgroup-name)]
1937 ["Copy article..." gnus-summary-copy-article t]
1938 ["Crosspost article..." gnus-summary-crosspost-article
1939 (gnus-check-backend-function
1940 'request-replace-article gnus-newsgroup-name)]
1941 ["Import file..." gnus-summary-import-article t]
1942 ["Create article..." gnus-summary-create-article t]
1943 ["Check if posted" gnus-summary-article-posted-p t]
1944 ["Edit article" gnus-summary-edit-article
1945 (not (gnus-group-read-only-p))]
1946 ["Delete article" gnus-summary-delete-article
1947 (gnus-check-backend-function
1948 'request-expire-articles gnus-newsgroup-name)]
1949 ["Query respool" gnus-summary-respool-query t]
1950 ["Trace respool" gnus-summary-respool-trace t]
1951 ["Delete expirable articles" gnus-summary-expire-articles-now
1952 (gnus-check-backend-function
1953 'request-expire-articles gnus-newsgroup-name)])
1955 ["Uudecode" gnus-uu-decode-uu
1956 ,@(if (featurep 'xemacs) '(t)
1957 '(:help "Decode uuencoded article(s)"))]
1958 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1959 ["Unshar" gnus-uu-decode-unshar t]
1960 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1961 ["Save" gnus-uu-decode-save t]
1962 ["Binhex" gnus-uu-decode-binhex t]
1963 ["Postscript" gnus-uu-decode-postscript t])
1965 ["Enter article" gnus-cache-enter-article t]
1966 ["Remove article" gnus-cache-remove-article t])
1967 ["Translate" gnus-article-babel t]
1968 ["Select article buffer" gnus-summary-select-article-buffer t]
1969 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1970 ["Isearch article..." gnus-summary-isearch-article t]
1971 ["Beginning of the article" gnus-summary-beginning-of-article t]
1972 ["End of the article" gnus-summary-end-of-article t]
1973 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1974 ["Fetch referenced articles" gnus-summary-refer-references t]
1975 ["Fetch current thread" gnus-summary-refer-thread t]
1976 ["Fetch article with id..." gnus-summary-refer-article t]
1977 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1978 ["Redisplay" gnus-summary-show-article t]
1979 ["Raw article" gnus-summary-show-raw-article t])))
1981 gnus-summary-article-menu gnus-summary-mode-map ""
1982 (cons "Article" innards))
1984 (if (not (keymapp gnus-summary-article-menu))
1986 gnus-article-commands-menu gnus-article-mode-map ""
1987 (cons "Commands" innards))
1988 ;; in Emacs, don't share menu.
1989 (setq gnus-article-commands-menu
1990 (copy-keymap gnus-summary-article-menu))
1991 (define-key gnus-article-mode-map [menu-bar commands]
1992 (cons "Commands" gnus-article-commands-menu))))
1995 gnus-summary-thread-menu gnus-summary-mode-map ""
1997 ["Toggle threading" gnus-summary-toggle-threads t]
1998 ["Hide threads" gnus-summary-hide-all-threads t]
1999 ["Show threads" gnus-summary-show-all-threads t]
2000 ["Hide thread" gnus-summary-hide-thread t]
2001 ["Show thread" gnus-summary-show-thread t]
2002 ["Go to next thread" gnus-summary-next-thread t]
2003 ["Go to previous thread" gnus-summary-prev-thread t]
2004 ["Go down thread" gnus-summary-down-thread t]
2005 ["Go up thread" gnus-summary-up-thread t]
2006 ["Top of thread" gnus-summary-top-thread t]
2007 ["Mark thread as read" gnus-summary-kill-thread t]
2008 ["Lower thread score" gnus-summary-lower-thread t]
2009 ["Raise thread score" gnus-summary-raise-thread t]
2010 ["Rethread current" gnus-summary-rethread-current t]))
2013 gnus-summary-post-menu gnus-summary-mode-map ""
2015 ["Post an article" gnus-summary-post-news
2016 ,@(if (featurep 'xemacs) '(t)
2017 '(:help "Post an article"))]
2018 ["Followup" gnus-summary-followup
2019 ,@(if (featurep 'xemacs) '(t)
2020 '(:help "Post followup to this article"))]
2021 ["Followup and yank" gnus-summary-followup-with-original
2022 ,@(if (featurep 'xemacs) '(t)
2023 '(:help "Post followup to this article, quoting its contents"))]
2024 ["Supersede article" gnus-summary-supersede-article t]
2025 ["Cancel article" gnus-summary-cancel-article
2026 ,@(if (featurep 'xemacs) '(t)
2027 '(:help "Cancel an article you posted"))]
2028 ["Reply" gnus-summary-reply t]
2029 ["Reply and yank" gnus-summary-reply-with-original t]
2030 ["Wide reply" gnus-summary-wide-reply t]
2031 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2032 ,@(if (featurep 'xemacs) '(t)
2033 '(:help "Mail a reply, quoting this article"))]
2034 ["Mail forward" gnus-summary-mail-forward t]
2035 ["Post forward" gnus-summary-post-forward t]
2036 ["Digest and mail" gnus-uu-digest-mail-forward t]
2037 ["Digest and post" gnus-uu-digest-post-forward t]
2038 ["Resend message" gnus-summary-resend-message t]
2039 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2040 ["Send a mail" gnus-summary-mail-other-window t]
2041 ["Uuencode and post" gnus-uu-post-news
2042 ,@(if (featurep 'xemacs) '(t)
2043 '(:help "Post a uuencoded article"))]
2044 ["Followup via news" gnus-summary-followup-to-mail t]
2045 ["Followup via news and yank"
2046 gnus-summary-followup-to-mail-with-original t]
2048 ;;["Send" gnus-summary-send-draft t]
2049 ;;["Send bounced" gnus-resend-bounced-mail t])
2053 ((not (keymapp gnus-summary-post-menu))
2054 (setq gnus-article-post-menu gnus-summary-post-menu))
2055 ((not gnus-article-post-menu)
2056 ;; Don't share post menu.
2057 (setq gnus-article-post-menu
2058 (copy-keymap gnus-summary-post-menu))))
2059 (define-key gnus-article-mode-map [menu-bar post]
2060 (cons "Post" gnus-article-post-menu))
2063 gnus-summary-misc-menu gnus-summary-mode-map ""
2066 ["Mark as read" gnus-summary-mark-as-read-forward t]
2067 ["Mark same subject and select"
2068 gnus-summary-kill-same-subject-and-select t]
2069 ["Mark same subject" gnus-summary-kill-same-subject t]
2070 ["Catchup" gnus-summary-catchup
2071 ,@(if (featurep 'xemacs) '(t)
2072 '(:help "Mark unread articles in this group as read"))]
2073 ["Catchup all" gnus-summary-catchup-all t]
2074 ["Catchup to here" gnus-summary-catchup-to-here t]
2075 ["Catchup from here" gnus-summary-catchup-from-here t]
2076 ["Catchup region" gnus-summary-mark-region-as-read t]
2077 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2079 ["Tick" gnus-summary-tick-article-forward t]
2080 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2081 ["Remove marks" gnus-summary-clear-mark-forward t]
2082 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2083 ["Set bookmark" gnus-summary-set-bookmark t]
2084 ["Remove bookmark" gnus-summary-remove-bookmark t])
2086 ["Marks..." gnus-summary-limit-to-marks t]
2087 ["Subject..." gnus-summary-limit-to-subject t]
2088 ["Author..." gnus-summary-limit-to-author t]
2089 ["Age..." gnus-summary-limit-to-age t]
2090 ["Extra..." gnus-summary-limit-to-extra t]
2091 ["Score" gnus-summary-limit-to-score t]
2092 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2093 ["Unread" gnus-summary-limit-to-unread t]
2094 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2095 ["Articles" gnus-summary-limit-to-articles t]
2096 ["Pop limit" gnus-summary-pop-limit t]
2097 ["Show dormant" gnus-summary-limit-include-dormant t]
2098 ["Hide childless dormant"
2099 gnus-summary-limit-exclude-childless-dormant t]
2100 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2101 ["Hide marked" gnus-summary-limit-exclude-marks t]
2102 ["Show expunged" gnus-summary-limit-include-expunged t])
2104 ["Set mark" gnus-summary-mark-as-processable t]
2105 ["Remove mark" gnus-summary-unmark-as-processable t]
2106 ["Remove all marks" gnus-summary-unmark-all-processable t]
2107 ["Mark above" gnus-uu-mark-over t]
2108 ["Mark series" gnus-uu-mark-series t]
2109 ["Mark region" gnus-uu-mark-region t]
2110 ["Unmark region" gnus-uu-unmark-region t]
2111 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2112 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2113 ["Mark all" gnus-uu-mark-all t]
2114 ["Mark buffer" gnus-uu-mark-buffer t]
2115 ["Mark sparse" gnus-uu-mark-sparse t]
2116 ["Mark thread" gnus-uu-mark-thread t]
2117 ["Unmark thread" gnus-uu-unmark-thread t]
2118 ("Process Mark Sets"
2119 ["Kill" gnus-summary-kill-process-mark t]
2120 ["Yank" gnus-summary-yank-process-mark
2121 gnus-newsgroup-process-stack]
2122 ["Save" gnus-summary-save-process-mark t]))
2124 ["Page forward" gnus-summary-next-page
2125 ,@(if (featurep 'xemacs) '(t)
2126 '(:help "Show next page of article"))]
2127 ["Page backward" gnus-summary-prev-page
2128 ,@(if (featurep 'xemacs) '(t)
2129 '(:help "Show previous page of article"))]
2130 ["Line forward" gnus-summary-scroll-up t])
2132 ["Next unread article" gnus-summary-next-unread-article t]
2133 ["Previous unread article" gnus-summary-prev-unread-article t]
2134 ["Next article" gnus-summary-next-article t]
2135 ["Previous article" gnus-summary-prev-article t]
2136 ["Next unread subject" gnus-summary-next-unread-subject t]
2137 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2138 ["Next article same subject" gnus-summary-next-same-subject t]
2139 ["Previous article same subject" gnus-summary-prev-same-subject t]
2140 ["First unread article" gnus-summary-first-unread-article t]
2141 ["Best unread article" gnus-summary-best-unread-article t]
2142 ["Go to subject number..." gnus-summary-goto-subject t]
2143 ["Go to article number..." gnus-summary-goto-article t]
2144 ["Go to the last article" gnus-summary-goto-last-article t]
2145 ["Pop article off history" gnus-summary-pop-article t])
2147 ["Sort by number" gnus-summary-sort-by-number t]
2148 ["Sort by author" gnus-summary-sort-by-author t]
2149 ["Sort by subject" gnus-summary-sort-by-subject t]
2150 ["Sort by date" gnus-summary-sort-by-date t]
2151 ["Sort by score" gnus-summary-sort-by-score t]
2152 ["Sort by lines" gnus-summary-sort-by-lines t]
2153 ["Sort by characters" gnus-summary-sort-by-chars t]
2154 ["Original sort" gnus-summary-sort-by-original t])
2156 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2157 ["Describe group" gnus-summary-describe-group t]
2158 ["Read manual" gnus-info-find-node t])
2160 ["Pick and read" gnus-pick-mode t]
2161 ["Binary" gnus-binary-mode t])
2163 ["Regenerate" gnus-summary-prepare t]
2164 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2165 ["Toggle threading" gnus-summary-toggle-threads t])
2166 ["See old articles" gnus-summary-insert-old-articles t]
2167 ["See new articles" gnus-summary-insert-new-articles t]
2168 ["Filter articles..." gnus-summary-execute-command t]
2169 ["Run command on subjects..." gnus-summary-universal-argument t]
2170 ["Search articles forward..." gnus-summary-search-article-forward t]
2171 ["Search articles backward..." gnus-summary-search-article-backward t]
2172 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2173 ["Expand window" gnus-summary-expand-window t]
2174 ["Expire expirable articles" gnus-summary-expire-articles
2175 (gnus-check-backend-function
2176 'request-expire-articles gnus-newsgroup-name)]
2177 ["Edit local kill file" gnus-summary-edit-local-kill t]
2178 ["Edit main kill file" gnus-summary-edit-global-kill t]
2179 ["Edit group parameters" gnus-summary-edit-parameters t]
2180 ["Customize group parameters" gnus-summary-customize-parameters t]
2181 ["Send a bug report" gnus-bug t]
2183 ["Catchup and exit" gnus-summary-catchup-and-exit
2184 ,@(if (featurep 'xemacs) '(t)
2185 '(:help "Mark unread articles in this group as read, then exit"))]
2186 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2187 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2188 ["Exit group" gnus-summary-exit
2189 ,@(if (featurep 'xemacs) '(t)
2190 '(:help "Exit current group, return to group selection mode"))]
2191 ["Exit group without updating" gnus-summary-exit-no-update t]
2192 ["Exit and goto next group" gnus-summary-next-group t]
2193 ["Exit and goto prev group" gnus-summary-prev-group t]
2194 ["Reselect group" gnus-summary-reselect-current-group t]
2195 ["Rescan group" gnus-summary-rescan-group t]
2196 ["Update dribble" gnus-summary-save-newsrc t])))
2198 (gnus-run-hooks 'gnus-summary-menu-hook)))
2200 (defvar gnus-summary-tool-bar-map nil)
2202 ;; Emacs 21 tool bar. Should be no-op otherwise.
2203 (defun gnus-summary-make-tool-bar ()
2204 (if (and (fboundp 'tool-bar-add-item-from-menu)
2205 (default-value 'tool-bar-mode)
2206 (not gnus-summary-tool-bar-map))
2207 (setq gnus-summary-tool-bar-map
2208 (let ((tool-bar-map (make-sparse-keymap))
2209 (load-path (mm-image-load-path)))
2210 (tool-bar-add-item-from-menu
2211 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2212 (tool-bar-add-item-from-menu
2213 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2214 (tool-bar-add-item-from-menu
2215 'gnus-summary-post-news "post" gnus-summary-mode-map)
2216 (tool-bar-add-item-from-menu
2217 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2218 (tool-bar-add-item-from-menu
2219 'gnus-summary-followup "followup" gnus-summary-mode-map)
2220 (tool-bar-add-item-from-menu
2221 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2222 (tool-bar-add-item-from-menu
2223 'gnus-summary-reply "reply" gnus-summary-mode-map)
2224 (tool-bar-add-item-from-menu
2225 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2226 (tool-bar-add-item-from-menu
2227 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2228 (tool-bar-add-item-from-menu
2229 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2230 (tool-bar-add-item-from-menu
2231 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2232 (tool-bar-add-item-from-menu
2233 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2234 (tool-bar-add-item-from-menu
2235 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2236 (tool-bar-add-item-from-menu
2237 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2238 (tool-bar-add-item-from-menu
2239 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2241 (if gnus-summary-tool-bar-map
2242 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2244 (defun gnus-score-set-default (var value)
2245 "A version of set that updates the GNU Emacs menu-bar."
2247 ;; It is the message that forces the active status to be updated.
2250 (defun gnus-make-score-map (type)
2251 "Make a summary score map of type TYPE."
2254 (let ((headers '(("author" "from" string)
2255 ("subject" "subject" string)
2256 ("article body" "body" string)
2257 ("article head" "head" string)
2258 ("xref" "xref" string)
2259 ("extra header" "extra" string)
2260 ("lines" "lines" number)
2261 ("followups to author" "followup" string)))
2262 (types '((number ("less than" <)
2265 (string ("substring" s)
2269 (perms '(("temporary" (current-time-string))
2277 (if (eq type 'lower)
2282 (setq header (car headers))
2288 (let ((ts (cdr (assoc (nth 2 header) types)))
2304 'gnus-summary-score-entry
2306 (if (or (string= (nth 1 header)
2308 (string= (nth 1 header)
2311 (list 'gnus-summary-header
2313 (list 'quote (nth 1 (car ts)))
2314 (list 'gnus-score-delta-default
2321 (list (nreverse outp))))
2324 (list (nreverse outt))))
2326 (setq headers (cdr headers)))
2327 (list (nreverse outh))))))))
2331 (defun gnus-summary-mode (&optional group)
2332 "Major mode for reading articles.
2334 All normal editing commands are switched off.
2335 \\<gnus-summary-mode-map>
2336 Each line in this buffer represents one article. To read an
2337 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2338 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2341 You can also post articles and send mail from this buffer. To
2342 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2343 of an article, type `\\[gnus-summary-reply]'.
2345 There are approx. one gazillion commands you can execute in this
2346 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2348 The following commands are available:
2350 \\{gnus-summary-mode-map}"
2352 (kill-all-local-variables)
2353 (when (gnus-visual-p 'summary-menu 'menu)
2354 (gnus-summary-make-menu-bar)
2355 (gnus-summary-make-tool-bar))
2356 (gnus-summary-make-local-variables)
2357 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2358 (gnus-summary-make-local-variables))
2359 (gnus-make-thread-indent-array)
2360 (gnus-simplify-mode-line)
2361 (setq major-mode 'gnus-summary-mode)
2362 (setq mode-name "Summary")
2363 (make-local-variable 'minor-mode-alist)
2364 (use-local-map gnus-summary-mode-map)
2365 (buffer-disable-undo)
2366 (setq buffer-read-only t) ;Disable modification
2367 (setq truncate-lines t)
2368 (setq selective-display t)
2369 (setq selective-display-ellipses t) ;Display `...'
2370 (gnus-summary-set-display-table)
2371 (gnus-set-default-directory)
2372 (setq gnus-newsgroup-name group)
2373 (make-local-variable 'gnus-summary-line-format)
2374 (make-local-variable 'gnus-summary-line-format-spec)
2375 (make-local-variable 'gnus-summary-dummy-line-format)
2376 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2377 (make-local-variable 'gnus-summary-mark-positions)
2378 (make-local-hook 'pre-command-hook)
2379 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2380 (gnus-run-hooks 'gnus-summary-mode-hook)
2381 (turn-on-gnus-mailing-list-mode)
2382 (mm-enable-multibyte-mule4)
2383 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2384 (gnus-update-summary-mark-positions))
2386 (defun gnus-summary-make-local-variables ()
2387 "Make all the local summary buffer variables."
2389 (dolist (local gnus-summary-local-variables)
2392 (if (eq (cdr local) 'global)
2393 ;; Copy the global value of the variable.
2394 (setq global (symbol-value (car local)))
2395 ;; Use the value from the list.
2396 (setq global (eval (cdr local))))
2397 (set (make-local-variable (car local)) global))
2398 ;; Simple nil-valued local variable.
2399 (set (make-local-variable local) nil)))))
2401 (defun gnus-summary-clear-local-variables ()
2402 (let ((locals gnus-summary-local-variables))
2404 (if (consp (car locals))
2405 (and (vectorp (caar locals))
2406 (set (caar locals) nil))
2407 (and (vectorp (car locals))
2408 (set (car locals) nil)))
2409 (setq locals (cdr locals)))))
2411 ;; Summary data functions.
2413 (defmacro gnus-data-number (data)
2416 (defmacro gnus-data-set-number (data number)
2417 `(setcar ,data ,number))
2419 (defmacro gnus-data-mark (data)
2422 (defmacro gnus-data-set-mark (data mark)
2423 `(setcar (nthcdr 1 ,data) ,mark))
2425 (defmacro gnus-data-pos (data)
2428 (defmacro gnus-data-set-pos (data pos)
2429 `(setcar (nthcdr 2 ,data) ,pos))
2431 (defmacro gnus-data-header (data)
2434 (defmacro gnus-data-set-header (data header)
2435 `(setf (nth 3 ,data) ,header))
2437 (defmacro gnus-data-level (data)
2440 (defmacro gnus-data-unread-p (data)
2441 `(= (nth 1 ,data) gnus-unread-mark))
2443 (defmacro gnus-data-read-p (data)
2444 `(/= (nth 1 ,data) gnus-unread-mark))
2446 (defmacro gnus-data-pseudo-p (data)
2447 `(consp (nth 3 ,data)))
2449 (defmacro gnus-data-find (number)
2450 `(assq ,number gnus-newsgroup-data))
2452 (defmacro gnus-data-find-list (number &optional data)
2453 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2454 (memq (assq ,number bdata)
2457 (defmacro gnus-data-make (number mark pos header level)
2458 `(list ,number ,mark ,pos ,header ,level))
2460 (defun gnus-data-enter (after-article number mark pos header level offset)
2461 (let ((data (gnus-data-find-list after-article)))
2463 (error "No such article: %d" after-article))
2464 (setcdr data (cons (gnus-data-make number mark pos header level)
2466 (setq gnus-newsgroup-data-reverse nil)
2467 (gnus-data-update-list (cddr data) offset)))
2469 (defun gnus-data-enter-list (after-article list &optional offset)
2471 (let ((data (and after-article (gnus-data-find-list after-article)))
2475 (let ((odata gnus-newsgroup-data))
2476 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2478 (gnus-data-update-list odata offset)))
2479 ;; Find the last element in the list to be spliced into the main
2482 (setq list (cdr list)))
2485 (setcdr list gnus-newsgroup-data)
2486 (setq gnus-newsgroup-data ilist)
2488 (gnus-data-update-list (cdr list) offset)))
2489 (setcdr list (cdr data))
2492 (gnus-data-update-list (cdr list) offset))))
2493 (setq gnus-newsgroup-data-reverse nil))))
2495 (defun gnus-data-remove (article &optional offset)
2496 (let ((data gnus-newsgroup-data))
2497 (if (= (gnus-data-number (car data)) article)
2499 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2500 gnus-newsgroup-data-reverse nil)
2502 (gnus-data-update-list gnus-newsgroup-data offset)))
2504 (when (= (gnus-data-number (cadr data)) article)
2505 (setcdr data (cddr data))
2507 (gnus-data-update-list (cdr data) offset))
2509 gnus-newsgroup-data-reverse nil))
2510 (setq data (cdr data))))))
2512 (defmacro gnus-data-list (backward)
2514 (or gnus-newsgroup-data-reverse
2515 (setq gnus-newsgroup-data-reverse
2516 (reverse gnus-newsgroup-data)))
2517 gnus-newsgroup-data))
2519 (defun gnus-data-update-list (data offset)
2520 "Add OFFSET to the POS of all data entries in DATA."
2521 (setq gnus-newsgroup-data-reverse nil)
2523 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2524 (setq data (cdr data))))
2526 (defun gnus-summary-article-pseudo-p (article)
2527 "Say whether this article is a pseudo article or not."
2528 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2530 (defmacro gnus-summary-article-sparse-p (article)
2531 "Say whether this article is a sparse article or not."
2532 `(memq ,article gnus-newsgroup-sparse))
2534 (defmacro gnus-summary-article-ancient-p (article)
2535 "Say whether this article is a sparse article or not."
2536 `(memq ,article gnus-newsgroup-ancient))
2538 (defun gnus-article-parent-p (number)
2539 "Say whether this article is a parent or not."
2540 (let ((data (gnus-data-find-list number)))
2541 (and (cdr data) ; There has to be an article after...
2542 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2543 (gnus-data-level (nth 1 data))))))
2545 (defun gnus-article-children (number)
2546 "Return a list of all children to NUMBER."
2547 (let* ((data (gnus-data-find-list number))
2548 (level (gnus-data-level (car data)))
2550 (setq data (cdr data))
2552 (= (gnus-data-level (car data)) (1+ level)))
2553 (push (gnus-data-number (car data)) children)
2554 (setq data (cdr data)))
2557 (defmacro gnus-summary-skip-intangible ()
2558 "If the current article is intangible, then jump to a different article."
2559 '(let ((to (get-text-property (point) 'gnus-intangible)))
2560 (and to (gnus-summary-goto-subject to))))
2562 (defmacro gnus-summary-article-intangible-p ()
2563 "Say whether this article is intangible or not."
2564 '(get-text-property (point) 'gnus-intangible))
2566 (defun gnus-article-read-p (article)
2567 "Say whether ARTICLE is read or not."
2568 (not (or (memq article gnus-newsgroup-marked)
2569 (memq article gnus-newsgroup-unreads)
2570 (memq article gnus-newsgroup-unselected)
2571 (memq article gnus-newsgroup-dormant))))
2573 ;; Some summary mode macros.
2575 (defmacro gnus-summary-article-number ()
2576 "The article number of the article on the current line.
2577 If there isn's an article number here, then we return the current
2580 (gnus-summary-skip-intangible)
2581 (or (get-text-property (point) 'gnus-number)
2582 (gnus-summary-last-subject))))
2584 (defmacro gnus-summary-article-header (&optional number)
2585 "Return the header of article NUMBER."
2586 `(gnus-data-header (gnus-data-find
2587 ,(or number '(gnus-summary-article-number)))))
2589 (defmacro gnus-summary-thread-level (&optional number)
2590 "Return the level of thread that starts with article NUMBER."
2591 `(if (and (eq gnus-summary-make-false-root 'dummy)
2592 (get-text-property (point) 'gnus-intangible))
2594 (gnus-data-level (gnus-data-find
2595 ,(or number '(gnus-summary-article-number))))))
2597 (defmacro gnus-summary-article-mark (&optional number)
2598 "Return the mark of article NUMBER."
2599 `(gnus-data-mark (gnus-data-find
2600 ,(or number '(gnus-summary-article-number)))))
2602 (defmacro gnus-summary-article-pos (&optional number)
2603 "Return the position of the line of article NUMBER."
2604 `(gnus-data-pos (gnus-data-find
2605 ,(or number '(gnus-summary-article-number)))))
2607 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2608 (defmacro gnus-summary-article-subject (&optional number)
2609 "Return current subject string or nil if nothing."
2612 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2613 '(gnus-data-header (assq (gnus-summary-article-number)
2614 gnus-newsgroup-data)))))
2617 (mail-header-subject headers))))
2619 (defmacro gnus-summary-article-score (&optional number)
2620 "Return current article score."
2621 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2622 gnus-newsgroup-scored))
2623 gnus-summary-default-score 0))
2625 (defun gnus-summary-article-children (&optional number)
2626 "Return a list of article numbers that are children of article NUMBER."
2627 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2628 (level (gnus-data-level (car data)))
2630 (while (and (setq data (cdr data))
2631 (> (setq l (gnus-data-level (car data))) level))
2632 (and (= (1+ level) l)
2633 (push (gnus-data-number (car data))
2635 (nreverse children)))
2637 (defun gnus-summary-article-parent (&optional number)
2638 "Return the article number of the parent of article NUMBER."
2639 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2640 (gnus-data-list t)))
2641 (level (gnus-data-level (car data))))
2643 () ; This is a root.
2644 ;; We search until we find an article with a level less than
2645 ;; this one. That function has to be the parent.
2646 (while (and (setq data (cdr data))
2647 (not (< (gnus-data-level (car data)) level))))
2648 (and data (gnus-data-number (car data))))))
2650 (defun gnus-unread-mark-p (mark)
2651 "Say whether MARK is the unread mark."
2652 (= mark gnus-unread-mark))
2654 (defun gnus-read-mark-p (mark)
2655 "Say whether MARK is one of the marks that mark as read.
2656 This is all marks except unread, ticked, dormant, and expirable."
2657 (not (or (= mark gnus-unread-mark)
2658 (= mark gnus-ticked-mark)
2659 (= mark gnus-dormant-mark)
2660 (= mark gnus-expirable-mark))))
2662 (defmacro gnus-article-mark (number)
2663 "Return the MARK of article NUMBER.
2664 This macro should only be used when computing the mark the \"first\"
2665 time; i.e., when generating the summary lines. After that,
2666 `gnus-summary-article-mark' should be used to examine the
2669 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2670 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2671 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2672 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2673 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2674 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2675 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2676 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2677 gnus-ancient-mark))))
2679 ;; Saving hidden threads.
2681 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2682 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2684 (defmacro gnus-save-hidden-threads (&rest forms)
2685 "Save hidden threads, eval FORMS, and restore the hidden threads."
2686 (let ((config (make-symbol "config")))
2687 `(let ((,config (gnus-hidden-threads-configuration)))
2691 (gnus-restore-hidden-threads-configuration ,config)))))
2693 (defun gnus-data-compute-positions ()
2694 "Compute the positions of all articles."
2695 (setq gnus-newsgroup-data-reverse nil)
2696 (let ((data gnus-newsgroup-data))
2698 (gnus-save-hidden-threads
2699 (gnus-summary-show-all-threads)
2700 (goto-char (point-min))
2702 (while (get-text-property (point) 'gnus-intangible)
2704 (gnus-data-set-pos (car data) (+ (point) 3))
2705 (setq data (cdr data))
2706 (forward-line 1))))))
2708 (defun gnus-hidden-threads-configuration ()
2709 "Return the current hidden threads configuration."
2712 (goto-char (point-min))
2713 (while (search-forward "\r" nil t)
2714 (push (1- (point)) config))
2717 (defun gnus-restore-hidden-threads-configuration (config)
2718 "Restore hidden threads configuration from CONFIG."
2720 (let (point buffer-read-only)
2721 (while (setq point (pop config))
2722 (when (and (< point (point-max))
2724 (eq (char-after) ?\n))
2725 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2727 ;; Various summary mode internalish functions.
2729 (defun gnus-mouse-pick-article (e)
2732 (gnus-summary-next-page nil t))
2734 (defun gnus-summary-set-display-table ()
2735 "Change the display table.
2736 Odd characters have a tendency to mess
2737 up nicely formatted displays - we make all possible glyphs
2738 display only a single character."
2740 ;; We start from the standard display table, if any.
2741 (let ((table (or (copy-sequence standard-display-table)
2742 (make-display-table)))
2744 ;; Nix out all the control chars...
2745 (while (>= (setq i (1- i)) 0)
2746 (aset table i [??]))
2747 ;; ... but not newline and cr, of course. (cr is necessary for the
2748 ;; selective display).
2749 (aset table ?\n nil)
2750 (aset table ?\r nil)
2751 ;; We keep TAB as well.
2752 (aset table ?\t nil)
2753 ;; We nix out any glyphs over 126 that are not set already.
2755 (while (>= (setq i (1- i)) 127)
2756 ;; Only modify if the entry is nil.
2757 (unless (aref table i)
2758 (aset table i [??]))))
2759 (setq buffer-display-table table)))
2761 (defun gnus-summary-set-article-display-arrow (pos)
2762 "Update the overlay arrow to point to line at position POS."
2763 (when (and gnus-summary-display-arrow
2764 (boundp 'overlay-arrow-position)
2765 (boundp 'overlay-arrow-string))
2769 (unless overlay-arrow-position
2770 (setq overlay-arrow-position (make-marker)))
2771 (setq overlay-arrow-string "=>"
2772 overlay-arrow-position (set-marker overlay-arrow-position
2774 (current-buffer))))))
2776 (defun gnus-summary-buffer-name (group)
2777 "Return the summary buffer name of GROUP."
2778 (concat "*Summary " group "*"))
2780 (defun gnus-summary-setup-buffer (group)
2781 "Initialize summary buffer."
2782 (let ((buffer (gnus-summary-buffer-name group)))
2783 (if (get-buffer buffer)
2786 (setq gnus-summary-buffer (current-buffer))
2787 (not gnus-newsgroup-prepared))
2788 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2789 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2790 (gnus-summary-mode group)
2792 (gnus-carpal-setup-buffer 'summary))
2793 (unless gnus-single-article-buffer
2794 (make-local-variable 'gnus-article-buffer)
2795 (make-local-variable 'gnus-article-current)
2796 (make-local-variable 'gnus-original-article-buffer))
2797 (setq gnus-newsgroup-name group)
2798 ;; Set any local variables in the group parameters.
2799 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2802 (defun gnus-set-global-variables ()
2803 "Set the global equivalents of the buffer-local variables.
2804 They are set to the latest values they had. These reflect the summary
2805 buffer that was in action when the last article was fetched."
2806 (when (eq major-mode 'gnus-summary-mode)
2807 (setq gnus-summary-buffer (current-buffer))
2808 (let ((name gnus-newsgroup-name)
2809 (marked gnus-newsgroup-marked)
2810 (unread gnus-newsgroup-unreads)
2811 (headers gnus-current-headers)
2812 (data gnus-newsgroup-data)
2813 (summary gnus-summary-buffer)
2814 (article-buffer gnus-article-buffer)
2815 (original gnus-original-article-buffer)
2816 (gac gnus-article-current)
2817 (reffed gnus-reffed-article-number)
2818 (score-file gnus-current-score-file)
2819 (default-charset gnus-newsgroup-charset)
2821 (let ((locals gnus-newsgroup-variables))
2823 (if (consp (car locals))
2824 (push (eval (caar locals)) vlist)
2825 (push (eval (car locals)) vlist))
2826 (setq locals (cdr locals)))
2827 (setq vlist (nreverse vlist)))
2829 (set-buffer gnus-group-buffer)
2830 (setq gnus-newsgroup-name name
2831 gnus-newsgroup-marked marked
2832 gnus-newsgroup-unreads unread
2833 gnus-current-headers headers
2834 gnus-newsgroup-data data
2835 gnus-article-current gac
2836 gnus-summary-buffer summary
2837 gnus-article-buffer article-buffer
2838 gnus-original-article-buffer original
2839 gnus-reffed-article-number reffed
2840 gnus-current-score-file score-file
2841 gnus-newsgroup-charset default-charset)
2842 (let ((locals gnus-newsgroup-variables))
2844 (if (consp (car locals))
2845 (set (caar locals) (pop vlist))
2846 (set (car locals) (pop vlist)))
2847 (setq locals (cdr locals))))
2848 ;; The article buffer also has local variables.
2849 (when (gnus-buffer-live-p gnus-article-buffer)
2850 (set-buffer gnus-article-buffer)
2851 (setq gnus-summary-buffer summary))))))
2853 (defun gnus-summary-article-unread-p (article)
2854 "Say whether ARTICLE is unread or not."
2855 (memq article gnus-newsgroup-unreads))
2857 (defun gnus-summary-first-article-p (&optional article)
2858 "Return whether ARTICLE is the first article in the buffer."
2859 (if (not (setq article (or article (gnus-summary-article-number))))
2861 (eq article (caar gnus-newsgroup-data))))
2863 (defun gnus-summary-last-article-p (&optional article)
2864 "Return whether ARTICLE is the last article in the buffer."
2865 (if (not (setq article (or article (gnus-summary-article-number))))
2866 ;; All non-existent numbers are the last article. :-)
2868 (not (cdr (gnus-data-find-list article)))))
2870 (defun gnus-make-thread-indent-array ()
2872 (unless (and gnus-thread-indent-array
2873 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2874 (setq gnus-thread-indent-array (make-vector 201 "")
2875 gnus-thread-indent-array-level gnus-thread-indent-level)
2877 (aset gnus-thread-indent-array n
2878 (make-string (* n gnus-thread-indent-level) ? ))
2881 (defun gnus-update-summary-mark-positions ()
2882 "Compute where the summary marks are to go."
2884 (when (gnus-buffer-exists-p gnus-summary-buffer)
2885 (set-buffer gnus-summary-buffer))
2886 (let ((gnus-replied-mark 129)
2887 (gnus-score-below-mark 130)
2888 (gnus-score-over-mark 130)
2889 (gnus-download-mark 131)
2890 (spec gnus-summary-line-format-spec)
2893 (gnus-set-work-buffer)
2894 (let ((gnus-summary-line-format-spec spec)
2895 (gnus-newsgroup-downloadable '((0 . t))))
2896 (gnus-summary-insert-line
2897 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2898 0 nil 128 t nil "" nil 1)
2899 (goto-char (point-min))
2900 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2902 (goto-char (point-min))
2903 (push (cons 'replied (and (search-forward "\201" nil t)
2906 (goto-char (point-min))
2907 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2909 (goto-char (point-min))
2910 (push (cons 'download
2911 (and (search-forward "\203" nil t) (- (point) 2)))
2913 (setq gnus-summary-mark-positions pos))))
2915 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2916 "Insert a dummy root in the summary buffer."
2918 (gnus-add-text-properties
2919 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2920 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2922 (defun gnus-summary-extract-address-component (from)
2923 (or (car (funcall gnus-extract-address-components from))
2926 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2927 (let ((mail-parse-charset gnus-newsgroup-charset)
2928 ; Is it really necessary to do this next part for each summary line?
2929 ; Luckily, doesn't seem to slow things down much.
2930 (mail-parse-ignored-charsets
2931 (save-excursion (set-buffer gnus-summary-buffer)
2932 gnus-newsgroup-ignored-charsets)))
2934 (and gnus-ignored-from-addresses
2935 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2936 (let ((extra-headers (mail-header-extra header))
2940 ((setq to (cdr (assq 'To extra-headers)))
2942 (gnus-summary-extract-address-component
2943 (funcall gnus-decode-encoded-word-function to))))
2944 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2945 (concat "=> " newsgroups)))))
2946 (gnus-summary-extract-address-component gnus-tmp-from))))
2948 (defun gnus-summary-insert-line (gnus-tmp-header
2949 gnus-tmp-level gnus-tmp-current
2950 gnus-tmp-unread gnus-tmp-replied
2951 gnus-tmp-expirable gnus-tmp-subject-or-nil
2952 &optional gnus-tmp-dummy gnus-tmp-score
2954 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2955 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2956 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2957 (gnus-tmp-score-char
2958 (if (or (null gnus-summary-default-score)
2959 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2960 gnus-summary-zcore-fuzz))
2962 (if (< gnus-tmp-score gnus-summary-default-score)
2963 gnus-score-below-mark gnus-score-over-mark)))
2964 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2966 (cond (gnus-tmp-process gnus-process-mark)
2967 ((memq gnus-tmp-current gnus-newsgroup-cached)
2969 (gnus-tmp-replied gnus-replied-mark)
2970 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
2971 gnus-forwarded-mark)
2972 ((memq gnus-tmp-current gnus-newsgroup-saved)
2974 ((memq gnus-tmp-number gnus-newsgroup-recent)
2976 ((memq gnus-tmp-number gnus-newsgroup-unseen)
2979 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2982 ((string-match "<[^>]+> *$" gnus-tmp-from)
2983 (let ((beg (match-beginning 0)))
2984 (or (and (string-match "^\".+\"" gnus-tmp-from)
2985 (substring gnus-tmp-from 1 (1- (match-end 0))))
2986 (substring gnus-tmp-from 0 beg))))
2987 ((string-match "(.+)" gnus-tmp-from)
2988 (substring gnus-tmp-from
2989 (1+ (match-beginning 0)) (1- (match-end 0))))
2991 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2992 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2993 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2994 (buffer-read-only nil))
2995 (when (string= gnus-tmp-name "")
2996 (setq gnus-tmp-name gnus-tmp-from))
2997 (unless (numberp gnus-tmp-lines)
2998 (setq gnus-tmp-lines -1))
2999 (if (= gnus-tmp-lines -1)
3000 (setq gnus-tmp-lines "?")
3001 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3002 (gnus-put-text-property
3004 (progn (eval gnus-summary-line-format-spec) (point))
3005 'gnus-number gnus-tmp-number)
3006 (when (gnus-visual-p 'summary-highlight 'highlight)
3008 (gnus-run-hooks 'gnus-summary-update-hook)
3011 (defun gnus-summary-update-line (&optional dont-update)
3012 "Update summary line after change."
3013 (when (and gnus-summary-default-score
3014 (not gnus-summary-inhibit-highlight))
3015 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3016 (article (gnus-summary-article-number))
3017 (score (gnus-summary-article-score article)))
3019 (if (and gnus-summary-mark-below
3020 (< (gnus-summary-article-score)
3021 gnus-summary-mark-below))
3022 ;; This article has a low score, so we mark it as read.
3023 (when (memq article gnus-newsgroup-unreads)
3024 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3025 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3026 ;; This article was previously marked as read on account
3027 ;; of a low score, but now it has risen, so we mark it as
3029 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3030 (gnus-summary-update-mark
3031 (if (or (null gnus-summary-default-score)
3032 (<= (abs (- score gnus-summary-default-score))
3033 gnus-summary-zcore-fuzz))
3035 (if (< score gnus-summary-default-score)
3036 gnus-score-below-mark gnus-score-over-mark))
3038 ;; Do visual highlighting.
3039 (when (gnus-visual-p 'summary-highlight 'highlight)
3040 (gnus-run-hooks 'gnus-summary-update-hook)))))
3042 (defvar gnus-tmp-new-adopts nil)
3044 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3045 "Return the number of articles in THREAD.
3046 This may be 0 in some cases -- if none of the articles in
3047 the thread are to be displayed."
3049 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3051 ((not (listp thread))
3053 ((and (consp thread) (cdr thread))
3056 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3059 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3062 (when (and level (zerop level) gnus-tmp-new-adopts)
3065 'gnus-summary-number-of-articles-in-thread
3066 gnus-tmp-new-adopts))))
3068 (if (> number 1) gnus-not-empty-thread-mark
3069 gnus-empty-thread-mark)
3072 (defun gnus-summary-set-local-parameters (group)
3073 "Go through the local params of GROUP and set all variable specs in that list."
3074 (let ((params (gnus-group-find-parameter group))
3075 (vars '(quit-config)) ; Ignore quit-config.
3078 (setq elem (car params)
3079 params (cdr params))
3080 (and (consp elem) ; Has to be a cons.
3081 (consp (cdr elem)) ; The cdr has to be a list.
3082 (symbolp (car elem)) ; Has to be a symbol in there.
3083 (not (memq (car elem) vars))
3084 (ignore-errors ; So we set it.
3085 (push (car elem) vars)
3086 (make-local-variable (car elem))
3087 (set (car elem) (eval (nth 1 elem))))))))
3089 (defun gnus-summary-read-group (group &optional show-all no-article
3090 kill-buffer no-display backward
3092 "Start reading news in newsgroup GROUP.
3093 If SHOW-ALL is non-nil, already read articles are also listed.
3094 If NO-ARTICLE is non-nil, no article is selected initially.
3095 If NO-DISPLAY, don't generate a summary buffer."
3099 (let ((gnus-auto-select-next nil))
3100 (or (gnus-summary-read-group-1
3101 group show-all no-article
3102 kill-buffer no-display
3105 select-articles nil)))))
3106 (eq gnus-auto-select-next 'quietly))
3107 (set-buffer gnus-group-buffer)
3108 ;; The entry function called above goes to the next
3109 ;; group automatically, so we go two groups back
3110 ;; if we are searching for the previous group.
3112 (gnus-group-prev-unread-group 2))
3113 (if (not (equal group (gnus-group-group-name)))
3114 (setq group (gnus-group-group-name))
3118 (defun gnus-summary-read-group-1 (group show-all no-article
3119 kill-buffer no-display
3120 &optional select-articles)
3121 ;; Killed foreign groups can't be entered.
3122 ;; (when (and (not (gnus-group-native-p group))
3123 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3124 ;; (error "Dead non-native groups can't be entered"))
3125 (gnus-message 5 "Retrieving newsgroup: %s..."
3126 (gnus-group-decoded-name group))
3127 (let* ((new-group (gnus-summary-setup-buffer group))
3128 (quit-config (gnus-group-quit-config group))
3129 (did-select (and new-group (gnus-select-newsgroup
3130 group show-all select-articles))))
3132 ;; This summary buffer exists already, so we just select it.
3134 (gnus-set-global-variables)
3136 (gnus-kill-or-deaden-summary kill-buffer))
3137 (gnus-configure-windows 'summary 'force)
3138 (gnus-set-mode-line 'summary)
3139 (gnus-summary-position-point)
3142 ;; We couldn't select this group.
3144 (when (and (eq major-mode 'gnus-summary-mode)
3145 (not (equal (current-buffer) kill-buffer)))
3146 (kill-buffer (current-buffer))
3147 (if (not quit-config)
3149 ;; Update the info -- marks might need to be removed,
3151 (gnus-summary-update-info)
3152 (set-buffer gnus-group-buffer)
3153 (gnus-group-jump-to-group group)
3154 (gnus-group-next-unread-group 1))
3155 (gnus-handle-ephemeral-exit quit-config)))
3156 (let ((grpinfo (gnus-get-info group)))
3157 (if (null (gnus-info-read grpinfo))
3158 (gnus-message 3 "Group %s contains no messages"
3159 (gnus-group-decoded-name group))
3160 (gnus-message 3 "Can't select group")))
3162 ;; The user did a `C-g' while prompting for number of articles,
3163 ;; so we exit this group.
3164 ((eq did-select 'quit)
3165 (and (eq major-mode 'gnus-summary-mode)
3166 (not (equal (current-buffer) kill-buffer))
3167 (kill-buffer (current-buffer)))
3169 (gnus-kill-or-deaden-summary kill-buffer))
3170 (if (not quit-config)
3172 (set-buffer gnus-group-buffer)
3173 (gnus-group-jump-to-group group)
3174 (gnus-group-next-unread-group 1)
3175 (gnus-configure-windows 'group 'force))
3176 (gnus-handle-ephemeral-exit quit-config))
3177 ;; Finally signal the quit.
3179 ;; The group was successfully selected.
3181 (gnus-set-global-variables)
3182 ;; Save the active value in effect when the group was entered.
3183 (setq gnus-newsgroup-active
3185 (gnus-active gnus-newsgroup-name)))
3186 ;; You can change the summary buffer in some way with this hook.
3187 (gnus-run-hooks 'gnus-select-group-hook)
3188 (gnus-update-format-specifications
3189 nil 'summary 'summary-mode 'summary-dummy)
3190 (gnus-update-summary-mark-positions)
3191 ;; Do score processing.
3192 (when gnus-use-scoring
3193 (gnus-possibly-score-headers))
3194 ;; Check whether to fill in the gaps in the threads.
3195 (when gnus-build-sparse-threads
3196 (gnus-build-sparse-threads))
3197 ;; Find the initial limit.
3198 (if gnus-show-threads
3200 (let ((gnus-newsgroup-dormant nil))
3201 (gnus-summary-initial-limit show-all))
3202 (gnus-summary-initial-limit show-all))
3203 ;; When untreaded, all articles are always shown.
3204 (setq gnus-newsgroup-limit
3206 (lambda (header) (mail-header-number header))
3207 gnus-newsgroup-headers)))
3208 ;; Generate the summary buffer.
3210 (gnus-summary-prepare))
3211 (when gnus-use-trees
3212 (gnus-tree-open group)
3213 (setq gnus-summary-highlight-line-function
3214 'gnus-tree-highlight-article))
3215 ;; If the summary buffer is empty, but there are some low-scored
3216 ;; articles or some excluded dormants, we include these in the
3218 (when (and (zerop (buffer-size))
3220 (cond (gnus-newsgroup-dormant
3221 (gnus-summary-limit-include-dormant))
3222 ((and gnus-newsgroup-scored show-all)
3223 (gnus-summary-limit-include-expunged t))))
3224 ;; Function `gnus-apply-kill-file' must be called in this hook.
3225 (gnus-run-hooks 'gnus-apply-kill-hook)
3226 (if (and (zerop (buffer-size))
3229 ;; This newsgroup is empty.
3230 (gnus-summary-catchup-and-exit nil t)
3231 (gnus-message 6 "No unread news")
3233 (gnus-kill-or-deaden-summary kill-buffer))
3234 ;; Return nil from this function.
3236 ;; Hide conversation thread subtrees. We cannot do this in
3237 ;; gnus-summary-prepare-hook since kill processing may not
3238 ;; work with hidden articles.
3239 (and gnus-show-threads
3240 gnus-thread-hide-subtree
3241 (gnus-summary-hide-all-threads))
3243 (gnus-kill-or-deaden-summary kill-buffer))
3244 ;; Show first unread article if requested.
3245 (if (and (not no-article)
3247 gnus-newsgroup-unreads
3248 gnus-auto-select-first)
3250 (gnus-configure-windows 'summary)
3252 ((eq gnus-auto-select-first 'best)
3253 (gnus-summary-best-unread-article))
3254 ((eq gnus-auto-select-first t)
3255 (gnus-summary-first-unread-article))
3256 ((gnus-functionp gnus-auto-select-first)
3257 (funcall gnus-auto-select-first))))
3258 ;; Don't select any articles, just move point to the first
3259 ;; article in the group.
3260 (goto-char (point-min))
3261 (gnus-summary-position-point)
3262 (gnus-configure-windows 'summary 'force)
3263 (gnus-set-mode-line 'summary))
3264 (when (get-buffer-window gnus-group-buffer t)
3265 ;; Gotta use windows, because recenter does weird stuff if
3266 ;; the current buffer ain't the displayed window.
3267 (let ((owin (selected-window)))
3268 (select-window (get-buffer-window gnus-group-buffer t))
3269 (when (gnus-group-goto-group group)
3271 (select-window owin)))
3272 ;; Mark this buffer as "prepared".
3273 (setq gnus-newsgroup-prepared t)
3274 (gnus-run-hooks 'gnus-summary-prepared-hook)
3277 (defun gnus-summary-prepare ()
3278 "Generate the summary buffer."
3280 (let ((buffer-read-only nil))
3282 (setq gnus-newsgroup-data nil
3283 gnus-newsgroup-data-reverse nil)
3284 (gnus-run-hooks 'gnus-summary-generate-hook)
3285 ;; Generate the buffer, either with threads or without.
3286 (when gnus-newsgroup-headers
3287 (gnus-summary-prepare-threads
3288 (if gnus-show-threads
3289 (gnus-sort-gathered-threads
3290 (funcall gnus-summary-thread-gathering-function
3292 (gnus-cut-threads (gnus-make-threads)))))
3293 ;; Unthreaded display.
3294 (gnus-sort-articles gnus-newsgroup-headers))))
3295 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3296 ;; Call hooks for modifying summary buffer.
3297 (goto-char (point-min))
3298 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3300 (defsubst gnus-general-simplify-subject (subject)
3301 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3304 ;; Truncate the subject.
3305 (gnus-simplify-subject-functions
3306 (gnus-map-function gnus-simplify-subject-functions subject))
3307 ((numberp gnus-summary-gather-subject-limit)
3308 (setq subject (gnus-simplify-subject-re subject))
3309 (if (> (length subject) gnus-summary-gather-subject-limit)
3310 (substring subject 0 gnus-summary-gather-subject-limit)
3312 ;; Fuzzily simplify it.
3313 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3314 (gnus-simplify-subject-fuzzy subject))
3315 ;; Just remove the leading "Re:".
3317 (gnus-simplify-subject-re subject))))
3319 (if (and gnus-summary-gather-exclude-subject
3320 (string-match gnus-summary-gather-exclude-subject subject))
3321 nil ; This article shouldn't be gathered
3324 (defun gnus-summary-simplify-subject-query ()
3325 "Query where the respool algorithm would put this article."
3327 (gnus-summary-select-article)
3328 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3330 (defun gnus-gather-threads-by-subject (threads)
3331 "Gather threads by looking at Subject headers."
3332 (if (not gnus-summary-make-false-root)
3334 (let ((hashtb (gnus-make-hashtable 1024))
3337 subject hthread whole-subject)
3339 (setq subject (gnus-general-simplify-subject
3340 (setq whole-subject (mail-header-subject
3343 (if (setq hthread (gnus-gethash subject hashtb))
3345 ;; We enter a dummy root into the thread, if we
3346 ;; haven't done that already.
3347 (unless (stringp (caar hthread))
3348 (setcar hthread (list whole-subject (car hthread))))
3349 ;; We add this new gathered thread to this gathered
3351 (setcdr (car hthread)
3352 (nconc (cdar hthread) (list (car threads))))
3353 ;; Remove it from the list of threads.
3354 (setcdr prev (cdr threads))
3355 (setq threads prev))
3356 ;; Enter this thread into the hash table.
3357 (gnus-sethash subject threads hashtb)))
3359 (setq threads (cdr threads)))
3362 (defun gnus-gather-threads-by-references (threads)
3363 "Gather threads by looking at References headers."
3364 (let ((idhashtb (gnus-make-hashtable 1024))
3365 (thhashtb (gnus-make-hashtable 1024))
3368 ids references id gthread gid entered ref)
3370 (when (setq references (mail-header-references (caar threads)))
3371 (setq id (mail-header-id (caar threads))
3372 ids (gnus-split-references references)
3374 (while (setq ref (pop ids))
3375 (setq ids (delete ref ids))
3376 (if (not (setq gid (gnus-gethash ref idhashtb)))
3378 (gnus-sethash ref id idhashtb)
3379 (gnus-sethash id threads thhashtb))
3380 (setq gthread (gnus-gethash gid thhashtb))
3382 ;; We enter a dummy root into the thread, if we
3383 ;; haven't done that already.
3384 (unless (stringp (caar gthread))
3385 (setcar gthread (list (mail-header-subject (caar gthread))
3387 ;; We add this new gathered thread to this gathered
3389 (setcdr (car gthread)
3390 (nconc (cdar gthread) (list (car threads)))))
3391 ;; Add it into the thread hash table.
3392 (gnus-sethash id gthread thhashtb)
3394 ;; Remove it from the list of threads.
3395 (setcdr prev (cdr threads))
3396 (setq threads prev))))
3398 (setq threads (cdr threads)))
3401 (defun gnus-sort-gathered-threads (threads)
3402 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3403 (let ((result threads))
3405 (when (stringp (caar threads))
3406 (setcdr (car threads)
3407 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3408 (setq threads (cdr threads)))
3411 (defun gnus-thread-loop-p (root thread)
3412 "Say whether ROOT is in THREAD."
3413 (let ((stack (list thread))
3416 (while (setq thread (pop stack))
3417 (setq th (cdr thread))
3419 (not (eq (caar th) root)))
3422 ;; We have found a loop.
3424 (setcdr thread (delq (car th) (cdr thread)))
3425 (if (boundp (setq ref-dep (intern "none"
3426 gnus-newsgroup-dependencies)))
3427 (setcdr (symbol-value ref-dep)
3428 (nconc (cdr (symbol-value ref-dep))
3430 (set ref-dep (list nil (car th))))
3433 ;; Push all the subthreads onto the stack.
3434 (push (cdr thread) stack)))
3437 (defun gnus-make-threads ()
3438 "Go through the dependency hashtb and find the roots. Return all threads."
3440 (while (catch 'infloop
3443 ;; Deal with self-referencing References loops.
3444 (when (and (car (symbol-value refs))
3451 (car (symbol-value refs)) thread))
3452 (cdr (symbol-value refs)))))))
3455 (unless (car (symbol-value refs))
3456 ;; These threads do not refer back to any other articles,
3457 ;; so they're roots.
3458 (setq threads (append (cdr (symbol-value refs)) threads))))
3459 gnus-newsgroup-dependencies)))
3462 ;; Build the thread tree.
3463 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3464 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3466 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3467 if it was already present.
3469 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3470 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3471 Message-IDs will be renamed be renamed to a unique Message-ID before
3474 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3475 (let* ((id (mail-header-id header))
3476 (id-dep (and id (intern id dependencies)))
3477 ref ref-dep ref-header)
3478 ;; Enter this `header' in the `dependencies' table.
3482 ;; The first two cases do the normal part: enter a new `header'
3483 ;; in the `dependencies' table.
3484 ((not (boundp id-dep))
3485 (set id-dep (list header)))
3486 ((null (car (symbol-value id-dep)))
3487 (setcar (symbol-value id-dep) header))
3489 ;; From here the `header' was already present in the
3490 ;; `dependencies' table.
3492 ;; Overrides an existing entry;
3493 ;; just set the header part of the entry.
3494 (setcar (symbol-value id-dep) header))
3496 ;; Renames the existing `header' to a unique Message-ID.
3497 ((not gnus-summary-ignore-duplicates)
3498 ;; An article with this Message-ID has already been seen.
3499 ;; We rename the Message-ID.
3500 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3502 (mail-header-set-id header id))
3504 ;; The last case ignores an existing entry, except it adds any
3505 ;; additional Xrefs (in case the two articles came from different
3507 ;; Also sets `header' to `nil' meaning that the `dependencies'
3508 ;; table was *not* modified.
3510 (mail-header-set-xref
3511 (car (symbol-value id-dep))
3512 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3514 (or (mail-header-xref header) "")))
3518 ;; First check if that we are not creating a References loop.
3519 (setq ref (gnus-parent-id (mail-header-references header)))
3521 (setq ref-dep (intern-soft ref dependencies))
3523 (setq ref-header (car (symbol-value ref-dep))))
3524 (if (string= id ref)
3525 ;; Yuk! This is a reference loop. Make the article be a
3528 (mail-header-set-references (car (symbol-value id-dep)) "none")
3530 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3531 (setq ref (gnus-parent-id (mail-header-references header)))
3532 (setq ref-dep (intern (or ref "none") dependencies))
3533 (if (boundp ref-dep)
3534 (setcdr (symbol-value ref-dep)
3535 (nconc (cdr (symbol-value ref-dep))
3536 (list (symbol-value id-dep))))
3537 (set ref-dep (list nil (symbol-value id-dep)))))
3540 (defun gnus-build-sparse-threads ()
3541 (let ((headers gnus-newsgroup-headers)
3542 (mail-parse-charset gnus-newsgroup-charset)
3543 (gnus-summary-ignore-duplicates t)
3544 header references generation relations
3545 subject child end new-child date)
3546 ;; First we create an alist of generations/relations, where
3547 ;; generations is how much we trust the relation, and the relation
3549 (gnus-message 7 "Making sparse threads...")
3551 (nnheader-set-temp-buffer " *gnus sparse threads*")
3552 (while (setq header (pop headers))
3553 (when (and (setq references (mail-header-references header))
3554 (not (string= references "")))
3556 (setq child (mail-header-id header)
3557 subject (mail-header-subject header)
3558 date (mail-header-date header)
3560 (while (search-backward ">" nil t)
3561 (setq end (1+ (point)))
3562 (when (search-backward "<" nil t)
3563 (setq new-child (buffer-substring (point) end))
3564 (push (list (incf generation)
3565 child (setq child new-child)
3569 (push (list (1+ generation) child nil subject) relations))
3571 (kill-buffer (current-buffer)))
3572 ;; Sort over trustworthiness.
3575 (when (gnus-dependencies-add-header
3576 (make-full-mail-header
3577 gnus-reffed-article-number
3578 (nth 3 relation) "" (or (nth 4 relation) "")
3580 (or (nth 2 relation) "") 0 0 "")
3581 gnus-newsgroup-dependencies nil)
3582 (push gnus-reffed-article-number gnus-newsgroup-limit)
3583 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3584 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3585 gnus-newsgroup-reads)
3586 (decf gnus-reffed-article-number)))
3587 (sort relations 'car-less-than-car))
3588 (gnus-message 7 "Making sparse threads...done")))
3590 (defun gnus-build-old-threads ()
3591 ;; Look at all the articles that refer back to old articles, and
3592 ;; fetch the headers for the articles that aren't there. This will
3593 ;; build complete threads - if the roots haven't been expired by the
3595 (let ((mail-parse-charset gnus-newsgroup-charset)
3599 (when (not (car (symbol-value refs)))
3600 (setq heads (cdr (symbol-value refs)))
3602 (if (memq (mail-header-number (caar heads))
3603 gnus-newsgroup-dormant)
3604 (setq heads (cdr heads))
3605 (setq id (symbol-name refs))
3606 (while (and (setq id (gnus-build-get-header id))
3607 (not (car (gnus-id-to-thread id)))))
3608 (setq heads nil)))))
3609 gnus-newsgroup-dependencies)))
3611 ;; This function has to be called with point after the article number
3612 ;; on the beginning of the line.
3613 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3614 (let ((eol (gnus-point-at-eol))
3615 (buffer (current-buffer))
3618 ;; overview: [num subject from date id refs chars lines misc]
3621 (narrow-to-region (point) eol)
3626 (make-full-mail-header
3628 (funcall gnus-decode-encoded-word-function
3629 (nnheader-nov-field)) ; subject
3630 (funcall gnus-decode-encoded-word-function
3631 (nnheader-nov-field)) ; from
3632 (nnheader-nov-field) ; date
3633 (nnheader-nov-read-message-id) ; id
3634 (nnheader-nov-field) ; refs
3635 (nnheader-nov-read-integer) ; chars
3636 (nnheader-nov-read-integer) ; lines
3638 (if (looking-at "Xref: ")
3639 (goto-char (match-end 0)))
3640 (nnheader-nov-field)) ; Xref
3641 (nnheader-nov-parse-extra)))) ; extra
3645 (when gnus-alter-header-function
3646 (funcall gnus-alter-header-function header))
3647 (gnus-dependencies-add-header header dependencies force-new)))
3649 (defun gnus-build-get-header (id)
3650 "Look through the buffer of NOV lines and find the header to ID.
3651 Enter this line into the dependencies hash table, and return
3652 the id of the parent article (if any)."
3653 (let ((deps gnus-newsgroup-dependencies)
3657 (set-buffer nntp-server-buffer)
3658 (let ((case-fold-search nil))
3659 (goto-char (point-min))
3660 (while (and (not found)
3661 (search-forward id nil t))
3663 (setq found (looking-at
3664 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3665 (regexp-quote id))))
3666 (or found (beginning-of-line 2)))
3670 (setq header (gnus-nov-parse-line
3671 (read (current-buffer)) deps))
3672 (gnus-parent-id (mail-header-references header))))))
3674 (let ((number (mail-header-number header)))
3675 (push number gnus-newsgroup-limit)
3676 (push header gnus-newsgroup-headers)
3677 (if (memq number gnus-newsgroup-unselected)
3679 (push number gnus-newsgroup-unreads)
3680 (setq gnus-newsgroup-unselected
3681 (delq number gnus-newsgroup-unselected)))
3682 (push number gnus-newsgroup-ancient)))))))
3684 (defun gnus-build-all-threads ()
3685 "Read all the headers."
3686 (let ((gnus-summary-ignore-duplicates t)
3687 (mail-parse-charset gnus-newsgroup-charset)
3688 (dependencies gnus-newsgroup-dependencies)
3691 (set-buffer nntp-server-buffer)
3692 (let ((case-fold-search nil))
3693 (goto-char (point-min))
3696 (setq article (read (current-buffer))
3697 header (gnus-nov-parse-line article dependencies)))
3700 (set-buffer gnus-summary-buffer)
3701 (push header gnus-newsgroup-headers)
3702 (if (memq (setq article (mail-header-number header))
3703 gnus-newsgroup-unselected)
3705 (push article gnus-newsgroup-unreads)
3706 (setq gnus-newsgroup-unselected
3707 (delq article gnus-newsgroup-unselected)))
3708 (push article gnus-newsgroup-ancient)))
3709 (forward-line 1)))))))
3711 (defun gnus-summary-update-article-line (article header)
3712 "Update the line for ARTICLE using HEADERS."
3713 (let* ((id (mail-header-id header))
3714 (thread (gnus-id-to-thread id)))
3716 (error "Article in no thread"))
3717 ;; Update the thread.
3718 (setcar thread header)
3719 (gnus-summary-goto-subject article)
3720 (let* ((datal (gnus-data-find-list article))
3722 (length (when (cdr datal)
3723 (- (gnus-data-pos data)
3724 (gnus-data-pos (cadr datal)))))
3725 (buffer-read-only nil)
3726 (level (gnus-summary-thread-level)))
3728 (gnus-summary-insert-line
3729 header level nil (gnus-article-mark article)
3730 (memq article gnus-newsgroup-replied)
3731 (memq article gnus-newsgroup-expirable)
3732 ;; Only insert the Subject string when it's different
3733 ;; from the previous Subject string.
3738 (mail-header-subject
3741 (gnus-data-find-list
3743 (gnus-data-list t)))))
3744 ;; Error on the side of excessive subjects.
3746 (mail-header-subject header)))
3748 (mail-header-subject header))
3749 nil (cdr (assq article gnus-newsgroup-scored))
3750 (memq article gnus-newsgroup-processable))
3752 (gnus-data-update-list
3753 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3755 (defun gnus-summary-update-article (article &optional iheader)
3756 "Update ARTICLE in the summary buffer."
3757 (set-buffer gnus-summary-buffer)
3758 (let* ((header (gnus-summary-article-header article))
3759 (id (mail-header-id header))
3760 (data (gnus-data-find article))
3761 (thread (gnus-id-to-thread id))
3762 (references (mail-header-references header))
3766 (when (and references
3767 (not (equal "" references)))
3770 (buffer-read-only nil)
3776 (delq thread parent)))
3777 (if (gnus-summary-insert-subject id header)
3778 ;; Set the (possibly) new article number in the data structure.
3779 (gnus-data-set-number data (gnus-id-to-article id))
3783 (defun gnus-rebuild-thread (id &optional line)
3784 "Rebuild the thread containing ID.
3785 If LINE, insert the rebuilt thread starting on line LINE."
3786 (let ((buffer-read-only nil)
3787 old-pos current thread data)
3788 (if (not gnus-show-threads)
3789 (setq thread (list (car (gnus-id-to-thread id))))
3790 ;; Get the thread this article is part of.
3791 (setq thread (gnus-remove-thread id)))
3792 (setq old-pos (gnus-point-at-bol))
3793 (setq current (save-excursion
3794 (and (re-search-backward "[\r\n]" nil t)
3795 (gnus-summary-article-number))))
3796 ;; If this is a gathered thread, we have to go some re-gathering.
3797 (when (stringp (car thread))
3798 (let ((subject (car thread))
3800 (setq thread (cdr thread))
3802 (unless (memq (setq thr (gnus-id-to-thread
3804 (mail-header-id (caar thread)))))
3807 (setq thread (cdr thread)))
3808 ;; We now have all (unique) roots.
3809 (if (= (length roots) 1)
3810 ;; All the loose roots are now one solid root.
3811 (setq thread (car roots))
3812 (setq thread (cons subject (gnus-sort-threads roots))))))
3814 ;; We then insert this thread into the summary buffer.
3816 (goto-char (point-min))
3817 (forward-line (1- line)))
3818 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3819 (if gnus-show-threads
3820 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3821 (gnus-summary-prepare-unthreaded thread))
3822 (setq data (nreverse gnus-newsgroup-data))
3823 (setq threads gnus-newsgroup-threads))
3824 ;; We splice the new data into the data structure.
3825 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3826 ;;!!! then we want to insert at the beginning of the buffer.
3827 ;;!!! That happens to be true with Gnus now, but that may
3828 ;;!!! change in the future. Perhaps.
3829 (gnus-data-enter-list
3830 (if line nil current) data (- (point) old-pos))
3831 (setq gnus-newsgroup-threads
3832 (nconc threads gnus-newsgroup-threads))
3833 (gnus-data-compute-positions))))
3835 (defun gnus-number-to-header (number)
3836 "Return the header for article NUMBER."
3837 (let ((headers gnus-newsgroup-headers))
3839 (not (= number (mail-header-number (car headers)))))
3844 (defun gnus-parent-headers (in-headers &optional generation)
3845 "Return the headers of the GENERATIONeth parent of HEADERS."
3847 (setq generation 1))
3849 (headers in-headers)
3852 (not (zerop generation))
3853 (setq references (mail-header-references headers)))
3854 (setq headers (if (and references
3855 (setq parent (gnus-parent-id references)))
3856 (car (gnus-id-to-thread parent))
3859 (and (not (eq headers in-headers))
3862 (defun gnus-id-to-thread (id)
3863 "Return the (sub-)thread where ID appears."
3864 (gnus-gethash id gnus-newsgroup-dependencies))
3866 (defun gnus-id-to-article (id)
3867 "Return the article number of ID."
3868 (let ((thread (gnus-id-to-thread id)))
3871 (mail-header-number (car thread)))))
3873 (defun gnus-id-to-header (id)
3874 "Return the article headers of ID."
3875 (car (gnus-id-to-thread id)))
3877 (defun gnus-article-displayed-root-p (article)
3878 "Say whether ARTICLE is a root(ish) article."
3879 (let ((level (gnus-summary-thread-level article))
3880 (refs (mail-header-references (gnus-summary-article-header article)))
3886 ((null (gnus-parent-id refs)) t)
3888 (null (setq particle (gnus-id-to-article
3889 (gnus-parent-id refs))))
3890 (null (gnus-summary-thread-level particle)))))))
3892 (defun gnus-root-id (id)
3893 "Return the id of the root of the thread where ID appears."
3895 (while (and id (setq prev (car (gnus-id-to-thread id))))
3897 id (gnus-parent-id (mail-header-references prev))))
3900 (defun gnus-articles-in-thread (thread)
3901 "Return the list of articles in THREAD."
3902 (cons (mail-header-number (car thread))
3903 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3905 (defun gnus-remove-thread (id &optional dont-remove)
3906 "Remove the thread that has ID in it."
3907 (let (headers thread last-id)
3908 ;; First go up in this thread until we find the root.
3909 (setq last-id (gnus-root-id id)
3910 headers (message-flatten-list (gnus-id-to-thread last-id)))
3911 ;; We have now found the real root of this thread. It might have
3912 ;; been gathered into some loose thread, so we have to search
3913 ;; through the threads to find the thread we wanted.
3914 (let ((threads gnus-newsgroup-threads)
3917 (setq sub (car threads))
3918 (if (stringp (car sub))
3919 ;; This is a gathered thread, so we look at the roots
3920 ;; below it to find whether this article is in this
3923 (setq sub (cdr sub))
3925 (when (member (caar sub) headers)
3926 (setq thread (car threads)
3929 (setq sub (cdr sub))))
3930 ;; It's an ordinary thread, so we check it.
3931 (when (eq (car sub) (car headers))
3934 (setq threads (cdr threads)))
3935 ;; If this article is in no thread, then it's a root.
3938 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3939 (setq thread (gnus-id-to-thread last-id)))
3942 thread ; We return this thread.
3944 (if (stringp (car thread))
3946 ;; If we use dummy roots, then we have to remove the
3947 ;; dummy root as well.
3948 (when (eq gnus-summary-make-false-root 'dummy)
3949 ;; We go to the dummy root by going to
3950 ;; the first sub-"thread", and then one line up.
3951 (gnus-summary-goto-article
3952 (mail-header-number (caadr thread)))
3955 (gnus-data-compute-positions))
3956 (setq thread (cdr thread))
3958 (gnus-remove-thread-1 (car thread))
3959 (setq thread (cdr thread))))
3960 (gnus-remove-thread-1 thread))))))))
3962 (defun gnus-remove-thread-1 (thread)
3963 "Remove the thread THREAD recursively."
3964 (let ((number (mail-header-number (pop thread)))
3966 (setq thread (reverse thread))
3968 (gnus-remove-thread-1 (pop thread)))
3969 (when (setq d (gnus-data-find number))
3970 (goto-char (gnus-data-pos d))
3971 (gnus-summary-show-thread)
3974 (- (gnus-point-at-bol)
3976 (1+ (gnus-point-at-eol))
3977 (gnus-delete-line)))))))
3979 (defun gnus-sort-threads-1 (threads func)
3980 (sort (mapcar (lambda (thread)
3983 (gnus-sort-threads-1 (cdr thread) func))))
3986 (defun gnus-sort-threads (threads)
3988 (if (not gnus-thread-sort-functions)
3990 (gnus-message 8 "Sorting threads...")
3992 (gnus-sort-threads-1
3994 (gnus-make-sort-function gnus-thread-sort-functions))
3995 (gnus-message 8 "Sorting threads...done"))))
3997 (defun gnus-sort-articles (articles)
3999 (when gnus-article-sort-functions
4000 (gnus-message 7 "Sorting articles...")
4002 (setq gnus-newsgroup-headers
4003 (sort articles (gnus-make-sort-function
4004 gnus-article-sort-functions)))
4005 (gnus-message 7 "Sorting articles...done"))))
4007 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4008 (defmacro gnus-thread-header (thread)
4009 "Return header of first article in THREAD.
4010 Note that THREAD must never, ever be anything else than a variable -
4011 using some other form will lead to serious barfage."
4012 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4013 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4014 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4017 (defsubst gnus-article-sort-by-number (h1 h2)
4018 "Sort articles by article number."
4019 (< (mail-header-number h1)
4020 (mail-header-number h2)))
4022 (defun gnus-thread-sort-by-number (h1 h2)
4023 "Sort threads by root article number."
4024 (gnus-article-sort-by-number
4025 (gnus-thread-header h1) (gnus-thread-header h2)))
4027 (defsubst gnus-article-sort-by-lines (h1 h2)
4028 "Sort articles by article Lines header."
4029 (< (mail-header-lines h1)
4030 (mail-header-lines h2)))
4032 (defun gnus-thread-sort-by-lines (h1 h2)
4033 "Sort threads by root article Lines header."
4034 (gnus-article-sort-by-lines
4035 (gnus-thread-header h1) (gnus-thread-header h2)))
4037 (defsubst gnus-article-sort-by-chars (h1 h2)
4038 "Sort articles by octet length."
4039 (< (mail-header-chars h1)
4040 (mail-header-chars h2)))
4042 (defun gnus-thread-sort-by-chars (h1 h2)
4043 "Sort threads by root article octet length."
4044 (gnus-article-sort-by-chars
4045 (gnus-thread-header h1) (gnus-thread-header h2)))
4047 (defsubst gnus-article-sort-by-author (h1 h2)
4048 "Sort articles by root author."
4050 (let ((extract (funcall
4051 gnus-extract-address-components
4052 (mail-header-from h1))))
4053 (or (car extract) (cadr extract) ""))
4054 (let ((extract (funcall
4055 gnus-extract-address-components
4056 (mail-header-from h2))))
4057 (or (car extract) (cadr extract) ""))))
4059 (defun gnus-thread-sort-by-author (h1 h2)
4060 "Sort threads by root author."
4061 (gnus-article-sort-by-author
4062 (gnus-thread-header h1) (gnus-thread-header h2)))
4064 (defsubst gnus-article-sort-by-subject (h1 h2)
4065 "Sort articles by root subject."
4067 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4068 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4070 (defun gnus-thread-sort-by-subject (h1 h2)
4071 "Sort threads by root subject."
4072 (gnus-article-sort-by-subject
4073 (gnus-thread-header h1) (gnus-thread-header h2)))
4075 (defsubst gnus-article-sort-by-date (h1 h2)
4076 "Sort articles by root article date."
4078 (gnus-date-get-time (mail-header-date h1))
4079 (gnus-date-get-time (mail-header-date h2))))
4081 (defun gnus-thread-sort-by-date (h1 h2)
4082 "Sort threads by root article date."
4083 (gnus-article-sort-by-date
4084 (gnus-thread-header h1) (gnus-thread-header h2)))
4086 (defsubst gnus-article-sort-by-score (h1 h2)
4087 "Sort articles by root article score.
4088 Unscored articles will be counted as having a score of zero."
4089 (> (or (cdr (assq (mail-header-number h1)
4090 gnus-newsgroup-scored))
4091 gnus-summary-default-score 0)
4092 (or (cdr (assq (mail-header-number h2)
4093 gnus-newsgroup-scored))
4094 gnus-summary-default-score 0)))
4096 (defun gnus-thread-sort-by-score (h1 h2)
4097 "Sort threads by root article score."
4098 (gnus-article-sort-by-score
4099 (gnus-thread-header h1) (gnus-thread-header h2)))
4101 (defun gnus-thread-sort-by-total-score (h1 h2)
4102 "Sort threads by the sum of all scores in the thread.
4103 Unscored articles will be counted as having a score of zero."
4104 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4106 (defun gnus-thread-total-score (thread)
4107 ;; This function find the total score of THREAD.
4108 (cond ((null thread)
4111 (if (stringp (car thread))
4112 (apply gnus-thread-score-function 0
4113 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4114 (gnus-thread-total-score-1 thread)))
4116 (gnus-thread-total-score-1 (list thread)))))
4118 (defun gnus-thread-total-score-1 (root)
4119 ;; This function find the total score of the thread below ROOT.
4120 (setq root (car root))
4121 (apply gnus-thread-score-function
4123 (mapcar 'gnus-thread-total-score
4124 (cdr (gnus-id-to-thread (mail-header-id root))))
4125 (when (> (mail-header-number root) 0)
4126 (list (or (cdr (assq (mail-header-number root)
4127 gnus-newsgroup-scored))
4128 gnus-summary-default-score 0))))
4129 (list gnus-summary-default-score)
4132 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4133 (defvar gnus-tmp-prev-subject nil)
4134 (defvar gnus-tmp-false-parent nil)
4135 (defvar gnus-tmp-root-expunged nil)
4136 (defvar gnus-tmp-dummy-line nil)
4138 (eval-when-compile (defvar gnus-tmp-header))
4139 (defun gnus-extra-header (type &optional header)
4140 "Return the extra header of TYPE."
4141 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4144 (defvar gnus-tmp-thread-tree-header-string "")
4146 (defvar gnus-sum-thread-tree-root "> "
4147 "With %B spec, used for the root of a thread.
4148 If nil, use subject instead.")
4149 (defvar gnus-sum-thread-tree-single-indent ""
4150 "With %B spec, used for a thread with just one message.
4151 If nil, use subject instead.")
4152 (defvar gnus-sum-thread-tree-vertical "| "
4153 "With %B spec, used for drawing a vertical line.")
4154 (defvar gnus-sum-thread-tree-indent " "
4155 "With %B spec, used for indenting.")
4156 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4157 "With %B spec, used for a leaf with brothers.")
4158 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4159 "With %B spec, used for a leaf without brothers.")
4161 (defun gnus-summary-prepare-threads (threads)
4162 "Prepare summary buffer from THREADS and indentation LEVEL.
4163 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4164 or a straight list of headers."
4165 (gnus-message 7 "Generating summary...")
4167 (setq gnus-newsgroup-threads threads)
4170 (let ((gnus-tmp-level 0)
4171 (default-score (or gnus-summary-default-score 0))
4172 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4173 thread number subject stack state gnus-tmp-gathered beg-match
4174 new-roots gnus-tmp-new-adopts thread-end
4175 gnus-tmp-header gnus-tmp-unread
4176 gnus-tmp-replied gnus-tmp-subject-or-nil
4177 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4178 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4179 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4182 (setq gnus-tmp-prev-subject nil)
4184 (if (vectorp (car threads))
4185 ;; If this is a straight (sic) list of headers, then a
4186 ;; threaded summary display isn't required, so we just create
4187 ;; an unthreaded one.
4188 (gnus-summary-prepare-unthreaded threads)
4190 ;; Do the threaded display.
4192 (while (or threads stack gnus-tmp-new-adopts new-roots)
4194 (if (and (= gnus-tmp-level 0)
4197 (not gnus-tmp-false-parent)
4198 (or gnus-tmp-new-adopts new-roots))
4199 (if gnus-tmp-new-adopts
4200 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4201 thread (list (car gnus-tmp-new-adopts))
4202 gnus-tmp-header (caar thread)
4203 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4205 (setq thread (list (car new-roots))
4206 gnus-tmp-header (caar thread)
4207 new-roots (cdr new-roots))))
4210 ;; If there are some threads, we do them before the
4211 ;; threads on the stack.
4212 (setq thread threads
4213 gnus-tmp-header (caar thread))
4214 ;; There were no current threads, so we pop something off
4216 (setq state (car stack)
4217 gnus-tmp-level (car state)
4218 tree-stack (cadr state)
4219 thread (caddr state)
4221 gnus-tmp-header (caar thread))))
4223 (setq gnus-tmp-false-parent nil)
4224 (setq gnus-tmp-root-expunged nil)
4225 (setq thread-end nil)
4227 (if (stringp gnus-tmp-header)
4228 ;; The header is a dummy root.
4230 ((eq gnus-summary-make-false-root 'adopt)
4231 ;; We let the first article adopt the rest.
4232 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4234 (setq gnus-tmp-gathered
4236 (lambda (h) (mail-header-number (car h)))
4239 (setq thread (cons (list (caar thread)
4242 (setq gnus-tmp-level -1
4243 gnus-tmp-false-parent t))
4244 ((eq gnus-summary-make-false-root 'empty)
4245 ;; We print adopted articles with empty subject fields.
4246 (setq gnus-tmp-gathered
4248 (lambda (h) (mail-header-number (car h)))
4251 (setq gnus-tmp-level -1))
4252 ((eq gnus-summary-make-false-root 'dummy)
4253 ;; We remember that we probably want to output a dummy
4255 (setq gnus-tmp-dummy-line gnus-tmp-header)
4256 (setq gnus-tmp-prev-subject gnus-tmp-header))
4258 ;; We do not make a root for the gathered
4259 ;; sub-threads at all.
4260 (setq gnus-tmp-level -1)))
4262 (setq number (mail-header-number gnus-tmp-header)
4263 subject (mail-header-subject gnus-tmp-header))
4266 ;; If the thread has changed subject, we might want to make
4267 ;; this subthread into a root.
4268 ((and (null gnus-thread-ignore-subject)
4269 (not (zerop gnus-tmp-level))
4270 gnus-tmp-prev-subject
4272 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4273 (setq new-roots (nconc new-roots (list (car thread)))
4275 gnus-tmp-header nil))
4276 ;; If the article lies outside the current limit,
4277 ;; then we do not display it.
4278 ((not (memq number gnus-newsgroup-limit))
4279 (setq gnus-tmp-gathered
4281 (lambda (h) (mail-header-number (car h)))
4284 (setq gnus-tmp-new-adopts (if (cdar thread)
4285 (append gnus-tmp-new-adopts
4287 gnus-tmp-new-adopts)
4289 gnus-tmp-header nil)
4290 (when (zerop gnus-tmp-level)
4291 (setq gnus-tmp-root-expunged t)))
4292 ;; Perhaps this article is to be marked as read?
4293 ((and gnus-summary-mark-below
4294 (< (or (cdr (assq number gnus-newsgroup-scored))
4296 gnus-summary-mark-below)
4297 ;; Don't touch sparse articles.
4298 (not (gnus-summary-article-sparse-p number))
4299 (not (gnus-summary-article-ancient-p number)))
4300 (setq gnus-newsgroup-unreads
4301 (delq number gnus-newsgroup-unreads))
4302 (if gnus-newsgroup-auto-expire
4303 (push number gnus-newsgroup-expirable)
4304 (push (cons number gnus-low-score-mark)
4305 gnus-newsgroup-reads))))
4307 (when gnus-tmp-header
4308 ;; We may have an old dummy line to output before this
4310 (when (and gnus-tmp-dummy-line
4313 (mail-header-subject gnus-tmp-header)))
4314 (gnus-summary-insert-dummy-line
4315 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4316 (setq gnus-tmp-dummy-line nil))
4318 ;; Compute the mark.
4319 (setq gnus-tmp-unread (gnus-article-mark number))
4321 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4322 gnus-tmp-header gnus-tmp-level)
4323 gnus-newsgroup-data)
4325 ;; Actually insert the line.
4327 gnus-tmp-subject-or-nil
4329 ((and gnus-thread-ignore-subject
4330 gnus-tmp-prev-subject
4331 (not (inline (gnus-subject-equal
4332 gnus-tmp-prev-subject subject))))
4334 ((zerop gnus-tmp-level)
4335 (if (and (eq gnus-summary-make-false-root 'empty)
4336 (memq number gnus-tmp-gathered)
4337 gnus-tmp-prev-subject
4338 (inline (gnus-subject-equal
4339 gnus-tmp-prev-subject subject)))
4340 gnus-summary-same-subject
4342 (t gnus-summary-same-subject)))
4343 (if (and (eq gnus-summary-make-false-root 'adopt)
4344 (= gnus-tmp-level 1)
4345 (memq number gnus-tmp-gathered))
4346 (setq gnus-tmp-opening-bracket ?\<
4347 gnus-tmp-closing-bracket ?\>)
4348 (setq gnus-tmp-opening-bracket ?\[
4349 gnus-tmp-closing-bracket ?\]))
4351 gnus-tmp-indentation
4352 (aref gnus-thread-indent-array gnus-tmp-level)
4353 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4354 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4355 gnus-summary-default-score 0)
4357 (if (or (null gnus-summary-default-score)
4358 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4359 gnus-summary-zcore-fuzz))
4361 (if (< gnus-tmp-score gnus-summary-default-score)
4362 gnus-score-below-mark gnus-score-over-mark))
4364 (cond ((memq number gnus-newsgroup-processable)
4366 ((memq number gnus-newsgroup-cached)
4368 ((memq number gnus-newsgroup-replied)
4370 ((memq number gnus-newsgroup-forwarded)
4371 gnus-forwarded-mark)
4372 ((memq number gnus-newsgroup-saved)
4374 ((memq number gnus-newsgroup-recent)
4376 ((memq number gnus-newsgroup-unseen)
4379 gnus-tmp-from (mail-header-from gnus-tmp-header)
4382 ((string-match "<[^>]+> *$" gnus-tmp-from)
4383 (setq beg-match (match-beginning 0))
4384 (or (and (string-match "^\".+\"" gnus-tmp-from)
4385 (substring gnus-tmp-from 1 (1- (match-end 0))))
4386 (substring gnus-tmp-from 0 beg-match)))
4387 ((string-match "(.+)" gnus-tmp-from)
4388 (substring gnus-tmp-from
4389 (1+ (match-beginning 0)) (1- (match-end 0))))
4391 gnus-tmp-thread-tree-header-string
4393 ((not gnus-show-threads) "")
4394 ((zerop gnus-tmp-level)
4396 (or gnus-sum-thread-tree-root subject)
4397 (or gnus-sum-thread-tree-single-indent subject)))
4399 (concat (apply 'concat
4400 (mapcar (lambda (item)
4402 gnus-sum-thread-tree-vertical
4403 gnus-sum-thread-tree-indent))
4404 (cdr (reverse tree-stack))))
4406 gnus-sum-thread-tree-leaf-with-other
4407 gnus-sum-thread-tree-single-leaf)))))
4408 (when (string= gnus-tmp-name "")
4409 (setq gnus-tmp-name gnus-tmp-from))
4410 (unless (numberp gnus-tmp-lines)
4411 (setq gnus-tmp-lines -1))
4412 (if (= gnus-tmp-lines -1)
4413 (setq gnus-tmp-lines "?")
4414 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4415 (gnus-put-text-property
4417 (progn (eval gnus-summary-line-format-spec) (point))
4418 'gnus-number number)
4421 (gnus-run-hooks 'gnus-summary-update-hook)
4424 (setq gnus-tmp-prev-subject subject)))
4426 (when (nth 1 thread)
4427 (push (list (max 0 gnus-tmp-level)
4428 (copy-list tree-stack)
4431 (push (if (nth 1 thread) 1 0) tree-stack)
4432 (incf gnus-tmp-level)
4433 (setq threads (if thread-end nil (cdar thread)))
4435 (setq gnus-tmp-level 0)))))
4436 (gnus-message 7 "Generating summary...done"))
4438 (defun gnus-summary-prepare-unthreaded (headers)
4439 "Generate an unthreaded summary buffer based on HEADERS."
4440 (let (header number mark)
4445 ;; We may have to root out some bad articles...
4446 (when (memq (setq number (mail-header-number
4447 (setq header (pop headers))))
4448 gnus-newsgroup-limit)
4449 ;; Mark article as read when it has a low score.
4450 (when (and gnus-summary-mark-below
4451 (< (or (cdr (assq number gnus-newsgroup-scored))
4452 gnus-summary-default-score 0)
4453 gnus-summary-mark-below)
4454 (not (gnus-summary-article-ancient-p number)))
4455 (setq gnus-newsgroup-unreads
4456 (delq number gnus-newsgroup-unreads))
4457 (if gnus-newsgroup-auto-expire
4458 (push number gnus-newsgroup-expirable)
4459 (push (cons number gnus-low-score-mark)
4460 gnus-newsgroup-reads)))
4462 (setq mark (gnus-article-mark number))
4463 (push (gnus-data-make number mark (1+ (point)) header 0)
4464 gnus-newsgroup-data)
4465 (gnus-summary-insert-line
4467 mark (memq number gnus-newsgroup-replied)
4468 (memq number gnus-newsgroup-expirable)
4469 (mail-header-subject header) nil
4470 (cdr (assq number gnus-newsgroup-scored))
4471 (memq number gnus-newsgroup-processable))))))
4473 (defun gnus-summary-remove-list-identifiers ()
4474 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4475 (let ((regexp (if (consp gnus-list-identifiers)
4476 (mapconcat 'identity gnus-list-identifiers " *\\|")
4477 gnus-list-identifiers))
4480 (dolist (header gnus-newsgroup-headers)
4481 (setq subject (mail-header-subject header)
4483 (while (string-match
4484 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4487 (concat (substring subject 0 (match-beginning 2))
4488 (substring subject (match-end 0)))
4492 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4494 (concat (substring subject 0 (match-beginning 1))
4495 (substring subject (match-end 1)))))
4497 (mail-header-set-subject header subject))))))
4499 (defun gnus-fetch-headers (articles)
4500 "Fetch headers of ARTICLES."
4501 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4502 (gnus-message 5 "Fetching headers for %s..." name)
4505 (setq gnus-headers-retrieved-by
4506 (gnus-retrieve-headers
4507 articles gnus-newsgroup-name
4508 ;; We might want to fetch old headers, but
4509 ;; not if there is only 1 article.
4511 (not (eq gnus-fetch-old-headers 'some))
4512 (not (numberp gnus-fetch-old-headers)))
4513 (> (length articles) 1))
4514 gnus-fetch-old-headers))))
4515 (gnus-get-newsgroup-headers-xover
4516 articles nil nil gnus-newsgroup-name t)
4517 (gnus-get-newsgroup-headers))
4518 (gnus-message 5 "Fetching headers for %s...done" name))))
4520 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4521 "Select newsgroup GROUP.
4522 If READ-ALL is non-nil, all articles in the group are selected.
4523 If SELECT-ARTICLES, only select those articles from GROUP."
4524 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4525 ;;!!! Dirty hack; should be removed.
4526 (gnus-summary-ignore-duplicates
4527 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4529 gnus-summary-ignore-duplicates))
4530 (info (nth 2 entry))
4531 articles fetched-articles cached)
4533 (unless (gnus-check-server
4534 (set (make-local-variable 'gnus-current-select-method)
4535 (gnus-find-method-for-group group)))
4536 (error "Couldn't open server"))
4538 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4539 (gnus-activate-group group) ; Or we can activate it...
4540 (progn ; Or we bug out.
4541 (when (equal major-mode 'gnus-summary-mode)
4542 (kill-buffer (current-buffer)))
4543 (error "Couldn't activate group %s: %s"
4544 group (gnus-status-message group))))
4546 (unless (gnus-request-group group t)
4547 (when (equal major-mode 'gnus-summary-mode)
4548 (kill-buffer (current-buffer)))
4549 (error "Couldn't request group %s: %s"
4550 group (gnus-status-message group)))
4552 (setq gnus-newsgroup-name group
4553 gnus-newsgroup-unselected nil
4554 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4556 (let ((display (gnus-group-find-parameter group 'display)))
4557 (setq gnus-newsgroup-display
4559 ((not (zerop (or (car-safe read-all) 0)))
4560 ;; The user entered the group with C-u SPC/RET, let's show
4566 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4568 ;; The following is probably the "correct" solution, but
4569 ;; it makes Gnus fetch all headers and then limit the
4570 ;; articles (which is slow), so instead we hack the
4571 ;; select-articles parameter instead. -- Simon Josefsson
4574 ;; (gnus-byte-compile
4575 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4577 (setq select-articles
4578 (gnus-uncompress-range
4579 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4583 (cdr (gnus-active group)))))
4588 (gnus-summary-setup-default-charset)
4590 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4591 (when (gnus-virtual-group-p group)
4592 (setq cached gnus-newsgroup-cached))
4594 (setq gnus-newsgroup-unreads
4595 (gnus-set-difference
4596 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4597 gnus-newsgroup-dormant))
4599 (setq gnus-newsgroup-processable nil)
4601 (gnus-update-read-articles group gnus-newsgroup-unreads)
4603 ;; Adjust and set lists of article marks.
4605 (gnus-adjust-marked-articles info))
4607 (if (setq articles select-articles)
4608 (setq gnus-newsgroup-unselected
4609 (gnus-sorted-intersection
4610 gnus-newsgroup-unreads
4611 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4612 (setq articles (gnus-articles-to-read group read-all)))
4616 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4618 ((eq articles 0) nil)
4620 ;; Init the dependencies hash table.
4621 (setq gnus-newsgroup-dependencies
4622 (gnus-make-hashtable (length articles)))
4623 (gnus-set-global-variables)
4624 ;; Retrieve the headers and read them in.
4625 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4627 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4629 (setq gnus-newsgroup-cached cached))
4631 ;; Suppress duplicates?
4632 (when gnus-suppress-duplicates
4633 (gnus-dup-suppress-articles))
4635 ;; Set the initial limit.
4636 (setq gnus-newsgroup-limit (copy-sequence articles))
4637 ;; Remove canceled articles from the list of unread articles.
4638 (setq fetched-articles
4639 (mapcar (lambda (headers) (mail-header-number headers))
4640 gnus-newsgroup-headers))
4641 (setq gnus-newsgroup-articles fetched-articles)
4642 (setq gnus-newsgroup-unreads
4643 (gnus-set-sorted-intersection
4644 gnus-newsgroup-unreads fetched-articles))
4646 (let ((marks (assq 'seen (gnus-info-marks info))))
4647 ;; The `seen' marks are treated specially.
4648 (when (setq gnus-newsgroup-seen (cdr marks))
4649 (dolist (article gnus-newsgroup-articles)
4650 (unless (gnus-member-of-range
4651 article gnus-newsgroup-seen)
4652 (push article gnus-newsgroup-unseen)))))
4654 ;; Removed marked articles that do not exist.
4655 (gnus-update-missing-marks
4656 (gnus-sorted-complement fetched-articles articles))
4657 ;; We might want to build some more threads first.
4658 (when (and gnus-fetch-old-headers
4659 (eq gnus-headers-retrieved-by 'nov))
4660 (if (eq gnus-fetch-old-headers 'invisible)
4661 (gnus-build-all-threads)
4662 (gnus-build-old-threads)))
4663 ;; Let the Gnus agent mark articles as read.
4665 (gnus-agent-get-undownloaded-list))
4666 ;; Remove list identifiers from subject
4667 (when gnus-list-identifiers
4668 (gnus-summary-remove-list-identifiers))
4669 ;; Check whether auto-expire is to be done in this group.
4670 (setq gnus-newsgroup-auto-expire
4671 (gnus-group-auto-expirable-p group))
4672 ;; Set up the article buffer now, if necessary.
4673 (unless gnus-single-article-buffer
4674 (gnus-article-setup-buffer))
4675 ;; First and last article in this newsgroup.
4676 (when gnus-newsgroup-headers
4677 (setq gnus-newsgroup-begin
4678 (mail-header-number (car gnus-newsgroup-headers))
4681 (gnus-last-element gnus-newsgroup-headers))))
4682 ;; GROUP is successfully selected.
4683 (or gnus-newsgroup-headers t)))))
4685 (defun gnus-summary-display-make-predicate (display)
4686 (require 'gnus-agent)
4687 (when (= (length display) 1)
4688 (setq display (car display)))
4689 (unless gnus-summary-display-cache
4690 (dolist (elem (append (list (cons 'read 'read)
4691 (cons 'unseen 'unseen))
4692 gnus-article-mark-lists))
4693 (push (cons (cdr elem)
4695 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4696 gnus-summary-display-cache)))
4697 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4698 (gnus-get-predicate display)))
4700 ;; Uses the dynamically bound `number' variable.
4702 (defun gnus-article-marked-p (type &optional article)
4703 (let ((article (or article number)))
4706 (memq article gnus-newsgroup-marked))
4708 (memq article gnus-newsgroup-unsendable))
4709 ((eq type 'undownload)
4710 (memq article gnus-newsgroup-undownloaded))
4711 ((eq type 'download)
4712 (memq article gnus-newsgroup-downloadable))
4714 (memq article gnus-newsgroup-unreads))
4716 (memq article gnus-newsgroup-reads))
4718 (memq article gnus-newsgroup-dormant) )
4720 (memq article gnus-newsgroup-expirable))
4722 (memq article gnus-newsgroup-replied))
4724 (memq article gnus-newsgroup-killed))
4725 ((eq type 'bookmark)
4726 (assq article gnus-newsgroup-bookmarks))
4728 (assq article gnus-newsgroup-scored))
4730 (memq article gnus-newsgroup-saved))
4732 (memq article gnus-newsgroup-cached))
4734 (memq article gnus-newsgroup-forwarded))
4736 (not (memq article gnus-newsgroup-unseen)))
4738 (memq article gnus-newsgroup-recent))
4741 (defun gnus-articles-to-read (group &optional read-all)
4742 "Find out what articles the user wants to read."
4744 ;; Select all articles if `read-all' is non-nil, or if there
4745 ;; are no unread articles.
4747 (and (zerop (length gnus-newsgroup-marked))
4748 (zerop (length gnus-newsgroup-unreads)))
4749 (eq gnus-newsgroup-display 'gnus-not-ignore))
4750 ;; We want to select the headers for all the articles in
4751 ;; the group, so we select either all the active
4752 ;; articles in the group, or (if that's nil), the
4753 ;; articles in the cache.
4755 (gnus-uncompress-range (gnus-active group))
4756 (gnus-cache-articles-in-group group))
4757 ;; Select only the "normal" subset of articles.
4758 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4759 (copy-sequence gnus-newsgroup-unreads))
4761 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4762 (scored (length scored-list))
4763 (number (length articles))
4764 (marked (+ (length gnus-newsgroup-marked)
4765 (length gnus-newsgroup-dormant)))
4773 ((and (or (<= scored marked) (= scored number))
4774 (numberp gnus-large-newsgroup)
4775 (> number gnus-large-newsgroup))
4779 "How many articles from %s (default %d): "
4781 (gnus-group-decoded-name gnus-newsgroup-name)
4784 (if (string-match "^[ \t]*$" input) number input)))
4785 ((and (> scored marked) (< scored number)
4786 (> (- scored number) 20))
4789 (format "%s %s (%d scored, %d total): "
4790 "How many articles from"
4791 (gnus-group-decoded-name group)
4793 (if (string-match "^[ \t]*$" input)
4797 (message "Quit getting the articles to read")
4799 (setq select (if (stringp select) (string-to-number select) select))
4800 (if (or (null select) (zerop select))
4802 (if (and (not (zerop scored)) (<= (abs select) scored))
4804 (setq articles (sort scored-list '<))
4805 (setq number (length articles)))
4806 (setq articles (copy-sequence articles)))
4808 (when (< (abs select) number)
4810 ;; Select the N oldest articles.
4811 (setcdr (nthcdr (1- (abs select)) articles) nil)
4812 ;; Select the N most recent articles.
4813 (setq articles (nthcdr (- number select) articles))))
4814 (setq gnus-newsgroup-unselected
4815 (gnus-sorted-intersection
4816 gnus-newsgroup-unreads
4817 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4818 (when gnus-alter-articles-to-read-function
4819 (setq gnus-newsgroup-unreads
4821 (funcall gnus-alter-articles-to-read-function
4822 gnus-newsgroup-name gnus-newsgroup-unreads)
4826 (defun gnus-killed-articles (killed articles)
4829 (when (inline (gnus-member-of-range (car articles) killed))
4830 (push (car articles) out))
4831 (setq articles (cdr articles)))
4834 (defun gnus-uncompress-marks (marks)
4835 "Uncompress the mark ranges in MARKS."
4836 (let ((uncompressed '(score bookmark))
4839 (if (memq (caar marks) uncompressed)
4840 (push (car marks) out)
4841 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4842 (setq marks (cdr marks)))
4845 (defun gnus-article-mark-to-type (mark)
4846 "Return the type of MARK."
4847 (or (cadr (assq mark gnus-article-special-mark-lists))
4850 (defun gnus-article-unpropagatable-p (mark)
4851 "Return whether MARK should be propagated to backend."
4852 (memq mark gnus-article-unpropagated-mark-lists))
4854 (defun gnus-adjust-marked-articles (info)
4855 "Set all article lists and remove all marks that are no longer valid."
4856 (let* ((marked-lists (gnus-info-marks info))
4857 (active (gnus-active (gnus-info-group info)))
4860 (types gnus-article-mark-lists)
4861 marks var articles article mark mark-type)
4863 (dolist (marks marked-lists)
4864 (setq mark (car marks)
4865 mark-type (gnus-article-mark-to-type mark)
4866 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4868 ;; We set the variable according to the type of the marks list,
4869 ;; and then adjust the marks to a subset of the active articles.
4871 ;; Adjust "simple" lists.
4872 ((eq mark-type 'list)
4873 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4874 (when (memq mark '(tick dormant expire reply save))
4876 (when (or (< (setq article (pop articles)) min) (> article max))
4877 (set var (delq article (symbol-value var)))))))
4879 ((eq mark-type 'tuple)
4880 (set var (setq articles (cdr marks)))
4881 (when (not (listp (cdr (symbol-value var))))
4882 (set var (list (symbol-value var))))
4883 (when (not (listp (cdr articles)))
4884 (setq articles (list articles)))
4886 (when (or (not (consp (setq article (pop articles))))
4887 (< (car article) min)
4888 (> (car article) max))
4889 (set var (delq article (symbol-value var))))))
4890 ((eq mark-type 'range)
4892 ((eq mark 'seen))))))))
4894 (defun gnus-update-missing-marks (missing)
4895 "Go through the list of MISSING articles and remove them from the mark lists."
4898 ;; Go through all types.
4899 (dolist (elem gnus-article-mark-lists)
4900 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4901 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4902 (when (symbol-value var)
4903 ;; This list has articles. So we delete all missing
4904 ;; articles from it.
4907 (set var (delq (pop m) (symbol-value var))))))))))
4909 (defun gnus-update-marks ()
4910 "Enter the various lists of marked articles into the newsgroup info list."
4911 (let ((types gnus-article-mark-lists)
4912 (info (gnus-get-info gnus-newsgroup-name))
4913 type list newmarked symbol delta-marks)
4915 ;; Add all marks lists to the list of marks lists.
4916 (while (setq type (pop types))
4917 (setq list (symbol-value
4919 (intern (format "gnus-newsgroup-%s" (car type))))))
4922 ;; Get rid of the entries of the articles that have the
4924 (when (and (eq (cdr type) 'score)
4928 (prev (cons nil list))
4931 (if (or (not (consp (car arts)))
4932 (= (cdar arts) gnus-summary-default-score))
4933 (setcdr prev (cdr arts))
4935 (setq arts (cdr arts)))
4936 (setq list (cdr all)))))
4938 (when (eq (cdr type) 'seen)
4941 (gnus-add-to-range list gnus-newsgroup-unseen)
4942 (gnus-compress-sequence gnus-newsgroup-articles))))
4944 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
4945 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4947 (when (and (gnus-check-backend-function
4948 'request-set-mark gnus-newsgroup-name)
4949 (not (gnus-article-unpropagatable-p (cdr type))))
4950 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4951 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4952 (add (gnus-remove-from-range
4953 (gnus-copy-sequence list) old)))
4955 (push (list add 'add (list (cdr type))) delta-marks))
4957 (push (list del 'del (list (cdr type))) delta-marks))))
4960 (push (cons (cdr type) list) newmarked)))
4963 (unless (gnus-check-group gnus-newsgroup-name)
4964 (error "Can't open server for %s" gnus-newsgroup-name))
4965 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4967 ;; Enter these new marks into the info of the group.
4969 (setcar (nthcdr 3 info) newmarked)
4970 ;; Add the marks lists to the end of the info.
4972 (setcdr (nthcdr 2 info) (list newmarked))))
4974 ;; Cut off the end of the info if there's nothing else there.
4978 (when (nthcdr (decf i) info)
4979 (setcdr (nthcdr i info) nil)))))))
4981 (defun gnus-set-mode-line (where)
4982 "Set the mode line of the article or summary buffers.
4983 If WHERE is `summary', the summary mode line format will be used."
4984 ;; Is this mode line one we keep updated?
4985 (when (and (memq where gnus-updated-mode-lines)
4987 (intern (format "gnus-%s-mode-line-format-spec" where))))
4990 ;; We evaluate this in the summary buffer since these
4991 ;; variables are buffer-local to that buffer.
4992 (set-buffer gnus-summary-buffer)
4993 ;; We bind all these variables that are used in the `eval' form
4995 (let* ((mformat (symbol-value
4997 (format "gnus-%s-mode-line-format-spec" where))))
4998 (gnus-tmp-group-name (gnus-group-decoded-name
4999 gnus-newsgroup-name))
5000 (gnus-tmp-article-number (or gnus-current-article 0))
5001 (gnus-tmp-unread gnus-newsgroup-unreads)
5002 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5003 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5004 (gnus-tmp-unread-and-unselected
5005 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5006 (zerop gnus-tmp-unselected))
5008 ((zerop gnus-tmp-unselected)
5009 (format "{%d more}" gnus-tmp-unread-and-unticked))
5010 (t (format "{%d(+%d) more}"
5011 gnus-tmp-unread-and-unticked
5012 gnus-tmp-unselected))))
5014 (if (and gnus-current-headers
5015 (vectorp gnus-current-headers))
5016 (gnus-mode-string-quote
5017 (mail-header-subject gnus-current-headers))
5019 bufname-length max-len
5020 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5021 (setq mode-string (eval mformat))
5022 (setq bufname-length (if (string-match "%b" mode-string)
5025 (if (eq where 'summary)
5027 (get-buffer gnus-article-buffer))))
5030 (setq max-len (max 4 (if gnus-mode-non-string-length
5032 gnus-mode-non-string-length
5034 (length mode-string))))
5035 ;; We might have to chop a bit of the string off...
5036 (when (> (length mode-string) max-len)
5038 (concat (truncate-string-to-width mode-string (- max-len 3))
5040 ;; Pad the mode string a bit.
5041 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5042 ;; Update the mode line.
5043 (setq mode-line-buffer-identification
5044 (gnus-mode-line-buffer-identification (list mode-string)))
5045 (set-buffer-modified-p t))))
5047 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5048 "Go through the HEADERS list and add all Xrefs to a hash table.
5049 The resulting hash table is returned, or nil if no Xrefs were found."
5050 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5051 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5052 (xref-hashtb (gnus-make-hashtable))
5053 start group entry number xrefs header)
5055 (setq header (pop headers))
5056 (when (and (setq xrefs (mail-header-xref header))
5057 (not (memq (setq number (mail-header-number header))
5060 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5061 (setq start (match-end 0))
5062 (setq group (if prefix
5063 (concat prefix (substring xrefs (match-beginning 1)
5065 (substring xrefs (match-beginning 1) (match-end 1))))
5067 (string-to-int (substring xrefs (match-beginning 2)
5069 (if (setq entry (gnus-gethash group xref-hashtb))
5070 (setcdr entry (cons number (cdr entry)))
5071 (gnus-sethash group (cons number nil) xref-hashtb)))))
5072 (and start xref-hashtb)))
5074 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5075 "Look through all the headers and mark the Xrefs as read."
5076 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5077 name entry info xref-hashtb idlist method nth4)
5079 (set-buffer gnus-group-buffer)
5080 (when (setq xref-hashtb
5081 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5084 (unless (string= from-newsgroup (setq name (symbol-name group)))
5085 (setq idlist (symbol-value group))
5086 ;; Dead groups are not updated.
5088 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5090 (when (stringp (setq nth4 (gnus-info-method info)))
5091 (setq nth4 (gnus-server-to-method nth4))))
5092 ;; Only do the xrefs if the group has the same
5093 ;; select method as the group we have just read.
5094 (or (gnus-methods-equal-p
5095 nth4 (gnus-find-method-for-group from-newsgroup))
5097 (equal nth4 (setq method (gnus-find-method-for-group
5099 (and (equal (car nth4) (car method))
5100 (equal (nth 1 nth4) (nth 1 method))))
5101 gnus-use-cross-reference
5102 (or (not (eq gnus-use-cross-reference t))
5104 ;; Only do cross-references on subscribed
5105 ;; groups, if that is what is wanted.
5106 (<= (gnus-info-level info) gnus-level-subscribed))
5107 (gnus-group-make-articles-read name idlist))))
5110 (defun gnus-compute-read-articles (group articles)
5111 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5112 (info (nth 2 entry))
5113 (active (gnus-active group))
5116 ;; First peel off all invalid article numbers.
5118 (let ((ids articles)
5120 (while (setq id (pop ids))
5121 (when (and first (> id (cdr active)))
5122 ;; We'll end up in this situation in one particular
5123 ;; obscure situation. If you re-scan a group and get
5124 ;; a new article that is cross-posted to a different
5125 ;; group that has not been re-scanned, you might get
5126 ;; crossposted article that has a higher number than
5127 ;; Gnus believes possible. So we re-activate this
5128 ;; group as well. This might mean doing the
5129 ;; crossposting thingy will *increase* the number
5130 ;; of articles in some groups. Tsk, tsk.
5131 (setq active (or (gnus-activate-group group) active)))
5132 (when (or (> id (cdr active))
5133 (< id (car active)))
5134 (setq articles (delq id articles))))))
5135 ;; If the read list is nil, we init it.
5137 (null (gnus-info-read info))
5139 (setq ninfo (cons 1 (1- (car active))))
5140 (setq ninfo (gnus-info-read info)))
5141 ;; Then we add the read articles to the range.
5143 ninfo (setq articles (sort articles '<))))))
5145 (defun gnus-group-make-articles-read (group articles)
5146 "Update the info of GROUP to say that ARTICLES are read."
5148 (entry (gnus-gethash group gnus-newsrc-hashtb))
5149 (info (nth 2 entry))
5150 (active (gnus-active group))
5153 (setq range (gnus-compute-read-articles group articles))
5155 (set-buffer gnus-group-buffer)
5158 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5159 (gnus-info-set-read ',info ',(gnus-info-read info))
5160 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5161 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5162 (gnus-group-update-group ,group t))))
5163 ;; Add the read articles to the range.
5164 (gnus-info-set-read info range)
5165 (gnus-request-set-mark group (list (list range 'add '(read))))
5166 ;; Then we have to re-compute how many unread
5167 ;; articles there are in this group.
5171 (setq num (- (1+ (cdr active)) (car active))))
5172 ((not (listp (cdr range)))
5173 (setq num (- (cdr active) (- (1+ (cdr range))
5177 (if (numberp (car range))
5179 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5180 (setq range (cdr range)))
5181 (setq num (- (cdr active) num))))
5182 ;; Update the number of unread articles.
5184 ;; Update the group buffer.
5185 (gnus-group-update-group group t)))))
5187 (defvar gnus-newsgroup-none-id 0)
5189 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5190 (let ((cur nntp-server-buffer)
5193 (save-excursion (set-buffer gnus-summary-buffer)
5194 gnus-newsgroup-dependencies)))
5196 (mail-parse-charset gnus-newsgroup-charset)
5197 (mail-parse-ignored-charsets
5198 (save-excursion (condition-case nil
5199 (set-buffer gnus-summary-buffer)
5201 gnus-newsgroup-ignored-charsets)))
5203 (set-buffer nntp-server-buffer)
5204 ;; Translate all TAB characters into SPACE characters.
5205 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5206 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5207 (gnus-run-hooks 'gnus-parse-headers-hook)
5208 (let ((case-fold-search t)
5209 in-reply-to header p lines chars)
5210 (goto-char (point-min))
5211 ;; Search to the beginning of the next header. Error messages
5212 ;; do not begin with 2 or 3.
5213 (while (re-search-forward "^[23][0-9]+ " nil t)
5216 ;; This implementation of this function, with nine
5217 ;; search-forwards instead of the one re-search-forward and
5218 ;; a case (which basically was the old function) is actually
5219 ;; about twice as fast, even though it looks messier. You
5220 ;; can't have everything, I guess. Speed and elegance
5221 ;; doesn't always go hand in hand.
5230 (narrow-to-region (point)
5231 (or (and (search-forward "\n.\n" nil t)
5237 (if (search-forward "\nsubject:" nil t)
5238 (funcall gnus-decode-encoded-word-function
5239 (nnheader-header-value))
5244 (if (search-forward "\nfrom:" nil t)
5245 (funcall gnus-decode-encoded-word-function
5246 (nnheader-header-value))
5251 (if (search-forward "\ndate:" nil t)
5252 (nnheader-header-value) ""))
5256 (setq id (if (re-search-forward
5257 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5258 ;; We do it this way to make sure the Message-ID
5259 ;; is (somewhat) syntactically valid.
5260 (buffer-substring (match-beginning 1)
5262 ;; If there was no message-id, we just fake one
5263 ;; to make subsequent routines simpler.
5264 (nnheader-generate-fake-message-id))))
5268 (if (search-forward "\nreferences:" nil t)
5272 (nnheader-header-value)
5277 (search-backward ">" end t)
5280 (search-backward "<" end t)
5282 ;; Get the references from the in-reply-to header if there
5283 ;; were no references and the in-reply-to header looks
5285 (if (and (search-forward "\nin-reply-to:" nil t)
5286 (setq in-reply-to (nnheader-header-value))
5287 (string-match "<[^>]+>" in-reply-to))
5289 (setq ref (substring in-reply-to (match-beginning 0)
5291 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5292 (setq ref2 (substring in-reply-to (match-beginning 0)
5294 (when (> (length ref2) (length ref))
5301 (if (search-forward "\nchars: " nil t)
5302 (if (numberp (setq chars (ignore-errors (read cur))))
5308 (if (search-forward "\nlines: " nil t)
5309 (if (numberp (setq lines (ignore-errors (read cur))))
5315 (and (search-forward "\nxref:" nil t)
5316 (nnheader-header-value)))
5318 (when gnus-extra-headers
5319 (let ((extra gnus-extra-headers)
5323 (when (search-forward
5324 (concat "\n" (symbol-name (car extra)) ":") nil t)
5325 (push (cons (car extra) (nnheader-header-value))
5329 (when (equal id ref)
5332 (when gnus-alter-header-function
5333 (funcall gnus-alter-header-function header)
5334 (setq id (mail-header-id header)
5335 ref (gnus-parent-id (mail-header-references header))))
5338 (gnus-dependencies-add-header
5339 header dependencies force-new))
5340 (push header headers))
5341 (goto-char (point-max))
5343 (nreverse headers)))))
5345 ;; Goes through the xover lines and returns a list of vectors
5346 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5347 force-new dependencies
5348 group also-fetch-heads)
5349 "Parse the news overview data in the server buffer.
5350 Return a list of headers that match SEQUENCE (see
5351 `nntp-retrieve-headers')."
5352 ;; Get the Xref when the users reads the articles since most/some
5353 ;; NNTP servers do not include Xrefs when using XOVER.
5354 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5355 (let ((mail-parse-charset gnus-newsgroup-charset)
5356 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5357 (cur nntp-server-buffer)
5358 (dependencies (or dependencies gnus-newsgroup-dependencies))
5360 ((eq gnus-read-all-available-headers t)
5362 ((stringp gnus-read-all-available-headers)
5363 (string-match gnus-read-all-available-headers group))
5366 number headers header)
5368 (set-buffer nntp-server-buffer)
5369 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5370 ;; Allow the user to mangle the headers before parsing them.
5371 (gnus-run-hooks 'gnus-parse-headers-hook)
5372 (goto-char (point-min))
5375 (while (and (or sequence allp)
5377 (setq number (read cur))
5379 (while (and sequence
5380 (< (car sequence) number))
5381 (setq sequence (cdr sequence))))
5384 (eq number (car sequence))))
5386 (setq sequence (cdr sequence))
5387 (setq header (inline
5388 (gnus-nov-parse-line
5389 number dependencies force-new)))))
5390 (push header headers))
5393 (gnus-error 4 "Strange nov line (%d)"
5394 (count-lines (point-min) (point)))))
5396 ;; A common bug in inn is that if you have posted an article and
5397 ;; then retrieves the active file, it will answer correctly --
5398 ;; the new article is included. However, a NOV entry for the
5399 ;; article may not have been generated yet, so this may fail.
5400 ;; We work around this problem by retrieving the last few
5401 ;; headers using HEAD.
5402 (if (or (not also-fetch-heads)
5404 ;; We (probably) got all the headers.
5406 (let ((gnus-nov-is-evil t))
5409 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5410 (gnus-get-newsgroup-headers))))))))
5412 (defun gnus-article-get-xrefs ()
5413 "Fill in the Xref value in `gnus-current-headers', if necessary.
5414 This is meant to be called in `gnus-article-internal-prepare-hook'."
5415 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5416 gnus-current-headers)))
5417 (or (not gnus-use-cross-reference)
5419 (and (mail-header-xref headers)
5420 (not (string= (mail-header-xref headers) "")))
5421 (let ((case-fold-search t)
5424 (nnheader-narrow-to-headers)
5425 (goto-char (point-min))
5426 (when (or (and (not (eobp))
5427 (eq (downcase (char-after)) ?x)
5428 (looking-at "Xref:"))
5429 (search-forward "\nXref:" nil t))
5430 (goto-char (1+ (match-end 0)))
5431 (setq xref (buffer-substring (point)
5432 (progn (end-of-line) (point))))
5433 (mail-header-set-xref headers xref)))))))
5435 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5436 "Find article ID and insert the summary line for that article.
5437 OLD-HEADER can either be a header or a line number to insert
5438 the subject line on."
5439 (let* ((line (and (numberp old-header) old-header))
5440 (old-header (and (vectorp old-header) old-header))
5441 (header (cond ((and old-header use-old-header)
5444 (gnus-number-to-header id))
5445 (gnus-number-to-header id))
5447 (gnus-read-header id))))
5448 (number (and (numberp id) id))
5451 ;; Rebuild the thread that this article is part of and go to the
5452 ;; article we have fetched.
5453 (when (and (not gnus-show-threads)
5456 (setq d (gnus-data-find (mail-header-number old-header))))
5457 (goto-char (gnus-data-pos d))
5460 (- (gnus-point-at-bol)
5462 (1+ (gnus-point-at-eol))
5463 (gnus-delete-line))))))
5465 (mail-header-set-number header (mail-header-number old-header)))
5466 (setq gnus-newsgroup-sparse
5467 (delq (setq number (mail-header-number header))
5468 gnus-newsgroup-sparse))
5469 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5470 (push number gnus-newsgroup-limit)
5471 (gnus-rebuild-thread (mail-header-id header) line)
5472 (gnus-summary-goto-subject number nil t))
5473 (when (and (numberp number)
5475 ;; We have to update the boundaries even if we can't fetch the
5476 ;; article if ID is a number -- so that the next `P' or `N'
5477 ;; command will fetch the previous (or next) article even
5478 ;; if the one we tried to fetch this time has been canceled.
5479 (when (> number gnus-newsgroup-end)
5480 (setq gnus-newsgroup-end number))
5481 (when (< number gnus-newsgroup-begin)
5482 (setq gnus-newsgroup-begin number))
5483 (setq gnus-newsgroup-unselected
5484 (delq number gnus-newsgroup-unselected)))
5485 ;; Report back a success?
5486 (and header (mail-header-number header))))
5488 ;;; Process/prefix in the summary buffer
5490 (defun gnus-summary-work-articles (n)
5491 "Return a list of articles to be worked upon.
5492 The prefix argument, the list of process marked articles, and the
5493 current article will be taken into consideration."
5495 (set-buffer gnus-summary-buffer)
5498 ;; A numerical prefix has been given.
5499 (setq n (prefix-numeric-value n))
5500 (let ((backward (< n 0))
5501 (n (abs (prefix-numeric-value n)))
5506 (push (setq article (gnus-summary-article-number))
5509 (gnus-summary-find-prev nil article)
5510 (gnus-summary-find-next nil article)))
5512 (nreverse articles)))
5513 ((and (gnus-region-active-p) (mark))
5514 (message "region active")
5515 ;; Work on the region between point and mark.
5516 (let ((max (max (point) (mark)))
5519 (goto-char (min (min (point) (mark))))
5522 (push (setq article (gnus-summary-article-number)) articles)
5523 (gnus-summary-find-next nil article)
5525 (nreverse articles))))
5526 (gnus-newsgroup-processable
5527 ;; There are process-marked articles present.
5528 ;; Save current state.
5529 (gnus-summary-save-process-mark)
5531 (reverse gnus-newsgroup-processable))
5533 ;; Just return the current article.
5534 (list (gnus-summary-article-number))))))
5536 (defmacro gnus-summary-iterate (arg &rest forms)
5537 "Iterate over the process/prefixed articles and do FORMS.
5538 ARG is the interactive prefix given to the command. FORMS will be
5539 executed with point over the summary line of the articles."
5540 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5541 `(let ((,articles (gnus-summary-work-articles ,arg)))
5543 (gnus-summary-goto-subject (car ,articles))
5547 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5548 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5550 (defun gnus-summary-save-process-mark ()
5551 "Push the current set of process marked articles on the stack."
5553 (push (copy-sequence gnus-newsgroup-processable)
5554 gnus-newsgroup-process-stack))
5556 (defun gnus-summary-kill-process-mark ()
5557 "Push the current set of process marked articles on the stack and unmark."
5559 (gnus-summary-save-process-mark)
5560 (gnus-summary-unmark-all-processable))
5562 (defun gnus-summary-yank-process-mark ()
5563 "Pop the last process mark state off the stack and restore it."
5565 (unless gnus-newsgroup-process-stack
5566 (error "Empty mark stack"))
5567 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5569 (defun gnus-summary-process-mark-set (set)
5570 "Make SET into the current process marked articles."
5571 (gnus-summary-unmark-all-processable)
5573 (gnus-summary-set-process-mark (pop set))))
5575 ;;; Searching and stuff
5577 (defun gnus-summary-search-group (&optional backward use-level)
5578 "Search for next unread newsgroup.
5579 If optional argument BACKWARD is non-nil, search backward instead."
5581 (set-buffer gnus-group-buffer)
5582 (when (gnus-group-search-forward
5583 backward nil (if use-level (gnus-group-group-level) nil))
5584 (gnus-group-group-name))))
5586 (defun gnus-summary-best-group (&optional exclude-group)
5587 "Find the name of the best unread group.
5588 If EXCLUDE-GROUP, do not go to this group."
5590 (set-buffer gnus-group-buffer)
5592 (gnus-group-best-unread-group exclude-group))))
5594 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5595 (if backward (gnus-summary-find-prev)
5596 (let* ((dummy (gnus-summary-article-intangible-p))
5597 (article (or article (gnus-summary-article-number)))
5598 (arts (gnus-data-find-list article))
5600 (when (and (not dummy)
5601 (or (not gnus-summary-check-current)
5603 (not (gnus-data-unread-p (car arts)))))
5604 (setq arts (cdr arts)))
5609 (when (or (and undownloaded
5610 (eq gnus-undownloaded-mark
5611 (gnus-data-mark (car arts))))
5612 (gnus-data-unread-p (car arts)))
5613 (setq result (car arts)
5615 (setq arts (cdr arts)))
5618 (goto-char (gnus-data-pos result))
5619 (gnus-data-number result)))))
5621 (defun gnus-summary-find-prev (&optional unread article)
5622 (let* ((eobp (eobp))
5623 (article (or article (gnus-summary-article-number)))
5624 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5626 (when (and (not eobp)
5627 (or (not gnus-summary-check-current)
5629 (not (gnus-data-unread-p (car arts)))))
5630 (setq arts (cdr arts)))
5635 (when (gnus-data-unread-p (car arts))
5636 (setq result (car arts)
5638 (setq arts (cdr arts)))
5641 (goto-char (gnus-data-pos result))
5642 (gnus-data-number result))))
5644 (defun gnus-summary-find-subject (subject &optional unread backward article)
5645 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5646 (article (or article (gnus-summary-article-number)))
5647 (articles (gnus-data-list backward))
5648 (arts (gnus-data-find-list article articles))
5650 (when (or (not gnus-summary-check-current)
5652 (not (gnus-data-unread-p (car arts))))
5653 (setq arts (cdr arts)))
5655 (and (or (not unread)
5656 (gnus-data-unread-p (car arts)))
5657 (vectorp (gnus-data-header (car arts)))
5659 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5660 (setq result (car arts)
5662 (setq arts (cdr arts)))
5664 (goto-char (gnus-data-pos result))
5665 (gnus-data-number result))))
5667 (defun gnus-summary-search-forward (&optional unread subject backward)
5668 "Search forward for an article.
5669 If UNREAD, look for unread articles. If SUBJECT, look for
5670 articles with that subject. If BACKWARD, search backward instead."
5671 (cond (subject (gnus-summary-find-subject subject unread backward))
5672 (backward (gnus-summary-find-prev unread))
5673 (t (gnus-summary-find-next unread))))
5675 (defun gnus-recenter (&optional n)
5676 "Center point in window and redisplay frame.
5677 Also do horizontal recentering."
5679 (when (and gnus-auto-center-summary
5680 (not (eq gnus-auto-center-summary 'vertical)))
5681 (gnus-horizontal-recenter))
5684 (defun gnus-summary-recenter ()
5685 "Center point in the summary window.
5686 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5687 displayed, no centering will be performed."
5688 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5689 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5691 (let* ((top (cond ((< (window-height) 4) 0)
5692 ((< (window-height) 7) 1)
5693 (t (if (numberp gnus-auto-center-summary)
5694 gnus-auto-center-summary
5696 (height (1- (window-height)))
5697 (bottom (save-excursion (goto-char (point-max))
5698 (forward-line (- height))
5700 (window (get-buffer-window (current-buffer))))
5701 ;; The user has to want it.
5702 (when gnus-auto-center-summary
5703 (when (get-buffer-window gnus-article-buffer)
5704 ;; Only do recentering when the article buffer is displayed,
5705 ;; Set the window start to either `bottom', which is the biggest
5706 ;; possible valid number, or the second line from the top,
5707 ;; whichever is the least.
5708 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5709 (if (> bottom top-pos)
5710 ;; Keep the second line from the top visible
5711 (set-window-start window top-pos t)
5712 ;; Try to keep the bottom line visible; if it's partially
5713 ;; obscured, either scroll one more line to make it fully
5714 ;; visible, or revert to using TOP-POS.
5716 (goto-char (point-max))
5718 (let ((last-line-start (point)))
5720 (set-window-start window (point) t)
5721 (when (not (pos-visible-in-window-p last-line-start window))
5723 (set-window-start window (min (point) top-pos) t)))))))
5724 ;; Do horizontal recentering while we're at it.
5725 (when (and (get-buffer-window (current-buffer) t)
5726 (not (eq gnus-auto-center-summary 'vertical)))
5727 (let ((selected (selected-window)))
5728 (select-window (get-buffer-window (current-buffer) t))
5729 (gnus-summary-position-point)
5730 (gnus-horizontal-recenter)
5731 (select-window selected))))))
5733 (defun gnus-summary-jump-to-group (newsgroup)
5734 "Move point to NEWSGROUP in group mode buffer."
5735 ;; Keep update point of group mode buffer if visible.
5736 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5737 (save-window-excursion
5738 ;; Take care of tree window mode.
5739 (when (get-buffer-window gnus-group-buffer)
5740 (pop-to-buffer gnus-group-buffer))
5741 (gnus-group-jump-to-group newsgroup))
5743 ;; Take care of tree window mode.
5744 (if (get-buffer-window gnus-group-buffer)
5745 (pop-to-buffer gnus-group-buffer)
5746 (set-buffer gnus-group-buffer))
5747 (gnus-group-jump-to-group newsgroup))))
5749 ;; This function returns a list of article numbers based on the
5750 ;; difference between the ranges of read articles in this group and
5751 ;; the range of active articles.
5752 (defun gnus-list-of-unread-articles (group)
5753 (let* ((read (gnus-info-read (gnus-get-info group)))
5754 (active (or (gnus-active group) (gnus-activate-group group)))
5757 ;; If none are read, then all are unread.
5759 (setq first (car active))
5760 ;; If the range of read articles is a single range, then the
5761 ;; first unread article is the article after the last read
5762 ;; article. Sounds logical, doesn't it?
5763 (if (and (not (listp (cdr read)))
5764 (or (< (car read) (car active))
5765 (progn (setq read (list read))
5767 (setq first (max (car active) (1+ (cdr read))))
5768 ;; `read' is a list of ranges.
5769 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5772 (setq first (car active)))
5775 (while (< first nlast)
5777 (setq first (1+ first))))
5778 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5779 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5780 (setq read (cdr read)))))
5781 ;; And add the last unread articles.
5782 (while (<= first last)
5784 (setq first (1+ first)))
5785 ;; Return the list of unread articles.
5786 (delq 0 (nreverse unread))))
5788 (defun gnus-list-of-read-articles (group)
5789 "Return a list of unread, unticked and non-dormant articles."
5790 (let* ((info (gnus-get-info group))
5791 (marked (gnus-info-marks info))
5792 (active (gnus-active group)))
5794 (gnus-set-difference
5795 (gnus-sorted-complement
5796 (gnus-uncompress-range active)
5797 (gnus-list-of-unread-articles group))
5799 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5800 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5802 ;; Various summary commands
5804 (defun gnus-summary-select-article-buffer ()
5805 "Reconfigure windows to show article buffer."
5807 (if (not (gnus-buffer-live-p gnus-article-buffer))
5808 (error "There is no article buffer for this summary buffer")
5809 (gnus-configure-windows 'article)
5810 (select-window (get-buffer-window gnus-article-buffer))))
5812 (defun gnus-summary-universal-argument (arg)
5813 "Perform any operation on all articles that are process/prefixed."
5815 (let ((articles (gnus-summary-work-articles arg))
5822 (substitute-command-keys
5823 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5825 (gnus-error 1 "Undefined key")
5828 (gnus-summary-goto-subject (setq article (pop articles)))
5829 (let (gnus-newsgroup-processable)
5830 (command-execute func))
5831 (gnus-summary-remove-process-mark article)))))
5832 (gnus-summary-position-point))
5834 (defun gnus-summary-toggle-truncation (&optional arg)
5835 "Toggle truncation of summary lines.
5836 With arg, turn line truncation on iff arg is positive."
5838 (setq truncate-lines
5839 (if (null arg) (not truncate-lines)
5840 (> (prefix-numeric-value arg) 0)))
5843 (defun gnus-summary-reselect-current-group (&optional all rescan)
5844 "Exit and then reselect the current newsgroup.
5845 The prefix argument ALL means to select all articles."
5847 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5848 (error "Ephemeral groups can't be reselected"))
5849 (let ((current-subject (gnus-summary-article-number))
5850 (group gnus-newsgroup-name))
5851 (setq gnus-newsgroup-begin nil)
5853 ;; We have to adjust the point of group mode buffer because
5854 ;; point was moved to the next unread newsgroup by exiting.
5855 (gnus-summary-jump-to-group group)
5858 (gnus-group-get-new-news-this-group 1)))
5859 (gnus-group-read-group all t)
5860 (gnus-summary-goto-subject current-subject nil t)))
5862 (defun gnus-summary-rescan-group (&optional all)
5863 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5865 (gnus-summary-reselect-current-group all t))
5867 (defun gnus-summary-update-info (&optional non-destructive)
5869 (let ((group gnus-newsgroup-name))
5871 (when gnus-newsgroup-kill-headers
5872 (setq gnus-newsgroup-killed
5873 (gnus-compress-sequence
5875 (gnus-set-sorted-intersection
5876 (gnus-uncompress-range gnus-newsgroup-killed)
5877 (setq gnus-newsgroup-unselected
5878 (sort gnus-newsgroup-unselected '<)))
5879 (setq gnus-newsgroup-unreads
5880 (sort gnus-newsgroup-unreads '<)))
5882 (unless (listp (cdr gnus-newsgroup-killed))
5883 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5884 (let ((headers gnus-newsgroup-headers))
5885 ;; Set the new ranges of read articles.
5887 (set-buffer gnus-group-buffer)
5888 (gnus-undo-force-boundary))
5889 (gnus-update-read-articles
5890 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5891 ;; Set the current article marks.
5892 (let ((gnus-newsgroup-scored
5893 (if (and (not gnus-save-score)
5894 (not non-destructive))
5896 gnus-newsgroup-scored)))
5898 (gnus-update-marks)))
5899 ;; Do the cross-ref thing.
5900 (when gnus-use-cross-reference
5901 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5902 ;; Do not switch windows but change the buffer to work.
5903 (set-buffer gnus-group-buffer)
5904 (unless (gnus-ephemeral-group-p group)
5905 (gnus-group-update-group group)))))))
5907 (defun gnus-summary-save-newsrc (&optional force)
5908 "Save the current number of read/marked articles in the dribble buffer.
5909 The dribble buffer will then be saved.
5910 If FORCE (the prefix), also save the .newsrc file(s)."
5912 (gnus-summary-update-info t)
5914 (gnus-save-newsrc-file)
5915 (gnus-dribble-save)))
5917 (defun gnus-summary-exit (&optional temporary)
5918 "Exit reading current newsgroup, and then return to group selection mode.
5919 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5921 (gnus-set-global-variables)
5922 (when (gnus-buffer-live-p gnus-article-buffer)
5924 (set-buffer gnus-article-buffer)
5925 (mm-destroy-parts gnus-article-mime-handles)
5926 ;; Set it to nil for safety reason.
5927 (setq gnus-article-mime-handle-alist nil)
5928 (setq gnus-article-mime-handles nil)))
5929 (gnus-kill-save-kill-buffer)
5930 (gnus-async-halt-prefetch)
5931 (let* ((group gnus-newsgroup-name)
5932 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5935 (buf (current-buffer)))
5937 ;; Do adaptive scoring, and possibly save score files.
5938 (when gnus-newsgroup-adaptive
5939 (gnus-score-adaptive))
5940 (when gnus-use-scoring
5942 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5943 ;; If we have several article buffers, we kill them at exit.
5944 (unless gnus-single-article-buffer
5945 (gnus-kill-buffer gnus-original-article-buffer)
5946 (setq gnus-article-current nil))
5947 (when gnus-use-cache
5948 (gnus-cache-possibly-remove-articles)
5949 (gnus-cache-save-buffers))
5950 (gnus-async-prefetch-remove-group group)
5951 (when gnus-suppress-duplicates
5952 (gnus-dup-enter-articles))
5953 (when gnus-use-trees
5954 (gnus-tree-close group))
5955 (when gnus-use-cache
5956 (gnus-cache-write-active))
5957 ;; Remove entries for this group.
5958 (nnmail-purge-split-history (gnus-group-real-name group))
5959 ;; Make all changes in this group permanent.
5961 (gnus-run-hooks 'gnus-exit-group-hook)
5962 (gnus-summary-update-info))
5963 (gnus-close-group group)
5964 ;; Make sure where we were, and go to next newsgroup.
5965 (set-buffer gnus-group-buffer)
5967 (gnus-group-jump-to-group group))
5968 (gnus-run-hooks 'gnus-summary-exit-hook)
5969 (unless (or quit-config
5970 ;; If this group has disappeared from the summary
5971 ;; buffer, don't skip forwards.
5972 (not (string= group (gnus-group-group-name))))
5973 (gnus-group-next-unread-group 1))
5974 (setq group-point (point))
5977 ;; If we have several article buffers, we kill them at exit.
5978 (unless gnus-single-article-buffer
5979 (gnus-kill-buffer gnus-article-buffer)
5980 (gnus-kill-buffer gnus-original-article-buffer)
5981 (setq gnus-article-current nil))
5983 (if (not gnus-kill-summary-on-exit)
5985 (gnus-deaden-summary)
5987 ;; We set all buffer-local variables to nil. It is unclear why
5988 ;; this is needed, but if we don't, buffer-local variables are
5989 ;; not garbage-collected, it seems. This would the lead to en
5990 ;; ever-growing Emacs.
5991 (gnus-summary-clear-local-variables)
5992 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5993 (gnus-summary-clear-local-variables))
5994 (when (get-buffer gnus-article-buffer)
5995 (bury-buffer gnus-article-buffer))
5996 ;; We clear the global counterparts of the buffer-local
5997 ;; variables as well, just to be on the safe side.
5998 (set-buffer gnus-group-buffer)
5999 (gnus-summary-clear-local-variables)
6000 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6001 (gnus-summary-clear-local-variables)))
6002 (setq gnus-current-select-method gnus-select-method)
6003 (pop-to-buffer gnus-group-buffer)
6004 (if (not quit-config)
6006 (goto-char group-point)
6007 (gnus-configure-windows 'group 'force))
6008 (gnus-handle-ephemeral-exit quit-config))
6009 ;; Return to group mode buffer.
6010 (when (eq mode 'gnus-summary-mode)
6011 (gnus-kill-buffer buf))
6012 ;; Clear the current group name.
6014 (setq gnus-newsgroup-name nil)))))
6016 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6017 (defun gnus-summary-exit-no-update (&optional no-questions)
6018 "Quit reading current newsgroup without updating read article info."
6020 (let* ((group gnus-newsgroup-name)
6021 (quit-config (gnus-group-quit-config group)))
6022 (when (or no-questions
6024 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6025 (gnus-async-halt-prefetch)
6027 (delq 'gnus-summary-expire-articles
6028 (copy-sequence gnus-summary-prepare-exit-hook)))
6029 (when (gnus-buffer-live-p gnus-article-buffer)
6031 (set-buffer gnus-article-buffer)
6032 (mm-destroy-parts gnus-article-mime-handles)
6033 ;; Set it to nil for safety reason.
6034 (setq gnus-article-mime-handle-alist nil)
6035 (setq gnus-article-mime-handles nil)))
6036 ;; If we have several article buffers, we kill them at exit.
6037 (unless gnus-single-article-buffer
6038 (gnus-kill-buffer gnus-article-buffer)
6039 (gnus-kill-buffer gnus-original-article-buffer)
6040 (setq gnus-article-current nil))
6041 (if (not gnus-kill-summary-on-exit)
6042 (gnus-deaden-summary)
6043 (gnus-close-group group)
6044 (gnus-summary-clear-local-variables)
6045 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6046 (gnus-summary-clear-local-variables))
6047 (set-buffer gnus-group-buffer)
6048 (gnus-summary-clear-local-variables)
6049 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6050 (gnus-summary-clear-local-variables))
6051 (when (get-buffer gnus-summary-buffer)
6052 (kill-buffer gnus-summary-buffer)))
6053 (unless gnus-single-article-buffer
6054 (setq gnus-article-current nil))
6055 (when gnus-use-trees
6056 (gnus-tree-close group))
6057 (gnus-async-prefetch-remove-group group)
6058 (when (get-buffer gnus-article-buffer)
6059 (bury-buffer gnus-article-buffer))
6060 ;; Return to the group buffer.
6061 (gnus-configure-windows 'group 'force)
6062 ;; Clear the current group name.
6063 (setq gnus-newsgroup-name nil)
6064 (when (equal (gnus-group-group-name) group)
6065 (gnus-group-next-unread-group 1))
6067 (gnus-handle-ephemeral-exit quit-config)))))
6069 (defun gnus-handle-ephemeral-exit (quit-config)
6070 "Handle movement when leaving an ephemeral group.
6071 The state which existed when entering the ephemeral is reset."
6072 (if (not (buffer-name (car quit-config)))
6073 (gnus-configure-windows 'group 'force)
6074 (set-buffer (car quit-config))
6075 (cond ((eq major-mode 'gnus-summary-mode)
6076 (gnus-set-global-variables))
6077 ((eq major-mode 'gnus-article-mode)
6079 ;; The `gnus-summary-buffer' variable may point
6080 ;; to the old summary buffer when using a single
6082 (unless (gnus-buffer-live-p gnus-summary-buffer)
6083 (set-buffer gnus-group-buffer))
6084 (set-buffer gnus-summary-buffer)
6085 (gnus-set-global-variables))))
6086 (if (or (eq (cdr quit-config) 'article)
6087 (eq (cdr quit-config) 'pick))
6089 ;; The current article may be from the ephemeral group
6090 ;; thus it is best that we reload this article
6091 (gnus-summary-show-article)
6092 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6093 (gnus-configure-windows 'pick 'force)
6094 (gnus-configure-windows (cdr quit-config) 'force)))
6095 (gnus-configure-windows (cdr quit-config) 'force))
6096 (when (eq major-mode 'gnus-summary-mode)
6097 (gnus-summary-next-subject 1 nil t)
6098 (gnus-summary-recenter)
6099 (gnus-summary-position-point))))
6103 (defvar gnus-dead-summary-mode-map nil)
6105 (unless gnus-dead-summary-mode-map
6106 (setq gnus-dead-summary-mode-map (make-keymap))
6107 (suppress-keymap gnus-dead-summary-mode-map)
6108 (substitute-key-definition
6109 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6110 (let ((keys '("\C-d" "\r" "\177" [delete])))
6112 (define-key gnus-dead-summary-mode-map
6113 (pop keys) 'gnus-summary-wake-up-the-dead))))
6115 (defvar gnus-dead-summary-mode nil
6116 "Minor mode for Gnus summary buffers.")
6118 (defun gnus-dead-summary-mode (&optional arg)
6119 "Minor mode for Gnus summary buffers."
6121 (when (eq major-mode 'gnus-summary-mode)
6122 (make-local-variable 'gnus-dead-summary-mode)
6123 (setq gnus-dead-summary-mode
6124 (if (null arg) (not gnus-dead-summary-mode)
6125 (> (prefix-numeric-value arg) 0)))
6126 (when gnus-dead-summary-mode
6127 (gnus-add-minor-mode
6128 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6130 (defun gnus-deaden-summary ()
6131 "Make the current summary buffer into a dead summary buffer."
6132 ;; Kill any previous dead summary buffer.
6133 (when (and gnus-dead-summary
6134 (buffer-name gnus-dead-summary))
6136 (set-buffer gnus-dead-summary)
6137 (when gnus-dead-summary-mode
6138 (kill-buffer (current-buffer)))))
6139 ;; Make this the current dead summary.
6140 (setq gnus-dead-summary (current-buffer))
6141 (gnus-dead-summary-mode 1)
6142 (let ((name (buffer-name)))
6143 (when (string-match "Summary" name)
6145 (concat (substring name 0 (match-beginning 0)) "Dead "
6146 (substring name (match-beginning 0)))
6150 (defun gnus-kill-or-deaden-summary (buffer)
6151 "Kill or deaden the summary BUFFER."
6153 (when (and (buffer-name buffer)
6154 (not gnus-single-article-buffer))
6157 (gnus-kill-buffer gnus-article-buffer)
6158 (gnus-kill-buffer gnus-original-article-buffer)))
6159 (cond (gnus-kill-summary-on-exit
6160 (when (and gnus-use-trees
6161 (gnus-buffer-exists-p buffer))
6164 (gnus-tree-close gnus-newsgroup-name)))
6165 (gnus-kill-buffer buffer))
6166 ((gnus-buffer-exists-p buffer)
6169 (gnus-deaden-summary))))))
6171 (defun gnus-summary-wake-up-the-dead (&rest args)
6172 "Wake up the dead summary buffer."
6174 (gnus-dead-summary-mode -1)
6175 (let ((name (buffer-name)))
6176 (when (string-match "Dead " name)
6178 (concat (substring name 0 (match-beginning 0))
6179 (substring name (match-end 0)))
6181 (gnus-message 3 "This dead summary is now alive again"))
6183 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6184 (defun gnus-summary-fetch-faq (&optional faq-dir)
6185 "Fetch the FAQ for the current group.
6186 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6190 (when current-prefix-arg
6192 "Faq dir: " (and (listp gnus-group-faq-directory)
6193 (mapcar (lambda (file) (list file))
6194 gnus-group-faq-directory))))))
6195 (let (gnus-faq-buffer)
6196 (when (setq gnus-faq-buffer
6197 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6198 (gnus-configure-windows 'summary-faq))))
6200 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6201 (defun gnus-summary-describe-group (&optional force)
6202 "Describe the current newsgroup."
6204 (gnus-group-describe-group force gnus-newsgroup-name))
6206 (defun gnus-summary-describe-briefly ()
6207 "Describe summary mode commands briefly."
6209 (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")))
6211 ;; Walking around group mode buffer from summary mode.
6213 (defun gnus-summary-next-group (&optional no-article target-group backward)
6214 "Exit current newsgroup and then select next unread newsgroup.
6215 If prefix argument NO-ARTICLE is non-nil, no article is selected
6216 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6217 previous group instead."
6219 ;; Stop pre-fetching.
6220 (gnus-async-halt-prefetch)
6221 (let ((current-group gnus-newsgroup-name)
6222 (current-buffer (current-buffer))
6224 ;; First we semi-exit this group to update Xrefs and all variables.
6225 ;; We can't do a real exit, because the window conf must remain
6226 ;; the same in case the user is prompted for info, and we don't
6227 ;; want the window conf to change before that...
6228 (gnus-summary-exit t)
6229 (while (not entered)
6230 ;; Then we find what group we are supposed to enter.
6231 (set-buffer gnus-group-buffer)
6232 (gnus-group-jump-to-group current-group)
6235 (if (eq gnus-keep-same-level 'best)
6236 (gnus-summary-best-group gnus-newsgroup-name)
6237 (gnus-summary-search-group backward gnus-keep-same-level))))
6238 (if (not target-group)
6239 ;; There are no further groups, so we return to the group
6242 (gnus-message 5 "Returning to the group buffer")
6244 (when (gnus-buffer-live-p current-buffer)
6245 (set-buffer current-buffer)
6246 (gnus-summary-exit))
6247 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6248 ;; We try to enter the target group.
6249 (gnus-group-jump-to-group target-group)
6250 (let ((unreads (gnus-group-group-unread)))
6251 (if (and (or (eq t unreads)
6252 (and unreads (not (zerop unreads))))
6253 (gnus-summary-read-group
6254 target-group nil no-article
6255 (and (buffer-name current-buffer) current-buffer)
6258 (setq current-group target-group
6259 target-group nil)))))))
6261 (defun gnus-summary-prev-group (&optional no-article)
6262 "Exit current newsgroup and then select previous unread newsgroup.
6263 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6265 (gnus-summary-next-group no-article nil t))
6267 ;; Walking around summary lines.
6269 (defun gnus-summary-first-subject (&optional unread undownloaded)
6270 "Go to the first unread subject.
6271 If UNREAD is non-nil, go to the first unread article.
6272 Returns the article selected or nil if there are no unread articles."
6277 ((null gnus-newsgroup-data)
6278 (gnus-message 3 "No articles in the group")
6280 ;; Pick the first article.
6282 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6283 (gnus-data-number (car gnus-newsgroup-data)))
6284 ;; No unread articles.
6285 ((null gnus-newsgroup-unreads)
6286 (gnus-message 3 "No more unread articles")
6288 ;; Find the first unread article.
6290 (let ((data gnus-newsgroup-data))
6292 (and (not (and undownloaded
6293 (eq gnus-undownloaded-mark
6294 (gnus-data-mark (car data)))))
6295 (not (gnus-data-unread-p (car data)))))
6296 (setq data (cdr data)))
6298 (goto-char (gnus-data-pos (car data)))
6299 (gnus-data-number (car data))))))
6300 (gnus-summary-position-point)))
6302 (defun gnus-summary-next-subject (n &optional unread dont-display)
6303 "Go to next N'th summary line.
6304 If N is negative, go to the previous N'th subject line.
6305 If UNREAD is non-nil, only unread articles are selected.
6306 The difference between N and the actual number of steps taken is
6309 (let ((backward (< n 0))
6313 (gnus-summary-find-prev unread)
6314 (gnus-summary-find-next unread)))
6315 (unless (zerop (setq n (1- n)))
6316 (gnus-summary-show-thread)))
6318 (gnus-message 7 "No more%s articles"
6319 (if unread " unread" "")))
6320 (unless dont-display
6321 (gnus-summary-recenter)
6322 (gnus-summary-position-point))
6325 (defun gnus-summary-next-unread-subject (n)
6326 "Go to next N'th unread summary line."
6328 (gnus-summary-next-subject n t))
6330 (defun gnus-summary-prev-subject (n &optional unread)
6331 "Go to previous N'th summary line.
6332 If optional argument UNREAD is non-nil, only unread article is selected."
6334 (gnus-summary-next-subject (- n) unread))
6336 (defun gnus-summary-prev-unread-subject (n)
6337 "Go to previous N'th unread summary line."
6339 (gnus-summary-next-subject (- n) t))
6341 (defun gnus-summary-goto-subject (article &optional force silent)
6342 "Go the subject line of ARTICLE.
6343 If FORCE, also allow jumping to articles not currently shown."
6344 (interactive "nArticle number: ")
6346 (data (gnus-data-find article)))
6347 ;; We read in the article if we have to.
6350 (gnus-summary-insert-subject
6352 (if (or (numberp force) (vectorp force)) force)
6354 (setq data (gnus-data-find article)))
6359 (gnus-message 3 "Can't find article %d" article))
6361 (let ((pt (gnus-data-pos data)))
6363 (gnus-summary-set-article-display-arrow pt))
6364 (gnus-summary-position-point)
6367 ;; Walking around summary lines with displaying articles.
6369 (defun gnus-summary-expand-window (&optional arg)
6370 "Make the summary buffer take up the entire Emacs frame.
6371 Given a prefix, will force an `article' buffer configuration."
6374 (gnus-configure-windows 'article 'force)
6375 (gnus-configure-windows 'summary 'force)))
6377 (defun gnus-summary-display-article (article &optional all-header)
6378 "Display ARTICLE in article buffer."
6379 (when (gnus-buffer-live-p gnus-article-buffer)
6380 (with-current-buffer gnus-article-buffer
6381 (mm-enable-multibyte-mule4)))
6382 (gnus-set-global-variables)
6383 (when (gnus-buffer-live-p gnus-article-buffer)
6384 (with-current-buffer gnus-article-buffer
6385 (setq gnus-article-charset gnus-newsgroup-charset)
6386 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6387 (mm-enable-multibyte-mule4)))
6391 (if gnus-summary-display-article-function
6392 (funcall gnus-summary-display-article-function article all-header)
6393 (gnus-article-prepare article all-header))
6394 (gnus-run-hooks 'gnus-select-article-hook)
6395 (when (and gnus-current-article
6396 (not (zerop gnus-current-article)))
6397 (gnus-summary-goto-subject gnus-current-article))
6398 (gnus-summary-recenter)
6399 (when (and gnus-use-trees gnus-show-threads)
6400 (gnus-possibly-generate-tree article)
6401 (gnus-highlight-selected-tree article))
6402 ;; Successfully display article.
6403 (gnus-article-set-window-start
6404 (cdr (assq article gnus-newsgroup-bookmarks))))))
6406 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6407 "Select the current article.
6408 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6409 non-nil, the article will be re-fetched even if it already present in
6410 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6412 ;; Make sure we are in the summary buffer to work around bbdb bug.
6413 (unless (eq major-mode 'gnus-summary-mode)
6414 (set-buffer gnus-summary-buffer))
6415 (let ((article (or article (gnus-summary-article-number)))
6416 (all-headers (not (not all-headers))) ;Must be T or NIL.
6417 gnus-summary-display-article-function)
6419 (gnus-summary-article-pseudo-p article)
6420 (error "This is a pseudo-article"))
6422 (set-buffer gnus-summary-buffer)
6423 (if (or (and gnus-single-article-buffer
6424 (or (null gnus-current-article)
6425 (null gnus-article-current)
6426 (null (get-buffer gnus-article-buffer))
6427 (not (eq article (cdr gnus-article-current)))
6428 (not (equal (car gnus-article-current)
6429 gnus-newsgroup-name))))
6430 (and (not gnus-single-article-buffer)
6431 (or (null gnus-current-article)
6432 (not (eq gnus-current-article article))))
6434 ;; The requested article is different from the current article.
6436 (gnus-summary-display-article article all-headers)
6437 (when (gnus-buffer-live-p gnus-article-buffer)
6438 (with-current-buffer gnus-article-buffer
6439 (if (not gnus-article-decoded-p) ;; a local variable
6440 (mm-disable-multibyte-mule4))))
6441 (when (or all-headers gnus-show-all-headers)
6442 (gnus-article-show-all-headers))
6443 (gnus-article-set-window-start
6444 (cdr (assq article gnus-newsgroup-bookmarks)))
6446 (when (or all-headers gnus-show-all-headers)
6447 (gnus-article-show-all-headers))
6450 (defun gnus-summary-force-verify-and-decrypt ()
6452 (let ((mm-verify-option 'known)
6453 (mm-decrypt-option 'known))
6454 (gnus-summary-select-article nil 'force)))
6456 (defun gnus-summary-set-current-mark (&optional current-mark)
6457 "Obsolete function."
6460 (defun gnus-summary-next-article (&optional unread subject backward push)
6461 "Select the next article.
6462 If UNREAD, only unread articles are selected.
6463 If SUBJECT, only articles with SUBJECT are selected.
6464 If BACKWARD, the previous article is selected instead of the next."
6467 ;; Is there such an article?
6468 ((and (gnus-summary-search-forward unread subject backward)
6469 (or (gnus-summary-display-article (gnus-summary-article-number))
6470 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6471 (gnus-summary-position-point))
6472 ;; If not, we try the first unread, if that is wanted.
6474 gnus-auto-select-same
6475 (gnus-summary-first-unread-article))
6476 (gnus-summary-position-point)
6477 (gnus-message 6 "Wrapped"))
6478 ;; Try to get next/previous article not displayed in this group.
6479 ((and gnus-auto-extend-newsgroup
6480 (not unread) (not subject))
6481 (gnus-summary-goto-article
6482 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6483 nil (count-lines (point-min) (point))))
6484 ;; Go to next/previous group.
6486 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6487 (gnus-summary-jump-to-group gnus-newsgroup-name))
6488 (let ((cmd last-command-char)
6491 (set-buffer gnus-group-buffer)
6494 (if (eq gnus-keep-same-level 'best)
6495 (gnus-summary-best-group gnus-newsgroup-name)
6496 (gnus-summary-search-group backward gnus-keep-same-level))))
6497 ;; For some reason, the group window gets selected. We change
6499 (select-window (get-buffer-window (current-buffer)))
6500 ;; Select next unread newsgroup automagically.
6502 ((or (not gnus-auto-select-next)
6504 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6505 ((or (eq gnus-auto-select-next 'quietly)
6506 (and (eq gnus-auto-select-next 'slightly-quietly)
6508 (and (eq gnus-auto-select-next 'almost-quietly)
6509 (gnus-summary-last-article-p)))
6511 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6513 (gnus-message 7 "No more%s articles (%s)..."
6514 (if unread " unread" "")
6515 (if group (concat "selecting " group)
6517 (gnus-summary-next-group nil group backward)))
6519 (when (gnus-key-press-event-p last-input-event)
6520 (gnus-summary-walk-group-buffer
6521 gnus-newsgroup-name cmd unread backward point))))))))
6523 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6524 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6525 (?\C-p (gnus-group-prev-unread-group 1))))
6526 (cursor-in-echo-area t)
6527 keve key group ended)
6529 (set-buffer gnus-group-buffer)
6532 (if (eq gnus-keep-same-level 'best)
6533 (gnus-summary-best-group gnus-newsgroup-name)
6534 (gnus-summary-search-group backward gnus-keep-same-level))))
6537 5 "No more%s articles%s" (if unread " unread" "")
6539 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6540 (format " (Type %s for %s [%s])"
6541 (single-key-description cmd) group
6542 (car (gnus-gethash group gnus-newsrc-hashtb)))
6543 (format " (Type %s to exit %s)"
6544 (single-key-description cmd)
6545 gnus-newsgroup-name)))
6546 ;; Confirm auto selection.
6547 (setq key (car (setq keve (gnus-read-event-char))))
6550 ((assq key keystrokes)
6551 (let ((obuf (current-buffer)))
6552 (switch-to-buffer gnus-group-buffer)
6554 (gnus-group-jump-to-group group))
6555 (eval (cadr (assq key keystrokes)))
6556 (setq group (gnus-group-group-name))
6557 (switch-to-buffer obuf))
6561 (gnus-ephemeral-group-p gnus-newsgroup-name))
6563 (gnus-summary-next-group nil group backward)))
6565 (push (cdr keve) unread-command-events))))))
6567 (defun gnus-summary-next-unread-article ()
6568 "Select unread article after current one."
6570 (gnus-summary-next-article
6571 (or (not (eq gnus-summary-goto-unread 'never))
6572 (gnus-summary-last-article-p (gnus-summary-article-number)))
6573 (and gnus-auto-select-same
6574 (gnus-summary-article-subject))))
6576 (defun gnus-summary-prev-article (&optional unread subject)
6577 "Select the article after the current one.
6578 If UNREAD is non-nil, only unread articles are selected."
6580 (gnus-summary-next-article unread subject t))
6582 (defun gnus-summary-prev-unread-article ()
6583 "Select unread article before current one."
6585 (gnus-summary-prev-article
6586 (or (not (eq gnus-summary-goto-unread 'never))
6587 (gnus-summary-first-article-p (gnus-summary-article-number)))
6588 (and gnus-auto-select-same
6589 (gnus-summary-article-subject))))
6591 (defun gnus-summary-next-page (&optional lines circular)
6592 "Show next page of the selected article.
6593 If at the end of the current article, select the next article.
6594 LINES says how many lines should be scrolled up.
6596 If CIRCULAR is non-nil, go to the start of the article instead of
6597 selecting the next article when reaching the end of the current
6600 (setq gnus-summary-buffer (current-buffer))
6601 (gnus-set-global-variables)
6602 (let ((article (gnus-summary-article-number))
6603 (article-window (get-buffer-window gnus-article-buffer t))
6605 ;; If the buffer is empty, we have no article.
6607 (error "No article to select"))
6608 (gnus-configure-windows 'article)
6609 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6610 (if (and (eq gnus-summary-goto-unread 'never)
6611 (not (gnus-summary-last-article-p article)))
6612 (gnus-summary-next-article)
6613 (gnus-summary-next-unread-article))
6614 (if (or (null gnus-current-article)
6615 (null gnus-article-current)
6616 (/= article (cdr gnus-article-current))
6617 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6618 ;; Selected subject is different from current article's.
6619 (gnus-summary-display-article article)
6620 (when article-window
6621 (gnus-eval-in-buffer-window gnus-article-buffer
6622 (setq endp (gnus-article-next-page lines)))
6625 (gnus-summary-beginning-of-article))
6627 (gnus-message 3 "End of message"))
6629 (if (and (eq gnus-summary-goto-unread 'never)
6630 (not (gnus-summary-last-article-p article)))
6631 (gnus-summary-next-article)
6632 (gnus-summary-next-unread-article))))))))
6633 (gnus-summary-recenter)
6634 (gnus-summary-position-point)))
6636 (defun gnus-summary-prev-page (&optional lines move)
6637 "Show previous page of selected article.
6638 Argument LINES specifies lines to be scrolled down.
6639 If MOVE, move to the previous unread article if point is at
6640 the beginning of the buffer."
6642 (let ((article (gnus-summary-article-number))
6643 (article-window (get-buffer-window gnus-article-buffer t))
6645 (gnus-configure-windows 'article)
6646 (if (or (null gnus-current-article)
6647 (null gnus-article-current)
6648 (/= article (cdr gnus-article-current))
6649 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6650 ;; Selected subject is different from current article's.
6651 (gnus-summary-display-article article)
6652 (gnus-summary-recenter)
6653 (when article-window
6654 (gnus-eval-in-buffer-window gnus-article-buffer
6655 (setq endp (gnus-article-prev-page lines)))
6656 (when (and move endp)
6658 (gnus-message 3 "Beginning of message"))
6660 (if (and (eq gnus-summary-goto-unread 'never)
6661 (not (gnus-summary-first-article-p article)))
6662 (gnus-summary-prev-article)
6663 (gnus-summary-prev-unread-article))))))))
6664 (gnus-summary-position-point))
6666 (defun gnus-summary-prev-page-or-article (&optional lines)
6667 "Show previous page of selected article.
6668 Argument LINES specifies lines to be scrolled down.
6669 If at the beginning of the article, go to the next article."
6671 (gnus-summary-prev-page lines t))
6673 (defun gnus-summary-scroll-up (lines)
6674 "Scroll up (or down) one line current article.
6675 Argument LINES specifies lines to be scrolled up (or down if negative)."
6677 (gnus-configure-windows 'article)
6678 (gnus-summary-show-thread)
6679 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6680 (gnus-eval-in-buffer-window gnus-article-buffer
6682 (when (gnus-article-next-page lines)
6683 (gnus-message 3 "End of message")))
6685 (gnus-article-prev-page (- lines))))))
6686 (gnus-summary-recenter)
6687 (gnus-summary-position-point))
6689 (defun gnus-summary-scroll-down (lines)
6690 "Scroll down (or up) one line current article.
6691 Argument LINES specifies lines to be scrolled down (or up if negative)."
6693 (gnus-summary-scroll-up (- lines)))
6695 (defun gnus-summary-next-same-subject ()
6696 "Select next article which has the same subject as current one."
6698 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6700 (defun gnus-summary-prev-same-subject ()
6701 "Select previous article which has the same subject as current one."
6703 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6705 (defun gnus-summary-next-unread-same-subject ()
6706 "Select next unread article which has the same subject as current one."
6708 (gnus-summary-next-article t (gnus-summary-article-subject)))
6710 (defun gnus-summary-prev-unread-same-subject ()
6711 "Select previous unread article which has the same subject as current one."
6713 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6715 (defun gnus-summary-first-unread-article ()
6716 "Select the first unread article.
6717 Return nil if there are no unread articles."
6720 (when (gnus-summary-first-subject t)
6721 (gnus-summary-show-thread)
6722 (gnus-summary-first-subject t)
6723 (gnus-summary-display-article (gnus-summary-article-number)))
6724 (gnus-summary-position-point)))
6726 (defun gnus-summary-first-unread-subject ()
6727 "Place the point on the subject line of the first unread article.
6728 Return nil if there are no unread articles."
6731 (when (gnus-summary-first-subject t)
6732 (gnus-summary-show-thread)
6733 (gnus-summary-first-subject t))
6734 (gnus-summary-position-point)))
6736 (defun gnus-summary-first-article ()
6737 "Select the first article.
6738 Return nil if there are no articles."
6741 (when (gnus-summary-first-subject)
6742 (gnus-summary-show-thread)
6743 (gnus-summary-first-subject)
6744 (gnus-summary-display-article (gnus-summary-article-number)))
6745 (gnus-summary-position-point)))
6747 (defun gnus-summary-best-unread-article ()
6748 "Select the unread article with the highest score."
6750 (let ((best -1000000)
6751 (data gnus-newsgroup-data)
6754 (and (gnus-data-unread-p (car data))
6756 (gnus-summary-article-score (gnus-data-number (car data))))
6759 article (gnus-data-number (car data))))
6760 (setq data (cdr data)))
6763 (gnus-summary-goto-article article)
6764 (error "No unread articles"))
6765 (gnus-summary-position-point))))
6767 (defun gnus-summary-last-subject ()
6768 "Go to the last displayed subject line in the group."
6769 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6771 (gnus-summary-goto-subject article))))
6773 (defun gnus-summary-goto-article (article &optional all-headers force)
6774 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6775 If ALL-HEADERS is non-nil, no header lines are hidden.
6776 If FORCE, go to the article even if it isn't displayed. If FORCE
6777 is a number, it is the line the article is to be displayed on."
6781 "Article number or Message-ID: "
6782 (mapcar (lambda (number) (list (int-to-string number)))
6783 gnus-newsgroup-limit))
6787 (if (and (stringp article)
6788 (string-match "@" article))
6789 (gnus-summary-refer-article article)
6790 (when (stringp article)
6791 (setq article (string-to-number article)))
6792 (if (gnus-summary-goto-subject article force)
6793 (gnus-summary-display-article article all-headers)
6794 (gnus-message 4 "Couldn't go to article %s" article) nil))
6795 (gnus-summary-position-point)))
6797 (defun gnus-summary-goto-last-article ()
6798 "Go to the previously read article."
6801 (when gnus-last-article
6802 (gnus-summary-goto-article gnus-last-article nil t))
6803 (gnus-summary-position-point)))
6805 (defun gnus-summary-pop-article (number)
6806 "Pop one article off the history and go to the previous.
6807 NUMBER articles will be popped off."
6810 (setq gnus-newsgroup-history
6811 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6813 (gnus-summary-goto-article (car to) nil t)
6814 (error "Article history empty")))
6815 (gnus-summary-position-point))
6817 ;; Summary commands and functions for limiting the summary buffer.
6819 (defun gnus-summary-limit-to-articles (n)
6820 "Limit the summary buffer to the next N articles.
6821 If not given a prefix, use the process marked articles instead."
6824 (let ((articles (gnus-summary-work-articles n)))
6825 (setq gnus-newsgroup-processable nil)
6826 (gnus-summary-limit articles))
6827 (gnus-summary-position-point)))
6829 (defun gnus-summary-pop-limit (&optional total)
6830 "Restore the previous limit.
6831 If given a prefix, remove all limits."
6834 (setq gnus-newsgroup-limits
6835 (list (mapcar (lambda (h) (mail-header-number h))
6836 gnus-newsgroup-headers))))
6837 (unless gnus-newsgroup-limits
6838 (error "No limit to pop"))
6840 (gnus-summary-limit nil 'pop)
6841 (gnus-summary-position-point)))
6843 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6844 "Limit the summary buffer to articles that have subjects that match a regexp.
6845 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6847 (list (read-string (if current-prefix-arg
6848 "Exclude subject (regexp): "
6849 "Limit to subject (regexp): "))
6850 nil current-prefix-arg))
6852 (setq header "subject"))
6853 (when (not (equal "" subject))
6855 (let ((articles (gnus-summary-find-matching
6856 (or header "subject") subject 'all nil nil
6859 (error "Found no matches for \"%s\"" subject))
6860 (gnus-summary-limit articles))
6861 (gnus-summary-position-point))))
6863 (defun gnus-summary-limit-to-author (from &optional not-matching)
6864 "Limit the summary buffer to articles that have authors that match a regexp.
6865 If NOT-MATCHING, excluding articles that have authors that match a regexp."
6867 (list (read-string (if current-prefix-arg
6868 "Exclude author (regexp): "
6869 "Limit to author (regexp): "))
6870 current-prefix-arg))
6871 (gnus-summary-limit-to-subject from "from" not-matching))
6873 (defun gnus-summary-limit-to-age (age &optional younger-p)
6874 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6875 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6876 articles that are younger than AGE days."
6878 (let ((younger current-prefix-arg)
6881 (while (not days-got)
6882 (setq days (if younger
6883 (read-string "Limit to articles within (in days): ")
6884 (read-string "Limit to articles older than (in days): ")))
6885 (when (> (length days) 0)
6886 (setq days (read days)))
6889 (message "Please enter a number.")
6891 (list days younger)))
6893 (let ((data gnus-newsgroup-data)
6894 (cutoff (days-to-time age))
6895 articles d date is-younger)
6896 (while (setq d (pop data))
6897 (when (and (vectorp (gnus-data-header d))
6898 (setq date (mail-header-date (gnus-data-header d))))
6899 (setq is-younger (time-less-p
6900 (time-since (condition-case ()
6907 (push (gnus-data-number d) articles))))
6908 (gnus-summary-limit (nreverse articles)))
6909 (gnus-summary-position-point)))
6911 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
6912 "Limit the summary buffer to articles that match an 'extra' header."
6916 (gnus-completing-read
6917 (symbol-name (car gnus-extra-headers))
6918 (if current-prefix-arg
6919 "Exclude extra header:"
6920 "Limit extra header:")
6922 (cons (symbol-name x) x))
6927 (read-string (format "%s header %s (regexp): "
6928 (if current-prefix-arg "Exclude" "Limit to")
6930 current-prefix-arg)))
6931 (when (not (equal "" regexp))
6933 (let ((articles (gnus-summary-find-matching
6934 (cons 'extra header) regexp 'all nil nil
6937 (error "Found no matches for \"%s\"" regexp))
6938 (gnus-summary-limit articles))
6939 (gnus-summary-position-point))))
6941 (defun gnus-summary-limit-to-display-predicate ()
6942 "Limit the summary buffer to the predicated in the `display' group parameter."
6944 (unless gnus-newsgroup-display
6945 (error "There is no `display' group parameter"))
6947 (dolist (number gnus-newsgroup-articles)
6948 (when (funcall gnus-newsgroup-display)
6949 (push number articles)))
6950 (gnus-summary-limit articles))
6951 (gnus-summary-position-point))
6953 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6955 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6957 (defun gnus-summary-limit-to-unread (&optional all)
6958 "Limit the summary buffer to articles that are not marked as read.
6959 If ALL is non-nil, limit strictly to unread articles."
6962 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6963 (gnus-summary-limit-to-marks
6964 ;; Concat all the marks that say that an article is read and have
6966 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6967 gnus-killed-mark gnus-kill-file-mark
6968 gnus-low-score-mark gnus-expirable-mark
6969 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6970 gnus-duplicate-mark gnus-souped-mark)
6973 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6974 (make-obsolete 'gnus-summary-delete-marked-with
6975 'gnus-summary-limit-exlude-marks)
6977 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6978 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6979 If REVERSE, limit the summary buffer to articles that are marked
6980 with MARKS. MARKS can either be a string of marks or a list of marks.
6981 Returns how many articles were removed."
6982 (interactive "sMarks: ")
6983 (gnus-summary-limit-to-marks marks t))
6985 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6986 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6987 If REVERSE (the prefix), limit the summary buffer to articles that are
6988 not marked with MARKS. MARKS can either be a string of marks or a
6990 Returns how many articles were removed."
6991 (interactive "sMarks: \nP")
6993 (let ((data gnus-newsgroup-data)
6994 (marks (if (listp marks) marks
6995 (append marks nil))) ; Transform to list.
6998 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6999 (memq (gnus-data-mark (car data)) marks))
7000 (push (gnus-data-number (car data)) articles))
7001 (setq data (cdr data)))
7002 (gnus-summary-limit articles))
7003 (gnus-summary-position-point)))
7005 (defun gnus-summary-limit-to-score (score)
7006 "Limit to articles with score at or above SCORE."
7007 (interactive "NLimit to articles with score of at least: ")
7008 (let ((data gnus-newsgroup-data)
7011 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7013 (push (gnus-data-number (car data)) articles))
7014 (setq data (cdr data)))
7016 (gnus-summary-limit articles)
7017 (gnus-summary-position-point))))
7019 (defun gnus-summary-limit-include-thread (id)
7020 "Display all the hidden articles that is in the thread with ID in it.
7021 When called interactively, ID is the Message-ID of the current
7023 (interactive (list (mail-header-id (gnus-summary-article-header))))
7024 (let ((articles (gnus-articles-in-thread
7025 (gnus-id-to-thread (gnus-root-id id)))))
7027 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7028 (gnus-summary-limit-include-matching-articles
7030 (regexp-quote (gnus-simplify-subject-re
7031 (mail-header-subject (gnus-id-to-header id)))))
7032 (gnus-summary-position-point))))
7034 (defun gnus-summary-limit-include-matching-articles (header regexp)
7035 "Display all the hidden articles that have HEADERs that match REGEXP."
7036 (interactive (list (read-string "Match on header: ")
7037 (read-string "Regexp: ")))
7038 (let ((articles (gnus-find-matching-articles header regexp)))
7040 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7041 (gnus-summary-position-point))))
7043 (defun gnus-summary-limit-include-dormant ()
7044 "Display all the hidden articles that are marked as dormant.
7045 Note that this command only works on a subset of the articles currently
7046 fetched for this group."
7048 (unless gnus-newsgroup-dormant
7049 (error "There are no dormant articles in this group"))
7051 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7052 (gnus-summary-position-point)))
7054 (defun gnus-summary-limit-exclude-dormant ()
7055 "Hide all dormant articles."
7058 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7059 (gnus-summary-position-point)))
7061 (defun gnus-summary-limit-exclude-childless-dormant ()
7062 "Hide all dormant articles that have no children."
7064 (let ((data (gnus-data-list t))
7065 articles d children)
7066 ;; Find all articles that are either not dormant or have
7068 (while (setq d (pop data))
7069 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7071 (gnus-article-children (gnus-data-number d)))
7074 (when (memq (car children) articles)
7079 (push (gnus-data-number d) articles)))
7082 (gnus-summary-limit articles)
7083 (gnus-summary-position-point))))
7085 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7086 "Mark all unread excluded articles as read.
7087 If ALL, mark even excluded ticked and dormants as read."
7089 (let ((articles (gnus-sorted-complement
7091 (mapcar (lambda (h) (mail-header-number h))
7092 gnus-newsgroup-headers)
7094 (sort gnus-newsgroup-limit '<)))
7096 (setq gnus-newsgroup-unreads
7097 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7099 (setq gnus-newsgroup-dormant nil
7100 gnus-newsgroup-marked nil
7101 gnus-newsgroup-reads
7103 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7104 gnus-newsgroup-reads))
7105 (while (setq article (pop articles))
7106 (unless (or (memq article gnus-newsgroup-dormant)
7107 (memq article gnus-newsgroup-marked))
7108 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7110 (defun gnus-summary-limit (articles &optional pop)
7112 ;; We pop the previous limit off the stack and use that.
7113 (setq articles (car gnus-newsgroup-limits)
7114 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7115 ;; We use the new limit, so we push the old limit on the stack.
7116 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7118 (setq gnus-newsgroup-limit articles)
7119 (let ((total (length gnus-newsgroup-data))
7120 (data (gnus-data-find-list (gnus-summary-article-number)))
7121 (gnus-summary-mark-below nil) ; Inhibit this.
7123 ;; This will do all the work of generating the new summary buffer
7124 ;; according to the new limit.
7125 (gnus-summary-prepare)
7126 ;; Hide any threads, possibly.
7127 (and gnus-show-threads
7128 gnus-thread-hide-subtree
7129 (gnus-summary-hide-all-threads))
7130 ;; Try to return to the article you were at, or one in the
7133 ;; We try to find some article after the current one.
7135 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7138 (setq data (cdr data))))
7140 ;; If there is no data, that means that we were after the last
7141 ;; article. The same goes when we can't find any articles
7142 ;; after the current one.
7143 (goto-char (point-max))
7144 (gnus-summary-find-prev))
7145 (gnus-set-mode-line 'summary)
7146 ;; We return how many articles were removed from the summary
7147 ;; buffer as a result of the new limit.
7148 (- total (length gnus-newsgroup-data))))
7150 (defsubst gnus-invisible-cut-children (threads)
7153 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7158 (defsubst gnus-cut-thread (thread)
7159 "Go forwards in the thread until we find an article that we want to display."
7160 (when (or (eq gnus-fetch-old-headers 'some)
7161 (eq gnus-fetch-old-headers 'invisible)
7162 (numberp gnus-fetch-old-headers)
7163 (eq gnus-build-sparse-threads 'some)
7164 (eq gnus-build-sparse-threads 'more))
7165 ;; Deal with old-fetched headers and sparse threads.
7169 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7170 (gnus-summary-article-ancient-p
7171 (mail-header-number (car thread))))
7172 (if (or (<= (length (cdr thread)) 1)
7173 (eq gnus-fetch-old-headers 'invisible))
7174 (setq gnus-newsgroup-limit
7175 (delq (mail-header-number (car thread))
7176 gnus-newsgroup-limit)
7177 thread (cadr thread))
7178 (when (gnus-invisible-cut-children (cdr thread))
7179 (let ((th (cdr thread)))
7181 (if (memq (mail-header-number (caar th))
7182 gnus-newsgroup-limit)
7183 (setq thread (car th)
7185 (setq th (cdr th))))))))))
7188 (defun gnus-cut-threads (threads)
7189 "Cut off all uninteresting articles from the beginning of threads."
7190 (when (or (eq gnus-fetch-old-headers 'some)
7191 (eq gnus-fetch-old-headers 'invisible)
7192 (numberp gnus-fetch-old-headers)
7193 (eq gnus-build-sparse-threads 'some)
7194 (eq gnus-build-sparse-threads 'more))
7197 (setcar th (gnus-cut-thread (car th)))
7198 (setq th (cdr th)))))
7199 ;; Remove nixed out threads.
7202 (defun gnus-summary-initial-limit (&optional show-if-empty)
7203 "Figure out what the initial limit is supposed to be on group entry.
7204 This entails weeding out unwanted dormants, low-scored articles,
7205 fetch-old-headers verbiage, and so on."
7206 ;; Most groups have nothing to remove.
7207 (if (or gnus-inhibit-limiting
7208 (and (null gnus-newsgroup-dormant)
7209 (eq gnus-newsgroup-display 'gnus-not-ignore)
7210 (not (eq gnus-fetch-old-headers 'some))
7211 (not (numberp gnus-fetch-old-headers))
7212 (not (eq gnus-fetch-old-headers 'invisible))
7213 (null gnus-summary-expunge-below)
7214 (not (eq gnus-build-sparse-threads 'some))
7215 (not (eq gnus-build-sparse-threads 'more))
7216 (null gnus-thread-expunge-below)
7217 (not gnus-use-nocem)))
7219 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7220 (setq gnus-newsgroup-limit nil)
7223 (unless (car (symbol-value node))
7224 ;; These threads have no parents -- they are roots.
7225 (let ((nodes (cdr (symbol-value node)))
7228 (if (and gnus-thread-expunge-below
7229 (< (gnus-thread-total-score (car nodes))
7230 gnus-thread-expunge-below))
7231 (gnus-expunge-thread (pop nodes))
7232 (setq thread (pop nodes))
7233 (gnus-summary-limit-children thread))))))
7234 gnus-newsgroup-dependencies)
7235 ;; If this limitation resulted in an empty group, we might
7236 ;; pop the previous limit and use it instead.
7237 (when (and (not gnus-newsgroup-limit)
7239 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7240 gnus-newsgroup-limit))
7242 (defun gnus-summary-limit-children (thread)
7243 "Return 1 if this subthread is visible and 0 if it is not."
7244 ;; First we get the number of visible children to this thread. This
7245 ;; is done by recursing down the thread using this function, so this
7246 ;; will really go down to a leaf article first, before slowly
7247 ;; working its way up towards the root.
7251 (apply '+ (mapcar 'gnus-summary-limit-children
7254 (number (mail-header-number (car thread)))
7257 (not (memq number gnus-newsgroup-marked))
7259 ;; If this article is dormant and has absolutely no visible
7260 ;; children, then this article isn't visible.
7261 (and (memq number gnus-newsgroup-dormant)
7263 ;; If this is "fetch-old-headered" and there is no
7264 ;; visible children, then we don't want this article.
7265 (and (or (eq gnus-fetch-old-headers 'some)
7266 (numberp gnus-fetch-old-headers))
7267 (gnus-summary-article-ancient-p number)
7269 ;; If this is "fetch-old-headered" and `invisible', then
7270 ;; we don't want this article.
7271 (and (eq gnus-fetch-old-headers 'invisible)
7272 (gnus-summary-article-ancient-p number))
7273 ;; If this is a sparsely inserted article with no children,
7274 ;; we don't want it.
7275 (and (eq gnus-build-sparse-threads 'some)
7276 (gnus-summary-article-sparse-p number)
7278 ;; If we use expunging, and this article is really
7279 ;; low-scored, then we don't want this article.
7280 (when (and gnus-summary-expunge-below
7282 (or (cdr (assq number gnus-newsgroup-scored))
7283 gnus-summary-default-score))
7284 gnus-summary-expunge-below))
7285 ;; We increase the expunge-tally here, but that has
7286 ;; nothing to do with the limits, really.
7287 (incf gnus-newsgroup-expunged-tally)
7288 ;; We also mark as read here, if that's wanted.
7289 (when (and gnus-summary-mark-below
7290 (< score gnus-summary-mark-below))
7291 (setq gnus-newsgroup-unreads
7292 (delq number gnus-newsgroup-unreads))
7293 (if gnus-newsgroup-auto-expire
7294 (push number gnus-newsgroup-expirable)
7295 (push (cons number gnus-low-score-mark)
7296 gnus-newsgroup-reads)))
7298 ;; Do the `display' group parameter.
7299 (and gnus-newsgroup-display
7300 (not (funcall gnus-newsgroup-display)))
7301 ;; Check NoCeM things.
7302 (if (and gnus-use-nocem
7303 (gnus-nocem-unwanted-article-p
7304 (mail-header-id (car thread))))
7306 (setq gnus-newsgroup-unreads
7307 (delq number gnus-newsgroup-unreads))
7309 ;; Nope, invisible article.
7311 ;; Ok, this article is to be visible, so we add it to the limit
7313 (push number gnus-newsgroup-limit)
7316 (defun gnus-expunge-thread (thread)
7317 "Mark all articles in THREAD as read."
7318 (let* ((number (mail-header-number (car thread))))
7319 (incf gnus-newsgroup-expunged-tally)
7320 ;; We also mark as read here, if that's wanted.
7321 (setq gnus-newsgroup-unreads
7322 (delq number gnus-newsgroup-unreads))
7323 (if gnus-newsgroup-auto-expire
7324 (push number gnus-newsgroup-expirable)
7325 (push (cons number gnus-low-score-mark)
7326 gnus-newsgroup-reads)))
7327 ;; Go recursively through all subthreads.
7328 (mapcar 'gnus-expunge-thread (cdr thread)))
7330 ;; Summary article oriented commands
7332 (defun gnus-summary-refer-parent-article (n)
7333 "Refer parent article N times.
7334 If N is negative, go to ancestor -N instead.
7335 The difference between N and the number of articles fetched is returned."
7339 (when (not (natnump n))
7344 (setq header (gnus-summary-article-header))
7345 (if (and (eq (mail-header-number header)
7346 (cdr gnus-article-current))
7347 (equal gnus-newsgroup-name
7348 (car gnus-article-current)))
7349 ;; If we try to find the parent of the currently
7350 ;; displayed article, then we take a look at the actual
7351 ;; References header, since this is slightly more
7352 ;; reliable than the References field we got from the
7355 (set-buffer gnus-original-article-buffer)
7356 (nnheader-narrow-to-headers)
7357 (unless (setq ref (message-fetch-field "references"))
7358 (setq ref (message-fetch-field "in-reply-to")))
7361 ;; It's not the current article, so we take a bet on
7362 ;; the value we got from the server.
7363 (mail-header-references header)))
7365 (not (equal ref "")))
7366 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7367 (gnus-message 1 "Couldn't find parent"))
7368 (gnus-message 1 "No references in article %d"
7369 (gnus-summary-article-number))
7372 (gnus-summary-position-point)
7375 (defun gnus-summary-refer-references ()
7376 "Fetch all articles mentioned in the References header.
7377 Return the number of articles fetched."
7379 (let ((ref (mail-header-references (gnus-summary-article-header)))
7380 (current (gnus-summary-article-number))
7384 (error "No References in the current article")
7385 ;; For each Message-ID in the References header...
7386 (while (string-match "<[^>]*>" ref)
7388 ;; ... fetch that article.
7389 (gnus-summary-refer-article
7390 (prog1 (match-string 0 ref)
7391 (setq ref (substring ref (match-end 0))))))
7392 (gnus-summary-goto-subject current)
7393 (gnus-summary-position-point)
7396 (defun gnus-summary-refer-thread (&optional limit)
7397 "Fetch all articles in the current thread.
7398 If LIMIT (the numerical prefix), fetch that many old headers instead
7399 of what's specified by the `gnus-refer-thread-limit' variable."
7401 (let ((id (mail-header-id (gnus-summary-article-header)))
7402 (limit (if limit (prefix-numeric-value limit)
7403 gnus-refer-thread-limit)))
7404 ;; We want to fetch LIMIT *old* headers, but we also have to
7405 ;; re-fetch all the headers in the current buffer, because many of
7406 ;; them may be undisplayed. So we adjust LIMIT.
7407 (when (numberp limit)
7408 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7409 (unless (eq gnus-fetch-old-headers 'invisible)
7410 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7411 ;; Retrieve the headers and read them in.
7412 (if (eq (gnus-retrieve-headers
7413 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7415 (gnus-build-all-threads)
7416 (error "Can't fetch thread from backends that don't support NOV"))
7417 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7418 (gnus-summary-limit-include-thread id)))
7420 (defun gnus-summary-refer-article (message-id)
7421 "Fetch an article specified by MESSAGE-ID."
7422 (interactive "sMessage-ID: ")
7423 (when (and (stringp message-id)
7424 (not (zerop (length message-id))))
7425 ;; Construct the correct Message-ID if necessary.
7426 ;; Suggested by tale@pawl.rpi.edu.
7427 (unless (string-match "^<" message-id)
7428 (setq message-id (concat "<" message-id)))
7429 (unless (string-match ">$" message-id)
7430 (setq message-id (concat message-id ">")))
7431 (let* ((header (gnus-id-to-header message-id))
7433 (gnus-summary-article-sparse-p
7434 (mail-header-number header))
7435 (memq (mail-header-number header)
7436 gnus-newsgroup-limit)))
7439 ;; If the article is present in the buffer we just go to it.
7441 (or (not (gnus-summary-article-sparse-p
7442 (mail-header-number header)))
7445 (gnus-summary-goto-article
7446 (mail-header-number header) nil t)
7448 (gnus-summary-update-article (mail-header-number header)))))
7450 ;; We fetch the article.
7452 (dolist (gnus-override-method (gnus-refer-article-methods))
7453 (gnus-check-server gnus-override-method)
7454 ;; Fetch the header, and display the article.
7455 (when (setq number (gnus-summary-insert-subject message-id))
7456 (gnus-summary-select-article nil nil nil number)
7458 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7460 (defun gnus-refer-article-methods ()
7461 "Return a list of referrable methods."
7463 ;; No method, so we default to current and native.
7464 ((null gnus-refer-article-method)
7465 (list gnus-current-select-method gnus-select-method))
7467 ((eq 'current gnus-refer-article-method)
7468 (list gnus-current-select-method))
7469 ;; List of select methods.
7470 ((not (and (symbolp (car gnus-refer-article-method))
7471 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7473 (dolist (method gnus-refer-article-method)
7474 (push (if (eq 'current method)
7475 gnus-current-select-method
7479 ;; One single select method.
7481 (list gnus-refer-article-method))))
7483 (defun gnus-summary-edit-parameters ()
7484 "Edit the group parameters of the current group."
7486 (gnus-group-edit-group gnus-newsgroup-name 'params))
7488 (defun gnus-summary-customize-parameters ()
7489 "Customize the group parameters of the current group."
7491 (gnus-group-customize gnus-newsgroup-name))
7493 (defun gnus-summary-enter-digest-group (&optional force)
7494 "Enter an nndoc group based on the current article.
7495 If FORCE, force a digest interpretation. If not, try
7496 to guess what the document format is."
7498 (let ((conf gnus-current-window-configuration))
7500 (gnus-summary-select-article))
7501 (setq gnus-current-window-configuration conf)
7502 (let* ((name (format "%s-%d"
7503 (gnus-group-prefixed-name
7504 gnus-newsgroup-name (list 'nndoc ""))
7506 (set-buffer gnus-summary-buffer)
7507 gnus-current-article)))
7508 (ogroup gnus-newsgroup-name)
7509 (params (append (gnus-info-params (gnus-get-info ogroup))
7510 (list (cons 'to-group ogroup))
7511 (list (cons 'save-article-group ogroup))))
7512 (case-fold-search t)
7513 (buf (current-buffer))
7516 (set-buffer gnus-original-article-buffer)
7517 ;; Have the digest group inherit the main mail address of
7518 ;; the parent article.
7519 (when (setq to-address (or (message-fetch-field "reply-to")
7520 (message-fetch-field "from")))
7521 (setq params (append
7522 (list (cons 'to-address
7523 (funcall gnus-decode-encoded-word-function
7525 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7526 (insert-buffer-substring gnus-original-article-buffer)
7527 ;; Remove lines that may lead nndoc to misinterpret the
7530 (goto-char (point-min))
7531 (or (search-forward "\n\n" nil t) (point)))
7532 (goto-char (point-min))
7533 (delete-matching-lines "^Path:\\|^From ")
7536 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7537 (gnus-newsgroup-ephemeral-ignored-charsets
7538 gnus-newsgroup-ignored-charsets))
7539 (gnus-group-read-ephemeral-group
7540 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7542 ,(if force 'mbox 'guess))) t))
7543 ;; Make all postings to this group go to the parent group.
7544 (nconc (gnus-info-params (gnus-get-info name))
7546 ;; Couldn't select this doc group.
7547 (switch-to-buffer buf)
7548 (gnus-set-global-variables)
7549 (gnus-configure-windows 'summary)
7550 (gnus-message 3 "Article couldn't be entered?"))
7551 (kill-buffer dig)))))
7553 (defun gnus-summary-read-document (n)
7554 "Open a new group based on the current article(s).
7555 This will allow you to read digests and other similar
7556 documents as newsgroups.
7557 Obeys the standard process/prefix convention."
7559 (let* ((articles (gnus-summary-work-articles n))
7560 (ogroup gnus-newsgroup-name)
7561 (params (append (gnus-info-params (gnus-get-info ogroup))
7562 (list (cons 'to-group ogroup))))
7563 article group egroup groups vgroup)
7564 (while (setq article (pop articles))
7565 (setq group (format "%s-%d" gnus-newsgroup-name article))
7566 (gnus-summary-remove-process-mark article)
7567 (when (gnus-summary-display-article article)
7570 (insert-buffer-substring gnus-original-article-buffer)
7571 ;; Remove some headers that may lead nndoc to make
7573 (message-narrow-to-head)
7574 (goto-char (point-min))
7575 (delete-matching-lines "^\\(Path\\):\\|^From ")
7578 (gnus-group-read-ephemeral-group
7579 group `(nndoc ,group (nndoc-address ,(current-buffer))
7580 (nndoc-article-type guess))
7583 ;; Make all postings to this group go to the parent group.
7584 (nconc (gnus-info-params (gnus-get-info egroup))
7586 (push egroup groups))
7587 ;; Couldn't select this doc group.
7588 (gnus-error 3 "Article couldn't be entered"))))))
7589 ;; Now we have selected all the documents.
7592 (error "None of the articles could be interpreted as documents"))
7593 ((gnus-group-read-ephemeral-group
7594 (setq vgroup (format
7595 "nnvirtual:%s-%s" gnus-newsgroup-name
7596 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7597 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7599 (cons (current-buffer) 'summary)))
7601 (error "Couldn't select virtual nndoc group")))))
7603 (defun gnus-summary-isearch-article (&optional regexp-p)
7604 "Do incremental search forward on the current article.
7605 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7607 (gnus-summary-select-article)
7608 (gnus-configure-windows 'article)
7609 (gnus-eval-in-buffer-window gnus-article-buffer
7612 (isearch-forward regexp-p))))
7614 (defun gnus-summary-search-article-forward (regexp &optional backward)
7615 "Search for an article containing REGEXP forward.
7616 If BACKWARD, search backward instead."
7619 (format "Search article %s (regexp%s): "
7620 (if current-prefix-arg "backward" "forward")
7621 (if gnus-last-search-regexp
7622 (concat ", default " gnus-last-search-regexp)
7624 current-prefix-arg))
7625 (if (string-equal regexp "")
7626 (setq regexp (or gnus-last-search-regexp ""))
7627 (setq gnus-last-search-regexp regexp)
7628 (setq gnus-article-before-search gnus-current-article))
7629 ;; Intentionally set gnus-last-article.
7630 (setq gnus-last-article gnus-article-before-search)
7631 (let ((gnus-last-article gnus-last-article))
7632 (if (gnus-summary-search-article regexp backward)
7633 (gnus-summary-show-thread)
7634 (error "Search failed: \"%s\"" regexp))))
7636 (defun gnus-summary-search-article-backward (regexp)
7637 "Search for an article containing REGEXP backward."
7640 (format "Search article backward (regexp%s): "
7641 (if gnus-last-search-regexp
7642 (concat ", default " gnus-last-search-regexp)
7644 (gnus-summary-search-article-forward regexp 'backward))
7646 (defun gnus-summary-search-article (regexp &optional backward)
7647 "Search for an article containing REGEXP.
7648 Optional argument BACKWARD means do search for backward.
7649 `gnus-select-article-hook' is not called during the search."
7650 ;; We have to require this here to make sure that the following
7651 ;; dynamic binding isn't shadowed by autoloading.
7652 (require 'gnus-async)
7654 (let ((gnus-select-article-hook nil) ;Disable hook.
7655 (gnus-article-prepare-hook nil)
7656 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7657 (gnus-use-article-prefetch nil)
7658 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7659 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7660 (sum (current-buffer))
7661 (gnus-display-mime-function nil)
7664 (gnus-save-hidden-threads
7665 (gnus-summary-select-article)
7666 (set-buffer gnus-article-buffer)
7667 (goto-char (window-point (get-buffer-window (current-buffer))))
7671 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7673 (re-search-backward regexp nil t)
7674 (re-search-forward regexp nil t))
7675 ;; We found the regexp.
7680 (get-buffer-window (current-buffer))
7684 (get-buffer-window (current-buffer))
7687 (setq point (point)))
7688 ;; We didn't find it, so we go to the next article.
7691 (while (eq found 'not)
7692 (if (not (if backward (gnus-summary-find-prev)
7693 (gnus-summary-find-next)))
7694 ;; No more articles.
7696 ;; Select the next article and adjust point.
7697 (unless (gnus-summary-article-sparse-p
7698 (gnus-summary-article-number))
7700 (gnus-summary-select-article)
7701 (set-buffer gnus-article-buffer)
7703 (goto-char (if backward (point-max) (point-min))))))))
7704 (gnus-message 7 ""))
7705 ;; Return whether we found the regexp.
7706 (when (eq found 'found)
7708 (gnus-summary-show-thread)
7709 (gnus-summary-goto-subject gnus-current-article)
7710 (gnus-summary-position-point)
7713 (defun gnus-find-matching-articles (header regexp)
7714 "Return a list of all articles that match REGEXP on HEADER.
7715 This search includes all articles in the current group that Gnus has
7716 fetched headers for, whether they are displayed or not."
7717 (let ((articles nil)
7718 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7719 (case-fold-search t))
7720 (dolist (header gnus-newsgroup-headers)
7721 (when (string-match regexp (funcall func header))
7722 (push (mail-header-number header) articles)))
7723 (nreverse articles)))
7725 (defun gnus-summary-find-matching (header regexp &optional backward unread
7726 not-case-fold not-matching)
7727 "Return a list of all articles that match REGEXP on HEADER.
7728 The search stars on the current article and goes forwards unless
7729 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7730 If UNREAD is non-nil, only unread articles will
7731 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7732 in the comparisons. If NOT-MATCHING, return a list of all articles that
7733 not match REGEXP on HEADER."
7734 (let ((case-fold-search (not not-case-fold))
7737 (if (eq (car header) 'extra)
7740 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7742 (error "%s is an invalid header" header))
7743 (unless (fboundp (intern (concat "mail-header-" header)))
7744 (error "%s is not a valid header" header))
7745 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7746 (dolist (d (if (eq backward 'all)
7748 (gnus-data-find-list
7749 (gnus-summary-article-number)
7750 (gnus-data-list backward))))
7751 (when (and (or (not unread) ; We want all articles...
7752 (gnus-data-unread-p d)) ; Or just unreads.
7753 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7757 (funcall func (gnus-data-header d))))
7758 (string-match regexp
7759 (funcall func (gnus-data-header d)))))
7760 (push (gnus-data-number d) articles))) ; Success!
7761 (nreverse articles)))
7763 (defun gnus-summary-execute-command (header regexp command &optional backward)
7764 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7765 If HEADER is an empty string (or nil), the match is done on the entire
7766 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7768 (list (let ((completion-ignore-case t))
7771 (mapcar (lambda (header) (list (format "%s" header)))
7773 '("Number" "Subject" "From" "Lines" "Date"
7774 "Message-ID" "Xref" "References" "Body")
7775 gnus-extra-headers))
7776 nil 'require-match))
7777 (read-string "Regexp: ")
7778 (read-key-sequence "Command: ")
7779 current-prefix-arg))
7780 (when (equal header "Body")
7782 ;; Hidden thread subtrees must be searched as well.
7783 (gnus-summary-show-all-threads)
7784 ;; We don't want to change current point nor window configuration.
7786 (save-window-excursion
7787 (gnus-message 6 "Executing %s..." (key-description command))
7788 ;; We'd like to execute COMMAND interactively so as to give arguments.
7789 (gnus-execute header regexp
7790 `(call-interactively ',(key-binding command))
7792 (gnus-message 6 "Executing %s...done" (key-description command)))))
7794 (defun gnus-summary-beginning-of-article ()
7795 "Scroll the article back to the beginning."
7797 (gnus-summary-select-article)
7798 (gnus-configure-windows 'article)
7799 (gnus-eval-in-buffer-window gnus-article-buffer
7801 (goto-char (point-min))
7802 (when gnus-page-broken
7803 (gnus-narrow-to-page))))
7805 (defun gnus-summary-end-of-article ()
7806 "Scroll to the end of the article."
7808 (gnus-summary-select-article)
7809 (gnus-configure-windows 'article)
7810 (gnus-eval-in-buffer-window gnus-article-buffer
7812 (goto-char (point-max))
7814 (when gnus-page-broken
7815 (gnus-narrow-to-page))))
7817 (defun gnus-summary-print-truncate-and-quote (string &optional len)
7818 "Truncate to LEN and quote all \"(\"'s in STRING."
7819 (gnus-replace-in-string (if (and len (> (length string) len))
7820 (substring string 0 len)
7824 (defun gnus-summary-print-article (&optional filename n)
7825 "Generate and print a PostScript image of the N next (mail) articles.
7827 If N is negative, print the N previous articles. If N is nil and articles
7828 have been marked with the process mark, print these instead.
7830 If the optional first argument FILENAME is nil, send the image to the
7831 printer. If FILENAME is a string, save the PostScript image in a file with
7832 that name. If FILENAME is a number, prompt the user for the name of the file
7834 (interactive (list (ps-print-preprint current-prefix-arg)))
7835 (dolist (article (gnus-summary-work-articles n))
7836 (gnus-summary-select-article nil nil 'pseudo article)
7837 (gnus-eval-in-buffer-window gnus-article-buffer
7838 (let ((buffer (generate-new-buffer " *print*")))
7841 (copy-to-buffer buffer (point-min) (point-max))
7843 (gnus-article-delete-invisible-text)
7844 (when (gnus-visual-p 'article-highlight 'highlight)
7845 ;; Copy-to-buffer doesn't copy overlay. So redo
7847 (let ((gnus-article-buffer buffer))
7848 (gnus-article-highlight-citation t)
7849 (gnus-article-highlight-signature)))
7850 (let ((ps-left-header
7853 (gnus-summary-print-truncate-and-quote
7854 (mail-header-subject gnus-current-headers)
7857 (gnus-summary-print-truncate-and-quote
7858 (mail-header-from gnus-current-headers)
7862 "/pagenumberstring load"
7864 (mail-header-date gnus-current-headers) ")"))))
7865 (gnus-run-hooks 'gnus-ps-print-hook)
7868 (ps-spool-buffer-with-faces)
7869 (ps-spool-buffer)))))
7870 (kill-buffer buffer))))
7871 (gnus-summary-remove-process-mark article))
7872 (ps-despool filename))
7874 (defun gnus-summary-show-article (&optional arg)
7875 "Force re-fetching of the current article.
7876 If ARG (the prefix) is a number, show the article with the charset
7877 defined in `gnus-summary-show-article-charset-alist', or the charset
7879 If ARG (the prefix) is non-nil and not a number, show the raw article
7880 without any article massaging functions being run."
7884 (gnus-summary-show-article t)
7885 (let ((gnus-newsgroup-charset
7886 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7887 (mm-read-coding-system
7890 (set-buffer gnus-article-buffer)
7891 (let ((coding-systems
7892 (detect-coding-region (point) (point-max))))
7893 (or (car-safe coding-systems)
7894 coding-systems))))))
7895 (gnus-newsgroup-ignored-charsets 'gnus-all))
7896 (gnus-summary-select-article nil 'force)
7897 (let ((deps gnus-newsgroup-dependencies)
7900 (set-buffer gnus-original-article-buffer)
7902 (message-narrow-to-head)
7903 (setq head (buffer-string))
7904 (goto-char (point-min))
7905 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
7906 (goto-char (point-max))
7908 (setq lines (1- (count-lines (point) (point-max))))))
7910 (insert (format "211 %d Article retrieved.\n"
7911 (cdr gnus-article-current)))
7913 (if lines (insert (format "Lines: %d\n" lines)))
7915 (let ((nntp-server-buffer (current-buffer)))
7916 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7917 (gnus-data-set-header
7918 (gnus-data-find (cdr gnus-article-current))
7920 (gnus-summary-update-article-line
7921 (cdr gnus-article-current) header)
7922 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
7923 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
7925 ;; Select the article the normal way.
7926 (gnus-summary-select-article nil 'force))
7928 ;; We have to require this here to make sure that the following
7929 ;; dynamic binding isn't shadowed by autoloading.
7930 (require 'gnus-async)
7932 ;; Bind the article treatment functions to nil.
7933 (let ((gnus-have-all-headers t)
7934 gnus-article-prepare-hook
7935 gnus-article-decode-hook
7936 gnus-display-mime-function
7938 ;; Destroy any MIME parts.
7939 (when (gnus-buffer-live-p gnus-article-buffer)
7941 (set-buffer gnus-article-buffer)
7942 (mm-destroy-parts gnus-article-mime-handles)
7943 ;; Set it to nil for safety reason.
7944 (setq gnus-article-mime-handle-alist nil)
7945 (setq gnus-article-mime-handles nil)))
7946 (gnus-summary-select-article nil 'force))))
7947 (gnus-summary-goto-subject gnus-current-article)
7948 (gnus-summary-position-point))
7950 (defun gnus-summary-show-raw-article ()
7951 "Show the raw article without any article massaging functions being run."
7953 (gnus-summary-show-article t))
7955 (defun gnus-summary-verbose-headers (&optional arg)
7956 "Toggle permanent full header display.
7957 If ARG is a positive number, turn header display on.
7958 If ARG is a negative number, turn header display off."
7960 (setq gnus-show-all-headers
7961 (cond ((or (not (numberp arg))
7963 (not gnus-show-all-headers))
7966 (gnus-summary-show-article))
7968 (defun gnus-summary-toggle-header (&optional arg)
7969 "Show the headers if they are hidden, or hide them if they are shown.
7970 If ARG is a positive number, show the entire header.
7971 If ARG is a negative number, hide the unwanted header lines."
7974 (set-buffer gnus-article-buffer)
7976 (let* ((buffer-read-only nil)
7977 (inhibit-point-motion-hooks t)
7983 (article-narrow-to-head)
7984 (gnus-article-hidden-text-p 'headers))))
7985 (goto-char (point-min))
7986 (when (search-forward "\n\n" nil t)
7987 (delete-region (point-min) (1- (point))))
7988 (goto-char (point-min))
7990 (set-buffer gnus-original-article-buffer)
7991 (goto-char (point-min))
7992 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7993 (insert-buffer-substring gnus-original-article-buffer 1 e)
7995 (narrow-to-region (point-min) (point))
7996 (article-decode-encoded-words)
7998 (let ((gnus-treat-hide-headers nil)
7999 (gnus-treat-hide-boring-headers nil))
8000 (setq gnus-article-wash-types
8001 (delq 'headers gnus-article-wash-types))
8002 (gnus-treat-article 'head))
8003 (gnus-treat-article 'head)))
8004 (gnus-set-mode-line 'article)))))
8006 (defun gnus-summary-show-all-headers ()
8007 "Make all header lines visible."
8009 (gnus-summary-toggle-header 1))
8011 (defun gnus-summary-caesar-message (&optional arg)
8012 "Caesar rotate the current article by 13.
8013 The numerical prefix specifies how many places to rotate each letter
8016 (gnus-summary-select-article)
8017 (let ((mail-header-separator ""))
8018 (gnus-eval-in-buffer-window gnus-article-buffer
8021 (let ((start (window-start))
8023 (message-caesar-buffer-body arg)
8024 (set-window-start (get-buffer-window (current-buffer)) start))))))
8026 (defun gnus-summary-stop-page-breaking ()
8027 "Stop page breaking in the current article."
8029 (gnus-summary-select-article)
8030 (gnus-eval-in-buffer-window gnus-article-buffer
8032 (when (gnus-visual-p 'page-marker)
8033 (let ((buffer-read-only nil))
8034 (gnus-remove-text-with-property 'gnus-prev)
8035 (gnus-remove-text-with-property 'gnus-next))
8036 (setq gnus-page-broken nil))))
8038 (defun gnus-summary-move-article (&optional n to-newsgroup
8039 select-method action)
8040 "Move the current article to a different newsgroup.
8041 If N is a positive number, move the N next articles.
8042 If N is a negative number, move the N previous articles.
8043 If N is nil and any articles have been marked with the process mark,
8044 move those articles instead.
8045 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8046 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8047 re-spool using this method.
8049 For this function to work, both the current newsgroup and the
8050 newsgroup that you want to move to have to support the `request-move'
8051 and `request-accept' functions.
8053 ACTION can be either `move' (the default), `crosspost' or `copy'."
8056 (setq action 'move))
8057 ;; Check whether the source group supports the required functions.
8058 (cond ((and (eq action 'move)
8059 (not (gnus-check-backend-function
8060 'request-move-article gnus-newsgroup-name)))
8061 (error "The current group does not support article moving"))
8062 ((and (eq action 'crosspost)
8063 (not (gnus-check-backend-function
8064 'request-replace-article gnus-newsgroup-name)))
8065 (error "The current group does not support article editing")))
8066 (let ((articles (gnus-summary-work-articles n))
8067 (prefix (if (gnus-check-backend-function
8068 'request-move-article gnus-newsgroup-name)
8069 (gnus-group-real-prefix gnus-newsgroup-name)
8071 (names '((move "Move" "Moving")
8072 (copy "Copy" "Copying")
8073 (crosspost "Crosspost" "Crossposting")))
8074 (copy-buf (save-excursion
8075 (nnheader-set-temp-buffer " *copy article*")))
8076 art-group to-method new-xref article to-groups)
8077 (unless (assq action names)
8078 (error "Unknown action %s" action))
8079 ;; Read the newsgroup name.
8080 (when (and (not to-newsgroup)
8081 (not select-method))
8083 (gnus-read-move-group-name
8084 (cadr (assq action names))
8085 (symbol-value (intern (format "gnus-current-%s-group" action)))
8087 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8088 (setq to-method (or select-method
8089 (gnus-server-to-method
8090 (gnus-group-method to-newsgroup))))
8091 ;; Check the method we are to move this article to...
8092 (unless (gnus-check-backend-function
8093 'request-accept-article (car to-method))
8094 (error "%s does not support article copying" (car to-method)))
8095 (unless (gnus-check-server to-method)
8096 (error "Can't open server %s" (car to-method)))
8097 (gnus-message 6 "%s to %s: %s..."
8098 (caddr (assq action names))
8099 (or (car select-method) to-newsgroup) articles)
8101 (setq article (pop articles))
8105 ;; Move the article.
8107 ;; Remove this article from future suppression.
8108 (gnus-dup-unsuppress-article article)
8109 (gnus-request-move-article
8110 article ; Article to move
8111 gnus-newsgroup-name ; From newsgroup
8112 (nth 1 (gnus-find-method-for-group
8113 gnus-newsgroup-name)) ; Server
8114 (list 'gnus-request-accept-article
8115 to-newsgroup (list 'quote select-method)
8116 (not articles) t) ; Accept form
8117 (not articles))) ; Only save nov last time
8118 ;; Copy the article.
8121 (set-buffer copy-buf)
8122 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8123 (gnus-request-accept-article
8124 to-newsgroup select-method (not articles) t))))
8125 ;; Crosspost the article.
8126 ((eq action 'crosspost)
8127 (let ((xref (message-tokenize-header
8128 (mail-header-xref (gnus-summary-article-header article))
8130 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8131 ":" (number-to-string article)))
8133 (setq xref (list (system-name))))
8136 (mapconcat 'identity
8137 (delete "Xref:" (delete new-xref xref))
8141 (set-buffer copy-buf)
8142 ;; First put the article in the destination group.
8143 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8144 (when (consp (setq art-group
8145 (gnus-request-accept-article
8146 to-newsgroup select-method (not articles))))
8147 (setq new-xref (concat new-xref " " (car art-group)
8149 (number-to-string (cdr art-group))))
8150 ;; Now we have the new Xrefs header, so we insert
8151 ;; it and replace the new article.
8152 (nnheader-replace-header "Xref" new-xref)
8153 (gnus-request-replace-article
8154 (cdr art-group) to-newsgroup (current-buffer))
8158 (gnus-message 1 "Couldn't %s article %s: %s"
8159 (cadr (assq action names)) article
8160 (nnheader-get-report (car to-method))))
8161 ((eq art-group 'junk)
8162 (when (eq action 'move)
8163 (gnus-summary-mark-article article gnus-canceled-mark)
8164 (gnus-message 4 "Deleted article %s" article)))
8166 (let* ((pto-group (gnus-group-prefixed-name
8167 (car art-group) to-method))
8169 (gnus-gethash pto-group gnus-newsrc-hashtb))
8170 (info (nth 2 entry))
8171 (to-group (gnus-info-group info))
8173 ;; Update the group that has been moved to.
8175 (memq action '(move copy)))
8176 (unless (member to-group to-groups)
8177 (push to-group to-groups))
8179 (unless (memq article gnus-newsgroup-unreads)
8180 (push 'read to-marks)
8182 info (gnus-add-to-range (gnus-info-read info)
8183 (list (cdr art-group)))))
8185 ;; See whether the article is to be put in the cache.
8186 (let ((marks gnus-article-mark-lists)
8187 (to-article (cdr art-group)))
8189 ;; Enter the article into the cache in the new group,
8190 ;; if that is required.
8191 (when gnus-use-cache
8192 (gnus-cache-possibly-enter-article
8194 (memq article gnus-newsgroup-marked)
8195 (memq article gnus-newsgroup-dormant)
8196 (memq article gnus-newsgroup-unreads)))
8198 (when gnus-preserve-marks
8199 ;; Copy any marks over to the new group.
8200 (when (and (equal to-group gnus-newsgroup-name)
8201 (not (memq article gnus-newsgroup-unreads)))
8202 ;; Mark this article as read in this group.
8203 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8204 (setcdr (gnus-active to-group) to-article)
8205 (setcdr gnus-newsgroup-active to-article))
8208 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8209 (when (memq article (symbol-value
8210 (intern (format "gnus-newsgroup-%s"
8212 (push (cdar marks) to-marks)
8213 ;; If the other group is the same as this group,
8214 ;; then we have to add the mark to the list.
8215 (when (equal to-group gnus-newsgroup-name)
8216 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8219 (intern (format "gnus-newsgroup-%s"
8221 ;; Copy the marks to other group.
8222 (gnus-add-marked-articles
8223 to-group (cdar marks) (list to-article) info)))
8224 (setq marks (cdr marks)))
8226 (gnus-request-set-mark to-group (list (list (list to-article)
8231 (concat "(gnus-group-set-info '"
8232 (gnus-prin1-to-string (gnus-get-info to-group))
8235 ;; Update the Xref header in this article to point to
8236 ;; the new crossposted article we have just created.
8237 (when (eq action 'crosspost)
8239 (set-buffer copy-buf)
8240 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8241 (nnheader-replace-header "Xref" new-xref)
8242 (gnus-request-replace-article
8243 article gnus-newsgroup-name (current-buffer)))))
8245 ;;;!!!Why is this necessary?
8246 (set-buffer gnus-summary-buffer)
8248 (gnus-summary-goto-subject article)
8249 (when (eq action 'move)
8250 (gnus-summary-mark-article article gnus-canceled-mark))))
8251 (gnus-summary-remove-process-mark article))
8252 ;; Re-activate all groups that have been moved to.
8254 (set-buffer gnus-group-buffer)
8255 (let ((gnus-group-marked to-groups))
8256 (gnus-group-get-new-news-this-group nil t)))
8258 (gnus-kill-buffer copy-buf)
8259 (gnus-summary-position-point)
8260 (gnus-set-mode-line 'summary)))
8262 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8263 "Move the current article to a different newsgroup.
8264 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8265 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8266 re-spool using this method."
8268 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8270 (defun gnus-summary-crosspost-article (&optional n)
8271 "Crosspost the current article to some other group."
8273 (gnus-summary-move-article n nil nil 'crosspost))
8275 (defcustom gnus-summary-respool-default-method nil
8276 "Default method type for respooling an article.
8277 If nil, use to the current newsgroup method."
8279 :group 'gnus-summary-mail)
8281 (defun gnus-summary-respool-article (&optional n method)
8282 "Respool the current article.
8283 The article will be squeezed through the mail spooling process again,
8284 which means that it will be put in some mail newsgroup or other
8285 depending on `nnmail-split-methods'.
8286 If N is a positive number, respool the N next articles.
8287 If N is a negative number, respool the N previous articles.
8288 If N is nil and any articles have been marked with the process mark,
8289 respool those articles instead.
8291 Respooling can be done both from mail groups and \"real\" newsgroups.
8292 In the former case, the articles in question will be moved from the
8293 current group into whatever groups they are destined to. In the
8294 latter case, they will be copied into the relevant groups."
8296 (list current-prefix-arg
8297 (let* ((methods (gnus-methods-using 'respool))
8299 (symbol-name (or gnus-summary-respool-default-method
8300 (car (gnus-find-method-for-group
8301 gnus-newsgroup-name)))))
8303 (gnus-completing-read
8304 methname "What backend do you want to use when respooling?"
8305 methods nil t nil 'gnus-mail-method-history))
8308 ((zerop (length (setq ms (gnus-servers-using-backend
8310 (list (intern method) ""))
8314 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8315 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8318 (error "No method given for respooling"))
8319 (if (assoc (symbol-name
8320 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8321 (gnus-methods-using 'respool))
8322 (gnus-summary-move-article n nil method)
8323 (gnus-summary-copy-article n nil method)))
8325 (defun gnus-summary-import-article (file &optional edit)
8326 "Import an arbitrary file into a mail newsgroup."
8327 (interactive "fImport file: \nP")
8328 (let ((group gnus-newsgroup-name)
8329 (now (current-time))
8330 atts lines group-art)
8331 (unless (gnus-check-backend-function 'request-accept-article group)
8332 (error "%s does not support article importing" group))
8333 (or (file-readable-p file)
8334 (not (file-regular-p file))
8335 (error "Can't read %s" file))
8337 (set-buffer (gnus-get-buffer-create " *import file*"))
8339 (nnheader-insert-file-contents file)
8340 (goto-char (point-min))
8341 (if (nnheader-article-p)
8343 (goto-char (point-min))
8344 (search-forward "\n\n" nil t)
8345 (narrow-to-region (point-min) (1- (point)))
8346 (goto-char (point-min))
8347 (unless (re-search-forward "^date:" nil t)
8348 (goto-char (point-max))
8349 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8350 ;; This doesn't look like an article, so we fudge some headers.
8351 (setq atts (file-attributes file)
8352 lines (count-lines (point-min) (point-max)))
8353 (insert "From: " (read-string "From: ") "\n"
8354 "Subject: " (read-string "Subject: ") "\n"
8355 "Date: " (message-make-date (nth 5 atts)) "\n"
8356 "Message-ID: " (message-make-message-id) "\n"
8357 "Lines: " (int-to-string lines) "\n"
8358 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8359 (setq group-art (gnus-request-accept-article group nil t))
8360 (kill-buffer (current-buffer)))
8361 (setq gnus-newsgroup-active (gnus-activate-group group))
8363 (gnus-summary-goto-article (cdr group-art) nil t)
8365 (gnus-summary-edit-article))))
8367 (defun gnus-summary-create-article ()
8368 "Create an article in a mail newsgroup."
8370 (let ((group gnus-newsgroup-name)
8371 (now (current-time))
8373 (unless (gnus-check-backend-function 'request-accept-article group)
8374 (error "%s does not support article importing" group))
8376 (set-buffer (gnus-get-buffer-create " *import file*"))
8378 (goto-char (point-min))
8379 ;; This doesn't look like an article, so we fudge some headers.
8380 (insert "From: " (read-string "From: ") "\n"
8381 "Subject: " (read-string "Subject: ") "\n"
8382 "Date: " (message-make-date now) "\n"
8383 "Message-ID: " (message-make-message-id) "\n")
8384 (setq group-art (gnus-request-accept-article group nil t))
8385 (kill-buffer (current-buffer)))
8386 (setq gnus-newsgroup-active (gnus-activate-group group))
8388 (gnus-summary-goto-article (cdr group-art) nil t)
8389 (gnus-summary-edit-article)))
8391 (defun gnus-summary-article-posted-p ()
8392 "Say whether the current (mail) article is available from news as well.
8393 This will be the case if the article has both been mailed and posted."
8395 (let ((id (mail-header-references (gnus-summary-article-header)))
8396 (gnus-override-method (car (gnus-refer-article-methods))))
8397 (if (gnus-request-head id "")
8398 (gnus-message 2 "The current message was found on %s"
8399 gnus-override-method)
8400 (gnus-message 2 "The current message couldn't be found on %s"
8401 gnus-override-method)
8404 (defun gnus-summary-expire-articles (&optional now)
8405 "Expire all articles that are marked as expirable in the current group."
8407 (when (gnus-check-backend-function
8408 'request-expire-articles gnus-newsgroup-name)
8409 ;; This backend supports expiry.
8410 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8411 (expirable (if total
8413 ;; We need to update the info for
8414 ;; this group for `gnus-list-of-read-articles'
8415 ;; to give us the right answer.
8416 (gnus-run-hooks 'gnus-exit-group-hook)
8417 (gnus-summary-update-info)
8418 (gnus-list-of-read-articles gnus-newsgroup-name))
8419 (setq gnus-newsgroup-expirable
8420 (sort gnus-newsgroup-expirable '<))))
8421 (expiry-wait (if now 'immediate
8422 (gnus-group-find-parameter
8423 gnus-newsgroup-name 'expiry-wait)))
8424 (nnmail-expiry-target
8425 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8426 nnmail-expiry-target))
8429 ;; There are expirable articles in this group, so we run them
8430 ;; through the expiry process.
8431 (gnus-message 6 "Expiring articles...")
8432 (unless (gnus-check-group gnus-newsgroup-name)
8433 (error "Can't open server for %s" gnus-newsgroup-name))
8434 ;; The list of articles that weren't expired is returned.
8437 (let ((nnmail-expiry-wait-function nil)
8438 (nnmail-expiry-wait expiry-wait))
8439 (setq es (gnus-request-expire-articles
8440 expirable gnus-newsgroup-name)))
8441 (setq es (gnus-request-expire-articles
8442 expirable gnus-newsgroup-name)))
8444 (setq gnus-newsgroup-expirable es))
8445 ;; We go through the old list of expirable, and mark all
8446 ;; really expired articles as nonexistent.
8447 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8448 (let ((gnus-use-cache nil))
8450 (unless (memq (car expirable) es)
8451 (when (gnus-data-find (car expirable))
8452 (gnus-summary-mark-article
8453 (car expirable) gnus-canceled-mark)))
8454 (setq expirable (cdr expirable))))))
8455 (gnus-message 6 "Expiring articles...done")))))
8457 (defun gnus-summary-expire-articles-now ()
8458 "Expunge all expirable articles in the current group.
8459 This means that *all* articles that are marked as expirable will be
8460 deleted forever, right now."
8462 (or gnus-expert-user
8464 "Are you really, really, really sure you want to delete all these messages? ")
8466 (gnus-summary-expire-articles t))
8468 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8469 (defun gnus-summary-delete-article (&optional n)
8470 "Delete the N next (mail) articles.
8471 This command actually deletes articles. This is not a marking
8472 command. The article will disappear forever from your life, never to
8474 If N is negative, delete backwards.
8475 If N is nil and articles have been marked with the process mark,
8476 delete these instead."
8478 (unless (gnus-check-backend-function 'request-expire-articles
8479 gnus-newsgroup-name)
8480 (error "The current newsgroup does not support article deletion"))
8481 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8482 (error "Couldn't open server"))
8483 ;; Compute the list of articles to delete.
8484 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8486 (if (and gnus-novice-user
8487 (not (gnus-yes-or-no-p
8488 (format "Do you really want to delete %s forever? "
8489 (if (> (length articles) 1)
8490 (format "these %s articles" (length articles))
8493 ;; Delete the articles.
8494 (setq not-deleted (gnus-request-expire-articles
8495 articles gnus-newsgroup-name 'force))
8497 (gnus-summary-remove-process-mark (car articles))
8498 ;; The backend might not have been able to delete the article
8500 (unless (memq (car articles) not-deleted)
8501 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8502 (setq articles (cdr articles)))
8504 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8505 (gnus-summary-position-point)
8506 (gnus-set-mode-line 'summary)
8509 (defun gnus-summary-edit-article (&optional arg)
8510 "Edit the current article.
8511 This will have permanent effect only in mail groups.
8512 If ARG is nil, edit the decoded articles.
8513 If ARG is 1, edit the raw articles.
8514 If ARG is 2, edit the raw articles even in read-only groups.
8515 If ARG is 3, edit the articles with the current handles.
8516 Otherwise, allow editing of articles even in read-only
8519 (let (force raw current-handles)
8522 ((eq arg 1) (setq raw t))
8523 ((eq arg 2) (setq raw t
8525 ((eq arg 3) (setq current-handles
8526 (and (gnus-buffer-live-p gnus-article-buffer)
8527 (with-current-buffer gnus-article-buffer
8529 gnus-article-mime-handles
8530 (setq gnus-article-mime-handles nil))))))
8532 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8533 (error "Can't edit the raw article in group nndraft:drafts"))
8535 (set-buffer gnus-summary-buffer)
8536 (let ((mail-parse-charset gnus-newsgroup-charset)
8537 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8538 (gnus-set-global-variables)
8539 (when (and (not force)
8540 (gnus-group-read-only-p))
8541 (error "The current newsgroup does not support article editing"))
8542 (gnus-summary-show-article t)
8543 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8544 (with-current-buffer gnus-article-buffer
8545 (mm-enable-multibyte-mule4)))
8546 (if (equal gnus-newsgroup-name "nndraft:drafts")
8548 (gnus-article-edit-article
8551 (let ((mbl mml-buffer-list))
8552 (setq mml-buffer-list nil)
8553 (mime-to-mml ,'current-handles)
8554 (let ((mbl1 mml-buffer-list))
8555 (setq mml-buffer-list mbl)
8556 (set (make-local-variable 'mml-buffer-list) mbl1))
8557 (make-local-hook 'kill-buffer-hook)
8558 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8559 `(lambda (no-highlight)
8560 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8561 (message-options message-options)
8562 (message-options-set-recipient)
8563 (mail-parse-ignored-charsets
8564 ',gnus-newsgroup-ignored-charsets))
8565 ,(if (not raw) '(progn
8567 (mml-destroy-buffers)
8568 (remove-hook 'kill-buffer-hook
8569 'mml-destroy-buffers t)
8570 (kill-local-variable 'mml-buffer-list)))
8571 (gnus-summary-edit-article-done
8572 ,(or (mail-header-references gnus-current-headers) "")
8573 ,(gnus-group-read-only-p)
8574 ,gnus-summary-buffer no-highlight))))))))
8576 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8578 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8580 "Make edits to the current article permanent."
8583 ;; The buffer restriction contains the entire article if it exists.
8584 (when (article-goto-body)
8585 (let ((lines (count-lines (point) (point-max)))
8586 (length (- (point-max) (point)))
8587 (case-fold-search t)
8588 (body (copy-marker (point))))
8589 (goto-char (point-min))
8590 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8591 (delete-region (match-beginning 1) (match-end 1))
8592 (insert (number-to-string length)))
8593 (goto-char (point-min))
8594 (when (re-search-forward
8595 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8596 (delete-region (match-beginning 1) (match-end 1))
8597 (insert (number-to-string length)))
8598 (goto-char (point-min))
8599 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8600 (delete-region (match-beginning 1) (match-end 1))
8601 (insert (number-to-string lines))))))
8602 ;; Replace the article.
8603 (let ((buf (current-buffer)))
8605 (insert-buffer-substring buf)
8607 (if (and (not read-only)
8608 (not (gnus-request-replace-article
8609 (cdr gnus-article-current) (car gnus-article-current)
8610 (current-buffer) t)))
8611 (error "Couldn't replace article")
8612 ;; Update the summary buffer.
8614 (equal (message-tokenize-header references " ")
8615 (message-tokenize-header
8616 (or (message-fetch-field "references") "") " ")))
8617 ;; We only have to update this line.
8620 (message-narrow-to-head)
8621 (let ((head (buffer-string))
8624 (insert (format "211 %d Article retrieved.\n"
8625 (cdr gnus-article-current)))
8628 (let ((nntp-server-buffer (current-buffer)))
8629 (setq header (car (gnus-get-newsgroup-headers
8631 (set-buffer gnus-summary-buffer)
8632 gnus-newsgroup-dependencies)
8635 (set-buffer gnus-summary-buffer)
8636 (gnus-data-set-header
8637 (gnus-data-find (cdr gnus-article-current))
8639 (gnus-summary-update-article-line
8640 (cdr gnus-article-current) header)
8641 (if (gnus-summary-goto-subject
8642 (cdr gnus-article-current) nil t)
8643 (gnus-summary-update-secondary-mark
8644 (cdr gnus-article-current))))))))
8646 (set-buffer (or buffer gnus-summary-buffer))
8647 (gnus-summary-update-article (cdr gnus-article-current))
8648 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8649 (gnus-summary-update-secondary-mark
8650 (cdr gnus-article-current))))
8651 ;; Prettify the article buffer again.
8652 (unless no-highlight
8654 (set-buffer gnus-article-buffer)
8655 ;;;!!! Fix this -- article should be rehighlighted.
8656 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8657 (set-buffer gnus-original-article-buffer)
8658 (gnus-request-article
8659 (cdr gnus-article-current)
8660 (car gnus-article-current) (current-buffer))))
8661 ;; Prettify the summary buffer line.
8662 (when (gnus-visual-p 'summary-highlight 'highlight)
8663 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8665 (defun gnus-summary-edit-wash (key)
8666 "Perform editing command KEY in the article buffer."
8670 (message "%s" (concat (this-command-keys) "- "))
8673 (gnus-summary-edit-article)
8674 (execute-kbd-macro (concat (this-command-keys) key))
8675 (gnus-article-edit-done))
8678 (defun gnus-summary-toggle-smiley (&optional arg)
8679 "Toggle the display of smilies as small graphical icons."
8682 (set-buffer gnus-article-buffer)
8683 (gnus-smiley-display arg)
8688 (defun gnus-summary-respool-query (&optional silent trace)
8689 "Query where the respool algorithm would put this article."
8691 (let (gnus-mark-article-hook)
8692 (gnus-summary-select-article)
8694 (set-buffer gnus-original-article-buffer)
8696 (message-narrow-to-head)
8697 (let ((groups (nnmail-article-group 'identity trace)))
8700 (message "This message would go to %s"
8701 (mapconcat 'car groups ", "))
8702 (message "This message would go to no groups"))
8705 (defun gnus-summary-respool-trace ()
8706 "Trace where the respool algorithm would put this article.
8707 Display a buffer showing all fancy splitting patterns which matched."
8709 (gnus-summary-respool-query nil t))
8711 ;; Summary marking commands.
8713 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8714 "Mark articles which has the same subject as read, and then select the next.
8715 If UNMARK is positive, remove any kind of mark.
8716 If UNMARK is negative, tick articles."
8719 (setq unmark (prefix-numeric-value unmark)))
8721 (gnus-summary-mark-same-subject
8722 (gnus-summary-article-subject) unmark)))
8723 ;; Select next unread article. If auto-select-same mode, should
8724 ;; select the first unread article.
8725 (gnus-summary-next-article t (and gnus-auto-select-same
8726 (gnus-summary-article-subject)))
8727 (gnus-message 7 "%d article%s marked as %s"
8728 count (if (= count 1) " is" "s are")
8729 (if unmark "unread" "read"))))
8731 (defun gnus-summary-kill-same-subject (&optional unmark)
8732 "Mark articles which has the same subject as read.
8733 If UNMARK is positive, remove any kind of mark.
8734 If UNMARK is negative, tick articles."
8737 (setq unmark (prefix-numeric-value unmark)))
8739 (gnus-summary-mark-same-subject
8740 (gnus-summary-article-subject) unmark)))
8741 ;; If marked as read, go to next unread subject.
8743 ;; Go to next unread subject.
8744 (gnus-summary-next-subject 1 t))
8745 (gnus-message 7 "%d articles are marked as %s"
8746 count (if unmark "unread" "read"))))
8748 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8749 "Mark articles with same SUBJECT as read, and return marked number.
8750 If optional argument UNMARK is positive, remove any kinds of marks.
8751 If optional argument UNMARK is negative, mark articles as unread instead."
8755 ((null unmark) ; Mark as read.
8758 (gnus-summary-mark-article-as-read gnus-killed-mark)
8759 (gnus-summary-show-thread) t)
8760 (gnus-summary-find-subject subject))
8761 (setq count (1+ count))))
8762 ((> unmark 0) ; Tick.
8765 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8766 (gnus-summary-show-thread) t)
8767 (gnus-summary-find-subject subject))
8768 (setq count (1+ count))))
8769 (t ; Mark as unread.
8772 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8773 (gnus-summary-show-thread) t)
8774 (gnus-summary-find-subject subject))
8775 (setq count (1+ count)))))
8776 (gnus-set-mode-line 'summary)
8777 ;; Return the number of marked articles.
8780 (defun gnus-summary-mark-as-processable (n &optional unmark)
8781 "Set the process mark on the next N articles.
8782 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8783 the process mark instead. The difference between N and the actual
8784 number of articles marked is returned."
8786 (if (and (null n) (gnus-region-active-p))
8787 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8788 (setq n (prefix-numeric-value n))
8789 (let ((backward (< n 0))
8794 (gnus-summary-remove-process-mark
8795 (gnus-summary-article-number))
8796 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8797 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8800 (gnus-message 7 "No more articles"))
8801 (gnus-summary-recenter)
8802 (gnus-summary-position-point)
8805 (defun gnus-summary-unmark-as-processable (n)
8806 "Remove the process mark from the next N articles.
8807 If N is negative, unmark backward instead. The difference between N and
8808 the actual number of articles unmarked is returned."
8810 (gnus-summary-mark-as-processable n t))
8812 (defun gnus-summary-unmark-all-processable ()
8813 "Remove the process mark from all articles."
8816 (while gnus-newsgroup-processable
8817 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8818 (gnus-summary-position-point))
8820 (defun gnus-summary-add-mark (article type)
8821 "Mark ARTICLE with a mark of TYPE."
8822 (let ((vtype (car (assq type gnus-article-mark-lists)))
8825 (error "No such mark type: %s" type)
8826 (setq var (intern (format "gnus-newsgroup-%s" type)))
8827 (set var (cons article (symbol-value var)))
8828 (if (memq type '(processable cached replied forwarded recent saved))
8829 (gnus-summary-update-secondary-mark article)
8830 ;;; !!! This is bogus. We should find out what primary
8831 ;;; !!! mark we want to set.
8832 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8834 (defun gnus-summary-mark-as-expirable (n)
8835 "Mark N articles forward as expirable.
8836 If N is negative, mark backward instead. The difference between N and
8837 the actual number of articles marked is returned."
8839 (gnus-summary-mark-forward n gnus-expirable-mark))
8841 (defun gnus-summary-mark-article-as-replied (article)
8842 "Mark ARTICLE as replied to and update the summary line.
8843 ARTICLE can also be a list of articles."
8844 (interactive (list (gnus-summary-article-number)))
8845 (let ((articles (if (listp article) article (list article))))
8846 (dolist (article articles)
8847 (push article gnus-newsgroup-replied)
8848 (let ((buffer-read-only nil))
8849 (when (gnus-summary-goto-subject article nil t)
8850 (gnus-summary-update-secondary-mark article))))))
8852 (defun gnus-summary-mark-article-as-forwarded (article)
8853 "Mark ARTICLE as forwarded and update the summary line.
8854 ARTICLE can also be a list of articles."
8855 (let ((articles (if (listp article) article (list article))))
8856 (dolist (article articles)
8857 (push article gnus-newsgroup-forwarded)
8858 (let ((buffer-read-only nil))
8859 (when (gnus-summary-goto-subject article nil t)
8860 (gnus-summary-update-secondary-mark article))))))
8862 (defun gnus-summary-set-bookmark (article)
8863 "Set a bookmark in current article."
8864 (interactive (list (gnus-summary-article-number)))
8865 (when (or (not (get-buffer gnus-article-buffer))
8866 (not gnus-current-article)
8867 (not gnus-article-current)
8868 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8869 (error "No current article selected"))
8870 ;; Remove old bookmark, if one exists.
8871 (let ((old (assq article gnus-newsgroup-bookmarks)))
8873 (setq gnus-newsgroup-bookmarks
8874 (delq old gnus-newsgroup-bookmarks))))
8875 ;; Set the new bookmark, which is on the form
8876 ;; (article-number . line-number-in-body).
8880 (set-buffer gnus-article-buffer)
8884 (goto-char (point-min))
8885 (search-forward "\n\n" nil t)
8888 gnus-newsgroup-bookmarks)
8889 (gnus-message 6 "A bookmark has been added to the current article."))
8891 (defun gnus-summary-remove-bookmark (article)
8892 "Remove the bookmark from the current article."
8893 (interactive (list (gnus-summary-article-number)))
8894 ;; Remove old bookmark, if one exists.
8895 (let ((old (assq article gnus-newsgroup-bookmarks)))
8898 (setq gnus-newsgroup-bookmarks
8899 (delq old gnus-newsgroup-bookmarks))
8900 (gnus-message 6 "Removed bookmark."))
8901 (gnus-message 6 "No bookmark in current article."))))
8903 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8904 (defun gnus-summary-mark-as-dormant (n)
8905 "Mark N articles forward as dormant.
8906 If N is negative, mark backward instead. The difference between N and
8907 the actual number of articles marked is returned."
8909 (gnus-summary-mark-forward n gnus-dormant-mark))
8911 (defun gnus-summary-set-process-mark (article)
8912 "Set the process mark on ARTICLE and update the summary line."
8913 (setq gnus-newsgroup-processable
8915 (delq article gnus-newsgroup-processable)))
8916 (when (gnus-summary-goto-subject article)
8917 (gnus-summary-show-thread)
8918 (gnus-summary-goto-subject article)
8919 (gnus-summary-update-secondary-mark article)))
8921 (defun gnus-summary-remove-process-mark (article)
8922 "Remove the process mark from ARTICLE and update the summary line."
8923 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8924 (when (gnus-summary-goto-subject article)
8925 (gnus-summary-show-thread)
8926 (gnus-summary-goto-subject article)
8927 (gnus-summary-update-secondary-mark article)))
8929 (defun gnus-summary-set-saved-mark (article)
8930 "Set the process mark on ARTICLE and update the summary line."
8931 (push article gnus-newsgroup-saved)
8932 (when (gnus-summary-goto-subject article)
8933 (gnus-summary-update-secondary-mark article)))
8935 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8936 "Mark N articles as read forwards.
8937 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8938 The difference between N and the actual number of articles marked is
8940 Iff NO-EXPIRE, auto-expiry will be inhibited."
8942 (gnus-summary-show-thread)
8943 (let ((backward (< n 0))
8944 (gnus-summary-goto-unread
8945 (and gnus-summary-goto-unread
8946 (not (eq gnus-summary-goto-unread 'never))
8947 (not (memq mark (list gnus-unread-mark
8948 gnus-ticked-mark gnus-dormant-mark)))))
8950 (mark (or mark gnus-del-mark)))
8952 (gnus-summary-mark-article nil mark no-expire)
8953 (zerop (gnus-summary-next-subject
8955 (and gnus-summary-goto-unread
8956 (not (eq gnus-summary-goto-unread 'never)))
8960 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8961 (gnus-summary-recenter)
8962 (gnus-summary-position-point)
8963 (gnus-set-mode-line 'summary)
8966 (defun gnus-summary-mark-article-as-read (mark)
8967 "Mark the current article quickly as read with MARK."
8968 (let ((article (gnus-summary-article-number)))
8969 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8970 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8971 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8972 (push (cons article mark) gnus-newsgroup-reads)
8973 ;; Possibly remove from cache, if that is used.
8974 (when gnus-use-cache
8975 (gnus-cache-enter-remove-article article))
8976 ;; Allow the backend to change the mark.
8977 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8978 ;; Check for auto-expiry.
8979 (when (and gnus-newsgroup-auto-expire
8980 (memq mark gnus-auto-expirable-marks))
8981 (setq mark gnus-expirable-mark)
8982 ;; Let the backend know about the mark change.
8983 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8984 (push article gnus-newsgroup-expirable))
8985 ;; Set the mark in the buffer.
8986 (gnus-summary-update-mark mark 'unread)
8989 (defun gnus-summary-mark-article-as-unread (mark)
8990 "Mark the current article quickly as unread with MARK."
8991 (let* ((article (gnus-summary-article-number))
8992 (old-mark (gnus-summary-article-mark article)))
8993 ;; Allow the backend to change the mark.
8994 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8995 (if (eq mark old-mark)
8999 (gnus-error 1 "Can't mark negative article numbers")
9001 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9002 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9003 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9004 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9005 (cond ((= mark gnus-ticked-mark)
9006 (push article gnus-newsgroup-marked))
9007 ((= mark gnus-dormant-mark)
9008 (push article gnus-newsgroup-dormant))
9010 (push article gnus-newsgroup-unreads)))
9011 (gnus-pull article gnus-newsgroup-reads)
9013 ;; See whether the article is to be put in the cache.
9015 (vectorp (gnus-summary-article-header article))
9017 (gnus-cache-possibly-enter-article
9018 gnus-newsgroup-name article
9019 (= mark gnus-ticked-mark)
9020 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9023 (gnus-summary-update-mark mark 'unread)
9026 (defun gnus-summary-mark-article (&optional article mark no-expire)
9027 "Mark ARTICLE with MARK. MARK can be any character.
9028 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9029 `??' (dormant) and `?E' (expirable).
9030 If MARK is nil, then the default character `?r' is used.
9031 If ARTICLE is nil, then the article on the current line will be
9033 Iff NO-EXPIRE, auto-expiry will be inhibited."
9034 ;; The mark might be a string.
9035 (when (stringp mark)
9036 (setq mark (aref mark 0)))
9037 ;; If no mark is given, then we check auto-expiring.
9039 (setq mark gnus-del-mark))
9040 (when (and (not no-expire)
9041 gnus-newsgroup-auto-expire
9042 (memq mark gnus-auto-expirable-marks))
9043 (setq mark gnus-expirable-mark))
9044 (let ((article (or article (gnus-summary-article-number)))
9045 (old-mark (gnus-summary-article-mark article)))
9046 ;; Allow the backend to change the mark.
9047 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9048 (if (eq mark old-mark)
9051 (error "No article on current line"))
9052 (if (not (if (or (= mark gnus-unread-mark)
9053 (= mark gnus-ticked-mark)
9054 (= mark gnus-dormant-mark))
9055 (gnus-mark-article-as-unread article mark)
9056 (gnus-mark-article-as-read article mark)))
9058 ;; See whether the article is to be put in the cache.
9060 (not (= mark gnus-canceled-mark))
9061 (vectorp (gnus-summary-article-header article))
9063 (gnus-cache-possibly-enter-article
9064 gnus-newsgroup-name article
9065 (= mark gnus-ticked-mark)
9066 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9068 (when (gnus-summary-goto-subject article nil t)
9069 (let ((buffer-read-only nil))
9070 (gnus-summary-show-thread)
9072 (gnus-summary-update-mark mark 'unread)
9075 (defun gnus-summary-update-secondary-mark (article)
9076 "Update the secondary (read, process, cache) mark."
9077 (gnus-summary-update-mark
9078 (cond ((memq article gnus-newsgroup-processable)
9080 ((memq article gnus-newsgroup-cached)
9082 ((memq article gnus-newsgroup-replied)
9084 ((memq article gnus-newsgroup-forwarded)
9085 gnus-forwarded-mark)
9086 ((memq article gnus-newsgroup-saved)
9088 ((memq article gnus-newsgroup-recent)
9090 ((memq article gnus-newsgroup-unseen)
9094 (when (gnus-visual-p 'summary-highlight 'highlight)
9095 (gnus-run-hooks 'gnus-summary-update-hook))
9098 (defun gnus-summary-update-mark (mark type)
9099 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9100 (buffer-read-only nil))
9101 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9103 (when (looking-at "\r")
9105 (when (<= (+ forward (point)) (point-max))
9106 ;; Go to the right position on the line.
9107 (goto-char (+ forward (point)))
9108 ;; Replace the old mark with the new mark.
9109 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9110 ;; Optionally update the marks by some user rule.
9111 (when (eq type 'unread)
9113 (gnus-data-find (gnus-summary-article-number)) mark)
9114 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9116 (defun gnus-mark-article-as-read (article &optional mark)
9117 "Enter ARTICLE in the pertinent lists and remove it from others."
9118 ;; Make the article expirable.
9119 (let ((mark (or mark gnus-del-mark)))
9120 (if (= mark gnus-expirable-mark)
9121 (push article gnus-newsgroup-expirable)
9122 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9123 ;; Remove from unread and marked lists.
9124 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9125 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9126 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9127 (push (cons article mark) gnus-newsgroup-reads)
9128 ;; Possibly remove from cache, if that is used.
9129 (when gnus-use-cache
9130 (gnus-cache-enter-remove-article article))
9133 (defun gnus-mark-article-as-unread (article &optional mark)
9134 "Enter ARTICLE in the pertinent lists and remove it from others."
9135 (let ((mark (or mark gnus-ticked-mark)))
9138 (gnus-error 1 "Can't mark negative article numbers")
9140 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9141 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9142 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9143 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9145 ;; Unsuppress duplicates?
9146 (when gnus-suppress-duplicates
9147 (gnus-dup-unsuppress-article article))
9149 (cond ((= mark gnus-ticked-mark)
9150 (push article gnus-newsgroup-marked))
9151 ((= mark gnus-dormant-mark)
9152 (push article gnus-newsgroup-dormant))
9154 (push article gnus-newsgroup-unreads)))
9155 (gnus-pull article gnus-newsgroup-reads)
9158 (defalias 'gnus-summary-mark-as-unread-forward
9159 'gnus-summary-tick-article-forward)
9160 (make-obsolete 'gnus-summary-mark-as-unread-forward
9161 'gnus-summary-tick-article-forward)
9162 (defun gnus-summary-tick-article-forward (n)
9163 "Tick N articles forwards.
9164 If N is negative, tick backwards instead.
9165 The difference between N and the number of articles ticked is returned."
9167 (gnus-summary-mark-forward n gnus-ticked-mark))
9169 (defalias 'gnus-summary-mark-as-unread-backward
9170 'gnus-summary-tick-article-backward)
9171 (make-obsolete 'gnus-summary-mark-as-unread-backward
9172 'gnus-summary-tick-article-backward)
9173 (defun gnus-summary-tick-article-backward (n)
9174 "Tick N articles backwards.
9175 The difference between N and the number of articles ticked is returned."
9177 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9179 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9180 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9181 (defun gnus-summary-tick-article (&optional article clear-mark)
9182 "Mark current article as unread.
9183 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9184 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9186 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9189 (defun gnus-summary-mark-as-read-forward (n)
9190 "Mark N articles as read forwards.
9191 If N is negative, mark backwards instead.
9192 The difference between N and the actual number of articles marked is
9195 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9197 (defun gnus-summary-mark-as-read-backward (n)
9198 "Mark the N articles as read backwards.
9199 The difference between N and the actual number of articles marked is
9202 (gnus-summary-mark-forward
9203 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9205 (defun gnus-summary-mark-as-read (&optional article mark)
9206 "Mark current article as read.
9207 ARTICLE specifies the article to be marked as read.
9208 MARK specifies a string to be inserted at the beginning of the line."
9209 (gnus-summary-mark-article article mark))
9211 (defun gnus-summary-clear-mark-forward (n)
9212 "Clear marks from N articles forward.
9213 If N is negative, clear backward instead.
9214 The difference between N and the number of marks cleared is returned."
9216 (gnus-summary-mark-forward n gnus-unread-mark))
9218 (defun gnus-summary-clear-mark-backward (n)
9219 "Clear marks from N articles backward.
9220 The difference between N and the number of marks cleared is returned."
9222 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9224 (defun gnus-summary-mark-unread-as-read ()
9225 "Intended to be used by `gnus-summary-mark-article-hook'."
9226 (when (memq gnus-current-article gnus-newsgroup-unreads)
9227 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9229 (defun gnus-summary-mark-read-and-unread-as-read ()
9230 "Intended to be used by `gnus-summary-mark-article-hook'."
9231 (let ((mark (gnus-summary-article-mark)))
9232 (when (or (gnus-unread-mark-p mark)
9233 (gnus-read-mark-p mark))
9234 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9236 (defun gnus-summary-mark-unread-as-ticked ()
9237 "Intended to be used by `gnus-summary-mark-article-hook'."
9238 (when (memq gnus-current-article gnus-newsgroup-unreads)
9239 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9241 (defun gnus-summary-mark-region-as-read (point mark all)
9242 "Mark all unread articles between point and mark as read.
9243 If given a prefix, mark all articles between point and mark as read,
9244 even ticked and dormant ones."
9245 (interactive "r\nP")
9254 (memq (setq article (gnus-summary-article-number))
9255 gnus-newsgroup-unreads))
9256 (gnus-summary-mark-article article gnus-del-mark))
9258 (gnus-summary-find-next))))))
9260 (defun gnus-summary-mark-below (score mark)
9261 "Mark articles with score less than SCORE with MARK."
9262 (interactive "P\ncMark: ")
9263 (setq score (if score
9264 (prefix-numeric-value score)
9265 (or gnus-summary-default-score 0)))
9267 (set-buffer gnus-summary-buffer)
9268 (goto-char (point-min))
9271 (and (< (gnus-summary-article-score) score)
9272 (gnus-summary-mark-article nil mark))
9273 (gnus-summary-find-next)))))
9275 (defun gnus-summary-kill-below (&optional score)
9276 "Mark articles with score below SCORE as read."
9278 (gnus-summary-mark-below score gnus-killed-mark))
9280 (defun gnus-summary-clear-above (&optional score)
9281 "Clear all marks from articles with score above SCORE."
9283 (gnus-summary-mark-above score gnus-unread-mark))
9285 (defun gnus-summary-tick-above (&optional score)
9286 "Tick all articles with score above SCORE."
9288 (gnus-summary-mark-above score gnus-ticked-mark))
9290 (defun gnus-summary-mark-above (score mark)
9291 "Mark articles with score over SCORE with MARK."
9292 (interactive "P\ncMark: ")
9293 (setq score (if score
9294 (prefix-numeric-value score)
9295 (or gnus-summary-default-score 0)))
9297 (set-buffer gnus-summary-buffer)
9298 (goto-char (point-min))
9300 (when (> (gnus-summary-article-score) score)
9301 (gnus-summary-mark-article nil mark))
9303 (gnus-summary-find-next)))))
9305 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9306 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9307 (defun gnus-summary-limit-include-expunged (&optional no-error)
9308 "Display all the hidden articles that were expunged for low scores."
9310 (let ((buffer-read-only nil))
9311 (let ((scored gnus-newsgroup-scored)
9314 (unless (gnus-summary-article-header (caar scored))
9315 (and (setq h (gnus-number-to-header (caar scored)))
9316 (< (cdar scored) gnus-summary-expunge-below)
9318 (setq scored (cdr scored)))
9320 (when (not no-error)
9321 (error "No expunged articles hidden"))
9322 (goto-char (point-min))
9323 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9324 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9325 (mapcar (lambda (x) (push (mail-header-number x)
9326 gnus-newsgroup-limit))
9328 (gnus-summary-prepare-unthreaded (nreverse headers))
9329 (goto-char (point-min))
9330 (gnus-summary-position-point)
9333 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9334 "Mark all unread articles in this newsgroup as read.
9335 If prefix argument ALL is non-nil, ticked and dormant articles will
9336 also be marked as read.
9337 If QUIETLY is non-nil, no questions will be asked.
9338 If TO-HERE is non-nil, it should be a point in the buffer. All
9339 articles before (after, if REVERSE is set) this point will be marked as read.
9340 Note that this function will only catch up the unread article
9341 in the current summary buffer limitation.
9342 The number of articles marked as read is returned."
9347 (not gnus-interactive-catchup) ;Without confirmation?
9351 "Mark absolutely all articles as read? "
9352 "Mark all unread articles as read? ")))
9354 (not gnus-newsgroup-adaptive)
9355 (not gnus-newsgroup-auto-expire)
9356 (not gnus-suppress-duplicates)
9357 (or (not gnus-use-cache)
9358 (eq gnus-use-cache 'passive)))
9361 (setq gnus-newsgroup-marked nil
9362 gnus-newsgroup-dormant nil))
9363 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9364 ;; We actually mark all articles as canceled, which we
9365 ;; have to do when using auto-expiry or adaptive scoring.
9366 (gnus-summary-show-all-threads)
9367 (if (and to-here reverse)
9371 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9372 (gnus-summary-find-next (not all) nil nil t))))
9373 (when (gnus-summary-first-subject (not all) t)
9375 (if to-here (< (point) to-here) t)
9376 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9377 (gnus-summary-find-next (not all) nil nil t)))))
9378 (gnus-set-mode-line 'summary))
9380 (gnus-summary-position-point)))
9382 (defun gnus-summary-catchup-to-here (&optional all)
9383 "Mark all unticked articles before the current one as read.
9384 If ALL is non-nil, also mark ticked and dormant articles as read."
9387 (gnus-save-hidden-threads
9388 (let ((beg (point)))
9389 ;; We check that there are unread articles.
9390 (when (or all (gnus-summary-find-prev))
9391 (gnus-summary-catchup all t beg)))))
9392 (gnus-summary-position-point))
9394 (defun gnus-summary-catchup-from-here (&optional all)
9395 "Mark all unticked articles after the current one as read.
9396 If ALL is non-nil, also mark ticked and dormant articles as read."
9399 (gnus-save-hidden-threads
9400 (let ((beg (point)))
9401 ;; We check that there are unread articles.
9402 (when (or all (gnus-summary-find-next))
9403 (gnus-summary-catchup all t beg nil t)))))
9405 (gnus-summary-position-point))
9406 (defun gnus-summary-catchup-all (&optional quietly)
9407 "Mark all articles in this newsgroup as read."
9409 (gnus-summary-catchup t quietly))
9411 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9412 "Mark all unread articles in this group as read, then exit.
9413 If prefix argument ALL is non-nil, all articles are marked as read.
9414 If QUIETLY is non-nil, no questions will be asked."
9416 (when (gnus-summary-catchup all quietly nil 'fast)
9417 ;; Select next newsgroup or exit.
9418 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9419 (eq gnus-auto-select-next 'quietly))
9420 (gnus-summary-next-group nil)
9421 (gnus-summary-exit))))
9423 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9424 "Mark all articles in this newsgroup as read, and then exit."
9426 (gnus-summary-catchup-and-exit t quietly))
9428 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9429 "Mark all articles in this group as read and select the next group.
9430 If given a prefix, mark all articles, unread as well as ticked, as
9434 (gnus-summary-catchup all))
9435 (gnus-summary-next-group))
9441 (defmacro gnus-with-article (article &rest forms)
9442 "Select ARTICLE and perform FORMS in the original article buffer.
9443 Then replace the article with the result."
9445 ;; We don't want the article to be marked as read.
9446 (let (gnus-mark-article-hook)
9447 (gnus-summary-select-article t t nil ,article))
9448 (set-buffer gnus-original-article-buffer)
9450 (if (not (gnus-check-backend-function
9451 'request-replace-article (car gnus-article-current)))
9452 (gnus-message 5 "Read-only group; not replacing")
9453 (unless (gnus-request-replace-article
9454 ,article (car gnus-article-current)
9456 (error "Couldn't replace article")))
9457 ;; The cache and backlog have to be flushed somewhat.
9458 (when gnus-keep-backlog
9459 (gnus-backlog-remove-article
9460 (car gnus-article-current) (cdr gnus-article-current)))
9461 (when gnus-use-cache
9462 (gnus-cache-update-article
9463 (car gnus-article-current) (cdr gnus-article-current)))))
9465 (put 'gnus-with-article 'lisp-indent-function 1)
9466 (put 'gnus-with-article 'edebug-form-spec '(form body))
9468 ;; Thread-based commands.
9470 (defun gnus-summary-articles-in-thread (&optional article)
9471 "Return a list of all articles in the current thread.
9472 If ARTICLE is non-nil, return all articles in the thread that starts
9474 (let* ((article (or article (gnus-summary-article-number)))
9475 (data (gnus-data-find-list article))
9476 (top-level (gnus-data-level (car data)))
9478 (cond ((null gnus-thread-operation-ignore-subject)
9479 (gnus-simplify-subject-re
9480 (mail-header-subject (gnus-data-header (car data)))))
9481 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9482 (gnus-simplify-subject-fuzzy
9483 (mail-header-subject (gnus-data-header (car data)))))
9485 (end-point (save-excursion
9486 (if (gnus-summary-go-to-next-thread)
9487 (point) (point-max))))
9490 (< (gnus-data-pos (car data)) end-point))
9491 (when (or (not top-subject)
9492 (string= top-subject
9493 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9494 (gnus-simplify-subject-fuzzy
9495 (mail-header-subject
9496 (gnus-data-header (car data))))
9497 (gnus-simplify-subject-re
9498 (mail-header-subject
9499 (gnus-data-header (car data)))))))
9500 (push (gnus-data-number (car data)) articles))
9501 (unless (and (setq data (cdr data))
9502 (> (gnus-data-level (car data)) top-level))
9504 ;; Return the list of articles.
9505 (nreverse articles)))
9507 (defun gnus-summary-rethread-current ()
9508 "Rethread the thread the current article is part of."
9510 (let* ((gnus-show-threads t)
9511 (article (gnus-summary-article-number))
9512 (id (mail-header-id (gnus-summary-article-header)))
9513 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9515 (error "No article on the current line"))
9516 (gnus-rebuild-thread id)
9517 (gnus-summary-goto-subject article)))
9519 (defun gnus-summary-reparent-thread ()
9520 "Make the current article child of the marked (or previous) article.
9522 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9523 is non-nil or the Subject: of both articles are the same."
9525 (unless (not (gnus-group-read-only-p))
9526 (error "The current newsgroup does not support article editing"))
9527 (unless (<= (length gnus-newsgroup-processable) 1)
9528 (error "No more than one article may be marked"))
9529 (save-window-excursion
9530 (let ((gnus-article-buffer " *reparent*")
9531 (current-article (gnus-summary-article-number))
9532 ;; First grab the marked article, otherwise one line up.
9533 (parent-article (if (not (null gnus-newsgroup-processable))
9534 (car gnus-newsgroup-processable)
9536 (if (eq (forward-line -1) 0)
9537 (gnus-summary-article-number)
9538 (error "Beginning of summary buffer"))))))
9539 (unless (not (eq current-article parent-article))
9540 (error "An article may not be self-referential"))
9541 (let ((message-id (mail-header-id
9542 (gnus-summary-article-header parent-article))))
9543 (unless (and message-id (not (equal message-id "")))
9544 (error "No message-id in desired parent"))
9545 (gnus-with-article current-article
9547 (goto-char (point-min))
9548 (message-narrow-to-head)
9549 (if (re-search-forward "^References: " nil t)
9551 (re-search-forward "^[^ \t]" nil t)
9554 (insert " " message-id))
9555 (insert "References: " message-id "\n"))))
9556 (set-buffer gnus-summary-buffer)
9557 (gnus-summary-unmark-all-processable)
9558 (gnus-summary-update-article current-article)
9559 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9560 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9561 (gnus-summary-rethread-current)
9562 (gnus-message 3 "Article %d is now the child of article %d"
9563 current-article parent-article)))))
9565 (defun gnus-summary-toggle-threads (&optional arg)
9566 "Toggle showing conversation threads.
9567 If ARG is positive number, turn showing conversation threads on."
9569 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9570 (setq gnus-show-threads
9571 (if (null arg) (not gnus-show-threads)
9572 (> (prefix-numeric-value arg) 0)))
9573 (gnus-summary-prepare)
9574 (gnus-summary-goto-subject current)
9575 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9576 (gnus-summary-position-point)))
9578 (defun gnus-summary-show-all-threads ()
9582 (let ((buffer-read-only nil))
9583 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9584 (gnus-summary-position-point))
9586 (defun gnus-summary-show-thread ()
9587 "Show thread subtrees.
9588 Returns nil if no thread was there to be shown."
9590 (let ((buffer-read-only nil)
9592 ;; first goto end then to beg, to have point at beg after let
9593 (end (progn (end-of-line) (point)))
9594 (beg (progn (beginning-of-line) (point))))
9596 ;; Any hidden lines here?
9597 (search-forward "\r" end t)
9598 (subst-char-in-region beg end ?\^M ?\n t)
9600 (gnus-summary-position-point))))
9602 (defun gnus-summary-hide-all-threads ()
9603 "Hide all thread subtrees."
9606 (goto-char (point-min))
9607 (gnus-summary-hide-thread)
9608 (while (zerop (gnus-summary-next-thread 1 t))
9609 (gnus-summary-hide-thread)))
9610 (gnus-summary-position-point))
9612 (defun gnus-summary-hide-thread ()
9613 "Hide thread subtrees.
9614 Returns nil if no threads were there to be hidden."
9616 (let ((buffer-read-only nil)
9618 (article (gnus-summary-article-number)))
9620 ;; Go forward until either the buffer ends or the subthread
9622 (when (and (not (eobp))
9623 (or (zerop (gnus-summary-next-thread 1 t))
9624 (goto-char (point-max))))
9626 (if (and (> (point) start)
9627 (search-backward "\n" start t))
9629 (subst-char-in-region start (point) ?\n ?\^M)
9630 (gnus-summary-goto-subject article))
9634 (defun gnus-summary-go-to-next-thread (&optional previous)
9635 "Go to the same level (or less) next thread.
9636 If PREVIOUS is non-nil, go to previous thread instead.
9637 Return the article number moved to, or nil if moving was impossible."
9638 (let ((level (gnus-summary-thread-level))
9639 (way (if previous -1 1))
9642 (while (and (not (eobp))
9643 (< level (gnus-summary-thread-level)))
9651 (gnus-summary-article-number)
9654 (defun gnus-summary-next-thread (n &optional silent)
9655 "Go to the same level next N'th thread.
9656 If N is negative, search backward instead.
9657 Returns the difference between N and the number of skips actually
9660 If SILENT, don't output messages."
9662 (let ((backward (< n 0))
9665 (gnus-summary-go-to-next-thread backward))
9668 (gnus-summary-position-point))
9669 (when (and (not silent) (/= 0 n))
9670 (gnus-message 7 "No more threads"))
9673 (defun gnus-summary-prev-thread (n)
9674 "Go to the same level previous N'th thread.
9675 Returns the difference between N and the number of skips actually
9678 (gnus-summary-next-thread (- n)))
9680 (defun gnus-summary-go-down-thread ()
9681 "Go down one level in the current thread."
9682 (let ((children (gnus-summary-article-children)))
9684 (gnus-summary-goto-subject (car children)))))
9686 (defun gnus-summary-go-up-thread ()
9687 "Go up one level in the current thread."
9688 (let ((parent (gnus-summary-article-parent)))
9690 (gnus-summary-goto-subject parent))))
9692 (defun gnus-summary-down-thread (n)
9693 "Go down thread N steps.
9694 If N is negative, go up instead.
9695 Returns the difference between N and how many steps down that were
9701 (if up (gnus-summary-go-up-thread)
9702 (gnus-summary-go-down-thread)))
9704 (gnus-summary-position-point)
9706 (gnus-message 7 "Can't go further"))
9709 (defun gnus-summary-up-thread (n)
9710 "Go up thread N steps.
9711 If N is negative, go down instead.
9712 Returns the difference between N and how many steps down that were
9715 (gnus-summary-down-thread (- n)))
9717 (defun gnus-summary-top-thread ()
9718 "Go to the top of the thread."
9720 (while (gnus-summary-go-up-thread))
9721 (gnus-summary-article-number))
9723 (defun gnus-summary-kill-thread (&optional unmark)
9724 "Mark articles under current thread as read.
9725 If the prefix argument is positive, remove any kinds of marks.
9726 If the prefix argument is negative, tick articles instead."
9729 (setq unmark (prefix-numeric-value unmark)))
9730 (let ((articles (gnus-summary-articles-in-thread)))
9732 ;; Expand the thread.
9733 (gnus-summary-show-thread)
9734 ;; Mark all the articles.
9736 (gnus-summary-goto-subject (car articles))
9737 (cond ((null unmark)
9738 (gnus-summary-mark-article-as-read gnus-killed-mark))
9740 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9742 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9743 (setq articles (cdr articles))))
9744 ;; Hide killed subtrees.
9746 gnus-thread-hide-killed
9747 (gnus-summary-hide-thread))
9748 ;; If marked as read, go to next unread subject.
9750 ;; Go to next unread subject.
9751 (gnus-summary-next-subject 1 t)))
9752 (gnus-set-mode-line 'summary))
9754 ;; Summary sorting commands
9756 (defun gnus-summary-sort-by-number (&optional reverse)
9757 "Sort the summary buffer by article number.
9758 Argument REVERSE means reverse order."
9760 (gnus-summary-sort 'number reverse))
9762 (defun gnus-summary-sort-by-author (&optional reverse)
9763 "Sort the summary buffer by author name alphabetically.
9764 If `case-fold-search' is non-nil, case of letters is ignored.
9765 Argument REVERSE means reverse order."
9767 (gnus-summary-sort 'author reverse))
9769 (defun gnus-summary-sort-by-subject (&optional reverse)
9770 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9771 If `case-fold-search' is non-nil, case of letters is ignored.
9772 Argument REVERSE means reverse order."
9774 (gnus-summary-sort 'subject reverse))
9776 (defun gnus-summary-sort-by-date (&optional reverse)
9777 "Sort the summary buffer by date.
9778 Argument REVERSE means reverse order."
9780 (gnus-summary-sort 'date reverse))
9782 (defun gnus-summary-sort-by-score (&optional reverse)
9783 "Sort the summary buffer by score.
9784 Argument REVERSE means reverse order."
9786 (gnus-summary-sort 'score reverse))
9788 (defun gnus-summary-sort-by-lines (&optional reverse)
9789 "Sort the summary buffer by the number of lines.
9790 Argument REVERSE means reverse order."
9792 (gnus-summary-sort 'lines reverse))
9794 (defun gnus-summary-sort-by-chars (&optional reverse)
9795 "Sort the summary buffer by article length.
9796 Argument REVERSE means reverse order."
9798 (gnus-summary-sort 'chars reverse))
9800 (defun gnus-summary-sort-by-original (&optional reverse)
9801 "Sort the summary buffer using the default sorting method.
9802 Argument REVERSE means reverse order."
9804 (let* ((buffer-read-only)
9805 (gnus-summary-prepare-hook nil))
9806 ;; We do the sorting by regenerating the threads.
9807 (gnus-summary-prepare)
9808 ;; Hide subthreads if needed.
9809 (when (and gnus-show-threads gnus-thread-hide-subtree)
9810 (gnus-summary-hide-all-threads))))
9812 (defun gnus-summary-sort (predicate reverse)
9813 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9814 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9815 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9816 (gnus-thread-sort-functions
9821 (gnus-sort-gathered-threads-function
9822 gnus-thread-sort-functions)
9823 (gnus-article-sort-functions
9829 (gnus-summary-prepare-hook nil))
9830 ;; We do the sorting by regenerating the threads.
9831 (gnus-summary-prepare)
9832 ;; Hide subthreads if needed.
9833 (when (and gnus-show-threads gnus-thread-hide-subtree)
9834 (gnus-summary-hide-all-threads))))
9836 ;; Summary saving commands.
9838 (defun gnus-summary-save-article (&optional n not-saved)
9839 "Save the current article using the default saver function.
9840 If N is a positive number, save the N next articles.
9841 If N is a negative number, save the N previous articles.
9842 If N is nil and any articles have been marked with the process mark,
9843 save those articles instead.
9844 The variable `gnus-default-article-saver' specifies the saver function."
9846 (let* ((articles (gnus-summary-work-articles n))
9847 (save-buffer (save-excursion
9848 (nnheader-set-temp-buffer " *Gnus Save*")))
9849 (num (length articles))
9851 (dolist (article articles)
9852 (setq header (gnus-summary-article-header article))
9853 (if (not (vectorp header))
9854 ;; This is a pseudo-article.
9855 (if (assq 'name header)
9856 (gnus-copy-file (cdr (assq 'name header)))
9857 (gnus-message 1 "Article %d is unsaveable" article))
9858 ;; This is a real article.
9859 (save-window-excursion
9860 (let ((gnus-display-mime-function nil)
9861 (gnus-article-prepare-hook nil))
9862 (gnus-summary-select-article t nil nil article)))
9864 (set-buffer save-buffer)
9866 (insert-buffer-substring gnus-original-article-buffer))
9867 (setq file (gnus-article-save save-buffer file num))
9868 (gnus-summary-remove-process-mark article)
9870 (gnus-summary-set-saved-mark article))))
9871 (gnus-kill-buffer save-buffer)
9872 (gnus-summary-position-point)
9873 (gnus-set-mode-line 'summary)
9876 (defun gnus-summary-pipe-output (&optional arg)
9877 "Pipe the current article to a subprocess.
9878 If N is a positive number, pipe the N next articles.
9879 If N is a negative number, pipe the N previous articles.
9880 If N is nil and any articles have been marked with the process mark,
9881 pipe those articles instead."
9884 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9885 (gnus-summary-save-article arg t))
9886 (let ((buffer (get-buffer "*Shell Command Output*")))
9888 (with-current-buffer buffer (> (point-max) (point-min))))
9889 (gnus-configure-windows 'pipe))))
9891 (defun gnus-summary-save-article-mail (&optional arg)
9892 "Append the current article to an mail file.
9893 If N is a positive number, save the N next articles.
9894 If N is a negative number, save the N previous articles.
9895 If N is nil and any articles have been marked with the process mark,
9896 save those articles instead."
9899 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9900 (gnus-summary-save-article arg)))
9902 (defun gnus-summary-save-article-rmail (&optional arg)
9903 "Append the current article to an rmail file.
9904 If N is a positive number, save the N next articles.
9905 If N is a negative number, save the N previous articles.
9906 If N is nil and any articles have been marked with the process mark,
9907 save those articles instead."
9910 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9911 (gnus-summary-save-article arg)))
9913 (defun gnus-summary-save-article-file (&optional arg)
9914 "Append the current article to a file.
9915 If N is a positive number, save the N next articles.
9916 If N is a negative number, save the N previous articles.
9917 If N is nil and any articles have been marked with the process mark,
9918 save those articles instead."
9921 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9922 (gnus-summary-save-article arg)))
9924 (defun gnus-summary-write-article-file (&optional arg)
9925 "Write the current article to a file, deleting the previous file.
9926 If N is a positive number, save the N next articles.
9927 If N is a negative number, save the N previous articles.
9928 If N is nil and any articles have been marked with the process mark,
9929 save those articles instead."
9932 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9933 (gnus-summary-save-article arg)))
9935 (defun gnus-summary-save-article-body-file (&optional arg)
9936 "Append the current article body to a file.
9937 If N is a positive number, save the N next articles.
9938 If N is a negative number, save the N previous articles.
9939 If N is nil and any articles have been marked with the process mark,
9940 save those articles instead."
9943 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9944 (gnus-summary-save-article arg)))
9946 (defun gnus-summary-pipe-message (program)
9947 "Pipe the current article through PROGRAM."
9948 (interactive "sProgram: ")
9949 (gnus-summary-select-article)
9950 (let ((mail-header-separator ""))
9951 (gnus-eval-in-buffer-window gnus-article-buffer
9954 (let ((start (window-start))
9956 (message-pipe-buffer-body program)
9957 (set-window-start (get-buffer-window (current-buffer)) start))))))
9959 (defun gnus-get-split-value (methods)
9960 "Return a value based on the split METHODS."
9961 (let (split-name method result match)
9964 (set-buffer gnus-original-article-buffer)
9966 (nnheader-narrow-to-headers)
9967 (while (and methods (not split-name))
9968 (goto-char (point-min))
9969 (setq method (pop methods))
9970 (setq match (car method))
9973 ;; Regular expression.
9975 (re-search-forward match nil t)))
9976 ((gnus-functionp match)
9980 (setq result (funcall match gnus-newsgroup-name))))
9985 (setq result (eval match)))))
9986 (setq split-name (cdr method))
9987 (cond ((stringp result)
9988 (push (expand-file-name
9989 result gnus-article-save-directory)
9992 (setq split-name (append result split-name)))))))))
9993 (nreverse split-name)))
9995 (defun gnus-valid-move-group-p (group)
9998 (symbol-value group)
9999 (gnus-get-function (gnus-find-method-for-group
10000 (symbol-name group)) 'request-accept-article t)))
10002 (defun gnus-read-move-group-name (prompt default articles prefix)
10003 "Read a group name."
10004 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10005 (minibuffer-confirm-incomplete nil) ; XEmacs
10007 (format "%s %s to:"
10009 (if (> (length articles) 1)
10010 (format "these %d articles" (length articles))
10015 (gnus-completing-read default prom
10017 'gnus-valid-move-group-p
10019 'gnus-group-history))
10020 ((= 1 (length split-name))
10021 (gnus-completing-read (car split-name) prom
10023 'gnus-valid-move-group-p
10025 'gnus-group-history))
10027 (gnus-completing-read nil prom
10028 (mapcar (lambda (el) (list el))
10029 (nreverse split-name))
10031 'gnus-group-history))))
10032 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10034 (if (or (string= to-newsgroup "")
10035 (string= to-newsgroup prefix))
10036 (setq to-newsgroup default))
10037 (unless to-newsgroup
10038 (error "No group name entered"))
10039 (or (gnus-active to-newsgroup)
10040 (gnus-activate-group to-newsgroup nil nil to-method)
10041 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10043 (or (and (gnus-request-create-group to-newsgroup to-method)
10044 (gnus-activate-group
10045 to-newsgroup nil nil to-method)
10046 (gnus-subscribe-group to-newsgroup))
10047 (error "Couldn't create group %s" to-newsgroup)))
10048 (error "No such group: %s" to-newsgroup)))
10051 (defun gnus-summary-save-parts (type dir n &optional reverse)
10052 "Save parts matching TYPE to DIR.
10053 If REVERSE, save parts that do not match TYPE."
10055 (list (read-string "Save parts of type: "
10056 (or (car gnus-summary-save-parts-type-history)
10057 gnus-summary-save-parts-default-mime)
10058 'gnus-summary-save-parts-type-history)
10059 (setq gnus-summary-save-parts-last-directory
10060 (read-file-name "Save to directory: "
10061 gnus-summary-save-parts-last-directory
10063 current-prefix-arg))
10064 (gnus-summary-iterate n
10065 (let ((gnus-display-mime-function nil)
10066 (gnus-inhibit-treatment t))
10067 (gnus-summary-select-article))
10069 (set-buffer gnus-article-buffer)
10070 (let ((handles (or gnus-article-mime-handles
10071 (mm-dissect-buffer) (mm-uu-dissect))))
10073 (gnus-summary-save-parts-1 type dir handles reverse)
10074 (unless gnus-article-mime-handles ;; Don't destroy this case.
10075 (mm-destroy-parts handles)))))))
10077 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10078 (if (stringp (car handle))
10079 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10082 (not (string-match type (mm-handle-media-type handle)))
10083 (string-match type (mm-handle-media-type handle)))
10084 (let ((file (expand-file-name
10085 (file-name-nondirectory
10087 (mail-content-type-get
10088 (mm-handle-disposition handle) 'filename)
10089 (concat gnus-newsgroup-name
10090 "." (number-to-string
10091 (cdr gnus-article-current)))))
10093 (unless (file-exists-p file)
10094 (mm-save-part-to-file handle file))))))
10096 ;; Summary extract commands
10098 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10099 (let ((buffer-read-only nil)
10100 (article (gnus-summary-article-number))
10102 (unless (gnus-summary-goto-subject article)
10103 (error "No such article: %d" article))
10104 (gnus-summary-position-point)
10105 ;; If all commands are to be bunched up on one line, we collect
10107 (unless gnus-view-pseudos-separately
10108 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10111 (setq action (cdr (assq 'action (car ps))))
10112 (setq files (list (cdr (assq 'name (car ps)))))
10113 (while (and ps (cdr ps)
10114 (string= (or action "1")
10115 (or (cdr (assq 'action (cadr ps))) "2")))
10116 (push (cdr (assq 'name (cadr ps))) files)
10117 (setcdr ps (cddr ps)))
10119 (when (not (string-match "%s" action))
10122 (when (assq 'execute (car ps))
10123 (setcdr (assq 'execute (car ps))
10124 (funcall (if (string-match "%s" action)
10133 (setq ps (cdr ps)))))
10134 (if (and gnus-view-pseudos (not not-view))
10136 (when (assq 'execute (car pslist))
10137 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10138 (eq gnus-view-pseudos 'not-confirm)))
10139 (setq pslist (cdr pslist)))
10142 (setq after-article (or (cdr (assq 'article (car pslist)))
10143 (gnus-summary-article-number)))
10144 (gnus-summary-goto-subject after-article)
10147 (insert " " (file-name-nondirectory
10148 (cdr (assq 'name (car pslist))))
10149 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10151 (forward-line -1) ; back to `b'
10152 (gnus-add-text-properties
10153 b (1- e) (list 'gnus-number gnus-reffed-article-number
10154 gnus-mouse-face-prop gnus-mouse-face))
10156 after-article gnus-reffed-article-number
10157 gnus-unread-mark b (car pslist) 0 (- e b))
10158 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10159 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10160 (setq pslist (cdr pslist)))))))
10162 (defun gnus-pseudos< (p1 p2)
10163 (let ((c1 (cdr (assq 'action p1)))
10164 (c2 (cdr (assq 'action p2))))
10165 (and c1 c2 (string< c1 c2))))
10167 (defun gnus-request-pseudo-article (props)
10168 (cond ((assq 'execute props)
10169 (gnus-execute-command (cdr (assq 'execute props)))))
10170 (let ((gnus-current-article (gnus-summary-article-number)))
10171 (gnus-run-hooks 'gnus-mark-article-hook)))
10173 (defun gnus-execute-command (command &optional automatic)
10175 (gnus-article-setup-buffer)
10176 (set-buffer gnus-article-buffer)
10177 (setq buffer-read-only nil)
10178 (let ((command (if automatic command
10179 (read-string "Command: " (cons command 0)))))
10181 (insert "$ " command "\n\n")
10182 (if gnus-view-pseudo-asynchronously
10183 (start-process "gnus-execute" (current-buffer) shell-file-name
10184 shell-command-switch command)
10185 (call-process shell-file-name nil t nil
10186 shell-command-switch command)))))
10188 ;; Summary kill commands.
10190 (defun gnus-summary-edit-global-kill (article)
10191 "Edit the \"global\" kill file."
10192 (interactive (list (gnus-summary-article-number)))
10193 (gnus-group-edit-global-kill article))
10195 (defun gnus-summary-edit-local-kill ()
10196 "Edit a local kill file applied to the current newsgroup."
10198 (setq gnus-current-headers (gnus-summary-article-header))
10199 (gnus-group-edit-local-kill
10200 (gnus-summary-article-number) gnus-newsgroup-name))
10202 ;;; Header reading.
10204 (defun gnus-read-header (id &optional header)
10205 "Read the headers of article ID and enter them into the Gnus system."
10206 (let ((group gnus-newsgroup-name)
10207 (gnus-override-method
10209 gnus-override-method
10210 (and (gnus-news-group-p gnus-newsgroup-name)
10211 (car (gnus-refer-article-methods)))))
10213 ;; First we check to see whether the header in question is already
10216 ;; This is a Message-ID.
10217 (setq header (or header (gnus-id-to-header id)))
10218 ;; This is an article number.
10219 (setq header (or header (gnus-summary-article-header id))))
10221 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10222 ;; We have found the header.
10224 ;; If this is a sparse article, we have to nix out its
10225 ;; previous entry in the thread hashtb.
10227 (gnus-summary-article-sparse-p (mail-header-number header)))
10228 (let* ((parent (gnus-parent-id (mail-header-references header)))
10229 (thread (and parent (gnus-id-to-thread parent))))
10231 (delq (assq header thread) thread))))
10232 ;; We have to really fetch the header to this article.
10234 (set-buffer nntp-server-buffer)
10235 (when (setq where (gnus-request-head id group))
10236 (nnheader-fold-continuation-lines)
10237 (goto-char (point-max))
10239 (goto-char (point-min))
10243 ((cdr where) (cdr where))
10244 (header (mail-header-number header))
10245 (t gnus-reffed-article-number))
10247 (insert " Article retrieved.\n"))
10248 (if (or (not where)
10249 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10250 () ; Malformed head.
10251 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10252 (when (and (stringp id)
10253 (not (string= (gnus-group-real-name group)
10255 ;; If we fetched by Message-ID and the article came
10256 ;; from a different group, we fudge some bogus article
10257 ;; numbers for this article.
10258 (mail-header-set-number header gnus-reffed-article-number))
10260 (set-buffer gnus-summary-buffer)
10261 (decf gnus-reffed-article-number)
10262 (gnus-remove-header (mail-header-number header))
10263 (push header gnus-newsgroup-headers)
10264 (setq gnus-current-headers header)
10265 (push (mail-header-number header) gnus-newsgroup-limit)))
10268 (defun gnus-remove-header (number)
10269 "Remove header NUMBER from `gnus-newsgroup-headers'."
10270 (if (and gnus-newsgroup-headers
10271 (= number (mail-header-number (car gnus-newsgroup-headers))))
10272 (pop gnus-newsgroup-headers)
10273 (let ((headers gnus-newsgroup-headers))
10274 (while (and (cdr headers)
10275 (not (= number (mail-header-number (cadr headers)))))
10277 (when (cdr headers)
10278 (setcdr headers (cddr headers))))))
10281 ;;; summary highlights
10284 (defun gnus-highlight-selected-summary ()
10285 "Highlight selected article in summary buffer."
10286 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10287 (when gnus-summary-selected-face
10289 (let* ((beg (progn (beginning-of-line) (point)))
10290 (end (progn (end-of-line) (point)))
10291 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10292 (from (if (get-text-property beg gnus-mouse-face-prop)
10294 (or (next-single-property-change
10295 beg gnus-mouse-face-prop nil end)
10300 (or (next-single-property-change
10301 from gnus-mouse-face-prop nil end)
10303 ;; If no mouse-face prop on line we will have to = from = end,
10304 ;; so we highlight the entire line instead.
10305 (when (= (+ to 2) from)
10308 (if gnus-newsgroup-selected-overlay
10309 ;; Move old overlay.
10311 gnus-newsgroup-selected-overlay from to (current-buffer))
10312 ;; Create new overlay.
10314 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10315 'face gnus-summary-selected-face))))))
10317 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10318 (defun gnus-summary-highlight-line ()
10319 "Highlight current line according to `gnus-summary-highlight'."
10320 (let* ((list gnus-summary-highlight)
10322 (end (progn (end-of-line) (point)))
10323 ;; now find out where the line starts and leave point there.
10324 (beg (progn (beginning-of-line) (point)))
10325 (article (gnus-summary-article-number))
10326 (score (or (cdr (assq (or article gnus-current-article)
10327 gnus-newsgroup-scored))
10328 gnus-summary-default-score 0))
10329 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10330 (inhibit-read-only t))
10331 ;; Eval the cars of the lists until we find a match.
10332 (let ((default gnus-summary-default-score)
10333 (default-high gnus-summary-default-high-score)
10334 (default-low gnus-summary-default-low-score))
10336 (not (eval (caar list))))
10337 (setq list (cdr list))))
10338 (let ((face (cdar list)))
10339 (unless (eq face (get-text-property beg 'face))
10340 (gnus-put-text-property-excluding-characters-with-faces
10342 (setq face (if (boundp face) (symbol-value face) face)))
10343 (when gnus-summary-highlight-line-function
10344 (funcall gnus-summary-highlight-line-function article face))))
10347 (defun gnus-update-read-articles (group unread &optional compute)
10348 "Update the list of read articles in GROUP."
10349 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10350 (entry (gnus-gethash group gnus-newsrc-hashtb))
10351 (info (nth 2 entry))
10353 (unread (sort (copy-sequence unread) '<))
10355 (if (or (not info) (not active))
10356 ;; There is no info on this group if it was, in fact,
10357 ;; killed. Gnus stores no information on killed groups, so
10358 ;; there's nothing to be done.
10359 ;; One could store the information somewhere temporarily,
10360 ;; perhaps... Hmmm...
10362 ;; Remove any negative articles numbers.
10363 (while (and unread (< (car unread) 0))
10364 (setq unread (cdr unread)))
10365 ;; Remove any expired article numbers
10366 (while (and unread (< (car unread) (car active)))
10367 (setq unread (cdr unread)))
10368 ;; Compute the ranges of read articles by looking at the list of
10369 ;; unread articles.
10371 (when (/= (car unread) prev)
10372 (push (if (= prev (1- (car unread))) prev
10373 (cons prev (1- (car unread))))
10375 (setq prev (1+ (car unread)))
10376 (setq unread (cdr unread)))
10377 (when (<= prev (cdr active))
10378 (push (cons prev (cdr active)) read))
10379 (setq read (if (> (length read) 1) (nreverse read) read))
10384 ;; Propagate the read marks to the backend.
10385 (when (gnus-check-backend-function 'request-set-mark group)
10386 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10387 (add (gnus-remove-from-range read (gnus-info-read info))))
10389 (unless (gnus-check-group group)
10390 (error "Can't open server for %s" group))
10391 (gnus-request-set-mark
10392 group (delq nil (list (if add (list add 'add '(read)))
10393 (if del (list del 'del '(read))))))
10395 `(gnus-request-set-mark
10398 (if del (list del 'add '(read)))
10399 (if add (list add 'del '(read))))))))))
10400 (set-buffer gnus-group-buffer)
10401 (gnus-undo-register
10403 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10404 (gnus-info-set-read ',info ',(gnus-info-read info))
10405 (gnus-get-unread-articles-in-group ',info
10406 (gnus-active ,group))
10407 (gnus-group-update-group ,group t)
10409 ;; Enter this list into the group info.
10410 (gnus-info-set-read info read)
10411 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10412 (gnus-get-unread-articles-in-group info (gnus-active group))
10415 (defun gnus-offer-save-summaries ()
10416 "Offer to save all active summary buffers."
10418 ;; Go through all buffers and find all summaries.
10419 (dolist (buffer (buffer-list))
10420 (when (and (setq buffer (buffer-name buffer))
10421 (string-match "Summary" buffer)
10423 (set-buffer buffer)
10424 ;; We check that this is, indeed, a summary buffer.
10425 (and (eq major-mode 'gnus-summary-mode)
10426 ;; Also make sure this isn't bogus.
10427 gnus-newsgroup-prepared
10428 ;; Also make sure that this isn't a
10429 ;; dead summary buffer.
10430 (not gnus-dead-summary-mode))))
10431 (push buffer buffers)))
10432 ;; Go through all these summary buffers and offer to save them.
10436 "Update summary buffer %s? "
10438 (switch-to-buffer buf)
10439 (gnus-summary-exit))
10442 (defun gnus-summary-setup-default-charset ()
10443 "Setup newsgroup default charset."
10444 (if (equal gnus-newsgroup-name "nndraft:drafts")
10445 (setq gnus-newsgroup-charset nil)
10446 (let* ((ignored-charsets
10447 (or gnus-newsgroup-ephemeral-ignored-charsets
10449 (and gnus-newsgroup-name
10450 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10451 gnus-newsgroup-ignored-charsets))))
10452 (setq gnus-newsgroup-charset
10453 (or gnus-newsgroup-ephemeral-charset
10454 (and gnus-newsgroup-name
10455 (gnus-parameter-charset gnus-newsgroup-name))
10456 gnus-default-charset))
10457 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10458 ignored-charsets))))
10464 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10465 "Display the current article buffer fully MIME-buttonized.
10466 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10467 treated as multipart/mixed."
10469 (require 'gnus-art)
10470 (let ((gnus-unbuttonized-mime-types nil)
10471 (gnus-mime-display-multipart-as-mixed show-all-parts))
10472 (gnus-summary-show-article)))
10474 (defun gnus-summary-repair-multipart (article)
10475 "Add a Content-Type header to a multipart article without one."
10476 (interactive (list (gnus-summary-article-number)))
10477 (gnus-with-article article
10478 (message-narrow-to-head)
10479 (message-remove-header "Mime-Version")
10480 (goto-char (point-max))
10481 (insert "Mime-Version: 1.0\n")
10483 (when (search-forward "\n--" nil t)
10484 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10485 (message-narrow-to-head)
10486 (message-remove-header "Content-Type")
10487 (goto-char (point-max))
10488 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10491 (let (gnus-mark-article-hook)
10492 (gnus-summary-select-article t t nil article)))
10494 (defun gnus-summary-toggle-display-buttonized ()
10495 "Toggle the buttonizing of the article buffer."
10497 (require 'gnus-art)
10498 (if (setq gnus-inhibit-mime-unbuttonizing
10499 (not gnus-inhibit-mime-unbuttonizing))
10500 (let ((gnus-unbuttonized-mime-types nil))
10501 (gnus-summary-show-article))
10502 (gnus-summary-show-article)))
10505 ;;; Generic summary marking commands
10508 (defvar gnus-summary-marking-alist
10509 '((read gnus-del-mark "d")
10510 (unread gnus-unread-mark "u")
10511 (ticked gnus-ticked-mark "!")
10512 (dormant gnus-dormant-mark "?")
10513 (expirable gnus-expirable-mark "e"))
10514 "An alist of names/marks/keystrokes.")
10516 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10517 (defvar gnus-summary-mark-map)
10519 (defun gnus-summary-make-all-marking-commands ()
10520 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10521 (dolist (elem gnus-summary-marking-alist)
10522 (apply 'gnus-summary-make-marking-command elem)))
10524 (defun gnus-summary-make-marking-command (name mark keystroke)
10525 (let ((map (make-sparse-keymap)))
10526 (define-key gnus-summary-generic-mark-map keystroke map)
10527 (dolist (lway `((next "next" next nil "n")
10528 (next-unread "next unread" next t "N")
10529 (prev "previous" prev nil "p")
10530 (prev-unread "previous unread" prev t "P")
10531 (nomove "" nil nil ,keystroke)))
10532 (let ((func (gnus-summary-make-marking-command-1
10533 mark (car lway) lway name)))
10534 (setq func (eval func))
10535 (define-key map (nth 4 lway) func)))))
10537 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10539 (format "gnus-summary-put-mark-as-%s%s"
10540 name (if (eq way 'nomove)
10542 (concat "-" (symbol-name way)))))
10545 "Mark the current article as %s%s.
10546 If N, the prefix, then repeat N times.
10547 If N is negative, move in reverse order.
10548 The difference between N and the actual number of articles marked is
10552 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10554 (defun gnus-summary-generic-mark (n mark move unread)
10555 "Mark N articles with MARK."
10556 (unless (eq major-mode 'gnus-summary-mode)
10557 (error "This command can only be used in the summary buffer"))
10558 (gnus-summary-show-thread)
10561 ((eq move 'next) 1)
10562 ((eq move 'prev) -1)
10564 (if (zerop nummove)
10568 nummove (* -1 nummove))))
10569 (while (and (> n 0)
10570 (gnus-summary-mark-article nil mark)
10571 (zerop (gnus-summary-next-subject nummove unread t)))
10574 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10575 (gnus-summary-recenter)
10576 (gnus-summary-position-point)
10577 (gnus-set-mode-line 'summary)
10580 (defun gnus-summary-insert-articles (articles)
10581 (when (setq articles
10582 (gnus-set-difference articles
10583 (mapcar (lambda (h) (mail-header-number h))
10584 gnus-newsgroup-headers)))
10585 (setq gnus-newsgroup-headers
10587 gnus-newsgroup-headers
10588 (gnus-fetch-headers articles)
10589 'gnus-article-sort-by-number))
10590 ;; Suppress duplicates?
10591 (when gnus-suppress-duplicates
10592 (gnus-dup-suppress-articles))
10594 ;; We might want to build some more threads first.
10595 (when (and gnus-fetch-old-headers
10596 (eq gnus-headers-retrieved-by 'nov))
10597 (if (eq gnus-fetch-old-headers 'invisible)
10598 (gnus-build-all-threads)
10599 (gnus-build-old-threads)))
10600 ;; Let the Gnus agent mark articles as read.
10602 (gnus-agent-get-undownloaded-list))
10603 ;; Remove list identifiers from subject
10604 (when gnus-list-identifiers
10605 (gnus-summary-remove-list-identifiers))
10606 ;; First and last article in this newsgroup.
10607 (when gnus-newsgroup-headers
10608 (setq gnus-newsgroup-begin
10609 (mail-header-number (car gnus-newsgroup-headers))
10611 (mail-header-number
10612 (gnus-last-element gnus-newsgroup-headers))))
10613 (when gnus-use-scoring
10614 (gnus-possibly-score-headers))))
10616 (defun gnus-summary-insert-old-articles (&optional all)
10617 "Insert all old articles in this group.
10618 If ALL is non-nil, already read articles become readable.
10619 If ALL is a number, fetch this number of articles."
10622 (let ((old (mapcar 'car gnus-newsgroup-data))
10623 (i (car gnus-newsgroup-active))
10625 (while (<= i (cdr gnus-newsgroup-active))
10626 (or (memq i old) (push i older))
10628 (setq len (length older))
10633 (setq older (subseq older 0 all))))
10636 (if (and (numberp gnus-large-newsgroup)
10637 (> len gnus-large-newsgroup))
10641 "How many articles from %s (default %d): "
10643 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10645 (unless (string-match "^[ \t]*$" input)
10646 (setq all (string-to-number input))
10648 (setq older (subseq older 0 all))))))))
10650 (message "No old news.")
10651 (gnus-summary-insert-articles older)
10652 (gnus-summary-limit (gnus-union older old))))
10653 (gnus-summary-position-point)))
10655 (defun gnus-summary-insert-new-articles ()
10656 "Insert all new articles in this group."
10659 (let ((old (mapcar 'car gnus-newsgroup-data))
10660 (old-active gnus-newsgroup-active)
10661 (nnmail-fetched-sources (list t))
10663 (setq gnus-newsgroup-active
10664 (gnus-activate-group gnus-newsgroup-name 'scan))
10665 (setq i (1+ (cdr old-active)))
10666 (while (<= i (cdr gnus-newsgroup-active))
10670 (message "No gnus is bad news.")
10671 (setq new (nreverse new))
10672 (gnus-summary-insert-articles new)
10673 (setq gnus-newsgroup-unreads
10674 (append gnus-newsgroup-unreads new))
10675 (gnus-summary-limit (gnus-union old new))))
10676 (gnus-summary-position-point)))
10678 (gnus-summary-make-all-marking-commands)
10680 (gnus-ems-redefine)
10682 (provide 'gnus-sum)
10684 (run-hooks 'gnus-sum-load-hook)
10686 ;;; gnus-sum.el ends here