1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 ;; (require 'gnus-art)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
45 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
46 (autoload 'mm-uu-dissect "mm-uu")
48 (defcustom gnus-kill-summary-on-exit t
49 "*If non-nil, kill the summary buffer when you exit from it.
50 If nil, the summary will become a \"*Dead Summary*\" buffer, and
51 it will be killed sometime later."
52 :group 'gnus-summary-exit
55 (defcustom gnus-fetch-old-headers nil
56 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
57 If an unread article in the group refers to an older, already read (or
58 just marked as read) article, the old article will not normally be
59 displayed in the Summary buffer. If this variable is non-nil, Gnus
60 will attempt to grab the headers to the old articles, and thereby
61 build complete threads. If it has the value `some', only enough
62 headers to connect otherwise loose threads will be displayed. This
63 variable can also be a number. In that case, no more than that number
64 of old headers will be fetched. If it has the value `invisible', all
65 old headers will be fetched, but none will be displayed.
67 The server has to support NOV for any of this to work."
69 :type '(choice (const :tag "off" nil)
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-refer-thread-limit 200
75 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
76 If t, fetch all the available old headers."
79 (sexp :menu-tag "other" t)))
81 (defcustom gnus-summary-make-false-root 'adopt
82 "*nil means that Gnus won't gather loose threads.
83 If the root of a thread has expired or been read in a previous
84 session, the information necessary to build a complete thread has been
85 lost. Instead of having many small sub-threads from this original thread
86 scattered all over the summary buffer, Gnus can gather them.
88 If non-nil, Gnus will try to gather all loose sub-threads from an
89 original thread into one large thread.
91 If this variable is non-nil, it should be one of `none', `adopt',
94 If this variable is `none', Gnus will not make a false root, but just
95 present the sub-threads after another.
96 If this variable is `dummy', Gnus will create a dummy root that will
97 have all the sub-threads as children.
98 If this variable is `adopt', Gnus will make one of the \"children\"
99 the parent and mark all the step-children as such.
100 If this variable is `empty', the \"children\" are printed with empty
101 subject fields. (Or rather, they will be printed with a string
102 given by the `gnus-summary-same-subject' variable.)"
104 :type '(choice (const :tag "off" nil)
110 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
111 "*A regexp to match subjects to be excluded from loose thread gathering.
112 As loose thread gathering is done on subjects only, that means that
113 there can be many false gatherings performed. By rooting out certain
114 common subjects, gathering might become saner."
118 (defcustom gnus-summary-gather-subject-limit nil
119 "*Maximum length of subject comparisons when gathering loose threads.
120 Use nil to compare full subjects. Setting this variable to a low
121 number will help gather threads that have been corrupted by
122 newsreaders chopping off subject lines, but it might also mean that
123 unrelated articles that have subject that happen to begin with the
124 same few characters will be incorrectly gathered.
126 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
129 :type '(choice (const :tag "off" nil)
131 (sexp :menu-tag "on" t)))
133 (defcustom gnus-simplify-subject-functions nil
134 "List of functions taking a string argument that simplify subjects.
135 The functions are applied recursively.
137 Useful functions to put in this list include: `gnus-simplify-subject-re',
138 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
140 :type '(repeat function))
142 (defcustom gnus-simplify-ignored-prefixes nil
143 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
145 :type '(choice (const :tag "off" nil)
148 (defcustom gnus-build-sparse-threads nil
149 "*If non-nil, fill in the gaps in threads.
150 If `some', only fill in the gaps that are needed to tie loose threads
151 together. If `more', fill in all leaf nodes that Gnus can find. If
152 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
154 :type '(choice (const :tag "off" nil)
157 (sexp :menu-tag "all" t)))
159 (defcustom gnus-summary-thread-gathering-function
160 'gnus-gather-threads-by-subject
161 "*Function used for gathering loose threads.
162 There are two pre-defined functions: `gnus-gather-threads-by-subject',
163 which only takes Subjects into consideration; and
164 `gnus-gather-threads-by-references', which compared the References
165 headers of the articles to find matches."
167 :type '(radio (function-item gnus-gather-threads-by-subject)
168 (function-item gnus-gather-threads-by-references)
169 (function :tag "other")))
171 (defcustom gnus-summary-same-subject ""
172 "*String indicating that the current article has the same subject as the previous.
173 This variable will only be used if the value of
174 `gnus-summary-make-false-root' is `empty'."
175 :group 'gnus-summary-format
178 (defcustom gnus-summary-goto-unread t
179 "*If t, many commands will go to the next unread article.
180 This applies to marking commands as well as other commands that
181 \"naturally\" select the next article, like, for instance, `SPC' at
182 the end of an article.
184 If nil, the marking commands do NOT go to the next unread article
185 (they go to the next article instead). If `never', commands that
186 usually go to the next unread article, will go to the next article,
187 whether it is read or not."
188 :group 'gnus-summary-marks
189 :link '(custom-manual "(gnus)Setting Marks")
190 :type '(choice (const :tag "off" nil)
192 (sexp :menu-tag "on" t)))
194 (defcustom gnus-summary-default-score 0
195 "*Default article score level.
196 All scores generated by the score files will be added to this score.
197 If this variable is nil, scoring will be disabled."
198 :group 'gnus-score-default
199 :type '(choice (const :tag "disable")
202 (defcustom gnus-summary-default-high-score 0
203 "*Default threshold for a high scored article.
204 An article will be highlighted as high scored if its score is greater
206 :group 'gnus-score-default
209 (defcustom gnus-summary-default-low-score 0
210 "*Default threshold for a low scored article.
211 An article will be highlighted as low scored if its score is smaller
213 :group 'gnus-score-default
216 (defcustom gnus-summary-zcore-fuzz 0
217 "*Fuzziness factor for the zcore in the summary buffer.
218 Articles with scores closer than this to `gnus-summary-default-score'
220 :group 'gnus-summary-format
223 (defcustom gnus-simplify-subject-fuzzy-regexp nil
224 "*Strings to be removed when doing fuzzy matches.
225 This can either be a regular expression or list of regular expressions
226 that will be removed from subject strings if fuzzy subject
227 simplification is selected."
229 :type '(repeat regexp))
231 (defcustom gnus-show-threads t
232 "*If non-nil, display threads in summary mode."
236 (defcustom gnus-thread-hide-subtree nil
237 "*If non-nil, hide all threads initially.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If nil, don't select the first unread article when entering a group.
282 If this variable is `best', select the highest-scored unread article
283 in the group. If t, select the first unread article.
285 This variable can also be a function to place point on a likely
286 subject line. Useful values include `gnus-summary-first-unread-subject',
287 `gnus-summary-first-unread-article' and
288 `gnus-summary-best-unread-article'.
290 If you want to prevent automatic selection of the first unread article
291 in some newsgroups, set the variable to nil in
292 `gnus-select-group-hook'."
293 :group 'gnus-group-select
294 :type '(choice (const :tag "none" nil)
296 (sexp :menu-tag "first" t)
297 (function-item gnus-summary-first-unread-subject)
298 (function-item gnus-summary-first-unread-article)
299 (function-item gnus-summary-best-unread-article)))
301 (defcustom gnus-auto-select-next t
302 "*If non-nil, offer to go to the next group from the end of the previous.
303 If the value is t and the next newsgroup is empty, Gnus will exit
304 summary mode and go back to group mode. If the value is neither nil
305 nor t, Gnus will select the following unread newsgroup. In
306 particular, if the value is the symbol `quietly', the next unread
307 newsgroup will be selected without any confirmation, and if it is
308 `almost-quietly', the next group will be selected without any
309 confirmation if you are located on the last article in the group.
310 Finally, if this variable is `slightly-quietly', the `Z n' command
311 will go to the next group without confirmation."
312 :group 'gnus-summary-maneuvering
313 :type '(choice (const :tag "off" nil)
315 (const almost-quietly)
316 (const slightly-quietly)
317 (sexp :menu-tag "on" t)))
319 (defcustom gnus-auto-select-same nil
320 "*If non-nil, select the next article with the same subject.
321 If there are no more articles with the same subject, go to
322 the first unread article."
323 :group 'gnus-summary-maneuvering
326 (defcustom gnus-summary-check-current nil
327 "*If non-nil, consider the current article when moving.
328 The \"unread\" movement commands will stay on the same line if the
329 current article is unread."
330 :group 'gnus-summary-maneuvering
333 (defcustom gnus-auto-center-summary t
334 "*If non-nil, always center the current summary buffer.
335 In particular, if `vertical' do only vertical recentering. If non-nil
336 and non-`vertical', do both horizontal and vertical recentering."
337 :group 'gnus-summary-maneuvering
338 :type '(choice (const :tag "none" nil)
340 (integer :tag "height")
341 (sexp :menu-tag "both" t)))
343 (defcustom gnus-show-all-headers nil
344 "*If non-nil, don't hide any headers."
345 :group 'gnus-article-hiding
346 :group 'gnus-article-headers
349 (defcustom gnus-summary-ignore-duplicates nil
350 "*If non-nil, ignore articles with identical Message-ID headers."
354 (defcustom gnus-single-article-buffer t
355 "*If non-nil, display all articles in the same buffer.
356 If nil, each group will get its own article buffer."
357 :group 'gnus-article-various
360 (defcustom gnus-break-pages t
361 "*If non-nil, do page breaking on articles.
362 The page delimiter is specified by the `gnus-page-delimiter'
364 :group 'gnus-article-various
367 (defcustom gnus-move-split-methods nil
368 "*Variable used to suggest where articles are to be moved to.
369 It uses the same syntax as the `gnus-split-methods' variable.
370 However, whereas `gnus-split-methods' specifies file names as targets,
371 this variable specifies group names."
372 :group 'gnus-summary-mail
373 :type '(repeat (choice (list :value (fun) function)
374 (cons :value ("" "") regexp (repeat string))
377 (defcustom gnus-unread-mark ? ;Whitespace
378 "*Mark used for unread articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-ticked-mark ?!
383 "*Mark used for ticked articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-dormant-mark ??
388 "*Mark used for dormant articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-del-mark ?r
393 "*Mark used for del'd articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-read-mark ?R
398 "*Mark used for read articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-expirable-mark ?E
403 "*Mark used for expirable articles."
404 :group 'gnus-summary-marks
407 (defcustom gnus-killed-mark ?K
408 "*Mark used for killed articles."
409 :group 'gnus-summary-marks
412 (defcustom gnus-souped-mark ?F
413 "*Mark used for souped articles."
414 :group 'gnus-summary-marks
417 (defcustom gnus-kill-file-mark ?X
418 "*Mark used for articles killed by kill files."
419 :group 'gnus-summary-marks
422 (defcustom gnus-low-score-mark ?Y
423 "*Mark used for articles with a low score."
424 :group 'gnus-summary-marks
427 (defcustom gnus-catchup-mark ?C
428 "*Mark used for articles that are caught up."
429 :group 'gnus-summary-marks
432 (defcustom gnus-replied-mark ?A
433 "*Mark used for articles that have been replied to."
434 :group 'gnus-summary-marks
437 (defcustom gnus-forwarded-mark ?F
438 "*Mark used for articles that have been forwarded."
439 :group 'gnus-summary-marks
442 (defcustom gnus-recent-mark ?N
443 "*Mark used for articles that are recent."
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."
454 :group 'gnus-summary-marks
457 (defcustom gnus-unseen-mark ?.
458 "*Mark used for articles that haven't been seen."
459 :group 'gnus-summary-marks
462 (defcustom gnus-no-mark ? ;Whitespace
463 "*Mark used for articles that have no other secondary mark."
464 :group 'gnus-summary-marks
467 (defcustom gnus-ancient-mark ?O
468 "*Mark used for ancient articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-sparse-mark ?Q
473 "*Mark used for sparsely reffed articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-canceled-mark ?G
478 "*Mark used for canceled articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-duplicate-mark ?M
483 "*Mark used for duplicate articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-undownloaded-mark ?@
488 "*Mark used for articles that weren't downloaded."
489 :group 'gnus-summary-marks
492 (defcustom gnus-downloadable-mark ?%
493 "*Mark used for articles that are to be downloaded."
494 :group 'gnus-summary-marks
497 (defcustom gnus-unsendable-mark ?=
498 "*Mark used for articles that won't be sent."
499 :group 'gnus-summary-marks
502 (defcustom gnus-score-over-mark ?+
503 "*Score mark used for articles with high scores."
504 :group 'gnus-summary-marks
507 (defcustom gnus-score-below-mark ?-
508 "*Score mark used for articles with low scores."
509 :group 'gnus-summary-marks
512 (defcustom gnus-empty-thread-mark ? ;Whitespace
513 "*There is no thread under the article."
514 :group 'gnus-summary-marks
517 (defcustom gnus-not-empty-thread-mark ?=
518 "*There is a thread under the article."
519 :group 'gnus-summary-marks
522 (defcustom gnus-view-pseudo-asynchronously nil
523 "*If non-nil, Gnus will view pseudo-articles asynchronously."
524 :group 'gnus-extract-view
527 (defcustom gnus-auto-expirable-marks
528 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
529 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
530 gnus-souped-mark gnus-duplicate-mark)
531 "*The list of marks converted into expiration if a group is auto-expirable."
534 :type '(repeat character))
536 (defcustom gnus-inhibit-user-auto-expire t
537 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
542 (defcustom gnus-view-pseudos nil
543 "*If `automatic', pseudo-articles will be viewed automatically.
544 If `not-confirm', pseudos will be viewed automatically, and the user
545 will not be asked to confirm the command."
546 :group 'gnus-extract-view
547 :type '(choice (const :tag "off" nil)
549 (const not-confirm)))
551 (defcustom gnus-view-pseudos-separately t
552 "*If non-nil, one pseudo-article will be created for each file to be viewed.
553 If nil, all files that use the same viewing command will be given as a
554 list of parameters to that command."
555 :group 'gnus-extract-view
558 (defcustom gnus-insert-pseudo-articles t
559 "*If non-nil, insert pseudo-articles when decoding articles."
560 :group 'gnus-extract-view
563 (defcustom gnus-summary-dummy-line-format
565 "*The format specification for the dummy roots in the summary buffer.
566 It works along the same lines as a normal formatting string,
567 with some simple extensions.
570 :group 'gnus-threading
573 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
574 "*The format specification for the summary mode line.
575 It works along the same lines as a normal formatting string,
576 with some simple extensions:
579 %p Unprefixed group name
580 %A Current article number
581 %z Current article score
583 %U Number of unread articles in the group
584 %e Number of unselected articles in the group
585 %Z A string with unread/unselected article counts
586 %g Shortish group name
587 %S Subject of the current article
589 %s Current score file name
590 %d Number of dormant articles
591 %r Number of articles that have been marked as read in this session
592 %E Number of articles expunged by the score files"
593 :group 'gnus-summary-format
596 (defcustom gnus-list-identifiers nil
597 "Regexp that matches list identifiers to be removed from subject.
598 This can also be a list of regexps."
600 :group 'gnus-summary-format
601 :group 'gnus-article-hiding
602 :type '(choice (const :tag "none" nil)
604 (repeat :value (".*") regexp)))
606 (defcustom gnus-summary-mark-below 0
607 "*Mark all articles with a score below this variable as read.
608 This variable is local to each summary buffer and usually set by the
610 :group 'gnus-score-default
613 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
614 "*List of functions used for sorting articles in the summary buffer.
616 Each function takes two articles and returns non-nil if the first
617 article should be sorted before the other. If you use more than one
618 function, the primary sort function should be the last. You should
619 probably always include `gnus-article-sort-by-number' in the list of
620 sorting functions -- preferably first. Also note that sorting by date
621 is often much slower than sorting by number, and the sorting order is
622 very similar. (Sorting by date means sorting by the time the message
623 was sent, sorting by number means sorting by arrival time.)
625 Ready-made functions include `gnus-article-sort-by-number',
626 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
627 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
629 When threading is turned on, the variable `gnus-thread-sort-functions'
630 controls how articles are sorted."
631 :group 'gnus-summary-sort
632 :type '(repeat (choice (function-item gnus-article-sort-by-number)
633 (function-item gnus-article-sort-by-author)
634 (function-item gnus-article-sort-by-subject)
635 (function-item gnus-article-sort-by-date)
636 (function-item gnus-article-sort-by-score)
637 (function :tag "other"))))
639 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
640 "*List of functions used for sorting threads in the summary buffer.
641 By default, threads are sorted by article number.
643 Each function takes two threads and returns non-nil if the first
644 thread should be sorted before the other. If you use more than one
645 function, the primary sort function should be the last. You should
646 probably always include `gnus-thread-sort-by-number' in the list of
647 sorting functions -- preferably first. Also note that sorting by date
648 is often much slower than sorting by number, and the sorting order is
649 very similar. (Sorting by date means sorting by the time the message
650 was sent, sorting by number means sorting by arrival time.)
652 Ready-made functions include `gnus-thread-sort-by-number',
653 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
654 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
655 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
657 When threading is turned off, the variable
658 `gnus-article-sort-functions' controls how articles are sorted."
659 :group 'gnus-summary-sort
660 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
661 (function-item gnus-thread-sort-by-author)
662 (function-item gnus-thread-sort-by-subject)
663 (function-item gnus-thread-sort-by-date)
664 (function-item gnus-thread-sort-by-score)
665 (function-item gnus-thread-sort-by-total-score)
666 (function :tag "other"))))
668 (defcustom gnus-thread-score-function '+
669 "*Function used for calculating the total score of a thread.
671 The function is called with the scores of the article and each
672 subthread and should then return the score of the thread.
674 Some functions you can use are `+', `max', or `min'."
675 :group 'gnus-summary-sort
678 (defcustom gnus-summary-expunge-below nil
679 "All articles that have a score less than this variable will be expunged.
680 This variable is local to the summary buffers."
681 :group 'gnus-score-default
682 :type '(choice (const :tag "off" nil)
685 (defcustom gnus-thread-expunge-below nil
686 "All threads that have a total score less than this variable will be expunged.
687 See `gnus-thread-score-function' for en explanation of what a
690 This variable is local to the summary buffers."
691 :group 'gnus-threading
692 :group 'gnus-score-default
693 :type '(choice (const :tag "off" nil)
696 (defcustom gnus-summary-mode-hook nil
697 "*A hook for Gnus summary mode.
698 This hook is run before any variables are set in the summary buffer."
699 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
700 :group 'gnus-summary-various
703 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
704 (when (featurep 'xemacs)
705 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
706 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
707 (add-hook 'gnus-summary-mode-hook
708 'gnus-xmas-switch-horizontal-scrollbar-off))
710 (defcustom gnus-summary-menu-hook nil
711 "*Hook run after the creation of the summary mode menu."
712 :group 'gnus-summary-visual
715 (defcustom gnus-summary-exit-hook nil
716 "*A hook called on exit from the summary buffer.
717 It will be called with point in the group buffer."
718 :group 'gnus-summary-exit
721 (defcustom gnus-summary-prepare-hook nil
722 "*A hook called after the summary buffer has been generated.
723 If you want to modify the summary buffer, you can use this hook."
724 :group 'gnus-summary-various
727 (defcustom gnus-summary-prepared-hook nil
728 "*A hook called as the last thing after the summary buffer has been generated."
729 :group 'gnus-summary-various
732 (defcustom gnus-summary-generate-hook nil
733 "*A hook run just before generating the summary buffer.
734 This hook is commonly used to customize threading variables and the
736 :group 'gnus-summary-various
739 (defcustom gnus-select-group-hook nil
740 "*A hook called when a newsgroup is selected.
742 If you'd like to simplify subjects like the
743 `gnus-summary-next-same-subject' command does, you can use the
746 (setq gnus-select-group-hook
749 (mapcar (lambda (header)
750 (mail-header-set-subject
752 (gnus-simplify-subject
753 (mail-header-subject header) 're-only)))
754 gnus-newsgroup-headers))))"
755 :group 'gnus-group-select
758 (defcustom gnus-select-article-hook nil
759 "*A hook called when an article is selected."
760 :group 'gnus-summary-choose
763 (defcustom gnus-visual-mark-article-hook
764 (list 'gnus-highlight-selected-summary)
765 "*Hook run after selecting an article in the summary buffer.
766 It is meant to be used for highlighting the article in some way. It
767 is not run if `gnus-visual' is nil."
768 :group 'gnus-summary-visual
771 (defcustom gnus-parse-headers-hook nil
772 "*A hook called before parsing the headers."
776 (defcustom gnus-exit-group-hook nil
777 "*A hook called when exiting summary mode.
778 This hook is not called from the non-updating exit commands like `Q'."
782 (defcustom gnus-summary-update-hook
783 (list 'gnus-summary-highlight-line)
784 "*A hook called when a summary line is changed.
785 The hook will not be called if `gnus-visual' is nil.
787 The default function `gnus-summary-highlight-line' will
788 highlight the line according to the `gnus-summary-highlight'
790 :group 'gnus-summary-visual
793 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
794 "*A hook called when an article is selected for the first time.
795 The hook is intended to mark an article as read (or unread)
796 automatically when it is selected."
797 :group 'gnus-summary-choose
800 (defcustom gnus-group-no-more-groups-hook nil
801 "*A hook run when returning to group mode having no more (unread) groups."
802 :group 'gnus-group-select
805 (defcustom gnus-ps-print-hook nil
806 "*A hook run before ps-printing something from Gnus."
810 (defcustom gnus-summary-display-arrow
811 (and (fboundp 'display-graphic-p)
813 "*If non-nil, display an arrow highlighting the current article."
818 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
819 "Face used for highlighting the current article in the summary buffer."
820 :group 'gnus-summary-visual
823 (defcustom gnus-summary-highlight
824 '(((= mark gnus-canceled-mark)
825 . gnus-summary-cancelled-face)
826 ((and (> score default-high)
827 (or (= mark gnus-dormant-mark)
828 (= mark gnus-ticked-mark)))
829 . gnus-summary-high-ticked-face)
830 ((and (< score default-low)
831 (or (= mark gnus-dormant-mark)
832 (= mark gnus-ticked-mark)))
833 . gnus-summary-low-ticked-face)
834 ((or (= mark gnus-dormant-mark)
835 (= mark gnus-ticked-mark))
836 . gnus-summary-normal-ticked-face)
837 ((and (> score default-high) (= mark gnus-ancient-mark))
838 . gnus-summary-high-ancient-face)
839 ((and (< score default-low) (= mark gnus-ancient-mark))
840 . gnus-summary-low-ancient-face)
841 ((= mark gnus-ancient-mark)
842 . gnus-summary-normal-ancient-face)
843 ((and (> score default-high) (= mark gnus-unread-mark))
844 . gnus-summary-high-unread-face)
845 ((and (< score default-low) (= mark gnus-unread-mark))
846 . gnus-summary-low-unread-face)
847 ((= mark gnus-unread-mark)
848 . gnus-summary-normal-unread-face)
849 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
850 gnus-undownloaded-mark)))
851 . gnus-summary-high-unread-face)
852 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
853 gnus-undownloaded-mark)))
854 . gnus-summary-low-unread-face)
855 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
856 (memq article gnus-newsgroup-unreads))
857 . gnus-summary-normal-unread-face)
858 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
859 . gnus-summary-normal-read-face)
860 ((> score default-high)
861 . gnus-summary-high-read-face)
862 ((< score default-low)
863 . gnus-summary-low-read-face)
865 . gnus-summary-normal-read-face))
866 "*Controls the highlighting of summary buffer lines.
868 A list of (FORM . FACE) pairs. When deciding how a a particular
869 summary line should be displayed, each form is evaluated. The content
870 of the face field after the first true form is used. You can change
871 how those summary lines are displayed, by editing the face field.
873 You can use the following variables in the FORM field.
875 score: The article's score
876 default: The default article score.
877 default-high: The default score for high scored articles.
878 default-low: The default score for low scored articles.
879 below: The score below which articles are automatically marked as read.
880 mark: The articles mark."
881 :group 'gnus-summary-visual
882 :type '(repeat (cons (sexp :tag "Form" nil)
885 (defcustom gnus-alter-header-function nil
886 "Function called to allow alteration of article header structures.
887 The function is called with one parameter, the article header vector,
888 which it may alter in any way.")
890 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
891 "Variable that says which function should be used to decode a string with encoded words.")
893 (defcustom gnus-extra-headers nil
894 "*Extra headers to parse."
897 :type '(repeat symbol))
899 (defcustom gnus-ignored-from-addresses
900 (and user-mail-address (regexp-quote user-mail-address))
901 "*Regexp of From headers that may be suppressed in favor of To headers."
906 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
907 "List of charsets that should be ignored.
908 When these charsets are used in the \"charset\" parameter, the
909 default charset will be used instead."
911 :type '(repeat symbol)
912 :group 'gnus-charset)
914 (gnus-define-group-parameter
918 "Return the ignored charsets of GROUP."
919 :variable gnus-group-ignored-charsets-alist
921 '(("alt\\.chinese\\.text" iso-8859-1))
923 "Alist of regexps (to match group names) and charsets that should be ignored.
924 When these charsets are used in the \"charset\" parameter, the
925 default charset will be used instead."
926 :variable-group gnus-charset
927 :variable-type '(repeat (cons (regexp :tag "Group")
929 :parameter-type '(choice :tag "Ignored charsets"
932 :parameter-document "\
933 List of charsets that should be ignored.
935 When these charsets are used in the \"charset\" parameter, the
936 default charset will be used instead.")
938 (defcustom gnus-group-highlight-words-alist nil
939 "Alist of group regexps and highlight regexps.
940 This variable uses the same syntax as `gnus-emphasis-alist'."
942 :type '(repeat (cons (regexp :tag "Group")
943 (repeat (list (regexp :tag "Highlight regexp")
944 (number :tag "Group for entire word" 0)
945 (number :tag "Group for displayed part" 0)
947 gnus-emphasis-highlight-words)))))
948 :group 'gnus-summary-visual)
950 (defcustom gnus-summary-show-article-charset-alist
952 "Alist of number and charset.
953 The article will be shown with the charset corresponding to the
955 For example: ((1 . cn-gb-2312) (2 . big5))."
957 :type '(repeat (cons (number :tag "Argument" 1)
958 (symbol :tag "Charset")))
959 :group 'gnus-charset)
961 (defcustom gnus-preserve-marks t
962 "Whether marks are preserved when moving, copying and respooling messages."
965 :group 'gnus-summary-marks)
967 (defcustom gnus-alter-articles-to-read-function nil
968 "Function to be called to alter the list of articles to be selected."
969 :type '(choice (const nil) function)
970 :group 'gnus-summary)
972 (defcustom gnus-orphan-score nil
973 "*All orphans get this score added. Set in the score file."
974 :group 'gnus-score-default
975 :type '(choice (const nil)
978 (defcustom gnus-summary-save-parts-default-mime "image/.*"
979 "*A regexp to match MIME parts when saving multiple parts of a message
980 with gnus-summary-save-parts (X m). This regexp will be used by default
981 when prompting the user for which type of files to save."
986 (defcustom gnus-summary-save-parts-default-mime "image/.*"
987 "*A regexp to match MIME parts when saving multiple parts of a message
988 with gnus-summary-save-parts (X m). This regexp will be used by default
989 when prompting the user for which type of files to save."
993 (defcustom gnus-read-all-available-headers nil
994 "Whether Gnus should parse all headers made available to it.
995 This is mostly relevant for slow backends where the user may
996 wish to widen the summary buffer to include all headers
997 that were fetched. Say, for nnultimate groups."
999 :type '(choice boolean regexp))
1001 ;;; Internal variables
1003 (defvar gnus-summary-display-cache nil)
1004 (defvar gnus-article-mime-handles nil)
1005 (defvar gnus-article-decoded-p nil)
1006 (defvar gnus-article-charset nil)
1007 (defvar gnus-article-ignored-charsets nil)
1008 (defvar gnus-scores-exclude-files nil)
1009 (defvar gnus-page-broken nil)
1010 (defvar gnus-inhibit-mime-unbuttonizing nil)
1012 (defvar gnus-original-article nil)
1013 (defvar gnus-article-internal-prepare-hook nil)
1014 (defvar gnus-newsgroup-process-stack nil)
1016 (defvar gnus-thread-indent-array nil)
1017 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1018 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1019 "Function called to sort the articles within a thread after it has been gathered together.")
1021 (defvar gnus-summary-save-parts-type-history nil)
1022 (defvar gnus-summary-save-parts-last-directory nil)
1024 (defvar gnus-summary-save-parts-type-history nil)
1025 (defvar gnus-summary-save-parts-last-directory nil)
1027 ;; Avoid highlighting in kill files.
1028 (defvar gnus-summary-inhibit-highlight nil)
1029 (defvar gnus-newsgroup-selected-overlay nil)
1030 (defvar gnus-inhibit-limiting nil)
1031 (defvar gnus-newsgroup-adaptive-score-file nil)
1032 (defvar gnus-current-score-file nil)
1033 (defvar gnus-current-move-group nil)
1034 (defvar gnus-current-copy-group nil)
1035 (defvar gnus-current-crosspost-group nil)
1036 (defvar gnus-newsgroup-display nil)
1038 (defvar gnus-newsgroup-dependencies nil)
1039 (defvar gnus-newsgroup-adaptive nil)
1040 (defvar gnus-summary-display-article-function nil)
1041 (defvar gnus-summary-highlight-line-function nil
1042 "Function called after highlighting a summary line.")
1044 (defvar gnus-summary-line-format-alist
1045 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1046 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1047 (?s gnus-tmp-subject-or-nil ?s)
1048 (?n gnus-tmp-name ?s)
1049 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1051 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1053 (?F gnus-tmp-from ?s)
1054 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1055 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1056 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1057 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1058 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1059 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1060 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1061 (?L gnus-tmp-lines ?s)
1062 (?I gnus-tmp-indentation ?s)
1063 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1064 (?R gnus-tmp-replied ?c)
1065 (?\[ gnus-tmp-opening-bracket ?c)
1066 (?\] gnus-tmp-closing-bracket ?c)
1067 (?\> (make-string gnus-tmp-level ? ) ?s)
1068 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1069 (?i gnus-tmp-score ?d)
1070 (?z gnus-tmp-score-char ?c)
1071 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1072 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1073 (?U gnus-tmp-unread ?c)
1074 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1076 (?t (gnus-summary-number-of-articles-in-thread
1077 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1079 (?e (gnus-summary-number-of-articles-in-thread
1080 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1082 (?u gnus-tmp-user-defined ?s)
1083 (?P (gnus-pick-line-number) ?d)
1084 (?B gnus-tmp-thread-tree-header-string ?s)
1085 (user-date (gnus-user-date
1086 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1087 "An alist of format specifications that can appear in summary lines.
1088 These are paired with what variables they correspond with, along with
1089 the type of the variable (string, integer, character, etc).")
1091 (defvar gnus-summary-dummy-line-format-alist
1092 `((?S gnus-tmp-subject ?s)
1093 (?N gnus-tmp-number ?d)
1094 (?u gnus-tmp-user-defined ?s)))
1096 (defvar gnus-summary-mode-line-format-alist
1097 `((?G gnus-tmp-group-name ?s)
1098 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1099 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1100 (?A gnus-tmp-article-number ?d)
1101 (?Z gnus-tmp-unread-and-unselected ?s)
1102 (?V gnus-version ?s)
1103 (?U gnus-tmp-unread-and-unticked ?d)
1104 (?S gnus-tmp-subject ?s)
1105 (?e gnus-tmp-unselected ?d)
1106 (?u gnus-tmp-user-defined ?s)
1107 (?d (length gnus-newsgroup-dormant) ?d)
1108 (?t (length gnus-newsgroup-marked) ?d)
1109 (?r (length gnus-newsgroup-reads) ?d)
1110 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1111 (?E gnus-newsgroup-expunged-tally ?d)
1112 (?s (gnus-current-score-file-nondirectory) ?s)))
1114 (defvar gnus-last-search-regexp nil
1115 "Default regexp for article search command.")
1117 (defvar gnus-last-shell-command nil
1118 "Default shell command on article.")
1120 (defvar gnus-newsgroup-begin nil)
1121 (defvar gnus-newsgroup-end nil)
1122 (defvar gnus-newsgroup-last-rmail nil)
1123 (defvar gnus-newsgroup-last-mail nil)
1124 (defvar gnus-newsgroup-last-folder nil)
1125 (defvar gnus-newsgroup-last-file nil)
1126 (defvar gnus-newsgroup-auto-expire nil)
1127 (defvar gnus-newsgroup-active nil)
1129 (defvar gnus-newsgroup-data nil)
1130 (defvar gnus-newsgroup-data-reverse nil)
1131 (defvar gnus-newsgroup-limit nil)
1132 (defvar gnus-newsgroup-limits nil)
1134 (defvar gnus-newsgroup-unreads nil
1135 "List of unread articles in the current newsgroup.")
1137 (defvar gnus-newsgroup-unselected nil
1138 "List of unselected unread articles in the current newsgroup.")
1140 (defvar gnus-newsgroup-reads nil
1141 "Alist of read articles and article marks in the current newsgroup.")
1143 (defvar gnus-newsgroup-expunged-tally nil)
1145 (defvar gnus-newsgroup-marked nil
1146 "List of ticked articles in the current newsgroup (a subset of unread art).")
1148 (defvar gnus-newsgroup-killed nil
1149 "List of ranges of articles that have been through the scoring process.")
1151 (defvar gnus-newsgroup-cached nil
1152 "List of articles that come from the article cache.")
1154 (defvar gnus-newsgroup-saved nil
1155 "List of articles that have been saved.")
1157 (defvar gnus-newsgroup-kill-headers nil)
1159 (defvar gnus-newsgroup-replied nil
1160 "List of articles that have been replied to in the current newsgroup.")
1162 (defvar gnus-newsgroup-forwarded nil
1163 "List of articles that have been forwarded in the current newsgroup.")
1165 (defvar gnus-newsgroup-recent nil
1166 "List of articles that have are recent in the current newsgroup.")
1168 (defvar gnus-newsgroup-expirable nil
1169 "List of articles in the current newsgroup that can be expired.")
1171 (defvar gnus-newsgroup-processable nil
1172 "List of articles in the current newsgroup that can be processed.")
1174 (defvar gnus-newsgroup-downloadable nil
1175 "List of articles in the current newsgroup that can be processed.")
1177 (defvar gnus-newsgroup-undownloaded nil
1178 "List of articles in the current newsgroup that haven't been downloaded..")
1180 (defvar gnus-newsgroup-unsendable nil
1181 "List of articles in the current newsgroup that won't be sent.")
1183 (defvar gnus-newsgroup-bookmarks nil
1184 "List of articles in the current newsgroup that have bookmarks.")
1186 (defvar gnus-newsgroup-dormant nil
1187 "List of dormant articles in the current newsgroup.")
1189 (defvar gnus-newsgroup-unseen nil
1190 "List of unseen articles in the current newsgroup.")
1192 (defvar gnus-newsgroup-seen nil
1193 "Range of seen articles in the current newsgroup.")
1195 (defvar gnus-newsgroup-articles nil
1196 "List of articles in the current newsgroup.")
1198 (defvar gnus-newsgroup-scored nil
1199 "List of scored articles in the current newsgroup.")
1201 (defvar gnus-newsgroup-headers nil
1202 "List of article headers in the current newsgroup.")
1204 (defvar gnus-newsgroup-threads nil)
1206 (defvar gnus-newsgroup-prepared nil
1207 "Whether the current group has been prepared properly.")
1209 (defvar gnus-newsgroup-ancient nil
1210 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1212 (defvar gnus-newsgroup-sparse nil)
1214 (defvar gnus-current-article nil)
1215 (defvar gnus-article-current nil)
1216 (defvar gnus-current-headers nil)
1217 (defvar gnus-have-all-headers nil)
1218 (defvar gnus-last-article nil)
1219 (defvar gnus-newsgroup-history nil)
1220 (defvar gnus-newsgroup-charset nil)
1221 (defvar gnus-newsgroup-ephemeral-charset nil)
1222 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1224 (defvar gnus-article-before-search nil)
1226 (defconst gnus-summary-local-variables
1227 '(gnus-newsgroup-name
1228 gnus-newsgroup-begin gnus-newsgroup-end
1229 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1230 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1231 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1232 gnus-newsgroup-unselected gnus-newsgroup-marked
1233 gnus-newsgroup-reads gnus-newsgroup-saved
1234 gnus-newsgroup-replied gnus-newsgroup-forwarded
1235 gnus-newsgroup-recent
1236 gnus-newsgroup-expirable
1237 gnus-newsgroup-processable gnus-newsgroup-killed
1238 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1239 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1240 gnus-newsgroup-seen gnus-newsgroup-articles
1241 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1242 gnus-newsgroup-headers gnus-newsgroup-threads
1243 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1244 gnus-current-article gnus-current-headers gnus-have-all-headers
1245 gnus-last-article gnus-article-internal-prepare-hook
1246 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1247 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1248 gnus-thread-expunge-below
1249 gnus-score-alist gnus-current-score-file
1250 (gnus-summary-expunge-below . global)
1251 (gnus-summary-mark-below . global)
1252 (gnus-orphan-score . global)
1253 gnus-newsgroup-active gnus-scores-exclude-files
1254 gnus-newsgroup-history gnus-newsgroup-ancient
1255 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1256 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1257 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1258 (gnus-newsgroup-expunged-tally . 0)
1259 gnus-cache-removable-articles gnus-newsgroup-cached
1260 gnus-newsgroup-data gnus-newsgroup-data-reverse
1261 gnus-newsgroup-limit gnus-newsgroup-limits
1262 gnus-newsgroup-charset gnus-newsgroup-display)
1263 "Variables that are buffer-local to the summary buffers.")
1265 (defvar gnus-newsgroup-variables nil
1266 "Variables that have separate values in the newsgroups.")
1268 ;; Byte-compiler warning.
1269 (eval-when-compile (defvar gnus-article-mode-map))
1273 (defvar gnus-decode-encoded-word-methods
1274 '(mail-decode-encoded-word-string)
1275 "List of methods used to decode encoded words.
1277 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1278 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1279 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1280 whose names match REGEXP.
1283 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1284 mail-decode-encoded-word-string
1285 (\"chinese\" . rfc1843-decode-string))")
1287 (defvar gnus-decode-encoded-word-methods-cache nil)
1289 (defun gnus-multi-decode-encoded-word-string (string)
1290 "Apply the functions from `gnus-encoded-word-methods' that match."
1291 (unless (and gnus-decode-encoded-word-methods-cache
1292 (eq gnus-newsgroup-name
1293 (car gnus-decode-encoded-word-methods-cache)))
1294 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1297 (nconc gnus-decode-encoded-word-methods-cache (list x))
1298 (if (and gnus-newsgroup-name
1299 (string-match (car x) gnus-newsgroup-name))
1300 (nconc gnus-decode-encoded-word-methods-cache
1302 gnus-decode-encoded-word-methods))
1303 (let ((xlist gnus-decode-encoded-word-methods-cache))
1306 (setq string (funcall (pop xlist) string))))
1309 ;; Subject simplification.
1311 (defun gnus-simplify-whitespace (str)
1312 "Remove excessive whitespace from STR."
1315 (while (string-match "[ \t][ \t]+" mystr)
1316 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1318 (substring mystr (match-end 0)))))
1320 (when (string-match "^[ \t]+" mystr)
1321 (setq mystr (substring mystr (match-end 0))))
1323 (when (string-match "[ \t]+$" mystr)
1324 (setq mystr (substring mystr 0 (match-beginning 0))))
1327 (defsubst gnus-simplify-subject-re (subject)
1328 "Remove \"Re:\" from subject lines."
1329 (if (string-match message-subject-re-regexp subject)
1330 (substring subject (match-end 0))
1333 (defun gnus-simplify-subject (subject &optional re-only)
1334 "Remove `Re:' and words in parentheses.
1335 If RE-ONLY is non-nil, strip leading `Re:'s only."
1336 (let ((case-fold-search t)) ;Ignore case.
1337 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1338 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1339 (setq subject (substring subject (match-end 0))))
1340 ;; Remove uninteresting prefixes.
1341 (when (and (not re-only)
1342 gnus-simplify-ignored-prefixes
1343 (string-match gnus-simplify-ignored-prefixes subject))
1344 (setq subject (substring subject (match-end 0))))
1345 ;; Remove words in parentheses from end.
1347 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1348 (setq subject (substring subject 0 (match-beginning 0)))))
1349 ;; Return subject string.
1352 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1354 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1355 (goto-char (point-min))
1356 (while (re-search-forward regexp nil t)
1357 (replace-match (or newtext ""))))
1359 (defun gnus-simplify-buffer-fuzzy ()
1360 "Simplify string in the buffer fuzzily.
1361 The string in the accessible portion of the current buffer is simplified.
1362 It is assumed to be a single-line subject.
1363 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1364 matter is removed. Additional things can be deleted by setting
1365 `gnus-simplify-subject-fuzzy-regexp'."
1366 (let ((case-fold-search t)
1368 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1370 (while (not (eq modified-tick (buffer-modified-tick)))
1371 (setq modified-tick (buffer-modified-tick))
1373 ((listp gnus-simplify-subject-fuzzy-regexp)
1374 (mapcar 'gnus-simplify-buffer-fuzzy-step
1375 gnus-simplify-subject-fuzzy-regexp))
1376 (gnus-simplify-subject-fuzzy-regexp
1377 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1378 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1379 (gnus-simplify-buffer-fuzzy-step
1380 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1381 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1383 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1384 (gnus-simplify-buffer-fuzzy-step " +" " ")
1385 (gnus-simplify-buffer-fuzzy-step " $")
1386 (gnus-simplify-buffer-fuzzy-step "^ +")))
1388 (defun gnus-simplify-subject-fuzzy (subject)
1389 "Simplify a subject string fuzzily.
1390 See `gnus-simplify-buffer-fuzzy' for details."
1392 (gnus-set-work-buffer)
1393 (let ((case-fold-search t))
1394 ;; Remove uninteresting prefixes.
1395 (when (and gnus-simplify-ignored-prefixes
1396 (string-match gnus-simplify-ignored-prefixes subject))
1397 (setq subject (substring subject (match-end 0))))
1399 (inline (gnus-simplify-buffer-fuzzy))
1402 (defsubst gnus-simplify-subject-fully (subject)
1403 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1405 (gnus-simplify-subject-functions
1406 (gnus-map-function gnus-simplify-subject-functions subject))
1407 ((null gnus-summary-gather-subject-limit)
1408 (gnus-simplify-subject-re subject))
1409 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1410 (gnus-simplify-subject-fuzzy subject))
1411 ((numberp gnus-summary-gather-subject-limit)
1412 (gnus-limit-string (gnus-simplify-subject-re subject)
1413 gnus-summary-gather-subject-limit))
1417 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1418 "Check whether two subjects are equal.
1419 If optional argument simple-first is t, first argument is already
1422 ((null simple-first)
1423 (equal (gnus-simplify-subject-fully s1)
1424 (gnus-simplify-subject-fully s2)))
1427 (gnus-simplify-subject-fully s2)))))
1429 (defun gnus-summary-bubble-group ()
1430 "Increase the score of the current group.
1431 This is a handy function to add to `gnus-summary-exit-hook' to
1432 increase the score of each group you read."
1433 (gnus-group-add-score gnus-newsgroup-name))
1437 ;;; Gnus summary mode
1440 (put 'gnus-summary-mode 'mode-class 'special)
1442 (defvar gnus-article-commands-menu)
1445 ;; Non-orthogonal keys
1447 (gnus-define-keys gnus-summary-mode-map
1448 " " gnus-summary-next-page
1449 "\177" gnus-summary-prev-page
1450 [delete] gnus-summary-prev-page
1451 [backspace] gnus-summary-prev-page
1452 "\r" gnus-summary-scroll-up
1453 "\M-\r" gnus-summary-scroll-down
1454 "n" gnus-summary-next-unread-article
1455 "p" gnus-summary-prev-unread-article
1456 "N" gnus-summary-next-article
1457 "P" gnus-summary-prev-article
1458 "\M-\C-n" gnus-summary-next-same-subject
1459 "\M-\C-p" gnus-summary-prev-same-subject
1460 "\M-n" gnus-summary-next-unread-subject
1461 "\M-p" gnus-summary-prev-unread-subject
1462 "." gnus-summary-first-unread-article
1463 "," gnus-summary-best-unread-article
1464 "\M-s" gnus-summary-search-article-forward
1465 "\M-r" gnus-summary-search-article-backward
1466 "<" gnus-summary-beginning-of-article
1467 ">" gnus-summary-end-of-article
1468 "j" gnus-summary-goto-article
1469 "^" gnus-summary-refer-parent-article
1470 "\M-^" gnus-summary-refer-article
1471 "u" gnus-summary-tick-article-forward
1472 "!" gnus-summary-tick-article-forward
1473 "U" gnus-summary-tick-article-backward
1474 "d" gnus-summary-mark-as-read-forward
1475 "D" gnus-summary-mark-as-read-backward
1476 "E" gnus-summary-mark-as-expirable
1477 "\M-u" gnus-summary-clear-mark-forward
1478 "\M-U" gnus-summary-clear-mark-backward
1479 "k" gnus-summary-kill-same-subject-and-select
1480 "\C-k" gnus-summary-kill-same-subject
1481 "\M-\C-k" gnus-summary-kill-thread
1482 "\M-\C-l" gnus-summary-lower-thread
1483 "e" gnus-summary-edit-article
1484 "#" gnus-summary-mark-as-processable
1485 "\M-#" gnus-summary-unmark-as-processable
1486 "\M-\C-t" gnus-summary-toggle-threads
1487 "\M-\C-s" gnus-summary-show-thread
1488 "\M-\C-h" gnus-summary-hide-thread
1489 "\M-\C-f" gnus-summary-next-thread
1490 "\M-\C-b" gnus-summary-prev-thread
1491 [(meta down)] gnus-summary-next-thread
1492 [(meta up)] gnus-summary-prev-thread
1493 "\M-\C-u" gnus-summary-up-thread
1494 "\M-\C-d" gnus-summary-down-thread
1495 "&" gnus-summary-execute-command
1496 "c" gnus-summary-catchup-and-exit
1497 "\C-w" gnus-summary-mark-region-as-read
1498 "\C-t" gnus-summary-toggle-truncation
1499 "?" gnus-summary-mark-as-dormant
1500 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1501 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1502 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1503 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1504 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1505 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1506 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1507 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1508 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1509 "=" gnus-summary-expand-window
1510 "\C-x\C-s" gnus-summary-reselect-current-group
1511 "\M-g" gnus-summary-rescan-group
1512 "w" gnus-summary-stop-page-breaking
1513 "\C-c\C-r" gnus-summary-caesar-message
1514 "f" gnus-summary-followup
1515 "F" gnus-summary-followup-with-original
1516 "C" gnus-summary-cancel-article
1517 "r" gnus-summary-reply
1518 "R" gnus-summary-reply-with-original
1519 "\C-c\C-f" gnus-summary-mail-forward
1520 "o" gnus-summary-save-article
1521 "\C-o" gnus-summary-save-article-mail
1522 "|" gnus-summary-pipe-output
1523 "\M-k" gnus-summary-edit-local-kill
1524 "\M-K" gnus-summary-edit-global-kill
1526 "\C-c\C-d" gnus-summary-describe-group
1527 "q" gnus-summary-exit
1528 "Q" gnus-summary-exit-no-update
1529 "\C-c\C-i" gnus-info-find-node
1530 gnus-mouse-2 gnus-mouse-pick-article
1531 "m" gnus-summary-mail-other-window
1532 "a" gnus-summary-post-news
1533 "x" gnus-summary-limit-to-unread
1534 "s" gnus-summary-isearch-article
1535 "t" gnus-summary-toggle-header
1536 "g" gnus-summary-show-article
1537 "l" gnus-summary-goto-last-article
1538 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1539 "\C-d" gnus-summary-enter-digest-group
1540 "\M-\C-d" gnus-summary-read-document
1541 "\M-\C-e" gnus-summary-edit-parameters
1542 "\M-\C-a" gnus-summary-customize-parameters
1544 "*" gnus-cache-enter-article
1545 "\M-*" gnus-cache-remove-article
1546 "\M-&" gnus-summary-universal-argument
1547 "\C-l" gnus-recenter
1548 "I" gnus-summary-increase-score
1549 "L" gnus-summary-lower-score
1550 "\M-i" gnus-symbolic-argument
1551 "h" gnus-summary-select-article-buffer
1553 "b" gnus-article-view-part
1554 "\M-t" gnus-summary-toggle-display-buttonized
1556 "V" gnus-summary-score-map
1557 "X" gnus-uu-extract-map
1558 "S" gnus-summary-send-map)
1560 ;; Sort of orthogonal keymap
1561 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1562 "t" gnus-summary-tick-article-forward
1563 "!" gnus-summary-tick-article-forward
1564 "d" gnus-summary-mark-as-read-forward
1565 "r" gnus-summary-mark-as-read-forward
1566 "c" gnus-summary-clear-mark-forward
1567 " " gnus-summary-clear-mark-forward
1568 "e" gnus-summary-mark-as-expirable
1569 "x" gnus-summary-mark-as-expirable
1570 "?" gnus-summary-mark-as-dormant
1571 "b" gnus-summary-set-bookmark
1572 "B" gnus-summary-remove-bookmark
1573 "#" gnus-summary-mark-as-processable
1574 "\M-#" gnus-summary-unmark-as-processable
1575 "S" gnus-summary-limit-include-expunged
1576 "C" gnus-summary-catchup
1577 "H" gnus-summary-catchup-to-here
1578 "h" gnus-summary-catchup-from-here
1579 "\C-c" gnus-summary-catchup-all
1580 "k" gnus-summary-kill-same-subject-and-select
1581 "K" gnus-summary-kill-same-subject
1582 "P" gnus-uu-mark-map)
1584 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1585 "c" gnus-summary-clear-above
1586 "u" gnus-summary-tick-above
1587 "m" gnus-summary-mark-above
1588 "k" gnus-summary-kill-below)
1590 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1591 "/" gnus-summary-limit-to-subject
1592 "n" gnus-summary-limit-to-articles
1593 "w" gnus-summary-pop-limit
1594 "s" gnus-summary-limit-to-subject
1595 "a" gnus-summary-limit-to-author
1596 "u" gnus-summary-limit-to-unread
1597 "m" gnus-summary-limit-to-marks
1598 "M" gnus-summary-limit-exclude-marks
1599 "v" gnus-summary-limit-to-score
1600 "*" gnus-summary-limit-include-cached
1601 "D" gnus-summary-limit-include-dormant
1602 "T" gnus-summary-limit-include-thread
1603 "d" gnus-summary-limit-exclude-dormant
1604 "t" gnus-summary-limit-to-age
1605 "x" gnus-summary-limit-to-extra
1606 "p" gnus-summary-limit-to-display-predicate
1607 "E" gnus-summary-limit-include-expunged
1608 "c" gnus-summary-limit-exclude-childless-dormant
1609 "C" gnus-summary-limit-mark-excluded-as-read
1610 "o" gnus-summary-insert-old-articles
1611 "N" gnus-summary-insert-new-articles)
1613 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1614 "n" gnus-summary-next-unread-article
1615 "p" gnus-summary-prev-unread-article
1616 "N" gnus-summary-next-article
1617 "P" gnus-summary-prev-article
1618 "\C-n" gnus-summary-next-same-subject
1619 "\C-p" gnus-summary-prev-same-subject
1620 "\M-n" gnus-summary-next-unread-subject
1621 "\M-p" gnus-summary-prev-unread-subject
1622 "f" gnus-summary-first-unread-article
1623 "b" gnus-summary-best-unread-article
1624 "j" gnus-summary-goto-article
1625 "g" gnus-summary-goto-subject
1626 "l" gnus-summary-goto-last-article
1627 "o" gnus-summary-pop-article)
1629 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1630 "k" gnus-summary-kill-thread
1631 "l" gnus-summary-lower-thread
1632 "i" gnus-summary-raise-thread
1633 "T" gnus-summary-toggle-threads
1634 "t" gnus-summary-rethread-current
1635 "^" gnus-summary-reparent-thread
1636 "s" gnus-summary-show-thread
1637 "S" gnus-summary-show-all-threads
1638 "h" gnus-summary-hide-thread
1639 "H" gnus-summary-hide-all-threads
1640 "n" gnus-summary-next-thread
1641 "p" gnus-summary-prev-thread
1642 "u" gnus-summary-up-thread
1643 "o" gnus-summary-top-thread
1644 "d" gnus-summary-down-thread
1645 "#" gnus-uu-mark-thread
1646 "\M-#" gnus-uu-unmark-thread)
1648 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1649 "g" gnus-summary-prepare
1650 "c" gnus-summary-insert-cached-articles)
1652 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1653 "c" gnus-summary-catchup-and-exit
1654 "C" gnus-summary-catchup-all-and-exit
1655 "E" gnus-summary-exit-no-update
1656 "Q" gnus-summary-exit
1657 "Z" gnus-summary-exit
1658 "n" gnus-summary-catchup-and-goto-next-group
1659 "R" gnus-summary-reselect-current-group
1660 "G" gnus-summary-rescan-group
1661 "N" gnus-summary-next-group
1662 "s" gnus-summary-save-newsrc
1663 "P" gnus-summary-prev-group)
1665 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1666 " " gnus-summary-next-page
1667 "n" gnus-summary-next-page
1668 "\177" gnus-summary-prev-page
1669 [delete] gnus-summary-prev-page
1670 "p" gnus-summary-prev-page
1671 "\r" gnus-summary-scroll-up
1672 "\M-\r" gnus-summary-scroll-down
1673 "<" gnus-summary-beginning-of-article
1674 ">" gnus-summary-end-of-article
1675 "b" gnus-summary-beginning-of-article
1676 "e" gnus-summary-end-of-article
1677 "^" gnus-summary-refer-parent-article
1678 "r" gnus-summary-refer-parent-article
1679 "D" gnus-summary-enter-digest-group
1680 "R" gnus-summary-refer-references
1681 "T" gnus-summary-refer-thread
1682 "g" gnus-summary-show-article
1683 "s" gnus-summary-isearch-article
1684 "P" gnus-summary-print-article
1685 "M" gnus-mailing-list-insinuate
1686 "t" gnus-article-babel)
1688 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1689 "b" gnus-article-add-buttons
1690 "B" gnus-article-add-buttons-to-head
1691 "o" gnus-article-treat-overstrike
1692 "e" gnus-article-emphasize
1693 "w" gnus-article-fill-cited-article
1694 "Q" gnus-article-fill-long-lines
1695 "C" gnus-article-capitalize-sentences
1696 "c" gnus-article-remove-cr
1697 "q" gnus-article-de-quoted-unreadable
1698 "6" gnus-article-de-base64-unreadable
1699 "Z" gnus-article-decode-HZ
1700 "h" gnus-article-wash-html
1701 "s" gnus-summary-force-verify-and-decrypt
1702 "f" gnus-article-display-x-face
1703 "l" gnus-summary-stop-page-breaking
1704 "r" gnus-summary-caesar-message
1705 "t" gnus-summary-toggle-header
1706 "g" gnus-summary-toggle-smiley
1707 "v" gnus-summary-verbose-headers
1708 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1709 "p" gnus-article-verify-x-pgp-sig
1710 "d" gnus-article-treat-dumbquotes)
1712 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1713 "a" gnus-article-hide
1714 "h" gnus-article-hide-headers
1715 "b" gnus-article-hide-boring-headers
1716 "s" gnus-article-hide-signature
1717 "c" gnus-article-hide-citation
1718 "C" gnus-article-hide-citation-in-followups
1719 "l" gnus-article-hide-list-identifiers
1720 "p" gnus-article-hide-pgp
1721 "B" gnus-article-strip-banner
1722 "P" gnus-article-hide-pem
1723 "\C-c" gnus-article-hide-citation-maybe)
1725 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1726 "a" gnus-article-highlight
1727 "h" gnus-article-highlight-headers
1728 "c" gnus-article-highlight-citation
1729 "s" gnus-article-highlight-signature)
1731 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1732 "w" gnus-article-decode-mime-words
1733 "c" gnus-article-decode-charset
1734 "v" gnus-mime-view-all-parts
1735 "b" gnus-article-view-part)
1737 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1738 "z" gnus-article-date-ut
1739 "u" gnus-article-date-ut
1740 "l" gnus-article-date-local
1741 "p" gnus-article-date-english
1742 "e" gnus-article-date-lapsed
1743 "o" gnus-article-date-original
1744 "i" gnus-article-date-iso8601
1745 "s" gnus-article-date-user)
1747 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1748 "t" gnus-article-remove-trailing-blank-lines
1749 "l" gnus-article-strip-leading-blank-lines
1750 "m" gnus-article-strip-multiple-blank-lines
1751 "a" gnus-article-strip-blank-lines
1752 "A" gnus-article-strip-all-blank-lines
1753 "s" gnus-article-strip-leading-space
1754 "e" gnus-article-strip-trailing-space
1755 "w" gnus-article-remove-leading-whitespace)
1757 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1759 "f" gnus-summary-fetch-faq
1760 "d" gnus-summary-describe-group
1761 "h" gnus-summary-describe-briefly
1762 "i" gnus-info-find-node)
1764 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1765 "e" gnus-summary-expire-articles
1766 "\M-\C-e" gnus-summary-expire-articles-now
1767 "\177" gnus-summary-delete-article
1768 [delete] gnus-summary-delete-article
1769 [backspace] gnus-summary-delete-article
1770 "m" gnus-summary-move-article
1771 "r" gnus-summary-respool-article
1772 "w" gnus-summary-edit-article
1773 "c" gnus-summary-copy-article
1774 "B" gnus-summary-crosspost-article
1775 "q" gnus-summary-respool-query
1776 "t" gnus-summary-respool-trace
1777 "i" gnus-summary-import-article
1778 "I" gnus-summary-create-article
1779 "p" gnus-summary-article-posted-p)
1781 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1782 "o" gnus-summary-save-article
1783 "m" gnus-summary-save-article-mail
1784 "F" gnus-summary-write-article-file
1785 "r" gnus-summary-save-article-rmail
1786 "f" gnus-summary-save-article-file
1787 "b" gnus-summary-save-article-body-file
1788 "h" gnus-summary-save-article-folder
1789 "v" gnus-summary-save-article-vm
1790 "p" gnus-summary-pipe-output
1791 "s" gnus-soup-add-article)
1793 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1794 "b" gnus-summary-display-buttonized
1795 "m" gnus-summary-repair-multipart
1796 "v" gnus-article-view-part
1797 "o" gnus-article-save-part
1798 "c" gnus-article-copy-part
1799 "C" gnus-article-view-part-as-charset
1800 "e" gnus-article-externalize-part
1801 "E" gnus-article-encrypt-body
1802 "i" gnus-article-inline-part
1803 "|" gnus-article-pipe-part))
1805 (defvar gnus-article-post-menu nil)
1807 (defun gnus-summary-make-menu-bar ()
1808 (gnus-turn-off-edit-menu 'summary)
1810 (unless (boundp 'gnus-summary-misc-menu)
1813 gnus-summary-kill-menu gnus-summary-mode-map ""
1818 ["Customize" gnus-score-customize t])
1819 (gnus-make-score-map 'increase)
1820 (gnus-make-score-map 'lower)
1822 ["Kill below" gnus-summary-kill-below t]
1823 ["Mark above" gnus-summary-mark-above t]
1824 ["Tick above" gnus-summary-tick-above t]
1825 ["Clear above" gnus-summary-clear-above t])
1826 ["Current score" gnus-summary-current-score t]
1827 ["Set score" gnus-summary-set-score t]
1828 ["Switch current score file..." gnus-score-change-score-file t]
1829 ["Set mark below..." gnus-score-set-mark-below t]
1830 ["Set expunge below..." gnus-score-set-expunge-below t]
1831 ["Edit current score file" gnus-score-edit-current-scores t]
1832 ["Edit score file" gnus-score-edit-file t]
1833 ["Trace score" gnus-score-find-trace t]
1834 ["Find words" gnus-score-find-favourite-words t]
1835 ["Rescore buffer" gnus-summary-rescore t]
1836 ["Increase score..." gnus-summary-increase-score t]
1837 ["Lower score..." gnus-summary-lower-score t]))))
1839 ;; Define both the Article menu in the summary buffer and the equivalent
1840 ;; Commands menu in the article buffer here for consistency.
1843 ["All" gnus-article-hide t]
1844 ["Headers" gnus-article-hide-headers t]
1845 ["Signature" gnus-article-hide-signature t]
1846 ["Citation" gnus-article-hide-citation t]
1847 ["List identifiers" gnus-article-hide-list-identifiers t]
1848 ["PGP" gnus-article-hide-pgp t]
1849 ["Banner" gnus-article-strip-banner t]
1850 ["Boring headers" gnus-article-hide-boring-headers t])
1852 ["All" gnus-article-highlight t]
1853 ["Headers" gnus-article-highlight-headers t]
1854 ["Signature" gnus-article-highlight-signature t]
1855 ["Citation" gnus-article-highlight-citation t])
1857 ["Words" gnus-article-decode-mime-words t]
1858 ["Charset" gnus-article-decode-charset t]
1859 ["QP" gnus-article-de-quoted-unreadable t]
1860 ["Base64" gnus-article-de-base64-unreadable t]
1861 ["View all" gnus-mime-view-all-parts t]
1862 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1863 ["Encrypt body" gnus-article-encrypt-body t])
1865 ["Local" gnus-article-date-local t]
1866 ["ISO8601" gnus-article-date-iso8601 t]
1867 ["UT" gnus-article-date-ut t]
1868 ["Original" gnus-article-date-original t]
1869 ["Lapsed" gnus-article-date-lapsed t]
1870 ["User-defined" gnus-article-date-user t])
1873 ["Leading" gnus-article-strip-leading-blank-lines t]
1874 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1875 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1876 ["All of the above" gnus-article-strip-blank-lines t]
1877 ["All" gnus-article-strip-all-blank-lines t]
1878 ["Leading space" gnus-article-strip-leading-space t]
1879 ["Trailing space" gnus-article-strip-trailing-space t]
1880 ["Leading space in headers"
1881 gnus-article-remove-leading-whitespace t])
1882 ["Overstrike" gnus-article-treat-overstrike t]
1883 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1884 ["Emphasis" gnus-article-emphasize t]
1885 ["Word wrap" gnus-article-fill-cited-article t]
1886 ["Fill long lines" gnus-article-fill-long-lines t]
1887 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1888 ["CR" gnus-article-remove-cr t]
1889 ["Show X-Face" gnus-article-display-x-face t]
1890 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1891 ["Base64" gnus-article-de-base64-unreadable t]
1892 ["Rot 13" gnus-summary-caesar-message
1893 ,@(if (featurep 'xemacs) '(t)
1894 '(:help "\"Caesar rotate\" article by 13"))]
1895 ["Unix pipe" gnus-summary-pipe-message t]
1896 ["Add buttons" gnus-article-add-buttons t]
1897 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1898 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1899 ["Verbose header" gnus-summary-verbose-headers t]
1900 ["Toggle header" gnus-summary-toggle-header t]
1901 ["Toggle smiley" gnus-summary-toggle-smiley t]
1902 ["Html" gnus-article-wash-html t]
1903 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1904 ["HZ" gnus-article-decode-HZ t])
1906 ["Save in default format" gnus-summary-save-article
1907 ,@(if (featurep 'xemacs) '(t)
1908 '(:help "Save article using default method"))]
1909 ["Save in file" gnus-summary-save-article-file
1910 ,@(if (featurep 'xemacs) '(t)
1911 '(:help "Save article in file"))]
1912 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1913 ["Save in MH folder" gnus-summary-save-article-folder t]
1914 ["Save in VM folder" gnus-summary-save-article-vm t]
1915 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1916 ["Save body in file" gnus-summary-save-article-body-file t]
1917 ["Pipe through a filter" gnus-summary-pipe-output t]
1918 ["Add to SOUP packet" gnus-soup-add-article t]
1919 ["Print" gnus-summary-print-article t])
1921 ["Respool article..." gnus-summary-respool-article t]
1922 ["Move article..." gnus-summary-move-article
1923 (gnus-check-backend-function
1924 'request-move-article gnus-newsgroup-name)]
1925 ["Copy article..." gnus-summary-copy-article t]
1926 ["Crosspost article..." gnus-summary-crosspost-article
1927 (gnus-check-backend-function
1928 'request-replace-article gnus-newsgroup-name)]
1929 ["Import file..." gnus-summary-import-article t]
1930 ["Create article..." gnus-summary-create-article t]
1931 ["Check if posted" gnus-summary-article-posted-p t]
1932 ["Edit article" gnus-summary-edit-article
1933 (not (gnus-group-read-only-p))]
1934 ["Delete article" gnus-summary-delete-article
1935 (gnus-check-backend-function
1936 'request-expire-articles gnus-newsgroup-name)]
1937 ["Query respool" gnus-summary-respool-query t]
1938 ["Trace respool" gnus-summary-respool-trace t]
1939 ["Delete expirable articles" gnus-summary-expire-articles-now
1940 (gnus-check-backend-function
1941 'request-expire-articles gnus-newsgroup-name)])
1943 ["Uudecode" gnus-uu-decode-uu
1944 ,@(if (featurep 'xemacs) '(t)
1945 '(:help "Decode uuencoded article(s)"))]
1946 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1947 ["Unshar" gnus-uu-decode-unshar t]
1948 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1949 ["Save" gnus-uu-decode-save t]
1950 ["Binhex" gnus-uu-decode-binhex t]
1951 ["Postscript" gnus-uu-decode-postscript t])
1953 ["Enter article" gnus-cache-enter-article t]
1954 ["Remove article" gnus-cache-remove-article t])
1955 ["Translate" gnus-article-babel t]
1956 ["Select article buffer" gnus-summary-select-article-buffer t]
1957 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1958 ["Isearch article..." gnus-summary-isearch-article t]
1959 ["Beginning of the article" gnus-summary-beginning-of-article t]
1960 ["End of the article" gnus-summary-end-of-article t]
1961 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1962 ["Fetch referenced articles" gnus-summary-refer-references t]
1963 ["Fetch current thread" gnus-summary-refer-thread t]
1964 ["Fetch article with id..." gnus-summary-refer-article t]
1965 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1966 ["Redisplay" gnus-summary-show-article t]
1967 ["Raw article" gnus-summary-show-raw-article t])))
1969 gnus-summary-article-menu gnus-summary-mode-map ""
1970 (cons "Article" innards))
1972 (if (not (keymapp gnus-summary-article-menu))
1974 gnus-article-commands-menu gnus-article-mode-map ""
1975 (cons "Commands" innards))
1976 ;; in Emacs, don't share menu.
1977 (setq gnus-article-commands-menu
1978 (copy-keymap gnus-summary-article-menu))
1979 (define-key gnus-article-mode-map [menu-bar commands]
1980 (cons "Commands" gnus-article-commands-menu))))
1983 gnus-summary-thread-menu gnus-summary-mode-map ""
1985 ["Toggle threading" gnus-summary-toggle-threads t]
1986 ["Hide threads" gnus-summary-hide-all-threads t]
1987 ["Show threads" gnus-summary-show-all-threads t]
1988 ["Hide thread" gnus-summary-hide-thread t]
1989 ["Show thread" gnus-summary-show-thread t]
1990 ["Go to next thread" gnus-summary-next-thread t]
1991 ["Go to previous thread" gnus-summary-prev-thread t]
1992 ["Go down thread" gnus-summary-down-thread t]
1993 ["Go up thread" gnus-summary-up-thread t]
1994 ["Top of thread" gnus-summary-top-thread t]
1995 ["Mark thread as read" gnus-summary-kill-thread t]
1996 ["Lower thread score" gnus-summary-lower-thread t]
1997 ["Raise thread score" gnus-summary-raise-thread t]
1998 ["Rethread current" gnus-summary-rethread-current t]))
2001 gnus-summary-post-menu gnus-summary-mode-map ""
2003 ["Post an article" gnus-summary-post-news
2004 ,@(if (featurep 'xemacs) '(t)
2005 '(:help "Post an article"))]
2006 ["Followup" gnus-summary-followup
2007 ,@(if (featurep 'xemacs) '(t)
2008 '(:help "Post followup to this article"))]
2009 ["Followup and yank" gnus-summary-followup-with-original
2010 ,@(if (featurep 'xemacs) '(t)
2011 '(:help "Post followup to this article, quoting its contents"))]
2012 ["Supersede article" gnus-summary-supersede-article t]
2013 ["Cancel article" gnus-summary-cancel-article
2014 ,@(if (featurep 'xemacs) '(t)
2015 '(:help "Cancel an article you posted"))]
2016 ["Reply" gnus-summary-reply t]
2017 ["Reply and yank" gnus-summary-reply-with-original t]
2018 ["Wide reply" gnus-summary-wide-reply t]
2019 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2020 ,@(if (featurep 'xemacs) '(t)
2021 '(:help "Mail a reply, quoting this article"))]
2022 ["Mail forward" gnus-summary-mail-forward t]
2023 ["Post forward" gnus-summary-post-forward t]
2024 ["Digest and mail" gnus-uu-digest-mail-forward t]
2025 ["Digest and post" gnus-uu-digest-post-forward t]
2026 ["Resend message" gnus-summary-resend-message t]
2027 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2028 ["Send a mail" gnus-summary-mail-other-window t]
2029 ["Uuencode and post" gnus-uu-post-news
2030 ,@(if (featurep 'xemacs) '(t)
2031 '(:help "Post a uuencoded article"))]
2032 ["Followup via news" gnus-summary-followup-to-mail t]
2033 ["Followup via news and yank"
2034 gnus-summary-followup-to-mail-with-original t]
2036 ;;["Send" gnus-summary-send-draft t]
2037 ;;["Send bounced" gnus-resend-bounced-mail t])
2041 ((not (keymapp gnus-summary-post-menu))
2042 (setq gnus-article-post-menu gnus-summary-post-menu))
2043 ((not gnus-article-post-menu)
2044 ;; Don't share post menu.
2045 (setq gnus-article-post-menu
2046 (copy-keymap gnus-summary-post-menu))))
2047 (define-key gnus-article-mode-map [menu-bar post]
2048 (cons "Post" gnus-article-post-menu))
2051 gnus-summary-misc-menu gnus-summary-mode-map ""
2054 ["Mark as read" gnus-summary-mark-as-read-forward t]
2055 ["Mark same subject and select"
2056 gnus-summary-kill-same-subject-and-select t]
2057 ["Mark same subject" gnus-summary-kill-same-subject t]
2058 ["Catchup" gnus-summary-catchup
2059 ,@(if (featurep 'xemacs) '(t)
2060 '(:help "Mark unread articles in this group as read"))]
2061 ["Catchup all" gnus-summary-catchup-all t]
2062 ["Catchup to here" gnus-summary-catchup-to-here t]
2063 ["Catchup from here" gnus-summary-catchup-from-here t]
2064 ["Catchup region" gnus-summary-mark-region-as-read t]
2065 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2067 ["Tick" gnus-summary-tick-article-forward t]
2068 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2069 ["Remove marks" gnus-summary-clear-mark-forward t]
2070 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2071 ["Set bookmark" gnus-summary-set-bookmark t]
2072 ["Remove bookmark" gnus-summary-remove-bookmark t])
2074 ["Marks..." gnus-summary-limit-to-marks t]
2075 ["Subject..." gnus-summary-limit-to-subject t]
2076 ["Author..." gnus-summary-limit-to-author t]
2077 ["Age..." gnus-summary-limit-to-age t]
2078 ["Extra..." gnus-summary-limit-to-extra t]
2079 ["Score" gnus-summary-limit-to-score t]
2080 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2081 ["Unread" gnus-summary-limit-to-unread t]
2082 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2083 ["Articles" gnus-summary-limit-to-articles t]
2084 ["Pop limit" gnus-summary-pop-limit t]
2085 ["Show dormant" gnus-summary-limit-include-dormant t]
2086 ["Hide childless dormant"
2087 gnus-summary-limit-exclude-childless-dormant t]
2088 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2089 ["Hide marked" gnus-summary-limit-exclude-marks t]
2090 ["Show expunged" gnus-summary-limit-include-expunged t])
2092 ["Set mark" gnus-summary-mark-as-processable t]
2093 ["Remove mark" gnus-summary-unmark-as-processable t]
2094 ["Remove all marks" gnus-summary-unmark-all-processable t]
2095 ["Mark above" gnus-uu-mark-over t]
2096 ["Mark series" gnus-uu-mark-series t]
2097 ["Mark region" gnus-uu-mark-region t]
2098 ["Unmark region" gnus-uu-unmark-region t]
2099 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2100 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2101 ["Mark all" gnus-uu-mark-all t]
2102 ["Mark buffer" gnus-uu-mark-buffer t]
2103 ["Mark sparse" gnus-uu-mark-sparse t]
2104 ["Mark thread" gnus-uu-mark-thread t]
2105 ["Unmark thread" gnus-uu-unmark-thread t]
2106 ("Process Mark Sets"
2107 ["Kill" gnus-summary-kill-process-mark t]
2108 ["Yank" gnus-summary-yank-process-mark
2109 gnus-newsgroup-process-stack]
2110 ["Save" gnus-summary-save-process-mark t]))
2112 ["Page forward" gnus-summary-next-page
2113 ,@(if (featurep 'xemacs) '(t)
2114 '(:help "Show next page of article"))]
2115 ["Page backward" gnus-summary-prev-page
2116 ,@(if (featurep 'xemacs) '(t)
2117 '(:help "Show previous page of article"))]
2118 ["Line forward" gnus-summary-scroll-up t])
2120 ["Next unread article" gnus-summary-next-unread-article t]
2121 ["Previous unread article" gnus-summary-prev-unread-article t]
2122 ["Next article" gnus-summary-next-article t]
2123 ["Previous article" gnus-summary-prev-article t]
2124 ["Next unread subject" gnus-summary-next-unread-subject t]
2125 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2126 ["Next article same subject" gnus-summary-next-same-subject t]
2127 ["Previous article same subject" gnus-summary-prev-same-subject t]
2128 ["First unread article" gnus-summary-first-unread-article t]
2129 ["Best unread article" gnus-summary-best-unread-article t]
2130 ["Go to subject number..." gnus-summary-goto-subject t]
2131 ["Go to article number..." gnus-summary-goto-article t]
2132 ["Go to the last article" gnus-summary-goto-last-article t]
2133 ["Pop article off history" gnus-summary-pop-article t])
2135 ["Sort by number" gnus-summary-sort-by-number t]
2136 ["Sort by author" gnus-summary-sort-by-author t]
2137 ["Sort by subject" gnus-summary-sort-by-subject t]
2138 ["Sort by date" gnus-summary-sort-by-date t]
2139 ["Sort by score" gnus-summary-sort-by-score t]
2140 ["Sort by lines" gnus-summary-sort-by-lines t]
2141 ["Sort by characters" gnus-summary-sort-by-chars t]
2142 ["Original sort" gnus-summary-sort-by-original t])
2144 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2145 ["Describe group" gnus-summary-describe-group t]
2146 ["Read manual" gnus-info-find-node t])
2148 ["Pick and read" gnus-pick-mode t]
2149 ["Binary" gnus-binary-mode t])
2151 ["Regenerate" gnus-summary-prepare t]
2152 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2153 ["Toggle threading" gnus-summary-toggle-threads t])
2154 ["See old articles" gnus-summary-insert-old-articles t]
2155 ["See new articles" gnus-summary-insert-new-articles t]
2156 ["Filter articles..." gnus-summary-execute-command t]
2157 ["Run command on subjects..." gnus-summary-universal-argument t]
2158 ["Search articles forward..." gnus-summary-search-article-forward t]
2159 ["Search articles backward..." gnus-summary-search-article-backward t]
2160 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2161 ["Expand window" gnus-summary-expand-window t]
2162 ["Expire expirable articles" gnus-summary-expire-articles
2163 (gnus-check-backend-function
2164 'request-expire-articles gnus-newsgroup-name)]
2165 ["Edit local kill file" gnus-summary-edit-local-kill t]
2166 ["Edit main kill file" gnus-summary-edit-global-kill t]
2167 ["Edit group parameters" gnus-summary-edit-parameters t]
2168 ["Customize group parameters" gnus-summary-customize-parameters t]
2169 ["Send a bug report" gnus-bug t]
2171 ["Catchup and exit" gnus-summary-catchup-and-exit
2172 ,@(if (featurep 'xemacs) '(t)
2173 '(:help "Mark unread articles in this group as read, then exit"))]
2174 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2175 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2176 ["Exit group" gnus-summary-exit
2177 ,@(if (featurep 'xemacs) '(t)
2178 '(:help "Exit current group, return to group selection mode"))]
2179 ["Exit group without updating" gnus-summary-exit-no-update t]
2180 ["Exit and goto next group" gnus-summary-next-group t]
2181 ["Exit and goto prev group" gnus-summary-prev-group t]
2182 ["Reselect group" gnus-summary-reselect-current-group t]
2183 ["Rescan group" gnus-summary-rescan-group t]
2184 ["Update dribble" gnus-summary-save-newsrc t])))
2186 (gnus-run-hooks 'gnus-summary-menu-hook)))
2188 (defvar gnus-summary-tool-bar-map nil)
2190 ;; Emacs 21 tool bar. Should be no-op otherwise.
2191 (defun gnus-summary-make-tool-bar ()
2192 (if (and (fboundp 'tool-bar-add-item-from-menu)
2193 (default-value 'tool-bar-mode)
2194 (not gnus-summary-tool-bar-map))
2195 (setq gnus-summary-tool-bar-map
2196 (let ((tool-bar-map (make-sparse-keymap))
2197 (load-path (mm-image-load-path)))
2198 (tool-bar-add-item-from-menu
2199 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2200 (tool-bar-add-item-from-menu
2201 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2202 (tool-bar-add-item-from-menu
2203 'gnus-summary-post-news "post" gnus-summary-mode-map)
2204 (tool-bar-add-item-from-menu
2205 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2206 (tool-bar-add-item-from-menu
2207 'gnus-summary-followup "followup" gnus-summary-mode-map)
2208 (tool-bar-add-item-from-menu
2209 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2210 (tool-bar-add-item-from-menu
2211 'gnus-summary-reply "reply" gnus-summary-mode-map)
2212 (tool-bar-add-item-from-menu
2213 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2214 (tool-bar-add-item-from-menu
2215 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2216 (tool-bar-add-item-from-menu
2217 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2218 (tool-bar-add-item-from-menu
2219 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2220 (tool-bar-add-item-from-menu
2221 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2222 (tool-bar-add-item-from-menu
2223 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2224 (tool-bar-add-item-from-menu
2225 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2226 (tool-bar-add-item-from-menu
2227 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2229 (if gnus-summary-tool-bar-map
2230 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2232 (defun gnus-score-set-default (var value)
2233 "A version of set that updates the GNU Emacs menu-bar."
2235 ;; It is the message that forces the active status to be updated.
2238 (defun gnus-make-score-map (type)
2239 "Make a summary score map of type TYPE."
2242 (let ((headers '(("author" "from" string)
2243 ("subject" "subject" string)
2244 ("article body" "body" string)
2245 ("article head" "head" string)
2246 ("xref" "xref" string)
2247 ("extra header" "extra" string)
2248 ("lines" "lines" number)
2249 ("followups to author" "followup" string)))
2250 (types '((number ("less than" <)
2253 (string ("substring" s)
2257 (perms '(("temporary" (current-time-string))
2265 (if (eq type 'lower)
2270 (setq header (car headers))
2276 (let ((ts (cdr (assoc (nth 2 header) types)))
2292 'gnus-summary-score-entry
2294 (if (or (string= (nth 1 header)
2296 (string= (nth 1 header)
2299 (list 'gnus-summary-header
2301 (list 'quote (nth 1 (car ts)))
2302 (list 'gnus-score-delta-default
2309 (list (nreverse outp))))
2312 (list (nreverse outt))))
2314 (setq headers (cdr headers)))
2315 (list (nreverse outh))))))))
2319 (defun gnus-summary-mode (&optional group)
2320 "Major mode for reading articles.
2322 All normal editing commands are switched off.
2323 \\<gnus-summary-mode-map>
2324 Each line in this buffer represents one article. To read an
2325 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2326 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2329 You can also post articles and send mail from this buffer. To
2330 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2331 of an article, type `\\[gnus-summary-reply]'.
2333 There are approx. one gazillion commands you can execute in this
2334 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2336 The following commands are available:
2338 \\{gnus-summary-mode-map}"
2340 (kill-all-local-variables)
2341 (when (gnus-visual-p 'summary-menu 'menu)
2342 (gnus-summary-make-menu-bar)
2343 (gnus-summary-make-tool-bar))
2344 (gnus-summary-make-local-variables)
2345 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2346 (gnus-summary-make-local-variables))
2347 (gnus-make-thread-indent-array)
2348 (gnus-simplify-mode-line)
2349 (setq major-mode 'gnus-summary-mode)
2350 (setq mode-name "Summary")
2351 (make-local-variable 'minor-mode-alist)
2352 (use-local-map gnus-summary-mode-map)
2353 (buffer-disable-undo)
2354 (setq buffer-read-only t) ;Disable modification
2355 (setq truncate-lines t)
2356 (setq selective-display t)
2357 (setq selective-display-ellipses t) ;Display `...'
2358 (gnus-summary-set-display-table)
2359 (gnus-set-default-directory)
2360 (setq gnus-newsgroup-name group)
2361 (make-local-variable 'gnus-summary-line-format)
2362 (make-local-variable 'gnus-summary-line-format-spec)
2363 (make-local-variable 'gnus-summary-dummy-line-format)
2364 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2365 (make-local-variable 'gnus-summary-mark-positions)
2366 (make-local-hook 'pre-command-hook)
2367 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2368 (gnus-run-hooks 'gnus-summary-mode-hook)
2369 (turn-on-gnus-mailing-list-mode)
2370 (mm-enable-multibyte-mule4)
2371 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2372 (gnus-update-summary-mark-positions))
2374 (defun gnus-summary-make-local-variables ()
2375 "Make all the local summary buffer variables."
2377 (dolist (local gnus-summary-local-variables)
2380 (if (eq (cdr local) 'global)
2381 ;; Copy the global value of the variable.
2382 (setq global (symbol-value (car local)))
2383 ;; Use the value from the list.
2384 (setq global (eval (cdr local))))
2385 (set (make-local-variable (car local)) global))
2386 ;; Simple nil-valued local variable.
2387 (set (make-local-variable local) nil)))))
2389 (defun gnus-summary-clear-local-variables ()
2390 (let ((locals gnus-summary-local-variables))
2392 (if (consp (car locals))
2393 (and (vectorp (caar locals))
2394 (set (caar locals) nil))
2395 (and (vectorp (car locals))
2396 (set (car locals) nil)))
2397 (setq locals (cdr locals)))))
2399 ;; Summary data functions.
2401 (defmacro gnus-data-number (data)
2404 (defmacro gnus-data-set-number (data number)
2405 `(setcar ,data ,number))
2407 (defmacro gnus-data-mark (data)
2410 (defmacro gnus-data-set-mark (data mark)
2411 `(setcar (nthcdr 1 ,data) ,mark))
2413 (defmacro gnus-data-pos (data)
2416 (defmacro gnus-data-set-pos (data pos)
2417 `(setcar (nthcdr 2 ,data) ,pos))
2419 (defmacro gnus-data-header (data)
2422 (defmacro gnus-data-set-header (data header)
2423 `(setf (nth 3 ,data) ,header))
2425 (defmacro gnus-data-level (data)
2428 (defmacro gnus-data-unread-p (data)
2429 `(= (nth 1 ,data) gnus-unread-mark))
2431 (defmacro gnus-data-read-p (data)
2432 `(/= (nth 1 ,data) gnus-unread-mark))
2434 (defmacro gnus-data-pseudo-p (data)
2435 `(consp (nth 3 ,data)))
2437 (defmacro gnus-data-find (number)
2438 `(assq ,number gnus-newsgroup-data))
2440 (defmacro gnus-data-find-list (number &optional data)
2441 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2442 (memq (assq ,number bdata)
2445 (defmacro gnus-data-make (number mark pos header level)
2446 `(list ,number ,mark ,pos ,header ,level))
2448 (defun gnus-data-enter (after-article number mark pos header level offset)
2449 (let ((data (gnus-data-find-list after-article)))
2451 (error "No such article: %d" after-article))
2452 (setcdr data (cons (gnus-data-make number mark pos header level)
2454 (setq gnus-newsgroup-data-reverse nil)
2455 (gnus-data-update-list (cddr data) offset)))
2457 (defun gnus-data-enter-list (after-article list &optional offset)
2459 (let ((data (and after-article (gnus-data-find-list after-article)))
2463 (let ((odata gnus-newsgroup-data))
2464 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2466 (gnus-data-update-list odata offset)))
2467 ;; Find the last element in the list to be spliced into the main
2470 (setq list (cdr list)))
2473 (setcdr list gnus-newsgroup-data)
2474 (setq gnus-newsgroup-data ilist)
2476 (gnus-data-update-list (cdr list) offset)))
2477 (setcdr list (cdr data))
2480 (gnus-data-update-list (cdr list) offset))))
2481 (setq gnus-newsgroup-data-reverse nil))))
2483 (defun gnus-data-remove (article &optional offset)
2484 (let ((data gnus-newsgroup-data))
2485 (if (= (gnus-data-number (car data)) article)
2487 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2488 gnus-newsgroup-data-reverse nil)
2490 (gnus-data-update-list gnus-newsgroup-data offset)))
2492 (when (= (gnus-data-number (cadr data)) article)
2493 (setcdr data (cddr data))
2495 (gnus-data-update-list (cdr data) offset))
2497 gnus-newsgroup-data-reverse nil))
2498 (setq data (cdr data))))))
2500 (defmacro gnus-data-list (backward)
2502 (or gnus-newsgroup-data-reverse
2503 (setq gnus-newsgroup-data-reverse
2504 (reverse gnus-newsgroup-data)))
2505 gnus-newsgroup-data))
2507 (defun gnus-data-update-list (data offset)
2508 "Add OFFSET to the POS of all data entries in DATA."
2509 (setq gnus-newsgroup-data-reverse nil)
2511 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2512 (setq data (cdr data))))
2514 (defun gnus-summary-article-pseudo-p (article)
2515 "Say whether this article is a pseudo article or not."
2516 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2518 (defmacro gnus-summary-article-sparse-p (article)
2519 "Say whether this article is a sparse article or not."
2520 `(memq ,article gnus-newsgroup-sparse))
2522 (defmacro gnus-summary-article-ancient-p (article)
2523 "Say whether this article is a sparse article or not."
2524 `(memq ,article gnus-newsgroup-ancient))
2526 (defun gnus-article-parent-p (number)
2527 "Say whether this article is a parent or not."
2528 (let ((data (gnus-data-find-list number)))
2529 (and (cdr data) ; There has to be an article after...
2530 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2531 (gnus-data-level (nth 1 data))))))
2533 (defun gnus-article-children (number)
2534 "Return a list of all children to NUMBER."
2535 (let* ((data (gnus-data-find-list number))
2536 (level (gnus-data-level (car data)))
2538 (setq data (cdr data))
2540 (= (gnus-data-level (car data)) (1+ level)))
2541 (push (gnus-data-number (car data)) children)
2542 (setq data (cdr data)))
2545 (defmacro gnus-summary-skip-intangible ()
2546 "If the current article is intangible, then jump to a different article."
2547 '(let ((to (get-text-property (point) 'gnus-intangible)))
2548 (and to (gnus-summary-goto-subject to))))
2550 (defmacro gnus-summary-article-intangible-p ()
2551 "Say whether this article is intangible or not."
2552 '(get-text-property (point) 'gnus-intangible))
2554 (defun gnus-article-read-p (article)
2555 "Say whether ARTICLE is read or not."
2556 (not (or (memq article gnus-newsgroup-marked)
2557 (memq article gnus-newsgroup-unreads)
2558 (memq article gnus-newsgroup-unselected)
2559 (memq article gnus-newsgroup-dormant))))
2561 ;; Some summary mode macros.
2563 (defmacro gnus-summary-article-number ()
2564 "The article number of the article on the current line.
2565 If there isn's an article number here, then we return the current
2568 (gnus-summary-skip-intangible)
2569 (or (get-text-property (point) 'gnus-number)
2570 (gnus-summary-last-subject))))
2572 (defmacro gnus-summary-article-header (&optional number)
2573 "Return the header of article NUMBER."
2574 `(gnus-data-header (gnus-data-find
2575 ,(or number '(gnus-summary-article-number)))))
2577 (defmacro gnus-summary-thread-level (&optional number)
2578 "Return the level of thread that starts with article NUMBER."
2579 `(if (and (eq gnus-summary-make-false-root 'dummy)
2580 (get-text-property (point) 'gnus-intangible))
2582 (gnus-data-level (gnus-data-find
2583 ,(or number '(gnus-summary-article-number))))))
2585 (defmacro gnus-summary-article-mark (&optional number)
2586 "Return the mark of article NUMBER."
2587 `(gnus-data-mark (gnus-data-find
2588 ,(or number '(gnus-summary-article-number)))))
2590 (defmacro gnus-summary-article-pos (&optional number)
2591 "Return the position of the line of article NUMBER."
2592 `(gnus-data-pos (gnus-data-find
2593 ,(or number '(gnus-summary-article-number)))))
2595 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2596 (defmacro gnus-summary-article-subject (&optional number)
2597 "Return current subject string or nil if nothing."
2600 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2601 '(gnus-data-header (assq (gnus-summary-article-number)
2602 gnus-newsgroup-data)))))
2605 (mail-header-subject headers))))
2607 (defmacro gnus-summary-article-score (&optional number)
2608 "Return current article score."
2609 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2610 gnus-newsgroup-scored))
2611 gnus-summary-default-score 0))
2613 (defun gnus-summary-article-children (&optional number)
2614 "Return a list of article numbers that are children of article NUMBER."
2615 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2616 (level (gnus-data-level (car data)))
2618 (while (and (setq data (cdr data))
2619 (> (setq l (gnus-data-level (car data))) level))
2620 (and (= (1+ level) l)
2621 (push (gnus-data-number (car data))
2623 (nreverse children)))
2625 (defun gnus-summary-article-parent (&optional number)
2626 "Return the article number of the parent of article NUMBER."
2627 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2628 (gnus-data-list t)))
2629 (level (gnus-data-level (car data))))
2631 () ; This is a root.
2632 ;; We search until we find an article with a level less than
2633 ;; this one. That function has to be the parent.
2634 (while (and (setq data (cdr data))
2635 (not (< (gnus-data-level (car data)) level))))
2636 (and data (gnus-data-number (car data))))))
2638 (defun gnus-unread-mark-p (mark)
2639 "Say whether MARK is the unread mark."
2640 (= mark gnus-unread-mark))
2642 (defun gnus-read-mark-p (mark)
2643 "Say whether MARK is one of the marks that mark as read.
2644 This is all marks except unread, ticked, dormant, and expirable."
2645 (not (or (= mark gnus-unread-mark)
2646 (= mark gnus-ticked-mark)
2647 (= mark gnus-dormant-mark)
2648 (= mark gnus-expirable-mark))))
2650 (defmacro gnus-article-mark (number)
2651 "Return the MARK of article NUMBER.
2652 This macro should only be used when computing the mark the \"first\"
2653 time; i.e., when generating the summary lines. After that,
2654 `gnus-summary-article-mark' should be used to examine the
2657 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2658 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2659 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2660 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2661 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2662 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2663 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2664 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2665 gnus-ancient-mark))))
2667 ;; Saving hidden threads.
2669 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2670 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2672 (defmacro gnus-save-hidden-threads (&rest forms)
2673 "Save hidden threads, eval FORMS, and restore the hidden threads."
2674 (let ((config (make-symbol "config")))
2675 `(let ((,config (gnus-hidden-threads-configuration)))
2679 (gnus-restore-hidden-threads-configuration ,config)))))
2681 (defun gnus-data-compute-positions ()
2682 "Compute the positions of all articles."
2683 (setq gnus-newsgroup-data-reverse nil)
2684 (let ((data gnus-newsgroup-data))
2686 (gnus-save-hidden-threads
2687 (gnus-summary-show-all-threads)
2688 (goto-char (point-min))
2690 (while (get-text-property (point) 'gnus-intangible)
2692 (gnus-data-set-pos (car data) (+ (point) 3))
2693 (setq data (cdr data))
2694 (forward-line 1))))))
2696 (defun gnus-hidden-threads-configuration ()
2697 "Return the current hidden threads configuration."
2700 (goto-char (point-min))
2701 (while (search-forward "\r" nil t)
2702 (push (1- (point)) config))
2705 (defun gnus-restore-hidden-threads-configuration (config)
2706 "Restore hidden threads configuration from CONFIG."
2708 (let (point buffer-read-only)
2709 (while (setq point (pop config))
2710 (when (and (< point (point-max))
2712 (eq (char-after) ?\n))
2713 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2715 ;; Various summary mode internalish functions.
2717 (defun gnus-mouse-pick-article (e)
2720 (gnus-summary-next-page nil t))
2722 (defun gnus-summary-set-display-table ()
2723 "Change the display table.
2724 Odd characters have a tendency to mess
2725 up nicely formatted displays - we make all possible glyphs
2726 display only a single character."
2728 ;; We start from the standard display table, if any.
2729 (let ((table (or (copy-sequence standard-display-table)
2730 (make-display-table)))
2732 ;; Nix out all the control chars...
2733 (while (>= (setq i (1- i)) 0)
2734 (aset table i [??]))
2735 ;; ... but not newline and cr, of course. (cr is necessary for the
2736 ;; selective display).
2737 (aset table ?\n nil)
2738 (aset table ?\r nil)
2739 ;; We keep TAB as well.
2740 (aset table ?\t nil)
2741 ;; We nix out any glyphs over 126 that are not set already.
2743 (while (>= (setq i (1- i)) 127)
2744 ;; Only modify if the entry is nil.
2745 (unless (aref table i)
2746 (aset table i [??]))))
2747 (setq buffer-display-table table)))
2749 (defun gnus-summary-set-article-display-arrow (pos)
2750 "Update the overlay arrow to point to line at position POS."
2751 (when (and gnus-summary-display-arrow
2752 (boundp 'overlay-arrow-position)
2753 (boundp 'overlay-arrow-string))
2757 (unless overlay-arrow-position
2758 (setq overlay-arrow-position (make-marker)))
2759 (setq overlay-arrow-string "=>"
2760 overlay-arrow-position (set-marker overlay-arrow-position
2762 (current-buffer))))))
2764 (defun gnus-summary-buffer-name (group)
2765 "Return the summary buffer name of GROUP."
2766 (concat "*Summary " group "*"))
2768 (defun gnus-summary-setup-buffer (group)
2769 "Initialize summary buffer."
2770 (let ((buffer (gnus-summary-buffer-name group)))
2771 (if (get-buffer buffer)
2774 (setq gnus-summary-buffer (current-buffer))
2775 (not gnus-newsgroup-prepared))
2776 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2777 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2778 (gnus-summary-mode group)
2780 (gnus-carpal-setup-buffer 'summary))
2781 (unless gnus-single-article-buffer
2782 (make-local-variable 'gnus-article-buffer)
2783 (make-local-variable 'gnus-article-current)
2784 (make-local-variable 'gnus-original-article-buffer))
2785 (setq gnus-newsgroup-name group)
2786 ;; Set any local variables in the group parameters.
2787 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2790 (defun gnus-set-global-variables ()
2791 "Set the global equivalents of the buffer-local variables.
2792 They are set to the latest values they had. These reflect the summary
2793 buffer that was in action when the last article was fetched."
2794 (when (eq major-mode 'gnus-summary-mode)
2795 (setq gnus-summary-buffer (current-buffer))
2796 (let ((name gnus-newsgroup-name)
2797 (marked gnus-newsgroup-marked)
2798 (unread gnus-newsgroup-unreads)
2799 (headers gnus-current-headers)
2800 (data gnus-newsgroup-data)
2801 (summary gnus-summary-buffer)
2802 (article-buffer gnus-article-buffer)
2803 (original gnus-original-article-buffer)
2804 (gac gnus-article-current)
2805 (reffed gnus-reffed-article-number)
2806 (score-file gnus-current-score-file)
2807 (default-charset gnus-newsgroup-charset)
2809 (let ((locals gnus-newsgroup-variables))
2811 (if (consp (car locals))
2812 (push (eval (caar locals)) vlist)
2813 (push (eval (car locals)) vlist))
2814 (setq locals (cdr locals)))
2815 (setq vlist (nreverse vlist)))
2817 (set-buffer gnus-group-buffer)
2818 (setq gnus-newsgroup-name name
2819 gnus-newsgroup-marked marked
2820 gnus-newsgroup-unreads unread
2821 gnus-current-headers headers
2822 gnus-newsgroup-data data
2823 gnus-article-current gac
2824 gnus-summary-buffer summary
2825 gnus-article-buffer article-buffer
2826 gnus-original-article-buffer original
2827 gnus-reffed-article-number reffed
2828 gnus-current-score-file score-file
2829 gnus-newsgroup-charset default-charset)
2830 (let ((locals gnus-newsgroup-variables))
2832 (if (consp (car locals))
2833 (set (caar locals) (pop vlist))
2834 (set (car locals) (pop vlist)))
2835 (setq locals (cdr locals))))
2836 ;; The article buffer also has local variables.
2837 (when (gnus-buffer-live-p gnus-article-buffer)
2838 (set-buffer gnus-article-buffer)
2839 (setq gnus-summary-buffer summary))))))
2841 (defun gnus-summary-article-unread-p (article)
2842 "Say whether ARTICLE is unread or not."
2843 (memq article gnus-newsgroup-unreads))
2845 (defun gnus-summary-first-article-p (&optional article)
2846 "Return whether ARTICLE is the first article in the buffer."
2847 (if (not (setq article (or article (gnus-summary-article-number))))
2849 (eq article (caar gnus-newsgroup-data))))
2851 (defun gnus-summary-last-article-p (&optional article)
2852 "Return whether ARTICLE is the last article in the buffer."
2853 (if (not (setq article (or article (gnus-summary-article-number))))
2854 ;; All non-existent numbers are the last article. :-)
2856 (not (cdr (gnus-data-find-list article)))))
2858 (defun gnus-make-thread-indent-array ()
2860 (unless (and gnus-thread-indent-array
2861 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2862 (setq gnus-thread-indent-array (make-vector 201 "")
2863 gnus-thread-indent-array-level gnus-thread-indent-level)
2865 (aset gnus-thread-indent-array n
2866 (make-string (* n gnus-thread-indent-level) ? ))
2869 (defun gnus-update-summary-mark-positions ()
2870 "Compute where the summary marks are to go."
2872 (when (gnus-buffer-exists-p gnus-summary-buffer)
2873 (set-buffer gnus-summary-buffer))
2874 (let ((gnus-replied-mark 129)
2875 (gnus-score-below-mark 130)
2876 (gnus-score-over-mark 130)
2877 (gnus-download-mark 131)
2878 (spec gnus-summary-line-format-spec)
2881 (gnus-set-work-buffer)
2882 (let ((gnus-summary-line-format-spec spec)
2883 (gnus-newsgroup-downloadable '((0 . t))))
2884 (gnus-summary-insert-line
2885 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2886 0 nil 128 t nil "" nil 1)
2887 (goto-char (point-min))
2888 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2890 (goto-char (point-min))
2891 (push (cons 'replied (and (search-forward "\201" nil t)
2894 (goto-char (point-min))
2895 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2897 (goto-char (point-min))
2898 (push (cons 'download
2899 (and (search-forward "\203" nil t) (- (point) 2)))
2901 (setq gnus-summary-mark-positions pos))))
2903 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2904 "Insert a dummy root in the summary buffer."
2906 (gnus-add-text-properties
2907 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2908 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2910 (defun gnus-summary-extract-address-component (from)
2911 (or (car (funcall gnus-extract-address-components from))
2914 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2915 (let ((mail-parse-charset gnus-newsgroup-charset)
2916 ; Is it really necessary to do this next part for each summary line?
2917 ; Luckily, doesn't seem to slow things down much.
2918 (mail-parse-ignored-charsets
2919 (save-excursion (set-buffer gnus-summary-buffer)
2920 gnus-newsgroup-ignored-charsets)))
2922 (and gnus-ignored-from-addresses
2923 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2924 (let ((extra-headers (mail-header-extra header))
2928 ((setq to (cdr (assq 'To extra-headers)))
2930 (gnus-summary-extract-address-component
2931 (funcall gnus-decode-encoded-word-function to))))
2932 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2933 (concat "=> " newsgroups)))))
2934 (gnus-summary-extract-address-component gnus-tmp-from))))
2936 (defun gnus-summary-insert-line (gnus-tmp-header
2937 gnus-tmp-level gnus-tmp-current
2938 gnus-tmp-unread gnus-tmp-replied
2939 gnus-tmp-expirable gnus-tmp-subject-or-nil
2940 &optional gnus-tmp-dummy gnus-tmp-score
2942 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2943 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2944 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2945 (gnus-tmp-score-char
2946 (if (or (null gnus-summary-default-score)
2947 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2948 gnus-summary-zcore-fuzz))
2950 (if (< gnus-tmp-score gnus-summary-default-score)
2951 gnus-score-below-mark gnus-score-over-mark)))
2952 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2954 (cond (gnus-tmp-process gnus-process-mark)
2955 ((memq gnus-tmp-current gnus-newsgroup-cached)
2957 (gnus-tmp-replied gnus-replied-mark)
2958 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
2959 gnus-forwarded-mark)
2960 ((memq gnus-tmp-current gnus-newsgroup-saved)
2962 ((memq gnus-tmp-number gnus-newsgroup-recent)
2964 ((memq gnus-tmp-number gnus-newsgroup-unseen)
2967 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2970 ((string-match "<[^>]+> *$" gnus-tmp-from)
2971 (let ((beg (match-beginning 0)))
2972 (or (and (string-match "^\".+\"" gnus-tmp-from)
2973 (substring gnus-tmp-from 1 (1- (match-end 0))))
2974 (substring gnus-tmp-from 0 beg))))
2975 ((string-match "(.+)" gnus-tmp-from)
2976 (substring gnus-tmp-from
2977 (1+ (match-beginning 0)) (1- (match-end 0))))
2979 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2980 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2981 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2982 (buffer-read-only nil))
2983 (when (string= gnus-tmp-name "")
2984 (setq gnus-tmp-name gnus-tmp-from))
2985 (unless (numberp gnus-tmp-lines)
2986 (setq gnus-tmp-lines -1))
2987 (if (= gnus-tmp-lines -1)
2988 (setq gnus-tmp-lines "?")
2989 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
2990 (gnus-put-text-property
2992 (progn (eval gnus-summary-line-format-spec) (point))
2993 'gnus-number gnus-tmp-number)
2994 (when (gnus-visual-p 'summary-highlight 'highlight)
2996 (gnus-run-hooks 'gnus-summary-update-hook)
2999 (defun gnus-summary-update-line (&optional dont-update)
3000 "Update summary line after change."
3001 (when (and gnus-summary-default-score
3002 (not gnus-summary-inhibit-highlight))
3003 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3004 (article (gnus-summary-article-number))
3005 (score (gnus-summary-article-score article)))
3007 (if (and gnus-summary-mark-below
3008 (< (gnus-summary-article-score)
3009 gnus-summary-mark-below))
3010 ;; This article has a low score, so we mark it as read.
3011 (when (memq article gnus-newsgroup-unreads)
3012 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3013 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3014 ;; This article was previously marked as read on account
3015 ;; of a low score, but now it has risen, so we mark it as
3017 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3018 (gnus-summary-update-mark
3019 (if (or (null gnus-summary-default-score)
3020 (<= (abs (- score gnus-summary-default-score))
3021 gnus-summary-zcore-fuzz))
3023 (if (< score gnus-summary-default-score)
3024 gnus-score-below-mark gnus-score-over-mark))
3026 ;; Do visual highlighting.
3027 (when (gnus-visual-p 'summary-highlight 'highlight)
3028 (gnus-run-hooks 'gnus-summary-update-hook)))))
3030 (defvar gnus-tmp-new-adopts nil)
3032 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3033 "Return the number of articles in THREAD.
3034 This may be 0 in some cases -- if none of the articles in
3035 the thread are to be displayed."
3037 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3039 ((not (listp thread))
3041 ((and (consp thread) (cdr thread))
3044 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3047 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3050 (when (and level (zerop level) gnus-tmp-new-adopts)
3053 'gnus-summary-number-of-articles-in-thread
3054 gnus-tmp-new-adopts))))
3056 (if (> number 1) gnus-not-empty-thread-mark
3057 gnus-empty-thread-mark)
3060 (defun gnus-summary-set-local-parameters (group)
3061 "Go through the local params of GROUP and set all variable specs in that list."
3062 (let ((params (gnus-group-find-parameter group))
3063 (vars '(quit-config)) ; Ignore quit-config.
3066 (setq elem (car params)
3067 params (cdr params))
3068 (and (consp elem) ; Has to be a cons.
3069 (consp (cdr elem)) ; The cdr has to be a list.
3070 (symbolp (car elem)) ; Has to be a symbol in there.
3071 (not (memq (car elem) vars))
3072 (ignore-errors ; So we set it.
3073 (push (car elem) vars)
3074 (make-local-variable (car elem))
3075 (set (car elem) (eval (nth 1 elem))))))))
3077 (defun gnus-summary-read-group (group &optional show-all no-article
3078 kill-buffer no-display backward
3080 "Start reading news in newsgroup GROUP.
3081 If SHOW-ALL is non-nil, already read articles are also listed.
3082 If NO-ARTICLE is non-nil, no article is selected initially.
3083 If NO-DISPLAY, don't generate a summary buffer."
3087 (let ((gnus-auto-select-next nil))
3088 (or (gnus-summary-read-group-1
3089 group show-all no-article
3090 kill-buffer no-display
3093 select-articles nil)))))
3094 (eq gnus-auto-select-next 'quietly))
3095 (set-buffer gnus-group-buffer)
3096 ;; The entry function called above goes to the next
3097 ;; group automatically, so we go two groups back
3098 ;; if we are searching for the previous group.
3100 (gnus-group-prev-unread-group 2))
3101 (if (not (equal group (gnus-group-group-name)))
3102 (setq group (gnus-group-group-name))
3106 (defun gnus-summary-read-group-1 (group show-all no-article
3107 kill-buffer no-display
3108 &optional select-articles)
3109 ;; Killed foreign groups can't be entered.
3110 ;; (when (and (not (gnus-group-native-p group))
3111 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3112 ;; (error "Dead non-native groups can't be entered"))
3113 (gnus-message 5 "Retrieving newsgroup: %s..."
3114 (gnus-group-decoded-name group))
3115 (let* ((new-group (gnus-summary-setup-buffer group))
3116 (quit-config (gnus-group-quit-config group))
3117 (did-select (and new-group (gnus-select-newsgroup
3118 group show-all select-articles))))
3120 ;; This summary buffer exists already, so we just select it.
3122 (gnus-set-global-variables)
3124 (gnus-kill-or-deaden-summary kill-buffer))
3125 (gnus-configure-windows 'summary 'force)
3126 (gnus-set-mode-line 'summary)
3127 (gnus-summary-position-point)
3130 ;; We couldn't select this group.
3132 (when (and (eq major-mode 'gnus-summary-mode)
3133 (not (equal (current-buffer) kill-buffer)))
3134 (kill-buffer (current-buffer))
3135 (if (not quit-config)
3137 ;; Update the info -- marks might need to be removed,
3139 (gnus-summary-update-info)
3140 (set-buffer gnus-group-buffer)
3141 (gnus-group-jump-to-group group)
3142 (gnus-group-next-unread-group 1))
3143 (gnus-handle-ephemeral-exit quit-config)))
3144 (let ((grpinfo (gnus-get-info group)))
3145 (if (null (gnus-info-read grpinfo))
3146 (gnus-message 3 "Group %s contains no messages"
3147 (gnus-group-decoded-name group))
3148 (gnus-message 3 "Can't select group")))
3150 ;; The user did a `C-g' while prompting for number of articles,
3151 ;; so we exit this group.
3152 ((eq did-select 'quit)
3153 (and (eq major-mode 'gnus-summary-mode)
3154 (not (equal (current-buffer) kill-buffer))
3155 (kill-buffer (current-buffer)))
3157 (gnus-kill-or-deaden-summary kill-buffer))
3158 (if (not quit-config)
3160 (set-buffer gnus-group-buffer)
3161 (gnus-group-jump-to-group group)
3162 (gnus-group-next-unread-group 1)
3163 (gnus-configure-windows 'group 'force))
3164 (gnus-handle-ephemeral-exit quit-config))
3165 ;; Finally signal the quit.
3167 ;; The group was successfully selected.
3169 (gnus-set-global-variables)
3170 ;; Save the active value in effect when the group was entered.
3171 (setq gnus-newsgroup-active
3173 (gnus-active gnus-newsgroup-name)))
3174 ;; You can change the summary buffer in some way with this hook.
3175 (gnus-run-hooks 'gnus-select-group-hook)
3176 (gnus-update-format-specifications
3177 nil 'summary 'summary-mode 'summary-dummy)
3178 (gnus-update-summary-mark-positions)
3179 ;; Do score processing.
3180 (when gnus-use-scoring
3181 (gnus-possibly-score-headers))
3182 ;; Check whether to fill in the gaps in the threads.
3183 (when gnus-build-sparse-threads
3184 (gnus-build-sparse-threads))
3185 ;; Find the initial limit.
3186 (if gnus-show-threads
3188 (let ((gnus-newsgroup-dormant nil))
3189 (gnus-summary-initial-limit show-all))
3190 (gnus-summary-initial-limit show-all))
3191 ;; When untreaded, all articles are always shown.
3192 (setq gnus-newsgroup-limit
3194 (lambda (header) (mail-header-number header))
3195 gnus-newsgroup-headers)))
3196 ;; Generate the summary buffer.
3198 (gnus-summary-prepare))
3199 (when gnus-use-trees
3200 (gnus-tree-open group)
3201 (setq gnus-summary-highlight-line-function
3202 'gnus-tree-highlight-article))
3203 ;; If the summary buffer is empty, but there are some low-scored
3204 ;; articles or some excluded dormants, we include these in the
3206 (when (and (zerop (buffer-size))
3208 (cond (gnus-newsgroup-dormant
3209 (gnus-summary-limit-include-dormant))
3210 ((and gnus-newsgroup-scored show-all)
3211 (gnus-summary-limit-include-expunged t))))
3212 ;; Function `gnus-apply-kill-file' must be called in this hook.
3213 (gnus-run-hooks 'gnus-apply-kill-hook)
3214 (if (and (zerop (buffer-size))
3217 ;; This newsgroup is empty.
3218 (gnus-summary-catchup-and-exit nil t)
3219 (gnus-message 6 "No unread news")
3221 (gnus-kill-or-deaden-summary kill-buffer))
3222 ;; Return nil from this function.
3224 ;; Hide conversation thread subtrees. We cannot do this in
3225 ;; gnus-summary-prepare-hook since kill processing may not
3226 ;; work with hidden articles.
3227 (and gnus-show-threads
3228 gnus-thread-hide-subtree
3229 (gnus-summary-hide-all-threads))
3231 (gnus-kill-or-deaden-summary kill-buffer))
3232 ;; Show first unread article if requested.
3233 (if (and (not no-article)
3235 gnus-newsgroup-unreads
3236 gnus-auto-select-first)
3238 (gnus-configure-windows 'summary)
3240 ((eq gnus-auto-select-first 'best)
3241 (gnus-summary-best-unread-article))
3242 ((eq gnus-auto-select-first t)
3243 (gnus-summary-first-unread-article))
3244 ((gnus-functionp gnus-auto-select-first)
3245 (funcall gnus-auto-select-first))))
3246 ;; Don't select any articles, just move point to the first
3247 ;; article in the group.
3248 (goto-char (point-min))
3249 (gnus-summary-position-point)
3250 (gnus-configure-windows 'summary 'force)
3251 (gnus-set-mode-line 'summary))
3252 (when (get-buffer-window gnus-group-buffer t)
3253 ;; Gotta use windows, because recenter does weird stuff if
3254 ;; the current buffer ain't the displayed window.
3255 (let ((owin (selected-window)))
3256 (select-window (get-buffer-window gnus-group-buffer t))
3257 (when (gnus-group-goto-group group)
3259 (select-window owin)))
3260 ;; Mark this buffer as "prepared".
3261 (setq gnus-newsgroup-prepared t)
3262 (gnus-run-hooks 'gnus-summary-prepared-hook)
3265 (defun gnus-summary-prepare ()
3266 "Generate the summary buffer."
3268 (let ((buffer-read-only nil))
3270 (setq gnus-newsgroup-data nil
3271 gnus-newsgroup-data-reverse nil)
3272 (gnus-run-hooks 'gnus-summary-generate-hook)
3273 ;; Generate the buffer, either with threads or without.
3274 (when gnus-newsgroup-headers
3275 (gnus-summary-prepare-threads
3276 (if gnus-show-threads
3277 (gnus-sort-gathered-threads
3278 (funcall gnus-summary-thread-gathering-function
3280 (gnus-cut-threads (gnus-make-threads)))))
3281 ;; Unthreaded display.
3282 (gnus-sort-articles gnus-newsgroup-headers))))
3283 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3284 ;; Call hooks for modifying summary buffer.
3285 (goto-char (point-min))
3286 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3288 (defsubst gnus-general-simplify-subject (subject)
3289 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3292 ;; Truncate the subject.
3293 (gnus-simplify-subject-functions
3294 (gnus-map-function gnus-simplify-subject-functions subject))
3295 ((numberp gnus-summary-gather-subject-limit)
3296 (setq subject (gnus-simplify-subject-re subject))
3297 (if (> (length subject) gnus-summary-gather-subject-limit)
3298 (substring subject 0 gnus-summary-gather-subject-limit)
3300 ;; Fuzzily simplify it.
3301 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3302 (gnus-simplify-subject-fuzzy subject))
3303 ;; Just remove the leading "Re:".
3305 (gnus-simplify-subject-re subject))))
3307 (if (and gnus-summary-gather-exclude-subject
3308 (string-match gnus-summary-gather-exclude-subject subject))
3309 nil ; This article shouldn't be gathered
3312 (defun gnus-summary-simplify-subject-query ()
3313 "Query where the respool algorithm would put this article."
3315 (gnus-summary-select-article)
3316 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3318 (defun gnus-gather-threads-by-subject (threads)
3319 "Gather threads by looking at Subject headers."
3320 (if (not gnus-summary-make-false-root)
3322 (let ((hashtb (gnus-make-hashtable 1024))
3325 subject hthread whole-subject)
3327 (setq subject (gnus-general-simplify-subject
3328 (setq whole-subject (mail-header-subject
3331 (if (setq hthread (gnus-gethash subject hashtb))
3333 ;; We enter a dummy root into the thread, if we
3334 ;; haven't done that already.
3335 (unless (stringp (caar hthread))
3336 (setcar hthread (list whole-subject (car hthread))))
3337 ;; We add this new gathered thread to this gathered
3339 (setcdr (car hthread)
3340 (nconc (cdar hthread) (list (car threads))))
3341 ;; Remove it from the list of threads.
3342 (setcdr prev (cdr threads))
3343 (setq threads prev))
3344 ;; Enter this thread into the hash table.
3345 (gnus-sethash subject threads hashtb)))
3347 (setq threads (cdr threads)))
3350 (defun gnus-gather-threads-by-references (threads)
3351 "Gather threads by looking at References headers."
3352 (let ((idhashtb (gnus-make-hashtable 1024))
3353 (thhashtb (gnus-make-hashtable 1024))
3356 ids references id gthread gid entered ref)
3358 (when (setq references (mail-header-references (caar threads)))
3359 (setq id (mail-header-id (caar threads))
3360 ids (gnus-split-references references)
3362 (while (setq ref (pop ids))
3363 (setq ids (delete ref ids))
3364 (if (not (setq gid (gnus-gethash ref idhashtb)))
3366 (gnus-sethash ref id idhashtb)
3367 (gnus-sethash id threads thhashtb))
3368 (setq gthread (gnus-gethash gid thhashtb))
3370 ;; We enter a dummy root into the thread, if we
3371 ;; haven't done that already.
3372 (unless (stringp (caar gthread))
3373 (setcar gthread (list (mail-header-subject (caar gthread))
3375 ;; We add this new gathered thread to this gathered
3377 (setcdr (car gthread)
3378 (nconc (cdar gthread) (list (car threads)))))
3379 ;; Add it into the thread hash table.
3380 (gnus-sethash id gthread thhashtb)
3382 ;; Remove it from the list of threads.
3383 (setcdr prev (cdr threads))
3384 (setq threads prev))))
3386 (setq threads (cdr threads)))
3389 (defun gnus-sort-gathered-threads (threads)
3390 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3391 (let ((result threads))
3393 (when (stringp (caar threads))
3394 (setcdr (car threads)
3395 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3396 (setq threads (cdr threads)))
3399 (defun gnus-thread-loop-p (root thread)
3400 "Say whether ROOT is in THREAD."
3401 (let ((stack (list thread))
3404 (while (setq thread (pop stack))
3405 (setq th (cdr thread))
3407 (not (eq (caar th) root)))
3410 ;; We have found a loop.
3412 (setcdr thread (delq (car th) (cdr thread)))
3413 (if (boundp (setq ref-dep (intern "none"
3414 gnus-newsgroup-dependencies)))
3415 (setcdr (symbol-value ref-dep)
3416 (nconc (cdr (symbol-value ref-dep))
3418 (set ref-dep (list nil (car th))))
3421 ;; Push all the subthreads onto the stack.
3422 (push (cdr thread) stack)))
3425 (defun gnus-make-threads ()
3426 "Go through the dependency hashtb and find the roots. Return all threads."
3428 (while (catch 'infloop
3431 ;; Deal with self-referencing References loops.
3432 (when (and (car (symbol-value refs))
3439 (car (symbol-value refs)) thread))
3440 (cdr (symbol-value refs)))))))
3443 (unless (car (symbol-value refs))
3444 ;; These threads do not refer back to any other articles,
3445 ;; so they're roots.
3446 (setq threads (append (cdr (symbol-value refs)) threads))))
3447 gnus-newsgroup-dependencies)))
3450 ;; Build the thread tree.
3451 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3452 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3454 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3455 if it was already present.
3457 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3458 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3459 Message-IDs will be renamed be renamed to a unique Message-ID before
3462 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3463 (let* ((id (mail-header-id header))
3464 (id-dep (and id (intern id dependencies)))
3465 ref ref-dep ref-header)
3466 ;; Enter this `header' in the `dependencies' table.
3470 ;; The first two cases do the normal part: enter a new `header'
3471 ;; in the `dependencies' table.
3472 ((not (boundp id-dep))
3473 (set id-dep (list header)))
3474 ((null (car (symbol-value id-dep)))
3475 (setcar (symbol-value id-dep) header))
3477 ;; From here the `header' was already present in the
3478 ;; `dependencies' table.
3480 ;; Overrides an existing entry;
3481 ;; just set the header part of the entry.
3482 (setcar (symbol-value id-dep) header))
3484 ;; Renames the existing `header' to a unique Message-ID.
3485 ((not gnus-summary-ignore-duplicates)
3486 ;; An article with this Message-ID has already been seen.
3487 ;; We rename the Message-ID.
3488 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3490 (mail-header-set-id header id))
3492 ;; The last case ignores an existing entry, except it adds any
3493 ;; additional Xrefs (in case the two articles came from different
3495 ;; Also sets `header' to `nil' meaning that the `dependencies'
3496 ;; table was *not* modified.
3498 (mail-header-set-xref
3499 (car (symbol-value id-dep))
3500 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3502 (or (mail-header-xref header) "")))
3506 ;; First check if that we are not creating a References loop.
3507 (setq ref (gnus-parent-id (mail-header-references header)))
3509 (setq ref-dep (intern-soft ref dependencies))
3511 (setq ref-header (car (symbol-value ref-dep))))
3512 (if (string= id ref)
3513 ;; Yuk! This is a reference loop. Make the article be a
3516 (mail-header-set-references (car (symbol-value id-dep)) "none")
3518 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3519 (setq ref (gnus-parent-id (mail-header-references header)))
3520 (setq ref-dep (intern (or ref "none") dependencies))
3521 (if (boundp ref-dep)
3522 (setcdr (symbol-value ref-dep)
3523 (nconc (cdr (symbol-value ref-dep))
3524 (list (symbol-value id-dep))))
3525 (set ref-dep (list nil (symbol-value id-dep)))))
3528 (defun gnus-build-sparse-threads ()
3529 (let ((headers gnus-newsgroup-headers)
3530 (mail-parse-charset gnus-newsgroup-charset)
3531 (gnus-summary-ignore-duplicates t)
3532 header references generation relations
3533 subject child end new-child date)
3534 ;; First we create an alist of generations/relations, where
3535 ;; generations is how much we trust the relation, and the relation
3537 (gnus-message 7 "Making sparse threads...")
3539 (nnheader-set-temp-buffer " *gnus sparse threads*")
3540 (while (setq header (pop headers))
3541 (when (and (setq references (mail-header-references header))
3542 (not (string= references "")))
3544 (setq child (mail-header-id header)
3545 subject (mail-header-subject header)
3546 date (mail-header-date header)
3548 (while (search-backward ">" nil t)
3549 (setq end (1+ (point)))
3550 (when (search-backward "<" nil t)
3551 (setq new-child (buffer-substring (point) end))
3552 (push (list (incf generation)
3553 child (setq child new-child)
3557 (push (list (1+ generation) child nil subject) relations))
3559 (kill-buffer (current-buffer)))
3560 ;; Sort over trustworthiness.
3563 (when (gnus-dependencies-add-header
3564 (make-full-mail-header
3565 gnus-reffed-article-number
3566 (nth 3 relation) "" (or (nth 4 relation) "")
3568 (or (nth 2 relation) "") 0 0 "")
3569 gnus-newsgroup-dependencies nil)
3570 (push gnus-reffed-article-number gnus-newsgroup-limit)
3571 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3572 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3573 gnus-newsgroup-reads)
3574 (decf gnus-reffed-article-number)))
3575 (sort relations 'car-less-than-car))
3576 (gnus-message 7 "Making sparse threads...done")))
3578 (defun gnus-build-old-threads ()
3579 ;; Look at all the articles that refer back to old articles, and
3580 ;; fetch the headers for the articles that aren't there. This will
3581 ;; build complete threads - if the roots haven't been expired by the
3583 (let ((mail-parse-charset gnus-newsgroup-charset)
3587 (when (not (car (symbol-value refs)))
3588 (setq heads (cdr (symbol-value refs)))
3590 (if (memq (mail-header-number (caar heads))
3591 gnus-newsgroup-dormant)
3592 (setq heads (cdr heads))
3593 (setq id (symbol-name refs))
3594 (while (and (setq id (gnus-build-get-header id))
3595 (not (car (gnus-id-to-thread id)))))
3596 (setq heads nil)))))
3597 gnus-newsgroup-dependencies)))
3599 ;; This function has to be called with point after the article number
3600 ;; on the beginning of the line.
3601 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3602 (let ((eol (gnus-point-at-eol))
3603 (buffer (current-buffer))
3606 ;; overview: [num subject from date id refs chars lines misc]
3609 (narrow-to-region (point) eol)
3614 (make-full-mail-header
3616 (funcall gnus-decode-encoded-word-function
3617 (nnheader-nov-field)) ; subject
3618 (funcall gnus-decode-encoded-word-function
3619 (nnheader-nov-field)) ; from
3620 (nnheader-nov-field) ; date
3621 (nnheader-nov-read-message-id) ; id
3622 (nnheader-nov-field) ; refs
3623 (nnheader-nov-read-integer) ; chars
3624 (nnheader-nov-read-integer) ; lines
3626 (if (looking-at "Xref: ")
3627 (goto-char (match-end 0)))
3628 (nnheader-nov-field)) ; Xref
3629 (nnheader-nov-parse-extra)))) ; extra
3633 (when gnus-alter-header-function
3634 (funcall gnus-alter-header-function header))
3635 (gnus-dependencies-add-header header dependencies force-new)))
3637 (defun gnus-build-get-header (id)
3638 "Look through the buffer of NOV lines and find the header to ID.
3639 Enter this line into the dependencies hash table, and return
3640 the id of the parent article (if any)."
3641 (let ((deps gnus-newsgroup-dependencies)
3645 (set-buffer nntp-server-buffer)
3646 (let ((case-fold-search nil))
3647 (goto-char (point-min))
3648 (while (and (not found)
3649 (search-forward id nil t))
3651 (setq found (looking-at
3652 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3653 (regexp-quote id))))
3654 (or found (beginning-of-line 2)))
3658 (setq header (gnus-nov-parse-line
3659 (read (current-buffer)) deps))
3660 (gnus-parent-id (mail-header-references header))))))
3662 (let ((number (mail-header-number header)))
3663 (push number gnus-newsgroup-limit)
3664 (push header gnus-newsgroup-headers)
3665 (if (memq number gnus-newsgroup-unselected)
3667 (push number gnus-newsgroup-unreads)
3668 (setq gnus-newsgroup-unselected
3669 (delq number gnus-newsgroup-unselected)))
3670 (push number gnus-newsgroup-ancient)))))))
3672 (defun gnus-build-all-threads ()
3673 "Read all the headers."
3674 (let ((gnus-summary-ignore-duplicates t)
3675 (mail-parse-charset gnus-newsgroup-charset)
3676 (dependencies gnus-newsgroup-dependencies)
3679 (set-buffer nntp-server-buffer)
3680 (let ((case-fold-search nil))
3681 (goto-char (point-min))
3684 (setq article (read (current-buffer))
3685 header (gnus-nov-parse-line article dependencies)))
3688 (set-buffer gnus-summary-buffer)
3689 (push header gnus-newsgroup-headers)
3690 (if (memq (setq article (mail-header-number header))
3691 gnus-newsgroup-unselected)
3693 (push article gnus-newsgroup-unreads)
3694 (setq gnus-newsgroup-unselected
3695 (delq article gnus-newsgroup-unselected)))
3696 (push article gnus-newsgroup-ancient)))
3697 (forward-line 1)))))))
3699 (defun gnus-summary-update-article-line (article header)
3700 "Update the line for ARTICLE using HEADERS."
3701 (let* ((id (mail-header-id header))
3702 (thread (gnus-id-to-thread id)))
3704 (error "Article in no thread"))
3705 ;; Update the thread.
3706 (setcar thread header)
3707 (gnus-summary-goto-subject article)
3708 (let* ((datal (gnus-data-find-list article))
3710 (length (when (cdr datal)
3711 (- (gnus-data-pos data)
3712 (gnus-data-pos (cadr datal)))))
3713 (buffer-read-only nil)
3714 (level (gnus-summary-thread-level)))
3716 (gnus-summary-insert-line
3717 header level nil (gnus-article-mark article)
3718 (memq article gnus-newsgroup-replied)
3719 (memq article gnus-newsgroup-expirable)
3720 ;; Only insert the Subject string when it's different
3721 ;; from the previous Subject string.
3726 (mail-header-subject
3729 (gnus-data-find-list
3731 (gnus-data-list t)))))
3732 ;; Error on the side of excessive subjects.
3734 (mail-header-subject header)))
3736 (mail-header-subject header))
3737 nil (cdr (assq article gnus-newsgroup-scored))
3738 (memq article gnus-newsgroup-processable))
3740 (gnus-data-update-list
3741 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3743 (defun gnus-summary-update-article (article &optional iheader)
3744 "Update ARTICLE in the summary buffer."
3745 (set-buffer gnus-summary-buffer)
3746 (let* ((header (gnus-summary-article-header article))
3747 (id (mail-header-id header))
3748 (data (gnus-data-find article))
3749 (thread (gnus-id-to-thread id))
3750 (references (mail-header-references header))
3754 (when (and references
3755 (not (equal "" references)))
3758 (buffer-read-only nil)
3764 (delq thread parent)))
3765 (if (gnus-summary-insert-subject id header)
3766 ;; Set the (possibly) new article number in the data structure.
3767 (gnus-data-set-number data (gnus-id-to-article id))
3771 (defun gnus-rebuild-thread (id &optional line)
3772 "Rebuild the thread containing ID.
3773 If LINE, insert the rebuilt thread starting on line LINE."
3774 (let ((buffer-read-only nil)
3775 old-pos current thread data)
3776 (if (not gnus-show-threads)
3777 (setq thread (list (car (gnus-id-to-thread id))))
3778 ;; Get the thread this article is part of.
3779 (setq thread (gnus-remove-thread id)))
3780 (setq old-pos (gnus-point-at-bol))
3781 (setq current (save-excursion
3782 (and (re-search-backward "[\r\n]" nil t)
3783 (gnus-summary-article-number))))
3784 ;; If this is a gathered thread, we have to go some re-gathering.
3785 (when (stringp (car thread))
3786 (let ((subject (car thread))
3788 (setq thread (cdr thread))
3790 (unless (memq (setq thr (gnus-id-to-thread
3792 (mail-header-id (caar thread)))))
3795 (setq thread (cdr thread)))
3796 ;; We now have all (unique) roots.
3797 (if (= (length roots) 1)
3798 ;; All the loose roots are now one solid root.
3799 (setq thread (car roots))
3800 (setq thread (cons subject (gnus-sort-threads roots))))))
3802 ;; We then insert this thread into the summary buffer.
3804 (goto-char (point-min))
3805 (forward-line (1- line)))
3806 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3807 (if gnus-show-threads
3808 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3809 (gnus-summary-prepare-unthreaded thread))
3810 (setq data (nreverse gnus-newsgroup-data))
3811 (setq threads gnus-newsgroup-threads))
3812 ;; We splice the new data into the data structure.
3813 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3814 ;;!!! then we want to insert at the beginning of the buffer.
3815 ;;!!! That happens to be true with Gnus now, but that may
3816 ;;!!! change in the future. Perhaps.
3817 (gnus-data-enter-list
3818 (if line nil current) data (- (point) old-pos))
3819 (setq gnus-newsgroup-threads
3820 (nconc threads gnus-newsgroup-threads))
3821 (gnus-data-compute-positions))))
3823 (defun gnus-number-to-header (number)
3824 "Return the header for article NUMBER."
3825 (let ((headers gnus-newsgroup-headers))
3827 (not (= number (mail-header-number (car headers)))))
3832 (defun gnus-parent-headers (in-headers &optional generation)
3833 "Return the headers of the GENERATIONeth parent of HEADERS."
3835 (setq generation 1))
3837 (headers in-headers)
3840 (not (zerop generation))
3841 (setq references (mail-header-references headers)))
3842 (setq headers (if (and references
3843 (setq parent (gnus-parent-id references)))
3844 (car (gnus-id-to-thread parent))
3847 (and (not (eq headers in-headers))
3850 (defun gnus-id-to-thread (id)
3851 "Return the (sub-)thread where ID appears."
3852 (gnus-gethash id gnus-newsgroup-dependencies))
3854 (defun gnus-id-to-article (id)
3855 "Return the article number of ID."
3856 (let ((thread (gnus-id-to-thread id)))
3859 (mail-header-number (car thread)))))
3861 (defun gnus-id-to-header (id)
3862 "Return the article headers of ID."
3863 (car (gnus-id-to-thread id)))
3865 (defun gnus-article-displayed-root-p (article)
3866 "Say whether ARTICLE is a root(ish) article."
3867 (let ((level (gnus-summary-thread-level article))
3868 (refs (mail-header-references (gnus-summary-article-header article)))
3874 ((null (gnus-parent-id refs)) t)
3876 (null (setq particle (gnus-id-to-article
3877 (gnus-parent-id refs))))
3878 (null (gnus-summary-thread-level particle)))))))
3880 (defun gnus-root-id (id)
3881 "Return the id of the root of the thread where ID appears."
3883 (while (and id (setq prev (car (gnus-id-to-thread id))))
3885 id (gnus-parent-id (mail-header-references prev))))
3888 (defun gnus-articles-in-thread (thread)
3889 "Return the list of articles in THREAD."
3890 (cons (mail-header-number (car thread))
3891 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3893 (defun gnus-remove-thread (id &optional dont-remove)
3894 "Remove the thread that has ID in it."
3895 (let (headers thread last-id)
3896 ;; First go up in this thread until we find the root.
3897 (setq last-id (gnus-root-id id)
3898 headers (message-flatten-list (gnus-id-to-thread last-id)))
3899 ;; We have now found the real root of this thread. It might have
3900 ;; been gathered into some loose thread, so we have to search
3901 ;; through the threads to find the thread we wanted.
3902 (let ((threads gnus-newsgroup-threads)
3905 (setq sub (car threads))
3906 (if (stringp (car sub))
3907 ;; This is a gathered thread, so we look at the roots
3908 ;; below it to find whether this article is in this
3911 (setq sub (cdr sub))
3913 (when (member (caar sub) headers)
3914 (setq thread (car threads)
3917 (setq sub (cdr sub))))
3918 ;; It's an ordinary thread, so we check it.
3919 (when (eq (car sub) (car headers))
3922 (setq threads (cdr threads)))
3923 ;; If this article is in no thread, then it's a root.
3926 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3927 (setq thread (gnus-id-to-thread last-id)))
3930 thread ; We return this thread.
3932 (if (stringp (car thread))
3934 ;; If we use dummy roots, then we have to remove the
3935 ;; dummy root as well.
3936 (when (eq gnus-summary-make-false-root 'dummy)
3937 ;; We go to the dummy root by going to
3938 ;; the first sub-"thread", and then one line up.
3939 (gnus-summary-goto-article
3940 (mail-header-number (caadr thread)))
3943 (gnus-data-compute-positions))
3944 (setq thread (cdr thread))
3946 (gnus-remove-thread-1 (car thread))
3947 (setq thread (cdr thread))))
3948 (gnus-remove-thread-1 thread))))))))
3950 (defun gnus-remove-thread-1 (thread)
3951 "Remove the thread THREAD recursively."
3952 (let ((number (mail-header-number (pop thread)))
3954 (setq thread (reverse thread))
3956 (gnus-remove-thread-1 (pop thread)))
3957 (when (setq d (gnus-data-find number))
3958 (goto-char (gnus-data-pos d))
3959 (gnus-summary-show-thread)
3962 (- (gnus-point-at-bol)
3964 (1+ (gnus-point-at-eol))
3965 (gnus-delete-line)))))))
3967 (defun gnus-sort-threads-1 (threads func)
3968 (sort (mapcar (lambda (thread)
3971 (gnus-sort-threads-1 (cdr thread) func))))
3974 (defun gnus-sort-threads (threads)
3976 (if (not gnus-thread-sort-functions)
3978 (gnus-message 8 "Sorting threads...")
3980 (gnus-sort-threads-1
3982 (gnus-make-sort-function gnus-thread-sort-functions))
3983 (gnus-message 8 "Sorting threads...done"))))
3985 (defun gnus-sort-articles (articles)
3987 (when gnus-article-sort-functions
3988 (gnus-message 7 "Sorting articles...")
3990 (setq gnus-newsgroup-headers
3991 (sort articles (gnus-make-sort-function
3992 gnus-article-sort-functions)))
3993 (gnus-message 7 "Sorting articles...done"))))
3995 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3996 (defmacro gnus-thread-header (thread)
3997 "Return header of first article in THREAD.
3998 Note that THREAD must never, ever be anything else than a variable -
3999 using some other form will lead to serious barfage."
4000 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4001 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4002 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4005 (defsubst gnus-article-sort-by-number (h1 h2)
4006 "Sort articles by article number."
4007 (< (mail-header-number h1)
4008 (mail-header-number h2)))
4010 (defun gnus-thread-sort-by-number (h1 h2)
4011 "Sort threads by root article number."
4012 (gnus-article-sort-by-number
4013 (gnus-thread-header h1) (gnus-thread-header h2)))
4015 (defsubst gnus-article-sort-by-lines (h1 h2)
4016 "Sort articles by article Lines header."
4017 (< (mail-header-lines h1)
4018 (mail-header-lines h2)))
4020 (defun gnus-thread-sort-by-lines (h1 h2)
4021 "Sort threads by root article Lines header."
4022 (gnus-article-sort-by-lines
4023 (gnus-thread-header h1) (gnus-thread-header h2)))
4025 (defsubst gnus-article-sort-by-chars (h1 h2)
4026 "Sort articles by octet length."
4027 (< (mail-header-chars h1)
4028 (mail-header-chars h2)))
4030 (defun gnus-thread-sort-by-chars (h1 h2)
4031 "Sort threads by root article octet length."
4032 (gnus-article-sort-by-chars
4033 (gnus-thread-header h1) (gnus-thread-header h2)))
4035 (defsubst gnus-article-sort-by-author (h1 h2)
4036 "Sort articles by root author."
4038 (let ((extract (funcall
4039 gnus-extract-address-components
4040 (mail-header-from h1))))
4041 (or (car extract) (cadr extract) ""))
4042 (let ((extract (funcall
4043 gnus-extract-address-components
4044 (mail-header-from h2))))
4045 (or (car extract) (cadr extract) ""))))
4047 (defun gnus-thread-sort-by-author (h1 h2)
4048 "Sort threads by root author."
4049 (gnus-article-sort-by-author
4050 (gnus-thread-header h1) (gnus-thread-header h2)))
4052 (defsubst gnus-article-sort-by-subject (h1 h2)
4053 "Sort articles by root subject."
4055 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4056 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4058 (defun gnus-thread-sort-by-subject (h1 h2)
4059 "Sort threads by root subject."
4060 (gnus-article-sort-by-subject
4061 (gnus-thread-header h1) (gnus-thread-header h2)))
4063 (defsubst gnus-article-sort-by-date (h1 h2)
4064 "Sort articles by root article date."
4066 (gnus-date-get-time (mail-header-date h1))
4067 (gnus-date-get-time (mail-header-date h2))))
4069 (defun gnus-thread-sort-by-date (h1 h2)
4070 "Sort threads by root article date."
4071 (gnus-article-sort-by-date
4072 (gnus-thread-header h1) (gnus-thread-header h2)))
4074 (defsubst gnus-article-sort-by-score (h1 h2)
4075 "Sort articles by root article score.
4076 Unscored articles will be counted as having a score of zero."
4077 (> (or (cdr (assq (mail-header-number h1)
4078 gnus-newsgroup-scored))
4079 gnus-summary-default-score 0)
4080 (or (cdr (assq (mail-header-number h2)
4081 gnus-newsgroup-scored))
4082 gnus-summary-default-score 0)))
4084 (defun gnus-thread-sort-by-score (h1 h2)
4085 "Sort threads by root article score."
4086 (gnus-article-sort-by-score
4087 (gnus-thread-header h1) (gnus-thread-header h2)))
4089 (defun gnus-thread-sort-by-total-score (h1 h2)
4090 "Sort threads by the sum of all scores in the thread.
4091 Unscored articles will be counted as having a score of zero."
4092 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4094 (defun gnus-thread-total-score (thread)
4095 ;; This function find the total score of THREAD.
4096 (cond ((null thread)
4099 (if (stringp (car thread))
4100 (apply gnus-thread-score-function 0
4101 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4102 (gnus-thread-total-score-1 thread)))
4104 (gnus-thread-total-score-1 (list thread)))))
4106 (defun gnus-thread-total-score-1 (root)
4107 ;; This function find the total score of the thread below ROOT.
4108 (setq root (car root))
4109 (apply gnus-thread-score-function
4111 (mapcar 'gnus-thread-total-score
4112 (cdr (gnus-id-to-thread (mail-header-id root))))
4113 (when (> (mail-header-number root) 0)
4114 (list (or (cdr (assq (mail-header-number root)
4115 gnus-newsgroup-scored))
4116 gnus-summary-default-score 0))))
4117 (list gnus-summary-default-score)
4120 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4121 (defvar gnus-tmp-prev-subject nil)
4122 (defvar gnus-tmp-false-parent nil)
4123 (defvar gnus-tmp-root-expunged nil)
4124 (defvar gnus-tmp-dummy-line nil)
4126 (eval-when-compile (defvar gnus-tmp-header))
4127 (defun gnus-extra-header (type &optional header)
4128 "Return the extra header of TYPE."
4129 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4132 (defvar gnus-tmp-thread-tree-header-string "")
4134 (defvar gnus-sum-thread-tree-root "> "
4135 "With %B spec, used for the root of a thread.
4136 If nil, use subject instead.")
4137 (defvar gnus-sum-thread-tree-single-indent ""
4138 "With %B spec, used for a thread with just one message.
4139 If nil, use subject instead.")
4140 (defvar gnus-sum-thread-tree-vertical "| "
4141 "With %B spec, used for drawing a vertical line.")
4142 (defvar gnus-sum-thread-tree-indent " "
4143 "With %B spec, used for indenting.")
4144 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4145 "With %B spec, used for a leaf with brothers.")
4146 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4147 "With %B spec, used for a leaf without brothers.")
4149 (defun gnus-summary-prepare-threads (threads)
4150 "Prepare summary buffer from THREADS and indentation LEVEL.
4151 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4152 or a straight list of headers."
4153 (gnus-message 7 "Generating summary...")
4155 (setq gnus-newsgroup-threads threads)
4158 (let ((gnus-tmp-level 0)
4159 (default-score (or gnus-summary-default-score 0))
4160 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4161 thread number subject stack state gnus-tmp-gathered beg-match
4162 new-roots gnus-tmp-new-adopts thread-end
4163 gnus-tmp-header gnus-tmp-unread
4164 gnus-tmp-replied gnus-tmp-subject-or-nil
4165 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4166 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4167 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4170 (setq gnus-tmp-prev-subject nil)
4172 (if (vectorp (car threads))
4173 ;; If this is a straight (sic) list of headers, then a
4174 ;; threaded summary display isn't required, so we just create
4175 ;; an unthreaded one.
4176 (gnus-summary-prepare-unthreaded threads)
4178 ;; Do the threaded display.
4180 (while (or threads stack gnus-tmp-new-adopts new-roots)
4182 (if (and (= gnus-tmp-level 0)
4185 (not gnus-tmp-false-parent)
4186 (or gnus-tmp-new-adopts new-roots))
4187 (if gnus-tmp-new-adopts
4188 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4189 thread (list (car gnus-tmp-new-adopts))
4190 gnus-tmp-header (caar thread)
4191 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4193 (setq thread (list (car new-roots))
4194 gnus-tmp-header (caar thread)
4195 new-roots (cdr new-roots))))
4198 ;; If there are some threads, we do them before the
4199 ;; threads on the stack.
4200 (setq thread threads
4201 gnus-tmp-header (caar thread))
4202 ;; There were no current threads, so we pop something off
4204 (setq state (car stack)
4205 gnus-tmp-level (car state)
4206 tree-stack (cadr state)
4207 thread (caddr state)
4209 gnus-tmp-header (caar thread))))
4211 (setq gnus-tmp-false-parent nil)
4212 (setq gnus-tmp-root-expunged nil)
4213 (setq thread-end nil)
4215 (if (stringp gnus-tmp-header)
4216 ;; The header is a dummy root.
4218 ((eq gnus-summary-make-false-root 'adopt)
4219 ;; We let the first article adopt the rest.
4220 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4222 (setq gnus-tmp-gathered
4224 (lambda (h) (mail-header-number (car h)))
4227 (setq thread (cons (list (caar thread)
4230 (setq gnus-tmp-level -1
4231 gnus-tmp-false-parent t))
4232 ((eq gnus-summary-make-false-root 'empty)
4233 ;; We print adopted articles with empty subject fields.
4234 (setq gnus-tmp-gathered
4236 (lambda (h) (mail-header-number (car h)))
4239 (setq gnus-tmp-level -1))
4240 ((eq gnus-summary-make-false-root 'dummy)
4241 ;; We remember that we probably want to output a dummy
4243 (setq gnus-tmp-dummy-line gnus-tmp-header)
4244 (setq gnus-tmp-prev-subject gnus-tmp-header))
4246 ;; We do not make a root for the gathered
4247 ;; sub-threads at all.
4248 (setq gnus-tmp-level -1)))
4250 (setq number (mail-header-number gnus-tmp-header)
4251 subject (mail-header-subject gnus-tmp-header))
4254 ;; If the thread has changed subject, we might want to make
4255 ;; this subthread into a root.
4256 ((and (null gnus-thread-ignore-subject)
4257 (not (zerop gnus-tmp-level))
4258 gnus-tmp-prev-subject
4260 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4261 (setq new-roots (nconc new-roots (list (car thread)))
4263 gnus-tmp-header nil))
4264 ;; If the article lies outside the current limit,
4265 ;; then we do not display it.
4266 ((not (memq number gnus-newsgroup-limit))
4267 (setq gnus-tmp-gathered
4269 (lambda (h) (mail-header-number (car h)))
4272 (setq gnus-tmp-new-adopts (if (cdar thread)
4273 (append gnus-tmp-new-adopts
4275 gnus-tmp-new-adopts)
4277 gnus-tmp-header nil)
4278 (when (zerop gnus-tmp-level)
4279 (setq gnus-tmp-root-expunged t)))
4280 ;; Perhaps this article is to be marked as read?
4281 ((and gnus-summary-mark-below
4282 (< (or (cdr (assq number gnus-newsgroup-scored))
4284 gnus-summary-mark-below)
4285 ;; Don't touch sparse articles.
4286 (not (gnus-summary-article-sparse-p number))
4287 (not (gnus-summary-article-ancient-p number)))
4288 (setq gnus-newsgroup-unreads
4289 (delq number gnus-newsgroup-unreads))
4290 (if gnus-newsgroup-auto-expire
4291 (push number gnus-newsgroup-expirable)
4292 (push (cons number gnus-low-score-mark)
4293 gnus-newsgroup-reads))))
4295 (when gnus-tmp-header
4296 ;; We may have an old dummy line to output before this
4298 (when (and gnus-tmp-dummy-line
4301 (mail-header-subject gnus-tmp-header)))
4302 (gnus-summary-insert-dummy-line
4303 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4304 (setq gnus-tmp-dummy-line nil))
4306 ;; Compute the mark.
4307 (setq gnus-tmp-unread (gnus-article-mark number))
4309 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4310 gnus-tmp-header gnus-tmp-level)
4311 gnus-newsgroup-data)
4313 ;; Actually insert the line.
4315 gnus-tmp-subject-or-nil
4317 ((and gnus-thread-ignore-subject
4318 gnus-tmp-prev-subject
4319 (not (inline (gnus-subject-equal
4320 gnus-tmp-prev-subject subject))))
4322 ((zerop gnus-tmp-level)
4323 (if (and (eq gnus-summary-make-false-root 'empty)
4324 (memq number gnus-tmp-gathered)
4325 gnus-tmp-prev-subject
4326 (inline (gnus-subject-equal
4327 gnus-tmp-prev-subject subject)))
4328 gnus-summary-same-subject
4330 (t gnus-summary-same-subject)))
4331 (if (and (eq gnus-summary-make-false-root 'adopt)
4332 (= gnus-tmp-level 1)
4333 (memq number gnus-tmp-gathered))
4334 (setq gnus-tmp-opening-bracket ?\<
4335 gnus-tmp-closing-bracket ?\>)
4336 (setq gnus-tmp-opening-bracket ?\[
4337 gnus-tmp-closing-bracket ?\]))
4339 gnus-tmp-indentation
4340 (aref gnus-thread-indent-array gnus-tmp-level)
4341 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4342 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4343 gnus-summary-default-score 0)
4345 (if (or (null gnus-summary-default-score)
4346 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4347 gnus-summary-zcore-fuzz))
4349 (if (< gnus-tmp-score gnus-summary-default-score)
4350 gnus-score-below-mark gnus-score-over-mark))
4352 (cond ((memq number gnus-newsgroup-processable)
4354 ((memq number gnus-newsgroup-cached)
4356 ((memq number gnus-newsgroup-replied)
4358 ((memq number gnus-newsgroup-forwarded)
4359 gnus-forwarded-mark)
4360 ((memq number gnus-newsgroup-saved)
4362 ((memq number gnus-newsgroup-recent)
4364 ((memq number gnus-newsgroup-unseen)
4367 gnus-tmp-from (mail-header-from gnus-tmp-header)
4370 ((string-match "<[^>]+> *$" gnus-tmp-from)
4371 (setq beg-match (match-beginning 0))
4372 (or (and (string-match "^\".+\"" gnus-tmp-from)
4373 (substring gnus-tmp-from 1 (1- (match-end 0))))
4374 (substring gnus-tmp-from 0 beg-match)))
4375 ((string-match "(.+)" gnus-tmp-from)
4376 (substring gnus-tmp-from
4377 (1+ (match-beginning 0)) (1- (match-end 0))))
4379 gnus-tmp-thread-tree-header-string
4381 ((not gnus-show-threads) "")
4382 ((zerop gnus-tmp-level)
4384 (or gnus-sum-thread-tree-root subject)
4385 (or gnus-sum-thread-tree-single-indent subject)))
4387 (concat (apply 'concat
4388 (mapcar (lambda (item)
4390 gnus-sum-thread-tree-vertical
4391 gnus-sum-thread-tree-indent))
4392 (cdr (reverse tree-stack))))
4394 gnus-sum-thread-tree-leaf-with-other
4395 gnus-sum-thread-tree-single-leaf)))))
4396 (when (string= gnus-tmp-name "")
4397 (setq gnus-tmp-name gnus-tmp-from))
4398 (unless (numberp gnus-tmp-lines)
4399 (setq gnus-tmp-lines -1))
4400 (if (= gnus-tmp-lines -1)
4401 (setq gnus-tmp-lines "?")
4402 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4403 (gnus-put-text-property
4405 (progn (eval gnus-summary-line-format-spec) (point))
4406 'gnus-number number)
4409 (gnus-run-hooks 'gnus-summary-update-hook)
4412 (setq gnus-tmp-prev-subject subject)))
4414 (when (nth 1 thread)
4415 (push (list (max 0 gnus-tmp-level)
4416 (copy-list tree-stack)
4419 (push (if (nth 1 thread) 1 0) tree-stack)
4420 (incf gnus-tmp-level)
4421 (setq threads (if thread-end nil (cdar thread)))
4423 (setq gnus-tmp-level 0)))))
4424 (gnus-message 7 "Generating summary...done"))
4426 (defun gnus-summary-prepare-unthreaded (headers)
4427 "Generate an unthreaded summary buffer based on HEADERS."
4428 (let (header number mark)
4433 ;; We may have to root out some bad articles...
4434 (when (memq (setq number (mail-header-number
4435 (setq header (pop headers))))
4436 gnus-newsgroup-limit)
4437 ;; Mark article as read when it has a low score.
4438 (when (and gnus-summary-mark-below
4439 (< (or (cdr (assq number gnus-newsgroup-scored))
4440 gnus-summary-default-score 0)
4441 gnus-summary-mark-below)
4442 (not (gnus-summary-article-ancient-p number)))
4443 (setq gnus-newsgroup-unreads
4444 (delq number gnus-newsgroup-unreads))
4445 (if gnus-newsgroup-auto-expire
4446 (push number gnus-newsgroup-expirable)
4447 (push (cons number gnus-low-score-mark)
4448 gnus-newsgroup-reads)))
4450 (setq mark (gnus-article-mark number))
4451 (push (gnus-data-make number mark (1+ (point)) header 0)
4452 gnus-newsgroup-data)
4453 (gnus-summary-insert-line
4455 mark (memq number gnus-newsgroup-replied)
4456 (memq number gnus-newsgroup-expirable)
4457 (mail-header-subject header) nil
4458 (cdr (assq number gnus-newsgroup-scored))
4459 (memq number gnus-newsgroup-processable))))))
4461 (defun gnus-summary-remove-list-identifiers ()
4462 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4463 (let ((regexp (if (consp gnus-list-identifiers)
4464 (mapconcat 'identity gnus-list-identifiers " *\\|")
4465 gnus-list-identifiers))
4468 (dolist (header gnus-newsgroup-headers)
4469 (setq subject (mail-header-subject header)
4471 (while (string-match
4472 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4475 (concat (substring subject 0 (match-beginning 2))
4476 (substring subject (match-end 0)))
4480 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4482 (concat (substring subject 0 (match-beginning 1))
4483 (substring subject (match-end 1)))))
4485 (mail-header-set-subject header subject))))))
4487 (defun gnus-fetch-headers (articles)
4488 "Fetch headers of ARTICLES."
4489 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4490 (gnus-message 5 "Fetching headers for %s..." name)
4493 (setq gnus-headers-retrieved-by
4494 (gnus-retrieve-headers
4495 articles gnus-newsgroup-name
4496 ;; We might want to fetch old headers, but
4497 ;; not if there is only 1 article.
4499 (not (eq gnus-fetch-old-headers 'some))
4500 (not (numberp gnus-fetch-old-headers)))
4501 (> (length articles) 1))
4502 gnus-fetch-old-headers))))
4503 (gnus-get-newsgroup-headers-xover
4504 articles nil nil gnus-newsgroup-name t)
4505 (gnus-get-newsgroup-headers))
4506 (gnus-message 5 "Fetching headers for %s...done" name))))
4508 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4509 "Select newsgroup GROUP.
4510 If READ-ALL is non-nil, all articles in the group are selected.
4511 If SELECT-ARTICLES, only select those articles from GROUP."
4512 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4513 ;;!!! Dirty hack; should be removed.
4514 (gnus-summary-ignore-duplicates
4515 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4517 gnus-summary-ignore-duplicates))
4518 (info (nth 2 entry))
4519 articles fetched-articles cached)
4521 (unless (gnus-check-server
4522 (set (make-local-variable 'gnus-current-select-method)
4523 (gnus-find-method-for-group group)))
4524 (error "Couldn't open server"))
4526 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4527 (gnus-activate-group group) ; Or we can activate it...
4528 (progn ; Or we bug out.
4529 (when (equal major-mode 'gnus-summary-mode)
4530 (kill-buffer (current-buffer)))
4531 (error "Couldn't activate group %s: %s"
4532 group (gnus-status-message group))))
4534 (unless (gnus-request-group group t)
4535 (when (equal major-mode 'gnus-summary-mode)
4536 (kill-buffer (current-buffer)))
4537 (error "Couldn't request group %s: %s"
4538 group (gnus-status-message group)))
4540 (setq gnus-newsgroup-name group
4541 gnus-newsgroup-unselected nil
4542 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4544 (let ((display (gnus-group-find-parameter group 'display)))
4545 (setq gnus-newsgroup-display
4547 ((not (zerop (or (car-safe read-all) 0)))
4548 ;; The user entered the group with C-u SPC/RET, let's show
4554 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4556 ;; The following is probably the "correct" solution, but
4557 ;; it makes Gnus fetch all headers and then limit the
4558 ;; articles (which is slow), so instead we hack the
4559 ;; select-articles parameter instead. -- Simon Josefsson
4562 ;; (gnus-byte-compile
4563 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4565 (setq select-articles
4566 (gnus-uncompress-range
4567 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4571 (cdr (gnus-active group)))))
4576 (gnus-summary-setup-default-charset)
4578 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4579 (when (gnus-virtual-group-p group)
4580 (setq cached gnus-newsgroup-cached))
4582 (setq gnus-newsgroup-unreads
4583 (gnus-set-difference
4584 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4585 gnus-newsgroup-dormant))
4587 (setq gnus-newsgroup-processable nil)
4589 (gnus-update-read-articles group gnus-newsgroup-unreads)
4591 ;; Adjust and set lists of article marks.
4593 (gnus-adjust-marked-articles info))
4595 (if (setq articles select-articles)
4596 (setq gnus-newsgroup-unselected
4597 (gnus-sorted-intersection
4598 gnus-newsgroup-unreads
4599 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4600 (setq articles (gnus-articles-to-read group read-all)))
4604 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4606 ((eq articles 0) nil)
4608 ;; Init the dependencies hash table.
4609 (setq gnus-newsgroup-dependencies
4610 (gnus-make-hashtable (length articles)))
4611 (gnus-set-global-variables)
4612 ;; Retrieve the headers and read them in.
4613 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4615 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4617 (setq gnus-newsgroup-cached cached))
4619 ;; Suppress duplicates?
4620 (when gnus-suppress-duplicates
4621 (gnus-dup-suppress-articles))
4623 ;; Set the initial limit.
4624 (setq gnus-newsgroup-limit (copy-sequence articles))
4625 ;; Remove canceled articles from the list of unread articles.
4626 (setq fetched-articles
4627 (mapcar (lambda (headers) (mail-header-number headers))
4628 gnus-newsgroup-headers))
4629 (setq gnus-newsgroup-articles fetched-articles)
4630 (setq gnus-newsgroup-unreads
4631 (gnus-set-sorted-intersection
4632 gnus-newsgroup-unreads fetched-articles))
4634 (let ((marks (assq 'seen (gnus-info-marks info))))
4635 ;; The `seen' marks are treated specially.
4636 (when (setq gnus-newsgroup-seen (cdr marks))
4637 (dolist (article gnus-newsgroup-articles)
4638 (unless (gnus-member-of-range
4639 article gnus-newsgroup-seen)
4640 (push article gnus-newsgroup-unseen)))))
4642 ;; Removed marked articles that do not exist.
4643 (gnus-update-missing-marks
4644 (gnus-sorted-complement fetched-articles articles))
4645 ;; We might want to build some more threads first.
4646 (when (and gnus-fetch-old-headers
4647 (eq gnus-headers-retrieved-by 'nov))
4648 (if (eq gnus-fetch-old-headers 'invisible)
4649 (gnus-build-all-threads)
4650 (gnus-build-old-threads)))
4651 ;; Let the Gnus agent mark articles as read.
4653 (gnus-agent-get-undownloaded-list))
4654 ;; Remove list identifiers from subject
4655 (when gnus-list-identifiers
4656 (gnus-summary-remove-list-identifiers))
4657 ;; Check whether auto-expire is to be done in this group.
4658 (setq gnus-newsgroup-auto-expire
4659 (gnus-group-auto-expirable-p group))
4660 ;; Set up the article buffer now, if necessary.
4661 (unless gnus-single-article-buffer
4662 (gnus-article-setup-buffer))
4663 ;; First and last article in this newsgroup.
4664 (when gnus-newsgroup-headers
4665 (setq gnus-newsgroup-begin
4666 (mail-header-number (car gnus-newsgroup-headers))
4669 (gnus-last-element gnus-newsgroup-headers))))
4670 ;; GROUP is successfully selected.
4671 (or gnus-newsgroup-headers t)))))
4673 (defun gnus-summary-display-make-predicate (display)
4674 (require 'gnus-agent)
4675 (when (= (length display) 1)
4676 (setq display (car display)))
4677 (unless gnus-summary-display-cache
4678 (dolist (elem (append (list (cons 'read 'read)
4679 (cons 'unseen 'unseen))
4680 gnus-article-mark-lists))
4681 (push (cons (cdr elem)
4683 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4684 gnus-summary-display-cache)))
4685 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4686 (gnus-get-predicate display)))
4688 ;; Uses the dynamically bound `number' variable.
4690 (defun gnus-article-marked-p (type &optional article)
4691 (let ((article (or article number)))
4694 (memq article gnus-newsgroup-marked))
4696 (memq article gnus-newsgroup-unsendable))
4697 ((eq type 'undownload)
4698 (memq article gnus-newsgroup-undownloaded))
4699 ((eq type 'download)
4700 (memq article gnus-newsgroup-downloadable))
4702 (memq article gnus-newsgroup-unreads))
4704 (memq article gnus-newsgroup-reads))
4706 (memq article gnus-newsgroup-dormant) )
4708 (memq article gnus-newsgroup-expirable))
4710 (memq article gnus-newsgroup-replied))
4712 (memq article gnus-newsgroup-killed))
4713 ((eq type 'bookmark)
4714 (assq article gnus-newsgroup-bookmarks))
4716 (assq article gnus-newsgroup-scored))
4718 (memq article gnus-newsgroup-saved))
4720 (memq article gnus-newsgroup-cached))
4722 (memq article gnus-newsgroup-forwarded))
4724 (not (memq article gnus-newsgroup-unseen)))
4726 (memq article gnus-newsgroup-recent))
4729 (defun gnus-articles-to-read (group &optional read-all)
4730 "Find out what articles the user wants to read."
4732 ;; Select all articles if `read-all' is non-nil, or if there
4733 ;; are no unread articles.
4735 (and (zerop (length gnus-newsgroup-marked))
4736 (zerop (length gnus-newsgroup-unreads)))
4737 (eq gnus-newsgroup-display 'gnus-not-ignore))
4738 ;; We want to select the headers for all the articles in
4739 ;; the group, so we select either all the active
4740 ;; articles in the group, or (if that's nil), the
4741 ;; articles in the cache.
4743 (gnus-uncompress-range (gnus-active group))
4744 (gnus-cache-articles-in-group group))
4745 ;; Select only the "normal" subset of articles.
4746 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4747 (copy-sequence gnus-newsgroup-unreads))
4749 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4750 (scored (length scored-list))
4751 (number (length articles))
4752 (marked (+ (length gnus-newsgroup-marked)
4753 (length gnus-newsgroup-dormant)))
4761 ((and (or (<= scored marked) (= scored number))
4762 (numberp gnus-large-newsgroup)
4763 (> number gnus-large-newsgroup))
4767 "How many articles from %s (default %d): "
4769 (gnus-group-decoded-name gnus-newsgroup-name)
4772 (if (string-match "^[ \t]*$" input) number input)))
4773 ((and (> scored marked) (< scored number)
4774 (> (- scored number) 20))
4777 (format "%s %s (%d scored, %d total): "
4778 "How many articles from"
4779 (gnus-group-decoded-name group)
4781 (if (string-match "^[ \t]*$" input)
4785 (message "Quit getting the articles to read")
4787 (setq select (if (stringp select) (string-to-number select) select))
4788 (if (or (null select) (zerop select))
4790 (if (and (not (zerop scored)) (<= (abs select) scored))
4792 (setq articles (sort scored-list '<))
4793 (setq number (length articles)))
4794 (setq articles (copy-sequence articles)))
4796 (when (< (abs select) number)
4798 ;; Select the N oldest articles.
4799 (setcdr (nthcdr (1- (abs select)) articles) nil)
4800 ;; Select the N most recent articles.
4801 (setq articles (nthcdr (- number select) articles))))
4802 (setq gnus-newsgroup-unselected
4803 (gnus-sorted-intersection
4804 gnus-newsgroup-unreads
4805 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4806 (when gnus-alter-articles-to-read-function
4807 (setq gnus-newsgroup-unreads
4809 (funcall gnus-alter-articles-to-read-function
4810 gnus-newsgroup-name gnus-newsgroup-unreads)
4814 (defun gnus-killed-articles (killed articles)
4817 (when (inline (gnus-member-of-range (car articles) killed))
4818 (push (car articles) out))
4819 (setq articles (cdr articles)))
4822 (defun gnus-uncompress-marks (marks)
4823 "Uncompress the mark ranges in MARKS."
4824 (let ((uncompressed '(score bookmark))
4827 (if (memq (caar marks) uncompressed)
4828 (push (car marks) out)
4829 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4830 (setq marks (cdr marks)))
4833 (defun gnus-article-mark-to-type (mark)
4834 "Return the type of MARK."
4835 (or (cadr (assq mark gnus-article-special-mark-lists))
4838 (defun gnus-article-unpropagatable-p (mark)
4839 "Return whether MARK should be propagated to backend."
4840 (memq mark gnus-article-unpropagated-mark-lists))
4842 (defun gnus-adjust-marked-articles (info)
4843 "Set all article lists and remove all marks that are no longer valid."
4844 (let* ((marked-lists (gnus-info-marks info))
4845 (active (gnus-active (gnus-info-group info)))
4848 (types gnus-article-mark-lists)
4849 marks var articles article mark mark-type)
4851 (dolist (marks marked-lists)
4852 (setq mark (car marks)
4853 mark-type (gnus-article-mark-to-type mark)
4854 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4856 ;; We set the variable according to the type of the marks list,
4857 ;; and then adjust the marks to a subset of the active articles.
4859 ;; Adjust "simple" lists.
4860 ((eq mark-type 'list)
4861 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4862 (when (memq mark '(tick dormant expire reply save))
4864 (when (or (< (setq article (pop articles)) min) (> article max))
4865 (set var (delq article (symbol-value var)))))))
4867 ((eq mark-type 'tuple)
4868 (set var (setq articles (cdr marks)))
4869 (when (not (listp (cdr (symbol-value var))))
4870 (set var (list (symbol-value var))))
4871 (when (not (listp (cdr articles)))
4872 (setq articles (list articles)))
4874 (when (or (not (consp (setq article (pop articles))))
4875 (< (car article) min)
4876 (> (car article) max))
4877 (set var (delq article (symbol-value var))))))
4878 ((eq mark-type 'range)
4880 ((eq mark 'seen))))))))
4882 (defun gnus-update-missing-marks (missing)
4883 "Go through the list of MISSING articles and remove them from the mark lists."
4886 ;; Go through all types.
4887 (dolist (elem gnus-article-mark-lists)
4888 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4889 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4890 (when (symbol-value var)
4891 ;; This list has articles. So we delete all missing
4892 ;; articles from it.
4895 (set var (delq (pop m) (symbol-value var))))))))))
4897 (defun gnus-update-marks ()
4898 "Enter the various lists of marked articles into the newsgroup info list."
4899 (let ((types gnus-article-mark-lists)
4900 (info (gnus-get-info gnus-newsgroup-name))
4901 type list newmarked symbol delta-marks)
4903 ;; Add all marks lists to the list of marks lists.
4904 (while (setq type (pop types))
4905 (setq list (symbol-value
4907 (intern (format "gnus-newsgroup-%s" (car type))))))
4910 ;; Get rid of the entries of the articles that have the
4912 (when (and (eq (cdr type) 'score)
4916 (prev (cons nil list))
4919 (if (or (not (consp (car arts)))
4920 (= (cdar arts) gnus-summary-default-score))
4921 (setcdr prev (cdr arts))
4923 (setq arts (cdr arts)))
4924 (setq list (cdr all)))))
4926 (when (eq (cdr type) 'seen)
4929 (gnus-add-to-range list gnus-newsgroup-unseen)
4930 (gnus-compress-sequence gnus-newsgroup-articles))))
4932 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
4933 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4935 (when (and (gnus-check-backend-function
4936 'request-set-mark gnus-newsgroup-name)
4937 (not (gnus-article-unpropagatable-p (cdr type))))
4938 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4939 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4940 (add (gnus-remove-from-range
4941 (gnus-copy-sequence list) old)))
4943 (push (list add 'add (list (cdr type))) delta-marks))
4945 (push (list del 'del (list (cdr type))) delta-marks))))
4948 (push (cons (cdr type) list) newmarked)))
4951 (unless (gnus-check-group gnus-newsgroup-name)
4952 (error "Can't open server for %s" gnus-newsgroup-name))
4953 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4955 ;; Enter these new marks into the info of the group.
4957 (setcar (nthcdr 3 info) newmarked)
4958 ;; Add the marks lists to the end of the info.
4960 (setcdr (nthcdr 2 info) (list newmarked))))
4962 ;; Cut off the end of the info if there's nothing else there.
4966 (when (nthcdr (decf i) info)
4967 (setcdr (nthcdr i info) nil)))))))
4969 (defun gnus-set-mode-line (where)
4970 "Set the mode line of the article or summary buffers.
4971 If WHERE is `summary', the summary mode line format will be used."
4972 ;; Is this mode line one we keep updated?
4973 (when (and (memq where gnus-updated-mode-lines)
4975 (intern (format "gnus-%s-mode-line-format-spec" where))))
4978 ;; We evaluate this in the summary buffer since these
4979 ;; variables are buffer-local to that buffer.
4980 (set-buffer gnus-summary-buffer)
4981 ;; We bind all these variables that are used in the `eval' form
4983 (let* ((mformat (symbol-value
4985 (format "gnus-%s-mode-line-format-spec" where))))
4986 (gnus-tmp-group-name (gnus-group-decoded-name
4987 gnus-newsgroup-name))
4988 (gnus-tmp-article-number (or gnus-current-article 0))
4989 (gnus-tmp-unread gnus-newsgroup-unreads)
4990 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4991 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4992 (gnus-tmp-unread-and-unselected
4993 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4994 (zerop gnus-tmp-unselected))
4996 ((zerop gnus-tmp-unselected)
4997 (format "{%d more}" gnus-tmp-unread-and-unticked))
4998 (t (format "{%d(+%d) more}"
4999 gnus-tmp-unread-and-unticked
5000 gnus-tmp-unselected))))
5002 (if (and gnus-current-headers
5003 (vectorp gnus-current-headers))
5004 (gnus-mode-string-quote
5005 (mail-header-subject gnus-current-headers))
5007 bufname-length max-len
5008 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5009 (setq mode-string (eval mformat))
5010 (setq bufname-length (if (string-match "%b" mode-string)
5013 (if (eq where 'summary)
5015 (get-buffer gnus-article-buffer))))
5018 (setq max-len (max 4 (if gnus-mode-non-string-length
5020 gnus-mode-non-string-length
5022 (length mode-string))))
5023 ;; We might have to chop a bit of the string off...
5024 (when (> (length mode-string) max-len)
5026 (concat (truncate-string-to-width mode-string (- max-len 3))
5028 ;; Pad the mode string a bit.
5029 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5030 ;; Update the mode line.
5031 (setq mode-line-buffer-identification
5032 (gnus-mode-line-buffer-identification (list mode-string)))
5033 (set-buffer-modified-p t))))
5035 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5036 "Go through the HEADERS list and add all Xrefs to a hash table.
5037 The resulting hash table is returned, or nil if no Xrefs were found."
5038 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5039 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5040 (xref-hashtb (gnus-make-hashtable))
5041 start group entry number xrefs header)
5043 (setq header (pop headers))
5044 (when (and (setq xrefs (mail-header-xref header))
5045 (not (memq (setq number (mail-header-number header))
5048 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5049 (setq start (match-end 0))
5050 (setq group (if prefix
5051 (concat prefix (substring xrefs (match-beginning 1)
5053 (substring xrefs (match-beginning 1) (match-end 1))))
5055 (string-to-int (substring xrefs (match-beginning 2)
5057 (if (setq entry (gnus-gethash group xref-hashtb))
5058 (setcdr entry (cons number (cdr entry)))
5059 (gnus-sethash group (cons number nil) xref-hashtb)))))
5060 (and start xref-hashtb)))
5062 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5063 "Look through all the headers and mark the Xrefs as read."
5064 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5065 name entry info xref-hashtb idlist method nth4)
5067 (set-buffer gnus-group-buffer)
5068 (when (setq xref-hashtb
5069 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5072 (unless (string= from-newsgroup (setq name (symbol-name group)))
5073 (setq idlist (symbol-value group))
5074 ;; Dead groups are not updated.
5076 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5078 (when (stringp (setq nth4 (gnus-info-method info)))
5079 (setq nth4 (gnus-server-to-method nth4))))
5080 ;; Only do the xrefs if the group has the same
5081 ;; select method as the group we have just read.
5082 (or (gnus-methods-equal-p
5083 nth4 (gnus-find-method-for-group from-newsgroup))
5085 (equal nth4 (setq method (gnus-find-method-for-group
5087 (and (equal (car nth4) (car method))
5088 (equal (nth 1 nth4) (nth 1 method))))
5089 gnus-use-cross-reference
5090 (or (not (eq gnus-use-cross-reference t))
5092 ;; Only do cross-references on subscribed
5093 ;; groups, if that is what is wanted.
5094 (<= (gnus-info-level info) gnus-level-subscribed))
5095 (gnus-group-make-articles-read name idlist))))
5098 (defun gnus-compute-read-articles (group articles)
5099 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5100 (info (nth 2 entry))
5101 (active (gnus-active group))
5104 ;; First peel off all invalid article numbers.
5106 (let ((ids articles)
5108 (while (setq id (pop ids))
5109 (when (and first (> id (cdr active)))
5110 ;; We'll end up in this situation in one particular
5111 ;; obscure situation. If you re-scan a group and get
5112 ;; a new article that is cross-posted to a different
5113 ;; group that has not been re-scanned, you might get
5114 ;; crossposted article that has a higher number than
5115 ;; Gnus believes possible. So we re-activate this
5116 ;; group as well. This might mean doing the
5117 ;; crossposting thingy will *increase* the number
5118 ;; of articles in some groups. Tsk, tsk.
5119 (setq active (or (gnus-activate-group group) active)))
5120 (when (or (> id (cdr active))
5121 (< id (car active)))
5122 (setq articles (delq id articles))))))
5123 ;; If the read list is nil, we init it.
5125 (null (gnus-info-read info))
5127 (setq ninfo (cons 1 (1- (car active))))
5128 (setq ninfo (gnus-info-read info)))
5129 ;; Then we add the read articles to the range.
5131 ninfo (setq articles (sort articles '<))))))
5133 (defun gnus-group-make-articles-read (group articles)
5134 "Update the info of GROUP to say that ARTICLES are read."
5136 (entry (gnus-gethash group gnus-newsrc-hashtb))
5137 (info (nth 2 entry))
5138 (active (gnus-active group))
5141 (setq range (gnus-compute-read-articles group articles))
5143 (set-buffer gnus-group-buffer)
5146 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5147 (gnus-info-set-read ',info ',(gnus-info-read info))
5148 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5149 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5150 (gnus-group-update-group ,group t))))
5151 ;; Add the read articles to the range.
5152 (gnus-info-set-read info range)
5153 (gnus-request-set-mark group (list (list range 'add '(read))))
5154 ;; Then we have to re-compute how many unread
5155 ;; articles there are in this group.
5159 (setq num (- (1+ (cdr active)) (car active))))
5160 ((not (listp (cdr range)))
5161 (setq num (- (cdr active) (- (1+ (cdr range))
5165 (if (numberp (car range))
5167 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5168 (setq range (cdr range)))
5169 (setq num (- (cdr active) num))))
5170 ;; Update the number of unread articles.
5172 ;; Update the group buffer.
5173 (gnus-group-update-group group t)))))
5175 (defvar gnus-newsgroup-none-id 0)
5177 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5178 (let ((cur nntp-server-buffer)
5181 (save-excursion (set-buffer gnus-summary-buffer)
5182 gnus-newsgroup-dependencies)))
5184 (mail-parse-charset gnus-newsgroup-charset)
5185 (mail-parse-ignored-charsets
5186 (save-excursion (condition-case nil
5187 (set-buffer gnus-summary-buffer)
5189 gnus-newsgroup-ignored-charsets)))
5191 (set-buffer nntp-server-buffer)
5192 ;; Translate all TAB characters into SPACE characters.
5193 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5194 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5195 (gnus-run-hooks 'gnus-parse-headers-hook)
5196 (let ((case-fold-search t)
5197 in-reply-to header p lines chars)
5198 (goto-char (point-min))
5199 ;; Search to the beginning of the next header. Error messages
5200 ;; do not begin with 2 or 3.
5201 (while (re-search-forward "^[23][0-9]+ " nil t)
5204 ;; This implementation of this function, with nine
5205 ;; search-forwards instead of the one re-search-forward and
5206 ;; a case (which basically was the old function) is actually
5207 ;; about twice as fast, even though it looks messier. You
5208 ;; can't have everything, I guess. Speed and elegance
5209 ;; doesn't always go hand in hand.
5218 (narrow-to-region (point)
5219 (or (and (search-forward "\n.\n" nil t)
5225 (if (search-forward "\nsubject:" nil t)
5226 (funcall gnus-decode-encoded-word-function
5227 (nnheader-header-value))
5232 (if (search-forward "\nfrom:" nil t)
5233 (funcall gnus-decode-encoded-word-function
5234 (nnheader-header-value))
5239 (if (search-forward "\ndate:" nil t)
5240 (nnheader-header-value) ""))
5244 (setq id (if (re-search-forward
5245 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5246 ;; We do it this way to make sure the Message-ID
5247 ;; is (somewhat) syntactically valid.
5248 (buffer-substring (match-beginning 1)
5250 ;; If there was no message-id, we just fake one
5251 ;; to make subsequent routines simpler.
5252 (nnheader-generate-fake-message-id))))
5256 (if (search-forward "\nreferences:" nil t)
5260 (nnheader-header-value)
5265 (search-backward ">" end t)
5268 (search-backward "<" end t)
5270 ;; Get the references from the in-reply-to header if there
5271 ;; were no references and the in-reply-to header looks
5273 (if (and (search-forward "\nin-reply-to:" nil t)
5274 (setq in-reply-to (nnheader-header-value))
5275 (string-match "<[^>]+>" in-reply-to))
5277 (setq ref (substring in-reply-to (match-beginning 0)
5279 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5280 (setq ref2 (substring in-reply-to (match-beginning 0)
5282 (when (> (length ref2) (length ref))
5289 (if (search-forward "\nchars: " nil t)
5290 (if (numberp (setq chars (ignore-errors (read cur))))
5296 (if (search-forward "\nlines: " nil t)
5297 (if (numberp (setq lines (ignore-errors (read cur))))
5303 (and (search-forward "\nxref:" nil t)
5304 (nnheader-header-value)))
5306 (when gnus-extra-headers
5307 (let ((extra gnus-extra-headers)
5311 (when (search-forward
5312 (concat "\n" (symbol-name (car extra)) ":") nil t)
5313 (push (cons (car extra) (nnheader-header-value))
5317 (when (equal id ref)
5320 (when gnus-alter-header-function
5321 (funcall gnus-alter-header-function header)
5322 (setq id (mail-header-id header)
5323 ref (gnus-parent-id (mail-header-references header))))
5326 (gnus-dependencies-add-header
5327 header dependencies force-new))
5328 (push header headers))
5329 (goto-char (point-max))
5331 (nreverse headers)))))
5333 ;; Goes through the xover lines and returns a list of vectors
5334 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5335 force-new dependencies
5336 group also-fetch-heads)
5337 "Parse the news overview data in the server buffer.
5338 Return a list of headers that match SEQUENCE (see
5339 `nntp-retrieve-headers')."
5340 ;; Get the Xref when the users reads the articles since most/some
5341 ;; NNTP servers do not include Xrefs when using XOVER.
5342 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5343 (let ((mail-parse-charset gnus-newsgroup-charset)
5344 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5345 (cur nntp-server-buffer)
5346 (dependencies (or dependencies gnus-newsgroup-dependencies))
5348 ((eq gnus-read-all-available-headers t)
5350 ((stringp gnus-read-all-available-headers)
5351 (string-match gnus-read-all-available-headers group))
5354 number headers header)
5356 (set-buffer nntp-server-buffer)
5357 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5358 ;; Allow the user to mangle the headers before parsing them.
5359 (gnus-run-hooks 'gnus-parse-headers-hook)
5360 (goto-char (point-min))
5363 (while (and (or sequence allp)
5365 (setq number (read cur))
5367 (while (and sequence
5368 (< (car sequence) number))
5369 (setq sequence (cdr sequence))))
5372 (eq number (car sequence))))
5374 (setq sequence (cdr sequence))
5375 (setq header (inline
5376 (gnus-nov-parse-line
5377 number dependencies force-new)))))
5378 (push header headers))
5381 (gnus-error 4 "Strange nov line (%d)"
5382 (count-lines (point-min) (point)))))
5384 ;; A common bug in inn is that if you have posted an article and
5385 ;; then retrieves the active file, it will answer correctly --
5386 ;; the new article is included. However, a NOV entry for the
5387 ;; article may not have been generated yet, so this may fail.
5388 ;; We work around this problem by retrieving the last few
5389 ;; headers using HEAD.
5390 (if (or (not also-fetch-heads)
5392 ;; We (probably) got all the headers.
5394 (let ((gnus-nov-is-evil t))
5397 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5398 (gnus-get-newsgroup-headers))))))))
5400 (defun gnus-article-get-xrefs ()
5401 "Fill in the Xref value in `gnus-current-headers', if necessary.
5402 This is meant to be called in `gnus-article-internal-prepare-hook'."
5403 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5404 gnus-current-headers)))
5405 (or (not gnus-use-cross-reference)
5407 (and (mail-header-xref headers)
5408 (not (string= (mail-header-xref headers) "")))
5409 (let ((case-fold-search t)
5412 (nnheader-narrow-to-headers)
5413 (goto-char (point-min))
5414 (when (or (and (not (eobp))
5415 (eq (downcase (char-after)) ?x)
5416 (looking-at "Xref:"))
5417 (search-forward "\nXref:" nil t))
5418 (goto-char (1+ (match-end 0)))
5419 (setq xref (buffer-substring (point)
5420 (progn (end-of-line) (point))))
5421 (mail-header-set-xref headers xref)))))))
5423 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5424 "Find article ID and insert the summary line for that article.
5425 OLD-HEADER can either be a header or a line number to insert
5426 the subject line on."
5427 (let* ((line (and (numberp old-header) old-header))
5428 (old-header (and (vectorp old-header) old-header))
5429 (header (cond ((and old-header use-old-header)
5432 (gnus-number-to-header id))
5433 (gnus-number-to-header id))
5435 (gnus-read-header id))))
5436 (number (and (numberp id) id))
5439 ;; Rebuild the thread that this article is part of and go to the
5440 ;; article we have fetched.
5441 (when (and (not gnus-show-threads)
5444 (setq d (gnus-data-find (mail-header-number old-header))))
5445 (goto-char (gnus-data-pos d))
5448 (- (gnus-point-at-bol)
5450 (1+ (gnus-point-at-eol))
5451 (gnus-delete-line))))))
5453 (mail-header-set-number header (mail-header-number old-header)))
5454 (setq gnus-newsgroup-sparse
5455 (delq (setq number (mail-header-number header))
5456 gnus-newsgroup-sparse))
5457 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5458 (push number gnus-newsgroup-limit)
5459 (gnus-rebuild-thread (mail-header-id header) line)
5460 (gnus-summary-goto-subject number nil t))
5461 (when (and (numberp number)
5463 ;; We have to update the boundaries even if we can't fetch the
5464 ;; article if ID is a number -- so that the next `P' or `N'
5465 ;; command will fetch the previous (or next) article even
5466 ;; if the one we tried to fetch this time has been canceled.
5467 (when (> number gnus-newsgroup-end)
5468 (setq gnus-newsgroup-end number))
5469 (when (< number gnus-newsgroup-begin)
5470 (setq gnus-newsgroup-begin number))
5471 (setq gnus-newsgroup-unselected
5472 (delq number gnus-newsgroup-unselected)))
5473 ;; Report back a success?
5474 (and header (mail-header-number header))))
5476 ;;; Process/prefix in the summary buffer
5478 (defun gnus-summary-work-articles (n)
5479 "Return a list of articles to be worked upon.
5480 The prefix argument, the list of process marked articles, and the
5481 current article will be taken into consideration."
5483 (set-buffer gnus-summary-buffer)
5486 ;; A numerical prefix has been given.
5487 (setq n (prefix-numeric-value n))
5488 (let ((backward (< n 0))
5489 (n (abs (prefix-numeric-value n)))
5494 (push (setq article (gnus-summary-article-number))
5497 (gnus-summary-find-prev nil article)
5498 (gnus-summary-find-next nil article)))
5500 (nreverse articles)))
5501 ((and (gnus-region-active-p) (mark))
5502 (message "region active")
5503 ;; Work on the region between point and mark.
5504 (let ((max (max (point) (mark)))
5507 (goto-char (min (min (point) (mark))))
5510 (push (setq article (gnus-summary-article-number)) articles)
5511 (gnus-summary-find-next nil article)
5513 (nreverse articles))))
5514 (gnus-newsgroup-processable
5515 ;; There are process-marked articles present.
5516 ;; Save current state.
5517 (gnus-summary-save-process-mark)
5519 (reverse gnus-newsgroup-processable))
5521 ;; Just return the current article.
5522 (list (gnus-summary-article-number))))))
5524 (defmacro gnus-summary-iterate (arg &rest forms)
5525 "Iterate over the process/prefixed articles and do FORMS.
5526 ARG is the interactive prefix given to the command. FORMS will be
5527 executed with point over the summary line of the articles."
5528 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5529 `(let ((,articles (gnus-summary-work-articles ,arg)))
5531 (gnus-summary-goto-subject (car ,articles))
5535 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5536 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5538 (defun gnus-summary-save-process-mark ()
5539 "Push the current set of process marked articles on the stack."
5541 (push (copy-sequence gnus-newsgroup-processable)
5542 gnus-newsgroup-process-stack))
5544 (defun gnus-summary-kill-process-mark ()
5545 "Push the current set of process marked articles on the stack and unmark."
5547 (gnus-summary-save-process-mark)
5548 (gnus-summary-unmark-all-processable))
5550 (defun gnus-summary-yank-process-mark ()
5551 "Pop the last process mark state off the stack and restore it."
5553 (unless gnus-newsgroup-process-stack
5554 (error "Empty mark stack"))
5555 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5557 (defun gnus-summary-process-mark-set (set)
5558 "Make SET into the current process marked articles."
5559 (gnus-summary-unmark-all-processable)
5561 (gnus-summary-set-process-mark (pop set))))
5563 ;;; Searching and stuff
5565 (defun gnus-summary-search-group (&optional backward use-level)
5566 "Search for next unread newsgroup.
5567 If optional argument BACKWARD is non-nil, search backward instead."
5569 (set-buffer gnus-group-buffer)
5570 (when (gnus-group-search-forward
5571 backward nil (if use-level (gnus-group-group-level) nil))
5572 (gnus-group-group-name))))
5574 (defun gnus-summary-best-group (&optional exclude-group)
5575 "Find the name of the best unread group.
5576 If EXCLUDE-GROUP, do not go to this group."
5578 (set-buffer gnus-group-buffer)
5580 (gnus-group-best-unread-group exclude-group))))
5582 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5583 (if backward (gnus-summary-find-prev)
5584 (let* ((dummy (gnus-summary-article-intangible-p))
5585 (article (or article (gnus-summary-article-number)))
5586 (arts (gnus-data-find-list article))
5588 (when (and (not dummy)
5589 (or (not gnus-summary-check-current)
5591 (not (gnus-data-unread-p (car arts)))))
5592 (setq arts (cdr arts)))
5597 (when (or (and undownloaded
5598 (eq gnus-undownloaded-mark
5599 (gnus-data-mark (car arts))))
5600 (gnus-data-unread-p (car arts)))
5601 (setq result (car arts)
5603 (setq arts (cdr arts)))
5606 (goto-char (gnus-data-pos result))
5607 (gnus-data-number result)))))
5609 (defun gnus-summary-find-prev (&optional unread article)
5610 (let* ((eobp (eobp))
5611 (article (or article (gnus-summary-article-number)))
5612 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5614 (when (and (not eobp)
5615 (or (not gnus-summary-check-current)
5617 (not (gnus-data-unread-p (car arts)))))
5618 (setq arts (cdr arts)))
5623 (when (gnus-data-unread-p (car arts))
5624 (setq result (car arts)
5626 (setq arts (cdr arts)))
5629 (goto-char (gnus-data-pos result))
5630 (gnus-data-number result))))
5632 (defun gnus-summary-find-subject (subject &optional unread backward article)
5633 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5634 (article (or article (gnus-summary-article-number)))
5635 (articles (gnus-data-list backward))
5636 (arts (gnus-data-find-list article articles))
5638 (when (or (not gnus-summary-check-current)
5640 (not (gnus-data-unread-p (car arts))))
5641 (setq arts (cdr arts)))
5643 (and (or (not unread)
5644 (gnus-data-unread-p (car arts)))
5645 (vectorp (gnus-data-header (car arts)))
5647 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5648 (setq result (car arts)
5650 (setq arts (cdr arts)))
5652 (goto-char (gnus-data-pos result))
5653 (gnus-data-number result))))
5655 (defun gnus-summary-search-forward (&optional unread subject backward)
5656 "Search forward for an article.
5657 If UNREAD, look for unread articles. If SUBJECT, look for
5658 articles with that subject. If BACKWARD, search backward instead."
5659 (cond (subject (gnus-summary-find-subject subject unread backward))
5660 (backward (gnus-summary-find-prev unread))
5661 (t (gnus-summary-find-next unread))))
5663 (defun gnus-recenter (&optional n)
5664 "Center point in window and redisplay frame.
5665 Also do horizontal recentering."
5667 (when (and gnus-auto-center-summary
5668 (not (eq gnus-auto-center-summary 'vertical)))
5669 (gnus-horizontal-recenter))
5672 (defun gnus-summary-recenter ()
5673 "Center point in the summary window.
5674 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5675 displayed, no centering will be performed."
5676 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5677 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5679 (let* ((top (cond ((< (window-height) 4) 0)
5680 ((< (window-height) 7) 1)
5681 (t (if (numberp gnus-auto-center-summary)
5682 gnus-auto-center-summary
5684 (height (1- (window-height)))
5685 (bottom (save-excursion (goto-char (point-max))
5686 (forward-line (- height))
5688 (window (get-buffer-window (current-buffer))))
5689 ;; The user has to want it.
5690 (when gnus-auto-center-summary
5691 (when (get-buffer-window gnus-article-buffer)
5692 ;; Only do recentering when the article buffer is displayed,
5693 ;; Set the window start to either `bottom', which is the biggest
5694 ;; possible valid number, or the second line from the top,
5695 ;; whichever is the least.
5696 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5697 (if (> bottom top-pos)
5698 ;; Keep the second line from the top visible
5699 (set-window-start window top-pos t)
5700 ;; Try to keep the bottom line visible; if it's partially
5701 ;; obscured, either scroll one more line to make it fully
5702 ;; visible, or revert to using TOP-POS.
5704 (goto-char (point-max))
5706 (let ((last-line-start (point)))
5708 (set-window-start window (point) t)
5709 (when (not (pos-visible-in-window-p last-line-start window))
5711 (set-window-start window (min (point) top-pos) t)))))))
5712 ;; Do horizontal recentering while we're at it.
5713 (when (and (get-buffer-window (current-buffer) t)
5714 (not (eq gnus-auto-center-summary 'vertical)))
5715 (let ((selected (selected-window)))
5716 (select-window (get-buffer-window (current-buffer) t))
5717 (gnus-summary-position-point)
5718 (gnus-horizontal-recenter)
5719 (select-window selected))))))
5721 (defun gnus-summary-jump-to-group (newsgroup)
5722 "Move point to NEWSGROUP in group mode buffer."
5723 ;; Keep update point of group mode buffer if visible.
5724 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5725 (save-window-excursion
5726 ;; Take care of tree window mode.
5727 (when (get-buffer-window gnus-group-buffer)
5728 (pop-to-buffer gnus-group-buffer))
5729 (gnus-group-jump-to-group newsgroup))
5731 ;; Take care of tree window mode.
5732 (if (get-buffer-window gnus-group-buffer)
5733 (pop-to-buffer gnus-group-buffer)
5734 (set-buffer gnus-group-buffer))
5735 (gnus-group-jump-to-group newsgroup))))
5737 ;; This function returns a list of article numbers based on the
5738 ;; difference between the ranges of read articles in this group and
5739 ;; the range of active articles.
5740 (defun gnus-list-of-unread-articles (group)
5741 (let* ((read (gnus-info-read (gnus-get-info group)))
5742 (active (or (gnus-active group) (gnus-activate-group group)))
5745 ;; If none are read, then all are unread.
5747 (setq first (car active))
5748 ;; If the range of read articles is a single range, then the
5749 ;; first unread article is the article after the last read
5750 ;; article. Sounds logical, doesn't it?
5751 (if (and (not (listp (cdr read)))
5752 (or (< (car read) (car active))
5753 (progn (setq read (list read))
5755 (setq first (max (car active) (1+ (cdr read))))
5756 ;; `read' is a list of ranges.
5757 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5760 (setq first (car active)))
5763 (while (< first nlast)
5765 (setq first (1+ first))))
5766 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5767 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5768 (setq read (cdr read)))))
5769 ;; And add the last unread articles.
5770 (while (<= first last)
5772 (setq first (1+ first)))
5773 ;; Return the list of unread articles.
5774 (delq 0 (nreverse unread))))
5776 (defun gnus-list-of-read-articles (group)
5777 "Return a list of unread, unticked and non-dormant articles."
5778 (let* ((info (gnus-get-info group))
5779 (marked (gnus-info-marks info))
5780 (active (gnus-active group)))
5782 (gnus-set-difference
5783 (gnus-sorted-complement
5784 (gnus-uncompress-range active)
5785 (gnus-list-of-unread-articles group))
5787 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5788 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5790 ;; Various summary commands
5792 (defun gnus-summary-select-article-buffer ()
5793 "Reconfigure windows to show article buffer."
5795 (if (not (gnus-buffer-live-p gnus-article-buffer))
5796 (error "There is no article buffer for this summary buffer")
5797 (gnus-configure-windows 'article)
5798 (select-window (get-buffer-window gnus-article-buffer))))
5800 (defun gnus-summary-universal-argument (arg)
5801 "Perform any operation on all articles that are process/prefixed."
5803 (let ((articles (gnus-summary-work-articles arg))
5810 (substitute-command-keys
5811 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5813 (gnus-error 1 "Undefined key")
5816 (gnus-summary-goto-subject (setq article (pop articles)))
5817 (let (gnus-newsgroup-processable)
5818 (command-execute func))
5819 (gnus-summary-remove-process-mark article)))))
5820 (gnus-summary-position-point))
5822 (defun gnus-summary-toggle-truncation (&optional arg)
5823 "Toggle truncation of summary lines.
5824 With arg, turn line truncation on iff arg is positive."
5826 (setq truncate-lines
5827 (if (null arg) (not truncate-lines)
5828 (> (prefix-numeric-value arg) 0)))
5831 (defun gnus-summary-reselect-current-group (&optional all rescan)
5832 "Exit and then reselect the current newsgroup.
5833 The prefix argument ALL means to select all articles."
5835 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5836 (error "Ephemeral groups can't be reselected"))
5837 (let ((current-subject (gnus-summary-article-number))
5838 (group gnus-newsgroup-name))
5839 (setq gnus-newsgroup-begin nil)
5841 ;; We have to adjust the point of group mode buffer because
5842 ;; point was moved to the next unread newsgroup by exiting.
5843 (gnus-summary-jump-to-group group)
5846 (gnus-group-get-new-news-this-group 1)))
5847 (gnus-group-read-group all t)
5848 (gnus-summary-goto-subject current-subject nil t)))
5850 (defun gnus-summary-rescan-group (&optional all)
5851 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5853 (gnus-summary-reselect-current-group all t))
5855 (defun gnus-summary-update-info (&optional non-destructive)
5857 (let ((group gnus-newsgroup-name))
5859 (when gnus-newsgroup-kill-headers
5860 (setq gnus-newsgroup-killed
5861 (gnus-compress-sequence
5863 (gnus-set-sorted-intersection
5864 (gnus-uncompress-range gnus-newsgroup-killed)
5865 (setq gnus-newsgroup-unselected
5866 (sort gnus-newsgroup-unselected '<)))
5867 (setq gnus-newsgroup-unreads
5868 (sort gnus-newsgroup-unreads '<)))
5870 (unless (listp (cdr gnus-newsgroup-killed))
5871 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5872 (let ((headers gnus-newsgroup-headers))
5873 ;; Set the new ranges of read articles.
5875 (set-buffer gnus-group-buffer)
5876 (gnus-undo-force-boundary))
5877 (gnus-update-read-articles
5878 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5879 ;; Set the current article marks.
5880 (let ((gnus-newsgroup-scored
5881 (if (and (not gnus-save-score)
5882 (not non-destructive))
5884 gnus-newsgroup-scored)))
5886 (gnus-update-marks)))
5887 ;; Do the cross-ref thing.
5888 (when gnus-use-cross-reference
5889 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5890 ;; Do not switch windows but change the buffer to work.
5891 (set-buffer gnus-group-buffer)
5892 (unless (gnus-ephemeral-group-p group)
5893 (gnus-group-update-group group)))))))
5895 (defun gnus-summary-save-newsrc (&optional force)
5896 "Save the current number of read/marked articles in the dribble buffer.
5897 The dribble buffer will then be saved.
5898 If FORCE (the prefix), also save the .newsrc file(s)."
5900 (gnus-summary-update-info t)
5902 (gnus-save-newsrc-file)
5903 (gnus-dribble-save)))
5905 (defun gnus-summary-exit (&optional temporary)
5906 "Exit reading current newsgroup, and then return to group selection mode.
5907 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5909 (gnus-set-global-variables)
5910 (when (gnus-buffer-live-p gnus-article-buffer)
5912 (set-buffer gnus-article-buffer)
5913 (mm-destroy-parts gnus-article-mime-handles)
5914 ;; Set it to nil for safety reason.
5915 (setq gnus-article-mime-handle-alist nil)
5916 (setq gnus-article-mime-handles nil)))
5917 (gnus-kill-save-kill-buffer)
5918 (gnus-async-halt-prefetch)
5919 (let* ((group gnus-newsgroup-name)
5920 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5923 (buf (current-buffer)))
5925 ;; Do adaptive scoring, and possibly save score files.
5926 (when gnus-newsgroup-adaptive
5927 (gnus-score-adaptive))
5928 (when gnus-use-scoring
5930 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5931 ;; If we have several article buffers, we kill them at exit.
5932 (unless gnus-single-article-buffer
5933 (gnus-kill-buffer gnus-original-article-buffer)
5934 (setq gnus-article-current nil))
5935 (when gnus-use-cache
5936 (gnus-cache-possibly-remove-articles)
5937 (gnus-cache-save-buffers))
5938 (gnus-async-prefetch-remove-group group)
5939 (when gnus-suppress-duplicates
5940 (gnus-dup-enter-articles))
5941 (when gnus-use-trees
5942 (gnus-tree-close group))
5943 (when gnus-use-cache
5944 (gnus-cache-write-active))
5945 ;; Remove entries for this group.
5946 (nnmail-purge-split-history (gnus-group-real-name group))
5947 ;; Make all changes in this group permanent.
5949 (gnus-run-hooks 'gnus-exit-group-hook)
5950 (gnus-summary-update-info))
5951 (gnus-close-group group)
5952 ;; Make sure where we were, and go to next newsgroup.
5953 (set-buffer gnus-group-buffer)
5955 (gnus-group-jump-to-group group))
5956 (gnus-run-hooks 'gnus-summary-exit-hook)
5957 (unless (or quit-config
5958 ;; If this group has disappeared from the summary
5959 ;; buffer, don't skip forwards.
5960 (not (string= group (gnus-group-group-name))))
5961 (gnus-group-next-unread-group 1))
5962 (setq group-point (point))
5965 ;; If we have several article buffers, we kill them at exit.
5966 (unless gnus-single-article-buffer
5967 (gnus-kill-buffer gnus-article-buffer)
5968 (gnus-kill-buffer gnus-original-article-buffer)
5969 (setq gnus-article-current nil))
5971 (if (not gnus-kill-summary-on-exit)
5973 (gnus-deaden-summary)
5975 ;; We set all buffer-local variables to nil. It is unclear why
5976 ;; this is needed, but if we don't, buffer-local variables are
5977 ;; not garbage-collected, it seems. This would the lead to en
5978 ;; ever-growing Emacs.
5979 (gnus-summary-clear-local-variables)
5980 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5981 (gnus-summary-clear-local-variables))
5982 (when (get-buffer gnus-article-buffer)
5983 (bury-buffer gnus-article-buffer))
5984 ;; We clear the global counterparts of the buffer-local
5985 ;; variables as well, just to be on the safe side.
5986 (set-buffer gnus-group-buffer)
5987 (gnus-summary-clear-local-variables)
5988 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5989 (gnus-summary-clear-local-variables)))
5990 (setq gnus-current-select-method gnus-select-method)
5991 (pop-to-buffer gnus-group-buffer)
5992 (if (not quit-config)
5994 (goto-char group-point)
5995 (gnus-configure-windows 'group 'force))
5996 (gnus-handle-ephemeral-exit quit-config))
5997 ;; Return to group mode buffer.
5998 (when (eq mode 'gnus-summary-mode)
5999 (gnus-kill-buffer buf))
6000 ;; Clear the current group name.
6002 (setq gnus-newsgroup-name nil)))))
6004 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6005 (defun gnus-summary-exit-no-update (&optional no-questions)
6006 "Quit reading current newsgroup without updating read article info."
6008 (let* ((group gnus-newsgroup-name)
6009 (quit-config (gnus-group-quit-config group)))
6010 (when (or no-questions
6012 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6013 (gnus-async-halt-prefetch)
6015 (delq 'gnus-summary-expire-articles
6016 (copy-sequence gnus-summary-prepare-exit-hook)))
6017 (when (gnus-buffer-live-p gnus-article-buffer)
6019 (set-buffer gnus-article-buffer)
6020 (mm-destroy-parts gnus-article-mime-handles)
6021 ;; Set it to nil for safety reason.
6022 (setq gnus-article-mime-handle-alist nil)
6023 (setq gnus-article-mime-handles nil)))
6024 ;; If we have several article buffers, we kill them at exit.
6025 (unless gnus-single-article-buffer
6026 (gnus-kill-buffer gnus-article-buffer)
6027 (gnus-kill-buffer gnus-original-article-buffer)
6028 (setq gnus-article-current nil))
6029 (if (not gnus-kill-summary-on-exit)
6030 (gnus-deaden-summary)
6031 (gnus-close-group group)
6032 (gnus-summary-clear-local-variables)
6033 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6034 (gnus-summary-clear-local-variables))
6035 (set-buffer gnus-group-buffer)
6036 (gnus-summary-clear-local-variables)
6037 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6038 (gnus-summary-clear-local-variables))
6039 (when (get-buffer gnus-summary-buffer)
6040 (kill-buffer gnus-summary-buffer)))
6041 (unless gnus-single-article-buffer
6042 (setq gnus-article-current nil))
6043 (when gnus-use-trees
6044 (gnus-tree-close group))
6045 (gnus-async-prefetch-remove-group group)
6046 (when (get-buffer gnus-article-buffer)
6047 (bury-buffer gnus-article-buffer))
6048 ;; Return to the group buffer.
6049 (gnus-configure-windows 'group 'force)
6050 ;; Clear the current group name.
6051 (setq gnus-newsgroup-name nil)
6052 (when (equal (gnus-group-group-name) group)
6053 (gnus-group-next-unread-group 1))
6055 (gnus-handle-ephemeral-exit quit-config)))))
6057 (defun gnus-handle-ephemeral-exit (quit-config)
6058 "Handle movement when leaving an ephemeral group.
6059 The state which existed when entering the ephemeral is reset."
6060 (if (not (buffer-name (car quit-config)))
6061 (gnus-configure-windows 'group 'force)
6062 (set-buffer (car quit-config))
6063 (cond ((eq major-mode 'gnus-summary-mode)
6064 (gnus-set-global-variables))
6065 ((eq major-mode 'gnus-article-mode)
6067 ;; The `gnus-summary-buffer' variable may point
6068 ;; to the old summary buffer when using a single
6070 (unless (gnus-buffer-live-p gnus-summary-buffer)
6071 (set-buffer gnus-group-buffer))
6072 (set-buffer gnus-summary-buffer)
6073 (gnus-set-global-variables))))
6074 (if (or (eq (cdr quit-config) 'article)
6075 (eq (cdr quit-config) 'pick))
6077 ;; The current article may be from the ephemeral group
6078 ;; thus it is best that we reload this article
6079 (gnus-summary-show-article)
6080 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6081 (gnus-configure-windows 'pick 'force)
6082 (gnus-configure-windows (cdr quit-config) 'force)))
6083 (gnus-configure-windows (cdr quit-config) 'force))
6084 (when (eq major-mode 'gnus-summary-mode)
6085 (gnus-summary-next-subject 1 nil t)
6086 (gnus-summary-recenter)
6087 (gnus-summary-position-point))))
6091 (defvar gnus-dead-summary-mode-map nil)
6093 (unless gnus-dead-summary-mode-map
6094 (setq gnus-dead-summary-mode-map (make-keymap))
6095 (suppress-keymap gnus-dead-summary-mode-map)
6096 (substitute-key-definition
6097 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6098 (let ((keys '("\C-d" "\r" "\177" [delete])))
6100 (define-key gnus-dead-summary-mode-map
6101 (pop keys) 'gnus-summary-wake-up-the-dead))))
6103 (defvar gnus-dead-summary-mode nil
6104 "Minor mode for Gnus summary buffers.")
6106 (defun gnus-dead-summary-mode (&optional arg)
6107 "Minor mode for Gnus summary buffers."
6109 (when (eq major-mode 'gnus-summary-mode)
6110 (make-local-variable 'gnus-dead-summary-mode)
6111 (setq gnus-dead-summary-mode
6112 (if (null arg) (not gnus-dead-summary-mode)
6113 (> (prefix-numeric-value arg) 0)))
6114 (when gnus-dead-summary-mode
6115 (gnus-add-minor-mode
6116 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6118 (defun gnus-deaden-summary ()
6119 "Make the current summary buffer into a dead summary buffer."
6120 ;; Kill any previous dead summary buffer.
6121 (when (and gnus-dead-summary
6122 (buffer-name gnus-dead-summary))
6124 (set-buffer gnus-dead-summary)
6125 (when gnus-dead-summary-mode
6126 (kill-buffer (current-buffer)))))
6127 ;; Make this the current dead summary.
6128 (setq gnus-dead-summary (current-buffer))
6129 (gnus-dead-summary-mode 1)
6130 (let ((name (buffer-name)))
6131 (when (string-match "Summary" name)
6133 (concat (substring name 0 (match-beginning 0)) "Dead "
6134 (substring name (match-beginning 0)))
6138 (defun gnus-kill-or-deaden-summary (buffer)
6139 "Kill or deaden the summary BUFFER."
6141 (when (and (buffer-name buffer)
6142 (not gnus-single-article-buffer))
6145 (gnus-kill-buffer gnus-article-buffer)
6146 (gnus-kill-buffer gnus-original-article-buffer)))
6147 (cond (gnus-kill-summary-on-exit
6148 (when (and gnus-use-trees
6149 (gnus-buffer-exists-p buffer))
6152 (gnus-tree-close gnus-newsgroup-name)))
6153 (gnus-kill-buffer buffer))
6154 ((gnus-buffer-exists-p buffer)
6157 (gnus-deaden-summary))))))
6159 (defun gnus-summary-wake-up-the-dead (&rest args)
6160 "Wake up the dead summary buffer."
6162 (gnus-dead-summary-mode -1)
6163 (let ((name (buffer-name)))
6164 (when (string-match "Dead " name)
6166 (concat (substring name 0 (match-beginning 0))
6167 (substring name (match-end 0)))
6169 (gnus-message 3 "This dead summary is now alive again"))
6171 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6172 (defun gnus-summary-fetch-faq (&optional faq-dir)
6173 "Fetch the FAQ for the current group.
6174 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6178 (when current-prefix-arg
6180 "Faq dir: " (and (listp gnus-group-faq-directory)
6181 (mapcar (lambda (file) (list file))
6182 gnus-group-faq-directory))))))
6183 (let (gnus-faq-buffer)
6184 (when (setq gnus-faq-buffer
6185 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6186 (gnus-configure-windows 'summary-faq))))
6188 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6189 (defun gnus-summary-describe-group (&optional force)
6190 "Describe the current newsgroup."
6192 (gnus-group-describe-group force gnus-newsgroup-name))
6194 (defun gnus-summary-describe-briefly ()
6195 "Describe summary mode commands briefly."
6197 (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")))
6199 ;; Walking around group mode buffer from summary mode.
6201 (defun gnus-summary-next-group (&optional no-article target-group backward)
6202 "Exit current newsgroup and then select next unread newsgroup.
6203 If prefix argument NO-ARTICLE is non-nil, no article is selected
6204 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6205 previous group instead."
6207 ;; Stop pre-fetching.
6208 (gnus-async-halt-prefetch)
6209 (let ((current-group gnus-newsgroup-name)
6210 (current-buffer (current-buffer))
6212 ;; First we semi-exit this group to update Xrefs and all variables.
6213 ;; We can't do a real exit, because the window conf must remain
6214 ;; the same in case the user is prompted for info, and we don't
6215 ;; want the window conf to change before that...
6216 (gnus-summary-exit t)
6217 (while (not entered)
6218 ;; Then we find what group we are supposed to enter.
6219 (set-buffer gnus-group-buffer)
6220 (gnus-group-jump-to-group current-group)
6223 (if (eq gnus-keep-same-level 'best)
6224 (gnus-summary-best-group gnus-newsgroup-name)
6225 (gnus-summary-search-group backward gnus-keep-same-level))))
6226 (if (not target-group)
6227 ;; There are no further groups, so we return to the group
6230 (gnus-message 5 "Returning to the group buffer")
6232 (when (gnus-buffer-live-p current-buffer)
6233 (set-buffer current-buffer)
6234 (gnus-summary-exit))
6235 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6236 ;; We try to enter the target group.
6237 (gnus-group-jump-to-group target-group)
6238 (let ((unreads (gnus-group-group-unread)))
6239 (if (and (or (eq t unreads)
6240 (and unreads (not (zerop unreads))))
6241 (gnus-summary-read-group
6242 target-group nil no-article
6243 (and (buffer-name current-buffer) current-buffer)
6246 (setq current-group target-group
6247 target-group nil)))))))
6249 (defun gnus-summary-prev-group (&optional no-article)
6250 "Exit current newsgroup and then select previous unread newsgroup.
6251 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6253 (gnus-summary-next-group no-article nil t))
6255 ;; Walking around summary lines.
6257 (defun gnus-summary-first-subject (&optional unread undownloaded)
6258 "Go to the first unread subject.
6259 If UNREAD is non-nil, go to the first unread article.
6260 Returns the article selected or nil if there are no unread articles."
6265 ((null gnus-newsgroup-data)
6266 (gnus-message 3 "No articles in the group")
6268 ;; Pick the first article.
6270 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6271 (gnus-data-number (car gnus-newsgroup-data)))
6272 ;; No unread articles.
6273 ((null gnus-newsgroup-unreads)
6274 (gnus-message 3 "No more unread articles")
6276 ;; Find the first unread article.
6278 (let ((data gnus-newsgroup-data))
6280 (and (not (and undownloaded
6281 (eq gnus-undownloaded-mark
6282 (gnus-data-mark (car data)))))
6283 (not (gnus-data-unread-p (car data)))))
6284 (setq data (cdr data)))
6286 (goto-char (gnus-data-pos (car data)))
6287 (gnus-data-number (car data))))))
6288 (gnus-summary-position-point)))
6290 (defun gnus-summary-next-subject (n &optional unread dont-display)
6291 "Go to next N'th summary line.
6292 If N is negative, go to the previous N'th subject line.
6293 If UNREAD is non-nil, only unread articles are selected.
6294 The difference between N and the actual number of steps taken is
6297 (let ((backward (< n 0))
6301 (gnus-summary-find-prev unread)
6302 (gnus-summary-find-next unread)))
6303 (unless (zerop (setq n (1- n)))
6304 (gnus-summary-show-thread)))
6306 (gnus-message 7 "No more%s articles"
6307 (if unread " unread" "")))
6308 (unless dont-display
6309 (gnus-summary-recenter)
6310 (gnus-summary-position-point))
6313 (defun gnus-summary-next-unread-subject (n)
6314 "Go to next N'th unread summary line."
6316 (gnus-summary-next-subject n t))
6318 (defun gnus-summary-prev-subject (n &optional unread)
6319 "Go to previous N'th summary line.
6320 If optional argument UNREAD is non-nil, only unread article is selected."
6322 (gnus-summary-next-subject (- n) unread))
6324 (defun gnus-summary-prev-unread-subject (n)
6325 "Go to previous N'th unread summary line."
6327 (gnus-summary-next-subject (- n) t))
6329 (defun gnus-summary-goto-subject (article &optional force silent)
6330 "Go the subject line of ARTICLE.
6331 If FORCE, also allow jumping to articles not currently shown."
6332 (interactive "nArticle number: ")
6334 (data (gnus-data-find article)))
6335 ;; We read in the article if we have to.
6338 (gnus-summary-insert-subject
6340 (if (or (numberp force) (vectorp force)) force)
6342 (setq data (gnus-data-find article)))
6347 (gnus-message 3 "Can't find article %d" article))
6349 (let ((pt (gnus-data-pos data)))
6351 (gnus-summary-set-article-display-arrow pt))
6352 (gnus-summary-position-point)
6355 ;; Walking around summary lines with displaying articles.
6357 (defun gnus-summary-expand-window (&optional arg)
6358 "Make the summary buffer take up the entire Emacs frame.
6359 Given a prefix, will force an `article' buffer configuration."
6362 (gnus-configure-windows 'article 'force)
6363 (gnus-configure-windows 'summary 'force)))
6365 (defun gnus-summary-display-article (article &optional all-header)
6366 "Display ARTICLE in article buffer."
6367 (when (gnus-buffer-live-p gnus-article-buffer)
6368 (with-current-buffer gnus-article-buffer
6369 (mm-enable-multibyte-mule4)))
6370 (gnus-set-global-variables)
6371 (when (gnus-buffer-live-p gnus-article-buffer)
6372 (with-current-buffer gnus-article-buffer
6373 (setq gnus-article-charset gnus-newsgroup-charset)
6374 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6375 (mm-enable-multibyte-mule4)))
6379 (if gnus-summary-display-article-function
6380 (funcall gnus-summary-display-article-function article all-header)
6381 (gnus-article-prepare article all-header))
6382 (gnus-run-hooks 'gnus-select-article-hook)
6383 (when (and gnus-current-article
6384 (not (zerop gnus-current-article)))
6385 (gnus-summary-goto-subject gnus-current-article))
6386 (gnus-summary-recenter)
6387 (when (and gnus-use-trees gnus-show-threads)
6388 (gnus-possibly-generate-tree article)
6389 (gnus-highlight-selected-tree article))
6390 ;; Successfully display article.
6391 (gnus-article-set-window-start
6392 (cdr (assq article gnus-newsgroup-bookmarks))))))
6394 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6395 "Select the current article.
6396 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6397 non-nil, the article will be re-fetched even if it already present in
6398 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6400 ;; Make sure we are in the summary buffer to work around bbdb bug.
6401 (unless (eq major-mode 'gnus-summary-mode)
6402 (set-buffer gnus-summary-buffer))
6403 (let ((article (or article (gnus-summary-article-number)))
6404 (all-headers (not (not all-headers))) ;Must be T or NIL.
6405 gnus-summary-display-article-function)
6407 (gnus-summary-article-pseudo-p article)
6408 (error "This is a pseudo-article"))
6410 (set-buffer gnus-summary-buffer)
6411 (if (or (and gnus-single-article-buffer
6412 (or (null gnus-current-article)
6413 (null gnus-article-current)
6414 (null (get-buffer gnus-article-buffer))
6415 (not (eq article (cdr gnus-article-current)))
6416 (not (equal (car gnus-article-current)
6417 gnus-newsgroup-name))))
6418 (and (not gnus-single-article-buffer)
6419 (or (null gnus-current-article)
6420 (not (eq gnus-current-article article))))
6422 ;; The requested article is different from the current article.
6424 (gnus-summary-display-article article all-headers)
6425 (when (gnus-buffer-live-p gnus-article-buffer)
6426 (with-current-buffer gnus-article-buffer
6427 (if (not gnus-article-decoded-p) ;; a local variable
6428 (mm-disable-multibyte-mule4))))
6429 (when (or all-headers gnus-show-all-headers)
6430 (gnus-article-show-all-headers))
6431 (gnus-article-set-window-start
6432 (cdr (assq article gnus-newsgroup-bookmarks)))
6434 (when (or all-headers gnus-show-all-headers)
6435 (gnus-article-show-all-headers))
6438 (defun gnus-summary-force-verify-and-decrypt ()
6440 (let ((mm-verify-option 'known)
6441 (mm-decrypt-option 'known))
6442 (gnus-summary-select-article nil 'force)))
6444 (defun gnus-summary-set-current-mark (&optional current-mark)
6445 "Obsolete function."
6448 (defun gnus-summary-next-article (&optional unread subject backward push)
6449 "Select the next article.
6450 If UNREAD, only unread articles are selected.
6451 If SUBJECT, only articles with SUBJECT are selected.
6452 If BACKWARD, the previous article is selected instead of the next."
6455 ;; Is there such an article?
6456 ((and (gnus-summary-search-forward unread subject backward)
6457 (or (gnus-summary-display-article (gnus-summary-article-number))
6458 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6459 (gnus-summary-position-point))
6460 ;; If not, we try the first unread, if that is wanted.
6462 gnus-auto-select-same
6463 (gnus-summary-first-unread-article))
6464 (gnus-summary-position-point)
6465 (gnus-message 6 "Wrapped"))
6466 ;; Try to get next/previous article not displayed in this group.
6467 ((and gnus-auto-extend-newsgroup
6468 (not unread) (not subject))
6469 (gnus-summary-goto-article
6470 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6471 nil (count-lines (point-min) (point))))
6472 ;; Go to next/previous group.
6474 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6475 (gnus-summary-jump-to-group gnus-newsgroup-name))
6476 (let ((cmd last-command-char)
6479 (set-buffer gnus-group-buffer)
6482 (if (eq gnus-keep-same-level 'best)
6483 (gnus-summary-best-group gnus-newsgroup-name)
6484 (gnus-summary-search-group backward gnus-keep-same-level))))
6485 ;; For some reason, the group window gets selected. We change
6487 (select-window (get-buffer-window (current-buffer)))
6488 ;; Select next unread newsgroup automagically.
6490 ((or (not gnus-auto-select-next)
6492 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6493 ((or (eq gnus-auto-select-next 'quietly)
6494 (and (eq gnus-auto-select-next 'slightly-quietly)
6496 (and (eq gnus-auto-select-next 'almost-quietly)
6497 (gnus-summary-last-article-p)))
6499 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6501 (gnus-message 7 "No more%s articles (%s)..."
6502 (if unread " unread" "")
6503 (if group (concat "selecting " group)
6505 (gnus-summary-next-group nil group backward)))
6507 (when (gnus-key-press-event-p last-input-event)
6508 (gnus-summary-walk-group-buffer
6509 gnus-newsgroup-name cmd unread backward point))))))))
6511 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6512 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6513 (?\C-p (gnus-group-prev-unread-group 1))))
6514 (cursor-in-echo-area t)
6515 keve key group ended)
6517 (set-buffer gnus-group-buffer)
6520 (if (eq gnus-keep-same-level 'best)
6521 (gnus-summary-best-group gnus-newsgroup-name)
6522 (gnus-summary-search-group backward gnus-keep-same-level))))
6525 5 "No more%s articles%s" (if unread " unread" "")
6527 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6528 (format " (Type %s for %s [%s])"
6529 (single-key-description cmd) group
6530 (car (gnus-gethash group gnus-newsrc-hashtb)))
6531 (format " (Type %s to exit %s)"
6532 (single-key-description cmd)
6533 gnus-newsgroup-name)))
6534 ;; Confirm auto selection.
6535 (setq key (car (setq keve (gnus-read-event-char))))
6538 ((assq key keystrokes)
6539 (let ((obuf (current-buffer)))
6540 (switch-to-buffer gnus-group-buffer)
6542 (gnus-group-jump-to-group group))
6543 (eval (cadr (assq key keystrokes)))
6544 (setq group (gnus-group-group-name))
6545 (switch-to-buffer obuf))
6549 (gnus-ephemeral-group-p gnus-newsgroup-name))
6551 (gnus-summary-next-group nil group backward)))
6553 (push (cdr keve) unread-command-events))))))
6555 (defun gnus-summary-next-unread-article ()
6556 "Select unread article after current one."
6558 (gnus-summary-next-article
6559 (or (not (eq gnus-summary-goto-unread 'never))
6560 (gnus-summary-last-article-p (gnus-summary-article-number)))
6561 (and gnus-auto-select-same
6562 (gnus-summary-article-subject))))
6564 (defun gnus-summary-prev-article (&optional unread subject)
6565 "Select the article after the current one.
6566 If UNREAD is non-nil, only unread articles are selected."
6568 (gnus-summary-next-article unread subject t))
6570 (defun gnus-summary-prev-unread-article ()
6571 "Select unread article before current one."
6573 (gnus-summary-prev-article
6574 (or (not (eq gnus-summary-goto-unread 'never))
6575 (gnus-summary-first-article-p (gnus-summary-article-number)))
6576 (and gnus-auto-select-same
6577 (gnus-summary-article-subject))))
6579 (defun gnus-summary-next-page (&optional lines circular)
6580 "Show next page of the selected article.
6581 If at the end of the current article, select the next article.
6582 LINES says how many lines should be scrolled up.
6584 If CIRCULAR is non-nil, go to the start of the article instead of
6585 selecting the next article when reaching the end of the current
6588 (setq gnus-summary-buffer (current-buffer))
6589 (gnus-set-global-variables)
6590 (let ((article (gnus-summary-article-number))
6591 (article-window (get-buffer-window gnus-article-buffer t))
6593 ;; If the buffer is empty, we have no article.
6595 (error "No article to select"))
6596 (gnus-configure-windows 'article)
6597 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6598 (if (and (eq gnus-summary-goto-unread 'never)
6599 (not (gnus-summary-last-article-p article)))
6600 (gnus-summary-next-article)
6601 (gnus-summary-next-unread-article))
6602 (if (or (null gnus-current-article)
6603 (null gnus-article-current)
6604 (/= article (cdr gnus-article-current))
6605 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6606 ;; Selected subject is different from current article's.
6607 (gnus-summary-display-article article)
6608 (when article-window
6609 (gnus-eval-in-buffer-window gnus-article-buffer
6610 (setq endp (gnus-article-next-page lines)))
6613 (gnus-summary-beginning-of-article))
6615 (gnus-message 3 "End of message"))
6617 (if (and (eq gnus-summary-goto-unread 'never)
6618 (not (gnus-summary-last-article-p article)))
6619 (gnus-summary-next-article)
6620 (gnus-summary-next-unread-article))))))))
6621 (gnus-summary-recenter)
6622 (gnus-summary-position-point)))
6624 (defun gnus-summary-prev-page (&optional lines move)
6625 "Show previous page of selected article.
6626 Argument LINES specifies lines to be scrolled down.
6627 If MOVE, move to the previous unread article if point is at
6628 the beginning of the buffer."
6630 (let ((article (gnus-summary-article-number))
6631 (article-window (get-buffer-window gnus-article-buffer t))
6633 (gnus-configure-windows 'article)
6634 (if (or (null gnus-current-article)
6635 (null gnus-article-current)
6636 (/= article (cdr gnus-article-current))
6637 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6638 ;; Selected subject is different from current article's.
6639 (gnus-summary-display-article article)
6640 (gnus-summary-recenter)
6641 (when article-window
6642 (gnus-eval-in-buffer-window gnus-article-buffer
6643 (setq endp (gnus-article-prev-page lines)))
6644 (when (and move endp)
6646 (gnus-message 3 "Beginning of message"))
6648 (if (and (eq gnus-summary-goto-unread 'never)
6649 (not (gnus-summary-first-article-p article)))
6650 (gnus-summary-prev-article)
6651 (gnus-summary-prev-unread-article))))))))
6652 (gnus-summary-position-point))
6654 (defun gnus-summary-prev-page-or-article (&optional lines)
6655 "Show previous page of selected article.
6656 Argument LINES specifies lines to be scrolled down.
6657 If at the beginning of the article, go to the next article."
6659 (gnus-summary-prev-page lines t))
6661 (defun gnus-summary-scroll-up (lines)
6662 "Scroll up (or down) one line current article.
6663 Argument LINES specifies lines to be scrolled up (or down if negative)."
6665 (gnus-configure-windows 'article)
6666 (gnus-summary-show-thread)
6667 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6668 (gnus-eval-in-buffer-window gnus-article-buffer
6670 (when (gnus-article-next-page lines)
6671 (gnus-message 3 "End of message")))
6673 (gnus-article-prev-page (- lines))))))
6674 (gnus-summary-recenter)
6675 (gnus-summary-position-point))
6677 (defun gnus-summary-scroll-down (lines)
6678 "Scroll down (or up) one line current article.
6679 Argument LINES specifies lines to be scrolled down (or up if negative)."
6681 (gnus-summary-scroll-up (- lines)))
6683 (defun gnus-summary-next-same-subject ()
6684 "Select next article which has the same subject as current one."
6686 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6688 (defun gnus-summary-prev-same-subject ()
6689 "Select previous article which has the same subject as current one."
6691 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6693 (defun gnus-summary-next-unread-same-subject ()
6694 "Select next unread article which has the same subject as current one."
6696 (gnus-summary-next-article t (gnus-summary-article-subject)))
6698 (defun gnus-summary-prev-unread-same-subject ()
6699 "Select previous unread article which has the same subject as current one."
6701 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6703 (defun gnus-summary-first-unread-article ()
6704 "Select the first unread article.
6705 Return nil if there are no unread articles."
6708 (when (gnus-summary-first-subject t)
6709 (gnus-summary-show-thread)
6710 (gnus-summary-first-subject t)
6711 (gnus-summary-display-article (gnus-summary-article-number)))
6712 (gnus-summary-position-point)))
6714 (defun gnus-summary-first-unread-subject ()
6715 "Place the point on the subject line of the first unread article.
6716 Return nil if there are no unread articles."
6719 (when (gnus-summary-first-subject t)
6720 (gnus-summary-show-thread)
6721 (gnus-summary-first-subject t))
6722 (gnus-summary-position-point)))
6724 (defun gnus-summary-first-article ()
6725 "Select the first article.
6726 Return nil if there are no articles."
6729 (when (gnus-summary-first-subject)
6730 (gnus-summary-show-thread)
6731 (gnus-summary-first-subject)
6732 (gnus-summary-display-article (gnus-summary-article-number)))
6733 (gnus-summary-position-point)))
6735 (defun gnus-summary-best-unread-article ()
6736 "Select the unread article with the highest score."
6738 (let ((best -1000000)
6739 (data gnus-newsgroup-data)
6742 (and (gnus-data-unread-p (car data))
6744 (gnus-summary-article-score (gnus-data-number (car data))))
6747 article (gnus-data-number (car data))))
6748 (setq data (cdr data)))
6751 (gnus-summary-goto-article article)
6752 (error "No unread articles"))
6753 (gnus-summary-position-point))))
6755 (defun gnus-summary-last-subject ()
6756 "Go to the last displayed subject line in the group."
6757 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6759 (gnus-summary-goto-subject article))))
6761 (defun gnus-summary-goto-article (article &optional all-headers force)
6762 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6763 If ALL-HEADERS is non-nil, no header lines are hidden.
6764 If FORCE, go to the article even if it isn't displayed. If FORCE
6765 is a number, it is the line the article is to be displayed on."
6769 "Article number or Message-ID: "
6770 (mapcar (lambda (number) (list (int-to-string number)))
6771 gnus-newsgroup-limit))
6775 (if (and (stringp article)
6776 (string-match "@" article))
6777 (gnus-summary-refer-article article)
6778 (when (stringp article)
6779 (setq article (string-to-number article)))
6780 (if (gnus-summary-goto-subject article force)
6781 (gnus-summary-display-article article all-headers)
6782 (gnus-message 4 "Couldn't go to article %s" article) nil))
6783 (gnus-summary-position-point)))
6785 (defun gnus-summary-goto-last-article ()
6786 "Go to the previously read article."
6789 (when gnus-last-article
6790 (gnus-summary-goto-article gnus-last-article nil t))
6791 (gnus-summary-position-point)))
6793 (defun gnus-summary-pop-article (number)
6794 "Pop one article off the history and go to the previous.
6795 NUMBER articles will be popped off."
6798 (setq gnus-newsgroup-history
6799 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6801 (gnus-summary-goto-article (car to) nil t)
6802 (error "Article history empty")))
6803 (gnus-summary-position-point))
6805 ;; Summary commands and functions for limiting the summary buffer.
6807 (defun gnus-summary-limit-to-articles (n)
6808 "Limit the summary buffer to the next N articles.
6809 If not given a prefix, use the process marked articles instead."
6812 (let ((articles (gnus-summary-work-articles n)))
6813 (setq gnus-newsgroup-processable nil)
6814 (gnus-summary-limit articles))
6815 (gnus-summary-position-point)))
6817 (defun gnus-summary-pop-limit (&optional total)
6818 "Restore the previous limit.
6819 If given a prefix, remove all limits."
6822 (setq gnus-newsgroup-limits
6823 (list (mapcar (lambda (h) (mail-header-number h))
6824 gnus-newsgroup-headers))))
6825 (unless gnus-newsgroup-limits
6826 (error "No limit to pop"))
6828 (gnus-summary-limit nil 'pop)
6829 (gnus-summary-position-point)))
6831 (defun gnus-summary-limit-to-subject (subject &optional header)
6832 "Limit the summary buffer to articles that have subjects that match a regexp."
6833 (interactive "sLimit to subject (regexp): ")
6835 (setq header "subject"))
6836 (when (not (equal "" subject))
6838 (let ((articles (gnus-summary-find-matching
6839 (or header "subject") subject 'all)))
6841 (error "Found no matches for \"%s\"" subject))
6842 (gnus-summary-limit articles))
6843 (gnus-summary-position-point))))
6845 (defun gnus-summary-limit-to-author (from)
6846 "Limit the summary buffer to articles that have authors that match a regexp."
6847 (interactive "sLimit to author (regexp): ")
6848 (gnus-summary-limit-to-subject from "from"))
6850 (defun gnus-summary-limit-to-age (age &optional younger-p)
6851 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6852 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6853 articles that are younger than AGE days."
6855 (let ((younger current-prefix-arg)
6858 (while (not days-got)
6859 (setq days (if younger
6860 (read-string "Limit to articles within (in days): ")
6861 (read-string "Limit to articles older than (in days): ")))
6862 (when (> (length days) 0)
6863 (setq days (read days)))
6866 (message "Please enter a number.")
6868 (list days younger)))
6870 (let ((data gnus-newsgroup-data)
6871 (cutoff (days-to-time age))
6872 articles d date is-younger)
6873 (while (setq d (pop data))
6874 (when (and (vectorp (gnus-data-header d))
6875 (setq date (mail-header-date (gnus-data-header d))))
6876 (setq is-younger (time-less-p
6877 (time-since (condition-case ()
6884 (push (gnus-data-number d) articles))))
6885 (gnus-summary-limit (nreverse articles)))
6886 (gnus-summary-position-point)))
6888 (defun gnus-summary-limit-to-extra (header regexp)
6889 "Limit the summary buffer to articles that match an 'extra' header."
6893 (gnus-completing-read
6894 (symbol-name (car gnus-extra-headers))
6895 "Limit extra header:"
6897 (cons (symbol-name x) x))
6902 (read-string (format "Limit to header %s (regexp): " header)))))
6903 (when (not (equal "" regexp))
6905 (let ((articles (gnus-summary-find-matching
6906 (cons 'extra header) regexp 'all)))
6908 (error "Found no matches for \"%s\"" regexp))
6909 (gnus-summary-limit articles))
6910 (gnus-summary-position-point))))
6912 (defun gnus-summary-limit-to-display-predicate ()
6913 "Limit the summary buffer to the predicated in the `display' group parameter."
6915 (unless gnus-newsgroup-display
6916 (error "There is no `display' group parameter"))
6918 (dolist (number gnus-newsgroup-articles)
6919 (when (funcall gnus-newsgroup-display)
6920 (push number articles)))
6921 (gnus-summary-limit articles))
6922 (gnus-summary-position-point))
6924 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6926 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6928 (defun gnus-summary-limit-to-unread (&optional all)
6929 "Limit the summary buffer to articles that are not marked as read.
6930 If ALL is non-nil, limit strictly to unread articles."
6933 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6934 (gnus-summary-limit-to-marks
6935 ;; Concat all the marks that say that an article is read and have
6937 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6938 gnus-killed-mark gnus-kill-file-mark
6939 gnus-low-score-mark gnus-expirable-mark
6940 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6941 gnus-duplicate-mark gnus-souped-mark)
6944 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6945 (make-obsolete 'gnus-summary-delete-marked-with
6946 'gnus-summary-limit-exlude-marks)
6948 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6949 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6950 If REVERSE, limit the summary buffer to articles that are marked
6951 with MARKS. MARKS can either be a string of marks or a list of marks.
6952 Returns how many articles were removed."
6953 (interactive "sMarks: ")
6954 (gnus-summary-limit-to-marks marks t))
6956 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6957 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6958 If REVERSE (the prefix), limit the summary buffer to articles that are
6959 not marked with MARKS. MARKS can either be a string of marks or a
6961 Returns how many articles were removed."
6962 (interactive "sMarks: \nP")
6964 (let ((data gnus-newsgroup-data)
6965 (marks (if (listp marks) marks
6966 (append marks nil))) ; Transform to list.
6969 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6970 (memq (gnus-data-mark (car data)) marks))
6971 (push (gnus-data-number (car data)) articles))
6972 (setq data (cdr data)))
6973 (gnus-summary-limit articles))
6974 (gnus-summary-position-point)))
6976 (defun gnus-summary-limit-to-score (score)
6977 "Limit to articles with score at or above SCORE."
6978 (interactive "NLimit to articles with score of at least: ")
6979 (let ((data gnus-newsgroup-data)
6982 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6984 (push (gnus-data-number (car data)) articles))
6985 (setq data (cdr data)))
6987 (gnus-summary-limit articles)
6988 (gnus-summary-position-point))))
6990 (defun gnus-summary-limit-include-thread (id)
6991 "Display all the hidden articles that is in the thread with ID in it.
6992 When called interactively, ID is the Message-ID of the current
6994 (interactive (list (mail-header-id (gnus-summary-article-header))))
6995 (let ((articles (gnus-articles-in-thread
6996 (gnus-id-to-thread (gnus-root-id id)))))
6998 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6999 (gnus-summary-limit-include-matching-articles
7001 (regexp-quote (gnus-simplify-subject-re
7002 (mail-header-subject (gnus-id-to-header id)))))
7003 (gnus-summary-position-point))))
7005 (defun gnus-summary-limit-include-matching-articles (header regexp)
7006 "Display all the hidden articles that have HEADERs that match REGEXP."
7007 (interactive (list (read-string "Match on header: ")
7008 (read-string "Regexp: ")))
7009 (let ((articles (gnus-find-matching-articles header regexp)))
7011 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7012 (gnus-summary-position-point))))
7014 (defun gnus-summary-limit-include-dormant ()
7015 "Display all the hidden articles that are marked as dormant.
7016 Note that this command only works on a subset of the articles currently
7017 fetched for this group."
7019 (unless gnus-newsgroup-dormant
7020 (error "There are no dormant articles in this group"))
7022 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7023 (gnus-summary-position-point)))
7025 (defun gnus-summary-limit-exclude-dormant ()
7026 "Hide all dormant articles."
7029 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7030 (gnus-summary-position-point)))
7032 (defun gnus-summary-limit-exclude-childless-dormant ()
7033 "Hide all dormant articles that have no children."
7035 (let ((data (gnus-data-list t))
7036 articles d children)
7037 ;; Find all articles that are either not dormant or have
7039 (while (setq d (pop data))
7040 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7042 (gnus-article-children (gnus-data-number d)))
7045 (when (memq (car children) articles)
7050 (push (gnus-data-number d) articles)))
7053 (gnus-summary-limit articles)
7054 (gnus-summary-position-point))))
7056 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7057 "Mark all unread excluded articles as read.
7058 If ALL, mark even excluded ticked and dormants as read."
7060 (let ((articles (gnus-sorted-complement
7062 (mapcar (lambda (h) (mail-header-number h))
7063 gnus-newsgroup-headers)
7065 (sort gnus-newsgroup-limit '<)))
7067 (setq gnus-newsgroup-unreads
7068 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7070 (setq gnus-newsgroup-dormant nil
7071 gnus-newsgroup-marked nil
7072 gnus-newsgroup-reads
7074 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7075 gnus-newsgroup-reads))
7076 (while (setq article (pop articles))
7077 (unless (or (memq article gnus-newsgroup-dormant)
7078 (memq article gnus-newsgroup-marked))
7079 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7081 (defun gnus-summary-limit (articles &optional pop)
7083 ;; We pop the previous limit off the stack and use that.
7084 (setq articles (car gnus-newsgroup-limits)
7085 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7086 ;; We use the new limit, so we push the old limit on the stack.
7087 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7089 (setq gnus-newsgroup-limit articles)
7090 (let ((total (length gnus-newsgroup-data))
7091 (data (gnus-data-find-list (gnus-summary-article-number)))
7092 (gnus-summary-mark-below nil) ; Inhibit this.
7094 ;; This will do all the work of generating the new summary buffer
7095 ;; according to the new limit.
7096 (gnus-summary-prepare)
7097 ;; Hide any threads, possibly.
7098 (and gnus-show-threads
7099 gnus-thread-hide-subtree
7100 (gnus-summary-hide-all-threads))
7101 ;; Try to return to the article you were at, or one in the
7104 ;; We try to find some article after the current one.
7106 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7109 (setq data (cdr data))))
7111 ;; If there is no data, that means that we were after the last
7112 ;; article. The same goes when we can't find any articles
7113 ;; after the current one.
7114 (goto-char (point-max))
7115 (gnus-summary-find-prev))
7116 (gnus-set-mode-line 'summary)
7117 ;; We return how many articles were removed from the summary
7118 ;; buffer as a result of the new limit.
7119 (- total (length gnus-newsgroup-data))))
7121 (defsubst gnus-invisible-cut-children (threads)
7124 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7129 (defsubst gnus-cut-thread (thread)
7130 "Go forwards in the thread until we find an article that we want to display."
7131 (when (or (eq gnus-fetch-old-headers 'some)
7132 (eq gnus-fetch-old-headers 'invisible)
7133 (numberp gnus-fetch-old-headers)
7134 (eq gnus-build-sparse-threads 'some)
7135 (eq gnus-build-sparse-threads 'more))
7136 ;; Deal with old-fetched headers and sparse threads.
7140 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7141 (gnus-summary-article-ancient-p
7142 (mail-header-number (car thread))))
7143 (if (or (<= (length (cdr thread)) 1)
7144 (eq gnus-fetch-old-headers 'invisible))
7145 (setq gnus-newsgroup-limit
7146 (delq (mail-header-number (car thread))
7147 gnus-newsgroup-limit)
7148 thread (cadr thread))
7149 (when (gnus-invisible-cut-children (cdr thread))
7150 (let ((th (cdr thread)))
7152 (if (memq (mail-header-number (caar th))
7153 gnus-newsgroup-limit)
7154 (setq thread (car th)
7156 (setq th (cdr th))))))))))
7159 (defun gnus-cut-threads (threads)
7160 "Cut off all uninteresting articles from the beginning of threads."
7161 (when (or (eq gnus-fetch-old-headers 'some)
7162 (eq gnus-fetch-old-headers 'invisible)
7163 (numberp gnus-fetch-old-headers)
7164 (eq gnus-build-sparse-threads 'some)
7165 (eq gnus-build-sparse-threads 'more))
7168 (setcar th (gnus-cut-thread (car th)))
7169 (setq th (cdr th)))))
7170 ;; Remove nixed out threads.
7173 (defun gnus-summary-initial-limit (&optional show-if-empty)
7174 "Figure out what the initial limit is supposed to be on group entry.
7175 This entails weeding out unwanted dormants, low-scored articles,
7176 fetch-old-headers verbiage, and so on."
7177 ;; Most groups have nothing to remove.
7178 (if (or gnus-inhibit-limiting
7179 (and (null gnus-newsgroup-dormant)
7180 (eq gnus-newsgroup-display 'gnus-not-ignore)
7181 (not (eq gnus-fetch-old-headers 'some))
7182 (not (numberp gnus-fetch-old-headers))
7183 (not (eq gnus-fetch-old-headers 'invisible))
7184 (null gnus-summary-expunge-below)
7185 (not (eq gnus-build-sparse-threads 'some))
7186 (not (eq gnus-build-sparse-threads 'more))
7187 (null gnus-thread-expunge-below)
7188 (not gnus-use-nocem)))
7190 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7191 (setq gnus-newsgroup-limit nil)
7194 (unless (car (symbol-value node))
7195 ;; These threads have no parents -- they are roots.
7196 (let ((nodes (cdr (symbol-value node)))
7199 (if (and gnus-thread-expunge-below
7200 (< (gnus-thread-total-score (car nodes))
7201 gnus-thread-expunge-below))
7202 (gnus-expunge-thread (pop nodes))
7203 (setq thread (pop nodes))
7204 (gnus-summary-limit-children thread))))))
7205 gnus-newsgroup-dependencies)
7206 ;; If this limitation resulted in an empty group, we might
7207 ;; pop the previous limit and use it instead.
7208 (when (and (not gnus-newsgroup-limit)
7210 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7211 gnus-newsgroup-limit))
7213 (defun gnus-summary-limit-children (thread)
7214 "Return 1 if this subthread is visible and 0 if it is not."
7215 ;; First we get the number of visible children to this thread. This
7216 ;; is done by recursing down the thread using this function, so this
7217 ;; will really go down to a leaf article first, before slowly
7218 ;; working its way up towards the root.
7222 (apply '+ (mapcar 'gnus-summary-limit-children
7225 (number (mail-header-number (car thread)))
7228 (not (memq number gnus-newsgroup-marked))
7230 ;; If this article is dormant and has absolutely no visible
7231 ;; children, then this article isn't visible.
7232 (and (memq number gnus-newsgroup-dormant)
7234 ;; If this is "fetch-old-headered" and there is no
7235 ;; visible children, then we don't want this article.
7236 (and (or (eq gnus-fetch-old-headers 'some)
7237 (numberp gnus-fetch-old-headers))
7238 (gnus-summary-article-ancient-p number)
7240 ;; If this is "fetch-old-headered" and `invisible', then
7241 ;; we don't want this article.
7242 (and (eq gnus-fetch-old-headers 'invisible)
7243 (gnus-summary-article-ancient-p number))
7244 ;; If this is a sparsely inserted article with no children,
7245 ;; we don't want it.
7246 (and (eq gnus-build-sparse-threads 'some)
7247 (gnus-summary-article-sparse-p number)
7249 ;; If we use expunging, and this article is really
7250 ;; low-scored, then we don't want this article.
7251 (when (and gnus-summary-expunge-below
7253 (or (cdr (assq number gnus-newsgroup-scored))
7254 gnus-summary-default-score))
7255 gnus-summary-expunge-below))
7256 ;; We increase the expunge-tally here, but that has
7257 ;; nothing to do with the limits, really.
7258 (incf gnus-newsgroup-expunged-tally)
7259 ;; We also mark as read here, if that's wanted.
7260 (when (and gnus-summary-mark-below
7261 (< score gnus-summary-mark-below))
7262 (setq gnus-newsgroup-unreads
7263 (delq number gnus-newsgroup-unreads))
7264 (if gnus-newsgroup-auto-expire
7265 (push number gnus-newsgroup-expirable)
7266 (push (cons number gnus-low-score-mark)
7267 gnus-newsgroup-reads)))
7269 ;; Do the `display' group parameter.
7270 (and gnus-newsgroup-display
7271 (not (funcall gnus-newsgroup-display)))
7272 ;; Check NoCeM things.
7273 (if (and gnus-use-nocem
7274 (gnus-nocem-unwanted-article-p
7275 (mail-header-id (car thread))))
7277 (setq gnus-newsgroup-unreads
7278 (delq number gnus-newsgroup-unreads))
7280 ;; Nope, invisible article.
7282 ;; Ok, this article is to be visible, so we add it to the limit
7284 (push number gnus-newsgroup-limit)
7287 (defun gnus-expunge-thread (thread)
7288 "Mark all articles in THREAD as read."
7289 (let* ((number (mail-header-number (car thread))))
7290 (incf gnus-newsgroup-expunged-tally)
7291 ;; We also mark as read here, if that's wanted.
7292 (setq gnus-newsgroup-unreads
7293 (delq number gnus-newsgroup-unreads))
7294 (if gnus-newsgroup-auto-expire
7295 (push number gnus-newsgroup-expirable)
7296 (push (cons number gnus-low-score-mark)
7297 gnus-newsgroup-reads)))
7298 ;; Go recursively through all subthreads.
7299 (mapcar 'gnus-expunge-thread (cdr thread)))
7301 ;; Summary article oriented commands
7303 (defun gnus-summary-refer-parent-article (n)
7304 "Refer parent article N times.
7305 If N is negative, go to ancestor -N instead.
7306 The difference between N and the number of articles fetched is returned."
7310 (when (not (natnump n))
7315 (setq header (gnus-summary-article-header))
7316 (if (and (eq (mail-header-number header)
7317 (cdr gnus-article-current))
7318 (equal gnus-newsgroup-name
7319 (car gnus-article-current)))
7320 ;; If we try to find the parent of the currently
7321 ;; displayed article, then we take a look at the actual
7322 ;; References header, since this is slightly more
7323 ;; reliable than the References field we got from the
7326 (set-buffer gnus-original-article-buffer)
7327 (nnheader-narrow-to-headers)
7328 (unless (setq ref (message-fetch-field "references"))
7329 (setq ref (message-fetch-field "in-reply-to")))
7332 ;; It's not the current article, so we take a bet on
7333 ;; the value we got from the server.
7334 (mail-header-references header)))
7336 (not (equal ref "")))
7337 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7338 (gnus-message 1 "Couldn't find parent"))
7339 (gnus-message 1 "No references in article %d"
7340 (gnus-summary-article-number))
7343 (gnus-summary-position-point)
7346 (defun gnus-summary-refer-references ()
7347 "Fetch all articles mentioned in the References header.
7348 Return the number of articles fetched."
7350 (let ((ref (mail-header-references (gnus-summary-article-header)))
7351 (current (gnus-summary-article-number))
7355 (error "No References in the current article")
7356 ;; For each Message-ID in the References header...
7357 (while (string-match "<[^>]*>" ref)
7359 ;; ... fetch that article.
7360 (gnus-summary-refer-article
7361 (prog1 (match-string 0 ref)
7362 (setq ref (substring ref (match-end 0))))))
7363 (gnus-summary-goto-subject current)
7364 (gnus-summary-position-point)
7367 (defun gnus-summary-refer-thread (&optional limit)
7368 "Fetch all articles in the current thread.
7369 If LIMIT (the numerical prefix), fetch that many old headers instead
7370 of what's specified by the `gnus-refer-thread-limit' variable."
7372 (let ((id (mail-header-id (gnus-summary-article-header)))
7373 (limit (if limit (prefix-numeric-value limit)
7374 gnus-refer-thread-limit)))
7375 ;; We want to fetch LIMIT *old* headers, but we also have to
7376 ;; re-fetch all the headers in the current buffer, because many of
7377 ;; them may be undisplayed. So we adjust LIMIT.
7378 (when (numberp limit)
7379 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7380 (unless (eq gnus-fetch-old-headers 'invisible)
7381 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7382 ;; Retrieve the headers and read them in.
7383 (if (eq (gnus-retrieve-headers
7384 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7386 (gnus-build-all-threads)
7387 (error "Can't fetch thread from backends that don't support NOV"))
7388 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7389 (gnus-summary-limit-include-thread id)))
7391 (defun gnus-summary-refer-article (message-id)
7392 "Fetch an article specified by MESSAGE-ID."
7393 (interactive "sMessage-ID: ")
7394 (when (and (stringp message-id)
7395 (not (zerop (length message-id))))
7396 ;; Construct the correct Message-ID if necessary.
7397 ;; Suggested by tale@pawl.rpi.edu.
7398 (unless (string-match "^<" message-id)
7399 (setq message-id (concat "<" message-id)))
7400 (unless (string-match ">$" message-id)
7401 (setq message-id (concat message-id ">")))
7402 (let* ((header (gnus-id-to-header message-id))
7404 (gnus-summary-article-sparse-p
7405 (mail-header-number header))
7406 (memq (mail-header-number header)
7407 gnus-newsgroup-limit)))
7410 ;; If the article is present in the buffer we just go to it.
7412 (or (not (gnus-summary-article-sparse-p
7413 (mail-header-number header)))
7416 (gnus-summary-goto-article
7417 (mail-header-number header) nil t)
7419 (gnus-summary-update-article (mail-header-number header)))))
7421 ;; We fetch the article.
7423 (dolist (gnus-override-method (gnus-refer-article-methods))
7424 (gnus-check-server gnus-override-method)
7425 ;; Fetch the header, and display the article.
7426 (when (setq number (gnus-summary-insert-subject message-id))
7427 (gnus-summary-select-article nil nil nil number)
7429 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7431 (defun gnus-refer-article-methods ()
7432 "Return a list of referrable methods."
7434 ;; No method, so we default to current and native.
7435 ((null gnus-refer-article-method)
7436 (list gnus-current-select-method gnus-select-method))
7438 ((eq 'current gnus-refer-article-method)
7439 (list gnus-current-select-method))
7440 ;; List of select methods.
7441 ((not (and (symbolp (car gnus-refer-article-method))
7442 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7444 (dolist (method gnus-refer-article-method)
7445 (push (if (eq 'current method)
7446 gnus-current-select-method
7450 ;; One single select method.
7452 (list gnus-refer-article-method))))
7454 (defun gnus-summary-edit-parameters ()
7455 "Edit the group parameters of the current group."
7457 (gnus-group-edit-group gnus-newsgroup-name 'params))
7459 (defun gnus-summary-customize-parameters ()
7460 "Customize the group parameters of the current group."
7462 (gnus-group-customize gnus-newsgroup-name))
7464 (defun gnus-summary-enter-digest-group (&optional force)
7465 "Enter an nndoc group based on the current article.
7466 If FORCE, force a digest interpretation. If not, try
7467 to guess what the document format is."
7469 (let ((conf gnus-current-window-configuration))
7471 (gnus-summary-select-article))
7472 (setq gnus-current-window-configuration conf)
7473 (let* ((name (format "%s-%d"
7474 (gnus-group-prefixed-name
7475 gnus-newsgroup-name (list 'nndoc ""))
7477 (set-buffer gnus-summary-buffer)
7478 gnus-current-article)))
7479 (ogroup gnus-newsgroup-name)
7480 (params (append (gnus-info-params (gnus-get-info ogroup))
7481 (list (cons 'to-group ogroup))
7482 (list (cons 'save-article-group ogroup))))
7483 (case-fold-search t)
7484 (buf (current-buffer))
7487 (set-buffer gnus-original-article-buffer)
7488 ;; Have the digest group inherit the main mail address of
7489 ;; the parent article.
7490 (when (setq to-address (or (message-fetch-field "reply-to")
7491 (message-fetch-field "from")))
7492 (setq params (append
7493 (list (cons 'to-address
7494 (funcall gnus-decode-encoded-word-function
7496 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7497 (insert-buffer-substring gnus-original-article-buffer)
7498 ;; Remove lines that may lead nndoc to misinterpret the
7501 (goto-char (point-min))
7502 (or (search-forward "\n\n" nil t) (point)))
7503 (goto-char (point-min))
7504 (delete-matching-lines "^Path:\\|^From ")
7507 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7508 (gnus-newsgroup-ephemeral-ignored-charsets
7509 gnus-newsgroup-ignored-charsets))
7510 (gnus-group-read-ephemeral-group
7511 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7513 ,(if force 'mbox 'guess))) t))
7514 ;; Make all postings to this group go to the parent group.
7515 (nconc (gnus-info-params (gnus-get-info name))
7517 ;; Couldn't select this doc group.
7518 (switch-to-buffer buf)
7519 (gnus-set-global-variables)
7520 (gnus-configure-windows 'summary)
7521 (gnus-message 3 "Article couldn't be entered?"))
7522 (kill-buffer dig)))))
7524 (defun gnus-summary-read-document (n)
7525 "Open a new group based on the current article(s).
7526 This will allow you to read digests and other similar
7527 documents as newsgroups.
7528 Obeys the standard process/prefix convention."
7530 (let* ((articles (gnus-summary-work-articles n))
7531 (ogroup gnus-newsgroup-name)
7532 (params (append (gnus-info-params (gnus-get-info ogroup))
7533 (list (cons 'to-group ogroup))))
7534 article group egroup groups vgroup)
7535 (while (setq article (pop articles))
7536 (setq group (format "%s-%d" gnus-newsgroup-name article))
7537 (gnus-summary-remove-process-mark article)
7538 (when (gnus-summary-display-article article)
7541 (insert-buffer-substring gnus-original-article-buffer)
7542 ;; Remove some headers that may lead nndoc to make
7544 (message-narrow-to-head)
7545 (goto-char (point-min))
7546 (delete-matching-lines "^\\(Path\\):\\|^From ")
7549 (gnus-group-read-ephemeral-group
7550 group `(nndoc ,group (nndoc-address ,(current-buffer))
7551 (nndoc-article-type guess))
7554 ;; Make all postings to this group go to the parent group.
7555 (nconc (gnus-info-params (gnus-get-info egroup))
7557 (push egroup groups))
7558 ;; Couldn't select this doc group.
7559 (gnus-error 3 "Article couldn't be entered"))))))
7560 ;; Now we have selected all the documents.
7563 (error "None of the articles could be interpreted as documents"))
7564 ((gnus-group-read-ephemeral-group
7565 (setq vgroup (format
7566 "nnvirtual:%s-%s" gnus-newsgroup-name
7567 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7568 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7570 (cons (current-buffer) 'summary)))
7572 (error "Couldn't select virtual nndoc group")))))
7574 (defun gnus-summary-isearch-article (&optional regexp-p)
7575 "Do incremental search forward on the current article.
7576 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7578 (gnus-summary-select-article)
7579 (gnus-configure-windows 'article)
7580 (gnus-eval-in-buffer-window gnus-article-buffer
7583 (isearch-forward regexp-p))))
7585 (defun gnus-summary-search-article-forward (regexp &optional backward)
7586 "Search for an article containing REGEXP forward.
7587 If BACKWARD, search backward instead."
7590 (format "Search article %s (regexp%s): "
7591 (if current-prefix-arg "backward" "forward")
7592 (if gnus-last-search-regexp
7593 (concat ", default " gnus-last-search-regexp)
7595 current-prefix-arg))
7596 (if (string-equal regexp "")
7597 (setq regexp (or gnus-last-search-regexp ""))
7598 (setq gnus-last-search-regexp regexp)
7599 (setq gnus-article-before-search gnus-current-article))
7600 ;; Intentionally set gnus-last-article.
7601 (setq gnus-last-article gnus-article-before-search)
7602 (let ((gnus-last-article gnus-last-article))
7603 (if (gnus-summary-search-article regexp backward)
7604 (gnus-summary-show-thread)
7605 (error "Search failed: \"%s\"" regexp))))
7607 (defun gnus-summary-search-article-backward (regexp)
7608 "Search for an article containing REGEXP backward."
7611 (format "Search article backward (regexp%s): "
7612 (if gnus-last-search-regexp
7613 (concat ", default " gnus-last-search-regexp)
7615 (gnus-summary-search-article-forward regexp 'backward))
7617 (defun gnus-summary-search-article (regexp &optional backward)
7618 "Search for an article containing REGEXP.
7619 Optional argument BACKWARD means do search for backward.
7620 `gnus-select-article-hook' is not called during the search."
7621 ;; We have to require this here to make sure that the following
7622 ;; dynamic binding isn't shadowed by autoloading.
7623 (require 'gnus-async)
7625 (let ((gnus-select-article-hook nil) ;Disable hook.
7626 (gnus-article-prepare-hook nil)
7627 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7628 (gnus-use-article-prefetch nil)
7629 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7630 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7631 (sum (current-buffer))
7632 (gnus-display-mime-function nil)
7635 (gnus-save-hidden-threads
7636 (gnus-summary-select-article)
7637 (set-buffer gnus-article-buffer)
7638 (goto-char (window-point (get-buffer-window (current-buffer))))
7642 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7644 (re-search-backward regexp nil t)
7645 (re-search-forward regexp nil t))
7646 ;; We found the regexp.
7651 (get-buffer-window (current-buffer))
7655 (get-buffer-window (current-buffer))
7658 (setq point (point)))
7659 ;; We didn't find it, so we go to the next article.
7662 (while (eq found 'not)
7663 (if (not (if backward (gnus-summary-find-prev)
7664 (gnus-summary-find-next)))
7665 ;; No more articles.
7667 ;; Select the next article and adjust point.
7668 (unless (gnus-summary-article-sparse-p
7669 (gnus-summary-article-number))
7671 (gnus-summary-select-article)
7672 (set-buffer gnus-article-buffer)
7674 (goto-char (if backward (point-max) (point-min))))))))
7675 (gnus-message 7 ""))
7676 ;; Return whether we found the regexp.
7677 (when (eq found 'found)
7679 (gnus-summary-show-thread)
7680 (gnus-summary-goto-subject gnus-current-article)
7681 (gnus-summary-position-point)
7684 (defun gnus-find-matching-articles (header regexp)
7685 "Return a list of all articles that match REGEXP on HEADER.
7686 This search includes all articles in the current group that Gnus has
7687 fetched headers for, whether they are displayed or not."
7688 (let ((articles nil)
7689 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7690 (case-fold-search t))
7691 (dolist (header gnus-newsgroup-headers)
7692 (when (string-match regexp (funcall func header))
7693 (push (mail-header-number header) articles)))
7694 (nreverse articles)))
7696 (defun gnus-summary-find-matching (header regexp &optional backward unread
7698 "Return a list of all articles that match REGEXP on HEADER.
7699 The search stars on the current article and goes forwards unless
7700 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7701 If UNREAD is non-nil, only unread articles will
7702 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7703 in the comparisons."
7704 (let ((case-fold-search (not not-case-fold))
7707 (if (eq (car header) 'extra)
7710 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7712 (error "%s is an invalid header" header))
7713 (unless (fboundp (intern (concat "mail-header-" header)))
7714 (error "%s is not a valid header" header))
7715 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7716 (dolist (d (if (eq backward 'all)
7718 (gnus-data-find-list
7719 (gnus-summary-article-number)
7720 (gnus-data-list backward))))
7721 (when (and (or (not unread) ; We want all articles...
7722 (gnus-data-unread-p d)) ; Or just unreads.
7723 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7724 (string-match regexp
7725 (funcall func (gnus-data-header d)))) ; Match.
7726 (push (gnus-data-number d) articles))) ; Success!
7727 (nreverse articles)))
7729 (defun gnus-summary-execute-command (header regexp command &optional backward)
7730 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7731 If HEADER is an empty string (or nil), the match is done on the entire
7732 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7734 (list (let ((completion-ignore-case t))
7737 (mapcar (lambda (header) (list (format "%s" header)))
7739 '("Number" "Subject" "From" "Lines" "Date"
7740 "Message-ID" "Xref" "References" "Body")
7741 gnus-extra-headers))
7742 nil 'require-match))
7743 (read-string "Regexp: ")
7744 (read-key-sequence "Command: ")
7745 current-prefix-arg))
7746 (when (equal header "Body")
7748 ;; Hidden thread subtrees must be searched as well.
7749 (gnus-summary-show-all-threads)
7750 ;; We don't want to change current point nor window configuration.
7752 (save-window-excursion
7753 (gnus-message 6 "Executing %s..." (key-description command))
7754 ;; We'd like to execute COMMAND interactively so as to give arguments.
7755 (gnus-execute header regexp
7756 `(call-interactively ',(key-binding command))
7758 (gnus-message 6 "Executing %s...done" (key-description command)))))
7760 (defun gnus-summary-beginning-of-article ()
7761 "Scroll the article back to the beginning."
7763 (gnus-summary-select-article)
7764 (gnus-configure-windows 'article)
7765 (gnus-eval-in-buffer-window gnus-article-buffer
7767 (goto-char (point-min))
7768 (when gnus-page-broken
7769 (gnus-narrow-to-page))))
7771 (defun gnus-summary-end-of-article ()
7772 "Scroll to the end of the article."
7774 (gnus-summary-select-article)
7775 (gnus-configure-windows 'article)
7776 (gnus-eval-in-buffer-window gnus-article-buffer
7778 (goto-char (point-max))
7780 (when gnus-page-broken
7781 (gnus-narrow-to-page))))
7783 (defun gnus-summary-print-article (&optional filename n)
7784 "Generate and print a PostScript image of the N next (mail) articles.
7786 If N is negative, print the N previous articles. If N is nil and articles
7787 have been marked with the process mark, print these instead.
7789 If the optional first argument FILENAME is nil, send the image to the
7790 printer. If FILENAME is a string, save the PostScript image in a file with
7791 that name. If FILENAME is a number, prompt the user for the name of the file
7793 (interactive (list (ps-print-preprint current-prefix-arg)))
7794 (dolist (article (gnus-summary-work-articles n))
7795 (gnus-summary-select-article nil nil 'pseudo article)
7796 (gnus-eval-in-buffer-window gnus-article-buffer
7797 (let ((buffer (generate-new-buffer " *print*")))
7800 (copy-to-buffer buffer (point-min) (point-max))
7802 (gnus-article-delete-invisible-text)
7803 (when (gnus-visual-p 'article-highlight 'highlight)
7804 ;; Copy-to-buffer doesn't copy overlay. So redo
7806 (let ((gnus-article-buffer buffer))
7807 (gnus-article-highlight-citation t)
7808 (gnus-article-highlight-signature)))
7809 (let ((ps-left-header
7812 (mail-header-subject gnus-current-headers) ")")
7814 (mail-header-from gnus-current-headers) ")")))
7817 "/pagenumberstring load"
7819 (mail-header-date gnus-current-headers) ")"))))
7820 (gnus-run-hooks 'gnus-ps-print-hook)
7823 (ps-spool-buffer-with-faces)
7824 (ps-spool-buffer)))))
7825 (kill-buffer buffer))))
7826 (gnus-summary-remove-process-mark article))
7827 (ps-despool filename))
7829 (defun gnus-summary-show-article (&optional arg)
7830 "Force re-fetching of the current article.
7831 If ARG (the prefix) is a number, show the article with the charset
7832 defined in `gnus-summary-show-article-charset-alist', or the charset
7834 If ARG (the prefix) is non-nil and not a number, show the raw article
7835 without any article massaging functions being run."
7839 (gnus-summary-show-article t)
7840 (let ((gnus-newsgroup-charset
7841 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7842 (mm-read-coding-system
7845 (set-buffer gnus-article-buffer)
7846 (let ((coding-systems
7847 (detect-coding-region (point) (point-max))))
7848 (or (car-safe coding-systems)
7849 coding-systems))))))
7850 (gnus-newsgroup-ignored-charsets 'gnus-all))
7851 (gnus-summary-select-article nil 'force)
7852 (let ((deps gnus-newsgroup-dependencies)
7855 (set-buffer gnus-original-article-buffer)
7857 (message-narrow-to-head)
7858 (setq head (buffer-string)))
7860 (insert (format "211 %d Article retrieved.\n"
7861 (cdr gnus-article-current)))
7864 (let ((nntp-server-buffer (current-buffer)))
7865 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7866 (gnus-data-set-header
7867 (gnus-data-find (cdr gnus-article-current))
7869 (gnus-summary-update-article-line
7870 (cdr gnus-article-current) header)
7871 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
7872 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
7874 ;; Select the article the normal way.
7875 (gnus-summary-select-article nil 'force))
7877 ;; We have to require this here to make sure that the following
7878 ;; dynamic binding isn't shadowed by autoloading.
7879 (require 'gnus-async)
7881 ;; Bind the article treatment functions to nil.
7882 (let ((gnus-have-all-headers t)
7883 gnus-article-prepare-hook
7884 gnus-article-decode-hook
7885 gnus-display-mime-function
7887 ;; Destroy any MIME parts.
7888 (when (gnus-buffer-live-p gnus-article-buffer)
7890 (set-buffer gnus-article-buffer)
7891 (mm-destroy-parts gnus-article-mime-handles)
7892 ;; Set it to nil for safety reason.
7893 (setq gnus-article-mime-handle-alist nil)
7894 (setq gnus-article-mime-handles nil)))
7895 (gnus-summary-select-article nil 'force))))
7896 (gnus-summary-goto-subject gnus-current-article)
7897 (gnus-summary-position-point))
7899 (defun gnus-summary-show-raw-article ()
7900 "Show the raw article without any article massaging functions being run."
7902 (gnus-summary-show-article t))
7904 (defun gnus-summary-verbose-headers (&optional arg)
7905 "Toggle permanent full header display.
7906 If ARG is a positive number, turn header display on.
7907 If ARG is a negative number, turn header display off."
7909 (setq gnus-show-all-headers
7910 (cond ((or (not (numberp arg))
7912 (not gnus-show-all-headers))
7915 (gnus-summary-show-article))
7917 (defun gnus-summary-toggle-header (&optional arg)
7918 "Show the headers if they are hidden, or hide them if they are shown.
7919 If ARG is a positive number, show the entire header.
7920 If ARG is a negative number, hide the unwanted header lines."
7923 (set-buffer gnus-article-buffer)
7925 (let* ((buffer-read-only nil)
7926 (inhibit-point-motion-hooks t)
7932 (article-narrow-to-head)
7933 (gnus-article-hidden-text-p 'headers))))
7934 (goto-char (point-min))
7935 (when (search-forward "\n\n" nil t)
7936 (delete-region (point-min) (1- (point))))
7937 (goto-char (point-min))
7939 (set-buffer gnus-original-article-buffer)
7940 (goto-char (point-min))
7941 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7942 (insert-buffer-substring gnus-original-article-buffer 1 e)
7944 (narrow-to-region (point-min) (point))
7945 (article-decode-encoded-words)
7947 (let ((gnus-treat-hide-headers nil)
7948 (gnus-treat-hide-boring-headers nil))
7949 (setq gnus-article-wash-types
7950 (delq 'headers gnus-article-wash-types))
7951 (gnus-treat-article 'head))
7952 (gnus-treat-article 'head)))
7953 (gnus-set-mode-line 'article)))))
7955 (defun gnus-summary-show-all-headers ()
7956 "Make all header lines visible."
7958 (gnus-summary-toggle-header 1))
7960 (defun gnus-summary-caesar-message (&optional arg)
7961 "Caesar rotate the current article by 13.
7962 The numerical prefix specifies how many places to rotate each letter
7965 (gnus-summary-select-article)
7966 (let ((mail-header-separator ""))
7967 (gnus-eval-in-buffer-window gnus-article-buffer
7970 (let ((start (window-start))
7972 (message-caesar-buffer-body arg)
7973 (set-window-start (get-buffer-window (current-buffer)) start))))))
7975 (defun gnus-summary-stop-page-breaking ()
7976 "Stop page breaking in the current article."
7978 (gnus-summary-select-article)
7979 (gnus-eval-in-buffer-window gnus-article-buffer
7981 (when (gnus-visual-p 'page-marker)
7982 (let ((buffer-read-only nil))
7983 (gnus-remove-text-with-property 'gnus-prev)
7984 (gnus-remove-text-with-property 'gnus-next))
7985 (setq gnus-page-broken nil))))
7987 (defun gnus-summary-move-article (&optional n to-newsgroup
7988 select-method action)
7989 "Move the current article to a different newsgroup.
7990 If N is a positive number, move the N next articles.
7991 If N is a negative number, move the N previous articles.
7992 If N is nil and any articles have been marked with the process mark,
7993 move those articles instead.
7994 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7995 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7996 re-spool using this method.
7998 For this function to work, both the current newsgroup and the
7999 newsgroup that you want to move to have to support the `request-move'
8000 and `request-accept' functions.
8002 ACTION can be either `move' (the default), `crosspost' or `copy'."
8005 (setq action 'move))
8006 ;; Check whether the source group supports the required functions.
8007 (cond ((and (eq action 'move)
8008 (not (gnus-check-backend-function
8009 'request-move-article gnus-newsgroup-name)))
8010 (error "The current group does not support article moving"))
8011 ((and (eq action 'crosspost)
8012 (not (gnus-check-backend-function
8013 'request-replace-article gnus-newsgroup-name)))
8014 (error "The current group does not support article editing")))
8015 (let ((articles (gnus-summary-work-articles n))
8016 (prefix (if (gnus-check-backend-function
8017 'request-move-article gnus-newsgroup-name)
8018 (gnus-group-real-prefix gnus-newsgroup-name)
8020 (names '((move "Move" "Moving")
8021 (copy "Copy" "Copying")
8022 (crosspost "Crosspost" "Crossposting")))
8023 (copy-buf (save-excursion
8024 (nnheader-set-temp-buffer " *copy article*")))
8025 art-group to-method new-xref article to-groups)
8026 (unless (assq action names)
8027 (error "Unknown action %s" action))
8028 ;; Read the newsgroup name.
8029 (when (and (not to-newsgroup)
8030 (not select-method))
8032 (gnus-read-move-group-name
8033 (cadr (assq action names))
8034 (symbol-value (intern (format "gnus-current-%s-group" action)))
8036 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8037 (setq to-method (or select-method
8038 (gnus-server-to-method
8039 (gnus-group-method to-newsgroup))))
8040 ;; Check the method we are to move this article to...
8041 (unless (gnus-check-backend-function
8042 'request-accept-article (car to-method))
8043 (error "%s does not support article copying" (car to-method)))
8044 (unless (gnus-check-server to-method)
8045 (error "Can't open server %s" (car to-method)))
8046 (gnus-message 6 "%s to %s: %s..."
8047 (caddr (assq action names))
8048 (or (car select-method) to-newsgroup) articles)
8050 (setq article (pop articles))
8054 ;; Move the article.
8056 ;; Remove this article from future suppression.
8057 (gnus-dup-unsuppress-article article)
8058 (gnus-request-move-article
8059 article ; Article to move
8060 gnus-newsgroup-name ; From newsgroup
8061 (nth 1 (gnus-find-method-for-group
8062 gnus-newsgroup-name)) ; Server
8063 (list 'gnus-request-accept-article
8064 to-newsgroup (list 'quote select-method)
8065 (not articles) t) ; Accept form
8066 (not articles))) ; Only save nov last time
8067 ;; Copy the article.
8070 (set-buffer copy-buf)
8071 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8072 (gnus-request-accept-article
8073 to-newsgroup select-method (not articles) t))))
8074 ;; Crosspost the article.
8075 ((eq action 'crosspost)
8076 (let ((xref (message-tokenize-header
8077 (mail-header-xref (gnus-summary-article-header article))
8079 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8082 (setq xref (list (system-name))))
8085 (mapconcat 'identity
8086 (delete "Xref:" (delete new-xref xref))
8090 (set-buffer copy-buf)
8091 ;; First put the article in the destination group.
8092 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8093 (when (consp (setq art-group
8094 (gnus-request-accept-article
8095 to-newsgroup select-method (not articles))))
8096 (setq new-xref (concat new-xref " " (car art-group)
8097 ":" (cdr art-group)))
8098 ;; Now we have the new Xrefs header, so we insert
8099 ;; it and replace the new article.
8100 (nnheader-replace-header "Xref" new-xref)
8101 (gnus-request-replace-article
8102 (cdr art-group) to-newsgroup (current-buffer))
8106 (gnus-message 1 "Couldn't %s article %s: %s"
8107 (cadr (assq action names)) article
8108 (nnheader-get-report (car to-method))))
8109 ((eq art-group 'junk)
8110 (when (eq action 'move)
8111 (gnus-summary-mark-article article gnus-canceled-mark)
8112 (gnus-message 4 "Deleted article %s" article)))
8114 (let* ((pto-group (gnus-group-prefixed-name
8115 (car art-group) to-method))
8117 (gnus-gethash pto-group gnus-newsrc-hashtb))
8118 (info (nth 2 entry))
8119 (to-group (gnus-info-group info))
8121 ;; Update the group that has been moved to.
8123 (memq action '(move copy)))
8124 (unless (member to-group to-groups)
8125 (push to-group to-groups))
8127 (unless (memq article gnus-newsgroup-unreads)
8128 (push 'read to-marks)
8130 info (gnus-add-to-range (gnus-info-read info)
8131 (list (cdr art-group)))))
8133 ;; See whether the article is to be put in the cache.
8134 (let ((marks gnus-article-mark-lists)
8135 (to-article (cdr art-group)))
8137 ;; Enter the article into the cache in the new group,
8138 ;; if that is required.
8139 (when gnus-use-cache
8140 (gnus-cache-possibly-enter-article
8142 (memq article gnus-newsgroup-marked)
8143 (memq article gnus-newsgroup-dormant)
8144 (memq article gnus-newsgroup-unreads)))
8146 (when gnus-preserve-marks
8147 ;; Copy any marks over to the new group.
8148 (when (and (equal to-group gnus-newsgroup-name)
8149 (not (memq article gnus-newsgroup-unreads)))
8150 ;; Mark this article as read in this group.
8151 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8152 (setcdr (gnus-active to-group) to-article)
8153 (setcdr gnus-newsgroup-active to-article))
8156 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8157 (when (memq article (symbol-value
8158 (intern (format "gnus-newsgroup-%s"
8160 (push (cdar marks) to-marks)
8161 ;; If the other group is the same as this group,
8162 ;; then we have to add the mark to the list.
8163 (when (equal to-group gnus-newsgroup-name)
8164 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8167 (intern (format "gnus-newsgroup-%s"
8169 ;; Copy the marks to other group.
8170 (gnus-add-marked-articles
8171 to-group (cdar marks) (list to-article) info)))
8172 (setq marks (cdr marks)))
8174 (gnus-request-set-mark to-group (list (list (list to-article)
8179 (concat "(gnus-group-set-info '"
8180 (gnus-prin1-to-string (gnus-get-info to-group))
8183 ;; Update the Xref header in this article to point to
8184 ;; the new crossposted article we have just created.
8185 (when (eq action 'crosspost)
8187 (set-buffer copy-buf)
8188 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8189 (nnheader-replace-header "Xref" new-xref)
8190 (gnus-request-replace-article
8191 article gnus-newsgroup-name (current-buffer)))))
8193 ;;;!!!Why is this necessary?
8194 (set-buffer gnus-summary-buffer)
8196 (gnus-summary-goto-subject article)
8197 (when (eq action 'move)
8198 (gnus-summary-mark-article article gnus-canceled-mark))))
8199 (gnus-summary-remove-process-mark article))
8200 ;; Re-activate all groups that have been moved to.
8202 (set-buffer gnus-group-buffer)
8203 (let ((gnus-group-marked to-groups))
8204 (gnus-group-get-new-news-this-group nil t)))
8206 (gnus-kill-buffer copy-buf)
8207 (gnus-summary-position-point)
8208 (gnus-set-mode-line 'summary)))
8210 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8211 "Move the current article to a different newsgroup.
8212 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8213 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8214 re-spool using this method."
8216 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8218 (defun gnus-summary-crosspost-article (&optional n)
8219 "Crosspost the current article to some other group."
8221 (gnus-summary-move-article n nil nil 'crosspost))
8223 (defcustom gnus-summary-respool-default-method nil
8224 "Default method type for respooling an article.
8225 If nil, use to the current newsgroup method."
8227 :group 'gnus-summary-mail)
8229 (defun gnus-summary-respool-article (&optional n method)
8230 "Respool the current article.
8231 The article will be squeezed through the mail spooling process again,
8232 which means that it will be put in some mail newsgroup or other
8233 depending on `nnmail-split-methods'.
8234 If N is a positive number, respool the N next articles.
8235 If N is a negative number, respool the N previous articles.
8236 If N is nil and any articles have been marked with the process mark,
8237 respool those articles instead.
8239 Respooling can be done both from mail groups and \"real\" newsgroups.
8240 In the former case, the articles in question will be moved from the
8241 current group into whatever groups they are destined to. In the
8242 latter case, they will be copied into the relevant groups."
8244 (list current-prefix-arg
8245 (let* ((methods (gnus-methods-using 'respool))
8247 (symbol-name (or gnus-summary-respool-default-method
8248 (car (gnus-find-method-for-group
8249 gnus-newsgroup-name)))))
8251 (gnus-completing-read
8252 methname "What backend do you want to use when respooling?"
8253 methods nil t nil 'gnus-mail-method-history))
8256 ((zerop (length (setq ms (gnus-servers-using-backend
8258 (list (intern method) ""))
8262 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8263 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8266 (error "No method given for respooling"))
8267 (if (assoc (symbol-name
8268 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8269 (gnus-methods-using 'respool))
8270 (gnus-summary-move-article n nil method)
8271 (gnus-summary-copy-article n nil method)))
8273 (defun gnus-summary-import-article (file &optional edit)
8274 "Import an arbitrary file into a mail newsgroup."
8275 (interactive "fImport file: \nP")
8276 (let ((group gnus-newsgroup-name)
8277 (now (current-time))
8278 atts lines group-art)
8279 (unless (gnus-check-backend-function 'request-accept-article group)
8280 (error "%s does not support article importing" group))
8281 (or (file-readable-p file)
8282 (not (file-regular-p file))
8283 (error "Can't read %s" file))
8285 (set-buffer (gnus-get-buffer-create " *import file*"))
8287 (nnheader-insert-file-contents file)
8288 (goto-char (point-min))
8289 (if (nnheader-article-p)
8291 (goto-char (point-min))
8292 (search-forward "\n\n" nil t)
8293 (narrow-to-region (point-min) (1- (point)))
8294 (goto-char (point-min))
8295 (unless (re-search-forward "^date:" nil t)
8296 (goto-char (point-max))
8297 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8298 ;; This doesn't look like an article, so we fudge some headers.
8299 (setq atts (file-attributes file)
8300 lines (count-lines (point-min) (point-max)))
8301 (insert "From: " (read-string "From: ") "\n"
8302 "Subject: " (read-string "Subject: ") "\n"
8303 "Date: " (message-make-date (nth 5 atts)) "\n"
8304 "Message-ID: " (message-make-message-id) "\n"
8305 "Lines: " (int-to-string lines) "\n"
8306 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8307 (setq group-art (gnus-request-accept-article group nil t))
8308 (kill-buffer (current-buffer)))
8309 (setq gnus-newsgroup-active (gnus-activate-group group))
8311 (gnus-summary-goto-article (cdr group-art) nil t)
8313 (gnus-summary-edit-article))))
8315 (defun gnus-summary-create-article ()
8316 "Create an article in a mail newsgroup."
8318 (let ((group gnus-newsgroup-name)
8319 (now (current-time))
8321 (unless (gnus-check-backend-function 'request-accept-article group)
8322 (error "%s does not support article importing" group))
8324 (set-buffer (gnus-get-buffer-create " *import file*"))
8326 (goto-char (point-min))
8327 ;; This doesn't look like an article, so we fudge some headers.
8328 (insert "From: " (read-string "From: ") "\n"
8329 "Subject: " (read-string "Subject: ") "\n"
8330 "Date: " (message-make-date now) "\n"
8331 "Message-ID: " (message-make-message-id) "\n")
8332 (setq group-art (gnus-request-accept-article group nil t))
8333 (kill-buffer (current-buffer)))
8334 (setq gnus-newsgroup-active (gnus-activate-group group))
8336 (gnus-summary-goto-article (cdr group-art) nil t)
8337 (gnus-summary-edit-article)))
8339 (defun gnus-summary-article-posted-p ()
8340 "Say whether the current (mail) article is available from news as well.
8341 This will be the case if the article has both been mailed and posted."
8343 (let ((id (mail-header-references (gnus-summary-article-header)))
8344 (gnus-override-method (car (gnus-refer-article-methods))))
8345 (if (gnus-request-head id "")
8346 (gnus-message 2 "The current message was found on %s"
8347 gnus-override-method)
8348 (gnus-message 2 "The current message couldn't be found on %s"
8349 gnus-override-method)
8352 (defun gnus-summary-expire-articles (&optional now)
8353 "Expire all articles that are marked as expirable in the current group."
8355 (when (gnus-check-backend-function
8356 'request-expire-articles gnus-newsgroup-name)
8357 ;; This backend supports expiry.
8358 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8359 (expirable (if total
8361 ;; We need to update the info for
8362 ;; this group for `gnus-list-of-read-articles'
8363 ;; to give us the right answer.
8364 (gnus-run-hooks 'gnus-exit-group-hook)
8365 (gnus-summary-update-info)
8366 (gnus-list-of-read-articles gnus-newsgroup-name))
8367 (setq gnus-newsgroup-expirable
8368 (sort gnus-newsgroup-expirable '<))))
8369 (expiry-wait (if now 'immediate
8370 (gnus-group-find-parameter
8371 gnus-newsgroup-name 'expiry-wait)))
8372 (nnmail-expiry-target
8373 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8374 nnmail-expiry-target))
8377 ;; There are expirable articles in this group, so we run them
8378 ;; through the expiry process.
8379 (gnus-message 6 "Expiring articles...")
8380 (unless (gnus-check-group gnus-newsgroup-name)
8381 (error "Can't open server for %s" gnus-newsgroup-name))
8382 ;; The list of articles that weren't expired is returned.
8385 (let ((nnmail-expiry-wait-function nil)
8386 (nnmail-expiry-wait expiry-wait))
8387 (setq es (gnus-request-expire-articles
8388 expirable gnus-newsgroup-name)))
8389 (setq es (gnus-request-expire-articles
8390 expirable gnus-newsgroup-name)))
8392 (setq gnus-newsgroup-expirable es))
8393 ;; We go through the old list of expirable, and mark all
8394 ;; really expired articles as nonexistent.
8395 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8396 (let ((gnus-use-cache nil))
8398 (unless (memq (car expirable) es)
8399 (when (gnus-data-find (car expirable))
8400 (gnus-summary-mark-article
8401 (car expirable) gnus-canceled-mark)))
8402 (setq expirable (cdr expirable))))))
8403 (gnus-message 6 "Expiring articles...done")))))
8405 (defun gnus-summary-expire-articles-now ()
8406 "Expunge all expirable articles in the current group.
8407 This means that *all* articles that are marked as expirable will be
8408 deleted forever, right now."
8410 (or gnus-expert-user
8412 "Are you really, really, really sure you want to delete all these messages? ")
8414 (gnus-summary-expire-articles t))
8416 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8417 (defun gnus-summary-delete-article (&optional n)
8418 "Delete the N next (mail) articles.
8419 This command actually deletes articles. This is not a marking
8420 command. The article will disappear forever from your life, never to
8422 If N is negative, delete backwards.
8423 If N is nil and articles have been marked with the process mark,
8424 delete these instead."
8426 (unless (gnus-check-backend-function 'request-expire-articles
8427 gnus-newsgroup-name)
8428 (error "The current newsgroup does not support article deletion"))
8429 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8430 (error "Couldn't open server"))
8431 ;; Compute the list of articles to delete.
8432 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8434 (if (and gnus-novice-user
8435 (not (gnus-yes-or-no-p
8436 (format "Do you really want to delete %s forever? "
8437 (if (> (length articles) 1)
8438 (format "these %s articles" (length articles))
8441 ;; Delete the articles.
8442 (setq not-deleted (gnus-request-expire-articles
8443 articles gnus-newsgroup-name 'force))
8445 (gnus-summary-remove-process-mark (car articles))
8446 ;; The backend might not have been able to delete the article
8448 (unless (memq (car articles) not-deleted)
8449 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8450 (setq articles (cdr articles)))
8452 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8453 (gnus-summary-position-point)
8454 (gnus-set-mode-line 'summary)
8457 (defun gnus-summary-edit-article (&optional arg)
8458 "Edit the current article.
8459 This will have permanent effect only in mail groups.
8460 If ARG is nil, edit the decoded articles.
8461 If ARG is 1, edit the raw articles.
8462 If ARG is 2, edit the raw articles even in read-only groups.
8463 If ARG is 3, edit the articles with the current handles.
8464 Otherwise, allow editing of articles even in read-only
8467 (let (force raw current-handles)
8470 ((eq arg 1) (setq raw t))
8471 ((eq arg 2) (setq raw t
8473 ((eq arg 3) (setq current-handles
8474 (and (gnus-buffer-live-p gnus-article-buffer)
8475 (with-current-buffer gnus-article-buffer
8477 gnus-article-mime-handles
8478 (setq gnus-article-mime-handles nil))))))
8480 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8481 (error "Can't edit the raw article in group nndraft:drafts"))
8483 (set-buffer gnus-summary-buffer)
8484 (let ((mail-parse-charset gnus-newsgroup-charset)
8485 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8486 (gnus-set-global-variables)
8487 (when (and (not force)
8488 (gnus-group-read-only-p))
8489 (error "The current newsgroup does not support article editing"))
8490 (gnus-summary-show-article t)
8491 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8492 (with-current-buffer gnus-article-buffer
8493 (mm-enable-multibyte-mule4)))
8494 (if (equal gnus-newsgroup-name "nndraft:drafts")
8496 (gnus-article-edit-article
8499 (let ((mbl mml-buffer-list))
8500 (setq mml-buffer-list nil)
8501 (mime-to-mml ,'current-handles)
8502 (let ((mbl1 mml-buffer-list))
8503 (setq mml-buffer-list mbl)
8504 (set (make-local-variable 'mml-buffer-list) mbl1))
8505 (make-local-hook 'kill-buffer-hook)
8506 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8507 `(lambda (no-highlight)
8508 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8509 (message-options message-options)
8510 (message-options-set-recipient)
8511 (mail-parse-ignored-charsets
8512 ',gnus-newsgroup-ignored-charsets))
8513 ,(if (not raw) '(progn
8515 (mml-destroy-buffers)
8516 (remove-hook 'kill-buffer-hook
8517 'mml-destroy-buffers t)
8518 (kill-local-variable 'mml-buffer-list)))
8519 (gnus-summary-edit-article-done
8520 ,(or (mail-header-references gnus-current-headers) "")
8521 ,(gnus-group-read-only-p)
8522 ,gnus-summary-buffer no-highlight))))))))
8524 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8526 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8528 "Make edits to the current article permanent."
8531 ;; The buffer restriction contains the entire article if it exists.
8532 (when (article-goto-body)
8533 (let ((lines (count-lines (point) (point-max)))
8534 (length (- (point-max) (point)))
8535 (case-fold-search t)
8536 (body (copy-marker (point))))
8537 (goto-char (point-min))
8538 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8539 (delete-region (match-beginning 1) (match-end 1))
8540 (insert (number-to-string length)))
8541 (goto-char (point-min))
8542 (when (re-search-forward
8543 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8544 (delete-region (match-beginning 1) (match-end 1))
8545 (insert (number-to-string length)))
8546 (goto-char (point-min))
8547 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8548 (delete-region (match-beginning 1) (match-end 1))
8549 (insert (number-to-string lines))))))
8550 ;; Replace the article.
8551 (let ((buf (current-buffer)))
8553 (insert-buffer-substring buf)
8555 (if (and (not read-only)
8556 (not (gnus-request-replace-article
8557 (cdr gnus-article-current) (car gnus-article-current)
8558 (current-buffer) t)))
8559 (error "Couldn't replace article")
8560 ;; Update the summary buffer.
8562 (equal (message-tokenize-header references " ")
8563 (message-tokenize-header
8564 (or (message-fetch-field "references") "") " ")))
8565 ;; We only have to update this line.
8568 (message-narrow-to-head)
8569 (let ((head (buffer-string))
8572 (insert (format "211 %d Article retrieved.\n"
8573 (cdr gnus-article-current)))
8576 (let ((nntp-server-buffer (current-buffer)))
8577 (setq header (car (gnus-get-newsgroup-headers
8579 (set-buffer gnus-summary-buffer)
8580 gnus-newsgroup-dependencies)
8583 (set-buffer gnus-summary-buffer)
8584 (gnus-data-set-header
8585 (gnus-data-find (cdr gnus-article-current))
8587 (gnus-summary-update-article-line
8588 (cdr gnus-article-current) header)
8589 (if (gnus-summary-goto-subject
8590 (cdr gnus-article-current) nil t)
8591 (gnus-summary-update-secondary-mark
8592 (cdr gnus-article-current))))))))
8594 (set-buffer (or buffer gnus-summary-buffer))
8595 (gnus-summary-update-article (cdr gnus-article-current))
8596 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8597 (gnus-summary-update-secondary-mark
8598 (cdr gnus-article-current))))
8599 ;; Prettify the article buffer again.
8600 (unless no-highlight
8602 (set-buffer gnus-article-buffer)
8603 ;;;!!! Fix this -- article should be rehighlighted.
8604 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8605 (set-buffer gnus-original-article-buffer)
8606 (gnus-request-article
8607 (cdr gnus-article-current)
8608 (car gnus-article-current) (current-buffer))))
8609 ;; Prettify the summary buffer line.
8610 (when (gnus-visual-p 'summary-highlight 'highlight)
8611 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8613 (defun gnus-summary-edit-wash (key)
8614 "Perform editing command KEY in the article buffer."
8618 (message "%s" (concat (this-command-keys) "- "))
8621 (gnus-summary-edit-article)
8622 (execute-kbd-macro (concat (this-command-keys) key))
8623 (gnus-article-edit-done))
8626 (defun gnus-summary-toggle-smiley (&optional arg)
8627 "Toggle the display of smilies as small graphical icons."
8630 (set-buffer gnus-article-buffer)
8631 (gnus-smiley-display arg)
8636 (defun gnus-summary-respool-query (&optional silent trace)
8637 "Query where the respool algorithm would put this article."
8639 (let (gnus-mark-article-hook)
8640 (gnus-summary-select-article)
8642 (set-buffer gnus-original-article-buffer)
8644 (message-narrow-to-head)
8645 (let ((groups (nnmail-article-group 'identity trace)))
8648 (message "This message would go to %s"
8649 (mapconcat 'car groups ", "))
8650 (message "This message would go to no groups"))
8653 (defun gnus-summary-respool-trace ()
8654 "Trace where the respool algorithm would put this article.
8655 Display a buffer showing all fancy splitting patterns which matched."
8657 (gnus-summary-respool-query nil t))
8659 ;; Summary marking commands.
8661 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8662 "Mark articles which has the same subject as read, and then select the next.
8663 If UNMARK is positive, remove any kind of mark.
8664 If UNMARK is negative, tick articles."
8667 (setq unmark (prefix-numeric-value unmark)))
8669 (gnus-summary-mark-same-subject
8670 (gnus-summary-article-subject) unmark)))
8671 ;; Select next unread article. If auto-select-same mode, should
8672 ;; select the first unread article.
8673 (gnus-summary-next-article t (and gnus-auto-select-same
8674 (gnus-summary-article-subject)))
8675 (gnus-message 7 "%d article%s marked as %s"
8676 count (if (= count 1) " is" "s are")
8677 (if unmark "unread" "read"))))
8679 (defun gnus-summary-kill-same-subject (&optional unmark)
8680 "Mark articles which has the same subject as read.
8681 If UNMARK is positive, remove any kind of mark.
8682 If UNMARK is negative, tick articles."
8685 (setq unmark (prefix-numeric-value unmark)))
8687 (gnus-summary-mark-same-subject
8688 (gnus-summary-article-subject) unmark)))
8689 ;; If marked as read, go to next unread subject.
8691 ;; Go to next unread subject.
8692 (gnus-summary-next-subject 1 t))
8693 (gnus-message 7 "%d articles are marked as %s"
8694 count (if unmark "unread" "read"))))
8696 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8697 "Mark articles with same SUBJECT as read, and return marked number.
8698 If optional argument UNMARK is positive, remove any kinds of marks.
8699 If optional argument UNMARK is negative, mark articles as unread instead."
8703 ((null unmark) ; Mark as read.
8706 (gnus-summary-mark-article-as-read gnus-killed-mark)
8707 (gnus-summary-show-thread) t)
8708 (gnus-summary-find-subject subject))
8709 (setq count (1+ count))))
8710 ((> unmark 0) ; Tick.
8713 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8714 (gnus-summary-show-thread) t)
8715 (gnus-summary-find-subject subject))
8716 (setq count (1+ count))))
8717 (t ; Mark as unread.
8720 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8721 (gnus-summary-show-thread) t)
8722 (gnus-summary-find-subject subject))
8723 (setq count (1+ count)))))
8724 (gnus-set-mode-line 'summary)
8725 ;; Return the number of marked articles.
8728 (defun gnus-summary-mark-as-processable (n &optional unmark)
8729 "Set the process mark on the next N articles.
8730 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8731 the process mark instead. The difference between N and the actual
8732 number of articles marked is returned."
8734 (if (and (null n) (gnus-region-active-p))
8735 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8736 (setq n (prefix-numeric-value n))
8737 (let ((backward (< n 0))
8742 (gnus-summary-remove-process-mark
8743 (gnus-summary-article-number))
8744 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8745 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8748 (gnus-message 7 "No more articles"))
8749 (gnus-summary-recenter)
8750 (gnus-summary-position-point)
8753 (defun gnus-summary-unmark-as-processable (n)
8754 "Remove the process mark from the next N articles.
8755 If N is negative, unmark backward instead. The difference between N and
8756 the actual number of articles unmarked is returned."
8758 (gnus-summary-mark-as-processable n t))
8760 (defun gnus-summary-unmark-all-processable ()
8761 "Remove the process mark from all articles."
8764 (while gnus-newsgroup-processable
8765 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8766 (gnus-summary-position-point))
8768 (defun gnus-summary-add-mark (article type)
8769 "Mark ARTICLE with a mark of TYPE."
8770 (let ((vtype (car (assq type gnus-article-mark-lists)))
8773 (error "No such mark type: %s" type)
8774 (setq var (intern (format "gnus-newsgroup-%s" type)))
8775 (set var (cons article (symbol-value var)))
8776 (if (memq type '(processable cached replied forwarded recent saved))
8777 (gnus-summary-update-secondary-mark article)
8778 ;;; !!! This is bogus. We should find out what primary
8779 ;;; !!! mark we want to set.
8780 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8782 (defun gnus-summary-mark-as-expirable (n)
8783 "Mark N articles forward as expirable.
8784 If N is negative, mark backward instead. The difference between N and
8785 the actual number of articles marked is returned."
8787 (gnus-summary-mark-forward n gnus-expirable-mark))
8789 (defun gnus-summary-mark-article-as-replied (article)
8790 "Mark ARTICLE as replied to and update the summary line.
8791 ARTICLE can also be a list of articles."
8792 (interactive (list (gnus-summary-article-number)))
8793 (let ((articles (if (listp article) article (list article))))
8794 (dolist (article articles)
8795 (push article gnus-newsgroup-replied)
8796 (let ((buffer-read-only nil))
8797 (when (gnus-summary-goto-subject article nil t)
8798 (gnus-summary-update-secondary-mark article))))))
8800 (defun gnus-summary-mark-article-as-forwarded (article)
8801 "Mark ARTICLE as forwarded and update the summary line.
8802 ARTICLE can also be a list of articles."
8803 (let ((articles (if (listp article) article (list article))))
8804 (dolist (article articles)
8805 (push article gnus-newsgroup-forwarded)
8806 (let ((buffer-read-only nil))
8807 (when (gnus-summary-goto-subject article nil t)
8808 (gnus-summary-update-secondary-mark article))))))
8810 (defun gnus-summary-set-bookmark (article)
8811 "Set a bookmark in current article."
8812 (interactive (list (gnus-summary-article-number)))
8813 (when (or (not (get-buffer gnus-article-buffer))
8814 (not gnus-current-article)
8815 (not gnus-article-current)
8816 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8817 (error "No current article selected"))
8818 ;; Remove old bookmark, if one exists.
8819 (let ((old (assq article gnus-newsgroup-bookmarks)))
8821 (setq gnus-newsgroup-bookmarks
8822 (delq old gnus-newsgroup-bookmarks))))
8823 ;; Set the new bookmark, which is on the form
8824 ;; (article-number . line-number-in-body).
8828 (set-buffer gnus-article-buffer)
8832 (goto-char (point-min))
8833 (search-forward "\n\n" nil t)
8836 gnus-newsgroup-bookmarks)
8837 (gnus-message 6 "A bookmark has been added to the current article."))
8839 (defun gnus-summary-remove-bookmark (article)
8840 "Remove the bookmark from the current article."
8841 (interactive (list (gnus-summary-article-number)))
8842 ;; Remove old bookmark, if one exists.
8843 (let ((old (assq article gnus-newsgroup-bookmarks)))
8846 (setq gnus-newsgroup-bookmarks
8847 (delq old gnus-newsgroup-bookmarks))
8848 (gnus-message 6 "Removed bookmark."))
8849 (gnus-message 6 "No bookmark in current article."))))
8851 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8852 (defun gnus-summary-mark-as-dormant (n)
8853 "Mark N articles forward as dormant.
8854 If N is negative, mark backward instead. The difference between N and
8855 the actual number of articles marked is returned."
8857 (gnus-summary-mark-forward n gnus-dormant-mark))
8859 (defun gnus-summary-set-process-mark (article)
8860 "Set the process mark on ARTICLE and update the summary line."
8861 (setq gnus-newsgroup-processable
8863 (delq article gnus-newsgroup-processable)))
8864 (when (gnus-summary-goto-subject article)
8865 (gnus-summary-show-thread)
8866 (gnus-summary-goto-subject article)
8867 (gnus-summary-update-secondary-mark article)))
8869 (defun gnus-summary-remove-process-mark (article)
8870 "Remove the process mark from ARTICLE and update the summary line."
8871 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8872 (when (gnus-summary-goto-subject article)
8873 (gnus-summary-show-thread)
8874 (gnus-summary-goto-subject article)
8875 (gnus-summary-update-secondary-mark article)))
8877 (defun gnus-summary-set-saved-mark (article)
8878 "Set the process mark on ARTICLE and update the summary line."
8879 (push article gnus-newsgroup-saved)
8880 (when (gnus-summary-goto-subject article)
8881 (gnus-summary-update-secondary-mark article)))
8883 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8884 "Mark N articles as read forwards.
8885 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8886 The difference between N and the actual number of articles marked is
8888 Iff NO-EXPIRE, auto-expiry will be inhibited."
8890 (gnus-summary-show-thread)
8891 (let ((backward (< n 0))
8892 (gnus-summary-goto-unread
8893 (and gnus-summary-goto-unread
8894 (not (eq gnus-summary-goto-unread 'never))
8895 (not (memq mark (list gnus-unread-mark
8896 gnus-ticked-mark gnus-dormant-mark)))))
8898 (mark (or mark gnus-del-mark)))
8900 (gnus-summary-mark-article nil mark no-expire)
8901 (zerop (gnus-summary-next-subject
8903 (and gnus-summary-goto-unread
8904 (not (eq gnus-summary-goto-unread 'never)))
8908 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8909 (gnus-summary-recenter)
8910 (gnus-summary-position-point)
8911 (gnus-set-mode-line 'summary)
8914 (defun gnus-summary-mark-article-as-read (mark)
8915 "Mark the current article quickly as read with MARK."
8916 (let ((article (gnus-summary-article-number)))
8917 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8918 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8919 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8920 (push (cons article mark) gnus-newsgroup-reads)
8921 ;; Possibly remove from cache, if that is used.
8922 (when gnus-use-cache
8923 (gnus-cache-enter-remove-article article))
8924 ;; Allow the backend to change the mark.
8925 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8926 ;; Check for auto-expiry.
8927 (when (and gnus-newsgroup-auto-expire
8928 (memq mark gnus-auto-expirable-marks))
8929 (setq mark gnus-expirable-mark)
8930 ;; Let the backend know about the mark change.
8931 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8932 (push article gnus-newsgroup-expirable))
8933 ;; Set the mark in the buffer.
8934 (gnus-summary-update-mark mark 'unread)
8937 (defun gnus-summary-mark-article-as-unread (mark)
8938 "Mark the current article quickly as unread with MARK."
8939 (let* ((article (gnus-summary-article-number))
8940 (old-mark (gnus-summary-article-mark article)))
8941 ;; Allow the backend to change the mark.
8942 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8943 (if (eq mark old-mark)
8947 (gnus-error 1 "Can't mark negative article numbers")
8949 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8950 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8951 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8952 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8953 (cond ((= mark gnus-ticked-mark)
8954 (push article gnus-newsgroup-marked))
8955 ((= mark gnus-dormant-mark)
8956 (push article gnus-newsgroup-dormant))
8958 (push article gnus-newsgroup-unreads)))
8959 (gnus-pull article gnus-newsgroup-reads)
8961 ;; See whether the article is to be put in the cache.
8963 (vectorp (gnus-summary-article-header article))
8965 (gnus-cache-possibly-enter-article
8966 gnus-newsgroup-name article
8967 (= mark gnus-ticked-mark)
8968 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8971 (gnus-summary-update-mark mark 'unread)
8974 (defun gnus-summary-mark-article (&optional article mark no-expire)
8975 "Mark ARTICLE with MARK. MARK can be any character.
8976 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8977 `??' (dormant) and `?E' (expirable).
8978 If MARK is nil, then the default character `?r' is used.
8979 If ARTICLE is nil, then the article on the current line will be
8981 Iff NO-EXPIRE, auto-expiry will be inhibited."
8982 ;; The mark might be a string.
8983 (when (stringp mark)
8984 (setq mark (aref mark 0)))
8985 ;; If no mark is given, then we check auto-expiring.
8987 (setq mark gnus-del-mark))
8988 (when (and (not no-expire)
8989 gnus-newsgroup-auto-expire
8990 (memq mark gnus-auto-expirable-marks))
8991 (setq mark gnus-expirable-mark))
8992 (let ((article (or article (gnus-summary-article-number)))
8993 (old-mark (gnus-summary-article-mark article)))
8994 ;; Allow the backend to change the mark.
8995 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8996 (if (eq mark old-mark)
8999 (error "No article on current line"))
9000 (if (not (if (or (= mark gnus-unread-mark)
9001 (= mark gnus-ticked-mark)
9002 (= mark gnus-dormant-mark))
9003 (gnus-mark-article-as-unread article mark)
9004 (gnus-mark-article-as-read article mark)))
9006 ;; See whether the article is to be put in the cache.
9008 (not (= mark gnus-canceled-mark))
9009 (vectorp (gnus-summary-article-header article))
9011 (gnus-cache-possibly-enter-article
9012 gnus-newsgroup-name article
9013 (= mark gnus-ticked-mark)
9014 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9016 (when (gnus-summary-goto-subject article nil t)
9017 (let ((buffer-read-only nil))
9018 (gnus-summary-show-thread)
9020 (gnus-summary-update-mark mark 'unread)
9023 (defun gnus-summary-update-secondary-mark (article)
9024 "Update the secondary (read, process, cache) mark."
9025 (gnus-summary-update-mark
9026 (cond ((memq article gnus-newsgroup-processable)
9028 ((memq article gnus-newsgroup-cached)
9030 ((memq article gnus-newsgroup-replied)
9032 ((memq article gnus-newsgroup-forwarded)
9033 gnus-forwarded-mark)
9034 ((memq article gnus-newsgroup-saved)
9036 ((memq article gnus-newsgroup-recent)
9038 ((memq article gnus-newsgroup-unseen)
9042 (when (gnus-visual-p 'summary-highlight 'highlight)
9043 (gnus-run-hooks 'gnus-summary-update-hook))
9046 (defun gnus-summary-update-mark (mark type)
9047 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9048 (buffer-read-only nil))
9049 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9051 (when (looking-at "\r")
9053 (when (<= (+ forward (point)) (point-max))
9054 ;; Go to the right position on the line.
9055 (goto-char (+ forward (point)))
9056 ;; Replace the old mark with the new mark.
9057 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9058 ;; Optionally update the marks by some user rule.
9059 (when (eq type 'unread)
9061 (gnus-data-find (gnus-summary-article-number)) mark)
9062 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9064 (defun gnus-mark-article-as-read (article &optional mark)
9065 "Enter ARTICLE in the pertinent lists and remove it from others."
9066 ;; Make the article expirable.
9067 (let ((mark (or mark gnus-del-mark)))
9068 (if (= mark gnus-expirable-mark)
9069 (push article gnus-newsgroup-expirable)
9070 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9071 ;; Remove from unread and marked lists.
9072 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9073 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9074 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9075 (push (cons article mark) gnus-newsgroup-reads)
9076 ;; Possibly remove from cache, if that is used.
9077 (when gnus-use-cache
9078 (gnus-cache-enter-remove-article article))
9081 (defun gnus-mark-article-as-unread (article &optional mark)
9082 "Enter ARTICLE in the pertinent lists and remove it from others."
9083 (let ((mark (or mark gnus-ticked-mark)))
9086 (gnus-error 1 "Can't mark negative article numbers")
9088 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9089 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9090 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9091 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9093 ;; Unsuppress duplicates?
9094 (when gnus-suppress-duplicates
9095 (gnus-dup-unsuppress-article article))
9097 (cond ((= mark gnus-ticked-mark)
9098 (push article gnus-newsgroup-marked))
9099 ((= mark gnus-dormant-mark)
9100 (push article gnus-newsgroup-dormant))
9102 (push article gnus-newsgroup-unreads)))
9103 (gnus-pull article gnus-newsgroup-reads)
9106 (defalias 'gnus-summary-mark-as-unread-forward
9107 'gnus-summary-tick-article-forward)
9108 (make-obsolete 'gnus-summary-mark-as-unread-forward
9109 'gnus-summary-tick-article-forward)
9110 (defun gnus-summary-tick-article-forward (n)
9111 "Tick N articles forwards.
9112 If N is negative, tick backwards instead.
9113 The difference between N and the number of articles ticked is returned."
9115 (gnus-summary-mark-forward n gnus-ticked-mark))
9117 (defalias 'gnus-summary-mark-as-unread-backward
9118 'gnus-summary-tick-article-backward)
9119 (make-obsolete 'gnus-summary-mark-as-unread-backward
9120 'gnus-summary-tick-article-backward)
9121 (defun gnus-summary-tick-article-backward (n)
9122 "Tick N articles backwards.
9123 The difference between N and the number of articles ticked is returned."
9125 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9127 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9128 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9129 (defun gnus-summary-tick-article (&optional article clear-mark)
9130 "Mark current article as unread.
9131 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9132 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9134 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9137 (defun gnus-summary-mark-as-read-forward (n)
9138 "Mark N articles as read forwards.
9139 If N is negative, mark backwards instead.
9140 The difference between N and the actual number of articles marked is
9143 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9145 (defun gnus-summary-mark-as-read-backward (n)
9146 "Mark the N articles as read backwards.
9147 The difference between N and the actual number of articles marked is
9150 (gnus-summary-mark-forward
9151 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9153 (defun gnus-summary-mark-as-read (&optional article mark)
9154 "Mark current article as read.
9155 ARTICLE specifies the article to be marked as read.
9156 MARK specifies a string to be inserted at the beginning of the line."
9157 (gnus-summary-mark-article article mark))
9159 (defun gnus-summary-clear-mark-forward (n)
9160 "Clear marks from N articles forward.
9161 If N is negative, clear backward instead.
9162 The difference between N and the number of marks cleared is returned."
9164 (gnus-summary-mark-forward n gnus-unread-mark))
9166 (defun gnus-summary-clear-mark-backward (n)
9167 "Clear marks from N articles backward.
9168 The difference between N and the number of marks cleared is returned."
9170 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9172 (defun gnus-summary-mark-unread-as-read ()
9173 "Intended to be used by `gnus-summary-mark-article-hook'."
9174 (when (memq gnus-current-article gnus-newsgroup-unreads)
9175 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9177 (defun gnus-summary-mark-read-and-unread-as-read ()
9178 "Intended to be used by `gnus-summary-mark-article-hook'."
9179 (let ((mark (gnus-summary-article-mark)))
9180 (when (or (gnus-unread-mark-p mark)
9181 (gnus-read-mark-p mark))
9182 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9184 (defun gnus-summary-mark-unread-as-ticked ()
9185 "Intended to be used by `gnus-summary-mark-article-hook'."
9186 (when (memq gnus-current-article gnus-newsgroup-unreads)
9187 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9189 (defun gnus-summary-mark-region-as-read (point mark all)
9190 "Mark all unread articles between point and mark as read.
9191 If given a prefix, mark all articles between point and mark as read,
9192 even ticked and dormant ones."
9193 (interactive "r\nP")
9202 (memq (setq article (gnus-summary-article-number))
9203 gnus-newsgroup-unreads))
9204 (gnus-summary-mark-article article gnus-del-mark))
9206 (gnus-summary-find-next))))))
9208 (defun gnus-summary-mark-below (score mark)
9209 "Mark articles with score less than SCORE with MARK."
9210 (interactive "P\ncMark: ")
9211 (setq score (if score
9212 (prefix-numeric-value score)
9213 (or gnus-summary-default-score 0)))
9215 (set-buffer gnus-summary-buffer)
9216 (goto-char (point-min))
9219 (and (< (gnus-summary-article-score) score)
9220 (gnus-summary-mark-article nil mark))
9221 (gnus-summary-find-next)))))
9223 (defun gnus-summary-kill-below (&optional score)
9224 "Mark articles with score below SCORE as read."
9226 (gnus-summary-mark-below score gnus-killed-mark))
9228 (defun gnus-summary-clear-above (&optional score)
9229 "Clear all marks from articles with score above SCORE."
9231 (gnus-summary-mark-above score gnus-unread-mark))
9233 (defun gnus-summary-tick-above (&optional score)
9234 "Tick all articles with score above SCORE."
9236 (gnus-summary-mark-above score gnus-ticked-mark))
9238 (defun gnus-summary-mark-above (score mark)
9239 "Mark articles with score over SCORE with MARK."
9240 (interactive "P\ncMark: ")
9241 (setq score (if score
9242 (prefix-numeric-value score)
9243 (or gnus-summary-default-score 0)))
9245 (set-buffer gnus-summary-buffer)
9246 (goto-char (point-min))
9248 (when (> (gnus-summary-article-score) score)
9249 (gnus-summary-mark-article nil mark))
9251 (gnus-summary-find-next)))))
9253 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9254 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9255 (defun gnus-summary-limit-include-expunged (&optional no-error)
9256 "Display all the hidden articles that were expunged for low scores."
9258 (let ((buffer-read-only nil))
9259 (let ((scored gnus-newsgroup-scored)
9262 (unless (gnus-summary-article-header (caar scored))
9263 (and (setq h (gnus-number-to-header (caar scored)))
9264 (< (cdar scored) gnus-summary-expunge-below)
9266 (setq scored (cdr scored)))
9268 (when (not no-error)
9269 (error "No expunged articles hidden"))
9270 (goto-char (point-min))
9271 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9272 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9273 (mapcar (lambda (x) (push (mail-header-number x)
9274 gnus-newsgroup-limit))
9276 (gnus-summary-prepare-unthreaded (nreverse headers))
9277 (goto-char (point-min))
9278 (gnus-summary-position-point)
9281 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9282 "Mark all unread articles in this newsgroup as read.
9283 If prefix argument ALL is non-nil, ticked and dormant articles will
9284 also be marked as read.
9285 If QUIETLY is non-nil, no questions will be asked.
9286 If TO-HERE is non-nil, it should be a point in the buffer. All
9287 articles before (after, if REVERSE is set) this point will be marked as read.
9288 Note that this function will only catch up the unread article
9289 in the current summary buffer limitation.
9290 The number of articles marked as read is returned."
9295 (not gnus-interactive-catchup) ;Without confirmation?
9299 "Mark absolutely all articles as read? "
9300 "Mark all unread articles as read? ")))
9302 (not gnus-newsgroup-adaptive)
9303 (not gnus-newsgroup-auto-expire)
9304 (not gnus-suppress-duplicates)
9305 (or (not gnus-use-cache)
9306 (eq gnus-use-cache 'passive)))
9309 (setq gnus-newsgroup-marked nil
9310 gnus-newsgroup-dormant nil))
9311 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9312 ;; We actually mark all articles as canceled, which we
9313 ;; have to do when using auto-expiry or adaptive scoring.
9314 (gnus-summary-show-all-threads)
9315 (if (and to-here reverse)
9319 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9320 (gnus-summary-find-next (not all) nil nil t))))
9321 (when (gnus-summary-first-subject (not all) t)
9323 (if to-here (< (point) to-here) t)
9324 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9325 (gnus-summary-find-next (not all) nil nil t)))))
9326 (gnus-set-mode-line 'summary))
9328 (gnus-summary-position-point)))
9330 (defun gnus-summary-catchup-to-here (&optional all)
9331 "Mark all unticked articles before the current one as read.
9332 If ALL is non-nil, also mark ticked and dormant articles as read."
9335 (gnus-save-hidden-threads
9336 (let ((beg (point)))
9337 ;; We check that there are unread articles.
9338 (when (or all (gnus-summary-find-prev))
9339 (gnus-summary-catchup all t beg)))))
9340 (gnus-summary-position-point))
9342 (defun gnus-summary-catchup-from-here (&optional all)
9343 "Mark all unticked articles after the current one as read.
9344 If ALL is non-nil, also mark ticked and dormant articles as read."
9347 (gnus-save-hidden-threads
9348 (let ((beg (point)))
9349 ;; We check that there are unread articles.
9350 (when (or all (gnus-summary-find-next))
9351 (gnus-summary-catchup all t beg nil t)))))
9353 (gnus-summary-position-point))
9354 (defun gnus-summary-catchup-all (&optional quietly)
9355 "Mark all articles in this newsgroup as read."
9357 (gnus-summary-catchup t quietly))
9359 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9360 "Mark all unread articles in this group as read, then exit.
9361 If prefix argument ALL is non-nil, all articles are marked as read.
9362 If QUIETLY is non-nil, no questions will be asked."
9364 (when (gnus-summary-catchup all quietly nil 'fast)
9365 ;; Select next newsgroup or exit.
9366 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9367 (eq gnus-auto-select-next 'quietly))
9368 (gnus-summary-next-group nil)
9369 (gnus-summary-exit))))
9371 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9372 "Mark all articles in this newsgroup as read, and then exit."
9374 (gnus-summary-catchup-and-exit t quietly))
9376 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9377 "Mark all articles in this group as read and select the next group.
9378 If given a prefix, mark all articles, unread as well as ticked, as
9382 (gnus-summary-catchup all))
9383 (gnus-summary-next-group))
9389 (defmacro gnus-with-article (article &rest forms)
9390 "Select ARTICLE and perform FORMS in the original article buffer.
9391 Then replace the article with the result."
9393 ;; We don't want the article to be marked as read.
9394 (let (gnus-mark-article-hook)
9395 (gnus-summary-select-article t t nil ,article))
9396 (set-buffer gnus-original-article-buffer)
9398 (if (not (gnus-check-backend-function
9399 'request-replace-article (car gnus-article-current)))
9400 (gnus-message 5 "Read-only group; not replacing")
9401 (unless (gnus-request-replace-article
9402 ,article (car gnus-article-current)
9404 (error "Couldn't replace article")))
9405 ;; The cache and backlog have to be flushed somewhat.
9406 (when gnus-keep-backlog
9407 (gnus-backlog-remove-article
9408 (car gnus-article-current) (cdr gnus-article-current)))
9409 (when gnus-use-cache
9410 (gnus-cache-update-article
9411 (car gnus-article-current) (cdr gnus-article-current)))))
9413 (put 'gnus-with-article 'lisp-indent-function 1)
9414 (put 'gnus-with-article 'edebug-form-spec '(form body))
9416 ;; Thread-based commands.
9418 (defun gnus-summary-articles-in-thread (&optional article)
9419 "Return a list of all articles in the current thread.
9420 If ARTICLE is non-nil, return all articles in the thread that starts
9422 (let* ((article (or article (gnus-summary-article-number)))
9423 (data (gnus-data-find-list article))
9424 (top-level (gnus-data-level (car data)))
9426 (cond ((null gnus-thread-operation-ignore-subject)
9427 (gnus-simplify-subject-re
9428 (mail-header-subject (gnus-data-header (car data)))))
9429 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9430 (gnus-simplify-subject-fuzzy
9431 (mail-header-subject (gnus-data-header (car data)))))
9433 (end-point (save-excursion
9434 (if (gnus-summary-go-to-next-thread)
9435 (point) (point-max))))
9438 (< (gnus-data-pos (car data)) end-point))
9439 (when (or (not top-subject)
9440 (string= top-subject
9441 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9442 (gnus-simplify-subject-fuzzy
9443 (mail-header-subject
9444 (gnus-data-header (car data))))
9445 (gnus-simplify-subject-re
9446 (mail-header-subject
9447 (gnus-data-header (car data)))))))
9448 (push (gnus-data-number (car data)) articles))
9449 (unless (and (setq data (cdr data))
9450 (> (gnus-data-level (car data)) top-level))
9452 ;; Return the list of articles.
9453 (nreverse articles)))
9455 (defun gnus-summary-rethread-current ()
9456 "Rethread the thread the current article is part of."
9458 (let* ((gnus-show-threads t)
9459 (article (gnus-summary-article-number))
9460 (id (mail-header-id (gnus-summary-article-header)))
9461 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9463 (error "No article on the current line"))
9464 (gnus-rebuild-thread id)
9465 (gnus-summary-goto-subject article)))
9467 (defun gnus-summary-reparent-thread ()
9468 "Make the current article child of the marked (or previous) article.
9470 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9471 is non-nil or the Subject: of both articles are the same."
9473 (unless (not (gnus-group-read-only-p))
9474 (error "The current newsgroup does not support article editing"))
9475 (unless (<= (length gnus-newsgroup-processable) 1)
9476 (error "No more than one article may be marked"))
9477 (save-window-excursion
9478 (let ((gnus-article-buffer " *reparent*")
9479 (current-article (gnus-summary-article-number))
9480 ;; First grab the marked article, otherwise one line up.
9481 (parent-article (if (not (null gnus-newsgroup-processable))
9482 (car gnus-newsgroup-processable)
9484 (if (eq (forward-line -1) 0)
9485 (gnus-summary-article-number)
9486 (error "Beginning of summary buffer"))))))
9487 (unless (not (eq current-article parent-article))
9488 (error "An article may not be self-referential"))
9489 (let ((message-id (mail-header-id
9490 (gnus-summary-article-header parent-article))))
9491 (unless (and message-id (not (equal message-id "")))
9492 (error "No message-id in desired parent"))
9493 (gnus-with-article current-article
9495 (goto-char (point-min))
9496 (message-narrow-to-head)
9497 (if (re-search-forward "^References: " nil t)
9499 (re-search-forward "^[^ \t]" nil t)
9502 (insert " " message-id))
9503 (insert "References: " message-id "\n"))))
9504 (set-buffer gnus-summary-buffer)
9505 (gnus-summary-unmark-all-processable)
9506 (gnus-summary-update-article current-article)
9507 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9508 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9509 (gnus-summary-rethread-current)
9510 (gnus-message 3 "Article %d is now the child of article %d"
9511 current-article parent-article)))))
9513 (defun gnus-summary-toggle-threads (&optional arg)
9514 "Toggle showing conversation threads.
9515 If ARG is positive number, turn showing conversation threads on."
9517 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9518 (setq gnus-show-threads
9519 (if (null arg) (not gnus-show-threads)
9520 (> (prefix-numeric-value arg) 0)))
9521 (gnus-summary-prepare)
9522 (gnus-summary-goto-subject current)
9523 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9524 (gnus-summary-position-point)))
9526 (defun gnus-summary-show-all-threads ()
9530 (let ((buffer-read-only nil))
9531 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9532 (gnus-summary-position-point))
9534 (defun gnus-summary-show-thread ()
9535 "Show thread subtrees.
9536 Returns nil if no thread was there to be shown."
9538 (let ((buffer-read-only nil)
9540 ;; first goto end then to beg, to have point at beg after let
9541 (end (progn (end-of-line) (point)))
9542 (beg (progn (beginning-of-line) (point))))
9544 ;; Any hidden lines here?
9545 (search-forward "\r" end t)
9546 (subst-char-in-region beg end ?\^M ?\n t)
9548 (gnus-summary-position-point))))
9550 (defun gnus-summary-hide-all-threads ()
9551 "Hide all thread subtrees."
9554 (goto-char (point-min))
9555 (gnus-summary-hide-thread)
9556 (while (zerop (gnus-summary-next-thread 1 t))
9557 (gnus-summary-hide-thread)))
9558 (gnus-summary-position-point))
9560 (defun gnus-summary-hide-thread ()
9561 "Hide thread subtrees.
9562 Returns nil if no threads were there to be hidden."
9564 (let ((buffer-read-only nil)
9566 (article (gnus-summary-article-number)))
9568 ;; Go forward until either the buffer ends or the subthread
9570 (when (and (not (eobp))
9571 (or (zerop (gnus-summary-next-thread 1 t))
9572 (goto-char (point-max))))
9574 (if (and (> (point) start)
9575 (search-backward "\n" start t))
9577 (subst-char-in-region start (point) ?\n ?\^M)
9578 (gnus-summary-goto-subject article))
9582 (defun gnus-summary-go-to-next-thread (&optional previous)
9583 "Go to the same level (or less) next thread.
9584 If PREVIOUS is non-nil, go to previous thread instead.
9585 Return the article number moved to, or nil if moving was impossible."
9586 (let ((level (gnus-summary-thread-level))
9587 (way (if previous -1 1))
9590 (while (and (not (eobp))
9591 (< level (gnus-summary-thread-level)))
9599 (gnus-summary-article-number)
9602 (defun gnus-summary-next-thread (n &optional silent)
9603 "Go to the same level next N'th thread.
9604 If N is negative, search backward instead.
9605 Returns the difference between N and the number of skips actually
9608 If SILENT, don't output messages."
9610 (let ((backward (< n 0))
9613 (gnus-summary-go-to-next-thread backward))
9616 (gnus-summary-position-point))
9617 (when (and (not silent) (/= 0 n))
9618 (gnus-message 7 "No more threads"))
9621 (defun gnus-summary-prev-thread (n)
9622 "Go to the same level previous N'th thread.
9623 Returns the difference between N and the number of skips actually
9626 (gnus-summary-next-thread (- n)))
9628 (defun gnus-summary-go-down-thread ()
9629 "Go down one level in the current thread."
9630 (let ((children (gnus-summary-article-children)))
9632 (gnus-summary-goto-subject (car children)))))
9634 (defun gnus-summary-go-up-thread ()
9635 "Go up one level in the current thread."
9636 (let ((parent (gnus-summary-article-parent)))
9638 (gnus-summary-goto-subject parent))))
9640 (defun gnus-summary-down-thread (n)
9641 "Go down thread N steps.
9642 If N is negative, go up instead.
9643 Returns the difference between N and how many steps down that were
9649 (if up (gnus-summary-go-up-thread)
9650 (gnus-summary-go-down-thread)))
9652 (gnus-summary-position-point)
9654 (gnus-message 7 "Can't go further"))
9657 (defun gnus-summary-up-thread (n)
9658 "Go up thread N steps.
9659 If N is negative, go down instead.
9660 Returns the difference between N and how many steps down that were
9663 (gnus-summary-down-thread (- n)))
9665 (defun gnus-summary-top-thread ()
9666 "Go to the top of the thread."
9668 (while (gnus-summary-go-up-thread))
9669 (gnus-summary-article-number))
9671 (defun gnus-summary-kill-thread (&optional unmark)
9672 "Mark articles under current thread as read.
9673 If the prefix argument is positive, remove any kinds of marks.
9674 If the prefix argument is negative, tick articles instead."
9677 (setq unmark (prefix-numeric-value unmark)))
9678 (let ((articles (gnus-summary-articles-in-thread)))
9680 ;; Expand the thread.
9681 (gnus-summary-show-thread)
9682 ;; Mark all the articles.
9684 (gnus-summary-goto-subject (car articles))
9685 (cond ((null unmark)
9686 (gnus-summary-mark-article-as-read gnus-killed-mark))
9688 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9690 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9691 (setq articles (cdr articles))))
9692 ;; Hide killed subtrees.
9694 gnus-thread-hide-killed
9695 (gnus-summary-hide-thread))
9696 ;; If marked as read, go to next unread subject.
9698 ;; Go to next unread subject.
9699 (gnus-summary-next-subject 1 t)))
9700 (gnus-set-mode-line 'summary))
9702 ;; Summary sorting commands
9704 (defun gnus-summary-sort-by-number (&optional reverse)
9705 "Sort the summary buffer by article number.
9706 Argument REVERSE means reverse order."
9708 (gnus-summary-sort 'number reverse))
9710 (defun gnus-summary-sort-by-author (&optional reverse)
9711 "Sort the summary buffer by author name alphabetically.
9712 If `case-fold-search' is non-nil, case of letters is ignored.
9713 Argument REVERSE means reverse order."
9715 (gnus-summary-sort 'author reverse))
9717 (defun gnus-summary-sort-by-subject (&optional reverse)
9718 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9719 If `case-fold-search' is non-nil, case of letters is ignored.
9720 Argument REVERSE means reverse order."
9722 (gnus-summary-sort 'subject reverse))
9724 (defun gnus-summary-sort-by-date (&optional reverse)
9725 "Sort the summary buffer by date.
9726 Argument REVERSE means reverse order."
9728 (gnus-summary-sort 'date reverse))
9730 (defun gnus-summary-sort-by-score (&optional reverse)
9731 "Sort the summary buffer by score.
9732 Argument REVERSE means reverse order."
9734 (gnus-summary-sort 'score reverse))
9736 (defun gnus-summary-sort-by-lines (&optional reverse)
9737 "Sort the summary buffer by the number of lines.
9738 Argument REVERSE means reverse order."
9740 (gnus-summary-sort 'lines reverse))
9742 (defun gnus-summary-sort-by-chars (&optional reverse)
9743 "Sort the summary buffer by article length.
9744 Argument REVERSE means reverse order."
9746 (gnus-summary-sort 'chars reverse))
9748 (defun gnus-summary-sort-by-original (&optional reverse)
9749 "Sort the summary buffer using the default sorting method.
9750 Argument REVERSE means reverse order."
9752 (let* ((buffer-read-only)
9753 (gnus-summary-prepare-hook nil))
9754 ;; We do the sorting by regenerating the threads.
9755 (gnus-summary-prepare)
9756 ;; Hide subthreads if needed.
9757 (when (and gnus-show-threads gnus-thread-hide-subtree)
9758 (gnus-summary-hide-all-threads))))
9760 (defun gnus-summary-sort (predicate reverse)
9761 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9762 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9763 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9764 (gnus-thread-sort-functions
9769 (gnus-sort-gathered-threads-function
9770 gnus-thread-sort-functions)
9771 (gnus-article-sort-functions
9777 (gnus-summary-prepare-hook nil))
9778 ;; We do the sorting by regenerating the threads.
9779 (gnus-summary-prepare)
9780 ;; Hide subthreads if needed.
9781 (when (and gnus-show-threads gnus-thread-hide-subtree)
9782 (gnus-summary-hide-all-threads))))
9784 ;; Summary saving commands.
9786 (defun gnus-summary-save-article (&optional n not-saved)
9787 "Save the current article using the default saver function.
9788 If N is a positive number, save the N next articles.
9789 If N is a negative number, save the N previous articles.
9790 If N is nil and any articles have been marked with the process mark,
9791 save those articles instead.
9792 The variable `gnus-default-article-saver' specifies the saver function."
9794 (let* ((articles (gnus-summary-work-articles n))
9795 (save-buffer (save-excursion
9796 (nnheader-set-temp-buffer " *Gnus Save*")))
9797 (num (length articles))
9799 (dolist (article articles)
9800 (setq header (gnus-summary-article-header article))
9801 (if (not (vectorp header))
9802 ;; This is a pseudo-article.
9803 (if (assq 'name header)
9804 (gnus-copy-file (cdr (assq 'name header)))
9805 (gnus-message 1 "Article %d is unsaveable" article))
9806 ;; This is a real article.
9807 (save-window-excursion
9808 (gnus-summary-select-article t nil nil article))
9810 (set-buffer save-buffer)
9812 (insert-buffer-substring gnus-original-article-buffer))
9813 (setq file (gnus-article-save save-buffer file num))
9814 (gnus-summary-remove-process-mark article)
9816 (gnus-summary-set-saved-mark article))))
9817 (gnus-kill-buffer save-buffer)
9818 (gnus-summary-position-point)
9819 (gnus-set-mode-line 'summary)
9822 (defun gnus-summary-pipe-output (&optional arg)
9823 "Pipe the current article to a subprocess.
9824 If N is a positive number, pipe the N next articles.
9825 If N is a negative number, pipe the N previous articles.
9826 If N is nil and any articles have been marked with the process mark,
9827 pipe those articles instead."
9830 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9831 (gnus-summary-save-article arg t))
9832 (let ((buffer (get-buffer "*Shell Command Output*")))
9834 (with-current-buffer buffer (> (point-max) (point-min))))
9835 (gnus-configure-windows 'pipe))))
9837 (defun gnus-summary-save-article-mail (&optional arg)
9838 "Append the current article to an mail file.
9839 If N is a positive number, save the N next articles.
9840 If N is a negative number, save the N previous articles.
9841 If N is nil and any articles have been marked with the process mark,
9842 save those articles instead."
9845 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9846 (gnus-summary-save-article arg)))
9848 (defun gnus-summary-save-article-rmail (&optional arg)
9849 "Append the current article to an rmail file.
9850 If N is a positive number, save the N next articles.
9851 If N is a negative number, save the N previous articles.
9852 If N is nil and any articles have been marked with the process mark,
9853 save those articles instead."
9856 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9857 (gnus-summary-save-article arg)))
9859 (defun gnus-summary-save-article-file (&optional arg)
9860 "Append the current article to a file.
9861 If N is a positive number, save the N next articles.
9862 If N is a negative number, save the N previous articles.
9863 If N is nil and any articles have been marked with the process mark,
9864 save those articles instead."
9867 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9868 (gnus-summary-save-article arg)))
9870 (defun gnus-summary-write-article-file (&optional arg)
9871 "Write the current article to a file, deleting the previous file.
9872 If N is a positive number, save the N next articles.
9873 If N is a negative number, save the N previous articles.
9874 If N is nil and any articles have been marked with the process mark,
9875 save those articles instead."
9878 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9879 (gnus-summary-save-article arg)))
9881 (defun gnus-summary-save-article-body-file (&optional arg)
9882 "Append the current article body to a file.
9883 If N is a positive number, save the N next articles.
9884 If N is a negative number, save the N previous articles.
9885 If N is nil and any articles have been marked with the process mark,
9886 save those articles instead."
9889 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9890 (gnus-summary-save-article arg)))
9892 (defun gnus-summary-pipe-message (program)
9893 "Pipe the current article through PROGRAM."
9894 (interactive "sProgram: ")
9895 (gnus-summary-select-article)
9896 (let ((mail-header-separator ""))
9897 (gnus-eval-in-buffer-window gnus-article-buffer
9900 (let ((start (window-start))
9902 (message-pipe-buffer-body program)
9903 (set-window-start (get-buffer-window (current-buffer)) start))))))
9905 (defun gnus-get-split-value (methods)
9906 "Return a value based on the split METHODS."
9907 (let (split-name method result match)
9910 (set-buffer gnus-original-article-buffer)
9912 (nnheader-narrow-to-headers)
9913 (while (and methods (not split-name))
9914 (goto-char (point-min))
9915 (setq method (pop methods))
9916 (setq match (car method))
9919 ;; Regular expression.
9921 (re-search-forward match nil t)))
9922 ((gnus-functionp match)
9926 (setq result (funcall match gnus-newsgroup-name))))
9931 (setq result (eval match)))))
9932 (setq split-name (cdr method))
9933 (cond ((stringp result)
9934 (push (expand-file-name
9935 result gnus-article-save-directory)
9938 (setq split-name (append result split-name)))))))))
9939 (nreverse split-name)))
9941 (defun gnus-valid-move-group-p (group)
9944 (symbol-value group)
9945 (gnus-get-function (gnus-find-method-for-group
9946 (symbol-name group)) 'request-accept-article t)))
9948 (defun gnus-read-move-group-name (prompt default articles prefix)
9949 "Read a group name."
9950 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9951 (minibuffer-confirm-incomplete nil) ; XEmacs
9955 (if (> (length articles) 1)
9956 (format "these %d articles" (length articles))
9961 (gnus-completing-read default prom
9963 'gnus-valid-move-group-p
9965 'gnus-group-history))
9966 ((= 1 (length split-name))
9967 (gnus-completing-read (car split-name) prom
9969 'gnus-valid-move-group-p
9971 'gnus-group-history))
9973 (gnus-completing-read nil prom
9974 (mapcar (lambda (el) (list el))
9975 (nreverse split-name))
9977 'gnus-group-history))))
9978 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9980 (if (or (string= to-newsgroup "")
9981 (string= to-newsgroup prefix))
9982 (setq to-newsgroup default))
9983 (unless to-newsgroup
9984 (error "No group name entered"))
9985 (or (gnus-active to-newsgroup)
9986 (gnus-activate-group to-newsgroup nil nil to-method)
9987 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9989 (or (and (gnus-request-create-group to-newsgroup to-method)
9990 (gnus-activate-group
9991 to-newsgroup nil nil to-method)
9992 (gnus-subscribe-group to-newsgroup))
9993 (error "Couldn't create group %s" to-newsgroup)))
9994 (error "No such group: %s" to-newsgroup)))
9997 (defun gnus-summary-save-parts (type dir n &optional reverse)
9998 "Save parts matching TYPE to DIR.
9999 If REVERSE, save parts that do not match TYPE."
10001 (list (read-string "Save parts of type: "
10002 (or (car gnus-summary-save-parts-type-history)
10003 gnus-summary-save-parts-default-mime)
10004 'gnus-summary-save-parts-type-history)
10005 (setq gnus-summary-save-parts-last-directory
10006 (read-file-name "Save to directory: "
10007 gnus-summary-save-parts-last-directory
10009 current-prefix-arg))
10010 (gnus-summary-iterate n
10011 (let ((gnus-display-mime-function nil)
10012 (gnus-inhibit-treatment t))
10013 (gnus-summary-select-article))
10015 (set-buffer gnus-article-buffer)
10016 (let ((handles (or gnus-article-mime-handles
10017 (mm-dissect-buffer) (mm-uu-dissect))))
10019 (gnus-summary-save-parts-1 type dir handles reverse)
10020 (unless gnus-article-mime-handles ;; Don't destroy this case.
10021 (mm-destroy-parts handles)))))))
10023 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10024 (if (stringp (car handle))
10025 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10028 (not (string-match type (mm-handle-media-type handle)))
10029 (string-match type (mm-handle-media-type handle)))
10030 (let ((file (expand-file-name
10031 (file-name-nondirectory
10033 (mail-content-type-get
10034 (mm-handle-disposition handle) 'filename)
10035 (concat gnus-newsgroup-name
10036 "." (number-to-string
10037 (cdr gnus-article-current)))))
10039 (unless (file-exists-p file)
10040 (mm-save-part-to-file handle file))))))
10042 ;; Summary extract commands
10044 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10045 (let ((buffer-read-only nil)
10046 (article (gnus-summary-article-number))
10048 (unless (gnus-summary-goto-subject article)
10049 (error "No such article: %d" article))
10050 (gnus-summary-position-point)
10051 ;; If all commands are to be bunched up on one line, we collect
10053 (unless gnus-view-pseudos-separately
10054 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10057 (setq action (cdr (assq 'action (car ps))))
10058 (setq files (list (cdr (assq 'name (car ps)))))
10059 (while (and ps (cdr ps)
10060 (string= (or action "1")
10061 (or (cdr (assq 'action (cadr ps))) "2")))
10062 (push (cdr (assq 'name (cadr ps))) files)
10063 (setcdr ps (cddr ps)))
10065 (when (not (string-match "%s" action))
10068 (when (assq 'execute (car ps))
10069 (setcdr (assq 'execute (car ps))
10070 (funcall (if (string-match "%s" action)
10079 (setq ps (cdr ps)))))
10080 (if (and gnus-view-pseudos (not not-view))
10082 (when (assq 'execute (car pslist))
10083 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10084 (eq gnus-view-pseudos 'not-confirm)))
10085 (setq pslist (cdr pslist)))
10088 (setq after-article (or (cdr (assq 'article (car pslist)))
10089 (gnus-summary-article-number)))
10090 (gnus-summary-goto-subject after-article)
10093 (insert " " (file-name-nondirectory
10094 (cdr (assq 'name (car pslist))))
10095 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10097 (forward-line -1) ; back to `b'
10098 (gnus-add-text-properties
10099 b (1- e) (list 'gnus-number gnus-reffed-article-number
10100 gnus-mouse-face-prop gnus-mouse-face))
10102 after-article gnus-reffed-article-number
10103 gnus-unread-mark b (car pslist) 0 (- e b))
10104 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10105 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10106 (setq pslist (cdr pslist)))))))
10108 (defun gnus-pseudos< (p1 p2)
10109 (let ((c1 (cdr (assq 'action p1)))
10110 (c2 (cdr (assq 'action p2))))
10111 (and c1 c2 (string< c1 c2))))
10113 (defun gnus-request-pseudo-article (props)
10114 (cond ((assq 'execute props)
10115 (gnus-execute-command (cdr (assq 'execute props)))))
10116 (let ((gnus-current-article (gnus-summary-article-number)))
10117 (gnus-run-hooks 'gnus-mark-article-hook)))
10119 (defun gnus-execute-command (command &optional automatic)
10121 (gnus-article-setup-buffer)
10122 (set-buffer gnus-article-buffer)
10123 (setq buffer-read-only nil)
10124 (let ((command (if automatic command
10125 (read-string "Command: " (cons command 0)))))
10127 (insert "$ " command "\n\n")
10128 (if gnus-view-pseudo-asynchronously
10129 (start-process "gnus-execute" (current-buffer) shell-file-name
10130 shell-command-switch command)
10131 (call-process shell-file-name nil t nil
10132 shell-command-switch command)))))
10134 ;; Summary kill commands.
10136 (defun gnus-summary-edit-global-kill (article)
10137 "Edit the \"global\" kill file."
10138 (interactive (list (gnus-summary-article-number)))
10139 (gnus-group-edit-global-kill article))
10141 (defun gnus-summary-edit-local-kill ()
10142 "Edit a local kill file applied to the current newsgroup."
10144 (setq gnus-current-headers (gnus-summary-article-header))
10145 (gnus-group-edit-local-kill
10146 (gnus-summary-article-number) gnus-newsgroup-name))
10148 ;;; Header reading.
10150 (defun gnus-read-header (id &optional header)
10151 "Read the headers of article ID and enter them into the Gnus system."
10152 (let ((group gnus-newsgroup-name)
10153 (gnus-override-method
10155 gnus-override-method
10156 (and (gnus-news-group-p gnus-newsgroup-name)
10157 (car (gnus-refer-article-methods)))))
10159 ;; First we check to see whether the header in question is already
10162 ;; This is a Message-ID.
10163 (setq header (or header (gnus-id-to-header id)))
10164 ;; This is an article number.
10165 (setq header (or header (gnus-summary-article-header id))))
10167 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10168 ;; We have found the header.
10170 ;; If this is a sparse article, we have to nix out its
10171 ;; previous entry in the thread hashtb.
10173 (gnus-summary-article-sparse-p (mail-header-number header)))
10174 (let* ((parent (gnus-parent-id (mail-header-references header)))
10175 (thread (and parent (gnus-id-to-thread parent))))
10177 (delq (assq header thread) thread))))
10178 ;; We have to really fetch the header to this article.
10180 (set-buffer nntp-server-buffer)
10181 (when (setq where (gnus-request-head id group))
10182 (nnheader-fold-continuation-lines)
10183 (goto-char (point-max))
10185 (goto-char (point-min))
10189 ((cdr where) (cdr where))
10190 (header (mail-header-number header))
10191 (t gnus-reffed-article-number))
10193 (insert " Article retrieved.\n"))
10194 (if (or (not where)
10195 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10196 () ; Malformed head.
10197 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10198 (when (and (stringp id)
10199 (not (string= (gnus-group-real-name group)
10201 ;; If we fetched by Message-ID and the article came
10202 ;; from a different group, we fudge some bogus article
10203 ;; numbers for this article.
10204 (mail-header-set-number header gnus-reffed-article-number))
10206 (set-buffer gnus-summary-buffer)
10207 (decf gnus-reffed-article-number)
10208 (gnus-remove-header (mail-header-number header))
10209 (push header gnus-newsgroup-headers)
10210 (setq gnus-current-headers header)
10211 (push (mail-header-number header) gnus-newsgroup-limit)))
10214 (defun gnus-remove-header (number)
10215 "Remove header NUMBER from `gnus-newsgroup-headers'."
10216 (if (and gnus-newsgroup-headers
10217 (= number (mail-header-number (car gnus-newsgroup-headers))))
10218 (pop gnus-newsgroup-headers)
10219 (let ((headers gnus-newsgroup-headers))
10220 (while (and (cdr headers)
10221 (not (= number (mail-header-number (cadr headers)))))
10223 (when (cdr headers)
10224 (setcdr headers (cddr headers))))))
10227 ;;; summary highlights
10230 (defun gnus-highlight-selected-summary ()
10231 "Highlight selected article in summary buffer."
10232 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10233 (when gnus-summary-selected-face
10235 (let* ((beg (progn (beginning-of-line) (point)))
10236 (end (progn (end-of-line) (point)))
10237 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10238 (from (if (get-text-property beg gnus-mouse-face-prop)
10240 (or (next-single-property-change
10241 beg gnus-mouse-face-prop nil end)
10246 (or (next-single-property-change
10247 from gnus-mouse-face-prop nil end)
10249 ;; If no mouse-face prop on line we will have to = from = end,
10250 ;; so we highlight the entire line instead.
10251 (when (= (+ to 2) from)
10254 (if gnus-newsgroup-selected-overlay
10255 ;; Move old overlay.
10257 gnus-newsgroup-selected-overlay from to (current-buffer))
10258 ;; Create new overlay.
10260 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10261 'face gnus-summary-selected-face))))))
10263 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10264 (defun gnus-summary-highlight-line ()
10265 "Highlight current line according to `gnus-summary-highlight'."
10266 (let* ((list gnus-summary-highlight)
10268 (end (progn (end-of-line) (point)))
10269 ;; now find out where the line starts and leave point there.
10270 (beg (progn (beginning-of-line) (point)))
10271 (article (gnus-summary-article-number))
10272 (score (or (cdr (assq (or article gnus-current-article)
10273 gnus-newsgroup-scored))
10274 gnus-summary-default-score 0))
10275 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10276 (inhibit-read-only t))
10277 ;; Eval the cars of the lists until we find a match.
10278 (let ((default gnus-summary-default-score)
10279 (default-high gnus-summary-default-high-score)
10280 (default-low gnus-summary-default-low-score))
10282 (not (eval (caar list))))
10283 (setq list (cdr list))))
10284 (let ((face (cdar list)))
10285 (unless (eq face (get-text-property beg 'face))
10286 (gnus-put-text-property-excluding-characters-with-faces
10288 (setq face (if (boundp face) (symbol-value face) face)))
10289 (when gnus-summary-highlight-line-function
10290 (funcall gnus-summary-highlight-line-function article face))))
10293 (defun gnus-update-read-articles (group unread &optional compute)
10294 "Update the list of read articles in GROUP."
10295 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10296 (entry (gnus-gethash group gnus-newsrc-hashtb))
10297 (info (nth 2 entry))
10299 (unread (sort (copy-sequence unread) '<))
10301 (if (or (not info) (not active))
10302 ;; There is no info on this group if it was, in fact,
10303 ;; killed. Gnus stores no information on killed groups, so
10304 ;; there's nothing to be done.
10305 ;; One could store the information somewhere temporarily,
10306 ;; perhaps... Hmmm...
10308 ;; Remove any negative articles numbers.
10309 (while (and unread (< (car unread) 0))
10310 (setq unread (cdr unread)))
10311 ;; Remove any expired article numbers
10312 (while (and unread (< (car unread) (car active)))
10313 (setq unread (cdr unread)))
10314 ;; Compute the ranges of read articles by looking at the list of
10315 ;; unread articles.
10317 (when (/= (car unread) prev)
10318 (push (if (= prev (1- (car unread))) prev
10319 (cons prev (1- (car unread))))
10321 (setq prev (1+ (car unread)))
10322 (setq unread (cdr unread)))
10323 (when (<= prev (cdr active))
10324 (push (cons prev (cdr active)) read))
10325 (setq read (if (> (length read) 1) (nreverse read) read))
10330 ;; Propagate the read marks to the backend.
10331 (when (gnus-check-backend-function 'request-set-mark group)
10332 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10333 (add (gnus-remove-from-range read (gnus-info-read info))))
10335 (unless (gnus-check-group group)
10336 (error "Can't open server for %s" group))
10337 (gnus-request-set-mark
10338 group (delq nil (list (if add (list add 'add '(read)))
10339 (if del (list del 'del '(read))))))
10341 `(gnus-request-set-mark
10344 (if del (list del 'add '(read)))
10345 (if add (list add 'del '(read))))))))))
10346 (set-buffer gnus-group-buffer)
10347 (gnus-undo-register
10349 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10350 (gnus-info-set-read ',info ',(gnus-info-read info))
10351 (gnus-get-unread-articles-in-group ',info
10352 (gnus-active ,group))
10353 (gnus-group-update-group ,group t)
10355 ;; Enter this list into the group info.
10356 (gnus-info-set-read info read)
10357 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10358 (gnus-get-unread-articles-in-group info (gnus-active group))
10361 (defun gnus-offer-save-summaries ()
10362 "Offer to save all active summary buffers."
10364 ;; Go through all buffers and find all summaries.
10365 (dolist (buffer (buffer-list))
10366 (when (and (setq buffer (buffer-name buffer))
10367 (string-match "Summary" buffer)
10369 (set-buffer buffer)
10370 ;; We check that this is, indeed, a summary buffer.
10371 (and (eq major-mode 'gnus-summary-mode)
10372 ;; Also make sure this isn't bogus.
10373 gnus-newsgroup-prepared
10374 ;; Also make sure that this isn't a
10375 ;; dead summary buffer.
10376 (not gnus-dead-summary-mode))))
10377 (push buffer buffers)))
10378 ;; Go through all these summary buffers and offer to save them.
10382 "Update summary buffer %s? "
10384 (switch-to-buffer buf)
10385 (gnus-summary-exit))
10388 (defun gnus-summary-setup-default-charset ()
10389 "Setup newsgroup default charset."
10390 (if (equal gnus-newsgroup-name "nndraft:drafts")
10391 (setq gnus-newsgroup-charset nil)
10392 (let* ((ignored-charsets
10393 (or gnus-newsgroup-ephemeral-ignored-charsets
10395 (and gnus-newsgroup-name
10396 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10397 gnus-newsgroup-ignored-charsets))))
10398 (setq gnus-newsgroup-charset
10399 (or gnus-newsgroup-ephemeral-charset
10400 (and gnus-newsgroup-name
10401 (gnus-parameter-charset gnus-newsgroup-name))
10402 gnus-default-charset))
10403 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10404 ignored-charsets))))
10410 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10411 "Display the current article buffer fully MIME-buttonized.
10412 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10413 treated as multipart/mixed."
10415 (require 'gnus-art)
10416 (let ((gnus-unbuttonized-mime-types nil)
10417 (gnus-mime-display-multipart-as-mixed show-all-parts))
10418 (gnus-summary-show-article)))
10420 (defun gnus-summary-repair-multipart (article)
10421 "Add a Content-Type header to a multipart article without one."
10422 (interactive (list (gnus-summary-article-number)))
10423 (gnus-with-article article
10424 (message-narrow-to-head)
10425 (message-remove-header "Mime-Version")
10426 (goto-char (point-max))
10427 (insert "Mime-Version: 1.0\n")
10429 (when (search-forward "\n--" nil t)
10430 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10431 (message-narrow-to-head)
10432 (message-remove-header "Content-Type")
10433 (goto-char (point-max))
10434 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10437 (let (gnus-mark-article-hook)
10438 (gnus-summary-select-article t t nil article)))
10440 (defun gnus-summary-toggle-display-buttonized ()
10441 "Toggle the buttonizing of the article buffer."
10443 (require 'gnus-art)
10444 (if (setq gnus-inhibit-mime-unbuttonizing
10445 (not gnus-inhibit-mime-unbuttonizing))
10446 (let ((gnus-unbuttonized-mime-types nil))
10447 (gnus-summary-show-article))
10448 (gnus-summary-show-article)))
10451 ;;; Generic summary marking commands
10454 (defvar gnus-summary-marking-alist
10455 '((read gnus-del-mark "d")
10456 (unread gnus-unread-mark "u")
10457 (ticked gnus-ticked-mark "!")
10458 (dormant gnus-dormant-mark "?")
10459 (expirable gnus-expirable-mark "e"))
10460 "An alist of names/marks/keystrokes.")
10462 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10463 (defvar gnus-summary-mark-map)
10465 (defun gnus-summary-make-all-marking-commands ()
10466 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10467 (dolist (elem gnus-summary-marking-alist)
10468 (apply 'gnus-summary-make-marking-command elem)))
10470 (defun gnus-summary-make-marking-command (name mark keystroke)
10471 (let ((map (make-sparse-keymap)))
10472 (define-key gnus-summary-generic-mark-map keystroke map)
10473 (dolist (lway `((next "next" next nil "n")
10474 (next-unread "next unread" next t "N")
10475 (prev "previous" prev nil "p")
10476 (prev-unread "previous unread" prev t "P")
10477 (nomove "" nil nil ,keystroke)))
10478 (let ((func (gnus-summary-make-marking-command-1
10479 mark (car lway) lway name)))
10480 (setq func (eval func))
10481 (define-key map (nth 4 lway) func)))))
10483 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10485 (format "gnus-summary-put-mark-as-%s%s"
10486 name (if (eq way 'nomove)
10488 (concat "-" (symbol-name way)))))
10491 "Mark the current article as %s%s.
10492 If N, the prefix, then repeat N times.
10493 If N is negative, move in reverse order.
10494 The difference between N and the actual number of articles marked is
10498 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10500 (defun gnus-summary-generic-mark (n mark move unread)
10501 "Mark N articles with MARK."
10502 (unless (eq major-mode 'gnus-summary-mode)
10503 (error "This command can only be used in the summary buffer"))
10504 (gnus-summary-show-thread)
10507 ((eq move 'next) 1)
10508 ((eq move 'prev) -1)
10510 (if (zerop nummove)
10514 nummove (* -1 nummove))))
10515 (while (and (> n 0)
10516 (gnus-summary-mark-article nil mark)
10517 (zerop (gnus-summary-next-subject nummove unread t)))
10520 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10521 (gnus-summary-recenter)
10522 (gnus-summary-position-point)
10523 (gnus-set-mode-line 'summary)
10526 (defun gnus-summary-insert-articles (articles)
10527 (when (setq articles
10528 (gnus-set-difference articles
10529 (mapcar (lambda (h) (mail-header-number h))
10530 gnus-newsgroup-headers)))
10531 (setq gnus-newsgroup-headers
10533 gnus-newsgroup-headers
10534 (gnus-fetch-headers articles)
10535 'gnus-article-sort-by-number))
10536 ;; Suppress duplicates?
10537 (when gnus-suppress-duplicates
10538 (gnus-dup-suppress-articles))
10540 ;; We might want to build some more threads first.
10541 (when (and gnus-fetch-old-headers
10542 (eq gnus-headers-retrieved-by 'nov))
10543 (if (eq gnus-fetch-old-headers 'invisible)
10544 (gnus-build-all-threads)
10545 (gnus-build-old-threads)))
10546 ;; Let the Gnus agent mark articles as read.
10548 (gnus-agent-get-undownloaded-list))
10549 ;; Remove list identifiers from subject
10550 (when gnus-list-identifiers
10551 (gnus-summary-remove-list-identifiers))
10552 ;; First and last article in this newsgroup.
10553 (when gnus-newsgroup-headers
10554 (setq gnus-newsgroup-begin
10555 (mail-header-number (car gnus-newsgroup-headers))
10557 (mail-header-number
10558 (gnus-last-element gnus-newsgroup-headers))))
10559 (when gnus-use-scoring
10560 (gnus-possibly-score-headers))))
10562 (defun gnus-summary-insert-old-articles (&optional all)
10563 "Insert all old articles in this group.
10564 If ALL is non-nil, already read articles become readable.
10565 If ALL is a number, fetch this number of articles."
10568 (let ((old (mapcar 'car gnus-newsgroup-data))
10569 (i (car gnus-newsgroup-active))
10571 (while (<= i (cdr gnus-newsgroup-active))
10572 (or (memq i old) (push i older))
10574 (setq len (length older))
10579 (setq older (subseq older 0 all))))
10582 (if (and (numberp gnus-large-newsgroup)
10583 (> len gnus-large-newsgroup))
10587 "How many articles from %s (default %d): "
10589 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10591 (unless (string-match "^[ \t]*$" input)
10592 (setq all (string-to-number input))
10594 (setq older (subseq older 0 all))))))))
10596 (message "No old news.")
10597 (gnus-summary-insert-articles older)
10598 (gnus-summary-limit (gnus-union older old))))
10599 (gnus-summary-position-point)))
10601 (defun gnus-summary-insert-new-articles ()
10602 "Insert all new articles in this group."
10605 (let ((old (mapcar 'car gnus-newsgroup-data))
10606 (old-active gnus-newsgroup-active)
10607 (nnmail-fetched-sources (list t))
10609 (setq gnus-newsgroup-active
10610 (gnus-activate-group gnus-newsgroup-name 'scan))
10611 (setq i (1+ (cdr old-active)))
10612 (while (<= i (cdr gnus-newsgroup-active))
10616 (message "No gnus is bad news.")
10617 (setq new (nreverse new))
10618 (gnus-summary-insert-articles new)
10619 (setq gnus-newsgroup-unreads
10620 (append gnus-newsgroup-unreads new))
10621 (gnus-summary-limit (gnus-union old new))))
10622 (gnus-summary-position-point)))
10624 (gnus-summary-make-all-marking-commands)
10626 (gnus-ems-redefine)
10628 (provide 'gnus-sum)
10630 (run-hooks 'gnus-sum-load-hook)
10632 ;;; gnus-sum.el ends here