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)
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
57 (defcustom gnus-kill-summary-on-exit t
58 "*If non-nil, kill the summary buffer when you exit from it.
59 If nil, the summary will become a \"*Dead Summary*\" buffer, and
60 it will be killed sometime later."
61 :group 'gnus-summary-exit
64 (defcustom gnus-fetch-old-headers nil
65 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
66 If an unread article in the group refers to an older, already read (or
67 just marked as read) article, the old article will not normally be
68 displayed in the Summary buffer. If this variable is non-nil, Gnus
69 will attempt to grab the headers to the old articles, and thereby
70 build complete threads. If it has the value `some', only enough
71 headers to connect otherwise loose threads will be displayed. This
72 variable can also be a number. In that case, no more than that number
73 of old headers will be fetched. If it has the value `invisible', all
74 old headers will be fetched, but none will be displayed.
76 The server has to support NOV for any of this to work."
78 :type '(choice (const :tag "off" nil)
81 (sexp :menu-tag "other" t)))
83 (defcustom gnus-refer-thread-limit 200
84 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
85 If t, fetch all the available old headers."
88 (sexp :menu-tag "other" t)))
90 (defcustom gnus-summary-make-false-root 'adopt
91 "*nil means that Gnus won't gather loose threads.
92 If the root of a thread has expired or been read in a previous
93 session, the information necessary to build a complete thread has been
94 lost. Instead of having many small sub-threads from this original thread
95 scattered all over the summary buffer, Gnus can gather them.
97 If non-nil, Gnus will try to gather all loose sub-threads from an
98 original thread into one large thread.
100 If this variable is non-nil, it should be one of `none', `adopt',
103 If this variable is `none', Gnus will not make a false root, but just
104 present the sub-threads after another.
105 If this variable is `dummy', Gnus will create a dummy root that will
106 have all the sub-threads as children.
107 If this variable is `adopt', Gnus will make one of the \"children\"
108 the parent and mark all the step-children as such.
109 If this variable is `empty', the \"children\" are printed with empty
110 subject fields. (Or rather, they will be printed with a string
111 given by the `gnus-summary-same-subject' variable.)"
113 :type '(choice (const :tag "off" nil)
119 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
120 "*A regexp to match subjects to be excluded from loose thread gathering.
121 As loose thread gathering is done on subjects only, that means that
122 there can be many false gatherings performed. By rooting out certain
123 common subjects, gathering might become saner."
127 (defcustom gnus-summary-gather-subject-limit nil
128 "*Maximum length of subject comparisons when gathering loose threads.
129 Use nil to compare full subjects. Setting this variable to a low
130 number will help gather threads that have been corrupted by
131 newsreaders chopping off subject lines, but it might also mean that
132 unrelated articles that have subject that happen to begin with the
133 same few characters will be incorrectly gathered.
135 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
138 :type '(choice (const :tag "off" nil)
140 (sexp :menu-tag "on" t)))
142 (defcustom gnus-simplify-subject-functions nil
143 "List of functions taking a string argument that simplify subjects.
144 The functions are applied recursively.
146 Useful functions to put in this list include: `gnus-simplify-subject-re',
147 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
149 :type '(repeat function))
151 (defcustom gnus-simplify-ignored-prefixes nil
152 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
154 :type '(choice (const :tag "off" nil)
157 (defcustom gnus-build-sparse-threads nil
158 "*If non-nil, fill in the gaps in threads.
159 If `some', only fill in the gaps that are needed to tie loose threads
160 together. If `more', fill in all leaf nodes that Gnus can find. If
161 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
163 :type '(choice (const :tag "off" nil)
166 (sexp :menu-tag "all" t)))
168 (defcustom gnus-summary-thread-gathering-function
169 'gnus-gather-threads-by-subject
170 "*Function used for gathering loose threads.
171 There are two pre-defined functions: `gnus-gather-threads-by-subject',
172 which only takes Subjects into consideration; and
173 `gnus-gather-threads-by-references', which compared the References
174 headers of the articles to find matches."
176 :type '(radio (function-item gnus-gather-threads-by-subject)
177 (function-item gnus-gather-threads-by-references)
178 (function :tag "other")))
180 (defcustom gnus-summary-same-subject ""
181 "*String indicating that the current article has the same subject as the previous.
182 This variable will only be used if the value of
183 `gnus-summary-make-false-root' is `empty'."
184 :group 'gnus-summary-format
187 (defcustom gnus-summary-goto-unread t
188 "*If t, many commands will go to the next unread article.
189 This applies to marking commands as well as other commands that
190 \"naturally\" select the next article, like, for instance, `SPC' at
191 the end of an article.
193 If nil, the marking commands do NOT go to the next unread article
194 (they go to the next article instead). If `never', commands that
195 usually go to the next unread article, will go to the next article,
196 whether it is read or not."
197 :group 'gnus-summary-marks
198 :link '(custom-manual "(gnus)Setting Marks")
199 :type '(choice (const :tag "off" nil)
201 (sexp :menu-tag "on" t)))
203 (defcustom gnus-summary-default-score 0
204 "*Default article score level.
205 All scores generated by the score files will be added to this score.
206 If this variable is nil, scoring will be disabled."
207 :group 'gnus-score-default
208 :type '(choice (const :tag "disable")
211 (defcustom gnus-summary-zcore-fuzz 0
212 "*Fuzziness factor for the zcore in the summary buffer.
213 Articles with scores closer than this to `gnus-summary-default-score'
215 :group 'gnus-summary-format
218 (defcustom gnus-simplify-subject-fuzzy-regexp nil
219 "*Strings to be removed when doing fuzzy matches.
220 This can either be a regular expression or list of regular expressions
221 that will be removed from subject strings if fuzzy subject
222 simplification is selected."
224 :type '(repeat regexp))
226 (defcustom gnus-show-threads t
227 "*If non-nil, display threads in summary mode."
231 (defcustom gnus-thread-hide-subtree nil
232 "*If non-nil, hide all threads initially.
233 If threads are hidden, you have to run the command
234 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
235 to expose hidden threads."
239 (defcustom gnus-thread-hide-killed t
240 "*If non-nil, hide killed threads automatically."
244 (defcustom gnus-thread-ignore-subject t
245 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
246 If nil, articles that have different subjects from their parents will
247 start separate threads."
251 (defcustom gnus-thread-operation-ignore-subject t
252 "*If non-nil, subjects will be ignored when doing thread commands.
253 This affects commands like `gnus-summary-kill-thread' and
254 `gnus-summary-lower-thread'.
256 If this variable is nil, articles in the same thread with different
257 subjects will not be included in the operation in question. If this
258 variable is `fuzzy', only articles that have subjects that are fuzzily
259 equal will be included."
261 :type '(choice (const :tag "off" nil)
265 (defcustom gnus-thread-indent-level 4
266 "*Number that says how much each sub-thread should be indented."
270 (defcustom gnus-auto-extend-newsgroup t
271 "*If non-nil, extend newsgroup forward and backward when requested."
272 :group 'gnus-summary-choose
275 (defcustom gnus-auto-select-first t
276 "*If nil, don't select the first unread article when entering a group.
277 If this variable is `best', select the highest-scored unread article
278 in the group. If t, select the first unread article.
280 This variable can also be a function to place point on a likely
281 subject line. Useful values include `gnus-summary-first-unread-subject',
282 `gnus-summary-first-unread-article' and
283 `gnus-summary-best-unread-article'.
285 If you want to prevent automatic selection of the first unread article
286 in some newsgroups, set the variable to nil in
287 `gnus-select-group-hook'."
288 :group 'gnus-group-select
289 :type '(choice (const :tag "none" nil)
291 (sexp :menu-tag "first" t)
292 (function-item gnus-summary-first-unread-subject)
293 (function-item gnus-summary-first-unread-article)
294 (function-item gnus-summary-best-unread-article)))
296 (defcustom gnus-dont-select-after-jump-to-other-group nil
297 "If non-nil, don't select the first unread article after entering the
298 other group by the command `gnus-summary-jump-to-other-group'. If nil,
299 it is depend on the value of `gnus-auto-select-first' whether to select
301 :group 'gnus-group-select
304 (defcustom gnus-auto-select-next t
305 "*If non-nil, offer to go to the next group from the end of the previous.
306 If the value is t and the next newsgroup is empty, Gnus will exit
307 summary mode and go back to group mode. If the value is neither nil
308 nor t, Gnus will select the following unread newsgroup. In
309 particular, if the value is the symbol `quietly', the next unread
310 newsgroup will be selected without any confirmation, and if it is
311 `almost-quietly', the next group will be selected without any
312 confirmation if you are located on the last article in the group.
313 Finally, if this variable is `slightly-quietly', the `Z n' command
314 will go to the next group without confirmation."
315 :group 'gnus-summary-maneuvering
316 :type '(choice (const :tag "off" nil)
318 (const almost-quietly)
319 (const slightly-quietly)
320 (sexp :menu-tag "on" t)))
322 (defcustom gnus-auto-select-same nil
323 "*If non-nil, select the next article with the same subject.
324 If there are no more articles with the same subject, go to
325 the first unread article."
326 :group 'gnus-summary-maneuvering
329 (defcustom gnus-summary-check-current nil
330 "*If non-nil, consider the current article when moving.
331 The \"unread\" movement commands will stay on the same line if the
332 current article is unread."
333 :group 'gnus-summary-maneuvering
336 (defcustom gnus-auto-center-summary t
337 "*If non-nil, always center the current summary buffer.
338 In particular, if `vertical' do only vertical recentering. If non-nil
339 and non-`vertical', do both horizontal and vertical recentering."
340 :group 'gnus-summary-maneuvering
341 :type '(choice (const :tag "none" nil)
343 (integer :tag "height")
344 (sexp :menu-tag "both" t)))
346 (defcustom gnus-show-all-headers nil
347 "*If non-nil, don't hide any headers."
348 :group 'gnus-article-hiding
349 :group 'gnus-article-headers
352 (defcustom gnus-summary-ignore-duplicates nil
353 "*If non-nil, ignore articles with identical Message-ID headers."
357 (defcustom gnus-single-article-buffer t
358 "*If non-nil, display all articles in the same buffer.
359 If nil, each group will get its own article buffer."
360 :group 'gnus-article-various
363 (defcustom gnus-break-pages t
364 "*If non-nil, do page breaking on articles.
365 The page delimiter is specified by the `gnus-page-delimiter'
367 :group 'gnus-article-various
370 (defcustom gnus-show-mime t
371 "*If non-nil, do mime processing of articles.
372 The articles will simply be fed to the function given by
373 `gnus-article-display-method-for-mime'."
374 :group 'gnus-article-mime
377 (defcustom gnus-move-split-methods nil
378 "*Variable used to suggest where articles are to be moved to.
379 It uses the same syntax as the `gnus-split-methods' variable.
380 However, whereas `gnus-split-methods' specifies file names as targets,
381 this variable specifies group names."
382 :group 'gnus-summary-mail
383 :type '(repeat (choice (list :value (fun) function)
384 (cons :value ("" "") regexp (repeat string))
387 (defcustom gnus-unread-mark ? ;Whitespace
388 "*Mark used for unread articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-ticked-mark ?!
393 "*Mark used for ticked articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-dormant-mark ??
398 "*Mark used for dormant articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-del-mark ?r
403 "*Mark used for del'd articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-read-mark ?R
408 "*Mark used for read articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-expirable-mark ?E
413 "*Mark used for expirable articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-killed-mark ?K
418 "*Mark used for killed articles."
419 :group 'gnus-summary-marks
422 (defcustom gnus-souped-mark ?F
423 "*Mark used for killed articles."
424 :group 'gnus-summary-marks
427 (defcustom gnus-kill-file-mark ?X
428 "*Mark used for articles killed by kill files."
429 :group 'gnus-summary-marks
432 (defcustom gnus-low-score-mark ?Y
433 "*Mark used for articles with a low score."
434 :group 'gnus-summary-marks
437 (defcustom gnus-catchup-mark ?C
438 "*Mark used for articles that are caught up."
439 :group 'gnus-summary-marks
442 (defcustom gnus-replied-mark ?A
443 "*Mark used for articles that have been replied to."
444 :group 'gnus-summary-marks
447 (defcustom gnus-cached-mark ?*
448 "*Mark used for articles that are in the cache."
449 :group 'gnus-summary-marks
452 (defcustom gnus-saved-mark ?S
453 "*Mark used for articles that have been saved to."
454 :group 'gnus-summary-marks
457 (defcustom gnus-ancient-mark ?O
458 "*Mark used for ancient articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-sparse-mark ?Q
463 "*Mark used for sparsely reffed articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-canceled-mark ?G
468 "*Mark used for canceled articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-duplicate-mark ?M
473 "*Mark used for duplicate articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-undownloaded-mark ?@
478 "*Mark used for articles that weren't downloaded."
479 :group 'gnus-summary-marks
482 (defcustom gnus-downloadable-mark ?%
483 "*Mark used for articles that are to be downloaded."
484 :group 'gnus-summary-marks
487 (defcustom gnus-unsendable-mark ?=
488 "*Mark used for articles that won't be sent."
489 :group 'gnus-summary-marks
492 (defcustom gnus-score-over-mark ?+
493 "*Score mark used for articles with high scores."
494 :group 'gnus-summary-marks
497 (defcustom gnus-score-below-mark ?-
498 "*Score mark used for articles with low scores."
499 :group 'gnus-summary-marks
502 (defcustom gnus-empty-thread-mark ? ;Whitespace
503 "*There is no thread under the article."
504 :group 'gnus-summary-marks
507 (defcustom gnus-not-empty-thread-mark ?=
508 "*There is a thread under the article."
509 :group 'gnus-summary-marks
512 (defcustom gnus-view-pseudo-asynchronously nil
513 "*If non-nil, Gnus will view pseudo-articles asynchronously."
514 :group 'gnus-extract-view
517 (defcustom gnus-auto-expirable-marks
518 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
519 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
520 gnus-souped-mark gnus-duplicate-mark)
521 "*The list of marks converted into expiration if a group is auto-expirable."
523 :type '(repeat character))
525 (defcustom gnus-inhibit-user-auto-expire t
526 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
530 (defcustom gnus-view-pseudos nil
531 "*If `automatic', pseudo-articles will be viewed automatically.
532 If `not-confirm', pseudos will be viewed automatically, and the user
533 will not be asked to confirm the command."
534 :group 'gnus-extract-view
535 :type '(choice (const :tag "off" nil)
537 (const not-confirm)))
539 (defcustom gnus-view-pseudos-separately t
540 "*If non-nil, one pseudo-article will be created for each file to be viewed.
541 If nil, all files that use the same viewing command will be given as a
542 list of parameters to that command."
543 :group 'gnus-extract-view
546 (defcustom gnus-insert-pseudo-articles t
547 "*If non-nil, insert pseudo-articles when decoding articles."
548 :group 'gnus-extract-view
551 (defcustom gnus-summary-dummy-line-format
553 "*The format specification for the dummy roots in the summary buffer.
554 It works along the same lines as a normal formatting string,
555 with some simple extensions.
558 :group 'gnus-threading
561 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
562 "*The format specification for the summary mode line.
563 It works along the same lines as a normal formatting string,
564 with some simple extensions:
567 %p Unprefixed group name
568 %A Current article number
569 %z Current article score
571 %U Number of unread articles in the group
572 %e Number of unselected articles in the group
573 %Z A string with unread/unselected article counts
574 %g Shortish group name
575 %S Subject of the current article
577 %s Current score file name
578 %d Number of dormant articles
579 %r Number of articles that have been marked as read in this session
580 %E Number of articles expunged by the score files"
581 :group 'gnus-summary-format
584 (defcustom gnus-list-identifiers nil
585 "Regexp that matches list identifiers to be removed from subject.
586 This can also be a list of regexps."
587 :group 'gnus-summary-format
588 :group 'gnus-article-hiding
589 :type '(choice (const :tag "none" nil)
591 (repeat :value (".*") regexp)))
593 (defcustom gnus-summary-mark-below 0
594 "*Mark all articles with a score below this variable as read.
595 This variable is local to each summary buffer and usually set by the
597 :group 'gnus-score-default
600 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
601 "*List of functions used for sorting articles in the summary buffer.
602 This variable is only used when not using a threaded display."
603 :group 'gnus-summary-sort
604 :type '(repeat (choice (function-item gnus-article-sort-by-number)
605 (function-item gnus-article-sort-by-author)
606 (function-item gnus-article-sort-by-subject)
607 (function-item gnus-article-sort-by-date)
608 (function-item gnus-article-sort-by-score)
609 (function :tag "other"))))
611 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
612 "*List of functions used for sorting threads in the summary buffer.
613 By default, threads are sorted by article number.
615 Each function takes two threads and return non-nil if the first thread
616 should be sorted before the other. If you use more than one function,
617 the primary sort function should be the last. You should probably
618 always include `gnus-thread-sort-by-number' in the list of sorting
619 functions -- preferably first.
621 Ready-made functions include `gnus-thread-sort-by-number',
622 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
623 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
624 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
625 :group 'gnus-summary-sort
626 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
627 (function-item gnus-thread-sort-by-author)
628 (function-item gnus-thread-sort-by-subject)
629 (function-item gnus-thread-sort-by-date)
630 (function-item gnus-thread-sort-by-score)
631 (function-item gnus-thread-sort-by-total-score)
632 (function :tag "other"))))
634 (defcustom gnus-thread-score-function '+
635 "*Function used for calculating the total score of a thread.
637 The function is called with the scores of the article and each
638 subthread and should then return the score of the thread.
640 Some functions you can use are `+', `max', or `min'."
641 :group 'gnus-summary-sort
644 (defcustom gnus-summary-expunge-below nil
645 "All articles that have a score less than this variable will be expunged.
646 This variable is local to the summary buffers."
647 :group 'gnus-score-default
648 :type '(choice (const :tag "off" nil)
651 (defcustom gnus-thread-expunge-below nil
652 "All threads that have a total score less than this variable will be expunged.
653 See `gnus-thread-score-function' for en explanation of what a
656 This variable is local to the summary buffers."
657 :group 'gnus-threading
658 :group 'gnus-score-default
659 :type '(choice (const :tag "off" nil)
662 (defcustom gnus-summary-mode-hook nil
663 "*A hook for Gnus summary mode.
664 This hook is run before any variables are set in the summary buffer."
665 :group 'gnus-summary-various
668 (defcustom gnus-summary-menu-hook nil
669 "*Hook run after the creation of the summary mode menu."
670 :group 'gnus-summary-visual
673 (defcustom gnus-summary-exit-hook nil
674 "*A hook called on exit from the summary buffer.
675 It will be called with point in the group buffer."
676 :group 'gnus-summary-exit
679 (defcustom gnus-summary-prepare-hook nil
680 "*A hook called after the summary buffer has been generated.
681 If you want to modify the summary buffer, you can use this hook."
682 :group 'gnus-summary-various
685 (defcustom gnus-summary-prepared-hook nil
686 "*A hook called as the last thing after the summary buffer has been generated."
687 :group 'gnus-summary-various
690 (defcustom gnus-summary-generate-hook nil
691 "*A hook run just before generating the summary buffer.
692 This hook is commonly used to customize threading variables and the
694 :group 'gnus-summary-various
697 (defcustom gnus-select-group-hook nil
698 "*A hook called when a newsgroup is selected.
700 If you'd like to simplify subjects like the
701 `gnus-summary-next-same-subject' command does, you can use the
704 (setq gnus-select-group-hook
707 (mapcar (lambda (header)
708 (mail-header-set-subject
710 (gnus-simplify-subject
711 (mail-header-subject header) 're-only)))
712 gnus-newsgroup-headers))))"
713 :group 'gnus-group-select
716 (defcustom gnus-select-article-hook nil
717 "*A hook called when an article is selected."
718 :group 'gnus-summary-choose
721 (defcustom gnus-visual-mark-article-hook
722 (list 'gnus-highlight-selected-summary)
723 "*Hook run after selecting an article in the summary buffer.
724 It is meant to be used for highlighting the article in some way. It
725 is not run if `gnus-visual' is nil."
726 :group 'gnus-summary-visual
729 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
730 "*A hook called before parsing the headers."
734 (defcustom gnus-exit-group-hook nil
735 "*A hook called when exiting summary mode.
736 This hook is not called from the non-updating exit commands like `Q'."
740 (defcustom gnus-summary-update-hook
741 (list 'gnus-summary-highlight-line)
742 "*A hook called when a summary line is changed.
743 The hook will not be called if `gnus-visual' is nil.
745 The default function `gnus-summary-highlight-line' will
746 highlight the line according to the `gnus-summary-highlight'
748 :group 'gnus-summary-visual
751 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
752 "*A hook called when an article is selected for the first time.
753 The hook is intended to mark an article as read (or unread)
754 automatically when it is selected."
755 :group 'gnus-summary-choose
758 (defcustom gnus-group-no-more-groups-hook nil
759 "*A hook run when returning to group mode having no more (unread) groups."
760 :group 'gnus-group-select
763 (defcustom gnus-ps-print-hook nil
764 "*A hook run before ps-printing something from Gnus."
768 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
769 "Face used for highlighting the current article in the summary buffer."
770 :group 'gnus-summary-visual
773 (defcustom gnus-summary-highlight
774 '(((= mark gnus-canceled-mark)
775 . gnus-summary-cancelled-face)
776 ((and (> score default)
777 (or (= mark gnus-dormant-mark)
778 (= mark gnus-ticked-mark)))
779 . gnus-summary-high-ticked-face)
780 ((and (< score default)
781 (or (= mark gnus-dormant-mark)
782 (= mark gnus-ticked-mark)))
783 . gnus-summary-low-ticked-face)
784 ((or (= mark gnus-dormant-mark)
785 (= mark gnus-ticked-mark))
786 . gnus-summary-normal-ticked-face)
787 ((and (> score default) (= mark gnus-ancient-mark))
788 . gnus-summary-high-ancient-face)
789 ((and (< score default) (= mark gnus-ancient-mark))
790 . gnus-summary-low-ancient-face)
791 ((= mark gnus-ancient-mark)
792 . gnus-summary-normal-ancient-face)
793 ((and (> score default) (= mark gnus-unread-mark))
794 . gnus-summary-high-unread-face)
795 ((and (< score default) (= mark gnus-unread-mark))
796 . gnus-summary-low-unread-face)
797 ((and (memq article gnus-newsgroup-incorporated)
798 (= mark gnus-unread-mark))
799 . gnus-summary-incorporated-face)
800 ((= mark gnus-unread-mark)
801 . gnus-summary-normal-unread-face)
802 ((and (> score default) (memq mark (list gnus-downloadable-mark
803 gnus-undownloaded-mark)))
804 . gnus-summary-high-unread-face)
805 ((and (< score default) (memq mark (list gnus-downloadable-mark
806 gnus-undownloaded-mark)))
807 . gnus-summary-low-unread-face)
808 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
809 . gnus-summary-normal-unread-face)
811 . gnus-summary-high-read-face)
813 . gnus-summary-low-read-face)
815 . gnus-summary-normal-read-face))
816 "*Controls the highlighting of summary buffer lines.
818 A list of (FORM . FACE) pairs. When deciding how a a particular
819 summary line should be displayed, each form is evaluated. The content
820 of the face field after the first true form is used. You can change
821 how those summary lines are displayed, by editing the face field.
823 You can use the following variables in the FORM field.
825 score: The articles score
826 default: The default article score.
827 below: The score below which articles are automatically marked as read.
828 mark: The articles mark."
829 :group 'gnus-summary-visual
830 :type '(repeat (cons (sexp :tag "Form" nil)
833 (defcustom gnus-alter-header-function nil
834 "Function called to allow alteration of article header structures.
835 The function is called with one parameter, the article header vector,
836 which it may alter in any way.")
838 (defvar gnus-decode-encoded-word-function
839 (mime-find-field-decoder 'From 'nov)
840 "Variable that says which function should be used to decode a string with encoded words.")
842 (defcustom gnus-extra-headers nil
843 "*Extra headers to parse."
845 :type '(repeat symbol))
847 (defcustom gnus-ignored-from-addresses
848 (and user-mail-address (regexp-quote user-mail-address))
849 "*Regexp of From headers that may be suppressed in favor of To headers."
853 (defcustom gnus-group-charset-alist
854 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
855 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
856 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
857 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
858 ("^relcom\\>" koi8-r)
860 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
861 ("^israel\\>" iso-8859-1)
863 ("^alt.chinese.text.big5\\>" chinese-big5)
864 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
865 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
867 "Alist of regexps (to match group names) and default charsets to be used when reading."
868 :type '(repeat (list (regexp :tag "Group")
869 (symbol :tag "Charset")))
870 :group 'gnus-charset)
872 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
873 "List of charsets that should be ignored.
874 When these charsets are used in the \"charset\" parameter, the
875 default charset will be used instead."
876 :type '(repeat symbol)
877 :group 'gnus-charset)
879 (defcustom gnus-group-ignored-charsets-alist
880 '(("alt\\.chinese\\.text" iso-8859-1))
881 "Alist of regexps (to match group names) and charsets that should be ignored.
882 When these charsets are used in the \"charset\" parameter, the
883 default charset will be used instead."
884 :type '(repeat (cons (regexp :tag "Group")
886 :group 'gnus-charset)
888 (defcustom gnus-group-highlight-words-alist nil
889 "Alist of group regexps and highlight regexps.
890 This variable uses the same syntax as `gnus-emphasis-alist'."
891 :type '(repeat (cons (regexp :tag "Group")
892 (repeat (list (regexp :tag "Highlight regexp")
893 (number :tag "Group for entire word" 0)
894 (number :tag "Group for displayed part" 0)
896 gnus-emphasis-highlight-words)))))
897 :group 'gnus-summary-visual)
899 (defcustom gnus-use-wheel nil
900 "Use Intelli-mouse on summary movement"
902 :group 'gnus-summary-maneuvering)
904 (defcustom gnus-wheel-scroll-amount '(5 . 1)
905 "Amount to scroll messages by spinning the mouse wheel.
906 This is actually a cons cell, where the first item is the amount to scroll
907 on a normal wheel event, and the second is the amount to scroll when the
908 wheel is moved with the shift key depressed."
909 :type '(cons (integer :tag "Shift") integer)
910 :group 'gnus-summary-maneuvering)
912 (defcustom gnus-wheel-edge-resistance 2
913 "How hard it should be to change the current article
914 by moving the mouse over the edge of the article window."
916 :group 'gnus-summary-maneuvering)
918 (defcustom gnus-summary-show-article-charset-alist
920 "Alist of number and charset.
921 The article will be shown with the charset corresponding to the
923 For example: ((1 . cn-gb-2312) (2 . big5))."
924 :type '(repeat (cons (number :tag "Argument" 1)
925 (symbol :tag "Charset")))
926 :group 'gnus-charset)
928 (defcustom gnus-preserve-marks t
929 "Whether marks are preserved when moving, copying and respooling messages."
931 :group 'gnus-summary-marks)
933 (defcustom gnus-alter-articles-to-read-function nil
934 "Function to be called to alter the list of articles to be selected."
936 :group 'gnus-summary)
938 (defcustom gnus-orphan-score nil
939 "*All orphans get this score added. Set in the score file."
940 :group 'gnus-score-default
941 :type '(choice (const nil)
944 (defcustom gnus-summary-save-parts-default-mime "image/.*"
945 "*A regexp to match MIME parts when saving multiple parts of a message
946 with gnus-summary-save-parts (X m). This regexp will be used by default
947 when prompting the user for which type of files to save."
952 ;;; Internal variables
954 (defvar gnus-article-mime-handles nil)
955 (defvar gnus-article-decoded-p nil)
956 (defvar gnus-scores-exclude-files nil)
957 (defvar gnus-page-broken nil)
958 (defvar gnus-inhibit-mime-unbuttonizing nil)
960 (defvar gnus-original-article nil)
961 (defvar gnus-article-internal-prepare-hook nil)
962 (defvar gnus-newsgroup-process-stack nil)
964 (defvar gnus-thread-indent-array nil)
965 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
966 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
967 "Function called to sort the articles within a thread after it has been gathered together.")
969 (defvar gnus-summary-save-parts-type-history nil)
970 (defvar gnus-summary-save-parts-last-directory nil)
972 ;; Avoid highlighting in kill files.
973 (defvar gnus-summary-inhibit-highlight nil)
974 (defvar gnus-newsgroup-selected-overlay nil)
975 (defvar gnus-inhibit-limiting nil)
976 (defvar gnus-newsgroup-adaptive-score-file nil)
977 (defvar gnus-current-score-file nil)
978 (defvar gnus-current-move-group nil)
979 (defvar gnus-current-copy-group nil)
980 (defvar gnus-current-crosspost-group nil)
982 (defvar gnus-newsgroup-dependencies nil)
983 (defvar gnus-newsgroup-adaptive nil)
984 (defvar gnus-summary-display-article-function nil)
985 (defvar gnus-summary-highlight-line-function nil
986 "Function called after highlighting a summary line.")
988 (defvar gnus-summary-line-format-alist
989 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
990 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
991 (?s gnus-tmp-subject-or-nil ?s)
992 (?n gnus-tmp-name ?s)
993 (?A (std11-address-string
994 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
995 (?a (or (std11-full-name-string
996 (car (mime-entity-read-field gnus-tmp-header 'From)))
998 (?F gnus-tmp-from ?s)
999 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1000 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1001 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1002 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1003 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1004 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1005 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1006 (?L gnus-tmp-lines ?d)
1007 (?I gnus-tmp-indentation ?s)
1008 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1009 (?R gnus-tmp-replied ?c)
1010 (?\[ gnus-tmp-opening-bracket ?c)
1011 (?\] gnus-tmp-closing-bracket ?c)
1012 (?\> (make-string gnus-tmp-level ? ) ?s)
1013 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1014 (?i gnus-tmp-score ?d)
1015 (?z gnus-tmp-score-char ?c)
1016 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1017 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1018 (?U gnus-tmp-unread ?c)
1019 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
1020 (?t (gnus-summary-number-of-articles-in-thread
1021 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1023 (?e (gnus-summary-number-of-articles-in-thread
1024 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1026 (?u gnus-tmp-user-defined ?s)
1027 (?P (gnus-pick-line-number) ?d))
1028 "An alist of format specifications that can appear in summary lines.
1029 These are paired with what variables they correspond with, along with
1030 the type of the variable (string, integer, character, etc).")
1032 (defvar gnus-summary-dummy-line-format-alist
1033 `((?S gnus-tmp-subject ?s)
1034 (?N gnus-tmp-number ?d)
1035 (?u gnus-tmp-user-defined ?s)))
1037 (defvar gnus-summary-mode-line-format-alist
1038 `((?G gnus-tmp-group-name ?s)
1039 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1040 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1041 (?A gnus-tmp-article-number ?d)
1042 (?Z gnus-tmp-unread-and-unselected ?s)
1043 (?V gnus-version ?s)
1044 (?U gnus-tmp-unread-and-unticked ?d)
1045 (?S gnus-tmp-subject ?s)
1046 (?e gnus-tmp-unselected ?d)
1047 (?u gnus-tmp-user-defined ?s)
1048 (?d (length gnus-newsgroup-dormant) ?d)
1049 (?t (length gnus-newsgroup-marked) ?d)
1050 (?r (length gnus-newsgroup-reads) ?d)
1051 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1052 (?E gnus-newsgroup-expunged-tally ?d)
1053 (?s (gnus-current-score-file-nondirectory) ?s)))
1055 (defvar gnus-last-search-regexp nil
1056 "Default regexp for article search command.")
1058 (defvar gnus-summary-search-article-matched-data nil
1059 "Last matched data of article search command. It is the local variable
1060 in `gnus-article-buffer' which consists of the list of start position,
1061 end position and text.")
1063 (defvar gnus-last-shell-command nil
1064 "Default shell command on article.")
1066 (defvar gnus-newsgroup-begin nil)
1067 (defvar gnus-newsgroup-end nil)
1068 (defvar gnus-newsgroup-last-rmail nil)
1069 (defvar gnus-newsgroup-last-mail nil)
1070 (defvar gnus-newsgroup-last-folder nil)
1071 (defvar gnus-newsgroup-last-file nil)
1072 (defvar gnus-newsgroup-auto-expire nil)
1073 (defvar gnus-newsgroup-active nil)
1075 (defvar gnus-newsgroup-data nil)
1076 (defvar gnus-newsgroup-data-reverse nil)
1077 (defvar gnus-newsgroup-limit nil)
1078 (defvar gnus-newsgroup-limits nil)
1080 (defvar gnus-newsgroup-unreads nil
1081 "List of unread articles in the current newsgroup.")
1083 (defvar gnus-newsgroup-unselected nil
1084 "List of unselected unread articles in the current newsgroup.")
1086 (defvar gnus-newsgroup-reads nil
1087 "Alist of read articles and article marks in the current newsgroup.")
1089 (defvar gnus-newsgroup-expunged-tally nil)
1091 (defvar gnus-newsgroup-marked nil
1092 "List of ticked articles in the current newsgroup (a subset of unread art).")
1094 (defvar gnus-newsgroup-killed nil
1095 "List of ranges of articles that have been through the scoring process.")
1097 (defvar gnus-newsgroup-cached nil
1098 "List of articles that come from the article cache.")
1100 (defvar gnus-newsgroup-saved nil
1101 "List of articles that have been saved.")
1103 (defvar gnus-newsgroup-kill-headers nil)
1105 (defvar gnus-newsgroup-replied nil
1106 "List of articles that have been replied to in the current newsgroup.")
1108 (defvar gnus-newsgroup-expirable nil
1109 "List of articles in the current newsgroup that can be expired.")
1111 (defvar gnus-newsgroup-processable nil
1112 "List of articles in the current newsgroup that can be processed.")
1114 (defvar gnus-newsgroup-downloadable nil
1115 "List of articles in the current newsgroup that can be processed.")
1117 (defvar gnus-newsgroup-undownloaded nil
1118 "List of articles in the current newsgroup that haven't been downloaded..")
1120 (defvar gnus-newsgroup-unsendable nil
1121 "List of articles in the current newsgroup that won't be sent.")
1123 (defvar gnus-newsgroup-bookmarks nil
1124 "List of articles in the current newsgroup that have bookmarks.")
1126 (defvar gnus-newsgroup-dormant nil
1127 "List of dormant articles in the current newsgroup.")
1129 (defvar gnus-newsgroup-scored nil
1130 "List of scored articles in the current newsgroup.")
1132 (defvar gnus-newsgroup-incorporated nil
1133 "List of incorporated articles in the current newsgroup.")
1135 (defvar gnus-newsgroup-headers nil
1136 "List of article headers in the current newsgroup.")
1138 (defvar gnus-newsgroup-threads nil)
1140 (defvar gnus-newsgroup-prepared nil
1141 "Whether the current group has been prepared properly.")
1143 (defvar gnus-newsgroup-ancient nil
1144 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1146 (defvar gnus-newsgroup-sparse nil)
1148 (defvar gnus-current-article nil)
1149 (defvar gnus-article-current nil)
1150 (defvar gnus-current-headers nil)
1151 (defvar gnus-have-all-headers nil)
1152 (defvar gnus-last-article nil)
1153 (defvar gnus-newsgroup-history nil)
1154 (defvar gnus-newsgroup-charset nil)
1155 (defvar gnus-newsgroup-ephemeral-charset nil)
1156 (defvar gnus-newsgroup-ephemeral-ignored-charsets 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 ;; Byte-compiler warning.
1196 (defvar gnus-article-mode-map)
1198 ;; Subject simplification.
1200 (defun gnus-simplify-whitespace (str)
1201 "Remove excessive whitespace from STR."
1204 (while (string-match "[ \t][ \t]+" mystr)
1205 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1207 (substring mystr (match-end 0)))))
1209 (when (string-match "^[ \t]+" mystr)
1210 (setq mystr (substring mystr (match-end 0))))
1212 (when (string-match "[ \t]+$" mystr)
1213 (setq mystr (substring mystr 0 (match-beginning 0))))
1216 (defsubst gnus-simplify-subject-re (subject)
1217 "Remove \"Re:\" from subject lines."
1218 (if (string-match "^[Rr][Ee]: *" subject)
1219 (substring subject (match-end 0))
1222 (defun gnus-simplify-subject (subject &optional re-only)
1223 "Remove `Re:' and words in parentheses.
1224 If RE-ONLY is non-nil, strip leading `Re:'s only."
1225 (let ((case-fold-search t)) ;Ignore case.
1226 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1227 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1228 (setq subject (substring subject (match-end 0))))
1229 ;; Remove uninteresting prefixes.
1230 (when (and (not re-only)
1231 gnus-simplify-ignored-prefixes
1232 (string-match gnus-simplify-ignored-prefixes subject))
1233 (setq subject (substring subject (match-end 0))))
1234 ;; Remove words in parentheses from end.
1236 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1237 (setq subject (substring subject 0 (match-beginning 0)))))
1238 ;; Return subject string.
1241 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1243 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1244 (goto-char (point-min))
1245 (while (re-search-forward regexp nil t)
1246 (replace-match (or newtext ""))))
1248 (defun gnus-simplify-buffer-fuzzy ()
1249 "Simplify string in the buffer fuzzily.
1250 The string in the accessible portion of the current buffer is simplified.
1251 It is assumed to be a single-line subject.
1252 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1253 matter is removed. Additional things can be deleted by setting
1254 `gnus-simplify-subject-fuzzy-regexp'."
1255 (let ((case-fold-search t)
1257 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1259 (while (not (eq modified-tick (buffer-modified-tick)))
1260 (setq modified-tick (buffer-modified-tick))
1262 ((listp gnus-simplify-subject-fuzzy-regexp)
1263 (mapcar 'gnus-simplify-buffer-fuzzy-step
1264 gnus-simplify-subject-fuzzy-regexp))
1265 (gnus-simplify-subject-fuzzy-regexp
1266 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1267 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1268 (gnus-simplify-buffer-fuzzy-step
1269 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1270 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1272 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1273 (gnus-simplify-buffer-fuzzy-step " +" " ")
1274 (gnus-simplify-buffer-fuzzy-step " $")
1275 (gnus-simplify-buffer-fuzzy-step "^ +")))
1277 (defun gnus-simplify-subject-fuzzy (subject)
1278 "Simplify a subject string fuzzily.
1279 See `gnus-simplify-buffer-fuzzy' for details."
1281 (gnus-set-work-buffer)
1282 (let ((case-fold-search t))
1283 ;; Remove uninteresting prefixes.
1284 (when (and gnus-simplify-ignored-prefixes
1285 (string-match gnus-simplify-ignored-prefixes subject))
1286 (setq subject (substring subject (match-end 0))))
1288 (inline (gnus-simplify-buffer-fuzzy))
1291 (defsubst gnus-simplify-subject-fully (subject)
1292 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1294 (gnus-simplify-subject-functions
1295 (gnus-map-function gnus-simplify-subject-functions subject))
1296 ((null gnus-summary-gather-subject-limit)
1297 (gnus-simplify-subject-re subject))
1298 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1299 (gnus-simplify-subject-fuzzy subject))
1300 ((numberp gnus-summary-gather-subject-limit)
1301 (gnus-limit-string (gnus-simplify-subject-re subject)
1302 gnus-summary-gather-subject-limit))
1306 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1307 "Check whether two subjects are equal.
1308 If optional argument simple-first is t, first argument is already
1311 ((null simple-first)
1312 (equal (gnus-simplify-subject-fully s1)
1313 (gnus-simplify-subject-fully s2)))
1316 (gnus-simplify-subject-fully s2)))))
1318 (defun gnus-summary-bubble-group ()
1319 "Increase the score of the current group.
1320 This is a handy function to add to `gnus-summary-exit-hook' to
1321 increase the score of each group you read."
1322 (gnus-group-add-score gnus-newsgroup-name))
1326 ;;; Gnus summary mode
1329 (put 'gnus-summary-mode 'mode-class 'special)
1332 ;; Non-orthogonal keys
1334 (gnus-define-keys gnus-summary-mode-map
1335 " " gnus-summary-next-page
1336 "\177" gnus-summary-prev-page
1337 [delete] gnus-summary-prev-page
1338 [backspace] gnus-summary-prev-page
1339 "\r" gnus-summary-scroll-up
1340 "\M-\r" gnus-summary-scroll-down
1341 "n" gnus-summary-next-unread-article
1342 "p" gnus-summary-prev-unread-article
1343 "N" gnus-summary-next-article
1344 "P" gnus-summary-prev-article
1345 "\M-\C-n" gnus-summary-next-same-subject
1346 "\M-\C-p" gnus-summary-prev-same-subject
1347 "\M-n" gnus-summary-next-unread-subject
1348 "\M-p" gnus-summary-prev-unread-subject
1349 "." gnus-summary-first-unread-article
1350 "," gnus-summary-best-unread-article
1351 "\M-s" gnus-summary-search-article-forward
1352 "\M-r" gnus-summary-search-article-backward
1353 "<" gnus-summary-beginning-of-article
1354 ">" gnus-summary-end-of-article
1355 "j" gnus-summary-goto-article
1356 "^" gnus-summary-refer-parent-article
1357 "\M-^" gnus-summary-refer-article
1358 "u" gnus-summary-tick-article-forward
1359 "!" gnus-summary-tick-article-forward
1360 "U" gnus-summary-tick-article-backward
1361 "d" gnus-summary-mark-as-read-forward
1362 "D" gnus-summary-mark-as-read-backward
1363 "E" gnus-summary-mark-as-expirable
1364 "\M-u" gnus-summary-clear-mark-forward
1365 "\M-U" gnus-summary-clear-mark-backward
1366 "k" gnus-summary-kill-same-subject-and-select
1367 "\C-k" gnus-summary-kill-same-subject
1368 "\M-\C-k" gnus-summary-kill-thread
1369 "\M-\C-l" gnus-summary-lower-thread
1370 "e" gnus-summary-edit-article
1371 "#" gnus-summary-mark-as-processable
1372 "\M-#" gnus-summary-unmark-as-processable
1373 "\M-\C-t" gnus-summary-toggle-threads
1374 "\M-\C-s" gnus-summary-show-thread
1375 "\M-\C-h" gnus-summary-hide-thread
1376 "\M-\C-f" gnus-summary-next-thread
1377 "\M-\C-b" gnus-summary-prev-thread
1378 [(meta down)] gnus-summary-next-thread
1379 [(meta up)] gnus-summary-prev-thread
1380 "\M-\C-u" gnus-summary-up-thread
1381 "\M-\C-d" gnus-summary-down-thread
1382 "&" gnus-summary-execute-command
1383 "c" gnus-summary-catchup-and-exit
1384 "\C-w" gnus-summary-mark-region-as-read
1385 "\C-t" gnus-summary-toggle-truncation
1386 "?" gnus-summary-mark-as-dormant
1387 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1388 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1389 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1390 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1391 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1392 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1393 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1394 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1395 "=" gnus-summary-expand-window
1396 "\C-x\C-s" gnus-summary-reselect-current-group
1397 "\M-g" gnus-summary-rescan-group
1398 "w" gnus-summary-stop-page-breaking
1399 "\C-c\C-r" gnus-summary-caesar-message
1400 "\M-t" gnus-summary-toggle-mime
1401 "f" gnus-summary-followup
1402 "F" gnus-summary-followup-with-original
1403 "C" gnus-summary-cancel-article
1404 "r" gnus-summary-reply
1405 "R" gnus-summary-reply-with-original
1406 "\C-c\C-f" gnus-summary-mail-forward
1407 "o" gnus-summary-save-article
1408 "\C-o" gnus-summary-save-article-mail
1409 "|" gnus-summary-pipe-output
1410 "\M-k" gnus-summary-edit-local-kill
1411 "\M-K" gnus-summary-edit-global-kill
1413 "\C-c\C-d" gnus-summary-describe-group
1414 "q" gnus-summary-exit
1415 "Q" gnus-summary-exit-no-update
1416 "\C-c\C-i" gnus-info-find-node
1417 gnus-mouse-2 gnus-mouse-pick-article
1418 "m" gnus-summary-mail-other-window
1419 "a" gnus-summary-post-news
1420 "x" gnus-summary-limit-to-unread
1421 "s" gnus-summary-isearch-article
1422 "t" gnus-article-toggle-headers
1423 "g" gnus-summary-show-article
1424 "l" gnus-summary-goto-last-article
1425 "v" gnus-summary-preview-mime-message
1426 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1427 "\C-d" gnus-summary-enter-digest-group
1428 "\M-\C-d" gnus-summary-read-document
1429 "\M-\C-e" gnus-summary-edit-parameters
1430 "\M-\C-a" gnus-summary-customize-parameters
1432 "*" gnus-cache-enter-article
1433 "\M-*" gnus-cache-remove-article
1434 "\M-&" gnus-summary-universal-argument
1435 "\C-l" gnus-recenter
1436 "I" gnus-summary-increase-score
1437 "L" gnus-summary-lower-score
1438 "\M-i" gnus-symbolic-argument
1439 "h" gnus-summary-select-article-buffer
1441 "V" gnus-summary-score-map
1442 "X" gnus-uu-extract-map
1443 "S" gnus-summary-send-map)
1445 ;; Sort of orthogonal keymap
1446 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1447 "t" gnus-summary-tick-article-forward
1448 "!" gnus-summary-tick-article-forward
1449 "d" gnus-summary-mark-as-read-forward
1450 "r" gnus-summary-mark-as-read-forward
1451 "c" gnus-summary-clear-mark-forward
1452 " " gnus-summary-clear-mark-forward
1453 "e" gnus-summary-mark-as-expirable
1454 "x" gnus-summary-mark-as-expirable
1455 "?" gnus-summary-mark-as-dormant
1456 "b" gnus-summary-set-bookmark
1457 "B" gnus-summary-remove-bookmark
1458 "#" gnus-summary-mark-as-processable
1459 "\M-#" gnus-summary-unmark-as-processable
1460 "S" gnus-summary-limit-include-expunged
1461 "C" gnus-summary-catchup
1462 "H" gnus-summary-catchup-to-here
1463 "\C-c" gnus-summary-catchup-all
1464 "k" gnus-summary-kill-same-subject-and-select
1465 "K" gnus-summary-kill-same-subject
1466 "P" gnus-uu-mark-map)
1468 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1469 "c" gnus-summary-clear-above
1470 "u" gnus-summary-tick-above
1471 "m" gnus-summary-mark-above
1472 "k" gnus-summary-kill-below)
1474 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1475 "/" gnus-summary-limit-to-subject
1476 "n" gnus-summary-limit-to-articles
1477 "w" gnus-summary-pop-limit
1478 "s" gnus-summary-limit-to-subject
1479 "a" gnus-summary-limit-to-author
1480 "u" gnus-summary-limit-to-unread
1481 "m" gnus-summary-limit-to-marks
1482 "M" gnus-summary-limit-exclude-marks
1483 "v" gnus-summary-limit-to-score
1484 "*" gnus-summary-limit-include-cached
1485 "D" gnus-summary-limit-include-dormant
1486 "T" gnus-summary-limit-include-thread
1487 "d" gnus-summary-limit-exclude-dormant
1488 "t" gnus-summary-limit-to-age
1489 "x" gnus-summary-limit-to-extra
1490 "E" gnus-summary-limit-include-expunged
1491 "c" gnus-summary-limit-exclude-childless-dormant
1492 "C" gnus-summary-limit-mark-excluded-as-read)
1494 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1495 "n" gnus-summary-next-unread-article
1496 "p" gnus-summary-prev-unread-article
1497 "N" gnus-summary-next-article
1498 "P" gnus-summary-prev-article
1499 "\C-n" gnus-summary-next-same-subject
1500 "\C-p" gnus-summary-prev-same-subject
1501 "\M-n" gnus-summary-next-unread-subject
1502 "\M-p" gnus-summary-prev-unread-subject
1503 "f" gnus-summary-first-unread-article
1504 "b" gnus-summary-best-unread-article
1505 "j" gnus-summary-goto-article
1506 "g" gnus-summary-goto-subject
1507 "l" gnus-summary-goto-last-article
1508 "o" gnus-summary-pop-article)
1510 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1511 "k" gnus-summary-kill-thread
1512 "l" gnus-summary-lower-thread
1513 "i" gnus-summary-raise-thread
1514 "T" gnus-summary-toggle-threads
1515 "t" gnus-summary-rethread-current
1516 "^" gnus-summary-reparent-thread
1517 "s" gnus-summary-show-thread
1518 "S" gnus-summary-show-all-threads
1519 "h" gnus-summary-hide-thread
1520 "H" gnus-summary-hide-all-threads
1521 "n" gnus-summary-next-thread
1522 "p" gnus-summary-prev-thread
1523 "u" gnus-summary-up-thread
1524 "o" gnus-summary-top-thread
1525 "d" gnus-summary-down-thread
1526 "#" gnus-uu-mark-thread
1527 "\M-#" gnus-uu-unmark-thread)
1529 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1530 "g" gnus-summary-prepare
1531 "c" gnus-summary-insert-cached-articles)
1533 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1534 "c" gnus-summary-catchup-and-exit
1535 "C" gnus-summary-catchup-all-and-exit
1536 "E" gnus-summary-exit-no-update
1537 "J" gnus-summary-jump-to-other-group
1538 "Q" gnus-summary-exit
1539 "Z" gnus-summary-exit
1540 "n" gnus-summary-catchup-and-goto-next-group
1541 "R" gnus-summary-reselect-current-group
1542 "G" gnus-summary-rescan-group
1543 "N" gnus-summary-next-group
1544 "s" gnus-summary-save-newsrc
1545 "P" gnus-summary-prev-group)
1547 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1548 " " gnus-summary-next-page
1549 "n" gnus-summary-next-page
1550 "\177" gnus-summary-prev-page
1551 [delete] gnus-summary-prev-page
1552 "p" gnus-summary-prev-page
1553 "\r" gnus-summary-scroll-up
1554 "\M-\r" gnus-summary-scroll-down
1555 "<" gnus-summary-beginning-of-article
1556 ">" gnus-summary-end-of-article
1557 "b" gnus-summary-beginning-of-article
1558 "e" gnus-summary-end-of-article
1559 "^" gnus-summary-refer-parent-article
1560 "r" gnus-summary-refer-parent-article
1561 "D" gnus-summary-enter-digest-group
1562 "R" gnus-summary-refer-references
1563 "T" gnus-summary-refer-thread
1564 "g" gnus-summary-show-article
1565 "s" gnus-summary-isearch-article
1566 "P" gnus-summary-print-article
1567 "M" gnus-mailing-list-insinuate
1568 "t" gnus-article-babel)
1570 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1571 "b" gnus-article-add-buttons
1572 "B" gnus-article-add-buttons-to-head
1573 "o" gnus-article-treat-overstrike
1574 "e" gnus-article-emphasize
1575 "w" gnus-article-fill-cited-article
1576 "Q" gnus-article-fill-long-lines
1577 "C" gnus-article-capitalize-sentences
1578 "c" gnus-article-remove-cr
1579 "Z" gnus-article-decode-HZ
1580 "f" gnus-article-display-x-face
1581 "l" gnus-summary-stop-page-breaking
1582 "r" gnus-summary-caesar-message
1583 "t" gnus-article-toggle-headers
1584 "v" gnus-summary-verbose-headers
1585 "m" gnus-summary-toggle-mime
1586 "H" gnus-article-strip-headers-in-body
1587 "d" gnus-article-treat-dumbquotes
1588 "s" gnus-smiley-display)
1590 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1591 "a" gnus-article-hide
1592 "h" gnus-article-toggle-headers
1593 "b" gnus-article-hide-boring-headers
1594 "s" gnus-article-hide-signature
1595 "c" gnus-article-hide-citation
1596 "C" gnus-article-hide-citation-in-followups
1597 "l" gnus-article-hide-list-identifiers
1598 "p" gnus-article-hide-pgp
1599 "B" gnus-article-strip-banner
1600 "P" gnus-article-hide-pem
1601 "\C-c" gnus-article-hide-citation-maybe)
1603 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1604 "a" gnus-article-highlight
1605 "h" gnus-article-highlight-headers
1606 "c" gnus-article-highlight-citation
1607 "s" gnus-article-highlight-signature)
1609 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1610 "z" gnus-article-date-ut
1611 "u" gnus-article-date-ut
1612 "l" gnus-article-date-local
1613 "e" gnus-article-date-lapsed
1614 "o" gnus-article-date-original
1615 "i" gnus-article-date-iso8601
1616 "s" gnus-article-date-user)
1618 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1619 "t" gnus-article-remove-trailing-blank-lines
1620 "l" gnus-article-strip-leading-blank-lines
1621 "m" gnus-article-strip-multiple-blank-lines
1622 "a" gnus-article-strip-blank-lines
1623 "A" gnus-article-strip-all-blank-lines
1624 "s" gnus-article-strip-leading-space
1625 "e" gnus-article-strip-trailing-space)
1627 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1629 "f" gnus-summary-fetch-faq
1630 "d" gnus-summary-describe-group
1631 "h" gnus-summary-describe-briefly
1632 "i" gnus-info-find-node)
1634 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1635 "e" gnus-summary-expire-articles
1636 "\M-\C-e" gnus-summary-expire-articles-now
1637 "\177" gnus-summary-delete-article
1638 [delete] gnus-summary-delete-article
1639 [backspace] gnus-summary-delete-article
1640 "m" gnus-summary-move-article
1641 "r" gnus-summary-respool-article
1642 "w" gnus-summary-edit-article
1643 "c" gnus-summary-copy-article
1644 "B" gnus-summary-crosspost-article
1645 "q" gnus-summary-respool-query
1646 "t" gnus-summary-respool-trace
1647 "i" gnus-summary-import-article
1648 "p" gnus-summary-article-posted-p)
1650 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1651 "o" gnus-summary-save-article
1652 "m" gnus-summary-save-article-mail
1653 "F" gnus-summary-write-article-file
1654 "r" gnus-summary-save-article-rmail
1655 "f" gnus-summary-save-article-file
1656 "b" gnus-summary-save-article-body-file
1657 "h" gnus-summary-save-article-folder
1658 "v" gnus-summary-save-article-vm
1659 "p" gnus-summary-pipe-output
1660 "s" gnus-soup-add-article)
1662 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1663 "b" gnus-summary-display-buttonized
1664 "m" gnus-summary-repair-multipart
1665 "v" gnus-article-view-part
1666 "o" gnus-article-save-part
1667 "c" gnus-article-copy-part
1668 "e" gnus-article-externalize-part
1669 "i" gnus-article-inline-part
1670 "|" gnus-article-pipe-part))
1672 (defun gnus-summary-make-menu-bar ()
1673 (gnus-turn-off-edit-menu 'summary)
1675 (unless (boundp 'gnus-summary-misc-menu)
1678 gnus-summary-kill-menu gnus-summary-mode-map ""
1683 ["Enter score..." gnus-summary-score-entry t]
1684 ["Customize" gnus-score-customize t])
1685 (gnus-make-score-map 'increase)
1686 (gnus-make-score-map 'lower)
1688 ["Kill below" gnus-summary-kill-below t]
1689 ["Mark above" gnus-summary-mark-above t]
1690 ["Tick above" gnus-summary-tick-above t]
1691 ["Clear above" gnus-summary-clear-above t])
1692 ["Current score" gnus-summary-current-score t]
1693 ["Set score" gnus-summary-set-score t]
1694 ["Switch current score file..." gnus-score-change-score-file t]
1695 ["Set mark below..." gnus-score-set-mark-below t]
1696 ["Set expunge below..." gnus-score-set-expunge-below t]
1697 ["Edit current score file" gnus-score-edit-current-scores t]
1698 ["Edit score file" gnus-score-edit-file t]
1699 ["Trace score" gnus-score-find-trace t]
1700 ["Find words" gnus-score-find-favourite-words t]
1701 ["Rescore buffer" gnus-summary-rescore t]
1702 ["Increase score..." gnus-summary-increase-score t]
1703 ["Lower score..." gnus-summary-lower-score t]))))
1705 ;; Define both the Article menu in the summary buffer and the equivalent
1706 ;; Commands menu in the article buffer here for consistency.
1709 ["All" gnus-article-hide t]
1710 ["Headers" gnus-article-toggle-headers t]
1711 ["Signature" gnus-article-hide-signature t]
1712 ["Citation" gnus-article-hide-citation t]
1713 ["List identifiers" gnus-article-hide-list-identifiers t]
1714 ["PGP" gnus-article-hide-pgp t]
1715 ["Banner" gnus-article-strip-banner t]
1716 ["Boring headers" gnus-article-hide-boring-headers t])
1718 ["All" gnus-article-highlight t]
1719 ["Headers" gnus-article-highlight-headers t]
1720 ["Signature" gnus-article-highlight-signature t]
1721 ["Citation" gnus-article-highlight-citation t])
1723 ["Local" gnus-article-date-local t]
1724 ["ISO8601" gnus-article-date-iso8601 t]
1725 ["UT" gnus-article-date-ut t]
1726 ["Original" gnus-article-date-original t]
1727 ["Lapsed" gnus-article-date-lapsed t]
1728 ["User-defined" gnus-article-date-user t])
1731 ["Leading" gnus-article-strip-leading-blank-lines t]
1732 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1733 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1734 ["All of the above" gnus-article-strip-blank-lines t]
1735 ["All" gnus-article-strip-all-blank-lines t]
1736 ["Leading space" gnus-article-strip-leading-space t]
1737 ["Trailing space" gnus-article-strip-trailing-space t])
1738 ["Overstrike" gnus-article-treat-overstrike t]
1739 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1740 ["Emphasis" gnus-article-emphasize t]
1741 ["Word wrap" gnus-article-fill-cited-article t]
1742 ["Fill long lines" gnus-article-fill-long-lines t]
1743 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1744 ["CR" gnus-article-remove-cr t]
1745 ["Show X-Face" gnus-article-display-x-face t]
1746 ["Rot 13" gnus-summary-caesar-message t]
1747 ["Unix pipe" gnus-summary-pipe-message t]
1748 ["Add buttons" gnus-article-add-buttons t]
1749 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1750 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1751 ["Toggle MIME" gnus-summary-toggle-mime t]
1752 ["Verbose header" gnus-summary-verbose-headers t]
1753 ["Toggle header" gnus-summary-toggle-header t]
1754 ["Toggle smileys" gnus-smiley-display t]
1755 ["HZ" gnus-article-decode-HZ t])
1757 ["Save in default format" gnus-summary-save-article t]
1758 ["Save in file" gnus-summary-save-article-file t]
1759 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1760 ["Save in MH folder" gnus-summary-save-article-folder t]
1761 ["Save in VM folder" gnus-summary-save-article-vm t]
1762 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1763 ["Save body in file" gnus-summary-save-article-body-file t]
1764 ["Pipe through a filter" gnus-summary-pipe-output t]
1765 ["Add to SOUP packet" gnus-soup-add-article t]
1766 ["Print" gnus-summary-print-article t])
1768 ["Respool article..." gnus-summary-respool-article t]
1769 ["Move article..." gnus-summary-move-article
1770 (gnus-check-backend-function
1771 'request-move-article gnus-newsgroup-name)]
1772 ["Copy article..." gnus-summary-copy-article t]
1773 ["Crosspost article..." gnus-summary-crosspost-article
1774 (gnus-check-backend-function
1775 'request-replace-article gnus-newsgroup-name)]
1776 ["Import file..." gnus-summary-import-article t]
1777 ["Check if posted" gnus-summary-article-posted-p t]
1778 ["Edit article" gnus-summary-edit-article
1779 (not (gnus-group-read-only-p))]
1780 ["Delete article" gnus-summary-delete-article
1781 (gnus-check-backend-function
1782 'request-expire-articles gnus-newsgroup-name)]
1783 ["Query respool" gnus-summary-respool-query t]
1784 ["Trace respool" gnus-summary-respool-trace t]
1785 ["Delete expirable articles" gnus-summary-expire-articles-now
1786 (gnus-check-backend-function
1787 'request-expire-articles gnus-newsgroup-name)])
1789 ["Uudecode" gnus-uu-decode-uu t]
1790 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1791 ["Unshar" gnus-uu-decode-unshar t]
1792 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1793 ["Save" gnus-uu-decode-save t]
1794 ["Binhex" gnus-uu-decode-binhex t]
1795 ["Postscript" gnus-uu-decode-postscript t])
1797 ["Enter article" gnus-cache-enter-article t]
1798 ["Remove article" gnus-cache-remove-article t])
1799 ["Translate" gnus-article-babel t]
1800 ["Select article buffer" gnus-summary-select-article-buffer t]
1801 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1802 ["Isearch article..." gnus-summary-isearch-article t]
1803 ["Beginning of the article" gnus-summary-beginning-of-article t]
1804 ["End of the article" gnus-summary-end-of-article t]
1805 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1806 ["Fetch referenced articles" gnus-summary-refer-references t]
1807 ["Fetch current thread" gnus-summary-refer-thread t]
1808 ["Fetch article with id..." gnus-summary-refer-article t]
1809 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1810 ["Redisplay" gnus-summary-show-article t])))
1812 gnus-summary-article-menu gnus-summary-mode-map ""
1813 (cons "Article" innards))
1816 gnus-article-commands-menu gnus-article-mode-map ""
1817 (cons "Commands" innards)))
1820 gnus-summary-thread-menu gnus-summary-mode-map ""
1822 ["Toggle threading" gnus-summary-toggle-threads t]
1823 ["Hide threads" gnus-summary-hide-all-threads t]
1824 ["Show threads" gnus-summary-show-all-threads t]
1825 ["Hide thread" gnus-summary-hide-thread t]
1826 ["Show thread" gnus-summary-show-thread t]
1827 ["Go to next thread" gnus-summary-next-thread t]
1828 ["Go to previous thread" gnus-summary-prev-thread t]
1829 ["Go down thread" gnus-summary-down-thread t]
1830 ["Go up thread" gnus-summary-up-thread t]
1831 ["Top of thread" gnus-summary-top-thread t]
1832 ["Mark thread as read" gnus-summary-kill-thread t]
1833 ["Lower thread score" gnus-summary-lower-thread t]
1834 ["Raise thread score" gnus-summary-raise-thread t]
1835 ["Rethread current" gnus-summary-rethread-current t]))
1838 gnus-summary-post-menu gnus-summary-mode-map ""
1840 ["Post an article" gnus-summary-post-news t]
1841 ["Followup" gnus-summary-followup t]
1842 ["Followup and yank" gnus-summary-followup-with-original t]
1843 ["Supersede article" gnus-summary-supersede-article t]
1844 ["Cancel article" gnus-summary-cancel-article t]
1845 ["Reply" gnus-summary-reply t]
1846 ["Reply and yank" gnus-summary-reply-with-original t]
1847 ["Wide reply" gnus-summary-wide-reply t]
1848 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1849 ["Mail forward" gnus-summary-mail-forward t]
1850 ["Post forward" gnus-summary-post-forward t]
1851 ["Digest and mail" gnus-summary-digest-mail-forward t]
1852 ["Digest and post" gnus-summary-digest-post-forward t]
1853 ["Resend message" gnus-summary-resend-message t]
1854 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1855 ["Send a mail" gnus-summary-mail-other-window t]
1856 ["Uuencode and post" gnus-uu-post-news t]
1857 ["Followup via news" gnus-summary-followup-to-mail t]
1858 ["Followup via news and yank"
1859 gnus-summary-followup-to-mail-with-original t]
1861 ;;["Send" gnus-summary-send-draft t]
1862 ;;["Send bounced" gnus-resend-bounced-mail t])
1866 gnus-summary-misc-menu gnus-summary-mode-map ""
1869 ["Mark as read" gnus-summary-mark-as-read-forward t]
1870 ["Mark same subject and select"
1871 gnus-summary-kill-same-subject-and-select t]
1872 ["Mark same subject" gnus-summary-kill-same-subject t]
1873 ["Catchup" gnus-summary-catchup t]
1874 ["Catchup all" gnus-summary-catchup-all t]
1875 ["Catchup to here" gnus-summary-catchup-to-here t]
1876 ["Catchup region" gnus-summary-mark-region-as-read t]
1877 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1879 ["Tick" gnus-summary-tick-article-forward t]
1880 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1881 ["Remove marks" gnus-summary-clear-mark-forward t]
1882 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1883 ["Set bookmark" gnus-summary-set-bookmark t]
1884 ["Remove bookmark" gnus-summary-remove-bookmark t])
1886 ["Marks..." gnus-summary-limit-to-marks t]
1887 ["Subject..." gnus-summary-limit-to-subject t]
1888 ["Author..." gnus-summary-limit-to-author t]
1889 ["Age..." gnus-summary-limit-to-age t]
1890 ["Extra..." gnus-summary-limit-to-extra t]
1891 ["Score" gnus-summary-limit-to-score t]
1892 ["Unread" gnus-summary-limit-to-unread t]
1893 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1894 ["Articles" gnus-summary-limit-to-articles t]
1895 ["Pop limit" gnus-summary-pop-limit t]
1896 ["Show dormant" gnus-summary-limit-include-dormant t]
1897 ["Hide childless dormant"
1898 gnus-summary-limit-exclude-childless-dormant t]
1899 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1900 ["Hide marked" gnus-summary-limit-exclude-marks t]
1901 ["Show expunged" gnus-summary-show-all-expunged t])
1903 ["Set mark" gnus-summary-mark-as-processable t]
1904 ["Remove mark" gnus-summary-unmark-as-processable t]
1905 ["Remove all marks" gnus-summary-unmark-all-processable t]
1906 ["Mark above" gnus-uu-mark-over t]
1907 ["Mark series" gnus-uu-mark-series t]
1908 ["Mark region" gnus-uu-mark-region t]
1909 ["Unmark region" gnus-uu-unmark-region t]
1910 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1911 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1912 ["Mark all" gnus-uu-mark-all t]
1913 ["Mark buffer" gnus-uu-mark-buffer t]
1914 ["Mark sparse" gnus-uu-mark-sparse t]
1915 ["Mark thread" gnus-uu-mark-thread t]
1916 ["Unmark thread" gnus-uu-unmark-thread t]
1917 ("Process Mark Sets"
1918 ["Kill" gnus-summary-kill-process-mark t]
1919 ["Yank" gnus-summary-yank-process-mark
1920 gnus-newsgroup-process-stack]
1921 ["Save" gnus-summary-save-process-mark t]))
1923 ["Page forward" gnus-summary-next-page t]
1924 ["Page backward" gnus-summary-prev-page t]
1925 ["Line forward" gnus-summary-scroll-up t])
1927 ["Next unread article" gnus-summary-next-unread-article t]
1928 ["Previous unread article" gnus-summary-prev-unread-article t]
1929 ["Next article" gnus-summary-next-article t]
1930 ["Previous article" gnus-summary-prev-article t]
1931 ["Next unread subject" gnus-summary-next-unread-subject t]
1932 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1933 ["Next article same subject" gnus-summary-next-same-subject t]
1934 ["Previous article same subject" gnus-summary-prev-same-subject t]
1935 ["First unread article" gnus-summary-first-unread-article t]
1936 ["Best unread article" gnus-summary-best-unread-article t]
1937 ["Go to subject number..." gnus-summary-goto-subject t]
1938 ["Go to article number..." gnus-summary-goto-article t]
1939 ["Go to the last article" gnus-summary-goto-last-article t]
1940 ["Pop article off history" gnus-summary-pop-article t])
1942 ["Sort by number" gnus-summary-sort-by-number t]
1943 ["Sort by author" gnus-summary-sort-by-author t]
1944 ["Sort by subject" gnus-summary-sort-by-subject t]
1945 ["Sort by date" gnus-summary-sort-by-date t]
1946 ["Sort by score" gnus-summary-sort-by-score t]
1947 ["Sort by lines" gnus-summary-sort-by-lines t]
1948 ["Sort by characters" gnus-summary-sort-by-chars t])
1950 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1951 ["Describe group" gnus-summary-describe-group t]
1952 ["Read manual" gnus-info-find-node t])
1954 ["Pick and read" gnus-pick-mode t]
1955 ["Binary" gnus-binary-mode t])
1957 ["Regenerate" gnus-summary-prepare t]
1958 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1959 ["Toggle threading" gnus-summary-toggle-threads t])
1960 ["Filter articles..." gnus-summary-execute-command t]
1961 ["Run command on subjects..." gnus-summary-universal-argument t]
1962 ["Search articles forward..." gnus-summary-search-article-forward t]
1963 ["Search articles backward..." gnus-summary-search-article-backward t]
1964 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1965 ["Expand window" gnus-summary-expand-window t]
1966 ["Expire expirable articles" gnus-summary-expire-articles
1967 (gnus-check-backend-function
1968 'request-expire-articles gnus-newsgroup-name)]
1969 ["Edit local kill file" gnus-summary-edit-local-kill t]
1970 ["Edit main kill file" gnus-summary-edit-global-kill t]
1971 ["Edit group parameters" gnus-summary-edit-parameters t]
1972 ["Customize group parameters" gnus-summary-customize-parameters t]
1973 ["Send a bug report" gnus-bug t]
1975 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1976 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1977 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1978 ["Exit group" gnus-summary-exit t]
1979 ["Exit group without updating" gnus-summary-exit-no-update t]
1980 ["Exit and goto next group" gnus-summary-next-group t]
1981 ["Exit and goto prev group" gnus-summary-prev-group t]
1982 ["Reselect group" gnus-summary-reselect-current-group t]
1983 ["Rescan group" gnus-summary-rescan-group t]
1984 ["Update dribble" gnus-summary-save-newsrc t])))
1986 (gnus-run-hooks 'gnus-summary-menu-hook)))
1988 (defun gnus-score-set-default (var value)
1989 "A version of set that updates the GNU Emacs menu-bar."
1991 ;; It is the message that forces the active status to be updated.
1994 (defun gnus-make-score-map (type)
1995 "Make a summary score map of type TYPE."
1998 (let ((headers '(("author" "from" string)
1999 ("subject" "subject" string)
2000 ("article body" "body" string)
2001 ("article head" "head" string)
2002 ("xref" "xref" string)
2003 ("extra header" "extra" string)
2004 ("lines" "lines" number)
2005 ("followups to author" "followup" string)))
2006 (types '((number ("less than" <)
2009 (string ("substring" s)
2013 (perms '(("temporary" (current-time-string))
2021 (if (eq type 'lower)
2026 (setq header (car headers))
2032 (let ((ts (cdr (assoc (nth 2 header) types)))
2048 'gnus-summary-score-entry
2050 (if (or (string= (nth 1 header)
2052 (string= (nth 1 header)
2055 (list 'gnus-summary-header
2057 (list 'quote (nth 1 (car ts)))
2058 (list 'gnus-score-delta-default
2065 (list (nreverse outp))))
2068 (list (nreverse outt))))
2070 (setq headers (cdr headers)))
2071 (list (nreverse outh))))))))
2075 (defun gnus-summary-mode (&optional group)
2076 "Major mode for reading articles.
2078 All normal editing commands are switched off.
2079 \\<gnus-summary-mode-map>
2080 Each line in this buffer represents one article. To read an
2081 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2082 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2085 You can also post articles and send mail from this buffer. To
2086 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2087 of an article, type `\\[gnus-summary-reply]'.
2089 There are approx. one gazillion commands you can execute in this
2090 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2092 The following commands are available:
2094 \\{gnus-summary-mode-map}"
2096 (when (gnus-visual-p 'summary-menu 'menu)
2097 (gnus-summary-make-menu-bar))
2098 (kill-all-local-variables)
2099 (gnus-summary-make-local-variables)
2100 (gnus-make-thread-indent-array)
2101 (gnus-simplify-mode-line)
2102 (setq major-mode 'gnus-summary-mode)
2103 (setq mode-name "Summary")
2104 (make-local-variable 'minor-mode-alist)
2105 (use-local-map gnus-summary-mode-map)
2106 (buffer-disable-undo)
2107 (setq buffer-read-only t) ;Disable modification
2108 (setq truncate-lines t)
2109 (setq selective-display t)
2110 (setq selective-display-ellipses t) ;Display `...'
2111 (gnus-summary-set-display-table)
2112 (gnus-set-default-directory)
2113 (setq gnus-newsgroup-name group)
2114 (unless (gnus-news-group-p group)
2115 (setq gnus-newsgroup-incorporated
2116 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2117 (make-local-variable 'gnus-summary-line-format)
2118 (make-local-variable 'gnus-summary-line-format-spec)
2119 (make-local-variable 'gnus-summary-dummy-line-format)
2120 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2121 (make-local-variable 'gnus-summary-mark-positions)
2122 (make-local-hook 'pre-command-hook)
2123 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2124 (gnus-run-hooks 'gnus-summary-mode-hook)
2125 (turn-on-gnus-mailing-list-mode)
2126 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2127 (gnus-update-summary-mark-positions))
2129 (defun gnus-summary-make-local-variables ()
2130 "Make all the local summary buffer variables."
2132 (dolist (local gnus-summary-local-variables)
2135 (if (eq (cdr local) 'global)
2136 ;; Copy the global value of the variable.
2137 (setq global (symbol-value (car local)))
2138 ;; Use the value from the list.
2139 (setq global (eval (cdr local))))
2140 (set (make-local-variable (car local)) global))
2141 ;; Simple nil-valued local variable.
2142 (set (make-local-variable local) nil)))))
2144 (defun gnus-summary-clear-local-variables ()
2145 (let ((locals gnus-summary-local-variables))
2147 (if (consp (car locals))
2148 (and (vectorp (caar locals))
2149 (set (caar locals) nil))
2150 (and (vectorp (car locals))
2151 (set (car locals) nil)))
2152 (setq locals (cdr locals)))))
2154 ;; Summary data functions.
2156 (defmacro gnus-data-number (data)
2159 (defmacro gnus-data-set-number (data number)
2160 `(setcar ,data ,number))
2162 (defmacro gnus-data-mark (data)
2165 (defmacro gnus-data-set-mark (data mark)
2166 `(setcar (nthcdr 1 ,data) ,mark))
2168 (defmacro gnus-data-pos (data)
2171 (defmacro gnus-data-set-pos (data pos)
2172 `(setcar (nthcdr 2 ,data) ,pos))
2174 (defmacro gnus-data-header (data)
2177 (defmacro gnus-data-set-header (data header)
2178 `(setcar (nthcdr 3 ,data) ,header))
2180 (defmacro gnus-data-level (data)
2183 (defmacro gnus-data-unread-p (data)
2184 `(= (nth 1 ,data) gnus-unread-mark))
2186 (defmacro gnus-data-read-p (data)
2187 `(/= (nth 1 ,data) gnus-unread-mark))
2189 (defmacro gnus-data-pseudo-p (data)
2190 `(consp (nth 3 ,data)))
2192 (defmacro gnus-data-find (number)
2193 `(assq ,number gnus-newsgroup-data))
2195 (defmacro gnus-data-find-list (number &optional data)
2196 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2197 (memq (assq ,number bdata)
2200 (defmacro gnus-data-make (number mark pos header level)
2201 `(list ,number ,mark ,pos ,header ,level))
2203 (defun gnus-data-enter (after-article number mark pos header level offset)
2204 (let ((data (gnus-data-find-list after-article)))
2206 (error "No such article: %d" after-article))
2207 (setcdr data (cons (gnus-data-make number mark pos header level)
2209 (setq gnus-newsgroup-data-reverse nil)
2210 (gnus-data-update-list (cddr data) offset)))
2212 (defun gnus-data-enter-list (after-article list &optional offset)
2214 (let ((data (and after-article (gnus-data-find-list after-article)))
2218 (let ((odata gnus-newsgroup-data))
2219 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2221 (gnus-data-update-list odata offset)))
2222 ;; Find the last element in the list to be spliced into the main
2225 (setq list (cdr list)))
2228 (setcdr list gnus-newsgroup-data)
2229 (setq gnus-newsgroup-data ilist)
2231 (gnus-data-update-list (cdr list) offset)))
2232 (setcdr list (cdr data))
2235 (gnus-data-update-list (cdr list) offset))))
2236 (setq gnus-newsgroup-data-reverse nil))))
2238 (defun gnus-data-remove (article &optional offset)
2239 (let ((data gnus-newsgroup-data))
2240 (if (= (gnus-data-number (car data)) article)
2242 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2243 gnus-newsgroup-data-reverse nil)
2245 (gnus-data-update-list gnus-newsgroup-data offset)))
2247 (when (= (gnus-data-number (cadr data)) article)
2248 (setcdr data (cddr data))
2250 (gnus-data-update-list (cdr data) offset))
2252 gnus-newsgroup-data-reverse nil))
2253 (setq data (cdr data))))))
2255 (defmacro gnus-data-list (backward)
2257 (or gnus-newsgroup-data-reverse
2258 (setq gnus-newsgroup-data-reverse
2259 (reverse gnus-newsgroup-data)))
2260 gnus-newsgroup-data))
2262 (defun gnus-data-update-list (data offset)
2263 "Add OFFSET to the POS of all data entries in DATA."
2264 (setq gnus-newsgroup-data-reverse nil)
2266 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2267 (setq data (cdr data))))
2269 (defun gnus-summary-article-pseudo-p (article)
2270 "Say whether this article is a pseudo article or not."
2271 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2273 (defmacro gnus-summary-article-sparse-p (article)
2274 "Say whether this article is a sparse article or not."
2275 `(memq ,article gnus-newsgroup-sparse))
2277 (defmacro gnus-summary-article-ancient-p (article)
2278 "Say whether this article is a sparse article or not."
2279 `(memq ,article gnus-newsgroup-ancient))
2281 (defun gnus-article-parent-p (number)
2282 "Say whether this article is a parent or not."
2283 (let ((data (gnus-data-find-list number)))
2284 (and (cdr data) ; There has to be an article after...
2285 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2286 (gnus-data-level (nth 1 data))))))
2288 (defun gnus-article-children (number)
2289 "Return a list of all children to NUMBER."
2290 (let* ((data (gnus-data-find-list number))
2291 (level (gnus-data-level (car data)))
2293 (setq data (cdr data))
2295 (= (gnus-data-level (car data)) (1+ level)))
2296 (push (gnus-data-number (car data)) children)
2297 (setq data (cdr data)))
2300 (defmacro gnus-summary-skip-intangible ()
2301 "If the current article is intangible, then jump to a different article."
2302 '(let ((to (get-text-property (point) 'gnus-intangible)))
2303 (and to (gnus-summary-goto-subject to))))
2305 (defmacro gnus-summary-article-intangible-p ()
2306 "Say whether this article is intangible or not."
2307 '(get-text-property (point) 'gnus-intangible))
2309 (defun gnus-article-read-p (article)
2310 "Say whether ARTICLE is read or not."
2311 (not (or (memq article gnus-newsgroup-marked)
2312 (memq article gnus-newsgroup-unreads)
2313 (memq article gnus-newsgroup-unselected)
2314 (memq article gnus-newsgroup-dormant))))
2316 ;; Some summary mode macros.
2318 (defmacro gnus-summary-article-number ()
2319 "The article number of the article on the current line.
2320 If there isn's an article number here, then we return the current
2323 (gnus-summary-skip-intangible)
2324 (or (get-text-property (point) 'gnus-number)
2325 (gnus-summary-last-subject))))
2327 (defmacro gnus-summary-article-header (&optional number)
2328 "Return the header of article NUMBER."
2329 `(gnus-data-header (gnus-data-find
2330 ,(or number '(gnus-summary-article-number)))))
2332 (defmacro gnus-summary-thread-level (&optional number)
2333 "Return the level of thread that starts with article NUMBER."
2334 `(if (and (eq gnus-summary-make-false-root 'dummy)
2335 (get-text-property (point) 'gnus-intangible))
2337 (gnus-data-level (gnus-data-find
2338 ,(or number '(gnus-summary-article-number))))))
2340 (defmacro gnus-summary-article-mark (&optional number)
2341 "Return the mark of article NUMBER."
2342 `(gnus-data-mark (gnus-data-find
2343 ,(or number '(gnus-summary-article-number)))))
2345 (defmacro gnus-summary-article-pos (&optional number)
2346 "Return the position of the line of article NUMBER."
2347 `(gnus-data-pos (gnus-data-find
2348 ,(or number '(gnus-summary-article-number)))))
2350 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2351 (defmacro gnus-summary-article-subject (&optional number)
2352 "Return current subject string or nil if nothing."
2355 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2356 '(gnus-data-header (assq (gnus-summary-article-number)
2357 gnus-newsgroup-data)))))
2360 (mail-header-subject headers))))
2362 (defmacro gnus-summary-article-score (&optional number)
2363 "Return current article score."
2364 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2365 gnus-newsgroup-scored))
2366 gnus-summary-default-score 0))
2368 (defun gnus-summary-article-children (&optional number)
2369 "Return a list of article numbers that are children of article NUMBER."
2370 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2371 (level (gnus-data-level (car data)))
2373 (while (and (setq data (cdr data))
2374 (> (setq l (gnus-data-level (car data))) level))
2375 (and (= (1+ level) l)
2376 (push (gnus-data-number (car data))
2378 (nreverse children)))
2380 (defun gnus-summary-article-parent (&optional number)
2381 "Return the article number of the parent of article NUMBER."
2382 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2383 (gnus-data-list t)))
2384 (level (gnus-data-level (car data))))
2386 () ; This is a root.
2387 ;; We search until we find an article with a level less than
2388 ;; this one. That function has to be the parent.
2389 (while (and (setq data (cdr data))
2390 (not (< (gnus-data-level (car data)) level))))
2391 (and data (gnus-data-number (car data))))))
2393 (defun gnus-unread-mark-p (mark)
2394 "Say whether MARK is the unread mark."
2395 (= mark gnus-unread-mark))
2397 (defun gnus-read-mark-p (mark)
2398 "Say whether MARK is one of the marks that mark as read.
2399 This is all marks except unread, ticked, dormant, and expirable."
2400 (not (or (= mark gnus-unread-mark)
2401 (= mark gnus-ticked-mark)
2402 (= mark gnus-dormant-mark)
2403 (= mark gnus-expirable-mark))))
2405 (defmacro gnus-article-mark (number)
2406 "Return the MARK of article NUMBER.
2407 This macro should only be used when computing the mark the \"first\"
2408 time; i.e., when generating the summary lines. After that,
2409 `gnus-summary-article-mark' should be used to examine the
2412 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2413 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2414 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2415 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2416 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2417 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2418 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2419 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2420 gnus-ancient-mark))))
2422 ;; Saving hidden threads.
2424 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2425 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2427 (defmacro gnus-save-hidden-threads (&rest forms)
2428 "Save hidden threads, eval FORMS, and restore the hidden threads."
2429 (let ((config (make-symbol "config")))
2430 `(let ((,config (gnus-hidden-threads-configuration)))
2434 (gnus-restore-hidden-threads-configuration ,config)))))
2436 (defun gnus-data-compute-positions ()
2437 "Compute the positions of all articles."
2438 (setq gnus-newsgroup-data-reverse nil)
2439 (let ((data gnus-newsgroup-data))
2441 (gnus-save-hidden-threads
2442 (gnus-summary-show-all-threads)
2443 (goto-char (point-min))
2445 (while (get-text-property (point) 'gnus-intangible)
2447 (gnus-data-set-pos (car data) (+ (point) 3))
2448 (setq data (cdr data))
2449 (forward-line 1))))))
2451 (defun gnus-hidden-threads-configuration ()
2452 "Return the current hidden threads configuration."
2455 (goto-char (point-min))
2456 (while (search-forward "\r" nil t)
2457 (push (1- (point)) config))
2460 (defun gnus-restore-hidden-threads-configuration (config)
2461 "Restore hidden threads configuration from CONFIG."
2463 (let (point buffer-read-only)
2464 (while (setq point (pop config))
2465 (when (and (< point (point-max))
2467 (eq (char-after) ?\n))
2468 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2470 ;; Various summary mode internalish functions.
2472 (defun gnus-mouse-pick-article (e)
2475 (gnus-summary-next-page nil t))
2477 (defun gnus-summary-set-display-table ()
2478 "Change the display table.
2479 Odd characters have a tendency to mess
2480 up nicely formatted displays - we make all possible glyphs
2481 display only a single character."
2483 ;; We start from the standard display table, if any.
2484 (let ((table (or (copy-sequence standard-display-table)
2485 (make-display-table)))
2487 ;; Nix out all the control chars...
2488 (while (>= (setq i (1- i)) 0)
2489 (aset table i [??]))
2490 ;; ... but not newline and cr, of course. (cr is necessary for the
2491 ;; selective display).
2492 (aset table ?\n nil)
2493 (aset table ?\r nil)
2494 ;; We keep TAB as well.
2495 (aset table ?\t nil)
2496 ;; We nix out any glyphs over 126 that are not set already.
2498 (while (>= (setq i (1- i)) 127)
2499 ;; Only modify if the entry is nil.
2500 (unless (aref table i)
2501 (aset table i [??]))))
2502 (setq buffer-display-table table)))
2504 (defun gnus-summary-setup-buffer (group)
2505 "Initialize summary buffer."
2506 (let ((buffer (concat "*Summary " group "*")))
2507 (if (get-buffer buffer)
2510 (setq gnus-summary-buffer (current-buffer))
2511 (not gnus-newsgroup-prepared))
2512 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2513 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2514 (gnus-summary-mode group)
2516 (gnus-carpal-setup-buffer 'summary))
2517 (unless gnus-single-article-buffer
2518 (make-local-variable 'gnus-article-buffer)
2519 (make-local-variable 'gnus-article-current)
2520 (make-local-variable 'gnus-original-article-buffer))
2521 (setq gnus-newsgroup-name group)
2524 (defun gnus-set-global-variables ()
2525 "Set the global equivalents of the buffer-local variables.
2526 They are set to the latest values they had. These reflect the summary
2527 buffer that was in action when the last article was fetched."
2528 (when (eq major-mode 'gnus-summary-mode)
2529 (setq gnus-summary-buffer (current-buffer))
2530 (let ((name gnus-newsgroup-name)
2531 (marked gnus-newsgroup-marked)
2532 (unread gnus-newsgroup-unreads)
2533 (headers gnus-current-headers)
2534 (data gnus-newsgroup-data)
2535 (summary gnus-summary-buffer)
2536 (article-buffer gnus-article-buffer)
2537 (original gnus-original-article-buffer)
2538 (gac gnus-article-current)
2539 (reffed gnus-reffed-article-number)
2540 (score-file gnus-current-score-file)
2541 (default-charset gnus-newsgroup-charset))
2543 (set-buffer gnus-group-buffer)
2544 (setq gnus-newsgroup-name name
2545 gnus-newsgroup-marked marked
2546 gnus-newsgroup-unreads unread
2547 gnus-current-headers headers
2548 gnus-newsgroup-data data
2549 gnus-article-current gac
2550 gnus-summary-buffer summary
2551 gnus-article-buffer article-buffer
2552 gnus-original-article-buffer original
2553 gnus-reffed-article-number reffed
2554 gnus-current-score-file score-file
2555 gnus-newsgroup-charset default-charset)
2556 ;; The article buffer also has local variables.
2557 (when (gnus-buffer-live-p gnus-article-buffer)
2558 (set-buffer gnus-article-buffer)
2559 (setq gnus-summary-buffer summary))))))
2561 (defun gnus-summary-article-unread-p (article)
2562 "Say whether ARTICLE is unread or not."
2563 (memq article gnus-newsgroup-unreads))
2565 (defun gnus-summary-first-article-p (&optional article)
2566 "Return whether ARTICLE is the first article in the buffer."
2567 (if (not (setq article (or article (gnus-summary-article-number))))
2569 (eq article (caar gnus-newsgroup-data))))
2571 (defun gnus-summary-last-article-p (&optional article)
2572 "Return whether ARTICLE is the last article in the buffer."
2573 (if (not (setq article (or article (gnus-summary-article-number))))
2574 ;; All non-existent numbers are the last article. :-)
2576 (not (cdr (gnus-data-find-list article)))))
2578 (defun gnus-make-thread-indent-array ()
2580 (unless (and gnus-thread-indent-array
2581 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2582 (setq gnus-thread-indent-array (make-vector 201 "")
2583 gnus-thread-indent-array-level gnus-thread-indent-level)
2585 (aset gnus-thread-indent-array n
2586 (make-string (* n gnus-thread-indent-level) ? ))
2589 (defun gnus-update-summary-mark-positions ()
2590 "Compute where the summary marks are to go."
2592 (when (gnus-buffer-exists-p gnus-summary-buffer)
2593 (set-buffer gnus-summary-buffer))
2594 (let ((gnus-replied-mark 129)
2595 (gnus-score-below-mark 130)
2596 (gnus-score-over-mark 130)
2597 (gnus-download-mark 131)
2598 (spec gnus-summary-line-format-spec)
2601 (gnus-set-work-buffer)
2602 (let ((gnus-summary-line-format-spec spec)
2603 (gnus-newsgroup-downloadable '((0 . t))))
2604 (gnus-summary-insert-line
2605 (make-full-mail-header 0 "" "nobody" "" "" "" 0 0 "" nil)
2606 0 nil 128 t nil "" nil 1)
2607 (goto-char (point-min))
2608 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2610 (goto-char (point-min))
2611 (push (cons 'replied (and (search-forward "\201" nil t)
2614 (goto-char (point-min))
2615 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2617 (goto-char (point-min))
2618 (push (cons 'download
2619 (and (search-forward "\203" nil t) (- (point) 2)))
2621 (setq gnus-summary-mark-positions pos))))
2623 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2624 "Insert a dummy root in the summary buffer."
2626 (gnus-add-text-properties
2627 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2628 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2630 (defun gnus-summary-from-or-to-or-newsgroups (header)
2631 (let ((to (cdr (assq 'To (mail-header-extra header))))
2632 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2633 (default-mime-charset (with-current-buffer gnus-summary-buffer
2634 default-mime-charset)))
2637 gnus-ignored-from-addresses
2638 (string-match gnus-ignored-from-addresses
2639 (mail-header-from header)))
2641 (or (car (funcall gnus-extract-address-components
2643 gnus-decode-encoded-word-function to)))
2644 (funcall gnus-decode-encoded-word-function to))))
2646 gnus-ignored-from-addresses
2647 (string-match gnus-ignored-from-addresses
2648 (mail-header-from header)))
2649 (concat "=> " newsgroups))
2651 (or (car (funcall gnus-extract-address-components
2652 (mail-header-from header)))
2653 (mail-header-from header))))))
2655 (defun gnus-summary-insert-line (gnus-tmp-header
2656 gnus-tmp-level gnus-tmp-current
2657 gnus-tmp-unread gnus-tmp-replied
2658 gnus-tmp-expirable gnus-tmp-subject-or-nil
2659 &optional gnus-tmp-dummy gnus-tmp-score
2661 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2662 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2663 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2664 (gnus-tmp-score-char
2665 (if (or (null gnus-summary-default-score)
2666 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2667 gnus-summary-zcore-fuzz))
2669 (if (< gnus-tmp-score gnus-summary-default-score)
2670 gnus-score-below-mark gnus-score-over-mark)))
2672 (cond (gnus-tmp-process gnus-process-mark)
2673 ((memq gnus-tmp-current gnus-newsgroup-cached)
2675 (gnus-tmp-replied gnus-replied-mark)
2676 ((memq gnus-tmp-current gnus-newsgroup-saved)
2678 (t gnus-unread-mark)))
2679 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2682 ((string-match "<[^>]+> *$" gnus-tmp-from)
2683 (let ((beg (match-beginning 0)))
2684 (or (and (string-match "^\".+\"" gnus-tmp-from)
2685 (substring gnus-tmp-from 1 (1- (match-end 0))))
2686 (substring gnus-tmp-from 0 beg))))
2687 ((string-match "(.+)" gnus-tmp-from)
2688 (substring gnus-tmp-from
2689 (1+ (match-beginning 0)) (1- (match-end 0))))
2691 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2692 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2693 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2694 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2695 (buffer-read-only nil))
2696 (when (string= gnus-tmp-name "")
2697 (setq gnus-tmp-name gnus-tmp-from))
2698 (unless (numberp gnus-tmp-lines)
2699 (setq gnus-tmp-lines 0))
2700 (gnus-put-text-property-excluding-characters-with-faces
2702 (progn (eval gnus-summary-line-format-spec) (point))
2703 'gnus-number gnus-tmp-number)
2704 (when (gnus-visual-p 'summary-highlight 'highlight)
2706 (gnus-run-hooks 'gnus-summary-update-hook)
2709 (defun gnus-summary-update-line (&optional dont-update)
2710 "Update summary line after change."
2711 (when (and gnus-summary-default-score
2712 (not gnus-summary-inhibit-highlight))
2713 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2714 (article (gnus-summary-article-number))
2715 (score (gnus-summary-article-score article)))
2717 (if (and gnus-summary-mark-below
2718 (< (gnus-summary-article-score)
2719 gnus-summary-mark-below))
2720 ;; This article has a low score, so we mark it as read.
2721 (when (memq article gnus-newsgroup-unreads)
2722 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2723 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2724 ;; This article was previously marked as read on account
2725 ;; of a low score, but now it has risen, so we mark it as
2727 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2728 (gnus-summary-update-mark
2729 (if (or (null gnus-summary-default-score)
2730 (<= (abs (- score gnus-summary-default-score))
2731 gnus-summary-zcore-fuzz))
2733 (if (< score gnus-summary-default-score)
2734 gnus-score-below-mark gnus-score-over-mark))
2736 ;; Do visual highlighting.
2737 (when (gnus-visual-p 'summary-highlight 'highlight)
2738 (gnus-run-hooks 'gnus-summary-update-hook)))))
2740 (defvar gnus-tmp-new-adopts nil)
2742 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2743 "Return the number of articles in THREAD.
2744 This may be 0 in some cases -- if none of the articles in
2745 the thread are to be displayed."
2747 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2749 ((not (listp thread))
2751 ((and (consp thread) (cdr thread))
2754 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2757 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2760 (when (and level (zerop level) gnus-tmp-new-adopts)
2763 'gnus-summary-number-of-articles-in-thread
2764 gnus-tmp-new-adopts))))
2766 (if (> number 1) gnus-not-empty-thread-mark
2767 gnus-empty-thread-mark)
2770 (defun gnus-summary-set-local-parameters (group)
2771 "Go through the local params of GROUP and set all variable specs in that list."
2772 (let ((params (gnus-group-find-parameter group))
2775 (setq elem (car params)
2776 params (cdr params))
2777 (and (consp elem) ; Has to be a cons.
2778 (consp (cdr elem)) ; The cdr has to be a list.
2779 (symbolp (car elem)) ; Has to be a symbol in there.
2780 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2781 (ignore-errors ; So we set it.
2782 (make-local-variable (car elem))
2783 (set (car elem) (eval (nth 1 elem))))))))
2785 (defun gnus-summary-read-group (group &optional show-all no-article
2786 kill-buffer no-display backward
2788 "Start reading news in newsgroup GROUP.
2789 If SHOW-ALL is non-nil, already read articles are also listed.
2790 If NO-ARTICLE is non-nil, no article is selected initially.
2791 If NO-DISPLAY, don't generate a summary buffer."
2795 (let ((gnus-auto-select-next nil))
2796 (or (gnus-summary-read-group-1
2797 group show-all no-article
2798 kill-buffer no-display
2801 select-articles nil)))))
2802 (eq gnus-auto-select-next 'quietly))
2803 (set-buffer gnus-group-buffer)
2804 ;; The entry function called above goes to the next
2805 ;; group automatically, so we go two groups back
2806 ;; if we are searching for the previous group.
2808 (gnus-group-prev-unread-group 2))
2809 (if (not (equal group (gnus-group-group-name)))
2810 (setq group (gnus-group-group-name))
2814 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2815 "Directly jump to the other GROUP from summary buffer.
2816 If SHOW-ALL is non-nil, already read articles are also listed."
2818 (if (eq gnus-summary-buffer (current-buffer))
2819 (list (completing-read
2820 "Group: " gnus-active-hashtb nil t
2821 (when (and gnus-newsgroup-name
2822 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2823 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2824 'gnus-group-history)
2826 (error "%s must be invoked from a gnus summary buffer." this-command)))
2827 (unless (or (zerop (length group))
2828 (and gnus-newsgroup-name
2829 (string-equal gnus-newsgroup-name group)))
2831 (gnus-summary-read-group group show-all
2832 gnus-dont-select-after-jump-to-other-group)))
2834 (defun gnus-summary-read-group-1 (group show-all no-article
2835 kill-buffer no-display
2836 &optional select-articles)
2837 ;; Killed foreign groups can't be entered.
2838 (when (and (not (gnus-group-native-p group))
2839 (not (gnus-gethash group gnus-newsrc-hashtb)))
2840 (error "Dead non-native groups can't be entered"))
2841 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2842 (let* ((new-group (gnus-summary-setup-buffer group))
2843 (quit-config (gnus-group-quit-config group))
2844 (did-select (and new-group (gnus-select-newsgroup
2845 group show-all select-articles))))
2847 ;; This summary buffer exists already, so we just select it.
2849 (gnus-set-global-variables)
2851 (gnus-kill-or-deaden-summary kill-buffer))
2852 (gnus-configure-windows 'summary 'force)
2853 (gnus-set-mode-line 'summary)
2854 (gnus-summary-position-point)
2857 ;; We couldn't select this group.
2859 (when (and (eq major-mode 'gnus-summary-mode)
2860 (not (equal (current-buffer) kill-buffer)))
2861 (kill-buffer (current-buffer))
2862 (if (not quit-config)
2864 ;; Update the info -- marks might need to be removed,
2866 (gnus-summary-update-info)
2867 (set-buffer gnus-group-buffer)
2868 (gnus-group-jump-to-group group)
2869 (gnus-group-next-unread-group 1))
2870 (gnus-handle-ephemeral-exit quit-config)))
2871 (gnus-message 3 "Can't select group")
2873 ;; The user did a `C-g' while prompting for number of articles,
2874 ;; so we exit this group.
2875 ((eq did-select 'quit)
2876 (and (eq major-mode 'gnus-summary-mode)
2877 (not (equal (current-buffer) kill-buffer))
2878 (kill-buffer (current-buffer)))
2880 (gnus-kill-or-deaden-summary kill-buffer))
2881 (if (not quit-config)
2883 (set-buffer gnus-group-buffer)
2884 (gnus-group-jump-to-group group)
2885 (gnus-group-next-unread-group 1)
2886 (gnus-configure-windows 'group 'force))
2887 (gnus-handle-ephemeral-exit quit-config))
2888 ;; Finally signal the quit.
2890 ;; The group was successfully selected.
2892 (gnus-set-global-variables)
2893 ;; Save the active value in effect when the group was entered.
2894 (setq gnus-newsgroup-active
2896 (gnus-active gnus-newsgroup-name)))
2897 ;; You can change the summary buffer in some way with this hook.
2898 (gnus-run-hooks 'gnus-select-group-hook)
2899 ;; Set any local variables in the group parameters.
2900 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2901 (gnus-update-format-specifications
2902 nil 'summary 'summary-mode 'summary-dummy)
2903 (gnus-update-summary-mark-positions)
2904 ;; Do score processing.
2905 (when gnus-use-scoring
2906 (gnus-possibly-score-headers))
2907 ;; Check whether to fill in the gaps in the threads.
2908 (when gnus-build-sparse-threads
2909 (gnus-build-sparse-threads))
2910 ;; Find the initial limit.
2911 (if gnus-show-threads
2913 (let ((gnus-newsgroup-dormant nil))
2914 (gnus-summary-initial-limit show-all))
2915 (gnus-summary-initial-limit show-all))
2916 ;; When untreaded, all articles are always shown.
2917 (setq gnus-newsgroup-limit
2919 (lambda (header) (mail-header-number header))
2920 gnus-newsgroup-headers)))
2921 ;; Generate the summary buffer.
2923 (gnus-summary-prepare))
2924 (when gnus-use-trees
2925 (gnus-tree-open group)
2926 (setq gnus-summary-highlight-line-function
2927 'gnus-tree-highlight-article))
2928 ;; If the summary buffer is empty, but there are some low-scored
2929 ;; articles or some excluded dormants, we include these in the
2931 (when (and (zerop (buffer-size))
2933 (cond (gnus-newsgroup-dormant
2934 (gnus-summary-limit-include-dormant))
2935 ((and gnus-newsgroup-scored show-all)
2936 (gnus-summary-limit-include-expunged t))))
2937 ;; Function `gnus-apply-kill-file' must be called in this hook.
2938 (gnus-run-hooks 'gnus-apply-kill-hook)
2939 (if (and (zerop (buffer-size))
2942 ;; This newsgroup is empty.
2943 (gnus-summary-catchup-and-exit nil t)
2944 (gnus-message 6 "No unread news")
2946 (gnus-kill-or-deaden-summary kill-buffer))
2947 ;; Return nil from this function.
2949 ;; Hide conversation thread subtrees. We cannot do this in
2950 ;; gnus-summary-prepare-hook since kill processing may not
2951 ;; work with hidden articles.
2952 (and gnus-show-threads
2953 gnus-thread-hide-subtree
2954 (gnus-summary-hide-all-threads))
2956 (gnus-kill-or-deaden-summary kill-buffer))
2957 ;; Show first unread article if requested.
2958 (if (and (not no-article)
2960 gnus-newsgroup-unreads
2961 gnus-auto-select-first)
2963 (gnus-configure-windows 'summary)
2965 ((eq gnus-auto-select-first 'best)
2966 (gnus-summary-best-unread-article))
2967 ((eq gnus-auto-select-first t)
2968 (gnus-summary-first-unread-article))
2969 ((gnus-functionp gnus-auto-select-first)
2970 (funcall gnus-auto-select-first))))
2971 ;; Don't select any articles, just move point to the first
2972 ;; article in the group.
2973 (goto-char (point-min))
2974 (gnus-summary-position-point)
2975 (gnus-configure-windows 'summary 'force)
2976 (gnus-set-mode-line 'summary))
2977 (when (get-buffer-window gnus-group-buffer t)
2978 ;; Gotta use windows, because recenter does weird stuff if
2979 ;; the current buffer ain't the displayed window.
2980 (let ((owin (selected-window)))
2981 (select-window (get-buffer-window gnus-group-buffer t))
2982 (when (gnus-group-goto-group group)
2984 (select-window owin)))
2985 ;; Mark this buffer as "prepared".
2986 (setq gnus-newsgroup-prepared t)
2987 (gnus-run-hooks 'gnus-summary-prepared-hook)
2990 (defun gnus-summary-prepare ()
2991 "Generate the summary buffer."
2993 (let ((buffer-read-only nil))
2995 (setq gnus-newsgroup-data nil
2996 gnus-newsgroup-data-reverse nil)
2997 (gnus-run-hooks 'gnus-summary-generate-hook)
2998 ;; Generate the buffer, either with threads or without.
2999 (when gnus-newsgroup-headers
3000 (gnus-summary-prepare-threads
3001 (if gnus-show-threads
3002 (gnus-sort-gathered-threads
3003 (funcall gnus-summary-thread-gathering-function
3005 (gnus-cut-threads (gnus-make-threads)))))
3006 ;; Unthreaded display.
3007 (gnus-sort-articles gnus-newsgroup-headers))))
3008 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3009 ;; Call hooks for modifying summary buffer.
3010 (goto-char (point-min))
3011 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3013 (defsubst gnus-general-simplify-subject (subject)
3014 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3017 ;; Truncate the subject.
3018 (gnus-simplify-subject-functions
3019 (gnus-map-function gnus-simplify-subject-functions subject))
3020 ((numberp gnus-summary-gather-subject-limit)
3021 (setq subject (gnus-simplify-subject-re subject))
3022 (if (> (length subject) gnus-summary-gather-subject-limit)
3023 (substring subject 0 gnus-summary-gather-subject-limit)
3025 ;; Fuzzily simplify it.
3026 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3027 (gnus-simplify-subject-fuzzy subject))
3028 ;; Just remove the leading "Re:".
3030 (gnus-simplify-subject-re subject))))
3032 (if (and gnus-summary-gather-exclude-subject
3033 (string-match gnus-summary-gather-exclude-subject subject))
3034 nil ; This article shouldn't be gathered
3037 (defun gnus-summary-simplify-subject-query ()
3038 "Query where the respool algorithm would put this article."
3040 (gnus-summary-select-article)
3042 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3044 (defun gnus-gather-threads-by-subject (threads)
3045 "Gather threads by looking at Subject headers."
3046 (if (not gnus-summary-make-false-root)
3048 (let ((hashtb (gnus-make-hashtable 1024))
3051 subject hthread whole-subject)
3053 (setq subject (gnus-general-simplify-subject
3054 (setq whole-subject (mail-header-subject
3057 (if (setq hthread (gnus-gethash subject hashtb))
3059 ;; We enter a dummy root into the thread, if we
3060 ;; haven't done that already.
3061 (unless (stringp (caar hthread))
3062 (setcar hthread (list whole-subject (car hthread))))
3063 ;; We add this new gathered thread to this gathered
3065 (setcdr (car hthread)
3066 (nconc (cdar hthread) (list (car threads))))
3067 ;; Remove it from the list of threads.
3068 (setcdr prev (cdr threads))
3069 (setq threads prev))
3070 ;; Enter this thread into the hash table.
3071 (gnus-sethash subject threads hashtb)))
3073 (setq threads (cdr threads)))
3076 (defun gnus-gather-threads-by-references (threads)
3077 "Gather threads by looking at References headers."
3078 (let ((idhashtb (gnus-make-hashtable 1024))
3079 (thhashtb (gnus-make-hashtable 1024))
3082 ids references id gthread gid entered ref)
3084 (when (setq references (mail-header-references (caar threads)))
3085 (setq id (mail-header-id (caar threads))
3086 ids (gnus-split-references references)
3088 (while (setq ref (pop ids))
3089 (setq ids (delete ref ids))
3090 (if (not (setq gid (gnus-gethash ref idhashtb)))
3092 (gnus-sethash ref id idhashtb)
3093 (gnus-sethash id threads thhashtb))
3094 (setq gthread (gnus-gethash gid thhashtb))
3096 ;; We enter a dummy root into the thread, if we
3097 ;; haven't done that already.
3098 (unless (stringp (caar gthread))
3099 (setcar gthread (list (mail-header-subject (caar gthread))
3101 ;; We add this new gathered thread to this gathered
3103 (setcdr (car gthread)
3104 (nconc (cdar gthread) (list (car threads)))))
3105 ;; Add it into the thread hash table.
3106 (gnus-sethash id gthread thhashtb)
3108 ;; Remove it from the list of threads.
3109 (setcdr prev (cdr threads))
3110 (setq threads prev))))
3112 (setq threads (cdr threads)))
3115 (defun gnus-sort-gathered-threads (threads)
3116 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3117 (let ((result threads))
3119 (when (stringp (caar threads))
3120 (setcdr (car threads)
3121 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3122 (setq threads (cdr threads)))
3125 (defun gnus-thread-loop-p (root thread)
3126 "Say whether ROOT is in THREAD."
3127 (let ((stack (list thread))
3130 (while (setq thread (pop stack))
3131 (setq th (cdr thread))
3133 (not (eq (caar th) root)))
3136 ;; We have found a loop.
3138 (setcdr thread (delq (car th) (cdr thread)))
3139 (if (boundp (setq ref-dep (intern "none"
3140 gnus-newsgroup-dependencies)))
3141 (setcdr (symbol-value ref-dep)
3142 (nconc (cdr (symbol-value ref-dep))
3144 (set ref-dep (list nil (car th))))
3147 ;; Push all the subthreads onto the stack.
3148 (push (cdr thread) stack)))
3151 (defun gnus-make-threads ()
3152 "Go through the dependency hashtb and find the roots. Return all threads."
3154 (while (catch 'infloop
3157 ;; Deal with self-referencing References loops.
3158 (when (and (car (symbol-value refs))
3165 (car (symbol-value refs)) thread))
3166 (cdr (symbol-value refs)))))))
3169 (unless (car (symbol-value refs))
3170 ;; These threads do not refer back to any other articles,
3171 ;; so they're roots.
3172 (setq threads (append (cdr (symbol-value refs)) threads))))
3173 gnus-newsgroup-dependencies)))
3176 ;; Build the thread tree.
3177 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3178 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3180 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3181 if it was already present.
3183 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3184 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3185 Message-IDs will be renamed be renamed to a unique Message-ID before
3188 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3189 (let* ((id (mail-header-id header))
3190 (id-dep (and id (intern id dependencies)))
3191 ref ref-dep ref-header)
3192 ;; Enter this `header' in the `dependencies' table.
3196 ;; The first two cases do the normal part: enter a new `header'
3197 ;; in the `dependencies' table.
3198 ((not (boundp id-dep))
3199 (set id-dep (list header)))
3200 ((null (car (symbol-value id-dep)))
3201 (setcar (symbol-value id-dep) header))
3203 ;; From here the `header' was already present in the
3204 ;; `dependencies' table.
3206 ;; Overrides an existing entry;
3207 ;; just set the header part of the entry.
3208 (setcar (symbol-value id-dep) header))
3210 ;; Renames the existing `header' to a unique Message-ID.
3211 ((not gnus-summary-ignore-duplicates)
3212 ;; An article with this Message-ID has already been seen.
3213 ;; We rename the Message-ID.
3214 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3216 (mail-header-set-id header id))
3218 ;; The last case ignores an existing entry, except it adds any
3219 ;; additional Xrefs (in case the two articles came from different
3221 ;; Also sets `header' to `nil' meaning that the `dependencies'
3222 ;; table was *not* modified.
3224 (mail-header-set-xref
3225 (car (symbol-value id-dep))
3226 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3228 (or (mail-header-xref header) "")))
3232 ;; First check if that we are not creating a References loop.
3233 (setq ref (gnus-parent-id (mail-header-references header)))
3235 (setq ref-dep (intern-soft ref dependencies))
3237 (setq ref-header (car (symbol-value ref-dep))))
3238 (if (string= id ref)
3239 ;; Yuk! This is a reference loop. Make the article be a
3242 (mail-header-set-references (car (symbol-value id-dep)) "none")
3244 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3245 (setq ref (gnus-parent-id (mail-header-references header)))
3246 (setq ref-dep (intern (or ref "none") dependencies))
3247 (if (boundp ref-dep)
3248 (setcdr (symbol-value ref-dep)
3249 (nconc (cdr (symbol-value ref-dep))
3250 (list (symbol-value id-dep))))
3251 (set ref-dep (list nil (symbol-value id-dep)))))
3254 (defun gnus-build-sparse-threads ()
3255 (let ((headers gnus-newsgroup-headers)
3256 (mail-parse-charset gnus-newsgroup-charset)
3257 (gnus-summary-ignore-duplicates t)
3258 header references generation relations
3259 subject child end new-child date)
3260 ;; First we create an alist of generations/relations, where
3261 ;; generations is how much we trust the relation, and the relation
3263 (gnus-message 7 "Making sparse threads...")
3265 (nnheader-set-temp-buffer " *gnus sparse threads*")
3266 (while (setq header (pop headers))
3267 (when (and (setq references (mail-header-references header))
3268 (not (string= references "")))
3270 (setq child (mail-header-id header)
3271 subject (mail-header-subject header)
3272 date (mail-header-date header)
3274 (while (search-backward ">" nil t)
3275 (setq end (1+ (point)))
3276 (when (search-backward "<" nil t)
3277 (setq new-child (buffer-substring (point) end))
3278 (push (list (incf generation)
3279 child (setq child new-child)
3283 (push (list (1+ generation) child nil subject) relations))
3285 (kill-buffer (current-buffer)))
3286 ;; Sort over trustworthiness.
3289 (when (gnus-dependencies-add-header
3290 (make-full-mail-header-from-decoded-header
3291 gnus-reffed-article-number
3292 (nth 3 relation) "" (or (nth 4 relation) "")
3294 (or (nth 2 relation) "") 0 0 "")
3295 gnus-newsgroup-dependencies nil)
3296 (push gnus-reffed-article-number gnus-newsgroup-limit)
3297 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3298 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3299 gnus-newsgroup-reads)
3300 (decf gnus-reffed-article-number)))
3301 (sort relations 'car-less-than-car))
3302 (gnus-message 7 "Making sparse threads...done")))
3304 (defun gnus-build-old-threads ()
3305 ;; Look at all the articles that refer back to old articles, and
3306 ;; fetch the headers for the articles that aren't there. This will
3307 ;; build complete threads - if the roots haven't been expired by the
3309 (let ((mail-parse-charset gnus-newsgroup-charset)
3313 (when (not (car (symbol-value refs)))
3314 (setq heads (cdr (symbol-value refs)))
3316 (if (memq (mail-header-number (caar heads))
3317 gnus-newsgroup-dormant)
3318 (setq heads (cdr heads))
3319 (setq id (symbol-name refs))
3320 (while (and (setq id (gnus-build-get-header id))
3321 (not (car (gnus-id-to-thread id)))))
3322 (setq heads nil)))))
3323 gnus-newsgroup-dependencies)))
3325 ;; This function has to be called with point after the article number
3326 ;; on the beginning of the line.
3327 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3328 (let ((eol (gnus-point-at-eol))
3329 (buffer (current-buffer))
3332 ;; overview: [num subject from date id refs chars lines misc]
3335 (narrow-to-region (point) eol)
3340 (make-full-mail-header
3342 (nnheader-nov-field) ; subject
3343 (nnheader-nov-field) ; from
3344 (nnheader-nov-field) ; date
3345 (nnheader-nov-read-message-id) ; id
3346 (nnheader-nov-field) ; refs
3347 (nnheader-nov-read-integer) ; chars
3348 (nnheader-nov-read-integer) ; lines
3350 (if (looking-at "Xref: ")
3351 (goto-char (match-end 0)))
3352 (nnheader-nov-field)) ; Xref
3353 (nnheader-nov-parse-extra)))) ; extra
3357 (when gnus-alter-header-function
3358 (funcall gnus-alter-header-function header))
3359 (gnus-dependencies-add-header header dependencies force-new)))
3361 (defun gnus-build-get-header (id)
3362 "Look through the buffer of NOV lines and find the header to ID.
3363 Enter this line into the dependencies hash table, and return
3364 the id of the parent article (if any)."
3365 (let ((deps gnus-newsgroup-dependencies)
3369 (set-buffer nntp-server-buffer)
3370 (let ((case-fold-search nil))
3371 (goto-char (point-min))
3372 (while (and (not found)
3373 (search-forward id nil t))
3375 (setq found (looking-at
3376 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3377 (regexp-quote id))))
3378 (or found (beginning-of-line 2)))
3382 (setq header (gnus-nov-parse-line
3383 (read (current-buffer)) deps))
3384 (gnus-parent-id (mail-header-references header))))))
3386 (let ((number (mail-header-number header)))
3387 (push number gnus-newsgroup-limit)
3388 (push header gnus-newsgroup-headers)
3389 (if (memq number gnus-newsgroup-unselected)
3391 (push number gnus-newsgroup-unreads)
3392 (setq gnus-newsgroup-unselected
3393 (delq number gnus-newsgroup-unselected)))
3394 (push number gnus-newsgroup-ancient)))))))
3396 (defun gnus-build-all-threads ()
3397 "Read all the headers."
3398 (let ((gnus-summary-ignore-duplicates t)
3399 (mail-parse-charset gnus-newsgroup-charset)
3400 (dependencies gnus-newsgroup-dependencies)
3403 (set-buffer nntp-server-buffer)
3404 (let ((case-fold-search nil))
3405 (goto-char (point-min))
3408 (setq article (read (current-buffer))
3409 header (gnus-nov-parse-line article dependencies)))
3412 (set-buffer gnus-summary-buffer)
3413 (push header gnus-newsgroup-headers)
3414 (if (memq (setq article (mail-header-number header))
3415 gnus-newsgroup-unselected)
3417 (push article gnus-newsgroup-unreads)
3418 (setq gnus-newsgroup-unselected
3419 (delq article gnus-newsgroup-unselected)))
3420 (push article gnus-newsgroup-ancient)))
3421 (forward-line 1)))))))
3423 (defun gnus-summary-update-article-line (article header)
3424 "Update the line for ARTICLE using HEADERS."
3425 (let* ((id (mail-header-id header))
3426 (thread (gnus-id-to-thread id)))
3428 (error "Article in no thread"))
3429 ;; Update the thread.
3430 (setcar thread header)
3431 (gnus-summary-goto-subject article)
3432 (let* ((datal (gnus-data-find-list article))
3434 (length (when (cdr datal)
3435 (- (gnus-data-pos data)
3436 (gnus-data-pos (cadr datal)))))
3437 (buffer-read-only nil)
3438 (level (gnus-summary-thread-level)))
3440 (gnus-summary-insert-line
3441 header level nil (gnus-article-mark article)
3442 (memq article gnus-newsgroup-replied)
3443 (memq article gnus-newsgroup-expirable)
3444 ;; Only insert the Subject string when it's different
3445 ;; from the previous Subject string.
3450 (mail-header-subject
3453 (gnus-data-find-list
3455 (gnus-data-list t)))))
3456 ;; Error on the side of excessive subjects.
3458 (mail-header-subject header)))
3460 (mail-header-subject header))
3461 nil (cdr (assq article gnus-newsgroup-scored))
3462 (memq article gnus-newsgroup-processable))
3464 (gnus-data-update-list
3465 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3467 (defun gnus-summary-update-article (article &optional iheader)
3468 "Update ARTICLE in the summary buffer."
3469 (set-buffer gnus-summary-buffer)
3470 (let* ((header (gnus-summary-article-header article))
3471 (id (mail-header-id header))
3472 (data (gnus-data-find article))
3473 (thread (gnus-id-to-thread id))
3474 (references (mail-header-references header))
3478 (when (and references
3479 (not (equal "" references)))
3482 (buffer-read-only nil)
3488 (delq thread parent)))
3489 (if (gnus-summary-insert-subject id header)
3490 ;; Set the (possibly) new article number in the data structure.
3491 (gnus-data-set-number data (gnus-id-to-article id))
3495 (defun gnus-rebuild-thread (id &optional line)
3496 "Rebuild the thread containing ID.
3497 If LINE, insert the rebuilt thread starting on line LINE."
3498 (let ((buffer-read-only nil)
3499 old-pos current thread data)
3500 (if (not gnus-show-threads)
3501 (setq thread (list (car (gnus-id-to-thread id))))
3502 ;; Get the thread this article is part of.
3503 (setq thread (gnus-remove-thread id)))
3504 (setq old-pos (gnus-point-at-bol))
3505 (setq current (save-excursion
3506 (and (zerop (forward-line -1))
3507 (gnus-summary-article-number))))
3508 ;; If this is a gathered thread, we have to go some re-gathering.
3509 (when (stringp (car thread))
3510 (let ((subject (car thread))
3512 (setq thread (cdr thread))
3514 (unless (memq (setq thr (gnus-id-to-thread
3516 (mail-header-id (caar thread)))))
3519 (setq thread (cdr thread)))
3520 ;; We now have all (unique) roots.
3521 (if (= (length roots) 1)
3522 ;; All the loose roots are now one solid root.
3523 (setq thread (car roots))
3524 (setq thread (cons subject (gnus-sort-threads roots))))))
3526 ;; We then insert this thread into the summary buffer.
3528 (goto-char (point-min))
3529 (forward-line (1- line)))
3530 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3531 (if gnus-show-threads
3532 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3533 (gnus-summary-prepare-unthreaded thread))
3534 (setq data (nreverse gnus-newsgroup-data))
3535 (setq threads gnus-newsgroup-threads))
3536 ;; We splice the new data into the data structure.
3537 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3538 ;;!!! then we want to insert at the beginning of the buffer.
3539 ;;!!! That happens to be true with Gnus now, but that may
3540 ;;!!! change in the future. Perhaps.
3541 (gnus-data-enter-list
3542 (if line nil current) data (- (point) old-pos))
3543 (setq gnus-newsgroup-threads
3544 (nconc threads gnus-newsgroup-threads))
3545 (gnus-data-compute-positions))))
3547 (defun gnus-number-to-header (number)
3548 "Return the header for article NUMBER."
3549 (let ((headers gnus-newsgroup-headers))
3551 (not (= number (mail-header-number (car headers)))))
3556 (defun gnus-parent-headers (in-headers &optional generation)
3557 "Return the headers of the GENERATIONeth parent of HEADERS."
3559 (setq generation 1))
3561 (headers in-headers)
3564 (not (zerop generation))
3565 (setq references (mail-header-references headers)))
3566 (setq headers (if (and references
3567 (setq parent (gnus-parent-id references)))
3568 (car (gnus-id-to-thread parent))
3571 (and (not (eq headers in-headers))
3574 (defun gnus-id-to-thread (id)
3575 "Return the (sub-)thread where ID appears."
3576 (gnus-gethash id gnus-newsgroup-dependencies))
3578 (defun gnus-id-to-article (id)
3579 "Return the article number of ID."
3580 (let ((thread (gnus-id-to-thread id)))
3583 (mail-header-number (car thread)))))
3585 (defun gnus-id-to-header (id)
3586 "Return the article headers of ID."
3587 (car (gnus-id-to-thread id)))
3589 (defun gnus-article-displayed-root-p (article)
3590 "Say whether ARTICLE is a root(ish) article."
3591 (let ((level (gnus-summary-thread-level article))
3592 (refs (mail-header-references (gnus-summary-article-header article)))
3598 ((null (gnus-parent-id refs)) t)
3600 (null (setq particle (gnus-id-to-article
3601 (gnus-parent-id refs))))
3602 (null (gnus-summary-thread-level particle)))))))
3604 (defun gnus-root-id (id)
3605 "Return the id of the root of the thread where ID appears."
3607 (while (and id (setq prev (car (gnus-id-to-thread id))))
3609 id (gnus-parent-id (mail-header-references prev))))
3612 (defun gnus-articles-in-thread (thread)
3613 "Return the list of articles in THREAD."
3614 (cons (mail-header-number (car thread))
3615 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3617 (defun gnus-remove-thread (id &optional dont-remove)
3618 "Remove the thread that has ID in it."
3619 (let (headers thread last-id)
3620 ;; First go up in this thread until we find the root.
3621 (setq last-id (gnus-root-id id)
3622 headers (message-flatten-list (gnus-id-to-thread last-id)))
3623 ;; We have now found the real root of this thread. It might have
3624 ;; been gathered into some loose thread, so we have to search
3625 ;; through the threads to find the thread we wanted.
3626 (let ((threads gnus-newsgroup-threads)
3629 (setq sub (car threads))
3630 (if (stringp (car sub))
3631 ;; This is a gathered thread, so we look at the roots
3632 ;; below it to find whether this article is in this
3635 (setq sub (cdr sub))
3637 (when (member (caar sub) headers)
3638 (setq thread (car threads)
3641 (setq sub (cdr sub))))
3642 ;; It's an ordinary thread, so we check it.
3643 (when (eq (car sub) (car headers))
3646 (setq threads (cdr threads)))
3647 ;; If this article is in no thread, then it's a root.
3650 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3651 (setq thread (gnus-id-to-thread last-id)))
3654 thread ; We return this thread.
3656 (if (stringp (car thread))
3658 ;; If we use dummy roots, then we have to remove the
3659 ;; dummy root as well.
3660 (when (eq gnus-summary-make-false-root 'dummy)
3661 ;; We go to the dummy root by going to
3662 ;; the first sub-"thread", and then one line up.
3663 (gnus-summary-goto-article
3664 (mail-header-number (caadr thread)))
3667 (gnus-data-compute-positions))
3668 (setq thread (cdr thread))
3670 (gnus-remove-thread-1 (car thread))
3671 (setq thread (cdr thread))))
3672 (gnus-remove-thread-1 thread))))))))
3674 (defun gnus-remove-thread-1 (thread)
3675 "Remove the thread THREAD recursively."
3676 (let ((number (mail-header-number (pop thread)))
3678 (setq thread (reverse thread))
3680 (gnus-remove-thread-1 (pop thread)))
3681 (when (setq d (gnus-data-find number))
3682 (goto-char (gnus-data-pos d))
3683 (gnus-summary-show-thread)
3686 (- (gnus-point-at-bol)
3688 (1+ (gnus-point-at-eol))
3689 (gnus-delete-line)))))))
3691 (defun gnus-sort-threads-1 (threads func)
3692 (sort (mapcar (lambda (thread)
3695 (gnus-sort-threads-1 (cdr thread) func))))
3698 (defun gnus-sort-threads (threads)
3700 (if (not gnus-thread-sort-functions)
3702 (gnus-message 8 "Sorting threads...")
3704 (gnus-sort-threads-1
3706 (gnus-make-sort-function gnus-thread-sort-functions))
3707 (gnus-message 8 "Sorting threads...done"))))
3709 (defun gnus-sort-articles (articles)
3711 (when gnus-article-sort-functions
3712 (gnus-message 7 "Sorting articles...")
3714 (setq gnus-newsgroup-headers
3715 (sort articles (gnus-make-sort-function
3716 gnus-article-sort-functions)))
3717 (gnus-message 7 "Sorting articles...done"))))
3719 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3720 (defmacro gnus-thread-header (thread)
3721 "Return header of first article in THREAD.
3722 Note that THREAD must never, ever be anything else than a variable -
3723 using some other form will lead to serious barfage."
3724 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3725 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3726 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3729 (defsubst gnus-article-sort-by-number (h1 h2)
3730 "Sort articles by article number."
3731 (< (mail-header-number h1)
3732 (mail-header-number h2)))
3734 (defun gnus-thread-sort-by-number (h1 h2)
3735 "Sort threads by root article number."
3736 (gnus-article-sort-by-number
3737 (gnus-thread-header h1) (gnus-thread-header h2)))
3739 (defsubst gnus-article-sort-by-lines (h1 h2)
3740 "Sort articles by article Lines header."
3741 (< (mail-header-lines h1)
3742 (mail-header-lines h2)))
3744 (defun gnus-thread-sort-by-lines (h1 h2)
3745 "Sort threads by root article Lines header."
3746 (gnus-article-sort-by-lines
3747 (gnus-thread-header h1) (gnus-thread-header h2)))
3749 (defsubst gnus-article-sort-by-chars (h1 h2)
3750 "Sort articles by octet length."
3751 (< (mail-header-chars h1)
3752 (mail-header-chars h2)))
3754 (defun gnus-thread-sort-by-chars (h1 h2)
3755 "Sort threads by root article octet length."
3756 (gnus-article-sort-by-chars
3757 (gnus-thread-header h1) (gnus-thread-header h2)))
3759 (defsubst gnus-article-sort-by-author (h1 h2)
3760 "Sort articles by root author."
3762 (let ((addr (car (mime-entity-read-field h1 'From))))
3763 (or (std11-full-name-string addr)
3764 (std11-address-string addr)
3766 (let ((addr (car (mime-entity-read-field h2 'From))))
3767 (or (std11-full-name-string addr)
3768 (std11-address-string addr)
3772 (defun gnus-thread-sort-by-author (h1 h2)
3773 "Sort threads by root author."
3774 (gnus-article-sort-by-author
3775 (gnus-thread-header h1) (gnus-thread-header h2)))
3777 (defsubst gnus-article-sort-by-subject (h1 h2)
3778 "Sort articles by root subject."
3780 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3781 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3783 (defun gnus-thread-sort-by-subject (h1 h2)
3784 "Sort threads by root subject."
3785 (gnus-article-sort-by-subject
3786 (gnus-thread-header h1) (gnus-thread-header h2)))
3788 (defsubst gnus-article-sort-by-date (h1 h2)
3789 "Sort articles by root article date."
3791 (gnus-date-get-time (mail-header-date h1))
3792 (gnus-date-get-time (mail-header-date h2))))
3794 (defun gnus-thread-sort-by-date (h1 h2)
3795 "Sort threads by root article date."
3796 (gnus-article-sort-by-date
3797 (gnus-thread-header h1) (gnus-thread-header h2)))
3799 (defsubst gnus-article-sort-by-score (h1 h2)
3800 "Sort articles by root article score.
3801 Unscored articles will be counted as having a score of zero."
3802 (> (or (cdr (assq (mail-header-number h1)
3803 gnus-newsgroup-scored))
3804 gnus-summary-default-score 0)
3805 (or (cdr (assq (mail-header-number h2)
3806 gnus-newsgroup-scored))
3807 gnus-summary-default-score 0)))
3809 (defun gnus-thread-sort-by-score (h1 h2)
3810 "Sort threads by root article score."
3811 (gnus-article-sort-by-score
3812 (gnus-thread-header h1) (gnus-thread-header h2)))
3814 (defun gnus-thread-sort-by-total-score (h1 h2)
3815 "Sort threads by the sum of all scores in the thread.
3816 Unscored articles will be counted as having a score of zero."
3817 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3819 (defun gnus-thread-total-score (thread)
3820 ;; This function find the total score of THREAD.
3821 (cond ((null thread)
3824 (if (stringp (car thread))
3825 (apply gnus-thread-score-function 0
3826 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3827 (gnus-thread-total-score-1 thread)))
3829 (gnus-thread-total-score-1 (list thread)))))
3831 (defun gnus-thread-total-score-1 (root)
3832 ;; This function find the total score of the thread below ROOT.
3833 (setq root (car root))
3834 (apply gnus-thread-score-function
3836 (mapcar 'gnus-thread-total-score
3837 (cdr (gnus-id-to-thread (mail-header-id root))))
3838 (when (> (mail-header-number root) 0)
3839 (list (or (cdr (assq (mail-header-number root)
3840 gnus-newsgroup-scored))
3841 gnus-summary-default-score 0))))
3842 (list gnus-summary-default-score)
3845 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3846 (defvar gnus-tmp-prev-subject nil)
3847 (defvar gnus-tmp-false-parent nil)
3848 (defvar gnus-tmp-root-expunged nil)
3849 (defvar gnus-tmp-dummy-line nil)
3851 (defvar gnus-tmp-header)
3852 (defun gnus-extra-header (type &optional header)
3853 "Return the extra header of TYPE."
3854 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3857 (defun gnus-summary-prepare-threads (threads)
3858 "Prepare summary buffer from THREADS and indentation LEVEL.
3859 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3860 or a straight list of headers."
3861 (gnus-message 7 "Generating summary...")
3863 (setq gnus-newsgroup-threads threads)
3866 (let ((gnus-tmp-level 0)
3867 (default-score (or gnus-summary-default-score 0))
3868 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3869 thread number subject stack state gnus-tmp-gathered beg-match
3870 new-roots gnus-tmp-new-adopts thread-end
3871 gnus-tmp-header gnus-tmp-unread
3872 gnus-tmp-replied gnus-tmp-subject-or-nil
3873 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3874 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3875 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3877 (setq gnus-tmp-prev-subject nil)
3879 (if (vectorp (car threads))
3880 ;; If this is a straight (sic) list of headers, then a
3881 ;; threaded summary display isn't required, so we just create
3882 ;; an unthreaded one.
3883 (gnus-summary-prepare-unthreaded threads)
3885 ;; Do the threaded display.
3887 (while (or threads stack gnus-tmp-new-adopts new-roots)
3889 (if (and (= gnus-tmp-level 0)
3892 (not gnus-tmp-false-parent)
3893 (or gnus-tmp-new-adopts new-roots))
3894 (if gnus-tmp-new-adopts
3895 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3896 thread (list (car gnus-tmp-new-adopts))
3897 gnus-tmp-header (caar thread)
3898 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3900 (setq thread (list (car new-roots))
3901 gnus-tmp-header (caar thread)
3902 new-roots (cdr new-roots))))
3905 ;; If there are some threads, we do them before the
3906 ;; threads on the stack.
3907 (setq thread threads
3908 gnus-tmp-header (caar thread))
3909 ;; There were no current threads, so we pop something off
3911 (setq state (car stack)
3912 gnus-tmp-level (car state)
3915 gnus-tmp-header (caar thread))))
3917 (setq gnus-tmp-false-parent nil)
3918 (setq gnus-tmp-root-expunged nil)
3919 (setq thread-end nil)
3921 (if (stringp gnus-tmp-header)
3922 ;; The header is a dummy root.
3924 ((eq gnus-summary-make-false-root 'adopt)
3925 ;; We let the first article adopt the rest.
3926 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3928 (setq gnus-tmp-gathered
3930 (lambda (h) (mail-header-number (car h)))
3933 (setq thread (cons (list (caar thread)
3936 (setq gnus-tmp-level -1
3937 gnus-tmp-false-parent t))
3938 ((eq gnus-summary-make-false-root 'empty)
3939 ;; We print adopted articles with empty subject fields.
3940 (setq gnus-tmp-gathered
3942 (lambda (h) (mail-header-number (car h)))
3945 (setq gnus-tmp-level -1))
3946 ((eq gnus-summary-make-false-root 'dummy)
3947 ;; We remember that we probably want to output a dummy
3949 (setq gnus-tmp-dummy-line gnus-tmp-header)
3950 (setq gnus-tmp-prev-subject gnus-tmp-header))
3952 ;; We do not make a root for the gathered
3953 ;; sub-threads at all.
3954 (setq gnus-tmp-level -1)))
3956 (setq number (mail-header-number gnus-tmp-header)
3957 subject (mail-header-subject gnus-tmp-header))
3960 ;; If the thread has changed subject, we might want to make
3961 ;; this subthread into a root.
3962 ((and (null gnus-thread-ignore-subject)
3963 (not (zerop gnus-tmp-level))
3964 gnus-tmp-prev-subject
3966 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3967 (setq new-roots (nconc new-roots (list (car thread)))
3969 gnus-tmp-header nil))
3970 ;; If the article lies outside the current limit,
3971 ;; then we do not display it.
3972 ((not (memq number gnus-newsgroup-limit))
3973 (setq gnus-tmp-gathered
3975 (lambda (h) (mail-header-number (car h)))
3978 (setq gnus-tmp-new-adopts (if (cdar thread)
3979 (append gnus-tmp-new-adopts
3981 gnus-tmp-new-adopts)
3983 gnus-tmp-header nil)
3984 (when (zerop gnus-tmp-level)
3985 (setq gnus-tmp-root-expunged t)))
3986 ;; Perhaps this article is to be marked as read?
3987 ((and gnus-summary-mark-below
3988 (< (or (cdr (assq number gnus-newsgroup-scored))
3990 gnus-summary-mark-below)
3991 ;; Don't touch sparse articles.
3992 (not (gnus-summary-article-sparse-p number))
3993 (not (gnus-summary-article-ancient-p number)))
3994 (setq gnus-newsgroup-unreads
3995 (delq number gnus-newsgroup-unreads))
3996 (if gnus-newsgroup-auto-expire
3997 (push number gnus-newsgroup-expirable)
3998 (push (cons number gnus-low-score-mark)
3999 gnus-newsgroup-reads))))
4001 (when gnus-tmp-header
4002 ;; We may have an old dummy line to output before this
4004 (when (and gnus-tmp-dummy-line
4007 (mail-header-subject gnus-tmp-header)))
4008 (gnus-summary-insert-dummy-line
4009 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4010 (setq gnus-tmp-dummy-line nil))
4012 ;; Compute the mark.
4013 (setq gnus-tmp-unread (gnus-article-mark number))
4015 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4016 gnus-tmp-header gnus-tmp-level)
4017 gnus-newsgroup-data)
4019 ;; Actually insert the line.
4021 gnus-tmp-subject-or-nil
4023 ((and gnus-thread-ignore-subject
4024 gnus-tmp-prev-subject
4025 (not (inline (gnus-subject-equal
4026 gnus-tmp-prev-subject subject))))
4028 ((zerop gnus-tmp-level)
4029 (if (and (eq gnus-summary-make-false-root 'empty)
4030 (memq number gnus-tmp-gathered)
4031 gnus-tmp-prev-subject
4032 (inline (gnus-subject-equal
4033 gnus-tmp-prev-subject subject)))
4034 gnus-summary-same-subject
4036 (t gnus-summary-same-subject)))
4037 (if (and (eq gnus-summary-make-false-root 'adopt)
4038 (= gnus-tmp-level 1)
4039 (memq number gnus-tmp-gathered))
4040 (setq gnus-tmp-opening-bracket ?\<
4041 gnus-tmp-closing-bracket ?\>)
4042 (setq gnus-tmp-opening-bracket ?\[
4043 gnus-tmp-closing-bracket ?\]))
4045 gnus-tmp-indentation
4046 (aref gnus-thread-indent-array gnus-tmp-level)
4047 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4048 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4049 gnus-summary-default-score 0)
4051 (if (or (null gnus-summary-default-score)
4052 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4053 gnus-summary-zcore-fuzz))
4055 (if (< gnus-tmp-score gnus-summary-default-score)
4056 gnus-score-below-mark gnus-score-over-mark))
4058 (cond ((memq number gnus-newsgroup-processable)
4060 ((memq number gnus-newsgroup-cached)
4062 ((memq number gnus-newsgroup-replied)
4064 ((memq number gnus-newsgroup-saved)
4066 (t gnus-unread-mark))
4067 gnus-tmp-from (mail-header-from gnus-tmp-header)
4070 ((string-match "<[^>]+> *$" gnus-tmp-from)
4071 (setq beg-match (match-beginning 0))
4072 (or (and (string-match "^\".+\"" gnus-tmp-from)
4073 (substring gnus-tmp-from 1 (1- (match-end 0))))
4074 (substring gnus-tmp-from 0 beg-match)))
4075 ((string-match "(.+)" gnus-tmp-from)
4076 (substring gnus-tmp-from
4077 (1+ (match-beginning 0)) (1- (match-end 0))))
4079 (when (string= gnus-tmp-name "")
4080 (setq gnus-tmp-name gnus-tmp-from))
4081 (unless (numberp gnus-tmp-lines)
4082 (setq gnus-tmp-lines 0))
4083 (gnus-put-text-property
4085 (progn (eval gnus-summary-line-format-spec) (point))
4086 'gnus-number number)
4089 (gnus-run-hooks 'gnus-summary-update-hook)
4092 (setq gnus-tmp-prev-subject subject)))
4094 (when (nth 1 thread)
4095 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4096 (incf gnus-tmp-level)
4097 (setq threads (if thread-end nil (cdar thread)))
4099 (setq gnus-tmp-level 0)))))
4100 (gnus-message 7 "Generating summary...done"))
4102 (defun gnus-summary-prepare-unthreaded (headers)
4103 "Generate an unthreaded summary buffer based on HEADERS."
4104 (let (header number mark)
4109 ;; We may have to root out some bad articles...
4110 (when (memq (setq number (mail-header-number
4111 (setq header (pop headers))))
4112 gnus-newsgroup-limit)
4113 ;; Mark article as read when it has a low score.
4114 (when (and gnus-summary-mark-below
4115 (< (or (cdr (assq number gnus-newsgroup-scored))
4116 gnus-summary-default-score 0)
4117 gnus-summary-mark-below)
4118 (not (gnus-summary-article-ancient-p number)))
4119 (setq gnus-newsgroup-unreads
4120 (delq number gnus-newsgroup-unreads))
4121 (if gnus-newsgroup-auto-expire
4122 (push number gnus-newsgroup-expirable)
4123 (push (cons number gnus-low-score-mark)
4124 gnus-newsgroup-reads)))
4126 (setq mark (gnus-article-mark number))
4127 (push (gnus-data-make number mark (1+ (point)) header 0)
4128 gnus-newsgroup-data)
4129 (gnus-summary-insert-line
4131 mark (memq number gnus-newsgroup-replied)
4132 (memq number gnus-newsgroup-expirable)
4133 (mail-header-subject header) nil
4134 (cdr (assq number gnus-newsgroup-scored))
4135 (memq number gnus-newsgroup-processable))))))
4137 (defun gnus-summary-remove-list-identifiers ()
4138 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4139 (let ((regexp (if (stringp gnus-list-identifiers)
4140 gnus-list-identifiers
4141 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4142 (dolist (header gnus-newsgroup-headers)
4143 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4144 " *\\)\\)+\\(Re: +\\)?\\)")
4145 (mail-header-subject header))
4146 (mail-header-set-subject
4147 header (concat (substring (mail-header-subject header)
4148 0 (match-beginning 1))
4150 (match-string 3 (mail-header-subject header))
4151 (match-string 5 (mail-header-subject header)))
4152 (substring (mail-header-subject header)
4153 (match-end 1))))))))
4155 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4156 "Select newsgroup GROUP.
4157 If READ-ALL is non-nil, all articles in the group are selected.
4158 If SELECT-ARTICLES, only select those articles from GROUP."
4159 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4160 ;;!!! Dirty hack; should be removed.
4161 (gnus-summary-ignore-duplicates
4162 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4164 gnus-summary-ignore-duplicates))
4165 (info (nth 2 entry))
4166 articles fetched-articles cached)
4168 (unless (gnus-check-server
4169 (setq gnus-current-select-method
4170 (gnus-find-method-for-group group)))
4171 (error "Couldn't open server"))
4173 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4174 (gnus-activate-group group) ; Or we can activate it...
4175 (progn ; Or we bug out.
4176 (when (equal major-mode 'gnus-summary-mode)
4177 (kill-buffer (current-buffer)))
4178 (error "Couldn't activate group %s: %s"
4179 group (gnus-status-message group))))
4181 (unless (gnus-request-group group t)
4182 (when (equal major-mode 'gnus-summary-mode)
4183 (kill-buffer (current-buffer)))
4184 (error "Couldn't request group %s: %s"
4185 group (gnus-status-message group)))
4187 (setq gnus-newsgroup-name group)
4188 (setq gnus-newsgroup-unselected nil)
4189 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4190 (gnus-summary-setup-default-charset)
4192 ;; Adjust and set lists of article marks.
4194 (gnus-adjust-marked-articles info))
4196 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4198 (if (gnus-virtual-group-p group)
4199 gnus-newsgroup-cached
4200 (gnus-cache-articles-in-group group)))
4202 (setq gnus-newsgroup-unreads
4203 (gnus-set-difference
4204 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4205 gnus-newsgroup-dormant))
4207 (setq gnus-newsgroup-processable nil)
4209 (gnus-update-read-articles group gnus-newsgroup-unreads)
4211 (if (setq articles select-articles)
4212 (setq gnus-newsgroup-unselected
4213 (gnus-sorted-intersection
4214 gnus-newsgroup-unreads
4215 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4216 (setq articles (gnus-articles-to-read group read-all)))
4220 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4222 ((eq articles 0) nil)
4224 ;; Init the dependencies hash table.
4225 (setq gnus-newsgroup-dependencies
4226 (gnus-make-hashtable (length articles)))
4227 (gnus-set-global-variables)
4228 ;; Retrieve the headers and read them in.
4229 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4230 (setq gnus-newsgroup-headers
4231 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
4232 (if (eq 'nnimap (car (gnus-find-method-for-group group)))
4235 gnus-headers-retrieved-by
4236 (gnus-retrieve-headers
4237 articles gnus-newsgroup-name
4238 ;; We might want to fetch old headers, but
4239 ;; not if there is only 1 article.
4241 (not (eq gnus-fetch-old-headers 'some))
4242 (not (numberp gnus-fetch-old-headers)))
4243 (> (length articles) 1))
4244 gnus-fetch-old-headers))))
4245 (gnus-get-newsgroup-headers-xover
4246 articles nil nil gnus-newsgroup-name t)
4247 (gnus-get-newsgroup-headers))
4248 (gnus-retrieve-parsed-headers
4249 articles gnus-newsgroup-name
4250 ;; We might want to fetch old headers, but
4251 ;; not if there is only 1 article.
4252 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4253 (not (numberp gnus-fetch-old-headers)))
4254 (> (length articles) 1))
4255 gnus-fetch-old-headers))))
4256 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4258 ;; Suppress duplicates?
4259 (when gnus-suppress-duplicates
4260 (gnus-dup-suppress-articles))
4262 ;; Set the initial limit.
4263 (setq gnus-newsgroup-limit (copy-sequence articles))
4264 ;; Remove canceled articles from the list of unread articles.
4265 (setq gnus-newsgroup-unreads
4266 (gnus-set-sorted-intersection
4267 gnus-newsgroup-unreads
4268 (setq fetched-articles
4269 (mapcar (lambda (headers) (mail-header-number headers))
4270 gnus-newsgroup-headers))))
4271 ;; Removed marked articles that do not exist.
4272 (gnus-update-missing-marks
4273 (gnus-sorted-complement fetched-articles articles))
4275 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4277 (setq gnus-newsgroup-cached cached))
4279 ;; We might want to build some more threads first.
4280 (when (and gnus-fetch-old-headers
4281 (eq gnus-headers-retrieved-by 'nov))
4282 (if (eq gnus-fetch-old-headers 'invisible)
4283 (gnus-build-all-threads)
4284 (gnus-build-old-threads)))
4285 ;; Let the Gnus agent mark articles as read.
4287 (gnus-agent-get-undownloaded-list))
4288 ;; Remove list identifiers from subject
4289 (when gnus-list-identifiers
4290 (gnus-summary-remove-list-identifiers))
4291 ;; Check whether auto-expire is to be done in this group.
4292 (setq gnus-newsgroup-auto-expire
4293 (gnus-group-auto-expirable-p group))
4294 ;; Set up the article buffer now, if necessary.
4295 (unless gnus-single-article-buffer
4296 (gnus-article-setup-buffer))
4297 ;; First and last article in this newsgroup.
4298 (when gnus-newsgroup-headers
4299 (setq gnus-newsgroup-begin
4300 (mail-header-number (car gnus-newsgroup-headers))
4303 (gnus-last-element gnus-newsgroup-headers))))
4304 ;; GROUP is successfully selected.
4305 (or gnus-newsgroup-headers t)))))
4307 (defun gnus-articles-to-read (group &optional read-all)
4308 "Find out what articles the user wants to read."
4310 ;; Select all articles if `read-all' is non-nil, or if there
4311 ;; are no unread articles.
4313 (and (zerop (length gnus-newsgroup-marked))
4314 (zerop (length gnus-newsgroup-unreads)))
4315 (eq (gnus-group-find-parameter group 'display)
4318 (gnus-uncompress-range (gnus-active group))
4319 (gnus-cache-articles-in-group group))
4320 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4321 (copy-sequence gnus-newsgroup-unreads))
4323 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4324 (scored (length scored-list))
4325 (number (length articles))
4326 (marked (+ (length gnus-newsgroup-marked)
4327 (length gnus-newsgroup-dormant)))
4335 ((and (or (<= scored marked) (= scored number))
4336 (natnump gnus-large-newsgroup)
4337 (> number gnus-large-newsgroup))
4338 (let* ((cursor-in-echo-area nil)
4339 (input (read-from-minibuffer
4341 "How many articles from %s (max %d): "
4342 (gnus-limit-string gnus-newsgroup-name 35)
4344 (cons (number-to-string gnus-large-newsgroup)
4346 (if (string-match "^[ \t]*$" input)
4349 ((and (> scored marked) (< scored number)
4350 (> (- scored number) 20))
4353 (format "%s %s (%d scored, %d total): "
4354 "How many articles from"
4355 group scored number))))
4356 (if (string-match "^[ \t]*$" input)
4360 (message "Quit getting the articles to read")
4362 (setq select (if (stringp select) (string-to-number select) select))
4363 (if (or (null select) (zerop select))
4365 (if (and (not (zerop scored)) (<= (abs select) scored))
4367 (setq articles (sort scored-list '<))
4368 (setq number (length articles)))
4369 (setq articles (copy-sequence articles)))
4371 (when (< (abs select) number)
4373 ;; Select the N oldest articles.
4374 (setcdr (nthcdr (1- (abs select)) articles) nil)
4375 ;; Select the N most recent articles.
4376 (setq articles (nthcdr (- number select) articles))))
4377 (setq gnus-newsgroup-unselected
4378 (gnus-sorted-intersection
4379 gnus-newsgroup-unreads
4380 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4381 (when gnus-alter-articles-to-read-function
4382 (setq gnus-newsgroup-unreads
4384 (funcall gnus-alter-articles-to-read-function
4385 gnus-newsgroup-name gnus-newsgroup-unreads)
4389 (defun gnus-killed-articles (killed articles)
4392 (when (inline (gnus-member-of-range (car articles) killed))
4393 (push (car articles) out))
4394 (setq articles (cdr articles)))
4397 (defun gnus-uncompress-marks (marks)
4398 "Uncompress the mark ranges in MARKS."
4399 (let ((uncompressed '(score bookmark))
4402 (if (memq (caar marks) uncompressed)
4403 (push (car marks) out)
4404 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4405 (setq marks (cdr marks)))
4408 (defun gnus-adjust-marked-articles (info)
4409 "Set all article lists and remove all marks that are no longer valid."
4410 (let* ((marked-lists (gnus-info-marks info))
4411 (active (gnus-active (gnus-info-group info)))
4414 (types gnus-article-mark-lists)
4415 (uncompressed '(score bookmark killed))
4416 marks var articles article mark)
4419 (setq marks (pop marked-lists))
4420 (set (setq var (intern (format "gnus-newsgroup-%s"
4421 (car (rassq (setq mark (car marks))
4423 (if (memq (car marks) uncompressed) (cdr marks)
4424 (gnus-uncompress-range (cdr marks))))
4426 (setq articles (symbol-value var))
4428 ;; All articles have to be subsets of the active articles.
4430 ;; Adjust "simple" lists.
4431 ((memq mark '(tick dormant expire reply save))
4433 (when (or (< (setq article (pop articles)) min) (> article max))
4434 (set var (delq article (symbol-value var))))))
4436 ((memq mark uncompressed)
4437 (when (not (listp (cdr (symbol-value var))))
4438 (set var (list (symbol-value var))))
4439 (when (not (listp (cdr articles)))
4440 (setq articles (list articles)))
4442 (when (or (not (consp (setq article (pop articles))))
4443 (< (car article) min)
4444 (> (car article) max))
4445 (set var (delq article (symbol-value var))))))))))
4447 (defun gnus-update-missing-marks (missing)
4448 "Go through the list of MISSING articles and remove them from the mark lists."
4450 (let ((types gnus-article-mark-lists)
4452 ;; Go through all types.
4454 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4455 (when (symbol-value var)
4456 ;; This list has articles. So we delete all missing articles
4460 (set var (delq (pop m) (symbol-value var)))))))))
4462 (defun gnus-update-marks ()
4463 "Enter the various lists of marked articles into the newsgroup info list."
4464 (let ((types gnus-article-mark-lists)
4465 (info (gnus-get-info gnus-newsgroup-name))
4466 (uncompressed '(score bookmark killed))
4467 type list newmarked symbol delta-marks)
4469 ;; Add all marks lists to the list of marks lists.
4470 (while (setq type (pop types))
4471 (setq list (symbol-value
4473 (intern (format "gnus-newsgroup-%s"
4477 ;; Get rid of the entries of the articles that have the
4479 (when (and (eq (cdr type) 'score)
4483 (prev (cons nil list))
4486 (if (or (not (consp (car arts)))
4487 (= (cdar arts) gnus-summary-default-score))
4488 (setcdr prev (cdr arts))
4490 (setq arts (cdr arts)))
4491 (setq list (cdr all)))))
4493 (unless (memq (cdr type) uncompressed)
4494 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4496 (when (gnus-check-backend-function
4497 'request-set-mark gnus-newsgroup-name)
4498 ;; propagate flags to server, with the following exceptions:
4499 ;; uncompressed:s are not proper flags (they are cons cells)
4500 ;; cache is a internal gnus flag
4501 ;; download are local to one gnus installation (well)
4502 ;; unsend are for nndraft groups only
4503 ;; xxx: generality of this? this suits nnimap anyway
4504 (unless (memq (cdr type) (append '(cache download unsend)
4506 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4507 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4508 (add (gnus-remove-from-range
4509 (gnus-copy-sequence list) old)))
4511 (push (list add 'add (list (cdr type))) delta-marks))
4513 (push (list del 'del (list (cdr type))) delta-marks)))))
4516 (push (cons (cdr type) list) newmarked)))
4519 (unless (gnus-check-group gnus-newsgroup-name)
4520 (error "Can't open server for %s" gnus-newsgroup-name))
4521 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4523 ;; Enter these new marks into the info of the group.
4525 (setcar (nthcdr 3 info) newmarked)
4526 ;; Add the marks lists to the end of the info.
4528 (setcdr (nthcdr 2 info) (list newmarked))))
4530 ;; Cut off the end of the info if there's nothing else there.
4534 (when (nthcdr (decf i) info)
4535 (setcdr (nthcdr i info) nil)))))))
4537 (defun gnus-set-mode-line (where)
4538 "Set the mode line of the article or summary buffers.
4539 If WHERE is `summary', the summary mode line format will be used."
4540 ;; Is this mode line one we keep updated?
4541 (when (and (memq where gnus-updated-mode-lines)
4543 (intern (format "gnus-%s-mode-line-format-spec" where))))
4546 ;; We evaluate this in the summary buffer since these
4547 ;; variables are buffer-local to that buffer.
4548 (set-buffer gnus-summary-buffer)
4549 ;; We bind all these variables that are used in the `eval' form
4551 (let* ((mformat (symbol-value
4553 (format "gnus-%s-mode-line-format-spec" where))))
4554 (gnus-tmp-group-name (gnus-group-name-decode
4556 (gnus-group-name-charset
4558 gnus-newsgroup-name)))
4559 (gnus-tmp-article-number (or gnus-current-article 0))
4560 (gnus-tmp-unread gnus-newsgroup-unreads)
4561 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4562 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4563 (gnus-tmp-unread-and-unselected
4564 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4565 (zerop gnus-tmp-unselected))
4567 ((zerop gnus-tmp-unselected)
4568 (format "{%d more}" gnus-tmp-unread-and-unticked))
4569 (t (format "{%d(+%d) more}"
4570 gnus-tmp-unread-and-unticked
4571 gnus-tmp-unselected))))
4573 (if (and gnus-current-headers
4574 (vectorp gnus-current-headers))
4575 (gnus-mode-string-quote
4576 (mail-header-subject gnus-current-headers))
4578 bufname-length max-len
4579 gnus-tmp-header);; passed as argument to any user-format-funcs
4580 (setq mode-string (eval mformat))
4581 (setq bufname-length (if (string-match "%b" mode-string)
4584 (if (eq where 'summary)
4586 (get-buffer gnus-article-buffer))))
4589 (setq max-len (max 4 (if gnus-mode-non-string-length
4591 gnus-mode-non-string-length
4593 (length mode-string))))
4594 ;; We might have to chop a bit of the string off...
4595 (when (> (length mode-string) max-len)
4597 (concat (gnus-truncate-string mode-string (- max-len 3))
4599 ;; Pad the mode string a bit.
4600 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4601 ;; Update the mode line.
4602 (setq mode-line-buffer-identification
4603 (gnus-mode-line-buffer-identification (list mode-string)))
4604 (set-buffer-modified-p t))))
4606 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4607 "Go through the HEADERS list and add all Xrefs to a hash table.
4608 The resulting hash table is returned, or nil if no Xrefs were found."
4609 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4610 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4611 (xref-hashtb (gnus-make-hashtable))
4612 start group entry number xrefs header)
4614 (setq header (pop headers))
4615 (when (and (setq xrefs (mail-header-xref header))
4616 (not (memq (setq number (mail-header-number header))
4619 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4620 (setq start (match-end 0))
4621 (setq group (if prefix
4622 (concat prefix (substring xrefs (match-beginning 1)
4624 (substring xrefs (match-beginning 1) (match-end 1))))
4626 (string-to-int (substring xrefs (match-beginning 2)
4628 (if (setq entry (gnus-gethash group xref-hashtb))
4629 (setcdr entry (cons number (cdr entry)))
4630 (gnus-sethash group (cons number nil) xref-hashtb)))))
4631 (and start xref-hashtb)))
4633 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4634 "Look through all the headers and mark the Xrefs as read."
4635 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4636 name entry info xref-hashtb idlist method nth4)
4638 (set-buffer gnus-group-buffer)
4639 (when (setq xref-hashtb
4640 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4643 (unless (string= from-newsgroup (setq name (symbol-name group)))
4644 (setq idlist (symbol-value group))
4645 ;; Dead groups are not updated.
4647 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4649 (when (stringp (setq nth4 (gnus-info-method info)))
4650 (setq nth4 (gnus-server-to-method nth4))))
4651 ;; Only do the xrefs if the group has the same
4652 ;; select method as the group we have just read.
4653 (or (gnus-methods-equal-p
4654 nth4 (gnus-find-method-for-group from-newsgroup))
4656 (equal nth4 (setq method (gnus-find-method-for-group
4658 (and (equal (car nth4) (car method))
4659 (equal (nth 1 nth4) (nth 1 method))))
4660 gnus-use-cross-reference
4661 (or (not (eq gnus-use-cross-reference t))
4663 ;; Only do cross-references on subscribed
4664 ;; groups, if that is what is wanted.
4665 (<= (gnus-info-level info) gnus-level-subscribed))
4666 (gnus-group-make-articles-read name idlist))))
4669 (defun gnus-compute-read-articles (group articles)
4670 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4671 (info (nth 2 entry))
4672 (active (gnus-active group))
4675 ;; First peel off all invalid article numbers.
4677 (let ((ids articles)
4679 (while (setq id (pop ids))
4680 (when (and first (> id (cdr active)))
4681 ;; We'll end up in this situation in one particular
4682 ;; obscure situation. If you re-scan a group and get
4683 ;; a new article that is cross-posted to a different
4684 ;; group that has not been re-scanned, you might get
4685 ;; crossposted article that has a higher number than
4686 ;; Gnus believes possible. So we re-activate this
4687 ;; group as well. This might mean doing the
4688 ;; crossposting thingy will *increase* the number
4689 ;; of articles in some groups. Tsk, tsk.
4690 (setq active (or (gnus-activate-group group) active)))
4691 (when (or (> id (cdr active))
4692 (< id (car active)))
4693 (setq articles (delq id articles))))))
4694 ;; If the read list is nil, we init it.
4696 (null (gnus-info-read info))
4698 (setq ninfo (cons 1 (1- (car active))))
4699 (setq ninfo (gnus-info-read info)))
4700 ;; Then we add the read articles to the range.
4702 ninfo (setq articles (sort articles '<))))))
4704 (defun gnus-group-make-articles-read (group articles)
4705 "Update the info of GROUP to say that ARTICLES are read."
4707 (entry (gnus-gethash group gnus-newsrc-hashtb))
4708 (info (nth 2 entry))
4709 (active (gnus-active group))
4712 (setq range (gnus-compute-read-articles group articles))
4714 (set-buffer gnus-group-buffer)
4717 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4718 (gnus-info-set-read ',info ',(gnus-info-read info))
4719 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4720 (gnus-group-update-group ,group t))))
4721 ;; Add the read articles to the range.
4722 (gnus-info-set-read info range)
4723 ;; Then we have to re-compute how many unread
4724 ;; articles there are in this group.
4728 (setq num (- (1+ (cdr active)) (car active))))
4729 ((not (listp (cdr range)))
4730 (setq num (- (cdr active) (- (1+ (cdr range))
4734 (if (numberp (car range))
4736 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4737 (setq range (cdr range)))
4738 (setq num (- (cdr active) num))))
4739 ;; Update the number of unread articles.
4741 ;; Update the group buffer.
4742 (gnus-group-update-group group t)))))
4744 (defvar gnus-newsgroup-none-id 0)
4746 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4747 (let ((cur nntp-server-buffer)
4750 (save-excursion (set-buffer gnus-summary-buffer)
4751 gnus-newsgroup-dependencies)))
4753 (mail-parse-charset gnus-newsgroup-charset)
4754 (mail-parse-ignored-charsets
4755 (save-excursion (condition-case nil
4756 (set-buffer gnus-summary-buffer)
4758 gnus-newsgroup-ignored-charsets)))
4760 (set-buffer nntp-server-buffer)
4761 ;; Translate all TAB characters into SPACE characters.
4762 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4763 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4764 (gnus-run-hooks 'gnus-parse-headers-hook)
4765 (let ((case-fold-search t)
4766 in-reply-to header p lines chars ctype)
4767 (goto-char (point-min))
4768 ;; Search to the beginning of the next header. Error messages
4769 ;; do not begin with 2 or 3.
4770 (while (re-search-forward "^[23][0-9]+ " nil t)
4773 ;; This implementation of this function, with nine
4774 ;; search-forwards instead of the one re-search-forward and
4775 ;; a case (which basically was the old function) is actually
4776 ;; about twice as fast, even though it looks messier. You
4777 ;; can't have everything, I guess. Speed and elegance
4778 ;; doesn't always go hand in hand.
4781 (make-full-mail-header
4787 (narrow-to-region (point)
4788 (or (and (search-forward "\n.\n" nil t)
4794 (if (search-forward "\nsubject: " nil t)
4795 (nnheader-header-value)
4800 (if (or (search-forward "\nfrom: " nil t)
4801 (search-forward "\nfrom:" nil t))
4802 (nnheader-header-value)
4807 (if (search-forward "\ndate: " nil t)
4808 (nnheader-header-value)
4813 (setq id (if (re-search-forward
4814 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4815 ;; We do it this way to make sure the Message-ID
4816 ;; is (somewhat) syntactically valid.
4817 (buffer-substring (match-beginning 1)
4819 ;; If there was no message-id, we just fake one
4820 ;; to make subsequent routines simpler.
4821 (nnheader-generate-fake-message-id))))
4825 (if (search-forward "\nreferences: " nil t)
4829 (nnheader-header-value)
4834 (search-backward ">" end t)
4837 (search-backward "<" end t)
4839 ;; Get the references from the in-reply-to header if there
4840 ;; were no references and the in-reply-to header looks
4842 (if (and (search-forward "\nin-reply-to: " nil t)
4843 (setq in-reply-to (nnheader-header-value))
4844 (string-match "<[^>]+>" in-reply-to))
4846 (setq ref (substring in-reply-to (match-beginning 0)
4848 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4849 (setq ref2 (substring in-reply-to (match-beginning 0)
4851 (when (> (length ref2) (length ref))
4858 (if (search-forward "\nchars: " nil t)
4859 (if (numberp (setq chars (ignore-errors (read cur))))
4865 (if (search-forward "\nlines: " nil t)
4866 (if (numberp (setq lines (ignore-errors (read cur))))
4872 (and (search-forward "\nxref: " nil t)
4873 (nnheader-header-value)))
4875 (when gnus-extra-headers
4876 (let ((extra gnus-extra-headers)
4880 (when (search-forward
4881 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4882 (push (cons (car extra) (nnheader-header-value)) out))
4886 (if (and (search-forward "\ncontent-type: " nil t)
4887 (setq ctype (nnheader-header-value)))
4888 (mime-entity-set-content-type-internal
4889 header (mime-parse-Content-Type ctype)))
4890 (when (equal id ref)
4893 (when gnus-alter-header-function
4894 (funcall gnus-alter-header-function header)
4895 (setq id (mail-header-id header)
4896 ref (gnus-parent-id (mail-header-references header))))
4899 (gnus-dependencies-add-header
4900 header dependencies force-new))
4901 (push header headers))
4902 (goto-char (point-max))
4904 (nreverse headers)))))
4906 ;; Goes through the xover lines and returns a list of vectors
4907 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4908 force-new dependencies
4909 group also-fetch-heads)
4910 "Parse the news overview data in the server buffer.
4911 Return a list of headers that match SEQUENCE (see
4912 `nntp-retrieve-headers')."
4913 ;; Get the Xref when the users reads the articles since most/some
4914 ;; NNTP servers do not include Xrefs when using XOVER.
4915 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4916 (let ((mail-parse-charset gnus-newsgroup-charset)
4917 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4918 (cur nntp-server-buffer)
4919 (dependencies (or dependencies gnus-newsgroup-dependencies))
4920 number headers header)
4922 (set-buffer nntp-server-buffer)
4923 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4924 ;; Allow the user to mangle the headers before parsing them.
4925 (gnus-run-hooks 'gnus-parse-headers-hook)
4926 (goto-char (point-min))
4929 (while (and sequence (not (eobp)))
4930 (setq number (read cur))
4931 (while (and sequence
4932 (< (car sequence) number))
4933 (setq sequence (cdr sequence)))
4935 (eq number (car sequence))
4937 (setq sequence (cdr sequence))
4938 (setq header (inline
4939 (gnus-nov-parse-line
4940 number dependencies force-new))))
4941 (push header headers))
4944 (gnus-error 4 "Strange nov line (%d)"
4945 (count-lines (point-min) (point)))))
4947 ;; A common bug in inn is that if you have posted an article and
4948 ;; then retrieves the active file, it will answer correctly --
4949 ;; the new article is included. However, a NOV entry for the
4950 ;; article may not have been generated yet, so this may fail.
4951 ;; We work around this problem by retrieving the last few
4952 ;; headers using HEAD.
4953 (if (or (not also-fetch-heads)
4955 ;; We (probably) got all the headers.
4957 (let ((gnus-nov-is-evil t))
4960 ;;;!!! FIXME: temporary fix for an infloop on nnimap.
4961 (if (eq 'nnimap (car (gnus-find-method-for-group group)))
4962 (when (gnus-retrieve-headers sequence group)
4963 (gnus-get-newsgroup-headers))
4964 (gnus-retrieve-parsed-headers sequence group))))))))
4966 (defun gnus-article-get-xrefs ()
4967 "Fill in the Xref value in `gnus-current-headers', if necessary.
4968 This is meant to be called in `gnus-article-internal-prepare-hook'."
4969 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4970 gnus-current-headers)))
4971 (or (not gnus-use-cross-reference)
4973 (and (mail-header-xref headers)
4974 (not (string= (mail-header-xref headers) "")))
4975 (let ((case-fold-search t)
4978 (nnheader-narrow-to-headers)
4979 (goto-char (point-min))
4980 (when (or (and (not (eobp))
4981 (eq (downcase (char-after)) ?x)
4982 (looking-at "Xref:"))
4983 (search-forward "\nXref:" nil t))
4984 (goto-char (1+ (match-end 0)))
4985 (setq xref (buffer-substring (point)
4986 (progn (end-of-line) (point))))
4987 (mail-header-set-xref headers xref)))))))
4989 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4990 "Find article ID and insert the summary line for that article.
4991 OLD-HEADER can either be a header or a line number to insert
4992 the subject line on."
4993 (let* ((line (and (numberp old-header) old-header))
4994 (old-header (and (vectorp old-header) old-header))
4995 (header (cond ((and old-header use-old-header)
4998 (gnus-number-to-header id))
4999 (gnus-number-to-header id))
5001 (gnus-read-header id))))
5002 (number (and (numberp id) id))
5005 ;; Rebuild the thread that this article is part of and go to the
5006 ;; article we have fetched.
5007 (when (and (not gnus-show-threads)
5010 (setq d (gnus-data-find (mail-header-number old-header))))
5011 (goto-char (gnus-data-pos d))
5014 (- (gnus-point-at-bol)
5016 (1+ (gnus-point-at-eol))
5017 (gnus-delete-line))))))
5019 (mail-header-set-number header (mail-header-number old-header)))
5020 (setq gnus-newsgroup-sparse
5021 (delq (setq number (mail-header-number header))
5022 gnus-newsgroup-sparse))
5023 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5024 (push number gnus-newsgroup-limit)
5025 (gnus-rebuild-thread (mail-header-id header) line)
5026 (gnus-summary-goto-subject number nil t))
5027 (when (and (numberp number)
5029 ;; We have to update the boundaries even if we can't fetch the
5030 ;; article if ID is a number -- so that the next `P' or `N'
5031 ;; command will fetch the previous (or next) article even
5032 ;; if the one we tried to fetch this time has been canceled.
5033 (when (> number gnus-newsgroup-end)
5034 (setq gnus-newsgroup-end number))
5035 (when (< number gnus-newsgroup-begin)
5036 (setq gnus-newsgroup-begin number))
5037 (setq gnus-newsgroup-unselected
5038 (delq number gnus-newsgroup-unselected)))
5039 ;; Report back a success?
5040 (and header (mail-header-number header))))
5042 ;;; Process/prefix in the summary buffer
5044 (defun gnus-summary-work-articles (n)
5045 "Return a list of articles to be worked upon.
5046 The prefix argument, the list of process marked articles, and the
5047 current article will be taken into consideration."
5049 (set-buffer gnus-summary-buffer)
5052 ;; A numerical prefix has been given.
5053 (setq n (prefix-numeric-value n))
5054 (let ((backward (< n 0))
5055 (n (abs (prefix-numeric-value n)))
5060 (push (setq article (gnus-summary-article-number))
5063 (gnus-summary-find-prev nil article)
5064 (gnus-summary-find-next nil article)))
5066 (nreverse articles)))
5067 ((and (gnus-region-active-p) (mark))
5068 (message "region active")
5069 ;; Work on the region between point and mark.
5070 (let ((max (max (point) (mark)))
5073 (goto-char (min (point) (mark)))
5076 (push (setq article (gnus-summary-article-number)) articles)
5077 (gnus-summary-find-next nil article)
5079 (nreverse articles))))
5080 (gnus-newsgroup-processable
5081 ;; There are process-marked articles present.
5082 ;; Save current state.
5083 (gnus-summary-save-process-mark)
5085 (reverse gnus-newsgroup-processable))
5087 ;; Just return the current article.
5088 (list (gnus-summary-article-number))))))
5090 (defmacro gnus-summary-iterate (arg &rest forms)
5091 "Iterate over the process/prefixed articles and do FORMS.
5092 ARG is the interactive prefix given to the command. FORMS will be
5093 executed with point over the summary line of the articles."
5094 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5095 `(let ((,articles (gnus-summary-work-articles ,arg)))
5097 (gnus-summary-goto-subject (car ,articles))
5101 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5102 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5104 (defun gnus-summary-save-process-mark ()
5105 "Push the current set of process marked articles on the stack."
5107 (push (copy-sequence gnus-newsgroup-processable)
5108 gnus-newsgroup-process-stack))
5110 (defun gnus-summary-kill-process-mark ()
5111 "Push the current set of process marked articles on the stack and unmark."
5113 (gnus-summary-save-process-mark)
5114 (gnus-summary-unmark-all-processable))
5116 (defun gnus-summary-yank-process-mark ()
5117 "Pop the last process mark state off the stack and restore it."
5119 (unless gnus-newsgroup-process-stack
5120 (error "Empty mark stack"))
5121 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5123 (defun gnus-summary-process-mark-set (set)
5124 "Make SET into the current process marked articles."
5125 (gnus-summary-unmark-all-processable)
5127 (gnus-summary-set-process-mark (pop set))))
5129 ;;; Searching and stuff
5131 (defun gnus-summary-search-group (&optional backward use-level)
5132 "Search for next unread newsgroup.
5133 If optional argument BACKWARD is non-nil, search backward instead."
5135 (set-buffer gnus-group-buffer)
5136 (when (gnus-group-search-forward
5137 backward nil (if use-level (gnus-group-group-level) nil))
5138 (gnus-group-group-name))))
5140 (defun gnus-summary-best-group (&optional exclude-group)
5141 "Find the name of the best unread group.
5142 If EXCLUDE-GROUP, do not go to this group."
5144 (set-buffer gnus-group-buffer)
5146 (gnus-group-best-unread-group exclude-group))))
5148 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5149 (if backward (gnus-summary-find-prev)
5150 (let* ((dummy (gnus-summary-article-intangible-p))
5151 (article (or article (gnus-summary-article-number)))
5152 (arts (gnus-data-find-list article))
5154 (when (and (not dummy)
5155 (or (not gnus-summary-check-current)
5157 (not (gnus-data-unread-p (car arts)))))
5158 (setq arts (cdr arts)))
5163 (when (or (and undownloaded
5164 (eq gnus-undownloaded-mark
5165 (gnus-data-mark (car arts))))
5166 (gnus-data-unread-p (car arts)))
5167 (setq result (car arts)
5169 (setq arts (cdr arts)))
5172 (goto-char (gnus-data-pos result))
5173 (gnus-data-number result)))))
5175 (defun gnus-summary-find-prev (&optional unread article)
5176 (let* ((eobp (eobp))
5177 (article (or article (gnus-summary-article-number)))
5178 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5180 (when (and (not eobp)
5181 (or (not gnus-summary-check-current)
5183 (not (gnus-data-unread-p (car arts)))))
5184 (setq arts (cdr arts)))
5189 (when (gnus-data-unread-p (car arts))
5190 (setq result (car arts)
5192 (setq arts (cdr arts)))
5195 (goto-char (gnus-data-pos result))
5196 (gnus-data-number result))))
5198 (defun gnus-summary-find-subject (subject &optional unread backward article)
5199 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5200 (article (or article (gnus-summary-article-number)))
5201 (articles (gnus-data-list backward))
5202 (arts (gnus-data-find-list article articles))
5204 (when (or (not gnus-summary-check-current)
5206 (not (gnus-data-unread-p (car arts))))
5207 (setq arts (cdr arts)))
5209 (and (or (not unread)
5210 (gnus-data-unread-p (car arts)))
5211 (vectorp (gnus-data-header (car arts)))
5213 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5214 (setq result (car arts)
5216 (setq arts (cdr arts)))
5218 (goto-char (gnus-data-pos result))
5219 (gnus-data-number result))))
5221 (defun gnus-summary-search-forward (&optional unread subject backward)
5222 "Search forward for an article.
5223 If UNREAD, look for unread articles. If SUBJECT, look for
5224 articles with that subject. If BACKWARD, search backward instead."
5225 (cond (subject (gnus-summary-find-subject subject unread backward))
5226 (backward (gnus-summary-find-prev unread))
5227 (t (gnus-summary-find-next unread))))
5229 (defun gnus-recenter (&optional n)
5230 "Center point in window and redisplay frame.
5231 Also do horizontal recentering."
5233 (when (and gnus-auto-center-summary
5234 (not (eq gnus-auto-center-summary 'vertical)))
5235 (gnus-horizontal-recenter))
5238 (defun gnus-summary-recenter ()
5239 "Center point in the summary window.
5240 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5241 displayed, no centering will be performed."
5242 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5243 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5245 (let* ((top (cond ((< (window-height) 4) 0)
5246 ((< (window-height) 7) 1)
5247 (t (if (numberp gnus-auto-center-summary)
5248 gnus-auto-center-summary
5250 (height (1- (window-height)))
5251 (bottom (save-excursion (goto-char (point-max))
5252 (forward-line (- height))
5254 (window (get-buffer-window (current-buffer))))
5255 ;; The user has to want it.
5256 (when gnus-auto-center-summary
5257 (when (get-buffer-window gnus-article-buffer)
5258 ;; Only do recentering when the article buffer is displayed,
5259 ;; Set the window start to either `bottom', which is the biggest
5260 ;; possible valid number, or the second line from the top,
5261 ;; whichever is the least.
5263 window (min bottom (save-excursion
5264 (forward-line (- top)) (point)))
5266 ;; Do horizontal recentering while we're at it.
5267 (when (and (get-buffer-window (current-buffer) t)
5268 (not (eq gnus-auto-center-summary 'vertical)))
5269 (let ((selected (selected-window)))
5270 (select-window (get-buffer-window (current-buffer) t))
5271 (gnus-summary-position-point)
5272 (gnus-horizontal-recenter)
5273 (select-window selected))))))
5275 (defun gnus-summary-jump-to-group (newsgroup)
5276 "Move point to NEWSGROUP in group mode buffer."
5277 ;; Keep update point of group mode buffer if visible.
5278 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5279 (save-window-excursion
5280 ;; Take care of tree window mode.
5281 (when (get-buffer-window gnus-group-buffer)
5282 (pop-to-buffer gnus-group-buffer))
5283 (gnus-group-jump-to-group newsgroup))
5285 ;; Take care of tree window mode.
5286 (if (get-buffer-window gnus-group-buffer)
5287 (pop-to-buffer gnus-group-buffer)
5288 (set-buffer gnus-group-buffer))
5289 (gnus-group-jump-to-group newsgroup))))
5291 ;; This function returns a list of article numbers based on the
5292 ;; difference between the ranges of read articles in this group and
5293 ;; the range of active articles.
5294 (defun gnus-list-of-unread-articles (group)
5295 (let* ((read (gnus-info-read (gnus-get-info group)))
5296 (active (or (gnus-active group) (gnus-activate-group group)))
5299 ;; If none are read, then all are unread.
5301 (setq first (car active))
5302 ;; If the range of read articles is a single range, then the
5303 ;; first unread article is the article after the last read
5304 ;; article. Sounds logical, doesn't it?
5305 (if (and (not (listp (cdr read)))
5306 (or (< (car read) (car active))
5307 (progn (setq read (list read))
5309 (setq first (max (car active) (1+ (cdr read))))
5310 ;; `read' is a list of ranges.
5311 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5314 (setq first (car active)))
5317 (while (< first nlast)
5319 (setq first (1+ first))))
5320 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5321 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5322 (setq read (cdr read)))))
5323 ;; And add the last unread articles.
5324 (while (<= first last)
5326 (setq first (1+ first)))
5327 ;; Return the list of unread articles.
5328 (delq 0 (nreverse unread))))
5330 (defun gnus-list-of-read-articles (group)
5331 "Return a list of unread, unticked and non-dormant articles."
5332 (let* ((info (gnus-get-info group))
5333 (marked (gnus-info-marks info))
5334 (active (gnus-active group)))
5336 (gnus-set-difference
5337 (gnus-sorted-complement
5338 (gnus-uncompress-range active)
5339 (gnus-list-of-unread-articles group))
5341 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5342 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5344 ;; Various summary commands
5346 (defun gnus-summary-select-article-buffer ()
5347 "Reconfigure windows to show article buffer."
5349 (if (not (gnus-buffer-live-p gnus-article-buffer))
5350 (error "There is no article buffer for this summary buffer")
5351 (gnus-configure-windows 'article)
5352 (select-window (get-buffer-window gnus-article-buffer))))
5354 (defun gnus-summary-universal-argument (arg)
5355 "Perform any operation on all articles that are process/prefixed."
5357 (let ((articles (gnus-summary-work-articles arg))
5364 (substitute-command-keys
5365 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5367 (gnus-error 1 "Undefined key")
5370 (gnus-summary-goto-subject (setq article (pop articles)))
5371 (let (gnus-newsgroup-processable)
5372 (command-execute func))
5373 (gnus-summary-remove-process-mark article)))))
5374 (gnus-summary-position-point))
5376 (defun gnus-summary-toggle-truncation (&optional arg)
5377 "Toggle truncation of summary lines.
5378 With arg, turn line truncation on iff arg is positive."
5380 (setq truncate-lines
5381 (if (null arg) (not truncate-lines)
5382 (> (prefix-numeric-value arg) 0)))
5385 (defun gnus-summary-reselect-current-group (&optional all rescan)
5386 "Exit and then reselect the current newsgroup.
5387 The prefix argument ALL means to select all articles."
5389 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5390 (error "Ephemeral groups can't be reselected"))
5391 (let ((current-subject (gnus-summary-article-number))
5392 (group gnus-newsgroup-name))
5393 (setq gnus-newsgroup-begin nil)
5395 ;; We have to adjust the point of group mode buffer because
5396 ;; point was moved to the next unread newsgroup by exiting.
5397 (gnus-summary-jump-to-group group)
5400 (save-window-excursion
5401 ;; Don't show group contents.
5402 (set-window-start (selected-window) (point-max))
5403 (gnus-group-get-new-news-this-group 1))))
5404 (gnus-group-read-group all t)
5405 (gnus-summary-goto-subject current-subject nil t)))
5407 (defun gnus-summary-rescan-group (&optional all)
5408 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5410 (gnus-summary-reselect-current-group all t))
5412 (defun gnus-summary-update-info (&optional non-destructive)
5414 (let ((group gnus-newsgroup-name))
5416 (when gnus-newsgroup-kill-headers
5417 (setq gnus-newsgroup-killed
5418 (gnus-compress-sequence
5420 (gnus-set-sorted-intersection
5421 (gnus-uncompress-range gnus-newsgroup-killed)
5422 (setq gnus-newsgroup-unselected
5423 (sort gnus-newsgroup-unselected '<)))
5424 (setq gnus-newsgroup-unreads
5425 (sort gnus-newsgroup-unreads '<)))
5427 (unless (listp (cdr gnus-newsgroup-killed))
5428 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5429 (let ((headers gnus-newsgroup-headers))
5430 ;; Set the new ranges of read articles.
5432 (set-buffer gnus-group-buffer)
5433 (gnus-undo-force-boundary))
5434 (gnus-update-read-articles
5435 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5436 ;; Set the current article marks.
5437 (let ((gnus-newsgroup-scored
5438 (if (and (not gnus-save-score)
5439 (not non-destructive))
5441 gnus-newsgroup-scored)))
5443 (gnus-update-marks)))
5444 ;; Do the cross-ref thing.
5445 (when gnus-use-cross-reference
5446 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5447 ;; Do not switch windows but change the buffer to work.
5448 (set-buffer gnus-group-buffer)
5449 (unless (gnus-ephemeral-group-p group)
5450 (gnus-group-update-group group)))))))
5452 (defun gnus-summary-save-newsrc (&optional force)
5453 "Save the current number of read/marked articles in the dribble buffer.
5454 The dribble buffer will then be saved.
5455 If FORCE (the prefix), also save the .newsrc file(s)."
5457 (gnus-summary-update-info t)
5459 (gnus-save-newsrc-file)
5460 (gnus-dribble-save)))
5462 (defun gnus-summary-exit (&optional temporary)
5463 "Exit reading current newsgroup, and then return to group selection mode.
5464 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5466 (gnus-set-global-variables)
5467 (gnus-kill-save-kill-buffer)
5468 (gnus-async-halt-prefetch)
5469 (let* ((group gnus-newsgroup-name)
5470 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5473 (buf (current-buffer)))
5475 ;; Do adaptive scoring, and possibly save score files.
5476 (when gnus-newsgroup-adaptive
5477 (gnus-score-adaptive))
5478 (when gnus-use-scoring
5480 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5481 ;; If we have several article buffers, we kill them at exit.
5482 (unless gnus-single-article-buffer
5483 (gnus-kill-buffer gnus-original-article-buffer)
5484 (setq gnus-article-current nil))
5485 (when gnus-use-cache
5486 (gnus-cache-possibly-remove-articles)
5487 (gnus-cache-save-buffers))
5488 (gnus-async-prefetch-remove-group group)
5489 (when gnus-suppress-duplicates
5490 (gnus-dup-enter-articles))
5491 (when gnus-use-trees
5492 (gnus-tree-close group))
5493 (when gnus-use-cache
5494 (gnus-cache-write-active))
5495 ;; Remove entries for this group.
5496 (nnmail-purge-split-history (gnus-group-real-name group))
5497 ;; Make all changes in this group permanent.
5499 (gnus-run-hooks 'gnus-exit-group-hook)
5500 (gnus-summary-update-info))
5501 (gnus-close-group group)
5502 ;; Make sure where we were, and go to next newsgroup.
5503 (set-buffer gnus-group-buffer)
5505 (gnus-group-jump-to-group group))
5506 (gnus-run-hooks 'gnus-summary-exit-hook)
5507 (unless (or quit-config
5508 ;; If this group has disappeared from the summary
5509 ;; buffer, don't skip forwards.
5510 (not (string= group (gnus-group-group-name))))
5511 (gnus-group-next-unread-group 1))
5512 (setq group-point (point))
5515 ;; If we have several article buffers, we kill them at exit.
5516 (unless gnus-single-article-buffer
5517 (gnus-kill-buffer gnus-article-buffer)
5518 (gnus-kill-buffer gnus-original-article-buffer)
5519 (setq gnus-article-current nil))
5521 (if (not gnus-kill-summary-on-exit)
5522 (gnus-deaden-summary)
5523 ;; We set all buffer-local variables to nil. It is unclear why
5524 ;; this is needed, but if we don't, buffer-local variables are
5525 ;; not garbage-collected, it seems. This would the lead to en
5526 ;; ever-growing Emacs.
5527 (gnus-summary-clear-local-variables)
5528 (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 ;; Return to group mode buffer.
5535 (when (eq mode 'gnus-summary-mode)
5536 (gnus-kill-buffer buf)))
5537 (setq gnus-current-select-method gnus-select-method)
5538 (pop-to-buffer gnus-group-buffer)
5539 (if (not quit-config)
5541 (goto-char group-point)
5542 (gnus-configure-windows 'group 'force)
5543 (unless (pos-visible-in-window-p)
5544 (forward-line (/ (static-if (featurep 'xemacs)
5545 (window-displayed-height)
5546 (1- (window-height)))
5548 (set-window-start (selected-window) (point))
5549 (goto-char group-point)))
5550 (gnus-handle-ephemeral-exit quit-config))
5551 ;; Clear the current group name.
5553 (setq gnus-newsgroup-name nil)))))
5555 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5556 (defun gnus-summary-exit-no-update (&optional no-questions)
5557 "Quit reading current newsgroup without updating read article info."
5559 (let* ((group gnus-newsgroup-name)
5560 (quit-config (gnus-group-quit-config group)))
5561 (when (or no-questions
5563 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5564 (gnus-async-halt-prefetch)
5566 (delq 'gnus-summary-expire-articles
5567 (copy-sequence gnus-summary-prepare-exit-hook)))
5568 ;; If we have several article buffers, we kill them at exit.
5569 (unless gnus-single-article-buffer
5570 (gnus-kill-buffer gnus-article-buffer)
5571 (gnus-kill-buffer gnus-original-article-buffer)
5572 (setq gnus-article-current nil))
5573 (if (not gnus-kill-summary-on-exit)
5574 (gnus-deaden-summary)
5575 (gnus-close-group group)
5576 (gnus-summary-clear-local-variables)
5577 (set-buffer gnus-group-buffer)
5578 (gnus-summary-clear-local-variables)
5579 (when (get-buffer gnus-summary-buffer)
5580 (kill-buffer gnus-summary-buffer)))
5581 (unless gnus-single-article-buffer
5582 (setq gnus-article-current nil))
5583 (when gnus-use-trees
5584 (gnus-tree-close group))
5585 (gnus-async-prefetch-remove-group group)
5586 (when (get-buffer gnus-article-buffer)
5587 (bury-buffer gnus-article-buffer))
5588 ;; Return to the group buffer.
5589 (gnus-configure-windows 'group 'force)
5590 ;; Clear the current group name.
5591 (setq gnus-newsgroup-name nil)
5592 (when (equal (gnus-group-group-name) group)
5593 (gnus-group-next-unread-group 1))
5595 (gnus-handle-ephemeral-exit quit-config)))))
5597 (defun gnus-handle-ephemeral-exit (quit-config)
5598 "Handle movement when leaving an ephemeral group.
5599 The state which existed when entering the ephemeral is reset."
5600 (if (not (buffer-name (car quit-config)))
5601 (gnus-configure-windows 'group 'force)
5602 (set-buffer (car quit-config))
5603 (cond ((eq major-mode 'gnus-summary-mode)
5604 (gnus-set-global-variables))
5605 ((eq major-mode 'gnus-article-mode)
5607 ;; The `gnus-summary-buffer' variable may point
5608 ;; to the old summary buffer when using a single
5610 (unless (gnus-buffer-live-p gnus-summary-buffer)
5611 (set-buffer gnus-group-buffer))
5612 (set-buffer gnus-summary-buffer)
5613 (gnus-set-global-variables))))
5614 (if (or (eq (cdr quit-config) 'article)
5615 (eq (cdr quit-config) 'pick))
5617 ;; The current article may be from the ephemeral group
5618 ;; thus it is best that we reload this article
5619 (gnus-summary-show-article)
5620 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5621 (gnus-configure-windows 'pick 'force)
5622 (gnus-configure-windows (cdr quit-config) 'force)))
5623 (gnus-configure-windows (cdr quit-config) 'force))
5624 (when (eq major-mode 'gnus-summary-mode)
5625 (gnus-summary-next-subject 1 nil t)
5626 (gnus-summary-recenter)
5627 (gnus-summary-position-point))))
5629 (defun gnus-summary-preview-mime-message ()
5630 "MIME decode and play this message."
5632 (let ((gnus-break-pages nil)
5634 (gnus-summary-select-article gnus-show-all-headers t))
5635 (select-window (get-buffer-window gnus-article-buffer)))
5639 (defvar gnus-dead-summary-mode-map nil)
5641 (unless gnus-dead-summary-mode-map
5642 (setq gnus-dead-summary-mode-map (make-keymap))
5643 (suppress-keymap gnus-dead-summary-mode-map)
5644 (substitute-key-definition
5645 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5646 (let ((keys '("\C-d" "\r" "\177" [delete])))
5648 (define-key gnus-dead-summary-mode-map
5649 (pop keys) 'gnus-summary-wake-up-the-dead))))
5651 (defvar gnus-dead-summary-mode nil
5652 "Minor mode for Gnus summary buffers.")
5654 (defun gnus-dead-summary-mode (&optional arg)
5655 "Minor mode for Gnus summary buffers."
5657 (when (eq major-mode 'gnus-summary-mode)
5658 (make-local-variable 'gnus-dead-summary-mode)
5659 (setq gnus-dead-summary-mode
5660 (if (null arg) (not gnus-dead-summary-mode)
5661 (> (prefix-numeric-value arg) 0)))
5662 (when gnus-dead-summary-mode
5663 (gnus-add-minor-mode
5664 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5666 (defun gnus-deaden-summary ()
5667 "Make the current summary buffer into a dead summary buffer."
5668 ;; Kill any previous dead summary buffer.
5669 (when (and gnus-dead-summary
5670 (buffer-name gnus-dead-summary))
5672 (set-buffer gnus-dead-summary)
5673 (when gnus-dead-summary-mode
5674 (kill-buffer (current-buffer)))))
5675 ;; Make this the current dead summary.
5676 (setq gnus-dead-summary (current-buffer))
5677 (gnus-dead-summary-mode 1)
5678 (let ((name (buffer-name)))
5679 (when (string-match "Summary" name)
5681 (concat (substring name 0 (match-beginning 0)) "Dead "
5682 (substring name (match-beginning 0)))
5686 (defun gnus-kill-or-deaden-summary (buffer)
5687 "Kill or deaden the summary BUFFER."
5689 (when (and (buffer-name buffer)
5690 (not gnus-single-article-buffer))
5693 (gnus-kill-buffer gnus-article-buffer)
5694 (gnus-kill-buffer gnus-original-article-buffer)))
5695 (cond (gnus-kill-summary-on-exit
5696 (when (and gnus-use-trees
5697 (gnus-buffer-exists-p buffer))
5700 (gnus-tree-close gnus-newsgroup-name)))
5701 (gnus-kill-buffer buffer))
5702 ((gnus-buffer-exists-p buffer)
5705 (gnus-deaden-summary))))))
5707 (defun gnus-summary-wake-up-the-dead (&rest args)
5708 "Wake up the dead summary buffer."
5710 (gnus-dead-summary-mode -1)
5711 (let ((name (buffer-name)))
5712 (when (string-match "Dead " name)
5714 (concat (substring name 0 (match-beginning 0))
5715 (substring name (match-end 0)))
5717 (gnus-message 3 "This dead summary is now alive again"))
5719 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5720 (defun gnus-summary-fetch-faq (&optional faq-dir)
5721 "Fetch the FAQ for the current group.
5722 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5726 (when current-prefix-arg
5728 "Faq dir: " (and (listp gnus-group-faq-directory)
5729 (mapcar (lambda (file) (list file))
5730 gnus-group-faq-directory))))))
5731 (let (gnus-faq-buffer)
5732 (when (setq gnus-faq-buffer
5733 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5734 (gnus-configure-windows 'summary-faq))))
5736 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5737 (defun gnus-summary-describe-group (&optional force)
5738 "Describe the current newsgroup."
5740 (gnus-group-describe-group force gnus-newsgroup-name))
5742 (defun gnus-summary-describe-briefly ()
5743 "Describe summary mode commands briefly."
5745 (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")))
5747 ;; Walking around group mode buffer from summary mode.
5749 (defun gnus-summary-next-group (&optional no-article target-group backward)
5750 "Exit current newsgroup and then select next unread newsgroup.
5751 If prefix argument NO-ARTICLE is non-nil, no article is selected
5752 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5753 previous group instead."
5755 ;; Stop pre-fetching.
5756 (gnus-async-halt-prefetch)
5757 (let ((current-group gnus-newsgroup-name)
5758 (current-buffer (current-buffer))
5760 ;; First we semi-exit this group to update Xrefs and all variables.
5761 ;; We can't do a real exit, because the window conf must remain
5762 ;; the same in case the user is prompted for info, and we don't
5763 ;; want the window conf to change before that...
5764 (gnus-summary-exit t)
5765 (while (not entered)
5766 ;; Then we find what group we are supposed to enter.
5767 (set-buffer gnus-group-buffer)
5768 (gnus-group-jump-to-group current-group)
5771 (if (eq gnus-keep-same-level 'best)
5772 (gnus-summary-best-group gnus-newsgroup-name)
5773 (gnus-summary-search-group backward gnus-keep-same-level))))
5774 (if (not target-group)
5775 ;; There are no further groups, so we return to the group
5778 (gnus-message 5 "Returning to the group buffer")
5780 (when (gnus-buffer-live-p current-buffer)
5781 (set-buffer current-buffer)
5782 (gnus-summary-exit))
5783 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5784 ;; We try to enter the target group.
5785 (gnus-group-jump-to-group target-group)
5786 (let ((unreads (gnus-group-group-unread)))
5787 (if (and (or (eq t unreads)
5788 (and unreads (not (zerop unreads))))
5789 (gnus-summary-read-group
5790 target-group nil no-article
5791 (and (buffer-name current-buffer) current-buffer)
5794 (setq current-group target-group
5795 target-group nil)))))))
5797 (defun gnus-summary-prev-group (&optional no-article)
5798 "Exit current newsgroup and then select previous unread newsgroup.
5799 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5801 (gnus-summary-next-group no-article nil t))
5803 ;; Walking around summary lines.
5805 (defun gnus-summary-first-subject (&optional unread undownloaded)
5806 "Go to the first unread subject.
5807 If UNREAD is non-nil, go to the first unread article.
5808 Returns the article selected or nil if there are no unread articles."
5813 ((null gnus-newsgroup-data)
5814 (gnus-message 3 "No articles in the group")
5816 ;; Pick the first article.
5818 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5819 (gnus-data-number (car gnus-newsgroup-data)))
5820 ;; No unread articles.
5821 ((null gnus-newsgroup-unreads)
5822 (gnus-message 3 "No more unread articles")
5824 ;; Find the first unread article.
5826 (let ((data gnus-newsgroup-data))
5828 (and (not (and undownloaded
5829 (eq gnus-undownloaded-mark
5830 (gnus-data-mark (car data)))))
5831 (not (gnus-data-unread-p (car data)))))
5832 (setq data (cdr data)))
5834 (goto-char (gnus-data-pos (car data)))
5835 (gnus-data-number (car data))))))
5836 (gnus-summary-position-point)))
5838 (defun gnus-summary-next-subject (n &optional unread dont-display)
5839 "Go to next N'th summary line.
5840 If N is negative, go to the previous N'th subject line.
5841 If UNREAD is non-nil, only unread articles are selected.
5842 The difference between N and the actual number of steps taken is
5845 (let ((backward (< n 0))
5849 (gnus-summary-find-prev unread)
5850 (gnus-summary-find-next unread)))
5851 (unless (zerop (setq n (1- n)))
5852 (gnus-summary-show-thread)))
5854 (gnus-message 7 "No more%s articles"
5855 (if unread " unread" "")))
5856 (unless dont-display
5857 (gnus-summary-recenter)
5858 (gnus-summary-position-point))
5861 (defun gnus-summary-next-unread-subject (n)
5862 "Go to next N'th unread summary line."
5864 (gnus-summary-next-subject n t))
5866 (defun gnus-summary-prev-subject (n &optional unread)
5867 "Go to previous N'th summary line.
5868 If optional argument UNREAD is non-nil, only unread article is selected."
5870 (gnus-summary-next-subject (- n) unread))
5872 (defun gnus-summary-prev-unread-subject (n)
5873 "Go to previous N'th unread summary line."
5875 (gnus-summary-next-subject (- n) t))
5877 (defun gnus-summary-goto-subject (article &optional force silent)
5878 "Go the subject line of ARTICLE.
5879 If FORCE, also allow jumping to articles not currently shown."
5880 (interactive "nArticle number: ")
5882 (data (gnus-data-find article)))
5883 ;; We read in the article if we have to.
5886 (gnus-summary-insert-subject
5888 (if (or (numberp force) (vectorp force)) force)
5890 (setq data (gnus-data-find article)))
5895 (gnus-message 3 "Can't find article %d" article))
5897 (goto-char (gnus-data-pos data))
5898 (gnus-summary-position-point)
5901 ;; Walking around summary lines with displaying articles.
5903 (defun gnus-summary-expand-window (&optional arg)
5904 "Make the summary buffer take up the entire Emacs frame.
5905 Given a prefix, will force an `article' buffer configuration."
5908 (gnus-configure-windows 'article 'force)
5909 (gnus-configure-windows 'summary 'force)))
5911 (defun gnus-summary-display-article (article &optional all-header)
5912 "Display ARTICLE in article buffer."
5913 (gnus-set-global-variables)
5917 (if gnus-summary-display-article-function
5918 (funcall gnus-summary-display-article-function article all-header)
5919 (gnus-article-prepare article all-header))
5920 (with-current-buffer gnus-article-buffer
5921 (set (make-local-variable 'gnus-summary-search-article-matched-data)
5923 (gnus-run-hooks 'gnus-select-article-hook)
5924 (when (and gnus-current-article
5925 (not (zerop gnus-current-article)))
5926 (gnus-summary-goto-subject gnus-current-article))
5927 (gnus-summary-recenter)
5928 (when (and gnus-use-trees gnus-show-threads)
5929 (gnus-possibly-generate-tree article)
5930 (gnus-highlight-selected-tree article))
5931 ;; Successfully display article.
5932 (gnus-article-set-window-start
5933 (cdr (assq article gnus-newsgroup-bookmarks))))))
5935 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5936 "Select the current article.
5937 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5938 non-nil, the article will be re-fetched even if it already present in
5939 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5941 ;; Make sure we are in the summary buffer to work around bbdb bug.
5942 (unless (eq major-mode 'gnus-summary-mode)
5943 (set-buffer gnus-summary-buffer))
5944 (let ((article (or article (gnus-summary-article-number)))
5945 (all-headers (not (not all-headers))) ;Must be T or NIL.
5946 gnus-summary-display-article-function)
5948 (gnus-summary-article-pseudo-p article)
5949 (error "This is a pseudo-article"))
5951 (set-buffer gnus-summary-buffer)
5952 (if (or (and gnus-single-article-buffer
5953 (or (null gnus-current-article)
5954 (null gnus-article-current)
5955 (null (get-buffer gnus-article-buffer))
5956 (not (eq article (cdr gnus-article-current)))
5957 (not (equal (car gnus-article-current)
5958 gnus-newsgroup-name))))
5959 (and (not gnus-single-article-buffer)
5960 (or (null gnus-current-article)
5961 (not (eq gnus-current-article article))))
5963 ;; The requested article is different from the current article.
5965 (gnus-summary-display-article article all-headers)
5966 (when (or all-headers gnus-show-all-headers)
5967 (gnus-article-show-all-headers))
5968 (gnus-article-set-window-start
5969 (cdr (assq article gnus-newsgroup-bookmarks)))
5971 (when (or all-headers gnus-show-all-headers)
5972 (gnus-article-show-all-headers))
5975 (defun gnus-summary-set-current-mark (&optional current-mark)
5976 "Obsolete function."
5979 (defun gnus-summary-next-article (&optional unread subject backward push)
5980 "Select the next article.
5981 If UNREAD, only unread articles are selected.
5982 If SUBJECT, only articles with SUBJECT are selected.
5983 If BACKWARD, the previous article is selected instead of the next."
5986 ;; Is there such an article?
5987 ((and (gnus-summary-search-forward unread subject backward)
5988 (or (gnus-summary-display-article (gnus-summary-article-number))
5989 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5990 (gnus-summary-position-point))
5991 ;; If not, we try the first unread, if that is wanted.
5993 gnus-auto-select-same
5994 (gnus-summary-first-unread-article))
5995 (gnus-summary-position-point)
5996 (gnus-message 6 "Wrapped"))
5997 ;; Try to get next/previous article not displayed in this group.
5998 ((and gnus-auto-extend-newsgroup
5999 (not unread) (not subject))
6000 (gnus-summary-goto-article
6001 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6002 nil (count-lines (point-min) (point))))
6003 ;; Go to next/previous group.
6005 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6006 (gnus-summary-jump-to-group gnus-newsgroup-name))
6007 (let ((cmd last-command-char)
6010 (set-buffer gnus-group-buffer)
6013 (if (eq gnus-keep-same-level 'best)
6014 (gnus-summary-best-group gnus-newsgroup-name)
6015 (gnus-summary-search-group backward gnus-keep-same-level))))
6016 ;; For some reason, the group window gets selected. We change
6018 (select-window (get-buffer-window (current-buffer)))
6019 ;; Select next unread newsgroup automagically.
6021 ((or (not gnus-auto-select-next)
6023 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6024 ((or (eq gnus-auto-select-next 'quietly)
6025 (and (eq gnus-auto-select-next 'slightly-quietly)
6027 (and (eq gnus-auto-select-next 'almost-quietly)
6028 (gnus-summary-last-article-p)))
6030 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6032 (gnus-message 7 "No more%s articles (%s)..."
6033 (if unread " unread" "")
6034 (if group (concat "selecting " group)
6036 (gnus-summary-next-group nil group backward)))
6038 (when (gnus-key-press-event-p last-input-event)
6039 (gnus-summary-walk-group-buffer
6040 gnus-newsgroup-name cmd unread backward point))))))))
6042 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6043 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6044 (?\C-p (gnus-group-prev-unread-group 1))))
6045 (cursor-in-echo-area t)
6046 keve key group ended)
6048 (set-buffer gnus-group-buffer)
6051 (if (eq gnus-keep-same-level 'best)
6052 (gnus-summary-best-group gnus-newsgroup-name)
6053 (gnus-summary-search-group backward gnus-keep-same-level))))
6056 5 "No more%s articles%s" (if unread " unread" "")
6058 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6059 (format " (Type %s for %s [%s])"
6060 (single-key-description cmd) group
6061 (car (gnus-gethash group gnus-newsrc-hashtb)))
6062 (format " (Type %s to exit %s)"
6063 (single-key-description cmd)
6064 gnus-newsgroup-name)))
6065 ;; Confirm auto selection.
6066 (setq key (car (setq keve (gnus-read-event-char))))
6069 ((assq key keystrokes)
6070 (let ((obuf (current-buffer)))
6071 (switch-to-buffer gnus-group-buffer)
6073 (gnus-group-jump-to-group group))
6074 (eval (cadr (assq key keystrokes)))
6075 (setq group (gnus-group-group-name))
6076 (switch-to-buffer obuf))
6080 (gnus-ephemeral-group-p gnus-newsgroup-name))
6082 (gnus-summary-next-group nil group backward)))
6084 (push (cdr keve) unread-command-events))))))
6086 (defun gnus-summary-next-unread-article ()
6087 "Select unread article after current one."
6089 (gnus-summary-next-article
6090 (or (not (eq gnus-summary-goto-unread 'never))
6091 (gnus-summary-last-article-p (gnus-summary-article-number)))
6092 (and gnus-auto-select-same
6093 (gnus-summary-article-subject))))
6095 (defun gnus-summary-prev-article (&optional unread subject)
6096 "Select the article after the current one.
6097 If UNREAD is non-nil, only unread articles are selected."
6099 (gnus-summary-next-article unread subject t))
6101 (defun gnus-summary-prev-unread-article ()
6102 "Select unread article before current one."
6104 (gnus-summary-prev-article
6105 (or (not (eq gnus-summary-goto-unread 'never))
6106 (gnus-summary-first-article-p (gnus-summary-article-number)))
6107 (and gnus-auto-select-same
6108 (gnus-summary-article-subject))))
6110 (defun gnus-summary-next-page (&optional lines circular)
6111 "Show next page of the selected article.
6112 If at the end of the current article, select the next article.
6113 LINES says how many lines should be scrolled up.
6115 If CIRCULAR is non-nil, go to the start of the article instead of
6116 selecting the next article when reaching the end of the current
6119 (setq gnus-summary-buffer (current-buffer))
6120 (gnus-set-global-variables)
6121 (let ((article (gnus-summary-article-number))
6122 (article-window (get-buffer-window gnus-article-buffer t))
6124 ;; If the buffer is empty, we have no article.
6126 (error "No article to select"))
6127 (gnus-configure-windows 'article)
6128 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6129 (if (and (eq gnus-summary-goto-unread 'never)
6130 (not (gnus-summary-last-article-p article)))
6131 (gnus-summary-next-article)
6132 (gnus-summary-next-unread-article))
6133 (if (or (null gnus-current-article)
6134 (null gnus-article-current)
6135 (/= article (cdr gnus-article-current))
6136 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6137 ;; Selected subject is different from current article's.
6138 (gnus-summary-display-article article)
6139 (when article-window
6140 (gnus-eval-in-buffer-window gnus-article-buffer
6141 (setq endp (gnus-article-next-page lines)))
6144 (gnus-summary-beginning-of-article))
6146 (gnus-message 3 "End of message"))
6148 (if (and (eq gnus-summary-goto-unread 'never)
6149 (not (gnus-summary-last-article-p article)))
6150 (gnus-summary-next-article)
6151 (gnus-summary-next-unread-article))))))))
6152 (gnus-summary-recenter)
6153 (gnus-summary-position-point)))
6155 (defun gnus-summary-prev-page (&optional lines move)
6156 "Show previous page of selected article.
6157 Argument LINES specifies lines to be scrolled down.
6158 If MOVE, move to the previous unread article if point is at
6159 the beginning of the buffer."
6161 (let ((article (gnus-summary-article-number))
6162 (article-window (get-buffer-window gnus-article-buffer t))
6164 (gnus-configure-windows 'article)
6165 (if (or (null gnus-current-article)
6166 (null gnus-article-current)
6167 (/= article (cdr gnus-article-current))
6168 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6169 ;; Selected subject is different from current article's.
6170 (gnus-summary-display-article article)
6171 (gnus-summary-recenter)
6172 (when article-window
6173 (gnus-eval-in-buffer-window gnus-article-buffer
6174 (setq endp (gnus-article-prev-page lines)))
6175 (when (and move endp)
6177 (gnus-message 3 "Beginning of message"))
6179 (if (and (eq gnus-summary-goto-unread 'never)
6180 (not (gnus-summary-first-article-p article)))
6181 (gnus-summary-prev-article)
6182 (gnus-summary-prev-unread-article))))))))
6183 (gnus-summary-position-point))
6185 (defun gnus-summary-prev-page-or-article (&optional lines)
6186 "Show previous page of selected article.
6187 Argument LINES specifies lines to be scrolled down.
6188 If at the beginning of the article, go to the next article."
6190 (gnus-summary-prev-page lines t))
6192 (defun gnus-summary-scroll-up (lines)
6193 "Scroll up (or down) one line current article.
6194 Argument LINES specifies lines to be scrolled up (or down if negative)."
6196 (gnus-configure-windows 'article)
6197 (gnus-summary-show-thread)
6198 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6199 (gnus-eval-in-buffer-window gnus-article-buffer
6201 (when (gnus-article-next-page lines)
6202 (gnus-message 3 "End of message")))
6204 (gnus-article-prev-page (- lines))))))
6205 (gnus-summary-recenter)
6206 (gnus-summary-position-point))
6208 (defun gnus-summary-scroll-down (lines)
6209 "Scroll down (or up) one line current article.
6210 Argument LINES specifies lines to be scrolled down (or up if negative)."
6212 (gnus-summary-scroll-up (- lines)))
6214 (defun gnus-summary-next-same-subject ()
6215 "Select next article which has the same subject as current one."
6217 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6219 (defun gnus-summary-prev-same-subject ()
6220 "Select previous article which has the same subject as current one."
6222 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6224 (defun gnus-summary-next-unread-same-subject ()
6225 "Select next unread article which has the same subject as current one."
6227 (gnus-summary-next-article t (gnus-summary-article-subject)))
6229 (defun gnus-summary-prev-unread-same-subject ()
6230 "Select previous unread article which has the same subject as current one."
6232 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6234 (defun gnus-summary-first-unread-article ()
6235 "Select the first unread article.
6236 Return nil if there are no unread articles."
6239 (when (gnus-summary-first-subject t)
6240 (gnus-summary-show-thread)
6241 (gnus-summary-first-subject t)
6242 (gnus-summary-display-article (gnus-summary-article-number)))
6243 (gnus-summary-position-point)))
6245 (defun gnus-summary-first-unread-subject ()
6246 "Place the point on the subject line of the first unread article.
6247 Return nil if there are no unread articles."
6250 (when (gnus-summary-first-subject t)
6251 (gnus-summary-show-thread)
6252 (gnus-summary-first-subject t))
6253 (gnus-summary-position-point)))
6255 (defun gnus-summary-first-article ()
6256 "Select the first article.
6257 Return nil if there are no articles."
6260 (when (gnus-summary-first-subject)
6261 (gnus-summary-show-thread)
6262 (gnus-summary-first-subject)
6263 (gnus-summary-display-article (gnus-summary-article-number)))
6264 (gnus-summary-position-point)))
6266 (defun gnus-summary-best-unread-article ()
6267 "Select the unread article with the highest score."
6269 (let ((best -1000000)
6270 (data gnus-newsgroup-data)
6273 (and (gnus-data-unread-p (car data))
6275 (gnus-summary-article-score (gnus-data-number (car data))))
6278 article (gnus-data-number (car data))))
6279 (setq data (cdr data)))
6282 (gnus-summary-goto-article article)
6283 (error "No unread articles"))
6284 (gnus-summary-position-point))))
6286 (defun gnus-summary-last-subject ()
6287 "Go to the last displayed subject line in the group."
6288 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6290 (gnus-summary-goto-subject article))))
6292 (defun gnus-summary-goto-article (article &optional all-headers force)
6293 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6294 If ALL-HEADERS is non-nil, no header lines are hidden.
6295 If FORCE, go to the article even if it isn't displayed. If FORCE
6296 is a number, it is the line the article is to be displayed on."
6300 "Article number or Message-ID: "
6301 (mapcar (lambda (number) (list (int-to-string number)))
6302 gnus-newsgroup-limit))
6306 (if (and (stringp article)
6307 (string-match "@" article))
6308 (gnus-summary-refer-article article)
6309 (when (stringp article)
6310 (setq article (string-to-number article)))
6311 (if (gnus-summary-goto-subject article force)
6312 (gnus-summary-display-article article all-headers)
6313 (gnus-message 4 "Couldn't go to article %s" article) nil))
6314 (gnus-summary-position-point)))
6316 (defun gnus-summary-goto-last-article ()
6317 "Go to the previously read article."
6320 (when gnus-last-article
6321 (gnus-summary-goto-article gnus-last-article nil t))
6322 (gnus-summary-position-point)))
6324 (defun gnus-summary-pop-article (number)
6325 "Pop one article off the history and go to the previous.
6326 NUMBER articles will be popped off."
6329 (setq gnus-newsgroup-history
6330 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6332 (gnus-summary-goto-article (car to) nil t)
6333 (error "Article history empty")))
6334 (gnus-summary-position-point))
6336 ;; Summary commands and functions for limiting the summary buffer.
6338 (defun gnus-summary-limit-to-articles (n)
6339 "Limit the summary buffer to the next N articles.
6340 If not given a prefix, use the process marked articles instead."
6343 (let ((articles (gnus-summary-work-articles n)))
6344 (setq gnus-newsgroup-processable nil)
6345 (gnus-summary-limit articles))
6346 (gnus-summary-position-point)))
6348 (defun gnus-summary-pop-limit (&optional total)
6349 "Restore the previous limit.
6350 If given a prefix, remove all limits."
6353 (setq gnus-newsgroup-limits
6354 (list (mapcar (lambda (h) (mail-header-number h))
6355 gnus-newsgroup-headers))))
6356 (unless gnus-newsgroup-limits
6357 (error "No limit to pop"))
6359 (gnus-summary-limit nil 'pop)
6360 (gnus-summary-position-point)))
6362 (defun gnus-summary-limit-to-subject (subject &optional header)
6363 "Limit the summary buffer to articles that have subjects that match a regexp."
6364 (interactive "sLimit to subject (regexp): ")
6366 (setq header "subject"))
6367 (when (not (equal "" subject))
6369 (let ((articles (gnus-summary-find-matching
6370 (or header "subject") subject 'all)))
6372 (error "Found no matches for \"%s\"" subject))
6373 (gnus-summary-limit articles))
6374 (gnus-summary-position-point))))
6376 (defun gnus-summary-limit-to-author (from)
6377 "Limit the summary buffer to articles that have authors that match a regexp."
6378 (interactive "sLimit to author (regexp): ")
6379 (gnus-summary-limit-to-subject from "from"))
6381 (defun gnus-summary-limit-to-age (age &optional younger-p)
6382 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6383 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6384 articles that are younger than AGE days."
6386 (let ((younger current-prefix-arg)
6389 (while (not days-got)
6390 (setq days (if younger
6391 (read-string "Limit to articles within (in days): ")
6392 (read-string "Limit to articles older than (in days): ")))
6393 (when (> (length days) 0)
6394 (setq days (read days)))
6397 (message "Please enter a number.")
6399 (list days younger)))
6401 (let ((data gnus-newsgroup-data)
6402 (cutoff (days-to-time age))
6403 articles d date is-younger)
6404 (while (setq d (pop data))
6405 (when (and (vectorp (gnus-data-header d))
6406 (setq date (mail-header-date (gnus-data-header d))))
6407 (setq is-younger (time-less-p
6408 (time-since (condition-case ()
6415 (push (gnus-data-number d) articles))))
6416 (gnus-summary-limit (nreverse articles)))
6417 (gnus-summary-position-point)))
6419 (defun gnus-summary-limit-to-extra (header regexp)
6420 "Limit the summary buffer to articles that match an 'extra' header."
6424 (gnus-completing-read
6425 (symbol-name (car gnus-extra-headers))
6426 "Limit extra header:"
6428 (cons (symbol-name x) x))
6433 (read-string (format "Limit to header %s (regexp): " header)))))
6434 (when (not (equal "" regexp))
6436 (let ((articles (gnus-summary-find-matching
6437 (cons 'extra header) regexp 'all)))
6439 (error "Found no matches for \"%s\"" regexp))
6440 (gnus-summary-limit articles))
6441 (gnus-summary-position-point))))
6443 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6445 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6447 (defun gnus-summary-limit-to-unread (&optional all)
6448 "Limit the summary buffer to articles that are not marked as read.
6449 If ALL is non-nil, limit strictly to unread articles."
6452 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6453 (gnus-summary-limit-to-marks
6454 ;; Concat all the marks that say that an article is read and have
6456 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6457 gnus-killed-mark gnus-kill-file-mark
6458 gnus-low-score-mark gnus-expirable-mark
6459 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6460 gnus-duplicate-mark gnus-souped-mark)
6463 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6464 (make-obsolete 'gnus-summary-delete-marked-with
6465 'gnus-summary-limit-exlude-marks)
6467 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6468 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6469 If REVERSE, limit the summary buffer to articles that are marked
6470 with MARKS. MARKS can either be a string of marks or a list of marks.
6471 Returns how many articles were removed."
6472 (interactive "sMarks: ")
6473 (gnus-summary-limit-to-marks marks t))
6475 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6476 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6477 If REVERSE (the prefix), limit the summary buffer to articles that are
6478 not marked with MARKS. MARKS can either be a string of marks or a
6480 Returns how many articles were removed."
6481 (interactive "sMarks: \nP")
6483 (let ((data gnus-newsgroup-data)
6484 (marks (if (listp marks) marks
6485 (append marks nil))) ; Transform to list.
6488 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6489 (memq (gnus-data-mark (car data)) marks))
6490 (push (gnus-data-number (car data)) articles))
6491 (setq data (cdr data)))
6492 (gnus-summary-limit articles))
6493 (gnus-summary-position-point)))
6495 (defun gnus-summary-limit-to-score (&optional score)
6496 "Limit to articles with score at or above SCORE."
6498 (setq score (if score
6499 (prefix-numeric-value score)
6500 (or gnus-summary-default-score 0)))
6501 (let ((data gnus-newsgroup-data)
6504 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6506 (push (gnus-data-number (car data)) articles))
6507 (setq data (cdr data)))
6509 (gnus-summary-limit articles)
6510 (gnus-summary-position-point))))
6512 (defun gnus-summary-limit-include-thread (id)
6513 "Display all the hidden articles that in the current thread."
6514 (interactive (list (mail-header-id (gnus-summary-article-header))))
6515 (let ((articles (gnus-articles-in-thread
6516 (gnus-id-to-thread (gnus-root-id id)))))
6518 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6519 (gnus-summary-position-point))))
6521 (defun gnus-summary-limit-include-dormant ()
6522 "Display all the hidden articles that are marked as dormant.
6523 Note that this command only works on a subset of the articles currently
6524 fetched for this group."
6526 (unless gnus-newsgroup-dormant
6527 (error "There are no dormant articles in this group"))
6529 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6530 (gnus-summary-position-point)))
6532 (defun gnus-summary-limit-exclude-dormant ()
6533 "Hide all dormant articles."
6536 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6537 (gnus-summary-position-point)))
6539 (defun gnus-summary-limit-exclude-childless-dormant ()
6540 "Hide all dormant articles that have no children."
6542 (let ((data (gnus-data-list t))
6543 articles d children)
6544 ;; Find all articles that are either not dormant or have
6546 (while (setq d (pop data))
6547 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6549 (gnus-article-children (gnus-data-number d)))
6552 (when (memq (car children) articles)
6557 (push (gnus-data-number d) articles)))
6560 (gnus-summary-limit articles)
6561 (gnus-summary-position-point))))
6563 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6564 "Mark all unread excluded articles as read.
6565 If ALL, mark even excluded ticked and dormants as read."
6567 (let ((articles (gnus-sorted-complement
6569 (mapcar (lambda (h) (mail-header-number h))
6570 gnus-newsgroup-headers)
6572 (sort gnus-newsgroup-limit '<)))
6574 (setq gnus-newsgroup-unreads
6575 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6577 (setq gnus-newsgroup-dormant nil
6578 gnus-newsgroup-marked nil
6579 gnus-newsgroup-reads
6581 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6582 gnus-newsgroup-reads))
6583 (while (setq article (pop articles))
6584 (unless (or (memq article gnus-newsgroup-dormant)
6585 (memq article gnus-newsgroup-marked))
6586 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6588 (defun gnus-summary-limit (articles &optional pop)
6590 ;; We pop the previous limit off the stack and use that.
6591 (setq articles (car gnus-newsgroup-limits)
6592 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6593 ;; We use the new limit, so we push the old limit on the stack.
6594 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6596 (setq gnus-newsgroup-limit articles)
6597 (let ((total (length gnus-newsgroup-data))
6598 (data (gnus-data-find-list (gnus-summary-article-number)))
6599 (gnus-summary-mark-below nil) ; Inhibit this.
6601 ;; This will do all the work of generating the new summary buffer
6602 ;; according to the new limit.
6603 (gnus-summary-prepare)
6604 ;; Hide any threads, possibly.
6605 (and gnus-show-threads
6606 gnus-thread-hide-subtree
6607 (gnus-summary-hide-all-threads))
6608 ;; Try to return to the article you were at, or one in the
6611 ;; We try to find some article after the current one.
6613 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6616 (setq data (cdr data))))
6618 ;; If there is no data, that means that we were after the last
6619 ;; article. The same goes when we can't find any articles
6620 ;; after the current one.
6621 (goto-char (point-max))
6622 (gnus-summary-find-prev))
6623 (gnus-set-mode-line 'summary)
6624 ;; We return how many articles were removed from the summary
6625 ;; buffer as a result of the new limit.
6626 (- total (length gnus-newsgroup-data))))
6628 (defsubst gnus-invisible-cut-children (threads)
6631 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6636 (defsubst gnus-cut-thread (thread)
6637 "Go forwards in the thread until we find an article that we want to display."
6638 (when (or (eq gnus-fetch-old-headers 'some)
6639 (eq gnus-fetch-old-headers 'invisible)
6640 (numberp gnus-fetch-old-headers)
6641 (eq gnus-build-sparse-threads 'some)
6642 (eq gnus-build-sparse-threads 'more))
6643 ;; Deal with old-fetched headers and sparse threads.
6647 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6648 (gnus-summary-article-ancient-p
6649 (mail-header-number (car thread))))
6650 (if (or (<= (length (cdr thread)) 1)
6651 (eq gnus-fetch-old-headers 'invisible))
6652 (setq gnus-newsgroup-limit
6653 (delq (mail-header-number (car thread))
6654 gnus-newsgroup-limit)
6655 thread (cadr thread))
6656 (when (gnus-invisible-cut-children (cdr thread))
6657 (let ((th (cdr thread)))
6659 (if (memq (mail-header-number (caar th))
6660 gnus-newsgroup-limit)
6661 (setq thread (car th)
6663 (setq th (cdr th))))))))))
6666 (defun gnus-cut-threads (threads)
6667 "Cut off all uninteresting articles from the beginning of threads."
6668 (when (or (eq gnus-fetch-old-headers 'some)
6669 (eq gnus-fetch-old-headers 'invisible)
6670 (numberp gnus-fetch-old-headers)
6671 (eq gnus-build-sparse-threads 'some)
6672 (eq gnus-build-sparse-threads 'more))
6675 (setcar th (gnus-cut-thread (car th)))
6676 (setq th (cdr th)))))
6677 ;; Remove nixed out threads.
6680 (defun gnus-summary-initial-limit (&optional show-if-empty)
6681 "Figure out what the initial limit is supposed to be on group entry.
6682 This entails weeding out unwanted dormants, low-scored articles,
6683 fetch-old-headers verbiage, and so on."
6684 ;; Most groups have nothing to remove.
6685 (if (or gnus-inhibit-limiting
6686 (and (null gnus-newsgroup-dormant)
6687 (not (eq gnus-fetch-old-headers 'some))
6688 (not (numberp gnus-fetch-old-headers))
6689 (not (eq gnus-fetch-old-headers 'invisible))
6690 (null gnus-summary-expunge-below)
6691 (not (eq gnus-build-sparse-threads 'some))
6692 (not (eq gnus-build-sparse-threads 'more))
6693 (null gnus-thread-expunge-below)
6694 (not gnus-use-nocem)))
6696 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6697 (setq gnus-newsgroup-limit nil)
6700 (unless (car (symbol-value node))
6701 ;; These threads have no parents -- they are roots.
6702 (let ((nodes (cdr (symbol-value node)))
6705 (if (and gnus-thread-expunge-below
6706 (< (gnus-thread-total-score (car nodes))
6707 gnus-thread-expunge-below))
6708 (gnus-expunge-thread (pop nodes))
6709 (setq thread (pop nodes))
6710 (gnus-summary-limit-children thread))))))
6711 gnus-newsgroup-dependencies)
6712 ;; If this limitation resulted in an empty group, we might
6713 ;; pop the previous limit and use it instead.
6714 (when (and (not gnus-newsgroup-limit)
6716 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6717 gnus-newsgroup-limit))
6719 (defun gnus-summary-limit-children (thread)
6720 "Return 1 if this subthread is visible and 0 if it is not."
6721 ;; First we get the number of visible children to this thread. This
6722 ;; is done by recursing down the thread using this function, so this
6723 ;; will really go down to a leaf article first, before slowly
6724 ;; working its way up towards the root.
6728 (apply '+ (mapcar 'gnus-summary-limit-children
6731 (number (mail-header-number (car thread)))
6734 (not (memq number gnus-newsgroup-marked))
6736 ;; If this article is dormant and has absolutely no visible
6737 ;; children, then this article isn't visible.
6738 (and (memq number gnus-newsgroup-dormant)
6740 ;; If this is "fetch-old-headered" and there is no
6741 ;; visible children, then we don't want this article.
6742 (and (or (eq gnus-fetch-old-headers 'some)
6743 (numberp gnus-fetch-old-headers))
6744 (gnus-summary-article-ancient-p number)
6746 ;; If this is "fetch-old-headered" and `invisible', then
6747 ;; we don't want this article.
6748 (and (eq gnus-fetch-old-headers 'invisible)
6749 (gnus-summary-article-ancient-p number))
6750 ;; If this is a sparsely inserted article with no children,
6751 ;; we don't want it.
6752 (and (eq gnus-build-sparse-threads 'some)
6753 (gnus-summary-article-sparse-p number)
6755 ;; If we use expunging, and this article is really
6756 ;; low-scored, then we don't want this article.
6757 (when (and gnus-summary-expunge-below
6759 (or (cdr (assq number gnus-newsgroup-scored))
6760 gnus-summary-default-score))
6761 gnus-summary-expunge-below))
6762 ;; We increase the expunge-tally here, but that has
6763 ;; nothing to do with the limits, really.
6764 (incf gnus-newsgroup-expunged-tally)
6765 ;; We also mark as read here, if that's wanted.
6766 (when (and gnus-summary-mark-below
6767 (< score gnus-summary-mark-below))
6768 (setq gnus-newsgroup-unreads
6769 (delq number gnus-newsgroup-unreads))
6770 (if gnus-newsgroup-auto-expire
6771 (push number gnus-newsgroup-expirable)
6772 (push (cons number gnus-low-score-mark)
6773 gnus-newsgroup-reads)))
6775 ;; Check NoCeM things.
6776 (if (and gnus-use-nocem
6777 (gnus-nocem-unwanted-article-p
6778 (mail-header-id (car thread))))
6780 (setq gnus-newsgroup-unreads
6781 (delq number gnus-newsgroup-unreads))
6783 ;; Nope, invisible article.
6785 ;; Ok, this article is to be visible, so we add it to the limit
6787 (push number gnus-newsgroup-limit)
6790 (defun gnus-expunge-thread (thread)
6791 "Mark all articles in THREAD as read."
6792 (let* ((number (mail-header-number (car thread))))
6793 (incf gnus-newsgroup-expunged-tally)
6794 ;; We also mark as read here, if that's wanted.
6795 (setq gnus-newsgroup-unreads
6796 (delq number gnus-newsgroup-unreads))
6797 (if gnus-newsgroup-auto-expire
6798 (push number gnus-newsgroup-expirable)
6799 (push (cons number gnus-low-score-mark)
6800 gnus-newsgroup-reads)))
6801 ;; Go recursively through all subthreads.
6802 (mapcar 'gnus-expunge-thread (cdr thread)))
6804 ;; Summary article oriented commands
6806 (defun gnus-summary-refer-parent-article (n)
6807 "Refer parent article N times.
6808 If N is negative, go to ancestor -N instead.
6809 The difference between N and the number of articles fetched is returned."
6813 (when (not (natnump n))
6818 (setq header (gnus-summary-article-header))
6819 (if (and (eq (mail-header-number header)
6820 (cdr gnus-article-current))
6821 (equal gnus-newsgroup-name
6822 (car gnus-article-current)))
6823 ;; If we try to find the parent of the currently
6824 ;; displayed article, then we take a look at the actual
6825 ;; References header, since this is slightly more
6826 ;; reliable than the References field we got from the
6829 (set-buffer gnus-original-article-buffer)
6830 (nnheader-narrow-to-headers)
6831 (unless (setq ref (message-fetch-field "references"))
6832 (setq ref (message-fetch-field "in-reply-to")))
6835 ;; It's not the current article, so we take a bet on
6836 ;; the value we got from the server.
6837 (mail-header-references header)))
6839 (not (equal ref "")))
6840 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6841 (gnus-message 1 "Couldn't find parent"))
6842 (gnus-message 1 "No references in article %d"
6843 (gnus-summary-article-number))
6846 (gnus-summary-position-point)
6849 (defun gnus-summary-refer-references ()
6850 "Fetch all articles mentioned in the References header.
6851 Return the number of articles fetched."
6853 (let ((ref (mail-header-references (gnus-summary-article-header)))
6854 (current (gnus-summary-article-number))
6858 (error "No References in the current article")
6859 ;; For each Message-ID in the References header...
6860 (while (string-match "<[^>]*>" ref)
6862 ;; ... fetch that article.
6863 (gnus-summary-refer-article
6864 (prog1 (match-string 0 ref)
6865 (setq ref (substring ref (match-end 0))))))
6866 (gnus-summary-goto-subject current)
6867 (gnus-summary-position-point)
6870 (defun gnus-summary-refer-thread (&optional limit)
6871 "Fetch all articles in the current thread.
6872 If LIMIT (the numerical prefix), fetch that many old headers instead
6873 of what's specified by the `gnus-refer-thread-limit' variable."
6875 (let ((id (mail-header-id (gnus-summary-article-header)))
6876 (limit (if limit (prefix-numeric-value limit)
6877 gnus-refer-thread-limit)))
6878 ;; We want to fetch LIMIT *old* headers, but we also have to
6879 ;; re-fetch all the headers in the current buffer, because many of
6880 ;; them may be undisplayed. So we adjust LIMIT.
6881 (when (numberp limit)
6882 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6883 (unless (eq gnus-fetch-old-headers 'invisible)
6884 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6885 ;; Retrieve the headers and read them in.
6886 (if (eq (gnus-retrieve-headers
6887 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6889 (gnus-build-all-threads)
6890 (error "Can't fetch thread from backends that don't support NOV"))
6891 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6892 (gnus-summary-limit-include-thread id)))
6894 (defun gnus-summary-refer-article (message-id)
6895 "Fetch an article specified by MESSAGE-ID."
6896 (interactive "sMessage-ID: ")
6897 (when (and (stringp message-id)
6898 (not (zerop (length message-id))))
6899 ;; Construct the correct Message-ID if necessary.
6900 ;; Suggested by tale@pawl.rpi.edu.
6901 (unless (string-match "^<" message-id)
6902 (setq message-id (concat "<" message-id)))
6903 (unless (string-match ">$" message-id)
6904 (setq message-id (concat message-id ">")))
6905 (let* ((header (gnus-id-to-header message-id))
6907 (gnus-summary-article-sparse-p
6908 (mail-header-number header))
6909 (memq (mail-header-number header)
6910 gnus-newsgroup-limit)))
6913 ;; If the article is present in the buffer we just go to it.
6915 (or (not (gnus-summary-article-sparse-p
6916 (mail-header-number header)))
6919 (gnus-summary-goto-article
6920 (mail-header-number header) nil t)
6922 (gnus-summary-update-article (mail-header-number header)))))
6924 ;; We fetch the article.
6926 (dolist (gnus-override-method (gnus-refer-article-methods))
6927 (gnus-check-server gnus-override-method)
6928 ;; Fetch the header, and display the article.
6929 (when (setq number (gnus-summary-insert-subject message-id))
6930 (gnus-summary-select-article nil nil nil number)
6932 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6934 (defun gnus-refer-article-methods ()
6935 "Return a list of referrable methods."
6937 ;; No method, so we default to current and native.
6938 ((null gnus-refer-article-method)
6939 (list gnus-current-select-method gnus-select-method))
6941 ((eq 'current gnus-refer-article-method)
6942 (list gnus-current-select-method))
6943 ;; List of select methods.
6944 ((not (and (symbolp (car gnus-refer-article-method))
6945 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
6947 (dolist (method gnus-refer-article-method)
6948 (push (if (eq 'current method)
6949 gnus-current-select-method
6953 ;; One single select method.
6955 (list gnus-refer-article-method))))
6957 (defun gnus-summary-edit-parameters ()
6958 "Edit the group parameters of the current group."
6960 (gnus-group-edit-group gnus-newsgroup-name 'params))
6962 (defun gnus-summary-customize-parameters ()
6963 "Customize the group parameters of the current group."
6965 (gnus-group-customize gnus-newsgroup-name))
6967 (defun gnus-summary-enter-digest-group (&optional force)
6968 "Enter an nndoc group based on the current article.
6969 If FORCE, force a digest interpretation. If not, try
6970 to guess what the document format is."
6972 (let ((conf gnus-current-window-configuration))
6974 (gnus-summary-select-article))
6975 (setq gnus-current-window-configuration conf)
6976 (let* ((name (format "%s-%d"
6977 (gnus-group-prefixed-name
6978 gnus-newsgroup-name (list 'nndoc ""))
6980 (set-buffer gnus-summary-buffer)
6981 gnus-current-article)))
6982 (ogroup gnus-newsgroup-name)
6983 (params (append (gnus-info-params (gnus-get-info ogroup))
6984 (list (cons 'to-group ogroup))
6985 (list (cons 'save-article-group ogroup))))
6986 (case-fold-search t)
6987 (buf (current-buffer))
6990 (set-buffer gnus-original-article-buffer)
6991 ;; Have the digest group inherit the main mail address of
6992 ;; the parent article.
6993 (when (setq to-address (or (message-fetch-field "reply-to")
6994 (message-fetch-field "from")))
6995 (setq params (append
6996 (list (cons 'to-address
6997 (funcall gnus-decode-encoded-word-function
6999 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7000 (insert-buffer-substring gnus-original-article-buffer)
7001 ;; Remove lines that may lead nndoc to misinterpret the
7004 (goto-char (point-min))
7005 (or (search-forward "\n\n" nil t) (point)))
7006 (goto-char (point-min))
7007 (delete-matching-lines "^Path:\\|^From ")
7010 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7011 (gnus-newsgroup-ephemeral-ignored-charsets
7012 gnus-newsgroup-ignored-charsets))
7013 (gnus-group-read-ephemeral-group
7014 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7016 ,(if force 'mbox 'guess))) t))
7017 ;; Make all postings to this group go to the parent group.
7018 (nconc (gnus-info-params (gnus-get-info name))
7020 ;; Couldn't select this doc group.
7021 (switch-to-buffer buf)
7022 (gnus-set-global-variables)
7023 (gnus-configure-windows 'summary)
7024 (gnus-message 3 "Article couldn't be entered?"))
7025 (kill-buffer dig)))))
7027 (defun gnus-summary-read-document (n)
7028 "Open a new group based on the current article(s).
7029 This will allow you to read digests and other similar
7030 documents as newsgroups.
7031 Obeys the standard process/prefix convention."
7033 (let* ((articles (gnus-summary-work-articles n))
7034 (ogroup gnus-newsgroup-name)
7035 (params (append (gnus-info-params (gnus-get-info ogroup))
7036 (list (cons 'to-group ogroup))))
7037 article group egroup groups vgroup)
7038 (while (setq article (pop articles))
7039 (setq group (format "%s-%d" gnus-newsgroup-name article))
7040 (gnus-summary-remove-process-mark article)
7041 (when (gnus-summary-display-article article)
7044 (insert-buffer-substring gnus-original-article-buffer)
7045 ;; Remove some headers that may lead nndoc to make
7047 (message-narrow-to-head)
7048 (goto-char (point-min))
7049 (delete-matching-lines "^\\(Path\\):\\|^From ")
7052 (gnus-group-read-ephemeral-group
7053 group `(nndoc ,group (nndoc-address ,(current-buffer))
7054 (nndoc-article-type guess))
7057 ;; Make all postings to this group go to the parent group.
7058 (nconc (gnus-info-params (gnus-get-info egroup))
7060 (push egroup groups))
7061 ;; Couldn't select this doc group.
7062 (gnus-error 3 "Article couldn't be entered"))))))
7063 ;; Now we have selected all the documents.
7066 (error "None of the articles could be interpreted as documents"))
7067 ((gnus-group-read-ephemeral-group
7068 (setq vgroup (format
7069 "nnvirtual:%s-%s" gnus-newsgroup-name
7070 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7071 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7073 (cons (current-buffer) 'summary)))
7075 (error "Couldn't select virtual nndoc group")))))
7077 (defun gnus-summary-isearch-article (&optional regexp-p)
7078 "Do incremental search forward on the current article.
7079 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7081 (let* ((gnus-inhibit-treatment t)
7082 (old (gnus-summary-select-article)))
7083 (gnus-configure-windows 'article)
7084 (gnus-eval-in-buffer-window gnus-article-buffer
7088 (gnus-article-show-all-headers))
7089 (goto-char (point-min))
7090 (isearch-forward regexp-p)))))
7092 (defun gnus-summary-search-article-forward (regexp &optional backward)
7093 "Search for an article containing REGEXP forward.
7094 If BACKWARD, search backward instead."
7097 (format "Search article %s (regexp%s): "
7098 (if current-prefix-arg "backward" "forward")
7099 (if gnus-last-search-regexp
7100 (concat ", default " gnus-last-search-regexp)
7102 current-prefix-arg))
7103 (if (string-equal regexp "")
7104 (setq regexp (or gnus-last-search-regexp ""))
7105 (setq gnus-last-search-regexp regexp))
7106 (if (gnus-summary-search-article regexp backward)
7107 (gnus-summary-show-thread)
7108 (error "Search failed: \"%s\"" regexp)))
7110 (defun gnus-summary-search-article-backward (regexp)
7111 "Search for an article containing REGEXP backward."
7114 (format "Search article backward (regexp%s): "
7115 (if gnus-last-search-regexp
7116 (concat ", default " gnus-last-search-regexp)
7118 (gnus-summary-search-article-forward regexp 'backward))
7121 (defmacro gnus-summary-search-article-position-point (regexp backward)
7122 "Dehighlight the last matched text and goto the beginning position."
7123 (` (if (and gnus-summary-search-article-matched-data
7124 (let ((text (caddr gnus-summary-search-article-matched-data))
7125 (inhibit-read-only t)
7128 (goto-char (car gnus-summary-search-article-matched-data))
7129 (cadr gnus-summary-search-article-matched-data))
7131 (string-match (, regexp) text)))
7132 (if (, backward) (beginning-of-line) (end-of-line))
7133 (goto-char (if (, backward) (point-max) (point-min))))))
7135 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7136 "Place point where X-Face image is displayed."
7137 (if (featurep 'xemacs)
7138 (` (let ((end (if (search-forward "\n\n" nil t)
7139 (goto-char (1- (point)))
7142 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7143 (unless (and (re-search-forward "^From:" end t)
7144 (setq extent (extent-at (point)))
7145 (extent-begin-glyph extent))
7146 (goto-char (, opoint)))))
7147 (` (let ((end (if (search-forward "\n\n" nil t)
7148 (goto-char (1- (point)))
7150 (start (or (search-backward "\n\n" nil t) (point-min))))
7152 (or (text-property-any start end 'x-face-image t);; x-face-e21
7153 (text-property-any start end 'x-face-mule-bitmap-image t)
7156 (defmacro gnus-summary-search-article-highlight-matched-text
7157 (backward treated x-face)
7158 "Highlight matched text in the function `gnus-summary-search-article'."
7159 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7160 (end (set-marker (make-marker) (match-end 0)))
7161 (inhibit-read-only t)
7165 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7167 (lambda (item) (setq items (delq item items)))
7168 '(gnus-treat-buttonize
7169 gnus-treat-fill-article
7170 gnus-treat-fill-long-lines
7171 gnus-treat-emphasize
7172 gnus-treat-highlight-headers
7173 gnus-treat-highlight-citation
7174 gnus-treat-highlight-signature
7175 gnus-treat-overstrike
7176 gnus-treat-display-xface
7177 gnus-treat-buttonize-head
7178 gnus-treat-decode-article-as-default-mime-charset))
7179 (static-if (featurep 'xemacs)
7181 (cons '(x-face-mule-delete-x-face-field
7184 (gnus-treat-display-xface
7185 (when (, x-face) gnus-treat-display-xface)))
7186 (gnus-article-prepare-mime-display)))
7187 (goto-char (if (, backward) start end))
7189 (gnus-summary-search-article-highlight-goto-x-face (point)))
7190 (setq gnus-summary-search-article-matched-data
7191 (list start end (buffer-substring start end)))
7192 (unless (eq start end);; matched text has been deleted. :-<
7193 (put-text-property start end 'face
7194 (or (find-face 'isearch)
7195 'secondary-selection))))))
7198 (defun gnus-summary-search-article (regexp &optional backward)
7199 "Search for an article containing REGEXP.
7200 Optional argument BACKWARD means do search for backward.
7201 `gnus-select-article-hook' is not called during the search."
7202 ;; We have to require this here to make sure that the following
7203 ;; dynamic binding isn't shadowed by autoloading.
7204 (require 'gnus-async)
7206 (let ((gnus-select-article-hook nil) ;Disable hook.
7207 (gnus-article-prepare-hook nil)
7208 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7209 (gnus-use-article-prefetch nil)
7210 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7211 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7212 (sum (current-buffer))
7215 (gnus-save-hidden-threads
7216 (static-if (featurep 'xemacs)
7217 (let ((gnus-inhibit-treatment t))
7218 (setq treated (eq 'old (gnus-summary-select-article)))
7220 (not (and (gnus-buffer-live-p gnus-article-buffer)
7221 (window-live-p (get-buffer-window
7222 gnus-article-buffer t)))))
7223 (gnus-summary-select-article nil t)
7224 (setq treated nil)))
7225 (let ((gnus-inhibit-treatment t)
7226 (x-face-mule-delete-x-face-field 'never))
7227 (setq treated (eq 'old (gnus-summary-select-article)))
7230 (and (gnus-buffer-live-p gnus-article-buffer)
7231 (window-live-p (get-buffer-window
7232 gnus-article-buffer t))
7233 (or (not (string-match "^\\^X-Face:" regexp))
7234 (with-current-buffer gnus-article-buffer
7235 gnus-summary-search-article-matched-data)))))
7236 (gnus-summary-select-article nil t)
7237 (setq treated nil))))
7238 (set-buffer gnus-article-buffer)
7242 (gnus-article-show-all-headers)
7243 (gnus-summary-search-article-position-point regexp backward))
7244 (goto-char (if backward (point-max) (point-min))))
7246 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7248 (re-search-backward regexp nil t)
7249 (re-search-forward regexp nil t))
7250 ;; We found the regexp.
7252 (gnus-summary-search-article-highlight-matched-text
7253 backward treated (string-match "^\\^X-Face:" regexp))
7256 (/ (- 2 (window-height
7257 (get-buffer-window gnus-article-buffer t)))
7260 (get-buffer-window (current-buffer))
7263 (setq point (point)))
7264 ;; We didn't find it, so we go to the next article.
7267 (while (eq found 'not)
7268 (if (not (if backward (gnus-summary-find-prev)
7269 (gnus-summary-find-next)))
7270 ;; No more articles.
7272 ;; Select the next article and adjust point.
7273 (unless (gnus-summary-article-sparse-p
7274 (gnus-summary-article-number))
7276 (let ((gnus-inhibit-treatment t))
7277 (gnus-summary-select-article))
7279 (set-buffer gnus-article-buffer)
7281 (goto-char (if backward (point-max) (point-min))))))))
7282 (gnus-message 7 ""))
7283 ;; Return whether we found the regexp.
7284 (when (eq found 'found)
7286 (gnus-summary-show-thread)
7287 (gnus-summary-goto-subject gnus-current-article)
7288 (gnus-summary-position-point)
7291 (defun gnus-summary-find-matching (header regexp &optional backward unread
7293 "Return a list of all articles that match REGEXP on HEADER.
7294 The search stars on the current article and goes forwards unless
7295 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7296 If UNREAD is non-nil, only unread articles will
7297 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7298 in the comparisons."
7299 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7300 (gnus-data-find-list
7301 (gnus-summary-article-number) (gnus-data-list backward))))
7302 (case-fold-search (not not-case-fold))
7305 (if (eq (car header) 'extra)
7308 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7310 (error "%s is an invalid header" header))
7311 (unless (fboundp (intern (concat "mail-header-" header)))
7312 (error "%s is not a valid header" header))
7313 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7316 (and (or (not unread) ; We want all articles...
7317 (gnus-data-unread-p d)) ; Or just unreads.
7318 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7319 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7320 (push (gnus-data-number d) articles)) ; Success!
7321 (setq data (cdr data)))
7322 (nreverse articles)))
7324 (defun gnus-summary-execute-command (header regexp command &optional backward)
7325 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7326 If HEADER is an empty string (or nil), the match is done on the entire
7327 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7329 (list (let ((completion-ignore-case t))
7332 (mapcar (lambda (header) (list (format "%s" header)))
7334 '("Number" "Subject" "From" "Lines" "Date"
7335 "Message-ID" "Xref" "References" "Body")
7336 gnus-extra-headers))
7337 nil 'require-match))
7338 (read-string "Regexp: ")
7339 (read-key-sequence "Command: ")
7340 current-prefix-arg))
7341 (when (equal header "Body")
7343 ;; Hidden thread subtrees must be searched as well.
7344 (gnus-summary-show-all-threads)
7345 ;; We don't want to change current point nor window configuration.
7347 (save-window-excursion
7348 (gnus-message 6 "Executing %s..." (key-description command))
7349 ;; We'd like to execute COMMAND interactively so as to give arguments.
7350 (gnus-execute header regexp
7351 `(call-interactively ',(key-binding command))
7353 (gnus-message 6 "Executing %s...done" (key-description command)))))
7355 (defun gnus-summary-beginning-of-article ()
7356 "Scroll the article back to the beginning."
7358 (gnus-summary-select-article)
7359 (gnus-configure-windows 'article)
7360 (gnus-eval-in-buffer-window gnus-article-buffer
7362 (goto-char (point-min))
7363 (when gnus-page-broken
7364 (gnus-narrow-to-page))))
7366 (defun gnus-summary-end-of-article ()
7367 "Scroll to the end of the article."
7369 (gnus-summary-select-article)
7370 (gnus-configure-windows 'article)
7371 (gnus-eval-in-buffer-window gnus-article-buffer
7373 (goto-char (point-max))
7375 (when gnus-page-broken
7376 (gnus-narrow-to-page))))
7378 (defun gnus-summary-print-article (&optional filename n)
7379 "Generate and print a PostScript image of the N next (mail) articles.
7381 If N is negative, print the N previous articles. If N is nil and articles
7382 have been marked with the process mark, print these instead.
7384 If the optional first argument FILENAME is nil, send the image to the
7385 printer. If FILENAME is a string, save the PostScript image in a file with
7386 that name. If FILENAME is a number, prompt the user for the name of the file
7388 (interactive (list (ps-print-preprint current-prefix-arg)
7389 current-prefix-arg))
7390 (dolist (article (gnus-summary-work-articles n))
7391 (gnus-summary-select-article nil nil 'pseudo article)
7392 (gnus-eval-in-buffer-window gnus-article-buffer
7393 (let ((buffer (generate-new-buffer " *print*")))
7396 (copy-to-buffer buffer (point-min) (point-max))
7398 (gnus-article-delete-invisible-text)
7399 (let ((ps-left-header
7402 (mail-header-subject gnus-current-headers) ")")
7404 (mail-header-from gnus-current-headers) ")")))
7407 "/pagenumberstring load"
7409 (mail-header-date gnus-current-headers) ")"))))
7410 (gnus-run-hooks 'gnus-ps-print-hook)
7412 (ps-print-buffer-with-faces filename))))
7413 (kill-buffer buffer))))))
7415 (defun gnus-summary-show-article (&optional arg)
7416 "Force re-fetching of the current article.
7417 If ARG (the prefix) is a number, show the article with the charset
7418 defined in `gnus-summary-show-article-charset-alist', or the charset
7420 If ARG (the prefix) is non-nil and not a number, show the raw article
7421 without any article massaging functions being run."
7425 (let ((gnus-newsgroup-charset
7426 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7427 (read-coding-system "Charset: ")))
7428 (gnus-newsgroup-ignored-charsets 'gnus-all))
7429 (gnus-summary-select-article nil 'force)
7430 (let ((deps gnus-newsgroup-dependencies)
7433 (set-buffer gnus-original-article-buffer)
7435 (message-narrow-to-head)
7436 (setq head (buffer-string)))
7438 (insert (format "211 %d Article retrieved.\n"
7439 (cdr gnus-article-current)))
7442 (let ((nntp-server-buffer (current-buffer)))
7443 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7444 (gnus-data-set-header
7445 (gnus-data-find (cdr gnus-article-current))
7447 (gnus-summary-update-article-line
7448 (cdr gnus-article-current) header))))
7450 ;; Select the article the normal way.
7451 (gnus-summary-select-article nil 'force))
7453 ;; We have to require this here to make sure that the following
7454 ;; dynamic binding isn't shadowed by autoloading.
7455 (require 'gnus-async)
7457 ;; Bind the article treatment functions to nil.
7458 (let ((gnus-have-all-headers t)
7459 gnus-article-prepare-hook
7460 gnus-article-decode-hook
7463 (gnus-inhibit-treatment t))
7464 (gnus-summary-select-article nil 'force))))
7465 (gnus-summary-goto-subject gnus-current-article)
7466 (gnus-summary-position-point))
7468 (defun gnus-summary-verbose-headers (&optional arg)
7469 "Toggle permanent full header display.
7470 If ARG is a positive number, turn header display on.
7471 If ARG is a negative number, turn header display off."
7473 (setq gnus-show-all-headers
7474 (cond ((or (not (numberp arg))
7476 (not gnus-show-all-headers))
7479 (gnus-summary-show-article))
7481 (defun gnus-summary-toggle-header (&optional arg)
7482 "Show the headers if they are hidden, or hide them if they are shown.
7483 If ARG is a positive number, show the entire header.
7484 If ARG is a negative number, hide the unwanted header lines."
7487 (set-buffer gnus-article-buffer)
7489 (let* ((buffer-read-only nil)
7490 (inhibit-point-motion-hooks t)
7496 (article-narrow-to-head)
7497 (gnus-article-hidden-text-p 'headers))))
7498 (goto-char (point-min))
7499 (when (search-forward "\n\n" nil t)
7500 (delete-region (point-min) (1- (point))))
7501 (goto-char (point-min))
7503 (set-buffer gnus-original-article-buffer)
7504 (goto-char (point-min))
7505 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7506 (insert-buffer-substring gnus-original-article-buffer 1 e)
7508 (narrow-to-region (point-min) (point))
7509 (article-decode-encoded-words)
7511 (let ((gnus-treat-hide-headers nil)
7512 (gnus-treat-hide-boring-headers nil))
7513 (setq gnus-article-wash-types
7514 (delq 'headers gnus-article-wash-types))
7515 (gnus-treat-article 'head))
7516 (gnus-treat-article 'head)))
7517 (gnus-set-mode-line 'article)))))
7519 (defun gnus-summary-show-all-headers ()
7520 "Make all header lines visible."
7522 (gnus-article-show-all-headers))
7524 (defun gnus-summary-toggle-mime (&optional arg)
7525 "Toggle MIME processing.
7526 If ARG is a positive number, turn MIME processing on."
7528 (setq gnus-show-mime
7530 (not gnus-show-mime)
7531 (> (prefix-numeric-value arg) 0)))
7532 (gnus-summary-select-article t 'force))
7534 (defun gnus-summary-caesar-message (&optional arg)
7535 "Caesar rotate the current article by 13.
7536 The numerical prefix specifies how many places to rotate each letter
7539 (gnus-summary-select-article)
7540 (let ((mail-header-separator ""))
7541 (gnus-eval-in-buffer-window gnus-article-buffer
7544 (let ((start (window-start))
7546 (message-caesar-buffer-body arg)
7547 (set-window-start (get-buffer-window (current-buffer)) start))))))
7549 (defun gnus-summary-stop-page-breaking ()
7550 "Stop page breaking in the current article."
7552 (gnus-summary-select-article)
7553 (gnus-eval-in-buffer-window gnus-article-buffer
7555 (when (gnus-visual-p 'page-marker)
7556 (let ((buffer-read-only nil))
7557 (gnus-remove-text-with-property 'gnus-prev)
7558 (gnus-remove-text-with-property 'gnus-next))
7559 (setq gnus-page-broken nil))))
7561 (defun gnus-summary-move-article (&optional n to-newsgroup
7562 select-method action)
7563 "Move the current article to a different newsgroup.
7564 If N is a positive number, move the N next articles.
7565 If N is a negative number, move the N previous articles.
7566 If N is nil and any articles have been marked with the process mark,
7567 move those articles instead.
7568 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7569 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7570 re-spool using this method.
7572 For this function to work, both the current newsgroup and the
7573 newsgroup that you want to move to have to support the `request-move'
7574 and `request-accept' functions.
7576 ACTION can be either `move' (the default), `crosspost' or `copy'."
7579 (setq action 'move))
7580 ;; Disable marking as read.
7581 (let (gnus-mark-article-hook)
7582 (save-window-excursion
7583 (gnus-summary-select-article)))
7584 ;; Check whether the source group supports the required functions.
7585 (cond ((and (eq action 'move)
7586 (not (gnus-check-backend-function
7587 'request-move-article gnus-newsgroup-name)))
7588 (error "The current group does not support article moving"))
7589 ((and (eq action 'crosspost)
7590 (not (gnus-check-backend-function
7591 'request-replace-article gnus-newsgroup-name)))
7592 (error "The current group does not support article editing")))
7593 (let ((articles (gnus-summary-work-articles n))
7594 (prefix (if (gnus-check-backend-function
7595 'request-move-article gnus-newsgroup-name)
7596 (gnus-group-real-prefix gnus-newsgroup-name)
7598 (names '((move "Move" "Moving")
7599 (copy "Copy" "Copying")
7600 (crosspost "Crosspost" "Crossposting")))
7601 (copy-buf (save-excursion
7602 (nnheader-set-temp-buffer " *copy article*")))
7603 (default-marks gnus-article-mark-lists)
7604 (no-expire-marks (delete '(expirable . expire)
7605 (copy-sequence gnus-article-mark-lists)))
7606 art-group to-method new-xref article to-groups)
7607 (unless (assq action names)
7608 (error "Unknown action %s" action))
7609 ;; Read the newsgroup name.
7610 (when (and (not to-newsgroup)
7611 (not select-method))
7613 (gnus-read-move-group-name
7614 (cadr (assq action names))
7615 (symbol-value (intern (format "gnus-current-%s-group" action)))
7617 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7618 (setq to-method (or select-method
7619 (gnus-server-to-method
7620 (gnus-group-method to-newsgroup))))
7621 ;; Check the method we are to move this article to...
7622 (unless (gnus-check-backend-function
7623 'request-accept-article (car to-method))
7624 (error "%s does not support article copying" (car to-method)))
7625 (unless (gnus-check-server to-method)
7626 (error "Can't open server %s" (car to-method)))
7627 (gnus-message 6 "%s to %s: %s..."
7628 (caddr (assq action names))
7629 (or (car select-method) to-newsgroup) articles)
7631 (setq article (pop articles))
7635 ;; Move the article.
7637 ;; Remove this article from future suppression.
7638 (gnus-dup-unsuppress-article article)
7639 (gnus-request-move-article
7640 article ; Article to move
7641 gnus-newsgroup-name ; From newsgroup
7642 (nth 1 (gnus-find-method-for-group
7643 gnus-newsgroup-name)) ; Server
7644 (list 'gnus-request-accept-article
7645 to-newsgroup (list 'quote select-method)
7646 (not articles) t) ; Accept form
7647 (not articles))) ; Only save nov last time
7648 ;; Copy the article.
7651 (set-buffer copy-buf)
7652 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7653 (gnus-request-accept-article
7654 to-newsgroup select-method (not articles) t))))
7655 ;; Crosspost the article.
7656 ((eq action 'crosspost)
7657 (let ((xref (message-tokenize-header
7658 (mail-header-xref (gnus-summary-article-header article))
7660 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7663 (setq xref (list (system-name))))
7666 (mapconcat 'identity
7667 (delete "Xref:" (delete new-xref xref))
7671 (set-buffer copy-buf)
7672 ;; First put the article in the destination group.
7673 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7674 (when (consp (setq art-group
7675 (gnus-request-accept-article
7676 to-newsgroup select-method (not articles))))
7677 (setq new-xref (concat new-xref " " (car art-group)
7678 ":" (cdr art-group)))
7679 ;; Now we have the new Xrefs header, so we insert
7680 ;; it and replace the new article.
7681 (nnheader-replace-header "Xref" new-xref)
7682 (gnus-request-replace-article
7683 (cdr art-group) to-newsgroup (current-buffer))
7687 (gnus-message 1 "Couldn't %s article %s: %s"
7688 (cadr (assq action names)) article
7689 (nnheader-get-report (car to-method))))
7690 ((eq art-group 'junk)
7691 (when (eq action 'move)
7692 (gnus-summary-mark-article article gnus-canceled-mark)
7693 (gnus-message 4 "Deleted article %s" article)))
7695 (let* ((pto-group (gnus-group-prefixed-name
7696 (car art-group) to-method))
7698 (gnus-gethash pto-group gnus-newsrc-hashtb))
7699 (info (nth 2 entry))
7700 (to-group (gnus-info-group info))
7702 ;; Update the group that has been moved to.
7704 (memq action '(move copy)))
7705 (unless (member to-group to-groups)
7706 (push to-group to-groups))
7708 (unless (memq article gnus-newsgroup-unreads)
7709 (push 'read to-marks)
7711 info (gnus-add-to-range (gnus-info-read info)
7712 (list (cdr art-group)))))
7714 ;; See whether the article is to be put in the cache.
7715 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7718 (to-article (cdr art-group)))
7720 ;; Enter the article into the cache in the new group,
7721 ;; if that is required.
7722 (when gnus-use-cache
7723 (gnus-cache-possibly-enter-article
7725 (let ((header (copy-sequence
7726 (gnus-summary-article-header article))))
7727 (mail-header-set-number header to-article)
7729 (memq article gnus-newsgroup-marked)
7730 (memq article gnus-newsgroup-dormant)
7731 (memq article gnus-newsgroup-unreads)))
7733 (when gnus-preserve-marks
7734 ;; Copy any marks over to the new group.
7735 (when (and (equal to-group gnus-newsgroup-name)
7736 (not (memq article gnus-newsgroup-unreads)))
7737 ;; Mark this article as read in this group.
7738 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7739 (setcdr (gnus-active to-group) to-article)
7740 (setcdr gnus-newsgroup-active to-article))
7743 (when (memq article (symbol-value
7744 (intern (format "gnus-newsgroup-%s"
7746 (push (cdar marks) to-marks)
7747 ;; If the other group is the same as this group,
7748 ;; then we have to add the mark to the list.
7749 (when (equal to-group gnus-newsgroup-name)
7750 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7753 (intern (format "gnus-newsgroup-%s"
7755 ;; Copy the marks to other group.
7756 (gnus-add-marked-articles
7757 to-group (cdar marks) (list to-article) info))
7758 (setq marks (cdr marks)))
7760 (gnus-request-set-mark to-group (list (list (list to-article)
7765 (concat "(gnus-group-set-info '"
7766 (gnus-prin1-to-string (gnus-get-info to-group))
7769 ;; Update the Xref header in this article to point to
7770 ;; the new crossposted article we have just created.
7771 (when (eq action 'crosspost)
7773 (set-buffer copy-buf)
7774 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7775 (nnheader-replace-header "Xref" new-xref)
7776 (gnus-request-replace-article
7777 article gnus-newsgroup-name (current-buffer)))))
7779 ;;;!!!Why is this necessary?
7780 (set-buffer gnus-summary-buffer)
7782 (gnus-summary-goto-subject article)
7783 (when (eq action 'move)
7784 (gnus-summary-mark-article article gnus-canceled-mark))))
7785 (gnus-summary-remove-process-mark article))
7786 ;; Re-activate all groups that have been moved to.
7789 (set-buffer gnus-group-buffer)
7790 (when (gnus-group-goto-group (car to-groups) t)
7791 (gnus-group-get-new-news-this-group 1 t))
7794 (gnus-kill-buffer copy-buf)
7795 (gnus-summary-position-point)
7796 (gnus-set-mode-line 'summary)))
7798 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7799 "Move the current article to a different newsgroup.
7800 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7801 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7802 re-spool using this method."
7804 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7806 (defun gnus-summary-crosspost-article (&optional n)
7807 "Crosspost the current article to some other group."
7809 (gnus-summary-move-article n nil nil 'crosspost))
7811 (defcustom gnus-summary-respool-default-method nil
7812 "Default method for respooling an article.
7813 If nil, use to the current newsgroup method."
7814 :type '(choice (gnus-select-method :value (nnml ""))
7816 :group 'gnus-summary-mail)
7818 (defun gnus-summary-respool-article (&optional n method)
7819 "Respool the current article.
7820 The article will be squeezed through the mail spooling process again,
7821 which means that it will be put in some mail newsgroup or other
7822 depending on `nnmail-split-methods'.
7823 If N is a positive number, respool the N next articles.
7824 If N is a negative number, respool the N previous articles.
7825 If N is nil and any articles have been marked with the process mark,
7826 respool those articles instead.
7828 Respooling can be done both from mail groups and \"real\" newsgroups.
7829 In the former case, the articles in question will be moved from the
7830 current group into whatever groups they are destined to. In the
7831 latter case, they will be copied into the relevant groups."
7833 (list current-prefix-arg
7834 (let* ((methods (gnus-methods-using 'respool))
7836 (symbol-name (or gnus-summary-respool-default-method
7837 (car (gnus-find-method-for-group
7838 gnus-newsgroup-name)))))
7840 (gnus-completing-read
7841 methname "What backend do you want to use when respooling?"
7842 methods nil t nil 'gnus-mail-method-history))
7845 ((zerop (length (setq ms (gnus-servers-using-backend
7847 (list (intern method) ""))
7851 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7852 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7855 (error "No method given for respooling"))
7856 (if (assoc (symbol-name
7857 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7858 (gnus-methods-using 'respool))
7859 (gnus-summary-move-article n nil method)
7860 (gnus-summary-copy-article n nil method)))
7862 (defun gnus-summary-import-article (file)
7863 "Import an arbitrary file into a mail newsgroup."
7864 (interactive "fImport file: ")
7865 (let ((group gnus-newsgroup-name)
7866 (now (current-time))
7868 (unless (gnus-check-backend-function 'request-accept-article group)
7869 (error "%s does not support article importing" group))
7870 (or (file-readable-p file)
7871 (not (file-regular-p file))
7872 (error "Can't read %s" file))
7874 (set-buffer (gnus-get-buffer-create " *import file*"))
7876 (nnheader-insert-file-contents file)
7877 (goto-char (point-min))
7878 (unless (nnheader-article-p)
7879 ;; This doesn't look like an article, so we fudge some headers.
7880 (setq atts (file-attributes file)
7881 lines (count-lines (point-min) (point-max)))
7882 (insert "From: " (read-string "From: ") "\n"
7883 "Subject: " (read-string "Subject: ") "\n"
7884 "Date: " (message-make-date (nth 5 atts))
7886 "Message-ID: " (message-make-message-id) "\n"
7887 "Lines: " (int-to-string lines) "\n"
7888 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7889 (gnus-request-accept-article group nil t)
7890 (kill-buffer (current-buffer)))))
7892 (defun gnus-summary-article-posted-p ()
7893 "Say whether the current (mail) article is available from news as well.
7894 This will be the case if the article has both been mailed and posted."
7896 (let ((id (mail-header-references (gnus-summary-article-header)))
7897 (gnus-override-method (car (gnus-refer-article-methods))))
7898 (if (gnus-request-head id "")
7899 (gnus-message 2 "The current message was found on %s"
7900 gnus-override-method)
7901 (gnus-message 2 "The current message couldn't be found on %s"
7902 gnus-override-method)
7905 (defun gnus-summary-expire-articles (&optional now)
7906 "Expire all articles that are marked as expirable in the current group."
7908 (when (gnus-check-backend-function
7909 'request-expire-articles gnus-newsgroup-name)
7910 ;; This backend supports expiry.
7911 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7912 (expirable (if total
7914 ;; We need to update the info for
7915 ;; this group for `gnus-list-of-read-articles'
7916 ;; to give us the right answer.
7917 (gnus-run-hooks 'gnus-exit-group-hook)
7918 (gnus-summary-update-info)
7919 (gnus-list-of-read-articles gnus-newsgroup-name))
7920 (setq gnus-newsgroup-expirable
7921 (sort gnus-newsgroup-expirable '<))))
7922 (expiry-wait (if now 'immediate
7923 (gnus-group-find-parameter
7924 gnus-newsgroup-name 'expiry-wait)))
7925 (nnmail-expiry-target
7926 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7927 nnmail-expiry-target))
7930 ;; There are expirable articles in this group, so we run them
7931 ;; through the expiry process.
7932 (gnus-message 6 "Expiring articles...")
7933 (unless (gnus-check-group gnus-newsgroup-name)
7934 (error "Can't open server for %s" gnus-newsgroup-name))
7935 ;; The list of articles that weren't expired is returned.
7938 (let ((nnmail-expiry-wait-function nil)
7939 (nnmail-expiry-wait expiry-wait))
7940 (setq es (gnus-request-expire-articles
7941 expirable gnus-newsgroup-name)))
7942 (setq es (gnus-request-expire-articles
7943 expirable gnus-newsgroup-name)))
7945 (setq gnus-newsgroup-expirable es))
7946 ;; We go through the old list of expirable, and mark all
7947 ;; really expired articles as nonexistent.
7948 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7949 (let ((gnus-use-cache nil))
7951 (unless (memq (car expirable) es)
7952 (when (gnus-data-find (car expirable))
7953 (gnus-summary-mark-article
7954 (car expirable) gnus-canceled-mark)))
7955 (setq expirable (cdr expirable))))))
7956 (gnus-message 6 "Expiring articles...done")))))
7958 (defun gnus-summary-expire-articles-now ()
7959 "Expunge all expirable articles in the current group.
7960 This means that *all* articles that are marked as expirable will be
7961 deleted forever, right now."
7963 (or gnus-expert-user
7965 "Are you really, really, really sure you want to delete all these messages? ")
7967 (gnus-summary-expire-articles t))
7969 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7970 (defun gnus-summary-delete-article (&optional n)
7971 "Delete the N next (mail) articles.
7972 This command actually deletes articles. This is not a marking
7973 command. The article will disappear forever from your life, never to
7975 If N is negative, delete backwards.
7976 If N is nil and articles have been marked with the process mark,
7977 delete these instead."
7979 (unless (gnus-check-backend-function 'request-expire-articles
7980 gnus-newsgroup-name)
7981 (error "The current newsgroup does not support article deletion"))
7982 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7983 (error "Couldn't open server"))
7984 ;; Compute the list of articles to delete.
7985 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7987 (if (and gnus-novice-user
7988 (not (gnus-yes-or-no-p
7989 (format "Do you really want to delete %s forever? "
7990 (if (> (length articles) 1)
7991 (format "these %s articles" (length articles))
7994 ;; Delete the articles.
7995 (setq not-deleted (gnus-request-expire-articles
7996 articles gnus-newsgroup-name 'force))
7998 (gnus-summary-remove-process-mark (car articles))
7999 ;; The backend might not have been able to delete the article
8001 (unless (memq (car articles) not-deleted)
8002 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8003 (setq articles (cdr articles)))
8005 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8006 (gnus-summary-position-point)
8007 (gnus-set-mode-line 'summary)
8010 (defun gnus-summary-edit-article (&optional force)
8011 "Edit the current article.
8012 This will have permanent effect only in mail groups.
8013 If FORCE is non-nil, allow editing of articles even in read-only
8017 (set-buffer gnus-summary-buffer)
8018 (let ((mail-parse-charset gnus-newsgroup-charset)
8019 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8020 (gnus-set-global-variables)
8021 (when (and (not force)
8022 (gnus-group-read-only-p))
8023 (error "The current newsgroup does not support article editing"))
8024 (gnus-summary-show-article t)
8025 (gnus-article-edit-article
8027 `(lambda (no-highlight)
8028 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8029 (message-options message-options)
8030 (message-options-set-recipient)
8031 (mail-parse-ignored-charsets
8032 ',gnus-newsgroup-ignored-charsets))
8033 (gnus-summary-edit-article-done
8034 ,(or (mail-header-references gnus-current-headers) "")
8035 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8037 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8039 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8041 "Make edits to the current article permanent."
8044 ;; The buffer restriction contains the entire article if it exists.
8045 (when (article-goto-body)
8046 (let ((lines (count-lines (point) (point-max)))
8047 (length (- (point-max) (point)))
8048 (case-fold-search t)
8049 (body (copy-marker (point))))
8050 (goto-char (point-min))
8051 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8052 (delete-region (match-beginning 1) (match-end 1))
8053 (insert (number-to-string length)))
8054 (goto-char (point-min))
8055 (when (re-search-forward
8056 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8057 (delete-region (match-beginning 1) (match-end 1))
8058 (insert (number-to-string length)))
8059 (goto-char (point-min))
8060 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8061 (delete-region (match-beginning 1) (match-end 1))
8062 (insert (number-to-string lines))))))
8063 ;; Replace the article.
8064 (let ((buf (current-buffer)))
8066 (insert-buffer-substring buf)
8068 (if (and (not read-only)
8069 (not (gnus-request-replace-article
8070 (cdr gnus-article-current) (car gnus-article-current)
8071 (current-buffer) t)))
8072 (error "Couldn't replace article")
8073 ;; Update the summary buffer.
8075 (equal (message-tokenize-header references " ")
8076 (message-tokenize-header
8077 (or (message-fetch-field "references") "") " ")))
8078 ;; We only have to update this line.
8081 (message-narrow-to-head)
8082 (let ((head (buffer-string))
8085 (insert (format "211 %d Article retrieved.\n"
8086 (cdr gnus-article-current)))
8089 (let ((nntp-server-buffer (current-buffer)))
8090 (setq header (car (gnus-get-newsgroup-headers
8092 (set-buffer gnus-summary-buffer)
8093 gnus-newsgroup-dependencies)
8096 (set-buffer gnus-summary-buffer)
8097 (gnus-data-set-header
8098 (gnus-data-find (cdr gnus-article-current))
8100 (gnus-summary-update-article-line
8101 (cdr gnus-article-current) header))))))
8103 (set-buffer (or buffer gnus-summary-buffer))
8104 (gnus-summary-update-article (cdr gnus-article-current)))
8105 ;; Prettify the article buffer again.
8106 (unless no-highlight
8108 (set-buffer gnus-article-buffer)
8109 ;;;!!! Fix this -- article should be rehighlighted.
8110 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8111 (set-buffer gnus-original-article-buffer)
8112 (gnus-request-article
8113 (cdr gnus-article-current)
8114 (car gnus-article-current) (current-buffer))))
8115 ;; Prettify the summary buffer line.
8116 (when (gnus-visual-p 'summary-highlight 'highlight)
8117 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8119 (defun gnus-summary-edit-wash (key)
8120 "Perform editing command KEY in the article buffer."
8124 (message "%s" (concat (this-command-keys) "- "))
8127 (gnus-summary-edit-article)
8128 (execute-kbd-macro (concat (this-command-keys) key))
8129 (gnus-article-edit-done))
8133 (defun gnus-summary-respool-query (&optional silent trace)
8134 "Query where the respool algorithm would put this article."
8136 (let (gnus-mark-article-hook)
8137 (gnus-summary-select-article)
8139 (set-buffer gnus-original-article-buffer)
8141 (message-narrow-to-head)
8142 (let ((groups (nnmail-article-group 'identity trace)))
8145 (message "This message would go to %s"
8146 (mapconcat 'car groups ", "))
8147 (message "This message would go to no groups"))
8150 (defun gnus-summary-respool-trace ()
8151 "Trace where the respool algorithm would put this article.
8152 Display a buffer showing all fancy splitting patterns which matched."
8154 (gnus-summary-respool-query nil t))
8156 ;; Summary marking commands.
8158 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8159 "Mark articles which has the same subject as read, and then select the next.
8160 If UNMARK is positive, remove any kind of mark.
8161 If UNMARK is negative, tick articles."
8164 (setq unmark (prefix-numeric-value unmark)))
8166 (gnus-summary-mark-same-subject
8167 (gnus-summary-article-subject) unmark)))
8168 ;; Select next unread article. If auto-select-same mode, should
8169 ;; select the first unread article.
8170 (gnus-summary-next-article t (and gnus-auto-select-same
8171 (gnus-summary-article-subject)))
8172 (gnus-message 7 "%d article%s marked as %s"
8173 count (if (= count 1) " is" "s are")
8174 (if unmark "unread" "read"))))
8176 (defun gnus-summary-kill-same-subject (&optional unmark)
8177 "Mark articles which has the same subject as read.
8178 If UNMARK is positive, remove any kind of mark.
8179 If UNMARK is negative, tick articles."
8182 (setq unmark (prefix-numeric-value unmark)))
8184 (gnus-summary-mark-same-subject
8185 (gnus-summary-article-subject) unmark)))
8186 ;; If marked as read, go to next unread subject.
8188 ;; Go to next unread subject.
8189 (gnus-summary-next-subject 1 t))
8190 (gnus-message 7 "%d articles are marked as %s"
8191 count (if unmark "unread" "read"))))
8193 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8194 "Mark articles with same SUBJECT as read, and return marked number.
8195 If optional argument UNMARK is positive, remove any kinds of marks.
8196 If optional argument UNMARK is negative, mark articles as unread instead."
8200 ((null unmark) ; Mark as read.
8203 (gnus-summary-mark-article-as-read gnus-killed-mark)
8204 (gnus-summary-show-thread) t)
8205 (gnus-summary-find-subject subject))
8206 (setq count (1+ count))))
8207 ((> unmark 0) ; Tick.
8210 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8211 (gnus-summary-show-thread) t)
8212 (gnus-summary-find-subject subject))
8213 (setq count (1+ count))))
8214 (t ; Mark as unread.
8217 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8218 (gnus-summary-show-thread) t)
8219 (gnus-summary-find-subject subject))
8220 (setq count (1+ count)))))
8221 (gnus-set-mode-line 'summary)
8222 ;; Return the number of marked articles.
8225 (defun gnus-summary-mark-as-processable (n &optional unmark)
8226 "Set the process mark on the next N articles.
8227 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8228 the process mark instead. The difference between N and the actual
8229 number of articles marked is returned."
8231 (let ((backward (< n 0))
8236 (gnus-summary-remove-process-mark
8237 (gnus-summary-article-number))
8238 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8239 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8242 (gnus-message 7 "No more articles"))
8243 (gnus-summary-recenter)
8244 (gnus-summary-position-point)
8247 (defun gnus-summary-unmark-as-processable (n)
8248 "Remove the process mark from the next N articles.
8249 If N is negative, unmark backward instead. The difference between N and
8250 the actual number of articles unmarked is returned."
8252 (gnus-summary-mark-as-processable n t))
8254 (defun gnus-summary-unmark-all-processable ()
8255 "Remove the process mark from all articles."
8258 (while gnus-newsgroup-processable
8259 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8260 (gnus-summary-position-point))
8262 (defun gnus-summary-mark-as-expirable (n)
8263 "Mark N articles forward as expirable.
8264 If N is negative, mark backward instead. The difference between N and
8265 the actual number of articles marked is returned."
8267 (gnus-summary-mark-forward n gnus-expirable-mark))
8269 (defun gnus-summary-mark-article-as-replied (article)
8270 "Mark ARTICLE replied and update the summary line."
8271 (push article gnus-newsgroup-replied)
8272 (let ((buffer-read-only nil))
8273 (when (gnus-summary-goto-subject article nil t)
8274 (gnus-summary-update-secondary-mark article))))
8276 (defun gnus-summary-set-bookmark (article)
8277 "Set a bookmark in current article."
8278 (interactive (list (gnus-summary-article-number)))
8279 (when (or (not (get-buffer gnus-article-buffer))
8280 (not gnus-current-article)
8281 (not gnus-article-current)
8282 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8283 (error "No current article selected"))
8284 ;; Remove old bookmark, if one exists.
8285 (let ((old (assq article gnus-newsgroup-bookmarks)))
8287 (setq gnus-newsgroup-bookmarks
8288 (delq old gnus-newsgroup-bookmarks))))
8289 ;; Set the new bookmark, which is on the form
8290 ;; (article-number . line-number-in-body).
8294 (set-buffer gnus-article-buffer)
8298 (goto-char (point-min))
8299 (search-forward "\n\n" nil t)
8302 gnus-newsgroup-bookmarks)
8303 (gnus-message 6 "A bookmark has been added to the current article."))
8305 (defun gnus-summary-remove-bookmark (article)
8306 "Remove the bookmark from the current article."
8307 (interactive (list (gnus-summary-article-number)))
8308 ;; Remove old bookmark, if one exists.
8309 (let ((old (assq article gnus-newsgroup-bookmarks)))
8312 (setq gnus-newsgroup-bookmarks
8313 (delq old gnus-newsgroup-bookmarks))
8314 (gnus-message 6 "Removed bookmark."))
8315 (gnus-message 6 "No bookmark in current article."))))
8317 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8318 (defun gnus-summary-mark-as-dormant (n)
8319 "Mark N articles forward as dormant.
8320 If N is negative, mark backward instead. The difference between N and
8321 the actual number of articles marked is returned."
8323 (gnus-summary-mark-forward n gnus-dormant-mark))
8325 (defun gnus-summary-set-process-mark (article)
8326 "Set the process mark on ARTICLE and update the summary line."
8327 (setq gnus-newsgroup-processable
8329 (delq article gnus-newsgroup-processable)))
8330 (when (gnus-summary-goto-subject article)
8331 (gnus-summary-show-thread)
8332 (gnus-summary-goto-subject article)
8333 (gnus-summary-update-secondary-mark article)))
8335 (defun gnus-summary-remove-process-mark (article)
8336 "Remove the process mark from ARTICLE and update the summary line."
8337 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8338 (when (gnus-summary-goto-subject article)
8339 (gnus-summary-show-thread)
8340 (gnus-summary-goto-subject article)
8341 (gnus-summary-update-secondary-mark article)))
8343 (defun gnus-summary-set-saved-mark (article)
8344 "Set the process mark on ARTICLE and update the summary line."
8345 (push article gnus-newsgroup-saved)
8346 (when (gnus-summary-goto-subject article)
8347 (gnus-summary-update-secondary-mark article)))
8349 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8350 "Mark N articles as read forwards.
8351 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8352 The difference between N and the actual number of articles marked is
8354 Iff NO-EXPIRE, auto-expiry will be inhibited."
8356 (gnus-summary-show-thread)
8357 (let ((backward (< n 0))
8358 (gnus-summary-goto-unread
8359 (and gnus-summary-goto-unread
8360 (not (eq gnus-summary-goto-unread 'never))
8361 (not (memq mark (list gnus-unread-mark
8362 gnus-ticked-mark gnus-dormant-mark)))))
8364 (mark (or mark gnus-del-mark)))
8366 (gnus-summary-mark-article nil mark no-expire)
8367 (zerop (gnus-summary-next-subject
8369 (and gnus-summary-goto-unread
8370 (not (eq gnus-summary-goto-unread 'never)))
8374 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8375 (gnus-summary-recenter)
8376 (gnus-summary-position-point)
8377 (gnus-set-mode-line 'summary)
8380 (defun gnus-summary-mark-article-as-read (mark)
8381 "Mark the current article quickly as read with MARK."
8382 (let ((article (gnus-summary-article-number)))
8383 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8384 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8385 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8386 (push (cons article mark) gnus-newsgroup-reads)
8387 ;; Possibly remove from cache, if that is used.
8388 (when gnus-use-cache
8389 (gnus-cache-enter-remove-article article))
8390 ;; Allow the backend to change the mark.
8391 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8392 ;; Check for auto-expiry.
8393 (when (and gnus-newsgroup-auto-expire
8394 (memq mark gnus-auto-expirable-marks))
8395 (setq mark gnus-expirable-mark)
8396 ;; Let the backend know about the mark change.
8397 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8398 (push article gnus-newsgroup-expirable))
8399 ;; Set the mark in the buffer.
8400 (gnus-summary-update-mark mark 'unread)
8403 (defun gnus-summary-mark-article-as-unread (mark)
8404 "Mark the current article quickly as unread with MARK."
8405 (let* ((article (gnus-summary-article-number))
8406 (old-mark (gnus-summary-article-mark article)))
8407 ;; Allow the backend to change the mark.
8408 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8409 (if (eq mark old-mark)
8413 (gnus-error 1 "Can't mark negative article numbers")
8415 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8416 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8417 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8418 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8419 (cond ((= mark gnus-ticked-mark)
8420 (push article gnus-newsgroup-marked))
8421 ((= mark gnus-dormant-mark)
8422 (push article gnus-newsgroup-dormant))
8424 (push article gnus-newsgroup-unreads)))
8425 (gnus-pull article gnus-newsgroup-reads)
8427 ;; See whether the article is to be put in the cache.
8429 (vectorp (gnus-summary-article-header article))
8431 (gnus-cache-possibly-enter-article
8432 gnus-newsgroup-name article
8433 (gnus-summary-article-header article)
8434 (= mark gnus-ticked-mark)
8435 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8438 (gnus-summary-update-mark mark 'unread)
8441 (defun gnus-summary-mark-article (&optional article mark no-expire)
8442 "Mark ARTICLE with MARK. MARK can be any character.
8443 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8444 `??' (dormant) and `?E' (expirable).
8445 If MARK is nil, then the default character `?r' is used.
8446 If ARTICLE is nil, then the article on the current line will be
8448 Iff NO-EXPIRE, auto-expiry will be inhibited."
8449 ;; The mark might be a string.
8450 (when (stringp mark)
8451 (setq mark (aref mark 0)))
8452 ;; If no mark is given, then we check auto-expiring.
8454 (setq mark gnus-del-mark))
8455 (when (and (not no-expire)
8456 gnus-newsgroup-auto-expire
8457 (memq mark gnus-auto-expirable-marks))
8458 (setq mark gnus-expirable-mark))
8459 (let ((article (or article (gnus-summary-article-number)))
8460 (old-mark (gnus-summary-article-mark article)))
8461 ;; Allow the backend to change the mark.
8462 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8463 (if (eq mark old-mark)
8466 (error "No article on current line"))
8467 (if (not (if (or (= mark gnus-unread-mark)
8468 (= mark gnus-ticked-mark)
8469 (= mark gnus-dormant-mark))
8470 (gnus-mark-article-as-unread article mark)
8471 (gnus-mark-article-as-read article mark)))
8473 ;; See whether the article is to be put in the cache.
8475 (not (= mark gnus-canceled-mark))
8476 (vectorp (gnus-summary-article-header article))
8478 (gnus-cache-possibly-enter-article
8479 gnus-newsgroup-name article
8480 (gnus-summary-article-header article)
8481 (= mark gnus-ticked-mark)
8482 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8484 (when (gnus-summary-goto-subject article nil t)
8485 (let ((buffer-read-only nil))
8486 (gnus-summary-show-thread)
8488 (gnus-summary-update-mark mark 'unread)
8491 (defun gnus-summary-update-secondary-mark (article)
8492 "Update the secondary (read, process, cache) mark."
8493 (gnus-summary-update-mark
8494 (cond ((memq article gnus-newsgroup-processable)
8496 ((memq article gnus-newsgroup-cached)
8498 ((memq article gnus-newsgroup-replied)
8500 ((memq article gnus-newsgroup-saved)
8502 (t gnus-unread-mark))
8504 (when (gnus-visual-p 'summary-highlight 'highlight)
8505 (gnus-run-hooks 'gnus-summary-update-hook))
8508 (defun gnus-summary-update-mark (mark type)
8509 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8510 (buffer-read-only nil))
8511 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8513 (when (looking-at "\r")
8515 (when (<= (+ forward (point)) (point-max))
8516 ;; Go to the right position on the line.
8517 (goto-char (+ forward (point)))
8518 ;; Replace the old mark with the new mark.
8519 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8520 ;; Optionally update the marks by some user rule.
8521 (when (eq type 'unread)
8523 (gnus-data-find (gnus-summary-article-number)) mark)
8524 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8526 (defun gnus-mark-article-as-read (article &optional mark)
8527 "Enter ARTICLE in the pertinent lists and remove it from others."
8528 ;; Make the article expirable.
8529 (let ((mark (or mark gnus-del-mark)))
8530 (if (= mark gnus-expirable-mark)
8531 (push article gnus-newsgroup-expirable)
8532 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8533 ;; Remove from unread and marked lists.
8534 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8535 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8536 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8537 (push (cons article mark) gnus-newsgroup-reads)
8538 ;; Possibly remove from cache, if that is used.
8539 (when gnus-use-cache
8540 (gnus-cache-enter-remove-article article))
8543 (defun gnus-mark-article-as-unread (article &optional mark)
8544 "Enter ARTICLE in the pertinent lists and remove it from others."
8545 (let ((mark (or mark gnus-ticked-mark)))
8548 (gnus-error 1 "Can't mark negative article numbers")
8550 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8551 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8552 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8553 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8555 ;; Unsuppress duplicates?
8556 (when gnus-suppress-duplicates
8557 (gnus-dup-unsuppress-article article))
8559 (cond ((= mark gnus-ticked-mark)
8560 (push article gnus-newsgroup-marked))
8561 ((= mark gnus-dormant-mark)
8562 (push article gnus-newsgroup-dormant))
8564 (push article gnus-newsgroup-unreads)))
8565 (gnus-pull article gnus-newsgroup-reads)
8568 (defalias 'gnus-summary-mark-as-unread-forward
8569 'gnus-summary-tick-article-forward)
8570 (make-obsolete 'gnus-summary-mark-as-unread-forward
8571 'gnus-summary-tick-article-forward)
8572 (defun gnus-summary-tick-article-forward (n)
8573 "Tick N articles forwards.
8574 If N is negative, tick backwards instead.
8575 The difference between N and the number of articles ticked is returned."
8577 (gnus-summary-mark-forward n gnus-ticked-mark))
8579 (defalias 'gnus-summary-mark-as-unread-backward
8580 'gnus-summary-tick-article-backward)
8581 (make-obsolete 'gnus-summary-mark-as-unread-backward
8582 'gnus-summary-tick-article-backward)
8583 (defun gnus-summary-tick-article-backward (n)
8584 "Tick N articles backwards.
8585 The difference between N and the number of articles ticked is returned."
8587 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8589 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8590 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8591 (defun gnus-summary-tick-article (&optional article clear-mark)
8592 "Mark current article as unread.
8593 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8594 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8596 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8599 (defun gnus-summary-mark-as-read-forward (n)
8600 "Mark N articles as read forwards.
8601 If N is negative, mark backwards instead.
8602 The difference between N and the actual number of articles marked is
8605 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8607 (defun gnus-summary-mark-as-read-backward (n)
8608 "Mark the N articles as read backwards.
8609 The difference between N and the actual number of articles marked is
8612 (gnus-summary-mark-forward
8613 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8615 (defun gnus-summary-mark-as-read (&optional article mark)
8616 "Mark current article as read.
8617 ARTICLE specifies the article to be marked as read.
8618 MARK specifies a string to be inserted at the beginning of the line."
8619 (gnus-summary-mark-article article mark))
8621 (defun gnus-summary-clear-mark-forward (n)
8622 "Clear marks from N articles forward.
8623 If N is negative, clear backward instead.
8624 The difference between N and the number of marks cleared is returned."
8626 (gnus-summary-mark-forward n gnus-unread-mark))
8628 (defun gnus-summary-clear-mark-backward (n)
8629 "Clear marks from N articles backward.
8630 The difference between N and the number of marks cleared is returned."
8632 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8634 (defun gnus-summary-mark-unread-as-read ()
8635 "Intended to be used by `gnus-summary-mark-article-hook'."
8636 (when (memq gnus-current-article gnus-newsgroup-unreads)
8637 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8639 (defun gnus-summary-mark-read-and-unread-as-read ()
8640 "Intended to be used by `gnus-summary-mark-article-hook'."
8641 (let ((mark (gnus-summary-article-mark)))
8642 (when (or (gnus-unread-mark-p mark)
8643 (gnus-read-mark-p mark))
8644 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8646 (defun gnus-summary-mark-region-as-read (point mark all)
8647 "Mark all unread articles between point and mark as read.
8648 If given a prefix, mark all articles between point and mark as read,
8649 even ticked and dormant ones."
8650 (interactive "r\nP")
8659 (memq (setq article (gnus-summary-article-number))
8660 gnus-newsgroup-unreads))
8661 (gnus-summary-mark-article article gnus-del-mark))
8663 (gnus-summary-find-next))))))
8665 (defun gnus-summary-mark-below (score mark)
8666 "Mark articles with score less than SCORE with MARK."
8667 (interactive "P\ncMark: ")
8668 (setq score (if score
8669 (prefix-numeric-value score)
8670 (or gnus-summary-default-score 0)))
8672 (set-buffer gnus-summary-buffer)
8673 (goto-char (point-min))
8676 (and (< (gnus-summary-article-score) score)
8677 (gnus-summary-mark-article nil mark))
8678 (gnus-summary-find-next)))))
8680 (defun gnus-summary-kill-below (&optional score)
8681 "Mark articles with score below SCORE as read."
8683 (gnus-summary-mark-below score gnus-killed-mark))
8685 (defun gnus-summary-clear-above (&optional score)
8686 "Clear all marks from articles with score above SCORE."
8688 (gnus-summary-mark-above score gnus-unread-mark))
8690 (defun gnus-summary-tick-above (&optional score)
8691 "Tick all articles with score above SCORE."
8693 (gnus-summary-mark-above score gnus-ticked-mark))
8695 (defun gnus-summary-mark-above (score mark)
8696 "Mark articles with score over SCORE with MARK."
8697 (interactive "P\ncMark: ")
8698 (setq score (if score
8699 (prefix-numeric-value score)
8700 (or gnus-summary-default-score 0)))
8702 (set-buffer gnus-summary-buffer)
8703 (goto-char (point-min))
8705 (when (> (gnus-summary-article-score) score)
8706 (gnus-summary-mark-article nil mark))
8708 (gnus-summary-find-next)))))
8710 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8711 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8712 (defun gnus-summary-limit-include-expunged (&optional no-error)
8713 "Display all the hidden articles that were expunged for low scores."
8715 (let ((buffer-read-only nil))
8716 (let ((scored gnus-newsgroup-scored)
8719 (unless (gnus-summary-goto-subject (caar scored))
8720 (and (setq h (gnus-summary-article-header (caar scored)))
8721 (< (cdar scored) gnus-summary-expunge-below)
8723 (setq scored (cdr scored)))
8725 (when (not no-error)
8726 (error "No expunged articles hidden"))
8727 (goto-char (point-min))
8728 (gnus-summary-prepare-unthreaded (nreverse headers))
8729 (goto-char (point-min))
8730 (gnus-summary-position-point)
8733 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8734 "Mark all unread articles in this newsgroup as read.
8735 If prefix argument ALL is non-nil, ticked and dormant articles will
8736 also be marked as read.
8737 If QUIETLY is non-nil, no questions will be asked.
8738 If TO-HERE is non-nil, it should be a point in the buffer. All
8739 articles before this point will be marked as read.
8740 Note that this function will only catch up the unread article
8741 in the current summary buffer limitation.
8742 The number of articles marked as read is returned."
8747 (not gnus-interactive-catchup) ;Without confirmation?
8751 "Mark absolutely all articles as read? "
8752 "Mark all unread articles as read? ")))
8754 (not gnus-newsgroup-adaptive)
8755 (not gnus-newsgroup-auto-expire)
8756 (not gnus-suppress-duplicates)
8757 (or (not gnus-use-cache)
8758 (eq gnus-use-cache 'passive)))
8761 (setq gnus-newsgroup-marked nil
8762 gnus-newsgroup-dormant nil))
8763 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8764 ;; We actually mark all articles as canceled, which we
8765 ;; have to do when using auto-expiry or adaptive scoring.
8766 (gnus-summary-show-all-threads)
8767 (when (gnus-summary-first-subject (not all) t)
8769 (if to-here (< (point) to-here) t)
8770 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8771 (gnus-summary-find-next (not all) nil nil t))))
8772 (gnus-set-mode-line 'summary))
8774 (gnus-summary-position-point)))
8776 (defun gnus-summary-catchup-to-here (&optional all)
8777 "Mark all unticked articles before the current one as read.
8778 If ALL is non-nil, also mark ticked and dormant articles as read."
8781 (gnus-save-hidden-threads
8782 (let ((beg (point)))
8783 ;; We check that there are unread articles.
8784 (when (or all (gnus-summary-find-prev))
8785 (gnus-summary-catchup all t beg)))))
8786 (gnus-summary-position-point))
8788 (defun gnus-summary-catchup-all (&optional quietly)
8789 "Mark all articles in this newsgroup as read."
8791 (gnus-summary-catchup t quietly))
8793 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8794 "Mark all unread articles in this group as read, then exit.
8795 If prefix argument ALL is non-nil, all articles are marked as read."
8797 (when (gnus-summary-catchup all quietly nil 'fast)
8798 ;; Select next newsgroup or exit.
8799 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8800 (eq gnus-auto-select-next 'quietly))
8801 (gnus-summary-next-group nil)
8802 (gnus-summary-exit))))
8804 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8805 "Mark all articles in this newsgroup as read, and then exit."
8807 (gnus-summary-catchup-and-exit t quietly))
8809 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8810 "Mark all articles in this group as read and select the next group.
8811 If given a prefix, mark all articles, unread as well as ticked, as
8815 (gnus-summary-catchup all))
8816 (gnus-summary-next-group))
8822 (defmacro gnus-with-article (article &rest forms)
8823 "Select ARTICLE and perform FORMS in the original article buffer.
8824 Then replace the article with the result."
8826 ;; We don't want the article to be marked as read.
8827 (let (gnus-mark-article-hook)
8828 (gnus-summary-select-article t t nil ,article))
8829 (set-buffer gnus-original-article-buffer)
8831 (if (not (gnus-check-backend-function
8832 'request-replace-article (car gnus-article-current)))
8833 (gnus-message 5 "Read-only group; not replacing")
8834 (unless (gnus-request-replace-article
8835 ,article (car gnus-article-current)
8837 (error "Couldn't replace article")))
8838 ;; The cache and backlog have to be flushed somewhat.
8839 (when gnus-keep-backlog
8840 (gnus-backlog-remove-article
8841 (car gnus-article-current) (cdr gnus-article-current)))
8842 (when gnus-use-cache
8843 (gnus-cache-update-article
8844 (car gnus-article-current) (cdr gnus-article-current)))))
8846 (put 'gnus-with-article 'lisp-indent-function 1)
8847 (put 'gnus-with-article 'edebug-form-spec '(form body))
8849 ;; Thread-based commands.
8851 (defun gnus-summary-articles-in-thread (&optional article)
8852 "Return a list of all articles in the current thread.
8853 If ARTICLE is non-nil, return all articles in the thread that starts
8855 (let* ((article (or article (gnus-summary-article-number)))
8856 (data (gnus-data-find-list article))
8857 (top-level (gnus-data-level (car data)))
8859 (cond ((null gnus-thread-operation-ignore-subject)
8860 (gnus-simplify-subject-re
8861 (mail-header-subject (gnus-data-header (car data)))))
8862 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8863 (gnus-simplify-subject-fuzzy
8864 (mail-header-subject (gnus-data-header (car data)))))
8866 (end-point (save-excursion
8867 (if (gnus-summary-go-to-next-thread)
8868 (point) (point-max))))
8871 (< (gnus-data-pos (car data)) end-point))
8872 (when (or (not top-subject)
8873 (string= top-subject
8874 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8875 (gnus-simplify-subject-fuzzy
8876 (mail-header-subject
8877 (gnus-data-header (car data))))
8878 (gnus-simplify-subject-re
8879 (mail-header-subject
8880 (gnus-data-header (car data)))))))
8881 (push (gnus-data-number (car data)) articles))
8882 (unless (and (setq data (cdr data))
8883 (> (gnus-data-level (car data)) top-level))
8885 ;; Return the list of articles.
8886 (nreverse articles)))
8888 (defun gnus-summary-rethread-current ()
8889 "Rethread the thread the current article is part of."
8891 (let* ((gnus-show-threads t)
8892 (article (gnus-summary-article-number))
8893 (id (mail-header-id (gnus-summary-article-header)))
8894 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8896 (error "No article on the current line"))
8897 (gnus-rebuild-thread id)
8898 (gnus-summary-goto-subject article)))
8900 (defun gnus-summary-reparent-thread ()
8901 "Make the current article child of the marked (or previous) article.
8903 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8904 is non-nil or the Subject: of both articles are the same."
8906 (unless (not (gnus-group-read-only-p))
8907 (error "The current newsgroup does not support article editing"))
8908 (unless (<= (length gnus-newsgroup-processable) 1)
8909 (error "No more than one article may be marked"))
8910 (save-window-excursion
8911 (let ((gnus-article-buffer " *reparent*")
8912 (current-article (gnus-summary-article-number))
8913 ;; First grab the marked article, otherwise one line up.
8914 (parent-article (if (not (null gnus-newsgroup-processable))
8915 (car gnus-newsgroup-processable)
8917 (if (eq (forward-line -1) 0)
8918 (gnus-summary-article-number)
8919 (error "Beginning of summary buffer"))))))
8920 (unless (not (eq current-article parent-article))
8921 (error "An article may not be self-referential"))
8922 (let ((message-id (mail-header-id
8923 (gnus-summary-article-header parent-article))))
8924 (unless (and message-id (not (equal message-id "")))
8925 (error "No message-id in desired parent"))
8926 (gnus-with-article current-article
8928 (goto-char (point-min))
8929 (message-narrow-to-head)
8930 (if (re-search-forward "^References: " nil t)
8932 (re-search-forward "^[^ \t]" nil t)
8935 (insert " " message-id))
8936 (insert "References: " message-id "\n"))))
8937 (set-buffer gnus-summary-buffer)
8938 (gnus-summary-unmark-all-processable)
8939 (gnus-summary-update-article current-article)
8940 (gnus-summary-rethread-current)
8941 (gnus-message 3 "Article %d is now the child of article %d"
8942 current-article parent-article)))))
8944 (defun gnus-summary-toggle-threads (&optional arg)
8945 "Toggle showing conversation threads.
8946 If ARG is positive number, turn showing conversation threads on."
8948 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8949 (setq gnus-show-threads
8950 (if (null arg) (not gnus-show-threads)
8951 (> (prefix-numeric-value arg) 0)))
8952 (gnus-summary-prepare)
8953 (gnus-summary-goto-subject current)
8954 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8955 (gnus-summary-position-point)))
8957 (defun gnus-summary-show-all-threads ()
8961 (let ((buffer-read-only nil))
8962 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8963 (gnus-summary-position-point))
8965 (defun gnus-summary-show-thread ()
8966 "Show thread subtrees.
8967 Returns nil if no thread was there to be shown."
8969 (let ((buffer-read-only nil)
8971 ;; first goto end then to beg, to have point at beg after let
8972 (end (progn (end-of-line) (point)))
8973 (beg (progn (beginning-of-line) (point))))
8975 ;; Any hidden lines here?
8976 (search-forward "\r" end t)
8977 (subst-char-in-region beg end ?\^M ?\n t)
8979 (gnus-summary-position-point))))
8981 (defun gnus-summary-hide-all-threads ()
8982 "Hide all thread subtrees."
8985 (goto-char (point-min))
8986 (gnus-summary-hide-thread)
8987 (while (zerop (gnus-summary-next-thread 1 t))
8988 (gnus-summary-hide-thread)))
8989 (gnus-summary-position-point))
8991 (defun gnus-summary-hide-thread ()
8992 "Hide thread subtrees.
8993 Returns nil if no threads were there to be hidden."
8995 (let ((buffer-read-only nil)
8997 (article (gnus-summary-article-number)))
8999 ;; Go forward until either the buffer ends or the subthread
9001 (when (and (not (eobp))
9002 (or (zerop (gnus-summary-next-thread 1 t))
9003 (goto-char (point-max))))
9005 (if (and (> (point) start)
9006 (search-backward "\n" start t))
9008 (subst-char-in-region start (point) ?\n ?\^M)
9009 (gnus-summary-goto-subject article))
9013 (defun gnus-summary-go-to-next-thread (&optional previous)
9014 "Go to the same level (or less) next thread.
9015 If PREVIOUS is non-nil, go to previous thread instead.
9016 Return the article number moved to, or nil if moving was impossible."
9017 (let ((level (gnus-summary-thread-level))
9018 (way (if previous -1 1))
9021 (while (and (not (eobp))
9022 (< level (gnus-summary-thread-level)))
9030 (gnus-summary-article-number)
9033 (defun gnus-summary-next-thread (n &optional silent)
9034 "Go to the same level next N'th thread.
9035 If N is negative, search backward instead.
9036 Returns the difference between N and the number of skips actually
9039 If SILENT, don't output messages."
9041 (let ((backward (< n 0))
9044 (gnus-summary-go-to-next-thread backward))
9047 (gnus-summary-position-point))
9048 (when (and (not silent) (/= 0 n))
9049 (gnus-message 7 "No more threads"))
9052 (defun gnus-summary-prev-thread (n)
9053 "Go to the same level previous N'th thread.
9054 Returns the difference between N and the number of skips actually
9057 (gnus-summary-next-thread (- n)))
9059 (defun gnus-summary-go-down-thread ()
9060 "Go down one level in the current thread."
9061 (let ((children (gnus-summary-article-children)))
9063 (gnus-summary-goto-subject (car children)))))
9065 (defun gnus-summary-go-up-thread ()
9066 "Go up one level in the current thread."
9067 (let ((parent (gnus-summary-article-parent)))
9069 (gnus-summary-goto-subject parent))))
9071 (defun gnus-summary-down-thread (n)
9072 "Go down thread N steps.
9073 If N is negative, go up instead.
9074 Returns the difference between N and how many steps down that were
9080 (if up (gnus-summary-go-up-thread)
9081 (gnus-summary-go-down-thread)))
9083 (gnus-summary-position-point)
9085 (gnus-message 7 "Can't go further"))
9088 (defun gnus-summary-up-thread (n)
9089 "Go up thread N steps.
9090 If N is negative, go up instead.
9091 Returns the difference between N and how many steps down that were
9094 (gnus-summary-down-thread (- n)))
9096 (defun gnus-summary-top-thread ()
9097 "Go to the top of the thread."
9099 (while (gnus-summary-go-up-thread))
9100 (gnus-summary-article-number))
9102 (defun gnus-summary-kill-thread (&optional unmark)
9103 "Mark articles under current thread as read.
9104 If the prefix argument is positive, remove any kinds of marks.
9105 If the prefix argument is negative, tick articles instead."
9108 (setq unmark (prefix-numeric-value unmark)))
9109 (let ((articles (gnus-summary-articles-in-thread)))
9111 ;; Expand the thread.
9112 (gnus-summary-show-thread)
9113 ;; Mark all the articles.
9115 (gnus-summary-goto-subject (car articles))
9116 (cond ((null unmark)
9117 (gnus-summary-mark-article-as-read gnus-killed-mark))
9119 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9121 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9122 (setq articles (cdr articles))))
9123 ;; Hide killed subtrees.
9125 gnus-thread-hide-killed
9126 (gnus-summary-hide-thread))
9127 ;; If marked as read, go to next unread subject.
9129 ;; Go to next unread subject.
9130 (gnus-summary-next-subject 1 t)))
9131 (gnus-set-mode-line 'summary))
9133 ;; Summary sorting commands
9135 (defun gnus-summary-sort-by-number (&optional reverse)
9136 "Sort the summary buffer by article number.
9137 Argument REVERSE means reverse order."
9139 (gnus-summary-sort 'number reverse))
9141 (defun gnus-summary-sort-by-author (&optional reverse)
9142 "Sort the summary buffer by author name alphabetically.
9143 If `case-fold-search' is non-nil, case of letters is ignored.
9144 Argument REVERSE means reverse order."
9146 (gnus-summary-sort 'author reverse))
9148 (defun gnus-summary-sort-by-subject (&optional reverse)
9149 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9150 If `case-fold-search' is non-nil, case of letters is ignored.
9151 Argument REVERSE means reverse order."
9153 (gnus-summary-sort 'subject reverse))
9155 (defun gnus-summary-sort-by-date (&optional reverse)
9156 "Sort the summary buffer by date.
9157 Argument REVERSE means reverse order."
9159 (gnus-summary-sort 'date reverse))
9161 (defun gnus-summary-sort-by-score (&optional reverse)
9162 "Sort the summary buffer by score.
9163 Argument REVERSE means reverse order."
9165 (gnus-summary-sort 'score reverse))
9167 (defun gnus-summary-sort-by-lines (&optional reverse)
9168 "Sort the summary buffer by the number of lines.
9169 Argument REVERSE means reverse order."
9171 (gnus-summary-sort 'lines reverse))
9173 (defun gnus-summary-sort-by-chars (&optional reverse)
9174 "Sort the summary buffer by article length.
9175 Argument REVERSE means reverse order."
9177 (gnus-summary-sort 'chars reverse))
9179 (defun gnus-summary-sort (predicate reverse)
9180 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9181 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9182 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9183 (gnus-thread-sort-functions
9188 (gnus-sort-gathered-threads-function
9189 gnus-thread-sort-functions)
9190 (gnus-article-sort-functions
9196 (gnus-summary-prepare-hook nil))
9197 ;; We do the sorting by regenerating the threads.
9198 (gnus-summary-prepare)
9199 ;; Hide subthreads if needed.
9200 (when (and gnus-show-threads gnus-thread-hide-subtree)
9201 (gnus-summary-hide-all-threads))))
9203 ;; Summary saving commands.
9205 (defun gnus-summary-save-article (&optional n not-saved)
9206 "Save the current article using the default saver function.
9207 If N is a positive number, save the N next articles.
9208 If N is a negative number, save the N previous articles.
9209 If N is nil and any articles have been marked with the process mark,
9210 save those articles instead.
9211 The variable `gnus-default-article-saver' specifies the saver function."
9213 (let* ((articles (gnus-summary-work-articles n))
9214 (save-buffer (save-excursion
9215 (nnheader-set-temp-buffer " *Gnus Save*")))
9216 (num (length articles))
9218 (dolist (article articles)
9219 (setq header (gnus-summary-article-header article))
9220 (if (not (vectorp header))
9221 ;; This is a pseudo-article.
9222 (if (assq 'name header)
9223 (gnus-copy-file (cdr (assq 'name header)))
9224 (gnus-message 1 "Article %d is unsaveable" article))
9225 ;; This is a real article.
9226 (save-window-excursion
9227 (gnus-summary-select-article t nil nil article))
9229 (set-buffer save-buffer)
9231 (insert-buffer-substring gnus-original-article-buffer))
9232 (setq file (gnus-article-save save-buffer file num))
9233 (gnus-summary-remove-process-mark article)
9235 (gnus-summary-set-saved-mark article))))
9236 (gnus-kill-buffer save-buffer)
9237 (gnus-summary-position-point)
9238 (gnus-set-mode-line 'summary)
9241 (defun gnus-summary-pipe-output (&optional arg)
9242 "Pipe the current article to a subprocess.
9243 If N is a positive number, pipe the N next articles.
9244 If N is a negative number, pipe the N previous articles.
9245 If N is nil and any articles have been marked with the process mark,
9246 pipe those articles instead."
9249 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9250 (gnus-summary-save-article arg t))
9251 (gnus-configure-windows 'pipe))
9253 (defun gnus-summary-save-article-mail (&optional arg)
9254 "Append the current article to an mail file.
9255 If N is a positive number, save the N next articles.
9256 If N is a negative number, save the N previous articles.
9257 If N is nil and any articles have been marked with the process mark,
9258 save those articles instead."
9261 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9262 (gnus-summary-save-article arg)))
9264 (defun gnus-summary-save-article-rmail (&optional arg)
9265 "Append the current article to an rmail file.
9266 If N is a positive number, save the N next articles.
9267 If N is a negative number, save the N previous articles.
9268 If N is nil and any articles have been marked with the process mark,
9269 save those articles instead."
9272 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9273 (gnus-summary-save-article arg)))
9275 (defun gnus-summary-save-article-file (&optional arg)
9276 "Append the current article to a file.
9277 If N is a positive number, save the N next articles.
9278 If N is a negative number, save the N previous articles.
9279 If N is nil and any articles have been marked with the process mark,
9280 save those articles instead."
9283 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9284 (gnus-summary-save-article arg)))
9286 (defun gnus-summary-write-article-file (&optional arg)
9287 "Write the current article to a file, deleting the previous file.
9288 If N is a positive number, save the N next articles.
9289 If N is a negative number, save the N previous articles.
9290 If N is nil and any articles have been marked with the process mark,
9291 save those articles instead."
9294 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9295 (gnus-summary-save-article arg)))
9297 (defun gnus-summary-save-article-body-file (&optional arg)
9298 "Append the current article body to a file.
9299 If N is a positive number, save the N next articles.
9300 If N is a negative number, save the N previous articles.
9301 If N is nil and any articles have been marked with the process mark,
9302 save those articles instead."
9305 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9306 (gnus-summary-save-article arg)))
9308 (defun gnus-summary-pipe-message (program)
9309 "Pipe the current article through PROGRAM."
9310 (interactive "sProgram: ")
9311 (gnus-summary-select-article)
9312 (let ((mail-header-separator ""))
9313 (gnus-eval-in-buffer-window gnus-article-buffer
9316 (let ((start (window-start))
9318 (message-pipe-buffer-body program)
9319 (set-window-start (get-buffer-window (current-buffer)) start))))))
9321 (defun gnus-get-split-value (methods)
9322 "Return a value based on the split METHODS."
9323 (let (split-name method result match)
9326 (set-buffer gnus-original-article-buffer)
9328 (nnheader-narrow-to-headers)
9329 (while (and methods (not split-name))
9330 (goto-char (point-min))
9331 (setq method (pop methods))
9332 (setq match (car method))
9335 ;; Regular expression.
9337 (re-search-forward match nil t)))
9338 ((gnus-functionp match)
9342 (setq result (funcall match gnus-newsgroup-name))))
9347 (setq result (eval match)))))
9348 (setq split-name (cdr method))
9349 (cond ((stringp result)
9350 (push (expand-file-name
9351 result gnus-article-save-directory)
9354 (setq split-name (append result split-name)))))))))
9355 (nreverse split-name)))
9357 (defun gnus-valid-move-group-p (group)
9360 (symbol-value group)
9361 (gnus-get-function (gnus-find-method-for-group
9362 (symbol-name group)) 'request-accept-article t)))
9364 (defun gnus-read-move-group-name (prompt default articles prefix)
9365 "Read a group name."
9366 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9367 (minibuffer-confirm-incomplete nil) ; XEmacs
9371 (if (> (length articles) 1)
9372 (format "these %d articles" (length articles))
9377 (gnus-completing-read default prom
9379 'gnus-valid-move-group-p
9381 'gnus-group-history))
9382 ((= 1 (length split-name))
9383 (gnus-completing-read (car split-name) prom
9385 'gnus-valid-move-group-p
9387 'gnus-group-history))
9389 (gnus-completing-read nil prom
9390 (mapcar (lambda (el) (list el))
9391 (nreverse split-name))
9393 'gnus-group-history))))
9394 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9396 (if (or (string= to-newsgroup "")
9397 (string= to-newsgroup prefix))
9398 (setq to-newsgroup default))
9399 (unless to-newsgroup
9400 (error "No group name entered"))
9401 (or (gnus-active to-newsgroup)
9402 (gnus-activate-group to-newsgroup nil nil to-method)
9403 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9405 (or (and (gnus-request-create-group to-newsgroup to-method)
9406 (gnus-activate-group
9407 to-newsgroup nil nil to-method)
9408 (gnus-subscribe-group to-newsgroup))
9409 (error "Couldn't create group %s" to-newsgroup)))
9410 (error "No such group: %s" to-newsgroup)))
9413 (defun gnus-summary-save-parts (type dir n &optional reverse)
9414 "Save parts matching TYPE to DIR.
9415 If REVERSE, save parts that do not match TYPE."
9417 (list (read-string "Save parts of type: "
9418 (or (car gnus-summary-save-parts-type-history)
9419 gnus-summary-save-parts-default-mime)
9420 'gnus-summary-save-parts-type-history)
9421 (setq gnus-summary-save-parts-last-directory
9422 (read-file-name "Save to directory: "
9423 gnus-summary-save-parts-last-directory
9425 current-prefix-arg))
9426 (gnus-summary-iterate n
9427 (let ((gnus-display-mime-function nil)
9428 (gnus-inhibit-treatment t))
9429 (gnus-summary-select-article))
9431 (set-buffer gnus-article-buffer)
9432 (let ((handles (or gnus-article-mime-handles
9433 (mm-dissect-buffer) (mm-uu-dissect))))
9435 (gnus-summary-save-parts-1 type dir handles reverse)
9436 (unless gnus-article-mime-handles ;; Don't destroy this case.
9437 (mm-destroy-parts handles)))))))
9439 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9440 (if (stringp (car handle))
9441 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9444 (not (string-match type (mm-handle-media-type handle)))
9445 (string-match type (mm-handle-media-type handle)))
9446 (let ((file (expand-file-name
9447 (file-name-nondirectory
9449 (mail-content-type-get
9450 (mm-handle-disposition handle) 'filename)
9451 (concat gnus-newsgroup-name
9452 "." (number-to-string
9453 (cdr gnus-article-current)))))
9455 (unless (file-exists-p file)
9456 (mm-save-part-to-file handle file))))))
9458 ;; Summary extract commands
9460 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9461 (let ((buffer-read-only nil)
9462 (article (gnus-summary-article-number))
9464 (unless (gnus-summary-goto-subject article)
9465 (error "No such article: %d" article))
9466 (gnus-summary-position-point)
9467 ;; If all commands are to be bunched up on one line, we collect
9469 (unless gnus-view-pseudos-separately
9470 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9473 (setq action (cdr (assq 'action (car ps))))
9474 (setq files (list (cdr (assq 'name (car ps)))))
9475 (while (and ps (cdr ps)
9476 (string= (or action "1")
9477 (or (cdr (assq 'action (cadr ps))) "2")))
9478 (push (cdr (assq 'name (cadr ps))) files)
9479 (setcdr ps (cddr ps)))
9481 (when (not (string-match "%s" action))
9484 (when (assq 'execute (car ps))
9485 (setcdr (assq 'execute (car ps))
9486 (funcall (if (string-match "%s" action)
9493 (gnus-quote-arg-for-sh-or-csh f)))
9495 (setq ps (cdr ps)))))
9496 (if (and gnus-view-pseudos (not not-view))
9498 (when (assq 'execute (car pslist))
9499 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9500 (eq gnus-view-pseudos 'not-confirm)))
9501 (setq pslist (cdr pslist)))
9504 (setq after-article (or (cdr (assq 'article (car pslist)))
9505 (gnus-summary-article-number)))
9506 (gnus-summary-goto-subject after-article)
9509 (insert " " (file-name-nondirectory
9510 (cdr (assq 'name (car pslist))))
9511 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9513 (forward-line -1) ; back to `b'
9514 (gnus-add-text-properties
9515 b (1- e) (list 'gnus-number gnus-reffed-article-number
9516 gnus-mouse-face-prop gnus-mouse-face))
9518 after-article gnus-reffed-article-number
9519 gnus-unread-mark b (car pslist) 0 (- e b))
9520 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9521 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9522 (setq pslist (cdr pslist)))))))
9524 (defun gnus-pseudos< (p1 p2)
9525 (let ((c1 (cdr (assq 'action p1)))
9526 (c2 (cdr (assq 'action p2))))
9527 (and c1 c2 (string< c1 c2))))
9529 (defun gnus-request-pseudo-article (props)
9530 (cond ((assq 'execute props)
9531 (gnus-execute-command (cdr (assq 'execute props)))))
9532 (let ((gnus-current-article (gnus-summary-article-number)))
9533 (gnus-run-hooks 'gnus-mark-article-hook)))
9535 (defun gnus-execute-command (command &optional automatic)
9537 (gnus-article-setup-buffer)
9538 (set-buffer gnus-article-buffer)
9539 (setq buffer-read-only nil)
9540 (let ((command (if automatic command
9541 (read-string "Command: " (cons command 0)))))
9543 (insert "$ " command "\n\n")
9544 (if gnus-view-pseudo-asynchronously
9545 (start-process "gnus-execute" (current-buffer) shell-file-name
9546 shell-command-switch command)
9547 (call-process shell-file-name nil t nil
9548 shell-command-switch command)))))
9550 ;; Summary kill commands.
9552 (defun gnus-summary-edit-global-kill (article)
9553 "Edit the \"global\" kill file."
9554 (interactive (list (gnus-summary-article-number)))
9555 (gnus-group-edit-global-kill article))
9557 (defun gnus-summary-edit-local-kill ()
9558 "Edit a local kill file applied to the current newsgroup."
9560 (setq gnus-current-headers (gnus-summary-article-header))
9561 (gnus-group-edit-local-kill
9562 (gnus-summary-article-number) gnus-newsgroup-name))
9566 (defun gnus-read-header (id &optional header)
9567 "Read the headers of article ID and enter them into the Gnus system."
9568 (let ((group gnus-newsgroup-name)
9569 (gnus-override-method
9571 gnus-override-method
9572 (and (gnus-news-group-p gnus-newsgroup-name)
9573 (car (gnus-refer-article-methods)))))
9575 ;; First we check to see whether the header in question is already
9578 ;; This is a Message-ID.
9579 (setq header (or header (gnus-id-to-header id)))
9580 ;; This is an article number.
9581 (setq header (or header (gnus-summary-article-header id))))
9583 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9584 ;; We have found the header.
9586 ;; If this is a sparse article, we have to nix out its
9587 ;; previous entry in the thread hashtb.
9589 (gnus-summary-article-sparse-p (mail-header-number header)))
9590 (let* ((parent (gnus-parent-id (mail-header-references header)))
9591 (thread (and parent (gnus-id-to-thread parent))))
9593 (delq (assq header thread) thread))))
9594 ;; We have to really fetch the header to this article.
9596 (set-buffer nntp-server-buffer)
9597 (when (setq where (gnus-request-head id group))
9598 (nnheader-fold-continuation-lines)
9599 (goto-char (point-max))
9601 (goto-char (point-min))
9605 ((cdr where) (cdr where))
9606 (header (mail-header-number header))
9607 (t gnus-reffed-article-number))
9609 (insert " Article retrieved.\n"))
9611 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9612 () ; Malformed head.
9613 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9614 (when (and (stringp id)
9615 (not (string= (gnus-group-real-name group)
9617 ;; If we fetched by Message-ID and the article came
9618 ;; from a different group, we fudge some bogus article
9619 ;; numbers for this article.
9620 (mail-header-set-number header gnus-reffed-article-number))
9622 (set-buffer gnus-summary-buffer)
9623 (decf gnus-reffed-article-number)
9624 (gnus-remove-header (mail-header-number header))
9625 (push header gnus-newsgroup-headers)
9626 (setq gnus-current-headers header)
9627 (push (mail-header-number header) gnus-newsgroup-limit)))
9630 (defun gnus-remove-header (number)
9631 "Remove header NUMBER from `gnus-newsgroup-headers'."
9632 (if (and gnus-newsgroup-headers
9633 (= number (mail-header-number (car gnus-newsgroup-headers))))
9634 (pop gnus-newsgroup-headers)
9635 (let ((headers gnus-newsgroup-headers))
9636 (while (and (cdr headers)
9637 (not (= number (mail-header-number (cadr headers)))))
9640 (setcdr headers (cddr headers))))))
9643 ;;; summary highlights
9646 (defun gnus-highlight-selected-summary ()
9647 "Highlight selected article in summary buffer."
9648 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9649 (when gnus-summary-selected-face
9651 (let* ((beg (progn (beginning-of-line) (point)))
9652 (end (progn (end-of-line) (point)))
9653 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9654 (from (if (get-text-property beg gnus-mouse-face-prop)
9656 (or (next-single-property-change
9657 beg gnus-mouse-face-prop nil end)
9662 (or (next-single-property-change
9663 from gnus-mouse-face-prop nil end)
9665 ;; If no mouse-face prop on line we will have to = from = end,
9666 ;; so we highlight the entire line instead.
9667 (when (= (+ to 2) from)
9670 (if gnus-newsgroup-selected-overlay
9671 ;; Move old overlay.
9673 gnus-newsgroup-selected-overlay from to (current-buffer))
9674 ;; Create new overlay.
9676 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9677 'face gnus-summary-selected-face))))))
9679 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9680 (defun gnus-summary-highlight-line ()
9681 "Highlight current line according to `gnus-summary-highlight'."
9682 (let* ((list gnus-summary-highlight)
9684 (end (progn (end-of-line) (point)))
9685 ;; now find out where the line starts and leave point there.
9686 (beg (progn (beginning-of-line) (point)))
9687 (article (gnus-summary-article-number))
9688 (score (or (cdr (assq (or article gnus-current-article)
9689 gnus-newsgroup-scored))
9690 gnus-summary-default-score 0))
9691 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9692 (inhibit-read-only t))
9693 ;; Eval the cars of the lists until we find a match.
9694 (let ((default gnus-summary-default-score))
9696 (not (eval (caar list))))
9697 (setq list (cdr list))))
9698 (let ((face (cdar list)))
9699 (unless (eq face (get-text-property beg 'face))
9700 (gnus-put-text-property-excluding-characters-with-faces
9702 (setq face (if (boundp face) (symbol-value face) face)))
9703 (when gnus-summary-highlight-line-function
9704 (funcall gnus-summary-highlight-line-function article face))))
9707 (defun gnus-update-read-articles (group unread &optional compute)
9708 "Update the list of read articles in GROUP."
9709 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9710 (entry (gnus-gethash group gnus-newsrc-hashtb))
9711 (info (nth 2 entry))
9713 (unread (sort (copy-sequence unread) '<))
9715 (if (or (not info) (not active))
9716 ;; There is no info on this group if it was, in fact,
9717 ;; killed. Gnus stores no information on killed groups, so
9718 ;; there's nothing to be done.
9719 ;; One could store the information somewhere temporarily,
9720 ;; perhaps... Hmmm...
9722 ;; Remove any negative articles numbers.
9723 (while (and unread (< (car unread) 0))
9724 (setq unread (cdr unread)))
9725 ;; Remove any expired article numbers
9726 (while (and unread (< (car unread) (car active)))
9727 (setq unread (cdr unread)))
9728 ;; Compute the ranges of read articles by looking at the list of
9731 (when (/= (car unread) prev)
9732 (push (if (= prev (1- (car unread))) prev
9733 (cons prev (1- (car unread))))
9735 (setq prev (1+ (car unread)))
9736 (setq unread (cdr unread)))
9737 (when (<= prev (cdr active))
9738 (push (cons prev (cdr active)) read))
9739 (setq read (if (> (length read) 1) (nreverse read) read))
9744 ;; Propagate the read marks to the backend.
9745 (when (gnus-check-backend-function 'request-set-mark group)
9746 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9747 (add (gnus-remove-from-range read (gnus-info-read info))))
9749 (unless (gnus-check-group group)
9750 (error "Can't open server for %s" group))
9751 (gnus-request-set-mark
9752 group (delq nil (list (if add (list add 'add '(read)))
9753 (if del (list del 'del '(read))))))
9755 `(gnus-request-set-mark
9758 (if del (list del 'add '(read)))
9759 (if add (list add 'del '(read))))))))))
9760 (set-buffer gnus-group-buffer)
9763 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9764 (gnus-info-set-read ',info ',(gnus-info-read info))
9765 (gnus-get-unread-articles-in-group ',info
9766 (gnus-active ,group))
9767 (gnus-group-update-group ,group t)
9769 ;; Enter this list into the group info.
9770 (gnus-info-set-read info read)
9771 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9772 (gnus-get-unread-articles-in-group info (gnus-active group))
9775 (defun gnus-offer-save-summaries ()
9776 "Offer to save all active summary buffers."
9778 (let ((buflist (buffer-list))
9780 ;; Go through all buffers and find all summaries.
9782 (and (setq bufname (buffer-name (car buflist)))
9783 (string-match "Summary" bufname)
9785 (set-buffer bufname)
9786 ;; We check that this is, indeed, a summary buffer.
9787 (and (eq major-mode 'gnus-summary-mode)
9788 ;; Also make sure this isn't bogus.
9789 gnus-newsgroup-prepared
9790 ;; Also make sure that this isn't a dead summary buffer.
9791 (not gnus-dead-summary-mode)))
9792 (push bufname buffers))
9793 (setq buflist (cdr buflist)))
9794 ;; Go through all these summary buffers and offer to save them.
9797 "Update summary buffer %s? "
9799 (switch-to-buffer buf)
9800 (gnus-summary-exit))
9804 ;;; @ for mime-partial
9807 (defun gnus-request-partial-message ()
9809 (let ((number (gnus-summary-article-number))
9810 (group gnus-newsgroup-name)
9811 (mother gnus-article-buffer))
9812 (set-buffer (get-buffer-create " *Partial Article*"))
9814 (setq mime-preview-buffer mother)
9815 (gnus-request-article-this-buffer number group)
9819 (autoload 'mime-combine-message/partial-pieces-automatically
9821 "Internal method to combine message/partial messages automatically.")
9824 'action '((type . message)(subtype . partial)
9825 (major-mode . gnus-original-article-mode)
9826 (method . mime-combine-message/partial-pieces-automatically)
9827 (summary-buffer-exp . gnus-summary-buffer)
9828 (request-partial-message-method . gnus-request-partial-message)
9832 ;;; @ for message/rfc822
9835 (defun gnus-mime-extract-message/rfc822 (entity situation)
9836 (let (group article num cwin swin cur)
9838 (mime-insert-entity-content entity)
9839 (setq group (or (cdr (assq 'group situation))
9840 (completing-read "Group: "
9843 (gnus-read-active-file-p)
9844 gnus-newsgroup-name))
9845 article (gnus-request-accept-article group)))
9846 (when (and (consp article)
9847 (numberp (setq article (cdr article))))
9848 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9849 cwin (get-buffer-window (current-buffer) t))
9850 (save-window-excursion
9851 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9852 (select-window swin)
9853 (set-buffer gnus-summary-buffer))
9854 (setq cur gnus-current-article)
9856 (let (gnus-show-threads)
9857 (gnus-summary-goto-subject article t))
9858 (gnus-summary-clear-mark-forward 1)
9859 (gnus-summary-goto-subject cur))
9860 (when (and cwin (window-frame cwin))
9861 (select-frame (window-frame cwin)))
9862 (when (boundp 'mime-acting-situation-to-override)
9863 (set-alist 'mime-acting-situation-to-override
9866 (set-alist 'mime-acting-situation-to-override
9869 (save-current-buffer
9870 (set-buffer gnus-group-buffer)
9871 (gnus-activate-group ,group))
9872 (gnus-summary-goto-article ,cur
9873 gnus-show-all-headers)))
9874 (set-alist 'mime-acting-situation-to-override
9878 'action '((type . message)(subtype . rfc822)
9879 (major-mode . gnus-original-article-mode)
9880 (method . gnus-mime-extract-message/rfc822)
9885 'action '((type . message)(subtype . news)
9886 (major-mode . gnus-original-article-mode)
9887 (method . gnus-mime-extract-message/rfc822)
9891 (defun gnus-mime-extract-multipart (entity situation)
9892 (let ((children (mime-entity-children entity))
9893 mime-acting-situation-to-override
9896 (mime-play-entity (car children)
9897 (cons (assq 'mode situation)
9898 mime-acting-situation-to-override))
9899 (setq children (cdr children)))
9900 (if (setq f (cdr (assq 'after-method
9901 mime-acting-situation-to-override)))
9906 'action '((type . multipart)
9907 (method . gnus-mime-extract-multipart)
9916 (defun gnus-summary-setup-default-charset ()
9917 "Setup newsgroup default charset."
9918 (if (equal gnus-newsgroup-name "nndraft:drafts")
9919 (setq gnus-newsgroup-charset nil)
9920 (let* ((name (and gnus-newsgroup-name
9921 (gnus-group-real-name gnus-newsgroup-name)))
9923 (or gnus-newsgroup-ephemeral-ignored-charsets
9925 (and gnus-newsgroup-name
9926 (or (gnus-group-find-parameter gnus-newsgroup-name
9927 'ignored-charsets t)
9928 (let ((alist gnus-group-ignored-charsets-alist)
9929 elem (charsets nil))
9930 (while (setq elem (pop alist))
9932 (string-match (car elem) name))
9934 charsets (cdr elem))))
9936 gnus-newsgroup-ignored-charsets))))
9937 (setq gnus-newsgroup-charset
9938 (or gnus-newsgroup-ephemeral-charset
9939 (and gnus-newsgroup-name
9940 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9941 (let ((alist gnus-group-charset-alist)
9943 (while (setq elem (pop alist))
9945 (string-match (car elem) name))
9947 charset (cadr elem))))
9949 gnus-default-charset))
9950 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9951 ignored-charsets))))
9957 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9958 "Display the current article buffer fully MIME-buttonized.
9959 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9960 treated as multipart/mixed."
9963 (let ((gnus-unbuttonized-mime-types nil)
9964 (gnus-mime-display-multipart-as-mixed show-all-parts))
9965 (gnus-summary-show-article)))
9967 (defun gnus-summary-repair-multipart (article)
9968 "Add a Content-Type header to a multipart article without one."
9969 (interactive (list (gnus-summary-article-number)))
9970 (gnus-with-article article
9971 (message-narrow-to-head)
9972 (message-remove-header "Mime-Version")
9973 (goto-char (point-max))
9974 (insert "Mime-Version: 1.0\n")
9976 (when (search-forward "\n--" nil t)
9977 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9978 (message-narrow-to-head)
9979 (message-remove-header "Content-Type")
9980 (goto-char (point-max))
9981 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9984 (let (gnus-mark-article-hook)
9985 (gnus-summary-select-article t t nil article)))
9987 (defun gnus-summary-toggle-display-buttonized ()
9988 "Toggle the buttonizing of the article buffer."
9991 (if (setq gnus-inhibit-mime-unbuttonizing
9992 (not gnus-inhibit-mime-unbuttonizing))
9993 (let ((gnus-unbuttonized-mime-types nil))
9994 (gnus-summary-show-article))
9995 (gnus-summary-show-article)))
9998 ;;; Intelli-mouse commmands
10001 (defun gnus-wheel-summary-scroll (event)
10003 (let ((amount (if (memq 'shift (event-modifiers event))
10004 (car gnus-wheel-scroll-amount)
10005 (cdr gnus-wheel-scroll-amount)))
10006 (direction (- (* (static-if (featurep 'xemacs)
10007 (event-button event)
10008 (cond ((eq 'mouse-4 (event-basic-type event))
10010 ((eq 'mouse-5 (event-basic-type event))
10014 (gnus-summary-scroll-up (* amount direction))
10015 (when (gnus-eval-in-buffer-window gnus-article-buffer
10018 (and (if (< 0 direction)
10019 (gnus-article-next-page 0)
10020 (gnus-article-prev-page 0)
10022 (if (setq edge (get-text-property
10023 (point-min) 'gnus-wheel-edge))
10024 (setq edge (* edge direction))
10027 (let ((buffer-read-only nil)
10028 (inhibit-read-only t))
10029 (put-text-property (point-min) (point-max)
10030 'gnus-wheel-edge direction)
10032 (or (> edge gnus-wheel-edge-resistance)
10033 (let ((buffer-read-only nil)
10034 (inhibit-read-only t))
10035 (put-text-property (point-min) (point-max)
10037 (* (1+ edge) direction))
10039 (eq last-command 'gnus-wheel-summary-scroll))))
10040 (gnus-summary-next-article nil nil (minusp direction)))))
10042 (defun gnus-wheel-install ()
10043 "Enable mouse wheel support on summary window."
10044 (when gnus-use-wheel
10046 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10048 (define-key gnus-summary-mode-map key
10049 'gnus-wheel-summary-scroll)))))
10051 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10054 ;;; Traditional PGP commmands
10057 (defun gnus-summary-decrypt-article (&optional force)
10058 "Decrypt the current article in traditional PGP way.
10059 This will have permanent effect only in mail groups.
10060 If FORCE is non-nil, allow editing of articles even in read-only
10063 (gnus-summary-select-article t)
10064 (gnus-eval-in-buffer-window gnus-article-buffer
10068 (goto-char (point-min))
10069 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10070 (error "Not a traditional PGP message!"))
10071 (let ((armor-start (match-beginning 0)))
10072 (if (and (pgg-decrypt-region armor-start (point-max))
10073 (or force (not (gnus-group-read-only-p))))
10074 (let ((inhibit-read-only t)
10076 (delete-region armor-start
10078 (re-search-forward "^-+END PGP" nil t)
10079 (beginning-of-line 2)
10081 (insert-buffer-substring pgg-output-buffer))))))))
10083 (defun gnus-summary-verify-article ()
10084 "Verify the current article in traditional PGP way."
10087 (set-buffer gnus-original-article-buffer)
10088 (goto-char (point-min))
10089 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10090 (error "Not a traditional PGP message!"))
10091 (re-search-forward "^-+END PGP" nil t)
10092 (beginning-of-line 2)
10093 (call-interactively (function pgg-verify-region))))
10096 ;;; Generic summary marking commands
10099 (defvar gnus-summary-marking-alist
10100 '((read gnus-del-mark "d")
10101 (unread gnus-unread-mark "u")
10102 (ticked gnus-ticked-mark "!")
10103 (dormant gnus-dormant-mark "?")
10104 (expirable gnus-expirable-mark "e"))
10105 "An alist of names/marks/keystrokes.")
10107 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10108 (defvar gnus-summary-mark-map)
10110 (defun gnus-summary-make-all-marking-commands ()
10111 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10112 (dolist (elem gnus-summary-marking-alist)
10113 (apply 'gnus-summary-make-marking-command elem)))
10115 (defun gnus-summary-make-marking-command (name mark keystroke)
10116 (let ((map (make-sparse-keymap)))
10117 (define-key gnus-summary-generic-mark-map keystroke map)
10118 (dolist (lway `((next "next" next nil "n")
10119 (next-unread "next unread" next t "N")
10120 (prev "previous" prev nil "p")
10121 (prev-unread "previous unread" prev t "P")
10122 (nomove "" nil nil ,keystroke)))
10123 (let ((func (gnus-summary-make-marking-command-1
10124 mark (car lway) lway name)))
10125 (setq func (eval func))
10126 (define-key map (nth 4 lway) func)))))
10128 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10130 (format "gnus-summary-put-mark-as-%s%s"
10131 name (if (eq way 'nomove)
10133 (concat "-" (symbol-name way)))))
10136 "Mark the current article as %s%s.
10137 If N, the prefix, then repeat N times.
10138 If N is negative, move in reverse order.
10139 The difference between N and the actual number of articles marked is
10141 name (car (cdr lway)))
10143 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10145 (defun gnus-summary-generic-mark (n mark move unread)
10146 "Mark N articles with MARK."
10147 (unless (eq major-mode 'gnus-summary-mode)
10148 (error "This command can only be used in the summary buffer"))
10149 (gnus-summary-show-thread)
10152 ((eq move 'next) 1)
10153 ((eq move 'prev) -1)
10155 (if (zerop nummove)
10159 nummove (* -1 nummove))))
10160 (while (and (> n 0)
10161 (gnus-summary-mark-article nil mark)
10162 (zerop (gnus-summary-next-subject nummove unread t)))
10165 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10166 (gnus-summary-recenter)
10167 (gnus-summary-position-point)
10168 (gnus-set-mode-line 'summary)
10171 (gnus-summary-make-all-marking-commands)
10173 (gnus-ems-redefine)
10175 (provide 'gnus-sum)
10177 (run-hooks 'gnus-sum-load-hook)
10179 ;;; gnus-sum.el ends here