1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
47 (autoload 'gnus-cache-articles-in-group "gnus-cache")
48 (autoload 'pgg-decrypt-region "pgg" nil t)
49 (autoload 'pgg-verify-region "pgg" nil t))
51 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
52 (autoload 'gnus-cache-write-active "gnus-cache")
53 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
55 (defcustom gnus-kill-summary-on-exit t
56 "*If non-nil, kill the summary buffer when you exit from it.
57 If nil, the summary will become a \"*Dead Summary*\" buffer, and
58 it will be killed sometime later."
59 :group 'gnus-summary-exit
62 (defcustom gnus-fetch-old-headers nil
63 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
64 If an unread article in the group refers to an older, already read (or
65 just marked as read) article, the old article will not normally be
66 displayed in the Summary buffer. If this variable is non-nil, Gnus
67 will attempt to grab the headers to the old articles, and thereby
68 build complete threads. If it has the value `some', only enough
69 headers to connect otherwise loose threads will be displayed. This
70 variable can also be a number. In that case, no more than that number
71 of old headers will be fetched. If it has the value `invisible', all
72 old headers will be fetched, but none will be displayed.
74 The server has to support NOV for any of this to work."
76 :type '(choice (const :tag "off" nil)
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-refer-thread-limit 200
82 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
83 If t, fetch all the available old headers."
86 (sexp :menu-tag "other" t)))
88 (defcustom gnus-summary-make-false-root 'adopt
89 "*nil means that Gnus won't gather loose threads.
90 If the root of a thread has expired or been read in a previous
91 session, the information necessary to build a complete thread has been
92 lost. Instead of having many small sub-threads from this original thread
93 scattered all over the summary buffer, Gnus can gather them.
95 If non-nil, Gnus will try to gather all loose sub-threads from an
96 original thread into one large thread.
98 If this variable is non-nil, it should be one of `none', `adopt',
101 If this variable is `none', Gnus will not make a false root, but just
102 present the sub-threads after another.
103 If this variable is `dummy', Gnus will create a dummy root that will
104 have all the sub-threads as children.
105 If this variable is `adopt', Gnus will make one of the \"children\"
106 the parent and mark all the step-children as such.
107 If this variable is `empty', the \"children\" are printed with empty
108 subject fields. (Or rather, they will be printed with a string
109 given by the `gnus-summary-same-subject' variable.)"
111 :type '(choice (const :tag "off" nil)
117 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
118 "*A regexp to match subjects to be excluded from loose thread gathering.
119 As loose thread gathering is done on subjects only, that means that
120 there can be many false gatherings performed. By rooting out certain
121 common subjects, gathering might become saner."
125 (defcustom gnus-summary-gather-subject-limit nil
126 "*Maximum length of subject comparisons when gathering loose threads.
127 Use nil to compare full subjects. Setting this variable to a low
128 number will help gather threads that have been corrupted by
129 newsreaders chopping off subject lines, but it might also mean that
130 unrelated articles that have subject that happen to begin with the
131 same few characters will be incorrectly gathered.
133 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
136 :type '(choice (const :tag "off" nil)
138 (sexp :menu-tag "on" t)))
140 (defcustom gnus-simplify-subject-functions nil
141 "List of functions taking a string argument that simplify subjects.
142 The functions are applied recursively.
144 Useful functions to put in this list include: `gnus-simplify-subject-re',
145 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
147 :type '(repeat function))
149 (defcustom gnus-simplify-ignored-prefixes nil
150 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
152 :type '(choice (const :tag "off" nil)
155 (defcustom gnus-build-sparse-threads nil
156 "*If non-nil, fill in the gaps in threads.
157 If `some', only fill in the gaps that are needed to tie loose threads
158 together. If `more', fill in all leaf nodes that Gnus can find. If
159 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
161 :type '(choice (const :tag "off" nil)
164 (sexp :menu-tag "all" t)))
166 (defcustom gnus-summary-thread-gathering-function
167 'gnus-gather-threads-by-subject
168 "*Function used for gathering loose threads.
169 There are two pre-defined functions: `gnus-gather-threads-by-subject',
170 which only takes Subjects into consideration; and
171 `gnus-gather-threads-by-references', which compared the References
172 headers of the articles to find matches."
174 :type '(radio (function-item gnus-gather-threads-by-subject)
175 (function-item gnus-gather-threads-by-references)
176 (function :tag "other")))
178 (defcustom gnus-summary-same-subject ""
179 "*String indicating that the current article has the same subject as the previous.
180 This variable will only be used if the value of
181 `gnus-summary-make-false-root' is `empty'."
182 :group 'gnus-summary-format
185 (defcustom gnus-summary-goto-unread t
186 "*If t, many commands will go to the next unread article.
187 This applies to marking commands as well as other commands that
188 \"naturally\" select the next article, like, for instance, `SPC' at
189 the end of an article.
191 If nil, the marking commands do NOT go to the next unread article
192 (they go to the next article instead). If `never', commands that
193 usually go to the next unread article, will go to the next article,
194 whether it is read or not."
195 :group 'gnus-summary-marks
196 :link '(custom-manual "(gnus)Setting Marks")
197 :type '(choice (const :tag "off" nil)
199 (sexp :menu-tag "on" t)))
201 (defcustom gnus-summary-default-score 0
202 "*Default article score level.
203 All scores generated by the score files will be added to this score.
204 If this variable is nil, scoring will be disabled."
205 :group 'gnus-score-default
206 :type '(choice (const :tag "disable")
209 (defcustom gnus-summary-zcore-fuzz 0
210 "*Fuzziness factor for the zcore in the summary buffer.
211 Articles with scores closer than this to `gnus-summary-default-score'
213 :group 'gnus-summary-format
216 (defcustom gnus-simplify-subject-fuzzy-regexp nil
217 "*Strings to be removed when doing fuzzy matches.
218 This can either be a regular expression or list of regular expressions
219 that will be removed from subject strings if fuzzy subject
220 simplification is selected."
222 :type '(repeat regexp))
224 (defcustom gnus-show-threads t
225 "*If non-nil, display threads in summary mode."
229 (defcustom gnus-thread-hide-subtree nil
230 "*If non-nil, hide all threads initially.
231 If threads are hidden, you have to run the command
232 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
233 to expose hidden threads."
237 (defcustom gnus-thread-hide-killed t
238 "*If non-nil, hide killed threads automatically."
242 (defcustom gnus-thread-ignore-subject t
243 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
244 If nil, articles that have different subjects from their parents will
245 start separate threads."
249 (defcustom gnus-thread-operation-ignore-subject t
250 "*If non-nil, subjects will be ignored when doing thread commands.
251 This affects commands like `gnus-summary-kill-thread' and
252 `gnus-summary-lower-thread'.
254 If this variable is nil, articles in the same thread with different
255 subjects will not be included in the operation in question. If this
256 variable is `fuzzy', only articles that have subjects that are fuzzily
257 equal will be included."
259 :type '(choice (const :tag "off" nil)
263 (defcustom gnus-thread-indent-level 4
264 "*Number that says how much each sub-thread should be indented."
268 (defcustom gnus-auto-extend-newsgroup t
269 "*If non-nil, extend newsgroup forward and backward when requested."
270 :group 'gnus-summary-choose
273 (defcustom gnus-auto-select-first t
274 "*If nil, don't select the first unread article when entering a group.
275 If this variable is `best', select the highest-scored unread article
276 in the group. If t, select the first unread article.
278 This variable can also be a function to place point on a likely
279 subject line. Useful values include `gnus-summary-first-unread-subject',
280 `gnus-summary-first-unread-article' and
281 `gnus-summary-best-unread-article'.
283 If you want to prevent automatic selection of the first unread article
284 in some newsgroups, set the variable to nil in
285 `gnus-select-group-hook'."
286 :group 'gnus-group-select
287 :type '(choice (const :tag "none" nil)
289 (sexp :menu-tag "first" t)
290 (function-item gnus-summary-first-unread-subject)
291 (function-item gnus-summary-first-unread-article)
292 (function-item gnus-summary-best-unread-article)))
294 (defcustom gnus-dont-select-after-jump-to-other-group nil
295 "If non-nil, don't select the first unread article after entering the
296 other group by the command `gnus-summary-jump-to-other-group'. If nil,
297 it is depend on the value of `gnus-auto-select-first' whether to select
299 :group 'gnus-group-select
302 (defcustom gnus-auto-select-next t
303 "*If non-nil, offer to go to the next group from the end of the previous.
304 If the value is t and the next newsgroup is empty, Gnus will exit
305 summary mode and go back to group mode. If the value is neither nil
306 nor t, Gnus will select the following unread newsgroup. In
307 particular, if the value is the symbol `quietly', the next unread
308 newsgroup will be selected without any confirmation, and if it is
309 `almost-quietly', the next group will be selected without any
310 confirmation if you are located on the last article in the group.
311 Finally, if this variable is `slightly-quietly', the `Z n' command
312 will go to the next group without confirmation."
313 :group 'gnus-summary-maneuvering
314 :type '(choice (const :tag "off" nil)
316 (const almost-quietly)
317 (const slightly-quietly)
318 (sexp :menu-tag "on" t)))
320 (defcustom gnus-auto-select-same nil
321 "*If non-nil, select the next article with the same subject.
322 If there are no more articles with the same subject, go to
323 the first unread article."
324 :group 'gnus-summary-maneuvering
327 (defcustom gnus-summary-check-current nil
328 "*If non-nil, consider the current article when moving.
329 The \"unread\" movement commands will stay on the same line if the
330 current article is unread."
331 :group 'gnus-summary-maneuvering
334 (defcustom gnus-auto-center-summary t
335 "*If non-nil, always center the current summary buffer.
336 In particular, if `vertical' do only vertical recentering. If non-nil
337 and non-`vertical', do both horizontal and vertical recentering."
338 :group 'gnus-summary-maneuvering
339 :type '(choice (const :tag "none" nil)
341 (integer :tag "height")
342 (sexp :menu-tag "both" t)))
344 (defcustom gnus-show-all-headers nil
345 "*If non-nil, don't hide any headers."
346 :group 'gnus-article-hiding
347 :group 'gnus-article-headers
350 (defcustom gnus-summary-ignore-duplicates nil
351 "*If non-nil, ignore articles with identical Message-ID headers."
355 (defcustom gnus-single-article-buffer t
356 "*If non-nil, display all articles in the same buffer.
357 If nil, each group will get its own article buffer."
358 :group 'gnus-article-various
361 (defcustom gnus-break-pages t
362 "*If non-nil, do page breaking on articles.
363 The page delimiter is specified by the `gnus-page-delimiter'
365 :group 'gnus-article-various
368 (defcustom gnus-show-mime t
369 "*If non-nil, do mime processing of articles.
370 The articles will simply be fed to the function given by
371 `gnus-article-display-method-for-mime'."
372 :group 'gnus-article-mime
375 (defcustom gnus-move-split-methods nil
376 "*Variable used to suggest where articles are to be moved to.
377 It uses the same syntax as the `gnus-split-methods' variable."
378 :group 'gnus-summary-mail
379 :type '(repeat (choice (list :value (fun) function)
380 (cons :value ("" "") regexp (repeat string))
383 (defcustom gnus-unread-mark ? ;Whitespace
384 "*Mark used for unread articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-ticked-mark ?!
389 "*Mark used for ticked articles."
390 :group 'gnus-summary-marks
393 (defcustom gnus-dormant-mark ??
394 "*Mark used for dormant articles."
395 :group 'gnus-summary-marks
398 (defcustom gnus-del-mark ?r
399 "*Mark used for del'd articles."
400 :group 'gnus-summary-marks
403 (defcustom gnus-read-mark ?R
404 "*Mark used for read articles."
405 :group 'gnus-summary-marks
408 (defcustom gnus-expirable-mark ?E
409 "*Mark used for expirable articles."
410 :group 'gnus-summary-marks
413 (defcustom gnus-killed-mark ?K
414 "*Mark used for killed articles."
415 :group 'gnus-summary-marks
418 (defcustom gnus-souped-mark ?F
419 "*Mark used for killed articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-kill-file-mark ?X
424 "*Mark used for articles killed by kill files."
425 :group 'gnus-summary-marks
428 (defcustom gnus-low-score-mark ?Y
429 "*Mark used for articles with a low score."
430 :group 'gnus-summary-marks
433 (defcustom gnus-catchup-mark ?C
434 "*Mark used for articles that are caught up."
435 :group 'gnus-summary-marks
438 (defcustom gnus-replied-mark ?A
439 "*Mark used for articles that have been replied to."
440 :group 'gnus-summary-marks
443 (defcustom gnus-cached-mark ?*
444 "*Mark used for articles that are in the cache."
445 :group 'gnus-summary-marks
448 (defcustom gnus-saved-mark ?S
449 "*Mark used for articles that have been saved to."
450 :group 'gnus-summary-marks
453 (defcustom gnus-ancient-mark ?O
454 "*Mark used for ancient articles."
455 :group 'gnus-summary-marks
458 (defcustom gnus-sparse-mark ?Q
459 "*Mark used for sparsely reffed articles."
460 :group 'gnus-summary-marks
463 (defcustom gnus-canceled-mark ?G
464 "*Mark used for canceled articles."
465 :group 'gnus-summary-marks
468 (defcustom gnus-duplicate-mark ?M
469 "*Mark used for duplicate articles."
470 :group 'gnus-summary-marks
473 (defcustom gnus-undownloaded-mark ?@
474 "*Mark used for articles that weren't downloaded."
475 :group 'gnus-summary-marks
478 (defcustom gnus-downloadable-mark ?%
479 "*Mark used for articles that are to be downloaded."
480 :group 'gnus-summary-marks
483 (defcustom gnus-unsendable-mark ?=
484 "*Mark used for articles that won't be sent."
485 :group 'gnus-summary-marks
488 (defcustom gnus-score-over-mark ?+
489 "*Score mark used for articles with high scores."
490 :group 'gnus-summary-marks
493 (defcustom gnus-score-below-mark ?-
494 "*Score mark used for articles with low scores."
495 :group 'gnus-summary-marks
498 (defcustom gnus-empty-thread-mark ? ;Whitespace
499 "*There is no thread under the article."
500 :group 'gnus-summary-marks
503 (defcustom gnus-not-empty-thread-mark ?=
504 "*There is a thread under the article."
505 :group 'gnus-summary-marks
508 (defcustom gnus-view-pseudo-asynchronously nil
509 "*If non-nil, Gnus will view pseudo-articles asynchronously."
510 :group 'gnus-extract-view
513 (defcustom gnus-auto-expirable-marks
514 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
515 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
516 gnus-souped-mark gnus-duplicate-mark)
517 "*The list of marks converted into expiration if a group is auto-expirable."
519 :type '(repeat character))
521 (defcustom gnus-inhibit-user-auto-expire t
522 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
526 (defcustom gnus-view-pseudos nil
527 "*If `automatic', pseudo-articles will be viewed automatically.
528 If `not-confirm', pseudos will be viewed automatically, and the user
529 will not be asked to confirm the command."
530 :group 'gnus-extract-view
531 :type '(choice (const :tag "off" nil)
533 (const not-confirm)))
535 (defcustom gnus-view-pseudos-separately t
536 "*If non-nil, one pseudo-article will be created for each file to be viewed.
537 If nil, all files that use the same viewing command will be given as a
538 list of parameters to that command."
539 :group 'gnus-extract-view
542 (defcustom gnus-insert-pseudo-articles t
543 "*If non-nil, insert pseudo-articles when decoding articles."
544 :group 'gnus-extract-view
547 (defcustom gnus-summary-dummy-line-format
549 "*The format specification for the dummy roots in the summary buffer.
550 It works along the same lines as a normal formatting string,
551 with some simple extensions.
554 :group 'gnus-threading
557 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
558 "*The format specification for the summary mode line.
559 It works along the same lines as a normal formatting string,
560 with some simple extensions:
563 %p Unprefixed group name
564 %A Current article number
565 %z Current article score
567 %U Number of unread articles in the group
568 %e Number of unselected articles in the group
569 %Z A string with unread/unselected article counts
570 %g Shortish group name
571 %S Subject of the current article
573 %s Current score file name
574 %d Number of dormant articles
575 %r Number of articles that have been marked as read in this session
576 %E Number of articles expunged by the score files"
577 :group 'gnus-summary-format
580 (defcustom gnus-list-identifiers nil
581 "Regexp that matches list identifiers to be removed from subject.
582 This can also be a list of regexps."
583 :group 'gnus-summary-format
584 :group 'gnus-article-hiding
585 :type '(choice (const :tag "none" nil)
587 (repeat :value (".*") regexp)))
589 (defcustom gnus-summary-mark-below 0
590 "*Mark all articles with a score below this variable as read.
591 This variable is local to each summary buffer and usually set by the
593 :group 'gnus-score-default
596 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
597 "*List of functions used for sorting articles in the summary buffer.
598 This variable is only used when not using a threaded display."
599 :group 'gnus-summary-sort
600 :type '(repeat (choice (function-item gnus-article-sort-by-number)
601 (function-item gnus-article-sort-by-author)
602 (function-item gnus-article-sort-by-subject)
603 (function-item gnus-article-sort-by-date)
604 (function-item gnus-article-sort-by-score)
605 (function :tag "other"))))
607 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
608 "*List of functions used for sorting threads in the summary buffer.
609 By default, threads are sorted by article number.
611 Each function takes two threads and return non-nil if the first thread
612 should be sorted before the other. If you use more than one function,
613 the primary sort function should be the last. You should probably
614 always include `gnus-thread-sort-by-number' in the list of sorting
615 functions -- preferably first.
617 Ready-made functions include `gnus-thread-sort-by-number',
618 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
619 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
620 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
621 :group 'gnus-summary-sort
622 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
623 (function-item gnus-thread-sort-by-author)
624 (function-item gnus-thread-sort-by-subject)
625 (function-item gnus-thread-sort-by-date)
626 (function-item gnus-thread-sort-by-score)
627 (function-item gnus-thread-sort-by-total-score)
628 (function :tag "other"))))
630 (defcustom gnus-thread-score-function '+
631 "*Function used for calculating the total score of a thread.
633 The function is called with the scores of the article and each
634 subthread and should then return the score of the thread.
636 Some functions you can use are `+', `max', or `min'."
637 :group 'gnus-summary-sort
640 (defcustom gnus-summary-expunge-below nil
641 "All articles that have a score less than this variable will be expunged.
642 This variable is local to the summary buffers."
643 :group 'gnus-score-default
644 :type '(choice (const :tag "off" nil)
647 (defcustom gnus-thread-expunge-below nil
648 "All threads that have a total score less than this variable will be expunged.
649 See `gnus-thread-score-function' for en explanation of what a
652 This variable is local to the summary buffers."
653 :group 'gnus-threading
654 :group 'gnus-score-default
655 :type '(choice (const :tag "off" nil)
658 (defcustom gnus-summary-mode-hook nil
659 "*A hook for Gnus summary mode.
660 This hook is run before any variables are set in the summary buffer."
661 :group 'gnus-summary-various
664 (defcustom gnus-summary-menu-hook nil
665 "*Hook run after the creation of the summary mode menu."
666 :group 'gnus-summary-visual
669 (defcustom gnus-summary-exit-hook nil
670 "*A hook called on exit from the summary buffer.
671 It will be called with point in the group buffer."
672 :group 'gnus-summary-exit
675 (defcustom gnus-summary-prepare-hook nil
676 "*A hook called after the summary buffer has been generated.
677 If you want to modify the summary buffer, you can use this hook."
678 :group 'gnus-summary-various
681 (defcustom gnus-summary-prepared-hook nil
682 "*A hook called as the last thing after the summary buffer has been generated."
683 :group 'gnus-summary-various
686 (defcustom gnus-summary-generate-hook nil
687 "*A hook run just before generating the summary buffer.
688 This hook is commonly used to customize threading variables and the
690 :group 'gnus-summary-various
693 (defcustom gnus-select-group-hook nil
694 "*A hook called when a newsgroup is selected.
696 If you'd like to simplify subjects like the
697 `gnus-summary-next-same-subject' command does, you can use the
700 (setq gnus-select-group-hook
703 (mapcar (lambda (header)
704 (mail-header-set-subject
706 (gnus-simplify-subject
707 (mail-header-subject header) 're-only)))
708 gnus-newsgroup-headers))))"
709 :group 'gnus-group-select
712 (defcustom gnus-select-article-hook nil
713 "*A hook called when an article is selected."
714 :group 'gnus-summary-choose
717 (defcustom gnus-visual-mark-article-hook
718 (list 'gnus-highlight-selected-summary)
719 "*Hook run after selecting an article in the summary buffer.
720 It is meant to be used for highlighting the article in some way. It
721 is not run if `gnus-visual' is nil."
722 :group 'gnus-summary-visual
725 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
726 "*A hook called before parsing the headers."
730 (defcustom gnus-exit-group-hook nil
731 "*A hook called when exiting summary mode.
732 This hook is not called from the non-updating exit commands like `Q'."
736 (defcustom gnus-summary-update-hook
737 (list 'gnus-summary-highlight-line)
738 "*A hook called when a summary line is changed.
739 The hook will not be called if `gnus-visual' is nil.
741 The default function `gnus-summary-highlight-line' will
742 highlight the line according to the `gnus-summary-highlight'
744 :group 'gnus-summary-visual
747 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
748 "*A hook called when an article is selected for the first time.
749 The hook is intended to mark an article as read (or unread)
750 automatically when it is selected."
751 :group 'gnus-summary-choose
754 (defcustom gnus-group-no-more-groups-hook nil
755 "*A hook run when returning to group mode having no more (unread) groups."
756 :group 'gnus-group-select
759 (defcustom gnus-ps-print-hook nil
760 "*A hook run before ps-printing something from Gnus."
764 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
765 "Face used for highlighting the current article in the summary buffer."
766 :group 'gnus-summary-visual
769 (defcustom gnus-summary-highlight
770 '(((= mark gnus-canceled-mark)
771 . gnus-summary-cancelled-face)
772 ((and (> score default)
773 (or (= mark gnus-dormant-mark)
774 (= mark gnus-ticked-mark)))
775 . gnus-summary-high-ticked-face)
776 ((and (< score default)
777 (or (= mark gnus-dormant-mark)
778 (= mark gnus-ticked-mark)))
779 . gnus-summary-low-ticked-face)
780 ((or (= mark gnus-dormant-mark)
781 (= mark gnus-ticked-mark))
782 . gnus-summary-normal-ticked-face)
783 ((and (> score default) (= mark gnus-ancient-mark))
784 . gnus-summary-high-ancient-face)
785 ((and (< score default) (= mark gnus-ancient-mark))
786 . gnus-summary-low-ancient-face)
787 ((= mark gnus-ancient-mark)
788 . gnus-summary-normal-ancient-face)
789 ((and (> score default) (= mark gnus-unread-mark))
790 . gnus-summary-high-unread-face)
791 ((and (< score default) (= mark gnus-unread-mark))
792 . gnus-summary-low-unread-face)
793 ((and (memq article gnus-newsgroup-incorporated)
794 (= mark gnus-unread-mark))
795 . gnus-summary-incorporated-face)
796 ((= mark gnus-unread-mark)
797 . gnus-summary-normal-unread-face)
798 ((and (> score default) (memq mark (list gnus-downloadable-mark
799 gnus-undownloaded-mark)))
800 . gnus-summary-high-unread-face)
801 ((and (< score default) (memq mark (list gnus-downloadable-mark
802 gnus-undownloaded-mark)))
803 . gnus-summary-low-unread-face)
804 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
805 . gnus-summary-normal-unread-face)
807 . gnus-summary-high-read-face)
809 . gnus-summary-low-read-face)
811 . gnus-summary-normal-read-face))
812 "*Controls the highlighting of summary buffer lines.
814 A list of (FORM . FACE) pairs. When deciding how a a particular
815 summary line should be displayed, each form is evaluated. The content
816 of the face field after the first true form is used. You can change
817 how those summary lines are displayed, by editing the face field.
819 You can use the following variables in the FORM field.
821 score: The articles score
822 default: The default article score.
823 below: The score below which articles are automatically marked as read.
824 mark: The articles mark."
825 :group 'gnus-summary-visual
826 :type '(repeat (cons (sexp :tag "Form" nil)
829 (defcustom gnus-alter-header-function nil
830 "Function called to allow alteration of article header structures.
831 The function is called with one parameter, the article header vector,
832 which it may alter in any way.")
834 (defvar gnus-decode-encoded-word-function
835 (mime-find-field-decoder 'From 'nov)
836 "Variable that says which function should be used to decode a string with encoded words.")
838 (defcustom gnus-extra-headers nil
839 "*Extra headers to parse."
841 :type '(repeat symbol))
843 (defcustom gnus-ignored-from-addresses
844 (and user-mail-address (regexp-quote user-mail-address))
845 "*Regexp of From headers that may be suppressed in favor of To headers."
849 (defcustom gnus-group-charset-alist
850 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
851 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
852 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
853 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
854 ("^relcom\\>" koi8-r)
856 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
857 ("^israel\\>" iso-8859-1)
859 ("^alt.chinese.text.big5\\>" chinese-big5)
860 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
861 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
863 "Alist of regexps (to match group names) and default charsets to be used when reading."
864 :type '(repeat (list (regexp :tag "Group")
865 (symbol :tag "Charset")))
866 :group 'gnus-charset)
868 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
869 "List of charsets that should be ignored.
870 When these charsets are used in the \"charset\" parameter, the
871 default charset will be used instead."
872 :type '(repeat symbol)
873 :group 'gnus-charset)
875 (defcustom gnus-group-ignored-charsets-alist
876 '(("alt\\.chinese\\.text" iso-8859-1))
877 "Alist of regexps (to match group names) and charsets that should be ignored.
878 When these charsets are used in the \"charset\" parameter, the
879 default charset will be used instead."
880 :type '(repeat (cons (regexp :tag "Group")
882 :group 'gnus-charset)
884 (defcustom gnus-group-highlight-words-alist nil
885 "Alist of group regexps and highlight regexps.
886 This variable uses the same syntax as `gnus-emphasis-alist'."
887 :type '(repeat (cons (regexp :tag "Group")
888 (repeat (list (regexp :tag "Highlight regexp")
889 (number :tag "Group for entire word" 0)
890 (number :tag "Group for displayed part" 0)
892 gnus-emphasis-highlight-words)))))
893 :group 'gnus-summary-visual)
895 (defcustom gnus-use-wheel nil
896 "Use Intelli-mouse on summary movement"
898 :group 'gnus-summary-maneuvering)
900 (defcustom gnus-wheel-scroll-amount '(5 . 1)
901 "Amount to scroll messages by spinning the mouse wheel.
902 This is actually a cons cell, where the first item is the amount to scroll
903 on a normal wheel event, and the second is the amount to scroll when the
904 wheel is moved with the shift key depressed."
905 :type '(cons (integer :tag "Shift") integer)
906 :group 'gnus-summary-maneuvering)
908 (defcustom gnus-wheel-edge-resistance 2
909 "How hard it should be to change the current article
910 by moving the mouse over the edge of the article window."
912 :group 'gnus-summary-maneuvering)
914 (defcustom gnus-summary-show-article-charset-alist
916 "Alist of number and charset.
917 The article will be shown with the charset corresponding to the
919 For example: ((1 . cn-gb-2312) (2 . big5))."
920 :type '(repeat (cons (number :tag "Argument" 1)
921 (symbol :tag "Charset")))
922 :group 'gnus-charset)
924 (defcustom gnus-preserve-marks t
925 "Whether marks are preserved when moving, copying and respooling messages."
927 :group 'gnus-summary-marks)
929 (defcustom gnus-alter-articles-to-read-function nil
930 "Function to be called to alter the list of articles to be selected."
932 :group 'gnus-summary)
934 (defcustom gnus-orphan-score nil
935 "*All orphans get this score added. Set in the score file."
936 :group 'gnus-score-default
937 :type '(choice (const nil)
940 (defcustom gnus-summary-save-parts-default-mime "image/.*"
941 "*A regexp to match MIME parts when saving multiple parts of a message
942 with gnus-summary-save-parts (X m). This regexp will be used by default
943 when prompting the user for which type of files to save."
948 ;;; Internal variables
950 (defvar gnus-article-mime-handles nil)
951 (defvar gnus-article-decoded-p nil)
952 (defvar gnus-article-charset nil)
953 (defvar gnus-article-ignored-charsets nil)
954 (defvar gnus-scores-exclude-files nil)
955 (defvar gnus-page-broken nil)
956 (defvar gnus-inhibit-mime-unbuttonizing nil)
958 (defvar gnus-original-article nil)
959 (defvar gnus-article-internal-prepare-hook nil)
960 (defvar gnus-newsgroup-process-stack nil)
962 (defvar gnus-thread-indent-array nil)
963 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
964 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
965 "Function called to sort the articles within a thread after it has been gathered together.")
967 (defvar gnus-summary-save-parts-type-history nil)
968 (defvar gnus-summary-save-parts-last-directory nil)
970 ;; Avoid highlighting in kill files.
971 (defvar gnus-summary-inhibit-highlight nil)
972 (defvar gnus-newsgroup-selected-overlay nil)
973 (defvar gnus-inhibit-limiting nil)
974 (defvar gnus-newsgroup-adaptive-score-file nil)
975 (defvar gnus-current-score-file nil)
976 (defvar gnus-current-move-group nil)
977 (defvar gnus-current-copy-group nil)
978 (defvar gnus-current-crosspost-group nil)
980 (defvar gnus-newsgroup-dependencies nil)
981 (defvar gnus-newsgroup-adaptive nil)
982 (defvar gnus-summary-display-article-function nil)
983 (defvar gnus-summary-highlight-line-function nil
984 "Function called after highlighting a summary line.")
986 (defvar gnus-summary-line-format-alist
987 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
988 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
989 (?s gnus-tmp-subject-or-nil ?s)
990 (?n gnus-tmp-name ?s)
991 (?A (std11-address-string
992 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
993 (?a (or (std11-full-name-string
994 (car (mime-entity-read-field gnus-tmp-header 'From)))
996 (?F gnus-tmp-from ?s)
997 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
998 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
999 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1000 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1001 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1002 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1003 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1004 (?L gnus-tmp-lines ?d)
1005 (?I gnus-tmp-indentation ?s)
1006 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1007 (?R gnus-tmp-replied ?c)
1008 (?\[ gnus-tmp-opening-bracket ?c)
1009 (?\] gnus-tmp-closing-bracket ?c)
1010 (?\> (make-string gnus-tmp-level ? ) ?s)
1011 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1012 (?i gnus-tmp-score ?d)
1013 (?z gnus-tmp-score-char ?c)
1014 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1015 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1016 (?U gnus-tmp-unread ?c)
1017 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1018 (?t (gnus-summary-number-of-articles-in-thread
1019 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1021 (?e (gnus-summary-number-of-articles-in-thread
1022 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1024 (?u gnus-tmp-user-defined ?s)
1025 (?P (gnus-pick-line-number) ?d))
1026 "An alist of format specifications that can appear in summary lines.
1027 These are paired with what variables they correspond with, along with
1028 the type of the variable (string, integer, character, etc).")
1030 (defvar gnus-summary-dummy-line-format-alist
1031 `((?S gnus-tmp-subject ?s)
1032 (?N gnus-tmp-number ?d)
1033 (?u gnus-tmp-user-defined ?s)))
1035 (defvar gnus-summary-mode-line-format-alist
1036 `((?G gnus-tmp-group-name ?s)
1037 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1038 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1039 (?A gnus-tmp-article-number ?d)
1040 (?Z gnus-tmp-unread-and-unselected ?s)
1041 (?V gnus-version ?s)
1042 (?U gnus-tmp-unread-and-unticked ?d)
1043 (?S gnus-tmp-subject ?s)
1044 (?e gnus-tmp-unselected ?d)
1045 (?u gnus-tmp-user-defined ?s)
1046 (?d (length gnus-newsgroup-dormant) ?d)
1047 (?t (length gnus-newsgroup-marked) ?d)
1048 (?r (length gnus-newsgroup-reads) ?d)
1049 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1050 (?E gnus-newsgroup-expunged-tally ?d)
1051 (?s (gnus-current-score-file-nondirectory) ?s)))
1053 (defvar gnus-last-search-regexp nil
1054 "Default regexp for article search command.")
1056 (defvar gnus-summary-search-article-matched-data nil
1057 "Last matched data of article search command. It is the local variable
1058 in `gnus-article-buffer' which consists of the list of start position,
1059 end position and text.")
1061 (defvar gnus-last-shell-command nil
1062 "Default shell command on article.")
1064 (defvar gnus-newsgroup-begin nil)
1065 (defvar gnus-newsgroup-end nil)
1066 (defvar gnus-newsgroup-last-rmail nil)
1067 (defvar gnus-newsgroup-last-mail nil)
1068 (defvar gnus-newsgroup-last-folder nil)
1069 (defvar gnus-newsgroup-last-file nil)
1070 (defvar gnus-newsgroup-auto-expire nil)
1071 (defvar gnus-newsgroup-active nil)
1073 (defvar gnus-newsgroup-data nil)
1074 (defvar gnus-newsgroup-data-reverse nil)
1075 (defvar gnus-newsgroup-limit nil)
1076 (defvar gnus-newsgroup-limits nil)
1078 (defvar gnus-newsgroup-unreads nil
1079 "List of unread articles in the current newsgroup.")
1081 (defvar gnus-newsgroup-unselected nil
1082 "List of unselected unread articles in the current newsgroup.")
1084 (defvar gnus-newsgroup-reads nil
1085 "Alist of read articles and article marks in the current newsgroup.")
1087 (defvar gnus-newsgroup-expunged-tally nil)
1089 (defvar gnus-newsgroup-marked nil
1090 "List of ticked articles in the current newsgroup (a subset of unread art).")
1092 (defvar gnus-newsgroup-killed nil
1093 "List of ranges of articles that have been through the scoring process.")
1095 (defvar gnus-newsgroup-cached nil
1096 "List of articles that come from the article cache.")
1098 (defvar gnus-newsgroup-saved nil
1099 "List of articles that have been saved.")
1101 (defvar gnus-newsgroup-kill-headers nil)
1103 (defvar gnus-newsgroup-replied nil
1104 "List of articles that have been replied to in the current newsgroup.")
1106 (defvar gnus-newsgroup-expirable nil
1107 "List of articles in the current newsgroup that can be expired.")
1109 (defvar gnus-newsgroup-processable nil
1110 "List of articles in the current newsgroup that can be processed.")
1112 (defvar gnus-newsgroup-downloadable nil
1113 "List of articles in the current newsgroup that can be processed.")
1115 (defvar gnus-newsgroup-undownloaded nil
1116 "List of articles in the current newsgroup that haven't been downloaded..")
1118 (defvar gnus-newsgroup-unsendable nil
1119 "List of articles in the current newsgroup that won't be sent.")
1121 (defvar gnus-newsgroup-bookmarks nil
1122 "List of articles in the current newsgroup that have bookmarks.")
1124 (defvar gnus-newsgroup-dormant nil
1125 "List of dormant articles in the current newsgroup.")
1127 (defvar gnus-newsgroup-scored nil
1128 "List of scored articles in the current newsgroup.")
1130 (defvar gnus-newsgroup-incorporated nil
1131 "List of incorporated articles in the current newsgroup.")
1133 (defvar gnus-newsgroup-headers nil
1134 "List of article headers in the current newsgroup.")
1136 (defvar gnus-newsgroup-threads nil)
1138 (defvar gnus-newsgroup-prepared nil
1139 "Whether the current group has been prepared properly.")
1141 (defvar gnus-newsgroup-ancient nil
1142 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1144 (defvar gnus-newsgroup-sparse nil)
1146 (defvar gnus-current-article nil)
1147 (defvar gnus-article-current nil)
1148 (defvar gnus-current-headers nil)
1149 (defvar gnus-have-all-headers nil)
1150 (defvar gnus-last-article nil)
1151 (defvar gnus-newsgroup-history nil)
1152 (defvar gnus-newsgroup-charset nil)
1153 (defvar gnus-newsgroup-ephemeral-charset nil)
1154 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1156 (defvar gnus-article-before-search nil)
1158 (defconst gnus-summary-local-variables
1159 '(gnus-newsgroup-name
1160 gnus-newsgroup-begin gnus-newsgroup-end
1161 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1162 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1163 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1164 gnus-newsgroup-unselected gnus-newsgroup-marked
1165 gnus-newsgroup-reads gnus-newsgroup-saved
1166 gnus-newsgroup-replied gnus-newsgroup-expirable
1167 gnus-newsgroup-processable gnus-newsgroup-killed
1168 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1169 gnus-newsgroup-unsendable
1170 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1171 gnus-newsgroup-headers gnus-newsgroup-threads
1172 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1173 gnus-current-article gnus-current-headers gnus-have-all-headers
1174 gnus-last-article gnus-article-internal-prepare-hook
1175 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1176 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1177 gnus-thread-expunge-below
1178 gnus-score-alist gnus-current-score-file
1179 (gnus-summary-expunge-below . global)
1180 (gnus-summary-mark-below . global)
1181 (gnus-orphan-score . global)
1182 gnus-newsgroup-active gnus-scores-exclude-files
1183 gnus-newsgroup-history gnus-newsgroup-ancient
1184 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1185 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1186 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1187 (gnus-newsgroup-expunged-tally . 0)
1188 gnus-cache-removable-articles gnus-newsgroup-cached
1189 gnus-newsgroup-data gnus-newsgroup-data-reverse
1190 gnus-newsgroup-limit gnus-newsgroup-limits
1191 gnus-newsgroup-charset
1192 gnus-newsgroup-incorporated)
1193 "Variables that are buffer-local to the summary buffers.")
1195 (defvar gnus-newsgroup-variables nil
1196 "Variables that have separate values in the newsgroups.")
1198 ;; Byte-compiler warning.
1199 (defvar gnus-article-mode-map)
1201 ;; Subject simplification.
1203 (defun gnus-simplify-whitespace (str)
1204 "Remove excessive whitespace from STR."
1207 (while (string-match "[ \t][ \t]+" mystr)
1208 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1210 (substring mystr (match-end 0)))))
1212 (when (string-match "^[ \t]+" mystr)
1213 (setq mystr (substring mystr (match-end 0))))
1215 (when (string-match "[ \t]+$" mystr)
1216 (setq mystr (substring mystr 0 (match-beginning 0))))
1219 (defsubst gnus-simplify-subject-re (subject)
1220 "Remove \"Re:\" from subject lines."
1221 (if (string-match "^[Rr][Ee]: *" subject)
1222 (substring subject (match-end 0))
1225 (defun gnus-simplify-subject (subject &optional re-only)
1226 "Remove `Re:' and words in parentheses.
1227 If RE-ONLY is non-nil, strip leading `Re:'s only."
1228 (let ((case-fold-search t)) ;Ignore case.
1229 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1230 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1231 (setq subject (substring subject (match-end 0))))
1232 ;; Remove uninteresting prefixes.
1233 (when (and (not re-only)
1234 gnus-simplify-ignored-prefixes
1235 (string-match gnus-simplify-ignored-prefixes subject))
1236 (setq subject (substring subject (match-end 0))))
1237 ;; Remove words in parentheses from end.
1239 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1240 (setq subject (substring subject 0 (match-beginning 0)))))
1241 ;; Return subject string.
1244 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1246 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1247 (goto-char (point-min))
1248 (while (re-search-forward regexp nil t)
1249 (replace-match (or newtext ""))))
1251 (defun gnus-simplify-buffer-fuzzy ()
1252 "Simplify string in the buffer fuzzily.
1253 The string in the accessible portion of the current buffer is simplified.
1254 It is assumed to be a single-line subject.
1255 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1256 matter is removed. Additional things can be deleted by setting
1257 `gnus-simplify-subject-fuzzy-regexp'."
1258 (let ((case-fold-search t)
1260 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1262 (while (not (eq modified-tick (buffer-modified-tick)))
1263 (setq modified-tick (buffer-modified-tick))
1265 ((listp gnus-simplify-subject-fuzzy-regexp)
1266 (mapcar 'gnus-simplify-buffer-fuzzy-step
1267 gnus-simplify-subject-fuzzy-regexp))
1268 (gnus-simplify-subject-fuzzy-regexp
1269 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1270 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1271 (gnus-simplify-buffer-fuzzy-step
1272 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1273 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1275 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1276 (gnus-simplify-buffer-fuzzy-step " +" " ")
1277 (gnus-simplify-buffer-fuzzy-step " $")
1278 (gnus-simplify-buffer-fuzzy-step "^ +")))
1280 (defun gnus-simplify-subject-fuzzy (subject)
1281 "Simplify a subject string fuzzily.
1282 See `gnus-simplify-buffer-fuzzy' for details."
1284 (gnus-set-work-buffer)
1285 (let ((case-fold-search t))
1286 ;; Remove uninteresting prefixes.
1287 (when (and gnus-simplify-ignored-prefixes
1288 (string-match gnus-simplify-ignored-prefixes subject))
1289 (setq subject (substring subject (match-end 0))))
1291 (inline (gnus-simplify-buffer-fuzzy))
1294 (defsubst gnus-simplify-subject-fully (subject)
1295 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1297 (gnus-simplify-subject-functions
1298 (gnus-map-function gnus-simplify-subject-functions subject))
1299 ((null gnus-summary-gather-subject-limit)
1300 (gnus-simplify-subject-re subject))
1301 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1302 (gnus-simplify-subject-fuzzy subject))
1303 ((numberp gnus-summary-gather-subject-limit)
1304 (gnus-limit-string (gnus-simplify-subject-re subject)
1305 gnus-summary-gather-subject-limit))
1309 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1310 "Check whether two subjects are equal.
1311 If optional argument simple-first is t, first argument is already
1314 ((null simple-first)
1315 (equal (gnus-simplify-subject-fully s1)
1316 (gnus-simplify-subject-fully s2)))
1319 (gnus-simplify-subject-fully s2)))))
1321 (defun gnus-summary-bubble-group ()
1322 "Increase the score of the current group.
1323 This is a handy function to add to `gnus-summary-exit-hook' to
1324 increase the score of each group you read."
1325 (gnus-group-add-score gnus-newsgroup-name))
1329 ;;; Gnus summary mode
1332 (put 'gnus-summary-mode 'mode-class 'special)
1335 ;; Non-orthogonal keys
1337 (gnus-define-keys gnus-summary-mode-map
1338 " " gnus-summary-next-page
1339 "\177" gnus-summary-prev-page
1340 [delete] gnus-summary-prev-page
1341 [backspace] gnus-summary-prev-page
1342 "\r" gnus-summary-scroll-up
1343 "\M-\r" gnus-summary-scroll-down
1344 "n" gnus-summary-next-unread-article
1345 "p" gnus-summary-prev-unread-article
1346 "N" gnus-summary-next-article
1347 "P" gnus-summary-prev-article
1348 "\M-\C-n" gnus-summary-next-same-subject
1349 "\M-\C-p" gnus-summary-prev-same-subject
1350 "\M-n" gnus-summary-next-unread-subject
1351 "\M-p" gnus-summary-prev-unread-subject
1352 "." gnus-summary-first-unread-article
1353 "," gnus-summary-best-unread-article
1354 "\M-s" gnus-summary-search-article-forward
1355 "\M-r" gnus-summary-search-article-backward
1356 "<" gnus-summary-beginning-of-article
1357 ">" gnus-summary-end-of-article
1358 "j" gnus-summary-goto-article
1359 "^" gnus-summary-refer-parent-article
1360 "\M-^" gnus-summary-refer-article
1361 "u" gnus-summary-tick-article-forward
1362 "!" gnus-summary-tick-article-forward
1363 "U" gnus-summary-tick-article-backward
1364 "d" gnus-summary-mark-as-read-forward
1365 "D" gnus-summary-mark-as-read-backward
1366 "E" gnus-summary-mark-as-expirable
1367 "\M-u" gnus-summary-clear-mark-forward
1368 "\M-U" gnus-summary-clear-mark-backward
1369 "k" gnus-summary-kill-same-subject-and-select
1370 "\C-k" gnus-summary-kill-same-subject
1371 "\M-\C-k" gnus-summary-kill-thread
1372 "\M-\C-l" gnus-summary-lower-thread
1373 "e" gnus-summary-edit-article
1374 "#" gnus-summary-mark-as-processable
1375 "\M-#" gnus-summary-unmark-as-processable
1376 "\M-\C-t" gnus-summary-toggle-threads
1377 "\M-\C-s" gnus-summary-show-thread
1378 "\M-\C-h" gnus-summary-hide-thread
1379 "\M-\C-f" gnus-summary-next-thread
1380 "\M-\C-b" gnus-summary-prev-thread
1381 [(meta down)] gnus-summary-next-thread
1382 [(meta up)] gnus-summary-prev-thread
1383 "\M-\C-u" gnus-summary-up-thread
1384 "\M-\C-d" gnus-summary-down-thread
1385 "&" gnus-summary-execute-command
1386 "c" gnus-summary-catchup-and-exit
1387 "\C-w" gnus-summary-mark-region-as-read
1388 "\C-t" gnus-summary-toggle-truncation
1389 "?" gnus-summary-mark-as-dormant
1390 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1391 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1392 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1393 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1394 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1395 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1396 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1397 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1398 "=" gnus-summary-expand-window
1399 "\C-x\C-s" gnus-summary-reselect-current-group
1400 "\M-g" gnus-summary-rescan-group
1401 "w" gnus-summary-stop-page-breaking
1402 "\C-c\C-r" gnus-summary-caesar-message
1403 "\M-t" gnus-summary-toggle-mime
1404 "f" gnus-summary-followup
1405 "F" gnus-summary-followup-with-original
1406 "C" gnus-summary-cancel-article
1407 "r" gnus-summary-reply
1408 "R" gnus-summary-reply-with-original
1409 "\C-c\C-f" gnus-summary-mail-forward
1410 "o" gnus-summary-save-article
1411 "\C-o" gnus-summary-save-article-mail
1412 "|" gnus-summary-pipe-output
1413 "\M-k" gnus-summary-edit-local-kill
1414 "\M-K" gnus-summary-edit-global-kill
1416 "\C-c\C-d" gnus-summary-describe-group
1417 "q" gnus-summary-exit
1418 "Q" gnus-summary-exit-no-update
1419 "\C-c\C-i" gnus-info-find-node
1420 gnus-mouse-2 gnus-mouse-pick-article
1421 "m" gnus-summary-mail-other-window
1422 "a" gnus-summary-post-news
1423 "x" gnus-summary-limit-to-unread
1424 "s" gnus-summary-isearch-article
1425 "t" gnus-article-toggle-headers
1426 "g" gnus-summary-show-article
1427 "l" gnus-summary-goto-last-article
1428 "v" gnus-summary-preview-mime-message
1429 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1430 "\C-d" gnus-summary-enter-digest-group
1431 "\M-\C-d" gnus-summary-read-document
1432 "\M-\C-e" gnus-summary-edit-parameters
1433 "\M-\C-a" gnus-summary-customize-parameters
1435 "*" gnus-cache-enter-article
1436 "\M-*" gnus-cache-remove-article
1437 "\M-&" gnus-summary-universal-argument
1438 "\C-l" gnus-recenter
1439 "I" gnus-summary-increase-score
1440 "L" gnus-summary-lower-score
1441 "\M-i" gnus-symbolic-argument
1442 "h" gnus-summary-select-article-buffer
1444 "V" gnus-summary-score-map
1445 "X" gnus-uu-extract-map
1446 "S" gnus-summary-send-map)
1448 ;; Sort of orthogonal keymap
1449 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1450 "t" gnus-summary-tick-article-forward
1451 "!" gnus-summary-tick-article-forward
1452 "d" gnus-summary-mark-as-read-forward
1453 "r" gnus-summary-mark-as-read-forward
1454 "c" gnus-summary-clear-mark-forward
1455 " " gnus-summary-clear-mark-forward
1456 "e" gnus-summary-mark-as-expirable
1457 "x" gnus-summary-mark-as-expirable
1458 "?" gnus-summary-mark-as-dormant
1459 "b" gnus-summary-set-bookmark
1460 "B" gnus-summary-remove-bookmark
1461 "#" gnus-summary-mark-as-processable
1462 "\M-#" gnus-summary-unmark-as-processable
1463 "S" gnus-summary-limit-include-expunged
1464 "C" gnus-summary-catchup
1465 "H" gnus-summary-catchup-to-here
1466 "\C-c" gnus-summary-catchup-all
1467 "k" gnus-summary-kill-same-subject-and-select
1468 "K" gnus-summary-kill-same-subject
1469 "P" gnus-uu-mark-map)
1471 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1472 "c" gnus-summary-clear-above
1473 "u" gnus-summary-tick-above
1474 "m" gnus-summary-mark-above
1475 "k" gnus-summary-kill-below)
1477 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1478 "/" gnus-summary-limit-to-subject
1479 "n" gnus-summary-limit-to-articles
1480 "w" gnus-summary-pop-limit
1481 "s" gnus-summary-limit-to-subject
1482 "a" gnus-summary-limit-to-author
1483 "u" gnus-summary-limit-to-unread
1484 "m" gnus-summary-limit-to-marks
1485 "M" gnus-summary-limit-exclude-marks
1486 "v" gnus-summary-limit-to-score
1487 "*" gnus-summary-limit-include-cached
1488 "D" gnus-summary-limit-include-dormant
1489 "T" gnus-summary-limit-include-thread
1490 "d" gnus-summary-limit-exclude-dormant
1491 "t" gnus-summary-limit-to-age
1492 "x" gnus-summary-limit-to-extra
1493 "E" gnus-summary-limit-include-expunged
1494 "c" gnus-summary-limit-exclude-childless-dormant
1495 "C" gnus-summary-limit-mark-excluded-as-read)
1497 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1498 "n" gnus-summary-next-unread-article
1499 "p" gnus-summary-prev-unread-article
1500 "N" gnus-summary-next-article
1501 "P" gnus-summary-prev-article
1502 "\C-n" gnus-summary-next-same-subject
1503 "\C-p" gnus-summary-prev-same-subject
1504 "\M-n" gnus-summary-next-unread-subject
1505 "\M-p" gnus-summary-prev-unread-subject
1506 "f" gnus-summary-first-unread-article
1507 "b" gnus-summary-best-unread-article
1508 "j" gnus-summary-goto-article
1509 "g" gnus-summary-goto-subject
1510 "l" gnus-summary-goto-last-article
1511 "o" gnus-summary-pop-article)
1513 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1514 "k" gnus-summary-kill-thread
1515 "l" gnus-summary-lower-thread
1516 "i" gnus-summary-raise-thread
1517 "T" gnus-summary-toggle-threads
1518 "t" gnus-summary-rethread-current
1519 "^" gnus-summary-reparent-thread
1520 "s" gnus-summary-show-thread
1521 "S" gnus-summary-show-all-threads
1522 "h" gnus-summary-hide-thread
1523 "H" gnus-summary-hide-all-threads
1524 "n" gnus-summary-next-thread
1525 "p" gnus-summary-prev-thread
1526 "u" gnus-summary-up-thread
1527 "o" gnus-summary-top-thread
1528 "d" gnus-summary-down-thread
1529 "#" gnus-uu-mark-thread
1530 "\M-#" gnus-uu-unmark-thread)
1532 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1533 "g" gnus-summary-prepare
1534 "c" gnus-summary-insert-cached-articles)
1536 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1537 "c" gnus-summary-catchup-and-exit
1538 "C" gnus-summary-catchup-all-and-exit
1539 "E" gnus-summary-exit-no-update
1540 "J" gnus-summary-jump-to-other-group
1541 "Q" gnus-summary-exit
1542 "Z" gnus-summary-exit
1543 "n" gnus-summary-catchup-and-goto-next-group
1544 "R" gnus-summary-reselect-current-group
1545 "G" gnus-summary-rescan-group
1546 "N" gnus-summary-next-group
1547 "s" gnus-summary-save-newsrc
1548 "P" gnus-summary-prev-group)
1550 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1551 " " gnus-summary-next-page
1552 "n" gnus-summary-next-page
1553 "\177" gnus-summary-prev-page
1554 [delete] gnus-summary-prev-page
1555 "p" gnus-summary-prev-page
1556 "\r" gnus-summary-scroll-up
1557 "\M-\r" gnus-summary-scroll-down
1558 "<" gnus-summary-beginning-of-article
1559 ">" gnus-summary-end-of-article
1560 "b" gnus-summary-beginning-of-article
1561 "e" gnus-summary-end-of-article
1562 "^" gnus-summary-refer-parent-article
1563 "r" gnus-summary-refer-parent-article
1564 "D" gnus-summary-enter-digest-group
1565 "R" gnus-summary-refer-references
1566 "T" gnus-summary-refer-thread
1567 "g" gnus-summary-show-article
1568 "s" gnus-summary-isearch-article
1569 "P" gnus-summary-print-article
1570 "t" gnus-article-babel
1571 "d" gnus-summary-decrypt-article
1572 "v" gnus-summary-verify-article)
1574 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1575 "b" gnus-article-add-buttons
1576 "B" gnus-article-add-buttons-to-head
1577 "o" gnus-article-treat-overstrike
1578 "e" gnus-article-emphasize
1579 "w" gnus-article-fill-cited-article
1580 "Q" gnus-article-fill-long-lines
1581 "C" gnus-article-capitalize-sentences
1582 "c" gnus-article-remove-cr
1583 "Z" gnus-article-decode-HZ
1584 "f" gnus-article-display-x-face
1585 "l" gnus-summary-stop-page-breaking
1586 "r" gnus-summary-caesar-message
1587 "t" gnus-article-toggle-headers
1588 "v" gnus-summary-verbose-headers
1589 "m" gnus-summary-toggle-mime
1590 "H" gnus-article-strip-headers-in-body
1591 "d" gnus-article-treat-dumbquotes
1592 "s" gnus-smiley-display)
1594 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1595 "a" gnus-article-hide
1596 "h" gnus-article-toggle-headers
1597 "b" gnus-article-hide-boring-headers
1598 "s" gnus-article-hide-signature
1599 "c" gnus-article-hide-citation
1600 "C" gnus-article-hide-citation-in-followups
1601 "l" gnus-article-hide-list-identifiers
1602 "p" gnus-article-hide-pgp
1603 "B" gnus-article-strip-banner
1604 "P" gnus-article-hide-pem
1605 "\C-c" gnus-article-hide-citation-maybe)
1607 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1608 "a" gnus-article-highlight
1609 "h" gnus-article-highlight-headers
1610 "c" gnus-article-highlight-citation
1611 "s" gnus-article-highlight-signature)
1613 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1614 "z" gnus-article-date-ut
1615 "u" gnus-article-date-ut
1616 "l" gnus-article-date-local
1617 "e" gnus-article-date-lapsed
1618 "o" gnus-article-date-original
1619 "i" gnus-article-date-iso8601
1620 "s" gnus-article-date-user)
1622 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1623 "t" gnus-article-remove-trailing-blank-lines
1624 "l" gnus-article-strip-leading-blank-lines
1625 "m" gnus-article-strip-multiple-blank-lines
1626 "a" gnus-article-strip-blank-lines
1627 "A" gnus-article-strip-all-blank-lines
1628 "s" gnus-article-strip-leading-space
1629 "e" gnus-article-strip-trailing-space)
1631 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1633 "f" gnus-summary-fetch-faq
1634 "d" gnus-summary-describe-group
1635 "h" gnus-summary-describe-briefly
1636 "i" gnus-info-find-node)
1638 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1639 "e" gnus-summary-expire-articles
1640 "\M-\C-e" gnus-summary-expire-articles-now
1641 "\177" gnus-summary-delete-article
1642 [delete] gnus-summary-delete-article
1643 [backspace] gnus-summary-delete-article
1644 "m" gnus-summary-move-article
1645 "r" gnus-summary-respool-article
1646 "w" gnus-summary-edit-article
1647 "c" gnus-summary-copy-article
1648 "B" gnus-summary-crosspost-article
1649 "q" gnus-summary-respool-query
1650 "t" gnus-summary-respool-trace
1651 "i" gnus-summary-import-article
1652 "p" gnus-summary-article-posted-p)
1654 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1655 "o" gnus-summary-save-article
1656 "m" gnus-summary-save-article-mail
1657 "F" gnus-summary-write-article-file
1658 "r" gnus-summary-save-article-rmail
1659 "f" gnus-summary-save-article-file
1660 "b" gnus-summary-save-article-body-file
1661 "h" gnus-summary-save-article-folder
1662 "v" gnus-summary-save-article-vm
1663 "p" gnus-summary-pipe-output
1664 "s" gnus-soup-add-article)
1666 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1667 "b" gnus-summary-display-buttonized
1668 "m" gnus-summary-repair-multipart
1669 "v" gnus-article-view-part
1670 "o" gnus-article-save-part
1671 "c" gnus-article-copy-part
1672 "e" gnus-article-externalize-part
1673 "i" gnus-article-inline-part
1674 "|" gnus-article-pipe-part))
1676 (defun gnus-summary-make-menu-bar ()
1677 (gnus-turn-off-edit-menu 'summary)
1679 (unless (boundp 'gnus-summary-misc-menu)
1682 gnus-summary-kill-menu gnus-summary-mode-map ""
1687 ["Enter score..." gnus-summary-score-entry t]
1688 ["Customize" gnus-score-customize t])
1689 (gnus-make-score-map 'increase)
1690 (gnus-make-score-map 'lower)
1692 ["Kill below" gnus-summary-kill-below t]
1693 ["Mark above" gnus-summary-mark-above t]
1694 ["Tick above" gnus-summary-tick-above t]
1695 ["Clear above" gnus-summary-clear-above t])
1696 ["Current score" gnus-summary-current-score t]
1697 ["Set score" gnus-summary-set-score t]
1698 ["Switch current score file..." gnus-score-change-score-file t]
1699 ["Set mark below..." gnus-score-set-mark-below t]
1700 ["Set expunge below..." gnus-score-set-expunge-below t]
1701 ["Edit current score file" gnus-score-edit-current-scores t]
1702 ["Edit score file" gnus-score-edit-file t]
1703 ["Trace score" gnus-score-find-trace t]
1704 ["Find words" gnus-score-find-favourite-words t]
1705 ["Rescore buffer" gnus-summary-rescore t]
1706 ["Increase score..." gnus-summary-increase-score t]
1707 ["Lower score..." gnus-summary-lower-score t]))))
1709 ;; Define both the Article menu in the summary buffer and the equivalent
1710 ;; Commands menu in the article buffer here for consistency.
1713 ["All" gnus-article-hide t]
1714 ["Headers" gnus-article-toggle-headers t]
1715 ["Signature" gnus-article-hide-signature t]
1716 ["Citation" gnus-article-hide-citation t]
1717 ["List identifiers" gnus-article-hide-list-identifiers t]
1718 ["PGP" gnus-article-hide-pgp t]
1719 ["Banner" gnus-article-strip-banner t]
1720 ["Boring headers" gnus-article-hide-boring-headers t])
1722 ["All" gnus-article-highlight t]
1723 ["Headers" gnus-article-highlight-headers t]
1724 ["Signature" gnus-article-highlight-signature t]
1725 ["Citation" gnus-article-highlight-citation t])
1727 ["Local" gnus-article-date-local t]
1728 ["ISO8601" gnus-article-date-iso8601 t]
1729 ["UT" gnus-article-date-ut t]
1730 ["Original" gnus-article-date-original t]
1731 ["Lapsed" gnus-article-date-lapsed t]
1732 ["User-defined" gnus-article-date-user t])
1735 ["Leading" gnus-article-strip-leading-blank-lines t]
1736 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1737 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1738 ["All of the above" gnus-article-strip-blank-lines t]
1739 ["All" gnus-article-strip-all-blank-lines t]
1740 ["Leading space" gnus-article-strip-leading-space t]
1741 ["Trailing space" gnus-article-strip-trailing-space t])
1742 ["Overstrike" gnus-article-treat-overstrike t]
1743 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1744 ["Emphasis" gnus-article-emphasize t]
1745 ["Word wrap" gnus-article-fill-cited-article t]
1746 ["Fill long lines" gnus-article-fill-long-lines t]
1747 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1748 ["CR" gnus-article-remove-cr t]
1749 ["Show X-Face" gnus-article-display-x-face t]
1750 ["Rot 13" gnus-summary-caesar-message t]
1751 ["Unix pipe" gnus-summary-pipe-message t]
1752 ["Add buttons" gnus-article-add-buttons t]
1753 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1754 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1755 ["Toggle MIME" gnus-summary-toggle-mime t]
1756 ["Verbose header" gnus-summary-verbose-headers t]
1757 ["Toggle header" gnus-summary-toggle-header t]
1758 ["Toggle smileys" gnus-smiley-display t]
1759 ["HZ" gnus-article-decode-HZ t])
1761 ["Save in default format" gnus-summary-save-article t]
1762 ["Save in file" gnus-summary-save-article-file t]
1763 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1764 ["Save in MH folder" gnus-summary-save-article-folder t]
1765 ["Save in VM folder" gnus-summary-save-article-vm t]
1766 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1767 ["Save body in file" gnus-summary-save-article-body-file t]
1768 ["Pipe through a filter" gnus-summary-pipe-output t]
1769 ["Add to SOUP packet" gnus-soup-add-article t]
1770 ["Print" gnus-summary-print-article t])
1772 ["Respool article..." gnus-summary-respool-article t]
1773 ["Move article..." gnus-summary-move-article
1774 (gnus-check-backend-function
1775 'request-move-article gnus-newsgroup-name)]
1776 ["Copy article..." gnus-summary-copy-article t]
1777 ["Crosspost article..." gnus-summary-crosspost-article
1778 (gnus-check-backend-function
1779 'request-replace-article gnus-newsgroup-name)]
1780 ["Import file..." gnus-summary-import-article t]
1781 ["Check if posted" gnus-summary-article-posted-p t]
1782 ["Edit article" gnus-summary-edit-article
1783 (not (gnus-group-read-only-p))]
1784 ["Delete article" gnus-summary-delete-article
1785 (gnus-check-backend-function
1786 'request-expire-articles gnus-newsgroup-name)]
1787 ["Query respool" gnus-summary-respool-query t]
1788 ["Trace respool" gnus-summary-respool-trace t]
1789 ["Delete expirable articles" gnus-summary-expire-articles-now
1790 (gnus-check-backend-function
1791 'request-expire-articles gnus-newsgroup-name)])
1793 ["Uudecode" gnus-uu-decode-uu t]
1794 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1795 ["Unshar" gnus-uu-decode-unshar t]
1796 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1797 ["Save" gnus-uu-decode-save t]
1798 ["Binhex" gnus-uu-decode-binhex t]
1799 ["Postscript" gnus-uu-decode-postscript t])
1801 ["Enter article" gnus-cache-enter-article t]
1802 ["Remove article" gnus-cache-remove-article t])
1803 ["Translate" gnus-article-babel t]
1804 ["Select article buffer" gnus-summary-select-article-buffer t]
1805 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1806 ["Isearch article..." gnus-summary-isearch-article t]
1807 ["Beginning of the article" gnus-summary-beginning-of-article t]
1808 ["End of the article" gnus-summary-end-of-article t]
1809 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1810 ["Fetch referenced articles" gnus-summary-refer-references t]
1811 ["Fetch current thread" gnus-summary-refer-thread t]
1812 ["Fetch article with id..." gnus-summary-refer-article t]
1813 ["Redisplay" gnus-summary-show-article t])))
1815 gnus-summary-article-menu gnus-summary-mode-map ""
1816 (cons "Article" innards))
1819 gnus-article-commands-menu gnus-article-mode-map ""
1820 (cons "Commands" innards)))
1823 gnus-summary-thread-menu gnus-summary-mode-map ""
1825 ["Toggle threading" gnus-summary-toggle-threads t]
1826 ["Hide threads" gnus-summary-hide-all-threads t]
1827 ["Show threads" gnus-summary-show-all-threads t]
1828 ["Hide thread" gnus-summary-hide-thread t]
1829 ["Show thread" gnus-summary-show-thread t]
1830 ["Go to next thread" gnus-summary-next-thread t]
1831 ["Go to previous thread" gnus-summary-prev-thread t]
1832 ["Go down thread" gnus-summary-down-thread t]
1833 ["Go up thread" gnus-summary-up-thread t]
1834 ["Top of thread" gnus-summary-top-thread t]
1835 ["Mark thread as read" gnus-summary-kill-thread t]
1836 ["Lower thread score" gnus-summary-lower-thread t]
1837 ["Raise thread score" gnus-summary-raise-thread t]
1838 ["Rethread current" gnus-summary-rethread-current t]))
1841 gnus-summary-post-menu gnus-summary-mode-map ""
1843 ["Post an article" gnus-summary-post-news t]
1844 ["Followup" gnus-summary-followup t]
1845 ["Followup and yank" gnus-summary-followup-with-original t]
1846 ["Supersede article" gnus-summary-supersede-article t]
1847 ["Cancel article" gnus-summary-cancel-article t]
1848 ["Reply" gnus-summary-reply t]
1849 ["Reply and yank" gnus-summary-reply-with-original t]
1850 ["Wide reply" gnus-summary-wide-reply t]
1851 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1852 ["Mail forward" gnus-summary-mail-forward t]
1853 ["Post forward" gnus-summary-post-forward t]
1854 ["Digest and mail" gnus-uu-digest-mail-forward t]
1855 ["Digest and post" gnus-uu-digest-post-forward t]
1856 ["Resend message" gnus-summary-resend-message t]
1857 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1858 ["Send a mail" gnus-summary-mail-other-window t]
1859 ["Uuencode and post" gnus-uu-post-news t]
1860 ["Followup via news" gnus-summary-followup-to-mail t]
1861 ["Followup via news and yank"
1862 gnus-summary-followup-to-mail-with-original t]
1864 ;;["Send" gnus-summary-send-draft t]
1865 ;;["Send bounced" gnus-resend-bounced-mail t])
1869 gnus-summary-misc-menu gnus-summary-mode-map ""
1872 ["Mark as read" gnus-summary-mark-as-read-forward t]
1873 ["Mark same subject and select"
1874 gnus-summary-kill-same-subject-and-select t]
1875 ["Mark same subject" gnus-summary-kill-same-subject t]
1876 ["Catchup" gnus-summary-catchup t]
1877 ["Catchup all" gnus-summary-catchup-all t]
1878 ["Catchup to here" gnus-summary-catchup-to-here t]
1879 ["Catchup region" gnus-summary-mark-region-as-read t]
1880 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1882 ["Tick" gnus-summary-tick-article-forward t]
1883 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1884 ["Remove marks" gnus-summary-clear-mark-forward t]
1885 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1886 ["Set bookmark" gnus-summary-set-bookmark t]
1887 ["Remove bookmark" gnus-summary-remove-bookmark t])
1889 ["Marks..." gnus-summary-limit-to-marks t]
1890 ["Subject..." gnus-summary-limit-to-subject t]
1891 ["Author..." gnus-summary-limit-to-author t]
1892 ["Age..." gnus-summary-limit-to-age t]
1893 ["Extra..." gnus-summary-limit-to-extra t]
1894 ["Score" gnus-summary-limit-to-score t]
1895 ["Unread" gnus-summary-limit-to-unread t]
1896 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1897 ["Articles" gnus-summary-limit-to-articles t]
1898 ["Pop limit" gnus-summary-pop-limit t]
1899 ["Show dormant" gnus-summary-limit-include-dormant t]
1900 ["Hide childless dormant"
1901 gnus-summary-limit-exclude-childless-dormant t]
1902 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1903 ["Hide marked" gnus-summary-limit-exclude-marks t]
1904 ["Show expunged" gnus-summary-show-all-expunged t])
1906 ["Set mark" gnus-summary-mark-as-processable t]
1907 ["Remove mark" gnus-summary-unmark-as-processable t]
1908 ["Remove all marks" gnus-summary-unmark-all-processable t]
1909 ["Mark above" gnus-uu-mark-over t]
1910 ["Mark series" gnus-uu-mark-series t]
1911 ["Mark region" gnus-uu-mark-region t]
1912 ["Unmark region" gnus-uu-unmark-region t]
1913 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1914 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1915 ["Mark all" gnus-uu-mark-all t]
1916 ["Mark buffer" gnus-uu-mark-buffer t]
1917 ["Mark sparse" gnus-uu-mark-sparse t]
1918 ["Mark thread" gnus-uu-mark-thread t]
1919 ["Unmark thread" gnus-uu-unmark-thread t]
1920 ("Process Mark Sets"
1921 ["Kill" gnus-summary-kill-process-mark t]
1922 ["Yank" gnus-summary-yank-process-mark
1923 gnus-newsgroup-process-stack]
1924 ["Save" gnus-summary-save-process-mark t]))
1926 ["Page forward" gnus-summary-next-page t]
1927 ["Page backward" gnus-summary-prev-page t]
1928 ["Line forward" gnus-summary-scroll-up t])
1930 ["Next unread article" gnus-summary-next-unread-article t]
1931 ["Previous unread article" gnus-summary-prev-unread-article t]
1932 ["Next article" gnus-summary-next-article t]
1933 ["Previous article" gnus-summary-prev-article t]
1934 ["Next unread subject" gnus-summary-next-unread-subject t]
1935 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1936 ["Next article same subject" gnus-summary-next-same-subject t]
1937 ["Previous article same subject" gnus-summary-prev-same-subject t]
1938 ["First unread article" gnus-summary-first-unread-article t]
1939 ["Best unread article" gnus-summary-best-unread-article t]
1940 ["Go to subject number..." gnus-summary-goto-subject t]
1941 ["Go to article number..." gnus-summary-goto-article t]
1942 ["Go to the last article" gnus-summary-goto-last-article t]
1943 ["Pop article off history" gnus-summary-pop-article t])
1945 ["Sort by number" gnus-summary-sort-by-number t]
1946 ["Sort by author" gnus-summary-sort-by-author t]
1947 ["Sort by subject" gnus-summary-sort-by-subject t]
1948 ["Sort by date" gnus-summary-sort-by-date t]
1949 ["Sort by score" gnus-summary-sort-by-score t]
1950 ["Sort by lines" gnus-summary-sort-by-lines t]
1951 ["Sort by characters" gnus-summary-sort-by-chars t])
1953 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1954 ["Describe group" gnus-summary-describe-group t]
1955 ["Read manual" gnus-info-find-node t])
1957 ["Pick and read" gnus-pick-mode t]
1958 ["Binary" gnus-binary-mode t])
1960 ["Regenerate" gnus-summary-prepare t]
1961 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1962 ["Toggle threading" gnus-summary-toggle-threads t])
1963 ["Filter articles..." gnus-summary-execute-command t]
1964 ["Run command on subjects..." gnus-summary-universal-argument t]
1965 ["Search articles forward..." gnus-summary-search-article-forward t]
1966 ["Search articles backward..." gnus-summary-search-article-backward t]
1967 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1968 ["Expand window" gnus-summary-expand-window t]
1969 ["Expire expirable articles" gnus-summary-expire-articles
1970 (gnus-check-backend-function
1971 'request-expire-articles gnus-newsgroup-name)]
1972 ["Edit local kill file" gnus-summary-edit-local-kill t]
1973 ["Edit main kill file" gnus-summary-edit-global-kill t]
1974 ["Edit group parameters" gnus-summary-edit-parameters t]
1975 ["Customize group parameters" gnus-summary-customize-parameters t]
1976 ["Send a bug report" gnus-bug t]
1978 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1979 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1980 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1981 ["Exit group" gnus-summary-exit t]
1982 ["Exit group without updating" gnus-summary-exit-no-update t]
1983 ["Exit and goto next group" gnus-summary-next-group t]
1984 ["Exit and goto prev group" gnus-summary-prev-group t]
1985 ["Reselect group" gnus-summary-reselect-current-group t]
1986 ["Rescan group" gnus-summary-rescan-group t]
1987 ["Update dribble" gnus-summary-save-newsrc t])))
1989 (gnus-run-hooks 'gnus-summary-menu-hook)))
1991 (defun gnus-score-set-default (var value)
1992 "A version of set that updates the GNU Emacs menu-bar."
1994 ;; It is the message that forces the active status to be updated.
1997 (defun gnus-make-score-map (type)
1998 "Make a summary score map of type TYPE."
2001 (let ((headers '(("author" "from" string)
2002 ("subject" "subject" string)
2003 ("article body" "body" string)
2004 ("article head" "head" string)
2005 ("xref" "xref" string)
2006 ("extra header" "extra" string)
2007 ("lines" "lines" number)
2008 ("followups to author" "followup" string)))
2009 (types '((number ("less than" <)
2012 (string ("substring" s)
2016 (perms '(("temporary" (current-time-string))
2024 (if (eq type 'lower)
2029 (setq header (car headers))
2035 (let ((ts (cdr (assoc (nth 2 header) types)))
2051 'gnus-summary-score-entry
2053 (if (or (string= (nth 1 header)
2055 (string= (nth 1 header)
2058 (list 'gnus-summary-header
2060 (list 'quote (nth 1 (car ts)))
2061 (list 'gnus-score-delta-default
2068 (list (nreverse outp))))
2071 (list (nreverse outt))))
2073 (setq headers (cdr headers)))
2074 (list (nreverse outh))))))))
2078 (defun gnus-summary-mode (&optional group)
2079 "Major mode for reading articles.
2081 All normal editing commands are switched off.
2082 \\<gnus-summary-mode-map>
2083 Each line in this buffer represents one article. To read an
2084 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2085 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2088 You can also post articles and send mail from this buffer. To
2089 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2090 of an article, type `\\[gnus-summary-reply]'.
2092 There are approx. one gazillion commands you can execute in this
2093 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2095 The following commands are available:
2097 \\{gnus-summary-mode-map}"
2099 (when (gnus-visual-p 'summary-menu 'menu)
2100 (gnus-summary-make-menu-bar))
2101 (kill-all-local-variables)
2102 (gnus-summary-make-local-variables)
2103 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2104 (gnus-summary-make-local-variables))
2105 (gnus-make-thread-indent-array)
2106 (gnus-simplify-mode-line)
2107 (setq major-mode 'gnus-summary-mode)
2108 (setq mode-name "Summary")
2109 (make-local-variable 'minor-mode-alist)
2110 (use-local-map gnus-summary-mode-map)
2111 (buffer-disable-undo)
2112 (setq buffer-read-only t) ;Disable modification
2113 (setq truncate-lines t)
2114 (setq selective-display t)
2115 (setq selective-display-ellipses t) ;Display `...'
2116 (gnus-summary-set-display-table)
2117 (gnus-set-default-directory)
2118 (setq gnus-newsgroup-name group)
2119 (unless (gnus-news-group-p group)
2120 (setq gnus-newsgroup-incorporated
2121 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2122 (make-local-variable 'gnus-summary-line-format)
2123 (make-local-variable 'gnus-summary-line-format-spec)
2124 (make-local-variable 'gnus-summary-dummy-line-format)
2125 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2126 (make-local-variable 'gnus-summary-mark-positions)
2127 (make-local-hook 'pre-command-hook)
2128 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2129 (gnus-run-hooks 'gnus-summary-mode-hook)
2130 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2131 (gnus-update-summary-mark-positions))
2133 (defun gnus-summary-make-local-variables ()
2134 "Make all the local summary buffer variables."
2136 (dolist (local gnus-summary-local-variables)
2139 (if (eq (cdr local) 'global)
2140 ;; Copy the global value of the variable.
2141 (setq global (symbol-value (car local)))
2142 ;; Use the value from the list.
2143 (setq global (eval (cdr local))))
2144 (set (make-local-variable (car local)) global))
2145 ;; Simple nil-valued local variable.
2146 (set (make-local-variable local) nil)))))
2148 (defun gnus-summary-clear-local-variables ()
2149 (let ((locals gnus-summary-local-variables))
2151 (if (consp (car locals))
2152 (and (vectorp (caar locals))
2153 (set (caar locals) nil))
2154 (and (vectorp (car locals))
2155 (set (car locals) nil)))
2156 (setq locals (cdr locals)))))
2158 ;; Summary data functions.
2160 (defmacro gnus-data-number (data)
2163 (defmacro gnus-data-set-number (data number)
2164 `(setcar ,data ,number))
2166 (defmacro gnus-data-mark (data)
2169 (defmacro gnus-data-set-mark (data mark)
2170 `(setcar (nthcdr 1 ,data) ,mark))
2172 (defmacro gnus-data-pos (data)
2175 (defmacro gnus-data-set-pos (data pos)
2176 `(setcar (nthcdr 2 ,data) ,pos))
2178 (defmacro gnus-data-header (data)
2181 (defmacro gnus-data-set-header (data header)
2182 `(setcar (nthcdr 3 ,data) ,header))
2184 (defmacro gnus-data-level (data)
2187 (defmacro gnus-data-unread-p (data)
2188 `(= (nth 1 ,data) gnus-unread-mark))
2190 (defmacro gnus-data-read-p (data)
2191 `(/= (nth 1 ,data) gnus-unread-mark))
2193 (defmacro gnus-data-pseudo-p (data)
2194 `(consp (nth 3 ,data)))
2196 (defmacro gnus-data-find (number)
2197 `(assq ,number gnus-newsgroup-data))
2199 (defmacro gnus-data-find-list (number &optional data)
2200 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2201 (memq (assq ,number bdata)
2204 (defmacro gnus-data-make (number mark pos header level)
2205 `(list ,number ,mark ,pos ,header ,level))
2207 (defun gnus-data-enter (after-article number mark pos header level offset)
2208 (let ((data (gnus-data-find-list after-article)))
2210 (error "No such article: %d" after-article))
2211 (setcdr data (cons (gnus-data-make number mark pos header level)
2213 (setq gnus-newsgroup-data-reverse nil)
2214 (gnus-data-update-list (cddr data) offset)))
2216 (defun gnus-data-enter-list (after-article list &optional offset)
2218 (let ((data (and after-article (gnus-data-find-list after-article)))
2222 (let ((odata gnus-newsgroup-data))
2223 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2225 (gnus-data-update-list odata offset)))
2226 ;; Find the last element in the list to be spliced into the main
2229 (setq list (cdr list)))
2232 (setcdr list gnus-newsgroup-data)
2233 (setq gnus-newsgroup-data ilist)
2235 (gnus-data-update-list (cdr list) offset)))
2236 (setcdr list (cdr data))
2239 (gnus-data-update-list (cdr list) offset))))
2240 (setq gnus-newsgroup-data-reverse nil))))
2242 (defun gnus-data-remove (article &optional offset)
2243 (let ((data gnus-newsgroup-data))
2244 (if (= (gnus-data-number (car data)) article)
2246 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2247 gnus-newsgroup-data-reverse nil)
2249 (gnus-data-update-list gnus-newsgroup-data offset)))
2251 (when (= (gnus-data-number (cadr data)) article)
2252 (setcdr data (cddr data))
2254 (gnus-data-update-list (cdr data) offset))
2256 gnus-newsgroup-data-reverse nil))
2257 (setq data (cdr data))))))
2259 (defmacro gnus-data-list (backward)
2261 (or gnus-newsgroup-data-reverse
2262 (setq gnus-newsgroup-data-reverse
2263 (reverse gnus-newsgroup-data)))
2264 gnus-newsgroup-data))
2266 (defun gnus-data-update-list (data offset)
2267 "Add OFFSET to the POS of all data entries in DATA."
2268 (setq gnus-newsgroup-data-reverse nil)
2270 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2271 (setq data (cdr data))))
2273 (defun gnus-summary-article-pseudo-p (article)
2274 "Say whether this article is a pseudo article or not."
2275 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2277 (defmacro gnus-summary-article-sparse-p (article)
2278 "Say whether this article is a sparse article or not."
2279 `(memq ,article gnus-newsgroup-sparse))
2281 (defmacro gnus-summary-article-ancient-p (article)
2282 "Say whether this article is a sparse article or not."
2283 `(memq ,article gnus-newsgroup-ancient))
2285 (defun gnus-article-parent-p (number)
2286 "Say whether this article is a parent or not."
2287 (let ((data (gnus-data-find-list number)))
2288 (and (cdr data) ; There has to be an article after...
2289 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2290 (gnus-data-level (nth 1 data))))))
2292 (defun gnus-article-children (number)
2293 "Return a list of all children to NUMBER."
2294 (let* ((data (gnus-data-find-list number))
2295 (level (gnus-data-level (car data)))
2297 (setq data (cdr data))
2299 (= (gnus-data-level (car data)) (1+ level)))
2300 (push (gnus-data-number (car data)) children)
2301 (setq data (cdr data)))
2304 (defmacro gnus-summary-skip-intangible ()
2305 "If the current article is intangible, then jump to a different article."
2306 '(let ((to (get-text-property (point) 'gnus-intangible)))
2307 (and to (gnus-summary-goto-subject to))))
2309 (defmacro gnus-summary-article-intangible-p ()
2310 "Say whether this article is intangible or not."
2311 '(get-text-property (point) 'gnus-intangible))
2313 (defun gnus-article-read-p (article)
2314 "Say whether ARTICLE is read or not."
2315 (not (or (memq article gnus-newsgroup-marked)
2316 (memq article gnus-newsgroup-unreads)
2317 (memq article gnus-newsgroup-unselected)
2318 (memq article gnus-newsgroup-dormant))))
2320 ;; Some summary mode macros.
2322 (defmacro gnus-summary-article-number ()
2323 "The article number of the article on the current line.
2324 If there isn's an article number here, then we return the current
2327 (gnus-summary-skip-intangible)
2328 (or (get-text-property (point) 'gnus-number)
2329 (gnus-summary-last-subject))))
2331 (defmacro gnus-summary-article-header (&optional number)
2332 "Return the header of article NUMBER."
2333 `(gnus-data-header (gnus-data-find
2334 ,(or number '(gnus-summary-article-number)))))
2336 (defmacro gnus-summary-thread-level (&optional number)
2337 "Return the level of thread that starts with article NUMBER."
2338 `(if (and (eq gnus-summary-make-false-root 'dummy)
2339 (get-text-property (point) 'gnus-intangible))
2341 (gnus-data-level (gnus-data-find
2342 ,(or number '(gnus-summary-article-number))))))
2344 (defmacro gnus-summary-article-mark (&optional number)
2345 "Return the mark of article NUMBER."
2346 `(gnus-data-mark (gnus-data-find
2347 ,(or number '(gnus-summary-article-number)))))
2349 (defmacro gnus-summary-article-pos (&optional number)
2350 "Return the position of the line of article NUMBER."
2351 `(gnus-data-pos (gnus-data-find
2352 ,(or number '(gnus-summary-article-number)))))
2354 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2355 (defmacro gnus-summary-article-subject (&optional number)
2356 "Return current subject string or nil if nothing."
2359 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2360 '(gnus-data-header (assq (gnus-summary-article-number)
2361 gnus-newsgroup-data)))))
2364 (mail-header-subject headers))))
2366 (defmacro gnus-summary-article-score (&optional number)
2367 "Return current article score."
2368 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2369 gnus-newsgroup-scored))
2370 gnus-summary-default-score 0))
2372 (defun gnus-summary-article-children (&optional number)
2373 "Return a list of article numbers that are children of article NUMBER."
2374 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2375 (level (gnus-data-level (car data)))
2377 (while (and (setq data (cdr data))
2378 (> (setq l (gnus-data-level (car data))) level))
2379 (and (= (1+ level) l)
2380 (push (gnus-data-number (car data))
2382 (nreverse children)))
2384 (defun gnus-summary-article-parent (&optional number)
2385 "Return the article number of the parent of article NUMBER."
2386 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2387 (gnus-data-list t)))
2388 (level (gnus-data-level (car data))))
2390 () ; This is a root.
2391 ;; We search until we find an article with a level less than
2392 ;; this one. That function has to be the parent.
2393 (while (and (setq data (cdr data))
2394 (not (< (gnus-data-level (car data)) level))))
2395 (and data (gnus-data-number (car data))))))
2397 (defun gnus-unread-mark-p (mark)
2398 "Say whether MARK is the unread mark."
2399 (= mark gnus-unread-mark))
2401 (defun gnus-read-mark-p (mark)
2402 "Say whether MARK is one of the marks that mark as read.
2403 This is all marks except unread, ticked, dormant, and expirable."
2404 (not (or (= mark gnus-unread-mark)
2405 (= mark gnus-ticked-mark)
2406 (= mark gnus-dormant-mark)
2407 (= mark gnus-expirable-mark))))
2409 (defmacro gnus-article-mark (number)
2410 "Return the MARK of article NUMBER.
2411 This macro should only be used when computing the mark the \"first\"
2412 time; i.e., when generating the summary lines. After that,
2413 `gnus-summary-article-mark' should be used to examine the
2416 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2417 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2418 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2419 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2420 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2421 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2422 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2423 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2424 gnus-ancient-mark))))
2426 ;; Saving hidden threads.
2428 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2429 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2431 (defmacro gnus-save-hidden-threads (&rest forms)
2432 "Save hidden threads, eval FORMS, and restore the hidden threads."
2433 (let ((config (make-symbol "config")))
2434 `(let ((,config (gnus-hidden-threads-configuration)))
2438 (gnus-restore-hidden-threads-configuration ,config)))))
2440 (defun gnus-data-compute-positions ()
2441 "Compute the positions of all articles."
2442 (setq gnus-newsgroup-data-reverse nil)
2443 (let ((data gnus-newsgroup-data))
2445 (gnus-save-hidden-threads
2446 (gnus-summary-show-all-threads)
2447 (goto-char (point-min))
2449 (while (get-text-property (point) 'gnus-intangible)
2451 (gnus-data-set-pos (car data) (+ (point) 3))
2452 (setq data (cdr data))
2453 (forward-line 1))))))
2455 (defun gnus-hidden-threads-configuration ()
2456 "Return the current hidden threads configuration."
2459 (goto-char (point-min))
2460 (while (search-forward "\r" nil t)
2461 (push (1- (point)) config))
2464 (defun gnus-restore-hidden-threads-configuration (config)
2465 "Restore hidden threads configuration from CONFIG."
2467 (let (point buffer-read-only)
2468 (while (setq point (pop config))
2469 (when (and (< point (point-max))
2471 (eq (char-after) ?\n))
2472 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2474 ;; Various summary mode internalish functions.
2476 (defun gnus-mouse-pick-article (e)
2479 (gnus-summary-next-page nil t))
2481 (defun gnus-summary-set-display-table ()
2482 "Change the display table.
2483 Odd characters have a tendency to mess
2484 up nicely formatted displays - we make all possible glyphs
2485 display only a single character."
2487 ;; We start from the standard display table, if any.
2488 (let ((table (or (copy-sequence standard-display-table)
2489 (make-display-table)))
2491 ;; Nix out all the control chars...
2492 (while (>= (setq i (1- i)) 0)
2493 (aset table i [??]))
2494 ;; ... but not newline and cr, of course. (cr is necessary for the
2495 ;; selective display).
2496 (aset table ?\n nil)
2497 (aset table ?\r nil)
2498 ;; We keep TAB as well.
2499 (aset table ?\t nil)
2500 ;; We nix out any glyphs over 126 that are not set already.
2502 (while (>= (setq i (1- i)) 127)
2503 ;; Only modify if the entry is nil.
2504 (unless (aref table i)
2505 (aset table i [??]))))
2506 (setq buffer-display-table table)))
2508 (defun gnus-summary-setup-buffer (group)
2509 "Initialize summary buffer."
2510 (let ((buffer (concat "*Summary " group "*")))
2511 (if (get-buffer buffer)
2514 (setq gnus-summary-buffer (current-buffer))
2515 (not gnus-newsgroup-prepared))
2516 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2517 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2518 (gnus-summary-mode group)
2520 (gnus-carpal-setup-buffer 'summary))
2521 (unless gnus-single-article-buffer
2522 (make-local-variable 'gnus-article-buffer)
2523 (make-local-variable 'gnus-article-current)
2524 (make-local-variable 'gnus-original-article-buffer))
2525 (setq gnus-newsgroup-name group)
2528 (defun gnus-set-global-variables ()
2529 "Set the global equivalents of the buffer-local variables.
2530 They are set to the latest values they had. These reflect the summary
2531 buffer that was in action when the last article was fetched."
2532 (when (eq major-mode 'gnus-summary-mode)
2533 (setq gnus-summary-buffer (current-buffer))
2534 (let ((name gnus-newsgroup-name)
2535 (marked gnus-newsgroup-marked)
2536 (unread gnus-newsgroup-unreads)
2537 (headers gnus-current-headers)
2538 (data gnus-newsgroup-data)
2539 (summary gnus-summary-buffer)
2540 (article-buffer gnus-article-buffer)
2541 (original gnus-original-article-buffer)
2542 (gac gnus-article-current)
2543 (reffed gnus-reffed-article-number)
2544 (score-file gnus-current-score-file)
2545 (default-charset gnus-newsgroup-charset)
2547 (let ((locals gnus-newsgroup-variables))
2549 (if (consp (car locals))
2550 (push (eval (caar locals)) vlist)
2551 (push (eval (car locals)) vlist))
2552 (setq locals (cdr locals)))
2553 (setq vlist (nreverse vlist)))
2555 (set-buffer gnus-group-buffer)
2556 (setq gnus-newsgroup-name name
2557 gnus-newsgroup-marked marked
2558 gnus-newsgroup-unreads unread
2559 gnus-current-headers headers
2560 gnus-newsgroup-data data
2561 gnus-article-current gac
2562 gnus-summary-buffer summary
2563 gnus-article-buffer article-buffer
2564 gnus-original-article-buffer original
2565 gnus-reffed-article-number reffed
2566 gnus-current-score-file score-file
2567 gnus-newsgroup-charset default-charset)
2568 (let ((locals gnus-newsgroup-variables))
2570 (if (consp (car locals))
2571 (set (caar locals) (pop vlist))
2572 (set (car locals) (pop vlist)))
2573 (setq locals (cdr locals))))
2574 ;; The article buffer also has local variables.
2575 (when (gnus-buffer-live-p gnus-article-buffer)
2576 (set-buffer gnus-article-buffer)
2577 (setq gnus-summary-buffer summary))))))
2579 (defun gnus-summary-article-unread-p (article)
2580 "Say whether ARTICLE is unread or not."
2581 (memq article gnus-newsgroup-unreads))
2583 (defun gnus-summary-first-article-p (&optional article)
2584 "Return whether ARTICLE is the first article in the buffer."
2585 (if (not (setq article (or article (gnus-summary-article-number))))
2587 (eq article (caar gnus-newsgroup-data))))
2589 (defun gnus-summary-last-article-p (&optional article)
2590 "Return whether ARTICLE is the last article in the buffer."
2591 (if (not (setq article (or article (gnus-summary-article-number))))
2592 ;; All non-existent numbers are the last article. :-)
2594 (not (cdr (gnus-data-find-list article)))))
2596 (defun gnus-make-thread-indent-array ()
2598 (unless (and gnus-thread-indent-array
2599 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2600 (setq gnus-thread-indent-array (make-vector 201 "")
2601 gnus-thread-indent-array-level gnus-thread-indent-level)
2603 (aset gnus-thread-indent-array n
2604 (make-string (* n gnus-thread-indent-level) ? ))
2607 (defun gnus-update-summary-mark-positions ()
2608 "Compute where the summary marks are to go."
2610 (when (gnus-buffer-exists-p gnus-summary-buffer)
2611 (set-buffer gnus-summary-buffer))
2612 (let ((gnus-replied-mark 129)
2613 (gnus-score-below-mark 130)
2614 (gnus-score-over-mark 130)
2615 (gnus-download-mark 131)
2616 (spec gnus-summary-line-format-spec)
2619 (gnus-set-work-buffer)
2620 (let ((gnus-summary-line-format-spec spec)
2621 (gnus-newsgroup-downloadable '((0 . t))))
2622 (gnus-summary-insert-line
2623 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2624 0 nil 128 t nil "" nil 1)
2625 (goto-char (point-min))
2626 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2628 (goto-char (point-min))
2629 (push (cons 'replied (and (search-forward "\201" nil t)
2632 (goto-char (point-min))
2633 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2635 (goto-char (point-min))
2636 (push (cons 'download
2637 (and (search-forward "\203" nil t) (- (point) 2)))
2639 (setq gnus-summary-mark-positions pos))))
2641 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2642 "Insert a dummy root in the summary buffer."
2644 (gnus-add-text-properties
2645 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2646 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2648 (defun gnus-summary-from-or-to-or-newsgroups (header)
2649 (let ((to (cdr (assq 'To (mail-header-extra header))))
2650 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2651 (default-mime-charset (with-current-buffer gnus-summary-buffer
2652 default-mime-charset)))
2655 gnus-ignored-from-addresses
2656 (string-match gnus-ignored-from-addresses
2657 (mail-header-from header)))
2659 (or (car (funcall gnus-extract-address-components
2661 gnus-decode-encoded-word-function to)))
2662 (funcall gnus-decode-encoded-word-function to))))
2664 gnus-ignored-from-addresses
2665 (string-match gnus-ignored-from-addresses
2666 (mail-header-from header)))
2667 (concat "=> " newsgroups))
2669 (or (car (funcall gnus-extract-address-components
2670 (mail-header-from header)))
2671 (mail-header-from header))))))
2673 (defun gnus-summary-insert-line (gnus-tmp-header
2674 gnus-tmp-level gnus-tmp-current
2675 gnus-tmp-unread gnus-tmp-replied
2676 gnus-tmp-expirable gnus-tmp-subject-or-nil
2677 &optional gnus-tmp-dummy gnus-tmp-score
2679 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2680 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2681 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2682 (gnus-tmp-score-char
2683 (if (or (null gnus-summary-default-score)
2684 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2685 gnus-summary-zcore-fuzz))
2687 (if (< gnus-tmp-score gnus-summary-default-score)
2688 gnus-score-below-mark gnus-score-over-mark)))
2690 (cond (gnus-tmp-process gnus-process-mark)
2691 ((memq gnus-tmp-current gnus-newsgroup-cached)
2693 (gnus-tmp-replied gnus-replied-mark)
2694 ((memq gnus-tmp-current gnus-newsgroup-saved)
2696 (t gnus-unread-mark)))
2697 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2700 ((string-match "<[^>]+> *$" gnus-tmp-from)
2701 (let ((beg (match-beginning 0)))
2702 (or (and (string-match "^\".+\"" gnus-tmp-from)
2703 (substring gnus-tmp-from 1 (1- (match-end 0))))
2704 (substring gnus-tmp-from 0 beg))))
2705 ((string-match "(.+)" gnus-tmp-from)
2706 (substring gnus-tmp-from
2707 (1+ (match-beginning 0)) (1- (match-end 0))))
2709 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2710 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2711 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2712 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2713 (buffer-read-only nil))
2714 (when (string= gnus-tmp-name "")
2715 (setq gnus-tmp-name gnus-tmp-from))
2716 (unless (numberp gnus-tmp-lines)
2717 (setq gnus-tmp-lines 0))
2718 (gnus-put-text-property-excluding-characters-with-faces
2720 (progn (eval gnus-summary-line-format-spec) (point))
2721 'gnus-number gnus-tmp-number)
2722 (when (gnus-visual-p 'summary-highlight 'highlight)
2724 (gnus-run-hooks 'gnus-summary-update-hook)
2727 (defun gnus-summary-update-line (&optional dont-update)
2728 "Update summary line after change."
2729 (when (and gnus-summary-default-score
2730 (not gnus-summary-inhibit-highlight))
2731 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2732 (article (gnus-summary-article-number))
2733 (score (gnus-summary-article-score article)))
2735 (if (and gnus-summary-mark-below
2736 (< (gnus-summary-article-score)
2737 gnus-summary-mark-below))
2738 ;; This article has a low score, so we mark it as read.
2739 (when (memq article gnus-newsgroup-unreads)
2740 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2741 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2742 ;; This article was previously marked as read on account
2743 ;; of a low score, but now it has risen, so we mark it as
2745 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2746 (gnus-summary-update-mark
2747 (if (or (null gnus-summary-default-score)
2748 (<= (abs (- score gnus-summary-default-score))
2749 gnus-summary-zcore-fuzz))
2751 (if (< score gnus-summary-default-score)
2752 gnus-score-below-mark gnus-score-over-mark))
2754 ;; Do visual highlighting.
2755 (when (gnus-visual-p 'summary-highlight 'highlight)
2756 (gnus-run-hooks 'gnus-summary-update-hook)))))
2758 (defvar gnus-tmp-new-adopts nil)
2760 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2761 "Return the number of articles in THREAD.
2762 This may be 0 in some cases -- if none of the articles in
2763 the thread are to be displayed."
2765 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2767 ((not (listp thread))
2769 ((and (consp thread) (cdr thread))
2772 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2775 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2778 (when (and level (zerop level) gnus-tmp-new-adopts)
2781 'gnus-summary-number-of-articles-in-thread
2782 gnus-tmp-new-adopts))))
2784 (if (> number 1) gnus-not-empty-thread-mark
2785 gnus-empty-thread-mark)
2788 (defun gnus-summary-set-local-parameters (group)
2789 "Go through the local params of GROUP and set all variable specs in that list."
2790 (let ((params (gnus-group-find-parameter group))
2793 (setq elem (car params)
2794 params (cdr params))
2795 (and (consp elem) ; Has to be a cons.
2796 (consp (cdr elem)) ; The cdr has to be a list.
2797 (symbolp (car elem)) ; Has to be a symbol in there.
2798 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2799 (ignore-errors ; So we set it.
2800 (make-local-variable (car elem))
2801 (set (car elem) (eval (nth 1 elem))))))))
2803 (defun gnus-summary-read-group (group &optional show-all no-article
2804 kill-buffer no-display backward
2806 "Start reading news in newsgroup GROUP.
2807 If SHOW-ALL is non-nil, already read articles are also listed.
2808 If NO-ARTICLE is non-nil, no article is selected initially.
2809 If NO-DISPLAY, don't generate a summary buffer."
2813 (let ((gnus-auto-select-next nil))
2814 (or (gnus-summary-read-group-1
2815 group show-all no-article
2816 kill-buffer no-display
2819 select-articles nil)))))
2820 (eq gnus-auto-select-next 'quietly))
2821 (set-buffer gnus-group-buffer)
2822 ;; The entry function called above goes to the next
2823 ;; group automatically, so we go two groups back
2824 ;; if we are searching for the previous group.
2826 (gnus-group-prev-unread-group 2))
2827 (if (not (equal group (gnus-group-group-name)))
2828 (setq group (gnus-group-group-name))
2832 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2833 "Directly jump to the other GROUP from summary buffer.
2834 If SHOW-ALL is non-nil, already read articles are also listed."
2836 (if (eq gnus-summary-buffer (current-buffer))
2837 (list (completing-read
2838 "Group: " gnus-active-hashtb nil t
2839 (when (and gnus-newsgroup-name
2840 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2841 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2842 'gnus-group-history)
2844 (error "%s must be invoked from a gnus summary buffer." this-command)))
2845 (unless (or (zerop (length group))
2846 (and gnus-newsgroup-name
2847 (string-equal gnus-newsgroup-name group)))
2849 (gnus-summary-read-group group show-all
2850 gnus-dont-select-after-jump-to-other-group)))
2852 (defun gnus-summary-read-group-1 (group show-all no-article
2853 kill-buffer no-display
2854 &optional select-articles)
2855 ;; Killed foreign groups can't be entered.
2856 (when (and (not (gnus-group-native-p group))
2857 (not (gnus-gethash group gnus-newsrc-hashtb)))
2858 (error "Dead non-native groups can't be entered"))
2859 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2860 (let* ((new-group (gnus-summary-setup-buffer group))
2861 (quit-config (gnus-group-quit-config group))
2862 (did-select (and new-group (gnus-select-newsgroup
2863 group show-all select-articles))))
2865 ;; This summary buffer exists already, so we just select it.
2867 (gnus-set-global-variables)
2869 (gnus-kill-or-deaden-summary kill-buffer))
2870 (gnus-configure-windows 'summary 'force)
2871 (gnus-set-mode-line 'summary)
2872 (gnus-summary-position-point)
2875 ;; We couldn't select this group.
2877 (when (and (eq major-mode 'gnus-summary-mode)
2878 (not (equal (current-buffer) kill-buffer)))
2879 (kill-buffer (current-buffer))
2880 (if (not quit-config)
2882 ;; Update the info -- marks might need to be removed,
2884 (gnus-summary-update-info)
2885 (set-buffer gnus-group-buffer)
2886 (gnus-group-jump-to-group group)
2887 (gnus-group-next-unread-group 1))
2888 (gnus-handle-ephemeral-exit quit-config)))
2889 (gnus-message 3 "Can't select group")
2891 ;; The user did a `C-g' while prompting for number of articles,
2892 ;; so we exit this group.
2893 ((eq did-select 'quit)
2894 (and (eq major-mode 'gnus-summary-mode)
2895 (not (equal (current-buffer) kill-buffer))
2896 (kill-buffer (current-buffer)))
2898 (gnus-kill-or-deaden-summary kill-buffer))
2899 (if (not quit-config)
2901 (set-buffer gnus-group-buffer)
2902 (gnus-group-jump-to-group group)
2903 (gnus-group-next-unread-group 1)
2904 (gnus-configure-windows 'group 'force))
2905 (gnus-handle-ephemeral-exit quit-config))
2906 ;; Finally signal the quit.
2908 ;; The group was successfully selected.
2910 (gnus-set-global-variables)
2911 ;; Save the active value in effect when the group was entered.
2912 (setq gnus-newsgroup-active
2914 (gnus-active gnus-newsgroup-name)))
2915 ;; You can change the summary buffer in some way with this hook.
2916 (gnus-run-hooks 'gnus-select-group-hook)
2917 ;; Set any local variables in the group parameters.
2918 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2919 (gnus-update-format-specifications
2920 nil 'summary 'summary-mode 'summary-dummy)
2921 (gnus-update-summary-mark-positions)
2922 ;; Do score processing.
2923 (when gnus-use-scoring
2924 (gnus-possibly-score-headers))
2925 ;; Check whether to fill in the gaps in the threads.
2926 (when gnus-build-sparse-threads
2927 (gnus-build-sparse-threads))
2928 ;; Find the initial limit.
2929 (if gnus-show-threads
2931 (let ((gnus-newsgroup-dormant nil))
2932 (gnus-summary-initial-limit show-all))
2933 (gnus-summary-initial-limit show-all))
2934 ;; When untreaded, all articles are always shown.
2935 (setq gnus-newsgroup-limit
2937 (lambda (header) (mail-header-number header))
2938 gnus-newsgroup-headers)))
2939 ;; Generate the summary buffer.
2941 (gnus-summary-prepare))
2942 (when gnus-use-trees
2943 (gnus-tree-open group)
2944 (setq gnus-summary-highlight-line-function
2945 'gnus-tree-highlight-article))
2946 ;; If the summary buffer is empty, but there are some low-scored
2947 ;; articles or some excluded dormants, we include these in the
2949 (when (and (zerop (buffer-size))
2951 (cond (gnus-newsgroup-dormant
2952 (gnus-summary-limit-include-dormant))
2953 ((and gnus-newsgroup-scored show-all)
2954 (gnus-summary-limit-include-expunged t))))
2955 ;; Function `gnus-apply-kill-file' must be called in this hook.
2956 (gnus-run-hooks 'gnus-apply-kill-hook)
2957 (if (and (zerop (buffer-size))
2960 ;; This newsgroup is empty.
2961 (gnus-summary-catchup-and-exit nil t)
2962 (gnus-message 6 "No unread news")
2964 (gnus-kill-or-deaden-summary kill-buffer))
2965 ;; Return nil from this function.
2967 ;; Hide conversation thread subtrees. We cannot do this in
2968 ;; gnus-summary-prepare-hook since kill processing may not
2969 ;; work with hidden articles.
2970 (and gnus-show-threads
2971 gnus-thread-hide-subtree
2972 (gnus-summary-hide-all-threads))
2974 (gnus-kill-or-deaden-summary kill-buffer))
2975 ;; Show first unread article if requested.
2976 (if (and (not no-article)
2978 gnus-newsgroup-unreads
2979 gnus-auto-select-first)
2981 (gnus-configure-windows 'summary)
2983 ((eq gnus-auto-select-first 'best)
2984 (gnus-summary-best-unread-article))
2985 ((eq gnus-auto-select-first t)
2986 (gnus-summary-first-unread-article))
2987 ((gnus-functionp gnus-auto-select-first)
2988 (funcall gnus-auto-select-first))))
2989 ;; Don't select any articles, just move point to the first
2990 ;; article in the group.
2991 (goto-char (point-min))
2992 (gnus-summary-position-point)
2993 (gnus-configure-windows 'summary 'force)
2994 (gnus-set-mode-line 'summary))
2995 (when (get-buffer-window gnus-group-buffer t)
2996 ;; Gotta use windows, because recenter does weird stuff if
2997 ;; the current buffer ain't the displayed window.
2998 (let ((owin (selected-window)))
2999 (select-window (get-buffer-window gnus-group-buffer t))
3000 (when (gnus-group-goto-group group)
3002 (select-window owin)))
3003 ;; Mark this buffer as "prepared".
3004 (setq gnus-newsgroup-prepared t)
3005 (gnus-run-hooks 'gnus-summary-prepared-hook)
3008 (defun gnus-summary-prepare ()
3009 "Generate the summary buffer."
3011 (let ((buffer-read-only nil))
3013 (setq gnus-newsgroup-data nil
3014 gnus-newsgroup-data-reverse nil)
3015 (gnus-run-hooks 'gnus-summary-generate-hook)
3016 ;; Generate the buffer, either with threads or without.
3017 (when gnus-newsgroup-headers
3018 (gnus-summary-prepare-threads
3019 (if gnus-show-threads
3020 (gnus-sort-gathered-threads
3021 (funcall gnus-summary-thread-gathering-function
3023 (gnus-cut-threads (gnus-make-threads)))))
3024 ;; Unthreaded display.
3025 (gnus-sort-articles gnus-newsgroup-headers))))
3026 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3027 ;; Call hooks for modifying summary buffer.
3028 (goto-char (point-min))
3029 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3031 (defsubst gnus-general-simplify-subject (subject)
3032 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3035 ;; Truncate the subject.
3036 (gnus-simplify-subject-functions
3037 (gnus-map-function gnus-simplify-subject-functions subject))
3038 ((numberp gnus-summary-gather-subject-limit)
3039 (setq subject (gnus-simplify-subject-re subject))
3040 (if (> (length subject) gnus-summary-gather-subject-limit)
3041 (substring subject 0 gnus-summary-gather-subject-limit)
3043 ;; Fuzzily simplify it.
3044 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3045 (gnus-simplify-subject-fuzzy subject))
3046 ;; Just remove the leading "Re:".
3048 (gnus-simplify-subject-re subject))))
3050 (if (and gnus-summary-gather-exclude-subject
3051 (string-match gnus-summary-gather-exclude-subject subject))
3052 nil ; This article shouldn't be gathered
3055 (defun gnus-summary-simplify-subject-query ()
3056 "Query where the respool algorithm would put this article."
3058 (gnus-summary-select-article)
3060 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3062 (defun gnus-gather-threads-by-subject (threads)
3063 "Gather threads by looking at Subject headers."
3064 (if (not gnus-summary-make-false-root)
3066 (let ((hashtb (gnus-make-hashtable 1024))
3069 subject hthread whole-subject)
3071 (setq subject (gnus-general-simplify-subject
3072 (setq whole-subject (mail-header-subject
3075 (if (setq hthread (gnus-gethash subject hashtb))
3077 ;; We enter a dummy root into the thread, if we
3078 ;; haven't done that already.
3079 (unless (stringp (caar hthread))
3080 (setcar hthread (list whole-subject (car hthread))))
3081 ;; We add this new gathered thread to this gathered
3083 (setcdr (car hthread)
3084 (nconc (cdar hthread) (list (car threads))))
3085 ;; Remove it from the list of threads.
3086 (setcdr prev (cdr threads))
3087 (setq threads prev))
3088 ;; Enter this thread into the hash table.
3089 (gnus-sethash subject threads hashtb)))
3091 (setq threads (cdr threads)))
3094 (defun gnus-gather-threads-by-references (threads)
3095 "Gather threads by looking at References headers."
3096 (let ((idhashtb (gnus-make-hashtable 1024))
3097 (thhashtb (gnus-make-hashtable 1024))
3100 ids references id gthread gid entered ref)
3102 (when (setq references (mail-header-references (caar threads)))
3103 (setq id (mail-header-id (caar threads))
3104 ids (gnus-split-references references)
3106 (while (setq ref (pop ids))
3107 (setq ids (delete ref ids))
3108 (if (not (setq gid (gnus-gethash ref idhashtb)))
3110 (gnus-sethash ref id idhashtb)
3111 (gnus-sethash id threads thhashtb))
3112 (setq gthread (gnus-gethash gid thhashtb))
3114 ;; We enter a dummy root into the thread, if we
3115 ;; haven't done that already.
3116 (unless (stringp (caar gthread))
3117 (setcar gthread (list (mail-header-subject (caar gthread))
3119 ;; We add this new gathered thread to this gathered
3121 (setcdr (car gthread)
3122 (nconc (cdar gthread) (list (car threads)))))
3123 ;; Add it into the thread hash table.
3124 (gnus-sethash id gthread thhashtb)
3126 ;; Remove it from the list of threads.
3127 (setcdr prev (cdr threads))
3128 (setq threads prev))))
3130 (setq threads (cdr threads)))
3133 (defun gnus-sort-gathered-threads (threads)
3134 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3135 (let ((result threads))
3137 (when (stringp (caar threads))
3138 (setcdr (car threads)
3139 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3140 (setq threads (cdr threads)))
3143 (defun gnus-thread-loop-p (root thread)
3144 "Say whether ROOT is in THREAD."
3145 (let ((stack (list thread))
3148 (while (setq thread (pop stack))
3149 (setq th (cdr thread))
3151 (not (eq (caar th) root)))
3154 ;; We have found a loop.
3156 (setcdr thread (delq (car th) (cdr thread)))
3157 (if (boundp (setq ref-dep (intern "none"
3158 gnus-newsgroup-dependencies)))
3159 (setcdr (symbol-value ref-dep)
3160 (nconc (cdr (symbol-value ref-dep))
3162 (set ref-dep (list nil (car th))))
3165 ;; Push all the subthreads onto the stack.
3166 (push (cdr thread) stack)))
3169 (defun gnus-make-threads ()
3170 "Go through the dependency hashtb and find the roots. Return all threads."
3172 (while (catch 'infloop
3175 ;; Deal with self-referencing References loops.
3176 (when (and (car (symbol-value refs))
3183 (car (symbol-value refs)) thread))
3184 (cdr (symbol-value refs)))))))
3187 (unless (car (symbol-value refs))
3188 ;; These threads do not refer back to any other articles,
3189 ;; so they're roots.
3190 (setq threads (append (cdr (symbol-value refs)) threads))))
3191 gnus-newsgroup-dependencies)))
3194 ;; Build the thread tree.
3195 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3196 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3198 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3199 if it was already present.
3201 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3202 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3203 Message-IDs will be renamed be renamed to a unique Message-ID before
3206 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3207 (let* ((id (mail-header-id header))
3208 (id-dep (and id (intern id dependencies)))
3209 ref ref-dep ref-header)
3210 ;; Enter this `header' in the `dependencies' table.
3214 ;; The first two cases do the normal part: enter a new `header'
3215 ;; in the `dependencies' table.
3216 ((not (boundp id-dep))
3217 (set id-dep (list header)))
3218 ((null (car (symbol-value id-dep)))
3219 (setcar (symbol-value id-dep) header))
3221 ;; From here the `header' was already present in the
3222 ;; `dependencies' table.
3224 ;; Overrides an existing entry;
3225 ;; just set the header part of the entry.
3226 (setcar (symbol-value id-dep) header))
3228 ;; Renames the existing `header' to a unique Message-ID.
3229 ((not gnus-summary-ignore-duplicates)
3230 ;; An article with this Message-ID has already been seen.
3231 ;; We rename the Message-ID.
3232 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3234 (mail-header-set-id header id))
3236 ;; The last case ignores an existing entry, except it adds any
3237 ;; additional Xrefs (in case the two articles came from different
3239 ;; Also sets `header' to `nil' meaning that the `dependencies'
3240 ;; table was *not* modified.
3242 (mail-header-set-xref
3243 (car (symbol-value id-dep))
3244 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3246 (or (mail-header-xref header) "")))
3250 ;; First check if that we are not creating a References loop.
3251 (setq ref (gnus-parent-id (mail-header-references header)))
3253 (setq ref-dep (intern-soft ref dependencies))
3255 (setq ref-header (car (symbol-value ref-dep))))
3256 (if (string= id ref)
3257 ;; Yuk! This is a reference loop. Make the article be a
3260 (mail-header-set-references (car (symbol-value id-dep)) "none")
3262 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3263 (setq ref (gnus-parent-id (mail-header-references header)))
3264 (setq ref-dep (intern (or ref "none") dependencies))
3265 (if (boundp ref-dep)
3266 (setcdr (symbol-value ref-dep)
3267 (nconc (cdr (symbol-value ref-dep))
3268 (list (symbol-value id-dep))))
3269 (set ref-dep (list nil (symbol-value id-dep)))))
3272 (defun gnus-build-sparse-threads ()
3273 (let ((headers gnus-newsgroup-headers)
3274 (mail-parse-charset gnus-newsgroup-charset)
3275 (gnus-summary-ignore-duplicates t)
3276 header references generation relations
3277 subject child end new-child date)
3278 ;; First we create an alist of generations/relations, where
3279 ;; generations is how much we trust the relation, and the relation
3281 (gnus-message 7 "Making sparse threads...")
3283 (nnheader-set-temp-buffer " *gnus sparse threads*")
3284 (while (setq header (pop headers))
3285 (when (and (setq references (mail-header-references header))
3286 (not (string= references "")))
3288 (setq child (mail-header-id header)
3289 subject (mail-header-subject header)
3290 date (mail-header-date header)
3292 (while (search-backward ">" nil t)
3293 (setq end (1+ (point)))
3294 (when (search-backward "<" nil t)
3295 (setq new-child (buffer-substring (point) end))
3296 (push (list (incf generation)
3297 child (setq child new-child)
3301 (push (list (1+ generation) child nil subject) relations))
3303 (kill-buffer (current-buffer)))
3304 ;; Sort over trustworthiness.
3307 (when (gnus-dependencies-add-header
3308 (make-full-mail-header-from-decoded-header
3309 gnus-reffed-article-number
3310 (nth 3 relation) "" (or (nth 4 relation) "")
3312 (or (nth 2 relation) "") 0 0 "")
3313 gnus-newsgroup-dependencies nil)
3314 (push gnus-reffed-article-number gnus-newsgroup-limit)
3315 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3316 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3317 gnus-newsgroup-reads)
3318 (decf gnus-reffed-article-number)))
3319 (sort relations 'car-less-than-car))
3320 (gnus-message 7 "Making sparse threads...done")))
3322 (defun gnus-build-old-threads ()
3323 ;; Look at all the articles that refer back to old articles, and
3324 ;; fetch the headers for the articles that aren't there. This will
3325 ;; build complete threads - if the roots haven't been expired by the
3327 (let ((mail-parse-charset gnus-newsgroup-charset)
3331 (when (not (car (symbol-value refs)))
3332 (setq heads (cdr (symbol-value refs)))
3334 (if (memq (mail-header-number (caar heads))
3335 gnus-newsgroup-dormant)
3336 (setq heads (cdr heads))
3337 (setq id (symbol-name refs))
3338 (while (and (setq id (gnus-build-get-header id))
3339 (not (car (gnus-id-to-thread id)))))
3340 (setq heads nil)))))
3341 gnus-newsgroup-dependencies)))
3343 ;; This function has to be called with point after the article number
3344 ;; on the beginning of the line.
3345 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3346 (let ((eol (gnus-point-at-eol))
3347 (buffer (current-buffer))
3350 ;; overview: [num subject from date id refs chars lines misc]
3353 (narrow-to-region (point) eol)
3358 (make-full-mail-header
3360 (nnheader-nov-field) ; subject
3361 (nnheader-nov-field) ; from
3362 (nnheader-nov-field) ; date
3363 (nnheader-nov-read-message-id) ; id
3364 (nnheader-nov-field) ; refs
3365 (nnheader-nov-read-integer) ; chars
3366 (nnheader-nov-read-integer) ; lines
3368 (if (looking-at "Xref: ")
3369 (goto-char (match-end 0)))
3370 (nnheader-nov-field)) ; Xref
3371 (nnheader-nov-parse-extra)))) ; extra
3375 (when gnus-alter-header-function
3376 (funcall gnus-alter-header-function header))
3377 (gnus-dependencies-add-header header dependencies force-new)))
3379 (defun gnus-build-get-header (id)
3380 "Look through the buffer of NOV lines and find the header to ID.
3381 Enter this line into the dependencies hash table, and return
3382 the id of the parent article (if any)."
3383 (let ((deps gnus-newsgroup-dependencies)
3387 (set-buffer nntp-server-buffer)
3388 (let ((case-fold-search nil))
3389 (goto-char (point-min))
3390 (while (and (not found)
3391 (search-forward id nil t))
3393 (setq found (looking-at
3394 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3395 (regexp-quote id))))
3396 (or found (beginning-of-line 2)))
3400 (setq header (gnus-nov-parse-line
3401 (read (current-buffer)) deps))
3402 (gnus-parent-id (mail-header-references header))))))
3404 (let ((number (mail-header-number header)))
3405 (push number gnus-newsgroup-limit)
3406 (push header gnus-newsgroup-headers)
3407 (if (memq number gnus-newsgroup-unselected)
3409 (push number gnus-newsgroup-unreads)
3410 (setq gnus-newsgroup-unselected
3411 (delq number gnus-newsgroup-unselected)))
3412 (push number gnus-newsgroup-ancient)))))))
3414 (defun gnus-build-all-threads ()
3415 "Read all the headers."
3416 (let ((gnus-summary-ignore-duplicates t)
3417 (mail-parse-charset gnus-newsgroup-charset)
3418 (dependencies gnus-newsgroup-dependencies)
3421 (set-buffer nntp-server-buffer)
3422 (let ((case-fold-search nil))
3423 (goto-char (point-min))
3426 (setq article (read (current-buffer))
3427 header (gnus-nov-parse-line article dependencies)))
3430 (set-buffer gnus-summary-buffer)
3431 (push header gnus-newsgroup-headers)
3432 (if (memq (setq article (mail-header-number header))
3433 gnus-newsgroup-unselected)
3435 (push article gnus-newsgroup-unreads)
3436 (setq gnus-newsgroup-unselected
3437 (delq article gnus-newsgroup-unselected)))
3438 (push article gnus-newsgroup-ancient)))
3439 (forward-line 1)))))))
3441 (defun gnus-summary-update-article-line (article header)
3442 "Update the line for ARTICLE using HEADERS."
3443 (let* ((id (mail-header-id header))
3444 (thread (gnus-id-to-thread id)))
3446 (error "Article in no thread"))
3447 ;; Update the thread.
3448 (setcar thread header)
3449 (gnus-summary-goto-subject article)
3450 (let* ((datal (gnus-data-find-list article))
3452 (length (when (cdr datal)
3453 (- (gnus-data-pos data)
3454 (gnus-data-pos (cadr datal)))))
3455 (buffer-read-only nil)
3456 (level (gnus-summary-thread-level)))
3458 (gnus-summary-insert-line
3459 header level nil (gnus-article-mark article)
3460 (memq article gnus-newsgroup-replied)
3461 (memq article gnus-newsgroup-expirable)
3462 ;; Only insert the Subject string when it's different
3463 ;; from the previous Subject string.
3468 (mail-header-subject
3471 (gnus-data-find-list
3473 (gnus-data-list t)))))
3474 ;; Error on the side of excessive subjects.
3476 (mail-header-subject header)))
3478 (mail-header-subject header))
3479 nil (cdr (assq article gnus-newsgroup-scored))
3480 (memq article gnus-newsgroup-processable))
3482 (gnus-data-update-list
3483 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3485 (defun gnus-summary-update-article (article &optional iheader)
3486 "Update ARTICLE in the summary buffer."
3487 (set-buffer gnus-summary-buffer)
3488 (let* ((header (gnus-summary-article-header article))
3489 (id (mail-header-id header))
3490 (data (gnus-data-find article))
3491 (thread (gnus-id-to-thread id))
3492 (references (mail-header-references header))
3496 (when (and references
3497 (not (equal "" references)))
3500 (buffer-read-only nil)
3506 (delq thread parent)))
3507 (if (gnus-summary-insert-subject id header)
3508 ;; Set the (possibly) new article number in the data structure.
3509 (gnus-data-set-number data (gnus-id-to-article id))
3513 (defun gnus-rebuild-thread (id &optional line)
3514 "Rebuild the thread containing ID.
3515 If LINE, insert the rebuilt thread starting on line LINE."
3516 (let ((buffer-read-only nil)
3517 old-pos current thread data)
3518 (if (not gnus-show-threads)
3519 (setq thread (list (car (gnus-id-to-thread id))))
3520 ;; Get the thread this article is part of.
3521 (setq thread (gnus-remove-thread id)))
3522 (setq old-pos (gnus-point-at-bol))
3523 (setq current (save-excursion
3524 (and (zerop (forward-line -1))
3525 (gnus-summary-article-number))))
3526 ;; If this is a gathered thread, we have to go some re-gathering.
3527 (when (stringp (car thread))
3528 (let ((subject (car thread))
3530 (setq thread (cdr thread))
3532 (unless (memq (setq thr (gnus-id-to-thread
3534 (mail-header-id (caar thread)))))
3537 (setq thread (cdr thread)))
3538 ;; We now have all (unique) roots.
3539 (if (= (length roots) 1)
3540 ;; All the loose roots are now one solid root.
3541 (setq thread (car roots))
3542 (setq thread (cons subject (gnus-sort-threads roots))))))
3544 ;; We then insert this thread into the summary buffer.
3546 (goto-char (point-min))
3547 (forward-line (1- line)))
3548 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3549 (if gnus-show-threads
3550 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3551 (gnus-summary-prepare-unthreaded thread))
3552 (setq data (nreverse gnus-newsgroup-data))
3553 (setq threads gnus-newsgroup-threads))
3554 ;; We splice the new data into the data structure.
3555 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3556 ;;!!! then we want to insert at the beginning of the buffer.
3557 ;;!!! That happens to be true with Gnus now, but that may
3558 ;;!!! change in the future. Perhaps.
3559 (gnus-data-enter-list
3560 (if line nil current) data (- (point) old-pos))
3561 (setq gnus-newsgroup-threads
3562 (nconc threads gnus-newsgroup-threads))
3563 (gnus-data-compute-positions))))
3565 (defun gnus-number-to-header (number)
3566 "Return the header for article NUMBER."
3567 (let ((headers gnus-newsgroup-headers))
3569 (not (= number (mail-header-number (car headers)))))
3574 (defun gnus-parent-headers (in-headers &optional generation)
3575 "Return the headers of the GENERATIONeth parent of HEADERS."
3577 (setq generation 1))
3579 (headers in-headers)
3582 (not (zerop generation))
3583 (setq references (mail-header-references headers)))
3584 (setq headers (if (and references
3585 (setq parent (gnus-parent-id references)))
3586 (car (gnus-id-to-thread parent))
3589 (and (not (eq headers in-headers))
3592 (defun gnus-id-to-thread (id)
3593 "Return the (sub-)thread where ID appears."
3594 (gnus-gethash id gnus-newsgroup-dependencies))
3596 (defun gnus-id-to-article (id)
3597 "Return the article number of ID."
3598 (let ((thread (gnus-id-to-thread id)))
3601 (mail-header-number (car thread)))))
3603 (defun gnus-id-to-header (id)
3604 "Return the article headers of ID."
3605 (car (gnus-id-to-thread id)))
3607 (defun gnus-article-displayed-root-p (article)
3608 "Say whether ARTICLE is a root(ish) article."
3609 (let ((level (gnus-summary-thread-level article))
3610 (refs (mail-header-references (gnus-summary-article-header article)))
3616 ((null (gnus-parent-id refs)) t)
3618 (null (setq particle (gnus-id-to-article
3619 (gnus-parent-id refs))))
3620 (null (gnus-summary-thread-level particle)))))))
3622 (defun gnus-root-id (id)
3623 "Return the id of the root of the thread where ID appears."
3625 (while (and id (setq prev (car (gnus-id-to-thread id))))
3627 id (gnus-parent-id (mail-header-references prev))))
3630 (defun gnus-articles-in-thread (thread)
3631 "Return the list of articles in THREAD."
3632 (cons (mail-header-number (car thread))
3633 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3635 (defun gnus-remove-thread (id &optional dont-remove)
3636 "Remove the thread that has ID in it."
3637 (let (headers thread last-id)
3638 ;; First go up in this thread until we find the root.
3639 (setq last-id (gnus-root-id id)
3640 headers (message-flatten-list (gnus-id-to-thread last-id)))
3641 ;; We have now found the real root of this thread. It might have
3642 ;; been gathered into some loose thread, so we have to search
3643 ;; through the threads to find the thread we wanted.
3644 (let ((threads gnus-newsgroup-threads)
3647 (setq sub (car threads))
3648 (if (stringp (car sub))
3649 ;; This is a gathered thread, so we look at the roots
3650 ;; below it to find whether this article is in this
3653 (setq sub (cdr sub))
3655 (when (member (caar sub) headers)
3656 (setq thread (car threads)
3659 (setq sub (cdr sub))))
3660 ;; It's an ordinary thread, so we check it.
3661 (when (eq (car sub) (car headers))
3664 (setq threads (cdr threads)))
3665 ;; If this article is in no thread, then it's a root.
3668 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3669 (setq thread (gnus-id-to-thread last-id)))
3672 thread ; We return this thread.
3674 (if (stringp (car thread))
3676 ;; If we use dummy roots, then we have to remove the
3677 ;; dummy root as well.
3678 (when (eq gnus-summary-make-false-root 'dummy)
3679 ;; We go to the dummy root by going to
3680 ;; the first sub-"thread", and then one line up.
3681 (gnus-summary-goto-article
3682 (mail-header-number (caadr thread)))
3685 (gnus-data-compute-positions))
3686 (setq thread (cdr thread))
3688 (gnus-remove-thread-1 (car thread))
3689 (setq thread (cdr thread))))
3690 (gnus-remove-thread-1 thread))))))))
3692 (defun gnus-remove-thread-1 (thread)
3693 "Remove the thread THREAD recursively."
3694 (let ((number (mail-header-number (pop thread)))
3696 (setq thread (reverse thread))
3698 (gnus-remove-thread-1 (pop thread)))
3699 (when (setq d (gnus-data-find number))
3700 (goto-char (gnus-data-pos d))
3701 (gnus-summary-show-thread)
3704 (- (gnus-point-at-bol)
3706 (1+ (gnus-point-at-eol))
3707 (gnus-delete-line)))))))
3709 (defun gnus-sort-threads-1 (threads func)
3710 (sort (mapcar (lambda (thread)
3713 (gnus-sort-threads-1 (cdr thread) func))))
3716 (defun gnus-sort-threads (threads)
3718 (if (not gnus-thread-sort-functions)
3720 (gnus-message 8 "Sorting threads...")
3722 (gnus-sort-threads-1
3724 (gnus-make-sort-function gnus-thread-sort-functions))
3725 (gnus-message 8 "Sorting threads...done"))))
3727 (defun gnus-sort-articles (articles)
3729 (when gnus-article-sort-functions
3730 (gnus-message 7 "Sorting articles...")
3732 (setq gnus-newsgroup-headers
3733 (sort articles (gnus-make-sort-function
3734 gnus-article-sort-functions)))
3735 (gnus-message 7 "Sorting articles...done"))))
3737 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3738 (defmacro gnus-thread-header (thread)
3739 "Return header of first article in THREAD.
3740 Note that THREAD must never, ever be anything else than a variable -
3741 using some other form will lead to serious barfage."
3742 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3743 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3744 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3747 (defsubst gnus-article-sort-by-number (h1 h2)
3748 "Sort articles by article number."
3749 (< (mail-header-number h1)
3750 (mail-header-number h2)))
3752 (defun gnus-thread-sort-by-number (h1 h2)
3753 "Sort threads by root article number."
3754 (gnus-article-sort-by-number
3755 (gnus-thread-header h1) (gnus-thread-header h2)))
3757 (defsubst gnus-article-sort-by-lines (h1 h2)
3758 "Sort articles by article Lines header."
3759 (< (mail-header-lines h1)
3760 (mail-header-lines h2)))
3762 (defun gnus-thread-sort-by-lines (h1 h2)
3763 "Sort threads by root article Lines header."
3764 (gnus-article-sort-by-lines
3765 (gnus-thread-header h1) (gnus-thread-header h2)))
3767 (defsubst gnus-article-sort-by-chars (h1 h2)
3768 "Sort articles by octet length."
3769 (< (mail-header-chars h1)
3770 (mail-header-chars h2)))
3772 (defun gnus-thread-sort-by-chars (h1 h2)
3773 "Sort threads by root article octet length."
3774 (gnus-article-sort-by-chars
3775 (gnus-thread-header h1) (gnus-thread-header h2)))
3777 (defsubst gnus-article-sort-by-author (h1 h2)
3778 "Sort articles by root author."
3780 (let ((addr (car (mime-entity-read-field h1 'From))))
3781 (or (std11-full-name-string addr)
3782 (std11-address-string addr)
3784 (let ((addr (car (mime-entity-read-field h2 'From))))
3785 (or (std11-full-name-string addr)
3786 (std11-address-string addr)
3790 (defun gnus-thread-sort-by-author (h1 h2)
3791 "Sort threads by root author."
3792 (gnus-article-sort-by-author
3793 (gnus-thread-header h1) (gnus-thread-header h2)))
3795 (defsubst gnus-article-sort-by-subject (h1 h2)
3796 "Sort articles by root subject."
3798 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3799 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3801 (defun gnus-thread-sort-by-subject (h1 h2)
3802 "Sort threads by root subject."
3803 (gnus-article-sort-by-subject
3804 (gnus-thread-header h1) (gnus-thread-header h2)))
3806 (defsubst gnus-article-sort-by-date (h1 h2)
3807 "Sort articles by root article date."
3809 (gnus-date-get-time (mail-header-date h1))
3810 (gnus-date-get-time (mail-header-date h2))))
3812 (defun gnus-thread-sort-by-date (h1 h2)
3813 "Sort threads by root article date."
3814 (gnus-article-sort-by-date
3815 (gnus-thread-header h1) (gnus-thread-header h2)))
3817 (defsubst gnus-article-sort-by-score (h1 h2)
3818 "Sort articles by root article score.
3819 Unscored articles will be counted as having a score of zero."
3820 (> (or (cdr (assq (mail-header-number h1)
3821 gnus-newsgroup-scored))
3822 gnus-summary-default-score 0)
3823 (or (cdr (assq (mail-header-number h2)
3824 gnus-newsgroup-scored))
3825 gnus-summary-default-score 0)))
3827 (defun gnus-thread-sort-by-score (h1 h2)
3828 "Sort threads by root article score."
3829 (gnus-article-sort-by-score
3830 (gnus-thread-header h1) (gnus-thread-header h2)))
3832 (defun gnus-thread-sort-by-total-score (h1 h2)
3833 "Sort threads by the sum of all scores in the thread.
3834 Unscored articles will be counted as having a score of zero."
3835 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3837 (defun gnus-thread-total-score (thread)
3838 ;; This function find the total score of THREAD.
3839 (cond ((null thread)
3842 (if (stringp (car thread))
3843 (apply gnus-thread-score-function 0
3844 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3845 (gnus-thread-total-score-1 thread)))
3847 (gnus-thread-total-score-1 (list thread)))))
3849 (defun gnus-thread-total-score-1 (root)
3850 ;; This function find the total score of the thread below ROOT.
3851 (setq root (car root))
3852 (apply gnus-thread-score-function
3854 (mapcar 'gnus-thread-total-score
3855 (cdr (gnus-id-to-thread (mail-header-id root))))
3856 (when (> (mail-header-number root) 0)
3857 (list (or (cdr (assq (mail-header-number root)
3858 gnus-newsgroup-scored))
3859 gnus-summary-default-score 0))))
3860 (list gnus-summary-default-score)
3863 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3864 (defvar gnus-tmp-prev-subject nil)
3865 (defvar gnus-tmp-false-parent nil)
3866 (defvar gnus-tmp-root-expunged nil)
3867 (defvar gnus-tmp-dummy-line nil)
3869 (defvar gnus-tmp-header)
3870 (defun gnus-extra-header (type &optional header)
3871 "Return the extra header of TYPE."
3872 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3875 (defun gnus-summary-prepare-threads (threads)
3876 "Prepare summary buffer from THREADS and indentation LEVEL.
3877 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3878 or a straight list of headers."
3879 (gnus-message 7 "Generating summary...")
3881 (setq gnus-newsgroup-threads threads)
3884 (let ((gnus-tmp-level 0)
3885 (default-score (or gnus-summary-default-score 0))
3886 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3887 thread number subject stack state gnus-tmp-gathered beg-match
3888 new-roots gnus-tmp-new-adopts thread-end
3889 gnus-tmp-header gnus-tmp-unread
3890 gnus-tmp-replied gnus-tmp-subject-or-nil
3891 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3892 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3893 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3895 (setq gnus-tmp-prev-subject nil)
3897 (if (vectorp (car threads))
3898 ;; If this is a straight (sic) list of headers, then a
3899 ;; threaded summary display isn't required, so we just create
3900 ;; an unthreaded one.
3901 (gnus-summary-prepare-unthreaded threads)
3903 ;; Do the threaded display.
3905 (while (or threads stack gnus-tmp-new-adopts new-roots)
3907 (if (and (= gnus-tmp-level 0)
3910 (not gnus-tmp-false-parent)
3911 (or gnus-tmp-new-adopts new-roots))
3912 (if gnus-tmp-new-adopts
3913 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3914 thread (list (car gnus-tmp-new-adopts))
3915 gnus-tmp-header (caar thread)
3916 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3918 (setq thread (list (car new-roots))
3919 gnus-tmp-header (caar thread)
3920 new-roots (cdr new-roots))))
3923 ;; If there are some threads, we do them before the
3924 ;; threads on the stack.
3925 (setq thread threads
3926 gnus-tmp-header (caar thread))
3927 ;; There were no current threads, so we pop something off
3929 (setq state (car stack)
3930 gnus-tmp-level (car state)
3933 gnus-tmp-header (caar thread))))
3935 (setq gnus-tmp-false-parent nil)
3936 (setq gnus-tmp-root-expunged nil)
3937 (setq thread-end nil)
3939 (if (stringp gnus-tmp-header)
3940 ;; The header is a dummy root.
3942 ((eq gnus-summary-make-false-root 'adopt)
3943 ;; We let the first article adopt the rest.
3944 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3946 (setq gnus-tmp-gathered
3948 (lambda (h) (mail-header-number (car h)))
3951 (setq thread (cons (list (caar thread)
3954 (setq gnus-tmp-level -1
3955 gnus-tmp-false-parent t))
3956 ((eq gnus-summary-make-false-root 'empty)
3957 ;; We print adopted articles with empty subject fields.
3958 (setq gnus-tmp-gathered
3960 (lambda (h) (mail-header-number (car h)))
3963 (setq gnus-tmp-level -1))
3964 ((eq gnus-summary-make-false-root 'dummy)
3965 ;; We remember that we probably want to output a dummy
3967 (setq gnus-tmp-dummy-line gnus-tmp-header)
3968 (setq gnus-tmp-prev-subject gnus-tmp-header))
3970 ;; We do not make a root for the gathered
3971 ;; sub-threads at all.
3972 (setq gnus-tmp-level -1)))
3974 (setq number (mail-header-number gnus-tmp-header)
3975 subject (mail-header-subject gnus-tmp-header))
3978 ;; If the thread has changed subject, we might want to make
3979 ;; this subthread into a root.
3980 ((and (null gnus-thread-ignore-subject)
3981 (not (zerop gnus-tmp-level))
3982 gnus-tmp-prev-subject
3984 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3985 (setq new-roots (nconc new-roots (list (car thread)))
3987 gnus-tmp-header nil))
3988 ;; If the article lies outside the current limit,
3989 ;; then we do not display it.
3990 ((not (memq number gnus-newsgroup-limit))
3991 (setq gnus-tmp-gathered
3993 (lambda (h) (mail-header-number (car h)))
3996 (setq gnus-tmp-new-adopts (if (cdar thread)
3997 (append gnus-tmp-new-adopts
3999 gnus-tmp-new-adopts)
4001 gnus-tmp-header nil)
4002 (when (zerop gnus-tmp-level)
4003 (setq gnus-tmp-root-expunged t)))
4004 ;; Perhaps this article is to be marked as read?
4005 ((and gnus-summary-mark-below
4006 (< (or (cdr (assq number gnus-newsgroup-scored))
4008 gnus-summary-mark-below)
4009 ;; Don't touch sparse articles.
4010 (not (gnus-summary-article-sparse-p number))
4011 (not (gnus-summary-article-ancient-p number)))
4012 (setq gnus-newsgroup-unreads
4013 (delq number gnus-newsgroup-unreads))
4014 (if gnus-newsgroup-auto-expire
4015 (push number gnus-newsgroup-expirable)
4016 (push (cons number gnus-low-score-mark)
4017 gnus-newsgroup-reads))))
4019 (when gnus-tmp-header
4020 ;; We may have an old dummy line to output before this
4022 (when (and gnus-tmp-dummy-line
4025 (mail-header-subject gnus-tmp-header)))
4026 (gnus-summary-insert-dummy-line
4027 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4028 (setq gnus-tmp-dummy-line nil))
4030 ;; Compute the mark.
4031 (setq gnus-tmp-unread (gnus-article-mark number))
4033 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4034 gnus-tmp-header gnus-tmp-level)
4035 gnus-newsgroup-data)
4037 ;; Actually insert the line.
4039 gnus-tmp-subject-or-nil
4041 ((and gnus-thread-ignore-subject
4042 gnus-tmp-prev-subject
4043 (not (inline (gnus-subject-equal
4044 gnus-tmp-prev-subject subject))))
4046 ((zerop gnus-tmp-level)
4047 (if (and (eq gnus-summary-make-false-root 'empty)
4048 (memq number gnus-tmp-gathered)
4049 gnus-tmp-prev-subject
4050 (inline (gnus-subject-equal
4051 gnus-tmp-prev-subject subject)))
4052 gnus-summary-same-subject
4054 (t gnus-summary-same-subject)))
4055 (if (and (eq gnus-summary-make-false-root 'adopt)
4056 (= gnus-tmp-level 1)
4057 (memq number gnus-tmp-gathered))
4058 (setq gnus-tmp-opening-bracket ?\<
4059 gnus-tmp-closing-bracket ?\>)
4060 (setq gnus-tmp-opening-bracket ?\[
4061 gnus-tmp-closing-bracket ?\]))
4063 gnus-tmp-indentation
4064 (aref gnus-thread-indent-array gnus-tmp-level)
4065 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4066 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4067 gnus-summary-default-score 0)
4069 (if (or (null gnus-summary-default-score)
4070 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4071 gnus-summary-zcore-fuzz))
4073 (if (< gnus-tmp-score gnus-summary-default-score)
4074 gnus-score-below-mark gnus-score-over-mark))
4076 (cond ((memq number gnus-newsgroup-processable)
4078 ((memq number gnus-newsgroup-cached)
4080 ((memq number gnus-newsgroup-replied)
4082 ((memq number gnus-newsgroup-saved)
4084 (t gnus-unread-mark))
4085 gnus-tmp-from (mail-header-from gnus-tmp-header)
4088 ((string-match "<[^>]+> *$" gnus-tmp-from)
4089 (setq beg-match (match-beginning 0))
4090 (or (and (string-match "^\".+\"" gnus-tmp-from)
4091 (substring gnus-tmp-from 1 (1- (match-end 0))))
4092 (substring gnus-tmp-from 0 beg-match)))
4093 ((string-match "(.+)" gnus-tmp-from)
4094 (substring gnus-tmp-from
4095 (1+ (match-beginning 0)) (1- (match-end 0))))
4097 (when (string= gnus-tmp-name "")
4098 (setq gnus-tmp-name gnus-tmp-from))
4099 (unless (numberp gnus-tmp-lines)
4100 (setq gnus-tmp-lines 0))
4101 (gnus-put-text-property
4103 (progn (eval gnus-summary-line-format-spec) (point))
4104 'gnus-number number)
4107 (gnus-run-hooks 'gnus-summary-update-hook)
4110 (setq gnus-tmp-prev-subject subject)))
4112 (when (nth 1 thread)
4113 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4114 (incf gnus-tmp-level)
4115 (setq threads (if thread-end nil (cdar thread)))
4117 (setq gnus-tmp-level 0)))))
4118 (gnus-message 7 "Generating summary...done"))
4120 (defun gnus-summary-prepare-unthreaded (headers)
4121 "Generate an unthreaded summary buffer based on HEADERS."
4122 (let (header number mark)
4127 ;; We may have to root out some bad articles...
4128 (when (memq (setq number (mail-header-number
4129 (setq header (pop headers))))
4130 gnus-newsgroup-limit)
4131 ;; Mark article as read when it has a low score.
4132 (when (and gnus-summary-mark-below
4133 (< (or (cdr (assq number gnus-newsgroup-scored))
4134 gnus-summary-default-score 0)
4135 gnus-summary-mark-below)
4136 (not (gnus-summary-article-ancient-p number)))
4137 (setq gnus-newsgroup-unreads
4138 (delq number gnus-newsgroup-unreads))
4139 (if gnus-newsgroup-auto-expire
4140 (push number gnus-newsgroup-expirable)
4141 (push (cons number gnus-low-score-mark)
4142 gnus-newsgroup-reads)))
4144 (setq mark (gnus-article-mark number))
4145 (push (gnus-data-make number mark (1+ (point)) header 0)
4146 gnus-newsgroup-data)
4147 (gnus-summary-insert-line
4149 mark (memq number gnus-newsgroup-replied)
4150 (memq number gnus-newsgroup-expirable)
4151 (mail-header-subject header) nil
4152 (cdr (assq number gnus-newsgroup-scored))
4153 (memq number gnus-newsgroup-processable))))))
4155 (defun gnus-summary-remove-list-identifiers ()
4156 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4157 (let ((regexp (if (stringp gnus-list-identifiers)
4158 gnus-list-identifiers
4159 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4160 (dolist (header gnus-newsgroup-headers)
4161 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4162 " *\\)\\)+\\(Re: +\\)?\\)")
4163 (mail-header-subject header))
4164 (mail-header-set-subject
4165 header (concat (substring (mail-header-subject header)
4166 0 (match-beginning 1))
4168 (match-string 3 (mail-header-subject header))
4169 (match-string 5 (mail-header-subject header)))
4170 (substring (mail-header-subject header)
4171 (match-end 1))))))))
4173 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4174 "Select newsgroup GROUP.
4175 If READ-ALL is non-nil, all articles in the group are selected.
4176 If SELECT-ARTICLES, only select those articles from GROUP."
4177 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4178 ;;!!! Dirty hack; should be removed.
4179 (gnus-summary-ignore-duplicates
4180 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4182 gnus-summary-ignore-duplicates))
4183 (info (nth 2 entry))
4184 articles fetched-articles cached)
4186 (unless (gnus-check-server
4187 (setq gnus-current-select-method
4188 (gnus-find-method-for-group group)))
4189 (error "Couldn't open server"))
4191 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4192 (gnus-activate-group group) ; Or we can activate it...
4193 (progn ; Or we bug out.
4194 (when (equal major-mode 'gnus-summary-mode)
4195 (kill-buffer (current-buffer)))
4196 (error "Couldn't request group %s: %s"
4197 group (gnus-status-message group))))
4199 (unless (gnus-request-group group t)
4200 (when (equal major-mode 'gnus-summary-mode)
4201 (kill-buffer (current-buffer)))
4202 (error "Couldn't request group %s: %s"
4203 group (gnus-status-message group)))
4205 (setq gnus-newsgroup-name group)
4206 (setq gnus-newsgroup-unselected nil)
4207 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4208 (gnus-summary-setup-default-charset)
4210 ;; Adjust and set lists of article marks.
4212 (gnus-adjust-marked-articles info))
4214 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4216 (if (gnus-virtual-group-p group)
4217 gnus-newsgroup-cached
4218 (gnus-cache-articles-in-group group)))
4220 (setq gnus-newsgroup-unreads
4221 (gnus-set-difference
4222 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4223 gnus-newsgroup-dormant))
4225 (setq gnus-newsgroup-processable nil)
4227 (gnus-update-read-articles group gnus-newsgroup-unreads)
4229 (if (setq articles select-articles)
4230 (setq gnus-newsgroup-unselected
4231 (gnus-sorted-intersection
4232 gnus-newsgroup-unreads
4233 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4234 (setq articles (gnus-articles-to-read group read-all)))
4238 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4240 ((eq articles 0) nil)
4242 ;; Init the dependencies hash table.
4243 (setq gnus-newsgroup-dependencies
4244 (gnus-make-hashtable (length articles)))
4245 (gnus-set-global-variables)
4246 ;; Retrieve the headers and read them in.
4247 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4248 (setq gnus-newsgroup-headers
4249 (gnus-retrieve-parsed-headers
4250 articles gnus-newsgroup-name
4251 ;; We might want to fetch old headers, but
4252 ;; not if there is only 1 article.
4253 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4254 (not (numberp gnus-fetch-old-headers)))
4255 (> (length articles) 1))
4256 gnus-fetch-old-headers)))
4257 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4259 ;; Suppress duplicates?
4260 (when gnus-suppress-duplicates
4261 (gnus-dup-suppress-articles))
4263 ;; Set the initial limit.
4264 (setq gnus-newsgroup-limit (copy-sequence articles))
4265 ;; Remove canceled articles from the list of unread articles.
4266 (setq gnus-newsgroup-unreads
4267 (gnus-set-sorted-intersection
4268 gnus-newsgroup-unreads
4269 (setq fetched-articles
4270 (mapcar (lambda (headers) (mail-header-number headers))
4271 gnus-newsgroup-headers))))
4272 ;; Removed marked articles that do not exist.
4273 (gnus-update-missing-marks
4274 (gnus-sorted-complement fetched-articles articles))
4276 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4278 (setq gnus-newsgroup-cached cached))
4280 ;; We might want to build some more threads first.
4281 (when (and gnus-fetch-old-headers
4282 (eq gnus-headers-retrieved-by 'nov))
4283 (if (eq gnus-fetch-old-headers 'invisible)
4284 (gnus-build-all-threads)
4285 (gnus-build-old-threads)))
4286 ;; Let the Gnus agent mark articles as read.
4288 (gnus-agent-get-undownloaded-list))
4289 ;; Remove list identifiers from subject
4290 (when gnus-list-identifiers
4291 (gnus-summary-remove-list-identifiers))
4292 ;; Check whether auto-expire is to be done in this group.
4293 (setq gnus-newsgroup-auto-expire
4294 (gnus-group-auto-expirable-p group))
4295 ;; Set up the article buffer now, if necessary.
4296 (unless gnus-single-article-buffer
4297 (gnus-article-setup-buffer))
4298 ;; First and last article in this newsgroup.
4299 (when gnus-newsgroup-headers
4300 (setq gnus-newsgroup-begin
4301 (mail-header-number (car gnus-newsgroup-headers))
4304 (gnus-last-element gnus-newsgroup-headers))))
4305 ;; GROUP is successfully selected.
4306 (or gnus-newsgroup-headers t)))))
4308 (defun gnus-articles-to-read (group &optional read-all)
4309 "Find out what articles the user wants to read."
4311 ;; Select all articles if `read-all' is non-nil, or if there
4312 ;; are no unread articles.
4314 (and (zerop (length gnus-newsgroup-marked))
4315 (zerop (length gnus-newsgroup-unreads)))
4316 (eq (gnus-group-find-parameter group 'display)
4319 (gnus-uncompress-range (gnus-active group))
4320 (gnus-cache-articles-in-group group))
4321 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4322 (copy-sequence gnus-newsgroup-unreads))
4324 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4325 (scored (length scored-list))
4326 (number (length articles))
4327 (marked (+ (length gnus-newsgroup-marked)
4328 (length gnus-newsgroup-dormant)))
4336 ((and (or (<= scored marked) (= scored number))
4337 (natnump gnus-large-newsgroup)
4338 (> number gnus-large-newsgroup))
4339 (let* ((cursor-in-echo-area nil)
4340 (input (read-from-minibuffer
4342 "How many articles from %s (max %d): "
4343 (gnus-limit-string gnus-newsgroup-name 35)
4345 (cons (number-to-string gnus-large-newsgroup)
4347 (if (string-match "^[ \t]*$" input)
4350 ((and (> scored marked) (< scored number)
4351 (> (- scored number) 20))
4354 (format "%s %s (%d scored, %d total): "
4355 "How many articles from"
4356 group scored number))))
4357 (if (string-match "^[ \t]*$" input)
4361 (message "Quit getting the articles to read")
4363 (setq select (if (stringp select) (string-to-number select) select))
4364 (if (or (null select) (zerop select))
4366 (if (and (not (zerop scored)) (<= (abs select) scored))
4368 (setq articles (sort scored-list '<))
4369 (setq number (length articles)))
4370 (setq articles (copy-sequence articles)))
4372 (when (< (abs select) number)
4374 ;; Select the N oldest articles.
4375 (setcdr (nthcdr (1- (abs select)) articles) nil)
4376 ;; Select the N most recent articles.
4377 (setq articles (nthcdr (- number select) articles))))
4378 (setq gnus-newsgroup-unselected
4379 (gnus-sorted-intersection
4380 gnus-newsgroup-unreads
4381 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4382 (when gnus-alter-articles-to-read-function
4383 (setq gnus-newsgroup-unreads
4385 (funcall gnus-alter-articles-to-read-function
4386 gnus-newsgroup-name gnus-newsgroup-unreads)
4390 (defun gnus-killed-articles (killed articles)
4393 (when (inline (gnus-member-of-range (car articles) killed))
4394 (push (car articles) out))
4395 (setq articles (cdr articles)))
4398 (defun gnus-uncompress-marks (marks)
4399 "Uncompress the mark ranges in MARKS."
4400 (let ((uncompressed '(score bookmark))
4403 (if (memq (caar marks) uncompressed)
4404 (push (car marks) out)
4405 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4406 (setq marks (cdr marks)))
4409 (defun gnus-adjust-marked-articles (info)
4410 "Set all article lists and remove all marks that are no longer valid."
4411 (let* ((marked-lists (gnus-info-marks info))
4412 (active (gnus-active (gnus-info-group info)))
4415 (types gnus-article-mark-lists)
4416 (uncompressed '(score bookmark killed))
4417 marks var articles article mark)
4420 (setq marks (pop marked-lists))
4421 (set (setq var (intern (format "gnus-newsgroup-%s"
4422 (car (rassq (setq mark (car marks))
4424 (if (memq (car marks) uncompressed) (cdr marks)
4425 (gnus-uncompress-range (cdr marks))))
4427 (setq articles (symbol-value var))
4429 ;; All articles have to be subsets of the active articles.
4431 ;; Adjust "simple" lists.
4432 ((memq mark '(tick dormant expire reply save))
4434 (when (or (< (setq article (pop articles)) min) (> article max))
4435 (set var (delq article (symbol-value var))))))
4437 ((memq mark uncompressed)
4438 (when (not (listp (cdr (symbol-value var))))
4439 (set var (list (symbol-value var))))
4440 (when (not (listp (cdr articles)))
4441 (setq articles (list articles)))
4443 (when (or (not (consp (setq article (pop articles))))
4444 (< (car article) min)
4445 (> (car article) max))
4446 (set var (delq article (symbol-value var))))))))))
4448 (defun gnus-update-missing-marks (missing)
4449 "Go through the list of MISSING articles and remove them from the mark lists."
4451 (let ((types gnus-article-mark-lists)
4453 ;; Go through all types.
4455 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4456 (when (symbol-value var)
4457 ;; This list has articles. So we delete all missing articles
4461 (set var (delq (pop m) (symbol-value var)))))))))
4463 (defun gnus-update-marks ()
4464 "Enter the various lists of marked articles into the newsgroup info list."
4465 (let ((types gnus-article-mark-lists)
4466 (info (gnus-get-info gnus-newsgroup-name))
4467 (uncompressed '(score bookmark killed))
4468 type list newmarked symbol delta-marks)
4470 ;; Add all marks lists to the list of marks lists.
4471 (while (setq type (pop types))
4472 (setq list (symbol-value
4474 (intern (format "gnus-newsgroup-%s"
4478 ;; Get rid of the entries of the articles that have the
4480 (when (and (eq (cdr type) 'score)
4484 (prev (cons nil list))
4487 (if (or (not (consp (car arts)))
4488 (= (cdar arts) gnus-summary-default-score))
4489 (setcdr prev (cdr arts))
4491 (setq arts (cdr arts)))
4492 (setq list (cdr all)))))
4494 (unless (memq (cdr type) uncompressed)
4495 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4497 (when (gnus-check-backend-function
4498 'request-set-mark gnus-newsgroup-name)
4499 ;; propagate flags to server, with the following exceptions:
4500 ;; uncompressed:s are not proper flags (they are cons cells)
4501 ;; cache is a internal gnus flag
4502 ;; download are local to one gnus installation (well)
4503 ;; unsend are for nndraft groups only
4504 ;; xxx: generality of this? this suits nnimap anyway
4505 (unless (memq (cdr type) (append '(cache download unsend)
4507 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4508 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4509 (add (gnus-remove-from-range
4510 (gnus-copy-sequence list) old)))
4512 (push (list add 'add (list (cdr type))) delta-marks))
4514 (push (list del 'del (list (cdr type))) delta-marks)))))
4517 (push (cons (cdr type) list) newmarked)))
4520 (unless (gnus-check-group gnus-newsgroup-name)
4521 (error "Can't open server for %s" gnus-newsgroup-name))
4522 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4524 ;; Enter these new marks into the info of the group.
4526 (setcar (nthcdr 3 info) newmarked)
4527 ;; Add the marks lists to the end of the info.
4529 (setcdr (nthcdr 2 info) (list newmarked))))
4531 ;; Cut off the end of the info if there's nothing else there.
4535 (when (nthcdr (decf i) info)
4536 (setcdr (nthcdr i info) nil)))))))
4538 (defun gnus-set-mode-line (where)
4539 "Set the mode line of the article or summary buffers.
4540 If WHERE is `summary', the summary mode line format will be used."
4541 ;; Is this mode line one we keep updated?
4542 (when (and (memq where gnus-updated-mode-lines)
4544 (intern (format "gnus-%s-mode-line-format-spec" where))))
4547 ;; We evaluate this in the summary buffer since these
4548 ;; variables are buffer-local to that buffer.
4549 (set-buffer gnus-summary-buffer)
4550 ;; We bind all these variables that are used in the `eval' form
4552 (let* ((mformat (symbol-value
4554 (format "gnus-%s-mode-line-format-spec" where))))
4555 (gnus-tmp-group-name (gnus-group-name-decode
4557 (gnus-group-name-charset
4559 gnus-newsgroup-name)))
4560 (gnus-tmp-article-number (or gnus-current-article 0))
4561 (gnus-tmp-unread gnus-newsgroup-unreads)
4562 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4563 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4564 (gnus-tmp-unread-and-unselected
4565 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4566 (zerop gnus-tmp-unselected))
4568 ((zerop gnus-tmp-unselected)
4569 (format "{%d more}" gnus-tmp-unread-and-unticked))
4570 (t (format "{%d(+%d) more}"
4571 gnus-tmp-unread-and-unticked
4572 gnus-tmp-unselected))))
4574 (if (and gnus-current-headers
4575 (vectorp gnus-current-headers))
4576 (gnus-mode-string-quote
4577 (mail-header-subject gnus-current-headers))
4579 bufname-length max-len
4580 gnus-tmp-header);; passed as argument to any user-format-funcs
4581 (setq mode-string (eval mformat))
4582 (setq bufname-length (if (string-match "%b" mode-string)
4585 (if (eq where 'summary)
4587 (get-buffer gnus-article-buffer))))
4590 (setq max-len (max 4 (if gnus-mode-non-string-length
4592 gnus-mode-non-string-length
4594 (length mode-string))))
4595 ;; We might have to chop a bit of the string off...
4596 (when (> (length mode-string) max-len)
4598 (concat (gnus-truncate-string mode-string (- max-len 3))
4600 ;; Pad the mode string a bit.
4601 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4602 ;; Update the mode line.
4603 (setq mode-line-buffer-identification
4604 (gnus-mode-line-buffer-identification (list mode-string)))
4605 (set-buffer-modified-p t))))
4607 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4608 "Go through the HEADERS list and add all Xrefs to a hash table.
4609 The resulting hash table is returned, or nil if no Xrefs were found."
4610 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4611 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4612 (xref-hashtb (gnus-make-hashtable))
4613 start group entry number xrefs header)
4615 (setq header (pop headers))
4616 (when (and (setq xrefs (mail-header-xref header))
4617 (not (memq (setq number (mail-header-number header))
4620 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4621 (setq start (match-end 0))
4622 (setq group (if prefix
4623 (concat prefix (substring xrefs (match-beginning 1)
4625 (substring xrefs (match-beginning 1) (match-end 1))))
4627 (string-to-int (substring xrefs (match-beginning 2)
4629 (if (setq entry (gnus-gethash group xref-hashtb))
4630 (setcdr entry (cons number (cdr entry)))
4631 (gnus-sethash group (cons number nil) xref-hashtb)))))
4632 (and start xref-hashtb)))
4634 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4635 "Look through all the headers and mark the Xrefs as read."
4636 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4637 name entry info xref-hashtb idlist method nth4)
4639 (set-buffer gnus-group-buffer)
4640 (when (setq xref-hashtb
4641 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4644 (unless (string= from-newsgroup (setq name (symbol-name group)))
4645 (setq idlist (symbol-value group))
4646 ;; Dead groups are not updated.
4648 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4650 (when (stringp (setq nth4 (gnus-info-method info)))
4651 (setq nth4 (gnus-server-to-method nth4))))
4652 ;; Only do the xrefs if the group has the same
4653 ;; select method as the group we have just read.
4654 (or (gnus-methods-equal-p
4655 nth4 (gnus-find-method-for-group from-newsgroup))
4657 (equal nth4 (setq method (gnus-find-method-for-group
4659 (and (equal (car nth4) (car method))
4660 (equal (nth 1 nth4) (nth 1 method))))
4661 gnus-use-cross-reference
4662 (or (not (eq gnus-use-cross-reference t))
4664 ;; Only do cross-references on subscribed
4665 ;; groups, if that is what is wanted.
4666 (<= (gnus-info-level info) gnus-level-subscribed))
4667 (gnus-group-make-articles-read name idlist))))
4670 (defun gnus-compute-read-articles (group articles)
4671 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4672 (info (nth 2 entry))
4673 (active (gnus-active group))
4676 ;; First peel off all invalid article numbers.
4678 (let ((ids articles)
4680 (while (setq id (pop ids))
4681 (when (and first (> id (cdr active)))
4682 ;; We'll end up in this situation in one particular
4683 ;; obscure situation. If you re-scan a group and get
4684 ;; a new article that is cross-posted to a different
4685 ;; group that has not been re-scanned, you might get
4686 ;; crossposted article that has a higher number than
4687 ;; Gnus believes possible. So we re-activate this
4688 ;; group as well. This might mean doing the
4689 ;; crossposting thingy will *increase* the number
4690 ;; of articles in some groups. Tsk, tsk.
4691 (setq active (or (gnus-activate-group group) active)))
4692 (when (or (> id (cdr active))
4693 (< id (car active)))
4694 (setq articles (delq id articles))))))
4695 ;; If the read list is nil, we init it.
4697 (null (gnus-info-read info))
4699 (setq ninfo (cons 1 (1- (car active))))
4700 (setq ninfo (gnus-info-read info)))
4701 ;; Then we add the read articles to the range.
4703 ninfo (setq articles (sort articles '<))))))
4705 (defun gnus-group-make-articles-read (group articles)
4706 "Update the info of GROUP to say that ARTICLES are read."
4708 (entry (gnus-gethash group gnus-newsrc-hashtb))
4709 (info (nth 2 entry))
4710 (active (gnus-active group))
4713 (setq range (gnus-compute-read-articles group articles))
4715 (set-buffer gnus-group-buffer)
4718 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4719 (gnus-info-set-read ',info ',(gnus-info-read info))
4720 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4721 (gnus-group-update-group ,group t))))
4722 ;; Add the read articles to the range.
4723 (gnus-info-set-read info range)
4724 ;; Then we have to re-compute how many unread
4725 ;; articles there are in this group.
4729 (setq num (- (1+ (cdr active)) (car active))))
4730 ((not (listp (cdr range)))
4731 (setq num (- (cdr active) (- (1+ (cdr range))
4735 (if (numberp (car range))
4737 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4738 (setq range (cdr range)))
4739 (setq num (- (cdr active) num))))
4740 ;; Update the number of unread articles.
4742 ;; Update the group buffer.
4743 (gnus-group-update-group group t)))))
4745 (defvar gnus-newsgroup-none-id 0)
4747 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4748 (let ((cur nntp-server-buffer)
4751 (save-excursion (set-buffer gnus-summary-buffer)
4752 gnus-newsgroup-dependencies)))
4754 (mail-parse-charset gnus-newsgroup-charset)
4755 (mail-parse-ignored-charsets
4756 (save-excursion (condition-case nil
4757 (set-buffer gnus-summary-buffer)
4759 gnus-newsgroup-ignored-charsets)))
4761 (set-buffer nntp-server-buffer)
4762 ;; Translate all TAB characters into SPACE characters.
4763 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4764 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4765 (gnus-run-hooks 'gnus-parse-headers-hook)
4766 (let ((case-fold-search t)
4767 in-reply-to header p lines chars ctype)
4768 (goto-char (point-min))
4769 ;; Search to the beginning of the next header. Error messages
4770 ;; do not begin with 2 or 3.
4771 (while (re-search-forward "^[23][0-9]+ " nil t)
4774 ;; This implementation of this function, with nine
4775 ;; search-forwards instead of the one re-search-forward and
4776 ;; a case (which basically was the old function) is actually
4777 ;; about twice as fast, even though it looks messier. You
4778 ;; can't have everything, I guess. Speed and elegance
4779 ;; doesn't always go hand in hand.
4782 (make-full-mail-header
4788 (narrow-to-region (point)
4789 (or (and (search-forward "\n.\n" nil t)
4795 (if (search-forward "\nsubject: " nil t)
4796 (nnheader-header-value)
4801 (if (or (search-forward "\nfrom: " nil t)
4802 (search-forward "\nfrom:" nil t))
4803 (nnheader-header-value)
4808 (if (search-forward "\ndate: " nil t)
4809 (nnheader-header-value)
4814 (setq id (if (re-search-forward
4815 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4816 ;; We do it this way to make sure the Message-ID
4817 ;; is (somewhat) syntactically valid.
4818 (buffer-substring (match-beginning 1)
4820 ;; If there was no message-id, we just fake one
4821 ;; to make subsequent routines simpler.
4822 (nnheader-generate-fake-message-id))))
4826 (if (search-forward "\nreferences: " nil t)
4830 (nnheader-header-value)
4835 (search-backward ">" end t)
4838 (search-backward "<" end t)
4840 ;; Get the references from the in-reply-to header if there
4841 ;; were no references and the in-reply-to header looks
4843 (if (and (search-forward "\nin-reply-to: " nil t)
4844 (setq in-reply-to (nnheader-header-value))
4845 (string-match "<[^>]+>" in-reply-to))
4847 (setq ref (substring in-reply-to (match-beginning 0)
4849 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4850 (setq ref2 (substring in-reply-to (match-beginning 0)
4852 (when (> (length ref2) (length ref))
4859 (if (search-forward "\nchars: " nil t)
4860 (if (numberp (setq chars (ignore-errors (read cur))))
4866 (if (search-forward "\nlines: " nil t)
4867 (if (numberp (setq lines (ignore-errors (read cur))))
4873 (and (search-forward "\nxref: " nil t)
4874 (nnheader-header-value)))
4876 (when gnus-extra-headers
4877 (let ((extra gnus-extra-headers)
4881 (when (search-forward
4882 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4883 (push (cons (car extra) (nnheader-header-value)) out))
4887 (if (and (search-forward "\ncontent-type: " nil t)
4888 (setq ctype (nnheader-header-value)))
4889 (mime-entity-set-content-type-internal
4890 header (mime-parse-Content-Type ctype)))
4891 (when (equal id ref)
4894 (when gnus-alter-header-function
4895 (funcall gnus-alter-header-function header)
4896 (setq id (mail-header-id header)
4897 ref (gnus-parent-id (mail-header-references header))))
4900 (gnus-dependencies-add-header
4901 header dependencies force-new))
4902 (push header headers))
4903 (goto-char (point-max))
4905 (nreverse headers)))))
4907 ;; Goes through the xover lines and returns a list of vectors
4908 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4909 force-new dependencies
4910 group also-fetch-heads)
4911 "Parse the news overview data in the server buffer.
4912 Return a list of headers that match SEQUENCE (see
4913 `nntp-retrieve-headers')."
4914 ;; Get the Xref when the users reads the articles since most/some
4915 ;; NNTP servers do not include Xrefs when using XOVER.
4916 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4917 (let ((mail-parse-charset gnus-newsgroup-charset)
4918 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4919 (cur nntp-server-buffer)
4920 (dependencies (or dependencies gnus-newsgroup-dependencies))
4921 number headers header)
4923 (set-buffer nntp-server-buffer)
4924 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4925 ;; Allow the user to mangle the headers before parsing them.
4926 (gnus-run-hooks 'gnus-parse-headers-hook)
4927 (goto-char (point-min))
4930 (while (and sequence (not (eobp)))
4931 (setq number (read cur))
4932 (while (and sequence
4933 (< (car sequence) number))
4934 (setq sequence (cdr sequence)))
4936 (eq number (car sequence))
4938 (setq sequence (cdr sequence))
4939 (setq header (inline
4940 (gnus-nov-parse-line
4941 number dependencies force-new))))
4942 (push header headers))
4945 (gnus-error 4 "Strange nov line (%d)"
4946 (count-lines (point-min) (point)))))
4948 ;; A common bug in inn is that if you have posted an article and
4949 ;; then retrieves the active file, it will answer correctly --
4950 ;; the new article is included. However, a NOV entry for the
4951 ;; article may not have been generated yet, so this may fail.
4952 ;; We work around this problem by retrieving the last few
4953 ;; headers using HEAD.
4954 (if (or (not also-fetch-heads)
4956 ;; We (probably) got all the headers.
4958 (let ((gnus-nov-is-evil t))
4961 (gnus-retrieve-parsed-headers sequence group)
4964 (defun gnus-article-get-xrefs ()
4965 "Fill in the Xref value in `gnus-current-headers', if necessary.
4966 This is meant to be called in `gnus-article-internal-prepare-hook'."
4967 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4968 gnus-current-headers)))
4969 (or (not gnus-use-cross-reference)
4971 (and (mail-header-xref headers)
4972 (not (string= (mail-header-xref headers) "")))
4973 (let ((case-fold-search t)
4976 (nnheader-narrow-to-headers)
4977 (goto-char (point-min))
4978 (when (or (and (not (eobp))
4979 (eq (downcase (char-after)) ?x)
4980 (looking-at "Xref:"))
4981 (search-forward "\nXref:" nil t))
4982 (goto-char (1+ (match-end 0)))
4983 (setq xref (buffer-substring (point)
4984 (progn (end-of-line) (point))))
4985 (mail-header-set-xref headers xref)))))))
4987 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4988 "Find article ID and insert the summary line for that article.
4989 OLD-HEADER can either be a header or a line number to insert
4990 the subject line on."
4991 (let* ((line (and (numberp old-header) old-header))
4992 (old-header (and (vectorp old-header) old-header))
4993 (header (cond ((and old-header use-old-header)
4996 (gnus-number-to-header id))
4997 (gnus-number-to-header id))
4999 (gnus-read-header id))))
5000 (number (and (numberp id) id))
5003 ;; Rebuild the thread that this article is part of and go to the
5004 ;; article we have fetched.
5005 (when (and (not gnus-show-threads)
5008 (setq d (gnus-data-find (mail-header-number old-header))))
5009 (goto-char (gnus-data-pos d))
5012 (- (gnus-point-at-bol)
5014 (1+ (gnus-point-at-eol))
5015 (gnus-delete-line))))))
5017 (mail-header-set-number header (mail-header-number old-header)))
5018 (setq gnus-newsgroup-sparse
5019 (delq (setq number (mail-header-number header))
5020 gnus-newsgroup-sparse))
5021 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5022 (push number gnus-newsgroup-limit)
5023 (gnus-rebuild-thread (mail-header-id header) line)
5024 (gnus-summary-goto-subject number nil t))
5025 (when (and (numberp number)
5027 ;; We have to update the boundaries even if we can't fetch the
5028 ;; article if ID is a number -- so that the next `P' or `N'
5029 ;; command will fetch the previous (or next) article even
5030 ;; if the one we tried to fetch this time has been canceled.
5031 (when (> number gnus-newsgroup-end)
5032 (setq gnus-newsgroup-end number))
5033 (when (< number gnus-newsgroup-begin)
5034 (setq gnus-newsgroup-begin number))
5035 (setq gnus-newsgroup-unselected
5036 (delq number gnus-newsgroup-unselected)))
5037 ;; Report back a success?
5038 (and header (mail-header-number header))))
5040 ;;; Process/prefix in the summary buffer
5042 (defun gnus-summary-work-articles (n)
5043 "Return a list of articles to be worked upon.
5044 The prefix argument, the list of process marked articles, and the
5045 current article will be taken into consideration."
5047 (set-buffer gnus-summary-buffer)
5050 ;; A numerical prefix has been given.
5051 (setq n (prefix-numeric-value n))
5052 (let ((backward (< n 0))
5053 (n (abs (prefix-numeric-value n)))
5058 (push (setq article (gnus-summary-article-number))
5061 (gnus-summary-find-prev nil article)
5062 (gnus-summary-find-next nil article)))
5064 (nreverse articles)))
5065 ((and (gnus-region-active-p) (mark))
5066 (message "region active")
5067 ;; Work on the region between point and mark.
5068 (let ((max (max (point) (mark)))
5071 (goto-char (min (point) (mark)))
5074 (push (setq article (gnus-summary-article-number)) articles)
5075 (gnus-summary-find-next nil article)
5077 (nreverse articles))))
5078 (gnus-newsgroup-processable
5079 ;; There are process-marked articles present.
5080 ;; Save current state.
5081 (gnus-summary-save-process-mark)
5083 (reverse gnus-newsgroup-processable))
5085 ;; Just return the current article.
5086 (list (gnus-summary-article-number))))))
5088 (defmacro gnus-summary-iterate (arg &rest forms)
5089 "Iterate over the process/prefixed articles and do FORMS.
5090 ARG is the interactive prefix given to the command. FORMS will be
5091 executed with point over the summary line of the articles."
5092 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5093 `(let ((,articles (gnus-summary-work-articles ,arg)))
5095 (gnus-summary-goto-subject (car ,articles))
5099 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5100 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5102 (defun gnus-summary-save-process-mark ()
5103 "Push the current set of process marked articles on the stack."
5105 (push (copy-sequence gnus-newsgroup-processable)
5106 gnus-newsgroup-process-stack))
5108 (defun gnus-summary-kill-process-mark ()
5109 "Push the current set of process marked articles on the stack and unmark."
5111 (gnus-summary-save-process-mark)
5112 (gnus-summary-unmark-all-processable))
5114 (defun gnus-summary-yank-process-mark ()
5115 "Pop the last process mark state off the stack and restore it."
5117 (unless gnus-newsgroup-process-stack
5118 (error "Empty mark stack"))
5119 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5121 (defun gnus-summary-process-mark-set (set)
5122 "Make SET into the current process marked articles."
5123 (gnus-summary-unmark-all-processable)
5125 (gnus-summary-set-process-mark (pop set))))
5127 ;;; Searching and stuff
5129 (defun gnus-summary-search-group (&optional backward use-level)
5130 "Search for next unread newsgroup.
5131 If optional argument BACKWARD is non-nil, search backward instead."
5133 (set-buffer gnus-group-buffer)
5134 (when (gnus-group-search-forward
5135 backward nil (if use-level (gnus-group-group-level) nil))
5136 (gnus-group-group-name))))
5138 (defun gnus-summary-best-group (&optional exclude-group)
5139 "Find the name of the best unread group.
5140 If EXCLUDE-GROUP, do not go to this group."
5142 (set-buffer gnus-group-buffer)
5144 (gnus-group-best-unread-group exclude-group))))
5146 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5147 (if backward (gnus-summary-find-prev)
5148 (let* ((dummy (gnus-summary-article-intangible-p))
5149 (article (or article (gnus-summary-article-number)))
5150 (arts (gnus-data-find-list article))
5152 (when (and (not dummy)
5153 (or (not gnus-summary-check-current)
5155 (not (gnus-data-unread-p (car arts)))))
5156 (setq arts (cdr arts)))
5161 (when (or (and undownloaded
5162 (eq gnus-undownloaded-mark
5163 (gnus-data-mark (car arts))))
5164 (gnus-data-unread-p (car arts)))
5165 (setq result (car arts)
5167 (setq arts (cdr arts)))
5170 (goto-char (gnus-data-pos result))
5171 (gnus-data-number result)))))
5173 (defun gnus-summary-find-prev (&optional unread article)
5174 (let* ((eobp (eobp))
5175 (article (or article (gnus-summary-article-number)))
5176 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5178 (when (and (not eobp)
5179 (or (not gnus-summary-check-current)
5181 (not (gnus-data-unread-p (car arts)))))
5182 (setq arts (cdr arts)))
5187 (when (gnus-data-unread-p (car arts))
5188 (setq result (car arts)
5190 (setq arts (cdr arts)))
5193 (goto-char (gnus-data-pos result))
5194 (gnus-data-number result))))
5196 (defun gnus-summary-find-subject (subject &optional unread backward article)
5197 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5198 (article (or article (gnus-summary-article-number)))
5199 (articles (gnus-data-list backward))
5200 (arts (gnus-data-find-list article articles))
5202 (when (or (not gnus-summary-check-current)
5204 (not (gnus-data-unread-p (car arts))))
5205 (setq arts (cdr arts)))
5207 (and (or (not unread)
5208 (gnus-data-unread-p (car arts)))
5209 (vectorp (gnus-data-header (car arts)))
5211 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5212 (setq result (car arts)
5214 (setq arts (cdr arts)))
5216 (goto-char (gnus-data-pos result))
5217 (gnus-data-number result))))
5219 (defun gnus-summary-search-forward (&optional unread subject backward)
5220 "Search forward for an article.
5221 If UNREAD, look for unread articles. If SUBJECT, look for
5222 articles with that subject. If BACKWARD, search backward instead."
5223 (cond (subject (gnus-summary-find-subject subject unread backward))
5224 (backward (gnus-summary-find-prev unread))
5225 (t (gnus-summary-find-next unread))))
5227 (defun gnus-recenter (&optional n)
5228 "Center point in window and redisplay frame.
5229 Also do horizontal recentering."
5231 (when (and gnus-auto-center-summary
5232 (not (eq gnus-auto-center-summary 'vertical)))
5233 (gnus-horizontal-recenter))
5236 (defun gnus-summary-recenter ()
5237 "Center point in the summary window.
5238 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5239 displayed, no centering will be performed."
5240 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5241 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5243 (let* ((top (cond ((< (window-height) 4) 0)
5244 ((< (window-height) 7) 1)
5245 (t (if (numberp gnus-auto-center-summary)
5246 gnus-auto-center-summary
5248 (height (1- (window-height)))
5249 (bottom (save-excursion (goto-char (point-max))
5250 (forward-line (- height))
5252 (window (get-buffer-window (current-buffer))))
5253 ;; The user has to want it.
5254 (when gnus-auto-center-summary
5255 (when (get-buffer-window gnus-article-buffer)
5256 ;; Only do recentering when the article buffer is displayed,
5257 ;; Set the window start to either `bottom', which is the biggest
5258 ;; possible valid number, or the second line from the top,
5259 ;; whichever is the least.
5261 window (min bottom (save-excursion
5262 (forward-line (- top)) (point)))
5264 ;; Do horizontal recentering while we're at it.
5265 (when (and (get-buffer-window (current-buffer) t)
5266 (not (eq gnus-auto-center-summary 'vertical)))
5267 (let ((selected (selected-window)))
5268 (select-window (get-buffer-window (current-buffer) t))
5269 (gnus-summary-position-point)
5270 (gnus-horizontal-recenter)
5271 (select-window selected))))))
5273 (defun gnus-summary-jump-to-group (newsgroup)
5274 "Move point to NEWSGROUP in group mode buffer."
5275 ;; Keep update point of group mode buffer if visible.
5276 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5277 (save-window-excursion
5278 ;; Take care of tree window mode.
5279 (when (get-buffer-window gnus-group-buffer)
5280 (pop-to-buffer gnus-group-buffer))
5281 (gnus-group-jump-to-group newsgroup))
5283 ;; Take care of tree window mode.
5284 (if (get-buffer-window gnus-group-buffer)
5285 (pop-to-buffer gnus-group-buffer)
5286 (set-buffer gnus-group-buffer))
5287 (gnus-group-jump-to-group newsgroup))))
5289 ;; This function returns a list of article numbers based on the
5290 ;; difference between the ranges of read articles in this group and
5291 ;; the range of active articles.
5292 (defun gnus-list-of-unread-articles (group)
5293 (let* ((read (gnus-info-read (gnus-get-info group)))
5294 (active (or (gnus-active group) (gnus-activate-group group)))
5297 ;; If none are read, then all are unread.
5299 (setq first (car active))
5300 ;; If the range of read articles is a single range, then the
5301 ;; first unread article is the article after the last read
5302 ;; article. Sounds logical, doesn't it?
5303 (if (and (not (listp (cdr read)))
5304 (or (< (car read) (car active))
5305 (progn (setq read (list read))
5307 (setq first (max (car active) (1+ (cdr read))))
5308 ;; `read' is a list of ranges.
5309 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5312 (setq first (car active)))
5315 (while (< first nlast)
5317 (setq first (1+ first))))
5318 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5319 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5320 (setq read (cdr read)))))
5321 ;; And add the last unread articles.
5322 (while (<= first last)
5324 (setq first (1+ first)))
5325 ;; Return the list of unread articles.
5326 (delq 0 (nreverse unread))))
5328 (defun gnus-list-of-read-articles (group)
5329 "Return a list of unread, unticked and non-dormant articles."
5330 (let* ((info (gnus-get-info group))
5331 (marked (gnus-info-marks info))
5332 (active (gnus-active group)))
5334 (gnus-set-difference
5335 (gnus-sorted-complement
5336 (gnus-uncompress-range active)
5337 (gnus-list-of-unread-articles group))
5339 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5340 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5342 ;; Various summary commands
5344 (defun gnus-summary-select-article-buffer ()
5345 "Reconfigure windows to show article buffer."
5347 (if (not (gnus-buffer-live-p gnus-article-buffer))
5348 (error "There is no article buffer for this summary buffer")
5349 (gnus-configure-windows 'article)
5350 (select-window (get-buffer-window gnus-article-buffer))))
5352 (defun gnus-summary-universal-argument (arg)
5353 "Perform any operation on all articles that are process/prefixed."
5355 (let ((articles (gnus-summary-work-articles arg))
5362 (substitute-command-keys
5363 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5365 (gnus-error 1 "Undefined key")
5368 (gnus-summary-goto-subject (setq article (pop articles)))
5369 (let (gnus-newsgroup-processable)
5370 (command-execute func))
5371 (gnus-summary-remove-process-mark article)))))
5372 (gnus-summary-position-point))
5374 (defun gnus-summary-toggle-truncation (&optional arg)
5375 "Toggle truncation of summary lines.
5376 With arg, turn line truncation on iff arg is positive."
5378 (setq truncate-lines
5379 (if (null arg) (not truncate-lines)
5380 (> (prefix-numeric-value arg) 0)))
5383 (defun gnus-summary-reselect-current-group (&optional all rescan)
5384 "Exit and then reselect the current newsgroup.
5385 The prefix argument ALL means to select all articles."
5387 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5388 (error "Ephemeral groups can't be reselected"))
5389 (let ((current-subject (gnus-summary-article-number))
5390 (group gnus-newsgroup-name))
5391 (setq gnus-newsgroup-begin nil)
5393 ;; We have to adjust the point of group mode buffer because
5394 ;; point was moved to the next unread newsgroup by exiting.
5395 (gnus-summary-jump-to-group group)
5398 (save-window-excursion
5399 ;; Don't show group contents.
5400 (set-window-start (selected-window) (point-max))
5401 (gnus-group-get-new-news-this-group 1))))
5402 (gnus-group-read-group all t)
5403 (gnus-summary-goto-subject current-subject nil t)))
5405 (defun gnus-summary-rescan-group (&optional all)
5406 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5408 (gnus-summary-reselect-current-group all t))
5410 (defun gnus-summary-update-info (&optional non-destructive)
5412 (let ((group gnus-newsgroup-name))
5414 (when gnus-newsgroup-kill-headers
5415 (setq gnus-newsgroup-killed
5416 (gnus-compress-sequence
5418 (gnus-set-sorted-intersection
5419 (gnus-uncompress-range gnus-newsgroup-killed)
5420 (setq gnus-newsgroup-unselected
5421 (sort gnus-newsgroup-unselected '<)))
5422 (setq gnus-newsgroup-unreads
5423 (sort gnus-newsgroup-unreads '<)))
5425 (unless (listp (cdr gnus-newsgroup-killed))
5426 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5427 (let ((headers gnus-newsgroup-headers))
5428 ;; Set the new ranges of read articles.
5430 (set-buffer gnus-group-buffer)
5431 (gnus-undo-force-boundary))
5432 (gnus-update-read-articles
5433 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5434 ;; Set the current article marks.
5435 (let ((gnus-newsgroup-scored
5436 (if (and (not gnus-save-score)
5437 (not non-destructive))
5439 gnus-newsgroup-scored)))
5441 (gnus-update-marks)))
5442 ;; Do the cross-ref thing.
5443 (when gnus-use-cross-reference
5444 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5445 ;; Do not switch windows but change the buffer to work.
5446 (set-buffer gnus-group-buffer)
5447 (unless (gnus-ephemeral-group-p group)
5448 (gnus-group-update-group group)))))))
5450 (defun gnus-summary-save-newsrc (&optional force)
5451 "Save the current number of read/marked articles in the dribble buffer.
5452 The dribble buffer will then be saved.
5453 If FORCE (the prefix), also save the .newsrc file(s)."
5455 (gnus-summary-update-info t)
5457 (gnus-save-newsrc-file)
5458 (gnus-dribble-save)))
5460 (defun gnus-summary-exit (&optional temporary)
5461 "Exit reading current newsgroup, and then return to group selection mode.
5462 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5464 (gnus-set-global-variables)
5465 (gnus-kill-save-kill-buffer)
5466 (gnus-async-halt-prefetch)
5467 (let* ((group gnus-newsgroup-name)
5468 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5471 (buf (current-buffer)))
5473 ;; Do adaptive scoring, and possibly save score files.
5474 (when gnus-newsgroup-adaptive
5475 (gnus-score-adaptive))
5476 (when gnus-use-scoring
5478 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5479 ;; If we have several article buffers, we kill them at exit.
5480 (unless gnus-single-article-buffer
5481 (gnus-kill-buffer gnus-original-article-buffer)
5482 (setq gnus-article-current nil))
5483 (when gnus-use-cache
5484 (gnus-cache-possibly-remove-articles)
5485 (gnus-cache-save-buffers))
5486 (gnus-async-prefetch-remove-group group)
5487 (when gnus-suppress-duplicates
5488 (gnus-dup-enter-articles))
5489 (when gnus-use-trees
5490 (gnus-tree-close group))
5491 (when gnus-use-cache
5492 (gnus-cache-write-active))
5493 ;; Remove entries for this group.
5494 (nnmail-purge-split-history (gnus-group-real-name group))
5495 ;; Make all changes in this group permanent.
5497 (gnus-run-hooks 'gnus-exit-group-hook)
5498 (gnus-summary-update-info))
5499 (gnus-close-group group)
5500 ;; Make sure where we were, and go to next newsgroup.
5501 (set-buffer gnus-group-buffer)
5503 (gnus-group-jump-to-group group))
5504 (gnus-run-hooks 'gnus-summary-exit-hook)
5505 (unless (or quit-config
5506 ;; If this group has disappeared from the summary
5507 ;; buffer, don't skip forwards.
5508 (not (string= group (gnus-group-group-name))))
5509 (gnus-group-next-unread-group 1))
5510 (setq group-point (point))
5513 ;; If we have several article buffers, we kill them at exit.
5514 (unless gnus-single-article-buffer
5515 (gnus-kill-buffer gnus-article-buffer)
5516 (gnus-kill-buffer gnus-original-article-buffer)
5517 (setq gnus-article-current nil))
5519 (if (not gnus-kill-summary-on-exit)
5520 (gnus-deaden-summary)
5521 ;; We set all buffer-local variables to nil. It is unclear why
5522 ;; this is needed, but if we don't, buffer-local variables are
5523 ;; not garbage-collected, it seems. This would the lead to en
5524 ;; ever-growing Emacs.
5525 (gnus-summary-clear-local-variables)
5526 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5527 (gnus-summary-clear-local-variables))
5528 (when (get-buffer gnus-article-buffer)
5529 (bury-buffer gnus-article-buffer))
5530 ;; We clear the global counterparts of the buffer-local
5531 ;; variables as well, just to be on the safe side.
5532 (set-buffer gnus-group-buffer)
5533 (gnus-summary-clear-local-variables)
5534 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5535 (gnus-summary-clear-local-variables))
5536 ;; Return to group mode buffer.
5537 (when (eq mode 'gnus-summary-mode)
5538 (gnus-kill-buffer buf)))
5539 (setq gnus-current-select-method gnus-select-method)
5540 (pop-to-buffer gnus-group-buffer)
5541 (if (not quit-config)
5543 (goto-char group-point)
5544 (gnus-configure-windows 'group 'force)
5545 (unless (pos-visible-in-window-p)
5546 (forward-line (/ (static-if (featurep 'xemacs)
5547 (window-displayed-height)
5548 (1- (window-height)))
5550 (set-window-start (selected-window) (point))
5551 (goto-char group-point)))
5552 (gnus-handle-ephemeral-exit quit-config))
5553 ;; Clear the current group name.
5555 (setq gnus-newsgroup-name nil)))))
5557 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5558 (defun gnus-summary-exit-no-update (&optional no-questions)
5559 "Quit reading current newsgroup without updating read article info."
5561 (let* ((group gnus-newsgroup-name)
5562 (quit-config (gnus-group-quit-config group)))
5563 (when (or no-questions
5565 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5566 (gnus-async-halt-prefetch)
5568 (delq 'gnus-summary-expire-articles
5569 (copy-sequence gnus-summary-prepare-exit-hook)))
5570 ;; If we have several article buffers, we kill them at exit.
5571 (unless gnus-single-article-buffer
5572 (gnus-kill-buffer gnus-article-buffer)
5573 (gnus-kill-buffer gnus-original-article-buffer)
5574 (setq gnus-article-current nil))
5575 (if (not gnus-kill-summary-on-exit)
5576 (gnus-deaden-summary)
5577 (gnus-close-group group)
5578 (gnus-summary-clear-local-variables)
5579 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5580 (gnus-summary-clear-local-variables))
5581 (set-buffer gnus-group-buffer)
5582 (gnus-summary-clear-local-variables)
5583 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5584 (gnus-summary-clear-local-variables))
5585 (when (get-buffer gnus-summary-buffer)
5586 (kill-buffer gnus-summary-buffer)))
5587 (unless gnus-single-article-buffer
5588 (setq gnus-article-current nil))
5589 (when gnus-use-trees
5590 (gnus-tree-close group))
5591 (gnus-async-prefetch-remove-group group)
5592 (when (get-buffer gnus-article-buffer)
5593 (bury-buffer gnus-article-buffer))
5594 ;; Return to the group buffer.
5595 (gnus-configure-windows 'group 'force)
5596 ;; Clear the current group name.
5597 (setq gnus-newsgroup-name nil)
5598 (when (equal (gnus-group-group-name) group)
5599 (gnus-group-next-unread-group 1))
5601 (gnus-handle-ephemeral-exit quit-config)))))
5603 (defun gnus-handle-ephemeral-exit (quit-config)
5604 "Handle movement when leaving an ephemeral group.
5605 The state which existed when entering the ephemeral is reset."
5606 (if (not (buffer-name (car quit-config)))
5607 (gnus-configure-windows 'group 'force)
5608 (set-buffer (car quit-config))
5609 (cond ((eq major-mode 'gnus-summary-mode)
5610 (gnus-set-global-variables))
5611 ((eq major-mode 'gnus-article-mode)
5613 ;; The `gnus-summary-buffer' variable may point
5614 ;; to the old summary buffer when using a single
5616 (unless (gnus-buffer-live-p gnus-summary-buffer)
5617 (set-buffer gnus-group-buffer))
5618 (set-buffer gnus-summary-buffer)
5619 (gnus-set-global-variables))))
5620 (if (or (eq (cdr quit-config) 'article)
5621 (eq (cdr quit-config) 'pick))
5623 ;; The current article may be from the ephemeral group
5624 ;; thus it is best that we reload this article
5625 (gnus-summary-show-article)
5626 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5627 (gnus-configure-windows 'pick 'force)
5628 (gnus-configure-windows (cdr quit-config) 'force)))
5629 (gnus-configure-windows (cdr quit-config) 'force))
5630 (when (eq major-mode 'gnus-summary-mode)
5631 (gnus-summary-next-subject 1 nil t)
5632 (gnus-summary-recenter)
5633 (gnus-summary-position-point))))
5635 (defun gnus-summary-preview-mime-message ()
5636 "MIME decode and play this message."
5638 (let ((gnus-break-pages nil)
5640 (gnus-summary-select-article gnus-show-all-headers t))
5641 (select-window (get-buffer-window gnus-article-buffer)))
5645 (defvar gnus-dead-summary-mode-map nil)
5647 (unless gnus-dead-summary-mode-map
5648 (setq gnus-dead-summary-mode-map (make-keymap))
5649 (suppress-keymap gnus-dead-summary-mode-map)
5650 (substitute-key-definition
5651 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5652 (let ((keys '("\C-d" "\r" "\177" [delete])))
5654 (define-key gnus-dead-summary-mode-map
5655 (pop keys) 'gnus-summary-wake-up-the-dead))))
5657 (defvar gnus-dead-summary-mode nil
5658 "Minor mode for Gnus summary buffers.")
5660 (defun gnus-dead-summary-mode (&optional arg)
5661 "Minor mode for Gnus summary buffers."
5663 (when (eq major-mode 'gnus-summary-mode)
5664 (make-local-variable 'gnus-dead-summary-mode)
5665 (setq gnus-dead-summary-mode
5666 (if (null arg) (not gnus-dead-summary-mode)
5667 (> (prefix-numeric-value arg) 0)))
5668 (when gnus-dead-summary-mode
5669 (gnus-add-minor-mode
5670 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5672 (defun gnus-deaden-summary ()
5673 "Make the current summary buffer into a dead summary buffer."
5674 ;; Kill any previous dead summary buffer.
5675 (when (and gnus-dead-summary
5676 (buffer-name gnus-dead-summary))
5678 (set-buffer gnus-dead-summary)
5679 (when gnus-dead-summary-mode
5680 (kill-buffer (current-buffer)))))
5681 ;; Make this the current dead summary.
5682 (setq gnus-dead-summary (current-buffer))
5683 (gnus-dead-summary-mode 1)
5684 (let ((name (buffer-name)))
5685 (when (string-match "Summary" name)
5687 (concat (substring name 0 (match-beginning 0)) "Dead "
5688 (substring name (match-beginning 0)))
5692 (defun gnus-kill-or-deaden-summary (buffer)
5693 "Kill or deaden the summary BUFFER."
5695 (when (and (buffer-name buffer)
5696 (not gnus-single-article-buffer))
5699 (gnus-kill-buffer gnus-article-buffer)
5700 (gnus-kill-buffer gnus-original-article-buffer)))
5701 (cond (gnus-kill-summary-on-exit
5702 (when (and gnus-use-trees
5703 (gnus-buffer-exists-p buffer))
5706 (gnus-tree-close gnus-newsgroup-name)))
5707 (gnus-kill-buffer buffer))
5708 ((gnus-buffer-exists-p buffer)
5711 (gnus-deaden-summary))))))
5713 (defun gnus-summary-wake-up-the-dead (&rest args)
5714 "Wake up the dead summary buffer."
5716 (gnus-dead-summary-mode -1)
5717 (let ((name (buffer-name)))
5718 (when (string-match "Dead " name)
5720 (concat (substring name 0 (match-beginning 0))
5721 (substring name (match-end 0)))
5723 (gnus-message 3 "This dead summary is now alive again"))
5725 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5726 (defun gnus-summary-fetch-faq (&optional faq-dir)
5727 "Fetch the FAQ for the current group.
5728 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5732 (when current-prefix-arg
5734 "Faq dir: " (and (listp gnus-group-faq-directory)
5735 (mapcar (lambda (file) (list file))
5736 gnus-group-faq-directory))))))
5737 (let (gnus-faq-buffer)
5738 (when (setq gnus-faq-buffer
5739 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5740 (gnus-configure-windows 'summary-faq))))
5742 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5743 (defun gnus-summary-describe-group (&optional force)
5744 "Describe the current newsgroup."
5746 (gnus-group-describe-group force gnus-newsgroup-name))
5748 (defun gnus-summary-describe-briefly ()
5749 "Describe summary mode commands briefly."
5751 (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")))
5753 ;; Walking around group mode buffer from summary mode.
5755 (defun gnus-summary-next-group (&optional no-article target-group backward)
5756 "Exit current newsgroup and then select next unread newsgroup.
5757 If prefix argument NO-ARTICLE is non-nil, no article is selected
5758 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5759 previous group instead."
5761 ;; Stop pre-fetching.
5762 (gnus-async-halt-prefetch)
5763 (let ((current-group gnus-newsgroup-name)
5764 (current-buffer (current-buffer))
5766 ;; First we semi-exit this group to update Xrefs and all variables.
5767 ;; We can't do a real exit, because the window conf must remain
5768 ;; the same in case the user is prompted for info, and we don't
5769 ;; want the window conf to change before that...
5770 (gnus-summary-exit t)
5771 (while (not entered)
5772 ;; Then we find what group we are supposed to enter.
5773 (set-buffer gnus-group-buffer)
5774 (gnus-group-jump-to-group current-group)
5777 (if (eq gnus-keep-same-level 'best)
5778 (gnus-summary-best-group gnus-newsgroup-name)
5779 (gnus-summary-search-group backward gnus-keep-same-level))))
5780 (if (not target-group)
5781 ;; There are no further groups, so we return to the group
5784 (gnus-message 5 "Returning to the group buffer")
5786 (when (gnus-buffer-live-p current-buffer)
5787 (set-buffer current-buffer)
5788 (gnus-summary-exit))
5789 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5790 ;; We try to enter the target group.
5791 (gnus-group-jump-to-group target-group)
5792 (let ((unreads (gnus-group-group-unread)))
5793 (if (and (or (eq t unreads)
5794 (and unreads (not (zerop unreads))))
5795 (gnus-summary-read-group
5796 target-group nil no-article
5797 (and (buffer-name current-buffer) current-buffer)
5800 (setq current-group target-group
5801 target-group nil)))))))
5803 (defun gnus-summary-prev-group (&optional no-article)
5804 "Exit current newsgroup and then select previous unread newsgroup.
5805 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5807 (gnus-summary-next-group no-article nil t))
5809 ;; Walking around summary lines.
5811 (defun gnus-summary-first-subject (&optional unread undownloaded)
5812 "Go to the first unread subject.
5813 If UNREAD is non-nil, go to the first unread article.
5814 Returns the article selected or nil if there are no unread articles."
5819 ((null gnus-newsgroup-data)
5820 (gnus-message 3 "No articles in the group")
5822 ;; Pick the first article.
5824 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5825 (gnus-data-number (car gnus-newsgroup-data)))
5826 ;; No unread articles.
5827 ((null gnus-newsgroup-unreads)
5828 (gnus-message 3 "No more unread articles")
5830 ;; Find the first unread article.
5832 (let ((data gnus-newsgroup-data))
5834 (and (not (and undownloaded
5835 (eq gnus-undownloaded-mark
5836 (gnus-data-mark (car data)))))
5837 (not (gnus-data-unread-p (car data)))))
5838 (setq data (cdr data)))
5840 (goto-char (gnus-data-pos (car data)))
5841 (gnus-data-number (car data))))))
5842 (gnus-summary-position-point)))
5844 (defun gnus-summary-next-subject (n &optional unread dont-display)
5845 "Go to next N'th summary line.
5846 If N is negative, go to the previous N'th subject line.
5847 If UNREAD is non-nil, only unread articles are selected.
5848 The difference between N and the actual number of steps taken is
5851 (let ((backward (< n 0))
5855 (gnus-summary-find-prev unread)
5856 (gnus-summary-find-next unread)))
5857 (unless (zerop (setq n (1- n)))
5858 (gnus-summary-show-thread)))
5860 (gnus-message 7 "No more%s articles"
5861 (if unread " unread" "")))
5862 (unless dont-display
5863 (gnus-summary-recenter)
5864 (gnus-summary-position-point))
5867 (defun gnus-summary-next-unread-subject (n)
5868 "Go to next N'th unread summary line."
5870 (gnus-summary-next-subject n t))
5872 (defun gnus-summary-prev-subject (n &optional unread)
5873 "Go to previous N'th summary line.
5874 If optional argument UNREAD is non-nil, only unread article is selected."
5876 (gnus-summary-next-subject (- n) unread))
5878 (defun gnus-summary-prev-unread-subject (n)
5879 "Go to previous N'th unread summary line."
5881 (gnus-summary-next-subject (- n) t))
5883 (defun gnus-summary-goto-subject (article &optional force silent)
5884 "Go the subject line of ARTICLE.
5885 If FORCE, also allow jumping to articles not currently shown."
5886 (interactive "nArticle number: ")
5888 (data (gnus-data-find article)))
5889 ;; We read in the article if we have to.
5892 (gnus-summary-insert-subject
5894 (if (or (numberp force) (vectorp force)) force)
5896 (setq data (gnus-data-find article)))
5901 (gnus-message 3 "Can't find article %d" article))
5903 (goto-char (gnus-data-pos data))
5904 (gnus-summary-position-point)
5907 ;; Walking around summary lines with displaying articles.
5909 (defun gnus-summary-expand-window (&optional arg)
5910 "Make the summary buffer take up the entire Emacs frame.
5911 Given a prefix, will force an `article' buffer configuration."
5914 (gnus-configure-windows 'article 'force)
5915 (gnus-configure-windows 'summary 'force)))
5917 (defun gnus-summary-display-article (article &optional all-header)
5918 "Display ARTICLE in article buffer."
5919 (gnus-set-global-variables)
5920 (when (gnus-buffer-live-p gnus-article-buffer)
5921 (with-current-buffer gnus-article-buffer
5922 (setq gnus-article-charset gnus-newsgroup-charset)
5923 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
5927 (if gnus-summary-display-article-function
5928 (funcall gnus-summary-display-article-function article all-header)
5929 (gnus-article-prepare article all-header))
5930 (with-current-buffer gnus-article-buffer
5931 (set (make-local-variable 'gnus-summary-search-article-matched-data)
5933 (gnus-run-hooks 'gnus-select-article-hook)
5934 (when (and gnus-current-article
5935 (not (zerop gnus-current-article)))
5936 (gnus-summary-goto-subject gnus-current-article))
5937 (gnus-summary-recenter)
5938 (when (and gnus-use-trees gnus-show-threads)
5939 (gnus-possibly-generate-tree article)
5940 (gnus-highlight-selected-tree article))
5941 ;; Successfully display article.
5942 (gnus-article-set-window-start
5943 (cdr (assq article gnus-newsgroup-bookmarks))))))
5945 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5946 "Select the current article.
5947 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5948 non-nil, the article will be re-fetched even if it already present in
5949 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5951 ;; Make sure we are in the summary buffer to work around bbdb bug.
5952 (unless (eq major-mode 'gnus-summary-mode)
5953 (set-buffer gnus-summary-buffer))
5954 (let ((article (or article (gnus-summary-article-number)))
5955 (all-headers (not (not all-headers))) ;Must be T or NIL.
5956 gnus-summary-display-article-function)
5958 (gnus-summary-article-pseudo-p article)
5959 (error "This is a pseudo-article"))
5961 (set-buffer gnus-summary-buffer)
5962 (if (or (and gnus-single-article-buffer
5963 (or (null gnus-current-article)
5964 (null gnus-article-current)
5965 (null (get-buffer gnus-article-buffer))
5966 (not (eq article (cdr gnus-article-current)))
5967 (not (equal (car gnus-article-current)
5968 gnus-newsgroup-name))))
5969 (and (not gnus-single-article-buffer)
5970 (or (null gnus-current-article)
5971 (not (eq gnus-current-article article))))
5973 ;; The requested article is different from the current article.
5975 (gnus-summary-display-article article all-headers)
5976 (when (or all-headers gnus-show-all-headers)
5977 (gnus-article-show-all-headers))
5978 (gnus-article-set-window-start
5979 (cdr (assq article gnus-newsgroup-bookmarks)))
5981 (when (or all-headers gnus-show-all-headers)
5982 (gnus-article-show-all-headers))
5985 (defun gnus-summary-force-verify-and-decrypt ()
5987 (let ((mm-verify-option 'known)
5988 (mm-decrypt-option 'known))
5989 (gnus-summary-select-article nil 'force)))
5991 (defun gnus-summary-set-current-mark (&optional current-mark)
5992 "Obsolete function."
5995 (defun gnus-summary-next-article (&optional unread subject backward push)
5996 "Select the next article.
5997 If UNREAD, only unread articles are selected.
5998 If SUBJECT, only articles with SUBJECT are selected.
5999 If BACKWARD, the previous article is selected instead of the next."
6002 ;; Is there such an article?
6003 ((and (gnus-summary-search-forward unread subject backward)
6004 (or (gnus-summary-display-article (gnus-summary-article-number))
6005 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6006 (gnus-summary-position-point))
6007 ;; If not, we try the first unread, if that is wanted.
6009 gnus-auto-select-same
6010 (gnus-summary-first-unread-article))
6011 (gnus-summary-position-point)
6012 (gnus-message 6 "Wrapped"))
6013 ;; Try to get next/previous article not displayed in this group.
6014 ((and gnus-auto-extend-newsgroup
6015 (not unread) (not subject))
6016 (gnus-summary-goto-article
6017 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6018 nil (count-lines (point-min) (point))))
6019 ;; Go to next/previous group.
6021 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6022 (gnus-summary-jump-to-group gnus-newsgroup-name))
6023 (let ((cmd last-command-char)
6026 (set-buffer gnus-group-buffer)
6029 (if (eq gnus-keep-same-level 'best)
6030 (gnus-summary-best-group gnus-newsgroup-name)
6031 (gnus-summary-search-group backward gnus-keep-same-level))))
6032 ;; For some reason, the group window gets selected. We change
6034 (select-window (get-buffer-window (current-buffer)))
6035 ;; Select next unread newsgroup automagically.
6037 ((or (not gnus-auto-select-next)
6039 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6040 ((or (eq gnus-auto-select-next 'quietly)
6041 (and (eq gnus-auto-select-next 'slightly-quietly)
6043 (and (eq gnus-auto-select-next 'almost-quietly)
6044 (gnus-summary-last-article-p)))
6046 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6048 (gnus-message 7 "No more%s articles (%s)..."
6049 (if unread " unread" "")
6050 (if group (concat "selecting " group)
6052 (gnus-summary-next-group nil group backward)))
6054 (when (gnus-key-press-event-p last-input-event)
6055 (gnus-summary-walk-group-buffer
6056 gnus-newsgroup-name cmd unread backward point))))))))
6058 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6059 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6060 (?\C-p (gnus-group-prev-unread-group 1))))
6061 (cursor-in-echo-area t)
6062 keve key group ended)
6064 (set-buffer gnus-group-buffer)
6067 (if (eq gnus-keep-same-level 'best)
6068 (gnus-summary-best-group gnus-newsgroup-name)
6069 (gnus-summary-search-group backward gnus-keep-same-level))))
6072 5 "No more%s articles%s" (if unread " unread" "")
6074 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6075 (format " (Type %s for %s [%s])"
6076 (single-key-description cmd) group
6077 (car (gnus-gethash group gnus-newsrc-hashtb)))
6078 (format " (Type %s to exit %s)"
6079 (single-key-description cmd)
6080 gnus-newsgroup-name)))
6081 ;; Confirm auto selection.
6082 (setq key (car (setq keve (gnus-read-event-char))))
6085 ((assq key keystrokes)
6086 (let ((obuf (current-buffer)))
6087 (switch-to-buffer gnus-group-buffer)
6089 (gnus-group-jump-to-group group))
6090 (eval (cadr (assq key keystrokes)))
6091 (setq group (gnus-group-group-name))
6092 (switch-to-buffer obuf))
6096 (gnus-ephemeral-group-p gnus-newsgroup-name))
6098 (gnus-summary-next-group nil group backward)))
6100 (push (cdr keve) unread-command-events))))))
6102 (defun gnus-summary-next-unread-article ()
6103 "Select unread article after current one."
6105 (gnus-summary-next-article
6106 (or (not (eq gnus-summary-goto-unread 'never))
6107 (gnus-summary-last-article-p (gnus-summary-article-number)))
6108 (and gnus-auto-select-same
6109 (gnus-summary-article-subject))))
6111 (defun gnus-summary-prev-article (&optional unread subject)
6112 "Select the article after the current one.
6113 If UNREAD is non-nil, only unread articles are selected."
6115 (gnus-summary-next-article unread subject t))
6117 (defun gnus-summary-prev-unread-article ()
6118 "Select unread article before current one."
6120 (gnus-summary-prev-article
6121 (or (not (eq gnus-summary-goto-unread 'never))
6122 (gnus-summary-first-article-p (gnus-summary-article-number)))
6123 (and gnus-auto-select-same
6124 (gnus-summary-article-subject))))
6126 (defun gnus-summary-next-page (&optional lines circular)
6127 "Show next page of the selected article.
6128 If at the end of the current article, select the next article.
6129 LINES says how many lines should be scrolled up.
6131 If CIRCULAR is non-nil, go to the start of the article instead of
6132 selecting the next article when reaching the end of the current
6135 (setq gnus-summary-buffer (current-buffer))
6136 (gnus-set-global-variables)
6137 (let ((article (gnus-summary-article-number))
6138 (article-window (get-buffer-window gnus-article-buffer t))
6140 ;; If the buffer is empty, we have no article.
6142 (error "No article to select"))
6143 (gnus-configure-windows 'article)
6144 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6145 (if (and (eq gnus-summary-goto-unread 'never)
6146 (not (gnus-summary-last-article-p article)))
6147 (gnus-summary-next-article)
6148 (gnus-summary-next-unread-article))
6149 (if (or (null gnus-current-article)
6150 (null gnus-article-current)
6151 (/= article (cdr gnus-article-current))
6152 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6153 ;; Selected subject is different from current article's.
6154 (gnus-summary-display-article article)
6155 (when article-window
6156 (gnus-eval-in-buffer-window gnus-article-buffer
6157 (setq endp (gnus-article-next-page lines)))
6160 (gnus-summary-beginning-of-article))
6162 (gnus-message 3 "End of message"))
6164 (if (and (eq gnus-summary-goto-unread 'never)
6165 (not (gnus-summary-last-article-p article)))
6166 (gnus-summary-next-article)
6167 (gnus-summary-next-unread-article))))))))
6168 (gnus-summary-recenter)
6169 (gnus-summary-position-point)))
6171 (defun gnus-summary-prev-page (&optional lines move)
6172 "Show previous page of selected article.
6173 Argument LINES specifies lines to be scrolled down.
6174 If MOVE, move to the previous unread article if point is at
6175 the beginning of the buffer."
6177 (let ((article (gnus-summary-article-number))
6178 (article-window (get-buffer-window gnus-article-buffer t))
6180 (gnus-configure-windows 'article)
6181 (if (or (null gnus-current-article)
6182 (null gnus-article-current)
6183 (/= article (cdr gnus-article-current))
6184 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6185 ;; Selected subject is different from current article's.
6186 (gnus-summary-display-article article)
6187 (gnus-summary-recenter)
6188 (when article-window
6189 (gnus-eval-in-buffer-window gnus-article-buffer
6190 (setq endp (gnus-article-prev-page lines)))
6191 (when (and move endp)
6193 (gnus-message 3 "Beginning of message"))
6195 (if (and (eq gnus-summary-goto-unread 'never)
6196 (not (gnus-summary-first-article-p article)))
6197 (gnus-summary-prev-article)
6198 (gnus-summary-prev-unread-article))))))))
6199 (gnus-summary-position-point))
6201 (defun gnus-summary-prev-page-or-article (&optional lines)
6202 "Show previous page of selected article.
6203 Argument LINES specifies lines to be scrolled down.
6204 If at the beginning of the article, go to the next article."
6206 (gnus-summary-prev-page lines t))
6208 (defun gnus-summary-scroll-up (lines)
6209 "Scroll up (or down) one line current article.
6210 Argument LINES specifies lines to be scrolled up (or down if negative)."
6212 (gnus-configure-windows 'article)
6213 (gnus-summary-show-thread)
6214 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6215 (gnus-eval-in-buffer-window gnus-article-buffer
6217 (when (gnus-article-next-page lines)
6218 (gnus-message 3 "End of message")))
6220 (gnus-article-prev-page (- lines))))))
6221 (gnus-summary-recenter)
6222 (gnus-summary-position-point))
6224 (defun gnus-summary-scroll-down (lines)
6225 "Scroll down (or up) one line current article.
6226 Argument LINES specifies lines to be scrolled down (or up if negative)."
6228 (gnus-summary-scroll-up (- lines)))
6230 (defun gnus-summary-next-same-subject ()
6231 "Select next article which has the same subject as current one."
6233 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6235 (defun gnus-summary-prev-same-subject ()
6236 "Select previous article which has the same subject as current one."
6238 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6240 (defun gnus-summary-next-unread-same-subject ()
6241 "Select next unread article which has the same subject as current one."
6243 (gnus-summary-next-article t (gnus-summary-article-subject)))
6245 (defun gnus-summary-prev-unread-same-subject ()
6246 "Select previous unread article which has the same subject as current one."
6248 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6250 (defun gnus-summary-first-unread-article ()
6251 "Select the first unread article.
6252 Return nil if there are no unread articles."
6255 (when (gnus-summary-first-subject t)
6256 (gnus-summary-show-thread)
6257 (gnus-summary-first-subject t)
6258 (gnus-summary-display-article (gnus-summary-article-number)))
6259 (gnus-summary-position-point)))
6261 (defun gnus-summary-first-unread-subject ()
6262 "Place the point on the subject line of the first unread article.
6263 Return nil if there are no unread articles."
6266 (when (gnus-summary-first-subject t)
6267 (gnus-summary-show-thread)
6268 (gnus-summary-first-subject t))
6269 (gnus-summary-position-point)))
6271 (defun gnus-summary-first-article ()
6272 "Select the first article.
6273 Return nil if there are no articles."
6276 (when (gnus-summary-first-subject)
6277 (gnus-summary-show-thread)
6278 (gnus-summary-first-subject)
6279 (gnus-summary-display-article (gnus-summary-article-number)))
6280 (gnus-summary-position-point)))
6282 (defun gnus-summary-best-unread-article ()
6283 "Select the unread article with the highest score."
6285 (let ((best -1000000)
6286 (data gnus-newsgroup-data)
6289 (and (gnus-data-unread-p (car data))
6291 (gnus-summary-article-score (gnus-data-number (car data))))
6294 article (gnus-data-number (car data))))
6295 (setq data (cdr data)))
6298 (gnus-summary-goto-article article)
6299 (error "No unread articles"))
6300 (gnus-summary-position-point))))
6302 (defun gnus-summary-last-subject ()
6303 "Go to the last displayed subject line in the group."
6304 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6306 (gnus-summary-goto-subject article))))
6308 (defun gnus-summary-goto-article (article &optional all-headers force)
6309 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6310 If ALL-HEADERS is non-nil, no header lines are hidden.
6311 If FORCE, go to the article even if it isn't displayed. If FORCE
6312 is a number, it is the line the article is to be displayed on."
6316 "Article number or Message-ID: "
6317 (mapcar (lambda (number) (list (int-to-string number)))
6318 gnus-newsgroup-limit))
6322 (if (and (stringp article)
6323 (string-match "@" article))
6324 (gnus-summary-refer-article article)
6325 (when (stringp article)
6326 (setq article (string-to-number article)))
6327 (if (gnus-summary-goto-subject article force)
6328 (gnus-summary-display-article article all-headers)
6329 (gnus-message 4 "Couldn't go to article %s" article) nil))
6330 (gnus-summary-position-point)))
6332 (defun gnus-summary-goto-last-article ()
6333 "Go to the previously read article."
6336 (when gnus-last-article
6337 (gnus-summary-goto-article gnus-last-article nil t))
6338 (gnus-summary-position-point)))
6340 (defun gnus-summary-pop-article (number)
6341 "Pop one article off the history and go to the previous.
6342 NUMBER articles will be popped off."
6345 (setq gnus-newsgroup-history
6346 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6348 (gnus-summary-goto-article (car to) nil t)
6349 (error "Article history empty")))
6350 (gnus-summary-position-point))
6352 ;; Summary commands and functions for limiting the summary buffer.
6354 (defun gnus-summary-limit-to-articles (n)
6355 "Limit the summary buffer to the next N articles.
6356 If not given a prefix, use the process marked articles instead."
6359 (let ((articles (gnus-summary-work-articles n)))
6360 (setq gnus-newsgroup-processable nil)
6361 (gnus-summary-limit articles))
6362 (gnus-summary-position-point)))
6364 (defun gnus-summary-pop-limit (&optional total)
6365 "Restore the previous limit.
6366 If given a prefix, remove all limits."
6369 (setq gnus-newsgroup-limits
6370 (list (mapcar (lambda (h) (mail-header-number h))
6371 gnus-newsgroup-headers))))
6372 (unless gnus-newsgroup-limits
6373 (error "No limit to pop"))
6375 (gnus-summary-limit nil 'pop)
6376 (gnus-summary-position-point)))
6378 (defun gnus-summary-limit-to-subject (subject &optional header)
6379 "Limit the summary buffer to articles that have subjects that match a regexp."
6380 (interactive "sLimit to subject (regexp): ")
6382 (setq header "subject"))
6383 (when (not (equal "" subject))
6385 (let ((articles (gnus-summary-find-matching
6386 (or header "subject") subject 'all)))
6388 (error "Found no matches for \"%s\"" subject))
6389 (gnus-summary-limit articles))
6390 (gnus-summary-position-point))))
6392 (defun gnus-summary-limit-to-author (from)
6393 "Limit the summary buffer to articles that have authors that match a regexp."
6394 (interactive "sLimit to author (regexp): ")
6395 (gnus-summary-limit-to-subject from "from"))
6397 (defun gnus-summary-limit-to-age (age &optional younger-p)
6398 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6399 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6400 articles that are younger than AGE days."
6402 (let ((younger current-prefix-arg)
6405 (while (not days-got)
6406 (setq days (if younger
6407 (read-string "Limit to articles within (in days): ")
6408 (read-string "Limit to articles old than (in days): ")))
6409 (when (> (length days) 0)
6410 (setq days (read days)))
6413 (message "Please enter a number.")
6415 (list days younger)))
6417 (let ((data gnus-newsgroup-data)
6418 (cutoff (days-to-time age))
6419 articles d date is-younger)
6420 (while (setq d (pop data))
6421 (when (and (vectorp (gnus-data-header d))
6422 (setq date (mail-header-date (gnus-data-header d))))
6423 (setq is-younger (time-less-p
6424 (time-since (condition-case ()
6431 (push (gnus-data-number d) articles))))
6432 (gnus-summary-limit (nreverse articles)))
6433 (gnus-summary-position-point)))
6435 (defun gnus-summary-limit-to-extra (header regexp)
6436 "Limit the summary buffer to articles that match an 'extra' header."
6440 (gnus-completing-read
6441 (symbol-name (car gnus-extra-headers))
6442 "Limit extra header:"
6444 (cons (symbol-name x) x))
6449 (read-string (format "Limit to header %s (regexp): " header)))))
6450 (when (not (equal "" regexp))
6452 (let ((articles (gnus-summary-find-matching
6453 (cons 'extra header) regexp 'all)))
6455 (error "Found no matches for \"%s\"" regexp))
6456 (gnus-summary-limit articles))
6457 (gnus-summary-position-point))))
6459 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6461 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6463 (defun gnus-summary-limit-to-unread (&optional all)
6464 "Limit the summary buffer to articles that are not marked as read.
6465 If ALL is non-nil, limit strictly to unread articles."
6468 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6469 (gnus-summary-limit-to-marks
6470 ;; Concat all the marks that say that an article is read and have
6472 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6473 gnus-killed-mark gnus-kill-file-mark
6474 gnus-low-score-mark gnus-expirable-mark
6475 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6476 gnus-duplicate-mark gnus-souped-mark)
6479 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6480 (make-obsolete 'gnus-summary-delete-marked-with
6481 'gnus-summary-limit-exlude-marks)
6483 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6484 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6485 If REVERSE, limit the summary buffer to articles that are marked
6486 with MARKS. MARKS can either be a string of marks or a list of marks.
6487 Returns how many articles were removed."
6488 (interactive "sMarks: ")
6489 (gnus-summary-limit-to-marks marks t))
6491 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6492 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6493 If REVERSE (the prefix), limit the summary buffer to articles that are
6494 not marked with MARKS. MARKS can either be a string of marks or a
6496 Returns how many articles were removed."
6497 (interactive "sMarks: \nP")
6499 (let ((data gnus-newsgroup-data)
6500 (marks (if (listp marks) marks
6501 (append marks nil))) ; Transform to list.
6504 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6505 (memq (gnus-data-mark (car data)) marks))
6506 (push (gnus-data-number (car data)) articles))
6507 (setq data (cdr data)))
6508 (gnus-summary-limit articles))
6509 (gnus-summary-position-point)))
6511 (defun gnus-summary-limit-to-score (&optional score)
6512 "Limit to articles with score at or above SCORE."
6514 (setq score (if score
6515 (prefix-numeric-value score)
6516 (or gnus-summary-default-score 0)))
6517 (let ((data gnus-newsgroup-data)
6520 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6522 (push (gnus-data-number (car data)) articles))
6523 (setq data (cdr data)))
6525 (gnus-summary-limit articles)
6526 (gnus-summary-position-point))))
6528 (defun gnus-summary-limit-include-thread (id)
6529 "Display all the hidden articles that in the current thread."
6530 (interactive (list (mail-header-id (gnus-summary-article-header))))
6531 (let ((articles (gnus-articles-in-thread
6532 (gnus-id-to-thread (gnus-root-id id)))))
6534 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6535 (gnus-summary-position-point))))
6537 (defun gnus-summary-limit-include-dormant ()
6538 "Display all the hidden articles that are marked as dormant.
6539 Note that this command only works on a subset of the articles currently
6540 fetched for this group."
6542 (unless gnus-newsgroup-dormant
6543 (error "There are no dormant articles in this group"))
6545 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6546 (gnus-summary-position-point)))
6548 (defun gnus-summary-limit-exclude-dormant ()
6549 "Hide all dormant articles."
6552 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6553 (gnus-summary-position-point)))
6555 (defun gnus-summary-limit-exclude-childless-dormant ()
6556 "Hide all dormant articles that have no children."
6558 (let ((data (gnus-data-list t))
6559 articles d children)
6560 ;; Find all articles that are either not dormant or have
6562 (while (setq d (pop data))
6563 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6565 (gnus-article-children (gnus-data-number d)))
6568 (when (memq (car children) articles)
6573 (push (gnus-data-number d) articles)))
6576 (gnus-summary-limit articles)
6577 (gnus-summary-position-point))))
6579 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6580 "Mark all unread excluded articles as read.
6581 If ALL, mark even excluded ticked and dormants as read."
6583 (let ((articles (gnus-sorted-complement
6585 (mapcar (lambda (h) (mail-header-number h))
6586 gnus-newsgroup-headers)
6588 (sort gnus-newsgroup-limit '<)))
6590 (setq gnus-newsgroup-unreads
6591 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6593 (setq gnus-newsgroup-dormant nil
6594 gnus-newsgroup-marked nil
6595 gnus-newsgroup-reads
6597 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6598 gnus-newsgroup-reads))
6599 (while (setq article (pop articles))
6600 (unless (or (memq article gnus-newsgroup-dormant)
6601 (memq article gnus-newsgroup-marked))
6602 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6604 (defun gnus-summary-limit (articles &optional pop)
6606 ;; We pop the previous limit off the stack and use that.
6607 (setq articles (car gnus-newsgroup-limits)
6608 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6609 ;; We use the new limit, so we push the old limit on the stack.
6610 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6612 (setq gnus-newsgroup-limit articles)
6613 (let ((total (length gnus-newsgroup-data))
6614 (data (gnus-data-find-list (gnus-summary-article-number)))
6615 (gnus-summary-mark-below nil) ; Inhibit this.
6617 ;; This will do all the work of generating the new summary buffer
6618 ;; according to the new limit.
6619 (gnus-summary-prepare)
6620 ;; Hide any threads, possibly.
6621 (and gnus-show-threads
6622 gnus-thread-hide-subtree
6623 (gnus-summary-hide-all-threads))
6624 ;; Try to return to the article you were at, or one in the
6627 ;; We try to find some article after the current one.
6629 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6632 (setq data (cdr data))))
6634 ;; If there is no data, that means that we were after the last
6635 ;; article. The same goes when we can't find any articles
6636 ;; after the current one.
6637 (goto-char (point-max))
6638 (gnus-summary-find-prev))
6639 (gnus-set-mode-line 'summary)
6640 ;; We return how many articles were removed from the summary
6641 ;; buffer as a result of the new limit.
6642 (- total (length gnus-newsgroup-data))))
6644 (defsubst gnus-invisible-cut-children (threads)
6647 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6652 (defsubst gnus-cut-thread (thread)
6653 "Go forwards in the thread until we find an article that we want to display."
6654 (when (or (eq gnus-fetch-old-headers 'some)
6655 (eq gnus-fetch-old-headers 'invisible)
6656 (numberp gnus-fetch-old-headers)
6657 (eq gnus-build-sparse-threads 'some)
6658 (eq gnus-build-sparse-threads 'more))
6659 ;; Deal with old-fetched headers and sparse threads.
6663 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6664 (gnus-summary-article-ancient-p
6665 (mail-header-number (car thread))))
6666 (if (or (<= (length (cdr thread)) 1)
6667 (eq gnus-fetch-old-headers 'invisible))
6668 (setq gnus-newsgroup-limit
6669 (delq (mail-header-number (car thread))
6670 gnus-newsgroup-limit)
6671 thread (cadr thread))
6672 (when (gnus-invisible-cut-children (cdr thread))
6673 (let ((th (cdr thread)))
6675 (if (memq (mail-header-number (caar th))
6676 gnus-newsgroup-limit)
6677 (setq thread (car th)
6679 (setq th (cdr th))))))))))
6682 (defun gnus-cut-threads (threads)
6683 "Cut off all uninteresting articles from the beginning of threads."
6684 (when (or (eq gnus-fetch-old-headers 'some)
6685 (eq gnus-fetch-old-headers 'invisible)
6686 (numberp gnus-fetch-old-headers)
6687 (eq gnus-build-sparse-threads 'some)
6688 (eq gnus-build-sparse-threads 'more))
6691 (setcar th (gnus-cut-thread (car th)))
6692 (setq th (cdr th)))))
6693 ;; Remove nixed out threads.
6696 (defun gnus-summary-initial-limit (&optional show-if-empty)
6697 "Figure out what the initial limit is supposed to be on group entry.
6698 This entails weeding out unwanted dormants, low-scored articles,
6699 fetch-old-headers verbiage, and so on."
6700 ;; Most groups have nothing to remove.
6701 (if (or gnus-inhibit-limiting
6702 (and (null gnus-newsgroup-dormant)
6703 (not (eq gnus-fetch-old-headers 'some))
6704 (not (numberp gnus-fetch-old-headers))
6705 (not (eq gnus-fetch-old-headers 'invisible))
6706 (null gnus-summary-expunge-below)
6707 (not (eq gnus-build-sparse-threads 'some))
6708 (not (eq gnus-build-sparse-threads 'more))
6709 (null gnus-thread-expunge-below)
6710 (not gnus-use-nocem)))
6712 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6713 (setq gnus-newsgroup-limit nil)
6716 (unless (car (symbol-value node))
6717 ;; These threads have no parents -- they are roots.
6718 (let ((nodes (cdr (symbol-value node)))
6721 (if (and gnus-thread-expunge-below
6722 (< (gnus-thread-total-score (car nodes))
6723 gnus-thread-expunge-below))
6724 (gnus-expunge-thread (pop nodes))
6725 (setq thread (pop nodes))
6726 (gnus-summary-limit-children thread))))))
6727 gnus-newsgroup-dependencies)
6728 ;; If this limitation resulted in an empty group, we might
6729 ;; pop the previous limit and use it instead.
6730 (when (and (not gnus-newsgroup-limit)
6732 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6733 gnus-newsgroup-limit))
6735 (defun gnus-summary-limit-children (thread)
6736 "Return 1 if this subthread is visible and 0 if it is not."
6737 ;; First we get the number of visible children to this thread. This
6738 ;; is done by recursing down the thread using this function, so this
6739 ;; will really go down to a leaf article first, before slowly
6740 ;; working its way up towards the root.
6744 (apply '+ (mapcar 'gnus-summary-limit-children
6747 (number (mail-header-number (car thread)))
6750 (not (memq number gnus-newsgroup-marked))
6752 ;; If this article is dormant and has absolutely no visible
6753 ;; children, then this article isn't visible.
6754 (and (memq number gnus-newsgroup-dormant)
6756 ;; If this is "fetch-old-headered" and there is no
6757 ;; visible children, then we don't want this article.
6758 (and (or (eq gnus-fetch-old-headers 'some)
6759 (numberp gnus-fetch-old-headers))
6760 (gnus-summary-article-ancient-p number)
6762 ;; If this is "fetch-old-headered" and `invisible', then
6763 ;; we don't want this article.
6764 (and (eq gnus-fetch-old-headers 'invisible)
6765 (gnus-summary-article-ancient-p number))
6766 ;; If this is a sparsely inserted article with no children,
6767 ;; we don't want it.
6768 (and (eq gnus-build-sparse-threads 'some)
6769 (gnus-summary-article-sparse-p number)
6771 ;; If we use expunging, and this article is really
6772 ;; low-scored, then we don't want this article.
6773 (when (and gnus-summary-expunge-below
6775 (or (cdr (assq number gnus-newsgroup-scored))
6776 gnus-summary-default-score))
6777 gnus-summary-expunge-below))
6778 ;; We increase the expunge-tally here, but that has
6779 ;; nothing to do with the limits, really.
6780 (incf gnus-newsgroup-expunged-tally)
6781 ;; We also mark as read here, if that's wanted.
6782 (when (and gnus-summary-mark-below
6783 (< score gnus-summary-mark-below))
6784 (setq gnus-newsgroup-unreads
6785 (delq number gnus-newsgroup-unreads))
6786 (if gnus-newsgroup-auto-expire
6787 (push number gnus-newsgroup-expirable)
6788 (push (cons number gnus-low-score-mark)
6789 gnus-newsgroup-reads)))
6791 ;; Check NoCeM things.
6792 (if (and gnus-use-nocem
6793 (gnus-nocem-unwanted-article-p
6794 (mail-header-id (car thread))))
6796 (setq gnus-newsgroup-unreads
6797 (delq number gnus-newsgroup-unreads))
6799 ;; Nope, invisible article.
6801 ;; Ok, this article is to be visible, so we add it to the limit
6803 (push number gnus-newsgroup-limit)
6806 (defun gnus-expunge-thread (thread)
6807 "Mark all articles in THREAD as read."
6808 (let* ((number (mail-header-number (car thread))))
6809 (incf gnus-newsgroup-expunged-tally)
6810 ;; We also mark as read here, if that's wanted.
6811 (setq gnus-newsgroup-unreads
6812 (delq number gnus-newsgroup-unreads))
6813 (if gnus-newsgroup-auto-expire
6814 (push number gnus-newsgroup-expirable)
6815 (push (cons number gnus-low-score-mark)
6816 gnus-newsgroup-reads)))
6817 ;; Go recursively through all subthreads.
6818 (mapcar 'gnus-expunge-thread (cdr thread)))
6820 ;; Summary article oriented commands
6822 (defun gnus-summary-refer-parent-article (n)
6823 "Refer parent article N times.
6824 If N is negative, go to ancestor -N instead.
6825 The difference between N and the number of articles fetched is returned."
6829 (when (not (natnump n))
6834 (setq header (gnus-summary-article-header))
6835 (if (and (eq (mail-header-number header)
6836 (cdr gnus-article-current))
6837 (equal gnus-newsgroup-name
6838 (car gnus-article-current)))
6839 ;; If we try to find the parent of the currently
6840 ;; displayed article, then we take a look at the actual
6841 ;; References header, since this is slightly more
6842 ;; reliable than the References field we got from the
6845 (set-buffer gnus-original-article-buffer)
6846 (nnheader-narrow-to-headers)
6847 (unless (setq ref (message-fetch-field "references"))
6848 (setq ref (message-fetch-field "in-reply-to")))
6851 ;; It's not the current article, so we take a bet on
6852 ;; the value we got from the server.
6853 (mail-header-references header)))
6855 (not (equal ref "")))
6856 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6857 (gnus-message 1 "Couldn't find parent"))
6858 (gnus-message 1 "No references in article %d"
6859 (gnus-summary-article-number))
6862 (gnus-summary-position-point)
6865 (defun gnus-summary-refer-references ()
6866 "Fetch all articles mentioned in the References header.
6867 Return the number of articles fetched."
6869 (let ((ref (mail-header-references (gnus-summary-article-header)))
6870 (current (gnus-summary-article-number))
6874 (error "No References in the current article")
6875 ;; For each Message-ID in the References header...
6876 (while (string-match "<[^>]*>" ref)
6878 ;; ... fetch that article.
6879 (gnus-summary-refer-article
6880 (prog1 (match-string 0 ref)
6881 (setq ref (substring ref (match-end 0))))))
6882 (gnus-summary-goto-subject current)
6883 (gnus-summary-position-point)
6886 (defun gnus-summary-refer-thread (&optional limit)
6887 "Fetch all articles in the current thread.
6888 If LIMIT (the numerical prefix), fetch that many old headers instead
6889 of what's specified by the `gnus-refer-thread-limit' variable."
6891 (let ((id (mail-header-id (gnus-summary-article-header)))
6892 (limit (if limit (prefix-numeric-value limit)
6893 gnus-refer-thread-limit)))
6894 ;; We want to fetch LIMIT *old* headers, but we also have to
6895 ;; re-fetch all the headers in the current buffer, because many of
6896 ;; them may be undisplayed. So we adjust LIMIT.
6897 (when (numberp limit)
6898 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6899 (unless (eq gnus-fetch-old-headers 'invisible)
6900 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6901 ;; Retrieve the headers and read them in.
6902 (if (eq (gnus-retrieve-headers
6903 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6905 (gnus-build-all-threads)
6906 (error "Can't fetch thread from backends that don't support NOV"))
6907 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6908 (gnus-summary-limit-include-thread id)))
6910 (defun gnus-summary-refer-article (message-id)
6911 "Fetch an article specified by MESSAGE-ID."
6912 (interactive "sMessage-ID: ")
6913 (when (and (stringp message-id)
6914 (not (zerop (length message-id))))
6915 ;; Construct the correct Message-ID if necessary.
6916 ;; Suggested by tale@pawl.rpi.edu.
6917 (unless (string-match "^<" message-id)
6918 (setq message-id (concat "<" message-id)))
6919 (unless (string-match ">$" message-id)
6920 (setq message-id (concat message-id ">")))
6921 (let* ((header (gnus-id-to-header message-id))
6923 (gnus-summary-article-sparse-p
6924 (mail-header-number header))
6925 (memq (mail-header-number header)
6926 gnus-newsgroup-limit)))
6929 ;; If the article is present in the buffer we just go to it.
6931 (or (not (gnus-summary-article-sparse-p
6932 (mail-header-number header)))
6935 (gnus-summary-goto-article
6936 (mail-header-number header) nil t)
6938 (gnus-summary-update-article (mail-header-number header)))))
6940 ;; We fetch the article.
6942 (dolist (gnus-override-method (gnus-refer-article-methods))
6943 (gnus-check-server gnus-override-method)
6944 ;; Fetch the header, and display the article.
6945 (when (setq number (gnus-summary-insert-subject message-id))
6946 (gnus-summary-select-article nil nil nil number)
6948 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6950 (defun gnus-refer-article-methods ()
6951 "Return a list of referrable methods."
6953 ;; No method, so we default to current and native.
6954 ((null gnus-refer-article-method)
6955 (list gnus-current-select-method gnus-select-method))
6957 ((eq 'current gnus-refer-article-method)
6958 (list gnus-current-select-method))
6959 ;; List of select methods.
6960 ((not (and (symbolp (car gnus-refer-article-method))
6961 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
6963 (dolist (method gnus-refer-article-method)
6964 (push (if (eq 'current method)
6965 gnus-current-select-method
6969 ;; One single select method.
6971 (list gnus-refer-article-method))))
6973 (defun gnus-summary-edit-parameters ()
6974 "Edit the group parameters of the current group."
6976 (gnus-group-edit-group gnus-newsgroup-name 'params))
6978 (defun gnus-summary-customize-parameters ()
6979 "Customize the group parameters of the current group."
6981 (gnus-group-customize gnus-newsgroup-name))
6983 (defun gnus-summary-enter-digest-group (&optional force)
6984 "Enter an nndoc group based on the current article.
6985 If FORCE, force a digest interpretation. If not, try
6986 to guess what the document format is."
6988 (let ((conf gnus-current-window-configuration))
6990 (gnus-summary-select-article))
6991 (setq gnus-current-window-configuration conf)
6992 (let* ((name (format "%s-%d"
6993 (gnus-group-prefixed-name
6994 gnus-newsgroup-name (list 'nndoc ""))
6996 (set-buffer gnus-summary-buffer)
6997 gnus-current-article)))
6998 (ogroup gnus-newsgroup-name)
6999 (params (append (gnus-info-params (gnus-get-info ogroup))
7000 (list (cons 'to-group ogroup))
7001 (list (cons 'save-article-group ogroup))))
7002 (case-fold-search t)
7003 (buf (current-buffer))
7006 (set-buffer gnus-original-article-buffer)
7007 ;; Have the digest group inherit the main mail address of
7008 ;; the parent article.
7009 (when (setq to-address (or (message-fetch-field "reply-to")
7010 (message-fetch-field "from")))
7011 (setq params (append
7012 (list (cons 'to-address
7013 (funcall gnus-decode-encoded-word-function
7015 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7016 (insert-buffer-substring gnus-original-article-buffer)
7017 ;; Remove lines that may lead nndoc to misinterpret the
7020 (goto-char (point-min))
7021 (or (search-forward "\n\n" nil t) (point)))
7022 (goto-char (point-min))
7023 (delete-matching-lines "^Path:\\|^From ")
7026 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7027 (gnus-newsgroup-ephemeral-ignored-charsets
7028 gnus-newsgroup-ignored-charsets))
7029 (gnus-group-read-ephemeral-group
7030 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7032 ,(if force 'mbox 'guess))) t))
7033 ;; Make all postings to this group go to the parent group.
7034 (nconc (gnus-info-params (gnus-get-info name))
7036 ;; Couldn't select this doc group.
7037 (switch-to-buffer buf)
7038 (gnus-set-global-variables)
7039 (gnus-configure-windows 'summary)
7040 (gnus-message 3 "Article couldn't be entered?"))
7041 (kill-buffer dig)))))
7043 (defun gnus-summary-read-document (n)
7044 "Open a new group based on the current article(s).
7045 This will allow you to read digests and other similar
7046 documents as newsgroups.
7047 Obeys the standard process/prefix convention."
7049 (let* ((articles (gnus-summary-work-articles n))
7050 (ogroup gnus-newsgroup-name)
7051 (params (append (gnus-info-params (gnus-get-info ogroup))
7052 (list (cons 'to-group ogroup))))
7053 article group egroup groups vgroup)
7054 (while (setq article (pop articles))
7055 (setq group (format "%s-%d" gnus-newsgroup-name article))
7056 (gnus-summary-remove-process-mark article)
7057 (when (gnus-summary-display-article article)
7060 (insert-buffer-substring gnus-original-article-buffer)
7061 ;; Remove some headers that may lead nndoc to make
7063 (message-narrow-to-head)
7064 (goto-char (point-min))
7065 (delete-matching-lines "^\\(Path\\):\\|^From ")
7068 (gnus-group-read-ephemeral-group
7069 group `(nndoc ,group (nndoc-address ,(current-buffer))
7070 (nndoc-article-type guess))
7073 ;; Make all postings to this group go to the parent group.
7074 (nconc (gnus-info-params (gnus-get-info egroup))
7076 (push egroup groups))
7077 ;; Couldn't select this doc group.
7078 (gnus-error 3 "Article couldn't be entered"))))))
7079 ;; Now we have selected all the documents.
7082 (error "None of the articles could be interpreted as documents"))
7083 ((gnus-group-read-ephemeral-group
7084 (setq vgroup (format
7085 "nnvirtual:%s-%s" gnus-newsgroup-name
7086 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7087 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7089 (cons (current-buffer) 'summary)))
7091 (error "Couldn't select virtual nndoc group")))))
7093 (defun gnus-summary-isearch-article (&optional regexp-p)
7094 "Do incremental search forward on the current article.
7095 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7097 (let* ((gnus-inhibit-treatment t)
7098 (old (gnus-summary-select-article)))
7099 (gnus-configure-windows 'article)
7100 (gnus-eval-in-buffer-window gnus-article-buffer
7104 (gnus-article-show-all-headers))
7105 (goto-char (point-min))
7106 (isearch-forward regexp-p)))))
7108 (defun gnus-summary-search-article-forward (regexp &optional backward)
7109 "Search for an article containing REGEXP forward.
7110 If BACKWARD, search backward instead."
7113 (format "Search article %s (regexp%s): "
7114 (if current-prefix-arg "backward" "forward")
7115 (if gnus-last-search-regexp
7116 (concat ", default " gnus-last-search-regexp)
7118 current-prefix-arg))
7119 (if (string-equal regexp "")
7120 (setq regexp (or gnus-last-search-regexp ""))
7121 (setq gnus-last-search-regexp regexp)
7122 (setq gnus-article-before-search gnus-current-article))
7123 ;; Intentionally set gnus-last-article.
7124 (setq gnus-last-article gnus-article-before-search)
7125 (let ((gnus-last-article gnus-last-article))
7126 (if (gnus-summary-search-article regexp backward)
7127 (gnus-summary-show-thread)
7128 (error "Search failed: \"%s\"" regexp))))
7130 (defun gnus-summary-search-article-backward (regexp)
7131 "Search for an article containing REGEXP backward."
7134 (format "Search article backward (regexp%s): "
7135 (if gnus-last-search-regexp
7136 (concat ", default " gnus-last-search-regexp)
7138 (gnus-summary-search-article-forward regexp 'backward))
7141 (defmacro gnus-summary-search-article-position-point (regexp backward)
7142 "Dehighlight the last matched text and goto the beginning position."
7143 (` (if (and gnus-summary-search-article-matched-data
7144 (let ((text (caddr gnus-summary-search-article-matched-data))
7145 (inhibit-read-only t)
7148 (goto-char (car gnus-summary-search-article-matched-data))
7149 (cadr gnus-summary-search-article-matched-data))
7151 (string-match (, regexp) text)))
7152 (if (, backward) (beginning-of-line) (end-of-line))
7153 (goto-char (if (, backward) (point-max) (point-min))))))
7155 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7156 "Place point where X-Face image is displayed."
7157 (if (featurep 'xemacs)
7158 (` (let ((end (if (search-forward "\n\n" nil t)
7159 (goto-char (1- (point)))
7162 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7163 (unless (and (re-search-forward "^From:" end t)
7164 (setq extent (extent-at (point)))
7165 (extent-begin-glyph extent))
7166 (goto-char (, opoint)))))
7167 (` (let ((end (if (search-forward "\n\n" nil t)
7168 (goto-char (1- (point)))
7171 (or (text-property-any (or (search-backward "\n\n" nil t)
7173 end 'x-face-mule-bitmap-image t)
7176 (defmacro gnus-summary-search-article-highlight-matched-text
7177 (backward treated x-face)
7178 "Highlight matched text in the function `gnus-summary-search-article'."
7179 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7180 (end (set-marker (make-marker) (match-end 0)))
7181 (inhibit-read-only t)
7185 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7187 (lambda (item) (setq items (delq item items)))
7188 '(gnus-treat-buttonize
7189 gnus-treat-fill-article
7190 gnus-treat-fill-long-lines
7191 gnus-treat-emphasize
7192 gnus-treat-highlight-headers
7193 gnus-treat-highlight-citation
7194 gnus-treat-highlight-signature
7195 gnus-treat-overstrike
7196 gnus-treat-display-xface
7197 gnus-treat-buttonize-head
7198 gnus-treat-decode-article-as-default-mime-charset))
7199 (static-if (featurep 'xemacs)
7201 (cons '(x-face-mule-delete-x-face-field
7204 (gnus-treat-display-xface
7205 (when (, x-face) gnus-treat-display-xface)))
7206 (gnus-article-prepare-mime-display)))
7207 (goto-char (if (, backward) start end))
7209 (gnus-summary-search-article-highlight-goto-x-face (point)))
7210 (setq gnus-summary-search-article-matched-data
7211 (list start end (buffer-substring start end)))
7212 (unless (eq start end);; matched text has been deleted. :-<
7213 (put-text-property start end 'face
7214 (or (find-face 'isearch)
7215 'secondary-selection))))))
7218 (defun gnus-summary-search-article (regexp &optional backward)
7219 "Search for an article containing REGEXP.
7220 Optional argument BACKWARD means do search for backward.
7221 `gnus-select-article-hook' is not called during the search."
7222 ;; We have to require this here to make sure that the following
7223 ;; dynamic binding isn't shadowed by autoloading.
7224 (require 'gnus-async)
7226 (let ((gnus-select-article-hook nil) ;Disable hook.
7227 (gnus-article-display-hook nil)
7228 (gnus-article-prepare-hook nil)
7229 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7230 (gnus-use-article-prefetch nil)
7231 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7232 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7233 (sum (current-buffer))
7236 (gnus-save-hidden-threads
7237 (static-if (featurep 'xemacs)
7238 (let ((gnus-inhibit-treatment t))
7239 (setq treated (eq 'old (gnus-summary-select-article)))
7241 (not (and (gnus-buffer-live-p gnus-article-buffer)
7242 (window-live-p (get-buffer-window
7243 gnus-article-buffer t)))))
7244 (gnus-summary-select-article nil t)
7245 (setq treated nil)))
7246 (let ((gnus-inhibit-treatment t)
7247 (x-face-mule-delete-x-face-field 'never))
7248 (setq treated (eq 'old (gnus-summary-select-article)))
7251 (and (gnus-buffer-live-p gnus-article-buffer)
7252 (window-live-p (get-buffer-window
7253 gnus-article-buffer t))
7254 (or (not (string-match "^\\^X-Face:" regexp))
7255 (with-current-buffer gnus-article-buffer
7256 gnus-summary-search-article-matched-data)))))
7257 (gnus-summary-select-article nil t)
7258 (setq treated nil))))
7259 (set-buffer gnus-article-buffer)
7263 (gnus-article-show-all-headers)
7264 (gnus-summary-search-article-position-point regexp backward))
7265 (goto-char (if backward (point-max) (point-min))))
7267 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7269 (re-search-backward regexp nil t)
7270 (re-search-forward regexp nil t))
7271 ;; We found the regexp.
7273 (gnus-summary-search-article-highlight-matched-text
7274 backward treated (string-match "^\\^X-Face:" regexp))
7277 (/ (- 2 (window-height
7278 (get-buffer-window gnus-article-buffer t)))
7281 (get-buffer-window (current-buffer))
7284 (setq point (point)))
7285 ;; We didn't find it, so we go to the next article.
7288 (while (eq found 'not)
7289 (if (not (if backward (gnus-summary-find-prev)
7290 (gnus-summary-find-next)))
7291 ;; No more articles.
7293 ;; Select the next article and adjust point.
7294 (unless (gnus-summary-article-sparse-p
7295 (gnus-summary-article-number))
7297 (let ((gnus-inhibit-treatment t))
7298 (gnus-summary-select-article))
7300 (set-buffer gnus-article-buffer)
7302 (goto-char (if backward (point-max) (point-min))))))))
7303 (gnus-message 7 ""))
7304 ;; Return whether we found the regexp.
7305 (when (eq found 'found)
7307 (gnus-summary-show-thread)
7308 (gnus-summary-goto-subject gnus-current-article)
7309 (gnus-summary-position-point)
7312 (defun gnus-summary-find-matching (header regexp &optional backward unread
7314 "Return a list of all articles that match REGEXP on HEADER.
7315 The search stars on the current article and goes forwards unless
7316 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7317 If UNREAD is non-nil, only unread articles will
7318 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7319 in the comparisons."
7320 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7321 (gnus-data-find-list
7322 (gnus-summary-article-number) (gnus-data-list backward))))
7323 (case-fold-search (not not-case-fold))
7326 (if (eq (car header) 'extra)
7329 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7331 (error "%s is an invalid header" header))
7332 (unless (fboundp (intern (concat "mail-header-" header)))
7333 (error "%s is not a valid header" header))
7334 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7337 (and (or (not unread) ; We want all articles...
7338 (gnus-data-unread-p d)) ; Or just unreads.
7339 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7340 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7341 (push (gnus-data-number d) articles)) ; Success!
7342 (setq data (cdr data)))
7343 (nreverse articles)))
7345 (defun gnus-summary-execute-command (header regexp command &optional backward)
7346 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7347 If HEADER is an empty string (or nil), the match is done on the entire
7348 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7350 (list (let ((completion-ignore-case t))
7353 (mapcar (lambda (string) (list string))
7354 '("Number" "Subject" "From" "Lines" "Date"
7355 "Message-ID" "Xref" "References" "Body"))
7356 nil 'require-match))
7357 (read-string "Regexp: ")
7358 (read-key-sequence "Command: ")
7359 current-prefix-arg))
7360 (when (equal header "Body")
7362 ;; Hidden thread subtrees must be searched as well.
7363 (gnus-summary-show-all-threads)
7364 ;; We don't want to change current point nor window configuration.
7366 (save-window-excursion
7367 (gnus-message 6 "Executing %s..." (key-description command))
7368 ;; We'd like to execute COMMAND interactively so as to give arguments.
7369 (gnus-execute header regexp
7370 `(call-interactively ',(key-binding command))
7372 (gnus-message 6 "Executing %s...done" (key-description command)))))
7374 (defun gnus-summary-beginning-of-article ()
7375 "Scroll the article back to the beginning."
7377 (gnus-summary-select-article)
7378 (gnus-configure-windows 'article)
7379 (gnus-eval-in-buffer-window gnus-article-buffer
7381 (goto-char (point-min))
7382 (when gnus-page-broken
7383 (gnus-narrow-to-page))))
7385 (defun gnus-summary-end-of-article ()
7386 "Scroll to the end of the article."
7388 (gnus-summary-select-article)
7389 (gnus-configure-windows 'article)
7390 (gnus-eval-in-buffer-window gnus-article-buffer
7392 (goto-char (point-max))
7394 (when gnus-page-broken
7395 (gnus-narrow-to-page))))
7397 (defun gnus-summary-print-article (&optional filename n)
7398 "Generate and print a PostScript image of the N next (mail) articles.
7400 If N is negative, print the N previous articles. If N is nil and articles
7401 have been marked with the process mark, print these instead.
7403 If the optional first argument FILENAME is nil, send the image to the
7404 printer. If FILENAME is a string, save the PostScript image in a file with
7405 that name. If FILENAME is a number, prompt the user for the name of the file
7407 (interactive (list (ps-print-preprint current-prefix-arg)
7408 current-prefix-arg))
7409 (dolist (article (gnus-summary-work-articles n))
7410 (gnus-summary-select-article nil nil 'pseudo article)
7411 (gnus-eval-in-buffer-window gnus-article-buffer
7412 (let ((buffer (generate-new-buffer " *print*")))
7415 (copy-to-buffer buffer (point-min) (point-max))
7417 (gnus-article-delete-invisible-text)
7418 (let ((ps-left-header
7421 (mail-header-subject gnus-current-headers) ")")
7423 (mail-header-from gnus-current-headers) ")")))
7426 "/pagenumberstring load"
7428 (mail-header-date gnus-current-headers) ")"))))
7429 (gnus-run-hooks 'gnus-ps-print-hook)
7431 (ps-print-buffer-with-faces filename))))
7432 (kill-buffer buffer))))))
7434 (defun gnus-summary-show-article (&optional arg)
7435 "Force re-fetching of the current article.
7436 If ARG (the prefix) is a number, show the article with the charset
7437 defined in `gnus-summary-show-article-charset-alist', or the charset
7439 If ARG (the prefix) is non-nil and not a number, show the raw article
7440 without any article massaging functions being run."
7444 (let ((gnus-newsgroup-charset
7445 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7446 (read-coding-system "Charset: ")))
7447 (gnus-newsgroup-ignored-charsets 'gnus-all))
7448 (gnus-summary-select-article nil 'force)
7449 (let ((deps gnus-newsgroup-dependencies)
7452 (set-buffer gnus-original-article-buffer)
7454 (message-narrow-to-head)
7455 (setq head (buffer-string)))
7457 (insert (format "211 %d Article retrieved.\n"
7458 (cdr gnus-article-current)))
7461 (let ((nntp-server-buffer (current-buffer)))
7462 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7463 (gnus-data-set-header
7464 (gnus-data-find (cdr gnus-article-current))
7466 (gnus-summary-update-article-line
7467 (cdr gnus-article-current) header))))
7469 ;; Select the article the normal way.
7470 (gnus-summary-select-article nil 'force))
7472 ;; We have to require this here to make sure that the following
7473 ;; dynamic binding isn't shadowed by autoloading.
7474 (require 'gnus-async)
7476 ;; Bind the article treatment functions to nil.
7477 (let ((gnus-have-all-headers t)
7478 gnus-article-display-hook
7479 gnus-article-prepare-hook
7480 gnus-article-decode-hook
7483 (gnus-summary-select-article nil 'force))))
7484 (gnus-summary-goto-subject gnus-current-article)
7485 (gnus-summary-position-point))
7487 (defun gnus-summary-verbose-headers (&optional arg)
7488 "Toggle permanent full header display.
7489 If ARG is a positive number, turn header display on.
7490 If ARG is a negative number, turn header display off."
7492 (setq gnus-show-all-headers
7493 (cond ((or (not (numberp arg))
7495 (not gnus-show-all-headers))
7498 (gnus-summary-show-article))
7500 (defun gnus-summary-toggle-header (&optional arg)
7501 "Show the headers if they are hidden, or hide them if they are shown.
7502 If ARG is a positive number, show the entire header.
7503 If ARG is a negative number, hide the unwanted header lines."
7506 (set-buffer gnus-article-buffer)
7508 (let* ((buffer-read-only nil)
7509 (inhibit-point-motion-hooks t)
7515 (article-narrow-to-head)
7516 (gnus-article-hidden-text-p 'headers))))
7517 (goto-char (point-min))
7518 (when (search-forward "\n\n" nil t)
7519 (delete-region (point-min) (1- (point))))
7520 (goto-char (point-min))
7522 (set-buffer gnus-original-article-buffer)
7523 (goto-char (point-min))
7524 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7525 (insert-buffer-substring gnus-original-article-buffer 1 e)
7527 (narrow-to-region (point-min) (point))
7528 (article-decode-encoded-words)
7530 (let ((gnus-treat-hide-headers nil)
7531 (gnus-treat-hide-boring-headers nil))
7532 (setq gnus-article-wash-types
7533 (delq 'headers gnus-article-wash-types))
7534 (gnus-treat-article 'head))
7535 (gnus-treat-article 'head)))
7536 (gnus-set-mode-line 'article)))))
7538 (defun gnus-summary-show-all-headers ()
7539 "Make all header lines visible."
7541 (gnus-article-show-all-headers))
7543 (defun gnus-summary-toggle-mime (&optional arg)
7544 "Toggle MIME processing.
7545 If ARG is a positive number, turn MIME processing on."
7547 (setq gnus-show-mime
7549 (not gnus-show-mime)
7550 (> (prefix-numeric-value arg) 0)))
7551 (gnus-summary-select-article t 'force))
7553 (defun gnus-summary-caesar-message (&optional arg)
7554 "Caesar rotate the current article by 13.
7555 The numerical prefix specifies how many places to rotate each letter
7558 (gnus-summary-select-article)
7559 (let ((mail-header-separator ""))
7560 (gnus-eval-in-buffer-window gnus-article-buffer
7563 (let ((start (window-start))
7565 (message-caesar-buffer-body arg)
7566 (set-window-start (get-buffer-window (current-buffer)) start))))))
7568 (defun gnus-summary-stop-page-breaking ()
7569 "Stop page breaking in the current article."
7571 (gnus-summary-select-article)
7572 (gnus-eval-in-buffer-window gnus-article-buffer
7574 (when (gnus-visual-p 'page-marker)
7575 (let ((buffer-read-only nil))
7576 (gnus-remove-text-with-property 'gnus-prev)
7577 (gnus-remove-text-with-property 'gnus-next))
7578 (setq gnus-page-broken nil))))
7580 (defun gnus-summary-move-article (&optional n to-newsgroup
7581 select-method action)
7582 "Move the current article to a different newsgroup.
7583 If N is a positive number, move the N next articles.
7584 If N is a negative number, move the N previous articles.
7585 If N is nil and any articles have been marked with the process mark,
7586 move those articles instead.
7587 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7588 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7589 re-spool using this method.
7591 For this function to work, both the current newsgroup and the
7592 newsgroup that you want to move to have to support the `request-move'
7593 and `request-accept' functions.
7595 ACTION can be either `move' (the default), `crosspost' or `copy'."
7598 (setq action 'move))
7599 ;; Disable marking as read.
7600 (let (gnus-mark-article-hook)
7601 (save-window-excursion
7602 (gnus-summary-select-article)))
7603 ;; Check whether the source group supports the required functions.
7604 (cond ((and (eq action 'move)
7605 (not (gnus-check-backend-function
7606 'request-move-article gnus-newsgroup-name)))
7607 (error "The current group does not support article moving"))
7608 ((and (eq action 'crosspost)
7609 (not (gnus-check-backend-function
7610 'request-replace-article gnus-newsgroup-name)))
7611 (error "The current group does not support article editing")))
7612 (let ((articles (gnus-summary-work-articles n))
7613 (prefix (if (gnus-check-backend-function
7614 'request-move-article gnus-newsgroup-name)
7615 (gnus-group-real-prefix gnus-newsgroup-name)
7617 (names '((move "Move" "Moving")
7618 (copy "Copy" "Copying")
7619 (crosspost "Crosspost" "Crossposting")))
7620 (copy-buf (save-excursion
7621 (nnheader-set-temp-buffer " *copy article*")))
7622 (default-marks gnus-article-mark-lists)
7623 (no-expire-marks (delete '(expirable . expire)
7624 (copy-sequence gnus-article-mark-lists)))
7625 art-group to-method new-xref article to-groups)
7626 (unless (assq action names)
7627 (error "Unknown action %s" action))
7628 ;; Read the newsgroup name.
7629 (when (and (not to-newsgroup)
7630 (not select-method))
7632 (gnus-read-move-group-name
7633 (cadr (assq action names))
7634 (symbol-value (intern (format "gnus-current-%s-group" action)))
7636 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7637 (setq to-method (or select-method
7638 (gnus-server-to-method
7639 (gnus-group-method to-newsgroup))))
7640 ;; Check the method we are to move this article to...
7641 (unless (gnus-check-backend-function
7642 'request-accept-article (car to-method))
7643 (error "%s does not support article copying" (car to-method)))
7644 (unless (gnus-check-server to-method)
7645 (error "Can't open server %s" (car to-method)))
7646 (gnus-message 6 "%s to %s: %s..."
7647 (caddr (assq action names))
7648 (or (car select-method) to-newsgroup) articles)
7650 (setq article (pop articles))
7654 ;; Move the article.
7656 ;; Remove this article from future suppression.
7657 (gnus-dup-unsuppress-article article)
7658 (gnus-request-move-article
7659 article ; Article to move
7660 gnus-newsgroup-name ; From newsgroup
7661 (nth 1 (gnus-find-method-for-group
7662 gnus-newsgroup-name)) ; Server
7663 (list 'gnus-request-accept-article
7664 to-newsgroup (list 'quote select-method)
7665 (not articles) t) ; Accept form
7666 (not articles))) ; Only save nov last time
7667 ;; Copy the article.
7670 (set-buffer copy-buf)
7671 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7672 (gnus-request-accept-article
7673 to-newsgroup select-method (not articles) t))))
7674 ;; Crosspost the article.
7675 ((eq action 'crosspost)
7676 (let ((xref (message-tokenize-header
7677 (mail-header-xref (gnus-summary-article-header article))
7679 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7682 (setq xref (list (system-name))))
7685 (mapconcat 'identity
7686 (delete "Xref:" (delete new-xref xref))
7690 (set-buffer copy-buf)
7691 ;; First put the article in the destination group.
7692 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7693 (when (consp (setq art-group
7694 (gnus-request-accept-article
7695 to-newsgroup select-method (not articles))))
7696 (setq new-xref (concat new-xref " " (car art-group)
7697 ":" (cdr art-group)))
7698 ;; Now we have the new Xrefs header, so we insert
7699 ;; it and replace the new article.
7700 (nnheader-replace-header "Xref" new-xref)
7701 (gnus-request-replace-article
7702 (cdr art-group) to-newsgroup (current-buffer))
7706 (gnus-message 1 "Couldn't %s article %s: %s"
7707 (cadr (assq action names)) article
7708 (nnheader-get-report (car to-method))))
7709 ((eq art-group 'junk)
7710 (when (eq action 'move)
7711 (gnus-summary-mark-article article gnus-canceled-mark)
7712 (gnus-message 4 "Deleted article %s" article)))
7714 (let* ((pto-group (gnus-group-prefixed-name
7715 (car art-group) to-method))
7717 (gnus-gethash pto-group gnus-newsrc-hashtb))
7718 (info (nth 2 entry))
7719 (to-group (gnus-info-group info))
7721 ;; Update the group that has been moved to.
7723 (memq action '(move copy)))
7724 (unless (member to-group to-groups)
7725 (push to-group to-groups))
7727 (unless (memq article gnus-newsgroup-unreads)
7728 (push 'read to-marks)
7730 info (gnus-add-to-range (gnus-info-read info)
7731 (list (cdr art-group)))))
7733 ;; See whether the article is to be put in the cache.
7734 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7737 (to-article (cdr art-group)))
7739 ;; Enter the article into the cache in the new group,
7740 ;; if that is required.
7741 (when gnus-use-cache
7742 (gnus-cache-possibly-enter-article
7744 (let ((header (copy-sequence
7745 (gnus-summary-article-header article))))
7746 (mail-header-set-number header to-article)
7748 (memq article gnus-newsgroup-marked)
7749 (memq article gnus-newsgroup-dormant)
7750 (memq article gnus-newsgroup-unreads)))
7752 (when gnus-preserve-marks
7753 ;; Copy any marks over to the new group.
7754 (when (and (equal to-group gnus-newsgroup-name)
7755 (not (memq article gnus-newsgroup-unreads)))
7756 ;; Mark this article as read in this group.
7757 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7758 (setcdr (gnus-active to-group) to-article)
7759 (setcdr gnus-newsgroup-active to-article))
7762 (when (memq article (symbol-value
7763 (intern (format "gnus-newsgroup-%s"
7765 (push (cdar marks) to-marks)
7766 ;; If the other group is the same as this group,
7767 ;; then we have to add the mark to the list.
7768 (when (equal to-group gnus-newsgroup-name)
7769 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7772 (intern (format "gnus-newsgroup-%s"
7774 ;; Copy the marks to other group.
7775 (gnus-add-marked-articles
7776 to-group (cdar marks) (list to-article) info))
7777 (setq marks (cdr marks)))
7779 (gnus-request-set-mark to-group (list (list (list to-article)
7784 (concat "(gnus-group-set-info '"
7785 (gnus-prin1-to-string (gnus-get-info to-group))
7788 ;; Update the Xref header in this article to point to
7789 ;; the new crossposted article we have just created.
7790 (when (eq action 'crosspost)
7792 (set-buffer copy-buf)
7793 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7794 (nnheader-replace-header "Xref" new-xref)
7795 (gnus-request-replace-article
7796 article gnus-newsgroup-name (current-buffer)))))
7798 ;;;!!!Why is this necessary?
7799 (set-buffer gnus-summary-buffer)
7801 (gnus-summary-goto-subject article)
7802 (when (eq action 'move)
7803 (gnus-summary-mark-article article gnus-canceled-mark))))
7804 (gnus-summary-remove-process-mark article))
7805 ;; Re-activate all groups that have been moved to.
7808 (set-buffer gnus-group-buffer)
7809 (when (gnus-group-goto-group (car to-groups) t)
7810 (gnus-group-get-new-news-this-group 1 t))
7813 (gnus-kill-buffer copy-buf)
7814 (gnus-summary-position-point)
7815 (gnus-set-mode-line 'summary)))
7817 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7818 "Move the current article to a different newsgroup.
7819 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7820 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7821 re-spool using this method."
7823 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7825 (defun gnus-summary-crosspost-article (&optional n)
7826 "Crosspost the current article to some other group."
7828 (gnus-summary-move-article n nil nil 'crosspost))
7830 (defcustom gnus-summary-respool-default-method nil
7831 "Default method for respooling an article.
7832 If nil, use to the current newsgroup method."
7833 :type '(choice (gnus-select-method :value (nnml ""))
7835 :group 'gnus-summary-mail)
7837 (defun gnus-summary-respool-article (&optional n method)
7838 "Respool the current article.
7839 The article will be squeezed through the mail spooling process again,
7840 which means that it will be put in some mail newsgroup or other
7841 depending on `nnmail-split-methods'.
7842 If N is a positive number, respool the N next articles.
7843 If N is a negative number, respool the N previous articles.
7844 If N is nil and any articles have been marked with the process mark,
7845 respool those articles instead.
7847 Respooling can be done both from mail groups and \"real\" newsgroups.
7848 In the former case, the articles in question will be moved from the
7849 current group into whatever groups they are destined to. In the
7850 latter case, they will be copied into the relevant groups."
7852 (list current-prefix-arg
7853 (let* ((methods (gnus-methods-using 'respool))
7855 (symbol-name (or gnus-summary-respool-default-method
7856 (car (gnus-find-method-for-group
7857 gnus-newsgroup-name)))))
7859 (gnus-completing-read
7860 methname "What backend do you want to use when respooling?"
7861 methods nil t nil 'gnus-mail-method-history))
7864 ((zerop (length (setq ms (gnus-servers-using-backend
7866 (list (intern method) ""))
7870 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7871 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7874 (error "No method given for respooling"))
7875 (if (assoc (symbol-name
7876 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7877 (gnus-methods-using 'respool))
7878 (gnus-summary-move-article n nil method)
7879 (gnus-summary-copy-article n nil method)))
7881 (defun gnus-summary-import-article (file)
7882 "Import an arbitrary file into a mail newsgroup."
7883 (interactive "fImport file: ")
7884 (let ((group gnus-newsgroup-name)
7885 (now (current-time))
7887 (unless (gnus-check-backend-function 'request-accept-article group)
7888 (error "%s does not support article importing" group))
7889 (or (file-readable-p file)
7890 (not (file-regular-p file))
7891 (error "Can't read %s" file))
7893 (set-buffer (gnus-get-buffer-create " *import file*"))
7895 (nnheader-insert-file-contents file)
7896 (goto-char (point-min))
7897 (unless (nnheader-article-p)
7898 ;; This doesn't look like an article, so we fudge some headers.
7899 (setq atts (file-attributes file)
7900 lines (count-lines (point-min) (point-max)))
7901 (insert "From: " (read-string "From: ") "\n"
7902 "Subject: " (read-string "Subject: ") "\n"
7903 "Date: " (message-make-date (nth 5 atts))
7905 "Message-ID: " (message-make-message-id) "\n"
7906 "Lines: " (int-to-string lines) "\n"
7907 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7908 (gnus-request-accept-article group nil t)
7909 (kill-buffer (current-buffer)))))
7911 (defun gnus-summary-article-posted-p ()
7912 "Say whether the current (mail) article is available from news as well.
7913 This will be the case if the article has both been mailed and posted."
7915 (let ((id (mail-header-references (gnus-summary-article-header)))
7916 (gnus-override-method (car (gnus-refer-article-methods))))
7917 (if (gnus-request-head id "")
7918 (gnus-message 2 "The current message was found on %s"
7919 gnus-override-method)
7920 (gnus-message 2 "The current message couldn't be found on %s"
7921 gnus-override-method)
7924 (defun gnus-summary-expire-articles (&optional now)
7925 "Expire all articles that are marked as expirable in the current group."
7927 (when (gnus-check-backend-function
7928 'request-expire-articles gnus-newsgroup-name)
7929 ;; This backend supports expiry.
7930 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7931 (expirable (if total
7933 ;; We need to update the info for
7934 ;; this group for `gnus-list-of-read-articles'
7935 ;; to give us the right answer.
7936 (gnus-run-hooks 'gnus-exit-group-hook)
7937 (gnus-summary-update-info)
7938 (gnus-list-of-read-articles gnus-newsgroup-name))
7939 (setq gnus-newsgroup-expirable
7940 (sort gnus-newsgroup-expirable '<))))
7941 (expiry-wait (if now 'immediate
7942 (gnus-group-find-parameter
7943 gnus-newsgroup-name 'expiry-wait)))
7944 (nnmail-expiry-target
7945 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7946 nnmail-expiry-target))
7949 ;; There are expirable articles in this group, so we run them
7950 ;; through the expiry process.
7951 (gnus-message 6 "Expiring articles...")
7952 (unless (gnus-check-group gnus-newsgroup-name)
7953 (error "Can't open server for %s" gnus-newsgroup-name))
7954 ;; The list of articles that weren't expired is returned.
7957 (let ((nnmail-expiry-wait-function nil)
7958 (nnmail-expiry-wait expiry-wait))
7959 (setq es (gnus-request-expire-articles
7960 expirable gnus-newsgroup-name)))
7961 (setq es (gnus-request-expire-articles
7962 expirable gnus-newsgroup-name)))
7964 (setq gnus-newsgroup-expirable es))
7965 ;; We go through the old list of expirable, and mark all
7966 ;; really expired articles as nonexistent.
7967 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7968 (let ((gnus-use-cache nil))
7970 (unless (memq (car expirable) es)
7971 (when (gnus-data-find (car expirable))
7972 (gnus-summary-mark-article
7973 (car expirable) gnus-canceled-mark)))
7974 (setq expirable (cdr expirable))))))
7975 (gnus-message 6 "Expiring articles...done")))))
7977 (defun gnus-summary-expire-articles-now ()
7978 "Expunge all expirable articles in the current group.
7979 This means that *all* articles that are marked as expirable will be
7980 deleted forever, right now."
7982 (or gnus-expert-user
7984 "Are you really, really, really sure you want to delete all these messages? ")
7986 (gnus-summary-expire-articles t))
7988 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7989 (defun gnus-summary-delete-article (&optional n)
7990 "Delete the N next (mail) articles.
7991 This command actually deletes articles. This is not a marking
7992 command. The article will disappear forever from your life, never to
7994 If N is negative, delete backwards.
7995 If N is nil and articles have been marked with the process mark,
7996 delete these instead."
7998 (unless (gnus-check-backend-function 'request-expire-articles
7999 gnus-newsgroup-name)
8000 (error "The current newsgroup does not support article deletion"))
8001 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8002 (error "Couldn't open server"))
8003 ;; Compute the list of articles to delete.
8004 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8006 (if (and gnus-novice-user
8007 (not (gnus-yes-or-no-p
8008 (format "Do you really want to delete %s forever? "
8009 (if (> (length articles) 1)
8010 (format "these %s articles" (length articles))
8013 ;; Delete the articles.
8014 (setq not-deleted (gnus-request-expire-articles
8015 articles gnus-newsgroup-name 'force))
8017 (gnus-summary-remove-process-mark (car articles))
8018 ;; The backend might not have been able to delete the article
8020 (unless (memq (car articles) not-deleted)
8021 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8022 (setq articles (cdr articles)))
8024 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8025 (gnus-summary-position-point)
8026 (gnus-set-mode-line 'summary)
8029 (defun gnus-summary-edit-article (&optional force)
8030 "Edit the current article.
8031 This will have permanent effect only in mail groups.
8032 If FORCE is non-nil, allow editing of articles even in read-only
8036 (set-buffer gnus-summary-buffer)
8037 (let ((mail-parse-charset gnus-newsgroup-charset)
8038 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8039 (gnus-set-global-variables)
8040 (when (and (not force)
8041 (gnus-group-read-only-p))
8042 (error "The current newsgroup does not support article editing"))
8043 (gnus-summary-show-article t)
8044 (gnus-article-edit-article
8046 `(lambda (no-highlight)
8047 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8048 (message-options message-options)
8049 (message-options-set-recipient)
8050 (mail-parse-ignored-charsets
8051 ',gnus-newsgroup-ignored-charsets))
8052 (gnus-summary-edit-article-done
8053 ,(or (mail-header-references gnus-current-headers) "")
8054 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8056 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8058 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8060 "Make edits to the current article permanent."
8063 ;; The buffer restriction contains the entire article if it exists.
8064 (when (article-goto-body)
8065 (let ((lines (count-lines (point) (point-max)))
8066 (length (- (point-max) (point)))
8067 (case-fold-search t)
8068 (body (copy-marker (point))))
8069 (goto-char (point-min))
8070 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8071 (delete-region (match-beginning 1) (match-end 1))
8072 (insert (number-to-string length)))
8073 (goto-char (point-min))
8074 (when (re-search-forward
8075 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8076 (delete-region (match-beginning 1) (match-end 1))
8077 (insert (number-to-string length)))
8078 (goto-char (point-min))
8079 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8080 (delete-region (match-beginning 1) (match-end 1))
8081 (insert (number-to-string lines))))))
8082 ;; Replace the article.
8083 (let ((buf (current-buffer)))
8085 (insert-buffer-substring buf)
8087 (if (and (not read-only)
8088 (not (gnus-request-replace-article
8089 (cdr gnus-article-current) (car gnus-article-current)
8090 (current-buffer) t)))
8091 (error "Couldn't replace article")
8092 ;; Update the summary buffer.
8094 (equal (message-tokenize-header references " ")
8095 (message-tokenize-header
8096 (or (message-fetch-field "references") "") " ")))
8097 ;; We only have to update this line.
8100 (message-narrow-to-head)
8101 (let ((head (buffer-string))
8104 (insert (format "211 %d Article retrieved.\n"
8105 (cdr gnus-article-current)))
8108 (let ((nntp-server-buffer (current-buffer)))
8109 (setq header (car (gnus-get-newsgroup-headers
8111 (set-buffer gnus-summary-buffer)
8112 gnus-newsgroup-dependencies)
8115 (set-buffer gnus-summary-buffer)
8116 (gnus-data-set-header
8117 (gnus-data-find (cdr gnus-article-current))
8119 (gnus-summary-update-article-line
8120 (cdr gnus-article-current) header))))))
8122 (set-buffer (or buffer gnus-summary-buffer))
8123 (gnus-summary-update-article (cdr gnus-article-current)))
8124 ;; Prettify the article buffer again.
8125 (unless no-highlight
8127 (set-buffer gnus-article-buffer)
8128 ;;;!!! Fix this -- article should be rehighlighted.
8129 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8130 (set-buffer gnus-original-article-buffer)
8131 (gnus-request-article
8132 (cdr gnus-article-current)
8133 (car gnus-article-current) (current-buffer))))
8134 ;; Prettify the summary buffer line.
8135 (when (gnus-visual-p 'summary-highlight 'highlight)
8136 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8138 (defun gnus-summary-edit-wash (key)
8139 "Perform editing command KEY in the article buffer."
8143 (message "%s" (concat (this-command-keys) "- "))
8146 (gnus-summary-edit-article)
8147 (execute-kbd-macro (concat (this-command-keys) key))
8148 (gnus-article-edit-done))
8152 (defun gnus-summary-respool-query (&optional silent trace)
8153 "Query where the respool algorithm would put this article."
8155 (let (gnus-mark-article-hook)
8156 (gnus-summary-select-article)
8158 (set-buffer gnus-original-article-buffer)
8160 (message-narrow-to-head)
8161 (let ((groups (nnmail-article-group 'identity trace)))
8164 (message "This message would go to %s"
8165 (mapconcat 'car groups ", "))
8166 (message "This message would go to no groups"))
8169 (defun gnus-summary-respool-trace ()
8170 "Trace where the respool algorithm would put this article.
8171 Display a buffer showing all fancy splitting patterns which matched."
8173 (gnus-summary-respool-query nil t))
8175 ;; Summary marking commands.
8177 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8178 "Mark articles which has the same subject as read, and then select the next.
8179 If UNMARK is positive, remove any kind of mark.
8180 If UNMARK is negative, tick articles."
8183 (setq unmark (prefix-numeric-value unmark)))
8185 (gnus-summary-mark-same-subject
8186 (gnus-summary-article-subject) unmark)))
8187 ;; Select next unread article. If auto-select-same mode, should
8188 ;; select the first unread article.
8189 (gnus-summary-next-article t (and gnus-auto-select-same
8190 (gnus-summary-article-subject)))
8191 (gnus-message 7 "%d article%s marked as %s"
8192 count (if (= count 1) " is" "s are")
8193 (if unmark "unread" "read"))))
8195 (defun gnus-summary-kill-same-subject (&optional unmark)
8196 "Mark articles which has the same subject as read.
8197 If UNMARK is positive, remove any kind of mark.
8198 If UNMARK is negative, tick articles."
8201 (setq unmark (prefix-numeric-value unmark)))
8203 (gnus-summary-mark-same-subject
8204 (gnus-summary-article-subject) unmark)))
8205 ;; If marked as read, go to next unread subject.
8207 ;; Go to next unread subject.
8208 (gnus-summary-next-subject 1 t))
8209 (gnus-message 7 "%d articles are marked as %s"
8210 count (if unmark "unread" "read"))))
8212 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8213 "Mark articles with same SUBJECT as read, and return marked number.
8214 If optional argument UNMARK is positive, remove any kinds of marks.
8215 If optional argument UNMARK is negative, mark articles as unread instead."
8219 ((null unmark) ; Mark as read.
8222 (gnus-summary-mark-article-as-read gnus-killed-mark)
8223 (gnus-summary-show-thread) t)
8224 (gnus-summary-find-subject subject))
8225 (setq count (1+ count))))
8226 ((> unmark 0) ; Tick.
8229 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8230 (gnus-summary-show-thread) t)
8231 (gnus-summary-find-subject subject))
8232 (setq count (1+ count))))
8233 (t ; Mark as unread.
8236 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8237 (gnus-summary-show-thread) t)
8238 (gnus-summary-find-subject subject))
8239 (setq count (1+ count)))))
8240 (gnus-set-mode-line 'summary)
8241 ;; Return the number of marked articles.
8244 (defun gnus-summary-mark-as-processable (n &optional unmark)
8245 "Set the process mark on the next N articles.
8246 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8247 the process mark instead. The difference between N and the actual
8248 number of articles marked is returned."
8250 (let ((backward (< n 0))
8255 (gnus-summary-remove-process-mark
8256 (gnus-summary-article-number))
8257 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8258 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8261 (gnus-message 7 "No more articles"))
8262 (gnus-summary-recenter)
8263 (gnus-summary-position-point)
8266 (defun gnus-summary-unmark-as-processable (n)
8267 "Remove the process mark from the next N articles.
8268 If N is negative, unmark backward instead. The difference between N and
8269 the actual number of articles unmarked is returned."
8271 (gnus-summary-mark-as-processable n t))
8273 (defun gnus-summary-unmark-all-processable ()
8274 "Remove the process mark from all articles."
8277 (while gnus-newsgroup-processable
8278 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8279 (gnus-summary-position-point))
8281 (defun gnus-summary-mark-as-expirable (n)
8282 "Mark N articles forward as expirable.
8283 If N is negative, mark backward instead. The difference between N and
8284 the actual number of articles marked is returned."
8286 (gnus-summary-mark-forward n gnus-expirable-mark))
8288 (defun gnus-summary-mark-article-as-replied (article)
8289 "Mark ARTICLE replied and update the summary line."
8290 (push article gnus-newsgroup-replied)
8291 (let ((buffer-read-only nil))
8292 (when (gnus-summary-goto-subject article nil t)
8293 (gnus-summary-update-secondary-mark article))))
8295 (defun gnus-summary-set-bookmark (article)
8296 "Set a bookmark in current article."
8297 (interactive (list (gnus-summary-article-number)))
8298 (when (or (not (get-buffer gnus-article-buffer))
8299 (not gnus-current-article)
8300 (not gnus-article-current)
8301 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8302 (error "No current article selected"))
8303 ;; Remove old bookmark, if one exists.
8304 (let ((old (assq article gnus-newsgroup-bookmarks)))
8306 (setq gnus-newsgroup-bookmarks
8307 (delq old gnus-newsgroup-bookmarks))))
8308 ;; Set the new bookmark, which is on the form
8309 ;; (article-number . line-number-in-body).
8313 (set-buffer gnus-article-buffer)
8317 (goto-char (point-min))
8318 (search-forward "\n\n" nil t)
8321 gnus-newsgroup-bookmarks)
8322 (gnus-message 6 "A bookmark has been added to the current article."))
8324 (defun gnus-summary-remove-bookmark (article)
8325 "Remove the bookmark from the current article."
8326 (interactive (list (gnus-summary-article-number)))
8327 ;; Remove old bookmark, if one exists.
8328 (let ((old (assq article gnus-newsgroup-bookmarks)))
8331 (setq gnus-newsgroup-bookmarks
8332 (delq old gnus-newsgroup-bookmarks))
8333 (gnus-message 6 "Removed bookmark."))
8334 (gnus-message 6 "No bookmark in current article."))))
8336 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8337 (defun gnus-summary-mark-as-dormant (n)
8338 "Mark N articles forward as dormant.
8339 If N is negative, mark backward instead. The difference between N and
8340 the actual number of articles marked is returned."
8342 (gnus-summary-mark-forward n gnus-dormant-mark))
8344 (defun gnus-summary-set-process-mark (article)
8345 "Set the process mark on ARTICLE and update the summary line."
8346 (setq gnus-newsgroup-processable
8348 (delq article gnus-newsgroup-processable)))
8349 (when (gnus-summary-goto-subject article)
8350 (gnus-summary-show-thread)
8351 (gnus-summary-goto-subject article)
8352 (gnus-summary-update-secondary-mark article)))
8354 (defun gnus-summary-remove-process-mark (article)
8355 "Remove the process mark from ARTICLE and update the summary line."
8356 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8357 (when (gnus-summary-goto-subject article)
8358 (gnus-summary-show-thread)
8359 (gnus-summary-goto-subject article)
8360 (gnus-summary-update-secondary-mark article)))
8362 (defun gnus-summary-set-saved-mark (article)
8363 "Set the process mark on ARTICLE and update the summary line."
8364 (push article gnus-newsgroup-saved)
8365 (when (gnus-summary-goto-subject article)
8366 (gnus-summary-update-secondary-mark article)))
8368 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8369 "Mark N articles as read forwards.
8370 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8371 The difference between N and the actual number of articles marked is
8373 Iff NO-EXPIRE, auto-expiry will be inhibited."
8375 (gnus-summary-show-thread)
8376 (let ((backward (< n 0))
8377 (gnus-summary-goto-unread
8378 (and gnus-summary-goto-unread
8379 (not (eq gnus-summary-goto-unread 'never))
8380 (not (memq mark (list gnus-unread-mark
8381 gnus-ticked-mark gnus-dormant-mark)))))
8383 (mark (or mark gnus-del-mark)))
8385 (gnus-summary-mark-article nil mark no-expire)
8386 (zerop (gnus-summary-next-subject
8388 (and gnus-summary-goto-unread
8389 (not (eq gnus-summary-goto-unread 'never)))
8393 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8394 (gnus-summary-recenter)
8395 (gnus-summary-position-point)
8396 (gnus-set-mode-line 'summary)
8399 (defun gnus-summary-mark-article-as-read (mark)
8400 "Mark the current article quickly as read with MARK."
8401 (let ((article (gnus-summary-article-number)))
8402 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8403 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8404 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8405 (push (cons article mark) gnus-newsgroup-reads)
8406 ;; Possibly remove from cache, if that is used.
8407 (when gnus-use-cache
8408 (gnus-cache-enter-remove-article article))
8409 ;; Allow the backend to change the mark.
8410 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8411 ;; Check for auto-expiry.
8412 (when (and gnus-newsgroup-auto-expire
8413 (memq mark gnus-auto-expirable-marks))
8414 (setq mark gnus-expirable-mark)
8415 ;; Let the backend know about the mark change.
8416 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8417 (push article gnus-newsgroup-expirable))
8418 ;; Set the mark in the buffer.
8419 (gnus-summary-update-mark mark 'unread)
8422 (defun gnus-summary-mark-article-as-unread (mark)
8423 "Mark the current article quickly as unread with MARK."
8424 (let* ((article (gnus-summary-article-number))
8425 (old-mark (gnus-summary-article-mark article)))
8426 ;; Allow the backend to change the mark.
8427 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8428 (if (eq mark old-mark)
8432 (gnus-error 1 "Can't mark negative article numbers")
8434 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8435 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8436 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8437 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8438 (cond ((= mark gnus-ticked-mark)
8439 (push article gnus-newsgroup-marked))
8440 ((= mark gnus-dormant-mark)
8441 (push article gnus-newsgroup-dormant))
8443 (push article gnus-newsgroup-unreads)))
8444 (gnus-pull article gnus-newsgroup-reads)
8446 ;; See whether the article is to be put in the cache.
8448 (vectorp (gnus-summary-article-header article))
8450 (gnus-cache-possibly-enter-article
8451 gnus-newsgroup-name article
8452 (gnus-summary-article-header article)
8453 (= mark gnus-ticked-mark)
8454 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8457 (gnus-summary-update-mark mark 'unread)
8460 (defun gnus-summary-mark-article (&optional article mark no-expire)
8461 "Mark ARTICLE with MARK. MARK can be any character.
8462 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8463 `??' (dormant) and `?E' (expirable).
8464 If MARK is nil, then the default character `?r' is used.
8465 If ARTICLE is nil, then the article on the current line will be
8467 Iff NO-EXPIRE, auto-expiry will be inhibited."
8468 ;; The mark might be a string.
8469 (when (stringp mark)
8470 (setq mark (aref mark 0)))
8471 ;; If no mark is given, then we check auto-expiring.
8473 (setq mark gnus-del-mark))
8474 (when (and (not no-expire)
8475 gnus-newsgroup-auto-expire
8476 (memq mark gnus-auto-expirable-marks))
8477 (setq mark gnus-expirable-mark))
8478 (let ((article (or article (gnus-summary-article-number)))
8479 (old-mark (gnus-summary-article-mark article)))
8480 ;; Allow the backend to change the mark.
8481 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8482 (if (eq mark old-mark)
8485 (error "No article on current line"))
8486 (if (not (if (or (= mark gnus-unread-mark)
8487 (= mark gnus-ticked-mark)
8488 (= mark gnus-dormant-mark))
8489 (gnus-mark-article-as-unread article mark)
8490 (gnus-mark-article-as-read article mark)))
8492 ;; See whether the article is to be put in the cache.
8494 (not (= mark gnus-canceled-mark))
8495 (vectorp (gnus-summary-article-header article))
8497 (gnus-cache-possibly-enter-article
8498 gnus-newsgroup-name article
8499 (gnus-summary-article-header article)
8500 (= mark gnus-ticked-mark)
8501 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8503 (when (gnus-summary-goto-subject article nil t)
8504 (let ((buffer-read-only nil))
8505 (gnus-summary-show-thread)
8507 (gnus-summary-update-mark mark 'unread)
8510 (defun gnus-summary-update-secondary-mark (article)
8511 "Update the secondary (read, process, cache) mark."
8512 (gnus-summary-update-mark
8513 (cond ((memq article gnus-newsgroup-processable)
8515 ((memq article gnus-newsgroup-cached)
8517 ((memq article gnus-newsgroup-replied)
8519 ((memq article gnus-newsgroup-saved)
8521 (t gnus-unread-mark))
8523 (when (gnus-visual-p 'summary-highlight 'highlight)
8524 (gnus-run-hooks 'gnus-summary-update-hook))
8527 (defun gnus-summary-update-mark (mark type)
8528 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8529 (buffer-read-only nil))
8530 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8532 (when (looking-at "\r")
8534 (when (<= (+ forward (point)) (point-max))
8535 ;; Go to the right position on the line.
8536 (goto-char (+ forward (point)))
8537 ;; Replace the old mark with the new mark.
8538 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8539 ;; Optionally update the marks by some user rule.
8540 (when (eq type 'unread)
8542 (gnus-data-find (gnus-summary-article-number)) mark)
8543 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8545 (defun gnus-mark-article-as-read (article &optional mark)
8546 "Enter ARTICLE in the pertinent lists and remove it from others."
8547 ;; Make the article expirable.
8548 (let ((mark (or mark gnus-del-mark)))
8549 (if (= mark gnus-expirable-mark)
8550 (push article gnus-newsgroup-expirable)
8551 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8552 ;; Remove from unread and marked lists.
8553 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8554 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8555 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8556 (push (cons article mark) gnus-newsgroup-reads)
8557 ;; Possibly remove from cache, if that is used.
8558 (when gnus-use-cache
8559 (gnus-cache-enter-remove-article article))
8562 (defun gnus-mark-article-as-unread (article &optional mark)
8563 "Enter ARTICLE in the pertinent lists and remove it from others."
8564 (let ((mark (or mark gnus-ticked-mark)))
8567 (gnus-error 1 "Can't mark negative article numbers")
8569 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8570 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8571 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8572 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8574 ;; Unsuppress duplicates?
8575 (when gnus-suppress-duplicates
8576 (gnus-dup-unsuppress-article article))
8578 (cond ((= mark gnus-ticked-mark)
8579 (push article gnus-newsgroup-marked))
8580 ((= mark gnus-dormant-mark)
8581 (push article gnus-newsgroup-dormant))
8583 (push article gnus-newsgroup-unreads)))
8584 (gnus-pull article gnus-newsgroup-reads)
8587 (defalias 'gnus-summary-mark-as-unread-forward
8588 'gnus-summary-tick-article-forward)
8589 (make-obsolete 'gnus-summary-mark-as-unread-forward
8590 'gnus-summary-tick-article-forward)
8591 (defun gnus-summary-tick-article-forward (n)
8592 "Tick N articles forwards.
8593 If N is negative, tick backwards instead.
8594 The difference between N and the number of articles ticked is returned."
8596 (gnus-summary-mark-forward n gnus-ticked-mark))
8598 (defalias 'gnus-summary-mark-as-unread-backward
8599 'gnus-summary-tick-article-backward)
8600 (make-obsolete 'gnus-summary-mark-as-unread-backward
8601 'gnus-summary-tick-article-backward)
8602 (defun gnus-summary-tick-article-backward (n)
8603 "Tick N articles backwards.
8604 The difference between N and the number of articles ticked is returned."
8606 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8608 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8609 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8610 (defun gnus-summary-tick-article (&optional article clear-mark)
8611 "Mark current article as unread.
8612 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8613 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8615 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8618 (defun gnus-summary-mark-as-read-forward (n)
8619 "Mark N articles as read forwards.
8620 If N is negative, mark backwards instead.
8621 The difference between N and the actual number of articles marked is
8624 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8626 (defun gnus-summary-mark-as-read-backward (n)
8627 "Mark the N articles as read backwards.
8628 The difference between N and the actual number of articles marked is
8631 (gnus-summary-mark-forward
8632 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8634 (defun gnus-summary-mark-as-read (&optional article mark)
8635 "Mark current article as read.
8636 ARTICLE specifies the article to be marked as read.
8637 MARK specifies a string to be inserted at the beginning of the line."
8638 (gnus-summary-mark-article article mark))
8640 (defun gnus-summary-clear-mark-forward (n)
8641 "Clear marks from N articles forward.
8642 If N is negative, clear backward instead.
8643 The difference between N and the number of marks cleared is returned."
8645 (gnus-summary-mark-forward n gnus-unread-mark))
8647 (defun gnus-summary-clear-mark-backward (n)
8648 "Clear marks from N articles backward.
8649 The difference between N and the number of marks cleared is returned."
8651 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8653 (defun gnus-summary-mark-unread-as-read ()
8654 "Intended to be used by `gnus-summary-mark-article-hook'."
8655 (when (memq gnus-current-article gnus-newsgroup-unreads)
8656 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8658 (defun gnus-summary-mark-read-and-unread-as-read ()
8659 "Intended to be used by `gnus-summary-mark-article-hook'."
8660 (let ((mark (gnus-summary-article-mark)))
8661 (when (or (gnus-unread-mark-p mark)
8662 (gnus-read-mark-p mark))
8663 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8665 (defun gnus-summary-mark-region-as-read (point mark all)
8666 "Mark all unread articles between point and mark as read.
8667 If given a prefix, mark all articles between point and mark as read,
8668 even ticked and dormant ones."
8669 (interactive "r\nP")
8678 (memq (setq article (gnus-summary-article-number))
8679 gnus-newsgroup-unreads))
8680 (gnus-summary-mark-article article gnus-del-mark))
8682 (gnus-summary-find-next))))))
8684 (defun gnus-summary-mark-below (score mark)
8685 "Mark articles with score less than SCORE with MARK."
8686 (interactive "P\ncMark: ")
8687 (setq score (if score
8688 (prefix-numeric-value score)
8689 (or gnus-summary-default-score 0)))
8691 (set-buffer gnus-summary-buffer)
8692 (goto-char (point-min))
8695 (and (< (gnus-summary-article-score) score)
8696 (gnus-summary-mark-article nil mark))
8697 (gnus-summary-find-next)))))
8699 (defun gnus-summary-kill-below (&optional score)
8700 "Mark articles with score below SCORE as read."
8702 (gnus-summary-mark-below score gnus-killed-mark))
8704 (defun gnus-summary-clear-above (&optional score)
8705 "Clear all marks from articles with score above SCORE."
8707 (gnus-summary-mark-above score gnus-unread-mark))
8709 (defun gnus-summary-tick-above (&optional score)
8710 "Tick all articles with score above SCORE."
8712 (gnus-summary-mark-above score gnus-ticked-mark))
8714 (defun gnus-summary-mark-above (score mark)
8715 "Mark articles with score over SCORE with MARK."
8716 (interactive "P\ncMark: ")
8717 (setq score (if score
8718 (prefix-numeric-value score)
8719 (or gnus-summary-default-score 0)))
8721 (set-buffer gnus-summary-buffer)
8722 (goto-char (point-min))
8724 (when (> (gnus-summary-article-score) score)
8725 (gnus-summary-mark-article nil mark))
8727 (gnus-summary-find-next)))))
8729 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8730 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8731 (defun gnus-summary-limit-include-expunged (&optional no-error)
8732 "Display all the hidden articles that were expunged for low scores."
8734 (let ((buffer-read-only nil))
8735 (let ((scored gnus-newsgroup-scored)
8738 (unless (gnus-summary-goto-subject (caar scored))
8739 (and (setq h (gnus-summary-article-header (caar scored)))
8740 (< (cdar scored) gnus-summary-expunge-below)
8742 (setq scored (cdr scored)))
8744 (when (not no-error)
8745 (error "No expunged articles hidden"))
8746 (goto-char (point-min))
8747 (gnus-summary-prepare-unthreaded (nreverse headers))
8748 (goto-char (point-min))
8749 (gnus-summary-position-point)
8752 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8753 "Mark all unread articles in this newsgroup as read.
8754 If prefix argument ALL is non-nil, ticked and dormant articles will
8755 also be marked as read.
8756 If QUIETLY is non-nil, no questions will be asked.
8757 If TO-HERE is non-nil, it should be a point in the buffer. All
8758 articles before this point will be marked as read.
8759 Note that this function will only catch up the unread article
8760 in the current summary buffer limitation.
8761 The number of articles marked as read is returned."
8766 (not gnus-interactive-catchup) ;Without confirmation?
8770 "Mark absolutely all articles as read? "
8771 "Mark all unread articles as read? ")))
8773 (not gnus-newsgroup-adaptive)
8774 (not gnus-newsgroup-auto-expire)
8775 (not gnus-suppress-duplicates)
8776 (or (not gnus-use-cache)
8777 (eq gnus-use-cache 'passive)))
8780 (setq gnus-newsgroup-marked nil
8781 gnus-newsgroup-dormant nil))
8782 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8783 ;; We actually mark all articles as canceled, which we
8784 ;; have to do when using auto-expiry or adaptive scoring.
8785 (gnus-summary-show-all-threads)
8786 (when (gnus-summary-first-subject (not all) t)
8788 (if to-here (< (point) to-here) t)
8789 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8790 (gnus-summary-find-next (not all) nil nil t))))
8791 (gnus-set-mode-line 'summary))
8793 (gnus-summary-position-point)))
8795 (defun gnus-summary-catchup-to-here (&optional all)
8796 "Mark all unticked articles before the current one as read.
8797 If ALL is non-nil, also mark ticked and dormant articles as read."
8800 (gnus-save-hidden-threads
8801 (let ((beg (point)))
8802 ;; We check that there are unread articles.
8803 (when (or all (gnus-summary-find-prev))
8804 (gnus-summary-catchup all t beg)))))
8805 (gnus-summary-position-point))
8807 (defun gnus-summary-catchup-all (&optional quietly)
8808 "Mark all articles in this newsgroup as read."
8810 (gnus-summary-catchup t quietly))
8812 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8813 "Mark all unread articles in this group as read, then exit.
8814 If prefix argument ALL is non-nil, all articles are marked as read."
8816 (when (gnus-summary-catchup all quietly nil 'fast)
8817 ;; Select next newsgroup or exit.
8818 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8819 (eq gnus-auto-select-next 'quietly))
8820 (gnus-summary-next-group nil)
8821 (gnus-summary-exit))))
8823 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8824 "Mark all articles in this newsgroup as read, and then exit."
8826 (gnus-summary-catchup-and-exit t quietly))
8828 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8829 "Mark all articles in this group as read and select the next group.
8830 If given a prefix, mark all articles, unread as well as ticked, as
8834 (gnus-summary-catchup all))
8835 (gnus-summary-next-group))
8841 (defmacro gnus-with-article (article &rest forms)
8842 "Select ARTICLE and perform FORMS in the original article buffer.
8843 Then replace the article with the result."
8845 ;; We don't want the article to be marked as read.
8846 (let (gnus-mark-article-hook)
8847 (gnus-summary-select-article t t nil ,article))
8848 (set-buffer gnus-original-article-buffer)
8850 (if (not (gnus-check-backend-function
8851 'request-replace-article (car gnus-article-current)))
8852 (gnus-message 5 "Read-only group; not replacing")
8853 (unless (gnus-request-replace-article
8854 ,article (car gnus-article-current)
8856 (error "Couldn't replace article")))
8857 ;; The cache and backlog have to be flushed somewhat.
8858 (when gnus-keep-backlog
8859 (gnus-backlog-remove-article
8860 (car gnus-article-current) (cdr gnus-article-current)))
8861 (when gnus-use-cache
8862 (gnus-cache-update-article
8863 (car gnus-article-current) (cdr gnus-article-current)))))
8865 (put 'gnus-with-article 'lisp-indent-function 1)
8866 (put 'gnus-with-article 'edebug-form-spec '(form body))
8868 ;; Thread-based commands.
8870 (defun gnus-summary-articles-in-thread (&optional article)
8871 "Return a list of all articles in the current thread.
8872 If ARTICLE is non-nil, return all articles in the thread that starts
8874 (let* ((article (or article (gnus-summary-article-number)))
8875 (data (gnus-data-find-list article))
8876 (top-level (gnus-data-level (car data)))
8878 (cond ((null gnus-thread-operation-ignore-subject)
8879 (gnus-simplify-subject-re
8880 (mail-header-subject (gnus-data-header (car data)))))
8881 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8882 (gnus-simplify-subject-fuzzy
8883 (mail-header-subject (gnus-data-header (car data)))))
8885 (end-point (save-excursion
8886 (if (gnus-summary-go-to-next-thread)
8887 (point) (point-max))))
8890 (< (gnus-data-pos (car data)) end-point))
8891 (when (or (not top-subject)
8892 (string= top-subject
8893 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8894 (gnus-simplify-subject-fuzzy
8895 (mail-header-subject
8896 (gnus-data-header (car data))))
8897 (gnus-simplify-subject-re
8898 (mail-header-subject
8899 (gnus-data-header (car data)))))))
8900 (push (gnus-data-number (car data)) articles))
8901 (unless (and (setq data (cdr data))
8902 (> (gnus-data-level (car data)) top-level))
8904 ;; Return the list of articles.
8905 (nreverse articles)))
8907 (defun gnus-summary-rethread-current ()
8908 "Rethread the thread the current article is part of."
8910 (let* ((gnus-show-threads t)
8911 (article (gnus-summary-article-number))
8912 (id (mail-header-id (gnus-summary-article-header)))
8913 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8915 (error "No article on the current line"))
8916 (gnus-rebuild-thread id)
8917 (gnus-summary-goto-subject article)))
8919 (defun gnus-summary-reparent-thread ()
8920 "Make the current article child of the marked (or previous) article.
8922 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8923 is non-nil or the Subject: of both articles are the same."
8925 (unless (not (gnus-group-read-only-p))
8926 (error "The current newsgroup does not support article editing"))
8927 (unless (<= (length gnus-newsgroup-processable) 1)
8928 (error "No more than one article may be marked"))
8929 (save-window-excursion
8930 (let ((gnus-article-buffer " *reparent*")
8931 (current-article (gnus-summary-article-number))
8932 ;; First grab the marked article, otherwise one line up.
8933 (parent-article (if (not (null gnus-newsgroup-processable))
8934 (car gnus-newsgroup-processable)
8936 (if (eq (forward-line -1) 0)
8937 (gnus-summary-article-number)
8938 (error "Beginning of summary buffer"))))))
8939 (unless (not (eq current-article parent-article))
8940 (error "An article may not be self-referential"))
8941 (let ((message-id (mail-header-id
8942 (gnus-summary-article-header parent-article))))
8943 (unless (and message-id (not (equal message-id "")))
8944 (error "No message-id in desired parent"))
8945 (gnus-with-article current-article
8947 (goto-char (point-min))
8948 (message-narrow-to-head)
8949 (if (re-search-forward "^References: " nil t)
8951 (re-search-forward "^[^ \t]" nil t)
8954 (insert " " message-id))
8955 (insert "References: " message-id "\n"))))
8956 (set-buffer gnus-summary-buffer)
8957 (gnus-summary-unmark-all-processable)
8958 (gnus-summary-update-article current-article)
8959 (gnus-summary-rethread-current)
8960 (gnus-message 3 "Article %d is now the child of article %d"
8961 current-article parent-article)))))
8963 (defun gnus-summary-toggle-threads (&optional arg)
8964 "Toggle showing conversation threads.
8965 If ARG is positive number, turn showing conversation threads on."
8967 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8968 (setq gnus-show-threads
8969 (if (null arg) (not gnus-show-threads)
8970 (> (prefix-numeric-value arg) 0)))
8971 (gnus-summary-prepare)
8972 (gnus-summary-goto-subject current)
8973 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8974 (gnus-summary-position-point)))
8976 (defun gnus-summary-show-all-threads ()
8980 (let ((buffer-read-only nil))
8981 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8982 (gnus-summary-position-point))
8984 (defun gnus-summary-show-thread ()
8985 "Show thread subtrees.
8986 Returns nil if no thread was there to be shown."
8988 (let ((buffer-read-only nil)
8990 ;; first goto end then to beg, to have point at beg after let
8991 (end (progn (end-of-line) (point)))
8992 (beg (progn (beginning-of-line) (point))))
8994 ;; Any hidden lines here?
8995 (search-forward "\r" end t)
8996 (subst-char-in-region beg end ?\^M ?\n t)
8998 (gnus-summary-position-point))))
9000 (defun gnus-summary-hide-all-threads ()
9001 "Hide all thread subtrees."
9004 (goto-char (point-min))
9005 (gnus-summary-hide-thread)
9006 (while (zerop (gnus-summary-next-thread 1 t))
9007 (gnus-summary-hide-thread)))
9008 (gnus-summary-position-point))
9010 (defun gnus-summary-hide-thread ()
9011 "Hide thread subtrees.
9012 Returns nil if no threads were there to be hidden."
9014 (let ((buffer-read-only nil)
9016 (article (gnus-summary-article-number)))
9018 ;; Go forward until either the buffer ends or the subthread
9020 (when (and (not (eobp))
9021 (or (zerop (gnus-summary-next-thread 1 t))
9022 (goto-char (point-max))))
9024 (if (and (> (point) start)
9025 (search-backward "\n" start t))
9027 (subst-char-in-region start (point) ?\n ?\^M)
9028 (gnus-summary-goto-subject article))
9032 (defun gnus-summary-go-to-next-thread (&optional previous)
9033 "Go to the same level (or less) next thread.
9034 If PREVIOUS is non-nil, go to previous thread instead.
9035 Return the article number moved to, or nil if moving was impossible."
9036 (let ((level (gnus-summary-thread-level))
9037 (way (if previous -1 1))
9040 (while (and (not (eobp))
9041 (< level (gnus-summary-thread-level)))
9049 (gnus-summary-article-number)
9052 (defun gnus-summary-next-thread (n &optional silent)
9053 "Go to the same level next N'th thread.
9054 If N is negative, search backward instead.
9055 Returns the difference between N and the number of skips actually
9058 If SILENT, don't output messages."
9060 (let ((backward (< n 0))
9063 (gnus-summary-go-to-next-thread backward))
9066 (gnus-summary-position-point))
9067 (when (and (not silent) (/= 0 n))
9068 (gnus-message 7 "No more threads"))
9071 (defun gnus-summary-prev-thread (n)
9072 "Go to the same level previous N'th thread.
9073 Returns the difference between N and the number of skips actually
9076 (gnus-summary-next-thread (- n)))
9078 (defun gnus-summary-go-down-thread ()
9079 "Go down one level in the current thread."
9080 (let ((children (gnus-summary-article-children)))
9082 (gnus-summary-goto-subject (car children)))))
9084 (defun gnus-summary-go-up-thread ()
9085 "Go up one level in the current thread."
9086 (let ((parent (gnus-summary-article-parent)))
9088 (gnus-summary-goto-subject parent))))
9090 (defun gnus-summary-down-thread (n)
9091 "Go down thread N steps.
9092 If N is negative, go up instead.
9093 Returns the difference between N and how many steps down that were
9099 (if up (gnus-summary-go-up-thread)
9100 (gnus-summary-go-down-thread)))
9102 (gnus-summary-position-point)
9104 (gnus-message 7 "Can't go further"))
9107 (defun gnus-summary-up-thread (n)
9108 "Go up thread N steps.
9109 If N is negative, go up instead.
9110 Returns the difference between N and how many steps down that were
9113 (gnus-summary-down-thread (- n)))
9115 (defun gnus-summary-top-thread ()
9116 "Go to the top of the thread."
9118 (while (gnus-summary-go-up-thread))
9119 (gnus-summary-article-number))
9121 (defun gnus-summary-kill-thread (&optional unmark)
9122 "Mark articles under current thread as read.
9123 If the prefix argument is positive, remove any kinds of marks.
9124 If the prefix argument is negative, tick articles instead."
9127 (setq unmark (prefix-numeric-value unmark)))
9128 (let ((articles (gnus-summary-articles-in-thread)))
9130 ;; Expand the thread.
9131 (gnus-summary-show-thread)
9132 ;; Mark all the articles.
9134 (gnus-summary-goto-subject (car articles))
9135 (cond ((null unmark)
9136 (gnus-summary-mark-article-as-read gnus-killed-mark))
9138 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9140 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9141 (setq articles (cdr articles))))
9142 ;; Hide killed subtrees.
9144 gnus-thread-hide-killed
9145 (gnus-summary-hide-thread))
9146 ;; If marked as read, go to next unread subject.
9148 ;; Go to next unread subject.
9149 (gnus-summary-next-subject 1 t)))
9150 (gnus-set-mode-line 'summary))
9152 ;; Summary sorting commands
9154 (defun gnus-summary-sort-by-number (&optional reverse)
9155 "Sort the summary buffer by article number.
9156 Argument REVERSE means reverse order."
9158 (gnus-summary-sort 'number reverse))
9160 (defun gnus-summary-sort-by-author (&optional reverse)
9161 "Sort the summary buffer by author name alphabetically.
9162 If `case-fold-search' is non-nil, case of letters is ignored.
9163 Argument REVERSE means reverse order."
9165 (gnus-summary-sort 'author reverse))
9167 (defun gnus-summary-sort-by-subject (&optional reverse)
9168 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9169 If `case-fold-search' is non-nil, case of letters is ignored.
9170 Argument REVERSE means reverse order."
9172 (gnus-summary-sort 'subject reverse))
9174 (defun gnus-summary-sort-by-date (&optional reverse)
9175 "Sort the summary buffer by date.
9176 Argument REVERSE means reverse order."
9178 (gnus-summary-sort 'date reverse))
9180 (defun gnus-summary-sort-by-score (&optional reverse)
9181 "Sort the summary buffer by score.
9182 Argument REVERSE means reverse order."
9184 (gnus-summary-sort 'score reverse))
9186 (defun gnus-summary-sort-by-lines (&optional reverse)
9187 "Sort the summary buffer by the number of lines.
9188 Argument REVERSE means reverse order."
9190 (gnus-summary-sort 'lines reverse))
9192 (defun gnus-summary-sort-by-chars (&optional reverse)
9193 "Sort the summary buffer by article length.
9194 Argument REVERSE means reverse order."
9196 (gnus-summary-sort 'chars reverse))
9198 (defun gnus-summary-sort (predicate reverse)
9199 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9200 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9201 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9202 (gnus-thread-sort-functions
9207 (gnus-sort-gathered-threads-function
9208 gnus-thread-sort-functions)
9209 (gnus-article-sort-functions
9215 (gnus-summary-prepare-hook nil))
9216 ;; We do the sorting by regenerating the threads.
9217 (gnus-summary-prepare)
9218 ;; Hide subthreads if needed.
9219 (when (and gnus-show-threads gnus-thread-hide-subtree)
9220 (gnus-summary-hide-all-threads))))
9222 ;; Summary saving commands.
9224 (defun gnus-summary-save-article (&optional n not-saved)
9225 "Save the current article using the default saver function.
9226 If N is a positive number, save the N next articles.
9227 If N is a negative number, save the N previous articles.
9228 If N is nil and any articles have been marked with the process mark,
9229 save those articles instead.
9230 The variable `gnus-default-article-saver' specifies the saver function."
9232 (let* ((articles (gnus-summary-work-articles n))
9233 (save-buffer (save-excursion
9234 (nnheader-set-temp-buffer " *Gnus Save*")))
9235 (num (length articles))
9237 (dolist (article articles)
9238 (setq header (gnus-summary-article-header article))
9239 (if (not (vectorp header))
9240 ;; This is a pseudo-article.
9241 (if (assq 'name header)
9242 (gnus-copy-file (cdr (assq 'name header)))
9243 (gnus-message 1 "Article %d is unsaveable" article))
9244 ;; This is a real article.
9245 (save-window-excursion
9246 (gnus-summary-select-article t nil nil article))
9248 (set-buffer save-buffer)
9250 (insert-buffer-substring gnus-original-article-buffer))
9251 (setq file (gnus-article-save save-buffer file num))
9252 (gnus-summary-remove-process-mark article)
9254 (gnus-summary-set-saved-mark article))))
9255 (gnus-kill-buffer save-buffer)
9256 (gnus-summary-position-point)
9257 (gnus-set-mode-line 'summary)
9260 (defun gnus-summary-pipe-output (&optional arg)
9261 "Pipe the current article to a subprocess.
9262 If N is a positive number, pipe the N next articles.
9263 If N is a negative number, pipe the N previous articles.
9264 If N is nil and any articles have been marked with the process mark,
9265 pipe those articles instead."
9267 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9268 (gnus-summary-save-article arg t))
9269 (gnus-configure-windows 'pipe))
9271 (defun gnus-summary-save-article-mail (&optional arg)
9272 "Append the current article to an mail file.
9273 If N is a positive number, save the N next articles.
9274 If N is a negative number, save the N previous articles.
9275 If N is nil and any articles have been marked with the process mark,
9276 save those articles instead."
9278 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9279 (gnus-summary-save-article arg)))
9281 (defun gnus-summary-save-article-rmail (&optional arg)
9282 "Append the current article to an rmail file.
9283 If N is a positive number, save the N next articles.
9284 If N is a negative number, save the N previous articles.
9285 If N is nil and any articles have been marked with the process mark,
9286 save those articles instead."
9288 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9289 (gnus-summary-save-article arg)))
9291 (defun gnus-summary-save-article-file (&optional arg)
9292 "Append the current article to a file.
9293 If N is a positive number, save the N next articles.
9294 If N is a negative number, save the N previous articles.
9295 If N is nil and any articles have been marked with the process mark,
9296 save those articles instead."
9298 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9299 (gnus-summary-save-article arg)))
9301 (defun gnus-summary-write-article-file (&optional arg)
9302 "Write the current article to a file, deleting the previous file.
9303 If N is a positive number, save the N next articles.
9304 If N is a negative number, save the N previous articles.
9305 If N is nil and any articles have been marked with the process mark,
9306 save those articles instead."
9308 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9309 (gnus-summary-save-article arg)))
9311 (defun gnus-summary-save-article-body-file (&optional arg)
9312 "Append the current article body to a file.
9313 If N is a positive number, save the N next articles.
9314 If N is a negative number, save the N previous articles.
9315 If N is nil and any articles have been marked with the process mark,
9316 save those articles instead."
9318 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9319 (gnus-summary-save-article arg)))
9321 (defun gnus-summary-pipe-message (program)
9322 "Pipe the current article through PROGRAM."
9323 (interactive "sProgram: ")
9324 (gnus-summary-select-article)
9325 (let ((mail-header-separator ""))
9326 (gnus-eval-in-buffer-window gnus-article-buffer
9329 (let ((start (window-start))
9331 (message-pipe-buffer-body program)
9332 (set-window-start (get-buffer-window (current-buffer)) start))))))
9334 (defun gnus-get-split-value (methods)
9335 "Return a value based on the split METHODS."
9336 (let (split-name method result match)
9339 (set-buffer gnus-original-article-buffer)
9341 (nnheader-narrow-to-headers)
9342 (while (and methods (not split-name))
9343 (goto-char (point-min))
9344 (setq method (pop methods))
9345 (setq match (car method))
9348 ;; Regular expression.
9350 (re-search-forward match nil t)))
9351 ((gnus-functionp match)
9355 (setq result (funcall match gnus-newsgroup-name))))
9360 (setq result (eval match)))))
9361 (setq split-name (cdr method))
9362 (cond ((stringp result)
9363 (push (expand-file-name
9364 result gnus-article-save-directory)
9367 (setq split-name (append result split-name)))))))))
9368 (nreverse split-name)))
9370 (defun gnus-valid-move-group-p (group)
9373 (symbol-value group)
9374 (gnus-get-function (gnus-find-method-for-group
9375 (symbol-name group)) 'request-accept-article t)))
9377 (defun gnus-read-move-group-name (prompt default articles prefix)
9378 "Read a group name."
9379 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9380 (minibuffer-confirm-incomplete nil) ; XEmacs
9384 (if (> (length articles) 1)
9385 (format "these %d articles" (length articles))
9390 (gnus-completing-read default prom
9392 'gnus-valid-move-group-p
9394 'gnus-group-history))
9395 ((= 1 (length split-name))
9396 (gnus-completing-read (car split-name) prom
9398 'gnus-valid-move-group-p
9400 'gnus-group-history))
9402 (gnus-completing-read nil prom
9403 (mapcar (lambda (el) (list el))
9404 (nreverse split-name))
9406 'gnus-group-history))))
9407 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9409 (if (or (string= to-newsgroup "")
9410 (string= to-newsgroup prefix))
9411 (setq to-newsgroup default))
9412 (unless to-newsgroup
9413 (error "No group name entered"))
9414 (or (gnus-active to-newsgroup)
9415 (gnus-activate-group to-newsgroup nil nil to-method)
9416 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9418 (or (and (gnus-request-create-group to-newsgroup to-method)
9419 (gnus-activate-group
9420 to-newsgroup nil nil to-method)
9421 (gnus-subscribe-group to-newsgroup))
9422 (error "Couldn't create group %s" to-newsgroup)))
9423 (error "No such group: %s" to-newsgroup)))
9426 (defun gnus-summary-save-parts (type dir n &optional reverse)
9427 "Save parts matching TYPE to DIR.
9428 If REVERSE, save parts that do not match TYPE."
9430 (list (read-string "Save parts of type: "
9431 (or (car gnus-summary-save-parts-type-history)
9432 gnus-summary-save-parts-default-mime)
9433 'gnus-summary-save-parts-type-history)
9434 (setq gnus-summary-save-parts-last-directory
9435 (read-file-name "Save to directory: "
9436 gnus-summary-save-parts-last-directory
9438 current-prefix-arg))
9439 (gnus-summary-iterate n
9440 (let ((gnus-display-mime-function nil)
9441 (gnus-inhibit-treatment t))
9442 (gnus-summary-select-article))
9444 (set-buffer gnus-article-buffer)
9445 (let ((handles (or gnus-article-mime-handles
9446 (mm-dissect-buffer) (mm-uu-dissect))))
9448 (gnus-summary-save-parts-1 type dir handles reverse)
9449 (unless gnus-article-mime-handles ;; Don't destroy this case.
9450 (mm-destroy-parts handles)))))))
9452 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9453 (if (stringp (car handle))
9454 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9457 (not (string-match type (mm-handle-media-type handle)))
9458 (string-match type (mm-handle-media-type handle)))
9459 (let ((file (expand-file-name
9460 (file-name-nondirectory
9462 (mail-content-type-get
9463 (mm-handle-disposition handle) 'filename)
9464 (concat gnus-newsgroup-name
9465 "." (number-to-string
9466 (cdr gnus-article-current)))))
9468 (unless (file-exists-p file)
9469 (mm-save-part-to-file handle file))))))
9471 ;; Summary extract commands
9473 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9474 (let ((buffer-read-only nil)
9475 (article (gnus-summary-article-number))
9477 (unless (gnus-summary-goto-subject article)
9478 (error "No such article: %d" article))
9479 (gnus-summary-position-point)
9480 ;; If all commands are to be bunched up on one line, we collect
9482 (unless gnus-view-pseudos-separately
9483 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9486 (setq action (cdr (assq 'action (car ps))))
9487 (setq files (list (cdr (assq 'name (car ps)))))
9488 (while (and ps (cdr ps)
9489 (string= (or action "1")
9490 (or (cdr (assq 'action (cadr ps))) "2")))
9491 (push (cdr (assq 'name (cadr ps))) files)
9492 (setcdr ps (cddr ps)))
9494 (when (not (string-match "%s" action))
9497 (when (assq 'execute (car ps))
9498 (setcdr (assq 'execute (car ps))
9499 (funcall (if (string-match "%s" action)
9506 (gnus-quote-arg-for-sh-or-csh f)))
9508 (setq ps (cdr ps)))))
9509 (if (and gnus-view-pseudos (not not-view))
9511 (when (assq 'execute (car pslist))
9512 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9513 (eq gnus-view-pseudos 'not-confirm)))
9514 (setq pslist (cdr pslist)))
9517 (setq after-article (or (cdr (assq 'article (car pslist)))
9518 (gnus-summary-article-number)))
9519 (gnus-summary-goto-subject after-article)
9522 (insert " " (file-name-nondirectory
9523 (cdr (assq 'name (car pslist))))
9524 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9526 (forward-line -1) ; back to `b'
9527 (gnus-add-text-properties
9528 b (1- e) (list 'gnus-number gnus-reffed-article-number
9529 gnus-mouse-face-prop gnus-mouse-face))
9531 after-article gnus-reffed-article-number
9532 gnus-unread-mark b (car pslist) 0 (- e b))
9533 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9534 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9535 (setq pslist (cdr pslist)))))))
9537 (defun gnus-pseudos< (p1 p2)
9538 (let ((c1 (cdr (assq 'action p1)))
9539 (c2 (cdr (assq 'action p2))))
9540 (and c1 c2 (string< c1 c2))))
9542 (defun gnus-request-pseudo-article (props)
9543 (cond ((assq 'execute props)
9544 (gnus-execute-command (cdr (assq 'execute props)))))
9545 (let ((gnus-current-article (gnus-summary-article-number)))
9546 (gnus-run-hooks 'gnus-mark-article-hook)))
9548 (defun gnus-execute-command (command &optional automatic)
9550 (gnus-article-setup-buffer)
9551 (set-buffer gnus-article-buffer)
9552 (setq buffer-read-only nil)
9553 (let ((command (if automatic command
9554 (read-string "Command: " (cons command 0)))))
9556 (insert "$ " command "\n\n")
9557 (if gnus-view-pseudo-asynchronously
9558 (start-process "gnus-execute" (current-buffer) shell-file-name
9559 shell-command-switch command)
9560 (call-process shell-file-name nil t nil
9561 shell-command-switch command)))))
9563 ;; Summary kill commands.
9565 (defun gnus-summary-edit-global-kill (article)
9566 "Edit the \"global\" kill file."
9567 (interactive (list (gnus-summary-article-number)))
9568 (gnus-group-edit-global-kill article))
9570 (defun gnus-summary-edit-local-kill ()
9571 "Edit a local kill file applied to the current newsgroup."
9573 (setq gnus-current-headers (gnus-summary-article-header))
9574 (gnus-group-edit-local-kill
9575 (gnus-summary-article-number) gnus-newsgroup-name))
9579 (defun gnus-read-header (id &optional header)
9580 "Read the headers of article ID and enter them into the Gnus system."
9581 (let ((group gnus-newsgroup-name)
9582 (gnus-override-method
9584 gnus-override-method
9585 (and (gnus-news-group-p gnus-newsgroup-name)
9586 (car (gnus-refer-article-methods)))))
9588 ;; First we check to see whether the header in question is already
9591 ;; This is a Message-ID.
9592 (setq header (or header (gnus-id-to-header id)))
9593 ;; This is an article number.
9594 (setq header (or header (gnus-summary-article-header id))))
9596 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9597 ;; We have found the header.
9599 ;; If this is a sparse article, we have to nix out its
9600 ;; previous entry in the thread hashtb.
9602 (gnus-summary-article-sparse-p (mail-header-number header)))
9603 (let* ((parent (gnus-parent-id (mail-header-references header)))
9604 (thread (and parent (gnus-id-to-thread parent))))
9606 (delq (assq header thread) thread))))
9607 ;; We have to really fetch the header to this article.
9609 (set-buffer nntp-server-buffer)
9610 (when (setq where (gnus-request-head id group))
9611 (nnheader-fold-continuation-lines)
9612 (goto-char (point-max))
9614 (goto-char (point-min))
9618 ((cdr where) (cdr where))
9619 (header (mail-header-number header))
9620 (t gnus-reffed-article-number))
9622 (insert " Article retrieved.\n"))
9624 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9625 () ; Malformed head.
9626 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9627 (when (and (stringp id)
9628 (not (string= (gnus-group-real-name group)
9630 ;; If we fetched by Message-ID and the article came
9631 ;; from a different group, we fudge some bogus article
9632 ;; numbers for this article.
9633 (mail-header-set-number header gnus-reffed-article-number))
9635 (set-buffer gnus-summary-buffer)
9636 (decf gnus-reffed-article-number)
9637 (gnus-remove-header (mail-header-number header))
9638 (push header gnus-newsgroup-headers)
9639 (setq gnus-current-headers header)
9640 (push (mail-header-number header) gnus-newsgroup-limit)))
9643 (defun gnus-remove-header (number)
9644 "Remove header NUMBER from `gnus-newsgroup-headers'."
9645 (if (and gnus-newsgroup-headers
9646 (= number (mail-header-number (car gnus-newsgroup-headers))))
9647 (pop gnus-newsgroup-headers)
9648 (let ((headers gnus-newsgroup-headers))
9649 (while (and (cdr headers)
9650 (not (= number (mail-header-number (cadr headers)))))
9653 (setcdr headers (cddr headers))))))
9656 ;;; summary highlights
9659 (defun gnus-highlight-selected-summary ()
9660 "Highlight selected article in summary buffer."
9661 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9662 (when gnus-summary-selected-face
9664 (let* ((beg (progn (beginning-of-line) (point)))
9665 (end (progn (end-of-line) (point)))
9666 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9667 (from (if (get-text-property beg gnus-mouse-face-prop)
9669 (or (next-single-property-change
9670 beg gnus-mouse-face-prop nil end)
9675 (or (next-single-property-change
9676 from gnus-mouse-face-prop nil end)
9678 ;; If no mouse-face prop on line we will have to = from = end,
9679 ;; so we highlight the entire line instead.
9680 (when (= (+ to 2) from)
9683 (if gnus-newsgroup-selected-overlay
9684 ;; Move old overlay.
9686 gnus-newsgroup-selected-overlay from to (current-buffer))
9687 ;; Create new overlay.
9689 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9690 'face gnus-summary-selected-face))))))
9692 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9693 (defun gnus-summary-highlight-line ()
9694 "Highlight current line according to `gnus-summary-highlight'."
9695 (let* ((list gnus-summary-highlight)
9697 (end (progn (end-of-line) (point)))
9698 ;; now find out where the line starts and leave point there.
9699 (beg (progn (beginning-of-line) (point)))
9700 (article (gnus-summary-article-number))
9701 (score (or (cdr (assq (or article gnus-current-article)
9702 gnus-newsgroup-scored))
9703 gnus-summary-default-score 0))
9704 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9705 (inhibit-read-only t))
9706 ;; Eval the cars of the lists until we find a match.
9707 (let ((default gnus-summary-default-score))
9709 (not (eval (caar list))))
9710 (setq list (cdr list))))
9711 (let ((face (cdar list)))
9712 (unless (eq face (get-text-property beg 'face))
9713 (gnus-put-text-property-excluding-characters-with-faces
9715 (setq face (if (boundp face) (symbol-value face) face)))
9716 (when gnus-summary-highlight-line-function
9717 (funcall gnus-summary-highlight-line-function article face))))
9720 (defun gnus-update-read-articles (group unread &optional compute)
9721 "Update the list of read articles in GROUP."
9722 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9723 (entry (gnus-gethash group gnus-newsrc-hashtb))
9724 (info (nth 2 entry))
9726 (unread (sort (copy-sequence unread) '<))
9728 (if (or (not info) (not active))
9729 ;; There is no info on this group if it was, in fact,
9730 ;; killed. Gnus stores no information on killed groups, so
9731 ;; there's nothing to be done.
9732 ;; One could store the information somewhere temporarily,
9733 ;; perhaps... Hmmm...
9735 ;; Remove any negative articles numbers.
9736 (while (and unread (< (car unread) 0))
9737 (setq unread (cdr unread)))
9738 ;; Remove any expired article numbers
9739 (while (and unread (< (car unread) (car active)))
9740 (setq unread (cdr unread)))
9741 ;; Compute the ranges of read articles by looking at the list of
9744 (when (/= (car unread) prev)
9745 (push (if (= prev (1- (car unread))) prev
9746 (cons prev (1- (car unread))))
9748 (setq prev (1+ (car unread)))
9749 (setq unread (cdr unread)))
9750 (when (<= prev (cdr active))
9751 (push (cons prev (cdr active)) read))
9752 (setq read (if (> (length read) 1) (nreverse read) read))
9757 ;; Propagate the read marks to the backend.
9758 (when (gnus-check-backend-function 'request-set-mark group)
9759 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9760 (add (gnus-remove-from-range read (gnus-info-read info))))
9762 (unless (gnus-check-group group)
9763 (error "Can't open server for %s" group))
9764 (gnus-request-set-mark
9765 group (delq nil (list (if add (list add 'add '(read)))
9766 (if del (list del 'del '(read))))))
9768 `(gnus-request-set-mark
9771 (if del (list del 'add '(read)))
9772 (if add (list add 'del '(read))))))))))
9773 (set-buffer gnus-group-buffer)
9776 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9777 (gnus-info-set-read ',info ',(gnus-info-read info))
9778 (gnus-get-unread-articles-in-group ',info
9779 (gnus-active ,group))
9780 (gnus-group-update-group ,group t)
9782 ;; Enter this list into the group info.
9783 (gnus-info-set-read info read)
9784 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9785 (gnus-get-unread-articles-in-group info (gnus-active group))
9788 (defun gnus-offer-save-summaries ()
9789 "Offer to save all active summary buffers."
9791 (let ((buflist (buffer-list))
9793 ;; Go through all buffers and find all summaries.
9795 (and (setq bufname (buffer-name (car buflist)))
9796 (string-match "Summary" bufname)
9798 (set-buffer bufname)
9799 ;; We check that this is, indeed, a summary buffer.
9800 (and (eq major-mode 'gnus-summary-mode)
9801 ;; Also make sure this isn't bogus.
9802 gnus-newsgroup-prepared
9803 ;; Also make sure that this isn't a dead summary buffer.
9804 (not gnus-dead-summary-mode)))
9805 (push bufname buffers))
9806 (setq buflist (cdr buflist)))
9807 ;; Go through all these summary buffers and offer to save them.
9810 "Update summary buffer %s? "
9812 (switch-to-buffer buf)
9813 (gnus-summary-exit))
9817 ;;; @ for mime-partial
9820 (defun gnus-request-partial-message ()
9822 (let ((number (gnus-summary-article-number))
9823 (group gnus-newsgroup-name)
9824 (mother gnus-article-buffer))
9825 (set-buffer (get-buffer-create " *Partial Article*"))
9827 (setq mime-preview-buffer mother)
9828 (gnus-request-article-this-buffer number group)
9832 (autoload 'mime-combine-message/partial-pieces-automatically
9834 "Internal method to combine message/partial messages automatically.")
9837 'action '((type . message)(subtype . partial)
9838 (major-mode . gnus-original-article-mode)
9839 (method . mime-combine-message/partial-pieces-automatically)
9840 (summary-buffer-exp . gnus-summary-buffer)
9841 (request-partial-message-method . gnus-request-partial-message)
9845 ;;; @ for message/rfc822
9848 (defun gnus-mime-extract-message/rfc822 (entity situation)
9849 (let (group article num cwin swin cur)
9851 (mime-insert-entity-content entity)
9852 (setq group (or (cdr (assq 'group situation))
9853 (completing-read "Group: "
9856 (gnus-read-active-file-p)
9857 gnus-newsgroup-name))
9858 article (gnus-request-accept-article group)))
9859 (when (and (consp article)
9860 (numberp (setq article (cdr article))))
9861 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9862 cwin (get-buffer-window (current-buffer) t))
9863 (save-window-excursion
9864 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9865 (select-window swin)
9866 (set-buffer gnus-summary-buffer))
9867 (setq cur gnus-current-article)
9869 (let (gnus-show-threads)
9870 (gnus-summary-goto-subject article t))
9871 (gnus-summary-clear-mark-forward 1)
9872 (gnus-summary-goto-subject cur))
9873 (when (and cwin (window-frame cwin))
9874 (select-frame (window-frame cwin)))
9875 (when (boundp 'mime-acting-situation-to-override)
9876 (set-alist 'mime-acting-situation-to-override
9879 (set-alist 'mime-acting-situation-to-override
9882 (save-current-buffer
9883 (set-buffer gnus-group-buffer)
9884 (gnus-activate-group ,group))
9885 (gnus-summary-goto-article ,cur
9886 gnus-show-all-headers)))
9887 (set-alist 'mime-acting-situation-to-override
9891 'action '((type . message)(subtype . rfc822)
9892 (major-mode . gnus-original-article-mode)
9893 (method . gnus-mime-extract-message/rfc822)
9898 'action '((type . message)(subtype . news)
9899 (major-mode . gnus-original-article-mode)
9900 (method . gnus-mime-extract-message/rfc822)
9904 (defun gnus-mime-extract-multipart (entity situation)
9905 (let ((children (mime-entity-children entity))
9906 mime-acting-situation-to-override
9909 (mime-play-entity (car children)
9910 (cons (assq 'mode situation)
9911 mime-acting-situation-to-override))
9912 (setq children (cdr children)))
9913 (if (setq f (cdr (assq 'after-method
9914 mime-acting-situation-to-override)))
9919 'action '((type . multipart)
9920 (method . gnus-mime-extract-multipart)
9929 (defun gnus-summary-setup-default-charset ()
9930 "Setup newsgroup default charset."
9931 (if (equal gnus-newsgroup-name "nndraft:drafts")
9932 (setq gnus-newsgroup-charset nil)
9933 (let* ((name (and gnus-newsgroup-name
9934 (gnus-group-real-name gnus-newsgroup-name)))
9936 (or gnus-newsgroup-ephemeral-ignored-charsets
9938 (and gnus-newsgroup-name
9939 (or (gnus-group-find-parameter gnus-newsgroup-name
9940 'ignored-charsets t)
9941 (let ((alist gnus-group-ignored-charsets-alist)
9942 elem (charsets nil))
9943 (while (setq elem (pop alist))
9945 (string-match (car elem) name))
9947 charsets (cdr elem))))
9949 gnus-newsgroup-ignored-charsets))))
9950 (setq gnus-newsgroup-charset
9951 (or gnus-newsgroup-ephemeral-charset
9952 (and gnus-newsgroup-name
9953 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9954 (let ((alist gnus-group-charset-alist)
9956 (while (setq elem (pop alist))
9958 (string-match (car elem) name))
9960 charset (cadr elem))))
9962 gnus-default-charset))
9963 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9964 ignored-charsets))))
9970 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9971 "Display the current article buffer fully MIME-buttonized.
9972 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9973 treated as multipart/mixed."
9976 (let ((gnus-unbuttonized-mime-types nil)
9977 (gnus-mime-display-multipart-as-mixed show-all-parts))
9978 (gnus-summary-show-article)))
9980 (defun gnus-summary-repair-multipart (article)
9981 "Add a Content-Type header to a multipart article without one."
9982 (interactive (list (gnus-summary-article-number)))
9983 (gnus-with-article article
9984 (message-narrow-to-head)
9985 (goto-char (point-max))
9987 (when (search-forward "\n--" nil t)
9988 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9989 (message-narrow-to-head)
9990 (message-remove-header "Mime-Version")
9991 (message-remove-header "Content-Type")
9992 (goto-char (point-max))
9993 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9995 (insert "Mime-Version: 1.0\n")
9997 (let (gnus-mark-article-hook)
9998 (gnus-summary-select-article t t nil article)))
10000 (defun gnus-summary-toggle-display-buttonized ()
10001 "Toggle the buttonizing of the article buffer."
10003 (require 'gnus-art)
10004 (if (setq gnus-inhibit-mime-unbuttonizing
10005 (not gnus-inhibit-mime-unbuttonizing))
10006 (let ((gnus-unbuttonized-mime-types nil))
10007 (gnus-summary-show-article))
10008 (gnus-summary-show-article)))
10011 ;;; Intelli-mouse commmands
10014 (defun gnus-wheel-summary-scroll (event)
10016 (let ((amount (if (memq 'shift (event-modifiers event))
10017 (car gnus-wheel-scroll-amount)
10018 (cdr gnus-wheel-scroll-amount)))
10019 (direction (- (* (static-if (featurep 'xemacs)
10020 (event-button event)
10021 (cond ((eq 'mouse-4 (event-basic-type event))
10023 ((eq 'mouse-5 (event-basic-type event))
10027 (gnus-summary-scroll-up (* amount direction))
10028 (when (gnus-eval-in-buffer-window gnus-article-buffer
10031 (and (if (< 0 direction)
10032 (gnus-article-next-page 0)
10033 (gnus-article-prev-page 0)
10035 (if (setq edge (get-text-property
10036 (point-min) 'gnus-wheel-edge))
10037 (setq edge (* edge direction))
10040 (let ((buffer-read-only nil)
10041 (inhibit-read-only t))
10042 (put-text-property (point-min) (point-max)
10043 'gnus-wheel-edge direction)
10045 (or (> edge gnus-wheel-edge-resistance)
10046 (let ((buffer-read-only nil)
10047 (inhibit-read-only t))
10048 (put-text-property (point-min) (point-max)
10050 (* (1+ edge) direction))
10052 (eq last-command 'gnus-wheel-summary-scroll))))
10053 (gnus-summary-next-article nil nil (minusp direction)))))
10055 (defun gnus-wheel-install ()
10056 "Enable mouse wheel support on summary window."
10057 (when gnus-use-wheel
10059 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10061 (define-key gnus-summary-mode-map key
10062 'gnus-wheel-summary-scroll)))))
10064 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10067 ;;; Traditional PGP commmands
10070 (defun gnus-summary-decrypt-article (&optional force)
10071 "Decrypt the current article in traditional PGP way.
10072 This will have permanent effect only in mail groups.
10073 If FORCE is non-nil, allow editing of articles even in read-only
10076 (gnus-summary-select-article t)
10077 (gnus-eval-in-buffer-window gnus-article-buffer
10081 (goto-char (point-min))
10082 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10083 (error "Not a traditional PGP message!"))
10084 (let ((armor-start (match-beginning 0)))
10085 (if (and (pgg-decrypt-region armor-start (point-max))
10086 (or force (not (gnus-group-read-only-p))))
10087 (let ((inhibit-read-only t)
10089 (delete-region armor-start
10091 (re-search-forward "^-+END PGP" nil t)
10092 (beginning-of-line 2)
10094 (insert-buffer-substring pgg-output-buffer))))))))
10096 (defun gnus-summary-verify-article ()
10097 "Verify the current article in traditional PGP way."
10100 (set-buffer gnus-original-article-buffer)
10101 (goto-char (point-min))
10102 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10103 (error "Not a traditional PGP message!"))
10104 (re-search-forward "^-+END PGP" nil t)
10105 (beginning-of-line 2)
10106 (call-interactively (function pgg-verify-region))))
10109 ;;; Generic summary marking commands
10112 (defvar gnus-summary-marking-alist
10113 '((read gnus-del-mark "d")
10114 (unread gnus-unread-mark "u")
10115 (ticked gnus-ticked-mark "!")
10116 (dormant gnus-dormant-mark "?")
10117 (expirable gnus-expirable-mark "e"))
10118 "An alist of names/marks/keystrokes.")
10120 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10121 (defvar gnus-summary-mark-map)
10123 (defun gnus-summary-make-all-marking-commands ()
10124 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10125 (dolist (elem gnus-summary-marking-alist)
10126 (apply 'gnus-summary-make-marking-command elem)))
10128 (defun gnus-summary-make-marking-command (name mark keystroke)
10129 (let ((map (make-sparse-keymap)))
10130 (define-key gnus-summary-generic-mark-map keystroke map)
10131 (dolist (lway `((next "next" next nil "n")
10132 (next-unread "next unread" next t "N")
10133 (prev "previous" prev nil "p")
10134 (prev-unread "previous unread" prev t "P")
10135 (nomove "" nil nil ,keystroke)))
10136 (let ((func (gnus-summary-make-marking-command-1
10137 mark (car lway) lway name)))
10138 (setq func (eval func))
10139 (define-key map (nth 4 lway) func)))))
10141 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10143 (format "gnus-summary-put-mark-as-%s%s"
10144 name (if (eq way 'nomove)
10146 (concat "-" (symbol-name way)))))
10149 "Mark the current article as %s%s.
10150 If N, the prefix, then repeat N times.
10151 If N is negative, move in reverse order.
10152 The difference between N and the actual number of articles marked is
10154 name (car (cdr lway)))
10156 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10158 (defun gnus-summary-generic-mark (n mark move unread)
10159 "Mark N articles with MARK."
10160 (unless (eq major-mode 'gnus-summary-mode)
10161 (error "This command can only be used in the summary buffer"))
10162 (gnus-summary-show-thread)
10165 ((eq move 'next) 1)
10166 ((eq move 'prev) -1)
10168 (if (zerop nummove)
10172 nummove (* -1 nummove))))
10173 (while (and (> n 0)
10174 (gnus-summary-mark-article nil mark)
10175 (zerop (gnus-summary-next-subject nummove unread t)))
10178 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10179 (gnus-summary-recenter)
10180 (gnus-summary-position-point)
10181 (gnus-set-mode-line 'summary)
10184 (gnus-summary-make-all-marking-commands)
10186 (gnus-ems-redefine)
10188 (provide 'gnus-sum)
10190 (run-hooks 'gnus-sum-load-hook)
10192 ;;; gnus-sum.el ends here