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 "6" gnus-article-de-base64-unreadable
1535 "Z" gnus-article-decode-HZ
1536 "h" gnus-article-wash-html
1537 "f" gnus-article-display-x-face
1538 "l" gnus-summary-stop-page-breaking
1539 "r" gnus-summary-caesar-message
1540 "t" gnus-article-hide-headers
1541 "v" gnus-summary-verbose-headers
1542 "H" gnus-article-strip-headers-in-body
1543 "d" gnus-article-treat-dumbquotes)
1545 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1546 "a" gnus-article-hide
1547 "h" gnus-article-hide-headers
1548 "b" gnus-article-hide-boring-headers
1549 "s" gnus-article-hide-signature
1550 "c" gnus-article-hide-citation
1551 "C" gnus-article-hide-citation-in-followups
1552 "l" gnus-article-hide-list-identifiers
1553 "p" gnus-article-hide-pgp
1554 "B" gnus-article-strip-banner
1555 "P" gnus-article-hide-pem
1556 "\C-c" gnus-article-hide-citation-maybe)
1558 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1559 "a" gnus-article-highlight
1560 "h" gnus-article-highlight-headers
1561 "c" gnus-article-highlight-citation
1562 "s" gnus-article-highlight-signature)
1564 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1565 "w" gnus-article-decode-mime-words
1566 "c" gnus-article-decode-charset
1567 "v" gnus-mime-view-all-parts
1568 "b" gnus-article-view-part)
1570 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1571 "z" gnus-article-date-ut
1572 "u" gnus-article-date-ut
1573 "l" gnus-article-date-local
1574 "e" gnus-article-date-lapsed
1575 "o" gnus-article-date-original
1576 "i" gnus-article-date-iso8601
1577 "s" gnus-article-date-user)
1579 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1580 "t" gnus-article-remove-trailing-blank-lines
1581 "l" gnus-article-strip-leading-blank-lines
1582 "m" gnus-article-strip-multiple-blank-lines
1583 "a" gnus-article-strip-blank-lines
1584 "A" gnus-article-strip-all-blank-lines
1585 "s" gnus-article-strip-leading-space
1586 "e" gnus-article-strip-trailing-space)
1588 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1590 "f" gnus-summary-fetch-faq
1591 "d" gnus-summary-describe-group
1592 "h" gnus-summary-describe-briefly
1593 "i" gnus-info-find-node)
1595 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1596 "e" gnus-summary-expire-articles
1597 "\M-\C-e" gnus-summary-expire-articles-now
1598 "\177" gnus-summary-delete-article
1599 [delete] gnus-summary-delete-article
1600 [backspace] gnus-summary-delete-article
1601 "m" gnus-summary-move-article
1602 "r" gnus-summary-respool-article
1603 "w" gnus-summary-edit-article
1604 "c" gnus-summary-copy-article
1605 "B" gnus-summary-crosspost-article
1606 "q" gnus-summary-respool-query
1607 "t" gnus-summary-respool-trace
1608 "i" gnus-summary-import-article
1609 "p" gnus-summary-article-posted-p)
1611 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1612 "o" gnus-summary-save-article
1613 "m" gnus-summary-save-article-mail
1614 "F" gnus-summary-write-article-file
1615 "r" gnus-summary-save-article-rmail
1616 "f" gnus-summary-save-article-file
1617 "b" gnus-summary-save-article-body-file
1618 "h" gnus-summary-save-article-folder
1619 "v" gnus-summary-save-article-vm
1620 "p" gnus-summary-pipe-output
1621 "s" gnus-soup-add-article)
1623 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1624 "b" gnus-summary-display-buttonized
1625 "m" gnus-summary-repair-multipart
1626 "v" gnus-article-view-part
1627 "o" gnus-article-save-part
1628 "c" gnus-article-copy-part
1629 "e" gnus-article-externalize-part
1630 "i" gnus-article-inline-part
1631 "|" gnus-article-pipe-part))
1633 (defun gnus-summary-make-menu-bar ()
1634 (gnus-turn-off-edit-menu 'summary)
1636 (unless (boundp 'gnus-summary-misc-menu)
1639 gnus-summary-kill-menu gnus-summary-mode-map ""
1644 ["Enter score..." gnus-summary-score-entry t]
1645 ["Customize" gnus-score-customize t])
1646 (gnus-make-score-map 'increase)
1647 (gnus-make-score-map 'lower)
1649 ["Kill below" gnus-summary-kill-below t]
1650 ["Mark above" gnus-summary-mark-above t]
1651 ["Tick above" gnus-summary-tick-above t]
1652 ["Clear above" gnus-summary-clear-above t])
1653 ["Current score" gnus-summary-current-score t]
1654 ["Set score" gnus-summary-set-score t]
1655 ["Switch current score file..." gnus-score-change-score-file t]
1656 ["Set mark below..." gnus-score-set-mark-below t]
1657 ["Set expunge below..." gnus-score-set-expunge-below t]
1658 ["Edit current score file" gnus-score-edit-current-scores t]
1659 ["Edit score file" gnus-score-edit-file t]
1660 ["Trace score" gnus-score-find-trace t]
1661 ["Find words" gnus-score-find-favourite-words t]
1662 ["Rescore buffer" gnus-summary-rescore t]
1663 ["Increase score..." gnus-summary-increase-score t]
1664 ["Lower score..." gnus-summary-lower-score t]))))
1666 ;; Define both the Article menu in the summary buffer and the equivalent
1667 ;; Commands menu in the article buffer here for consistency.
1670 ["All" gnus-article-hide t]
1671 ["Headers" gnus-article-hide-headers t]
1672 ["Signature" gnus-article-hide-signature t]
1673 ["Citation" gnus-article-hide-citation t]
1674 ["List identifiers" gnus-article-hide-list-identifiers t]
1675 ["PGP" gnus-article-hide-pgp t]
1676 ["Banner" gnus-article-strip-banner t]
1677 ["Boring headers" gnus-article-hide-boring-headers t])
1679 ["All" gnus-article-highlight t]
1680 ["Headers" gnus-article-highlight-headers t]
1681 ["Signature" gnus-article-highlight-signature t]
1682 ["Citation" gnus-article-highlight-citation t])
1684 ["Words" gnus-article-decode-mime-words t]
1685 ["Charset" gnus-article-decode-charset t]
1686 ["QP" gnus-article-de-quoted-unreadable t]
1687 ["Base64" gnus-article-de-base64-unreadable t]
1688 ["View all" gnus-mime-view-all-parts t])
1690 ["Local" gnus-article-date-local t]
1691 ["ISO8601" gnus-article-date-iso8601 t]
1692 ["UT" gnus-article-date-ut t]
1693 ["Original" gnus-article-date-original t]
1694 ["Lapsed" gnus-article-date-lapsed t]
1695 ["User-defined" gnus-article-date-user t])
1698 ["Leading" gnus-article-strip-leading-blank-lines t]
1699 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1700 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1701 ["All of the above" gnus-article-strip-blank-lines t]
1702 ["All" gnus-article-strip-all-blank-lines t]
1703 ["Leading space" gnus-article-strip-leading-space t]
1704 ["Trailing space" gnus-article-strip-trailing-space t])
1705 ["Overstrike" gnus-article-treat-overstrike t]
1706 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1707 ["Emphasis" gnus-article-emphasize t]
1708 ["Word wrap" gnus-article-fill-cited-article t]
1709 ["Fill long lines" gnus-article-fill-long-lines t]
1710 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1711 ["CR" gnus-article-remove-cr t]
1712 ["Show X-Face" gnus-article-display-x-face t]
1713 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1714 ["Base64" gnus-article-de-base64-unreadable t]
1715 ["Rot 13" gnus-summary-caesar-message t]
1716 ["Unix pipe" gnus-summary-pipe-message t]
1717 ["Add buttons" gnus-article-add-buttons t]
1718 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1719 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1720 ["Verbose header" gnus-summary-verbose-headers t]
1721 ["Toggle header" gnus-summary-toggle-header t]
1722 ["Html" gnus-article-wash-html t]
1723 ["HZ" gnus-article-decode-HZ t])
1725 ["Save in default format" gnus-summary-save-article t]
1726 ["Save in file" gnus-summary-save-article-file t]
1727 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1728 ["Save in MH folder" gnus-summary-save-article-folder t]
1729 ["Save in VM folder" gnus-summary-save-article-vm t]
1730 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1731 ["Save body in file" gnus-summary-save-article-body-file t]
1732 ["Pipe through a filter" gnus-summary-pipe-output t]
1733 ["Add to SOUP packet" gnus-soup-add-article t]
1734 ["Print" gnus-summary-print-article t])
1736 ["Respool article..." gnus-summary-respool-article t]
1737 ["Move article..." gnus-summary-move-article
1738 (gnus-check-backend-function
1739 'request-move-article gnus-newsgroup-name)]
1740 ["Copy article..." gnus-summary-copy-article t]
1741 ["Crosspost article..." gnus-summary-crosspost-article
1742 (gnus-check-backend-function
1743 'request-replace-article gnus-newsgroup-name)]
1744 ["Import file..." gnus-summary-import-article t]
1745 ["Check if posted" gnus-summary-article-posted-p t]
1746 ["Edit article" gnus-summary-edit-article
1747 (not (gnus-group-read-only-p))]
1748 ["Delete article" gnus-summary-delete-article
1749 (gnus-check-backend-function
1750 'request-expire-articles gnus-newsgroup-name)]
1751 ["Query respool" gnus-summary-respool-query t]
1752 ["Trace respool" gnus-summary-respool-trace t]
1753 ["Delete expirable articles" gnus-summary-expire-articles-now
1754 (gnus-check-backend-function
1755 'request-expire-articles gnus-newsgroup-name)])
1757 ["Uudecode" gnus-uu-decode-uu t]
1758 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1759 ["Unshar" gnus-uu-decode-unshar t]
1760 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1761 ["Save" gnus-uu-decode-save t]
1762 ["Binhex" gnus-uu-decode-binhex t]
1763 ["Postscript" gnus-uu-decode-postscript t])
1765 ["Enter article" gnus-cache-enter-article t]
1766 ["Remove article" gnus-cache-remove-article t])
1767 ["Translate" gnus-article-babel t]
1768 ["Select article buffer" gnus-summary-select-article-buffer t]
1769 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1770 ["Isearch article..." gnus-summary-isearch-article t]
1771 ["Beginning of the article" gnus-summary-beginning-of-article t]
1772 ["End of the article" gnus-summary-end-of-article t]
1773 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1774 ["Fetch referenced articles" gnus-summary-refer-references t]
1775 ["Fetch current thread" gnus-summary-refer-thread t]
1776 ["Fetch article with id..." gnus-summary-refer-article t]
1777 ["Redisplay" gnus-summary-show-article t])))
1779 gnus-summary-article-menu gnus-summary-mode-map ""
1780 (cons "Article" innards))
1783 gnus-article-commands-menu gnus-article-mode-map ""
1784 (cons "Commands" innards)))
1787 gnus-summary-thread-menu gnus-summary-mode-map ""
1789 ["Toggle threading" gnus-summary-toggle-threads t]
1790 ["Hide threads" gnus-summary-hide-all-threads t]
1791 ["Show threads" gnus-summary-show-all-threads t]
1792 ["Hide thread" gnus-summary-hide-thread t]
1793 ["Show thread" gnus-summary-show-thread t]
1794 ["Go to next thread" gnus-summary-next-thread t]
1795 ["Go to previous thread" gnus-summary-prev-thread t]
1796 ["Go down thread" gnus-summary-down-thread t]
1797 ["Go up thread" gnus-summary-up-thread t]
1798 ["Top of thread" gnus-summary-top-thread t]
1799 ["Mark thread as read" gnus-summary-kill-thread t]
1800 ["Lower thread score" gnus-summary-lower-thread t]
1801 ["Raise thread score" gnus-summary-raise-thread t]
1802 ["Rethread current" gnus-summary-rethread-current t]))
1805 gnus-summary-post-menu gnus-summary-mode-map ""
1807 ["Post an article" gnus-summary-post-news t]
1808 ["Followup" gnus-summary-followup t]
1809 ["Followup and yank" gnus-summary-followup-with-original t]
1810 ["Supersede article" gnus-summary-supersede-article t]
1811 ["Cancel article" gnus-summary-cancel-article t]
1812 ["Reply" gnus-summary-reply t]
1813 ["Reply and yank" gnus-summary-reply-with-original t]
1814 ["Wide reply" gnus-summary-wide-reply t]
1815 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1816 ["Mail forward" gnus-summary-mail-forward t]
1817 ["Post forward" gnus-summary-post-forward t]
1818 ["Digest and mail" gnus-uu-digest-mail-forward t]
1819 ["Digest and post" gnus-uu-digest-post-forward t]
1820 ["Resend message" gnus-summary-resend-message t]
1821 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1822 ["Send a mail" gnus-summary-mail-other-window t]
1823 ["Uuencode and post" gnus-uu-post-news t]
1824 ["Followup via news" gnus-summary-followup-to-mail t]
1825 ["Followup via news and yank"
1826 gnus-summary-followup-to-mail-with-original t]
1828 ;;["Send" gnus-summary-send-draft t]
1829 ;;["Send bounced" gnus-resend-bounced-mail t])
1833 gnus-summary-misc-menu gnus-summary-mode-map ""
1836 ["Mark as read" gnus-summary-mark-as-read-forward t]
1837 ["Mark same subject and select"
1838 gnus-summary-kill-same-subject-and-select t]
1839 ["Mark same subject" gnus-summary-kill-same-subject t]
1840 ["Catchup" gnus-summary-catchup t]
1841 ["Catchup all" gnus-summary-catchup-all t]
1842 ["Catchup to here" gnus-summary-catchup-to-here t]
1843 ["Catchup region" gnus-summary-mark-region-as-read t]
1844 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1846 ["Tick" gnus-summary-tick-article-forward t]
1847 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1848 ["Remove marks" gnus-summary-clear-mark-forward t]
1849 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1850 ["Set bookmark" gnus-summary-set-bookmark t]
1851 ["Remove bookmark" gnus-summary-remove-bookmark t])
1853 ["Marks..." gnus-summary-limit-to-marks t]
1854 ["Subject..." gnus-summary-limit-to-subject t]
1855 ["Author..." gnus-summary-limit-to-author t]
1856 ["Age..." gnus-summary-limit-to-age t]
1857 ["Extra..." gnus-summary-limit-to-extra t]
1858 ["Score" gnus-summary-limit-to-score t]
1859 ["Unread" gnus-summary-limit-to-unread t]
1860 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1861 ["Articles" gnus-summary-limit-to-articles t]
1862 ["Pop limit" gnus-summary-pop-limit t]
1863 ["Show dormant" gnus-summary-limit-include-dormant t]
1864 ["Hide childless dormant"
1865 gnus-summary-limit-exclude-childless-dormant t]
1866 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1867 ["Hide marked" gnus-summary-limit-exclude-marks t]
1868 ["Show expunged" gnus-summary-show-all-expunged t])
1870 ["Set mark" gnus-summary-mark-as-processable t]
1871 ["Remove mark" gnus-summary-unmark-as-processable t]
1872 ["Remove all marks" gnus-summary-unmark-all-processable t]
1873 ["Mark above" gnus-uu-mark-over t]
1874 ["Mark series" gnus-uu-mark-series t]
1875 ["Mark region" gnus-uu-mark-region t]
1876 ["Unmark region" gnus-uu-unmark-region t]
1877 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1878 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1879 ["Mark all" gnus-uu-mark-all t]
1880 ["Mark buffer" gnus-uu-mark-buffer t]
1881 ["Mark sparse" gnus-uu-mark-sparse t]
1882 ["Mark thread" gnus-uu-mark-thread t]
1883 ["Unmark thread" gnus-uu-unmark-thread t]
1884 ("Process Mark Sets"
1885 ["Kill" gnus-summary-kill-process-mark t]
1886 ["Yank" gnus-summary-yank-process-mark
1887 gnus-newsgroup-process-stack]
1888 ["Save" gnus-summary-save-process-mark t]))
1890 ["Page forward" gnus-summary-next-page t]
1891 ["Page backward" gnus-summary-prev-page t]
1892 ["Line forward" gnus-summary-scroll-up t])
1894 ["Next unread article" gnus-summary-next-unread-article t]
1895 ["Previous unread article" gnus-summary-prev-unread-article t]
1896 ["Next article" gnus-summary-next-article t]
1897 ["Previous article" gnus-summary-prev-article t]
1898 ["Next unread subject" gnus-summary-next-unread-subject t]
1899 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1900 ["Next article same subject" gnus-summary-next-same-subject t]
1901 ["Previous article same subject" gnus-summary-prev-same-subject t]
1902 ["First unread article" gnus-summary-first-unread-article t]
1903 ["Best unread article" gnus-summary-best-unread-article t]
1904 ["Go to subject number..." gnus-summary-goto-subject t]
1905 ["Go to article number..." gnus-summary-goto-article t]
1906 ["Go to the last article" gnus-summary-goto-last-article t]
1907 ["Pop article off history" gnus-summary-pop-article t])
1909 ["Sort by number" gnus-summary-sort-by-number t]
1910 ["Sort by author" gnus-summary-sort-by-author t]
1911 ["Sort by subject" gnus-summary-sort-by-subject t]
1912 ["Sort by date" gnus-summary-sort-by-date t]
1913 ["Sort by score" gnus-summary-sort-by-score t]
1914 ["Sort by lines" gnus-summary-sort-by-lines t]
1915 ["Sort by characters" gnus-summary-sort-by-chars t])
1917 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1918 ["Describe group" gnus-summary-describe-group t]
1919 ["Read manual" gnus-info-find-node t])
1921 ["Pick and read" gnus-pick-mode t]
1922 ["Binary" gnus-binary-mode t])
1924 ["Regenerate" gnus-summary-prepare t]
1925 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1926 ["Toggle threading" gnus-summary-toggle-threads t])
1927 ["Filter articles..." gnus-summary-execute-command t]
1928 ["Run command on subjects..." gnus-summary-universal-argument t]
1929 ["Search articles forward..." gnus-summary-search-article-forward t]
1930 ["Search articles backward..." gnus-summary-search-article-backward t]
1931 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1932 ["Expand window" gnus-summary-expand-window t]
1933 ["Expire expirable articles" gnus-summary-expire-articles
1934 (gnus-check-backend-function
1935 'request-expire-articles gnus-newsgroup-name)]
1936 ["Edit local kill file" gnus-summary-edit-local-kill t]
1937 ["Edit main kill file" gnus-summary-edit-global-kill t]
1938 ["Edit group parameters" gnus-summary-edit-parameters t]
1939 ["Customize group parameters" gnus-summary-customize-parameters t]
1940 ["Send a bug report" gnus-bug t]
1942 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1943 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1944 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1945 ["Exit group" gnus-summary-exit t]
1946 ["Exit group without updating" gnus-summary-exit-no-update t]
1947 ["Exit and goto next group" gnus-summary-next-group t]
1948 ["Exit and goto prev group" gnus-summary-prev-group t]
1949 ["Reselect group" gnus-summary-reselect-current-group t]
1950 ["Rescan group" gnus-summary-rescan-group t]
1951 ["Update dribble" gnus-summary-save-newsrc t])))
1953 (gnus-run-hooks 'gnus-summary-menu-hook)))
1955 (defun gnus-score-set-default (var value)
1956 "A version of set that updates the GNU Emacs menu-bar."
1958 ;; It is the message that forces the active status to be updated.
1961 (defun gnus-make-score-map (type)
1962 "Make a summary score map of type TYPE."
1965 (let ((headers '(("author" "from" string)
1966 ("subject" "subject" string)
1967 ("article body" "body" string)
1968 ("article head" "head" string)
1969 ("xref" "xref" string)
1970 ("extra header" "extra" string)
1971 ("lines" "lines" number)
1972 ("followups to author" "followup" string)))
1973 (types '((number ("less than" <)
1976 (string ("substring" s)
1980 (perms '(("temporary" (current-time-string))
1988 (if (eq type 'lower)
1993 (setq header (car headers))
1999 (let ((ts (cdr (assoc (nth 2 header) types)))
2015 'gnus-summary-score-entry
2017 (if (or (string= (nth 1 header)
2019 (string= (nth 1 header)
2022 (list 'gnus-summary-header
2024 (list 'quote (nth 1 (car ts)))
2025 (list 'gnus-score-delta-default
2032 (list (nreverse outp))))
2035 (list (nreverse outt))))
2037 (setq headers (cdr headers)))
2038 (list (nreverse outh))))))))
2042 (defun gnus-summary-mode (&optional group)
2043 "Major mode for reading articles.
2045 All normal editing commands are switched off.
2046 \\<gnus-summary-mode-map>
2047 Each line in this buffer represents one article. To read an
2048 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2049 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2052 You can also post articles and send mail from this buffer. To
2053 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2054 of an article, type `\\[gnus-summary-reply]'.
2056 There are approx. one gazillion commands you can execute in this
2057 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2059 The following commands are available:
2061 \\{gnus-summary-mode-map}"
2063 (when (gnus-visual-p 'summary-menu 'menu)
2064 (gnus-summary-make-menu-bar))
2065 (kill-all-local-variables)
2066 (gnus-summary-make-local-variables)
2067 (gnus-make-thread-indent-array)
2068 (gnus-simplify-mode-line)
2069 (setq major-mode 'gnus-summary-mode)
2070 (setq mode-name "Summary")
2071 (make-local-variable 'minor-mode-alist)
2072 (use-local-map gnus-summary-mode-map)
2073 (buffer-disable-undo)
2074 (setq buffer-read-only t) ;Disable modification
2075 (setq truncate-lines t)
2076 (setq selective-display t)
2077 (setq selective-display-ellipses t) ;Display `...'
2078 (gnus-summary-set-display-table)
2079 (gnus-set-default-directory)
2080 (setq gnus-newsgroup-name group)
2081 (make-local-variable 'gnus-summary-line-format)
2082 (make-local-variable 'gnus-summary-line-format-spec)
2083 (make-local-variable 'gnus-summary-dummy-line-format)
2084 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2085 (make-local-variable 'gnus-summary-mark-positions)
2086 (make-local-hook 'pre-command-hook)
2087 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2088 (gnus-run-hooks 'gnus-summary-mode-hook)
2089 (mm-enable-multibyte)
2090 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2091 (gnus-update-summary-mark-positions))
2093 (defun gnus-summary-make-local-variables ()
2094 "Make all the local summary buffer variables."
2096 (dolist (local gnus-summary-local-variables)
2099 (if (eq (cdr local) 'global)
2100 ;; Copy the global value of the variable.
2101 (setq global (symbol-value (car local)))
2102 ;; Use the value from the list.
2103 (setq global (eval (cdr local))))
2104 (set (make-local-variable (car local)) global))
2105 ;; Simple nil-valued local variable.
2106 (set (make-local-variable local) nil)))))
2108 (defun gnus-summary-clear-local-variables ()
2109 (let ((locals gnus-summary-local-variables))
2111 (if (consp (car locals))
2112 (and (vectorp (caar locals))
2113 (set (caar locals) nil))
2114 (and (vectorp (car locals))
2115 (set (car locals) nil)))
2116 (setq locals (cdr locals)))))
2118 ;; Summary data functions.
2120 (defmacro gnus-data-number (data)
2123 (defmacro gnus-data-set-number (data number)
2124 `(setcar ,data ,number))
2126 (defmacro gnus-data-mark (data)
2129 (defmacro gnus-data-set-mark (data mark)
2130 `(setcar (nthcdr 1 ,data) ,mark))
2132 (defmacro gnus-data-pos (data)
2135 (defmacro gnus-data-set-pos (data pos)
2136 `(setcar (nthcdr 2 ,data) ,pos))
2138 (defmacro gnus-data-header (data)
2141 (defmacro gnus-data-set-header (data header)
2142 `(setf (nth 3 ,data) ,header))
2144 (defmacro gnus-data-level (data)
2147 (defmacro gnus-data-unread-p (data)
2148 `(= (nth 1 ,data) gnus-unread-mark))
2150 (defmacro gnus-data-read-p (data)
2151 `(/= (nth 1 ,data) gnus-unread-mark))
2153 (defmacro gnus-data-pseudo-p (data)
2154 `(consp (nth 3 ,data)))
2156 (defmacro gnus-data-find (number)
2157 `(assq ,number gnus-newsgroup-data))
2159 (defmacro gnus-data-find-list (number &optional data)
2160 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2161 (memq (assq ,number bdata)
2164 (defmacro gnus-data-make (number mark pos header level)
2165 `(list ,number ,mark ,pos ,header ,level))
2167 (defun gnus-data-enter (after-article number mark pos header level offset)
2168 (let ((data (gnus-data-find-list after-article)))
2170 (error "No such article: %d" after-article))
2171 (setcdr data (cons (gnus-data-make number mark pos header level)
2173 (setq gnus-newsgroup-data-reverse nil)
2174 (gnus-data-update-list (cddr data) offset)))
2176 (defun gnus-data-enter-list (after-article list &optional offset)
2178 (let ((data (and after-article (gnus-data-find-list after-article)))
2182 (let ((odata gnus-newsgroup-data))
2183 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2185 (gnus-data-update-list odata offset)))
2186 ;; Find the last element in the list to be spliced into the main
2189 (setq list (cdr list)))
2192 (setcdr list gnus-newsgroup-data)
2193 (setq gnus-newsgroup-data ilist)
2195 (gnus-data-update-list (cdr list) offset)))
2196 (setcdr list (cdr data))
2199 (gnus-data-update-list (cdr list) offset))))
2200 (setq gnus-newsgroup-data-reverse nil))))
2202 (defun gnus-data-remove (article &optional offset)
2203 (let ((data gnus-newsgroup-data))
2204 (if (= (gnus-data-number (car data)) article)
2206 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2207 gnus-newsgroup-data-reverse nil)
2209 (gnus-data-update-list gnus-newsgroup-data offset)))
2211 (when (= (gnus-data-number (cadr data)) article)
2212 (setcdr data (cddr data))
2214 (gnus-data-update-list (cdr data) offset))
2216 gnus-newsgroup-data-reverse nil))
2217 (setq data (cdr data))))))
2219 (defmacro gnus-data-list (backward)
2221 (or gnus-newsgroup-data-reverse
2222 (setq gnus-newsgroup-data-reverse
2223 (reverse gnus-newsgroup-data)))
2224 gnus-newsgroup-data))
2226 (defun gnus-data-update-list (data offset)
2227 "Add OFFSET to the POS of all data entries in DATA."
2228 (setq gnus-newsgroup-data-reverse nil)
2230 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2231 (setq data (cdr data))))
2233 (defun gnus-summary-article-pseudo-p (article)
2234 "Say whether this article is a pseudo article or not."
2235 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2237 (defmacro gnus-summary-article-sparse-p (article)
2238 "Say whether this article is a sparse article or not."
2239 `(memq ,article gnus-newsgroup-sparse))
2241 (defmacro gnus-summary-article-ancient-p (article)
2242 "Say whether this article is a sparse article or not."
2243 `(memq ,article gnus-newsgroup-ancient))
2245 (defun gnus-article-parent-p (number)
2246 "Say whether this article is a parent or not."
2247 (let ((data (gnus-data-find-list number)))
2248 (and (cdr data) ; There has to be an article after...
2249 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2250 (gnus-data-level (nth 1 data))))))
2252 (defun gnus-article-children (number)
2253 "Return a list of all children to NUMBER."
2254 (let* ((data (gnus-data-find-list number))
2255 (level (gnus-data-level (car data)))
2257 (setq data (cdr data))
2259 (= (gnus-data-level (car data)) (1+ level)))
2260 (push (gnus-data-number (car data)) children)
2261 (setq data (cdr data)))
2264 (defmacro gnus-summary-skip-intangible ()
2265 "If the current article is intangible, then jump to a different article."
2266 '(let ((to (get-text-property (point) 'gnus-intangible)))
2267 (and to (gnus-summary-goto-subject to))))
2269 (defmacro gnus-summary-article-intangible-p ()
2270 "Say whether this article is intangible or not."
2271 '(get-text-property (point) 'gnus-intangible))
2273 (defun gnus-article-read-p (article)
2274 "Say whether ARTICLE is read or not."
2275 (not (or (memq article gnus-newsgroup-marked)
2276 (memq article gnus-newsgroup-unreads)
2277 (memq article gnus-newsgroup-unselected)
2278 (memq article gnus-newsgroup-dormant))))
2280 ;; Some summary mode macros.
2282 (defmacro gnus-summary-article-number ()
2283 "The article number of the article on the current line.
2284 If there isn's an article number here, then we return the current
2287 (gnus-summary-skip-intangible)
2288 (or (get-text-property (point) 'gnus-number)
2289 (gnus-summary-last-subject))))
2291 (defmacro gnus-summary-article-header (&optional number)
2292 "Return the header of article NUMBER."
2293 `(gnus-data-header (gnus-data-find
2294 ,(or number '(gnus-summary-article-number)))))
2296 (defmacro gnus-summary-thread-level (&optional number)
2297 "Return the level of thread that starts with article NUMBER."
2298 `(if (and (eq gnus-summary-make-false-root 'dummy)
2299 (get-text-property (point) 'gnus-intangible))
2301 (gnus-data-level (gnus-data-find
2302 ,(or number '(gnus-summary-article-number))))))
2304 (defmacro gnus-summary-article-mark (&optional number)
2305 "Return the mark of article NUMBER."
2306 `(gnus-data-mark (gnus-data-find
2307 ,(or number '(gnus-summary-article-number)))))
2309 (defmacro gnus-summary-article-pos (&optional number)
2310 "Return the position of the line of article NUMBER."
2311 `(gnus-data-pos (gnus-data-find
2312 ,(or number '(gnus-summary-article-number)))))
2314 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2315 (defmacro gnus-summary-article-subject (&optional number)
2316 "Return current subject string or nil if nothing."
2319 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2320 '(gnus-data-header (assq (gnus-summary-article-number)
2321 gnus-newsgroup-data)))))
2324 (mail-header-subject headers))))
2326 (defmacro gnus-summary-article-score (&optional number)
2327 "Return current article score."
2328 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2329 gnus-newsgroup-scored))
2330 gnus-summary-default-score 0))
2332 (defun gnus-summary-article-children (&optional number)
2333 "Return a list of article numbers that are children of article NUMBER."
2334 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2335 (level (gnus-data-level (car data)))
2337 (while (and (setq data (cdr data))
2338 (> (setq l (gnus-data-level (car data))) level))
2339 (and (= (1+ level) l)
2340 (push (gnus-data-number (car data))
2342 (nreverse children)))
2344 (defun gnus-summary-article-parent (&optional number)
2345 "Return the article number of the parent of article NUMBER."
2346 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2347 (gnus-data-list t)))
2348 (level (gnus-data-level (car data))))
2350 () ; This is a root.
2351 ;; We search until we find an article with a level less than
2352 ;; this one. That function has to be the parent.
2353 (while (and (setq data (cdr data))
2354 (not (< (gnus-data-level (car data)) level))))
2355 (and data (gnus-data-number (car data))))))
2357 (defun gnus-unread-mark-p (mark)
2358 "Say whether MARK is the unread mark."
2359 (= mark gnus-unread-mark))
2361 (defun gnus-read-mark-p (mark)
2362 "Say whether MARK is one of the marks that mark as read.
2363 This is all marks except unread, ticked, dormant, and expirable."
2364 (not (or (= mark gnus-unread-mark)
2365 (= mark gnus-ticked-mark)
2366 (= mark gnus-dormant-mark)
2367 (= mark gnus-expirable-mark))))
2369 (defmacro gnus-article-mark (number)
2370 "Return the MARK of article NUMBER.
2371 This macro should only be used when computing the mark the \"first\"
2372 time; i.e., when generating the summary lines. After that,
2373 `gnus-summary-article-mark' should be used to examine the
2376 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2377 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2378 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2379 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2380 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2381 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2382 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2383 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2384 gnus-ancient-mark))))
2386 ;; Saving hidden threads.
2388 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2389 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2391 (defmacro gnus-save-hidden-threads (&rest forms)
2392 "Save hidden threads, eval FORMS, and restore the hidden threads."
2393 (let ((config (make-symbol "config")))
2394 `(let ((,config (gnus-hidden-threads-configuration)))
2398 (gnus-restore-hidden-threads-configuration ,config)))))
2400 (defun gnus-data-compute-positions ()
2401 "Compute the positions of all articles."
2402 (setq gnus-newsgroup-data-reverse nil)
2403 (let ((data gnus-newsgroup-data))
2405 (gnus-save-hidden-threads
2406 (gnus-summary-show-all-threads)
2407 (goto-char (point-min))
2409 (while (get-text-property (point) 'gnus-intangible)
2411 (gnus-data-set-pos (car data) (+ (point) 3))
2412 (setq data (cdr data))
2413 (forward-line 1))))))
2415 (defun gnus-hidden-threads-configuration ()
2416 "Return the current hidden threads configuration."
2419 (goto-char (point-min))
2420 (while (search-forward "\r" nil t)
2421 (push (1- (point)) config))
2424 (defun gnus-restore-hidden-threads-configuration (config)
2425 "Restore hidden threads configuration from CONFIG."
2426 (let (point buffer-read-only)
2427 (while (setq point (pop config))
2428 (when (and (< point (point-max))
2430 (eq (char-after) ?\n))
2431 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2433 ;; Various summary mode internalish functions.
2435 (defun gnus-mouse-pick-article (e)
2438 (gnus-summary-next-page nil t))
2440 (defun gnus-summary-set-display-table ()
2441 ;; Change the display table. Odd characters have a tendency to mess
2442 ;; up nicely formatted displays - we make all possible glyphs
2443 ;; display only a single character.
2445 ;; We start from the standard display table, if any.
2446 (let ((table (or (copy-sequence standard-display-table)
2447 (make-display-table)))
2449 ;; Nix out all the control chars...
2450 (while (>= (setq i (1- i)) 0)
2451 (aset table i [??]))
2452 ;; ... but not newline and cr, of course. (cr is necessary for the
2453 ;; selective display).
2454 (aset table ?\n nil)
2455 (aset table ?\r nil)
2456 ;; We keep TAB as well.
2457 (aset table ?\t nil)
2458 ;; We nix out any glyphs over 126 that are not set already.
2460 (while (>= (setq i (1- i)) 127)
2461 ;; Only modify if the entry is nil.
2462 (unless (aref table i)
2463 (aset table i [??]))))
2464 (setq buffer-display-table table)))
2466 (defun gnus-summary-setup-buffer (group)
2467 "Initialize summary buffer."
2468 (let ((buffer (concat "*Summary " group "*")))
2469 (if (get-buffer buffer)
2472 (setq gnus-summary-buffer (current-buffer))
2473 (not gnus-newsgroup-prepared))
2474 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2475 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2476 (gnus-summary-mode group)
2478 (gnus-carpal-setup-buffer 'summary))
2479 (unless gnus-single-article-buffer
2480 (make-local-variable 'gnus-article-buffer)
2481 (make-local-variable 'gnus-article-current)
2482 (make-local-variable 'gnus-original-article-buffer))
2483 (setq gnus-newsgroup-name group)
2486 (defun gnus-set-global-variables ()
2487 ;; Set the global equivalents of the summary buffer-local variables
2488 ;; to the latest values they had. These reflect the summary buffer
2489 ;; that was in action when the last article was fetched.
2490 (when (eq major-mode 'gnus-summary-mode)
2491 (setq gnus-summary-buffer (current-buffer))
2492 (let ((name gnus-newsgroup-name)
2493 (marked gnus-newsgroup-marked)
2494 (unread gnus-newsgroup-unreads)
2495 (headers gnus-current-headers)
2496 (data gnus-newsgroup-data)
2497 (summary gnus-summary-buffer)
2498 (article-buffer gnus-article-buffer)
2499 (original gnus-original-article-buffer)
2500 (gac gnus-article-current)
2501 (reffed gnus-reffed-article-number)
2502 (score-file gnus-current-score-file)
2503 (default-charset gnus-newsgroup-charset))
2505 (set-buffer gnus-group-buffer)
2506 (setq gnus-newsgroup-name name
2507 gnus-newsgroup-marked marked
2508 gnus-newsgroup-unreads unread
2509 gnus-current-headers headers
2510 gnus-newsgroup-data data
2511 gnus-article-current gac
2512 gnus-summary-buffer summary
2513 gnus-article-buffer article-buffer
2514 gnus-original-article-buffer original
2515 gnus-reffed-article-number reffed
2516 gnus-current-score-file score-file
2517 gnus-newsgroup-charset default-charset)
2518 ;; The article buffer also has local variables.
2519 (when (gnus-buffer-live-p gnus-article-buffer)
2520 (set-buffer gnus-article-buffer)
2521 (setq gnus-summary-buffer summary))))))
2523 (defun gnus-summary-article-unread-p (article)
2524 "Say whether ARTICLE is unread or not."
2525 (memq article gnus-newsgroup-unreads))
2527 (defun gnus-summary-first-article-p (&optional article)
2528 "Return whether ARTICLE is the first article in the buffer."
2529 (if (not (setq article (or article (gnus-summary-article-number))))
2531 (eq article (caar gnus-newsgroup-data))))
2533 (defun gnus-summary-last-article-p (&optional article)
2534 "Return whether ARTICLE is the last article in the buffer."
2535 (if (not (setq article (or article (gnus-summary-article-number))))
2536 ;; All non-existent numbers are the last article. :-)
2538 (not (cdr (gnus-data-find-list article)))))
2540 (defun gnus-make-thread-indent-array ()
2542 (unless (and gnus-thread-indent-array
2543 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2544 (setq gnus-thread-indent-array (make-vector 201 "")
2545 gnus-thread-indent-array-level gnus-thread-indent-level)
2547 (aset gnus-thread-indent-array n
2548 (make-string (* n gnus-thread-indent-level) ? ))
2551 (defun gnus-update-summary-mark-positions ()
2552 "Compute where the summary marks are to go."
2554 (when (gnus-buffer-exists-p gnus-summary-buffer)
2555 (set-buffer gnus-summary-buffer))
2556 (let ((gnus-replied-mark 129)
2557 (gnus-score-below-mark 130)
2558 (gnus-score-over-mark 130)
2559 (gnus-download-mark 131)
2560 (spec gnus-summary-line-format-spec)
2563 (gnus-set-work-buffer)
2564 (let ((gnus-summary-line-format-spec spec)
2565 (gnus-newsgroup-downloadable '((0 . t))))
2566 (gnus-summary-insert-line
2567 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2568 (goto-char (point-min))
2569 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2571 (goto-char (point-min))
2572 (push (cons 'replied (and (search-forward "\201" nil t)
2575 (goto-char (point-min))
2576 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2578 (goto-char (point-min))
2579 (push (cons 'download
2580 (and (search-forward "\203" nil t) (- (point) 2)))
2582 (setq gnus-summary-mark-positions pos))))
2584 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2585 "Insert a dummy root in the summary buffer."
2587 (gnus-add-text-properties
2588 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2589 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2591 (defun gnus-summary-from-or-to-or-newsgroups (header)
2592 (let ((to (cdr (assq 'To (mail-header-extra header))))
2593 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2594 (mail-parse-charset gnus-newsgroup-charset)
2595 (mail-parse-ignored-charsets
2596 (save-excursion (set-buffer gnus-summary-buffer)
2597 gnus-newsgroup-ignored-charsets)))
2600 gnus-ignored-from-addresses
2601 (string-match gnus-ignored-from-addresses
2602 (mail-header-from header)))
2604 (or (car (funcall gnus-extract-address-components
2606 gnus-decode-encoded-word-function to)))
2607 (funcall gnus-decode-encoded-word-function to))))
2609 gnus-ignored-from-addresses
2610 (string-match gnus-ignored-from-addresses
2611 (mail-header-from header)))
2612 (concat "=> " newsgroups))
2614 (or (car (funcall gnus-extract-address-components
2615 (mail-header-from header)))
2616 (mail-header-from header))))))
2618 (defun gnus-summary-insert-line (gnus-tmp-header
2619 gnus-tmp-level gnus-tmp-current
2620 gnus-tmp-unread gnus-tmp-replied
2621 gnus-tmp-expirable gnus-tmp-subject-or-nil
2622 &optional gnus-tmp-dummy gnus-tmp-score
2624 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2625 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2626 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2627 (gnus-tmp-score-char
2628 (if (or (null gnus-summary-default-score)
2629 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2630 gnus-summary-zcore-fuzz))
2632 (if (< gnus-tmp-score gnus-summary-default-score)
2633 gnus-score-below-mark gnus-score-over-mark)))
2635 (cond (gnus-tmp-process gnus-process-mark)
2636 ((memq gnus-tmp-current gnus-newsgroup-cached)
2638 (gnus-tmp-replied gnus-replied-mark)
2639 ((memq gnus-tmp-current gnus-newsgroup-saved)
2641 (t gnus-unread-mark)))
2642 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2645 ((string-match "<[^>]+> *$" gnus-tmp-from)
2646 (let ((beg (match-beginning 0)))
2647 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2648 (substring gnus-tmp-from (1+ (match-beginning 0))
2649 (1- (match-end 0))))
2650 (substring gnus-tmp-from 0 beg))))
2651 ((string-match "(.+)" gnus-tmp-from)
2652 (substring gnus-tmp-from
2653 (1+ (match-beginning 0)) (1- (match-end 0))))
2655 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2656 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2657 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2658 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2659 (buffer-read-only nil))
2660 (when (string= gnus-tmp-name "")
2661 (setq gnus-tmp-name gnus-tmp-from))
2662 (unless (numberp gnus-tmp-lines)
2663 (setq gnus-tmp-lines 0))
2664 (gnus-put-text-property
2666 (progn (eval gnus-summary-line-format-spec) (point))
2667 'gnus-number gnus-tmp-number)
2668 (when (gnus-visual-p 'summary-highlight 'highlight)
2670 (gnus-run-hooks 'gnus-summary-update-hook)
2673 (defun gnus-summary-update-line (&optional dont-update)
2674 ;; Update summary line after change.
2675 (when (and gnus-summary-default-score
2676 (not gnus-summary-inhibit-highlight))
2677 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2678 (article (gnus-summary-article-number))
2679 (score (gnus-summary-article-score article)))
2681 (if (and gnus-summary-mark-below
2682 (< (gnus-summary-article-score)
2683 gnus-summary-mark-below))
2684 ;; This article has a low score, so we mark it as read.
2685 (when (memq article gnus-newsgroup-unreads)
2686 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2687 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2688 ;; This article was previously marked as read on account
2689 ;; of a low score, but now it has risen, so we mark it as
2691 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2692 (gnus-summary-update-mark
2693 (if (or (null gnus-summary-default-score)
2694 (<= (abs (- score gnus-summary-default-score))
2695 gnus-summary-zcore-fuzz))
2697 (if (< score gnus-summary-default-score)
2698 gnus-score-below-mark gnus-score-over-mark))
2700 ;; Do visual highlighting.
2701 (when (gnus-visual-p 'summary-highlight 'highlight)
2702 (gnus-run-hooks 'gnus-summary-update-hook)))))
2704 (defvar gnus-tmp-new-adopts nil)
2706 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2707 "Return the number of articles in THREAD.
2708 This may be 0 in some cases -- if none of the articles in
2709 the thread are to be displayed."
2711 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2713 ((not (listp thread))
2715 ((and (consp thread) (cdr thread))
2718 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2721 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2724 (when (and level (zerop level) gnus-tmp-new-adopts)
2727 'gnus-summary-number-of-articles-in-thread
2728 gnus-tmp-new-adopts))))
2730 (if (> number 1) gnus-not-empty-thread-mark
2731 gnus-empty-thread-mark)
2734 (defun gnus-summary-set-local-parameters (group)
2735 "Go through the local params of GROUP and set all variable specs in that list."
2736 (let ((params (gnus-group-find-parameter group))
2739 (setq elem (car params)
2740 params (cdr params))
2741 (and (consp elem) ; Has to be a cons.
2742 (consp (cdr elem)) ; The cdr has to be a list.
2743 (symbolp (car elem)) ; Has to be a symbol in there.
2744 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2745 (ignore-errors ; So we set it.
2746 (make-local-variable (car elem))
2747 (set (car elem) (eval (nth 1 elem))))))))
2749 (defun gnus-summary-read-group (group &optional show-all no-article
2750 kill-buffer no-display backward
2752 "Start reading news in newsgroup GROUP.
2753 If SHOW-ALL is non-nil, already read articles are also listed.
2754 If NO-ARTICLE is non-nil, no article is selected initially.
2755 If NO-DISPLAY, don't generate a summary buffer."
2759 (let ((gnus-auto-select-next nil))
2760 (or (gnus-summary-read-group-1
2761 group show-all no-article
2762 kill-buffer no-display
2765 select-articles nil)))))
2766 (eq gnus-auto-select-next 'quietly))
2767 (set-buffer gnus-group-buffer)
2768 ;; The entry function called above goes to the next
2769 ;; group automatically, so we go two groups back
2770 ;; if we are searching for the previous group.
2772 (gnus-group-prev-unread-group 2))
2773 (if (not (equal group (gnus-group-group-name)))
2774 (setq group (gnus-group-group-name))
2778 (defun gnus-summary-read-group-1 (group show-all no-article
2779 kill-buffer no-display
2780 &optional select-articles)
2781 ;; Killed foreign groups can't be entered.
2782 (when (and (not (gnus-group-native-p group))
2783 (not (gnus-gethash group gnus-newsrc-hashtb)))
2784 (error "Dead non-native groups can't be entered"))
2785 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2786 (let* ((new-group (gnus-summary-setup-buffer group))
2787 (quit-config (gnus-group-quit-config group))
2788 (did-select (and new-group (gnus-select-newsgroup
2789 group show-all select-articles))))
2791 ;; This summary buffer exists already, so we just select it.
2793 (gnus-set-global-variables)
2795 (gnus-kill-or-deaden-summary kill-buffer))
2796 (gnus-configure-windows 'summary 'force)
2797 (gnus-set-mode-line 'summary)
2798 (gnus-summary-position-point)
2801 ;; We couldn't select this group.
2803 (when (and (eq major-mode 'gnus-summary-mode)
2804 (not (equal (current-buffer) kill-buffer)))
2805 (kill-buffer (current-buffer))
2806 (if (not quit-config)
2808 ;; Update the info -- marks might need to be removed,
2810 (gnus-summary-update-info)
2811 (set-buffer gnus-group-buffer)
2812 (gnus-group-jump-to-group group)
2813 (gnus-group-next-unread-group 1))
2814 (gnus-handle-ephemeral-exit quit-config)))
2815 (gnus-message 3 "Can't select group")
2817 ;; The user did a `C-g' while prompting for number of articles,
2818 ;; so we exit this group.
2819 ((eq did-select 'quit)
2820 (and (eq major-mode 'gnus-summary-mode)
2821 (not (equal (current-buffer) kill-buffer))
2822 (kill-buffer (current-buffer)))
2824 (gnus-kill-or-deaden-summary kill-buffer))
2825 (if (not quit-config)
2827 (set-buffer gnus-group-buffer)
2828 (gnus-group-jump-to-group group)
2829 (gnus-group-next-unread-group 1)
2830 (gnus-configure-windows 'group 'force))
2831 (gnus-handle-ephemeral-exit quit-config))
2832 ;; Finally signal the quit.
2834 ;; The group was successfully selected.
2836 (gnus-set-global-variables)
2837 ;; Save the active value in effect when the group was entered.
2838 (setq gnus-newsgroup-active
2840 (gnus-active gnus-newsgroup-name)))
2841 ;; You can change the summary buffer in some way with this hook.
2842 (gnus-run-hooks 'gnus-select-group-hook)
2843 ;; Set any local variables in the group parameters.
2844 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2845 (gnus-update-format-specifications
2846 nil 'summary 'summary-mode 'summary-dummy)
2847 (gnus-update-summary-mark-positions)
2848 ;; Do score processing.
2849 (when gnus-use-scoring
2850 (gnus-possibly-score-headers))
2851 ;; Check whether to fill in the gaps in the threads.
2852 (when gnus-build-sparse-threads
2853 (gnus-build-sparse-threads))
2854 ;; Find the initial limit.
2855 (if gnus-show-threads
2857 (let ((gnus-newsgroup-dormant nil))
2858 (gnus-summary-initial-limit show-all))
2859 (gnus-summary-initial-limit show-all))
2860 ;; When untreaded, all articles are always shown.
2861 (setq gnus-newsgroup-limit
2863 (lambda (header) (mail-header-number header))
2864 gnus-newsgroup-headers)))
2865 ;; Generate the summary buffer.
2867 (gnus-summary-prepare))
2868 (when gnus-use-trees
2869 (gnus-tree-open group)
2870 (setq gnus-summary-highlight-line-function
2871 'gnus-tree-highlight-article))
2872 ;; If the summary buffer is empty, but there are some low-scored
2873 ;; articles or some excluded dormants, we include these in the
2875 (when (and (zerop (buffer-size))
2877 (cond (gnus-newsgroup-dormant
2878 (gnus-summary-limit-include-dormant))
2879 ((and gnus-newsgroup-scored show-all)
2880 (gnus-summary-limit-include-expunged t))))
2881 ;; Function `gnus-apply-kill-file' must be called in this hook.
2882 (gnus-run-hooks 'gnus-apply-kill-hook)
2883 (if (and (zerop (buffer-size))
2886 ;; This newsgroup is empty.
2887 (gnus-summary-catchup-and-exit nil t)
2888 (gnus-message 6 "No unread news")
2890 (gnus-kill-or-deaden-summary kill-buffer))
2891 ;; Return nil from this function.
2893 ;; Hide conversation thread subtrees. We cannot do this in
2894 ;; gnus-summary-prepare-hook since kill processing may not
2895 ;; work with hidden articles.
2896 (and gnus-show-threads
2897 gnus-thread-hide-subtree
2898 (gnus-summary-hide-all-threads))
2900 (gnus-kill-or-deaden-summary kill-buffer))
2901 ;; Show first unread article if requested.
2902 (if (and (not no-article)
2904 gnus-newsgroup-unreads
2905 gnus-auto-select-first)
2907 (gnus-configure-windows 'summary)
2909 ((eq gnus-auto-select-first 'best)
2910 (gnus-summary-best-unread-article))
2911 ((eq gnus-auto-select-first t)
2912 (gnus-summary-first-unread-article))
2913 ((gnus-functionp gnus-auto-select-first)
2914 (funcall gnus-auto-select-first))))
2915 ;; Don't select any articles, just move point to the first
2916 ;; article in the group.
2917 (goto-char (point-min))
2918 (gnus-summary-position-point)
2919 (gnus-configure-windows 'summary 'force)
2920 (gnus-set-mode-line 'summary))
2921 (when (get-buffer-window gnus-group-buffer t)
2922 ;; Gotta use windows, because recenter does weird stuff if
2923 ;; the current buffer ain't the displayed window.
2924 (let ((owin (selected-window)))
2925 (select-window (get-buffer-window gnus-group-buffer t))
2926 (when (gnus-group-goto-group group)
2928 (select-window owin)))
2929 ;; Mark this buffer as "prepared".
2930 (setq gnus-newsgroup-prepared t)
2931 (gnus-run-hooks 'gnus-summary-prepared-hook)
2934 (defun gnus-summary-prepare ()
2935 "Generate the summary buffer."
2937 (let ((buffer-read-only nil))
2939 (setq gnus-newsgroup-data nil
2940 gnus-newsgroup-data-reverse nil)
2941 (gnus-run-hooks 'gnus-summary-generate-hook)
2942 ;; Generate the buffer, either with threads or without.
2943 (when gnus-newsgroup-headers
2944 (gnus-summary-prepare-threads
2945 (if gnus-show-threads
2946 (gnus-sort-gathered-threads
2947 (funcall gnus-summary-thread-gathering-function
2949 (gnus-cut-threads (gnus-make-threads)))))
2950 ;; Unthreaded display.
2951 (gnus-sort-articles gnus-newsgroup-headers))))
2952 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2953 ;; Call hooks for modifying summary buffer.
2954 (goto-char (point-min))
2955 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2957 (defsubst gnus-general-simplify-subject (subject)
2958 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2961 ;; Truncate the subject.
2962 (gnus-simplify-subject-functions
2963 (gnus-map-function gnus-simplify-subject-functions subject))
2964 ((numberp gnus-summary-gather-subject-limit)
2965 (setq subject (gnus-simplify-subject-re subject))
2966 (if (> (length subject) gnus-summary-gather-subject-limit)
2967 (substring subject 0 gnus-summary-gather-subject-limit)
2969 ;; Fuzzily simplify it.
2970 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2971 (gnus-simplify-subject-fuzzy subject))
2972 ;; Just remove the leading "Re:".
2974 (gnus-simplify-subject-re subject))))
2976 (if (and gnus-summary-gather-exclude-subject
2977 (string-match gnus-summary-gather-exclude-subject subject))
2978 nil ; This article shouldn't be gathered
2981 (defun gnus-summary-simplify-subject-query ()
2982 "Query where the respool algorithm would put this article."
2984 (gnus-summary-select-article)
2985 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2987 (defun gnus-gather-threads-by-subject (threads)
2988 "Gather threads by looking at Subject headers."
2989 (if (not gnus-summary-make-false-root)
2991 (let ((hashtb (gnus-make-hashtable 1024))
2994 subject hthread whole-subject)
2996 (setq subject (gnus-general-simplify-subject
2997 (setq whole-subject (mail-header-subject
3000 (if (setq hthread (gnus-gethash subject hashtb))
3002 ;; We enter a dummy root into the thread, if we
3003 ;; haven't done that already.
3004 (unless (stringp (caar hthread))
3005 (setcar hthread (list whole-subject (car hthread))))
3006 ;; We add this new gathered thread to this gathered
3008 (setcdr (car hthread)
3009 (nconc (cdar hthread) (list (car threads))))
3010 ;; Remove it from the list of threads.
3011 (setcdr prev (cdr threads))
3012 (setq threads prev))
3013 ;; Enter this thread into the hash table.
3014 (gnus-sethash subject threads hashtb)))
3016 (setq threads (cdr threads)))
3019 (defun gnus-gather-threads-by-references (threads)
3020 "Gather threads by looking at References headers."
3021 (let ((idhashtb (gnus-make-hashtable 1024))
3022 (thhashtb (gnus-make-hashtable 1024))
3025 ids references id gthread gid entered ref)
3027 (when (setq references (mail-header-references (caar threads)))
3028 (setq id (mail-header-id (caar threads))
3029 ids (gnus-split-references references)
3031 (while (setq ref (pop ids))
3032 (setq ids (delete ref ids))
3033 (if (not (setq gid (gnus-gethash ref idhashtb)))
3035 (gnus-sethash ref id idhashtb)
3036 (gnus-sethash id threads thhashtb))
3037 (setq gthread (gnus-gethash gid thhashtb))
3039 ;; We enter a dummy root into the thread, if we
3040 ;; haven't done that already.
3041 (unless (stringp (caar gthread))
3042 (setcar gthread (list (mail-header-subject (caar gthread))
3044 ;; We add this new gathered thread to this gathered
3046 (setcdr (car gthread)
3047 (nconc (cdar gthread) (list (car threads)))))
3048 ;; Add it into the thread hash table.
3049 (gnus-sethash id gthread thhashtb)
3051 ;; Remove it from the list of threads.
3052 (setcdr prev (cdr threads))
3053 (setq threads prev))))
3055 (setq threads (cdr threads)))
3058 (defun gnus-sort-gathered-threads (threads)
3059 "Sort subtreads inside each gathered thread by article number."
3060 (let ((result threads))
3062 (when (stringp (caar threads))
3063 (setcdr (car threads)
3064 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3065 (setq threads (cdr threads)))
3068 (defun gnus-thread-loop-p (root thread)
3069 "Say whether ROOT is in THREAD."
3070 (let ((stack (list thread))
3073 (while (setq thread (pop stack))
3074 (setq th (cdr thread))
3076 (not (eq (caar th) root)))
3079 ;; We have found a loop.
3081 (setcdr thread (delq (car th) (cdr thread)))
3082 (if (boundp (setq ref-dep (intern "none"
3083 gnus-newsgroup-dependencies)))
3084 (setcdr (symbol-value ref-dep)
3085 (nconc (cdr (symbol-value ref-dep))
3087 (set ref-dep (list nil (car th))))
3090 ;; Push all the subthreads onto the stack.
3091 (push (cdr thread) stack)))
3094 (defun gnus-make-threads ()
3095 "Go through the dependency hashtb and find the roots. Return all threads."
3097 (while (catch 'infloop
3100 ;; Deal with self-referencing References loops.
3101 (when (and (car (symbol-value refs))
3108 (car (symbol-value refs)) thread))
3109 (cdr (symbol-value refs)))))))
3112 (unless (car (symbol-value refs))
3113 ;; These threads do not refer back to any other articles,
3114 ;; so they're roots.
3115 (setq threads (append (cdr (symbol-value refs)) threads))))
3116 gnus-newsgroup-dependencies)))
3119 ;; Build the thread tree.
3120 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3121 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3123 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3124 if it was already present.
3126 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3127 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3128 Message-IDs will be renamed be renamed to a unique Message-ID before
3131 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3132 (let* ((id (mail-header-id header))
3133 (id-dep (and id (intern id dependencies)))
3134 ref ref-dep ref-header)
3135 ;; Enter this `header' in the `dependencies' table.
3139 ;; The first two cases do the normal part: enter a new `header'
3140 ;; in the `dependencies' table.
3141 ((not (boundp id-dep))
3142 (set id-dep (list header)))
3143 ((null (car (symbol-value id-dep)))
3144 (setcar (symbol-value id-dep) header))
3146 ;; From here the `header' was already present in the
3147 ;; `dependencies' table.
3149 ;; Overrides an existing entry;
3150 ;; just set the header part of the entry.
3151 (setcar (symbol-value id-dep) header))
3153 ;; Renames the existing `header' to a unique Message-ID.
3154 ((not gnus-summary-ignore-duplicates)
3155 ;; An article with this Message-ID has already been seen.
3156 ;; We rename the Message-ID.
3157 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3159 (mail-header-set-id header id))
3161 ;; The last case ignores an existing entry, except it adds any
3162 ;; additional Xrefs (in case the two articles came from different
3164 ;; Also sets `header' to `nil' meaning that the `dependencies'
3165 ;; table was *not* modified.
3167 (mail-header-set-xref
3168 (car (symbol-value id-dep))
3169 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3171 (or (mail-header-xref header) "")))
3175 ;; First check if that we are not creating a References loop.
3176 (setq ref (gnus-parent-id (mail-header-references header)))
3178 (setq ref-dep (intern-soft ref dependencies))
3180 (setq ref-header (car (symbol-value ref-dep))))
3181 (if (string= id ref)
3182 ;; Yuk! This is a reference loop. Make the article be a
3185 (mail-header-set-references (car (symbol-value id-dep)) "none")
3187 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3188 (setq ref (gnus-parent-id (mail-header-references header)))
3189 (setq ref-dep (intern (or ref "none") dependencies))
3190 (if (boundp ref-dep)
3191 (setcdr (symbol-value ref-dep)
3192 (nconc (cdr (symbol-value ref-dep))
3193 (list (symbol-value id-dep))))
3194 (set ref-dep (list nil (symbol-value id-dep)))))
3197 (defun gnus-build-sparse-threads ()
3198 (let ((headers gnus-newsgroup-headers)
3199 (mail-parse-charset gnus-newsgroup-charset)
3200 (gnus-summary-ignore-duplicates t)
3201 header references generation relations
3202 subject child end new-child date)
3203 ;; First we create an alist of generations/relations, where
3204 ;; generations is how much we trust the relation, and the relation
3206 (gnus-message 7 "Making sparse threads...")
3208 (nnheader-set-temp-buffer " *gnus sparse threads*")
3209 (while (setq header (pop headers))
3210 (when (and (setq references (mail-header-references header))
3211 (not (string= references "")))
3213 (setq child (mail-header-id header)
3214 subject (mail-header-subject header)
3215 date (mail-header-date header)
3217 (while (search-backward ">" nil t)
3218 (setq end (1+ (point)))
3219 (when (search-backward "<" nil t)
3220 (setq new-child (buffer-substring (point) end))
3221 (push (list (incf generation)
3222 child (setq child new-child)
3226 (push (list (1+ generation) child nil subject) relations))
3228 (kill-buffer (current-buffer)))
3229 ;; Sort over trustworthiness.
3232 (when (gnus-dependencies-add-header
3233 (make-full-mail-header
3234 gnus-reffed-article-number
3235 (nth 3 relation) "" (or (nth 4 relation) "")
3237 (or (nth 2 relation) "") 0 0 "")
3238 gnus-newsgroup-dependencies nil)
3239 (push gnus-reffed-article-number gnus-newsgroup-limit)
3240 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3241 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3242 gnus-newsgroup-reads)
3243 (decf gnus-reffed-article-number)))
3244 (sort relations 'car-less-than-car))
3245 (gnus-message 7 "Making sparse threads...done")))
3247 (defun gnus-build-old-threads ()
3248 ;; Look at all the articles that refer back to old articles, and
3249 ;; fetch the headers for the articles that aren't there. This will
3250 ;; build complete threads - if the roots haven't been expired by the
3252 (let ((mail-parse-charset gnus-newsgroup-charset)
3256 (when (not (car (symbol-value refs)))
3257 (setq heads (cdr (symbol-value refs)))
3259 (if (memq (mail-header-number (caar heads))
3260 gnus-newsgroup-dormant)
3261 (setq heads (cdr heads))
3262 (setq id (symbol-name refs))
3263 (while (and (setq id (gnus-build-get-header id))
3264 (not (car (gnus-id-to-thread id)))))
3265 (setq heads nil)))))
3266 gnus-newsgroup-dependencies)))
3268 ;; This function has to be called with point after the article number
3269 ;; on the beginning of the line.
3270 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3271 (let ((eol (gnus-point-at-eol))
3272 (buffer (current-buffer))
3275 ;; overview: [num subject from date id refs chars lines misc]
3278 (narrow-to-region (point) eol)
3283 (make-full-mail-header
3285 (funcall gnus-decode-encoded-word-function
3286 (nnheader-nov-field)) ; subject
3287 (funcall gnus-decode-encoded-word-function
3288 (nnheader-nov-field)) ; from
3289 (nnheader-nov-field) ; date
3290 (nnheader-nov-read-message-id) ; id
3291 (nnheader-nov-field) ; refs
3292 (nnheader-nov-read-integer) ; chars
3293 (nnheader-nov-read-integer) ; lines
3295 (nnheader-nov-field)) ; misc
3296 (nnheader-nov-parse-extra)))) ; extra
3300 (when gnus-alter-header-function
3301 (funcall gnus-alter-header-function header))
3302 (gnus-dependencies-add-header header dependencies force-new)))
3304 (defun gnus-build-get-header (id)
3305 ;; Look through the buffer of NOV lines and find the header to
3306 ;; ID. Enter this line into the dependencies hash table, and return
3307 ;; the id of the parent article (if any).
3308 (let ((deps gnus-newsgroup-dependencies)
3312 (set-buffer nntp-server-buffer)
3313 (let ((case-fold-search nil))
3314 (goto-char (point-min))
3315 (while (and (not found)
3316 (search-forward id nil t))
3318 (setq found (looking-at
3319 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3320 (regexp-quote id))))
3321 (or found (beginning-of-line 2)))
3325 (setq header (gnus-nov-parse-line
3326 (read (current-buffer)) deps))
3327 (gnus-parent-id (mail-header-references header))))))
3329 (let ((number (mail-header-number header)))
3330 (push number gnus-newsgroup-limit)
3331 (push header gnus-newsgroup-headers)
3332 (if (memq number gnus-newsgroup-unselected)
3334 (push number gnus-newsgroup-unreads)
3335 (setq gnus-newsgroup-unselected
3336 (delq number gnus-newsgroup-unselected)))
3337 (push number gnus-newsgroup-ancient)))))))
3339 (defun gnus-build-all-threads ()
3340 "Read all the headers."
3341 (let ((gnus-summary-ignore-duplicates t)
3342 (mail-parse-charset gnus-newsgroup-charset)
3343 (dependencies gnus-newsgroup-dependencies)
3346 (set-buffer nntp-server-buffer)
3347 (let ((case-fold-search nil))
3348 (goto-char (point-min))
3351 (setq article (read (current-buffer))
3352 header (gnus-nov-parse-line article dependencies)))
3355 (set-buffer gnus-summary-buffer)
3356 (push header gnus-newsgroup-headers)
3357 (if (memq (setq article (mail-header-number header))
3358 gnus-newsgroup-unselected)
3360 (push article gnus-newsgroup-unreads)
3361 (setq gnus-newsgroup-unselected
3362 (delq article gnus-newsgroup-unselected)))
3363 (push article gnus-newsgroup-ancient)))
3364 (forward-line 1)))))))
3366 (defun gnus-summary-update-article-line (article header)
3367 "Update the line for ARTICLE using HEADERS."
3368 (let* ((id (mail-header-id header))
3369 (thread (gnus-id-to-thread id)))
3371 (error "Article in no thread"))
3372 ;; Update the thread.
3373 (setcar thread header)
3374 (gnus-summary-goto-subject article)
3375 (let* ((datal (gnus-data-find-list article))
3377 (length (when (cdr datal)
3378 (- (gnus-data-pos data)
3379 (gnus-data-pos (cadr datal)))))
3380 (buffer-read-only nil)
3381 (level (gnus-summary-thread-level)))
3383 (gnus-summary-insert-line
3384 header level nil (gnus-article-mark article)
3385 (memq article gnus-newsgroup-replied)
3386 (memq article gnus-newsgroup-expirable)
3387 ;; Only insert the Subject string when it's different
3388 ;; from the previous Subject string.
3393 (mail-header-subject
3396 (gnus-data-find-list
3398 (gnus-data-list t)))))
3399 ;; Error on the side of excessive subjects.
3401 (mail-header-subject header)))
3403 (mail-header-subject header))
3404 nil (cdr (assq article gnus-newsgroup-scored))
3405 (memq article gnus-newsgroup-processable))
3407 (gnus-data-update-list
3408 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3410 (defun gnus-summary-update-article (article &optional iheader)
3411 "Update ARTICLE in the summary buffer."
3412 (set-buffer gnus-summary-buffer)
3413 (let* ((header (gnus-summary-article-header article))
3414 (id (mail-header-id header))
3415 (data (gnus-data-find article))
3416 (thread (gnus-id-to-thread id))
3417 (references (mail-header-references header))
3421 (when (and references
3422 (not (equal "" references)))
3425 (buffer-read-only nil)
3431 (delq thread parent)))
3432 (if (gnus-summary-insert-subject id header)
3433 ;; Set the (possibly) new article number in the data structure.
3434 (gnus-data-set-number data (gnus-id-to-article id))
3438 (defun gnus-rebuild-thread (id &optional line)
3439 "Rebuild the thread containing ID.
3440 If LINE, insert the rebuilt thread starting on line LINE."
3441 (let ((buffer-read-only nil)
3442 old-pos current thread data)
3443 (if (not gnus-show-threads)
3444 (setq thread (list (car (gnus-id-to-thread id))))
3445 ;; Get the thread this article is part of.
3446 (setq thread (gnus-remove-thread id)))
3447 (setq old-pos (gnus-point-at-bol))
3448 (setq current (save-excursion
3449 (and (zerop (forward-line -1))
3450 (gnus-summary-article-number))))
3451 ;; If this is a gathered thread, we have to go some re-gathering.
3452 (when (stringp (car thread))
3453 (let ((subject (car thread))
3455 (setq thread (cdr thread))
3457 (unless (memq (setq thr (gnus-id-to-thread
3459 (mail-header-id (caar thread)))))
3462 (setq thread (cdr thread)))
3463 ;; We now have all (unique) roots.
3464 (if (= (length roots) 1)
3465 ;; All the loose roots are now one solid root.
3466 (setq thread (car roots))
3467 (setq thread (cons subject (gnus-sort-threads roots))))))
3469 ;; We then insert this thread into the summary buffer.
3471 (goto-char (point-min))
3472 (forward-line (1- line)))
3473 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3474 (if gnus-show-threads
3475 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3476 (gnus-summary-prepare-unthreaded thread))
3477 (setq data (nreverse gnus-newsgroup-data))
3478 (setq threads gnus-newsgroup-threads))
3479 ;; We splice the new data into the data structure.
3480 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3481 ;;!!! then we want to insert at the beginning of the buffer.
3482 ;;!!! That happens to be true with Gnus now, but that may
3483 ;;!!! change in the future. Perhaps.
3484 (gnus-data-enter-list
3485 (if line nil current) data (- (point) old-pos))
3486 (setq gnus-newsgroup-threads
3487 (nconc threads gnus-newsgroup-threads))
3488 (gnus-data-compute-positions))))
3490 (defun gnus-number-to-header (number)
3491 "Return the header for article NUMBER."
3492 (let ((headers gnus-newsgroup-headers))
3494 (not (= number (mail-header-number (car headers)))))
3499 (defun gnus-parent-headers (in-headers &optional generation)
3500 "Return the headers of the GENERATIONeth parent of HEADERS."
3502 (setq generation 1))
3504 (headers in-headers)
3507 (not (zerop generation))
3508 (setq references (mail-header-references headers)))
3509 (setq headers (if (and references
3510 (setq parent (gnus-parent-id references)))
3511 (car (gnus-id-to-thread parent))
3514 (and (not (eq headers in-headers))
3517 (defun gnus-id-to-thread (id)
3518 "Return the (sub-)thread where ID appears."
3519 (gnus-gethash id gnus-newsgroup-dependencies))
3521 (defun gnus-id-to-article (id)
3522 "Return the article number of ID."
3523 (let ((thread (gnus-id-to-thread id)))
3526 (mail-header-number (car thread)))))
3528 (defun gnus-id-to-header (id)
3529 "Return the article headers of ID."
3530 (car (gnus-id-to-thread id)))
3532 (defun gnus-article-displayed-root-p (article)
3533 "Say whether ARTICLE is a root(ish) article."
3534 (let ((level (gnus-summary-thread-level article))
3535 (refs (mail-header-references (gnus-summary-article-header article)))
3541 ((null (gnus-parent-id refs)) t)
3543 (null (setq particle (gnus-id-to-article
3544 (gnus-parent-id refs))))
3545 (null (gnus-summary-thread-level particle)))))))
3547 (defun gnus-root-id (id)
3548 "Return the id of the root of the thread where ID appears."
3550 (while (and id (setq prev (car (gnus-id-to-thread id))))
3552 id (gnus-parent-id (mail-header-references prev))))
3555 (defun gnus-articles-in-thread (thread)
3556 "Return the list of articles in THREAD."
3557 (cons (mail-header-number (car thread))
3558 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3560 (defun gnus-remove-thread (id &optional dont-remove)
3561 "Remove the thread that has ID in it."
3562 (let (headers thread last-id)
3563 ;; First go up in this thread until we find the root.
3564 (setq last-id (gnus-root-id id)
3565 headers (message-flatten-list (gnus-id-to-thread last-id)))
3566 ;; We have now found the real root of this thread. It might have
3567 ;; been gathered into some loose thread, so we have to search
3568 ;; through the threads to find the thread we wanted.
3569 (let ((threads gnus-newsgroup-threads)
3572 (setq sub (car threads))
3573 (if (stringp (car sub))
3574 ;; This is a gathered thread, so we look at the roots
3575 ;; below it to find whether this article is in this
3578 (setq sub (cdr sub))
3580 (when (member (caar sub) headers)
3581 (setq thread (car threads)
3584 (setq sub (cdr sub))))
3585 ;; It's an ordinary thread, so we check it.
3586 (when (eq (car sub) (car headers))
3589 (setq threads (cdr threads)))
3590 ;; If this article is in no thread, then it's a root.
3593 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3594 (setq thread (gnus-id-to-thread last-id)))
3597 thread ; We return this thread.
3599 (if (stringp (car thread))
3601 ;; If we use dummy roots, then we have to remove the
3602 ;; dummy root as well.
3603 (when (eq gnus-summary-make-false-root 'dummy)
3604 ;; We go to the dummy root by going to
3605 ;; the first sub-"thread", and then one line up.
3606 (gnus-summary-goto-article
3607 (mail-header-number (caadr thread)))
3610 (gnus-data-compute-positions))
3611 (setq thread (cdr thread))
3613 (gnus-remove-thread-1 (car thread))
3614 (setq thread (cdr thread))))
3615 (gnus-remove-thread-1 thread))))))))
3617 (defun gnus-remove-thread-1 (thread)
3618 "Remove the thread THREAD recursively."
3619 (let ((number (mail-header-number (pop thread)))
3621 (setq thread (reverse thread))
3623 (gnus-remove-thread-1 (pop thread)))
3624 (when (setq d (gnus-data-find number))
3625 (goto-char (gnus-data-pos d))
3626 (gnus-summary-show-thread)
3629 (- (gnus-point-at-bol)
3631 (1+ (gnus-point-at-eol))
3632 (gnus-delete-line)))))))
3634 (defun gnus-sort-threads (threads)
3636 (if (not gnus-thread-sort-functions)
3638 (gnus-message 8 "Sorting threads...")
3640 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3641 (gnus-message 8 "Sorting threads...done"))))
3643 (defun gnus-sort-articles (articles)
3645 (when gnus-article-sort-functions
3646 (gnus-message 7 "Sorting articles...")
3648 (setq gnus-newsgroup-headers
3649 (sort articles (gnus-make-sort-function
3650 gnus-article-sort-functions)))
3651 (gnus-message 7 "Sorting articles...done"))))
3653 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3654 (defmacro gnus-thread-header (thread)
3655 ;; Return header of first article in THREAD.
3656 ;; Note that THREAD must never, ever be anything else than a variable -
3657 ;; using some other form will lead to serious barfage.
3658 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3659 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3660 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3663 (defsubst gnus-article-sort-by-number (h1 h2)
3664 "Sort articles by article number."
3665 (< (mail-header-number h1)
3666 (mail-header-number h2)))
3668 (defun gnus-thread-sort-by-number (h1 h2)
3669 "Sort threads by root article number."
3670 (gnus-article-sort-by-number
3671 (gnus-thread-header h1) (gnus-thread-header h2)))
3673 (defsubst gnus-article-sort-by-lines (h1 h2)
3674 "Sort articles by article Lines header."
3675 (< (mail-header-lines h1)
3676 (mail-header-lines h2)))
3678 (defun gnus-thread-sort-by-lines (h1 h2)
3679 "Sort threads by root article Lines header."
3680 (gnus-article-sort-by-lines
3681 (gnus-thread-header h1) (gnus-thread-header h2)))
3683 (defsubst gnus-article-sort-by-chars (h1 h2)
3684 "Sort articles by octet length."
3685 (< (mail-header-chars h1)
3686 (mail-header-chars h2)))
3688 (defun gnus-thread-sort-by-chars (h1 h2)
3689 "Sort threads by root article octet length."
3690 (gnus-article-sort-by-chars
3691 (gnus-thread-header h1) (gnus-thread-header h2)))
3693 (defsubst gnus-article-sort-by-author (h1 h2)
3694 "Sort articles by root author."
3696 (let ((extract (funcall
3697 gnus-extract-address-components
3698 (mail-header-from h1))))
3699 (or (car extract) (cadr extract) ""))
3700 (let ((extract (funcall
3701 gnus-extract-address-components
3702 (mail-header-from h2))))
3703 (or (car extract) (cadr extract) ""))))
3705 (defun gnus-thread-sort-by-author (h1 h2)
3706 "Sort threads by root author."
3707 (gnus-article-sort-by-author
3708 (gnus-thread-header h1) (gnus-thread-header h2)))
3710 (defsubst gnus-article-sort-by-subject (h1 h2)
3711 "Sort articles by root subject."
3713 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3714 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3716 (defun gnus-thread-sort-by-subject (h1 h2)
3717 "Sort threads by root subject."
3718 (gnus-article-sort-by-subject
3719 (gnus-thread-header h1) (gnus-thread-header h2)))
3721 (defsubst gnus-article-sort-by-date (h1 h2)
3722 "Sort articles by root article date."
3724 (gnus-date-get-time (mail-header-date h1))
3725 (gnus-date-get-time (mail-header-date h2))))
3727 (defun gnus-thread-sort-by-date (h1 h2)
3728 "Sort threads by root article date."
3729 (gnus-article-sort-by-date
3730 (gnus-thread-header h1) (gnus-thread-header h2)))
3732 (defsubst gnus-article-sort-by-score (h1 h2)
3733 "Sort articles by root article score.
3734 Unscored articles will be counted as having a score of zero."
3735 (> (or (cdr (assq (mail-header-number h1)
3736 gnus-newsgroup-scored))
3737 gnus-summary-default-score 0)
3738 (or (cdr (assq (mail-header-number h2)
3739 gnus-newsgroup-scored))
3740 gnus-summary-default-score 0)))
3742 (defun gnus-thread-sort-by-score (h1 h2)
3743 "Sort threads by root article score."
3744 (gnus-article-sort-by-score
3745 (gnus-thread-header h1) (gnus-thread-header h2)))
3747 (defun gnus-thread-sort-by-total-score (h1 h2)
3748 "Sort threads by the sum of all scores in the thread.
3749 Unscored articles will be counted as having a score of zero."
3750 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3752 (defun gnus-thread-total-score (thread)
3753 ;; This function find the total score of THREAD.
3754 (cond ((null thread)
3757 (if (stringp (car thread))
3758 (apply gnus-thread-score-function 0
3759 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3760 (gnus-thread-total-score-1 thread)))
3762 (gnus-thread-total-score-1 (list thread)))))
3764 (defun gnus-thread-total-score-1 (root)
3765 ;; This function find the total score of the thread below ROOT.
3766 (setq root (car root))
3767 (apply gnus-thread-score-function
3769 (mapcar 'gnus-thread-total-score
3770 (cdr (gnus-id-to-thread (mail-header-id root))))
3771 (when (> (mail-header-number root) 0)
3772 (list (or (cdr (assq (mail-header-number root)
3773 gnus-newsgroup-scored))
3774 gnus-summary-default-score 0))))
3775 (list gnus-summary-default-score)
3778 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3779 (defvar gnus-tmp-prev-subject nil)
3780 (defvar gnus-tmp-false-parent nil)
3781 (defvar gnus-tmp-root-expunged nil)
3782 (defvar gnus-tmp-dummy-line nil)
3784 (defvar gnus-tmp-header)
3785 (defun gnus-extra-header (type &optional header)
3786 "Return the extra header of TYPE."
3787 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3790 (defun gnus-summary-prepare-threads (threads)
3791 "Prepare summary buffer from THREADS and indentation LEVEL.
3792 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3793 or a straight list of headers."
3794 (gnus-message 7 "Generating summary...")
3796 (setq gnus-newsgroup-threads threads)
3799 (let ((gnus-tmp-level 0)
3800 (default-score (or gnus-summary-default-score 0))
3801 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3802 thread number subject stack state gnus-tmp-gathered beg-match
3803 new-roots gnus-tmp-new-adopts thread-end
3804 gnus-tmp-header gnus-tmp-unread
3805 gnus-tmp-replied gnus-tmp-subject-or-nil
3806 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3807 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3808 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3810 (setq gnus-tmp-prev-subject nil)
3812 (if (vectorp (car threads))
3813 ;; If this is a straight (sic) list of headers, then a
3814 ;; threaded summary display isn't required, so we just create
3815 ;; an unthreaded one.
3816 (gnus-summary-prepare-unthreaded threads)
3818 ;; Do the threaded display.
3820 (while (or threads stack gnus-tmp-new-adopts new-roots)
3822 (if (and (= gnus-tmp-level 0)
3825 (not gnus-tmp-false-parent)
3826 (or gnus-tmp-new-adopts new-roots))
3827 (if gnus-tmp-new-adopts
3828 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3829 thread (list (car gnus-tmp-new-adopts))
3830 gnus-tmp-header (caar thread)
3831 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3833 (setq thread (list (car new-roots))
3834 gnus-tmp-header (caar thread)
3835 new-roots (cdr new-roots))))
3838 ;; If there are some threads, we do them before the
3839 ;; threads on the stack.
3840 (setq thread threads
3841 gnus-tmp-header (caar thread))
3842 ;; There were no current threads, so we pop something off
3844 (setq state (car stack)
3845 gnus-tmp-level (car state)
3848 gnus-tmp-header (caar thread))))
3850 (setq gnus-tmp-false-parent nil)
3851 (setq gnus-tmp-root-expunged nil)
3852 (setq thread-end nil)
3854 (if (stringp gnus-tmp-header)
3855 ;; The header is a dummy root.
3857 ((eq gnus-summary-make-false-root 'adopt)
3858 ;; We let the first article adopt the rest.
3859 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3861 (setq gnus-tmp-gathered
3863 (lambda (h) (mail-header-number (car h)))
3866 (setq thread (cons (list (caar thread)
3869 (setq gnus-tmp-level -1
3870 gnus-tmp-false-parent t))
3871 ((eq gnus-summary-make-false-root 'empty)
3872 ;; We print adopted articles with empty subject fields.
3873 (setq gnus-tmp-gathered
3875 (lambda (h) (mail-header-number (car h)))
3878 (setq gnus-tmp-level -1))
3879 ((eq gnus-summary-make-false-root 'dummy)
3880 ;; We remember that we probably want to output a dummy
3882 (setq gnus-tmp-dummy-line gnus-tmp-header)
3883 (setq gnus-tmp-prev-subject gnus-tmp-header))
3885 ;; We do not make a root for the gathered
3886 ;; sub-threads at all.
3887 (setq gnus-tmp-level -1)))
3889 (setq number (mail-header-number gnus-tmp-header)
3890 subject (mail-header-subject gnus-tmp-header))
3893 ;; If the thread has changed subject, we might want to make
3894 ;; this subthread into a root.
3895 ((and (null gnus-thread-ignore-subject)
3896 (not (zerop gnus-tmp-level))
3897 gnus-tmp-prev-subject
3899 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3900 (setq new-roots (nconc new-roots (list (car thread)))
3902 gnus-tmp-header nil))
3903 ;; If the article lies outside the current limit,
3904 ;; then we do not display it.
3905 ((not (memq number gnus-newsgroup-limit))
3906 (setq gnus-tmp-gathered
3908 (lambda (h) (mail-header-number (car h)))
3911 (setq gnus-tmp-new-adopts (if (cdar thread)
3912 (append gnus-tmp-new-adopts
3914 gnus-tmp-new-adopts)
3916 gnus-tmp-header nil)
3917 (when (zerop gnus-tmp-level)
3918 (setq gnus-tmp-root-expunged t)))
3919 ;; Perhaps this article is to be marked as read?
3920 ((and gnus-summary-mark-below
3921 (< (or (cdr (assq number gnus-newsgroup-scored))
3923 gnus-summary-mark-below)
3924 ;; Don't touch sparse articles.
3925 (not (gnus-summary-article-sparse-p number))
3926 (not (gnus-summary-article-ancient-p number)))
3927 (setq gnus-newsgroup-unreads
3928 (delq number gnus-newsgroup-unreads))
3929 (if gnus-newsgroup-auto-expire
3930 (push number gnus-newsgroup-expirable)
3931 (push (cons number gnus-low-score-mark)
3932 gnus-newsgroup-reads))))
3934 (when gnus-tmp-header
3935 ;; We may have an old dummy line to output before this
3937 (when (and gnus-tmp-dummy-line
3940 (mail-header-subject gnus-tmp-header)))
3941 (gnus-summary-insert-dummy-line
3942 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3943 (setq gnus-tmp-dummy-line nil))
3945 ;; Compute the mark.
3946 (setq gnus-tmp-unread (gnus-article-mark number))
3948 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3949 gnus-tmp-header gnus-tmp-level)
3950 gnus-newsgroup-data)
3952 ;; Actually insert the line.
3954 gnus-tmp-subject-or-nil
3956 ((and gnus-thread-ignore-subject
3957 gnus-tmp-prev-subject
3958 (not (inline (gnus-subject-equal
3959 gnus-tmp-prev-subject subject))))
3961 ((zerop gnus-tmp-level)
3962 (if (and (eq gnus-summary-make-false-root 'empty)
3963 (memq number gnus-tmp-gathered)
3964 gnus-tmp-prev-subject
3965 (inline (gnus-subject-equal
3966 gnus-tmp-prev-subject subject)))
3967 gnus-summary-same-subject
3969 (t gnus-summary-same-subject)))
3970 (if (and (eq gnus-summary-make-false-root 'adopt)
3971 (= gnus-tmp-level 1)
3972 (memq number gnus-tmp-gathered))
3973 (setq gnus-tmp-opening-bracket ?\<
3974 gnus-tmp-closing-bracket ?\>)
3975 (setq gnus-tmp-opening-bracket ?\[
3976 gnus-tmp-closing-bracket ?\]))
3978 gnus-tmp-indentation
3979 (aref gnus-thread-indent-array gnus-tmp-level)
3980 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3981 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3982 gnus-summary-default-score 0)
3984 (if (or (null gnus-summary-default-score)
3985 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3986 gnus-summary-zcore-fuzz))
3988 (if (< gnus-tmp-score gnus-summary-default-score)
3989 gnus-score-below-mark gnus-score-over-mark))
3991 (cond ((memq number gnus-newsgroup-processable)
3993 ((memq number gnus-newsgroup-cached)
3995 ((memq number gnus-newsgroup-replied)
3997 ((memq number gnus-newsgroup-saved)
3999 (t gnus-unread-mark))
4000 gnus-tmp-from (mail-header-from gnus-tmp-header)
4003 ((string-match "<[^>]+> *$" gnus-tmp-from)
4004 (setq beg-match (match-beginning 0))
4005 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4006 (substring gnus-tmp-from (1+ (match-beginning 0))
4007 (1- (match-end 0))))
4008 (substring gnus-tmp-from 0 beg-match)))
4009 ((string-match "(.+)" gnus-tmp-from)
4010 (substring gnus-tmp-from
4011 (1+ (match-beginning 0)) (1- (match-end 0))))
4013 (when (string= gnus-tmp-name "")
4014 (setq gnus-tmp-name gnus-tmp-from))
4015 (unless (numberp gnus-tmp-lines)
4016 (setq gnus-tmp-lines 0))
4017 (gnus-put-text-property
4019 (progn (eval gnus-summary-line-format-spec) (point))
4020 'gnus-number number)
4023 (gnus-run-hooks 'gnus-summary-update-hook)
4026 (setq gnus-tmp-prev-subject subject)))
4028 (when (nth 1 thread)
4029 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4030 (incf gnus-tmp-level)
4031 (setq threads (if thread-end nil (cdar thread)))
4033 (setq gnus-tmp-level 0)))))
4034 (gnus-message 7 "Generating summary...done"))
4036 (defun gnus-summary-prepare-unthreaded (headers)
4037 "Generate an unthreaded summary buffer based on HEADERS."
4038 (let (header number mark)
4043 ;; We may have to root out some bad articles...
4044 (when (memq (setq number (mail-header-number
4045 (setq header (pop headers))))
4046 gnus-newsgroup-limit)
4047 ;; Mark article as read when it has a low score.
4048 (when (and gnus-summary-mark-below
4049 (< (or (cdr (assq number gnus-newsgroup-scored))
4050 gnus-summary-default-score 0)
4051 gnus-summary-mark-below)
4052 (not (gnus-summary-article-ancient-p number)))
4053 (setq gnus-newsgroup-unreads
4054 (delq number gnus-newsgroup-unreads))
4055 (if gnus-newsgroup-auto-expire
4056 (push number gnus-newsgroup-expirable)
4057 (push (cons number gnus-low-score-mark)
4058 gnus-newsgroup-reads)))
4060 (setq mark (gnus-article-mark number))
4061 (push (gnus-data-make number mark (1+ (point)) header 0)
4062 gnus-newsgroup-data)
4063 (gnus-summary-insert-line
4065 mark (memq number gnus-newsgroup-replied)
4066 (memq number gnus-newsgroup-expirable)
4067 (mail-header-subject header) nil
4068 (cdr (assq number gnus-newsgroup-scored))
4069 (memq number gnus-newsgroup-processable))))))
4071 (defun gnus-summary-remove-list-identifiers ()
4072 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4073 (let ((regexp (if (stringp gnus-list-identifiers)
4074 gnus-list-identifiers
4075 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4076 (dolist (header gnus-newsgroup-headers)
4077 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4078 " *\\)\\)+\\(Re: +\\)?\\)")
4079 (mail-header-subject header))
4080 (mail-header-set-subject
4081 header (concat (substring (mail-header-subject header)
4082 0 (match-beginning 1))
4084 (match-string 3 (mail-header-subject header))
4085 (match-string 5 (mail-header-subject header)))
4086 (substring (mail-header-subject header)
4087 (match-end 1))))))))
4089 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4090 "Select newsgroup GROUP.
4091 If READ-ALL is non-nil, all articles in the group are selected.
4092 If SELECT-ARTICLES, only select those articles from GROUP."
4093 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4094 ;;!!! Dirty hack; should be removed.
4095 (gnus-summary-ignore-duplicates
4096 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4098 gnus-summary-ignore-duplicates))
4099 (info (nth 2 entry))
4100 articles fetched-articles cached)
4102 (unless (gnus-check-server
4103 (setq gnus-current-select-method
4104 (gnus-find-method-for-group group)))
4105 (error "Couldn't open server"))
4107 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4108 (gnus-activate-group group) ; Or we can activate it...
4109 (progn ; Or we bug out.
4110 (when (equal major-mode 'gnus-summary-mode)
4111 (kill-buffer (current-buffer)))
4112 (error "Couldn't request group %s: %s"
4113 group (gnus-status-message group))))
4115 (unless (gnus-request-group group t)
4116 (when (equal major-mode 'gnus-summary-mode)
4117 (kill-buffer (current-buffer)))
4118 (error "Couldn't request group %s: %s"
4119 group (gnus-status-message group)))
4121 (setq gnus-newsgroup-name group)
4122 (setq gnus-newsgroup-unselected nil)
4123 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4124 (gnus-summary-setup-default-charset)
4126 ;; Adjust and set lists of article marks.
4128 (gnus-adjust-marked-articles info))
4130 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4131 (when (gnus-virtual-group-p group)
4132 (setq cached gnus-newsgroup-cached))
4134 (setq gnus-newsgroup-unreads
4135 (gnus-set-difference
4136 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4137 gnus-newsgroup-dormant))
4139 (setq gnus-newsgroup-processable nil)
4141 (gnus-update-read-articles group gnus-newsgroup-unreads)
4143 (if (setq articles select-articles)
4144 (setq gnus-newsgroup-unselected
4145 (gnus-sorted-intersection
4146 gnus-newsgroup-unreads
4147 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4148 (setq articles (gnus-articles-to-read group read-all)))
4152 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4154 ((eq articles 0) nil)
4156 ;; Init the dependencies hash table.
4157 (setq gnus-newsgroup-dependencies
4158 (gnus-make-hashtable (length articles)))
4159 (gnus-set-global-variables)
4160 ;; Retrieve the headers and read them in.
4161 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4162 (setq gnus-newsgroup-headers
4164 (setq gnus-headers-retrieved-by
4165 (gnus-retrieve-headers
4166 articles gnus-newsgroup-name
4167 ;; We might want to fetch old headers, but
4168 ;; not if there is only 1 article.
4170 (not (eq gnus-fetch-old-headers 'some))
4171 (not (numberp gnus-fetch-old-headers)))
4172 (> (length articles) 1))
4173 gnus-fetch-old-headers))))
4174 (gnus-get-newsgroup-headers-xover
4175 articles nil nil gnus-newsgroup-name t)
4176 (gnus-get-newsgroup-headers)))
4177 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4179 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4181 (setq gnus-newsgroup-cached cached))
4183 ;; Suppress duplicates?
4184 (when gnus-suppress-duplicates
4185 (gnus-dup-suppress-articles))
4187 ;; Set the initial limit.
4188 (setq gnus-newsgroup-limit (copy-sequence articles))
4189 ;; Remove canceled articles from the list of unread articles.
4190 (setq gnus-newsgroup-unreads
4191 (gnus-set-sorted-intersection
4192 gnus-newsgroup-unreads
4193 (setq fetched-articles
4194 (mapcar (lambda (headers) (mail-header-number headers))
4195 gnus-newsgroup-headers))))
4196 ;; Removed marked articles that do not exist.
4197 (gnus-update-missing-marks
4198 (gnus-sorted-complement fetched-articles articles))
4199 ;; We might want to build some more threads first.
4200 (when (and gnus-fetch-old-headers
4201 (eq gnus-headers-retrieved-by 'nov))
4202 (if (eq gnus-fetch-old-headers 'invisible)
4203 (gnus-build-all-threads)
4204 (gnus-build-old-threads)))
4205 ;; Let the Gnus agent mark articles as read.
4207 (gnus-agent-get-undownloaded-list))
4208 ;; Remove list identifiers from subject
4209 (when gnus-list-identifiers
4210 (gnus-summary-remove-list-identifiers))
4211 ;; Check whether auto-expire is to be done in this group.
4212 (setq gnus-newsgroup-auto-expire
4213 (gnus-group-auto-expirable-p group))
4214 ;; Set up the article buffer now, if necessary.
4215 (unless gnus-single-article-buffer
4216 (gnus-article-setup-buffer))
4217 ;; First and last article in this newsgroup.
4218 (when gnus-newsgroup-headers
4219 (setq gnus-newsgroup-begin
4220 (mail-header-number (car gnus-newsgroup-headers))
4223 (gnus-last-element gnus-newsgroup-headers))))
4224 ;; GROUP is successfully selected.
4225 (or gnus-newsgroup-headers t)))))
4227 (defun gnus-articles-to-read (group &optional read-all)
4228 ;; Find out what articles the user wants to read.
4230 ;; Select all articles if `read-all' is non-nil, or if there
4231 ;; are no unread articles.
4233 (and (zerop (length gnus-newsgroup-marked))
4234 (zerop (length gnus-newsgroup-unreads)))
4235 (eq (gnus-group-find-parameter group 'display)
4238 (gnus-uncompress-range (gnus-active group))
4239 (gnus-cache-articles-in-group group))
4240 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4241 (copy-sequence gnus-newsgroup-unreads))
4243 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4244 (scored (length scored-list))
4245 (number (length articles))
4246 (marked (+ (length gnus-newsgroup-marked)
4247 (length gnus-newsgroup-dormant)))
4255 ((and (or (<= scored marked) (= scored number))
4256 (numberp gnus-large-newsgroup)
4257 (> number gnus-large-newsgroup))
4261 "How many articles from %s (default %d): "
4262 (gnus-limit-string gnus-newsgroup-name 35)
4264 (if (string-match "^[ \t]*$" input) number input)))
4265 ((and (> scored marked) (< scored number)
4266 (> (- scored number) 20))
4269 (format "%s %s (%d scored, %d total): "
4270 "How many articles from"
4271 group scored number))))
4272 (if (string-match "^[ \t]*$" input)
4276 (setq select (if (stringp select) (string-to-number select) select))
4277 (if (or (null select) (zerop select))
4279 (if (and (not (zerop scored)) (<= (abs select) scored))
4281 (setq articles (sort scored-list '<))
4282 (setq number (length articles)))
4283 (setq articles (copy-sequence articles)))
4285 (when (< (abs select) number)
4287 ;; Select the N oldest articles.
4288 (setcdr (nthcdr (1- (abs select)) articles) nil)
4289 ;; Select the N most recent articles.
4290 (setq articles (nthcdr (- number select) articles))))
4291 (setq gnus-newsgroup-unselected
4292 (gnus-sorted-intersection
4293 gnus-newsgroup-unreads
4294 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4295 (when gnus-alter-articles-to-read-function
4296 (setq gnus-newsgroup-unreads
4298 (funcall gnus-alter-articles-to-read-function
4299 gnus-newsgroup-name gnus-newsgroup-unreads)
4303 (defun gnus-killed-articles (killed articles)
4306 (when (inline (gnus-member-of-range (car articles) killed))
4307 (push (car articles) out))
4308 (setq articles (cdr articles)))
4311 (defun gnus-uncompress-marks (marks)
4312 "Uncompress the mark ranges in MARKS."
4313 (let ((uncompressed '(score bookmark))
4316 (if (memq (caar marks) uncompressed)
4317 (push (car marks) out)
4318 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4319 (setq marks (cdr marks)))
4322 (defun gnus-adjust-marked-articles (info)
4323 "Set all article lists and remove all marks that are no longer valid."
4324 (let* ((marked-lists (gnus-info-marks info))
4325 (active (gnus-active (gnus-info-group info)))
4328 (types gnus-article-mark-lists)
4329 (uncompressed '(score bookmark killed))
4330 marks var articles article mark)
4333 (setq marks (pop marked-lists))
4334 (set (setq var (intern (format "gnus-newsgroup-%s"
4335 (car (rassq (setq mark (car marks))
4337 (if (memq (car marks) uncompressed) (cdr marks)
4338 (gnus-uncompress-range (cdr marks))))
4340 (setq articles (symbol-value var))
4342 ;; All articles have to be subsets of the active articles.
4344 ;; Adjust "simple" lists.
4345 ((memq mark '(tick dormant expire reply save))
4347 (when (or (< (setq article (pop articles)) min) (> article max))
4348 (set var (delq article (symbol-value var))))))
4350 ((memq mark uncompressed)
4351 (when (not (listp (cdr (symbol-value var))))
4352 (set var (list (symbol-value var))))
4353 (when (not (listp (cdr articles)))
4354 (setq articles (list articles)))
4356 (when (or (not (consp (setq article (pop articles))))
4357 (< (car article) min)
4358 (> (car article) max))
4359 (set var (delq article (symbol-value var))))))))))
4361 (defun gnus-update-missing-marks (missing)
4362 "Go through the list of MISSING articles and remove them from the mark lists."
4364 (let ((types gnus-article-mark-lists)
4366 ;; Go through all types.
4368 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4369 (when (symbol-value var)
4370 ;; This list has articles. So we delete all missing articles
4374 (set var (delq (pop m) (symbol-value var)))))))))
4376 (defun gnus-update-marks ()
4377 "Enter the various lists of marked articles into the newsgroup info list."
4378 (let ((types gnus-article-mark-lists)
4379 (info (gnus-get-info gnus-newsgroup-name))
4380 (uncompressed '(score bookmark killed))
4381 type list newmarked symbol delta-marks)
4383 ;; Add all marks lists to the list of marks lists.
4384 (while (setq type (pop types))
4385 (setq list (symbol-value
4387 (intern (format "gnus-newsgroup-%s"
4391 ;; Get rid of the entries of the articles that have the
4393 (when (and (eq (cdr type) 'score)
4397 (prev (cons nil list))
4400 (if (or (not (consp (car arts)))
4401 (= (cdar arts) gnus-summary-default-score))
4402 (setcdr prev (cdr arts))
4404 (setq arts (cdr arts)))
4405 (setq list (cdr all)))))
4407 (unless (memq (cdr type) uncompressed)
4408 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4410 (when (gnus-check-backend-function
4411 'request-set-mark gnus-newsgroup-name)
4412 ;; uncompressed:s are not proper flags (they are cons cells)
4413 ;; cache is a internal gnus flag
4414 (unless (memq (cdr type) (cons 'cache uncompressed))
4415 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4416 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4417 (add (gnus-remove-from-range
4418 (gnus-copy-sequence list) old)))
4420 (push (list add 'add (list (cdr type))) delta-marks))
4422 (push (list del 'del (list (cdr type))) delta-marks)))))
4425 (push (cons (cdr type) list) newmarked)))
4428 (unless (gnus-check-group gnus-newsgroup-name)
4429 (error "Can't open server for %s" gnus-newsgroup-name))
4430 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4432 ;; Enter these new marks into the info of the group.
4434 (setcar (nthcdr 3 info) newmarked)
4435 ;; Add the marks lists to the end of the info.
4437 (setcdr (nthcdr 2 info) (list newmarked))))
4439 ;; Cut off the end of the info if there's nothing else there.
4443 (when (nthcdr (decf i) info)
4444 (setcdr (nthcdr i info) nil)))))))
4446 (defun gnus-set-mode-line (where)
4447 "This function sets the mode line of the article or summary buffers.
4448 If WHERE is `summary', the summary mode line format will be used."
4449 ;; Is this mode line one we keep updated?
4450 (when (and (memq where gnus-updated-mode-lines)
4452 (intern (format "gnus-%s-mode-line-format-spec" where))))
4455 ;; We evaluate this in the summary buffer since these
4456 ;; variables are buffer-local to that buffer.
4457 (set-buffer gnus-summary-buffer)
4458 ;; We bind all these variables that are used in the `eval' form
4460 (let* ((mformat (symbol-value
4462 (format "gnus-%s-mode-line-format-spec" where))))
4463 (gnus-tmp-group-name (gnus-group-name-decode
4465 (gnus-group-name-charset
4467 gnus-newsgroup-name)))
4468 (gnus-tmp-article-number (or gnus-current-article 0))
4469 (gnus-tmp-unread gnus-newsgroup-unreads)
4470 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4471 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4472 (gnus-tmp-unread-and-unselected
4473 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4474 (zerop gnus-tmp-unselected))
4476 ((zerop gnus-tmp-unselected)
4477 (format "{%d more}" gnus-tmp-unread-and-unticked))
4478 (t (format "{%d(+%d) more}"
4479 gnus-tmp-unread-and-unticked
4480 gnus-tmp-unselected))))
4482 (if (and gnus-current-headers
4483 (vectorp gnus-current-headers))
4484 (gnus-mode-string-quote
4485 (mail-header-subject gnus-current-headers))
4487 bufname-length max-len
4488 gnus-tmp-header);; passed as argument to any user-format-funcs
4489 (setq mode-string (eval mformat))
4490 (setq bufname-length (if (string-match "%b" mode-string)
4493 (if (eq where 'summary)
4495 (get-buffer gnus-article-buffer))))
4498 (setq max-len (max 4 (if gnus-mode-non-string-length
4500 gnus-mode-non-string-length
4502 (length mode-string))))
4503 ;; We might have to chop a bit of the string off...
4504 (when (> (length mode-string) max-len)
4506 (concat (truncate-string-to-width mode-string (- max-len 3))
4508 ;; Pad the mode string a bit.
4509 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4510 ;; Update the mode line.
4511 (setq mode-line-buffer-identification
4512 (gnus-mode-line-buffer-identification (list mode-string)))
4513 (set-buffer-modified-p t))))
4515 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4516 "Go through the HEADERS list and add all Xrefs to a hash table.
4517 The resulting hash table is returned, or nil if no Xrefs were found."
4518 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4519 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4520 (xref-hashtb (gnus-make-hashtable))
4521 start group entry number xrefs header)
4523 (setq header (pop headers))
4524 (when (and (setq xrefs (mail-header-xref header))
4525 (not (memq (setq number (mail-header-number header))
4528 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4529 (setq start (match-end 0))
4530 (setq group (if prefix
4531 (concat prefix (substring xrefs (match-beginning 1)
4533 (substring xrefs (match-beginning 1) (match-end 1))))
4535 (string-to-int (substring xrefs (match-beginning 2)
4537 (if (setq entry (gnus-gethash group xref-hashtb))
4538 (setcdr entry (cons number (cdr entry)))
4539 (gnus-sethash group (cons number nil) xref-hashtb)))))
4540 (and start xref-hashtb)))
4542 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4543 "Look through all the headers and mark the Xrefs as read."
4544 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4545 name entry info xref-hashtb idlist method nth4)
4547 (set-buffer gnus-group-buffer)
4548 (when (setq xref-hashtb
4549 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4552 (unless (string= from-newsgroup (setq name (symbol-name group)))
4553 (setq idlist (symbol-value group))
4554 ;; Dead groups are not updated.
4556 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4558 (when (stringp (setq nth4 (gnus-info-method info)))
4559 (setq nth4 (gnus-server-to-method nth4))))
4560 ;; Only do the xrefs if the group has the same
4561 ;; select method as the group we have just read.
4562 (or (gnus-methods-equal-p
4563 nth4 (gnus-find-method-for-group from-newsgroup))
4565 (equal nth4 (setq method (gnus-find-method-for-group
4567 (and (equal (car nth4) (car method))
4568 (equal (nth 1 nth4) (nth 1 method))))
4569 gnus-use-cross-reference
4570 (or (not (eq gnus-use-cross-reference t))
4572 ;; Only do cross-references on subscribed
4573 ;; groups, if that is what is wanted.
4574 (<= (gnus-info-level info) gnus-level-subscribed))
4575 (gnus-group-make-articles-read name idlist))))
4578 (defun gnus-compute-read-articles (group articles)
4579 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4580 (info (nth 2 entry))
4581 (active (gnus-active group))
4584 ;; First peel off all invalid article numbers.
4586 (let ((ids articles)
4588 (while (setq id (pop ids))
4589 (when (and first (> id (cdr active)))
4590 ;; We'll end up in this situation in one particular
4591 ;; obscure situation. If you re-scan a group and get
4592 ;; a new article that is cross-posted to a different
4593 ;; group that has not been re-scanned, you might get
4594 ;; crossposted article that has a higher number than
4595 ;; Gnus believes possible. So we re-activate this
4596 ;; group as well. This might mean doing the
4597 ;; crossposting thingy will *increase* the number
4598 ;; of articles in some groups. Tsk, tsk.
4599 (setq active (or (gnus-activate-group group) active)))
4600 (when (or (> id (cdr active))
4601 (< id (car active)))
4602 (setq articles (delq id articles))))))
4603 ;; If the read list is nil, we init it.
4605 (null (gnus-info-read info))
4607 (setq ninfo (cons 1 (1- (car active))))
4608 (setq ninfo (gnus-info-read info)))
4609 ;; Then we add the read articles to the range.
4611 ninfo (setq articles (sort articles '<))))))
4613 (defun gnus-group-make-articles-read (group articles)
4614 "Update the info of GROUP to say that ARTICLES are read."
4616 (entry (gnus-gethash group gnus-newsrc-hashtb))
4617 (info (nth 2 entry))
4618 (active (gnus-active group))
4621 (setq range (gnus-compute-read-articles group articles))
4623 (set-buffer gnus-group-buffer)
4626 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4627 (gnus-info-set-read ',info ',(gnus-info-read info))
4628 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4629 (gnus-group-update-group ,group t))))
4630 ;; Add the read articles to the range.
4631 (gnus-info-set-read info range)
4632 ;; Then we have to re-compute how many unread
4633 ;; articles there are in this group.
4637 (setq num (- (1+ (cdr active)) (car active))))
4638 ((not (listp (cdr range)))
4639 (setq num (- (cdr active) (- (1+ (cdr range))
4643 (if (numberp (car range))
4645 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4646 (setq range (cdr range)))
4647 (setq num (- (cdr active) num))))
4648 ;; Update the number of unread articles.
4650 ;; Update the group buffer.
4651 (gnus-group-update-group group t)))))
4653 (defvar gnus-newsgroup-none-id 0)
4655 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4656 (let ((cur nntp-server-buffer)
4659 (save-excursion (set-buffer gnus-summary-buffer)
4660 gnus-newsgroup-dependencies)))
4662 (mail-parse-charset gnus-newsgroup-charset)
4663 (mail-parse-ignored-charsets
4664 (save-excursion (condition-case nil
4665 (set-buffer gnus-summary-buffer)
4667 gnus-newsgroup-ignored-charsets)))
4669 (set-buffer nntp-server-buffer)
4670 ;; Translate all TAB characters into SPACE characters.
4671 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4672 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4673 (gnus-run-hooks 'gnus-parse-headers-hook)
4674 (let ((case-fold-search t)
4675 in-reply-to header p lines chars)
4676 (goto-char (point-min))
4677 ;; Search to the beginning of the next header. Error messages
4678 ;; do not begin with 2 or 3.
4679 (while (re-search-forward "^[23][0-9]+ " nil t)
4682 ;; This implementation of this function, with nine
4683 ;; search-forwards instead of the one re-search-forward and
4684 ;; a case (which basically was the old function) is actually
4685 ;; about twice as fast, even though it looks messier. You
4686 ;; can't have everything, I guess. Speed and elegance
4687 ;; doesn't always go hand in hand.
4696 (narrow-to-region (point)
4697 (or (and (search-forward "\n.\n" nil t)
4703 (if (search-forward "\nsubject: " nil t)
4704 (funcall gnus-decode-encoded-word-function
4705 (nnheader-header-value))
4710 (if (search-forward "\nfrom: " nil t)
4711 (funcall gnus-decode-encoded-word-function
4712 (nnheader-header-value))
4717 (if (search-forward "\ndate: " nil t)
4718 (nnheader-header-value) ""))
4722 (setq id (if (re-search-forward
4723 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4724 ;; We do it this way to make sure the Message-ID
4725 ;; is (somewhat) syntactically valid.
4726 (buffer-substring (match-beginning 1)
4728 ;; If there was no message-id, we just fake one
4729 ;; to make subsequent routines simpler.
4730 (nnheader-generate-fake-message-id))))
4734 (if (search-forward "\nreferences: " nil t)
4738 (nnheader-header-value)
4743 (search-backward ">" end t)
4746 (search-backward "<" end t)
4748 ;; Get the references from the in-reply-to header if there
4749 ;; were no references and the in-reply-to header looks
4751 (if (and (search-forward "\nin-reply-to: " nil t)
4752 (setq in-reply-to (nnheader-header-value))
4753 (string-match "<[^>]+>" in-reply-to))
4755 (setq ref (substring in-reply-to (match-beginning 0)
4757 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4758 (setq ref2 (substring in-reply-to (match-beginning 0)
4760 (when (> (length ref2) (length ref))
4767 (if (search-forward "\nchars: " nil t)
4768 (if (numberp (setq chars (ignore-errors (read cur))))
4774 (if (search-forward "\nlines: " nil t)
4775 (if (numberp (setq lines (ignore-errors (read cur))))
4781 (and (search-forward "\nxref: " nil t)
4782 (nnheader-header-value)))
4784 (when gnus-extra-headers
4785 (let ((extra gnus-extra-headers)
4789 (when (search-forward
4790 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4791 (push (cons (car extra) (nnheader-header-value))
4795 (when (equal id ref)
4798 (when gnus-alter-header-function
4799 (funcall gnus-alter-header-function header)
4800 (setq id (mail-header-id header)
4801 ref (gnus-parent-id (mail-header-references header))))
4804 (gnus-dependencies-add-header
4805 header dependencies force-new))
4806 (push header headers))
4807 (goto-char (point-max))
4809 (nreverse headers)))))
4811 ;; Goes through the xover lines and returns a list of vectors
4812 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4813 force-new dependencies
4814 group also-fetch-heads)
4815 "Parse the news overview data in the server buffer, and return a
4816 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4817 ;; Get the Xref when the users reads the articles since most/some
4818 ;; NNTP servers do not include Xrefs when using XOVER.
4819 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4820 (let ((mail-parse-charset gnus-newsgroup-charset)
4821 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4822 (cur nntp-server-buffer)
4823 (dependencies (or dependencies gnus-newsgroup-dependencies))
4824 number headers header)
4826 (set-buffer nntp-server-buffer)
4827 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4828 ;; Allow the user to mangle the headers before parsing them.
4829 (gnus-run-hooks 'gnus-parse-headers-hook)
4830 (goto-char (point-min))
4833 (while (and sequence (not (eobp)))
4834 (setq number (read cur))
4835 (while (and sequence
4836 (< (car sequence) number))
4837 (setq sequence (cdr sequence)))
4839 (eq number (car sequence))
4841 (setq sequence (cdr sequence))
4842 (setq header (inline
4843 (gnus-nov-parse-line
4844 number dependencies force-new))))
4845 (push header headers))
4848 (gnus-error 4 "Strange nov line (%d)"
4849 (count-lines (point-min) (point)))))
4851 ;; A common bug in inn is that if you have posted an article and
4852 ;; then retrieves the active file, it will answer correctly --
4853 ;; the new article is included. However, a NOV entry for the
4854 ;; article may not have been generated yet, so this may fail.
4855 ;; We work around this problem by retrieving the last few
4856 ;; headers using HEAD.
4857 (if (or (not also-fetch-heads)
4859 ;; We (probably) got all the headers.
4861 (let ((gnus-nov-is-evil t))
4864 (when (gnus-retrieve-headers sequence group)
4865 (gnus-get-newsgroup-headers))))))))
4867 (defun gnus-article-get-xrefs ()
4868 "Fill in the Xref value in `gnus-current-headers', if necessary.
4869 This is meant to be called in `gnus-article-internal-prepare-hook'."
4870 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4871 gnus-current-headers)))
4872 (or (not gnus-use-cross-reference)
4874 (and (mail-header-xref headers)
4875 (not (string= (mail-header-xref headers) "")))
4876 (let ((case-fold-search t)
4879 (nnheader-narrow-to-headers)
4880 (goto-char (point-min))
4881 (when (or (and (not (eobp))
4882 (eq (downcase (char-after)) ?x)
4883 (looking-at "Xref:"))
4884 (search-forward "\nXref:" nil t))
4885 (goto-char (1+ (match-end 0)))
4886 (setq xref (buffer-substring (point)
4887 (progn (end-of-line) (point))))
4888 (mail-header-set-xref headers xref)))))))
4890 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4891 "Find article ID and insert the summary line for that article.
4892 OLD-HEADER can either be a header or a line number to insert
4893 the subject line on."
4894 (let* ((line (and (numberp old-header) old-header))
4895 (old-header (and (vectorp old-header) old-header))
4896 (header (cond ((and old-header use-old-header)
4899 (gnus-number-to-header id))
4900 (gnus-number-to-header id))
4902 (gnus-read-header id))))
4903 (number (and (numberp id) id))
4906 ;; Rebuild the thread that this article is part of and go to the
4907 ;; article we have fetched.
4908 (when (and (not gnus-show-threads)
4911 (setq d (gnus-data-find (mail-header-number old-header))))
4912 (goto-char (gnus-data-pos d))
4915 (- (gnus-point-at-bol)
4917 (1+ (gnus-point-at-eol))
4918 (gnus-delete-line))))))
4920 (mail-header-set-number header (mail-header-number old-header)))
4921 (setq gnus-newsgroup-sparse
4922 (delq (setq number (mail-header-number header))
4923 gnus-newsgroup-sparse))
4924 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4925 (push number gnus-newsgroup-limit)
4926 (gnus-rebuild-thread (mail-header-id header) line)
4927 (gnus-summary-goto-subject number nil t))
4928 (when (and (numberp number)
4930 ;; We have to update the boundaries even if we can't fetch the
4931 ;; article if ID is a number -- so that the next `P' or `N'
4932 ;; command will fetch the previous (or next) article even
4933 ;; if the one we tried to fetch this time has been canceled.
4934 (when (> number gnus-newsgroup-end)
4935 (setq gnus-newsgroup-end number))
4936 (when (< number gnus-newsgroup-begin)
4937 (setq gnus-newsgroup-begin number))
4938 (setq gnus-newsgroup-unselected
4939 (delq number gnus-newsgroup-unselected)))
4940 ;; Report back a success?
4941 (and header (mail-header-number header))))
4943 ;;; Process/prefix in the summary buffer
4945 (defun gnus-summary-work-articles (n)
4946 "Return a list of articles to be worked upon.
4947 The prefix argument, the list of process marked articles, and the
4948 current article will be taken into consideration."
4950 (set-buffer gnus-summary-buffer)
4953 ;; A numerical prefix has been given.
4954 (setq n (prefix-numeric-value n))
4955 (let ((backward (< n 0))
4956 (n (abs (prefix-numeric-value n)))
4961 (push (setq article (gnus-summary-article-number))
4964 (gnus-summary-find-prev nil article)
4965 (gnus-summary-find-next nil article)))
4967 (nreverse articles)))
4968 ((and (gnus-region-active-p) (mark))
4969 (message "region active")
4970 ;; Work on the region between point and mark.
4971 (let ((max (max (point) (mark)))
4974 (goto-char (min (min (point) (mark))))
4977 (push (setq article (gnus-summary-article-number)) articles)
4978 (gnus-summary-find-next nil article)
4980 (nreverse articles))))
4981 (gnus-newsgroup-processable
4982 ;; There are process-marked articles present.
4983 ;; Save current state.
4984 (gnus-summary-save-process-mark)
4986 (reverse gnus-newsgroup-processable))
4988 ;; Just return the current article.
4989 (list (gnus-summary-article-number))))))
4991 (defmacro gnus-summary-iterate (arg &rest forms)
4992 "Iterate over the process/prefixed articles and do FORMS.
4993 ARG is the interactive prefix given to the command. FORMS will be
4994 executed with point over the summary line of the articles."
4995 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4996 `(let ((,articles (gnus-summary-work-articles ,arg)))
4998 (gnus-summary-goto-subject (car ,articles))
5002 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5003 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5005 (defun gnus-summary-save-process-mark ()
5006 "Push the current set of process marked articles on the stack."
5008 (push (copy-sequence gnus-newsgroup-processable)
5009 gnus-newsgroup-process-stack))
5011 (defun gnus-summary-kill-process-mark ()
5012 "Push the current set of process marked articles on the stack and unmark."
5014 (gnus-summary-save-process-mark)
5015 (gnus-summary-unmark-all-processable))
5017 (defun gnus-summary-yank-process-mark ()
5018 "Pop the last process mark state off the stack and restore it."
5020 (unless gnus-newsgroup-process-stack
5021 (error "Empty mark stack"))
5022 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5024 (defun gnus-summary-process-mark-set (set)
5025 "Make SET into the current process marked articles."
5026 (gnus-summary-unmark-all-processable)
5028 (gnus-summary-set-process-mark (pop set))))
5030 ;;; Searching and stuff
5032 (defun gnus-summary-search-group (&optional backward use-level)
5033 "Search for next unread newsgroup.
5034 If optional argument BACKWARD is non-nil, search backward instead."
5036 (set-buffer gnus-group-buffer)
5037 (when (gnus-group-search-forward
5038 backward nil (if use-level (gnus-group-group-level) nil))
5039 (gnus-group-group-name))))
5041 (defun gnus-summary-best-group (&optional exclude-group)
5042 "Find the name of the best unread group.
5043 If EXCLUDE-GROUP, do not go to this group."
5045 (set-buffer gnus-group-buffer)
5047 (gnus-group-best-unread-group exclude-group))))
5049 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5050 (if backward (gnus-summary-find-prev)
5051 (let* ((dummy (gnus-summary-article-intangible-p))
5052 (article (or article (gnus-summary-article-number)))
5053 (arts (gnus-data-find-list article))
5055 (when (and (not dummy)
5056 (or (not gnus-summary-check-current)
5058 (not (gnus-data-unread-p (car arts)))))
5059 (setq arts (cdr arts)))
5064 (when (or (and undownloaded
5065 (eq gnus-undownloaded-mark
5066 (gnus-data-mark (car arts))))
5067 (gnus-data-unread-p (car arts)))
5068 (setq result (car arts)
5070 (setq arts (cdr arts)))
5073 (goto-char (gnus-data-pos result))
5074 (gnus-data-number result)))))
5076 (defun gnus-summary-find-prev (&optional unread article)
5077 (let* ((eobp (eobp))
5078 (article (or article (gnus-summary-article-number)))
5079 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5081 (when (and (not eobp)
5082 (or (not gnus-summary-check-current)
5084 (not (gnus-data-unread-p (car arts)))))
5085 (setq arts (cdr arts)))
5090 (when (gnus-data-unread-p (car arts))
5091 (setq result (car arts)
5093 (setq arts (cdr arts)))
5096 (goto-char (gnus-data-pos result))
5097 (gnus-data-number result))))
5099 (defun gnus-summary-find-subject (subject &optional unread backward article)
5100 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5101 (article (or article (gnus-summary-article-number)))
5102 (articles (gnus-data-list backward))
5103 (arts (gnus-data-find-list article articles))
5105 (when (or (not gnus-summary-check-current)
5107 (not (gnus-data-unread-p (car arts))))
5108 (setq arts (cdr arts)))
5110 (and (or (not unread)
5111 (gnus-data-unread-p (car arts)))
5112 (vectorp (gnus-data-header (car arts)))
5114 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5115 (setq result (car arts)
5117 (setq arts (cdr arts)))
5119 (goto-char (gnus-data-pos result))
5120 (gnus-data-number result))))
5122 (defun gnus-summary-search-forward (&optional unread subject backward)
5123 "Search forward for an article.
5124 If UNREAD, look for unread articles. If SUBJECT, look for
5125 articles with that subject. If BACKWARD, search backward instead."
5126 (cond (subject (gnus-summary-find-subject subject unread backward))
5127 (backward (gnus-summary-find-prev unread))
5128 (t (gnus-summary-find-next unread))))
5130 (defun gnus-recenter (&optional n)
5131 "Center point in window and redisplay frame.
5132 Also do horizontal recentering."
5135 gnus-auto-center-summary
5136 (not (eq gnus-auto-center-summary 'vertical)))
5137 (gnus-horizontal-recenter))
5140 (defun gnus-summary-recenter ()
5141 "Center point in the summary window.
5142 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5143 displayed, no centering will be performed."
5144 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5145 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5147 (let* ((top (cond ((< (window-height) 4) 0)
5148 ((< (window-height) 7) 1)
5149 (t (if (numberp gnus-auto-center-summary)
5150 gnus-auto-center-summary
5152 (height (1- (window-height)))
5153 (bottom (save-excursion (goto-char (point-max))
5154 (forward-line (- height))
5156 (window (get-buffer-window (current-buffer))))
5157 ;; The user has to want it.
5158 (when gnus-auto-center-summary
5159 (when (get-buffer-window gnus-article-buffer)
5160 ;; Only do recentering when the article buffer is displayed,
5161 ;; Set the window start to either `bottom', which is the biggest
5162 ;; possible valid number, or the second line from the top,
5163 ;; whichever is the least.
5165 window (min bottom (save-excursion
5166 (forward-line (- top)) (point)))
5168 ;; Do horizontal recentering while we're at it.
5169 (when (and (get-buffer-window (current-buffer) t)
5170 (not (eq gnus-auto-center-summary 'vertical)))
5171 (let ((selected (selected-window)))
5172 (select-window (get-buffer-window (current-buffer) t))
5173 (gnus-summary-position-point)
5174 (gnus-horizontal-recenter)
5175 (select-window selected))))))
5177 (defun gnus-summary-jump-to-group (newsgroup)
5178 "Move point to NEWSGROUP in group mode buffer."
5179 ;; Keep update point of group mode buffer if visible.
5180 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5181 (save-window-excursion
5182 ;; Take care of tree window mode.
5183 (when (get-buffer-window gnus-group-buffer)
5184 (pop-to-buffer gnus-group-buffer))
5185 (gnus-group-jump-to-group newsgroup))
5187 ;; Take care of tree window mode.
5188 (if (get-buffer-window gnus-group-buffer)
5189 (pop-to-buffer gnus-group-buffer)
5190 (set-buffer gnus-group-buffer))
5191 (gnus-group-jump-to-group newsgroup))))
5193 ;; This function returns a list of article numbers based on the
5194 ;; difference between the ranges of read articles in this group and
5195 ;; the range of active articles.
5196 (defun gnus-list-of-unread-articles (group)
5197 (let* ((read (gnus-info-read (gnus-get-info group)))
5198 (active (or (gnus-active group) (gnus-activate-group group)))
5201 ;; If none are read, then all are unread.
5203 (setq first (car active))
5204 ;; If the range of read articles is a single range, then the
5205 ;; first unread article is the article after the last read
5206 ;; article. Sounds logical, doesn't it?
5207 (if (and (not (listp (cdr read)))
5208 (or (< (car read) (car active))
5209 (progn (setq read (list read))
5211 (setq first (max (car active) (1+ (cdr read))))
5212 ;; `read' is a list of ranges.
5213 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5216 (setq first (car active)))
5219 (while (< first nlast)
5221 (setq first (1+ first))))
5222 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5223 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5224 (setq read (cdr read)))))
5225 ;; And add the last unread articles.
5226 (while (<= first last)
5228 (setq first (1+ first)))
5229 ;; Return the list of unread articles.
5230 (delq 0 (nreverse unread))))
5232 (defun gnus-list-of-read-articles (group)
5233 "Return a list of unread, unticked and non-dormant articles."
5234 (let* ((info (gnus-get-info group))
5235 (marked (gnus-info-marks info))
5236 (active (gnus-active group)))
5238 (gnus-set-difference
5239 (gnus-sorted-complement
5240 (gnus-uncompress-range active)
5241 (gnus-list-of-unread-articles group))
5243 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5244 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5246 ;; Various summary commands
5248 (defun gnus-summary-select-article-buffer ()
5249 "Reconfigure windows to show article buffer."
5251 (if (not (gnus-buffer-live-p gnus-article-buffer))
5252 (error "There is no article buffer for this summary buffer")
5253 (gnus-configure-windows 'article)
5254 (select-window (get-buffer-window gnus-article-buffer))))
5256 (defun gnus-summary-universal-argument (arg)
5257 "Perform any operation on all articles that are process/prefixed."
5259 (let ((articles (gnus-summary-work-articles arg))
5266 (substitute-command-keys
5267 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5269 (gnus-error 1 "Undefined key")
5272 (gnus-summary-goto-subject (setq article (pop articles)))
5273 (let (gnus-newsgroup-processable)
5274 (command-execute func))
5275 (gnus-summary-remove-process-mark article)))))
5276 (gnus-summary-position-point))
5278 (defun gnus-summary-toggle-truncation (&optional arg)
5279 "Toggle truncation of summary lines.
5280 With arg, turn line truncation on iff arg is positive."
5282 (setq truncate-lines
5283 (if (null arg) (not truncate-lines)
5284 (> (prefix-numeric-value arg) 0)))
5287 (defun gnus-summary-reselect-current-group (&optional all rescan)
5288 "Exit and then reselect the current newsgroup.
5289 The prefix argument ALL means to select all articles."
5291 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5292 (error "Ephemeral groups can't be reselected"))
5293 (let ((current-subject (gnus-summary-article-number))
5294 (group gnus-newsgroup-name))
5295 (setq gnus-newsgroup-begin nil)
5297 ;; We have to adjust the point of group mode buffer because
5298 ;; point was moved to the next unread newsgroup by exiting.
5299 (gnus-summary-jump-to-group group)
5302 (gnus-group-get-new-news-this-group 1)))
5303 (gnus-group-read-group all t)
5304 (gnus-summary-goto-subject current-subject nil t)))
5306 (defun gnus-summary-rescan-group (&optional all)
5307 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5309 (gnus-summary-reselect-current-group all t))
5311 (defun gnus-summary-update-info (&optional non-destructive)
5313 (let ((group gnus-newsgroup-name))
5315 (when gnus-newsgroup-kill-headers
5316 (setq gnus-newsgroup-killed
5317 (gnus-compress-sequence
5319 (gnus-set-sorted-intersection
5320 (gnus-uncompress-range gnus-newsgroup-killed)
5321 (setq gnus-newsgroup-unselected
5322 (sort gnus-newsgroup-unselected '<)))
5323 (setq gnus-newsgroup-unreads
5324 (sort gnus-newsgroup-unreads '<)))
5326 (unless (listp (cdr gnus-newsgroup-killed))
5327 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5328 (let ((headers gnus-newsgroup-headers))
5329 ;; Set the new ranges of read articles.
5331 (set-buffer gnus-group-buffer)
5332 (gnus-undo-force-boundary))
5333 (gnus-update-read-articles
5334 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5335 ;; Set the current article marks.
5336 (let ((gnus-newsgroup-scored
5337 (if (and (not gnus-save-score)
5338 (not non-destructive))
5340 gnus-newsgroup-scored)))
5342 (gnus-update-marks)))
5343 ;; Do the cross-ref thing.
5344 (when gnus-use-cross-reference
5345 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5346 ;; Do not switch windows but change the buffer to work.
5347 (set-buffer gnus-group-buffer)
5348 (unless (gnus-ephemeral-group-p group)
5349 (gnus-group-update-group group)))))))
5351 (defun gnus-summary-save-newsrc (&optional force)
5352 "Save the current number of read/marked articles in the dribble buffer.
5353 The dribble buffer will then be saved.
5354 If FORCE (the prefix), also save the .newsrc file(s)."
5356 (gnus-summary-update-info t)
5358 (gnus-save-newsrc-file)
5359 (gnus-dribble-save)))
5361 (defun gnus-summary-exit (&optional temporary)
5362 "Exit reading current newsgroup, and then return to group selection mode.
5363 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5365 (gnus-set-global-variables)
5366 (when (gnus-buffer-live-p gnus-article-buffer)
5368 (set-buffer gnus-article-buffer)
5369 (mm-destroy-parts gnus-article-mime-handles)))
5370 (gnus-kill-save-kill-buffer)
5371 (gnus-async-halt-prefetch)
5372 (let* ((group gnus-newsgroup-name)
5373 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5376 (buf (current-buffer)))
5378 ;; Do adaptive scoring, and possibly save score files.
5379 (when gnus-newsgroup-adaptive
5380 (gnus-score-adaptive))
5381 (when gnus-use-scoring
5383 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5384 ;; If we have several article buffers, we kill them at exit.
5385 (unless gnus-single-article-buffer
5386 (gnus-kill-buffer gnus-original-article-buffer)
5387 (setq gnus-article-current nil))
5388 (when gnus-use-cache
5389 (gnus-cache-possibly-remove-articles)
5390 (gnus-cache-save-buffers))
5391 (gnus-async-prefetch-remove-group group)
5392 (when gnus-suppress-duplicates
5393 (gnus-dup-enter-articles))
5394 (when gnus-use-trees
5395 (gnus-tree-close group))
5396 (when gnus-use-cache
5397 (gnus-cache-write-active))
5398 ;; Remove entries for this group.
5399 (nnmail-purge-split-history (gnus-group-real-name group))
5400 ;; Make all changes in this group permanent.
5402 (gnus-run-hooks 'gnus-exit-group-hook)
5403 (gnus-summary-update-info))
5404 (gnus-close-group group)
5405 ;; Make sure where we were, and go to next newsgroup.
5406 (set-buffer gnus-group-buffer)
5408 (gnus-group-jump-to-group group))
5409 (gnus-run-hooks 'gnus-summary-exit-hook)
5410 (unless (or quit-config
5411 ;; If this group has disappeared from the summary
5412 ;; buffer, don't skip forwards.
5413 (not (string= group (gnus-group-group-name))))
5414 (gnus-group-next-unread-group 1))
5415 (setq group-point (point))
5418 ;; If we have several article buffers, we kill them at exit.
5419 (unless gnus-single-article-buffer
5420 (gnus-kill-buffer gnus-article-buffer)
5421 (gnus-kill-buffer gnus-original-article-buffer)
5422 (setq gnus-article-current nil))
5424 (if (not gnus-kill-summary-on-exit)
5425 (gnus-deaden-summary)
5426 ;; We set all buffer-local variables to nil. It is unclear why
5427 ;; this is needed, but if we don't, buffer-local variables are
5428 ;; not garbage-collected, it seems. This would the lead to en
5429 ;; ever-growing Emacs.
5430 (gnus-summary-clear-local-variables)
5431 (when (get-buffer gnus-article-buffer)
5432 (bury-buffer gnus-article-buffer))
5433 ;; We clear the global counterparts of the buffer-local
5434 ;; variables as well, just to be on the safe side.
5435 (set-buffer gnus-group-buffer)
5436 (gnus-summary-clear-local-variables)
5437 ;; Return to group mode buffer.
5438 (when (eq mode 'gnus-summary-mode)
5439 (gnus-kill-buffer buf)))
5440 (setq gnus-current-select-method gnus-select-method)
5441 (pop-to-buffer gnus-group-buffer)
5442 (if (not quit-config)
5444 (goto-char group-point)
5445 (gnus-configure-windows 'group 'force))
5446 (gnus-handle-ephemeral-exit quit-config))
5447 ;; Clear the current group name.
5449 (setq gnus-newsgroup-name nil)))))
5451 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5452 (defun gnus-summary-exit-no-update (&optional no-questions)
5453 "Quit reading current newsgroup without updating read article info."
5455 (let* ((group gnus-newsgroup-name)
5456 (quit-config (gnus-group-quit-config group)))
5457 (when (or no-questions
5459 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5460 (gnus-async-halt-prefetch)
5462 (delq 'gnus-summary-expire-articles
5463 (copy-sequence gnus-summary-prepare-exit-hook)))
5464 (when (gnus-buffer-live-p gnus-article-buffer)
5466 (set-buffer gnus-article-buffer)
5467 (mm-destroy-parts gnus-article-mime-handles)))
5468 ;; If we have several article buffers, we kill them at exit.
5469 (unless gnus-single-article-buffer
5470 (gnus-kill-buffer gnus-article-buffer)
5471 (gnus-kill-buffer gnus-original-article-buffer)
5472 (setq gnus-article-current nil))
5473 (if (not gnus-kill-summary-on-exit)
5474 (gnus-deaden-summary)
5475 (gnus-close-group group)
5476 (gnus-summary-clear-local-variables)
5477 (set-buffer gnus-group-buffer)
5478 (gnus-summary-clear-local-variables)
5479 (when (get-buffer gnus-summary-buffer)
5480 (kill-buffer gnus-summary-buffer)))
5481 (unless gnus-single-article-buffer
5482 (setq gnus-article-current nil))
5483 (when gnus-use-trees
5484 (gnus-tree-close group))
5485 (gnus-async-prefetch-remove-group group)
5486 (when (get-buffer gnus-article-buffer)
5487 (bury-buffer gnus-article-buffer))
5488 ;; Return to the group buffer.
5489 (gnus-configure-windows 'group 'force)
5490 ;; Clear the current group name.
5491 (setq gnus-newsgroup-name nil)
5492 (when (equal (gnus-group-group-name) group)
5493 (gnus-group-next-unread-group 1))
5495 (gnus-handle-ephemeral-exit quit-config)))))
5497 (defun gnus-handle-ephemeral-exit (quit-config)
5498 "Handle movement when leaving an ephemeral group.
5499 The state which existed when entering the ephemeral is reset."
5500 (if (not (buffer-name (car quit-config)))
5501 (gnus-configure-windows 'group 'force)
5502 (set-buffer (car quit-config))
5503 (cond ((eq major-mode 'gnus-summary-mode)
5504 (gnus-set-global-variables))
5505 ((eq major-mode 'gnus-article-mode)
5507 ;; The `gnus-summary-buffer' variable may point
5508 ;; to the old summary buffer when using a single
5510 (unless (gnus-buffer-live-p gnus-summary-buffer)
5511 (set-buffer gnus-group-buffer))
5512 (set-buffer gnus-summary-buffer)
5513 (gnus-set-global-variables))))
5514 (if (or (eq (cdr quit-config) 'article)
5515 (eq (cdr quit-config) 'pick))
5517 ;; The current article may be from the ephemeral group
5518 ;; thus it is best that we reload this article
5519 (gnus-summary-show-article)
5520 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5521 (gnus-configure-windows 'pick 'force)
5522 (gnus-configure-windows (cdr quit-config) 'force)))
5523 (gnus-configure-windows (cdr quit-config) 'force))
5524 (when (eq major-mode 'gnus-summary-mode)
5525 (gnus-summary-next-subject 1 nil t)
5526 (gnus-summary-recenter)
5527 (gnus-summary-position-point))))
5531 (defvar gnus-dead-summary-mode-map nil)
5533 (unless gnus-dead-summary-mode-map
5534 (setq gnus-dead-summary-mode-map (make-keymap))
5535 (suppress-keymap gnus-dead-summary-mode-map)
5536 (substitute-key-definition
5537 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5538 (let ((keys '("\C-d" "\r" "\177" [delete])))
5540 (define-key gnus-dead-summary-mode-map
5541 (pop keys) 'gnus-summary-wake-up-the-dead))))
5543 (defvar gnus-dead-summary-mode nil
5544 "Minor mode for Gnus summary buffers.")
5546 (defun gnus-dead-summary-mode (&optional arg)
5547 "Minor mode for Gnus summary buffers."
5549 (when (eq major-mode 'gnus-summary-mode)
5550 (make-local-variable 'gnus-dead-summary-mode)
5551 (setq gnus-dead-summary-mode
5552 (if (null arg) (not gnus-dead-summary-mode)
5553 (> (prefix-numeric-value arg) 0)))
5554 (when gnus-dead-summary-mode
5555 (gnus-add-minor-mode
5556 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5558 (defun gnus-deaden-summary ()
5559 "Make the current summary buffer into a dead summary buffer."
5560 ;; Kill any previous dead summary buffer.
5561 (when (and gnus-dead-summary
5562 (buffer-name gnus-dead-summary))
5564 (set-buffer gnus-dead-summary)
5565 (when gnus-dead-summary-mode
5566 (kill-buffer (current-buffer)))))
5567 ;; Make this the current dead summary.
5568 (setq gnus-dead-summary (current-buffer))
5569 (gnus-dead-summary-mode 1)
5570 (let ((name (buffer-name)))
5571 (when (string-match "Summary" name)
5573 (concat (substring name 0 (match-beginning 0)) "Dead "
5574 (substring name (match-beginning 0)))
5578 (defun gnus-kill-or-deaden-summary (buffer)
5579 "Kill or deaden the summary BUFFER."
5581 (when (and (buffer-name buffer)
5582 (not gnus-single-article-buffer))
5585 (gnus-kill-buffer gnus-article-buffer)
5586 (gnus-kill-buffer gnus-original-article-buffer)))
5587 (cond (gnus-kill-summary-on-exit
5588 (when (and gnus-use-trees
5589 (gnus-buffer-exists-p buffer))
5592 (gnus-tree-close gnus-newsgroup-name)))
5593 (gnus-kill-buffer buffer))
5594 ((gnus-buffer-exists-p buffer)
5597 (gnus-deaden-summary))))))
5599 (defun gnus-summary-wake-up-the-dead (&rest args)
5600 "Wake up the dead summary buffer."
5602 (gnus-dead-summary-mode -1)
5603 (let ((name (buffer-name)))
5604 (when (string-match "Dead " name)
5606 (concat (substring name 0 (match-beginning 0))
5607 (substring name (match-end 0)))
5609 (gnus-message 3 "This dead summary is now alive again"))
5611 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5612 (defun gnus-summary-fetch-faq (&optional faq-dir)
5613 "Fetch the FAQ for the current group.
5614 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5618 (when current-prefix-arg
5620 "Faq dir: " (and (listp gnus-group-faq-directory)
5621 (mapcar (lambda (file) (list file))
5622 gnus-group-faq-directory))))))
5623 (let (gnus-faq-buffer)
5624 (when (setq gnus-faq-buffer
5625 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5626 (gnus-configure-windows 'summary-faq))))
5628 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5629 (defun gnus-summary-describe-group (&optional force)
5630 "Describe the current newsgroup."
5632 (gnus-group-describe-group force gnus-newsgroup-name))
5634 (defun gnus-summary-describe-briefly ()
5635 "Describe summary mode commands briefly."
5637 (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")))
5639 ;; Walking around group mode buffer from summary mode.
5641 (defun gnus-summary-next-group (&optional no-article target-group backward)
5642 "Exit current newsgroup and then select next unread newsgroup.
5643 If prefix argument NO-ARTICLE is non-nil, no article is selected
5644 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5645 previous group instead."
5647 ;; Stop pre-fetching.
5648 (gnus-async-halt-prefetch)
5649 (let ((current-group gnus-newsgroup-name)
5650 (current-buffer (current-buffer))
5652 ;; First we semi-exit this group to update Xrefs and all variables.
5653 ;; We can't do a real exit, because the window conf must remain
5654 ;; the same in case the user is prompted for info, and we don't
5655 ;; want the window conf to change before that...
5656 (gnus-summary-exit t)
5657 (while (not entered)
5658 ;; Then we find what group we are supposed to enter.
5659 (set-buffer gnus-group-buffer)
5660 (gnus-group-jump-to-group current-group)
5663 (if (eq gnus-keep-same-level 'best)
5664 (gnus-summary-best-group gnus-newsgroup-name)
5665 (gnus-summary-search-group backward gnus-keep-same-level))))
5666 (if (not target-group)
5667 ;; There are no further groups, so we return to the group
5670 (gnus-message 5 "Returning to the group buffer")
5672 (when (gnus-buffer-live-p current-buffer)
5673 (set-buffer current-buffer)
5674 (gnus-summary-exit))
5675 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5676 ;; We try to enter the target group.
5677 (gnus-group-jump-to-group target-group)
5678 (let ((unreads (gnus-group-group-unread)))
5679 (if (and (or (eq t unreads)
5680 (and unreads (not (zerop unreads))))
5681 (gnus-summary-read-group
5682 target-group nil no-article
5683 (and (buffer-name current-buffer) current-buffer)
5686 (setq current-group target-group
5687 target-group nil)))))))
5689 (defun gnus-summary-prev-group (&optional no-article)
5690 "Exit current newsgroup and then select previous unread newsgroup.
5691 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5693 (gnus-summary-next-group no-article nil t))
5695 ;; Walking around summary lines.
5697 (defun gnus-summary-first-subject (&optional unread undownloaded)
5698 "Go to the first unread subject.
5699 If UNREAD is non-nil, go to the first unread article.
5700 Returns the article selected or nil if there are no unread articles."
5705 ((null gnus-newsgroup-data)
5706 (gnus-message 3 "No articles in the group")
5708 ;; Pick the first article.
5710 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5711 (gnus-data-number (car gnus-newsgroup-data)))
5712 ;; No unread articles.
5713 ((null gnus-newsgroup-unreads)
5714 (gnus-message 3 "No more unread articles")
5716 ;; Find the first unread article.
5718 (let ((data gnus-newsgroup-data))
5720 (and (not (and undownloaded
5721 (eq gnus-undownloaded-mark
5722 (gnus-data-mark (car data)))))
5723 (not (gnus-data-unread-p (car data)))))
5724 (setq data (cdr data)))
5726 (goto-char (gnus-data-pos (car data)))
5727 (gnus-data-number (car data))))))
5728 (gnus-summary-position-point)))
5730 (defun gnus-summary-next-subject (n &optional unread dont-display)
5731 "Go to next N'th summary line.
5732 If N is negative, go to the previous N'th subject line.
5733 If UNREAD is non-nil, only unread articles are selected.
5734 The difference between N and the actual number of steps taken is
5737 (let ((backward (< n 0))
5741 (gnus-summary-find-prev unread)
5742 (gnus-summary-find-next unread)))
5743 (unless (zerop (setq n (1- n)))
5744 (gnus-summary-show-thread)))
5746 (gnus-message 7 "No more%s articles"
5747 (if unread " unread" "")))
5748 (unless dont-display
5749 (gnus-summary-recenter)
5750 (gnus-summary-position-point))
5753 (defun gnus-summary-next-unread-subject (n)
5754 "Go to next N'th unread summary line."
5756 (gnus-summary-next-subject n t))
5758 (defun gnus-summary-prev-subject (n &optional unread)
5759 "Go to previous N'th summary line.
5760 If optional argument UNREAD is non-nil, only unread article is selected."
5762 (gnus-summary-next-subject (- n) unread))
5764 (defun gnus-summary-prev-unread-subject (n)
5765 "Go to previous N'th unread summary line."
5767 (gnus-summary-next-subject (- n) t))
5769 (defun gnus-summary-goto-subject (article &optional force silent)
5770 "Go the subject line of ARTICLE.
5771 If FORCE, also allow jumping to articles not currently shown."
5772 (interactive "nArticle number: ")
5774 (data (gnus-data-find article)))
5775 ;; We read in the article if we have to.
5778 (gnus-summary-insert-subject
5780 (if (or (numberp force) (vectorp force)) force)
5782 (setq data (gnus-data-find article)))
5787 (gnus-message 3 "Can't find article %d" article))
5789 (goto-char (gnus-data-pos data))
5790 (gnus-summary-position-point)
5793 ;; Walking around summary lines with displaying articles.
5795 (defun gnus-summary-expand-window (&optional arg)
5796 "Make the summary buffer take up the entire Emacs frame.
5797 Given a prefix, will force an `article' buffer configuration."
5800 (gnus-configure-windows 'article 'force)
5801 (gnus-configure-windows 'summary 'force)))
5803 (defun gnus-summary-display-article (article &optional all-header)
5804 "Display ARTICLE in article buffer."
5805 (gnus-set-global-variables)
5809 (if gnus-summary-display-article-function
5810 (funcall gnus-summary-display-article-function article all-header)
5811 (gnus-article-prepare article all-header))
5812 (gnus-run-hooks 'gnus-select-article-hook)
5813 (when (and gnus-current-article
5814 (not (zerop gnus-current-article)))
5815 (gnus-summary-goto-subject gnus-current-article))
5816 (gnus-summary-recenter)
5817 (when (and gnus-use-trees gnus-show-threads)
5818 (gnus-possibly-generate-tree article)
5819 (gnus-highlight-selected-tree article))
5820 ;; Successfully display article.
5821 (gnus-article-set-window-start
5822 (cdr (assq article gnus-newsgroup-bookmarks))))))
5824 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5825 "Select the current article.
5826 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5827 non-nil, the article will be re-fetched even if it already present in
5828 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5830 ;; Make sure we are in the summary buffer to work around bbdb bug.
5831 (unless (eq major-mode 'gnus-summary-mode)
5832 (set-buffer gnus-summary-buffer))
5833 (let ((article (or article (gnus-summary-article-number)))
5834 (all-headers (not (not all-headers))) ;Must be T or NIL.
5835 gnus-summary-display-article-function)
5837 (gnus-summary-article-pseudo-p article)
5838 (error "This is a pseudo-article"))
5840 (set-buffer gnus-summary-buffer)
5841 (if (or (and gnus-single-article-buffer
5842 (or (null gnus-current-article)
5843 (null gnus-article-current)
5844 (null (get-buffer gnus-article-buffer))
5845 (not (eq article (cdr gnus-article-current)))
5846 (not (equal (car gnus-article-current)
5847 gnus-newsgroup-name))))
5848 (and (not gnus-single-article-buffer)
5849 (or (null gnus-current-article)
5850 (not (eq gnus-current-article article))))
5852 ;; The requested article is different from the current article.
5854 (when (gnus-buffer-live-p gnus-article-buffer)
5855 (with-current-buffer gnus-article-buffer
5856 (mm-enable-multibyte)))
5857 (gnus-summary-display-article article all-headers)
5858 (when (gnus-buffer-live-p gnus-article-buffer)
5859 (with-current-buffer gnus-article-buffer
5860 (if (not gnus-article-decoded-p) ;; a local variable
5861 (mm-disable-multibyte))))
5862 (when (or all-headers gnus-show-all-headers)
5863 (gnus-article-show-all-headers))
5864 (gnus-article-set-window-start
5865 (cdr (assq article gnus-newsgroup-bookmarks)))
5867 (when (or all-headers gnus-show-all-headers)
5868 (gnus-article-show-all-headers))
5871 (defun gnus-summary-set-current-mark (&optional current-mark)
5872 "Obsolete function."
5875 (defun gnus-summary-next-article (&optional unread subject backward push)
5876 "Select the next article.
5877 If UNREAD, only unread articles are selected.
5878 If SUBJECT, only articles with SUBJECT are selected.
5879 If BACKWARD, the previous article is selected instead of the next."
5882 ;; Is there such an article?
5883 ((and (gnus-summary-search-forward unread subject backward)
5884 (or (gnus-summary-display-article (gnus-summary-article-number))
5885 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5886 (gnus-summary-position-point))
5887 ;; If not, we try the first unread, if that is wanted.
5889 gnus-auto-select-same
5890 (gnus-summary-first-unread-article))
5891 (gnus-summary-position-point)
5892 (gnus-message 6 "Wrapped"))
5893 ;; Try to get next/previous article not displayed in this group.
5894 ((and gnus-auto-extend-newsgroup
5895 (not unread) (not subject))
5896 (gnus-summary-goto-article
5897 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5898 nil (count-lines (point-min) (point))))
5899 ;; Go to next/previous group.
5901 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5902 (gnus-summary-jump-to-group gnus-newsgroup-name))
5903 (let ((cmd last-command-char)
5906 (set-buffer gnus-group-buffer)
5909 (if (eq gnus-keep-same-level 'best)
5910 (gnus-summary-best-group gnus-newsgroup-name)
5911 (gnus-summary-search-group backward gnus-keep-same-level))))
5912 ;; For some reason, the group window gets selected. We change
5914 (select-window (get-buffer-window (current-buffer)))
5915 ;; Select next unread newsgroup automagically.
5917 ((or (not gnus-auto-select-next)
5919 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5920 ((or (eq gnus-auto-select-next 'quietly)
5921 (and (eq gnus-auto-select-next 'slightly-quietly)
5923 (and (eq gnus-auto-select-next 'almost-quietly)
5924 (gnus-summary-last-article-p)))
5926 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5928 (gnus-message 7 "No more%s articles (%s)..."
5929 (if unread " unread" "")
5930 (if group (concat "selecting " group)
5932 (gnus-summary-next-group nil group backward)))
5934 (when (gnus-key-press-event-p last-input-event)
5935 (gnus-summary-walk-group-buffer
5936 gnus-newsgroup-name cmd unread backward point))))))))
5938 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5939 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5940 (?\C-p (gnus-group-prev-unread-group 1))))
5941 (cursor-in-echo-area t)
5942 keve key group ended)
5944 (set-buffer gnus-group-buffer)
5947 (if (eq gnus-keep-same-level 'best)
5948 (gnus-summary-best-group gnus-newsgroup-name)
5949 (gnus-summary-search-group backward gnus-keep-same-level))))
5952 5 "No more%s articles%s" (if unread " unread" "")
5954 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5955 (format " (Type %s for %s [%s])"
5956 (single-key-description cmd) group
5957 (car (gnus-gethash group gnus-newsrc-hashtb)))
5958 (format " (Type %s to exit %s)"
5959 (single-key-description cmd)
5960 gnus-newsgroup-name)))
5961 ;; Confirm auto selection.
5962 (setq key (car (setq keve (gnus-read-event-char))))
5965 ((assq key keystrokes)
5966 (let ((obuf (current-buffer)))
5967 (switch-to-buffer gnus-group-buffer)
5969 (gnus-group-jump-to-group group))
5970 (eval (cadr (assq key keystrokes)))
5971 (setq group (gnus-group-group-name))
5972 (switch-to-buffer obuf))
5976 (gnus-ephemeral-group-p gnus-newsgroup-name))
5978 (gnus-summary-next-group nil group backward)))
5980 (push (cdr keve) unread-command-events))))))
5982 (defun gnus-summary-next-unread-article ()
5983 "Select unread article after current one."
5985 (gnus-summary-next-article
5986 (or (not (eq gnus-summary-goto-unread 'never))
5987 (gnus-summary-last-article-p (gnus-summary-article-number)))
5988 (and gnus-auto-select-same
5989 (gnus-summary-article-subject))))
5991 (defun gnus-summary-prev-article (&optional unread subject)
5992 "Select the article after the current one.
5993 If UNREAD is non-nil, only unread articles are selected."
5995 (gnus-summary-next-article unread subject t))
5997 (defun gnus-summary-prev-unread-article ()
5998 "Select unread article before current one."
6000 (gnus-summary-prev-article
6001 (or (not (eq gnus-summary-goto-unread 'never))
6002 (gnus-summary-first-article-p (gnus-summary-article-number)))
6003 (and gnus-auto-select-same
6004 (gnus-summary-article-subject))))
6006 (defun gnus-summary-next-page (&optional lines circular)
6007 "Show next page of the selected article.
6008 If at the end of the current article, select the next article.
6009 LINES says how many lines should be scrolled up.
6011 If CIRCULAR is non-nil, go to the start of the article instead of
6012 selecting the next article when reaching the end of the current
6015 (setq gnus-summary-buffer (current-buffer))
6016 (gnus-set-global-variables)
6017 (let ((article (gnus-summary-article-number))
6018 (article-window (get-buffer-window gnus-article-buffer t))
6020 ;; If the buffer is empty, we have no article.
6022 (error "No article to select"))
6023 (gnus-configure-windows 'article)
6024 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6025 (if (and (eq gnus-summary-goto-unread 'never)
6026 (not (gnus-summary-last-article-p article)))
6027 (gnus-summary-next-article)
6028 (gnus-summary-next-unread-article))
6029 (if (or (null gnus-current-article)
6030 (null gnus-article-current)
6031 (/= article (cdr gnus-article-current))
6032 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6033 ;; Selected subject is different from current article's.
6034 (gnus-summary-display-article article)
6035 (when article-window
6036 (gnus-eval-in-buffer-window gnus-article-buffer
6037 (setq endp (gnus-article-next-page lines)))
6040 (gnus-summary-beginning-of-article))
6042 (gnus-message 3 "End of message"))
6044 (if (and (eq gnus-summary-goto-unread 'never)
6045 (not (gnus-summary-last-article-p article)))
6046 (gnus-summary-next-article)
6047 (gnus-summary-next-unread-article))))))))
6048 (gnus-summary-recenter)
6049 (gnus-summary-position-point)))
6051 (defun gnus-summary-prev-page (&optional lines move)
6052 "Show previous page of selected article.
6053 Argument LINES specifies lines to be scrolled down.
6054 If MOVE, move to the previous unread article if point is at
6055 the beginning of the buffer."
6057 (let ((article (gnus-summary-article-number))
6058 (article-window (get-buffer-window gnus-article-buffer t))
6060 (gnus-configure-windows 'article)
6061 (if (or (null gnus-current-article)
6062 (null gnus-article-current)
6063 (/= article (cdr gnus-article-current))
6064 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6065 ;; Selected subject is different from current article's.
6066 (gnus-summary-display-article article)
6067 (gnus-summary-recenter)
6068 (when article-window
6069 (gnus-eval-in-buffer-window gnus-article-buffer
6070 (setq endp (gnus-article-prev-page lines)))
6071 (when (and move endp)
6073 (gnus-message 3 "Beginning of message"))
6075 (if (and (eq gnus-summary-goto-unread 'never)
6076 (not (gnus-summary-first-article-p article)))
6077 (gnus-summary-prev-article)
6078 (gnus-summary-prev-unread-article))))))))
6079 (gnus-summary-position-point))
6081 (defun gnus-summary-prev-page-or-article (&optional lines)
6082 "Show previous page of selected article.
6083 Argument LINES specifies lines to be scrolled down.
6084 If at the beginning of the article, go to the next article."
6086 (gnus-summary-prev-page lines t))
6088 (defun gnus-summary-scroll-up (lines)
6089 "Scroll up (or down) one line current article.
6090 Argument LINES specifies lines to be scrolled up (or down if negative)."
6092 (gnus-configure-windows 'article)
6093 (gnus-summary-show-thread)
6094 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6095 (gnus-eval-in-buffer-window gnus-article-buffer
6097 (when (gnus-article-next-page lines)
6098 (gnus-message 3 "End of message")))
6100 (gnus-article-prev-page (- lines))))))
6101 (gnus-summary-recenter)
6102 (gnus-summary-position-point))
6104 (defun gnus-summary-scroll-down (lines)
6105 "Scroll down (or up) one line current article.
6106 Argument LINES specifies lines to be scrolled down (or up if negative)."
6108 (gnus-summary-scroll-up (- lines)))
6110 (defun gnus-summary-next-same-subject ()
6111 "Select next article which has the same subject as current one."
6113 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6115 (defun gnus-summary-prev-same-subject ()
6116 "Select previous article which has the same subject as current one."
6118 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6120 (defun gnus-summary-next-unread-same-subject ()
6121 "Select next unread article which has the same subject as current one."
6123 (gnus-summary-next-article t (gnus-summary-article-subject)))
6125 (defun gnus-summary-prev-unread-same-subject ()
6126 "Select previous unread article which has the same subject as current one."
6128 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6130 (defun gnus-summary-first-unread-article ()
6131 "Select the first unread article.
6132 Return nil if there are no unread articles."
6135 (when (gnus-summary-first-subject t)
6136 (gnus-summary-show-thread)
6137 (gnus-summary-first-subject t)
6138 (gnus-summary-display-article (gnus-summary-article-number)))
6139 (gnus-summary-position-point)))
6141 (defun gnus-summary-first-unread-subject ()
6142 "Place the point on the subject line of the first unread article.
6143 Return nil if there are no unread articles."
6146 (when (gnus-summary-first-subject t)
6147 (gnus-summary-show-thread)
6148 (gnus-summary-first-subject t))
6149 (gnus-summary-position-point)))
6151 (defun gnus-summary-first-article ()
6152 "Select the first article.
6153 Return nil if there are no articles."
6156 (when (gnus-summary-first-subject)
6157 (gnus-summary-show-thread)
6158 (gnus-summary-first-subject)
6159 (gnus-summary-display-article (gnus-summary-article-number)))
6160 (gnus-summary-position-point)))
6162 (defun gnus-summary-best-unread-article ()
6163 "Select the unread article with the highest score."
6165 (let ((best -1000000)
6166 (data gnus-newsgroup-data)
6169 (and (gnus-data-unread-p (car data))
6171 (gnus-summary-article-score (gnus-data-number (car data))))
6174 article (gnus-data-number (car data))))
6175 (setq data (cdr data)))
6178 (gnus-summary-goto-article article)
6179 (error "No unread articles"))
6180 (gnus-summary-position-point))))
6182 (defun gnus-summary-last-subject ()
6183 "Go to the last displayed subject line in the group."
6184 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6186 (gnus-summary-goto-subject article))))
6188 (defun gnus-summary-goto-article (article &optional all-headers force)
6189 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6190 If ALL-HEADERS is non-nil, no header lines are hidden.
6191 If FORCE, go to the article even if it isn't displayed. If FORCE
6192 is a number, it is the line the article is to be displayed on."
6196 "Article number or Message-ID: "
6197 (mapcar (lambda (number) (list (int-to-string number)))
6198 gnus-newsgroup-limit))
6202 (if (and (stringp article)
6203 (string-match "@" article))
6204 (gnus-summary-refer-article article)
6205 (when (stringp article)
6206 (setq article (string-to-number article)))
6207 (if (gnus-summary-goto-subject article force)
6208 (gnus-summary-display-article article all-headers)
6209 (gnus-message 4 "Couldn't go to article %s" article) nil))
6210 (gnus-summary-position-point)))
6212 (defun gnus-summary-goto-last-article ()
6213 "Go to the previously read article."
6216 (when gnus-last-article
6217 (gnus-summary-goto-article gnus-last-article nil t))
6218 (gnus-summary-position-point)))
6220 (defun gnus-summary-pop-article (number)
6221 "Pop one article off the history and go to the previous.
6222 NUMBER articles will be popped off."
6225 (setq gnus-newsgroup-history
6226 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6228 (gnus-summary-goto-article (car to) nil t)
6229 (error "Article history empty")))
6230 (gnus-summary-position-point))
6232 ;; Summary commands and functions for limiting the summary buffer.
6234 (defun gnus-summary-limit-to-articles (n)
6235 "Limit the summary buffer to the next N articles.
6236 If not given a prefix, use the process marked articles instead."
6239 (let ((articles (gnus-summary-work-articles n)))
6240 (setq gnus-newsgroup-processable nil)
6241 (gnus-summary-limit articles))
6242 (gnus-summary-position-point)))
6244 (defun gnus-summary-pop-limit (&optional total)
6245 "Restore the previous limit.
6246 If given a prefix, remove all limits."
6249 (setq gnus-newsgroup-limits
6250 (list (mapcar (lambda (h) (mail-header-number h))
6251 gnus-newsgroup-headers))))
6252 (unless gnus-newsgroup-limits
6253 (error "No limit to pop"))
6255 (gnus-summary-limit nil 'pop)
6256 (gnus-summary-position-point)))
6258 (defun gnus-summary-limit-to-subject (subject &optional header)
6259 "Limit the summary buffer to articles that have subjects that match a regexp."
6260 (interactive "sLimit to subject (regexp): ")
6262 (setq header "subject"))
6263 (when (not (equal "" subject))
6265 (let ((articles (gnus-summary-find-matching
6266 (or header "subject") subject 'all)))
6268 (error "Found no matches for \"%s\"" subject))
6269 (gnus-summary-limit articles))
6270 (gnus-summary-position-point))))
6272 (defun gnus-summary-limit-to-author (from)
6273 "Limit the summary buffer to articles that have authors that match a regexp."
6274 (interactive "sLimit to author (regexp): ")
6275 (gnus-summary-limit-to-subject from "from"))
6277 (defun gnus-summary-limit-to-age (age &optional younger-p)
6278 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6279 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6280 articles that are younger than AGE days."
6282 (let ((younger current-prefix-arg)
6285 (while (not days-got)
6286 (setq days (if younger
6287 (read-string "Limit to articles within (in days): ")
6288 (read-string "Limit to articles old than (in days): ")))
6289 (when (> (length days) 0)
6290 (setq days (read days)))
6293 (message "Please enter a number.")
6295 (list days younger)))
6297 (let ((data gnus-newsgroup-data)
6298 (cutoff (days-to-time age))
6299 articles d date is-younger)
6300 (while (setq d (pop data))
6301 (when (and (vectorp (gnus-data-header d))
6302 (setq date (mail-header-date (gnus-data-header d))))
6303 (setq is-younger (time-less-p
6304 (time-since (condition-case ()
6311 (push (gnus-data-number d) articles))))
6312 (gnus-summary-limit (nreverse articles)))
6313 (gnus-summary-position-point)))
6315 (defun gnus-summary-limit-to-extra (header regexp)
6316 "Limit the summary buffer to articles that match an 'extra' header."
6320 (gnus-completing-read
6321 (symbol-name (car gnus-extra-headers))
6322 "Limit extra header:"
6324 (cons (symbol-name x) x))
6329 (read-string (format "Limit to header %s (regexp): " header)))))
6330 (when (not (equal "" regexp))
6332 (let ((articles (gnus-summary-find-matching
6333 (cons 'extra header) regexp 'all)))
6335 (error "Found no matches for \"%s\"" regexp))
6336 (gnus-summary-limit articles))
6337 (gnus-summary-position-point))))
6339 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6341 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6343 (defun gnus-summary-limit-to-unread (&optional all)
6344 "Limit the summary buffer to articles that are not marked as read.
6345 If ALL is non-nil, limit strictly to unread articles."
6348 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6349 (gnus-summary-limit-to-marks
6350 ;; Concat all the marks that say that an article is read and have
6352 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6353 gnus-killed-mark gnus-kill-file-mark
6354 gnus-low-score-mark gnus-expirable-mark
6355 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6356 gnus-duplicate-mark gnus-souped-mark)
6359 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6360 (make-obsolete 'gnus-summary-delete-marked-with
6361 'gnus-summary-limit-exlude-marks)
6363 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6364 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6365 If REVERSE, limit the summary buffer to articles that are marked
6366 with MARKS. MARKS can either be a string of marks or a list of marks.
6367 Returns how many articles were removed."
6368 (interactive "sMarks: ")
6369 (gnus-summary-limit-to-marks marks t))
6371 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6372 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6373 If REVERSE (the prefix), limit the summary buffer to articles that are
6374 not marked with MARKS. MARKS can either be a string of marks or a
6376 Returns how many articles were removed."
6377 (interactive "sMarks: \nP")
6379 (let ((data gnus-newsgroup-data)
6380 (marks (if (listp marks) marks
6381 (append marks nil))) ; Transform to list.
6384 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6385 (memq (gnus-data-mark (car data)) marks))
6386 (push (gnus-data-number (car data)) articles))
6387 (setq data (cdr data)))
6388 (gnus-summary-limit articles))
6389 (gnus-summary-position-point)))
6391 (defun gnus-summary-limit-to-score (&optional score)
6392 "Limit to articles with score at or above SCORE."
6394 (setq score (if score
6395 (prefix-numeric-value score)
6396 (or gnus-summary-default-score 0)))
6397 (let ((data gnus-newsgroup-data)
6400 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6402 (push (gnus-data-number (car data)) articles))
6403 (setq data (cdr data)))
6405 (gnus-summary-limit articles)
6406 (gnus-summary-position-point))))
6408 (defun gnus-summary-limit-include-thread (id)
6409 "Display all the hidden articles that in the current thread."
6410 (interactive (list (mail-header-id (gnus-summary-article-header))))
6411 (let ((articles (gnus-articles-in-thread
6412 (gnus-id-to-thread (gnus-root-id id)))))
6414 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6415 (gnus-summary-position-point))))
6417 (defun gnus-summary-limit-include-dormant ()
6418 "Display all the hidden articles that are marked as dormant.
6419 Note that this command only works on a subset of the articles currently
6420 fetched for this group."
6422 (unless gnus-newsgroup-dormant
6423 (error "There are no dormant articles in this group"))
6425 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6426 (gnus-summary-position-point)))
6428 (defun gnus-summary-limit-exclude-dormant ()
6429 "Hide all dormant articles."
6432 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6433 (gnus-summary-position-point)))
6435 (defun gnus-summary-limit-exclude-childless-dormant ()
6436 "Hide all dormant articles that have no children."
6438 (let ((data (gnus-data-list t))
6439 articles d children)
6440 ;; Find all articles that are either not dormant or have
6442 (while (setq d (pop data))
6443 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6445 (gnus-article-children (gnus-data-number d)))
6448 (when (memq (car children) articles)
6453 (push (gnus-data-number d) articles)))
6456 (gnus-summary-limit articles)
6457 (gnus-summary-position-point))))
6459 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6460 "Mark all unread excluded articles as read.
6461 If ALL, mark even excluded ticked and dormants as read."
6463 (let ((articles (gnus-sorted-complement
6465 (mapcar (lambda (h) (mail-header-number h))
6466 gnus-newsgroup-headers)
6468 (sort gnus-newsgroup-limit '<)))
6470 (setq gnus-newsgroup-unreads
6471 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6473 (setq gnus-newsgroup-dormant nil
6474 gnus-newsgroup-marked nil
6475 gnus-newsgroup-reads
6477 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6478 gnus-newsgroup-reads))
6479 (while (setq article (pop articles))
6480 (unless (or (memq article gnus-newsgroup-dormant)
6481 (memq article gnus-newsgroup-marked))
6482 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6484 (defun gnus-summary-limit (articles &optional pop)
6486 ;; We pop the previous limit off the stack and use that.
6487 (setq articles (car gnus-newsgroup-limits)
6488 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6489 ;; We use the new limit, so we push the old limit on the stack.
6490 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6492 (setq gnus-newsgroup-limit articles)
6493 (let ((total (length gnus-newsgroup-data))
6494 (data (gnus-data-find-list (gnus-summary-article-number)))
6495 (gnus-summary-mark-below nil) ; Inhibit this.
6497 ;; This will do all the work of generating the new summary buffer
6498 ;; according to the new limit.
6499 (gnus-summary-prepare)
6500 ;; Hide any threads, possibly.
6501 (and gnus-show-threads
6502 gnus-thread-hide-subtree
6503 (gnus-summary-hide-all-threads))
6504 ;; Try to return to the article you were at, or one in the
6507 ;; We try to find some article after the current one.
6509 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6512 (setq data (cdr data))))
6514 ;; If there is no data, that means that we were after the last
6515 ;; article. The same goes when we can't find any articles
6516 ;; after the current one.
6517 (goto-char (point-max))
6518 (gnus-summary-find-prev))
6519 (gnus-set-mode-line 'summary)
6520 ;; We return how many articles were removed from the summary
6521 ;; buffer as a result of the new limit.
6522 (- total (length gnus-newsgroup-data))))
6524 (defsubst gnus-invisible-cut-children (threads)
6527 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6532 (defsubst gnus-cut-thread (thread)
6533 "Go forwards in the thread until we find an article that we want to display."
6534 (when (or (eq gnus-fetch-old-headers 'some)
6535 (eq gnus-fetch-old-headers 'invisible)
6536 (numberp gnus-fetch-old-headers)
6537 (eq gnus-build-sparse-threads 'some)
6538 (eq gnus-build-sparse-threads 'more))
6539 ;; Deal with old-fetched headers and sparse threads.
6543 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6544 (gnus-summary-article-ancient-p
6545 (mail-header-number (car thread))))
6546 (if (or (<= (length (cdr thread)) 1)
6547 (eq gnus-fetch-old-headers 'invisible))
6548 (setq gnus-newsgroup-limit
6549 (delq (mail-header-number (car thread))
6550 gnus-newsgroup-limit)
6551 thread (cadr thread))
6552 (when (gnus-invisible-cut-children (cdr thread))
6553 (let ((th (cdr thread)))
6555 (if (memq (mail-header-number (caar th))
6556 gnus-newsgroup-limit)
6557 (setq thread (car th)
6559 (setq th (cdr th))))))))))
6562 (defun gnus-cut-threads (threads)
6563 "Cut off all uninteresting articles from the beginning of threads."
6564 (when (or (eq gnus-fetch-old-headers 'some)
6565 (eq gnus-fetch-old-headers 'invisible)
6566 (numberp gnus-fetch-old-headers)
6567 (eq gnus-build-sparse-threads 'some)
6568 (eq gnus-build-sparse-threads 'more))
6571 (setcar th (gnus-cut-thread (car th)))
6572 (setq th (cdr th)))))
6573 ;; Remove nixed out threads.
6576 (defun gnus-summary-initial-limit (&optional show-if-empty)
6577 "Figure out what the initial limit is supposed to be on group entry.
6578 This entails weeding out unwanted dormants, low-scored articles,
6579 fetch-old-headers verbiage, and so on."
6580 ;; Most groups have nothing to remove.
6581 (if (or gnus-inhibit-limiting
6582 (and (null gnus-newsgroup-dormant)
6583 (not (eq gnus-fetch-old-headers 'some))
6584 (not (numberp gnus-fetch-old-headers))
6585 (not (eq gnus-fetch-old-headers 'invisible))
6586 (null gnus-summary-expunge-below)
6587 (not (eq gnus-build-sparse-threads 'some))
6588 (not (eq gnus-build-sparse-threads 'more))
6589 (null gnus-thread-expunge-below)
6590 (not gnus-use-nocem)))
6592 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6593 (setq gnus-newsgroup-limit nil)
6596 (unless (car (symbol-value node))
6597 ;; These threads have no parents -- they are roots.
6598 (let ((nodes (cdr (symbol-value node)))
6601 (if (and gnus-thread-expunge-below
6602 (< (gnus-thread-total-score (car nodes))
6603 gnus-thread-expunge-below))
6604 (gnus-expunge-thread (pop nodes))
6605 (setq thread (pop nodes))
6606 (gnus-summary-limit-children thread))))))
6607 gnus-newsgroup-dependencies)
6608 ;; If this limitation resulted in an empty group, we might
6609 ;; pop the previous limit and use it instead.
6610 (when (and (not gnus-newsgroup-limit)
6612 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6613 gnus-newsgroup-limit))
6615 (defun gnus-summary-limit-children (thread)
6616 "Return 1 if this subthread is visible and 0 if it is not."
6617 ;; First we get the number of visible children to this thread. This
6618 ;; is done by recursing down the thread using this function, so this
6619 ;; will really go down to a leaf article first, before slowly
6620 ;; working its way up towards the root.
6624 (apply '+ (mapcar 'gnus-summary-limit-children
6627 (number (mail-header-number (car thread)))
6630 (not (memq number gnus-newsgroup-marked))
6632 ;; If this article is dormant and has absolutely no visible
6633 ;; children, then this article isn't visible.
6634 (and (memq number gnus-newsgroup-dormant)
6636 ;; If this is "fetch-old-headered" and there is no
6637 ;; visible children, then we don't want this article.
6638 (and (or (eq gnus-fetch-old-headers 'some)
6639 (numberp gnus-fetch-old-headers))
6640 (gnus-summary-article-ancient-p number)
6642 ;; If this is "fetch-old-headered" and `invisible', then
6643 ;; we don't want this article.
6644 (and (eq gnus-fetch-old-headers 'invisible)
6645 (gnus-summary-article-ancient-p number))
6646 ;; If this is a sparsely inserted article with no children,
6647 ;; we don't want it.
6648 (and (eq gnus-build-sparse-threads 'some)
6649 (gnus-summary-article-sparse-p number)
6651 ;; If we use expunging, and this article is really
6652 ;; low-scored, then we don't want this article.
6653 (when (and gnus-summary-expunge-below
6655 (or (cdr (assq number gnus-newsgroup-scored))
6656 gnus-summary-default-score))
6657 gnus-summary-expunge-below))
6658 ;; We increase the expunge-tally here, but that has
6659 ;; nothing to do with the limits, really.
6660 (incf gnus-newsgroup-expunged-tally)
6661 ;; We also mark as read here, if that's wanted.
6662 (when (and gnus-summary-mark-below
6663 (< score gnus-summary-mark-below))
6664 (setq gnus-newsgroup-unreads
6665 (delq number gnus-newsgroup-unreads))
6666 (if gnus-newsgroup-auto-expire
6667 (push number gnus-newsgroup-expirable)
6668 (push (cons number gnus-low-score-mark)
6669 gnus-newsgroup-reads)))
6671 ;; Check NoCeM things.
6672 (if (and gnus-use-nocem
6673 (gnus-nocem-unwanted-article-p
6674 (mail-header-id (car thread))))
6676 (setq gnus-newsgroup-unreads
6677 (delq number gnus-newsgroup-unreads))
6679 ;; Nope, invisible article.
6681 ;; Ok, this article is to be visible, so we add it to the limit
6683 (push number gnus-newsgroup-limit)
6686 (defun gnus-expunge-thread (thread)
6687 "Mark all articles in THREAD as read."
6688 (let* ((number (mail-header-number (car thread))))
6689 (incf gnus-newsgroup-expunged-tally)
6690 ;; We also mark as read here, if that's wanted.
6691 (setq gnus-newsgroup-unreads
6692 (delq number gnus-newsgroup-unreads))
6693 (if gnus-newsgroup-auto-expire
6694 (push number gnus-newsgroup-expirable)
6695 (push (cons number gnus-low-score-mark)
6696 gnus-newsgroup-reads)))
6697 ;; Go recursively through all subthreads.
6698 (mapcar 'gnus-expunge-thread (cdr thread)))
6700 ;; Summary article oriented commands
6702 (defun gnus-summary-refer-parent-article (n)
6703 "Refer parent article N times.
6704 If N is negative, go to ancestor -N instead.
6705 The difference between N and the number of articles fetched is returned."
6709 (when (not (natnump n))
6714 (setq header (gnus-summary-article-header))
6715 (if (and (eq (mail-header-number header)
6716 (cdr gnus-article-current))
6717 (equal gnus-newsgroup-name
6718 (car gnus-article-current)))
6719 ;; If we try to find the parent of the currently
6720 ;; displayed article, then we take a look at the actual
6721 ;; References header, since this is slightly more
6722 ;; reliable than the References field we got from the
6725 (set-buffer gnus-original-article-buffer)
6726 (nnheader-narrow-to-headers)
6727 (unless (setq ref (message-fetch-field "references"))
6728 (setq ref (message-fetch-field "in-reply-to")))
6731 ;; It's not the current article, so we take a bet on
6732 ;; the value we got from the server.
6733 (mail-header-references header)))
6735 (not (equal ref "")))
6736 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6737 (gnus-message 1 "Couldn't find parent"))
6738 (gnus-message 1 "No references in article %d"
6739 (gnus-summary-article-number))
6742 (gnus-summary-position-point)
6745 (defun gnus-summary-refer-references ()
6746 "Fetch all articles mentioned in the References header.
6747 Return the number of articles fetched."
6749 (let ((ref (mail-header-references (gnus-summary-article-header)))
6750 (current (gnus-summary-article-number))
6754 (error "No References in the current article")
6755 ;; For each Message-ID in the References header...
6756 (while (string-match "<[^>]*>" ref)
6758 ;; ... fetch that article.
6759 (gnus-summary-refer-article
6760 (prog1 (match-string 0 ref)
6761 (setq ref (substring ref (match-end 0))))))
6762 (gnus-summary-goto-subject current)
6763 (gnus-summary-position-point)
6766 (defun gnus-summary-refer-thread (&optional limit)
6767 "Fetch all articles in the current thread.
6768 If LIMIT (the numerical prefix), fetch that many old headers instead
6769 of what's specified by the `gnus-refer-thread-limit' variable."
6771 (let ((id (mail-header-id (gnus-summary-article-header)))
6772 (limit (if limit (prefix-numeric-value limit)
6773 gnus-refer-thread-limit)))
6774 ;; We want to fetch LIMIT *old* headers, but we also have to
6775 ;; re-fetch all the headers in the current buffer, because many of
6776 ;; them may be undisplayed. So we adjust LIMIT.
6777 (when (numberp limit)
6778 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6779 (unless (eq gnus-fetch-old-headers 'invisible)
6780 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6781 ;; Retrieve the headers and read them in.
6782 (if (eq (gnus-retrieve-headers
6783 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6785 (gnus-build-all-threads)
6786 (error "Can't fetch thread from backends that don't support NOV"))
6787 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6788 (gnus-summary-limit-include-thread id)))
6790 (defun gnus-summary-refer-article (message-id)
6791 "Fetch an article specified by MESSAGE-ID."
6792 (interactive "sMessage-ID: ")
6793 (when (and (stringp message-id)
6794 (not (zerop (length message-id))))
6795 ;; Construct the correct Message-ID if necessary.
6796 ;; Suggested by tale@pawl.rpi.edu.
6797 (unless (string-match "^<" message-id)
6798 (setq message-id (concat "<" message-id)))
6799 (unless (string-match ">$" message-id)
6800 (setq message-id (concat message-id ">")))
6801 (let* ((header (gnus-id-to-header message-id))
6803 (gnus-summary-article-sparse-p
6804 (mail-header-number header))
6805 (memq (mail-header-number header)
6806 gnus-newsgroup-limit)))
6809 ;; If the article is present in the buffer we just go to it.
6811 (or (not (gnus-summary-article-sparse-p
6812 (mail-header-number header)))
6815 (gnus-summary-goto-article
6816 (mail-header-number header) nil t)
6818 (gnus-summary-update-article (mail-header-number header)))))
6820 ;; We fetch the article.
6822 (dolist (gnus-override-method (gnus-refer-article-methods))
6823 (gnus-check-server gnus-override-method)
6824 ;; Fetch the header, and display the article.
6825 (when (setq number (gnus-summary-insert-subject message-id))
6826 (gnus-summary-select-article nil nil nil number)
6828 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6830 (defun gnus-refer-article-methods ()
6831 "Return a list of referrable methods."
6833 ;; No method, so we default to current and native.
6834 ((null gnus-refer-article-method)
6835 (list gnus-current-select-method gnus-select-method))
6837 ((eq 'current gnus-refer-article-method)
6838 (list gnus-current-select-method))
6839 ;; List of select methods.
6840 ((not (stringp (cadr gnus-refer-article-method)))
6842 (dolist (method gnus-refer-article-method)
6843 (push (if (eq 'current method)
6844 gnus-current-select-method
6848 ;; One single select method.
6850 (list gnus-refer-article-method))))
6852 (defun gnus-summary-edit-parameters ()
6853 "Edit the group parameters of the current group."
6855 (gnus-group-edit-group gnus-newsgroup-name 'params))
6857 (defun gnus-summary-customize-parameters ()
6858 "Customize the group parameters of the current group."
6860 (gnus-group-customize gnus-newsgroup-name))
6862 (defun gnus-summary-enter-digest-group (&optional force)
6863 "Enter an nndoc group based on the current article.
6864 If FORCE, force a digest interpretation. If not, try
6865 to guess what the document format is."
6867 (let ((conf gnus-current-window-configuration))
6869 (gnus-summary-select-article))
6870 (setq gnus-current-window-configuration conf)
6871 (let* ((name (format "%s-%d"
6872 (gnus-group-prefixed-name
6873 gnus-newsgroup-name (list 'nndoc ""))
6875 (set-buffer gnus-summary-buffer)
6876 gnus-current-article)))
6877 (ogroup gnus-newsgroup-name)
6878 (params (append (gnus-info-params (gnus-get-info ogroup))
6879 (list (cons 'to-group ogroup))
6880 (list (cons 'save-article-group ogroup))))
6881 (case-fold-search t)
6882 (buf (current-buffer))
6885 (set-buffer gnus-original-article-buffer)
6886 ;; Have the digest group inherit the main mail address of
6887 ;; the parent article.
6888 (when (setq to-address (or (message-fetch-field "reply-to")
6889 (message-fetch-field "from")))
6890 (setq params (append (list (cons 'to-address to-address)))))
6891 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6892 (insert-buffer-substring gnus-original-article-buffer)
6893 ;; Remove lines that may lead nndoc to misinterpret the
6896 (goto-char (point-min))
6897 (or (search-forward "\n\n" nil t) (point)))
6898 (goto-char (point-min))
6899 (delete-matching-lines "^Path:\\|^From ")
6902 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6903 (gnus-newsgroup-ephemeral-ignored-charsets
6904 gnus-newsgroup-ignored-charsets))
6905 (gnus-group-read-ephemeral-group
6906 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6908 ,(if force 'mbox 'guess))) t))
6909 ;; Make all postings to this group go to the parent group.
6910 (nconc (gnus-info-params (gnus-get-info name))
6912 ;; Couldn't select this doc group.
6913 (switch-to-buffer buf)
6914 (gnus-set-global-variables)
6915 (gnus-configure-windows 'summary)
6916 (gnus-message 3 "Article couldn't be entered?"))
6917 (kill-buffer dig)))))
6919 (defun gnus-summary-read-document (n)
6920 "Open a new group based on the current article(s).
6921 This will allow you to read digests and other similar
6922 documents as newsgroups.
6923 Obeys the standard process/prefix convention."
6925 (let* ((articles (gnus-summary-work-articles n))
6926 (ogroup gnus-newsgroup-name)
6927 (params (append (gnus-info-params (gnus-get-info ogroup))
6928 (list (cons 'to-group ogroup))))
6929 article group egroup groups vgroup)
6930 (while (setq article (pop articles))
6931 (setq group (format "%s-%d" gnus-newsgroup-name article))
6932 (gnus-summary-remove-process-mark article)
6933 (when (gnus-summary-display-article article)
6936 (insert-buffer-substring gnus-original-article-buffer)
6937 ;; Remove some headers that may lead nndoc to make
6939 (message-narrow-to-head)
6940 (goto-char (point-min))
6941 (delete-matching-lines "^\\(Path\\):\\|^From ")
6944 (gnus-group-read-ephemeral-group
6945 group `(nndoc ,group (nndoc-address ,(current-buffer))
6946 (nndoc-article-type guess))
6949 ;; Make all postings to this group go to the parent group.
6950 (nconc (gnus-info-params (gnus-get-info egroup))
6952 (push egroup groups))
6953 ;; Couldn't select this doc group.
6954 (gnus-error 3 "Article couldn't be entered"))))))
6955 ;; Now we have selected all the documents.
6958 (error "None of the articles could be interpreted as documents"))
6959 ((gnus-group-read-ephemeral-group
6960 (setq vgroup (format
6961 "nnvirtual:%s-%s" gnus-newsgroup-name
6962 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6963 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6965 (cons (current-buffer) 'summary)))
6967 (error "Couldn't select virtual nndoc group")))))
6969 (defun gnus-summary-isearch-article (&optional regexp-p)
6970 "Do incremental search forward on the current article.
6971 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6973 (gnus-summary-select-article)
6974 (gnus-configure-windows 'article)
6975 (gnus-eval-in-buffer-window gnus-article-buffer
6978 (isearch-forward regexp-p))))
6980 (defun gnus-summary-search-article-forward (regexp &optional backward)
6981 "Search for an article containing REGEXP forward.
6982 If BACKWARD, search backward instead."
6985 (format "Search article %s (regexp%s): "
6986 (if current-prefix-arg "backward" "forward")
6987 (if gnus-last-search-regexp
6988 (concat ", default " gnus-last-search-regexp)
6990 current-prefix-arg))
6991 (if (string-equal regexp "")
6992 (setq regexp (or gnus-last-search-regexp ""))
6993 (setq gnus-last-search-regexp regexp))
6994 (if (gnus-summary-search-article regexp backward)
6995 (gnus-summary-show-thread)
6996 (error "Search failed: \"%s\"" regexp)))
6998 (defun gnus-summary-search-article-backward (regexp)
6999 "Search for an article containing REGEXP backward."
7002 (format "Search article backward (regexp%s): "
7003 (if gnus-last-search-regexp
7004 (concat ", default " gnus-last-search-regexp)
7006 (gnus-summary-search-article-forward regexp 'backward))
7008 (defun gnus-summary-search-article (regexp &optional backward)
7009 "Search for an article containing REGEXP.
7010 Optional argument BACKWARD means do search for backward.
7011 `gnus-select-article-hook' is not called during the search."
7012 ;; We have to require this here to make sure that the following
7013 ;; dynamic binding isn't shadowed by autoloading.
7014 (require 'gnus-async)
7016 (let ((gnus-select-article-hook nil) ;Disable hook.
7017 (gnus-article-prepare-hook nil)
7018 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7019 (gnus-use-article-prefetch nil)
7020 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7021 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7022 (sum (current-buffer))
7023 (gnus-display-mime-function nil)
7026 (gnus-save-hidden-threads
7027 (gnus-summary-select-article)
7028 (set-buffer gnus-article-buffer)
7029 (goto-char (window-point (get-buffer-window (current-buffer))))
7033 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7035 (re-search-backward regexp nil t)
7036 (re-search-forward regexp nil t))
7037 ;; We found the regexp.
7042 (get-buffer-window (current-buffer))
7046 (get-buffer-window (current-buffer))
7049 (setq point (point)))
7050 ;; We didn't find it, so we go to the next article.
7053 (while (eq found 'not)
7054 (if (not (if backward (gnus-summary-find-prev)
7055 (gnus-summary-find-next)))
7056 ;; No more articles.
7058 ;; Select the next article and adjust point.
7059 (unless (gnus-summary-article-sparse-p
7060 (gnus-summary-article-number))
7062 (gnus-summary-select-article)
7063 (set-buffer gnus-article-buffer)
7065 (goto-char (if backward (point-max) (point-min))))))))
7066 (gnus-message 7 ""))
7067 ;; Return whether we found the regexp.
7068 (when (eq found 'found)
7070 (gnus-summary-show-thread)
7071 (gnus-summary-goto-subject gnus-current-article)
7072 (gnus-summary-position-point)
7075 (defun gnus-summary-find-matching (header regexp &optional backward unread
7077 "Return a list of all articles that match REGEXP on HEADER.
7078 The search stars on the current article and goes forwards unless
7079 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7080 If UNREAD is non-nil, only unread articles will
7081 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7082 in the comparisons."
7083 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7084 (gnus-data-find-list
7085 (gnus-summary-article-number) (gnus-data-list backward))))
7086 (case-fold-search (not not-case-fold))
7089 (if (eq (car header) 'extra)
7092 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7094 (error "%s is an invalid header" header))
7095 (unless (fboundp (intern (concat "mail-header-" header)))
7096 (error "%s is not a valid header" header))
7097 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7100 (and (or (not unread) ; We want all articles...
7101 (gnus-data-unread-p d)) ; Or just unreads.
7102 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7103 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7104 (push (gnus-data-number d) articles)) ; Success!
7105 (setq data (cdr data)))
7106 (nreverse articles)))
7108 (defun gnus-summary-execute-command (header regexp command &optional backward)
7109 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7110 If HEADER is an empty string (or nil), the match is done on the entire
7111 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7113 (list (let ((completion-ignore-case t))
7116 (mapcar (lambda (string) (list string))
7117 '("Number" "Subject" "From" "Lines" "Date"
7118 "Message-ID" "Xref" "References" "Body"))
7119 nil 'require-match))
7120 (read-string "Regexp: ")
7121 (read-key-sequence "Command: ")
7122 current-prefix-arg))
7123 (when (equal header "Body")
7125 ;; Hidden thread subtrees must be searched as well.
7126 (gnus-summary-show-all-threads)
7127 ;; We don't want to change current point nor window configuration.
7129 (save-window-excursion
7130 (gnus-message 6 "Executing %s..." (key-description command))
7131 ;; We'd like to execute COMMAND interactively so as to give arguments.
7132 (gnus-execute header regexp
7133 `(call-interactively ',(key-binding command))
7135 (gnus-message 6 "Executing %s...done" (key-description command)))))
7137 (defun gnus-summary-beginning-of-article ()
7138 "Scroll the article back to the beginning."
7140 (gnus-summary-select-article)
7141 (gnus-configure-windows 'article)
7142 (gnus-eval-in-buffer-window gnus-article-buffer
7144 (goto-char (point-min))
7145 (when gnus-page-broken
7146 (gnus-narrow-to-page))))
7148 (defun gnus-summary-end-of-article ()
7149 "Scroll to the end of the article."
7151 (gnus-summary-select-article)
7152 (gnus-configure-windows 'article)
7153 (gnus-eval-in-buffer-window gnus-article-buffer
7155 (goto-char (point-max))
7157 (when gnus-page-broken
7158 (gnus-narrow-to-page))))
7160 (defun gnus-summary-print-article (&optional filename n)
7161 "Generate and print a PostScript image of the N next (mail) articles.
7163 If N is negative, print the N previous articles. If N is nil and articles
7164 have been marked with the process mark, print these instead.
7166 If the optional first argument FILENAME is nil, send the image to the
7167 printer. If FILENAME is a string, save the PostScript image in a file with
7168 that name. If FILENAME is a number, prompt the user for the name of the file
7170 (interactive (list (ps-print-preprint current-prefix-arg)
7171 current-prefix-arg))
7172 (dolist (article (gnus-summary-work-articles n))
7173 (gnus-summary-select-article nil nil 'pseudo article)
7174 (gnus-eval-in-buffer-window gnus-article-buffer
7175 (let ((buffer (generate-new-buffer " *print*")))
7178 (copy-to-buffer buffer (point-min) (point-max))
7180 (gnus-article-delete-invisible-text)
7181 (let ((ps-left-header
7184 (mail-header-subject gnus-current-headers) ")")
7186 (mail-header-from gnus-current-headers) ")")))
7189 "/pagenumberstring load"
7191 (mail-header-date gnus-current-headers) ")"))))
7192 (gnus-run-hooks 'gnus-ps-print-hook)
7194 (ps-print-buffer-with-faces filename))))
7195 (kill-buffer buffer))))))
7197 (defun gnus-summary-show-article (&optional arg)
7198 "Force re-fetching of the current article.
7199 If ARG (the prefix) is a number, show the article with the charset
7200 defined in `gnus-summary-show-article-charset-alist', or the charset
7202 If ARG (the prefix) is non-nil and not a number, show the raw article
7203 without any article massaging functions being run."
7207 (let ((gnus-newsgroup-charset
7208 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7209 (read-coding-system "Charset: ")))
7210 (gnus-newsgroup-ignored-charsets 'gnus-all))
7211 (gnus-summary-select-article nil 'force)))
7213 ;; Select the article the normal way.
7214 (gnus-summary-select-article nil 'force))
7216 ;; We have to require this here to make sure that the following
7217 ;; dynamic binding isn't shadowed by autoloading.
7218 (require 'gnus-async)
7220 ;; Bind the article treatment functions to nil.
7221 (let ((gnus-have-all-headers t)
7222 gnus-article-prepare-hook
7223 gnus-article-decode-hook
7224 gnus-display-mime-function
7226 ;; Destroy any MIME parts.
7227 (when (gnus-buffer-live-p gnus-article-buffer)
7229 (set-buffer gnus-article-buffer)
7230 (mm-destroy-parts gnus-article-mime-handles)))
7231 (gnus-summary-select-article nil 'force))))
7232 (gnus-summary-goto-subject gnus-current-article)
7233 (gnus-summary-position-point))
7235 (defun gnus-summary-verbose-headers (&optional arg)
7236 "Toggle permanent full header display.
7237 If ARG is a positive number, turn header display on.
7238 If ARG is a negative number, turn header display off."
7240 (setq gnus-show-all-headers
7241 (cond ((or (not (numberp arg))
7243 (not gnus-show-all-headers))
7246 (gnus-summary-show-article))
7248 (defun gnus-summary-toggle-header (&optional arg)
7249 "Show the headers if they are hidden, or hide them if they are shown.
7250 If ARG is a positive number, show the entire header.
7251 If ARG is a negative number, hide the unwanted header lines."
7254 (set-buffer gnus-article-buffer)
7256 (let* ((buffer-read-only nil)
7257 (inhibit-point-motion-hooks t)
7263 (article-narrow-to-head)
7264 (gnus-article-hidden-text-p 'headers))))
7265 (goto-char (point-min))
7266 (when (search-forward "\n\n" nil t)
7267 (delete-region (point-min) (1- (point))))
7268 (goto-char (point-min))
7270 (set-buffer gnus-original-article-buffer)
7271 (goto-char (point-min))
7272 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7273 (insert-buffer-substring gnus-original-article-buffer 1 e)
7275 (narrow-to-region (point-min) (point))
7276 (article-decode-encoded-words)
7278 (let ((gnus-treat-hide-headers nil)
7279 (gnus-treat-hide-boring-headers nil))
7280 (setq gnus-article-wash-types
7281 (delq 'headers gnus-article-wash-types))
7282 (gnus-treat-article 'head))
7283 (gnus-treat-article 'head)))
7284 (gnus-set-mode-line 'article)))))
7286 (defun gnus-summary-show-all-headers ()
7287 "Make all header lines visible."
7289 (gnus-article-show-all-headers))
7291 (defun gnus-summary-caesar-message (&optional arg)
7292 "Caesar rotate the current article by 13.
7293 The numerical prefix specifies how many places to rotate each letter
7296 (gnus-summary-select-article)
7297 (let ((mail-header-separator ""))
7298 (gnus-eval-in-buffer-window gnus-article-buffer
7301 (let ((start (window-start))
7303 (message-caesar-buffer-body arg)
7304 (set-window-start (get-buffer-window (current-buffer)) start))))))
7306 (defun gnus-summary-stop-page-breaking ()
7307 "Stop page breaking in the current article."
7309 (gnus-summary-select-article)
7310 (gnus-eval-in-buffer-window gnus-article-buffer
7312 (when (gnus-visual-p 'page-marker)
7313 (let ((buffer-read-only nil))
7314 (gnus-remove-text-with-property 'gnus-prev)
7315 (gnus-remove-text-with-property 'gnus-next))
7316 (setq gnus-page-broken nil))))
7318 (defun gnus-summary-move-article (&optional n to-newsgroup
7319 select-method action)
7320 "Move the current article to a different newsgroup.
7321 If N is a positive number, move the N next articles.
7322 If N is a negative number, move the N previous articles.
7323 If N is nil and any articles have been marked with the process mark,
7324 move those articles instead.
7325 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7326 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7327 re-spool using this method.
7329 For this function to work, both the current newsgroup and the
7330 newsgroup that you want to move to have to support the `request-move'
7331 and `request-accept' functions.
7333 ACTION can be either `move' (the default), `crosspost' or `copy'."
7336 (setq action 'move))
7337 ;; Disable marking as read.
7338 (let (gnus-mark-article-hook)
7339 (save-window-excursion
7340 (gnus-summary-select-article)))
7341 ;; Check whether the source group supports the required functions.
7342 (cond ((and (eq action 'move)
7343 (not (gnus-check-backend-function
7344 'request-move-article gnus-newsgroup-name)))
7345 (error "The current group does not support article moving"))
7346 ((and (eq action 'crosspost)
7347 (not (gnus-check-backend-function
7348 'request-replace-article gnus-newsgroup-name)))
7349 (error "The current group does not support article editing")))
7350 (let ((articles (gnus-summary-work-articles n))
7351 (prefix (if (gnus-check-backend-function
7352 'request-move-article gnus-newsgroup-name)
7353 (gnus-group-real-prefix gnus-newsgroup-name)
7355 (names '((move "Move" "Moving")
7356 (copy "Copy" "Copying")
7357 (crosspost "Crosspost" "Crossposting")))
7358 (copy-buf (save-excursion
7359 (nnheader-set-temp-buffer " *copy article*")))
7360 art-group to-method new-xref article to-groups)
7361 (unless (assq action names)
7362 (error "Unknown action %s" action))
7363 ;; Read the newsgroup name.
7364 (when (and (not to-newsgroup)
7365 (not select-method))
7367 (gnus-read-move-group-name
7368 (cadr (assq action names))
7369 (symbol-value (intern (format "gnus-current-%s-group" action)))
7371 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7372 (setq to-method (or select-method
7373 (gnus-server-to-method
7374 (gnus-group-method to-newsgroup))))
7375 ;; Check the method we are to move this article to...
7376 (unless (gnus-check-backend-function
7377 'request-accept-article (car to-method))
7378 (error "%s does not support article copying" (car to-method)))
7379 (unless (gnus-check-server to-method)
7380 (error "Can't open server %s" (car to-method)))
7381 (gnus-message 6 "%s to %s: %s..."
7382 (caddr (assq action names))
7383 (or (car select-method) to-newsgroup) articles)
7385 (setq article (pop articles))
7389 ;; Move the article.
7391 ;; Remove this article from future suppression.
7392 (gnus-dup-unsuppress-article article)
7393 (gnus-request-move-article
7394 article ; Article to move
7395 gnus-newsgroup-name ; From newsgroup
7396 (nth 1 (gnus-find-method-for-group
7397 gnus-newsgroup-name)) ; Server
7398 (list 'gnus-request-accept-article
7399 to-newsgroup (list 'quote select-method)
7400 (not articles) t) ; Accept form
7401 (not articles))) ; Only save nov last time
7402 ;; Copy the article.
7405 (set-buffer copy-buf)
7406 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7407 (gnus-request-accept-article
7408 to-newsgroup select-method (not articles) t))))
7409 ;; Crosspost the article.
7410 ((eq action 'crosspost)
7411 (let ((xref (message-tokenize-header
7412 (mail-header-xref (gnus-summary-article-header article))
7414 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7417 (setq xref (list (system-name))))
7420 (mapconcat 'identity
7421 (delete "Xref:" (delete new-xref xref))
7425 (set-buffer copy-buf)
7426 ;; First put the article in the destination group.
7427 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7428 (when (consp (setq art-group
7429 (gnus-request-accept-article
7430 to-newsgroup select-method (not articles))))
7431 (setq new-xref (concat new-xref " " (car art-group)
7432 ":" (cdr art-group)))
7433 ;; Now we have the new Xrefs header, so we insert
7434 ;; it and replace the new article.
7435 (nnheader-replace-header "Xref" new-xref)
7436 (gnus-request-replace-article
7437 (cdr art-group) to-newsgroup (current-buffer))
7441 (gnus-message 1 "Couldn't %s article %s: %s"
7442 (cadr (assq action names)) article
7443 (nnheader-get-report (car to-method))))
7444 ((eq art-group 'junk)
7445 (when (eq action 'move)
7446 (gnus-summary-mark-article article gnus-canceled-mark)
7447 (gnus-message 4 "Deleted article %s" article)))
7449 (let* ((pto-group (gnus-group-prefixed-name
7450 (car art-group) to-method))
7452 (gnus-gethash pto-group gnus-newsrc-hashtb))
7453 (info (nth 2 entry))
7454 (to-group (gnus-info-group info))
7456 ;; Update the group that has been moved to.
7458 (memq action '(move copy)))
7459 (unless (member to-group to-groups)
7460 (push to-group to-groups))
7462 (unless (memq article gnus-newsgroup-unreads)
7463 (push 'read to-marks)
7465 info (gnus-add-to-range (gnus-info-read info)
7466 (list (cdr art-group)))))
7468 ;; See whether the article is to be put in the cache.
7469 (let ((marks gnus-article-mark-lists)
7470 (to-article (cdr art-group)))
7472 ;; Enter the article into the cache in the new group,
7473 ;; if that is required.
7474 (when gnus-use-cache
7475 (gnus-cache-possibly-enter-article
7477 (memq article gnus-newsgroup-marked)
7478 (memq article gnus-newsgroup-dormant)
7479 (memq article gnus-newsgroup-unreads)))
7481 (when gnus-preserve-marks
7482 ;; Copy any marks over to the new group.
7483 (when (and (equal to-group gnus-newsgroup-name)
7484 (not (memq article gnus-newsgroup-unreads)))
7485 ;; Mark this article as read in this group.
7486 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7487 (setcdr (gnus-active to-group) to-article)
7488 (setcdr gnus-newsgroup-active to-article))
7491 (when (memq article (symbol-value
7492 (intern (format "gnus-newsgroup-%s"
7494 (push (cdar marks) to-marks)
7495 ;; If the other group is the same as this group,
7496 ;; then we have to add the mark to the list.
7497 (when (equal to-group gnus-newsgroup-name)
7498 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7501 (intern (format "gnus-newsgroup-%s"
7503 ;; Copy the marks to other group.
7504 (gnus-add-marked-articles
7505 to-group (cdar marks) (list to-article) info))
7506 (setq marks (cdr marks)))
7508 (gnus-request-set-mark to-group (list (list (list to-article)
7513 (concat "(gnus-group-set-info '"
7514 (gnus-prin1-to-string (gnus-get-info to-group))
7517 ;; Update the Xref header in this article to point to
7518 ;; the new crossposted article we have just created.
7519 (when (eq action 'crosspost)
7521 (set-buffer copy-buf)
7522 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7523 (nnheader-replace-header "Xref" new-xref)
7524 (gnus-request-replace-article
7525 article gnus-newsgroup-name (current-buffer)))))
7527 ;;;!!!Why is this necessary?
7528 (set-buffer gnus-summary-buffer)
7530 (gnus-summary-goto-subject article)
7531 (when (eq action 'move)
7532 (gnus-summary-mark-article article gnus-canceled-mark))))
7533 (gnus-summary-remove-process-mark article))
7534 ;; Re-activate all groups that have been moved to.
7537 (set-buffer gnus-group-buffer)
7538 (when (gnus-group-goto-group (car to-groups) t)
7539 (gnus-group-get-new-news-this-group 1 t))
7542 (gnus-kill-buffer copy-buf)
7543 (gnus-summary-position-point)
7544 (gnus-set-mode-line 'summary)))
7546 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7547 "Move the current article to a different newsgroup.
7548 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7549 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7550 re-spool using this method."
7552 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7554 (defun gnus-summary-crosspost-article (&optional n)
7555 "Crosspost the current article to some other group."
7557 (gnus-summary-move-article n nil nil 'crosspost))
7559 (defcustom gnus-summary-respool-default-method nil
7560 "Default method for respooling an article.
7561 If nil, use to the current newsgroup method."
7562 :type '(choice (gnus-select-method :value (nnml ""))
7564 :group 'gnus-summary-mail)
7566 (defun gnus-summary-respool-article (&optional n method)
7567 "Respool the current article.
7568 The article will be squeezed through the mail spooling process again,
7569 which means that it will be put in some mail newsgroup or other
7570 depending on `nnmail-split-methods'.
7571 If N is a positive number, respool the N next articles.
7572 If N is a negative number, respool the N previous articles.
7573 If N is nil and any articles have been marked with the process mark,
7574 respool those articles instead.
7576 Respooling can be done both from mail groups and \"real\" newsgroups.
7577 In the former case, the articles in question will be moved from the
7578 current group into whatever groups they are destined to. In the
7579 latter case, they will be copied into the relevant groups."
7581 (list current-prefix-arg
7582 (let* ((methods (gnus-methods-using 'respool))
7584 (symbol-name (or gnus-summary-respool-default-method
7585 (car (gnus-find-method-for-group
7586 gnus-newsgroup-name)))))
7588 (gnus-completing-read
7589 methname "What backend do you want to use when respooling?"
7590 methods nil t nil 'gnus-mail-method-history))
7593 ((zerop (length (setq ms (gnus-servers-using-backend
7595 (list (intern method) ""))
7599 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7600 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7603 (error "No method given for respooling"))
7604 (if (assoc (symbol-name
7605 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7606 (gnus-methods-using 'respool))
7607 (gnus-summary-move-article n nil method)
7608 (gnus-summary-copy-article n nil method)))
7610 (defun gnus-summary-import-article (file)
7611 "Import an arbitrary file into a mail newsgroup."
7612 (interactive "fImport file: ")
7613 (let ((group gnus-newsgroup-name)
7614 (now (current-time))
7616 (unless (gnus-check-backend-function 'request-accept-article group)
7617 (error "%s does not support article importing" group))
7618 (or (file-readable-p file)
7619 (not (file-regular-p file))
7620 (error "Can't read %s" file))
7622 (set-buffer (gnus-get-buffer-create " *import file*"))
7624 (nnheader-insert-file-contents file)
7625 (goto-char (point-min))
7626 (unless (nnheader-article-p)
7627 ;; This doesn't look like an article, so we fudge some headers.
7628 (setq atts (file-attributes file)
7629 lines (count-lines (point-min) (point-max)))
7630 (insert "From: " (read-string "From: ") "\n"
7631 "Subject: " (read-string "Subject: ") "\n"
7632 "Date: " (message-make-date (nth 5 atts))
7634 "Message-ID: " (message-make-message-id) "\n"
7635 "Lines: " (int-to-string lines) "\n"
7636 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7637 (gnus-request-accept-article group nil t)
7638 (kill-buffer (current-buffer)))))
7640 (defun gnus-summary-article-posted-p ()
7641 "Say whether the current (mail) article is available from news as well.
7642 This will be the case if the article has both been mailed and posted."
7644 (let ((id (mail-header-references (gnus-summary-article-header)))
7645 (gnus-override-method (car (gnus-refer-article-methods))))
7646 (if (gnus-request-head id "")
7647 (gnus-message 2 "The current message was found on %s"
7648 gnus-override-method)
7649 (gnus-message 2 "The current message couldn't be found on %s"
7650 gnus-override-method)
7653 (defun gnus-summary-expire-articles (&optional now)
7654 "Expire all articles that are marked as expirable in the current group."
7656 (when (gnus-check-backend-function
7657 'request-expire-articles gnus-newsgroup-name)
7658 ;; This backend supports expiry.
7659 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7660 (expirable (if total
7662 ;; We need to update the info for
7663 ;; this group for `gnus-list-of-read-articles'
7664 ;; to give us the right answer.
7665 (gnus-run-hooks 'gnus-exit-group-hook)
7666 (gnus-summary-update-info)
7667 (gnus-list-of-read-articles gnus-newsgroup-name))
7668 (setq gnus-newsgroup-expirable
7669 (sort gnus-newsgroup-expirable '<))))
7670 (expiry-wait (if now 'immediate
7671 (gnus-group-find-parameter
7672 gnus-newsgroup-name 'expiry-wait)))
7675 ;; There are expirable articles in this group, so we run them
7676 ;; through the expiry process.
7677 (gnus-message 6 "Expiring articles...")
7678 (unless (gnus-check-group gnus-newsgroup-name)
7679 (error "Can't open server for %s" gnus-newsgroup-name))
7680 ;; The list of articles that weren't expired is returned.
7683 (let ((nnmail-expiry-wait-function nil)
7684 (nnmail-expiry-wait expiry-wait))
7685 (setq es (gnus-request-expire-articles
7686 expirable gnus-newsgroup-name)))
7687 (setq es (gnus-request-expire-articles
7688 expirable gnus-newsgroup-name))))
7690 (setq gnus-newsgroup-expirable es))
7691 ;; We go through the old list of expirable, and mark all
7692 ;; really expired articles as nonexistent.
7693 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7694 (let ((gnus-use-cache nil))
7696 (unless (memq (car expirable) es)
7697 (when (gnus-data-find (car expirable))
7698 (gnus-summary-mark-article
7699 (car expirable) gnus-canceled-mark)))
7700 (setq expirable (cdr expirable)))))
7701 (gnus-message 6 "Expiring articles...done")))))
7703 (defun gnus-summary-expire-articles-now ()
7704 "Expunge all expirable articles in the current group.
7705 This means that *all* articles that are marked as expirable will be
7706 deleted forever, right now."
7708 (or gnus-expert-user
7710 "Are you really, really, really sure you want to delete all these messages? ")
7712 (gnus-summary-expire-articles t))
7714 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7715 (defun gnus-summary-delete-article (&optional n)
7716 "Delete the N next (mail) articles.
7717 This command actually deletes articles. This is not a marking
7718 command. The article will disappear forever from your life, never to
7720 If N is negative, delete backwards.
7721 If N is nil and articles have been marked with the process mark,
7722 delete these instead."
7724 (unless (gnus-check-backend-function 'request-expire-articles
7725 gnus-newsgroup-name)
7726 (error "The current newsgroup does not support article deletion"))
7727 ;; Compute the list of articles to delete.
7728 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7730 (if (and gnus-novice-user
7731 (not (gnus-yes-or-no-p
7732 (format "Do you really want to delete %s forever? "
7733 (if (> (length articles) 1)
7734 (format "these %s articles" (length articles))
7737 ;; Delete the articles.
7738 (setq not-deleted (gnus-request-expire-articles
7739 articles gnus-newsgroup-name 'force))
7741 (gnus-summary-remove-process-mark (car articles))
7742 ;; The backend might not have been able to delete the article
7744 (unless (memq (car articles) not-deleted)
7745 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7746 (setq articles (cdr articles)))
7748 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7749 (gnus-summary-position-point)
7750 (gnus-set-mode-line 'summary)
7753 (defun gnus-summary-edit-article (&optional arg)
7754 "Edit the current article.
7755 This will have permanent effect only in mail groups.
7756 If ARG is nil, edit the decoded articles.
7757 If ARG is 1, edit the raw articles.
7758 If ARG is 2, edit the raw articles even in read-only groups.
7759 Otherwise, allow editing of articles even in read-only
7765 ((eq arg 1) (setq raw t))
7766 ((eq arg 2) (setq raw t
7769 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
7770 (error "Can't edit the raw article in group nndraft:drafts."))
7772 (set-buffer gnus-summary-buffer)
7773 (let ((mail-parse-charset gnus-newsgroup-charset)
7774 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7775 (gnus-set-global-variables)
7776 (when (and (not force)
7777 (gnus-group-read-only-p))
7778 (error "The current newsgroup does not support article editing"))
7779 (gnus-summary-show-article t)
7780 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
7781 (with-current-buffer gnus-article-buffer
7782 (mm-enable-multibyte)))
7783 (if (equal gnus-newsgroup-name "nndraft:drafts")
7785 (gnus-article-edit-article
7788 (let ((mbl mml-buffer-list))
7789 (setq mml-buffer-list nil)
7791 (make-local-hook 'kill-buffer-hook)
7792 (let ((mml-buffer-list mml-buffer-list))
7793 (setq mml-buffer-list mbl)
7794 (make-local-variable 'mml-buffer-list))
7795 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
7796 `(lambda (no-highlight)
7797 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7798 (mail-parse-ignored-charsets
7799 ',gnus-newsgroup-ignored-charsets))
7800 ,(if (not raw) '(progn
7802 (mml-destroy-buffers)
7803 (remove-hook 'kill-buffer-hook
7804 'mml-destroy-buffers t)
7805 (kill-local-variable 'mml-buffer-list)))
7806 (gnus-summary-edit-article-done
7807 ,(or (mail-header-references gnus-current-headers) "")
7808 ,(gnus-group-read-only-p)
7809 ,gnus-summary-buffer no-highlight))))))))
7811 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7813 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7815 "Make edits to the current article permanent."
7817 ;; Replace the article.
7818 (let ((buf (current-buffer)))
7820 (insert-buffer-substring buf)
7821 (if (and (not read-only)
7822 (not (gnus-request-replace-article
7823 (cdr gnus-article-current) (car gnus-article-current)
7824 (current-buffer) t)))
7825 (error "Couldn't replace article")
7826 ;; Update the summary buffer.
7828 (equal (message-tokenize-header references " ")
7829 (message-tokenize-header
7830 (or (message-fetch-field "references") "") " ")))
7831 ;; We only have to update this line.
7834 (message-narrow-to-head)
7835 (let ((head (buffer-string))
7838 (insert (format "211 %d Article retrieved.\n"
7839 (cdr gnus-article-current)))
7842 (let ((nntp-server-buffer (current-buffer)))
7843 (setq header (car (gnus-get-newsgroup-headers
7845 (set-buffer gnus-summary-buffer)
7846 gnus-newsgroup-dependencies)
7849 (set-buffer gnus-summary-buffer)
7850 (gnus-data-set-header
7851 (gnus-data-find (cdr gnus-article-current))
7853 (gnus-summary-update-article-line
7854 (cdr gnus-article-current) header))))))
7856 (set-buffer (or buffer gnus-summary-buffer))
7857 (gnus-summary-update-article (cdr gnus-article-current)))
7858 ;; Prettify the article buffer again.
7859 (unless no-highlight
7861 (set-buffer gnus-article-buffer)
7862 ;;;!!! Fix this -- article should be rehighlighted.
7863 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7864 (set-buffer gnus-original-article-buffer)
7865 (gnus-request-article
7866 (cdr gnus-article-current)
7867 (car gnus-article-current) (current-buffer))))
7868 ;; Prettify the summary buffer line.
7869 (when (gnus-visual-p 'summary-highlight 'highlight)
7870 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7872 (defun gnus-summary-edit-wash (key)
7873 "Perform editing command KEY in the article buffer."
7877 (message "%s" (concat (this-command-keys) "- "))
7880 (gnus-summary-edit-article)
7881 (execute-kbd-macro (concat (this-command-keys) key))
7882 (gnus-article-edit-done))
7886 (defun gnus-summary-respool-query (&optional silent trace)
7887 "Query where the respool algorithm would put this article."
7889 (let (gnus-mark-article-hook)
7890 (gnus-summary-select-article)
7892 (set-buffer gnus-original-article-buffer)
7894 (message-narrow-to-head)
7895 (let ((groups (nnmail-article-group 'identity trace)))
7898 (message "This message would go to %s"
7899 (mapconcat 'car groups ", "))
7900 (message "This message would go to no groups"))
7903 (defun gnus-summary-respool-trace ()
7904 "Trace where the respool algorithm would put this article.
7905 Display a buffer showing all fancy splitting patterns which matched."
7907 (gnus-summary-respool-query nil t))
7909 ;; Summary marking commands.
7911 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7912 "Mark articles which has the same subject as read, and then select the next.
7913 If UNMARK is positive, remove any kind of mark.
7914 If UNMARK is negative, tick articles."
7917 (setq unmark (prefix-numeric-value unmark)))
7919 (gnus-summary-mark-same-subject
7920 (gnus-summary-article-subject) unmark)))
7921 ;; Select next unread article. If auto-select-same mode, should
7922 ;; select the first unread article.
7923 (gnus-summary-next-article t (and gnus-auto-select-same
7924 (gnus-summary-article-subject)))
7925 (gnus-message 7 "%d article%s marked as %s"
7926 count (if (= count 1) " is" "s are")
7927 (if unmark "unread" "read"))))
7929 (defun gnus-summary-kill-same-subject (&optional unmark)
7930 "Mark articles which has the same subject as read.
7931 If UNMARK is positive, remove any kind of mark.
7932 If UNMARK is negative, tick articles."
7935 (setq unmark (prefix-numeric-value unmark)))
7937 (gnus-summary-mark-same-subject
7938 (gnus-summary-article-subject) unmark)))
7939 ;; If marked as read, go to next unread subject.
7941 ;; Go to next unread subject.
7942 (gnus-summary-next-subject 1 t))
7943 (gnus-message 7 "%d articles are marked as %s"
7944 count (if unmark "unread" "read"))))
7946 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7947 "Mark articles with same SUBJECT as read, and return marked number.
7948 If optional argument UNMARK is positive, remove any kinds of marks.
7949 If optional argument UNMARK is negative, mark articles as unread instead."
7953 ((null unmark) ; Mark as read.
7956 (gnus-summary-mark-article-as-read gnus-killed-mark)
7957 (gnus-summary-show-thread) t)
7958 (gnus-summary-find-subject subject))
7959 (setq count (1+ count))))
7960 ((> unmark 0) ; Tick.
7963 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7964 (gnus-summary-show-thread) t)
7965 (gnus-summary-find-subject subject))
7966 (setq count (1+ count))))
7967 (t ; Mark as unread.
7970 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7971 (gnus-summary-show-thread) t)
7972 (gnus-summary-find-subject subject))
7973 (setq count (1+ count)))))
7974 (gnus-set-mode-line 'summary)
7975 ;; Return the number of marked articles.
7978 (defun gnus-summary-mark-as-processable (n &optional unmark)
7979 "Set the process mark on the next N articles.
7980 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7981 the process mark instead. The difference between N and the actual
7982 number of articles marked is returned."
7984 (let ((backward (< n 0))
7989 (gnus-summary-remove-process-mark
7990 (gnus-summary-article-number))
7991 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7992 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7995 (gnus-message 7 "No more articles"))
7996 (gnus-summary-recenter)
7997 (gnus-summary-position-point)
8000 (defun gnus-summary-unmark-as-processable (n)
8001 "Remove the process mark from the next N articles.
8002 If N is negative, unmark backward instead. The difference between N and
8003 the actual number of articles unmarked is returned."
8005 (gnus-summary-mark-as-processable n t))
8007 (defun gnus-summary-unmark-all-processable ()
8008 "Remove the process mark from all articles."
8011 (while gnus-newsgroup-processable
8012 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8013 (gnus-summary-position-point))
8015 (defun gnus-summary-mark-as-expirable (n)
8016 "Mark N articles forward as expirable.
8017 If N is negative, mark backward instead. The difference between N and
8018 the actual number of articles marked is returned."
8020 (gnus-summary-mark-forward n gnus-expirable-mark))
8022 (defun gnus-summary-mark-article-as-replied (article)
8023 "Mark ARTICLE replied and update the summary line."
8024 (push article gnus-newsgroup-replied)
8025 (let ((buffer-read-only nil))
8026 (when (gnus-summary-goto-subject article nil t)
8027 (gnus-summary-update-secondary-mark article))))
8029 (defun gnus-summary-set-bookmark (article)
8030 "Set a bookmark in current article."
8031 (interactive (list (gnus-summary-article-number)))
8032 (when (or (not (get-buffer gnus-article-buffer))
8033 (not gnus-current-article)
8034 (not gnus-article-current)
8035 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8036 (error "No current article selected"))
8037 ;; Remove old bookmark, if one exists.
8038 (let ((old (assq article gnus-newsgroup-bookmarks)))
8040 (setq gnus-newsgroup-bookmarks
8041 (delq old gnus-newsgroup-bookmarks))))
8042 ;; Set the new bookmark, which is on the form
8043 ;; (article-number . line-number-in-body).
8047 (set-buffer gnus-article-buffer)
8051 (goto-char (point-min))
8052 (search-forward "\n\n" nil t)
8055 gnus-newsgroup-bookmarks)
8056 (gnus-message 6 "A bookmark has been added to the current article."))
8058 (defun gnus-summary-remove-bookmark (article)
8059 "Remove the bookmark from the current article."
8060 (interactive (list (gnus-summary-article-number)))
8061 ;; Remove old bookmark, if one exists.
8062 (let ((old (assq article gnus-newsgroup-bookmarks)))
8065 (setq gnus-newsgroup-bookmarks
8066 (delq old gnus-newsgroup-bookmarks))
8067 (gnus-message 6 "Removed bookmark."))
8068 (gnus-message 6 "No bookmark in current article."))))
8070 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8071 (defun gnus-summary-mark-as-dormant (n)
8072 "Mark N articles forward as dormant.
8073 If N is negative, mark backward instead. The difference between N and
8074 the actual number of articles marked is returned."
8076 (gnus-summary-mark-forward n gnus-dormant-mark))
8078 (defun gnus-summary-set-process-mark (article)
8079 "Set the process mark on ARTICLE and update the summary line."
8080 (setq gnus-newsgroup-processable
8082 (delq article gnus-newsgroup-processable)))
8083 (when (gnus-summary-goto-subject article)
8084 (gnus-summary-show-thread)
8085 (gnus-summary-goto-subject article)
8086 (gnus-summary-update-secondary-mark article)))
8088 (defun gnus-summary-remove-process-mark (article)
8089 "Remove the process mark from ARTICLE and update the summary line."
8090 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8091 (when (gnus-summary-goto-subject article)
8092 (gnus-summary-show-thread)
8093 (gnus-summary-goto-subject article)
8094 (gnus-summary-update-secondary-mark article)))
8096 (defun gnus-summary-set-saved-mark (article)
8097 "Set the process mark on ARTICLE and update the summary line."
8098 (push article gnus-newsgroup-saved)
8099 (when (gnus-summary-goto-subject article)
8100 (gnus-summary-update-secondary-mark article)))
8102 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8103 "Mark N articles as read forwards.
8104 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8105 The difference between N and the actual number of articles marked is
8107 Iff NO-EXPIRE, auto-expiry will be inhibited."
8109 (gnus-summary-show-thread)
8110 (let ((backward (< n 0))
8111 (gnus-summary-goto-unread
8112 (and gnus-summary-goto-unread
8113 (not (eq gnus-summary-goto-unread 'never))
8114 (not (memq mark (list gnus-unread-mark
8115 gnus-ticked-mark gnus-dormant-mark)))))
8117 (mark (or mark gnus-del-mark)))
8119 (gnus-summary-mark-article nil mark no-expire)
8120 (zerop (gnus-summary-next-subject
8122 (and gnus-summary-goto-unread
8123 (not (eq gnus-summary-goto-unread 'never)))
8127 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8128 (gnus-summary-recenter)
8129 (gnus-summary-position-point)
8130 (gnus-set-mode-line 'summary)
8133 (defun gnus-summary-mark-article-as-read (mark)
8134 "Mark the current article quickly as read with MARK."
8135 (let ((article (gnus-summary-article-number)))
8136 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8137 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8138 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8139 (push (cons article mark) gnus-newsgroup-reads)
8140 ;; Possibly remove from cache, if that is used.
8141 (when gnus-use-cache
8142 (gnus-cache-enter-remove-article article))
8143 ;; Allow the backend to change the mark.
8144 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8145 ;; Check for auto-expiry.
8146 (when (and gnus-newsgroup-auto-expire
8147 (memq mark gnus-auto-expirable-marks))
8148 (setq mark gnus-expirable-mark)
8149 ;; Let the backend know about the mark change.
8150 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8151 (push article gnus-newsgroup-expirable))
8152 ;; Set the mark in the buffer.
8153 (gnus-summary-update-mark mark 'unread)
8156 (defun gnus-summary-mark-article-as-unread (mark)
8157 "Mark the current article quickly as unread with MARK."
8158 (let* ((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)
8166 (gnus-error 1 "Can't mark negative article numbers")
8168 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8169 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8170 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8171 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8172 (cond ((= mark gnus-ticked-mark)
8173 (push article gnus-newsgroup-marked))
8174 ((= mark gnus-dormant-mark)
8175 (push article gnus-newsgroup-dormant))
8177 (push article gnus-newsgroup-unreads)))
8178 (gnus-pull article gnus-newsgroup-reads)
8180 ;; See whether the article is to be put in the cache.
8182 (vectorp (gnus-summary-article-header article))
8184 (gnus-cache-possibly-enter-article
8185 gnus-newsgroup-name article
8186 (= mark gnus-ticked-mark)
8187 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8190 (gnus-summary-update-mark mark 'unread)
8193 (defun gnus-summary-mark-article (&optional article mark no-expire)
8194 "Mark ARTICLE with MARK. MARK can be any character.
8195 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8196 `??' (dormant) and `?E' (expirable).
8197 If MARK is nil, then the default character `?r' is used.
8198 If ARTICLE is nil, then the article on the current line will be
8200 Iff NO-EXPIRE, auto-expiry will be inhibited."
8201 ;; The mark might be a string.
8202 (when (stringp mark)
8203 (setq mark (aref mark 0)))
8204 ;; If no mark is given, then we check auto-expiring.
8206 (setq mark gnus-del-mark))
8207 (when (and (not no-expire)
8208 gnus-newsgroup-auto-expire
8209 (memq mark gnus-auto-expirable-marks))
8210 (setq mark gnus-expirable-mark))
8211 (let ((article (or article (gnus-summary-article-number)))
8212 (old-mark (gnus-summary-article-mark article)))
8213 ;; Allow the backend to change the mark.
8214 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8215 (if (eq mark old-mark)
8218 (error "No article on current line"))
8219 (if (not (if (or (= mark gnus-unread-mark)
8220 (= mark gnus-ticked-mark)
8221 (= mark gnus-dormant-mark))
8222 (gnus-mark-article-as-unread article mark)
8223 (gnus-mark-article-as-read article mark)))
8225 ;; See whether the article is to be put in the cache.
8227 (not (= mark gnus-canceled-mark))
8228 (vectorp (gnus-summary-article-header article))
8230 (gnus-cache-possibly-enter-article
8231 gnus-newsgroup-name article
8232 (= mark gnus-ticked-mark)
8233 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8235 (when (gnus-summary-goto-subject article nil t)
8236 (let ((buffer-read-only nil))
8237 (gnus-summary-show-thread)
8239 (gnus-summary-update-mark mark 'unread)
8242 (defun gnus-summary-update-secondary-mark (article)
8243 "Update the secondary (read, process, cache) mark."
8244 (gnus-summary-update-mark
8245 (cond ((memq article gnus-newsgroup-processable)
8247 ((memq article gnus-newsgroup-cached)
8249 ((memq article gnus-newsgroup-replied)
8251 ((memq article gnus-newsgroup-saved)
8253 (t gnus-unread-mark))
8255 (when (gnus-visual-p 'summary-highlight 'highlight)
8256 (gnus-run-hooks 'gnus-summary-update-hook))
8259 (defun gnus-summary-update-mark (mark type)
8260 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8261 (buffer-read-only nil))
8262 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8264 (when (looking-at "\r")
8266 (when (<= (+ forward (point)) (point-max))
8267 ;; Go to the right position on the line.
8268 (goto-char (+ forward (point)))
8269 ;; Replace the old mark with the new mark.
8270 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8271 ;; Optionally update the marks by some user rule.
8272 (when (eq type 'unread)
8274 (gnus-data-find (gnus-summary-article-number)) mark)
8275 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8277 (defun gnus-mark-article-as-read (article &optional mark)
8278 "Enter ARTICLE in the pertinent lists and remove it from others."
8279 ;; Make the article expirable.
8280 (let ((mark (or mark gnus-del-mark)))
8281 (if (= mark gnus-expirable-mark)
8282 (push article gnus-newsgroup-expirable)
8283 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8284 ;; Remove from unread and marked lists.
8285 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8286 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8287 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8288 (push (cons article mark) gnus-newsgroup-reads)
8289 ;; Possibly remove from cache, if that is used.
8290 (when gnus-use-cache
8291 (gnus-cache-enter-remove-article article))
8294 (defun gnus-mark-article-as-unread (article &optional mark)
8295 "Enter ARTICLE in the pertinent lists and remove it from others."
8296 (let ((mark (or mark gnus-ticked-mark)))
8299 (gnus-error 1 "Can't mark negative article numbers")
8301 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8302 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8303 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8304 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8306 ;; Unsuppress duplicates?
8307 (when gnus-suppress-duplicates
8308 (gnus-dup-unsuppress-article article))
8310 (cond ((= mark gnus-ticked-mark)
8311 (push article gnus-newsgroup-marked))
8312 ((= mark gnus-dormant-mark)
8313 (push article gnus-newsgroup-dormant))
8315 (push article gnus-newsgroup-unreads)))
8316 (gnus-pull article gnus-newsgroup-reads)
8319 (defalias 'gnus-summary-mark-as-unread-forward
8320 'gnus-summary-tick-article-forward)
8321 (make-obsolete 'gnus-summary-mark-as-unread-forward
8322 'gnus-summary-tick-article-forward)
8323 (defun gnus-summary-tick-article-forward (n)
8324 "Tick N articles forwards.
8325 If N is negative, tick backwards instead.
8326 The difference between N and the number of articles ticked is returned."
8328 (gnus-summary-mark-forward n gnus-ticked-mark))
8330 (defalias 'gnus-summary-mark-as-unread-backward
8331 'gnus-summary-tick-article-backward)
8332 (make-obsolete 'gnus-summary-mark-as-unread-backward
8333 'gnus-summary-tick-article-backward)
8334 (defun gnus-summary-tick-article-backward (n)
8335 "Tick N articles backwards.
8336 The difference between N and the number of articles ticked is returned."
8338 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8340 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8341 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8342 (defun gnus-summary-tick-article (&optional article clear-mark)
8343 "Mark current article as unread.
8344 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8345 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8347 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8350 (defun gnus-summary-mark-as-read-forward (n)
8351 "Mark N articles as read forwards.
8352 If N is negative, mark backwards instead.
8353 The difference between N and the actual number of articles marked is
8356 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8358 (defun gnus-summary-mark-as-read-backward (n)
8359 "Mark the N articles as read backwards.
8360 The difference between N and the actual number of articles marked is
8363 (gnus-summary-mark-forward
8364 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8366 (defun gnus-summary-mark-as-read (&optional article mark)
8367 "Mark current article as read.
8368 ARTICLE specifies the article to be marked as read.
8369 MARK specifies a string to be inserted at the beginning of the line."
8370 (gnus-summary-mark-article article mark))
8372 (defun gnus-summary-clear-mark-forward (n)
8373 "Clear marks from N articles forward.
8374 If N is negative, clear backward instead.
8375 The difference between N and the number of marks cleared is returned."
8377 (gnus-summary-mark-forward n gnus-unread-mark))
8379 (defun gnus-summary-clear-mark-backward (n)
8380 "Clear marks from N articles backward.
8381 The difference between N and the number of marks cleared is returned."
8383 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8385 (defun gnus-summary-mark-unread-as-read ()
8386 "Intended to be used by `gnus-summary-mark-article-hook'."
8387 (when (memq gnus-current-article gnus-newsgroup-unreads)
8388 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8390 (defun gnus-summary-mark-read-and-unread-as-read ()
8391 "Intended to be used by `gnus-summary-mark-article-hook'."
8392 (let ((mark (gnus-summary-article-mark)))
8393 (when (or (gnus-unread-mark-p mark)
8394 (gnus-read-mark-p mark))
8395 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8397 (defun gnus-summary-mark-region-as-read (point mark all)
8398 "Mark all unread articles between point and mark as read.
8399 If given a prefix, mark all articles between point and mark as read,
8400 even ticked and dormant ones."
8401 (interactive "r\nP")
8410 (memq (setq article (gnus-summary-article-number))
8411 gnus-newsgroup-unreads))
8412 (gnus-summary-mark-article article gnus-del-mark))
8414 (gnus-summary-find-next))))))
8416 (defun gnus-summary-mark-below (score mark)
8417 "Mark articles with score less than SCORE with MARK."
8418 (interactive "P\ncMark: ")
8419 (setq score (if score
8420 (prefix-numeric-value score)
8421 (or gnus-summary-default-score 0)))
8423 (set-buffer gnus-summary-buffer)
8424 (goto-char (point-min))
8427 (and (< (gnus-summary-article-score) score)
8428 (gnus-summary-mark-article nil mark))
8429 (gnus-summary-find-next)))))
8431 (defun gnus-summary-kill-below (&optional score)
8432 "Mark articles with score below SCORE as read."
8434 (gnus-summary-mark-below score gnus-killed-mark))
8436 (defun gnus-summary-clear-above (&optional score)
8437 "Clear all marks from articles with score above SCORE."
8439 (gnus-summary-mark-above score gnus-unread-mark))
8441 (defun gnus-summary-tick-above (&optional score)
8442 "Tick all articles with score above SCORE."
8444 (gnus-summary-mark-above score gnus-ticked-mark))
8446 (defun gnus-summary-mark-above (score mark)
8447 "Mark articles with score over SCORE with MARK."
8448 (interactive "P\ncMark: ")
8449 (setq score (if score
8450 (prefix-numeric-value score)
8451 (or gnus-summary-default-score 0)))
8453 (set-buffer gnus-summary-buffer)
8454 (goto-char (point-min))
8456 (when (> (gnus-summary-article-score) score)
8457 (gnus-summary-mark-article nil mark))
8459 (gnus-summary-find-next)))))
8461 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8462 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8463 (defun gnus-summary-limit-include-expunged (&optional no-error)
8464 "Display all the hidden articles that were expunged for low scores."
8466 (let ((buffer-read-only nil))
8467 (let ((scored gnus-newsgroup-scored)
8470 (unless (gnus-summary-goto-subject (caar scored))
8471 (and (setq h (gnus-summary-article-header (caar scored)))
8472 (< (cdar scored) gnus-summary-expunge-below)
8474 (setq scored (cdr scored)))
8476 (when (not no-error)
8477 (error "No expunged articles hidden"))
8478 (goto-char (point-min))
8479 (gnus-summary-prepare-unthreaded (nreverse headers))
8480 (goto-char (point-min))
8481 (gnus-summary-position-point)
8484 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8485 "Mark all unread articles in this newsgroup as read.
8486 If prefix argument ALL is non-nil, ticked and dormant articles will
8487 also be marked as read.
8488 If QUIETLY is non-nil, no questions will be asked.
8489 If TO-HERE is non-nil, it should be a point in the buffer. All
8490 articles before this point will be marked as read.
8491 Note that this function will only catch up the unread article
8492 in the current summary buffer limitation.
8493 The number of articles marked as read is returned."
8498 (not gnus-interactive-catchup) ;Without confirmation?
8502 "Mark absolutely all articles as read? "
8503 "Mark all unread articles as read? ")))
8505 (not gnus-newsgroup-adaptive)
8506 (not gnus-newsgroup-auto-expire)
8507 (not gnus-suppress-duplicates)
8508 (or (not gnus-use-cache)
8509 (eq gnus-use-cache 'passive)))
8512 (setq gnus-newsgroup-marked nil
8513 gnus-newsgroup-dormant nil))
8514 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8515 ;; We actually mark all articles as canceled, which we
8516 ;; have to do when using auto-expiry or adaptive scoring.
8517 (gnus-summary-show-all-threads)
8518 (when (gnus-summary-first-subject (not all) t)
8520 (if to-here (< (point) to-here) t)
8521 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8522 (gnus-summary-find-next (not all) nil nil t))))
8523 (gnus-set-mode-line 'summary))
8525 (gnus-summary-position-point)))
8527 (defun gnus-summary-catchup-to-here (&optional all)
8528 "Mark all unticked articles before the current one as read.
8529 If ALL is non-nil, also mark ticked and dormant articles as read."
8532 (gnus-save-hidden-threads
8533 (let ((beg (point)))
8534 ;; We check that there are unread articles.
8535 (when (or all (gnus-summary-find-prev))
8536 (gnus-summary-catchup all t beg)))))
8537 (gnus-summary-position-point))
8539 (defun gnus-summary-catchup-all (&optional quietly)
8540 "Mark all articles in this newsgroup as read."
8542 (gnus-summary-catchup t quietly))
8544 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8545 "Mark all unread articles in this group as read, then exit.
8546 If prefix argument ALL is non-nil, all articles are marked as read."
8548 (when (gnus-summary-catchup all quietly nil 'fast)
8549 ;; Select next newsgroup or exit.
8550 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8551 (eq gnus-auto-select-next 'quietly))
8552 (gnus-summary-next-group nil)
8553 (gnus-summary-exit))))
8555 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8556 "Mark all articles in this newsgroup as read, and then exit."
8558 (gnus-summary-catchup-and-exit t quietly))
8560 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8561 "Mark all articles in this group as read and select the next group.
8562 If given a prefix, mark all articles, unread as well as ticked, as
8566 (gnus-summary-catchup all))
8567 (gnus-summary-next-group))
8573 (defmacro gnus-with-article (article &rest forms)
8574 "Select ARTICLE and perform FORMS in the original article buffer.
8575 Then replace the article with the result."
8577 ;; We don't want the article to be marked as read.
8578 (let (gnus-mark-article-hook)
8579 (gnus-summary-select-article t t nil ,article))
8580 (set-buffer gnus-original-article-buffer)
8582 (if (not (gnus-check-backend-function
8583 'request-replace-article (car gnus-article-current)))
8584 (gnus-message 5 "Read-only group; not replacing")
8585 (unless (gnus-request-replace-article
8586 ,article (car gnus-article-current)
8588 (error "Couldn't replace article")))
8589 ;; The cache and backlog have to be flushed somewhat.
8590 (when gnus-keep-backlog
8591 (gnus-backlog-remove-article
8592 (car gnus-article-current) (cdr gnus-article-current)))
8593 (when gnus-use-cache
8594 (gnus-cache-update-article
8595 (car gnus-article-current) (cdr gnus-article-current)))))
8597 (put 'gnus-with-article 'lisp-indent-function 1)
8598 (put 'gnus-with-article 'edebug-form-spec '(form body))
8600 ;; Thread-based commands.
8602 (defun gnus-summary-articles-in-thread (&optional article)
8603 "Return a list of all articles in the current thread.
8604 If ARTICLE is non-nil, return all articles in the thread that starts
8606 (let* ((article (or article (gnus-summary-article-number)))
8607 (data (gnus-data-find-list article))
8608 (top-level (gnus-data-level (car data)))
8610 (cond ((null gnus-thread-operation-ignore-subject)
8611 (gnus-simplify-subject-re
8612 (mail-header-subject (gnus-data-header (car data)))))
8613 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8614 (gnus-simplify-subject-fuzzy
8615 (mail-header-subject (gnus-data-header (car data)))))
8617 (end-point (save-excursion
8618 (if (gnus-summary-go-to-next-thread)
8619 (point) (point-max))))
8622 (< (gnus-data-pos (car data)) end-point))
8623 (when (or (not top-subject)
8624 (string= top-subject
8625 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8626 (gnus-simplify-subject-fuzzy
8627 (mail-header-subject
8628 (gnus-data-header (car data))))
8629 (gnus-simplify-subject-re
8630 (mail-header-subject
8631 (gnus-data-header (car data)))))))
8632 (push (gnus-data-number (car data)) articles))
8633 (unless (and (setq data (cdr data))
8634 (> (gnus-data-level (car data)) top-level))
8636 ;; Return the list of articles.
8637 (nreverse articles)))
8639 (defun gnus-summary-rethread-current ()
8640 "Rethread the thread the current article is part of."
8642 (let* ((gnus-show-threads t)
8643 (article (gnus-summary-article-number))
8644 (id (mail-header-id (gnus-summary-article-header)))
8645 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8647 (error "No article on the current line"))
8648 (gnus-rebuild-thread id)
8649 (gnus-summary-goto-subject article)))
8651 (defun gnus-summary-reparent-thread ()
8652 "Make the current article child of the marked (or previous) article.
8654 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8655 is non-nil or the Subject: of both articles are the same."
8657 (unless (not (gnus-group-read-only-p))
8658 (error "The current newsgroup does not support article editing"))
8659 (unless (<= (length gnus-newsgroup-processable) 1)
8660 (error "No more than one article may be marked"))
8661 (save-window-excursion
8662 (let ((gnus-article-buffer " *reparent*")
8663 (current-article (gnus-summary-article-number))
8664 ;; First grab the marked article, otherwise one line up.
8665 (parent-article (if (not (null gnus-newsgroup-processable))
8666 (car gnus-newsgroup-processable)
8668 (if (eq (forward-line -1) 0)
8669 (gnus-summary-article-number)
8670 (error "Beginning of summary buffer"))))))
8671 (unless (not (eq current-article parent-article))
8672 (error "An article may not be self-referential"))
8673 (let ((message-id (mail-header-id
8674 (gnus-summary-article-header parent-article))))
8675 (unless (and message-id (not (equal message-id "")))
8676 (error "No message-id in desired parent"))
8677 (gnus-with-article current-article
8678 (goto-char (point-min))
8679 (if (re-search-forward "^References: " nil t)
8681 (re-search-forward "^[^ \t]" nil t)
8684 (insert " " message-id))
8685 (insert "References: " message-id "\n")))
8686 (set-buffer gnus-summary-buffer)
8687 (gnus-summary-unmark-all-processable)
8688 (gnus-summary-update-article current-article)
8689 (gnus-summary-rethread-current)
8690 (gnus-message 3 "Article %d is now the child of article %d"
8691 current-article parent-article)))))
8693 (defun gnus-summary-toggle-threads (&optional arg)
8694 "Toggle showing conversation threads.
8695 If ARG is positive number, turn showing conversation threads on."
8697 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8698 (setq gnus-show-threads
8699 (if (null arg) (not gnus-show-threads)
8700 (> (prefix-numeric-value arg) 0)))
8701 (gnus-summary-prepare)
8702 (gnus-summary-goto-subject current)
8703 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8704 (gnus-summary-position-point)))
8706 (defun gnus-summary-show-all-threads ()
8710 (let ((buffer-read-only nil))
8711 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8712 (gnus-summary-position-point))
8714 (defun gnus-summary-show-thread ()
8715 "Show thread subtrees.
8716 Returns nil if no thread was there to be shown."
8718 (let ((buffer-read-only nil)
8720 ;; first goto end then to beg, to have point at beg after let
8721 (end (progn (end-of-line) (point)))
8722 (beg (progn (beginning-of-line) (point))))
8724 ;; Any hidden lines here?
8725 (search-forward "\r" end t)
8726 (subst-char-in-region beg end ?\^M ?\n t)
8728 (gnus-summary-position-point))))
8730 (defun gnus-summary-hide-all-threads ()
8731 "Hide all thread subtrees."
8734 (goto-char (point-min))
8735 (gnus-summary-hide-thread)
8736 (while (zerop (gnus-summary-next-thread 1 t))
8737 (gnus-summary-hide-thread)))
8738 (gnus-summary-position-point))
8740 (defun gnus-summary-hide-thread ()
8741 "Hide thread subtrees.
8742 Returns nil if no threads were there to be hidden."
8744 (let ((buffer-read-only nil)
8746 (article (gnus-summary-article-number)))
8748 ;; Go forward until either the buffer ends or the subthread
8750 (when (and (not (eobp))
8751 (or (zerop (gnus-summary-next-thread 1 t))
8752 (goto-char (point-max))))
8754 (if (and (> (point) start)
8755 (search-backward "\n" start t))
8757 (subst-char-in-region start (point) ?\n ?\^M)
8758 (gnus-summary-goto-subject article))
8762 (defun gnus-summary-go-to-next-thread (&optional previous)
8763 "Go to the same level (or less) next thread.
8764 If PREVIOUS is non-nil, go to previous thread instead.
8765 Return the article number moved to, or nil if moving was impossible."
8766 (let ((level (gnus-summary-thread-level))
8767 (way (if previous -1 1))
8770 (while (and (not (eobp))
8771 (< level (gnus-summary-thread-level)))
8779 (gnus-summary-article-number)
8782 (defun gnus-summary-next-thread (n &optional silent)
8783 "Go to the same level next N'th thread.
8784 If N is negative, search backward instead.
8785 Returns the difference between N and the number of skips actually
8788 If SILENT, don't output messages."
8790 (let ((backward (< n 0))
8793 (gnus-summary-go-to-next-thread backward))
8796 (gnus-summary-position-point))
8797 (when (and (not silent) (/= 0 n))
8798 (gnus-message 7 "No more threads"))
8801 (defun gnus-summary-prev-thread (n)
8802 "Go to the same level previous N'th thread.
8803 Returns the difference between N and the number of skips actually
8806 (gnus-summary-next-thread (- n)))
8808 (defun gnus-summary-go-down-thread ()
8809 "Go down one level in the current thread."
8810 (let ((children (gnus-summary-article-children)))
8812 (gnus-summary-goto-subject (car children)))))
8814 (defun gnus-summary-go-up-thread ()
8815 "Go up one level in the current thread."
8816 (let ((parent (gnus-summary-article-parent)))
8818 (gnus-summary-goto-subject parent))))
8820 (defun gnus-summary-down-thread (n)
8821 "Go down thread N steps.
8822 If N is negative, go up instead.
8823 Returns the difference between N and how many steps down that were
8829 (if up (gnus-summary-go-up-thread)
8830 (gnus-summary-go-down-thread)))
8832 (gnus-summary-position-point)
8834 (gnus-message 7 "Can't go further"))
8837 (defun gnus-summary-up-thread (n)
8838 "Go up thread N steps.
8839 If N is negative, go up instead.
8840 Returns the difference between N and how many steps down that were
8843 (gnus-summary-down-thread (- n)))
8845 (defun gnus-summary-top-thread ()
8846 "Go to the top of the thread."
8848 (while (gnus-summary-go-up-thread))
8849 (gnus-summary-article-number))
8851 (defun gnus-summary-kill-thread (&optional unmark)
8852 "Mark articles under current thread as read.
8853 If the prefix argument is positive, remove any kinds of marks.
8854 If the prefix argument is negative, tick articles instead."
8857 (setq unmark (prefix-numeric-value unmark)))
8858 (let ((articles (gnus-summary-articles-in-thread)))
8860 ;; Expand the thread.
8861 (gnus-summary-show-thread)
8862 ;; Mark all the articles.
8864 (gnus-summary-goto-subject (car articles))
8865 (cond ((null unmark)
8866 (gnus-summary-mark-article-as-read gnus-killed-mark))
8868 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8870 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8871 (setq articles (cdr articles))))
8872 ;; Hide killed subtrees.
8874 gnus-thread-hide-killed
8875 (gnus-summary-hide-thread))
8876 ;; If marked as read, go to next unread subject.
8878 ;; Go to next unread subject.
8879 (gnus-summary-next-subject 1 t)))
8880 (gnus-set-mode-line 'summary))
8882 ;; Summary sorting commands
8884 (defun gnus-summary-sort-by-number (&optional reverse)
8885 "Sort the summary buffer by article number.
8886 Argument REVERSE means reverse order."
8888 (gnus-summary-sort 'number reverse))
8890 (defun gnus-summary-sort-by-author (&optional reverse)
8891 "Sort the summary buffer by author name alphabetically.
8892 If case-fold-search is non-nil, case of letters is ignored.
8893 Argument REVERSE means reverse order."
8895 (gnus-summary-sort 'author reverse))
8897 (defun gnus-summary-sort-by-subject (&optional reverse)
8898 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8899 If case-fold-search is non-nil, case of letters is ignored.
8900 Argument REVERSE means reverse order."
8902 (gnus-summary-sort 'subject reverse))
8904 (defun gnus-summary-sort-by-date (&optional reverse)
8905 "Sort the summary buffer by date.
8906 Argument REVERSE means reverse order."
8908 (gnus-summary-sort 'date reverse))
8910 (defun gnus-summary-sort-by-score (&optional reverse)
8911 "Sort the summary buffer by score.
8912 Argument REVERSE means reverse order."
8914 (gnus-summary-sort 'score reverse))
8916 (defun gnus-summary-sort-by-lines (&optional reverse)
8917 "Sort the summary buffer by the number of lines.
8918 Argument REVERSE means reverse order."
8920 (gnus-summary-sort 'lines reverse))
8922 (defun gnus-summary-sort-by-chars (&optional reverse)
8923 "Sort the summary buffer by article length.
8924 Argument REVERSE means reverse order."
8926 (gnus-summary-sort 'chars reverse))
8928 (defun gnus-summary-sort (predicate reverse)
8929 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8930 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8931 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8932 (gnus-thread-sort-functions
8937 (gnus-article-sort-functions
8943 (gnus-summary-prepare-hook nil))
8944 ;; We do the sorting by regenerating the threads.
8945 (gnus-summary-prepare)
8946 ;; Hide subthreads if needed.
8947 (when (and gnus-show-threads gnus-thread-hide-subtree)
8948 (gnus-summary-hide-all-threads))))
8950 ;; Summary saving commands.
8952 (defun gnus-summary-save-article (&optional n not-saved)
8953 "Save the current article using the default saver function.
8954 If N is a positive number, save the N next articles.
8955 If N is a negative number, save the N previous articles.
8956 If N is nil and any articles have been marked with the process mark,
8957 save those articles instead.
8958 The variable `gnus-default-article-saver' specifies the saver function."
8960 (let* ((articles (gnus-summary-work-articles n))
8961 (save-buffer (save-excursion
8962 (nnheader-set-temp-buffer " *Gnus Save*")))
8963 (num (length articles))
8965 (dolist (article articles)
8966 (setq header (gnus-summary-article-header article))
8967 (if (not (vectorp header))
8968 ;; This is a pseudo-article.
8969 (if (assq 'name header)
8970 (gnus-copy-file (cdr (assq 'name header)))
8971 (gnus-message 1 "Article %d is unsaveable" article))
8972 ;; This is a real article.
8973 (save-window-excursion
8974 (gnus-summary-select-article t nil nil article))
8976 (set-buffer save-buffer)
8978 (insert-buffer-substring gnus-original-article-buffer))
8979 (setq file (gnus-article-save save-buffer file num))
8980 (gnus-summary-remove-process-mark article)
8982 (gnus-summary-set-saved-mark article))))
8983 (gnus-kill-buffer save-buffer)
8984 (gnus-summary-position-point)
8985 (gnus-set-mode-line 'summary)
8988 (defun gnus-summary-pipe-output (&optional arg)
8989 "Pipe the current article to a subprocess.
8990 If N is a positive number, pipe the N next articles.
8991 If N is a negative number, pipe the N previous articles.
8992 If N is nil and any articles have been marked with the process mark,
8993 pipe those articles instead."
8995 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8996 (gnus-summary-save-article arg t))
8997 (gnus-configure-windows 'pipe))
8999 (defun gnus-summary-save-article-mail (&optional arg)
9000 "Append the current article to an mail file.
9001 If N is a positive number, save the N next articles.
9002 If N is a negative number, save the N previous articles.
9003 If N is nil and any articles have been marked with the process mark,
9004 save those articles instead."
9006 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9007 (gnus-summary-save-article arg)))
9009 (defun gnus-summary-save-article-rmail (&optional arg)
9010 "Append the current article to an rmail file.
9011 If N is a positive number, save the N next articles.
9012 If N is a negative number, save the N previous articles.
9013 If N is nil and any articles have been marked with the process mark,
9014 save those articles instead."
9016 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
9017 (gnus-summary-save-article arg)))
9019 (defun gnus-summary-save-article-file (&optional arg)
9020 "Append the current article to a file.
9021 If N is a positive number, save the N next articles.
9022 If N is a negative number, save the N previous articles.
9023 If N is nil and any articles have been marked with the process mark,
9024 save those articles instead."
9026 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9027 (gnus-summary-save-article arg)))
9029 (defun gnus-summary-write-article-file (&optional arg)
9030 "Write the current article to a file, deleting the previous file.
9031 If N is a positive number, save the N next articles.
9032 If N is a negative number, save the N previous articles.
9033 If N is nil and any articles have been marked with the process mark,
9034 save those articles instead."
9036 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9037 (gnus-summary-save-article arg)))
9039 (defun gnus-summary-save-article-body-file (&optional arg)
9040 "Append the current article body to a file.
9041 If N is a positive number, save the N next articles.
9042 If N is a negative number, save the N previous articles.
9043 If N is nil and any articles have been marked with the process mark,
9044 save those articles instead."
9046 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9047 (gnus-summary-save-article arg)))
9049 (defun gnus-summary-pipe-message (program)
9050 "Pipe the current article through PROGRAM."
9051 (interactive "sProgram: ")
9052 (gnus-summary-select-article)
9053 (let ((mail-header-separator ""))
9054 (gnus-eval-in-buffer-window gnus-article-buffer
9057 (let ((start (window-start))
9059 (message-pipe-buffer-body program)
9060 (set-window-start (get-buffer-window (current-buffer)) start))))))
9062 (defun gnus-get-split-value (methods)
9063 "Return a value based on the split METHODS."
9064 (let (split-name method result match)
9067 (set-buffer gnus-original-article-buffer)
9069 (nnheader-narrow-to-headers)
9071 (goto-char (point-min))
9072 (setq method (pop methods))
9073 (setq match (car method))
9076 ;; Regular expression.
9078 (re-search-forward match nil t)))
9079 ((gnus-functionp match)
9083 (setq result (funcall match gnus-newsgroup-name))))
9088 (setq result (eval match)))))
9089 (setq split-name (append (cdr method) split-name))
9090 (cond ((stringp result)
9091 (push (expand-file-name
9092 result gnus-article-save-directory)
9095 (setq split-name (append result split-name)))))))))
9096 (nreverse split-name)))
9098 (defun gnus-valid-move-group-p (group)
9101 (symbol-value group)
9102 (gnus-get-function (gnus-find-method-for-group
9103 (symbol-name group)) 'request-accept-article t)))
9105 (defun gnus-read-move-group-name (prompt default articles prefix)
9106 "Read a group name."
9107 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9108 (minibuffer-confirm-incomplete nil) ; XEmacs
9112 (if (> (length articles) 1)
9113 (format "these %d articles" (length articles))
9118 (gnus-completing-read default prom
9120 'gnus-valid-move-group-p
9122 'gnus-group-history))
9123 ((= 1 (length split-name))
9124 (gnus-completing-read (car split-name) prom
9126 'gnus-valid-move-group-p
9128 'gnus-group-history))
9130 (gnus-completing-read nil prom
9131 (mapcar (lambda (el) (list el))
9132 (nreverse split-name))
9134 'gnus-group-history))))
9135 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9137 (if (or (string= to-newsgroup "")
9138 (string= to-newsgroup prefix))
9139 (setq to-newsgroup default))
9140 (unless to-newsgroup
9141 (error "No group name entered"))
9142 (or (gnus-active to-newsgroup)
9143 (gnus-activate-group to-newsgroup nil nil to-method)
9144 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9146 (or (and (gnus-request-create-group to-newsgroup to-method)
9147 (gnus-activate-group
9148 to-newsgroup nil nil to-method)
9149 (gnus-subscribe-group to-newsgroup))
9150 (error "Couldn't create group %s" to-newsgroup)))
9151 (error "No such group: %s" to-newsgroup)))
9154 (defun gnus-summary-save-parts (type dir n &optional reverse)
9155 "Save parts matching TYPE to DIR.
9156 If REVERSE, save parts that do not match TYPE."
9158 (list (read-string "Save parts of type: " "image/.*")
9159 (read-file-name "Save to directory: " nil nil t)
9160 current-prefix-arg))
9161 (gnus-summary-iterate n
9162 (let ((gnus-display-mime-function nil)
9163 (gnus-inhibit-treatment t))
9164 (gnus-summary-select-article))
9166 (set-buffer gnus-article-buffer)
9167 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9169 (gnus-summary-save-parts-1 type dir handles reverse)
9170 (mm-destroy-parts handles))))))
9172 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9173 (if (stringp (car handle))
9174 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9177 (not (string-match type (mm-handle-media-type handle)))
9178 (string-match type (mm-handle-media-type handle)))
9179 (let ((file (expand-file-name
9180 (file-name-nondirectory
9182 (mail-content-type-get
9183 (mm-handle-disposition handle) 'filename)
9184 (concat gnus-newsgroup-name "." gnus-current-article)))
9186 (unless (file-exists-p file)
9187 (mm-save-part-to-file handle file))))))
9189 ;; Summary extract commands
9191 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9192 (let ((buffer-read-only nil)
9193 (article (gnus-summary-article-number))
9195 (unless (gnus-summary-goto-subject article)
9196 (error "No such article: %d" article))
9197 (gnus-summary-position-point)
9198 ;; If all commands are to be bunched up on one line, we collect
9200 (unless gnus-view-pseudos-separately
9201 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9204 (setq action (cdr (assq 'action (car ps))))
9205 (setq files (list (cdr (assq 'name (car ps)))))
9206 (while (and ps (cdr ps)
9207 (string= (or action "1")
9208 (or (cdr (assq 'action (cadr ps))) "2")))
9209 (push (cdr (assq 'name (cadr ps))) files)
9210 (setcdr ps (cddr ps)))
9212 (when (not (string-match "%s" action))
9215 (when (assq 'execute (car ps))
9216 (setcdr (assq 'execute (car ps))
9217 (funcall (if (string-match "%s" action)
9226 (setq ps (cdr ps)))))
9227 (if (and gnus-view-pseudos (not not-view))
9229 (when (assq 'execute (car pslist))
9230 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9231 (eq gnus-view-pseudos 'not-confirm)))
9232 (setq pslist (cdr pslist)))
9235 (setq after-article (or (cdr (assq 'article (car pslist)))
9236 (gnus-summary-article-number)))
9237 (gnus-summary-goto-subject after-article)
9240 (insert " " (file-name-nondirectory
9241 (cdr (assq 'name (car pslist))))
9242 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9244 (forward-line -1) ; back to `b'
9245 (gnus-add-text-properties
9246 b (1- e) (list 'gnus-number gnus-reffed-article-number
9247 gnus-mouse-face-prop gnus-mouse-face))
9249 after-article gnus-reffed-article-number
9250 gnus-unread-mark b (car pslist) 0 (- e b))
9251 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9252 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9253 (setq pslist (cdr pslist)))))))
9255 (defun gnus-pseudos< (p1 p2)
9256 (let ((c1 (cdr (assq 'action p1)))
9257 (c2 (cdr (assq 'action p2))))
9258 (and c1 c2 (string< c1 c2))))
9260 (defun gnus-request-pseudo-article (props)
9261 (cond ((assq 'execute props)
9262 (gnus-execute-command (cdr (assq 'execute props)))))
9263 (let ((gnus-current-article (gnus-summary-article-number)))
9264 (gnus-run-hooks 'gnus-mark-article-hook)))
9266 (defun gnus-execute-command (command &optional automatic)
9268 (gnus-article-setup-buffer)
9269 (set-buffer gnus-article-buffer)
9270 (setq buffer-read-only nil)
9271 (let ((command (if automatic command
9272 (read-string "Command: " (cons command 0)))))
9274 (insert "$ " command "\n\n")
9275 (if gnus-view-pseudo-asynchronously
9276 (start-process "gnus-execute" (current-buffer) shell-file-name
9277 shell-command-switch command)
9278 (call-process shell-file-name nil t nil
9279 shell-command-switch command)))))
9281 ;; Summary kill commands.
9283 (defun gnus-summary-edit-global-kill (article)
9284 "Edit the \"global\" kill file."
9285 (interactive (list (gnus-summary-article-number)))
9286 (gnus-group-edit-global-kill article))
9288 (defun gnus-summary-edit-local-kill ()
9289 "Edit a local kill file applied to the current newsgroup."
9291 (setq gnus-current-headers (gnus-summary-article-header))
9292 (gnus-group-edit-local-kill
9293 (gnus-summary-article-number) gnus-newsgroup-name))
9297 (defun gnus-read-header (id &optional header)
9298 "Read the headers of article ID and enter them into the Gnus system."
9299 (let ((group gnus-newsgroup-name)
9300 (gnus-override-method
9302 gnus-override-method
9303 (and (gnus-news-group-p gnus-newsgroup-name)
9304 (car (gnus-refer-article-methods)))))
9306 ;; First we check to see whether the header in question is already
9309 ;; This is a Message-ID.
9310 (setq header (or header (gnus-id-to-header id)))
9311 ;; This is an article number.
9312 (setq header (or header (gnus-summary-article-header id))))
9314 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9315 ;; We have found the header.
9317 ;; If this is a sparse article, we have to nix out its
9318 ;; previous entry in the thread hashtb.
9320 (gnus-summary-article-sparse-p (mail-header-number header)))
9321 (let* ((parent (gnus-parent-id (mail-header-references header)))
9322 (thread (and parent (gnus-id-to-thread parent))))
9324 (delq (assq header thread) thread))))
9325 ;; We have to really fetch the header to this article.
9327 (set-buffer nntp-server-buffer)
9328 (when (setq where (gnus-request-head id group))
9329 (nnheader-fold-continuation-lines)
9330 (goto-char (point-max))
9332 (goto-char (point-min))
9336 ((cdr where) (cdr where))
9337 (header (mail-header-number header))
9338 (t gnus-reffed-article-number))
9340 (insert " Article retrieved.\n"))
9342 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9343 () ; Malformed head.
9344 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9345 (when (and (stringp id)
9346 (not (string= (gnus-group-real-name group)
9348 ;; If we fetched by Message-ID and the article came
9349 ;; from a different group, we fudge some bogus article
9350 ;; numbers for this article.
9351 (mail-header-set-number header gnus-reffed-article-number))
9353 (set-buffer gnus-summary-buffer)
9354 (decf gnus-reffed-article-number)
9355 (gnus-remove-header (mail-header-number header))
9356 (push header gnus-newsgroup-headers)
9357 (setq gnus-current-headers header)
9358 (push (mail-header-number header) gnus-newsgroup-limit)))
9361 (defun gnus-remove-header (number)
9362 "Remove header NUMBER from `gnus-newsgroup-headers'."
9363 (if (and gnus-newsgroup-headers
9364 (= number (mail-header-number (car gnus-newsgroup-headers))))
9365 (pop gnus-newsgroup-headers)
9366 (let ((headers gnus-newsgroup-headers))
9367 (while (and (cdr headers)
9368 (not (= number (mail-header-number (cadr headers)))))
9371 (setcdr headers (cddr headers))))))
9374 ;;; summary highlights
9377 (defun gnus-highlight-selected-summary ()
9378 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9379 ;; Highlight selected article in summary buffer
9380 (when gnus-summary-selected-face
9382 (let* ((beg (progn (beginning-of-line) (point)))
9383 (end (progn (end-of-line) (point)))
9384 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9385 (from (if (get-text-property beg gnus-mouse-face-prop)
9387 (or (next-single-property-change
9388 beg gnus-mouse-face-prop nil end)
9393 (or (next-single-property-change
9394 from gnus-mouse-face-prop nil end)
9396 ;; If no mouse-face prop on line we will have to = from = end,
9397 ;; so we highlight the entire line instead.
9398 (when (= (+ to 2) from)
9401 (if gnus-newsgroup-selected-overlay
9402 ;; Move old overlay.
9404 gnus-newsgroup-selected-overlay from to (current-buffer))
9405 ;; Create new overlay.
9407 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9408 'face gnus-summary-selected-face))))))
9410 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9411 (defun gnus-summary-highlight-line ()
9412 "Highlight current line according to `gnus-summary-highlight'."
9413 (let* ((list gnus-summary-highlight)
9415 (end (progn (end-of-line) (point)))
9416 ;; now find out where the line starts and leave point there.
9417 (beg (progn (beginning-of-line) (point)))
9418 (article (gnus-summary-article-number))
9419 (score (or (cdr (assq (or article gnus-current-article)
9420 gnus-newsgroup-scored))
9421 gnus-summary-default-score 0))
9422 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9423 (inhibit-read-only t))
9424 ;; Eval the cars of the lists until we find a match.
9425 (let ((default gnus-summary-default-score))
9427 (not (eval (caar list))))
9428 (setq list (cdr list))))
9429 (let ((face (cdar list)))
9430 (unless (eq face (get-text-property beg 'face))
9431 (gnus-put-text-property-excluding-characters-with-faces
9433 (setq face (if (boundp face) (symbol-value face) face)))
9434 (when gnus-summary-highlight-line-function
9435 (funcall gnus-summary-highlight-line-function article face))))
9438 (defun gnus-update-read-articles (group unread &optional compute)
9439 "Update the list of read articles in GROUP."
9440 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9441 (entry (gnus-gethash group gnus-newsrc-hashtb))
9442 (info (nth 2 entry))
9444 (unread (sort (copy-sequence unread) '<))
9446 (if (or (not info) (not active))
9447 ;; There is no info on this group if it was, in fact,
9448 ;; killed. Gnus stores no information on killed groups, so
9449 ;; there's nothing to be done.
9450 ;; One could store the information somewhere temporarily,
9451 ;; perhaps... Hmmm...
9453 ;; Remove any negative articles numbers.
9454 (while (and unread (< (car unread) 0))
9455 (setq unread (cdr unread)))
9456 ;; Remove any expired article numbers
9457 (while (and unread (< (car unread) (car active)))
9458 (setq unread (cdr unread)))
9459 ;; Compute the ranges of read articles by looking at the list of
9462 (when (/= (car unread) prev)
9463 (push (if (= prev (1- (car unread))) prev
9464 (cons prev (1- (car unread))))
9466 (setq prev (1+ (car unread)))
9467 (setq unread (cdr unread)))
9468 (when (<= prev (cdr active))
9469 (push (cons prev (cdr active)) read))
9470 (setq read (if (> (length read) 1) (nreverse read) read))
9474 (set-buffer gnus-group-buffer)
9477 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9478 (gnus-info-set-read ',info ',(gnus-info-read info))
9479 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9480 (gnus-group-update-group ,group t))))
9481 ;; Propagate the read marks to the backend.
9482 (if (gnus-check-backend-function 'request-set-mark group)
9483 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9484 (add (gnus-remove-from-range read (gnus-info-read info))))
9486 (unless (gnus-check-group group)
9487 (error "Can't open server for %s" group))
9488 (gnus-request-set-mark
9489 group (delq nil (list (if add (list add 'add '(read)))
9490 (if del (list del 'del '(read)))))))))
9491 ;; Enter this list into the group info.
9492 (gnus-info-set-read info read)
9493 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9494 (gnus-get-unread-articles-in-group info (gnus-active group))
9497 (defun gnus-offer-save-summaries ()
9498 "Offer to save all active summary buffers."
9500 (let ((buflist (buffer-list))
9502 ;; Go through all buffers and find all summaries.
9504 (and (setq bufname (buffer-name (car buflist)))
9505 (string-match "Summary" bufname)
9507 (set-buffer bufname)
9508 ;; We check that this is, indeed, a summary buffer.
9509 (and (eq major-mode 'gnus-summary-mode)
9510 ;; Also make sure this isn't bogus.
9511 gnus-newsgroup-prepared
9512 ;; Also make sure that this isn't a dead summary buffer.
9513 (not gnus-dead-summary-mode)))
9514 (push bufname buffers))
9515 (setq buflist (cdr buflist)))
9516 ;; Go through all these summary buffers and offer to save them.
9519 "Update summary buffer %s? "
9521 (switch-to-buffer buf)
9522 (gnus-summary-exit))
9525 (defun gnus-summary-setup-default-charset ()
9526 "Setup newsgroup default charset."
9527 (if (equal gnus-newsgroup-name "nndraft:drafts")
9528 (setq gnus-newsgroup-charset nil)
9529 (let* ((name (and gnus-newsgroup-name
9530 (gnus-group-real-name gnus-newsgroup-name)))
9532 (or gnus-newsgroup-ephemeral-ignored-charsets
9534 (and gnus-newsgroup-name
9535 (or (gnus-group-find-parameter gnus-newsgroup-name
9536 'ignored-charsets t)
9537 (let ((alist gnus-group-ignored-charsets-alist)
9538 elem (charsets nil))
9539 (while (setq elem (pop alist))
9541 (string-match (car elem) name))
9543 charsets (cdr elem))))
9545 gnus-newsgroup-ignored-charsets))))
9546 (setq gnus-newsgroup-charset
9547 (or gnus-newsgroup-ephemeral-charset
9548 (and gnus-newsgroup-name
9549 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9550 (let ((alist gnus-group-charset-alist)
9552 (while (setq elem (pop alist))
9554 (string-match (car elem) name))
9556 charset (cadr elem))))
9558 gnus-default-charset))
9559 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9560 ignored-charsets))))
9566 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9567 "Display the current article buffer fully MIME-buttonized.
9568 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9569 treated as multipart/mixed."
9572 (let ((gnus-unbuttonized-mime-types nil)
9573 (gnus-mime-display-multipart-as-mixed show-all-parts))
9574 (gnus-summary-show-article)))
9576 (defun gnus-summary-repair-multipart (article)
9577 "Add a Content-Type header to a multipart article without one."
9578 (interactive (list (gnus-summary-article-number)))
9579 (gnus-with-article article
9580 (message-narrow-to-head)
9581 (goto-char (point-max))
9583 (when (search-forward "\n--" nil t)
9584 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9585 (message-narrow-to-head)
9586 (message-remove-header "Mime-Version")
9587 (message-remove-header "Content-Type")
9588 (goto-char (point-max))
9589 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9591 (insert "Mime-Version: 1.0\n")
9593 (let (gnus-mark-article-hook)
9594 (gnus-summary-select-article t t nil article)))
9596 (defun gnus-summary-toggle-display-buttonized ()
9597 "Toggle the buttonizing of the article buffer."
9600 (if (setq gnus-inhibit-mime-unbuttonizing
9601 (not gnus-inhibit-mime-unbuttonizing))
9602 (let ((gnus-unbuttonized-mime-types nil))
9603 (gnus-summary-show-article))
9604 (gnus-summary-show-article)))
9607 ;;; Generic summary marking commands
9610 (defvar gnus-summary-marking-alist
9611 '((read gnus-del-mark "d")
9612 (unread gnus-unread-mark "u")
9613 (ticked gnus-ticked-mark "!")
9614 (dormant gnus-dormant-mark "?")
9615 (expirable gnus-expirable-mark "e"))
9616 "An alist of names/marks/keystrokes.")
9618 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9619 (defvar gnus-summary-mark-map)
9621 (defun gnus-summary-make-all-marking-commands ()
9622 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9623 (dolist (elem gnus-summary-marking-alist)
9624 (apply 'gnus-summary-make-marking-command elem)))
9626 (defun gnus-summary-make-marking-command (name mark keystroke)
9627 (let ((map (make-sparse-keymap)))
9628 (define-key gnus-summary-generic-mark-map keystroke map)
9629 (dolist (lway `((next "next" next nil "n")
9630 (next-unread "next unread" next t "N")
9631 (prev "previous" prev nil "p")
9632 (prev-unread "previous unread" prev t "P")
9633 (nomove "" nil nil ,keystroke)))
9634 (let ((func (gnus-summary-make-marking-command-1
9635 mark (car lway) lway name)))
9636 (setq func (eval func))
9637 (define-key map (nth 4 lway) func)))))
9639 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9641 (format "gnus-summary-put-mark-as-%s%s"
9642 name (if (eq way 'nomove)
9644 (concat "-" (symbol-name way)))))
9647 "Mark the current article as %s%s.
9648 If N, the prefix, then repeat N times.
9649 If N is negative, move in reverse order.
9650 The difference between N and the actual number of articles marked is
9654 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9656 (defun gnus-summary-generic-mark (n mark move unread)
9657 "Mark N articles with MARK."
9658 (unless (eq major-mode 'gnus-summary-mode)
9659 (error "This command can only be used in the summary buffer"))
9660 (gnus-summary-show-thread)
9664 ((eq move 'prev) -1)
9670 nummove (* -1 nummove))))
9672 (gnus-summary-mark-article nil mark)
9673 (zerop (gnus-summary-next-subject nummove unread t)))
9676 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9677 (gnus-summary-recenter)
9678 (gnus-summary-position-point)
9679 (gnus-set-mode-line 'summary)
9682 (gnus-summary-make-all-marking-commands)
9688 (run-hooks 'gnus-sum-load-hook)
9690 ;;; gnus-sum.el ends here