1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
47 (autoload 'gnus-cache-articles-in-group "gnus-cache")
48 (autoload 'pgg-decrypt-region "pgg" nil t)
49 (autoload 'pgg-verify-region "pgg" nil t))
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-cache-write-active "gnus-cache")
53 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
55 (defcustom gnus-kill-summary-on-exit t
56 "*If non-nil, kill the summary buffer when you exit from it.
57 If nil, the summary will become a \"*Dead Summary*\" buffer, and
58 it will be killed sometime later."
59 :group 'gnus-summary-exit
62 (defcustom gnus-fetch-old-headers nil
63 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
64 If an unread article in the group refers to an older, already read (or
65 just marked as read) article, the old article will not normally be
66 displayed in the Summary buffer. If this variable is non-nil, Gnus
67 will attempt to grab the headers to the old articles, and thereby
68 build complete threads. If it has the value `some', only enough
69 headers to connect otherwise loose threads will be displayed. This
70 variable can also be a number. In that case, no more than that number
71 of old headers will be fetched. If it has the value `invisible', all
72 old headers will be fetched, but none will be displayed.
74 The server has to support NOV for any of this to work."
76 :type '(choice (const :tag "off" nil)
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-refer-thread-limit 200
82 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
83 If t, fetch all the available old headers."
86 (sexp :menu-tag "other" t)))
88 (defcustom gnus-summary-make-false-root 'adopt
89 "*nil means that Gnus won't gather loose threads.
90 If the root of a thread has expired or been read in a previous
91 session, the information necessary to build a complete thread has been
92 lost. Instead of having many small sub-threads from this original thread
93 scattered all over the summary buffer, Gnus can gather them.
95 If non-nil, Gnus will try to gather all loose sub-threads from an
96 original thread into one large thread.
98 If this variable is non-nil, it should be one of `none', `adopt',
101 If this variable is `none', Gnus will not make a false root, but just
102 present the sub-threads after another.
103 If this variable is `dummy', Gnus will create a dummy root that will
104 have all the sub-threads as children.
105 If this variable is `adopt', Gnus will make one of the \"children\"
106 the parent and mark all the step-children as such.
107 If this variable is `empty', the \"children\" are printed with empty
108 subject fields. (Or rather, they will be printed with a string
109 given by the `gnus-summary-same-subject' variable.)"
111 :type '(choice (const :tag "off" nil)
117 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
118 "*A regexp to match subjects to be excluded from loose thread gathering.
119 As loose thread gathering is done on subjects only, that means that
120 there can be many false gatherings performed. By rooting out certain
121 common subjects, gathering might become saner."
125 (defcustom gnus-summary-gather-subject-limit nil
126 "*Maximum length of subject comparisons when gathering loose threads.
127 Use nil to compare full subjects. Setting this variable to a low
128 number will help gather threads that have been corrupted by
129 newsreaders chopping off subject lines, but it might also mean that
130 unrelated articles that have subject that happen to begin with the
131 same few characters will be incorrectly gathered.
133 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
136 :type '(choice (const :tag "off" nil)
138 (sexp :menu-tag "on" t)))
140 (defcustom gnus-simplify-subject-functions nil
141 "List of functions taking a string argument that simplify subjects.
142 The functions are applied recursively.
144 Useful functions to put in this list include: `gnus-simplify-subject-re',
145 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
147 :type '(repeat function))
149 (defcustom gnus-simplify-ignored-prefixes nil
150 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
152 :type '(choice (const :tag "off" nil)
155 (defcustom gnus-build-sparse-threads nil
156 "*If non-nil, fill in the gaps in threads.
157 If `some', only fill in the gaps that are needed to tie loose threads
158 together. If `more', fill in all leaf nodes that Gnus can find. If
159 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
161 :type '(choice (const :tag "off" nil)
164 (sexp :menu-tag "all" t)))
166 (defcustom gnus-summary-thread-gathering-function
167 'gnus-gather-threads-by-subject
168 "*Function used for gathering loose threads.
169 There are two pre-defined functions: `gnus-gather-threads-by-subject',
170 which only takes Subjects into consideration; and
171 `gnus-gather-threads-by-references', which compared the References
172 headers of the articles to find matches."
174 :type '(radio (function-item gnus-gather-threads-by-subject)
175 (function-item gnus-gather-threads-by-references)
176 (function :tag "other")))
178 (defcustom gnus-summary-same-subject ""
179 "*String indicating that the current article has the same subject as the previous.
180 This variable will only be used if the value of
181 `gnus-summary-make-false-root' is `empty'."
182 :group 'gnus-summary-format
185 (defcustom gnus-summary-goto-unread t
186 "*If t, many commands will go to the next unread article.
187 This applies to marking commands as well as other commands that
188 \"naturally\" select the next article, like, for instance, `SPC' at
189 the end of an article.
191 If nil, the marking commands do NOT go to the next unread article
192 (they go to the next article instead). If `never', commands that
193 usually go to the next unread article, will go to the next article,
194 whether it is read or not."
195 :group 'gnus-summary-marks
196 :link '(custom-manual "(gnus)Setting Marks")
197 :type '(choice (const :tag "off" nil)
199 (sexp :menu-tag "on" t)))
201 (defcustom gnus-summary-default-score 0
202 "*Default article score level.
203 All scores generated by the score files will be added to this score.
204 If this variable is nil, scoring will be disabled."
205 :group 'gnus-score-default
206 :type '(choice (const :tag "disable")
209 (defcustom gnus-summary-zcore-fuzz 0
210 "*Fuzziness factor for the zcore in the summary buffer.
211 Articles with scores closer than this to `gnus-summary-default-score'
213 :group 'gnus-summary-format
216 (defcustom gnus-simplify-subject-fuzzy-regexp nil
217 "*Strings to be removed when doing fuzzy matches.
218 This can either be a regular expression or list of regular expressions
219 that will be removed from subject strings if fuzzy subject
220 simplification is selected."
222 :type '(repeat regexp))
224 (defcustom gnus-show-threads t
225 "*If non-nil, display threads in summary mode."
229 (defcustom gnus-thread-hide-subtree nil
230 "*If non-nil, hide all threads initially.
231 If threads are hidden, you have to run the command
232 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
233 to expose hidden threads."
237 (defcustom gnus-thread-hide-killed t
238 "*If non-nil, hide killed threads automatically."
242 (defcustom gnus-thread-ignore-subject t
243 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
244 If nil, articles that have different subjects from their parents will
245 start separate threads."
249 (defcustom gnus-thread-operation-ignore-subject t
250 "*If non-nil, subjects will be ignored when doing thread commands.
251 This affects commands like `gnus-summary-kill-thread' and
252 `gnus-summary-lower-thread'.
254 If this variable is nil, articles in the same thread with different
255 subjects will not be included in the operation in question. If this
256 variable is `fuzzy', only articles that have subjects that are fuzzily
257 equal will be included."
259 :type '(choice (const :tag "off" nil)
263 (defcustom gnus-thread-indent-level 4
264 "*Number that says how much each sub-thread should be indented."
268 (defcustom gnus-auto-extend-newsgroup t
269 "*If non-nil, extend newsgroup forward and backward when requested."
270 :group 'gnus-summary-choose
273 (defcustom gnus-auto-select-first t
274 "*If nil, don't select the first unread article when entering a group.
275 If this variable is `best', select the highest-scored unread article
276 in the group. If t, select the first unread article.
278 This variable can also be a function to place point on a likely
279 subject line. Useful values include `gnus-summary-first-unread-subject',
280 `gnus-summary-first-unread-article' and
281 `gnus-summary-best-unread-article'.
283 If you want to prevent automatic selection of the first unread article
284 in some newsgroups, set the variable to nil in
285 `gnus-select-group-hook'."
286 :group 'gnus-group-select
287 :type '(choice (const :tag "none" nil)
289 (sexp :menu-tag "first" t)
290 (function-item gnus-summary-first-unread-subject)
291 (function-item gnus-summary-first-unread-article)
292 (function-item gnus-summary-best-unread-article)))
294 (defcustom gnus-dont-select-after-jump-to-other-group nil
295 "If non-nil, don't select the first unread article after entering the
296 other group by the command `gnus-summary-jump-to-other-group'. If nil,
297 it is depend on the value of `gnus-auto-select-first' whether to select
299 :group 'gnus-group-select
302 (defcustom gnus-auto-select-next t
303 "*If non-nil, offer to go to the next group from the end of the previous.
304 If the value is t and the next newsgroup is empty, Gnus will exit
305 summary mode and go back to group mode. If the value is neither nil
306 nor t, Gnus will select the following unread newsgroup. In
307 particular, if the value is the symbol `quietly', the next unread
308 newsgroup will be selected without any confirmation, and if it is
309 `almost-quietly', the next group will be selected without any
310 confirmation if you are located on the last article in the group.
311 Finally, if this variable is `slightly-quietly', the `Z n' command
312 will go to the next group without confirmation."
313 :group 'gnus-summary-maneuvering
314 :type '(choice (const :tag "off" nil)
316 (const almost-quietly)
317 (const slightly-quietly)
318 (sexp :menu-tag "on" t)))
320 (defcustom gnus-auto-select-same nil
321 "*If non-nil, select the next article with the same subject.
322 If there are no more articles with the same subject, go to
323 the first unread article."
324 :group 'gnus-summary-maneuvering
327 (defcustom gnus-summary-check-current nil
328 "*If non-nil, consider the current article when moving.
329 The \"unread\" movement commands will stay on the same line if the
330 current article is unread."
331 :group 'gnus-summary-maneuvering
334 (defcustom gnus-auto-center-summary t
335 "*If non-nil, always center the current summary buffer.
336 In particular, if `vertical' do only vertical recentering. If non-nil
337 and non-`vertical', do both horizontal and vertical recentering."
338 :group 'gnus-summary-maneuvering
339 :type '(choice (const :tag "none" nil)
341 (integer :tag "height")
342 (sexp :menu-tag "both" t)))
344 (defcustom gnus-show-all-headers nil
345 "*If non-nil, don't hide any headers."
346 :group 'gnus-article-hiding
347 :group 'gnus-article-headers
350 (defcustom gnus-summary-ignore-duplicates nil
351 "*If non-nil, ignore articles with identical Message-ID headers."
355 (defcustom gnus-single-article-buffer t
356 "*If non-nil, display all articles in the same buffer.
357 If nil, each group will get its own article buffer."
358 :group 'gnus-article-various
361 (defcustom gnus-break-pages t
362 "*If non-nil, do page breaking on articles.
363 The page delimiter is specified by the `gnus-page-delimiter'
365 :group 'gnus-article-various
368 (defcustom gnus-show-mime t
369 "*If non-nil, do mime processing of articles.
370 The articles will simply be fed to the function given by
371 `gnus-article-display-method-for-mime'."
372 :group 'gnus-article-mime
375 (defcustom gnus-move-split-methods nil
376 "*Variable used to suggest where articles are to be moved to.
377 It uses the same syntax as the `gnus-split-methods' variable."
378 :group 'gnus-summary-mail
379 :type '(repeat (choice (list :value (fun) function)
380 (cons :value ("" "") regexp (repeat string))
383 (defcustom gnus-unread-mark ? ;Whitespace
384 "*Mark used for unread articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-ticked-mark ?!
389 "*Mark used for ticked articles."
390 :group 'gnus-summary-marks
393 (defcustom gnus-dormant-mark ??
394 "*Mark used for dormant articles."
395 :group 'gnus-summary-marks
398 (defcustom gnus-del-mark ?r
399 "*Mark used for del'd articles."
400 :group 'gnus-summary-marks
403 (defcustom gnus-read-mark ?R
404 "*Mark used for read articles."
405 :group 'gnus-summary-marks
408 (defcustom gnus-expirable-mark ?E
409 "*Mark used for expirable articles."
410 :group 'gnus-summary-marks
413 (defcustom gnus-killed-mark ?K
414 "*Mark used for killed articles."
415 :group 'gnus-summary-marks
418 (defcustom gnus-souped-mark ?F
419 "*Mark used for killed articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-kill-file-mark ?X
424 "*Mark used for articles killed by kill files."
425 :group 'gnus-summary-marks
428 (defcustom gnus-low-score-mark ?Y
429 "*Mark used for articles with a low score."
430 :group 'gnus-summary-marks
433 (defcustom gnus-catchup-mark ?C
434 "*Mark used for articles that are caught up."
435 :group 'gnus-summary-marks
438 (defcustom gnus-replied-mark ?A
439 "*Mark used for articles that have been replied to."
440 :group 'gnus-summary-marks
443 (defcustom gnus-cached-mark ?*
444 "*Mark used for articles that are in the cache."
445 :group 'gnus-summary-marks
448 (defcustom gnus-saved-mark ?S
449 "*Mark used for articles that have been saved to."
450 :group 'gnus-summary-marks
453 (defcustom gnus-ancient-mark ?O
454 "*Mark used for ancient articles."
455 :group 'gnus-summary-marks
458 (defcustom gnus-sparse-mark ?Q
459 "*Mark used for sparsely reffed articles."
460 :group 'gnus-summary-marks
463 (defcustom gnus-canceled-mark ?G
464 "*Mark used for canceled articles."
465 :group 'gnus-summary-marks
468 (defcustom gnus-duplicate-mark ?M
469 "*Mark used for duplicate articles."
470 :group 'gnus-summary-marks
473 (defcustom gnus-undownloaded-mark ?@
474 "*Mark used for articles that weren't downloaded."
475 :group 'gnus-summary-marks
478 (defcustom gnus-downloadable-mark ?%
479 "*Mark used for articles that are to be downloaded."
480 :group 'gnus-summary-marks
483 (defcustom gnus-unsendable-mark ?=
484 "*Mark used for articles that won't be sent."
485 :group 'gnus-summary-marks
488 (defcustom gnus-score-over-mark ?+
489 "*Score mark used for articles with high scores."
490 :group 'gnus-summary-marks
493 (defcustom gnus-score-below-mark ?-
494 "*Score mark used for articles with low scores."
495 :group 'gnus-summary-marks
498 (defcustom gnus-empty-thread-mark ? ;Whitespace
499 "*There is no thread under the article."
500 :group 'gnus-summary-marks
503 (defcustom gnus-not-empty-thread-mark ?=
504 "*There is a thread under the article."
505 :group 'gnus-summary-marks
508 (defcustom gnus-view-pseudo-asynchronously nil
509 "*If non-nil, Gnus will view pseudo-articles asynchronously."
510 :group 'gnus-extract-view
513 (defcustom gnus-auto-expirable-marks
514 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
515 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
516 gnus-souped-mark gnus-duplicate-mark)
517 "*The list of marks converted into expiration if a group is auto-expirable."
519 :type '(repeat character))
521 (defcustom gnus-inhibit-user-auto-expire t
522 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
526 (defcustom gnus-view-pseudos nil
527 "*If `automatic', pseudo-articles will be viewed automatically.
528 If `not-confirm', pseudos will be viewed automatically, and the user
529 will not be asked to confirm the command."
530 :group 'gnus-extract-view
531 :type '(choice (const :tag "off" nil)
533 (const not-confirm)))
535 (defcustom gnus-view-pseudos-separately t
536 "*If non-nil, one pseudo-article will be created for each file to be viewed.
537 If nil, all files that use the same viewing command will be given as a
538 list of parameters to that command."
539 :group 'gnus-extract-view
542 (defcustom gnus-insert-pseudo-articles t
543 "*If non-nil, insert pseudo-articles when decoding articles."
544 :group 'gnus-extract-view
547 (defcustom gnus-summary-dummy-line-format
549 "*The format specification for the dummy roots in the summary buffer.
550 It works along the same lines as a normal formatting string,
551 with some simple extensions.
554 :group 'gnus-threading
557 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
558 "*The format specification for the summary mode line.
559 It works along the same lines as a normal formatting string,
560 with some simple extensions:
563 %p Unprefixed group name
564 %A Current article number
565 %z Current article score
567 %U Number of unread articles in the group
568 %e Number of unselected articles in the group
569 %Z A string with unread/unselected article counts
570 %g Shortish group name
571 %S Subject of the current article
573 %s Current score file name
574 %d Number of dormant articles
575 %r Number of articles that have been marked as read in this session
576 %E Number of articles expunged by the score files"
577 :group 'gnus-summary-format
580 (defcustom gnus-list-identifiers nil
581 "Regexp that matches list identifiers to be removed from subject.
582 This can also be a list of regexps."
583 :group 'gnus-summary-format
584 :group 'gnus-article-hiding
585 :type '(choice (const :tag "none" nil)
587 (repeat :value (".*") regexp)))
589 (defcustom gnus-summary-mark-below 0
590 "*Mark all articles with a score below this variable as read.
591 This variable is local to each summary buffer and usually set by the
593 :group 'gnus-score-default
596 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
597 "*List of functions used for sorting articles in the summary buffer.
598 This variable is only used when not using a threaded display."
599 :group 'gnus-summary-sort
600 :type '(repeat (choice (function-item gnus-article-sort-by-number)
601 (function-item gnus-article-sort-by-author)
602 (function-item gnus-article-sort-by-subject)
603 (function-item gnus-article-sort-by-date)
604 (function-item gnus-article-sort-by-score)
605 (function :tag "other"))))
607 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
608 "*List of functions used for sorting threads in the summary buffer.
609 By default, threads are sorted by article number.
611 Each function takes two threads and return non-nil if the first thread
612 should be sorted before the other. If you use more than one function,
613 the primary sort function should be the last. You should probably
614 always include `gnus-thread-sort-by-number' in the list of sorting
615 functions -- preferably first.
617 Ready-made functions include `gnus-thread-sort-by-number',
618 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
619 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
620 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
621 :group 'gnus-summary-sort
622 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
623 (function-item gnus-thread-sort-by-author)
624 (function-item gnus-thread-sort-by-subject)
625 (function-item gnus-thread-sort-by-date)
626 (function-item gnus-thread-sort-by-score)
627 (function-item gnus-thread-sort-by-total-score)
628 (function :tag "other"))))
630 (defcustom gnus-thread-score-function '+
631 "*Function used for calculating the total score of a thread.
633 The function is called with the scores of the article and each
634 subthread and should then return the score of the thread.
636 Some functions you can use are `+', `max', or `min'."
637 :group 'gnus-summary-sort
640 (defcustom gnus-summary-expunge-below nil
641 "All articles that have a score less than this variable will be expunged.
642 This variable is local to the summary buffers."
643 :group 'gnus-score-default
644 :type '(choice (const :tag "off" nil)
647 (defcustom gnus-thread-expunge-below nil
648 "All threads that have a total score less than this variable will be expunged.
649 See `gnus-thread-score-function' for en explanation of what a
652 This variable is local to the summary buffers."
653 :group 'gnus-threading
654 :group 'gnus-score-default
655 :type '(choice (const :tag "off" nil)
658 (defcustom gnus-summary-mode-hook nil
659 "*A hook for Gnus summary mode.
660 This hook is run before any variables are set in the summary buffer."
661 :group 'gnus-summary-various
664 (defcustom gnus-summary-menu-hook nil
665 "*Hook run after the creation of the summary mode menu."
666 :group 'gnus-summary-visual
669 (defcustom gnus-summary-exit-hook nil
670 "*A hook called on exit from the summary buffer.
671 It will be called with point in the group buffer."
672 :group 'gnus-summary-exit
675 (defcustom gnus-summary-prepare-hook nil
676 "*A hook called after the summary buffer has been generated.
677 If you want to modify the summary buffer, you can use this hook."
678 :group 'gnus-summary-various
681 (defcustom gnus-summary-prepared-hook nil
682 "*A hook called as the last thing after the summary buffer has been generated."
683 :group 'gnus-summary-various
686 (defcustom gnus-summary-generate-hook nil
687 "*A hook run just before generating the summary buffer.
688 This hook is commonly used to customize threading variables and the
690 :group 'gnus-summary-various
693 (defcustom gnus-select-group-hook nil
694 "*A hook called when a newsgroup is selected.
696 If you'd like to simplify subjects like the
697 `gnus-summary-next-same-subject' command does, you can use the
700 (setq gnus-select-group-hook
703 (mapcar (lambda (header)
704 (mail-header-set-subject
706 (gnus-simplify-subject
707 (mail-header-subject header) 're-only)))
708 gnus-newsgroup-headers))))"
709 :group 'gnus-group-select
712 (defcustom gnus-select-article-hook nil
713 "*A hook called when an article is selected."
714 :group 'gnus-summary-choose
717 (defcustom gnus-visual-mark-article-hook
718 (list 'gnus-highlight-selected-summary)
719 "*Hook run after selecting an article in the summary buffer.
720 It is meant to be used for highlighting the article in some way. It
721 is not run if `gnus-visual' is nil."
722 :group 'gnus-summary-visual
725 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
726 "*A hook called before parsing the headers."
730 (defcustom gnus-exit-group-hook nil
731 "*A hook called when exiting summary mode.
732 This hook is not called from the non-updating exit commands like `Q'."
736 (defcustom gnus-summary-update-hook
737 (list 'gnus-summary-highlight-line)
738 "*A hook called when a summary line is changed.
739 The hook will not be called if `gnus-visual' is nil.
741 The default function `gnus-summary-highlight-line' will
742 highlight the line according to the `gnus-summary-highlight'
744 :group 'gnus-summary-visual
747 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
748 "*A hook called when an article is selected for the first time.
749 The hook is intended to mark an article as read (or unread)
750 automatically when it is selected."
751 :group 'gnus-summary-choose
754 (defcustom gnus-group-no-more-groups-hook nil
755 "*A hook run when returning to group mode having no more (unread) groups."
756 :group 'gnus-group-select
759 (defcustom gnus-ps-print-hook nil
760 "*A hook run before ps-printing something from Gnus."
764 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
765 "Face used for highlighting the current article in the summary buffer."
766 :group 'gnus-summary-visual
769 (defcustom gnus-summary-highlight
770 '(((= mark gnus-canceled-mark)
771 . gnus-summary-cancelled-face)
772 ((and (> score default)
773 (or (= mark gnus-dormant-mark)
774 (= mark gnus-ticked-mark)))
775 . gnus-summary-high-ticked-face)
776 ((and (< score default)
777 (or (= mark gnus-dormant-mark)
778 (= mark gnus-ticked-mark)))
779 . gnus-summary-low-ticked-face)
780 ((or (= mark gnus-dormant-mark)
781 (= mark gnus-ticked-mark))
782 . gnus-summary-normal-ticked-face)
783 ((and (> score default) (= mark gnus-ancient-mark))
784 . gnus-summary-high-ancient-face)
785 ((and (< score default) (= mark gnus-ancient-mark))
786 . gnus-summary-low-ancient-face)
787 ((= mark gnus-ancient-mark)
788 . gnus-summary-normal-ancient-face)
789 ((and (> score default) (= mark gnus-unread-mark))
790 . gnus-summary-high-unread-face)
791 ((and (< score default) (= mark gnus-unread-mark))
792 . gnus-summary-low-unread-face)
793 ((and (memq article gnus-newsgroup-incorporated)
794 (= mark gnus-unread-mark))
795 . gnus-summary-incorporated-face)
796 ((= mark gnus-unread-mark)
797 . gnus-summary-normal-unread-face)
798 ((and (> score default) (memq mark (list gnus-downloadable-mark
799 gnus-undownloaded-mark)))
800 . gnus-summary-high-unread-face)
801 ((and (< score default) (memq mark (list gnus-downloadable-mark
802 gnus-undownloaded-mark)))
803 . gnus-summary-low-unread-face)
804 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
805 . gnus-summary-normal-unread-face)
807 . gnus-summary-high-read-face)
809 . gnus-summary-low-read-face)
811 . gnus-summary-normal-read-face))
812 "*Controls the highlighting of summary buffer lines.
814 A list of (FORM . FACE) pairs. When deciding how a a particular
815 summary line should be displayed, each form is evaluated. The content
816 of the face field after the first true form is used. You can change
817 how those summary lines are displayed, by editing the face field.
819 You can use the following variables in the FORM field.
821 score: The articles score
822 default: The default article score.
823 below: The score below which articles are automatically marked as read.
824 mark: The articles mark."
825 :group 'gnus-summary-visual
826 :type '(repeat (cons (sexp :tag "Form" nil)
829 (defcustom gnus-alter-header-function nil
830 "Function called to allow alteration of article header structures.
831 The function is called with one parameter, the article header vector,
832 which it may alter in any way.")
834 (defvar gnus-decode-encoded-word-function
835 (mime-find-field-decoder 'From 'nov)
836 "Variable that says which function should be used to decode a string with encoded words.")
838 (defcustom gnus-extra-headers nil
839 "*Extra headers to parse."
841 :type '(repeat symbol))
843 (defcustom gnus-ignored-from-addresses
844 (and user-mail-address (regexp-quote user-mail-address))
845 "*Regexp of From headers that may be suppressed in favor of To headers."
849 (defcustom gnus-group-charset-alist
850 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
851 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
852 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
853 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
854 ("^relcom\\>" koi8-r)
856 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
857 ("^israel\\>" iso-8859-1)
859 ("^alt.chinese.text.big5\\>" chinese-big5)
860 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
861 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
863 "Alist of regexps (to match group names) and default charsets to be used when reading."
864 :type '(repeat (list (regexp :tag "Group")
865 (symbol :tag "Charset")))
866 :group 'gnus-charset)
868 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
869 "List of charsets that should be ignored.
870 When these charsets are used in the \"charset\" parameter, the
871 default charset will be used instead."
872 :type '(repeat symbol)
873 :group 'gnus-charset)
875 (defcustom gnus-group-ignored-charsets-alist
876 '(("alt\\.chinese\\.text" iso-8859-1))
877 "Alist of regexps (to match group names) and charsets that should be ignored.
878 When these charsets are used in the \"charset\" parameter, the
879 default charset will be used instead."
880 :type '(repeat (cons (regexp :tag "Group")
882 :group 'gnus-charset)
884 (defcustom gnus-group-highlight-words-alist nil
885 "Alist of group regexps and highlight regexps.
886 This variable uses the same syntax as `gnus-emphasis-alist'."
887 :type '(repeat (cons (regexp :tag "Group")
888 (repeat (list (regexp :tag "Highlight regexp")
889 (number :tag "Group for entire word" 0)
890 (number :tag "Group for displayed part" 0)
892 gnus-emphasis-highlight-words)))))
893 :group 'gnus-summary-visual)
895 (defcustom gnus-use-wheel nil
896 "Use Intelli-mouse on summary movement"
898 :group 'gnus-summary-maneuvering)
900 (defcustom gnus-wheel-scroll-amount '(5 . 1)
901 "Amount to scroll messages by spinning the mouse wheel.
902 This is actually a cons cell, where the first item is the amount to scroll
903 on a normal wheel event, and the second is the amount to scroll when the
904 wheel is moved with the shift key depressed."
905 :type '(cons (integer :tag "Shift") integer)
906 :group 'gnus-summary-maneuvering)
908 (defcustom gnus-wheel-edge-resistance 2
909 "How hard it should be to change the current article
910 by moving the mouse over the edge of the article window."
912 :group 'gnus-summary-maneuvering)
914 (defcustom gnus-summary-show-article-charset-alist
916 "Alist of number and charset.
917 The article will be shown with the charset corresponding to the
919 For example: ((1 . cn-gb-2312) (2 . big5))."
920 :type '(repeat (cons (number :tag "Argument" 1)
921 (symbol :tag "Charset")))
922 :group 'gnus-charset)
924 (defcustom gnus-preserve-marks t
925 "Whether marks are preserved when moving, copying and respooling messages."
927 :group 'gnus-summary-marks)
929 (defcustom gnus-alter-articles-to-read-function nil
930 "Function to be called to alter the list of articles to be selected."
932 :group 'gnus-summary)
934 (defcustom gnus-orphan-score nil
935 "*All orphans get this score added. Set in the score file."
936 :group 'gnus-score-default
937 :type '(choice (const nil)
940 (defcustom gnus-summary-save-parts-default-mime "image/.*"
941 "*A regexp to match MIME parts when saving multiple parts of a message
942 with gnus-summary-save-parts (X m). This regexp will be used by default
943 when prompting the user for which type of files to save."
948 ;;; Internal variables
950 (defvar gnus-article-mime-handles nil)
951 (defvar gnus-article-decoded-p nil)
952 (defvar gnus-article-charset nil)
953 (defvar gnus-article-ignored-charsets nil)
954 (defvar gnus-scores-exclude-files nil)
955 (defvar gnus-page-broken nil)
956 (defvar gnus-inhibit-mime-unbuttonizing nil)
958 (defvar gnus-original-article nil)
959 (defvar gnus-article-internal-prepare-hook nil)
960 (defvar gnus-newsgroup-process-stack nil)
962 (defvar gnus-thread-indent-array nil)
963 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
964 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
965 "Function called to sort the articles within a thread after it has been gathered together.")
967 (defvar gnus-summary-save-parts-type-history nil)
968 (defvar gnus-summary-save-parts-last-directory nil)
970 ;; Avoid highlighting in kill files.
971 (defvar gnus-summary-inhibit-highlight nil)
972 (defvar gnus-newsgroup-selected-overlay nil)
973 (defvar gnus-inhibit-limiting nil)
974 (defvar gnus-newsgroup-adaptive-score-file nil)
975 (defvar gnus-current-score-file nil)
976 (defvar gnus-current-move-group nil)
977 (defvar gnus-current-copy-group nil)
978 (defvar gnus-current-crosspost-group nil)
980 (defvar gnus-newsgroup-dependencies nil)
981 (defvar gnus-newsgroup-adaptive nil)
982 (defvar gnus-summary-display-article-function nil)
983 (defvar gnus-summary-highlight-line-function nil
984 "Function called after highlighting a summary line.")
986 (defvar gnus-summary-line-format-alist
987 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
988 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
989 (?s gnus-tmp-subject-or-nil ?s)
990 (?n gnus-tmp-name ?s)
991 (?A (std11-address-string
992 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
993 (?a (or (std11-full-name-string
994 (car (mime-entity-read-field gnus-tmp-header 'From)))
996 (?F gnus-tmp-from ?s)
997 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
998 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
999 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1000 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1001 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1002 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1003 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1004 (?L gnus-tmp-lines ?d)
1005 (?I gnus-tmp-indentation ?s)
1006 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1007 (?R gnus-tmp-replied ?c)
1008 (?\[ gnus-tmp-opening-bracket ?c)
1009 (?\] gnus-tmp-closing-bracket ?c)
1010 (?\> (make-string gnus-tmp-level ? ) ?s)
1011 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1012 (?i gnus-tmp-score ?d)
1013 (?z gnus-tmp-score-char ?c)
1014 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1015 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1016 (?U gnus-tmp-unread ?c)
1017 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1018 (?t (gnus-summary-number-of-articles-in-thread
1019 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1021 (?e (gnus-summary-number-of-articles-in-thread
1022 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1024 (?u gnus-tmp-user-defined ?s)
1025 (?P (gnus-pick-line-number) ?d))
1026 "An alist of format specifications that can appear in summary lines.
1027 These are paired with what variables they correspond with, along with
1028 the type of the variable (string, integer, character, etc).")
1030 (defvar gnus-summary-dummy-line-format-alist
1031 `((?S gnus-tmp-subject ?s)
1032 (?N gnus-tmp-number ?d)
1033 (?u gnus-tmp-user-defined ?s)))
1035 (defvar gnus-summary-mode-line-format-alist
1036 `((?G gnus-tmp-group-name ?s)
1037 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1038 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1039 (?A gnus-tmp-article-number ?d)
1040 (?Z gnus-tmp-unread-and-unselected ?s)
1041 (?V gnus-version ?s)
1042 (?U gnus-tmp-unread-and-unticked ?d)
1043 (?S gnus-tmp-subject ?s)
1044 (?e gnus-tmp-unselected ?d)
1045 (?u gnus-tmp-user-defined ?s)
1046 (?d (length gnus-newsgroup-dormant) ?d)
1047 (?t (length gnus-newsgroup-marked) ?d)
1048 (?r (length gnus-newsgroup-reads) ?d)
1049 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1050 (?E gnus-newsgroup-expunged-tally ?d)
1051 (?s (gnus-current-score-file-nondirectory) ?s)))
1053 (defvar gnus-last-search-regexp nil
1054 "Default regexp for article search command.")
1056 (defvar gnus-summary-search-article-matched-data nil
1057 "Last matched data of article search command. It is the local variable
1058 in `gnus-article-buffer' which consists of the list of start position,
1059 end position and text.")
1061 (defvar gnus-last-shell-command nil
1062 "Default shell command on article.")
1064 (defvar gnus-newsgroup-begin nil)
1065 (defvar gnus-newsgroup-end nil)
1066 (defvar gnus-newsgroup-last-rmail nil)
1067 (defvar gnus-newsgroup-last-mail nil)
1068 (defvar gnus-newsgroup-last-folder nil)
1069 (defvar gnus-newsgroup-last-file nil)
1070 (defvar gnus-newsgroup-auto-expire nil)
1071 (defvar gnus-newsgroup-active nil)
1073 (defvar gnus-newsgroup-data nil)
1074 (defvar gnus-newsgroup-data-reverse nil)
1075 (defvar gnus-newsgroup-limit nil)
1076 (defvar gnus-newsgroup-limits nil)
1078 (defvar gnus-newsgroup-unreads nil
1079 "List of unread articles in the current newsgroup.")
1081 (defvar gnus-newsgroup-unselected nil
1082 "List of unselected unread articles in the current newsgroup.")
1084 (defvar gnus-newsgroup-reads nil
1085 "Alist of read articles and article marks in the current newsgroup.")
1087 (defvar gnus-newsgroup-expunged-tally nil)
1089 (defvar gnus-newsgroup-marked nil
1090 "List of ticked articles in the current newsgroup (a subset of unread art).")
1092 (defvar gnus-newsgroup-killed nil
1093 "List of ranges of articles that have been through the scoring process.")
1095 (defvar gnus-newsgroup-cached nil
1096 "List of articles that come from the article cache.")
1098 (defvar gnus-newsgroup-saved nil
1099 "List of articles that have been saved.")
1101 (defvar gnus-newsgroup-kill-headers nil)
1103 (defvar gnus-newsgroup-replied nil
1104 "List of articles that have been replied to in the current newsgroup.")
1106 (defvar gnus-newsgroup-expirable nil
1107 "List of articles in the current newsgroup that can be expired.")
1109 (defvar gnus-newsgroup-processable nil
1110 "List of articles in the current newsgroup that can be processed.")
1112 (defvar gnus-newsgroup-downloadable nil
1113 "List of articles in the current newsgroup that can be processed.")
1115 (defvar gnus-newsgroup-undownloaded nil
1116 "List of articles in the current newsgroup that haven't been downloaded..")
1118 (defvar gnus-newsgroup-unsendable nil
1119 "List of articles in the current newsgroup that won't be sent.")
1121 (defvar gnus-newsgroup-bookmarks nil
1122 "List of articles in the current newsgroup that have bookmarks.")
1124 (defvar gnus-newsgroup-dormant nil
1125 "List of dormant articles in the current newsgroup.")
1127 (defvar gnus-newsgroup-scored nil
1128 "List of scored articles in the current newsgroup.")
1130 (defvar gnus-newsgroup-incorporated nil
1131 "List of incorporated articles in the current newsgroup.")
1133 (defvar gnus-newsgroup-headers nil
1134 "List of article headers in the current newsgroup.")
1136 (defvar gnus-newsgroup-threads nil)
1138 (defvar gnus-newsgroup-prepared nil
1139 "Whether the current group has been prepared properly.")
1141 (defvar gnus-newsgroup-ancient nil
1142 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1144 (defvar gnus-newsgroup-sparse nil)
1146 (defvar gnus-current-article nil)
1147 (defvar gnus-article-current nil)
1148 (defvar gnus-current-headers nil)
1149 (defvar gnus-have-all-headers nil)
1150 (defvar gnus-last-article nil)
1151 (defvar gnus-newsgroup-history nil)
1152 (defvar gnus-newsgroup-charset nil)
1153 (defvar gnus-newsgroup-ephemeral-charset nil)
1154 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1156 (defvar gnus-article-before-search nil)
1158 (defconst gnus-summary-local-variables
1159 '(gnus-newsgroup-name
1160 gnus-newsgroup-begin gnus-newsgroup-end
1161 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1162 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1163 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1164 gnus-newsgroup-unselected gnus-newsgroup-marked
1165 gnus-newsgroup-reads gnus-newsgroup-saved
1166 gnus-newsgroup-replied gnus-newsgroup-expirable
1167 gnus-newsgroup-processable gnus-newsgroup-killed
1168 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1169 gnus-newsgroup-unsendable
1170 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1171 gnus-newsgroup-headers gnus-newsgroup-threads
1172 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1173 gnus-current-article gnus-current-headers gnus-have-all-headers
1174 gnus-last-article gnus-article-internal-prepare-hook
1175 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1176 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1177 gnus-thread-expunge-below
1178 gnus-score-alist gnus-current-score-file
1179 (gnus-summary-expunge-below . global)
1180 (gnus-summary-mark-below . global)
1181 (gnus-orphan-score . global)
1182 gnus-newsgroup-active gnus-scores-exclude-files
1183 gnus-newsgroup-history gnus-newsgroup-ancient
1184 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1185 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1186 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1187 (gnus-newsgroup-expunged-tally . 0)
1188 gnus-cache-removable-articles gnus-newsgroup-cached
1189 gnus-newsgroup-data gnus-newsgroup-data-reverse
1190 gnus-newsgroup-limit gnus-newsgroup-limits
1191 gnus-newsgroup-charset
1192 gnus-newsgroup-incorporated)
1193 "Variables that are buffer-local to the summary buffers.")
1195 (defvar gnus-newsgroup-variables nil
1196 "Variables that have separate values in the newsgroups.")
1198 ;; Byte-compiler warning.
1199 (defvar gnus-article-mode-map)
1201 ;; Subject simplification.
1203 (defun gnus-simplify-whitespace (str)
1204 "Remove excessive whitespace from STR."
1207 (while (string-match "[ \t][ \t]+" mystr)
1208 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1210 (substring mystr (match-end 0)))))
1212 (when (string-match "^[ \t]+" mystr)
1213 (setq mystr (substring mystr (match-end 0))))
1215 (when (string-match "[ \t]+$" mystr)
1216 (setq mystr (substring mystr 0 (match-beginning 0))))
1219 (defsubst gnus-simplify-subject-re (subject)
1220 "Remove \"Re:\" from subject lines."
1221 (if (string-match "^[Rr][Ee]: *" subject)
1222 (substring subject (match-end 0))
1225 (defun gnus-simplify-subject (subject &optional re-only)
1226 "Remove `Re:' and words in parentheses.
1227 If RE-ONLY is non-nil, strip leading `Re:'s only."
1228 (let ((case-fold-search t)) ;Ignore case.
1229 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1230 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1231 (setq subject (substring subject (match-end 0))))
1232 ;; Remove uninteresting prefixes.
1233 (when (and (not re-only)
1234 gnus-simplify-ignored-prefixes
1235 (string-match gnus-simplify-ignored-prefixes subject))
1236 (setq subject (substring subject (match-end 0))))
1237 ;; Remove words in parentheses from end.
1239 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1240 (setq subject (substring subject 0 (match-beginning 0)))))
1241 ;; Return subject string.
1244 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1246 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1247 (goto-char (point-min))
1248 (while (re-search-forward regexp nil t)
1249 (replace-match (or newtext ""))))
1251 (defun gnus-simplify-buffer-fuzzy ()
1252 "Simplify string in the buffer fuzzily.
1253 The string in the accessible portion of the current buffer is simplified.
1254 It is assumed to be a single-line subject.
1255 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1256 matter is removed. Additional things can be deleted by setting
1257 `gnus-simplify-subject-fuzzy-regexp'."
1258 (let ((case-fold-search t)
1260 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1262 (while (not (eq modified-tick (buffer-modified-tick)))
1263 (setq modified-tick (buffer-modified-tick))
1265 ((listp gnus-simplify-subject-fuzzy-regexp)
1266 (mapcar 'gnus-simplify-buffer-fuzzy-step
1267 gnus-simplify-subject-fuzzy-regexp))
1268 (gnus-simplify-subject-fuzzy-regexp
1269 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1270 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1271 (gnus-simplify-buffer-fuzzy-step
1272 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1273 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1275 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1276 (gnus-simplify-buffer-fuzzy-step " +" " ")
1277 (gnus-simplify-buffer-fuzzy-step " $")
1278 (gnus-simplify-buffer-fuzzy-step "^ +")))
1280 (defun gnus-simplify-subject-fuzzy (subject)
1281 "Simplify a subject string fuzzily.
1282 See `gnus-simplify-buffer-fuzzy' for details."
1284 (gnus-set-work-buffer)
1285 (let ((case-fold-search t))
1286 ;; Remove uninteresting prefixes.
1287 (when (and gnus-simplify-ignored-prefixes
1288 (string-match gnus-simplify-ignored-prefixes subject))
1289 (setq subject (substring subject (match-end 0))))
1291 (inline (gnus-simplify-buffer-fuzzy))
1294 (defsubst gnus-simplify-subject-fully (subject)
1295 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1297 (gnus-simplify-subject-functions
1298 (gnus-map-function gnus-simplify-subject-functions subject))
1299 ((null gnus-summary-gather-subject-limit)
1300 (gnus-simplify-subject-re subject))
1301 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1302 (gnus-simplify-subject-fuzzy subject))
1303 ((numberp gnus-summary-gather-subject-limit)
1304 (gnus-limit-string (gnus-simplify-subject-re subject)
1305 gnus-summary-gather-subject-limit))
1309 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1310 "Check whether two subjects are equal.
1311 If optional argument simple-first is t, first argument is already
1314 ((null simple-first)
1315 (equal (gnus-simplify-subject-fully s1)
1316 (gnus-simplify-subject-fully s2)))
1319 (gnus-simplify-subject-fully s2)))))
1321 (defun gnus-summary-bubble-group ()
1322 "Increase the score of the current group.
1323 This is a handy function to add to `gnus-summary-exit-hook' to
1324 increase the score of each group you read."
1325 (gnus-group-add-score gnus-newsgroup-name))
1329 ;;; Gnus summary mode
1332 (put 'gnus-summary-mode 'mode-class 'special)
1335 ;; Non-orthogonal keys
1337 (gnus-define-keys gnus-summary-mode-map
1338 " " gnus-summary-next-page
1339 "\177" gnus-summary-prev-page
1340 [delete] gnus-summary-prev-page
1341 [backspace] gnus-summary-prev-page
1342 "\r" gnus-summary-scroll-up
1343 "\M-\r" gnus-summary-scroll-down
1344 "n" gnus-summary-next-unread-article
1345 "p" gnus-summary-prev-unread-article
1346 "N" gnus-summary-next-article
1347 "P" gnus-summary-prev-article
1348 "\M-\C-n" gnus-summary-next-same-subject
1349 "\M-\C-p" gnus-summary-prev-same-subject
1350 "\M-n" gnus-summary-next-unread-subject
1351 "\M-p" gnus-summary-prev-unread-subject
1352 "." gnus-summary-first-unread-article
1353 "," gnus-summary-best-unread-article
1354 "\M-s" gnus-summary-search-article-forward
1355 "\M-r" gnus-summary-search-article-backward
1356 "<" gnus-summary-beginning-of-article
1357 ">" gnus-summary-end-of-article
1358 "j" gnus-summary-goto-article
1359 "^" gnus-summary-refer-parent-article
1360 "\M-^" gnus-summary-refer-article
1361 "u" gnus-summary-tick-article-forward
1362 "!" gnus-summary-tick-article-forward
1363 "U" gnus-summary-tick-article-backward
1364 "d" gnus-summary-mark-as-read-forward
1365 "D" gnus-summary-mark-as-read-backward
1366 "E" gnus-summary-mark-as-expirable
1367 "\M-u" gnus-summary-clear-mark-forward
1368 "\M-U" gnus-summary-clear-mark-backward
1369 "k" gnus-summary-kill-same-subject-and-select
1370 "\C-k" gnus-summary-kill-same-subject
1371 "\M-\C-k" gnus-summary-kill-thread
1372 "\M-\C-l" gnus-summary-lower-thread
1373 "e" gnus-summary-edit-article
1374 "#" gnus-summary-mark-as-processable
1375 "\M-#" gnus-summary-unmark-as-processable
1376 "\M-\C-t" gnus-summary-toggle-threads
1377 "\M-\C-s" gnus-summary-show-thread
1378 "\M-\C-h" gnus-summary-hide-thread
1379 "\M-\C-f" gnus-summary-next-thread
1380 "\M-\C-b" gnus-summary-prev-thread
1381 [(meta down)] gnus-summary-next-thread
1382 [(meta up)] gnus-summary-prev-thread
1383 "\M-\C-u" gnus-summary-up-thread
1384 "\M-\C-d" gnus-summary-down-thread
1385 "&" gnus-summary-execute-command
1386 "c" gnus-summary-catchup-and-exit
1387 "\C-w" gnus-summary-mark-region-as-read
1388 "\C-t" gnus-summary-toggle-truncation
1389 "?" gnus-summary-mark-as-dormant
1390 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1391 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1392 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1393 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1394 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1395 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1396 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1397 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1398 "=" gnus-summary-expand-window
1399 "\C-x\C-s" gnus-summary-reselect-current-group
1400 "\M-g" gnus-summary-rescan-group
1401 "w" gnus-summary-stop-page-breaking
1402 "\C-c\C-r" gnus-summary-caesar-message
1403 "\M-t" gnus-summary-toggle-mime
1404 "f" gnus-summary-followup
1405 "F" gnus-summary-followup-with-original
1406 "C" gnus-summary-cancel-article
1407 "r" gnus-summary-reply
1408 "R" gnus-summary-reply-with-original
1409 "\C-c\C-f" gnus-summary-mail-forward
1410 "o" gnus-summary-save-article
1411 "\C-o" gnus-summary-save-article-mail
1412 "|" gnus-summary-pipe-output
1413 "\M-k" gnus-summary-edit-local-kill
1414 "\M-K" gnus-summary-edit-global-kill
1416 "\C-c\C-d" gnus-summary-describe-group
1417 "q" gnus-summary-exit
1418 "Q" gnus-summary-exit-no-update
1419 "\C-c\C-i" gnus-info-find-node
1420 gnus-mouse-2 gnus-mouse-pick-article
1421 "m" gnus-summary-mail-other-window
1422 "a" gnus-summary-post-news
1423 "x" gnus-summary-limit-to-unread
1424 "s" gnus-summary-isearch-article
1425 "t" gnus-article-toggle-headers
1426 "g" gnus-summary-show-article
1427 "l" gnus-summary-goto-last-article
1428 "v" gnus-summary-preview-mime-message
1429 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1430 "\C-d" gnus-summary-enter-digest-group
1431 "\M-\C-d" gnus-summary-read-document
1432 "\M-\C-e" gnus-summary-edit-parameters
1433 "\M-\C-a" gnus-summary-customize-parameters
1435 "*" gnus-cache-enter-article
1436 "\M-*" gnus-cache-remove-article
1437 "\M-&" gnus-summary-universal-argument
1438 "\C-l" gnus-recenter
1439 "I" gnus-summary-increase-score
1440 "L" gnus-summary-lower-score
1441 "\M-i" gnus-symbolic-argument
1442 "h" gnus-summary-select-article-buffer
1444 "V" gnus-summary-score-map
1445 "X" gnus-uu-extract-map
1446 "S" gnus-summary-send-map)
1448 ;; Sort of orthogonal keymap
1449 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1450 "t" gnus-summary-tick-article-forward
1451 "!" gnus-summary-tick-article-forward
1452 "d" gnus-summary-mark-as-read-forward
1453 "r" gnus-summary-mark-as-read-forward
1454 "c" gnus-summary-clear-mark-forward
1455 " " gnus-summary-clear-mark-forward
1456 "e" gnus-summary-mark-as-expirable
1457 "x" gnus-summary-mark-as-expirable
1458 "?" gnus-summary-mark-as-dormant
1459 "b" gnus-summary-set-bookmark
1460 "B" gnus-summary-remove-bookmark
1461 "#" gnus-summary-mark-as-processable
1462 "\M-#" gnus-summary-unmark-as-processable
1463 "S" gnus-summary-limit-include-expunged
1464 "C" gnus-summary-catchup
1465 "H" gnus-summary-catchup-to-here
1466 "\C-c" gnus-summary-catchup-all
1467 "k" gnus-summary-kill-same-subject-and-select
1468 "K" gnus-summary-kill-same-subject
1469 "P" gnus-uu-mark-map)
1471 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1472 "c" gnus-summary-clear-above
1473 "u" gnus-summary-tick-above
1474 "m" gnus-summary-mark-above
1475 "k" gnus-summary-kill-below)
1477 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1478 "/" gnus-summary-limit-to-subject
1479 "n" gnus-summary-limit-to-articles
1480 "w" gnus-summary-pop-limit
1481 "s" gnus-summary-limit-to-subject
1482 "a" gnus-summary-limit-to-author
1483 "u" gnus-summary-limit-to-unread
1484 "m" gnus-summary-limit-to-marks
1485 "M" gnus-summary-limit-exclude-marks
1486 "v" gnus-summary-limit-to-score
1487 "*" gnus-summary-limit-include-cached
1488 "D" gnus-summary-limit-include-dormant
1489 "T" gnus-summary-limit-include-thread
1490 "d" gnus-summary-limit-exclude-dormant
1491 "t" gnus-summary-limit-to-age
1492 "x" gnus-summary-limit-to-extra
1493 "E" gnus-summary-limit-include-expunged
1494 "c" gnus-summary-limit-exclude-childless-dormant
1495 "C" gnus-summary-limit-mark-excluded-as-read)
1497 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1498 "n" gnus-summary-next-unread-article
1499 "p" gnus-summary-prev-unread-article
1500 "N" gnus-summary-next-article
1501 "P" gnus-summary-prev-article
1502 "\C-n" gnus-summary-next-same-subject
1503 "\C-p" gnus-summary-prev-same-subject
1504 "\M-n" gnus-summary-next-unread-subject
1505 "\M-p" gnus-summary-prev-unread-subject
1506 "f" gnus-summary-first-unread-article
1507 "b" gnus-summary-best-unread-article
1508 "j" gnus-summary-goto-article
1509 "g" gnus-summary-goto-subject
1510 "l" gnus-summary-goto-last-article
1511 "o" gnus-summary-pop-article)
1513 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1514 "k" gnus-summary-kill-thread
1515 "l" gnus-summary-lower-thread
1516 "i" gnus-summary-raise-thread
1517 "T" gnus-summary-toggle-threads
1518 "t" gnus-summary-rethread-current
1519 "^" gnus-summary-reparent-thread
1520 "s" gnus-summary-show-thread
1521 "S" gnus-summary-show-all-threads
1522 "h" gnus-summary-hide-thread
1523 "H" gnus-summary-hide-all-threads
1524 "n" gnus-summary-next-thread
1525 "p" gnus-summary-prev-thread
1526 "u" gnus-summary-up-thread
1527 "o" gnus-summary-top-thread
1528 "d" gnus-summary-down-thread
1529 "#" gnus-uu-mark-thread
1530 "\M-#" gnus-uu-unmark-thread)
1532 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1533 "g" gnus-summary-prepare
1534 "c" gnus-summary-insert-cached-articles)
1536 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1537 "c" gnus-summary-catchup-and-exit
1538 "C" gnus-summary-catchup-all-and-exit
1539 "E" gnus-summary-exit-no-update
1540 "J" gnus-summary-jump-to-other-group
1541 "Q" gnus-summary-exit
1542 "Z" gnus-summary-exit
1543 "n" gnus-summary-catchup-and-goto-next-group
1544 "R" gnus-summary-reselect-current-group
1545 "G" gnus-summary-rescan-group
1546 "N" gnus-summary-next-group
1547 "s" gnus-summary-save-newsrc
1548 "P" gnus-summary-prev-group)
1550 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1551 " " gnus-summary-next-page
1552 "n" gnus-summary-next-page
1553 "\177" gnus-summary-prev-page
1554 [delete] gnus-summary-prev-page
1555 "p" gnus-summary-prev-page
1556 "\r" gnus-summary-scroll-up
1557 "\M-\r" gnus-summary-scroll-down
1558 "<" gnus-summary-beginning-of-article
1559 ">" gnus-summary-end-of-article
1560 "b" gnus-summary-beginning-of-article
1561 "e" gnus-summary-end-of-article
1562 "^" gnus-summary-refer-parent-article
1563 "r" gnus-summary-refer-parent-article
1564 "D" gnus-summary-enter-digest-group
1565 "R" gnus-summary-refer-references
1566 "T" gnus-summary-refer-thread
1567 "g" gnus-summary-show-article
1568 "s" gnus-summary-isearch-article
1569 "P" gnus-summary-print-article
1570 "t" gnus-article-babel
1571 "d" gnus-summary-decrypt-article
1572 "v" gnus-summary-verify-article)
1574 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1575 "b" gnus-article-add-buttons
1576 "B" gnus-article-add-buttons-to-head
1577 "o" gnus-article-treat-overstrike
1578 "e" gnus-article-emphasize
1579 "w" gnus-article-fill-cited-article
1580 "Q" gnus-article-fill-long-lines
1581 "C" gnus-article-capitalize-sentences
1582 "c" gnus-article-remove-cr
1583 "Z" gnus-article-decode-HZ
1584 "f" gnus-article-display-x-face
1585 "l" gnus-summary-stop-page-breaking
1586 "r" gnus-summary-caesar-message
1587 "t" gnus-article-toggle-headers
1588 "v" gnus-summary-verbose-headers
1589 "m" gnus-summary-toggle-mime
1590 "H" gnus-article-strip-headers-in-body
1591 "d" gnus-article-treat-dumbquotes
1592 "s" gnus-smiley-display)
1594 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1595 "a" gnus-article-hide
1596 "h" gnus-article-toggle-headers
1597 "b" gnus-article-hide-boring-headers
1598 "s" gnus-article-hide-signature
1599 "c" gnus-article-hide-citation
1600 "C" gnus-article-hide-citation-in-followups
1601 "l" gnus-article-hide-list-identifiers
1602 "p" gnus-article-hide-pgp
1603 "B" gnus-article-strip-banner
1604 "P" gnus-article-hide-pem
1605 "\C-c" gnus-article-hide-citation-maybe)
1607 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1608 "a" gnus-article-highlight
1609 "h" gnus-article-highlight-headers
1610 "c" gnus-article-highlight-citation
1611 "s" gnus-article-highlight-signature)
1613 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1614 "z" gnus-article-date-ut
1615 "u" gnus-article-date-ut
1616 "l" gnus-article-date-local
1617 "e" gnus-article-date-lapsed
1618 "o" gnus-article-date-original
1619 "i" gnus-article-date-iso8601
1620 "s" gnus-article-date-user)
1622 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1623 "t" gnus-article-remove-trailing-blank-lines
1624 "l" gnus-article-strip-leading-blank-lines
1625 "m" gnus-article-strip-multiple-blank-lines
1626 "a" gnus-article-strip-blank-lines
1627 "A" gnus-article-strip-all-blank-lines
1628 "s" gnus-article-strip-leading-space
1629 "e" gnus-article-strip-trailing-space)
1631 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1633 "f" gnus-summary-fetch-faq
1634 "d" gnus-summary-describe-group
1635 "h" gnus-summary-describe-briefly
1636 "i" gnus-info-find-node)
1638 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1639 "e" gnus-summary-expire-articles
1640 "\M-\C-e" gnus-summary-expire-articles-now
1641 "\177" gnus-summary-delete-article
1642 [delete] gnus-summary-delete-article
1643 [backspace] gnus-summary-delete-article
1644 "m" gnus-summary-move-article
1645 "r" gnus-summary-respool-article
1646 "w" gnus-summary-edit-article
1647 "c" gnus-summary-copy-article
1648 "B" gnus-summary-crosspost-article
1649 "q" gnus-summary-respool-query
1650 "t" gnus-summary-respool-trace
1651 "i" gnus-summary-import-article
1652 "p" gnus-summary-article-posted-p)
1654 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1655 "o" gnus-summary-save-article
1656 "m" gnus-summary-save-article-mail
1657 "F" gnus-summary-write-article-file
1658 "r" gnus-summary-save-article-rmail
1659 "f" gnus-summary-save-article-file
1660 "b" gnus-summary-save-article-body-file
1661 "h" gnus-summary-save-article-folder
1662 "v" gnus-summary-save-article-vm
1663 "p" gnus-summary-pipe-output
1664 "s" gnus-soup-add-article)
1666 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1667 "b" gnus-summary-display-buttonized
1668 "m" gnus-summary-repair-multipart
1669 "v" gnus-article-view-part
1670 "o" gnus-article-save-part
1671 "c" gnus-article-copy-part
1672 "C" gnus-article-view-part-as-charset
1673 "e" gnus-article-externalize-part
1674 "E" gnus-article-encrypt-body
1675 "i" gnus-article-inline-part
1676 "|" gnus-article-pipe-part))
1678 (defun gnus-summary-make-menu-bar ()
1679 (gnus-turn-off-edit-menu 'summary)
1681 (unless (boundp 'gnus-summary-misc-menu)
1684 gnus-summary-kill-menu gnus-summary-mode-map ""
1689 ["Enter score..." gnus-summary-score-entry t]
1690 ["Customize" gnus-score-customize t])
1691 (gnus-make-score-map 'increase)
1692 (gnus-make-score-map 'lower)
1694 ["Kill below" gnus-summary-kill-below t]
1695 ["Mark above" gnus-summary-mark-above t]
1696 ["Tick above" gnus-summary-tick-above t]
1697 ["Clear above" gnus-summary-clear-above t])
1698 ["Current score" gnus-summary-current-score t]
1699 ["Set score" gnus-summary-set-score t]
1700 ["Switch current score file..." gnus-score-change-score-file t]
1701 ["Set mark below..." gnus-score-set-mark-below t]
1702 ["Set expunge below..." gnus-score-set-expunge-below t]
1703 ["Edit current score file" gnus-score-edit-current-scores t]
1704 ["Edit score file" gnus-score-edit-file t]
1705 ["Trace score" gnus-score-find-trace t]
1706 ["Find words" gnus-score-find-favourite-words t]
1707 ["Rescore buffer" gnus-summary-rescore t]
1708 ["Increase score..." gnus-summary-increase-score t]
1709 ["Lower score..." gnus-summary-lower-score t]))))
1711 ;; Define both the Article menu in the summary buffer and the equivalent
1712 ;; Commands menu in the article buffer here for consistency.
1715 ["All" gnus-article-hide t]
1716 ["Headers" gnus-article-toggle-headers t]
1717 ["Signature" gnus-article-hide-signature t]
1718 ["Citation" gnus-article-hide-citation t]
1719 ["List identifiers" gnus-article-hide-list-identifiers t]
1720 ["PGP" gnus-article-hide-pgp t]
1721 ["Banner" gnus-article-strip-banner t]
1722 ["Boring headers" gnus-article-hide-boring-headers t])
1724 ["All" gnus-article-highlight t]
1725 ["Headers" gnus-article-highlight-headers t]
1726 ["Signature" gnus-article-highlight-signature t]
1727 ["Citation" gnus-article-highlight-citation t])
1729 ["Local" gnus-article-date-local t]
1730 ["ISO8601" gnus-article-date-iso8601 t]
1731 ["UT" gnus-article-date-ut t]
1732 ["Original" gnus-article-date-original t]
1733 ["Lapsed" gnus-article-date-lapsed t]
1734 ["User-defined" gnus-article-date-user t])
1737 ["Leading" gnus-article-strip-leading-blank-lines t]
1738 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1739 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1740 ["All of the above" gnus-article-strip-blank-lines t]
1741 ["All" gnus-article-strip-all-blank-lines t]
1742 ["Leading space" gnus-article-strip-leading-space t]
1743 ["Trailing space" gnus-article-strip-trailing-space t])
1744 ["Overstrike" gnus-article-treat-overstrike t]
1745 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1746 ["Emphasis" gnus-article-emphasize t]
1747 ["Word wrap" gnus-article-fill-cited-article t]
1748 ["Fill long lines" gnus-article-fill-long-lines t]
1749 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1750 ["CR" gnus-article-remove-cr t]
1751 ["Show X-Face" gnus-article-display-x-face t]
1752 ["Rot 13" gnus-summary-caesar-message t]
1753 ["Unix pipe" gnus-summary-pipe-message t]
1754 ["Add buttons" gnus-article-add-buttons t]
1755 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1756 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1757 ["Toggle MIME" gnus-summary-toggle-mime t]
1758 ["Verbose header" gnus-summary-verbose-headers t]
1759 ["Toggle header" gnus-summary-toggle-header t]
1760 ["Toggle smileys" gnus-smiley-display t]
1761 ["HZ" gnus-article-decode-HZ t])
1763 ["Save in default format" gnus-summary-save-article t]
1764 ["Save in file" gnus-summary-save-article-file t]
1765 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1766 ["Save in MH folder" gnus-summary-save-article-folder t]
1767 ["Save in VM folder" gnus-summary-save-article-vm t]
1768 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1769 ["Save body in file" gnus-summary-save-article-body-file t]
1770 ["Pipe through a filter" gnus-summary-pipe-output t]
1771 ["Add to SOUP packet" gnus-soup-add-article t]
1772 ["Print" gnus-summary-print-article t])
1774 ["Respool article..." gnus-summary-respool-article t]
1775 ["Move article..." gnus-summary-move-article
1776 (gnus-check-backend-function
1777 'request-move-article gnus-newsgroup-name)]
1778 ["Copy article..." gnus-summary-copy-article t]
1779 ["Crosspost article..." gnus-summary-crosspost-article
1780 (gnus-check-backend-function
1781 'request-replace-article gnus-newsgroup-name)]
1782 ["Import file..." gnus-summary-import-article t]
1783 ["Check if posted" gnus-summary-article-posted-p t]
1784 ["Edit article" gnus-summary-edit-article
1785 (not (gnus-group-read-only-p))]
1786 ["Delete article" gnus-summary-delete-article
1787 (gnus-check-backend-function
1788 'request-expire-articles gnus-newsgroup-name)]
1789 ["Query respool" gnus-summary-respool-query t]
1790 ["Trace respool" gnus-summary-respool-trace t]
1791 ["Delete expirable articles" gnus-summary-expire-articles-now
1792 (gnus-check-backend-function
1793 'request-expire-articles gnus-newsgroup-name)])
1795 ["Uudecode" gnus-uu-decode-uu t]
1796 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1797 ["Unshar" gnus-uu-decode-unshar t]
1798 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1799 ["Save" gnus-uu-decode-save t]
1800 ["Binhex" gnus-uu-decode-binhex t]
1801 ["Postscript" gnus-uu-decode-postscript t])
1803 ["Enter article" gnus-cache-enter-article t]
1804 ["Remove article" gnus-cache-remove-article t])
1805 ["Translate" gnus-article-babel t]
1806 ["Select article buffer" gnus-summary-select-article-buffer t]
1807 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1808 ["Isearch article..." gnus-summary-isearch-article t]
1809 ["Beginning of the article" gnus-summary-beginning-of-article t]
1810 ["End of the article" gnus-summary-end-of-article t]
1811 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1812 ["Fetch referenced articles" gnus-summary-refer-references t]
1813 ["Fetch current thread" gnus-summary-refer-thread t]
1814 ["Fetch article with id..." gnus-summary-refer-article t]
1815 ["Redisplay" gnus-summary-show-article t])))
1817 gnus-summary-article-menu gnus-summary-mode-map ""
1818 (cons "Article" innards))
1821 gnus-article-commands-menu gnus-article-mode-map ""
1822 (cons "Commands" innards)))
1825 gnus-summary-thread-menu gnus-summary-mode-map ""
1827 ["Toggle threading" gnus-summary-toggle-threads t]
1828 ["Hide threads" gnus-summary-hide-all-threads t]
1829 ["Show threads" gnus-summary-show-all-threads t]
1830 ["Hide thread" gnus-summary-hide-thread t]
1831 ["Show thread" gnus-summary-show-thread t]
1832 ["Go to next thread" gnus-summary-next-thread t]
1833 ["Go to previous thread" gnus-summary-prev-thread t]
1834 ["Go down thread" gnus-summary-down-thread t]
1835 ["Go up thread" gnus-summary-up-thread t]
1836 ["Top of thread" gnus-summary-top-thread t]
1837 ["Mark thread as read" gnus-summary-kill-thread t]
1838 ["Lower thread score" gnus-summary-lower-thread t]
1839 ["Raise thread score" gnus-summary-raise-thread t]
1840 ["Rethread current" gnus-summary-rethread-current t]))
1843 gnus-summary-post-menu gnus-summary-mode-map ""
1845 ["Post an article" gnus-summary-post-news t]
1846 ["Followup" gnus-summary-followup t]
1847 ["Followup and yank" gnus-summary-followup-with-original t]
1848 ["Supersede article" gnus-summary-supersede-article t]
1849 ["Cancel article" gnus-summary-cancel-article t]
1850 ["Reply" gnus-summary-reply t]
1851 ["Reply and yank" gnus-summary-reply-with-original t]
1852 ["Wide reply" gnus-summary-wide-reply t]
1853 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1854 ["Mail forward" gnus-summary-mail-forward t]
1855 ["Post forward" gnus-summary-post-forward t]
1856 ["Digest and mail" gnus-uu-digest-mail-forward t]
1857 ["Digest and post" gnus-uu-digest-post-forward t]
1858 ["Resend message" gnus-summary-resend-message t]
1859 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1860 ["Send a mail" gnus-summary-mail-other-window t]
1861 ["Uuencode and post" gnus-uu-post-news t]
1862 ["Followup via news" gnus-summary-followup-to-mail t]
1863 ["Followup via news and yank"
1864 gnus-summary-followup-to-mail-with-original t]
1866 ;;["Send" gnus-summary-send-draft t]
1867 ;;["Send bounced" gnus-resend-bounced-mail t])
1871 gnus-summary-misc-menu gnus-summary-mode-map ""
1874 ["Mark as read" gnus-summary-mark-as-read-forward t]
1875 ["Mark same subject and select"
1876 gnus-summary-kill-same-subject-and-select t]
1877 ["Mark same subject" gnus-summary-kill-same-subject t]
1878 ["Catchup" gnus-summary-catchup t]
1879 ["Catchup all" gnus-summary-catchup-all t]
1880 ["Catchup to here" gnus-summary-catchup-to-here t]
1881 ["Catchup region" gnus-summary-mark-region-as-read t]
1882 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1884 ["Tick" gnus-summary-tick-article-forward t]
1885 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1886 ["Remove marks" gnus-summary-clear-mark-forward t]
1887 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1888 ["Set bookmark" gnus-summary-set-bookmark t]
1889 ["Remove bookmark" gnus-summary-remove-bookmark t])
1891 ["Marks..." gnus-summary-limit-to-marks t]
1892 ["Subject..." gnus-summary-limit-to-subject t]
1893 ["Author..." gnus-summary-limit-to-author t]
1894 ["Age..." gnus-summary-limit-to-age t]
1895 ["Extra..." gnus-summary-limit-to-extra t]
1896 ["Score" gnus-summary-limit-to-score t]
1897 ["Unread" gnus-summary-limit-to-unread t]
1898 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1899 ["Articles" gnus-summary-limit-to-articles t]
1900 ["Pop limit" gnus-summary-pop-limit t]
1901 ["Show dormant" gnus-summary-limit-include-dormant t]
1902 ["Hide childless dormant"
1903 gnus-summary-limit-exclude-childless-dormant t]
1904 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1905 ["Hide marked" gnus-summary-limit-exclude-marks t]
1906 ["Show expunged" gnus-summary-show-all-expunged t])
1908 ["Set mark" gnus-summary-mark-as-processable t]
1909 ["Remove mark" gnus-summary-unmark-as-processable t]
1910 ["Remove all marks" gnus-summary-unmark-all-processable t]
1911 ["Mark above" gnus-uu-mark-over t]
1912 ["Mark series" gnus-uu-mark-series t]
1913 ["Mark region" gnus-uu-mark-region t]
1914 ["Unmark region" gnus-uu-unmark-region t]
1915 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1916 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1917 ["Mark all" gnus-uu-mark-all t]
1918 ["Mark buffer" gnus-uu-mark-buffer t]
1919 ["Mark sparse" gnus-uu-mark-sparse t]
1920 ["Mark thread" gnus-uu-mark-thread t]
1921 ["Unmark thread" gnus-uu-unmark-thread t]
1922 ("Process Mark Sets"
1923 ["Kill" gnus-summary-kill-process-mark t]
1924 ["Yank" gnus-summary-yank-process-mark
1925 gnus-newsgroup-process-stack]
1926 ["Save" gnus-summary-save-process-mark t]))
1928 ["Page forward" gnus-summary-next-page t]
1929 ["Page backward" gnus-summary-prev-page t]
1930 ["Line forward" gnus-summary-scroll-up t])
1932 ["Next unread article" gnus-summary-next-unread-article t]
1933 ["Previous unread article" gnus-summary-prev-unread-article t]
1934 ["Next article" gnus-summary-next-article t]
1935 ["Previous article" gnus-summary-prev-article t]
1936 ["Next unread subject" gnus-summary-next-unread-subject t]
1937 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1938 ["Next article same subject" gnus-summary-next-same-subject t]
1939 ["Previous article same subject" gnus-summary-prev-same-subject t]
1940 ["First unread article" gnus-summary-first-unread-article t]
1941 ["Best unread article" gnus-summary-best-unread-article t]
1942 ["Go to subject number..." gnus-summary-goto-subject t]
1943 ["Go to article number..." gnus-summary-goto-article t]
1944 ["Go to the last article" gnus-summary-goto-last-article t]
1945 ["Pop article off history" gnus-summary-pop-article t])
1947 ["Sort by number" gnus-summary-sort-by-number t]
1948 ["Sort by author" gnus-summary-sort-by-author t]
1949 ["Sort by subject" gnus-summary-sort-by-subject t]
1950 ["Sort by date" gnus-summary-sort-by-date t]
1951 ["Sort by score" gnus-summary-sort-by-score t]
1952 ["Sort by lines" gnus-summary-sort-by-lines t]
1953 ["Sort by characters" gnus-summary-sort-by-chars t])
1955 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1956 ["Describe group" gnus-summary-describe-group t]
1957 ["Read manual" gnus-info-find-node t])
1959 ["Pick and read" gnus-pick-mode t]
1960 ["Binary" gnus-binary-mode t])
1962 ["Regenerate" gnus-summary-prepare t]
1963 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1964 ["Toggle threading" gnus-summary-toggle-threads t])
1965 ["Filter articles..." gnus-summary-execute-command t]
1966 ["Run command on subjects..." gnus-summary-universal-argument t]
1967 ["Search articles forward..." gnus-summary-search-article-forward t]
1968 ["Search articles backward..." gnus-summary-search-article-backward t]
1969 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1970 ["Expand window" gnus-summary-expand-window t]
1971 ["Expire expirable articles" gnus-summary-expire-articles
1972 (gnus-check-backend-function
1973 'request-expire-articles gnus-newsgroup-name)]
1974 ["Edit local kill file" gnus-summary-edit-local-kill t]
1975 ["Edit main kill file" gnus-summary-edit-global-kill t]
1976 ["Edit group parameters" gnus-summary-edit-parameters t]
1977 ["Customize group parameters" gnus-summary-customize-parameters t]
1978 ["Send a bug report" gnus-bug t]
1980 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1981 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1982 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1983 ["Exit group" gnus-summary-exit t]
1984 ["Exit group without updating" gnus-summary-exit-no-update t]
1985 ["Exit and goto next group" gnus-summary-next-group t]
1986 ["Exit and goto prev group" gnus-summary-prev-group t]
1987 ["Reselect group" gnus-summary-reselect-current-group t]
1988 ["Rescan group" gnus-summary-rescan-group t]
1989 ["Update dribble" gnus-summary-save-newsrc t])))
1991 (gnus-run-hooks 'gnus-summary-menu-hook)))
1993 (defun gnus-score-set-default (var value)
1994 "A version of set that updates the GNU Emacs menu-bar."
1996 ;; It is the message that forces the active status to be updated.
1999 (defun gnus-make-score-map (type)
2000 "Make a summary score map of type TYPE."
2003 (let ((headers '(("author" "from" string)
2004 ("subject" "subject" string)
2005 ("article body" "body" string)
2006 ("article head" "head" string)
2007 ("xref" "xref" string)
2008 ("extra header" "extra" string)
2009 ("lines" "lines" number)
2010 ("followups to author" "followup" string)))
2011 (types '((number ("less than" <)
2014 (string ("substring" s)
2018 (perms '(("temporary" (current-time-string))
2026 (if (eq type 'lower)
2031 (setq header (car headers))
2037 (let ((ts (cdr (assoc (nth 2 header) types)))
2053 'gnus-summary-score-entry
2055 (if (or (string= (nth 1 header)
2057 (string= (nth 1 header)
2060 (list 'gnus-summary-header
2062 (list 'quote (nth 1 (car ts)))
2063 (list 'gnus-score-delta-default
2070 (list (nreverse outp))))
2073 (list (nreverse outt))))
2075 (setq headers (cdr headers)))
2076 (list (nreverse outh))))))))
2080 (defun gnus-summary-mode (&optional group)
2081 "Major mode for reading articles.
2083 All normal editing commands are switched off.
2084 \\<gnus-summary-mode-map>
2085 Each line in this buffer represents one article. To read an
2086 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2087 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2090 You can also post articles and send mail from this buffer. To
2091 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2092 of an article, type `\\[gnus-summary-reply]'.
2094 There are approx. one gazillion commands you can execute in this
2095 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2097 The following commands are available:
2099 \\{gnus-summary-mode-map}"
2101 (when (gnus-visual-p 'summary-menu 'menu)
2102 (gnus-summary-make-menu-bar))
2103 (kill-all-local-variables)
2104 (gnus-summary-make-local-variables)
2105 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2106 (gnus-summary-make-local-variables))
2107 (gnus-make-thread-indent-array)
2108 (gnus-simplify-mode-line)
2109 (setq major-mode 'gnus-summary-mode)
2110 (setq mode-name "Summary")
2111 (make-local-variable 'minor-mode-alist)
2112 (use-local-map gnus-summary-mode-map)
2113 (buffer-disable-undo)
2114 (setq buffer-read-only t) ;Disable modification
2115 (setq truncate-lines t)
2116 (setq selective-display t)
2117 (setq selective-display-ellipses t) ;Display `...'
2118 (gnus-summary-set-display-table)
2119 (gnus-set-default-directory)
2120 (setq gnus-newsgroup-name group)
2121 (unless (gnus-news-group-p group)
2122 (setq gnus-newsgroup-incorporated
2123 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2124 (make-local-variable 'gnus-summary-line-format)
2125 (make-local-variable 'gnus-summary-line-format-spec)
2126 (make-local-variable 'gnus-summary-dummy-line-format)
2127 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2128 (make-local-variable 'gnus-summary-mark-positions)
2129 (make-local-hook 'pre-command-hook)
2130 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2131 (gnus-run-hooks 'gnus-summary-mode-hook)
2132 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2133 (gnus-update-summary-mark-positions))
2135 (defun gnus-summary-make-local-variables ()
2136 "Make all the local summary buffer variables."
2138 (dolist (local gnus-summary-local-variables)
2141 (if (eq (cdr local) 'global)
2142 ;; Copy the global value of the variable.
2143 (setq global (symbol-value (car local)))
2144 ;; Use the value from the list.
2145 (setq global (eval (cdr local))))
2146 (set (make-local-variable (car local)) global))
2147 ;; Simple nil-valued local variable.
2148 (set (make-local-variable local) nil)))))
2150 (defun gnus-summary-clear-local-variables ()
2151 (let ((locals gnus-summary-local-variables))
2153 (if (consp (car locals))
2154 (and (vectorp (caar locals))
2155 (set (caar locals) nil))
2156 (and (vectorp (car locals))
2157 (set (car locals) nil)))
2158 (setq locals (cdr locals)))))
2160 ;; Summary data functions.
2162 (defmacro gnus-data-number (data)
2165 (defmacro gnus-data-set-number (data number)
2166 `(setcar ,data ,number))
2168 (defmacro gnus-data-mark (data)
2171 (defmacro gnus-data-set-mark (data mark)
2172 `(setcar (nthcdr 1 ,data) ,mark))
2174 (defmacro gnus-data-pos (data)
2177 (defmacro gnus-data-set-pos (data pos)
2178 `(setcar (nthcdr 2 ,data) ,pos))
2180 (defmacro gnus-data-header (data)
2183 (defmacro gnus-data-set-header (data header)
2184 `(setcar (nthcdr 3 ,data) ,header))
2186 (defmacro gnus-data-level (data)
2189 (defmacro gnus-data-unread-p (data)
2190 `(= (nth 1 ,data) gnus-unread-mark))
2192 (defmacro gnus-data-read-p (data)
2193 `(/= (nth 1 ,data) gnus-unread-mark))
2195 (defmacro gnus-data-pseudo-p (data)
2196 `(consp (nth 3 ,data)))
2198 (defmacro gnus-data-find (number)
2199 `(assq ,number gnus-newsgroup-data))
2201 (defmacro gnus-data-find-list (number &optional data)
2202 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2203 (memq (assq ,number bdata)
2206 (defmacro gnus-data-make (number mark pos header level)
2207 `(list ,number ,mark ,pos ,header ,level))
2209 (defun gnus-data-enter (after-article number mark pos header level offset)
2210 (let ((data (gnus-data-find-list after-article)))
2212 (error "No such article: %d" after-article))
2213 (setcdr data (cons (gnus-data-make number mark pos header level)
2215 (setq gnus-newsgroup-data-reverse nil)
2216 (gnus-data-update-list (cddr data) offset)))
2218 (defun gnus-data-enter-list (after-article list &optional offset)
2220 (let ((data (and after-article (gnus-data-find-list after-article)))
2224 (let ((odata gnus-newsgroup-data))
2225 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2227 (gnus-data-update-list odata offset)))
2228 ;; Find the last element in the list to be spliced into the main
2231 (setq list (cdr list)))
2234 (setcdr list gnus-newsgroup-data)
2235 (setq gnus-newsgroup-data ilist)
2237 (gnus-data-update-list (cdr list) offset)))
2238 (setcdr list (cdr data))
2241 (gnus-data-update-list (cdr list) offset))))
2242 (setq gnus-newsgroup-data-reverse nil))))
2244 (defun gnus-data-remove (article &optional offset)
2245 (let ((data gnus-newsgroup-data))
2246 (if (= (gnus-data-number (car data)) article)
2248 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2249 gnus-newsgroup-data-reverse nil)
2251 (gnus-data-update-list gnus-newsgroup-data offset)))
2253 (when (= (gnus-data-number (cadr data)) article)
2254 (setcdr data (cddr data))
2256 (gnus-data-update-list (cdr data) offset))
2258 gnus-newsgroup-data-reverse nil))
2259 (setq data (cdr data))))))
2261 (defmacro gnus-data-list (backward)
2263 (or gnus-newsgroup-data-reverse
2264 (setq gnus-newsgroup-data-reverse
2265 (reverse gnus-newsgroup-data)))
2266 gnus-newsgroup-data))
2268 (defun gnus-data-update-list (data offset)
2269 "Add OFFSET to the POS of all data entries in DATA."
2270 (setq gnus-newsgroup-data-reverse nil)
2272 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2273 (setq data (cdr data))))
2275 (defun gnus-summary-article-pseudo-p (article)
2276 "Say whether this article is a pseudo article or not."
2277 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2279 (defmacro gnus-summary-article-sparse-p (article)
2280 "Say whether this article is a sparse article or not."
2281 `(memq ,article gnus-newsgroup-sparse))
2283 (defmacro gnus-summary-article-ancient-p (article)
2284 "Say whether this article is a sparse article or not."
2285 `(memq ,article gnus-newsgroup-ancient))
2287 (defun gnus-article-parent-p (number)
2288 "Say whether this article is a parent or not."
2289 (let ((data (gnus-data-find-list number)))
2290 (and (cdr data) ; There has to be an article after...
2291 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2292 (gnus-data-level (nth 1 data))))))
2294 (defun gnus-article-children (number)
2295 "Return a list of all children to NUMBER."
2296 (let* ((data (gnus-data-find-list number))
2297 (level (gnus-data-level (car data)))
2299 (setq data (cdr data))
2301 (= (gnus-data-level (car data)) (1+ level)))
2302 (push (gnus-data-number (car data)) children)
2303 (setq data (cdr data)))
2306 (defmacro gnus-summary-skip-intangible ()
2307 "If the current article is intangible, then jump to a different article."
2308 '(let ((to (get-text-property (point) 'gnus-intangible)))
2309 (and to (gnus-summary-goto-subject to))))
2311 (defmacro gnus-summary-article-intangible-p ()
2312 "Say whether this article is intangible or not."
2313 '(get-text-property (point) 'gnus-intangible))
2315 (defun gnus-article-read-p (article)
2316 "Say whether ARTICLE is read or not."
2317 (not (or (memq article gnus-newsgroup-marked)
2318 (memq article gnus-newsgroup-unreads)
2319 (memq article gnus-newsgroup-unselected)
2320 (memq article gnus-newsgroup-dormant))))
2322 ;; Some summary mode macros.
2324 (defmacro gnus-summary-article-number ()
2325 "The article number of the article on the current line.
2326 If there isn's an article number here, then we return the current
2329 (gnus-summary-skip-intangible)
2330 (or (get-text-property (point) 'gnus-number)
2331 (gnus-summary-last-subject))))
2333 (defmacro gnus-summary-article-header (&optional number)
2334 "Return the header of article NUMBER."
2335 `(gnus-data-header (gnus-data-find
2336 ,(or number '(gnus-summary-article-number)))))
2338 (defmacro gnus-summary-thread-level (&optional number)
2339 "Return the level of thread that starts with article NUMBER."
2340 `(if (and (eq gnus-summary-make-false-root 'dummy)
2341 (get-text-property (point) 'gnus-intangible))
2343 (gnus-data-level (gnus-data-find
2344 ,(or number '(gnus-summary-article-number))))))
2346 (defmacro gnus-summary-article-mark (&optional number)
2347 "Return the mark of article NUMBER."
2348 `(gnus-data-mark (gnus-data-find
2349 ,(or number '(gnus-summary-article-number)))))
2351 (defmacro gnus-summary-article-pos (&optional number)
2352 "Return the position of the line of article NUMBER."
2353 `(gnus-data-pos (gnus-data-find
2354 ,(or number '(gnus-summary-article-number)))))
2356 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2357 (defmacro gnus-summary-article-subject (&optional number)
2358 "Return current subject string or nil if nothing."
2361 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2362 '(gnus-data-header (assq (gnus-summary-article-number)
2363 gnus-newsgroup-data)))))
2366 (mail-header-subject headers))))
2368 (defmacro gnus-summary-article-score (&optional number)
2369 "Return current article score."
2370 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2371 gnus-newsgroup-scored))
2372 gnus-summary-default-score 0))
2374 (defun gnus-summary-article-children (&optional number)
2375 "Return a list of article numbers that are children of article NUMBER."
2376 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2377 (level (gnus-data-level (car data)))
2379 (while (and (setq data (cdr data))
2380 (> (setq l (gnus-data-level (car data))) level))
2381 (and (= (1+ level) l)
2382 (push (gnus-data-number (car data))
2384 (nreverse children)))
2386 (defun gnus-summary-article-parent (&optional number)
2387 "Return the article number of the parent of article NUMBER."
2388 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2389 (gnus-data-list t)))
2390 (level (gnus-data-level (car data))))
2392 () ; This is a root.
2393 ;; We search until we find an article with a level less than
2394 ;; this one. That function has to be the parent.
2395 (while (and (setq data (cdr data))
2396 (not (< (gnus-data-level (car data)) level))))
2397 (and data (gnus-data-number (car data))))))
2399 (defun gnus-unread-mark-p (mark)
2400 "Say whether MARK is the unread mark."
2401 (= mark gnus-unread-mark))
2403 (defun gnus-read-mark-p (mark)
2404 "Say whether MARK is one of the marks that mark as read.
2405 This is all marks except unread, ticked, dormant, and expirable."
2406 (not (or (= mark gnus-unread-mark)
2407 (= mark gnus-ticked-mark)
2408 (= mark gnus-dormant-mark)
2409 (= mark gnus-expirable-mark))))
2411 (defmacro gnus-article-mark (number)
2412 "Return the MARK of article NUMBER.
2413 This macro should only be used when computing the mark the \"first\"
2414 time; i.e., when generating the summary lines. After that,
2415 `gnus-summary-article-mark' should be used to examine the
2418 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2419 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2420 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2421 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2422 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2423 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2424 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2425 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2426 gnus-ancient-mark))))
2428 ;; Saving hidden threads.
2430 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2431 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2433 (defmacro gnus-save-hidden-threads (&rest forms)
2434 "Save hidden threads, eval FORMS, and restore the hidden threads."
2435 (let ((config (make-symbol "config")))
2436 `(let ((,config (gnus-hidden-threads-configuration)))
2440 (gnus-restore-hidden-threads-configuration ,config)))))
2442 (defun gnus-data-compute-positions ()
2443 "Compute the positions of all articles."
2444 (setq gnus-newsgroup-data-reverse nil)
2445 (let ((data gnus-newsgroup-data))
2447 (gnus-save-hidden-threads
2448 (gnus-summary-show-all-threads)
2449 (goto-char (point-min))
2451 (while (get-text-property (point) 'gnus-intangible)
2453 (gnus-data-set-pos (car data) (+ (point) 3))
2454 (setq data (cdr data))
2455 (forward-line 1))))))
2457 (defun gnus-hidden-threads-configuration ()
2458 "Return the current hidden threads configuration."
2461 (goto-char (point-min))
2462 (while (search-forward "\r" nil t)
2463 (push (1- (point)) config))
2466 (defun gnus-restore-hidden-threads-configuration (config)
2467 "Restore hidden threads configuration from CONFIG."
2469 (let (point buffer-read-only)
2470 (while (setq point (pop config))
2471 (when (and (< point (point-max))
2473 (eq (char-after) ?\n))
2474 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2476 ;; Various summary mode internalish functions.
2478 (defun gnus-mouse-pick-article (e)
2481 (gnus-summary-next-page nil t))
2483 (defun gnus-summary-set-display-table ()
2484 "Change the display table.
2485 Odd characters have a tendency to mess
2486 up nicely formatted displays - we make all possible glyphs
2487 display only a single character."
2489 ;; We start from the standard display table, if any.
2490 (let ((table (or (copy-sequence standard-display-table)
2491 (make-display-table)))
2493 ;; Nix out all the control chars...
2494 (while (>= (setq i (1- i)) 0)
2495 (aset table i [??]))
2496 ;; ... but not newline and cr, of course. (cr is necessary for the
2497 ;; selective display).
2498 (aset table ?\n nil)
2499 (aset table ?\r nil)
2500 ;; We keep TAB as well.
2501 (aset table ?\t nil)
2502 ;; We nix out any glyphs over 126 that are not set already.
2504 (while (>= (setq i (1- i)) 127)
2505 ;; Only modify if the entry is nil.
2506 (unless (aref table i)
2507 (aset table i [??]))))
2508 (setq buffer-display-table table)))
2510 (defun gnus-summary-setup-buffer (group)
2511 "Initialize summary buffer."
2512 (let ((buffer (concat "*Summary " group "*")))
2513 (if (get-buffer buffer)
2516 (setq gnus-summary-buffer (current-buffer))
2517 (not gnus-newsgroup-prepared))
2518 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2519 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2520 (gnus-summary-mode group)
2522 (gnus-carpal-setup-buffer 'summary))
2523 (unless gnus-single-article-buffer
2524 (make-local-variable 'gnus-article-buffer)
2525 (make-local-variable 'gnus-article-current)
2526 (make-local-variable 'gnus-original-article-buffer))
2527 (setq gnus-newsgroup-name group)
2530 (defun gnus-set-global-variables ()
2531 "Set the global equivalents of the buffer-local variables.
2532 They are set to the latest values they had. These reflect the summary
2533 buffer that was in action when the last article was fetched."
2534 (when (eq major-mode 'gnus-summary-mode)
2535 (setq gnus-summary-buffer (current-buffer))
2536 (let ((name gnus-newsgroup-name)
2537 (marked gnus-newsgroup-marked)
2538 (unread gnus-newsgroup-unreads)
2539 (headers gnus-current-headers)
2540 (data gnus-newsgroup-data)
2541 (summary gnus-summary-buffer)
2542 (article-buffer gnus-article-buffer)
2543 (original gnus-original-article-buffer)
2544 (gac gnus-article-current)
2545 (reffed gnus-reffed-article-number)
2546 (score-file gnus-current-score-file)
2547 (default-charset gnus-newsgroup-charset)
2549 (let ((locals gnus-newsgroup-variables))
2551 (if (consp (car locals))
2552 (push (eval (caar locals)) vlist)
2553 (push (eval (car locals)) vlist))
2554 (setq locals (cdr locals)))
2555 (setq vlist (nreverse vlist)))
2557 (set-buffer gnus-group-buffer)
2558 (setq gnus-newsgroup-name name
2559 gnus-newsgroup-marked marked
2560 gnus-newsgroup-unreads unread
2561 gnus-current-headers headers
2562 gnus-newsgroup-data data
2563 gnus-article-current gac
2564 gnus-summary-buffer summary
2565 gnus-article-buffer article-buffer
2566 gnus-original-article-buffer original
2567 gnus-reffed-article-number reffed
2568 gnus-current-score-file score-file
2569 gnus-newsgroup-charset default-charset)
2570 (let ((locals gnus-newsgroup-variables))
2572 (if (consp (car locals))
2573 (set (caar locals) (pop vlist))
2574 (set (car locals) (pop vlist)))
2575 (setq locals (cdr locals))))
2576 ;; The article buffer also has local variables.
2577 (when (gnus-buffer-live-p gnus-article-buffer)
2578 (set-buffer gnus-article-buffer)
2579 (setq gnus-summary-buffer summary))))))
2581 (defun gnus-summary-article-unread-p (article)
2582 "Say whether ARTICLE is unread or not."
2583 (memq article gnus-newsgroup-unreads))
2585 (defun gnus-summary-first-article-p (&optional article)
2586 "Return whether ARTICLE is the first article in the buffer."
2587 (if (not (setq article (or article (gnus-summary-article-number))))
2589 (eq article (caar gnus-newsgroup-data))))
2591 (defun gnus-summary-last-article-p (&optional article)
2592 "Return whether ARTICLE is the last article in the buffer."
2593 (if (not (setq article (or article (gnus-summary-article-number))))
2594 ;; All non-existent numbers are the last article. :-)
2596 (not (cdr (gnus-data-find-list article)))))
2598 (defun gnus-make-thread-indent-array ()
2600 (unless (and gnus-thread-indent-array
2601 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2602 (setq gnus-thread-indent-array (make-vector 201 "")
2603 gnus-thread-indent-array-level gnus-thread-indent-level)
2605 (aset gnus-thread-indent-array n
2606 (make-string (* n gnus-thread-indent-level) ? ))
2609 (defun gnus-update-summary-mark-positions ()
2610 "Compute where the summary marks are to go."
2612 (when (gnus-buffer-exists-p gnus-summary-buffer)
2613 (set-buffer gnus-summary-buffer))
2614 (let ((gnus-replied-mark 129)
2615 (gnus-score-below-mark 130)
2616 (gnus-score-over-mark 130)
2617 (gnus-download-mark 131)
2618 (spec gnus-summary-line-format-spec)
2621 (gnus-set-work-buffer)
2622 (let ((gnus-summary-line-format-spec spec)
2623 (gnus-newsgroup-downloadable '((0 . t))))
2624 (gnus-summary-insert-line
2625 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2626 0 nil 128 t nil "" nil 1)
2627 (goto-char (point-min))
2628 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2630 (goto-char (point-min))
2631 (push (cons 'replied (and (search-forward "\201" nil t)
2634 (goto-char (point-min))
2635 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2637 (goto-char (point-min))
2638 (push (cons 'download
2639 (and (search-forward "\203" nil t) (- (point) 2)))
2641 (setq gnus-summary-mark-positions pos))))
2643 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2644 "Insert a dummy root in the summary buffer."
2646 (gnus-add-text-properties
2647 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2648 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2650 (defun gnus-summary-from-or-to-or-newsgroups (header)
2651 (let ((to (cdr (assq 'To (mail-header-extra header))))
2652 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2653 (default-mime-charset (with-current-buffer gnus-summary-buffer
2654 default-mime-charset)))
2657 gnus-ignored-from-addresses
2658 (string-match gnus-ignored-from-addresses
2659 (mail-header-from header)))
2661 (or (car (funcall gnus-extract-address-components
2663 gnus-decode-encoded-word-function to)))
2664 (funcall gnus-decode-encoded-word-function to))))
2666 gnus-ignored-from-addresses
2667 (string-match gnus-ignored-from-addresses
2668 (mail-header-from header)))
2669 (concat "=> " newsgroups))
2671 (or (car (funcall gnus-extract-address-components
2672 (mail-header-from header)))
2673 (mail-header-from header))))))
2675 (defun gnus-summary-insert-line (gnus-tmp-header
2676 gnus-tmp-level gnus-tmp-current
2677 gnus-tmp-unread gnus-tmp-replied
2678 gnus-tmp-expirable gnus-tmp-subject-or-nil
2679 &optional gnus-tmp-dummy gnus-tmp-score
2681 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2682 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2683 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2684 (gnus-tmp-score-char
2685 (if (or (null gnus-summary-default-score)
2686 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2687 gnus-summary-zcore-fuzz))
2689 (if (< gnus-tmp-score gnus-summary-default-score)
2690 gnus-score-below-mark gnus-score-over-mark)))
2692 (cond (gnus-tmp-process gnus-process-mark)
2693 ((memq gnus-tmp-current gnus-newsgroup-cached)
2695 (gnus-tmp-replied gnus-replied-mark)
2696 ((memq gnus-tmp-current gnus-newsgroup-saved)
2698 (t gnus-unread-mark)))
2699 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2702 ((string-match "<[^>]+> *$" gnus-tmp-from)
2703 (let ((beg (match-beginning 0)))
2704 (or (and (string-match "^\".+\"" gnus-tmp-from)
2705 (substring gnus-tmp-from 1 (1- (match-end 0))))
2706 (substring gnus-tmp-from 0 beg))))
2707 ((string-match "(.+)" gnus-tmp-from)
2708 (substring gnus-tmp-from
2709 (1+ (match-beginning 0)) (1- (match-end 0))))
2711 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2712 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2713 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2714 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2715 (buffer-read-only nil))
2716 (when (string= gnus-tmp-name "")
2717 (setq gnus-tmp-name gnus-tmp-from))
2718 (unless (numberp gnus-tmp-lines)
2719 (setq gnus-tmp-lines 0))
2720 (gnus-put-text-property-excluding-characters-with-faces
2722 (progn (eval gnus-summary-line-format-spec) (point))
2723 'gnus-number gnus-tmp-number)
2724 (when (gnus-visual-p 'summary-highlight 'highlight)
2726 (gnus-run-hooks 'gnus-summary-update-hook)
2729 (defun gnus-summary-update-line (&optional dont-update)
2730 "Update summary line after change."
2731 (when (and gnus-summary-default-score
2732 (not gnus-summary-inhibit-highlight))
2733 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2734 (article (gnus-summary-article-number))
2735 (score (gnus-summary-article-score article)))
2737 (if (and gnus-summary-mark-below
2738 (< (gnus-summary-article-score)
2739 gnus-summary-mark-below))
2740 ;; This article has a low score, so we mark it as read.
2741 (when (memq article gnus-newsgroup-unreads)
2742 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2743 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2744 ;; This article was previously marked as read on account
2745 ;; of a low score, but now it has risen, so we mark it as
2747 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2748 (gnus-summary-update-mark
2749 (if (or (null gnus-summary-default-score)
2750 (<= (abs (- score gnus-summary-default-score))
2751 gnus-summary-zcore-fuzz))
2753 (if (< score gnus-summary-default-score)
2754 gnus-score-below-mark gnus-score-over-mark))
2756 ;; Do visual highlighting.
2757 (when (gnus-visual-p 'summary-highlight 'highlight)
2758 (gnus-run-hooks 'gnus-summary-update-hook)))))
2760 (defvar gnus-tmp-new-adopts nil)
2762 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2763 "Return the number of articles in THREAD.
2764 This may be 0 in some cases -- if none of the articles in
2765 the thread are to be displayed."
2767 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2769 ((not (listp thread))
2771 ((and (consp thread) (cdr thread))
2774 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2777 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2780 (when (and level (zerop level) gnus-tmp-new-adopts)
2783 'gnus-summary-number-of-articles-in-thread
2784 gnus-tmp-new-adopts))))
2786 (if (> number 1) gnus-not-empty-thread-mark
2787 gnus-empty-thread-mark)
2790 (defun gnus-summary-set-local-parameters (group)
2791 "Go through the local params of GROUP and set all variable specs in that list."
2792 (let ((params (gnus-group-find-parameter group))
2795 (setq elem (car params)
2796 params (cdr params))
2797 (and (consp elem) ; Has to be a cons.
2798 (consp (cdr elem)) ; The cdr has to be a list.
2799 (symbolp (car elem)) ; Has to be a symbol in there.
2800 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2801 (ignore-errors ; So we set it.
2802 (make-local-variable (car elem))
2803 (set (car elem) (eval (nth 1 elem))))))))
2805 (defun gnus-summary-read-group (group &optional show-all no-article
2806 kill-buffer no-display backward
2808 "Start reading news in newsgroup GROUP.
2809 If SHOW-ALL is non-nil, already read articles are also listed.
2810 If NO-ARTICLE is non-nil, no article is selected initially.
2811 If NO-DISPLAY, don't generate a summary buffer."
2815 (let ((gnus-auto-select-next nil))
2816 (or (gnus-summary-read-group-1
2817 group show-all no-article
2818 kill-buffer no-display
2821 select-articles nil)))))
2822 (eq gnus-auto-select-next 'quietly))
2823 (set-buffer gnus-group-buffer)
2824 ;; The entry function called above goes to the next
2825 ;; group automatically, so we go two groups back
2826 ;; if we are searching for the previous group.
2828 (gnus-group-prev-unread-group 2))
2829 (if (not (equal group (gnus-group-group-name)))
2830 (setq group (gnus-group-group-name))
2834 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2835 "Directly jump to the other GROUP from summary buffer.
2836 If SHOW-ALL is non-nil, already read articles are also listed."
2838 (if (eq gnus-summary-buffer (current-buffer))
2839 (list (completing-read
2840 "Group: " gnus-active-hashtb nil t
2841 (when (and gnus-newsgroup-name
2842 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2843 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2844 'gnus-group-history)
2846 (error "%s must be invoked from a gnus summary buffer." this-command)))
2847 (unless (or (zerop (length group))
2848 (and gnus-newsgroup-name
2849 (string-equal gnus-newsgroup-name group)))
2851 (gnus-summary-read-group group show-all
2852 gnus-dont-select-after-jump-to-other-group)))
2854 (defun gnus-summary-read-group-1 (group show-all no-article
2855 kill-buffer no-display
2856 &optional select-articles)
2857 ;; Killed foreign groups can't be entered.
2858 (when (and (not (gnus-group-native-p group))
2859 (not (gnus-gethash group gnus-newsrc-hashtb)))
2860 (error "Dead non-native groups can't be entered"))
2861 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2862 (let* ((new-group (gnus-summary-setup-buffer group))
2863 (quit-config (gnus-group-quit-config group))
2864 (did-select (and new-group (gnus-select-newsgroup
2865 group show-all select-articles))))
2867 ;; This summary buffer exists already, so we just select it.
2869 (gnus-set-global-variables)
2871 (gnus-kill-or-deaden-summary kill-buffer))
2872 (gnus-configure-windows 'summary 'force)
2873 (gnus-set-mode-line 'summary)
2874 (gnus-summary-position-point)
2877 ;; We couldn't select this group.
2879 (when (and (eq major-mode 'gnus-summary-mode)
2880 (not (equal (current-buffer) kill-buffer)))
2881 (kill-buffer (current-buffer))
2882 (if (not quit-config)
2884 ;; Update the info -- marks might need to be removed,
2886 (gnus-summary-update-info)
2887 (set-buffer gnus-group-buffer)
2888 (gnus-group-jump-to-group group)
2889 (gnus-group-next-unread-group 1))
2890 (gnus-handle-ephemeral-exit quit-config)))
2891 (gnus-message 3 "Can't select group")
2893 ;; The user did a `C-g' while prompting for number of articles,
2894 ;; so we exit this group.
2895 ((eq did-select 'quit)
2896 (and (eq major-mode 'gnus-summary-mode)
2897 (not (equal (current-buffer) kill-buffer))
2898 (kill-buffer (current-buffer)))
2900 (gnus-kill-or-deaden-summary kill-buffer))
2901 (if (not quit-config)
2903 (set-buffer gnus-group-buffer)
2904 (gnus-group-jump-to-group group)
2905 (gnus-group-next-unread-group 1)
2906 (gnus-configure-windows 'group 'force))
2907 (gnus-handle-ephemeral-exit quit-config))
2908 ;; Finally signal the quit.
2910 ;; The group was successfully selected.
2912 (gnus-set-global-variables)
2913 ;; Save the active value in effect when the group was entered.
2914 (setq gnus-newsgroup-active
2916 (gnus-active gnus-newsgroup-name)))
2917 ;; You can change the summary buffer in some way with this hook.
2918 (gnus-run-hooks 'gnus-select-group-hook)
2919 ;; Set any local variables in the group parameters.
2920 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2921 (gnus-update-format-specifications
2922 nil 'summary 'summary-mode 'summary-dummy)
2923 (gnus-update-summary-mark-positions)
2924 ;; Do score processing.
2925 (when gnus-use-scoring
2926 (gnus-possibly-score-headers))
2927 ;; Check whether to fill in the gaps in the threads.
2928 (when gnus-build-sparse-threads
2929 (gnus-build-sparse-threads))
2930 ;; Find the initial limit.
2931 (if gnus-show-threads
2933 (let ((gnus-newsgroup-dormant nil))
2934 (gnus-summary-initial-limit show-all))
2935 (gnus-summary-initial-limit show-all))
2936 ;; When untreaded, all articles are always shown.
2937 (setq gnus-newsgroup-limit
2939 (lambda (header) (mail-header-number header))
2940 gnus-newsgroup-headers)))
2941 ;; Generate the summary buffer.
2943 (gnus-summary-prepare))
2944 (when gnus-use-trees
2945 (gnus-tree-open group)
2946 (setq gnus-summary-highlight-line-function
2947 'gnus-tree-highlight-article))
2948 ;; If the summary buffer is empty, but there are some low-scored
2949 ;; articles or some excluded dormants, we include these in the
2951 (when (and (zerop (buffer-size))
2953 (cond (gnus-newsgroup-dormant
2954 (gnus-summary-limit-include-dormant))
2955 ((and gnus-newsgroup-scored show-all)
2956 (gnus-summary-limit-include-expunged t))))
2957 ;; Function `gnus-apply-kill-file' must be called in this hook.
2958 (gnus-run-hooks 'gnus-apply-kill-hook)
2959 (if (and (zerop (buffer-size))
2962 ;; This newsgroup is empty.
2963 (gnus-summary-catchup-and-exit nil t)
2964 (gnus-message 6 "No unread news")
2966 (gnus-kill-or-deaden-summary kill-buffer))
2967 ;; Return nil from this function.
2969 ;; Hide conversation thread subtrees. We cannot do this in
2970 ;; gnus-summary-prepare-hook since kill processing may not
2971 ;; work with hidden articles.
2972 (and gnus-show-threads
2973 gnus-thread-hide-subtree
2974 (gnus-summary-hide-all-threads))
2976 (gnus-kill-or-deaden-summary kill-buffer))
2977 ;; Show first unread article if requested.
2978 (if (and (not no-article)
2980 gnus-newsgroup-unreads
2981 gnus-auto-select-first)
2983 (gnus-configure-windows 'summary)
2985 ((eq gnus-auto-select-first 'best)
2986 (gnus-summary-best-unread-article))
2987 ((eq gnus-auto-select-first t)
2988 (gnus-summary-first-unread-article))
2989 ((gnus-functionp gnus-auto-select-first)
2990 (funcall gnus-auto-select-first))))
2991 ;; Don't select any articles, just move point to the first
2992 ;; article in the group.
2993 (goto-char (point-min))
2994 (gnus-summary-position-point)
2995 (gnus-configure-windows 'summary 'force)
2996 (gnus-set-mode-line 'summary))
2997 (when (get-buffer-window gnus-group-buffer t)
2998 ;; Gotta use windows, because recenter does weird stuff if
2999 ;; the current buffer ain't the displayed window.
3000 (let ((owin (selected-window)))
3001 (select-window (get-buffer-window gnus-group-buffer t))
3002 (when (gnus-group-goto-group group)
3004 (select-window owin)))
3005 ;; Mark this buffer as "prepared".
3006 (setq gnus-newsgroup-prepared t)
3007 (gnus-run-hooks 'gnus-summary-prepared-hook)
3010 (defun gnus-summary-prepare ()
3011 "Generate the summary buffer."
3013 (let ((buffer-read-only nil))
3015 (setq gnus-newsgroup-data nil
3016 gnus-newsgroup-data-reverse nil)
3017 (gnus-run-hooks 'gnus-summary-generate-hook)
3018 ;; Generate the buffer, either with threads or without.
3019 (when gnus-newsgroup-headers
3020 (gnus-summary-prepare-threads
3021 (if gnus-show-threads
3022 (gnus-sort-gathered-threads
3023 (funcall gnus-summary-thread-gathering-function
3025 (gnus-cut-threads (gnus-make-threads)))))
3026 ;; Unthreaded display.
3027 (gnus-sort-articles gnus-newsgroup-headers))))
3028 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3029 ;; Call hooks for modifying summary buffer.
3030 (goto-char (point-min))
3031 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3033 (defsubst gnus-general-simplify-subject (subject)
3034 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3037 ;; Truncate the subject.
3038 (gnus-simplify-subject-functions
3039 (gnus-map-function gnus-simplify-subject-functions subject))
3040 ((numberp gnus-summary-gather-subject-limit)
3041 (setq subject (gnus-simplify-subject-re subject))
3042 (if (> (length subject) gnus-summary-gather-subject-limit)
3043 (substring subject 0 gnus-summary-gather-subject-limit)
3045 ;; Fuzzily simplify it.
3046 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3047 (gnus-simplify-subject-fuzzy subject))
3048 ;; Just remove the leading "Re:".
3050 (gnus-simplify-subject-re subject))))
3052 (if (and gnus-summary-gather-exclude-subject
3053 (string-match gnus-summary-gather-exclude-subject subject))
3054 nil ; This article shouldn't be gathered
3057 (defun gnus-summary-simplify-subject-query ()
3058 "Query where the respool algorithm would put this article."
3060 (gnus-summary-select-article)
3062 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3064 (defun gnus-gather-threads-by-subject (threads)
3065 "Gather threads by looking at Subject headers."
3066 (if (not gnus-summary-make-false-root)
3068 (let ((hashtb (gnus-make-hashtable 1024))
3071 subject hthread whole-subject)
3073 (setq subject (gnus-general-simplify-subject
3074 (setq whole-subject (mail-header-subject
3077 (if (setq hthread (gnus-gethash subject hashtb))
3079 ;; We enter a dummy root into the thread, if we
3080 ;; haven't done that already.
3081 (unless (stringp (caar hthread))
3082 (setcar hthread (list whole-subject (car hthread))))
3083 ;; We add this new gathered thread to this gathered
3085 (setcdr (car hthread)
3086 (nconc (cdar hthread) (list (car threads))))
3087 ;; Remove it from the list of threads.
3088 (setcdr prev (cdr threads))
3089 (setq threads prev))
3090 ;; Enter this thread into the hash table.
3091 (gnus-sethash subject threads hashtb)))
3093 (setq threads (cdr threads)))
3096 (defun gnus-gather-threads-by-references (threads)
3097 "Gather threads by looking at References headers."
3098 (let ((idhashtb (gnus-make-hashtable 1024))
3099 (thhashtb (gnus-make-hashtable 1024))
3102 ids references id gthread gid entered ref)
3104 (when (setq references (mail-header-references (caar threads)))
3105 (setq id (mail-header-id (caar threads))
3106 ids (gnus-split-references references)
3108 (while (setq ref (pop ids))
3109 (setq ids (delete ref ids))
3110 (if (not (setq gid (gnus-gethash ref idhashtb)))
3112 (gnus-sethash ref id idhashtb)
3113 (gnus-sethash id threads thhashtb))
3114 (setq gthread (gnus-gethash gid thhashtb))
3116 ;; We enter a dummy root into the thread, if we
3117 ;; haven't done that already.
3118 (unless (stringp (caar gthread))
3119 (setcar gthread (list (mail-header-subject (caar gthread))
3121 ;; We add this new gathered thread to this gathered
3123 (setcdr (car gthread)
3124 (nconc (cdar gthread) (list (car threads)))))
3125 ;; Add it into the thread hash table.
3126 (gnus-sethash id gthread thhashtb)
3128 ;; Remove it from the list of threads.
3129 (setcdr prev (cdr threads))
3130 (setq threads prev))))
3132 (setq threads (cdr threads)))
3135 (defun gnus-sort-gathered-threads (threads)
3136 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3137 (let ((result threads))
3139 (when (stringp (caar threads))
3140 (setcdr (car threads)
3141 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3142 (setq threads (cdr threads)))
3145 (defun gnus-thread-loop-p (root thread)
3146 "Say whether ROOT is in THREAD."
3147 (let ((stack (list thread))
3150 (while (setq thread (pop stack))
3151 (setq th (cdr thread))
3153 (not (eq (caar th) root)))
3156 ;; We have found a loop.
3158 (setcdr thread (delq (car th) (cdr thread)))
3159 (if (boundp (setq ref-dep (intern "none"
3160 gnus-newsgroup-dependencies)))
3161 (setcdr (symbol-value ref-dep)
3162 (nconc (cdr (symbol-value ref-dep))
3164 (set ref-dep (list nil (car th))))
3167 ;; Push all the subthreads onto the stack.
3168 (push (cdr thread) stack)))
3171 (defun gnus-make-threads ()
3172 "Go through the dependency hashtb and find the roots. Return all threads."
3174 (while (catch 'infloop
3177 ;; Deal with self-referencing References loops.
3178 (when (and (car (symbol-value refs))
3185 (car (symbol-value refs)) thread))
3186 (cdr (symbol-value refs)))))))
3189 (unless (car (symbol-value refs))
3190 ;; These threads do not refer back to any other articles,
3191 ;; so they're roots.
3192 (setq threads (append (cdr (symbol-value refs)) threads))))
3193 gnus-newsgroup-dependencies)))
3196 ;; Build the thread tree.
3197 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3198 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3200 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3201 if it was already present.
3203 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3204 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3205 Message-IDs will be renamed be renamed to a unique Message-ID before
3208 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3209 (let* ((id (mail-header-id header))
3210 (id-dep (and id (intern id dependencies)))
3211 ref ref-dep ref-header)
3212 ;; Enter this `header' in the `dependencies' table.
3216 ;; The first two cases do the normal part: enter a new `header'
3217 ;; in the `dependencies' table.
3218 ((not (boundp id-dep))
3219 (set id-dep (list header)))
3220 ((null (car (symbol-value id-dep)))
3221 (setcar (symbol-value id-dep) header))
3223 ;; From here the `header' was already present in the
3224 ;; `dependencies' table.
3226 ;; Overrides an existing entry;
3227 ;; just set the header part of the entry.
3228 (setcar (symbol-value id-dep) header))
3230 ;; Renames the existing `header' to a unique Message-ID.
3231 ((not gnus-summary-ignore-duplicates)
3232 ;; An article with this Message-ID has already been seen.
3233 ;; We rename the Message-ID.
3234 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3236 (mail-header-set-id header id))
3238 ;; The last case ignores an existing entry, except it adds any
3239 ;; additional Xrefs (in case the two articles came from different
3241 ;; Also sets `header' to `nil' meaning that the `dependencies'
3242 ;; table was *not* modified.
3244 (mail-header-set-xref
3245 (car (symbol-value id-dep))
3246 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3248 (or (mail-header-xref header) "")))
3252 ;; First check if that we are not creating a References loop.
3253 (setq ref (gnus-parent-id (mail-header-references header)))
3255 (setq ref-dep (intern-soft ref dependencies))
3257 (setq ref-header (car (symbol-value ref-dep))))
3258 (if (string= id ref)
3259 ;; Yuk! This is a reference loop. Make the article be a
3262 (mail-header-set-references (car (symbol-value id-dep)) "none")
3264 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3265 (setq ref (gnus-parent-id (mail-header-references header)))
3266 (setq ref-dep (intern (or ref "none") dependencies))
3267 (if (boundp ref-dep)
3268 (setcdr (symbol-value ref-dep)
3269 (nconc (cdr (symbol-value ref-dep))
3270 (list (symbol-value id-dep))))
3271 (set ref-dep (list nil (symbol-value id-dep)))))
3274 (defun gnus-build-sparse-threads ()
3275 (let ((headers gnus-newsgroup-headers)
3276 (mail-parse-charset gnus-newsgroup-charset)
3277 (gnus-summary-ignore-duplicates t)
3278 header references generation relations
3279 subject child end new-child date)
3280 ;; First we create an alist of generations/relations, where
3281 ;; generations is how much we trust the relation, and the relation
3283 (gnus-message 7 "Making sparse threads...")
3285 (nnheader-set-temp-buffer " *gnus sparse threads*")
3286 (while (setq header (pop headers))
3287 (when (and (setq references (mail-header-references header))
3288 (not (string= references "")))
3290 (setq child (mail-header-id header)
3291 subject (mail-header-subject header)
3292 date (mail-header-date header)
3294 (while (search-backward ">" nil t)
3295 (setq end (1+ (point)))
3296 (when (search-backward "<" nil t)
3297 (setq new-child (buffer-substring (point) end))
3298 (push (list (incf generation)
3299 child (setq child new-child)
3303 (push (list (1+ generation) child nil subject) relations))
3305 (kill-buffer (current-buffer)))
3306 ;; Sort over trustworthiness.
3309 (when (gnus-dependencies-add-header
3310 (make-full-mail-header-from-decoded-header
3311 gnus-reffed-article-number
3312 (nth 3 relation) "" (or (nth 4 relation) "")
3314 (or (nth 2 relation) "") 0 0 "")
3315 gnus-newsgroup-dependencies nil)
3316 (push gnus-reffed-article-number gnus-newsgroup-limit)
3317 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3318 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3319 gnus-newsgroup-reads)
3320 (decf gnus-reffed-article-number)))
3321 (sort relations 'car-less-than-car))
3322 (gnus-message 7 "Making sparse threads...done")))
3324 (defun gnus-build-old-threads ()
3325 ;; Look at all the articles that refer back to old articles, and
3326 ;; fetch the headers for the articles that aren't there. This will
3327 ;; build complete threads - if the roots haven't been expired by the
3329 (let ((mail-parse-charset gnus-newsgroup-charset)
3333 (when (not (car (symbol-value refs)))
3334 (setq heads (cdr (symbol-value refs)))
3336 (if (memq (mail-header-number (caar heads))
3337 gnus-newsgroup-dormant)
3338 (setq heads (cdr heads))
3339 (setq id (symbol-name refs))
3340 (while (and (setq id (gnus-build-get-header id))
3341 (not (car (gnus-id-to-thread id)))))
3342 (setq heads nil)))))
3343 gnus-newsgroup-dependencies)))
3345 ;; This function has to be called with point after the article number
3346 ;; on the beginning of the line.
3347 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3348 (let ((eol (gnus-point-at-eol))
3349 (buffer (current-buffer))
3352 ;; overview: [num subject from date id refs chars lines misc]
3355 (narrow-to-region (point) eol)
3360 (make-full-mail-header
3362 (nnheader-nov-field) ; subject
3363 (nnheader-nov-field) ; from
3364 (nnheader-nov-field) ; date
3365 (nnheader-nov-read-message-id) ; id
3366 (nnheader-nov-field) ; refs
3367 (nnheader-nov-read-integer) ; chars
3368 (nnheader-nov-read-integer) ; lines
3370 (if (looking-at "Xref: ")
3371 (goto-char (match-end 0)))
3372 (nnheader-nov-field)) ; Xref
3373 (nnheader-nov-parse-extra)))) ; extra
3377 (when gnus-alter-header-function
3378 (funcall gnus-alter-header-function header))
3379 (gnus-dependencies-add-header header dependencies force-new)))
3381 (defun gnus-build-get-header (id)
3382 "Look through the buffer of NOV lines and find the header to ID.
3383 Enter this line into the dependencies hash table, and return
3384 the id of the parent article (if any)."
3385 (let ((deps gnus-newsgroup-dependencies)
3389 (set-buffer nntp-server-buffer)
3390 (let ((case-fold-search nil))
3391 (goto-char (point-min))
3392 (while (and (not found)
3393 (search-forward id nil t))
3395 (setq found (looking-at
3396 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3397 (regexp-quote id))))
3398 (or found (beginning-of-line 2)))
3402 (setq header (gnus-nov-parse-line
3403 (read (current-buffer)) deps))
3404 (gnus-parent-id (mail-header-references header))))))
3406 (let ((number (mail-header-number header)))
3407 (push number gnus-newsgroup-limit)
3408 (push header gnus-newsgroup-headers)
3409 (if (memq number gnus-newsgroup-unselected)
3411 (push number gnus-newsgroup-unreads)
3412 (setq gnus-newsgroup-unselected
3413 (delq number gnus-newsgroup-unselected)))
3414 (push number gnus-newsgroup-ancient)))))))
3416 (defun gnus-build-all-threads ()
3417 "Read all the headers."
3418 (let ((gnus-summary-ignore-duplicates t)
3419 (mail-parse-charset gnus-newsgroup-charset)
3420 (dependencies gnus-newsgroup-dependencies)
3423 (set-buffer nntp-server-buffer)
3424 (let ((case-fold-search nil))
3425 (goto-char (point-min))
3428 (setq article (read (current-buffer))
3429 header (gnus-nov-parse-line article dependencies)))
3432 (set-buffer gnus-summary-buffer)
3433 (push header gnus-newsgroup-headers)
3434 (if (memq (setq article (mail-header-number header))
3435 gnus-newsgroup-unselected)
3437 (push article gnus-newsgroup-unreads)
3438 (setq gnus-newsgroup-unselected
3439 (delq article gnus-newsgroup-unselected)))
3440 (push article gnus-newsgroup-ancient)))
3441 (forward-line 1)))))))
3443 (defun gnus-summary-update-article-line (article header)
3444 "Update the line for ARTICLE using HEADERS."
3445 (let* ((id (mail-header-id header))
3446 (thread (gnus-id-to-thread id)))
3448 (error "Article in no thread"))
3449 ;; Update the thread.
3450 (setcar thread header)
3451 (gnus-summary-goto-subject article)
3452 (let* ((datal (gnus-data-find-list article))
3454 (length (when (cdr datal)
3455 (- (gnus-data-pos data)
3456 (gnus-data-pos (cadr datal)))))
3457 (buffer-read-only nil)
3458 (level (gnus-summary-thread-level)))
3460 (gnus-summary-insert-line
3461 header level nil (gnus-article-mark article)
3462 (memq article gnus-newsgroup-replied)
3463 (memq article gnus-newsgroup-expirable)
3464 ;; Only insert the Subject string when it's different
3465 ;; from the previous Subject string.
3470 (mail-header-subject
3473 (gnus-data-find-list
3475 (gnus-data-list t)))))
3476 ;; Error on the side of excessive subjects.
3478 (mail-header-subject header)))
3480 (mail-header-subject header))
3481 nil (cdr (assq article gnus-newsgroup-scored))
3482 (memq article gnus-newsgroup-processable))
3484 (gnus-data-update-list
3485 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3487 (defun gnus-summary-update-article (article &optional iheader)
3488 "Update ARTICLE in the summary buffer."
3489 (set-buffer gnus-summary-buffer)
3490 (let* ((header (gnus-summary-article-header article))
3491 (id (mail-header-id header))
3492 (data (gnus-data-find article))
3493 (thread (gnus-id-to-thread id))
3494 (references (mail-header-references header))
3498 (when (and references
3499 (not (equal "" references)))
3502 (buffer-read-only nil)
3508 (delq thread parent)))
3509 (if (gnus-summary-insert-subject id header)
3510 ;; Set the (possibly) new article number in the data structure.
3511 (gnus-data-set-number data (gnus-id-to-article id))
3515 (defun gnus-rebuild-thread (id &optional line)
3516 "Rebuild the thread containing ID.
3517 If LINE, insert the rebuilt thread starting on line LINE."
3518 (let ((buffer-read-only nil)
3519 old-pos current thread data)
3520 (if (not gnus-show-threads)
3521 (setq thread (list (car (gnus-id-to-thread id))))
3522 ;; Get the thread this article is part of.
3523 (setq thread (gnus-remove-thread id)))
3524 (setq old-pos (gnus-point-at-bol))
3525 (setq current (save-excursion
3526 (and (zerop (forward-line -1))
3527 (gnus-summary-article-number))))
3528 ;; If this is a gathered thread, we have to go some re-gathering.
3529 (when (stringp (car thread))
3530 (let ((subject (car thread))
3532 (setq thread (cdr thread))
3534 (unless (memq (setq thr (gnus-id-to-thread
3536 (mail-header-id (caar thread)))))
3539 (setq thread (cdr thread)))
3540 ;; We now have all (unique) roots.
3541 (if (= (length roots) 1)
3542 ;; All the loose roots are now one solid root.
3543 (setq thread (car roots))
3544 (setq thread (cons subject (gnus-sort-threads roots))))))
3546 ;; We then insert this thread into the summary buffer.
3548 (goto-char (point-min))
3549 (forward-line (1- line)))
3550 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3551 (if gnus-show-threads
3552 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3553 (gnus-summary-prepare-unthreaded thread))
3554 (setq data (nreverse gnus-newsgroup-data))
3555 (setq threads gnus-newsgroup-threads))
3556 ;; We splice the new data into the data structure.
3557 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3558 ;;!!! then we want to insert at the beginning of the buffer.
3559 ;;!!! That happens to be true with Gnus now, but that may
3560 ;;!!! change in the future. Perhaps.
3561 (gnus-data-enter-list
3562 (if line nil current) data (- (point) old-pos))
3563 (setq gnus-newsgroup-threads
3564 (nconc threads gnus-newsgroup-threads))
3565 (gnus-data-compute-positions))))
3567 (defun gnus-number-to-header (number)
3568 "Return the header for article NUMBER."
3569 (let ((headers gnus-newsgroup-headers))
3571 (not (= number (mail-header-number (car headers)))))
3576 (defun gnus-parent-headers (in-headers &optional generation)
3577 "Return the headers of the GENERATIONeth parent of HEADERS."
3579 (setq generation 1))
3581 (headers in-headers)
3584 (not (zerop generation))
3585 (setq references (mail-header-references headers)))
3586 (setq headers (if (and references
3587 (setq parent (gnus-parent-id references)))
3588 (car (gnus-id-to-thread parent))
3591 (and (not (eq headers in-headers))
3594 (defun gnus-id-to-thread (id)
3595 "Return the (sub-)thread where ID appears."
3596 (gnus-gethash id gnus-newsgroup-dependencies))
3598 (defun gnus-id-to-article (id)
3599 "Return the article number of ID."
3600 (let ((thread (gnus-id-to-thread id)))
3603 (mail-header-number (car thread)))))
3605 (defun gnus-id-to-header (id)
3606 "Return the article headers of ID."
3607 (car (gnus-id-to-thread id)))
3609 (defun gnus-article-displayed-root-p (article)
3610 "Say whether ARTICLE is a root(ish) article."
3611 (let ((level (gnus-summary-thread-level article))
3612 (refs (mail-header-references (gnus-summary-article-header article)))
3618 ((null (gnus-parent-id refs)) t)
3620 (null (setq particle (gnus-id-to-article
3621 (gnus-parent-id refs))))
3622 (null (gnus-summary-thread-level particle)))))))
3624 (defun gnus-root-id (id)
3625 "Return the id of the root of the thread where ID appears."
3627 (while (and id (setq prev (car (gnus-id-to-thread id))))
3629 id (gnus-parent-id (mail-header-references prev))))
3632 (defun gnus-articles-in-thread (thread)
3633 "Return the list of articles in THREAD."
3634 (cons (mail-header-number (car thread))
3635 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3637 (defun gnus-remove-thread (id &optional dont-remove)
3638 "Remove the thread that has ID in it."
3639 (let (headers thread last-id)
3640 ;; First go up in this thread until we find the root.
3641 (setq last-id (gnus-root-id id)
3642 headers (message-flatten-list (gnus-id-to-thread last-id)))
3643 ;; We have now found the real root of this thread. It might have
3644 ;; been gathered into some loose thread, so we have to search
3645 ;; through the threads to find the thread we wanted.
3646 (let ((threads gnus-newsgroup-threads)
3649 (setq sub (car threads))
3650 (if (stringp (car sub))
3651 ;; This is a gathered thread, so we look at the roots
3652 ;; below it to find whether this article is in this
3655 (setq sub (cdr sub))
3657 (when (member (caar sub) headers)
3658 (setq thread (car threads)
3661 (setq sub (cdr sub))))
3662 ;; It's an ordinary thread, so we check it.
3663 (when (eq (car sub) (car headers))
3666 (setq threads (cdr threads)))
3667 ;; If this article is in no thread, then it's a root.
3670 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3671 (setq thread (gnus-id-to-thread last-id)))
3674 thread ; We return this thread.
3676 (if (stringp (car thread))
3678 ;; If we use dummy roots, then we have to remove the
3679 ;; dummy root as well.
3680 (when (eq gnus-summary-make-false-root 'dummy)
3681 ;; We go to the dummy root by going to
3682 ;; the first sub-"thread", and then one line up.
3683 (gnus-summary-goto-article
3684 (mail-header-number (caadr thread)))
3687 (gnus-data-compute-positions))
3688 (setq thread (cdr thread))
3690 (gnus-remove-thread-1 (car thread))
3691 (setq thread (cdr thread))))
3692 (gnus-remove-thread-1 thread))))))))
3694 (defun gnus-remove-thread-1 (thread)
3695 "Remove the thread THREAD recursively."
3696 (let ((number (mail-header-number (pop thread)))
3698 (setq thread (reverse thread))
3700 (gnus-remove-thread-1 (pop thread)))
3701 (when (setq d (gnus-data-find number))
3702 (goto-char (gnus-data-pos d))
3703 (gnus-summary-show-thread)
3706 (- (gnus-point-at-bol)
3708 (1+ (gnus-point-at-eol))
3709 (gnus-delete-line)))))))
3711 (defun gnus-sort-threads-1 (threads func)
3712 (sort (mapcar (lambda (thread)
3715 (gnus-sort-threads-1 (cdr thread) func))))
3718 (defun gnus-sort-threads (threads)
3720 (if (not gnus-thread-sort-functions)
3722 (gnus-message 8 "Sorting threads...")
3724 (gnus-sort-threads-1
3726 (gnus-make-sort-function gnus-thread-sort-functions))
3727 (gnus-message 8 "Sorting threads...done"))))
3729 (defun gnus-sort-articles (articles)
3731 (when gnus-article-sort-functions
3732 (gnus-message 7 "Sorting articles...")
3734 (setq gnus-newsgroup-headers
3735 (sort articles (gnus-make-sort-function
3736 gnus-article-sort-functions)))
3737 (gnus-message 7 "Sorting articles...done"))))
3739 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3740 (defmacro gnus-thread-header (thread)
3741 "Return header of first article in THREAD.
3742 Note that THREAD must never, ever be anything else than a variable -
3743 using some other form will lead to serious barfage."
3744 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3745 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3746 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3749 (defsubst gnus-article-sort-by-number (h1 h2)
3750 "Sort articles by article number."
3751 (< (mail-header-number h1)
3752 (mail-header-number h2)))
3754 (defun gnus-thread-sort-by-number (h1 h2)
3755 "Sort threads by root article number."
3756 (gnus-article-sort-by-number
3757 (gnus-thread-header h1) (gnus-thread-header h2)))
3759 (defsubst gnus-article-sort-by-lines (h1 h2)
3760 "Sort articles by article Lines header."
3761 (< (mail-header-lines h1)
3762 (mail-header-lines h2)))
3764 (defun gnus-thread-sort-by-lines (h1 h2)
3765 "Sort threads by root article Lines header."
3766 (gnus-article-sort-by-lines
3767 (gnus-thread-header h1) (gnus-thread-header h2)))
3769 (defsubst gnus-article-sort-by-chars (h1 h2)
3770 "Sort articles by octet length."
3771 (< (mail-header-chars h1)
3772 (mail-header-chars h2)))
3774 (defun gnus-thread-sort-by-chars (h1 h2)
3775 "Sort threads by root article octet length."
3776 (gnus-article-sort-by-chars
3777 (gnus-thread-header h1) (gnus-thread-header h2)))
3779 (defsubst gnus-article-sort-by-author (h1 h2)
3780 "Sort articles by root author."
3782 (let ((addr (car (mime-entity-read-field h1 'From))))
3783 (or (std11-full-name-string addr)
3784 (std11-address-string addr)
3786 (let ((addr (car (mime-entity-read-field h2 'From))))
3787 (or (std11-full-name-string addr)
3788 (std11-address-string addr)
3792 (defun gnus-thread-sort-by-author (h1 h2)
3793 "Sort threads by root author."
3794 (gnus-article-sort-by-author
3795 (gnus-thread-header h1) (gnus-thread-header h2)))
3797 (defsubst gnus-article-sort-by-subject (h1 h2)
3798 "Sort articles by root subject."
3800 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3801 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3803 (defun gnus-thread-sort-by-subject (h1 h2)
3804 "Sort threads by root subject."
3805 (gnus-article-sort-by-subject
3806 (gnus-thread-header h1) (gnus-thread-header h2)))
3808 (defsubst gnus-article-sort-by-date (h1 h2)
3809 "Sort articles by root article date."
3811 (gnus-date-get-time (mail-header-date h1))
3812 (gnus-date-get-time (mail-header-date h2))))
3814 (defun gnus-thread-sort-by-date (h1 h2)
3815 "Sort threads by root article date."
3816 (gnus-article-sort-by-date
3817 (gnus-thread-header h1) (gnus-thread-header h2)))
3819 (defsubst gnus-article-sort-by-score (h1 h2)
3820 "Sort articles by root article score.
3821 Unscored articles will be counted as having a score of zero."
3822 (> (or (cdr (assq (mail-header-number h1)
3823 gnus-newsgroup-scored))
3824 gnus-summary-default-score 0)
3825 (or (cdr (assq (mail-header-number h2)
3826 gnus-newsgroup-scored))
3827 gnus-summary-default-score 0)))
3829 (defun gnus-thread-sort-by-score (h1 h2)
3830 "Sort threads by root article score."
3831 (gnus-article-sort-by-score
3832 (gnus-thread-header h1) (gnus-thread-header h2)))
3834 (defun gnus-thread-sort-by-total-score (h1 h2)
3835 "Sort threads by the sum of all scores in the thread.
3836 Unscored articles will be counted as having a score of zero."
3837 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3839 (defun gnus-thread-total-score (thread)
3840 ;; This function find the total score of THREAD.
3841 (cond ((null thread)
3844 (if (stringp (car thread))
3845 (apply gnus-thread-score-function 0
3846 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3847 (gnus-thread-total-score-1 thread)))
3849 (gnus-thread-total-score-1 (list thread)))))
3851 (defun gnus-thread-total-score-1 (root)
3852 ;; This function find the total score of the thread below ROOT.
3853 (setq root (car root))
3854 (apply gnus-thread-score-function
3856 (mapcar 'gnus-thread-total-score
3857 (cdr (gnus-id-to-thread (mail-header-id root))))
3858 (when (> (mail-header-number root) 0)
3859 (list (or (cdr (assq (mail-header-number root)
3860 gnus-newsgroup-scored))
3861 gnus-summary-default-score 0))))
3862 (list gnus-summary-default-score)
3865 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3866 (defvar gnus-tmp-prev-subject nil)
3867 (defvar gnus-tmp-false-parent nil)
3868 (defvar gnus-tmp-root-expunged nil)
3869 (defvar gnus-tmp-dummy-line nil)
3871 (defvar gnus-tmp-header)
3872 (defun gnus-extra-header (type &optional header)
3873 "Return the extra header of TYPE."
3874 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3877 (defun gnus-summary-prepare-threads (threads)
3878 "Prepare summary buffer from THREADS and indentation LEVEL.
3879 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3880 or a straight list of headers."
3881 (gnus-message 7 "Generating summary...")
3883 (setq gnus-newsgroup-threads threads)
3886 (let ((gnus-tmp-level 0)
3887 (default-score (or gnus-summary-default-score 0))
3888 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3889 thread number subject stack state gnus-tmp-gathered beg-match
3890 new-roots gnus-tmp-new-adopts thread-end
3891 gnus-tmp-header gnus-tmp-unread
3892 gnus-tmp-replied gnus-tmp-subject-or-nil
3893 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3894 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3895 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3897 (setq gnus-tmp-prev-subject nil)
3899 (if (vectorp (car threads))
3900 ;; If this is a straight (sic) list of headers, then a
3901 ;; threaded summary display isn't required, so we just create
3902 ;; an unthreaded one.
3903 (gnus-summary-prepare-unthreaded threads)
3905 ;; Do the threaded display.
3907 (while (or threads stack gnus-tmp-new-adopts new-roots)
3909 (if (and (= gnus-tmp-level 0)
3912 (not gnus-tmp-false-parent)
3913 (or gnus-tmp-new-adopts new-roots))
3914 (if gnus-tmp-new-adopts
3915 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3916 thread (list (car gnus-tmp-new-adopts))
3917 gnus-tmp-header (caar thread)
3918 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3920 (setq thread (list (car new-roots))
3921 gnus-tmp-header (caar thread)
3922 new-roots (cdr new-roots))))
3925 ;; If there are some threads, we do them before the
3926 ;; threads on the stack.
3927 (setq thread threads
3928 gnus-tmp-header (caar thread))
3929 ;; There were no current threads, so we pop something off
3931 (setq state (car stack)
3932 gnus-tmp-level (car state)
3935 gnus-tmp-header (caar thread))))
3937 (setq gnus-tmp-false-parent nil)
3938 (setq gnus-tmp-root-expunged nil)
3939 (setq thread-end nil)
3941 (if (stringp gnus-tmp-header)
3942 ;; The header is a dummy root.
3944 ((eq gnus-summary-make-false-root 'adopt)
3945 ;; We let the first article adopt the rest.
3946 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3948 (setq gnus-tmp-gathered
3950 (lambda (h) (mail-header-number (car h)))
3953 (setq thread (cons (list (caar thread)
3956 (setq gnus-tmp-level -1
3957 gnus-tmp-false-parent t))
3958 ((eq gnus-summary-make-false-root 'empty)
3959 ;; We print adopted articles with empty subject fields.
3960 (setq gnus-tmp-gathered
3962 (lambda (h) (mail-header-number (car h)))
3965 (setq gnus-tmp-level -1))
3966 ((eq gnus-summary-make-false-root 'dummy)
3967 ;; We remember that we probably want to output a dummy
3969 (setq gnus-tmp-dummy-line gnus-tmp-header)
3970 (setq gnus-tmp-prev-subject gnus-tmp-header))
3972 ;; We do not make a root for the gathered
3973 ;; sub-threads at all.
3974 (setq gnus-tmp-level -1)))
3976 (setq number (mail-header-number gnus-tmp-header)
3977 subject (mail-header-subject gnus-tmp-header))
3980 ;; If the thread has changed subject, we might want to make
3981 ;; this subthread into a root.
3982 ((and (null gnus-thread-ignore-subject)
3983 (not (zerop gnus-tmp-level))
3984 gnus-tmp-prev-subject
3986 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3987 (setq new-roots (nconc new-roots (list (car thread)))
3989 gnus-tmp-header nil))
3990 ;; If the article lies outside the current limit,
3991 ;; then we do not display it.
3992 ((not (memq number gnus-newsgroup-limit))
3993 (setq gnus-tmp-gathered
3995 (lambda (h) (mail-header-number (car h)))
3998 (setq gnus-tmp-new-adopts (if (cdar thread)
3999 (append gnus-tmp-new-adopts
4001 gnus-tmp-new-adopts)
4003 gnus-tmp-header nil)
4004 (when (zerop gnus-tmp-level)
4005 (setq gnus-tmp-root-expunged t)))
4006 ;; Perhaps this article is to be marked as read?
4007 ((and gnus-summary-mark-below
4008 (< (or (cdr (assq number gnus-newsgroup-scored))
4010 gnus-summary-mark-below)
4011 ;; Don't touch sparse articles.
4012 (not (gnus-summary-article-sparse-p number))
4013 (not (gnus-summary-article-ancient-p number)))
4014 (setq gnus-newsgroup-unreads
4015 (delq number gnus-newsgroup-unreads))
4016 (if gnus-newsgroup-auto-expire
4017 (push number gnus-newsgroup-expirable)
4018 (push (cons number gnus-low-score-mark)
4019 gnus-newsgroup-reads))))
4021 (when gnus-tmp-header
4022 ;; We may have an old dummy line to output before this
4024 (when (and gnus-tmp-dummy-line
4027 (mail-header-subject gnus-tmp-header)))
4028 (gnus-summary-insert-dummy-line
4029 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4030 (setq gnus-tmp-dummy-line nil))
4032 ;; Compute the mark.
4033 (setq gnus-tmp-unread (gnus-article-mark number))
4035 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4036 gnus-tmp-header gnus-tmp-level)
4037 gnus-newsgroup-data)
4039 ;; Actually insert the line.
4041 gnus-tmp-subject-or-nil
4043 ((and gnus-thread-ignore-subject
4044 gnus-tmp-prev-subject
4045 (not (inline (gnus-subject-equal
4046 gnus-tmp-prev-subject subject))))
4048 ((zerop gnus-tmp-level)
4049 (if (and (eq gnus-summary-make-false-root 'empty)
4050 (memq number gnus-tmp-gathered)
4051 gnus-tmp-prev-subject
4052 (inline (gnus-subject-equal
4053 gnus-tmp-prev-subject subject)))
4054 gnus-summary-same-subject
4056 (t gnus-summary-same-subject)))
4057 (if (and (eq gnus-summary-make-false-root 'adopt)
4058 (= gnus-tmp-level 1)
4059 (memq number gnus-tmp-gathered))
4060 (setq gnus-tmp-opening-bracket ?\<
4061 gnus-tmp-closing-bracket ?\>)
4062 (setq gnus-tmp-opening-bracket ?\[
4063 gnus-tmp-closing-bracket ?\]))
4065 gnus-tmp-indentation
4066 (aref gnus-thread-indent-array gnus-tmp-level)
4067 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4068 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4069 gnus-summary-default-score 0)
4071 (if (or (null gnus-summary-default-score)
4072 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4073 gnus-summary-zcore-fuzz))
4075 (if (< gnus-tmp-score gnus-summary-default-score)
4076 gnus-score-below-mark gnus-score-over-mark))
4078 (cond ((memq number gnus-newsgroup-processable)
4080 ((memq number gnus-newsgroup-cached)
4082 ((memq number gnus-newsgroup-replied)
4084 ((memq number gnus-newsgroup-saved)
4086 (t gnus-unread-mark))
4087 gnus-tmp-from (mail-header-from gnus-tmp-header)
4090 ((string-match "<[^>]+> *$" gnus-tmp-from)
4091 (setq beg-match (match-beginning 0))
4092 (or (and (string-match "^\".+\"" gnus-tmp-from)
4093 (substring gnus-tmp-from 1 (1- (match-end 0))))
4094 (substring gnus-tmp-from 0 beg-match)))
4095 ((string-match "(.+)" gnus-tmp-from)
4096 (substring gnus-tmp-from
4097 (1+ (match-beginning 0)) (1- (match-end 0))))
4099 (when (string= gnus-tmp-name "")
4100 (setq gnus-tmp-name gnus-tmp-from))
4101 (unless (numberp gnus-tmp-lines)
4102 (setq gnus-tmp-lines 0))
4103 (gnus-put-text-property
4105 (progn (eval gnus-summary-line-format-spec) (point))
4106 'gnus-number number)
4109 (gnus-run-hooks 'gnus-summary-update-hook)
4112 (setq gnus-tmp-prev-subject subject)))
4114 (when (nth 1 thread)
4115 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4116 (incf gnus-tmp-level)
4117 (setq threads (if thread-end nil (cdar thread)))
4119 (setq gnus-tmp-level 0)))))
4120 (gnus-message 7 "Generating summary...done"))
4122 (defun gnus-summary-prepare-unthreaded (headers)
4123 "Generate an unthreaded summary buffer based on HEADERS."
4124 (let (header number mark)
4129 ;; We may have to root out some bad articles...
4130 (when (memq (setq number (mail-header-number
4131 (setq header (pop headers))))
4132 gnus-newsgroup-limit)
4133 ;; Mark article as read when it has a low score.
4134 (when (and gnus-summary-mark-below
4135 (< (or (cdr (assq number gnus-newsgroup-scored))
4136 gnus-summary-default-score 0)
4137 gnus-summary-mark-below)
4138 (not (gnus-summary-article-ancient-p number)))
4139 (setq gnus-newsgroup-unreads
4140 (delq number gnus-newsgroup-unreads))
4141 (if gnus-newsgroup-auto-expire
4142 (push number gnus-newsgroup-expirable)
4143 (push (cons number gnus-low-score-mark)
4144 gnus-newsgroup-reads)))
4146 (setq mark (gnus-article-mark number))
4147 (push (gnus-data-make number mark (1+ (point)) header 0)
4148 gnus-newsgroup-data)
4149 (gnus-summary-insert-line
4151 mark (memq number gnus-newsgroup-replied)
4152 (memq number gnus-newsgroup-expirable)
4153 (mail-header-subject header) nil
4154 (cdr (assq number gnus-newsgroup-scored))
4155 (memq number gnus-newsgroup-processable))))))
4157 (defun gnus-summary-remove-list-identifiers ()
4158 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4159 (let ((regexp (if (stringp gnus-list-identifiers)
4160 gnus-list-identifiers
4161 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4162 (dolist (header gnus-newsgroup-headers)
4163 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4164 " *\\)\\)+\\(Re: +\\)?\\)")
4165 (mail-header-subject header))
4166 (mail-header-set-subject
4167 header (concat (substring (mail-header-subject header)
4168 0 (match-beginning 1))
4170 (match-string 3 (mail-header-subject header))
4171 (match-string 5 (mail-header-subject header)))
4172 (substring (mail-header-subject header)
4173 (match-end 1))))))))
4175 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4176 "Select newsgroup GROUP.
4177 If READ-ALL is non-nil, all articles in the group are selected.
4178 If SELECT-ARTICLES, only select those articles from GROUP."
4179 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4180 ;;!!! Dirty hack; should be removed.
4181 (gnus-summary-ignore-duplicates
4182 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4184 gnus-summary-ignore-duplicates))
4185 (info (nth 2 entry))
4186 articles fetched-articles cached)
4188 (unless (gnus-check-server
4189 (setq gnus-current-select-method
4190 (gnus-find-method-for-group group)))
4191 (error "Couldn't open server"))
4193 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4194 (gnus-activate-group group) ; Or we can activate it...
4195 (progn ; Or we bug out.
4196 (when (equal major-mode 'gnus-summary-mode)
4197 (kill-buffer (current-buffer)))
4198 (error "Couldn't request group %s: %s"
4199 group (gnus-status-message group))))
4201 (unless (gnus-request-group group t)
4202 (when (equal major-mode 'gnus-summary-mode)
4203 (kill-buffer (current-buffer)))
4204 (error "Couldn't request group %s: %s"
4205 group (gnus-status-message group)))
4207 (setq gnus-newsgroup-name group)
4208 (setq gnus-newsgroup-unselected nil)
4209 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4210 (gnus-summary-setup-default-charset)
4212 ;; Adjust and set lists of article marks.
4214 (gnus-adjust-marked-articles info))
4216 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4218 (if (gnus-virtual-group-p group)
4219 gnus-newsgroup-cached
4220 (gnus-cache-articles-in-group group)))
4222 (setq gnus-newsgroup-unreads
4223 (gnus-set-difference
4224 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4225 gnus-newsgroup-dormant))
4227 (setq gnus-newsgroup-processable nil)
4229 (gnus-update-read-articles group gnus-newsgroup-unreads)
4231 (if (setq articles select-articles)
4232 (setq gnus-newsgroup-unselected
4233 (gnus-sorted-intersection
4234 gnus-newsgroup-unreads
4235 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4236 (setq articles (gnus-articles-to-read group read-all)))
4240 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4242 ((eq articles 0) nil)
4244 ;; Init the dependencies hash table.
4245 (setq gnus-newsgroup-dependencies
4246 (gnus-make-hashtable (length articles)))
4247 (gnus-set-global-variables)
4248 ;; Retrieve the headers and read them in.
4249 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4250 (setq gnus-newsgroup-headers
4251 (gnus-retrieve-parsed-headers
4252 articles gnus-newsgroup-name
4253 ;; We might want to fetch old headers, but
4254 ;; not if there is only 1 article.
4255 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4256 (not (numberp gnus-fetch-old-headers)))
4257 (> (length articles) 1))
4258 gnus-fetch-old-headers)))
4259 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4261 ;; Suppress duplicates?
4262 (when gnus-suppress-duplicates
4263 (gnus-dup-suppress-articles))
4265 ;; Set the initial limit.
4266 (setq gnus-newsgroup-limit (copy-sequence articles))
4267 ;; Remove canceled articles from the list of unread articles.
4268 (setq gnus-newsgroup-unreads
4269 (gnus-set-sorted-intersection
4270 gnus-newsgroup-unreads
4271 (setq fetched-articles
4272 (mapcar (lambda (headers) (mail-header-number headers))
4273 gnus-newsgroup-headers))))
4274 ;; Removed marked articles that do not exist.
4275 (gnus-update-missing-marks
4276 (gnus-sorted-complement fetched-articles articles))
4278 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4280 (setq gnus-newsgroup-cached cached))
4282 ;; We might want to build some more threads first.
4283 (when (and gnus-fetch-old-headers
4284 (eq gnus-headers-retrieved-by 'nov))
4285 (if (eq gnus-fetch-old-headers 'invisible)
4286 (gnus-build-all-threads)
4287 (gnus-build-old-threads)))
4288 ;; Let the Gnus agent mark articles as read.
4290 (gnus-agent-get-undownloaded-list))
4291 ;; Remove list identifiers from subject
4292 (when gnus-list-identifiers
4293 (gnus-summary-remove-list-identifiers))
4294 ;; Check whether auto-expire is to be done in this group.
4295 (setq gnus-newsgroup-auto-expire
4296 (gnus-group-auto-expirable-p group))
4297 ;; Set up the article buffer now, if necessary.
4298 (unless gnus-single-article-buffer
4299 (gnus-article-setup-buffer))
4300 ;; First and last article in this newsgroup.
4301 (when gnus-newsgroup-headers
4302 (setq gnus-newsgroup-begin
4303 (mail-header-number (car gnus-newsgroup-headers))
4306 (gnus-last-element gnus-newsgroup-headers))))
4307 ;; GROUP is successfully selected.
4308 (or gnus-newsgroup-headers t)))))
4310 (defun gnus-articles-to-read (group &optional read-all)
4311 "Find out what articles the user wants to read."
4313 ;; Select all articles if `read-all' is non-nil, or if there
4314 ;; are no unread articles.
4316 (and (zerop (length gnus-newsgroup-marked))
4317 (zerop (length gnus-newsgroup-unreads)))
4318 (eq (gnus-group-find-parameter group 'display)
4321 (gnus-uncompress-range (gnus-active group))
4322 (gnus-cache-articles-in-group group))
4323 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4324 (copy-sequence gnus-newsgroup-unreads))
4326 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4327 (scored (length scored-list))
4328 (number (length articles))
4329 (marked (+ (length gnus-newsgroup-marked)
4330 (length gnus-newsgroup-dormant)))
4338 ((and (or (<= scored marked) (= scored number))
4339 (natnump gnus-large-newsgroup)
4340 (> number gnus-large-newsgroup))
4341 (let* ((cursor-in-echo-area nil)
4342 (input (read-from-minibuffer
4344 "How many articles from %s (max %d): "
4345 (gnus-limit-string gnus-newsgroup-name 35)
4347 (cons (number-to-string gnus-large-newsgroup)
4349 (if (string-match "^[ \t]*$" input)
4352 ((and (> scored marked) (< scored number)
4353 (> (- scored number) 20))
4356 (format "%s %s (%d scored, %d total): "
4357 "How many articles from"
4358 group scored number))))
4359 (if (string-match "^[ \t]*$" input)
4363 (message "Quit getting the articles to read")
4365 (setq select (if (stringp select) (string-to-number select) select))
4366 (if (or (null select) (zerop select))
4368 (if (and (not (zerop scored)) (<= (abs select) scored))
4370 (setq articles (sort scored-list '<))
4371 (setq number (length articles)))
4372 (setq articles (copy-sequence articles)))
4374 (when (< (abs select) number)
4376 ;; Select the N oldest articles.
4377 (setcdr (nthcdr (1- (abs select)) articles) nil)
4378 ;; Select the N most recent articles.
4379 (setq articles (nthcdr (- number select) articles))))
4380 (setq gnus-newsgroup-unselected
4381 (gnus-sorted-intersection
4382 gnus-newsgroup-unreads
4383 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4384 (when gnus-alter-articles-to-read-function
4385 (setq gnus-newsgroup-unreads
4387 (funcall gnus-alter-articles-to-read-function
4388 gnus-newsgroup-name gnus-newsgroup-unreads)
4392 (defun gnus-killed-articles (killed articles)
4395 (when (inline (gnus-member-of-range (car articles) killed))
4396 (push (car articles) out))
4397 (setq articles (cdr articles)))
4400 (defun gnus-uncompress-marks (marks)
4401 "Uncompress the mark ranges in MARKS."
4402 (let ((uncompressed '(score bookmark))
4405 (if (memq (caar marks) uncompressed)
4406 (push (car marks) out)
4407 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4408 (setq marks (cdr marks)))
4411 (defun gnus-adjust-marked-articles (info)
4412 "Set all article lists and remove all marks that are no longer valid."
4413 (let* ((marked-lists (gnus-info-marks info))
4414 (active (gnus-active (gnus-info-group info)))
4417 (types gnus-article-mark-lists)
4418 (uncompressed '(score bookmark killed))
4419 marks var articles article mark)
4422 (setq marks (pop marked-lists))
4423 (set (setq var (intern (format "gnus-newsgroup-%s"
4424 (car (rassq (setq mark (car marks))
4426 (if (memq (car marks) uncompressed) (cdr marks)
4427 (gnus-uncompress-range (cdr marks))))
4429 (setq articles (symbol-value var))
4431 ;; All articles have to be subsets of the active articles.
4433 ;; Adjust "simple" lists.
4434 ((memq mark '(tick dormant expire reply save))
4436 (when (or (< (setq article (pop articles)) min) (> article max))
4437 (set var (delq article (symbol-value var))))))
4439 ((memq mark uncompressed)
4440 (when (not (listp (cdr (symbol-value var))))
4441 (set var (list (symbol-value var))))
4442 (when (not (listp (cdr articles)))
4443 (setq articles (list articles)))
4445 (when (or (not (consp (setq article (pop articles))))
4446 (< (car article) min)
4447 (> (car article) max))
4448 (set var (delq article (symbol-value var))))))))))
4450 (defun gnus-update-missing-marks (missing)
4451 "Go through the list of MISSING articles and remove them from the mark lists."
4453 (let ((types gnus-article-mark-lists)
4455 ;; Go through all types.
4457 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4458 (when (symbol-value var)
4459 ;; This list has articles. So we delete all missing articles
4463 (set var (delq (pop m) (symbol-value var)))))))))
4465 (defun gnus-update-marks ()
4466 "Enter the various lists of marked articles into the newsgroup info list."
4467 (let ((types gnus-article-mark-lists)
4468 (info (gnus-get-info gnus-newsgroup-name))
4469 (uncompressed '(score bookmark killed))
4470 type list newmarked symbol delta-marks)
4472 ;; Add all marks lists to the list of marks lists.
4473 (while (setq type (pop types))
4474 (setq list (symbol-value
4476 (intern (format "gnus-newsgroup-%s"
4480 ;; Get rid of the entries of the articles that have the
4482 (when (and (eq (cdr type) 'score)
4486 (prev (cons nil list))
4489 (if (or (not (consp (car arts)))
4490 (= (cdar arts) gnus-summary-default-score))
4491 (setcdr prev (cdr arts))
4493 (setq arts (cdr arts)))
4494 (setq list (cdr all)))))
4496 (unless (memq (cdr type) uncompressed)
4497 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4499 (when (gnus-check-backend-function
4500 'request-set-mark gnus-newsgroup-name)
4501 ;; propagate flags to server, with the following exceptions:
4502 ;; uncompressed:s are not proper flags (they are cons cells)
4503 ;; cache is a internal gnus flag
4504 ;; download are local to one gnus installation (well)
4505 ;; unsend are for nndraft groups only
4506 ;; xxx: generality of this? this suits nnimap anyway
4507 (unless (memq (cdr type) (append '(cache download unsend)
4509 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4510 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4511 (add (gnus-remove-from-range
4512 (gnus-copy-sequence list) old)))
4514 (push (list add 'add (list (cdr type))) delta-marks))
4516 (push (list del 'del (list (cdr type))) delta-marks)))))
4519 (push (cons (cdr type) list) newmarked)))
4522 (unless (gnus-check-group gnus-newsgroup-name)
4523 (error "Can't open server for %s" gnus-newsgroup-name))
4524 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4526 ;; Enter these new marks into the info of the group.
4528 (setcar (nthcdr 3 info) newmarked)
4529 ;; Add the marks lists to the end of the info.
4531 (setcdr (nthcdr 2 info) (list newmarked))))
4533 ;; Cut off the end of the info if there's nothing else there.
4537 (when (nthcdr (decf i) info)
4538 (setcdr (nthcdr i info) nil)))))))
4540 (defun gnus-set-mode-line (where)
4541 "Set the mode line of the article or summary buffers.
4542 If WHERE is `summary', the summary mode line format will be used."
4543 ;; Is this mode line one we keep updated?
4544 (when (and (memq where gnus-updated-mode-lines)
4546 (intern (format "gnus-%s-mode-line-format-spec" where))))
4549 ;; We evaluate this in the summary buffer since these
4550 ;; variables are buffer-local to that buffer.
4551 (set-buffer gnus-summary-buffer)
4552 ;; We bind all these variables that are used in the `eval' form
4554 (let* ((mformat (symbol-value
4556 (format "gnus-%s-mode-line-format-spec" where))))
4557 (gnus-tmp-group-name (gnus-group-name-decode
4559 (gnus-group-name-charset
4561 gnus-newsgroup-name)))
4562 (gnus-tmp-article-number (or gnus-current-article 0))
4563 (gnus-tmp-unread gnus-newsgroup-unreads)
4564 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4565 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4566 (gnus-tmp-unread-and-unselected
4567 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4568 (zerop gnus-tmp-unselected))
4570 ((zerop gnus-tmp-unselected)
4571 (format "{%d more}" gnus-tmp-unread-and-unticked))
4572 (t (format "{%d(+%d) more}"
4573 gnus-tmp-unread-and-unticked
4574 gnus-tmp-unselected))))
4576 (if (and gnus-current-headers
4577 (vectorp gnus-current-headers))
4578 (gnus-mode-string-quote
4579 (mail-header-subject gnus-current-headers))
4581 bufname-length max-len
4582 gnus-tmp-header);; passed as argument to any user-format-funcs
4583 (setq mode-string (eval mformat))
4584 (setq bufname-length (if (string-match "%b" mode-string)
4587 (if (eq where 'summary)
4589 (get-buffer gnus-article-buffer))))
4592 (setq max-len (max 4 (if gnus-mode-non-string-length
4594 gnus-mode-non-string-length
4596 (length mode-string))))
4597 ;; We might have to chop a bit of the string off...
4598 (when (> (length mode-string) max-len)
4600 (concat (gnus-truncate-string mode-string (- max-len 3))
4602 ;; Pad the mode string a bit.
4603 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4604 ;; Update the mode line.
4605 (setq mode-line-buffer-identification
4606 (gnus-mode-line-buffer-identification (list mode-string)))
4607 (set-buffer-modified-p t))))
4609 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4610 "Go through the HEADERS list and add all Xrefs to a hash table.
4611 The resulting hash table is returned, or nil if no Xrefs were found."
4612 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4613 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4614 (xref-hashtb (gnus-make-hashtable))
4615 start group entry number xrefs header)
4617 (setq header (pop headers))
4618 (when (and (setq xrefs (mail-header-xref header))
4619 (not (memq (setq number (mail-header-number header))
4622 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4623 (setq start (match-end 0))
4624 (setq group (if prefix
4625 (concat prefix (substring xrefs (match-beginning 1)
4627 (substring xrefs (match-beginning 1) (match-end 1))))
4629 (string-to-int (substring xrefs (match-beginning 2)
4631 (if (setq entry (gnus-gethash group xref-hashtb))
4632 (setcdr entry (cons number (cdr entry)))
4633 (gnus-sethash group (cons number nil) xref-hashtb)))))
4634 (and start xref-hashtb)))
4636 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4637 "Look through all the headers and mark the Xrefs as read."
4638 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4639 name entry info xref-hashtb idlist method nth4)
4641 (set-buffer gnus-group-buffer)
4642 (when (setq xref-hashtb
4643 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4646 (unless (string= from-newsgroup (setq name (symbol-name group)))
4647 (setq idlist (symbol-value group))
4648 ;; Dead groups are not updated.
4650 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4652 (when (stringp (setq nth4 (gnus-info-method info)))
4653 (setq nth4 (gnus-server-to-method nth4))))
4654 ;; Only do the xrefs if the group has the same
4655 ;; select method as the group we have just read.
4656 (or (gnus-methods-equal-p
4657 nth4 (gnus-find-method-for-group from-newsgroup))
4659 (equal nth4 (setq method (gnus-find-method-for-group
4661 (and (equal (car nth4) (car method))
4662 (equal (nth 1 nth4) (nth 1 method))))
4663 gnus-use-cross-reference
4664 (or (not (eq gnus-use-cross-reference t))
4666 ;; Only do cross-references on subscribed
4667 ;; groups, if that is what is wanted.
4668 (<= (gnus-info-level info) gnus-level-subscribed))
4669 (gnus-group-make-articles-read name idlist))))
4672 (defun gnus-compute-read-articles (group articles)
4673 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4674 (info (nth 2 entry))
4675 (active (gnus-active group))
4678 ;; First peel off all invalid article numbers.
4680 (let ((ids articles)
4682 (while (setq id (pop ids))
4683 (when (and first (> id (cdr active)))
4684 ;; We'll end up in this situation in one particular
4685 ;; obscure situation. If you re-scan a group and get
4686 ;; a new article that is cross-posted to a different
4687 ;; group that has not been re-scanned, you might get
4688 ;; crossposted article that has a higher number than
4689 ;; Gnus believes possible. So we re-activate this
4690 ;; group as well. This might mean doing the
4691 ;; crossposting thingy will *increase* the number
4692 ;; of articles in some groups. Tsk, tsk.
4693 (setq active (or (gnus-activate-group group) active)))
4694 (when (or (> id (cdr active))
4695 (< id (car active)))
4696 (setq articles (delq id articles))))))
4697 ;; If the read list is nil, we init it.
4699 (null (gnus-info-read info))
4701 (setq ninfo (cons 1 (1- (car active))))
4702 (setq ninfo (gnus-info-read info)))
4703 ;; Then we add the read articles to the range.
4705 ninfo (setq articles (sort articles '<))))))
4707 (defun gnus-group-make-articles-read (group articles)
4708 "Update the info of GROUP to say that ARTICLES are read."
4710 (entry (gnus-gethash group gnus-newsrc-hashtb))
4711 (info (nth 2 entry))
4712 (active (gnus-active group))
4715 (setq range (gnus-compute-read-articles group articles))
4717 (set-buffer gnus-group-buffer)
4720 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4721 (gnus-info-set-read ',info ',(gnus-info-read info))
4722 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4723 (gnus-group-update-group ,group t))))
4724 ;; Add the read articles to the range.
4725 (gnus-info-set-read info range)
4726 ;; Then we have to re-compute how many unread
4727 ;; articles there are in this group.
4731 (setq num (- (1+ (cdr active)) (car active))))
4732 ((not (listp (cdr range)))
4733 (setq num (- (cdr active) (- (1+ (cdr range))
4737 (if (numberp (car range))
4739 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4740 (setq range (cdr range)))
4741 (setq num (- (cdr active) num))))
4742 ;; Update the number of unread articles.
4744 ;; Update the group buffer.
4745 (gnus-group-update-group group t)))))
4747 (defvar gnus-newsgroup-none-id 0)
4749 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4750 (let ((cur nntp-server-buffer)
4753 (save-excursion (set-buffer gnus-summary-buffer)
4754 gnus-newsgroup-dependencies)))
4756 (mail-parse-charset gnus-newsgroup-charset)
4757 (mail-parse-ignored-charsets
4758 (save-excursion (condition-case nil
4759 (set-buffer gnus-summary-buffer)
4761 gnus-newsgroup-ignored-charsets)))
4763 (set-buffer nntp-server-buffer)
4764 ;; Translate all TAB characters into SPACE characters.
4765 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4766 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4767 (gnus-run-hooks 'gnus-parse-headers-hook)
4768 (let ((case-fold-search t)
4769 in-reply-to header p lines chars ctype)
4770 (goto-char (point-min))
4771 ;; Search to the beginning of the next header. Error messages
4772 ;; do not begin with 2 or 3.
4773 (while (re-search-forward "^[23][0-9]+ " nil t)
4776 ;; This implementation of this function, with nine
4777 ;; search-forwards instead of the one re-search-forward and
4778 ;; a case (which basically was the old function) is actually
4779 ;; about twice as fast, even though it looks messier. You
4780 ;; can't have everything, I guess. Speed and elegance
4781 ;; doesn't always go hand in hand.
4784 (make-full-mail-header
4790 (narrow-to-region (point)
4791 (or (and (search-forward "\n.\n" nil t)
4797 (if (search-forward "\nsubject: " nil t)
4798 (nnheader-header-value)
4803 (if (or (search-forward "\nfrom: " nil t)
4804 (search-forward "\nfrom:" nil t))
4805 (nnheader-header-value)
4810 (if (search-forward "\ndate: " nil t)
4811 (nnheader-header-value)
4816 (setq id (if (re-search-forward
4817 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4818 ;; We do it this way to make sure the Message-ID
4819 ;; is (somewhat) syntactically valid.
4820 (buffer-substring (match-beginning 1)
4822 ;; If there was no message-id, we just fake one
4823 ;; to make subsequent routines simpler.
4824 (nnheader-generate-fake-message-id))))
4828 (if (search-forward "\nreferences: " nil t)
4832 (nnheader-header-value)
4837 (search-backward ">" end t)
4840 (search-backward "<" end t)
4842 ;; Get the references from the in-reply-to header if there
4843 ;; were no references and the in-reply-to header looks
4845 (if (and (search-forward "\nin-reply-to: " nil t)
4846 (setq in-reply-to (nnheader-header-value))
4847 (string-match "<[^>]+>" in-reply-to))
4849 (setq ref (substring in-reply-to (match-beginning 0)
4851 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4852 (setq ref2 (substring in-reply-to (match-beginning 0)
4854 (when (> (length ref2) (length ref))
4861 (if (search-forward "\nchars: " nil t)
4862 (if (numberp (setq chars (ignore-errors (read cur))))
4868 (if (search-forward "\nlines: " nil t)
4869 (if (numberp (setq lines (ignore-errors (read cur))))
4875 (and (search-forward "\nxref: " nil t)
4876 (nnheader-header-value)))
4878 (when gnus-extra-headers
4879 (let ((extra gnus-extra-headers)
4883 (when (search-forward
4884 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4885 (push (cons (car extra) (nnheader-header-value)) out))
4889 (if (and (search-forward "\ncontent-type: " nil t)
4890 (setq ctype (nnheader-header-value)))
4891 (mime-entity-set-content-type-internal
4892 header (mime-parse-Content-Type ctype)))
4893 (when (equal id ref)
4896 (when gnus-alter-header-function
4897 (funcall gnus-alter-header-function header)
4898 (setq id (mail-header-id header)
4899 ref (gnus-parent-id (mail-header-references header))))
4902 (gnus-dependencies-add-header
4903 header dependencies force-new))
4904 (push header headers))
4905 (goto-char (point-max))
4907 (nreverse headers)))))
4909 ;; Goes through the xover lines and returns a list of vectors
4910 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4911 force-new dependencies
4912 group also-fetch-heads)
4913 "Parse the news overview data in the server buffer.
4914 Return a list of headers that match SEQUENCE (see
4915 `nntp-retrieve-headers')."
4916 ;; Get the Xref when the users reads the articles since most/some
4917 ;; NNTP servers do not include Xrefs when using XOVER.
4918 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4919 (let ((mail-parse-charset gnus-newsgroup-charset)
4920 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4921 (cur nntp-server-buffer)
4922 (dependencies (or dependencies gnus-newsgroup-dependencies))
4923 number headers header)
4925 (set-buffer nntp-server-buffer)
4926 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4927 ;; Allow the user to mangle the headers before parsing them.
4928 (gnus-run-hooks 'gnus-parse-headers-hook)
4929 (goto-char (point-min))
4932 (while (and sequence (not (eobp)))
4933 (setq number (read cur))
4934 (while (and sequence
4935 (< (car sequence) number))
4936 (setq sequence (cdr sequence)))
4938 (eq number (car sequence))
4940 (setq sequence (cdr sequence))
4941 (setq header (inline
4942 (gnus-nov-parse-line
4943 number dependencies force-new))))
4944 (push header headers))
4947 (gnus-error 4 "Strange nov line (%d)"
4948 (count-lines (point-min) (point)))))
4950 ;; A common bug in inn is that if you have posted an article and
4951 ;; then retrieves the active file, it will answer correctly --
4952 ;; the new article is included. However, a NOV entry for the
4953 ;; article may not have been generated yet, so this may fail.
4954 ;; We work around this problem by retrieving the last few
4955 ;; headers using HEAD.
4956 (if (or (not also-fetch-heads)
4958 ;; We (probably) got all the headers.
4960 (let ((gnus-nov-is-evil t))
4963 (gnus-retrieve-parsed-headers sequence group)
4966 (defun gnus-article-get-xrefs ()
4967 "Fill in the Xref value in `gnus-current-headers', if necessary.
4968 This is meant to be called in `gnus-article-internal-prepare-hook'."
4969 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4970 gnus-current-headers)))
4971 (or (not gnus-use-cross-reference)
4973 (and (mail-header-xref headers)
4974 (not (string= (mail-header-xref headers) "")))
4975 (let ((case-fold-search t)
4978 (nnheader-narrow-to-headers)
4979 (goto-char (point-min))
4980 (when (or (and (not (eobp))
4981 (eq (downcase (char-after)) ?x)
4982 (looking-at "Xref:"))
4983 (search-forward "\nXref:" nil t))
4984 (goto-char (1+ (match-end 0)))
4985 (setq xref (buffer-substring (point)
4986 (progn (end-of-line) (point))))
4987 (mail-header-set-xref headers xref)))))))
4989 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4990 "Find article ID and insert the summary line for that article.
4991 OLD-HEADER can either be a header or a line number to insert
4992 the subject line on."
4993 (let* ((line (and (numberp old-header) old-header))
4994 (old-header (and (vectorp old-header) old-header))
4995 (header (cond ((and old-header use-old-header)
4998 (gnus-number-to-header id))
4999 (gnus-number-to-header id))
5001 (gnus-read-header id))))
5002 (number (and (numberp id) id))
5005 ;; Rebuild the thread that this article is part of and go to the
5006 ;; article we have fetched.
5007 (when (and (not gnus-show-threads)
5010 (setq d (gnus-data-find (mail-header-number old-header))))
5011 (goto-char (gnus-data-pos d))
5014 (- (gnus-point-at-bol)
5016 (1+ (gnus-point-at-eol))
5017 (gnus-delete-line))))))
5019 (mail-header-set-number header (mail-header-number old-header)))
5020 (setq gnus-newsgroup-sparse
5021 (delq (setq number (mail-header-number header))
5022 gnus-newsgroup-sparse))
5023 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5024 (push number gnus-newsgroup-limit)
5025 (gnus-rebuild-thread (mail-header-id header) line)
5026 (gnus-summary-goto-subject number nil t))
5027 (when (and (numberp number)
5029 ;; We have to update the boundaries even if we can't fetch the
5030 ;; article if ID is a number -- so that the next `P' or `N'
5031 ;; command will fetch the previous (or next) article even
5032 ;; if the one we tried to fetch this time has been canceled.
5033 (when (> number gnus-newsgroup-end)
5034 (setq gnus-newsgroup-end number))
5035 (when (< number gnus-newsgroup-begin)
5036 (setq gnus-newsgroup-begin number))
5037 (setq gnus-newsgroup-unselected
5038 (delq number gnus-newsgroup-unselected)))
5039 ;; Report back a success?
5040 (and header (mail-header-number header))))
5042 ;;; Process/prefix in the summary buffer
5044 (defun gnus-summary-work-articles (n)
5045 "Return a list of articles to be worked upon.
5046 The prefix argument, the list of process marked articles, and the
5047 current article will be taken into consideration."
5049 (set-buffer gnus-summary-buffer)
5052 ;; A numerical prefix has been given.
5053 (setq n (prefix-numeric-value n))
5054 (let ((backward (< n 0))
5055 (n (abs (prefix-numeric-value n)))
5060 (push (setq article (gnus-summary-article-number))
5063 (gnus-summary-find-prev nil article)
5064 (gnus-summary-find-next nil article)))
5066 (nreverse articles)))
5067 ((and (gnus-region-active-p) (mark))
5068 (message "region active")
5069 ;; Work on the region between point and mark.
5070 (let ((max (max (point) (mark)))
5073 (goto-char (min (point) (mark)))
5076 (push (setq article (gnus-summary-article-number)) articles)
5077 (gnus-summary-find-next nil article)
5079 (nreverse articles))))
5080 (gnus-newsgroup-processable
5081 ;; There are process-marked articles present.
5082 ;; Save current state.
5083 (gnus-summary-save-process-mark)
5085 (reverse gnus-newsgroup-processable))
5087 ;; Just return the current article.
5088 (list (gnus-summary-article-number))))))
5090 (defmacro gnus-summary-iterate (arg &rest forms)
5091 "Iterate over the process/prefixed articles and do FORMS.
5092 ARG is the interactive prefix given to the command. FORMS will be
5093 executed with point over the summary line of the articles."
5094 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5095 `(let ((,articles (gnus-summary-work-articles ,arg)))
5097 (gnus-summary-goto-subject (car ,articles))
5101 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5102 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5104 (defun gnus-summary-save-process-mark ()
5105 "Push the current set of process marked articles on the stack."
5107 (push (copy-sequence gnus-newsgroup-processable)
5108 gnus-newsgroup-process-stack))
5110 (defun gnus-summary-kill-process-mark ()
5111 "Push the current set of process marked articles on the stack and unmark."
5113 (gnus-summary-save-process-mark)
5114 (gnus-summary-unmark-all-processable))
5116 (defun gnus-summary-yank-process-mark ()
5117 "Pop the last process mark state off the stack and restore it."
5119 (unless gnus-newsgroup-process-stack
5120 (error "Empty mark stack"))
5121 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5123 (defun gnus-summary-process-mark-set (set)
5124 "Make SET into the current process marked articles."
5125 (gnus-summary-unmark-all-processable)
5127 (gnus-summary-set-process-mark (pop set))))
5129 ;;; Searching and stuff
5131 (defun gnus-summary-search-group (&optional backward use-level)
5132 "Search for next unread newsgroup.
5133 If optional argument BACKWARD is non-nil, search backward instead."
5135 (set-buffer gnus-group-buffer)
5136 (when (gnus-group-search-forward
5137 backward nil (if use-level (gnus-group-group-level) nil))
5138 (gnus-group-group-name))))
5140 (defun gnus-summary-best-group (&optional exclude-group)
5141 "Find the name of the best unread group.
5142 If EXCLUDE-GROUP, do not go to this group."
5144 (set-buffer gnus-group-buffer)
5146 (gnus-group-best-unread-group exclude-group))))
5148 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5149 (if backward (gnus-summary-find-prev)
5150 (let* ((dummy (gnus-summary-article-intangible-p))
5151 (article (or article (gnus-summary-article-number)))
5152 (arts (gnus-data-find-list article))
5154 (when (and (not dummy)
5155 (or (not gnus-summary-check-current)
5157 (not (gnus-data-unread-p (car arts)))))
5158 (setq arts (cdr arts)))
5163 (when (or (and undownloaded
5164 (eq gnus-undownloaded-mark
5165 (gnus-data-mark (car arts))))
5166 (gnus-data-unread-p (car arts)))
5167 (setq result (car arts)
5169 (setq arts (cdr arts)))
5172 (goto-char (gnus-data-pos result))
5173 (gnus-data-number result)))))
5175 (defun gnus-summary-find-prev (&optional unread article)
5176 (let* ((eobp (eobp))
5177 (article (or article (gnus-summary-article-number)))
5178 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5180 (when (and (not eobp)
5181 (or (not gnus-summary-check-current)
5183 (not (gnus-data-unread-p (car arts)))))
5184 (setq arts (cdr arts)))
5189 (when (gnus-data-unread-p (car arts))
5190 (setq result (car arts)
5192 (setq arts (cdr arts)))
5195 (goto-char (gnus-data-pos result))
5196 (gnus-data-number result))))
5198 (defun gnus-summary-find-subject (subject &optional unread backward article)
5199 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5200 (article (or article (gnus-summary-article-number)))
5201 (articles (gnus-data-list backward))
5202 (arts (gnus-data-find-list article articles))
5204 (when (or (not gnus-summary-check-current)
5206 (not (gnus-data-unread-p (car arts))))
5207 (setq arts (cdr arts)))
5209 (and (or (not unread)
5210 (gnus-data-unread-p (car arts)))
5211 (vectorp (gnus-data-header (car arts)))
5213 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5214 (setq result (car arts)
5216 (setq arts (cdr arts)))
5218 (goto-char (gnus-data-pos result))
5219 (gnus-data-number result))))
5221 (defun gnus-summary-search-forward (&optional unread subject backward)
5222 "Search forward for an article.
5223 If UNREAD, look for unread articles. If SUBJECT, look for
5224 articles with that subject. If BACKWARD, search backward instead."
5225 (cond (subject (gnus-summary-find-subject subject unread backward))
5226 (backward (gnus-summary-find-prev unread))
5227 (t (gnus-summary-find-next unread))))
5229 (defun gnus-recenter (&optional n)
5230 "Center point in window and redisplay frame.
5231 Also do horizontal recentering."
5233 (when (and gnus-auto-center-summary
5234 (not (eq gnus-auto-center-summary 'vertical)))
5235 (gnus-horizontal-recenter))
5238 (defun gnus-summary-recenter ()
5239 "Center point in the summary window.
5240 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5241 displayed, no centering will be performed."
5242 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5243 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5245 (let* ((top (cond ((< (window-height) 4) 0)
5246 ((< (window-height) 7) 1)
5247 (t (if (numberp gnus-auto-center-summary)
5248 gnus-auto-center-summary
5250 (height (1- (window-height)))
5251 (bottom (save-excursion (goto-char (point-max))
5252 (forward-line (- height))
5254 (window (get-buffer-window (current-buffer))))
5255 ;; The user has to want it.
5256 (when gnus-auto-center-summary
5257 (when (get-buffer-window gnus-article-buffer)
5258 ;; Only do recentering when the article buffer is displayed,
5259 ;; Set the window start to either `bottom', which is the biggest
5260 ;; possible valid number, or the second line from the top,
5261 ;; whichever is the least.
5263 window (min bottom (save-excursion
5264 (forward-line (- top)) (point)))
5266 ;; Do horizontal recentering while we're at it.
5267 (when (and (get-buffer-window (current-buffer) t)
5268 (not (eq gnus-auto-center-summary 'vertical)))
5269 (let ((selected (selected-window)))
5270 (select-window (get-buffer-window (current-buffer) t))
5271 (gnus-summary-position-point)
5272 (gnus-horizontal-recenter)
5273 (select-window selected))))))
5275 (defun gnus-summary-jump-to-group (newsgroup)
5276 "Move point to NEWSGROUP in group mode buffer."
5277 ;; Keep update point of group mode buffer if visible.
5278 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5279 (save-window-excursion
5280 ;; Take care of tree window mode.
5281 (when (get-buffer-window gnus-group-buffer)
5282 (pop-to-buffer gnus-group-buffer))
5283 (gnus-group-jump-to-group newsgroup))
5285 ;; Take care of tree window mode.
5286 (if (get-buffer-window gnus-group-buffer)
5287 (pop-to-buffer gnus-group-buffer)
5288 (set-buffer gnus-group-buffer))
5289 (gnus-group-jump-to-group newsgroup))))
5291 ;; This function returns a list of article numbers based on the
5292 ;; difference between the ranges of read articles in this group and
5293 ;; the range of active articles.
5294 (defun gnus-list-of-unread-articles (group)
5295 (let* ((read (gnus-info-read (gnus-get-info group)))
5296 (active (or (gnus-active group) (gnus-activate-group group)))
5299 ;; If none are read, then all are unread.
5301 (setq first (car active))
5302 ;; If the range of read articles is a single range, then the
5303 ;; first unread article is the article after the last read
5304 ;; article. Sounds logical, doesn't it?
5305 (if (and (not (listp (cdr read)))
5306 (or (< (car read) (car active))
5307 (progn (setq read (list read))
5309 (setq first (max (car active) (1+ (cdr read))))
5310 ;; `read' is a list of ranges.
5311 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5314 (setq first (car active)))
5317 (while (< first nlast)
5319 (setq first (1+ first))))
5320 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5321 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5322 (setq read (cdr read)))))
5323 ;; And add the last unread articles.
5324 (while (<= first last)
5326 (setq first (1+ first)))
5327 ;; Return the list of unread articles.
5328 (delq 0 (nreverse unread))))
5330 (defun gnus-list-of-read-articles (group)
5331 "Return a list of unread, unticked and non-dormant articles."
5332 (let* ((info (gnus-get-info group))
5333 (marked (gnus-info-marks info))
5334 (active (gnus-active group)))
5336 (gnus-set-difference
5337 (gnus-sorted-complement
5338 (gnus-uncompress-range active)
5339 (gnus-list-of-unread-articles group))
5341 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5342 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5344 ;; Various summary commands
5346 (defun gnus-summary-select-article-buffer ()
5347 "Reconfigure windows to show article buffer."
5349 (if (not (gnus-buffer-live-p gnus-article-buffer))
5350 (error "There is no article buffer for this summary buffer")
5351 (gnus-configure-windows 'article)
5352 (select-window (get-buffer-window gnus-article-buffer))))
5354 (defun gnus-summary-universal-argument (arg)
5355 "Perform any operation on all articles that are process/prefixed."
5357 (let ((articles (gnus-summary-work-articles arg))
5364 (substitute-command-keys
5365 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5367 (gnus-error 1 "Undefined key")
5370 (gnus-summary-goto-subject (setq article (pop articles)))
5371 (let (gnus-newsgroup-processable)
5372 (command-execute func))
5373 (gnus-summary-remove-process-mark article)))))
5374 (gnus-summary-position-point))
5376 (defun gnus-summary-toggle-truncation (&optional arg)
5377 "Toggle truncation of summary lines.
5378 With arg, turn line truncation on iff arg is positive."
5380 (setq truncate-lines
5381 (if (null arg) (not truncate-lines)
5382 (> (prefix-numeric-value arg) 0)))
5385 (defun gnus-summary-reselect-current-group (&optional all rescan)
5386 "Exit and then reselect the current newsgroup.
5387 The prefix argument ALL means to select all articles."
5389 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5390 (error "Ephemeral groups can't be reselected"))
5391 (let ((current-subject (gnus-summary-article-number))
5392 (group gnus-newsgroup-name))
5393 (setq gnus-newsgroup-begin nil)
5395 ;; We have to adjust the point of group mode buffer because
5396 ;; point was moved to the next unread newsgroup by exiting.
5397 (gnus-summary-jump-to-group group)
5400 (save-window-excursion
5401 ;; Don't show group contents.
5402 (set-window-start (selected-window) (point-max))
5403 (gnus-group-get-new-news-this-group 1))))
5404 (gnus-group-read-group all t)
5405 (gnus-summary-goto-subject current-subject nil t)))
5407 (defun gnus-summary-rescan-group (&optional all)
5408 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5410 (gnus-summary-reselect-current-group all t))
5412 (defun gnus-summary-update-info (&optional non-destructive)
5414 (let ((group gnus-newsgroup-name))
5416 (when gnus-newsgroup-kill-headers
5417 (setq gnus-newsgroup-killed
5418 (gnus-compress-sequence
5420 (gnus-set-sorted-intersection
5421 (gnus-uncompress-range gnus-newsgroup-killed)
5422 (setq gnus-newsgroup-unselected
5423 (sort gnus-newsgroup-unselected '<)))
5424 (setq gnus-newsgroup-unreads
5425 (sort gnus-newsgroup-unreads '<)))
5427 (unless (listp (cdr gnus-newsgroup-killed))
5428 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5429 (let ((headers gnus-newsgroup-headers))
5430 ;; Set the new ranges of read articles.
5432 (set-buffer gnus-group-buffer)
5433 (gnus-undo-force-boundary))
5434 (gnus-update-read-articles
5435 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5436 ;; Set the current article marks.
5437 (let ((gnus-newsgroup-scored
5438 (if (and (not gnus-save-score)
5439 (not non-destructive))
5441 gnus-newsgroup-scored)))
5443 (gnus-update-marks)))
5444 ;; Do the cross-ref thing.
5445 (when gnus-use-cross-reference
5446 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5447 ;; Do not switch windows but change the buffer to work.
5448 (set-buffer gnus-group-buffer)
5449 (unless (gnus-ephemeral-group-p group)
5450 (gnus-group-update-group group)))))))
5452 (defun gnus-summary-save-newsrc (&optional force)
5453 "Save the current number of read/marked articles in the dribble buffer.
5454 The dribble buffer will then be saved.
5455 If FORCE (the prefix), also save the .newsrc file(s)."
5457 (gnus-summary-update-info t)
5459 (gnus-save-newsrc-file)
5460 (gnus-dribble-save)))
5462 (defun gnus-summary-exit (&optional temporary)
5463 "Exit reading current newsgroup, and then return to group selection mode.
5464 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5466 (gnus-set-global-variables)
5467 (gnus-kill-save-kill-buffer)
5468 (gnus-async-halt-prefetch)
5469 (let* ((group gnus-newsgroup-name)
5470 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5473 (buf (current-buffer)))
5475 ;; Do adaptive scoring, and possibly save score files.
5476 (when gnus-newsgroup-adaptive
5477 (gnus-score-adaptive))
5478 (when gnus-use-scoring
5480 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5481 ;; If we have several article buffers, we kill them at exit.
5482 (unless gnus-single-article-buffer
5483 (gnus-kill-buffer gnus-original-article-buffer)
5484 (setq gnus-article-current nil))
5485 (when gnus-use-cache
5486 (gnus-cache-possibly-remove-articles)
5487 (gnus-cache-save-buffers))
5488 (gnus-async-prefetch-remove-group group)
5489 (when gnus-suppress-duplicates
5490 (gnus-dup-enter-articles))
5491 (when gnus-use-trees
5492 (gnus-tree-close group))
5493 (when gnus-use-cache
5494 (gnus-cache-write-active))
5495 ;; Remove entries for this group.
5496 (nnmail-purge-split-history (gnus-group-real-name group))
5497 ;; Make all changes in this group permanent.
5499 (gnus-run-hooks 'gnus-exit-group-hook)
5500 (gnus-summary-update-info))
5501 (gnus-close-group group)
5502 ;; Make sure where we were, and go to next newsgroup.
5503 (set-buffer gnus-group-buffer)
5505 (gnus-group-jump-to-group group))
5506 (gnus-run-hooks 'gnus-summary-exit-hook)
5507 (unless (or quit-config
5508 ;; If this group has disappeared from the summary
5509 ;; buffer, don't skip forwards.
5510 (not (string= group (gnus-group-group-name))))
5511 (gnus-group-next-unread-group 1))
5512 (setq group-point (point))
5515 ;; If we have several article buffers, we kill them at exit.
5516 (unless gnus-single-article-buffer
5517 (gnus-kill-buffer gnus-article-buffer)
5518 (gnus-kill-buffer gnus-original-article-buffer)
5519 (setq gnus-article-current nil))
5521 (if (not gnus-kill-summary-on-exit)
5522 (gnus-deaden-summary)
5523 ;; We set all buffer-local variables to nil. It is unclear why
5524 ;; this is needed, but if we don't, buffer-local variables are
5525 ;; not garbage-collected, it seems. This would the lead to en
5526 ;; ever-growing Emacs.
5527 (gnus-summary-clear-local-variables)
5528 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5529 (gnus-summary-clear-local-variables))
5530 (when (get-buffer gnus-article-buffer)
5531 (bury-buffer gnus-article-buffer))
5532 ;; We clear the global counterparts of the buffer-local
5533 ;; variables as well, just to be on the safe side.
5534 (set-buffer gnus-group-buffer)
5535 (gnus-summary-clear-local-variables)
5536 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5537 (gnus-summary-clear-local-variables))
5538 ;; Return to group mode buffer.
5539 (when (eq mode 'gnus-summary-mode)
5540 (gnus-kill-buffer buf)))
5541 (setq gnus-current-select-method gnus-select-method)
5542 (pop-to-buffer gnus-group-buffer)
5543 (if (not quit-config)
5545 (goto-char group-point)
5546 (gnus-configure-windows 'group 'force)
5547 (unless (pos-visible-in-window-p)
5548 (forward-line (/ (static-if (featurep 'xemacs)
5549 (window-displayed-height)
5550 (1- (window-height)))
5552 (set-window-start (selected-window) (point))
5553 (goto-char group-point)))
5554 (gnus-handle-ephemeral-exit quit-config))
5555 ;; Clear the current group name.
5557 (setq gnus-newsgroup-name nil)))))
5559 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5560 (defun gnus-summary-exit-no-update (&optional no-questions)
5561 "Quit reading current newsgroup without updating read article info."
5563 (let* ((group gnus-newsgroup-name)
5564 (quit-config (gnus-group-quit-config group)))
5565 (when (or no-questions
5567 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5568 (gnus-async-halt-prefetch)
5570 (delq 'gnus-summary-expire-articles
5571 (copy-sequence gnus-summary-prepare-exit-hook)))
5572 ;; If we have several article buffers, we kill them at exit.
5573 (unless gnus-single-article-buffer
5574 (gnus-kill-buffer gnus-article-buffer)
5575 (gnus-kill-buffer gnus-original-article-buffer)
5576 (setq gnus-article-current nil))
5577 (if (not gnus-kill-summary-on-exit)
5578 (gnus-deaden-summary)
5579 (gnus-close-group group)
5580 (gnus-summary-clear-local-variables)
5581 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5582 (gnus-summary-clear-local-variables))
5583 (set-buffer gnus-group-buffer)
5584 (gnus-summary-clear-local-variables)
5585 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5586 (gnus-summary-clear-local-variables))
5587 (when (get-buffer gnus-summary-buffer)
5588 (kill-buffer gnus-summary-buffer)))
5589 (unless gnus-single-article-buffer
5590 (setq gnus-article-current nil))
5591 (when gnus-use-trees
5592 (gnus-tree-close group))
5593 (gnus-async-prefetch-remove-group group)
5594 (when (get-buffer gnus-article-buffer)
5595 (bury-buffer gnus-article-buffer))
5596 ;; Return to the group buffer.
5597 (gnus-configure-windows 'group 'force)
5598 ;; Clear the current group name.
5599 (setq gnus-newsgroup-name nil)
5600 (when (equal (gnus-group-group-name) group)
5601 (gnus-group-next-unread-group 1))
5603 (gnus-handle-ephemeral-exit quit-config)))))
5605 (defun gnus-handle-ephemeral-exit (quit-config)
5606 "Handle movement when leaving an ephemeral group.
5607 The state which existed when entering the ephemeral is reset."
5608 (if (not (buffer-name (car quit-config)))
5609 (gnus-configure-windows 'group 'force)
5610 (set-buffer (car quit-config))
5611 (cond ((eq major-mode 'gnus-summary-mode)
5612 (gnus-set-global-variables))
5613 ((eq major-mode 'gnus-article-mode)
5615 ;; The `gnus-summary-buffer' variable may point
5616 ;; to the old summary buffer when using a single
5618 (unless (gnus-buffer-live-p gnus-summary-buffer)
5619 (set-buffer gnus-group-buffer))
5620 (set-buffer gnus-summary-buffer)
5621 (gnus-set-global-variables))))
5622 (if (or (eq (cdr quit-config) 'article)
5623 (eq (cdr quit-config) 'pick))
5625 ;; The current article may be from the ephemeral group
5626 ;; thus it is best that we reload this article
5627 (gnus-summary-show-article)
5628 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5629 (gnus-configure-windows 'pick 'force)
5630 (gnus-configure-windows (cdr quit-config) 'force)))
5631 (gnus-configure-windows (cdr quit-config) 'force))
5632 (when (eq major-mode 'gnus-summary-mode)
5633 (gnus-summary-next-subject 1 nil t)
5634 (gnus-summary-recenter)
5635 (gnus-summary-position-point))))
5637 (defun gnus-summary-preview-mime-message ()
5638 "MIME decode and play this message."
5640 (let ((gnus-break-pages nil)
5642 (gnus-summary-select-article gnus-show-all-headers t))
5643 (select-window (get-buffer-window gnus-article-buffer)))
5647 (defvar gnus-dead-summary-mode-map nil)
5649 (unless gnus-dead-summary-mode-map
5650 (setq gnus-dead-summary-mode-map (make-keymap))
5651 (suppress-keymap gnus-dead-summary-mode-map)
5652 (substitute-key-definition
5653 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5654 (let ((keys '("\C-d" "\r" "\177" [delete])))
5656 (define-key gnus-dead-summary-mode-map
5657 (pop keys) 'gnus-summary-wake-up-the-dead))))
5659 (defvar gnus-dead-summary-mode nil
5660 "Minor mode for Gnus summary buffers.")
5662 (defun gnus-dead-summary-mode (&optional arg)
5663 "Minor mode for Gnus summary buffers."
5665 (when (eq major-mode 'gnus-summary-mode)
5666 (make-local-variable 'gnus-dead-summary-mode)
5667 (setq gnus-dead-summary-mode
5668 (if (null arg) (not gnus-dead-summary-mode)
5669 (> (prefix-numeric-value arg) 0)))
5670 (when gnus-dead-summary-mode
5671 (gnus-add-minor-mode
5672 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5674 (defun gnus-deaden-summary ()
5675 "Make the current summary buffer into a dead summary buffer."
5676 ;; Kill any previous dead summary buffer.
5677 (when (and gnus-dead-summary
5678 (buffer-name gnus-dead-summary))
5680 (set-buffer gnus-dead-summary)
5681 (when gnus-dead-summary-mode
5682 (kill-buffer (current-buffer)))))
5683 ;; Make this the current dead summary.
5684 (setq gnus-dead-summary (current-buffer))
5685 (gnus-dead-summary-mode 1)
5686 (let ((name (buffer-name)))
5687 (when (string-match "Summary" name)
5689 (concat (substring name 0 (match-beginning 0)) "Dead "
5690 (substring name (match-beginning 0)))
5694 (defun gnus-kill-or-deaden-summary (buffer)
5695 "Kill or deaden the summary BUFFER."
5697 (when (and (buffer-name buffer)
5698 (not gnus-single-article-buffer))
5701 (gnus-kill-buffer gnus-article-buffer)
5702 (gnus-kill-buffer gnus-original-article-buffer)))
5703 (cond (gnus-kill-summary-on-exit
5704 (when (and gnus-use-trees
5705 (gnus-buffer-exists-p buffer))
5708 (gnus-tree-close gnus-newsgroup-name)))
5709 (gnus-kill-buffer buffer))
5710 ((gnus-buffer-exists-p buffer)
5713 (gnus-deaden-summary))))))
5715 (defun gnus-summary-wake-up-the-dead (&rest args)
5716 "Wake up the dead summary buffer."
5718 (gnus-dead-summary-mode -1)
5719 (let ((name (buffer-name)))
5720 (when (string-match "Dead " name)
5722 (concat (substring name 0 (match-beginning 0))
5723 (substring name (match-end 0)))
5725 (gnus-message 3 "This dead summary is now alive again"))
5727 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5728 (defun gnus-summary-fetch-faq (&optional faq-dir)
5729 "Fetch the FAQ for the current group.
5730 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5734 (when current-prefix-arg
5736 "Faq dir: " (and (listp gnus-group-faq-directory)
5737 (mapcar (lambda (file) (list file))
5738 gnus-group-faq-directory))))))
5739 (let (gnus-faq-buffer)
5740 (when (setq gnus-faq-buffer
5741 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5742 (gnus-configure-windows 'summary-faq))))
5744 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5745 (defun gnus-summary-describe-group (&optional force)
5746 "Describe the current newsgroup."
5748 (gnus-group-describe-group force gnus-newsgroup-name))
5750 (defun gnus-summary-describe-briefly ()
5751 "Describe summary mode commands briefly."
5753 (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")))
5755 ;; Walking around group mode buffer from summary mode.
5757 (defun gnus-summary-next-group (&optional no-article target-group backward)
5758 "Exit current newsgroup and then select next unread newsgroup.
5759 If prefix argument NO-ARTICLE is non-nil, no article is selected
5760 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5761 previous group instead."
5763 ;; Stop pre-fetching.
5764 (gnus-async-halt-prefetch)
5765 (let ((current-group gnus-newsgroup-name)
5766 (current-buffer (current-buffer))
5768 ;; First we semi-exit this group to update Xrefs and all variables.
5769 ;; We can't do a real exit, because the window conf must remain
5770 ;; the same in case the user is prompted for info, and we don't
5771 ;; want the window conf to change before that...
5772 (gnus-summary-exit t)
5773 (while (not entered)
5774 ;; Then we find what group we are supposed to enter.
5775 (set-buffer gnus-group-buffer)
5776 (gnus-group-jump-to-group current-group)
5779 (if (eq gnus-keep-same-level 'best)
5780 (gnus-summary-best-group gnus-newsgroup-name)
5781 (gnus-summary-search-group backward gnus-keep-same-level))))
5782 (if (not target-group)
5783 ;; There are no further groups, so we return to the group
5786 (gnus-message 5 "Returning to the group buffer")
5788 (when (gnus-buffer-live-p current-buffer)
5789 (set-buffer current-buffer)
5790 (gnus-summary-exit))
5791 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5792 ;; We try to enter the target group.
5793 (gnus-group-jump-to-group target-group)
5794 (let ((unreads (gnus-group-group-unread)))
5795 (if (and (or (eq t unreads)
5796 (and unreads (not (zerop unreads))))
5797 (gnus-summary-read-group
5798 target-group nil no-article
5799 (and (buffer-name current-buffer) current-buffer)
5802 (setq current-group target-group
5803 target-group nil)))))))
5805 (defun gnus-summary-prev-group (&optional no-article)
5806 "Exit current newsgroup and then select previous unread newsgroup.
5807 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5809 (gnus-summary-next-group no-article nil t))
5811 ;; Walking around summary lines.
5813 (defun gnus-summary-first-subject (&optional unread undownloaded)
5814 "Go to the first unread subject.
5815 If UNREAD is non-nil, go to the first unread article.
5816 Returns the article selected or nil if there are no unread articles."
5821 ((null gnus-newsgroup-data)
5822 (gnus-message 3 "No articles in the group")
5824 ;; Pick the first article.
5826 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5827 (gnus-data-number (car gnus-newsgroup-data)))
5828 ;; No unread articles.
5829 ((null gnus-newsgroup-unreads)
5830 (gnus-message 3 "No more unread articles")
5832 ;; Find the first unread article.
5834 (let ((data gnus-newsgroup-data))
5836 (and (not (and undownloaded
5837 (eq gnus-undownloaded-mark
5838 (gnus-data-mark (car data)))))
5839 (not (gnus-data-unread-p (car data)))))
5840 (setq data (cdr data)))
5842 (goto-char (gnus-data-pos (car data)))
5843 (gnus-data-number (car data))))))
5844 (gnus-summary-position-point)))
5846 (defun gnus-summary-next-subject (n &optional unread dont-display)
5847 "Go to next N'th summary line.
5848 If N is negative, go to the previous N'th subject line.
5849 If UNREAD is non-nil, only unread articles are selected.
5850 The difference between N and the actual number of steps taken is
5853 (let ((backward (< n 0))
5857 (gnus-summary-find-prev unread)
5858 (gnus-summary-find-next unread)))
5859 (unless (zerop (setq n (1- n)))
5860 (gnus-summary-show-thread)))
5862 (gnus-message 7 "No more%s articles"
5863 (if unread " unread" "")))
5864 (unless dont-display
5865 (gnus-summary-recenter)
5866 (gnus-summary-position-point))
5869 (defun gnus-summary-next-unread-subject (n)
5870 "Go to next N'th unread summary line."
5872 (gnus-summary-next-subject n t))
5874 (defun gnus-summary-prev-subject (n &optional unread)
5875 "Go to previous N'th summary line.
5876 If optional argument UNREAD is non-nil, only unread article is selected."
5878 (gnus-summary-next-subject (- n) unread))
5880 (defun gnus-summary-prev-unread-subject (n)
5881 "Go to previous N'th unread summary line."
5883 (gnus-summary-next-subject (- n) t))
5885 (defun gnus-summary-goto-subject (article &optional force silent)
5886 "Go the subject line of ARTICLE.
5887 If FORCE, also allow jumping to articles not currently shown."
5888 (interactive "nArticle number: ")
5890 (data (gnus-data-find article)))
5891 ;; We read in the article if we have to.
5894 (gnus-summary-insert-subject
5896 (if (or (numberp force) (vectorp force)) force)
5898 (setq data (gnus-data-find article)))
5903 (gnus-message 3 "Can't find article %d" article))
5905 (goto-char (gnus-data-pos data))
5906 (gnus-summary-position-point)
5909 ;; Walking around summary lines with displaying articles.
5911 (defun gnus-summary-expand-window (&optional arg)
5912 "Make the summary buffer take up the entire Emacs frame.
5913 Given a prefix, will force an `article' buffer configuration."
5916 (gnus-configure-windows 'article 'force)
5917 (gnus-configure-windows 'summary 'force)))
5919 (defun gnus-summary-display-article (article &optional all-header)
5920 "Display ARTICLE in article buffer."
5921 (gnus-set-global-variables)
5922 (when (gnus-buffer-live-p gnus-article-buffer)
5923 (with-current-buffer gnus-article-buffer
5924 (setq gnus-article-charset gnus-newsgroup-charset)
5925 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
5929 (if gnus-summary-display-article-function
5930 (funcall gnus-summary-display-article-function article all-header)
5931 (gnus-article-prepare article all-header))
5932 (with-current-buffer gnus-article-buffer
5933 (set (make-local-variable 'gnus-summary-search-article-matched-data)
5935 (gnus-run-hooks 'gnus-select-article-hook)
5936 (when (and gnus-current-article
5937 (not (zerop gnus-current-article)))
5938 (gnus-summary-goto-subject gnus-current-article))
5939 (gnus-summary-recenter)
5940 (when (and gnus-use-trees gnus-show-threads)
5941 (gnus-possibly-generate-tree article)
5942 (gnus-highlight-selected-tree article))
5943 ;; Successfully display article.
5944 (gnus-article-set-window-start
5945 (cdr (assq article gnus-newsgroup-bookmarks))))))
5947 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5948 "Select the current article.
5949 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5950 non-nil, the article will be re-fetched even if it already present in
5951 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5953 ;; Make sure we are in the summary buffer to work around bbdb bug.
5954 (unless (eq major-mode 'gnus-summary-mode)
5955 (set-buffer gnus-summary-buffer))
5956 (let ((article (or article (gnus-summary-article-number)))
5957 (all-headers (not (not all-headers))) ;Must be T or NIL.
5958 gnus-summary-display-article-function)
5960 (gnus-summary-article-pseudo-p article)
5961 (error "This is a pseudo-article"))
5963 (set-buffer gnus-summary-buffer)
5964 (if (or (and gnus-single-article-buffer
5965 (or (null gnus-current-article)
5966 (null gnus-article-current)
5967 (null (get-buffer gnus-article-buffer))
5968 (not (eq article (cdr gnus-article-current)))
5969 (not (equal (car gnus-article-current)
5970 gnus-newsgroup-name))))
5971 (and (not gnus-single-article-buffer)
5972 (or (null gnus-current-article)
5973 (not (eq gnus-current-article article))))
5975 ;; The requested article is different from the current article.
5977 (gnus-summary-display-article article all-headers)
5978 (when (or all-headers gnus-show-all-headers)
5979 (gnus-article-show-all-headers))
5980 (gnus-article-set-window-start
5981 (cdr (assq article gnus-newsgroup-bookmarks)))
5983 (when (or all-headers gnus-show-all-headers)
5984 (gnus-article-show-all-headers))
5987 (defun gnus-summary-force-verify-and-decrypt ()
5989 (let ((mm-verify-option 'known)
5990 (mm-decrypt-option 'known))
5991 (gnus-summary-select-article nil 'force)))
5993 (defun gnus-summary-set-current-mark (&optional current-mark)
5994 "Obsolete function."
5997 (defun gnus-summary-next-article (&optional unread subject backward push)
5998 "Select the next article.
5999 If UNREAD, only unread articles are selected.
6000 If SUBJECT, only articles with SUBJECT are selected.
6001 If BACKWARD, the previous article is selected instead of the next."
6004 ;; Is there such an article?
6005 ((and (gnus-summary-search-forward unread subject backward)
6006 (or (gnus-summary-display-article (gnus-summary-article-number))
6007 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6008 (gnus-summary-position-point))
6009 ;; If not, we try the first unread, if that is wanted.
6011 gnus-auto-select-same
6012 (gnus-summary-first-unread-article))
6013 (gnus-summary-position-point)
6014 (gnus-message 6 "Wrapped"))
6015 ;; Try to get next/previous article not displayed in this group.
6016 ((and gnus-auto-extend-newsgroup
6017 (not unread) (not subject))
6018 (gnus-summary-goto-article
6019 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6020 nil (count-lines (point-min) (point))))
6021 ;; Go to next/previous group.
6023 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6024 (gnus-summary-jump-to-group gnus-newsgroup-name))
6025 (let ((cmd last-command-char)
6028 (set-buffer gnus-group-buffer)
6031 (if (eq gnus-keep-same-level 'best)
6032 (gnus-summary-best-group gnus-newsgroup-name)
6033 (gnus-summary-search-group backward gnus-keep-same-level))))
6034 ;; For some reason, the group window gets selected. We change
6036 (select-window (get-buffer-window (current-buffer)))
6037 ;; Select next unread newsgroup automagically.
6039 ((or (not gnus-auto-select-next)
6041 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6042 ((or (eq gnus-auto-select-next 'quietly)
6043 (and (eq gnus-auto-select-next 'slightly-quietly)
6045 (and (eq gnus-auto-select-next 'almost-quietly)
6046 (gnus-summary-last-article-p)))
6048 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6050 (gnus-message 7 "No more%s articles (%s)..."
6051 (if unread " unread" "")
6052 (if group (concat "selecting " group)
6054 (gnus-summary-next-group nil group backward)))
6056 (when (gnus-key-press-event-p last-input-event)
6057 (gnus-summary-walk-group-buffer
6058 gnus-newsgroup-name cmd unread backward point))))))))
6060 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6061 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6062 (?\C-p (gnus-group-prev-unread-group 1))))
6063 (cursor-in-echo-area t)
6064 keve key group ended)
6066 (set-buffer gnus-group-buffer)
6069 (if (eq gnus-keep-same-level 'best)
6070 (gnus-summary-best-group gnus-newsgroup-name)
6071 (gnus-summary-search-group backward gnus-keep-same-level))))
6074 5 "No more%s articles%s" (if unread " unread" "")
6076 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6077 (format " (Type %s for %s [%s])"
6078 (single-key-description cmd) group
6079 (car (gnus-gethash group gnus-newsrc-hashtb)))
6080 (format " (Type %s to exit %s)"
6081 (single-key-description cmd)
6082 gnus-newsgroup-name)))
6083 ;; Confirm auto selection.
6084 (setq key (car (setq keve (gnus-read-event-char))))
6087 ((assq key keystrokes)
6088 (let ((obuf (current-buffer)))
6089 (switch-to-buffer gnus-group-buffer)
6091 (gnus-group-jump-to-group group))
6092 (eval (cadr (assq key keystrokes)))
6093 (setq group (gnus-group-group-name))
6094 (switch-to-buffer obuf))
6098 (gnus-ephemeral-group-p gnus-newsgroup-name))
6100 (gnus-summary-next-group nil group backward)))
6102 (push (cdr keve) unread-command-events))))))
6104 (defun gnus-summary-next-unread-article ()
6105 "Select unread article after current one."
6107 (gnus-summary-next-article
6108 (or (not (eq gnus-summary-goto-unread 'never))
6109 (gnus-summary-last-article-p (gnus-summary-article-number)))
6110 (and gnus-auto-select-same
6111 (gnus-summary-article-subject))))
6113 (defun gnus-summary-prev-article (&optional unread subject)
6114 "Select the article after the current one.
6115 If UNREAD is non-nil, only unread articles are selected."
6117 (gnus-summary-next-article unread subject t))
6119 (defun gnus-summary-prev-unread-article ()
6120 "Select unread article before current one."
6122 (gnus-summary-prev-article
6123 (or (not (eq gnus-summary-goto-unread 'never))
6124 (gnus-summary-first-article-p (gnus-summary-article-number)))
6125 (and gnus-auto-select-same
6126 (gnus-summary-article-subject))))
6128 (defun gnus-summary-next-page (&optional lines circular)
6129 "Show next page of the selected article.
6130 If at the end of the current article, select the next article.
6131 LINES says how many lines should be scrolled up.
6133 If CIRCULAR is non-nil, go to the start of the article instead of
6134 selecting the next article when reaching the end of the current
6137 (setq gnus-summary-buffer (current-buffer))
6138 (gnus-set-global-variables)
6139 (let ((article (gnus-summary-article-number))
6140 (article-window (get-buffer-window gnus-article-buffer t))
6142 ;; If the buffer is empty, we have no article.
6144 (error "No article to select"))
6145 (gnus-configure-windows 'article)
6146 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6147 (if (and (eq gnus-summary-goto-unread 'never)
6148 (not (gnus-summary-last-article-p article)))
6149 (gnus-summary-next-article)
6150 (gnus-summary-next-unread-article))
6151 (if (or (null gnus-current-article)
6152 (null gnus-article-current)
6153 (/= article (cdr gnus-article-current))
6154 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6155 ;; Selected subject is different from current article's.
6156 (gnus-summary-display-article article)
6157 (when article-window
6158 (gnus-eval-in-buffer-window gnus-article-buffer
6159 (setq endp (gnus-article-next-page lines)))
6162 (gnus-summary-beginning-of-article))
6164 (gnus-message 3 "End of message"))
6166 (if (and (eq gnus-summary-goto-unread 'never)
6167 (not (gnus-summary-last-article-p article)))
6168 (gnus-summary-next-article)
6169 (gnus-summary-next-unread-article))))))))
6170 (gnus-summary-recenter)
6171 (gnus-summary-position-point)))
6173 (defun gnus-summary-prev-page (&optional lines move)
6174 "Show previous page of selected article.
6175 Argument LINES specifies lines to be scrolled down.
6176 If MOVE, move to the previous unread article if point is at
6177 the beginning of the buffer."
6179 (let ((article (gnus-summary-article-number))
6180 (article-window (get-buffer-window gnus-article-buffer t))
6182 (gnus-configure-windows 'article)
6183 (if (or (null gnus-current-article)
6184 (null gnus-article-current)
6185 (/= article (cdr gnus-article-current))
6186 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6187 ;; Selected subject is different from current article's.
6188 (gnus-summary-display-article article)
6189 (gnus-summary-recenter)
6190 (when article-window
6191 (gnus-eval-in-buffer-window gnus-article-buffer
6192 (setq endp (gnus-article-prev-page lines)))
6193 (when (and move endp)
6195 (gnus-message 3 "Beginning of message"))
6197 (if (and (eq gnus-summary-goto-unread 'never)
6198 (not (gnus-summary-first-article-p article)))
6199 (gnus-summary-prev-article)
6200 (gnus-summary-prev-unread-article))))))))
6201 (gnus-summary-position-point))
6203 (defun gnus-summary-prev-page-or-article (&optional lines)
6204 "Show previous page of selected article.
6205 Argument LINES specifies lines to be scrolled down.
6206 If at the beginning of the article, go to the next article."
6208 (gnus-summary-prev-page lines t))
6210 (defun gnus-summary-scroll-up (lines)
6211 "Scroll up (or down) one line current article.
6212 Argument LINES specifies lines to be scrolled up (or down if negative)."
6214 (gnus-configure-windows 'article)
6215 (gnus-summary-show-thread)
6216 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6217 (gnus-eval-in-buffer-window gnus-article-buffer
6219 (when (gnus-article-next-page lines)
6220 (gnus-message 3 "End of message")))
6222 (gnus-article-prev-page (- lines))))))
6223 (gnus-summary-recenter)
6224 (gnus-summary-position-point))
6226 (defun gnus-summary-scroll-down (lines)
6227 "Scroll down (or up) one line current article.
6228 Argument LINES specifies lines to be scrolled down (or up if negative)."
6230 (gnus-summary-scroll-up (- lines)))
6232 (defun gnus-summary-next-same-subject ()
6233 "Select next article which has the same subject as current one."
6235 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6237 (defun gnus-summary-prev-same-subject ()
6238 "Select previous article which has the same subject as current one."
6240 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6242 (defun gnus-summary-next-unread-same-subject ()
6243 "Select next unread article which has the same subject as current one."
6245 (gnus-summary-next-article t (gnus-summary-article-subject)))
6247 (defun gnus-summary-prev-unread-same-subject ()
6248 "Select previous unread article which has the same subject as current one."
6250 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6252 (defun gnus-summary-first-unread-article ()
6253 "Select the first unread article.
6254 Return nil if there are no unread articles."
6257 (when (gnus-summary-first-subject t)
6258 (gnus-summary-show-thread)
6259 (gnus-summary-first-subject t)
6260 (gnus-summary-display-article (gnus-summary-article-number)))
6261 (gnus-summary-position-point)))
6263 (defun gnus-summary-first-unread-subject ()
6264 "Place the point on the subject line of the first unread article.
6265 Return nil if there are no unread articles."
6268 (when (gnus-summary-first-subject t)
6269 (gnus-summary-show-thread)
6270 (gnus-summary-first-subject t))
6271 (gnus-summary-position-point)))
6273 (defun gnus-summary-first-article ()
6274 "Select the first article.
6275 Return nil if there are no articles."
6278 (when (gnus-summary-first-subject)
6279 (gnus-summary-show-thread)
6280 (gnus-summary-first-subject)
6281 (gnus-summary-display-article (gnus-summary-article-number)))
6282 (gnus-summary-position-point)))
6284 (defun gnus-summary-best-unread-article ()
6285 "Select the unread article with the highest score."
6287 (let ((best -1000000)
6288 (data gnus-newsgroup-data)
6291 (and (gnus-data-unread-p (car data))
6293 (gnus-summary-article-score (gnus-data-number (car data))))
6296 article (gnus-data-number (car data))))
6297 (setq data (cdr data)))
6300 (gnus-summary-goto-article article)
6301 (error "No unread articles"))
6302 (gnus-summary-position-point))))
6304 (defun gnus-summary-last-subject ()
6305 "Go to the last displayed subject line in the group."
6306 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6308 (gnus-summary-goto-subject article))))
6310 (defun gnus-summary-goto-article (article &optional all-headers force)
6311 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6312 If ALL-HEADERS is non-nil, no header lines are hidden.
6313 If FORCE, go to the article even if it isn't displayed. If FORCE
6314 is a number, it is the line the article is to be displayed on."
6318 "Article number or Message-ID: "
6319 (mapcar (lambda (number) (list (int-to-string number)))
6320 gnus-newsgroup-limit))
6324 (if (and (stringp article)
6325 (string-match "@" article))
6326 (gnus-summary-refer-article article)
6327 (when (stringp article)
6328 (setq article (string-to-number article)))
6329 (if (gnus-summary-goto-subject article force)
6330 (gnus-summary-display-article article all-headers)
6331 (gnus-message 4 "Couldn't go to article %s" article) nil))
6332 (gnus-summary-position-point)))
6334 (defun gnus-summary-goto-last-article ()
6335 "Go to the previously read article."
6338 (when gnus-last-article
6339 (gnus-summary-goto-article gnus-last-article nil t))
6340 (gnus-summary-position-point)))
6342 (defun gnus-summary-pop-article (number)
6343 "Pop one article off the history and go to the previous.
6344 NUMBER articles will be popped off."
6347 (setq gnus-newsgroup-history
6348 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6350 (gnus-summary-goto-article (car to) nil t)
6351 (error "Article history empty")))
6352 (gnus-summary-position-point))
6354 ;; Summary commands and functions for limiting the summary buffer.
6356 (defun gnus-summary-limit-to-articles (n)
6357 "Limit the summary buffer to the next N articles.
6358 If not given a prefix, use the process marked articles instead."
6361 (let ((articles (gnus-summary-work-articles n)))
6362 (setq gnus-newsgroup-processable nil)
6363 (gnus-summary-limit articles))
6364 (gnus-summary-position-point)))
6366 (defun gnus-summary-pop-limit (&optional total)
6367 "Restore the previous limit.
6368 If given a prefix, remove all limits."
6371 (setq gnus-newsgroup-limits
6372 (list (mapcar (lambda (h) (mail-header-number h))
6373 gnus-newsgroup-headers))))
6374 (unless gnus-newsgroup-limits
6375 (error "No limit to pop"))
6377 (gnus-summary-limit nil 'pop)
6378 (gnus-summary-position-point)))
6380 (defun gnus-summary-limit-to-subject (subject &optional header)
6381 "Limit the summary buffer to articles that have subjects that match a regexp."
6382 (interactive "sLimit to subject (regexp): ")
6384 (setq header "subject"))
6385 (when (not (equal "" subject))
6387 (let ((articles (gnus-summary-find-matching
6388 (or header "subject") subject 'all)))
6390 (error "Found no matches for \"%s\"" subject))
6391 (gnus-summary-limit articles))
6392 (gnus-summary-position-point))))
6394 (defun gnus-summary-limit-to-author (from)
6395 "Limit the summary buffer to articles that have authors that match a regexp."
6396 (interactive "sLimit to author (regexp): ")
6397 (gnus-summary-limit-to-subject from "from"))
6399 (defun gnus-summary-limit-to-age (age &optional younger-p)
6400 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6401 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6402 articles that are younger than AGE days."
6404 (let ((younger current-prefix-arg)
6407 (while (not days-got)
6408 (setq days (if younger
6409 (read-string "Limit to articles within (in days): ")
6410 (read-string "Limit to articles old than (in days): ")))
6411 (when (> (length days) 0)
6412 (setq days (read days)))
6415 (message "Please enter a number.")
6417 (list days younger)))
6419 (let ((data gnus-newsgroup-data)
6420 (cutoff (days-to-time age))
6421 articles d date is-younger)
6422 (while (setq d (pop data))
6423 (when (and (vectorp (gnus-data-header d))
6424 (setq date (mail-header-date (gnus-data-header d))))
6425 (setq is-younger (time-less-p
6426 (time-since (condition-case ()
6433 (push (gnus-data-number d) articles))))
6434 (gnus-summary-limit (nreverse articles)))
6435 (gnus-summary-position-point)))
6437 (defun gnus-summary-limit-to-extra (header regexp)
6438 "Limit the summary buffer to articles that match an 'extra' header."
6442 (gnus-completing-read
6443 (symbol-name (car gnus-extra-headers))
6444 "Limit extra header:"
6446 (cons (symbol-name x) x))
6451 (read-string (format "Limit to header %s (regexp): " header)))))
6452 (when (not (equal "" regexp))
6454 (let ((articles (gnus-summary-find-matching
6455 (cons 'extra header) regexp 'all)))
6457 (error "Found no matches for \"%s\"" regexp))
6458 (gnus-summary-limit articles))
6459 (gnus-summary-position-point))))
6461 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6463 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6465 (defun gnus-summary-limit-to-unread (&optional all)
6466 "Limit the summary buffer to articles that are not marked as read.
6467 If ALL is non-nil, limit strictly to unread articles."
6470 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6471 (gnus-summary-limit-to-marks
6472 ;; Concat all the marks that say that an article is read and have
6474 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6475 gnus-killed-mark gnus-kill-file-mark
6476 gnus-low-score-mark gnus-expirable-mark
6477 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6478 gnus-duplicate-mark gnus-souped-mark)
6481 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6482 (make-obsolete 'gnus-summary-delete-marked-with
6483 'gnus-summary-limit-exlude-marks)
6485 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6486 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6487 If REVERSE, limit the summary buffer to articles that are marked
6488 with MARKS. MARKS can either be a string of marks or a list of marks.
6489 Returns how many articles were removed."
6490 (interactive "sMarks: ")
6491 (gnus-summary-limit-to-marks marks t))
6493 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6494 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6495 If REVERSE (the prefix), limit the summary buffer to articles that are
6496 not marked with MARKS. MARKS can either be a string of marks or a
6498 Returns how many articles were removed."
6499 (interactive "sMarks: \nP")
6501 (let ((data gnus-newsgroup-data)
6502 (marks (if (listp marks) marks
6503 (append marks nil))) ; Transform to list.
6506 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6507 (memq (gnus-data-mark (car data)) marks))
6508 (push (gnus-data-number (car data)) articles))
6509 (setq data (cdr data)))
6510 (gnus-summary-limit articles))
6511 (gnus-summary-position-point)))
6513 (defun gnus-summary-limit-to-score (&optional score)
6514 "Limit to articles with score at or above SCORE."
6516 (setq score (if score
6517 (prefix-numeric-value score)
6518 (or gnus-summary-default-score 0)))
6519 (let ((data gnus-newsgroup-data)
6522 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6524 (push (gnus-data-number (car data)) articles))
6525 (setq data (cdr data)))
6527 (gnus-summary-limit articles)
6528 (gnus-summary-position-point))))
6530 (defun gnus-summary-limit-include-thread (id)
6531 "Display all the hidden articles that in the current thread."
6532 (interactive (list (mail-header-id (gnus-summary-article-header))))
6533 (let ((articles (gnus-articles-in-thread
6534 (gnus-id-to-thread (gnus-root-id id)))))
6536 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6537 (gnus-summary-position-point))))
6539 (defun gnus-summary-limit-include-dormant ()
6540 "Display all the hidden articles that are marked as dormant.
6541 Note that this command only works on a subset of the articles currently
6542 fetched for this group."
6544 (unless gnus-newsgroup-dormant
6545 (error "There are no dormant articles in this group"))
6547 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6548 (gnus-summary-position-point)))
6550 (defun gnus-summary-limit-exclude-dormant ()
6551 "Hide all dormant articles."
6554 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6555 (gnus-summary-position-point)))
6557 (defun gnus-summary-limit-exclude-childless-dormant ()
6558 "Hide all dormant articles that have no children."
6560 (let ((data (gnus-data-list t))
6561 articles d children)
6562 ;; Find all articles that are either not dormant or have
6564 (while (setq d (pop data))
6565 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6567 (gnus-article-children (gnus-data-number d)))
6570 (when (memq (car children) articles)
6575 (push (gnus-data-number d) articles)))
6578 (gnus-summary-limit articles)
6579 (gnus-summary-position-point))))
6581 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6582 "Mark all unread excluded articles as read.
6583 If ALL, mark even excluded ticked and dormants as read."
6585 (let ((articles (gnus-sorted-complement
6587 (mapcar (lambda (h) (mail-header-number h))
6588 gnus-newsgroup-headers)
6590 (sort gnus-newsgroup-limit '<)))
6592 (setq gnus-newsgroup-unreads
6593 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6595 (setq gnus-newsgroup-dormant nil
6596 gnus-newsgroup-marked nil
6597 gnus-newsgroup-reads
6599 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6600 gnus-newsgroup-reads))
6601 (while (setq article (pop articles))
6602 (unless (or (memq article gnus-newsgroup-dormant)
6603 (memq article gnus-newsgroup-marked))
6604 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6606 (defun gnus-summary-limit (articles &optional pop)
6608 ;; We pop the previous limit off the stack and use that.
6609 (setq articles (car gnus-newsgroup-limits)
6610 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6611 ;; We use the new limit, so we push the old limit on the stack.
6612 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6614 (setq gnus-newsgroup-limit articles)
6615 (let ((total (length gnus-newsgroup-data))
6616 (data (gnus-data-find-list (gnus-summary-article-number)))
6617 (gnus-summary-mark-below nil) ; Inhibit this.
6619 ;; This will do all the work of generating the new summary buffer
6620 ;; according to the new limit.
6621 (gnus-summary-prepare)
6622 ;; Hide any threads, possibly.
6623 (and gnus-show-threads
6624 gnus-thread-hide-subtree
6625 (gnus-summary-hide-all-threads))
6626 ;; Try to return to the article you were at, or one in the
6629 ;; We try to find some article after the current one.
6631 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6634 (setq data (cdr data))))
6636 ;; If there is no data, that means that we were after the last
6637 ;; article. The same goes when we can't find any articles
6638 ;; after the current one.
6639 (goto-char (point-max))
6640 (gnus-summary-find-prev))
6641 (gnus-set-mode-line 'summary)
6642 ;; We return how many articles were removed from the summary
6643 ;; buffer as a result of the new limit.
6644 (- total (length gnus-newsgroup-data))))
6646 (defsubst gnus-invisible-cut-children (threads)
6649 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6654 (defsubst gnus-cut-thread (thread)
6655 "Go forwards in the thread until we find an article that we want to display."
6656 (when (or (eq gnus-fetch-old-headers 'some)
6657 (eq gnus-fetch-old-headers 'invisible)
6658 (numberp gnus-fetch-old-headers)
6659 (eq gnus-build-sparse-threads 'some)
6660 (eq gnus-build-sparse-threads 'more))
6661 ;; Deal with old-fetched headers and sparse threads.
6665 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6666 (gnus-summary-article-ancient-p
6667 (mail-header-number (car thread))))
6668 (if (or (<= (length (cdr thread)) 1)
6669 (eq gnus-fetch-old-headers 'invisible))
6670 (setq gnus-newsgroup-limit
6671 (delq (mail-header-number (car thread))
6672 gnus-newsgroup-limit)
6673 thread (cadr thread))
6674 (when (gnus-invisible-cut-children (cdr thread))
6675 (let ((th (cdr thread)))
6677 (if (memq (mail-header-number (caar th))
6678 gnus-newsgroup-limit)
6679 (setq thread (car th)
6681 (setq th (cdr th))))))))))
6684 (defun gnus-cut-threads (threads)
6685 "Cut off all uninteresting articles from the beginning of threads."
6686 (when (or (eq gnus-fetch-old-headers 'some)
6687 (eq gnus-fetch-old-headers 'invisible)
6688 (numberp gnus-fetch-old-headers)
6689 (eq gnus-build-sparse-threads 'some)
6690 (eq gnus-build-sparse-threads 'more))
6693 (setcar th (gnus-cut-thread (car th)))
6694 (setq th (cdr th)))))
6695 ;; Remove nixed out threads.
6698 (defun gnus-summary-initial-limit (&optional show-if-empty)
6699 "Figure out what the initial limit is supposed to be on group entry.
6700 This entails weeding out unwanted dormants, low-scored articles,
6701 fetch-old-headers verbiage, and so on."
6702 ;; Most groups have nothing to remove.
6703 (if (or gnus-inhibit-limiting
6704 (and (null gnus-newsgroup-dormant)
6705 (not (eq gnus-fetch-old-headers 'some))
6706 (not (numberp gnus-fetch-old-headers))
6707 (not (eq gnus-fetch-old-headers 'invisible))
6708 (null gnus-summary-expunge-below)
6709 (not (eq gnus-build-sparse-threads 'some))
6710 (not (eq gnus-build-sparse-threads 'more))
6711 (null gnus-thread-expunge-below)
6712 (not gnus-use-nocem)))
6714 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6715 (setq gnus-newsgroup-limit nil)
6718 (unless (car (symbol-value node))
6719 ;; These threads have no parents -- they are roots.
6720 (let ((nodes (cdr (symbol-value node)))
6723 (if (and gnus-thread-expunge-below
6724 (< (gnus-thread-total-score (car nodes))
6725 gnus-thread-expunge-below))
6726 (gnus-expunge-thread (pop nodes))
6727 (setq thread (pop nodes))
6728 (gnus-summary-limit-children thread))))))
6729 gnus-newsgroup-dependencies)
6730 ;; If this limitation resulted in an empty group, we might
6731 ;; pop the previous limit and use it instead.
6732 (when (and (not gnus-newsgroup-limit)
6734 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6735 gnus-newsgroup-limit))
6737 (defun gnus-summary-limit-children (thread)
6738 "Return 1 if this subthread is visible and 0 if it is not."
6739 ;; First we get the number of visible children to this thread. This
6740 ;; is done by recursing down the thread using this function, so this
6741 ;; will really go down to a leaf article first, before slowly
6742 ;; working its way up towards the root.
6746 (apply '+ (mapcar 'gnus-summary-limit-children
6749 (number (mail-header-number (car thread)))
6752 (not (memq number gnus-newsgroup-marked))
6754 ;; If this article is dormant and has absolutely no visible
6755 ;; children, then this article isn't visible.
6756 (and (memq number gnus-newsgroup-dormant)
6758 ;; If this is "fetch-old-headered" and there is no
6759 ;; visible children, then we don't want this article.
6760 (and (or (eq gnus-fetch-old-headers 'some)
6761 (numberp gnus-fetch-old-headers))
6762 (gnus-summary-article-ancient-p number)
6764 ;; If this is "fetch-old-headered" and `invisible', then
6765 ;; we don't want this article.
6766 (and (eq gnus-fetch-old-headers 'invisible)
6767 (gnus-summary-article-ancient-p number))
6768 ;; If this is a sparsely inserted article with no children,
6769 ;; we don't want it.
6770 (and (eq gnus-build-sparse-threads 'some)
6771 (gnus-summary-article-sparse-p number)
6773 ;; If we use expunging, and this article is really
6774 ;; low-scored, then we don't want this article.
6775 (when (and gnus-summary-expunge-below
6777 (or (cdr (assq number gnus-newsgroup-scored))
6778 gnus-summary-default-score))
6779 gnus-summary-expunge-below))
6780 ;; We increase the expunge-tally here, but that has
6781 ;; nothing to do with the limits, really.
6782 (incf gnus-newsgroup-expunged-tally)
6783 ;; We also mark as read here, if that's wanted.
6784 (when (and gnus-summary-mark-below
6785 (< score gnus-summary-mark-below))
6786 (setq gnus-newsgroup-unreads
6787 (delq number gnus-newsgroup-unreads))
6788 (if gnus-newsgroup-auto-expire
6789 (push number gnus-newsgroup-expirable)
6790 (push (cons number gnus-low-score-mark)
6791 gnus-newsgroup-reads)))
6793 ;; Check NoCeM things.
6794 (if (and gnus-use-nocem
6795 (gnus-nocem-unwanted-article-p
6796 (mail-header-id (car thread))))
6798 (setq gnus-newsgroup-unreads
6799 (delq number gnus-newsgroup-unreads))
6801 ;; Nope, invisible article.
6803 ;; Ok, this article is to be visible, so we add it to the limit
6805 (push number gnus-newsgroup-limit)
6808 (defun gnus-expunge-thread (thread)
6809 "Mark all articles in THREAD as read."
6810 (let* ((number (mail-header-number (car thread))))
6811 (incf gnus-newsgroup-expunged-tally)
6812 ;; We also mark as read here, if that's wanted.
6813 (setq gnus-newsgroup-unreads
6814 (delq number gnus-newsgroup-unreads))
6815 (if gnus-newsgroup-auto-expire
6816 (push number gnus-newsgroup-expirable)
6817 (push (cons number gnus-low-score-mark)
6818 gnus-newsgroup-reads)))
6819 ;; Go recursively through all subthreads.
6820 (mapcar 'gnus-expunge-thread (cdr thread)))
6822 ;; Summary article oriented commands
6824 (defun gnus-summary-refer-parent-article (n)
6825 "Refer parent article N times.
6826 If N is negative, go to ancestor -N instead.
6827 The difference between N and the number of articles fetched is returned."
6831 (when (not (natnump n))
6836 (setq header (gnus-summary-article-header))
6837 (if (and (eq (mail-header-number header)
6838 (cdr gnus-article-current))
6839 (equal gnus-newsgroup-name
6840 (car gnus-article-current)))
6841 ;; If we try to find the parent of the currently
6842 ;; displayed article, then we take a look at the actual
6843 ;; References header, since this is slightly more
6844 ;; reliable than the References field we got from the
6847 (set-buffer gnus-original-article-buffer)
6848 (nnheader-narrow-to-headers)
6849 (unless (setq ref (message-fetch-field "references"))
6850 (setq ref (message-fetch-field "in-reply-to")))
6853 ;; It's not the current article, so we take a bet on
6854 ;; the value we got from the server.
6855 (mail-header-references header)))
6857 (not (equal ref "")))
6858 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6859 (gnus-message 1 "Couldn't find parent"))
6860 (gnus-message 1 "No references in article %d"
6861 (gnus-summary-article-number))
6864 (gnus-summary-position-point)
6867 (defun gnus-summary-refer-references ()
6868 "Fetch all articles mentioned in the References header.
6869 Return the number of articles fetched."
6871 (let ((ref (mail-header-references (gnus-summary-article-header)))
6872 (current (gnus-summary-article-number))
6876 (error "No References in the current article")
6877 ;; For each Message-ID in the References header...
6878 (while (string-match "<[^>]*>" ref)
6880 ;; ... fetch that article.
6881 (gnus-summary-refer-article
6882 (prog1 (match-string 0 ref)
6883 (setq ref (substring ref (match-end 0))))))
6884 (gnus-summary-goto-subject current)
6885 (gnus-summary-position-point)
6888 (defun gnus-summary-refer-thread (&optional limit)
6889 "Fetch all articles in the current thread.
6890 If LIMIT (the numerical prefix), fetch that many old headers instead
6891 of what's specified by the `gnus-refer-thread-limit' variable."
6893 (let ((id (mail-header-id (gnus-summary-article-header)))
6894 (limit (if limit (prefix-numeric-value limit)
6895 gnus-refer-thread-limit)))
6896 ;; We want to fetch LIMIT *old* headers, but we also have to
6897 ;; re-fetch all the headers in the current buffer, because many of
6898 ;; them may be undisplayed. So we adjust LIMIT.
6899 (when (numberp limit)
6900 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6901 (unless (eq gnus-fetch-old-headers 'invisible)
6902 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6903 ;; Retrieve the headers and read them in.
6904 (if (eq (gnus-retrieve-headers
6905 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6907 (gnus-build-all-threads)
6908 (error "Can't fetch thread from backends that don't support NOV"))
6909 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6910 (gnus-summary-limit-include-thread id)))
6912 (defun gnus-summary-refer-article (message-id)
6913 "Fetch an article specified by MESSAGE-ID."
6914 (interactive "sMessage-ID: ")
6915 (when (and (stringp message-id)
6916 (not (zerop (length message-id))))
6917 ;; Construct the correct Message-ID if necessary.
6918 ;; Suggested by tale@pawl.rpi.edu.
6919 (unless (string-match "^<" message-id)
6920 (setq message-id (concat "<" message-id)))
6921 (unless (string-match ">$" message-id)
6922 (setq message-id (concat message-id ">")))
6923 (let* ((header (gnus-id-to-header message-id))
6925 (gnus-summary-article-sparse-p
6926 (mail-header-number header))
6927 (memq (mail-header-number header)
6928 gnus-newsgroup-limit)))
6931 ;; If the article is present in the buffer we just go to it.
6933 (or (not (gnus-summary-article-sparse-p
6934 (mail-header-number header)))
6937 (gnus-summary-goto-article
6938 (mail-header-number header) nil t)
6940 (gnus-summary-update-article (mail-header-number header)))))
6942 ;; We fetch the article.
6944 (dolist (gnus-override-method (gnus-refer-article-methods))
6945 (gnus-check-server gnus-override-method)
6946 ;; Fetch the header, and display the article.
6947 (when (setq number (gnus-summary-insert-subject message-id))
6948 (gnus-summary-select-article nil nil nil number)
6950 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6952 (defun gnus-refer-article-methods ()
6953 "Return a list of referrable methods."
6955 ;; No method, so we default to current and native.
6956 ((null gnus-refer-article-method)
6957 (list gnus-current-select-method gnus-select-method))
6959 ((eq 'current gnus-refer-article-method)
6960 (list gnus-current-select-method))
6961 ;; List of select methods.
6962 ((not (and (symbolp (car gnus-refer-article-method))
6963 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
6965 (dolist (method gnus-refer-article-method)
6966 (push (if (eq 'current method)
6967 gnus-current-select-method
6971 ;; One single select method.
6973 (list gnus-refer-article-method))))
6975 (defun gnus-summary-edit-parameters ()
6976 "Edit the group parameters of the current group."
6978 (gnus-group-edit-group gnus-newsgroup-name 'params))
6980 (defun gnus-summary-customize-parameters ()
6981 "Customize the group parameters of the current group."
6983 (gnus-group-customize gnus-newsgroup-name))
6985 (defun gnus-summary-enter-digest-group (&optional force)
6986 "Enter an nndoc group based on the current article.
6987 If FORCE, force a digest interpretation. If not, try
6988 to guess what the document format is."
6990 (let ((conf gnus-current-window-configuration))
6992 (gnus-summary-select-article))
6993 (setq gnus-current-window-configuration conf)
6994 (let* ((name (format "%s-%d"
6995 (gnus-group-prefixed-name
6996 gnus-newsgroup-name (list 'nndoc ""))
6998 (set-buffer gnus-summary-buffer)
6999 gnus-current-article)))
7000 (ogroup gnus-newsgroup-name)
7001 (params (append (gnus-info-params (gnus-get-info ogroup))
7002 (list (cons 'to-group ogroup))
7003 (list (cons 'save-article-group ogroup))))
7004 (case-fold-search t)
7005 (buf (current-buffer))
7008 (set-buffer gnus-original-article-buffer)
7009 ;; Have the digest group inherit the main mail address of
7010 ;; the parent article.
7011 (when (setq to-address (or (message-fetch-field "reply-to")
7012 (message-fetch-field "from")))
7013 (setq params (append
7014 (list (cons 'to-address
7015 (funcall gnus-decode-encoded-word-function
7017 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7018 (insert-buffer-substring gnus-original-article-buffer)
7019 ;; Remove lines that may lead nndoc to misinterpret the
7022 (goto-char (point-min))
7023 (or (search-forward "\n\n" nil t) (point)))
7024 (goto-char (point-min))
7025 (delete-matching-lines "^Path:\\|^From ")
7028 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7029 (gnus-newsgroup-ephemeral-ignored-charsets
7030 gnus-newsgroup-ignored-charsets))
7031 (gnus-group-read-ephemeral-group
7032 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7034 ,(if force 'mbox 'guess))) t))
7035 ;; Make all postings to this group go to the parent group.
7036 (nconc (gnus-info-params (gnus-get-info name))
7038 ;; Couldn't select this doc group.
7039 (switch-to-buffer buf)
7040 (gnus-set-global-variables)
7041 (gnus-configure-windows 'summary)
7042 (gnus-message 3 "Article couldn't be entered?"))
7043 (kill-buffer dig)))))
7045 (defun gnus-summary-read-document (n)
7046 "Open a new group based on the current article(s).
7047 This will allow you to read digests and other similar
7048 documents as newsgroups.
7049 Obeys the standard process/prefix convention."
7051 (let* ((articles (gnus-summary-work-articles n))
7052 (ogroup gnus-newsgroup-name)
7053 (params (append (gnus-info-params (gnus-get-info ogroup))
7054 (list (cons 'to-group ogroup))))
7055 article group egroup groups vgroup)
7056 (while (setq article (pop articles))
7057 (setq group (format "%s-%d" gnus-newsgroup-name article))
7058 (gnus-summary-remove-process-mark article)
7059 (when (gnus-summary-display-article article)
7062 (insert-buffer-substring gnus-original-article-buffer)
7063 ;; Remove some headers that may lead nndoc to make
7065 (message-narrow-to-head)
7066 (goto-char (point-min))
7067 (delete-matching-lines "^\\(Path\\):\\|^From ")
7070 (gnus-group-read-ephemeral-group
7071 group `(nndoc ,group (nndoc-address ,(current-buffer))
7072 (nndoc-article-type guess))
7075 ;; Make all postings to this group go to the parent group.
7076 (nconc (gnus-info-params (gnus-get-info egroup))
7078 (push egroup groups))
7079 ;; Couldn't select this doc group.
7080 (gnus-error 3 "Article couldn't be entered"))))))
7081 ;; Now we have selected all the documents.
7084 (error "None of the articles could be interpreted as documents"))
7085 ((gnus-group-read-ephemeral-group
7086 (setq vgroup (format
7087 "nnvirtual:%s-%s" gnus-newsgroup-name
7088 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7089 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7091 (cons (current-buffer) 'summary)))
7093 (error "Couldn't select virtual nndoc group")))))
7095 (defun gnus-summary-isearch-article (&optional regexp-p)
7096 "Do incremental search forward on the current article.
7097 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7099 (let* ((gnus-inhibit-treatment t)
7100 (old (gnus-summary-select-article)))
7101 (gnus-configure-windows 'article)
7102 (gnus-eval-in-buffer-window gnus-article-buffer
7106 (gnus-article-show-all-headers))
7107 (goto-char (point-min))
7108 (isearch-forward regexp-p)))))
7110 (defun gnus-summary-search-article-forward (regexp &optional backward)
7111 "Search for an article containing REGEXP forward.
7112 If BACKWARD, search backward instead."
7115 (format "Search article %s (regexp%s): "
7116 (if current-prefix-arg "backward" "forward")
7117 (if gnus-last-search-regexp
7118 (concat ", default " gnus-last-search-regexp)
7120 current-prefix-arg))
7121 (if (string-equal regexp "")
7122 (setq regexp (or gnus-last-search-regexp ""))
7123 (setq gnus-last-search-regexp regexp)
7124 (setq gnus-article-before-search gnus-current-article))
7125 ;; Intentionally set gnus-last-article.
7126 (setq gnus-last-article gnus-article-before-search)
7127 (let ((gnus-last-article gnus-last-article))
7128 (if (gnus-summary-search-article regexp backward)
7129 (gnus-summary-show-thread)
7130 (error "Search failed: \"%s\"" regexp))))
7132 (defun gnus-summary-search-article-backward (regexp)
7133 "Search for an article containing REGEXP backward."
7136 (format "Search article backward (regexp%s): "
7137 (if gnus-last-search-regexp
7138 (concat ", default " gnus-last-search-regexp)
7140 (gnus-summary-search-article-forward regexp 'backward))
7143 (defmacro gnus-summary-search-article-position-point (regexp backward)
7144 "Dehighlight the last matched text and goto the beginning position."
7145 (` (if (and gnus-summary-search-article-matched-data
7146 (let ((text (caddr gnus-summary-search-article-matched-data))
7147 (inhibit-read-only t)
7150 (goto-char (car gnus-summary-search-article-matched-data))
7151 (cadr gnus-summary-search-article-matched-data))
7153 (string-match (, regexp) text)))
7154 (if (, backward) (beginning-of-line) (end-of-line))
7155 (goto-char (if (, backward) (point-max) (point-min))))))
7157 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7158 "Place point where X-Face image is displayed."
7159 (if (featurep 'xemacs)
7160 (` (let ((end (if (search-forward "\n\n" nil t)
7161 (goto-char (1- (point)))
7164 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7165 (unless (and (re-search-forward "^From:" end t)
7166 (setq extent (extent-at (point)))
7167 (extent-begin-glyph extent))
7168 (goto-char (, opoint)))))
7169 (` (let ((end (if (search-forward "\n\n" nil t)
7170 (goto-char (1- (point)))
7173 (or (text-property-any (or (search-backward "\n\n" nil t)
7175 end 'x-face-mule-bitmap-image t)
7178 (defmacro gnus-summary-search-article-highlight-matched-text
7179 (backward treated x-face)
7180 "Highlight matched text in the function `gnus-summary-search-article'."
7181 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7182 (end (set-marker (make-marker) (match-end 0)))
7183 (inhibit-read-only t)
7187 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7189 (lambda (item) (setq items (delq item items)))
7190 '(gnus-treat-buttonize
7191 gnus-treat-fill-article
7192 gnus-treat-fill-long-lines
7193 gnus-treat-emphasize
7194 gnus-treat-highlight-headers
7195 gnus-treat-highlight-citation
7196 gnus-treat-highlight-signature
7197 gnus-treat-overstrike
7198 gnus-treat-display-xface
7199 gnus-treat-buttonize-head
7200 gnus-treat-decode-article-as-default-mime-charset))
7201 (static-if (featurep 'xemacs)
7203 (cons '(x-face-mule-delete-x-face-field
7206 (gnus-treat-display-xface
7207 (when (, x-face) gnus-treat-display-xface)))
7208 (gnus-article-prepare-mime-display)))
7209 (goto-char (if (, backward) start end))
7211 (gnus-summary-search-article-highlight-goto-x-face (point)))
7212 (setq gnus-summary-search-article-matched-data
7213 (list start end (buffer-substring start end)))
7214 (unless (eq start end);; matched text has been deleted. :-<
7215 (put-text-property start end 'face
7216 (or (find-face 'isearch)
7217 'secondary-selection))))))
7220 (defun gnus-summary-search-article (regexp &optional backward)
7221 "Search for an article containing REGEXP.
7222 Optional argument BACKWARD means do search for backward.
7223 `gnus-select-article-hook' is not called during the search."
7224 ;; We have to require this here to make sure that the following
7225 ;; dynamic binding isn't shadowed by autoloading.
7226 (require 'gnus-async)
7228 (let ((gnus-select-article-hook nil) ;Disable hook.
7229 (gnus-article-display-hook nil)
7230 (gnus-article-prepare-hook nil)
7231 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7232 (gnus-use-article-prefetch nil)
7233 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7234 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7235 (sum (current-buffer))
7238 (gnus-save-hidden-threads
7239 (static-if (featurep 'xemacs)
7240 (let ((gnus-inhibit-treatment t))
7241 (setq treated (eq 'old (gnus-summary-select-article)))
7243 (not (and (gnus-buffer-live-p gnus-article-buffer)
7244 (window-live-p (get-buffer-window
7245 gnus-article-buffer t)))))
7246 (gnus-summary-select-article nil t)
7247 (setq treated nil)))
7248 (let ((gnus-inhibit-treatment t)
7249 (x-face-mule-delete-x-face-field 'never))
7250 (setq treated (eq 'old (gnus-summary-select-article)))
7253 (and (gnus-buffer-live-p gnus-article-buffer)
7254 (window-live-p (get-buffer-window
7255 gnus-article-buffer t))
7256 (or (not (string-match "^\\^X-Face:" regexp))
7257 (with-current-buffer gnus-article-buffer
7258 gnus-summary-search-article-matched-data)))))
7259 (gnus-summary-select-article nil t)
7260 (setq treated nil))))
7261 (set-buffer gnus-article-buffer)
7265 (gnus-article-show-all-headers)
7266 (gnus-summary-search-article-position-point regexp backward))
7267 (goto-char (if backward (point-max) (point-min))))
7269 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7271 (re-search-backward regexp nil t)
7272 (re-search-forward regexp nil t))
7273 ;; We found the regexp.
7275 (gnus-summary-search-article-highlight-matched-text
7276 backward treated (string-match "^\\^X-Face:" regexp))
7279 (/ (- 2 (window-height
7280 (get-buffer-window gnus-article-buffer t)))
7283 (get-buffer-window (current-buffer))
7286 (setq point (point)))
7287 ;; We didn't find it, so we go to the next article.
7290 (while (eq found 'not)
7291 (if (not (if backward (gnus-summary-find-prev)
7292 (gnus-summary-find-next)))
7293 ;; No more articles.
7295 ;; Select the next article and adjust point.
7296 (unless (gnus-summary-article-sparse-p
7297 (gnus-summary-article-number))
7299 (let ((gnus-inhibit-treatment t))
7300 (gnus-summary-select-article))
7302 (set-buffer gnus-article-buffer)
7304 (goto-char (if backward (point-max) (point-min))))))))
7305 (gnus-message 7 ""))
7306 ;; Return whether we found the regexp.
7307 (when (eq found 'found)
7309 (gnus-summary-show-thread)
7310 (gnus-summary-goto-subject gnus-current-article)
7311 (gnus-summary-position-point)
7314 (defun gnus-summary-find-matching (header regexp &optional backward unread
7316 "Return a list of all articles that match REGEXP on HEADER.
7317 The search stars on the current article and goes forwards unless
7318 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7319 If UNREAD is non-nil, only unread articles will
7320 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7321 in the comparisons."
7322 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7323 (gnus-data-find-list
7324 (gnus-summary-article-number) (gnus-data-list backward))))
7325 (case-fold-search (not not-case-fold))
7328 (if (eq (car header) 'extra)
7331 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7333 (error "%s is an invalid header" header))
7334 (unless (fboundp (intern (concat "mail-header-" header)))
7335 (error "%s is not a valid header" header))
7336 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7339 (and (or (not unread) ; We want all articles...
7340 (gnus-data-unread-p d)) ; Or just unreads.
7341 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7342 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7343 (push (gnus-data-number d) articles)) ; Success!
7344 (setq data (cdr data)))
7345 (nreverse articles)))
7347 (defun gnus-summary-execute-command (header regexp command &optional backward)
7348 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7349 If HEADER is an empty string (or nil), the match is done on the entire
7350 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7352 (list (let ((completion-ignore-case t))
7355 (mapcar (lambda (string) (list string))
7356 '("Number" "Subject" "From" "Lines" "Date"
7357 "Message-ID" "Xref" "References" "Body"))
7358 nil 'require-match))
7359 (read-string "Regexp: ")
7360 (read-key-sequence "Command: ")
7361 current-prefix-arg))
7362 (when (equal header "Body")
7364 ;; Hidden thread subtrees must be searched as well.
7365 (gnus-summary-show-all-threads)
7366 ;; We don't want to change current point nor window configuration.
7368 (save-window-excursion
7369 (gnus-message 6 "Executing %s..." (key-description command))
7370 ;; We'd like to execute COMMAND interactively so as to give arguments.
7371 (gnus-execute header regexp
7372 `(call-interactively ',(key-binding command))
7374 (gnus-message 6 "Executing %s...done" (key-description command)))))
7376 (defun gnus-summary-beginning-of-article ()
7377 "Scroll the article back to the beginning."
7379 (gnus-summary-select-article)
7380 (gnus-configure-windows 'article)
7381 (gnus-eval-in-buffer-window gnus-article-buffer
7383 (goto-char (point-min))
7384 (when gnus-page-broken
7385 (gnus-narrow-to-page))))
7387 (defun gnus-summary-end-of-article ()
7388 "Scroll to the end of the article."
7390 (gnus-summary-select-article)
7391 (gnus-configure-windows 'article)
7392 (gnus-eval-in-buffer-window gnus-article-buffer
7394 (goto-char (point-max))
7396 (when gnus-page-broken
7397 (gnus-narrow-to-page))))
7399 (defun gnus-summary-print-article (&optional filename n)
7400 "Generate and print a PostScript image of the N next (mail) articles.
7402 If N is negative, print the N previous articles. If N is nil and articles
7403 have been marked with the process mark, print these instead.
7405 If the optional first argument FILENAME is nil, send the image to the
7406 printer. If FILENAME is a string, save the PostScript image in a file with
7407 that name. If FILENAME is a number, prompt the user for the name of the file
7409 (interactive (list (ps-print-preprint current-prefix-arg)
7410 current-prefix-arg))
7411 (dolist (article (gnus-summary-work-articles n))
7412 (gnus-summary-select-article nil nil 'pseudo article)
7413 (gnus-eval-in-buffer-window gnus-article-buffer
7414 (let ((buffer (generate-new-buffer " *print*")))
7417 (copy-to-buffer buffer (point-min) (point-max))
7419 (gnus-article-delete-invisible-text)
7420 (let ((ps-left-header
7423 (mail-header-subject gnus-current-headers) ")")
7425 (mail-header-from gnus-current-headers) ")")))
7428 "/pagenumberstring load"
7430 (mail-header-date gnus-current-headers) ")"))))
7431 (gnus-run-hooks 'gnus-ps-print-hook)
7433 (ps-print-buffer-with-faces filename))))
7434 (kill-buffer buffer))))))
7436 (defun gnus-summary-show-article (&optional arg)
7437 "Force re-fetching of the current article.
7438 If ARG (the prefix) is a number, show the article with the charset
7439 defined in `gnus-summary-show-article-charset-alist', or the charset
7441 If ARG (the prefix) is non-nil and not a number, show the raw article
7442 without any article massaging functions being run."
7446 (let ((gnus-newsgroup-charset
7447 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7448 (read-coding-system "Charset: ")))
7449 (gnus-newsgroup-ignored-charsets 'gnus-all))
7450 (gnus-summary-select-article nil 'force)
7451 (let ((deps gnus-newsgroup-dependencies)
7454 (set-buffer gnus-original-article-buffer)
7456 (message-narrow-to-head)
7457 (setq head (buffer-string)))
7459 (insert (format "211 %d Article retrieved.\n"
7460 (cdr gnus-article-current)))
7463 (let ((nntp-server-buffer (current-buffer)))
7464 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7465 (gnus-data-set-header
7466 (gnus-data-find (cdr gnus-article-current))
7468 (gnus-summary-update-article-line
7469 (cdr gnus-article-current) header))))
7471 ;; Select the article the normal way.
7472 (gnus-summary-select-article nil 'force))
7474 ;; We have to require this here to make sure that the following
7475 ;; dynamic binding isn't shadowed by autoloading.
7476 (require 'gnus-async)
7478 ;; Bind the article treatment functions to nil.
7479 (let ((gnus-have-all-headers t)
7480 gnus-article-display-hook
7481 gnus-article-prepare-hook
7482 gnus-article-decode-hook
7485 (gnus-summary-select-article nil 'force))))
7486 (gnus-summary-goto-subject gnus-current-article)
7487 (gnus-summary-position-point))
7489 (defun gnus-summary-verbose-headers (&optional arg)
7490 "Toggle permanent full header display.
7491 If ARG is a positive number, turn header display on.
7492 If ARG is a negative number, turn header display off."
7494 (setq gnus-show-all-headers
7495 (cond ((or (not (numberp arg))
7497 (not gnus-show-all-headers))
7500 (gnus-summary-show-article))
7502 (defun gnus-summary-toggle-header (&optional arg)
7503 "Show the headers if they are hidden, or hide them if they are shown.
7504 If ARG is a positive number, show the entire header.
7505 If ARG is a negative number, hide the unwanted header lines."
7508 (set-buffer gnus-article-buffer)
7510 (let* ((buffer-read-only nil)
7511 (inhibit-point-motion-hooks t)
7517 (article-narrow-to-head)
7518 (gnus-article-hidden-text-p 'headers))))
7519 (goto-char (point-min))
7520 (when (search-forward "\n\n" nil t)
7521 (delete-region (point-min) (1- (point))))
7522 (goto-char (point-min))
7524 (set-buffer gnus-original-article-buffer)
7525 (goto-char (point-min))
7526 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7527 (insert-buffer-substring gnus-original-article-buffer 1 e)
7529 (narrow-to-region (point-min) (point))
7530 (article-decode-encoded-words)
7532 (let ((gnus-treat-hide-headers nil)
7533 (gnus-treat-hide-boring-headers nil))
7534 (setq gnus-article-wash-types
7535 (delq 'headers gnus-article-wash-types))
7536 (gnus-treat-article 'head))
7537 (gnus-treat-article 'head)))
7538 (gnus-set-mode-line 'article)))))
7540 (defun gnus-summary-show-all-headers ()
7541 "Make all header lines visible."
7543 (gnus-article-show-all-headers))
7545 (defun gnus-summary-toggle-mime (&optional arg)
7546 "Toggle MIME processing.
7547 If ARG is a positive number, turn MIME processing on."
7549 (setq gnus-show-mime
7551 (not gnus-show-mime)
7552 (> (prefix-numeric-value arg) 0)))
7553 (gnus-summary-select-article t 'force))
7555 (defun gnus-summary-caesar-message (&optional arg)
7556 "Caesar rotate the current article by 13.
7557 The numerical prefix specifies how many places to rotate each letter
7560 (gnus-summary-select-article)
7561 (let ((mail-header-separator ""))
7562 (gnus-eval-in-buffer-window gnus-article-buffer
7565 (let ((start (window-start))
7567 (message-caesar-buffer-body arg)
7568 (set-window-start (get-buffer-window (current-buffer)) start))))))
7570 (defun gnus-summary-stop-page-breaking ()
7571 "Stop page breaking in the current article."
7573 (gnus-summary-select-article)
7574 (gnus-eval-in-buffer-window gnus-article-buffer
7576 (when (gnus-visual-p 'page-marker)
7577 (let ((buffer-read-only nil))
7578 (gnus-remove-text-with-property 'gnus-prev)
7579 (gnus-remove-text-with-property 'gnus-next))
7580 (setq gnus-page-broken nil))))
7582 (defun gnus-summary-move-article (&optional n to-newsgroup
7583 select-method action)
7584 "Move the current article to a different newsgroup.
7585 If N is a positive number, move the N next articles.
7586 If N is a negative number, move the N previous articles.
7587 If N is nil and any articles have been marked with the process mark,
7588 move those articles instead.
7589 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7590 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7591 re-spool using this method.
7593 For this function to work, both the current newsgroup and the
7594 newsgroup that you want to move to have to support the `request-move'
7595 and `request-accept' functions.
7597 ACTION can be either `move' (the default), `crosspost' or `copy'."
7600 (setq action 'move))
7601 ;; Disable marking as read.
7602 (let (gnus-mark-article-hook)
7603 (save-window-excursion
7604 (gnus-summary-select-article)))
7605 ;; Check whether the source group supports the required functions.
7606 (cond ((and (eq action 'move)
7607 (not (gnus-check-backend-function
7608 'request-move-article gnus-newsgroup-name)))
7609 (error "The current group does not support article moving"))
7610 ((and (eq action 'crosspost)
7611 (not (gnus-check-backend-function
7612 'request-replace-article gnus-newsgroup-name)))
7613 (error "The current group does not support article editing")))
7614 (let ((articles (gnus-summary-work-articles n))
7615 (prefix (if (gnus-check-backend-function
7616 'request-move-article gnus-newsgroup-name)
7617 (gnus-group-real-prefix gnus-newsgroup-name)
7619 (names '((move "Move" "Moving")
7620 (copy "Copy" "Copying")
7621 (crosspost "Crosspost" "Crossposting")))
7622 (copy-buf (save-excursion
7623 (nnheader-set-temp-buffer " *copy article*")))
7624 (default-marks gnus-article-mark-lists)
7625 (no-expire-marks (delete '(expirable . expire)
7626 (copy-sequence gnus-article-mark-lists)))
7627 art-group to-method new-xref article to-groups)
7628 (unless (assq action names)
7629 (error "Unknown action %s" action))
7630 ;; Read the newsgroup name.
7631 (when (and (not to-newsgroup)
7632 (not select-method))
7634 (gnus-read-move-group-name
7635 (cadr (assq action names))
7636 (symbol-value (intern (format "gnus-current-%s-group" action)))
7638 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7639 (setq to-method (or select-method
7640 (gnus-server-to-method
7641 (gnus-group-method to-newsgroup))))
7642 ;; Check the method we are to move this article to...
7643 (unless (gnus-check-backend-function
7644 'request-accept-article (car to-method))
7645 (error "%s does not support article copying" (car to-method)))
7646 (unless (gnus-check-server to-method)
7647 (error "Can't open server %s" (car to-method)))
7648 (gnus-message 6 "%s to %s: %s..."
7649 (caddr (assq action names))
7650 (or (car select-method) to-newsgroup) articles)
7652 (setq article (pop articles))
7656 ;; Move the article.
7658 ;; Remove this article from future suppression.
7659 (gnus-dup-unsuppress-article article)
7660 (gnus-request-move-article
7661 article ; Article to move
7662 gnus-newsgroup-name ; From newsgroup
7663 (nth 1 (gnus-find-method-for-group
7664 gnus-newsgroup-name)) ; Server
7665 (list 'gnus-request-accept-article
7666 to-newsgroup (list 'quote select-method)
7667 (not articles) t) ; Accept form
7668 (not articles))) ; Only save nov last time
7669 ;; Copy the article.
7672 (set-buffer copy-buf)
7673 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7674 (gnus-request-accept-article
7675 to-newsgroup select-method (not articles) t))))
7676 ;; Crosspost the article.
7677 ((eq action 'crosspost)
7678 (let ((xref (message-tokenize-header
7679 (mail-header-xref (gnus-summary-article-header article))
7681 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7684 (setq xref (list (system-name))))
7687 (mapconcat 'identity
7688 (delete "Xref:" (delete new-xref xref))
7692 (set-buffer copy-buf)
7693 ;; First put the article in the destination group.
7694 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7695 (when (consp (setq art-group
7696 (gnus-request-accept-article
7697 to-newsgroup select-method (not articles))))
7698 (setq new-xref (concat new-xref " " (car art-group)
7699 ":" (cdr art-group)))
7700 ;; Now we have the new Xrefs header, so we insert
7701 ;; it and replace the new article.
7702 (nnheader-replace-header "Xref" new-xref)
7703 (gnus-request-replace-article
7704 (cdr art-group) to-newsgroup (current-buffer))
7708 (gnus-message 1 "Couldn't %s article %s: %s"
7709 (cadr (assq action names)) article
7710 (nnheader-get-report (car to-method))))
7711 ((eq art-group 'junk)
7712 (when (eq action 'move)
7713 (gnus-summary-mark-article article gnus-canceled-mark)
7714 (gnus-message 4 "Deleted article %s" article)))
7716 (let* ((pto-group (gnus-group-prefixed-name
7717 (car art-group) to-method))
7719 (gnus-gethash pto-group gnus-newsrc-hashtb))
7720 (info (nth 2 entry))
7721 (to-group (gnus-info-group info))
7723 ;; Update the group that has been moved to.
7725 (memq action '(move copy)))
7726 (unless (member to-group to-groups)
7727 (push to-group to-groups))
7729 (unless (memq article gnus-newsgroup-unreads)
7730 (push 'read to-marks)
7732 info (gnus-add-to-range (gnus-info-read info)
7733 (list (cdr art-group)))))
7735 ;; See whether the article is to be put in the cache.
7736 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7739 (to-article (cdr art-group)))
7741 ;; Enter the article into the cache in the new group,
7742 ;; if that is required.
7743 (when gnus-use-cache
7744 (gnus-cache-possibly-enter-article
7746 (let ((header (copy-sequence
7747 (gnus-summary-article-header article))))
7748 (mail-header-set-number header to-article)
7750 (memq article gnus-newsgroup-marked)
7751 (memq article gnus-newsgroup-dormant)
7752 (memq article gnus-newsgroup-unreads)))
7754 (when gnus-preserve-marks
7755 ;; Copy any marks over to the new group.
7756 (when (and (equal to-group gnus-newsgroup-name)
7757 (not (memq article gnus-newsgroup-unreads)))
7758 ;; Mark this article as read in this group.
7759 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7760 (setcdr (gnus-active to-group) to-article)
7761 (setcdr gnus-newsgroup-active to-article))
7764 (when (memq article (symbol-value
7765 (intern (format "gnus-newsgroup-%s"
7767 (push (cdar marks) to-marks)
7768 ;; If the other group is the same as this group,
7769 ;; then we have to add the mark to the list.
7770 (when (equal to-group gnus-newsgroup-name)
7771 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7774 (intern (format "gnus-newsgroup-%s"
7776 ;; Copy the marks to other group.
7777 (gnus-add-marked-articles
7778 to-group (cdar marks) (list to-article) info))
7779 (setq marks (cdr marks)))
7781 (gnus-request-set-mark to-group (list (list (list to-article)
7786 (concat "(gnus-group-set-info '"
7787 (gnus-prin1-to-string (gnus-get-info to-group))
7790 ;; Update the Xref header in this article to point to
7791 ;; the new crossposted article we have just created.
7792 (when (eq action 'crosspost)
7794 (set-buffer copy-buf)
7795 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7796 (nnheader-replace-header "Xref" new-xref)
7797 (gnus-request-replace-article
7798 article gnus-newsgroup-name (current-buffer)))))
7800 ;;;!!!Why is this necessary?
7801 (set-buffer gnus-summary-buffer)
7803 (gnus-summary-goto-subject article)
7804 (when (eq action 'move)
7805 (gnus-summary-mark-article article gnus-canceled-mark))))
7806 (gnus-summary-remove-process-mark article))
7807 ;; Re-activate all groups that have been moved to.
7810 (set-buffer gnus-group-buffer)
7811 (when (gnus-group-goto-group (car to-groups) t)
7812 (gnus-group-get-new-news-this-group 1 t))
7815 (gnus-kill-buffer copy-buf)
7816 (gnus-summary-position-point)
7817 (gnus-set-mode-line 'summary)))
7819 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7820 "Move the current article to a different newsgroup.
7821 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7822 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7823 re-spool using this method."
7825 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7827 (defun gnus-summary-crosspost-article (&optional n)
7828 "Crosspost the current article to some other group."
7830 (gnus-summary-move-article n nil nil 'crosspost))
7832 (defcustom gnus-summary-respool-default-method nil
7833 "Default method for respooling an article.
7834 If nil, use to the current newsgroup method."
7835 :type '(choice (gnus-select-method :value (nnml ""))
7837 :group 'gnus-summary-mail)
7839 (defun gnus-summary-respool-article (&optional n method)
7840 "Respool the current article.
7841 The article will be squeezed through the mail spooling process again,
7842 which means that it will be put in some mail newsgroup or other
7843 depending on `nnmail-split-methods'.
7844 If N is a positive number, respool the N next articles.
7845 If N is a negative number, respool the N previous articles.
7846 If N is nil and any articles have been marked with the process mark,
7847 respool those articles instead.
7849 Respooling can be done both from mail groups and \"real\" newsgroups.
7850 In the former case, the articles in question will be moved from the
7851 current group into whatever groups they are destined to. In the
7852 latter case, they will be copied into the relevant groups."
7854 (list current-prefix-arg
7855 (let* ((methods (gnus-methods-using 'respool))
7857 (symbol-name (or gnus-summary-respool-default-method
7858 (car (gnus-find-method-for-group
7859 gnus-newsgroup-name)))))
7861 (gnus-completing-read
7862 methname "What backend do you want to use when respooling?"
7863 methods nil t nil 'gnus-mail-method-history))
7866 ((zerop (length (setq ms (gnus-servers-using-backend
7868 (list (intern method) ""))
7872 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7873 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7876 (error "No method given for respooling"))
7877 (if (assoc (symbol-name
7878 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7879 (gnus-methods-using 'respool))
7880 (gnus-summary-move-article n nil method)
7881 (gnus-summary-copy-article n nil method)))
7883 (defun gnus-summary-import-article (file)
7884 "Import an arbitrary file into a mail newsgroup."
7885 (interactive "fImport file: ")
7886 (let ((group gnus-newsgroup-name)
7887 (now (current-time))
7889 (unless (gnus-check-backend-function 'request-accept-article group)
7890 (error "%s does not support article importing" group))
7891 (or (file-readable-p file)
7892 (not (file-regular-p file))
7893 (error "Can't read %s" file))
7895 (set-buffer (gnus-get-buffer-create " *import file*"))
7897 (nnheader-insert-file-contents file)
7898 (goto-char (point-min))
7899 (unless (nnheader-article-p)
7900 ;; This doesn't look like an article, so we fudge some headers.
7901 (setq atts (file-attributes file)
7902 lines (count-lines (point-min) (point-max)))
7903 (insert "From: " (read-string "From: ") "\n"
7904 "Subject: " (read-string "Subject: ") "\n"
7905 "Date: " (message-make-date (nth 5 atts))
7907 "Message-ID: " (message-make-message-id) "\n"
7908 "Lines: " (int-to-string lines) "\n"
7909 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7910 (gnus-request-accept-article group nil t)
7911 (kill-buffer (current-buffer)))))
7913 (defun gnus-summary-article-posted-p ()
7914 "Say whether the current (mail) article is available from news as well.
7915 This will be the case if the article has both been mailed and posted."
7917 (let ((id (mail-header-references (gnus-summary-article-header)))
7918 (gnus-override-method (car (gnus-refer-article-methods))))
7919 (if (gnus-request-head id "")
7920 (gnus-message 2 "The current message was found on %s"
7921 gnus-override-method)
7922 (gnus-message 2 "The current message couldn't be found on %s"
7923 gnus-override-method)
7926 (defun gnus-summary-expire-articles (&optional now)
7927 "Expire all articles that are marked as expirable in the current group."
7929 (when (gnus-check-backend-function
7930 'request-expire-articles gnus-newsgroup-name)
7931 ;; This backend supports expiry.
7932 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7933 (expirable (if total
7935 ;; We need to update the info for
7936 ;; this group for `gnus-list-of-read-articles'
7937 ;; to give us the right answer.
7938 (gnus-run-hooks 'gnus-exit-group-hook)
7939 (gnus-summary-update-info)
7940 (gnus-list-of-read-articles gnus-newsgroup-name))
7941 (setq gnus-newsgroup-expirable
7942 (sort gnus-newsgroup-expirable '<))))
7943 (expiry-wait (if now 'immediate
7944 (gnus-group-find-parameter
7945 gnus-newsgroup-name 'expiry-wait)))
7946 (nnmail-expiry-target
7947 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7948 nnmail-expiry-target))
7951 ;; There are expirable articles in this group, so we run them
7952 ;; through the expiry process.
7953 (gnus-message 6 "Expiring articles...")
7954 (unless (gnus-check-group gnus-newsgroup-name)
7955 (error "Can't open server for %s" gnus-newsgroup-name))
7956 ;; The list of articles that weren't expired is returned.
7959 (let ((nnmail-expiry-wait-function nil)
7960 (nnmail-expiry-wait expiry-wait))
7961 (setq es (gnus-request-expire-articles
7962 expirable gnus-newsgroup-name)))
7963 (setq es (gnus-request-expire-articles
7964 expirable gnus-newsgroup-name)))
7966 (setq gnus-newsgroup-expirable es))
7967 ;; We go through the old list of expirable, and mark all
7968 ;; really expired articles as nonexistent.
7969 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7970 (let ((gnus-use-cache nil))
7972 (unless (memq (car expirable) es)
7973 (when (gnus-data-find (car expirable))
7974 (gnus-summary-mark-article
7975 (car expirable) gnus-canceled-mark)))
7976 (setq expirable (cdr expirable))))))
7977 (gnus-message 6 "Expiring articles...done")))))
7979 (defun gnus-summary-expire-articles-now ()
7980 "Expunge all expirable articles in the current group.
7981 This means that *all* articles that are marked as expirable will be
7982 deleted forever, right now."
7984 (or gnus-expert-user
7986 "Are you really, really, really sure you want to delete all these messages? ")
7988 (gnus-summary-expire-articles t))
7990 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7991 (defun gnus-summary-delete-article (&optional n)
7992 "Delete the N next (mail) articles.
7993 This command actually deletes articles. This is not a marking
7994 command. The article will disappear forever from your life, never to
7996 If N is negative, delete backwards.
7997 If N is nil and articles have been marked with the process mark,
7998 delete these instead."
8000 (unless (gnus-check-backend-function 'request-expire-articles
8001 gnus-newsgroup-name)
8002 (error "The current newsgroup does not support article deletion"))
8003 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8004 (error "Couldn't open server"))
8005 ;; Compute the list of articles to delete.
8006 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8008 (if (and gnus-novice-user
8009 (not (gnus-yes-or-no-p
8010 (format "Do you really want to delete %s forever? "
8011 (if (> (length articles) 1)
8012 (format "these %s articles" (length articles))
8015 ;; Delete the articles.
8016 (setq not-deleted (gnus-request-expire-articles
8017 articles gnus-newsgroup-name 'force))
8019 (gnus-summary-remove-process-mark (car articles))
8020 ;; The backend might not have been able to delete the article
8022 (unless (memq (car articles) not-deleted)
8023 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8024 (setq articles (cdr articles)))
8026 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8027 (gnus-summary-position-point)
8028 (gnus-set-mode-line 'summary)
8031 (defun gnus-summary-edit-article (&optional force)
8032 "Edit the current article.
8033 This will have permanent effect only in mail groups.
8034 If FORCE is non-nil, allow editing of articles even in read-only
8038 (set-buffer gnus-summary-buffer)
8039 (let ((mail-parse-charset gnus-newsgroup-charset)
8040 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8041 (gnus-set-global-variables)
8042 (when (and (not force)
8043 (gnus-group-read-only-p))
8044 (error "The current newsgroup does not support article editing"))
8045 (gnus-summary-show-article t)
8046 (gnus-article-edit-article
8048 `(lambda (no-highlight)
8049 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8050 (message-options message-options)
8051 (message-options-set-recipient)
8052 (mail-parse-ignored-charsets
8053 ',gnus-newsgroup-ignored-charsets))
8054 (gnus-summary-edit-article-done
8055 ,(or (mail-header-references gnus-current-headers) "")
8056 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8058 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8060 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8062 "Make edits to the current article permanent."
8065 ;; The buffer restriction contains the entire article if it exists.
8066 (when (article-goto-body)
8067 (let ((lines (count-lines (point) (point-max)))
8068 (length (- (point-max) (point)))
8069 (case-fold-search t)
8070 (body (copy-marker (point))))
8071 (goto-char (point-min))
8072 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8073 (delete-region (match-beginning 1) (match-end 1))
8074 (insert (number-to-string length)))
8075 (goto-char (point-min))
8076 (when (re-search-forward
8077 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8078 (delete-region (match-beginning 1) (match-end 1))
8079 (insert (number-to-string length)))
8080 (goto-char (point-min))
8081 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8082 (delete-region (match-beginning 1) (match-end 1))
8083 (insert (number-to-string lines))))))
8084 ;; Replace the article.
8085 (let ((buf (current-buffer)))
8087 (insert-buffer-substring buf)
8089 (if (and (not read-only)
8090 (not (gnus-request-replace-article
8091 (cdr gnus-article-current) (car gnus-article-current)
8092 (current-buffer) t)))
8093 (error "Couldn't replace article")
8094 ;; Update the summary buffer.
8096 (equal (message-tokenize-header references " ")
8097 (message-tokenize-header
8098 (or (message-fetch-field "references") "") " ")))
8099 ;; We only have to update this line.
8102 (message-narrow-to-head)
8103 (let ((head (buffer-string))
8106 (insert (format "211 %d Article retrieved.\n"
8107 (cdr gnus-article-current)))
8110 (let ((nntp-server-buffer (current-buffer)))
8111 (setq header (car (gnus-get-newsgroup-headers
8113 (set-buffer gnus-summary-buffer)
8114 gnus-newsgroup-dependencies)
8117 (set-buffer gnus-summary-buffer)
8118 (gnus-data-set-header
8119 (gnus-data-find (cdr gnus-article-current))
8121 (gnus-summary-update-article-line
8122 (cdr gnus-article-current) header))))))
8124 (set-buffer (or buffer gnus-summary-buffer))
8125 (gnus-summary-update-article (cdr gnus-article-current)))
8126 ;; Prettify the article buffer again.
8127 (unless no-highlight
8129 (set-buffer gnus-article-buffer)
8130 ;;;!!! Fix this -- article should be rehighlighted.
8131 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8132 (set-buffer gnus-original-article-buffer)
8133 (gnus-request-article
8134 (cdr gnus-article-current)
8135 (car gnus-article-current) (current-buffer))))
8136 ;; Prettify the summary buffer line.
8137 (when (gnus-visual-p 'summary-highlight 'highlight)
8138 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8140 (defun gnus-summary-edit-wash (key)
8141 "Perform editing command KEY in the article buffer."
8145 (message "%s" (concat (this-command-keys) "- "))
8148 (gnus-summary-edit-article)
8149 (execute-kbd-macro (concat (this-command-keys) key))
8150 (gnus-article-edit-done))
8154 (defun gnus-summary-respool-query (&optional silent trace)
8155 "Query where the respool algorithm would put this article."
8157 (let (gnus-mark-article-hook)
8158 (gnus-summary-select-article)
8160 (set-buffer gnus-original-article-buffer)
8162 (message-narrow-to-head)
8163 (let ((groups (nnmail-article-group 'identity trace)))
8166 (message "This message would go to %s"
8167 (mapconcat 'car groups ", "))
8168 (message "This message would go to no groups"))
8171 (defun gnus-summary-respool-trace ()
8172 "Trace where the respool algorithm would put this article.
8173 Display a buffer showing all fancy splitting patterns which matched."
8175 (gnus-summary-respool-query nil t))
8177 ;; Summary marking commands.
8179 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8180 "Mark articles which has the same subject as read, and then select the next.
8181 If UNMARK is positive, remove any kind of mark.
8182 If UNMARK is negative, tick articles."
8185 (setq unmark (prefix-numeric-value unmark)))
8187 (gnus-summary-mark-same-subject
8188 (gnus-summary-article-subject) unmark)))
8189 ;; Select next unread article. If auto-select-same mode, should
8190 ;; select the first unread article.
8191 (gnus-summary-next-article t (and gnus-auto-select-same
8192 (gnus-summary-article-subject)))
8193 (gnus-message 7 "%d article%s marked as %s"
8194 count (if (= count 1) " is" "s are")
8195 (if unmark "unread" "read"))))
8197 (defun gnus-summary-kill-same-subject (&optional unmark)
8198 "Mark articles which has the same subject as read.
8199 If UNMARK is positive, remove any kind of mark.
8200 If UNMARK is negative, tick articles."
8203 (setq unmark (prefix-numeric-value unmark)))
8205 (gnus-summary-mark-same-subject
8206 (gnus-summary-article-subject) unmark)))
8207 ;; If marked as read, go to next unread subject.
8209 ;; Go to next unread subject.
8210 (gnus-summary-next-subject 1 t))
8211 (gnus-message 7 "%d articles are marked as %s"
8212 count (if unmark "unread" "read"))))
8214 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8215 "Mark articles with same SUBJECT as read, and return marked number.
8216 If optional argument UNMARK is positive, remove any kinds of marks.
8217 If optional argument UNMARK is negative, mark articles as unread instead."
8221 ((null unmark) ; Mark as read.
8224 (gnus-summary-mark-article-as-read gnus-killed-mark)
8225 (gnus-summary-show-thread) t)
8226 (gnus-summary-find-subject subject))
8227 (setq count (1+ count))))
8228 ((> unmark 0) ; Tick.
8231 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8232 (gnus-summary-show-thread) t)
8233 (gnus-summary-find-subject subject))
8234 (setq count (1+ count))))
8235 (t ; Mark as unread.
8238 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8239 (gnus-summary-show-thread) t)
8240 (gnus-summary-find-subject subject))
8241 (setq count (1+ count)))))
8242 (gnus-set-mode-line 'summary)
8243 ;; Return the number of marked articles.
8246 (defun gnus-summary-mark-as-processable (n &optional unmark)
8247 "Set the process mark on the next N articles.
8248 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8249 the process mark instead. The difference between N and the actual
8250 number of articles marked is returned."
8252 (let ((backward (< n 0))
8257 (gnus-summary-remove-process-mark
8258 (gnus-summary-article-number))
8259 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8260 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8263 (gnus-message 7 "No more articles"))
8264 (gnus-summary-recenter)
8265 (gnus-summary-position-point)
8268 (defun gnus-summary-unmark-as-processable (n)
8269 "Remove the process mark from the next N articles.
8270 If N is negative, unmark backward instead. The difference between N and
8271 the actual number of articles unmarked is returned."
8273 (gnus-summary-mark-as-processable n t))
8275 (defun gnus-summary-unmark-all-processable ()
8276 "Remove the process mark from all articles."
8279 (while gnus-newsgroup-processable
8280 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8281 (gnus-summary-position-point))
8283 (defun gnus-summary-mark-as-expirable (n)
8284 "Mark N articles forward as expirable.
8285 If N is negative, mark backward instead. The difference between N and
8286 the actual number of articles marked is returned."
8288 (gnus-summary-mark-forward n gnus-expirable-mark))
8290 (defun gnus-summary-mark-article-as-replied (article)
8291 "Mark ARTICLE replied and update the summary line."
8292 (push article gnus-newsgroup-replied)
8293 (let ((buffer-read-only nil))
8294 (when (gnus-summary-goto-subject article nil t)
8295 (gnus-summary-update-secondary-mark article))))
8297 (defun gnus-summary-set-bookmark (article)
8298 "Set a bookmark in current article."
8299 (interactive (list (gnus-summary-article-number)))
8300 (when (or (not (get-buffer gnus-article-buffer))
8301 (not gnus-current-article)
8302 (not gnus-article-current)
8303 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8304 (error "No current article selected"))
8305 ;; Remove old bookmark, if one exists.
8306 (let ((old (assq article gnus-newsgroup-bookmarks)))
8308 (setq gnus-newsgroup-bookmarks
8309 (delq old gnus-newsgroup-bookmarks))))
8310 ;; Set the new bookmark, which is on the form
8311 ;; (article-number . line-number-in-body).
8315 (set-buffer gnus-article-buffer)
8319 (goto-char (point-min))
8320 (search-forward "\n\n" nil t)
8323 gnus-newsgroup-bookmarks)
8324 (gnus-message 6 "A bookmark has been added to the current article."))
8326 (defun gnus-summary-remove-bookmark (article)
8327 "Remove the bookmark from the current article."
8328 (interactive (list (gnus-summary-article-number)))
8329 ;; Remove old bookmark, if one exists.
8330 (let ((old (assq article gnus-newsgroup-bookmarks)))
8333 (setq gnus-newsgroup-bookmarks
8334 (delq old gnus-newsgroup-bookmarks))
8335 (gnus-message 6 "Removed bookmark."))
8336 (gnus-message 6 "No bookmark in current article."))))
8338 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8339 (defun gnus-summary-mark-as-dormant (n)
8340 "Mark N articles forward as dormant.
8341 If N is negative, mark backward instead. The difference between N and
8342 the actual number of articles marked is returned."
8344 (gnus-summary-mark-forward n gnus-dormant-mark))
8346 (defun gnus-summary-set-process-mark (article)
8347 "Set the process mark on ARTICLE and update the summary line."
8348 (setq gnus-newsgroup-processable
8350 (delq article gnus-newsgroup-processable)))
8351 (when (gnus-summary-goto-subject article)
8352 (gnus-summary-show-thread)
8353 (gnus-summary-goto-subject article)
8354 (gnus-summary-update-secondary-mark article)))
8356 (defun gnus-summary-remove-process-mark (article)
8357 "Remove the process mark from ARTICLE and update the summary line."
8358 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8359 (when (gnus-summary-goto-subject article)
8360 (gnus-summary-show-thread)
8361 (gnus-summary-goto-subject article)
8362 (gnus-summary-update-secondary-mark article)))
8364 (defun gnus-summary-set-saved-mark (article)
8365 "Set the process mark on ARTICLE and update the summary line."
8366 (push article gnus-newsgroup-saved)
8367 (when (gnus-summary-goto-subject article)
8368 (gnus-summary-update-secondary-mark article)))
8370 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8371 "Mark N articles as read forwards.
8372 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8373 The difference between N and the actual number of articles marked is
8375 Iff NO-EXPIRE, auto-expiry will be inhibited."
8377 (gnus-summary-show-thread)
8378 (let ((backward (< n 0))
8379 (gnus-summary-goto-unread
8380 (and gnus-summary-goto-unread
8381 (not (eq gnus-summary-goto-unread 'never))
8382 (not (memq mark (list gnus-unread-mark
8383 gnus-ticked-mark gnus-dormant-mark)))))
8385 (mark (or mark gnus-del-mark)))
8387 (gnus-summary-mark-article nil mark no-expire)
8388 (zerop (gnus-summary-next-subject
8390 (and gnus-summary-goto-unread
8391 (not (eq gnus-summary-goto-unread 'never)))
8395 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8396 (gnus-summary-recenter)
8397 (gnus-summary-position-point)
8398 (gnus-set-mode-line 'summary)
8401 (defun gnus-summary-mark-article-as-read (mark)
8402 "Mark the current article quickly as read with MARK."
8403 (let ((article (gnus-summary-article-number)))
8404 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8405 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8406 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8407 (push (cons article mark) gnus-newsgroup-reads)
8408 ;; Possibly remove from cache, if that is used.
8409 (when gnus-use-cache
8410 (gnus-cache-enter-remove-article article))
8411 ;; Allow the backend to change the mark.
8412 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8413 ;; Check for auto-expiry.
8414 (when (and gnus-newsgroup-auto-expire
8415 (memq mark gnus-auto-expirable-marks))
8416 (setq mark gnus-expirable-mark)
8417 ;; Let the backend know about the mark change.
8418 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8419 (push article gnus-newsgroup-expirable))
8420 ;; Set the mark in the buffer.
8421 (gnus-summary-update-mark mark 'unread)
8424 (defun gnus-summary-mark-article-as-unread (mark)
8425 "Mark the current article quickly as unread with MARK."
8426 (let* ((article (gnus-summary-article-number))
8427 (old-mark (gnus-summary-article-mark article)))
8428 ;; Allow the backend to change the mark.
8429 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8430 (if (eq mark old-mark)
8434 (gnus-error 1 "Can't mark negative article numbers")
8436 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8437 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8438 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8439 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8440 (cond ((= mark gnus-ticked-mark)
8441 (push article gnus-newsgroup-marked))
8442 ((= mark gnus-dormant-mark)
8443 (push article gnus-newsgroup-dormant))
8445 (push article gnus-newsgroup-unreads)))
8446 (gnus-pull article gnus-newsgroup-reads)
8448 ;; See whether the article is to be put in the cache.
8450 (vectorp (gnus-summary-article-header article))
8452 (gnus-cache-possibly-enter-article
8453 gnus-newsgroup-name article
8454 (gnus-summary-article-header article)
8455 (= mark gnus-ticked-mark)
8456 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8459 (gnus-summary-update-mark mark 'unread)
8462 (defun gnus-summary-mark-article (&optional article mark no-expire)
8463 "Mark ARTICLE with MARK. MARK can be any character.
8464 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8465 `??' (dormant) and `?E' (expirable).
8466 If MARK is nil, then the default character `?r' is used.
8467 If ARTICLE is nil, then the article on the current line will be
8469 Iff NO-EXPIRE, auto-expiry will be inhibited."
8470 ;; The mark might be a string.
8471 (when (stringp mark)
8472 (setq mark (aref mark 0)))
8473 ;; If no mark is given, then we check auto-expiring.
8475 (setq mark gnus-del-mark))
8476 (when (and (not no-expire)
8477 gnus-newsgroup-auto-expire
8478 (memq mark gnus-auto-expirable-marks))
8479 (setq mark gnus-expirable-mark))
8480 (let ((article (or article (gnus-summary-article-number)))
8481 (old-mark (gnus-summary-article-mark article)))
8482 ;; Allow the backend to change the mark.
8483 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8484 (if (eq mark old-mark)
8487 (error "No article on current line"))
8488 (if (not (if (or (= mark gnus-unread-mark)
8489 (= mark gnus-ticked-mark)
8490 (= mark gnus-dormant-mark))
8491 (gnus-mark-article-as-unread article mark)
8492 (gnus-mark-article-as-read article mark)))
8494 ;; See whether the article is to be put in the cache.
8496 (not (= mark gnus-canceled-mark))
8497 (vectorp (gnus-summary-article-header article))
8499 (gnus-cache-possibly-enter-article
8500 gnus-newsgroup-name article
8501 (gnus-summary-article-header article)
8502 (= mark gnus-ticked-mark)
8503 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8505 (when (gnus-summary-goto-subject article nil t)
8506 (let ((buffer-read-only nil))
8507 (gnus-summary-show-thread)
8509 (gnus-summary-update-mark mark 'unread)
8512 (defun gnus-summary-update-secondary-mark (article)
8513 "Update the secondary (read, process, cache) mark."
8514 (gnus-summary-update-mark
8515 (cond ((memq article gnus-newsgroup-processable)
8517 ((memq article gnus-newsgroup-cached)
8519 ((memq article gnus-newsgroup-replied)
8521 ((memq article gnus-newsgroup-saved)
8523 (t gnus-unread-mark))
8525 (when (gnus-visual-p 'summary-highlight 'highlight)
8526 (gnus-run-hooks 'gnus-summary-update-hook))
8529 (defun gnus-summary-update-mark (mark type)
8530 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8531 (buffer-read-only nil))
8532 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8534 (when (looking-at "\r")
8536 (when (<= (+ forward (point)) (point-max))
8537 ;; Go to the right position on the line.
8538 (goto-char (+ forward (point)))
8539 ;; Replace the old mark with the new mark.
8540 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8541 ;; Optionally update the marks by some user rule.
8542 (when (eq type 'unread)
8544 (gnus-data-find (gnus-summary-article-number)) mark)
8545 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8547 (defun gnus-mark-article-as-read (article &optional mark)
8548 "Enter ARTICLE in the pertinent lists and remove it from others."
8549 ;; Make the article expirable.
8550 (let ((mark (or mark gnus-del-mark)))
8551 (if (= mark gnus-expirable-mark)
8552 (push article gnus-newsgroup-expirable)
8553 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8554 ;; Remove from unread and marked lists.
8555 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8556 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8557 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8558 (push (cons article mark) gnus-newsgroup-reads)
8559 ;; Possibly remove from cache, if that is used.
8560 (when gnus-use-cache
8561 (gnus-cache-enter-remove-article article))
8564 (defun gnus-mark-article-as-unread (article &optional mark)
8565 "Enter ARTICLE in the pertinent lists and remove it from others."
8566 (let ((mark (or mark gnus-ticked-mark)))
8569 (gnus-error 1 "Can't mark negative article numbers")
8571 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8572 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8573 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8574 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8576 ;; Unsuppress duplicates?
8577 (when gnus-suppress-duplicates
8578 (gnus-dup-unsuppress-article article))
8580 (cond ((= mark gnus-ticked-mark)
8581 (push article gnus-newsgroup-marked))
8582 ((= mark gnus-dormant-mark)
8583 (push article gnus-newsgroup-dormant))
8585 (push article gnus-newsgroup-unreads)))
8586 (gnus-pull article gnus-newsgroup-reads)
8589 (defalias 'gnus-summary-mark-as-unread-forward
8590 'gnus-summary-tick-article-forward)
8591 (make-obsolete 'gnus-summary-mark-as-unread-forward
8592 'gnus-summary-tick-article-forward)
8593 (defun gnus-summary-tick-article-forward (n)
8594 "Tick N articles forwards.
8595 If N is negative, tick backwards instead.
8596 The difference between N and the number of articles ticked is returned."
8598 (gnus-summary-mark-forward n gnus-ticked-mark))
8600 (defalias 'gnus-summary-mark-as-unread-backward
8601 'gnus-summary-tick-article-backward)
8602 (make-obsolete 'gnus-summary-mark-as-unread-backward
8603 'gnus-summary-tick-article-backward)
8604 (defun gnus-summary-tick-article-backward (n)
8605 "Tick N articles backwards.
8606 The difference between N and the number of articles ticked is returned."
8608 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8610 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8611 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8612 (defun gnus-summary-tick-article (&optional article clear-mark)
8613 "Mark current article as unread.
8614 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8615 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8617 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8620 (defun gnus-summary-mark-as-read-forward (n)
8621 "Mark N articles as read forwards.
8622 If N is negative, mark backwards instead.
8623 The difference between N and the actual number of articles marked is
8626 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8628 (defun gnus-summary-mark-as-read-backward (n)
8629 "Mark the N articles as read backwards.
8630 The difference between N and the actual number of articles marked is
8633 (gnus-summary-mark-forward
8634 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8636 (defun gnus-summary-mark-as-read (&optional article mark)
8637 "Mark current article as read.
8638 ARTICLE specifies the article to be marked as read.
8639 MARK specifies a string to be inserted at the beginning of the line."
8640 (gnus-summary-mark-article article mark))
8642 (defun gnus-summary-clear-mark-forward (n)
8643 "Clear marks from N articles forward.
8644 If N is negative, clear backward instead.
8645 The difference between N and the number of marks cleared is returned."
8647 (gnus-summary-mark-forward n gnus-unread-mark))
8649 (defun gnus-summary-clear-mark-backward (n)
8650 "Clear marks from N articles backward.
8651 The difference between N and the number of marks cleared is returned."
8653 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8655 (defun gnus-summary-mark-unread-as-read ()
8656 "Intended to be used by `gnus-summary-mark-article-hook'."
8657 (when (memq gnus-current-article gnus-newsgroup-unreads)
8658 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8660 (defun gnus-summary-mark-read-and-unread-as-read ()
8661 "Intended to be used by `gnus-summary-mark-article-hook'."
8662 (let ((mark (gnus-summary-article-mark)))
8663 (when (or (gnus-unread-mark-p mark)
8664 (gnus-read-mark-p mark))
8665 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8667 (defun gnus-summary-mark-region-as-read (point mark all)
8668 "Mark all unread articles between point and mark as read.
8669 If given a prefix, mark all articles between point and mark as read,
8670 even ticked and dormant ones."
8671 (interactive "r\nP")
8680 (memq (setq article (gnus-summary-article-number))
8681 gnus-newsgroup-unreads))
8682 (gnus-summary-mark-article article gnus-del-mark))
8684 (gnus-summary-find-next))))))
8686 (defun gnus-summary-mark-below (score mark)
8687 "Mark articles with score less than SCORE with MARK."
8688 (interactive "P\ncMark: ")
8689 (setq score (if score
8690 (prefix-numeric-value score)
8691 (or gnus-summary-default-score 0)))
8693 (set-buffer gnus-summary-buffer)
8694 (goto-char (point-min))
8697 (and (< (gnus-summary-article-score) score)
8698 (gnus-summary-mark-article nil mark))
8699 (gnus-summary-find-next)))))
8701 (defun gnus-summary-kill-below (&optional score)
8702 "Mark articles with score below SCORE as read."
8704 (gnus-summary-mark-below score gnus-killed-mark))
8706 (defun gnus-summary-clear-above (&optional score)
8707 "Clear all marks from articles with score above SCORE."
8709 (gnus-summary-mark-above score gnus-unread-mark))
8711 (defun gnus-summary-tick-above (&optional score)
8712 "Tick all articles with score above SCORE."
8714 (gnus-summary-mark-above score gnus-ticked-mark))
8716 (defun gnus-summary-mark-above (score mark)
8717 "Mark articles with score over SCORE with MARK."
8718 (interactive "P\ncMark: ")
8719 (setq score (if score
8720 (prefix-numeric-value score)
8721 (or gnus-summary-default-score 0)))
8723 (set-buffer gnus-summary-buffer)
8724 (goto-char (point-min))
8726 (when (> (gnus-summary-article-score) score)
8727 (gnus-summary-mark-article nil mark))
8729 (gnus-summary-find-next)))))
8731 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8732 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8733 (defun gnus-summary-limit-include-expunged (&optional no-error)
8734 "Display all the hidden articles that were expunged for low scores."
8736 (let ((buffer-read-only nil))
8737 (let ((scored gnus-newsgroup-scored)
8740 (unless (gnus-summary-goto-subject (caar scored))
8741 (and (setq h (gnus-summary-article-header (caar scored)))
8742 (< (cdar scored) gnus-summary-expunge-below)
8744 (setq scored (cdr scored)))
8746 (when (not no-error)
8747 (error "No expunged articles hidden"))
8748 (goto-char (point-min))
8749 (gnus-summary-prepare-unthreaded (nreverse headers))
8750 (goto-char (point-min))
8751 (gnus-summary-position-point)
8754 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8755 "Mark all unread articles in this newsgroup as read.
8756 If prefix argument ALL is non-nil, ticked and dormant articles will
8757 also be marked as read.
8758 If QUIETLY is non-nil, no questions will be asked.
8759 If TO-HERE is non-nil, it should be a point in the buffer. All
8760 articles before this point will be marked as read.
8761 Note that this function will only catch up the unread article
8762 in the current summary buffer limitation.
8763 The number of articles marked as read is returned."
8768 (not gnus-interactive-catchup) ;Without confirmation?
8772 "Mark absolutely all articles as read? "
8773 "Mark all unread articles as read? ")))
8775 (not gnus-newsgroup-adaptive)
8776 (not gnus-newsgroup-auto-expire)
8777 (not gnus-suppress-duplicates)
8778 (or (not gnus-use-cache)
8779 (eq gnus-use-cache 'passive)))
8782 (setq gnus-newsgroup-marked nil
8783 gnus-newsgroup-dormant nil))
8784 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8785 ;; We actually mark all articles as canceled, which we
8786 ;; have to do when using auto-expiry or adaptive scoring.
8787 (gnus-summary-show-all-threads)
8788 (when (gnus-summary-first-subject (not all) t)
8790 (if to-here (< (point) to-here) t)
8791 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8792 (gnus-summary-find-next (not all) nil nil t))))
8793 (gnus-set-mode-line 'summary))
8795 (gnus-summary-position-point)))
8797 (defun gnus-summary-catchup-to-here (&optional all)
8798 "Mark all unticked articles before the current one as read.
8799 If ALL is non-nil, also mark ticked and dormant articles as read."
8802 (gnus-save-hidden-threads
8803 (let ((beg (point)))
8804 ;; We check that there are unread articles.
8805 (when (or all (gnus-summary-find-prev))
8806 (gnus-summary-catchup all t beg)))))
8807 (gnus-summary-position-point))
8809 (defun gnus-summary-catchup-all (&optional quietly)
8810 "Mark all articles in this newsgroup as read."
8812 (gnus-summary-catchup t quietly))
8814 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8815 "Mark all unread articles in this group as read, then exit.
8816 If prefix argument ALL is non-nil, all articles are marked as read."
8818 (when (gnus-summary-catchup all quietly nil 'fast)
8819 ;; Select next newsgroup or exit.
8820 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8821 (eq gnus-auto-select-next 'quietly))
8822 (gnus-summary-next-group nil)
8823 (gnus-summary-exit))))
8825 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8826 "Mark all articles in this newsgroup as read, and then exit."
8828 (gnus-summary-catchup-and-exit t quietly))
8830 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8831 "Mark all articles in this group as read and select the next group.
8832 If given a prefix, mark all articles, unread as well as ticked, as
8836 (gnus-summary-catchup all))
8837 (gnus-summary-next-group))
8843 (defmacro gnus-with-article (article &rest forms)
8844 "Select ARTICLE and perform FORMS in the original article buffer.
8845 Then replace the article with the result."
8847 ;; We don't want the article to be marked as read.
8848 (let (gnus-mark-article-hook)
8849 (gnus-summary-select-article t t nil ,article))
8850 (set-buffer gnus-original-article-buffer)
8852 (if (not (gnus-check-backend-function
8853 'request-replace-article (car gnus-article-current)))
8854 (gnus-message 5 "Read-only group; not replacing")
8855 (unless (gnus-request-replace-article
8856 ,article (car gnus-article-current)
8858 (error "Couldn't replace article")))
8859 ;; The cache and backlog have to be flushed somewhat.
8860 (when gnus-keep-backlog
8861 (gnus-backlog-remove-article
8862 (car gnus-article-current) (cdr gnus-article-current)))
8863 (when gnus-use-cache
8864 (gnus-cache-update-article
8865 (car gnus-article-current) (cdr gnus-article-current)))))
8867 (put 'gnus-with-article 'lisp-indent-function 1)
8868 (put 'gnus-with-article 'edebug-form-spec '(form body))
8870 ;; Thread-based commands.
8872 (defun gnus-summary-articles-in-thread (&optional article)
8873 "Return a list of all articles in the current thread.
8874 If ARTICLE is non-nil, return all articles in the thread that starts
8876 (let* ((article (or article (gnus-summary-article-number)))
8877 (data (gnus-data-find-list article))
8878 (top-level (gnus-data-level (car data)))
8880 (cond ((null gnus-thread-operation-ignore-subject)
8881 (gnus-simplify-subject-re
8882 (mail-header-subject (gnus-data-header (car data)))))
8883 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8884 (gnus-simplify-subject-fuzzy
8885 (mail-header-subject (gnus-data-header (car data)))))
8887 (end-point (save-excursion
8888 (if (gnus-summary-go-to-next-thread)
8889 (point) (point-max))))
8892 (< (gnus-data-pos (car data)) end-point))
8893 (when (or (not top-subject)
8894 (string= top-subject
8895 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8896 (gnus-simplify-subject-fuzzy
8897 (mail-header-subject
8898 (gnus-data-header (car data))))
8899 (gnus-simplify-subject-re
8900 (mail-header-subject
8901 (gnus-data-header (car data)))))))
8902 (push (gnus-data-number (car data)) articles))
8903 (unless (and (setq data (cdr data))
8904 (> (gnus-data-level (car data)) top-level))
8906 ;; Return the list of articles.
8907 (nreverse articles)))
8909 (defun gnus-summary-rethread-current ()
8910 "Rethread the thread the current article is part of."
8912 (let* ((gnus-show-threads t)
8913 (article (gnus-summary-article-number))
8914 (id (mail-header-id (gnus-summary-article-header)))
8915 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8917 (error "No article on the current line"))
8918 (gnus-rebuild-thread id)
8919 (gnus-summary-goto-subject article)))
8921 (defun gnus-summary-reparent-thread ()
8922 "Make the current article child of the marked (or previous) article.
8924 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8925 is non-nil or the Subject: of both articles are the same."
8927 (unless (not (gnus-group-read-only-p))
8928 (error "The current newsgroup does not support article editing"))
8929 (unless (<= (length gnus-newsgroup-processable) 1)
8930 (error "No more than one article may be marked"))
8931 (save-window-excursion
8932 (let ((gnus-article-buffer " *reparent*")
8933 (current-article (gnus-summary-article-number))
8934 ;; First grab the marked article, otherwise one line up.
8935 (parent-article (if (not (null gnus-newsgroup-processable))
8936 (car gnus-newsgroup-processable)
8938 (if (eq (forward-line -1) 0)
8939 (gnus-summary-article-number)
8940 (error "Beginning of summary buffer"))))))
8941 (unless (not (eq current-article parent-article))
8942 (error "An article may not be self-referential"))
8943 (let ((message-id (mail-header-id
8944 (gnus-summary-article-header parent-article))))
8945 (unless (and message-id (not (equal message-id "")))
8946 (error "No message-id in desired parent"))
8947 (gnus-with-article current-article
8949 (goto-char (point-min))
8950 (message-narrow-to-head)
8951 (if (re-search-forward "^References: " nil t)
8953 (re-search-forward "^[^ \t]" nil t)
8956 (insert " " message-id))
8957 (insert "References: " message-id "\n"))))
8958 (set-buffer gnus-summary-buffer)
8959 (gnus-summary-unmark-all-processable)
8960 (gnus-summary-update-article current-article)
8961 (gnus-summary-rethread-current)
8962 (gnus-message 3 "Article %d is now the child of article %d"
8963 current-article parent-article)))))
8965 (defun gnus-summary-toggle-threads (&optional arg)
8966 "Toggle showing conversation threads.
8967 If ARG is positive number, turn showing conversation threads on."
8969 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8970 (setq gnus-show-threads
8971 (if (null arg) (not gnus-show-threads)
8972 (> (prefix-numeric-value arg) 0)))
8973 (gnus-summary-prepare)
8974 (gnus-summary-goto-subject current)
8975 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8976 (gnus-summary-position-point)))
8978 (defun gnus-summary-show-all-threads ()
8982 (let ((buffer-read-only nil))
8983 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8984 (gnus-summary-position-point))
8986 (defun gnus-summary-show-thread ()
8987 "Show thread subtrees.
8988 Returns nil if no thread was there to be shown."
8990 (let ((buffer-read-only nil)
8992 ;; first goto end then to beg, to have point at beg after let
8993 (end (progn (end-of-line) (point)))
8994 (beg (progn (beginning-of-line) (point))))
8996 ;; Any hidden lines here?
8997 (search-forward "\r" end t)
8998 (subst-char-in-region beg end ?\^M ?\n t)
9000 (gnus-summary-position-point))))
9002 (defun gnus-summary-hide-all-threads ()
9003 "Hide all thread subtrees."
9006 (goto-char (point-min))
9007 (gnus-summary-hide-thread)
9008 (while (zerop (gnus-summary-next-thread 1 t))
9009 (gnus-summary-hide-thread)))
9010 (gnus-summary-position-point))
9012 (defun gnus-summary-hide-thread ()
9013 "Hide thread subtrees.
9014 Returns nil if no threads were there to be hidden."
9016 (let ((buffer-read-only nil)
9018 (article (gnus-summary-article-number)))
9020 ;; Go forward until either the buffer ends or the subthread
9022 (when (and (not (eobp))
9023 (or (zerop (gnus-summary-next-thread 1 t))
9024 (goto-char (point-max))))
9026 (if (and (> (point) start)
9027 (search-backward "\n" start t))
9029 (subst-char-in-region start (point) ?\n ?\^M)
9030 (gnus-summary-goto-subject article))
9034 (defun gnus-summary-go-to-next-thread (&optional previous)
9035 "Go to the same level (or less) next thread.
9036 If PREVIOUS is non-nil, go to previous thread instead.
9037 Return the article number moved to, or nil if moving was impossible."
9038 (let ((level (gnus-summary-thread-level))
9039 (way (if previous -1 1))
9042 (while (and (not (eobp))
9043 (< level (gnus-summary-thread-level)))
9051 (gnus-summary-article-number)
9054 (defun gnus-summary-next-thread (n &optional silent)
9055 "Go to the same level next N'th thread.
9056 If N is negative, search backward instead.
9057 Returns the difference between N and the number of skips actually
9060 If SILENT, don't output messages."
9062 (let ((backward (< n 0))
9065 (gnus-summary-go-to-next-thread backward))
9068 (gnus-summary-position-point))
9069 (when (and (not silent) (/= 0 n))
9070 (gnus-message 7 "No more threads"))
9073 (defun gnus-summary-prev-thread (n)
9074 "Go to the same level previous N'th thread.
9075 Returns the difference between N and the number of skips actually
9078 (gnus-summary-next-thread (- n)))
9080 (defun gnus-summary-go-down-thread ()
9081 "Go down one level in the current thread."
9082 (let ((children (gnus-summary-article-children)))
9084 (gnus-summary-goto-subject (car children)))))
9086 (defun gnus-summary-go-up-thread ()
9087 "Go up one level in the current thread."
9088 (let ((parent (gnus-summary-article-parent)))
9090 (gnus-summary-goto-subject parent))))
9092 (defun gnus-summary-down-thread (n)
9093 "Go down thread N steps.
9094 If N is negative, go up instead.
9095 Returns the difference between N and how many steps down that were
9101 (if up (gnus-summary-go-up-thread)
9102 (gnus-summary-go-down-thread)))
9104 (gnus-summary-position-point)
9106 (gnus-message 7 "Can't go further"))
9109 (defun gnus-summary-up-thread (n)
9110 "Go up thread N steps.
9111 If N is negative, go up instead.
9112 Returns the difference between N and how many steps down that were
9115 (gnus-summary-down-thread (- n)))
9117 (defun gnus-summary-top-thread ()
9118 "Go to the top of the thread."
9120 (while (gnus-summary-go-up-thread))
9121 (gnus-summary-article-number))
9123 (defun gnus-summary-kill-thread (&optional unmark)
9124 "Mark articles under current thread as read.
9125 If the prefix argument is positive, remove any kinds of marks.
9126 If the prefix argument is negative, tick articles instead."
9129 (setq unmark (prefix-numeric-value unmark)))
9130 (let ((articles (gnus-summary-articles-in-thread)))
9132 ;; Expand the thread.
9133 (gnus-summary-show-thread)
9134 ;; Mark all the articles.
9136 (gnus-summary-goto-subject (car articles))
9137 (cond ((null unmark)
9138 (gnus-summary-mark-article-as-read gnus-killed-mark))
9140 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9142 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9143 (setq articles (cdr articles))))
9144 ;; Hide killed subtrees.
9146 gnus-thread-hide-killed
9147 (gnus-summary-hide-thread))
9148 ;; If marked as read, go to next unread subject.
9150 ;; Go to next unread subject.
9151 (gnus-summary-next-subject 1 t)))
9152 (gnus-set-mode-line 'summary))
9154 ;; Summary sorting commands
9156 (defun gnus-summary-sort-by-number (&optional reverse)
9157 "Sort the summary buffer by article number.
9158 Argument REVERSE means reverse order."
9160 (gnus-summary-sort 'number reverse))
9162 (defun gnus-summary-sort-by-author (&optional reverse)
9163 "Sort the summary buffer by author name alphabetically.
9164 If `case-fold-search' is non-nil, case of letters is ignored.
9165 Argument REVERSE means reverse order."
9167 (gnus-summary-sort 'author reverse))
9169 (defun gnus-summary-sort-by-subject (&optional reverse)
9170 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9171 If `case-fold-search' is non-nil, case of letters is ignored.
9172 Argument REVERSE means reverse order."
9174 (gnus-summary-sort 'subject reverse))
9176 (defun gnus-summary-sort-by-date (&optional reverse)
9177 "Sort the summary buffer by date.
9178 Argument REVERSE means reverse order."
9180 (gnus-summary-sort 'date reverse))
9182 (defun gnus-summary-sort-by-score (&optional reverse)
9183 "Sort the summary buffer by score.
9184 Argument REVERSE means reverse order."
9186 (gnus-summary-sort 'score reverse))
9188 (defun gnus-summary-sort-by-lines (&optional reverse)
9189 "Sort the summary buffer by the number of lines.
9190 Argument REVERSE means reverse order."
9192 (gnus-summary-sort 'lines reverse))
9194 (defun gnus-summary-sort-by-chars (&optional reverse)
9195 "Sort the summary buffer by article length.
9196 Argument REVERSE means reverse order."
9198 (gnus-summary-sort 'chars reverse))
9200 (defun gnus-summary-sort (predicate reverse)
9201 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9202 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9203 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9204 (gnus-thread-sort-functions
9209 (gnus-sort-gathered-threads-function
9210 gnus-thread-sort-functions)
9211 (gnus-article-sort-functions
9217 (gnus-summary-prepare-hook nil))
9218 ;; We do the sorting by regenerating the threads.
9219 (gnus-summary-prepare)
9220 ;; Hide subthreads if needed.
9221 (when (and gnus-show-threads gnus-thread-hide-subtree)
9222 (gnus-summary-hide-all-threads))))
9224 ;; Summary saving commands.
9226 (defun gnus-summary-save-article (&optional n not-saved)
9227 "Save the current article using the default saver function.
9228 If N is a positive number, save the N next articles.
9229 If N is a negative number, save the N previous articles.
9230 If N is nil and any articles have been marked with the process mark,
9231 save those articles instead.
9232 The variable `gnus-default-article-saver' specifies the saver function."
9234 (let* ((articles (gnus-summary-work-articles n))
9235 (save-buffer (save-excursion
9236 (nnheader-set-temp-buffer " *Gnus Save*")))
9237 (num (length articles))
9239 (dolist (article articles)
9240 (setq header (gnus-summary-article-header article))
9241 (if (not (vectorp header))
9242 ;; This is a pseudo-article.
9243 (if (assq 'name header)
9244 (gnus-copy-file (cdr (assq 'name header)))
9245 (gnus-message 1 "Article %d is unsaveable" article))
9246 ;; This is a real article.
9247 (save-window-excursion
9248 (gnus-summary-select-article t nil nil article))
9250 (set-buffer save-buffer)
9252 (insert-buffer-substring gnus-original-article-buffer))
9253 (setq file (gnus-article-save save-buffer file num))
9254 (gnus-summary-remove-process-mark article)
9256 (gnus-summary-set-saved-mark article))))
9257 (gnus-kill-buffer save-buffer)
9258 (gnus-summary-position-point)
9259 (gnus-set-mode-line 'summary)
9262 (defun gnus-summary-pipe-output (&optional arg)
9263 "Pipe the current article to a subprocess.
9264 If N is a positive number, pipe the N next articles.
9265 If N is a negative number, pipe the N previous articles.
9266 If N is nil and any articles have been marked with the process mark,
9267 pipe those articles instead."
9269 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9270 (gnus-summary-save-article arg t))
9271 (gnus-configure-windows 'pipe))
9273 (defun gnus-summary-save-article-mail (&optional arg)
9274 "Append the current article to an mail file.
9275 If N is a positive number, save the N next articles.
9276 If N is a negative number, save the N previous articles.
9277 If N is nil and any articles have been marked with the process mark,
9278 save those articles instead."
9280 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9281 (gnus-summary-save-article arg)))
9283 (defun gnus-summary-save-article-rmail (&optional arg)
9284 "Append the current article to an rmail file.
9285 If N is a positive number, save the N next articles.
9286 If N is a negative number, save the N previous articles.
9287 If N is nil and any articles have been marked with the process mark,
9288 save those articles instead."
9290 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9291 (gnus-summary-save-article arg)))
9293 (defun gnus-summary-save-article-file (&optional arg)
9294 "Append the current article to a file.
9295 If N is a positive number, save the N next articles.
9296 If N is a negative number, save the N previous articles.
9297 If N is nil and any articles have been marked with the process mark,
9298 save those articles instead."
9300 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9301 (gnus-summary-save-article arg)))
9303 (defun gnus-summary-write-article-file (&optional arg)
9304 "Write the current article to a file, deleting the previous file.
9305 If N is a positive number, save the N next articles.
9306 If N is a negative number, save the N previous articles.
9307 If N is nil and any articles have been marked with the process mark,
9308 save those articles instead."
9310 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9311 (gnus-summary-save-article arg)))
9313 (defun gnus-summary-save-article-body-file (&optional arg)
9314 "Append the current article body to a file.
9315 If N is a positive number, save the N next articles.
9316 If N is a negative number, save the N previous articles.
9317 If N is nil and any articles have been marked with the process mark,
9318 save those articles instead."
9320 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9321 (gnus-summary-save-article arg)))
9323 (defun gnus-summary-pipe-message (program)
9324 "Pipe the current article through PROGRAM."
9325 (interactive "sProgram: ")
9326 (gnus-summary-select-article)
9327 (let ((mail-header-separator ""))
9328 (gnus-eval-in-buffer-window gnus-article-buffer
9331 (let ((start (window-start))
9333 (message-pipe-buffer-body program)
9334 (set-window-start (get-buffer-window (current-buffer)) start))))))
9336 (defun gnus-get-split-value (methods)
9337 "Return a value based on the split METHODS."
9338 (let (split-name method result match)
9341 (set-buffer gnus-original-article-buffer)
9343 (nnheader-narrow-to-headers)
9344 (while (and methods (not split-name))
9345 (goto-char (point-min))
9346 (setq method (pop methods))
9347 (setq match (car method))
9350 ;; Regular expression.
9352 (re-search-forward match nil t)))
9353 ((gnus-functionp match)
9357 (setq result (funcall match gnus-newsgroup-name))))
9362 (setq result (eval match)))))
9363 (setq split-name (cdr method))
9364 (cond ((stringp result)
9365 (push (expand-file-name
9366 result gnus-article-save-directory)
9369 (setq split-name (append result split-name)))))))))
9370 (nreverse split-name)))
9372 (defun gnus-valid-move-group-p (group)
9375 (symbol-value group)
9376 (gnus-get-function (gnus-find-method-for-group
9377 (symbol-name group)) 'request-accept-article t)))
9379 (defun gnus-read-move-group-name (prompt default articles prefix)
9380 "Read a group name."
9381 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9382 (minibuffer-confirm-incomplete nil) ; XEmacs
9386 (if (> (length articles) 1)
9387 (format "these %d articles" (length articles))
9392 (gnus-completing-read default prom
9394 'gnus-valid-move-group-p
9396 'gnus-group-history))
9397 ((= 1 (length split-name))
9398 (gnus-completing-read (car split-name) prom
9400 'gnus-valid-move-group-p
9402 'gnus-group-history))
9404 (gnus-completing-read nil prom
9405 (mapcar (lambda (el) (list el))
9406 (nreverse split-name))
9408 'gnus-group-history))))
9409 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9411 (if (or (string= to-newsgroup "")
9412 (string= to-newsgroup prefix))
9413 (setq to-newsgroup default))
9414 (unless to-newsgroup
9415 (error "No group name entered"))
9416 (or (gnus-active to-newsgroup)
9417 (gnus-activate-group to-newsgroup nil nil to-method)
9418 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9420 (or (and (gnus-request-create-group to-newsgroup to-method)
9421 (gnus-activate-group
9422 to-newsgroup nil nil to-method)
9423 (gnus-subscribe-group to-newsgroup))
9424 (error "Couldn't create group %s" to-newsgroup)))
9425 (error "No such group: %s" to-newsgroup)))
9428 (defun gnus-summary-save-parts (type dir n &optional reverse)
9429 "Save parts matching TYPE to DIR.
9430 If REVERSE, save parts that do not match TYPE."
9432 (list (read-string "Save parts of type: "
9433 (or (car gnus-summary-save-parts-type-history)
9434 gnus-summary-save-parts-default-mime)
9435 'gnus-summary-save-parts-type-history)
9436 (setq gnus-summary-save-parts-last-directory
9437 (read-file-name "Save to directory: "
9438 gnus-summary-save-parts-last-directory
9440 current-prefix-arg))
9441 (gnus-summary-iterate n
9442 (let ((gnus-display-mime-function nil)
9443 (gnus-inhibit-treatment t))
9444 (gnus-summary-select-article))
9446 (set-buffer gnus-article-buffer)
9447 (let ((handles (or gnus-article-mime-handles
9448 (mm-dissect-buffer) (mm-uu-dissect))))
9450 (gnus-summary-save-parts-1 type dir handles reverse)
9451 (unless gnus-article-mime-handles ;; Don't destroy this case.
9452 (mm-destroy-parts handles)))))))
9454 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9455 (if (stringp (car handle))
9456 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9459 (not (string-match type (mm-handle-media-type handle)))
9460 (string-match type (mm-handle-media-type handle)))
9461 (let ((file (expand-file-name
9462 (file-name-nondirectory
9464 (mail-content-type-get
9465 (mm-handle-disposition handle) 'filename)
9466 (concat gnus-newsgroup-name
9467 "." (number-to-string
9468 (cdr gnus-article-current)))))
9470 (unless (file-exists-p file)
9471 (mm-save-part-to-file handle file))))))
9473 ;; Summary extract commands
9475 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9476 (let ((buffer-read-only nil)
9477 (article (gnus-summary-article-number))
9479 (unless (gnus-summary-goto-subject article)
9480 (error "No such article: %d" article))
9481 (gnus-summary-position-point)
9482 ;; If all commands are to be bunched up on one line, we collect
9484 (unless gnus-view-pseudos-separately
9485 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9488 (setq action (cdr (assq 'action (car ps))))
9489 (setq files (list (cdr (assq 'name (car ps)))))
9490 (while (and ps (cdr ps)
9491 (string= (or action "1")
9492 (or (cdr (assq 'action (cadr ps))) "2")))
9493 (push (cdr (assq 'name (cadr ps))) files)
9494 (setcdr ps (cddr ps)))
9496 (when (not (string-match "%s" action))
9499 (when (assq 'execute (car ps))
9500 (setcdr (assq 'execute (car ps))
9501 (funcall (if (string-match "%s" action)
9508 (gnus-quote-arg-for-sh-or-csh f)))
9510 (setq ps (cdr ps)))))
9511 (if (and gnus-view-pseudos (not not-view))
9513 (when (assq 'execute (car pslist))
9514 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9515 (eq gnus-view-pseudos 'not-confirm)))
9516 (setq pslist (cdr pslist)))
9519 (setq after-article (or (cdr (assq 'article (car pslist)))
9520 (gnus-summary-article-number)))
9521 (gnus-summary-goto-subject after-article)
9524 (insert " " (file-name-nondirectory
9525 (cdr (assq 'name (car pslist))))
9526 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9528 (forward-line -1) ; back to `b'
9529 (gnus-add-text-properties
9530 b (1- e) (list 'gnus-number gnus-reffed-article-number
9531 gnus-mouse-face-prop gnus-mouse-face))
9533 after-article gnus-reffed-article-number
9534 gnus-unread-mark b (car pslist) 0 (- e b))
9535 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9536 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9537 (setq pslist (cdr pslist)))))))
9539 (defun gnus-pseudos< (p1 p2)
9540 (let ((c1 (cdr (assq 'action p1)))
9541 (c2 (cdr (assq 'action p2))))
9542 (and c1 c2 (string< c1 c2))))
9544 (defun gnus-request-pseudo-article (props)
9545 (cond ((assq 'execute props)
9546 (gnus-execute-command (cdr (assq 'execute props)))))
9547 (let ((gnus-current-article (gnus-summary-article-number)))
9548 (gnus-run-hooks 'gnus-mark-article-hook)))
9550 (defun gnus-execute-command (command &optional automatic)
9552 (gnus-article-setup-buffer)
9553 (set-buffer gnus-article-buffer)
9554 (setq buffer-read-only nil)
9555 (let ((command (if automatic command
9556 (read-string "Command: " (cons command 0)))))
9558 (insert "$ " command "\n\n")
9559 (if gnus-view-pseudo-asynchronously
9560 (start-process "gnus-execute" (current-buffer) shell-file-name
9561 shell-command-switch command)
9562 (call-process shell-file-name nil t nil
9563 shell-command-switch command)))))
9565 ;; Summary kill commands.
9567 (defun gnus-summary-edit-global-kill (article)
9568 "Edit the \"global\" kill file."
9569 (interactive (list (gnus-summary-article-number)))
9570 (gnus-group-edit-global-kill article))
9572 (defun gnus-summary-edit-local-kill ()
9573 "Edit a local kill file applied to the current newsgroup."
9575 (setq gnus-current-headers (gnus-summary-article-header))
9576 (gnus-group-edit-local-kill
9577 (gnus-summary-article-number) gnus-newsgroup-name))
9581 (defun gnus-read-header (id &optional header)
9582 "Read the headers of article ID and enter them into the Gnus system."
9583 (let ((group gnus-newsgroup-name)
9584 (gnus-override-method
9586 gnus-override-method
9587 (and (gnus-news-group-p gnus-newsgroup-name)
9588 (car (gnus-refer-article-methods)))))
9590 ;; First we check to see whether the header in question is already
9593 ;; This is a Message-ID.
9594 (setq header (or header (gnus-id-to-header id)))
9595 ;; This is an article number.
9596 (setq header (or header (gnus-summary-article-header id))))
9598 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9599 ;; We have found the header.
9601 ;; If this is a sparse article, we have to nix out its
9602 ;; previous entry in the thread hashtb.
9604 (gnus-summary-article-sparse-p (mail-header-number header)))
9605 (let* ((parent (gnus-parent-id (mail-header-references header)))
9606 (thread (and parent (gnus-id-to-thread parent))))
9608 (delq (assq header thread) thread))))
9609 ;; We have to really fetch the header to this article.
9611 (set-buffer nntp-server-buffer)
9612 (when (setq where (gnus-request-head id group))
9613 (nnheader-fold-continuation-lines)
9614 (goto-char (point-max))
9616 (goto-char (point-min))
9620 ((cdr where) (cdr where))
9621 (header (mail-header-number header))
9622 (t gnus-reffed-article-number))
9624 (insert " Article retrieved.\n"))
9626 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9627 () ; Malformed head.
9628 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9629 (when (and (stringp id)
9630 (not (string= (gnus-group-real-name group)
9632 ;; If we fetched by Message-ID and the article came
9633 ;; from a different group, we fudge some bogus article
9634 ;; numbers for this article.
9635 (mail-header-set-number header gnus-reffed-article-number))
9637 (set-buffer gnus-summary-buffer)
9638 (decf gnus-reffed-article-number)
9639 (gnus-remove-header (mail-header-number header))
9640 (push header gnus-newsgroup-headers)
9641 (setq gnus-current-headers header)
9642 (push (mail-header-number header) gnus-newsgroup-limit)))
9645 (defun gnus-remove-header (number)
9646 "Remove header NUMBER from `gnus-newsgroup-headers'."
9647 (if (and gnus-newsgroup-headers
9648 (= number (mail-header-number (car gnus-newsgroup-headers))))
9649 (pop gnus-newsgroup-headers)
9650 (let ((headers gnus-newsgroup-headers))
9651 (while (and (cdr headers)
9652 (not (= number (mail-header-number (cadr headers)))))
9655 (setcdr headers (cddr headers))))))
9658 ;;; summary highlights
9661 (defun gnus-highlight-selected-summary ()
9662 "Highlight selected article in summary buffer."
9663 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9664 (when gnus-summary-selected-face
9666 (let* ((beg (progn (beginning-of-line) (point)))
9667 (end (progn (end-of-line) (point)))
9668 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9669 (from (if (get-text-property beg gnus-mouse-face-prop)
9671 (or (next-single-property-change
9672 beg gnus-mouse-face-prop nil end)
9677 (or (next-single-property-change
9678 from gnus-mouse-face-prop nil end)
9680 ;; If no mouse-face prop on line we will have to = from = end,
9681 ;; so we highlight the entire line instead.
9682 (when (= (+ to 2) from)
9685 (if gnus-newsgroup-selected-overlay
9686 ;; Move old overlay.
9688 gnus-newsgroup-selected-overlay from to (current-buffer))
9689 ;; Create new overlay.
9691 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9692 'face gnus-summary-selected-face))))))
9694 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9695 (defun gnus-summary-highlight-line ()
9696 "Highlight current line according to `gnus-summary-highlight'."
9697 (let* ((list gnus-summary-highlight)
9699 (end (progn (end-of-line) (point)))
9700 ;; now find out where the line starts and leave point there.
9701 (beg (progn (beginning-of-line) (point)))
9702 (article (gnus-summary-article-number))
9703 (score (or (cdr (assq (or article gnus-current-article)
9704 gnus-newsgroup-scored))
9705 gnus-summary-default-score 0))
9706 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9707 (inhibit-read-only t))
9708 ;; Eval the cars of the lists until we find a match.
9709 (let ((default gnus-summary-default-score))
9711 (not (eval (caar list))))
9712 (setq list (cdr list))))
9713 (let ((face (cdar list)))
9714 (unless (eq face (get-text-property beg 'face))
9715 (gnus-put-text-property-excluding-characters-with-faces
9717 (setq face (if (boundp face) (symbol-value face) face)))
9718 (when gnus-summary-highlight-line-function
9719 (funcall gnus-summary-highlight-line-function article face))))
9722 (defun gnus-update-read-articles (group unread &optional compute)
9723 "Update the list of read articles in GROUP."
9724 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9725 (entry (gnus-gethash group gnus-newsrc-hashtb))
9726 (info (nth 2 entry))
9728 (unread (sort (copy-sequence unread) '<))
9730 (if (or (not info) (not active))
9731 ;; There is no info on this group if it was, in fact,
9732 ;; killed. Gnus stores no information on killed groups, so
9733 ;; there's nothing to be done.
9734 ;; One could store the information somewhere temporarily,
9735 ;; perhaps... Hmmm...
9737 ;; Remove any negative articles numbers.
9738 (while (and unread (< (car unread) 0))
9739 (setq unread (cdr unread)))
9740 ;; Remove any expired article numbers
9741 (while (and unread (< (car unread) (car active)))
9742 (setq unread (cdr unread)))
9743 ;; Compute the ranges of read articles by looking at the list of
9746 (when (/= (car unread) prev)
9747 (push (if (= prev (1- (car unread))) prev
9748 (cons prev (1- (car unread))))
9750 (setq prev (1+ (car unread)))
9751 (setq unread (cdr unread)))
9752 (when (<= prev (cdr active))
9753 (push (cons prev (cdr active)) read))
9754 (setq read (if (> (length read) 1) (nreverse read) read))
9759 ;; Propagate the read marks to the backend.
9760 (when (gnus-check-backend-function 'request-set-mark group)
9761 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9762 (add (gnus-remove-from-range read (gnus-info-read info))))
9764 (unless (gnus-check-group group)
9765 (error "Can't open server for %s" group))
9766 (gnus-request-set-mark
9767 group (delq nil (list (if add (list add 'add '(read)))
9768 (if del (list del 'del '(read))))))
9770 `(gnus-request-set-mark
9773 (if del (list del 'add '(read)))
9774 (if add (list add 'del '(read))))))))))
9775 (set-buffer gnus-group-buffer)
9778 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9779 (gnus-info-set-read ',info ',(gnus-info-read info))
9780 (gnus-get-unread-articles-in-group ',info
9781 (gnus-active ,group))
9782 (gnus-group-update-group ,group t)
9784 ;; Enter this list into the group info.
9785 (gnus-info-set-read info read)
9786 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9787 (gnus-get-unread-articles-in-group info (gnus-active group))
9790 (defun gnus-offer-save-summaries ()
9791 "Offer to save all active summary buffers."
9793 (let ((buflist (buffer-list))
9795 ;; Go through all buffers and find all summaries.
9797 (and (setq bufname (buffer-name (car buflist)))
9798 (string-match "Summary" bufname)
9800 (set-buffer bufname)
9801 ;; We check that this is, indeed, a summary buffer.
9802 (and (eq major-mode 'gnus-summary-mode)
9803 ;; Also make sure this isn't bogus.
9804 gnus-newsgroup-prepared
9805 ;; Also make sure that this isn't a dead summary buffer.
9806 (not gnus-dead-summary-mode)))
9807 (push bufname buffers))
9808 (setq buflist (cdr buflist)))
9809 ;; Go through all these summary buffers and offer to save them.
9812 "Update summary buffer %s? "
9814 (switch-to-buffer buf)
9815 (gnus-summary-exit))
9819 ;;; @ for mime-partial
9822 (defun gnus-request-partial-message ()
9824 (let ((number (gnus-summary-article-number))
9825 (group gnus-newsgroup-name)
9826 (mother gnus-article-buffer))
9827 (set-buffer (get-buffer-create " *Partial Article*"))
9829 (setq mime-preview-buffer mother)
9830 (gnus-request-article-this-buffer number group)
9834 (autoload 'mime-combine-message/partial-pieces-automatically
9836 "Internal method to combine message/partial messages automatically.")
9839 'action '((type . message)(subtype . partial)
9840 (major-mode . gnus-original-article-mode)
9841 (method . mime-combine-message/partial-pieces-automatically)
9842 (summary-buffer-exp . gnus-summary-buffer)
9843 (request-partial-message-method . gnus-request-partial-message)
9847 ;;; @ for message/rfc822
9850 (defun gnus-mime-extract-message/rfc822 (entity situation)
9851 (let (group article num cwin swin cur)
9853 (mime-insert-entity-content entity)
9854 (setq group (or (cdr (assq 'group situation))
9855 (completing-read "Group: "
9858 (gnus-read-active-file-p)
9859 gnus-newsgroup-name))
9860 article (gnus-request-accept-article group)))
9861 (when (and (consp article)
9862 (numberp (setq article (cdr article))))
9863 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9864 cwin (get-buffer-window (current-buffer) t))
9865 (save-window-excursion
9866 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9867 (select-window swin)
9868 (set-buffer gnus-summary-buffer))
9869 (setq cur gnus-current-article)
9871 (let (gnus-show-threads)
9872 (gnus-summary-goto-subject article t))
9873 (gnus-summary-clear-mark-forward 1)
9874 (gnus-summary-goto-subject cur))
9875 (when (and cwin (window-frame cwin))
9876 (select-frame (window-frame cwin)))
9877 (when (boundp 'mime-acting-situation-to-override)
9878 (set-alist 'mime-acting-situation-to-override
9881 (set-alist 'mime-acting-situation-to-override
9884 (save-current-buffer
9885 (set-buffer gnus-group-buffer)
9886 (gnus-activate-group ,group))
9887 (gnus-summary-goto-article ,cur
9888 gnus-show-all-headers)))
9889 (set-alist 'mime-acting-situation-to-override
9893 'action '((type . message)(subtype . rfc822)
9894 (major-mode . gnus-original-article-mode)
9895 (method . gnus-mime-extract-message/rfc822)
9900 'action '((type . message)(subtype . news)
9901 (major-mode . gnus-original-article-mode)
9902 (method . gnus-mime-extract-message/rfc822)
9906 (defun gnus-mime-extract-multipart (entity situation)
9907 (let ((children (mime-entity-children entity))
9908 mime-acting-situation-to-override
9911 (mime-play-entity (car children)
9912 (cons (assq 'mode situation)
9913 mime-acting-situation-to-override))
9914 (setq children (cdr children)))
9915 (if (setq f (cdr (assq 'after-method
9916 mime-acting-situation-to-override)))
9921 'action '((type . multipart)
9922 (method . gnus-mime-extract-multipart)
9931 (defun gnus-summary-setup-default-charset ()
9932 "Setup newsgroup default charset."
9933 (if (equal gnus-newsgroup-name "nndraft:drafts")
9934 (setq gnus-newsgroup-charset nil)
9935 (let* ((name (and gnus-newsgroup-name
9936 (gnus-group-real-name gnus-newsgroup-name)))
9938 (or gnus-newsgroup-ephemeral-ignored-charsets
9940 (and gnus-newsgroup-name
9941 (or (gnus-group-find-parameter gnus-newsgroup-name
9942 'ignored-charsets t)
9943 (let ((alist gnus-group-ignored-charsets-alist)
9944 elem (charsets nil))
9945 (while (setq elem (pop alist))
9947 (string-match (car elem) name))
9949 charsets (cdr elem))))
9951 gnus-newsgroup-ignored-charsets))))
9952 (setq gnus-newsgroup-charset
9953 (or gnus-newsgroup-ephemeral-charset
9954 (and gnus-newsgroup-name
9955 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9956 (let ((alist gnus-group-charset-alist)
9958 (while (setq elem (pop alist))
9960 (string-match (car elem) name))
9962 charset (cadr elem))))
9964 gnus-default-charset))
9965 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9966 ignored-charsets))))
9972 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9973 "Display the current article buffer fully MIME-buttonized.
9974 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9975 treated as multipart/mixed."
9978 (let ((gnus-unbuttonized-mime-types nil)
9979 (gnus-mime-display-multipart-as-mixed show-all-parts))
9980 (gnus-summary-show-article)))
9982 (defun gnus-summary-repair-multipart (article)
9983 "Add a Content-Type header to a multipart article without one."
9984 (interactive (list (gnus-summary-article-number)))
9985 (gnus-with-article article
9986 (message-narrow-to-head)
9987 (goto-char (point-max))
9989 (when (search-forward "\n--" nil t)
9990 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9991 (message-narrow-to-head)
9992 (message-remove-header "Mime-Version")
9993 (message-remove-header "Content-Type")
9994 (goto-char (point-max))
9995 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9997 (insert "Mime-Version: 1.0\n")
9999 (let (gnus-mark-article-hook)
10000 (gnus-summary-select-article t t nil article)))
10002 (defun gnus-summary-toggle-display-buttonized ()
10003 "Toggle the buttonizing of the article buffer."
10005 (require 'gnus-art)
10006 (if (setq gnus-inhibit-mime-unbuttonizing
10007 (not gnus-inhibit-mime-unbuttonizing))
10008 (let ((gnus-unbuttonized-mime-types nil))
10009 (gnus-summary-show-article))
10010 (gnus-summary-show-article)))
10013 ;;; Intelli-mouse commmands
10016 (defun gnus-wheel-summary-scroll (event)
10018 (let ((amount (if (memq 'shift (event-modifiers event))
10019 (car gnus-wheel-scroll-amount)
10020 (cdr gnus-wheel-scroll-amount)))
10021 (direction (- (* (static-if (featurep 'xemacs)
10022 (event-button event)
10023 (cond ((eq 'mouse-4 (event-basic-type event))
10025 ((eq 'mouse-5 (event-basic-type event))
10029 (gnus-summary-scroll-up (* amount direction))
10030 (when (gnus-eval-in-buffer-window gnus-article-buffer
10033 (and (if (< 0 direction)
10034 (gnus-article-next-page 0)
10035 (gnus-article-prev-page 0)
10037 (if (setq edge (get-text-property
10038 (point-min) 'gnus-wheel-edge))
10039 (setq edge (* edge direction))
10042 (let ((buffer-read-only nil)
10043 (inhibit-read-only t))
10044 (put-text-property (point-min) (point-max)
10045 'gnus-wheel-edge direction)
10047 (or (> edge gnus-wheel-edge-resistance)
10048 (let ((buffer-read-only nil)
10049 (inhibit-read-only t))
10050 (put-text-property (point-min) (point-max)
10052 (* (1+ edge) direction))
10054 (eq last-command 'gnus-wheel-summary-scroll))))
10055 (gnus-summary-next-article nil nil (minusp direction)))))
10057 (defun gnus-wheel-install ()
10058 "Enable mouse wheel support on summary window."
10059 (when gnus-use-wheel
10061 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10063 (define-key gnus-summary-mode-map key
10064 'gnus-wheel-summary-scroll)))))
10066 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10069 ;;; Traditional PGP commmands
10072 (defun gnus-summary-decrypt-article (&optional force)
10073 "Decrypt the current article in traditional PGP way.
10074 This will have permanent effect only in mail groups.
10075 If FORCE is non-nil, allow editing of articles even in read-only
10078 (gnus-summary-select-article t)
10079 (gnus-eval-in-buffer-window gnus-article-buffer
10083 (goto-char (point-min))
10084 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10085 (error "Not a traditional PGP message!"))
10086 (let ((armor-start (match-beginning 0)))
10087 (if (and (pgg-decrypt-region armor-start (point-max))
10088 (or force (not (gnus-group-read-only-p))))
10089 (let ((inhibit-read-only t)
10091 (delete-region armor-start
10093 (re-search-forward "^-+END PGP" nil t)
10094 (beginning-of-line 2)
10096 (insert-buffer-substring pgg-output-buffer))))))))
10098 (defun gnus-summary-verify-article ()
10099 "Verify the current article in traditional PGP way."
10102 (set-buffer gnus-original-article-buffer)
10103 (goto-char (point-min))
10104 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10105 (error "Not a traditional PGP message!"))
10106 (re-search-forward "^-+END PGP" nil t)
10107 (beginning-of-line 2)
10108 (call-interactively (function pgg-verify-region))))
10111 ;;; Generic summary marking commands
10114 (defvar gnus-summary-marking-alist
10115 '((read gnus-del-mark "d")
10116 (unread gnus-unread-mark "u")
10117 (ticked gnus-ticked-mark "!")
10118 (dormant gnus-dormant-mark "?")
10119 (expirable gnus-expirable-mark "e"))
10120 "An alist of names/marks/keystrokes.")
10122 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10123 (defvar gnus-summary-mark-map)
10125 (defun gnus-summary-make-all-marking-commands ()
10126 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10127 (dolist (elem gnus-summary-marking-alist)
10128 (apply 'gnus-summary-make-marking-command elem)))
10130 (defun gnus-summary-make-marking-command (name mark keystroke)
10131 (let ((map (make-sparse-keymap)))
10132 (define-key gnus-summary-generic-mark-map keystroke map)
10133 (dolist (lway `((next "next" next nil "n")
10134 (next-unread "next unread" next t "N")
10135 (prev "previous" prev nil "p")
10136 (prev-unread "previous unread" prev t "P")
10137 (nomove "" nil nil ,keystroke)))
10138 (let ((func (gnus-summary-make-marking-command-1
10139 mark (car lway) lway name)))
10140 (setq func (eval func))
10141 (define-key map (nth 4 lway) func)))))
10143 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10145 (format "gnus-summary-put-mark-as-%s%s"
10146 name (if (eq way 'nomove)
10148 (concat "-" (symbol-name way)))))
10151 "Mark the current article as %s%s.
10152 If N, the prefix, then repeat N times.
10153 If N is negative, move in reverse order.
10154 The difference between N and the actual number of articles marked is
10156 name (car (cdr lway)))
10158 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10160 (defun gnus-summary-generic-mark (n mark move unread)
10161 "Mark N articles with MARK."
10162 (unless (eq major-mode 'gnus-summary-mode)
10163 (error "This command can only be used in the summary buffer"))
10164 (gnus-summary-show-thread)
10167 ((eq move 'next) 1)
10168 ((eq move 'prev) -1)
10170 (if (zerop nummove)
10174 nummove (* -1 nummove))))
10175 (while (and (> n 0)
10176 (gnus-summary-mark-article nil mark)
10177 (zerop (gnus-summary-next-subject nummove unread t)))
10180 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10181 (gnus-summary-recenter)
10182 (gnus-summary-position-point)
10183 (gnus-set-mode-line 'summary)
10186 (gnus-summary-make-all-marking-commands)
10188 (gnus-ems-redefine)
10190 (provide 'gnus-sum)
10192 (run-hooks 'gnus-sum-load-hook)
10194 ;;; gnus-sum.el ends here