1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
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))
39 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
41 (defcustom gnus-kill-summary-on-exit t
42 "*If non-nil, kill the summary buffer when you exit from it.
43 If nil, the summary will become a \"*Dead Summary*\" buffer, and
44 it will be killed sometime later."
45 :group 'gnus-summary-exit
48 (defcustom gnus-fetch-old-headers nil
49 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
50 If an unread article in the group refers to an older, already read (or
51 just marked as read) article, the old article will not normally be
52 displayed in the Summary buffer. If this variable is non-nil, Gnus
53 will attempt to grab the headers to the old articles, and thereby
54 build complete threads. If it has the value `some', only enough
55 headers to connect otherwise loose threads will be displayed. This
56 variable can also be a number. In that case, no more than that number
57 of old headers will be fetched. If it has the value `invisible', all
58 old headers will be fetched, but none will be displayed.
60 The server has to support NOV for any of this to work."
62 :type '(choice (const :tag "off" nil)
65 (sexp :menu-tag "other" t)))
67 (defcustom gnus-refer-thread-limit 200
68 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
69 If t, fetch all the available old headers."
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-summary-make-false-root 'adopt
75 "*nil means that Gnus won't gather loose threads.
76 If the root of a thread has expired or been read in a previous
77 session, the information necessary to build a complete thread has been
78 lost. Instead of having many small sub-threads from this original thread
79 scattered all over the summary buffer, Gnus can gather them.
81 If non-nil, Gnus will try to gather all loose sub-threads from an
82 original thread into one large thread.
84 If this variable is non-nil, it should be one of `none', `adopt',
87 If this variable is `none', Gnus will not make a false root, but just
88 present the sub-threads after another.
89 If this variable is `dummy', Gnus will create a dummy root that will
90 have all the sub-threads as children.
91 If this variable is `adopt', Gnus will make one of the \"children\"
92 the parent and mark all the step-children as such.
93 If this variable is `empty', the \"children\" are printed with empty
94 subject fields. (Or rather, they will be printed with a string
95 given by the `gnus-summary-same-subject' variable.)"
97 :type '(choice (const :tag "off" nil)
103 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
104 "*A regexp to match subjects to be excluded from loose thread gathering.
105 As loose thread gathering is done on subjects only, that means that
106 there can be many false gatherings performed. By rooting out certain
107 common subjects, gathering might become saner."
111 (defcustom gnus-summary-gather-subject-limit nil
112 "*Maximum length of subject comparisons when gathering loose threads.
113 Use nil to compare full subjects. Setting this variable to a low
114 number will help gather threads that have been corrupted by
115 newsreaders chopping off subject lines, but it might also mean that
116 unrelated articles that have subject that happen to begin with the
117 same few characters will be incorrectly gathered.
119 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
122 :type '(choice (const :tag "off" nil)
124 (sexp :menu-tag "on" t)))
126 (defcustom gnus-simplify-subject-functions nil
127 "List of functions taking a string argument that simplify subjects.
128 The functions are applied recursively.
130 Useful functions to put in this list include: `gnus-simplify-subject-re',
131 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
133 :type '(repeat function))
135 (defcustom gnus-simplify-ignored-prefixes nil
136 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
138 :type '(choice (const :tag "off" nil)
141 (defcustom gnus-build-sparse-threads nil
142 "*If non-nil, fill in the gaps in threads.
143 If `some', only fill in the gaps that are needed to tie loose threads
144 together. If `more', fill in all leaf nodes that Gnus can find. If
145 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
147 :type '(choice (const :tag "off" nil)
150 (sexp :menu-tag "all" t)))
152 (defcustom gnus-summary-thread-gathering-function
153 'gnus-gather-threads-by-subject
154 "*Function used for gathering loose threads.
155 There are two pre-defined functions: `gnus-gather-threads-by-subject',
156 which only takes Subjects into consideration; and
157 `gnus-gather-threads-by-references', which compared the References
158 headers of the articles to find matches."
160 :type '(radio (function-item gnus-gather-threads-by-subject)
161 (function-item gnus-gather-threads-by-references)
162 (function :tag "other")))
164 (defcustom gnus-summary-same-subject ""
165 "*String indicating that the current article has the same subject as the previous.
166 This variable will only be used if the value of
167 `gnus-summary-make-false-root' is `empty'."
168 :group 'gnus-summary-format
171 (defcustom gnus-summary-goto-unread t
172 "*If t, many commands will go to the next unread article.
173 This applies to marking commands as well as other commands that
174 \"naturally\" select the next article, like, for instance, `SPC' at
175 the end of an article.
177 If nil, the marking commands do NOT go to the next unread article
178 (they go to the next article instead). If `never', commands that
179 usually go to the next unread article, will go to the next article,
180 whether it is read or not."
181 :group 'gnus-summary-marks
182 :link '(custom-manual "(gnus)Setting Marks")
183 :type '(choice (const :tag "off" nil)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-summary-default-score 0
188 "*Default article score level.
189 All scores generated by the score files will be added to this score.
190 If this variable is nil, scoring will be disabled."
191 :group 'gnus-score-default
192 :type '(choice (const :tag "disable")
195 (defcustom gnus-summary-zcore-fuzz 0
196 "*Fuzziness factor for the zcore in the summary buffer.
197 Articles with scores closer than this to `gnus-summary-default-score'
199 :group 'gnus-summary-format
202 (defcustom gnus-simplify-subject-fuzzy-regexp nil
203 "*Strings to be removed when doing fuzzy matches.
204 This can either be a regular expression or list of regular expressions
205 that will be removed from subject strings if fuzzy subject
206 simplification is selected."
208 :type '(repeat regexp))
210 (defcustom gnus-show-threads t
211 "*If non-nil, display threads in summary mode."
215 (defcustom gnus-thread-hide-subtree nil
216 "*If non-nil, hide all threads initially.
217 If threads are hidden, you have to run the command
218 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
219 to expose hidden threads."
223 (defcustom gnus-thread-hide-killed t
224 "*If non-nil, hide killed threads automatically."
228 (defcustom gnus-thread-ignore-subject t
229 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
230 If nil, articles that have different subjects from their parents will
231 start separate threads."
235 (defcustom gnus-thread-operation-ignore-subject t
236 "*If non-nil, subjects will be ignored when doing thread commands.
237 This affects commands like `gnus-summary-kill-thread' and
238 `gnus-summary-lower-thread'.
240 If this variable is nil, articles in the same thread with different
241 subjects will not be included in the operation in question. If this
242 variable is `fuzzy', only articles that have subjects that are fuzzily
243 equal will be included."
245 :type '(choice (const :tag "off" nil)
249 (defcustom gnus-thread-indent-level 4
250 "*Number that says how much each sub-thread should be indented."
254 (defcustom gnus-auto-extend-newsgroup t
255 "*If non-nil, extend newsgroup forward and backward when requested."
256 :group 'gnus-summary-choose
259 (defcustom gnus-auto-select-first t
260 "*If nil, don't select the first unread article when entering a group.
261 If this variable is `best', select the highest-scored unread article
262 in the group. If t, select the first unread article.
264 This variable can also be a function to place point on a likely
265 subject line. Useful values include `gnus-summary-first-unread-subject',
266 `gnus-summary-first-unread-article' and
267 `gnus-summary-best-unread-article'.
269 If you want to prevent automatic selection of the first unread article
270 in some newsgroups, set the variable to nil in
271 `gnus-select-group-hook'."
272 :group 'gnus-group-select
273 :type '(choice (const :tag "none" nil)
275 (sexp :menu-tag "first" t)
276 (function-item gnus-summary-first-unread-subject)
277 (function-item gnus-summary-first-unread-article)
278 (function-item gnus-summary-best-unread-article)))
280 (defcustom gnus-auto-select-next t
281 "*If non-nil, offer to go to the next group from the end of the previous.
282 If the value is t and the next newsgroup is empty, Gnus will exit
283 summary mode and go back to group mode. If the value is neither nil
284 nor t, Gnus will select the following unread newsgroup. In
285 particular, if the value is the symbol `quietly', the next unread
286 newsgroup will be selected without any confirmation, and if it is
287 `almost-quietly', the next group will be selected without any
288 confirmation if you are located on the last article in the group.
289 Finally, if this variable is `slightly-quietly', the `Z n' command
290 will go to the next group without confirmation."
291 :group 'gnus-summary-maneuvering
292 :type '(choice (const :tag "off" nil)
294 (const almost-quietly)
295 (const slightly-quietly)
296 (sexp :menu-tag "on" t)))
298 (defcustom gnus-auto-select-same nil
299 "*If non-nil, select the next article with the same subject.
300 If there are no more articles with the same subject, go to
301 the first unread article."
302 :group 'gnus-summary-maneuvering
305 (defcustom gnus-summary-check-current nil
306 "*If non-nil, consider the current article when moving.
307 The \"unread\" movement commands will stay on the same line if the
308 current article is unread."
309 :group 'gnus-summary-maneuvering
312 (defcustom gnus-auto-center-summary t
313 "*If non-nil, always center the current summary buffer.
314 In particular, if `vertical' do only vertical recentering. If non-nil
315 and non-`vertical', do both horizontal and vertical recentering."
316 :group 'gnus-summary-maneuvering
317 :type '(choice (const :tag "none" nil)
319 (integer :tag "height")
320 (sexp :menu-tag "both" t)))
322 (defcustom gnus-show-all-headers nil
323 "*If non-nil, don't hide any headers."
324 :group 'gnus-article-hiding
325 :group 'gnus-article-headers
328 (defcustom gnus-summary-ignore-duplicates nil
329 "*If non-nil, ignore articles with identical Message-ID headers."
333 (defcustom gnus-single-article-buffer t
334 "*If non-nil, display all articles in the same buffer.
335 If nil, each group will get its own article buffer."
336 :group 'gnus-article-various
339 (defcustom gnus-break-pages t
340 "*If non-nil, do page breaking on articles.
341 The page delimiter is specified by the `gnus-page-delimiter'
343 :group 'gnus-article-various
346 (defcustom gnus-move-split-methods nil
347 "*Variable used to suggest where articles are to be moved to.
348 It uses the same syntax as the `gnus-split-methods' variable."
349 :group 'gnus-summary-mail
350 :type '(repeat (choice (list :value (fun) function)
351 (cons :value ("" "") regexp (repeat string))
354 (defcustom gnus-unread-mark ? ;Whitespace
355 "*Mark used for unread articles."
356 :group 'gnus-summary-marks
359 (defcustom gnus-ticked-mark ?!
360 "*Mark used for ticked articles."
361 :group 'gnus-summary-marks
364 (defcustom gnus-dormant-mark ??
365 "*Mark used for dormant articles."
366 :group 'gnus-summary-marks
369 (defcustom gnus-del-mark ?r
370 "*Mark used for del'd articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-read-mark ?R
375 "*Mark used for read articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-expirable-mark ?E
380 "*Mark used for expirable articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-killed-mark ?K
385 "*Mark used for killed articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-souped-mark ?F
390 "*Mark used for killed articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-kill-file-mark ?X
395 "*Mark used for articles killed by kill files."
396 :group 'gnus-summary-marks
399 (defcustom gnus-low-score-mark ?Y
400 "*Mark used for articles with a low score."
401 :group 'gnus-summary-marks
404 (defcustom gnus-catchup-mark ?C
405 "*Mark used for articles that are caught up."
406 :group 'gnus-summary-marks
409 (defcustom gnus-replied-mark ?A
410 "*Mark used for articles that have been replied to."
411 :group 'gnus-summary-marks
414 (defcustom gnus-cached-mark ?*
415 "*Mark used for articles that are in the cache."
416 :group 'gnus-summary-marks
419 (defcustom gnus-saved-mark ?S
420 "*Mark used for articles that have been saved to."
421 :group 'gnus-summary-marks
424 (defcustom gnus-ancient-mark ?O
425 "*Mark used for ancient articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-sparse-mark ?Q
430 "*Mark used for sparsely reffed articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-canceled-mark ?G
435 "*Mark used for canceled articles."
436 :group 'gnus-summary-marks
439 (defcustom gnus-duplicate-mark ?M
440 "*Mark used for duplicate articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-undownloaded-mark ?@
445 "*Mark used for articles that weren't downloaded."
446 :group 'gnus-summary-marks
449 (defcustom gnus-downloadable-mark ?%
450 "*Mark used for articles that are to be downloaded."
451 :group 'gnus-summary-marks
454 (defcustom gnus-unsendable-mark ?=
455 "*Mark used for articles that won't be sent."
456 :group 'gnus-summary-marks
459 (defcustom gnus-score-over-mark ?+
460 "*Score mark used for articles with high scores."
461 :group 'gnus-summary-marks
464 (defcustom gnus-score-below-mark ?-
465 "*Score mark used for articles with low scores."
466 :group 'gnus-summary-marks
469 (defcustom gnus-empty-thread-mark ? ;Whitespace
470 "*There is no thread under the article."
471 :group 'gnus-summary-marks
474 (defcustom gnus-not-empty-thread-mark ?=
475 "*There is a thread under the article."
476 :group 'gnus-summary-marks
479 (defcustom gnus-view-pseudo-asynchronously nil
480 "*If non-nil, Gnus will view pseudo-articles asynchronously."
481 :group 'gnus-extract-view
484 (defcustom gnus-auto-expirable-marks
485 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
486 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
487 gnus-souped-mark gnus-duplicate-mark)
488 "*The list of marks converted into expiration if a group is auto-expirable."
490 :type '(repeat character))
492 (defcustom gnus-inhibit-user-auto-expire t
493 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
497 (defcustom gnus-view-pseudos nil
498 "*If `automatic', pseudo-articles will be viewed automatically.
499 If `not-confirm', pseudos will be viewed automatically, and the user
500 will not be asked to confirm the command."
501 :group 'gnus-extract-view
502 :type '(choice (const :tag "off" nil)
504 (const not-confirm)))
506 (defcustom gnus-view-pseudos-separately t
507 "*If non-nil, one pseudo-article will be created for each file to be viewed.
508 If nil, all files that use the same viewing command will be given as a
509 list of parameters to that command."
510 :group 'gnus-extract-view
513 (defcustom gnus-insert-pseudo-articles t
514 "*If non-nil, insert pseudo-articles when decoding articles."
515 :group 'gnus-extract-view
518 (defcustom gnus-summary-dummy-line-format
520 "*The format specification for the dummy roots in the summary buffer.
521 It works along the same lines as a normal formatting string,
522 with some simple extensions.
525 :group 'gnus-threading
528 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
529 "*The format specification for the summary mode line.
530 It works along the same lines as a normal formatting string,
531 with some simple extensions:
534 %p Unprefixed group name
535 %A Current article number
536 %z Current article score
538 %U Number of unread articles in the group
539 %e Number of unselected articles in the group
540 %Z A string with unread/unselected article counts
541 %g Shortish group name
542 %S Subject of the current article
544 %s Current score file name
545 %d Number of dormant articles
546 %r Number of articles that have been marked as read in this session
547 %E Number of articles expunged by the score files"
548 :group 'gnus-summary-format
551 (defcustom gnus-list-identifiers nil
552 "Regexp that matches list identifiers to be removed from subject.
553 This can also be a list of regexps."
554 :group 'gnus-summary-format
555 :group 'gnus-article-hiding
556 :type '(choice (const :tag "none" nil)
558 (repeat :value (".*") regexp)))
560 (defcustom gnus-summary-mark-below 0
561 "*Mark all articles with a score below this variable as read.
562 This variable is local to each summary buffer and usually set by the
564 :group 'gnus-score-default
567 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
568 "*List of functions used for sorting articles in the summary buffer.
569 This variable is only used when not using a threaded display."
570 :group 'gnus-summary-sort
571 :type '(repeat (choice (function-item gnus-article-sort-by-number)
572 (function-item gnus-article-sort-by-author)
573 (function-item gnus-article-sort-by-subject)
574 (function-item gnus-article-sort-by-date)
575 (function-item gnus-article-sort-by-score)
576 (function :tag "other"))))
578 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
579 "*List of functions used for sorting threads in the summary buffer.
580 By default, threads are sorted by article number.
582 Each function takes two threads and return non-nil if the first thread
583 should be sorted before the other. If you use more than one function,
584 the primary sort function should be the last. You should probably
585 always include `gnus-thread-sort-by-number' in the list of sorting
586 functions -- preferably first.
588 Ready-made functions include `gnus-thread-sort-by-number',
589 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
590 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
591 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
592 :group 'gnus-summary-sort
593 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
594 (function-item gnus-thread-sort-by-author)
595 (function-item gnus-thread-sort-by-subject)
596 (function-item gnus-thread-sort-by-date)
597 (function-item gnus-thread-sort-by-score)
598 (function-item gnus-thread-sort-by-total-score)
599 (function :tag "other"))))
601 (defcustom gnus-thread-score-function '+
602 "*Function used for calculating the total score of a thread.
604 The function is called with the scores of the article and each
605 subthread and should then return the score of the thread.
607 Some functions you can use are `+', `max', or `min'."
608 :group 'gnus-summary-sort
611 (defcustom gnus-summary-expunge-below nil
612 "All articles that have a score less than this variable will be expunged.
613 This variable is local to the summary buffers."
614 :group 'gnus-score-default
615 :type '(choice (const :tag "off" nil)
618 (defcustom gnus-thread-expunge-below nil
619 "All threads that have a total score less than this variable will be expunged.
620 See `gnus-thread-score-function' for en explanation of what a
623 This variable is local to the summary buffers."
624 :group 'gnus-threading
625 :group 'gnus-score-default
626 :type '(choice (const :tag "off" nil)
629 (defcustom gnus-summary-mode-hook nil
630 "*A hook for Gnus summary mode.
631 This hook is run before any variables are set in the summary buffer."
632 :group 'gnus-summary-various
635 (defcustom gnus-summary-menu-hook nil
636 "*Hook run after the creation of the summary mode menu."
637 :group 'gnus-summary-visual
640 (defcustom gnus-summary-exit-hook nil
641 "*A hook called on exit from the summary buffer.
642 It will be called with point in the group buffer."
643 :group 'gnus-summary-exit
646 (defcustom gnus-summary-prepare-hook nil
647 "*A hook called after the summary buffer has been generated.
648 If you want to modify the summary buffer, you can use this hook."
649 :group 'gnus-summary-various
652 (defcustom gnus-summary-prepared-hook nil
653 "*A hook called as the last thing after the summary buffer has been generated."
654 :group 'gnus-summary-various
657 (defcustom gnus-summary-generate-hook nil
658 "*A hook run just before generating the summary buffer.
659 This hook is commonly used to customize threading variables and the
661 :group 'gnus-summary-various
664 (defcustom gnus-select-group-hook nil
665 "*A hook called when a newsgroup is selected.
667 If you'd like to simplify subjects like the
668 `gnus-summary-next-same-subject' command does, you can use the
671 (setq gnus-select-group-hook
674 (mapcar (lambda (header)
675 (mail-header-set-subject
677 (gnus-simplify-subject
678 (mail-header-subject header) 're-only)))
679 gnus-newsgroup-headers))))"
680 :group 'gnus-group-select
683 (defcustom gnus-select-article-hook nil
684 "*A hook called when an article is selected."
685 :group 'gnus-summary-choose
688 (defcustom gnus-visual-mark-article-hook
689 (list 'gnus-highlight-selected-summary)
690 "*Hook run after selecting an article in the summary buffer.
691 It is meant to be used for highlighting the article in some way. It
692 is not run if `gnus-visual' is nil."
693 :group 'gnus-summary-visual
696 (defcustom gnus-parse-headers-hook nil
697 "*A hook called before parsing the headers."
701 (defcustom gnus-exit-group-hook nil
702 "*A hook called when exiting summary mode.
703 This hook is not called from the non-updating exit commands like `Q'."
707 (defcustom gnus-summary-update-hook
708 (list 'gnus-summary-highlight-line)
709 "*A hook called when a summary line is changed.
710 The hook will not be called if `gnus-visual' is nil.
712 The default function `gnus-summary-highlight-line' will
713 highlight the line according to the `gnus-summary-highlight'
715 :group 'gnus-summary-visual
718 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
719 "*A hook called when an article is selected for the first time.
720 The hook is intended to mark an article as read (or unread)
721 automatically when it is selected."
722 :group 'gnus-summary-choose
725 (defcustom gnus-group-no-more-groups-hook nil
726 "*A hook run when returning to group mode having no more (unread) groups."
727 :group 'gnus-group-select
730 (defcustom gnus-ps-print-hook nil
731 "*A hook run before ps-printing something from Gnus."
735 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
736 "Face used for highlighting the current article in the summary buffer."
737 :group 'gnus-summary-visual
740 (defcustom gnus-summary-highlight
741 '(((= mark gnus-canceled-mark)
742 . gnus-summary-cancelled-face)
743 ((and (> score default)
744 (or (= mark gnus-dormant-mark)
745 (= mark gnus-ticked-mark)))
746 . gnus-summary-high-ticked-face)
747 ((and (< score default)
748 (or (= mark gnus-dormant-mark)
749 (= mark gnus-ticked-mark)))
750 . gnus-summary-low-ticked-face)
751 ((or (= mark gnus-dormant-mark)
752 (= mark gnus-ticked-mark))
753 . gnus-summary-normal-ticked-face)
754 ((and (> score default) (= mark gnus-ancient-mark))
755 . gnus-summary-high-ancient-face)
756 ((and (< score default) (= mark gnus-ancient-mark))
757 . gnus-summary-low-ancient-face)
758 ((= mark gnus-ancient-mark)
759 . gnus-summary-normal-ancient-face)
760 ((and (> score default) (= mark gnus-unread-mark))
761 . gnus-summary-high-unread-face)
762 ((and (< score default) (= mark gnus-unread-mark))
763 . gnus-summary-low-unread-face)
764 ((= mark gnus-unread-mark)
765 . gnus-summary-normal-unread-face)
766 ((and (> score default) (memq mark (list gnus-downloadable-mark
767 gnus-undownloaded-mark)))
768 . gnus-summary-high-unread-face)
769 ((and (< score default) (memq mark (list gnus-downloadable-mark
770 gnus-undownloaded-mark)))
771 . gnus-summary-low-unread-face)
772 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
773 . gnus-summary-normal-unread-face)
775 . gnus-summary-high-read-face)
777 . gnus-summary-low-read-face)
779 . gnus-summary-normal-read-face))
780 "*Controls the highlighting of summary buffer lines.
782 A list of (FORM . FACE) pairs. When deciding how a a particular
783 summary line should be displayed, each form is evaluated. The content
784 of the face field after the first true form is used. You can change
785 how those summary lines are displayed, by editing the face field.
787 You can use the following variables in the FORM field.
789 score: The articles score
790 default: The default article score.
791 below: The score below which articles are automatically marked as read.
792 mark: The articles mark."
793 :group 'gnus-summary-visual
794 :type '(repeat (cons (sexp :tag "Form" nil)
797 (defcustom gnus-alter-header-function nil
798 "Function called to allow alteration of article header structures.
799 The function is called with one parameter, the article header vector,
800 which it may alter in any way.")
802 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
803 "Variable that says which function should be used to decode a string with encoded words.")
805 (defcustom gnus-extra-headers nil
806 "*Extra headers to parse."
808 :type '(repeat symbol))
810 (defcustom gnus-ignored-from-addresses
811 (and user-mail-address (regexp-quote user-mail-address))
812 "*Regexp of From headers that may be suppressed in favor of To headers."
816 (defcustom gnus-group-charset-alist
817 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
818 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
819 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
820 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
821 ("^relcom\\>" koi8-r)
823 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
824 ("^israel\\>" iso-8859-1)
826 ("^alt.chinese.text.big5\\>" chinese-big5)
827 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
828 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
830 "Alist of regexps (to match group names) and default charsets to be used when reading."
831 :type '(repeat (list (regexp :tag "Group")
832 (symbol :tag "Charset")))
833 :group 'gnus-charset)
835 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
836 "List of charsets that should be ignored.
837 When these charsets are used in the \"charset\" parameter, the
838 default charset will be used instead."
839 :type '(repeat symbol)
840 :group 'gnus-charset)
842 (defcustom gnus-group-ignored-charsets-alist
843 '(("alt\\.chinese\\.text" iso-8859-1))
844 "Alist of regexps (to match group names) and charsets that should be ignored.
845 When these charsets are used in the \"charset\" parameter, the
846 default charset will be used instead."
847 :type '(repeat (cons (regexp :tag "Group")
849 :group 'gnus-charset)
851 (defcustom gnus-group-highlight-words-alist nil
852 "Alist of group regexps and highlight regexps.
853 This variable uses the same syntax as `gnus-emphasis-alist'."
854 :type '(repeat (cons (regexp :tag "Group")
855 (repeat (list (regexp :tag "Highlight regexp")
856 (number :tag "Group for entire word" 0)
857 (number :tag "Group for displayed part" 0)
859 gnus-emphasis-highlight-words)))))
860 :group 'gnus-summary-visual)
862 (defcustom gnus-summary-show-article-charset-alist
864 "Alist of number and charset.
865 The article will be shown with the charset corresponding to the
867 For example: ((1 . cn-gb-2312) (2 . big5))."
868 :type '(repeat (cons (number :tag "Argument" 1)
869 (symbol :tag "Charset")))
870 :group 'gnus-charset)
872 (defcustom gnus-preserve-marks t
873 "Whether marks are preserved when moving, copying and respooling messages."
875 :group 'gnus-summary-marks)
877 (defcustom gnus-alter-articles-to-read-function nil
878 "Function to be called to alter the list of articles to be selected."
880 :group 'gnus-summary)
882 ;;; Internal variables
884 (defvar gnus-article-mime-handles nil)
885 (defvar gnus-article-decoded-p nil)
886 (defvar gnus-scores-exclude-files nil)
887 (defvar gnus-page-broken nil)
888 (defvar gnus-inhibit-mime-unbuttonizing nil)
890 (defvar gnus-original-article nil)
891 (defvar gnus-article-internal-prepare-hook nil)
892 (defvar gnus-newsgroup-process-stack nil)
894 (defvar gnus-thread-indent-array nil)
895 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
896 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
897 "Function called to sort the articles within a thread after it has been gathered together.")
899 ;; Avoid highlighting in kill files.
900 (defvar gnus-summary-inhibit-highlight nil)
901 (defvar gnus-newsgroup-selected-overlay nil)
902 (defvar gnus-inhibit-limiting nil)
903 (defvar gnus-newsgroup-adaptive-score-file nil)
904 (defvar gnus-current-score-file nil)
905 (defvar gnus-current-move-group nil)
906 (defvar gnus-current-copy-group nil)
907 (defvar gnus-current-crosspost-group nil)
909 (defvar gnus-newsgroup-dependencies nil)
910 (defvar gnus-newsgroup-adaptive nil)
911 (defvar gnus-summary-display-article-function nil)
912 (defvar gnus-summary-highlight-line-function nil
913 "Function called after highlighting a summary line.")
915 (defvar gnus-summary-line-format-alist
916 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
917 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
918 (?s gnus-tmp-subject-or-nil ?s)
919 (?n gnus-tmp-name ?s)
920 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
922 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
924 (?F gnus-tmp-from ?s)
925 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
926 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
927 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
928 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
929 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
930 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
931 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
932 (?L gnus-tmp-lines ?d)
933 (?I gnus-tmp-indentation ?s)
934 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
935 (?R gnus-tmp-replied ?c)
936 (?\[ gnus-tmp-opening-bracket ?c)
937 (?\] gnus-tmp-closing-bracket ?c)
938 (?\> (make-string gnus-tmp-level ? ) ?s)
939 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
940 (?i gnus-tmp-score ?d)
941 (?z gnus-tmp-score-char ?c)
942 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
943 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
944 (?U gnus-tmp-unread ?c)
945 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
946 (?t (gnus-summary-number-of-articles-in-thread
947 (and (boundp 'thread) (car thread)) gnus-tmp-level)
949 (?e (gnus-summary-number-of-articles-in-thread
950 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
952 (?u gnus-tmp-user-defined ?s)
953 (?P (gnus-pick-line-number) ?d))
954 "An alist of format specifications that can appear in summary lines,
955 and what variables they correspond with, along with the type of the
956 variable (string, integer, character, etc).")
958 (defvar gnus-summary-dummy-line-format-alist
959 `((?S gnus-tmp-subject ?s)
960 (?N gnus-tmp-number ?d)
961 (?u gnus-tmp-user-defined ?s)))
963 (defvar gnus-summary-mode-line-format-alist
964 `((?G gnus-tmp-group-name ?s)
965 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
966 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
967 (?A gnus-tmp-article-number ?d)
968 (?Z gnus-tmp-unread-and-unselected ?s)
970 (?U gnus-tmp-unread-and-unticked ?d)
971 (?S gnus-tmp-subject ?s)
972 (?e gnus-tmp-unselected ?d)
973 (?u gnus-tmp-user-defined ?s)
974 (?d (length gnus-newsgroup-dormant) ?d)
975 (?t (length gnus-newsgroup-marked) ?d)
976 (?r (length gnus-newsgroup-reads) ?d)
977 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
978 (?E gnus-newsgroup-expunged-tally ?d)
979 (?s (gnus-current-score-file-nondirectory) ?s)))
981 (defvar gnus-last-search-regexp nil
982 "Default regexp for article search command.")
984 (defvar gnus-last-shell-command nil
985 "Default shell command on article.")
987 (defvar gnus-newsgroup-begin nil)
988 (defvar gnus-newsgroup-end nil)
989 (defvar gnus-newsgroup-last-rmail nil)
990 (defvar gnus-newsgroup-last-mail nil)
991 (defvar gnus-newsgroup-last-folder nil)
992 (defvar gnus-newsgroup-last-file nil)
993 (defvar gnus-newsgroup-auto-expire nil)
994 (defvar gnus-newsgroup-active nil)
996 (defvar gnus-newsgroup-data nil)
997 (defvar gnus-newsgroup-data-reverse nil)
998 (defvar gnus-newsgroup-limit nil)
999 (defvar gnus-newsgroup-limits nil)
1001 (defvar gnus-newsgroup-unreads nil
1002 "List of unread articles in the current newsgroup.")
1004 (defvar gnus-newsgroup-unselected nil
1005 "List of unselected unread articles in the current newsgroup.")
1007 (defvar gnus-newsgroup-reads nil
1008 "Alist of read articles and article marks in the current newsgroup.")
1010 (defvar gnus-newsgroup-expunged-tally nil)
1012 (defvar gnus-newsgroup-marked nil
1013 "List of ticked articles in the current newsgroup (a subset of unread art).")
1015 (defvar gnus-newsgroup-killed nil
1016 "List of ranges of articles that have been through the scoring process.")
1018 (defvar gnus-newsgroup-cached nil
1019 "List of articles that come from the article cache.")
1021 (defvar gnus-newsgroup-saved nil
1022 "List of articles that have been saved.")
1024 (defvar gnus-newsgroup-kill-headers nil)
1026 (defvar gnus-newsgroup-replied nil
1027 "List of articles that have been replied to in the current newsgroup.")
1029 (defvar gnus-newsgroup-expirable nil
1030 "List of articles in the current newsgroup that can be expired.")
1032 (defvar gnus-newsgroup-processable nil
1033 "List of articles in the current newsgroup that can be processed.")
1035 (defvar gnus-newsgroup-downloadable nil
1036 "List of articles in the current newsgroup that can be processed.")
1038 (defvar gnus-newsgroup-undownloaded nil
1039 "List of articles in the current newsgroup that haven't been downloaded..")
1041 (defvar gnus-newsgroup-unsendable nil
1042 "List of articles in the current newsgroup that won't be sent.")
1044 (defvar gnus-newsgroup-bookmarks nil
1045 "List of articles in the current newsgroup that have bookmarks.")
1047 (defvar gnus-newsgroup-dormant nil
1048 "List of dormant articles in the current newsgroup.")
1050 (defvar gnus-newsgroup-scored nil
1051 "List of scored articles in the current newsgroup.")
1053 (defvar gnus-newsgroup-headers nil
1054 "List of article headers in the current newsgroup.")
1056 (defvar gnus-newsgroup-threads nil)
1058 (defvar gnus-newsgroup-prepared nil
1059 "Whether the current group has been prepared properly.")
1061 (defvar gnus-newsgroup-ancient nil
1062 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1064 (defvar gnus-newsgroup-sparse nil)
1066 (defvar gnus-current-article nil)
1067 (defvar gnus-article-current nil)
1068 (defvar gnus-current-headers nil)
1069 (defvar gnus-have-all-headers nil)
1070 (defvar gnus-last-article nil)
1071 (defvar gnus-newsgroup-history nil)
1072 (defvar gnus-newsgroup-charset nil)
1073 (defvar gnus-newsgroup-ephemeral-charset nil)
1074 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1076 (defconst gnus-summary-local-variables
1077 '(gnus-newsgroup-name
1078 gnus-newsgroup-begin gnus-newsgroup-end
1079 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1080 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1081 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1082 gnus-newsgroup-unselected gnus-newsgroup-marked
1083 gnus-newsgroup-reads gnus-newsgroup-saved
1084 gnus-newsgroup-replied gnus-newsgroup-expirable
1085 gnus-newsgroup-processable gnus-newsgroup-killed
1086 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1087 gnus-newsgroup-unsendable
1088 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1089 gnus-newsgroup-headers gnus-newsgroup-threads
1090 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1091 gnus-current-article gnus-current-headers gnus-have-all-headers
1092 gnus-last-article gnus-article-internal-prepare-hook
1093 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1094 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1095 gnus-thread-expunge-below
1096 gnus-score-alist gnus-current-score-file
1097 (gnus-summary-expunge-below . global)
1098 (gnus-summary-mark-below . global)
1099 gnus-newsgroup-active gnus-scores-exclude-files
1100 gnus-newsgroup-history gnus-newsgroup-ancient
1101 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1102 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1103 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1104 (gnus-newsgroup-expunged-tally . 0)
1105 gnus-cache-removable-articles gnus-newsgroup-cached
1106 gnus-newsgroup-data gnus-newsgroup-data-reverse
1107 gnus-newsgroup-limit gnus-newsgroup-limits
1108 gnus-newsgroup-charset)
1109 "Variables that are buffer-local to the summary buffers.")
1111 ;; Byte-compiler warning.
1112 (defvar gnus-article-mode-map)
1116 (defvar gnus-decode-encoded-word-methods
1117 '(mail-decode-encoded-word-string)
1118 "List of methods used to decode encoded words.
1120 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1121 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1122 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1123 whose names match REGEXP.
1126 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1127 mail-decode-encoded-word-string
1128 (\"chinese\" . rfc1843-decode-string))
1131 (defvar gnus-decode-encoded-word-methods-cache nil)
1133 (defun gnus-multi-decode-encoded-word-string (string)
1134 "Apply the functions from `gnus-encoded-word-methods' that match."
1135 (unless (and gnus-decode-encoded-word-methods-cache
1136 (eq gnus-newsgroup-name
1137 (car gnus-decode-encoded-word-methods-cache)))
1138 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1141 (nconc gnus-decode-encoded-word-methods-cache (list x))
1142 (if (and gnus-newsgroup-name
1143 (string-match (car x) gnus-newsgroup-name))
1144 (nconc gnus-decode-encoded-word-methods-cache
1146 gnus-decode-encoded-word-methods))
1147 (let ((xlist gnus-decode-encoded-word-methods-cache))
1150 (setq string (funcall (pop xlist) string))))
1153 ;; Subject simplification.
1155 (defun gnus-simplify-whitespace (str)
1156 "Remove excessive whitespace."
1159 (while (string-match "[ \t][ \t]+" mystr)
1160 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1162 (substring mystr (match-end 0)))))
1164 (when (string-match "^[ \t]+" mystr)
1165 (setq mystr (substring mystr (match-end 0))))
1167 (when (string-match "[ \t]+$" mystr)
1168 (setq mystr (substring mystr 0 (match-beginning 0))))
1171 (defsubst gnus-simplify-subject-re (subject)
1172 "Remove \"Re:\" from subject lines."
1173 (if (string-match "^[Rr][Ee]: *" subject)
1174 (substring subject (match-end 0))
1177 (defun gnus-simplify-subject (subject &optional re-only)
1178 "Remove `Re:' and words in parentheses.
1179 If RE-ONLY is non-nil, strip leading `Re:'s only."
1180 (let ((case-fold-search t)) ;Ignore case.
1181 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1182 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1183 (setq subject (substring subject (match-end 0))))
1184 ;; Remove uninteresting prefixes.
1185 (when (and (not re-only)
1186 gnus-simplify-ignored-prefixes
1187 (string-match gnus-simplify-ignored-prefixes subject))
1188 (setq subject (substring subject (match-end 0))))
1189 ;; Remove words in parentheses from end.
1191 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1192 (setq subject (substring subject 0 (match-beginning 0)))))
1193 ;; Return subject string.
1196 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1198 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1199 (goto-char (point-min))
1200 (while (re-search-forward regexp nil t)
1201 (replace-match (or newtext ""))))
1203 (defun gnus-simplify-buffer-fuzzy ()
1204 "Simplify string in the buffer fuzzily.
1205 The string in the accessible portion of the current buffer is simplified.
1206 It is assumed to be a single-line subject.
1207 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1208 matter is removed. Additional things can be deleted by setting
1209 gnus-simplify-subject-fuzzy-regexp."
1210 (let ((case-fold-search t)
1212 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1214 (while (not (eq modified-tick (buffer-modified-tick)))
1215 (setq modified-tick (buffer-modified-tick))
1217 ((listp gnus-simplify-subject-fuzzy-regexp)
1218 (mapcar 'gnus-simplify-buffer-fuzzy-step
1219 gnus-simplify-subject-fuzzy-regexp))
1220 (gnus-simplify-subject-fuzzy-regexp
1221 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1222 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1223 (gnus-simplify-buffer-fuzzy-step
1224 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1225 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1227 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1228 (gnus-simplify-buffer-fuzzy-step " +" " ")
1229 (gnus-simplify-buffer-fuzzy-step " $")
1230 (gnus-simplify-buffer-fuzzy-step "^ +")))
1232 (defun gnus-simplify-subject-fuzzy (subject)
1233 "Simplify a subject string fuzzily.
1234 See `gnus-simplify-buffer-fuzzy' for details."
1236 (gnus-set-work-buffer)
1237 (let ((case-fold-search t))
1238 ;; Remove uninteresting prefixes.
1239 (when (and gnus-simplify-ignored-prefixes
1240 (string-match gnus-simplify-ignored-prefixes subject))
1241 (setq subject (substring subject (match-end 0))))
1243 (inline (gnus-simplify-buffer-fuzzy))
1246 (defsubst gnus-simplify-subject-fully (subject)
1247 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1249 (gnus-simplify-subject-functions
1250 (gnus-map-function gnus-simplify-subject-functions subject))
1251 ((null gnus-summary-gather-subject-limit)
1252 (gnus-simplify-subject-re subject))
1253 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1254 (gnus-simplify-subject-fuzzy subject))
1255 ((numberp gnus-summary-gather-subject-limit)
1256 (gnus-limit-string (gnus-simplify-subject-re subject)
1257 gnus-summary-gather-subject-limit))
1261 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1262 "Check whether two subjects are equal.
1263 If optional argument simple-first is t, first argument is already
1266 ((null simple-first)
1267 (equal (gnus-simplify-subject-fully s1)
1268 (gnus-simplify-subject-fully s2)))
1271 (gnus-simplify-subject-fully s2)))))
1273 (defun gnus-summary-bubble-group ()
1274 "Increase the score of the current group.
1275 This is a handy function to add to `gnus-summary-exit-hook' to
1276 increase the score of each group you read."
1277 (gnus-group-add-score gnus-newsgroup-name))
1281 ;;; Gnus summary mode
1284 (put 'gnus-summary-mode 'mode-class 'special)
1287 ;; Non-orthogonal keys
1289 (gnus-define-keys gnus-summary-mode-map
1290 " " gnus-summary-next-page
1291 "\177" gnus-summary-prev-page
1292 [delete] gnus-summary-prev-page
1293 [backspace] gnus-summary-prev-page
1294 "\r" gnus-summary-scroll-up
1295 "\M-\r" gnus-summary-scroll-down
1296 "n" gnus-summary-next-unread-article
1297 "p" gnus-summary-prev-unread-article
1298 "N" gnus-summary-next-article
1299 "P" gnus-summary-prev-article
1300 "\M-\C-n" gnus-summary-next-same-subject
1301 "\M-\C-p" gnus-summary-prev-same-subject
1302 "\M-n" gnus-summary-next-unread-subject
1303 "\M-p" gnus-summary-prev-unread-subject
1304 "." gnus-summary-first-unread-article
1305 "," gnus-summary-best-unread-article
1306 "\M-s" gnus-summary-search-article-forward
1307 "\M-r" gnus-summary-search-article-backward
1308 "<" gnus-summary-beginning-of-article
1309 ">" gnus-summary-end-of-article
1310 "j" gnus-summary-goto-article
1311 "^" gnus-summary-refer-parent-article
1312 "\M-^" gnus-summary-refer-article
1313 "u" gnus-summary-tick-article-forward
1314 "!" gnus-summary-tick-article-forward
1315 "U" gnus-summary-tick-article-backward
1316 "d" gnus-summary-mark-as-read-forward
1317 "D" gnus-summary-mark-as-read-backward
1318 "E" gnus-summary-mark-as-expirable
1319 "\M-u" gnus-summary-clear-mark-forward
1320 "\M-U" gnus-summary-clear-mark-backward
1321 "k" gnus-summary-kill-same-subject-and-select
1322 "\C-k" gnus-summary-kill-same-subject
1323 "\M-\C-k" gnus-summary-kill-thread
1324 "\M-\C-l" gnus-summary-lower-thread
1325 "e" gnus-summary-edit-article
1326 "#" gnus-summary-mark-as-processable
1327 "\M-#" gnus-summary-unmark-as-processable
1328 "\M-\C-t" gnus-summary-toggle-threads
1329 "\M-\C-s" gnus-summary-show-thread
1330 "\M-\C-h" gnus-summary-hide-thread
1331 "\M-\C-f" gnus-summary-next-thread
1332 "\M-\C-b" gnus-summary-prev-thread
1333 [(meta down)] gnus-summary-next-thread
1334 [(meta up)] gnus-summary-prev-thread
1335 "\M-\C-u" gnus-summary-up-thread
1336 "\M-\C-d" gnus-summary-down-thread
1337 "&" gnus-summary-execute-command
1338 "c" gnus-summary-catchup-and-exit
1339 "\C-w" gnus-summary-mark-region-as-read
1340 "\C-t" gnus-summary-toggle-truncation
1341 "?" gnus-summary-mark-as-dormant
1342 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1343 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1344 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1345 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1346 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1347 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1348 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1349 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1350 "=" gnus-summary-expand-window
1351 "\C-x\C-s" gnus-summary-reselect-current-group
1352 "\M-g" gnus-summary-rescan-group
1353 "w" gnus-summary-stop-page-breaking
1354 "\C-c\C-r" gnus-summary-caesar-message
1355 "f" gnus-summary-followup
1356 "F" gnus-summary-followup-with-original
1357 "C" gnus-summary-cancel-article
1358 "r" gnus-summary-reply
1359 "R" gnus-summary-reply-with-original
1360 "\C-c\C-f" gnus-summary-mail-forward
1361 "o" gnus-summary-save-article
1362 "\C-o" gnus-summary-save-article-mail
1363 "|" gnus-summary-pipe-output
1364 "\M-k" gnus-summary-edit-local-kill
1365 "\M-K" gnus-summary-edit-global-kill
1367 "\C-c\C-d" gnus-summary-describe-group
1368 "q" gnus-summary-exit
1369 "Q" gnus-summary-exit-no-update
1370 "\C-c\C-i" gnus-info-find-node
1371 gnus-mouse-2 gnus-mouse-pick-article
1372 "m" gnus-summary-mail-other-window
1373 "a" gnus-summary-post-news
1374 "x" gnus-summary-limit-to-unread
1375 "s" gnus-summary-isearch-article
1376 "t" gnus-summary-toggle-header
1377 "g" gnus-summary-show-article
1378 "l" gnus-summary-goto-last-article
1379 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1380 "\C-d" gnus-summary-enter-digest-group
1381 "\M-\C-d" gnus-summary-read-document
1382 "\M-\C-e" gnus-summary-edit-parameters
1383 "\M-\C-a" gnus-summary-customize-parameters
1385 "*" gnus-cache-enter-article
1386 "\M-*" gnus-cache-remove-article
1387 "\M-&" gnus-summary-universal-argument
1388 "\C-l" gnus-recenter
1389 "I" gnus-summary-increase-score
1390 "L" gnus-summary-lower-score
1391 "\M-i" gnus-symbolic-argument
1392 "h" gnus-summary-select-article-buffer
1394 "b" gnus-article-view-part
1395 "\M-t" gnus-summary-toggle-display-buttonized
1397 "V" gnus-summary-score-map
1398 "X" gnus-uu-extract-map
1399 "S" gnus-summary-send-map)
1401 ;; Sort of orthogonal keymap
1402 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1403 "t" gnus-summary-tick-article-forward
1404 "!" gnus-summary-tick-article-forward
1405 "d" gnus-summary-mark-as-read-forward
1406 "r" gnus-summary-mark-as-read-forward
1407 "c" gnus-summary-clear-mark-forward
1408 " " gnus-summary-clear-mark-forward
1409 "e" gnus-summary-mark-as-expirable
1410 "x" gnus-summary-mark-as-expirable
1411 "?" gnus-summary-mark-as-dormant
1412 "b" gnus-summary-set-bookmark
1413 "B" gnus-summary-remove-bookmark
1414 "#" gnus-summary-mark-as-processable
1415 "\M-#" gnus-summary-unmark-as-processable
1416 "S" gnus-summary-limit-include-expunged
1417 "C" gnus-summary-catchup
1418 "H" gnus-summary-catchup-to-here
1419 "\C-c" gnus-summary-catchup-all
1420 "k" gnus-summary-kill-same-subject-and-select
1421 "K" gnus-summary-kill-same-subject
1422 "P" gnus-uu-mark-map)
1424 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1425 "c" gnus-summary-clear-above
1426 "u" gnus-summary-tick-above
1427 "m" gnus-summary-mark-above
1428 "k" gnus-summary-kill-below)
1430 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1431 "/" gnus-summary-limit-to-subject
1432 "n" gnus-summary-limit-to-articles
1433 "w" gnus-summary-pop-limit
1434 "s" gnus-summary-limit-to-subject
1435 "a" gnus-summary-limit-to-author
1436 "u" gnus-summary-limit-to-unread
1437 "m" gnus-summary-limit-to-marks
1438 "M" gnus-summary-limit-exclude-marks
1439 "v" gnus-summary-limit-to-score
1440 "*" gnus-summary-limit-include-cached
1441 "D" gnus-summary-limit-include-dormant
1442 "T" gnus-summary-limit-include-thread
1443 "d" gnus-summary-limit-exclude-dormant
1444 "t" gnus-summary-limit-to-age
1445 "x" gnus-summary-limit-to-extra
1446 "E" gnus-summary-limit-include-expunged
1447 "c" gnus-summary-limit-exclude-childless-dormant
1448 "C" gnus-summary-limit-mark-excluded-as-read)
1450 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1451 "n" gnus-summary-next-unread-article
1452 "p" gnus-summary-prev-unread-article
1453 "N" gnus-summary-next-article
1454 "P" gnus-summary-prev-article
1455 "\C-n" gnus-summary-next-same-subject
1456 "\C-p" gnus-summary-prev-same-subject
1457 "\M-n" gnus-summary-next-unread-subject
1458 "\M-p" gnus-summary-prev-unread-subject
1459 "f" gnus-summary-first-unread-article
1460 "b" gnus-summary-best-unread-article
1461 "j" gnus-summary-goto-article
1462 "g" gnus-summary-goto-subject
1463 "l" gnus-summary-goto-last-article
1464 "o" gnus-summary-pop-article)
1466 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1467 "k" gnus-summary-kill-thread
1468 "l" gnus-summary-lower-thread
1469 "i" gnus-summary-raise-thread
1470 "T" gnus-summary-toggle-threads
1471 "t" gnus-summary-rethread-current
1472 "^" gnus-summary-reparent-thread
1473 "s" gnus-summary-show-thread
1474 "S" gnus-summary-show-all-threads
1475 "h" gnus-summary-hide-thread
1476 "H" gnus-summary-hide-all-threads
1477 "n" gnus-summary-next-thread
1478 "p" gnus-summary-prev-thread
1479 "u" gnus-summary-up-thread
1480 "o" gnus-summary-top-thread
1481 "d" gnus-summary-down-thread
1482 "#" gnus-uu-mark-thread
1483 "\M-#" gnus-uu-unmark-thread)
1485 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1486 "g" gnus-summary-prepare
1487 "c" gnus-summary-insert-cached-articles)
1489 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1490 "c" gnus-summary-catchup-and-exit
1491 "C" gnus-summary-catchup-all-and-exit
1492 "E" gnus-summary-exit-no-update
1493 "Q" gnus-summary-exit
1494 "Z" gnus-summary-exit
1495 "n" gnus-summary-catchup-and-goto-next-group
1496 "R" gnus-summary-reselect-current-group
1497 "G" gnus-summary-rescan-group
1498 "N" gnus-summary-next-group
1499 "s" gnus-summary-save-newsrc
1500 "P" gnus-summary-prev-group)
1502 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1503 " " gnus-summary-next-page
1504 "n" gnus-summary-next-page
1505 "\177" gnus-summary-prev-page
1506 [delete] gnus-summary-prev-page
1507 "p" gnus-summary-prev-page
1508 "\r" gnus-summary-scroll-up
1509 "\M-\r" gnus-summary-scroll-down
1510 "<" gnus-summary-beginning-of-article
1511 ">" gnus-summary-end-of-article
1512 "b" gnus-summary-beginning-of-article
1513 "e" gnus-summary-end-of-article
1514 "^" gnus-summary-refer-parent-article
1515 "r" gnus-summary-refer-parent-article
1516 "D" gnus-summary-enter-digest-group
1517 "R" gnus-summary-refer-references
1518 "T" gnus-summary-refer-thread
1519 "g" gnus-summary-show-article
1520 "s" gnus-summary-isearch-article
1521 "P" gnus-summary-print-article
1522 "t" gnus-article-babel)
1524 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1525 "b" gnus-article-add-buttons
1526 "B" gnus-article-add-buttons-to-head
1527 "o" gnus-article-treat-overstrike
1528 "e" gnus-article-emphasize
1529 "w" gnus-article-fill-cited-article
1530 "Q" gnus-article-fill-long-lines
1531 "C" gnus-article-capitalize-sentences
1532 "c" gnus-article-remove-cr
1533 "q" gnus-article-de-quoted-unreadable
1534 "f" gnus-article-display-x-face
1535 "l" gnus-summary-stop-page-breaking
1536 "r" gnus-summary-caesar-message
1537 "t" gnus-article-hide-headers
1538 "v" gnus-summary-verbose-headers
1539 "H" gnus-article-strip-headers-in-body
1540 "d" gnus-article-treat-dumbquotes)
1542 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1543 "a" gnus-article-hide
1544 "h" gnus-article-hide-headers
1545 "b" gnus-article-hide-boring-headers
1546 "s" gnus-article-hide-signature
1547 "c" gnus-article-hide-citation
1548 "C" gnus-article-hide-citation-in-followups
1549 "l" gnus-article-hide-list-identifiers
1550 "p" gnus-article-hide-pgp
1551 "B" gnus-article-strip-banner
1552 "P" gnus-article-hide-pem
1553 "\C-c" gnus-article-hide-citation-maybe)
1555 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1556 "a" gnus-article-highlight
1557 "h" gnus-article-highlight-headers
1558 "c" gnus-article-highlight-citation
1559 "s" gnus-article-highlight-signature)
1561 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1562 "w" gnus-article-decode-mime-words
1563 "c" gnus-article-decode-charset
1564 "v" gnus-mime-view-all-parts
1565 "b" gnus-article-view-part)
1567 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1568 "z" gnus-article-date-ut
1569 "u" gnus-article-date-ut
1570 "l" gnus-article-date-local
1571 "e" gnus-article-date-lapsed
1572 "o" gnus-article-date-original
1573 "i" gnus-article-date-iso8601
1574 "s" gnus-article-date-user)
1576 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1577 "t" gnus-article-remove-trailing-blank-lines
1578 "l" gnus-article-strip-leading-blank-lines
1579 "m" gnus-article-strip-multiple-blank-lines
1580 "a" gnus-article-strip-blank-lines
1581 "A" gnus-article-strip-all-blank-lines
1582 "s" gnus-article-strip-leading-space
1583 "e" gnus-article-strip-trailing-space)
1585 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1587 "f" gnus-summary-fetch-faq
1588 "d" gnus-summary-describe-group
1589 "h" gnus-summary-describe-briefly
1590 "i" gnus-info-find-node)
1592 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1593 "e" gnus-summary-expire-articles
1594 "\M-\C-e" gnus-summary-expire-articles-now
1595 "\177" gnus-summary-delete-article
1596 [delete] gnus-summary-delete-article
1597 [backspace] gnus-summary-delete-article
1598 "m" gnus-summary-move-article
1599 "r" gnus-summary-respool-article
1600 "w" gnus-summary-edit-article
1601 "c" gnus-summary-copy-article
1602 "B" gnus-summary-crosspost-article
1603 "q" gnus-summary-respool-query
1604 "t" gnus-summary-respool-trace
1605 "i" gnus-summary-import-article
1606 "p" gnus-summary-article-posted-p)
1608 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1609 "o" gnus-summary-save-article
1610 "m" gnus-summary-save-article-mail
1611 "F" gnus-summary-write-article-file
1612 "r" gnus-summary-save-article-rmail
1613 "f" gnus-summary-save-article-file
1614 "b" gnus-summary-save-article-body-file
1615 "h" gnus-summary-save-article-folder
1616 "v" gnus-summary-save-article-vm
1617 "p" gnus-summary-pipe-output
1618 "s" gnus-soup-add-article)
1620 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1621 "b" gnus-summary-display-buttonized
1622 "m" gnus-summary-repair-multipart
1623 "v" gnus-article-view-part
1624 "o" gnus-article-save-part
1625 "c" gnus-article-copy-part
1626 "e" gnus-article-externalize-part
1627 "i" gnus-article-inline-part
1628 "|" gnus-article-pipe-part))
1630 (defun gnus-summary-make-menu-bar ()
1631 (gnus-turn-off-edit-menu 'summary)
1633 (unless (boundp 'gnus-summary-misc-menu)
1636 gnus-summary-kill-menu gnus-summary-mode-map ""
1641 ["Enter score..." gnus-summary-score-entry t]
1642 ["Customize" gnus-score-customize t])
1643 (gnus-make-score-map 'increase)
1644 (gnus-make-score-map 'lower)
1646 ["Kill below" gnus-summary-kill-below t]
1647 ["Mark above" gnus-summary-mark-above t]
1648 ["Tick above" gnus-summary-tick-above t]
1649 ["Clear above" gnus-summary-clear-above t])
1650 ["Current score" gnus-summary-current-score t]
1651 ["Set score" gnus-summary-set-score t]
1652 ["Switch current score file..." gnus-score-change-score-file t]
1653 ["Set mark below..." gnus-score-set-mark-below t]
1654 ["Set expunge below..." gnus-score-set-expunge-below t]
1655 ["Edit current score file" gnus-score-edit-current-scores t]
1656 ["Edit score file" gnus-score-edit-file t]
1657 ["Trace score" gnus-score-find-trace t]
1658 ["Find words" gnus-score-find-favourite-words t]
1659 ["Rescore buffer" gnus-summary-rescore t]
1660 ["Increase score..." gnus-summary-increase-score t]
1661 ["Lower score..." gnus-summary-lower-score t]))))
1663 ;; Define both the Article menu in the summary buffer and the equivalent
1664 ;; Commands menu in the article buffer here for consistency.
1667 ["All" gnus-article-hide t]
1668 ["Headers" gnus-article-hide-headers t]
1669 ["Signature" gnus-article-hide-signature t]
1670 ["Citation" gnus-article-hide-citation t]
1671 ["List identifiers" gnus-article-hide-list-identifiers t]
1672 ["PGP" gnus-article-hide-pgp t]
1673 ["Banner" gnus-article-strip-banner t]
1674 ["Boring headers" gnus-article-hide-boring-headers t])
1676 ["All" gnus-article-highlight t]
1677 ["Headers" gnus-article-highlight-headers t]
1678 ["Signature" gnus-article-highlight-signature t]
1679 ["Citation" gnus-article-highlight-citation t])
1681 ["Words" gnus-article-decode-mime-words t]
1682 ["Charset" gnus-article-decode-charset t]
1683 ["QP" gnus-article-de-quoted-unreadable t]
1684 ["View all" gnus-mime-view-all-parts t])
1686 ["Local" gnus-article-date-local t]
1687 ["ISO8601" gnus-article-date-iso8601 t]
1688 ["UT" gnus-article-date-ut t]
1689 ["Original" gnus-article-date-original t]
1690 ["Lapsed" gnus-article-date-lapsed t]
1691 ["User-defined" gnus-article-date-user t])
1694 ["Leading" gnus-article-strip-leading-blank-lines t]
1695 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1696 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1697 ["All of the above" gnus-article-strip-blank-lines t]
1698 ["All" gnus-article-strip-all-blank-lines t]
1699 ["Leading space" gnus-article-strip-leading-space t]
1700 ["Trailing space" gnus-article-strip-trailing-space t])
1701 ["Overstrike" gnus-article-treat-overstrike t]
1702 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1703 ["Emphasis" gnus-article-emphasize t]
1704 ["Word wrap" gnus-article-fill-cited-article t]
1705 ["Fill long lines" gnus-article-fill-long-lines t]
1706 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1707 ["CR" gnus-article-remove-cr t]
1708 ["Show X-Face" gnus-article-display-x-face t]
1709 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1710 ["Rot 13" gnus-summary-caesar-message t]
1711 ["Unix pipe" gnus-summary-pipe-message t]
1712 ["Add buttons" gnus-article-add-buttons t]
1713 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1714 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1715 ["Verbose header" gnus-summary-verbose-headers t]
1716 ["Toggle header" gnus-summary-toggle-header t]
1717 ["HZ" gnus-article-decode-HZ t])
1719 ["Save in default format" gnus-summary-save-article t]
1720 ["Save in file" gnus-summary-save-article-file t]
1721 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1722 ["Save in MH folder" gnus-summary-save-article-folder t]
1723 ["Save in VM folder" gnus-summary-save-article-vm t]
1724 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1725 ["Save body in file" gnus-summary-save-article-body-file t]
1726 ["Pipe through a filter" gnus-summary-pipe-output t]
1727 ["Add to SOUP packet" gnus-soup-add-article t]
1728 ["Print" gnus-summary-print-article t])
1730 ["Respool article..." gnus-summary-respool-article t]
1731 ["Move article..." gnus-summary-move-article
1732 (gnus-check-backend-function
1733 'request-move-article gnus-newsgroup-name)]
1734 ["Copy article..." gnus-summary-copy-article t]
1735 ["Crosspost article..." gnus-summary-crosspost-article
1736 (gnus-check-backend-function
1737 'request-replace-article gnus-newsgroup-name)]
1738 ["Import file..." gnus-summary-import-article t]
1739 ["Check if posted" gnus-summary-article-posted-p t]
1740 ["Edit article" gnus-summary-edit-article
1741 (not (gnus-group-read-only-p))]
1742 ["Delete article" gnus-summary-delete-article
1743 (gnus-check-backend-function
1744 'request-expire-articles gnus-newsgroup-name)]
1745 ["Query respool" gnus-summary-respool-query t]
1746 ["Trace respool" gnus-summary-respool-trace t]
1747 ["Delete expirable articles" gnus-summary-expire-articles-now
1748 (gnus-check-backend-function
1749 'request-expire-articles gnus-newsgroup-name)])
1751 ["Uudecode" gnus-uu-decode-uu t]
1752 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1753 ["Unshar" gnus-uu-decode-unshar t]
1754 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1755 ["Save" gnus-uu-decode-save t]
1756 ["Binhex" gnus-uu-decode-binhex t]
1757 ["Postscript" gnus-uu-decode-postscript t])
1759 ["Enter article" gnus-cache-enter-article t]
1760 ["Remove article" gnus-cache-remove-article t])
1761 ["Translate" gnus-article-babel t]
1762 ["Select article buffer" gnus-summary-select-article-buffer t]
1763 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1764 ["Isearch article..." gnus-summary-isearch-article t]
1765 ["Beginning of the article" gnus-summary-beginning-of-article t]
1766 ["End of the article" gnus-summary-end-of-article t]
1767 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1768 ["Fetch referenced articles" gnus-summary-refer-references t]
1769 ["Fetch current thread" gnus-summary-refer-thread t]
1770 ["Fetch article with id..." gnus-summary-refer-article t]
1771 ["Redisplay" gnus-summary-show-article t])))
1773 gnus-summary-article-menu gnus-summary-mode-map ""
1774 (cons "Article" innards))
1777 gnus-article-commands-menu gnus-article-mode-map ""
1778 (cons "Commands" innards)))
1781 gnus-summary-thread-menu gnus-summary-mode-map ""
1783 ["Toggle threading" gnus-summary-toggle-threads t]
1784 ["Hide threads" gnus-summary-hide-all-threads t]
1785 ["Show threads" gnus-summary-show-all-threads t]
1786 ["Hide thread" gnus-summary-hide-thread t]
1787 ["Show thread" gnus-summary-show-thread t]
1788 ["Go to next thread" gnus-summary-next-thread t]
1789 ["Go to previous thread" gnus-summary-prev-thread t]
1790 ["Go down thread" gnus-summary-down-thread t]
1791 ["Go up thread" gnus-summary-up-thread t]
1792 ["Top of thread" gnus-summary-top-thread t]
1793 ["Mark thread as read" gnus-summary-kill-thread t]
1794 ["Lower thread score" gnus-summary-lower-thread t]
1795 ["Raise thread score" gnus-summary-raise-thread t]
1796 ["Rethread current" gnus-summary-rethread-current t]))
1799 gnus-summary-post-menu gnus-summary-mode-map ""
1801 ["Post an article" gnus-summary-post-news t]
1802 ["Followup" gnus-summary-followup t]
1803 ["Followup and yank" gnus-summary-followup-with-original t]
1804 ["Supersede article" gnus-summary-supersede-article t]
1805 ["Cancel article" gnus-summary-cancel-article t]
1806 ["Reply" gnus-summary-reply t]
1807 ["Reply and yank" gnus-summary-reply-with-original t]
1808 ["Wide reply" gnus-summary-wide-reply t]
1809 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1810 ["Mail forward" gnus-summary-mail-forward t]
1811 ["Post forward" gnus-summary-post-forward t]
1812 ["Digest and mail" gnus-uu-digest-mail-forward t]
1813 ["Digest and post" gnus-uu-digest-post-forward t]
1814 ["Resend message" gnus-summary-resend-message t]
1815 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1816 ["Send a mail" gnus-summary-mail-other-window t]
1817 ["Uuencode and post" gnus-uu-post-news t]
1818 ["Followup via news" gnus-summary-followup-to-mail t]
1819 ["Followup via news and yank"
1820 gnus-summary-followup-to-mail-with-original t]
1822 ;;["Send" gnus-summary-send-draft t]
1823 ;;["Send bounced" gnus-resend-bounced-mail t])
1827 gnus-summary-misc-menu gnus-summary-mode-map ""
1830 ["Mark as read" gnus-summary-mark-as-read-forward t]
1831 ["Mark same subject and select"
1832 gnus-summary-kill-same-subject-and-select t]
1833 ["Mark same subject" gnus-summary-kill-same-subject t]
1834 ["Catchup" gnus-summary-catchup t]
1835 ["Catchup all" gnus-summary-catchup-all t]
1836 ["Catchup to here" gnus-summary-catchup-to-here t]
1837 ["Catchup region" gnus-summary-mark-region-as-read t]
1838 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1840 ["Tick" gnus-summary-tick-article-forward t]
1841 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1842 ["Remove marks" gnus-summary-clear-mark-forward t]
1843 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1844 ["Set bookmark" gnus-summary-set-bookmark t]
1845 ["Remove bookmark" gnus-summary-remove-bookmark t])
1847 ["Marks..." gnus-summary-limit-to-marks t]
1848 ["Subject..." gnus-summary-limit-to-subject t]
1849 ["Author..." gnus-summary-limit-to-author t]
1850 ["Age..." gnus-summary-limit-to-age t]
1851 ["Extra..." gnus-summary-limit-to-extra t]
1852 ["Score" gnus-summary-limit-to-score t]
1853 ["Unread" gnus-summary-limit-to-unread t]
1854 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1855 ["Articles" gnus-summary-limit-to-articles t]
1856 ["Pop limit" gnus-summary-pop-limit t]
1857 ["Show dormant" gnus-summary-limit-include-dormant t]
1858 ["Hide childless dormant"
1859 gnus-summary-limit-exclude-childless-dormant t]
1860 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1861 ["Hide marked" gnus-summary-limit-exclude-marks t]
1862 ["Show expunged" gnus-summary-show-all-expunged t])
1864 ["Set mark" gnus-summary-mark-as-processable t]
1865 ["Remove mark" gnus-summary-unmark-as-processable t]
1866 ["Remove all marks" gnus-summary-unmark-all-processable t]
1867 ["Mark above" gnus-uu-mark-over t]
1868 ["Mark series" gnus-uu-mark-series t]
1869 ["Mark region" gnus-uu-mark-region t]
1870 ["Unmark region" gnus-uu-unmark-region t]
1871 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1872 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1873 ["Mark all" gnus-uu-mark-all t]
1874 ["Mark buffer" gnus-uu-mark-buffer t]
1875 ["Mark sparse" gnus-uu-mark-sparse t]
1876 ["Mark thread" gnus-uu-mark-thread t]
1877 ["Unmark thread" gnus-uu-unmark-thread t]
1878 ("Process Mark Sets"
1879 ["Kill" gnus-summary-kill-process-mark t]
1880 ["Yank" gnus-summary-yank-process-mark
1881 gnus-newsgroup-process-stack]
1882 ["Save" gnus-summary-save-process-mark t]))
1884 ["Page forward" gnus-summary-next-page t]
1885 ["Page backward" gnus-summary-prev-page t]
1886 ["Line forward" gnus-summary-scroll-up t])
1888 ["Next unread article" gnus-summary-next-unread-article t]
1889 ["Previous unread article" gnus-summary-prev-unread-article t]
1890 ["Next article" gnus-summary-next-article t]
1891 ["Previous article" gnus-summary-prev-article t]
1892 ["Next unread subject" gnus-summary-next-unread-subject t]
1893 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1894 ["Next article same subject" gnus-summary-next-same-subject t]
1895 ["Previous article same subject" gnus-summary-prev-same-subject t]
1896 ["First unread article" gnus-summary-first-unread-article t]
1897 ["Best unread article" gnus-summary-best-unread-article t]
1898 ["Go to subject number..." gnus-summary-goto-subject t]
1899 ["Go to article number..." gnus-summary-goto-article t]
1900 ["Go to the last article" gnus-summary-goto-last-article t]
1901 ["Pop article off history" gnus-summary-pop-article t])
1903 ["Sort by number" gnus-summary-sort-by-number t]
1904 ["Sort by author" gnus-summary-sort-by-author t]
1905 ["Sort by subject" gnus-summary-sort-by-subject t]
1906 ["Sort by date" gnus-summary-sort-by-date t]
1907 ["Sort by score" gnus-summary-sort-by-score t]
1908 ["Sort by lines" gnus-summary-sort-by-lines t]
1909 ["Sort by characters" gnus-summary-sort-by-chars t])
1911 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1912 ["Describe group" gnus-summary-describe-group t]
1913 ["Read manual" gnus-info-find-node t])
1915 ["Pick and read" gnus-pick-mode t]
1916 ["Binary" gnus-binary-mode t])
1918 ["Regenerate" gnus-summary-prepare t]
1919 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1920 ["Toggle threading" gnus-summary-toggle-threads t])
1921 ["Filter articles..." gnus-summary-execute-command t]
1922 ["Run command on subjects..." gnus-summary-universal-argument t]
1923 ["Search articles forward..." gnus-summary-search-article-forward t]
1924 ["Search articles backward..." gnus-summary-search-article-backward t]
1925 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1926 ["Expand window" gnus-summary-expand-window t]
1927 ["Expire expirable articles" gnus-summary-expire-articles
1928 (gnus-check-backend-function
1929 'request-expire-articles gnus-newsgroup-name)]
1930 ["Edit local kill file" gnus-summary-edit-local-kill t]
1931 ["Edit main kill file" gnus-summary-edit-global-kill t]
1932 ["Edit group parameters" gnus-summary-edit-parameters t]
1933 ["Customize group parameters" gnus-summary-customize-parameters t]
1934 ["Send a bug report" gnus-bug t]
1936 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1937 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1938 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1939 ["Exit group" gnus-summary-exit t]
1940 ["Exit group without updating" gnus-summary-exit-no-update t]
1941 ["Exit and goto next group" gnus-summary-next-group t]
1942 ["Exit and goto prev group" gnus-summary-prev-group t]
1943 ["Reselect group" gnus-summary-reselect-current-group t]
1944 ["Rescan group" gnus-summary-rescan-group t]
1945 ["Update dribble" gnus-summary-save-newsrc t])))
1947 (gnus-run-hooks 'gnus-summary-menu-hook)))
1949 (defun gnus-score-set-default (var value)
1950 "A version of set that updates the GNU Emacs menu-bar."
1952 ;; It is the message that forces the active status to be updated.
1955 (defun gnus-make-score-map (type)
1956 "Make a summary score map of type TYPE."
1959 (let ((headers '(("author" "from" string)
1960 ("subject" "subject" string)
1961 ("article body" "body" string)
1962 ("article head" "head" string)
1963 ("xref" "xref" string)
1964 ("extra header" "extra" string)
1965 ("lines" "lines" number)
1966 ("followups to author" "followup" string)))
1967 (types '((number ("less than" <)
1970 (string ("substring" s)
1974 (perms '(("temporary" (current-time-string))
1982 (if (eq type 'lower)
1987 (setq header (car headers))
1993 (let ((ts (cdr (assoc (nth 2 header) types)))
2009 'gnus-summary-score-entry
2011 (if (or (string= (nth 1 header)
2013 (string= (nth 1 header)
2016 (list 'gnus-summary-header
2018 (list 'quote (nth 1 (car ts)))
2019 (list 'gnus-score-delta-default
2026 (list (nreverse outp))))
2029 (list (nreverse outt))))
2031 (setq headers (cdr headers)))
2032 (list (nreverse outh))))))))
2036 (defun gnus-summary-mode (&optional group)
2037 "Major mode for reading articles.
2039 All normal editing commands are switched off.
2040 \\<gnus-summary-mode-map>
2041 Each line in this buffer represents one article. To read an
2042 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2043 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2046 You can also post articles and send mail from this buffer. To
2047 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2048 of an article, type `\\[gnus-summary-reply]'.
2050 There are approx. one gazillion commands you can execute in this
2051 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2053 The following commands are available:
2055 \\{gnus-summary-mode-map}"
2057 (when (gnus-visual-p 'summary-menu 'menu)
2058 (gnus-summary-make-menu-bar))
2059 (kill-all-local-variables)
2060 (gnus-summary-make-local-variables)
2061 (gnus-make-thread-indent-array)
2062 (gnus-simplify-mode-line)
2063 (setq major-mode 'gnus-summary-mode)
2064 (setq mode-name "Summary")
2065 (make-local-variable 'minor-mode-alist)
2066 (use-local-map gnus-summary-mode-map)
2067 (buffer-disable-undo)
2068 (setq buffer-read-only t) ;Disable modification
2069 (setq truncate-lines t)
2070 (setq selective-display t)
2071 (setq selective-display-ellipses t) ;Display `...'
2072 (gnus-summary-set-display-table)
2073 (gnus-set-default-directory)
2074 (setq gnus-newsgroup-name group)
2075 (make-local-variable 'gnus-summary-line-format)
2076 (make-local-variable 'gnus-summary-line-format-spec)
2077 (make-local-variable 'gnus-summary-dummy-line-format)
2078 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2079 (make-local-variable 'gnus-summary-mark-positions)
2080 (make-local-hook 'pre-command-hook)
2081 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2082 (gnus-run-hooks 'gnus-summary-mode-hook)
2083 (mm-enable-multibyte)
2084 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2085 (gnus-update-summary-mark-positions))
2087 (defun gnus-summary-make-local-variables ()
2088 "Make all the local summary buffer variables."
2090 (dolist (local gnus-summary-local-variables)
2093 (if (eq (cdr local) 'global)
2094 ;; Copy the global value of the variable.
2095 (setq global (symbol-value (car local)))
2096 ;; Use the value from the list.
2097 (setq global (eval (cdr local))))
2098 (set (make-local-variable (car local)) global))
2099 ;; Simple nil-valued local variable.
2100 (set (make-local-variable local) nil)))))
2102 (defun gnus-summary-clear-local-variables ()
2103 (let ((locals gnus-summary-local-variables))
2105 (if (consp (car locals))
2106 (and (vectorp (caar locals))
2107 (set (caar locals) nil))
2108 (and (vectorp (car locals))
2109 (set (car locals) nil)))
2110 (setq locals (cdr locals)))))
2112 ;; Summary data functions.
2114 (defmacro gnus-data-number (data)
2117 (defmacro gnus-data-set-number (data number)
2118 `(setcar ,data ,number))
2120 (defmacro gnus-data-mark (data)
2123 (defmacro gnus-data-set-mark (data mark)
2124 `(setcar (nthcdr 1 ,data) ,mark))
2126 (defmacro gnus-data-pos (data)
2129 (defmacro gnus-data-set-pos (data pos)
2130 `(setcar (nthcdr 2 ,data) ,pos))
2132 (defmacro gnus-data-header (data)
2135 (defmacro gnus-data-set-header (data header)
2136 `(setf (nth 3 ,data) ,header))
2138 (defmacro gnus-data-level (data)
2141 (defmacro gnus-data-unread-p (data)
2142 `(= (nth 1 ,data) gnus-unread-mark))
2144 (defmacro gnus-data-read-p (data)
2145 `(/= (nth 1 ,data) gnus-unread-mark))
2147 (defmacro gnus-data-pseudo-p (data)
2148 `(consp (nth 3 ,data)))
2150 (defmacro gnus-data-find (number)
2151 `(assq ,number gnus-newsgroup-data))
2153 (defmacro gnus-data-find-list (number &optional data)
2154 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2155 (memq (assq ,number bdata)
2158 (defmacro gnus-data-make (number mark pos header level)
2159 `(list ,number ,mark ,pos ,header ,level))
2161 (defun gnus-data-enter (after-article number mark pos header level offset)
2162 (let ((data (gnus-data-find-list after-article)))
2164 (error "No such article: %d" after-article))
2165 (setcdr data (cons (gnus-data-make number mark pos header level)
2167 (setq gnus-newsgroup-data-reverse nil)
2168 (gnus-data-update-list (cddr data) offset)))
2170 (defun gnus-data-enter-list (after-article list &optional offset)
2172 (let ((data (and after-article (gnus-data-find-list after-article)))
2176 (let ((odata gnus-newsgroup-data))
2177 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2179 (gnus-data-update-list odata offset)))
2180 ;; Find the last element in the list to be spliced into the main
2183 (setq list (cdr list)))
2186 (setcdr list gnus-newsgroup-data)
2187 (setq gnus-newsgroup-data ilist)
2189 (gnus-data-update-list (cdr list) offset)))
2190 (setcdr list (cdr data))
2193 (gnus-data-update-list (cdr list) offset))))
2194 (setq gnus-newsgroup-data-reverse nil))))
2196 (defun gnus-data-remove (article &optional offset)
2197 (let ((data gnus-newsgroup-data))
2198 (if (= (gnus-data-number (car data)) article)
2200 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2201 gnus-newsgroup-data-reverse nil)
2203 (gnus-data-update-list gnus-newsgroup-data offset)))
2205 (when (= (gnus-data-number (cadr data)) article)
2206 (setcdr data (cddr data))
2208 (gnus-data-update-list (cdr data) offset))
2210 gnus-newsgroup-data-reverse nil))
2211 (setq data (cdr data))))))
2213 (defmacro gnus-data-list (backward)
2215 (or gnus-newsgroup-data-reverse
2216 (setq gnus-newsgroup-data-reverse
2217 (reverse gnus-newsgroup-data)))
2218 gnus-newsgroup-data))
2220 (defun gnus-data-update-list (data offset)
2221 "Add OFFSET to the POS of all data entries in DATA."
2222 (setq gnus-newsgroup-data-reverse nil)
2224 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2225 (setq data (cdr data))))
2227 (defun gnus-summary-article-pseudo-p (article)
2228 "Say whether this article is a pseudo article or not."
2229 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2231 (defmacro gnus-summary-article-sparse-p (article)
2232 "Say whether this article is a sparse article or not."
2233 `(memq ,article gnus-newsgroup-sparse))
2235 (defmacro gnus-summary-article-ancient-p (article)
2236 "Say whether this article is a sparse article or not."
2237 `(memq ,article gnus-newsgroup-ancient))
2239 (defun gnus-article-parent-p (number)
2240 "Say whether this article is a parent or not."
2241 (let ((data (gnus-data-find-list number)))
2242 (and (cdr data) ; There has to be an article after...
2243 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2244 (gnus-data-level (nth 1 data))))))
2246 (defun gnus-article-children (number)
2247 "Return a list of all children to NUMBER."
2248 (let* ((data (gnus-data-find-list number))
2249 (level (gnus-data-level (car data)))
2251 (setq data (cdr data))
2253 (= (gnus-data-level (car data)) (1+ level)))
2254 (push (gnus-data-number (car data)) children)
2255 (setq data (cdr data)))
2258 (defmacro gnus-summary-skip-intangible ()
2259 "If the current article is intangible, then jump to a different article."
2260 '(let ((to (get-text-property (point) 'gnus-intangible)))
2261 (and to (gnus-summary-goto-subject to))))
2263 (defmacro gnus-summary-article-intangible-p ()
2264 "Say whether this article is intangible or not."
2265 '(get-text-property (point) 'gnus-intangible))
2267 (defun gnus-article-read-p (article)
2268 "Say whether ARTICLE is read or not."
2269 (not (or (memq article gnus-newsgroup-marked)
2270 (memq article gnus-newsgroup-unreads)
2271 (memq article gnus-newsgroup-unselected)
2272 (memq article gnus-newsgroup-dormant))))
2274 ;; Some summary mode macros.
2276 (defmacro gnus-summary-article-number ()
2277 "The article number of the article on the current line.
2278 If there isn's an article number here, then we return the current
2281 (gnus-summary-skip-intangible)
2282 (or (get-text-property (point) 'gnus-number)
2283 (gnus-summary-last-subject))))
2285 (defmacro gnus-summary-article-header (&optional number)
2286 "Return the header of article NUMBER."
2287 `(gnus-data-header (gnus-data-find
2288 ,(or number '(gnus-summary-article-number)))))
2290 (defmacro gnus-summary-thread-level (&optional number)
2291 "Return the level of thread that starts with article NUMBER."
2292 `(if (and (eq gnus-summary-make-false-root 'dummy)
2293 (get-text-property (point) 'gnus-intangible))
2295 (gnus-data-level (gnus-data-find
2296 ,(or number '(gnus-summary-article-number))))))
2298 (defmacro gnus-summary-article-mark (&optional number)
2299 "Return the mark of article NUMBER."
2300 `(gnus-data-mark (gnus-data-find
2301 ,(or number '(gnus-summary-article-number)))))
2303 (defmacro gnus-summary-article-pos (&optional number)
2304 "Return the position of the line of article NUMBER."
2305 `(gnus-data-pos (gnus-data-find
2306 ,(or number '(gnus-summary-article-number)))))
2308 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2309 (defmacro gnus-summary-article-subject (&optional number)
2310 "Return current subject string or nil if nothing."
2313 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2314 '(gnus-data-header (assq (gnus-summary-article-number)
2315 gnus-newsgroup-data)))))
2318 (mail-header-subject headers))))
2320 (defmacro gnus-summary-article-score (&optional number)
2321 "Return current article score."
2322 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2323 gnus-newsgroup-scored))
2324 gnus-summary-default-score 0))
2326 (defun gnus-summary-article-children (&optional number)
2327 "Return a list of article numbers that are children of article NUMBER."
2328 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2329 (level (gnus-data-level (car data)))
2331 (while (and (setq data (cdr data))
2332 (> (setq l (gnus-data-level (car data))) level))
2333 (and (= (1+ level) l)
2334 (push (gnus-data-number (car data))
2336 (nreverse children)))
2338 (defun gnus-summary-article-parent (&optional number)
2339 "Return the article number of the parent of article NUMBER."
2340 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2341 (gnus-data-list t)))
2342 (level (gnus-data-level (car data))))
2344 () ; This is a root.
2345 ;; We search until we find an article with a level less than
2346 ;; this one. That function has to be the parent.
2347 (while (and (setq data (cdr data))
2348 (not (< (gnus-data-level (car data)) level))))
2349 (and data (gnus-data-number (car data))))))
2351 (defun gnus-unread-mark-p (mark)
2352 "Say whether MARK is the unread mark."
2353 (= mark gnus-unread-mark))
2355 (defun gnus-read-mark-p (mark)
2356 "Say whether MARK is one of the marks that mark as read.
2357 This is all marks except unread, ticked, dormant, and expirable."
2358 (not (or (= mark gnus-unread-mark)
2359 (= mark gnus-ticked-mark)
2360 (= mark gnus-dormant-mark)
2361 (= mark gnus-expirable-mark))))
2363 (defmacro gnus-article-mark (number)
2364 "Return the MARK of article NUMBER.
2365 This macro should only be used when computing the mark the \"first\"
2366 time; i.e., when generating the summary lines. After that,
2367 `gnus-summary-article-mark' should be used to examine the
2370 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2371 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2372 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2373 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2374 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2375 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2376 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2377 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2378 gnus-ancient-mark))))
2380 ;; Saving hidden threads.
2382 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2383 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2385 (defmacro gnus-save-hidden-threads (&rest forms)
2386 "Save hidden threads, eval FORMS, and restore the hidden threads."
2387 (let ((config (make-symbol "config")))
2388 `(let ((,config (gnus-hidden-threads-configuration)))
2392 (gnus-restore-hidden-threads-configuration ,config)))))
2394 (defun gnus-data-compute-positions ()
2395 "Compute the positions of all articles."
2396 (setq gnus-newsgroup-data-reverse nil)
2397 (let ((data gnus-newsgroup-data))
2399 (gnus-save-hidden-threads
2400 (gnus-summary-show-all-threads)
2401 (goto-char (point-min))
2403 (while (get-text-property (point) 'gnus-intangible)
2405 (gnus-data-set-pos (car data) (+ (point) 3))
2406 (setq data (cdr data))
2407 (forward-line 1))))))
2409 (defun gnus-hidden-threads-configuration ()
2410 "Return the current hidden threads configuration."
2413 (goto-char (point-min))
2414 (while (search-forward "\r" nil t)
2415 (push (1- (point)) config))
2418 (defun gnus-restore-hidden-threads-configuration (config)
2419 "Restore hidden threads configuration from CONFIG."
2420 (let (point buffer-read-only)
2421 (while (setq point (pop config))
2422 (when (and (< point (point-max))
2424 (eq (char-after) ?\n))
2425 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2427 ;; Various summary mode internalish functions.
2429 (defun gnus-mouse-pick-article (e)
2432 (gnus-summary-next-page nil t))
2434 (defun gnus-summary-set-display-table ()
2435 ;; Change the display table. Odd characters have a tendency to mess
2436 ;; up nicely formatted displays - we make all possible glyphs
2437 ;; display only a single character.
2439 ;; We start from the standard display table, if any.
2440 (let ((table (or (copy-sequence standard-display-table)
2441 (make-display-table)))
2443 ;; Nix out all the control chars...
2444 (while (>= (setq i (1- i)) 0)
2445 (aset table i [??]))
2446 ;; ... but not newline and cr, of course. (cr is necessary for the
2447 ;; selective display).
2448 (aset table ?\n nil)
2449 (aset table ?\r nil)
2450 ;; We keep TAB as well.
2451 (aset table ?\t nil)
2452 ;; We nix out any glyphs over 126 that are not set already.
2454 (while (>= (setq i (1- i)) 127)
2455 ;; Only modify if the entry is nil.
2456 (unless (aref table i)
2457 (aset table i [??]))))
2458 (setq buffer-display-table table)))
2460 (defun gnus-summary-setup-buffer (group)
2461 "Initialize summary buffer."
2462 (let ((buffer (concat "*Summary " group "*")))
2463 (if (get-buffer buffer)
2466 (setq gnus-summary-buffer (current-buffer))
2467 (not gnus-newsgroup-prepared))
2468 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2469 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2470 (gnus-summary-mode group)
2472 (gnus-carpal-setup-buffer 'summary))
2473 (unless gnus-single-article-buffer
2474 (make-local-variable 'gnus-article-buffer)
2475 (make-local-variable 'gnus-article-current)
2476 (make-local-variable 'gnus-original-article-buffer))
2477 (setq gnus-newsgroup-name group)
2480 (defun gnus-set-global-variables ()
2481 ;; Set the global equivalents of the summary buffer-local variables
2482 ;; to the latest values they had. These reflect the summary buffer
2483 ;; that was in action when the last article was fetched.
2484 (when (eq major-mode 'gnus-summary-mode)
2485 (setq gnus-summary-buffer (current-buffer))
2486 (let ((name gnus-newsgroup-name)
2487 (marked gnus-newsgroup-marked)
2488 (unread gnus-newsgroup-unreads)
2489 (headers gnus-current-headers)
2490 (data gnus-newsgroup-data)
2491 (summary gnus-summary-buffer)
2492 (article-buffer gnus-article-buffer)
2493 (original gnus-original-article-buffer)
2494 (gac gnus-article-current)
2495 (reffed gnus-reffed-article-number)
2496 (score-file gnus-current-score-file)
2497 (default-charset gnus-newsgroup-charset))
2499 (set-buffer gnus-group-buffer)
2500 (setq gnus-newsgroup-name name
2501 gnus-newsgroup-marked marked
2502 gnus-newsgroup-unreads unread
2503 gnus-current-headers headers
2504 gnus-newsgroup-data data
2505 gnus-article-current gac
2506 gnus-summary-buffer summary
2507 gnus-article-buffer article-buffer
2508 gnus-original-article-buffer original
2509 gnus-reffed-article-number reffed
2510 gnus-current-score-file score-file
2511 gnus-newsgroup-charset default-charset)
2512 ;; The article buffer also has local variables.
2513 (when (gnus-buffer-live-p gnus-article-buffer)
2514 (set-buffer gnus-article-buffer)
2515 (setq gnus-summary-buffer summary))))))
2517 (defun gnus-summary-article-unread-p (article)
2518 "Say whether ARTICLE is unread or not."
2519 (memq article gnus-newsgroup-unreads))
2521 (defun gnus-summary-first-article-p (&optional article)
2522 "Return whether ARTICLE is the first article in the buffer."
2523 (if (not (setq article (or article (gnus-summary-article-number))))
2525 (eq article (caar gnus-newsgroup-data))))
2527 (defun gnus-summary-last-article-p (&optional article)
2528 "Return whether ARTICLE is the last article in the buffer."
2529 (if (not (setq article (or article (gnus-summary-article-number))))
2530 ;; All non-existent numbers are the last article. :-)
2532 (not (cdr (gnus-data-find-list article)))))
2534 (defun gnus-make-thread-indent-array ()
2536 (unless (and gnus-thread-indent-array
2537 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2538 (setq gnus-thread-indent-array (make-vector 201 "")
2539 gnus-thread-indent-array-level gnus-thread-indent-level)
2541 (aset gnus-thread-indent-array n
2542 (make-string (* n gnus-thread-indent-level) ? ))
2545 (defun gnus-update-summary-mark-positions ()
2546 "Compute where the summary marks are to go."
2548 (when (gnus-buffer-exists-p gnus-summary-buffer)
2549 (set-buffer gnus-summary-buffer))
2550 (let ((gnus-replied-mark 129)
2551 (gnus-score-below-mark 130)
2552 (gnus-score-over-mark 130)
2553 (gnus-download-mark 131)
2554 (spec gnus-summary-line-format-spec)
2557 (gnus-set-work-buffer)
2558 (let ((gnus-summary-line-format-spec spec)
2559 (gnus-newsgroup-downloadable '((0 . t))))
2560 (gnus-summary-insert-line
2561 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2562 (goto-char (point-min))
2563 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2565 (goto-char (point-min))
2566 (push (cons 'replied (and (search-forward "\201" nil t)
2569 (goto-char (point-min))
2570 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2572 (goto-char (point-min))
2573 (push (cons 'download
2574 (and (search-forward "\203" nil t) (- (point) 2)))
2576 (setq gnus-summary-mark-positions pos))))
2578 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2579 "Insert a dummy root in the summary buffer."
2581 (gnus-add-text-properties
2582 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2583 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2585 (defun gnus-summary-from-or-to-or-newsgroups (header)
2586 (let ((to (cdr (assq 'To (mail-header-extra header))))
2587 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2588 (mail-parse-charset gnus-newsgroup-charset)
2589 (mail-parse-ignored-charsets
2590 (save-excursion (set-buffer gnus-summary-buffer)
2591 gnus-newsgroup-ignored-charsets)))
2594 gnus-ignored-from-addresses
2595 (string-match gnus-ignored-from-addresses
2596 (mail-header-from header)))
2598 (or (car (funcall gnus-extract-address-components
2600 gnus-decode-encoded-word-function to)))
2601 (funcall gnus-decode-encoded-word-function to))))
2603 gnus-ignored-from-addresses
2604 (string-match gnus-ignored-from-addresses
2605 (mail-header-from header)))
2606 (concat "=> " newsgroups))
2608 (or (car (funcall gnus-extract-address-components
2609 (mail-header-from header)))
2610 (mail-header-from header))))))
2612 (defun gnus-summary-insert-line (gnus-tmp-header
2613 gnus-tmp-level gnus-tmp-current
2614 gnus-tmp-unread gnus-tmp-replied
2615 gnus-tmp-expirable gnus-tmp-subject-or-nil
2616 &optional gnus-tmp-dummy gnus-tmp-score
2618 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2619 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2620 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2621 (gnus-tmp-score-char
2622 (if (or (null gnus-summary-default-score)
2623 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2624 gnus-summary-zcore-fuzz))
2626 (if (< gnus-tmp-score gnus-summary-default-score)
2627 gnus-score-below-mark gnus-score-over-mark)))
2629 (cond (gnus-tmp-process gnus-process-mark)
2630 ((memq gnus-tmp-current gnus-newsgroup-cached)
2632 (gnus-tmp-replied gnus-replied-mark)
2633 ((memq gnus-tmp-current gnus-newsgroup-saved)
2635 (t gnus-unread-mark)))
2636 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2639 ((string-match "<[^>]+> *$" gnus-tmp-from)
2640 (let ((beg (match-beginning 0)))
2641 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2642 (substring gnus-tmp-from (1+ (match-beginning 0))
2643 (1- (match-end 0))))
2644 (substring gnus-tmp-from 0 beg))))
2645 ((string-match "(.+)" gnus-tmp-from)
2646 (substring gnus-tmp-from
2647 (1+ (match-beginning 0)) (1- (match-end 0))))
2649 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2650 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2651 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2652 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2653 (buffer-read-only nil))
2654 (when (string= gnus-tmp-name "")
2655 (setq gnus-tmp-name gnus-tmp-from))
2656 (unless (numberp gnus-tmp-lines)
2657 (setq gnus-tmp-lines 0))
2658 (gnus-put-text-property
2660 (progn (eval gnus-summary-line-format-spec) (point))
2661 'gnus-number gnus-tmp-number)
2662 (when (gnus-visual-p 'summary-highlight 'highlight)
2664 (gnus-run-hooks 'gnus-summary-update-hook)
2667 (defun gnus-summary-update-line (&optional dont-update)
2668 ;; Update summary line after change.
2669 (when (and gnus-summary-default-score
2670 (not gnus-summary-inhibit-highlight))
2671 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2672 (article (gnus-summary-article-number))
2673 (score (gnus-summary-article-score article)))
2675 (if (and gnus-summary-mark-below
2676 (< (gnus-summary-article-score)
2677 gnus-summary-mark-below))
2678 ;; This article has a low score, so we mark it as read.
2679 (when (memq article gnus-newsgroup-unreads)
2680 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2681 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2682 ;; This article was previously marked as read on account
2683 ;; of a low score, but now it has risen, so we mark it as
2685 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2686 (gnus-summary-update-mark
2687 (if (or (null gnus-summary-default-score)
2688 (<= (abs (- score gnus-summary-default-score))
2689 gnus-summary-zcore-fuzz))
2691 (if (< score gnus-summary-default-score)
2692 gnus-score-below-mark gnus-score-over-mark))
2694 ;; Do visual highlighting.
2695 (when (gnus-visual-p 'summary-highlight 'highlight)
2696 (gnus-run-hooks 'gnus-summary-update-hook)))))
2698 (defvar gnus-tmp-new-adopts nil)
2700 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2701 "Return the number of articles in THREAD.
2702 This may be 0 in some cases -- if none of the articles in
2703 the thread are to be displayed."
2705 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2707 ((not (listp thread))
2709 ((and (consp thread) (cdr thread))
2712 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2715 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2718 (when (and level (zerop level) gnus-tmp-new-adopts)
2721 'gnus-summary-number-of-articles-in-thread
2722 gnus-tmp-new-adopts))))
2724 (if (> number 1) gnus-not-empty-thread-mark
2725 gnus-empty-thread-mark)
2728 (defun gnus-summary-set-local-parameters (group)
2729 "Go through the local params of GROUP and set all variable specs in that list."
2730 (let ((params (gnus-group-find-parameter group))
2733 (setq elem (car params)
2734 params (cdr params))
2735 (and (consp elem) ; Has to be a cons.
2736 (consp (cdr elem)) ; The cdr has to be a list.
2737 (symbolp (car elem)) ; Has to be a symbol in there.
2738 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2739 (ignore-errors ; So we set it.
2740 (make-local-variable (car elem))
2741 (set (car elem) (eval (nth 1 elem))))))))
2743 (defun gnus-summary-read-group (group &optional show-all no-article
2744 kill-buffer no-display backward
2746 "Start reading news in newsgroup GROUP.
2747 If SHOW-ALL is non-nil, already read articles are also listed.
2748 If NO-ARTICLE is non-nil, no article is selected initially.
2749 If NO-DISPLAY, don't generate a summary buffer."
2753 (let ((gnus-auto-select-next nil))
2754 (or (gnus-summary-read-group-1
2755 group show-all no-article
2756 kill-buffer no-display
2759 select-articles nil)))))
2760 (eq gnus-auto-select-next 'quietly))
2761 (set-buffer gnus-group-buffer)
2762 ;; The entry function called above goes to the next
2763 ;; group automatically, so we go two groups back
2764 ;; if we are searching for the previous group.
2766 (gnus-group-prev-unread-group 2))
2767 (if (not (equal group (gnus-group-group-name)))
2768 (setq group (gnus-group-group-name))
2772 (defun gnus-summary-read-group-1 (group show-all no-article
2773 kill-buffer no-display
2774 &optional select-articles)
2775 ;; Killed foreign groups can't be entered.
2776 (when (and (not (gnus-group-native-p group))
2777 (not (gnus-gethash group gnus-newsrc-hashtb)))
2778 (error "Dead non-native groups can't be entered"))
2779 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2780 (let* ((new-group (gnus-summary-setup-buffer group))
2781 (quit-config (gnus-group-quit-config group))
2782 (did-select (and new-group (gnus-select-newsgroup
2783 group show-all select-articles))))
2785 ;; This summary buffer exists already, so we just select it.
2787 (gnus-set-global-variables)
2789 (gnus-kill-or-deaden-summary kill-buffer))
2790 (gnus-configure-windows 'summary 'force)
2791 (gnus-set-mode-line 'summary)
2792 (gnus-summary-position-point)
2795 ;; We couldn't select this group.
2797 (when (and (eq major-mode 'gnus-summary-mode)
2798 (not (equal (current-buffer) kill-buffer)))
2799 (kill-buffer (current-buffer))
2800 (if (not quit-config)
2802 ;; Update the info -- marks might need to be removed,
2804 (gnus-summary-update-info)
2805 (set-buffer gnus-group-buffer)
2806 (gnus-group-jump-to-group group)
2807 (gnus-group-next-unread-group 1))
2808 (gnus-handle-ephemeral-exit quit-config)))
2809 (gnus-message 3 "Can't select group")
2811 ;; The user did a `C-g' while prompting for number of articles,
2812 ;; so we exit this group.
2813 ((eq did-select 'quit)
2814 (and (eq major-mode 'gnus-summary-mode)
2815 (not (equal (current-buffer) kill-buffer))
2816 (kill-buffer (current-buffer)))
2818 (gnus-kill-or-deaden-summary kill-buffer))
2819 (if (not quit-config)
2821 (set-buffer gnus-group-buffer)
2822 (gnus-group-jump-to-group group)
2823 (gnus-group-next-unread-group 1)
2824 (gnus-configure-windows 'group 'force))
2825 (gnus-handle-ephemeral-exit quit-config))
2826 ;; Finally signal the quit.
2828 ;; The group was successfully selected.
2830 (gnus-set-global-variables)
2831 ;; Save the active value in effect when the group was entered.
2832 (setq gnus-newsgroup-active
2834 (gnus-active gnus-newsgroup-name)))
2835 ;; You can change the summary buffer in some way with this hook.
2836 (gnus-run-hooks 'gnus-select-group-hook)
2837 ;; Set any local variables in the group parameters.
2838 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2839 (gnus-update-format-specifications
2840 nil 'summary 'summary-mode 'summary-dummy)
2841 (gnus-update-summary-mark-positions)
2842 ;; Do score processing.
2843 (when gnus-use-scoring
2844 (gnus-possibly-score-headers))
2845 ;; Check whether to fill in the gaps in the threads.
2846 (when gnus-build-sparse-threads
2847 (gnus-build-sparse-threads))
2848 ;; Find the initial limit.
2849 (if gnus-show-threads
2851 (let ((gnus-newsgroup-dormant nil))
2852 (gnus-summary-initial-limit show-all))
2853 (gnus-summary-initial-limit show-all))
2854 ;; When untreaded, all articles are always shown.
2855 (setq gnus-newsgroup-limit
2857 (lambda (header) (mail-header-number header))
2858 gnus-newsgroup-headers)))
2859 ;; Generate the summary buffer.
2861 (gnus-summary-prepare))
2862 (when gnus-use-trees
2863 (gnus-tree-open group)
2864 (setq gnus-summary-highlight-line-function
2865 'gnus-tree-highlight-article))
2866 ;; If the summary buffer is empty, but there are some low-scored
2867 ;; articles or some excluded dormants, we include these in the
2869 (when (and (zerop (buffer-size))
2871 (cond (gnus-newsgroup-dormant
2872 (gnus-summary-limit-include-dormant))
2873 ((and gnus-newsgroup-scored show-all)
2874 (gnus-summary-limit-include-expunged t))))
2875 ;; Function `gnus-apply-kill-file' must be called in this hook.
2876 (gnus-run-hooks 'gnus-apply-kill-hook)
2877 (if (and (zerop (buffer-size))
2880 ;; This newsgroup is empty.
2881 (gnus-summary-catchup-and-exit nil t)
2882 (gnus-message 6 "No unread news")
2884 (gnus-kill-or-deaden-summary kill-buffer))
2885 ;; Return nil from this function.
2887 ;; Hide conversation thread subtrees. We cannot do this in
2888 ;; gnus-summary-prepare-hook since kill processing may not
2889 ;; work with hidden articles.
2890 (and gnus-show-threads
2891 gnus-thread-hide-subtree
2892 (gnus-summary-hide-all-threads))
2894 (gnus-kill-or-deaden-summary kill-buffer))
2895 ;; Show first unread article if requested.
2896 (if (and (not no-article)
2898 gnus-newsgroup-unreads
2899 gnus-auto-select-first)
2901 (gnus-configure-windows 'summary)
2903 ((eq gnus-auto-select-first 'best)
2904 (gnus-summary-best-unread-article))
2905 ((eq gnus-auto-select-first t)
2906 (gnus-summary-first-unread-article))
2907 ((gnus-functionp gnus-auto-select-first)
2908 (funcall gnus-auto-select-first))))
2909 ;; Don't select any articles, just move point to the first
2910 ;; article in the group.
2911 (goto-char (point-min))
2912 (gnus-summary-position-point)
2913 (gnus-configure-windows 'summary 'force)
2914 (gnus-set-mode-line 'summary))
2915 (when (get-buffer-window gnus-group-buffer t)
2916 ;; Gotta use windows, because recenter does weird stuff if
2917 ;; the current buffer ain't the displayed window.
2918 (let ((owin (selected-window)))
2919 (select-window (get-buffer-window gnus-group-buffer t))
2920 (when (gnus-group-goto-group group)
2922 (select-window owin)))
2923 ;; Mark this buffer as "prepared".
2924 (setq gnus-newsgroup-prepared t)
2925 (gnus-run-hooks 'gnus-summary-prepared-hook)
2928 (defun gnus-summary-prepare ()
2929 "Generate the summary buffer."
2931 (let ((buffer-read-only nil))
2933 (setq gnus-newsgroup-data nil
2934 gnus-newsgroup-data-reverse nil)
2935 (gnus-run-hooks 'gnus-summary-generate-hook)
2936 ;; Generate the buffer, either with threads or without.
2937 (when gnus-newsgroup-headers
2938 (gnus-summary-prepare-threads
2939 (if gnus-show-threads
2940 (gnus-sort-gathered-threads
2941 (funcall gnus-summary-thread-gathering-function
2943 (gnus-cut-threads (gnus-make-threads)))))
2944 ;; Unthreaded display.
2945 (gnus-sort-articles gnus-newsgroup-headers))))
2946 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2947 ;; Call hooks for modifying summary buffer.
2948 (goto-char (point-min))
2949 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2951 (defsubst gnus-general-simplify-subject (subject)
2952 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2955 ;; Truncate the subject.
2956 (gnus-simplify-subject-functions
2957 (gnus-map-function gnus-simplify-subject-functions subject))
2958 ((numberp gnus-summary-gather-subject-limit)
2959 (setq subject (gnus-simplify-subject-re subject))
2960 (if (> (length subject) gnus-summary-gather-subject-limit)
2961 (substring subject 0 gnus-summary-gather-subject-limit)
2963 ;; Fuzzily simplify it.
2964 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2965 (gnus-simplify-subject-fuzzy subject))
2966 ;; Just remove the leading "Re:".
2968 (gnus-simplify-subject-re subject))))
2970 (if (and gnus-summary-gather-exclude-subject
2971 (string-match gnus-summary-gather-exclude-subject subject))
2972 nil ; This article shouldn't be gathered
2975 (defun gnus-summary-simplify-subject-query ()
2976 "Query where the respool algorithm would put this article."
2978 (gnus-summary-select-article)
2979 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2981 (defun gnus-gather-threads-by-subject (threads)
2982 "Gather threads by looking at Subject headers."
2983 (if (not gnus-summary-make-false-root)
2985 (let ((hashtb (gnus-make-hashtable 1024))
2988 subject hthread whole-subject)
2990 (setq subject (gnus-general-simplify-subject
2991 (setq whole-subject (mail-header-subject
2994 (if (setq hthread (gnus-gethash subject hashtb))
2996 ;; We enter a dummy root into the thread, if we
2997 ;; haven't done that already.
2998 (unless (stringp (caar hthread))
2999 (setcar hthread (list whole-subject (car hthread))))
3000 ;; We add this new gathered thread to this gathered
3002 (setcdr (car hthread)
3003 (nconc (cdar hthread) (list (car threads))))
3004 ;; Remove it from the list of threads.
3005 (setcdr prev (cdr threads))
3006 (setq threads prev))
3007 ;; Enter this thread into the hash table.
3008 (gnus-sethash subject threads hashtb)))
3010 (setq threads (cdr threads)))
3013 (defun gnus-gather-threads-by-references (threads)
3014 "Gather threads by looking at References headers."
3015 (let ((idhashtb (gnus-make-hashtable 1024))
3016 (thhashtb (gnus-make-hashtable 1024))
3019 ids references id gthread gid entered ref)
3021 (when (setq references (mail-header-references (caar threads)))
3022 (setq id (mail-header-id (caar threads))
3023 ids (gnus-split-references references)
3025 (while (setq ref (pop ids))
3026 (setq ids (delete ref ids))
3027 (if (not (setq gid (gnus-gethash ref idhashtb)))
3029 (gnus-sethash ref id idhashtb)
3030 (gnus-sethash id threads thhashtb))
3031 (setq gthread (gnus-gethash gid thhashtb))
3033 ;; We enter a dummy root into the thread, if we
3034 ;; haven't done that already.
3035 (unless (stringp (caar gthread))
3036 (setcar gthread (list (mail-header-subject (caar gthread))
3038 ;; We add this new gathered thread to this gathered
3040 (setcdr (car gthread)
3041 (nconc (cdar gthread) (list (car threads)))))
3042 ;; Add it into the thread hash table.
3043 (gnus-sethash id gthread thhashtb)
3045 ;; Remove it from the list of threads.
3046 (setcdr prev (cdr threads))
3047 (setq threads prev))))
3049 (setq threads (cdr threads)))
3052 (defun gnus-sort-gathered-threads (threads)
3053 "Sort subtreads inside each gathered thread by article number."
3054 (let ((result threads))
3056 (when (stringp (caar threads))
3057 (setcdr (car threads)
3058 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3059 (setq threads (cdr threads)))
3062 (defun gnus-thread-loop-p (root thread)
3063 "Say whether ROOT is in THREAD."
3064 (let ((stack (list thread))
3067 (while (setq thread (pop stack))
3068 (setq th (cdr thread))
3070 (not (eq (caar th) root)))
3073 ;; We have found a loop.
3075 (setcdr thread (delq (car th) (cdr thread)))
3076 (if (boundp (setq ref-dep (intern "none"
3077 gnus-newsgroup-dependencies)))
3078 (setcdr (symbol-value ref-dep)
3079 (nconc (cdr (symbol-value ref-dep))
3081 (set ref-dep (list nil (car th))))
3084 ;; Push all the subthreads onto the stack.
3085 (push (cdr thread) stack)))
3088 (defun gnus-make-threads ()
3089 "Go through the dependency hashtb and find the roots. Return all threads."
3091 (while (catch 'infloop
3094 ;; Deal with self-referencing References loops.
3095 (when (and (car (symbol-value refs))
3102 (car (symbol-value refs)) thread))
3103 (cdr (symbol-value refs)))))))
3106 (unless (car (symbol-value refs))
3107 ;; These threads do not refer back to any other articles,
3108 ;; so they're roots.
3109 (setq threads (append (cdr (symbol-value refs)) threads))))
3110 gnus-newsgroup-dependencies)))
3113 ;; Build the thread tree.
3114 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3115 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3117 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3118 if it was already present.
3120 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3121 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3122 Message-IDs will be renamed be renamed to a unique Message-ID before
3125 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3126 (let* ((id (mail-header-id header))
3127 (id-dep (and id (intern id dependencies)))
3128 ref ref-dep ref-header)
3129 ;; Enter this `header' in the `dependencies' table.
3133 ;; The first two cases do the normal part: enter a new `header'
3134 ;; in the `dependencies' table.
3135 ((not (boundp id-dep))
3136 (set id-dep (list header)))
3137 ((null (car (symbol-value id-dep)))
3138 (setcar (symbol-value id-dep) header))
3140 ;; From here the `header' was already present in the
3141 ;; `dependencies' table.
3143 ;; Overrides an existing entry;
3144 ;; just set the header part of the entry.
3145 (setcar (symbol-value id-dep) header))
3147 ;; Renames the existing `header' to a unique Message-ID.
3148 ((not gnus-summary-ignore-duplicates)
3149 ;; An article with this Message-ID has already been seen.
3150 ;; We rename the Message-ID.
3151 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3153 (mail-header-set-id header id))
3155 ;; The last case ignores an existing entry, except it adds any
3156 ;; additional Xrefs (in case the two articles came from different
3158 ;; Also sets `header' to `nil' meaning that the `dependencies'
3159 ;; table was *not* modified.
3161 (mail-header-set-xref
3162 (car (symbol-value id-dep))
3163 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3165 (or (mail-header-xref header) "")))
3169 ;; First check if that we are not creating a References loop.
3170 (setq ref (gnus-parent-id (mail-header-references header)))
3172 (setq ref-dep (intern-soft ref dependencies))
3174 (setq ref-header (car (symbol-value ref-dep))))
3175 (if (string= id ref)
3176 ;; Yuk! This is a reference loop. Make the article be a
3179 (mail-header-set-references (car (symbol-value id-dep)) "none")
3181 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3182 (setq ref (gnus-parent-id (mail-header-references header)))
3183 (setq ref-dep (intern (or ref "none") dependencies))
3184 (if (boundp ref-dep)
3185 (setcdr (symbol-value ref-dep)
3186 (nconc (cdr (symbol-value ref-dep))
3187 (list (symbol-value id-dep))))
3188 (set ref-dep (list nil (symbol-value id-dep)))))
3191 (defun gnus-build-sparse-threads ()
3192 (let ((headers gnus-newsgroup-headers)
3193 (mail-parse-charset gnus-newsgroup-charset)
3194 (gnus-summary-ignore-duplicates t)
3195 header references generation relations
3196 subject child end new-child date)
3197 ;; First we create an alist of generations/relations, where
3198 ;; generations is how much we trust the relation, and the relation
3200 (gnus-message 7 "Making sparse threads...")
3202 (nnheader-set-temp-buffer " *gnus sparse threads*")
3203 (while (setq header (pop headers))
3204 (when (and (setq references (mail-header-references header))
3205 (not (string= references "")))
3207 (setq child (mail-header-id header)
3208 subject (mail-header-subject header)
3209 date (mail-header-date header)
3211 (while (search-backward ">" nil t)
3212 (setq end (1+ (point)))
3213 (when (search-backward "<" nil t)
3214 (setq new-child (buffer-substring (point) end))
3215 (push (list (incf generation)
3216 child (setq child new-child)
3220 (push (list (1+ generation) child nil subject) relations))
3222 (kill-buffer (current-buffer)))
3223 ;; Sort over trustworthiness.
3226 (when (gnus-dependencies-add-header
3227 (make-full-mail-header
3228 gnus-reffed-article-number
3229 (nth 3 relation) "" (or (nth 4 relation) "")
3231 (or (nth 2 relation) "") 0 0 "")
3232 gnus-newsgroup-dependencies nil)
3233 (push gnus-reffed-article-number gnus-newsgroup-limit)
3234 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3235 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3236 gnus-newsgroup-reads)
3237 (decf gnus-reffed-article-number)))
3238 (sort relations 'car-less-than-car))
3239 (gnus-message 7 "Making sparse threads...done")))
3241 (defun gnus-build-old-threads ()
3242 ;; Look at all the articles that refer back to old articles, and
3243 ;; fetch the headers for the articles that aren't there. This will
3244 ;; build complete threads - if the roots haven't been expired by the
3246 (let ((mail-parse-charset gnus-newsgroup-charset)
3250 (when (not (car (symbol-value refs)))
3251 (setq heads (cdr (symbol-value refs)))
3253 (if (memq (mail-header-number (caar heads))
3254 gnus-newsgroup-dormant)
3255 (setq heads (cdr heads))
3256 (setq id (symbol-name refs))
3257 (while (and (setq id (gnus-build-get-header id))
3258 (not (car (gnus-id-to-thread id)))))
3259 (setq heads nil)))))
3260 gnus-newsgroup-dependencies)))
3262 ;; This function has to be called with point after the article number
3263 ;; on the beginning of the line.
3264 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3265 (let ((eol (gnus-point-at-eol))
3266 (buffer (current-buffer))
3269 ;; overview: [num subject from date id refs chars lines misc]
3272 (narrow-to-region (point) eol)
3277 (make-full-mail-header
3279 (funcall gnus-decode-encoded-word-function
3280 (nnheader-nov-field)) ; subject
3281 (funcall gnus-decode-encoded-word-function
3282 (nnheader-nov-field)) ; from
3283 (nnheader-nov-field) ; date
3284 (nnheader-nov-read-message-id) ; id
3285 (nnheader-nov-field) ; refs
3286 (nnheader-nov-read-integer) ; chars
3287 (nnheader-nov-read-integer) ; lines
3289 (nnheader-nov-field)) ; misc
3290 (nnheader-nov-parse-extra)))) ; extra
3294 (when gnus-alter-header-function
3295 (funcall gnus-alter-header-function header))
3296 (gnus-dependencies-add-header header dependencies force-new)))
3298 (defun gnus-build-get-header (id)
3299 ;; Look through the buffer of NOV lines and find the header to
3300 ;; ID. Enter this line into the dependencies hash table, and return
3301 ;; the id of the parent article (if any).
3302 (let ((deps gnus-newsgroup-dependencies)
3306 (set-buffer nntp-server-buffer)
3307 (let ((case-fold-search nil))
3308 (goto-char (point-min))
3309 (while (and (not found)
3310 (search-forward id nil t))
3312 (setq found (looking-at
3313 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3314 (regexp-quote id))))
3315 (or found (beginning-of-line 2)))
3319 (setq header (gnus-nov-parse-line
3320 (read (current-buffer)) deps))
3321 (gnus-parent-id (mail-header-references header))))))
3323 (let ((number (mail-header-number header)))
3324 (push number gnus-newsgroup-limit)
3325 (push header gnus-newsgroup-headers)
3326 (if (memq number gnus-newsgroup-unselected)
3328 (push number gnus-newsgroup-unreads)
3329 (setq gnus-newsgroup-unselected
3330 (delq number gnus-newsgroup-unselected)))
3331 (push number gnus-newsgroup-ancient)))))))
3333 (defun gnus-build-all-threads ()
3334 "Read all the headers."
3335 (let ((gnus-summary-ignore-duplicates t)
3336 (mail-parse-charset gnus-newsgroup-charset)
3337 (dependencies gnus-newsgroup-dependencies)
3340 (set-buffer nntp-server-buffer)
3341 (let ((case-fold-search nil))
3342 (goto-char (point-min))
3345 (setq article (read (current-buffer))
3346 header (gnus-nov-parse-line article dependencies)))
3349 (set-buffer gnus-summary-buffer)
3350 (push header gnus-newsgroup-headers)
3351 (if (memq (setq article (mail-header-number header))
3352 gnus-newsgroup-unselected)
3354 (push article gnus-newsgroup-unreads)
3355 (setq gnus-newsgroup-unselected
3356 (delq article gnus-newsgroup-unselected)))
3357 (push article gnus-newsgroup-ancient)))
3358 (forward-line 1)))))))
3360 (defun gnus-summary-update-article-line (article header)
3361 "Update the line for ARTICLE using HEADERS."
3362 (let* ((id (mail-header-id header))
3363 (thread (gnus-id-to-thread id)))
3365 (error "Article in no thread"))
3366 ;; Update the thread.
3367 (setcar thread header)
3368 (gnus-summary-goto-subject article)
3369 (let* ((datal (gnus-data-find-list article))
3371 (length (when (cdr datal)
3372 (- (gnus-data-pos data)
3373 (gnus-data-pos (cadr datal)))))
3374 (buffer-read-only nil)
3375 (level (gnus-summary-thread-level)))
3377 (gnus-summary-insert-line
3378 header level nil (gnus-article-mark article)
3379 (memq article gnus-newsgroup-replied)
3380 (memq article gnus-newsgroup-expirable)
3381 ;; Only insert the Subject string when it's different
3382 ;; from the previous Subject string.
3387 (mail-header-subject
3390 (gnus-data-find-list
3392 (gnus-data-list t)))))
3393 ;; Error on the side of excessive subjects.
3395 (mail-header-subject header)))
3397 (mail-header-subject header))
3398 nil (cdr (assq article gnus-newsgroup-scored))
3399 (memq article gnus-newsgroup-processable))
3401 (gnus-data-update-list
3402 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3404 (defun gnus-summary-update-article (article &optional iheader)
3405 "Update ARTICLE in the summary buffer."
3406 (set-buffer gnus-summary-buffer)
3407 (let* ((header (gnus-summary-article-header article))
3408 (id (mail-header-id header))
3409 (data (gnus-data-find article))
3410 (thread (gnus-id-to-thread id))
3411 (references (mail-header-references header))
3415 (when (and references
3416 (not (equal "" references)))
3419 (buffer-read-only nil)
3425 (delq thread parent)))
3426 (if (gnus-summary-insert-subject id header)
3427 ;; Set the (possibly) new article number in the data structure.
3428 (gnus-data-set-number data (gnus-id-to-article id))
3432 (defun gnus-rebuild-thread (id &optional line)
3433 "Rebuild the thread containing ID.
3434 If LINE, insert the rebuilt thread starting on line LINE."
3435 (let ((buffer-read-only nil)
3436 old-pos current thread data)
3437 (if (not gnus-show-threads)
3438 (setq thread (list (car (gnus-id-to-thread id))))
3439 ;; Get the thread this article is part of.
3440 (setq thread (gnus-remove-thread id)))
3441 (setq old-pos (gnus-point-at-bol))
3442 (setq current (save-excursion
3443 (and (zerop (forward-line -1))
3444 (gnus-summary-article-number))))
3445 ;; If this is a gathered thread, we have to go some re-gathering.
3446 (when (stringp (car thread))
3447 (let ((subject (car thread))
3449 (setq thread (cdr thread))
3451 (unless (memq (setq thr (gnus-id-to-thread
3453 (mail-header-id (caar thread)))))
3456 (setq thread (cdr thread)))
3457 ;; We now have all (unique) roots.
3458 (if (= (length roots) 1)
3459 ;; All the loose roots are now one solid root.
3460 (setq thread (car roots))
3461 (setq thread (cons subject (gnus-sort-threads roots))))))
3463 ;; We then insert this thread into the summary buffer.
3465 (goto-char (point-min))
3466 (forward-line (1- line)))
3467 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3468 (if gnus-show-threads
3469 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3470 (gnus-summary-prepare-unthreaded thread))
3471 (setq data (nreverse gnus-newsgroup-data))
3472 (setq threads gnus-newsgroup-threads))
3473 ;; We splice the new data into the data structure.
3474 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3475 ;;!!! then we want to insert at the beginning of the buffer.
3476 ;;!!! That happens to be true with Gnus now, but that may
3477 ;;!!! change in the future. Perhaps.
3478 (gnus-data-enter-list
3479 (if line nil current) data (- (point) old-pos))
3480 (setq gnus-newsgroup-threads
3481 (nconc threads gnus-newsgroup-threads))
3482 (gnus-data-compute-positions))))
3484 (defun gnus-number-to-header (number)
3485 "Return the header for article NUMBER."
3486 (let ((headers gnus-newsgroup-headers))
3488 (not (= number (mail-header-number (car headers)))))
3493 (defun gnus-parent-headers (in-headers &optional generation)
3494 "Return the headers of the GENERATIONeth parent of HEADERS."
3496 (setq generation 1))
3498 (headers in-headers)
3501 (not (zerop generation))
3502 (setq references (mail-header-references headers)))
3503 (setq headers (if (and references
3504 (setq parent (gnus-parent-id references)))
3505 (car (gnus-id-to-thread parent))
3508 (and (not (eq headers in-headers))
3511 (defun gnus-id-to-thread (id)
3512 "Return the (sub-)thread where ID appears."
3513 (gnus-gethash id gnus-newsgroup-dependencies))
3515 (defun gnus-id-to-article (id)
3516 "Return the article number of ID."
3517 (let ((thread (gnus-id-to-thread id)))
3520 (mail-header-number (car thread)))))
3522 (defun gnus-id-to-header (id)
3523 "Return the article headers of ID."
3524 (car (gnus-id-to-thread id)))
3526 (defun gnus-article-displayed-root-p (article)
3527 "Say whether ARTICLE is a root(ish) article."
3528 (let ((level (gnus-summary-thread-level article))
3529 (refs (mail-header-references (gnus-summary-article-header article)))
3535 ((null (gnus-parent-id refs)) t)
3537 (null (setq particle (gnus-id-to-article
3538 (gnus-parent-id refs))))
3539 (null (gnus-summary-thread-level particle)))))))
3541 (defun gnus-root-id (id)
3542 "Return the id of the root of the thread where ID appears."
3544 (while (and id (setq prev (car (gnus-id-to-thread id))))
3546 id (gnus-parent-id (mail-header-references prev))))
3549 (defun gnus-articles-in-thread (thread)
3550 "Return the list of articles in THREAD."
3551 (cons (mail-header-number (car thread))
3552 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3554 (defun gnus-remove-thread (id &optional dont-remove)
3555 "Remove the thread that has ID in it."
3556 (let (headers thread last-id)
3557 ;; First go up in this thread until we find the root.
3558 (setq last-id (gnus-root-id id)
3559 headers (message-flatten-list (gnus-id-to-thread last-id)))
3560 ;; We have now found the real root of this thread. It might have
3561 ;; been gathered into some loose thread, so we have to search
3562 ;; through the threads to find the thread we wanted.
3563 (let ((threads gnus-newsgroup-threads)
3566 (setq sub (car threads))
3567 (if (stringp (car sub))
3568 ;; This is a gathered thread, so we look at the roots
3569 ;; below it to find whether this article is in this
3572 (setq sub (cdr sub))
3574 (when (member (caar sub) headers)
3575 (setq thread (car threads)
3578 (setq sub (cdr sub))))
3579 ;; It's an ordinary thread, so we check it.
3580 (when (eq (car sub) (car headers))
3583 (setq threads (cdr threads)))
3584 ;; If this article is in no thread, then it's a root.
3587 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3588 (setq thread (gnus-id-to-thread last-id)))
3591 thread ; We return this thread.
3593 (if (stringp (car thread))
3595 ;; If we use dummy roots, then we have to remove the
3596 ;; dummy root as well.
3597 (when (eq gnus-summary-make-false-root 'dummy)
3598 ;; We go to the dummy root by going to
3599 ;; the first sub-"thread", and then one line up.
3600 (gnus-summary-goto-article
3601 (mail-header-number (caadr thread)))
3604 (gnus-data-compute-positions))
3605 (setq thread (cdr thread))
3607 (gnus-remove-thread-1 (car thread))
3608 (setq thread (cdr thread))))
3609 (gnus-remove-thread-1 thread))))))))
3611 (defun gnus-remove-thread-1 (thread)
3612 "Remove the thread THREAD recursively."
3613 (let ((number (mail-header-number (pop thread)))
3615 (setq thread (reverse thread))
3617 (gnus-remove-thread-1 (pop thread)))
3618 (when (setq d (gnus-data-find number))
3619 (goto-char (gnus-data-pos d))
3620 (gnus-summary-show-thread)
3623 (- (gnus-point-at-bol)
3625 (1+ (gnus-point-at-eol))
3626 (gnus-delete-line)))))))
3628 (defun gnus-sort-threads (threads)
3630 (if (not gnus-thread-sort-functions)
3632 (gnus-message 8 "Sorting threads...")
3634 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3635 (gnus-message 8 "Sorting threads...done"))))
3637 (defun gnus-sort-articles (articles)
3639 (when gnus-article-sort-functions
3640 (gnus-message 7 "Sorting articles...")
3642 (setq gnus-newsgroup-headers
3643 (sort articles (gnus-make-sort-function
3644 gnus-article-sort-functions)))
3645 (gnus-message 7 "Sorting articles...done"))))
3647 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3648 (defmacro gnus-thread-header (thread)
3649 ;; Return header of first article in THREAD.
3650 ;; Note that THREAD must never, ever be anything else than a variable -
3651 ;; using some other form will lead to serious barfage.
3652 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3653 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3654 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3657 (defsubst gnus-article-sort-by-number (h1 h2)
3658 "Sort articles by article number."
3659 (< (mail-header-number h1)
3660 (mail-header-number h2)))
3662 (defun gnus-thread-sort-by-number (h1 h2)
3663 "Sort threads by root article number."
3664 (gnus-article-sort-by-number
3665 (gnus-thread-header h1) (gnus-thread-header h2)))
3667 (defsubst gnus-article-sort-by-lines (h1 h2)
3668 "Sort articles by article Lines header."
3669 (< (mail-header-lines h1)
3670 (mail-header-lines h2)))
3672 (defun gnus-thread-sort-by-lines (h1 h2)
3673 "Sort threads by root article Lines header."
3674 (gnus-article-sort-by-lines
3675 (gnus-thread-header h1) (gnus-thread-header h2)))
3677 (defsubst gnus-article-sort-by-chars (h1 h2)
3678 "Sort articles by octet length."
3679 (< (mail-header-chars h1)
3680 (mail-header-chars h2)))
3682 (defun gnus-thread-sort-by-chars (h1 h2)
3683 "Sort threads by root article octet length."
3684 (gnus-article-sort-by-chars
3685 (gnus-thread-header h1) (gnus-thread-header h2)))
3687 (defsubst gnus-article-sort-by-author (h1 h2)
3688 "Sort articles by root author."
3690 (let ((extract (funcall
3691 gnus-extract-address-components
3692 (mail-header-from h1))))
3693 (or (car extract) (cadr extract) ""))
3694 (let ((extract (funcall
3695 gnus-extract-address-components
3696 (mail-header-from h2))))
3697 (or (car extract) (cadr extract) ""))))
3699 (defun gnus-thread-sort-by-author (h1 h2)
3700 "Sort threads by root author."
3701 (gnus-article-sort-by-author
3702 (gnus-thread-header h1) (gnus-thread-header h2)))
3704 (defsubst gnus-article-sort-by-subject (h1 h2)
3705 "Sort articles by root subject."
3707 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3708 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3710 (defun gnus-thread-sort-by-subject (h1 h2)
3711 "Sort threads by root subject."
3712 (gnus-article-sort-by-subject
3713 (gnus-thread-header h1) (gnus-thread-header h2)))
3715 (defsubst gnus-article-sort-by-date (h1 h2)
3716 "Sort articles by root article date."
3718 (gnus-date-get-time (mail-header-date h1))
3719 (gnus-date-get-time (mail-header-date h2))))
3721 (defun gnus-thread-sort-by-date (h1 h2)
3722 "Sort threads by root article date."
3723 (gnus-article-sort-by-date
3724 (gnus-thread-header h1) (gnus-thread-header h2)))
3726 (defsubst gnus-article-sort-by-score (h1 h2)
3727 "Sort articles by root article score.
3728 Unscored articles will be counted as having a score of zero."
3729 (> (or (cdr (assq (mail-header-number h1)
3730 gnus-newsgroup-scored))
3731 gnus-summary-default-score 0)
3732 (or (cdr (assq (mail-header-number h2)
3733 gnus-newsgroup-scored))
3734 gnus-summary-default-score 0)))
3736 (defun gnus-thread-sort-by-score (h1 h2)
3737 "Sort threads by root article score."
3738 (gnus-article-sort-by-score
3739 (gnus-thread-header h1) (gnus-thread-header h2)))
3741 (defun gnus-thread-sort-by-total-score (h1 h2)
3742 "Sort threads by the sum of all scores in the thread.
3743 Unscored articles will be counted as having a score of zero."
3744 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3746 (defun gnus-thread-total-score (thread)
3747 ;; This function find the total score of THREAD.
3748 (cond ((null thread)
3751 (if (stringp (car thread))
3752 (apply gnus-thread-score-function 0
3753 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3754 (gnus-thread-total-score-1 thread)))
3756 (gnus-thread-total-score-1 (list thread)))))
3758 (defun gnus-thread-total-score-1 (root)
3759 ;; This function find the total score of the thread below ROOT.
3760 (setq root (car root))
3761 (apply gnus-thread-score-function
3763 (mapcar 'gnus-thread-total-score
3764 (cdr (gnus-id-to-thread (mail-header-id root))))
3765 (when (> (mail-header-number root) 0)
3766 (list (or (cdr (assq (mail-header-number root)
3767 gnus-newsgroup-scored))
3768 gnus-summary-default-score 0))))
3769 (list gnus-summary-default-score)
3772 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3773 (defvar gnus-tmp-prev-subject nil)
3774 (defvar gnus-tmp-false-parent nil)
3775 (defvar gnus-tmp-root-expunged nil)
3776 (defvar gnus-tmp-dummy-line nil)
3778 (defvar gnus-tmp-header)
3779 (defun gnus-extra-header (type &optional header)
3780 "Return the extra header of TYPE."
3781 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3784 (defun gnus-summary-prepare-threads (threads)
3785 "Prepare summary buffer from THREADS and indentation LEVEL.
3786 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3787 or a straight list of headers."
3788 (gnus-message 7 "Generating summary...")
3790 (setq gnus-newsgroup-threads threads)
3793 (let ((gnus-tmp-level 0)
3794 (default-score (or gnus-summary-default-score 0))
3795 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3796 thread number subject stack state gnus-tmp-gathered beg-match
3797 new-roots gnus-tmp-new-adopts thread-end
3798 gnus-tmp-header gnus-tmp-unread
3799 gnus-tmp-replied gnus-tmp-subject-or-nil
3800 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3801 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3802 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3804 (setq gnus-tmp-prev-subject nil)
3806 (if (vectorp (car threads))
3807 ;; If this is a straight (sic) list of headers, then a
3808 ;; threaded summary display isn't required, so we just create
3809 ;; an unthreaded one.
3810 (gnus-summary-prepare-unthreaded threads)
3812 ;; Do the threaded display.
3814 (while (or threads stack gnus-tmp-new-adopts new-roots)
3816 (if (and (= gnus-tmp-level 0)
3819 (not gnus-tmp-false-parent)
3820 (or gnus-tmp-new-adopts new-roots))
3821 (if gnus-tmp-new-adopts
3822 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3823 thread (list (car gnus-tmp-new-adopts))
3824 gnus-tmp-header (caar thread)
3825 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3827 (setq thread (list (car new-roots))
3828 gnus-tmp-header (caar thread)
3829 new-roots (cdr new-roots))))
3832 ;; If there are some threads, we do them before the
3833 ;; threads on the stack.
3834 (setq thread threads
3835 gnus-tmp-header (caar thread))
3836 ;; There were no current threads, so we pop something off
3838 (setq state (car stack)
3839 gnus-tmp-level (car state)
3842 gnus-tmp-header (caar thread))))
3844 (setq gnus-tmp-false-parent nil)
3845 (setq gnus-tmp-root-expunged nil)
3846 (setq thread-end nil)
3848 (if (stringp gnus-tmp-header)
3849 ;; The header is a dummy root.
3851 ((eq gnus-summary-make-false-root 'adopt)
3852 ;; We let the first article adopt the rest.
3853 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3855 (setq gnus-tmp-gathered
3857 (lambda (h) (mail-header-number (car h)))
3860 (setq thread (cons (list (caar thread)
3863 (setq gnus-tmp-level -1
3864 gnus-tmp-false-parent t))
3865 ((eq gnus-summary-make-false-root 'empty)
3866 ;; We print adopted articles with empty subject fields.
3867 (setq gnus-tmp-gathered
3869 (lambda (h) (mail-header-number (car h)))
3872 (setq gnus-tmp-level -1))
3873 ((eq gnus-summary-make-false-root 'dummy)
3874 ;; We remember that we probably want to output a dummy
3876 (setq gnus-tmp-dummy-line gnus-tmp-header)
3877 (setq gnus-tmp-prev-subject gnus-tmp-header))
3879 ;; We do not make a root for the gathered
3880 ;; sub-threads at all.
3881 (setq gnus-tmp-level -1)))
3883 (setq number (mail-header-number gnus-tmp-header)
3884 subject (mail-header-subject gnus-tmp-header))
3887 ;; If the thread has changed subject, we might want to make
3888 ;; this subthread into a root.
3889 ((and (null gnus-thread-ignore-subject)
3890 (not (zerop gnus-tmp-level))
3891 gnus-tmp-prev-subject
3893 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3894 (setq new-roots (nconc new-roots (list (car thread)))
3896 gnus-tmp-header nil))
3897 ;; If the article lies outside the current limit,
3898 ;; then we do not display it.
3899 ((not (memq number gnus-newsgroup-limit))
3900 (setq gnus-tmp-gathered
3902 (lambda (h) (mail-header-number (car h)))
3905 (setq gnus-tmp-new-adopts (if (cdar thread)
3906 (append gnus-tmp-new-adopts
3908 gnus-tmp-new-adopts)
3910 gnus-tmp-header nil)
3911 (when (zerop gnus-tmp-level)
3912 (setq gnus-tmp-root-expunged t)))
3913 ;; Perhaps this article is to be marked as read?
3914 ((and gnus-summary-mark-below
3915 (< (or (cdr (assq number gnus-newsgroup-scored))
3917 gnus-summary-mark-below)
3918 ;; Don't touch sparse articles.
3919 (not (gnus-summary-article-sparse-p number))
3920 (not (gnus-summary-article-ancient-p number)))
3921 (setq gnus-newsgroup-unreads
3922 (delq number gnus-newsgroup-unreads))
3923 (if gnus-newsgroup-auto-expire
3924 (push number gnus-newsgroup-expirable)
3925 (push (cons number gnus-low-score-mark)
3926 gnus-newsgroup-reads))))
3928 (when gnus-tmp-header
3929 ;; We may have an old dummy line to output before this
3931 (when (and gnus-tmp-dummy-line
3934 (mail-header-subject gnus-tmp-header)))
3935 (gnus-summary-insert-dummy-line
3936 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3937 (setq gnus-tmp-dummy-line nil))
3939 ;; Compute the mark.
3940 (setq gnus-tmp-unread (gnus-article-mark number))
3942 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3943 gnus-tmp-header gnus-tmp-level)
3944 gnus-newsgroup-data)
3946 ;; Actually insert the line.
3948 gnus-tmp-subject-or-nil
3950 ((and gnus-thread-ignore-subject
3951 gnus-tmp-prev-subject
3952 (not (inline (gnus-subject-equal
3953 gnus-tmp-prev-subject subject))))
3955 ((zerop gnus-tmp-level)
3956 (if (and (eq gnus-summary-make-false-root 'empty)
3957 (memq number gnus-tmp-gathered)
3958 gnus-tmp-prev-subject
3959 (inline (gnus-subject-equal
3960 gnus-tmp-prev-subject subject)))
3961 gnus-summary-same-subject
3963 (t gnus-summary-same-subject)))
3964 (if (and (eq gnus-summary-make-false-root 'adopt)
3965 (= gnus-tmp-level 1)
3966 (memq number gnus-tmp-gathered))
3967 (setq gnus-tmp-opening-bracket ?\<
3968 gnus-tmp-closing-bracket ?\>)
3969 (setq gnus-tmp-opening-bracket ?\[
3970 gnus-tmp-closing-bracket ?\]))
3972 gnus-tmp-indentation
3973 (aref gnus-thread-indent-array gnus-tmp-level)
3974 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3975 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3976 gnus-summary-default-score 0)
3978 (if (or (null gnus-summary-default-score)
3979 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3980 gnus-summary-zcore-fuzz))
3982 (if (< gnus-tmp-score gnus-summary-default-score)
3983 gnus-score-below-mark gnus-score-over-mark))
3985 (cond ((memq number gnus-newsgroup-processable)
3987 ((memq number gnus-newsgroup-cached)
3989 ((memq number gnus-newsgroup-replied)
3991 ((memq number gnus-newsgroup-saved)
3993 (t gnus-unread-mark))
3994 gnus-tmp-from (mail-header-from gnus-tmp-header)
3997 ((string-match "<[^>]+> *$" gnus-tmp-from)
3998 (setq beg-match (match-beginning 0))
3999 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4000 (substring gnus-tmp-from (1+ (match-beginning 0))
4001 (1- (match-end 0))))
4002 (substring gnus-tmp-from 0 beg-match)))
4003 ((string-match "(.+)" gnus-tmp-from)
4004 (substring gnus-tmp-from
4005 (1+ (match-beginning 0)) (1- (match-end 0))))
4007 (when (string= gnus-tmp-name "")
4008 (setq gnus-tmp-name gnus-tmp-from))
4009 (unless (numberp gnus-tmp-lines)
4010 (setq gnus-tmp-lines 0))
4011 (gnus-put-text-property
4013 (progn (eval gnus-summary-line-format-spec) (point))
4014 'gnus-number number)
4017 (gnus-run-hooks 'gnus-summary-update-hook)
4020 (setq gnus-tmp-prev-subject subject)))
4022 (when (nth 1 thread)
4023 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4024 (incf gnus-tmp-level)
4025 (setq threads (if thread-end nil (cdar thread)))
4027 (setq gnus-tmp-level 0)))))
4028 (gnus-message 7 "Generating summary...done"))
4030 (defun gnus-summary-prepare-unthreaded (headers)
4031 "Generate an unthreaded summary buffer based on HEADERS."
4032 (let (header number mark)
4037 ;; We may have to root out some bad articles...
4038 (when (memq (setq number (mail-header-number
4039 (setq header (pop headers))))
4040 gnus-newsgroup-limit)
4041 ;; Mark article as read when it has a low score.
4042 (when (and gnus-summary-mark-below
4043 (< (or (cdr (assq number gnus-newsgroup-scored))
4044 gnus-summary-default-score 0)
4045 gnus-summary-mark-below)
4046 (not (gnus-summary-article-ancient-p number)))
4047 (setq gnus-newsgroup-unreads
4048 (delq number gnus-newsgroup-unreads))
4049 (if gnus-newsgroup-auto-expire
4050 (push number gnus-newsgroup-expirable)
4051 (push (cons number gnus-low-score-mark)
4052 gnus-newsgroup-reads)))
4054 (setq mark (gnus-article-mark number))
4055 (push (gnus-data-make number mark (1+ (point)) header 0)
4056 gnus-newsgroup-data)
4057 (gnus-summary-insert-line
4059 mark (memq number gnus-newsgroup-replied)
4060 (memq number gnus-newsgroup-expirable)
4061 (mail-header-subject header) nil
4062 (cdr (assq number gnus-newsgroup-scored))
4063 (memq number gnus-newsgroup-processable))))))
4065 (defun gnus-summary-remove-list-identifiers ()
4066 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4067 (let ((regexp (if (stringp gnus-list-identifiers)
4068 gnus-list-identifiers
4069 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4070 (dolist (header gnus-newsgroup-headers)
4071 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4072 (mail-header-subject header))
4073 (mail-header-set-subject
4074 header (concat (substring (mail-header-subject header)
4075 0 (match-beginning 2))
4076 (substring (mail-header-subject header)
4077 (match-end 2))))))))
4079 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4080 "Select newsgroup GROUP.
4081 If READ-ALL is non-nil, all articles in the group are selected.
4082 If SELECT-ARTICLES, only select those articles from GROUP."
4083 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4084 ;;!!! Dirty hack; should be removed.
4085 (gnus-summary-ignore-duplicates
4086 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4088 gnus-summary-ignore-duplicates))
4089 (info (nth 2 entry))
4090 articles fetched-articles cached)
4092 (unless (gnus-check-server
4093 (setq gnus-current-select-method
4094 (gnus-find-method-for-group group)))
4095 (error "Couldn't open server"))
4097 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4098 (gnus-activate-group group) ; Or we can activate it...
4099 (progn ; Or we bug out.
4100 (when (equal major-mode 'gnus-summary-mode)
4101 (kill-buffer (current-buffer)))
4102 (error "Couldn't request group %s: %s"
4103 group (gnus-status-message group))))
4105 (unless (gnus-request-group group t)
4106 (when (equal major-mode 'gnus-summary-mode)
4107 (kill-buffer (current-buffer)))
4108 (error "Couldn't request group %s: %s"
4109 group (gnus-status-message group)))
4111 (setq gnus-newsgroup-name group)
4112 (setq gnus-newsgroup-unselected nil)
4113 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4114 (gnus-summary-setup-default-charset)
4116 ;; Adjust and set lists of article marks.
4118 (gnus-adjust-marked-articles info))
4120 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4121 (when (gnus-virtual-group-p group)
4122 (setq cached gnus-newsgroup-cached))
4124 (setq gnus-newsgroup-unreads
4125 (gnus-set-difference
4126 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4127 gnus-newsgroup-dormant))
4129 (setq gnus-newsgroup-processable nil)
4131 (gnus-update-read-articles group gnus-newsgroup-unreads)
4133 (if (setq articles select-articles)
4134 (setq gnus-newsgroup-unselected
4135 (gnus-sorted-intersection
4136 gnus-newsgroup-unreads
4137 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4138 (setq articles (gnus-articles-to-read group read-all)))
4142 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4144 ((eq articles 0) nil)
4146 ;; Init the dependencies hash table.
4147 (setq gnus-newsgroup-dependencies
4148 (gnus-make-hashtable (length articles)))
4149 (gnus-set-global-variables)
4150 ;; Retrieve the headers and read them in.
4151 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4152 (setq gnus-newsgroup-headers
4154 (setq gnus-headers-retrieved-by
4155 (gnus-retrieve-headers
4156 articles gnus-newsgroup-name
4157 ;; We might want to fetch old headers, but
4158 ;; not if there is only 1 article.
4160 (not (eq gnus-fetch-old-headers 'some))
4161 (not (numberp gnus-fetch-old-headers)))
4162 (> (length articles) 1))
4163 gnus-fetch-old-headers))))
4164 (gnus-get-newsgroup-headers-xover
4165 articles nil nil gnus-newsgroup-name t)
4166 (gnus-get-newsgroup-headers)))
4167 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4169 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4171 (setq gnus-newsgroup-cached cached))
4173 ;; Suppress duplicates?
4174 (when gnus-suppress-duplicates
4175 (gnus-dup-suppress-articles))
4177 ;; Set the initial limit.
4178 (setq gnus-newsgroup-limit (copy-sequence articles))
4179 ;; Remove canceled articles from the list of unread articles.
4180 (setq gnus-newsgroup-unreads
4181 (gnus-set-sorted-intersection
4182 gnus-newsgroup-unreads
4183 (setq fetched-articles
4184 (mapcar (lambda (headers) (mail-header-number headers))
4185 gnus-newsgroup-headers))))
4186 ;; Removed marked articles that do not exist.
4187 (gnus-update-missing-marks
4188 (gnus-sorted-complement fetched-articles articles))
4189 ;; We might want to build some more threads first.
4190 (when (and gnus-fetch-old-headers
4191 (eq gnus-headers-retrieved-by 'nov))
4192 (if (eq gnus-fetch-old-headers 'invisible)
4193 (gnus-build-all-threads)
4194 (gnus-build-old-threads)))
4195 ;; Let the Gnus agent mark articles as read.
4197 (gnus-agent-get-undownloaded-list))
4198 ;; Remove list identifiers from subject
4199 (when gnus-list-identifiers
4200 (gnus-summary-remove-list-identifiers))
4201 ;; Check whether auto-expire is to be done in this group.
4202 (setq gnus-newsgroup-auto-expire
4203 (gnus-group-auto-expirable-p group))
4204 ;; Set up the article buffer now, if necessary.
4205 (unless gnus-single-article-buffer
4206 (gnus-article-setup-buffer))
4207 ;; First and last article in this newsgroup.
4208 (when gnus-newsgroup-headers
4209 (setq gnus-newsgroup-begin
4210 (mail-header-number (car gnus-newsgroup-headers))
4213 (gnus-last-element gnus-newsgroup-headers))))
4214 ;; GROUP is successfully selected.
4215 (or gnus-newsgroup-headers t)))))
4217 (defun gnus-articles-to-read (group &optional read-all)
4218 ;; Find out what articles the user wants to read.
4220 ;; Select all articles if `read-all' is non-nil, or if there
4221 ;; are no unread articles.
4223 (and (zerop (length gnus-newsgroup-marked))
4224 (zerop (length gnus-newsgroup-unreads)))
4225 (eq (gnus-group-find-parameter group 'display)
4228 (gnus-uncompress-range (gnus-active group))
4229 (gnus-cache-articles-in-group group))
4230 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4231 (copy-sequence gnus-newsgroup-unreads))
4233 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4234 (scored (length scored-list))
4235 (number (length articles))
4236 (marked (+ (length gnus-newsgroup-marked)
4237 (length gnus-newsgroup-dormant)))
4245 ((and (or (<= scored marked) (= scored number))
4246 (numberp gnus-large-newsgroup)
4247 (> number gnus-large-newsgroup))
4251 "How many articles from %s (default %d): "
4252 (gnus-limit-string gnus-newsgroup-name 35)
4254 (if (string-match "^[ \t]*$" input) number input)))
4255 ((and (> scored marked) (< scored number)
4256 (> (- scored number) 20))
4259 (format "%s %s (%d scored, %d total): "
4260 "How many articles from"
4261 group scored number))))
4262 (if (string-match "^[ \t]*$" input)
4266 (setq select (if (stringp select) (string-to-number select) select))
4267 (if (or (null select) (zerop select))
4269 (if (and (not (zerop scored)) (<= (abs select) scored))
4271 (setq articles (sort scored-list '<))
4272 (setq number (length articles)))
4273 (setq articles (copy-sequence articles)))
4275 (when (< (abs select) number)
4277 ;; Select the N oldest articles.
4278 (setcdr (nthcdr (1- (abs select)) articles) nil)
4279 ;; Select the N most recent articles.
4280 (setq articles (nthcdr (- number select) articles))))
4281 (setq gnus-newsgroup-unselected
4282 (gnus-sorted-intersection
4283 gnus-newsgroup-unreads
4284 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4285 (when gnus-alter-articles-to-read-function
4286 (setq gnus-newsgroup-unreads
4288 (funcall gnus-alter-articles-to-read-function
4289 gnus-newsgroup-name gnus-newsgroup-unreads)
4293 (defun gnus-killed-articles (killed articles)
4296 (when (inline (gnus-member-of-range (car articles) killed))
4297 (push (car articles) out))
4298 (setq articles (cdr articles)))
4301 (defun gnus-uncompress-marks (marks)
4302 "Uncompress the mark ranges in MARKS."
4303 (let ((uncompressed '(score bookmark))
4306 (if (memq (caar marks) uncompressed)
4307 (push (car marks) out)
4308 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4309 (setq marks (cdr marks)))
4312 (defun gnus-adjust-marked-articles (info)
4313 "Set all article lists and remove all marks that are no longer valid."
4314 (let* ((marked-lists (gnus-info-marks info))
4315 (active (gnus-active (gnus-info-group info)))
4318 (types gnus-article-mark-lists)
4319 (uncompressed '(score bookmark killed))
4320 marks var articles article mark)
4323 (setq marks (pop marked-lists))
4324 (set (setq var (intern (format "gnus-newsgroup-%s"
4325 (car (rassq (setq mark (car marks))
4327 (if (memq (car marks) uncompressed) (cdr marks)
4328 (gnus-uncompress-range (cdr marks))))
4330 (setq articles (symbol-value var))
4332 ;; All articles have to be subsets of the active articles.
4334 ;; Adjust "simple" lists.
4335 ((memq mark '(tick dormant expire reply save))
4337 (when (or (< (setq article (pop articles)) min) (> article max))
4338 (set var (delq article (symbol-value var))))))
4340 ((memq mark uncompressed)
4341 (when (not (listp (cdr (symbol-value var))))
4342 (set var (list (symbol-value var))))
4343 (when (not (listp (cdr articles)))
4344 (setq articles (list articles)))
4346 (when (or (not (consp (setq article (pop articles))))
4347 (< (car article) min)
4348 (> (car article) max))
4349 (set var (delq article (symbol-value var))))))))))
4351 (defun gnus-update-missing-marks (missing)
4352 "Go through the list of MISSING articles and remove them from the mark lists."
4354 (let ((types gnus-article-mark-lists)
4356 ;; Go through all types.
4358 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4359 (when (symbol-value var)
4360 ;; This list has articles. So we delete all missing articles
4364 (set var (delq (pop m) (symbol-value var)))))))))
4366 (defun gnus-update-marks ()
4367 "Enter the various lists of marked articles into the newsgroup info list."
4368 (let ((types gnus-article-mark-lists)
4369 (info (gnus-get-info gnus-newsgroup-name))
4370 (uncompressed '(score bookmark killed))
4371 type list newmarked symbol delta-marks)
4373 ;; Add all marks lists to the list of marks lists.
4374 (while (setq type (pop types))
4375 (setq list (symbol-value
4377 (intern (format "gnus-newsgroup-%s"
4381 ;; Get rid of the entries of the articles that have the
4383 (when (and (eq (cdr type) 'score)
4387 (prev (cons nil list))
4390 (if (or (not (consp (car arts)))
4391 (= (cdar arts) gnus-summary-default-score))
4392 (setcdr prev (cdr arts))
4394 (setq arts (cdr arts)))
4395 (setq list (cdr all)))))
4397 (unless (memq (cdr type) uncompressed)
4398 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4400 (when (gnus-check-backend-function
4401 'request-set-mark gnus-newsgroup-name)
4402 ;; uncompressed:s are not proper flags (they are cons cells)
4403 ;; cache is a internal gnus flag
4404 (unless (memq (cdr type) (cons 'cache uncompressed))
4405 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4406 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4407 (add (gnus-remove-from-range
4408 (gnus-copy-sequence list) old)))
4410 (push (list add 'add (list (cdr type))) delta-marks))
4412 (push (list del 'del (list (cdr type))) delta-marks)))))
4415 (push (cons (cdr type) list) newmarked)))
4418 (unless (gnus-check-group gnus-newsgroup-name)
4419 (error "Can't open server for %s" gnus-newsgroup-name))
4420 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4422 ;; Enter these new marks into the info of the group.
4424 (setcar (nthcdr 3 info) newmarked)
4425 ;; Add the marks lists to the end of the info.
4427 (setcdr (nthcdr 2 info) (list newmarked))))
4429 ;; Cut off the end of the info if there's nothing else there.
4433 (when (nthcdr (decf i) info)
4434 (setcdr (nthcdr i info) nil)))))))
4436 (defun gnus-set-mode-line (where)
4437 "This function sets the mode line of the article or summary buffers.
4438 If WHERE is `summary', the summary mode line format will be used."
4439 ;; Is this mode line one we keep updated?
4440 (when (and (memq where gnus-updated-mode-lines)
4442 (intern (format "gnus-%s-mode-line-format-spec" where))))
4445 ;; We evaluate this in the summary buffer since these
4446 ;; variables are buffer-local to that buffer.
4447 (set-buffer gnus-summary-buffer)
4448 ;; We bind all these variables that are used in the `eval' form
4450 (let* ((mformat (symbol-value
4452 (format "gnus-%s-mode-line-format-spec" where))))
4453 (gnus-tmp-group-name gnus-newsgroup-name)
4454 (gnus-tmp-article-number (or gnus-current-article 0))
4455 (gnus-tmp-unread gnus-newsgroup-unreads)
4456 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4457 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4458 (gnus-tmp-unread-and-unselected
4459 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4460 (zerop gnus-tmp-unselected))
4462 ((zerop gnus-tmp-unselected)
4463 (format "{%d more}" gnus-tmp-unread-and-unticked))
4464 (t (format "{%d(+%d) more}"
4465 gnus-tmp-unread-and-unticked
4466 gnus-tmp-unselected))))
4468 (if (and gnus-current-headers
4469 (vectorp gnus-current-headers))
4470 (gnus-mode-string-quote
4471 (mail-header-subject gnus-current-headers))
4473 bufname-length max-len
4474 gnus-tmp-header);; passed as argument to any user-format-funcs
4475 (setq mode-string (eval mformat))
4476 (setq bufname-length (if (string-match "%b" mode-string)
4479 (if (eq where 'summary)
4481 (get-buffer gnus-article-buffer))))
4484 (setq max-len (max 4 (if gnus-mode-non-string-length
4486 gnus-mode-non-string-length
4488 (length mode-string))))
4489 ;; We might have to chop a bit of the string off...
4490 (when (> (length mode-string) max-len)
4492 (concat (truncate-string-to-width mode-string (- max-len 3))
4494 ;; Pad the mode string a bit.
4495 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4496 ;; Update the mode line.
4497 (setq mode-line-buffer-identification
4498 (gnus-mode-line-buffer-identification (list mode-string)))
4499 (set-buffer-modified-p t))))
4501 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4502 "Go through the HEADERS list and add all Xrefs to a hash table.
4503 The resulting hash table is returned, or nil if no Xrefs were found."
4504 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4505 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4506 (xref-hashtb (gnus-make-hashtable))
4507 start group entry number xrefs header)
4509 (setq header (pop headers))
4510 (when (and (setq xrefs (mail-header-xref header))
4511 (not (memq (setq number (mail-header-number header))
4514 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4515 (setq start (match-end 0))
4516 (setq group (if prefix
4517 (concat prefix (substring xrefs (match-beginning 1)
4519 (substring xrefs (match-beginning 1) (match-end 1))))
4521 (string-to-int (substring xrefs (match-beginning 2)
4523 (if (setq entry (gnus-gethash group xref-hashtb))
4524 (setcdr entry (cons number (cdr entry)))
4525 (gnus-sethash group (cons number nil) xref-hashtb)))))
4526 (and start xref-hashtb)))
4528 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4529 "Look through all the headers and mark the Xrefs as read."
4530 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4531 name entry info xref-hashtb idlist method nth4)
4533 (set-buffer gnus-group-buffer)
4534 (when (setq xref-hashtb
4535 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4538 (unless (string= from-newsgroup (setq name (symbol-name group)))
4539 (setq idlist (symbol-value group))
4540 ;; Dead groups are not updated.
4542 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4544 (when (stringp (setq nth4 (gnus-info-method info)))
4545 (setq nth4 (gnus-server-to-method nth4))))
4546 ;; Only do the xrefs if the group has the same
4547 ;; select method as the group we have just read.
4548 (or (gnus-methods-equal-p
4549 nth4 (gnus-find-method-for-group from-newsgroup))
4551 (equal nth4 (setq method (gnus-find-method-for-group
4553 (and (equal (car nth4) (car method))
4554 (equal (nth 1 nth4) (nth 1 method))))
4555 gnus-use-cross-reference
4556 (or (not (eq gnus-use-cross-reference t))
4558 ;; Only do cross-references on subscribed
4559 ;; groups, if that is what is wanted.
4560 (<= (gnus-info-level info) gnus-level-subscribed))
4561 (gnus-group-make-articles-read name idlist))))
4564 (defun gnus-compute-read-articles (group articles)
4565 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4566 (info (nth 2 entry))
4567 (active (gnus-active group))
4570 ;; First peel off all invalid article numbers.
4572 (let ((ids articles)
4574 (while (setq id (pop ids))
4575 (when (and first (> id (cdr active)))
4576 ;; We'll end up in this situation in one particular
4577 ;; obscure situation. If you re-scan a group and get
4578 ;; a new article that is cross-posted to a different
4579 ;; group that has not been re-scanned, you might get
4580 ;; crossposted article that has a higher number than
4581 ;; Gnus believes possible. So we re-activate this
4582 ;; group as well. This might mean doing the
4583 ;; crossposting thingy will *increase* the number
4584 ;; of articles in some groups. Tsk, tsk.
4585 (setq active (or (gnus-activate-group group) active)))
4586 (when (or (> id (cdr active))
4587 (< id (car active)))
4588 (setq articles (delq id articles))))))
4589 ;; If the read list is nil, we init it.
4591 (null (gnus-info-read info))
4593 (setq ninfo (cons 1 (1- (car active))))
4594 (setq ninfo (gnus-info-read info)))
4595 ;; Then we add the read articles to the range.
4597 ninfo (setq articles (sort articles '<))))))
4599 (defun gnus-group-make-articles-read (group articles)
4600 "Update the info of GROUP to say that ARTICLES are read."
4602 (entry (gnus-gethash group gnus-newsrc-hashtb))
4603 (info (nth 2 entry))
4604 (active (gnus-active group))
4607 (setq range (gnus-compute-read-articles group articles))
4609 (set-buffer gnus-group-buffer)
4612 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4613 (gnus-info-set-read ',info ',(gnus-info-read info))
4614 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4615 (gnus-group-update-group ,group t))))
4616 ;; Add the read articles to the range.
4617 (gnus-info-set-read info range)
4618 ;; Then we have to re-compute how many unread
4619 ;; articles there are in this group.
4623 (setq num (- (1+ (cdr active)) (car active))))
4624 ((not (listp (cdr range)))
4625 (setq num (- (cdr active) (- (1+ (cdr range))
4629 (if (numberp (car range))
4631 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4632 (setq range (cdr range)))
4633 (setq num (- (cdr active) num))))
4634 ;; Update the number of unread articles.
4636 ;; Update the group buffer.
4637 (gnus-group-update-group group t)))))
4639 (defvar gnus-newsgroup-none-id 0)
4641 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4642 (let ((cur nntp-server-buffer)
4645 (save-excursion (set-buffer gnus-summary-buffer)
4646 gnus-newsgroup-dependencies)))
4648 (mail-parse-charset gnus-newsgroup-charset)
4649 (mail-parse-ignored-charsets
4650 (save-excursion (condition-case nil
4651 (set-buffer gnus-summary-buffer)
4653 gnus-newsgroup-ignored-charsets)))
4655 (set-buffer nntp-server-buffer)
4656 ;; Translate all TAB characters into SPACE characters.
4657 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4658 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4659 (gnus-run-hooks 'gnus-parse-headers-hook)
4660 (let ((case-fold-search t)
4661 in-reply-to header p lines chars)
4662 (goto-char (point-min))
4663 ;; Search to the beginning of the next header. Error messages
4664 ;; do not begin with 2 or 3.
4665 (while (re-search-forward "^[23][0-9]+ " nil t)
4668 ;; This implementation of this function, with nine
4669 ;; search-forwards instead of the one re-search-forward and
4670 ;; a case (which basically was the old function) is actually
4671 ;; about twice as fast, even though it looks messier. You
4672 ;; can't have everything, I guess. Speed and elegance
4673 ;; doesn't always go hand in hand.
4682 (narrow-to-region (point)
4683 (or (and (search-forward "\n.\n" nil t)
4689 (if (search-forward "\nsubject: " nil t)
4690 (funcall gnus-decode-encoded-word-function
4691 (nnheader-header-value))
4696 (if (search-forward "\nfrom: " nil t)
4697 (funcall gnus-decode-encoded-word-function
4698 (nnheader-header-value))
4703 (if (search-forward "\ndate: " nil t)
4704 (nnheader-header-value) ""))
4708 (setq id (if (re-search-forward
4709 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4710 ;; We do it this way to make sure the Message-ID
4711 ;; is (somewhat) syntactically valid.
4712 (buffer-substring (match-beginning 1)
4714 ;; If there was no message-id, we just fake one
4715 ;; to make subsequent routines simpler.
4716 (nnheader-generate-fake-message-id))))
4720 (if (search-forward "\nreferences: " nil t)
4724 (nnheader-header-value)
4729 (search-backward ">" end t)
4732 (search-backward "<" end t)
4734 ;; Get the references from the in-reply-to header if there
4735 ;; were no references and the in-reply-to header looks
4737 (if (and (search-forward "\nin-reply-to: " nil t)
4738 (setq in-reply-to (nnheader-header-value))
4739 (string-match "<[^>]+>" in-reply-to))
4741 (setq ref (substring in-reply-to (match-beginning 0)
4743 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4744 (setq ref2 (substring in-reply-to (match-beginning 0)
4746 (when (> (length ref2) (length ref))
4753 (if (search-forward "\nchars: " nil t)
4754 (if (numberp (setq chars (ignore-errors (read cur))))
4760 (if (search-forward "\nlines: " nil t)
4761 (if (numberp (setq lines (ignore-errors (read cur))))
4767 (and (search-forward "\nxref: " nil t)
4768 (nnheader-header-value)))
4770 (when gnus-extra-headers
4771 (let ((extra gnus-extra-headers)
4775 (when (search-forward
4776 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4777 (push (cons (car extra) (nnheader-header-value))
4781 (when (equal id ref)
4784 (when gnus-alter-header-function
4785 (funcall gnus-alter-header-function header)
4786 (setq id (mail-header-id header)
4787 ref (gnus-parent-id (mail-header-references header))))
4790 (gnus-dependencies-add-header
4791 header dependencies force-new))
4792 (push header headers))
4793 (goto-char (point-max))
4795 (nreverse headers)))))
4797 ;; Goes through the xover lines and returns a list of vectors
4798 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4799 force-new dependencies
4800 group also-fetch-heads)
4801 "Parse the news overview data in the server buffer, and return a
4802 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4803 ;; Get the Xref when the users reads the articles since most/some
4804 ;; NNTP servers do not include Xrefs when using XOVER.
4805 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4806 (let ((mail-parse-charset gnus-newsgroup-charset)
4807 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4808 (cur nntp-server-buffer)
4809 (dependencies (or dependencies gnus-newsgroup-dependencies))
4810 number headers header)
4812 (set-buffer nntp-server-buffer)
4813 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4814 ;; Allow the user to mangle the headers before parsing them.
4815 (gnus-run-hooks 'gnus-parse-headers-hook)
4816 (goto-char (point-min))
4819 (while (and sequence (not (eobp)))
4820 (setq number (read cur))
4821 (while (and sequence
4822 (< (car sequence) number))
4823 (setq sequence (cdr sequence)))
4825 (eq number (car sequence))
4827 (setq sequence (cdr sequence))
4828 (setq header (inline
4829 (gnus-nov-parse-line
4830 number dependencies force-new))))
4831 (push header headers))
4834 (gnus-error 4 "Strange nov line (%d)"
4835 (count-lines (point-min) (point)))))
4837 ;; A common bug in inn is that if you have posted an article and
4838 ;; then retrieves the active file, it will answer correctly --
4839 ;; the new article is included. However, a NOV entry for the
4840 ;; article may not have been generated yet, so this may fail.
4841 ;; We work around this problem by retrieving the last few
4842 ;; headers using HEAD.
4843 (if (or (not also-fetch-heads)
4845 ;; We (probably) got all the headers.
4847 (let ((gnus-nov-is-evil t))
4850 (when (gnus-retrieve-headers sequence group)
4851 (gnus-get-newsgroup-headers))))))))
4853 (defun gnus-article-get-xrefs ()
4854 "Fill in the Xref value in `gnus-current-headers', if necessary.
4855 This is meant to be called in `gnus-article-internal-prepare-hook'."
4856 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4857 gnus-current-headers)))
4858 (or (not gnus-use-cross-reference)
4860 (and (mail-header-xref headers)
4861 (not (string= (mail-header-xref headers) "")))
4862 (let ((case-fold-search t)
4865 (nnheader-narrow-to-headers)
4866 (goto-char (point-min))
4867 (when (or (and (not (eobp))
4868 (eq (downcase (char-after)) ?x)
4869 (looking-at "Xref:"))
4870 (search-forward "\nXref:" nil t))
4871 (goto-char (1+ (match-end 0)))
4872 (setq xref (buffer-substring (point)
4873 (progn (end-of-line) (point))))
4874 (mail-header-set-xref headers xref)))))))
4876 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4877 "Find article ID and insert the summary line for that article.
4878 OLD-HEADER can either be a header or a line number to insert
4879 the subject line on."
4880 (let* ((line (and (numberp old-header) old-header))
4881 (old-header (and (vectorp old-header) old-header))
4882 (header (cond ((and old-header use-old-header)
4885 (gnus-number-to-header id))
4886 (gnus-number-to-header id))
4888 (gnus-read-header id))))
4889 (number (and (numberp id) id))
4892 ;; Rebuild the thread that this article is part of and go to the
4893 ;; article we have fetched.
4894 (when (and (not gnus-show-threads)
4897 (setq d (gnus-data-find (mail-header-number old-header))))
4898 (goto-char (gnus-data-pos d))
4901 (- (gnus-point-at-bol)
4903 (1+ (gnus-point-at-eol))
4904 (gnus-delete-line))))))
4906 (mail-header-set-number header (mail-header-number old-header)))
4907 (setq gnus-newsgroup-sparse
4908 (delq (setq number (mail-header-number header))
4909 gnus-newsgroup-sparse))
4910 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4911 (push number gnus-newsgroup-limit)
4912 (gnus-rebuild-thread (mail-header-id header) line)
4913 (gnus-summary-goto-subject number nil t))
4914 (when (and (numberp number)
4916 ;; We have to update the boundaries even if we can't fetch the
4917 ;; article if ID is a number -- so that the next `P' or `N'
4918 ;; command will fetch the previous (or next) article even
4919 ;; if the one we tried to fetch this time has been canceled.
4920 (when (> number gnus-newsgroup-end)
4921 (setq gnus-newsgroup-end number))
4922 (when (< number gnus-newsgroup-begin)
4923 (setq gnus-newsgroup-begin number))
4924 (setq gnus-newsgroup-unselected
4925 (delq number gnus-newsgroup-unselected)))
4926 ;; Report back a success?
4927 (and header (mail-header-number header))))
4929 ;;; Process/prefix in the summary buffer
4931 (defun gnus-summary-work-articles (n)
4932 "Return a list of articles to be worked upon.
4933 The prefix argument, the list of process marked articles, and the
4934 current article will be taken into consideration."
4936 (set-buffer gnus-summary-buffer)
4939 ;; A numerical prefix has been given.
4940 (setq n (prefix-numeric-value n))
4941 (let ((backward (< n 0))
4942 (n (abs (prefix-numeric-value n)))
4947 (push (setq article (gnus-summary-article-number))
4950 (gnus-summary-find-prev nil article)
4951 (gnus-summary-find-next nil article)))
4953 (nreverse articles)))
4954 ((and (gnus-region-active-p) (mark))
4955 (message "region active")
4956 ;; Work on the region between point and mark.
4957 (let ((max (max (point) (mark)))
4960 (goto-char (min (min (point) (mark))))
4963 (push (setq article (gnus-summary-article-number)) articles)
4964 (gnus-summary-find-next nil article)
4966 (nreverse articles))))
4967 (gnus-newsgroup-processable
4968 ;; There are process-marked articles present.
4969 ;; Save current state.
4970 (gnus-summary-save-process-mark)
4972 (reverse gnus-newsgroup-processable))
4974 ;; Just return the current article.
4975 (list (gnus-summary-article-number))))))
4977 (defmacro gnus-summary-iterate (arg &rest forms)
4978 "Iterate over the process/prefixed articles and do FORMS.
4979 ARG is the interactive prefix given to the command. FORMS will be
4980 executed with point over the summary line of the articles."
4981 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4982 `(let ((,articles (gnus-summary-work-articles ,arg)))
4984 (gnus-summary-goto-subject (car ,articles))
4988 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4989 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4991 (defun gnus-summary-save-process-mark ()
4992 "Push the current set of process marked articles on the stack."
4994 (push (copy-sequence gnus-newsgroup-processable)
4995 gnus-newsgroup-process-stack))
4997 (defun gnus-summary-kill-process-mark ()
4998 "Push the current set of process marked articles on the stack and unmark."
5000 (gnus-summary-save-process-mark)
5001 (gnus-summary-unmark-all-processable))
5003 (defun gnus-summary-yank-process-mark ()
5004 "Pop the last process mark state off the stack and restore it."
5006 (unless gnus-newsgroup-process-stack
5007 (error "Empty mark stack"))
5008 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5010 (defun gnus-summary-process-mark-set (set)
5011 "Make SET into the current process marked articles."
5012 (gnus-summary-unmark-all-processable)
5014 (gnus-summary-set-process-mark (pop set))))
5016 ;;; Searching and stuff
5018 (defun gnus-summary-search-group (&optional backward use-level)
5019 "Search for next unread newsgroup.
5020 If optional argument BACKWARD is non-nil, search backward instead."
5022 (set-buffer gnus-group-buffer)
5023 (when (gnus-group-search-forward
5024 backward nil (if use-level (gnus-group-group-level) nil))
5025 (gnus-group-group-name))))
5027 (defun gnus-summary-best-group (&optional exclude-group)
5028 "Find the name of the best unread group.
5029 If EXCLUDE-GROUP, do not go to this group."
5031 (set-buffer gnus-group-buffer)
5033 (gnus-group-best-unread-group exclude-group))))
5035 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5036 (if backward (gnus-summary-find-prev)
5037 (let* ((dummy (gnus-summary-article-intangible-p))
5038 (article (or article (gnus-summary-article-number)))
5039 (arts (gnus-data-find-list article))
5041 (when (and (not dummy)
5042 (or (not gnus-summary-check-current)
5044 (not (gnus-data-unread-p (car arts)))))
5045 (setq arts (cdr arts)))
5050 (when (or (and undownloaded
5051 (eq gnus-undownloaded-mark
5052 (gnus-data-mark (car arts))))
5053 (gnus-data-unread-p (car arts)))
5054 (setq result (car arts)
5056 (setq arts (cdr arts)))
5059 (goto-char (gnus-data-pos result))
5060 (gnus-data-number result)))))
5062 (defun gnus-summary-find-prev (&optional unread article)
5063 (let* ((eobp (eobp))
5064 (article (or article (gnus-summary-article-number)))
5065 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5067 (when (and (not eobp)
5068 (or (not gnus-summary-check-current)
5070 (not (gnus-data-unread-p (car arts)))))
5071 (setq arts (cdr arts)))
5076 (when (gnus-data-unread-p (car arts))
5077 (setq result (car arts)
5079 (setq arts (cdr arts)))
5082 (goto-char (gnus-data-pos result))
5083 (gnus-data-number result))))
5085 (defun gnus-summary-find-subject (subject &optional unread backward article)
5086 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5087 (article (or article (gnus-summary-article-number)))
5088 (articles (gnus-data-list backward))
5089 (arts (gnus-data-find-list article articles))
5091 (when (or (not gnus-summary-check-current)
5093 (not (gnus-data-unread-p (car arts))))
5094 (setq arts (cdr arts)))
5096 (and (or (not unread)
5097 (gnus-data-unread-p (car arts)))
5098 (vectorp (gnus-data-header (car arts)))
5100 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5101 (setq result (car arts)
5103 (setq arts (cdr arts)))
5105 (goto-char (gnus-data-pos result))
5106 (gnus-data-number result))))
5108 (defun gnus-summary-search-forward (&optional unread subject backward)
5109 "Search forward for an article.
5110 If UNREAD, look for unread articles. If SUBJECT, look for
5111 articles with that subject. If BACKWARD, search backward instead."
5112 (cond (subject (gnus-summary-find-subject subject unread backward))
5113 (backward (gnus-summary-find-prev unread))
5114 (t (gnus-summary-find-next unread))))
5116 (defun gnus-recenter (&optional n)
5117 "Center point in window and redisplay frame.
5118 Also do horizontal recentering."
5121 gnus-auto-center-summary
5122 (not (eq gnus-auto-center-summary 'vertical)))
5123 (gnus-horizontal-recenter))
5126 (defun gnus-summary-recenter ()
5127 "Center point in the summary window.
5128 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5129 displayed, no centering will be performed."
5130 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5131 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5133 (let* ((top (cond ((< (window-height) 4) 0)
5134 ((< (window-height) 7) 1)
5135 (t (if (numberp gnus-auto-center-summary)
5136 gnus-auto-center-summary
5138 (height (1- (window-height)))
5139 (bottom (save-excursion (goto-char (point-max))
5140 (forward-line (- height))
5142 (window (get-buffer-window (current-buffer))))
5143 ;; The user has to want it.
5144 (when gnus-auto-center-summary
5145 (when (get-buffer-window gnus-article-buffer)
5146 ;; Only do recentering when the article buffer is displayed,
5147 ;; Set the window start to either `bottom', which is the biggest
5148 ;; possible valid number, or the second line from the top,
5149 ;; whichever is the least.
5151 window (min bottom (save-excursion
5152 (forward-line (- top)) (point)))
5154 ;; Do horizontal recentering while we're at it.
5155 (when (and (get-buffer-window (current-buffer) t)
5156 (not (eq gnus-auto-center-summary 'vertical)))
5157 (let ((selected (selected-window)))
5158 (select-window (get-buffer-window (current-buffer) t))
5159 (gnus-summary-position-point)
5160 (gnus-horizontal-recenter)
5161 (select-window selected))))))
5163 (defun gnus-summary-jump-to-group (newsgroup)
5164 "Move point to NEWSGROUP in group mode buffer."
5165 ;; Keep update point of group mode buffer if visible.
5166 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5167 (save-window-excursion
5168 ;; Take care of tree window mode.
5169 (when (get-buffer-window gnus-group-buffer)
5170 (pop-to-buffer gnus-group-buffer))
5171 (gnus-group-jump-to-group newsgroup))
5173 ;; Take care of tree window mode.
5174 (if (get-buffer-window gnus-group-buffer)
5175 (pop-to-buffer gnus-group-buffer)
5176 (set-buffer gnus-group-buffer))
5177 (gnus-group-jump-to-group newsgroup))))
5179 ;; This function returns a list of article numbers based on the
5180 ;; difference between the ranges of read articles in this group and
5181 ;; the range of active articles.
5182 (defun gnus-list-of-unread-articles (group)
5183 (let* ((read (gnus-info-read (gnus-get-info group)))
5184 (active (or (gnus-active group) (gnus-activate-group group)))
5187 ;; If none are read, then all are unread.
5189 (setq first (car active))
5190 ;; If the range of read articles is a single range, then the
5191 ;; first unread article is the article after the last read
5192 ;; article. Sounds logical, doesn't it?
5193 (if (and (not (listp (cdr read)))
5194 (or (< (car read) (car active))
5195 (progn (setq read (list read))
5197 (setq first (max (car active) (1+ (cdr read))))
5198 ;; `read' is a list of ranges.
5199 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5202 (setq first (car active)))
5205 (while (< first nlast)
5207 (setq first (1+ first))))
5208 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5209 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5210 (setq read (cdr read)))))
5211 ;; And add the last unread articles.
5212 (while (<= first last)
5214 (setq first (1+ first)))
5215 ;; Return the list of unread articles.
5216 (delq 0 (nreverse unread))))
5218 (defun gnus-list-of-read-articles (group)
5219 "Return a list of unread, unticked and non-dormant articles."
5220 (let* ((info (gnus-get-info group))
5221 (marked (gnus-info-marks info))
5222 (active (gnus-active group)))
5224 (gnus-set-difference
5225 (gnus-sorted-complement
5226 (gnus-uncompress-range active)
5227 (gnus-list-of-unread-articles group))
5229 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5230 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5232 ;; Various summary commands
5234 (defun gnus-summary-select-article-buffer ()
5235 "Reconfigure windows to show article buffer."
5237 (if (not (gnus-buffer-live-p gnus-article-buffer))
5238 (error "There is no article buffer for this summary buffer")
5239 (gnus-configure-windows 'article)
5240 (select-window (get-buffer-window gnus-article-buffer))))
5242 (defun gnus-summary-universal-argument (arg)
5243 "Perform any operation on all articles that are process/prefixed."
5245 (let ((articles (gnus-summary-work-articles arg))
5252 (substitute-command-keys
5253 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5255 (gnus-error 1 "Undefined key")
5258 (gnus-summary-goto-subject (setq article (pop articles)))
5259 (let (gnus-newsgroup-processable)
5260 (command-execute func))
5261 (gnus-summary-remove-process-mark article)))))
5262 (gnus-summary-position-point))
5264 (defun gnus-summary-toggle-truncation (&optional arg)
5265 "Toggle truncation of summary lines.
5266 With arg, turn line truncation on iff arg is positive."
5268 (setq truncate-lines
5269 (if (null arg) (not truncate-lines)
5270 (> (prefix-numeric-value arg) 0)))
5273 (defun gnus-summary-reselect-current-group (&optional all rescan)
5274 "Exit and then reselect the current newsgroup.
5275 The prefix argument ALL means to select all articles."
5277 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5278 (error "Ephemeral groups can't be reselected"))
5279 (let ((current-subject (gnus-summary-article-number))
5280 (group gnus-newsgroup-name))
5281 (setq gnus-newsgroup-begin nil)
5283 ;; We have to adjust the point of group mode buffer because
5284 ;; point was moved to the next unread newsgroup by exiting.
5285 (gnus-summary-jump-to-group group)
5288 (gnus-group-get-new-news-this-group 1)))
5289 (gnus-group-read-group all t)
5290 (gnus-summary-goto-subject current-subject nil t)))
5292 (defun gnus-summary-rescan-group (&optional all)
5293 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5295 (gnus-summary-reselect-current-group all t))
5297 (defun gnus-summary-update-info (&optional non-destructive)
5299 (let ((group gnus-newsgroup-name))
5301 (when gnus-newsgroup-kill-headers
5302 (setq gnus-newsgroup-killed
5303 (gnus-compress-sequence
5305 (gnus-set-sorted-intersection
5306 (gnus-uncompress-range gnus-newsgroup-killed)
5307 (setq gnus-newsgroup-unselected
5308 (sort gnus-newsgroup-unselected '<)))
5309 (setq gnus-newsgroup-unreads
5310 (sort gnus-newsgroup-unreads '<)))
5312 (unless (listp (cdr gnus-newsgroup-killed))
5313 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5314 (let ((headers gnus-newsgroup-headers))
5315 ;; Set the new ranges of read articles.
5317 (set-buffer gnus-group-buffer)
5318 (gnus-undo-force-boundary))
5319 (gnus-update-read-articles
5320 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5321 ;; Set the current article marks.
5322 (let ((gnus-newsgroup-scored
5323 (if (and (not gnus-save-score)
5324 (not non-destructive))
5326 gnus-newsgroup-scored)))
5328 (gnus-update-marks)))
5329 ;; Do the cross-ref thing.
5330 (when gnus-use-cross-reference
5331 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5332 ;; Do not switch windows but change the buffer to work.
5333 (set-buffer gnus-group-buffer)
5334 (unless (gnus-ephemeral-group-p group)
5335 (gnus-group-update-group group)))))))
5337 (defun gnus-summary-save-newsrc (&optional force)
5338 "Save the current number of read/marked articles in the dribble buffer.
5339 The dribble buffer will then be saved.
5340 If FORCE (the prefix), also save the .newsrc file(s)."
5342 (gnus-summary-update-info t)
5344 (gnus-save-newsrc-file)
5345 (gnus-dribble-save)))
5347 (defun gnus-summary-exit (&optional temporary)
5348 "Exit reading current newsgroup, and then return to group selection mode.
5349 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5351 (gnus-set-global-variables)
5352 (when (gnus-buffer-live-p gnus-article-buffer)
5354 (set-buffer gnus-article-buffer)
5355 (mm-destroy-parts gnus-article-mime-handles)))
5356 (gnus-kill-save-kill-buffer)
5357 (gnus-async-halt-prefetch)
5358 (let* ((group gnus-newsgroup-name)
5359 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5362 (buf (current-buffer)))
5364 ;; Do adaptive scoring, and possibly save score files.
5365 (when gnus-newsgroup-adaptive
5366 (gnus-score-adaptive))
5367 (when gnus-use-scoring
5369 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5370 ;; If we have several article buffers, we kill them at exit.
5371 (unless gnus-single-article-buffer
5372 (gnus-kill-buffer gnus-original-article-buffer)
5373 (setq gnus-article-current nil))
5374 (when gnus-use-cache
5375 (gnus-cache-possibly-remove-articles)
5376 (gnus-cache-save-buffers))
5377 (gnus-async-prefetch-remove-group group)
5378 (when gnus-suppress-duplicates
5379 (gnus-dup-enter-articles))
5380 (when gnus-use-trees
5381 (gnus-tree-close group))
5382 (when gnus-use-cache
5383 (gnus-cache-write-active))
5384 ;; Remove entries for this group.
5385 (nnmail-purge-split-history (gnus-group-real-name group))
5386 ;; Make all changes in this group permanent.
5388 (gnus-run-hooks 'gnus-exit-group-hook)
5389 (gnus-summary-update-info))
5390 (gnus-close-group group)
5391 ;; Make sure where we were, and go to next newsgroup.
5392 (set-buffer gnus-group-buffer)
5394 (gnus-group-jump-to-group group))
5395 (gnus-run-hooks 'gnus-summary-exit-hook)
5396 (unless (or quit-config
5397 ;; If this group has disappeared from the summary
5398 ;; buffer, don't skip forwards.
5399 (not (string= group (gnus-group-group-name))))
5400 (gnus-group-next-unread-group 1))
5401 (setq group-point (point))
5404 ;; If we have several article buffers, we kill them at exit.
5405 (unless gnus-single-article-buffer
5406 (gnus-kill-buffer gnus-article-buffer)
5407 (gnus-kill-buffer gnus-original-article-buffer)
5408 (setq gnus-article-current nil))
5410 (if (not gnus-kill-summary-on-exit)
5411 (gnus-deaden-summary)
5412 ;; We set all buffer-local variables to nil. It is unclear why
5413 ;; this is needed, but if we don't, buffer-local variables are
5414 ;; not garbage-collected, it seems. This would the lead to en
5415 ;; ever-growing Emacs.
5416 (gnus-summary-clear-local-variables)
5417 (when (get-buffer gnus-article-buffer)
5418 (bury-buffer gnus-article-buffer))
5419 ;; We clear the global counterparts of the buffer-local
5420 ;; variables as well, just to be on the safe side.
5421 (set-buffer gnus-group-buffer)
5422 (gnus-summary-clear-local-variables)
5423 ;; Return to group mode buffer.
5424 (when (eq mode 'gnus-summary-mode)
5425 (gnus-kill-buffer buf)))
5426 (setq gnus-current-select-method gnus-select-method)
5427 (pop-to-buffer gnus-group-buffer)
5428 (if (not quit-config)
5430 (goto-char group-point)
5431 (gnus-configure-windows 'group 'force))
5432 (gnus-handle-ephemeral-exit quit-config))
5433 ;; Clear the current group name.
5435 (setq gnus-newsgroup-name nil)))))
5437 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5438 (defun gnus-summary-exit-no-update (&optional no-questions)
5439 "Quit reading current newsgroup without updating read article info."
5441 (let* ((group gnus-newsgroup-name)
5442 (quit-config (gnus-group-quit-config group)))
5443 (when (or no-questions
5445 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5446 (gnus-async-halt-prefetch)
5448 (delq 'gnus-summary-expire-articles
5449 (copy-sequence gnus-summary-prepare-exit-hook)))
5450 (when (gnus-buffer-live-p gnus-article-buffer)
5452 (set-buffer gnus-article-buffer)
5453 (mm-destroy-parts gnus-article-mime-handles)))
5454 ;; If we have several article buffers, we kill them at exit.
5455 (unless gnus-single-article-buffer
5456 (gnus-kill-buffer gnus-article-buffer)
5457 (gnus-kill-buffer gnus-original-article-buffer)
5458 (setq gnus-article-current nil))
5459 (if (not gnus-kill-summary-on-exit)
5460 (gnus-deaden-summary)
5461 (gnus-close-group group)
5462 (gnus-summary-clear-local-variables)
5463 (set-buffer gnus-group-buffer)
5464 (gnus-summary-clear-local-variables)
5465 (when (get-buffer gnus-summary-buffer)
5466 (kill-buffer gnus-summary-buffer)))
5467 (unless gnus-single-article-buffer
5468 (setq gnus-article-current nil))
5469 (when gnus-use-trees
5470 (gnus-tree-close group))
5471 (gnus-async-prefetch-remove-group group)
5472 (when (get-buffer gnus-article-buffer)
5473 (bury-buffer gnus-article-buffer))
5474 ;; Return to the group buffer.
5475 (gnus-configure-windows 'group 'force)
5476 ;; Clear the current group name.
5477 (setq gnus-newsgroup-name nil)
5478 (when (equal (gnus-group-group-name) group)
5479 (gnus-group-next-unread-group 1))
5481 (gnus-handle-ephemeral-exit quit-config)))))
5483 (defun gnus-handle-ephemeral-exit (quit-config)
5484 "Handle movement when leaving an ephemeral group.
5485 The state which existed when entering the ephemeral is reset."
5486 (if (not (buffer-name (car quit-config)))
5487 (gnus-configure-windows 'group 'force)
5488 (set-buffer (car quit-config))
5489 (cond ((eq major-mode 'gnus-summary-mode)
5490 (gnus-set-global-variables))
5491 ((eq major-mode 'gnus-article-mode)
5493 ;; The `gnus-summary-buffer' variable may point
5494 ;; to the old summary buffer when using a single
5496 (unless (gnus-buffer-live-p gnus-summary-buffer)
5497 (set-buffer gnus-group-buffer))
5498 (set-buffer gnus-summary-buffer)
5499 (gnus-set-global-variables))))
5500 (if (or (eq (cdr quit-config) 'article)
5501 (eq (cdr quit-config) 'pick))
5503 ;; The current article may be from the ephemeral group
5504 ;; thus it is best that we reload this article
5505 (gnus-summary-show-article)
5506 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5507 (gnus-configure-windows 'pick 'force)
5508 (gnus-configure-windows (cdr quit-config) 'force)))
5509 (gnus-configure-windows (cdr quit-config) 'force))
5510 (when (eq major-mode 'gnus-summary-mode)
5511 (gnus-summary-next-subject 1 nil t)
5512 (gnus-summary-recenter)
5513 (gnus-summary-position-point))))
5517 (defvar gnus-dead-summary-mode-map nil)
5519 (unless gnus-dead-summary-mode-map
5520 (setq gnus-dead-summary-mode-map (make-keymap))
5521 (suppress-keymap gnus-dead-summary-mode-map)
5522 (substitute-key-definition
5523 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5524 (let ((keys '("\C-d" "\r" "\177" [delete])))
5526 (define-key gnus-dead-summary-mode-map
5527 (pop keys) 'gnus-summary-wake-up-the-dead))))
5529 (defvar gnus-dead-summary-mode nil
5530 "Minor mode for Gnus summary buffers.")
5532 (defun gnus-dead-summary-mode (&optional arg)
5533 "Minor mode for Gnus summary buffers."
5535 (when (eq major-mode 'gnus-summary-mode)
5536 (make-local-variable 'gnus-dead-summary-mode)
5537 (setq gnus-dead-summary-mode
5538 (if (null arg) (not gnus-dead-summary-mode)
5539 (> (prefix-numeric-value arg) 0)))
5540 (when gnus-dead-summary-mode
5541 (gnus-add-minor-mode
5542 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5544 (defun gnus-deaden-summary ()
5545 "Make the current summary buffer into a dead summary buffer."
5546 ;; Kill any previous dead summary buffer.
5547 (when (and gnus-dead-summary
5548 (buffer-name gnus-dead-summary))
5550 (set-buffer gnus-dead-summary)
5551 (when gnus-dead-summary-mode
5552 (kill-buffer (current-buffer)))))
5553 ;; Make this the current dead summary.
5554 (setq gnus-dead-summary (current-buffer))
5555 (gnus-dead-summary-mode 1)
5556 (let ((name (buffer-name)))
5557 (when (string-match "Summary" name)
5559 (concat (substring name 0 (match-beginning 0)) "Dead "
5560 (substring name (match-beginning 0)))
5564 (defun gnus-kill-or-deaden-summary (buffer)
5565 "Kill or deaden the summary BUFFER."
5567 (when (and (buffer-name buffer)
5568 (not gnus-single-article-buffer))
5571 (gnus-kill-buffer gnus-article-buffer)
5572 (gnus-kill-buffer gnus-original-article-buffer)))
5573 (cond (gnus-kill-summary-on-exit
5574 (when (and gnus-use-trees
5575 (gnus-buffer-exists-p buffer))
5578 (gnus-tree-close gnus-newsgroup-name)))
5579 (gnus-kill-buffer buffer))
5580 ((gnus-buffer-exists-p buffer)
5583 (gnus-deaden-summary))))))
5585 (defun gnus-summary-wake-up-the-dead (&rest args)
5586 "Wake up the dead summary buffer."
5588 (gnus-dead-summary-mode -1)
5589 (let ((name (buffer-name)))
5590 (when (string-match "Dead " name)
5592 (concat (substring name 0 (match-beginning 0))
5593 (substring name (match-end 0)))
5595 (gnus-message 3 "This dead summary is now alive again"))
5597 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5598 (defun gnus-summary-fetch-faq (&optional faq-dir)
5599 "Fetch the FAQ for the current group.
5600 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5604 (when current-prefix-arg
5606 "Faq dir: " (and (listp gnus-group-faq-directory)
5607 (mapcar (lambda (file) (list file))
5608 gnus-group-faq-directory))))))
5609 (let (gnus-faq-buffer)
5610 (when (setq gnus-faq-buffer
5611 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5612 (gnus-configure-windows 'summary-faq))))
5614 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5615 (defun gnus-summary-describe-group (&optional force)
5616 "Describe the current newsgroup."
5618 (gnus-group-describe-group force gnus-newsgroup-name))
5620 (defun gnus-summary-describe-briefly ()
5621 "Describe summary mode commands briefly."
5623 (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")))
5625 ;; Walking around group mode buffer from summary mode.
5627 (defun gnus-summary-next-group (&optional no-article target-group backward)
5628 "Exit current newsgroup and then select next unread newsgroup.
5629 If prefix argument NO-ARTICLE is non-nil, no article is selected
5630 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5631 previous group instead."
5633 ;; Stop pre-fetching.
5634 (gnus-async-halt-prefetch)
5635 (let ((current-group gnus-newsgroup-name)
5636 (current-buffer (current-buffer))
5638 ;; First we semi-exit this group to update Xrefs and all variables.
5639 ;; We can't do a real exit, because the window conf must remain
5640 ;; the same in case the user is prompted for info, and we don't
5641 ;; want the window conf to change before that...
5642 (gnus-summary-exit t)
5643 (while (not entered)
5644 ;; Then we find what group we are supposed to enter.
5645 (set-buffer gnus-group-buffer)
5646 (gnus-group-jump-to-group current-group)
5649 (if (eq gnus-keep-same-level 'best)
5650 (gnus-summary-best-group gnus-newsgroup-name)
5651 (gnus-summary-search-group backward gnus-keep-same-level))))
5652 (if (not target-group)
5653 ;; There are no further groups, so we return to the group
5656 (gnus-message 5 "Returning to the group buffer")
5658 (when (gnus-buffer-live-p current-buffer)
5659 (set-buffer current-buffer)
5660 (gnus-summary-exit))
5661 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5662 ;; We try to enter the target group.
5663 (gnus-group-jump-to-group target-group)
5664 (let ((unreads (gnus-group-group-unread)))
5665 (if (and (or (eq t unreads)
5666 (and unreads (not (zerop unreads))))
5667 (gnus-summary-read-group
5668 target-group nil no-article
5669 (and (buffer-name current-buffer) current-buffer)
5672 (setq current-group target-group
5673 target-group nil)))))))
5675 (defun gnus-summary-prev-group (&optional no-article)
5676 "Exit current newsgroup and then select previous unread newsgroup.
5677 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5679 (gnus-summary-next-group no-article nil t))
5681 ;; Walking around summary lines.
5683 (defun gnus-summary-first-subject (&optional unread undownloaded)
5684 "Go to the first unread subject.
5685 If UNREAD is non-nil, go to the first unread article.
5686 Returns the article selected or nil if there are no unread articles."
5691 ((null gnus-newsgroup-data)
5692 (gnus-message 3 "No articles in the group")
5694 ;; Pick the first article.
5696 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5697 (gnus-data-number (car gnus-newsgroup-data)))
5698 ;; No unread articles.
5699 ((null gnus-newsgroup-unreads)
5700 (gnus-message 3 "No more unread articles")
5702 ;; Find the first unread article.
5704 (let ((data gnus-newsgroup-data))
5706 (and (not (and undownloaded
5707 (eq gnus-undownloaded-mark
5708 (gnus-data-mark (car data)))))
5709 (not (gnus-data-unread-p (car data)))))
5710 (setq data (cdr data)))
5712 (goto-char (gnus-data-pos (car data)))
5713 (gnus-data-number (car data))))))
5714 (gnus-summary-position-point)))
5716 (defun gnus-summary-next-subject (n &optional unread dont-display)
5717 "Go to next N'th summary line.
5718 If N is negative, go to the previous N'th subject line.
5719 If UNREAD is non-nil, only unread articles are selected.
5720 The difference between N and the actual number of steps taken is
5723 (let ((backward (< n 0))
5727 (gnus-summary-find-prev unread)
5728 (gnus-summary-find-next unread)))
5729 (unless (zerop (setq n (1- n)))
5730 (gnus-summary-show-thread)))
5732 (gnus-message 7 "No more%s articles"
5733 (if unread " unread" "")))
5734 (unless dont-display
5735 (gnus-summary-recenter)
5736 (gnus-summary-position-point))
5739 (defun gnus-summary-next-unread-subject (n)
5740 "Go to next N'th unread summary line."
5742 (gnus-summary-next-subject n t))
5744 (defun gnus-summary-prev-subject (n &optional unread)
5745 "Go to previous N'th summary line.
5746 If optional argument UNREAD is non-nil, only unread article is selected."
5748 (gnus-summary-next-subject (- n) unread))
5750 (defun gnus-summary-prev-unread-subject (n)
5751 "Go to previous N'th unread summary line."
5753 (gnus-summary-next-subject (- n) t))
5755 (defun gnus-summary-goto-subject (article &optional force silent)
5756 "Go the subject line of ARTICLE.
5757 If FORCE, also allow jumping to articles not currently shown."
5758 (interactive "nArticle number: ")
5760 (data (gnus-data-find article)))
5761 ;; We read in the article if we have to.
5764 (gnus-summary-insert-subject
5766 (if (or (numberp force) (vectorp force)) force)
5768 (setq data (gnus-data-find article)))
5773 (gnus-message 3 "Can't find article %d" article))
5775 (goto-char (gnus-data-pos data))
5776 (gnus-summary-position-point)
5779 ;; Walking around summary lines with displaying articles.
5781 (defun gnus-summary-expand-window (&optional arg)
5782 "Make the summary buffer take up the entire Emacs frame.
5783 Given a prefix, will force an `article' buffer configuration."
5786 (gnus-configure-windows 'article 'force)
5787 (gnus-configure-windows 'summary 'force)))
5789 (defun gnus-summary-display-article (article &optional all-header)
5790 "Display ARTICLE in article buffer."
5791 (gnus-set-global-variables)
5795 (if gnus-summary-display-article-function
5796 (funcall gnus-summary-display-article-function article all-header)
5797 (gnus-article-prepare article all-header))
5798 (gnus-run-hooks 'gnus-select-article-hook)
5799 (when (and gnus-current-article
5800 (not (zerop gnus-current-article)))
5801 (gnus-summary-goto-subject gnus-current-article))
5802 (gnus-summary-recenter)
5803 (when (and gnus-use-trees gnus-show-threads)
5804 (gnus-possibly-generate-tree article)
5805 (gnus-highlight-selected-tree article))
5806 ;; Successfully display article.
5807 (gnus-article-set-window-start
5808 (cdr (assq article gnus-newsgroup-bookmarks))))))
5810 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5811 "Select the current article.
5812 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5813 non-nil, the article will be re-fetched even if it already present in
5814 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5816 ;; Make sure we are in the summary buffer to work around bbdb bug.
5817 (unless (eq major-mode 'gnus-summary-mode)
5818 (set-buffer gnus-summary-buffer))
5819 (let ((article (or article (gnus-summary-article-number)))
5820 (all-headers (not (not all-headers))) ;Must be T or NIL.
5821 gnus-summary-display-article-function)
5823 (gnus-summary-article-pseudo-p article)
5824 (error "This is a pseudo-article"))
5826 (set-buffer gnus-summary-buffer)
5827 (if (or (and gnus-single-article-buffer
5828 (or (null gnus-current-article)
5829 (null gnus-article-current)
5830 (null (get-buffer gnus-article-buffer))
5831 (not (eq article (cdr gnus-article-current)))
5832 (not (equal (car gnus-article-current)
5833 gnus-newsgroup-name))))
5834 (and (not gnus-single-article-buffer)
5835 (or (null gnus-current-article)
5836 (not (eq gnus-current-article article))))
5838 ;; The requested article is different from the current article.
5840 (gnus-summary-display-article article all-headers)
5841 (when (or all-headers gnus-show-all-headers)
5842 (gnus-article-show-all-headers))
5843 (gnus-article-set-window-start
5844 (cdr (assq article gnus-newsgroup-bookmarks)))
5846 (when (or all-headers gnus-show-all-headers)
5847 (gnus-article-show-all-headers))
5850 (defun gnus-summary-set-current-mark (&optional current-mark)
5851 "Obsolete function."
5854 (defun gnus-summary-next-article (&optional unread subject backward push)
5855 "Select the next article.
5856 If UNREAD, only unread articles are selected.
5857 If SUBJECT, only articles with SUBJECT are selected.
5858 If BACKWARD, the previous article is selected instead of the next."
5861 ;; Is there such an article?
5862 ((and (gnus-summary-search-forward unread subject backward)
5863 (or (gnus-summary-display-article (gnus-summary-article-number))
5864 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5865 (gnus-summary-position-point))
5866 ;; If not, we try the first unread, if that is wanted.
5868 gnus-auto-select-same
5869 (gnus-summary-first-unread-article))
5870 (gnus-summary-position-point)
5871 (gnus-message 6 "Wrapped"))
5872 ;; Try to get next/previous article not displayed in this group.
5873 ((and gnus-auto-extend-newsgroup
5874 (not unread) (not subject))
5875 (gnus-summary-goto-article
5876 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5877 nil (count-lines (point-min) (point))))
5878 ;; Go to next/previous group.
5880 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5881 (gnus-summary-jump-to-group gnus-newsgroup-name))
5882 (let ((cmd last-command-char)
5885 (set-buffer gnus-group-buffer)
5888 (if (eq gnus-keep-same-level 'best)
5889 (gnus-summary-best-group gnus-newsgroup-name)
5890 (gnus-summary-search-group backward gnus-keep-same-level))))
5891 ;; For some reason, the group window gets selected. We change
5893 (select-window (get-buffer-window (current-buffer)))
5894 ;; Select next unread newsgroup automagically.
5896 ((or (not gnus-auto-select-next)
5898 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5899 ((or (eq gnus-auto-select-next 'quietly)
5900 (and (eq gnus-auto-select-next 'slightly-quietly)
5902 (and (eq gnus-auto-select-next 'almost-quietly)
5903 (gnus-summary-last-article-p)))
5905 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5907 (gnus-message 7 "No more%s articles (%s)..."
5908 (if unread " unread" "")
5909 (if group (concat "selecting " group)
5911 (gnus-summary-next-group nil group backward)))
5913 (when (gnus-key-press-event-p last-input-event)
5914 (gnus-summary-walk-group-buffer
5915 gnus-newsgroup-name cmd unread backward point))))))))
5917 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5918 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5919 (?\C-p (gnus-group-prev-unread-group 1))))
5920 (cursor-in-echo-area t)
5921 keve key group ended)
5923 (set-buffer gnus-group-buffer)
5926 (if (eq gnus-keep-same-level 'best)
5927 (gnus-summary-best-group gnus-newsgroup-name)
5928 (gnus-summary-search-group backward gnus-keep-same-level))))
5931 5 "No more%s articles%s" (if unread " unread" "")
5933 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5934 (format " (Type %s for %s [%s])"
5935 (single-key-description cmd) group
5936 (car (gnus-gethash group gnus-newsrc-hashtb)))
5937 (format " (Type %s to exit %s)"
5938 (single-key-description cmd)
5939 gnus-newsgroup-name)))
5940 ;; Confirm auto selection.
5941 (setq key (car (setq keve (gnus-read-event-char))))
5944 ((assq key keystrokes)
5945 (let ((obuf (current-buffer)))
5946 (switch-to-buffer gnus-group-buffer)
5948 (gnus-group-jump-to-group group))
5949 (eval (cadr (assq key keystrokes)))
5950 (setq group (gnus-group-group-name))
5951 (switch-to-buffer obuf))
5955 (gnus-ephemeral-group-p gnus-newsgroup-name))
5957 (gnus-summary-next-group nil group backward)))
5959 (push (cdr keve) unread-command-events))))))
5961 (defun gnus-summary-next-unread-article ()
5962 "Select unread article after current one."
5964 (gnus-summary-next-article
5965 (or (not (eq gnus-summary-goto-unread 'never))
5966 (gnus-summary-last-article-p (gnus-summary-article-number)))
5967 (and gnus-auto-select-same
5968 (gnus-summary-article-subject))))
5970 (defun gnus-summary-prev-article (&optional unread subject)
5971 "Select the article after the current one.
5972 If UNREAD is non-nil, only unread articles are selected."
5974 (gnus-summary-next-article unread subject t))
5976 (defun gnus-summary-prev-unread-article ()
5977 "Select unread article before current one."
5979 (gnus-summary-prev-article
5980 (or (not (eq gnus-summary-goto-unread 'never))
5981 (gnus-summary-first-article-p (gnus-summary-article-number)))
5982 (and gnus-auto-select-same
5983 (gnus-summary-article-subject))))
5985 (defun gnus-summary-next-page (&optional lines circular)
5986 "Show next page of the selected article.
5987 If at the end of the current article, select the next article.
5988 LINES says how many lines should be scrolled up.
5990 If CIRCULAR is non-nil, go to the start of the article instead of
5991 selecting the next article when reaching the end of the current
5994 (setq gnus-summary-buffer (current-buffer))
5995 (gnus-set-global-variables)
5996 (let ((article (gnus-summary-article-number))
5997 (article-window (get-buffer-window gnus-article-buffer t))
5999 ;; If the buffer is empty, we have no article.
6001 (error "No article to select"))
6002 (gnus-configure-windows 'article)
6003 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6004 (if (and (eq gnus-summary-goto-unread 'never)
6005 (not (gnus-summary-last-article-p article)))
6006 (gnus-summary-next-article)
6007 (gnus-summary-next-unread-article))
6008 (if (or (null gnus-current-article)
6009 (null gnus-article-current)
6010 (/= article (cdr gnus-article-current))
6011 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6012 ;; Selected subject is different from current article's.
6013 (gnus-summary-display-article article)
6014 (when article-window
6015 (gnus-eval-in-buffer-window gnus-article-buffer
6016 (setq endp (gnus-article-next-page lines)))
6019 (gnus-summary-beginning-of-article))
6021 (gnus-message 3 "End of message"))
6023 (if (and (eq gnus-summary-goto-unread 'never)
6024 (not (gnus-summary-last-article-p article)))
6025 (gnus-summary-next-article)
6026 (gnus-summary-next-unread-article))))))))
6027 (gnus-summary-recenter)
6028 (gnus-summary-position-point)))
6030 (defun gnus-summary-prev-page (&optional lines move)
6031 "Show previous page of selected article.
6032 Argument LINES specifies lines to be scrolled down.
6033 If MOVE, move to the previous unread article if point is at
6034 the beginning of the buffer."
6036 (let ((article (gnus-summary-article-number))
6037 (article-window (get-buffer-window gnus-article-buffer t))
6039 (gnus-configure-windows 'article)
6040 (if (or (null gnus-current-article)
6041 (null gnus-article-current)
6042 (/= article (cdr gnus-article-current))
6043 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6044 ;; Selected subject is different from current article's.
6045 (gnus-summary-display-article article)
6046 (gnus-summary-recenter)
6047 (when article-window
6048 (gnus-eval-in-buffer-window gnus-article-buffer
6049 (setq endp (gnus-article-prev-page lines)))
6050 (when (and move endp)
6052 (gnus-message 3 "Beginning of message"))
6054 (if (and (eq gnus-summary-goto-unread 'never)
6055 (not (gnus-summary-first-article-p article)))
6056 (gnus-summary-prev-article)
6057 (gnus-summary-prev-unread-article))))))))
6058 (gnus-summary-position-point))
6060 (defun gnus-summary-prev-page-or-article (&optional lines)
6061 "Show previous page of selected article.
6062 Argument LINES specifies lines to be scrolled down.
6063 If at the beginning of the article, go to the next article."
6065 (gnus-summary-prev-page lines t))
6067 (defun gnus-summary-scroll-up (lines)
6068 "Scroll up (or down) one line current article.
6069 Argument LINES specifies lines to be scrolled up (or down if negative)."
6071 (gnus-configure-windows 'article)
6072 (gnus-summary-show-thread)
6073 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6074 (gnus-eval-in-buffer-window gnus-article-buffer
6076 (when (gnus-article-next-page lines)
6077 (gnus-message 3 "End of message")))
6079 (gnus-article-prev-page (- lines))))))
6080 (gnus-summary-recenter)
6081 (gnus-summary-position-point))
6083 (defun gnus-summary-scroll-down (lines)
6084 "Scroll down (or up) one line current article.
6085 Argument LINES specifies lines to be scrolled down (or up if negative)."
6087 (gnus-summary-scroll-up (- lines)))
6089 (defun gnus-summary-next-same-subject ()
6090 "Select next article which has the same subject as current one."
6092 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6094 (defun gnus-summary-prev-same-subject ()
6095 "Select previous article which has the same subject as current one."
6097 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6099 (defun gnus-summary-next-unread-same-subject ()
6100 "Select next unread article which has the same subject as current one."
6102 (gnus-summary-next-article t (gnus-summary-article-subject)))
6104 (defun gnus-summary-prev-unread-same-subject ()
6105 "Select previous unread article which has the same subject as current one."
6107 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6109 (defun gnus-summary-first-unread-article ()
6110 "Select the first unread article.
6111 Return nil if there are no unread articles."
6114 (when (gnus-summary-first-subject t)
6115 (gnus-summary-show-thread)
6116 (gnus-summary-first-subject t)
6117 (gnus-summary-display-article (gnus-summary-article-number)))
6118 (gnus-summary-position-point)))
6120 (defun gnus-summary-first-unread-subject ()
6121 "Place the point on the subject line of the first unread article.
6122 Return nil if there are no unread articles."
6125 (when (gnus-summary-first-subject t)
6126 (gnus-summary-show-thread)
6127 (gnus-summary-first-subject t))
6128 (gnus-summary-position-point)))
6130 (defun gnus-summary-first-article ()
6131 "Select the first article.
6132 Return nil if there are no articles."
6135 (when (gnus-summary-first-subject)
6136 (gnus-summary-show-thread)
6137 (gnus-summary-first-subject)
6138 (gnus-summary-display-article (gnus-summary-article-number)))
6139 (gnus-summary-position-point)))
6141 (defun gnus-summary-best-unread-article ()
6142 "Select the unread article with the highest score."
6144 (let ((best -1000000)
6145 (data gnus-newsgroup-data)
6148 (and (gnus-data-unread-p (car data))
6150 (gnus-summary-article-score (gnus-data-number (car data))))
6153 article (gnus-data-number (car data))))
6154 (setq data (cdr data)))
6157 (gnus-summary-goto-article article)
6158 (error "No unread articles"))
6159 (gnus-summary-position-point))))
6161 (defun gnus-summary-last-subject ()
6162 "Go to the last displayed subject line in the group."
6163 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6165 (gnus-summary-goto-subject article))))
6167 (defun gnus-summary-goto-article (article &optional all-headers force)
6168 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6169 If ALL-HEADERS is non-nil, no header lines are hidden.
6170 If FORCE, go to the article even if it isn't displayed. If FORCE
6171 is a number, it is the line the article is to be displayed on."
6175 "Article number or Message-ID: "
6176 (mapcar (lambda (number) (list (int-to-string number)))
6177 gnus-newsgroup-limit))
6181 (if (and (stringp article)
6182 (string-match "@" article))
6183 (gnus-summary-refer-article article)
6184 (when (stringp article)
6185 (setq article (string-to-number article)))
6186 (if (gnus-summary-goto-subject article force)
6187 (gnus-summary-display-article article all-headers)
6188 (gnus-message 4 "Couldn't go to article %s" article) nil))
6189 (gnus-summary-position-point)))
6191 (defun gnus-summary-goto-last-article ()
6192 "Go to the previously read article."
6195 (when gnus-last-article
6196 (gnus-summary-goto-article gnus-last-article nil t))
6197 (gnus-summary-position-point)))
6199 (defun gnus-summary-pop-article (number)
6200 "Pop one article off the history and go to the previous.
6201 NUMBER articles will be popped off."
6204 (setq gnus-newsgroup-history
6205 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6207 (gnus-summary-goto-article (car to) nil t)
6208 (error "Article history empty")))
6209 (gnus-summary-position-point))
6211 ;; Summary commands and functions for limiting the summary buffer.
6213 (defun gnus-summary-limit-to-articles (n)
6214 "Limit the summary buffer to the next N articles.
6215 If not given a prefix, use the process marked articles instead."
6218 (let ((articles (gnus-summary-work-articles n)))
6219 (setq gnus-newsgroup-processable nil)
6220 (gnus-summary-limit articles))
6221 (gnus-summary-position-point)))
6223 (defun gnus-summary-pop-limit (&optional total)
6224 "Restore the previous limit.
6225 If given a prefix, remove all limits."
6228 (setq gnus-newsgroup-limits
6229 (list (mapcar (lambda (h) (mail-header-number h))
6230 gnus-newsgroup-headers))))
6231 (unless gnus-newsgroup-limits
6232 (error "No limit to pop"))
6234 (gnus-summary-limit nil 'pop)
6235 (gnus-summary-position-point)))
6237 (defun gnus-summary-limit-to-subject (subject &optional header)
6238 "Limit the summary buffer to articles that have subjects that match a regexp."
6239 (interactive "sLimit to subject (regexp): ")
6241 (setq header "subject"))
6242 (when (not (equal "" subject))
6244 (let ((articles (gnus-summary-find-matching
6245 (or header "subject") subject 'all)))
6247 (error "Found no matches for \"%s\"" subject))
6248 (gnus-summary-limit articles))
6249 (gnus-summary-position-point))))
6251 (defun gnus-summary-limit-to-author (from)
6252 "Limit the summary buffer to articles that have authors that match a regexp."
6253 (interactive "sLimit to author (regexp): ")
6254 (gnus-summary-limit-to-subject from "from"))
6256 (defun gnus-summary-limit-to-age (age &optional younger-p)
6257 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6258 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6259 articles that are younger than AGE days."
6261 (let ((younger current-prefix-arg)
6264 (while (not days-got)
6265 (setq days (if younger
6266 (read-string "Limit to articles within (in days): ")
6267 (read-string "Limit to articles old than (in days): ")))
6268 (when (> (length days) 0)
6269 (setq days (read days)))
6272 (message "Please enter a number.")
6274 (list days younger)))
6276 (let ((data gnus-newsgroup-data)
6277 (cutoff (days-to-time age))
6278 articles d date is-younger)
6279 (while (setq d (pop data))
6280 (when (and (vectorp (gnus-data-header d))
6281 (setq date (mail-header-date (gnus-data-header d))))
6282 (setq is-younger (time-less-p
6283 (time-since (condition-case ()
6290 (push (gnus-data-number d) articles))))
6291 (gnus-summary-limit (nreverse articles)))
6292 (gnus-summary-position-point)))
6294 (defun gnus-summary-limit-to-extra (header regexp)
6295 "Limit the summary buffer to articles that match an 'extra' header."
6299 (gnus-completing-read
6300 (symbol-name (car gnus-extra-headers))
6301 "Limit extra header:"
6303 (cons (symbol-name x) x))
6308 (read-string (format "Limit to header %s (regexp): " header)))))
6309 (when (not (equal "" regexp))
6311 (let ((articles (gnus-summary-find-matching
6312 (cons 'extra header) regexp 'all)))
6314 (error "Found no matches for \"%s\"" regexp))
6315 (gnus-summary-limit articles))
6316 (gnus-summary-position-point))))
6318 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6320 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6322 (defun gnus-summary-limit-to-unread (&optional all)
6323 "Limit the summary buffer to articles that are not marked as read.
6324 If ALL is non-nil, limit strictly to unread articles."
6327 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6328 (gnus-summary-limit-to-marks
6329 ;; Concat all the marks that say that an article is read and have
6331 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6332 gnus-killed-mark gnus-kill-file-mark
6333 gnus-low-score-mark gnus-expirable-mark
6334 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6335 gnus-duplicate-mark gnus-souped-mark)
6338 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6339 (make-obsolete 'gnus-summary-delete-marked-with
6340 'gnus-summary-limit-exlude-marks)
6342 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6343 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6344 If REVERSE, limit the summary buffer to articles that are marked
6345 with MARKS. MARKS can either be a string of marks or a list of marks.
6346 Returns how many articles were removed."
6347 (interactive "sMarks: ")
6348 (gnus-summary-limit-to-marks marks t))
6350 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6351 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6352 If REVERSE (the prefix), limit the summary buffer to articles that are
6353 not marked with MARKS. MARKS can either be a string of marks or a
6355 Returns how many articles were removed."
6356 (interactive "sMarks: \nP")
6358 (let ((data gnus-newsgroup-data)
6359 (marks (if (listp marks) marks
6360 (append marks nil))) ; Transform to list.
6363 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6364 (memq (gnus-data-mark (car data)) marks))
6365 (push (gnus-data-number (car data)) articles))
6366 (setq data (cdr data)))
6367 (gnus-summary-limit articles))
6368 (gnus-summary-position-point)))
6370 (defun gnus-summary-limit-to-score (&optional score)
6371 "Limit to articles with score at or above SCORE."
6373 (setq score (if score
6374 (prefix-numeric-value score)
6375 (or gnus-summary-default-score 0)))
6376 (let ((data gnus-newsgroup-data)
6379 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6381 (push (gnus-data-number (car data)) articles))
6382 (setq data (cdr data)))
6384 (gnus-summary-limit articles)
6385 (gnus-summary-position-point))))
6387 (defun gnus-summary-limit-include-thread (id)
6388 "Display all the hidden articles that in the current thread."
6389 (interactive (list (mail-header-id (gnus-summary-article-header))))
6390 (let ((articles (gnus-articles-in-thread
6391 (gnus-id-to-thread (gnus-root-id id)))))
6393 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6394 (gnus-summary-position-point))))
6396 (defun gnus-summary-limit-include-dormant ()
6397 "Display all the hidden articles that are marked as dormant.
6398 Note that this command only works on a subset of the articles currently
6399 fetched for this group."
6401 (unless gnus-newsgroup-dormant
6402 (error "There are no dormant articles in this group"))
6404 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6405 (gnus-summary-position-point)))
6407 (defun gnus-summary-limit-exclude-dormant ()
6408 "Hide all dormant articles."
6411 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6412 (gnus-summary-position-point)))
6414 (defun gnus-summary-limit-exclude-childless-dormant ()
6415 "Hide all dormant articles that have no children."
6417 (let ((data (gnus-data-list t))
6418 articles d children)
6419 ;; Find all articles that are either not dormant or have
6421 (while (setq d (pop data))
6422 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6424 (gnus-article-children (gnus-data-number d)))
6427 (when (memq (car children) articles)
6432 (push (gnus-data-number d) articles)))
6435 (gnus-summary-limit articles)
6436 (gnus-summary-position-point))))
6438 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6439 "Mark all unread excluded articles as read.
6440 If ALL, mark even excluded ticked and dormants as read."
6442 (let ((articles (gnus-sorted-complement
6444 (mapcar (lambda (h) (mail-header-number h))
6445 gnus-newsgroup-headers)
6447 (sort gnus-newsgroup-limit '<)))
6449 (setq gnus-newsgroup-unreads
6450 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6452 (setq gnus-newsgroup-dormant nil
6453 gnus-newsgroup-marked nil
6454 gnus-newsgroup-reads
6456 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6457 gnus-newsgroup-reads))
6458 (while (setq article (pop articles))
6459 (unless (or (memq article gnus-newsgroup-dormant)
6460 (memq article gnus-newsgroup-marked))
6461 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6463 (defun gnus-summary-limit (articles &optional pop)
6465 ;; We pop the previous limit off the stack and use that.
6466 (setq articles (car gnus-newsgroup-limits)
6467 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6468 ;; We use the new limit, so we push the old limit on the stack.
6469 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6471 (setq gnus-newsgroup-limit articles)
6472 (let ((total (length gnus-newsgroup-data))
6473 (data (gnus-data-find-list (gnus-summary-article-number)))
6474 (gnus-summary-mark-below nil) ; Inhibit this.
6476 ;; This will do all the work of generating the new summary buffer
6477 ;; according to the new limit.
6478 (gnus-summary-prepare)
6479 ;; Hide any threads, possibly.
6480 (and gnus-show-threads
6481 gnus-thread-hide-subtree
6482 (gnus-summary-hide-all-threads))
6483 ;; Try to return to the article you were at, or one in the
6486 ;; We try to find some article after the current one.
6488 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6491 (setq data (cdr data))))
6493 ;; If there is no data, that means that we were after the last
6494 ;; article. The same goes when we can't find any articles
6495 ;; after the current one.
6496 (goto-char (point-max))
6497 (gnus-summary-find-prev))
6498 (gnus-set-mode-line 'summary)
6499 ;; We return how many articles were removed from the summary
6500 ;; buffer as a result of the new limit.
6501 (- total (length gnus-newsgroup-data))))
6503 (defsubst gnus-invisible-cut-children (threads)
6506 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6511 (defsubst gnus-cut-thread (thread)
6512 "Go forwards in the thread until we find an article that we want to display."
6513 (when (or (eq gnus-fetch-old-headers 'some)
6514 (eq gnus-fetch-old-headers 'invisible)
6515 (numberp gnus-fetch-old-headers)
6516 (eq gnus-build-sparse-threads 'some)
6517 (eq gnus-build-sparse-threads 'more))
6518 ;; Deal with old-fetched headers and sparse threads.
6522 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6523 (gnus-summary-article-ancient-p
6524 (mail-header-number (car thread))))
6525 (if (or (<= (length (cdr thread)) 1)
6526 (eq gnus-fetch-old-headers 'invisible))
6527 (setq gnus-newsgroup-limit
6528 (delq (mail-header-number (car thread))
6529 gnus-newsgroup-limit)
6530 thread (cadr thread))
6531 (when (gnus-invisible-cut-children (cdr thread))
6532 (let ((th (cdr thread)))
6534 (if (memq (mail-header-number (caar th))
6535 gnus-newsgroup-limit)
6536 (setq thread (car th)
6538 (setq th (cdr th))))))))))
6541 (defun gnus-cut-threads (threads)
6542 "Cut off all uninteresting articles from the beginning of threads."
6543 (when (or (eq gnus-fetch-old-headers 'some)
6544 (eq gnus-fetch-old-headers 'invisible)
6545 (numberp gnus-fetch-old-headers)
6546 (eq gnus-build-sparse-threads 'some)
6547 (eq gnus-build-sparse-threads 'more))
6550 (setcar th (gnus-cut-thread (car th)))
6551 (setq th (cdr th)))))
6552 ;; Remove nixed out threads.
6555 (defun gnus-summary-initial-limit (&optional show-if-empty)
6556 "Figure out what the initial limit is supposed to be on group entry.
6557 This entails weeding out unwanted dormants, low-scored articles,
6558 fetch-old-headers verbiage, and so on."
6559 ;; Most groups have nothing to remove.
6560 (if (or gnus-inhibit-limiting
6561 (and (null gnus-newsgroup-dormant)
6562 (not (eq gnus-fetch-old-headers 'some))
6563 (not (numberp gnus-fetch-old-headers))
6564 (not (eq gnus-fetch-old-headers 'invisible))
6565 (null gnus-summary-expunge-below)
6566 (not (eq gnus-build-sparse-threads 'some))
6567 (not (eq gnus-build-sparse-threads 'more))
6568 (null gnus-thread-expunge-below)
6569 (not gnus-use-nocem)))
6571 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6572 (setq gnus-newsgroup-limit nil)
6575 (unless (car (symbol-value node))
6576 ;; These threads have no parents -- they are roots.
6577 (let ((nodes (cdr (symbol-value node)))
6580 (if (and gnus-thread-expunge-below
6581 (< (gnus-thread-total-score (car nodes))
6582 gnus-thread-expunge-below))
6583 (gnus-expunge-thread (pop nodes))
6584 (setq thread (pop nodes))
6585 (gnus-summary-limit-children thread))))))
6586 gnus-newsgroup-dependencies)
6587 ;; If this limitation resulted in an empty group, we might
6588 ;; pop the previous limit and use it instead.
6589 (when (and (not gnus-newsgroup-limit)
6591 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6592 gnus-newsgroup-limit))
6594 (defun gnus-summary-limit-children (thread)
6595 "Return 1 if this subthread is visible and 0 if it is not."
6596 ;; First we get the number of visible children to this thread. This
6597 ;; is done by recursing down the thread using this function, so this
6598 ;; will really go down to a leaf article first, before slowly
6599 ;; working its way up towards the root.
6603 (apply '+ (mapcar 'gnus-summary-limit-children
6606 (number (mail-header-number (car thread)))
6609 (not (memq number gnus-newsgroup-marked))
6611 ;; If this article is dormant and has absolutely no visible
6612 ;; children, then this article isn't visible.
6613 (and (memq number gnus-newsgroup-dormant)
6615 ;; If this is "fetch-old-headered" and there is no
6616 ;; visible children, then we don't want this article.
6617 (and (or (eq gnus-fetch-old-headers 'some)
6618 (numberp gnus-fetch-old-headers))
6619 (gnus-summary-article-ancient-p number)
6621 ;; If this is "fetch-old-headered" and `invisible', then
6622 ;; we don't want this article.
6623 (and (eq gnus-fetch-old-headers 'invisible)
6624 (gnus-summary-article-ancient-p number))
6625 ;; If this is a sparsely inserted article with no children,
6626 ;; we don't want it.
6627 (and (eq gnus-build-sparse-threads 'some)
6628 (gnus-summary-article-sparse-p number)
6630 ;; If we use expunging, and this article is really
6631 ;; low-scored, then we don't want this article.
6632 (when (and gnus-summary-expunge-below
6634 (or (cdr (assq number gnus-newsgroup-scored))
6635 gnus-summary-default-score))
6636 gnus-summary-expunge-below))
6637 ;; We increase the expunge-tally here, but that has
6638 ;; nothing to do with the limits, really.
6639 (incf gnus-newsgroup-expunged-tally)
6640 ;; We also mark as read here, if that's wanted.
6641 (when (and gnus-summary-mark-below
6642 (< score gnus-summary-mark-below))
6643 (setq gnus-newsgroup-unreads
6644 (delq number gnus-newsgroup-unreads))
6645 (if gnus-newsgroup-auto-expire
6646 (push number gnus-newsgroup-expirable)
6647 (push (cons number gnus-low-score-mark)
6648 gnus-newsgroup-reads)))
6650 ;; Check NoCeM things.
6651 (if (and gnus-use-nocem
6652 (gnus-nocem-unwanted-article-p
6653 (mail-header-id (car thread))))
6655 (setq gnus-newsgroup-unreads
6656 (delq number gnus-newsgroup-unreads))
6658 ;; Nope, invisible article.
6660 ;; Ok, this article is to be visible, so we add it to the limit
6662 (push number gnus-newsgroup-limit)
6665 (defun gnus-expunge-thread (thread)
6666 "Mark all articles in THREAD as read."
6667 (let* ((number (mail-header-number (car thread))))
6668 (incf gnus-newsgroup-expunged-tally)
6669 ;; We also mark as read here, if that's wanted.
6670 (setq gnus-newsgroup-unreads
6671 (delq number gnus-newsgroup-unreads))
6672 (if gnus-newsgroup-auto-expire
6673 (push number gnus-newsgroup-expirable)
6674 (push (cons number gnus-low-score-mark)
6675 gnus-newsgroup-reads)))
6676 ;; Go recursively through all subthreads.
6677 (mapcar 'gnus-expunge-thread (cdr thread)))
6679 ;; Summary article oriented commands
6681 (defun gnus-summary-refer-parent-article (n)
6682 "Refer parent article N times.
6683 If N is negative, go to ancestor -N instead.
6684 The difference between N and the number of articles fetched is returned."
6688 (when (not (natnump n))
6693 (setq header (gnus-summary-article-header))
6694 (if (and (eq (mail-header-number header)
6695 (cdr gnus-article-current))
6696 (equal gnus-newsgroup-name
6697 (car gnus-article-current)))
6698 ;; If we try to find the parent of the currently
6699 ;; displayed article, then we take a look at the actual
6700 ;; References header, since this is slightly more
6701 ;; reliable than the References field we got from the
6704 (set-buffer gnus-original-article-buffer)
6705 (nnheader-narrow-to-headers)
6706 (unless (setq ref (message-fetch-field "references"))
6707 (setq ref (message-fetch-field "in-reply-to")))
6710 ;; It's not the current article, so we take a bet on
6711 ;; the value we got from the server.
6712 (mail-header-references header)))
6714 (not (equal ref "")))
6715 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6716 (gnus-message 1 "Couldn't find parent"))
6717 (gnus-message 1 "No references in article %d"
6718 (gnus-summary-article-number))
6721 (gnus-summary-position-point)
6724 (defun gnus-summary-refer-references ()
6725 "Fetch all articles mentioned in the References header.
6726 Return the number of articles fetched."
6728 (let ((ref (mail-header-references (gnus-summary-article-header)))
6729 (current (gnus-summary-article-number))
6733 (error "No References in the current article")
6734 ;; For each Message-ID in the References header...
6735 (while (string-match "<[^>]*>" ref)
6737 ;; ... fetch that article.
6738 (gnus-summary-refer-article
6739 (prog1 (match-string 0 ref)
6740 (setq ref (substring ref (match-end 0))))))
6741 (gnus-summary-goto-subject current)
6742 (gnus-summary-position-point)
6745 (defun gnus-summary-refer-thread (&optional limit)
6746 "Fetch all articles in the current thread.
6747 If LIMIT (the numerical prefix), fetch that many old headers instead
6748 of what's specified by the `gnus-refer-thread-limit' variable."
6750 (let ((id (mail-header-id (gnus-summary-article-header)))
6751 (limit (if limit (prefix-numeric-value limit)
6752 gnus-refer-thread-limit)))
6753 ;; We want to fetch LIMIT *old* headers, but we also have to
6754 ;; re-fetch all the headers in the current buffer, because many of
6755 ;; them may be undisplayed. So we adjust LIMIT.
6756 (when (numberp limit)
6757 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6758 (unless (eq gnus-fetch-old-headers 'invisible)
6759 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6760 ;; Retrieve the headers and read them in.
6761 (if (eq (gnus-retrieve-headers
6762 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6764 (gnus-build-all-threads)
6765 (error "Can't fetch thread from backends that don't support NOV"))
6766 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6767 (gnus-summary-limit-include-thread id)))
6769 (defun gnus-summary-refer-article (message-id)
6770 "Fetch an article specified by MESSAGE-ID."
6771 (interactive "sMessage-ID: ")
6772 (when (and (stringp message-id)
6773 (not (zerop (length message-id))))
6774 ;; Construct the correct Message-ID if necessary.
6775 ;; Suggested by tale@pawl.rpi.edu.
6776 (unless (string-match "^<" message-id)
6777 (setq message-id (concat "<" message-id)))
6778 (unless (string-match ">$" message-id)
6779 (setq message-id (concat message-id ">")))
6780 (let* ((header (gnus-id-to-header message-id))
6782 (gnus-summary-article-sparse-p
6783 (mail-header-number header))
6784 (memq (mail-header-number header)
6785 gnus-newsgroup-limit)))
6788 ;; If the article is present in the buffer we just go to it.
6790 (or (not (gnus-summary-article-sparse-p
6791 (mail-header-number header)))
6794 (gnus-summary-goto-article
6795 (mail-header-number header) nil t)
6797 (gnus-summary-update-article (mail-header-number header)))))
6799 ;; We fetch the article.
6801 (dolist (gnus-override-method (gnus-refer-article-methods))
6802 (gnus-check-server gnus-override-method)
6803 ;; Fetch the header, and display the article.
6804 (when (setq number (gnus-summary-insert-subject message-id))
6805 (gnus-summary-select-article nil nil nil number)
6807 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6809 (defun gnus-refer-article-methods ()
6810 "Return a list of referrable methods."
6812 ;; No method, so we default to current and native.
6813 ((null gnus-refer-article-method)
6814 (list gnus-current-select-method gnus-select-method))
6816 ((eq 'current gnus-refer-article-method)
6817 (list gnus-current-select-method))
6818 ;; List of select methods.
6819 ((not (stringp (cadr gnus-refer-article-method)))
6821 (dolist (method gnus-refer-article-method)
6822 (push (if (eq 'current method)
6823 gnus-current-select-method
6827 ;; One single select method.
6829 (list gnus-refer-article-method))))
6831 (defun gnus-summary-edit-parameters ()
6832 "Edit the group parameters of the current group."
6834 (gnus-group-edit-group gnus-newsgroup-name 'params))
6836 (defun gnus-summary-customize-parameters ()
6837 "Customize the group parameters of the current group."
6839 (gnus-group-customize gnus-newsgroup-name))
6841 (defun gnus-summary-enter-digest-group (&optional force)
6842 "Enter an nndoc group based on the current article.
6843 If FORCE, force a digest interpretation. If not, try
6844 to guess what the document format is."
6846 (let ((conf gnus-current-window-configuration))
6848 (gnus-summary-select-article))
6849 (setq gnus-current-window-configuration conf)
6850 (let* ((name (format "%s-%d"
6851 (gnus-group-prefixed-name
6852 gnus-newsgroup-name (list 'nndoc ""))
6854 (set-buffer gnus-summary-buffer)
6855 gnus-current-article)))
6856 (ogroup gnus-newsgroup-name)
6857 (params (append (gnus-info-params (gnus-get-info ogroup))
6858 (list (cons 'to-group ogroup))
6859 (list (cons 'save-article-group ogroup))))
6860 (case-fold-search t)
6861 (buf (current-buffer))
6864 (set-buffer gnus-original-article-buffer)
6865 ;; Have the digest group inherit the main mail address of
6866 ;; the parent article.
6867 (when (setq to-address (or (message-fetch-field "reply-to")
6868 (message-fetch-field "from")))
6869 (setq params (append (list (cons 'to-address to-address)))))
6870 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6871 (insert-buffer-substring gnus-original-article-buffer)
6872 ;; Remove lines that may lead nndoc to misinterpret the
6875 (goto-char (point-min))
6876 (or (search-forward "\n\n" nil t) (point)))
6877 (goto-char (point-min))
6878 (delete-matching-lines "^Path:\\|^From ")
6881 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6882 (gnus-newsgroup-ephemeral-ignored-charsets
6883 gnus-newsgroup-ignored-charsets))
6884 (gnus-group-read-ephemeral-group
6885 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6887 ,(if force 'mbox 'guess))) t))
6888 ;; Make all postings to this group go to the parent group.
6889 (nconc (gnus-info-params (gnus-get-info name))
6891 ;; Couldn't select this doc group.
6892 (switch-to-buffer buf)
6893 (gnus-set-global-variables)
6894 (gnus-configure-windows 'summary)
6895 (gnus-message 3 "Article couldn't be entered?"))
6896 (kill-buffer dig)))))
6898 (defun gnus-summary-read-document (n)
6899 "Open a new group based on the current article(s).
6900 This will allow you to read digests and other similar
6901 documents as newsgroups.
6902 Obeys the standard process/prefix convention."
6904 (let* ((articles (gnus-summary-work-articles n))
6905 (ogroup gnus-newsgroup-name)
6906 (params (append (gnus-info-params (gnus-get-info ogroup))
6907 (list (cons 'to-group ogroup))))
6908 article group egroup groups vgroup)
6909 (while (setq article (pop articles))
6910 (setq group (format "%s-%d" gnus-newsgroup-name article))
6911 (gnus-summary-remove-process-mark article)
6912 (when (gnus-summary-display-article article)
6915 (insert-buffer-substring gnus-original-article-buffer)
6916 ;; Remove some headers that may lead nndoc to make
6918 (message-narrow-to-head)
6919 (goto-char (point-min))
6920 (delete-matching-lines "^\\(Path\\):\\|^From ")
6923 (gnus-group-read-ephemeral-group
6924 group `(nndoc ,group (nndoc-address ,(current-buffer))
6925 (nndoc-article-type guess))
6928 ;; Make all postings to this group go to the parent group.
6929 (nconc (gnus-info-params (gnus-get-info egroup))
6931 (push egroup groups))
6932 ;; Couldn't select this doc group.
6933 (gnus-error 3 "Article couldn't be entered"))))))
6934 ;; Now we have selected all the documents.
6937 (error "None of the articles could be interpreted as documents"))
6938 ((gnus-group-read-ephemeral-group
6939 (setq vgroup (format
6940 "nnvirtual:%s-%s" gnus-newsgroup-name
6941 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6942 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6944 (cons (current-buffer) 'summary)))
6946 (error "Couldn't select virtual nndoc group")))))
6948 (defun gnus-summary-isearch-article (&optional regexp-p)
6949 "Do incremental search forward on the current article.
6950 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6952 (gnus-summary-select-article)
6953 (gnus-configure-windows 'article)
6954 (gnus-eval-in-buffer-window gnus-article-buffer
6957 (isearch-forward regexp-p))))
6959 (defun gnus-summary-search-article-forward (regexp &optional backward)
6960 "Search for an article containing REGEXP forward.
6961 If BACKWARD, search backward instead."
6964 (format "Search article %s (regexp%s): "
6965 (if current-prefix-arg "backward" "forward")
6966 (if gnus-last-search-regexp
6967 (concat ", default " gnus-last-search-regexp)
6969 current-prefix-arg))
6970 (if (string-equal regexp "")
6971 (setq regexp (or gnus-last-search-regexp ""))
6972 (setq gnus-last-search-regexp regexp))
6973 (if (gnus-summary-search-article regexp backward)
6974 (gnus-summary-show-thread)
6975 (error "Search failed: \"%s\"" regexp)))
6977 (defun gnus-summary-search-article-backward (regexp)
6978 "Search for an article containing REGEXP backward."
6981 (format "Search article backward (regexp%s): "
6982 (if gnus-last-search-regexp
6983 (concat ", default " gnus-last-search-regexp)
6985 (gnus-summary-search-article-forward regexp 'backward))
6987 (defun gnus-summary-search-article (regexp &optional backward)
6988 "Search for an article containing REGEXP.
6989 Optional argument BACKWARD means do search for backward.
6990 `gnus-select-article-hook' is not called during the search."
6991 ;; We have to require this here to make sure that the following
6992 ;; dynamic binding isn't shadowed by autoloading.
6993 (require 'gnus-async)
6995 (let ((gnus-select-article-hook nil) ;Disable hook.
6996 (gnus-article-prepare-hook nil)
6997 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6998 (gnus-use-article-prefetch nil)
6999 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7000 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7001 (sum (current-buffer))
7002 (gnus-display-mime-function nil)
7005 (gnus-save-hidden-threads
7006 (gnus-summary-select-article)
7007 (set-buffer gnus-article-buffer)
7008 (goto-char (window-point (get-buffer-window (current-buffer))))
7012 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7014 (re-search-backward regexp nil t)
7015 (re-search-forward regexp nil t))
7016 ;; We found the regexp.
7021 (get-buffer-window (current-buffer))
7025 (get-buffer-window (current-buffer))
7028 (setq point (point)))
7029 ;; We didn't find it, so we go to the next article.
7032 (while (eq found 'not)
7033 (if (not (if backward (gnus-summary-find-prev)
7034 (gnus-summary-find-next)))
7035 ;; No more articles.
7037 ;; Select the next article and adjust point.
7038 (unless (gnus-summary-article-sparse-p
7039 (gnus-summary-article-number))
7041 (gnus-summary-select-article)
7042 (set-buffer gnus-article-buffer)
7044 (goto-char (if backward (point-max) (point-min))))))))
7045 (gnus-message 7 ""))
7046 ;; Return whether we found the regexp.
7047 (when (eq found 'found)
7049 (gnus-summary-show-thread)
7050 (gnus-summary-goto-subject gnus-current-article)
7051 (gnus-summary-position-point)
7054 (defun gnus-summary-find-matching (header regexp &optional backward unread
7056 "Return a list of all articles that match REGEXP on HEADER.
7057 The search stars on the current article and goes forwards unless
7058 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7059 If UNREAD is non-nil, only unread articles will
7060 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7061 in the comparisons."
7062 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7063 (gnus-data-find-list
7064 (gnus-summary-article-number) (gnus-data-list backward))))
7065 (case-fold-search (not not-case-fold))
7068 (if (eq (car header) 'extra)
7071 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7073 (error "%s is an invalid header" header))
7074 (unless (fboundp (intern (concat "mail-header-" header)))
7075 (error "%s is not a valid header" header))
7076 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7079 (and (or (not unread) ; We want all articles...
7080 (gnus-data-unread-p d)) ; Or just unreads.
7081 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7082 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7083 (push (gnus-data-number d) articles)) ; Success!
7084 (setq data (cdr data)))
7085 (nreverse articles)))
7087 (defun gnus-summary-execute-command (header regexp command &optional backward)
7088 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7089 If HEADER is an empty string (or nil), the match is done on the entire
7090 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7092 (list (let ((completion-ignore-case t))
7095 (mapcar (lambda (string) (list string))
7096 '("Number" "Subject" "From" "Lines" "Date"
7097 "Message-ID" "Xref" "References" "Body"))
7098 nil 'require-match))
7099 (read-string "Regexp: ")
7100 (read-key-sequence "Command: ")
7101 current-prefix-arg))
7102 (when (equal header "Body")
7104 ;; Hidden thread subtrees must be searched as well.
7105 (gnus-summary-show-all-threads)
7106 ;; We don't want to change current point nor window configuration.
7108 (save-window-excursion
7109 (gnus-message 6 "Executing %s..." (key-description command))
7110 ;; We'd like to execute COMMAND interactively so as to give arguments.
7111 (gnus-execute header regexp
7112 `(call-interactively ',(key-binding command))
7114 (gnus-message 6 "Executing %s...done" (key-description command)))))
7116 (defun gnus-summary-beginning-of-article ()
7117 "Scroll the article back to the beginning."
7119 (gnus-summary-select-article)
7120 (gnus-configure-windows 'article)
7121 (gnus-eval-in-buffer-window gnus-article-buffer
7123 (goto-char (point-min))
7124 (when gnus-page-broken
7125 (gnus-narrow-to-page))))
7127 (defun gnus-summary-end-of-article ()
7128 "Scroll to the end of the article."
7130 (gnus-summary-select-article)
7131 (gnus-configure-windows 'article)
7132 (gnus-eval-in-buffer-window gnus-article-buffer
7134 (goto-char (point-max))
7136 (when gnus-page-broken
7137 (gnus-narrow-to-page))))
7139 (defun gnus-summary-print-article (&optional filename n)
7140 "Generate and print a PostScript image of the N next (mail) articles.
7142 If N is negative, print the N previous articles. If N is nil and articles
7143 have been marked with the process mark, print these instead.
7145 If the optional first argument FILENAME is nil, send the image to the
7146 printer. If FILENAME is a string, save the PostScript image in a file with
7147 that name. If FILENAME is a number, prompt the user for the name of the file
7149 (interactive (list (ps-print-preprint current-prefix-arg)
7150 current-prefix-arg))
7151 (dolist (article (gnus-summary-work-articles n))
7152 (gnus-summary-select-article nil nil 'pseudo article)
7153 (gnus-eval-in-buffer-window gnus-article-buffer
7154 (let ((buffer (generate-new-buffer " *print*")))
7157 (copy-to-buffer buffer (point-min) (point-max))
7159 (gnus-article-delete-invisible-text)
7160 (let ((ps-left-header
7163 (mail-header-subject gnus-current-headers) ")")
7165 (mail-header-from gnus-current-headers) ")")))
7168 "/pagenumberstring load"
7170 (mail-header-date gnus-current-headers) ")"))))
7171 (gnus-run-hooks 'gnus-ps-print-hook)
7173 (ps-print-buffer-with-faces filename))))
7174 (kill-buffer buffer))))))
7176 (defun gnus-summary-show-article (&optional arg)
7177 "Force re-fetching of the current article.
7178 If ARG (the prefix) is a number, show the article with the charset
7179 defined in `gnus-summary-show-article-charset-alist', or the charset
7181 If ARG (the prefix) is non-nil and not a number, show the raw article
7182 without any article massaging functions being run."
7186 (let ((gnus-newsgroup-charset
7187 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7188 (read-coding-system "Charset: ")))
7189 (gnus-newsgroup-ignored-charsets 'gnus-all))
7190 (gnus-summary-select-article nil 'force)))
7192 ;; Select the article the normal way.
7193 (gnus-summary-select-article nil 'force))
7195 ;; We have to require this here to make sure that the following
7196 ;; dynamic binding isn't shadowed by autoloading.
7197 (require 'gnus-async)
7199 ;; Bind the article treatment functions to nil.
7200 (let ((gnus-have-all-headers t)
7201 gnus-article-prepare-hook
7202 gnus-article-decode-hook
7203 gnus-display-mime-function
7205 ;; Destroy any MIME parts.
7206 (when (gnus-buffer-live-p gnus-article-buffer)
7208 (set-buffer gnus-article-buffer)
7209 (mm-destroy-parts gnus-article-mime-handles)))
7210 (gnus-summary-select-article nil 'force))))
7211 (gnus-summary-goto-subject gnus-current-article)
7212 (gnus-summary-position-point))
7214 (defun gnus-summary-verbose-headers (&optional arg)
7215 "Toggle permanent full header display.
7216 If ARG is a positive number, turn header display on.
7217 If ARG is a negative number, turn header display off."
7219 (setq gnus-show-all-headers
7220 (cond ((or (not (numberp arg))
7222 (not gnus-show-all-headers))
7225 (gnus-summary-show-article))
7227 (defun gnus-summary-toggle-header (&optional arg)
7228 "Show the headers if they are hidden, or hide them if they are shown.
7229 If ARG is a positive number, show the entire header.
7230 If ARG is a negative number, hide the unwanted header lines."
7233 (set-buffer gnus-article-buffer)
7235 (let* ((buffer-read-only nil)
7236 (inhibit-point-motion-hooks t)
7242 (article-narrow-to-head)
7243 (gnus-article-hidden-text-p 'headers))))
7244 (goto-char (point-min))
7245 (when (search-forward "\n\n" nil t)
7246 (delete-region (point-min) (1- (point))))
7247 (goto-char (point-min))
7249 (set-buffer gnus-original-article-buffer)
7250 (goto-char (point-min))
7251 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7252 (insert-buffer-substring gnus-original-article-buffer 1 e)
7254 (narrow-to-region (point-min) (point))
7255 (article-decode-encoded-words)
7257 (let ((gnus-treat-hide-headers nil)
7258 (gnus-treat-hide-boring-headers nil))
7259 (setq gnus-article-wash-types
7260 (delq 'headers gnus-article-wash-types))
7261 (gnus-treat-article 'head))
7262 (gnus-treat-article 'head)))
7263 (gnus-set-mode-line 'article)))))
7265 (defun gnus-summary-show-all-headers ()
7266 "Make all header lines visible."
7268 (gnus-article-show-all-headers))
7270 (defun gnus-summary-caesar-message (&optional arg)
7271 "Caesar rotate the current article by 13.
7272 The numerical prefix specifies how many places to rotate each letter
7275 (gnus-summary-select-article)
7276 (let ((mail-header-separator ""))
7277 (gnus-eval-in-buffer-window gnus-article-buffer
7280 (let ((start (window-start))
7282 (message-caesar-buffer-body arg)
7283 (set-window-start (get-buffer-window (current-buffer)) start))))))
7285 (defun gnus-summary-stop-page-breaking ()
7286 "Stop page breaking in the current article."
7288 (gnus-summary-select-article)
7289 (gnus-eval-in-buffer-window gnus-article-buffer
7291 (when (gnus-visual-p 'page-marker)
7292 (let ((buffer-read-only nil))
7293 (gnus-remove-text-with-property 'gnus-prev)
7294 (gnus-remove-text-with-property 'gnus-next))
7295 (setq gnus-page-broken nil))))
7297 (defun gnus-summary-move-article (&optional n to-newsgroup
7298 select-method action)
7299 "Move the current article to a different newsgroup.
7300 If N is a positive number, move the N next articles.
7301 If N is a negative number, move the N previous articles.
7302 If N is nil and any articles have been marked with the process mark,
7303 move those articles instead.
7304 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7305 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7306 re-spool using this method.
7308 For this function to work, both the current newsgroup and the
7309 newsgroup that you want to move to have to support the `request-move'
7310 and `request-accept' functions.
7312 ACTION can be either `move' (the default), `crosspost' or `copy'."
7315 (setq action 'move))
7316 ;; Disable marking as read.
7317 (let (gnus-mark-article-hook)
7318 (save-window-excursion
7319 (gnus-summary-select-article)))
7320 ;; Check whether the source group supports the required functions.
7321 (cond ((and (eq action 'move)
7322 (not (gnus-check-backend-function
7323 'request-move-article gnus-newsgroup-name)))
7324 (error "The current group does not support article moving"))
7325 ((and (eq action 'crosspost)
7326 (not (gnus-check-backend-function
7327 'request-replace-article gnus-newsgroup-name)))
7328 (error "The current group does not support article editing")))
7329 (let ((articles (gnus-summary-work-articles n))
7330 (prefix (if (gnus-check-backend-function
7331 'request-move-article gnus-newsgroup-name)
7332 (gnus-group-real-prefix gnus-newsgroup-name)
7334 (names '((move "Move" "Moving")
7335 (copy "Copy" "Copying")
7336 (crosspost "Crosspost" "Crossposting")))
7337 (copy-buf (save-excursion
7338 (nnheader-set-temp-buffer " *copy article*")))
7339 art-group to-method new-xref article to-groups)
7340 (unless (assq action names)
7341 (error "Unknown action %s" action))
7342 ;; Read the newsgroup name.
7343 (when (and (not to-newsgroup)
7344 (not select-method))
7346 (gnus-read-move-group-name
7347 (cadr (assq action names))
7348 (symbol-value (intern (format "gnus-current-%s-group" action)))
7350 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7351 (setq to-method (or select-method
7352 (gnus-server-to-method
7353 (gnus-group-method to-newsgroup))))
7354 ;; Check the method we are to move this article to...
7355 (unless (gnus-check-backend-function
7356 'request-accept-article (car to-method))
7357 (error "%s does not support article copying" (car to-method)))
7358 (unless (gnus-check-server to-method)
7359 (error "Can't open server %s" (car to-method)))
7360 (gnus-message 6 "%s to %s: %s..."
7361 (caddr (assq action names))
7362 (or (car select-method) to-newsgroup) articles)
7364 (setq article (pop articles))
7368 ;; Move the article.
7370 ;; Remove this article from future suppression.
7371 (gnus-dup-unsuppress-article article)
7372 (gnus-request-move-article
7373 article ; Article to move
7374 gnus-newsgroup-name ; From newsgroup
7375 (nth 1 (gnus-find-method-for-group
7376 gnus-newsgroup-name)) ; Server
7377 (list 'gnus-request-accept-article
7378 to-newsgroup (list 'quote select-method)
7379 (not articles) t) ; Accept form
7380 (not articles))) ; Only save nov last time
7381 ;; Copy the article.
7384 (set-buffer copy-buf)
7385 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7386 (gnus-request-accept-article
7387 to-newsgroup select-method (not articles) t))))
7388 ;; Crosspost the article.
7389 ((eq action 'crosspost)
7390 (let ((xref (message-tokenize-header
7391 (mail-header-xref (gnus-summary-article-header article))
7393 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7396 (setq xref (list (system-name))))
7399 (mapconcat 'identity
7400 (delete "Xref:" (delete new-xref xref))
7404 (set-buffer copy-buf)
7405 ;; First put the article in the destination group.
7406 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7407 (when (consp (setq art-group
7408 (gnus-request-accept-article
7409 to-newsgroup select-method (not articles))))
7410 (setq new-xref (concat new-xref " " (car art-group)
7411 ":" (cdr art-group)))
7412 ;; Now we have the new Xrefs header, so we insert
7413 ;; it and replace the new article.
7414 (nnheader-replace-header "Xref" new-xref)
7415 (gnus-request-replace-article
7416 (cdr art-group) to-newsgroup (current-buffer))
7420 (gnus-message 1 "Couldn't %s article %s: %s"
7421 (cadr (assq action names)) article
7422 (nnheader-get-report (car to-method))))
7423 ((eq art-group 'junk)
7424 (when (eq action 'move)
7425 (gnus-summary-mark-article article gnus-canceled-mark)
7426 (gnus-message 4 "Deleted article %s" article)))
7428 (let* ((pto-group (gnus-group-prefixed-name
7429 (car art-group) to-method))
7431 (gnus-gethash pto-group gnus-newsrc-hashtb))
7432 (info (nth 2 entry))
7433 (to-group (gnus-info-group info))
7435 ;; Update the group that has been moved to.
7437 (memq action '(move copy)))
7438 (unless (member to-group to-groups)
7439 (push to-group to-groups))
7441 (unless (memq article gnus-newsgroup-unreads)
7442 (push 'read to-marks)
7444 info (gnus-add-to-range (gnus-info-read info)
7445 (list (cdr art-group)))))
7447 ;; See whether the article is to be put in the cache.
7448 (let ((marks gnus-article-mark-lists)
7449 (to-article (cdr art-group)))
7451 ;; Enter the article into the cache in the new group,
7452 ;; if that is required.
7453 (when gnus-use-cache
7454 (gnus-cache-possibly-enter-article
7456 (memq article gnus-newsgroup-marked)
7457 (memq article gnus-newsgroup-dormant)
7458 (memq article gnus-newsgroup-unreads)))
7460 (when gnus-preserve-marks
7461 ;; Copy any marks over to the new group.
7462 (when (and (equal to-group gnus-newsgroup-name)
7463 (not (memq article gnus-newsgroup-unreads)))
7464 ;; Mark this article as read in this group.
7465 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7466 (setcdr (gnus-active to-group) to-article)
7467 (setcdr gnus-newsgroup-active to-article))
7470 (when (memq article (symbol-value
7471 (intern (format "gnus-newsgroup-%s"
7473 (push (cdar marks) to-marks)
7474 ;; If the other group is the same as this group,
7475 ;; then we have to add the mark to the list.
7476 (when (equal to-group gnus-newsgroup-name)
7477 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7480 (intern (format "gnus-newsgroup-%s"
7482 ;; Copy the marks to other group.
7483 (gnus-add-marked-articles
7484 to-group (cdar marks) (list to-article) info))
7485 (setq marks (cdr marks)))
7487 (gnus-request-set-mark to-group (list (list (list to-article)
7492 (concat "(gnus-group-set-info '"
7493 (gnus-prin1-to-string (gnus-get-info to-group))
7496 ;; Update the Xref header in this article to point to
7497 ;; the new crossposted article we have just created.
7498 (when (eq action 'crosspost)
7500 (set-buffer copy-buf)
7501 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7502 (nnheader-replace-header "Xref" new-xref)
7503 (gnus-request-replace-article
7504 article gnus-newsgroup-name (current-buffer)))))
7506 ;;;!!!Why is this necessary?
7507 (set-buffer gnus-summary-buffer)
7509 (gnus-summary-goto-subject article)
7510 (when (eq action 'move)
7511 (gnus-summary-mark-article article gnus-canceled-mark))))
7512 (gnus-summary-remove-process-mark article))
7513 ;; Re-activate all groups that have been moved to.
7516 (set-buffer gnus-group-buffer)
7517 (when (gnus-group-goto-group (car to-groups) t)
7518 (gnus-group-get-new-news-this-group 1 t))
7521 (gnus-kill-buffer copy-buf)
7522 (gnus-summary-position-point)
7523 (gnus-set-mode-line 'summary)))
7525 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7526 "Move the current article to a different newsgroup.
7527 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7528 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7529 re-spool using this method."
7531 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7533 (defun gnus-summary-crosspost-article (&optional n)
7534 "Crosspost the current article to some other group."
7536 (gnus-summary-move-article n nil nil 'crosspost))
7538 (defcustom gnus-summary-respool-default-method nil
7539 "Default method for respooling an article.
7540 If nil, use to the current newsgroup method."
7541 :type '(choice (gnus-select-method :value (nnml ""))
7543 :group 'gnus-summary-mail)
7545 (defun gnus-summary-respool-article (&optional n method)
7546 "Respool the current article.
7547 The article will be squeezed through the mail spooling process again,
7548 which means that it will be put in some mail newsgroup or other
7549 depending on `nnmail-split-methods'.
7550 If N is a positive number, respool the N next articles.
7551 If N is a negative number, respool the N previous articles.
7552 If N is nil and any articles have been marked with the process mark,
7553 respool those articles instead.
7555 Respooling can be done both from mail groups and \"real\" newsgroups.
7556 In the former case, the articles in question will be moved from the
7557 current group into whatever groups they are destined to. In the
7558 latter case, they will be copied into the relevant groups."
7560 (list current-prefix-arg
7561 (let* ((methods (gnus-methods-using 'respool))
7563 (symbol-name (or gnus-summary-respool-default-method
7564 (car (gnus-find-method-for-group
7565 gnus-newsgroup-name)))))
7567 (gnus-completing-read
7568 methname "What backend do you want to use when respooling?"
7569 methods nil t nil 'gnus-mail-method-history))
7572 ((zerop (length (setq ms (gnus-servers-using-backend
7574 (list (intern method) ""))
7578 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7579 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7582 (error "No method given for respooling"))
7583 (if (assoc (symbol-name
7584 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7585 (gnus-methods-using 'respool))
7586 (gnus-summary-move-article n nil method)
7587 (gnus-summary-copy-article n nil method)))
7589 (defun gnus-summary-import-article (file)
7590 "Import an arbitrary file into a mail newsgroup."
7591 (interactive "fImport file: ")
7592 (let ((group gnus-newsgroup-name)
7593 (now (current-time))
7595 (unless (gnus-check-backend-function 'request-accept-article group)
7596 (error "%s does not support article importing" group))
7597 (or (file-readable-p file)
7598 (not (file-regular-p file))
7599 (error "Can't read %s" file))
7601 (set-buffer (gnus-get-buffer-create " *import file*"))
7603 (insert-file-contents file)
7604 (goto-char (point-min))
7605 (unless (nnheader-article-p)
7606 ;; This doesn't look like an article, so we fudge some headers.
7607 (setq atts (file-attributes file)
7608 lines (count-lines (point-min) (point-max)))
7609 (insert "From: " (read-string "From: ") "\n"
7610 "Subject: " (read-string "Subject: ") "\n"
7611 "Date: " (message-make-date (nth 5 atts))
7613 "Message-ID: " (message-make-message-id) "\n"
7614 "Lines: " (int-to-string lines) "\n"
7615 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7616 (gnus-request-accept-article group nil t)
7617 (kill-buffer (current-buffer)))))
7619 (defun gnus-summary-article-posted-p ()
7620 "Say whether the current (mail) article is available from news as well.
7621 This will be the case if the article has both been mailed and posted."
7623 (let ((id (mail-header-references (gnus-summary-article-header)))
7624 (gnus-override-method (car (gnus-refer-article-methods))))
7625 (if (gnus-request-head id "")
7626 (gnus-message 2 "The current message was found on %s"
7627 gnus-override-method)
7628 (gnus-message 2 "The current message couldn't be found on %s"
7629 gnus-override-method)
7632 (defun gnus-summary-expire-articles (&optional now)
7633 "Expire all articles that are marked as expirable in the current group."
7635 (when (gnus-check-backend-function
7636 'request-expire-articles gnus-newsgroup-name)
7637 ;; This backend supports expiry.
7638 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7639 (expirable (if total
7641 ;; We need to update the info for
7642 ;; this group for `gnus-list-of-read-articles'
7643 ;; to give us the right answer.
7644 (gnus-run-hooks 'gnus-exit-group-hook)
7645 (gnus-summary-update-info)
7646 (gnus-list-of-read-articles gnus-newsgroup-name))
7647 (setq gnus-newsgroup-expirable
7648 (sort gnus-newsgroup-expirable '<))))
7649 (expiry-wait (if now 'immediate
7650 (gnus-group-find-parameter
7651 gnus-newsgroup-name 'expiry-wait)))
7654 ;; There are expirable articles in this group, so we run them
7655 ;; through the expiry process.
7656 (gnus-message 6 "Expiring articles...")
7657 (unless (gnus-check-group gnus-newsgroup-name)
7658 (error "Can't open server for %s" gnus-newsgroup-name))
7659 ;; The list of articles that weren't expired is returned.
7662 (let ((nnmail-expiry-wait-function nil)
7663 (nnmail-expiry-wait expiry-wait))
7664 (setq es (gnus-request-expire-articles
7665 expirable gnus-newsgroup-name)))
7666 (setq es (gnus-request-expire-articles
7667 expirable gnus-newsgroup-name))))
7669 (setq gnus-newsgroup-expirable es))
7670 ;; We go through the old list of expirable, and mark all
7671 ;; really expired articles as nonexistent.
7672 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7673 (let ((gnus-use-cache nil))
7675 (unless (memq (car expirable) es)
7676 (when (gnus-data-find (car expirable))
7677 (gnus-summary-mark-article
7678 (car expirable) gnus-canceled-mark)))
7679 (setq expirable (cdr expirable)))))
7680 (gnus-message 6 "Expiring articles...done")))))
7682 (defun gnus-summary-expire-articles-now ()
7683 "Expunge all expirable articles in the current group.
7684 This means that *all* articles that are marked as expirable will be
7685 deleted forever, right now."
7687 (or gnus-expert-user
7689 "Are you really, really, really sure you want to delete all these messages? ")
7691 (gnus-summary-expire-articles t))
7693 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7694 (defun gnus-summary-delete-article (&optional n)
7695 "Delete the N next (mail) articles.
7696 This command actually deletes articles. This is not a marking
7697 command. The article will disappear forever from your life, never to
7699 If N is negative, delete backwards.
7700 If N is nil and articles have been marked with the process mark,
7701 delete these instead."
7703 (unless (gnus-check-backend-function 'request-expire-articles
7704 gnus-newsgroup-name)
7705 (error "The current newsgroup does not support article deletion"))
7706 ;; Compute the list of articles to delete.
7707 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7709 (if (and gnus-novice-user
7710 (not (gnus-yes-or-no-p
7711 (format "Do you really want to delete %s forever? "
7712 (if (> (length articles) 1)
7713 (format "these %s articles" (length articles))
7716 ;; Delete the articles.
7717 (setq not-deleted (gnus-request-expire-articles
7718 articles gnus-newsgroup-name 'force))
7720 (gnus-summary-remove-process-mark (car articles))
7721 ;; The backend might not have been able to delete the article
7723 (unless (memq (car articles) not-deleted)
7724 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7725 (setq articles (cdr articles)))
7727 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7728 (gnus-summary-position-point)
7729 (gnus-set-mode-line 'summary)
7732 (defun gnus-summary-edit-article (&optional force)
7733 "Edit the current article.
7734 This will have permanent effect only in mail groups.
7735 If FORCE is non-nil, allow editing of articles even in read-only
7739 (set-buffer gnus-summary-buffer)
7740 (let ((mail-parse-charset gnus-newsgroup-charset)
7741 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7742 (gnus-set-global-variables)
7743 (when (and (not force)
7744 (gnus-group-read-only-p))
7745 (error "The current newsgroup does not support article editing"))
7746 (gnus-summary-show-article t)
7747 (gnus-article-edit-article
7749 `(lambda (no-highlight)
7750 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7751 (mail-parse-ignored-charsets
7752 ',gnus-newsgroup-ignored-charsets))
7754 (gnus-summary-edit-article-done
7755 ,(or (mail-header-references gnus-current-headers) "")
7756 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7758 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7760 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7762 "Make edits to the current article permanent."
7764 ;; Replace the article.
7765 (let ((buf (current-buffer)))
7767 (insert-buffer-substring buf)
7768 (if (and (not read-only)
7769 (not (gnus-request-replace-article
7770 (cdr gnus-article-current) (car gnus-article-current)
7771 (current-buffer) t)))
7772 (error "Couldn't replace article")
7773 ;; Update the summary buffer.
7775 (equal (message-tokenize-header references " ")
7776 (message-tokenize-header
7777 (or (message-fetch-field "references") "") " ")))
7778 ;; We only have to update this line.
7781 (message-narrow-to-head)
7782 (let ((head (buffer-string))
7785 (insert (format "211 %d Article retrieved.\n"
7786 (cdr gnus-article-current)))
7789 (let ((nntp-server-buffer (current-buffer)))
7790 (setq header (car (gnus-get-newsgroup-headers
7792 (set-buffer gnus-summary-buffer)
7793 gnus-newsgroup-dependencies)
7796 (set-buffer gnus-summary-buffer)
7797 (gnus-data-set-header
7798 (gnus-data-find (cdr gnus-article-current))
7800 (gnus-summary-update-article-line
7801 (cdr gnus-article-current) header))))))
7803 (set-buffer (or buffer gnus-summary-buffer))
7804 (gnus-summary-update-article (cdr gnus-article-current)))
7805 ;; Prettify the article buffer again.
7806 (unless no-highlight
7808 (set-buffer gnus-article-buffer)
7809 ;;;!!! Fix this -- article should be rehighlighted.
7810 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7811 (set-buffer gnus-original-article-buffer)
7812 (gnus-request-article
7813 (cdr gnus-article-current)
7814 (car gnus-article-current) (current-buffer))))
7815 ;; Prettify the summary buffer line.
7816 (when (gnus-visual-p 'summary-highlight 'highlight)
7817 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7819 (defun gnus-summary-edit-wash (key)
7820 "Perform editing command KEY in the article buffer."
7824 (message "%s" (concat (this-command-keys) "- "))
7827 (gnus-summary-edit-article)
7828 (execute-kbd-macro (concat (this-command-keys) key))
7829 (gnus-article-edit-done))
7833 (defun gnus-summary-respool-query (&optional silent trace)
7834 "Query where the respool algorithm would put this article."
7836 (let (gnus-mark-article-hook)
7837 (gnus-summary-select-article)
7839 (set-buffer gnus-original-article-buffer)
7841 (message-narrow-to-head)
7842 (let ((groups (nnmail-article-group 'identity trace)))
7845 (message "This message would go to %s"
7846 (mapconcat 'car groups ", "))
7847 (message "This message would go to no groups"))
7850 (defun gnus-summary-respool-trace ()
7851 "Trace where the respool algorithm would put this article.
7852 Display a buffer showing all fancy splitting patterns which matched."
7854 (gnus-summary-respool-query nil t))
7856 ;; Summary marking commands.
7858 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7859 "Mark articles which has the same subject as read, and then select the next.
7860 If UNMARK is positive, remove any kind of mark.
7861 If UNMARK is negative, tick articles."
7864 (setq unmark (prefix-numeric-value unmark)))
7866 (gnus-summary-mark-same-subject
7867 (gnus-summary-article-subject) unmark)))
7868 ;; Select next unread article. If auto-select-same mode, should
7869 ;; select the first unread article.
7870 (gnus-summary-next-article t (and gnus-auto-select-same
7871 (gnus-summary-article-subject)))
7872 (gnus-message 7 "%d article%s marked as %s"
7873 count (if (= count 1) " is" "s are")
7874 (if unmark "unread" "read"))))
7876 (defun gnus-summary-kill-same-subject (&optional unmark)
7877 "Mark articles which has the same subject as read.
7878 If UNMARK is positive, remove any kind of mark.
7879 If UNMARK is negative, tick articles."
7882 (setq unmark (prefix-numeric-value unmark)))
7884 (gnus-summary-mark-same-subject
7885 (gnus-summary-article-subject) unmark)))
7886 ;; If marked as read, go to next unread subject.
7888 ;; Go to next unread subject.
7889 (gnus-summary-next-subject 1 t))
7890 (gnus-message 7 "%d articles are marked as %s"
7891 count (if unmark "unread" "read"))))
7893 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7894 "Mark articles with same SUBJECT as read, and return marked number.
7895 If optional argument UNMARK is positive, remove any kinds of marks.
7896 If optional argument UNMARK is negative, mark articles as unread instead."
7900 ((null unmark) ; Mark as read.
7903 (gnus-summary-mark-article-as-read gnus-killed-mark)
7904 (gnus-summary-show-thread) t)
7905 (gnus-summary-find-subject subject))
7906 (setq count (1+ count))))
7907 ((> unmark 0) ; Tick.
7910 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7911 (gnus-summary-show-thread) t)
7912 (gnus-summary-find-subject subject))
7913 (setq count (1+ count))))
7914 (t ; Mark as unread.
7917 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7918 (gnus-summary-show-thread) t)
7919 (gnus-summary-find-subject subject))
7920 (setq count (1+ count)))))
7921 (gnus-set-mode-line 'summary)
7922 ;; Return the number of marked articles.
7925 (defun gnus-summary-mark-as-processable (n &optional unmark)
7926 "Set the process mark on the next N articles.
7927 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7928 the process mark instead. The difference between N and the actual
7929 number of articles marked is returned."
7931 (let ((backward (< n 0))
7936 (gnus-summary-remove-process-mark
7937 (gnus-summary-article-number))
7938 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7939 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7942 (gnus-message 7 "No more articles"))
7943 (gnus-summary-recenter)
7944 (gnus-summary-position-point)
7947 (defun gnus-summary-unmark-as-processable (n)
7948 "Remove the process mark from the next N articles.
7949 If N is negative, unmark backward instead. The difference between N and
7950 the actual number of articles unmarked is returned."
7952 (gnus-summary-mark-as-processable n t))
7954 (defun gnus-summary-unmark-all-processable ()
7955 "Remove the process mark from all articles."
7958 (while gnus-newsgroup-processable
7959 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7960 (gnus-summary-position-point))
7962 (defun gnus-summary-mark-as-expirable (n)
7963 "Mark N articles forward as expirable.
7964 If N is negative, mark backward instead. The difference between N and
7965 the actual number of articles marked is returned."
7967 (gnus-summary-mark-forward n gnus-expirable-mark))
7969 (defun gnus-summary-mark-article-as-replied (article)
7970 "Mark ARTICLE replied and update the summary line."
7971 (push article gnus-newsgroup-replied)
7972 (let ((buffer-read-only nil))
7973 (when (gnus-summary-goto-subject article nil t)
7974 (gnus-summary-update-secondary-mark article))))
7976 (defun gnus-summary-set-bookmark (article)
7977 "Set a bookmark in current article."
7978 (interactive (list (gnus-summary-article-number)))
7979 (when (or (not (get-buffer gnus-article-buffer))
7980 (not gnus-current-article)
7981 (not gnus-article-current)
7982 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7983 (error "No current article selected"))
7984 ;; Remove old bookmark, if one exists.
7985 (let ((old (assq article gnus-newsgroup-bookmarks)))
7987 (setq gnus-newsgroup-bookmarks
7988 (delq old gnus-newsgroup-bookmarks))))
7989 ;; Set the new bookmark, which is on the form
7990 ;; (article-number . line-number-in-body).
7994 (set-buffer gnus-article-buffer)
7998 (goto-char (point-min))
7999 (search-forward "\n\n" nil t)
8002 gnus-newsgroup-bookmarks)
8003 (gnus-message 6 "A bookmark has been added to the current article."))
8005 (defun gnus-summary-remove-bookmark (article)
8006 "Remove the bookmark from the current article."
8007 (interactive (list (gnus-summary-article-number)))
8008 ;; Remove old bookmark, if one exists.
8009 (let ((old (assq article gnus-newsgroup-bookmarks)))
8012 (setq gnus-newsgroup-bookmarks
8013 (delq old gnus-newsgroup-bookmarks))
8014 (gnus-message 6 "Removed bookmark."))
8015 (gnus-message 6 "No bookmark in current article."))))
8017 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8018 (defun gnus-summary-mark-as-dormant (n)
8019 "Mark N articles forward as dormant.
8020 If N is negative, mark backward instead. The difference between N and
8021 the actual number of articles marked is returned."
8023 (gnus-summary-mark-forward n gnus-dormant-mark))
8025 (defun gnus-summary-set-process-mark (article)
8026 "Set the process mark on ARTICLE and update the summary line."
8027 (setq gnus-newsgroup-processable
8029 (delq article gnus-newsgroup-processable)))
8030 (when (gnus-summary-goto-subject article)
8031 (gnus-summary-show-thread)
8032 (gnus-summary-goto-subject article)
8033 (gnus-summary-update-secondary-mark article)))
8035 (defun gnus-summary-remove-process-mark (article)
8036 "Remove the process mark from ARTICLE and update the summary line."
8037 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8038 (when (gnus-summary-goto-subject article)
8039 (gnus-summary-show-thread)
8040 (gnus-summary-goto-subject article)
8041 (gnus-summary-update-secondary-mark article)))
8043 (defun gnus-summary-set-saved-mark (article)
8044 "Set the process mark on ARTICLE and update the summary line."
8045 (push article gnus-newsgroup-saved)
8046 (when (gnus-summary-goto-subject article)
8047 (gnus-summary-update-secondary-mark article)))
8049 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8050 "Mark N articles as read forwards.
8051 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8052 The difference between N and the actual number of articles marked is
8054 Iff NO-EXPIRE, auto-expiry will be inhibited."
8056 (gnus-summary-show-thread)
8057 (let ((backward (< n 0))
8058 (gnus-summary-goto-unread
8059 (and gnus-summary-goto-unread
8060 (not (eq gnus-summary-goto-unread 'never))
8061 (not (memq mark (list gnus-unread-mark
8062 gnus-ticked-mark gnus-dormant-mark)))))
8064 (mark (or mark gnus-del-mark)))
8066 (gnus-summary-mark-article nil mark no-expire)
8067 (zerop (gnus-summary-next-subject
8069 (and gnus-summary-goto-unread
8070 (not (eq gnus-summary-goto-unread 'never)))
8074 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8075 (gnus-summary-recenter)
8076 (gnus-summary-position-point)
8077 (gnus-set-mode-line 'summary)
8080 (defun gnus-summary-mark-article-as-read (mark)
8081 "Mark the current article quickly as read with MARK."
8082 (let ((article (gnus-summary-article-number)))
8083 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8084 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8085 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8086 (push (cons article mark) gnus-newsgroup-reads)
8087 ;; Possibly remove from cache, if that is used.
8088 (when gnus-use-cache
8089 (gnus-cache-enter-remove-article article))
8090 ;; Allow the backend to change the mark.
8091 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8092 ;; Check for auto-expiry.
8093 (when (and gnus-newsgroup-auto-expire
8094 (memq mark gnus-auto-expirable-marks))
8095 (setq mark gnus-expirable-mark)
8096 ;; Let the backend know about the mark change.
8097 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8098 (push article gnus-newsgroup-expirable))
8099 ;; Set the mark in the buffer.
8100 (gnus-summary-update-mark mark 'unread)
8103 (defun gnus-summary-mark-article-as-unread (mark)
8104 "Mark the current article quickly as unread with MARK."
8105 (let* ((article (gnus-summary-article-number))
8106 (old-mark (gnus-summary-article-mark article)))
8107 ;; Allow the backend to change the mark.
8108 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8109 (if (eq mark old-mark)
8113 (gnus-error 1 "Can't mark negative article numbers")
8115 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8116 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8117 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8118 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8119 (cond ((= mark gnus-ticked-mark)
8120 (push article gnus-newsgroup-marked))
8121 ((= mark gnus-dormant-mark)
8122 (push article gnus-newsgroup-dormant))
8124 (push article gnus-newsgroup-unreads)))
8125 (gnus-pull article gnus-newsgroup-reads)
8127 ;; See whether the article is to be put in the cache.
8129 (vectorp (gnus-summary-article-header article))
8131 (gnus-cache-possibly-enter-article
8132 gnus-newsgroup-name article
8133 (= mark gnus-ticked-mark)
8134 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8137 (gnus-summary-update-mark mark 'unread)
8140 (defun gnus-summary-mark-article (&optional article mark no-expire)
8141 "Mark ARTICLE with MARK. MARK can be any character.
8142 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8143 `??' (dormant) and `?E' (expirable).
8144 If MARK is nil, then the default character `?r' is used.
8145 If ARTICLE is nil, then the article on the current line will be
8147 Iff NO-EXPIRE, auto-expiry will be inhibited."
8148 ;; The mark might be a string.
8149 (when (stringp mark)
8150 (setq mark (aref mark 0)))
8151 ;; If no mark is given, then we check auto-expiring.
8153 (setq mark gnus-del-mark))
8154 (when (and (not no-expire)
8155 gnus-newsgroup-auto-expire
8156 (memq mark gnus-auto-expirable-marks))
8157 (setq mark gnus-expirable-mark))
8158 (let ((article (or article (gnus-summary-article-number)))
8159 (old-mark (gnus-summary-article-mark article)))
8160 ;; Allow the backend to change the mark.
8161 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8162 (if (eq mark old-mark)
8165 (error "No article on current line"))
8166 (if (not (if (or (= mark gnus-unread-mark)
8167 (= mark gnus-ticked-mark)
8168 (= mark gnus-dormant-mark))
8169 (gnus-mark-article-as-unread article mark)
8170 (gnus-mark-article-as-read article mark)))
8172 ;; See whether the article is to be put in the cache.
8174 (not (= mark gnus-canceled-mark))
8175 (vectorp (gnus-summary-article-header article))
8177 (gnus-cache-possibly-enter-article
8178 gnus-newsgroup-name article
8179 (= mark gnus-ticked-mark)
8180 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8182 (when (gnus-summary-goto-subject article nil t)
8183 (let ((buffer-read-only nil))
8184 (gnus-summary-show-thread)
8186 (gnus-summary-update-mark mark 'unread)
8189 (defun gnus-summary-update-secondary-mark (article)
8190 "Update the secondary (read, process, cache) mark."
8191 (gnus-summary-update-mark
8192 (cond ((memq article gnus-newsgroup-processable)
8194 ((memq article gnus-newsgroup-cached)
8196 ((memq article gnus-newsgroup-replied)
8198 ((memq article gnus-newsgroup-saved)
8200 (t gnus-unread-mark))
8202 (when (gnus-visual-p 'summary-highlight 'highlight)
8203 (gnus-run-hooks 'gnus-summary-update-hook))
8206 (defun gnus-summary-update-mark (mark type)
8207 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8208 (buffer-read-only nil))
8209 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8211 (when (looking-at "\r")
8213 (when (<= (+ forward (point)) (point-max))
8214 ;; Go to the right position on the line.
8215 (goto-char (+ forward (point)))
8216 ;; Replace the old mark with the new mark.
8217 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8218 ;; Optionally update the marks by some user rule.
8219 (when (eq type 'unread)
8221 (gnus-data-find (gnus-summary-article-number)) mark)
8222 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8224 (defun gnus-mark-article-as-read (article &optional mark)
8225 "Enter ARTICLE in the pertinent lists and remove it from others."
8226 ;; Make the article expirable.
8227 (let ((mark (or mark gnus-del-mark)))
8228 (if (= mark gnus-expirable-mark)
8229 (push article gnus-newsgroup-expirable)
8230 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8231 ;; Remove from unread and marked lists.
8232 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8233 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8234 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8235 (push (cons article mark) gnus-newsgroup-reads)
8236 ;; Possibly remove from cache, if that is used.
8237 (when gnus-use-cache
8238 (gnus-cache-enter-remove-article article))
8241 (defun gnus-mark-article-as-unread (article &optional mark)
8242 "Enter ARTICLE in the pertinent lists and remove it from others."
8243 (let ((mark (or mark gnus-ticked-mark)))
8246 (gnus-error 1 "Can't mark negative article numbers")
8248 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8249 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8250 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8251 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8253 ;; Unsuppress duplicates?
8254 (when gnus-suppress-duplicates
8255 (gnus-dup-unsuppress-article article))
8257 (cond ((= mark gnus-ticked-mark)
8258 (push article gnus-newsgroup-marked))
8259 ((= mark gnus-dormant-mark)
8260 (push article gnus-newsgroup-dormant))
8262 (push article gnus-newsgroup-unreads)))
8263 (gnus-pull article gnus-newsgroup-reads)
8266 (defalias 'gnus-summary-mark-as-unread-forward
8267 'gnus-summary-tick-article-forward)
8268 (make-obsolete 'gnus-summary-mark-as-unread-forward
8269 'gnus-summary-tick-article-forward)
8270 (defun gnus-summary-tick-article-forward (n)
8271 "Tick N articles forwards.
8272 If N is negative, tick backwards instead.
8273 The difference between N and the number of articles ticked is returned."
8275 (gnus-summary-mark-forward n gnus-ticked-mark))
8277 (defalias 'gnus-summary-mark-as-unread-backward
8278 'gnus-summary-tick-article-backward)
8279 (make-obsolete 'gnus-summary-mark-as-unread-backward
8280 'gnus-summary-tick-article-backward)
8281 (defun gnus-summary-tick-article-backward (n)
8282 "Tick N articles backwards.
8283 The difference between N and the number of articles ticked is returned."
8285 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8287 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8288 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8289 (defun gnus-summary-tick-article (&optional article clear-mark)
8290 "Mark current article as unread.
8291 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8292 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8294 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8297 (defun gnus-summary-mark-as-read-forward (n)
8298 "Mark N articles as read forwards.
8299 If N is negative, mark backwards instead.
8300 The difference between N and the actual number of articles marked is
8303 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8305 (defun gnus-summary-mark-as-read-backward (n)
8306 "Mark the N articles as read backwards.
8307 The difference between N and the actual number of articles marked is
8310 (gnus-summary-mark-forward
8311 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8313 (defun gnus-summary-mark-as-read (&optional article mark)
8314 "Mark current article as read.
8315 ARTICLE specifies the article to be marked as read.
8316 MARK specifies a string to be inserted at the beginning of the line."
8317 (gnus-summary-mark-article article mark))
8319 (defun gnus-summary-clear-mark-forward (n)
8320 "Clear marks from N articles forward.
8321 If N is negative, clear backward instead.
8322 The difference between N and the number of marks cleared is returned."
8324 (gnus-summary-mark-forward n gnus-unread-mark))
8326 (defun gnus-summary-clear-mark-backward (n)
8327 "Clear marks from N articles backward.
8328 The difference between N and the number of marks cleared is returned."
8330 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8332 (defun gnus-summary-mark-unread-as-read ()
8333 "Intended to be used by `gnus-summary-mark-article-hook'."
8334 (when (memq gnus-current-article gnus-newsgroup-unreads)
8335 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8337 (defun gnus-summary-mark-read-and-unread-as-read ()
8338 "Intended to be used by `gnus-summary-mark-article-hook'."
8339 (let ((mark (gnus-summary-article-mark)))
8340 (when (or (gnus-unread-mark-p mark)
8341 (gnus-read-mark-p mark))
8342 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8344 (defun gnus-summary-mark-region-as-read (point mark all)
8345 "Mark all unread articles between point and mark as read.
8346 If given a prefix, mark all articles between point and mark as read,
8347 even ticked and dormant ones."
8348 (interactive "r\nP")
8357 (memq (setq article (gnus-summary-article-number))
8358 gnus-newsgroup-unreads))
8359 (gnus-summary-mark-article article gnus-del-mark))
8361 (gnus-summary-find-next))))))
8363 (defun gnus-summary-mark-below (score mark)
8364 "Mark articles with score less than SCORE with MARK."
8365 (interactive "P\ncMark: ")
8366 (setq score (if score
8367 (prefix-numeric-value score)
8368 (or gnus-summary-default-score 0)))
8370 (set-buffer gnus-summary-buffer)
8371 (goto-char (point-min))
8374 (and (< (gnus-summary-article-score) score)
8375 (gnus-summary-mark-article nil mark))
8376 (gnus-summary-find-next)))))
8378 (defun gnus-summary-kill-below (&optional score)
8379 "Mark articles with score below SCORE as read."
8381 (gnus-summary-mark-below score gnus-killed-mark))
8383 (defun gnus-summary-clear-above (&optional score)
8384 "Clear all marks from articles with score above SCORE."
8386 (gnus-summary-mark-above score gnus-unread-mark))
8388 (defun gnus-summary-tick-above (&optional score)
8389 "Tick all articles with score above SCORE."
8391 (gnus-summary-mark-above score gnus-ticked-mark))
8393 (defun gnus-summary-mark-above (score mark)
8394 "Mark articles with score over SCORE with MARK."
8395 (interactive "P\ncMark: ")
8396 (setq score (if score
8397 (prefix-numeric-value score)
8398 (or gnus-summary-default-score 0)))
8400 (set-buffer gnus-summary-buffer)
8401 (goto-char (point-min))
8403 (when (> (gnus-summary-article-score) score)
8404 (gnus-summary-mark-article nil mark))
8406 (gnus-summary-find-next)))))
8408 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8409 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8410 (defun gnus-summary-limit-include-expunged (&optional no-error)
8411 "Display all the hidden articles that were expunged for low scores."
8413 (let ((buffer-read-only nil))
8414 (let ((scored gnus-newsgroup-scored)
8417 (unless (gnus-summary-goto-subject (caar scored))
8418 (and (setq h (gnus-summary-article-header (caar scored)))
8419 (< (cdar scored) gnus-summary-expunge-below)
8421 (setq scored (cdr scored)))
8423 (when (not no-error)
8424 (error "No expunged articles hidden"))
8425 (goto-char (point-min))
8426 (gnus-summary-prepare-unthreaded (nreverse headers))
8427 (goto-char (point-min))
8428 (gnus-summary-position-point)
8431 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8432 "Mark all unread articles in this newsgroup as read.
8433 If prefix argument ALL is non-nil, ticked and dormant articles will
8434 also be marked as read.
8435 If QUIETLY is non-nil, no questions will be asked.
8436 If TO-HERE is non-nil, it should be a point in the buffer. All
8437 articles before this point will be marked as read.
8438 Note that this function will only catch up the unread article
8439 in the current summary buffer limitation.
8440 The number of articles marked as read is returned."
8445 (not gnus-interactive-catchup) ;Without confirmation?
8449 "Mark absolutely all articles as read? "
8450 "Mark all unread articles as read? ")))
8452 (not gnus-newsgroup-adaptive)
8453 (not gnus-newsgroup-auto-expire)
8454 (not gnus-suppress-duplicates)
8455 (or (not gnus-use-cache)
8456 (eq gnus-use-cache 'passive)))
8459 (setq gnus-newsgroup-marked nil
8460 gnus-newsgroup-dormant nil))
8461 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8462 ;; We actually mark all articles as canceled, which we
8463 ;; have to do when using auto-expiry or adaptive scoring.
8464 (gnus-summary-show-all-threads)
8465 (when (gnus-summary-first-subject (not all) t)
8467 (if to-here (< (point) to-here) t)
8468 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8469 (gnus-summary-find-next (not all) nil nil t))))
8470 (gnus-set-mode-line 'summary))
8472 (gnus-summary-position-point)))
8474 (defun gnus-summary-catchup-to-here (&optional all)
8475 "Mark all unticked articles before the current one as read.
8476 If ALL is non-nil, also mark ticked and dormant articles as read."
8479 (gnus-save-hidden-threads
8480 (let ((beg (point)))
8481 ;; We check that there are unread articles.
8482 (when (or all (gnus-summary-find-prev))
8483 (gnus-summary-catchup all t beg)))))
8484 (gnus-summary-position-point))
8486 (defun gnus-summary-catchup-all (&optional quietly)
8487 "Mark all articles in this newsgroup as read."
8489 (gnus-summary-catchup t quietly))
8491 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8492 "Mark all unread articles in this group as read, then exit.
8493 If prefix argument ALL is non-nil, all articles are marked as read."
8495 (when (gnus-summary-catchup all quietly nil 'fast)
8496 ;; Select next newsgroup or exit.
8497 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8498 (eq gnus-auto-select-next 'quietly))
8499 (gnus-summary-next-group nil)
8500 (gnus-summary-exit))))
8502 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8503 "Mark all articles in this newsgroup as read, and then exit."
8505 (gnus-summary-catchup-and-exit t quietly))
8507 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8508 "Mark all articles in this group as read and select the next group.
8509 If given a prefix, mark all articles, unread as well as ticked, as
8513 (gnus-summary-catchup all))
8514 (gnus-summary-next-group))
8516 ;; Thread-based commands.
8518 (defun gnus-summary-articles-in-thread (&optional article)
8519 "Return a list of all articles in the current thread.
8520 If ARTICLE is non-nil, return all articles in the thread that starts
8522 (let* ((article (or article (gnus-summary-article-number)))
8523 (data (gnus-data-find-list article))
8524 (top-level (gnus-data-level (car data)))
8526 (cond ((null gnus-thread-operation-ignore-subject)
8527 (gnus-simplify-subject-re
8528 (mail-header-subject (gnus-data-header (car data)))))
8529 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8530 (gnus-simplify-subject-fuzzy
8531 (mail-header-subject (gnus-data-header (car data)))))
8533 (end-point (save-excursion
8534 (if (gnus-summary-go-to-next-thread)
8535 (point) (point-max))))
8538 (< (gnus-data-pos (car data)) end-point))
8539 (when (or (not top-subject)
8540 (string= top-subject
8541 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8542 (gnus-simplify-subject-fuzzy
8543 (mail-header-subject
8544 (gnus-data-header (car data))))
8545 (gnus-simplify-subject-re
8546 (mail-header-subject
8547 (gnus-data-header (car data)))))))
8548 (push (gnus-data-number (car data)) articles))
8549 (unless (and (setq data (cdr data))
8550 (> (gnus-data-level (car data)) top-level))
8552 ;; Return the list of articles.
8553 (nreverse articles)))
8555 (defun gnus-summary-rethread-current ()
8556 "Rethread the thread the current article is part of."
8558 (let* ((gnus-show-threads t)
8559 (article (gnus-summary-article-number))
8560 (id (mail-header-id (gnus-summary-article-header)))
8561 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8563 (error "No article on the current line"))
8564 (gnus-rebuild-thread id)
8565 (gnus-summary-goto-subject article)))
8567 (defun gnus-summary-reparent-thread ()
8568 "Make the current article child of the marked (or previous) article.
8570 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8571 is non-nil or the Subject: of both articles are the same."
8573 (unless (not (gnus-group-read-only-p))
8574 (error "The current newsgroup does not support article editing"))
8575 (unless (<= (length gnus-newsgroup-processable) 1)
8576 (error "No more than one article may be marked"))
8577 (save-window-excursion
8578 (let ((gnus-article-buffer " *reparent*")
8579 (current-article (gnus-summary-article-number))
8580 ;; First grab the marked article, otherwise one line up.
8581 (parent-article (if (not (null gnus-newsgroup-processable))
8582 (car gnus-newsgroup-processable)
8584 (if (eq (forward-line -1) 0)
8585 (gnus-summary-article-number)
8586 (error "Beginning of summary buffer"))))))
8587 (unless (not (eq current-article parent-article))
8588 (error "An article may not be self-referential"))
8589 (let ((message-id (mail-header-id
8590 (gnus-summary-article-header parent-article))))
8591 (unless (and message-id (not (equal message-id "")))
8592 (error "No message-id in desired parent"))
8593 (gnus-with-article current-article
8594 (goto-char (point-min))
8595 (if (re-search-forward "^References: " nil t)
8597 (re-search-forward "^[^ \t]" nil t)
8600 (insert " " message-id))
8601 (insert "References: " message-id "\n")))
8602 (set-buffer gnus-summary-buffer)
8603 (gnus-summary-unmark-all-processable)
8604 (gnus-summary-update-article current-article)
8605 (gnus-summary-rethread-current)
8606 (gnus-message 3 "Article %d is now the child of article %d"
8607 current-article parent-article)))))
8609 (defun gnus-summary-toggle-threads (&optional arg)
8610 "Toggle showing conversation threads.
8611 If ARG is positive number, turn showing conversation threads on."
8613 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8614 (setq gnus-show-threads
8615 (if (null arg) (not gnus-show-threads)
8616 (> (prefix-numeric-value arg) 0)))
8617 (gnus-summary-prepare)
8618 (gnus-summary-goto-subject current)
8619 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8620 (gnus-summary-position-point)))
8622 (defun gnus-summary-show-all-threads ()
8626 (let ((buffer-read-only nil))
8627 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8628 (gnus-summary-position-point))
8630 (defun gnus-summary-show-thread ()
8631 "Show thread subtrees.
8632 Returns nil if no thread was there to be shown."
8634 (let ((buffer-read-only nil)
8636 ;; first goto end then to beg, to have point at beg after let
8637 (end (progn (end-of-line) (point)))
8638 (beg (progn (beginning-of-line) (point))))
8640 ;; Any hidden lines here?
8641 (search-forward "\r" end t)
8642 (subst-char-in-region beg end ?\^M ?\n t)
8644 (gnus-summary-position-point))))
8646 (defun gnus-summary-hide-all-threads ()
8647 "Hide all thread subtrees."
8650 (goto-char (point-min))
8651 (gnus-summary-hide-thread)
8652 (while (zerop (gnus-summary-next-thread 1 t))
8653 (gnus-summary-hide-thread)))
8654 (gnus-summary-position-point))
8656 (defun gnus-summary-hide-thread ()
8657 "Hide thread subtrees.
8658 Returns nil if no threads were there to be hidden."
8660 (let ((buffer-read-only nil)
8662 (article (gnus-summary-article-number)))
8664 ;; Go forward until either the buffer ends or the subthread
8666 (when (and (not (eobp))
8667 (or (zerop (gnus-summary-next-thread 1 t))
8668 (goto-char (point-max))))
8670 (if (and (> (point) start)
8671 (search-backward "\n" start t))
8673 (subst-char-in-region start (point) ?\n ?\^M)
8674 (gnus-summary-goto-subject article))
8678 (defun gnus-summary-go-to-next-thread (&optional previous)
8679 "Go to the same level (or less) next thread.
8680 If PREVIOUS is non-nil, go to previous thread instead.
8681 Return the article number moved to, or nil if moving was impossible."
8682 (let ((level (gnus-summary-thread-level))
8683 (way (if previous -1 1))
8686 (while (and (not (eobp))
8687 (< level (gnus-summary-thread-level)))
8695 (gnus-summary-article-number)
8698 (defun gnus-summary-next-thread (n &optional silent)
8699 "Go to the same level next N'th thread.
8700 If N is negative, search backward instead.
8701 Returns the difference between N and the number of skips actually
8704 If SILENT, don't output messages."
8706 (let ((backward (< n 0))
8709 (gnus-summary-go-to-next-thread backward))
8712 (gnus-summary-position-point))
8713 (when (and (not silent) (/= 0 n))
8714 (gnus-message 7 "No more threads"))
8717 (defun gnus-summary-prev-thread (n)
8718 "Go to the same level previous N'th thread.
8719 Returns the difference between N and the number of skips actually
8722 (gnus-summary-next-thread (- n)))
8724 (defun gnus-summary-go-down-thread ()
8725 "Go down one level in the current thread."
8726 (let ((children (gnus-summary-article-children)))
8728 (gnus-summary-goto-subject (car children)))))
8730 (defun gnus-summary-go-up-thread ()
8731 "Go up one level in the current thread."
8732 (let ((parent (gnus-summary-article-parent)))
8734 (gnus-summary-goto-subject parent))))
8736 (defun gnus-summary-down-thread (n)
8737 "Go down thread N steps.
8738 If N is negative, go up instead.
8739 Returns the difference between N and how many steps down that were
8745 (if up (gnus-summary-go-up-thread)
8746 (gnus-summary-go-down-thread)))
8748 (gnus-summary-position-point)
8750 (gnus-message 7 "Can't go further"))
8753 (defun gnus-summary-up-thread (n)
8754 "Go up thread N steps.
8755 If N is negative, go up instead.
8756 Returns the difference between N and how many steps down that were
8759 (gnus-summary-down-thread (- n)))
8761 (defun gnus-summary-top-thread ()
8762 "Go to the top of the thread."
8764 (while (gnus-summary-go-up-thread))
8765 (gnus-summary-article-number))
8767 (defun gnus-summary-kill-thread (&optional unmark)
8768 "Mark articles under current thread as read.
8769 If the prefix argument is positive, remove any kinds of marks.
8770 If the prefix argument is negative, tick articles instead."
8773 (setq unmark (prefix-numeric-value unmark)))
8774 (let ((articles (gnus-summary-articles-in-thread)))
8776 ;; Expand the thread.
8777 (gnus-summary-show-thread)
8778 ;; Mark all the articles.
8780 (gnus-summary-goto-subject (car articles))
8781 (cond ((null unmark)
8782 (gnus-summary-mark-article-as-read gnus-killed-mark))
8784 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8786 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8787 (setq articles (cdr articles))))
8788 ;; Hide killed subtrees.
8790 gnus-thread-hide-killed
8791 (gnus-summary-hide-thread))
8792 ;; If marked as read, go to next unread subject.
8794 ;; Go to next unread subject.
8795 (gnus-summary-next-subject 1 t)))
8796 (gnus-set-mode-line 'summary))
8798 ;; Summary sorting commands
8800 (defun gnus-summary-sort-by-number (&optional reverse)
8801 "Sort the summary buffer by article number.
8802 Argument REVERSE means reverse order."
8804 (gnus-summary-sort 'number reverse))
8806 (defun gnus-summary-sort-by-author (&optional reverse)
8807 "Sort the summary buffer by author name alphabetically.
8808 If case-fold-search is non-nil, case of letters is ignored.
8809 Argument REVERSE means reverse order."
8811 (gnus-summary-sort 'author reverse))
8813 (defun gnus-summary-sort-by-subject (&optional reverse)
8814 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8815 If case-fold-search is non-nil, case of letters is ignored.
8816 Argument REVERSE means reverse order."
8818 (gnus-summary-sort 'subject reverse))
8820 (defun gnus-summary-sort-by-date (&optional reverse)
8821 "Sort the summary buffer by date.
8822 Argument REVERSE means reverse order."
8824 (gnus-summary-sort 'date reverse))
8826 (defun gnus-summary-sort-by-score (&optional reverse)
8827 "Sort the summary buffer by score.
8828 Argument REVERSE means reverse order."
8830 (gnus-summary-sort 'score reverse))
8832 (defun gnus-summary-sort-by-lines (&optional reverse)
8833 "Sort the summary buffer by the number of lines.
8834 Argument REVERSE means reverse order."
8836 (gnus-summary-sort 'lines reverse))
8838 (defun gnus-summary-sort-by-chars (&optional reverse)
8839 "Sort the summary buffer by article length.
8840 Argument REVERSE means reverse order."
8842 (gnus-summary-sort 'chars reverse))
8844 (defun gnus-summary-sort (predicate reverse)
8845 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8846 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8847 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8848 (gnus-thread-sort-functions
8853 (gnus-article-sort-functions
8859 (gnus-summary-prepare-hook nil))
8860 ;; We do the sorting by regenerating the threads.
8861 (gnus-summary-prepare)
8862 ;; Hide subthreads if needed.
8863 (when (and gnus-show-threads gnus-thread-hide-subtree)
8864 (gnus-summary-hide-all-threads))))
8866 ;; Summary saving commands.
8868 (defun gnus-summary-save-article (&optional n not-saved)
8869 "Save the current article using the default saver function.
8870 If N is a positive number, save the N next articles.
8871 If N is a negative number, save the N previous articles.
8872 If N is nil and any articles have been marked with the process mark,
8873 save those articles instead.
8874 The variable `gnus-default-article-saver' specifies the saver function."
8876 (let* ((articles (gnus-summary-work-articles n))
8877 (save-buffer (save-excursion
8878 (nnheader-set-temp-buffer " *Gnus Save*")))
8879 (num (length articles))
8881 (dolist (article articles)
8882 (setq header (gnus-summary-article-header article))
8883 (if (not (vectorp header))
8884 ;; This is a pseudo-article.
8885 (if (assq 'name header)
8886 (gnus-copy-file (cdr (assq 'name header)))
8887 (gnus-message 1 "Article %d is unsaveable" article))
8888 ;; This is a real article.
8889 (save-window-excursion
8890 (gnus-summary-select-article t nil nil article))
8892 (set-buffer save-buffer)
8894 (insert-buffer-substring gnus-original-article-buffer))
8895 (setq file (gnus-article-save save-buffer file num))
8896 (gnus-summary-remove-process-mark article)
8898 (gnus-summary-set-saved-mark article))))
8899 (gnus-kill-buffer save-buffer)
8900 (gnus-summary-position-point)
8901 (gnus-set-mode-line 'summary)
8904 (defun gnus-summary-pipe-output (&optional arg)
8905 "Pipe the current article to a subprocess.
8906 If N is a positive number, pipe the N next articles.
8907 If N is a negative number, pipe the N previous articles.
8908 If N is nil and any articles have been marked with the process mark,
8909 pipe those articles instead."
8911 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8912 (gnus-summary-save-article arg t))
8913 (gnus-configure-windows 'pipe))
8915 (defun gnus-summary-save-article-mail (&optional arg)
8916 "Append the current article to an mail file.
8917 If N is a positive number, save the N next articles.
8918 If N is a negative number, save the N previous articles.
8919 If N is nil and any articles have been marked with the process mark,
8920 save those articles instead."
8922 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8923 (gnus-summary-save-article arg)))
8925 (defun gnus-summary-save-article-rmail (&optional arg)
8926 "Append the current article to an rmail file.
8927 If N is a positive number, save the N next articles.
8928 If N is a negative number, save the N previous articles.
8929 If N is nil and any articles have been marked with the process mark,
8930 save those articles instead."
8932 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8933 (gnus-summary-save-article arg)))
8935 (defun gnus-summary-save-article-file (&optional arg)
8936 "Append the current article to a file.
8937 If N is a positive number, save the N next articles.
8938 If N is a negative number, save the N previous articles.
8939 If N is nil and any articles have been marked with the process mark,
8940 save those articles instead."
8942 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8943 (gnus-summary-save-article arg)))
8945 (defun gnus-summary-write-article-file (&optional arg)
8946 "Write the current article to a file, deleting the previous file.
8947 If N is a positive number, save the N next articles.
8948 If N is a negative number, save the N previous articles.
8949 If N is nil and any articles have been marked with the process mark,
8950 save those articles instead."
8952 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8953 (gnus-summary-save-article arg)))
8955 (defun gnus-summary-save-article-body-file (&optional arg)
8956 "Append the current article body to a file.
8957 If N is a positive number, save the N next articles.
8958 If N is a negative number, save the N previous articles.
8959 If N is nil and any articles have been marked with the process mark,
8960 save those articles instead."
8962 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8963 (gnus-summary-save-article arg)))
8965 (defun gnus-summary-pipe-message (program)
8966 "Pipe the current article through PROGRAM."
8967 (interactive "sProgram: ")
8968 (gnus-summary-select-article)
8969 (let ((mail-header-separator ""))
8970 (gnus-eval-in-buffer-window gnus-article-buffer
8973 (let ((start (window-start))
8975 (message-pipe-buffer-body program)
8976 (set-window-start (get-buffer-window (current-buffer)) start))))))
8978 (defun gnus-get-split-value (methods)
8979 "Return a value based on the split METHODS."
8980 (let (split-name method result match)
8983 (set-buffer gnus-original-article-buffer)
8985 (nnheader-narrow-to-headers)
8987 (goto-char (point-min))
8988 (setq method (pop methods))
8989 (setq match (car method))
8992 ;; Regular expression.
8994 (re-search-forward match nil t)))
8995 ((gnus-functionp match)
8999 (setq result (funcall match gnus-newsgroup-name))))
9004 (setq result (eval match)))))
9005 (setq split-name (append (cdr method) split-name))
9006 (cond ((stringp result)
9007 (push (expand-file-name
9008 result gnus-article-save-directory)
9011 (setq split-name (append result split-name)))))))))
9012 (nreverse split-name)))
9014 (defun gnus-valid-move-group-p (group)
9017 (symbol-value group)
9018 (gnus-get-function (gnus-find-method-for-group
9019 (symbol-name group)) 'request-accept-article t)))
9021 (defun gnus-read-move-group-name (prompt default articles prefix)
9022 "Read a group name."
9023 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9024 (minibuffer-confirm-incomplete nil) ; XEmacs
9028 (if (> (length articles) 1)
9029 (format "these %d articles" (length articles))
9034 (gnus-completing-read default prom
9036 'gnus-valid-move-group-p
9038 'gnus-group-history))
9039 ((= 1 (length split-name))
9040 (gnus-completing-read (car split-name) prom
9042 'gnus-valid-move-group-p
9044 'gnus-group-history))
9046 (gnus-completing-read nil prom
9047 (mapcar (lambda (el) (list el))
9048 (nreverse split-name))
9050 'gnus-group-history))))
9051 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9053 (if (or (string= to-newsgroup "")
9054 (string= to-newsgroup prefix))
9055 (setq to-newsgroup default))
9056 (unless to-newsgroup
9057 (error "No group name entered"))
9058 (or (gnus-active to-newsgroup)
9059 (gnus-activate-group to-newsgroup nil nil to-method)
9060 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9062 (or (and (gnus-request-create-group to-newsgroup to-method)
9063 (gnus-activate-group
9064 to-newsgroup nil nil to-method)
9065 (gnus-subscribe-group to-newsgroup))
9066 (error "Couldn't create group %s" to-newsgroup)))
9067 (error "No such group: %s" to-newsgroup)))
9070 (defun gnus-summary-save-parts (type dir n &optional reverse)
9071 "Save parts matching TYPE to DIR.
9072 If REVERSE, save parts that do not match TYPE."
9074 (list (read-string "Save parts of type: " "image/.*")
9075 (read-file-name "Save to directory: " nil nil t)
9076 current-prefix-arg))
9077 (gnus-summary-iterate n
9078 (let ((gnus-display-mime-function nil)
9079 (gnus-inhibit-treatment t))
9080 (gnus-summary-select-article))
9082 (set-buffer gnus-article-buffer)
9083 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9085 (gnus-summary-save-parts-1 type dir handles reverse)
9086 (mm-destroy-parts handles))))))
9088 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9089 (if (stringp (car handle))
9090 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9093 (not (string-match type (mm-handle-media-type handle)))
9094 (string-match type (mm-handle-media-type handle)))
9095 (let ((file (expand-file-name
9096 (file-name-nondirectory
9098 (mail-content-type-get
9099 (mm-handle-disposition handle) 'filename)
9100 (concat gnus-newsgroup-name "." gnus-current-article)))
9102 (unless (file-exists-p file)
9103 (mm-save-part-to-file handle file))))))
9105 ;; Summary extract commands
9107 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9108 (let ((buffer-read-only nil)
9109 (article (gnus-summary-article-number))
9111 (unless (gnus-summary-goto-subject article)
9112 (error "No such article: %d" article))
9113 (gnus-summary-position-point)
9114 ;; If all commands are to be bunched up on one line, we collect
9116 (unless gnus-view-pseudos-separately
9117 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9120 (setq action (cdr (assq 'action (car ps))))
9121 (setq files (list (cdr (assq 'name (car ps)))))
9122 (while (and ps (cdr ps)
9123 (string= (or action "1")
9124 (or (cdr (assq 'action (cadr ps))) "2")))
9125 (push (cdr (assq 'name (cadr ps))) files)
9126 (setcdr ps (cddr ps)))
9128 (when (not (string-match "%s" action))
9131 (when (assq 'execute (car ps))
9132 (setcdr (assq 'execute (car ps))
9133 (funcall (if (string-match "%s" action)
9142 (setq ps (cdr ps)))))
9143 (if (and gnus-view-pseudos (not not-view))
9145 (when (assq 'execute (car pslist))
9146 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9147 (eq gnus-view-pseudos 'not-confirm)))
9148 (setq pslist (cdr pslist)))
9151 (setq after-article (or (cdr (assq 'article (car pslist)))
9152 (gnus-summary-article-number)))
9153 (gnus-summary-goto-subject after-article)
9156 (insert " " (file-name-nondirectory
9157 (cdr (assq 'name (car pslist))))
9158 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9160 (forward-line -1) ; back to `b'
9161 (gnus-add-text-properties
9162 b (1- e) (list 'gnus-number gnus-reffed-article-number
9163 gnus-mouse-face-prop gnus-mouse-face))
9165 after-article gnus-reffed-article-number
9166 gnus-unread-mark b (car pslist) 0 (- e b))
9167 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9168 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9169 (setq pslist (cdr pslist)))))))
9171 (defun gnus-pseudos< (p1 p2)
9172 (let ((c1 (cdr (assq 'action p1)))
9173 (c2 (cdr (assq 'action p2))))
9174 (and c1 c2 (string< c1 c2))))
9176 (defun gnus-request-pseudo-article (props)
9177 (cond ((assq 'execute props)
9178 (gnus-execute-command (cdr (assq 'execute props)))))
9179 (let ((gnus-current-article (gnus-summary-article-number)))
9180 (gnus-run-hooks 'gnus-mark-article-hook)))
9182 (defun gnus-execute-command (command &optional automatic)
9184 (gnus-article-setup-buffer)
9185 (set-buffer gnus-article-buffer)
9186 (setq buffer-read-only nil)
9187 (let ((command (if automatic command
9188 (read-string "Command: " (cons command 0)))))
9190 (insert "$ " command "\n\n")
9191 (if gnus-view-pseudo-asynchronously
9192 (start-process "gnus-execute" (current-buffer) shell-file-name
9193 shell-command-switch command)
9194 (call-process shell-file-name nil t nil
9195 shell-command-switch command)))))
9197 ;; Summary kill commands.
9199 (defun gnus-summary-edit-global-kill (article)
9200 "Edit the \"global\" kill file."
9201 (interactive (list (gnus-summary-article-number)))
9202 (gnus-group-edit-global-kill article))
9204 (defun gnus-summary-edit-local-kill ()
9205 "Edit a local kill file applied to the current newsgroup."
9207 (setq gnus-current-headers (gnus-summary-article-header))
9208 (gnus-group-edit-local-kill
9209 (gnus-summary-article-number) gnus-newsgroup-name))
9213 (defun gnus-read-header (id &optional header)
9214 "Read the headers of article ID and enter them into the Gnus system."
9215 (let ((group gnus-newsgroup-name)
9216 (gnus-override-method
9218 gnus-override-method
9219 (and (gnus-news-group-p gnus-newsgroup-name)
9220 (car (gnus-refer-article-methods)))))
9222 ;; First we check to see whether the header in question is already
9225 ;; This is a Message-ID.
9226 (setq header (or header (gnus-id-to-header id)))
9227 ;; This is an article number.
9228 (setq header (or header (gnus-summary-article-header id))))
9230 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9231 ;; We have found the header.
9233 ;; If this is a sparse article, we have to nix out its
9234 ;; previous entry in the thread hashtb.
9236 (gnus-summary-article-sparse-p (mail-header-number header)))
9237 (let* ((parent (gnus-parent-id (mail-header-references header)))
9238 (thread (and parent (gnus-id-to-thread parent))))
9240 (delq (assq header thread) thread))))
9241 ;; We have to really fetch the header to this article.
9243 (set-buffer nntp-server-buffer)
9244 (when (setq where (gnus-request-head id group))
9245 (nnheader-fold-continuation-lines)
9246 (goto-char (point-max))
9248 (goto-char (point-min))
9252 ((cdr where) (cdr where))
9253 (header (mail-header-number header))
9254 (t gnus-reffed-article-number))
9256 (insert " Article retrieved.\n"))
9258 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9259 () ; Malformed head.
9260 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9261 (when (and (stringp id)
9262 (not (string= (gnus-group-real-name group)
9264 ;; If we fetched by Message-ID and the article came
9265 ;; from a different group, we fudge some bogus article
9266 ;; numbers for this article.
9267 (mail-header-set-number header gnus-reffed-article-number))
9269 (set-buffer gnus-summary-buffer)
9270 (decf gnus-reffed-article-number)
9271 (gnus-remove-header (mail-header-number header))
9272 (push header gnus-newsgroup-headers)
9273 (setq gnus-current-headers header)
9274 (push (mail-header-number header) gnus-newsgroup-limit)))
9277 (defun gnus-remove-header (number)
9278 "Remove header NUMBER from `gnus-newsgroup-headers'."
9279 (if (and gnus-newsgroup-headers
9280 (= number (mail-header-number (car gnus-newsgroup-headers))))
9281 (pop gnus-newsgroup-headers)
9282 (let ((headers gnus-newsgroup-headers))
9283 (while (and (cdr headers)
9284 (not (= number (mail-header-number (cadr headers)))))
9287 (setcdr headers (cddr headers))))))
9290 ;;; summary highlights
9293 (defun gnus-highlight-selected-summary ()
9294 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9295 ;; Highlight selected article in summary buffer
9296 (when gnus-summary-selected-face
9298 (let* ((beg (progn (beginning-of-line) (point)))
9299 (end (progn (end-of-line) (point)))
9300 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9301 (from (if (get-text-property beg gnus-mouse-face-prop)
9303 (or (next-single-property-change
9304 beg gnus-mouse-face-prop nil end)
9309 (or (next-single-property-change
9310 from gnus-mouse-face-prop nil end)
9312 ;; If no mouse-face prop on line we will have to = from = end,
9313 ;; so we highlight the entire line instead.
9314 (when (= (+ to 2) from)
9317 (if gnus-newsgroup-selected-overlay
9318 ;; Move old overlay.
9320 gnus-newsgroup-selected-overlay from to (current-buffer))
9321 ;; Create new overlay.
9323 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9324 'face gnus-summary-selected-face))))))
9326 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9327 (defun gnus-summary-highlight-line ()
9328 "Highlight current line according to `gnus-summary-highlight'."
9329 (let* ((list gnus-summary-highlight)
9331 (end (progn (end-of-line) (point)))
9332 ;; now find out where the line starts and leave point there.
9333 (beg (progn (beginning-of-line) (point)))
9334 (article (gnus-summary-article-number))
9335 (score (or (cdr (assq (or article gnus-current-article)
9336 gnus-newsgroup-scored))
9337 gnus-summary-default-score 0))
9338 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9339 (inhibit-read-only t))
9340 ;; Eval the cars of the lists until we find a match.
9341 (let ((default gnus-summary-default-score))
9343 (not (eval (caar list))))
9344 (setq list (cdr list))))
9345 (let ((face (cdar list)))
9346 (unless (eq face (get-text-property beg 'face))
9347 (gnus-put-text-property-excluding-characters-with-faces
9349 (setq face (if (boundp face) (symbol-value face) face)))
9350 (when gnus-summary-highlight-line-function
9351 (funcall gnus-summary-highlight-line-function article face))))
9354 (defun gnus-update-read-articles (group unread &optional compute)
9355 "Update the list of read articles in GROUP."
9356 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9357 (entry (gnus-gethash group gnus-newsrc-hashtb))
9358 (info (nth 2 entry))
9360 (unread (sort (copy-sequence unread) '<))
9362 (if (or (not info) (not active))
9363 ;; There is no info on this group if it was, in fact,
9364 ;; killed. Gnus stores no information on killed groups, so
9365 ;; there's nothing to be done.
9366 ;; One could store the information somewhere temporarily,
9367 ;; perhaps... Hmmm...
9369 ;; Remove any negative articles numbers.
9370 (while (and unread (< (car unread) 0))
9371 (setq unread (cdr unread)))
9372 ;; Remove any expired article numbers
9373 (while (and unread (< (car unread) (car active)))
9374 (setq unread (cdr unread)))
9375 ;; Compute the ranges of read articles by looking at the list of
9378 (when (/= (car unread) prev)
9379 (push (if (= prev (1- (car unread))) prev
9380 (cons prev (1- (car unread))))
9382 (setq prev (1+ (car unread)))
9383 (setq unread (cdr unread)))
9384 (when (<= prev (cdr active))
9385 (push (cons prev (cdr active)) read))
9386 (setq read (if (> (length read) 1) (nreverse read) read))
9390 (set-buffer gnus-group-buffer)
9393 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9394 (gnus-info-set-read ',info ',(gnus-info-read info))
9395 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9396 (gnus-group-update-group ,group t))))
9397 ;; Propagate the read marks to the backend.
9398 (if (gnus-check-backend-function 'request-set-mark group)
9399 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9400 (add (gnus-remove-from-range read (gnus-info-read info))))
9402 (unless (gnus-check-group group)
9403 (error "Can't open server for %s" group))
9404 (gnus-request-set-mark
9405 group (delq nil (list (if add (list add 'add '(read)))
9406 (if del (list del 'del '(read)))))))))
9407 ;; Enter this list into the group info.
9408 (gnus-info-set-read info read)
9409 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9410 (gnus-get-unread-articles-in-group info (gnus-active group))
9413 (defun gnus-offer-save-summaries ()
9414 "Offer to save all active summary buffers."
9416 (let ((buflist (buffer-list))
9418 ;; Go through all buffers and find all summaries.
9420 (and (setq bufname (buffer-name (car buflist)))
9421 (string-match "Summary" bufname)
9423 (set-buffer bufname)
9424 ;; We check that this is, indeed, a summary buffer.
9425 (and (eq major-mode 'gnus-summary-mode)
9426 ;; Also make sure this isn't bogus.
9427 gnus-newsgroup-prepared
9428 ;; Also make sure that this isn't a dead summary buffer.
9429 (not gnus-dead-summary-mode)))
9430 (push bufname buffers))
9431 (setq buflist (cdr buflist)))
9432 ;; Go through all these summary buffers and offer to save them.
9435 "Update summary buffer %s? "
9437 (switch-to-buffer buf)
9438 (gnus-summary-exit))
9441 (defun gnus-summary-setup-default-charset ()
9442 "Setup newsgroup default charset."
9443 (if (equal gnus-newsgroup-name "nndraft:drafts")
9444 (setq gnus-newsgroup-charset nil)
9445 (let* ((name (and gnus-newsgroup-name
9446 (gnus-group-real-name gnus-newsgroup-name)))
9448 (or gnus-newsgroup-ephemeral-ignored-charsets
9450 (and gnus-newsgroup-name
9451 (or (gnus-group-find-parameter gnus-newsgroup-name
9452 'ignored-charsets t)
9453 (let ((alist gnus-group-ignored-charsets-alist)
9454 elem (charsets nil))
9455 (while (setq elem (pop alist))
9457 (string-match (car elem) name))
9459 charsets (cdr elem))))
9461 gnus-newsgroup-ignored-charsets))))
9462 (setq gnus-newsgroup-charset
9463 (or gnus-newsgroup-ephemeral-charset
9464 (and gnus-newsgroup-name
9465 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9466 (let ((alist gnus-group-charset-alist)
9468 (while (setq elem (pop alist))
9470 (string-match (car elem) name))
9472 charset (cadr elem))))
9474 gnus-default-charset))
9475 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9476 ignored-charsets))))
9482 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9483 "Display the current article buffer fully MIME-buttonized.
9484 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9485 treated as multipart/mixed."
9488 (let ((gnus-unbuttonized-mime-types nil)
9489 (gnus-mime-display-multipart-as-mixed show-all-parts))
9490 (gnus-summary-show-article)))
9492 (defun gnus-summary-repair-multipart (article)
9493 "Add a Content-Type header to a multipart article without one."
9494 (interactive (list (gnus-summary-article-number)))
9495 (gnus-with-article article
9496 (message-narrow-to-head)
9497 (goto-char (point-max))
9499 (when (search-forward "\n--" nil t)
9500 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9501 (message-narrow-to-head)
9502 (message-remove-header "Mime-Version")
9503 (message-remove-header "Content-Type")
9504 (goto-char (point-max))
9505 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9507 (insert "Mime-Version: 1.0\n")
9509 (let (gnus-mark-article-hook)
9510 (gnus-summary-select-article t t nil article)))
9512 (defun gnus-summary-toggle-display-buttonized ()
9513 "Toggle the buttonizing of the article buffer."
9516 (if (setq gnus-inhibit-mime-unbuttonizing
9517 (not gnus-inhibit-mime-unbuttonizing))
9518 (let ((gnus-unbuttonized-mime-types nil))
9519 (gnus-summary-show-article))
9520 (gnus-summary-show-article)))
9526 (defmacro gnus-with-article (article &rest forms)
9527 "Select ARTICLE and perform FORMS in the original article buffer.
9528 Then replace the article with the result."
9530 ;; We don't want the article to be marked as read.
9531 (let (gnus-mark-article-hook)
9532 (gnus-summary-select-article t t nil ,article))
9533 (set-buffer gnus-original-article-buffer)
9535 (if (not (gnus-check-backend-function
9536 'request-replace-article (car gnus-article-current)))
9537 (gnus-message 5 "Read-only group; not replacing")
9538 (unless (gnus-request-replace-article
9539 ,article (car gnus-article-current)
9541 (error "Couldn't replace article")))
9542 ;; The cache and backlog have to be flushed somewhat.
9543 (when gnus-keep-backlog
9544 (gnus-backlog-remove-article
9545 (car gnus-article-current) (cdr gnus-article-current)))
9546 (when gnus-use-cache
9547 (gnus-cache-update-article
9548 (car gnus-article-current) (cdr gnus-article-current)))))
9550 (put 'gnus-with-article 'lisp-indent-function 1)
9551 (put 'gnus-with-article 'edebug-form-spec '(form body))
9554 ;;; Generic summary marking commands
9557 (defvar gnus-summary-marking-alist
9558 '((read gnus-del-mark "d")
9559 (unread gnus-unread-mark "u")
9560 (ticked gnus-ticked-mark "!")
9561 (dormant gnus-dormant-mark "?")
9562 (expirable gnus-expirable-mark "e"))
9563 "An alist of names/marks/keystrokes.")
9565 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9566 (defvar gnus-summary-mark-map)
9568 (defun gnus-summary-make-all-marking-commands ()
9569 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9570 (dolist (elem gnus-summary-marking-alist)
9571 (apply 'gnus-summary-make-marking-command elem)))
9573 (defun gnus-summary-make-marking-command (name mark keystroke)
9574 (let ((map (make-sparse-keymap)))
9575 (define-key gnus-summary-generic-mark-map keystroke map)
9576 (dolist (lway `((next "next" next nil "n")
9577 (next-unread "next unread" next t "N")
9578 (prev "previous" prev nil "p")
9579 (prev-unread "previous unread" prev t "P")
9580 (nomove "" nil nil ,keystroke)))
9581 (let ((func (gnus-summary-make-marking-command-1
9582 mark (car lway) lway name)))
9583 (setq func (eval func))
9584 (define-key map (nth 4 lway) func)))))
9586 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9588 (format "gnus-summary-put-mark-as-%s%s"
9589 name (if (eq way 'nomove)
9591 (concat "-" (symbol-name way)))))
9594 "Mark the current article as %s%s.
9595 If N, the prefix, then repeat N times.
9596 If N is negative, move in reverse order.
9597 The difference between N and the actual number of articles marked is
9601 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9603 (defun gnus-summary-generic-mark (n mark move unread)
9604 "Mark N articles with MARK."
9605 (unless (eq major-mode 'gnus-summary-mode)
9606 (error "This command can only be used in the summary buffer"))
9607 (gnus-summary-show-thread)
9611 ((eq move 'prev) -1)
9617 nummove (* -1 nummove))))
9619 (gnus-summary-mark-article nil mark)
9620 (zerop (gnus-summary-next-subject nummove unread t)))
9623 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9624 (gnus-summary-recenter)
9625 (gnus-summary-position-point)
9626 (gnus-set-mode-line 'summary)
9629 (gnus-summary-make-all-marking-commands)
9635 (run-hooks 'gnus-sum-load-hook)
9637 ;;; gnus-sum.el ends here