1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
42 (autoload 'gnus-cache-write-active "gnus-cache")
43 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
44 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
45 (autoload 'mm-uu-dissect "mm-uu")
47 (defcustom gnus-kill-summary-on-exit t
48 "*If non-nil, kill the summary buffer when you exit from it.
49 If nil, the summary will become a \"*Dead Summary*\" buffer, and
50 it will be killed sometime later."
51 :group 'gnus-summary-exit
54 (defcustom gnus-fetch-old-headers nil
55 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
56 If an unread article in the group refers to an older, already read (or
57 just marked as read) article, the old article will not normally be
58 displayed in the Summary buffer. If this variable is non-nil, Gnus
59 will attempt to grab the headers to the old articles, and thereby
60 build complete threads. If it has the value `some', only enough
61 headers to connect otherwise loose threads will be displayed. This
62 variable can also be a number. In that case, no more than that number
63 of old headers will be fetched. If it has the value `invisible', all
64 old headers will be fetched, but none will be displayed.
66 The server has to support NOV for any of this to work."
68 :type '(choice (const :tag "off" nil)
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-refer-thread-limit 200
74 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
75 If t, fetch all the available old headers."
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-summary-make-false-root 'adopt
81 "*nil means that Gnus won't gather loose threads.
82 If the root of a thread has expired or been read in a previous
83 session, the information necessary to build a complete thread has been
84 lost. Instead of having many small sub-threads from this original thread
85 scattered all over the summary buffer, Gnus can gather them.
87 If non-nil, Gnus will try to gather all loose sub-threads from an
88 original thread into one large thread.
90 If this variable is non-nil, it should be one of `none', `adopt',
93 If this variable is `none', Gnus will not make a false root, but just
94 present the sub-threads after another.
95 If this variable is `dummy', Gnus will create a dummy root that will
96 have all the sub-threads as children.
97 If this variable is `adopt', Gnus will make one of the \"children\"
98 the parent and mark all the step-children as such.
99 If this variable is `empty', the \"children\" are printed with empty
100 subject fields. (Or rather, they will be printed with a string
101 given by the `gnus-summary-same-subject' variable.)"
103 :type '(choice (const :tag "off" nil)
109 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
110 "*A regexp to match subjects to be excluded from loose thread gathering.
111 As loose thread gathering is done on subjects only, that means that
112 there can be many false gatherings performed. By rooting out certain
113 common subjects, gathering might become saner."
117 (defcustom gnus-summary-gather-subject-limit nil
118 "*Maximum length of subject comparisons when gathering loose threads.
119 Use nil to compare full subjects. Setting this variable to a low
120 number will help gather threads that have been corrupted by
121 newsreaders chopping off subject lines, but it might also mean that
122 unrelated articles that have subject that happen to begin with the
123 same few characters will be incorrectly gathered.
125 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
128 :type '(choice (const :tag "off" nil)
130 (sexp :menu-tag "on" t)))
132 (defcustom gnus-simplify-subject-functions nil
133 "List of functions taking a string argument that simplify subjects.
134 The functions are applied recursively.
136 Useful functions to put in this list include: `gnus-simplify-subject-re',
137 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
139 :type '(repeat function))
141 (defcustom gnus-simplify-ignored-prefixes nil
142 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
144 :type '(choice (const :tag "off" nil)
147 (defcustom gnus-build-sparse-threads nil
148 "*If non-nil, fill in the gaps in threads.
149 If `some', only fill in the gaps that are needed to tie loose threads
150 together. If `more', fill in all leaf nodes that Gnus can find. If
151 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
153 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "all" t)))
158 (defcustom gnus-summary-thread-gathering-function
159 'gnus-gather-threads-by-subject
160 "*Function used for gathering loose threads.
161 There are two pre-defined functions: `gnus-gather-threads-by-subject',
162 which only takes Subjects into consideration; and
163 `gnus-gather-threads-by-references', which compared the References
164 headers of the articles to find matches."
166 :type '(radio (function-item gnus-gather-threads-by-subject)
167 (function-item gnus-gather-threads-by-references)
168 (function :tag "other")))
170 (defcustom gnus-summary-same-subject ""
171 "*String indicating that the current article has the same subject as the previous.
172 This variable will only be used if the value of
173 `gnus-summary-make-false-root' is `empty'."
174 :group 'gnus-summary-format
177 (defcustom gnus-summary-goto-unread t
178 "*If t, many commands will go to the next unread article.
179 This applies to marking commands as well as other commands that
180 \"naturally\" select the next article, like, for instance, `SPC' at
181 the end of an article.
183 If nil, the marking commands do NOT go to the next unread article
184 (they go to the next article instead). If `never', commands that
185 usually go to the next unread article, will go to the next article,
186 whether it is read or not."
187 :group 'gnus-summary-marks
188 :link '(custom-manual "(gnus)Setting Marks")
189 :type '(choice (const :tag "off" nil)
191 (sexp :menu-tag "on" t)))
193 (defcustom gnus-summary-default-score 0
194 "*Default article score level.
195 All scores generated by the score files will be added to this score.
196 If this variable is nil, scoring will be disabled."
197 :group 'gnus-score-default
198 :type '(choice (const :tag "disable")
201 (defcustom gnus-summary-default-high-score 0
202 "*Default threshold for a high scored article.
203 An article will be highlighted as high scored if its score is greater
205 :group 'gnus-score-default
208 (defcustom gnus-summary-default-low-score 0
209 "*Default threshold for a low scored article.
210 An article will be highlighted as low scored if its score is smaller
212 :group 'gnus-score-default
215 (defcustom gnus-summary-zcore-fuzz 0
216 "*Fuzziness factor for the zcore in the summary buffer.
217 Articles with scores closer than this to `gnus-summary-default-score'
219 :group 'gnus-summary-format
222 (defcustom gnus-simplify-subject-fuzzy-regexp nil
223 "*Strings to be removed when doing fuzzy matches.
224 This can either be a regular expression or list of regular expressions
225 that will be removed from subject strings if fuzzy subject
226 simplification is selected."
228 :type '(repeat regexp))
230 (defcustom gnus-show-threads t
231 "*If non-nil, display threads in summary mode."
235 (defcustom gnus-thread-hide-subtree nil
236 "*If non-nil, hide all threads initially.
237 This can be a predicate specifier which says which threads to hide.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If non-nil, select the article under point.
282 Which article this is is controlled by the `gnus-auto-select-subject'
285 If you want to prevent automatic selection of articles in some
286 newsgroups, set the variable to nil in `gnus-select-group-hook'."
287 :group 'gnus-group-select
288 :type '(choice (const :tag "none" nil)
289 (sexp :menu-tag "first" t)))
291 (defcustom gnus-auto-select-subject 'unread
292 "*Says what subject to place under point when entering a group.
294 This variable can either be the symbols `first' (place point on the
295 first subject), `unread' (place point on the subject line of the first
296 unread article), `best' (place point on the subject line of the
297 higest-scored article), `unseen' (place point on the subject line of
298 the first unseen article), or a function to be called to place point on
300 :group 'gnus-group-select
301 :type '(choice (const best)
306 (defcustom gnus-auto-select-next t
307 "*If non-nil, offer to go to the next group from the end of the previous.
308 If the value is t and the next newsgroup is empty, Gnus will exit
309 summary mode and go back to group mode. If the value is neither nil
310 nor t, Gnus will select the following unread newsgroup. In
311 particular, if the value is the symbol `quietly', the next unread
312 newsgroup will be selected without any confirmation, and if it is
313 `almost-quietly', the next group will be selected without any
314 confirmation if you are located on the last article in the group.
315 Finally, if this variable is `slightly-quietly', the `Z n' command
316 will go to the next group without confirmation."
317 :group 'gnus-summary-maneuvering
318 :type '(choice (const :tag "off" nil)
320 (const almost-quietly)
321 (const slightly-quietly)
322 (sexp :menu-tag "on" t)))
324 (defcustom gnus-auto-select-same nil
325 "*If non-nil, select the next article with the same subject.
326 If there are no more articles with the same subject, go to
327 the first unread article."
328 :group 'gnus-summary-maneuvering
331 (defcustom gnus-summary-check-current nil
332 "*If non-nil, consider the current article when moving.
333 The \"unread\" movement commands will stay on the same line if the
334 current article is unread."
335 :group 'gnus-summary-maneuvering
338 (defcustom gnus-auto-center-summary t
339 "*If non-nil, always center the current summary buffer.
340 In particular, if `vertical' do only vertical recentering. If non-nil
341 and non-`vertical', do both horizontal and vertical recentering."
342 :group 'gnus-summary-maneuvering
343 :type '(choice (const :tag "none" nil)
345 (integer :tag "height")
346 (sexp :menu-tag "both" t)))
348 (defcustom gnus-show-all-headers nil
349 "*If non-nil, don't hide any headers."
350 :group 'gnus-article-hiding
351 :group 'gnus-article-headers
354 (defcustom gnus-summary-ignore-duplicates nil
355 "*If non-nil, ignore articles with identical Message-ID headers."
359 (defcustom gnus-single-article-buffer t
360 "*If non-nil, display all articles in the same buffer.
361 If nil, each group will get its own article buffer."
362 :group 'gnus-article-various
365 (defcustom gnus-break-pages t
366 "*If non-nil, do page breaking on articles.
367 The page delimiter is specified by the `gnus-page-delimiter'
369 :group 'gnus-article-various
372 (defcustom gnus-move-split-methods nil
373 "*Variable used to suggest where articles are to be moved to.
374 It uses the same syntax as the `gnus-split-methods' variable.
375 However, whereas `gnus-split-methods' specifies file names as targets,
376 this variable specifies group names."
377 :group 'gnus-summary-mail
378 :type '(repeat (choice (list :value (fun) function)
379 (cons :value ("" "") regexp (repeat string))
382 (defcustom gnus-unread-mark ? ;Whitespace
383 "*Mark used for unread articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-ticked-mark ?!
388 "*Mark used for ticked articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-dormant-mark ??
393 "*Mark used for dormant articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-del-mark ?r
398 "*Mark used for del'd articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-read-mark ?R
403 "*Mark used for read articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-expirable-mark ?E
408 "*Mark used for expirable articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-killed-mark ?K
413 "*Mark used for killed articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-souped-mark ?F
418 "*Mark used for souped articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-kill-file-mark ?X
423 "*Mark used for articles killed by kill files."
424 :group 'gnus-summary-marks
427 (defcustom gnus-low-score-mark ?Y
428 "*Mark used for articles with a low score."
429 :group 'gnus-summary-marks
432 (defcustom gnus-catchup-mark ?C
433 "*Mark used for articles that are caught up."
434 :group 'gnus-summary-marks
437 (defcustom gnus-replied-mark ?A
438 "*Mark used for articles that have been replied to."
439 :group 'gnus-summary-marks
442 (defcustom gnus-forwarded-mark ?F
443 "*Mark used for articles that have been forwarded."
444 :group 'gnus-summary-marks
447 (defcustom gnus-recent-mark ?N
448 "*Mark used for articles that are recent."
449 :group 'gnus-summary-marks
452 (defcustom gnus-cached-mark ?*
453 "*Mark used for articles that are in the cache."
454 :group 'gnus-summary-marks
457 (defcustom gnus-saved-mark ?S
458 "*Mark used for articles that have been saved."
459 :group 'gnus-summary-marks
462 (defcustom gnus-unseen-mark ?.
463 "*Mark used for articles that haven't been seen."
464 :group 'gnus-summary-marks
467 (defcustom gnus-no-mark ? ;Whitespace
468 "*Mark used for articles that have no other secondary mark."
469 :group 'gnus-summary-marks
472 (defcustom gnus-ancient-mark ?O
473 "*Mark used for ancient articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-sparse-mark ?Q
478 "*Mark used for sparsely reffed articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-canceled-mark ?G
483 "*Mark used for canceled articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-duplicate-mark ?M
488 "*Mark used for duplicate articles."
489 :group 'gnus-summary-marks
492 (defcustom gnus-undownloaded-mark ?@
493 "*Mark used for articles that weren't downloaded."
494 :group 'gnus-summary-marks
497 (defcustom gnus-downloadable-mark ?%
498 "*Mark used for articles that are to be downloaded."
499 :group 'gnus-summary-marks
502 (defcustom gnus-unsendable-mark ?=
503 "*Mark used for articles that won't be sent."
504 :group 'gnus-summary-marks
507 (defcustom gnus-score-over-mark ?+
508 "*Score mark used for articles with high scores."
509 :group 'gnus-summary-marks
512 (defcustom gnus-score-below-mark ?-
513 "*Score mark used for articles with low scores."
514 :group 'gnus-summary-marks
517 (defcustom gnus-empty-thread-mark ? ;Whitespace
518 "*There is no thread under the article."
519 :group 'gnus-summary-marks
522 (defcustom gnus-not-empty-thread-mark ?=
523 "*There is a thread under the article."
524 :group 'gnus-summary-marks
527 (defcustom gnus-view-pseudo-asynchronously nil
528 "*If non-nil, Gnus will view pseudo-articles asynchronously."
529 :group 'gnus-extract-view
532 (defcustom gnus-auto-expirable-marks
533 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
534 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
535 gnus-souped-mark gnus-duplicate-mark)
536 "*The list of marks converted into expiration if a group is auto-expirable."
539 :type '(repeat character))
541 (defcustom gnus-inhibit-user-auto-expire t
542 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
547 (defcustom gnus-view-pseudos nil
548 "*If `automatic', pseudo-articles will be viewed automatically.
549 If `not-confirm', pseudos will be viewed automatically, and the user
550 will not be asked to confirm the command."
551 :group 'gnus-extract-view
552 :type '(choice (const :tag "off" nil)
554 (const not-confirm)))
556 (defcustom gnus-view-pseudos-separately t
557 "*If non-nil, one pseudo-article will be created for each file to be viewed.
558 If nil, all files that use the same viewing command will be given as a
559 list of parameters to that command."
560 :group 'gnus-extract-view
563 (defcustom gnus-insert-pseudo-articles t
564 "*If non-nil, insert pseudo-articles when decoding articles."
565 :group 'gnus-extract-view
568 (defcustom gnus-summary-dummy-line-format
570 "*The format specification for the dummy roots in the summary buffer.
571 It works along the same lines as a normal formatting string,
572 with some simple extensions.
575 :group 'gnus-threading
578 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
579 "*The format specification for the summary mode line.
580 It works along the same lines as a normal formatting string,
581 with some simple extensions:
584 %p Unprefixed group name
585 %A Current article number
586 %z Current article score
588 %U Number of unread articles in the group
589 %e Number of unselected articles in the group
590 %Z A string with unread/unselected article counts
591 %g Shortish group name
592 %S Subject of the current article
594 %s Current score file name
595 %d Number of dormant articles
596 %r Number of articles that have been marked as read in this session
597 %E Number of articles expunged by the score files"
598 :group 'gnus-summary-format
601 (defcustom gnus-list-identifiers nil
602 "Regexp that matches list identifiers to be removed from subject.
603 This can also be a list of regexps."
605 :group 'gnus-summary-format
606 :group 'gnus-article-hiding
607 :type '(choice (const :tag "none" nil)
609 (repeat :value (".*") regexp)))
611 (defcustom gnus-summary-mark-below 0
612 "*Mark all articles with a score below this variable as read.
613 This variable is local to each summary buffer and usually set by the
615 :group 'gnus-score-default
618 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
619 "*List of functions used for sorting articles in the summary buffer.
621 Each function takes two articles and returns non-nil if the first
622 article should be sorted before the other. If you use more than one
623 function, the primary sort function should be the last. You should
624 probably always include `gnus-article-sort-by-number' in the list of
625 sorting functions -- preferably first. Also note that sorting by date
626 is often much slower than sorting by number, and the sorting order is
627 very similar. (Sorting by date means sorting by the time the message
628 was sent, sorting by number means sorting by arrival time.)
630 Ready-made functions include `gnus-article-sort-by-number',
631 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
632 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
634 When threading is turned on, the variable `gnus-thread-sort-functions'
635 controls how articles are sorted."
636 :group 'gnus-summary-sort
637 :type '(repeat (choice (function-item gnus-article-sort-by-number)
638 (function-item gnus-article-sort-by-author)
639 (function-item gnus-article-sort-by-subject)
640 (function-item gnus-article-sort-by-date)
641 (function-item gnus-article-sort-by-score)
642 (function :tag "other"))))
644 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
645 "*List of functions used for sorting threads in the summary buffer.
646 By default, threads are sorted by article number.
648 Each function takes two threads and returns non-nil if the first
649 thread should be sorted before the other. If you use more than one
650 function, the primary sort function should be the last. You should
651 probably always include `gnus-thread-sort-by-number' in the list of
652 sorting functions -- preferably first. Also note that sorting by date
653 is often much slower than sorting by number, and the sorting order is
654 very similar. (Sorting by date means sorting by the time the message
655 was sent, sorting by number means sorting by arrival time.)
657 Ready-made functions include `gnus-thread-sort-by-number',
658 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
659 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
660 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
662 When threading is turned off, the variable
663 `gnus-article-sort-functions' controls how articles are sorted."
664 :group 'gnus-summary-sort
665 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
666 (function-item gnus-thread-sort-by-author)
667 (function-item gnus-thread-sort-by-subject)
668 (function-item gnus-thread-sort-by-date)
669 (function-item gnus-thread-sort-by-score)
670 (function-item gnus-thread-sort-by-total-score)
671 (function :tag "other"))))
673 (defcustom gnus-thread-score-function '+
674 "*Function used for calculating the total score of a thread.
676 The function is called with the scores of the article and each
677 subthread and should then return the score of the thread.
679 Some functions you can use are `+', `max', or `min'."
680 :group 'gnus-summary-sort
683 (defcustom gnus-summary-expunge-below nil
684 "All articles that have a score less than this variable will be expunged.
685 This variable is local to the summary buffers."
686 :group 'gnus-score-default
687 :type '(choice (const :tag "off" nil)
690 (defcustom gnus-thread-expunge-below nil
691 "All threads that have a total score less than this variable will be expunged.
692 See `gnus-thread-score-function' for en explanation of what a
695 This variable is local to the summary buffers."
696 :group 'gnus-threading
697 :group 'gnus-score-default
698 :type '(choice (const :tag "off" nil)
701 (defcustom gnus-summary-mode-hook nil
702 "*A hook for Gnus summary mode.
703 This hook is run before any variables are set in the summary buffer."
704 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
705 :group 'gnus-summary-various
708 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
709 (when (featurep 'xemacs)
710 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
711 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
712 (add-hook 'gnus-summary-mode-hook
713 'gnus-xmas-switch-horizontal-scrollbar-off))
715 (defcustom gnus-summary-menu-hook nil
716 "*Hook run after the creation of the summary mode menu."
717 :group 'gnus-summary-visual
720 (defcustom gnus-summary-exit-hook nil
721 "*A hook called on exit from the summary buffer.
722 It will be called with point in the group buffer."
723 :group 'gnus-summary-exit
726 (defcustom gnus-summary-prepare-hook nil
727 "*A hook called after the summary buffer has been generated.
728 If you want to modify the summary buffer, you can use this hook."
729 :group 'gnus-summary-various
732 (defcustom gnus-summary-prepared-hook nil
733 "*A hook called as the last thing after the summary buffer has been generated."
734 :group 'gnus-summary-various
737 (defcustom gnus-summary-generate-hook nil
738 "*A hook run just before generating the summary buffer.
739 This hook is commonly used to customize threading variables and the
741 :group 'gnus-summary-various
744 (defcustom gnus-select-group-hook nil
745 "*A hook called when a newsgroup is selected.
747 If you'd like to simplify subjects like the
748 `gnus-summary-next-same-subject' command does, you can use the
751 (setq gnus-select-group-hook
754 (mapcar (lambda (header)
755 (mail-header-set-subject
757 (gnus-simplify-subject
758 (mail-header-subject header) 're-only)))
759 gnus-newsgroup-headers))))"
760 :group 'gnus-group-select
763 (defcustom gnus-select-article-hook nil
764 "*A hook called when an article is selected."
765 :group 'gnus-summary-choose
768 (defcustom gnus-visual-mark-article-hook
769 (list 'gnus-highlight-selected-summary)
770 "*Hook run after selecting an article in the summary buffer.
771 It is meant to be used for highlighting the article in some way. It
772 is not run if `gnus-visual' is nil."
773 :group 'gnus-summary-visual
776 (defcustom gnus-parse-headers-hook nil
777 "*A hook called before parsing the headers."
781 (defcustom gnus-exit-group-hook nil
782 "*A hook called when exiting summary mode.
783 This hook is not called from the non-updating exit commands like `Q'."
787 (defcustom gnus-summary-update-hook
788 (list 'gnus-summary-highlight-line)
789 "*A hook called when a summary line is changed.
790 The hook will not be called if `gnus-visual' is nil.
792 The default function `gnus-summary-highlight-line' will
793 highlight the line according to the `gnus-summary-highlight'
795 :group 'gnus-summary-visual
798 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
799 "*A hook called when an article is selected for the first time.
800 The hook is intended to mark an article as read (or unread)
801 automatically when it is selected."
802 :group 'gnus-summary-choose
805 (defcustom gnus-group-no-more-groups-hook nil
806 "*A hook run when returning to group mode having no more (unread) groups."
807 :group 'gnus-group-select
810 (defcustom gnus-ps-print-hook nil
811 "*A hook run before ps-printing something from Gnus."
815 (defcustom gnus-summary-display-arrow
816 (and (fboundp 'display-graphic-p)
818 "*If non-nil, display an arrow highlighting the current article."
823 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
824 "Face used for highlighting the current article in the summary buffer."
825 :group 'gnus-summary-visual
828 (defcustom gnus-summary-highlight
829 '(((= mark gnus-canceled-mark)
830 . gnus-summary-cancelled-face)
831 ((and (> score default-high)
832 (or (= mark gnus-dormant-mark)
833 (= mark gnus-ticked-mark)))
834 . gnus-summary-high-ticked-face)
835 ((and (< score default-low)
836 (or (= mark gnus-dormant-mark)
837 (= mark gnus-ticked-mark)))
838 . gnus-summary-low-ticked-face)
839 ((or (= mark gnus-dormant-mark)
840 (= mark gnus-ticked-mark))
841 . gnus-summary-normal-ticked-face)
842 ((and (> score default-high) (= mark gnus-ancient-mark))
843 . gnus-summary-high-ancient-face)
844 ((and (< score default-low) (= mark gnus-ancient-mark))
845 . gnus-summary-low-ancient-face)
846 ((= mark gnus-ancient-mark)
847 . gnus-summary-normal-ancient-face)
848 ((and (> score default-high) (= mark gnus-unread-mark))
849 . gnus-summary-high-unread-face)
850 ((and (< score default-low) (= mark gnus-unread-mark))
851 . gnus-summary-low-unread-face)
852 ((= mark gnus-unread-mark)
853 . gnus-summary-normal-unread-face)
854 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
855 gnus-undownloaded-mark)))
856 . gnus-summary-high-unread-face)
857 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
858 gnus-undownloaded-mark)))
859 . gnus-summary-low-unread-face)
860 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
861 (memq article gnus-newsgroup-unreads))
862 . gnus-summary-normal-unread-face)
863 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
864 . gnus-summary-normal-read-face)
865 ((> score default-high)
866 . gnus-summary-high-read-face)
867 ((< score default-low)
868 . gnus-summary-low-read-face)
870 . gnus-summary-normal-read-face))
871 "*Controls the highlighting of summary buffer lines.
873 A list of (FORM . FACE) pairs. When deciding how a a particular
874 summary line should be displayed, each form is evaluated. The content
875 of the face field after the first true form is used. You can change
876 how those summary lines are displayed, by editing the face field.
878 You can use the following variables in the FORM field.
880 score: The article's score
881 default: The default article score.
882 default-high: The default score for high scored articles.
883 default-low: The default score for low scored articles.
884 below: The score below which articles are automatically marked as read.
885 mark: The articles mark."
886 :group 'gnus-summary-visual
887 :type '(repeat (cons (sexp :tag "Form" nil)
890 (defcustom gnus-alter-header-function nil
891 "Function called to allow alteration of article header structures.
892 The function is called with one parameter, the article header vector,
893 which it may alter in any way.")
895 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
896 "Variable that says which function should be used to decode a string with encoded words.")
898 (defcustom gnus-extra-headers '(To Newsgroups)
899 "*Extra headers to parse."
902 :type '(repeat symbol))
904 (defcustom gnus-ignored-from-addresses
905 (and user-mail-address (regexp-quote user-mail-address))
906 "*Regexp of From headers that may be suppressed in favor of To headers."
911 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
912 "List of charsets that should be ignored.
913 When these charsets are used in the \"charset\" parameter, the
914 default charset will be used instead."
916 :type '(repeat symbol)
917 :group 'gnus-charset)
919 (gnus-define-group-parameter
923 "Return the ignored charsets of GROUP."
924 :variable gnus-group-ignored-charsets-alist
926 '(("alt\\.chinese\\.text" iso-8859-1))
928 "Alist of regexps (to match group names) and charsets that should be ignored.
929 When these charsets are used in the \"charset\" parameter, the
930 default charset will be used instead."
931 :variable-group gnus-charset
932 :variable-type '(repeat (cons (regexp :tag "Group")
934 :parameter-type '(choice :tag "Ignored charsets"
937 :parameter-document "\
938 List of charsets that should be ignored.
940 When these charsets are used in the \"charset\" parameter, the
941 default charset will be used instead.")
943 (defcustom gnus-group-highlight-words-alist nil
944 "Alist of group regexps and highlight regexps.
945 This variable uses the same syntax as `gnus-emphasis-alist'."
947 :type '(repeat (cons (regexp :tag "Group")
948 (repeat (list (regexp :tag "Highlight regexp")
949 (number :tag "Group for entire word" 0)
950 (number :tag "Group for displayed part" 0)
952 gnus-emphasis-highlight-words)))))
953 :group 'gnus-summary-visual)
955 (defcustom gnus-summary-show-article-charset-alist
957 "Alist of number and charset.
958 The article will be shown with the charset corresponding to the
960 For example: ((1 . cn-gb-2312) (2 . big5))."
962 :type '(repeat (cons (number :tag "Argument" 1)
963 (symbol :tag "Charset")))
964 :group 'gnus-charset)
966 (defcustom gnus-preserve-marks t
967 "Whether marks are preserved when moving, copying and respooling messages."
970 :group 'gnus-summary-marks)
972 (defcustom gnus-alter-articles-to-read-function nil
973 "Function to be called to alter the list of articles to be selected."
974 :type '(choice (const nil) function)
975 :group 'gnus-summary)
977 (defcustom gnus-orphan-score nil
978 "*All orphans get this score added. Set in the score file."
979 :group 'gnus-score-default
980 :type '(choice (const nil)
983 (defcustom gnus-summary-save-parts-default-mime "image/.*"
984 "*A regexp to match MIME parts when saving multiple parts of a message
985 with gnus-summary-save-parts (X m). This regexp will be used by default
986 when prompting the user for which type of files to save."
991 (defcustom gnus-summary-save-parts-default-mime "image/.*"
992 "*A regexp to match MIME parts when saving multiple parts of a message
993 with gnus-summary-save-parts (X m). This regexp will be used by default
994 when prompting the user for which type of files to save."
998 (defcustom gnus-read-all-available-headers nil
999 "Whether Gnus should parse all headers made available to it.
1000 This is mostly relevant for slow backends where the user may
1001 wish to widen the summary buffer to include all headers
1002 that were fetched. Say, for nnultimate groups."
1003 :group 'gnus-summary
1004 :type '(choice boolean regexp))
1006 (defcustom gnus-summary-muttprint-program "muttprint"
1007 "Command (and optional arguments) used to run Muttprint."
1008 :group 'gnus-summary
1011 ;;; Internal variables
1013 (defvar gnus-summary-display-cache nil)
1014 (defvar gnus-article-mime-handles nil)
1015 (defvar gnus-article-decoded-p nil)
1016 (defvar gnus-article-charset nil)
1017 (defvar gnus-article-ignored-charsets nil)
1018 (defvar gnus-scores-exclude-files nil)
1019 (defvar gnus-page-broken nil)
1020 (defvar gnus-inhibit-mime-unbuttonizing nil)
1022 (defvar gnus-original-article nil)
1023 (defvar gnus-article-internal-prepare-hook nil)
1024 (defvar gnus-newsgroup-process-stack nil)
1026 (defvar gnus-thread-indent-array nil)
1027 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1028 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1029 "Function called to sort the articles within a thread after it has been gathered together.")
1031 (defvar gnus-summary-save-parts-type-history nil)
1032 (defvar gnus-summary-save-parts-last-directory nil)
1034 (defvar gnus-summary-save-parts-type-history nil)
1035 (defvar gnus-summary-save-parts-last-directory nil)
1037 ;; Avoid highlighting in kill files.
1038 (defvar gnus-summary-inhibit-highlight nil)
1039 (defvar gnus-newsgroup-selected-overlay nil)
1040 (defvar gnus-inhibit-limiting nil)
1041 (defvar gnus-newsgroup-adaptive-score-file nil)
1042 (defvar gnus-current-score-file nil)
1043 (defvar gnus-current-move-group nil)
1044 (defvar gnus-current-copy-group nil)
1045 (defvar gnus-current-crosspost-group nil)
1046 (defvar gnus-newsgroup-display nil)
1048 (defvar gnus-newsgroup-dependencies nil)
1049 (defvar gnus-newsgroup-adaptive nil)
1050 (defvar gnus-summary-display-article-function nil)
1051 (defvar gnus-summary-highlight-line-function nil
1052 "Function called after highlighting a summary line.")
1054 (defvar gnus-summary-line-format-alist
1055 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1056 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1057 (?s gnus-tmp-subject-or-nil ?s)
1058 (?n gnus-tmp-name ?s)
1059 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1061 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1063 (?F gnus-tmp-from ?s)
1064 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1065 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1066 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1067 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1068 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1069 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1070 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1071 (?L gnus-tmp-lines ?s)
1072 (?I gnus-tmp-indentation ?s)
1073 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1074 (?R gnus-tmp-replied ?c)
1075 (?\[ gnus-tmp-opening-bracket ?c)
1076 (?\] gnus-tmp-closing-bracket ?c)
1077 (?\> (make-string gnus-tmp-level ? ) ?s)
1078 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1079 (?i gnus-tmp-score ?d)
1080 (?z gnus-tmp-score-char ?c)
1081 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1082 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1083 (?U gnus-tmp-unread ?c)
1084 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1086 (?t (gnus-summary-number-of-articles-in-thread
1087 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1089 (?e (gnus-summary-number-of-articles-in-thread
1090 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1092 (?u gnus-tmp-user-defined ?s)
1093 (?P (gnus-pick-line-number) ?d)
1094 (?B gnus-tmp-thread-tree-header-string ?s)
1095 (user-date (gnus-user-date
1096 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1097 "An alist of format specifications that can appear in summary lines.
1098 These are paired with what variables they correspond with, along with
1099 the type of the variable (string, integer, character, etc).")
1101 (defvar gnus-summary-dummy-line-format-alist
1102 `((?S gnus-tmp-subject ?s)
1103 (?N gnus-tmp-number ?d)
1104 (?u gnus-tmp-user-defined ?s)))
1106 (defvar gnus-summary-mode-line-format-alist
1107 `((?G gnus-tmp-group-name ?s)
1108 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1109 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1110 (?A gnus-tmp-article-number ?d)
1111 (?Z gnus-tmp-unread-and-unselected ?s)
1112 (?V gnus-version ?s)
1113 (?U gnus-tmp-unread-and-unticked ?d)
1114 (?S gnus-tmp-subject ?s)
1115 (?e gnus-tmp-unselected ?d)
1116 (?u gnus-tmp-user-defined ?s)
1117 (?d (length gnus-newsgroup-dormant) ?d)
1118 (?t (length gnus-newsgroup-marked) ?d)
1119 (?r (length gnus-newsgroup-reads) ?d)
1120 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1121 (?E gnus-newsgroup-expunged-tally ?d)
1122 (?s (gnus-current-score-file-nondirectory) ?s)))
1124 (defvar gnus-last-search-regexp nil
1125 "Default regexp for article search command.")
1127 (defvar gnus-last-shell-command nil
1128 "Default shell command on article.")
1130 (defvar gnus-newsgroup-begin nil)
1131 (defvar gnus-newsgroup-end nil)
1132 (defvar gnus-newsgroup-last-rmail nil)
1133 (defvar gnus-newsgroup-last-mail nil)
1134 (defvar gnus-newsgroup-last-folder nil)
1135 (defvar gnus-newsgroup-last-file nil)
1136 (defvar gnus-newsgroup-auto-expire nil)
1137 (defvar gnus-newsgroup-active nil)
1139 (defvar gnus-newsgroup-data nil)
1140 (defvar gnus-newsgroup-data-reverse nil)
1141 (defvar gnus-newsgroup-limit nil)
1142 (defvar gnus-newsgroup-limits nil)
1144 (defvar gnus-newsgroup-unreads nil
1145 "List of unread articles in the current newsgroup.")
1147 (defvar gnus-newsgroup-unselected nil
1148 "List of unselected unread articles in the current newsgroup.")
1150 (defvar gnus-newsgroup-reads nil
1151 "Alist of read articles and article marks in the current newsgroup.")
1153 (defvar gnus-newsgroup-expunged-tally nil)
1155 (defvar gnus-newsgroup-marked nil
1156 "List of ticked articles in the current newsgroup (a subset of unread art).")
1158 (defvar gnus-newsgroup-killed nil
1159 "List of ranges of articles that have been through the scoring process.")
1161 (defvar gnus-newsgroup-cached nil
1162 "List of articles that come from the article cache.")
1164 (defvar gnus-newsgroup-saved nil
1165 "List of articles that have been saved.")
1167 (defvar gnus-newsgroup-kill-headers nil)
1169 (defvar gnus-newsgroup-replied nil
1170 "List of articles that have been replied to in the current newsgroup.")
1172 (defvar gnus-newsgroup-forwarded nil
1173 "List of articles that have been forwarded in the current newsgroup.")
1175 (defvar gnus-newsgroup-recent nil
1176 "List of articles that have are recent in the current newsgroup.")
1178 (defvar gnus-newsgroup-expirable nil
1179 "List of articles in the current newsgroup that can be expired.")
1181 (defvar gnus-newsgroup-processable nil
1182 "List of articles in the current newsgroup that can be processed.")
1184 (defvar gnus-newsgroup-downloadable nil
1185 "List of articles in the current newsgroup that can be processed.")
1187 (defvar gnus-newsgroup-undownloaded nil
1188 "List of articles in the current newsgroup that haven't been downloaded..")
1190 (defvar gnus-newsgroup-unsendable nil
1191 "List of articles in the current newsgroup that won't be sent.")
1193 (defvar gnus-newsgroup-bookmarks nil
1194 "List of articles in the current newsgroup that have bookmarks.")
1196 (defvar gnus-newsgroup-dormant nil
1197 "List of dormant articles in the current newsgroup.")
1199 (defvar gnus-newsgroup-unseen nil
1200 "List of unseen articles in the current newsgroup.")
1202 (defvar gnus-newsgroup-seen nil
1203 "Range of seen articles in the current newsgroup.")
1205 (defvar gnus-newsgroup-articles nil
1206 "List of articles in the current newsgroup.")
1208 (defvar gnus-newsgroup-scored nil
1209 "List of scored articles in the current newsgroup.")
1211 (defvar gnus-newsgroup-headers nil
1212 "List of article headers in the current newsgroup.")
1214 (defvar gnus-newsgroup-threads nil)
1216 (defvar gnus-newsgroup-prepared nil
1217 "Whether the current group has been prepared properly.")
1219 (defvar gnus-newsgroup-ancient nil
1220 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1222 (defvar gnus-newsgroup-sparse nil)
1224 (defvar gnus-current-article nil)
1225 (defvar gnus-article-current nil)
1226 (defvar gnus-current-headers nil)
1227 (defvar gnus-have-all-headers nil)
1228 (defvar gnus-last-article nil)
1229 (defvar gnus-newsgroup-history nil)
1230 (defvar gnus-newsgroup-charset nil)
1231 (defvar gnus-newsgroup-ephemeral-charset nil)
1232 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1234 (defvar gnus-article-before-search nil)
1236 (defconst gnus-summary-local-variables
1237 '(gnus-newsgroup-name
1238 gnus-newsgroup-begin gnus-newsgroup-end
1239 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1240 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1241 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1242 gnus-newsgroup-unselected gnus-newsgroup-marked
1243 gnus-newsgroup-reads gnus-newsgroup-saved
1244 gnus-newsgroup-replied gnus-newsgroup-forwarded
1245 gnus-newsgroup-recent
1246 gnus-newsgroup-expirable
1247 gnus-newsgroup-processable gnus-newsgroup-killed
1248 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1249 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1250 gnus-newsgroup-seen gnus-newsgroup-articles
1251 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1252 gnus-newsgroup-headers gnus-newsgroup-threads
1253 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1254 gnus-current-article gnus-current-headers gnus-have-all-headers
1255 gnus-last-article gnus-article-internal-prepare-hook
1256 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1257 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1258 gnus-thread-expunge-below
1259 gnus-score-alist gnus-current-score-file
1260 (gnus-summary-expunge-below . global)
1261 (gnus-summary-mark-below . global)
1262 (gnus-orphan-score . global)
1263 gnus-newsgroup-active gnus-scores-exclude-files
1264 gnus-newsgroup-history gnus-newsgroup-ancient
1265 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1266 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1267 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1268 (gnus-newsgroup-expunged-tally . 0)
1269 gnus-cache-removable-articles gnus-newsgroup-cached
1270 gnus-newsgroup-data gnus-newsgroup-data-reverse
1271 gnus-newsgroup-limit gnus-newsgroup-limits
1272 gnus-newsgroup-charset gnus-newsgroup-display)
1273 "Variables that are buffer-local to the summary buffers.")
1275 (defvar gnus-newsgroup-variables nil
1276 "A list of variables that have separate values in different newsgroups.
1277 A list of newsgroup (summary buffer) local variables, or cons of
1278 variables and their default values (when the default values are not
1279 nil), that should be made global while the summary buffer is active.
1280 These variables can be used to set variables in the group parameters
1281 while still allowing them to affect operations done in other
1282 buffers. For example:
1284 \(setq gnus-newsgroup-variables
1285 '(message-use-followup-to
1286 (gnus-visible-headers .
1287 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1290 ;; Byte-compiler warning.
1291 (eval-when-compile (defvar gnus-article-mode-map))
1295 (defvar gnus-decode-encoded-word-methods
1296 '(mail-decode-encoded-word-string)
1297 "List of methods used to decode encoded words.
1299 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1300 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1301 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1302 whose names match REGEXP.
1305 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1306 mail-decode-encoded-word-string
1307 (\"chinese\" . rfc1843-decode-string))")
1309 (defvar gnus-decode-encoded-word-methods-cache nil)
1311 (defun gnus-multi-decode-encoded-word-string (string)
1312 "Apply the functions from `gnus-encoded-word-methods' that match."
1313 (unless (and gnus-decode-encoded-word-methods-cache
1314 (eq gnus-newsgroup-name
1315 (car gnus-decode-encoded-word-methods-cache)))
1316 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1319 (nconc gnus-decode-encoded-word-methods-cache (list x))
1320 (if (and gnus-newsgroup-name
1321 (string-match (car x) gnus-newsgroup-name))
1322 (nconc gnus-decode-encoded-word-methods-cache
1324 gnus-decode-encoded-word-methods))
1325 (let ((xlist gnus-decode-encoded-word-methods-cache))
1328 (setq string (funcall (pop xlist) string))))
1331 ;; Subject simplification.
1333 (defun gnus-simplify-whitespace (str)
1334 "Remove excessive whitespace from STR."
1337 (while (string-match "[ \t][ \t]+" mystr)
1338 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1340 (substring mystr (match-end 0)))))
1342 (when (string-match "^[ \t]+" mystr)
1343 (setq mystr (substring mystr (match-end 0))))
1345 (when (string-match "[ \t]+$" mystr)
1346 (setq mystr (substring mystr 0 (match-beginning 0))))
1349 (defsubst gnus-simplify-subject-re (subject)
1350 "Remove \"Re:\" from subject lines."
1351 (if (string-match message-subject-re-regexp subject)
1352 (substring subject (match-end 0))
1355 (defun gnus-simplify-subject (subject &optional re-only)
1356 "Remove `Re:' and words in parentheses.
1357 If RE-ONLY is non-nil, strip leading `Re:'s only."
1358 (let ((case-fold-search t)) ;Ignore case.
1359 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1360 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1361 (setq subject (substring subject (match-end 0))))
1362 ;; Remove uninteresting prefixes.
1363 (when (and (not re-only)
1364 gnus-simplify-ignored-prefixes
1365 (string-match gnus-simplify-ignored-prefixes subject))
1366 (setq subject (substring subject (match-end 0))))
1367 ;; Remove words in parentheses from end.
1369 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1370 (setq subject (substring subject 0 (match-beginning 0)))))
1371 ;; Return subject string.
1374 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1376 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1377 (goto-char (point-min))
1378 (while (re-search-forward regexp nil t)
1379 (replace-match (or newtext ""))))
1381 (defun gnus-simplify-buffer-fuzzy ()
1382 "Simplify string in the buffer fuzzily.
1383 The string in the accessible portion of the current buffer is simplified.
1384 It is assumed to be a single-line subject.
1385 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1386 matter is removed. Additional things can be deleted by setting
1387 `gnus-simplify-subject-fuzzy-regexp'."
1388 (let ((case-fold-search t)
1390 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1392 (while (not (eq modified-tick (buffer-modified-tick)))
1393 (setq modified-tick (buffer-modified-tick))
1395 ((listp gnus-simplify-subject-fuzzy-regexp)
1396 (mapcar 'gnus-simplify-buffer-fuzzy-step
1397 gnus-simplify-subject-fuzzy-regexp))
1398 (gnus-simplify-subject-fuzzy-regexp
1399 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1400 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1401 (gnus-simplify-buffer-fuzzy-step
1402 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1403 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1405 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1406 (gnus-simplify-buffer-fuzzy-step " +" " ")
1407 (gnus-simplify-buffer-fuzzy-step " $")
1408 (gnus-simplify-buffer-fuzzy-step "^ +")))
1410 (defun gnus-simplify-subject-fuzzy (subject)
1411 "Simplify a subject string fuzzily.
1412 See `gnus-simplify-buffer-fuzzy' for details."
1414 (gnus-set-work-buffer)
1415 (let ((case-fold-search t))
1416 ;; Remove uninteresting prefixes.
1417 (when (and gnus-simplify-ignored-prefixes
1418 (string-match gnus-simplify-ignored-prefixes subject))
1419 (setq subject (substring subject (match-end 0))))
1421 (inline (gnus-simplify-buffer-fuzzy))
1424 (defsubst gnus-simplify-subject-fully (subject)
1425 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1427 (gnus-simplify-subject-functions
1428 (gnus-map-function gnus-simplify-subject-functions subject))
1429 ((null gnus-summary-gather-subject-limit)
1430 (gnus-simplify-subject-re subject))
1431 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1432 (gnus-simplify-subject-fuzzy subject))
1433 ((numberp gnus-summary-gather-subject-limit)
1434 (gnus-limit-string (gnus-simplify-subject-re subject)
1435 gnus-summary-gather-subject-limit))
1439 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1440 "Check whether two subjects are equal.
1441 If optional argument simple-first is t, first argument is already
1444 ((null simple-first)
1445 (equal (gnus-simplify-subject-fully s1)
1446 (gnus-simplify-subject-fully s2)))
1449 (gnus-simplify-subject-fully s2)))))
1451 (defun gnus-summary-bubble-group ()
1452 "Increase the score of the current group.
1453 This is a handy function to add to `gnus-summary-exit-hook' to
1454 increase the score of each group you read."
1455 (gnus-group-add-score gnus-newsgroup-name))
1459 ;;; Gnus summary mode
1462 (put 'gnus-summary-mode 'mode-class 'special)
1464 (defvar gnus-article-commands-menu)
1467 ;; Non-orthogonal keys
1469 (gnus-define-keys gnus-summary-mode-map
1470 " " gnus-summary-next-page
1471 "\177" gnus-summary-prev-page
1472 [delete] gnus-summary-prev-page
1473 [backspace] gnus-summary-prev-page
1474 "\r" gnus-summary-scroll-up
1475 "\M-\r" gnus-summary-scroll-down
1476 "n" gnus-summary-next-unread-article
1477 "p" gnus-summary-prev-unread-article
1478 "N" gnus-summary-next-article
1479 "P" gnus-summary-prev-article
1480 "\M-\C-n" gnus-summary-next-same-subject
1481 "\M-\C-p" gnus-summary-prev-same-subject
1482 "\M-n" gnus-summary-next-unread-subject
1483 "\M-p" gnus-summary-prev-unread-subject
1484 "." gnus-summary-first-unread-article
1485 "," gnus-summary-best-unread-article
1486 "\M-s" gnus-summary-search-article-forward
1487 "\M-r" gnus-summary-search-article-backward
1488 "<" gnus-summary-beginning-of-article
1489 ">" gnus-summary-end-of-article
1490 "j" gnus-summary-goto-article
1491 "^" gnus-summary-refer-parent-article
1492 "\M-^" gnus-summary-refer-article
1493 "u" gnus-summary-tick-article-forward
1494 "!" gnus-summary-tick-article-forward
1495 "U" gnus-summary-tick-article-backward
1496 "d" gnus-summary-mark-as-read-forward
1497 "D" gnus-summary-mark-as-read-backward
1498 "E" gnus-summary-mark-as-expirable
1499 "\M-u" gnus-summary-clear-mark-forward
1500 "\M-U" gnus-summary-clear-mark-backward
1501 "k" gnus-summary-kill-same-subject-and-select
1502 "\C-k" gnus-summary-kill-same-subject
1503 "\M-\C-k" gnus-summary-kill-thread
1504 "\M-\C-l" gnus-summary-lower-thread
1505 "e" gnus-summary-edit-article
1506 "#" gnus-summary-mark-as-processable
1507 "\M-#" gnus-summary-unmark-as-processable
1508 "\M-\C-t" gnus-summary-toggle-threads
1509 "\M-\C-s" gnus-summary-show-thread
1510 "\M-\C-h" gnus-summary-hide-thread
1511 "\M-\C-f" gnus-summary-next-thread
1512 "\M-\C-b" gnus-summary-prev-thread
1513 [(meta down)] gnus-summary-next-thread
1514 [(meta up)] gnus-summary-prev-thread
1515 "\M-\C-u" gnus-summary-up-thread
1516 "\M-\C-d" gnus-summary-down-thread
1517 "&" gnus-summary-execute-command
1518 "c" gnus-summary-catchup-and-exit
1519 "\C-w" gnus-summary-mark-region-as-read
1520 "\C-t" gnus-summary-toggle-truncation
1521 "?" gnus-summary-mark-as-dormant
1522 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1523 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1524 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1525 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1526 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1527 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1528 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1529 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1530 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1531 "=" gnus-summary-expand-window
1532 "\C-x\C-s" gnus-summary-reselect-current-group
1533 "\M-g" gnus-summary-rescan-group
1534 "w" gnus-summary-stop-page-breaking
1535 "\C-c\C-r" gnus-summary-caesar-message
1536 "f" gnus-summary-followup
1537 "F" gnus-summary-followup-with-original
1538 "C" gnus-summary-cancel-article
1539 "r" gnus-summary-reply
1540 "R" gnus-summary-reply-with-original
1541 "\C-c\C-f" gnus-summary-mail-forward
1542 "o" gnus-summary-save-article
1543 "\C-o" gnus-summary-save-article-mail
1544 "|" gnus-summary-pipe-output
1545 "\M-k" gnus-summary-edit-local-kill
1546 "\M-K" gnus-summary-edit-global-kill
1548 "\C-c\C-d" gnus-summary-describe-group
1549 "q" gnus-summary-exit
1550 "Q" gnus-summary-exit-no-update
1551 "\C-c\C-i" gnus-info-find-node
1552 gnus-mouse-2 gnus-mouse-pick-article
1553 "m" gnus-summary-mail-other-window
1554 "a" gnus-summary-post-news
1555 "i" gnus-summary-news-other-window
1556 "x" gnus-summary-limit-to-unread
1557 "s" gnus-summary-isearch-article
1558 "t" gnus-summary-toggle-header
1559 "g" gnus-summary-show-article
1560 "l" gnus-summary-goto-last-article
1561 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1562 "\C-d" gnus-summary-enter-digest-group
1563 "\M-\C-d" gnus-summary-read-document
1564 "\M-\C-e" gnus-summary-edit-parameters
1565 "\M-\C-a" gnus-summary-customize-parameters
1567 "*" gnus-cache-enter-article
1568 "\M-*" gnus-cache-remove-article
1569 "\M-&" gnus-summary-universal-argument
1570 "\C-l" gnus-recenter
1571 "I" gnus-summary-increase-score
1572 "L" gnus-summary-lower-score
1573 "\M-i" gnus-symbolic-argument
1574 "h" gnus-summary-select-article-buffer
1576 "b" gnus-article-view-part
1577 "\M-t" gnus-summary-toggle-display-buttonized
1579 "V" gnus-summary-score-map
1580 "X" gnus-uu-extract-map
1581 "S" gnus-summary-send-map)
1583 ;; Sort of orthogonal keymap
1584 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1585 "t" gnus-summary-tick-article-forward
1586 "!" gnus-summary-tick-article-forward
1587 "d" gnus-summary-mark-as-read-forward
1588 "r" gnus-summary-mark-as-read-forward
1589 "c" gnus-summary-clear-mark-forward
1590 " " gnus-summary-clear-mark-forward
1591 "e" gnus-summary-mark-as-expirable
1592 "x" gnus-summary-mark-as-expirable
1593 "?" gnus-summary-mark-as-dormant
1594 "b" gnus-summary-set-bookmark
1595 "B" gnus-summary-remove-bookmark
1596 "#" gnus-summary-mark-as-processable
1597 "\M-#" gnus-summary-unmark-as-processable
1598 "S" gnus-summary-limit-include-expunged
1599 "C" gnus-summary-catchup
1600 "H" gnus-summary-catchup-to-here
1601 "h" gnus-summary-catchup-from-here
1602 "\C-c" gnus-summary-catchup-all
1603 "k" gnus-summary-kill-same-subject-and-select
1604 "K" gnus-summary-kill-same-subject
1605 "P" gnus-uu-mark-map)
1607 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1608 "c" gnus-summary-clear-above
1609 "u" gnus-summary-tick-above
1610 "m" gnus-summary-mark-above
1611 "k" gnus-summary-kill-below)
1613 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1614 "/" gnus-summary-limit-to-subject
1615 "n" gnus-summary-limit-to-articles
1616 "w" gnus-summary-pop-limit
1617 "s" gnus-summary-limit-to-subject
1618 "a" gnus-summary-limit-to-author
1619 "u" gnus-summary-limit-to-unread
1620 "m" gnus-summary-limit-to-marks
1621 "M" gnus-summary-limit-exclude-marks
1622 "v" gnus-summary-limit-to-score
1623 "*" gnus-summary-limit-include-cached
1624 "D" gnus-summary-limit-include-dormant
1625 "T" gnus-summary-limit-include-thread
1626 "d" gnus-summary-limit-exclude-dormant
1627 "t" gnus-summary-limit-to-age
1628 "x" gnus-summary-limit-to-extra
1629 "p" gnus-summary-limit-to-display-predicate
1630 "E" gnus-summary-limit-include-expunged
1631 "c" gnus-summary-limit-exclude-childless-dormant
1632 "C" gnus-summary-limit-mark-excluded-as-read
1633 "o" gnus-summary-insert-old-articles
1634 "N" gnus-summary-insert-new-articles)
1636 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1637 "n" gnus-summary-next-unread-article
1638 "p" gnus-summary-prev-unread-article
1639 "N" gnus-summary-next-article
1640 "P" gnus-summary-prev-article
1641 "\C-n" gnus-summary-next-same-subject
1642 "\C-p" gnus-summary-prev-same-subject
1643 "\M-n" gnus-summary-next-unread-subject
1644 "\M-p" gnus-summary-prev-unread-subject
1645 "f" gnus-summary-first-unread-article
1646 "b" gnus-summary-best-unread-article
1647 "j" gnus-summary-goto-article
1648 "g" gnus-summary-goto-subject
1649 "l" gnus-summary-goto-last-article
1650 "o" gnus-summary-pop-article)
1652 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1653 "k" gnus-summary-kill-thread
1654 "l" gnus-summary-lower-thread
1655 "i" gnus-summary-raise-thread
1656 "T" gnus-summary-toggle-threads
1657 "t" gnus-summary-rethread-current
1658 "^" gnus-summary-reparent-thread
1659 "s" gnus-summary-show-thread
1660 "S" gnus-summary-show-all-threads
1661 "h" gnus-summary-hide-thread
1662 "H" gnus-summary-hide-all-threads
1663 "n" gnus-summary-next-thread
1664 "p" gnus-summary-prev-thread
1665 "u" gnus-summary-up-thread
1666 "o" gnus-summary-top-thread
1667 "d" gnus-summary-down-thread
1668 "#" gnus-uu-mark-thread
1669 "\M-#" gnus-uu-unmark-thread)
1671 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1672 "g" gnus-summary-prepare
1673 "c" gnus-summary-insert-cached-articles)
1675 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1676 "c" gnus-summary-catchup-and-exit
1677 "C" gnus-summary-catchup-all-and-exit
1678 "E" gnus-summary-exit-no-update
1679 "Q" gnus-summary-exit
1680 "Z" gnus-summary-exit
1681 "n" gnus-summary-catchup-and-goto-next-group
1682 "R" gnus-summary-reselect-current-group
1683 "G" gnus-summary-rescan-group
1684 "N" gnus-summary-next-group
1685 "s" gnus-summary-save-newsrc
1686 "P" gnus-summary-prev-group)
1688 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1689 " " gnus-summary-next-page
1690 "n" gnus-summary-next-page
1691 "\177" gnus-summary-prev-page
1692 [delete] gnus-summary-prev-page
1693 "p" gnus-summary-prev-page
1694 "\r" gnus-summary-scroll-up
1695 "\M-\r" gnus-summary-scroll-down
1696 "<" gnus-summary-beginning-of-article
1697 ">" gnus-summary-end-of-article
1698 "b" gnus-summary-beginning-of-article
1699 "e" gnus-summary-end-of-article
1700 "^" gnus-summary-refer-parent-article
1701 "r" gnus-summary-refer-parent-article
1702 "D" gnus-summary-enter-digest-group
1703 "R" gnus-summary-refer-references
1704 "T" gnus-summary-refer-thread
1705 "g" gnus-summary-show-article
1706 "s" gnus-summary-isearch-article
1707 "P" gnus-summary-print-article
1708 "M" gnus-mailing-list-insinuate
1709 "t" gnus-article-babel)
1711 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1712 "b" gnus-article-add-buttons
1713 "B" gnus-article-add-buttons-to-head
1714 "o" gnus-article-treat-overstrike
1715 "e" gnus-article-emphasize
1716 "w" gnus-article-fill-cited-article
1717 "Q" gnus-article-fill-long-lines
1718 "C" gnus-article-capitalize-sentences
1719 "c" gnus-article-remove-cr
1720 "q" gnus-article-de-quoted-unreadable
1721 "6" gnus-article-de-base64-unreadable
1722 "Z" gnus-article-decode-HZ
1723 "h" gnus-article-wash-html
1724 "s" gnus-summary-force-verify-and-decrypt
1725 "f" gnus-article-display-x-face
1726 "l" gnus-summary-stop-page-breaking
1727 "r" gnus-summary-caesar-message
1728 "t" gnus-summary-toggle-header
1729 "g" gnus-treat-smiley
1730 "v" gnus-summary-verbose-headers
1731 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1732 "p" gnus-article-verify-x-pgp-sig
1733 "d" gnus-article-treat-dumbquotes)
1735 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1736 "a" gnus-article-hide
1737 "h" gnus-article-hide-headers
1738 "b" gnus-article-hide-boring-headers
1739 "s" gnus-article-hide-signature
1740 "c" gnus-article-hide-citation
1741 "C" gnus-article-hide-citation-in-followups
1742 "l" gnus-article-hide-list-identifiers
1743 "p" gnus-article-hide-pgp
1744 "B" gnus-article-strip-banner
1745 "P" gnus-article-hide-pem
1746 "\C-c" gnus-article-hide-citation-maybe)
1748 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1749 "a" gnus-article-highlight
1750 "h" gnus-article-highlight-headers
1751 "c" gnus-article-highlight-citation
1752 "s" gnus-article-highlight-signature)
1754 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1755 "f" gnus-article-treat-fold-headers
1756 "u" gnus-article-treat-unfold-headers
1757 "n" gnus-article-treat-fold-newsgroups)
1759 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1760 "x" gnus-article-display-x-face
1761 "s" gnus-treat-smiley
1762 "D" gnus-article-remove-images
1763 "f" gnus-treat-from-picon
1764 "m" gnus-treat-mail-picon
1765 "n" gnus-treat-newsgroups-picon)
1767 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1768 "w" gnus-article-decode-mime-words
1769 "c" gnus-article-decode-charset
1770 "v" gnus-mime-view-all-parts
1771 "b" gnus-article-view-part)
1773 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1774 "z" gnus-article-date-ut
1775 "u" gnus-article-date-ut
1776 "l" gnus-article-date-local
1777 "p" gnus-article-date-english
1778 "e" gnus-article-date-lapsed
1779 "o" gnus-article-date-original
1780 "i" gnus-article-date-iso8601
1781 "s" gnus-article-date-user)
1783 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1784 "t" gnus-article-remove-trailing-blank-lines
1785 "l" gnus-article-strip-leading-blank-lines
1786 "m" gnus-article-strip-multiple-blank-lines
1787 "a" gnus-article-strip-blank-lines
1788 "A" gnus-article-strip-all-blank-lines
1789 "s" gnus-article-strip-leading-space
1790 "e" gnus-article-strip-trailing-space
1791 "w" gnus-article-remove-leading-whitespace)
1793 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1795 "f" gnus-summary-fetch-faq
1796 "d" gnus-summary-describe-group
1797 "h" gnus-summary-describe-briefly
1798 "i" gnus-info-find-node)
1800 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1801 "e" gnus-summary-expire-articles
1802 "\M-\C-e" gnus-summary-expire-articles-now
1803 "\177" gnus-summary-delete-article
1804 [delete] gnus-summary-delete-article
1805 [backspace] gnus-summary-delete-article
1806 "m" gnus-summary-move-article
1807 "r" gnus-summary-respool-article
1808 "w" gnus-summary-edit-article
1809 "c" gnus-summary-copy-article
1810 "B" gnus-summary-crosspost-article
1811 "q" gnus-summary-respool-query
1812 "t" gnus-summary-respool-trace
1813 "i" gnus-summary-import-article
1814 "I" gnus-summary-create-article
1815 "p" gnus-summary-article-posted-p)
1817 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1818 "o" gnus-summary-save-article
1819 "m" gnus-summary-save-article-mail
1820 "F" gnus-summary-write-article-file
1821 "r" gnus-summary-save-article-rmail
1822 "f" gnus-summary-save-article-file
1823 "b" gnus-summary-save-article-body-file
1824 "h" gnus-summary-save-article-folder
1825 "v" gnus-summary-save-article-vm
1826 "p" gnus-summary-pipe-output
1827 "P" gnus-summary-muttprint
1828 "s" gnus-soup-add-article)
1830 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1831 "b" gnus-summary-display-buttonized
1832 "m" gnus-summary-repair-multipart
1833 "v" gnus-article-view-part
1834 "o" gnus-article-save-part
1835 "c" gnus-article-copy-part
1836 "C" gnus-article-view-part-as-charset
1837 "e" gnus-article-externalize-part
1838 "E" gnus-article-encrypt-body
1839 "i" gnus-article-inline-part
1840 "|" gnus-article-pipe-part))
1842 (defvar gnus-article-post-menu nil)
1844 (defun gnus-summary-make-menu-bar ()
1845 (gnus-turn-off-edit-menu 'summary)
1847 (unless (boundp 'gnus-summary-misc-menu)
1850 gnus-summary-kill-menu gnus-summary-mode-map ""
1855 ["Customize" gnus-score-customize t])
1856 (gnus-make-score-map 'increase)
1857 (gnus-make-score-map 'lower)
1859 ["Kill below" gnus-summary-kill-below t]
1860 ["Mark above" gnus-summary-mark-above t]
1861 ["Tick above" gnus-summary-tick-above t]
1862 ["Clear above" gnus-summary-clear-above t])
1863 ["Current score" gnus-summary-current-score t]
1864 ["Set score" gnus-summary-set-score t]
1865 ["Switch current score file..." gnus-score-change-score-file t]
1866 ["Set mark below..." gnus-score-set-mark-below t]
1867 ["Set expunge below..." gnus-score-set-expunge-below t]
1868 ["Edit current score file" gnus-score-edit-current-scores t]
1869 ["Edit score file" gnus-score-edit-file t]
1870 ["Trace score" gnus-score-find-trace t]
1871 ["Find words" gnus-score-find-favourite-words t]
1872 ["Rescore buffer" gnus-summary-rescore t]
1873 ["Increase score..." gnus-summary-increase-score t]
1874 ["Lower score..." gnus-summary-lower-score t]))))
1876 ;; Define both the Article menu in the summary buffer and the
1877 ;; equivalent Commands menu in the article buffer here for
1881 ["All" gnus-article-hide t]
1882 ["Headers" gnus-article-hide-headers t]
1883 ["Signature" gnus-article-hide-signature t]
1884 ["Citation" gnus-article-hide-citation t]
1885 ["List identifiers" gnus-article-hide-list-identifiers t]
1886 ["PGP" gnus-article-hide-pgp t]
1887 ["Banner" gnus-article-strip-banner t]
1888 ["Boring headers" gnus-article-hide-boring-headers t])
1890 ["All" gnus-article-highlight t]
1891 ["Headers" gnus-article-highlight-headers t]
1892 ["Signature" gnus-article-highlight-signature t]
1893 ["Citation" gnus-article-highlight-citation t])
1895 ["Words" gnus-article-decode-mime-words t]
1896 ["Charset" gnus-article-decode-charset t]
1897 ["QP" gnus-article-de-quoted-unreadable t]
1898 ["Base64" gnus-article-de-base64-unreadable t]
1899 ["View all" gnus-mime-view-all-parts t]
1900 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1901 ["Encrypt body" gnus-article-encrypt-body t])
1903 ["Local" gnus-article-date-local t]
1904 ["ISO8601" gnus-article-date-iso8601 t]
1905 ["UT" gnus-article-date-ut t]
1906 ["Original" gnus-article-date-original t]
1907 ["Lapsed" gnus-article-date-lapsed t]
1908 ["User-defined" gnus-article-date-user t])
1910 ["Remove images" gnus-article-remove-images t]
1911 ["Toggle smiley" gnus-treat-smiley t]
1912 ["Show X-Face" gnus-article-display-x-face t]
1913 ["Show picons in From" gnus-treat-from-picon t]
1914 ["Show picons in mail headers" gnus-treat-mail-picon t]
1915 ["Show picons in news headers" gnus-treat-newsgroups-picon t])
1918 ["Leading" gnus-article-strip-leading-blank-lines t]
1919 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1920 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1921 ["All of the above" gnus-article-strip-blank-lines t]
1922 ["All" gnus-article-strip-all-blank-lines t]
1923 ["Leading space" gnus-article-strip-leading-space t]
1924 ["Trailing space" gnus-article-strip-trailing-space t]
1925 ["Leading space in headers"
1926 gnus-article-remove-leading-whitespace t])
1927 ["Overstrike" gnus-article-treat-overstrike t]
1928 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1929 ["Emphasis" gnus-article-emphasize t]
1930 ["Word wrap" gnus-article-fill-cited-article t]
1931 ["Fill long lines" gnus-article-fill-long-lines t]
1932 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1933 ["CR" gnus-article-remove-cr t]
1934 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1935 ["Base64" gnus-article-de-base64-unreadable t]
1936 ["Rot 13" gnus-summary-caesar-message
1937 ,@(if (featurep 'xemacs) '(t)
1938 '(:help "\"Caesar rotate\" article by 13"))]
1939 ["Unix pipe" gnus-summary-pipe-message t]
1940 ["Add buttons" gnus-article-add-buttons t]
1941 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1942 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1943 ["Verbose header" gnus-summary-verbose-headers t]
1944 ["Toggle header" gnus-summary-toggle-header t]
1945 ["Unfold headers" gnus-article-treat-unfold-headers t]
1946 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
1947 ["Html" gnus-article-wash-html t]
1948 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1949 ["HZ" gnus-article-decode-HZ t])
1951 ["Save in default format" gnus-summary-save-article
1952 ,@(if (featurep 'xemacs) '(t)
1953 '(:help "Save article using default method"))]
1954 ["Save in file" gnus-summary-save-article-file
1955 ,@(if (featurep 'xemacs) '(t)
1956 '(:help "Save article in file"))]
1957 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1958 ["Save in MH folder" gnus-summary-save-article-folder t]
1959 ["Save in VM folder" gnus-summary-save-article-vm t]
1960 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1961 ["Save body in file" gnus-summary-save-article-body-file t]
1962 ["Pipe through a filter" gnus-summary-pipe-output t]
1963 ["Add to SOUP packet" gnus-soup-add-article t]
1964 ["Print with Muttprint" gnus-summary-muttprint t]
1965 ["Print" gnus-summary-print-article t])
1967 ["Respool article..." gnus-summary-respool-article t]
1968 ["Move article..." gnus-summary-move-article
1969 (gnus-check-backend-function
1970 'request-move-article gnus-newsgroup-name)]
1971 ["Copy article..." gnus-summary-copy-article t]
1972 ["Crosspost article..." gnus-summary-crosspost-article
1973 (gnus-check-backend-function
1974 'request-replace-article gnus-newsgroup-name)]
1975 ["Import file..." gnus-summary-import-article t]
1976 ["Create article..." gnus-summary-create-article t]
1977 ["Check if posted" gnus-summary-article-posted-p t]
1978 ["Edit article" gnus-summary-edit-article
1979 (not (gnus-group-read-only-p))]
1980 ["Delete article" gnus-summary-delete-article
1981 (gnus-check-backend-function
1982 'request-expire-articles gnus-newsgroup-name)]
1983 ["Query respool" gnus-summary-respool-query t]
1984 ["Trace respool" gnus-summary-respool-trace t]
1985 ["Delete expirable articles" gnus-summary-expire-articles-now
1986 (gnus-check-backend-function
1987 'request-expire-articles gnus-newsgroup-name)])
1989 ["Uudecode" gnus-uu-decode-uu
1990 ,@(if (featurep 'xemacs) '(t)
1991 '(:help "Decode uuencoded article(s)"))]
1992 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1993 ["Unshar" gnus-uu-decode-unshar t]
1994 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1995 ["Save" gnus-uu-decode-save t]
1996 ["Binhex" gnus-uu-decode-binhex t]
1997 ["Postscript" gnus-uu-decode-postscript t])
1999 ["Enter article" gnus-cache-enter-article t]
2000 ["Remove article" gnus-cache-remove-article t])
2001 ["Translate" gnus-article-babel t]
2002 ["Select article buffer" gnus-summary-select-article-buffer t]
2003 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2004 ["Isearch article..." gnus-summary-isearch-article t]
2005 ["Beginning of the article" gnus-summary-beginning-of-article t]
2006 ["End of the article" gnus-summary-end-of-article t]
2007 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2008 ["Fetch referenced articles" gnus-summary-refer-references t]
2009 ["Fetch current thread" gnus-summary-refer-thread t]
2010 ["Fetch article with id..." gnus-summary-refer-article t]
2011 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2012 ["Redisplay" gnus-summary-show-article t]
2013 ["Raw article" gnus-summary-show-raw-article t])))
2015 gnus-summary-article-menu gnus-summary-mode-map ""
2016 (cons "Article" innards))
2018 (if (not (keymapp gnus-summary-article-menu))
2020 gnus-article-commands-menu gnus-article-mode-map ""
2021 (cons "Commands" innards))
2022 ;; in Emacs, don't share menu.
2023 (setq gnus-article-commands-menu
2024 (copy-keymap gnus-summary-article-menu))
2025 (define-key gnus-article-mode-map [menu-bar commands]
2026 (cons "Commands" gnus-article-commands-menu))))
2029 gnus-summary-thread-menu gnus-summary-mode-map ""
2031 ["Toggle threading" gnus-summary-toggle-threads t]
2032 ["Hide threads" gnus-summary-hide-all-threads t]
2033 ["Show threads" gnus-summary-show-all-threads t]
2034 ["Hide thread" gnus-summary-hide-thread t]
2035 ["Show thread" gnus-summary-show-thread t]
2036 ["Go to next thread" gnus-summary-next-thread t]
2037 ["Go to previous thread" gnus-summary-prev-thread t]
2038 ["Go down thread" gnus-summary-down-thread t]
2039 ["Go up thread" gnus-summary-up-thread t]
2040 ["Top of thread" gnus-summary-top-thread t]
2041 ["Mark thread as read" gnus-summary-kill-thread t]
2042 ["Lower thread score" gnus-summary-lower-thread t]
2043 ["Raise thread score" gnus-summary-raise-thread t]
2044 ["Rethread current" gnus-summary-rethread-current t]))
2047 gnus-summary-post-menu gnus-summary-mode-map ""
2049 ["Send a message (mail or news)" gnus-summary-post-news
2050 ,@(if (featurep 'xemacs) '(t)
2051 '(:help "Post an article"))]
2052 ["Followup" gnus-summary-followup
2053 ,@(if (featurep 'xemacs) '(t)
2054 '(:help "Post followup to this article"))]
2055 ["Followup and yank" gnus-summary-followup-with-original
2056 ,@(if (featurep 'xemacs) '(t)
2057 '(:help "Post followup to this article, quoting its contents"))]
2058 ["Supersede article" gnus-summary-supersede-article t]
2059 ["Cancel article" gnus-summary-cancel-article
2060 ,@(if (featurep 'xemacs) '(t)
2061 '(:help "Cancel an article you posted"))]
2062 ["Reply" gnus-summary-reply t]
2063 ["Reply and yank" gnus-summary-reply-with-original t]
2064 ["Wide reply" gnus-summary-wide-reply t]
2065 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2066 ,@(if (featurep 'xemacs) '(t)
2067 '(:help "Mail a reply, quoting this article"))]
2068 ["Mail forward" gnus-summary-mail-forward t]
2069 ["Post forward" gnus-summary-post-forward t]
2070 ["Digest and mail" gnus-uu-digest-mail-forward t]
2071 ["Digest and post" gnus-uu-digest-post-forward t]
2072 ["Resend message" gnus-summary-resend-message t]
2073 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2074 ["Send a mail" gnus-summary-mail-other-window t]
2075 ["Create a local message" gnus-summary-news-other-window t]
2076 ["Uuencode and post" gnus-uu-post-news
2077 ,@(if (featurep 'xemacs) '(t)
2078 '(:help "Post a uuencoded article"))]
2079 ["Followup via news" gnus-summary-followup-to-mail t]
2080 ["Followup via news and yank"
2081 gnus-summary-followup-to-mail-with-original t]
2083 ;;["Send" gnus-summary-send-draft t]
2084 ;;["Send bounced" gnus-resend-bounced-mail t])
2088 ((not (keymapp gnus-summary-post-menu))
2089 (setq gnus-article-post-menu gnus-summary-post-menu))
2090 ((not gnus-article-post-menu)
2091 ;; Don't share post menu.
2092 (setq gnus-article-post-menu
2093 (copy-keymap gnus-summary-post-menu))))
2094 (define-key gnus-article-mode-map [menu-bar post]
2095 (cons "Post" gnus-article-post-menu))
2098 gnus-summary-misc-menu gnus-summary-mode-map ""
2101 ["Mark as read" gnus-summary-mark-as-read-forward t]
2102 ["Mark same subject and select"
2103 gnus-summary-kill-same-subject-and-select t]
2104 ["Mark same subject" gnus-summary-kill-same-subject t]
2105 ["Catchup" gnus-summary-catchup
2106 ,@(if (featurep 'xemacs) '(t)
2107 '(:help "Mark unread articles in this group as read"))]
2108 ["Catchup all" gnus-summary-catchup-all t]
2109 ["Catchup to here" gnus-summary-catchup-to-here t]
2110 ["Catchup from here" gnus-summary-catchup-from-here t]
2111 ["Catchup region" gnus-summary-mark-region-as-read t]
2112 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2114 ["Tick" gnus-summary-tick-article-forward t]
2115 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2116 ["Remove marks" gnus-summary-clear-mark-forward t]
2117 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2118 ["Set bookmark" gnus-summary-set-bookmark t]
2119 ["Remove bookmark" gnus-summary-remove-bookmark t])
2121 ["Marks..." gnus-summary-limit-to-marks t]
2122 ["Subject..." gnus-summary-limit-to-subject t]
2123 ["Author..." gnus-summary-limit-to-author t]
2124 ["Age..." gnus-summary-limit-to-age t]
2125 ["Extra..." gnus-summary-limit-to-extra t]
2126 ["Score" gnus-summary-limit-to-score t]
2127 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2128 ["Unread" gnus-summary-limit-to-unread t]
2129 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2130 ["Articles" gnus-summary-limit-to-articles t]
2131 ["Pop limit" gnus-summary-pop-limit t]
2132 ["Show dormant" gnus-summary-limit-include-dormant t]
2133 ["Hide childless dormant"
2134 gnus-summary-limit-exclude-childless-dormant t]
2135 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2136 ["Hide marked" gnus-summary-limit-exclude-marks t]
2137 ["Show expunged" gnus-summary-limit-include-expunged t])
2139 ["Set mark" gnus-summary-mark-as-processable t]
2140 ["Remove mark" gnus-summary-unmark-as-processable t]
2141 ["Remove all marks" gnus-summary-unmark-all-processable t]
2142 ["Mark above" gnus-uu-mark-over t]
2143 ["Mark series" gnus-uu-mark-series t]
2144 ["Mark region" gnus-uu-mark-region t]
2145 ["Unmark region" gnus-uu-unmark-region t]
2146 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2147 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2148 ["Mark all" gnus-uu-mark-all t]
2149 ["Mark buffer" gnus-uu-mark-buffer t]
2150 ["Mark sparse" gnus-uu-mark-sparse t]
2151 ["Mark thread" gnus-uu-mark-thread t]
2152 ["Unmark thread" gnus-uu-unmark-thread t]
2153 ("Process Mark Sets"
2154 ["Kill" gnus-summary-kill-process-mark t]
2155 ["Yank" gnus-summary-yank-process-mark
2156 gnus-newsgroup-process-stack]
2157 ["Save" gnus-summary-save-process-mark t]))
2159 ["Page forward" gnus-summary-next-page
2160 ,@(if (featurep 'xemacs) '(t)
2161 '(:help "Show next page of article"))]
2162 ["Page backward" gnus-summary-prev-page
2163 ,@(if (featurep 'xemacs) '(t)
2164 '(:help "Show previous page of article"))]
2165 ["Line forward" gnus-summary-scroll-up t])
2167 ["Next unread article" gnus-summary-next-unread-article t]
2168 ["Previous unread article" gnus-summary-prev-unread-article t]
2169 ["Next article" gnus-summary-next-article t]
2170 ["Previous article" gnus-summary-prev-article t]
2171 ["Next unread subject" gnus-summary-next-unread-subject t]
2172 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2173 ["Next article same subject" gnus-summary-next-same-subject t]
2174 ["Previous article same subject" gnus-summary-prev-same-subject t]
2175 ["First unread article" gnus-summary-first-unread-article t]
2176 ["Best unread article" gnus-summary-best-unread-article t]
2177 ["Go to subject number..." gnus-summary-goto-subject t]
2178 ["Go to article number..." gnus-summary-goto-article t]
2179 ["Go to the last article" gnus-summary-goto-last-article t]
2180 ["Pop article off history" gnus-summary-pop-article t])
2182 ["Sort by number" gnus-summary-sort-by-number t]
2183 ["Sort by author" gnus-summary-sort-by-author t]
2184 ["Sort by subject" gnus-summary-sort-by-subject t]
2185 ["Sort by date" gnus-summary-sort-by-date t]
2186 ["Sort by score" gnus-summary-sort-by-score t]
2187 ["Sort by lines" gnus-summary-sort-by-lines t]
2188 ["Sort by characters" gnus-summary-sort-by-chars t]
2189 ["Original sort" gnus-summary-sort-by-original t])
2191 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2192 ["Describe group" gnus-summary-describe-group t]
2193 ["Read manual" gnus-info-find-node t])
2195 ["Pick and read" gnus-pick-mode t]
2196 ["Binary" gnus-binary-mode t])
2198 ["Regenerate" gnus-summary-prepare t]
2199 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2200 ["Toggle threading" gnus-summary-toggle-threads t])
2201 ["See old articles" gnus-summary-insert-old-articles t]
2202 ["See new articles" gnus-summary-insert-new-articles t]
2203 ["Filter articles..." gnus-summary-execute-command t]
2204 ["Run command on subjects..." gnus-summary-universal-argument t]
2205 ["Search articles forward..." gnus-summary-search-article-forward t]
2206 ["Search articles backward..." gnus-summary-search-article-backward t]
2207 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2208 ["Expand window" gnus-summary-expand-window t]
2209 ["Expire expirable articles" gnus-summary-expire-articles
2210 (gnus-check-backend-function
2211 'request-expire-articles gnus-newsgroup-name)]
2212 ["Edit local kill file" gnus-summary-edit-local-kill t]
2213 ["Edit main kill file" gnus-summary-edit-global-kill t]
2214 ["Edit group parameters" gnus-summary-edit-parameters t]
2215 ["Customize group parameters" gnus-summary-customize-parameters t]
2216 ["Send a bug report" gnus-bug t]
2218 ["Catchup and exit" gnus-summary-catchup-and-exit
2219 ,@(if (featurep 'xemacs) '(t)
2220 '(:help "Mark unread articles in this group as read, then exit"))]
2221 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2222 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2223 ["Exit group" gnus-summary-exit
2224 ,@(if (featurep 'xemacs) '(t)
2225 '(:help "Exit current group, return to group selection mode"))]
2226 ["Exit group without updating" gnus-summary-exit-no-update t]
2227 ["Exit and goto next group" gnus-summary-next-group t]
2228 ["Exit and goto prev group" gnus-summary-prev-group t]
2229 ["Reselect group" gnus-summary-reselect-current-group t]
2230 ["Rescan group" gnus-summary-rescan-group t]
2231 ["Update dribble" gnus-summary-save-newsrc t])))
2233 (gnus-run-hooks 'gnus-summary-menu-hook)))
2235 (defvar gnus-summary-tool-bar-map nil)
2237 ;; Emacs 21 tool bar. Should be no-op otherwise.
2238 (defun gnus-summary-make-tool-bar ()
2239 (if (and (fboundp 'tool-bar-add-item-from-menu)
2240 (default-value 'tool-bar-mode)
2241 (not gnus-summary-tool-bar-map))
2242 (setq gnus-summary-tool-bar-map
2243 (let ((tool-bar-map (make-sparse-keymap))
2244 (load-path (mm-image-load-path)))
2245 (tool-bar-add-item-from-menu
2246 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2247 (tool-bar-add-item-from-menu
2248 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2249 (tool-bar-add-item-from-menu
2250 'gnus-summary-post-news "post" gnus-summary-mode-map)
2251 (tool-bar-add-item-from-menu
2252 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2253 (tool-bar-add-item-from-menu
2254 'gnus-summary-followup "followup" gnus-summary-mode-map)
2255 (tool-bar-add-item-from-menu
2256 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2257 (tool-bar-add-item-from-menu
2258 'gnus-summary-reply "reply" gnus-summary-mode-map)
2259 (tool-bar-add-item-from-menu
2260 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2261 (tool-bar-add-item-from-menu
2262 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2263 (tool-bar-add-item-from-menu
2264 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2265 (tool-bar-add-item-from-menu
2266 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2267 (tool-bar-add-item-from-menu
2268 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2269 (tool-bar-add-item-from-menu
2270 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2271 (tool-bar-add-item-from-menu
2272 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2273 (tool-bar-add-item-from-menu
2274 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2276 (if gnus-summary-tool-bar-map
2277 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2279 (defun gnus-score-set-default (var value)
2280 "A version of set that updates the GNU Emacs menu-bar."
2282 ;; It is the message that forces the active status to be updated.
2285 (defun gnus-make-score-map (type)
2286 "Make a summary score map of type TYPE."
2289 (let ((headers '(("author" "from" string)
2290 ("subject" "subject" string)
2291 ("article body" "body" string)
2292 ("article head" "head" string)
2293 ("xref" "xref" string)
2294 ("extra header" "extra" string)
2295 ("lines" "lines" number)
2296 ("followups to author" "followup" string)))
2297 (types '((number ("less than" <)
2300 (string ("substring" s)
2304 (perms '(("temporary" (current-time-string))
2312 (if (eq type 'lower)
2317 (setq header (car headers))
2323 (let ((ts (cdr (assoc (nth 2 header) types)))
2339 'gnus-summary-score-entry
2341 (if (or (string= (nth 1 header)
2343 (string= (nth 1 header)
2346 (list 'gnus-summary-header
2348 (list 'quote (nth 1 (car ts)))
2349 (list 'gnus-score-delta-default
2356 (list (nreverse outp))))
2359 (list (nreverse outt))))
2361 (setq headers (cdr headers)))
2362 (list (nreverse outh))))))))
2366 (defun gnus-summary-mode (&optional group)
2367 "Major mode for reading articles.
2369 All normal editing commands are switched off.
2370 \\<gnus-summary-mode-map>
2371 Each line in this buffer represents one article. To read an
2372 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2373 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2376 You can also post articles and send mail from this buffer. To
2377 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2378 of an article, type `\\[gnus-summary-reply]'.
2380 There are approx. one gazillion commands you can execute in this
2381 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2383 The following commands are available:
2385 \\{gnus-summary-mode-map}"
2387 (kill-all-local-variables)
2388 (when (gnus-visual-p 'summary-menu 'menu)
2389 (gnus-summary-make-menu-bar)
2390 (gnus-summary-make-tool-bar))
2391 (gnus-summary-make-local-variables)
2392 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2393 (gnus-summary-make-local-variables))
2394 (gnus-make-thread-indent-array)
2395 (gnus-simplify-mode-line)
2396 (setq major-mode 'gnus-summary-mode)
2397 (setq mode-name "Summary")
2398 (make-local-variable 'minor-mode-alist)
2399 (use-local-map gnus-summary-mode-map)
2400 (buffer-disable-undo)
2401 (setq buffer-read-only t) ;Disable modification
2402 (setq truncate-lines t)
2403 (setq selective-display t)
2404 (setq selective-display-ellipses t) ;Display `...'
2405 (gnus-summary-set-display-table)
2406 (gnus-set-default-directory)
2407 (setq gnus-newsgroup-name group)
2408 (make-local-variable 'gnus-summary-line-format)
2409 (make-local-variable 'gnus-summary-line-format-spec)
2410 (make-local-variable 'gnus-summary-dummy-line-format)
2411 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2412 (make-local-variable 'gnus-summary-mark-positions)
2413 (make-local-hook 'pre-command-hook)
2414 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2415 (gnus-run-hooks 'gnus-summary-mode-hook)
2416 (turn-on-gnus-mailing-list-mode)
2417 (mm-enable-multibyte-mule4)
2418 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2419 (gnus-update-summary-mark-positions))
2421 (defun gnus-summary-make-local-variables ()
2422 "Make all the local summary buffer variables."
2424 (dolist (local gnus-summary-local-variables)
2427 (if (eq (cdr local) 'global)
2428 ;; Copy the global value of the variable.
2429 (setq global (symbol-value (car local)))
2430 ;; Use the value from the list.
2431 (setq global (eval (cdr local))))
2432 (set (make-local-variable (car local)) global))
2433 ;; Simple nil-valued local variable.
2434 (set (make-local-variable local) nil)))))
2436 (defun gnus-summary-clear-local-variables ()
2437 (let ((locals gnus-summary-local-variables))
2439 (if (consp (car locals))
2440 (and (vectorp (caar locals))
2441 (set (caar locals) nil))
2442 (and (vectorp (car locals))
2443 (set (car locals) nil)))
2444 (setq locals (cdr locals)))))
2446 ;; Summary data functions.
2448 (defmacro gnus-data-number (data)
2451 (defmacro gnus-data-set-number (data number)
2452 `(setcar ,data ,number))
2454 (defmacro gnus-data-mark (data)
2457 (defmacro gnus-data-set-mark (data mark)
2458 `(setcar (nthcdr 1 ,data) ,mark))
2460 (defmacro gnus-data-pos (data)
2463 (defmacro gnus-data-set-pos (data pos)
2464 `(setcar (nthcdr 2 ,data) ,pos))
2466 (defmacro gnus-data-header (data)
2469 (defmacro gnus-data-set-header (data header)
2470 `(setf (nth 3 ,data) ,header))
2472 (defmacro gnus-data-level (data)
2475 (defmacro gnus-data-unread-p (data)
2476 `(= (nth 1 ,data) gnus-unread-mark))
2478 (defmacro gnus-data-read-p (data)
2479 `(/= (nth 1 ,data) gnus-unread-mark))
2481 (defmacro gnus-data-pseudo-p (data)
2482 `(consp (nth 3 ,data)))
2484 (defmacro gnus-data-find (number)
2485 `(assq ,number gnus-newsgroup-data))
2487 (defmacro gnus-data-find-list (number &optional data)
2488 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2489 (memq (assq ,number bdata)
2492 (defmacro gnus-data-make (number mark pos header level)
2493 `(list ,number ,mark ,pos ,header ,level))
2495 (defun gnus-data-enter (after-article number mark pos header level offset)
2496 (let ((data (gnus-data-find-list after-article)))
2498 (error "No such article: %d" after-article))
2499 (setcdr data (cons (gnus-data-make number mark pos header level)
2501 (setq gnus-newsgroup-data-reverse nil)
2502 (gnus-data-update-list (cddr data) offset)))
2504 (defun gnus-data-enter-list (after-article list &optional offset)
2506 (let ((data (and after-article (gnus-data-find-list after-article)))
2510 (let ((odata gnus-newsgroup-data))
2511 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2513 (gnus-data-update-list odata offset)))
2514 ;; Find the last element in the list to be spliced into the main
2517 (setq list (cdr list)))
2520 (setcdr list gnus-newsgroup-data)
2521 (setq gnus-newsgroup-data ilist)
2523 (gnus-data-update-list (cdr list) offset)))
2524 (setcdr list (cdr data))
2527 (gnus-data-update-list (cdr list) offset))))
2528 (setq gnus-newsgroup-data-reverse nil))))
2530 (defun gnus-data-remove (article &optional offset)
2531 (let ((data gnus-newsgroup-data))
2532 (if (= (gnus-data-number (car data)) article)
2534 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2535 gnus-newsgroup-data-reverse nil)
2537 (gnus-data-update-list gnus-newsgroup-data offset)))
2539 (when (= (gnus-data-number (cadr data)) article)
2540 (setcdr data (cddr data))
2542 (gnus-data-update-list (cdr data) offset))
2544 gnus-newsgroup-data-reverse nil))
2545 (setq data (cdr data))))))
2547 (defmacro gnus-data-list (backward)
2549 (or gnus-newsgroup-data-reverse
2550 (setq gnus-newsgroup-data-reverse
2551 (reverse gnus-newsgroup-data)))
2552 gnus-newsgroup-data))
2554 (defun gnus-data-update-list (data offset)
2555 "Add OFFSET to the POS of all data entries in DATA."
2556 (setq gnus-newsgroup-data-reverse nil)
2558 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2559 (setq data (cdr data))))
2561 (defun gnus-summary-article-pseudo-p (article)
2562 "Say whether this article is a pseudo article or not."
2563 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2565 (defmacro gnus-summary-article-sparse-p (article)
2566 "Say whether this article is a sparse article or not."
2567 `(memq ,article gnus-newsgroup-sparse))
2569 (defmacro gnus-summary-article-ancient-p (article)
2570 "Say whether this article is a sparse article or not."
2571 `(memq ,article gnus-newsgroup-ancient))
2573 (defun gnus-article-parent-p (number)
2574 "Say whether this article is a parent or not."
2575 (let ((data (gnus-data-find-list number)))
2576 (and (cdr data) ; There has to be an article after...
2577 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2578 (gnus-data-level (nth 1 data))))))
2580 (defun gnus-article-children (number)
2581 "Return a list of all children to NUMBER."
2582 (let* ((data (gnus-data-find-list number))
2583 (level (gnus-data-level (car data)))
2585 (setq data (cdr data))
2587 (= (gnus-data-level (car data)) (1+ level)))
2588 (push (gnus-data-number (car data)) children)
2589 (setq data (cdr data)))
2592 (defmacro gnus-summary-skip-intangible ()
2593 "If the current article is intangible, then jump to a different article."
2594 '(let ((to (get-text-property (point) 'gnus-intangible)))
2595 (and to (gnus-summary-goto-subject to))))
2597 (defmacro gnus-summary-article-intangible-p ()
2598 "Say whether this article is intangible or not."
2599 '(get-text-property (point) 'gnus-intangible))
2601 (defun gnus-article-read-p (article)
2602 "Say whether ARTICLE is read or not."
2603 (not (or (memq article gnus-newsgroup-marked)
2604 (memq article gnus-newsgroup-unreads)
2605 (memq article gnus-newsgroup-unselected)
2606 (memq article gnus-newsgroup-dormant))))
2608 ;; Some summary mode macros.
2610 (defmacro gnus-summary-article-number ()
2611 "The article number of the article on the current line.
2612 If there isn's an article number here, then we return the current
2615 (gnus-summary-skip-intangible)
2616 (or (get-text-property (point) 'gnus-number)
2617 (gnus-summary-last-subject))))
2619 (defmacro gnus-summary-article-header (&optional number)
2620 "Return the header of article NUMBER."
2621 `(gnus-data-header (gnus-data-find
2622 ,(or number '(gnus-summary-article-number)))))
2624 (defmacro gnus-summary-thread-level (&optional number)
2625 "Return the level of thread that starts with article NUMBER."
2626 `(if (and (eq gnus-summary-make-false-root 'dummy)
2627 (get-text-property (point) 'gnus-intangible))
2629 (gnus-data-level (gnus-data-find
2630 ,(or number '(gnus-summary-article-number))))))
2632 (defmacro gnus-summary-article-mark (&optional number)
2633 "Return the mark of article NUMBER."
2634 `(gnus-data-mark (gnus-data-find
2635 ,(or number '(gnus-summary-article-number)))))
2637 (defmacro gnus-summary-article-pos (&optional number)
2638 "Return the position of the line of article NUMBER."
2639 `(gnus-data-pos (gnus-data-find
2640 ,(or number '(gnus-summary-article-number)))))
2642 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2643 (defmacro gnus-summary-article-subject (&optional number)
2644 "Return current subject string or nil if nothing."
2647 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2648 '(gnus-data-header (assq (gnus-summary-article-number)
2649 gnus-newsgroup-data)))))
2652 (mail-header-subject headers))))
2654 (defmacro gnus-summary-article-score (&optional number)
2655 "Return current article score."
2656 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2657 gnus-newsgroup-scored))
2658 gnus-summary-default-score 0))
2660 (defun gnus-summary-article-children (&optional number)
2661 "Return a list of article numbers that are children of article NUMBER."
2662 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2663 (level (gnus-data-level (car data)))
2665 (while (and (setq data (cdr data))
2666 (> (setq l (gnus-data-level (car data))) level))
2667 (and (= (1+ level) l)
2668 (push (gnus-data-number (car data))
2670 (nreverse children)))
2672 (defun gnus-summary-article-parent (&optional number)
2673 "Return the article number of the parent of article NUMBER."
2674 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2675 (gnus-data-list t)))
2676 (level (gnus-data-level (car data))))
2678 () ; This is a root.
2679 ;; We search until we find an article with a level less than
2680 ;; this one. That function has to be the parent.
2681 (while (and (setq data (cdr data))
2682 (not (< (gnus-data-level (car data)) level))))
2683 (and data (gnus-data-number (car data))))))
2685 (defun gnus-unread-mark-p (mark)
2686 "Say whether MARK is the unread mark."
2687 (= mark gnus-unread-mark))
2689 (defun gnus-read-mark-p (mark)
2690 "Say whether MARK is one of the marks that mark as read.
2691 This is all marks except unread, ticked, dormant, and expirable."
2692 (not (or (= mark gnus-unread-mark)
2693 (= mark gnus-ticked-mark)
2694 (= mark gnus-dormant-mark)
2695 (= mark gnus-expirable-mark))))
2697 (defmacro gnus-article-mark (number)
2698 "Return the MARK of article NUMBER.
2699 This macro should only be used when computing the mark the \"first\"
2700 time; i.e., when generating the summary lines. After that,
2701 `gnus-summary-article-mark' should be used to examine the
2704 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2705 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2706 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2707 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2708 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2709 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2710 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2711 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2712 gnus-ancient-mark))))
2714 ;; Saving hidden threads.
2716 (defmacro gnus-save-hidden-threads (&rest forms)
2717 "Save hidden threads, eval FORMS, and restore the hidden threads."
2718 (let ((config (make-symbol "config")))
2719 `(let ((,config (gnus-hidden-threads-configuration)))
2723 (gnus-restore-hidden-threads-configuration ,config)))))
2724 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2725 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2727 (defun gnus-data-compute-positions ()
2728 "Compute the positions of all articles."
2729 (setq gnus-newsgroup-data-reverse nil)
2730 (let ((data gnus-newsgroup-data))
2732 (gnus-save-hidden-threads
2733 (gnus-summary-show-all-threads)
2734 (goto-char (point-min))
2736 (while (get-text-property (point) 'gnus-intangible)
2738 (gnus-data-set-pos (car data) (+ (point) 3))
2739 (setq data (cdr data))
2740 (forward-line 1))))))
2742 (defun gnus-hidden-threads-configuration ()
2743 "Return the current hidden threads configuration."
2746 (goto-char (point-min))
2747 (while (search-forward "\r" nil t)
2748 (push (1- (point)) config))
2751 (defun gnus-restore-hidden-threads-configuration (config)
2752 "Restore hidden threads configuration from CONFIG."
2754 (let (point buffer-read-only)
2755 (while (setq point (pop config))
2756 (when (and (< point (point-max))
2758 (eq (char-after) ?\n))
2759 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2761 ;; Various summary mode internalish functions.
2763 (defun gnus-mouse-pick-article (e)
2766 (gnus-summary-next-page nil t))
2768 (defun gnus-summary-set-display-table ()
2769 "Change the display table.
2770 Odd characters have a tendency to mess
2771 up nicely formatted displays - we make all possible glyphs
2772 display only a single character."
2774 ;; We start from the standard display table, if any.
2775 (let ((table (or (copy-sequence standard-display-table)
2776 (make-display-table)))
2778 ;; Nix out all the control chars...
2779 (while (>= (setq i (1- i)) 0)
2780 (aset table i [??]))
2781 ;; ... but not newline and cr, of course. (cr is necessary for the
2782 ;; selective display).
2783 (aset table ?\n nil)
2784 (aset table ?\r nil)
2785 ;; We keep TAB as well.
2786 (aset table ?\t nil)
2787 ;; We nix out any glyphs over 126 that are not set already.
2789 (while (>= (setq i (1- i)) 127)
2790 ;; Only modify if the entry is nil.
2791 (unless (aref table i)
2792 (aset table i [??]))))
2793 (setq buffer-display-table table)))
2795 (defun gnus-summary-set-article-display-arrow (pos)
2796 "Update the overlay arrow to point to line at position POS."
2797 (when (and gnus-summary-display-arrow
2798 (boundp 'overlay-arrow-position)
2799 (boundp 'overlay-arrow-string))
2803 (unless overlay-arrow-position
2804 (setq overlay-arrow-position (make-marker)))
2805 (setq overlay-arrow-string "=>"
2806 overlay-arrow-position (set-marker overlay-arrow-position
2808 (current-buffer))))))
2810 (defun gnus-summary-buffer-name (group)
2811 "Return the summary buffer name of GROUP."
2812 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2814 (defun gnus-summary-setup-buffer (group)
2815 "Initialize summary buffer."
2816 (let ((buffer (gnus-summary-buffer-name group)))
2817 (if (get-buffer buffer)
2820 (setq gnus-summary-buffer (current-buffer))
2821 (not gnus-newsgroup-prepared))
2822 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2823 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2824 (gnus-summary-mode group)
2826 (gnus-carpal-setup-buffer 'summary))
2827 (unless gnus-single-article-buffer
2828 (make-local-variable 'gnus-article-buffer)
2829 (make-local-variable 'gnus-article-current)
2830 (make-local-variable 'gnus-original-article-buffer))
2831 (setq gnus-newsgroup-name group)
2832 ;; Set any local variables in the group parameters.
2833 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2836 (defun gnus-set-global-variables ()
2837 "Set the global equivalents of the buffer-local variables.
2838 They are set to the latest values they had. These reflect the summary
2839 buffer that was in action when the last article was fetched."
2840 (when (eq major-mode 'gnus-summary-mode)
2841 (setq gnus-summary-buffer (current-buffer))
2842 (let ((name gnus-newsgroup-name)
2843 (marked gnus-newsgroup-marked)
2844 (unread gnus-newsgroup-unreads)
2845 (headers gnus-current-headers)
2846 (data gnus-newsgroup-data)
2847 (summary gnus-summary-buffer)
2848 (article-buffer gnus-article-buffer)
2849 (original gnus-original-article-buffer)
2850 (gac gnus-article-current)
2851 (reffed gnus-reffed-article-number)
2852 (score-file gnus-current-score-file)
2853 (default-charset gnus-newsgroup-charset)
2855 (let ((locals gnus-newsgroup-variables))
2857 (if (consp (car locals))
2858 (push (eval (caar locals)) vlist)
2859 (push (eval (car locals)) vlist))
2860 (setq locals (cdr locals)))
2861 (setq vlist (nreverse vlist)))
2863 (set-buffer gnus-group-buffer)
2864 (setq gnus-newsgroup-name name
2865 gnus-newsgroup-marked marked
2866 gnus-newsgroup-unreads unread
2867 gnus-current-headers headers
2868 gnus-newsgroup-data data
2869 gnus-article-current gac
2870 gnus-summary-buffer summary
2871 gnus-article-buffer article-buffer
2872 gnus-original-article-buffer original
2873 gnus-reffed-article-number reffed
2874 gnus-current-score-file score-file
2875 gnus-newsgroup-charset default-charset)
2876 (let ((locals gnus-newsgroup-variables))
2878 (if (consp (car locals))
2879 (set (caar locals) (pop vlist))
2880 (set (car locals) (pop vlist)))
2881 (setq locals (cdr locals))))
2882 ;; The article buffer also has local variables.
2883 (when (gnus-buffer-live-p gnus-article-buffer)
2884 (set-buffer gnus-article-buffer)
2885 (setq gnus-summary-buffer summary))))))
2887 (defun gnus-summary-article-unread-p (article)
2888 "Say whether ARTICLE is unread or not."
2889 (memq article gnus-newsgroup-unreads))
2891 (defun gnus-summary-first-article-p (&optional article)
2892 "Return whether ARTICLE is the first article in the buffer."
2893 (if (not (setq article (or article (gnus-summary-article-number))))
2895 (eq article (caar gnus-newsgroup-data))))
2897 (defun gnus-summary-last-article-p (&optional article)
2898 "Return whether ARTICLE is the last article in the buffer."
2899 (if (not (setq article (or article (gnus-summary-article-number))))
2900 ;; All non-existent numbers are the last article. :-)
2902 (not (cdr (gnus-data-find-list article)))))
2904 (defun gnus-make-thread-indent-array ()
2906 (unless (and gnus-thread-indent-array
2907 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2908 (setq gnus-thread-indent-array (make-vector 201 "")
2909 gnus-thread-indent-array-level gnus-thread-indent-level)
2911 (aset gnus-thread-indent-array n
2912 (make-string (* n gnus-thread-indent-level) ? ))
2915 (defun gnus-update-summary-mark-positions ()
2916 "Compute where the summary marks are to go."
2918 (when (gnus-buffer-exists-p gnus-summary-buffer)
2919 (set-buffer gnus-summary-buffer))
2920 (let ((gnus-replied-mark 129)
2921 (gnus-score-below-mark 130)
2922 (gnus-score-over-mark 130)
2923 (gnus-download-mark 131)
2924 (spec gnus-summary-line-format-spec)
2927 (gnus-set-work-buffer)
2928 (let ((gnus-summary-line-format-spec spec)
2929 (gnus-newsgroup-downloadable '((0 . t))))
2930 (gnus-summary-insert-line
2931 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2932 0 nil 128 t nil "" nil 1)
2933 (goto-char (point-min))
2934 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2936 (goto-char (point-min))
2937 (push (cons 'replied (and (search-forward "\201" nil t)
2940 (goto-char (point-min))
2941 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2943 (goto-char (point-min))
2944 (push (cons 'download
2945 (and (search-forward "\203" nil t) (- (point) 2)))
2947 (setq gnus-summary-mark-positions pos))))
2949 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2950 "Insert a dummy root in the summary buffer."
2952 (gnus-add-text-properties
2953 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2954 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2956 (defun gnus-summary-extract-address-component (from)
2957 (or (car (funcall gnus-extract-address-components from))
2960 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2961 (let ((mail-parse-charset gnus-newsgroup-charset)
2962 ; Is it really necessary to do this next part for each summary line?
2963 ; Luckily, doesn't seem to slow things down much.
2964 (mail-parse-ignored-charsets
2965 (save-excursion (set-buffer gnus-summary-buffer)
2966 gnus-newsgroup-ignored-charsets)))
2968 (and gnus-ignored-from-addresses
2969 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2970 (let ((extra-headers (mail-header-extra header))
2974 ((setq to (cdr (assq 'To extra-headers)))
2976 (gnus-summary-extract-address-component
2977 (funcall gnus-decode-encoded-word-function to))))
2978 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2979 (concat "=> " newsgroups)))))
2980 (gnus-summary-extract-address-component gnus-tmp-from))))
2982 (defun gnus-summary-insert-line (gnus-tmp-header
2983 gnus-tmp-level gnus-tmp-current
2984 gnus-tmp-unread gnus-tmp-replied
2985 gnus-tmp-expirable gnus-tmp-subject-or-nil
2986 &optional gnus-tmp-dummy gnus-tmp-score
2988 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2989 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2990 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2991 (gnus-tmp-score-char
2992 (if (or (null gnus-summary-default-score)
2993 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2994 gnus-summary-zcore-fuzz))
2996 (if (< gnus-tmp-score gnus-summary-default-score)
2997 gnus-score-below-mark gnus-score-over-mark)))
2998 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3000 (cond (gnus-tmp-process gnus-process-mark)
3001 ((memq gnus-tmp-current gnus-newsgroup-cached)
3003 (gnus-tmp-replied gnus-replied-mark)
3004 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3005 gnus-forwarded-mark)
3006 ((memq gnus-tmp-current gnus-newsgroup-saved)
3008 ((memq gnus-tmp-number gnus-newsgroup-recent)
3010 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3013 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3016 ((string-match "<[^>]+> *$" gnus-tmp-from)
3017 (let ((beg (match-beginning 0)))
3018 (or (and (string-match "^\".+\"" gnus-tmp-from)
3019 (substring gnus-tmp-from 1 (1- (match-end 0))))
3020 (substring gnus-tmp-from 0 beg))))
3021 ((string-match "(.+)" gnus-tmp-from)
3022 (substring gnus-tmp-from
3023 (1+ (match-beginning 0)) (1- (match-end 0))))
3025 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3026 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3027 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3028 (buffer-read-only nil))
3029 (when (string= gnus-tmp-name "")
3030 (setq gnus-tmp-name gnus-tmp-from))
3031 (unless (numberp gnus-tmp-lines)
3032 (setq gnus-tmp-lines -1))
3033 (if (= gnus-tmp-lines -1)
3034 (setq gnus-tmp-lines "?")
3035 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3036 (gnus-put-text-property
3038 (progn (eval gnus-summary-line-format-spec) (point))
3039 'gnus-number gnus-tmp-number)
3040 (when (gnus-visual-p 'summary-highlight 'highlight)
3042 (gnus-run-hooks 'gnus-summary-update-hook)
3045 (defun gnus-summary-update-line (&optional dont-update)
3046 "Update summary line after change."
3047 (when (and gnus-summary-default-score
3048 (not gnus-summary-inhibit-highlight))
3049 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3050 (article (gnus-summary-article-number))
3051 (score (gnus-summary-article-score article)))
3053 (if (and gnus-summary-mark-below
3054 (< (gnus-summary-article-score)
3055 gnus-summary-mark-below))
3056 ;; This article has a low score, so we mark it as read.
3057 (when (memq article gnus-newsgroup-unreads)
3058 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3059 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3060 ;; This article was previously marked as read on account
3061 ;; of a low score, but now it has risen, so we mark it as
3063 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3064 (gnus-summary-update-mark
3065 (if (or (null gnus-summary-default-score)
3066 (<= (abs (- score gnus-summary-default-score))
3067 gnus-summary-zcore-fuzz))
3069 (if (< score gnus-summary-default-score)
3070 gnus-score-below-mark gnus-score-over-mark))
3072 ;; Do visual highlighting.
3073 (when (gnus-visual-p 'summary-highlight 'highlight)
3074 (gnus-run-hooks 'gnus-summary-update-hook)))))
3076 (defvar gnus-tmp-new-adopts nil)
3078 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3079 "Return the number of articles in THREAD.
3080 This may be 0 in some cases -- if none of the articles in
3081 the thread are to be displayed."
3083 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3085 ((not (listp thread))
3087 ((and (consp thread) (cdr thread))
3090 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3093 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3096 (when (and level (zerop level) gnus-tmp-new-adopts)
3099 'gnus-summary-number-of-articles-in-thread
3100 gnus-tmp-new-adopts))))
3102 (if (> number 1) gnus-not-empty-thread-mark
3103 gnus-empty-thread-mark)
3106 (defun gnus-summary-set-local-parameters (group)
3107 "Go through the local params of GROUP and set all variable specs in that list."
3108 (let ((params (gnus-group-find-parameter group))
3109 (vars '(quit-config)) ; Ignore quit-config.
3112 (setq elem (car params)
3113 params (cdr params))
3114 (and (consp elem) ; Has to be a cons.
3115 (consp (cdr elem)) ; The cdr has to be a list.
3116 (symbolp (car elem)) ; Has to be a symbol in there.
3117 (not (memq (car elem) vars))
3118 (ignore-errors ; So we set it.
3119 (push (car elem) vars)
3120 (make-local-variable (car elem))
3121 (set (car elem) (eval (nth 1 elem))))))))
3123 (defun gnus-summary-read-group (group &optional show-all no-article
3124 kill-buffer no-display backward
3126 "Start reading news in newsgroup GROUP.
3127 If SHOW-ALL is non-nil, already read articles are also listed.
3128 If NO-ARTICLE is non-nil, no article is selected initially.
3129 If NO-DISPLAY, don't generate a summary buffer."
3133 (let ((gnus-auto-select-next nil))
3134 (or (gnus-summary-read-group-1
3135 group show-all no-article
3136 kill-buffer no-display
3139 select-articles nil)))))
3140 (eq gnus-auto-select-next 'quietly))
3141 (set-buffer gnus-group-buffer)
3142 ;; The entry function called above goes to the next
3143 ;; group automatically, so we go two groups back
3144 ;; if we are searching for the previous group.
3146 (gnus-group-prev-unread-group 2))
3147 (if (not (equal group (gnus-group-group-name)))
3148 (setq group (gnus-group-group-name))
3152 (defun gnus-summary-read-group-1 (group show-all no-article
3153 kill-buffer no-display
3154 &optional select-articles)
3155 ;; Killed foreign groups can't be entered.
3156 ;; (when (and (not (gnus-group-native-p group))
3157 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3158 ;; (error "Dead non-native groups can't be entered"))
3159 (gnus-message 5 "Retrieving newsgroup: %s..."
3160 (gnus-group-decoded-name group))
3161 (let* ((new-group (gnus-summary-setup-buffer group))
3162 (quit-config (gnus-group-quit-config group))
3163 (did-select (and new-group (gnus-select-newsgroup
3164 group show-all select-articles))))
3166 ;; This summary buffer exists already, so we just select it.
3168 (gnus-set-global-variables)
3170 (gnus-kill-or-deaden-summary kill-buffer))
3171 (gnus-configure-windows 'summary 'force)
3172 (gnus-set-mode-line 'summary)
3173 (gnus-summary-position-point)
3176 ;; We couldn't select this group.
3178 (when (and (eq major-mode 'gnus-summary-mode)
3179 (not (equal (current-buffer) kill-buffer)))
3180 (kill-buffer (current-buffer))
3181 (if (not quit-config)
3183 ;; Update the info -- marks might need to be removed,
3185 (gnus-summary-update-info)
3186 (set-buffer gnus-group-buffer)
3187 (gnus-group-jump-to-group group)
3188 (gnus-group-next-unread-group 1))
3189 (gnus-handle-ephemeral-exit quit-config)))
3190 (let ((grpinfo (gnus-get-info group)))
3191 (if (null (gnus-info-read grpinfo))
3192 (gnus-message 3 "Group %s contains no messages"
3193 (gnus-group-decoded-name group))
3194 (gnus-message 3 "Can't select group")))
3196 ;; The user did a `C-g' while prompting for number of articles,
3197 ;; so we exit this group.
3198 ((eq did-select 'quit)
3199 (and (eq major-mode 'gnus-summary-mode)
3200 (not (equal (current-buffer) kill-buffer))
3201 (kill-buffer (current-buffer)))
3203 (gnus-kill-or-deaden-summary kill-buffer))
3204 (if (not quit-config)
3206 (set-buffer gnus-group-buffer)
3207 (gnus-group-jump-to-group group)
3208 (gnus-group-next-unread-group 1)
3209 (gnus-configure-windows 'group 'force))
3210 (gnus-handle-ephemeral-exit quit-config))
3211 ;; Finally signal the quit.
3213 ;; The group was successfully selected.
3215 (gnus-set-global-variables)
3216 ;; Save the active value in effect when the group was entered.
3217 (setq gnus-newsgroup-active
3219 (gnus-active gnus-newsgroup-name)))
3220 ;; You can change the summary buffer in some way with this hook.
3221 (gnus-run-hooks 'gnus-select-group-hook)
3222 (gnus-update-format-specifications
3223 nil 'summary 'summary-mode 'summary-dummy)
3224 (gnus-update-summary-mark-positions)
3225 ;; Do score processing.
3226 (when gnus-use-scoring
3227 (gnus-possibly-score-headers))
3228 ;; Check whether to fill in the gaps in the threads.
3229 (when gnus-build-sparse-threads
3230 (gnus-build-sparse-threads))
3231 ;; Find the initial limit.
3232 (if gnus-show-threads
3234 (let ((gnus-newsgroup-dormant nil))
3235 (gnus-summary-initial-limit show-all))
3236 (gnus-summary-initial-limit show-all))
3237 ;; When untreaded, all articles are always shown.
3238 (setq gnus-newsgroup-limit
3240 (lambda (header) (mail-header-number header))
3241 gnus-newsgroup-headers)))
3242 ;; Generate the summary buffer.
3244 (gnus-summary-prepare))
3245 (when gnus-use-trees
3246 (gnus-tree-open group)
3247 (setq gnus-summary-highlight-line-function
3248 'gnus-tree-highlight-article))
3249 ;; If the summary buffer is empty, but there are some low-scored
3250 ;; articles or some excluded dormants, we include these in the
3252 (when (and (zerop (buffer-size))
3254 (cond (gnus-newsgroup-dormant
3255 (gnus-summary-limit-include-dormant))
3256 ((and gnus-newsgroup-scored show-all)
3257 (gnus-summary-limit-include-expunged t))))
3258 ;; Function `gnus-apply-kill-file' must be called in this hook.
3259 (gnus-run-hooks 'gnus-apply-kill-hook)
3260 (if (and (zerop (buffer-size))
3263 ;; This newsgroup is empty.
3264 (gnus-summary-catchup-and-exit nil t)
3265 (gnus-message 6 "No unread news")
3267 (gnus-kill-or-deaden-summary kill-buffer))
3268 ;; Return nil from this function.
3270 ;; Hide conversation thread subtrees. We cannot do this in
3271 ;; gnus-summary-prepare-hook since kill processing may not
3272 ;; work with hidden articles.
3273 (gnus-summary-maybe-hide-threads)
3275 (gnus-kill-or-deaden-summary kill-buffer))
3276 (gnus-summary-auto-select-subject)
3277 ;; Show first unread article if requested.
3278 (if (and (not no-article)
3280 gnus-newsgroup-unreads
3281 gnus-auto-select-first)
3283 (gnus-configure-windows 'summary)
3284 (gnus-summary-goto-article (gnus-summary-article-number)))
3285 ;; Don't select any articles.
3286 (gnus-summary-position-point)
3287 (gnus-configure-windows 'summary 'force)
3288 (gnus-set-mode-line 'summary))
3289 (when (get-buffer-window gnus-group-buffer t)
3290 ;; Gotta use windows, because recenter does weird stuff if
3291 ;; the current buffer ain't the displayed window.
3292 (let ((owin (selected-window)))
3293 (select-window (get-buffer-window gnus-group-buffer t))
3294 (when (gnus-group-goto-group group)
3296 (select-window owin)))
3297 ;; Mark this buffer as "prepared".
3298 (setq gnus-newsgroup-prepared t)
3299 (gnus-run-hooks 'gnus-summary-prepared-hook)
3302 (defun gnus-summary-auto-select-subject ()
3303 "Select the subject line on initial group entry."
3304 (goto-char (point-min))
3306 ((eq gnus-auto-select-subject 'best)
3307 (gnus-summary-best-unread-subject))
3308 ((eq gnus-auto-select-subject 'unread)
3309 (gnus-summary-first-unread-subject))
3310 ((eq gnus-auto-select-subject 'unseen)
3311 (gnus-summary-first-unseen-subject))
3312 ((eq gnus-auto-select-subject 'first)
3315 ((gnus-functionp gnus-auto-select-subject)
3316 (funcall gnus-auto-select-subject))))
3318 (defun gnus-summary-prepare ()
3319 "Generate the summary buffer."
3321 (let ((buffer-read-only nil))
3323 (setq gnus-newsgroup-data nil
3324 gnus-newsgroup-data-reverse nil)
3325 (gnus-run-hooks 'gnus-summary-generate-hook)
3326 ;; Generate the buffer, either with threads or without.
3327 (when gnus-newsgroup-headers
3328 (gnus-summary-prepare-threads
3329 (if gnus-show-threads
3330 (gnus-sort-gathered-threads
3331 (funcall gnus-summary-thread-gathering-function
3333 (gnus-cut-threads (gnus-make-threads)))))
3334 ;; Unthreaded display.
3335 (gnus-sort-articles gnus-newsgroup-headers))))
3336 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3337 ;; Call hooks for modifying summary buffer.
3338 (goto-char (point-min))
3339 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3341 (defsubst gnus-general-simplify-subject (subject)
3342 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3345 ;; Truncate the subject.
3346 (gnus-simplify-subject-functions
3347 (gnus-map-function gnus-simplify-subject-functions subject))
3348 ((numberp gnus-summary-gather-subject-limit)
3349 (setq subject (gnus-simplify-subject-re subject))
3350 (if (> (length subject) gnus-summary-gather-subject-limit)
3351 (substring subject 0 gnus-summary-gather-subject-limit)
3353 ;; Fuzzily simplify it.
3354 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3355 (gnus-simplify-subject-fuzzy subject))
3356 ;; Just remove the leading "Re:".
3358 (gnus-simplify-subject-re subject))))
3360 (if (and gnus-summary-gather-exclude-subject
3361 (string-match gnus-summary-gather-exclude-subject subject))
3362 nil ; This article shouldn't be gathered
3365 (defun gnus-summary-simplify-subject-query ()
3366 "Query where the respool algorithm would put this article."
3368 (gnus-summary-select-article)
3369 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3371 (defun gnus-gather-threads-by-subject (threads)
3372 "Gather threads by looking at Subject headers."
3373 (if (not gnus-summary-make-false-root)
3375 (let ((hashtb (gnus-make-hashtable 1024))
3378 subject hthread whole-subject)
3380 (setq subject (gnus-general-simplify-subject
3381 (setq whole-subject (mail-header-subject
3384 (if (setq hthread (gnus-gethash subject hashtb))
3386 ;; We enter a dummy root into the thread, if we
3387 ;; haven't done that already.
3388 (unless (stringp (caar hthread))
3389 (setcar hthread (list whole-subject (car hthread))))
3390 ;; We add this new gathered thread to this gathered
3392 (setcdr (car hthread)
3393 (nconc (cdar hthread) (list (car threads))))
3394 ;; Remove it from the list of threads.
3395 (setcdr prev (cdr threads))
3396 (setq threads prev))
3397 ;; Enter this thread into the hash table.
3398 (gnus-sethash subject threads hashtb)))
3400 (setq threads (cdr threads)))
3403 (defun gnus-gather-threads-by-references (threads)
3404 "Gather threads by looking at References headers."
3405 (let ((idhashtb (gnus-make-hashtable 1024))
3406 (thhashtb (gnus-make-hashtable 1024))
3409 ids references id gthread gid entered ref)
3411 (when (setq references (mail-header-references (caar threads)))
3412 (setq id (mail-header-id (caar threads))
3413 ids (gnus-split-references references)
3415 (while (setq ref (pop ids))
3416 (setq ids (delete ref ids))
3417 (if (not (setq gid (gnus-gethash ref idhashtb)))
3419 (gnus-sethash ref id idhashtb)
3420 (gnus-sethash id threads thhashtb))
3421 (setq gthread (gnus-gethash gid thhashtb))
3423 ;; We enter a dummy root into the thread, if we
3424 ;; haven't done that already.
3425 (unless (stringp (caar gthread))
3426 (setcar gthread (list (mail-header-subject (caar gthread))
3428 ;; We add this new gathered thread to this gathered
3430 (setcdr (car gthread)
3431 (nconc (cdar gthread) (list (car threads)))))
3432 ;; Add it into the thread hash table.
3433 (gnus-sethash id gthread thhashtb)
3435 ;; Remove it from the list of threads.
3436 (setcdr prev (cdr threads))
3437 (setq threads prev))))
3439 (setq threads (cdr threads)))
3442 (defun gnus-sort-gathered-threads (threads)
3443 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3444 (let ((result threads))
3446 (when (stringp (caar threads))
3447 (setcdr (car threads)
3448 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3449 (setq threads (cdr threads)))
3452 (defun gnus-thread-loop-p (root thread)
3453 "Say whether ROOT is in THREAD."
3454 (let ((stack (list thread))
3457 (while (setq thread (pop stack))
3458 (setq th (cdr thread))
3460 (not (eq (caar th) root)))
3463 ;; We have found a loop.
3465 (setcdr thread (delq (car th) (cdr thread)))
3466 (if (boundp (setq ref-dep (intern "none"
3467 gnus-newsgroup-dependencies)))
3468 (setcdr (symbol-value ref-dep)
3469 (nconc (cdr (symbol-value ref-dep))
3471 (set ref-dep (list nil (car th))))
3474 ;; Push all the subthreads onto the stack.
3475 (push (cdr thread) stack)))
3478 (defun gnus-make-threads ()
3479 "Go through the dependency hashtb and find the roots. Return all threads."
3481 (while (catch 'infloop
3484 ;; Deal with self-referencing References loops.
3485 (when (and (car (symbol-value refs))
3492 (car (symbol-value refs)) thread))
3493 (cdr (symbol-value refs)))))))
3496 (unless (car (symbol-value refs))
3497 ;; These threads do not refer back to any other articles,
3498 ;; so they're roots.
3499 (setq threads (append (cdr (symbol-value refs)) threads))))
3500 gnus-newsgroup-dependencies)))
3503 ;; Build the thread tree.
3504 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3505 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3507 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3508 if it was already present.
3510 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3511 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3512 Message-IDs will be renamed be renamed to a unique Message-ID before
3515 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3516 (let* ((id (mail-header-id header))
3517 (id-dep (and id (intern id dependencies)))
3518 ref ref-dep ref-header)
3519 ;; Enter this `header' in the `dependencies' table.
3523 ;; The first two cases do the normal part: enter a new `header'
3524 ;; in the `dependencies' table.
3525 ((not (boundp id-dep))
3526 (set id-dep (list header)))
3527 ((null (car (symbol-value id-dep)))
3528 (setcar (symbol-value id-dep) header))
3530 ;; From here the `header' was already present in the
3531 ;; `dependencies' table.
3533 ;; Overrides an existing entry;
3534 ;; just set the header part of the entry.
3535 (setcar (symbol-value id-dep) header))
3537 ;; Renames the existing `header' to a unique Message-ID.
3538 ((not gnus-summary-ignore-duplicates)
3539 ;; An article with this Message-ID has already been seen.
3540 ;; We rename the Message-ID.
3541 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3543 (mail-header-set-id header id))
3545 ;; The last case ignores an existing entry, except it adds any
3546 ;; additional Xrefs (in case the two articles came from different
3548 ;; Also sets `header' to `nil' meaning that the `dependencies'
3549 ;; table was *not* modified.
3551 (mail-header-set-xref
3552 (car (symbol-value id-dep))
3553 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3555 (or (mail-header-xref header) "")))
3559 ;; First check if that we are not creating a References loop.
3560 (setq ref (gnus-parent-id (mail-header-references header)))
3562 (setq ref-dep (intern-soft ref dependencies))
3564 (setq ref-header (car (symbol-value ref-dep))))
3565 (if (string= id ref)
3566 ;; Yuk! This is a reference loop. Make the article be a
3569 (mail-header-set-references (car (symbol-value id-dep)) "none")
3571 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3572 (setq ref (gnus-parent-id (mail-header-references header)))
3573 (setq ref-dep (intern (or ref "none") dependencies))
3574 (if (boundp ref-dep)
3575 (setcdr (symbol-value ref-dep)
3576 (nconc (cdr (symbol-value ref-dep))
3577 (list (symbol-value id-dep))))
3578 (set ref-dep (list nil (symbol-value id-dep)))))
3581 (defun gnus-build-sparse-threads ()
3582 (let ((headers gnus-newsgroup-headers)
3583 (mail-parse-charset gnus-newsgroup-charset)
3584 (gnus-summary-ignore-duplicates t)
3585 header references generation relations
3586 subject child end new-child date)
3587 ;; First we create an alist of generations/relations, where
3588 ;; generations is how much we trust the relation, and the relation
3590 (gnus-message 7 "Making sparse threads...")
3592 (nnheader-set-temp-buffer " *gnus sparse threads*")
3593 (while (setq header (pop headers))
3594 (when (and (setq references (mail-header-references header))
3595 (not (string= references "")))
3597 (setq child (mail-header-id header)
3598 subject (mail-header-subject header)
3599 date (mail-header-date header)
3601 (while (search-backward ">" nil t)
3602 (setq end (1+ (point)))
3603 (when (search-backward "<" nil t)
3604 (setq new-child (buffer-substring (point) end))
3605 (push (list (incf generation)
3606 child (setq child new-child)
3610 (push (list (1+ generation) child nil subject) relations))
3612 (kill-buffer (current-buffer)))
3613 ;; Sort over trustworthiness.
3616 (when (gnus-dependencies-add-header
3617 (make-full-mail-header
3618 gnus-reffed-article-number
3619 (nth 3 relation) "" (or (nth 4 relation) "")
3621 (or (nth 2 relation) "") 0 0 "")
3622 gnus-newsgroup-dependencies nil)
3623 (push gnus-reffed-article-number gnus-newsgroup-limit)
3624 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3625 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3626 gnus-newsgroup-reads)
3627 (decf gnus-reffed-article-number)))
3628 (sort relations 'car-less-than-car))
3629 (gnus-message 7 "Making sparse threads...done")))
3631 (defun gnus-build-old-threads ()
3632 ;; Look at all the articles that refer back to old articles, and
3633 ;; fetch the headers for the articles that aren't there. This will
3634 ;; build complete threads - if the roots haven't been expired by the
3636 (let ((mail-parse-charset gnus-newsgroup-charset)
3640 (when (not (car (symbol-value refs)))
3641 (setq heads (cdr (symbol-value refs)))
3643 (if (memq (mail-header-number (caar heads))
3644 gnus-newsgroup-dormant)
3645 (setq heads (cdr heads))
3646 (setq id (symbol-name refs))
3647 (while (and (setq id (gnus-build-get-header id))
3648 (not (car (gnus-id-to-thread id)))))
3649 (setq heads nil)))))
3650 gnus-newsgroup-dependencies)))
3652 ;; This function has to be called with point after the article number
3653 ;; on the beginning of the line.
3654 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3655 (let ((eol (gnus-point-at-eol))
3656 (buffer (current-buffer))
3659 ;; overview: [num subject from date id refs chars lines misc]
3662 (narrow-to-region (point) eol)
3667 (make-full-mail-header
3669 (funcall gnus-decode-encoded-word-function
3670 (nnheader-nov-field)) ; subject
3671 (funcall gnus-decode-encoded-word-function
3672 (nnheader-nov-field)) ; from
3673 (nnheader-nov-field) ; date
3674 (nnheader-nov-read-message-id) ; id
3675 (nnheader-nov-field) ; refs
3676 (nnheader-nov-read-integer) ; chars
3677 (nnheader-nov-read-integer) ; lines
3679 (if (looking-at "Xref: ")
3680 (goto-char (match-end 0)))
3681 (nnheader-nov-field)) ; Xref
3682 (nnheader-nov-parse-extra)))) ; extra
3686 (when gnus-alter-header-function
3687 (funcall gnus-alter-header-function header))
3688 (gnus-dependencies-add-header header dependencies force-new)))
3690 (defun gnus-build-get-header (id)
3691 "Look through the buffer of NOV lines and find the header to ID.
3692 Enter this line into the dependencies hash table, and return
3693 the id of the parent article (if any)."
3694 (let ((deps gnus-newsgroup-dependencies)
3698 (set-buffer nntp-server-buffer)
3699 (let ((case-fold-search nil))
3700 (goto-char (point-min))
3701 (while (and (not found)
3702 (search-forward id nil t))
3704 (setq found (looking-at
3705 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3706 (regexp-quote id))))
3707 (or found (beginning-of-line 2)))
3711 (setq header (gnus-nov-parse-line
3712 (read (current-buffer)) deps))
3713 (gnus-parent-id (mail-header-references header))))))
3715 (let ((number (mail-header-number header)))
3716 (push number gnus-newsgroup-limit)
3717 (push header gnus-newsgroup-headers)
3718 (if (memq number gnus-newsgroup-unselected)
3720 (push number gnus-newsgroup-unreads)
3721 (setq gnus-newsgroup-unselected
3722 (delq number gnus-newsgroup-unselected)))
3723 (push number gnus-newsgroup-ancient)))))))
3725 (defun gnus-build-all-threads ()
3726 "Read all the headers."
3727 (let ((gnus-summary-ignore-duplicates t)
3728 (mail-parse-charset gnus-newsgroup-charset)
3729 (dependencies gnus-newsgroup-dependencies)
3732 (set-buffer nntp-server-buffer)
3733 (let ((case-fold-search nil))
3734 (goto-char (point-min))
3737 (setq article (read (current-buffer))
3738 header (gnus-nov-parse-line article dependencies)))
3741 (set-buffer gnus-summary-buffer)
3742 (push header gnus-newsgroup-headers)
3743 (if (memq (setq article (mail-header-number header))
3744 gnus-newsgroup-unselected)
3746 (push article gnus-newsgroup-unreads)
3747 (setq gnus-newsgroup-unselected
3748 (delq article gnus-newsgroup-unselected)))
3749 (push article gnus-newsgroup-ancient)))
3750 (forward-line 1)))))))
3752 (defun gnus-summary-update-article-line (article header)
3753 "Update the line for ARTICLE using HEADERS."
3754 (let* ((id (mail-header-id header))
3755 (thread (gnus-id-to-thread id)))
3757 (error "Article in no thread"))
3758 ;; Update the thread.
3759 (setcar thread header)
3760 (gnus-summary-goto-subject article)
3761 (let* ((datal (gnus-data-find-list article))
3763 (length (when (cdr datal)
3764 (- (gnus-data-pos data)
3765 (gnus-data-pos (cadr datal)))))
3766 (buffer-read-only nil)
3767 (level (gnus-summary-thread-level)))
3769 (gnus-summary-insert-line
3770 header level nil (gnus-article-mark article)
3771 (memq article gnus-newsgroup-replied)
3772 (memq article gnus-newsgroup-expirable)
3773 ;; Only insert the Subject string when it's different
3774 ;; from the previous Subject string.
3779 (mail-header-subject
3782 (gnus-data-find-list
3784 (gnus-data-list t)))))
3785 ;; Error on the side of excessive subjects.
3787 (mail-header-subject header)))
3789 (mail-header-subject header))
3790 nil (cdr (assq article gnus-newsgroup-scored))
3791 (memq article gnus-newsgroup-processable))
3793 (gnus-data-update-list
3794 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3796 (defun gnus-summary-update-article (article &optional iheader)
3797 "Update ARTICLE in the summary buffer."
3798 (set-buffer gnus-summary-buffer)
3799 (let* ((header (gnus-summary-article-header article))
3800 (id (mail-header-id header))
3801 (data (gnus-data-find article))
3802 (thread (gnus-id-to-thread id))
3803 (references (mail-header-references header))
3807 (when (and references
3808 (not (equal "" references)))
3811 (buffer-read-only nil)
3817 (delq thread parent)))
3818 (if (gnus-summary-insert-subject id header)
3819 ;; Set the (possibly) new article number in the data structure.
3820 (gnus-data-set-number data (gnus-id-to-article id))
3824 (defun gnus-rebuild-thread (id &optional line)
3825 "Rebuild the thread containing ID.
3826 If LINE, insert the rebuilt thread starting on line LINE."
3827 (let ((buffer-read-only nil)
3828 old-pos current thread data)
3829 (if (not gnus-show-threads)
3830 (setq thread (list (car (gnus-id-to-thread id))))
3831 ;; Get the thread this article is part of.
3832 (setq thread (gnus-remove-thread id)))
3833 (setq old-pos (gnus-point-at-bol))
3834 (setq current (save-excursion
3835 (and (re-search-backward "[\r\n]" nil t)
3836 (gnus-summary-article-number))))
3837 ;; If this is a gathered thread, we have to go some re-gathering.
3838 (when (stringp (car thread))
3839 (let ((subject (car thread))
3841 (setq thread (cdr thread))
3843 (unless (memq (setq thr (gnus-id-to-thread
3845 (mail-header-id (caar thread)))))
3848 (setq thread (cdr thread)))
3849 ;; We now have all (unique) roots.
3850 (if (= (length roots) 1)
3851 ;; All the loose roots are now one solid root.
3852 (setq thread (car roots))
3853 (setq thread (cons subject (gnus-sort-threads roots))))))
3855 ;; We then insert this thread into the summary buffer.
3857 (goto-char (point-min))
3858 (forward-line (1- line)))
3859 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3860 (if gnus-show-threads
3861 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3862 (gnus-summary-prepare-unthreaded thread))
3863 (setq data (nreverse gnus-newsgroup-data))
3864 (setq threads gnus-newsgroup-threads))
3865 ;; We splice the new data into the data structure.
3866 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3867 ;;!!! then we want to insert at the beginning of the buffer.
3868 ;;!!! That happens to be true with Gnus now, but that may
3869 ;;!!! change in the future. Perhaps.
3870 (gnus-data-enter-list
3871 (if line nil current) data (- (point) old-pos))
3872 (setq gnus-newsgroup-threads
3873 (nconc threads gnus-newsgroup-threads))
3874 (gnus-data-compute-positions))))
3876 (defun gnus-number-to-header (number)
3877 "Return the header for article NUMBER."
3878 (let ((headers gnus-newsgroup-headers))
3880 (not (= number (mail-header-number (car headers)))))
3885 (defun gnus-parent-headers (in-headers &optional generation)
3886 "Return the headers of the GENERATIONeth parent of HEADERS."
3888 (setq generation 1))
3890 (headers in-headers)
3893 (not (zerop generation))
3894 (setq references (mail-header-references headers)))
3895 (setq headers (if (and references
3896 (setq parent (gnus-parent-id references)))
3897 (car (gnus-id-to-thread parent))
3900 (and (not (eq headers in-headers))
3903 (defun gnus-id-to-thread (id)
3904 "Return the (sub-)thread where ID appears."
3905 (gnus-gethash id gnus-newsgroup-dependencies))
3907 (defun gnus-id-to-article (id)
3908 "Return the article number of ID."
3909 (let ((thread (gnus-id-to-thread id)))
3912 (mail-header-number (car thread)))))
3914 (defun gnus-id-to-header (id)
3915 "Return the article headers of ID."
3916 (car (gnus-id-to-thread id)))
3918 (defun gnus-article-displayed-root-p (article)
3919 "Say whether ARTICLE is a root(ish) article."
3920 (let ((level (gnus-summary-thread-level article))
3921 (refs (mail-header-references (gnus-summary-article-header article)))
3927 ((null (gnus-parent-id refs)) t)
3929 (null (setq particle (gnus-id-to-article
3930 (gnus-parent-id refs))))
3931 (null (gnus-summary-thread-level particle)))))))
3933 (defun gnus-root-id (id)
3934 "Return the id of the root of the thread where ID appears."
3936 (while (and id (setq prev (car (gnus-id-to-thread id))))
3938 id (gnus-parent-id (mail-header-references prev))))
3941 (defun gnus-articles-in-thread (thread)
3942 "Return the list of articles in THREAD."
3943 (cons (mail-header-number (car thread))
3944 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3946 (defun gnus-remove-thread (id &optional dont-remove)
3947 "Remove the thread that has ID in it."
3948 (let (headers thread last-id)
3949 ;; First go up in this thread until we find the root.
3950 (setq last-id (gnus-root-id id)
3951 headers (message-flatten-list (gnus-id-to-thread last-id)))
3952 ;; We have now found the real root of this thread. It might have
3953 ;; been gathered into some loose thread, so we have to search
3954 ;; through the threads to find the thread we wanted.
3955 (let ((threads gnus-newsgroup-threads)
3958 (setq sub (car threads))
3959 (if (stringp (car sub))
3960 ;; This is a gathered thread, so we look at the roots
3961 ;; below it to find whether this article is in this
3964 (setq sub (cdr sub))
3966 (when (member (caar sub) headers)
3967 (setq thread (car threads)
3970 (setq sub (cdr sub))))
3971 ;; It's an ordinary thread, so we check it.
3972 (when (eq (car sub) (car headers))
3975 (setq threads (cdr threads)))
3976 ;; If this article is in no thread, then it's a root.
3979 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3980 (setq thread (gnus-id-to-thread last-id)))
3983 thread ; We return this thread.
3985 (if (stringp (car thread))
3987 ;; If we use dummy roots, then we have to remove the
3988 ;; dummy root as well.
3989 (when (eq gnus-summary-make-false-root 'dummy)
3990 ;; We go to the dummy root by going to
3991 ;; the first sub-"thread", and then one line up.
3992 (gnus-summary-goto-article
3993 (mail-header-number (caadr thread)))
3996 (gnus-data-compute-positions))
3997 (setq thread (cdr thread))
3999 (gnus-remove-thread-1 (car thread))
4000 (setq thread (cdr thread))))
4001 (gnus-remove-thread-1 thread))))))))
4003 (defun gnus-remove-thread-1 (thread)
4004 "Remove the thread THREAD recursively."
4005 (let ((number (mail-header-number (pop thread)))
4007 (setq thread (reverse thread))
4009 (gnus-remove-thread-1 (pop thread)))
4010 (when (setq d (gnus-data-find number))
4011 (goto-char (gnus-data-pos d))
4012 (gnus-summary-show-thread)
4015 (- (gnus-point-at-bol)
4017 (1+ (gnus-point-at-eol))
4018 (gnus-delete-line)))))))
4020 (defun gnus-sort-threads-1 (threads func)
4021 (sort (mapcar (lambda (thread)
4024 (gnus-sort-threads-1 (cdr thread) func))))
4027 (defun gnus-sort-threads (threads)
4029 (if (not gnus-thread-sort-functions)
4031 (gnus-message 8 "Sorting threads...")
4033 (gnus-sort-threads-1
4035 (gnus-make-sort-function gnus-thread-sort-functions))
4036 (gnus-message 8 "Sorting threads...done"))))
4038 (defun gnus-sort-articles (articles)
4040 (when gnus-article-sort-functions
4041 (gnus-message 7 "Sorting articles...")
4043 (setq gnus-newsgroup-headers
4044 (sort articles (gnus-make-sort-function
4045 gnus-article-sort-functions)))
4046 (gnus-message 7 "Sorting articles...done"))))
4048 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4049 (defmacro gnus-thread-header (thread)
4050 "Return header of first article in THREAD.
4051 Note that THREAD must never, ever be anything else than a variable -
4052 using some other form will lead to serious barfage."
4053 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4054 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4055 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4058 (defsubst gnus-article-sort-by-number (h1 h2)
4059 "Sort articles by article number."
4060 (< (mail-header-number h1)
4061 (mail-header-number h2)))
4063 (defun gnus-thread-sort-by-number (h1 h2)
4064 "Sort threads by root article number."
4065 (gnus-article-sort-by-number
4066 (gnus-thread-header h1) (gnus-thread-header h2)))
4068 (defsubst gnus-article-sort-by-lines (h1 h2)
4069 "Sort articles by article Lines header."
4070 (< (mail-header-lines h1)
4071 (mail-header-lines h2)))
4073 (defun gnus-thread-sort-by-lines (h1 h2)
4074 "Sort threads by root article Lines header."
4075 (gnus-article-sort-by-lines
4076 (gnus-thread-header h1) (gnus-thread-header h2)))
4078 (defsubst gnus-article-sort-by-chars (h1 h2)
4079 "Sort articles by octet length."
4080 (< (mail-header-chars h1)
4081 (mail-header-chars h2)))
4083 (defun gnus-thread-sort-by-chars (h1 h2)
4084 "Sort threads by root article octet length."
4085 (gnus-article-sort-by-chars
4086 (gnus-thread-header h1) (gnus-thread-header h2)))
4088 (defsubst gnus-article-sort-by-author (h1 h2)
4089 "Sort articles by root author."
4091 (let ((extract (funcall
4092 gnus-extract-address-components
4093 (mail-header-from h1))))
4094 (or (car extract) (cadr extract) ""))
4095 (let ((extract (funcall
4096 gnus-extract-address-components
4097 (mail-header-from h2))))
4098 (or (car extract) (cadr extract) ""))))
4100 (defun gnus-thread-sort-by-author (h1 h2)
4101 "Sort threads by root author."
4102 (gnus-article-sort-by-author
4103 (gnus-thread-header h1) (gnus-thread-header h2)))
4105 (defsubst gnus-article-sort-by-subject (h1 h2)
4106 "Sort articles by root subject."
4108 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4109 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4111 (defun gnus-thread-sort-by-subject (h1 h2)
4112 "Sort threads by root subject."
4113 (gnus-article-sort-by-subject
4114 (gnus-thread-header h1) (gnus-thread-header h2)))
4116 (defsubst gnus-article-sort-by-date (h1 h2)
4117 "Sort articles by root article date."
4119 (gnus-date-get-time (mail-header-date h1))
4120 (gnus-date-get-time (mail-header-date h2))))
4122 (defun gnus-thread-sort-by-date (h1 h2)
4123 "Sort threads by root article date."
4124 (gnus-article-sort-by-date
4125 (gnus-thread-header h1) (gnus-thread-header h2)))
4127 (defsubst gnus-article-sort-by-score (h1 h2)
4128 "Sort articles by root article score.
4129 Unscored articles will be counted as having a score of zero."
4130 (> (or (cdr (assq (mail-header-number h1)
4131 gnus-newsgroup-scored))
4132 gnus-summary-default-score 0)
4133 (or (cdr (assq (mail-header-number h2)
4134 gnus-newsgroup-scored))
4135 gnus-summary-default-score 0)))
4137 (defun gnus-thread-sort-by-score (h1 h2)
4138 "Sort threads by root article score."
4139 (gnus-article-sort-by-score
4140 (gnus-thread-header h1) (gnus-thread-header h2)))
4142 (defun gnus-thread-sort-by-total-score (h1 h2)
4143 "Sort threads by the sum of all scores in the thread.
4144 Unscored articles will be counted as having a score of zero."
4145 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4147 (defun gnus-thread-total-score (thread)
4148 ;; This function find the total score of THREAD.
4149 (cond ((null thread)
4152 (if (stringp (car thread))
4153 (apply gnus-thread-score-function 0
4154 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4155 (gnus-thread-total-score-1 thread)))
4157 (gnus-thread-total-score-1 (list thread)))))
4159 (defun gnus-thread-total-score-1 (root)
4160 ;; This function find the total score of the thread below ROOT.
4161 (setq root (car root))
4162 (apply gnus-thread-score-function
4164 (mapcar 'gnus-thread-total-score
4165 (cdr (gnus-id-to-thread (mail-header-id root))))
4166 (when (> (mail-header-number root) 0)
4167 (list (or (cdr (assq (mail-header-number root)
4168 gnus-newsgroup-scored))
4169 gnus-summary-default-score 0))))
4170 (list gnus-summary-default-score)
4173 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4174 (defvar gnus-tmp-prev-subject nil)
4175 (defvar gnus-tmp-false-parent nil)
4176 (defvar gnus-tmp-root-expunged nil)
4177 (defvar gnus-tmp-dummy-line nil)
4179 (eval-when-compile (defvar gnus-tmp-header))
4180 (defun gnus-extra-header (type &optional header)
4181 "Return the extra header of TYPE."
4182 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4185 (defvar gnus-tmp-thread-tree-header-string "")
4187 (defvar gnus-sum-thread-tree-root "> "
4188 "With %B spec, used for the root of a thread.
4189 If nil, use subject instead.")
4190 (defvar gnus-sum-thread-tree-single-indent ""
4191 "With %B spec, used for a thread with just one message.
4192 If nil, use subject instead.")
4193 (defvar gnus-sum-thread-tree-vertical "| "
4194 "With %B spec, used for drawing a vertical line.")
4195 (defvar gnus-sum-thread-tree-indent " "
4196 "With %B spec, used for indenting.")
4197 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4198 "With %B spec, used for a leaf with brothers.")
4199 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4200 "With %B spec, used for a leaf without brothers.")
4202 (defun gnus-summary-prepare-threads (threads)
4203 "Prepare summary buffer from THREADS and indentation LEVEL.
4204 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4205 or a straight list of headers."
4206 (gnus-message 7 "Generating summary...")
4208 (setq gnus-newsgroup-threads threads)
4211 (let ((gnus-tmp-level 0)
4212 (default-score (or gnus-summary-default-score 0))
4213 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4214 thread number subject stack state gnus-tmp-gathered beg-match
4215 new-roots gnus-tmp-new-adopts thread-end
4216 gnus-tmp-header gnus-tmp-unread
4217 gnus-tmp-replied gnus-tmp-subject-or-nil
4218 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4219 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4220 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4223 (setq gnus-tmp-prev-subject nil)
4225 (if (vectorp (car threads))
4226 ;; If this is a straight (sic) list of headers, then a
4227 ;; threaded summary display isn't required, so we just create
4228 ;; an unthreaded one.
4229 (gnus-summary-prepare-unthreaded threads)
4231 ;; Do the threaded display.
4233 (while (or threads stack gnus-tmp-new-adopts new-roots)
4235 (if (and (= gnus-tmp-level 0)
4238 (not gnus-tmp-false-parent)
4239 (or gnus-tmp-new-adopts new-roots))
4240 (if gnus-tmp-new-adopts
4241 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4242 thread (list (car gnus-tmp-new-adopts))
4243 gnus-tmp-header (caar thread)
4244 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4246 (setq thread (list (car new-roots))
4247 gnus-tmp-header (caar thread)
4248 new-roots (cdr new-roots))))
4251 ;; If there are some threads, we do them before the
4252 ;; threads on the stack.
4253 (setq thread threads
4254 gnus-tmp-header (caar thread))
4255 ;; There were no current threads, so we pop something off
4257 (setq state (car stack)
4258 gnus-tmp-level (car state)
4259 tree-stack (cadr state)
4260 thread (caddr state)
4262 gnus-tmp-header (caar thread))))
4264 (setq gnus-tmp-false-parent nil)
4265 (setq gnus-tmp-root-expunged nil)
4266 (setq thread-end nil)
4268 (if (stringp gnus-tmp-header)
4269 ;; The header is a dummy root.
4271 ((eq gnus-summary-make-false-root 'adopt)
4272 ;; We let the first article adopt the rest.
4273 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4275 (setq gnus-tmp-gathered
4277 (lambda (h) (mail-header-number (car h)))
4280 (setq thread (cons (list (caar thread)
4283 (setq gnus-tmp-level -1
4284 gnus-tmp-false-parent t))
4285 ((eq gnus-summary-make-false-root 'empty)
4286 ;; We print adopted articles with empty subject fields.
4287 (setq gnus-tmp-gathered
4289 (lambda (h) (mail-header-number (car h)))
4292 (setq gnus-tmp-level -1))
4293 ((eq gnus-summary-make-false-root 'dummy)
4294 ;; We remember that we probably want to output a dummy
4296 (setq gnus-tmp-dummy-line gnus-tmp-header)
4297 (setq gnus-tmp-prev-subject gnus-tmp-header))
4299 ;; We do not make a root for the gathered
4300 ;; sub-threads at all.
4301 (setq gnus-tmp-level -1)))
4303 (setq number (mail-header-number gnus-tmp-header)
4304 subject (mail-header-subject gnus-tmp-header))
4307 ;; If the thread has changed subject, we might want to make
4308 ;; this subthread into a root.
4309 ((and (null gnus-thread-ignore-subject)
4310 (not (zerop gnus-tmp-level))
4311 gnus-tmp-prev-subject
4313 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4314 (setq new-roots (nconc new-roots (list (car thread)))
4316 gnus-tmp-header nil))
4317 ;; If the article lies outside the current limit,
4318 ;; then we do not display it.
4319 ((not (memq number gnus-newsgroup-limit))
4320 (setq gnus-tmp-gathered
4322 (lambda (h) (mail-header-number (car h)))
4325 (setq gnus-tmp-new-adopts (if (cdar thread)
4326 (append gnus-tmp-new-adopts
4328 gnus-tmp-new-adopts)
4330 gnus-tmp-header nil)
4331 (when (zerop gnus-tmp-level)
4332 (setq gnus-tmp-root-expunged t)))
4333 ;; Perhaps this article is to be marked as read?
4334 ((and gnus-summary-mark-below
4335 (< (or (cdr (assq number gnus-newsgroup-scored))
4337 gnus-summary-mark-below)
4338 ;; Don't touch sparse articles.
4339 (not (gnus-summary-article-sparse-p number))
4340 (not (gnus-summary-article-ancient-p number)))
4341 (setq gnus-newsgroup-unreads
4342 (delq number gnus-newsgroup-unreads))
4343 (if gnus-newsgroup-auto-expire
4344 (push number gnus-newsgroup-expirable)
4345 (push (cons number gnus-low-score-mark)
4346 gnus-newsgroup-reads))))
4348 (when gnus-tmp-header
4349 ;; We may have an old dummy line to output before this
4351 (when (and gnus-tmp-dummy-line
4354 (mail-header-subject gnus-tmp-header)))
4355 (gnus-summary-insert-dummy-line
4356 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4357 (setq gnus-tmp-dummy-line nil))
4359 ;; Compute the mark.
4360 (setq gnus-tmp-unread (gnus-article-mark number))
4362 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4363 gnus-tmp-header gnus-tmp-level)
4364 gnus-newsgroup-data)
4366 ;; Actually insert the line.
4368 gnus-tmp-subject-or-nil
4370 ((and gnus-thread-ignore-subject
4371 gnus-tmp-prev-subject
4372 (not (inline (gnus-subject-equal
4373 gnus-tmp-prev-subject subject))))
4375 ((zerop gnus-tmp-level)
4376 (if (and (eq gnus-summary-make-false-root 'empty)
4377 (memq number gnus-tmp-gathered)
4378 gnus-tmp-prev-subject
4379 (inline (gnus-subject-equal
4380 gnus-tmp-prev-subject subject)))
4381 gnus-summary-same-subject
4383 (t gnus-summary-same-subject)))
4384 (if (and (eq gnus-summary-make-false-root 'adopt)
4385 (= gnus-tmp-level 1)
4386 (memq number gnus-tmp-gathered))
4387 (setq gnus-tmp-opening-bracket ?\<
4388 gnus-tmp-closing-bracket ?\>)
4389 (setq gnus-tmp-opening-bracket ?\[
4390 gnus-tmp-closing-bracket ?\]))
4392 gnus-tmp-indentation
4393 (aref gnus-thread-indent-array gnus-tmp-level)
4394 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4395 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4396 gnus-summary-default-score 0)
4398 (if (or (null gnus-summary-default-score)
4399 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4400 gnus-summary-zcore-fuzz))
4402 (if (< gnus-tmp-score gnus-summary-default-score)
4403 gnus-score-below-mark gnus-score-over-mark))
4405 (cond ((memq number gnus-newsgroup-processable)
4407 ((memq number gnus-newsgroup-cached)
4409 ((memq number gnus-newsgroup-replied)
4411 ((memq number gnus-newsgroup-forwarded)
4412 gnus-forwarded-mark)
4413 ((memq number gnus-newsgroup-saved)
4415 ((memq number gnus-newsgroup-recent)
4417 ((memq number gnus-newsgroup-unseen)
4420 gnus-tmp-from (mail-header-from gnus-tmp-header)
4423 ((string-match "<[^>]+> *$" gnus-tmp-from)
4424 (setq beg-match (match-beginning 0))
4425 (or (and (string-match "^\".+\"" gnus-tmp-from)
4426 (substring gnus-tmp-from 1 (1- (match-end 0))))
4427 (substring gnus-tmp-from 0 beg-match)))
4428 ((string-match "(.+)" gnus-tmp-from)
4429 (substring gnus-tmp-from
4430 (1+ (match-beginning 0)) (1- (match-end 0))))
4432 gnus-tmp-thread-tree-header-string
4434 ((not gnus-show-threads) "")
4435 ((zerop gnus-tmp-level)
4437 (or gnus-sum-thread-tree-root subject)
4438 (or gnus-sum-thread-tree-single-indent subject)))
4440 (concat (apply 'concat
4441 (mapcar (lambda (item)
4443 gnus-sum-thread-tree-vertical
4444 gnus-sum-thread-tree-indent))
4445 (cdr (reverse tree-stack))))
4447 gnus-sum-thread-tree-leaf-with-other
4448 gnus-sum-thread-tree-single-leaf)))))
4449 (when (string= gnus-tmp-name "")
4450 (setq gnus-tmp-name gnus-tmp-from))
4451 (unless (numberp gnus-tmp-lines)
4452 (setq gnus-tmp-lines -1))
4453 (if (= gnus-tmp-lines -1)
4454 (setq gnus-tmp-lines "?")
4455 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4456 (gnus-put-text-property
4458 (progn (eval gnus-summary-line-format-spec) (point))
4459 'gnus-number number)
4462 (gnus-run-hooks 'gnus-summary-update-hook)
4465 (setq gnus-tmp-prev-subject subject)))
4467 (when (nth 1 thread)
4468 (push (list (max 0 gnus-tmp-level)
4469 (copy-list tree-stack)
4472 (push (if (nth 1 thread) 1 0) tree-stack)
4473 (incf gnus-tmp-level)
4474 (setq threads (if thread-end nil (cdar thread)))
4476 (setq gnus-tmp-level 0)))))
4477 (gnus-message 7 "Generating summary...done"))
4479 (defun gnus-summary-prepare-unthreaded (headers)
4480 "Generate an unthreaded summary buffer based on HEADERS."
4481 (let (header number mark)
4486 ;; We may have to root out some bad articles...
4487 (when (memq (setq number (mail-header-number
4488 (setq header (pop headers))))
4489 gnus-newsgroup-limit)
4490 ;; Mark article as read when it has a low score.
4491 (when (and gnus-summary-mark-below
4492 (< (or (cdr (assq number gnus-newsgroup-scored))
4493 gnus-summary-default-score 0)
4494 gnus-summary-mark-below)
4495 (not (gnus-summary-article-ancient-p number)))
4496 (setq gnus-newsgroup-unreads
4497 (delq number gnus-newsgroup-unreads))
4498 (if gnus-newsgroup-auto-expire
4499 (push number gnus-newsgroup-expirable)
4500 (push (cons number gnus-low-score-mark)
4501 gnus-newsgroup-reads)))
4503 (setq mark (gnus-article-mark number))
4504 (push (gnus-data-make number mark (1+ (point)) header 0)
4505 gnus-newsgroup-data)
4506 (gnus-summary-insert-line
4508 mark (memq number gnus-newsgroup-replied)
4509 (memq number gnus-newsgroup-expirable)
4510 (mail-header-subject header) nil
4511 (cdr (assq number gnus-newsgroup-scored))
4512 (memq number gnus-newsgroup-processable))))))
4514 (defun gnus-summary-remove-list-identifiers ()
4515 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4516 (let ((regexp (if (consp gnus-list-identifiers)
4517 (mapconcat 'identity gnus-list-identifiers " *\\|")
4518 gnus-list-identifiers))
4521 (dolist (header gnus-newsgroup-headers)
4522 (setq subject (mail-header-subject header)
4524 (while (string-match
4525 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4528 (concat (substring subject 0 (match-beginning 2))
4529 (substring subject (match-end 0)))
4533 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4535 (concat (substring subject 0 (match-beginning 1))
4536 (substring subject (match-end 1)))))
4538 (mail-header-set-subject header subject))))))
4540 (defun gnus-fetch-headers (articles)
4541 "Fetch headers of ARTICLES."
4542 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4543 (gnus-message 5 "Fetching headers for %s..." name)
4546 (setq gnus-headers-retrieved-by
4547 (gnus-retrieve-headers
4548 articles gnus-newsgroup-name
4549 ;; We might want to fetch old headers, but
4550 ;; not if there is only 1 article.
4552 (not (eq gnus-fetch-old-headers 'some))
4553 (not (numberp gnus-fetch-old-headers)))
4554 (> (length articles) 1))
4555 gnus-fetch-old-headers))))
4556 (gnus-get-newsgroup-headers-xover
4557 articles nil nil gnus-newsgroup-name t)
4558 (gnus-get-newsgroup-headers))
4559 (gnus-message 5 "Fetching headers for %s...done" name))))
4561 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4562 "Select newsgroup GROUP.
4563 If READ-ALL is non-nil, all articles in the group are selected.
4564 If SELECT-ARTICLES, only select those articles from GROUP."
4565 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4566 ;;!!! Dirty hack; should be removed.
4567 (gnus-summary-ignore-duplicates
4568 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4570 gnus-summary-ignore-duplicates))
4571 (info (nth 2 entry))
4572 articles fetched-articles cached)
4574 (unless (gnus-check-server
4575 (set (make-local-variable 'gnus-current-select-method)
4576 (gnus-find-method-for-group group)))
4577 (error "Couldn't open server"))
4579 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4580 (gnus-activate-group group) ; Or we can activate it...
4581 (progn ; Or we bug out.
4582 (when (equal major-mode 'gnus-summary-mode)
4583 (kill-buffer (current-buffer)))
4584 (error "Couldn't activate group %s: %s"
4585 group (gnus-status-message group))))
4587 (unless (gnus-request-group group t)
4588 (when (equal major-mode 'gnus-summary-mode)
4589 (kill-buffer (current-buffer)))
4590 (error "Couldn't request group %s: %s"
4591 group (gnus-status-message group)))
4593 (setq gnus-newsgroup-name group
4594 gnus-newsgroup-unselected nil
4595 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4597 (let ((display (gnus-group-find-parameter group 'display)))
4598 (setq gnus-newsgroup-display
4600 ((not (zerop (or (car-safe read-all) 0)))
4601 ;; The user entered the group with C-u SPC/RET, let's show
4607 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4609 ;; The following is probably the "correct" solution, but
4610 ;; it makes Gnus fetch all headers and then limit the
4611 ;; articles (which is slow), so instead we hack the
4612 ;; select-articles parameter instead. -- Simon Josefsson
4615 ;; (gnus-byte-compile
4616 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4618 (setq select-articles
4619 (gnus-uncompress-range
4620 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4624 (cdr (gnus-active group)))))
4629 (gnus-summary-setup-default-charset)
4631 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4632 (when (gnus-virtual-group-p group)
4633 (setq cached gnus-newsgroup-cached))
4635 (setq gnus-newsgroup-unreads
4636 (gnus-set-difference
4637 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4638 gnus-newsgroup-dormant))
4640 (setq gnus-newsgroup-processable nil)
4642 (gnus-update-read-articles group gnus-newsgroup-unreads)
4644 ;; Adjust and set lists of article marks.
4646 (gnus-adjust-marked-articles info))
4648 (if (setq articles select-articles)
4649 (setq gnus-newsgroup-unselected
4650 (gnus-sorted-intersection
4651 gnus-newsgroup-unreads
4652 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4653 (setq articles (gnus-articles-to-read group read-all)))
4657 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4659 ((eq articles 0) nil)
4661 ;; Init the dependencies hash table.
4662 (setq gnus-newsgroup-dependencies
4663 (gnus-make-hashtable (length articles)))
4664 (gnus-set-global-variables)
4665 ;; Retrieve the headers and read them in.
4666 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4668 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4670 (setq gnus-newsgroup-cached cached))
4672 ;; Suppress duplicates?
4673 (when gnus-suppress-duplicates
4674 (gnus-dup-suppress-articles))
4676 ;; Set the initial limit.
4677 (setq gnus-newsgroup-limit (copy-sequence articles))
4678 ;; Remove canceled articles from the list of unread articles.
4679 (setq fetched-articles
4680 (mapcar (lambda (headers) (mail-header-number headers))
4681 gnus-newsgroup-headers))
4682 (setq gnus-newsgroup-articles fetched-articles)
4683 (setq gnus-newsgroup-unreads
4684 (gnus-set-sorted-intersection
4685 gnus-newsgroup-unreads fetched-articles))
4687 ;; The `seen' marks are treated specially.
4688 (if (not gnus-newsgroup-seen)
4689 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4690 (dolist (article gnus-newsgroup-articles)
4691 (unless (gnus-member-of-range article gnus-newsgroup-seen)
4692 (push article gnus-newsgroup-unseen)))
4693 (setq gnus-newsgroup-unseen (nreverse gnus-newsgroup-unseen)))
4695 ;; Removed marked articles that do not exist.
4696 (gnus-update-missing-marks
4697 (gnus-sorted-complement fetched-articles articles))
4698 ;; We might want to build some more threads first.
4699 (when (and gnus-fetch-old-headers
4700 (eq gnus-headers-retrieved-by 'nov))
4701 (if (eq gnus-fetch-old-headers 'invisible)
4702 (gnus-build-all-threads)
4703 (gnus-build-old-threads)))
4704 ;; Let the Gnus agent mark articles as read.
4706 (gnus-agent-get-undownloaded-list))
4707 ;; Remove list identifiers from subject
4708 (when gnus-list-identifiers
4709 (gnus-summary-remove-list-identifiers))
4710 ;; Check whether auto-expire is to be done in this group.
4711 (setq gnus-newsgroup-auto-expire
4712 (gnus-group-auto-expirable-p group))
4713 ;; Set up the article buffer now, if necessary.
4714 (unless gnus-single-article-buffer
4715 (gnus-article-setup-buffer))
4716 ;; First and last article in this newsgroup.
4717 (when gnus-newsgroup-headers
4718 (setq gnus-newsgroup-begin
4719 (mail-header-number (car gnus-newsgroup-headers))
4722 (gnus-last-element gnus-newsgroup-headers))))
4723 ;; GROUP is successfully selected.
4724 (or gnus-newsgroup-headers t)))))
4726 (defun gnus-summary-display-make-predicate (display)
4727 (require 'gnus-agent)
4728 (when (= (length display) 1)
4729 (setq display (car display)))
4730 (unless gnus-summary-display-cache
4731 (dolist (elem (append (list (cons 'read 'read)
4732 (cons 'unseen 'unseen))
4733 gnus-article-mark-lists))
4734 (push (cons (cdr elem)
4736 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4737 gnus-summary-display-cache)))
4738 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4739 (gnus-get-predicate display)))
4741 ;; Uses the dynamically bound `number' variable.
4743 (defun gnus-article-marked-p (type &optional article)
4744 (let ((article (or article number)))
4747 (memq article gnus-newsgroup-marked))
4749 (memq article gnus-newsgroup-unsendable))
4750 ((eq type 'undownload)
4751 (memq article gnus-newsgroup-undownloaded))
4752 ((eq type 'download)
4753 (memq article gnus-newsgroup-downloadable))
4755 (memq article gnus-newsgroup-unreads))
4757 (memq article gnus-newsgroup-reads))
4759 (memq article gnus-newsgroup-dormant) )
4761 (memq article gnus-newsgroup-expirable))
4763 (memq article gnus-newsgroup-replied))
4765 (memq article gnus-newsgroup-killed))
4766 ((eq type 'bookmark)
4767 (assq article gnus-newsgroup-bookmarks))
4769 (assq article gnus-newsgroup-scored))
4771 (memq article gnus-newsgroup-saved))
4773 (memq article gnus-newsgroup-cached))
4775 (memq article gnus-newsgroup-forwarded))
4777 (not (memq article gnus-newsgroup-unseen)))
4779 (memq article gnus-newsgroup-recent))
4782 (defun gnus-articles-to-read (group &optional read-all)
4783 "Find out what articles the user wants to read."
4785 ;; Select all articles if `read-all' is non-nil, or if there
4786 ;; are no unread articles.
4788 (and (zerop (length gnus-newsgroup-marked))
4789 (zerop (length gnus-newsgroup-unreads)))
4790 (eq gnus-newsgroup-display 'gnus-not-ignore))
4791 ;; We want to select the headers for all the articles in
4792 ;; the group, so we select either all the active
4793 ;; articles in the group, or (if that's nil), the
4794 ;; articles in the cache.
4796 (gnus-uncompress-range (gnus-active group))
4797 (gnus-cache-articles-in-group group))
4798 ;; Select only the "normal" subset of articles.
4799 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4800 (copy-sequence gnus-newsgroup-unreads))
4802 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4803 (scored (length scored-list))
4804 (number (length articles))
4805 (marked (+ (length gnus-newsgroup-marked)
4806 (length gnus-newsgroup-dormant)))
4814 ((and (or (<= scored marked) (= scored number))
4815 (numberp gnus-large-newsgroup)
4816 (> number gnus-large-newsgroup))
4820 "How many articles from %s (default %d): "
4822 (gnus-group-decoded-name gnus-newsgroup-name)
4825 (if (string-match "^[ \t]*$" input) number input)))
4826 ((and (> scored marked) (< scored number)
4827 (> (- scored number) 20))
4830 (format "%s %s (%d scored, %d total): "
4831 "How many articles from"
4832 (gnus-group-decoded-name group)
4834 (if (string-match "^[ \t]*$" input)
4838 (message "Quit getting the articles to read")
4840 (setq select (if (stringp select) (string-to-number select) select))
4841 (if (or (null select) (zerop select))
4843 (if (and (not (zerop scored)) (<= (abs select) scored))
4845 (setq articles (sort scored-list '<))
4846 (setq number (length articles)))
4847 (setq articles (copy-sequence articles)))
4849 (when (< (abs select) number)
4851 ;; Select the N oldest articles.
4852 (setcdr (nthcdr (1- (abs select)) articles) nil)
4853 ;; Select the N most recent articles.
4854 (setq articles (nthcdr (- number select) articles))))
4855 (setq gnus-newsgroup-unselected
4856 (gnus-sorted-intersection
4857 gnus-newsgroup-unreads
4858 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4859 (when gnus-alter-articles-to-read-function
4860 (setq gnus-newsgroup-unreads
4862 (funcall gnus-alter-articles-to-read-function
4863 gnus-newsgroup-name gnus-newsgroup-unreads)
4867 (defun gnus-killed-articles (killed articles)
4870 (when (inline (gnus-member-of-range (car articles) killed))
4871 (push (car articles) out))
4872 (setq articles (cdr articles)))
4875 (defun gnus-uncompress-marks (marks)
4876 "Uncompress the mark ranges in MARKS."
4877 (let ((uncompressed '(score bookmark))
4880 (if (memq (caar marks) uncompressed)
4881 (push (car marks) out)
4882 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4883 (setq marks (cdr marks)))
4886 (defun gnus-article-mark-to-type (mark)
4887 "Return the type of MARK."
4888 (or (cadr (assq mark gnus-article-special-mark-lists))
4891 (defun gnus-article-unpropagatable-p (mark)
4892 "Return whether MARK should be propagated to backend."
4893 (memq mark gnus-article-unpropagated-mark-lists))
4895 (defun gnus-adjust-marked-articles (info)
4896 "Set all article lists and remove all marks that are no longer valid."
4897 (let* ((marked-lists (gnus-info-marks info))
4898 (active (gnus-active (gnus-info-group info)))
4901 (types gnus-article-mark-lists)
4902 marks var articles article mark mark-type)
4904 (dolist (marks marked-lists)
4905 (setq mark (car marks)
4906 mark-type (gnus-article-mark-to-type mark)
4907 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4909 ;; We set the variable according to the type of the marks list,
4910 ;; and then adjust the marks to a subset of the active articles.
4912 ;; Adjust "simple" lists.
4913 ((eq mark-type 'list)
4914 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4915 (when (memq mark '(tick dormant expire reply save))
4917 (when (or (< (setq article (pop articles)) min) (> article max))
4918 (set var (delq article (symbol-value var)))))))
4920 ((eq mark-type 'tuple)
4921 (set var (setq articles (cdr marks)))
4922 (when (not (listp (cdr (symbol-value var))))
4923 (set var (list (symbol-value var))))
4924 (when (not (listp (cdr articles)))
4925 (setq articles (list articles)))
4927 (when (or (not (consp (setq article (pop articles))))
4928 (< (car article) min)
4929 (> (car article) max))
4930 (set var (delq article (symbol-value var))))))
4931 ;; Adjust ranges (sloppily).
4932 ((eq mark-type 'range)
4935 (setq articles (cdr marks))
4936 (while (and articles
4937 (or (and (consp (car articles))
4938 (> min (cdar articles)))
4939 (and (numberp (car articles))
4940 (> min (car articles)))))
4942 (set var articles))))))))
4944 (defun gnus-update-missing-marks (missing)
4945 "Go through the list of MISSING articles and remove them from the mark lists."
4948 ;; Go through all types.
4949 (dolist (elem gnus-article-mark-lists)
4950 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4951 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4952 (when (symbol-value var)
4953 ;; This list has articles. So we delete all missing
4954 ;; articles from it.
4957 (set var (delq (pop m) (symbol-value var))))))))))
4959 (defun gnus-update-marks ()
4960 "Enter the various lists of marked articles into the newsgroup info list."
4961 (let ((types gnus-article-mark-lists)
4962 (info (gnus-get-info gnus-newsgroup-name))
4963 type list newmarked symbol delta-marks)
4965 ;; Add all marks lists to the list of marks lists.
4966 (while (setq type (pop types))
4967 (setq list (symbol-value
4969 (intern (format "gnus-newsgroup-%s" (car type))))))
4972 ;; Get rid of the entries of the articles that have the
4974 (when (and (eq (cdr type) 'score)
4978 (prev (cons nil list))
4981 (if (or (not (consp (car arts)))
4982 (= (cdar arts) gnus-summary-default-score))
4983 (setcdr prev (cdr arts))
4985 (setq arts (cdr arts)))
4986 (setq list (cdr all)))))
4988 (when (eq (cdr type) 'seen)
4989 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
4991 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
4992 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4994 (when (and (gnus-check-backend-function
4995 'request-set-mark gnus-newsgroup-name)
4996 (not (gnus-article-unpropagatable-p (cdr type))))
4997 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4998 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4999 (add (gnus-remove-from-range
5000 (gnus-copy-sequence list) old)))
5002 (push (list add 'add (list (cdr type))) delta-marks))
5004 (push (list del 'del (list (cdr type))) delta-marks))))
5007 (push (cons (cdr type) list) newmarked)))
5010 (unless (gnus-check-group gnus-newsgroup-name)
5011 (error "Can't open server for %s" gnus-newsgroup-name))
5012 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5014 ;; Enter these new marks into the info of the group.
5016 (setcar (nthcdr 3 info) newmarked)
5017 ;; Add the marks lists to the end of the info.
5019 (setcdr (nthcdr 2 info) (list newmarked))))
5021 ;; Cut off the end of the info if there's nothing else there.
5025 (when (nthcdr (decf i) info)
5026 (setcdr (nthcdr i info) nil)))))))
5028 (defun gnus-set-mode-line (where)
5029 "Set the mode line of the article or summary buffers.
5030 If WHERE is `summary', the summary mode line format will be used."
5031 ;; Is this mode line one we keep updated?
5032 (when (and (memq where gnus-updated-mode-lines)
5034 (intern (format "gnus-%s-mode-line-format-spec" where))))
5037 ;; We evaluate this in the summary buffer since these
5038 ;; variables are buffer-local to that buffer.
5039 (set-buffer gnus-summary-buffer)
5040 ;; We bind all these variables that are used in the `eval' form
5042 (let* ((mformat (symbol-value
5044 (format "gnus-%s-mode-line-format-spec" where))))
5045 (gnus-tmp-group-name (gnus-group-decoded-name
5046 gnus-newsgroup-name))
5047 (gnus-tmp-article-number (or gnus-current-article 0))
5048 (gnus-tmp-unread gnus-newsgroup-unreads)
5049 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5050 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5051 (gnus-tmp-unread-and-unselected
5052 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5053 (zerop gnus-tmp-unselected))
5055 ((zerop gnus-tmp-unselected)
5056 (format "{%d more}" gnus-tmp-unread-and-unticked))
5057 (t (format "{%d(+%d) more}"
5058 gnus-tmp-unread-and-unticked
5059 gnus-tmp-unselected))))
5061 (if (and gnus-current-headers
5062 (vectorp gnus-current-headers))
5063 (gnus-mode-string-quote
5064 (mail-header-subject gnus-current-headers))
5066 bufname-length max-len
5067 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5068 (setq mode-string (eval mformat))
5069 (setq bufname-length (if (string-match "%b" mode-string)
5072 (if (eq where 'summary)
5074 (get-buffer gnus-article-buffer))))
5077 (setq max-len (max 4 (if gnus-mode-non-string-length
5079 gnus-mode-non-string-length
5081 (length mode-string))))
5082 ;; We might have to chop a bit of the string off...
5083 (when (> (length mode-string) max-len)
5085 (concat (truncate-string-to-width mode-string (- max-len 3))
5087 ;; Pad the mode string a bit.
5088 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5089 ;; Update the mode line.
5090 (setq mode-line-buffer-identification
5091 (gnus-mode-line-buffer-identification (list mode-string)))
5092 (set-buffer-modified-p t))))
5094 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5095 "Go through the HEADERS list and add all Xrefs to a hash table.
5096 The resulting hash table is returned, or nil if no Xrefs were found."
5097 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5098 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5099 (xref-hashtb (gnus-make-hashtable))
5100 start group entry number xrefs header)
5102 (setq header (pop headers))
5103 (when (and (setq xrefs (mail-header-xref header))
5104 (not (memq (setq number (mail-header-number header))
5107 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5108 (setq start (match-end 0))
5109 (setq group (if prefix
5110 (concat prefix (substring xrefs (match-beginning 1)
5112 (substring xrefs (match-beginning 1) (match-end 1))))
5114 (string-to-int (substring xrefs (match-beginning 2)
5116 (if (setq entry (gnus-gethash group xref-hashtb))
5117 (setcdr entry (cons number (cdr entry)))
5118 (gnus-sethash group (cons number nil) xref-hashtb)))))
5119 (and start xref-hashtb)))
5121 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5122 "Look through all the headers and mark the Xrefs as read."
5123 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5124 name entry info xref-hashtb idlist method nth4)
5126 (set-buffer gnus-group-buffer)
5127 (when (setq xref-hashtb
5128 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5131 (unless (string= from-newsgroup (setq name (symbol-name group)))
5132 (setq idlist (symbol-value group))
5133 ;; Dead groups are not updated.
5135 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5137 (when (stringp (setq nth4 (gnus-info-method info)))
5138 (setq nth4 (gnus-server-to-method nth4))))
5139 ;; Only do the xrefs if the group has the same
5140 ;; select method as the group we have just read.
5141 (or (gnus-methods-equal-p
5142 nth4 (gnus-find-method-for-group from-newsgroup))
5144 (equal nth4 (setq method (gnus-find-method-for-group
5146 (and (equal (car nth4) (car method))
5147 (equal (nth 1 nth4) (nth 1 method))))
5148 gnus-use-cross-reference
5149 (or (not (eq gnus-use-cross-reference t))
5151 ;; Only do cross-references on subscribed
5152 ;; groups, if that is what is wanted.
5153 (<= (gnus-info-level info) gnus-level-subscribed))
5154 (gnus-group-make-articles-read name idlist))))
5157 (defun gnus-compute-read-articles (group articles)
5158 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5159 (info (nth 2 entry))
5160 (active (gnus-active group))
5163 ;; First peel off all invalid article numbers.
5165 (let ((ids articles)
5167 (while (setq id (pop ids))
5168 (when (and first (> id (cdr active)))
5169 ;; We'll end up in this situation in one particular
5170 ;; obscure situation. If you re-scan a group and get
5171 ;; a new article that is cross-posted to a different
5172 ;; group that has not been re-scanned, you might get
5173 ;; crossposted article that has a higher number than
5174 ;; Gnus believes possible. So we re-activate this
5175 ;; group as well. This might mean doing the
5176 ;; crossposting thingy will *increase* the number
5177 ;; of articles in some groups. Tsk, tsk.
5178 (setq active (or (gnus-activate-group group) active)))
5179 (when (or (> id (cdr active))
5180 (< id (car active)))
5181 (setq articles (delq id articles))))))
5182 ;; If the read list is nil, we init it.
5184 (null (gnus-info-read info))
5186 (setq ninfo (cons 1 (1- (car active))))
5187 (setq ninfo (gnus-info-read info)))
5188 ;; Then we add the read articles to the range.
5190 ninfo (setq articles (sort articles '<))))))
5192 (defun gnus-group-make-articles-read (group articles)
5193 "Update the info of GROUP to say that ARTICLES are read."
5195 (entry (gnus-gethash group gnus-newsrc-hashtb))
5196 (info (nth 2 entry))
5197 (active (gnus-active group))
5200 (setq range (gnus-compute-read-articles group articles))
5202 (set-buffer gnus-group-buffer)
5205 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5206 (gnus-info-set-read ',info ',(gnus-info-read info))
5207 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5208 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5209 (gnus-group-update-group ,group t))))
5210 ;; Add the read articles to the range.
5211 (gnus-info-set-read info range)
5212 (gnus-request-set-mark group (list (list range 'add '(read))))
5213 ;; Then we have to re-compute how many unread
5214 ;; articles there are in this group.
5218 (setq num (- (1+ (cdr active)) (car active))))
5219 ((not (listp (cdr range)))
5220 (setq num (- (cdr active) (- (1+ (cdr range))
5224 (if (numberp (car range))
5226 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5227 (setq range (cdr range)))
5228 (setq num (- (cdr active) num))))
5229 ;; Update the number of unread articles.
5231 ;; Update the group buffer.
5232 (gnus-group-update-group group t)))))
5234 (defvar gnus-newsgroup-none-id 0)
5236 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5237 (let ((cur nntp-server-buffer)
5240 (save-excursion (set-buffer gnus-summary-buffer)
5241 gnus-newsgroup-dependencies)))
5243 (mail-parse-charset gnus-newsgroup-charset)
5244 (mail-parse-ignored-charsets
5245 (save-excursion (condition-case nil
5246 (set-buffer gnus-summary-buffer)
5248 gnus-newsgroup-ignored-charsets)))
5250 (set-buffer nntp-server-buffer)
5251 ;; Translate all TAB characters into SPACE characters.
5252 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5253 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5254 (gnus-run-hooks 'gnus-parse-headers-hook)
5255 (let ((case-fold-search t)
5256 in-reply-to header p lines chars)
5257 (goto-char (point-min))
5258 ;; Search to the beginning of the next header. Error messages
5259 ;; do not begin with 2 or 3.
5260 (while (re-search-forward "^[23][0-9]+ " nil t)
5263 ;; This implementation of this function, with nine
5264 ;; search-forwards instead of the one re-search-forward and
5265 ;; a case (which basically was the old function) is actually
5266 ;; about twice as fast, even though it looks messier. You
5267 ;; can't have everything, I guess. Speed and elegance
5268 ;; doesn't always go hand in hand.
5277 (narrow-to-region (point)
5278 (or (and (search-forward "\n.\n" nil t)
5284 (if (search-forward "\nsubject:" nil t)
5285 (funcall gnus-decode-encoded-word-function
5286 (nnheader-header-value))
5291 (if (search-forward "\nfrom:" nil t)
5292 (funcall gnus-decode-encoded-word-function
5293 (nnheader-header-value))
5298 (if (search-forward "\ndate:" nil t)
5299 (nnheader-header-value) ""))
5303 (setq id (if (re-search-forward
5304 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5305 ;; We do it this way to make sure the Message-ID
5306 ;; is (somewhat) syntactically valid.
5307 (buffer-substring (match-beginning 1)
5309 ;; If there was no message-id, we just fake one
5310 ;; to make subsequent routines simpler.
5311 (nnheader-generate-fake-message-id))))
5315 (if (search-forward "\nreferences:" nil t)
5319 (nnheader-header-value)
5324 (search-backward ">" end t)
5327 (search-backward "<" end t)
5329 ;; Get the references from the in-reply-to header if there
5330 ;; were no references and the in-reply-to header looks
5332 (if (and (search-forward "\nin-reply-to:" nil t)
5333 (setq in-reply-to (nnheader-header-value))
5334 (string-match "<[^>]+>" in-reply-to))
5336 (setq ref (substring in-reply-to (match-beginning 0)
5338 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5339 (setq ref2 (substring in-reply-to (match-beginning 0)
5341 (when (> (length ref2) (length ref))
5348 (if (search-forward "\nchars: " nil t)
5349 (if (numberp (setq chars (ignore-errors (read cur))))
5355 (if (search-forward "\nlines: " nil t)
5356 (if (numberp (setq lines (ignore-errors (read cur))))
5362 (and (search-forward "\nxref:" nil t)
5363 (nnheader-header-value)))
5365 (when gnus-extra-headers
5366 (let ((extra gnus-extra-headers)
5370 (when (search-forward
5371 (concat "\n" (symbol-name (car extra)) ":") nil t)
5372 (push (cons (car extra) (nnheader-header-value))
5376 (when (equal id ref)
5379 (when gnus-alter-header-function
5380 (funcall gnus-alter-header-function header)
5381 (setq id (mail-header-id header)
5382 ref (gnus-parent-id (mail-header-references header))))
5385 (gnus-dependencies-add-header
5386 header dependencies force-new))
5387 (push header headers))
5388 (goto-char (point-max))
5390 (nreverse headers)))))
5392 ;; Goes through the xover lines and returns a list of vectors
5393 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5394 force-new dependencies
5395 group also-fetch-heads)
5396 "Parse the news overview data in the server buffer.
5397 Return a list of headers that match SEQUENCE (see
5398 `nntp-retrieve-headers')."
5399 ;; Get the Xref when the users reads the articles since most/some
5400 ;; NNTP servers do not include Xrefs when using XOVER.
5401 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5402 (let ((mail-parse-charset gnus-newsgroup-charset)
5403 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5404 (cur nntp-server-buffer)
5405 (dependencies (or dependencies gnus-newsgroup-dependencies))
5407 ((eq gnus-read-all-available-headers t)
5409 ((stringp gnus-read-all-available-headers)
5410 (string-match gnus-read-all-available-headers group))
5413 number headers header)
5415 (set-buffer nntp-server-buffer)
5416 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5417 ;; Allow the user to mangle the headers before parsing them.
5418 (gnus-run-hooks 'gnus-parse-headers-hook)
5419 (goto-char (point-min))
5422 (while (and (or sequence allp)
5424 (setq number (read cur))
5426 (while (and sequence
5427 (< (car sequence) number))
5428 (setq sequence (cdr sequence))))
5431 (eq number (car sequence))))
5433 (setq sequence (cdr sequence))
5434 (setq header (inline
5435 (gnus-nov-parse-line
5436 number dependencies force-new)))))
5437 (push header headers))
5440 (gnus-error 4 "Strange nov line (%d)"
5441 (count-lines (point-min) (point)))))
5443 ;; A common bug in inn is that if you have posted an article and
5444 ;; then retrieves the active file, it will answer correctly --
5445 ;; the new article is included. However, a NOV entry for the
5446 ;; article may not have been generated yet, so this may fail.
5447 ;; We work around this problem by retrieving the last few
5448 ;; headers using HEAD.
5449 (if (or (not also-fetch-heads)
5451 ;; We (probably) got all the headers.
5453 (let ((gnus-nov-is-evil t))
5456 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5457 (gnus-get-newsgroup-headers))))))))
5459 (defun gnus-article-get-xrefs ()
5460 "Fill in the Xref value in `gnus-current-headers', if necessary.
5461 This is meant to be called in `gnus-article-internal-prepare-hook'."
5462 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5463 gnus-current-headers)))
5464 (or (not gnus-use-cross-reference)
5466 (and (mail-header-xref headers)
5467 (not (string= (mail-header-xref headers) "")))
5468 (let ((case-fold-search t)
5471 (nnheader-narrow-to-headers)
5472 (goto-char (point-min))
5473 (when (or (and (not (eobp))
5474 (eq (downcase (char-after)) ?x)
5475 (looking-at "Xref:"))
5476 (search-forward "\nXref:" nil t))
5477 (goto-char (1+ (match-end 0)))
5478 (setq xref (buffer-substring (point)
5479 (progn (end-of-line) (point))))
5480 (mail-header-set-xref headers xref)))))))
5482 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5483 "Find article ID and insert the summary line for that article.
5484 OLD-HEADER can either be a header or a line number to insert
5485 the subject line on."
5486 (let* ((line (and (numberp old-header) old-header))
5487 (old-header (and (vectorp old-header) old-header))
5488 (header (cond ((and old-header use-old-header)
5491 (gnus-number-to-header id))
5492 (gnus-number-to-header id))
5494 (gnus-read-header id))))
5495 (number (and (numberp id) id))
5498 ;; Rebuild the thread that this article is part of and go to the
5499 ;; article we have fetched.
5500 (when (and (not gnus-show-threads)
5503 (setq d (gnus-data-find (mail-header-number old-header))))
5504 (goto-char (gnus-data-pos d))
5507 (- (gnus-point-at-bol)
5509 (1+ (gnus-point-at-eol))
5510 (gnus-delete-line))))))
5512 (mail-header-set-number header (mail-header-number old-header)))
5513 (setq gnus-newsgroup-sparse
5514 (delq (setq number (mail-header-number header))
5515 gnus-newsgroup-sparse))
5516 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5517 (push number gnus-newsgroup-limit)
5518 (gnus-rebuild-thread (mail-header-id header) line)
5519 (gnus-summary-goto-subject number nil t))
5520 (when (and (numberp number)
5522 ;; We have to update the boundaries even if we can't fetch the
5523 ;; article if ID is a number -- so that the next `P' or `N'
5524 ;; command will fetch the previous (or next) article even
5525 ;; if the one we tried to fetch this time has been canceled.
5526 (when (> number gnus-newsgroup-end)
5527 (setq gnus-newsgroup-end number))
5528 (when (< number gnus-newsgroup-begin)
5529 (setq gnus-newsgroup-begin number))
5530 (setq gnus-newsgroup-unselected
5531 (delq number gnus-newsgroup-unselected)))
5532 ;; Report back a success?
5533 (and header (mail-header-number header))))
5535 ;;; Process/prefix in the summary buffer
5537 (defun gnus-summary-work-articles (n)
5538 "Return a list of articles to be worked upon.
5539 The prefix argument, the list of process marked articles, and the
5540 current article will be taken into consideration."
5542 (set-buffer gnus-summary-buffer)
5545 ;; A numerical prefix has been given.
5546 (setq n (prefix-numeric-value n))
5547 (let ((backward (< n 0))
5548 (n (abs (prefix-numeric-value n)))
5553 (push (setq article (gnus-summary-article-number))
5556 (gnus-summary-find-prev nil article)
5557 (gnus-summary-find-next nil article)))
5559 (nreverse articles)))
5560 ((and (gnus-region-active-p) (mark))
5561 (message "region active")
5562 ;; Work on the region between point and mark.
5563 (let ((max (max (point) (mark)))
5566 (goto-char (min (min (point) (mark))))
5569 (push (setq article (gnus-summary-article-number)) articles)
5570 (gnus-summary-find-next nil article)
5572 (nreverse articles))))
5573 (gnus-newsgroup-processable
5574 ;; There are process-marked articles present.
5575 ;; Save current state.
5576 (gnus-summary-save-process-mark)
5578 (reverse gnus-newsgroup-processable))
5580 ;; Just return the current article.
5581 (list (gnus-summary-article-number))))))
5583 (defmacro gnus-summary-iterate (arg &rest forms)
5584 "Iterate over the process/prefixed articles and do FORMS.
5585 ARG is the interactive prefix given to the command. FORMS will be
5586 executed with point over the summary line of the articles."
5587 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5588 `(let ((,articles (gnus-summary-work-articles ,arg)))
5590 (gnus-summary-goto-subject (car ,articles))
5594 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5595 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5597 (defun gnus-summary-save-process-mark ()
5598 "Push the current set of process marked articles on the stack."
5600 (push (copy-sequence gnus-newsgroup-processable)
5601 gnus-newsgroup-process-stack))
5603 (defun gnus-summary-kill-process-mark ()
5604 "Push the current set of process marked articles on the stack and unmark."
5606 (gnus-summary-save-process-mark)
5607 (gnus-summary-unmark-all-processable))
5609 (defun gnus-summary-yank-process-mark ()
5610 "Pop the last process mark state off the stack and restore it."
5612 (unless gnus-newsgroup-process-stack
5613 (error "Empty mark stack"))
5614 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5616 (defun gnus-summary-process-mark-set (set)
5617 "Make SET into the current process marked articles."
5618 (gnus-summary-unmark-all-processable)
5620 (gnus-summary-set-process-mark (pop set))))
5622 ;;; Searching and stuff
5624 (defun gnus-summary-search-group (&optional backward use-level)
5625 "Search for next unread newsgroup.
5626 If optional argument BACKWARD is non-nil, search backward instead."
5628 (set-buffer gnus-group-buffer)
5629 (when (gnus-group-search-forward
5630 backward nil (if use-level (gnus-group-group-level) nil))
5631 (gnus-group-group-name))))
5633 (defun gnus-summary-best-group (&optional exclude-group)
5634 "Find the name of the best unread group.
5635 If EXCLUDE-GROUP, do not go to this group."
5637 (set-buffer gnus-group-buffer)
5639 (gnus-group-best-unread-group exclude-group))))
5641 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5642 (if backward (gnus-summary-find-prev)
5643 (let* ((dummy (gnus-summary-article-intangible-p))
5644 (article (or article (gnus-summary-article-number)))
5645 (arts (gnus-data-find-list article))
5647 (when (and (not dummy)
5648 (or (not gnus-summary-check-current)
5650 (not (gnus-data-unread-p (car arts)))))
5651 (setq arts (cdr arts)))
5656 (when (or (and undownloaded
5657 (eq gnus-undownloaded-mark
5658 (gnus-data-mark (car arts))))
5659 (gnus-data-unread-p (car arts)))
5660 (setq result (car arts)
5662 (setq arts (cdr arts)))
5665 (goto-char (gnus-data-pos result))
5666 (gnus-data-number result)))))
5668 (defun gnus-summary-find-prev (&optional unread article)
5669 (let* ((eobp (eobp))
5670 (article (or article (gnus-summary-article-number)))
5671 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5673 (when (and (not eobp)
5674 (or (not gnus-summary-check-current)
5676 (not (gnus-data-unread-p (car arts)))))
5677 (setq arts (cdr arts)))
5682 (when (gnus-data-unread-p (car arts))
5683 (setq result (car arts)
5685 (setq arts (cdr arts)))
5688 (goto-char (gnus-data-pos result))
5689 (gnus-data-number result))))
5691 (defun gnus-summary-find-subject (subject &optional unread backward article)
5692 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5693 (article (or article (gnus-summary-article-number)))
5694 (articles (gnus-data-list backward))
5695 (arts (gnus-data-find-list article articles))
5697 (when (or (not gnus-summary-check-current)
5699 (not (gnus-data-unread-p (car arts))))
5700 (setq arts (cdr arts)))
5702 (and (or (not unread)
5703 (gnus-data-unread-p (car arts)))
5704 (vectorp (gnus-data-header (car arts)))
5706 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5707 (setq result (car arts)
5709 (setq arts (cdr arts)))
5711 (goto-char (gnus-data-pos result))
5712 (gnus-data-number result))))
5714 (defun gnus-summary-search-forward (&optional unread subject backward)
5715 "Search forward for an article.
5716 If UNREAD, look for unread articles. If SUBJECT, look for
5717 articles with that subject. If BACKWARD, search backward instead."
5718 (cond (subject (gnus-summary-find-subject subject unread backward))
5719 (backward (gnus-summary-find-prev unread))
5720 (t (gnus-summary-find-next unread))))
5722 (defun gnus-recenter (&optional n)
5723 "Center point in window and redisplay frame.
5724 Also do horizontal recentering."
5726 (when (and gnus-auto-center-summary
5727 (not (eq gnus-auto-center-summary 'vertical)))
5728 (gnus-horizontal-recenter))
5731 (defun gnus-summary-recenter ()
5732 "Center point in the summary window.
5733 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5734 displayed, no centering will be performed."
5735 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5736 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5738 (let* ((top (cond ((< (window-height) 4) 0)
5739 ((< (window-height) 7) 1)
5740 (t (if (numberp gnus-auto-center-summary)
5741 gnus-auto-center-summary
5743 (height (1- (window-height)))
5744 (bottom (save-excursion (goto-char (point-max))
5745 (forward-line (- height))
5747 (window (get-buffer-window (current-buffer))))
5748 ;; The user has to want it.
5749 (when gnus-auto-center-summary
5750 (when (get-buffer-window gnus-article-buffer)
5751 ;; Only do recentering when the article buffer is displayed,
5752 ;; Set the window start to either `bottom', which is the biggest
5753 ;; possible valid number, or the second line from the top,
5754 ;; whichever is the least.
5755 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5756 (if (> bottom top-pos)
5757 ;; Keep the second line from the top visible
5758 (set-window-start window top-pos t)
5759 ;; Try to keep the bottom line visible; if it's partially
5760 ;; obscured, either scroll one more line to make it fully
5761 ;; visible, or revert to using TOP-POS.
5763 (goto-char (point-max))
5765 (let ((last-line-start (point)))
5767 (set-window-start window (point) t)
5768 (when (not (pos-visible-in-window-p last-line-start window))
5770 (set-window-start window (min (point) top-pos) t)))))))
5771 ;; Do horizontal recentering while we're at it.
5772 (when (and (get-buffer-window (current-buffer) t)
5773 (not (eq gnus-auto-center-summary 'vertical)))
5774 (let ((selected (selected-window)))
5775 (select-window (get-buffer-window (current-buffer) t))
5776 (gnus-summary-position-point)
5777 (gnus-horizontal-recenter)
5778 (select-window selected))))))
5780 (defun gnus-summary-jump-to-group (newsgroup)
5781 "Move point to NEWSGROUP in group mode buffer."
5782 ;; Keep update point of group mode buffer if visible.
5783 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5784 (save-window-excursion
5785 ;; Take care of tree window mode.
5786 (when (get-buffer-window gnus-group-buffer)
5787 (pop-to-buffer gnus-group-buffer))
5788 (gnus-group-jump-to-group newsgroup))
5790 ;; Take care of tree window mode.
5791 (if (get-buffer-window gnus-group-buffer)
5792 (pop-to-buffer gnus-group-buffer)
5793 (set-buffer gnus-group-buffer))
5794 (gnus-group-jump-to-group newsgroup))))
5796 ;; This function returns a list of article numbers based on the
5797 ;; difference between the ranges of read articles in this group and
5798 ;; the range of active articles.
5799 (defun gnus-list-of-unread-articles (group)
5800 (let* ((read (gnus-info-read (gnus-get-info group)))
5801 (active (or (gnus-active group) (gnus-activate-group group)))
5804 ;; If none are read, then all are unread.
5806 (setq first (car active))
5807 ;; If the range of read articles is a single range, then the
5808 ;; first unread article is the article after the last read
5809 ;; article. Sounds logical, doesn't it?
5810 (if (and (not (listp (cdr read)))
5811 (or (< (car read) (car active))
5812 (progn (setq read (list read))
5814 (setq first (max (car active) (1+ (cdr read))))
5815 ;; `read' is a list of ranges.
5816 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5819 (setq first (car active)))
5822 (while (< first nlast)
5824 (setq first (1+ first))))
5825 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5826 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5827 (setq read (cdr read)))))
5828 ;; And add the last unread articles.
5829 (while (<= first last)
5831 (setq first (1+ first)))
5832 ;; Return the list of unread articles.
5833 (delq 0 (nreverse unread))))
5835 (defun gnus-list-of-read-articles (group)
5836 "Return a list of unread, unticked and non-dormant articles."
5837 (let* ((info (gnus-get-info group))
5838 (marked (gnus-info-marks info))
5839 (active (gnus-active group)))
5841 (gnus-set-difference
5842 (gnus-sorted-complement
5843 (gnus-uncompress-range active)
5844 (gnus-list-of-unread-articles group))
5846 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5847 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5849 ;; Various summary commands
5851 (defun gnus-summary-select-article-buffer ()
5852 "Reconfigure windows to show article buffer."
5854 (if (not (gnus-buffer-live-p gnus-article-buffer))
5855 (error "There is no article buffer for this summary buffer")
5856 (gnus-configure-windows 'article)
5857 (select-window (get-buffer-window gnus-article-buffer))))
5859 (defun gnus-summary-universal-argument (arg)
5860 "Perform any operation on all articles that are process/prefixed."
5862 (let ((articles (gnus-summary-work-articles arg))
5869 (substitute-command-keys
5870 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5872 (gnus-error 1 "Undefined key")
5875 (gnus-summary-goto-subject (setq article (pop articles)))
5876 (let (gnus-newsgroup-processable)
5877 (command-execute func))
5878 (gnus-summary-remove-process-mark article)))))
5879 (gnus-summary-position-point))
5881 (defun gnus-summary-toggle-truncation (&optional arg)
5882 "Toggle truncation of summary lines.
5883 With arg, turn line truncation on iff arg is positive."
5885 (setq truncate-lines
5886 (if (null arg) (not truncate-lines)
5887 (> (prefix-numeric-value arg) 0)))
5890 (defun gnus-summary-reselect-current-group (&optional all rescan)
5891 "Exit and then reselect the current newsgroup.
5892 The prefix argument ALL means to select all articles."
5894 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5895 (error "Ephemeral groups can't be reselected"))
5896 (let ((current-subject (gnus-summary-article-number))
5897 (group gnus-newsgroup-name))
5898 (setq gnus-newsgroup-begin nil)
5900 ;; We have to adjust the point of group mode buffer because
5901 ;; point was moved to the next unread newsgroup by exiting.
5902 (gnus-summary-jump-to-group group)
5905 (gnus-group-get-new-news-this-group 1)))
5906 (gnus-group-read-group all t)
5907 (gnus-summary-goto-subject current-subject nil t)))
5909 (defun gnus-summary-rescan-group (&optional all)
5910 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5912 (gnus-summary-reselect-current-group all t))
5914 (defun gnus-summary-update-info (&optional non-destructive)
5916 (let ((group gnus-newsgroup-name))
5918 (when gnus-newsgroup-kill-headers
5919 (setq gnus-newsgroup-killed
5920 (gnus-compress-sequence
5922 (gnus-set-sorted-intersection
5923 (gnus-uncompress-range gnus-newsgroup-killed)
5924 (setq gnus-newsgroup-unselected
5925 (sort gnus-newsgroup-unselected '<)))
5926 (setq gnus-newsgroup-unreads
5927 (sort gnus-newsgroup-unreads '<)))
5929 (unless (listp (cdr gnus-newsgroup-killed))
5930 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5931 (let ((headers gnus-newsgroup-headers))
5932 ;; Set the new ranges of read articles.
5934 (set-buffer gnus-group-buffer)
5935 (gnus-undo-force-boundary))
5936 (gnus-update-read-articles
5937 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5938 ;; Set the current article marks.
5939 (let ((gnus-newsgroup-scored
5940 (if (and (not gnus-save-score)
5941 (not non-destructive))
5943 gnus-newsgroup-scored)))
5945 (gnus-update-marks)))
5946 ;; Do the cross-ref thing.
5947 (when gnus-use-cross-reference
5948 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5949 ;; Do not switch windows but change the buffer to work.
5950 (set-buffer gnus-group-buffer)
5951 (unless (gnus-ephemeral-group-p group)
5952 (gnus-group-update-group group)))))))
5954 (defun gnus-summary-save-newsrc (&optional force)
5955 "Save the current number of read/marked articles in the dribble buffer.
5956 The dribble buffer will then be saved.
5957 If FORCE (the prefix), also save the .newsrc file(s)."
5959 (gnus-summary-update-info t)
5961 (gnus-save-newsrc-file)
5962 (gnus-dribble-save)))
5964 (defun gnus-summary-exit (&optional temporary)
5965 "Exit reading current newsgroup, and then return to group selection mode.
5966 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5968 (gnus-set-global-variables)
5969 (when (gnus-buffer-live-p gnus-article-buffer)
5971 (set-buffer gnus-article-buffer)
5972 (mm-destroy-parts gnus-article-mime-handles)
5973 ;; Set it to nil for safety reason.
5974 (setq gnus-article-mime-handle-alist nil)
5975 (setq gnus-article-mime-handles nil)))
5976 (gnus-kill-save-kill-buffer)
5977 (gnus-async-halt-prefetch)
5978 (let* ((group gnus-newsgroup-name)
5979 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5982 (buf (current-buffer)))
5984 ;; Do adaptive scoring, and possibly save score files.
5985 (when gnus-newsgroup-adaptive
5986 (gnus-score-adaptive))
5987 (when gnus-use-scoring
5989 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5990 ;; If we have several article buffers, we kill them at exit.
5991 (unless gnus-single-article-buffer
5992 (gnus-kill-buffer gnus-original-article-buffer)
5993 (setq gnus-article-current nil))
5994 (when gnus-use-cache
5995 (gnus-cache-possibly-remove-articles)
5996 (gnus-cache-save-buffers))
5997 (gnus-async-prefetch-remove-group group)
5998 (when gnus-suppress-duplicates
5999 (gnus-dup-enter-articles))
6000 (when gnus-use-trees
6001 (gnus-tree-close group))
6002 (when gnus-use-cache
6003 (gnus-cache-write-active))
6004 ;; Remove entries for this group.
6005 (nnmail-purge-split-history (gnus-group-real-name group))
6006 ;; Make all changes in this group permanent.
6008 (gnus-run-hooks 'gnus-exit-group-hook)
6009 (gnus-summary-update-info))
6010 (gnus-close-group group)
6011 ;; Make sure where we were, and go to next newsgroup.
6012 (set-buffer gnus-group-buffer)
6014 (gnus-group-jump-to-group group))
6015 (gnus-run-hooks 'gnus-summary-exit-hook)
6016 (unless (or quit-config
6017 ;; If this group has disappeared from the summary
6018 ;; buffer, don't skip forwards.
6019 (not (string= group (gnus-group-group-name))))
6020 (gnus-group-next-unread-group 1))
6021 (setq group-point (point))
6024 ;; If we have several article buffers, we kill them at exit.
6025 (unless gnus-single-article-buffer
6026 (gnus-kill-buffer gnus-article-buffer)
6027 (gnus-kill-buffer gnus-original-article-buffer)
6028 (setq gnus-article-current nil))
6030 (if (not gnus-kill-summary-on-exit)
6032 (gnus-deaden-summary)
6034 ;; We set all buffer-local variables to nil. It is unclear why
6035 ;; this is needed, but if we don't, buffer-local variables are
6036 ;; not garbage-collected, it seems. This would the lead to en
6037 ;; ever-growing Emacs.
6038 (gnus-summary-clear-local-variables)
6039 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6040 (gnus-summary-clear-local-variables))
6041 (when (get-buffer gnus-article-buffer)
6042 (bury-buffer gnus-article-buffer))
6043 ;; We clear the global counterparts of the buffer-local
6044 ;; variables as well, just to be on the safe side.
6045 (set-buffer gnus-group-buffer)
6046 (gnus-summary-clear-local-variables)
6047 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6048 (gnus-summary-clear-local-variables)))
6049 (setq gnus-current-select-method gnus-select-method)
6050 (pop-to-buffer gnus-group-buffer)
6051 (if (not quit-config)
6053 (goto-char group-point)
6054 (gnus-configure-windows 'group 'force))
6055 (gnus-handle-ephemeral-exit quit-config))
6056 ;; Return to group mode buffer.
6057 (when (eq mode 'gnus-summary-mode)
6058 (gnus-kill-buffer buf))
6059 ;; Clear the current group name.
6061 (setq gnus-newsgroup-name nil)))))
6063 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6064 (defun gnus-summary-exit-no-update (&optional no-questions)
6065 "Quit reading current newsgroup without updating read article info."
6067 (let* ((group gnus-newsgroup-name)
6068 (quit-config (gnus-group-quit-config group)))
6069 (when (or no-questions
6071 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6072 (gnus-async-halt-prefetch)
6074 (delq 'gnus-summary-expire-articles
6075 (copy-sequence gnus-summary-prepare-exit-hook)))
6076 (when (gnus-buffer-live-p gnus-article-buffer)
6078 (set-buffer gnus-article-buffer)
6079 (mm-destroy-parts gnus-article-mime-handles)
6080 ;; Set it to nil for safety reason.
6081 (setq gnus-article-mime-handle-alist nil)
6082 (setq gnus-article-mime-handles nil)))
6083 ;; If we have several article buffers, we kill them at exit.
6084 (unless gnus-single-article-buffer
6085 (gnus-kill-buffer gnus-article-buffer)
6086 (gnus-kill-buffer gnus-original-article-buffer)
6087 (setq gnus-article-current nil))
6088 (if (not gnus-kill-summary-on-exit)
6089 (gnus-deaden-summary)
6090 (gnus-close-group group)
6091 (gnus-summary-clear-local-variables)
6092 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6093 (gnus-summary-clear-local-variables))
6094 (set-buffer gnus-group-buffer)
6095 (gnus-summary-clear-local-variables)
6096 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6097 (gnus-summary-clear-local-variables))
6098 (when (get-buffer gnus-summary-buffer)
6099 (kill-buffer gnus-summary-buffer)))
6100 (unless gnus-single-article-buffer
6101 (setq gnus-article-current nil))
6102 (when gnus-use-trees
6103 (gnus-tree-close group))
6104 (gnus-async-prefetch-remove-group group)
6105 (when (get-buffer gnus-article-buffer)
6106 (bury-buffer gnus-article-buffer))
6107 ;; Return to the group buffer.
6108 (gnus-configure-windows 'group 'force)
6109 ;; Clear the current group name.
6110 (setq gnus-newsgroup-name nil)
6111 (when (equal (gnus-group-group-name) group)
6112 (gnus-group-next-unread-group 1))
6114 (gnus-handle-ephemeral-exit quit-config)))))
6116 (defun gnus-handle-ephemeral-exit (quit-config)
6117 "Handle movement when leaving an ephemeral group.
6118 The state which existed when entering the ephemeral is reset."
6119 (if (not (buffer-name (car quit-config)))
6120 (gnus-configure-windows 'group 'force)
6121 (set-buffer (car quit-config))
6122 (cond ((eq major-mode 'gnus-summary-mode)
6123 (gnus-set-global-variables))
6124 ((eq major-mode 'gnus-article-mode)
6126 ;; The `gnus-summary-buffer' variable may point
6127 ;; to the old summary buffer when using a single
6129 (unless (gnus-buffer-live-p gnus-summary-buffer)
6130 (set-buffer gnus-group-buffer))
6131 (set-buffer gnus-summary-buffer)
6132 (gnus-set-global-variables))))
6133 (if (or (eq (cdr quit-config) 'article)
6134 (eq (cdr quit-config) 'pick))
6136 ;; The current article may be from the ephemeral group
6137 ;; thus it is best that we reload this article
6138 (gnus-summary-show-article)
6139 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6140 (gnus-configure-windows 'pick 'force)
6141 (gnus-configure-windows (cdr quit-config) 'force)))
6142 (gnus-configure-windows (cdr quit-config) 'force))
6143 (when (eq major-mode 'gnus-summary-mode)
6144 (gnus-summary-next-subject 1 nil t)
6145 (gnus-summary-recenter)
6146 (gnus-summary-position-point))))
6150 (defvar gnus-dead-summary-mode-map nil)
6152 (unless gnus-dead-summary-mode-map
6153 (setq gnus-dead-summary-mode-map (make-keymap))
6154 (suppress-keymap gnus-dead-summary-mode-map)
6155 (substitute-key-definition
6156 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6157 (dolist (key '("\C-d" "\r" "\177" [delete]))
6158 (define-key gnus-dead-summary-mode-map
6159 key 'gnus-summary-wake-up-the-dead))
6160 (dolist (key '("q" "Q"))
6161 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6163 (defvar gnus-dead-summary-mode nil
6164 "Minor mode for Gnus summary buffers.")
6166 (defun gnus-dead-summary-mode (&optional arg)
6167 "Minor mode for Gnus summary buffers."
6169 (when (eq major-mode 'gnus-summary-mode)
6170 (make-local-variable 'gnus-dead-summary-mode)
6171 (setq gnus-dead-summary-mode
6172 (if (null arg) (not gnus-dead-summary-mode)
6173 (> (prefix-numeric-value arg) 0)))
6174 (when gnus-dead-summary-mode
6175 (gnus-add-minor-mode
6176 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6178 (defun gnus-deaden-summary ()
6179 "Make the current summary buffer into a dead summary buffer."
6180 ;; Kill any previous dead summary buffer.
6181 (when (and gnus-dead-summary
6182 (buffer-name gnus-dead-summary))
6184 (set-buffer gnus-dead-summary)
6185 (when gnus-dead-summary-mode
6186 (kill-buffer (current-buffer)))))
6187 ;; Make this the current dead summary.
6188 (setq gnus-dead-summary (current-buffer))
6189 (gnus-dead-summary-mode 1)
6190 (let ((name (buffer-name)))
6191 (when (string-match "Summary" name)
6193 (concat (substring name 0 (match-beginning 0)) "Dead "
6194 (substring name (match-beginning 0)))
6198 (defun gnus-kill-or-deaden-summary (buffer)
6199 "Kill or deaden the summary BUFFER."
6201 (when (and (buffer-name buffer)
6202 (not gnus-single-article-buffer))
6205 (gnus-kill-buffer gnus-article-buffer)
6206 (gnus-kill-buffer gnus-original-article-buffer)))
6207 (cond (gnus-kill-summary-on-exit
6208 (when (and gnus-use-trees
6209 (gnus-buffer-exists-p buffer))
6212 (gnus-tree-close gnus-newsgroup-name)))
6213 (gnus-kill-buffer buffer))
6214 ((gnus-buffer-exists-p buffer)
6217 (gnus-deaden-summary))))))
6219 (defun gnus-summary-wake-up-the-dead (&rest args)
6220 "Wake up the dead summary buffer."
6222 (gnus-dead-summary-mode -1)
6223 (let ((name (buffer-name)))
6224 (when (string-match "Dead " name)
6226 (concat (substring name 0 (match-beginning 0))
6227 (substring name (match-end 0)))
6229 (gnus-message 3 "This dead summary is now alive again"))
6231 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6232 (defun gnus-summary-fetch-faq (&optional faq-dir)
6233 "Fetch the FAQ for the current group.
6234 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6238 (when current-prefix-arg
6240 "Faq dir: " (and (listp gnus-group-faq-directory)
6241 (mapcar (lambda (file) (list file))
6242 gnus-group-faq-directory))))))
6243 (let (gnus-faq-buffer)
6244 (when (setq gnus-faq-buffer
6245 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6246 (gnus-configure-windows 'summary-faq))))
6248 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6249 (defun gnus-summary-describe-group (&optional force)
6250 "Describe the current newsgroup."
6252 (gnus-group-describe-group force gnus-newsgroup-name))
6254 (defun gnus-summary-describe-briefly ()
6255 "Describe summary mode commands briefly."
6257 (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")))
6259 ;; Walking around group mode buffer from summary mode.
6261 (defun gnus-summary-next-group (&optional no-article target-group backward)
6262 "Exit current newsgroup and then select next unread newsgroup.
6263 If prefix argument NO-ARTICLE is non-nil, no article is selected
6264 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6265 previous group instead."
6267 ;; Stop pre-fetching.
6268 (gnus-async-halt-prefetch)
6269 (let ((current-group gnus-newsgroup-name)
6270 (current-buffer (current-buffer))
6272 ;; First we semi-exit this group to update Xrefs and all variables.
6273 ;; We can't do a real exit, because the window conf must remain
6274 ;; the same in case the user is prompted for info, and we don't
6275 ;; want the window conf to change before that...
6276 (gnus-summary-exit t)
6277 (while (not entered)
6278 ;; Then we find what group we are supposed to enter.
6279 (set-buffer gnus-group-buffer)
6280 (gnus-group-jump-to-group current-group)
6283 (if (eq gnus-keep-same-level 'best)
6284 (gnus-summary-best-group gnus-newsgroup-name)
6285 (gnus-summary-search-group backward gnus-keep-same-level))))
6286 (if (not target-group)
6287 ;; There are no further groups, so we return to the group
6290 (gnus-message 5 "Returning to the group buffer")
6292 (when (gnus-buffer-live-p current-buffer)
6293 (set-buffer current-buffer)
6294 (gnus-summary-exit))
6295 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6296 ;; We try to enter the target group.
6297 (gnus-group-jump-to-group target-group)
6298 (let ((unreads (gnus-group-group-unread)))
6299 (if (and (or (eq t unreads)
6300 (and unreads (not (zerop unreads))))
6301 (gnus-summary-read-group
6302 target-group nil no-article
6303 (and (buffer-name current-buffer) current-buffer)
6306 (setq current-group target-group
6307 target-group nil)))))))
6309 (defun gnus-summary-prev-group (&optional no-article)
6310 "Exit current newsgroup and then select previous unread newsgroup.
6311 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6313 (gnus-summary-next-group no-article nil t))
6315 ;; Walking around summary lines.
6317 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6318 "Go to the first unread subject.
6319 If UNREAD is non-nil, go to the first unread article.
6320 Returns the article selected or nil if there are no unread articles."
6325 ((null gnus-newsgroup-data)
6326 (gnus-message 3 "No articles in the group")
6328 ;; Pick the first article.
6330 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6331 (gnus-data-number (car gnus-newsgroup-data)))
6332 ;; No unread articles.
6333 ((null gnus-newsgroup-unreads)
6334 (gnus-message 3 "No more unread articles")
6336 ;; Find the first unread article.
6338 (let ((data gnus-newsgroup-data))
6340 (and (not (and undownloaded
6341 (eq gnus-undownloaded-mark
6342 (gnus-data-mark (car data)))))
6344 (memq (car data) gnus-newsgroup-unseen)))
6345 (not (gnus-data-unread-p (car data)))))
6346 (setq data (cdr data)))
6348 (goto-char (gnus-data-pos (car data)))
6349 (gnus-data-number (car data))))))
6350 (gnus-summary-position-point)))
6352 (defun gnus-summary-next-subject (n &optional unread dont-display)
6353 "Go to next N'th summary line.
6354 If N is negative, go to the previous N'th subject line.
6355 If UNREAD is non-nil, only unread articles are selected.
6356 The difference between N and the actual number of steps taken is
6359 (let ((backward (< n 0))
6363 (gnus-summary-find-prev unread)
6364 (gnus-summary-find-next unread)))
6365 (unless (zerop (setq n (1- n)))
6366 (gnus-summary-show-thread)))
6368 (gnus-message 7 "No more%s articles"
6369 (if unread " unread" "")))
6370 (unless dont-display
6371 (gnus-summary-recenter)
6372 (gnus-summary-position-point))
6375 (defun gnus-summary-next-unread-subject (n)
6376 "Go to next N'th unread summary line."
6378 (gnus-summary-next-subject n t))
6380 (defun gnus-summary-prev-subject (n &optional unread)
6381 "Go to previous N'th summary line.
6382 If optional argument UNREAD is non-nil, only unread article is selected."
6384 (gnus-summary-next-subject (- n) unread))
6386 (defun gnus-summary-prev-unread-subject (n)
6387 "Go to previous N'th unread summary line."
6389 (gnus-summary-next-subject (- n) t))
6391 (defun gnus-summary-goto-subject (article &optional force silent)
6392 "Go the subject line of ARTICLE.
6393 If FORCE, also allow jumping to articles not currently shown."
6394 (interactive "nArticle number: ")
6396 (data (gnus-data-find article)))
6397 ;; We read in the article if we have to.
6400 (gnus-summary-insert-subject
6402 (if (or (numberp force) (vectorp force)) force)
6404 (setq data (gnus-data-find article)))
6409 (gnus-message 3 "Can't find article %d" article))
6411 (let ((pt (gnus-data-pos data)))
6413 (gnus-summary-set-article-display-arrow pt))
6414 (gnus-summary-position-point)
6417 ;; Walking around summary lines with displaying articles.
6419 (defun gnus-summary-expand-window (&optional arg)
6420 "Make the summary buffer take up the entire Emacs frame.
6421 Given a prefix, will force an `article' buffer configuration."
6424 (gnus-configure-windows 'article 'force)
6425 (gnus-configure-windows 'summary 'force)))
6427 (defun gnus-summary-display-article (article &optional all-header)
6428 "Display ARTICLE in article buffer."
6429 (when (gnus-buffer-live-p gnus-article-buffer)
6430 (with-current-buffer gnus-article-buffer
6431 (mm-enable-multibyte-mule4)))
6432 (gnus-set-global-variables)
6433 (when (gnus-buffer-live-p gnus-article-buffer)
6434 (with-current-buffer gnus-article-buffer
6435 (setq gnus-article-charset gnus-newsgroup-charset)
6436 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6437 (mm-enable-multibyte-mule4)))
6441 (if gnus-summary-display-article-function
6442 (funcall gnus-summary-display-article-function article all-header)
6443 (gnus-article-prepare article all-header))
6444 (gnus-run-hooks 'gnus-select-article-hook)
6445 (when (and gnus-current-article
6446 (not (zerop gnus-current-article)))
6447 (gnus-summary-goto-subject gnus-current-article))
6448 (gnus-summary-recenter)
6449 (when (and gnus-use-trees gnus-show-threads)
6450 (gnus-possibly-generate-tree article)
6451 (gnus-highlight-selected-tree article))
6452 ;; Successfully display article.
6453 (gnus-article-set-window-start
6454 (cdr (assq article gnus-newsgroup-bookmarks))))))
6456 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6457 "Select the current article.
6458 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6459 non-nil, the article will be re-fetched even if it already present in
6460 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6462 ;; Make sure we are in the summary buffer to work around bbdb bug.
6463 (unless (eq major-mode 'gnus-summary-mode)
6464 (set-buffer gnus-summary-buffer))
6465 (let ((article (or article (gnus-summary-article-number)))
6466 (all-headers (not (not all-headers))) ;Must be t or nil.
6467 gnus-summary-display-article-function)
6469 (gnus-summary-article-pseudo-p article)
6470 (error "This is a pseudo-article"))
6472 (set-buffer gnus-summary-buffer)
6473 (if (or (and gnus-single-article-buffer
6474 (or (null gnus-current-article)
6475 (null gnus-article-current)
6476 (null (get-buffer gnus-article-buffer))
6477 (not (eq article (cdr gnus-article-current)))
6478 (not (equal (car gnus-article-current)
6479 gnus-newsgroup-name))))
6480 (and (not gnus-single-article-buffer)
6481 (or (null gnus-current-article)
6482 (not (eq gnus-current-article article))))
6484 ;; The requested article is different from the current article.
6486 (gnus-summary-display-article article all-headers)
6487 (when (gnus-buffer-live-p gnus-article-buffer)
6488 (with-current-buffer gnus-article-buffer
6489 (if (not gnus-article-decoded-p) ;; a local variable
6490 (mm-disable-multibyte-mule4))))
6491 (when (or all-headers gnus-show-all-headers)
6492 (gnus-article-show-all-headers))
6493 (gnus-article-set-window-start
6494 (cdr (assq article gnus-newsgroup-bookmarks)))
6496 (when (or all-headers gnus-show-all-headers)
6497 (gnus-article-show-all-headers))
6500 (defun gnus-summary-force-verify-and-decrypt ()
6502 (let ((mm-verify-option 'known)
6503 (mm-decrypt-option 'known))
6504 (gnus-summary-select-article nil 'force)))
6506 (defun gnus-summary-set-current-mark (&optional current-mark)
6507 "Obsolete function."
6510 (defun gnus-summary-next-article (&optional unread subject backward push)
6511 "Select the next article.
6512 If UNREAD, only unread articles are selected.
6513 If SUBJECT, only articles with SUBJECT are selected.
6514 If BACKWARD, the previous article is selected instead of the next."
6517 ;; Is there such an article?
6518 ((and (gnus-summary-search-forward unread subject backward)
6519 (or (gnus-summary-display-article (gnus-summary-article-number))
6520 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6521 (gnus-summary-position-point))
6522 ;; If not, we try the first unread, if that is wanted.
6524 gnus-auto-select-same
6525 (gnus-summary-first-unread-article))
6526 (gnus-summary-position-point)
6527 (gnus-message 6 "Wrapped"))
6528 ;; Try to get next/previous article not displayed in this group.
6529 ((and gnus-auto-extend-newsgroup
6530 (not unread) (not subject))
6531 (gnus-summary-goto-article
6532 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6533 nil (count-lines (point-min) (point))))
6534 ;; Go to next/previous group.
6536 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6537 (gnus-summary-jump-to-group gnus-newsgroup-name))
6538 (let ((cmd last-command-char)
6541 (set-buffer gnus-group-buffer)
6544 (if (eq gnus-keep-same-level 'best)
6545 (gnus-summary-best-group gnus-newsgroup-name)
6546 (gnus-summary-search-group backward gnus-keep-same-level))))
6547 ;; For some reason, the group window gets selected. We change
6549 (select-window (get-buffer-window (current-buffer)))
6550 ;; Select next unread newsgroup automagically.
6552 ((or (not gnus-auto-select-next)
6554 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6555 ((or (eq gnus-auto-select-next 'quietly)
6556 (and (eq gnus-auto-select-next 'slightly-quietly)
6558 (and (eq gnus-auto-select-next 'almost-quietly)
6559 (gnus-summary-last-article-p)))
6561 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6563 (gnus-message 7 "No more%s articles (%s)..."
6564 (if unread " unread" "")
6565 (if group (concat "selecting " group)
6567 (gnus-summary-next-group nil group backward)))
6569 (when (gnus-key-press-event-p last-input-event)
6570 (gnus-summary-walk-group-buffer
6571 gnus-newsgroup-name cmd unread backward point))))))))
6573 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6574 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6575 (?\C-p (gnus-group-prev-unread-group 1))))
6576 (cursor-in-echo-area t)
6577 keve key group ended)
6579 (set-buffer gnus-group-buffer)
6582 (if (eq gnus-keep-same-level 'best)
6583 (gnus-summary-best-group gnus-newsgroup-name)
6584 (gnus-summary-search-group backward gnus-keep-same-level))))
6587 5 "No more%s articles%s" (if unread " unread" "")
6589 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6590 (format " (Type %s for %s [%s])"
6591 (single-key-description cmd) group
6592 (car (gnus-gethash group gnus-newsrc-hashtb)))
6593 (format " (Type %s to exit %s)"
6594 (single-key-description cmd)
6595 gnus-newsgroup-name)))
6596 ;; Confirm auto selection.
6597 (setq key (car (setq keve (gnus-read-event-char))))
6600 ((assq key keystrokes)
6601 (let ((obuf (current-buffer)))
6602 (switch-to-buffer gnus-group-buffer)
6604 (gnus-group-jump-to-group group))
6605 (eval (cadr (assq key keystrokes)))
6606 (setq group (gnus-group-group-name))
6607 (switch-to-buffer obuf))
6611 (gnus-ephemeral-group-p gnus-newsgroup-name))
6613 (gnus-summary-next-group nil group backward)))
6615 (push (cdr keve) unread-command-events))))))
6617 (defun gnus-summary-next-unread-article ()
6618 "Select unread article after current one."
6620 (gnus-summary-next-article
6621 (or (not (eq gnus-summary-goto-unread 'never))
6622 (gnus-summary-last-article-p (gnus-summary-article-number)))
6623 (and gnus-auto-select-same
6624 (gnus-summary-article-subject))))
6626 (defun gnus-summary-prev-article (&optional unread subject)
6627 "Select the article after the current one.
6628 If UNREAD is non-nil, only unread articles are selected."
6630 (gnus-summary-next-article unread subject t))
6632 (defun gnus-summary-prev-unread-article ()
6633 "Select unread article before current one."
6635 (gnus-summary-prev-article
6636 (or (not (eq gnus-summary-goto-unread 'never))
6637 (gnus-summary-first-article-p (gnus-summary-article-number)))
6638 (and gnus-auto-select-same
6639 (gnus-summary-article-subject))))
6641 (defun gnus-summary-next-page (&optional lines circular)
6642 "Show next page of the selected article.
6643 If at the end of the current article, select the next article.
6644 LINES says how many lines should be scrolled up.
6646 If CIRCULAR is non-nil, go to the start of the article instead of
6647 selecting the next article when reaching the end of the current
6650 (setq gnus-summary-buffer (current-buffer))
6651 (gnus-set-global-variables)
6652 (let ((article (gnus-summary-article-number))
6653 (article-window (get-buffer-window gnus-article-buffer t))
6655 ;; If the buffer is empty, we have no article.
6657 (error "No article to select"))
6658 (gnus-configure-windows 'article)
6659 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6660 (if (and (eq gnus-summary-goto-unread 'never)
6661 (not (gnus-summary-last-article-p article)))
6662 (gnus-summary-next-article)
6663 (gnus-summary-next-unread-article))
6664 (if (or (null gnus-current-article)
6665 (null gnus-article-current)
6666 (/= article (cdr gnus-article-current))
6667 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6668 ;; Selected subject is different from current article's.
6669 (gnus-summary-display-article article)
6670 (when article-window
6671 (gnus-eval-in-buffer-window gnus-article-buffer
6672 (setq endp (gnus-article-next-page lines)))
6675 (gnus-summary-beginning-of-article))
6677 (gnus-message 3 "End of message"))
6679 (if (and (eq gnus-summary-goto-unread 'never)
6680 (not (gnus-summary-last-article-p article)))
6681 (gnus-summary-next-article)
6682 (gnus-summary-next-unread-article))))))))
6683 (gnus-summary-recenter)
6684 (gnus-summary-position-point)))
6686 (defun gnus-summary-prev-page (&optional lines move)
6687 "Show previous page of selected article.
6688 Argument LINES specifies lines to be scrolled down.
6689 If MOVE, move to the previous unread article if point is at
6690 the beginning of the buffer."
6692 (let ((article (gnus-summary-article-number))
6693 (article-window (get-buffer-window gnus-article-buffer t))
6695 (gnus-configure-windows 'article)
6696 (if (or (null gnus-current-article)
6697 (null gnus-article-current)
6698 (/= article (cdr gnus-article-current))
6699 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6700 ;; Selected subject is different from current article's.
6701 (gnus-summary-display-article article)
6702 (gnus-summary-recenter)
6703 (when article-window
6704 (gnus-eval-in-buffer-window gnus-article-buffer
6705 (setq endp (gnus-article-prev-page lines)))
6706 (when (and move endp)
6708 (gnus-message 3 "Beginning of message"))
6710 (if (and (eq gnus-summary-goto-unread 'never)
6711 (not (gnus-summary-first-article-p article)))
6712 (gnus-summary-prev-article)
6713 (gnus-summary-prev-unread-article))))))))
6714 (gnus-summary-position-point))
6716 (defun gnus-summary-prev-page-or-article (&optional lines)
6717 "Show previous page of selected article.
6718 Argument LINES specifies lines to be scrolled down.
6719 If at the beginning of the article, go to the next article."
6721 (gnus-summary-prev-page lines t))
6723 (defun gnus-summary-scroll-up (lines)
6724 "Scroll up (or down) one line current article.
6725 Argument LINES specifies lines to be scrolled up (or down if negative)."
6727 (gnus-configure-windows 'article)
6728 (gnus-summary-show-thread)
6729 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6730 (gnus-eval-in-buffer-window gnus-article-buffer
6732 (when (gnus-article-next-page lines)
6733 (gnus-message 3 "End of message")))
6735 (gnus-article-prev-page (- lines))))))
6736 (gnus-summary-recenter)
6737 (gnus-summary-position-point))
6739 (defun gnus-summary-scroll-down (lines)
6740 "Scroll down (or up) one line current article.
6741 Argument LINES specifies lines to be scrolled down (or up if negative)."
6743 (gnus-summary-scroll-up (- lines)))
6745 (defun gnus-summary-next-same-subject ()
6746 "Select next article which has the same subject as current one."
6748 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6750 (defun gnus-summary-prev-same-subject ()
6751 "Select previous article which has the same subject as current one."
6753 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6755 (defun gnus-summary-next-unread-same-subject ()
6756 "Select next unread article which has the same subject as current one."
6758 (gnus-summary-next-article t (gnus-summary-article-subject)))
6760 (defun gnus-summary-prev-unread-same-subject ()
6761 "Select previous unread article which has the same subject as current one."
6763 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6765 (defun gnus-summary-first-unread-article ()
6766 "Select the first unread article.
6767 Return nil if there are no unread articles."
6770 (when (gnus-summary-first-subject t)
6771 (gnus-summary-show-thread)
6772 (gnus-summary-first-subject t)
6773 (gnus-summary-display-article (gnus-summary-article-number)))
6774 (gnus-summary-position-point)))
6776 (defun gnus-summary-first-unread-subject ()
6777 "Place the point on the subject line of the first unread article.
6778 Return nil if there are no unread articles."
6781 (when (gnus-summary-first-subject t)
6782 (gnus-summary-show-thread)
6783 (gnus-summary-first-subject t))
6784 (gnus-summary-position-point)))
6786 (defun gnus-summary-first-unseen-subject ()
6787 "Place the point on the subject line of the first unseen article.
6788 Return nil if there are no unseen articles."
6791 (when (gnus-summary-first-subject t t t)
6792 (gnus-summary-show-thread)
6793 (gnus-summary-first-subject t t t))
6794 (gnus-summary-position-point)))
6796 (defun gnus-summary-first-article ()
6797 "Select the first article.
6798 Return nil if there are no articles."
6801 (when (gnus-summary-first-subject)
6802 (gnus-summary-show-thread)
6803 (gnus-summary-first-subject)
6804 (gnus-summary-display-article (gnus-summary-article-number)))
6805 (gnus-summary-position-point)))
6807 (defun gnus-summary-best-unread-article (&optional arg)
6808 "Select the unread article with the highest score.
6809 If given a prefix argument, select the next unread article that has a
6810 score higher than the default score."
6812 (let ((article (if arg
6813 (gnus-summary-better-unread-subject)
6814 (gnus-summary-best-unread-subject))))
6816 (gnus-summary-goto-article article)
6817 (error "No unread articles"))))
6819 (defun gnus-summary-best-unread-subject ()
6820 "Select the unread subject with the highest score."
6822 (let ((best -1000000)
6823 (data gnus-newsgroup-data)
6826 (and (gnus-data-unread-p (car data))
6828 (gnus-summary-article-score (gnus-data-number (car data))))
6831 article (gnus-data-number (car data))))
6832 (setq data (cdr data)))
6834 (gnus-summary-goto-subject article))
6835 (gnus-summary-position-point)
6838 (defun gnus-summary-better-unread-subject ()
6839 "Select the first unread subject that has a score over the default score."
6841 (let ((data gnus-newsgroup-data)
6843 (while (and (setq article (gnus-data-number (car data)))
6844 (or (gnus-data-read-p (car data))
6845 (not (> (gnus-summary-article-score article)
6846 gnus-summary-default-score))))
6847 (setq data (cdr data)))
6849 (gnus-summary-goto-subject article))
6850 (gnus-summary-position-point)
6853 (defun gnus-summary-last-subject ()
6854 "Go to the last displayed subject line in the group."
6855 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6857 (gnus-summary-goto-subject article))))
6859 (defun gnus-summary-goto-article (article &optional all-headers force)
6860 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6861 If ALL-HEADERS is non-nil, no header lines are hidden.
6862 If FORCE, go to the article even if it isn't displayed. If FORCE
6863 is a number, it is the line the article is to be displayed on."
6867 "Article number or Message-ID: "
6868 (mapcar (lambda (number) (list (int-to-string number)))
6869 gnus-newsgroup-limit))
6873 (if (and (stringp article)
6874 (string-match "@" article))
6875 (gnus-summary-refer-article article)
6876 (when (stringp article)
6877 (setq article (string-to-number article)))
6878 (if (gnus-summary-goto-subject article force)
6879 (gnus-summary-display-article article all-headers)
6880 (gnus-message 4 "Couldn't go to article %s" article) nil))
6881 (gnus-summary-position-point)))
6883 (defun gnus-summary-goto-last-article ()
6884 "Go to the previously read article."
6887 (when gnus-last-article
6888 (gnus-summary-goto-article gnus-last-article nil t))
6889 (gnus-summary-position-point)))
6891 (defun gnus-summary-pop-article (number)
6892 "Pop one article off the history and go to the previous.
6893 NUMBER articles will be popped off."
6896 (setq gnus-newsgroup-history
6897 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6899 (gnus-summary-goto-article (car to) nil t)
6900 (error "Article history empty")))
6901 (gnus-summary-position-point))
6903 ;; Summary commands and functions for limiting the summary buffer.
6905 (defun gnus-summary-limit-to-articles (n)
6906 "Limit the summary buffer to the next N articles.
6907 If not given a prefix, use the process marked articles instead."
6910 (let ((articles (gnus-summary-work-articles n)))
6911 (setq gnus-newsgroup-processable nil)
6912 (gnus-summary-limit articles))
6913 (gnus-summary-position-point)))
6915 (defun gnus-summary-pop-limit (&optional total)
6916 "Restore the previous limit.
6917 If given a prefix, remove all limits."
6920 (setq gnus-newsgroup-limits
6921 (list (mapcar (lambda (h) (mail-header-number h))
6922 gnus-newsgroup-headers))))
6923 (unless gnus-newsgroup-limits
6924 (error "No limit to pop"))
6926 (gnus-summary-limit nil 'pop)
6927 (gnus-summary-position-point)))
6929 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6930 "Limit the summary buffer to articles that have subjects that match a regexp.
6931 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6933 (list (read-string (if current-prefix-arg
6934 "Exclude subject (regexp): "
6935 "Limit to subject (regexp): "))
6936 nil current-prefix-arg))
6938 (setq header "subject"))
6939 (when (not (equal "" subject))
6941 (let ((articles (gnus-summary-find-matching
6942 (or header "subject") subject 'all nil nil
6945 (error "Found no matches for \"%s\"" subject))
6946 (gnus-summary-limit articles))
6947 (gnus-summary-position-point))))
6949 (defun gnus-summary-limit-to-author (from &optional not-matching)
6950 "Limit the summary buffer to articles that have authors that match a regexp.
6951 If NOT-MATCHING, excluding articles that have authors that match a regexp."
6953 (list (read-string (if current-prefix-arg
6954 "Exclude author (regexp): "
6955 "Limit to author (regexp): "))
6956 current-prefix-arg))
6957 (gnus-summary-limit-to-subject from "from" not-matching))
6959 (defun gnus-summary-limit-to-age (age &optional younger-p)
6960 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6961 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6962 articles that are younger than AGE days."
6964 (let ((younger current-prefix-arg)
6967 (while (not days-got)
6968 (setq days (if younger
6969 (read-string "Limit to articles within (in days): ")
6970 (read-string "Limit to articles older than (in days): ")))
6971 (when (> (length days) 0)
6972 (setq days (read days)))
6978 (setq younger (not younger))
6979 (setq days (* days -1)))))
6980 (message "Please enter a number.")
6982 (list days younger)))
6984 (let ((data gnus-newsgroup-data)
6985 (cutoff (days-to-time age))
6986 articles d date is-younger)
6987 (while (setq d (pop data))
6988 (when (and (vectorp (gnus-data-header d))
6989 (setq date (mail-header-date (gnus-data-header d))))
6990 (setq is-younger (time-less-p
6991 (time-since (condition-case ()
6998 (push (gnus-data-number d) articles))))
6999 (gnus-summary-limit (nreverse articles)))
7000 (gnus-summary-position-point)))
7002 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7003 "Limit the summary buffer to articles that match an 'extra' header."
7007 (gnus-completing-read
7008 (symbol-name (car gnus-extra-headers))
7009 (if current-prefix-arg
7010 "Exclude extra header:"
7011 "Limit extra header:")
7013 (cons (symbol-name x) x))
7018 (read-string (format "%s header %s (regexp): "
7019 (if current-prefix-arg "Exclude" "Limit to")
7021 current-prefix-arg)))
7022 (when (not (equal "" regexp))
7024 (let ((articles (gnus-summary-find-matching
7025 (cons 'extra header) regexp 'all nil nil
7028 (error "Found no matches for \"%s\"" regexp))
7029 (gnus-summary-limit articles))
7030 (gnus-summary-position-point))))
7032 (defun gnus-summary-limit-to-display-predicate ()
7033 "Limit the summary buffer to the predicated in the `display' group parameter."
7035 (unless gnus-newsgroup-display
7036 (error "There is no `display' group parameter"))
7038 (dolist (number gnus-newsgroup-articles)
7039 (when (funcall gnus-newsgroup-display)
7040 (push number articles)))
7041 (gnus-summary-limit articles))
7042 (gnus-summary-position-point))
7044 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7046 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7048 (defun gnus-summary-limit-to-unread (&optional all)
7049 "Limit the summary buffer to articles that are not marked as read.
7050 If ALL is non-nil, limit strictly to unread articles."
7053 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7054 (gnus-summary-limit-to-marks
7055 ;; Concat all the marks that say that an article is read and have
7057 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7058 gnus-killed-mark gnus-kill-file-mark
7059 gnus-low-score-mark gnus-expirable-mark
7060 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7061 gnus-duplicate-mark gnus-souped-mark)
7064 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7065 (make-obsolete 'gnus-summary-delete-marked-with
7066 'gnus-summary-limit-exlude-marks)
7068 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7069 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7070 If REVERSE, limit the summary buffer to articles that are marked
7071 with MARKS. MARKS can either be a string of marks or a list of marks.
7072 Returns how many articles were removed."
7073 (interactive "sMarks: ")
7074 (gnus-summary-limit-to-marks marks t))
7076 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7077 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7078 If REVERSE (the prefix), limit the summary buffer to articles that are
7079 not marked with MARKS. MARKS can either be a string of marks or a
7081 Returns how many articles were removed."
7082 (interactive "sMarks: \nP")
7084 (let ((data gnus-newsgroup-data)
7085 (marks (if (listp marks) marks
7086 (append marks nil))) ; Transform to list.
7089 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7090 (memq (gnus-data-mark (car data)) marks))
7091 (push (gnus-data-number (car data)) articles))
7092 (setq data (cdr data)))
7093 (gnus-summary-limit articles))
7094 (gnus-summary-position-point)))
7096 (defun gnus-summary-limit-to-score (score)
7097 "Limit to articles with score at or above SCORE."
7098 (interactive "NLimit to articles with score of at least: ")
7099 (let ((data gnus-newsgroup-data)
7102 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7104 (push (gnus-data-number (car data)) articles))
7105 (setq data (cdr data)))
7107 (gnus-summary-limit articles)
7108 (gnus-summary-position-point))))
7110 (defun gnus-summary-limit-include-thread (id)
7111 "Display all the hidden articles that is in the thread with ID in it.
7112 When called interactively, ID is the Message-ID of the current
7114 (interactive (list (mail-header-id (gnus-summary-article-header))))
7115 (let ((articles (gnus-articles-in-thread
7116 (gnus-id-to-thread (gnus-root-id id)))))
7118 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7119 (gnus-summary-limit-include-matching-articles
7121 (regexp-quote (gnus-simplify-subject-re
7122 (mail-header-subject (gnus-id-to-header id)))))
7123 (gnus-summary-position-point))))
7125 (defun gnus-summary-limit-include-matching-articles (header regexp)
7126 "Display all the hidden articles that have HEADERs that match REGEXP."
7127 (interactive (list (read-string "Match on header: ")
7128 (read-string "Regexp: ")))
7129 (let ((articles (gnus-find-matching-articles header regexp)))
7131 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7132 (gnus-summary-position-point))))
7134 (defun gnus-summary-limit-include-dormant ()
7135 "Display all the hidden articles that are marked as dormant.
7136 Note that this command only works on a subset of the articles currently
7137 fetched for this group."
7139 (unless gnus-newsgroup-dormant
7140 (error "There are no dormant articles in this group"))
7142 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7143 (gnus-summary-position-point)))
7145 (defun gnus-summary-limit-exclude-dormant ()
7146 "Hide all dormant articles."
7149 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7150 (gnus-summary-position-point)))
7152 (defun gnus-summary-limit-exclude-childless-dormant ()
7153 "Hide all dormant articles that have no children."
7155 (let ((data (gnus-data-list t))
7156 articles d children)
7157 ;; Find all articles that are either not dormant or have
7159 (while (setq d (pop data))
7160 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7162 (gnus-article-children (gnus-data-number d)))
7165 (when (memq (car children) articles)
7170 (push (gnus-data-number d) articles)))
7173 (gnus-summary-limit articles)
7174 (gnus-summary-position-point))))
7176 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7177 "Mark all unread excluded articles as read.
7178 If ALL, mark even excluded ticked and dormants as read."
7180 (let ((articles (gnus-sorted-complement
7182 (mapcar (lambda (h) (mail-header-number h))
7183 gnus-newsgroup-headers)
7185 (sort gnus-newsgroup-limit '<)))
7187 (setq gnus-newsgroup-unreads
7188 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7190 (setq gnus-newsgroup-dormant nil
7191 gnus-newsgroup-marked nil
7192 gnus-newsgroup-reads
7194 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7195 gnus-newsgroup-reads))
7196 (while (setq article (pop articles))
7197 (unless (or (memq article gnus-newsgroup-dormant)
7198 (memq article gnus-newsgroup-marked))
7199 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7201 (defun gnus-summary-limit (articles &optional pop)
7203 ;; We pop the previous limit off the stack and use that.
7204 (setq articles (car gnus-newsgroup-limits)
7205 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7206 ;; We use the new limit, so we push the old limit on the stack.
7207 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7209 (setq gnus-newsgroup-limit articles)
7210 (let ((total (length gnus-newsgroup-data))
7211 (data (gnus-data-find-list (gnus-summary-article-number)))
7212 (gnus-summary-mark-below nil) ; Inhibit this.
7214 ;; This will do all the work of generating the new summary buffer
7215 ;; according to the new limit.
7216 (gnus-summary-prepare)
7217 ;; Hide any threads, possibly.
7218 (gnus-summary-maybe-hide-threads)
7219 ;; Try to return to the article you were at, or one in the
7222 ;; We try to find some article after the current one.
7224 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7227 (setq data (cdr data))))
7229 ;; If there is no data, that means that we were after the last
7230 ;; article. The same goes when we can't find any articles
7231 ;; after the current one.
7232 (goto-char (point-max))
7233 (gnus-summary-find-prev))
7234 (gnus-set-mode-line 'summary)
7235 ;; We return how many articles were removed from the summary
7236 ;; buffer as a result of the new limit.
7237 (- total (length gnus-newsgroup-data))))
7239 (defsubst gnus-invisible-cut-children (threads)
7242 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7247 (defsubst gnus-cut-thread (thread)
7248 "Go forwards in the thread until we find an article that we want to display."
7249 (when (or (eq gnus-fetch-old-headers 'some)
7250 (eq gnus-fetch-old-headers 'invisible)
7251 (numberp gnus-fetch-old-headers)
7252 (eq gnus-build-sparse-threads 'some)
7253 (eq gnus-build-sparse-threads 'more))
7254 ;; Deal with old-fetched headers and sparse threads.
7258 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7259 (gnus-summary-article-ancient-p
7260 (mail-header-number (car thread))))
7261 (if (or (<= (length (cdr thread)) 1)
7262 (eq gnus-fetch-old-headers 'invisible))
7263 (setq gnus-newsgroup-limit
7264 (delq (mail-header-number (car thread))
7265 gnus-newsgroup-limit)
7266 thread (cadr thread))
7267 (when (gnus-invisible-cut-children (cdr thread))
7268 (let ((th (cdr thread)))
7270 (if (memq (mail-header-number (caar th))
7271 gnus-newsgroup-limit)
7272 (setq thread (car th)
7274 (setq th (cdr th))))))))))
7277 (defun gnus-cut-threads (threads)
7278 "Cut off all uninteresting articles from the beginning of threads."
7279 (when (or (eq gnus-fetch-old-headers 'some)
7280 (eq gnus-fetch-old-headers 'invisible)
7281 (numberp gnus-fetch-old-headers)
7282 (eq gnus-build-sparse-threads 'some)
7283 (eq gnus-build-sparse-threads 'more))
7286 (setcar th (gnus-cut-thread (car th)))
7287 (setq th (cdr th)))))
7288 ;; Remove nixed out threads.
7291 (defun gnus-summary-initial-limit (&optional show-if-empty)
7292 "Figure out what the initial limit is supposed to be on group entry.
7293 This entails weeding out unwanted dormants, low-scored articles,
7294 fetch-old-headers verbiage, and so on."
7295 ;; Most groups have nothing to remove.
7296 (if (or gnus-inhibit-limiting
7297 (and (null gnus-newsgroup-dormant)
7298 (eq gnus-newsgroup-display 'gnus-not-ignore)
7299 (not (eq gnus-fetch-old-headers 'some))
7300 (not (numberp gnus-fetch-old-headers))
7301 (not (eq gnus-fetch-old-headers 'invisible))
7302 (null gnus-summary-expunge-below)
7303 (not (eq gnus-build-sparse-threads 'some))
7304 (not (eq gnus-build-sparse-threads 'more))
7305 (null gnus-thread-expunge-below)
7306 (not gnus-use-nocem)))
7308 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7309 (setq gnus-newsgroup-limit nil)
7312 (unless (car (symbol-value node))
7313 ;; These threads have no parents -- they are roots.
7314 (let ((nodes (cdr (symbol-value node)))
7317 (if (and gnus-thread-expunge-below
7318 (< (gnus-thread-total-score (car nodes))
7319 gnus-thread-expunge-below))
7320 (gnus-expunge-thread (pop nodes))
7321 (setq thread (pop nodes))
7322 (gnus-summary-limit-children thread))))))
7323 gnus-newsgroup-dependencies)
7324 ;; If this limitation resulted in an empty group, we might
7325 ;; pop the previous limit and use it instead.
7326 (when (and (not gnus-newsgroup-limit)
7328 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7329 gnus-newsgroup-limit))
7331 (defun gnus-summary-limit-children (thread)
7332 "Return 1 if this subthread is visible and 0 if it is not."
7333 ;; First we get the number of visible children to this thread. This
7334 ;; is done by recursing down the thread using this function, so this
7335 ;; will really go down to a leaf article first, before slowly
7336 ;; working its way up towards the root.
7340 (apply '+ (mapcar 'gnus-summary-limit-children
7343 (number (mail-header-number (car thread)))
7346 (not (memq number gnus-newsgroup-marked))
7348 ;; If this article is dormant and has absolutely no visible
7349 ;; children, then this article isn't visible.
7350 (and (memq number gnus-newsgroup-dormant)
7352 ;; If this is "fetch-old-headered" and there is no
7353 ;; visible children, then we don't want this article.
7354 (and (or (eq gnus-fetch-old-headers 'some)
7355 (numberp gnus-fetch-old-headers))
7356 (gnus-summary-article-ancient-p number)
7358 ;; If this is "fetch-old-headered" and `invisible', then
7359 ;; we don't want this article.
7360 (and (eq gnus-fetch-old-headers 'invisible)
7361 (gnus-summary-article-ancient-p number))
7362 ;; If this is a sparsely inserted article with no children,
7363 ;; we don't want it.
7364 (and (eq gnus-build-sparse-threads 'some)
7365 (gnus-summary-article-sparse-p number)
7367 ;; If we use expunging, and this article is really
7368 ;; low-scored, then we don't want this article.
7369 (when (and gnus-summary-expunge-below
7371 (or (cdr (assq number gnus-newsgroup-scored))
7372 gnus-summary-default-score))
7373 gnus-summary-expunge-below))
7374 ;; We increase the expunge-tally here, but that has
7375 ;; nothing to do with the limits, really.
7376 (incf gnus-newsgroup-expunged-tally)
7377 ;; We also mark as read here, if that's wanted.
7378 (when (and gnus-summary-mark-below
7379 (< score gnus-summary-mark-below))
7380 (setq gnus-newsgroup-unreads
7381 (delq number gnus-newsgroup-unreads))
7382 (if gnus-newsgroup-auto-expire
7383 (push number gnus-newsgroup-expirable)
7384 (push (cons number gnus-low-score-mark)
7385 gnus-newsgroup-reads)))
7387 ;; Do the `display' group parameter.
7388 (and gnus-newsgroup-display
7389 (not (funcall gnus-newsgroup-display)))
7390 ;; Check NoCeM things.
7391 (if (and gnus-use-nocem
7392 (gnus-nocem-unwanted-article-p
7393 (mail-header-id (car thread))))
7395 (setq gnus-newsgroup-unreads
7396 (delq number gnus-newsgroup-unreads))
7398 ;; Nope, invisible article.
7400 ;; Ok, this article is to be visible, so we add it to the limit
7402 (push number gnus-newsgroup-limit)
7405 (defun gnus-expunge-thread (thread)
7406 "Mark all articles in THREAD as read."
7407 (let* ((number (mail-header-number (car thread))))
7408 (incf gnus-newsgroup-expunged-tally)
7409 ;; We also mark as read here, if that's wanted.
7410 (setq gnus-newsgroup-unreads
7411 (delq number gnus-newsgroup-unreads))
7412 (if gnus-newsgroup-auto-expire
7413 (push number gnus-newsgroup-expirable)
7414 (push (cons number gnus-low-score-mark)
7415 gnus-newsgroup-reads)))
7416 ;; Go recursively through all subthreads.
7417 (mapcar 'gnus-expunge-thread (cdr thread)))
7419 ;; Summary article oriented commands
7421 (defun gnus-summary-refer-parent-article (n)
7422 "Refer parent article N times.
7423 If N is negative, go to ancestor -N instead.
7424 The difference between N and the number of articles fetched is returned."
7428 (when (not (natnump n))
7433 (setq header (gnus-summary-article-header))
7434 (if (and (eq (mail-header-number header)
7435 (cdr gnus-article-current))
7436 (equal gnus-newsgroup-name
7437 (car gnus-article-current)))
7438 ;; If we try to find the parent of the currently
7439 ;; displayed article, then we take a look at the actual
7440 ;; References header, since this is slightly more
7441 ;; reliable than the References field we got from the
7444 (set-buffer gnus-original-article-buffer)
7445 (nnheader-narrow-to-headers)
7446 (unless (setq ref (message-fetch-field "references"))
7447 (setq ref (message-fetch-field "in-reply-to")))
7450 ;; It's not the current article, so we take a bet on
7451 ;; the value we got from the server.
7452 (mail-header-references header)))
7454 (not (equal ref "")))
7455 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7456 (gnus-message 1 "Couldn't find parent"))
7457 (gnus-message 1 "No references in article %d"
7458 (gnus-summary-article-number))
7461 (gnus-summary-position-point)
7464 (defun gnus-summary-refer-references ()
7465 "Fetch all articles mentioned in the References header.
7466 Return the number of articles fetched."
7468 (let ((ref (mail-header-references (gnus-summary-article-header)))
7469 (current (gnus-summary-article-number))
7473 (error "No References in the current article")
7474 ;; For each Message-ID in the References header...
7475 (while (string-match "<[^>]*>" ref)
7477 ;; ... fetch that article.
7478 (gnus-summary-refer-article
7479 (prog1 (match-string 0 ref)
7480 (setq ref (substring ref (match-end 0))))))
7481 (gnus-summary-goto-subject current)
7482 (gnus-summary-position-point)
7485 (defun gnus-summary-refer-thread (&optional limit)
7486 "Fetch all articles in the current thread.
7487 If LIMIT (the numerical prefix), fetch that many old headers instead
7488 of what's specified by the `gnus-refer-thread-limit' variable."
7490 (let ((id (mail-header-id (gnus-summary-article-header)))
7491 (limit (if limit (prefix-numeric-value limit)
7492 gnus-refer-thread-limit)))
7493 ;; We want to fetch LIMIT *old* headers, but we also have to
7494 ;; re-fetch all the headers in the current buffer, because many of
7495 ;; them may be undisplayed. So we adjust LIMIT.
7496 (when (numberp limit)
7497 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7498 (unless (eq gnus-fetch-old-headers 'invisible)
7499 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7500 ;; Retrieve the headers and read them in.
7501 (if (eq (gnus-retrieve-headers
7502 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7504 (gnus-build-all-threads)
7505 (error "Can't fetch thread from backends that don't support NOV"))
7506 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7507 (gnus-summary-limit-include-thread id)))
7509 (defun gnus-summary-refer-article (message-id)
7510 "Fetch an article specified by MESSAGE-ID."
7511 (interactive "sMessage-ID: ")
7512 (when (and (stringp message-id)
7513 (not (zerop (length message-id))))
7514 ;; Construct the correct Message-ID if necessary.
7515 ;; Suggested by tale@pawl.rpi.edu.
7516 (unless (string-match "^<" message-id)
7517 (setq message-id (concat "<" message-id)))
7518 (unless (string-match ">$" message-id)
7519 (setq message-id (concat message-id ">")))
7520 (let* ((header (gnus-id-to-header message-id))
7522 (gnus-summary-article-sparse-p
7523 (mail-header-number header))
7524 (memq (mail-header-number header)
7525 gnus-newsgroup-limit)))
7528 ;; If the article is present in the buffer we just go to it.
7530 (or (not (gnus-summary-article-sparse-p
7531 (mail-header-number header)))
7534 (gnus-summary-goto-article
7535 (mail-header-number header) nil t)
7537 (gnus-summary-update-article (mail-header-number header)))))
7539 ;; We fetch the article.
7541 (dolist (gnus-override-method (gnus-refer-article-methods))
7542 (gnus-check-server gnus-override-method)
7543 ;; Fetch the header, and display the article.
7544 (when (setq number (gnus-summary-insert-subject message-id))
7545 (gnus-summary-select-article nil nil nil number)
7547 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7549 (defun gnus-refer-article-methods ()
7550 "Return a list of referrable methods."
7552 ;; No method, so we default to current and native.
7553 ((null gnus-refer-article-method)
7554 (list gnus-current-select-method gnus-select-method))
7556 ((eq 'current gnus-refer-article-method)
7557 (list gnus-current-select-method))
7558 ;; List of select methods.
7559 ((not (and (symbolp (car gnus-refer-article-method))
7560 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7562 (dolist (method gnus-refer-article-method)
7563 (push (if (eq 'current method)
7564 gnus-current-select-method
7568 ;; One single select method.
7570 (list gnus-refer-article-method))))
7572 (defun gnus-summary-edit-parameters ()
7573 "Edit the group parameters of the current group."
7575 (gnus-group-edit-group gnus-newsgroup-name 'params))
7577 (defun gnus-summary-customize-parameters ()
7578 "Customize the group parameters of the current group."
7580 (gnus-group-customize gnus-newsgroup-name))
7582 (defun gnus-summary-enter-digest-group (&optional force)
7583 "Enter an nndoc group based on the current article.
7584 If FORCE, force a digest interpretation. If not, try
7585 to guess what the document format is."
7587 (let ((conf gnus-current-window-configuration))
7589 (gnus-summary-select-article))
7590 (setq gnus-current-window-configuration conf)
7591 (let* ((name (format "%s-%d"
7592 (gnus-group-prefixed-name
7593 gnus-newsgroup-name (list 'nndoc ""))
7595 (set-buffer gnus-summary-buffer)
7596 gnus-current-article)))
7597 (ogroup gnus-newsgroup-name)
7598 (params (append (gnus-info-params (gnus-get-info ogroup))
7599 (list (cons 'to-group ogroup))
7600 (list (cons 'save-article-group ogroup))))
7601 (case-fold-search t)
7602 (buf (current-buffer))
7605 (set-buffer gnus-original-article-buffer)
7606 ;; Have the digest group inherit the main mail address of
7607 ;; the parent article.
7608 (when (setq to-address (or (message-fetch-field "reply-to")
7609 (message-fetch-field "from")))
7610 (setq params (append
7611 (list (cons 'to-address
7612 (funcall gnus-decode-encoded-word-function
7614 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7615 (insert-buffer-substring gnus-original-article-buffer)
7616 ;; Remove lines that may lead nndoc to misinterpret the
7619 (goto-char (point-min))
7620 (or (search-forward "\n\n" nil t) (point)))
7621 (goto-char (point-min))
7622 (delete-matching-lines "^Path:\\|^From ")
7625 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7626 (gnus-newsgroup-ephemeral-ignored-charsets
7627 gnus-newsgroup-ignored-charsets))
7628 (gnus-group-read-ephemeral-group
7629 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7631 ,(if force 'mbox 'guess))) t))
7632 ;; Make all postings to this group go to the parent group.
7633 (nconc (gnus-info-params (gnus-get-info name))
7635 ;; Couldn't select this doc group.
7636 (switch-to-buffer buf)
7637 (gnus-set-global-variables)
7638 (gnus-configure-windows 'summary)
7639 (gnus-message 3 "Article couldn't be entered?"))
7640 (kill-buffer dig)))))
7642 (defun gnus-summary-read-document (n)
7643 "Open a new group based on the current article(s).
7644 This will allow you to read digests and other similar
7645 documents as newsgroups.
7646 Obeys the standard process/prefix convention."
7648 (let* ((articles (gnus-summary-work-articles n))
7649 (ogroup gnus-newsgroup-name)
7650 (params (append (gnus-info-params (gnus-get-info ogroup))
7651 (list (cons 'to-group ogroup))))
7652 article group egroup groups vgroup)
7653 (while (setq article (pop articles))
7654 (setq group (format "%s-%d" gnus-newsgroup-name article))
7655 (gnus-summary-remove-process-mark article)
7656 (when (gnus-summary-display-article article)
7659 (insert-buffer-substring gnus-original-article-buffer)
7660 ;; Remove some headers that may lead nndoc to make
7662 (message-narrow-to-head)
7663 (goto-char (point-min))
7664 (delete-matching-lines "^\\(Path\\):\\|^From ")
7667 (gnus-group-read-ephemeral-group
7668 group `(nndoc ,group (nndoc-address ,(current-buffer))
7669 (nndoc-article-type guess))
7672 ;; Make all postings to this group go to the parent group.
7673 (nconc (gnus-info-params (gnus-get-info egroup))
7675 (push egroup groups))
7676 ;; Couldn't select this doc group.
7677 (gnus-error 3 "Article couldn't be entered"))))))
7678 ;; Now we have selected all the documents.
7681 (error "None of the articles could be interpreted as documents"))
7682 ((gnus-group-read-ephemeral-group
7683 (setq vgroup (format
7684 "nnvirtual:%s-%s" gnus-newsgroup-name
7685 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7686 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7688 (cons (current-buffer) 'summary)))
7690 (error "Couldn't select virtual nndoc group")))))
7692 (defun gnus-summary-isearch-article (&optional regexp-p)
7693 "Do incremental search forward on the current article.
7694 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7696 (gnus-summary-select-article)
7697 (gnus-configure-windows 'article)
7698 (gnus-eval-in-buffer-window gnus-article-buffer
7701 (isearch-forward regexp-p))))
7703 (defun gnus-summary-search-article-forward (regexp &optional backward)
7704 "Search for an article containing REGEXP forward.
7705 If BACKWARD, search backward instead."
7708 (format "Search article %s (regexp%s): "
7709 (if current-prefix-arg "backward" "forward")
7710 (if gnus-last-search-regexp
7711 (concat ", default " gnus-last-search-regexp)
7713 current-prefix-arg))
7714 (if (string-equal regexp "")
7715 (setq regexp (or gnus-last-search-regexp ""))
7716 (setq gnus-last-search-regexp regexp)
7717 (setq gnus-article-before-search gnus-current-article))
7718 ;; Intentionally set gnus-last-article.
7719 (setq gnus-last-article gnus-article-before-search)
7720 (let ((gnus-last-article gnus-last-article))
7721 (if (gnus-summary-search-article regexp backward)
7722 (gnus-summary-show-thread)
7723 (error "Search failed: \"%s\"" regexp))))
7725 (defun gnus-summary-search-article-backward (regexp)
7726 "Search for an article containing REGEXP backward."
7729 (format "Search article backward (regexp%s): "
7730 (if gnus-last-search-regexp
7731 (concat ", default " gnus-last-search-regexp)
7733 (gnus-summary-search-article-forward regexp 'backward))
7735 (defun gnus-summary-search-article (regexp &optional backward)
7736 "Search for an article containing REGEXP.
7737 Optional argument BACKWARD means do search for backward.
7738 `gnus-select-article-hook' is not called during the search."
7739 ;; We have to require this here to make sure that the following
7740 ;; dynamic binding isn't shadowed by autoloading.
7741 (require 'gnus-async)
7743 (let ((gnus-select-article-hook nil) ;Disable hook.
7744 (gnus-article-prepare-hook nil)
7745 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7746 (gnus-use-article-prefetch nil)
7747 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7748 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7749 (sum (current-buffer))
7750 (gnus-display-mime-function nil)
7753 (gnus-save-hidden-threads
7754 (gnus-summary-select-article)
7755 (set-buffer gnus-article-buffer)
7756 (goto-char (window-point (get-buffer-window (current-buffer))))
7760 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7762 (re-search-backward regexp nil t)
7763 (re-search-forward regexp nil t))
7764 ;; We found the regexp.
7769 (get-buffer-window (current-buffer))
7773 (get-buffer-window (current-buffer))
7776 (setq point (point)))
7777 ;; We didn't find it, so we go to the next article.
7780 (while (eq found 'not)
7781 (if (not (if backward (gnus-summary-find-prev)
7782 (gnus-summary-find-next)))
7783 ;; No more articles.
7785 ;; Select the next article and adjust point.
7786 (unless (gnus-summary-article-sparse-p
7787 (gnus-summary-article-number))
7789 (gnus-summary-select-article)
7790 (set-buffer gnus-article-buffer)
7792 (goto-char (if backward (point-max) (point-min))))))))
7793 (gnus-message 7 ""))
7794 ;; Return whether we found the regexp.
7795 (when (eq found 'found)
7797 (gnus-summary-show-thread)
7798 (gnus-summary-goto-subject gnus-current-article)
7799 (gnus-summary-position-point)
7802 (defun gnus-find-matching-articles (header regexp)
7803 "Return a list of all articles that match REGEXP on HEADER.
7804 This search includes all articles in the current group that Gnus has
7805 fetched headers for, whether they are displayed or not."
7806 (let ((articles nil)
7807 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7808 (case-fold-search t))
7809 (dolist (header gnus-newsgroup-headers)
7810 (when (string-match regexp (funcall func header))
7811 (push (mail-header-number header) articles)))
7812 (nreverse articles)))
7814 (defun gnus-summary-find-matching (header regexp &optional backward unread
7815 not-case-fold not-matching)
7816 "Return a list of all articles that match REGEXP on HEADER.
7817 The search stars on the current article and goes forwards unless
7818 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7819 If UNREAD is non-nil, only unread articles will
7820 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7821 in the comparisons. If NOT-MATCHING, return a list of all articles that
7822 not match REGEXP on HEADER."
7823 (let ((case-fold-search (not not-case-fold))
7826 (if (eq (car header) 'extra)
7829 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7831 (error "%s is an invalid header" header))
7832 (unless (fboundp (intern (concat "mail-header-" header)))
7833 (error "%s is not a valid header" header))
7834 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7835 (dolist (d (if (eq backward 'all)
7837 (gnus-data-find-list
7838 (gnus-summary-article-number)
7839 (gnus-data-list backward))))
7840 (when (and (or (not unread) ; We want all articles...
7841 (gnus-data-unread-p d)) ; Or just unreads.
7842 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7846 (funcall func (gnus-data-header d))))
7847 (string-match regexp
7848 (funcall func (gnus-data-header d)))))
7849 (push (gnus-data-number d) articles))) ; Success!
7850 (nreverse articles)))
7852 (defun gnus-summary-execute-command (header regexp command &optional backward)
7853 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7854 If HEADER is an empty string (or nil), the match is done on the entire
7855 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7857 (list (let ((completion-ignore-case t))
7860 (mapcar (lambda (header) (list (format "%s" header)))
7862 '("Number" "Subject" "From" "Lines" "Date"
7863 "Message-ID" "Xref" "References" "Body")
7864 gnus-extra-headers))
7865 nil 'require-match))
7866 (read-string "Regexp: ")
7867 (read-key-sequence "Command: ")
7868 current-prefix-arg))
7869 (when (equal header "Body")
7871 ;; Hidden thread subtrees must be searched as well.
7872 (gnus-summary-show-all-threads)
7873 ;; We don't want to change current point nor window configuration.
7875 (save-window-excursion
7876 (gnus-message 6 "Executing %s..." (key-description command))
7877 ;; We'd like to execute COMMAND interactively so as to give arguments.
7878 (gnus-execute header regexp
7879 `(call-interactively ',(key-binding command))
7881 (gnus-message 6 "Executing %s...done" (key-description command)))))
7883 (defun gnus-summary-beginning-of-article ()
7884 "Scroll the article back to the beginning."
7886 (gnus-summary-select-article)
7887 (gnus-configure-windows 'article)
7888 (gnus-eval-in-buffer-window gnus-article-buffer
7890 (goto-char (point-min))
7891 (when gnus-page-broken
7892 (gnus-narrow-to-page))))
7894 (defun gnus-summary-end-of-article ()
7895 "Scroll to the end of the article."
7897 (gnus-summary-select-article)
7898 (gnus-configure-windows 'article)
7899 (gnus-eval-in-buffer-window gnus-article-buffer
7901 (goto-char (point-max))
7903 (when gnus-page-broken
7904 (gnus-narrow-to-page))))
7906 (defun gnus-summary-print-truncate-and-quote (string &optional len)
7907 "Truncate to LEN and quote all \"(\"'s in STRING."
7908 (gnus-replace-in-string (if (and len (> (length string) len))
7909 (substring string 0 len)
7913 (defun gnus-summary-print-article (&optional filename n)
7914 "Generate and print a PostScript image of the N next (mail) articles.
7916 If N is negative, print the N previous articles. If N is nil and articles
7917 have been marked with the process mark, print these instead.
7919 If the optional first argument FILENAME is nil, send the image to the
7920 printer. If FILENAME is a string, save the PostScript image in a file with
7921 that name. If FILENAME is a number, prompt the user for the name of the file
7923 (interactive (list (ps-print-preprint current-prefix-arg)))
7924 (dolist (article (gnus-summary-work-articles n))
7925 (gnus-summary-select-article nil nil 'pseudo article)
7926 (gnus-eval-in-buffer-window gnus-article-buffer
7927 (gnus-print-buffer))
7928 (gnus-summary-remove-process-mark article))
7929 (ps-despool filename))
7931 (defun gnus-print-buffer ()
7932 (let ((buffer (generate-new-buffer " *print*")))
7935 (copy-to-buffer buffer (point-min) (point-max))
7937 (gnus-article-delete-invisible-text)
7938 (when (gnus-visual-p 'article-highlight 'highlight)
7939 ;; Copy-to-buffer doesn't copy overlay. So redo
7941 (let ((gnus-article-buffer buffer))
7942 (gnus-article-highlight-citation t)
7943 (gnus-article-highlight-signature)))
7944 (let ((ps-left-header
7947 (gnus-summary-print-truncate-and-quote
7948 (mail-header-subject gnus-current-headers)
7951 (gnus-summary-print-truncate-and-quote
7952 (mail-header-from gnus-current-headers)
7956 "/pagenumberstring load"
7958 (mail-header-date gnus-current-headers) ")"))))
7959 (gnus-run-hooks 'gnus-ps-print-hook)
7962 (ps-spool-buffer-with-faces)
7963 (ps-spool-buffer)))))
7964 (kill-buffer buffer))))
7966 (defun gnus-summary-show-article (&optional arg)
7967 "Force redisplaying of the current article.
7968 If ARG (the prefix) is a number, show the article with the charset
7969 defined in `gnus-summary-show-article-charset-alist', or the charset
7971 If ARG (the prefix) is non-nil and not a number, show the raw article
7972 without any article massaging functions being run. Normally, the key strokes
7977 (gnus-summary-show-article t)
7978 (let ((gnus-newsgroup-charset
7979 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7980 (mm-read-coding-system
7983 (set-buffer gnus-article-buffer)
7984 (let ((coding-systems
7985 (detect-coding-region (point) (point-max))))
7986 (or (car-safe coding-systems)
7987 coding-systems))))))
7988 (gnus-newsgroup-ignored-charsets 'gnus-all))
7989 (gnus-summary-select-article nil 'force)
7990 (let ((deps gnus-newsgroup-dependencies)
7993 (set-buffer gnus-original-article-buffer)
7995 (message-narrow-to-head)
7996 (setq head (buffer-string))
7997 (goto-char (point-min))
7998 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
7999 (goto-char (point-max))
8001 (setq lines (1- (count-lines (point) (point-max))))))
8003 (insert (format "211 %d Article retrieved.\n"
8004 (cdr gnus-article-current)))
8006 (if lines (insert (format "Lines: %d\n" lines)))
8008 (let ((nntp-server-buffer (current-buffer)))
8009 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8010 (gnus-data-set-header
8011 (gnus-data-find (cdr gnus-article-current))
8013 (gnus-summary-update-article-line
8014 (cdr gnus-article-current) header)
8015 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8016 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8018 ;; Select the article the normal way.
8019 (gnus-summary-select-article nil 'force))
8021 ;; We have to require this here to make sure that the following
8022 ;; dynamic binding isn't shadowed by autoloading.
8023 (require 'gnus-async)
8025 ;; Bind the article treatment functions to nil.
8026 (let ((gnus-have-all-headers t)
8027 gnus-article-prepare-hook
8028 gnus-article-decode-hook
8029 gnus-display-mime-function
8031 ;; Destroy any MIME parts.
8032 (when (gnus-buffer-live-p gnus-article-buffer)
8034 (set-buffer gnus-article-buffer)
8035 (mm-destroy-parts gnus-article-mime-handles)
8036 ;; Set it to nil for safety reason.
8037 (setq gnus-article-mime-handle-alist nil)
8038 (setq gnus-article-mime-handles nil)))
8039 (gnus-summary-select-article nil 'force))))
8040 (gnus-summary-goto-subject gnus-current-article)
8041 (gnus-summary-position-point))
8043 (defun gnus-summary-show-raw-article ()
8044 "Show the raw article without any article massaging functions being run."
8046 (gnus-summary-show-article t))
8048 (defun gnus-summary-verbose-headers (&optional arg)
8049 "Toggle permanent full header display.
8050 If ARG is a positive number, turn header display on.
8051 If ARG is a negative number, turn header display off."
8053 (setq gnus-show-all-headers
8054 (cond ((or (not (numberp arg))
8056 (not gnus-show-all-headers))
8059 (gnus-summary-show-article))
8061 (defun gnus-summary-toggle-header (&optional arg)
8062 "Show the headers if they are hidden, or hide them if they are shown.
8063 If ARG is a positive number, show the entire header.
8064 If ARG is a negative number, hide the unwanted header lines."
8067 (set-buffer gnus-article-buffer)
8069 (let* ((buffer-read-only nil)
8070 (inhibit-point-motion-hooks t)
8076 (article-narrow-to-head)
8077 (gnus-article-hidden-text-p 'headers))))
8078 (goto-char (point-min))
8079 (when (search-forward "\n\n" nil t)
8080 (delete-region (point-min) (1- (point))))
8081 (goto-char (point-min))
8083 (set-buffer gnus-original-article-buffer)
8084 (goto-char (point-min))
8085 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8086 (insert-buffer-substring gnus-original-article-buffer 1 e)
8088 (narrow-to-region (point-min) (point))
8089 (article-decode-encoded-words)
8091 (let ((gnus-treat-hide-headers nil)
8092 (gnus-treat-hide-boring-headers nil))
8093 (gnus-delete-wash-type 'headers)
8094 (gnus-treat-article 'head))
8095 (gnus-treat-article 'head)))
8096 (gnus-set-mode-line 'article)))))
8098 (defun gnus-summary-show-all-headers ()
8099 "Make all header lines visible."
8101 (gnus-summary-toggle-header 1))
8103 (defun gnus-summary-caesar-message (&optional arg)
8104 "Caesar rotate the current article by 13.
8105 The numerical prefix specifies how many places to rotate each letter
8108 (gnus-summary-select-article)
8109 (let ((mail-header-separator ""))
8110 (gnus-eval-in-buffer-window gnus-article-buffer
8113 (let ((start (window-start))
8115 (message-caesar-buffer-body arg)
8116 (set-window-start (get-buffer-window (current-buffer)) start))))))
8118 (defun gnus-summary-stop-page-breaking ()
8119 "Stop page breaking in the current article."
8121 (gnus-summary-select-article)
8122 (gnus-eval-in-buffer-window gnus-article-buffer
8124 (when (gnus-visual-p 'page-marker)
8125 (let ((buffer-read-only nil))
8126 (gnus-remove-text-with-property 'gnus-prev)
8127 (gnus-remove-text-with-property 'gnus-next))
8128 (setq gnus-page-broken nil))))
8130 (defun gnus-summary-move-article (&optional n to-newsgroup
8131 select-method action)
8132 "Move the current article to a different newsgroup.
8133 If N is a positive number, move the N next articles.
8134 If N is a negative number, move the N previous articles.
8135 If N is nil and any articles have been marked with the process mark,
8136 move those articles instead.
8137 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8138 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8139 re-spool using this method.
8141 For this function to work, both the current newsgroup and the
8142 newsgroup that you want to move to have to support the `request-move'
8143 and `request-accept' functions.
8145 ACTION can be either `move' (the default), `crosspost' or `copy'."
8148 (setq action 'move))
8149 ;; Check whether the source group supports the required functions.
8150 (cond ((and (eq action 'move)
8151 (not (gnus-check-backend-function
8152 'request-move-article gnus-newsgroup-name)))
8153 (error "The current group does not support article moving"))
8154 ((and (eq action 'crosspost)
8155 (not (gnus-check-backend-function
8156 'request-replace-article gnus-newsgroup-name)))
8157 (error "The current group does not support article editing")))
8158 (let ((articles (gnus-summary-work-articles n))
8159 (prefix (if (gnus-check-backend-function
8160 'request-move-article gnus-newsgroup-name)
8161 (gnus-group-real-prefix gnus-newsgroup-name)
8163 (names '((move "Move" "Moving")
8164 (copy "Copy" "Copying")
8165 (crosspost "Crosspost" "Crossposting")))
8166 (copy-buf (save-excursion
8167 (nnheader-set-temp-buffer " *copy article*")))
8168 art-group to-method new-xref article to-groups)
8169 (unless (assq action names)
8170 (error "Unknown action %s" action))
8171 ;; We have to select an article to give
8172 ;; `gnus-read-move-group-name' an opportunity to suggest an
8173 ;; appropriate default.
8174 (unless (gnus-buffer-live-p gnus-original-article-buffer)
8175 (gnus-summary-select-article nil nil nil (car articles)))
8176 ;; Read the newsgroup name.
8177 (when (and (not to-newsgroup)
8178 (not select-method))
8180 (gnus-read-move-group-name
8181 (cadr (assq action names))
8182 (symbol-value (intern (format "gnus-current-%s-group" action)))
8184 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8185 (setq to-method (or select-method
8186 (gnus-server-to-method
8187 (gnus-group-method to-newsgroup))))
8188 ;; Check the method we are to move this article to...
8189 (unless (gnus-check-backend-function
8190 'request-accept-article (car to-method))
8191 (error "%s does not support article copying" (car to-method)))
8192 (unless (gnus-check-server to-method)
8193 (error "Can't open server %s" (car to-method)))
8194 (gnus-message 6 "%s to %s: %s..."
8195 (caddr (assq action names))
8196 (or (car select-method) to-newsgroup) articles)
8198 (setq article (pop articles))
8202 ;; Move the article.
8204 ;; Remove this article from future suppression.
8205 (gnus-dup-unsuppress-article article)
8206 (gnus-request-move-article
8207 article ; Article to move
8208 gnus-newsgroup-name ; From newsgroup
8209 (nth 1 (gnus-find-method-for-group
8210 gnus-newsgroup-name)) ; Server
8211 (list 'gnus-request-accept-article
8212 to-newsgroup (list 'quote select-method)
8213 (not articles) t) ; Accept form
8214 (not articles))) ; Only save nov last time
8215 ;; Copy the article.
8218 (set-buffer copy-buf)
8219 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8220 (gnus-request-accept-article
8221 to-newsgroup select-method (not articles) t))))
8222 ;; Crosspost the article.
8223 ((eq action 'crosspost)
8224 (let ((xref (message-tokenize-header
8225 (mail-header-xref (gnus-summary-article-header article))
8227 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8228 ":" (number-to-string article)))
8230 (setq xref (list (system-name))))
8233 (mapconcat 'identity
8234 (delete "Xref:" (delete new-xref xref))
8238 (set-buffer copy-buf)
8239 ;; First put the article in the destination group.
8240 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8241 (when (consp (setq art-group
8242 (gnus-request-accept-article
8243 to-newsgroup select-method (not articles))))
8244 (setq new-xref (concat new-xref " " (car art-group)
8246 (number-to-string (cdr art-group))))
8247 ;; Now we have the new Xrefs header, so we insert
8248 ;; it and replace the new article.
8249 (nnheader-replace-header "Xref" new-xref)
8250 (gnus-request-replace-article
8251 (cdr art-group) to-newsgroup (current-buffer))
8255 (gnus-message 1 "Couldn't %s article %s: %s"
8256 (cadr (assq action names)) article
8257 (nnheader-get-report (car to-method))))
8258 ((eq art-group 'junk)
8259 (when (eq action 'move)
8260 (gnus-summary-mark-article article gnus-canceled-mark)
8261 (gnus-message 4 "Deleted article %s" article)))
8263 (let* ((pto-group (gnus-group-prefixed-name
8264 (car art-group) to-method))
8266 (gnus-gethash pto-group gnus-newsrc-hashtb))
8267 (info (nth 2 entry))
8268 (to-group (gnus-info-group info))
8270 ;; Update the group that has been moved to.
8272 (memq action '(move copy)))
8273 (unless (member to-group to-groups)
8274 (push to-group to-groups))
8276 (unless (memq article gnus-newsgroup-unreads)
8277 (push 'read to-marks)
8279 info (gnus-add-to-range (gnus-info-read info)
8280 (list (cdr art-group)))))
8282 ;; See whether the article is to be put in the cache.
8283 (let ((marks gnus-article-mark-lists)
8284 (to-article (cdr art-group)))
8286 ;; Enter the article into the cache in the new group,
8287 ;; if that is required.
8288 (when gnus-use-cache
8289 (gnus-cache-possibly-enter-article
8291 (memq article gnus-newsgroup-marked)
8292 (memq article gnus-newsgroup-dormant)
8293 (memq article gnus-newsgroup-unreads)))
8295 (when gnus-preserve-marks
8296 ;; Copy any marks over to the new group.
8297 (when (and (equal to-group gnus-newsgroup-name)
8298 (not (memq article gnus-newsgroup-unreads)))
8299 ;; Mark this article as read in this group.
8300 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8301 (setcdr (gnus-active to-group) to-article)
8302 (setcdr gnus-newsgroup-active to-article))
8305 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8306 (when (memq article (symbol-value
8307 (intern (format "gnus-newsgroup-%s"
8309 (push (cdar marks) to-marks)
8310 ;; If the other group is the same as this group,
8311 ;; then we have to add the mark to the list.
8312 (when (equal to-group gnus-newsgroup-name)
8313 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8316 (intern (format "gnus-newsgroup-%s"
8318 ;; Copy the marks to other group.
8319 (gnus-add-marked-articles
8320 to-group (cdar marks) (list to-article) info)))
8321 (setq marks (cdr marks)))
8323 (gnus-request-set-mark to-group (list (list (list to-article)
8328 (concat "(gnus-group-set-info '"
8329 (gnus-prin1-to-string (gnus-get-info to-group))
8332 ;; Update the Xref header in this article to point to
8333 ;; the new crossposted article we have just created.
8334 (when (eq action 'crosspost)
8336 (set-buffer copy-buf)
8337 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8338 (nnheader-replace-header "Xref" new-xref)
8339 (gnus-request-replace-article
8340 article gnus-newsgroup-name (current-buffer)))))
8342 ;;;!!!Why is this necessary?
8343 (set-buffer gnus-summary-buffer)
8345 (gnus-summary-goto-subject article)
8346 (when (eq action 'move)
8347 (gnus-summary-mark-article article gnus-canceled-mark))))
8348 (gnus-summary-remove-process-mark article))
8349 ;; Re-activate all groups that have been moved to.
8351 (set-buffer gnus-group-buffer)
8352 (let ((gnus-group-marked to-groups))
8353 (gnus-group-get-new-news-this-group nil t)))
8355 (gnus-kill-buffer copy-buf)
8356 (gnus-summary-position-point)
8357 (gnus-set-mode-line 'summary)))
8359 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8360 "Move the current article to a different newsgroup.
8361 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8362 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8363 re-spool using this method."
8365 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8367 (defun gnus-summary-crosspost-article (&optional n)
8368 "Crosspost the current article to some other group."
8370 (gnus-summary-move-article n nil nil 'crosspost))
8372 (defcustom gnus-summary-respool-default-method nil
8373 "Default method type for respooling an article.
8374 If nil, use to the current newsgroup method."
8376 :group 'gnus-summary-mail)
8378 (defun gnus-summary-respool-article (&optional n method)
8379 "Respool the current article.
8380 The article will be squeezed through the mail spooling process again,
8381 which means that it will be put in some mail newsgroup or other
8382 depending on `nnmail-split-methods'.
8383 If N is a positive number, respool the N next articles.
8384 If N is a negative number, respool the N previous articles.
8385 If N is nil and any articles have been marked with the process mark,
8386 respool those articles instead.
8388 Respooling can be done both from mail groups and \"real\" newsgroups.
8389 In the former case, the articles in question will be moved from the
8390 current group into whatever groups they are destined to. In the
8391 latter case, they will be copied into the relevant groups."
8393 (list current-prefix-arg
8394 (let* ((methods (gnus-methods-using 'respool))
8396 (symbol-name (or gnus-summary-respool-default-method
8397 (car (gnus-find-method-for-group
8398 gnus-newsgroup-name)))))
8400 (gnus-completing-read
8401 methname "What backend do you want to use when respooling?"
8402 methods nil t nil 'gnus-mail-method-history))
8405 ((zerop (length (setq ms (gnus-servers-using-backend
8407 (list (intern method) ""))
8411 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8412 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8415 (error "No method given for respooling"))
8416 (if (assoc (symbol-name
8417 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8418 (gnus-methods-using 'respool))
8419 (gnus-summary-move-article n nil method)
8420 (gnus-summary-copy-article n nil method)))
8422 (defun gnus-summary-import-article (file &optional edit)
8423 "Import an arbitrary file into a mail newsgroup."
8424 (interactive "fImport file: \nP")
8425 (let ((group gnus-newsgroup-name)
8426 (now (current-time))
8427 atts lines group-art)
8428 (unless (gnus-check-backend-function 'request-accept-article group)
8429 (error "%s does not support article importing" group))
8430 (or (file-readable-p file)
8431 (not (file-regular-p file))
8432 (error "Can't read %s" file))
8434 (set-buffer (gnus-get-buffer-create " *import file*"))
8436 (nnheader-insert-file-contents file)
8437 (goto-char (point-min))
8438 (if (nnheader-article-p)
8440 (goto-char (point-min))
8441 (search-forward "\n\n" nil t)
8442 (narrow-to-region (point-min) (1- (point)))
8443 (goto-char (point-min))
8444 (unless (re-search-forward "^date:" nil t)
8445 (goto-char (point-max))
8446 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8447 ;; This doesn't look like an article, so we fudge some headers.
8448 (setq atts (file-attributes file)
8449 lines (count-lines (point-min) (point-max)))
8450 (insert "From: " (read-string "From: ") "\n"
8451 "Subject: " (read-string "Subject: ") "\n"
8452 "Date: " (message-make-date (nth 5 atts)) "\n"
8453 "Message-ID: " (message-make-message-id) "\n"
8454 "Lines: " (int-to-string lines) "\n"
8455 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8456 (setq group-art (gnus-request-accept-article group nil t))
8457 (kill-buffer (current-buffer)))
8458 (setq gnus-newsgroup-active (gnus-activate-group group))
8460 (gnus-summary-goto-article (cdr group-art) nil t)
8462 (gnus-summary-edit-article))))
8464 (defun gnus-summary-create-article ()
8465 "Create an article in a mail newsgroup."
8467 (let ((group gnus-newsgroup-name)
8468 (now (current-time))
8470 (unless (gnus-check-backend-function 'request-accept-article group)
8471 (error "%s does not support article importing" group))
8473 (set-buffer (gnus-get-buffer-create " *import file*"))
8475 (goto-char (point-min))
8476 ;; This doesn't look like an article, so we fudge some headers.
8477 (insert "From: " (read-string "From: ") "\n"
8478 "Subject: " (read-string "Subject: ") "\n"
8479 "Date: " (message-make-date now) "\n"
8480 "Message-ID: " (message-make-message-id) "\n")
8481 (setq group-art (gnus-request-accept-article group nil t))
8482 (kill-buffer (current-buffer)))
8483 (setq gnus-newsgroup-active (gnus-activate-group group))
8485 (gnus-summary-goto-article (cdr group-art) nil t)
8486 (gnus-summary-edit-article)))
8488 (defun gnus-summary-article-posted-p ()
8489 "Say whether the current (mail) article is available from news as well.
8490 This will be the case if the article has both been mailed and posted."
8492 (let ((id (mail-header-references (gnus-summary-article-header)))
8493 (gnus-override-method (car (gnus-refer-article-methods))))
8494 (if (gnus-request-head id "")
8495 (gnus-message 2 "The current message was found on %s"
8496 gnus-override-method)
8497 (gnus-message 2 "The current message couldn't be found on %s"
8498 gnus-override-method)
8501 (defun gnus-summary-expire-articles (&optional now)
8502 "Expire all articles that are marked as expirable in the current group."
8504 (when (gnus-check-backend-function
8505 'request-expire-articles gnus-newsgroup-name)
8506 ;; This backend supports expiry.
8507 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8508 (expirable (if total
8510 ;; We need to update the info for
8511 ;; this group for `gnus-list-of-read-articles'
8512 ;; to give us the right answer.
8513 (gnus-run-hooks 'gnus-exit-group-hook)
8514 (gnus-summary-update-info)
8515 (gnus-list-of-read-articles gnus-newsgroup-name))
8516 (setq gnus-newsgroup-expirable
8517 (sort gnus-newsgroup-expirable '<))))
8518 (expiry-wait (if now 'immediate
8519 (gnus-group-find-parameter
8520 gnus-newsgroup-name 'expiry-wait)))
8521 (nnmail-expiry-target
8522 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8523 nnmail-expiry-target))
8526 ;; There are expirable articles in this group, so we run them
8527 ;; through the expiry process.
8528 (gnus-message 6 "Expiring articles...")
8529 (unless (gnus-check-group gnus-newsgroup-name)
8530 (error "Can't open server for %s" gnus-newsgroup-name))
8531 ;; The list of articles that weren't expired is returned.
8534 (let ((nnmail-expiry-wait-function nil)
8535 (nnmail-expiry-wait expiry-wait))
8536 (setq es (gnus-request-expire-articles
8537 expirable gnus-newsgroup-name)))
8538 (setq es (gnus-request-expire-articles
8539 expirable gnus-newsgroup-name)))
8541 (setq gnus-newsgroup-expirable es))
8542 ;; We go through the old list of expirable, and mark all
8543 ;; really expired articles as nonexistent.
8544 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8545 (let ((gnus-use-cache nil))
8547 (unless (memq (car expirable) es)
8548 (when (gnus-data-find (car expirable))
8549 (gnus-summary-mark-article
8550 (car expirable) gnus-canceled-mark)))
8551 (setq expirable (cdr expirable))))))
8552 (gnus-message 6 "Expiring articles...done")))))
8554 (defun gnus-summary-expire-articles-now ()
8555 "Expunge all expirable articles in the current group.
8556 This means that *all* articles that are marked as expirable will be
8557 deleted forever, right now."
8559 (or gnus-expert-user
8561 "Are you really, really, really sure you want to delete all these messages? ")
8563 (gnus-summary-expire-articles t))
8565 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8566 (defun gnus-summary-delete-article (&optional n)
8567 "Delete the N next (mail) articles.
8568 This command actually deletes articles. This is not a marking
8569 command. The article will disappear forever from your life, never to
8571 If N is negative, delete backwards.
8572 If N is nil and articles have been marked with the process mark,
8573 delete these instead."
8575 (unless (gnus-check-backend-function 'request-expire-articles
8576 gnus-newsgroup-name)
8577 (error "The current newsgroup does not support article deletion"))
8578 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8579 (error "Couldn't open server"))
8580 ;; Compute the list of articles to delete.
8581 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8583 (if (and gnus-novice-user
8584 (not (gnus-yes-or-no-p
8585 (format "Do you really want to delete %s forever? "
8586 (if (> (length articles) 1)
8587 (format "these %s articles" (length articles))
8590 ;; Delete the articles.
8591 (setq not-deleted (gnus-request-expire-articles
8592 articles gnus-newsgroup-name 'force))
8594 (gnus-summary-remove-process-mark (car articles))
8595 ;; The backend might not have been able to delete the article
8597 (unless (memq (car articles) not-deleted)
8598 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8599 (setq articles (cdr articles)))
8601 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8602 (gnus-summary-position-point)
8603 (gnus-set-mode-line 'summary)
8606 (defun gnus-summary-edit-article (&optional arg)
8607 "Edit the current article.
8608 This will have permanent effect only in mail groups.
8609 If ARG is nil, edit the decoded articles.
8610 If ARG is 1, edit the raw articles.
8611 If ARG is 2, edit the raw articles even in read-only groups.
8612 If ARG is 3, edit the articles with the current handles.
8613 Otherwise, allow editing of articles even in read-only
8616 (let (force raw current-handles)
8619 ((eq arg 1) (setq raw t))
8620 ((eq arg 2) (setq raw t
8622 ((eq arg 3) (setq current-handles
8623 (and (gnus-buffer-live-p gnus-article-buffer)
8624 (with-current-buffer gnus-article-buffer
8626 gnus-article-mime-handles
8627 (setq gnus-article-mime-handles nil))))))
8629 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8630 (error "Can't edit the raw article in group nndraft:drafts"))
8632 (set-buffer gnus-summary-buffer)
8633 (let ((mail-parse-charset gnus-newsgroup-charset)
8634 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8635 (gnus-set-global-variables)
8636 (when (and (not force)
8637 (gnus-group-read-only-p))
8638 (error "The current newsgroup does not support article editing"))
8639 (gnus-summary-show-article t)
8640 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8641 (with-current-buffer gnus-article-buffer
8642 (mm-enable-multibyte-mule4)))
8643 (if (equal gnus-newsgroup-name "nndraft:drafts")
8645 (gnus-article-edit-article
8648 (let ((mbl mml-buffer-list))
8649 (setq mml-buffer-list nil)
8650 (mime-to-mml ,'current-handles)
8651 (let ((mbl1 mml-buffer-list))
8652 (setq mml-buffer-list mbl)
8653 (set (make-local-variable 'mml-buffer-list) mbl1))
8654 (make-local-hook 'kill-buffer-hook)
8655 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8656 `(lambda (no-highlight)
8657 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8658 (message-options message-options)
8659 (message-options-set-recipient)
8660 (mail-parse-ignored-charsets
8661 ',gnus-newsgroup-ignored-charsets))
8662 ,(if (not raw) '(progn
8664 (mml-destroy-buffers)
8665 (remove-hook 'kill-buffer-hook
8666 'mml-destroy-buffers t)
8667 (kill-local-variable 'mml-buffer-list)))
8668 (gnus-summary-edit-article-done
8669 ,(or (mail-header-references gnus-current-headers) "")
8670 ,(gnus-group-read-only-p)
8671 ,gnus-summary-buffer no-highlight))))))))
8673 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8675 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8677 "Make edits to the current article permanent."
8680 ;; The buffer restriction contains the entire article if it exists.
8681 (when (article-goto-body)
8682 (let ((lines (count-lines (point) (point-max)))
8683 (length (- (point-max) (point)))
8684 (case-fold-search t)
8685 (body (copy-marker (point))))
8686 (goto-char (point-min))
8687 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8688 (delete-region (match-beginning 1) (match-end 1))
8689 (insert (number-to-string length)))
8690 (goto-char (point-min))
8691 (when (re-search-forward
8692 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8693 (delete-region (match-beginning 1) (match-end 1))
8694 (insert (number-to-string length)))
8695 (goto-char (point-min))
8696 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8697 (delete-region (match-beginning 1) (match-end 1))
8698 (insert (number-to-string lines))))))
8699 ;; Replace the article.
8700 (let ((buf (current-buffer)))
8702 (insert-buffer-substring buf)
8704 (if (and (not read-only)
8705 (not (gnus-request-replace-article
8706 (cdr gnus-article-current) (car gnus-article-current)
8707 (current-buffer) t)))
8708 (error "Couldn't replace article")
8709 ;; Update the summary buffer.
8711 (equal (message-tokenize-header references " ")
8712 (message-tokenize-header
8713 (or (message-fetch-field "references") "") " ")))
8714 ;; We only have to update this line.
8717 (message-narrow-to-head)
8718 (let ((head (buffer-string))
8721 (insert (format "211 %d Article retrieved.\n"
8722 (cdr gnus-article-current)))
8725 (let ((nntp-server-buffer (current-buffer)))
8726 (setq header (car (gnus-get-newsgroup-headers
8728 (set-buffer gnus-summary-buffer)
8729 gnus-newsgroup-dependencies)
8732 (set-buffer gnus-summary-buffer)
8733 (gnus-data-set-header
8734 (gnus-data-find (cdr gnus-article-current))
8736 (gnus-summary-update-article-line
8737 (cdr gnus-article-current) header)
8738 (if (gnus-summary-goto-subject
8739 (cdr gnus-article-current) nil t)
8740 (gnus-summary-update-secondary-mark
8741 (cdr gnus-article-current))))))))
8743 (set-buffer (or buffer gnus-summary-buffer))
8744 (gnus-summary-update-article (cdr gnus-article-current))
8745 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8746 (gnus-summary-update-secondary-mark
8747 (cdr gnus-article-current))))
8748 ;; Prettify the article buffer again.
8749 (unless no-highlight
8751 (set-buffer gnus-article-buffer)
8752 ;;;!!! Fix this -- article should be rehighlighted.
8753 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8754 (set-buffer gnus-original-article-buffer)
8755 (gnus-request-article
8756 (cdr gnus-article-current)
8757 (car gnus-article-current) (current-buffer))))
8758 ;; Prettify the summary buffer line.
8759 (when (gnus-visual-p 'summary-highlight 'highlight)
8760 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8762 (defun gnus-summary-edit-wash (key)
8763 "Perform editing command KEY in the article buffer."
8767 (message "%s" (concat (this-command-keys) "- "))
8770 (gnus-summary-edit-article)
8771 (execute-kbd-macro (concat (this-command-keys) key))
8772 (gnus-article-edit-done))
8776 (defun gnus-summary-respool-query (&optional silent trace)
8777 "Query where the respool algorithm would put this article."
8779 (let (gnus-mark-article-hook)
8780 (gnus-summary-select-article)
8782 (set-buffer gnus-original-article-buffer)
8784 (message-narrow-to-head)
8785 (let ((groups (nnmail-article-group 'identity trace)))
8788 (message "This message would go to %s"
8789 (mapconcat 'car groups ", "))
8790 (message "This message would go to no groups"))
8793 (defun gnus-summary-respool-trace ()
8794 "Trace where the respool algorithm would put this article.
8795 Display a buffer showing all fancy splitting patterns which matched."
8797 (gnus-summary-respool-query nil t))
8799 ;; Summary marking commands.
8801 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8802 "Mark articles which has the same subject as read, and then select the next.
8803 If UNMARK is positive, remove any kind of mark.
8804 If UNMARK is negative, tick articles."
8807 (setq unmark (prefix-numeric-value unmark)))
8809 (gnus-summary-mark-same-subject
8810 (gnus-summary-article-subject) unmark)))
8811 ;; Select next unread article. If auto-select-same mode, should
8812 ;; select the first unread article.
8813 (gnus-summary-next-article t (and gnus-auto-select-same
8814 (gnus-summary-article-subject)))
8815 (gnus-message 7 "%d article%s marked as %s"
8816 count (if (= count 1) " is" "s are")
8817 (if unmark "unread" "read"))))
8819 (defun gnus-summary-kill-same-subject (&optional unmark)
8820 "Mark articles which has the same subject as read.
8821 If UNMARK is positive, remove any kind of mark.
8822 If UNMARK is negative, tick articles."
8825 (setq unmark (prefix-numeric-value unmark)))
8827 (gnus-summary-mark-same-subject
8828 (gnus-summary-article-subject) unmark)))
8829 ;; If marked as read, go to next unread subject.
8831 ;; Go to next unread subject.
8832 (gnus-summary-next-subject 1 t))
8833 (gnus-message 7 "%d articles are marked as %s"
8834 count (if unmark "unread" "read"))))
8836 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8837 "Mark articles with same SUBJECT as read, and return marked number.
8838 If optional argument UNMARK is positive, remove any kinds of marks.
8839 If optional argument UNMARK is negative, mark articles as unread instead."
8843 ((null unmark) ; Mark as read.
8846 (gnus-summary-mark-article-as-read gnus-killed-mark)
8847 (gnus-summary-show-thread) t)
8848 (gnus-summary-find-subject subject))
8849 (setq count (1+ count))))
8850 ((> unmark 0) ; Tick.
8853 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8854 (gnus-summary-show-thread) t)
8855 (gnus-summary-find-subject subject))
8856 (setq count (1+ count))))
8857 (t ; Mark as unread.
8860 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8861 (gnus-summary-show-thread) t)
8862 (gnus-summary-find-subject subject))
8863 (setq count (1+ count)))))
8864 (gnus-set-mode-line 'summary)
8865 ;; Return the number of marked articles.
8868 (defun gnus-summary-mark-as-processable (n &optional unmark)
8869 "Set the process mark on the next N articles.
8870 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8871 the process mark instead. The difference between N and the actual
8872 number of articles marked is returned."
8874 (if (and (null n) (gnus-region-active-p))
8875 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8876 (setq n (prefix-numeric-value n))
8877 (let ((backward (< n 0))
8882 (gnus-summary-remove-process-mark
8883 (gnus-summary-article-number))
8884 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8885 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8888 (gnus-message 7 "No more articles"))
8889 (gnus-summary-recenter)
8890 (gnus-summary-position-point)
8893 (defun gnus-summary-unmark-as-processable (n)
8894 "Remove the process mark from the next N articles.
8895 If N is negative, unmark backward instead. The difference between N and
8896 the actual number of articles unmarked is returned."
8898 (gnus-summary-mark-as-processable n t))
8900 (defun gnus-summary-unmark-all-processable ()
8901 "Remove the process mark from all articles."
8904 (while gnus-newsgroup-processable
8905 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8906 (gnus-summary-position-point))
8908 (defun gnus-summary-add-mark (article type)
8909 "Mark ARTICLE with a mark of TYPE."
8910 (let ((vtype (car (assq type gnus-article-mark-lists)))
8913 (error "No such mark type: %s" type)
8914 (setq var (intern (format "gnus-newsgroup-%s" type)))
8915 (set var (cons article (symbol-value var)))
8916 (if (memq type '(processable cached replied forwarded recent saved))
8917 (gnus-summary-update-secondary-mark article)
8918 ;;; !!! This is bogus. We should find out what primary
8919 ;;; !!! mark we want to set.
8920 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8922 (defun gnus-summary-mark-as-expirable (n)
8923 "Mark N articles forward as expirable.
8924 If N is negative, mark backward instead. The difference between N and
8925 the actual number of articles marked is returned."
8927 (gnus-summary-mark-forward n gnus-expirable-mark))
8929 (defun gnus-summary-mark-article-as-replied (article)
8930 "Mark ARTICLE as replied to and update the summary line.
8931 ARTICLE can also be a list of articles."
8932 (interactive (list (gnus-summary-article-number)))
8933 (let ((articles (if (listp article) article (list article))))
8934 (dolist (article articles)
8935 (push article gnus-newsgroup-replied)
8936 (let ((buffer-read-only nil))
8937 (when (gnus-summary-goto-subject article nil t)
8938 (gnus-summary-update-secondary-mark article))))))
8940 (defun gnus-summary-mark-article-as-forwarded (article)
8941 "Mark ARTICLE as forwarded and update the summary line.
8942 ARTICLE can also be a list of articles."
8943 (let ((articles (if (listp article) article (list article))))
8944 (dolist (article articles)
8945 (push article gnus-newsgroup-forwarded)
8946 (let ((buffer-read-only nil))
8947 (when (gnus-summary-goto-subject article nil t)
8948 (gnus-summary-update-secondary-mark article))))))
8950 (defun gnus-summary-set-bookmark (article)
8951 "Set a bookmark in current article."
8952 (interactive (list (gnus-summary-article-number)))
8953 (when (or (not (get-buffer gnus-article-buffer))
8954 (not gnus-current-article)
8955 (not gnus-article-current)
8956 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8957 (error "No current article selected"))
8958 ;; Remove old bookmark, if one exists.
8959 (let ((old (assq article gnus-newsgroup-bookmarks)))
8961 (setq gnus-newsgroup-bookmarks
8962 (delq old gnus-newsgroup-bookmarks))))
8963 ;; Set the new bookmark, which is on the form
8964 ;; (article-number . line-number-in-body).
8968 (set-buffer gnus-article-buffer)
8972 (goto-char (point-min))
8973 (search-forward "\n\n" nil t)
8976 gnus-newsgroup-bookmarks)
8977 (gnus-message 6 "A bookmark has been added to the current article."))
8979 (defun gnus-summary-remove-bookmark (article)
8980 "Remove the bookmark from the current article."
8981 (interactive (list (gnus-summary-article-number)))
8982 ;; Remove old bookmark, if one exists.
8983 (let ((old (assq article gnus-newsgroup-bookmarks)))
8986 (setq gnus-newsgroup-bookmarks
8987 (delq old gnus-newsgroup-bookmarks))
8988 (gnus-message 6 "Removed bookmark."))
8989 (gnus-message 6 "No bookmark in current article."))))
8991 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8992 (defun gnus-summary-mark-as-dormant (n)
8993 "Mark N articles forward as dormant.
8994 If N is negative, mark backward instead. The difference between N and
8995 the actual number of articles marked is returned."
8997 (gnus-summary-mark-forward n gnus-dormant-mark))
8999 (defun gnus-summary-set-process-mark (article)
9000 "Set the process mark on ARTICLE and update the summary line."
9001 (setq gnus-newsgroup-processable
9003 (delq article gnus-newsgroup-processable)))
9004 (when (gnus-summary-goto-subject article)
9005 (gnus-summary-show-thread)
9006 (gnus-summary-goto-subject article)
9007 (gnus-summary-update-secondary-mark article)))
9009 (defun gnus-summary-remove-process-mark (article)
9010 "Remove the process mark from ARTICLE and update the summary line."
9011 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9012 (when (gnus-summary-goto-subject article)
9013 (gnus-summary-show-thread)
9014 (gnus-summary-goto-subject article)
9015 (gnus-summary-update-secondary-mark article)))
9017 (defun gnus-summary-set-saved-mark (article)
9018 "Set the process mark on ARTICLE and update the summary line."
9019 (push article gnus-newsgroup-saved)
9020 (when (gnus-summary-goto-subject article)
9021 (gnus-summary-update-secondary-mark article)))
9023 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9024 "Mark N articles as read forwards.
9025 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9026 The difference between N and the actual number of articles marked is
9028 Iff NO-EXPIRE, auto-expiry will be inhibited."
9030 (gnus-summary-show-thread)
9031 (let ((backward (< n 0))
9032 (gnus-summary-goto-unread
9033 (and gnus-summary-goto-unread
9034 (not (eq gnus-summary-goto-unread 'never))
9035 (not (memq mark (list gnus-unread-mark
9036 gnus-ticked-mark gnus-dormant-mark)))))
9038 (mark (or mark gnus-del-mark)))
9040 (gnus-summary-mark-article nil mark no-expire)
9041 (zerop (gnus-summary-next-subject
9043 (and gnus-summary-goto-unread
9044 (not (eq gnus-summary-goto-unread 'never)))
9048 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9049 (gnus-summary-recenter)
9050 (gnus-summary-position-point)
9051 (gnus-set-mode-line 'summary)
9054 (defun gnus-summary-mark-article-as-read (mark)
9055 "Mark the current article quickly as read with MARK."
9056 (let ((article (gnus-summary-article-number)))
9057 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9058 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9059 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9060 (push (cons article mark) gnus-newsgroup-reads)
9061 ;; Possibly remove from cache, if that is used.
9062 (when gnus-use-cache
9063 (gnus-cache-enter-remove-article article))
9064 ;; Allow the backend to change the mark.
9065 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9066 ;; Check for auto-expiry.
9067 (when (and gnus-newsgroup-auto-expire
9068 (memq mark gnus-auto-expirable-marks))
9069 (setq mark gnus-expirable-mark)
9070 ;; Let the backend know about the mark change.
9071 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9072 (push article gnus-newsgroup-expirable))
9073 ;; Set the mark in the buffer.
9074 (gnus-summary-update-mark mark 'unread)
9077 (defun gnus-summary-mark-article-as-unread (mark)
9078 "Mark the current article quickly as unread with MARK."
9079 (let* ((article (gnus-summary-article-number))
9080 (old-mark (gnus-summary-article-mark article)))
9081 ;; Allow the backend to change the mark.
9082 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9083 (if (eq mark old-mark)
9087 (gnus-error 1 "Can't mark negative article numbers")
9089 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9090 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9091 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9092 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9093 (cond ((= mark gnus-ticked-mark)
9094 (push article gnus-newsgroup-marked))
9095 ((= mark gnus-dormant-mark)
9096 (push article gnus-newsgroup-dormant))
9098 (push article gnus-newsgroup-unreads)))
9099 (gnus-pull article gnus-newsgroup-reads)
9101 ;; See whether the article is to be put in the cache.
9103 (vectorp (gnus-summary-article-header article))
9105 (gnus-cache-possibly-enter-article
9106 gnus-newsgroup-name article
9107 (= mark gnus-ticked-mark)
9108 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9111 (gnus-summary-update-mark mark 'unread)
9114 (defun gnus-summary-mark-article (&optional article mark no-expire)
9115 "Mark ARTICLE with MARK. MARK can be any character.
9116 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9117 `??' (dormant) and `?E' (expirable).
9118 If MARK is nil, then the default character `?r' is used.
9119 If ARTICLE is nil, then the article on the current line will be
9121 Iff NO-EXPIRE, auto-expiry will be inhibited."
9122 ;; The mark might be a string.
9123 (when (stringp mark)
9124 (setq mark (aref mark 0)))
9125 ;; If no mark is given, then we check auto-expiring.
9127 (setq mark gnus-del-mark))
9128 (when (and (not no-expire)
9129 gnus-newsgroup-auto-expire
9130 (memq mark gnus-auto-expirable-marks))
9131 (setq mark gnus-expirable-mark))
9132 (let ((article (or article (gnus-summary-article-number)))
9133 (old-mark (gnus-summary-article-mark article)))
9134 ;; Allow the backend to change the mark.
9135 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9136 (if (eq mark old-mark)
9139 (error "No article on current line"))
9140 (if (not (if (or (= mark gnus-unread-mark)
9141 (= mark gnus-ticked-mark)
9142 (= mark gnus-dormant-mark))
9143 (gnus-mark-article-as-unread article mark)
9144 (gnus-mark-article-as-read article mark)))
9146 ;; See whether the article is to be put in the cache.
9148 (not (= mark gnus-canceled-mark))
9149 (vectorp (gnus-summary-article-header article))
9151 (gnus-cache-possibly-enter-article
9152 gnus-newsgroup-name article
9153 (= mark gnus-ticked-mark)
9154 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9156 (when (gnus-summary-goto-subject article nil t)
9157 (let ((buffer-read-only nil))
9158 (gnus-summary-show-thread)
9160 (gnus-summary-update-mark mark 'unread)
9163 (defun gnus-summary-update-secondary-mark (article)
9164 "Update the secondary (read, process, cache) mark."
9165 (gnus-summary-update-mark
9166 (cond ((memq article gnus-newsgroup-processable)
9168 ((memq article gnus-newsgroup-cached)
9170 ((memq article gnus-newsgroup-replied)
9172 ((memq article gnus-newsgroup-forwarded)
9173 gnus-forwarded-mark)
9174 ((memq article gnus-newsgroup-saved)
9176 ((memq article gnus-newsgroup-recent)
9178 ((memq article gnus-newsgroup-unseen)
9182 (when (gnus-visual-p 'summary-highlight 'highlight)
9183 (gnus-run-hooks 'gnus-summary-update-hook))
9186 (defun gnus-summary-update-mark (mark type)
9187 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9188 (buffer-read-only nil))
9189 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9191 (when (looking-at "\r")
9193 (when (<= (+ forward (point)) (point-max))
9194 ;; Go to the right position on the line.
9195 (goto-char (+ forward (point)))
9196 ;; Replace the old mark with the new mark.
9197 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9198 ;; Optionally update the marks by some user rule.
9199 (when (eq type 'unread)
9201 (gnus-data-find (gnus-summary-article-number)) mark)
9202 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9204 (defun gnus-mark-article-as-read (article &optional mark)
9205 "Enter ARTICLE in the pertinent lists and remove it from others."
9206 ;; Make the article expirable.
9207 (let ((mark (or mark gnus-del-mark)))
9208 (if (= mark gnus-expirable-mark)
9209 (push article gnus-newsgroup-expirable)
9210 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9211 ;; Remove from unread and marked lists.
9212 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9213 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9214 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9215 (push (cons article mark) gnus-newsgroup-reads)
9216 ;; Possibly remove from cache, if that is used.
9217 (when gnus-use-cache
9218 (gnus-cache-enter-remove-article article))
9221 (defun gnus-mark-article-as-unread (article &optional mark)
9222 "Enter ARTICLE in the pertinent lists and remove it from others."
9223 (let ((mark (or mark gnus-ticked-mark)))
9226 (gnus-error 1 "Can't mark negative article numbers")
9228 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9229 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9230 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9231 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9233 ;; Unsuppress duplicates?
9234 (when gnus-suppress-duplicates
9235 (gnus-dup-unsuppress-article article))
9237 (cond ((= mark gnus-ticked-mark)
9238 (push article gnus-newsgroup-marked))
9239 ((= mark gnus-dormant-mark)
9240 (push article gnus-newsgroup-dormant))
9242 (push article gnus-newsgroup-unreads)))
9243 (gnus-pull article gnus-newsgroup-reads)
9246 (defalias 'gnus-summary-mark-as-unread-forward
9247 'gnus-summary-tick-article-forward)
9248 (make-obsolete 'gnus-summary-mark-as-unread-forward
9249 'gnus-summary-tick-article-forward)
9250 (defun gnus-summary-tick-article-forward (n)
9251 "Tick N articles forwards.
9252 If N is negative, tick backwards instead.
9253 The difference between N and the number of articles ticked is returned."
9255 (gnus-summary-mark-forward n gnus-ticked-mark))
9257 (defalias 'gnus-summary-mark-as-unread-backward
9258 'gnus-summary-tick-article-backward)
9259 (make-obsolete 'gnus-summary-mark-as-unread-backward
9260 'gnus-summary-tick-article-backward)
9261 (defun gnus-summary-tick-article-backward (n)
9262 "Tick N articles backwards.
9263 The difference between N and the number of articles ticked is returned."
9265 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9267 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9268 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9269 (defun gnus-summary-tick-article (&optional article clear-mark)
9270 "Mark current article as unread.
9271 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9272 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9274 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9277 (defun gnus-summary-mark-as-read-forward (n)
9278 "Mark N articles as read forwards.
9279 If N is negative, mark backwards instead.
9280 The difference between N and the actual number of articles marked is
9283 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9285 (defun gnus-summary-mark-as-read-backward (n)
9286 "Mark the N articles as read backwards.
9287 The difference between N and the actual number of articles marked is
9290 (gnus-summary-mark-forward
9291 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9293 (defun gnus-summary-mark-as-read (&optional article mark)
9294 "Mark current article as read.
9295 ARTICLE specifies the article to be marked as read.
9296 MARK specifies a string to be inserted at the beginning of the line."
9297 (gnus-summary-mark-article article mark))
9299 (defun gnus-summary-clear-mark-forward (n)
9300 "Clear marks from N articles forward.
9301 If N is negative, clear backward instead.
9302 The difference between N and the number of marks cleared is returned."
9304 (gnus-summary-mark-forward n gnus-unread-mark))
9306 (defun gnus-summary-clear-mark-backward (n)
9307 "Clear marks from N articles backward.
9308 The difference between N and the number of marks cleared is returned."
9310 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9312 (defun gnus-summary-mark-unread-as-read ()
9313 "Intended to be used by `gnus-summary-mark-article-hook'."
9314 (when (memq gnus-current-article gnus-newsgroup-unreads)
9315 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9317 (defun gnus-summary-mark-read-and-unread-as-read ()
9318 "Intended to be used by `gnus-summary-mark-article-hook'."
9319 (let ((mark (gnus-summary-article-mark)))
9320 (when (or (gnus-unread-mark-p mark)
9321 (gnus-read-mark-p mark))
9322 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9324 (defun gnus-summary-mark-unread-as-ticked ()
9325 "Intended to be used by `gnus-summary-mark-article-hook'."
9326 (when (memq gnus-current-article gnus-newsgroup-unreads)
9327 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9329 (defun gnus-summary-mark-region-as-read (point mark all)
9330 "Mark all unread articles between point and mark as read.
9331 If given a prefix, mark all articles between point and mark as read,
9332 even ticked and dormant ones."
9333 (interactive "r\nP")
9342 (memq (setq article (gnus-summary-article-number))
9343 gnus-newsgroup-unreads))
9344 (gnus-summary-mark-article article gnus-del-mark))
9346 (gnus-summary-find-next))))))
9348 (defun gnus-summary-mark-below (score mark)
9349 "Mark articles with score less than SCORE with MARK."
9350 (interactive "P\ncMark: ")
9351 (setq score (if score
9352 (prefix-numeric-value score)
9353 (or gnus-summary-default-score 0)))
9355 (set-buffer gnus-summary-buffer)
9356 (goto-char (point-min))
9359 (and (< (gnus-summary-article-score) score)
9360 (gnus-summary-mark-article nil mark))
9361 (gnus-summary-find-next)))))
9363 (defun gnus-summary-kill-below (&optional score)
9364 "Mark articles with score below SCORE as read."
9366 (gnus-summary-mark-below score gnus-killed-mark))
9368 (defun gnus-summary-clear-above (&optional score)
9369 "Clear all marks from articles with score above SCORE."
9371 (gnus-summary-mark-above score gnus-unread-mark))
9373 (defun gnus-summary-tick-above (&optional score)
9374 "Tick all articles with score above SCORE."
9376 (gnus-summary-mark-above score gnus-ticked-mark))
9378 (defun gnus-summary-mark-above (score mark)
9379 "Mark articles with score over SCORE with MARK."
9380 (interactive "P\ncMark: ")
9381 (setq score (if score
9382 (prefix-numeric-value score)
9383 (or gnus-summary-default-score 0)))
9385 (set-buffer gnus-summary-buffer)
9386 (goto-char (point-min))
9388 (when (> (gnus-summary-article-score) score)
9389 (gnus-summary-mark-article nil mark))
9391 (gnus-summary-find-next)))))
9393 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9394 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9395 (defun gnus-summary-limit-include-expunged (&optional no-error)
9396 "Display all the hidden articles that were expunged for low scores."
9398 (let ((buffer-read-only nil))
9399 (let ((scored gnus-newsgroup-scored)
9402 (unless (gnus-summary-article-header (caar scored))
9403 (and (setq h (gnus-number-to-header (caar scored)))
9404 (< (cdar scored) gnus-summary-expunge-below)
9406 (setq scored (cdr scored)))
9408 (when (not no-error)
9409 (error "No expunged articles hidden"))
9410 (goto-char (point-min))
9411 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9412 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9413 (mapcar (lambda (x) (push (mail-header-number x)
9414 gnus-newsgroup-limit))
9416 (gnus-summary-prepare-unthreaded (nreverse headers))
9417 (goto-char (point-min))
9418 (gnus-summary-position-point)
9421 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9422 "Mark all unread articles in this newsgroup as read.
9423 If prefix argument ALL is non-nil, ticked and dormant articles will
9424 also be marked as read.
9425 If QUIETLY is non-nil, no questions will be asked.
9426 If TO-HERE is non-nil, it should be a point in the buffer. All
9427 articles before (after, if REVERSE is set) this point will be marked as read.
9428 Note that this function will only catch up the unread article
9429 in the current summary buffer limitation.
9430 The number of articles marked as read is returned."
9435 (not gnus-interactive-catchup) ;Without confirmation?
9439 "Mark absolutely all articles as read? "
9440 "Mark all unread articles as read? ")))
9442 (not gnus-newsgroup-adaptive)
9443 (not gnus-newsgroup-auto-expire)
9444 (not gnus-suppress-duplicates)
9445 (or (not gnus-use-cache)
9446 (eq gnus-use-cache 'passive)))
9449 (setq gnus-newsgroup-marked nil
9450 gnus-newsgroup-dormant nil))
9451 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9452 ;; We actually mark all articles as canceled, which we
9453 ;; have to do when using auto-expiry or adaptive scoring.
9454 (gnus-summary-show-all-threads)
9455 (if (and to-here reverse)
9459 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9460 (gnus-summary-find-next (not all) nil nil t))))
9461 (when (gnus-summary-first-subject (not all) t)
9463 (if to-here (< (point) to-here) t)
9464 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9465 (gnus-summary-find-next (not all) nil nil t)))))
9466 (gnus-set-mode-line 'summary))
9468 (gnus-summary-position-point)))
9470 (defun gnus-summary-catchup-to-here (&optional all)
9471 "Mark all unticked articles before the current one as read.
9472 If ALL is non-nil, also mark ticked and dormant articles as read."
9475 (gnus-save-hidden-threads
9476 (let ((beg (point)))
9477 ;; We check that there are unread articles.
9478 (when (or all (gnus-summary-find-prev))
9479 (gnus-summary-catchup all t beg)))))
9480 (gnus-summary-position-point))
9482 (defun gnus-summary-catchup-from-here (&optional all)
9483 "Mark all unticked articles after the current one as read.
9484 If ALL is non-nil, also mark ticked and dormant articles as read."
9487 (gnus-save-hidden-threads
9488 (let ((beg (point)))
9489 ;; We check that there are unread articles.
9490 (when (or all (gnus-summary-find-next))
9491 (gnus-summary-catchup all t beg nil t)))))
9493 (gnus-summary-position-point))
9494 (defun gnus-summary-catchup-all (&optional quietly)
9495 "Mark all articles in this newsgroup as read."
9497 (gnus-summary-catchup t quietly))
9499 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9500 "Mark all unread articles in this group as read, then exit.
9501 If prefix argument ALL is non-nil, all articles are marked as read.
9502 If QUIETLY is non-nil, no questions will be asked."
9504 (when (gnus-summary-catchup all quietly nil 'fast)
9505 ;; Select next newsgroup or exit.
9506 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9507 (eq gnus-auto-select-next 'quietly))
9508 (gnus-summary-next-group nil)
9509 (gnus-summary-exit))))
9511 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9512 "Mark all articles in this newsgroup as read, and then exit."
9514 (gnus-summary-catchup-and-exit t quietly))
9516 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9517 "Mark all articles in this group as read and select the next group.
9518 If given a prefix, mark all articles, unread as well as ticked, as
9522 (gnus-summary-catchup all))
9523 (gnus-summary-next-group))
9529 (defmacro gnus-with-article (article &rest forms)
9530 "Select ARTICLE and perform FORMS in the original article buffer.
9531 Then replace the article with the result."
9533 ;; We don't want the article to be marked as read.
9534 (let (gnus-mark-article-hook)
9535 (gnus-summary-select-article t t nil ,article))
9536 (set-buffer gnus-original-article-buffer)
9538 (if (not (gnus-check-backend-function
9539 'request-replace-article (car gnus-article-current)))
9540 (gnus-message 5 "Read-only group; not replacing")
9541 (unless (gnus-request-replace-article
9542 ,article (car gnus-article-current)
9544 (error "Couldn't replace article")))
9545 ;; The cache and backlog have to be flushed somewhat.
9546 (when gnus-keep-backlog
9547 (gnus-backlog-remove-article
9548 (car gnus-article-current) (cdr gnus-article-current)))
9549 (when gnus-use-cache
9550 (gnus-cache-update-article
9551 (car gnus-article-current) (cdr gnus-article-current)))))
9553 (put 'gnus-with-article 'lisp-indent-function 1)
9554 (put 'gnus-with-article 'edebug-form-spec '(form body))
9556 ;; Thread-based commands.
9558 (defun gnus-summary-articles-in-thread (&optional article)
9559 "Return a list of all articles in the current thread.
9560 If ARTICLE is non-nil, return all articles in the thread that starts
9562 (let* ((article (or article (gnus-summary-article-number)))
9563 (data (gnus-data-find-list article))
9564 (top-level (gnus-data-level (car data)))
9566 (cond ((null gnus-thread-operation-ignore-subject)
9567 (gnus-simplify-subject-re
9568 (mail-header-subject (gnus-data-header (car data)))))
9569 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9570 (gnus-simplify-subject-fuzzy
9571 (mail-header-subject (gnus-data-header (car data)))))
9573 (end-point (save-excursion
9574 (if (gnus-summary-go-to-next-thread)
9575 (point) (point-max))))
9578 (< (gnus-data-pos (car data)) end-point))
9579 (when (or (not top-subject)
9580 (string= top-subject
9581 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9582 (gnus-simplify-subject-fuzzy
9583 (mail-header-subject
9584 (gnus-data-header (car data))))
9585 (gnus-simplify-subject-re
9586 (mail-header-subject
9587 (gnus-data-header (car data)))))))
9588 (push (gnus-data-number (car data)) articles))
9589 (unless (and (setq data (cdr data))
9590 (> (gnus-data-level (car data)) top-level))
9592 ;; Return the list of articles.
9593 (nreverse articles)))
9595 (defun gnus-summary-rethread-current ()
9596 "Rethread the thread the current article is part of."
9598 (let* ((gnus-show-threads t)
9599 (article (gnus-summary-article-number))
9600 (id (mail-header-id (gnus-summary-article-header)))
9601 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9603 (error "No article on the current line"))
9604 (gnus-rebuild-thread id)
9605 (gnus-summary-goto-subject article)))
9607 (defun gnus-summary-reparent-thread ()
9608 "Make the current article child of the marked (or previous) article.
9610 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9611 is non-nil or the Subject: of both articles are the same."
9613 (unless (not (gnus-group-read-only-p))
9614 (error "The current newsgroup does not support article editing"))
9615 (unless (<= (length gnus-newsgroup-processable) 1)
9616 (error "No more than one article may be marked"))
9617 (save-window-excursion
9618 (let ((gnus-article-buffer " *reparent*")
9619 (current-article (gnus-summary-article-number))
9620 ;; First grab the marked article, otherwise one line up.
9621 (parent-article (if (not (null gnus-newsgroup-processable))
9622 (car gnus-newsgroup-processable)
9624 (if (eq (forward-line -1) 0)
9625 (gnus-summary-article-number)
9626 (error "Beginning of summary buffer"))))))
9627 (unless (not (eq current-article parent-article))
9628 (error "An article may not be self-referential"))
9629 (let ((message-id (mail-header-id
9630 (gnus-summary-article-header parent-article))))
9631 (unless (and message-id (not (equal message-id "")))
9632 (error "No message-id in desired parent"))
9633 (gnus-with-article current-article
9635 (goto-char (point-min))
9636 (message-narrow-to-head)
9637 (if (re-search-forward "^References: " nil t)
9639 (re-search-forward "^[^ \t]" nil t)
9642 (insert " " message-id))
9643 (insert "References: " message-id "\n"))))
9644 (set-buffer gnus-summary-buffer)
9645 (gnus-summary-unmark-all-processable)
9646 (gnus-summary-update-article current-article)
9647 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9648 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9649 (gnus-summary-rethread-current)
9650 (gnus-message 3 "Article %d is now the child of article %d"
9651 current-article parent-article)))))
9653 (defun gnus-summary-toggle-threads (&optional arg)
9654 "Toggle showing conversation threads.
9655 If ARG is positive number, turn showing conversation threads on."
9657 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9658 (setq gnus-show-threads
9659 (if (null arg) (not gnus-show-threads)
9660 (> (prefix-numeric-value arg) 0)))
9661 (gnus-summary-prepare)
9662 (gnus-summary-goto-subject current)
9663 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9664 (gnus-summary-position-point)))
9666 (defun gnus-summary-show-all-threads ()
9670 (let ((buffer-read-only nil))
9671 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9672 (gnus-summary-position-point))
9674 (defun gnus-summary-show-thread ()
9675 "Show thread subtrees.
9676 Returns nil if no thread was there to be shown."
9678 (let ((buffer-read-only nil)
9680 ;; first goto end then to beg, to have point at beg after let
9681 (end (progn (end-of-line) (point)))
9682 (beg (progn (beginning-of-line) (point))))
9684 ;; Any hidden lines here?
9685 (search-forward "\r" end t)
9686 (subst-char-in-region beg end ?\^M ?\n t)
9688 (gnus-summary-position-point))))
9690 (defun gnus-summary-maybe-hide-threads ()
9691 "If requested, hide the threads that should be hidden."
9692 (when (and gnus-show-threads
9693 gnus-thread-hide-subtree)
9694 (gnus-summary-hide-all-threads
9695 (if (or (consp gnus-thread-hide-subtree)
9696 (gnus-functionp gnus-thread-hide-subtree))
9697 (gnus-make-predicate gnus-thread-hide-subtree)
9700 ;;; Hiding predicates.
9702 (defun gnus-article-unread-p (header)
9703 (memq (mail-header-number header) gnus-newsgroup-unreads))
9705 (defun gnus-article-unseen-p (header)
9706 (memq (mail-header-number header) gnus-newsgroup-unseen))
9708 (defun gnus-map-articles (predicate articles)
9709 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
9710 (apply 'gnus-or (mapcar predicate
9711 (mapcar 'gnus-summary-article-header articles))))
9713 (defun gnus-summary-hide-all-threads (&optional predicate)
9714 "Hide all thread subtrees.
9715 If PREDICATE is supplied, threads that satisfy this predicate
9716 will not be hidden."
9719 (goto-char (point-min))
9722 (when (or (not predicate)
9724 predicate (gnus-summary-article-children)))
9725 (gnus-summary-hide-thread))
9726 (setq end (zerop (gnus-summary-next-thread 1 t))))))
9727 (gnus-summary-position-point))
9729 (defun gnus-summary-hide-thread ()
9730 "Hide thread subtrees.
9731 If PREDICATE is supplied, threads that satisfy this predicate
9733 Returns nil if no threads were there to be hidden."
9735 (let ((buffer-read-only nil)
9737 (article (gnus-summary-article-number)))
9739 ;; Go forward until either the buffer ends or the subthread
9741 (when (and (not (eobp))
9742 (or (zerop (gnus-summary-next-thread 1 t))
9743 (goto-char (point-max))))
9745 (if (and (> (point) start)
9746 (search-backward "\n" start t))
9748 (subst-char-in-region start (point) ?\n ?\^M)
9749 (gnus-summary-goto-subject article))
9753 (defun gnus-summary-go-to-next-thread (&optional previous)
9754 "Go to the same level (or less) next thread.
9755 If PREVIOUS is non-nil, go to previous thread instead.
9756 Return the article number moved to, or nil if moving was impossible."
9757 (let ((level (gnus-summary-thread-level))
9758 (way (if previous -1 1))
9761 (while (and (not (eobp))
9762 (< level (gnus-summary-thread-level)))
9770 (gnus-summary-article-number)
9773 (defun gnus-summary-next-thread (n &optional silent)
9774 "Go to the same level next N'th thread.
9775 If N is negative, search backward instead.
9776 Returns the difference between N and the number of skips actually
9779 If SILENT, don't output messages."
9781 (let ((backward (< n 0))
9784 (gnus-summary-go-to-next-thread backward))
9787 (gnus-summary-position-point))
9788 (when (and (not silent) (/= 0 n))
9789 (gnus-message 7 "No more threads"))
9792 (defun gnus-summary-prev-thread (n)
9793 "Go to the same level previous N'th thread.
9794 Returns the difference between N and the number of skips actually
9797 (gnus-summary-next-thread (- n)))
9799 (defun gnus-summary-go-down-thread ()
9800 "Go down one level in the current thread."
9801 (let ((children (gnus-summary-article-children)))
9803 (gnus-summary-goto-subject (car children)))))
9805 (defun gnus-summary-go-up-thread ()
9806 "Go up one level in the current thread."
9807 (let ((parent (gnus-summary-article-parent)))
9809 (gnus-summary-goto-subject parent))))
9811 (defun gnus-summary-down-thread (n)
9812 "Go down thread N steps.
9813 If N is negative, go up instead.
9814 Returns the difference between N and how many steps down that were
9820 (if up (gnus-summary-go-up-thread)
9821 (gnus-summary-go-down-thread)))
9823 (gnus-summary-position-point)
9825 (gnus-message 7 "Can't go further"))
9828 (defun gnus-summary-up-thread (n)
9829 "Go up thread N steps.
9830 If N is negative, go down instead.
9831 Returns the difference between N and how many steps down that were
9834 (gnus-summary-down-thread (- n)))
9836 (defun gnus-summary-top-thread ()
9837 "Go to the top of the thread."
9839 (while (gnus-summary-go-up-thread))
9840 (gnus-summary-article-number))
9842 (defun gnus-summary-kill-thread (&optional unmark)
9843 "Mark articles under current thread as read.
9844 If the prefix argument is positive, remove any kinds of marks.
9845 If the prefix argument is negative, tick articles instead."
9848 (setq unmark (prefix-numeric-value unmark)))
9849 (let ((articles (gnus-summary-articles-in-thread)))
9851 ;; Expand the thread.
9852 (gnus-summary-show-thread)
9853 ;; Mark all the articles.
9855 (gnus-summary-goto-subject (car articles))
9856 (cond ((null unmark)
9857 (gnus-summary-mark-article-as-read gnus-killed-mark))
9859 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9861 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9862 (setq articles (cdr articles))))
9863 ;; Hide killed subtrees.
9865 gnus-thread-hide-killed
9866 (gnus-summary-hide-thread))
9867 ;; If marked as read, go to next unread subject.
9869 ;; Go to next unread subject.
9870 (gnus-summary-next-subject 1 t)))
9871 (gnus-set-mode-line 'summary))
9873 ;; Summary sorting commands
9875 (defun gnus-summary-sort-by-number (&optional reverse)
9876 "Sort the summary buffer by article number.
9877 Argument REVERSE means reverse order."
9879 (gnus-summary-sort 'number reverse))
9881 (defun gnus-summary-sort-by-author (&optional reverse)
9882 "Sort the summary buffer by author name alphabetically.
9883 If `case-fold-search' is non-nil, case of letters is ignored.
9884 Argument REVERSE means reverse order."
9886 (gnus-summary-sort 'author reverse))
9888 (defun gnus-summary-sort-by-subject (&optional reverse)
9889 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9890 If `case-fold-search' is non-nil, case of letters is ignored.
9891 Argument REVERSE means reverse order."
9893 (gnus-summary-sort 'subject reverse))
9895 (defun gnus-summary-sort-by-date (&optional reverse)
9896 "Sort the summary buffer by date.
9897 Argument REVERSE means reverse order."
9899 (gnus-summary-sort 'date reverse))
9901 (defun gnus-summary-sort-by-score (&optional reverse)
9902 "Sort the summary buffer by score.
9903 Argument REVERSE means reverse order."
9905 (gnus-summary-sort 'score reverse))
9907 (defun gnus-summary-sort-by-lines (&optional reverse)
9908 "Sort the summary buffer by the number of lines.
9909 Argument REVERSE means reverse order."
9911 (gnus-summary-sort 'lines reverse))
9913 (defun gnus-summary-sort-by-chars (&optional reverse)
9914 "Sort the summary buffer by article length.
9915 Argument REVERSE means reverse order."
9917 (gnus-summary-sort 'chars reverse))
9919 (defun gnus-summary-sort-by-original (&optional reverse)
9920 "Sort the summary buffer using the default sorting method.
9921 Argument REVERSE means reverse order."
9923 (let* ((buffer-read-only)
9924 (gnus-summary-prepare-hook nil))
9925 ;; We do the sorting by regenerating the threads.
9926 (gnus-summary-prepare)
9927 ;; Hide subthreads if needed.
9928 (gnus-summary-maybe-hide-threads)))
9930 (defun gnus-summary-sort (predicate reverse)
9931 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9932 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9933 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9934 (gnus-thread-sort-functions
9939 (gnus-sort-gathered-threads-function
9940 gnus-thread-sort-functions)
9941 (gnus-article-sort-functions
9947 (gnus-summary-prepare-hook nil))
9948 ;; We do the sorting by regenerating the threads.
9949 (gnus-summary-prepare)
9950 ;; Hide subthreads if needed.
9951 (gnus-summary-maybe-hide-threads)))
9953 ;; Summary saving commands.
9955 (defun gnus-summary-save-article (&optional n not-saved)
9956 "Save the current article using the default saver function.
9957 If N is a positive number, save the N next articles.
9958 If N is a negative number, save the N previous articles.
9959 If N is nil and any articles have been marked with the process mark,
9960 save those articles instead.
9961 The variable `gnus-default-article-saver' specifies the saver function."
9963 (let* ((articles (gnus-summary-work-articles n))
9964 (save-buffer (save-excursion
9965 (nnheader-set-temp-buffer " *Gnus Save*")))
9966 (num (length articles))
9968 (dolist (article articles)
9969 (setq header (gnus-summary-article-header article))
9970 (if (not (vectorp header))
9971 ;; This is a pseudo-article.
9972 (if (assq 'name header)
9973 (gnus-copy-file (cdr (assq 'name header)))
9974 (gnus-message 1 "Article %d is unsaveable" article))
9975 ;; This is a real article.
9976 (save-window-excursion
9977 (let ((gnus-display-mime-function nil)
9978 (gnus-article-prepare-hook nil))
9979 (gnus-summary-select-article t nil nil article)))
9981 (set-buffer save-buffer)
9983 (insert-buffer-substring gnus-original-article-buffer))
9984 (setq file (gnus-article-save save-buffer file num))
9985 (gnus-summary-remove-process-mark article)
9987 (gnus-summary-set-saved-mark article))))
9988 (gnus-kill-buffer save-buffer)
9989 (gnus-summary-position-point)
9990 (gnus-set-mode-line 'summary)
9993 (defun gnus-summary-pipe-output (&optional arg)
9994 "Pipe the current article to a subprocess.
9995 If N is a positive number, pipe the N next articles.
9996 If N is a negative number, pipe the N previous articles.
9997 If N is nil and any articles have been marked with the process mark,
9998 pipe those articles instead."
10000 (require 'gnus-art)
10001 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10002 (gnus-summary-save-article arg t))
10003 (let ((buffer (get-buffer "*Shell Command Output*")))
10005 (with-current-buffer buffer (> (point-max) (point-min))))
10006 (gnus-configure-windows 'pipe))))
10008 (defun gnus-summary-save-article-mail (&optional arg)
10009 "Append the current article to an mail file.
10010 If N is a positive number, save the N next articles.
10011 If N is a negative number, save the N previous articles.
10012 If N is nil and any articles have been marked with the process mark,
10013 save those articles instead."
10015 (require 'gnus-art)
10016 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10017 (gnus-summary-save-article arg)))
10019 (defun gnus-summary-save-article-rmail (&optional arg)
10020 "Append the current article to an rmail file.
10021 If N is a positive number, save the N next articles.
10022 If N is a negative number, save the N previous articles.
10023 If N is nil and any articles have been marked with the process mark,
10024 save those articles instead."
10026 (require 'gnus-art)
10027 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10028 (gnus-summary-save-article arg)))
10030 (defun gnus-summary-save-article-file (&optional arg)
10031 "Append the current article to a file.
10032 If N is a positive number, save the N next articles.
10033 If N is a negative number, save the N previous articles.
10034 If N is nil and any articles have been marked with the process mark,
10035 save those articles instead."
10037 (require 'gnus-art)
10038 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10039 (gnus-summary-save-article arg)))
10041 (defun gnus-summary-write-article-file (&optional arg)
10042 "Write the current article to a file, deleting the previous file.
10043 If N is a positive number, save the N next articles.
10044 If N is a negative number, save the N previous articles.
10045 If N is nil and any articles have been marked with the process mark,
10046 save those articles instead."
10048 (require 'gnus-art)
10049 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10050 (gnus-summary-save-article arg)))
10052 (defun gnus-summary-save-article-body-file (&optional arg)
10053 "Append the current article body to a file.
10054 If N is a positive number, save the N next articles.
10055 If N is a negative number, save the N previous articles.
10056 If N is nil and any articles have been marked with the process mark,
10057 save those articles instead."
10059 (require 'gnus-art)
10060 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10061 (gnus-summary-save-article arg)))
10063 (defun gnus-summary-muttprint (&optional arg)
10064 "Print the current article using Muttprint.
10065 If N is a positive number, save the N next articles.
10066 If N is a negative number, save the N previous articles.
10067 If N is nil and any articles have been marked with the process mark,
10068 save those articles instead."
10070 (require 'gnus-art)
10071 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10072 (gnus-summary-save-article arg t)))
10074 (defun gnus-summary-pipe-message (program)
10075 "Pipe the current article through PROGRAM."
10076 (interactive "sProgram: ")
10077 (gnus-summary-select-article)
10078 (let ((mail-header-separator ""))
10079 (gnus-eval-in-buffer-window gnus-article-buffer
10082 (let ((start (window-start))
10084 (message-pipe-buffer-body program)
10085 (set-window-start (get-buffer-window (current-buffer)) start))))))
10087 (defun gnus-get-split-value (methods)
10088 "Return a value based on the split METHODS."
10089 (let (split-name method result match)
10092 (set-buffer gnus-original-article-buffer)
10094 (nnheader-narrow-to-headers)
10095 (while (and methods (not split-name))
10096 (goto-char (point-min))
10097 (setq method (pop methods))
10098 (setq match (car method))
10101 ;; Regular expression.
10103 (re-search-forward match nil t)))
10104 ((gnus-functionp match)
10108 (setq result (funcall match gnus-newsgroup-name))))
10113 (setq result (eval match)))))
10114 (setq split-name (cdr method))
10115 (cond ((stringp result)
10116 (push (expand-file-name
10117 result gnus-article-save-directory)
10120 (setq split-name (append result split-name)))))))))
10121 (nreverse split-name)))
10123 (defun gnus-valid-move-group-p (group)
10124 (and (boundp group)
10125 (symbol-name group)
10126 (symbol-value group)
10127 (gnus-get-function (gnus-find-method-for-group
10128 (symbol-name group)) 'request-accept-article t)))
10130 (defun gnus-read-move-group-name (prompt default articles prefix)
10131 "Read a group name."
10132 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10133 (minibuffer-confirm-incomplete nil) ; XEmacs
10135 (format "%s %s to:"
10137 (if (> (length articles) 1)
10138 (format "these %d articles" (length articles))
10143 (gnus-completing-read default prom
10145 'gnus-valid-move-group-p
10147 'gnus-group-history))
10148 ((= 1 (length split-name))
10149 (gnus-completing-read (car split-name) prom
10151 'gnus-valid-move-group-p
10153 'gnus-group-history))
10155 (gnus-completing-read nil prom
10156 (mapcar (lambda (el) (list el))
10157 (nreverse split-name))
10159 'gnus-group-history))))
10160 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10162 (if (or (string= to-newsgroup "")
10163 (string= to-newsgroup prefix))
10164 (setq to-newsgroup default))
10165 (unless to-newsgroup
10166 (error "No group name entered"))
10167 (or (gnus-active to-newsgroup)
10168 (gnus-activate-group to-newsgroup nil nil to-method)
10169 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10171 (or (and (gnus-request-create-group to-newsgroup to-method)
10172 (gnus-activate-group
10173 to-newsgroup nil nil to-method)
10174 (gnus-subscribe-group to-newsgroup))
10175 (error "Couldn't create group %s" to-newsgroup)))
10176 (error "No such group: %s" to-newsgroup)))
10179 (defun gnus-summary-save-parts (type dir n &optional reverse)
10180 "Save parts matching TYPE to DIR.
10181 If REVERSE, save parts that do not match TYPE."
10183 (list (read-string "Save parts of type: "
10184 (or (car gnus-summary-save-parts-type-history)
10185 gnus-summary-save-parts-default-mime)
10186 'gnus-summary-save-parts-type-history)
10187 (setq gnus-summary-save-parts-last-directory
10188 (read-file-name "Save to directory: "
10189 gnus-summary-save-parts-last-directory
10191 current-prefix-arg))
10192 (gnus-summary-iterate n
10193 (let ((gnus-display-mime-function nil)
10194 (gnus-inhibit-treatment t))
10195 (gnus-summary-select-article))
10197 (set-buffer gnus-article-buffer)
10198 (let ((handles (or gnus-article-mime-handles
10199 (mm-dissect-buffer) (mm-uu-dissect))))
10201 (gnus-summary-save-parts-1 type dir handles reverse)
10202 (unless gnus-article-mime-handles ;; Don't destroy this case.
10203 (mm-destroy-parts handles)))))))
10205 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10206 (if (stringp (car handle))
10207 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10210 (not (string-match type (mm-handle-media-type handle)))
10211 (string-match type (mm-handle-media-type handle)))
10212 (let ((file (expand-file-name
10213 (file-name-nondirectory
10215 (mail-content-type-get
10216 (mm-handle-disposition handle) 'filename)
10217 (concat gnus-newsgroup-name
10218 "." (number-to-string
10219 (cdr gnus-article-current)))))
10221 (unless (file-exists-p file)
10222 (mm-save-part-to-file handle file))))))
10224 ;; Summary extract commands
10226 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10227 (let ((buffer-read-only nil)
10228 (article (gnus-summary-article-number))
10230 (unless (gnus-summary-goto-subject article)
10231 (error "No such article: %d" article))
10232 (gnus-summary-position-point)
10233 ;; If all commands are to be bunched up on one line, we collect
10235 (unless gnus-view-pseudos-separately
10236 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10239 (setq action (cdr (assq 'action (car ps))))
10240 (setq files (list (cdr (assq 'name (car ps)))))
10241 (while (and ps (cdr ps)
10242 (string= (or action "1")
10243 (or (cdr (assq 'action (cadr ps))) "2")))
10244 (push (cdr (assq 'name (cadr ps))) files)
10245 (setcdr ps (cddr ps)))
10247 (when (not (string-match "%s" action))
10250 (when (assq 'execute (car ps))
10251 (setcdr (assq 'execute (car ps))
10252 (funcall (if (string-match "%s" action)
10261 (setq ps (cdr ps)))))
10262 (if (and gnus-view-pseudos (not not-view))
10264 (when (assq 'execute (car pslist))
10265 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10266 (eq gnus-view-pseudos 'not-confirm)))
10267 (setq pslist (cdr pslist)))
10270 (setq after-article (or (cdr (assq 'article (car pslist)))
10271 (gnus-summary-article-number)))
10272 (gnus-summary-goto-subject after-article)
10275 (insert " " (file-name-nondirectory
10276 (cdr (assq 'name (car pslist))))
10277 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10279 (forward-line -1) ; back to `b'
10280 (gnus-add-text-properties
10281 b (1- e) (list 'gnus-number gnus-reffed-article-number
10282 gnus-mouse-face-prop gnus-mouse-face))
10284 after-article gnus-reffed-article-number
10285 gnus-unread-mark b (car pslist) 0 (- e b))
10286 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10287 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10288 (setq pslist (cdr pslist)))))))
10290 (defun gnus-pseudos< (p1 p2)
10291 (let ((c1 (cdr (assq 'action p1)))
10292 (c2 (cdr (assq 'action p2))))
10293 (and c1 c2 (string< c1 c2))))
10295 (defun gnus-request-pseudo-article (props)
10296 (cond ((assq 'execute props)
10297 (gnus-execute-command (cdr (assq 'execute props)))))
10298 (let ((gnus-current-article (gnus-summary-article-number)))
10299 (gnus-run-hooks 'gnus-mark-article-hook)))
10301 (defun gnus-execute-command (command &optional automatic)
10303 (gnus-article-setup-buffer)
10304 (set-buffer gnus-article-buffer)
10305 (setq buffer-read-only nil)
10306 (let ((command (if automatic command
10307 (read-string "Command: " (cons command 0)))))
10309 (insert "$ " command "\n\n")
10310 (if gnus-view-pseudo-asynchronously
10311 (start-process "gnus-execute" (current-buffer) shell-file-name
10312 shell-command-switch command)
10313 (call-process shell-file-name nil t nil
10314 shell-command-switch command)))))
10316 ;; Summary kill commands.
10318 (defun gnus-summary-edit-global-kill (article)
10319 "Edit the \"global\" kill file."
10320 (interactive (list (gnus-summary-article-number)))
10321 (gnus-group-edit-global-kill article))
10323 (defun gnus-summary-edit-local-kill ()
10324 "Edit a local kill file applied to the current newsgroup."
10326 (setq gnus-current-headers (gnus-summary-article-header))
10327 (gnus-group-edit-local-kill
10328 (gnus-summary-article-number) gnus-newsgroup-name))
10330 ;;; Header reading.
10332 (defun gnus-read-header (id &optional header)
10333 "Read the headers of article ID and enter them into the Gnus system."
10334 (let ((group gnus-newsgroup-name)
10335 (gnus-override-method
10337 gnus-override-method
10338 (and (gnus-news-group-p gnus-newsgroup-name)
10339 (car (gnus-refer-article-methods)))))
10341 ;; First we check to see whether the header in question is already
10344 ;; This is a Message-ID.
10345 (setq header (or header (gnus-id-to-header id)))
10346 ;; This is an article number.
10347 (setq header (or header (gnus-summary-article-header id))))
10349 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10350 ;; We have found the header.
10352 ;; If this is a sparse article, we have to nix out its
10353 ;; previous entry in the thread hashtb.
10355 (gnus-summary-article-sparse-p (mail-header-number header)))
10356 (let* ((parent (gnus-parent-id (mail-header-references header)))
10357 (thread (and parent (gnus-id-to-thread parent))))
10359 (delq (assq header thread) thread))))
10360 ;; We have to really fetch the header to this article.
10362 (set-buffer nntp-server-buffer)
10363 (when (setq where (gnus-request-head id group))
10364 (nnheader-fold-continuation-lines)
10365 (goto-char (point-max))
10367 (goto-char (point-min))
10371 ((cdr where) (cdr where))
10372 (header (mail-header-number header))
10373 (t gnus-reffed-article-number))
10375 (insert " Article retrieved.\n"))
10376 (if (or (not where)
10377 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10378 () ; Malformed head.
10379 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10380 (when (and (stringp id)
10381 (not (string= (gnus-group-real-name group)
10383 ;; If we fetched by Message-ID and the article came
10384 ;; from a different group, we fudge some bogus article
10385 ;; numbers for this article.
10386 (mail-header-set-number header gnus-reffed-article-number))
10388 (set-buffer gnus-summary-buffer)
10389 (decf gnus-reffed-article-number)
10390 (gnus-remove-header (mail-header-number header))
10391 (push header gnus-newsgroup-headers)
10392 (setq gnus-current-headers header)
10393 (push (mail-header-number header) gnus-newsgroup-limit)))
10396 (defun gnus-remove-header (number)
10397 "Remove header NUMBER from `gnus-newsgroup-headers'."
10398 (if (and gnus-newsgroup-headers
10399 (= number (mail-header-number (car gnus-newsgroup-headers))))
10400 (pop gnus-newsgroup-headers)
10401 (let ((headers gnus-newsgroup-headers))
10402 (while (and (cdr headers)
10403 (not (= number (mail-header-number (cadr headers)))))
10405 (when (cdr headers)
10406 (setcdr headers (cddr headers))))))
10409 ;;; summary highlights
10412 (defun gnus-highlight-selected-summary ()
10413 "Highlight selected article in summary buffer."
10414 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10415 (when gnus-summary-selected-face
10417 (let* ((beg (progn (beginning-of-line) (point)))
10418 (end (progn (end-of-line) (point)))
10419 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10420 (from (if (get-text-property beg gnus-mouse-face-prop)
10422 (or (next-single-property-change
10423 beg gnus-mouse-face-prop nil end)
10428 (or (next-single-property-change
10429 from gnus-mouse-face-prop nil end)
10431 ;; If no mouse-face prop on line we will have to = from = end,
10432 ;; so we highlight the entire line instead.
10433 (when (= (+ to 2) from)
10436 (if gnus-newsgroup-selected-overlay
10437 ;; Move old overlay.
10439 gnus-newsgroup-selected-overlay from to (current-buffer))
10440 ;; Create new overlay.
10442 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10443 'face gnus-summary-selected-face))))))
10445 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10446 (defun gnus-summary-highlight-line ()
10447 "Highlight current line according to `gnus-summary-highlight'."
10448 (let* ((list gnus-summary-highlight)
10450 (end (progn (end-of-line) (point)))
10451 ;; now find out where the line starts and leave point there.
10452 (beg (progn (beginning-of-line) (point)))
10453 (article (gnus-summary-article-number))
10454 (score (or (cdr (assq (or article gnus-current-article)
10455 gnus-newsgroup-scored))
10456 gnus-summary-default-score 0))
10457 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10458 (inhibit-read-only t))
10459 ;; Eval the cars of the lists until we find a match.
10460 (let ((default gnus-summary-default-score)
10461 (default-high gnus-summary-default-high-score)
10462 (default-low gnus-summary-default-low-score))
10464 (not (eval (caar list))))
10465 (setq list (cdr list))))
10466 (let ((face (cdar list)))
10467 (unless (eq face (get-text-property beg 'face))
10468 (gnus-put-text-property-excluding-characters-with-faces
10470 (setq face (if (boundp face) (symbol-value face) face)))
10471 (when gnus-summary-highlight-line-function
10472 (funcall gnus-summary-highlight-line-function article face))))
10475 (defun gnus-update-read-articles (group unread &optional compute)
10476 "Update the list of read articles in GROUP."
10477 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10478 (entry (gnus-gethash group gnus-newsrc-hashtb))
10479 (info (nth 2 entry))
10481 (unread (sort (copy-sequence unread) '<))
10483 (if (or (not info) (not active))
10484 ;; There is no info on this group if it was, in fact,
10485 ;; killed. Gnus stores no information on killed groups, so
10486 ;; there's nothing to be done.
10487 ;; One could store the information somewhere temporarily,
10488 ;; perhaps... Hmmm...
10490 ;; Remove any negative articles numbers.
10491 (while (and unread (< (car unread) 0))
10492 (setq unread (cdr unread)))
10493 ;; Remove any expired article numbers
10494 (while (and unread (< (car unread) (car active)))
10495 (setq unread (cdr unread)))
10496 ;; Compute the ranges of read articles by looking at the list of
10497 ;; unread articles.
10499 (when (/= (car unread) prev)
10500 (push (if (= prev (1- (car unread))) prev
10501 (cons prev (1- (car unread))))
10503 (setq prev (1+ (car unread)))
10504 (setq unread (cdr unread)))
10505 (when (<= prev (cdr active))
10506 (push (cons prev (cdr active)) read))
10507 (setq read (if (> (length read) 1) (nreverse read) read))
10512 ;; Propagate the read marks to the backend.
10513 (when (gnus-check-backend-function 'request-set-mark group)
10514 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10515 (add (gnus-remove-from-range read (gnus-info-read info))))
10517 (unless (gnus-check-group group)
10518 (error "Can't open server for %s" group))
10519 (gnus-request-set-mark
10520 group (delq nil (list (if add (list add 'add '(read)))
10521 (if del (list del 'del '(read))))))
10523 `(gnus-request-set-mark
10526 (if del (list del 'add '(read)))
10527 (if add (list add 'del '(read))))))))))
10528 (set-buffer gnus-group-buffer)
10529 (gnus-undo-register
10531 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10532 (gnus-info-set-read ',info ',(gnus-info-read info))
10533 (gnus-get-unread-articles-in-group ',info
10534 (gnus-active ,group))
10535 (gnus-group-update-group ,group t)
10537 ;; Enter this list into the group info.
10538 (gnus-info-set-read info read)
10539 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10540 (gnus-get-unread-articles-in-group info (gnus-active group))
10543 (defun gnus-offer-save-summaries ()
10544 "Offer to save all active summary buffers."
10546 ;; Go through all buffers and find all summaries.
10547 (dolist (buffer (buffer-list))
10548 (when (and (setq buffer (buffer-name buffer))
10549 (string-match "Summary" buffer)
10551 (set-buffer buffer)
10552 ;; We check that this is, indeed, a summary buffer.
10553 (and (eq major-mode 'gnus-summary-mode)
10554 ;; Also make sure this isn't bogus.
10555 gnus-newsgroup-prepared
10556 ;; Also make sure that this isn't a
10557 ;; dead summary buffer.
10558 (not gnus-dead-summary-mode))))
10559 (push buffer buffers)))
10560 ;; Go through all these summary buffers and offer to save them.
10564 "Update summary buffer %s? "
10566 (switch-to-buffer buf)
10567 (gnus-summary-exit))
10570 (defun gnus-summary-setup-default-charset ()
10571 "Setup newsgroup default charset."
10572 (if (equal gnus-newsgroup-name "nndraft:drafts")
10573 (setq gnus-newsgroup-charset nil)
10574 (let* ((ignored-charsets
10575 (or gnus-newsgroup-ephemeral-ignored-charsets
10577 (and gnus-newsgroup-name
10578 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10579 gnus-newsgroup-ignored-charsets))))
10580 (setq gnus-newsgroup-charset
10581 (or gnus-newsgroup-ephemeral-charset
10582 (and gnus-newsgroup-name
10583 (gnus-parameter-charset gnus-newsgroup-name))
10584 gnus-default-charset))
10585 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10586 ignored-charsets))))
10592 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10593 "Display the current article buffer fully MIME-buttonized.
10594 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10595 treated as multipart/mixed."
10597 (require 'gnus-art)
10598 (let ((gnus-unbuttonized-mime-types nil)
10599 (gnus-mime-display-multipart-as-mixed show-all-parts))
10600 (gnus-summary-show-article)))
10602 (defun gnus-summary-repair-multipart (article)
10603 "Add a Content-Type header to a multipart article without one."
10604 (interactive (list (gnus-summary-article-number)))
10605 (gnus-with-article article
10606 (message-narrow-to-head)
10607 (message-remove-header "Mime-Version")
10608 (goto-char (point-max))
10609 (insert "Mime-Version: 1.0\n")
10611 (when (search-forward "\n--" nil t)
10612 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10613 (message-narrow-to-head)
10614 (message-remove-header "Content-Type")
10615 (goto-char (point-max))
10616 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10619 (let (gnus-mark-article-hook)
10620 (gnus-summary-select-article t t nil article)))
10622 (defun gnus-summary-toggle-display-buttonized ()
10623 "Toggle the buttonizing of the article buffer."
10625 (require 'gnus-art)
10626 (if (setq gnus-inhibit-mime-unbuttonizing
10627 (not gnus-inhibit-mime-unbuttonizing))
10628 (let ((gnus-unbuttonized-mime-types nil))
10629 (gnus-summary-show-article))
10630 (gnus-summary-show-article)))
10633 ;;; Generic summary marking commands
10636 (defvar gnus-summary-marking-alist
10637 '((read gnus-del-mark "d")
10638 (unread gnus-unread-mark "u")
10639 (ticked gnus-ticked-mark "!")
10640 (dormant gnus-dormant-mark "?")
10641 (expirable gnus-expirable-mark "e"))
10642 "An alist of names/marks/keystrokes.")
10644 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10645 (defvar gnus-summary-mark-map)
10647 (defun gnus-summary-make-all-marking-commands ()
10648 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10649 (dolist (elem gnus-summary-marking-alist)
10650 (apply 'gnus-summary-make-marking-command elem)))
10652 (defun gnus-summary-make-marking-command (name mark keystroke)
10653 (let ((map (make-sparse-keymap)))
10654 (define-key gnus-summary-generic-mark-map keystroke map)
10655 (dolist (lway `((next "next" next nil "n")
10656 (next-unread "next unread" next t "N")
10657 (prev "previous" prev nil "p")
10658 (prev-unread "previous unread" prev t "P")
10659 (nomove "" nil nil ,keystroke)))
10660 (let ((func (gnus-summary-make-marking-command-1
10661 mark (car lway) lway name)))
10662 (setq func (eval func))
10663 (define-key map (nth 4 lway) func)))))
10665 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10667 (format "gnus-summary-put-mark-as-%s%s"
10668 name (if (eq way 'nomove)
10670 (concat "-" (symbol-name way)))))
10673 "Mark the current article as %s%s.
10674 If N, the prefix, then repeat N times.
10675 If N is negative, move in reverse order.
10676 The difference between N and the actual number of articles marked is
10680 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10682 (defun gnus-summary-generic-mark (n mark move unread)
10683 "Mark N articles with MARK."
10684 (unless (eq major-mode 'gnus-summary-mode)
10685 (error "This command can only be used in the summary buffer"))
10686 (gnus-summary-show-thread)
10689 ((eq move 'next) 1)
10690 ((eq move 'prev) -1)
10692 (if (zerop nummove)
10696 nummove (* -1 nummove))))
10697 (while (and (> n 0)
10698 (gnus-summary-mark-article nil mark)
10699 (zerop (gnus-summary-next-subject nummove unread t)))
10702 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10703 (gnus-summary-recenter)
10704 (gnus-summary-position-point)
10705 (gnus-set-mode-line 'summary)
10708 (defun gnus-summary-insert-articles (articles)
10709 (when (setq articles
10710 (gnus-set-difference articles
10711 (mapcar (lambda (h) (mail-header-number h))
10712 gnus-newsgroup-headers)))
10713 (setq gnus-newsgroup-headers
10715 gnus-newsgroup-headers
10716 (gnus-fetch-headers articles)
10717 'gnus-article-sort-by-number))
10718 ;; Suppress duplicates?
10719 (when gnus-suppress-duplicates
10720 (gnus-dup-suppress-articles))
10722 ;; We might want to build some more threads first.
10723 (when (and gnus-fetch-old-headers
10724 (eq gnus-headers-retrieved-by 'nov))
10725 (if (eq gnus-fetch-old-headers 'invisible)
10726 (gnus-build-all-threads)
10727 (gnus-build-old-threads)))
10728 ;; Let the Gnus agent mark articles as read.
10730 (gnus-agent-get-undownloaded-list))
10731 ;; Remove list identifiers from subject
10732 (when gnus-list-identifiers
10733 (gnus-summary-remove-list-identifiers))
10734 ;; First and last article in this newsgroup.
10735 (when gnus-newsgroup-headers
10736 (setq gnus-newsgroup-begin
10737 (mail-header-number (car gnus-newsgroup-headers))
10739 (mail-header-number
10740 (gnus-last-element gnus-newsgroup-headers))))
10741 (when gnus-use-scoring
10742 (gnus-possibly-score-headers))))
10744 (defun gnus-summary-insert-old-articles (&optional all)
10745 "Insert all old articles in this group.
10746 If ALL is non-nil, already read articles become readable.
10747 If ALL is a number, fetch this number of articles."
10750 (let ((old (mapcar 'car gnus-newsgroup-data))
10751 (i (car gnus-newsgroup-active))
10753 (while (<= i (cdr gnus-newsgroup-active))
10754 (or (memq i old) (push i older))
10756 (setq len (length older))
10761 (setq older (subseq older 0 all))))
10764 (if (and (numberp gnus-large-newsgroup)
10765 (> len gnus-large-newsgroup))
10769 "How many articles from %s (default %d): "
10771 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10773 (unless (string-match "^[ \t]*$" input)
10774 (setq all (string-to-number input))
10776 (setq older (subseq older 0 all))))))))
10778 (message "No old news.")
10779 (gnus-summary-insert-articles older)
10780 (gnus-summary-limit (gnus-union older old))))
10781 (gnus-summary-position-point)))
10783 (defun gnus-summary-insert-new-articles ()
10784 "Insert all new articles in this group."
10787 (let ((old (mapcar 'car gnus-newsgroup-data))
10788 (old-active gnus-newsgroup-active)
10789 (nnmail-fetched-sources (list t))
10791 (setq gnus-newsgroup-active
10792 (gnus-activate-group gnus-newsgroup-name 'scan))
10793 (setq i (1+ (cdr old-active)))
10794 (while (<= i (cdr gnus-newsgroup-active))
10798 (message "No gnus is bad news.")
10799 (setq new (nreverse new))
10800 (gnus-summary-insert-articles new)
10801 (setq gnus-newsgroup-unreads
10802 (append gnus-newsgroup-unreads new))
10803 (gnus-summary-limit (gnus-union old new))))
10804 (gnus-summary-position-point)))
10806 (gnus-summary-make-all-marking-commands)
10808 (gnus-ems-redefine)
10810 (provide 'gnus-sum)
10812 (run-hooks 'gnus-sum-load-hook)
10814 ;;; gnus-sum.el ends here