1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
36 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
38 (defcustom gnus-kill-summary-on-exit t
39 "*If non-nil, kill the summary buffer when you exit from it.
40 If nil, the summary will become a \"*Dead Summary*\" buffer, and
41 it will be killed sometime later."
42 :group 'gnus-summary-exit
45 (defcustom gnus-fetch-old-headers nil
46 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
47 If an unread article in the group refers to an older, already read (or
48 just marked as read) article, the old article will not normally be
49 displayed in the Summary buffer. If this variable is non-nil, Gnus
50 will attempt to grab the headers to the old articles, and thereby
51 build complete threads. If it has the value `some', only enough
52 headers to connect otherwise loose threads will be displayed. This
53 variable can also be a number. In that case, no more than that number
54 of old headers will be fetched. If it has the value `invisible', all
55 old headers will be fetched, but none will be displayed.
57 The server has to support NOV for any of this to work."
59 :type '(choice (const :tag "off" nil)
62 (sexp :menu-tag "other" t)))
64 (defcustom gnus-refer-thread-limit 200
65 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
66 If t, fetch all the available old headers."
69 (sexp :menu-tag "other" t)))
71 (defcustom gnus-summary-make-false-root 'adopt
72 "*nil means that Gnus won't gather loose threads.
73 If the root of a thread has expired or been read in a previous
74 session, the information necessary to build a complete thread has been
75 lost. Instead of having many small sub-threads from this original thread
76 scattered all over the summary buffer, Gnus can gather them.
78 If non-nil, Gnus will try to gather all loose sub-threads from an
79 original thread into one large thread.
81 If this variable is non-nil, it should be one of `none', `adopt',
84 If this variable is `none', Gnus will not make a false root, but just
85 present the sub-threads after another.
86 If this variable is `dummy', Gnus will create a dummy root that will
87 have all the sub-threads as children.
88 If this variable is `adopt', Gnus will make one of the \"children\"
89 the parent and mark all the step-children as such.
90 If this variable is `empty', the \"children\" are printed with empty
91 subject fields. (Or rather, they will be printed with a string
92 given by the `gnus-summary-same-subject' variable.)"
94 :type '(choice (const :tag "off" nil)
100 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
101 "*A regexp to match subjects to be excluded from loose thread gathering.
102 As loose thread gathering is done on subjects only, that means that
103 there can be many false gatherings performed. By rooting out certain
104 common subjects, gathering might become saner."
108 (defcustom gnus-summary-gather-subject-limit nil
109 "*Maximum length of subject comparisons when gathering loose threads.
110 Use nil to compare full subjects. Setting this variable to a low
111 number will help gather threads that have been corrupted by
112 newsreaders chopping off subject lines, but it might also mean that
113 unrelated articles that have subject that happen to begin with the
114 same few characters will be incorrectly gathered.
116 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
119 :type '(choice (const :tag "off" nil)
121 (sexp :menu-tag "on" t)))
123 (defcustom gnus-simplify-subject-functions nil
124 "List of functions taking a string argument that simplify subjects.
125 The functions are applied recursively.
127 Useful functions to put in this list include: `gnus-simplify-subject-re',
128 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
130 :type '(repeat function))
132 (defcustom gnus-simplify-ignored-prefixes nil
133 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
135 :type '(choice (const :tag "off" nil)
138 (defcustom gnus-build-sparse-threads nil
139 "*If non-nil, fill in the gaps in threads.
140 If `some', only fill in the gaps that are needed to tie loose threads
141 together. If `more', fill in all leaf nodes that Gnus can find. If
142 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
144 :type '(choice (const :tag "off" nil)
147 (sexp :menu-tag "all" t)))
149 (defcustom gnus-summary-thread-gathering-function
150 'gnus-gather-threads-by-subject
151 "*Function used for gathering loose threads.
152 There are two pre-defined functions: `gnus-gather-threads-by-subject',
153 which only takes Subjects into consideration; and
154 `gnus-gather-threads-by-references', which compared the References
155 headers of the articles to find matches."
157 :type '(radio (function-item gnus-gather-threads-by-subject)
158 (function-item gnus-gather-threads-by-references)
159 (function :tag "other")))
161 (defcustom gnus-summary-same-subject ""
162 "*String indicating that the current article has the same subject as the previous.
163 This variable will only be used if the value of
164 `gnus-summary-make-false-root' is `empty'."
165 :group 'gnus-summary-format
168 (defcustom gnus-summary-goto-unread t
169 "*If t, marking commands will go to the next unread article.
170 If `never', commands that usually go to the next unread article, will
171 go to the next article, whether it is read or not.
172 If nil, only the marking commands will go to the next (un)read article."
173 :group 'gnus-summary-marks
174 :link '(custom-manual "(gnus)Setting Marks")
175 :type '(choice (const :tag "off" nil)
177 (sexp :menu-tag "on" t)))
179 (defcustom gnus-summary-default-score 0
180 "*Default article score level.
181 All scores generated by the score files will be added to this score.
182 If this variable is nil, scoring will be disabled."
183 :group 'gnus-score-default
184 :type '(choice (const :tag "disable")
187 (defcustom gnus-summary-zcore-fuzz 0
188 "*Fuzziness factor for the zcore in the summary buffer.
189 Articles with scores closer than this to `gnus-summary-default-score'
191 :group 'gnus-summary-format
194 (defcustom gnus-simplify-subject-fuzzy-regexp nil
195 "*Strings to be removed when doing fuzzy matches.
196 This can either be a regular expression or list of regular expressions
197 that will be removed from subject strings if fuzzy subject
198 simplification is selected."
200 :type '(repeat regexp))
202 (defcustom gnus-show-threads t
203 "*If non-nil, display threads in summary mode."
207 (defcustom gnus-thread-hide-subtree nil
208 "*If non-nil, hide all threads initially.
209 If threads are hidden, you have to run the command
210 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
211 to expose hidden threads."
215 (defcustom gnus-thread-hide-killed t
216 "*If non-nil, hide killed threads automatically."
220 (defcustom gnus-thread-ignore-subject nil
221 "*If non-nil, ignore subjects and do all threading based on the Reference header.
222 If nil, which is the default, articles that have different subjects
223 from their parents will start separate threads."
227 (defcustom gnus-thread-operation-ignore-subject t
228 "*If non-nil, subjects will be ignored when doing thread commands.
229 This affects commands like `gnus-summary-kill-thread' and
230 `gnus-summary-lower-thread'.
232 If this variable is nil, articles in the same thread with different
233 subjects will not be included in the operation in question. If this
234 variable is `fuzzy', only articles that have subjects that are fuzzily
235 equal will be included."
237 :type '(choice (const :tag "off" nil)
241 (defcustom gnus-thread-indent-level 4
242 "*Number that says how much each sub-thread should be indented."
246 (defcustom gnus-auto-extend-newsgroup t
247 "*If non-nil, extend newsgroup forward and backward when requested."
248 :group 'gnus-summary-choose
251 (defcustom gnus-auto-select-first t
252 "*If nil, don't select the first unread article when entering a group.
253 If this variable is `best', select the highest-scored unread article
254 in the group. If neither nil nor `best', select the first unread
257 If you want to prevent automatic selection of the first unread article
258 in some newsgroups, set the variable to nil in
259 `gnus-select-group-hook'."
260 :group 'gnus-group-select
261 :type '(choice (const :tag "none" nil)
263 (sexp :menu-tag "first" t)))
265 (defcustom gnus-auto-select-next t
266 "*If non-nil, offer to go to the next group from the end of the previous.
267 If the value is t and the next newsgroup is empty, Gnus will exit
268 summary mode and go back to group mode. If the value is neither nil
269 nor t, Gnus will select the following unread newsgroup. In
270 particular, if the value is the symbol `quietly', the next unread
271 newsgroup will be selected without any confirmation, and if it is
272 `almost-quietly', the next group will be selected without any
273 confirmation if you are located on the last article in the group.
274 Finally, if this variable is `slightly-quietly', the `Z n' command
275 will go to the next group without confirmation."
276 :group 'gnus-summary-maneuvering
277 :type '(choice (const :tag "off" nil)
279 (const almost-quietly)
280 (const slightly-quietly)
281 (sexp :menu-tag "on" t)))
283 (defcustom gnus-auto-select-same nil
284 "*If non-nil, select the next article with the same subject."
285 :group 'gnus-summary-maneuvering
288 (defcustom gnus-summary-check-current nil
289 "*If non-nil, consider the current article when moving.
290 The \"unread\" movement commands will stay on the same line if the
291 current article is unread."
292 :group 'gnus-summary-maneuvering
295 (defcustom gnus-auto-center-summary t
296 "*If non-nil, always center the current summary buffer.
297 In particular, if `vertical' do only vertical recentering. If non-nil
298 and non-`vertical', do both horizontal and vertical recentering."
299 :group 'gnus-summary-maneuvering
300 :type '(choice (const :tag "none" nil)
302 (sexp :menu-tag "both" t)))
304 (defcustom gnus-show-all-headers nil
305 "*If non-nil, don't hide any headers."
306 :group 'gnus-article-hiding
307 :group 'gnus-article-headers
310 (defcustom gnus-summary-ignore-duplicates nil
311 "*If non-nil, ignore articles with identical Message-ID headers."
315 (defcustom gnus-single-article-buffer t
316 "*If non-nil, display all articles in the same buffer.
317 If nil, each group will get its own article buffer."
318 :group 'gnus-article-various
321 (defcustom gnus-break-pages t
322 "*If non-nil, do page breaking on articles.
323 The page delimiter is specified by the `gnus-page-delimiter'
325 :group 'gnus-article-various
328 (defcustom gnus-show-mime nil
329 "*If non-nil, do mime processing of articles.
330 The articles will simply be fed to the function given by
331 `gnus-show-mime-method'."
332 :group 'gnus-article-mime
335 (defcustom gnus-move-split-methods nil
336 "*Variable used to suggest where articles are to be moved to.
337 It uses the same syntax as the `gnus-split-methods' variable."
338 :group 'gnus-summary-mail
339 :type '(repeat (choice (list :value (fun) function)
340 (cons :value ("" "") regexp (repeat string))
343 (defcustom gnus-unread-mark ?
344 "*Mark used for unread articles."
345 :group 'gnus-summary-marks
348 (defcustom gnus-ticked-mark ?!
349 "*Mark used for ticked articles."
350 :group 'gnus-summary-marks
353 (defcustom gnus-dormant-mark ??
354 "*Mark used for dormant articles."
355 :group 'gnus-summary-marks
358 (defcustom gnus-del-mark ?r
359 "*Mark used for del'd articles."
360 :group 'gnus-summary-marks
363 (defcustom gnus-read-mark ?R
364 "*Mark used for read articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-expirable-mark ?E
369 "*Mark used for expirable articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-killed-mark ?K
374 "*Mark used for killed articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-souped-mark ?F
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-kill-file-mark ?X
384 "*Mark used for articles killed by kill files."
385 :group 'gnus-summary-marks
388 (defcustom gnus-low-score-mark ?Y
389 "*Mark used for articles with a low score."
390 :group 'gnus-summary-marks
393 (defcustom gnus-catchup-mark ?C
394 "*Mark used for articles that are caught up."
395 :group 'gnus-summary-marks
398 (defcustom gnus-replied-mark ?A
399 "*Mark used for articles that have been replied to."
400 :group 'gnus-summary-marks
403 (defcustom gnus-cached-mark ?*
404 "*Mark used for articles that are in the cache."
405 :group 'gnus-summary-marks
408 (defcustom gnus-saved-mark ?S
409 "*Mark used for articles that have been saved to."
410 :group 'gnus-summary-marks
413 (defcustom gnus-ancient-mark ?O
414 "*Mark used for ancient articles."
415 :group 'gnus-summary-marks
418 (defcustom gnus-sparse-mark ?Q
419 "*Mark used for sparsely reffed articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-canceled-mark ?G
424 "*Mark used for canceled articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-duplicate-mark ?M
429 "*Mark used for duplicate articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-undownloaded-mark ?@
434 "*Mark used for articles that weren't downloaded."
435 :group 'gnus-summary-marks
438 (defcustom gnus-downloadable-mark ?%
439 "*Mark used for articles that are to be downloaded."
440 :group 'gnus-summary-marks
443 (defcustom gnus-unsendable-mark ?=
444 "*Mark used for articles that won't be sent."
445 :group 'gnus-summary-marks
448 (defcustom gnus-score-over-mark ?+
449 "*Score mark used for articles with high scores."
450 :group 'gnus-summary-marks
453 (defcustom gnus-score-below-mark ?-
454 "*Score mark used for articles with low scores."
455 :group 'gnus-summary-marks
458 (defcustom gnus-empty-thread-mark ?
459 "*There is no thread under the article."
460 :group 'gnus-summary-marks
463 (defcustom gnus-not-empty-thread-mark ?=
464 "*There is a thread under the article."
465 :group 'gnus-summary-marks
468 (defcustom gnus-view-pseudo-asynchronously nil
469 "*If non-nil, Gnus will view pseudo-articles asynchronously."
470 :group 'gnus-extract-view
473 (defcustom gnus-view-pseudos nil
474 "*If `automatic', pseudo-articles will be viewed automatically.
475 If `not-confirm', pseudos will be viewed automatically, and the user
476 will not be asked to confirm the command."
477 :group 'gnus-extract-view
478 :type '(choice (const :tag "off" nil)
480 (const not-confirm)))
482 (defcustom gnus-view-pseudos-separately t
483 "*If non-nil, one pseudo-article will be created for each file to be viewed.
484 If nil, all files that use the same viewing command will be given as a
485 list of parameters to that command."
486 :group 'gnus-extract-view
489 (defcustom gnus-insert-pseudo-articles t
490 "*If non-nil, insert pseudo-articles when decoding articles."
491 :group 'gnus-extract-view
494 (defcustom gnus-summary-dummy-line-format
496 "*The format specification for the dummy roots in the summary buffer.
497 It works along the same lines as a normal formatting string,
498 with some simple extensions.
501 :group 'gnus-threading
504 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
505 "*The format specification for the summary mode line.
506 It works along the same lines as a normal formatting string,
507 with some simple extensions:
510 %p Unprefixed group name
511 %A Current article number
513 %U Number of unread articles in the group
514 %e Number of unselected articles in the group
515 %Z A string with unread/unselected article counts
516 %g Shortish group name
517 %S Subject of the current article
519 %s Current score file name
520 %d Number of dormant articles
521 %r Number of articles that have been marked as read in this session
522 %E Number of articles expunged by the score files"
523 :group 'gnus-summary-format
526 (defcustom gnus-summary-mark-below 0
527 "*Mark all articles with a score below this variable as read.
528 This variable is local to each summary buffer and usually set by the
530 :group 'gnus-score-default
533 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
534 "*List of functions used for sorting articles in the summary buffer.
535 This variable is only used when not using a threaded display."
536 :group 'gnus-summary-sort
537 :type '(repeat (choice (function-item gnus-article-sort-by-number)
538 (function-item gnus-article-sort-by-author)
539 (function-item gnus-article-sort-by-subject)
540 (function-item gnus-article-sort-by-date)
541 (function-item gnus-article-sort-by-score)
542 (function :tag "other"))))
544 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
545 "*List of functions used for sorting threads in the summary buffer.
546 By default, threads are sorted by article number.
548 Each function takes two threads and return non-nil if the first thread
549 should be sorted before the other. If you use more than one function,
550 the primary sort function should be the last. You should probably
551 always include `gnus-thread-sort-by-number' in the list of sorting
552 functions -- preferably first.
554 Ready-made functions include `gnus-thread-sort-by-number',
555 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
556 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
557 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
558 :group 'gnus-summary-sort
559 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
560 (function-item gnus-thread-sort-by-author)
561 (function-item gnus-thread-sort-by-subject)
562 (function-item gnus-thread-sort-by-date)
563 (function-item gnus-thread-sort-by-score)
564 (function-item gnus-thread-sort-by-total-score)
565 (function :tag "other"))))
567 (defcustom gnus-thread-score-function '+
568 "*Function used for calculating the total score of a thread.
570 The function is called with the scores of the article and each
571 subthread and should then return the score of the thread.
573 Some functions you can use are `+', `max', or `min'."
574 :group 'gnus-summary-sort
577 (defcustom gnus-summary-expunge-below nil
578 "All articles that have a score less than this variable will be expunged.
579 This variable is local to the summary buffers."
580 :group 'gnus-score-default
581 :type '(choice (const :tag "off" nil)
584 (defcustom gnus-thread-expunge-below nil
585 "All threads that have a total score less than this variable will be expunged.
586 See `gnus-thread-score-function' for en explanation of what a
589 This variable is local to the summary buffers."
590 :group 'gnus-treading
591 :group 'gnus-score-default
592 :type '(choice (const :tag "off" nil)
595 (defcustom gnus-summary-mode-hook nil
596 "*A hook for Gnus summary mode.
597 This hook is run before any variables are set in the summary buffer."
598 :group 'gnus-summary-various
601 (defcustom gnus-summary-menu-hook nil
602 "*Hook run after the creation of the summary mode menu."
603 :group 'gnus-summary-visual
606 (defcustom gnus-summary-exit-hook nil
607 "*A hook called on exit from the summary buffer.
608 It will be called with point in the group buffer."
609 :group 'gnus-summary-exit
612 (defcustom gnus-summary-prepare-hook nil
613 "*A hook called after the summary buffer has been generated.
614 If you want to modify the summary buffer, you can use this hook."
615 :group 'gnus-summary-various
618 (defcustom gnus-summary-prepared-hook nil
619 "*A hook called as the last thing after the summary buffer has been generated."
620 :group 'gnus-summary-various
623 (defcustom gnus-summary-generate-hook nil
624 "*A hook run just before generating the summary buffer.
625 This hook is commonly used to customize threading variables and the
627 :group 'gnus-summary-various
630 (defcustom gnus-select-group-hook nil
631 "*A hook called when a newsgroup is selected.
633 If you'd like to simplify subjects like the
634 `gnus-summary-next-same-subject' command does, you can use the
637 (setq gnus-select-group-hook
640 (mapcar (lambda (header)
641 (mail-header-set-subject
643 (gnus-simplify-subject
644 (mail-header-subject header) 're-only)))
645 gnus-newsgroup-headers))))"
646 :group 'gnus-group-select
649 (defcustom gnus-select-article-hook nil
650 "*A hook called when an article is selected."
651 :group 'gnus-summary-choose
654 (defcustom gnus-visual-mark-article-hook
655 (list 'gnus-highlight-selected-summary)
656 "*Hook run after selecting an article in the summary buffer.
657 It is meant to be used for highlighting the article in some way. It
658 is not run if `gnus-visual' is nil."
659 :group 'gnus-summary-visual
662 (defcustom gnus-structured-field-decoder 'identity
663 "Function to decode non-ASCII characters in structured field for summary."
667 (defcustom gnus-unstructured-field-decoder 'identity
668 "Function to decode non-ASCII characters in unstructured field for summary."
672 (defcustom gnus-parse-headers-hook
673 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
674 "*A hook called before parsing the headers."
678 (defcustom gnus-exit-group-hook nil
679 "*A hook called when exiting (not quitting) summary mode."
683 (defcustom gnus-summary-update-hook
684 (list 'gnus-summary-highlight-line)
685 "*A hook called when a summary line is changed.
686 The hook will not be called if `gnus-visual' is nil.
688 The default function `gnus-summary-highlight-line' will
689 highlight the line according to the `gnus-summary-highlight'
691 :group 'gnus-summary-visual
694 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
695 "*A hook called when an article is selected for the first time.
696 The hook is intended to mark an article as read (or unread)
697 automatically when it is selected."
698 :group 'gnus-summary-choose
701 (defcustom gnus-group-no-more-groups-hook nil
702 "*A hook run when returning to group mode having no more (unread) groups."
703 :group 'gnus-group-select
706 (defcustom gnus-ps-print-hook nil
707 "*A hook run before ps-printing something from Gnus."
711 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
712 "Face used for highlighting the current article in the summary buffer."
713 :group 'gnus-summary-visual
716 (defcustom gnus-summary-highlight
717 '(((= mark gnus-canceled-mark)
718 . gnus-summary-cancelled-face)
719 ((and (> score default)
720 (or (= mark gnus-dormant-mark)
721 (= mark gnus-ticked-mark)))
722 . gnus-summary-high-ticked-face)
723 ((and (< score default)
724 (or (= mark gnus-dormant-mark)
725 (= mark gnus-ticked-mark)))
726 . gnus-summary-low-ticked-face)
727 ((or (= mark gnus-dormant-mark)
728 (= mark gnus-ticked-mark))
729 . gnus-summary-normal-ticked-face)
730 ((and (> score default) (= mark gnus-ancient-mark))
731 . gnus-summary-high-ancient-face)
732 ((and (< score default) (= mark gnus-ancient-mark))
733 . gnus-summary-low-ancient-face)
734 ((= mark gnus-ancient-mark)
735 . gnus-summary-normal-ancient-face)
736 ((and (> score default) (= mark gnus-unread-mark))
737 . gnus-summary-high-unread-face)
738 ((and (< score default) (= mark gnus-unread-mark))
739 . gnus-summary-low-unread-face)
740 ((= mark gnus-unread-mark)
741 . gnus-summary-normal-unread-face)
742 ((and (> score default) (memq mark (list gnus-downloadable-mark
743 gnus-undownloaded-mark)))
744 . gnus-summary-high-unread-face)
745 ((and (< score default) (memq mark (list gnus-downloadable-mark
746 gnus-undownloaded-mark)))
747 . gnus-summary-low-unread-face)
748 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
749 . gnus-summary-normal-unread-face)
751 . gnus-summary-high-read-face)
753 . gnus-summary-low-read-face)
755 . gnus-summary-normal-read-face))
756 "*Controls the highlighting of summary buffer lines.
758 A list of (FORM . FACE) pairs. When deciding how a a particular
759 summary line should be displayed, each form is evaluated. The content
760 of the face field after the first true form is used. You can change
761 how those summary lines are displayed, by editing the face field.
763 You can use the following variables in the FORM field.
765 score: The articles score
766 default: The default article score.
767 below: The score below which articles are automatically marked as read.
768 mark: The articles mark."
769 :group 'gnus-summary-visual
770 :type '(repeat (cons (sexp :tag "Form" nil)
773 (defcustom gnus-alter-header-function nil
774 "Function called to allow alteration of article header structures.
775 The function is called with one parameter, the article header vector,
776 which it may alter in any way.")
778 ;;; Internal variables
780 (defvar gnus-scores-exclude-files nil)
781 (defvar gnus-page-broken nil)
783 (defvar gnus-original-article nil)
784 (defvar gnus-article-internal-prepare-hook nil)
785 (defvar gnus-newsgroup-process-stack nil)
787 (defvar gnus-thread-indent-array nil)
788 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
790 ;; Avoid highlighting in kill files.
791 (defvar gnus-summary-inhibit-highlight nil)
792 (defvar gnus-newsgroup-selected-overlay nil)
793 (defvar gnus-inhibit-limiting nil)
794 (defvar gnus-newsgroup-adaptive-score-file nil)
795 (defvar gnus-current-score-file nil)
796 (defvar gnus-current-move-group nil)
797 (defvar gnus-current-copy-group nil)
798 (defvar gnus-current-crosspost-group nil)
800 (defvar gnus-newsgroup-dependencies nil)
801 (defvar gnus-newsgroup-adaptive nil)
802 (defvar gnus-summary-display-article-function nil)
803 (defvar gnus-summary-highlight-line-function nil
804 "Function called after highlighting a summary line.")
806 (defvar gnus-summary-line-format-alist
807 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
808 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
809 (?s gnus-tmp-subject-or-nil ?s)
810 (?n gnus-tmp-name ?s)
811 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
813 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
815 (?F gnus-tmp-from ?s)
816 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
817 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
818 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
819 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
820 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
821 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
822 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
823 (?L gnus-tmp-lines ?d)
824 (?I gnus-tmp-indentation ?s)
825 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
826 (?R gnus-tmp-replied ?c)
827 (?\[ gnus-tmp-opening-bracket ?c)
828 (?\] gnus-tmp-closing-bracket ?c)
829 (?\> (make-string gnus-tmp-level ? ) ?s)
830 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
831 (?i gnus-tmp-score ?d)
832 (?z gnus-tmp-score-char ?c)
833 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
834 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
835 (?U gnus-tmp-unread ?c)
836 (?t (gnus-summary-number-of-articles-in-thread
837 (and (boundp 'thread) (car thread)) gnus-tmp-level)
839 (?e (gnus-summary-number-of-articles-in-thread
840 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
842 (?u gnus-tmp-user-defined ?s)
843 (?P (gnus-pick-line-number) ?d))
844 "An alist of format specifications that can appear in summary lines,
845 and what variables they correspond with, along with the type of the
846 variable (string, integer, character, etc).")
848 (defvar gnus-summary-dummy-line-format-alist
849 `((?S gnus-tmp-subject ?s)
850 (?N gnus-tmp-number ?d)
851 (?u gnus-tmp-user-defined ?s)))
853 (defvar gnus-summary-mode-line-format-alist
854 `((?G gnus-tmp-group-name ?s)
855 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
856 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
857 (?A gnus-tmp-article-number ?d)
858 (?Z gnus-tmp-unread-and-unselected ?s)
860 (?U gnus-tmp-unread-and-unticked ?d)
861 (?S gnus-tmp-subject ?s)
862 (?e gnus-tmp-unselected ?d)
863 (?u gnus-tmp-user-defined ?s)
864 (?d (length gnus-newsgroup-dormant) ?d)
865 (?t (length gnus-newsgroup-marked) ?d)
866 (?r (length gnus-newsgroup-reads) ?d)
867 (?E gnus-newsgroup-expunged-tally ?d)
868 (?s (gnus-current-score-file-nondirectory) ?s)))
870 (defvar gnus-last-search-regexp nil
871 "Default regexp for article search command.")
873 (defvar gnus-last-shell-command nil
874 "Default shell command on article.")
876 (defvar gnus-newsgroup-begin nil)
877 (defvar gnus-newsgroup-end nil)
878 (defvar gnus-newsgroup-last-rmail nil)
879 (defvar gnus-newsgroup-last-mail nil)
880 (defvar gnus-newsgroup-last-folder nil)
881 (defvar gnus-newsgroup-last-file nil)
882 (defvar gnus-newsgroup-auto-expire nil)
883 (defvar gnus-newsgroup-active nil)
885 (defvar gnus-newsgroup-data nil)
886 (defvar gnus-newsgroup-data-reverse nil)
887 (defvar gnus-newsgroup-limit nil)
888 (defvar gnus-newsgroup-limits nil)
890 (defvar gnus-newsgroup-unreads nil
891 "List of unread articles in the current newsgroup.")
893 (defvar gnus-newsgroup-unselected nil
894 "List of unselected unread articles in the current newsgroup.")
896 (defvar gnus-newsgroup-reads nil
897 "Alist of read articles and article marks in the current newsgroup.")
899 (defvar gnus-newsgroup-expunged-tally nil)
901 (defvar gnus-newsgroup-marked nil
902 "List of ticked articles in the current newsgroup (a subset of unread art).")
904 (defvar gnus-newsgroup-killed nil
905 "List of ranges of articles that have been through the scoring process.")
907 (defvar gnus-newsgroup-cached nil
908 "List of articles that come from the article cache.")
910 (defvar gnus-newsgroup-saved nil
911 "List of articles that have been saved.")
913 (defvar gnus-newsgroup-kill-headers nil)
915 (defvar gnus-newsgroup-replied nil
916 "List of articles that have been replied to in the current newsgroup.")
918 (defvar gnus-newsgroup-expirable nil
919 "List of articles in the current newsgroup that can be expired.")
921 (defvar gnus-newsgroup-processable nil
922 "List of articles in the current newsgroup that can be processed.")
924 (defvar gnus-newsgroup-downloadable nil
925 "List of articles in the current newsgroup that can be processed.")
927 (defvar gnus-newsgroup-undownloaded nil
928 "List of articles in the current newsgroup that haven't been downloaded..")
930 (defvar gnus-newsgroup-unsendable nil
931 "List of articles in the current newsgroup that won't be sent.")
933 (defvar gnus-newsgroup-bookmarks nil
934 "List of articles in the current newsgroup that have bookmarks.")
936 (defvar gnus-newsgroup-dormant nil
937 "List of dormant articles in the current newsgroup.")
939 (defvar gnus-newsgroup-scored nil
940 "List of scored articles in the current newsgroup.")
942 (defvar gnus-newsgroup-headers nil
943 "List of article headers in the current newsgroup.")
945 (defvar gnus-newsgroup-threads nil)
947 (defvar gnus-newsgroup-prepared nil
948 "Whether the current group has been prepared properly.")
950 (defvar gnus-newsgroup-ancient nil
951 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
953 (defvar gnus-newsgroup-sparse nil)
955 (defvar gnus-current-article nil)
956 (defvar gnus-article-current nil)
957 (defvar gnus-current-headers nil)
958 (defvar gnus-have-all-headers nil)
959 (defvar gnus-last-article nil)
960 (defvar gnus-newsgroup-history nil)
962 (defconst gnus-summary-local-variables
963 '(gnus-newsgroup-name
964 gnus-newsgroup-begin gnus-newsgroup-end
965 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
966 gnus-newsgroup-last-folder gnus-newsgroup-last-file
967 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
968 gnus-newsgroup-unselected gnus-newsgroup-marked
969 gnus-newsgroup-reads gnus-newsgroup-saved
970 gnus-newsgroup-replied gnus-newsgroup-expirable
971 gnus-newsgroup-processable gnus-newsgroup-killed
972 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
973 gnus-newsgroup-unsendable
974 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
975 gnus-newsgroup-headers gnus-newsgroup-threads
976 gnus-newsgroup-prepared gnus-summary-highlight-line-function
977 gnus-current-article gnus-current-headers gnus-have-all-headers
978 gnus-last-article gnus-article-internal-prepare-hook
979 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
980 gnus-newsgroup-scored gnus-newsgroup-kill-headers
981 gnus-thread-expunge-below
982 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
983 (gnus-summary-mark-below . global)
984 gnus-newsgroup-active gnus-scores-exclude-files
985 gnus-newsgroup-history gnus-newsgroup-ancient
986 gnus-newsgroup-sparse gnus-newsgroup-process-stack
987 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
988 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
989 (gnus-newsgroup-expunged-tally . 0)
990 gnus-cache-removable-articles gnus-newsgroup-cached
991 gnus-newsgroup-data gnus-newsgroup-data-reverse
992 gnus-newsgroup-limit gnus-newsgroup-limits)
993 "Variables that are buffer-local to the summary buffers.")
995 ;; Byte-compiler warning.
996 (defvar gnus-article-mode-map)
998 ;; Subject simplification.
1000 (defun gnus-simplify-whitespace (str)
1001 "Remove excessive whitespace."
1004 (while (string-match "[ \t][ \t]+" mystr)
1005 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1007 (substring mystr (match-end 0)))))
1009 (when (string-match "^[ \t]+" mystr)
1010 (setq mystr (substring mystr (match-end 0))))
1012 (when (string-match "[ \t]+$" mystr)
1013 (setq mystr (substring mystr 0 (match-beginning 0))))
1016 (defsubst gnus-simplify-subject-re (subject)
1017 "Remove \"Re:\" from subject lines."
1018 (if (string-match "^[Rr][Ee]: *" subject)
1019 (substring subject (match-end 0))
1022 (defun gnus-simplify-subject (subject &optional re-only)
1023 "Remove `Re:' and words in parentheses.
1024 If RE-ONLY is non-nil, strip leading `Re:'s only."
1025 (let ((case-fold-search t)) ;Ignore case.
1026 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1027 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1028 (setq subject (substring subject (match-end 0))))
1029 ;; Remove uninteresting prefixes.
1030 (when (and (not re-only)
1031 gnus-simplify-ignored-prefixes
1032 (string-match gnus-simplify-ignored-prefixes subject))
1033 (setq subject (substring subject (match-end 0))))
1034 ;; Remove words in parentheses from end.
1036 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1037 (setq subject (substring subject 0 (match-beginning 0)))))
1038 ;; Return subject string.
1041 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1043 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1044 (goto-char (point-min))
1045 (while (re-search-forward regexp nil t)
1046 (replace-match (or newtext ""))))
1048 (defun gnus-simplify-buffer-fuzzy ()
1049 "Simplify string in the buffer fuzzily.
1050 The string in the accessible portion of the current buffer is simplified.
1051 It is assumed to be a single-line subject.
1052 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1053 matter is removed. Additional things can be deleted by setting
1054 gnus-simplify-subject-fuzzy-regexp."
1055 (let ((case-fold-search t)
1057 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1059 (while (not (eq modified-tick (buffer-modified-tick)))
1060 (setq modified-tick (buffer-modified-tick))
1062 ((listp gnus-simplify-subject-fuzzy-regexp)
1063 (mapcar 'gnus-simplify-buffer-fuzzy-step
1064 gnus-simplify-subject-fuzzy-regexp))
1065 (gnus-simplify-subject-fuzzy-regexp
1066 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1067 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1068 (gnus-simplify-buffer-fuzzy-step
1069 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1070 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1072 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1073 (gnus-simplify-buffer-fuzzy-step " +" " ")
1074 (gnus-simplify-buffer-fuzzy-step " $")
1075 (gnus-simplify-buffer-fuzzy-step "^ +")))
1077 (defun gnus-simplify-subject-fuzzy (subject)
1078 "Simplify a subject string fuzzily.
1079 See `gnus-simplify-buffer-fuzzy' for details."
1081 (gnus-set-work-buffer)
1082 (let ((case-fold-search t))
1083 ;; Remove uninteresting prefixes.
1084 (when (and gnus-simplify-ignored-prefixes
1085 (string-match gnus-simplify-ignored-prefixes subject))
1086 (setq subject (substring subject (match-end 0))))
1088 (inline (gnus-simplify-buffer-fuzzy))
1091 (defsubst gnus-simplify-subject-fully (subject)
1092 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1094 (gnus-simplify-subject-functions
1095 (gnus-map-function gnus-simplify-subject-functions subject))
1096 ((null gnus-summary-gather-subject-limit)
1097 (gnus-simplify-subject-re subject))
1098 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1099 (gnus-simplify-subject-fuzzy subject))
1100 ((numberp gnus-summary-gather-subject-limit)
1101 (gnus-limit-string (gnus-simplify-subject-re subject)
1102 gnus-summary-gather-subject-limit))
1106 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1107 "Check whether two subjects are equal.
1108 If optional argument simple-first is t, first argument is already
1111 ((null simple-first)
1112 (equal (gnus-simplify-subject-fully s1)
1113 (gnus-simplify-subject-fully s2)))
1116 (gnus-simplify-subject-fully s2)))))
1118 (defun gnus-summary-bubble-group ()
1119 "Increase the score of the current group.
1120 This is a handy function to add to `gnus-summary-exit-hook' to
1121 increase the score of each group you read."
1122 (gnus-group-add-score gnus-newsgroup-name))
1126 ;;; Gnus summary mode
1129 (put 'gnus-summary-mode 'mode-class 'special)
1132 ;; Non-orthogonal keys
1134 (gnus-define-keys gnus-summary-mode-map
1135 " " gnus-summary-next-page
1136 "\177" gnus-summary-prev-page
1137 [delete] gnus-summary-prev-page
1138 [backspace] gnus-summary-prev-page
1139 "\r" gnus-summary-scroll-up
1140 "n" gnus-summary-next-unread-article
1141 "p" gnus-summary-prev-unread-article
1142 "N" gnus-summary-next-article
1143 "P" gnus-summary-prev-article
1144 "\M-\C-n" gnus-summary-next-same-subject
1145 "\M-\C-p" gnus-summary-prev-same-subject
1146 "\M-n" gnus-summary-next-unread-subject
1147 "\M-p" gnus-summary-prev-unread-subject
1148 "." gnus-summary-first-unread-article
1149 "," gnus-summary-best-unread-article
1150 "\M-s" gnus-summary-search-article-forward
1151 "\M-r" gnus-summary-search-article-backward
1152 "<" gnus-summary-beginning-of-article
1153 ">" gnus-summary-end-of-article
1154 "j" gnus-summary-goto-article
1155 "^" gnus-summary-refer-parent-article
1156 "\M-^" gnus-summary-refer-article
1157 "u" gnus-summary-tick-article-forward
1158 "!" gnus-summary-tick-article-forward
1159 "U" gnus-summary-tick-article-backward
1160 "d" gnus-summary-mark-as-read-forward
1161 "D" gnus-summary-mark-as-read-backward
1162 "E" gnus-summary-mark-as-expirable
1163 "\M-u" gnus-summary-clear-mark-forward
1164 "\M-U" gnus-summary-clear-mark-backward
1165 "k" gnus-summary-kill-same-subject-and-select
1166 "\C-k" gnus-summary-kill-same-subject
1167 "\M-\C-k" gnus-summary-kill-thread
1168 "\M-\C-l" gnus-summary-lower-thread
1169 "e" gnus-summary-edit-article
1170 "#" gnus-summary-mark-as-processable
1171 "\M-#" gnus-summary-unmark-as-processable
1172 "\M-\C-t" gnus-summary-toggle-threads
1173 "\M-\C-s" gnus-summary-show-thread
1174 "\M-\C-h" gnus-summary-hide-thread
1175 "\M-\C-f" gnus-summary-next-thread
1176 "\M-\C-b" gnus-summary-prev-thread
1177 "\M-\C-u" gnus-summary-up-thread
1178 "\M-\C-d" gnus-summary-down-thread
1179 "&" gnus-summary-execute-command
1180 "c" gnus-summary-catchup-and-exit
1181 "\C-w" gnus-summary-mark-region-as-read
1182 "\C-t" gnus-summary-toggle-truncation
1183 "?" gnus-summary-mark-as-dormant
1184 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1185 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1186 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1187 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1188 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1189 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1190 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1191 "=" gnus-summary-expand-window
1192 "\C-x\C-s" gnus-summary-reselect-current-group
1193 "\M-g" gnus-summary-rescan-group
1194 "w" gnus-summary-stop-page-breaking
1195 "\C-c\C-r" gnus-summary-caesar-message
1196 "\M-t" gnus-summary-toggle-mime
1197 "f" gnus-summary-followup
1198 "F" gnus-summary-followup-with-original
1199 "C" gnus-summary-cancel-article
1200 "r" gnus-summary-reply
1201 "R" gnus-summary-reply-with-original
1202 "\C-c\C-f" gnus-summary-mail-forward
1203 "o" gnus-summary-save-article
1204 "\C-o" gnus-summary-save-article-mail
1205 "|" gnus-summary-pipe-output
1206 "\M-k" gnus-summary-edit-local-kill
1207 "\M-K" gnus-summary-edit-global-kill
1209 "\C-c\C-d" gnus-summary-describe-group
1210 "q" gnus-summary-exit
1211 "Q" gnus-summary-exit-no-update
1212 "\C-c\C-i" gnus-info-find-node
1213 gnus-mouse-2 gnus-mouse-pick-article
1214 "m" gnus-summary-mail-other-window
1215 "a" gnus-summary-post-news
1216 "x" gnus-summary-limit-to-unread
1217 "s" gnus-summary-isearch-article
1218 "t" gnus-article-hide-headers
1219 "g" gnus-summary-show-article
1220 "l" gnus-summary-goto-last-article
1221 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1222 "\C-d" gnus-summary-enter-digest-group
1223 "\M-\C-d" gnus-summary-read-document
1224 "\M-\C-e" gnus-summary-edit-parameters
1226 "*" gnus-cache-enter-article
1227 "\M-*" gnus-cache-remove-article
1228 "\M-&" gnus-summary-universal-argument
1229 "\C-l" gnus-recenter
1230 "I" gnus-summary-increase-score
1231 "L" gnus-summary-lower-score
1232 "\M-i" gnus-symbolic-argument
1233 "h" gnus-summary-select-article-buffer
1235 "V" gnus-summary-score-map
1236 "X" gnus-uu-extract-map
1237 "S" gnus-summary-send-map)
1239 ;; Sort of orthogonal keymap
1240 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1241 "t" gnus-summary-tick-article-forward
1242 "!" gnus-summary-tick-article-forward
1243 "d" gnus-summary-mark-as-read-forward
1244 "r" gnus-summary-mark-as-read-forward
1245 "c" gnus-summary-clear-mark-forward
1246 " " gnus-summary-clear-mark-forward
1247 "e" gnus-summary-mark-as-expirable
1248 "x" gnus-summary-mark-as-expirable
1249 "?" gnus-summary-mark-as-dormant
1250 "b" gnus-summary-set-bookmark
1251 "B" gnus-summary-remove-bookmark
1252 "#" gnus-summary-mark-as-processable
1253 "\M-#" gnus-summary-unmark-as-processable
1254 "S" gnus-summary-limit-include-expunged
1255 "C" gnus-summary-catchup
1256 "H" gnus-summary-catchup-to-here
1257 "\C-c" gnus-summary-catchup-all
1258 "k" gnus-summary-kill-same-subject-and-select
1259 "K" gnus-summary-kill-same-subject
1260 "P" gnus-uu-mark-map)
1262 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1263 "c" gnus-summary-clear-above
1264 "u" gnus-summary-tick-above
1265 "m" gnus-summary-mark-above
1266 "k" gnus-summary-kill-below)
1268 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1269 "/" gnus-summary-limit-to-subject
1270 "n" gnus-summary-limit-to-articles
1271 "w" gnus-summary-pop-limit
1272 "s" gnus-summary-limit-to-subject
1273 "a" gnus-summary-limit-to-author
1274 "u" gnus-summary-limit-to-unread
1275 "m" gnus-summary-limit-to-marks
1276 "v" gnus-summary-limit-to-score
1277 "*" gnus-summary-limit-include-cached
1278 "D" gnus-summary-limit-include-dormant
1279 "T" gnus-summary-limit-include-thread
1280 "d" gnus-summary-limit-exclude-dormant
1281 "t" gnus-summary-limit-to-age
1282 "E" gnus-summary-limit-include-expunged
1283 "c" gnus-summary-limit-exclude-childless-dormant
1284 "C" gnus-summary-limit-mark-excluded-as-read)
1286 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1287 "n" gnus-summary-next-unread-article
1288 "p" gnus-summary-prev-unread-article
1289 "N" gnus-summary-next-article
1290 "P" gnus-summary-prev-article
1291 "\C-n" gnus-summary-next-same-subject
1292 "\C-p" gnus-summary-prev-same-subject
1293 "\M-n" gnus-summary-next-unread-subject
1294 "\M-p" gnus-summary-prev-unread-subject
1295 "f" gnus-summary-first-unread-article
1296 "b" gnus-summary-best-unread-article
1297 "j" gnus-summary-goto-article
1298 "g" gnus-summary-goto-subject
1299 "l" gnus-summary-goto-last-article
1300 "o" gnus-summary-pop-article)
1302 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1303 "k" gnus-summary-kill-thread
1304 "l" gnus-summary-lower-thread
1305 "i" gnus-summary-raise-thread
1306 "T" gnus-summary-toggle-threads
1307 "t" gnus-summary-rethread-current
1308 "^" gnus-summary-reparent-thread
1309 "s" gnus-summary-show-thread
1310 "S" gnus-summary-show-all-threads
1311 "h" gnus-summary-hide-thread
1312 "H" gnus-summary-hide-all-threads
1313 "n" gnus-summary-next-thread
1314 "p" gnus-summary-prev-thread
1315 "u" gnus-summary-up-thread
1316 "o" gnus-summary-top-thread
1317 "d" gnus-summary-down-thread
1318 "#" gnus-uu-mark-thread
1319 "\M-#" gnus-uu-unmark-thread)
1321 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1322 "g" gnus-summary-prepare
1323 "c" gnus-summary-insert-cached-articles)
1325 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1326 "c" gnus-summary-catchup-and-exit
1327 "C" gnus-summary-catchup-all-and-exit
1328 "E" gnus-summary-exit-no-update
1329 "Q" gnus-summary-exit
1330 "Z" gnus-summary-exit
1331 "n" gnus-summary-catchup-and-goto-next-group
1332 "R" gnus-summary-reselect-current-group
1333 "G" gnus-summary-rescan-group
1334 "N" gnus-summary-next-group
1335 "s" gnus-summary-save-newsrc
1336 "P" gnus-summary-prev-group)
1338 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1339 " " gnus-summary-next-page
1340 "n" gnus-summary-next-page
1341 "\177" gnus-summary-prev-page
1342 [delete] gnus-summary-prev-page
1343 "p" gnus-summary-prev-page
1344 "\r" gnus-summary-scroll-up
1345 "<" gnus-summary-beginning-of-article
1346 ">" gnus-summary-end-of-article
1347 "b" gnus-summary-beginning-of-article
1348 "e" gnus-summary-end-of-article
1349 "^" gnus-summary-refer-parent-article
1350 "r" gnus-summary-refer-parent-article
1351 "R" gnus-summary-refer-references
1352 "T" gnus-summary-refer-thread
1353 "g" gnus-summary-show-article
1354 "s" gnus-summary-isearch-article
1355 "P" gnus-summary-print-article)
1357 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1358 "b" gnus-article-add-buttons
1359 "B" gnus-article-add-buttons-to-head
1360 "o" gnus-article-treat-overstrike
1361 "e" gnus-article-emphasize
1362 "w" gnus-article-fill-cited-article
1363 "c" gnus-article-remove-cr
1364 "q" gnus-article-de-quoted-unreadable
1365 "f" gnus-article-display-x-face
1366 "l" gnus-summary-stop-page-breaking
1367 "r" gnus-summary-caesar-message
1368 "t" gnus-article-hide-headers
1369 "v" gnus-summary-verbose-headers
1370 "m" gnus-summary-toggle-mime
1371 "h" gnus-article-treat-html
1372 "d" gnus-article-treat-dumbquotes)
1374 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1375 "a" gnus-article-hide
1376 "h" gnus-article-hide-headers
1377 "b" gnus-article-hide-boring-headers
1378 "s" gnus-article-hide-signature
1379 "c" gnus-article-hide-citation
1380 "p" gnus-article-hide-pgp
1381 "P" gnus-article-hide-pem
1382 "\C-c" gnus-article-hide-citation-maybe)
1384 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1385 "a" gnus-article-highlight
1386 "h" gnus-article-highlight-headers
1387 "c" gnus-article-highlight-citation
1388 "s" gnus-article-highlight-signature)
1390 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1391 "z" gnus-article-date-ut
1392 "u" gnus-article-date-ut
1393 "l" gnus-article-date-local
1394 "e" gnus-article-date-lapsed
1395 "o" gnus-article-date-original
1396 "i" gnus-article-date-iso8601
1397 "s" gnus-article-date-user)
1399 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1400 "t" gnus-article-remove-trailing-blank-lines
1401 "l" gnus-article-strip-leading-blank-lines
1402 "m" gnus-article-strip-multiple-blank-lines
1403 "a" gnus-article-strip-blank-lines
1404 "A" gnus-article-strip-all-blank-lines
1405 "s" gnus-article-strip-leading-space)
1407 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1409 "f" gnus-summary-fetch-faq
1410 "d" gnus-summary-describe-group
1411 "h" gnus-summary-describe-briefly
1412 "i" gnus-info-find-node)
1414 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1415 "e" gnus-summary-expire-articles
1416 "\M-\C-e" gnus-summary-expire-articles-now
1417 "\177" gnus-summary-delete-article
1418 [delete] gnus-summary-delete-article
1419 "m" gnus-summary-move-article
1420 "r" gnus-summary-respool-article
1421 "w" gnus-summary-edit-article
1422 "c" gnus-summary-copy-article
1423 "B" gnus-summary-crosspost-article
1424 "q" gnus-summary-respool-query
1425 "i" gnus-summary-import-article
1426 "p" gnus-summary-article-posted-p)
1428 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1429 "o" gnus-summary-save-article
1430 "m" gnus-summary-save-article-mail
1431 "F" gnus-summary-write-article-file
1432 "r" gnus-summary-save-article-rmail
1433 "f" gnus-summary-save-article-file
1434 "b" gnus-summary-save-article-body-file
1435 "h" gnus-summary-save-article-folder
1436 "v" gnus-summary-save-article-vm
1437 "p" gnus-summary-pipe-output
1438 "s" gnus-soup-add-article))
1440 (defun gnus-summary-make-menu-bar ()
1441 (gnus-turn-off-edit-menu 'summary)
1443 (unless (boundp 'gnus-summary-misc-menu)
1446 gnus-summary-kill-menu gnus-summary-mode-map ""
1451 ["Enter score..." gnus-summary-score-entry t]
1452 ["Customize" gnus-score-customize t])
1453 (gnus-make-score-map 'increase)
1454 (gnus-make-score-map 'lower)
1456 ["Kill below" gnus-summary-kill-below t]
1457 ["Mark above" gnus-summary-mark-above t]
1458 ["Tick above" gnus-summary-tick-above t]
1459 ["Clear above" gnus-summary-clear-above t])
1460 ["Current score" gnus-summary-current-score t]
1461 ["Set score" gnus-summary-set-score t]
1462 ["Switch current score file..." gnus-score-change-score-file t]
1463 ["Set mark below..." gnus-score-set-mark-below t]
1464 ["Set expunge below..." gnus-score-set-expunge-below t]
1465 ["Edit current score file" gnus-score-edit-current-scores t]
1466 ["Edit score file" gnus-score-edit-file t]
1467 ["Trace score" gnus-score-find-trace t]
1468 ["Find words" gnus-score-find-favourite-words t]
1469 ["Rescore buffer" gnus-summary-rescore t]
1470 ["Increase score..." gnus-summary-increase-score t]
1471 ["Lower score..." gnus-summary-lower-score t]))))
1473 ;; Define both the Article menu in the summary buffer and the equivalent
1474 ;; Commands menu in the article buffer here for consistency.
1477 ["All" gnus-article-hide t]
1478 ["Headers" gnus-article-hide-headers t]
1479 ["Signature" gnus-article-hide-signature t]
1480 ["Citation" gnus-article-hide-citation t]
1481 ["PGP" gnus-article-hide-pgp t]
1482 ["Boring headers" gnus-article-hide-boring-headers t])
1484 ["All" gnus-article-highlight t]
1485 ["Headers" gnus-article-highlight-headers t]
1486 ["Signature" gnus-article-highlight-signature t]
1487 ["Citation" gnus-article-highlight-citation t])
1489 ["Local" gnus-article-date-local t]
1490 ["ISO8601" gnus-article-date-iso8601 t]
1491 ["UT" gnus-article-date-ut t]
1492 ["Original" gnus-article-date-original t]
1493 ["Lapsed" gnus-article-date-lapsed t]
1494 ["User-defined" gnus-article-date-user t])
1497 ["Leading" gnus-article-strip-leading-blank-lines t]
1498 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1499 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1500 ["All of the above" gnus-article-strip-blank-lines t]
1501 ["All" gnus-article-strip-all-blank-lines t]
1502 ["Leading space" gnus-article-strip-leading-space t])
1503 ["Overstrike" gnus-article-treat-overstrike t]
1504 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1505 ["Emphasis" gnus-article-emphasize t]
1506 ["Word wrap" gnus-article-fill-cited-article t]
1507 ["CR" gnus-article-remove-cr t]
1508 ["Show X-Face" gnus-article-display-x-face t]
1509 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1510 ["UnHTMLize" gnus-article-treat-html t]
1511 ["Rot 13" gnus-summary-caesar-message t]
1512 ["Unix pipe" gnus-summary-pipe-message t]
1513 ["Add buttons" gnus-article-add-buttons t]
1514 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1515 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1516 ["Toggle MIME" gnus-summary-toggle-mime t]
1517 ["Verbose header" gnus-summary-verbose-headers t]
1518 ["Toggle header" gnus-summary-toggle-header t])
1520 ["Save in default format" gnus-summary-save-article t]
1521 ["Save in file" gnus-summary-save-article-file t]
1522 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1523 ["Save in MH folder" gnus-summary-save-article-folder t]
1524 ["Save in VM folder" gnus-summary-save-article-vm t]
1525 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1526 ["Save body in file" gnus-summary-save-article-body-file t]
1527 ["Pipe through a filter" gnus-summary-pipe-output t]
1528 ["Add to SOUP packet" gnus-soup-add-article t]
1529 ["Print" gnus-summary-print-article t])
1531 ["Respool article..." gnus-summary-respool-article t]
1532 ["Move article..." gnus-summary-move-article
1533 (gnus-check-backend-function
1534 'request-move-article gnus-newsgroup-name)]
1535 ["Copy article..." gnus-summary-copy-article t]
1536 ["Crosspost article..." gnus-summary-crosspost-article
1537 (gnus-check-backend-function
1538 'request-replace-article gnus-newsgroup-name)]
1539 ["Import file..." gnus-summary-import-article t]
1540 ["Check if posted" gnus-summary-article-posted-p t]
1541 ["Edit article" gnus-summary-edit-article
1542 (not (gnus-group-read-only-p))]
1543 ["Delete article" gnus-summary-delete-article
1544 (gnus-check-backend-function
1545 'request-expire-articles gnus-newsgroup-name)]
1546 ["Query respool" gnus-summary-respool-query t]
1547 ["Delete expirable articles" gnus-summary-expire-articles-now
1548 (gnus-check-backend-function
1549 'request-expire-articles gnus-newsgroup-name)])
1551 ["Uudecode" gnus-uu-decode-uu t]
1552 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1553 ["Unshar" gnus-uu-decode-unshar t]
1554 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1555 ["Save" gnus-uu-decode-save t]
1556 ["Binhex" gnus-uu-decode-binhex t]
1557 ["Postscript" gnus-uu-decode-postscript t])
1559 ["Enter article" gnus-cache-enter-article t]
1560 ["Remove article" gnus-cache-remove-article t])
1561 ["Select article buffer" gnus-summary-select-article-buffer t]
1562 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1563 ["Isearch article..." gnus-summary-isearch-article t]
1564 ["Beginning of the article" gnus-summary-beginning-of-article t]
1565 ["End of the article" gnus-summary-end-of-article t]
1566 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1567 ["Fetch referenced articles" gnus-summary-refer-references t]
1568 ["Fetch current thread" gnus-summary-refer-thread t]
1569 ["Fetch article with id..." gnus-summary-refer-article t]
1570 ["Redisplay" gnus-summary-show-article t])))
1572 gnus-summary-article-menu gnus-summary-mode-map ""
1573 (cons "Article" innards))
1576 gnus-article-commands-menu gnus-article-mode-map ""
1577 (cons "Commands" innards)))
1580 gnus-summary-thread-menu gnus-summary-mode-map ""
1582 ["Toggle threading" gnus-summary-toggle-threads t]
1583 ["Hide threads" gnus-summary-hide-all-threads t]
1584 ["Show threads" gnus-summary-show-all-threads t]
1585 ["Hide thread" gnus-summary-hide-thread t]
1586 ["Show thread" gnus-summary-show-thread t]
1587 ["Go to next thread" gnus-summary-next-thread t]
1588 ["Go to previous thread" gnus-summary-prev-thread t]
1589 ["Go down thread" gnus-summary-down-thread t]
1590 ["Go up thread" gnus-summary-up-thread t]
1591 ["Top of thread" gnus-summary-top-thread t]
1592 ["Mark thread as read" gnus-summary-kill-thread t]
1593 ["Lower thread score" gnus-summary-lower-thread t]
1594 ["Raise thread score" gnus-summary-raise-thread t]
1595 ["Rethread current" gnus-summary-rethread-current t]
1599 gnus-summary-post-menu gnus-summary-mode-map ""
1601 ["Post an article" gnus-summary-post-news t]
1602 ["Followup" gnus-summary-followup t]
1603 ["Followup and yank" gnus-summary-followup-with-original t]
1604 ["Supersede article" gnus-summary-supersede-article t]
1605 ["Cancel article" gnus-summary-cancel-article t]
1606 ["Reply" gnus-summary-reply t]
1607 ["Reply and yank" gnus-summary-reply-with-original t]
1608 ["Wide reply" gnus-summary-wide-reply t]
1609 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1610 ["Mail forward" gnus-summary-mail-forward t]
1611 ["Post forward" gnus-summary-post-forward t]
1612 ["Digest and mail" gnus-uu-digest-mail-forward t]
1613 ["Digest and post" gnus-uu-digest-post-forward t]
1614 ["Resend message" gnus-summary-resend-message t]
1615 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1616 ["Send a mail" gnus-summary-mail-other-window t]
1617 ["Uuencode and post" gnus-uu-post-news t]
1618 ["Followup via news" gnus-summary-followup-to-mail t]
1619 ["Followup via news and yank"
1620 gnus-summary-followup-to-mail-with-original t]
1622 ;;["Send" gnus-summary-send-draft t]
1623 ;;["Send bounced" gnus-resend-bounced-mail t])
1627 gnus-summary-misc-menu gnus-summary-mode-map ""
1630 ["Mark as read" gnus-summary-mark-as-read-forward t]
1631 ["Mark same subject and select"
1632 gnus-summary-kill-same-subject-and-select t]
1633 ["Mark same subject" gnus-summary-kill-same-subject t]
1634 ["Catchup" gnus-summary-catchup t]
1635 ["Catchup all" gnus-summary-catchup-all t]
1636 ["Catchup to here" gnus-summary-catchup-to-here t]
1637 ["Catchup region" gnus-summary-mark-region-as-read t]
1638 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1640 ["Tick" gnus-summary-tick-article-forward t]
1641 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1642 ["Remove marks" gnus-summary-clear-mark-forward t]
1643 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1644 ["Set bookmark" gnus-summary-set-bookmark t]
1645 ["Remove bookmark" gnus-summary-remove-bookmark t])
1647 ["Marks..." gnus-summary-limit-to-marks t]
1648 ["Subject..." gnus-summary-limit-to-subject t]
1649 ["Author..." gnus-summary-limit-to-author t]
1650 ["Age..." gnus-summary-limit-to-age t]
1651 ["Score" gnus-summary-limit-to-score t]
1652 ["Unread" gnus-summary-limit-to-unread t]
1653 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1654 ["Articles" gnus-summary-limit-to-articles t]
1655 ["Pop limit" gnus-summary-pop-limit t]
1656 ["Show dormant" gnus-summary-limit-include-dormant t]
1657 ["Hide childless dormant"
1658 gnus-summary-limit-exclude-childless-dormant t]
1659 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1660 ["Show expunged" gnus-summary-show-all-expunged t])
1662 ["Set mark" gnus-summary-mark-as-processable t]
1663 ["Remove mark" gnus-summary-unmark-as-processable t]
1664 ["Remove all marks" gnus-summary-unmark-all-processable t]
1665 ["Mark above" gnus-uu-mark-over t]
1666 ["Mark series" gnus-uu-mark-series t]
1667 ["Mark region" gnus-uu-mark-region t]
1668 ["Unmark region" gnus-uu-unmark-region t]
1669 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1670 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1671 ["Mark all" gnus-uu-mark-all t]
1672 ["Mark buffer" gnus-uu-mark-buffer t]
1673 ["Mark sparse" gnus-uu-mark-sparse t]
1674 ["Mark thread" gnus-uu-mark-thread t]
1675 ["Unmark thread" gnus-uu-unmark-thread t]
1676 ("Process Mark Sets"
1677 ["Kill" gnus-summary-kill-process-mark t]
1678 ["Yank" gnus-summary-yank-process-mark
1679 gnus-newsgroup-process-stack]
1680 ["Save" gnus-summary-save-process-mark t]))
1682 ["Page forward" gnus-summary-next-page t]
1683 ["Page backward" gnus-summary-prev-page t]
1684 ["Line forward" gnus-summary-scroll-up t])
1686 ["Next unread article" gnus-summary-next-unread-article t]
1687 ["Previous unread article" gnus-summary-prev-unread-article t]
1688 ["Next article" gnus-summary-next-article t]
1689 ["Previous article" gnus-summary-prev-article t]
1690 ["Next unread subject" gnus-summary-next-unread-subject t]
1691 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1692 ["Next article same subject" gnus-summary-next-same-subject t]
1693 ["Previous article same subject" gnus-summary-prev-same-subject t]
1694 ["First unread article" gnus-summary-first-unread-article t]
1695 ["Best unread article" gnus-summary-best-unread-article t]
1696 ["Go to subject number..." gnus-summary-goto-subject t]
1697 ["Go to article number..." gnus-summary-goto-article t]
1698 ["Go to the last article" gnus-summary-goto-last-article t]
1699 ["Pop article off history" gnus-summary-pop-article t])
1701 ["Sort by number" gnus-summary-sort-by-number t]
1702 ["Sort by author" gnus-summary-sort-by-author t]
1703 ["Sort by subject" gnus-summary-sort-by-subject t]
1704 ["Sort by date" gnus-summary-sort-by-date t]
1705 ["Sort by score" gnus-summary-sort-by-score t]
1706 ["Sort by lines" gnus-summary-sort-by-lines t])
1708 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1709 ["Describe group" gnus-summary-describe-group t]
1710 ["Read manual" gnus-info-find-node t])
1712 ["Pick and read" gnus-pick-mode t]
1713 ["Binary" gnus-binary-mode t])
1715 ["Regenerate" gnus-summary-prepare t]
1716 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1717 ["Toggle threading" gnus-summary-toggle-threads t])
1718 ["Filter articles..." gnus-summary-execute-command t]
1719 ["Run command on subjects..." gnus-summary-universal-argument t]
1720 ["Search articles forward..." gnus-summary-search-article-forward t]
1721 ["Search articles backward..." gnus-summary-search-article-backward t]
1722 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1723 ["Expand window" gnus-summary-expand-window t]
1724 ["Expire expirable articles" gnus-summary-expire-articles
1725 (gnus-check-backend-function
1726 'request-expire-articles gnus-newsgroup-name)]
1727 ["Edit local kill file" gnus-summary-edit-local-kill t]
1728 ["Edit main kill file" gnus-summary-edit-global-kill t]
1729 ["Edit group parameters" gnus-summary-edit-parameters t]
1731 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1732 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1733 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1734 ["Exit group" gnus-summary-exit t]
1735 ["Exit group without updating" gnus-summary-exit-no-update t]
1736 ["Exit and goto next group" gnus-summary-next-group t]
1737 ["Exit and goto prev group" gnus-summary-prev-group t]
1738 ["Reselect group" gnus-summary-reselect-current-group t]
1739 ["Rescan group" gnus-summary-rescan-group t]
1740 ["Update dribble" gnus-summary-save-newsrc t])))
1742 (gnus-run-hooks 'gnus-summary-menu-hook)))
1744 (defun gnus-score-set-default (var value)
1745 "A version of set that updates the GNU Emacs menu-bar."
1747 ;; It is the message that forces the active status to be updated.
1750 (defun gnus-make-score-map (type)
1751 "Make a summary score map of type TYPE."
1754 (let ((headers '(("author" "from" string)
1755 ("subject" "subject" string)
1756 ("article body" "body" string)
1757 ("article head" "head" string)
1758 ("xref" "xref" string)
1759 ("lines" "lines" number)
1760 ("followups to author" "followup" string)))
1761 (types '((number ("less than" <)
1764 (string ("substring" s)
1768 (perms '(("temporary" (current-time-string))
1776 (if (eq type 'lower)
1781 (setq header (car headers))
1787 (let ((ts (cdr (assoc (nth 2 header) types)))
1803 'gnus-summary-score-entry
1805 (if (or (string= (nth 1 header)
1807 (string= (nth 1 header)
1810 (list 'gnus-summary-header
1812 (list 'quote (nth 1 (car ts)))
1813 (list 'gnus-score-default nil)
1819 (list (nreverse outp))))
1822 (list (nreverse outt))))
1824 (setq headers (cdr headers)))
1825 (list (nreverse outh))))))))
1829 (defun gnus-summary-mode (&optional group)
1830 "Major mode for reading articles.
1832 All normal editing commands are switched off.
1833 \\<gnus-summary-mode-map>
1834 Each line in this buffer represents one article. To read an
1835 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1836 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1839 You can also post articles and send mail from this buffer. To
1840 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1841 of an article, type `\\[gnus-summary-reply]'.
1843 There are approx. one gazillion commands you can execute in this
1844 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1846 The following commands are available:
1848 \\{gnus-summary-mode-map}"
1850 (when (gnus-visual-p 'summary-menu 'menu)
1851 (gnus-summary-make-menu-bar))
1852 (kill-all-local-variables)
1853 (gnus-summary-make-local-variables)
1854 (gnus-make-thread-indent-array)
1855 (gnus-simplify-mode-line)
1856 (setq major-mode 'gnus-summary-mode)
1857 (setq mode-name "Summary")
1858 (make-local-variable 'minor-mode-alist)
1859 (use-local-map gnus-summary-mode-map)
1860 (buffer-disable-undo (current-buffer))
1861 (setq buffer-read-only t) ;Disable modification
1862 (setq truncate-lines t)
1863 (setq selective-display t)
1864 (setq selective-display-ellipses t) ;Display `...'
1865 (gnus-summary-set-display-table)
1866 (gnus-set-default-directory)
1867 (setq gnus-newsgroup-name group)
1868 (make-local-variable 'gnus-summary-line-format)
1869 (make-local-variable 'gnus-summary-line-format-spec)
1870 (make-local-variable 'gnus-summary-dummy-line-format)
1871 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1872 (make-local-variable 'gnus-summary-mark-positions)
1873 (make-local-hook 'post-command-hook)
1874 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1875 (make-local-hook 'pre-command-hook)
1876 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1877 (gnus-run-hooks 'gnus-summary-mode-hook)
1878 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1879 (gnus-update-summary-mark-positions))
1881 (defun gnus-summary-make-local-variables ()
1882 "Make all the local summary buffer variables."
1883 (let ((locals gnus-summary-local-variables)
1885 (while (setq local (pop locals))
1888 (if (eq (cdr local) 'global)
1889 ;; Copy the global value of the variable.
1890 (setq global (symbol-value (car local)))
1891 ;; Use the value from the list.
1892 (setq global (eval (cdr local))))
1893 (make-local-variable (car local))
1894 (set (car local) global))
1895 ;; Simple nil-valued local variable.
1896 (make-local-variable local)
1899 (defun gnus-summary-clear-local-variables ()
1900 (let ((locals gnus-summary-local-variables))
1902 (if (consp (car locals))
1903 (and (vectorp (caar locals))
1904 (set (caar locals) nil))
1905 (and (vectorp (car locals))
1906 (set (car locals) nil)))
1907 (setq locals (cdr locals)))))
1909 ;; Summary data functions.
1911 (defmacro gnus-data-number (data)
1914 (defmacro gnus-data-set-number (data number)
1915 `(setcar ,data ,number))
1917 (defmacro gnus-data-mark (data)
1920 (defmacro gnus-data-set-mark (data mark)
1921 `(setcar (nthcdr 1 ,data) ,mark))
1923 (defmacro gnus-data-pos (data)
1926 (defmacro gnus-data-set-pos (data pos)
1927 `(setcar (nthcdr 2 ,data) ,pos))
1929 (defmacro gnus-data-header (data)
1932 (defmacro gnus-data-set-header (data header)
1933 `(setf (nth 3 ,data) ,header))
1935 (defmacro gnus-data-level (data)
1938 (defmacro gnus-data-unread-p (data)
1939 `(= (nth 1 ,data) gnus-unread-mark))
1941 (defmacro gnus-data-read-p (data)
1942 `(/= (nth 1 ,data) gnus-unread-mark))
1944 (defmacro gnus-data-pseudo-p (data)
1945 `(consp (nth 3 ,data)))
1947 (defmacro gnus-data-find (number)
1948 `(assq ,number gnus-newsgroup-data))
1950 (defmacro gnus-data-find-list (number &optional data)
1951 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1952 (memq (assq ,number bdata)
1955 (defmacro gnus-data-make (number mark pos header level)
1956 `(list ,number ,mark ,pos ,header ,level))
1958 (defun gnus-data-enter (after-article number mark pos header level offset)
1959 (let ((data (gnus-data-find-list after-article)))
1961 (error "No such article: %d" after-article))
1962 (setcdr data (cons (gnus-data-make number mark pos header level)
1964 (setq gnus-newsgroup-data-reverse nil)
1965 (gnus-data-update-list (cddr data) offset)))
1967 (defun gnus-data-enter-list (after-article list &optional offset)
1969 (let ((data (and after-article (gnus-data-find-list after-article)))
1971 (or data (not after-article) (error "No such article: %d" after-article))
1972 ;; Find the last element in the list to be spliced into the main
1975 (setq list (cdr list)))
1978 (setcdr list gnus-newsgroup-data)
1979 (setq gnus-newsgroup-data ilist)
1981 (gnus-data-update-list (cdr list) offset)))
1982 (setcdr list (cdr data))
1985 (gnus-data-update-list (cdr list) offset)))
1986 (setq gnus-newsgroup-data-reverse nil))))
1988 (defun gnus-data-remove (article &optional offset)
1989 (let ((data gnus-newsgroup-data))
1990 (if (= (gnus-data-number (car data)) article)
1992 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1993 gnus-newsgroup-data-reverse nil)
1995 (gnus-data-update-list gnus-newsgroup-data offset)))
1997 (when (= (gnus-data-number (cadr data)) article)
1998 (setcdr data (cddr data))
2000 (gnus-data-update-list (cdr data) offset))
2002 gnus-newsgroup-data-reverse nil))
2003 (setq data (cdr data))))))
2005 (defmacro gnus-data-list (backward)
2007 (or gnus-newsgroup-data-reverse
2008 (setq gnus-newsgroup-data-reverse
2009 (reverse gnus-newsgroup-data)))
2010 gnus-newsgroup-data))
2012 (defun gnus-data-update-list (data offset)
2013 "Add OFFSET to the POS of all data entries in DATA."
2015 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2016 (setq data (cdr data))))
2018 (defun gnus-data-compute-positions ()
2019 "Compute the positions of all articles."
2020 (let ((data gnus-newsgroup-data)
2023 (when (setq pos (text-property-any
2024 (point-min) (point-max)
2025 'gnus-number (gnus-data-number (car data))))
2026 (gnus-data-set-pos (car data) (+ pos 3)))
2027 (setq data (cdr data)))))
2029 (defun gnus-summary-article-pseudo-p (article)
2030 "Say whether this article is a pseudo article or not."
2031 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2033 (defmacro gnus-summary-article-sparse-p (article)
2034 "Say whether this article is a sparse article or not."
2035 `(memq ,article gnus-newsgroup-sparse))
2037 (defmacro gnus-summary-article-ancient-p (article)
2038 "Say whether this article is a sparse article or not."
2039 `(memq ,article gnus-newsgroup-ancient))
2041 (defun gnus-article-parent-p (number)
2042 "Say whether this article is a parent or not."
2043 (let ((data (gnus-data-find-list number)))
2044 (and (cdr data) ; There has to be an article after...
2045 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2046 (gnus-data-level (nth 1 data))))))
2048 (defun gnus-article-children (number)
2049 "Return a list of all children to NUMBER."
2050 (let* ((data (gnus-data-find-list number))
2051 (level (gnus-data-level (car data)))
2053 (setq data (cdr data))
2055 (= (gnus-data-level (car data)) (1+ level)))
2056 (push (gnus-data-number (car data)) children)
2057 (setq data (cdr data)))
2060 (defmacro gnus-summary-skip-intangible ()
2061 "If the current article is intangible, then jump to a different article."
2062 '(let ((to (get-text-property (point) 'gnus-intangible)))
2063 (and to (gnus-summary-goto-subject to))))
2065 (defmacro gnus-summary-article-intangible-p ()
2066 "Say whether this article is intangible or not."
2067 '(get-text-property (point) 'gnus-intangible))
2069 (defun gnus-article-read-p (article)
2070 "Say whether ARTICLE is read or not."
2071 (not (or (memq article gnus-newsgroup-marked)
2072 (memq article gnus-newsgroup-unreads)
2073 (memq article gnus-newsgroup-unselected)
2074 (memq article gnus-newsgroup-dormant))))
2076 ;; Some summary mode macros.
2078 (defmacro gnus-summary-article-number ()
2079 "The article number of the article on the current line.
2080 If there isn's an article number here, then we return the current
2083 (gnus-summary-skip-intangible)
2084 (or (get-text-property (point) 'gnus-number)
2085 (gnus-summary-last-subject))))
2087 (defmacro gnus-summary-article-header (&optional number)
2088 "Return the header of article NUMBER."
2089 `(gnus-data-header (gnus-data-find
2090 ,(or number '(gnus-summary-article-number)))))
2092 (defmacro gnus-summary-thread-level (&optional number)
2093 "Return the level of thread that starts with article NUMBER."
2094 `(if (and (eq gnus-summary-make-false-root 'dummy)
2095 (get-text-property (point) 'gnus-intangible))
2097 (gnus-data-level (gnus-data-find
2098 ,(or number '(gnus-summary-article-number))))))
2100 (defmacro gnus-summary-article-mark (&optional number)
2101 "Return the mark of article NUMBER."
2102 `(gnus-data-mark (gnus-data-find
2103 ,(or number '(gnus-summary-article-number)))))
2105 (defmacro gnus-summary-article-pos (&optional number)
2106 "Return the position of the line of article NUMBER."
2107 `(gnus-data-pos (gnus-data-find
2108 ,(or number '(gnus-summary-article-number)))))
2110 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2111 (defmacro gnus-summary-article-subject (&optional number)
2112 "Return current subject string or nil if nothing."
2115 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2116 '(gnus-data-header (assq (gnus-summary-article-number)
2117 gnus-newsgroup-data)))))
2120 (mail-header-subject headers))))
2122 (defmacro gnus-summary-article-score (&optional number)
2123 "Return current article score."
2124 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2125 gnus-newsgroup-scored))
2126 gnus-summary-default-score 0))
2128 (defun gnus-summary-article-children (&optional number)
2129 "Return a list of article numbers that are children of article NUMBER."
2130 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2131 (level (gnus-data-level (car data)))
2133 (while (and (setq data (cdr data))
2134 (> (setq l (gnus-data-level (car data))) level))
2135 (and (= (1+ level) l)
2136 (push (gnus-data-number (car data))
2138 (nreverse children)))
2140 (defun gnus-summary-article-parent (&optional number)
2141 "Return the article number of the parent of article NUMBER."
2142 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2143 (gnus-data-list t)))
2144 (level (gnus-data-level (car data))))
2146 () ; This is a root.
2147 ;; We search until we find an article with a level less than
2148 ;; this one. That function has to be the parent.
2149 (while (and (setq data (cdr data))
2150 (not (< (gnus-data-level (car data)) level))))
2151 (and data (gnus-data-number (car data))))))
2153 (defun gnus-unread-mark-p (mark)
2154 "Say whether MARK is the unread mark."
2155 (= mark gnus-unread-mark))
2157 (defun gnus-read-mark-p (mark)
2158 "Say whether MARK is one of the marks that mark as read.
2159 This is all marks except unread, ticked, dormant, and expirable."
2160 (not (or (= mark gnus-unread-mark)
2161 (= mark gnus-ticked-mark)
2162 (= mark gnus-dormant-mark)
2163 (= mark gnus-expirable-mark))))
2165 (defmacro gnus-article-mark (number)
2166 "Return the MARK of article NUMBER.
2167 This macro should only be used when computing the mark the \"first\"
2168 time; i.e., when generating the summary lines. After that,
2169 `gnus-summary-article-mark' should be used to examine the
2172 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2173 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2174 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2175 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2176 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2177 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2178 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2179 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2180 gnus-ancient-mark))))
2182 ;; Saving hidden threads.
2184 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2185 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2187 (defmacro gnus-save-hidden-threads (&rest forms)
2188 "Save hidden threads, eval FORMS, and restore the hidden threads."
2189 (let ((config (make-symbol "config")))
2190 `(let ((,config (gnus-hidden-threads-configuration)))
2194 (gnus-restore-hidden-threads-configuration ,config)))))
2196 (defun gnus-hidden-threads-configuration ()
2197 "Return the current hidden threads configuration."
2200 (goto-char (point-min))
2201 (while (search-forward "\r" nil t)
2202 (push (1- (point)) config))
2205 (defun gnus-restore-hidden-threads-configuration (config)
2206 "Restore hidden threads configuration from CONFIG."
2207 (let (point buffer-read-only)
2208 (while (setq point (pop config))
2209 (when (and (< point (point-max))
2211 (= (following-char) ?\n))
2212 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2214 ;; Various summary mode internalish functions.
2216 (defun gnus-mouse-pick-article (e)
2219 (gnus-summary-next-page nil t))
2221 (defun gnus-summary-set-display-table ()
2222 ;; Change the display table. Odd characters have a tendency to mess
2223 ;; up nicely formatted displays - we make all possible glyphs
2224 ;; display only a single character.
2226 ;; We start from the standard display table, if any.
2227 (let ((table (or (copy-sequence standard-display-table)
2228 (make-display-table)))
2230 ;; Nix out all the control chars...
2231 (while (>= (setq i (1- i)) 0)
2232 (aset table i [??]))
2233 ;; ... but not newline and cr, of course. (cr is necessary for the
2234 ;; selective display).
2235 (aset table ?\n nil)
2236 (aset table ?\r nil)
2237 ;; We keep TAB as well.
2238 (aset table ?\t nil)
2239 ;; We nix out any glyphs over 126 that are not set already.
2241 (while (>= (setq i (1- i)) 127)
2242 ;; Only modify if the entry is nil.
2243 (unless (aref table i)
2244 (aset table i [??]))))
2245 (setq buffer-display-table table)))
2247 (defun gnus-summary-setup-buffer (group)
2248 "Initialize summary buffer."
2249 (let ((buffer (concat "*Summary " group "*")))
2250 (if (get-buffer buffer)
2253 (setq gnus-summary-buffer (current-buffer))
2254 (not gnus-newsgroup-prepared))
2255 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2256 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2257 (gnus-add-current-to-buffer-list)
2258 (gnus-summary-mode group)
2260 (gnus-carpal-setup-buffer 'summary))
2261 (unless gnus-single-article-buffer
2262 (make-local-variable 'gnus-article-buffer)
2263 (make-local-variable 'gnus-article-current)
2264 (make-local-variable 'gnus-original-article-buffer))
2265 (setq gnus-newsgroup-name group)
2268 (defun gnus-set-global-variables ()
2269 ;; Set the global equivalents of the summary buffer-local variables
2270 ;; to the latest values they had. These reflect the summary buffer
2271 ;; that was in action when the last article was fetched.
2272 (when (eq major-mode 'gnus-summary-mode)
2273 (setq gnus-summary-buffer (current-buffer))
2274 (let ((name gnus-newsgroup-name)
2275 (marked gnus-newsgroup-marked)
2276 (unread gnus-newsgroup-unreads)
2277 (headers gnus-current-headers)
2278 (data gnus-newsgroup-data)
2279 (summary gnus-summary-buffer)
2280 (article-buffer gnus-article-buffer)
2281 (original gnus-original-article-buffer)
2282 (gac gnus-article-current)
2283 (reffed gnus-reffed-article-number)
2284 (score-file gnus-current-score-file))
2286 (set-buffer gnus-group-buffer)
2287 (setq gnus-newsgroup-name name
2288 gnus-newsgroup-marked marked
2289 gnus-newsgroup-unreads unread
2290 gnus-current-headers headers
2291 gnus-newsgroup-data data
2292 gnus-article-current gac
2293 gnus-summary-buffer summary
2294 gnus-article-buffer article-buffer
2295 gnus-original-article-buffer original
2296 gnus-reffed-article-number reffed
2297 gnus-current-score-file score-file)
2298 ;; The article buffer also has local variables.
2299 (when (gnus-buffer-live-p gnus-article-buffer)
2300 (set-buffer gnus-article-buffer)
2301 (setq gnus-summary-buffer summary))))))
2303 (defun gnus-summary-article-unread-p (article)
2304 "Say whether ARTICLE is unread or not."
2305 (memq article gnus-newsgroup-unreads))
2307 (defun gnus-summary-first-article-p (&optional article)
2308 "Return whether ARTICLE is the first article in the buffer."
2309 (if (not (setq article (or article (gnus-summary-article-number))))
2311 (eq article (caar gnus-newsgroup-data))))
2313 (defun gnus-summary-last-article-p (&optional article)
2314 "Return whether ARTICLE is the last article in the buffer."
2315 (if (not (setq article (or article (gnus-summary-article-number))))
2316 t ; All non-existent numbers are the last article. :-)
2317 (not (cdr (gnus-data-find-list article)))))
2319 (defun gnus-make-thread-indent-array ()
2321 (unless (and gnus-thread-indent-array
2322 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2323 (setq gnus-thread-indent-array (make-vector 201 "")
2324 gnus-thread-indent-array-level gnus-thread-indent-level)
2326 (aset gnus-thread-indent-array n
2327 (make-string (* n gnus-thread-indent-level) ? ))
2330 (defun gnus-update-summary-mark-positions ()
2331 "Compute where the summary marks are to go."
2333 (when (gnus-buffer-exists-p gnus-summary-buffer)
2334 (set-buffer gnus-summary-buffer))
2335 (let ((gnus-replied-mark 129)
2336 (gnus-score-below-mark 130)
2337 (gnus-score-over-mark 130)
2338 (gnus-download-mark 131)
2339 (spec gnus-summary-line-format-spec)
2340 thread gnus-visual pos)
2342 (gnus-set-work-buffer)
2343 (let ((gnus-summary-line-format-spec spec)
2344 (gnus-newsgroup-downloadable '((0 . t))))
2345 (gnus-summary-insert-line
2346 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2347 (goto-char (point-min))
2348 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2350 (goto-char (point-min))
2351 (push (cons 'replied (and (search-forward "\201" nil t)
2354 (goto-char (point-min))
2355 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2357 (goto-char (point-min))
2358 (push (cons 'download
2359 (and (search-forward "\203" nil t) (- (point) 2)))
2361 (setq gnus-summary-mark-positions pos))))
2363 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2364 "Insert a dummy root in the summary buffer."
2366 (gnus-add-text-properties
2367 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2368 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2370 (defun gnus-summary-insert-line (gnus-tmp-header
2371 gnus-tmp-level gnus-tmp-current
2372 gnus-tmp-unread gnus-tmp-replied
2373 gnus-tmp-expirable gnus-tmp-subject-or-nil
2374 &optional gnus-tmp-dummy gnus-tmp-score
2376 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2377 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2378 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2379 (gnus-tmp-score-char
2380 (if (or (null gnus-summary-default-score)
2381 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2382 gnus-summary-zcore-fuzz))
2384 (if (< gnus-tmp-score gnus-summary-default-score)
2385 gnus-score-below-mark gnus-score-over-mark)))
2387 (cond (gnus-tmp-process gnus-process-mark)
2388 ((memq gnus-tmp-current gnus-newsgroup-cached)
2390 (gnus-tmp-replied gnus-replied-mark)
2391 ((memq gnus-tmp-current gnus-newsgroup-saved)
2393 (t gnus-unread-mark)))
2394 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2397 ((string-match "<[^>]+> *$" gnus-tmp-from)
2398 (let ((beg (match-beginning 0)))
2399 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2400 (substring gnus-tmp-from (1+ (match-beginning 0))
2401 (1- (match-end 0))))
2402 (substring gnus-tmp-from 0 beg))))
2403 ((string-match "(.+)" gnus-tmp-from)
2404 (substring gnus-tmp-from
2405 (1+ (match-beginning 0)) (1- (match-end 0))))
2407 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2408 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2409 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2410 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2411 (buffer-read-only nil))
2412 (when (string= gnus-tmp-name "")
2413 (setq gnus-tmp-name gnus-tmp-from))
2414 (unless (numberp gnus-tmp-lines)
2415 (setq gnus-tmp-lines 0))
2416 (gnus-put-text-property
2418 (progn (eval gnus-summary-line-format-spec) (point))
2419 'gnus-number gnus-tmp-number)
2420 (when (gnus-visual-p 'summary-highlight 'highlight)
2422 (gnus-run-hooks 'gnus-summary-update-hook)
2425 (defun gnus-summary-update-line (&optional dont-update)
2426 ;; Update summary line after change.
2427 (when (and gnus-summary-default-score
2428 (not gnus-summary-inhibit-highlight))
2429 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2430 (article (gnus-summary-article-number))
2431 (score (gnus-summary-article-score article)))
2433 (if (and gnus-summary-mark-below
2434 (< (gnus-summary-article-score)
2435 gnus-summary-mark-below))
2436 ;; This article has a low score, so we mark it as read.
2437 (when (memq article gnus-newsgroup-unreads)
2438 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2439 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2440 ;; This article was previously marked as read on account
2441 ;; of a low score, but now it has risen, so we mark it as
2443 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2444 (gnus-summary-update-mark
2445 (if (or (null gnus-summary-default-score)
2446 (<= (abs (- score gnus-summary-default-score))
2447 gnus-summary-zcore-fuzz))
2449 (if (< score gnus-summary-default-score)
2450 gnus-score-below-mark gnus-score-over-mark))
2452 ;; Do visual highlighting.
2453 (when (gnus-visual-p 'summary-highlight 'highlight)
2454 (gnus-run-hooks 'gnus-summary-update-hook)))))
2456 (defvar gnus-tmp-new-adopts nil)
2458 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2459 "Return the number of articles in THREAD.
2460 This may be 0 in some cases -- if none of the articles in
2461 the thread are to be displayed."
2463 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2465 ((not (listp thread))
2467 ((and (consp thread) (cdr thread))
2470 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2473 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2476 (when (and level (zerop level) gnus-tmp-new-adopts)
2479 'gnus-summary-number-of-articles-in-thread
2480 gnus-tmp-new-adopts))))
2482 (if (> number 1) gnus-not-empty-thread-mark
2483 gnus-empty-thread-mark)
2486 (defun gnus-summary-set-local-parameters (group)
2487 "Go through the local params of GROUP and set all variable specs in that list."
2488 (let ((params (gnus-group-find-parameter group))
2491 (setq elem (car params)
2492 params (cdr params))
2493 (and (consp elem) ; Has to be a cons.
2494 (consp (cdr elem)) ; The cdr has to be a list.
2495 (symbolp (car elem)) ; Has to be a symbol in there.
2496 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2497 (ignore-errors ; So we set it.
2498 (make-local-variable (car elem))
2499 (set (car elem) (eval (nth 1 elem))))))))
2501 (defun gnus-summary-read-group (group &optional show-all no-article
2502 kill-buffer no-display backward)
2503 "Start reading news in newsgroup GROUP.
2504 If SHOW-ALL is non-nil, already read articles are also listed.
2505 If NO-ARTICLE is non-nil, no article is selected initially.
2506 If NO-DISPLAY, don't generate a summary buffer."
2510 (let ((gnus-auto-select-next nil))
2511 (or (gnus-summary-read-group-1
2512 group show-all no-article
2513 kill-buffer no-display)
2514 (setq show-all nil)))))
2515 (eq gnus-auto-select-next 'quietly))
2516 (set-buffer gnus-group-buffer)
2517 ;; The entry function called above goes to the next
2518 ;; group automatically, so we go two groups back
2519 ;; if we are searching for the previous group.
2521 (gnus-group-prev-unread-group 2))
2522 (if (not (equal group (gnus-group-group-name)))
2523 (setq group (gnus-group-group-name))
2527 (defun gnus-summary-read-group-1 (group show-all no-article
2528 kill-buffer no-display)
2529 ;; Killed foreign groups can't be entered.
2530 (when (and (not (gnus-group-native-p group))
2531 (not (gnus-gethash group gnus-newsrc-hashtb)))
2532 (error "Dead non-native groups can't be entered"))
2533 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2534 (let* ((new-group (gnus-summary-setup-buffer group))
2535 (quit-config (gnus-group-quit-config group))
2536 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2538 ;; This summary buffer exists already, so we just select it.
2540 (gnus-set-global-variables)
2542 (gnus-kill-or-deaden-summary kill-buffer))
2543 (gnus-configure-windows 'summary 'force)
2544 (gnus-set-mode-line 'summary)
2545 (gnus-summary-position-point)
2548 ;; We couldn't select this group.
2550 (when (and (eq major-mode 'gnus-summary-mode)
2551 (not (equal (current-buffer) kill-buffer)))
2552 (kill-buffer (current-buffer))
2553 (if (not quit-config)
2555 ;; Update the info -- marks might need to be removed,
2557 (gnus-summary-update-info)
2558 (set-buffer gnus-group-buffer)
2559 (gnus-group-jump-to-group group)
2560 (gnus-group-next-unread-group 1))
2561 (gnus-handle-ephemeral-exit quit-config)))
2562 (gnus-message 3 "Can't select group")
2564 ;; The user did a `C-g' while prompting for number of articles,
2565 ;; so we exit this group.
2566 ((eq did-select 'quit)
2567 (and (eq major-mode 'gnus-summary-mode)
2568 (not (equal (current-buffer) kill-buffer))
2569 (kill-buffer (current-buffer)))
2571 (gnus-kill-or-deaden-summary kill-buffer))
2572 (if (not quit-config)
2574 (set-buffer gnus-group-buffer)
2575 (gnus-group-jump-to-group group)
2576 (gnus-group-next-unread-group 1)
2577 (gnus-configure-windows 'group 'force))
2578 (gnus-handle-ephemeral-exit quit-config))
2579 ;; Finally signal the quit.
2581 ;; The group was successfully selected.
2583 (gnus-set-global-variables)
2584 ;; Save the active value in effect when the group was entered.
2585 (setq gnus-newsgroup-active
2587 (gnus-active gnus-newsgroup-name)))
2588 ;; You can change the summary buffer in some way with this hook.
2589 (gnus-run-hooks 'gnus-select-group-hook)
2590 ;; Set any local variables in the group parameters.
2591 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2592 (gnus-update-format-specifications
2593 nil 'summary 'summary-mode 'summary-dummy)
2594 ;; Do score processing.
2595 (when gnus-use-scoring
2596 (gnus-possibly-score-headers))
2597 ;; Check whether to fill in the gaps in the threads.
2598 (when gnus-build-sparse-threads
2599 (gnus-build-sparse-threads))
2600 ;; Find the initial limit.
2601 (if gnus-show-threads
2603 (let ((gnus-newsgroup-dormant nil))
2604 (gnus-summary-initial-limit show-all))
2605 (gnus-summary-initial-limit show-all))
2606 (setq gnus-newsgroup-limit
2608 (lambda (header) (mail-header-number header))
2609 gnus-newsgroup-headers)))
2610 ;; Generate the summary buffer.
2612 (gnus-summary-prepare))
2613 (when gnus-use-trees
2614 (gnus-tree-open group)
2615 (setq gnus-summary-highlight-line-function
2616 'gnus-tree-highlight-article))
2617 ;; If the summary buffer is empty, but there are some low-scored
2618 ;; articles or some excluded dormants, we include these in the
2620 (when (and (zerop (buffer-size))
2622 (cond (gnus-newsgroup-dormant
2623 (gnus-summary-limit-include-dormant))
2624 ((and gnus-newsgroup-scored show-all)
2625 (gnus-summary-limit-include-expunged t))))
2626 ;; Function `gnus-apply-kill-file' must be called in this hook.
2627 (gnus-run-hooks 'gnus-apply-kill-hook)
2628 (if (and (zerop (buffer-size))
2631 ;; This newsgroup is empty.
2632 (gnus-summary-catchup-and-exit nil t)
2633 (gnus-message 6 "No unread news")
2635 (gnus-kill-or-deaden-summary kill-buffer))
2636 ;; Return nil from this function.
2638 ;; Hide conversation thread subtrees. We cannot do this in
2639 ;; gnus-summary-prepare-hook since kill processing may not
2640 ;; work with hidden articles.
2641 (and gnus-show-threads
2642 gnus-thread-hide-subtree
2643 (gnus-summary-hide-all-threads))
2645 (gnus-kill-or-deaden-summary kill-buffer))
2646 ;; Show first unread article if requested.
2647 (if (and (not no-article)
2649 gnus-newsgroup-unreads
2650 gnus-auto-select-first)
2651 (unless (if (eq gnus-auto-select-first 'best)
2652 (gnus-summary-best-unread-article)
2653 (gnus-summary-first-unread-article))
2654 (gnus-configure-windows 'summary))
2655 ;; Don't select any articles, just move point to the first
2656 ;; article in the group.
2657 (goto-char (point-min))
2658 (gnus-summary-position-point)
2659 (gnus-configure-windows 'summary 'force)
2660 (gnus-set-mode-line 'summary))
2661 (when (get-buffer-window gnus-group-buffer t)
2662 ;; Gotta use windows, because recenter does weird stuff if
2663 ;; the current buffer ain't the displayed window.
2664 (let ((owin (selected-window)))
2665 (select-window (get-buffer-window gnus-group-buffer t))
2666 (when (gnus-group-goto-group group)
2668 (select-window owin)))
2669 ;; Mark this buffer as "prepared".
2670 (setq gnus-newsgroup-prepared t)
2671 (gnus-run-hooks 'gnus-summary-prepared-hook)
2674 (defun gnus-summary-prepare ()
2675 "Generate the summary buffer."
2677 (let ((buffer-read-only nil))
2679 (setq gnus-newsgroup-data nil
2680 gnus-newsgroup-data-reverse nil)
2681 (gnus-run-hooks 'gnus-summary-generate-hook)
2682 ;; Generate the buffer, either with threads or without.
2683 (when gnus-newsgroup-headers
2684 (gnus-summary-prepare-threads
2685 (if gnus-show-threads
2686 (gnus-sort-gathered-threads
2687 (funcall gnus-summary-thread-gathering-function
2689 (gnus-cut-threads (gnus-make-threads)))))
2690 ;; Unthreaded display.
2691 (gnus-sort-articles gnus-newsgroup-headers))))
2692 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2693 ;; Call hooks for modifying summary buffer.
2694 (goto-char (point-min))
2695 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2697 (defsubst gnus-general-simplify-subject (subject)
2698 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2701 ;; Truncate the subject.
2702 (gnus-simplify-subject-functions
2703 (gnus-map-function gnus-simplify-subject-functions subject))
2704 ((numberp gnus-summary-gather-subject-limit)
2705 (setq subject (gnus-simplify-subject-re subject))
2706 (if (> (length subject) gnus-summary-gather-subject-limit)
2707 (substring subject 0 gnus-summary-gather-subject-limit)
2709 ;; Fuzzily simplify it.
2710 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2711 (gnus-simplify-subject-fuzzy subject))
2712 ;; Just remove the leading "Re:".
2714 (gnus-simplify-subject-re subject))))
2716 (if (and gnus-summary-gather-exclude-subject
2717 (string-match gnus-summary-gather-exclude-subject subject))
2718 nil ; This article shouldn't be gathered
2721 (defun gnus-summary-simplify-subject-query ()
2722 "Query where the respool algorithm would put this article."
2724 (gnus-summary-select-article)
2725 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2727 (defun gnus-gather-threads-by-subject (threads)
2728 "Gather threads by looking at Subject headers."
2729 (if (not gnus-summary-make-false-root)
2731 (let ((hashtb (gnus-make-hashtable 1024))
2734 subject hthread whole-subject)
2736 (setq subject (gnus-general-simplify-subject
2737 (setq whole-subject (mail-header-subject
2740 (if (setq hthread (gnus-gethash subject hashtb))
2742 ;; We enter a dummy root into the thread, if we
2743 ;; haven't done that already.
2744 (unless (stringp (caar hthread))
2745 (setcar hthread (list whole-subject (car hthread))))
2746 ;; We add this new gathered thread to this gathered
2748 (setcdr (car hthread)
2749 (nconc (cdar hthread) (list (car threads))))
2750 ;; Remove it from the list of threads.
2751 (setcdr prev (cdr threads))
2752 (setq threads prev))
2753 ;; Enter this thread into the hash table.
2754 (gnus-sethash subject threads hashtb)))
2756 (setq threads (cdr threads)))
2759 (defun gnus-gather-threads-by-references (threads)
2760 "Gather threads by looking at References headers."
2761 (let ((idhashtb (gnus-make-hashtable 1024))
2762 (thhashtb (gnus-make-hashtable 1024))
2765 ids references id gthread gid entered ref)
2767 (when (setq references (mail-header-references (caar threads)))
2768 (setq id (mail-header-id (caar threads))
2769 ids (gnus-split-references references)
2771 (while (setq ref (pop ids))
2772 (setq ids (delete ref ids))
2773 (if (not (setq gid (gnus-gethash ref idhashtb)))
2775 (gnus-sethash ref id idhashtb)
2776 (gnus-sethash id threads thhashtb))
2777 (setq gthread (gnus-gethash gid thhashtb))
2779 ;; We enter a dummy root into the thread, if we
2780 ;; haven't done that already.
2781 (unless (stringp (caar gthread))
2782 (setcar gthread (list (mail-header-subject (caar gthread))
2784 ;; We add this new gathered thread to this gathered
2786 (setcdr (car gthread)
2787 (nconc (cdar gthread) (list (car threads)))))
2788 ;; Add it into the thread hash table.
2789 (gnus-sethash id gthread thhashtb)
2791 ;; Remove it from the list of threads.
2792 (setcdr prev (cdr threads))
2793 (setq threads prev))))
2795 (setq threads (cdr threads)))
2798 (defun gnus-sort-gathered-threads (threads)
2799 "Sort subtreads inside each gathered thread by article number."
2800 (let ((result threads))
2802 (when (stringp (caar threads))
2803 (setcdr (car threads)
2804 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2805 (setq threads (cdr threads)))
2808 (defun gnus-thread-loop-p (root thread)
2809 "Say whether ROOT is in THREAD."
2810 (let ((stack (list thread))
2813 (while (setq thread (pop stack))
2814 (setq th (cdr thread))
2816 (not (eq (caar th) root)))
2819 ;; We have found a loop.
2821 (setcdr thread (delq (car th) (cdr thread)))
2822 (if (boundp (setq ref-dep (intern "none"
2823 gnus-newsgroup-dependencies)))
2824 (setcdr (symbol-value ref-dep)
2825 (nconc (cdr (symbol-value ref-dep))
2827 (set ref-dep (list nil (car th))))
2830 ;; Push all the subthreads onto the stack.
2831 (push (cdr thread) stack)))
2834 (defun gnus-make-threads ()
2835 "Go through the dependency hashtb and find the roots. Return all threads."
2837 (while (catch 'infloop
2840 ;; Deal with self-referencing References loops.
2841 (when (and (car (symbol-value refs))
2848 (car (symbol-value refs)) thread))
2849 (cdr (symbol-value refs)))))))
2852 (unless (car (symbol-value refs))
2853 ;; These threads do not refer back to any other articles,
2854 ;; so they're roots.
2855 (setq threads (append (cdr (symbol-value refs)) threads))))
2856 gnus-newsgroup-dependencies)))
2859 ;; Build the thread tree.
2860 (defun gnus-dependencies-add-header (header dependencies force-new)
2861 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2863 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2864 if it was already present.
2866 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2867 will not be entered in the DEPENDENCIES table. Otherwise duplicate
2868 Message-IDs will be renamed be renamed to a unique Message-ID before
2871 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2872 (let* ((id (mail-header-id header))
2873 (id-dep (and id (intern id dependencies)))
2874 ref ref-dep ref-header)
2875 ;; Enter this `header' in the `dependencies' table.
2879 ;; The first two cases do the normal part: enter a new `header'
2880 ;; in the `dependencies' table.
2881 ((not (boundp id-dep))
2882 (set id-dep (list header)))
2883 ((null (car (symbol-value id-dep)))
2884 (setcar (symbol-value id-dep) header))
2886 ;; From here the `header' was already present in the
2887 ;; `dependencies' table.
2889 ;; Overrides an existing entry;
2890 ;; just set the header part of the entry.
2891 (setcar (symbol-value id-dep) header))
2893 ;; Renames the existing `header' to a unique Message-ID.
2894 ((not gnus-summary-ignore-duplicates)
2895 ;; An article with this Message-ID has already been seen.
2896 ;; We rename the Message-ID.
2897 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2899 (mail-header-set-id header id))
2901 ;; The last case ignores an existing entry, except it adds any
2902 ;; additional Xrefs (in case the two articles came from different
2904 ;; Also sets `header' to `nil' meaning that the `dependencies'
2905 ;; table was *not* modified.
2907 (mail-header-set-xref
2908 (car (symbol-value id-dep))
2909 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2911 (or (mail-header-xref header) "")))
2915 ;; First check if that we are not creating a References loop.
2916 (setq ref (gnus-parent-id (mail-header-references header)))
2918 (setq ref-dep (intern-soft ref dependencies))
2920 (setq ref-header (car (symbol-value ref-dep))))
2921 (if (string= id ref)
2922 ;; Yuk! This is a reference loop. Make the article be a
2926 (mail-header-set-references (car (symbol-value id-dep)) "none")
2928 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2929 (setq ref (gnus-parent-id (mail-header-references header)))
2930 (setq ref-dep (intern (or ref "none") dependencies))
2931 (if (boundp ref-dep)
2932 (setcdr (symbol-value ref-dep)
2933 (nconc (cdr (symbol-value ref-dep))
2934 (list (symbol-value id-dep))))
2935 (set ref-dep (list nil (symbol-value id-dep)))))
2938 (defun gnus-build-sparse-threads ()
2939 (let ((headers gnus-newsgroup-headers)
2940 header references generation relations
2941 cthread subject child end pthread relation new-child date)
2942 ;; First we create an alist of generations/relations, where
2943 ;; generations is how much we trust the relation, and the relation
2945 (gnus-message 7 "Making sparse threads...")
2947 (nnheader-set-temp-buffer " *gnus sparse threads*")
2948 (while (setq header (pop headers))
2949 (when (and (setq references (mail-header-references header))
2950 (not (string= references "")))
2952 (setq child (mail-header-id header)
2953 subject (mail-header-subject header)
2954 date (mail-header-date header)
2956 (while (search-backward ">" nil t)
2957 (setq end (1+ (point)))
2958 (if (search-backward "<" nil t)
2959 (push (list (incf generation)
2960 child (setq child new-child)
2963 (push (list (1+ generation) child nil subject) relations)
2965 (kill-buffer (current-buffer)))
2966 ;; Sort over trustworthiness.
2969 (when (gnus-dependencies-add-header
2970 (make-full-mail-header
2971 gnus-reffed-article-number
2972 (nth 3 relation) "" (nth 4 relation)
2974 (or (nth 2 relation) "") 0 0 "")
2975 gnus-newsgroup-dependencies nil)
2976 (push gnus-reffed-article-number gnus-newsgroup-limit)
2977 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2978 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2979 gnus-newsgroup-reads)
2980 (decf gnus-reffed-article-number)))
2981 (sort relations 'car-less-than-car))
2982 (gnus-message 7 "Making sparse threads...done")))
2984 (defun gnus-build-old-threads ()
2985 ;; Look at all the articles that refer back to old articles, and
2986 ;; fetch the headers for the articles that aren't there. This will
2987 ;; build complete threads - if the roots haven't been expired by the
2992 (when (not (car (symbol-value refs)))
2993 (setq heads (cdr (symbol-value refs)))
2995 (if (memq (mail-header-number (caar heads))
2996 gnus-newsgroup-dormant)
2997 (setq heads (cdr heads))
2998 (setq id (symbol-name refs))
2999 (while (and (setq id (gnus-build-get-header id))
3000 (not (car (gnus-id-to-thread id)))))
3001 (setq heads nil)))))
3002 gnus-newsgroup-dependencies)))
3004 ;; The following macros and functions were written by Felix Lee
3005 ;; <flee@cse.psu.edu>.
3007 (defmacro gnus-nov-read-integer ()
3009 (if (= (following-char) ?\t)
3011 (let ((num (ignore-errors (read buffer))))
3012 (if (numberp num) num 0)))
3014 (search-forward "\t" eol 'move))))
3016 (defmacro gnus-nov-skip-field ()
3017 '(search-forward "\t" eol 'move))
3019 (defmacro gnus-nov-field ()
3020 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3022 ;; This function has to be called with point after the article number
3023 ;; on the beginning of the line.
3024 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3025 (let ((eol (gnus-point-at-eol))
3026 (buffer (current-buffer))
3029 ;; overview: [num subject from date id refs chars lines misc]
3032 (narrow-to-region (point) eol)
3037 (make-full-mail-header
3040 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
3042 gnus-structured-field-decoder (gnus-nov-field)) ; from
3043 (gnus-nov-field) ; date
3044 (or (gnus-nov-field)
3045 (nnheader-generate-fake-message-id)) ; id
3046 (gnus-nov-field) ; refs
3047 (gnus-nov-read-integer) ; chars
3048 (gnus-nov-read-integer) ; lines
3049 (unless (= (following-char) ?\n)
3050 (gnus-nov-field))))) ; misc
3054 (when gnus-alter-header-function
3055 (funcall gnus-alter-header-function header))
3056 (gnus-dependencies-add-header header dependencies force-new)))
3058 (defun gnus-build-get-header (id)
3059 ;; Look through the buffer of NOV lines and find the header to
3060 ;; ID. Enter this line into the dependencies hash table, and return
3061 ;; the id of the parent article (if any).
3062 (let ((deps gnus-newsgroup-dependencies)
3066 (set-buffer nntp-server-buffer)
3067 (let ((case-fold-search nil))
3068 (goto-char (point-min))
3069 (while (and (not found)
3070 (search-forward id nil t))
3072 (setq found (looking-at
3073 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3074 (regexp-quote id))))
3075 (or found (beginning-of-line 2)))
3079 (setq header (gnus-nov-parse-line
3080 (read (current-buffer)) deps))
3081 (gnus-parent-id (mail-header-references header))))))
3083 (let ((number (mail-header-number header)))
3084 (push number gnus-newsgroup-limit)
3085 (push header gnus-newsgroup-headers)
3086 (if (memq number gnus-newsgroup-unselected)
3088 (push number gnus-newsgroup-unreads)
3089 (setq gnus-newsgroup-unselected
3090 (delq number gnus-newsgroup-unselected)))
3091 (push number gnus-newsgroup-ancient)))))))
3093 (defun gnus-build-all-threads ()
3094 "Read all the headers."
3095 (let ((gnus-summary-ignore-duplicates t)
3096 (dependencies gnus-newsgroup-dependencies)
3097 found header article)
3099 (set-buffer nntp-server-buffer)
3100 (let ((case-fold-search nil))
3101 (goto-char (point-min))
3104 (setq article (read (current-buffer))
3105 header (gnus-nov-parse-line
3106 article dependencies)))
3108 (push header gnus-newsgroup-headers)
3109 (if (memq (setq article (mail-header-number header))
3110 gnus-newsgroup-unselected)
3112 (push article gnus-newsgroup-unreads)
3113 (setq gnus-newsgroup-unselected
3114 (delq article gnus-newsgroup-unselected)))
3115 (push article gnus-newsgroup-ancient))
3116 (forward-line 1)))))))
3118 (defun gnus-summary-update-article-line (article header)
3119 "Update the line for ARTICLE using HEADERS."
3120 (let* ((id (mail-header-id header))
3121 (thread (gnus-id-to-thread id)))
3123 (error "Article in no thread"))
3124 ;; Update the thread.
3125 (setcar thread header)
3126 (gnus-summary-goto-subject article)
3127 (let* ((datal (gnus-data-find-list article))
3129 (length (when (cdr datal)
3130 (- (gnus-data-pos data)
3131 (gnus-data-pos (cadr datal)))))
3132 (buffer-read-only nil)
3133 (level (gnus-summary-thread-level)))
3135 (gnus-summary-insert-line
3136 header level nil (gnus-article-mark article)
3137 (memq article gnus-newsgroup-replied)
3138 (memq article gnus-newsgroup-expirable)
3139 ;; Only insert the Subject string when it's different
3140 ;; from the previous Subject string.
3141 (if (gnus-subject-equal
3143 (mail-header-subject
3146 (gnus-data-find-list
3148 (gnus-data-list t)))))
3149 ;; Error on the side of excessive subjects.
3151 (mail-header-subject header))
3153 (mail-header-subject header))
3154 nil (cdr (assq article gnus-newsgroup-scored))
3155 (memq article gnus-newsgroup-processable))
3157 (gnus-data-update-list
3158 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3160 (defun gnus-summary-update-article (article &optional iheader)
3161 "Update ARTICLE in the summary buffer."
3162 (set-buffer gnus-summary-buffer)
3163 (let* ((header (or iheader (gnus-summary-article-header article)))
3164 (id (mail-header-id header))
3165 (data (gnus-data-find article))
3166 (thread (gnus-id-to-thread id))
3167 (references (mail-header-references header))
3171 (when (and references
3172 (not (equal "" references)))
3175 (buffer-read-only nil)
3177 (number (mail-header-number header))
3180 ;; !!! Should this be in or not?
3182 (setcar thread nil))
3184 (delq thread parent))
3185 (if (gnus-summary-insert-subject id header iheader)
3186 ;; Set the (possibly) new article number in the data structure.
3187 (gnus-data-set-number data (gnus-id-to-article id))
3191 (defun gnus-rebuild-thread (id &optional line)
3192 "Rebuild the thread containing ID.
3193 If LINE, insert the rebuilt thread starting on line LINE."
3194 (let ((buffer-read-only nil)
3195 old-pos current thread data)
3196 (if (not gnus-show-threads)
3197 (setq thread (list (car (gnus-id-to-thread id))))
3198 ;; Get the thread this article is part of.
3199 (setq thread (gnus-remove-thread id)))
3200 (setq old-pos (gnus-point-at-bol))
3201 (setq current (save-excursion
3202 (and (zerop (forward-line -1))
3203 (gnus-summary-article-number))))
3204 ;; If this is a gathered thread, we have to go some re-gathering.
3205 (when (stringp (car thread))
3206 (let ((subject (car thread))
3208 (setq thread (cdr thread))
3210 (unless (memq (setq thr (gnus-id-to-thread
3212 (mail-header-id (caar thread)))))
3215 (setq thread (cdr thread)))
3216 ;; We now have all (unique) roots.
3217 (if (= (length roots) 1)
3218 ;; All the loose roots are now one solid root.
3219 (setq thread (car roots))
3220 (setq thread (cons subject (gnus-sort-threads roots))))))
3222 ;; We then insert this thread into the summary buffer.
3224 (goto-char (point-min))
3225 (forward-line (1- line)))
3226 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3227 (if gnus-show-threads
3228 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3229 (gnus-summary-prepare-unthreaded thread))
3230 (setq data (nreverse gnus-newsgroup-data))
3231 (setq threads gnus-newsgroup-threads))
3232 ;; We splice the new data into the data structure.
3233 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3234 ;;!!! then we want to insert at the beginning of the buffer.
3235 ;;!!! That happens to be true with Gnus now, but that may
3236 ;;!!! change in the future. Perhaps.
3237 (gnus-data-enter-list (if line nil current) data (- (point) old-pos))
3238 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads))
3240 (gnus-data-compute-positions)))))
3242 (defun gnus-number-to-header (number)
3243 "Return the header for article NUMBER."
3244 (let ((headers gnus-newsgroup-headers))
3246 (not (= number (mail-header-number (car headers)))))
3251 (defun gnus-parent-headers (in-headers &optional generation)
3252 "Return the headers of the GENERATIONeth parent of HEADERS."
3254 (setq generation 1))
3256 (headers in-headers)
3260 (not (zerop generation))
3261 (setq references (mail-header-references headers)))
3262 (when (and references
3263 (setq parent (gnus-parent-id references))
3264 (setq headers (car (gnus-id-to-thread parent))))
3266 (and (not (eq headers in-headers))
3269 (defun gnus-id-to-thread (id)
3270 "Return the (sub-)thread where ID appears."
3271 (gnus-gethash id gnus-newsgroup-dependencies))
3273 (defun gnus-id-to-article (id)
3274 "Return the article number of ID."
3275 (let ((thread (gnus-id-to-thread id)))
3278 (mail-header-number (car thread)))))
3280 (defun gnus-id-to-header (id)
3281 "Return the article headers of ID."
3282 (car (gnus-id-to-thread id)))
3284 (defun gnus-article-displayed-root-p (article)
3285 "Say whether ARTICLE is a root(ish) article."
3286 (let ((level (gnus-summary-thread-level article))
3287 (refs (mail-header-references (gnus-summary-article-header article)))
3293 ((null (gnus-parent-id refs)) t)
3295 (null (setq particle (gnus-id-to-article
3296 (gnus-parent-id refs))))
3297 (null (gnus-summary-thread-level particle)))))))
3299 (defun gnus-root-id (id)
3300 "Return the id of the root of the thread where ID appears."
3302 (while (and id (setq prev (car (gnus-id-to-thread id))))
3304 id (gnus-parent-id (mail-header-references prev))))
3307 (defun gnus-articles-in-thread (thread)
3308 "Return the list of articles in THREAD."
3309 (cons (mail-header-number (car thread))
3310 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3312 (defun gnus-remove-thread (id &optional dont-remove)
3313 "Remove the thread that has ID in it."
3314 (let (headers thread last-id)
3315 ;; First go up in this thread until we find the root.
3316 (setq last-id (gnus-root-id id))
3317 (setq headers (list (car (gnus-id-to-thread last-id))
3318 (caadr (gnus-id-to-thread last-id))))
3319 ;; We have now found the real root of this thread. It might have
3320 ;; been gathered into some loose thread, so we have to search
3321 ;; through the threads to find the thread we wanted.
3322 (let ((threads gnus-newsgroup-threads)
3325 (setq sub (car threads))
3326 (if (stringp (car sub))
3327 ;; This is a gathered thread, so we look at the roots
3328 ;; below it to find whether this article is in this
3331 (setq sub (cdr sub))
3333 (when (member (caar sub) headers)
3334 (setq thread (car threads)
3337 (setq sub (cdr sub))))
3338 ;; It's an ordinary thread, so we check it.
3339 (when (eq (car sub) (car headers))
3342 (setq threads (cdr threads)))
3343 ;; If this article is in no thread, then it's a root.
3346 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3347 (setq thread (gnus-id-to-thread last-id)))
3350 thread ; We return this thread.
3352 (if (stringp (car thread))
3354 ;; If we use dummy roots, then we have to remove the
3355 ;; dummy root as well.
3356 (when (eq gnus-summary-make-false-root 'dummy)
3357 ;; We go to the dummy root by going to
3358 ;; the first sub-"thread", and then one line up.
3359 (gnus-summary-goto-article
3360 (mail-header-number (caadr thread)))
3363 (gnus-data-compute-positions))
3364 (setq thread (cdr thread))
3366 (gnus-remove-thread-1 (car thread))
3367 (setq thread (cdr thread))))
3368 (gnus-remove-thread-1 thread))))))))
3370 (defun gnus-remove-thread-1 (thread)
3371 "Remove the thread THREAD recursively."
3372 (let ((number (mail-header-number (pop thread)))
3374 (setq thread (reverse thread))
3376 (gnus-remove-thread-1 (pop thread)))
3377 (when (setq d (gnus-data-find number))
3378 (goto-char (gnus-data-pos d))
3381 (- (gnus-point-at-bol)
3383 (1+ (gnus-point-at-eol))
3384 (gnus-delete-line)))))))
3386 (defun gnus-sort-threads (threads)
3388 (if (not gnus-thread-sort-functions)
3390 (gnus-message 7 "Sorting threads...")
3392 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3393 (gnus-message 7 "Sorting threads...done"))))
3395 (defun gnus-sort-articles (articles)
3397 (when gnus-article-sort-functions
3398 (gnus-message 7 "Sorting articles...")
3400 (setq gnus-newsgroup-headers
3401 (sort articles (gnus-make-sort-function
3402 gnus-article-sort-functions)))
3403 (gnus-message 7 "Sorting articles...done"))))
3405 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3406 (defmacro gnus-thread-header (thread)
3407 ;; Return header of first article in THREAD.
3408 ;; Note that THREAD must never, ever be anything else than a variable -
3409 ;; using some other form will lead to serious barfage.
3410 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3411 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3412 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3415 (defsubst gnus-article-sort-by-number (h1 h2)
3416 "Sort articles by article number."
3417 (< (mail-header-number h1)
3418 (mail-header-number h2)))
3420 (defun gnus-thread-sort-by-number (h1 h2)
3421 "Sort threads by root article number."
3422 (gnus-article-sort-by-number
3423 (gnus-thread-header h1) (gnus-thread-header h2)))
3425 (defsubst gnus-article-sort-by-lines (h1 h2)
3426 "Sort articles by article Lines header."
3427 (< (mail-header-lines h1)
3428 (mail-header-lines h2)))
3430 (defun gnus-thread-sort-by-lines (h1 h2)
3431 "Sort threads by root article Lines header."
3432 (gnus-article-sort-by-lines
3433 (gnus-thread-header h1) (gnus-thread-header h2)))
3435 (defsubst gnus-article-sort-by-author (h1 h2)
3436 "Sort articles by root author."
3438 (let ((extract (funcall
3439 gnus-extract-address-components
3440 (mail-header-from h1))))
3441 (or (car extract) (cadr extract) ""))
3442 (let ((extract (funcall
3443 gnus-extract-address-components
3444 (mail-header-from h2))))
3445 (or (car extract) (cadr extract) ""))))
3447 (defun gnus-thread-sort-by-author (h1 h2)
3448 "Sort threads by root author."
3449 (gnus-article-sort-by-author
3450 (gnus-thread-header h1) (gnus-thread-header h2)))
3452 (defsubst gnus-article-sort-by-subject (h1 h2)
3453 "Sort articles by root subject."
3455 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3456 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3458 (defun gnus-thread-sort-by-subject (h1 h2)
3459 "Sort threads by root subject."
3460 (gnus-article-sort-by-subject
3461 (gnus-thread-header h1) (gnus-thread-header h2)))
3463 (defsubst gnus-article-sort-by-date (h1 h2)
3464 "Sort articles by root article date."
3466 (gnus-date-get-time (mail-header-date h1))
3467 (gnus-date-get-time (mail-header-date h2))))
3469 (defun gnus-thread-sort-by-date (h1 h2)
3470 "Sort threads by root article date."
3471 (gnus-article-sort-by-date
3472 (gnus-thread-header h1) (gnus-thread-header h2)))
3474 (defsubst gnus-article-sort-by-score (h1 h2)
3475 "Sort articles by root article score.
3476 Unscored articles will be counted as having a score of zero."
3477 (> (or (cdr (assq (mail-header-number h1)
3478 gnus-newsgroup-scored))
3479 gnus-summary-default-score 0)
3480 (or (cdr (assq (mail-header-number h2)
3481 gnus-newsgroup-scored))
3482 gnus-summary-default-score 0)))
3484 (defun gnus-thread-sort-by-score (h1 h2)
3485 "Sort threads by root article score."
3486 (gnus-article-sort-by-score
3487 (gnus-thread-header h1) (gnus-thread-header h2)))
3489 (defun gnus-thread-sort-by-total-score (h1 h2)
3490 "Sort threads by the sum of all scores in the thread.
3491 Unscored articles will be counted as having a score of zero."
3492 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3494 (defun gnus-thread-total-score (thread)
3495 ;; This function find the total score of THREAD.
3496 (cond ((null thread)
3499 (if (stringp (car thread))
3500 (apply gnus-thread-score-function 0
3501 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3502 (gnus-thread-total-score-1 thread)))
3504 (gnus-thread-total-score-1 (list thread)))))
3506 (defun gnus-thread-total-score-1 (root)
3507 ;; This function find the total score of the thread below ROOT.
3508 (setq root (car root))
3509 (apply gnus-thread-score-function
3511 (mapcar 'gnus-thread-total-score
3512 (cdr (gnus-id-to-thread (mail-header-id root))))
3513 (when (> (mail-header-number root) 0)
3514 (list (or (cdr (assq (mail-header-number root)
3515 gnus-newsgroup-scored))
3516 gnus-summary-default-score 0))))
3517 (list gnus-summary-default-score)
3520 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3521 (defvar gnus-tmp-prev-subject nil)
3522 (defvar gnus-tmp-false-parent nil)
3523 (defvar gnus-tmp-root-expunged nil)
3524 (defvar gnus-tmp-dummy-line nil)
3526 (defun gnus-summary-prepare-threads (threads)
3527 "Prepare summary buffer from THREADS and indentation LEVEL.
3528 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3529 or a straight list of headers."
3530 (gnus-message 7 "Generating summary...")
3532 (setq gnus-newsgroup-threads threads)
3535 (let ((gnus-tmp-level 0)
3536 (default-score (or gnus-summary-default-score 0))
3537 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3538 thread number subject stack state gnus-tmp-gathered beg-match
3539 new-roots gnus-tmp-new-adopts thread-end
3540 gnus-tmp-header gnus-tmp-unread
3541 gnus-tmp-replied gnus-tmp-subject-or-nil
3542 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3543 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3544 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3546 (setq gnus-tmp-prev-subject nil)
3548 (if (vectorp (car threads))
3549 ;; If this is a straight (sic) list of headers, then a
3550 ;; threaded summary display isn't required, so we just create
3551 ;; an unthreaded one.
3552 (gnus-summary-prepare-unthreaded threads)
3554 ;; Do the threaded display.
3556 (while (or threads stack gnus-tmp-new-adopts new-roots)
3558 (if (and (= gnus-tmp-level 0)
3561 (not gnus-tmp-false-parent)
3562 (or gnus-tmp-new-adopts new-roots))
3563 (if gnus-tmp-new-adopts
3564 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3565 thread (list (car gnus-tmp-new-adopts))
3566 gnus-tmp-header (caar thread)
3567 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3569 (setq thread (list (car new-roots))
3570 gnus-tmp-header (caar thread)
3571 new-roots (cdr new-roots))))
3574 ;; If there are some threads, we do them before the
3575 ;; threads on the stack.
3576 (setq thread threads
3577 gnus-tmp-header (caar thread))
3578 ;; There were no current threads, so we pop something off
3580 (setq state (car stack)
3581 gnus-tmp-level (car state)
3584 gnus-tmp-header (caar thread))))
3586 (setq gnus-tmp-false-parent nil)
3587 (setq gnus-tmp-root-expunged nil)
3588 (setq thread-end nil)
3590 (if (stringp gnus-tmp-header)
3591 ;; The header is a dummy root.
3593 ((eq gnus-summary-make-false-root 'adopt)
3594 ;; We let the first article adopt the rest.
3595 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3597 (setq gnus-tmp-gathered
3599 (lambda (h) (mail-header-number (car h)))
3602 (setq thread (cons (list (caar thread)
3605 (setq gnus-tmp-level -1
3606 gnus-tmp-false-parent t))
3607 ((eq gnus-summary-make-false-root 'empty)
3608 ;; We print adopted articles with empty subject fields.
3609 (setq gnus-tmp-gathered
3611 (lambda (h) (mail-header-number (car h)))
3614 (setq gnus-tmp-level -1))
3615 ((eq gnus-summary-make-false-root 'dummy)
3616 ;; We remember that we probably want to output a dummy
3618 (setq gnus-tmp-dummy-line gnus-tmp-header)
3619 (setq gnus-tmp-prev-subject gnus-tmp-header))
3621 ;; We do not make a root for the gathered
3622 ;; sub-threads at all.
3623 (setq gnus-tmp-level -1)))
3625 (setq number (mail-header-number gnus-tmp-header)
3626 subject (mail-header-subject gnus-tmp-header))
3629 ;; If the thread has changed subject, we might want to make
3630 ;; this subthread into a root.
3631 ((and (null gnus-thread-ignore-subject)
3632 (not (zerop gnus-tmp-level))
3633 gnus-tmp-prev-subject
3635 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3636 (setq new-roots (nconc new-roots (list (car thread)))
3638 gnus-tmp-header nil))
3639 ;; If the article lies outside the current limit,
3640 ;; then we do not display it.
3641 ((not (memq number gnus-newsgroup-limit))
3642 (setq gnus-tmp-gathered
3644 (lambda (h) (mail-header-number (car h)))
3647 (setq gnus-tmp-new-adopts (if (cdar thread)
3648 (append gnus-tmp-new-adopts
3650 gnus-tmp-new-adopts)
3652 gnus-tmp-header nil)
3653 (when (zerop gnus-tmp-level)
3654 (setq gnus-tmp-root-expunged t)))
3655 ;; Perhaps this article is to be marked as read?
3656 ((and gnus-summary-mark-below
3657 (< (or (cdr (assq number gnus-newsgroup-scored))
3659 gnus-summary-mark-below)
3660 ;; Don't touch sparse articles.
3661 (not (gnus-summary-article-sparse-p number))
3662 (not (gnus-summary-article-ancient-p number)))
3663 (setq gnus-newsgroup-unreads
3664 (delq number gnus-newsgroup-unreads))
3665 (if gnus-newsgroup-auto-expire
3666 (push number gnus-newsgroup-expirable)
3667 (push (cons number gnus-low-score-mark)
3668 gnus-newsgroup-reads))))
3670 (when gnus-tmp-header
3671 ;; We may have an old dummy line to output before this
3673 (when (and gnus-tmp-dummy-line
3676 (mail-header-subject gnus-tmp-header)))
3677 (gnus-summary-insert-dummy-line
3678 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3679 (setq gnus-tmp-dummy-line nil))
3681 ;; Compute the mark.
3682 (setq gnus-tmp-unread (gnus-article-mark number))
3684 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3685 gnus-tmp-header gnus-tmp-level)
3686 gnus-newsgroup-data)
3688 ;; Actually insert the line.
3690 gnus-tmp-subject-or-nil
3692 ((and gnus-thread-ignore-subject
3693 gnus-tmp-prev-subject
3694 (not (inline (gnus-subject-equal
3695 gnus-tmp-prev-subject subject))))
3697 ((zerop gnus-tmp-level)
3698 (if (and (eq gnus-summary-make-false-root 'empty)
3699 (memq number gnus-tmp-gathered)
3700 gnus-tmp-prev-subject
3701 (inline (gnus-subject-equal
3702 gnus-tmp-prev-subject subject)))
3703 gnus-summary-same-subject
3705 (t gnus-summary-same-subject)))
3706 (if (and (eq gnus-summary-make-false-root 'adopt)
3707 (= gnus-tmp-level 1)
3708 (memq number gnus-tmp-gathered))
3709 (setq gnus-tmp-opening-bracket ?\<
3710 gnus-tmp-closing-bracket ?\>)
3711 (setq gnus-tmp-opening-bracket ?\[
3712 gnus-tmp-closing-bracket ?\]))
3714 gnus-tmp-indentation
3715 (aref gnus-thread-indent-array gnus-tmp-level)
3716 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3717 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3718 gnus-summary-default-score 0)
3720 (if (or (null gnus-summary-default-score)
3721 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3722 gnus-summary-zcore-fuzz))
3724 (if (< gnus-tmp-score gnus-summary-default-score)
3725 gnus-score-below-mark gnus-score-over-mark))
3727 (cond ((memq number gnus-newsgroup-processable)
3729 ((memq number gnus-newsgroup-cached)
3731 ((memq number gnus-newsgroup-replied)
3733 ((memq number gnus-newsgroup-saved)
3735 (t gnus-unread-mark))
3736 gnus-tmp-from (mail-header-from gnus-tmp-header)
3739 ((string-match "<[^>]+> *$" gnus-tmp-from)
3740 (setq beg-match (match-beginning 0))
3741 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3742 (substring gnus-tmp-from (1+ (match-beginning 0))
3743 (1- (match-end 0))))
3744 (substring gnus-tmp-from 0 beg-match)))
3745 ((string-match "(.+)" gnus-tmp-from)
3746 (substring gnus-tmp-from
3747 (1+ (match-beginning 0)) (1- (match-end 0))))
3749 (when (string= gnus-tmp-name "")
3750 (setq gnus-tmp-name gnus-tmp-from))
3751 (unless (numberp gnus-tmp-lines)
3752 (setq gnus-tmp-lines 0))
3753 (gnus-put-text-property
3755 (progn (eval gnus-summary-line-format-spec) (point))
3756 'gnus-number number)
3759 (gnus-run-hooks 'gnus-summary-update-hook)
3762 (setq gnus-tmp-prev-subject subject)))
3764 (when (nth 1 thread)
3765 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3766 (incf gnus-tmp-level)
3767 (setq threads (if thread-end nil (cdar thread)))
3769 (setq gnus-tmp-level 0)))))
3770 (gnus-message 7 "Generating summary...done"))
3772 (defun gnus-summary-prepare-unthreaded (headers)
3773 "Generate an unthreaded summary buffer based on HEADERS."
3774 (let (header number mark)
3779 ;; We may have to root out some bad articles...
3780 (when (memq (setq number (mail-header-number
3781 (setq header (pop headers))))
3782 gnus-newsgroup-limit)
3783 ;; Mark article as read when it has a low score.
3784 (when (and gnus-summary-mark-below
3785 (< (or (cdr (assq number gnus-newsgroup-scored))
3786 gnus-summary-default-score 0)
3787 gnus-summary-mark-below)
3788 (not (gnus-summary-article-ancient-p number)))
3789 (setq gnus-newsgroup-unreads
3790 (delq number gnus-newsgroup-unreads))
3791 (if gnus-newsgroup-auto-expire
3792 (push number gnus-newsgroup-expirable)
3793 (push (cons number gnus-low-score-mark)
3794 gnus-newsgroup-reads)))
3796 (setq mark (gnus-article-mark number))
3797 (push (gnus-data-make number mark (1+ (point)) header 0)
3798 gnus-newsgroup-data)
3799 (gnus-summary-insert-line
3801 mark (memq number gnus-newsgroup-replied)
3802 (memq number gnus-newsgroup-expirable)
3803 (mail-header-subject header) nil
3804 (cdr (assq number gnus-newsgroup-scored))
3805 (memq number gnus-newsgroup-processable))))))
3807 (defun gnus-select-newsgroup (group &optional read-all)
3808 "Select newsgroup GROUP.
3809 If READ-ALL is non-nil, all articles in the group are selected."
3810 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3811 ;;!!! Dirty hack; should be removed.
3812 (gnus-summary-ignore-duplicates
3813 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3815 gnus-summary-ignore-duplicates))
3816 (info (nth 2 entry))
3817 articles fetched-articles cached)
3819 (unless (gnus-check-server
3820 (setq gnus-current-select-method
3821 (gnus-find-method-for-group group)))
3822 (error "Couldn't open server"))
3824 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3825 (gnus-activate-group group) ; Or we can activate it...
3826 (progn ; Or we bug out.
3827 (when (equal major-mode 'gnus-summary-mode)
3828 (kill-buffer (current-buffer)))
3829 (error "Couldn't request group %s: %s"
3830 group (gnus-status-message group))))
3832 (unless (gnus-request-group group t)
3833 (when (equal major-mode 'gnus-summary-mode)
3834 (kill-buffer (current-buffer)))
3835 (error "Couldn't request group %s: %s"
3836 group (gnus-status-message group)))
3838 (setq gnus-newsgroup-name group)
3839 (setq gnus-newsgroup-unselected nil)
3840 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3842 ;; Adjust and set lists of article marks.
3844 (gnus-adjust-marked-articles info))
3846 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3847 (when (gnus-virtual-group-p group)
3848 (setq cached gnus-newsgroup-cached))
3850 (setq gnus-newsgroup-unreads
3851 (gnus-set-difference
3852 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3853 gnus-newsgroup-dormant))
3855 (setq gnus-newsgroup-processable nil)
3857 (gnus-update-read-articles group gnus-newsgroup-unreads)
3858 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3859 (gnus-group-update-group group))
3861 (setq articles (gnus-articles-to-read group read-all))
3865 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3867 ((eq articles 0) nil)
3869 ;; Init the dependencies hash table.
3870 (setq gnus-newsgroup-dependencies
3871 (gnus-make-hashtable (length articles)))
3872 ;; Retrieve the headers and read them in.
3873 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3874 (setq gnus-newsgroup-headers
3876 (setq gnus-headers-retrieved-by
3877 (gnus-retrieve-headers
3878 articles gnus-newsgroup-name
3879 ;; We might want to fetch old headers, but
3880 ;; not if there is only 1 article.
3882 (not (eq gnus-fetch-old-headers 'some))
3883 (not (numberp gnus-fetch-old-headers)))
3884 (> (length articles) 1))
3885 gnus-fetch-old-headers))))
3886 (gnus-get-newsgroup-headers-xover
3887 articles nil nil gnus-newsgroup-name t)
3888 (gnus-get-newsgroup-headers)))
3889 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3891 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3893 (setq gnus-newsgroup-cached cached))
3895 ;; Suppress duplicates?
3896 (when gnus-suppress-duplicates
3897 (gnus-dup-suppress-articles))
3899 ;; Set the initial limit.
3900 (setq gnus-newsgroup-limit (copy-sequence articles))
3901 ;; Remove canceled articles from the list of unread articles.
3902 (setq gnus-newsgroup-unreads
3903 (gnus-set-sorted-intersection
3904 gnus-newsgroup-unreads
3905 (setq fetched-articles
3906 (mapcar (lambda (headers) (mail-header-number headers))
3907 gnus-newsgroup-headers))))
3908 ;; Removed marked articles that do not exist.
3909 (gnus-update-missing-marks
3910 (gnus-sorted-complement fetched-articles articles))
3911 ;; Let the Gnus agent mark articles as read.
3913 (gnus-agent-get-undownloaded-list))
3914 ;; We might want to build some more threads first.
3915 (when (and gnus-fetch-old-headers
3916 (eq gnus-headers-retrieved-by 'nov))
3917 (if (eq gnus-fetch-old-headers 'invisible)
3918 (gnus-build-all-threads)
3919 (gnus-build-old-threads)))
3920 ;; Check whether auto-expire is to be done in this group.
3921 (setq gnus-newsgroup-auto-expire
3922 (gnus-group-auto-expirable-p group))
3923 ;; Set up the article buffer now, if necessary.
3924 (unless gnus-single-article-buffer
3925 (gnus-article-setup-buffer))
3926 ;; First and last article in this newsgroup.
3927 (when gnus-newsgroup-headers
3928 (setq gnus-newsgroup-begin
3929 (mail-header-number (car gnus-newsgroup-headers))
3932 (gnus-last-element gnus-newsgroup-headers))))
3933 ;; GROUP is successfully selected.
3934 (or gnus-newsgroup-headers t)))))
3936 (defun gnus-articles-to-read (group &optional read-all)
3937 ;; Find out what articles the user wants to read.
3939 ;; Select all articles if `read-all' is non-nil, or if there
3940 ;; are no unread articles.
3942 (and (zerop (length gnus-newsgroup-marked))
3943 (zerop (length gnus-newsgroup-unreads)))
3944 (eq (gnus-group-find-parameter group 'display)
3946 (gnus-uncompress-range (gnus-active group))
3947 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3948 (copy-sequence gnus-newsgroup-unreads))
3950 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3951 (scored (length scored-list))
3952 (number (length articles))
3953 (marked (+ (length gnus-newsgroup-marked)
3954 (length gnus-newsgroup-dormant)))
3962 ((and (or (<= scored marked) (= scored number))
3963 (numberp gnus-large-newsgroup)
3964 (> number gnus-large-newsgroup))
3968 "How many articles from %s (default %d): "
3969 (gnus-limit-string gnus-newsgroup-name 35)
3971 (if (string-match "^[ \t]*$" input) number input)))
3972 ((and (> scored marked) (< scored number)
3973 (> (- scored number) 20))
3976 (format "%s %s (%d scored, %d total): "
3977 "How many articles from"
3978 group scored number))))
3979 (if (string-match "^[ \t]*$" input)
3983 (setq select (if (stringp select) (string-to-number select) select))
3984 (if (or (null select) (zerop select))
3986 (if (and (not (zerop scored)) (<= (abs select) scored))
3988 (setq articles (sort scored-list '<))
3989 (setq number (length articles)))
3990 (setq articles (copy-sequence articles)))
3992 (when (< (abs select) number)
3994 ;; Select the N oldest articles.
3995 (setcdr (nthcdr (1- (abs select)) articles) nil)
3996 ;; Select the N most recent articles.
3997 (setq articles (nthcdr (- number select) articles))))
3998 (setq gnus-newsgroup-unselected
3999 (gnus-sorted-intersection
4000 gnus-newsgroup-unreads
4001 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4004 (defun gnus-killed-articles (killed articles)
4007 (when (inline (gnus-member-of-range (car articles) killed))
4008 (push (car articles) out))
4009 (setq articles (cdr articles)))
4012 (defun gnus-uncompress-marks (marks)
4013 "Uncompress the mark ranges in MARKS."
4014 (let ((uncompressed '(score bookmark))
4017 (if (memq (caar marks) uncompressed)
4018 (push (car marks) out)
4019 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4020 (setq marks (cdr marks)))
4023 (defun gnus-adjust-marked-articles (info)
4024 "Set all article lists and remove all marks that are no longer legal."
4025 (let* ((marked-lists (gnus-info-marks info))
4026 (active (gnus-active (gnus-info-group info)))
4029 (types gnus-article-mark-lists)
4030 (uncompressed '(score bookmark killed))
4031 marks var articles article mark)
4034 (setq marks (pop marked-lists))
4035 (set (setq var (intern (format "gnus-newsgroup-%s"
4036 (car (rassq (setq mark (car marks))
4038 (if (memq (car marks) uncompressed) (cdr marks)
4039 (gnus-uncompress-range (cdr marks))))
4041 (setq articles (symbol-value var))
4043 ;; All articles have to be subsets of the active articles.
4045 ;; Adjust "simple" lists.
4046 ((memq mark '(tick dormant expire reply save))
4048 (when (or (< (setq article (pop articles)) min) (> article max))
4049 (set var (delq article (symbol-value var))))))
4051 ((memq mark uncompressed)
4052 (when (not (listp (cdr (symbol-value var))))
4053 (set var (list (symbol-value var))))
4054 (when (not (listp (cdr articles)))
4055 (setq articles (list articles)))
4057 (when (or (not (consp (setq article (pop articles))))
4058 (< (car article) min)
4059 (> (car article) max))
4060 (set var (delq article (symbol-value var))))))))))
4062 (defun gnus-update-missing-marks (missing)
4063 "Go through the list of MISSING articles and remove them from the mark lists."
4065 (let ((types gnus-article-mark-lists)
4067 ;; Go through all types.
4069 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4070 (when (symbol-value var)
4071 ;; This list has articles. So we delete all missing articles
4075 (set var (delq (pop m) (symbol-value var)))))))))
4077 (defun gnus-update-marks ()
4078 "Enter the various lists of marked articles into the newsgroup info list."
4079 (let ((types gnus-article-mark-lists)
4080 (info (gnus-get-info gnus-newsgroup-name))
4081 (uncompressed '(score bookmark killed))
4082 type list newmarked symbol)
4084 ;; Add all marks lists that are non-nil to the list of marks lists.
4085 (while (setq type (pop types))
4086 (when (setq list (symbol-value
4088 (intern (format "gnus-newsgroup-%s"
4091 ;; Get rid of the entries of the articles that have the
4093 (when (and (eq (cdr type) 'score)
4097 (prev (cons nil list))
4100 (if (or (not (consp (car arts)))
4101 (= (cdar arts) gnus-summary-default-score))
4102 (setcdr prev (cdr arts))
4104 (setq arts (cdr arts)))
4105 (setq list (cdr all))))
4107 (push (cons (cdr type)
4108 (if (memq (cdr type) uncompressed) list
4109 (gnus-compress-sequence
4110 (set symbol (sort list '<)) t)))
4113 ;; Enter these new marks into the info of the group.
4115 (setcar (nthcdr 3 info) newmarked)
4116 ;; Add the marks lists to the end of the info.
4118 (setcdr (nthcdr 2 info) (list newmarked))))
4120 ;; Cut off the end of the info if there's nothing else there.
4124 (when (nthcdr (decf i) info)
4125 (setcdr (nthcdr i info) nil)))))))
4127 (defun gnus-set-mode-line (where)
4128 "This function sets the mode line of the article or summary buffers.
4129 If WHERE is `summary', the summary mode line format will be used."
4130 ;; Is this mode line one we keep updated?
4131 (when (memq where gnus-updated-mode-lines)
4134 ;; We evaluate this in the summary buffer since these
4135 ;; variables are buffer-local to that buffer.
4136 (set-buffer gnus-summary-buffer)
4137 ;; We bind all these variables that are used in the `eval' form
4139 (let* ((mformat (symbol-value
4141 (format "gnus-%s-mode-line-format-spec" where))))
4142 (gnus-tmp-group-name gnus-newsgroup-name)
4143 (gnus-tmp-article-number (or gnus-current-article 0))
4144 (gnus-tmp-unread gnus-newsgroup-unreads)
4145 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4146 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4147 (gnus-tmp-unread-and-unselected
4148 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4149 (zerop gnus-tmp-unselected))
4151 ((zerop gnus-tmp-unselected)
4152 (format "{%d more}" gnus-tmp-unread-and-unticked))
4153 (t (format "{%d(+%d) more}"
4154 gnus-tmp-unread-and-unticked
4155 gnus-tmp-unselected))))
4157 (if (and gnus-current-headers
4158 (vectorp gnus-current-headers))
4159 (gnus-mode-string-quote
4160 (mail-header-subject gnus-current-headers))
4162 bufname-length max-len
4163 gnus-tmp-header);; passed as argument to any user-format-funcs
4164 (setq mode-string (eval mformat))
4165 (setq bufname-length (if (string-match "%b" mode-string)
4168 (if (eq where 'summary)
4170 (get-buffer gnus-article-buffer))))
4173 (setq max-len (max 4 (if gnus-mode-non-string-length
4175 gnus-mode-non-string-length
4177 (length mode-string))))
4178 ;; We might have to chop a bit of the string off...
4179 (when (> (length mode-string) max-len)
4181 (concat (gnus-truncate-string mode-string (- max-len 3))
4183 ;; Pad the mode string a bit.
4184 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4185 ;; Update the mode line.
4186 (setq mode-line-buffer-identification
4187 (gnus-mode-line-buffer-identification (list mode-string)))
4188 (set-buffer-modified-p t))))
4190 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4191 "Go through the HEADERS list and add all Xrefs to a hash table.
4192 The resulting hash table is returned, or nil if no Xrefs were found."
4193 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4194 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4195 (xref-hashtb (gnus-make-hashtable))
4196 start group entry number xrefs header)
4198 (setq header (pop headers))
4199 (when (and (setq xrefs (mail-header-xref header))
4200 (not (memq (setq number (mail-header-number header))
4203 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4204 (setq start (match-end 0))
4205 (setq group (if prefix
4206 (concat prefix (substring xrefs (match-beginning 1)
4208 (substring xrefs (match-beginning 1) (match-end 1))))
4210 (string-to-int (substring xrefs (match-beginning 2)
4212 (if (setq entry (gnus-gethash group xref-hashtb))
4213 (setcdr entry (cons number (cdr entry)))
4214 (gnus-sethash group (cons number nil) xref-hashtb)))))
4215 (and start xref-hashtb)))
4217 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4218 "Look through all the headers and mark the Xrefs as read."
4219 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4220 name entry info xref-hashtb idlist method nth4)
4222 (set-buffer gnus-group-buffer)
4223 (when (setq xref-hashtb
4224 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4227 (unless (string= from-newsgroup (setq name (symbol-name group)))
4228 (setq idlist (symbol-value group))
4229 ;; Dead groups are not updated.
4231 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4233 (when (stringp (setq nth4 (gnus-info-method info)))
4234 (setq nth4 (gnus-server-to-method nth4))))
4235 ;; Only do the xrefs if the group has the same
4236 ;; select method as the group we have just read.
4237 (or (gnus-methods-equal-p
4238 nth4 (gnus-find-method-for-group from-newsgroup))
4240 (equal nth4 (setq method (gnus-find-method-for-group
4242 (and (equal (car nth4) (car method))
4243 (equal (nth 1 nth4) (nth 1 method))))
4244 gnus-use-cross-reference
4245 (or (not (eq gnus-use-cross-reference t))
4247 ;; Only do cross-references on subscribed
4248 ;; groups, if that is what is wanted.
4249 (<= (gnus-info-level info) gnus-level-subscribed))
4250 (gnus-group-make-articles-read name idlist))))
4253 (defun gnus-compute-read-articles (group articles)
4254 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4255 (info (nth 2 entry))
4256 (active (gnus-active group))
4259 ;; First peel off all illegal article numbers.
4261 (let ((ids articles)
4263 (while (setq id (pop ids))
4264 (when (and first (> id (cdr active)))
4265 ;; We'll end up in this situation in one particular
4266 ;; obscure situation. If you re-scan a group and get
4267 ;; a new article that is cross-posted to a different
4268 ;; group that has not been re-scanned, you might get
4269 ;; crossposted article that has a higher number than
4270 ;; Gnus believes possible. So we re-activate this
4271 ;; group as well. This might mean doing the
4272 ;; crossposting thingy will *increase* the number
4273 ;; of articles in some groups. Tsk, tsk.
4274 (setq active (or (gnus-activate-group group) active)))
4275 (when (or (> id (cdr active))
4276 (< id (car active)))
4277 (setq articles (delq id articles))))))
4278 ;; If the read list is nil, we init it.
4280 (null (gnus-info-read info))
4282 (setq ninfo (cons 1 (1- (car active))))
4283 (setq ninfo (gnus-info-read info)))
4284 ;; Then we add the read articles to the range.
4286 ninfo (setq articles (sort articles '<))))))
4288 (defun gnus-group-make-articles-read (group articles)
4289 "Update the info of GROUP to say that ARTICLES are read."
4291 (entry (gnus-gethash group gnus-newsrc-hashtb))
4292 (info (nth 2 entry))
4293 (active (gnus-active group))
4296 (setq range (gnus-compute-read-articles group articles))
4298 (set-buffer gnus-group-buffer)
4301 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4302 (gnus-info-set-read ',info ',(gnus-info-read info))
4303 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4304 (gnus-group-update-group ,group t))))
4305 ;; Add the read articles to the range.
4306 (gnus-info-set-read info range)
4307 ;; Then we have to re-compute how many unread
4308 ;; articles there are in this group.
4312 (setq num (- (1+ (cdr active)) (car active))))
4313 ((not (listp (cdr range)))
4314 (setq num (- (cdr active) (- (1+ (cdr range))
4318 (if (numberp (car range))
4320 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4321 (setq range (cdr range)))
4322 (setq num (- (cdr active) num))))
4323 ;; Update the number of unread articles.
4325 ;; Update the group buffer.
4326 (gnus-group-update-group group t)))))
4328 (defun gnus-methods-equal-p (m1 m2)
4329 (let ((m1 (or m1 gnus-select-method))
4330 (m2 (or m2 gnus-select-method)))
4332 (and (eq (car m1) (car m2))
4333 (or (not (memq 'address (assoc (symbol-name (car m1))
4334 gnus-valid-select-methods)))
4335 (equal (nth 1 m1) (nth 1 m2)))))))
4337 (defvar gnus-newsgroup-none-id 0)
4339 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4340 (let ((cur nntp-server-buffer)
4343 (save-excursion (set-buffer gnus-summary-buffer)
4344 gnus-newsgroup-dependencies)))
4345 headers id id-dep ref-dep end ref)
4347 (set-buffer nntp-server-buffer)
4348 ;; Translate all TAB characters into SPACE characters.
4349 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4350 (gnus-run-hooks 'gnus-parse-headers-hook)
4351 (let ((case-fold-search t)
4352 in-reply-to header p lines)
4353 (goto-char (point-min))
4354 ;; Search to the beginning of the next header. Error messages
4355 ;; do not begin with 2 or 3.
4356 (while (re-search-forward "^[23][0-9]+ " nil t)
4359 ;; This implementation of this function, with nine
4360 ;; search-forwards instead of the one re-search-forward and
4361 ;; a case (which basically was the old function) is actually
4362 ;; about twice as fast, even though it looks messier. You
4363 ;; can't have everything, I guess. Speed and elegance
4364 ;; doesn't always go hand in hand.
4373 (narrow-to-region (point)
4374 (or (and (search-forward "\n.\n" nil t)
4380 (if (search-forward "\nsubject: " nil t)
4382 gnus-unstructured-field-decoder (nnheader-header-value))
4387 (if (search-forward "\nfrom: " nil t)
4389 gnus-structured-field-decoder (nnheader-header-value))
4394 (if (search-forward "\ndate: " nil t)
4395 (nnheader-header-value) ""))
4399 (setq id (if (re-search-forward
4400 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4401 ;; We do it this way to make sure the Message-ID
4402 ;; is (somewhat) syntactically valid.
4403 (buffer-substring (match-beginning 1)
4405 ;; If there was no message-id, we just fake one
4406 ;; to make subsequent routines simpler.
4407 (nnheader-generate-fake-message-id))))
4411 (if (search-forward "\nreferences: " nil t)
4415 (nnheader-header-value)
4420 (search-backward ">" end t)
4423 (search-backward "<" end t)
4425 ;; Get the references from the in-reply-to header if there
4426 ;; were no references and the in-reply-to header looks
4428 (if (and (search-forward "\nin-reply-to: " nil t)
4429 (setq in-reply-to (nnheader-header-value))
4430 (string-match "<[^>]+>" in-reply-to))
4432 (setq ref (substring in-reply-to (match-beginning 0)
4434 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4435 (setq ref2 (substring in-reply-to (match-beginning 0)
4437 (when (> (length ref2) (length ref))
4445 (if (search-forward "\nlines: " nil t)
4446 (if (numberp (setq lines (ignore-errors (read cur))))
4452 (and (search-forward "\nxref: " nil t)
4453 (nnheader-header-value)))))
4454 (when (equal id ref)
4457 (when gnus-alter-header-function
4458 (funcall gnus-alter-header-function header)
4459 (setq id (mail-header-id header)
4460 ref (gnus-parent-id (mail-header-references header))))
4463 (gnus-dependencies-add-header
4464 header dependencies force-new))
4465 (push header headers))
4466 (goto-char (point-max))
4468 (nreverse headers)))))
4470 ;; Goes through the xover lines and returns a list of vectors
4471 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4472 force-new dependencies
4473 group also-fetch-heads)
4474 "Parse the news overview data in the server buffer, and return a
4475 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4476 ;; Get the Xref when the users reads the articles since most/some
4477 ;; NNTP servers do not include Xrefs when using XOVER.
4478 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4479 (let ((cur nntp-server-buffer)
4480 (dependencies (or dependencies gnus-newsgroup-dependencies))
4481 number headers header)
4483 (set-buffer nntp-server-buffer)
4484 ;; Allow the user to mangle the headers before parsing them.
4485 (gnus-run-hooks 'gnus-parse-headers-hook)
4486 (goto-char (point-min))
4489 (while (and sequence (not (eobp)))
4490 (setq number (read cur))
4491 (while (and sequence
4492 (< (car sequence) number))
4493 (setq sequence (cdr sequence)))
4495 (eq number (car sequence))
4497 (setq sequence (cdr sequence))
4498 (setq header (inline
4499 (gnus-nov-parse-line
4500 number dependencies force-new))))
4501 (push header headers))
4504 (gnus-error 4 "Strange nov line (%d)"
4505 (count-lines (point-min) (point)))))
4507 ;; A common bug in inn is that if you have posted an article and
4508 ;; then retrieves the active file, it will answer correctly --
4509 ;; the new article is included. However, a NOV entry for the
4510 ;; article may not have been generated yet, so this may fail.
4511 ;; We work around this problem by retrieving the last few
4512 ;; headers using HEAD.
4513 (if (or (not also-fetch-heads)
4515 ;; We (probably) got all the headers.
4517 (let ((gnus-nov-is-evil t))
4520 (when (gnus-retrieve-headers sequence group)
4521 (gnus-get-newsgroup-headers))))))))
4523 (defun gnus-article-get-xrefs ()
4524 "Fill in the Xref value in `gnus-current-headers', if necessary.
4525 This is meant to be called in `gnus-article-internal-prepare-hook'."
4526 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4527 gnus-current-headers)))
4528 (or (not gnus-use-cross-reference)
4530 (and (mail-header-xref headers)
4531 (not (string= (mail-header-xref headers) "")))
4532 (let ((case-fold-search t)
4535 (nnheader-narrow-to-headers)
4536 (goto-char (point-min))
4537 (when (or (and (eq (downcase (following-char)) ?x)
4538 (looking-at "Xref:"))
4539 (search-forward "\nXref:" nil t))
4540 (goto-char (1+ (match-end 0)))
4541 (setq xref (buffer-substring (point)
4542 (progn (end-of-line) (point))))
4543 (mail-header-set-xref headers xref)))))))
4545 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4546 "Find article ID and insert the summary line for that article.
4547 OLD-HEADER can either be a header or a line number to insert
4548 the subject line on."
4549 (let* ((line (and (numberp old-header) old-header))
4550 (old-header (and (vectorp old-header) old-header))
4551 (header (cond ((and old-header use-old-header)
4554 (gnus-number-to-header id))
4555 (gnus-number-to-header id))
4557 (gnus-read-header id))))
4558 (number (and (numberp id) id))
4561 ;; Rebuild the thread that this article is part of and go to the
4562 ;; article we have fetched.
4563 (when (and (not gnus-show-threads)
4566 (setq d (gnus-data-find (mail-header-number old-header))))
4567 (goto-char (gnus-data-pos d))
4570 (- (gnus-point-at-bol)
4572 (1+ (gnus-point-at-eol))
4573 (gnus-delete-line))))))
4575 (mail-header-set-number header (mail-header-number old-header)))
4576 (setq gnus-newsgroup-sparse
4577 (delq (setq number (mail-header-number header))
4578 gnus-newsgroup-sparse))
4579 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4580 (push number gnus-newsgroup-limit)
4581 (gnus-rebuild-thread (mail-header-id header) line)
4582 (gnus-summary-goto-subject number nil t))
4583 (when (and (numberp number)
4585 ;; We have to update the boundaries even if we can't fetch the
4586 ;; article if ID is a number -- so that the next `P' or `N'
4587 ;; command will fetch the previous (or next) article even
4588 ;; if the one we tried to fetch this time has been canceled.
4589 (when (> number gnus-newsgroup-end)
4590 (setq gnus-newsgroup-end number))
4591 (when (< number gnus-newsgroup-begin)
4592 (setq gnus-newsgroup-begin number))
4593 (setq gnus-newsgroup-unselected
4594 (delq number gnus-newsgroup-unselected)))
4595 ;; Report back a success?
4596 (and header (mail-header-number header))))
4598 ;;; Process/prefix in the summary buffer
4600 (defun gnus-summary-work-articles (n)
4601 "Return a list of articles to be worked upon.
4602 The prefix argument, the list of process marked articles, and the
4603 current article will be taken into consideration."
4605 (set-buffer gnus-summary-buffer)
4608 ;; A numerical prefix has been given.
4609 (setq n (prefix-numeric-value n))
4610 (let ((backward (< n 0))
4611 (n (abs (prefix-numeric-value n)))
4616 (push (setq article (gnus-summary-article-number))
4619 (gnus-summary-find-prev nil article)
4620 (gnus-summary-find-next nil article)))
4622 (nreverse articles)))
4623 ((and (gnus-region-active-p) (mark))
4624 (message "region active")
4625 ;; Work on the region between point and mark.
4626 (let ((max (max (point) (mark)))
4629 (goto-char (min (min (point) (mark))))
4632 (push (setq article (gnus-summary-article-number)) articles)
4633 (gnus-summary-find-next nil article)
4635 (nreverse articles))))
4636 (gnus-newsgroup-processable
4637 ;; There are process-marked articles present.
4638 ;; Save current state.
4639 (gnus-summary-save-process-mark)
4641 (reverse gnus-newsgroup-processable))
4643 ;; Just return the current article.
4644 (list (gnus-summary-article-number))))))
4646 (defun gnus-summary-save-process-mark ()
4647 "Push the current set of process marked articles on the stack."
4649 (push (copy-sequence gnus-newsgroup-processable)
4650 gnus-newsgroup-process-stack))
4652 (defun gnus-summary-kill-process-mark ()
4653 "Push the current set of process marked articles on the stack and unmark."
4655 (gnus-summary-save-process-mark)
4656 (gnus-summary-unmark-all-processable))
4658 (defun gnus-summary-yank-process-mark ()
4659 "Pop the last process mark state off the stack and restore it."
4661 (unless gnus-newsgroup-process-stack
4662 (error "Empty mark stack"))
4663 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4665 (defun gnus-summary-process-mark-set (set)
4666 "Make SET into the current process marked articles."
4667 (gnus-summary-unmark-all-processable)
4669 (gnus-summary-set-process-mark (pop set))))
4671 ;;; Searching and stuff
4673 (defun gnus-summary-search-group (&optional backward use-level)
4674 "Search for next unread newsgroup.
4675 If optional argument BACKWARD is non-nil, search backward instead."
4677 (set-buffer gnus-group-buffer)
4678 (when (gnus-group-search-forward
4679 backward nil (if use-level (gnus-group-group-level) nil))
4680 (gnus-group-group-name))))
4682 (defun gnus-summary-best-group (&optional exclude-group)
4683 "Find the name of the best unread group.
4684 If EXCLUDE-GROUP, do not go to this group."
4686 (set-buffer gnus-group-buffer)
4688 (gnus-group-best-unread-group exclude-group))))
4690 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4691 (if backward (gnus-summary-find-prev)
4692 (let* ((dummy (gnus-summary-article-intangible-p))
4693 (article (or article (gnus-summary-article-number)))
4694 (arts (gnus-data-find-list article))
4696 (when (and (not dummy)
4697 (or (not gnus-summary-check-current)
4699 (not (gnus-data-unread-p (car arts)))))
4700 (setq arts (cdr arts)))
4705 (when (or (and undownloaded
4706 (eq gnus-undownloaded-mark
4707 (gnus-data-mark (car arts))))
4708 (gnus-data-unread-p (car arts)))
4709 (setq result (car arts)
4711 (setq arts (cdr arts)))
4714 (goto-char (gnus-data-pos result))
4715 (gnus-data-number result)))))
4717 (defun gnus-summary-find-prev (&optional unread article)
4718 (let* ((eobp (eobp))
4719 (article (or article (gnus-summary-article-number)))
4720 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4722 (when (and (not eobp)
4723 (or (not gnus-summary-check-current)
4725 (not (gnus-data-unread-p (car arts)))))
4726 (setq arts (cdr arts)))
4731 (when (gnus-data-unread-p (car arts))
4732 (setq result (car arts)
4734 (setq arts (cdr arts)))
4737 (goto-char (gnus-data-pos result))
4738 (gnus-data-number result))))
4740 (defun gnus-summary-find-subject (subject &optional unread backward article)
4741 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4742 (article (or article (gnus-summary-article-number)))
4743 (articles (gnus-data-list backward))
4744 (arts (gnus-data-find-list article articles))
4746 (when (or (not gnus-summary-check-current)
4748 (not (gnus-data-unread-p (car arts))))
4749 (setq arts (cdr arts)))
4751 (and (or (not unread)
4752 (gnus-data-unread-p (car arts)))
4753 (vectorp (gnus-data-header (car arts)))
4755 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4756 (setq result (car arts)
4758 (setq arts (cdr arts)))
4760 (goto-char (gnus-data-pos result))
4761 (gnus-data-number result))))
4763 (defun gnus-summary-search-forward (&optional unread subject backward)
4764 "Search forward for an article.
4765 If UNREAD, look for unread articles. If SUBJECT, look for
4766 articles with that subject. If BACKWARD, search backward instead."
4767 (cond (subject (gnus-summary-find-subject subject unread backward))
4768 (backward (gnus-summary-find-prev unread))
4769 (t (gnus-summary-find-next unread))))
4771 (defun gnus-recenter (&optional n)
4772 "Center point in window and redisplay frame.
4773 Also do horizontal recentering."
4775 (when (and gnus-auto-center-summary
4776 (not (eq gnus-auto-center-summary 'vertical)))
4777 (gnus-horizontal-recenter))
4780 (defun gnus-summary-recenter ()
4781 "Center point in the summary window.
4782 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4783 displayed, no centering will be performed."
4784 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4785 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4786 (let* ((top (cond ((< (window-height) 4) 0)
4787 ((< (window-height) 7) 1)
4789 (height (1- (window-height)))
4790 (bottom (save-excursion (goto-char (point-max))
4791 (forward-line (- height))
4793 (window (get-buffer-window (current-buffer))))
4794 ;; The user has to want it.
4795 (when gnus-auto-center-summary
4796 (when (get-buffer-window gnus-article-buffer)
4797 ;; Only do recentering when the article buffer is displayed,
4798 ;; Set the window start to either `bottom', which is the biggest
4799 ;; possible valid number, or the second line from the top,
4800 ;; whichever is the least.
4802 window (min bottom (save-excursion
4803 (forward-line (- top)) (point)))))
4804 ;; Do horizontal recentering while we're at it.
4805 (when (and (get-buffer-window (current-buffer) t)
4806 (not (eq gnus-auto-center-summary 'vertical)))
4807 (let ((selected (selected-window)))
4808 (select-window (get-buffer-window (current-buffer) t))
4809 (gnus-summary-position-point)
4810 (gnus-horizontal-recenter)
4811 (select-window selected))))))
4813 (defun gnus-summary-jump-to-group (newsgroup)
4814 "Move point to NEWSGROUP in group mode buffer."
4815 ;; Keep update point of group mode buffer if visible.
4816 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4817 (save-window-excursion
4818 ;; Take care of tree window mode.
4819 (when (get-buffer-window gnus-group-buffer)
4820 (pop-to-buffer gnus-group-buffer))
4821 (gnus-group-jump-to-group newsgroup))
4823 ;; Take care of tree window mode.
4824 (if (get-buffer-window gnus-group-buffer)
4825 (pop-to-buffer gnus-group-buffer)
4826 (set-buffer gnus-group-buffer))
4827 (gnus-group-jump-to-group newsgroup))))
4829 ;; This function returns a list of article numbers based on the
4830 ;; difference between the ranges of read articles in this group and
4831 ;; the range of active articles.
4832 (defun gnus-list-of-unread-articles (group)
4833 (let* ((read (gnus-info-read (gnus-get-info group)))
4834 (active (or (gnus-active group) (gnus-activate-group group)))
4837 ;; If none are read, then all are unread.
4839 (setq first (car active))
4840 ;; If the range of read articles is a single range, then the
4841 ;; first unread article is the article after the last read
4842 ;; article. Sounds logical, doesn't it?
4843 (if (not (listp (cdr read)))
4844 (setq first (1+ (cdr read)))
4845 ;; `read' is a list of ranges.
4846 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4852 (while (< first nlast)
4854 (setq first (1+ first))))
4855 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4856 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4857 (setq read (cdr read)))))
4858 ;; And add the last unread articles.
4859 (while (<= first last)
4861 (setq first (1+ first)))
4862 ;; Return the list of unread articles.
4863 (delq 0 (nreverse unread))))
4865 (defun gnus-list-of-read-articles (group)
4866 "Return a list of unread, unticked and non-dormant articles."
4867 (let* ((info (gnus-get-info group))
4868 (marked (gnus-info-marks info))
4869 (active (gnus-active group)))
4871 (gnus-set-difference
4872 (gnus-sorted-complement
4873 (gnus-uncompress-range active)
4874 (gnus-list-of-unread-articles group))
4876 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4877 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4879 ;; Various summary commands
4881 (defun gnus-summary-select-article-buffer ()
4882 "Reconfigure windows to show article buffer."
4884 (if (not (gnus-buffer-live-p gnus-article-buffer))
4885 (error "There is no article buffer for this summary buffer")
4886 (gnus-configure-windows 'article)
4887 (select-window (get-buffer-window gnus-article-buffer))))
4889 (defun gnus-summary-universal-argument (arg)
4890 "Perform any operation on all articles that are process/prefixed."
4892 (let ((articles (gnus-summary-work-articles arg))
4899 (substitute-command-keys
4900 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4903 (gnus-error 1 "Undefined key")
4906 (gnus-summary-goto-subject (setq article (pop articles)))
4907 (let (gnus-newsgroup-processable)
4908 (command-execute func))
4909 (gnus-summary-remove-process-mark article)))))
4910 (gnus-summary-position-point))
4912 (defun gnus-summary-toggle-truncation (&optional arg)
4913 "Toggle truncation of summary lines.
4914 With arg, turn line truncation on iff arg is positive."
4916 (setq truncate-lines
4917 (if (null arg) (not truncate-lines)
4918 (> (prefix-numeric-value arg) 0)))
4921 (defun gnus-summary-reselect-current-group (&optional all rescan)
4922 "Exit and then reselect the current newsgroup.
4923 The prefix argument ALL means to select all articles."
4925 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4926 (error "Ephemeral groups can't be reselected"))
4927 (let ((current-subject (gnus-summary-article-number))
4928 (group gnus-newsgroup-name))
4929 (setq gnus-newsgroup-begin nil)
4931 ;; We have to adjust the point of group mode buffer because
4932 ;; point was moved to the next unread newsgroup by exiting.
4933 (gnus-summary-jump-to-group group)
4936 (gnus-group-get-new-news-this-group 1)))
4937 (gnus-group-read-group all t)
4938 (gnus-summary-goto-subject current-subject nil t)))
4940 (defun gnus-summary-rescan-group (&optional all)
4941 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4943 (gnus-summary-reselect-current-group all t))
4945 (defun gnus-summary-update-info (&optional non-destructive)
4947 (let ((group gnus-newsgroup-name))
4949 (when gnus-newsgroup-kill-headers
4950 (setq gnus-newsgroup-killed
4951 (gnus-compress-sequence
4953 (gnus-set-sorted-intersection
4954 (gnus-uncompress-range gnus-newsgroup-killed)
4955 (setq gnus-newsgroup-unselected
4956 (sort gnus-newsgroup-unselected '<)))
4957 (setq gnus-newsgroup-unreads
4958 (sort gnus-newsgroup-unreads '<)))
4960 (unless (listp (cdr gnus-newsgroup-killed))
4961 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4962 (let ((headers gnus-newsgroup-headers))
4963 ;; Set the new ranges of read articles.
4965 (set-buffer gnus-group-buffer)
4966 (gnus-undo-force-boundary))
4967 (gnus-update-read-articles
4968 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4969 ;; Set the current article marks.
4970 (let ((gnus-newsgroup-scored
4971 (if (and (not gnus-save-score)
4972 (not non-destructive))
4974 gnus-newsgroup-scored)))
4976 (gnus-update-marks)))
4977 ;; Do the cross-ref thing.
4978 (when gnus-use-cross-reference
4979 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4980 ;; Do not switch windows but change the buffer to work.
4981 (set-buffer gnus-group-buffer)
4982 (unless (gnus-ephemeral-group-p group)
4983 (gnus-group-update-group group)))))))
4985 (defun gnus-summary-save-newsrc (&optional force)
4986 "Save the current number of read/marked articles in the dribble buffer.
4987 The dribble buffer will then be saved.
4988 If FORCE (the prefix), also save the .newsrc file(s)."
4990 (gnus-summary-update-info t)
4992 (gnus-save-newsrc-file)
4993 (gnus-dribble-save)))
4995 (defun gnus-summary-exit (&optional temporary)
4996 "Exit reading current newsgroup, and then return to group selection mode.
4997 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4999 (gnus-set-global-variables)
5000 (gnus-kill-save-kill-buffer)
5001 (gnus-async-halt-prefetch)
5002 (let* ((group gnus-newsgroup-name)
5003 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5006 (buf (current-buffer)))
5007 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5008 ;; If we have several article buffers, we kill them at exit.
5009 (unless gnus-single-article-buffer
5010 (gnus-kill-buffer gnus-original-article-buffer)
5011 (setq gnus-article-current nil))
5012 (when gnus-use-cache
5013 (gnus-cache-possibly-remove-articles)
5014 (gnus-cache-save-buffers))
5015 (gnus-async-prefetch-remove-group group)
5016 (when gnus-suppress-duplicates
5017 (gnus-dup-enter-articles))
5018 (when gnus-use-trees
5019 (gnus-tree-close group))
5020 ;; Remove entries for this group.
5021 (nnmail-purge-split-history (gnus-group-real-name group))
5022 ;; Make all changes in this group permanent.
5024 (gnus-run-hooks 'gnus-exit-group-hook)
5025 (gnus-summary-update-info)
5026 ;; Do adaptive scoring, and possibly save score files.
5027 (when gnus-newsgroup-adaptive
5028 (gnus-score-adaptive))
5029 (when gnus-use-scoring
5031 (gnus-close-group group)
5032 ;; Make sure where we were, and go to next newsgroup.
5033 (set-buffer gnus-group-buffer)
5035 (gnus-group-jump-to-group group))
5036 (gnus-run-hooks 'gnus-summary-exit-hook)
5037 (unless (or quit-config
5038 ;; If this group has disappeared from the summary
5039 ;; buffer, don't skip forwards.
5040 (not (string= group (gnus-group-group-name))))
5041 (gnus-group-next-unread-group 1))
5042 (setq group-point (point))
5045 ;; If we have several article buffers, we kill them at exit.
5046 (unless gnus-single-article-buffer
5047 (gnus-kill-buffer gnus-article-buffer)
5048 (gnus-kill-buffer gnus-original-article-buffer)
5049 (setq gnus-article-current nil))
5051 (if (not gnus-kill-summary-on-exit)
5052 (gnus-deaden-summary)
5053 ;; We set all buffer-local variables to nil. It is unclear why
5054 ;; this is needed, but if we don't, buffer-local variables are
5055 ;; not garbage-collected, it seems. This would the lead to en
5056 ;; ever-growing Emacs.
5057 (gnus-summary-clear-local-variables)
5058 (when (get-buffer gnus-article-buffer)
5059 (bury-buffer gnus-article-buffer))
5060 ;; We clear the global counterparts of the buffer-local
5061 ;; variables as well, just to be on the safe side.
5062 (set-buffer gnus-group-buffer)
5063 (gnus-summary-clear-local-variables)
5064 ;; Return to group mode buffer.
5065 (when (eq mode 'gnus-summary-mode)
5066 (gnus-kill-buffer buf)))
5067 (setq gnus-current-select-method gnus-select-method)
5068 (pop-to-buffer gnus-group-buffer)
5069 ;; Clear the current group name.
5070 (if (not quit-config)
5072 (goto-char group-point)
5073 (gnus-configure-windows 'group 'force))
5074 (gnus-handle-ephemeral-exit quit-config))
5076 (setq gnus-newsgroup-name nil)))))
5078 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5079 (defun gnus-summary-exit-no-update (&optional no-questions)
5080 "Quit reading current newsgroup without updating read article info."
5082 (let* ((group gnus-newsgroup-name)
5083 (quit-config (gnus-group-quit-config group)))
5084 (when (or no-questions
5086 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5087 (gnus-async-halt-prefetch)
5088 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5089 ;; If we have several article buffers, we kill them at exit.
5090 (unless gnus-single-article-buffer
5091 (gnus-kill-buffer gnus-article-buffer)
5092 (gnus-kill-buffer gnus-original-article-buffer)
5093 (setq gnus-article-current nil))
5094 (if (not gnus-kill-summary-on-exit)
5095 (gnus-deaden-summary)
5096 (gnus-close-group group)
5097 (gnus-summary-clear-local-variables)
5098 (set-buffer gnus-group-buffer)
5099 (gnus-summary-clear-local-variables)
5100 (when (get-buffer gnus-summary-buffer)
5101 (kill-buffer gnus-summary-buffer)))
5102 (unless gnus-single-article-buffer
5103 (setq gnus-article-current nil))
5104 (when gnus-use-trees
5105 (gnus-tree-close group))
5106 (gnus-async-prefetch-remove-group group)
5107 (when (get-buffer gnus-article-buffer)
5108 (bury-buffer gnus-article-buffer))
5109 ;; Return to the group buffer.
5110 (gnus-configure-windows 'group 'force)
5111 ;; Clear the current group name.
5112 (setq gnus-newsgroup-name nil)
5113 (when (equal (gnus-group-group-name) group)
5114 (gnus-group-next-unread-group 1))
5116 (gnus-handle-ephemeral-exit quit-config)))))
5118 (defun gnus-handle-ephemeral-exit (quit-config)
5119 "Handle movement when leaving an ephemeral group.
5120 The state which existed when entering the ephemeral is reset."
5121 (if (not (buffer-name (car quit-config)))
5122 (gnus-configure-windows 'group 'force)
5123 (set-buffer (car quit-config))
5124 (cond ((eq major-mode 'gnus-summary-mode)
5125 (gnus-set-global-variables))
5126 ((eq major-mode 'gnus-article-mode)
5128 ;; The `gnus-summary-buffer' variable may point
5129 ;; to the old summary buffer when using a single
5131 (unless (gnus-buffer-live-p gnus-summary-buffer)
5132 (set-buffer gnus-group-buffer))
5133 (set-buffer gnus-summary-buffer)
5134 (gnus-set-global-variables))))
5135 (if (or (eq (cdr quit-config) 'article)
5136 (eq (cdr quit-config) 'pick))
5138 ;; The current article may be from the ephemeral group
5139 ;; thus it is best that we reload this article
5140 (gnus-summary-show-article)
5141 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5142 (gnus-configure-windows 'pick 'force)
5143 (gnus-configure-windows (cdr quit-config) 'force)))
5144 (gnus-configure-windows (cdr quit-config) 'force))
5145 (when (eq major-mode 'gnus-summary-mode)
5146 (gnus-summary-next-subject 1 nil t)
5147 (gnus-summary-recenter)
5148 (gnus-summary-position-point))))
5152 (defvar gnus-dead-summary-mode-map nil)
5154 (unless gnus-dead-summary-mode-map
5155 (setq gnus-dead-summary-mode-map (make-keymap))
5156 (suppress-keymap gnus-dead-summary-mode-map)
5157 (substitute-key-definition
5158 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5159 (let ((keys '("\C-d" "\r" "\177" [delete])))
5161 (define-key gnus-dead-summary-mode-map
5162 (pop keys) 'gnus-summary-wake-up-the-dead))))
5164 (defvar gnus-dead-summary-mode nil
5165 "Minor mode for Gnus summary buffers.")
5167 (defun gnus-dead-summary-mode (&optional arg)
5168 "Minor mode for Gnus summary buffers."
5170 (when (eq major-mode 'gnus-summary-mode)
5171 (make-local-variable 'gnus-dead-summary-mode)
5172 (setq gnus-dead-summary-mode
5173 (if (null arg) (not gnus-dead-summary-mode)
5174 (> (prefix-numeric-value arg) 0)))
5175 (when gnus-dead-summary-mode
5176 (gnus-add-minor-mode
5177 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5179 (defun gnus-deaden-summary ()
5180 "Make the current summary buffer into a dead summary buffer."
5181 ;; Kill any previous dead summary buffer.
5182 (when (and gnus-dead-summary
5183 (buffer-name gnus-dead-summary))
5185 (set-buffer gnus-dead-summary)
5186 (when gnus-dead-summary-mode
5187 (kill-buffer (current-buffer)))))
5188 ;; Make this the current dead summary.
5189 (setq gnus-dead-summary (current-buffer))
5190 (gnus-dead-summary-mode 1)
5191 (let ((name (buffer-name)))
5192 (when (string-match "Summary" name)
5194 (concat (substring name 0 (match-beginning 0)) "Dead "
5195 (substring name (match-beginning 0)))
5198 (defun gnus-kill-or-deaden-summary (buffer)
5199 "Kill or deaden the summary BUFFER."
5201 (when (and (buffer-name buffer)
5202 (not gnus-single-article-buffer))
5205 (gnus-kill-buffer gnus-article-buffer)
5206 (gnus-kill-buffer gnus-original-article-buffer)))
5207 (cond (gnus-kill-summary-on-exit
5208 (when (and gnus-use-trees
5209 (gnus-buffer-exists-p buffer))
5212 (gnus-tree-close gnus-newsgroup-name)))
5213 (gnus-kill-buffer buffer))
5214 ((gnus-buffer-exists-p buffer)
5217 (gnus-deaden-summary))))))
5219 (defun gnus-summary-wake-up-the-dead (&rest args)
5220 "Wake up the dead summary buffer."
5222 (gnus-dead-summary-mode -1)
5223 (let ((name (buffer-name)))
5224 (when (string-match "Dead " name)
5226 (concat (substring name 0 (match-beginning 0))
5227 (substring name (match-end 0)))
5229 (gnus-message 3 "This dead summary is now alive again"))
5231 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5232 (defun gnus-summary-fetch-faq (&optional faq-dir)
5233 "Fetch the FAQ for the current group.
5234 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5238 (when current-prefix-arg
5240 "Faq dir: " (and (listp gnus-group-faq-directory)
5241 (mapcar (lambda (file) (list file))
5242 gnus-group-faq-directory))))))
5243 (let (gnus-faq-buffer)
5244 (when (setq gnus-faq-buffer
5245 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5246 (gnus-configure-windows 'summary-faq))))
5248 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5249 (defun gnus-summary-describe-group (&optional force)
5250 "Describe the current newsgroup."
5252 (gnus-group-describe-group force gnus-newsgroup-name))
5254 (defun gnus-summary-describe-briefly ()
5255 "Describe summary mode commands briefly."
5258 (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")))
5260 ;; Walking around group mode buffer from summary mode.
5262 (defun gnus-summary-next-group (&optional no-article target-group backward)
5263 "Exit current newsgroup and then select next unread newsgroup.
5264 If prefix argument NO-ARTICLE is non-nil, no article is selected
5265 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5266 previous group instead."
5268 ;; Stop pre-fetching.
5269 (gnus-async-halt-prefetch)
5270 (let ((current-group gnus-newsgroup-name)
5271 (current-buffer (current-buffer))
5273 ;; First we semi-exit this group to update Xrefs and all variables.
5274 ;; We can't do a real exit, because the window conf must remain
5275 ;; the same in case the user is prompted for info, and we don't
5276 ;; want the window conf to change before that...
5277 (gnus-summary-exit t)
5278 (while (not entered)
5279 ;; Then we find what group we are supposed to enter.
5280 (set-buffer gnus-group-buffer)
5281 (gnus-group-jump-to-group current-group)
5284 (if (eq gnus-keep-same-level 'best)
5285 (gnus-summary-best-group gnus-newsgroup-name)
5286 (gnus-summary-search-group backward gnus-keep-same-level))))
5287 (if (not target-group)
5288 ;; There are no further groups, so we return to the group
5291 (gnus-message 5 "Returning to the group buffer")
5293 (when (gnus-buffer-live-p current-buffer)
5294 (set-buffer current-buffer)
5295 (gnus-summary-exit))
5296 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5297 ;; We try to enter the target group.
5298 (gnus-group-jump-to-group target-group)
5299 (let ((unreads (gnus-group-group-unread)))
5300 (if (and (or (eq t unreads)
5301 (and unreads (not (zerop unreads))))
5302 (gnus-summary-read-group
5303 target-group nil no-article
5304 (and (buffer-name current-buffer) current-buffer)
5307 (setq current-group target-group
5308 target-group nil)))))))
5310 (defun gnus-summary-prev-group (&optional no-article)
5311 "Exit current newsgroup and then select previous unread newsgroup.
5312 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5314 (gnus-summary-next-group no-article nil t))
5316 ;; Walking around summary lines.
5318 (defun gnus-summary-first-subject (&optional unread undownloaded)
5319 "Go to the first unread subject.
5320 If UNREAD is non-nil, go to the first unread article.
5321 Returns the article selected or nil if there are no unread articles."
5326 ((null gnus-newsgroup-data)
5327 (gnus-message 3 "No articles in the group")
5329 ;; Pick the first article.
5331 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5332 (gnus-data-number (car gnus-newsgroup-data)))
5333 ;; No unread articles.
5334 ((null gnus-newsgroup-unreads)
5335 (gnus-message 3 "No more unread articles")
5337 ;; Find the first unread article.
5339 (let ((data gnus-newsgroup-data))
5341 (and (not (and undownloaded
5342 (eq gnus-undownloaded-mark
5343 (gnus-data-mark (car data)))))
5344 (not (gnus-data-unread-p (car data)))))
5345 (setq data (cdr data)))
5347 (goto-char (gnus-data-pos (car data)))
5348 (gnus-data-number (car data))))))
5349 (gnus-summary-position-point)))
5351 (defun gnus-summary-next-subject (n &optional unread dont-display)
5352 "Go to next N'th summary line.
5353 If N is negative, go to the previous N'th subject line.
5354 If UNREAD is non-nil, only unread articles are selected.
5355 The difference between N and the actual number of steps taken is
5358 (let ((backward (< n 0))
5362 (gnus-summary-find-prev unread)
5363 (gnus-summary-find-next unread)))
5364 (gnus-summary-show-thread)
5367 (gnus-message 7 "No more%s articles"
5368 (if unread " unread" "")))
5369 (unless dont-display
5370 (gnus-summary-recenter)
5371 (gnus-summary-position-point))
5374 (defun gnus-summary-next-unread-subject (n)
5375 "Go to next N'th unread summary line."
5377 (gnus-summary-next-subject n t))
5379 (defun gnus-summary-prev-subject (n &optional unread)
5380 "Go to previous N'th summary line.
5381 If optional argument UNREAD is non-nil, only unread article is selected."
5383 (gnus-summary-next-subject (- n) unread))
5385 (defun gnus-summary-prev-unread-subject (n)
5386 "Go to previous N'th unread summary line."
5388 (gnus-summary-next-subject (- n) t))
5390 (defun gnus-summary-goto-subject (article &optional force silent)
5391 "Go the subject line of ARTICLE.
5392 If FORCE, also allow jumping to articles not currently shown."
5393 (interactive "nArticle number: ")
5395 (data (gnus-data-find article)))
5396 ;; We read in the article if we have to.
5399 (gnus-summary-insert-subject
5401 (if (or (numberp force) (vectorp force)) force)
5403 (setq data (gnus-data-find article)))
5408 (gnus-message 3 "Can't find article %d" article))
5410 (goto-char (gnus-data-pos data))
5413 ;; Walking around summary lines with displaying articles.
5415 (defun gnus-summary-expand-window (&optional arg)
5416 "Make the summary buffer take up the entire Emacs frame.
5417 Given a prefix, will force an `article' buffer configuration."
5420 (gnus-configure-windows 'article 'force)
5421 (gnus-configure-windows 'summary 'force)))
5423 (defun gnus-summary-display-article (article &optional all-header)
5424 "Display ARTICLE in article buffer."
5425 (gnus-set-global-variables)
5429 (if gnus-summary-display-article-function
5430 (funcall gnus-summary-display-article-function article all-header)
5431 (gnus-article-prepare article all-header))
5432 (gnus-run-hooks 'gnus-select-article-hook)
5433 (when (and gnus-current-article
5434 (not (zerop gnus-current-article)))
5435 (gnus-summary-goto-subject gnus-current-article))
5436 (gnus-summary-recenter)
5437 (when (and gnus-use-trees gnus-show-threads)
5438 (gnus-possibly-generate-tree article)
5439 (gnus-highlight-selected-tree article))
5440 ;; Successfully display article.
5441 (gnus-article-set-window-start
5442 (cdr (assq article gnus-newsgroup-bookmarks))))))
5444 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5445 "Select the current article.
5446 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5447 non-nil, the article will be re-fetched even if it already present in
5448 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5450 ;; Make sure we are in the summary buffer to work around bbdb bug.
5451 (unless (eq major-mode 'gnus-summary-mode)
5452 (set-buffer gnus-summary-buffer))
5453 (let ((article (or article (gnus-summary-article-number)))
5454 (all-headers (not (not all-headers))) ;Must be T or NIL.
5455 gnus-summary-display-article-function
5458 (gnus-summary-article-pseudo-p article)
5459 (error "This is a pseudo-article"))
5462 (set-buffer gnus-summary-buffer)
5463 (if (or (and gnus-single-article-buffer
5464 (or (null gnus-current-article)
5465 (null gnus-article-current)
5466 (null (get-buffer gnus-article-buffer))
5467 (not (eq article (cdr gnus-article-current)))
5468 (not (equal (car gnus-article-current)
5469 gnus-newsgroup-name))))
5470 (and (not gnus-single-article-buffer)
5471 (or (null gnus-current-article)
5472 (not (eq gnus-current-article article))))
5474 ;; The requested article is different from the current article.
5476 (gnus-summary-display-article article all-headers)
5478 (when (or all-headers gnus-show-all-headers)
5479 (gnus-article-show-all-headers))
5482 (gnus-article-set-window-start
5483 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5485 (defun gnus-summary-set-current-mark (&optional current-mark)
5486 "Obsolete function."
5489 (defun gnus-summary-next-article (&optional unread subject backward push)
5490 "Select the next article.
5491 If UNREAD, only unread articles are selected.
5492 If SUBJECT, only articles with SUBJECT are selected.
5493 If BACKWARD, the previous article is selected instead of the next."
5496 ;; Is there such an article?
5497 ((and (gnus-summary-search-forward unread subject backward)
5498 (or (gnus-summary-display-article (gnus-summary-article-number))
5499 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5500 (gnus-summary-position-point))
5501 ;; If not, we try the first unread, if that is wanted.
5503 gnus-auto-select-same
5504 (gnus-summary-first-unread-article))
5505 (gnus-summary-position-point)
5506 (gnus-message 6 "Wrapped"))
5507 ;; Try to get next/previous article not displayed in this group.
5508 ((and gnus-auto-extend-newsgroup
5509 (not unread) (not subject))
5510 (gnus-summary-goto-article
5511 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5512 nil (count-lines (point-min) (point))))
5513 ;; Go to next/previous group.
5515 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5516 (gnus-summary-jump-to-group gnus-newsgroup-name))
5517 (let ((cmd last-command-char)
5520 (set-buffer gnus-group-buffer)
5523 (if (eq gnus-keep-same-level 'best)
5524 (gnus-summary-best-group gnus-newsgroup-name)
5525 (gnus-summary-search-group backward gnus-keep-same-level))))
5526 ;; For some reason, the group window gets selected. We change
5528 (select-window (get-buffer-window (current-buffer)))
5529 ;; Select next unread newsgroup automagically.
5531 ((or (not gnus-auto-select-next)
5533 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5534 ((or (eq gnus-auto-select-next 'quietly)
5535 (and (eq gnus-auto-select-next 'slightly-quietly)
5537 (and (eq gnus-auto-select-next 'almost-quietly)
5538 (gnus-summary-last-article-p)))
5540 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5542 (gnus-message 7 "No more%s articles (%s)..."
5543 (if unread " unread" "")
5544 (if group (concat "selecting " group)
5546 (gnus-summary-next-group nil group backward)))
5548 (when (gnus-key-press-event-p last-input-event)
5549 (gnus-summary-walk-group-buffer
5550 gnus-newsgroup-name cmd unread backward point))))))))
5552 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5553 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5554 (?\C-p (gnus-group-prev-unread-group 1))))
5555 (cursor-in-echo-area t)
5556 keve key group ended)
5558 (set-buffer gnus-group-buffer)
5561 (if (eq gnus-keep-same-level 'best)
5562 (gnus-summary-best-group gnus-newsgroup-name)
5563 (gnus-summary-search-group backward gnus-keep-same-level))))
5566 5 "No more%s articles%s" (if unread " unread" "")
5568 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5569 (format " (Type %s for %s [%s])"
5570 (single-key-description cmd) group
5571 (car (gnus-gethash group gnus-newsrc-hashtb)))
5572 (format " (Type %s to exit %s)"
5573 (single-key-description cmd)
5574 gnus-newsgroup-name)))
5575 ;; Confirm auto selection.
5576 (setq key (car (setq keve (gnus-read-event-char))))
5579 ((assq key keystrokes)
5580 (let ((obuf (current-buffer)))
5581 (switch-to-buffer gnus-group-buffer)
5583 (gnus-group-jump-to-group group))
5584 (eval (cadr (assq key keystrokes)))
5585 (setq group (gnus-group-group-name))
5586 (switch-to-buffer obuf))
5590 (gnus-ephemeral-group-p gnus-newsgroup-name))
5592 (gnus-summary-next-group nil group backward)))
5594 (push (cdr keve) unread-command-events))))))
5596 (defun gnus-summary-next-unread-article ()
5597 "Select unread article after current one."
5599 (gnus-summary-next-article
5600 (or (not (eq gnus-summary-goto-unread 'never))
5601 (gnus-summary-last-article-p (gnus-summary-article-number)))
5602 (and gnus-auto-select-same
5603 (gnus-summary-article-subject))))
5605 (defun gnus-summary-prev-article (&optional unread subject)
5606 "Select the article after the current one.
5607 If UNREAD is non-nil, only unread articles are selected."
5609 (gnus-summary-next-article unread subject t))
5611 (defun gnus-summary-prev-unread-article ()
5612 "Select unread article before current one."
5614 (gnus-summary-prev-article
5615 (or (not (eq gnus-summary-goto-unread 'never))
5616 (gnus-summary-first-article-p (gnus-summary-article-number)))
5617 (and gnus-auto-select-same
5618 (gnus-summary-article-subject))))
5620 (defun gnus-summary-next-page (&optional lines circular)
5621 "Show next page of the selected article.
5622 If at the end of the current article, select the next article.
5623 LINES says how many lines should be scrolled up.
5625 If CIRCULAR is non-nil, go to the start of the article instead of
5626 selecting the next article when reaching the end of the current
5629 (setq gnus-summary-buffer (current-buffer))
5630 (gnus-set-global-variables)
5631 (let ((article (gnus-summary-article-number))
5632 (article-window (get-buffer-window gnus-article-buffer t))
5634 ;; If the buffer is empty, we have no article.
5636 (error "No article to select"))
5637 (gnus-configure-windows 'article)
5638 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5639 (if (and (eq gnus-summary-goto-unread 'never)
5640 (not (gnus-summary-last-article-p article)))
5641 (gnus-summary-next-article)
5642 (gnus-summary-next-unread-article))
5643 (if (or (null gnus-current-article)
5644 (null gnus-article-current)
5645 (/= article (cdr gnus-article-current))
5646 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5647 ;; Selected subject is different from current article's.
5648 (gnus-summary-display-article article)
5649 (when article-window
5650 (gnus-eval-in-buffer-window gnus-article-buffer
5651 (setq endp (gnus-article-next-page lines)))
5654 (gnus-summary-beginning-of-article))
5656 (gnus-message 3 "End of message"))
5658 (if (and (eq gnus-summary-goto-unread 'never)
5659 (not (gnus-summary-last-article-p article)))
5660 (gnus-summary-next-article)
5661 (gnus-summary-next-unread-article))))))))
5662 (gnus-summary-recenter)
5663 (gnus-summary-position-point)))
5665 (defun gnus-summary-prev-page (&optional lines move)
5666 "Show previous page of selected article.
5667 Argument LINES specifies lines to be scrolled down.
5668 If MOVE, move to the previous unread article if point is at
5669 the beginning of the buffer."
5671 (let ((article (gnus-summary-article-number))
5672 (article-window (get-buffer-window gnus-article-buffer t))
5674 (gnus-configure-windows 'article)
5675 (if (or (null gnus-current-article)
5676 (null gnus-article-current)
5677 (/= article (cdr gnus-article-current))
5678 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5679 ;; Selected subject is different from current article's.
5680 (gnus-summary-display-article article)
5681 (gnus-summary-recenter)
5682 (when article-window
5683 (gnus-eval-in-buffer-window gnus-article-buffer
5684 (setq endp (gnus-article-prev-page lines)))
5685 (when (and move endp)
5687 (gnus-message 3 "Beginning of message"))
5689 (if (and (eq gnus-summary-goto-unread 'never)
5690 (not (gnus-summary-first-article-p article)))
5691 (gnus-summary-prev-article)
5692 (gnus-summary-prev-unread-article))))))))
5693 (gnus-summary-position-point))
5695 (defun gnus-summary-prev-page-or-article (&optional lines)
5696 "Show previous page of selected article.
5697 Argument LINES specifies lines to be scrolled down.
5698 If at the beginning of the article, go to the next article."
5700 (gnus-summary-prev-page lines t))
5702 (defun gnus-summary-scroll-up (lines)
5703 "Scroll up (or down) one line current article.
5704 Argument LINES specifies lines to be scrolled up (or down if negative)."
5706 (gnus-configure-windows 'article)
5707 (gnus-summary-show-thread)
5708 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5709 (gnus-eval-in-buffer-window gnus-article-buffer
5711 (when (gnus-article-next-page lines)
5712 (gnus-message 3 "End of message")))
5714 (gnus-article-prev-page (- lines))))))
5715 (gnus-summary-recenter)
5716 (gnus-summary-position-point))
5718 (defun gnus-summary-next-same-subject ()
5719 "Select next article which has the same subject as current one."
5721 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5723 (defun gnus-summary-prev-same-subject ()
5724 "Select previous article which has the same subject as current one."
5726 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5728 (defun gnus-summary-next-unread-same-subject ()
5729 "Select next unread article which has the same subject as current one."
5731 (gnus-summary-next-article t (gnus-summary-article-subject)))
5733 (defun gnus-summary-prev-unread-same-subject ()
5734 "Select previous unread article which has the same subject as current one."
5736 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5738 (defun gnus-summary-first-unread-article ()
5739 "Select the first unread article.
5740 Return nil if there are no unread articles."
5743 (when (gnus-summary-first-subject t)
5744 (gnus-summary-show-thread)
5745 (gnus-summary-first-subject t)
5746 (gnus-summary-display-article (gnus-summary-article-number)))
5747 (gnus-summary-position-point)))
5749 (defun gnus-summary-first-article ()
5750 "Select the first article.
5751 Return nil if there are no articles."
5754 (when (gnus-summary-first-subject)
5755 (gnus-summary-show-thread)
5756 (gnus-summary-first-subject)
5757 (gnus-summary-display-article (gnus-summary-article-number)))
5758 (gnus-summary-position-point)))
5760 (defun gnus-summary-best-unread-article ()
5761 "Select the unread article with the highest score."
5763 (let ((best -1000000)
5764 (data gnus-newsgroup-data)
5767 (and (gnus-data-unread-p (car data))
5769 (gnus-summary-article-score (gnus-data-number (car data))))
5772 article (gnus-data-number (car data))))
5773 (setq data (cdr data)))
5776 (gnus-summary-goto-article article)
5777 (error "No unread articles"))
5778 (gnus-summary-position-point))))
5780 (defun gnus-summary-last-subject ()
5781 "Go to the last displayed subject line in the group."
5782 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5784 (gnus-summary-goto-subject article))))
5786 (defun gnus-summary-goto-article (article &optional all-headers force)
5787 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5788 If ALL-HEADERS is non-nil, no header lines are hidden.
5789 If FORCE, go to the article even if it isn't displayed. If FORCE
5790 is a number, it is the line the article is to be displayed on."
5794 "Article number or Message-ID: "
5795 (mapcar (lambda (number) (list (int-to-string number)))
5796 gnus-newsgroup-limit))
5800 (if (and (stringp article)
5801 (string-match "@" article))
5802 (gnus-summary-refer-article article)
5803 (when (stringp article)
5804 (setq article (string-to-number article)))
5805 (if (gnus-summary-goto-subject article force)
5806 (gnus-summary-display-article article all-headers)
5807 (gnus-message 4 "Couldn't go to article %s" article) nil))
5808 (gnus-summary-position-point)))
5810 (defun gnus-summary-goto-last-article ()
5811 "Go to the previously read article."
5814 (when gnus-last-article
5815 (gnus-summary-goto-article gnus-last-article nil t))
5816 (gnus-summary-position-point)))
5818 (defun gnus-summary-pop-article (number)
5819 "Pop one article off the history and go to the previous.
5820 NUMBER articles will be popped off."
5823 (setq gnus-newsgroup-history
5824 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5826 (gnus-summary-goto-article (car to) nil t)
5827 (error "Article history empty")))
5828 (gnus-summary-position-point))
5830 ;; Summary commands and functions for limiting the summary buffer.
5832 (defun gnus-summary-limit-to-articles (n)
5833 "Limit the summary buffer to the next N articles.
5834 If not given a prefix, use the process marked articles instead."
5837 (let ((articles (gnus-summary-work-articles n)))
5838 (setq gnus-newsgroup-processable nil)
5839 (gnus-summary-limit articles))
5840 (gnus-summary-position-point)))
5842 (defun gnus-summary-pop-limit (&optional total)
5843 "Restore the previous limit.
5844 If given a prefix, remove all limits."
5847 (setq gnus-newsgroup-limits
5848 (list (mapcar (lambda (h) (mail-header-number h))
5849 gnus-newsgroup-headers))))
5850 (unless gnus-newsgroup-limits
5851 (error "No limit to pop"))
5853 (gnus-summary-limit nil 'pop)
5854 (gnus-summary-position-point)))
5856 (defun gnus-summary-limit-to-subject (subject &optional header)
5857 "Limit the summary buffer to articles that have subjects that match a regexp."
5858 (interactive "sLimit to subject (regexp): ")
5860 (setq header "subject"))
5861 (when (not (equal "" subject))
5863 (let ((articles (gnus-summary-find-matching
5864 (or header "subject") subject 'all)))
5866 (error "Found no matches for \"%s\"" subject))
5867 (gnus-summary-limit articles))
5868 (gnus-summary-position-point))))
5870 (defun gnus-summary-limit-to-author (from)
5871 "Limit the summary buffer to articles that have authors that match a regexp."
5872 (interactive "sLimit to author (regexp): ")
5873 (gnus-summary-limit-to-subject from "from"))
5875 (defun gnus-summary-limit-to-age (age &optional younger-p)
5876 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5877 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5878 articles that are younger than AGE days."
5879 (interactive "nTime in days: \nP")
5881 (let ((data gnus-newsgroup-data)
5882 (cutoff (nnmail-days-to-time age))
5883 articles d date is-younger)
5884 (while (setq d (pop data))
5885 (when (and (vectorp (gnus-data-header d))
5886 (setq date (mail-header-date (gnus-data-header d))))
5887 (setq is-younger (nnmail-time-less
5888 (nnmail-time-since (nnmail-date-to-time date))
5893 (push (gnus-data-number d) articles))))
5894 (gnus-summary-limit (nreverse articles)))
5895 (gnus-summary-position-point)))
5897 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5899 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5901 (defun gnus-summary-limit-to-unread (&optional all)
5902 "Limit the summary buffer to articles that are not marked as read.
5903 If ALL is non-nil, limit strictly to unread articles."
5906 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5907 (gnus-summary-limit-to-marks
5908 ;; Concat all the marks that say that an article is read and have
5910 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5911 gnus-killed-mark gnus-kill-file-mark
5912 gnus-low-score-mark gnus-expirable-mark
5913 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5914 gnus-duplicate-mark gnus-souped-mark)
5917 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5918 (make-obsolete 'gnus-summary-delete-marked-with
5919 'gnus-summary-limit-exlude-marks)
5921 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5922 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5923 If REVERSE, limit the summary buffer to articles that are marked
5924 with MARKS. MARKS can either be a string of marks or a list of marks.
5925 Returns how many articles were removed."
5926 (interactive "sMarks: ")
5927 (gnus-summary-limit-to-marks marks t))
5929 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5930 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5931 If REVERSE (the prefix), limit the summary buffer to articles that are
5932 not marked with MARKS. MARKS can either be a string of marks or a
5934 Returns how many articles were removed."
5935 (interactive "sMarks: \nP")
5937 (let ((data gnus-newsgroup-data)
5938 (marks (if (listp marks) marks
5939 (append marks nil))) ; Transform to list.
5942 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5943 (memq (gnus-data-mark (car data)) marks))
5944 (push (gnus-data-number (car data)) articles))
5945 (setq data (cdr data)))
5946 (gnus-summary-limit articles))
5947 (gnus-summary-position-point)))
5949 (defun gnus-summary-limit-to-score (&optional score)
5950 "Limit to articles with score at or above SCORE."
5952 (setq score (if score
5953 (prefix-numeric-value score)
5954 (or gnus-summary-default-score 0)))
5955 (let ((data gnus-newsgroup-data)
5958 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5960 (push (gnus-data-number (car data)) articles))
5961 (setq data (cdr data)))
5963 (gnus-summary-limit articles)
5964 (gnus-summary-position-point))))
5966 (defun gnus-summary-limit-include-thread (id)
5967 "Display all the hidden articles that in the current thread."
5968 (interactive (list (mail-header-id (gnus-summary-article-header))))
5969 (let ((articles (gnus-articles-in-thread
5970 (gnus-id-to-thread (gnus-root-id id)))))
5972 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
5973 (gnus-summary-position-point))))
5975 (defun gnus-summary-limit-include-dormant ()
5976 "Display all the hidden articles that are marked as dormant.
5977 Note that this command only works on a subset of the articles currently
5978 fetched for this group."
5980 (unless gnus-newsgroup-dormant
5981 (error "There are no dormant articles in this group"))
5983 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5984 (gnus-summary-position-point)))
5986 (defun gnus-summary-limit-exclude-dormant ()
5987 "Hide all dormant articles."
5990 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5991 (gnus-summary-position-point)))
5993 (defun gnus-summary-limit-exclude-childless-dormant ()
5994 "Hide all dormant articles that have no children."
5996 (let ((data (gnus-data-list t))
5997 articles d children)
5998 ;; Find all articles that are either not dormant or have
6000 (while (setq d (pop data))
6001 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6003 (gnus-article-children (gnus-data-number d)))
6006 (when (memq (car children) articles)
6011 (push (gnus-data-number d) articles)))
6014 (gnus-summary-limit articles)
6015 (gnus-summary-position-point))))
6017 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6018 "Mark all unread excluded articles as read.
6019 If ALL, mark even excluded ticked and dormants as read."
6021 (let ((articles (gnus-sorted-complement
6023 (mapcar (lambda (h) (mail-header-number h))
6024 gnus-newsgroup-headers)
6026 (sort gnus-newsgroup-limit '<)))
6028 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6030 (setq gnus-newsgroup-dormant nil
6031 gnus-newsgroup-marked nil
6032 gnus-newsgroup-reads
6034 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6035 gnus-newsgroup-reads))
6036 (while (setq article (pop articles))
6037 (unless (or (memq article gnus-newsgroup-dormant)
6038 (memq article gnus-newsgroup-marked))
6039 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6041 (defun gnus-summary-limit (articles &optional pop)
6043 ;; We pop the previous limit off the stack and use that.
6044 (setq articles (car gnus-newsgroup-limits)
6045 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6046 ;; We use the new limit, so we push the old limit on the stack.
6047 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6049 (setq gnus-newsgroup-limit articles)
6050 (let ((total (length gnus-newsgroup-data))
6051 (data (gnus-data-find-list (gnus-summary-article-number)))
6052 (gnus-summary-mark-below nil) ; Inhibit this.
6054 ;; This will do all the work of generating the new summary buffer
6055 ;; according to the new limit.
6056 (gnus-summary-prepare)
6057 ;; Hide any threads, possibly.
6058 (and gnus-show-threads
6059 gnus-thread-hide-subtree
6060 (gnus-summary-hide-all-threads))
6061 ;; Try to return to the article you were at, or one in the
6064 ;; We try to find some article after the current one.
6066 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6069 (setq data (cdr data))))
6071 ;; If there is no data, that means that we were after the last
6072 ;; article. The same goes when we can't find any articles
6073 ;; after the current one.
6074 (goto-char (point-max))
6075 (gnus-summary-find-prev))
6076 ;; We return how many articles were removed from the summary
6077 ;; buffer as a result of the new limit.
6078 (- total (length gnus-newsgroup-data))))
6080 (defsubst gnus-invisible-cut-children (threads)
6083 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6088 (defsubst gnus-cut-thread (thread)
6089 "Go forwards in the thread until we find an article that we want to display."
6090 (when (or (eq gnus-fetch-old-headers 'some)
6091 (eq gnus-fetch-old-headers 'invisible)
6092 (eq gnus-build-sparse-threads 'some)
6093 (eq gnus-build-sparse-threads 'more))
6094 ;; Deal with old-fetched headers and sparse threads.
6098 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6099 (gnus-summary-article-ancient-p
6100 (mail-header-number (car thread))))
6101 (if (or (<= (length (cdr thread)) 1)
6102 (eq gnus-fetch-old-headers 'invisible))
6103 (setq gnus-newsgroup-limit
6104 (delq (mail-header-number (car thread))
6105 gnus-newsgroup-limit)
6106 thread (cadr thread))
6107 (when (gnus-invisible-cut-children (cdr thread))
6108 (let ((th (cdr thread)))
6110 (if (memq (mail-header-number (caar th))
6111 gnus-newsgroup-limit)
6112 (setq thread (car th)
6114 (setq th (cdr th))))))))))
6117 (defun gnus-cut-threads (threads)
6118 "Cut off all uninteresting articles from the beginning of threads."
6119 (when (or (eq gnus-fetch-old-headers 'some)
6120 (eq gnus-fetch-old-headers 'invisible)
6121 (eq gnus-build-sparse-threads 'some)
6122 (eq gnus-build-sparse-threads 'more))
6125 (setcar th (gnus-cut-thread (car th)))
6126 (setq th (cdr th)))))
6127 ;; Remove nixed out threads.
6130 (defun gnus-summary-initial-limit (&optional show-if-empty)
6131 "Figure out what the initial limit is supposed to be on group entry.
6132 This entails weeding out unwanted dormants, low-scored articles,
6133 fetch-old-headers verbiage, and so on."
6134 ;; Most groups have nothing to remove.
6135 (if (or gnus-inhibit-limiting
6136 (and (null gnus-newsgroup-dormant)
6137 (not (eq gnus-fetch-old-headers 'some))
6138 (not (eq gnus-fetch-old-headers 'invisible))
6139 (null gnus-summary-expunge-below)
6140 (not (eq gnus-build-sparse-threads 'some))
6141 (not (eq gnus-build-sparse-threads 'more))
6142 (null gnus-thread-expunge-below)
6143 (not gnus-use-nocem)))
6145 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6146 (setq gnus-newsgroup-limit nil)
6149 (unless (car (symbol-value node))
6150 ;; These threads have no parents -- they are roots.
6151 (let ((nodes (cdr (symbol-value node)))
6154 (if (and gnus-thread-expunge-below
6155 (< (gnus-thread-total-score (car nodes))
6156 gnus-thread-expunge-below))
6157 (gnus-expunge-thread (pop nodes))
6158 (setq thread (pop nodes))
6159 (gnus-summary-limit-children thread))))))
6160 gnus-newsgroup-dependencies)
6161 ;; If this limitation resulted in an empty group, we might
6162 ;; pop the previous limit and use it instead.
6163 (when (and (not gnus-newsgroup-limit)
6165 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6166 gnus-newsgroup-limit))
6168 (defun gnus-summary-limit-children (thread)
6169 "Return 1 if this subthread is visible and 0 if it is not."
6170 ;; First we get the number of visible children to this thread. This
6171 ;; is done by recursing down the thread using this function, so this
6172 ;; will really go down to a leaf article first, before slowly
6173 ;; working its way up towards the root.
6177 (apply '+ (mapcar 'gnus-summary-limit-children
6180 (number (mail-header-number (car thread)))
6183 (not (memq number gnus-newsgroup-marked))
6185 ;; If this article is dormant and has absolutely no visible
6186 ;; children, then this article isn't visible.
6187 (and (memq number gnus-newsgroup-dormant)
6189 ;; If this is "fetch-old-headered" and there is no
6190 ;; visible children, then we don't want this article.
6191 (and (eq gnus-fetch-old-headers 'some)
6192 (gnus-summary-article-ancient-p number)
6194 ;; If this is "fetch-old-headered" and `invisible', then
6195 ;; we don't want this article.
6196 (and (eq gnus-fetch-old-headers 'invisible)
6197 (gnus-summary-article-ancient-p number))
6198 ;; If this is a sparsely inserted article with no children,
6199 ;; we don't want it.
6200 (and (eq gnus-build-sparse-threads 'some)
6201 (gnus-summary-article-sparse-p number)
6203 ;; If we use expunging, and this article is really
6204 ;; low-scored, then we don't want this article.
6205 (when (and gnus-summary-expunge-below
6207 (or (cdr (assq number gnus-newsgroup-scored))
6208 gnus-summary-default-score))
6209 gnus-summary-expunge-below))
6210 ;; We increase the expunge-tally here, but that has
6211 ;; nothing to do with the limits, really.
6212 (incf gnus-newsgroup-expunged-tally)
6213 ;; We also mark as read here, if that's wanted.
6214 (when (and gnus-summary-mark-below
6215 (< score gnus-summary-mark-below))
6216 (setq gnus-newsgroup-unreads
6217 (delq number gnus-newsgroup-unreads))
6218 (if gnus-newsgroup-auto-expire
6219 (push number gnus-newsgroup-expirable)
6220 (push (cons number gnus-low-score-mark)
6221 gnus-newsgroup-reads)))
6223 ;; Check NoCeM things.
6224 (if (and gnus-use-nocem
6225 (gnus-nocem-unwanted-article-p
6226 (mail-header-id (car thread))))
6228 (setq gnus-newsgroup-unreads
6229 (delq number gnus-newsgroup-unreads))
6231 ;; Nope, invisible article.
6233 ;; Ok, this article is to be visible, so we add it to the limit
6235 (push number gnus-newsgroup-limit)
6238 (defun gnus-expunge-thread (thread)
6239 "Mark all articles in THREAD as read."
6240 (let* ((number (mail-header-number (car thread))))
6241 (incf gnus-newsgroup-expunged-tally)
6242 ;; We also mark as read here, if that's wanted.
6243 (setq gnus-newsgroup-unreads
6244 (delq number gnus-newsgroup-unreads))
6245 (if gnus-newsgroup-auto-expire
6246 (push number gnus-newsgroup-expirable)
6247 (push (cons number gnus-low-score-mark)
6248 gnus-newsgroup-reads)))
6249 ;; Go recursively through all subthreads.
6250 (mapcar 'gnus-expunge-thread (cdr thread)))
6252 ;; Summary article oriented commands
6254 (defun gnus-summary-refer-parent-article (n)
6255 "Refer parent article N times.
6256 If N is negative, go to ancestor -N instead.
6257 The difference between N and the number of articles fetched is returned."
6261 (when (not (natnump n))
6266 (setq header (gnus-summary-article-header))
6267 (if (and (eq (mail-header-number header)
6268 (cdr gnus-article-current))
6269 (equal gnus-newsgroup-name
6270 (car gnus-article-current)))
6271 ;; If we try to find the parent of the currently
6272 ;; displayed article, then we take a look at the actual
6273 ;; References header, since this is slightly more
6274 ;; reliable than the References field we got from the
6277 (set-buffer gnus-original-article-buffer)
6278 (nnheader-narrow-to-headers)
6279 (unless (setq ref (message-fetch-field "references"))
6280 (setq ref (message-fetch-field "in-reply-to")))
6283 ;; It's not the current article, so we take a bet on
6284 ;; the value we got from the server.
6285 (mail-header-references header)))
6287 (not (equal ref "")))
6288 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6289 (gnus-message 1 "Couldn't find parent"))
6290 (gnus-message 1 "No references in article %d"
6291 (gnus-summary-article-number))
6294 (gnus-summary-position-point)
6297 (defun gnus-summary-refer-references ()
6298 "Fetch all articles mentioned in the References header.
6299 Return the number of articles fetched."
6301 (let ((ref (mail-header-references (gnus-summary-article-header)))
6302 (current (gnus-summary-article-number))
6306 (error "No References in the current article")
6307 ;; For each Message-ID in the References header...
6308 (while (string-match "<[^>]*>" ref)
6310 ;; ... fetch that article.
6311 (gnus-summary-refer-article
6312 (prog1 (match-string 0 ref)
6313 (setq ref (substring ref (match-end 0))))))
6314 (gnus-summary-goto-subject current)
6315 (gnus-summary-position-point)
6318 (defun gnus-summary-refer-thread (&optional limit)
6319 "Fetch all articles in the current thread.
6320 If LIMIT (the numerical prefix), fetch that many old headers instead
6321 of what's specified by the `gnus-refer-thread-limit' variable."
6323 (let ((id (mail-header-id (gnus-summary-article-header)))
6324 (limit (if limit (prefix-numeric-value limit)
6325 gnus-refer-thread-limit))
6327 ;; We want to fetch LIMIT *old* headers, but we also have to
6328 ;; re-fetch all the headers in the current buffer, because many of
6329 ;; them may be undisplayed. So we adjust LIMIT.
6330 (when (numberp limit)
6331 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6332 (unless (eq gnus-fetch-old-headers 'invisible)
6333 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6334 ;; Retrieve the headers and read them in.
6335 (if (eq (gnus-retrieve-headers
6336 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6338 (gnus-build-all-threads)
6339 (error "Can't fetch thread from backends that don't support NOV"))
6340 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6341 (gnus-summary-limit-include-thread id)))
6343 (defun gnus-summary-refer-article (message-id &optional arg)
6344 "Fetch an article specified by MESSAGE-ID.
6345 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6346 or `gnus-select-method', no matter what backend the article comes from."
6347 (interactive "sMessage-ID: \nP")
6348 (when (and (stringp message-id)
6349 (not (zerop (length message-id))))
6350 ;; Construct the correct Message-ID if necessary.
6351 ;; Suggested by tale@pawl.rpi.edu.
6352 (unless (string-match "^<" message-id)
6353 (setq message-id (concat "<" message-id)))
6354 (unless (string-match ">$" message-id)
6355 (setq message-id (concat message-id ">")))
6356 (let* ((header (gnus-id-to-header message-id))
6358 (gnus-summary-article-sparse-p
6359 (mail-header-number header))
6360 (memq (mail-header-number header)
6361 gnus-newsgroup-limit)))
6364 ;; If the article is present in the buffer we just go to it.
6366 (or (not (gnus-summary-article-sparse-p
6367 (mail-header-number header)))
6370 (gnus-summary-goto-article
6371 (mail-header-number header) nil t)
6373 (gnus-summary-update-article (mail-header-number header)))))
6375 ;; We fetch the article
6376 (let ((gnus-override-method
6377 (cond ((gnus-news-group-p gnus-newsgroup-name)
6378 gnus-refer-article-method)
6380 (or gnus-refer-article-method gnus-select-method))
6383 ;; Start the special refer-article method, if necessary.
6384 (when (and gnus-refer-article-method
6385 (gnus-news-group-p gnus-newsgroup-name))
6386 (gnus-check-server gnus-refer-article-method))
6387 ;; Fetch the header, and display the article.
6388 (if (setq number (gnus-summary-insert-subject message-id))
6389 (gnus-summary-select-article nil nil nil number)
6390 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6392 (defun gnus-summary-edit-parameters ()
6393 "Edit the group parameters of the current group."
6395 (gnus-group-edit-group gnus-newsgroup-name 'params))
6397 (defun gnus-summary-enter-digest-group (&optional force)
6398 "Enter an nndoc group based on the current article.
6399 If FORCE, force a digest interpretation. If not, try
6400 to guess what the document format is."
6402 (let ((conf gnus-current-window-configuration))
6404 (gnus-summary-select-article))
6405 (setq gnus-current-window-configuration conf)
6406 (let* ((name (format "%s-%d"
6407 (gnus-group-prefixed-name
6408 gnus-newsgroup-name (list 'nndoc ""))
6410 (set-buffer gnus-summary-buffer)
6411 gnus-current-article)))
6412 (ogroup gnus-newsgroup-name)
6413 (params (append (gnus-info-params (gnus-get-info ogroup))
6414 (list (cons 'to-group ogroup))
6415 (list (cons 'save-article-group ogroup))))
6416 (case-fold-search t)
6417 (buf (current-buffer))
6420 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6421 (insert-buffer-substring gnus-original-article-buffer)
6422 ;; Remove lines that may lead nndoc to misinterpret the
6425 (goto-char (point-min))
6426 (or (search-forward "\n\n" nil t) (point)))
6427 (goto-char (point-min))
6428 (delete-matching-lines "^\\(Path\\):\\|^From ")
6431 (if (gnus-group-read-ephemeral-group
6432 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6434 ,(if force 'digest 'guess))) t)
6435 ;; Make all postings to this group go to the parent group.
6436 (nconc (gnus-info-params (gnus-get-info name))
6438 ;; Couldn't select this doc group.
6439 (switch-to-buffer buf)
6440 (gnus-set-global-variables)
6441 (gnus-configure-windows 'summary)
6442 (gnus-message 3 "Article couldn't be entered?"))
6443 (kill-buffer dig)))))
6445 (defun gnus-summary-read-document (n)
6446 "Open a new group based on the current article(s).
6447 This will allow you to read digests and other similar
6448 documents as newsgroups.
6449 Obeys the standard process/prefix convention."
6451 (let* ((articles (gnus-summary-work-articles n))
6452 (ogroup gnus-newsgroup-name)
6453 (params (append (gnus-info-params (gnus-get-info ogroup))
6454 (list (cons 'to-group ogroup))))
6455 article group egroup groups vgroup)
6456 (while (setq article (pop articles))
6457 (setq group (format "%s-%d" gnus-newsgroup-name article))
6458 (gnus-summary-remove-process-mark article)
6459 (when (gnus-summary-display-article article)
6461 (nnheader-temp-write nil
6462 (insert-buffer-substring gnus-original-article-buffer)
6463 ;; Remove some headers that may lead nndoc to make
6465 (message-narrow-to-head)
6466 (goto-char (point-min))
6467 (delete-matching-lines "^\\(Path\\):\\|^From ")
6470 (gnus-group-read-ephemeral-group
6471 group `(nndoc ,group (nndoc-address ,(current-buffer))
6472 (nndoc-article-type guess))
6475 ;; Make all postings to this group go to the parent group.
6476 (nconc (gnus-info-params (gnus-get-info egroup))
6478 (push egroup groups))
6479 ;; Couldn't select this doc group.
6480 (gnus-error 3 "Article couldn't be entered"))))))
6481 ;; Now we have selected all the documents.
6484 (error "None of the articles could be interpreted as documents"))
6485 ((gnus-group-read-ephemeral-group
6486 (setq vgroup (format
6487 "nnvirtual:%s-%s" gnus-newsgroup-name
6488 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6489 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6491 (cons (current-buffer) 'summary)))
6493 (error "Couldn't select virtual nndoc group")))))
6495 (defun gnus-summary-isearch-article (&optional regexp-p)
6496 "Do incremental search forward on the current article.
6497 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6499 (gnus-summary-select-article)
6500 (gnus-configure-windows 'article)
6501 (gnus-eval-in-buffer-window gnus-article-buffer
6504 (isearch-forward regexp-p))))
6506 (defun gnus-summary-search-article-forward (regexp &optional backward)
6507 "Search for an article containing REGEXP forward.
6508 If BACKWARD, search backward instead."
6511 (format "Search article %s (regexp%s): "
6512 (if current-prefix-arg "backward" "forward")
6513 (if gnus-last-search-regexp
6514 (concat ", default " gnus-last-search-regexp)
6516 current-prefix-arg))
6517 (if (string-equal regexp "")
6518 (setq regexp (or gnus-last-search-regexp ""))
6519 (setq gnus-last-search-regexp regexp))
6520 (if (gnus-summary-search-article regexp backward)
6521 (gnus-summary-show-thread)
6522 (error "Search failed: \"%s\"" regexp)))
6524 (defun gnus-summary-search-article-backward (regexp)
6525 "Search for an article containing REGEXP backward."
6528 (format "Search article backward (regexp%s): "
6529 (if gnus-last-search-regexp
6530 (concat ", default " gnus-last-search-regexp)
6532 (gnus-summary-search-article-forward regexp 'backward))
6534 (defun gnus-summary-search-article (regexp &optional backward)
6535 "Search for an article containing REGEXP.
6536 Optional argument BACKWARD means do search for backward.
6537 `gnus-select-article-hook' is not called during the search."
6538 ;; We have to require this here to make sure that the following
6539 ;; dynamic binding isn't shadowed by autoloading.
6540 (require 'gnus-async)
6541 (let ((gnus-select-article-hook nil) ;Disable hook.
6542 (gnus-article-display-hook nil)
6543 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6544 (gnus-use-article-prefetch nil)
6545 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6546 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6547 (sum (current-buffer))
6550 (gnus-save-hidden-threads
6551 (gnus-summary-select-article)
6552 (set-buffer gnus-article-buffer)
6556 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6558 (re-search-backward regexp nil t)
6559 (re-search-forward regexp nil t))
6560 ;; We found the regexp.
6565 (get-buffer-window (current-buffer))
6569 (setq point (point)))
6570 ;; We didn't find it, so we go to the next article.
6573 (while (eq found 'not)
6574 (if (not (if backward (gnus-summary-find-prev)
6575 (gnus-summary-find-next)))
6576 ;; No more articles.
6578 ;; Select the next article and adjust point.
6579 (unless (gnus-summary-article-sparse-p
6580 (gnus-summary-article-number))
6582 (gnus-summary-select-article)
6583 (set-buffer gnus-article-buffer)
6585 (goto-char (if backward (point-max) (point-min))))))))
6586 (gnus-message 7 ""))
6587 ;; Return whether we found the regexp.
6588 (when (eq found 'found)
6590 (gnus-summary-show-thread)
6591 (gnus-summary-goto-subject gnus-current-article)
6592 (gnus-summary-position-point)
6595 (defun gnus-summary-find-matching (header regexp &optional backward unread
6597 "Return a list of all articles that match REGEXP on HEADER.
6598 The search stars on the current article and goes forwards unless
6599 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6600 If UNREAD is non-nil, only unread articles will
6601 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6602 in the comparisons."
6603 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6604 (gnus-data-find-list
6605 (gnus-summary-article-number) (gnus-data-list backward))))
6606 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6607 (case-fold-search (not not-case-fold))
6609 (unless (fboundp (intern (concat "mail-header-" header)))
6610 (error "%s is not a valid header" header))
6613 (and (or (not unread) ; We want all articles...
6614 (gnus-data-unread-p d)) ; Or just unreads.
6615 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6616 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6617 (push (gnus-data-number d) articles)) ; Success!
6618 (setq data (cdr data)))
6619 (nreverse articles)))
6621 (defun gnus-summary-execute-command (header regexp command &optional backward)
6622 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6623 If HEADER is an empty string (or nil), the match is done on the entire
6624 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6626 (list (let ((completion-ignore-case t))
6629 (mapcar (lambda (string) (list string))
6630 '("Number" "Subject" "From" "Lines" "Date"
6631 "Message-ID" "Xref" "References" "Body"))
6632 nil 'require-match))
6633 (read-string "Regexp: ")
6634 (read-key-sequence "Command: ")
6635 current-prefix-arg))
6636 (when (equal header "Body")
6638 ;; Hidden thread subtrees must be searched as well.
6639 (gnus-summary-show-all-threads)
6640 ;; We don't want to change current point nor window configuration.
6642 (save-window-excursion
6643 (gnus-message 6 "Executing %s..." (key-description command))
6644 ;; We'd like to execute COMMAND interactively so as to give arguments.
6645 (gnus-execute header regexp
6646 `(call-interactively ',(key-binding command))
6648 (gnus-message 6 "Executing %s...done" (key-description command)))))
6650 (defun gnus-summary-beginning-of-article ()
6651 "Scroll the article back to the beginning."
6653 (gnus-summary-select-article)
6654 (gnus-configure-windows 'article)
6655 (gnus-eval-in-buffer-window gnus-article-buffer
6657 (goto-char (point-min))
6658 (when gnus-page-broken
6659 (gnus-narrow-to-page))))
6661 (defun gnus-summary-end-of-article ()
6662 "Scroll to the end of the article."
6664 (gnus-summary-select-article)
6665 (gnus-configure-windows 'article)
6666 (gnus-eval-in-buffer-window gnus-article-buffer
6668 (goto-char (point-max))
6670 (when gnus-page-broken
6671 (gnus-narrow-to-page))))
6673 (defun gnus-summary-print-article (&optional filename n)
6674 "Generate and print a PostScript image of the N next (mail) articles.
6676 If N is negative, print the N previous articles. If N is nil and articles
6677 have been marked with the process mark, print these instead.
6679 If the optional second argument FILENAME is nil, send the image to the
6680 printer. If FILENAME is a string, save the PostScript image in a file with
6681 that name. If FILENAME is a number, prompt the user for the name of the file
6683 (interactive (list (ps-print-preprint current-prefix-arg)
6684 current-prefix-arg))
6685 (dolist (article (gnus-summary-work-articles n))
6686 (gnus-summary-select-article nil nil 'pseudo article)
6687 (gnus-eval-in-buffer-window gnus-article-buffer
6688 (let ((buffer (generate-new-buffer " *print*")))
6691 (copy-to-buffer buffer (point-min) (point-max))
6693 (gnus-article-delete-invisible-text)
6694 (let ((ps-left-header
6697 (mail-header-subject gnus-current-headers) ")")
6699 (mail-header-from gnus-current-headers) ")")))
6702 "/pagenumberstring load"
6704 (mail-header-date gnus-current-headers) ")"))))
6705 (gnus-run-hooks 'gnus-ps-print-hook)
6707 (ps-print-buffer-with-faces filename))))
6708 (kill-buffer buffer))))))
6710 (defun gnus-summary-show-article (&optional arg)
6711 "Force re-fetching of the current article.
6712 If ARG (the prefix) is non-nil, show the raw article without any
6713 article massaging functions being run."
6716 ;; Select the article the normal way.
6717 (gnus-summary-select-article nil 'force)
6718 ;; Bind the article treatment functions to nil.
6719 (let ((gnus-have-all-headers t)
6720 gnus-article-display-hook
6721 gnus-article-prepare-hook
6725 (gnus-summary-select-article nil 'force)))
6726 (gnus-summary-goto-subject gnus-current-article)
6727 (gnus-summary-position-point))
6729 (defun gnus-summary-verbose-headers (&optional arg)
6730 "Toggle permanent full header display.
6731 If ARG is a positive number, turn header display on.
6732 If ARG is a negative number, turn header display off."
6734 (setq gnus-show-all-headers
6735 (cond ((or (not (numberp arg))
6737 (not gnus-show-all-headers))
6740 (gnus-summary-show-article))
6742 (defun gnus-summary-toggle-header (&optional arg)
6743 "Show the headers if they are hidden, or hide them if they are shown.
6744 If ARG is a positive number, show the entire header.
6745 If ARG is a negative number, hide the unwanted header lines."
6748 (set-buffer gnus-article-buffer)
6749 (let* ((buffer-read-only nil)
6750 (inhibit-point-motion-hooks t)
6751 (hidden (text-property-any
6752 (goto-char (point-min)) (search-forward "\n\n")
6755 (goto-char (point-min))
6756 (when (search-forward "\n\n" nil t)
6757 (delete-region (point-min) (1- (point))))
6758 (goto-char (point-min))
6760 (set-buffer gnus-original-article-buffer)
6761 (goto-char (point-min))
6762 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6763 (insert-buffer-substring gnus-original-article-buffer 1 e)
6764 (let ((article-inhibit-hiding t))
6765 (gnus-run-hooks 'gnus-article-display-hook))
6766 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6767 (gnus-article-hide-headers)))))
6769 (defun gnus-summary-show-all-headers ()
6770 "Make all header lines visible."
6772 (gnus-article-show-all-headers))
6774 (defun gnus-summary-toggle-mime (&optional arg)
6775 "Toggle MIME processing.
6776 If ARG is a positive number, turn MIME processing on."
6778 (setq gnus-show-mime
6779 (if (null arg) (not gnus-show-mime)
6780 (> (prefix-numeric-value arg) 0)))
6781 (gnus-summary-select-article t 'force))
6783 (defun gnus-summary-caesar-message (&optional arg)
6784 "Caesar rotate the current article by 13.
6785 The numerical prefix specifies how many places to rotate each letter
6788 (gnus-summary-select-article)
6789 (let ((mail-header-separator ""))
6790 (gnus-eval-in-buffer-window gnus-article-buffer
6793 (let ((start (window-start))
6795 (message-caesar-buffer-body arg)
6796 (set-window-start (get-buffer-window (current-buffer)) start))))))
6798 (defun gnus-summary-stop-page-breaking ()
6799 "Stop page breaking in the current article."
6801 (gnus-summary-select-article)
6802 (gnus-eval-in-buffer-window gnus-article-buffer
6804 (when (gnus-visual-p 'page-marker)
6805 (let ((buffer-read-only nil))
6806 (gnus-remove-text-with-property 'gnus-prev)
6807 (gnus-remove-text-with-property 'gnus-next))
6808 (setq gnus-page-broken nil))))
6810 (defun gnus-summary-move-article (&optional n to-newsgroup
6811 select-method action)
6812 "Move the current article to a different newsgroup.
6813 If N is a positive number, move the N next articles.
6814 If N is a negative number, move the N previous articles.
6815 If N is nil and any articles have been marked with the process mark,
6816 move those articles instead.
6817 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6818 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6819 re-spool using this method.
6821 For this function to work, both the current newsgroup and the
6822 newsgroup that you want to move to have to support the `request-move'
6823 and `request-accept' functions."
6826 (setq action 'move))
6827 ;; Disable marking as read.
6828 (let (gnus-mark-article-hook)
6829 (save-window-excursion
6830 (gnus-summary-select-article)))
6831 ;; Check whether the source group supports the required functions.
6832 (cond ((and (eq action 'move)
6833 (not (gnus-check-backend-function
6834 'request-move-article gnus-newsgroup-name)))
6835 (error "The current group does not support article moving"))
6836 ((and (eq action 'crosspost)
6837 (not (gnus-check-backend-function
6838 'request-replace-article gnus-newsgroup-name)))
6839 (error "The current group does not support article editing")))
6840 (let ((articles (gnus-summary-work-articles n))
6841 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6842 (names '((move "Move" "Moving")
6843 (copy "Copy" "Copying")
6844 (crosspost "Crosspost" "Crossposting")))
6845 (copy-buf (save-excursion
6846 (nnheader-set-temp-buffer " *copy article*")))
6847 art-group to-method new-xref article to-groups)
6848 (unless (assq action names)
6849 (error "Unknown action %s" action))
6850 ;; Read the newsgroup name.
6851 (when (and (not to-newsgroup)
6852 (not select-method))
6854 (gnus-read-move-group-name
6855 (cadr (assq action names))
6856 (symbol-value (intern (format "gnus-current-%s-group" action)))
6858 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6859 (setq to-method (or select-method
6860 (gnus-group-name-to-method to-newsgroup)))
6861 ;; Check the method we are to move this article to...
6862 (unless (gnus-check-backend-function
6863 'request-accept-article (car to-method))
6864 (error "%s does not support article copying" (car to-method)))
6865 (unless (gnus-check-server to-method)
6866 (error "Can't open server %s" (car to-method)))
6867 (gnus-message 6 "%s to %s: %s..."
6868 (caddr (assq action names))
6869 (or (car select-method) to-newsgroup) articles)
6871 (setq article (pop articles))
6875 ;; Move the article.
6877 ;; Remove this article from future suppression.
6878 (gnus-dup-unsuppress-article article)
6879 (gnus-request-move-article
6880 article ; Article to move
6881 gnus-newsgroup-name ; From newsgroup
6882 (nth 1 (gnus-find-method-for-group
6883 gnus-newsgroup-name)) ; Server
6884 (list 'gnus-request-accept-article
6885 to-newsgroup (list 'quote select-method)
6886 (not articles)) ; Accept form
6887 (not articles))) ; Only save nov last time
6888 ;; Copy the article.
6891 (set-buffer copy-buf)
6892 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6893 (gnus-request-accept-article
6894 to-newsgroup select-method (not articles)))))
6895 ;; Crosspost the article.
6896 ((eq action 'crosspost)
6897 (let ((xref (message-tokenize-header
6898 (mail-header-xref (gnus-summary-article-header article))
6900 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6903 (setq xref (list (system-name))))
6906 (mapconcat 'identity
6907 (delete "Xref:" (delete new-xref xref))
6911 (set-buffer copy-buf)
6912 ;; First put the article in the destination group.
6913 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6914 (when (consp (setq art-group
6915 (gnus-request-accept-article
6916 to-newsgroup select-method (not articles))))
6917 (setq new-xref (concat new-xref " " (car art-group)
6918 ":" (cdr art-group)))
6919 ;; Now we have the new Xrefs header, so we insert
6920 ;; it and replace the new article.
6921 (nnheader-replace-header "Xref" new-xref)
6922 (gnus-request-replace-article
6923 (cdr art-group) to-newsgroup (current-buffer))
6927 (gnus-message 1 "Couldn't %s article %s"
6928 (cadr (assq action names)) article))
6929 ((and (eq art-group 'junk)
6931 (gnus-summary-mark-article article gnus-canceled-mark)
6932 (gnus-message 4 "Deleted article %s" article))
6936 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6938 (gnus-group-prefixed-name
6941 (gnus-find-method-for-group to-newsgroup)))
6942 gnus-newsrc-hashtb)))
6943 (info (nth 2 entry))
6944 (to-group (gnus-info-group info)))
6945 ;; Update the group that has been moved to.
6947 (memq action '(move copy)))
6948 (unless (member to-group to-groups)
6949 (push to-group to-groups))
6951 (unless (memq article gnus-newsgroup-unreads)
6953 info (gnus-add-to-range (gnus-info-read info)
6954 (list (cdr art-group)))))
6956 ;; Copy any marks over to the new group.
6957 (let ((marks gnus-article-mark-lists)
6958 (to-article (cdr art-group)))
6960 ;; See whether the article is to be put in the cache.
6961 (when gnus-use-cache
6962 (gnus-cache-possibly-enter-article
6964 (let ((header (copy-sequence
6965 (gnus-summary-article-header article))))
6966 (mail-header-set-number header to-article)
6968 (memq article gnus-newsgroup-marked)
6969 (memq article gnus-newsgroup-dormant)
6970 (memq article gnus-newsgroup-unreads)))
6972 (when (and (equal to-group gnus-newsgroup-name)
6973 (not (memq article gnus-newsgroup-unreads)))
6974 ;; Mark this article as read in this group.
6975 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
6976 (setcdr (gnus-active to-group) to-article)
6977 (setcdr gnus-newsgroup-active to-article))
6980 (when (memq article (symbol-value
6981 (intern (format "gnus-newsgroup-%s"
6983 ;; If the other group is the same as this group,
6984 ;; then we have to add the mark to the list.
6985 (when (equal to-group gnus-newsgroup-name)
6986 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6989 (intern (format "gnus-newsgroup-%s"
6991 ;; Copy the marks to other group.
6992 (gnus-add-marked-articles
6993 to-group (cdar marks) (list to-article) info))
6994 (setq marks (cdr marks)))
6997 (concat "(gnus-group-set-info '"
6998 (gnus-prin1-to-string (gnus-get-info to-group))
7001 ;; Update the Xref header in this article to point to
7002 ;; the new crossposted article we have just created.
7003 (when (eq action 'crosspost)
7005 (set-buffer copy-buf)
7006 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7007 (nnheader-replace-header "Xref" new-xref)
7008 (gnus-request-replace-article
7009 article gnus-newsgroup-name (current-buffer)))))
7011 ;;;!!!Why is this necessary?
7012 (set-buffer gnus-summary-buffer)
7014 (gnus-summary-goto-subject article)
7015 (when (eq action 'move)
7016 (gnus-summary-mark-article article gnus-canceled-mark))))
7017 (gnus-summary-remove-process-mark article))
7018 ;; Re-activate all groups that have been moved to.
7021 (set-buffer gnus-group-buffer)
7022 (when (gnus-group-goto-group (car to-groups) t)
7023 (gnus-group-get-new-news-this-group 1 t))
7026 (gnus-kill-buffer copy-buf)
7027 (gnus-summary-position-point)
7028 (gnus-set-mode-line 'summary)))
7030 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7031 "Move the current article to a different newsgroup.
7032 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7033 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7034 re-spool using this method."
7036 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7038 (defun gnus-summary-crosspost-article (&optional n)
7039 "Crosspost the current article to some other group."
7041 (gnus-summary-move-article n nil nil 'crosspost))
7043 (defcustom gnus-summary-respool-default-method nil
7044 "Default method for respooling an article.
7045 If nil, use to the current newsgroup method."
7046 :type `(choice (gnus-select-method :value (nnml ""))
7048 :group 'gnus-summary-mail)
7050 (defun gnus-summary-respool-article (&optional n method)
7051 "Respool the current article.
7052 The article will be squeezed through the mail spooling process again,
7053 which means that it will be put in some mail newsgroup or other
7054 depending on `nnmail-split-methods'.
7055 If N is a positive number, respool the N next articles.
7056 If N is a negative number, respool the N previous articles.
7057 If N is nil and any articles have been marked with the process mark,
7058 respool those articles instead.
7060 Respooling can be done both from mail groups and \"real\" newsgroups.
7061 In the former case, the articles in question will be moved from the
7062 current group into whatever groups they are destined to. In the
7063 latter case, they will be copied into the relevant groups."
7065 (list current-prefix-arg
7066 (let* ((methods (gnus-methods-using 'respool))
7068 (symbol-name (or gnus-summary-respool-default-method
7069 (car (gnus-find-method-for-group
7070 gnus-newsgroup-name)))))
7072 (gnus-completing-read
7073 methname "What backend do you want to use when respooling?"
7074 methods nil t nil 'gnus-mail-method-history))
7077 ((zerop (length (setq ms (gnus-servers-using-backend
7079 (list (intern method) ""))
7083 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7084 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7087 (error "No method given for respooling"))
7088 (if (assoc (symbol-name
7089 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7090 (gnus-methods-using 'respool))
7091 (gnus-summary-move-article n nil method)
7092 (gnus-summary-copy-article n nil method)))
7094 (defun gnus-summary-import-article (file)
7095 "Import an arbitrary file into a mail newsgroup."
7096 (interactive "fImport file: ")
7097 (let ((group gnus-newsgroup-name)
7098 (now (current-time))
7100 (unless (gnus-check-backend-function 'request-accept-article group)
7101 (error "%s does not support article importing" group))
7102 (or (file-readable-p file)
7103 (not (file-regular-p file))
7104 (error "Can't read %s" file))
7106 (set-buffer (get-buffer-create " *import file*"))
7107 (buffer-disable-undo (current-buffer))
7109 (insert-file-contents file)
7110 (goto-char (point-min))
7111 (unless (nnheader-article-p)
7112 ;; This doesn't look like an article, so we fudge some headers.
7113 (setq atts (file-attributes file)
7114 lines (count-lines (point-min) (point-max)))
7115 (insert "From: " (read-string "From: ") "\n"
7116 "Subject: " (read-string "Subject: ") "\n"
7117 "Date: " (timezone-make-date-arpa-standard
7118 (current-time-string (nth 5 atts))
7119 (current-time-zone now)
7120 (current-time-zone now))
7122 "Message-ID: " (message-make-message-id) "\n"
7123 "Lines: " (int-to-string lines) "\n"
7124 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7125 (gnus-request-accept-article group nil t)
7126 (kill-buffer (current-buffer)))))
7128 (defun gnus-summary-article-posted-p ()
7129 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7130 This will be the case if the article has both been mailed and posted."
7132 (let ((id (mail-header-references (gnus-summary-article-header)))
7133 (gnus-override-method
7134 (or gnus-refer-article-method gnus-select-method)))
7135 (if (gnus-request-head id "")
7136 (gnus-message 2 "The current message was found on %s"
7137 gnus-override-method)
7138 (gnus-message 2 "The current message couldn't be found on %s"
7139 gnus-override-method)
7142 (defun gnus-summary-expire-articles (&optional now)
7143 "Expire all articles that are marked as expirable in the current group."
7145 (when (gnus-check-backend-function
7146 'request-expire-articles gnus-newsgroup-name)
7147 ;; This backend supports expiry.
7148 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7149 (expirable (if total
7151 ;; We need to update the info for
7152 ;; this group for `gnus-list-of-read-articles'
7153 ;; to give us the right answer.
7154 (gnus-run-hooks 'gnus-exit-group-hook)
7155 (gnus-summary-update-info)
7156 (gnus-list-of-read-articles gnus-newsgroup-name))
7157 (setq gnus-newsgroup-expirable
7158 (sort gnus-newsgroup-expirable '<))))
7159 (expiry-wait (if now 'immediate
7160 (gnus-group-find-parameter
7161 gnus-newsgroup-name 'expiry-wait)))
7164 ;; There are expirable articles in this group, so we run them
7165 ;; through the expiry process.
7166 (gnus-message 6 "Expiring articles...")
7167 ;; The list of articles that weren't expired is returned.
7170 (let ((nnmail-expiry-wait-function nil)
7171 (nnmail-expiry-wait expiry-wait))
7172 (setq es (gnus-request-expire-articles
7173 expirable gnus-newsgroup-name)))
7174 (setq es (gnus-request-expire-articles
7175 expirable gnus-newsgroup-name))))
7177 (setq gnus-newsgroup-expirable es))
7178 ;; We go through the old list of expirable, and mark all
7179 ;; really expired articles as nonexistent.
7180 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7181 (let ((gnus-use-cache nil))
7183 (unless (memq (car expirable) es)
7184 (when (gnus-data-find (car expirable))
7185 (gnus-summary-mark-article
7186 (car expirable) gnus-canceled-mark)))
7187 (setq expirable (cdr expirable)))))
7188 (gnus-message 6 "Expiring articles...done")))))
7190 (defun gnus-summary-expire-articles-now ()
7191 "Expunge all expirable articles in the current group.
7192 This means that *all* articles that are marked as expirable will be
7193 deleted forever, right now."
7195 (or gnus-expert-user
7197 "Are you really, really, really sure you want to delete all these messages? ")
7199 (gnus-summary-expire-articles t))
7201 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7202 (defun gnus-summary-delete-article (&optional n)
7203 "Delete the N next (mail) articles.
7204 This command actually deletes articles. This is not a marking
7205 command. The article will disappear forever from your life, never to
7207 If N is negative, delete backwards.
7208 If N is nil and articles have been marked with the process mark,
7209 delete these instead."
7211 (unless (gnus-check-backend-function 'request-expire-articles
7212 gnus-newsgroup-name)
7213 (error "The current newsgroup does not support article deletion"))
7214 ;; Compute the list of articles to delete.
7215 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7217 (if (and gnus-novice-user
7218 (not (gnus-yes-or-no-p
7219 (format "Do you really want to delete %s forever? "
7220 (if (> (length articles) 1)
7221 (format "these %s articles" (length articles))
7224 ;; Delete the articles.
7225 (setq not-deleted (gnus-request-expire-articles
7226 articles gnus-newsgroup-name 'force))
7228 (gnus-summary-remove-process-mark (car articles))
7229 ;; The backend might not have been able to delete the article
7231 (unless (memq (car articles) not-deleted)
7232 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7233 (setq articles (cdr articles)))
7235 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7236 (gnus-summary-position-point)
7237 (gnus-set-mode-line 'summary)
7240 (defun gnus-summary-edit-article (&optional force)
7241 "Edit the current article.
7242 This will have permanent effect only in mail groups.
7243 If FORCE is non-nil, allow editing of articles even in read-only
7247 (set-buffer gnus-summary-buffer)
7248 (gnus-set-global-variables)
7249 (when (and (not force)
7250 (gnus-group-read-only-p))
7251 (error "The current newsgroup does not support article editing"))
7252 ;; Select article if needed.
7253 (unless (eq (gnus-summary-article-number)
7254 gnus-current-article)
7255 (gnus-summary-select-article t))
7256 (gnus-article-date-original)
7257 (gnus-article-edit-article
7258 `(lambda (no-highlight)
7259 (gnus-summary-edit-article-done
7260 ,(or (mail-header-references gnus-current-headers) "")
7261 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7263 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7265 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7267 "Make edits to the current article permanent."
7269 ;; Replace the article.
7270 (if (and (not read-only)
7271 (not (gnus-request-replace-article
7272 (cdr gnus-article-current) (car gnus-article-current)
7274 (error "Couldn't replace article")
7275 ;; Update the summary buffer.
7277 (equal (message-tokenize-header references " ")
7278 (message-tokenize-header
7279 (or (message-fetch-field "references") "") " ")))
7280 ;; We only have to update this line.
7283 (message-narrow-to-head)
7284 (let ((head (buffer-string))
7286 (nnheader-temp-write nil
7287 (insert (format "211 %d Article retrieved.\n"
7288 (cdr gnus-article-current)))
7291 (let ((nntp-server-buffer (current-buffer)))
7292 (setq header (car (gnus-get-newsgroup-headers
7294 (set-buffer gnus-summary-buffer)
7295 gnus-newsgroup-dependencies)
7298 (set-buffer gnus-summary-buffer)
7299 (gnus-data-set-header
7300 (gnus-data-find (cdr gnus-article-current))
7302 (gnus-summary-update-article-line
7303 (cdr gnus-article-current) header))))))
7305 (set-buffer (or buffer gnus-summary-buffer))
7306 (gnus-summary-update-article (cdr gnus-article-current)))
7307 ;; Prettify the article buffer again.
7308 (unless no-highlight
7310 (set-buffer gnus-article-buffer)
7311 (gnus-run-hooks 'gnus-article-display-hook)
7312 (set-buffer gnus-original-article-buffer)
7313 (gnus-request-article
7314 (cdr gnus-article-current)
7315 (car gnus-article-current) (current-buffer))))
7316 ;; Prettify the summary buffer line.
7317 (when (gnus-visual-p 'summary-highlight 'highlight)
7318 (gnus-run-hooks 'gnus-visual-mark-article-hook))))
7320 (defun gnus-summary-edit-wash (key)
7321 "Perform editing command KEY in the article buffer."
7325 (message "%s" (concat (this-command-keys) "- "))
7328 (gnus-summary-edit-article)
7329 (execute-kbd-macro (concat (this-command-keys) key))
7330 (gnus-article-edit-done))
7334 (defun gnus-summary-respool-query (&optional silent)
7335 "Query where the respool algorithm would put this article."
7337 (let (gnus-mark-article-hook)
7338 (gnus-summary-select-article)
7340 (set-buffer gnus-original-article-buffer)
7342 (message-narrow-to-head)
7343 (let ((groups (nnmail-article-group 'identity)))
7346 (message "This message would go to %s"
7347 (mapconcat 'car groups ", "))
7348 (message "This message would go to no groups"))
7351 ;; Summary marking commands.
7353 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7354 "Mark articles which has the same subject as read, and then select the next.
7355 If UNMARK is positive, remove any kind of mark.
7356 If UNMARK is negative, tick articles."
7359 (setq unmark (prefix-numeric-value unmark)))
7361 (gnus-summary-mark-same-subject
7362 (gnus-summary-article-subject) unmark)))
7363 ;; Select next unread article. If auto-select-same mode, should
7364 ;; select the first unread article.
7365 (gnus-summary-next-article t (and gnus-auto-select-same
7366 (gnus-summary-article-subject)))
7367 (gnus-message 7 "%d article%s marked as %s"
7368 count (if (= count 1) " is" "s are")
7369 (if unmark "unread" "read"))))
7371 (defun gnus-summary-kill-same-subject (&optional unmark)
7372 "Mark articles which has the same subject as read.
7373 If UNMARK is positive, remove any kind of mark.
7374 If UNMARK is negative, tick articles."
7377 (setq unmark (prefix-numeric-value unmark)))
7379 (gnus-summary-mark-same-subject
7380 (gnus-summary-article-subject) unmark)))
7381 ;; If marked as read, go to next unread subject.
7383 ;; Go to next unread subject.
7384 (gnus-summary-next-subject 1 t))
7385 (gnus-message 7 "%d articles are marked as %s"
7386 count (if unmark "unread" "read"))))
7388 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7389 "Mark articles with same SUBJECT as read, and return marked number.
7390 If optional argument UNMARK is positive, remove any kinds of marks.
7391 If optional argument UNMARK is negative, mark articles as unread instead."
7395 ((null unmark) ; Mark as read.
7398 (gnus-summary-mark-article-as-read gnus-killed-mark)
7399 (gnus-summary-show-thread) t)
7400 (gnus-summary-find-subject subject))
7401 (setq count (1+ count))))
7402 ((> unmark 0) ; Tick.
7405 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7406 (gnus-summary-show-thread) t)
7407 (gnus-summary-find-subject subject))
7408 (setq count (1+ count))))
7409 (t ; Mark as unread.
7412 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7413 (gnus-summary-show-thread) t)
7414 (gnus-summary-find-subject subject))
7415 (setq count (1+ count)))))
7416 (gnus-set-mode-line 'summary)
7417 ;; Return the number of marked articles.
7420 (defun gnus-summary-mark-as-processable (n &optional unmark)
7421 "Set the process mark on the next N articles.
7422 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7423 the process mark instead. The difference between N and the actual
7424 number of articles marked is returned."
7426 (let ((backward (< n 0))
7431 (gnus-summary-remove-process-mark
7432 (gnus-summary-article-number))
7433 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7434 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7437 (gnus-message 7 "No more articles"))
7438 (gnus-summary-recenter)
7439 (gnus-summary-position-point)
7442 (defun gnus-summary-unmark-as-processable (n)
7443 "Remove the process mark from the next N articles.
7444 If N is negative, unmark backward instead. The difference between N and
7445 the actual number of articles unmarked is returned."
7447 (gnus-summary-mark-as-processable n t))
7449 (defun gnus-summary-unmark-all-processable ()
7450 "Remove the process mark from all articles."
7453 (while gnus-newsgroup-processable
7454 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7455 (gnus-summary-position-point))
7457 (defun gnus-summary-mark-as-expirable (n)
7458 "Mark N articles forward as expirable.
7459 If N is negative, mark backward instead. The difference between N and
7460 the actual number of articles marked is returned."
7462 (gnus-summary-mark-forward n gnus-expirable-mark))
7464 (defun gnus-summary-mark-article-as-replied (article)
7465 "Mark ARTICLE replied and update the summary line."
7466 (push article gnus-newsgroup-replied)
7467 (let ((buffer-read-only nil))
7468 (when (gnus-summary-goto-subject article)
7469 (gnus-summary-update-secondary-mark article))))
7471 (defun gnus-summary-set-bookmark (article)
7472 "Set a bookmark in current article."
7473 (interactive (list (gnus-summary-article-number)))
7474 (when (or (not (get-buffer gnus-article-buffer))
7475 (not gnus-current-article)
7476 (not gnus-article-current)
7477 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7478 (error "No current article selected"))
7479 ;; Remove old bookmark, if one exists.
7480 (let ((old (assq article gnus-newsgroup-bookmarks)))
7482 (setq gnus-newsgroup-bookmarks
7483 (delq old gnus-newsgroup-bookmarks))))
7484 ;; Set the new bookmark, which is on the form
7485 ;; (article-number . line-number-in-body).
7489 (set-buffer gnus-article-buffer)
7493 (goto-char (point-min))
7494 (search-forward "\n\n" nil t)
7497 gnus-newsgroup-bookmarks)
7498 (gnus-message 6 "A bookmark has been added to the current article."))
7500 (defun gnus-summary-remove-bookmark (article)
7501 "Remove the bookmark from the current article."
7502 (interactive (list (gnus-summary-article-number)))
7503 ;; Remove old bookmark, if one exists.
7504 (let ((old (assq article gnus-newsgroup-bookmarks)))
7507 (setq gnus-newsgroup-bookmarks
7508 (delq old gnus-newsgroup-bookmarks))
7509 (gnus-message 6 "Removed bookmark."))
7510 (gnus-message 6 "No bookmark in current article."))))
7512 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7513 (defun gnus-summary-mark-as-dormant (n)
7514 "Mark N articles forward as dormant.
7515 If N is negative, mark backward instead. The difference between N and
7516 the actual number of articles marked is returned."
7518 (gnus-summary-mark-forward n gnus-dormant-mark))
7520 (defun gnus-summary-set-process-mark (article)
7521 "Set the process mark on ARTICLE and update the summary line."
7522 (setq gnus-newsgroup-processable
7524 (delq article gnus-newsgroup-processable)))
7525 (when (gnus-summary-goto-subject article)
7526 (gnus-summary-show-thread)
7527 (gnus-summary-update-secondary-mark article)))
7529 (defun gnus-summary-remove-process-mark (article)
7530 "Remove the process mark from ARTICLE and update the summary line."
7531 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7532 (when (gnus-summary-goto-subject article)
7533 (gnus-summary-show-thread)
7534 (gnus-summary-update-secondary-mark article)))
7536 (defun gnus-summary-set-saved-mark (article)
7537 "Set the process mark on ARTICLE and update the summary line."
7538 (push article gnus-newsgroup-saved)
7539 (when (gnus-summary-goto-subject article)
7540 (gnus-summary-update-secondary-mark article)))
7542 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7543 "Mark N articles as read forwards.
7544 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7545 The difference between N and the actual number of articles marked is
7548 (let ((backward (< n 0))
7549 (gnus-summary-goto-unread
7550 (and gnus-summary-goto-unread
7551 (not (eq gnus-summary-goto-unread 'never))
7552 (not (memq mark (list gnus-unread-mark
7553 gnus-ticked-mark gnus-dormant-mark)))))
7555 (mark (or mark gnus-del-mark)))
7557 (gnus-summary-mark-article nil mark no-expire)
7558 (zerop (gnus-summary-next-subject
7560 (and gnus-summary-goto-unread
7561 (not (eq gnus-summary-goto-unread 'never)))
7565 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7566 (gnus-summary-recenter)
7567 (gnus-summary-position-point)
7568 (gnus-set-mode-line 'summary)
7571 (defun gnus-summary-mark-article-as-read (mark)
7572 "Mark the current article quickly as read with MARK."
7573 (let ((article (gnus-summary-article-number)))
7574 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7575 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7576 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7577 (push (cons article mark) gnus-newsgroup-reads)
7578 ;; Possibly remove from cache, if that is used.
7579 (when gnus-use-cache
7580 (gnus-cache-enter-remove-article article))
7581 ;; Allow the backend to change the mark.
7582 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7583 ;; Check for auto-expiry.
7584 (when (and gnus-newsgroup-auto-expire
7585 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7586 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7587 (= mark gnus-ancient-mark)
7588 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7589 (= mark gnus-duplicate-mark)))
7590 (setq mark gnus-expirable-mark)
7591 (push article gnus-newsgroup-expirable))
7592 ;; Set the mark in the buffer.
7593 (gnus-summary-update-mark mark 'unread)
7596 (defun gnus-summary-mark-article-as-unread (mark)
7597 "Mark the current article quickly as unread with MARK."
7598 (let* ((article (gnus-summary-article-number))
7599 (old-mark (gnus-summary-article-mark article)))
7600 (if (eq mark old-mark)
7604 (gnus-error 1 "Can't mark negative article numbers")
7606 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7607 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7608 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7609 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7610 (cond ((= mark gnus-ticked-mark)
7611 (push article gnus-newsgroup-marked))
7612 ((= mark gnus-dormant-mark)
7613 (push article gnus-newsgroup-dormant))
7615 (push article gnus-newsgroup-unreads)))
7616 (setq gnus-newsgroup-reads
7617 (delq (assq article gnus-newsgroup-reads)
7618 gnus-newsgroup-reads))
7620 ;; See whether the article is to be put in the cache.
7622 (vectorp (gnus-summary-article-header article))
7624 (gnus-cache-possibly-enter-article
7625 gnus-newsgroup-name article
7626 (gnus-summary-article-header article)
7627 (= mark gnus-ticked-mark)
7628 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7631 (gnus-summary-update-mark mark 'unread)
7634 (defun gnus-summary-mark-article (&optional article mark no-expire)
7635 "Mark ARTICLE with MARK. MARK can be any character.
7636 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7637 `??' (dormant) and `?E' (expirable).
7638 If MARK is nil, then the default character `?D' is used.
7639 If ARTICLE is nil, then the article on the current line will be
7641 ;; The mark might be a string.
7642 (when (stringp mark)
7643 (setq mark (aref mark 0)))
7644 ;; If no mark is given, then we check auto-expiring.
7645 (and (not no-expire)
7646 gnus-newsgroup-auto-expire
7648 (and (gnus-characterp mark)
7649 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7650 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7651 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7652 (= mark gnus-duplicate-mark))))
7653 (setq mark gnus-expirable-mark))
7654 (let* ((mark (or mark gnus-del-mark))
7655 (article (or article (gnus-summary-article-number)))
7656 (old-mark (gnus-summary-article-mark article)))
7657 (if (eq mark old-mark)
7660 (error "No article on current line"))
7661 (if (not (if (or (= mark gnus-unread-mark)
7662 (= mark gnus-ticked-mark)
7663 (= mark gnus-dormant-mark))
7664 (gnus-mark-article-as-unread article mark)
7665 (gnus-mark-article-as-read article mark)))
7667 ;; See whether the article is to be put in the cache.
7669 (not (= mark gnus-canceled-mark))
7670 (vectorp (gnus-summary-article-header article))
7672 (gnus-cache-possibly-enter-article
7673 gnus-newsgroup-name article
7674 (gnus-summary-article-header article)
7675 (= mark gnus-ticked-mark)
7676 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7678 (when (gnus-summary-goto-subject article nil t)
7679 (let ((buffer-read-only nil))
7680 (gnus-summary-show-thread)
7682 (gnus-summary-update-mark mark 'unread)
7685 (defun gnus-summary-update-secondary-mark (article)
7686 "Update the secondary (read, process, cache) mark."
7687 (gnus-summary-update-mark
7688 (cond ((memq article gnus-newsgroup-processable)
7690 ((memq article gnus-newsgroup-cached)
7692 ((memq article gnus-newsgroup-replied)
7694 ((memq article gnus-newsgroup-saved)
7696 (t gnus-unread-mark))
7698 (when (gnus-visual-p 'summary-highlight 'highlight)
7699 (gnus-run-hooks 'gnus-summary-update-hook))
7702 (defun gnus-summary-update-mark (mark type)
7703 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7704 (buffer-read-only nil))
7705 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7706 (when (looking-at "\r")
7709 (<= (+ forward (point)) (point-max)))
7710 ;; Go to the right position on the line.
7711 (goto-char (+ forward (point)))
7712 ;; Replace the old mark with the new mark.
7713 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7714 ;; Optionally update the marks by some user rule.
7715 (when (eq type 'unread)
7717 (gnus-data-find (gnus-summary-article-number)) mark)
7718 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7720 (defun gnus-mark-article-as-read (article &optional mark)
7721 "Enter ARTICLE in the pertinent lists and remove it from others."
7722 ;; Make the article expirable.
7723 (let ((mark (or mark gnus-del-mark)))
7724 (if (= mark gnus-expirable-mark)
7725 (push article gnus-newsgroup-expirable)
7726 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7727 ;; Remove from unread and marked lists.
7728 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7729 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7730 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7731 (push (cons article mark) gnus-newsgroup-reads)
7732 ;; Possibly remove from cache, if that is used.
7733 (when gnus-use-cache
7734 (gnus-cache-enter-remove-article article))
7737 (defun gnus-mark-article-as-unread (article &optional mark)
7738 "Enter ARTICLE in the pertinent lists and remove it from others."
7739 (let ((mark (or mark gnus-ticked-mark)))
7742 (gnus-error 1 "Can't mark negative article numbers")
7744 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7745 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7746 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7747 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7749 ;; Unsuppress duplicates?
7750 (when gnus-suppress-duplicates
7751 (gnus-dup-unsuppress-article article))
7753 (cond ((= mark gnus-ticked-mark)
7754 (push article gnus-newsgroup-marked))
7755 ((= mark gnus-dormant-mark)
7756 (push article gnus-newsgroup-dormant))
7758 (push article gnus-newsgroup-unreads)))
7759 (setq gnus-newsgroup-reads
7760 (delq (assq article gnus-newsgroup-reads)
7761 gnus-newsgroup-reads))
7764 (defalias 'gnus-summary-mark-as-unread-forward
7765 'gnus-summary-tick-article-forward)
7766 (make-obsolete 'gnus-summary-mark-as-unread-forward
7767 'gnus-summary-tick-article-forward)
7768 (defun gnus-summary-tick-article-forward (n)
7769 "Tick N articles forwards.
7770 If N is negative, tick backwards instead.
7771 The difference between N and the number of articles ticked is returned."
7773 (gnus-summary-mark-forward n gnus-ticked-mark))
7775 (defalias 'gnus-summary-mark-as-unread-backward
7776 'gnus-summary-tick-article-backward)
7777 (make-obsolete 'gnus-summary-mark-as-unread-backward
7778 'gnus-summary-tick-article-backward)
7779 (defun gnus-summary-tick-article-backward (n)
7780 "Tick N articles backwards.
7781 The difference between N and the number of articles ticked is returned."
7783 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7785 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7786 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7787 (defun gnus-summary-tick-article (&optional article clear-mark)
7788 "Mark current article as unread.
7789 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7790 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7792 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7795 (defun gnus-summary-mark-as-read-forward (n)
7796 "Mark N articles as read forwards.
7797 If N is negative, mark backwards instead.
7798 The difference between N and the actual number of articles marked is
7801 (gnus-summary-mark-forward n gnus-del-mark t))
7803 (defun gnus-summary-mark-as-read-backward (n)
7804 "Mark the N articles as read backwards.
7805 The difference between N and the actual number of articles marked is
7808 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7810 (defun gnus-summary-mark-as-read (&optional article mark)
7811 "Mark current article as read.
7812 ARTICLE specifies the article to be marked as read.
7813 MARK specifies a string to be inserted at the beginning of the line."
7814 (gnus-summary-mark-article article mark))
7816 (defun gnus-summary-clear-mark-forward (n)
7817 "Clear marks from N articles forward.
7818 If N is negative, clear backward instead.
7819 The difference between N and the number of marks cleared is returned."
7821 (gnus-summary-mark-forward n gnus-unread-mark))
7823 (defun gnus-summary-clear-mark-backward (n)
7824 "Clear marks from N articles backward.
7825 The difference between N and the number of marks cleared is returned."
7827 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7829 (defun gnus-summary-mark-unread-as-read ()
7830 "Intended to be used by `gnus-summary-mark-article-hook'."
7831 (when (memq gnus-current-article gnus-newsgroup-unreads)
7832 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7834 (defun gnus-summary-mark-read-and-unread-as-read ()
7835 "Intended to be used by `gnus-summary-mark-article-hook'."
7836 (let ((mark (gnus-summary-article-mark)))
7837 (when (or (gnus-unread-mark-p mark)
7838 (gnus-read-mark-p mark))
7839 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7841 (defun gnus-summary-mark-region-as-read (point mark all)
7842 "Mark all unread articles between point and mark as read.
7843 If given a prefix, mark all articles between point and mark as read,
7844 even ticked and dormant ones."
7845 (interactive "r\nP")
7854 (memq (setq article (gnus-summary-article-number))
7855 gnus-newsgroup-unreads))
7856 (gnus-summary-mark-article article gnus-del-mark))
7858 (gnus-summary-find-next))))))
7860 (defun gnus-summary-mark-below (score mark)
7861 "Mark articles with score less than SCORE with MARK."
7862 (interactive "P\ncMark: ")
7863 (setq score (if score
7864 (prefix-numeric-value score)
7865 (or gnus-summary-default-score 0)))
7867 (set-buffer gnus-summary-buffer)
7868 (goto-char (point-min))
7871 (and (< (gnus-summary-article-score) score)
7872 (gnus-summary-mark-article nil mark))
7873 (gnus-summary-find-next)))))
7875 (defun gnus-summary-kill-below (&optional score)
7876 "Mark articles with score below SCORE as read."
7878 (gnus-summary-mark-below score gnus-killed-mark))
7880 (defun gnus-summary-clear-above (&optional score)
7881 "Clear all marks from articles with score above SCORE."
7883 (gnus-summary-mark-above score gnus-unread-mark))
7885 (defun gnus-summary-tick-above (&optional score)
7886 "Tick all articles with score above SCORE."
7888 (gnus-summary-mark-above score gnus-ticked-mark))
7890 (defun gnus-summary-mark-above (score mark)
7891 "Mark articles with score over SCORE with MARK."
7892 (interactive "P\ncMark: ")
7893 (setq score (if score
7894 (prefix-numeric-value score)
7895 (or gnus-summary-default-score 0)))
7897 (set-buffer gnus-summary-buffer)
7898 (goto-char (point-min))
7900 (when (> (gnus-summary-article-score) score)
7901 (gnus-summary-mark-article nil mark))
7903 (gnus-summary-find-next)))))
7905 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7906 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7907 (defun gnus-summary-limit-include-expunged (&optional no-error)
7908 "Display all the hidden articles that were expunged for low scores."
7910 (let ((buffer-read-only nil))
7911 (let ((scored gnus-newsgroup-scored)
7914 (unless (gnus-summary-goto-subject (caar scored))
7915 (and (setq h (gnus-summary-article-header (caar scored)))
7916 (< (cdar scored) gnus-summary-expunge-below)
7918 (setq scored (cdr scored)))
7920 (when (not no-error)
7921 (error "No expunged articles hidden"))
7922 (goto-char (point-min))
7923 (gnus-summary-prepare-unthreaded (nreverse headers))
7924 (goto-char (point-min))
7925 (gnus-summary-position-point)
7928 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7929 "Mark all unread articles in this newsgroup as read.
7930 If prefix argument ALL is non-nil, ticked and dormant articles will
7931 also be marked as read.
7932 If QUIETLY is non-nil, no questions will be asked.
7933 If TO-HERE is non-nil, it should be a point in the buffer. All
7934 articles before this point will be marked as read.
7935 Note that this function will only catch up the unread article
7936 in the current summary buffer limitation.
7937 The number of articles marked as read is returned."
7942 (not gnus-interactive-catchup) ;Without confirmation?
7946 "Mark absolutely all articles as read? "
7947 "Mark all unread articles as read? ")))
7949 (not gnus-newsgroup-adaptive)
7950 (not gnus-newsgroup-auto-expire)
7951 (not gnus-suppress-duplicates)
7952 (or (not gnus-use-cache)
7953 (eq gnus-use-cache 'passive)))
7956 (setq gnus-newsgroup-marked nil
7957 gnus-newsgroup-dormant nil))
7958 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
7959 ;; We actually mark all articles as canceled, which we
7960 ;; have to do when using auto-expiry or adaptive scoring.
7961 (gnus-summary-show-all-threads)
7962 (when (gnus-summary-first-subject (not all) t)
7964 (if to-here (< (point) to-here) t)
7965 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7966 (gnus-summary-find-next (not all) nil nil t))))
7967 (gnus-set-mode-line 'summary))
7969 (gnus-summary-position-point)))
7971 (defun gnus-summary-catchup-to-here (&optional all)
7972 "Mark all unticked articles before the current one as read.
7973 If ALL is non-nil, also mark ticked and dormant articles as read."
7976 (gnus-save-hidden-threads
7977 (let ((beg (point)))
7978 ;; We check that there are unread articles.
7979 (when (or all (gnus-summary-find-prev))
7980 (gnus-summary-catchup all t beg)))))
7981 (gnus-summary-position-point))
7983 (defun gnus-summary-catchup-all (&optional quietly)
7984 "Mark all articles in this newsgroup as read."
7986 (gnus-summary-catchup t quietly))
7988 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7989 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7990 If prefix argument ALL is non-nil, all articles are marked as read."
7992 (when (gnus-summary-catchup all quietly nil 'fast)
7993 ;; Select next newsgroup or exit.
7994 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
7995 (eq gnus-auto-select-next 'quietly))
7996 (gnus-summary-next-group nil)
7997 (gnus-summary-exit))))
7999 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8000 "Mark all articles in this newsgroup as read, and then exit."
8002 (gnus-summary-catchup-and-exit t quietly))
8004 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8005 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8006 "Mark all articles in this group as read and select the next group.
8007 If given a prefix, mark all articles, unread as well as ticked, as
8011 (gnus-summary-catchup all))
8012 (gnus-summary-next-article t nil nil t))
8014 ;; Thread-based commands.
8016 (defun gnus-summary-articles-in-thread (&optional article)
8017 "Return a list of all articles in the current thread.
8018 If ARTICLE is non-nil, return all articles in the thread that starts
8020 (let* ((article (or article (gnus-summary-article-number)))
8021 (data (gnus-data-find-list article))
8022 (top-level (gnus-data-level (car data)))
8024 (cond ((null gnus-thread-operation-ignore-subject)
8025 (gnus-simplify-subject-re
8026 (mail-header-subject (gnus-data-header (car data)))))
8027 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8028 (gnus-simplify-subject-fuzzy
8029 (mail-header-subject (gnus-data-header (car data)))))
8031 (end-point (save-excursion
8032 (if (gnus-summary-go-to-next-thread)
8033 (point) (point-max))))
8036 (< (gnus-data-pos (car data)) end-point))
8037 (when (or (not top-subject)
8038 (string= top-subject
8039 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8040 (gnus-simplify-subject-fuzzy
8041 (mail-header-subject
8042 (gnus-data-header (car data))))
8043 (gnus-simplify-subject-re
8044 (mail-header-subject
8045 (gnus-data-header (car data)))))))
8046 (push (gnus-data-number (car data)) articles))
8047 (unless (and (setq data (cdr data))
8048 (> (gnus-data-level (car data)) top-level))
8050 ;; Return the list of articles.
8051 (nreverse articles)))
8053 (defun gnus-summary-rethread-current ()
8054 "Rethread the thread the current article is part of."
8056 (let* ((gnus-show-threads t)
8057 (article (gnus-summary-article-number))
8058 (id (mail-header-id (gnus-summary-article-header)))
8059 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8061 (error "No article on the current line"))
8062 (gnus-rebuild-thread id)
8063 (gnus-summary-goto-subject article)))
8065 (defun gnus-summary-reparent-thread ()
8066 "Make the current article child of the marked (or previous) article.
8068 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8069 is non-nil or the Subject: of both articles are the same."
8071 (unless (not (gnus-group-read-only-p))
8072 (error "The current newsgroup does not support article editing"))
8073 (unless (<= (length gnus-newsgroup-processable) 1)
8074 (error "No more than one article may be marked"))
8075 (save-window-excursion
8076 (let ((gnus-article-buffer " *reparent*")
8077 (current-article (gnus-summary-article-number))
8078 ;; First grab the marked article, otherwise one line up.
8079 (parent-article (if (not (null gnus-newsgroup-processable))
8080 (car gnus-newsgroup-processable)
8082 (if (eq (forward-line -1) 0)
8083 (gnus-summary-article-number)
8084 (error "Beginning of summary buffer"))))))
8085 (unless (not (eq current-article parent-article))
8086 (error "An article may not be self-referential"))
8087 (let ((message-id (mail-header-id
8088 (gnus-summary-article-header parent-article))))
8089 (unless (and message-id (not (equal message-id "")))
8090 (error "No message-id in desired parent"))
8091 ;; We don't want the article to be marked as read.
8092 (let (gnus-mark-article-hook)
8093 (gnus-summary-select-article t t nil current-article))
8094 (set-buffer gnus-original-article-buffer)
8095 (let ((buf (format "%s" (buffer-string))))
8096 (nnheader-temp-write nil
8098 (goto-char (point-min))
8099 (if (re-search-forward "^References: " nil t)
8101 (re-search-forward "^[^ \t]" nil t)
8104 (insert " " message-id))
8105 (insert "References: " message-id "\n"))
8106 (unless (gnus-request-replace-article
8107 current-article (car gnus-article-current)
8109 (error "Couldn't replace article"))))
8110 (set-buffer gnus-summary-buffer)
8111 (gnus-summary-unmark-all-processable)
8112 (gnus-summary-update-article current-article)
8113 (gnus-summary-rethread-current)
8114 (gnus-message 3 "Article %d is now the child of article %d"
8115 current-article parent-article)))))
8117 (defun gnus-summary-toggle-threads (&optional arg)
8118 "Toggle showing conversation threads.
8119 If ARG is positive number, turn showing conversation threads on."
8121 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8122 (setq gnus-show-threads
8123 (if (null arg) (not gnus-show-threads)
8124 (> (prefix-numeric-value arg) 0)))
8125 (gnus-summary-prepare)
8126 (gnus-summary-goto-subject current)
8127 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8128 (gnus-summary-position-point)))
8130 (defun gnus-summary-show-all-threads ()
8134 (let ((buffer-read-only nil))
8135 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8136 (gnus-summary-position-point))
8138 (defun gnus-summary-show-thread ()
8139 "Show thread subtrees.
8140 Returns nil if no thread was there to be shown."
8142 (let ((buffer-read-only nil)
8144 ;; first goto end then to beg, to have point at beg after let
8145 (end (progn (end-of-line) (point)))
8146 (beg (progn (beginning-of-line) (point))))
8148 ;; Any hidden lines here?
8149 (search-forward "\r" end t)
8150 (subst-char-in-region beg end ?\^M ?\n t)
8152 (gnus-summary-position-point))))
8154 (defun gnus-summary-hide-all-threads ()
8155 "Hide all thread subtrees."
8158 (goto-char (point-min))
8159 (gnus-summary-hide-thread)
8160 (while (zerop (gnus-summary-next-thread 1 t))
8161 (gnus-summary-hide-thread)))
8162 (gnus-summary-position-point))
8164 (defun gnus-summary-hide-thread ()
8165 "Hide thread subtrees.
8166 Returns nil if no threads were there to be hidden."
8168 (let ((buffer-read-only nil)
8170 (article (gnus-summary-article-number)))
8172 ;; Go forward until either the buffer ends or the subthread
8174 (when (and (not (eobp))
8175 (or (zerop (gnus-summary-next-thread 1 t))
8176 (goto-char (point-max))))
8178 (if (and (> (point) start)
8179 (search-backward "\n" start t))
8181 (subst-char-in-region start (point) ?\n ?\^M)
8182 (gnus-summary-goto-subject article))
8185 ;;(gnus-summary-position-point)
8188 (defun gnus-summary-go-to-next-thread (&optional previous)
8189 "Go to the same level (or less) next thread.
8190 If PREVIOUS is non-nil, go to previous thread instead.
8191 Return the article number moved to, or nil if moving was impossible."
8192 (let ((level (gnus-summary-thread-level))
8193 (way (if previous -1 1))
8196 (while (and (not (eobp))
8197 (< level (gnus-summary-thread-level)))
8205 (gnus-summary-article-number)
8208 (defun gnus-summary-next-thread (n &optional silent)
8209 "Go to the same level next N'th thread.
8210 If N is negative, search backward instead.
8211 Returns the difference between N and the number of skips actually
8214 If SILENT, don't output messages."
8216 (let ((backward (< n 0))
8219 (gnus-summary-go-to-next-thread backward))
8222 (gnus-summary-position-point))
8223 (when (and (not silent) (/= 0 n))
8224 (gnus-message 7 "No more threads"))
8227 (defun gnus-summary-prev-thread (n)
8228 "Go to the same level previous N'th thread.
8229 Returns the difference between N and the number of skips actually
8232 (gnus-summary-next-thread (- n)))
8234 (defun gnus-summary-go-down-thread ()
8235 "Go down one level in the current thread."
8236 (let ((children (gnus-summary-article-children)))
8238 (gnus-summary-goto-subject (car children)))))
8240 (defun gnus-summary-go-up-thread ()
8241 "Go up one level in the current thread."
8242 (let ((parent (gnus-summary-article-parent)))
8244 (gnus-summary-goto-subject parent))))
8246 (defun gnus-summary-down-thread (n)
8247 "Go down thread N steps.
8248 If N is negative, go up instead.
8249 Returns the difference between N and how many steps down that were
8255 (if up (gnus-summary-go-up-thread)
8256 (gnus-summary-go-down-thread)))
8258 (gnus-summary-position-point)
8260 (gnus-message 7 "Can't go further"))
8263 (defun gnus-summary-up-thread (n)
8264 "Go up thread N steps.
8265 If N is negative, go up instead.
8266 Returns the difference between N and how many steps down that were
8269 (gnus-summary-down-thread (- n)))
8271 (defun gnus-summary-top-thread ()
8272 "Go to the top of the thread."
8274 (while (gnus-summary-go-up-thread))
8275 (gnus-summary-article-number))
8277 (defun gnus-summary-kill-thread (&optional unmark)
8278 "Mark articles under current thread as read.
8279 If the prefix argument is positive, remove any kinds of marks.
8280 If the prefix argument is negative, tick articles instead."
8283 (setq unmark (prefix-numeric-value unmark)))
8284 (let ((articles (gnus-summary-articles-in-thread)))
8286 ;; Expand the thread.
8287 (gnus-summary-show-thread)
8288 ;; Mark all the articles.
8290 (gnus-summary-goto-subject (car articles))
8291 (cond ((null unmark)
8292 (gnus-summary-mark-article-as-read gnus-killed-mark))
8294 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8296 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8297 (setq articles (cdr articles))))
8298 ;; Hide killed subtrees.
8300 gnus-thread-hide-killed
8301 (gnus-summary-hide-thread))
8302 ;; If marked as read, go to next unread subject.
8304 ;; Go to next unread subject.
8305 (gnus-summary-next-subject 1 t)))
8306 (gnus-set-mode-line 'summary))
8308 ;; Summary sorting commands
8310 (defun gnus-summary-sort-by-number (&optional reverse)
8311 "Sort the summary buffer by article number.
8312 Argument REVERSE means reverse order."
8314 (gnus-summary-sort 'number reverse))
8316 (defun gnus-summary-sort-by-author (&optional reverse)
8317 "Sort the summary buffer by author name alphabetically.
8318 If case-fold-search is non-nil, case of letters is ignored.
8319 Argument REVERSE means reverse order."
8321 (gnus-summary-sort 'author reverse))
8323 (defun gnus-summary-sort-by-subject (&optional reverse)
8324 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8325 If case-fold-search is non-nil, case of letters is ignored.
8326 Argument REVERSE means reverse order."
8328 (gnus-summary-sort 'subject reverse))
8330 (defun gnus-summary-sort-by-date (&optional reverse)
8331 "Sort the summary buffer by date.
8332 Argument REVERSE means reverse order."
8334 (gnus-summary-sort 'date reverse))
8336 (defun gnus-summary-sort-by-score (&optional reverse)
8337 "Sort the summary buffer by score.
8338 Argument REVERSE means reverse order."
8340 (gnus-summary-sort 'score reverse))
8342 (defun gnus-summary-sort-by-lines (&optional reverse)
8343 "Sort the summary buffer by article length.
8344 Argument REVERSE means reverse order."
8346 (gnus-summary-sort 'lines reverse))
8348 (defun gnus-summary-sort (predicate reverse)
8349 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8350 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8351 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8352 (gnus-thread-sort-functions
8358 (gnus-article-sort-functions
8363 (,article t2 t1)))))
8365 (gnus-summary-prepare-hook nil))
8366 ;; We do the sorting by regenerating the threads.
8367 (gnus-summary-prepare)
8368 ;; Hide subthreads if needed.
8369 (when (and gnus-show-threads gnus-thread-hide-subtree)
8370 (gnus-summary-hide-all-threads))))
8372 ;; Summary saving commands.
8374 (defun gnus-summary-save-article (&optional n not-saved)
8375 "Save the current article using the default saver function.
8376 If N is a positive number, save the N next articles.
8377 If N is a negative number, save the N previous articles.
8378 If N is nil and any articles have been marked with the process mark,
8379 save those articles instead.
8380 The variable `gnus-default-article-saver' specifies the saver function."
8382 (let* ((articles (gnus-summary-work-articles n))
8383 (save-buffer (save-excursion
8384 (nnheader-set-temp-buffer " *Gnus Save*")))
8385 (num (length articles))
8386 header article file)
8388 (setq header (gnus-summary-article-header
8389 (setq article (pop articles))))
8390 (if (not (vectorp header))
8391 ;; This is a pseudo-article.
8392 (if (assq 'name header)
8393 (gnus-copy-file (cdr (assq 'name header)))
8394 (gnus-message 1 "Article %d is unsaveable" article))
8395 ;; This is a real article.
8396 (save-window-excursion
8397 (gnus-summary-select-article t nil nil article))
8399 (set-buffer save-buffer)
8401 (insert-buffer-substring gnus-original-article-buffer))
8402 (setq file (gnus-article-save save-buffer file num))
8403 (gnus-summary-remove-process-mark article)
8405 (gnus-summary-set-saved-mark article))))
8406 (gnus-kill-buffer save-buffer)
8407 (gnus-summary-position-point)
8408 (gnus-set-mode-line 'summary)
8411 (defun gnus-summary-pipe-output (&optional arg)
8412 "Pipe the current article to a subprocess.
8413 If N is a positive number, pipe the N next articles.
8414 If N is a negative number, pipe the N previous articles.
8415 If N is nil and any articles have been marked with the process mark,
8416 pipe those articles instead."
8418 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8419 (gnus-summary-save-article arg t))
8420 (gnus-configure-windows 'pipe))
8422 (defun gnus-summary-save-article-mail (&optional arg)
8423 "Append the current article to an mail file.
8424 If N is a positive number, save the N next articles.
8425 If N is a negative number, save the N previous articles.
8426 If N is nil and any articles have been marked with the process mark,
8427 save those articles instead."
8429 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8430 (gnus-summary-save-article arg)))
8432 (defun gnus-summary-save-article-rmail (&optional arg)
8433 "Append the current article to an rmail file.
8434 If N is a positive number, save the N next articles.
8435 If N is a negative number, save the N previous articles.
8436 If N is nil and any articles have been marked with the process mark,
8437 save those articles instead."
8439 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8440 (gnus-summary-save-article arg)))
8442 (defun gnus-summary-save-article-file (&optional arg)
8443 "Append the current article to a file.
8444 If N is a positive number, save the N next articles.
8445 If N is a negative number, save the N previous articles.
8446 If N is nil and any articles have been marked with the process mark,
8447 save those articles instead."
8449 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8450 (gnus-summary-save-article arg)))
8452 (defun gnus-summary-write-article-file (&optional arg)
8453 "Write the current article to a file, deleting the previous file.
8454 If N is a positive number, save the N next articles.
8455 If N is a negative number, save the N previous articles.
8456 If N is nil and any articles have been marked with the process mark,
8457 save those articles instead."
8459 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8460 (gnus-summary-save-article arg)))
8462 (defun gnus-summary-save-article-body-file (&optional arg)
8463 "Append the current article body to a file.
8464 If N is a positive number, save the N next articles.
8465 If N is a negative number, save the N previous articles.
8466 If N is nil and any articles have been marked with the process mark,
8467 save those articles instead."
8469 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8470 (gnus-summary-save-article arg)))
8472 (defun gnus-summary-pipe-message (program)
8473 "Pipe the current article through PROGRAM."
8474 (interactive "sProgram: ")
8475 (gnus-summary-select-article)
8476 (let ((mail-header-separator "")
8477 (art-buf (get-buffer gnus-article-buffer)))
8478 (gnus-eval-in-buffer-window gnus-article-buffer
8481 (let ((start (window-start))
8483 (message-pipe-buffer-body program)
8484 (set-window-start (get-buffer-window (current-buffer)) start))))))
8486 (defun gnus-get-split-value (methods)
8487 "Return a value based on the split METHODS."
8488 (let (split-name method result match)
8491 (set-buffer gnus-original-article-buffer)
8493 (nnheader-narrow-to-headers)
8495 (goto-char (point-min))
8496 (setq method (pop methods))
8497 (setq match (car method))
8500 ;; Regular expression.
8502 (re-search-forward match nil t)))
8503 ((gnus-functionp match)
8507 (setq result (funcall match gnus-newsgroup-name))))
8512 (setq result (eval match)))))
8513 (setq split-name (append (cdr method) split-name))
8514 (cond ((stringp result)
8515 (push (expand-file-name
8516 result gnus-article-save-directory)
8519 (setq split-name (append result split-name)))))))))
8522 (defun gnus-valid-move-group-p (group)
8527 (car (gnus-find-method-for-group
8528 (symbol-name group))))
8529 gnus-valid-select-methods))))
8531 (defun gnus-read-move-group-name (prompt default articles prefix)
8532 "Read a group name."
8533 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8534 (minibuffer-confirm-incomplete nil) ; XEmacs
8538 (if (> (length articles) 1)
8539 (format "these %d articles" (length articles))
8544 (gnus-completing-read default prom
8546 'gnus-valid-move-group-p
8548 'gnus-group-history))
8549 ((= 1 (length split-name))
8550 (gnus-completing-read (car split-name) prom
8552 'gnus-valid-move-group-p
8554 'gnus-group-history))
8556 (gnus-completing-read nil prom
8557 (mapcar (lambda (el) (list el))
8558 (nreverse split-name))
8560 'gnus-group-history)))))
8562 (if (or (string= to-newsgroup "")
8563 (string= to-newsgroup prefix))
8564 (setq to-newsgroup default))
8565 (unless to-newsgroup
8566 (error "No group name entered"))
8567 (or (gnus-active to-newsgroup)
8568 (gnus-activate-group to-newsgroup)
8569 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8571 (or (and (gnus-request-create-group
8572 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8573 (gnus-activate-group to-newsgroup nil nil
8574 (gnus-group-name-to-method
8576 (error "Couldn't create group %s" to-newsgroup)))
8577 (error "No such group: %s" to-newsgroup)))
8580 ;; Summary extract commands
8582 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8583 (let ((buffer-read-only nil)
8584 (article (gnus-summary-article-number))
8586 (unless (gnus-summary-goto-subject article)
8587 (error "No such article: %d" article))
8588 (gnus-summary-position-point)
8589 ;; If all commands are to be bunched up on one line, we collect
8591 (unless gnus-view-pseudos-separately
8592 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8595 (setq action (cdr (assq 'action (car ps))))
8596 (setq files (list (cdr (assq 'name (car ps)))))
8597 (while (and ps (cdr ps)
8598 (string= (or action "1")
8599 (or (cdr (assq 'action (cadr ps))) "2")))
8600 (push (cdr (assq 'name (cadr ps))) files)
8601 (setcdr ps (cddr ps)))
8603 (when (not (string-match "%s" action))
8606 (when (assq 'execute (car ps))
8607 (setcdr (assq 'execute (car ps))
8608 (funcall (if (string-match "%s" action)
8615 (gnus-quote-arg-for-sh-or-csh f)))
8617 (setq ps (cdr ps)))))
8618 (if (and gnus-view-pseudos (not not-view))
8620 (when (assq 'execute (car pslist))
8621 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8622 (eq gnus-view-pseudos 'not-confirm)))
8623 (setq pslist (cdr pslist)))
8626 (setq after-article (or (cdr (assq 'article (car pslist)))
8627 (gnus-summary-article-number)))
8628 (gnus-summary-goto-subject after-article)
8631 (insert " " (file-name-nondirectory
8632 (cdr (assq 'name (car pslist))))
8633 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8635 (forward-line -1) ; back to `b'
8636 (gnus-add-text-properties
8637 b (1- e) (list 'gnus-number gnus-reffed-article-number
8638 gnus-mouse-face-prop gnus-mouse-face))
8640 after-article gnus-reffed-article-number
8641 gnus-unread-mark b (car pslist) 0 (- e b))
8642 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8643 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8644 (setq pslist (cdr pslist)))))))
8646 (defun gnus-pseudos< (p1 p2)
8647 (let ((c1 (cdr (assq 'action p1)))
8648 (c2 (cdr (assq 'action p2))))
8649 (and c1 c2 (string< c1 c2))))
8651 (defun gnus-request-pseudo-article (props)
8652 (cond ((assq 'execute props)
8653 (gnus-execute-command (cdr (assq 'execute props)))))
8654 (let ((gnus-current-article (gnus-summary-article-number)))
8655 (gnus-run-hooks 'gnus-mark-article-hook)))
8657 (defun gnus-execute-command (command &optional automatic)
8659 (gnus-article-setup-buffer)
8660 (set-buffer gnus-article-buffer)
8661 (setq buffer-read-only nil)
8662 (let ((command (if automatic command
8663 (read-string "Command: " (cons command 0)))))
8665 (insert "$ " command "\n\n")
8666 (if gnus-view-pseudo-asynchronously
8667 (start-process "gnus-execute" (current-buffer) shell-file-name
8668 shell-command-switch command)
8669 (call-process shell-file-name nil t nil
8670 shell-command-switch command)))))
8672 ;; Summary kill commands.
8674 (defun gnus-summary-edit-global-kill (article)
8675 "Edit the \"global\" kill file."
8676 (interactive (list (gnus-summary-article-number)))
8677 (gnus-group-edit-global-kill article))
8679 (defun gnus-summary-edit-local-kill ()
8680 "Edit a local kill file applied to the current newsgroup."
8682 (setq gnus-current-headers (gnus-summary-article-header))
8683 (gnus-group-edit-local-kill
8684 (gnus-summary-article-number) gnus-newsgroup-name))
8688 (defun gnus-read-header (id &optional header)
8689 "Read the headers of article ID and enter them into the Gnus system."
8690 (let ((group gnus-newsgroup-name)
8691 (gnus-override-method
8692 (and (gnus-news-group-p gnus-newsgroup-name)
8693 gnus-refer-article-method))
8695 ;; First we check to see whether the header in question is already
8698 ;; This is a Message-ID.
8699 (setq header (or header (gnus-id-to-header id)))
8700 ;; This is an article number.
8701 (setq header (or header (gnus-summary-article-header id))))
8703 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8704 ;; We have found the header.
8706 ;; If this is a sparse article, we have to nix out its
8707 ;; previous entry in the thread hashtb.
8709 (gnus-summary-article-sparse-p (mail-header-number header)))
8710 (let* ((parent (gnus-parent-id (mail-header-references header)))
8711 (thread (and parent (gnus-id-to-thread parent))))
8713 (delq (assq header thread) thread))))
8714 ;; We have to really fetch the header to this article.
8716 (set-buffer nntp-server-buffer)
8717 (when (setq where (gnus-request-head id group))
8718 (nnheader-fold-continuation-lines)
8719 (goto-char (point-max))
8721 (goto-char (point-min))
8725 ((cdr where) (cdr where))
8726 (header (mail-header-number header))
8727 (t gnus-reffed-article-number))
8729 (insert " Article retrieved.\n"))
8731 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8732 () ; Malformed head.
8733 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8734 (when (and (stringp id)
8735 (not (string= (gnus-group-real-name group)
8737 ;; If we fetched by Message-ID and the article came
8738 ;; from a different group, we fudge some bogus article
8739 ;; numbers for this article.
8740 (mail-header-set-number header gnus-reffed-article-number))
8742 (set-buffer gnus-summary-buffer)
8743 (decf gnus-reffed-article-number)
8744 (gnus-remove-header (mail-header-number header))
8745 (push header gnus-newsgroup-headers)
8746 (setq gnus-current-headers header)
8747 (push (mail-header-number header) gnus-newsgroup-limit)))
8750 (defun gnus-remove-header (number)
8751 "Remove header NUMBER from `gnus-newsgroup-headers'."
8752 (if (and gnus-newsgroup-headers
8753 (= number (mail-header-number (car gnus-newsgroup-headers))))
8754 (pop gnus-newsgroup-headers)
8755 (let ((headers gnus-newsgroup-headers))
8756 (while (and (cdr headers)
8757 (not (= number (mail-header-number (cadr headers)))))
8760 (setcdr headers (cddr headers))))))
8763 ;;; summary highlights
8766 (defun gnus-highlight-selected-summary ()
8767 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8768 ;; Highlight selected article in summary buffer
8769 (when gnus-summary-selected-face
8771 (let* ((beg (progn (beginning-of-line) (point)))
8772 (end (progn (end-of-line) (point)))
8773 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8774 (from (if (get-text-property beg gnus-mouse-face-prop)
8776 (or (next-single-property-change
8777 beg gnus-mouse-face-prop nil end)
8782 (or (next-single-property-change
8783 from gnus-mouse-face-prop nil end)
8785 ;; If no mouse-face prop on line we will have to = from = end,
8786 ;; so we highlight the entire line instead.
8787 (when (= (+ to 2) from)
8790 (if gnus-newsgroup-selected-overlay
8791 ;; Move old overlay.
8793 gnus-newsgroup-selected-overlay from to (current-buffer))
8794 ;; Create new overlay.
8796 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8797 'face gnus-summary-selected-face))))))
8799 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8800 (defun gnus-summary-highlight-line ()
8801 "Highlight current line according to `gnus-summary-highlight'."
8802 (let* ((list gnus-summary-highlight)
8804 (end (progn (end-of-line) (point)))
8805 ;; now find out where the line starts and leave point there.
8806 (beg (progn (beginning-of-line) (point)))
8807 (article (gnus-summary-article-number))
8808 (score (or (cdr (assq (or article gnus-current-article)
8809 gnus-newsgroup-scored))
8810 gnus-summary-default-score 0))
8811 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8812 (inhibit-read-only t))
8813 ;; Eval the cars of the lists until we find a match.
8814 (let ((default gnus-summary-default-score))
8816 (not (eval (caar list))))
8817 (setq list (cdr list))))
8818 (let ((face (cdar list)))
8819 (unless (eq face (get-text-property beg 'face))
8820 (gnus-put-text-property
8822 (setq face (if (boundp face) (symbol-value face) face)))
8823 (when gnus-summary-highlight-line-function
8824 (funcall gnus-summary-highlight-line-function article face))))
8827 (defun gnus-update-read-articles (group unread &optional compute)
8828 "Update the list of read articles in GROUP."
8829 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8830 (entry (gnus-gethash group gnus-newsrc-hashtb))
8831 (info (nth 2 entry))
8833 (unread (sort (copy-sequence unread) '<))
8835 (if (or (not info) (not active))
8836 ;; There is no info on this group if it was, in fact,
8837 ;; killed. Gnus stores no information on killed groups, so
8838 ;; there's nothing to be done.
8839 ;; One could store the information somewhere temporarily,
8840 ;; perhaps... Hmmm...
8842 ;; Remove any negative articles numbers.
8843 (while (and unread (< (car unread) 0))
8844 (setq unread (cdr unread)))
8845 ;; Remove any expired article numbers
8846 (while (and unread (< (car unread) (car active)))
8847 (setq unread (cdr unread)))
8848 ;; Compute the ranges of read articles by looking at the list of
8851 (when (/= (car unread) prev)
8852 (push (if (= prev (1- (car unread))) prev
8853 (cons prev (1- (car unread))))
8855 (setq prev (1+ (car unread)))
8856 (setq unread (cdr unread)))
8857 (when (<= prev (cdr active))
8858 (push (cons prev (cdr active)) read))
8860 (if (> (length read) 1) (nreverse read) read)
8862 (set-buffer gnus-group-buffer)
8865 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8866 (gnus-info-set-read ',info ',(gnus-info-read info))
8867 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8868 (gnus-group-update-group ,group t))))
8869 ;; Enter this list into the group info.
8871 info (if (> (length read) 1) (nreverse read) read))
8872 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8873 (gnus-get-unread-articles-in-group info (gnus-active group))
8876 (defun gnus-offer-save-summaries ()
8877 "Offer to save all active summary buffers."
8879 (let ((buflist (buffer-list))
8881 ;; Go through all buffers and find all summaries.
8883 (and (setq bufname (buffer-name (car buflist)))
8884 (string-match "Summary" bufname)
8886 (set-buffer bufname)
8887 ;; We check that this is, indeed, a summary buffer.
8888 (and (eq major-mode 'gnus-summary-mode)
8889 ;; Also make sure this isn't bogus.
8890 gnus-newsgroup-prepared
8891 ;; Also make sure that this isn't a dead summary buffer.
8892 (not gnus-dead-summary-mode)))
8893 (push bufname buffers))
8894 (setq buflist (cdr buflist)))
8895 ;; Go through all these summary buffers and offer to save them.
8898 "Update summary buffer %s? "
8900 (switch-to-buffer buf)
8901 (gnus-summary-exit))
8908 (run-hooks 'gnus-sum-load-hook)
8910 ;;; gnus-sum.el ends here