1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
39 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
42 (defcustom gnus-kill-summary-on-exit t
43 "*If non-nil, kill the summary buffer when you exit from it.
44 If nil, the summary will become a \"*Dead Summary*\" buffer, and
45 it will be killed sometime later."
46 :group 'gnus-summary-exit
49 (defcustom gnus-fetch-old-headers nil
50 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
51 If an unread article in the group refers to an older, already read (or
52 just marked as read) article, the old article will not normally be
53 displayed in the Summary buffer. If this variable is non-nil, Gnus
54 will attempt to grab the headers to the old articles, and thereby
55 build complete threads. If it has the value `some', only enough
56 headers to connect otherwise loose threads will be displayed. This
57 variable can also be a number. In that case, no more than that number
58 of old headers will be fetched. If it has the value `invisible', all
59 old headers will be fetched, but none will be displayed.
61 The server has to support NOV for any of this to work."
63 :type '(choice (const :tag "off" nil)
66 (sexp :menu-tag "other" t)))
68 (defcustom gnus-refer-thread-limit 200
69 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
70 If t, fetch all the available old headers."
73 (sexp :menu-tag "other" t)))
75 (defcustom gnus-summary-make-false-root 'adopt
76 "*nil means that Gnus won't gather loose threads.
77 If the root of a thread has expired or been read in a previous
78 session, the information necessary to build a complete thread has been
79 lost. Instead of having many small sub-threads from this original thread
80 scattered all over the summary buffer, Gnus can gather them.
82 If non-nil, Gnus will try to gather all loose sub-threads from an
83 original thread into one large thread.
85 If this variable is non-nil, it should be one of `none', `adopt',
88 If this variable is `none', Gnus will not make a false root, but just
89 present the sub-threads after another.
90 If this variable is `dummy', Gnus will create a dummy root that will
91 have all the sub-threads as children.
92 If this variable is `adopt', Gnus will make one of the \"children\"
93 the parent and mark all the step-children as such.
94 If this variable is `empty', the \"children\" are printed with empty
95 subject fields. (Or rather, they will be printed with a string
96 given by the `gnus-summary-same-subject' variable.)"
98 :type '(choice (const :tag "off" nil)
104 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
105 "*A regexp to match subjects to be excluded from loose thread gathering.
106 As loose thread gathering is done on subjects only, that means that
107 there can be many false gatherings performed. By rooting out certain
108 common subjects, gathering might become saner."
112 (defcustom gnus-summary-gather-subject-limit nil
113 "*Maximum length of subject comparisons when gathering loose threads.
114 Use nil to compare full subjects. Setting this variable to a low
115 number will help gather threads that have been corrupted by
116 newsreaders chopping off subject lines, but it might also mean that
117 unrelated articles that have subject that happen to begin with the
118 same few characters will be incorrectly gathered.
120 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
123 :type '(choice (const :tag "off" nil)
125 (sexp :menu-tag "on" t)))
127 (defcustom gnus-simplify-subject-functions nil
128 "List of functions taking a string argument that simplify subjects.
129 The functions are applied recursively."
131 :type '(repeat (list function)))
133 (defcustom gnus-simplify-ignored-prefixes nil
134 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
136 :type '(choice (const :tag "off" nil)
139 (defcustom gnus-build-sparse-threads nil
140 "*If non-nil, fill in the gaps in threads.
141 If `some', only fill in the gaps that are needed to tie loose threads
142 together. If `more', fill in all leaf nodes that Gnus can find. If
143 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
145 :type '(choice (const :tag "off" nil)
148 (sexp :menu-tag "all" t)))
150 (defcustom gnus-summary-thread-gathering-function
151 'gnus-gather-threads-by-subject
152 "Function used for gathering loose threads.
153 There are two pre-defined functions: `gnus-gather-threads-by-subject',
154 which only takes Subjects into consideration; and
155 `gnus-gather-threads-by-references', which compared the References
156 headers of the articles to find matches."
158 :type '(radio (function-item gnus-gather-threads-by-subject)
159 (function-item gnus-gather-threads-by-references)
160 (function :tag "other")))
162 (defcustom gnus-summary-same-subject ""
163 "*String indicating that the current article has the same subject as the previous.
164 This variable will only be used if the value of
165 `gnus-summary-make-false-root' is `empty'."
166 :group 'gnus-summary-format
169 (defcustom gnus-summary-goto-unread t
170 "*If t, marking commands will go to the next unread article.
171 If `never', commands that usually go to the next unread article, will
172 go to the next article, whether it is read or not.
173 If nil, only the marking commands will go to the next (un)read article."
174 :group 'gnus-summary-marks
175 :link '(custom-manual "(gnus)Setting Marks")
176 :type '(choice (const :tag "off" nil)
178 (sexp :menu-tag "on" t)))
180 (defcustom gnus-summary-default-score 0
181 "*Default article score level.
182 All scores generated by the score files will be added to this score.
183 If this variable is nil, scoring will be disabled."
184 :group 'gnus-score-default
185 :type '(choice (const :tag "disable")
188 (defcustom gnus-summary-zcore-fuzz 0
189 "*Fuzziness factor for the zcore in the summary buffer.
190 Articles with scores closer than this to `gnus-summary-default-score'
192 :group 'gnus-summary-format
195 (defcustom gnus-simplify-subject-fuzzy-regexp nil
196 "*Strings to be removed when doing fuzzy matches.
197 This can either be a regular expression or list of regular expressions
198 that will be removed from subject strings if fuzzy subject
199 simplification is selected."
201 :type '(repeat regexp))
203 (defcustom gnus-show-threads t
204 "*If non-nil, display threads in summary mode."
208 (defcustom gnus-thread-hide-subtree nil
209 "*If non-nil, hide all threads initially.
210 If threads are hidden, you have to run the command
211 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
212 to expose hidden threads."
216 (defcustom gnus-thread-hide-killed t
217 "*If non-nil, hide killed threads automatically."
221 (defcustom gnus-thread-ignore-subject nil
222 "*If non-nil, ignore subjects and do all threading based on the Reference header.
223 If nil, which is the default, articles that have different subjects
224 from their parents will start separate threads."
228 (defcustom gnus-thread-operation-ignore-subject t
229 "*If non-nil, subjects will be ignored when doing thread commands.
230 This affects commands like `gnus-summary-kill-thread' and
231 `gnus-summary-lower-thread'.
233 If this variable is nil, articles in the same thread with different
234 subjects will not be included in the operation in question. If this
235 variable is `fuzzy', only articles that have subjects that are fuzzily
236 equal will be included."
238 :type '(choice (const :tag "off" nil)
242 (defcustom gnus-thread-indent-level 4
243 "*Number that says how much each sub-thread should be indented."
247 (defcustom gnus-auto-extend-newsgroup t
248 "*If non-nil, extend newsgroup forward and backward when requested."
249 :group 'gnus-summary-choose
252 (defcustom gnus-auto-select-first t
253 "*If nil, don't select the first unread article when entering a group.
254 If this variable is `best', select the highest-scored unread article
255 in the group. If neither nil nor `best', select the first unread
258 If you want to prevent automatic selection of the first unread article
259 in some newsgroups, set the variable to nil in
260 `gnus-select-group-hook'."
261 :group 'gnus-group-select
262 :type '(choice (const :tag "none" nil)
264 (sexp :menu-tag "first" t)))
266 (defcustom gnus-auto-select-next t
267 "*If non-nil, offer to go to the next group from the end of the previous.
268 If the value is t and the next newsgroup is empty, Gnus will exit
269 summary mode and go back to group mode. If the value is neither nil
270 nor t, Gnus will select the following unread newsgroup. In
271 particular, if the value is the symbol `quietly', the next unread
272 newsgroup will be selected without any confirmation, and if it is
273 `almost-quietly', the next group will be selected without any
274 confirmation if you are located on the last article in the group.
275 Finally, if this variable is `slightly-quietly', the `Z n' command
276 will go to the next group without confirmation."
277 :group 'gnus-summary-maneuvering
278 :type '(choice (const :tag "off" nil)
280 (const almost-quietly)
281 (const slightly-quietly)
282 (sexp :menu-tag "on" t)))
284 (defcustom gnus-auto-select-same nil
285 "*If non-nil, select the next article with the same subject."
286 :group 'gnus-summary-maneuvering
289 (defcustom gnus-summary-check-current nil
290 "*If non-nil, consider the current article when moving.
291 The \"unread\" movement commands will stay on the same line if the
292 current article is unread."
293 :group 'gnus-summary-maneuvering
296 (defcustom gnus-auto-center-summary t
297 "*If non-nil, always center the current summary buffer.
298 In particular, if `vertical' do only vertical recentering. If non-nil
299 and non-`vertical', do both horizontal and vertical recentering."
300 :group 'gnus-summary-maneuvering
301 :type '(choice (const :tag "none" nil)
303 (sexp :menu-tag "both" t)))
305 (defcustom gnus-show-all-headers nil
306 "*If non-nil, don't hide any headers."
307 :group 'gnus-article-hiding
308 :group 'gnus-article-headers
311 (defcustom gnus-summary-ignore-duplicates nil
312 "*If non-nil, ignore articles with identical Message-ID headers."
316 (defcustom gnus-single-article-buffer t
317 "*If non-nil, display all articles in the same buffer.
318 If nil, each group will get its own article buffer."
319 :group 'gnus-article-various
322 (defcustom gnus-break-pages t
323 "*If non-nil, do page breaking on articles.
324 The page delimiter is specified by the `gnus-page-delimiter'
326 :group 'gnus-article-various
329 (defcustom gnus-show-mime t
330 "*If non-nil, do mime processing of articles.
331 The articles will simply be fed to the function given by
332 `gnus-show-mime-method'."
333 :group 'gnus-article-mime
336 (defcustom gnus-move-split-methods nil
337 "*Variable used to suggest where articles are to be moved to.
338 It uses the same syntax as the `gnus-split-methods' variable."
339 :group 'gnus-summary-mail
340 :type '(repeat (choice (list :value (fun) function)
341 (cons :value ("" "") regexp (repeat string))
344 (defcustom gnus-unread-mark ?
345 "*Mark used for unread articles."
346 :group 'gnus-summary-marks
349 (defcustom gnus-ticked-mark ?!
350 "*Mark used for ticked articles."
351 :group 'gnus-summary-marks
354 (defcustom gnus-dormant-mark ??
355 "*Mark used for dormant articles."
356 :group 'gnus-summary-marks
359 (defcustom gnus-del-mark ?r
360 "*Mark used for del'd articles."
361 :group 'gnus-summary-marks
364 (defcustom gnus-read-mark ?R
365 "*Mark used for read articles."
366 :group 'gnus-summary-marks
369 (defcustom gnus-expirable-mark ?E
370 "*Mark used for expirable articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-killed-mark ?K
375 "*Mark used for killed articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-souped-mark ?F
380 "*Mark used for killed articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-kill-file-mark ?X
385 "*Mark used for articles killed by kill files."
386 :group 'gnus-summary-marks
389 (defcustom gnus-low-score-mark ?Y
390 "*Mark used for articles with a low score."
391 :group 'gnus-summary-marks
394 (defcustom gnus-catchup-mark ?C
395 "*Mark used for articles that are caught up."
396 :group 'gnus-summary-marks
399 (defcustom gnus-replied-mark ?A
400 "*Mark used for articles that have been replied to."
401 :group 'gnus-summary-marks
404 (defcustom gnus-cached-mark ?*
405 "*Mark used for articles that are in the cache."
406 :group 'gnus-summary-marks
409 (defcustom gnus-saved-mark ?S
410 "*Mark used for articles that have been saved to."
411 :group 'gnus-summary-marks
414 (defcustom gnus-ancient-mark ?O
415 "*Mark used for ancient articles."
416 :group 'gnus-summary-marks
419 (defcustom gnus-sparse-mark ?Q
420 "*Mark used for sparsely reffed articles."
421 :group 'gnus-summary-marks
424 (defcustom gnus-canceled-mark ?G
425 "*Mark used for canceled articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-duplicate-mark ?M
430 "*Mark used for duplicate articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-undownloaded-mark ?@
435 "*Mark used for articles that weren't downloaded."
436 :group 'gnus-summary-marks
439 (defcustom gnus-downloadable-mark ?%
440 "*Mark used for articles that are to be downloaded."
441 :group 'gnus-summary-marks
444 (defcustom gnus-unsendable-mark ?=
445 "*Mark used for articles that won't be sent."
446 :group 'gnus-summary-marks
449 (defcustom gnus-score-over-mark ?+
450 "*Score mark used for articles with high scores."
451 :group 'gnus-summary-marks
454 (defcustom gnus-score-below-mark ?-
455 "*Score mark used for articles with low scores."
456 :group 'gnus-summary-marks
459 (defcustom gnus-empty-thread-mark ?
460 "*There is no thread under the article."
461 :group 'gnus-summary-marks
464 (defcustom gnus-not-empty-thread-mark ?=
465 "*There is a thread under the article."
466 :group 'gnus-summary-marks
469 (defcustom gnus-view-pseudo-asynchronously nil
470 "*If non-nil, Gnus will view pseudo-articles asynchronously."
471 :group 'gnus-extract-view
474 (defcustom gnus-view-pseudos nil
475 "*If `automatic', pseudo-articles will be viewed automatically.
476 If `not-confirm', pseudos will be viewed automatically, and the user
477 will not be asked to confirm the command."
478 :group 'gnus-extract-view
479 :type '(choice (const :tag "off" nil)
481 (const not-confirm)))
483 (defcustom gnus-view-pseudos-separately t
484 "*If non-nil, one pseudo-article will be created for each file to be viewed.
485 If nil, all files that use the same viewing command will be given as a
486 list of parameters to that command."
487 :group 'gnus-extract-view
490 (defcustom gnus-insert-pseudo-articles t
491 "*If non-nil, insert pseudo-articles when decoding articles."
492 :group 'gnus-extract-view
495 (defcustom gnus-summary-dummy-line-format
497 "*The format specification for the dummy roots in the summary buffer.
498 It works along the same lines as a normal formatting string,
499 with some simple extensions.
502 :group 'gnus-threading
505 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
506 "*The format specification for the summary mode line.
507 It works along the same lines as a normal formatting string,
508 with some simple extensions:
511 %p Unprefixed group name
512 %A Current article number
514 %U Number of unread articles in the group
515 %e Number of unselected articles in the group
516 %Z A string with unread/unselected article counts
517 %g Shortish group name
518 %S Subject of the current article
520 %s Current score file name
521 %d Number of dormant articles
522 %r Number of articles that have been marked as read in this session
523 %E Number of articles expunged by the score files"
524 :group 'gnus-summary-format
527 (defcustom gnus-summary-mark-below 0
528 "*Mark all articles with a score below this variable as read.
529 This variable is local to each summary buffer and usually set by the
531 :group 'gnus-score-default
534 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
535 "*List of functions used for sorting articles in the summary buffer.
536 This variable is only used when not using a threaded display."
537 :group 'gnus-summary-sort
538 :type '(repeat (choice (function-item gnus-article-sort-by-number)
539 (function-item gnus-article-sort-by-author)
540 (function-item gnus-article-sort-by-subject)
541 (function-item gnus-article-sort-by-date)
542 (function-item gnus-article-sort-by-score)
543 (function :tag "other"))))
545 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
546 "*List of functions used for sorting threads in the summary buffer.
547 By default, threads are sorted by article number.
549 Each function takes two threads and return non-nil if the first thread
550 should be sorted before the other. If you use more than one function,
551 the primary sort function should be the last. You should probably
552 always include `gnus-thread-sort-by-number' in the list of sorting
553 functions -- preferably first.
555 Ready-made functions include `gnus-thread-sort-by-number',
556 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
557 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
558 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
559 :group 'gnus-summary-sort
560 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
561 (function-item gnus-thread-sort-by-author)
562 (function-item gnus-thread-sort-by-subject)
563 (function-item gnus-thread-sort-by-date)
564 (function-item gnus-thread-sort-by-score)
565 (function-item gnus-thread-sort-by-total-score)
566 (function :tag "other"))))
568 (defcustom gnus-thread-score-function '+
569 "*Function used for calculating the total score of a thread.
571 The function is called with the scores of the article and each
572 subthread and should then return the score of the thread.
574 Some functions you can use are `+', `max', or `min'."
575 :group 'gnus-summary-sort
578 (defcustom gnus-summary-expunge-below nil
579 "All articles that have a score less than this variable will be expunged.
580 This variable is local to the summary buffers."
581 :group 'gnus-score-default
582 :type '(choice (const :tag "off" nil)
585 (defcustom gnus-thread-expunge-below nil
586 "All threads that have a total score less than this variable will be expunged.
587 See `gnus-thread-score-function' for en explanation of what a
590 This variable is local to the summary buffers."
591 :group 'gnus-treading
592 :group 'gnus-score-default
593 :type '(choice (const :tag "off" nil)
596 (defcustom gnus-summary-mode-hook nil
597 "*A hook for Gnus summary mode.
598 This hook is run before any variables are set in the summary buffer."
599 :group 'gnus-summary-various
602 (defcustom gnus-summary-menu-hook nil
603 "*Hook run after the creation of the summary mode menu."
604 :group 'gnus-summary-visual
607 (defcustom gnus-summary-exit-hook nil
608 "*A hook called on exit from the summary buffer.
609 It will be called with point in the group buffer."
610 :group 'gnus-summary-exit
613 (defcustom gnus-summary-prepare-hook nil
614 "*A hook called after the summary buffer has been generated.
615 If you want to modify the summary buffer, you can use this hook."
616 :group 'gnus-summary-various
619 (defcustom gnus-summary-prepared-hook nil
620 "*A hook called as the last thing after the summary buffer has been generated."
621 :group 'gnus-summary-various
624 (defcustom gnus-summary-generate-hook nil
625 "*A hook run just before generating the summary buffer.
626 This hook is commonly used to customize threading variables and the
628 :group 'gnus-summary-various
631 (defcustom gnus-select-group-hook nil
632 "*A hook called when a newsgroup is selected.
634 If you'd like to simplify subjects like the
635 `gnus-summary-next-same-subject' command does, you can use the
638 (setq gnus-select-group-hook
641 (mapcar (lambda (header)
642 (mail-header-set-subject
644 (gnus-simplify-subject
645 (mail-header-subject header) 're-only)))
646 gnus-newsgroup-headers))))"
647 :group 'gnus-group-select
650 (defcustom gnus-select-article-hook nil
651 "*A hook called when an article is selected."
652 :group 'gnus-summary-choose
655 (defcustom gnus-visual-mark-article-hook
656 (list 'gnus-highlight-selected-summary)
657 "*Hook run after selecting an article in the summary buffer.
658 It is meant to be used for highlighting the article in some way. It
659 is not run if `gnus-visual' is nil."
660 :group 'gnus-summary-visual
663 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
664 (defcustom gnus-structured-field-decoder
667 (eword-decode-structured-field-body
668 (std11-unfold-string string) 'must-unfold)
670 "Function to decode non-ASCII characters in structured field for summary."
674 (defcustom gnus-unstructured-field-decoder
677 (eword-decode-unstructured-field-body
678 (std11-unfold-string string) 'must-unfold)
680 "Function to decode non-ASCII characters in unstructured field for summary."
684 (defcustom gnus-parse-headers-hook
685 '(gnus-set-summary-default-charset)
686 "*A hook called before parsing the headers."
690 (defcustom gnus-exit-group-hook nil
691 "*A hook called when exiting (not quitting) summary mode."
695 (defcustom gnus-summary-update-hook
696 (list 'gnus-summary-highlight-line)
697 "*A hook called when a summary line is changed.
698 The hook will not be called if `gnus-visual' is nil.
700 The default function `gnus-summary-highlight-line' will
701 highlight the line according to the `gnus-summary-highlight'
703 :group 'gnus-summary-visual
706 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
707 "*A hook called when an article is selected for the first time.
708 The hook is intended to mark an article as read (or unread)
709 automatically when it is selected."
710 :group 'gnus-summary-choose
713 (defcustom gnus-group-no-more-groups-hook nil
714 "*A hook run when returning to group mode having no more (unread) groups."
715 :group 'gnus-group-select
718 (defcustom gnus-ps-print-hook nil
719 "*A hook run before ps-printing something from Gnus."
723 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
724 "Face used for highlighting the current article in the summary buffer."
725 :group 'gnus-summary-visual
728 (defcustom gnus-summary-highlight
729 '(((= mark gnus-canceled-mark)
730 . gnus-summary-cancelled-face)
731 ((and (> score default)
732 (or (= mark gnus-dormant-mark)
733 (= mark gnus-ticked-mark)))
734 . gnus-summary-high-ticked-face)
735 ((and (< score default)
736 (or (= mark gnus-dormant-mark)
737 (= mark gnus-ticked-mark)))
738 . gnus-summary-low-ticked-face)
739 ((or (= mark gnus-dormant-mark)
740 (= mark gnus-ticked-mark))
741 . gnus-summary-normal-ticked-face)
742 ((and (> score default) (= mark gnus-ancient-mark))
743 . gnus-summary-high-ancient-face)
744 ((and (< score default) (= mark gnus-ancient-mark))
745 . gnus-summary-low-ancient-face)
746 ((= mark gnus-ancient-mark)
747 . gnus-summary-normal-ancient-face)
748 ((and (> score default) (= mark gnus-unread-mark))
749 . gnus-summary-high-unread-face)
750 ((and (< score default) (= mark gnus-unread-mark))
751 . gnus-summary-low-unread-face)
752 ((memq mark (list gnus-unread-mark gnus-downloadable-mark
753 gnus-undownloaded-mark))
754 . gnus-summary-normal-unread-face)
756 . gnus-summary-high-read-face)
758 . gnus-summary-low-read-face)
760 . gnus-summary-normal-read-face))
761 "Controls the highlighting of summary buffer lines.
763 A list of (FORM . FACE) pairs. When deciding how a a particular
764 summary line should be displayed, each form is evaluated. The content
765 of the face field after the first true form is used. You can change
766 how those summary lines are displayed, by editing the face field.
768 You can use the following variables in the FORM field.
770 score: The articles score
771 default: The default article score.
772 below: The score below which articles are automatically marked as read.
773 mark: The articles mark."
774 :group 'gnus-summary-visual
775 :type '(repeat (cons (sexp :tag "Form" nil)
778 (defcustom gnus-alter-header-function nil
779 "Function called to allow alteration of article header structures.
780 The function is called with one parameter, the article header vector,
781 which it may alter in any way.")
783 ;;; Internal variables
785 (defvar gnus-scores-exclude-files nil)
786 (defvar gnus-page-broken nil)
788 (defvar gnus-original-article nil)
789 (defvar gnus-article-internal-prepare-hook nil)
790 (defvar gnus-newsgroup-process-stack nil)
792 (defvar gnus-thread-indent-array nil)
793 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
795 ;; Avoid highlighting in kill files.
796 (defvar gnus-summary-inhibit-highlight nil)
797 (defvar gnus-newsgroup-selected-overlay nil)
798 (defvar gnus-inhibit-limiting nil)
799 (defvar gnus-newsgroup-adaptive-score-file nil)
800 (defvar gnus-current-score-file nil)
801 (defvar gnus-current-move-group nil)
802 (defvar gnus-current-copy-group nil)
803 (defvar gnus-current-crosspost-group nil)
805 (defvar gnus-newsgroup-dependencies nil)
806 (defvar gnus-newsgroup-adaptive nil)
807 (defvar gnus-summary-display-article-function nil)
808 (defvar gnus-summary-highlight-line-function nil
809 "Function called after highlighting a summary line.")
811 (defvar gnus-summary-line-format-alist
812 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
813 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
814 (?s gnus-tmp-subject-or-nil ?s)
815 (?n gnus-tmp-name ?s)
816 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
818 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
820 (?F gnus-tmp-from ?s)
821 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
822 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
823 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
824 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
825 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
826 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
827 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
828 (?L gnus-tmp-lines ?d)
829 (?I gnus-tmp-indentation ?s)
830 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
831 (?R gnus-tmp-replied ?c)
832 (?\[ gnus-tmp-opening-bracket ?c)
833 (?\] gnus-tmp-closing-bracket ?c)
834 (?\> (make-string gnus-tmp-level ? ) ?s)
835 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
836 (?i gnus-tmp-score ?d)
837 (?z gnus-tmp-score-char ?c)
838 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
839 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
840 (?U gnus-tmp-unread ?c)
841 (?t (gnus-summary-number-of-articles-in-thread
842 (and (boundp 'thread) (car thread)) gnus-tmp-level)
844 (?e (gnus-summary-number-of-articles-in-thread
845 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
847 (?u gnus-tmp-user-defined ?s)
848 (?P (gnus-pick-line-number) ?d))
849 "An alist of format specifications that can appear in summary lines,
850 and what variables they correspond with, along with the type of the
851 variable (string, integer, character, etc).")
853 (defvar gnus-summary-dummy-line-format-alist
854 `((?S gnus-tmp-subject ?s)
855 (?N gnus-tmp-number ?d)
856 (?u gnus-tmp-user-defined ?s)))
858 (defvar gnus-summary-mode-line-format-alist
859 `((?G gnus-tmp-group-name ?s)
860 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
861 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
862 (?A gnus-tmp-article-number ?d)
863 (?Z gnus-tmp-unread-and-unselected ?s)
865 (?U gnus-tmp-unread-and-unticked ?d)
866 (?S gnus-tmp-subject ?s)
867 (?e gnus-tmp-unselected ?d)
868 (?u gnus-tmp-user-defined ?s)
869 (?d (length gnus-newsgroup-dormant) ?d)
870 (?t (length gnus-newsgroup-marked) ?d)
871 (?r (length gnus-newsgroup-reads) ?d)
872 (?E gnus-newsgroup-expunged-tally ?d)
873 (?s (gnus-current-score-file-nondirectory) ?s)))
875 (defvar gnus-last-search-regexp nil
876 "Default regexp for article search command.")
878 (defvar gnus-last-shell-command nil
879 "Default shell command on article.")
881 (defvar gnus-newsgroup-begin nil)
882 (defvar gnus-newsgroup-end nil)
883 (defvar gnus-newsgroup-last-rmail nil)
884 (defvar gnus-newsgroup-last-mail nil)
885 (defvar gnus-newsgroup-last-folder nil)
886 (defvar gnus-newsgroup-last-file nil)
887 (defvar gnus-newsgroup-auto-expire nil)
888 (defvar gnus-newsgroup-active nil)
890 (defvar gnus-newsgroup-data nil)
891 (defvar gnus-newsgroup-data-reverse nil)
892 (defvar gnus-newsgroup-limit nil)
893 (defvar gnus-newsgroup-limits nil)
895 (defvar gnus-newsgroup-unreads nil
896 "List of unread articles in the current newsgroup.")
898 (defvar gnus-newsgroup-unselected nil
899 "List of unselected unread articles in the current newsgroup.")
901 (defvar gnus-newsgroup-reads nil
902 "Alist of read articles and article marks in the current newsgroup.")
904 (defvar gnus-newsgroup-expunged-tally nil)
906 (defvar gnus-newsgroup-marked nil
907 "List of ticked articles in the current newsgroup (a subset of unread art).")
909 (defvar gnus-newsgroup-killed nil
910 "List of ranges of articles that have been through the scoring process.")
912 (defvar gnus-newsgroup-cached nil
913 "List of articles that come from the article cache.")
915 (defvar gnus-newsgroup-saved nil
916 "List of articles that have been saved.")
918 (defvar gnus-newsgroup-kill-headers nil)
920 (defvar gnus-newsgroup-replied nil
921 "List of articles that have been replied to in the current newsgroup.")
923 (defvar gnus-newsgroup-expirable nil
924 "List of articles in the current newsgroup that can be expired.")
926 (defvar gnus-newsgroup-processable nil
927 "List of articles in the current newsgroup that can be processed.")
929 (defvar gnus-newsgroup-downloadable nil
930 "List of articles in the current newsgroup that can be processed.")
932 (defvar gnus-newsgroup-undownloaded nil
933 "List of articles in the current newsgroup that haven't been downloaded..")
935 (defvar gnus-newsgroup-unsendable nil
936 "List of articles in the current newsgroup that won't be sent.")
938 (defvar gnus-newsgroup-bookmarks nil
939 "List of articles in the current newsgroup that have bookmarks.")
941 (defvar gnus-newsgroup-dormant nil
942 "List of dormant articles in the current newsgroup.")
944 (defvar gnus-newsgroup-scored nil
945 "List of scored articles in the current newsgroup.")
947 (defvar gnus-newsgroup-headers nil
948 "List of article headers in the current newsgroup.")
950 (defvar gnus-newsgroup-threads nil)
952 (defvar gnus-newsgroup-prepared nil
953 "Whether the current group has been prepared properly.")
955 (defvar gnus-newsgroup-ancient nil
956 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
958 (defvar gnus-newsgroup-sparse nil)
960 (defvar gnus-current-article nil)
961 (defvar gnus-article-current nil)
962 (defvar gnus-current-headers nil)
963 (defvar gnus-have-all-headers nil)
964 (defvar gnus-last-article nil)
965 (defvar gnus-newsgroup-history nil)
967 (defconst gnus-summary-local-variables
968 '(gnus-newsgroup-name
969 gnus-newsgroup-begin gnus-newsgroup-end
970 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
971 gnus-newsgroup-last-folder gnus-newsgroup-last-file
972 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
973 gnus-newsgroup-unselected gnus-newsgroup-marked
974 gnus-newsgroup-reads gnus-newsgroup-saved
975 gnus-newsgroup-replied gnus-newsgroup-expirable
976 gnus-newsgroup-processable gnus-newsgroup-killed
977 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
978 gnus-newsgroup-unsendable
979 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
980 gnus-newsgroup-headers gnus-newsgroup-threads
981 gnus-newsgroup-prepared gnus-summary-highlight-line-function
982 gnus-current-article gnus-current-headers gnus-have-all-headers
983 gnus-last-article gnus-article-internal-prepare-hook
984 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
985 gnus-newsgroup-scored gnus-newsgroup-kill-headers
986 gnus-thread-expunge-below
987 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
988 (gnus-summary-mark-below . global)
989 gnus-newsgroup-active gnus-scores-exclude-files
990 gnus-newsgroup-history gnus-newsgroup-ancient
991 gnus-newsgroup-sparse gnus-newsgroup-process-stack
992 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
993 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
994 (gnus-newsgroup-expunged-tally . 0)
995 gnus-cache-removable-articles gnus-newsgroup-cached
996 gnus-newsgroup-data gnus-newsgroup-data-reverse
997 gnus-newsgroup-limit gnus-newsgroup-limits)
998 "Variables that are buffer-local to the summary buffers.")
1000 ;; Byte-compiler warning.
1001 (defvar gnus-article-mode-map)
1003 ;; Subject simplification.
1005 (defun gnus-simplify-whitespace (str)
1006 "Remove excessive whitespace."
1009 (while (string-match "[ \t][ \t]+" mystr)
1010 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1012 (substring mystr (match-end 0)))))
1014 (when (string-match "^[ \t]+" mystr)
1015 (setq mystr (substring mystr (match-end 0))))
1017 (when (string-match "[ \t]+$" mystr)
1018 (setq mystr (substring mystr 0 (match-beginning 0))))
1021 (defsubst gnus-simplify-subject-re (subject)
1022 "Remove \"Re:\" from subject lines."
1023 (if (string-match "^[Rr][Ee]: *" subject)
1024 (substring subject (match-end 0))
1027 (defun gnus-simplify-subject (subject &optional re-only)
1028 "Remove `Re:' and words in parentheses.
1029 If RE-ONLY is non-nil, strip leading `Re:'s only."
1030 (let ((case-fold-search t)) ;Ignore case.
1031 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1032 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1033 (setq subject (substring subject (match-end 0))))
1034 ;; Remove uninteresting prefixes.
1035 (when (and (not re-only)
1036 gnus-simplify-ignored-prefixes
1037 (string-match gnus-simplify-ignored-prefixes subject))
1038 (setq subject (substring subject (match-end 0))))
1039 ;; Remove words in parentheses from end.
1041 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1042 (setq subject (substring subject 0 (match-beginning 0)))))
1043 ;; Return subject string.
1046 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1048 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1049 (goto-char (point-min))
1050 (while (re-search-forward regexp nil t)
1051 (replace-match (or newtext ""))))
1053 (defun gnus-simplify-buffer-fuzzy ()
1054 "Simplify string in the buffer fuzzily.
1055 The string in the accessible portion of the current buffer is simplified.
1056 It is assumed to be a single-line subject.
1057 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1058 matter is removed. Additional things can be deleted by setting
1059 gnus-simplify-subject-fuzzy-regexp."
1060 (let ((case-fold-search t)
1062 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1064 (while (not (eq modified-tick (buffer-modified-tick)))
1065 (setq modified-tick (buffer-modified-tick))
1067 ((listp gnus-simplify-subject-fuzzy-regexp)
1068 (mapcar 'gnus-simplify-buffer-fuzzy-step
1069 gnus-simplify-subject-fuzzy-regexp))
1070 (gnus-simplify-subject-fuzzy-regexp
1071 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1072 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1073 (gnus-simplify-buffer-fuzzy-step
1074 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1075 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1077 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1078 (gnus-simplify-buffer-fuzzy-step " +" " ")
1079 (gnus-simplify-buffer-fuzzy-step " $")
1080 (gnus-simplify-buffer-fuzzy-step "^ +")))
1082 (defun gnus-simplify-subject-fuzzy (subject)
1083 "Simplify a subject string fuzzily.
1084 See `gnus-simplify-buffer-fuzzy' for details."
1086 (gnus-set-work-buffer)
1087 (let ((case-fold-search t))
1088 ;; Remove uninteresting prefixes.
1089 (when (and gnus-simplify-ignored-prefixes
1090 (string-match gnus-simplify-ignored-prefixes subject))
1091 (setq subject (substring subject (match-end 0))))
1093 (inline (gnus-simplify-buffer-fuzzy))
1096 (defsubst gnus-simplify-subject-fully (subject)
1097 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1099 (gnus-simplify-subject-functions
1100 (gnus-map-function gnus-simplify-subject-functions subject))
1101 ((null gnus-summary-gather-subject-limit)
1102 (gnus-simplify-subject-re subject))
1103 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1104 (gnus-simplify-subject-fuzzy subject))
1105 ((numberp gnus-summary-gather-subject-limit)
1106 (gnus-limit-string (gnus-simplify-subject-re subject)
1107 gnus-summary-gather-subject-limit))
1111 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1112 "Check whether two subjects are equal.
1113 If optional argument simple-first is t, first argument is already
1116 ((null simple-first)
1117 (equal (gnus-simplify-subject-fully s1)
1118 (gnus-simplify-subject-fully s2)))
1121 (gnus-simplify-subject-fully s2)))))
1123 (defun gnus-summary-bubble-group ()
1124 "Increase the score of the current group.
1125 This is a handy function to add to `gnus-summary-exit-hook' to
1126 increase the score of each group you read."
1127 (gnus-group-add-score gnus-newsgroup-name))
1131 ;;; Gnus summary mode
1134 (put 'gnus-summary-mode 'mode-class 'special)
1137 ;; Non-orthogonal keys
1139 (gnus-define-keys gnus-summary-mode-map
1140 " " gnus-summary-next-page
1141 "\177" gnus-summary-prev-page
1142 [delete] gnus-summary-prev-page
1143 [backspace] gnus-summary-prev-page
1144 "\r" gnus-summary-scroll-up
1145 "\e\r" gnus-summary-scroll-down
1146 "n" gnus-summary-next-unread-article
1147 "p" gnus-summary-prev-unread-article
1148 "N" gnus-summary-next-article
1149 "P" gnus-summary-prev-article
1150 "\M-\C-n" gnus-summary-next-same-subject
1151 "\M-\C-p" gnus-summary-prev-same-subject
1152 "\M-n" gnus-summary-next-unread-subject
1153 "\M-p" gnus-summary-prev-unread-subject
1154 "." gnus-summary-first-unread-article
1155 "," gnus-summary-best-unread-article
1156 "\M-s" gnus-summary-search-article-forward
1157 "\M-r" gnus-summary-search-article-backward
1158 "<" gnus-summary-beginning-of-article
1159 ">" gnus-summary-end-of-article
1160 "j" gnus-summary-goto-article
1161 "^" gnus-summary-refer-parent-article
1162 "\M-^" gnus-summary-refer-article
1163 "u" gnus-summary-tick-article-forward
1164 "!" gnus-summary-tick-article-forward
1165 "U" gnus-summary-tick-article-backward
1166 "d" gnus-summary-mark-as-read-forward
1167 "D" gnus-summary-mark-as-read-backward
1168 "E" gnus-summary-mark-as-expirable
1169 "\M-u" gnus-summary-clear-mark-forward
1170 "\M-U" gnus-summary-clear-mark-backward
1171 "k" gnus-summary-kill-same-subject-and-select
1172 "\C-k" gnus-summary-kill-same-subject
1173 "\M-\C-k" gnus-summary-kill-thread
1174 "\M-\C-l" gnus-summary-lower-thread
1175 "e" gnus-summary-edit-article
1176 "#" gnus-summary-mark-as-processable
1177 "\M-#" gnus-summary-unmark-as-processable
1178 "\M-\C-t" gnus-summary-toggle-threads
1179 "\M-\C-s" gnus-summary-show-thread
1180 "\M-\C-h" gnus-summary-hide-thread
1181 "\M-\C-f" gnus-summary-next-thread
1182 "\M-\C-b" gnus-summary-prev-thread
1183 "\M-\C-u" gnus-summary-up-thread
1184 "\M-\C-d" gnus-summary-down-thread
1185 "&" gnus-summary-execute-command
1186 "c" gnus-summary-catchup-and-exit
1187 "\C-w" gnus-summary-mark-region-as-read
1188 "\C-t" gnus-summary-toggle-truncation
1189 "?" gnus-summary-mark-as-dormant
1190 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1191 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1192 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1193 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1194 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1195 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1196 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1197 "=" gnus-summary-expand-window
1198 "\C-x\C-s" gnus-summary-reselect-current-group
1199 "\M-g" gnus-summary-rescan-group
1200 "w" gnus-summary-stop-page-breaking
1201 "\C-c\C-r" gnus-summary-caesar-message
1202 "\M-t" gnus-summary-toggle-mime
1203 "f" gnus-summary-followup
1204 "F" gnus-summary-followup-with-original
1205 "C" gnus-summary-cancel-article
1206 "r" gnus-summary-reply
1207 "R" gnus-summary-reply-with-original
1208 "\C-c\C-f" gnus-summary-mail-forward
1209 "o" gnus-summary-save-article
1210 "\C-o" gnus-summary-save-article-mail
1211 "|" gnus-summary-pipe-output
1212 "\M-k" gnus-summary-edit-local-kill
1213 "\M-K" gnus-summary-edit-global-kill
1215 "\C-c\C-d" gnus-summary-describe-group
1216 "q" gnus-summary-exit
1217 "Q" gnus-summary-exit-no-update
1218 "\C-c\C-i" gnus-info-find-node
1219 gnus-mouse-2 gnus-mouse-pick-article
1220 "m" gnus-summary-mail-other-window
1221 "a" gnus-summary-post-news
1222 "x" gnus-summary-limit-to-unread
1223 "s" gnus-summary-isearch-article
1224 "t" gnus-article-hide-headers
1225 "g" gnus-summary-show-article
1226 "l" gnus-summary-goto-last-article
1227 "v" gnus-summary-preview-mime-message
1228 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1229 "\C-d" gnus-summary-enter-digest-group
1230 "\M-\C-d" gnus-summary-read-document
1232 "*" gnus-cache-enter-article
1233 "\M-*" gnus-cache-remove-article
1234 "\M-&" gnus-summary-universal-argument
1235 "\C-l" gnus-recenter
1236 "I" gnus-summary-increase-score
1237 "L" gnus-summary-lower-score
1238 "\M-i" gnus-symbolic-argument
1239 "h" gnus-summary-select-article-buffer
1241 "V" gnus-summary-score-map
1242 "X" gnus-uu-extract-map
1243 "S" gnus-summary-send-map)
1245 ;; Sort of orthogonal keymap
1246 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1247 "t" gnus-summary-tick-article-forward
1248 "!" gnus-summary-tick-article-forward
1249 "d" gnus-summary-mark-as-read-forward
1250 "r" gnus-summary-mark-as-read-forward
1251 "c" gnus-summary-clear-mark-forward
1252 " " gnus-summary-clear-mark-forward
1253 "e" gnus-summary-mark-as-expirable
1254 "x" gnus-summary-mark-as-expirable
1255 "?" gnus-summary-mark-as-dormant
1256 "b" gnus-summary-set-bookmark
1257 "B" gnus-summary-remove-bookmark
1258 "#" gnus-summary-mark-as-processable
1259 "\M-#" gnus-summary-unmark-as-processable
1260 "S" gnus-summary-limit-include-expunged
1261 "C" gnus-summary-catchup
1262 "H" gnus-summary-catchup-to-here
1263 "\C-c" gnus-summary-catchup-all
1264 "k" gnus-summary-kill-same-subject-and-select
1265 "K" gnus-summary-kill-same-subject
1266 "P" gnus-uu-mark-map)
1268 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1269 "c" gnus-summary-clear-above
1270 "u" gnus-summary-tick-above
1271 "m" gnus-summary-mark-above
1272 "k" gnus-summary-kill-below)
1274 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1275 "/" gnus-summary-limit-to-subject
1276 "n" gnus-summary-limit-to-articles
1277 "w" gnus-summary-pop-limit
1278 "s" gnus-summary-limit-to-subject
1279 "a" gnus-summary-limit-to-author
1280 "u" gnus-summary-limit-to-unread
1281 "m" gnus-summary-limit-to-marks
1282 "v" gnus-summary-limit-to-score
1283 "*" gnus-summary-limit-include-cached
1284 "D" gnus-summary-limit-include-dormant
1285 "T" gnus-summary-limit-include-thread
1286 "d" gnus-summary-limit-exclude-dormant
1287 "t" gnus-summary-limit-to-age
1288 "E" gnus-summary-limit-include-expunged
1289 "c" gnus-summary-limit-exclude-childless-dormant
1290 "C" gnus-summary-limit-mark-excluded-as-read)
1292 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1293 "n" gnus-summary-next-unread-article
1294 "p" gnus-summary-prev-unread-article
1295 "N" gnus-summary-next-article
1296 "P" gnus-summary-prev-article
1297 "\C-n" gnus-summary-next-same-subject
1298 "\C-p" gnus-summary-prev-same-subject
1299 "\M-n" gnus-summary-next-unread-subject
1300 "\M-p" gnus-summary-prev-unread-subject
1301 "f" gnus-summary-first-unread-article
1302 "b" gnus-summary-best-unread-article
1303 "j" gnus-summary-goto-article
1304 "g" gnus-summary-goto-subject
1305 "l" gnus-summary-goto-last-article
1306 "o" gnus-summary-pop-article)
1308 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1309 "k" gnus-summary-kill-thread
1310 "l" gnus-summary-lower-thread
1311 "i" gnus-summary-raise-thread
1312 "T" gnus-summary-toggle-threads
1313 "t" gnus-summary-rethread-current
1314 "^" gnus-summary-reparent-thread
1315 "s" gnus-summary-show-thread
1316 "S" gnus-summary-show-all-threads
1317 "h" gnus-summary-hide-thread
1318 "H" gnus-summary-hide-all-threads
1319 "n" gnus-summary-next-thread
1320 "p" gnus-summary-prev-thread
1321 "u" gnus-summary-up-thread
1322 "o" gnus-summary-top-thread
1323 "d" gnus-summary-down-thread
1324 "#" gnus-uu-mark-thread
1325 "\M-#" gnus-uu-unmark-thread)
1327 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1328 "g" gnus-summary-prepare
1329 "c" gnus-summary-insert-cached-articles)
1331 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1332 "c" gnus-summary-catchup-and-exit
1333 "C" gnus-summary-catchup-all-and-exit
1334 "E" gnus-summary-exit-no-update
1335 "Q" gnus-summary-exit
1336 "Z" gnus-summary-exit
1337 "n" gnus-summary-catchup-and-goto-next-group
1338 "R" gnus-summary-reselect-current-group
1339 "G" gnus-summary-rescan-group
1340 "N" gnus-summary-next-group
1341 "s" gnus-summary-save-newsrc
1342 "P" gnus-summary-prev-group)
1344 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1345 " " gnus-summary-next-page
1346 "n" gnus-summary-next-page
1347 "\177" gnus-summary-prev-page
1348 [delete] gnus-summary-prev-page
1349 "p" gnus-summary-prev-page
1350 "\r" gnus-summary-scroll-up
1351 "<" gnus-summary-beginning-of-article
1352 ">" gnus-summary-end-of-article
1353 "b" gnus-summary-beginning-of-article
1354 "e" gnus-summary-end-of-article
1355 "^" gnus-summary-refer-parent-article
1356 "r" gnus-summary-refer-parent-article
1357 "R" gnus-summary-refer-references
1358 "T" gnus-summary-refer-thread
1359 "g" gnus-summary-show-article
1360 "s" gnus-summary-isearch-article
1361 "P" gnus-summary-print-article)
1363 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1364 "b" gnus-article-add-buttons
1365 "B" gnus-article-add-buttons-to-head
1366 "o" gnus-article-treat-overstrike
1367 "e" gnus-article-emphasize
1368 "w" gnus-article-fill-cited-article
1369 "c" gnus-article-remove-cr
1370 "q" gnus-article-de-quoted-unreadable
1371 "f" gnus-article-display-x-face
1372 "l" gnus-summary-stop-page-breaking
1373 "r" gnus-summary-caesar-message
1374 "t" gnus-article-hide-headers
1375 "v" gnus-summary-verbose-headers
1376 "m" gnus-summary-toggle-mime
1377 "h" gnus-article-treat-html
1378 "d" gnus-article-treat-dumbquotes)
1380 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1381 "a" gnus-article-hide
1382 "h" gnus-article-hide-headers
1383 "b" gnus-article-hide-boring-headers
1384 "s" gnus-article-hide-signature
1385 "c" gnus-article-hide-citation
1386 "p" gnus-article-hide-pgp
1387 "P" gnus-article-hide-pem
1388 "\C-c" gnus-article-hide-citation-maybe)
1390 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1391 "a" gnus-article-highlight
1392 "h" gnus-article-highlight-headers
1393 "c" gnus-article-highlight-citation
1394 "s" gnus-article-highlight-signature)
1396 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1397 "z" gnus-article-date-ut
1398 "u" gnus-article-date-ut
1399 "l" gnus-article-date-local
1400 "e" gnus-article-date-lapsed
1401 "o" gnus-article-date-original
1402 "i" gnus-article-date-iso8601
1403 "s" gnus-article-date-user)
1405 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1406 "t" gnus-article-remove-trailing-blank-lines
1407 "l" gnus-article-strip-leading-blank-lines
1408 "m" gnus-article-strip-multiple-blank-lines
1409 "a" gnus-article-strip-blank-lines
1410 "A" gnus-article-strip-all-blank-lines
1411 "s" gnus-article-strip-leading-space)
1413 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1415 "f" gnus-summary-fetch-faq
1416 "d" gnus-summary-describe-group
1417 "h" gnus-summary-describe-briefly
1418 "i" gnus-info-find-node)
1420 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1421 "e" gnus-summary-expire-articles
1422 "\M-\C-e" gnus-summary-expire-articles-now
1423 "\177" gnus-summary-delete-article
1424 [delete] gnus-summary-delete-article
1425 "m" gnus-summary-move-article
1426 "r" gnus-summary-respool-article
1427 "w" gnus-summary-edit-article
1428 "c" gnus-summary-copy-article
1429 "B" gnus-summary-crosspost-article
1430 "q" gnus-summary-respool-query
1431 "i" gnus-summary-import-article
1432 "p" gnus-summary-article-posted-p)
1434 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1435 "o" gnus-summary-save-article
1436 "m" gnus-summary-save-article-mail
1437 "F" gnus-summary-write-article-file
1438 "r" gnus-summary-save-article-rmail
1439 "f" gnus-summary-save-article-file
1440 "b" gnus-summary-save-article-body-file
1441 "h" gnus-summary-save-article-folder
1442 "v" gnus-summary-save-article-vm
1443 "p" gnus-summary-pipe-output
1444 "s" gnus-soup-add-article))
1446 (defun gnus-summary-make-menu-bar ()
1447 (gnus-turn-off-edit-menu 'summary)
1449 (unless (boundp 'gnus-summary-misc-menu)
1452 gnus-summary-kill-menu gnus-summary-mode-map ""
1457 ["Enter score..." gnus-summary-score-entry t]
1458 ["Customize" gnus-score-customize t])
1459 (gnus-make-score-map 'increase)
1460 (gnus-make-score-map 'lower)
1462 ["Kill below" gnus-summary-kill-below t]
1463 ["Mark above" gnus-summary-mark-above t]
1464 ["Tick above" gnus-summary-tick-above t]
1465 ["Clear above" gnus-summary-clear-above t])
1466 ["Current score" gnus-summary-current-score t]
1467 ["Set score" gnus-summary-set-score t]
1468 ["Switch current score file..." gnus-score-change-score-file t]
1469 ["Set mark below..." gnus-score-set-mark-below t]
1470 ["Set expunge below..." gnus-score-set-expunge-below t]
1471 ["Edit current score file" gnus-score-edit-current-scores t]
1472 ["Edit score file" gnus-score-edit-file t]
1473 ["Trace score" gnus-score-find-trace t]
1474 ["Find words" gnus-score-find-favourite-words t]
1475 ["Rescore buffer" gnus-summary-rescore t]
1476 ["Increase score..." gnus-summary-increase-score t]
1477 ["Lower score..." gnus-summary-lower-score t]))))
1480 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1482 :selected (null gnus-score-default-header)]
1483 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1485 :selected (eq gnus-score-default-header 'a)]
1486 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1488 :selected (eq gnus-score-default-header 's)]
1490 (gnus-score-set-default 'gnus-score-default-header 'b)
1492 :selected (eq gnus-score-default-header 'b )]
1494 (gnus-score-set-default 'gnus-score-default-header 'h)
1496 :selected (eq gnus-score-default-header 'h )]
1497 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1499 :selected (eq gnus-score-default-header 'i )]
1500 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1502 :selected (eq gnus-score-default-header 't )]
1504 (gnus-score-set-default 'gnus-score-default-header 'x)
1506 :selected (eq gnus-score-default-header 'x )]
1507 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1509 :selected (eq gnus-score-default-header 'l )]
1510 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1512 :selected (eq gnus-score-default-header 'd )]
1513 ["Followups to author"
1514 (gnus-score-set-default 'gnus-score-default-header 'f)
1516 :selected (eq gnus-score-default-header 'f )])
1518 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1520 :selected (null gnus-score-default-type)]
1521 ;; The `:active' key is commented out in the following,
1522 ;; because the GNU Emacs hack to support radio buttons use
1523 ;; active to indicate which button is selected.
1524 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1526 ;; :active (not (memq gnus-score-default-header '(l d)))
1527 :selected (eq gnus-score-default-type 's)]
1528 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1530 ;; :active (not (memq gnus-score-default-header '(l d)))
1531 :selected (eq gnus-score-default-type 'r)]
1532 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1534 ;; :active (not (memq gnus-score-default-header '(l d)))
1535 :selected (eq gnus-score-default-type 'e)]
1536 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1538 ;; :active (not (memq gnus-score-default-header '(l d)))
1539 :selected (eq gnus-score-default-type 'f)]
1540 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1542 ;; :active (eq (gnus-score-default-header 'd))
1543 :selected (eq gnus-score-default-type 'b)]
1544 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1546 ;; :active (eq (gnus-score-default-header 'd))
1547 :selected (eq gnus-score-default-type 'n)]
1548 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1550 ;; :active (eq (gnus-score-default-header 'd))
1551 :selected (eq gnus-score-default-type 'a)]
1553 (gnus-score-set-default 'gnus-score-default-type '<)
1555 ;; :active (eq (gnus-score-default-header 'l))
1556 :selected (eq gnus-score-default-type '<)]
1558 (gnus-score-set-default 'gnus-score-default-type '=)
1560 ;; :active (eq (gnus-score-default-header 'l))
1561 :selected (eq gnus-score-default-type '=)]
1562 ["Greater than number"
1563 (gnus-score-set-default 'gnus-score-default-type '>)
1565 ;; :active (eq (gnus-score-default-header 'l))
1566 :selected (eq gnus-score-default-type '>)])
1567 ["Default fold" gnus-score-default-fold-toggle
1569 :selected gnus-score-default-fold]
1571 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1573 :selected (null gnus-score-default-duration)]
1575 (gnus-score-set-default 'gnus-score-default-duration 'p)
1577 :selected (eq gnus-score-default-duration 'p)]
1579 (gnus-score-set-default 'gnus-score-default-duration 't)
1581 :selected (eq gnus-score-default-duration 't)]
1583 (gnus-score-set-default 'gnus-score-default-duration 'i)
1585 :selected (eq gnus-score-default-duration 'i)]))
1588 gnus-summary-article-menu gnus-summary-mode-map ""
1591 ["All" gnus-article-hide t]
1592 ["Headers" gnus-article-hide-headers t]
1593 ["Signature" gnus-article-hide-signature t]
1594 ["Citation" gnus-article-hide-citation t]
1595 ["PGP" gnus-article-hide-pgp t]
1596 ["Boring headers" gnus-article-hide-boring-headers t])
1598 ["All" gnus-article-highlight t]
1599 ["Headers" gnus-article-highlight-headers t]
1600 ["Signature" gnus-article-highlight-signature t]
1601 ["Citation" gnus-article-highlight-citation t])
1603 ["Local" gnus-article-date-local t]
1604 ["ISO8601" gnus-article-date-iso8601 t]
1605 ["UT" gnus-article-date-ut t]
1606 ["Original" gnus-article-date-original t]
1607 ["Lapsed" gnus-article-date-lapsed t]
1608 ["User-defined" gnus-article-date-user t])
1611 ["Leading" gnus-article-strip-leading-blank-lines t]
1612 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1613 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1614 ["All of the above" gnus-article-strip-blank-lines t]
1615 ["All" gnus-article-strip-all-blank-lines t]
1616 ["Leading space" gnus-article-strip-leading-space t])
1617 ["Overstrike" gnus-article-treat-overstrike t]
1618 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1619 ["Emphasis" gnus-article-emphasize t]
1620 ["Word wrap" gnus-article-fill-cited-article t]
1621 ["CR" gnus-article-remove-cr t]
1622 ["Show X-Face" gnus-article-display-x-face t]
1623 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1624 ["UnHTMLize" gnus-article-treat-html t]
1625 ["Rot 13" gnus-summary-caesar-message t]
1626 ["Unix pipe" gnus-summary-pipe-message t]
1627 ["Add buttons" gnus-article-add-buttons t]
1628 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1629 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1630 ["Toggle MIME" gnus-summary-toggle-mime t]
1631 ["Verbose header" gnus-summary-verbose-headers t]
1632 ["Toggle header" gnus-summary-toggle-header t])
1634 ["Save in default format" gnus-summary-save-article t]
1635 ["Save in file" gnus-summary-save-article-file t]
1636 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1637 ["Save in MH folder" gnus-summary-save-article-folder t]
1638 ["Save in VM folder" gnus-summary-save-article-vm t]
1639 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1640 ["Save body in file" gnus-summary-save-article-body-file t]
1641 ["Pipe through a filter" gnus-summary-pipe-output t]
1642 ["Add to SOUP packet" gnus-soup-add-article t]
1643 ["Print" gnus-summary-print-article t])
1645 ["Respool article..." gnus-summary-respool-article t]
1646 ["Move article..." gnus-summary-move-article
1647 (gnus-check-backend-function
1648 'request-move-article gnus-newsgroup-name)]
1649 ["Copy article..." gnus-summary-copy-article t]
1650 ["Crosspost article..." gnus-summary-crosspost-article
1651 (gnus-check-backend-function
1652 'request-replace-article gnus-newsgroup-name)]
1653 ["Import file..." gnus-summary-import-article t]
1654 ["Check if posted" gnus-summary-article-posted-p t]
1655 ["Edit article" gnus-summary-edit-article
1656 (not (gnus-group-read-only-p))]
1657 ["Delete article" gnus-summary-delete-article
1658 (gnus-check-backend-function
1659 'request-expire-articles gnus-newsgroup-name)]
1660 ["Query respool" gnus-summary-respool-query t]
1661 ["Delete expirable articles" gnus-summary-expire-articles-now
1662 (gnus-check-backend-function
1663 'request-expire-articles gnus-newsgroup-name)])
1665 ["Uudecode" gnus-uu-decode-uu t]
1666 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1667 ["Unshar" gnus-uu-decode-unshar t]
1668 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1669 ["Save" gnus-uu-decode-save t]
1670 ["Binhex" gnus-uu-decode-binhex t]
1671 ["Postscript" gnus-uu-decode-postscript t])
1673 ["Enter article" gnus-cache-enter-article t]
1674 ["Remove article" gnus-cache-remove-article t])
1675 ["Select article buffer" gnus-summary-select-article-buffer t]
1676 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1677 ["Isearch article..." gnus-summary-isearch-article t]
1678 ["Beginning of the article" gnus-summary-beginning-of-article t]
1679 ["End of the article" gnus-summary-end-of-article t]
1680 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1681 ["Fetch referenced articles" gnus-summary-refer-references t]
1682 ["Fetch current thread" gnus-summary-refer-thread t]
1683 ["Fetch article with id..." gnus-summary-refer-article t]
1684 ["Redisplay" gnus-summary-show-article t]))
1687 gnus-summary-thread-menu gnus-summary-mode-map ""
1689 ["Toggle threading" gnus-summary-toggle-threads t]
1690 ["Hide threads" gnus-summary-hide-all-threads t]
1691 ["Show threads" gnus-summary-show-all-threads t]
1692 ["Hide thread" gnus-summary-hide-thread t]
1693 ["Show thread" gnus-summary-show-thread t]
1694 ["Go to next thread" gnus-summary-next-thread t]
1695 ["Go to previous thread" gnus-summary-prev-thread t]
1696 ["Go down thread" gnus-summary-down-thread t]
1697 ["Go up thread" gnus-summary-up-thread t]
1698 ["Top of thread" gnus-summary-top-thread t]
1699 ["Mark thread as read" gnus-summary-kill-thread t]
1700 ["Lower thread score" gnus-summary-lower-thread t]
1701 ["Raise thread score" gnus-summary-raise-thread t]
1702 ["Rethread current" gnus-summary-rethread-current t]
1706 gnus-summary-post-menu gnus-summary-mode-map ""
1708 ["Post an article" gnus-summary-post-news t]
1709 ["Followup" gnus-summary-followup t]
1710 ["Followup and yank" gnus-summary-followup-with-original t]
1711 ["Supersede article" gnus-summary-supersede-article t]
1712 ["Cancel article" gnus-summary-cancel-article t]
1713 ["Reply" gnus-summary-reply t]
1714 ["Reply and yank" gnus-summary-reply-with-original t]
1715 ["Wide reply" gnus-summary-wide-reply t]
1716 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1717 ["Mail forward" gnus-summary-mail-forward t]
1718 ["Post forward" gnus-summary-post-forward t]
1719 ["Digest and mail" gnus-uu-digest-mail-forward t]
1720 ["Digest and post" gnus-uu-digest-post-forward t]
1721 ["Resend message" gnus-summary-resend-message t]
1722 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1723 ["Send a mail" gnus-summary-mail-other-window t]
1724 ["Uuencode and post" gnus-uu-post-news t]
1725 ["Followup via news" gnus-summary-followup-to-mail t]
1726 ["Followup via news and yank"
1727 gnus-summary-followup-to-mail-with-original t]
1729 ;;["Send" gnus-summary-send-draft t]
1730 ;;["Send bounced" gnus-resend-bounced-mail t])
1734 gnus-summary-misc-menu gnus-summary-mode-map ""
1737 ["Mark as read" gnus-summary-mark-as-read-forward t]
1738 ["Mark same subject and select"
1739 gnus-summary-kill-same-subject-and-select t]
1740 ["Mark same subject" gnus-summary-kill-same-subject t]
1741 ["Catchup" gnus-summary-catchup t]
1742 ["Catchup all" gnus-summary-catchup-all t]
1743 ["Catchup to here" gnus-summary-catchup-to-here t]
1744 ["Catchup region" gnus-summary-mark-region-as-read t]
1745 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1747 ["Tick" gnus-summary-tick-article-forward t]
1748 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1749 ["Remove marks" gnus-summary-clear-mark-forward t]
1750 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1751 ["Set bookmark" gnus-summary-set-bookmark t]
1752 ["Remove bookmark" gnus-summary-remove-bookmark t])
1754 ["Marks..." gnus-summary-limit-to-marks t]
1755 ["Subject..." gnus-summary-limit-to-subject t]
1756 ["Author..." gnus-summary-limit-to-author t]
1757 ["Age..." gnus-summary-limit-to-age t]
1758 ["Score" gnus-summary-limit-to-score t]
1759 ["Unread" gnus-summary-limit-to-unread t]
1760 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1761 ["Articles" gnus-summary-limit-to-articles t]
1762 ["Pop limit" gnus-summary-pop-limit t]
1763 ["Show dormant" gnus-summary-limit-include-dormant t]
1764 ["Hide childless dormant"
1765 gnus-summary-limit-exclude-childless-dormant t]
1766 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1767 ["Show expunged" gnus-summary-show-all-expunged t])
1769 ["Set mark" gnus-summary-mark-as-processable t]
1770 ["Remove mark" gnus-summary-unmark-as-processable t]
1771 ["Remove all marks" gnus-summary-unmark-all-processable t]
1772 ["Mark above" gnus-uu-mark-over t]
1773 ["Mark series" gnus-uu-mark-series t]
1774 ["Mark region" gnus-uu-mark-region t]
1775 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1776 ["Mark all" gnus-uu-mark-all t]
1777 ["Mark buffer" gnus-uu-mark-buffer t]
1778 ["Mark sparse" gnus-uu-mark-sparse t]
1779 ["Mark thread" gnus-uu-mark-thread t]
1780 ["Unmark thread" gnus-uu-unmark-thread t]
1781 ("Process Mark Sets"
1782 ["Kill" gnus-summary-kill-process-mark t]
1783 ["Yank" gnus-summary-yank-process-mark
1784 gnus-newsgroup-process-stack]
1785 ["Save" gnus-summary-save-process-mark t]))
1787 ["Page forward" gnus-summary-next-page t]
1788 ["Page backward" gnus-summary-prev-page t]
1789 ["Line forward" gnus-summary-scroll-up t])
1791 ["Next unread article" gnus-summary-next-unread-article t]
1792 ["Previous unread article" gnus-summary-prev-unread-article t]
1793 ["Next article" gnus-summary-next-article t]
1794 ["Previous article" gnus-summary-prev-article t]
1795 ["Next unread subject" gnus-summary-next-unread-subject t]
1796 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1797 ["Next article same subject" gnus-summary-next-same-subject t]
1798 ["Previous article same subject" gnus-summary-prev-same-subject t]
1799 ["First unread article" gnus-summary-first-unread-article t]
1800 ["Best unread article" gnus-summary-best-unread-article t]
1801 ["Go to subject number..." gnus-summary-goto-subject t]
1802 ["Go to article number..." gnus-summary-goto-article t]
1803 ["Go to the last article" gnus-summary-goto-last-article t]
1804 ["Pop article off history" gnus-summary-pop-article t])
1806 ["Sort by number" gnus-summary-sort-by-number t]
1807 ["Sort by author" gnus-summary-sort-by-author t]
1808 ["Sort by subject" gnus-summary-sort-by-subject t]
1809 ["Sort by date" gnus-summary-sort-by-date t]
1810 ["Sort by score" gnus-summary-sort-by-score t]
1811 ["Sort by lines" gnus-summary-sort-by-lines t])
1813 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1814 ["Describe group" gnus-summary-describe-group t]
1815 ["Read manual" gnus-info-find-node t])
1817 ["Pick and read" gnus-pick-mode t]
1818 ["Binary" gnus-binary-mode t])
1820 ["Regenerate" gnus-summary-prepare t]
1821 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1822 ["Toggle threading" gnus-summary-toggle-threads t])
1823 ["Filter articles..." gnus-summary-execute-command t]
1824 ["Run command on subjects..." gnus-summary-universal-argument t]
1825 ["Search articles forward..." gnus-summary-search-article-forward t]
1826 ["Search articles backward..." gnus-summary-search-article-backward t]
1827 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1828 ["Expand window" gnus-summary-expand-window t]
1829 ["Expire expirable articles" gnus-summary-expire-articles
1830 (gnus-check-backend-function
1831 'request-expire-articles gnus-newsgroup-name)]
1832 ["Edit local kill file" gnus-summary-edit-local-kill t]
1833 ["Edit main kill file" gnus-summary-edit-global-kill t]
1835 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1836 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1837 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1838 ["Exit group" gnus-summary-exit t]
1839 ["Exit group without updating" gnus-summary-exit-no-update t]
1840 ["Exit and goto next group" gnus-summary-next-group t]
1841 ["Exit and goto prev group" gnus-summary-prev-group t]
1842 ["Reselect group" gnus-summary-reselect-current-group t]
1843 ["Rescan group" gnus-summary-rescan-group t]
1844 ["Update dribble" gnus-summary-save-newsrc t])))
1846 (run-hooks 'gnus-summary-menu-hook)))
1848 (defun gnus-score-set-default (var value)
1849 "A version of set that updates the GNU Emacs menu-bar."
1851 ;; It is the message that forces the active status to be updated.
1854 (defun gnus-make-score-map (type)
1855 "Make a summary score map of type TYPE."
1858 (let ((headers '(("author" "from" string)
1859 ("subject" "subject" string)
1860 ("article body" "body" string)
1861 ("article head" "head" string)
1862 ("xref" "xref" string)
1863 ("lines" "lines" number)
1864 ("followups to author" "followup" string)))
1865 (types '((number ("less than" <)
1868 (string ("substring" s)
1872 (perms '(("temporary" (current-time-string))
1880 (if (eq type 'lower)
1885 (setq header (car headers))
1891 (let ((ts (cdr (assoc (nth 2 header) types)))
1907 'gnus-summary-score-entry
1909 (if (or (string= (nth 1 header)
1911 (string= (nth 1 header)
1914 (list 'gnus-summary-header
1916 (list 'quote (nth 1 (car ts)))
1917 (list 'gnus-score-default nil)
1923 (list (nreverse outp))))
1926 (list (nreverse outt))))
1928 (setq headers (cdr headers)))
1929 (list (nreverse outh))))))))
1933 (defun gnus-summary-mode (&optional group)
1934 "Major mode for reading articles.
1936 All normal editing commands are switched off.
1937 \\<gnus-summary-mode-map>
1938 Each line in this buffer represents one article. To read an
1939 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1940 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1943 You can also post articles and send mail from this buffer. To
1944 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1945 of an article, type `\\[gnus-summary-reply]'.
1947 There are approx. one gazillion commands you can execute in this
1948 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1950 The following commands are available:
1952 \\{gnus-summary-mode-map}"
1954 (when (gnus-visual-p 'summary-menu 'menu)
1955 (gnus-summary-make-menu-bar))
1956 (kill-all-local-variables)
1957 (gnus-summary-make-local-variables)
1958 (gnus-make-thread-indent-array)
1959 (gnus-simplify-mode-line)
1960 (setq major-mode 'gnus-summary-mode)
1961 (setq mode-name "Summary")
1962 (make-local-variable 'minor-mode-alist)
1963 (use-local-map gnus-summary-mode-map)
1964 (buffer-disable-undo (current-buffer))
1965 (setq buffer-read-only t) ;Disable modification
1966 (setq truncate-lines t)
1967 (setq selective-display t)
1968 (setq selective-display-ellipses t) ;Display `...'
1969 (gnus-summary-set-display-table)
1970 (gnus-set-default-directory)
1971 (setq gnus-newsgroup-name group)
1972 (make-local-variable 'gnus-summary-line-format)
1973 (make-local-variable 'gnus-summary-line-format-spec)
1974 (make-local-variable 'gnus-summary-dummy-line-format)
1975 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1976 (make-local-variable 'gnus-summary-mark-positions)
1977 (make-local-hook 'post-command-hook)
1978 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1979 (make-local-hook 'pre-command-hook)
1980 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1981 (run-hooks 'gnus-summary-mode-hook)
1982 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1983 (gnus-update-summary-mark-positions))
1985 (defun gnus-summary-make-local-variables ()
1986 "Make all the local summary buffer variables."
1987 (let ((locals gnus-summary-local-variables)
1989 (while (setq local (pop locals))
1992 (if (eq (cdr local) 'global)
1993 ;; Copy the global value of the variable.
1994 (setq global (symbol-value (car local)))
1995 ;; Use the value from the list.
1996 (setq global (eval (cdr local))))
1997 (make-local-variable (car local))
1998 (set (car local) global))
1999 ;; Simple nil-valued local variable.
2000 (make-local-variable local)
2003 (defun gnus-summary-clear-local-variables ()
2004 (let ((locals gnus-summary-local-variables))
2006 (if (consp (car locals))
2007 (and (vectorp (caar locals))
2008 (set (caar locals) nil))
2009 (and (vectorp (car locals))
2010 (set (car locals) nil)))
2011 (setq locals (cdr locals)))))
2013 ;; Summary data functions.
2015 (defmacro gnus-data-number (data)
2018 (defmacro gnus-data-set-number (data number)
2019 `(setcar ,data ,number))
2021 (defmacro gnus-data-mark (data)
2024 (defmacro gnus-data-set-mark (data mark)
2025 `(setcar (nthcdr 1 ,data) ,mark))
2027 (defmacro gnus-data-pos (data)
2030 (defmacro gnus-data-set-pos (data pos)
2031 `(setcar (nthcdr 2 ,data) ,pos))
2033 (defmacro gnus-data-header (data)
2036 (defmacro gnus-data-set-header (data header)
2037 `(setf (nth 3 ,data) ,header))
2039 (defmacro gnus-data-level (data)
2042 (defmacro gnus-data-unread-p (data)
2043 `(= (nth 1 ,data) gnus-unread-mark))
2045 (defmacro gnus-data-read-p (data)
2046 `(/= (nth 1 ,data) gnus-unread-mark))
2048 (defmacro gnus-data-pseudo-p (data)
2049 `(consp (nth 3 ,data)))
2051 (defmacro gnus-data-find (number)
2052 `(assq ,number gnus-newsgroup-data))
2054 (defmacro gnus-data-find-list (number &optional data)
2055 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2056 (memq (assq ,number bdata)
2059 (defmacro gnus-data-make (number mark pos header level)
2060 `(list ,number ,mark ,pos ,header ,level))
2062 (defun gnus-data-enter (after-article number mark pos header level offset)
2063 (let ((data (gnus-data-find-list after-article)))
2065 (error "No such article: %d" after-article))
2066 (setcdr data (cons (gnus-data-make number mark pos header level)
2068 (setq gnus-newsgroup-data-reverse nil)
2069 (gnus-data-update-list (cddr data) offset)))
2071 (defun gnus-data-enter-list (after-article list &optional offset)
2073 (let ((data (and after-article (gnus-data-find-list after-article)))
2075 (or data (not after-article) (error "No such article: %d" after-article))
2076 ;; Find the last element in the list to be spliced into the main
2079 (setq list (cdr list)))
2082 (setcdr list gnus-newsgroup-data)
2083 (setq gnus-newsgroup-data ilist)
2085 (gnus-data-update-list (cdr list) offset)))
2086 (setcdr list (cdr data))
2089 (gnus-data-update-list (cdr list) offset)))
2090 (setq gnus-newsgroup-data-reverse nil))))
2092 (defun gnus-data-remove (article &optional offset)
2093 (let ((data gnus-newsgroup-data))
2094 (if (= (gnus-data-number (car data)) article)
2096 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2097 gnus-newsgroup-data-reverse nil)
2099 (gnus-data-update-list gnus-newsgroup-data offset)))
2101 (when (= (gnus-data-number (cadr data)) article)
2102 (setcdr data (cddr data))
2104 (gnus-data-update-list (cdr data) offset))
2106 gnus-newsgroup-data-reverse nil))
2107 (setq data (cdr data))))))
2109 (defmacro gnus-data-list (backward)
2111 (or gnus-newsgroup-data-reverse
2112 (setq gnus-newsgroup-data-reverse
2113 (reverse gnus-newsgroup-data)))
2114 gnus-newsgroup-data))
2116 (defun gnus-data-update-list (data offset)
2117 "Add OFFSET to the POS of all data entries in DATA."
2119 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2120 (setq data (cdr data))))
2122 (defun gnus-data-compute-positions ()
2123 "Compute the positions of all articles."
2124 (let ((data gnus-newsgroup-data)
2127 (when (setq pos (text-property-any
2128 (point-min) (point-max)
2129 'gnus-number (gnus-data-number (car data))))
2130 (gnus-data-set-pos (car data) (+ pos 3)))
2131 (setq data (cdr data)))))
2133 (defun gnus-summary-article-pseudo-p (article)
2134 "Say whether this article is a pseudo article or not."
2135 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2137 (defmacro gnus-summary-article-sparse-p (article)
2138 "Say whether this article is a sparse article or not."
2139 `(memq ,article gnus-newsgroup-sparse))
2141 (defmacro gnus-summary-article-ancient-p (article)
2142 "Say whether this article is a sparse article or not."
2143 `(memq ,article gnus-newsgroup-ancient))
2145 (defun gnus-article-parent-p (number)
2146 "Say whether this article is a parent or not."
2147 (let ((data (gnus-data-find-list number)))
2148 (and (cdr data) ; There has to be an article after...
2149 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2150 (gnus-data-level (nth 1 data))))))
2152 (defun gnus-article-children (number)
2153 "Return a list of all children to NUMBER."
2154 (let* ((data (gnus-data-find-list number))
2155 (level (gnus-data-level (car data)))
2157 (setq data (cdr data))
2159 (= (gnus-data-level (car data)) (1+ level)))
2160 (push (gnus-data-number (car data)) children)
2161 (setq data (cdr data)))
2164 (defmacro gnus-summary-skip-intangible ()
2165 "If the current article is intangible, then jump to a different article."
2166 '(let ((to (get-text-property (point) 'gnus-intangible)))
2167 (and to (gnus-summary-goto-subject to))))
2169 (defmacro gnus-summary-article-intangible-p ()
2170 "Say whether this article is intangible or not."
2171 '(get-text-property (point) 'gnus-intangible))
2173 (defun gnus-article-read-p (article)
2174 "Say whether ARTICLE is read or not."
2175 (not (or (memq article gnus-newsgroup-marked)
2176 (memq article gnus-newsgroup-unreads)
2177 (memq article gnus-newsgroup-unselected)
2178 (memq article gnus-newsgroup-dormant))))
2180 ;; Some summary mode macros.
2182 (defmacro gnus-summary-article-number ()
2183 "The article number of the article on the current line.
2184 If there isn's an article number here, then we return the current
2187 (gnus-summary-skip-intangible)
2188 (or (get-text-property (point) 'gnus-number)
2189 (gnus-summary-last-subject))))
2191 (defmacro gnus-summary-article-header (&optional number)
2192 "Return the header of article NUMBER."
2193 `(gnus-data-header (gnus-data-find
2194 ,(or number '(gnus-summary-article-number)))))
2196 (defmacro gnus-summary-thread-level (&optional number)
2197 "Return the level of thread that starts with article NUMBER."
2198 `(if (and (eq gnus-summary-make-false-root 'dummy)
2199 (get-text-property (point) 'gnus-intangible))
2201 (gnus-data-level (gnus-data-find
2202 ,(or number '(gnus-summary-article-number))))))
2204 (defmacro gnus-summary-article-mark (&optional number)
2205 "Return the mark of article NUMBER."
2206 `(gnus-data-mark (gnus-data-find
2207 ,(or number '(gnus-summary-article-number)))))
2209 (defmacro gnus-summary-article-pos (&optional number)
2210 "Return the position of the line of article NUMBER."
2211 `(gnus-data-pos (gnus-data-find
2212 ,(or number '(gnus-summary-article-number)))))
2214 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2215 (defmacro gnus-summary-article-subject (&optional number)
2216 "Return current subject string or nil if nothing."
2219 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2220 '(gnus-data-header (assq (gnus-summary-article-number)
2221 gnus-newsgroup-data)))))
2224 (mail-header-subject headers))))
2226 (defmacro gnus-summary-article-score (&optional number)
2227 "Return current article score."
2228 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2229 gnus-newsgroup-scored))
2230 gnus-summary-default-score 0))
2232 (defun gnus-summary-article-children (&optional number)
2233 "Return a list of article numbers that are children of article NUMBER."
2234 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2235 (level (gnus-data-level (car data)))
2237 (while (and (setq data (cdr data))
2238 (> (setq l (gnus-data-level (car data))) level))
2239 (and (= (1+ level) l)
2240 (push (gnus-data-number (car data))
2242 (nreverse children)))
2244 (defun gnus-summary-article-parent (&optional number)
2245 "Return the article number of the parent of article NUMBER."
2246 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2247 (gnus-data-list t)))
2248 (level (gnus-data-level (car data))))
2250 () ; This is a root.
2251 ;; We search until we find an article with a level less than
2252 ;; this one. That function has to be the parent.
2253 (while (and (setq data (cdr data))
2254 (not (< (gnus-data-level (car data)) level))))
2255 (and data (gnus-data-number (car data))))))
2257 (defun gnus-unread-mark-p (mark)
2258 "Say whether MARK is the unread mark."
2259 (= mark gnus-unread-mark))
2261 (defun gnus-read-mark-p (mark)
2262 "Say whether MARK is one of the marks that mark as read.
2263 This is all marks except unread, ticked, dormant, and expirable."
2264 (not (or (= mark gnus-unread-mark)
2265 (= mark gnus-ticked-mark)
2266 (= mark gnus-dormant-mark)
2267 (= mark gnus-expirable-mark))))
2269 (defmacro gnus-article-mark (number)
2270 "Return the MARK of article NUMBER.
2271 This macro should only be used when computing the mark the \"first\"
2272 time; i.e., when generating the summary lines. After that,
2273 `gnus-summary-article-mark' should be used to examine the
2276 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2277 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2278 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2279 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2280 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2281 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2282 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2283 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2284 gnus-ancient-mark))))
2286 ;; Saving hidden threads.
2288 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2289 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2291 (defmacro gnus-save-hidden-threads (&rest forms)
2292 "Save hidden threads, eval FORMS, and restore the hidden threads."
2293 (let ((config (make-symbol "config")))
2294 `(let ((,config (gnus-hidden-threads-configuration)))
2298 (gnus-restore-hidden-threads-configuration ,config)))))
2300 (defun gnus-hidden-threads-configuration ()
2301 "Return the current hidden threads configuration."
2304 (goto-char (point-min))
2305 (while (search-forward "\r" nil t)
2306 (push (1- (point)) config))
2309 (defun gnus-restore-hidden-threads-configuration (config)
2310 "Restore hidden threads configuration from CONFIG."
2311 (let (point buffer-read-only)
2312 (while (setq point (pop config))
2313 (when (and (< point (point-max))
2315 (= (following-char) ?\n))
2316 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2318 ;; Various summary mode internalish functions.
2320 (defun gnus-mouse-pick-article (e)
2323 (gnus-summary-next-page nil t))
2325 (defun gnus-summary-set-display-table ()
2326 ;; Change the display table. Odd characters have a tendency to mess
2327 ;; up nicely formatted displays - we make all possible glyphs
2328 ;; display only a single character.
2330 ;; We start from the standard display table, if any.
2331 (let ((table (or (copy-sequence standard-display-table)
2332 (make-display-table)))
2334 ;; Nix out all the control chars...
2335 (while (>= (setq i (1- i)) 0)
2336 (aset table i [??]))
2337 ;; ... but not newline and cr, of course. (cr is necessary for the
2338 ;; selective display).
2339 (aset table ?\n nil)
2340 (aset table ?\r nil)
2341 ;; We keep TAB as well.
2342 (aset table ?\t nil)
2343 ;; We nix out any glyphs over 126 that are not set already.
2345 (while (>= (setq i (1- i)) 127)
2346 ;; Only modify if the entry is nil.
2347 (unless (aref table i)
2348 (aset table i [??]))))
2349 (setq buffer-display-table table)))
2351 (defun gnus-summary-setup-buffer (group)
2352 "Initialize summary buffer."
2353 (let ((buffer (concat "*Summary " group "*")))
2354 (if (get-buffer buffer)
2357 (setq gnus-summary-buffer (current-buffer))
2358 (not gnus-newsgroup-prepared))
2359 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2360 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2361 (gnus-add-current-to-buffer-list)
2362 (gnus-summary-mode group)
2364 (gnus-carpal-setup-buffer 'summary))
2365 (unless gnus-single-article-buffer
2366 (make-local-variable 'gnus-article-buffer)
2367 (make-local-variable 'gnus-article-current)
2368 (make-local-variable 'gnus-original-article-buffer))
2369 (setq gnus-newsgroup-name group)
2372 (defun gnus-set-global-variables ()
2373 ;; Set the global equivalents of the summary buffer-local variables
2374 ;; to the latest values they had. These reflect the summary buffer
2375 ;; that was in action when the last article was fetched.
2376 (when (eq major-mode 'gnus-summary-mode)
2377 (setq gnus-summary-buffer (current-buffer))
2378 (let ((name gnus-newsgroup-name)
2379 (marked gnus-newsgroup-marked)
2380 (unread gnus-newsgroup-unreads)
2381 (headers gnus-current-headers)
2382 (data gnus-newsgroup-data)
2383 (summary gnus-summary-buffer)
2384 (article-buffer gnus-article-buffer)
2385 (original gnus-original-article-buffer)
2386 (gac gnus-article-current)
2387 (reffed gnus-reffed-article-number)
2388 (score-file gnus-current-score-file))
2390 (set-buffer gnus-group-buffer)
2391 (setq gnus-newsgroup-name name
2392 gnus-newsgroup-marked marked
2393 gnus-newsgroup-unreads unread
2394 gnus-current-headers headers
2395 gnus-newsgroup-data data
2396 gnus-article-current gac
2397 gnus-summary-buffer summary
2398 gnus-article-buffer article-buffer
2399 gnus-original-article-buffer original
2400 gnus-reffed-article-number reffed
2401 gnus-current-score-file score-file)
2402 ;; The article buffer also has local variables.
2403 (when (gnus-buffer-live-p gnus-article-buffer)
2404 (set-buffer gnus-article-buffer)
2405 (setq gnus-summary-buffer summary))))))
2407 (defun gnus-summary-article-unread-p (article)
2408 "Say whether ARTICLE is unread or not."
2409 (memq article gnus-newsgroup-unreads))
2411 (defun gnus-summary-first-article-p (&optional article)
2412 "Return whether ARTICLE is the first article in the buffer."
2413 (if (not (setq article (or article (gnus-summary-article-number))))
2415 (eq article (caar gnus-newsgroup-data))))
2417 (defun gnus-summary-last-article-p (&optional article)
2418 "Return whether ARTICLE is the last article in the buffer."
2419 (if (not (setq article (or article (gnus-summary-article-number))))
2420 t ; All non-existent numbers are the last article. :-)
2421 (not (cdr (gnus-data-find-list article)))))
2423 (defun gnus-make-thread-indent-array ()
2425 (unless (and gnus-thread-indent-array
2426 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2427 (setq gnus-thread-indent-array (make-vector 201 "")
2428 gnus-thread-indent-array-level gnus-thread-indent-level)
2430 (aset gnus-thread-indent-array n
2431 (make-string (* n gnus-thread-indent-level) ? ))
2434 (defun gnus-update-summary-mark-positions ()
2435 "Compute where the summary marks are to go."
2437 (when (and gnus-summary-buffer
2438 (get-buffer gnus-summary-buffer)
2439 (buffer-name (get-buffer gnus-summary-buffer)))
2440 (set-buffer gnus-summary-buffer))
2441 (let ((gnus-replied-mark 129)
2442 (gnus-score-below-mark 130)
2443 (gnus-score-over-mark 130)
2444 (gnus-download-mark 131)
2445 (spec gnus-summary-line-format-spec)
2446 thread gnus-visual pos)
2448 (gnus-set-work-buffer)
2449 (let ((gnus-summary-line-format-spec spec)
2450 (gnus-newsgroup-downloadable '((0 . t))))
2451 (gnus-summary-insert-line
2452 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2453 (goto-char (point-min))
2454 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2456 (goto-char (point-min))
2457 (push (cons 'replied (and (search-forward "\201" nil t)
2460 (goto-char (point-min))
2461 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2463 (goto-char (point-min))
2464 (push (cons 'download
2465 (and (search-forward "\203" nil t) (- (point) 2)))
2467 (setq gnus-summary-mark-positions pos))))
2469 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2470 "Insert a dummy root in the summary buffer."
2472 (gnus-add-text-properties
2473 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2474 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2476 (defun gnus-summary-insert-line (gnus-tmp-header
2477 gnus-tmp-level gnus-tmp-current
2478 gnus-tmp-unread gnus-tmp-replied
2479 gnus-tmp-expirable gnus-tmp-subject-or-nil
2480 &optional gnus-tmp-dummy gnus-tmp-score
2482 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2483 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2484 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2485 (gnus-tmp-score-char
2486 (if (or (null gnus-summary-default-score)
2487 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2488 gnus-summary-zcore-fuzz))
2490 (if (< gnus-tmp-score gnus-summary-default-score)
2491 gnus-score-below-mark gnus-score-over-mark)))
2493 (cond (gnus-tmp-process gnus-process-mark)
2494 ((memq gnus-tmp-current gnus-newsgroup-cached)
2496 (gnus-tmp-replied gnus-replied-mark)
2497 ((memq gnus-tmp-current gnus-newsgroup-saved)
2499 (t gnus-unread-mark)))
2500 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2503 ((string-match "<[^>]+> *$" gnus-tmp-from)
2504 (let ((beg (match-beginning 0)))
2505 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2506 (substring gnus-tmp-from (1+ (match-beginning 0))
2507 (1- (match-end 0))))
2508 (substring gnus-tmp-from 0 beg))))
2509 ((string-match "(.+)" gnus-tmp-from)
2510 (substring gnus-tmp-from
2511 (1+ (match-beginning 0)) (1- (match-end 0))))
2513 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2514 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2515 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2516 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2517 (buffer-read-only nil))
2518 (when (string= gnus-tmp-name "")
2519 (setq gnus-tmp-name gnus-tmp-from))
2520 (unless (numberp gnus-tmp-lines)
2521 (setq gnus-tmp-lines 0))
2522 (gnus-put-text-property
2524 (progn (eval gnus-summary-line-format-spec) (point))
2525 'gnus-number gnus-tmp-number)
2526 (when (gnus-visual-p 'summary-highlight 'highlight)
2528 (run-hooks 'gnus-summary-update-hook)
2531 (defun gnus-summary-update-line (&optional dont-update)
2532 ;; Update summary line after change.
2533 (when (and gnus-summary-default-score
2534 (not gnus-summary-inhibit-highlight))
2535 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2536 (article (gnus-summary-article-number))
2537 (score (gnus-summary-article-score article)))
2539 (if (and gnus-summary-mark-below
2540 (< (gnus-summary-article-score)
2541 gnus-summary-mark-below))
2542 ;; This article has a low score, so we mark it as read.
2543 (when (memq article gnus-newsgroup-unreads)
2544 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2545 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2546 ;; This article was previously marked as read on account
2547 ;; of a low score, but now it has risen, so we mark it as
2549 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2550 (gnus-summary-update-mark
2551 (if (or (null gnus-summary-default-score)
2552 (<= (abs (- score gnus-summary-default-score))
2553 gnus-summary-zcore-fuzz))
2555 (if (< score gnus-summary-default-score)
2556 gnus-score-below-mark gnus-score-over-mark))
2558 ;; Do visual highlighting.
2559 (when (gnus-visual-p 'summary-highlight 'highlight)
2560 (run-hooks 'gnus-summary-update-hook)))))
2562 (defvar gnus-tmp-new-adopts nil)
2564 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2565 "Return the number of articles in THREAD.
2566 This may be 0 in some cases -- if none of the articles in
2567 the thread are to be displayed."
2569 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2571 ((not (listp thread))
2573 ((and (consp thread) (cdr thread))
2576 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2579 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2582 (when (and level (zerop level) gnus-tmp-new-adopts)
2585 'gnus-summary-number-of-articles-in-thread
2586 gnus-tmp-new-adopts))))
2588 (if (> number 1) gnus-not-empty-thread-mark
2589 gnus-empty-thread-mark)
2592 (defun gnus-summary-set-local-parameters (group)
2593 "Go through the local params of GROUP and set all variable specs in that list."
2594 (let ((params (gnus-group-find-parameter group))
2597 (setq elem (car params)
2598 params (cdr params))
2599 (and (consp elem) ; Has to be a cons.
2600 (consp (cdr elem)) ; The cdr has to be a list.
2601 (symbolp (car elem)) ; Has to be a symbol in there.
2602 (not (memq (car elem)
2603 '(quit-config to-address to-list to-group)))
2604 (ignore-errors ; So we set it.
2605 (make-local-variable (car elem))
2606 (set (car elem) (eval (nth 1 elem))))))))
2608 (defun gnus-summary-read-group (group &optional show-all no-article
2609 kill-buffer no-display)
2610 "Start reading news in newsgroup GROUP.
2611 If SHOW-ALL is non-nil, already read articles are also listed.
2612 If NO-ARTICLE is non-nil, no article is selected initially.
2613 If NO-DISPLAY, don't generate a summary buffer."
2617 (let ((gnus-auto-select-next nil))
2618 (or (gnus-summary-read-group-1
2619 group show-all no-article
2620 kill-buffer no-display)
2621 (setq show-all nil)))))
2622 (eq gnus-auto-select-next 'quietly))
2623 (set-buffer gnus-group-buffer)
2624 (if (not (equal group (gnus-group-group-name)))
2625 (setq group (gnus-group-group-name))
2629 (defun gnus-summary-read-group-1 (group show-all no-article
2630 kill-buffer no-display)
2631 ;; Killed foreign groups can't be entered.
2632 (when (and (not (gnus-group-native-p group))
2633 (not (gnus-gethash group gnus-newsrc-hashtb)))
2634 (error "Dead non-native groups can't be entered"))
2635 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2636 (let* ((new-group (gnus-summary-setup-buffer group))
2637 (quit-config (gnus-group-quit-config group))
2638 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2640 ;; This summary buffer exists already, so we just select it.
2642 (gnus-set-global-variables)
2644 (gnus-kill-or-deaden-summary kill-buffer))
2645 (gnus-configure-windows 'summary 'force)
2646 (gnus-set-mode-line 'summary)
2647 (gnus-summary-position-point)
2650 ;; We couldn't select this group.
2652 (when (and (eq major-mode 'gnus-summary-mode)
2653 (not (equal (current-buffer) kill-buffer)))
2654 (kill-buffer (current-buffer))
2655 (if (not quit-config)
2657 ;; Update the info -- marks might need to be removed,
2659 (gnus-summary-update-info)
2660 (set-buffer gnus-group-buffer)
2661 (gnus-group-jump-to-group group)
2662 (gnus-group-next-unread-group 1))
2663 (gnus-handle-ephemeral-exit quit-config)))
2664 (gnus-message 3 "Can't select group")
2666 ;; The user did a `C-g' while prompting for number of articles,
2667 ;; so we exit this group.
2668 ((eq did-select 'quit)
2669 (and (eq major-mode 'gnus-summary-mode)
2670 (not (equal (current-buffer) kill-buffer))
2671 (kill-buffer (current-buffer)))
2673 (gnus-kill-or-deaden-summary kill-buffer))
2674 (if (not quit-config)
2676 (set-buffer gnus-group-buffer)
2677 (gnus-group-jump-to-group group)
2678 (gnus-group-next-unread-group 1)
2679 (gnus-configure-windows 'group 'force))
2680 (gnus-handle-ephemeral-exit quit-config))
2681 ;; Finally signal the quit.
2683 ;; The group was successfully selected.
2685 (gnus-set-global-variables)
2686 ;; Save the active value in effect when the group was entered.
2687 (setq gnus-newsgroup-active
2689 (gnus-active gnus-newsgroup-name)))
2690 ;; You can change the summary buffer in some way with this hook.
2691 (run-hooks 'gnus-select-group-hook)
2692 ;; Set any local variables in the group parameters.
2693 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2694 (gnus-update-format-specifications
2695 nil 'summary 'summary-mode 'summary-dummy)
2696 ;; Do score processing.
2697 (when gnus-use-scoring
2698 (gnus-possibly-score-headers))
2699 ;; Check whether to fill in the gaps in the threads.
2700 (when gnus-build-sparse-threads
2701 (gnus-build-sparse-threads))
2702 ;; Find the initial limit.
2703 (if gnus-show-threads
2705 (let ((gnus-newsgroup-dormant nil))
2706 (gnus-summary-initial-limit show-all))
2707 (gnus-summary-initial-limit show-all))
2708 (setq gnus-newsgroup-limit
2710 (lambda (header) (mail-header-number header))
2711 gnus-newsgroup-headers)))
2712 ;; Generate the summary buffer.
2714 (gnus-summary-prepare))
2715 (when gnus-use-trees
2716 (gnus-tree-open group)
2717 (setq gnus-summary-highlight-line-function
2718 'gnus-tree-highlight-article))
2719 ;; If the summary buffer is empty, but there are some low-scored
2720 ;; articles or some excluded dormants, we include these in the
2722 (when (and (zerop (buffer-size))
2724 (cond (gnus-newsgroup-dormant
2725 (gnus-summary-limit-include-dormant))
2726 ((and gnus-newsgroup-scored show-all)
2727 (gnus-summary-limit-include-expunged t))))
2728 ;; Function `gnus-apply-kill-file' must be called in this hook.
2729 (run-hooks 'gnus-apply-kill-hook)
2730 (if (and (zerop (buffer-size))
2733 ;; This newsgroup is empty.
2734 (gnus-summary-catchup-and-exit nil t)
2735 (gnus-message 6 "No unread news")
2737 (gnus-kill-or-deaden-summary kill-buffer))
2738 ;; Return nil from this function.
2740 ;; Hide conversation thread subtrees. We cannot do this in
2741 ;; gnus-summary-prepare-hook since kill processing may not
2742 ;; work with hidden articles.
2743 (and gnus-show-threads
2744 gnus-thread-hide-subtree
2745 (gnus-summary-hide-all-threads))
2747 (gnus-kill-or-deaden-summary kill-buffer))
2748 ;; Show first unread article if requested.
2749 (if (and (not no-article)
2751 gnus-newsgroup-unreads
2752 gnus-auto-select-first)
2753 (unless (if (eq gnus-auto-select-first 'best)
2754 (gnus-summary-best-unread-article)
2755 (gnus-summary-first-unread-article))
2756 (gnus-configure-windows 'summary))
2757 ;; Don't select any articles, just move point to the first
2758 ;; article in the group.
2759 (goto-char (point-min))
2760 (gnus-summary-position-point)
2761 (gnus-configure-windows 'summary 'force)
2762 (gnus-set-mode-line 'summary))
2763 (when (get-buffer-window gnus-group-buffer t)
2764 ;; Gotta use windows, because recenter does weird stuff if
2765 ;; the current buffer ain't the displayed window.
2766 (let ((owin (selected-window)))
2767 (select-window (get-buffer-window gnus-group-buffer t))
2768 (when (gnus-group-goto-group group)
2770 (select-window owin)))
2771 ;; Mark this buffer as "prepared".
2772 (setq gnus-newsgroup-prepared t)
2773 (run-hooks 'gnus-summary-prepared-hook)
2776 (defun gnus-summary-prepare ()
2777 "Generate the summary buffer."
2779 (let ((buffer-read-only nil))
2781 (setq gnus-newsgroup-data nil
2782 gnus-newsgroup-data-reverse nil)
2783 (run-hooks 'gnus-summary-generate-hook)
2784 ;; Generate the buffer, either with threads or without.
2785 (when gnus-newsgroup-headers
2786 (gnus-summary-prepare-threads
2787 (if gnus-show-threads
2788 (gnus-sort-gathered-threads
2789 (funcall gnus-summary-thread-gathering-function
2791 (gnus-cut-threads (gnus-make-threads)))))
2792 ;; Unthreaded display.
2793 (gnus-sort-articles gnus-newsgroup-headers))))
2794 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2795 ;; Call hooks for modifying summary buffer.
2796 (goto-char (point-min))
2797 (run-hooks 'gnus-summary-prepare-hook)))
2799 (defsubst gnus-general-simplify-subject (subject)
2800 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2803 ;; Truncate the subject.
2804 (gnus-simplify-subject-functions
2805 (gnus-map-function gnus-simplify-subject-functions subject))
2806 ((numberp gnus-summary-gather-subject-limit)
2807 (setq subject (gnus-simplify-subject-re subject))
2808 (if (> (length subject) gnus-summary-gather-subject-limit)
2809 (substring subject 0 gnus-summary-gather-subject-limit)
2811 ;; Fuzzily simplify it.
2812 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2813 (gnus-simplify-subject-fuzzy subject))
2814 ;; Just remove the leading "Re:".
2816 (gnus-simplify-subject-re subject))))
2818 (if (and gnus-summary-gather-exclude-subject
2819 (string-match gnus-summary-gather-exclude-subject subject))
2820 nil ; This article shouldn't be gathered
2823 (defun gnus-summary-simplify-subject-query ()
2824 "Query where the respool algorithm would put this article."
2826 (gnus-summary-select-article)
2827 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2829 (defun gnus-gather-threads-by-subject (threads)
2830 "Gather threads by looking at Subject headers."
2831 (if (not gnus-summary-make-false-root)
2833 (let ((hashtb (gnus-make-hashtable 1024))
2836 subject hthread whole-subject)
2838 (setq subject (gnus-general-simplify-subject
2839 (setq whole-subject (mail-header-subject
2842 (if (setq hthread (gnus-gethash subject hashtb))
2844 ;; We enter a dummy root into the thread, if we
2845 ;; haven't done that already.
2846 (unless (stringp (caar hthread))
2847 (setcar hthread (list whole-subject (car hthread))))
2848 ;; We add this new gathered thread to this gathered
2850 (setcdr (car hthread)
2851 (nconc (cdar hthread) (list (car threads))))
2852 ;; Remove it from the list of threads.
2853 (setcdr prev (cdr threads))
2854 (setq threads prev))
2855 ;; Enter this thread into the hash table.
2856 (gnus-sethash subject threads hashtb)))
2858 (setq threads (cdr threads)))
2861 (defun gnus-gather-threads-by-references (threads)
2862 "Gather threads by looking at References headers."
2863 (let ((idhashtb (gnus-make-hashtable 1024))
2864 (thhashtb (gnus-make-hashtable 1024))
2867 ids references id gthread gid entered ref)
2869 (when (setq references (mail-header-references (caar threads)))
2870 (setq id (mail-header-id (caar threads))
2871 ids (gnus-split-references references)
2873 (while (setq ref (pop ids))
2874 (setq ids (delete ref ids))
2875 (if (not (setq gid (gnus-gethash ref idhashtb)))
2877 (gnus-sethash ref id idhashtb)
2878 (gnus-sethash id threads thhashtb))
2879 (setq gthread (gnus-gethash gid thhashtb))
2881 ;; We enter a dummy root into the thread, if we
2882 ;; haven't done that already.
2883 (unless (stringp (caar gthread))
2884 (setcar gthread (list (mail-header-subject (caar gthread))
2886 ;; We add this new gathered thread to this gathered
2888 (setcdr (car gthread)
2889 (nconc (cdar gthread) (list (car threads)))))
2890 ;; Add it into the thread hash table.
2891 (gnus-sethash id gthread thhashtb)
2893 ;; Remove it from the list of threads.
2894 (setcdr prev (cdr threads))
2895 (setq threads prev))))
2897 (setq threads (cdr threads)))
2900 (defun gnus-sort-gathered-threads (threads)
2901 "Sort subtreads inside each gathered thread by article number."
2902 (let ((result threads))
2904 (when (stringp (caar threads))
2905 (setcdr (car threads)
2906 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2907 (setq threads (cdr threads)))
2910 (defun gnus-thread-loop-p (root thread)
2911 "Say whether ROOT is in THREAD."
2912 (let ((stack (list thread))
2915 (while (setq thread (pop stack))
2916 (setq th (cdr thread))
2918 (not (eq (caar th) root)))
2921 ;; We have found a loop.
2923 (setcdr thread (delq (car th) (cdr thread)))
2924 (if (boundp (setq ref-dep (intern "none"
2925 gnus-newsgroup-dependencies)))
2926 (setcdr (symbol-value ref-dep)
2927 (nconc (cdr (symbol-value ref-dep))
2929 (set ref-dep (list nil (car th))))
2932 ;; Push all the subthreads onto the stack.
2933 (push (cdr thread) stack)))
2936 (defun gnus-make-threads ()
2937 "Go through the dependency hashtb and find the roots. Return all threads."
2939 (while (catch 'infloop
2942 ;; Deal with self-referencing References loops.
2943 (when (and (car (symbol-value refs))
2950 (car (symbol-value refs)) thread))
2951 (cdr (symbol-value refs)))))))
2954 (unless (car (symbol-value refs))
2955 ;; These threads do not refer back to any other articles,
2956 ;; so they're roots.
2957 (setq threads (append (cdr (symbol-value refs)) threads))))
2958 gnus-newsgroup-dependencies)))
2961 (defun gnus-build-sparse-threads ()
2962 (let ((headers gnus-newsgroup-headers)
2963 (deps gnus-newsgroup-dependencies)
2964 header references generation relations
2965 cthread subject child end pthread relation new-child)
2966 ;; First we create an alist of generations/relations, where
2967 ;; generations is how much we trust the relation, and the relation
2969 (gnus-message 7 "Making sparse threads...")
2971 (nnheader-set-temp-buffer " *gnus sparse threads*")
2972 (while (setq header (pop headers))
2973 (when (and (setq references (mail-header-references header))
2974 (not (string= references "")))
2976 (setq child (mail-header-id header)
2977 subject (mail-header-subject header))
2979 (while (search-backward ">" nil t)
2980 (setq end (1+ (point)))
2981 (when (search-backward "<" nil t)
2982 (unless (string= (setq new-child (buffer-substring (point) end))
2984 (push (list (incf generation)
2985 child (setq child new-child)
2988 (push (list (1+ generation) child nil subject) relations)
2990 (kill-buffer (current-buffer)))
2991 ;; Sort over trustworthiness.
2992 (setq relations (sort relations 'car-less-than-car))
2993 (while (setq relation (pop relations))
2994 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2995 (unless (car (symbol-value cthread))
2996 ;; Make this article the parent of these threads.
2997 (setcar (symbol-value cthread)
2998 (vector gnus-reffed-article-number
3002 (or (caddr relation) "") 0 0 "")))
3003 (set cthread (list (vector gnus-reffed-article-number
3005 "" "" (cadr relation)
3006 (or (caddr relation) "") 0 0 ""))))
3007 (push gnus-reffed-article-number gnus-newsgroup-limit)
3008 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3009 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3010 gnus-newsgroup-reads)
3011 (decf gnus-reffed-article-number)
3012 ;; Make this new thread the child of its parent.
3013 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
3014 (setcdr (symbol-value pthread)
3015 (nconc (cdr (symbol-value pthread))
3016 (list (symbol-value cthread))))
3017 (set pthread (list nil (symbol-value cthread))))))
3018 (gnus-message 7 "Making sparse threads...done")))
3020 (defun gnus-build-old-threads ()
3021 ;; Look at all the articles that refer back to old articles, and
3022 ;; fetch the headers for the articles that aren't there. This will
3023 ;; build complete threads - if the roots haven't been expired by the
3028 (when (not (car (symbol-value refs)))
3029 (setq heads (cdr (symbol-value refs)))
3031 (if (memq (mail-header-number (caar heads))
3032 gnus-newsgroup-dormant)
3033 (setq heads (cdr heads))
3034 (setq id (symbol-name refs))
3035 (while (and (setq id (gnus-build-get-header id))
3036 (not (car (gnus-gethash
3037 id gnus-newsgroup-dependencies)))))
3038 (setq heads nil)))))
3039 gnus-newsgroup-dependencies)))
3041 (defun gnus-build-get-header (id)
3042 ;; Look through the buffer of NOV lines and find the header to
3043 ;; ID. Enter this line into the dependencies hash table, and return
3044 ;; the id of the parent article (if any).
3045 (let ((deps gnus-newsgroup-dependencies)
3049 (set-buffer nntp-server-buffer)
3050 (let ((case-fold-search nil))
3051 (goto-char (point-min))
3052 (while (and (not found)
3053 (search-forward id nil t))
3055 (setq found (looking-at
3056 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3057 (regexp-quote id))))
3058 (or found (beginning-of-line 2)))
3062 (setq header (gnus-nov-parse-line
3063 (read (current-buffer)) deps))
3064 (gnus-parent-id (mail-header-references header))))))
3066 (let ((number (mail-header-number header)))
3067 (push number gnus-newsgroup-limit)
3068 (push header gnus-newsgroup-headers)
3069 (if (memq number gnus-newsgroup-unselected)
3071 (push number gnus-newsgroup-unreads)
3072 (setq gnus-newsgroup-unselected
3073 (delq number gnus-newsgroup-unselected)))
3074 (push number gnus-newsgroup-ancient)))))))
3076 (defun gnus-build-all-threads ()
3077 "Read all the headers."
3078 (let ((deps gnus-newsgroup-dependencies)
3079 (gnus-summary-ignore-duplicates t)
3080 found header article)
3082 (set-buffer nntp-server-buffer)
3083 (let ((case-fold-search nil))
3084 (goto-char (point-min))
3087 (setq article (read (current-buffer)))
3088 (setq header (gnus-nov-parse-line article deps)))
3090 (push header gnus-newsgroup-headers)
3091 (if (memq (setq article (mail-header-number header))
3092 gnus-newsgroup-unselected)
3094 (push article gnus-newsgroup-unreads)
3095 (setq gnus-newsgroup-unselected
3096 (delq article gnus-newsgroup-unselected)))
3097 (push article gnus-newsgroup-ancient))
3098 (forward-line 1)))))))
3100 (defun gnus-summary-update-article-line (article header)
3101 "Update the line for ARTICLE using HEADERS."
3102 (let* ((id (mail-header-id header))
3103 (thread (gnus-id-to-thread id)))
3105 (error "Article in no thread"))
3106 ;; Update the thread.
3107 (setcar thread header)
3108 (gnus-summary-goto-subject article)
3109 (let* ((datal (gnus-data-find-list article))
3111 (length (when (cdr datal)
3112 (- (gnus-data-pos data)
3113 (gnus-data-pos (cadr datal)))))
3114 (buffer-read-only nil)
3115 (level (gnus-summary-thread-level)))
3117 (gnus-summary-insert-line
3118 header level nil (gnus-article-mark article)
3119 (memq article gnus-newsgroup-replied)
3120 (memq article gnus-newsgroup-expirable)
3121 ;; Only insert the Subject string when it's different
3122 ;; from the previous Subject string.
3123 (if (gnus-subject-equal
3125 (mail-header-subject
3128 (gnus-data-find-list
3130 (gnus-data-list t)))))
3131 ;; Error on the side of excessive subjects.
3133 (mail-header-subject header))
3135 (mail-header-subject header))
3136 nil (cdr (assq article gnus-newsgroup-scored))
3137 (memq article gnus-newsgroup-processable))
3139 (gnus-data-update-list
3140 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3142 (defun gnus-summary-update-article (article &optional iheader)
3143 "Update ARTICLE in the summary buffer."
3144 (set-buffer gnus-summary-buffer)
3145 (let* ((header (or iheader (gnus-summary-article-header article)))
3146 (id (mail-header-id header))
3147 (data (gnus-data-find article))
3148 (thread (gnus-id-to-thread id))
3149 (references (mail-header-references header))
3153 (when (and references
3154 (not (equal "" references)))
3157 (buffer-read-only nil)
3159 (number (mail-header-number header))
3162 ;; !!! Should this be in or not?
3164 (setcar thread nil))
3166 (delq thread parent))
3167 (if (gnus-summary-insert-subject id header iheader)
3168 ;; Set the (possibly) new article number in the data structure.
3169 (gnus-data-set-number data (gnus-id-to-article id))
3173 (defun gnus-rebuild-thread (id)
3174 "Rebuild the thread containing ID."
3175 (let ((buffer-read-only nil)
3176 old-pos current thread data)
3177 (if (not gnus-show-threads)
3178 (setq thread (list (car (gnus-id-to-thread id))))
3179 ;; Get the thread this article is part of.
3180 (setq thread (gnus-remove-thread id)))
3181 (setq old-pos (gnus-point-at-bol))
3182 (setq current (save-excursion
3183 (and (zerop (forward-line -1))
3184 (gnus-summary-article-number))))
3185 ;; If this is a gathered thread, we have to go some re-gathering.
3186 (when (stringp (car thread))
3187 (let ((subject (car thread))
3189 (setq thread (cdr thread))
3191 (unless (memq (setq thr (gnus-id-to-thread
3193 (mail-header-id (caar thread)))))
3196 (setq thread (cdr thread)))
3197 ;; We now have all (unique) roots.
3198 (if (= (length roots) 1)
3199 ;; All the loose roots are now one solid root.
3200 (setq thread (car roots))
3201 (setq thread (cons subject (gnus-sort-threads roots))))))
3203 ;; We then insert this thread into the summary buffer.
3204 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3205 (if gnus-show-threads
3206 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3207 (gnus-summary-prepare-unthreaded thread))
3208 (setq data (nreverse gnus-newsgroup-data))
3209 (setq threads gnus-newsgroup-threads))
3210 ;; We splice the new data into the data structure.
3211 (gnus-data-enter-list current data (- (point) old-pos))
3212 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3214 (defun gnus-number-to-header (number)
3215 "Return the header for article NUMBER."
3216 (let ((headers gnus-newsgroup-headers))
3218 (not (= number (mail-header-number (car headers)))))
3223 (defun gnus-parent-headers (headers &optional generation)
3224 "Return the headers of the GENERATIONeth parent of HEADERS."
3226 (setq generation 1))
3229 (while (and parent headers (not (zerop generation)))
3230 (setq references (mail-header-references headers))
3231 (when (and references
3232 (setq parent (gnus-parent-id references))
3233 (setq headers (car (gnus-id-to-thread parent))))
3237 (defun gnus-id-to-thread (id)
3238 "Return the (sub-)thread where ID appears."
3239 (gnus-gethash id gnus-newsgroup-dependencies))
3241 (defun gnus-id-to-article (id)
3242 "Return the article number of ID."
3243 (let ((thread (gnus-id-to-thread id)))
3246 (mail-header-number (car thread)))))
3248 (defun gnus-id-to-header (id)
3249 "Return the article headers of ID."
3250 (car (gnus-id-to-thread id)))
3252 (defun gnus-article-displayed-root-p (article)
3253 "Say whether ARTICLE is a root(ish) article."
3254 (let ((level (gnus-summary-thread-level article))
3255 (refs (mail-header-references (gnus-summary-article-header article)))
3261 ((null (gnus-parent-id refs)) t)
3263 (null (setq particle (gnus-id-to-article
3264 (gnus-parent-id refs))))
3265 (null (gnus-summary-thread-level particle)))))))
3267 (defun gnus-root-id (id)
3268 "Return the id of the root of the thread where ID appears."
3270 (while (and id (setq prev (car (gnus-gethash
3271 id gnus-newsgroup-dependencies))))
3273 id (gnus-parent-id (mail-header-references prev))))
3276 (defun gnus-articles-in-thread (thread)
3277 "Return the list of articles in THREAD."
3278 (cons (mail-header-number (car thread))
3279 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3281 (defun gnus-remove-thread (id &optional dont-remove)
3282 "Remove the thread that has ID in it."
3283 (let ((dep gnus-newsgroup-dependencies)
3284 headers thread last-id)
3285 ;; First go up in this thread until we find the root.
3286 (setq last-id (gnus-root-id id))
3287 (setq headers (list (car (gnus-id-to-thread last-id))
3288 (caadr (gnus-id-to-thread last-id))))
3289 ;; We have now found the real root of this thread. It might have
3290 ;; been gathered into some loose thread, so we have to search
3291 ;; through the threads to find the thread we wanted.
3292 (let ((threads gnus-newsgroup-threads)
3295 (setq sub (car threads))
3296 (if (stringp (car sub))
3297 ;; This is a gathered thread, so we look at the roots
3298 ;; below it to find whether this article is in this
3301 (setq sub (cdr sub))
3303 (when (member (caar sub) headers)
3304 (setq thread (car threads)
3307 (setq sub (cdr sub))))
3308 ;; It's an ordinary thread, so we check it.
3309 (when (eq (car sub) (car headers))
3312 (setq threads (cdr threads)))
3313 ;; If this article is in no thread, then it's a root.
3316 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3317 (setq thread (gnus-gethash last-id dep)))
3320 thread ; We return this thread.
3322 (if (stringp (car thread))
3324 ;; If we use dummy roots, then we have to remove the
3325 ;; dummy root as well.
3326 (when (eq gnus-summary-make-false-root 'dummy)
3328 (gnus-data-compute-positions))
3329 (setq thread (cdr thread))
3331 (gnus-remove-thread-1 (car thread))
3332 (setq thread (cdr thread))))
3333 (gnus-remove-thread-1 thread))))))))
3335 (defun gnus-remove-thread-1 (thread)
3336 "Remove the thread THREAD recursively."
3337 (let ((number (mail-header-number (pop thread)))
3339 (setq thread (reverse thread))
3341 (gnus-remove-thread-1 (pop thread)))
3342 (when (setq d (gnus-data-find number))
3343 (goto-char (gnus-data-pos d))
3346 (- (gnus-point-at-bol)
3348 (1+ (gnus-point-at-eol))
3349 (gnus-delete-line)))))))
3351 (defun gnus-sort-threads (threads)
3353 (if (not gnus-thread-sort-functions)
3355 (gnus-message 7 "Sorting threads...")
3357 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3358 (gnus-message 7 "Sorting threads...done"))))
3360 (defun gnus-sort-articles (articles)
3362 (when gnus-article-sort-functions
3363 (gnus-message 7 "Sorting articles...")
3365 (setq gnus-newsgroup-headers
3366 (sort articles (gnus-make-sort-function
3367 gnus-article-sort-functions)))
3368 (gnus-message 7 "Sorting articles...done"))))
3370 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3371 (defmacro gnus-thread-header (thread)
3372 ;; Return header of first article in THREAD.
3373 ;; Note that THREAD must never, ever be anything else than a variable -
3374 ;; using some other form will lead to serious barfage.
3375 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3376 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3377 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3380 (defsubst gnus-article-sort-by-number (h1 h2)
3381 "Sort articles by article number."
3382 (< (mail-header-number h1)
3383 (mail-header-number h2)))
3385 (defun gnus-thread-sort-by-number (h1 h2)
3386 "Sort threads by root article number."
3387 (gnus-article-sort-by-number
3388 (gnus-thread-header h1) (gnus-thread-header h2)))
3390 (defsubst gnus-article-sort-by-lines (h1 h2)
3391 "Sort articles by article Lines header."
3392 (< (mail-header-lines h1)
3393 (mail-header-lines h2)))
3395 (defun gnus-thread-sort-by-lines (h1 h2)
3396 "Sort threads by root article Lines header."
3397 (gnus-article-sort-by-lines
3398 (gnus-thread-header h1) (gnus-thread-header h2)))
3400 (defsubst gnus-article-sort-by-author (h1 h2)
3401 "Sort articles by root author."
3403 (let ((extract (funcall
3404 gnus-extract-address-components
3405 (mail-header-from h1))))
3406 (or (car extract) (cadr extract) ""))
3407 (let ((extract (funcall
3408 gnus-extract-address-components
3409 (mail-header-from h2))))
3410 (or (car extract) (cadr extract) ""))))
3412 (defun gnus-thread-sort-by-author (h1 h2)
3413 "Sort threads by root author."
3414 (gnus-article-sort-by-author
3415 (gnus-thread-header h1) (gnus-thread-header h2)))
3417 (defsubst gnus-article-sort-by-subject (h1 h2)
3418 "Sort articles by root subject."
3420 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3421 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3423 (defun gnus-thread-sort-by-subject (h1 h2)
3424 "Sort threads by root subject."
3425 (gnus-article-sort-by-subject
3426 (gnus-thread-header h1) (gnus-thread-header h2)))
3428 (defsubst gnus-article-sort-by-date (h1 h2)
3429 "Sort articles by root article date."
3431 (gnus-date-get-time (mail-header-date h1))
3432 (gnus-date-get-time (mail-header-date h2))))
3434 (defun gnus-thread-sort-by-date (h1 h2)
3435 "Sort threads by root article date."
3436 (gnus-article-sort-by-date
3437 (gnus-thread-header h1) (gnus-thread-header h2)))
3439 (defsubst gnus-article-sort-by-score (h1 h2)
3440 "Sort articles by root article score.
3441 Unscored articles will be counted as having a score of zero."
3442 (> (or (cdr (assq (mail-header-number h1)
3443 gnus-newsgroup-scored))
3444 gnus-summary-default-score 0)
3445 (or (cdr (assq (mail-header-number h2)
3446 gnus-newsgroup-scored))
3447 gnus-summary-default-score 0)))
3449 (defun gnus-thread-sort-by-score (h1 h2)
3450 "Sort threads by root article score."
3451 (gnus-article-sort-by-score
3452 (gnus-thread-header h1) (gnus-thread-header h2)))
3454 (defun gnus-thread-sort-by-total-score (h1 h2)
3455 "Sort threads by the sum of all scores in the thread.
3456 Unscored articles will be counted as having a score of zero."
3457 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3459 (defun gnus-thread-total-score (thread)
3460 ;; This function find the total score of THREAD.
3461 (cond ((null thread)
3464 (if (stringp (car thread))
3465 (apply gnus-thread-score-function 0
3466 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3467 (gnus-thread-total-score-1 thread)))
3469 (gnus-thread-total-score-1 (list thread)))))
3471 (defun gnus-thread-total-score-1 (root)
3472 ;; This function find the total score of the thread below ROOT.
3473 (setq root (car root))
3474 (apply gnus-thread-score-function
3476 (mapcar 'gnus-thread-total-score
3477 (cdr (gnus-gethash (mail-header-id root)
3478 gnus-newsgroup-dependencies)))
3479 (when (> (mail-header-number root) 0)
3480 (list (or (cdr (assq (mail-header-number root)
3481 gnus-newsgroup-scored))
3482 gnus-summary-default-score 0))))
3483 (list gnus-summary-default-score)
3486 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3487 (defvar gnus-tmp-prev-subject nil)
3488 (defvar gnus-tmp-false-parent nil)
3489 (defvar gnus-tmp-root-expunged nil)
3490 (defvar gnus-tmp-dummy-line nil)
3492 (defun gnus-summary-prepare-threads (threads)
3493 "Prepare summary buffer from THREADS and indentation LEVEL.
3494 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3495 or a straight list of headers."
3496 (gnus-message 7 "Generating summary...")
3498 (setq gnus-newsgroup-threads threads)
3501 (let ((gnus-tmp-level 0)
3502 (default-score (or gnus-summary-default-score 0))
3503 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3504 thread number subject stack state gnus-tmp-gathered beg-match
3505 new-roots gnus-tmp-new-adopts thread-end
3506 gnus-tmp-header gnus-tmp-unread
3507 gnus-tmp-replied gnus-tmp-subject-or-nil
3508 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3509 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3510 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3512 (setq gnus-tmp-prev-subject nil)
3514 (if (vectorp (car threads))
3515 ;; If this is a straight (sic) list of headers, then a
3516 ;; threaded summary display isn't required, so we just create
3517 ;; an unthreaded one.
3518 (gnus-summary-prepare-unthreaded threads)
3520 ;; Do the threaded display.
3522 (while (or threads stack gnus-tmp-new-adopts new-roots)
3524 (if (and (= gnus-tmp-level 0)
3525 (not (setq gnus-tmp-dummy-line nil))
3528 (not gnus-tmp-false-parent)
3529 (or gnus-tmp-new-adopts new-roots))
3530 (if gnus-tmp-new-adopts
3531 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3532 thread (list (car gnus-tmp-new-adopts))
3533 gnus-tmp-header (caar thread)
3534 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3536 (setq thread (list (car new-roots))
3537 gnus-tmp-header (caar thread)
3538 new-roots (cdr new-roots))))
3541 ;; If there are some threads, we do them before the
3542 ;; threads on the stack.
3543 (setq thread threads
3544 gnus-tmp-header (caar thread))
3545 ;; There were no current threads, so we pop something off
3547 (setq state (car stack)
3548 gnus-tmp-level (car state)
3551 gnus-tmp-header (caar thread))))
3553 (setq gnus-tmp-false-parent nil)
3554 (setq gnus-tmp-root-expunged nil)
3555 (setq thread-end nil)
3557 (if (stringp gnus-tmp-header)
3558 ;; The header is a dummy root.
3560 ((eq gnus-summary-make-false-root 'adopt)
3561 ;; We let the first article adopt the rest.
3562 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3564 (setq gnus-tmp-gathered
3566 (lambda (h) (mail-header-number (car h)))
3569 (setq thread (cons (list (caar thread)
3572 (setq gnus-tmp-level -1
3573 gnus-tmp-false-parent t))
3574 ((eq gnus-summary-make-false-root 'empty)
3575 ;; We print adopted articles with empty subject fields.
3576 (setq gnus-tmp-gathered
3578 (lambda (h) (mail-header-number (car h)))
3581 (setq gnus-tmp-level -1))
3582 ((eq gnus-summary-make-false-root 'dummy)
3583 ;; We remember that we probably want to output a dummy
3585 (setq gnus-tmp-dummy-line gnus-tmp-header)
3586 (setq gnus-tmp-prev-subject gnus-tmp-header))
3588 ;; We do not make a root for the gathered
3589 ;; sub-threads at all.
3590 (setq gnus-tmp-level -1)))
3592 (setq number (mail-header-number gnus-tmp-header)
3593 subject (mail-header-subject gnus-tmp-header))
3596 ;; If the thread has changed subject, we might want to make
3597 ;; this subthread into a root.
3598 ((and (null gnus-thread-ignore-subject)
3599 (not (zerop gnus-tmp-level))
3600 gnus-tmp-prev-subject
3602 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3603 (setq new-roots (nconc new-roots (list (car thread)))
3605 gnus-tmp-header nil))
3606 ;; If the article lies outside the current limit,
3607 ;; then we do not display it.
3608 ((not (memq number gnus-newsgroup-limit))
3609 (setq gnus-tmp-gathered
3611 (lambda (h) (mail-header-number (car h)))
3614 (setq gnus-tmp-new-adopts (if (cdar thread)
3615 (append gnus-tmp-new-adopts
3617 gnus-tmp-new-adopts)
3619 gnus-tmp-header nil)
3620 (when (zerop gnus-tmp-level)
3621 (setq gnus-tmp-root-expunged t)))
3622 ;; Perhaps this article is to be marked as read?
3623 ((and gnus-summary-mark-below
3624 (< (or (cdr (assq number gnus-newsgroup-scored))
3626 gnus-summary-mark-below)
3627 ;; Don't touch sparse articles.
3628 (not (gnus-summary-article-sparse-p number))
3629 (not (gnus-summary-article-ancient-p number)))
3630 (setq gnus-newsgroup-unreads
3631 (delq number gnus-newsgroup-unreads))
3632 (if gnus-newsgroup-auto-expire
3633 (push number gnus-newsgroup-expirable)
3634 (push (cons number gnus-low-score-mark)
3635 gnus-newsgroup-reads))))
3637 (when gnus-tmp-header
3638 ;; We may have an old dummy line to output before this
3640 (when gnus-tmp-dummy-line
3641 (gnus-summary-insert-dummy-line
3642 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3643 (setq gnus-tmp-dummy-line nil))
3645 ;; Compute the mark.
3646 (setq gnus-tmp-unread (gnus-article-mark number))
3648 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3649 gnus-tmp-header gnus-tmp-level)
3650 gnus-newsgroup-data)
3652 ;; Actually insert the line.
3654 gnus-tmp-subject-or-nil
3656 ((and gnus-thread-ignore-subject
3657 gnus-tmp-prev-subject
3658 (not (inline (gnus-subject-equal
3659 gnus-tmp-prev-subject subject))))
3661 ((zerop gnus-tmp-level)
3662 (if (and (eq gnus-summary-make-false-root 'empty)
3663 (memq number gnus-tmp-gathered)
3664 gnus-tmp-prev-subject
3665 (inline (gnus-subject-equal
3666 gnus-tmp-prev-subject subject)))
3667 gnus-summary-same-subject
3669 (t gnus-summary-same-subject)))
3670 (if (and (eq gnus-summary-make-false-root 'adopt)
3671 (= gnus-tmp-level 1)
3672 (memq number gnus-tmp-gathered))
3673 (setq gnus-tmp-opening-bracket ?\<
3674 gnus-tmp-closing-bracket ?\>)
3675 (setq gnus-tmp-opening-bracket ?\[
3676 gnus-tmp-closing-bracket ?\]))
3678 gnus-tmp-indentation
3679 (aref gnus-thread-indent-array gnus-tmp-level)
3680 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3681 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3682 gnus-summary-default-score 0)
3684 (if (or (null gnus-summary-default-score)
3685 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3686 gnus-summary-zcore-fuzz))
3688 (if (< gnus-tmp-score gnus-summary-default-score)
3689 gnus-score-below-mark gnus-score-over-mark))
3691 (cond ((memq number gnus-newsgroup-processable)
3693 ((memq number gnus-newsgroup-cached)
3695 ((memq number gnus-newsgroup-replied)
3697 ((memq number gnus-newsgroup-saved)
3699 (t gnus-unread-mark))
3700 gnus-tmp-from (mail-header-from gnus-tmp-header)
3703 ((string-match "<[^>]+> *$" gnus-tmp-from)
3704 (setq beg-match (match-beginning 0))
3705 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3706 (substring gnus-tmp-from (1+ (match-beginning 0))
3707 (1- (match-end 0))))
3708 (substring gnus-tmp-from 0 beg-match)))
3709 ((string-match "(.+)" gnus-tmp-from)
3710 (substring gnus-tmp-from
3711 (1+ (match-beginning 0)) (1- (match-end 0))))
3713 (when (string= gnus-tmp-name "")
3714 (setq gnus-tmp-name gnus-tmp-from))
3715 (unless (numberp gnus-tmp-lines)
3716 (setq gnus-tmp-lines 0))
3717 (gnus-put-text-property
3719 (progn (eval gnus-summary-line-format-spec) (point))
3720 'gnus-number number)
3723 (run-hooks 'gnus-summary-update-hook)
3726 (setq gnus-tmp-prev-subject subject)))
3728 (when (nth 1 thread)
3729 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3730 (incf gnus-tmp-level)
3731 (setq threads (if thread-end nil (cdar thread)))
3733 (setq gnus-tmp-level 0)))))
3734 (gnus-message 7 "Generating summary...done"))
3736 (defun gnus-summary-prepare-unthreaded (headers)
3737 "Generate an unthreaded summary buffer based on HEADERS."
3738 (let (header number mark)
3743 ;; We may have to root out some bad articles...
3744 (when (memq (setq number (mail-header-number
3745 (setq header (pop headers))))
3746 gnus-newsgroup-limit)
3747 ;; Mark article as read when it has a low score.
3748 (when (and gnus-summary-mark-below
3749 (< (or (cdr (assq number gnus-newsgroup-scored))
3750 gnus-summary-default-score 0)
3751 gnus-summary-mark-below)
3752 (not (gnus-summary-article-ancient-p number)))
3753 (setq gnus-newsgroup-unreads
3754 (delq number gnus-newsgroup-unreads))
3755 (if gnus-newsgroup-auto-expire
3756 (push number gnus-newsgroup-expirable)
3757 (push (cons number gnus-low-score-mark)
3758 gnus-newsgroup-reads)))
3760 (setq mark (gnus-article-mark number))
3761 (push (gnus-data-make number mark (1+ (point)) header 0)
3762 gnus-newsgroup-data)
3763 (gnus-summary-insert-line
3765 mark (memq number gnus-newsgroup-replied)
3766 (memq number gnus-newsgroup-expirable)
3767 (mail-header-subject header) nil
3768 (cdr (assq number gnus-newsgroup-scored))
3769 (memq number gnus-newsgroup-processable))))))
3771 (defun gnus-select-newsgroup (group &optional read-all)
3772 "Select newsgroup GROUP.
3773 If READ-ALL is non-nil, all articles in the group are selected."
3774 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3775 ;;!!! Dirty hack; should be removed.
3776 (gnus-summary-ignore-duplicates
3777 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3779 gnus-summary-ignore-duplicates))
3780 (info (nth 2 entry))
3781 articles fetched-articles cached)
3783 (unless (gnus-check-server
3784 (setq gnus-current-select-method
3785 (gnus-find-method-for-group group)))
3786 (error "Couldn't open server"))
3788 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3789 (gnus-activate-group group) ; Or we can activate it...
3790 (progn ; Or we bug out.
3791 (when (equal major-mode 'gnus-summary-mode)
3792 (kill-buffer (current-buffer)))
3793 (error "Couldn't request group %s: %s"
3794 group (gnus-status-message group))))
3796 (unless (gnus-request-group group t)
3797 (when (equal major-mode 'gnus-summary-mode)
3798 (kill-buffer (current-buffer)))
3799 (error "Couldn't request group %s: %s"
3800 group (gnus-status-message group)))
3802 (setq gnus-newsgroup-name group)
3803 (setq gnus-newsgroup-unselected nil)
3804 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3806 ;; Adjust and set lists of article marks.
3808 (gnus-adjust-marked-articles info))
3810 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3811 (when (gnus-virtual-group-p group)
3812 (setq cached gnus-newsgroup-cached))
3814 (setq gnus-newsgroup-unreads
3815 (gnus-set-difference
3816 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3817 gnus-newsgroup-dormant))
3819 (setq gnus-newsgroup-processable nil)
3821 (gnus-update-read-articles group gnus-newsgroup-unreads)
3822 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
3823 (gnus-group-update-group group))
3825 (setq articles (gnus-articles-to-read group read-all))
3829 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3831 ((eq articles 0) nil)
3833 ;; Init the dependencies hash table.
3834 (setq gnus-newsgroup-dependencies
3835 (gnus-make-hashtable (length articles)))
3836 ;; Retrieve the headers and read them in.
3837 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3838 (setq gnus-newsgroup-headers
3840 (setq gnus-headers-retrieved-by
3841 (gnus-retrieve-headers
3842 articles gnus-newsgroup-name
3843 ;; We might want to fetch old headers, but
3844 ;; not if there is only 1 article.
3845 (and gnus-fetch-old-headers
3847 (not (eq gnus-fetch-old-headers 'some))
3848 (not (numberp gnus-fetch-old-headers)))
3849 (> (length articles) 1))))))
3850 (gnus-get-newsgroup-headers-xover
3851 articles nil nil gnus-newsgroup-name t)
3852 (gnus-get-newsgroup-headers)))
3853 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3855 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3857 (setq gnus-newsgroup-cached cached))
3859 ;; Suppress duplicates?
3860 (when gnus-suppress-duplicates
3861 (gnus-dup-suppress-articles))
3863 ;; Set the initial limit.
3864 (setq gnus-newsgroup-limit (copy-sequence articles))
3865 ;; Remove canceled articles from the list of unread articles.
3866 (setq gnus-newsgroup-unreads
3867 (gnus-set-sorted-intersection
3868 gnus-newsgroup-unreads
3869 (setq fetched-articles
3870 (mapcar (lambda (headers) (mail-header-number headers))
3871 gnus-newsgroup-headers))))
3872 ;; Removed marked articles that do not exist.
3873 (gnus-update-missing-marks
3874 (gnus-sorted-complement fetched-articles articles))
3875 ;; Let the Gnus agent mark articles as read.
3877 (gnus-agent-get-undownloaded-list))
3878 ;; We might want to build some more threads first.
3879 (when (and gnus-fetch-old-headers
3880 (eq gnus-headers-retrieved-by 'nov))
3881 (if (eq gnus-fetch-old-headers 'invisible)
3882 (gnus-build-all-threads)
3883 (gnus-build-old-threads)))
3884 ;; Check whether auto-expire is to be done in this group.
3885 (setq gnus-newsgroup-auto-expire
3886 (gnus-group-auto-expirable-p group))
3887 ;; Set up the article buffer now, if necessary.
3888 (unless gnus-single-article-buffer
3889 (gnus-article-setup-buffer))
3890 ;; First and last article in this newsgroup.
3891 (when gnus-newsgroup-headers
3892 (setq gnus-newsgroup-begin
3893 (mail-header-number (car gnus-newsgroup-headers))
3896 (gnus-last-element gnus-newsgroup-headers))))
3897 ;; GROUP is successfully selected.
3898 (or gnus-newsgroup-headers t)))))
3900 (defun gnus-articles-to-read (group &optional read-all)
3901 ;; Find out what articles the user wants to read.
3903 ;; Select all articles if `read-all' is non-nil, or if there
3904 ;; are no unread articles.
3906 (and (zerop (length gnus-newsgroup-marked))
3907 (zerop (length gnus-newsgroup-unreads)))
3908 (eq (gnus-group-find-parameter group 'display)
3910 (gnus-uncompress-range (gnus-active group))
3911 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3912 (copy-sequence gnus-newsgroup-unreads))
3914 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3915 (scored (length scored-list))
3916 (number (length articles))
3917 (marked (+ (length gnus-newsgroup-marked)
3918 (length gnus-newsgroup-dormant)))
3926 ((and (or (<= scored marked) (= scored number))
3927 (numberp gnus-large-newsgroup)
3928 (> number gnus-large-newsgroup))
3932 "How many articles from %s (default %d): "
3933 (gnus-limit-string gnus-newsgroup-name 35)
3935 (if (string-match "^[ \t]*$" input) number input)))
3936 ((and (> scored marked) (< scored number)
3937 (> (- scored number) 20))
3940 (format "%s %s (%d scored, %d total): "
3941 "How many articles from"
3942 group scored number))))
3943 (if (string-match "^[ \t]*$" input)
3947 (setq select (if (stringp select) (string-to-number select) select))
3948 (if (or (null select) (zerop select))
3950 (if (and (not (zerop scored)) (<= (abs select) scored))
3952 (setq articles (sort scored-list '<))
3953 (setq number (length articles)))
3954 (setq articles (copy-sequence articles)))
3956 (when (< (abs select) number)
3958 ;; Select the N oldest articles.
3959 (setcdr (nthcdr (1- (abs select)) articles) nil)
3960 ;; Select the N most recent articles.
3961 (setq articles (nthcdr (- number select) articles))))
3962 (setq gnus-newsgroup-unselected
3963 (gnus-sorted-intersection
3964 gnus-newsgroup-unreads
3965 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3968 (defun gnus-killed-articles (killed articles)
3971 (when (inline (gnus-member-of-range (car articles) killed))
3972 (push (car articles) out))
3973 (setq articles (cdr articles)))
3976 (defun gnus-uncompress-marks (marks)
3977 "Uncompress the mark ranges in MARKS."
3978 (let ((uncompressed '(score bookmark))
3981 (if (memq (caar marks) uncompressed)
3982 (push (car marks) out)
3983 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3984 (setq marks (cdr marks)))
3987 (defun gnus-adjust-marked-articles (info)
3988 "Set all article lists and remove all marks that are no longer legal."
3989 (let* ((marked-lists (gnus-info-marks info))
3990 (active (gnus-active (gnus-info-group info)))
3993 (types gnus-article-mark-lists)
3994 (uncompressed '(score bookmark killed))
3995 marks var articles article mark)
3998 (setq marks (pop marked-lists))
3999 (set (setq var (intern (format "gnus-newsgroup-%s"
4000 (car (rassq (setq mark (car marks))
4002 (if (memq (car marks) uncompressed) (cdr marks)
4003 (gnus-uncompress-range (cdr marks))))
4005 (setq articles (symbol-value var))
4007 ;; All articles have to be subsets of the active articles.
4009 ;; Adjust "simple" lists.
4010 ((memq mark '(tick dormant expire reply save))
4012 (when (or (< (setq article (pop articles)) min) (> article max))
4013 (set var (delq article (symbol-value var))))))
4015 ((memq mark uncompressed)
4016 (when (not (listp (cdr (symbol-value var))))
4017 (set var (list (symbol-value var))))
4018 (when (not (listp (cdr articles)))
4019 (setq articles (list articles)))
4021 (when (or (not (consp (setq article (pop articles))))
4022 (< (car article) min)
4023 (> (car article) max))
4024 (set var (delq article (symbol-value var))))))))))
4026 (defun gnus-update-missing-marks (missing)
4027 "Go through the list of MISSING articles and remove them from the mark lists."
4029 (let ((types gnus-article-mark-lists)
4031 ;; Go through all types.
4033 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4034 (when (symbol-value var)
4035 ;; This list has articles. So we delete all missing articles
4039 (set var (delq (pop m) (symbol-value var)))))))))
4041 (defun gnus-update-marks ()
4042 "Enter the various lists of marked articles into the newsgroup info list."
4043 (let ((types gnus-article-mark-lists)
4044 (info (gnus-get-info gnus-newsgroup-name))
4045 (uncompressed '(score bookmark killed))
4046 type list newmarked symbol)
4048 ;; Add all marks lists that are non-nil to the list of marks lists.
4049 (while (setq type (pop types))
4050 (when (setq list (symbol-value
4052 (intern (format "gnus-newsgroup-%s"
4055 ;; Get rid of the entries of the articles that have the
4057 (when (and (eq (cdr type) 'score)
4061 (prev (cons nil list))
4064 (if (or (not (consp (car arts)))
4065 (= (cdar arts) gnus-summary-default-score))
4066 (setcdr prev (cdr arts))
4068 (setq arts (cdr arts)))
4069 (setq list (cdr all))))
4071 (push (cons (cdr type)
4072 (if (memq (cdr type) uncompressed) list
4073 (gnus-compress-sequence
4074 (set symbol (sort list '<)) t)))
4077 ;; Enter these new marks into the info of the group.
4079 (setcar (nthcdr 3 info) newmarked)
4080 ;; Add the marks lists to the end of the info.
4082 (setcdr (nthcdr 2 info) (list newmarked))))
4084 ;; Cut off the end of the info if there's nothing else there.
4088 (when (nthcdr (decf i) info)
4089 (setcdr (nthcdr i info) nil)))))))
4091 (defun gnus-set-mode-line (where)
4092 "This function sets the mode line of the article or summary buffers.
4093 If WHERE is `summary', the summary mode line format will be used."
4094 ;; Is this mode line one we keep updated?
4095 (when (memq where gnus-updated-mode-lines)
4098 ;; We evaluate this in the summary buffer since these
4099 ;; variables are buffer-local to that buffer.
4100 (set-buffer gnus-summary-buffer)
4101 ;; We bind all these variables that are used in the `eval' form
4103 (let* ((mformat (symbol-value
4105 (format "gnus-%s-mode-line-format-spec" where))))
4106 (gnus-tmp-group-name gnus-newsgroup-name)
4107 (gnus-tmp-article-number (or gnus-current-article 0))
4108 (gnus-tmp-unread gnus-newsgroup-unreads)
4109 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4110 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4111 (gnus-tmp-unread-and-unselected
4112 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4113 (zerop gnus-tmp-unselected))
4115 ((zerop gnus-tmp-unselected)
4116 (format "{%d more}" gnus-tmp-unread-and-unticked))
4117 (t (format "{%d(+%d) more}"
4118 gnus-tmp-unread-and-unticked
4119 gnus-tmp-unselected))))
4121 (if (and gnus-current-headers
4122 (vectorp gnus-current-headers))
4123 (gnus-mode-string-quote
4124 (mail-header-subject gnus-current-headers))
4126 bufname-length max-len
4127 gnus-tmp-header);; passed as argument to any user-format-funcs
4128 (setq mode-string (eval mformat))
4129 (setq bufname-length (if (string-match "%b" mode-string)
4132 (if (eq where 'summary)
4134 (get-buffer gnus-article-buffer))))
4137 (setq max-len (max 4 (if gnus-mode-non-string-length
4139 gnus-mode-non-string-length
4141 (length mode-string))))
4142 ;; We might have to chop a bit of the string off...
4143 (when (> (length mode-string) max-len)
4145 (concat (gnus-truncate-string mode-string (- max-len 3))
4147 ;; Pad the mode string a bit.
4148 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4149 ;; Update the mode line.
4150 (setq mode-line-buffer-identification
4151 (gnus-mode-line-buffer-identification (list mode-string)))
4152 (set-buffer-modified-p t))))
4154 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4155 "Go through the HEADERS list and add all Xrefs to a hash table.
4156 The resulting hash table is returned, or nil if no Xrefs were found."
4157 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4158 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4159 (xref-hashtb (gnus-make-hashtable))
4160 start group entry number xrefs header)
4162 (setq header (pop headers))
4163 (when (and (setq xrefs (mail-header-xref header))
4164 (not (memq (setq number (mail-header-number header))
4167 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4168 (setq start (match-end 0))
4169 (setq group (if prefix
4170 (concat prefix (substring xrefs (match-beginning 1)
4172 (substring xrefs (match-beginning 1) (match-end 1))))
4174 (string-to-int (substring xrefs (match-beginning 2)
4176 (if (setq entry (gnus-gethash group xref-hashtb))
4177 (setcdr entry (cons number (cdr entry)))
4178 (gnus-sethash group (cons number nil) xref-hashtb)))))
4179 (and start xref-hashtb)))
4181 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4182 "Look through all the headers and mark the Xrefs as read."
4183 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4184 name entry info xref-hashtb idlist method nth4)
4186 (set-buffer gnus-group-buffer)
4187 (when (setq xref-hashtb
4188 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4191 (unless (string= from-newsgroup (setq name (symbol-name group)))
4192 (setq idlist (symbol-value group))
4193 ;; Dead groups are not updated.
4195 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4197 (when (stringp (setq nth4 (gnus-info-method info)))
4198 (setq nth4 (gnus-server-to-method nth4))))
4199 ;; Only do the xrefs if the group has the same
4200 ;; select method as the group we have just read.
4201 (or (gnus-methods-equal-p
4202 nth4 (gnus-find-method-for-group from-newsgroup))
4204 (equal nth4 (setq method (gnus-find-method-for-group
4206 (and (equal (car nth4) (car method))
4207 (equal (nth 1 nth4) (nth 1 method))))
4208 gnus-use-cross-reference
4209 (or (not (eq gnus-use-cross-reference t))
4211 ;; Only do cross-references on subscribed
4212 ;; groups, if that is what is wanted.
4213 (<= (gnus-info-level info) gnus-level-subscribed))
4214 (gnus-group-make-articles-read name idlist))))
4217 (defun gnus-compute-read-articles (group articles)
4218 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4219 (info (nth 2 entry))
4220 (active (gnus-active group))
4223 ;; First peel off all illegal article numbers.
4225 (let ((ids articles)
4227 (while (setq id (pop ids))
4228 (when (and first (> id (cdr active)))
4229 ;; We'll end up in this situation in one particular
4230 ;; obscure situation. If you re-scan a group and get
4231 ;; a new article that is cross-posted to a different
4232 ;; group that has not been re-scanned, you might get
4233 ;; crossposted article that has a higher number than
4234 ;; Gnus believes possible. So we re-activate this
4235 ;; group as well. This might mean doing the
4236 ;; crossposting thingy will *increase* the number
4237 ;; of articles in some groups. Tsk, tsk.
4238 (setq active (or (gnus-activate-group group) active)))
4239 (when (or (> id (cdr active))
4240 (< id (car active)))
4241 (setq articles (delq id articles))))))
4242 ;; If the read list is nil, we init it.
4244 (null (gnus-info-read info))
4246 (setq ninfo (cons 1 (1- (car active))))
4247 (setq ninfo (gnus-info-read info)))
4248 ;; Then we add the read articles to the range.
4250 ninfo (setq articles (sort articles '<))))))
4252 (defun gnus-group-make-articles-read (group articles)
4253 "Update the info of GROUP to say that ARTICLES are read."
4255 (entry (gnus-gethash group gnus-newsrc-hashtb))
4256 (info (nth 2 entry))
4257 (active (gnus-active group))
4260 (setq range (gnus-compute-read-articles group articles))
4262 (set-buffer gnus-group-buffer)
4265 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4266 (gnus-info-set-read ',info ',(gnus-info-read info))
4267 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4268 (gnus-group-update-group ,group t))))
4269 ;; Add the read articles to the range.
4270 (gnus-info-set-read info range)
4271 ;; Then we have to re-compute how many unread
4272 ;; articles there are in this group.
4276 (setq num (- (1+ (cdr active)) (car active))))
4277 ((not (listp (cdr range)))
4278 (setq num (- (cdr active) (- (1+ (cdr range))
4282 (if (numberp (car range))
4284 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4285 (setq range (cdr range)))
4286 (setq num (- (cdr active) num))))
4287 ;; Update the number of unread articles.
4289 ;; Update the group buffer.
4290 (gnus-group-update-group group t)))))
4292 (defun gnus-methods-equal-p (m1 m2)
4293 (let ((m1 (or m1 gnus-select-method))
4294 (m2 (or m2 gnus-select-method)))
4296 (and (eq (car m1) (car m2))
4297 (or (not (memq 'address (assoc (symbol-name (car m1))
4298 gnus-valid-select-methods)))
4299 (equal (nth 1 m1) (nth 1 m2)))))))
4301 (defvar gnus-newsgroup-none-id 0)
4303 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4304 (let ((cur nntp-server-buffer)
4307 (save-excursion (set-buffer gnus-summary-buffer)
4308 gnus-newsgroup-dependencies)))
4309 headers id id-dep ref-dep end ref)
4311 (set-buffer nntp-server-buffer)
4312 ;; Translate all TAB characters into SPACE characters.
4313 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4314 (run-hooks 'gnus-parse-headers-hook)
4315 (let ((case-fold-search t)
4316 in-reply-to header p lines)
4317 (goto-char (point-min))
4318 ;; Search to the beginning of the next header. Error messages
4319 ;; do not begin with 2 or 3.
4320 (while (re-search-forward "^[23][0-9]+ " nil t)
4323 ;; This implementation of this function, with nine
4324 ;; search-forwards instead of the one re-search-forward and
4325 ;; a case (which basically was the old function) is actually
4326 ;; about twice as fast, even though it looks messier. You
4327 ;; can't have everything, I guess. Speed and elegance
4328 ;; doesn't always go hand in hand.
4337 (narrow-to-region (point)
4338 (or (and (search-forward "\n.\n" nil t)
4344 (if (search-forward "\nsubject: " nil t)
4345 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4347 gnus-unstructured-field-decoder (nnheader-header-value))
4352 (if (search-forward "\nfrom: " nil t)
4353 ;; 1997/5/4 by MORIOKA Tomohiko <morioka@jaist.ac.jp>
4355 gnus-structured-field-decoder (nnheader-header-value))
4360 (if (search-forward "\ndate: " nil t)
4361 (nnheader-header-value) ""))
4365 (setq id (if (search-forward "\nmessage-id:" nil t)
4367 (1- (or (search-forward "<" nil t) (point)))
4368 (or (search-forward ">" nil t) (point)))
4369 ;; If there was no message-id, we just fake one
4370 ;; to make subsequent routines simpler.
4371 (nnheader-generate-fake-message-id))))
4375 (if (search-forward "\nreferences: " nil t)
4379 (nnheader-header-value)
4384 (search-backward ">" end t)
4387 (search-backward "<" end t)
4389 ;; Get the references from the in-reply-to header if there
4390 ;; were no references and the in-reply-to header looks
4392 (if (and (search-forward "\nin-reply-to: " nil t)
4393 (setq in-reply-to (nnheader-header-value))
4394 (string-match "<[^>]+>" in-reply-to))
4396 (setq ref (substring in-reply-to (match-beginning 0)
4398 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4399 (setq ref2 (substring in-reply-to (match-beginning 0)
4401 (when (> (length ref2) (length ref))
4409 (if (search-forward "\nlines: " nil t)
4410 (if (numberp (setq lines (ignore-errors (read cur))))
4416 (and (search-forward "\nxref: " nil t)
4417 (nnheader-header-value)))))
4418 (when (equal id ref)
4421 (when gnus-alter-header-function
4422 (funcall gnus-alter-header-function header)
4423 (setq id (mail-header-id header)
4424 ref (gnus-parent-id (mail-header-references header))))
4426 ;; We do the threading while we read the headers. The
4427 ;; message-id and the last reference are both entered into
4428 ;; the same hash table. Some tippy-toeing around has to be
4429 ;; done in case an article has arrived before the article
4430 ;; which it refers to.
4431 (if (boundp (setq id-dep (intern id dependencies)))
4432 (if (and (car (symbol-value id-dep))
4434 ;; An article with this Message-ID has already been seen.
4435 (if gnus-summary-ignore-duplicates
4436 ;; We ignore this one, except we add
4437 ;; any additional Xrefs (in case the two articles
4438 ;; came from different servers).
4440 (mail-header-set-xref
4441 (car (symbol-value id-dep))
4442 (concat (or (mail-header-xref
4443 (car (symbol-value id-dep)))
4445 (or (mail-header-xref header) "")))
4447 ;; We rename the Message-ID.
4449 (setq id-dep (intern (setq id (nnmail-message-id))
4452 (mail-header-set-id header id))
4453 (setcar (symbol-value id-dep) header))
4454 (set id-dep (list header)))
4456 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4457 (setcdr (symbol-value ref-dep)
4458 (nconc (cdr (symbol-value ref-dep))
4459 (list (symbol-value id-dep))))
4460 (set ref-dep (list nil (symbol-value id-dep))))
4461 (push header headers))
4462 (goto-char (point-max))
4464 (nreverse headers)))))
4466 ;; The following macros and functions were written by Felix Lee
4467 ;; <flee@cse.psu.edu>.
4469 (defmacro gnus-nov-read-integer ()
4471 (if (= (following-char) ?\t)
4473 (let ((num (ignore-errors (read buffer))))
4474 (if (numberp num) num 0)))
4476 (search-forward "\t" eol 'move))))
4478 (defmacro gnus-nov-skip-field ()
4479 '(search-forward "\t" eol 'move))
4481 (defmacro gnus-nov-field ()
4482 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4484 ;; (defvar gnus-nov-none-counter 0)
4486 ;; This function has to be called with point after the article number
4487 ;; on the beginning of the line.
4488 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4489 (let ((eol (gnus-point-at-eol))
4490 (buffer (current-buffer))
4491 header ref id id-dep ref-dep)
4493 ;; overview: [num subject from date id refs chars lines misc]
4496 (narrow-to-region (point) eol)
4504 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
4506 gnus-structured-field-decoder (gnus-nov-field)) ; from
4507 (gnus-nov-field) ; date
4508 (setq id (or (gnus-nov-field)
4509 (nnheader-generate-fake-message-id))) ; id
4511 (let ((beg (point)))
4512 (search-forward "\t" eol)
4513 (if (search-backward ">" beg t)
4517 (search-backward "<" beg t)))
4520 (gnus-nov-field)) ; refs
4521 (gnus-nov-read-integer) ; chars
4522 (gnus-nov-read-integer) ; lines
4523 (if (= (following-char) ?\n)
4525 (gnus-nov-field))))) ; misc
4529 (when gnus-alter-header-function
4530 (funcall gnus-alter-header-function header)
4531 (setq id (mail-header-id header)
4532 ref (gnus-parent-id (mail-header-references header))))
4534 ;; We build the thread tree.
4535 (when (equal id ref)
4536 ;; This article refers back to itself. Naughty, naughty.
4538 (if (boundp (setq id-dep (intern id dependencies)))
4539 (if (and (car (symbol-value id-dep))
4541 ;; An article with this Message-ID has already been seen.
4542 (if gnus-summary-ignore-duplicates
4543 ;; We ignore this one, except we add any additional
4544 ;; Xrefs (in case the two articles came from different
4547 (mail-header-set-xref
4548 (car (symbol-value id-dep))
4549 (concat (or (mail-header-xref
4550 (car (symbol-value id-dep)))
4552 (or (mail-header-xref header) "")))
4554 ;; We rename the Message-ID.
4556 (setq id-dep (intern (setq id (nnmail-message-id))
4559 (mail-header-set-id header id))
4560 (setcar (symbol-value id-dep) header))
4561 (set id-dep (list header)))
4563 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4564 (setcdr (symbol-value ref-dep)
4565 (nconc (cdr (symbol-value ref-dep))
4566 (list (symbol-value id-dep))))
4567 (set ref-dep (list nil (symbol-value id-dep)))))
4570 ;; Goes through the xover lines and returns a list of vectors
4571 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4572 force-new dependencies
4573 group also-fetch-heads)
4574 "Parse the news overview data in the server buffer, and return a
4575 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4576 ;; Get the Xref when the users reads the articles since most/some
4577 ;; NNTP servers do not include Xrefs when using XOVER.
4578 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4579 (let ((cur nntp-server-buffer)
4580 (dependencies (or dependencies gnus-newsgroup-dependencies))
4581 number headers header)
4583 (set-buffer nntp-server-buffer)
4584 ;; Allow the user to mangle the headers before parsing them.
4585 (run-hooks 'gnus-parse-headers-hook)
4586 (goto-char (point-min))
4589 (while (and sequence (not (eobp)))
4590 (setq number (read cur))
4591 (while (and sequence
4592 (< (car sequence) number))
4593 (setq sequence (cdr sequence)))
4595 (eq number (car sequence))
4597 (setq sequence (cdr sequence))
4598 (setq header (inline
4599 (gnus-nov-parse-line
4600 number dependencies force-new))))
4601 (push header headers))
4604 (gnus-error 4 "Strange nov line (%d)"
4605 (count-lines (point-min) (point)))))
4607 ;; A common bug in inn is that if you have posted an article and
4608 ;; then retrieves the active file, it will answer correctly --
4609 ;; the new article is included. However, a NOV entry for the
4610 ;; article may not have been generated yet, so this may fail.
4611 ;; We work around this problem by retrieving the last few
4612 ;; headers using HEAD.
4613 (if (or (not also-fetch-heads)
4615 ;; We (probably) got all the headers.
4617 (let ((gnus-nov-is-evil t))
4620 (when (gnus-retrieve-headers sequence group)
4621 (gnus-get-newsgroup-headers))))))))
4623 (defun gnus-article-get-xrefs ()
4624 "Fill in the Xref value in `gnus-current-headers', if necessary.
4625 This is meant to be called in `gnus-article-internal-prepare-hook'."
4626 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4627 gnus-current-headers)))
4628 (or (not gnus-use-cross-reference)
4630 (and (mail-header-xref headers)
4631 (not (string= (mail-header-xref headers) "")))
4632 (let ((case-fold-search t)
4635 (nnheader-narrow-to-headers)
4636 (goto-char (point-min))
4637 (when (or (and (eq (downcase (following-char)) ?x)
4638 (looking-at "Xref:"))
4639 (search-forward "\nXref:" nil t))
4640 (goto-char (1+ (match-end 0)))
4641 (setq xref (buffer-substring (point)
4642 (progn (end-of-line) (point))))
4643 (mail-header-set-xref headers xref)))))))
4645 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4646 "Find article ID and insert the summary line for that article."
4647 (let ((header (if (and old-header use-old-header)
4648 old-header (gnus-read-header id)))
4649 (number (and (numberp id) id))
4652 ;; Rebuild the thread that this article is part of and go to the
4653 ;; article we have fetched.
4654 (when (and (not gnus-show-threads)
4656 (when (setq d (gnus-data-find (mail-header-number old-header)))
4657 (goto-char (gnus-data-pos d))
4660 (- (gnus-point-at-bol)
4662 (1+ (gnus-point-at-eol))
4663 (gnus-delete-line))))))
4665 (mail-header-set-number header (mail-header-number old-header)))
4666 (setq gnus-newsgroup-sparse
4667 (delq (setq number (mail-header-number header))
4668 gnus-newsgroup-sparse))
4669 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4670 (gnus-rebuild-thread (mail-header-id header))
4671 (gnus-summary-goto-subject number nil t))
4672 (when (and (numberp number)
4674 ;; We have to update the boundaries even if we can't fetch the
4675 ;; article if ID is a number -- so that the next `P' or `N'
4676 ;; command will fetch the previous (or next) article even
4677 ;; if the one we tried to fetch this time has been canceled.
4678 (when (> number gnus-newsgroup-end)
4679 (setq gnus-newsgroup-end number))
4680 (when (< number gnus-newsgroup-begin)
4681 (setq gnus-newsgroup-begin number))
4682 (setq gnus-newsgroup-unselected
4683 (delq number gnus-newsgroup-unselected)))
4684 ;; Report back a success?
4685 (and header (mail-header-number header))))
4687 ;;; Process/prefix in the summary buffer
4689 (defun gnus-summary-work-articles (n)
4690 "Return a list of articles to be worked upon. The prefix argument,
4691 the list of process marked articles, and the current article will be
4692 taken into consideration."
4695 ;; A numerical prefix has been given.
4696 (setq n (prefix-numeric-value n))
4697 (let ((backward (< n 0))
4698 (n (abs (prefix-numeric-value n)))
4703 (push (setq article (gnus-summary-article-number))
4706 (gnus-summary-find-prev nil article)
4707 (gnus-summary-find-next nil article)))
4709 (nreverse articles)))
4710 ((gnus-region-active-p)
4711 ;; Work on the region between point and mark.
4712 (let ((max (max (point) (mark)))
4715 (goto-char (min (point) (mark)))
4718 (push (setq article (gnus-summary-article-number)) articles)
4719 (gnus-summary-find-next nil article)
4721 (nreverse articles))))
4722 (gnus-newsgroup-processable
4723 ;; There are process-marked articles present.
4724 ;; Save current state.
4725 (gnus-summary-save-process-mark)
4727 (reverse gnus-newsgroup-processable))
4729 ;; Just return the current article.
4730 (list (gnus-summary-article-number)))))
4732 (defun gnus-summary-save-process-mark ()
4733 "Push the current set of process marked articles on the stack."
4735 (push (copy-sequence gnus-newsgroup-processable)
4736 gnus-newsgroup-process-stack))
4738 (defun gnus-summary-kill-process-mark ()
4739 "Push the current set of process marked articles on the stack and unmark."
4741 (gnus-summary-save-process-mark)
4742 (gnus-summary-unmark-all-processable))
4744 (defun gnus-summary-yank-process-mark ()
4745 "Pop the last process mark state off the stack and restore it."
4747 (unless gnus-newsgroup-process-stack
4748 (error "Empty mark stack"))
4749 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4751 (defun gnus-summary-process-mark-set (set)
4752 "Make SET into the current process marked articles."
4753 (gnus-summary-unmark-all-processable)
4755 (gnus-summary-set-process-mark (pop set))))
4757 ;;; Searching and stuff
4759 (defun gnus-summary-search-group (&optional backward use-level)
4760 "Search for next unread newsgroup.
4761 If optional argument BACKWARD is non-nil, search backward instead."
4763 (set-buffer gnus-group-buffer)
4764 (when (gnus-group-search-forward
4765 backward nil (if use-level (gnus-group-group-level) nil))
4766 (gnus-group-group-name))))
4768 (defun gnus-summary-best-group (&optional exclude-group)
4769 "Find the name of the best unread group.
4770 If EXCLUDE-GROUP, do not go to this group."
4772 (set-buffer gnus-group-buffer)
4774 (gnus-group-best-unread-group exclude-group))))
4776 (defun gnus-summary-find-next (&optional unread article backward)
4777 (if backward (gnus-summary-find-prev)
4778 (let* ((dummy (gnus-summary-article-intangible-p))
4779 (article (or article (gnus-summary-article-number)))
4780 (arts (gnus-data-find-list article))
4782 (when (and (not dummy)
4783 (or (not gnus-summary-check-current)
4785 (not (gnus-data-unread-p (car arts)))))
4786 (setq arts (cdr arts)))
4791 (when (gnus-data-unread-p (car arts))
4792 (setq result (car arts)
4794 (setq arts (cdr arts)))
4797 (goto-char (gnus-data-pos result))
4798 (gnus-data-number result)))))
4800 (defun gnus-summary-find-prev (&optional unread article)
4801 (let* ((eobp (eobp))
4802 (article (or article (gnus-summary-article-number)))
4803 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4805 (when (and (not eobp)
4806 (or (not gnus-summary-check-current)
4808 (not (gnus-data-unread-p (car arts)))))
4809 (setq arts (cdr arts)))
4814 (when (gnus-data-unread-p (car arts))
4815 (setq result (car arts)
4817 (setq arts (cdr arts)))
4820 (goto-char (gnus-data-pos result))
4821 (gnus-data-number result))))
4823 (defun gnus-summary-find-subject (subject &optional unread backward article)
4824 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4825 (article (or article (gnus-summary-article-number)))
4826 (articles (gnus-data-list backward))
4827 (arts (gnus-data-find-list article articles))
4829 (when (or (not gnus-summary-check-current)
4831 (not (gnus-data-unread-p (car arts))))
4832 (setq arts (cdr arts)))
4834 (and (or (not unread)
4835 (gnus-data-unread-p (car arts)))
4836 (vectorp (gnus-data-header (car arts)))
4838 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4839 (setq result (car arts)
4841 (setq arts (cdr arts)))
4843 (goto-char (gnus-data-pos result))
4844 (gnus-data-number result))))
4846 (defun gnus-summary-search-forward (&optional unread subject backward)
4847 "Search forward for an article.
4848 If UNREAD, look for unread articles. If SUBJECT, look for
4849 articles with that subject. If BACKWARD, search backward instead."
4850 (cond (subject (gnus-summary-find-subject subject unread backward))
4851 (backward (gnus-summary-find-prev unread))
4852 (t (gnus-summary-find-next unread))))
4854 (defun gnus-recenter (&optional n)
4855 "Center point in window and redisplay frame.
4856 Also do horizontal recentering."
4858 (when (and gnus-auto-center-summary
4859 (not (eq gnus-auto-center-summary 'vertical)))
4860 (gnus-horizontal-recenter))
4863 (defun gnus-summary-recenter ()
4864 "Center point in the summary window.
4865 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4866 displayed, no centering will be performed."
4867 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4868 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4869 (let* ((top (cond ((< (window-height) 4) 0)
4870 ((< (window-height) 7) 1)
4872 (height (1- (window-height)))
4873 (bottom (save-excursion (goto-char (point-max))
4874 (forward-line (- height))
4876 (window (get-buffer-window (current-buffer))))
4877 ;; The user has to want it.
4878 (when gnus-auto-center-summary
4879 (when (get-buffer-window gnus-article-buffer)
4880 ;; Only do recentering when the article buffer is displayed,
4881 ;; Set the window start to either `bottom', which is the biggest
4882 ;; possible valid number, or the second line from the top,
4883 ;; whichever is the least.
4885 window (min bottom (save-excursion
4886 (forward-line (- top)) (point)))))
4887 ;; Do horizontal recentering while we're at it.
4888 (when (and (get-buffer-window (current-buffer) t)
4889 (not (eq gnus-auto-center-summary 'vertical)))
4890 (let ((selected (selected-window)))
4891 (select-window (get-buffer-window (current-buffer) t))
4892 (gnus-summary-position-point)
4893 (gnus-horizontal-recenter)
4894 (select-window selected))))))
4896 (defun gnus-summary-jump-to-group (newsgroup)
4897 "Move point to NEWSGROUP in group mode buffer."
4898 ;; Keep update point of group mode buffer if visible.
4899 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4900 (save-window-excursion
4901 ;; Take care of tree window mode.
4902 (when (get-buffer-window gnus-group-buffer)
4903 (pop-to-buffer gnus-group-buffer))
4904 (gnus-group-jump-to-group newsgroup))
4906 ;; Take care of tree window mode.
4907 (if (get-buffer-window gnus-group-buffer)
4908 (pop-to-buffer gnus-group-buffer)
4909 (set-buffer gnus-group-buffer))
4910 (gnus-group-jump-to-group newsgroup))))
4912 ;; This function returns a list of article numbers based on the
4913 ;; difference between the ranges of read articles in this group and
4914 ;; the range of active articles.
4915 (defun gnus-list-of-unread-articles (group)
4916 (let* ((read (gnus-info-read (gnus-get-info group)))
4917 (active (or (gnus-active group) (gnus-activate-group group)))
4920 ;; If none are read, then all are unread.
4922 (setq first (car active))
4923 ;; If the range of read articles is a single range, then the
4924 ;; first unread article is the article after the last read
4925 ;; article. Sounds logical, doesn't it?
4926 (if (not (listp (cdr read)))
4927 (setq first (1+ (cdr read)))
4928 ;; `read' is a list of ranges.
4929 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4935 (while (< first nlast)
4937 (setq first (1+ first))))
4938 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4939 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4940 (setq read (cdr read)))))
4941 ;; And add the last unread articles.
4942 (while (<= first last)
4944 (setq first (1+ first)))
4945 ;; Return the list of unread articles.
4946 (delq 0 (nreverse unread))))
4948 (defun gnus-list-of-read-articles (group)
4949 "Return a list of unread, unticked and non-dormant articles."
4950 (let* ((info (gnus-get-info group))
4951 (marked (gnus-info-marks info))
4952 (active (gnus-active group)))
4954 (gnus-set-difference
4955 (gnus-sorted-complement
4956 (gnus-uncompress-range active)
4957 (gnus-list-of-unread-articles group))
4959 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4960 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4962 ;; Various summary commands
4964 (defun gnus-summary-select-article-buffer ()
4965 "Reconfigure windows to show article buffer."
4967 (if (not (gnus-buffer-live-p gnus-article-buffer))
4968 (error "There is no article buffer for this summary buffer")
4969 (gnus-configure-windows 'article)
4970 (select-window (get-buffer-window gnus-article-buffer))))
4972 (defun gnus-summary-universal-argument (arg)
4973 "Perform any operation on all articles that are process/prefixed."
4975 (let ((articles (gnus-summary-work-articles arg))
4982 (substitute-command-keys
4983 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4986 (gnus-error 1 "Undefined key")
4989 (gnus-summary-goto-subject (setq article (pop articles)))
4990 (let (gnus-newsgroup-processable)
4991 (command-execute func))
4992 (gnus-summary-remove-process-mark article)))))
4993 (gnus-summary-position-point))
4995 (defun gnus-summary-toggle-truncation (&optional arg)
4996 "Toggle truncation of summary lines.
4997 With arg, turn line truncation on iff arg is positive."
4999 (setq truncate-lines
5000 (if (null arg) (not truncate-lines)
5001 (> (prefix-numeric-value arg) 0)))
5004 (defun gnus-summary-reselect-current-group (&optional all rescan)
5005 "Exit and then reselect the current newsgroup.
5006 The prefix argument ALL means to select all articles."
5008 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5009 (error "Ephemeral groups can't be reselected"))
5010 (let ((current-subject (gnus-summary-article-number))
5011 (group gnus-newsgroup-name))
5012 (setq gnus-newsgroup-begin nil)
5014 ;; We have to adjust the point of group mode buffer because
5015 ;; point was moved to the next unread newsgroup by exiting.
5016 (gnus-summary-jump-to-group group)
5019 (gnus-group-get-new-news-this-group 1)))
5020 (gnus-group-read-group all t)
5021 (gnus-summary-goto-subject current-subject nil t)))
5023 (defun gnus-summary-rescan-group (&optional all)
5024 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5026 (gnus-summary-reselect-current-group all t))
5028 (defun gnus-summary-update-info (&optional non-destructive)
5030 (let ((group gnus-newsgroup-name))
5032 (when gnus-newsgroup-kill-headers
5033 (setq gnus-newsgroup-killed
5034 (gnus-compress-sequence
5036 (gnus-set-sorted-intersection
5037 (gnus-uncompress-range gnus-newsgroup-killed)
5038 (setq gnus-newsgroup-unselected
5039 (sort gnus-newsgroup-unselected '<)))
5040 (setq gnus-newsgroup-unreads
5041 (sort gnus-newsgroup-unreads '<)))
5043 (unless (listp (cdr gnus-newsgroup-killed))
5044 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5045 (let ((headers gnus-newsgroup-headers))
5046 (when (and (not gnus-save-score)
5047 (not non-destructive))
5048 (setq gnus-newsgroup-scored nil))
5049 ;; Set the new ranges of read articles.
5051 (set-buffer gnus-group-buffer)
5052 (gnus-undo-force-boundary))
5053 (gnus-update-read-articles
5054 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5055 ;; Set the current article marks.
5057 ;; Do the cross-ref thing.
5058 (when gnus-use-cross-reference
5059 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5060 ;; Do not switch windows but change the buffer to work.
5061 (set-buffer gnus-group-buffer)
5062 (unless (gnus-ephemeral-group-p group)
5063 (gnus-group-update-group group)))))))
5065 (defun gnus-summary-save-newsrc (&optional force)
5066 "Save the current number of read/marked articles in the dribble buffer.
5067 The dribble buffer will then be saved.
5068 If FORCE (the prefix), also save the .newsrc file(s)."
5070 (gnus-summary-update-info t)
5072 (gnus-save-newsrc-file)
5073 (gnus-dribble-save)))
5075 (defun gnus-summary-exit (&optional temporary)
5076 "Exit reading current newsgroup, and then return to group selection mode.
5077 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5079 (gnus-kill-save-kill-buffer)
5080 (let* ((group gnus-newsgroup-name)
5081 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5084 (buf (current-buffer)))
5085 (run-hooks 'gnus-summary-prepare-exit-hook)
5086 ;; If we have several article buffers, we kill them at exit.
5087 (unless gnus-single-article-buffer
5088 (gnus-kill-buffer gnus-original-article-buffer)
5089 (setq gnus-article-current nil))
5090 (when gnus-use-cache
5091 (gnus-cache-possibly-remove-articles)
5092 (gnus-cache-save-buffers))
5093 (gnus-async-prefetch-remove-group group)
5094 (when gnus-suppress-duplicates
5095 (gnus-dup-enter-articles))
5096 (when gnus-use-trees
5097 (gnus-tree-close group))
5098 ;; Remove entries for this group.
5099 (nnmail-purge-split-history group)
5100 ;; Make all changes in this group permanent.
5102 (run-hooks 'gnus-exit-group-hook)
5103 (gnus-summary-update-info)
5104 ;; Do adaptive scoring, and possibly save score files.
5105 (when gnus-newsgroup-adaptive
5106 (gnus-score-adaptive))
5107 (when gnus-use-scoring
5109 (gnus-close-group group)
5110 ;; Make sure where we were, and go to next newsgroup.
5111 (set-buffer gnus-group-buffer)
5113 (gnus-group-jump-to-group group))
5114 (run-hooks 'gnus-summary-exit-hook)
5115 (unless (or quit-config
5116 ;; If this group has disappeared from the summary
5117 ;; buffer, don't skip forwards.
5118 (not (string= group (gnus-group-group-name))))
5119 (gnus-group-next-unread-group 1))
5120 (setq group-point (point))
5123 ;; If we have several article buffers, we kill them at exit.
5124 (unless gnus-single-article-buffer
5125 (gnus-kill-buffer gnus-article-buffer)
5126 (gnus-kill-buffer gnus-original-article-buffer)
5127 (setq gnus-article-current nil))
5129 (if (not gnus-kill-summary-on-exit)
5130 (gnus-deaden-summary)
5131 ;; We set all buffer-local variables to nil. It is unclear why
5132 ;; this is needed, but if we don't, buffer-local variables are
5133 ;; not garbage-collected, it seems. This would the lead to en
5134 ;; ever-growing Emacs.
5135 (gnus-summary-clear-local-variables)
5136 (when (get-buffer gnus-article-buffer)
5137 (bury-buffer gnus-article-buffer))
5138 ;; We clear the global counterparts of the buffer-local
5139 ;; variables as well, just to be on the safe side.
5140 (set-buffer gnus-group-buffer)
5141 (gnus-summary-clear-local-variables)
5142 ;; Return to group mode buffer.
5143 (when (eq mode 'gnus-summary-mode)
5144 (gnus-kill-buffer buf)))
5145 (setq gnus-current-select-method gnus-select-method)
5146 (pop-to-buffer gnus-group-buffer)
5147 ;; Clear the current group name.
5148 (if (not quit-config)
5150 (goto-char group-point)
5151 (gnus-configure-windows 'group 'force))
5152 (gnus-handle-ephemeral-exit quit-config))
5154 (setq gnus-newsgroup-name nil)))))
5156 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5157 (defun gnus-summary-exit-no-update (&optional no-questions)
5158 "Quit reading current newsgroup without updating read article info."
5160 (let* ((group gnus-newsgroup-name)
5161 (quit-config (gnus-group-quit-config group)))
5162 (when (or no-questions
5164 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5165 ;; If we have several article buffers, we kill them at exit.
5166 (unless gnus-single-article-buffer
5167 (gnus-kill-buffer gnus-article-buffer)
5168 (gnus-kill-buffer gnus-original-article-buffer)
5169 (setq gnus-article-current nil))
5170 (if (not gnus-kill-summary-on-exit)
5171 (gnus-deaden-summary)
5172 (gnus-close-group group)
5173 (gnus-summary-clear-local-variables)
5174 (set-buffer gnus-group-buffer)
5175 (gnus-summary-clear-local-variables)
5176 (when (get-buffer gnus-summary-buffer)
5177 (kill-buffer gnus-summary-buffer)))
5178 (unless gnus-single-article-buffer
5179 (setq gnus-article-current nil))
5180 (when gnus-use-trees
5181 (gnus-tree-close group))
5182 (gnus-async-prefetch-remove-group group)
5183 (when (get-buffer gnus-article-buffer)
5184 (bury-buffer gnus-article-buffer))
5185 ;; Return to the group buffer.
5186 (gnus-configure-windows 'group 'force)
5187 ;; Clear the current group name.
5188 (setq gnus-newsgroup-name nil)
5189 (when (equal (gnus-group-group-name) group)
5190 (gnus-group-next-unread-group 1))
5192 (gnus-handle-ephemeral-exit quit-config)))))
5194 (defun gnus-handle-ephemeral-exit (quit-config)
5195 "Handle movement when leaving an ephemeral group. The state
5196 which existed when entering the ephemeral is reset."
5197 (if (not (buffer-name (car quit-config)))
5198 (gnus-configure-windows 'group 'force)
5199 (set-buffer (car quit-config))
5200 (cond ((eq major-mode 'gnus-summary-mode)
5201 (gnus-set-global-variables))
5202 ((eq major-mode 'gnus-article-mode)
5204 ;; The `gnus-summary-buffer' variable may point
5205 ;; to the old summary buffer when using a single
5207 (unless (gnus-buffer-live-p gnus-summary-buffer)
5208 (set-buffer gnus-group-buffer))
5209 (set-buffer gnus-summary-buffer)
5210 (gnus-set-global-variables))))
5211 (if (or (eq (cdr quit-config) 'article)
5212 (eq (cdr quit-config) 'pick))
5214 ;; The current article may be from the ephemeral group
5215 ;; thus it is best that we reload this article
5216 (gnus-summary-show-article)
5217 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5218 (gnus-configure-windows 'pick 'force)
5219 (gnus-configure-windows (cdr quit-config) 'force)))
5220 (gnus-configure-windows (cdr quit-config) 'force))
5221 (when (eq major-mode 'gnus-summary-mode)
5222 (gnus-summary-next-subject 1 nil t)
5223 (gnus-summary-recenter)
5224 (gnus-summary-position-point))))
5226 (defun gnus-summary-preview-mime-message (arg)
5227 "MIME decode and play this message."
5229 (let ((gnus-break-pages nil))
5230 (gnus-summary-select-article t t)
5232 (pop-to-buffer gnus-original-article-buffer t)
5233 (let (buffer-read-only)
5234 (if (text-property-any (point-min) (point-max) 'invisible t)
5235 (remove-text-properties (point-min) (point-max)
5236 gnus-hidden-properties)
5238 (mime-view-mode nil nil nil gnus-original-article-buffer
5239 gnus-article-buffer)
5242 (defun gnus-summary-scroll-down ()
5243 "Scroll down one line current article."
5245 (gnus-summary-scroll-up -1)
5250 (defvar gnus-dead-summary-mode-map nil)
5252 (unless gnus-dead-summary-mode-map
5253 (setq gnus-dead-summary-mode-map (make-keymap))
5254 (suppress-keymap gnus-dead-summary-mode-map)
5255 (substitute-key-definition
5256 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5257 (let ((keys '("\C-d" "\r" "\177" [delete])))
5259 (define-key gnus-dead-summary-mode-map
5260 (pop keys) 'gnus-summary-wake-up-the-dead))))
5262 (defvar gnus-dead-summary-mode nil
5263 "Minor mode for Gnus summary buffers.")
5265 (defun gnus-dead-summary-mode (&optional arg)
5266 "Minor mode for Gnus summary buffers."
5268 (when (eq major-mode 'gnus-summary-mode)
5269 (make-local-variable 'gnus-dead-summary-mode)
5270 (setq gnus-dead-summary-mode
5271 (if (null arg) (not gnus-dead-summary-mode)
5272 (> (prefix-numeric-value arg) 0)))
5273 (when gnus-dead-summary-mode
5274 (gnus-add-minor-mode
5275 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5277 (defun gnus-deaden-summary ()
5278 "Make the current summary buffer into a dead summary buffer."
5279 ;; Kill any previous dead summary buffer.
5280 (when (and gnus-dead-summary
5281 (buffer-name gnus-dead-summary))
5283 (set-buffer gnus-dead-summary)
5284 (when gnus-dead-summary-mode
5285 (kill-buffer (current-buffer)))))
5286 ;; Make this the current dead summary.
5287 (setq gnus-dead-summary (current-buffer))
5288 (gnus-dead-summary-mode 1)
5289 (let ((name (buffer-name)))
5290 (when (string-match "Summary" name)
5292 (concat (substring name 0 (match-beginning 0)) "Dead "
5293 (substring name (match-beginning 0)))
5296 (defun gnus-kill-or-deaden-summary (buffer)
5297 "Kill or deaden the summary BUFFER."
5299 (when (and (buffer-name buffer)
5300 (not gnus-single-article-buffer))
5303 (gnus-kill-buffer gnus-article-buffer)
5304 (gnus-kill-buffer gnus-original-article-buffer)))
5305 (cond (gnus-kill-summary-on-exit
5306 (when (and gnus-use-trees
5307 (and (get-buffer buffer)
5308 (buffer-name (get-buffer buffer))))
5310 (set-buffer (get-buffer buffer))
5311 (gnus-tree-close gnus-newsgroup-name)))
5312 (gnus-kill-buffer buffer))
5313 ((and (get-buffer buffer)
5314 (buffer-name (get-buffer buffer)))
5317 (gnus-deaden-summary))))))
5319 (defun gnus-summary-wake-up-the-dead (&rest args)
5320 "Wake up the dead summary buffer."
5322 (gnus-dead-summary-mode -1)
5323 (let ((name (buffer-name)))
5324 (when (string-match "Dead " name)
5326 (concat (substring name 0 (match-beginning 0))
5327 (substring name (match-end 0)))
5329 (gnus-message 3 "This dead summary is now alive again"))
5331 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5332 (defun gnus-summary-fetch-faq (&optional faq-dir)
5333 "Fetch the FAQ for the current group.
5334 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5338 (when current-prefix-arg
5340 "Faq dir: " (and (listp gnus-group-faq-directory)
5341 (mapcar (lambda (file) (list file))
5342 gnus-group-faq-directory))))))
5343 (let (gnus-faq-buffer)
5344 (when (setq gnus-faq-buffer
5345 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5346 (gnus-configure-windows 'summary-faq))))
5348 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5349 (defun gnus-summary-describe-group (&optional force)
5350 "Describe the current newsgroup."
5352 (gnus-group-describe-group force gnus-newsgroup-name))
5354 (defun gnus-summary-describe-briefly ()
5355 "Describe summary mode commands briefly."
5358 (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")))
5360 ;; Walking around group mode buffer from summary mode.
5362 (defun gnus-summary-next-group (&optional no-article target-group backward)
5363 "Exit current newsgroup and then select next unread newsgroup.
5364 If prefix argument NO-ARTICLE is non-nil, no article is selected
5365 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5366 previous group instead."
5368 ;; Stop pre-fetching.
5369 (gnus-async-halt-prefetch)
5370 (let ((current-group gnus-newsgroup-name)
5371 (current-buffer (current-buffer))
5373 ;; First we semi-exit this group to update Xrefs and all variables.
5374 ;; We can't do a real exit, because the window conf must remain
5375 ;; the same in case the user is prompted for info, and we don't
5376 ;; want the window conf to change before that...
5377 (gnus-summary-exit t)
5378 (while (not entered)
5379 ;; Then we find what group we are supposed to enter.
5380 (set-buffer gnus-group-buffer)
5381 (gnus-group-jump-to-group current-group)
5384 (if (eq gnus-keep-same-level 'best)
5385 (gnus-summary-best-group gnus-newsgroup-name)
5386 (gnus-summary-search-group backward gnus-keep-same-level))))
5387 (if (not target-group)
5388 ;; There are no further groups, so we return to the group
5391 (gnus-message 5 "Returning to the group buffer")
5393 (when (gnus-buffer-live-p current-buffer)
5394 (set-buffer current-buffer)
5395 (gnus-summary-exit))
5396 (run-hooks 'gnus-group-no-more-groups-hook))
5397 ;; We try to enter the target group.
5398 (gnus-group-jump-to-group target-group)
5399 (let ((unreads (gnus-group-group-unread)))
5400 (if (and (or (eq t unreads)
5401 (and unreads (not (zerop unreads))))
5402 (gnus-summary-read-group
5403 target-group nil no-article
5404 (and (buffer-name current-buffer) current-buffer)))
5406 (setq current-group target-group
5407 target-group nil)))))))
5409 (defun gnus-summary-prev-group (&optional no-article)
5410 "Exit current newsgroup and then select previous unread newsgroup.
5411 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5413 (gnus-summary-next-group no-article nil t))
5415 ;; Walking around summary lines.
5417 (defun gnus-summary-first-subject (&optional unread)
5418 "Go to the first unread subject.
5419 If UNREAD is non-nil, go to the first unread article.
5420 Returns the article selected or nil if there are no unread articles."
5425 ((null gnus-newsgroup-data)
5426 (gnus-message 3 "No articles in the group")
5428 ;; Pick the first article.
5430 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5431 (gnus-data-number (car gnus-newsgroup-data)))
5432 ;; No unread articles.
5433 ((null gnus-newsgroup-unreads)
5434 (gnus-message 3 "No more unread articles")
5436 ;; Find the first unread article.
5438 (let ((data gnus-newsgroup-data))
5440 (not (gnus-data-unread-p (car data))))
5441 (setq data (cdr data)))
5443 (goto-char (gnus-data-pos (car data)))
5444 (gnus-data-number (car data))))))
5445 (gnus-summary-position-point)))
5447 (defun gnus-summary-next-subject (n &optional unread dont-display)
5448 "Go to next N'th summary line.
5449 If N is negative, go to the previous N'th subject line.
5450 If UNREAD is non-nil, only unread articles are selected.
5451 The difference between N and the actual number of steps taken is
5454 (let ((backward (< n 0))
5458 (gnus-summary-find-prev unread)
5459 (gnus-summary-find-next unread)))
5462 (gnus-message 7 "No more%s articles"
5463 (if unread " unread" "")))
5464 (unless dont-display
5465 (gnus-summary-recenter)
5466 (gnus-summary-position-point))
5469 (defun gnus-summary-next-unread-subject (n)
5470 "Go to next N'th unread summary line."
5472 (gnus-summary-next-subject n t))
5474 (defun gnus-summary-prev-subject (n &optional unread)
5475 "Go to previous N'th summary line.
5476 If optional argument UNREAD is non-nil, only unread article is selected."
5478 (gnus-summary-next-subject (- n) unread))
5480 (defun gnus-summary-prev-unread-subject (n)
5481 "Go to previous N'th unread summary line."
5483 (gnus-summary-next-subject (- n) t))
5485 (defun gnus-summary-goto-subject (article &optional force silent)
5486 "Go the subject line of ARTICLE.
5487 If FORCE, also allow jumping to articles not currently shown."
5488 (interactive "nArticle number: ")
5490 (data (gnus-data-find article)))
5491 ;; We read in the article if we have to.
5494 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5495 (setq data (gnus-data-find article)))
5500 (gnus-message 3 "Can't find article %d" article))
5502 (goto-char (gnus-data-pos data))
5505 ;; Walking around summary lines with displaying articles.
5507 (defun gnus-summary-expand-window (&optional arg)
5508 "Make the summary buffer take up the entire Emacs frame.
5509 Given a prefix, will force an `article' buffer configuration."
5512 (gnus-configure-windows 'article 'force)
5513 (gnus-configure-windows 'summary 'force)))
5515 (defun gnus-summary-display-article (article &optional all-header)
5516 "Display ARTICLE in article buffer."
5517 (gnus-set-global-variables)
5521 (if gnus-summary-display-article-function
5522 (funcall gnus-summary-display-article-function article all-header)
5523 (gnus-article-prepare article all-header))
5524 (run-hooks 'gnus-select-article-hook)
5525 (when (and gnus-current-article
5526 (not (zerop gnus-current-article)))
5527 (gnus-summary-goto-subject gnus-current-article))
5528 (gnus-summary-recenter)
5529 (when (and gnus-use-trees gnus-show-threads)
5530 (gnus-possibly-generate-tree article)
5531 (gnus-highlight-selected-tree article))
5532 ;; Successfully display article.
5533 (gnus-article-set-window-start
5534 (cdr (assq article gnus-newsgroup-bookmarks))))))
5536 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5537 "Select the current article.
5538 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5539 non-nil, the article will be re-fetched even if it already present in
5540 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5542 ;; Make sure we are in the summary buffer to work around bbdb bug.
5543 (unless (eq major-mode 'gnus-summary-mode)
5544 (set-buffer gnus-summary-buffer))
5545 (let ((article (or article (gnus-summary-article-number)))
5546 (all-headers (not (not all-headers))) ;Must be T or NIL.
5547 gnus-summary-display-article-function
5550 (gnus-summary-article-pseudo-p article)
5551 (error "This is a pseudo-article"))
5554 (set-buffer gnus-summary-buffer)
5555 (if (or (and gnus-single-article-buffer
5556 (or (null gnus-current-article)
5557 (null gnus-article-current)
5558 (null (get-buffer gnus-article-buffer))
5559 (not (eq article (cdr gnus-article-current)))
5560 (not (equal (car gnus-article-current)
5561 gnus-newsgroup-name))))
5562 (and (not gnus-single-article-buffer)
5563 (or (null gnus-current-article)
5564 (not (eq gnus-current-article article))))
5566 ;; The requested article is different from the current article.
5568 (gnus-summary-display-article article all-headers)
5570 (when (or all-headers gnus-show-all-headers)
5571 (gnus-article-show-all-headers))
5574 (gnus-article-set-window-start
5575 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5577 (defun gnus-summary-set-current-mark (&optional current-mark)
5578 "Obsolete function."
5581 (defun gnus-summary-next-article (&optional unread subject backward push)
5582 "Select the next article.
5583 If UNREAD, only unread articles are selected.
5584 If SUBJECT, only articles with SUBJECT are selected.
5585 If BACKWARD, the previous article is selected instead of the next."
5588 ;; Is there such an article?
5589 ((and (gnus-summary-search-forward unread subject backward)
5590 (or (gnus-summary-display-article (gnus-summary-article-number))
5591 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5592 (gnus-summary-position-point))
5593 ;; If not, we try the first unread, if that is wanted.
5595 gnus-auto-select-same
5596 (gnus-summary-first-unread-article))
5597 (gnus-summary-position-point)
5598 (gnus-message 6 "Wrapped"))
5599 ;; Try to get next/previous article not displayed in this group.
5600 ((and gnus-auto-extend-newsgroup
5601 (not unread) (not subject))
5602 (gnus-summary-goto-article
5603 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5605 ;; Go to next/previous group.
5607 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5608 (gnus-summary-jump-to-group gnus-newsgroup-name))
5609 (let ((cmd last-command-char)
5612 (set-buffer gnus-group-buffer)
5615 (if (eq gnus-keep-same-level 'best)
5616 (gnus-summary-best-group gnus-newsgroup-name)
5617 (gnus-summary-search-group backward gnus-keep-same-level))))
5618 ;; For some reason, the group window gets selected. We change
5620 (select-window (get-buffer-window (current-buffer)))
5621 ;; Select next unread newsgroup automagically.
5623 ((or (not gnus-auto-select-next)
5625 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5626 ((or (eq gnus-auto-select-next 'quietly)
5627 (and (eq gnus-auto-select-next 'slightly-quietly)
5629 (and (eq gnus-auto-select-next 'almost-quietly)
5630 (gnus-summary-last-article-p)))
5632 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5634 (gnus-message 7 "No more%s articles (%s)..."
5635 (if unread " unread" "")
5636 (if group (concat "selecting " group)
5638 (gnus-summary-next-group nil group backward)))
5640 (when (gnus-key-press-event-p last-input-event)
5641 (gnus-summary-walk-group-buffer
5642 gnus-newsgroup-name cmd unread backward point))))))))
5644 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5645 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5646 (?\C-p (gnus-group-prev-unread-group 1))))
5647 (cursor-in-echo-area t)
5648 keve key group ended)
5650 (set-buffer gnus-group-buffer)
5653 (if (eq gnus-keep-same-level 'best)
5654 (gnus-summary-best-group gnus-newsgroup-name)
5655 (gnus-summary-search-group backward gnus-keep-same-level))))
5658 5 "No more%s articles%s" (if unread " unread" "")
5660 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5661 (format " (Type %s for %s [%s])"
5662 (single-key-description cmd) group
5663 (car (gnus-gethash group gnus-newsrc-hashtb)))
5664 (format " (Type %s to exit %s)"
5665 (single-key-description cmd)
5666 gnus-newsgroup-name)))
5667 ;; Confirm auto selection.
5668 (setq key (car (setq keve (gnus-read-event-char))))
5671 ((assq key keystrokes)
5672 (let ((obuf (current-buffer)))
5673 (switch-to-buffer gnus-group-buffer)
5675 (gnus-group-jump-to-group group))
5676 (eval (cadr (assq key keystrokes)))
5677 (setq group (gnus-group-group-name))
5678 (switch-to-buffer obuf))
5682 (gnus-ephemeral-group-p gnus-newsgroup-name))
5684 (gnus-summary-next-group nil group backward)))
5686 (push (cdr keve) unread-command-events))))))
5688 (defun gnus-summary-next-unread-article ()
5689 "Select unread article after current one."
5691 (gnus-summary-next-article
5692 (or (not (eq gnus-summary-goto-unread 'never))
5693 (gnus-summary-last-article-p (gnus-summary-article-number)))
5694 (and gnus-auto-select-same
5695 (gnus-summary-article-subject))))
5697 (defun gnus-summary-prev-article (&optional unread subject)
5698 "Select the article after the current one.
5699 If UNREAD is non-nil, only unread articles are selected."
5701 (gnus-summary-next-article unread subject t))
5703 (defun gnus-summary-prev-unread-article ()
5704 "Select unread article before current one."
5706 (gnus-summary-prev-article
5707 (or (not (eq gnus-summary-goto-unread 'never))
5708 (gnus-summary-first-article-p (gnus-summary-article-number)))
5709 (and gnus-auto-select-same
5710 (gnus-summary-article-subject))))
5712 (defun gnus-summary-next-page (&optional lines circular)
5713 "Show next page of the selected article.
5714 If at the end of the current article, select the next article.
5715 LINES says how many lines should be scrolled up.
5717 If CIRCULAR is non-nil, go to the start of the article instead of
5718 selecting the next article when reaching the end of the current
5721 (setq gnus-summary-buffer (current-buffer))
5722 (gnus-set-global-variables)
5723 (let ((article (gnus-summary-article-number))
5724 (article-window (get-buffer-window gnus-article-buffer t))
5726 (gnus-configure-windows 'article)
5727 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5728 (if (and (eq gnus-summary-goto-unread 'never)
5729 (not (gnus-summary-last-article-p article)))
5730 (gnus-summary-next-article)
5731 (gnus-summary-next-unread-article))
5732 (if (or (null gnus-current-article)
5733 (null gnus-article-current)
5734 (/= article (cdr gnus-article-current))
5735 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5736 ;; Selected subject is different from current article's.
5737 (gnus-summary-display-article article)
5738 (when article-window
5739 (gnus-eval-in-buffer-window gnus-article-buffer
5740 (setq endp (gnus-article-next-page lines)))
5743 (gnus-summary-beginning-of-article))
5745 (gnus-message 3 "End of message"))
5747 (if (and (eq gnus-summary-goto-unread 'never)
5748 (not (gnus-summary-last-article-p article)))
5749 (gnus-summary-next-article)
5750 (gnus-summary-next-unread-article))))))))
5751 (gnus-summary-recenter)
5752 (gnus-summary-position-point)))
5754 (defun gnus-summary-prev-page (&optional lines move)
5755 "Show previous page of selected article.
5756 Argument LINES specifies lines to be scrolled down.
5757 If MOVE, move to the previous unread article if point is at
5758 the beginning of the buffer."
5760 (let ((article (gnus-summary-article-number))
5761 (article-window (get-buffer-window gnus-article-buffer t))
5763 (gnus-configure-windows 'article)
5764 (if (or (null gnus-current-article)
5765 (null gnus-article-current)
5766 (/= article (cdr gnus-article-current))
5767 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5768 ;; Selected subject is different from current article's.
5769 (gnus-summary-display-article article)
5770 (gnus-summary-recenter)
5771 (when article-window
5772 (gnus-eval-in-buffer-window gnus-article-buffer
5773 (setq endp (gnus-article-prev-page lines)))
5774 (when (and move endp)
5776 (gnus-message 3 "Beginning of message"))
5778 (if (and (eq gnus-summary-goto-unread 'never)
5779 (not (gnus-summary-first-article-p article)))
5780 (gnus-summary-prev-article)
5781 (gnus-summary-prev-unread-article))))))))
5782 (gnus-summary-position-point))
5784 (defun gnus-summary-prev-page-or-article (&optional lines)
5785 "Show previous page of selected article.
5786 Argument LINES specifies lines to be scrolled down.
5787 If at the beginning of the article, go to the next article."
5789 (gnus-summary-prev-page lines t))
5791 (defun gnus-summary-scroll-up (lines)
5792 "Scroll up (or down) one line current article.
5793 Argument LINES specifies lines to be scrolled up (or down if negative)."
5795 (gnus-configure-windows 'article)
5796 (gnus-summary-show-thread)
5797 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5798 (gnus-eval-in-buffer-window gnus-article-buffer
5800 (when (gnus-article-next-page lines)
5801 (gnus-message 3 "End of message")))
5803 (gnus-article-prev-page (- lines))))))
5804 (gnus-summary-recenter)
5805 (gnus-summary-position-point))
5807 (defun gnus-summary-next-same-subject ()
5808 "Select next article which has the same subject as current one."
5810 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5812 (defun gnus-summary-prev-same-subject ()
5813 "Select previous article which has the same subject as current one."
5815 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5817 (defun gnus-summary-next-unread-same-subject ()
5818 "Select next unread article which has the same subject as current one."
5820 (gnus-summary-next-article t (gnus-summary-article-subject)))
5822 (defun gnus-summary-prev-unread-same-subject ()
5823 "Select previous unread article which has the same subject as current one."
5825 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5827 (defun gnus-summary-first-unread-article ()
5828 "Select the first unread article.
5829 Return nil if there are no unread articles."
5832 (when (gnus-summary-first-subject t)
5833 (gnus-summary-show-thread)
5834 (gnus-summary-first-subject t)
5835 (gnus-summary-display-article (gnus-summary-article-number)))
5836 (gnus-summary-position-point)))
5838 (defun gnus-summary-first-article ()
5839 "Select the first article.
5840 Return nil if there are no articles."
5843 (when (gnus-summary-first-subject)
5844 (gnus-summary-show-thread)
5845 (gnus-summary-first-subject)
5846 (gnus-summary-display-article (gnus-summary-article-number)))
5847 (gnus-summary-position-point)))
5849 (defun gnus-summary-best-unread-article ()
5850 "Select the unread article with the highest score."
5852 (let ((best -1000000)
5853 (data gnus-newsgroup-data)
5856 (and (gnus-data-unread-p (car data))
5858 (gnus-summary-article-score (gnus-data-number (car data))))
5861 article (gnus-data-number (car data))))
5862 (setq data (cdr data)))
5865 (gnus-summary-goto-article article)
5866 (error "No unread articles"))
5867 (gnus-summary-position-point))))
5869 (defun gnus-summary-last-subject ()
5870 "Go to the last displayed subject line in the group."
5871 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5873 (gnus-summary-goto-subject article))))
5875 (defun gnus-summary-goto-article (article &optional all-headers force)
5876 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5877 If ALL-HEADERS is non-nil, no header lines are hidden."
5881 "Article number or Message-ID: "
5882 (mapcar (lambda (number) (list (int-to-string number)))
5883 gnus-newsgroup-limit))
5887 (if (and (stringp article)
5888 (string-match "@" article))
5889 (gnus-summary-refer-article article)
5890 (when (stringp article)
5891 (setq article (string-to-number article)))
5892 (if (gnus-summary-goto-subject article force)
5893 (gnus-summary-display-article article all-headers)
5894 (gnus-message 4 "Couldn't go to article %s" article) nil))
5895 (gnus-summary-position-point)))
5897 (defun gnus-summary-goto-last-article ()
5898 "Go to the previously read article."
5901 (when gnus-last-article
5902 (gnus-summary-goto-article gnus-last-article))
5903 (gnus-summary-position-point)))
5905 (defun gnus-summary-pop-article (number)
5906 "Pop one article off the history and go to the previous.
5907 NUMBER articles will be popped off."
5910 (setq gnus-newsgroup-history
5911 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5913 (gnus-summary-goto-article (car to) nil t)
5914 (error "Article history empty")))
5915 (gnus-summary-position-point))
5917 ;; Summary commands and functions for limiting the summary buffer.
5919 (defun gnus-summary-limit-to-articles (n)
5920 "Limit the summary buffer to the next N articles.
5921 If not given a prefix, use the process marked articles instead."
5924 (let ((articles (gnus-summary-work-articles n)))
5925 (setq gnus-newsgroup-processable nil)
5926 (gnus-summary-limit articles))
5927 (gnus-summary-position-point)))
5929 (defun gnus-summary-pop-limit (&optional total)
5930 "Restore the previous limit.
5931 If given a prefix, remove all limits."
5934 (setq gnus-newsgroup-limits
5935 (list (mapcar (lambda (h) (mail-header-number h))
5936 gnus-newsgroup-headers))))
5937 (unless gnus-newsgroup-limits
5938 (error "No limit to pop"))
5940 (gnus-summary-limit nil 'pop)
5941 (gnus-summary-position-point)))
5943 (defun gnus-summary-limit-to-subject (subject &optional header)
5944 "Limit the summary buffer to articles that have subjects that match a regexp."
5945 (interactive "sLimit to subject (regexp): ")
5947 (setq header "subject"))
5948 (when (not (equal "" subject))
5950 (let ((articles (gnus-summary-find-matching
5951 (or header "subject") subject 'all)))
5953 (error "Found no matches for \"%s\"" subject))
5954 (gnus-summary-limit articles))
5955 (gnus-summary-position-point))))
5957 (defun gnus-summary-limit-to-author (from)
5958 "Limit the summary buffer to articles that have authors that match a regexp."
5959 (interactive "sLimit to author (regexp): ")
5960 (gnus-summary-limit-to-subject from "from"))
5962 (defun gnus-summary-limit-to-age (age &optional younger-p)
5963 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5964 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5965 articles that are younger than AGE days."
5966 (interactive "nTime in days: \nP")
5968 (let ((data gnus-newsgroup-data)
5969 (cutoff (nnmail-days-to-time age))
5970 articles d date is-younger)
5971 (while (setq d (pop data))
5972 (when (and (vectorp (gnus-data-header d))
5973 (setq date (mail-header-date (gnus-data-header d))))
5974 (setq is-younger (nnmail-time-less
5975 (nnmail-time-since (nnmail-date-to-time date))
5977 (when (if younger-p is-younger (not is-younger))
5978 (push (gnus-data-number d) articles))))
5979 (gnus-summary-limit (nreverse articles)))
5980 (gnus-summary-position-point)))
5982 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5984 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5986 (defun gnus-summary-limit-to-unread (&optional all)
5987 "Limit the summary buffer to articles that are not marked as read.
5988 If ALL is non-nil, limit strictly to unread articles."
5991 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5992 (gnus-summary-limit-to-marks
5993 ;; Concat all the marks that say that an article is read and have
5995 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5996 gnus-killed-mark gnus-kill-file-mark
5997 gnus-low-score-mark gnus-expirable-mark
5998 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5999 gnus-duplicate-mark gnus-souped-mark)
6002 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6003 (make-obsolete 'gnus-summary-delete-marked-with
6004 'gnus-summary-limit-exlude-marks)
6006 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6007 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6008 If REVERSE, limit the summary buffer to articles that are marked
6009 with MARKS. MARKS can either be a string of marks or a list of marks.
6010 Returns how many articles were removed."
6011 (interactive "sMarks: ")
6012 (gnus-summary-limit-to-marks marks t))
6014 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6015 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6016 If REVERSE (the prefix), limit the summary buffer to articles that are
6017 not marked with MARKS. MARKS can either be a string of marks or a
6019 Returns how many articles were removed."
6020 (interactive "sMarks: \nP")
6022 (let ((data gnus-newsgroup-data)
6023 (marks (if (listp marks) marks
6024 (append marks nil))) ; Transform to list.
6027 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6028 (memq (gnus-data-mark (car data)) marks))
6029 (push (gnus-data-number (car data)) articles))
6030 (setq data (cdr data)))
6031 (gnus-summary-limit articles))
6032 (gnus-summary-position-point)))
6034 (defun gnus-summary-limit-to-score (&optional score)
6035 "Limit to articles with score at or above SCORE."
6037 (setq score (if score
6038 (prefix-numeric-value score)
6039 (or gnus-summary-default-score 0)))
6040 (let ((data gnus-newsgroup-data)
6043 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6045 (push (gnus-data-number (car data)) articles))
6046 (setq data (cdr data)))
6048 (gnus-summary-limit articles)
6049 (gnus-summary-position-point))))
6051 (defun gnus-summary-limit-include-thread (id)
6052 "Display all the hidden articles that in the current thread."
6053 (interactive (list (mail-header-id (gnus-summary-article-header))))
6054 (let ((articles (gnus-articles-in-thread
6055 (gnus-id-to-thread (gnus-root-id id)))))
6057 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6058 (gnus-summary-position-point))))
6060 (defun gnus-summary-limit-include-dormant ()
6061 "Display all the hidden articles that are marked as dormant.
6062 Note that this command only works on a subset of the articles currently
6063 fetched for this group."
6065 (unless gnus-newsgroup-dormant
6066 (error "There are no dormant articles in this group"))
6068 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6069 (gnus-summary-position-point)))
6071 (defun gnus-summary-limit-exclude-dormant ()
6072 "Hide all dormant articles."
6075 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6076 (gnus-summary-position-point)))
6078 (defun gnus-summary-limit-exclude-childless-dormant ()
6079 "Hide all dormant articles that have no children."
6081 (let ((data (gnus-data-list t))
6082 articles d children)
6083 ;; Find all articles that are either not dormant or have
6085 (while (setq d (pop data))
6086 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6088 (gnus-article-children (gnus-data-number d)))
6091 (when (memq (car children) articles)
6096 (push (gnus-data-number d) articles)))
6099 (gnus-summary-limit articles)
6100 (gnus-summary-position-point))))
6102 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6103 "Mark all unread excluded articles as read.
6104 If ALL, mark even excluded ticked and dormants as read."
6106 (let ((articles (gnus-sorted-complement
6108 (mapcar (lambda (h) (mail-header-number h))
6109 gnus-newsgroup-headers)
6111 (sort gnus-newsgroup-limit '<)))
6113 (setq gnus-newsgroup-unreads gnus-newsgroup-limit)
6115 (setq gnus-newsgroup-dormant nil
6116 gnus-newsgroup-marked nil
6117 gnus-newsgroup-reads
6119 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6120 gnus-newsgroup-reads))
6121 (while (setq article (pop articles))
6122 (unless (or (memq article gnus-newsgroup-dormant)
6123 (memq article gnus-newsgroup-marked))
6124 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6126 (defun gnus-summary-limit (articles &optional pop)
6128 ;; We pop the previous limit off the stack and use that.
6129 (setq articles (car gnus-newsgroup-limits)
6130 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6131 ;; We use the new limit, so we push the old limit on the stack.
6132 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6134 (setq gnus-newsgroup-limit articles)
6135 (let ((total (length gnus-newsgroup-data))
6136 (data (gnus-data-find-list (gnus-summary-article-number)))
6137 (gnus-summary-mark-below nil) ; Inhibit this.
6139 ;; This will do all the work of generating the new summary buffer
6140 ;; according to the new limit.
6141 (gnus-summary-prepare)
6142 ;; Hide any threads, possibly.
6143 (and gnus-show-threads
6144 gnus-thread-hide-subtree
6145 (gnus-summary-hide-all-threads))
6146 ;; Try to return to the article you were at, or one in the
6149 ;; We try to find some article after the current one.
6151 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6154 (setq data (cdr data))))
6156 ;; If there is no data, that means that we were after the last
6157 ;; article. The same goes when we can't find any articles
6158 ;; after the current one.
6159 (goto-char (point-max))
6160 (gnus-summary-find-prev))
6161 ;; We return how many articles were removed from the summary
6162 ;; buffer as a result of the new limit.
6163 (- total (length gnus-newsgroup-data))))
6165 (defsubst gnus-invisible-cut-children (threads)
6168 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6173 (defsubst gnus-cut-thread (thread)
6174 "Go forwards in the thread until we find an article that we want to display."
6175 (when (or (eq gnus-fetch-old-headers 'some)
6176 (eq gnus-fetch-old-headers 'invisible)
6177 (eq gnus-build-sparse-threads 'some)
6178 (eq gnus-build-sparse-threads 'more))
6179 ;; Deal with old-fetched headers and sparse threads.
6183 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6184 (gnus-summary-article-ancient-p
6185 (mail-header-number (car thread))))
6186 (if (or (<= (length (cdr thread)) 1)
6187 (eq gnus-fetch-old-headers 'invisible))
6188 (setq gnus-newsgroup-limit
6189 (delq (mail-header-number (car thread))
6190 gnus-newsgroup-limit)
6191 thread (cadr thread))
6192 (when (gnus-invisible-cut-children (cdr thread))
6193 (let ((th (cdr thread)))
6195 (if (memq (mail-header-number (caar th))
6196 gnus-newsgroup-limit)
6197 (setq thread (car th)
6199 (setq th (cdr th))))))))))
6202 (defun gnus-cut-threads (threads)
6203 "Cut off all uninteresting articles from the beginning of threads."
6204 (when (or (eq gnus-fetch-old-headers 'some)
6205 (eq gnus-fetch-old-headers 'invisible)
6206 (eq gnus-build-sparse-threads 'some)
6207 (eq gnus-build-sparse-threads 'more))
6210 (setcar th (gnus-cut-thread (car th)))
6211 (setq th (cdr th)))))
6212 ;; Remove nixed out threads.
6215 (defun gnus-summary-initial-limit (&optional show-if-empty)
6216 "Figure out what the initial limit is supposed to be on group entry.
6217 This entails weeding out unwanted dormants, low-scored articles,
6218 fetch-old-headers verbiage, and so on."
6219 ;; Most groups have nothing to remove.
6220 (if (or gnus-inhibit-limiting
6221 (and (null gnus-newsgroup-dormant)
6222 (not (eq gnus-fetch-old-headers 'some))
6223 (not (eq gnus-fetch-old-headers 'invisible))
6224 (null gnus-summary-expunge-below)
6225 (not (eq gnus-build-sparse-threads 'some))
6226 (not (eq gnus-build-sparse-threads 'more))
6227 (null gnus-thread-expunge-below)
6228 (not gnus-use-nocem)))
6230 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6231 (setq gnus-newsgroup-limit nil)
6234 (unless (car (symbol-value node))
6235 ;; These threads have no parents -- they are roots.
6236 (let ((nodes (cdr (symbol-value node)))
6239 (if (and gnus-thread-expunge-below
6240 (< (gnus-thread-total-score (car nodes))
6241 gnus-thread-expunge-below))
6242 (gnus-expunge-thread (pop nodes))
6243 (setq thread (pop nodes))
6244 (gnus-summary-limit-children thread))))))
6245 gnus-newsgroup-dependencies)
6246 ;; If this limitation resulted in an empty group, we might
6247 ;; pop the previous limit and use it instead.
6248 (when (and (not gnus-newsgroup-limit)
6250 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6251 gnus-newsgroup-limit))
6253 (defun gnus-summary-limit-children (thread)
6254 "Return 1 if this subthread is visible and 0 if it is not."
6255 ;; First we get the number of visible children to this thread. This
6256 ;; is done by recursing down the thread using this function, so this
6257 ;; will really go down to a leaf article first, before slowly
6258 ;; working its way up towards the root.
6262 (apply '+ (mapcar 'gnus-summary-limit-children
6265 (number (mail-header-number (car thread)))
6268 (not (memq number gnus-newsgroup-marked))
6270 ;; If this article is dormant and has absolutely no visible
6271 ;; children, then this article isn't visible.
6272 (and (memq number gnus-newsgroup-dormant)
6274 ;; If this is "fetch-old-headered" and there is no
6275 ;; visible children, then we don't want this article.
6276 (and (eq gnus-fetch-old-headers 'some)
6277 (gnus-summary-article-ancient-p number)
6279 ;; If this is "fetch-old-headered" and `invisible', then
6280 ;; we don't want this article.
6281 (and (eq gnus-fetch-old-headers 'invisible)
6282 (gnus-summary-article-ancient-p number))
6283 ;; If this is a sparsely inserted article with no children,
6284 ;; we don't want it.
6285 (and (eq gnus-build-sparse-threads 'some)
6286 (gnus-summary-article-sparse-p number)
6288 ;; If we use expunging, and this article is really
6289 ;; low-scored, then we don't want this article.
6290 (when (and gnus-summary-expunge-below
6292 (or (cdr (assq number gnus-newsgroup-scored))
6293 gnus-summary-default-score))
6294 gnus-summary-expunge-below))
6295 ;; We increase the expunge-tally here, but that has
6296 ;; nothing to do with the limits, really.
6297 (incf gnus-newsgroup-expunged-tally)
6298 ;; We also mark as read here, if that's wanted.
6299 (when (and gnus-summary-mark-below
6300 (< score gnus-summary-mark-below))
6301 (setq gnus-newsgroup-unreads
6302 (delq number gnus-newsgroup-unreads))
6303 (if gnus-newsgroup-auto-expire
6304 (push number gnus-newsgroup-expirable)
6305 (push (cons number gnus-low-score-mark)
6306 gnus-newsgroup-reads)))
6308 ;; Check NoCeM things.
6309 (if (and gnus-use-nocem
6310 (gnus-nocem-unwanted-article-p
6311 (mail-header-id (car thread))))
6313 (setq gnus-newsgroup-unreads
6314 (delq number gnus-newsgroup-unreads))
6316 ;; Nope, invisible article.
6318 ;; Ok, this article is to be visible, so we add it to the limit
6320 (push number gnus-newsgroup-limit)
6323 (defun gnus-expunge-thread (thread)
6324 "Mark all articles in THREAD as read."
6325 (let* ((number (mail-header-number (car thread))))
6326 (incf gnus-newsgroup-expunged-tally)
6327 ;; We also mark as read here, if that's wanted.
6328 (setq gnus-newsgroup-unreads
6329 (delq number gnus-newsgroup-unreads))
6330 (if gnus-newsgroup-auto-expire
6331 (push number gnus-newsgroup-expirable)
6332 (push (cons number gnus-low-score-mark)
6333 gnus-newsgroup-reads)))
6334 ;; Go recursively through all subthreads.
6335 (mapcar 'gnus-expunge-thread (cdr thread)))
6337 ;; Summary article oriented commands
6339 (defun gnus-summary-refer-parent-article (n)
6340 "Refer parent article N times.
6341 If N is negative, go to ancestor -N instead.
6342 The difference between N and the number of articles fetched is returned."
6346 (when (not (natnump n))
6351 (setq header (gnus-summary-article-header))
6352 (if (and (eq (mail-header-number header)
6353 (cdr gnus-article-current))
6354 (equal gnus-newsgroup-name
6355 (car gnus-article-current)))
6356 ;; If we try to find the parent of the currently
6357 ;; displayed article, then we take a look at the actual
6358 ;; References header, since this is slightly more
6359 ;; reliable than the References field we got from the
6362 (set-buffer gnus-original-article-buffer)
6363 (nnheader-narrow-to-headers)
6364 (unless (setq ref (message-fetch-field "references"))
6365 (setq ref (message-fetch-field "in-reply-to")))
6368 ;; It's not the current article, so we take a bet on
6369 ;; the value we got from the server.
6370 (mail-header-references header)))
6372 (not (equal ref "")))
6373 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6374 (gnus-message 1 "Couldn't find parent"))
6375 (gnus-message 1 "No references in article %d"
6376 (gnus-summary-article-number))
6379 (gnus-summary-position-point)
6382 (defun gnus-summary-refer-references ()
6383 "Fetch all articles mentioned in the References header.
6384 Return the number of articles fetched."
6386 (let ((ref (mail-header-references (gnus-summary-article-header)))
6387 (current (gnus-summary-article-number))
6391 (error "No References in the current article")
6392 ;; For each Message-ID in the References header...
6393 (while (string-match "<[^>]*>" ref)
6395 ;; ... fetch that article.
6396 (gnus-summary-refer-article
6397 (prog1 (match-string 0 ref)
6398 (setq ref (substring ref (match-end 0))))))
6399 (gnus-summary-goto-subject current)
6400 (gnus-summary-position-point)
6403 (defun gnus-summary-refer-thread (&optional limit)
6404 "Fetch all articles in the current thread.
6405 If LIMIT (the numerical prefix), fetch that many old headers instead
6406 of what's specified by the `gnus-refer-thread-limit' variable."
6408 (let ((id (mail-header-id (gnus-summary-article-header)))
6409 (limit (if limit (prefix-numeric-value limit)
6410 gnus-refer-thread-limit))
6412 ;; We want to fetch LIMIT *old* headers, but we also have to
6413 ;; re-fetch all the headers in the current buffer, because many of
6414 ;; them may be undisplayed. So we adjust LIMIT.
6415 (when (numberp limit)
6416 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6417 (unless (eq gnus-fetch-old-headers 'invisible)
6418 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6419 ;; Retrieve the headers and read them in.
6420 (if (eq (gnus-retrieve-headers
6421 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6423 (gnus-build-all-threads)
6424 (error "Can't fetch thread from backends that don't support NOV"))
6425 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6426 (gnus-summary-limit-include-thread id)))
6428 (defun gnus-summary-refer-article (message-id &optional arg)
6429 "Fetch an article specified by MESSAGE-ID.
6430 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6431 or `gnus-select-method', no matter what backend the article comes from."
6432 (interactive "sMessage-ID: \nP")
6433 (when (and (stringp message-id)
6434 (not (zerop (length message-id))))
6435 ;; Construct the correct Message-ID if necessary.
6436 ;; Suggested by tale@pawl.rpi.edu.
6437 (unless (string-match "^<" message-id)
6438 (setq message-id (concat "<" message-id)))
6439 (unless (string-match ">$" message-id)
6440 (setq message-id (concat message-id ">")))
6441 (let* ((header (gnus-id-to-header message-id))
6443 (gnus-summary-article-sparse-p
6444 (mail-header-number header))
6445 (memq (mail-header-number header)
6446 gnus-newsgroup-limit)))
6449 ;; If the article is present in the buffer we just go to it.
6451 (or (not (gnus-summary-article-sparse-p
6452 (mail-header-number header)))
6455 (gnus-summary-goto-article
6456 (mail-header-number header) nil t)
6458 (gnus-summary-update-article (mail-header-number header)))))
6460 ;; We fetch the article
6461 (let ((gnus-override-method
6462 (cond ((gnus-news-group-p gnus-newsgroup-name)
6463 gnus-refer-article-method)
6465 (or gnus-refer-article-method gnus-select-method))
6468 ;; Start the special refer-article method, if necessary.
6469 (when (and gnus-refer-article-method
6470 (gnus-news-group-p gnus-newsgroup-name))
6471 (gnus-check-server gnus-refer-article-method))
6472 ;; Fetch the header, and display the article.
6473 (if (setq number (gnus-summary-insert-subject message-id))
6474 (gnus-summary-select-article nil nil nil number)
6475 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6477 (defun gnus-summary-enter-digest-group (&optional force)
6478 "Enter an nndoc group based on the current article.
6479 If FORCE, force a digest interpretation. If not, try
6480 to guess what the document format is."
6482 (let ((conf gnus-current-window-configuration))
6484 (gnus-summary-select-article))
6485 (setq gnus-current-window-configuration conf)
6486 (let* ((name (format "%s-%d"
6487 (gnus-group-prefixed-name
6488 gnus-newsgroup-name (list 'nndoc ""))
6490 (set-buffer gnus-summary-buffer)
6491 gnus-current-article)))
6492 (ogroup gnus-newsgroup-name)
6493 (params (append (gnus-info-params (gnus-get-info ogroup))
6494 (list (cons 'to-group ogroup))
6495 (list (cons 'save-article-group ogroup))))
6496 (case-fold-search t)
6497 (buf (current-buffer))
6500 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6501 (insert-buffer-substring gnus-original-article-buffer)
6502 ;; Remove lines that may lead nndoc to misinterpret the
6505 (goto-char (point-min))
6506 (or (search-forward "\n\n" nil t) (point)))
6507 (goto-char (point-min))
6508 (delete-matching-lines "^\\(Path\\):\\|^From ")
6511 (if (gnus-group-read-ephemeral-group
6512 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6514 ,(if force 'digest 'guess))) t)
6515 ;; Make all postings to this group go to the parent group.
6516 (nconc (gnus-info-params (gnus-get-info name))
6518 ;; Couldn't select this doc group.
6519 (switch-to-buffer buf)
6520 (gnus-set-global-variables)
6521 (gnus-configure-windows 'summary)
6522 (gnus-message 3 "Article couldn't be entered?"))
6523 (kill-buffer dig)))))
6525 (defun gnus-summary-read-document (n)
6526 "Open a new group based on the current article(s).
6527 This will allow you to read digests and other similar
6528 documents as newsgroups.
6529 Obeys the standard process/prefix convention."
6531 (let* ((articles (gnus-summary-work-articles n))
6532 (ogroup gnus-newsgroup-name)
6533 (params (append (gnus-info-params (gnus-get-info ogroup))
6534 (list (cons 'to-group ogroup))))
6535 article group egroup groups vgroup)
6536 (while (setq article (pop articles))
6537 (setq group (format "%s-%d" gnus-newsgroup-name article))
6538 (gnus-summary-remove-process-mark article)
6539 (when (gnus-summary-display-article article)
6541 (nnheader-temp-write nil
6542 (insert-buffer-substring gnus-original-article-buffer)
6543 ;; Remove some headers that may lead nndoc to make
6545 (message-narrow-to-head)
6546 (goto-char (point-min))
6547 (delete-matching-lines "^\\(Path\\):\\|^From ")
6550 (gnus-group-read-ephemeral-group
6551 group `(nndoc ,group (nndoc-address ,(current-buffer))
6552 (nndoc-article-type guess))
6555 ;; Make all postings to this group go to the parent group.
6556 (nconc (gnus-info-params (gnus-get-info egroup))
6558 (push egroup groups))
6559 ;; Couldn't select this doc group.
6560 (gnus-error 3 "Article couldn't be entered"))))))
6561 ;; Now we have selected all the documents.
6564 (error "None of the articles could be interpreted as documents"))
6565 ((gnus-group-read-ephemeral-group
6566 (setq vgroup (format
6567 "nnvirtual:%s-%s" gnus-newsgroup-name
6568 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6569 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6571 (cons (current-buffer) 'summary)))
6573 (error "Couldn't select virtual nndoc group")))))
6575 (defun gnus-summary-isearch-article (&optional regexp-p)
6576 "Do incremental search forward on the current article.
6577 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6579 (gnus-summary-select-article)
6580 (gnus-configure-windows 'article)
6581 (gnus-eval-in-buffer-window gnus-article-buffer
6584 (isearch-forward regexp-p))))
6586 (defun gnus-summary-search-article-forward (regexp &optional backward)
6587 "Search for an article containing REGEXP forward.
6588 If BACKWARD, search backward instead."
6591 (format "Search article %s (regexp%s): "
6592 (if current-prefix-arg "backward" "forward")
6593 (if gnus-last-search-regexp
6594 (concat ", default " gnus-last-search-regexp)
6596 current-prefix-arg))
6597 (if (string-equal regexp "")
6598 (setq regexp (or gnus-last-search-regexp ""))
6599 (setq gnus-last-search-regexp regexp))
6600 (if (gnus-summary-search-article regexp backward)
6601 (gnus-summary-show-thread)
6602 (error "Search failed: \"%s\"" regexp)))
6604 (defun gnus-summary-search-article-backward (regexp)
6605 "Search for an article containing REGEXP backward."
6608 (format "Search article backward (regexp%s): "
6609 (if gnus-last-search-regexp
6610 (concat ", default " gnus-last-search-regexp)
6612 (gnus-summary-search-article-forward regexp 'backward))
6614 (defun gnus-summary-search-article (regexp &optional backward)
6615 "Search for an article containing REGEXP.
6616 Optional argument BACKWARD means do search for backward.
6617 `gnus-select-article-hook' is not called during the search."
6618 ;; We have to require this here to make sure that the following
6619 ;; dynamic binding isn't shadowed by autoloading.
6620 (require 'gnus-async)
6621 (let ((gnus-select-article-hook nil) ;Disable hook.
6622 (gnus-article-display-hook nil)
6623 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6624 (gnus-use-article-prefetch nil)
6625 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6626 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6627 (sum (current-buffer))
6630 (gnus-save-hidden-threads
6631 (gnus-summary-select-article)
6632 (set-buffer gnus-article-buffer)
6636 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6638 (re-search-backward regexp nil t)
6639 (re-search-forward regexp nil t))
6640 ;; We found the regexp.
6645 (get-buffer-window (current-buffer))
6649 (setq point (point)))
6650 ;; We didn't find it, so we go to the next article.
6653 (while (eq found 'not)
6654 (if (not (if backward (gnus-summary-find-prev)
6655 (gnus-summary-find-next)))
6656 ;; No more articles.
6658 ;; Select the next article and adjust point.
6659 (unless (gnus-summary-article-sparse-p
6660 (gnus-summary-article-number))
6662 (gnus-summary-select-article)
6663 (set-buffer gnus-article-buffer)
6665 (goto-char (if backward (point-max) (point-min))))))))
6666 (gnus-message 7 ""))
6667 ;; Return whether we found the regexp.
6668 (when (eq found 'found)
6670 (gnus-summary-show-thread)
6671 (gnus-summary-goto-subject gnus-current-article)
6672 (gnus-summary-position-point)
6675 (defun gnus-summary-find-matching (header regexp &optional backward unread
6677 "Return a list of all articles that match REGEXP on HEADER.
6678 The search stars on the current article and goes forwards unless
6679 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6680 If UNREAD is non-nil, only unread articles will
6681 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6682 in the comparisons."
6683 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6684 (gnus-data-find-list
6685 (gnus-summary-article-number) (gnus-data-list backward))))
6686 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6687 (case-fold-search (not not-case-fold))
6689 (unless (fboundp (intern (concat "mail-header-" header)))
6690 (error "%s is not a valid header" header))
6693 (and (or (not unread) ; We want all articles...
6694 (gnus-data-unread-p d)) ; Or just unreads.
6695 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6696 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6697 (push (gnus-data-number d) articles)) ; Success!
6698 (setq data (cdr data)))
6699 (nreverse articles)))
6701 (defun gnus-summary-execute-command (header regexp command &optional backward)
6702 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6703 If HEADER is an empty string (or nil), the match is done on the entire
6704 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6706 (list (let ((completion-ignore-case t))
6709 (mapcar (lambda (string) (list string))
6710 '("Number" "Subject" "From" "Lines" "Date"
6711 "Message-ID" "Xref" "References" "Body"))
6712 nil 'require-match))
6713 (read-string "Regexp: ")
6714 (read-key-sequence "Command: ")
6715 current-prefix-arg))
6716 (when (equal header "Body")
6718 ;; Hidden thread subtrees must be searched as well.
6719 (gnus-summary-show-all-threads)
6720 ;; We don't want to change current point nor window configuration.
6722 (save-window-excursion
6723 (gnus-message 6 "Executing %s..." (key-description command))
6724 ;; We'd like to execute COMMAND interactively so as to give arguments.
6725 (gnus-execute header regexp
6726 `(call-interactively ',(key-binding command))
6728 (gnus-message 6 "Executing %s...done" (key-description command)))))
6730 (defun gnus-summary-beginning-of-article ()
6731 "Scroll the article back to the beginning."
6733 (gnus-summary-select-article)
6734 (gnus-configure-windows 'article)
6735 (gnus-eval-in-buffer-window gnus-article-buffer
6737 (goto-char (point-min))
6738 (when gnus-page-broken
6739 (gnus-narrow-to-page))))
6741 (defun gnus-summary-end-of-article ()
6742 "Scroll to the end of the article."
6744 (gnus-summary-select-article)
6745 (gnus-configure-windows 'article)
6746 (gnus-eval-in-buffer-window gnus-article-buffer
6748 (goto-char (point-max))
6750 (when gnus-page-broken
6751 (gnus-narrow-to-page))))
6753 (defun gnus-summary-print-article (&optional filename n)
6754 "Generate and print a PostScript image of the N next (mail) articles.
6756 If N is negative, print the N previous articles. If N is nil and articles
6757 have been marked with the process mark, print these instead.
6759 If the optional second argument FILENAME is nil, send the image to the
6760 printer. If FILENAME is a string, save the PostScript image in a file with
6761 that name. If FILENAME is a number, prompt the user for the name of the file
6763 (interactive (list (ps-print-preprint current-prefix-arg)
6764 current-prefix-arg))
6765 (dolist (nbr (gnus-summary-work-articles n))
6766 (gnus-summary-select-article 'all nil 'pseudo nbr)
6767 (gnus-eval-in-buffer-window gnus-article-buffer
6768 (let ((buffer (generate-new-buffer " *print*")))
6771 (copy-to-buffer buffer (point-min) (point-max))
6773 (gnus-article-delete-invisible-text)
6774 (let ((ps-left-header
6777 (mail-header-subject gnus-current-headers) ")")
6779 (mail-header-from gnus-current-headers) ")")))
6782 "/pagenumberstring load"
6784 (mail-header-date gnus-current-headers) ")"))))
6785 (run-hooks 'gnus-ps-print-hook)
6786 (ps-print-buffer-with-faces filename)))
6787 (kill-buffer buffer))))))
6789 (defun gnus-summary-show-article (&optional arg)
6790 "Force re-fetching of the current article.
6791 If ARG (the prefix) is non-nil, show the raw article without any
6792 article massaging functions being run."
6795 ;; Select the article the normal way.
6796 (gnus-summary-select-article nil 'force)
6797 ;; Bind the article treatment functions to nil.
6798 (let ((gnus-have-all-headers t)
6799 gnus-article-display-hook
6800 gnus-article-prepare-hook
6804 (gnus-summary-select-article nil 'force)))
6805 (gnus-summary-goto-subject gnus-current-article)
6806 (gnus-summary-position-point))
6808 (defun gnus-summary-verbose-headers (&optional arg)
6809 "Toggle permanent full header display.
6810 If ARG is a positive number, turn header display on.
6811 If ARG is a negative number, turn header display off."
6813 (setq gnus-show-all-headers
6814 (cond ((or (not (numberp arg))
6816 (not gnus-show-all-headers))
6819 (gnus-summary-show-article))
6821 (defun gnus-summary-toggle-header (&optional arg)
6822 "Show the headers if they are hidden, or hide them if they are shown.
6823 If ARG is a positive number, show the entire header.
6824 If ARG is a negative number, hide the unwanted header lines."
6827 (set-buffer gnus-article-buffer)
6828 (let* ((buffer-read-only nil)
6829 (inhibit-point-motion-hooks t)
6830 (hidden (text-property-any
6831 (goto-char (point-min)) (search-forward "\n\n")
6834 (goto-char (point-min))
6835 (when (search-forward "\n\n" nil t)
6836 (delete-region (point-min) (1- (point))))
6837 (goto-char (point-min))
6839 (set-buffer gnus-original-article-buffer)
6840 (goto-char (point-min))
6841 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6842 (insert-buffer-substring gnus-original-article-buffer 1 e)
6843 (let ((article-inhibit-hiding t))
6844 (run-hooks 'gnus-article-display-hook))
6845 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6846 (gnus-article-hide-headers)))))
6848 (defun gnus-summary-show-all-headers ()
6849 "Make all header lines visible."
6851 (gnus-article-show-all-headers))
6853 (defun gnus-summary-toggle-mime (&optional arg)
6854 "Toggle MIME processing.
6855 If ARG is a positive number, turn MIME processing on."
6857 (setq gnus-show-mime
6858 (if (null arg) (not gnus-show-mime)
6859 (> (prefix-numeric-value arg) 0)))
6860 (gnus-summary-select-article t 'force))
6862 (defun gnus-summary-caesar-message (&optional arg)
6863 "Caesar rotate the current article by 13.
6864 The numerical prefix specifies how many places to rotate each letter
6867 (gnus-summary-select-article)
6868 (let ((mail-header-separator ""))
6869 (gnus-eval-in-buffer-window gnus-article-buffer
6872 (let ((start (window-start))
6874 (message-caesar-buffer-body arg)
6875 (set-window-start (get-buffer-window (current-buffer)) start))))))
6877 (defun gnus-summary-stop-page-breaking ()
6878 "Stop page breaking in the current article."
6880 (gnus-summary-select-article)
6881 (gnus-eval-in-buffer-window gnus-article-buffer
6883 (when (gnus-visual-p 'page-marker)
6884 (let ((buffer-read-only nil))
6885 (gnus-remove-text-with-property 'gnus-prev)
6886 (gnus-remove-text-with-property 'gnus-next)))))
6888 (defun gnus-summary-move-article (&optional n to-newsgroup
6889 select-method action)
6890 "Move the current article to a different newsgroup.
6891 If N is a positive number, move the N next articles.
6892 If N is a negative number, move the N previous articles.
6893 If N is nil and any articles have been marked with the process mark,
6894 move those articles instead.
6895 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6896 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6897 re-spool using this method.
6899 For this function to work, both the current newsgroup and the
6900 newsgroup that you want to move to have to support the `request-move'
6901 and `request-accept' functions."
6904 (setq action 'move))
6905 ;; Disable marking as read.
6906 (let (gnus-mark-article-hook)
6907 (save-window-excursion
6908 (gnus-summary-select-article)))
6909 ;; Check whether the source group supports the required functions.
6910 (cond ((and (eq action 'move)
6911 (not (gnus-check-backend-function
6912 'request-move-article gnus-newsgroup-name)))
6913 (error "The current group does not support article moving"))
6914 ((and (eq action 'crosspost)
6915 (not (gnus-check-backend-function
6916 'request-replace-article gnus-newsgroup-name)))
6917 (error "The current group does not support article editing")))
6918 (let ((articles (gnus-summary-work-articles n))
6919 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6920 (names '((move "Move" "Moving")
6921 (copy "Copy" "Copying")
6922 (crosspost "Crosspost" "Crossposting")))
6923 (copy-buf (save-excursion
6924 (nnheader-set-temp-buffer " *copy article*")))
6925 art-group to-method new-xref article to-groups)
6926 (unless (assq action names)
6927 (error "Unknown action %s" action))
6928 ;; Read the newsgroup name.
6929 (when (and (not to-newsgroup)
6930 (not select-method))
6932 (gnus-read-move-group-name
6933 (cadr (assq action names))
6934 (symbol-value (intern (format "gnus-current-%s-group" action)))
6936 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6937 (setq to-method (or select-method
6938 (gnus-group-name-to-method to-newsgroup)))
6939 ;; Check the method we are to move this article to...
6940 (unless (gnus-check-backend-function
6941 'request-accept-article (car to-method))
6942 (error "%s does not support article copying" (car to-method)))
6943 (unless (gnus-check-server to-method)
6944 (error "Can't open server %s" (car to-method)))
6945 (gnus-message 6 "%s to %s: %s..."
6946 (caddr (assq action names))
6947 (or (car select-method) to-newsgroup) articles)
6949 (setq article (pop articles))
6953 ;; Move the article.
6955 ;; Remove this article from future suppression.
6956 (gnus-dup-unsuppress-article article)
6957 (gnus-request-move-article
6958 article ; Article to move
6959 gnus-newsgroup-name ; From newsgroup
6960 (nth 1 (gnus-find-method-for-group
6961 gnus-newsgroup-name)) ; Server
6962 (list 'gnus-request-accept-article
6963 to-newsgroup (list 'quote select-method)
6964 (not articles)) ; Accept form
6965 (not articles))) ; Only save nov last time
6966 ;; Copy the article.
6969 (set-buffer copy-buf)
6970 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6971 (gnus-request-accept-article
6972 to-newsgroup select-method (not articles)))))
6973 ;; Crosspost the article.
6974 ((eq action 'crosspost)
6975 (let ((xref (message-tokenize-header
6976 (mail-header-xref (gnus-summary-article-header article))
6978 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6981 (setq xref (list (system-name))))
6984 (mapconcat 'identity
6985 (delete "Xref:" (delete new-xref xref))
6989 (set-buffer copy-buf)
6990 ;; First put the article in the destination group.
6991 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6992 (when (consp (setq art-group
6993 (gnus-request-accept-article
6994 to-newsgroup select-method (not articles))))
6995 (setq new-xref (concat new-xref " " (car art-group)
6996 ":" (cdr art-group)))
6997 ;; Now we have the new Xrefs header, so we insert
6998 ;; it and replace the new article.
6999 (nnheader-replace-header "Xref" new-xref)
7000 (gnus-request-replace-article
7001 (cdr art-group) to-newsgroup (current-buffer))
7005 (gnus-message 1 "Couldn't %s article %s"
7006 (cadr (assq action names)) article))
7007 ((and (eq art-group 'junk)
7009 (gnus-summary-mark-article article gnus-canceled-mark)
7010 (gnus-message 4 "Deleted article %s" article))
7014 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7016 (gnus-group-prefixed-name
7019 (gnus-find-method-for-group to-newsgroup)))
7020 gnus-newsrc-hashtb)))
7021 (info (nth 2 entry))
7022 (to-group (gnus-info-group info)))
7023 ;; Update the group that has been moved to.
7025 (memq action '(move copy)))
7026 (unless (member to-group to-groups)
7027 (push to-group to-groups))
7029 (unless (memq article gnus-newsgroup-unreads)
7031 info (gnus-add-to-range (gnus-info-read info)
7032 (list (cdr art-group)))))
7034 ;; Copy any marks over to the new group.
7035 (let ((marks gnus-article-mark-lists)
7036 (to-article (cdr art-group)))
7038 ;; See whether the article is to be put in the cache.
7039 (when gnus-use-cache
7040 (gnus-cache-possibly-enter-article
7042 (let ((header (copy-sequence
7043 (gnus-summary-article-header article))))
7044 (mail-header-set-number header to-article)
7046 (memq article gnus-newsgroup-marked)
7047 (memq article gnus-newsgroup-dormant)
7048 (memq article gnus-newsgroup-unreads)))
7050 (when (and (equal to-group gnus-newsgroup-name)
7051 (not (memq article gnus-newsgroup-unreads)))
7052 ;; Mark this article as read in this group.
7053 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7054 (setcdr (gnus-active to-group) to-article)
7055 (setcdr gnus-newsgroup-active to-article))
7058 (when (memq article (symbol-value
7059 (intern (format "gnus-newsgroup-%s"
7061 ;; If the other group is the same as this group,
7062 ;; then we have to add the mark to the list.
7063 (when (equal to-group gnus-newsgroup-name)
7064 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7067 (intern (format "gnus-newsgroup-%s"
7069 ;; Copy the marks to other group.
7070 (gnus-add-marked-articles
7071 to-group (cdar marks) (list to-article) info))
7072 (setq marks (cdr marks)))
7075 (concat "(gnus-group-set-info '"
7076 (gnus-prin1-to-string (gnus-get-info to-group))
7079 ;; Update the Xref header in this article to point to
7080 ;; the new crossposted article we have just created.
7081 (when (eq action 'crosspost)
7083 (set-buffer copy-buf)
7084 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7085 (nnheader-replace-header "Xref" new-xref)
7086 (gnus-request-replace-article
7087 article gnus-newsgroup-name (current-buffer)))))
7089 ;;;!!!Why is this necessary?
7090 (set-buffer gnus-summary-buffer)
7092 (gnus-summary-goto-subject article)
7093 (when (eq action 'move)
7094 (gnus-summary-mark-article article gnus-canceled-mark))))
7095 (gnus-summary-remove-process-mark article))
7096 ;; Re-activate all groups that have been moved to.
7099 (set-buffer gnus-group-buffer)
7100 (when (gnus-group-goto-group (car to-groups) t)
7101 (gnus-group-get-new-news-this-group 1 t))
7104 (gnus-kill-buffer copy-buf)
7105 (gnus-summary-position-point)
7106 (gnus-set-mode-line 'summary)))
7108 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7109 "Move the current article to a different newsgroup.
7110 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7111 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7112 re-spool using this method."
7114 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7116 (defun gnus-summary-crosspost-article (&optional n)
7117 "Crosspost the current article to some other group."
7119 (gnus-summary-move-article n nil nil 'crosspost))
7121 (defcustom gnus-summary-respool-default-method nil
7122 "Default method for respooling an article.
7123 If nil, use to the current newsgroup method."
7124 :type `(choice (gnus-select-method :value (nnml ""))
7126 :group 'gnus-summary-mail)
7128 (defun gnus-summary-respool-article (&optional n method)
7129 "Respool the current article.
7130 The article will be squeezed through the mail spooling process again,
7131 which means that it will be put in some mail newsgroup or other
7132 depending on `nnmail-split-methods'.
7133 If N is a positive number, respool the N next articles.
7134 If N is a negative number, respool the N previous articles.
7135 If N is nil and any articles have been marked with the process mark,
7136 respool those articles instead.
7138 Respooling can be done both from mail groups and \"real\" newsgroups.
7139 In the former case, the articles in question will be moved from the
7140 current group into whatever groups they are destined to. In the
7141 latter case, they will be copied into the relevant groups."
7143 (list current-prefix-arg
7144 (let* ((methods (gnus-methods-using 'respool))
7146 (symbol-name (or gnus-summary-respool-default-method
7147 (car (gnus-find-method-for-group
7148 gnus-newsgroup-name)))))
7150 (gnus-completing-read
7151 methname "What backend do you want to use when respooling?"
7152 methods nil t nil 'gnus-mail-method-history))
7155 ((zerop (length (setq ms (gnus-servers-using-backend
7157 (list (intern method) ""))
7161 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7162 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7165 (error "No method given for respooling"))
7166 (if (assoc (symbol-name
7167 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7168 (gnus-methods-using 'respool))
7169 (gnus-summary-move-article n nil method)
7170 (gnus-summary-copy-article n nil method)))
7172 (defun gnus-summary-import-article (file)
7173 "Import a random file into a mail newsgroup."
7174 (interactive "fImport file: ")
7175 (let ((group gnus-newsgroup-name)
7176 (now (current-time))
7178 (unless (gnus-check-backend-function 'request-accept-article group)
7179 (error "%s does not support article importing" group))
7180 (or (file-readable-p file)
7181 (not (file-regular-p file))
7182 (error "Can't read %s" file))
7184 (set-buffer (get-buffer-create " *import file*"))
7185 (buffer-disable-undo (current-buffer))
7187 (insert-file-contents file)
7188 (goto-char (point-min))
7189 (unless (nnheader-article-p)
7190 ;; This doesn't look like an article, so we fudge some headers.
7191 (setq atts (file-attributes file)
7192 lines (count-lines (point-min) (point-max)))
7193 (insert "From: " (read-string "From: ") "\n"
7194 "Subject: " (read-string "Subject: ") "\n"
7195 "Date: " (timezone-make-date-arpa-standard
7196 (current-time-string (nth 5 atts))
7197 (current-time-zone now)
7198 (current-time-zone now))
7200 "Message-ID: " (message-make-message-id) "\n"
7201 "Lines: " (int-to-string lines) "\n"
7202 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7203 (gnus-request-accept-article group nil t)
7204 (kill-buffer (current-buffer)))))
7206 (defun gnus-summary-article-posted-p ()
7207 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7208 This will be the case if the article has both been mailed and posted."
7210 (let ((id (mail-header-references (gnus-summary-article-header)))
7211 (gnus-override-method
7212 (or gnus-refer-article-method gnus-select-method)))
7213 (if (gnus-request-head id "")
7214 (gnus-message 2 "The current message was found on %s"
7215 gnus-override-method)
7216 (gnus-message 2 "The current message couldn't be found on %s"
7217 gnus-override-method)
7220 (defun gnus-summary-expire-articles (&optional now)
7221 "Expire all articles that are marked as expirable in the current group."
7223 (when (gnus-check-backend-function
7224 'request-expire-articles gnus-newsgroup-name)
7225 ;; This backend supports expiry.
7226 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7227 (expirable (if total
7229 ;; We need to update the info for
7230 ;; this group for `gnus-list-of-read-articles'
7231 ;; to give us the right answer.
7232 (run-hooks 'gnus-exit-group-hook)
7233 (gnus-summary-update-info)
7234 (gnus-list-of-read-articles gnus-newsgroup-name))
7235 (setq gnus-newsgroup-expirable
7236 (sort gnus-newsgroup-expirable '<))))
7237 (expiry-wait (if now 'immediate
7238 (gnus-group-find-parameter
7239 gnus-newsgroup-name 'expiry-wait)))
7242 ;; There are expirable articles in this group, so we run them
7243 ;; through the expiry process.
7244 (gnus-message 6 "Expiring articles...")
7245 ;; The list of articles that weren't expired is returned.
7247 (let ((nnmail-expiry-wait-function nil)
7248 (nnmail-expiry-wait expiry-wait))
7249 (setq es (gnus-request-expire-articles
7250 expirable gnus-newsgroup-name)))
7251 (setq es (gnus-request-expire-articles
7252 expirable gnus-newsgroup-name)))
7254 (setq gnus-newsgroup-expirable es))
7255 ;; We go through the old list of expirable, and mark all
7256 ;; really expired articles as nonexistent.
7257 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7258 (let ((gnus-use-cache nil))
7260 (unless (memq (car expirable) es)
7261 (when (gnus-data-find (car expirable))
7262 (gnus-summary-mark-article
7263 (car expirable) gnus-canceled-mark)))
7264 (setq expirable (cdr expirable)))))
7265 (gnus-message 6 "Expiring articles...done")))))
7267 (defun gnus-summary-expire-articles-now ()
7268 "Expunge all expirable articles in the current group.
7269 This means that *all* articles that are marked as expirable will be
7270 deleted forever, right now."
7272 (or gnus-expert-user
7274 "Are you really, really, really sure you want to delete all these messages? ")
7276 (gnus-summary-expire-articles t))
7278 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7279 (defun gnus-summary-delete-article (&optional n)
7280 "Delete the N next (mail) articles.
7281 This command actually deletes articles. This is not a marking
7282 command. The article will disappear forever from your life, never to
7284 If N is negative, delete backwards.
7285 If N is nil and articles have been marked with the process mark,
7286 delete these instead."
7288 (unless (gnus-check-backend-function 'request-expire-articles
7289 gnus-newsgroup-name)
7290 (error "The current newsgroup does not support article deletion"))
7291 ;; Compute the list of articles to delete.
7292 (let ((articles (gnus-summary-work-articles n))
7294 (if (and gnus-novice-user
7295 (not (gnus-yes-or-no-p
7296 (format "Do you really want to delete %s forever? "
7297 (if (> (length articles) 1)
7298 (format "these %s articles" (length articles))
7301 ;; Delete the articles.
7302 (setq not-deleted (gnus-request-expire-articles
7303 articles gnus-newsgroup-name 'force))
7305 (gnus-summary-remove-process-mark (car articles))
7306 ;; The backend might not have been able to delete the article
7308 (unless (memq (car articles) not-deleted)
7309 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7310 (setq articles (cdr articles)))
7312 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7313 (gnus-summary-position-point)
7314 (gnus-set-mode-line 'summary)
7317 (defun gnus-summary-edit-article (&optional force)
7318 "Edit the current article.
7319 This will have permanent effect only in mail groups.
7320 If FORCE is non-nil, allow editing of articles even in read-only
7324 (set-buffer gnus-summary-buffer)
7325 (gnus-set-global-variables)
7326 (when (and (not force)
7327 (gnus-group-read-only-p))
7328 (error "The current newsgroup does not support article editing"))
7329 ;; Select article if needed.
7330 (unless (eq (gnus-summary-article-number)
7331 gnus-current-article)
7332 (gnus-summary-select-article t))
7333 (gnus-article-date-original)
7334 (gnus-article-edit-article
7335 `(lambda (no-highlight)
7336 (gnus-summary-edit-article-done
7337 ,(or (mail-header-references gnus-current-headers) "")
7338 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
7340 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7342 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7344 "Make edits to the current article permanent."
7346 ;; Replace the article.
7347 (if (and (not read-only)
7348 (not (gnus-request-replace-article
7349 (cdr gnus-article-current) (car gnus-article-current)
7351 (error "Couldn't replace article")
7352 ;; Update the summary buffer.
7354 (equal (message-tokenize-header references " ")
7355 (message-tokenize-header
7356 (or (message-fetch-field "references") "") " ")))
7357 ;; We only have to update this line.
7360 (message-narrow-to-head)
7361 (let ((head (buffer-string))
7363 (nnheader-temp-write nil
7364 (insert (format "211 %d Article retrieved.\n"
7365 (cdr gnus-article-current)))
7368 (let ((nntp-server-buffer (current-buffer)))
7369 (setq header (car (gnus-get-newsgroup-headers
7371 (set-buffer gnus-summary-buffer)
7372 gnus-newsgroup-dependencies)
7375 (set-buffer gnus-summary-buffer)
7376 (gnus-data-set-header
7377 (gnus-data-find (cdr gnus-article-current))
7379 (gnus-summary-update-article-line
7380 (cdr gnus-article-current) header))))))
7382 (set-buffer (or buffer gnus-summary-buffer))
7383 (gnus-summary-update-article (cdr gnus-article-current)))
7384 ;; Prettify the article buffer again.
7385 (unless no-highlight
7387 (set-buffer gnus-article-buffer)
7388 (run-hooks 'gnus-article-display-hook)
7389 (set-buffer gnus-original-article-buffer)
7390 (gnus-request-article
7391 (cdr gnus-article-current)
7392 (car gnus-article-current) (current-buffer))))
7393 ;; Prettify the summary buffer line.
7394 (when (gnus-visual-p 'summary-highlight 'highlight)
7395 (run-hooks 'gnus-visual-mark-article-hook))))
7397 (defun gnus-summary-edit-wash (key)
7398 "Perform editing command in the article buffer."
7402 (message "%s" (concat (this-command-keys) "- "))
7405 (gnus-summary-edit-article)
7406 (execute-kbd-macro (concat (this-command-keys) key))
7407 (gnus-article-edit-done))
7411 (defun gnus-summary-respool-query (&optional silent)
7412 "Query where the respool algorithm would put this article."
7414 (let (gnus-mark-article-hook)
7415 (gnus-summary-select-article)
7417 (set-buffer gnus-original-article-buffer)
7419 (message-narrow-to-head)
7420 (let ((groups (nnmail-article-group 'identity)))
7423 (message "This message would go to %s"
7424 (mapconcat 'car groups ", "))
7425 (message "This message would go to no groups"))
7428 ;; Summary marking commands.
7430 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7431 "Mark articles which has the same subject as read, and then select the next.
7432 If UNMARK is positive, remove any kind of mark.
7433 If UNMARK is negative, tick articles."
7436 (setq unmark (prefix-numeric-value unmark)))
7438 (gnus-summary-mark-same-subject
7439 (gnus-summary-article-subject) unmark)))
7440 ;; Select next unread article. If auto-select-same mode, should
7441 ;; select the first unread article.
7442 (gnus-summary-next-article t (and gnus-auto-select-same
7443 (gnus-summary-article-subject)))
7444 (gnus-message 7 "%d article%s marked as %s"
7445 count (if (= count 1) " is" "s are")
7446 (if unmark "unread" "read"))))
7448 (defun gnus-summary-kill-same-subject (&optional unmark)
7449 "Mark articles which has the same subject as read.
7450 If UNMARK is positive, remove any kind of mark.
7451 If UNMARK is negative, tick articles."
7454 (setq unmark (prefix-numeric-value unmark)))
7456 (gnus-summary-mark-same-subject
7457 (gnus-summary-article-subject) unmark)))
7458 ;; If marked as read, go to next unread subject.
7460 ;; Go to next unread subject.
7461 (gnus-summary-next-subject 1 t))
7462 (gnus-message 7 "%d articles are marked as %s"
7463 count (if unmark "unread" "read"))))
7465 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7466 "Mark articles with same SUBJECT as read, and return marked number.
7467 If optional argument UNMARK is positive, remove any kinds of marks.
7468 If optional argument UNMARK is negative, mark articles as unread instead."
7472 ((null unmark) ; Mark as read.
7475 (gnus-summary-mark-article-as-read gnus-killed-mark)
7476 (gnus-summary-show-thread) t)
7477 (gnus-summary-find-subject subject))
7478 (setq count (1+ count))))
7479 ((> unmark 0) ; Tick.
7482 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7483 (gnus-summary-show-thread) t)
7484 (gnus-summary-find-subject subject))
7485 (setq count (1+ count))))
7486 (t ; Mark as unread.
7489 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7490 (gnus-summary-show-thread) t)
7491 (gnus-summary-find-subject subject))
7492 (setq count (1+ count)))))
7493 (gnus-set-mode-line 'summary)
7494 ;; Return the number of marked articles.
7497 (defun gnus-summary-mark-as-processable (n &optional unmark)
7498 "Set the process mark on the next N articles.
7499 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7500 the process mark instead. The difference between N and the actual
7501 number of articles marked is returned."
7503 (let ((backward (< n 0))
7508 (gnus-summary-remove-process-mark
7509 (gnus-summary-article-number))
7510 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7511 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7514 (gnus-message 7 "No more articles"))
7515 (gnus-summary-recenter)
7516 (gnus-summary-position-point)
7519 (defun gnus-summary-unmark-as-processable (n)
7520 "Remove the process mark from the next N articles.
7521 If N is negative, unmark backward instead. The difference between N and
7522 the actual number of articles unmarked is returned."
7524 (gnus-summary-mark-as-processable n t))
7526 (defun gnus-summary-unmark-all-processable ()
7527 "Remove the process mark from all articles."
7530 (while gnus-newsgroup-processable
7531 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7532 (gnus-summary-position-point))
7534 (defun gnus-summary-mark-as-expirable (n)
7535 "Mark N articles forward as expirable.
7536 If N is negative, mark backward instead. The difference between N and
7537 the actual number of articles marked is returned."
7539 (gnus-summary-mark-forward n gnus-expirable-mark))
7541 (defun gnus-summary-mark-article-as-replied (article)
7542 "Mark ARTICLE replied and update the summary line."
7543 (push article gnus-newsgroup-replied)
7544 (let ((buffer-read-only nil))
7545 (when (gnus-summary-goto-subject article)
7546 (gnus-summary-update-secondary-mark article))))
7548 (defun gnus-summary-set-bookmark (article)
7549 "Set a bookmark in current article."
7550 (interactive (list (gnus-summary-article-number)))
7551 (when (or (not (get-buffer gnus-article-buffer))
7552 (not gnus-current-article)
7553 (not gnus-article-current)
7554 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7555 (error "No current article selected"))
7556 ;; Remove old bookmark, if one exists.
7557 (let ((old (assq article gnus-newsgroup-bookmarks)))
7559 (setq gnus-newsgroup-bookmarks
7560 (delq old gnus-newsgroup-bookmarks))))
7561 ;; Set the new bookmark, which is on the form
7562 ;; (article-number . line-number-in-body).
7566 (set-buffer gnus-article-buffer)
7570 (goto-char (point-min))
7571 (search-forward "\n\n" nil t)
7574 gnus-newsgroup-bookmarks)
7575 (gnus-message 6 "A bookmark has been added to the current article."))
7577 (defun gnus-summary-remove-bookmark (article)
7578 "Remove the bookmark from the current article."
7579 (interactive (list (gnus-summary-article-number)))
7580 ;; Remove old bookmark, if one exists.
7581 (let ((old (assq article gnus-newsgroup-bookmarks)))
7584 (setq gnus-newsgroup-bookmarks
7585 (delq old gnus-newsgroup-bookmarks))
7586 (gnus-message 6 "Removed bookmark."))
7587 (gnus-message 6 "No bookmark in current article."))))
7589 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7590 (defun gnus-summary-mark-as-dormant (n)
7591 "Mark N articles forward as dormant.
7592 If N is negative, mark backward instead. The difference between N and
7593 the actual number of articles marked is returned."
7595 (gnus-summary-mark-forward n gnus-dormant-mark))
7597 (defun gnus-summary-set-process-mark (article)
7598 "Set the process mark on ARTICLE and update the summary line."
7599 (setq gnus-newsgroup-processable
7601 (delq article gnus-newsgroup-processable)))
7602 (when (gnus-summary-goto-subject article)
7603 (gnus-summary-show-thread)
7604 (gnus-summary-update-secondary-mark article)))
7606 (defun gnus-summary-remove-process-mark (article)
7607 "Remove the process mark from ARTICLE and update the summary line."
7608 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7609 (when (gnus-summary-goto-subject article)
7610 (gnus-summary-show-thread)
7611 (gnus-summary-update-secondary-mark article)))
7613 (defun gnus-summary-set-saved-mark (article)
7614 "Set the process mark on ARTICLE and update the summary line."
7615 (push article gnus-newsgroup-saved)
7616 (when (gnus-summary-goto-subject article)
7617 (gnus-summary-update-secondary-mark article)))
7619 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7620 "Mark N articles as read forwards.
7621 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7622 The difference between N and the actual number of articles marked is
7625 (let ((backward (< n 0))
7626 (gnus-summary-goto-unread
7627 (and gnus-summary-goto-unread
7628 (not (eq gnus-summary-goto-unread 'never))
7629 (not (memq mark (list gnus-unread-mark
7630 gnus-ticked-mark gnus-dormant-mark)))))
7632 (mark (or mark gnus-del-mark)))
7634 (gnus-summary-mark-article nil mark no-expire)
7635 (zerop (gnus-summary-next-subject
7637 (and gnus-summary-goto-unread
7638 (not (eq gnus-summary-goto-unread 'never)))
7642 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7643 (gnus-summary-recenter)
7644 (gnus-summary-position-point)
7645 (gnus-set-mode-line 'summary)
7648 (defun gnus-summary-mark-article-as-read (mark)
7649 "Mark the current article quickly as read with MARK."
7650 (let ((article (gnus-summary-article-number)))
7651 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7652 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7653 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7654 (push (cons article mark) gnus-newsgroup-reads)
7655 ;; Possibly remove from cache, if that is used.
7656 (when gnus-use-cache
7657 (gnus-cache-enter-remove-article article))
7658 ;; Allow the backend to change the mark.
7659 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7660 ;; Check for auto-expiry.
7661 (when (and gnus-newsgroup-auto-expire
7662 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7663 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7664 (= mark gnus-ancient-mark)
7665 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7666 (= mark gnus-duplicate-mark)))
7667 (setq mark gnus-expirable-mark)
7668 (push article gnus-newsgroup-expirable))
7669 ;; Set the mark in the buffer.
7670 (gnus-summary-update-mark mark 'unread)
7673 (defun gnus-summary-mark-article-as-unread (mark)
7674 "Mark the current article quickly as unread with MARK."
7675 (let ((article (gnus-summary-article-number)))
7678 (gnus-error 1 "Can't mark negative article numbers")
7680 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7681 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7682 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7683 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7684 (cond ((= mark gnus-ticked-mark)
7685 (push article gnus-newsgroup-marked))
7686 ((= mark gnus-dormant-mark)
7687 (push article gnus-newsgroup-dormant))
7689 (push article gnus-newsgroup-unreads)))
7690 (setq gnus-newsgroup-reads
7691 (delq (assq article gnus-newsgroup-reads)
7692 gnus-newsgroup-reads))
7694 ;; See whether the article is to be put in the cache.
7696 (vectorp (gnus-summary-article-header article))
7698 (gnus-cache-possibly-enter-article
7699 gnus-newsgroup-name article
7700 (gnus-summary-article-header article)
7701 (= mark gnus-ticked-mark)
7702 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7705 (gnus-summary-update-mark mark 'unread)
7708 (defun gnus-summary-mark-article (&optional article mark no-expire)
7709 "Mark ARTICLE with MARK. MARK can be any character.
7710 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7711 `??' (dormant) and `?E' (expirable).
7712 If MARK is nil, then the default character `?D' is used.
7713 If ARTICLE is nil, then the article on the current line will be
7715 ;; The mark might be a string.
7716 (when (stringp mark)
7717 (setq mark (aref mark 0)))
7718 ;; If no mark is given, then we check auto-expiring.
7719 (and (not no-expire)
7720 gnus-newsgroup-auto-expire
7722 (and (gnus-characterp mark)
7723 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7724 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7725 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7726 (= mark gnus-duplicate-mark))))
7727 (setq mark gnus-expirable-mark))
7728 (let* ((mark (or mark gnus-del-mark))
7729 (article (or article (gnus-summary-article-number))))
7731 (error "No article on current line"))
7732 (if (not (if (or (= mark gnus-unread-mark)
7733 (= mark gnus-ticked-mark)
7734 (= mark gnus-dormant-mark))
7735 (gnus-mark-article-as-unread article mark)
7736 (gnus-mark-article-as-read article mark)))
7738 ;; See whether the article is to be put in the cache.
7740 (not (= mark gnus-canceled-mark))
7741 (vectorp (gnus-summary-article-header article))
7743 (gnus-cache-possibly-enter-article
7744 gnus-newsgroup-name article
7745 (gnus-summary-article-header article)
7746 (= mark gnus-ticked-mark)
7747 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7749 (when (gnus-summary-goto-subject article nil t)
7750 (let ((buffer-read-only nil))
7751 (gnus-summary-show-thread)
7753 (gnus-summary-update-mark mark 'unread)
7756 (defun gnus-summary-update-secondary-mark (article)
7757 "Update the secondary (read, process, cache) mark."
7758 (gnus-summary-update-mark
7759 (cond ((memq article gnus-newsgroup-processable)
7761 ((memq article gnus-newsgroup-cached)
7763 ((memq article gnus-newsgroup-replied)
7765 ((memq article gnus-newsgroup-saved)
7767 (t gnus-unread-mark))
7769 (when (gnus-visual-p 'summary-highlight 'highlight)
7770 (run-hooks 'gnus-summary-update-hook))
7773 (defun gnus-summary-update-mark (mark type)
7774 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7775 (buffer-read-only nil))
7776 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7777 (when (looking-at "\r")
7780 (<= (+ forward (point)) (point-max)))
7781 ;; Go to the right position on the line.
7782 (goto-char (+ forward (point)))
7783 ;; Replace the old mark with the new mark.
7784 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7785 ;; Optionally update the marks by some user rule.
7786 (when (eq type 'unread)
7788 (gnus-data-find (gnus-summary-article-number)) mark)
7789 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7791 (defun gnus-mark-article-as-read (article &optional mark)
7792 "Enter ARTICLE in the pertinent lists and remove it from others."
7793 ;; Make the article expirable.
7794 (let ((mark (or mark gnus-del-mark)))
7795 (if (= mark gnus-expirable-mark)
7796 (push article gnus-newsgroup-expirable)
7797 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7798 ;; Remove from unread and marked lists.
7799 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7800 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7801 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7802 (push (cons article mark) gnus-newsgroup-reads)
7803 ;; Possibly remove from cache, if that is used.
7804 (when gnus-use-cache
7805 (gnus-cache-enter-remove-article article))))
7807 (defun gnus-mark-article-as-unread (article &optional mark)
7808 "Enter ARTICLE in the pertinent lists and remove it from others."
7809 (let ((mark (or mark gnus-ticked-mark)))
7812 (gnus-error 1 "Can't mark negative article numbers")
7814 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7815 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7816 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7817 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7819 ;; Unsuppress duplicates?
7820 (when gnus-suppress-duplicates
7821 (gnus-dup-unsuppress-article article))
7823 (cond ((= mark gnus-ticked-mark)
7824 (push article gnus-newsgroup-marked))
7825 ((= mark gnus-dormant-mark)
7826 (push article gnus-newsgroup-dormant))
7828 (push article gnus-newsgroup-unreads)))
7829 (setq gnus-newsgroup-reads
7830 (delq (assq article gnus-newsgroup-reads)
7831 gnus-newsgroup-reads))
7834 (defalias 'gnus-summary-mark-as-unread-forward
7835 'gnus-summary-tick-article-forward)
7836 (make-obsolete 'gnus-summary-mark-as-unread-forward
7837 'gnus-summary-tick-article-forward)
7838 (defun gnus-summary-tick-article-forward (n)
7839 "Tick N articles forwards.
7840 If N is negative, tick backwards instead.
7841 The difference between N and the number of articles ticked is returned."
7843 (gnus-summary-mark-forward n gnus-ticked-mark))
7845 (defalias 'gnus-summary-mark-as-unread-backward
7846 'gnus-summary-tick-article-backward)
7847 (make-obsolete 'gnus-summary-mark-as-unread-backward
7848 'gnus-summary-tick-article-backward)
7849 (defun gnus-summary-tick-article-backward (n)
7850 "Tick N articles backwards.
7851 The difference between N and the number of articles ticked is returned."
7853 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7855 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7856 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7857 (defun gnus-summary-tick-article (&optional article clear-mark)
7858 "Mark current article as unread.
7859 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7860 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7862 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7865 (defun gnus-summary-mark-as-read-forward (n)
7866 "Mark N articles as read forwards.
7867 If N is negative, mark backwards instead.
7868 The difference between N and the actual number of articles marked is
7871 (gnus-summary-mark-forward n gnus-del-mark t))
7873 (defun gnus-summary-mark-as-read-backward (n)
7874 "Mark the N articles as read backwards.
7875 The difference between N and the actual number of articles marked is
7878 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7880 (defun gnus-summary-mark-as-read (&optional article mark)
7881 "Mark current article as read.
7882 ARTICLE specifies the article to be marked as read.
7883 MARK specifies a string to be inserted at the beginning of the line."
7884 (gnus-summary-mark-article article mark))
7886 (defun gnus-summary-clear-mark-forward (n)
7887 "Clear marks from N articles forward.
7888 If N is negative, clear backward instead.
7889 The difference between N and the number of marks cleared is returned."
7891 (gnus-summary-mark-forward n gnus-unread-mark))
7893 (defun gnus-summary-clear-mark-backward (n)
7894 "Clear marks from N articles backward.
7895 The difference between N and the number of marks cleared is returned."
7897 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7899 (defun gnus-summary-mark-unread-as-read ()
7900 "Intended to be used by `gnus-summary-mark-article-hook'."
7901 (when (memq gnus-current-article gnus-newsgroup-unreads)
7902 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7904 (defun gnus-summary-mark-read-and-unread-as-read ()
7905 "Intended to be used by `gnus-summary-mark-article-hook'."
7906 (let ((mark (gnus-summary-article-mark)))
7907 (when (or (gnus-unread-mark-p mark)
7908 (gnus-read-mark-p mark))
7909 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7911 (defun gnus-summary-mark-region-as-read (point mark all)
7912 "Mark all unread articles between point and mark as read.
7913 If given a prefix, mark all articles between point and mark as read,
7914 even ticked and dormant ones."
7915 (interactive "r\nP")
7924 (memq (setq article (gnus-summary-article-number))
7925 gnus-newsgroup-unreads))
7926 (gnus-summary-mark-article article gnus-del-mark))
7928 (gnus-summary-find-next))))))
7930 (defun gnus-summary-mark-below (score mark)
7931 "Mark articles with score less than SCORE with MARK."
7932 (interactive "P\ncMark: ")
7933 (setq score (if score
7934 (prefix-numeric-value score)
7935 (or gnus-summary-default-score 0)))
7937 (set-buffer gnus-summary-buffer)
7938 (goto-char (point-min))
7941 (and (< (gnus-summary-article-score) score)
7942 (gnus-summary-mark-article nil mark))
7943 (gnus-summary-find-next)))))
7945 (defun gnus-summary-kill-below (&optional score)
7946 "Mark articles with score below SCORE as read."
7948 (gnus-summary-mark-below score gnus-killed-mark))
7950 (defun gnus-summary-clear-above (&optional score)
7951 "Clear all marks from articles with score above SCORE."
7953 (gnus-summary-mark-above score gnus-unread-mark))
7955 (defun gnus-summary-tick-above (&optional score)
7956 "Tick all articles with score above SCORE."
7958 (gnus-summary-mark-above score gnus-ticked-mark))
7960 (defun gnus-summary-mark-above (score mark)
7961 "Mark articles with score over SCORE with MARK."
7962 (interactive "P\ncMark: ")
7963 (setq score (if score
7964 (prefix-numeric-value score)
7965 (or gnus-summary-default-score 0)))
7967 (set-buffer gnus-summary-buffer)
7968 (goto-char (point-min))
7970 (when (> (gnus-summary-article-score) score)
7971 (gnus-summary-mark-article nil mark))
7973 (gnus-summary-find-next)))))
7975 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7976 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7977 (defun gnus-summary-limit-include-expunged (&optional no-error)
7978 "Display all the hidden articles that were expunged for low scores."
7980 (let ((buffer-read-only nil))
7981 (let ((scored gnus-newsgroup-scored)
7984 (unless (gnus-summary-goto-subject (caar scored))
7985 (and (setq h (gnus-summary-article-header (caar scored)))
7986 (< (cdar scored) gnus-summary-expunge-below)
7988 (setq scored (cdr scored)))
7990 (when (not no-error)
7991 (error "No expunged articles hidden"))
7992 (goto-char (point-min))
7993 (gnus-summary-prepare-unthreaded (nreverse headers))
7994 (goto-char (point-min))
7995 (gnus-summary-position-point)
7998 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7999 "Mark all unread articles in this newsgroup as read.
8000 If prefix argument ALL is non-nil, ticked and dormant articles will
8001 also be marked as read.
8002 If QUIETLY is non-nil, no questions will be asked.
8003 If TO-HERE is non-nil, it should be a point in the buffer. All
8004 articles before this point will be marked as read.
8005 Note that this function will only catch up the unread article
8006 in the current summary buffer limitation.
8007 The number of articles marked as read is returned."
8012 (not gnus-interactive-catchup) ;Without confirmation?
8016 "Mark absolutely all articles as read? "
8017 "Mark all unread articles as read? ")))
8019 (not gnus-newsgroup-adaptive)
8020 (not gnus-newsgroup-auto-expire)
8021 (not gnus-suppress-duplicates)
8022 (or (not gnus-use-cache)
8023 (eq gnus-use-cache 'passive)))
8026 (setq gnus-newsgroup-marked nil
8027 gnus-newsgroup-dormant nil))
8028 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8029 ;; We actually mark all articles as canceled, which we
8030 ;; have to do when using auto-expiry or adaptive scoring.
8031 (gnus-summary-show-all-threads)
8032 (when (gnus-summary-first-subject (not all))
8034 (if to-here (< (point) to-here) t)
8035 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8036 (gnus-summary-find-next (not all)))))
8037 (gnus-set-mode-line 'summary))
8039 (gnus-summary-position-point)))
8041 (defun gnus-summary-catchup-to-here (&optional all)
8042 "Mark all unticked articles before the current one as read.
8043 If ALL is non-nil, also mark ticked and dormant articles as read."
8046 (gnus-save-hidden-threads
8047 (let ((beg (point)))
8048 ;; We check that there are unread articles.
8049 (when (or all (gnus-summary-find-prev))
8050 (gnus-summary-catchup all t beg)))))
8051 (gnus-summary-position-point))
8053 (defun gnus-summary-catchup-all (&optional quietly)
8054 "Mark all articles in this newsgroup as read."
8056 (gnus-summary-catchup t quietly))
8058 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8059 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8060 If prefix argument ALL is non-nil, all articles are marked as read."
8062 (when (gnus-summary-catchup all quietly nil 'fast)
8063 ;; Select next newsgroup or exit.
8064 (if (eq gnus-auto-select-next 'quietly)
8065 (gnus-summary-next-group nil)
8066 (gnus-summary-exit))))
8068 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8069 "Mark all articles in this newsgroup as read, and then exit."
8071 (gnus-summary-catchup-and-exit t quietly))
8073 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8074 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8075 "Mark all articles in this group as read and select the next group.
8076 If given a prefix, mark all articles, unread as well as ticked, as
8080 (gnus-summary-catchup all))
8081 (gnus-summary-next-article t nil nil t))
8083 ;; Thread-based commands.
8085 (defun gnus-summary-articles-in-thread (&optional article)
8086 "Return a list of all articles in the current thread.
8087 If ARTICLE is non-nil, return all articles in the thread that starts
8089 (let* ((article (or article (gnus-summary-article-number)))
8090 (data (gnus-data-find-list article))
8091 (top-level (gnus-data-level (car data)))
8093 (cond ((null gnus-thread-operation-ignore-subject)
8094 (gnus-simplify-subject-re
8095 (mail-header-subject (gnus-data-header (car data)))))
8096 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8097 (gnus-simplify-subject-fuzzy
8098 (mail-header-subject (gnus-data-header (car data)))))
8100 (end-point (save-excursion
8101 (if (gnus-summary-go-to-next-thread)
8102 (point) (point-max))))
8105 (< (gnus-data-pos (car data)) end-point))
8106 (when (or (not top-subject)
8107 (string= top-subject
8108 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8109 (gnus-simplify-subject-fuzzy
8110 (mail-header-subject
8111 (gnus-data-header (car data))))
8112 (gnus-simplify-subject-re
8113 (mail-header-subject
8114 (gnus-data-header (car data)))))))
8115 (push (gnus-data-number (car data)) articles))
8116 (unless (and (setq data (cdr data))
8117 (> (gnus-data-level (car data)) top-level))
8119 ;; Return the list of articles.
8120 (nreverse articles)))
8122 (defun gnus-summary-rethread-current ()
8123 "Rethread the thread the current article is part of."
8125 (let* ((gnus-show-threads t)
8126 (article (gnus-summary-article-number))
8127 (id (mail-header-id (gnus-summary-article-header)))
8128 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8130 (error "No article on the current line"))
8131 (gnus-rebuild-thread id)
8132 (gnus-summary-goto-subject article)))
8134 (defun gnus-summary-reparent-thread ()
8135 "Make the current article child of the marked (or previous) article.
8137 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8138 is non-nil or the Subject: of both articles are the same."
8140 (unless (not (gnus-group-read-only-p))
8141 (error "The current newsgroup does not support article editing"))
8142 (unless (<= (length gnus-newsgroup-processable) 1)
8143 (error "No more than one article may be marked"))
8144 (save-window-excursion
8145 (let ((gnus-article-buffer " *reparent*")
8146 (current-article (gnus-summary-article-number))
8147 ;; First grab the marked article, otherwise one line up.
8148 (parent-article (if (not (null gnus-newsgroup-processable))
8149 (car gnus-newsgroup-processable)
8151 (if (eq (forward-line -1) 0)
8152 (gnus-summary-article-number)
8153 (error "Beginning of summary buffer"))))))
8154 (unless (not (eq current-article parent-article))
8155 (error "An article may not be self-referential"))
8156 (let ((message-id (mail-header-id
8157 (gnus-summary-article-header parent-article))))
8158 (unless (and message-id (not (equal message-id "")))
8159 (error "No message-id in desired parent"))
8160 (gnus-summary-select-article t t nil current-article)
8161 (set-buffer gnus-original-article-buffer)
8162 (let ((buf (format "%s" (buffer-string))))
8163 (nnheader-temp-write nil
8165 (goto-char (point-min))
8166 (if (re-search-forward "^References: " nil t)
8168 (re-search-forward "^[^ \t]" nil t)
8171 (insert " " message-id))
8172 (insert "References: " message-id "\n"))
8173 (unless (gnus-request-replace-article
8174 current-article (car gnus-article-current)
8176 (error "Couldn't replace article"))))
8177 (set-buffer gnus-summary-buffer)
8178 (gnus-summary-unmark-all-processable)
8179 (gnus-summary-update-article current-article)
8180 (gnus-summary-rethread-current)
8181 (gnus-message 3 "Article %d is now the child of article %d"
8182 current-article parent-article)))))
8184 (defun gnus-summary-toggle-threads (&optional arg)
8185 "Toggle showing conversation threads.
8186 If ARG is positive number, turn showing conversation threads on."
8188 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8189 (setq gnus-show-threads
8190 (if (null arg) (not gnus-show-threads)
8191 (> (prefix-numeric-value arg) 0)))
8192 (gnus-summary-prepare)
8193 (gnus-summary-goto-subject current)
8194 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8195 (gnus-summary-position-point)))
8197 (defun gnus-summary-show-all-threads ()
8201 (let ((buffer-read-only nil))
8202 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8203 (gnus-summary-position-point))
8205 (defun gnus-summary-show-thread ()
8206 "Show thread subtrees.
8207 Returns nil if no thread was there to be shown."
8209 (let ((buffer-read-only nil)
8211 ;; first goto end then to beg, to have point at beg after let
8212 (end (progn (end-of-line) (point)))
8213 (beg (progn (beginning-of-line) (point))))
8215 ;; Any hidden lines here?
8216 (search-forward "\r" end t)
8217 (subst-char-in-region beg end ?\^M ?\n t)
8219 (gnus-summary-position-point))))
8221 (defun gnus-summary-hide-all-threads ()
8222 "Hide all thread subtrees."
8225 (goto-char (point-min))
8226 (gnus-summary-hide-thread)
8227 (while (zerop (gnus-summary-next-thread 1 t))
8228 (gnus-summary-hide-thread)))
8229 (gnus-summary-position-point))
8231 (defun gnus-summary-hide-thread ()
8232 "Hide thread subtrees.
8233 Returns nil if no threads were there to be hidden."
8235 (let ((buffer-read-only nil)
8237 (article (gnus-summary-article-number)))
8239 ;; Go forward until either the buffer ends or the subthread
8241 (when (and (not (eobp))
8242 (or (zerop (gnus-summary-next-thread 1 t))
8243 (goto-char (point-max))))
8245 (if (and (> (point) start)
8246 (search-backward "\n" start t))
8248 (subst-char-in-region start (point) ?\n ?\^M)
8249 (gnus-summary-goto-subject article))
8252 ;;(gnus-summary-position-point)
8255 (defun gnus-summary-go-to-next-thread (&optional previous)
8256 "Go to the same level (or less) next thread.
8257 If PREVIOUS is non-nil, go to previous thread instead.
8258 Return the article number moved to, or nil if moving was impossible."
8259 (let ((level (gnus-summary-thread-level))
8260 (way (if previous -1 1))
8263 (while (and (not (eobp))
8264 (< level (gnus-summary-thread-level)))
8272 (gnus-summary-article-number)
8275 (defun gnus-summary-next-thread (n &optional silent)
8276 "Go to the same level next N'th thread.
8277 If N is negative, search backward instead.
8278 Returns the difference between N and the number of skips actually
8281 If SILENT, don't output messages."
8283 (let ((backward (< n 0))
8286 (gnus-summary-go-to-next-thread backward))
8289 (gnus-summary-position-point))
8290 (when (and (not silent) (/= 0 n))
8291 (gnus-message 7 "No more threads"))
8294 (defun gnus-summary-prev-thread (n)
8295 "Go to the same level previous N'th thread.
8296 Returns the difference between N and the number of skips actually
8299 (gnus-summary-next-thread (- n)))
8301 (defun gnus-summary-go-down-thread ()
8302 "Go down one level in the current thread."
8303 (let ((children (gnus-summary-article-children)))
8305 (gnus-summary-goto-subject (car children)))))
8307 (defun gnus-summary-go-up-thread ()
8308 "Go up one level in the current thread."
8309 (let ((parent (gnus-summary-article-parent)))
8311 (gnus-summary-goto-subject parent))))
8313 (defun gnus-summary-down-thread (n)
8314 "Go down thread N steps.
8315 If N is negative, go up instead.
8316 Returns the difference between N and how many steps down that were
8322 (if up (gnus-summary-go-up-thread)
8323 (gnus-summary-go-down-thread)))
8325 (gnus-summary-position-point)
8327 (gnus-message 7 "Can't go further"))
8330 (defun gnus-summary-up-thread (n)
8331 "Go up thread N steps.
8332 If N is negative, go up instead.
8333 Returns the difference between N and how many steps down that were
8336 (gnus-summary-down-thread (- n)))
8338 (defun gnus-summary-top-thread ()
8339 "Go to the top of the thread."
8341 (while (gnus-summary-go-up-thread))
8342 (gnus-summary-article-number))
8344 (defun gnus-summary-kill-thread (&optional unmark)
8345 "Mark articles under current thread as read.
8346 If the prefix argument is positive, remove any kinds of marks.
8347 If the prefix argument is negative, tick articles instead."
8350 (setq unmark (prefix-numeric-value unmark)))
8351 (let ((articles (gnus-summary-articles-in-thread)))
8353 ;; Expand the thread.
8354 (gnus-summary-show-thread)
8355 ;; Mark all the articles.
8357 (gnus-summary-goto-subject (car articles))
8358 (cond ((null unmark)
8359 (gnus-summary-mark-article-as-read gnus-killed-mark))
8361 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8363 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8364 (setq articles (cdr articles))))
8365 ;; Hide killed subtrees.
8367 gnus-thread-hide-killed
8368 (gnus-summary-hide-thread))
8369 ;; If marked as read, go to next unread subject.
8371 ;; Go to next unread subject.
8372 (gnus-summary-next-subject 1 t)))
8373 (gnus-set-mode-line 'summary))
8375 ;; Summary sorting commands
8377 (defun gnus-summary-sort-by-number (&optional reverse)
8378 "Sort the summary buffer by article number.
8379 Argument REVERSE means reverse order."
8381 (gnus-summary-sort 'number reverse))
8383 (defun gnus-summary-sort-by-author (&optional reverse)
8384 "Sort the summary buffer by author name alphabetically.
8385 If case-fold-search is non-nil, case of letters is ignored.
8386 Argument REVERSE means reverse order."
8388 (gnus-summary-sort 'author reverse))
8390 (defun gnus-summary-sort-by-subject (&optional reverse)
8391 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8392 If case-fold-search is non-nil, case of letters is ignored.
8393 Argument REVERSE means reverse order."
8395 (gnus-summary-sort 'subject reverse))
8397 (defun gnus-summary-sort-by-date (&optional reverse)
8398 "Sort the summary buffer by date.
8399 Argument REVERSE means reverse order."
8401 (gnus-summary-sort 'date reverse))
8403 (defun gnus-summary-sort-by-score (&optional reverse)
8404 "Sort the summary buffer by score.
8405 Argument REVERSE means reverse order."
8407 (gnus-summary-sort 'score reverse))
8409 (defun gnus-summary-sort-by-lines (&optional reverse)
8410 "Sort the summary buffer by article length.
8411 Argument REVERSE means reverse order."
8413 (gnus-summary-sort 'lines reverse))
8415 (defun gnus-summary-sort (predicate reverse)
8416 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8417 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8418 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8419 (gnus-thread-sort-functions
8425 (gnus-article-sort-functions
8430 (,article t2 t1)))))
8432 (gnus-summary-prepare-hook nil))
8433 ;; We do the sorting by regenerating the threads.
8434 (gnus-summary-prepare)
8435 ;; Hide subthreads if needed.
8436 (when (and gnus-show-threads gnus-thread-hide-subtree)
8437 (gnus-summary-hide-all-threads))))
8439 ;; Summary saving commands.
8441 (defun gnus-summary-save-article (&optional n not-saved)
8442 "Save the current article using the default saver function.
8443 If N is a positive number, save the N next articles.
8444 If N is a negative number, save the N previous articles.
8445 If N is nil and any articles have been marked with the process mark,
8446 save those articles instead.
8447 The variable `gnus-default-article-saver' specifies the saver function."
8449 (let* ((articles (gnus-summary-work-articles n))
8450 (save-buffer (save-excursion
8451 (nnheader-set-temp-buffer " *Gnus Save*")))
8452 (num (length articles))
8453 header article file)
8455 (setq header (gnus-summary-article-header
8456 (setq article (pop articles))))
8457 (if (not (vectorp header))
8458 ;; This is a pseudo-article.
8459 (if (assq 'name header)
8460 (gnus-copy-file (cdr (assq 'name header)))
8461 (gnus-message 1 "Article %d is unsaveable" article))
8462 ;; This is a real article.
8463 (save-window-excursion
8464 (gnus-summary-select-article t nil nil article))
8466 (set-buffer save-buffer)
8468 (insert-buffer-substring gnus-original-article-buffer))
8469 (setq file (gnus-article-save save-buffer file num))
8470 (gnus-summary-remove-process-mark article)
8472 (gnus-summary-set-saved-mark article))))
8473 (gnus-kill-buffer save-buffer)
8474 (gnus-summary-position-point)
8475 (gnus-set-mode-line 'summary)
8478 (defun gnus-summary-pipe-output (&optional arg)
8479 "Pipe the current article to a subprocess.
8480 If N is a positive number, pipe the N next articles.
8481 If N is a negative number, pipe the N previous articles.
8482 If N is nil and any articles have been marked with the process mark,
8483 pipe those articles instead."
8485 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8486 (gnus-summary-save-article arg t))
8487 (gnus-configure-windows 'pipe))
8489 (defun gnus-summary-save-article-mail (&optional arg)
8490 "Append the current article to an mail file.
8491 If N is a positive number, save the N next articles.
8492 If N is a negative number, save the N previous articles.
8493 If N is nil and any articles have been marked with the process mark,
8494 save those articles instead."
8496 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8497 (gnus-summary-save-article arg)))
8499 (defun gnus-summary-save-article-rmail (&optional arg)
8500 "Append the current article to an rmail file.
8501 If N is a positive number, save the N next articles.
8502 If N is a negative number, save the N previous articles.
8503 If N is nil and any articles have been marked with the process mark,
8504 save those articles instead."
8506 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8507 (gnus-summary-save-article arg)))
8509 (defun gnus-summary-save-article-file (&optional arg)
8510 "Append the current article to a file.
8511 If N is a positive number, save the N next articles.
8512 If N is a negative number, save the N previous articles.
8513 If N is nil and any articles have been marked with the process mark,
8514 save those articles instead."
8516 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8517 (gnus-summary-save-article arg)))
8519 (defun gnus-summary-write-article-file (&optional arg)
8520 "Write the current article to a file, deleting the previous file.
8521 If N is a positive number, save the N next articles.
8522 If N is a negative number, save the N previous articles.
8523 If N is nil and any articles have been marked with the process mark,
8524 save those articles instead."
8526 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8527 (gnus-summary-save-article arg)))
8529 (defun gnus-summary-save-article-body-file (&optional arg)
8530 "Append the current article body to a file.
8531 If N is a positive number, save the N next articles.
8532 If N is a negative number, save the N previous articles.
8533 If N is nil and any articles have been marked with the process mark,
8534 save those articles instead."
8536 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8537 (gnus-summary-save-article arg)))
8539 (defun gnus-summary-pipe-message (program)
8540 "Pipe the current article through PROGRAM."
8541 (interactive "sProgram: ")
8542 (gnus-summary-select-article)
8543 (let ((mail-header-separator "")
8544 (art-buf (get-buffer gnus-article-buffer)))
8545 (gnus-eval-in-buffer-window gnus-article-buffer
8548 (let ((start (window-start))
8550 (message-pipe-buffer-body program)
8551 (set-window-start (get-buffer-window (current-buffer)) start))))))
8553 (defun gnus-get-split-value (methods)
8554 "Return a value based on the split METHODS."
8555 (let (split-name method result match)
8558 (set-buffer gnus-original-article-buffer)
8560 (nnheader-narrow-to-headers)
8562 (goto-char (point-min))
8563 (setq method (pop methods))
8564 (setq match (car method))
8567 ;; Regular expression.
8569 (re-search-forward match nil t)))
8570 ((gnus-functionp match)
8574 (setq result (funcall match gnus-newsgroup-name))))
8579 (setq result (eval match)))))
8580 (setq split-name (append (cdr method) split-name))
8581 (cond ((stringp result)
8582 (push (expand-file-name
8583 result gnus-article-save-directory)
8586 (setq split-name (append result split-name)))))))))
8589 (defun gnus-valid-move-group-p (group)
8594 (car (gnus-find-method-for-group
8595 (symbol-name group))))
8596 gnus-valid-select-methods))))
8598 (defun gnus-read-move-group-name (prompt default articles prefix)
8599 "Read a group name."
8600 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8601 (minibuffer-confirm-incomplete nil) ; XEmacs
8605 (if (> (length articles) 1)
8606 (format "these %d articles" (length articles))
8611 (gnus-completing-read default prom
8613 'gnus-valid-move-group-p
8615 'gnus-group-history))
8616 ((= 1 (length split-name))
8617 (gnus-completing-read (car split-name) prom
8619 'gnus-valid-move-group-p
8621 'gnus-group-history))
8623 (gnus-completing-read nil prom
8624 (mapcar (lambda (el) (list el))
8625 (nreverse split-name))
8627 'gnus-group-history)))))
8629 (if (or (string= to-newsgroup "")
8630 (string= to-newsgroup prefix))
8631 (setq to-newsgroup default))
8632 (unless to-newsgroup
8633 (error "No group name entered"))
8634 (or (gnus-active to-newsgroup)
8635 (gnus-activate-group to-newsgroup)
8636 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8638 (or (and (gnus-request-create-group
8639 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8640 (gnus-activate-group to-newsgroup nil nil
8641 (gnus-group-name-to-method
8643 (error "Couldn't create group %s" to-newsgroup)))
8644 (error "No such group: %s" to-newsgroup)))
8647 ;; Summary extract commands
8649 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8650 (let ((buffer-read-only nil)
8651 (article (gnus-summary-article-number))
8653 (unless (gnus-summary-goto-subject article)
8654 (error "No such article: %d" article))
8655 (gnus-summary-position-point)
8656 ;; If all commands are to be bunched up on one line, we collect
8658 (unless gnus-view-pseudos-separately
8659 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8662 (setq action (cdr (assq 'action (car ps))))
8663 (setq files (list (cdr (assq 'name (car ps)))))
8664 (while (and ps (cdr ps)
8665 (string= (or action "1")
8666 (or (cdr (assq 'action (cadr ps))) "2")))
8667 (push (cdr (assq 'name (cadr ps))) files)
8668 (setcdr ps (cddr ps)))
8670 (when (not (string-match "%s" action))
8673 (when (assq 'execute (car ps))
8674 (setcdr (assq 'execute (car ps))
8675 (funcall (if (string-match "%s" action)
8682 (gnus-quote-arg-for-sh-or-csh f)))
8684 (setq ps (cdr ps)))))
8685 (if (and gnus-view-pseudos (not not-view))
8687 (when (assq 'execute (car pslist))
8688 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8689 (eq gnus-view-pseudos 'not-confirm)))
8690 (setq pslist (cdr pslist)))
8693 (setq after-article (or (cdr (assq 'article (car pslist)))
8694 (gnus-summary-article-number)))
8695 (gnus-summary-goto-subject after-article)
8698 (insert " " (file-name-nondirectory
8699 (cdr (assq 'name (car pslist))))
8700 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8702 (forward-line -1) ; back to `b'
8703 (gnus-add-text-properties
8704 b (1- e) (list 'gnus-number gnus-reffed-article-number
8705 gnus-mouse-face-prop gnus-mouse-face))
8707 after-article gnus-reffed-article-number
8708 gnus-unread-mark b (car pslist) 0 (- e b))
8709 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8710 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8711 (setq pslist (cdr pslist)))))))
8713 (defun gnus-pseudos< (p1 p2)
8714 (let ((c1 (cdr (assq 'action p1)))
8715 (c2 (cdr (assq 'action p2))))
8716 (and c1 c2 (string< c1 c2))))
8718 (defun gnus-request-pseudo-article (props)
8719 (cond ((assq 'execute props)
8720 (gnus-execute-command (cdr (assq 'execute props)))))
8721 (let ((gnus-current-article (gnus-summary-article-number)))
8722 (run-hooks 'gnus-mark-article-hook)))
8724 (defun gnus-execute-command (command &optional automatic)
8726 (gnus-article-setup-buffer)
8727 (set-buffer gnus-article-buffer)
8728 (setq buffer-read-only nil)
8729 (let ((command (if automatic command
8730 (read-string "Command: " (cons command 0)))))
8732 (insert "$ " command "\n\n")
8733 (if gnus-view-pseudo-asynchronously
8734 (start-process "gnus-execute" (current-buffer) shell-file-name
8735 shell-command-switch command)
8736 (call-process shell-file-name nil t nil
8737 shell-command-switch command)))))
8739 ;; Summary kill commands.
8741 (defun gnus-summary-edit-global-kill (article)
8742 "Edit the \"global\" kill file."
8743 (interactive (list (gnus-summary-article-number)))
8744 (gnus-group-edit-global-kill article))
8746 (defun gnus-summary-edit-local-kill ()
8747 "Edit a local kill file applied to the current newsgroup."
8749 (setq gnus-current-headers (gnus-summary-article-header))
8750 (gnus-group-edit-local-kill
8751 (gnus-summary-article-number) gnus-newsgroup-name))
8755 (defun gnus-read-header (id &optional header)
8756 "Read the headers of article ID and enter them into the Gnus system."
8757 (let ((group gnus-newsgroup-name)
8758 (gnus-override-method
8759 (and (gnus-news-group-p gnus-newsgroup-name)
8760 gnus-refer-article-method))
8762 ;; First we check to see whether the header in question is already
8765 ;; This is a Message-ID.
8766 (setq header (or header (gnus-id-to-header id)))
8767 ;; This is an article number.
8768 (setq header (or header (gnus-summary-article-header id))))
8770 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8771 ;; We have found the header.
8773 ;; If this is a sparse article, we have to nix out its
8774 ;; previous entry in the thread hashtb.
8776 (gnus-summary-article-sparse-p (mail-header-number header)))
8777 (let* ((parent (gnus-parent-id (mail-header-references header)))
8780 (gnus-gethash parent gnus-newsgroup-dependencies))))
8782 (delq (assq header thread) thread))))
8783 ;; We have to really fetch the header to this article.
8785 (set-buffer nntp-server-buffer)
8786 (when (setq where (gnus-request-head id group))
8787 (nnheader-fold-continuation-lines)
8788 (goto-char (point-max))
8790 (goto-char (point-min))
8794 ((cdr where) (cdr where))
8795 (header (mail-header-number header))
8796 (t gnus-reffed-article-number))
8798 (insert " Article retrieved.\n"))
8800 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8801 () ; Malformed head.
8802 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8803 (when (and (stringp id)
8804 (not (string= (gnus-group-real-name group)
8806 ;; If we fetched by Message-ID and the article came
8807 ;; from a different group, we fudge some bogus article
8808 ;; numbers for this article.
8809 (mail-header-set-number header gnus-reffed-article-number))
8811 (set-buffer gnus-summary-buffer)
8812 (decf gnus-reffed-article-number)
8813 (gnus-remove-header (mail-header-number header))
8814 (push header gnus-newsgroup-headers)
8815 (setq gnus-current-headers header)
8816 (push (mail-header-number header) gnus-newsgroup-limit)))
8819 (defun gnus-remove-header (number)
8820 "Remove header NUMBER from `gnus-newsgroup-headers'."
8821 (if (and gnus-newsgroup-headers
8822 (= number (mail-header-number (car gnus-newsgroup-headers))))
8823 (pop gnus-newsgroup-headers)
8824 (let ((headers gnus-newsgroup-headers))
8825 (while (and (cdr headers)
8826 (not (= number (mail-header-number (cadr headers)))))
8829 (setcdr headers (cddr headers))))))
8832 ;;; summary highlights
8835 (defun gnus-highlight-selected-summary ()
8836 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8837 ;; Highlight selected article in summary buffer
8838 (when gnus-summary-selected-face
8840 (let* ((beg (progn (beginning-of-line) (point)))
8841 (end (progn (end-of-line) (point)))
8842 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8843 (from (if (get-text-property beg gnus-mouse-face-prop)
8845 (or (next-single-property-change
8846 beg gnus-mouse-face-prop nil end)
8851 (or (next-single-property-change
8852 from gnus-mouse-face-prop nil end)
8854 ;; If no mouse-face prop on line we will have to = from = end,
8855 ;; so we highlight the entire line instead.
8856 (when (= (+ to 2) from)
8859 (if gnus-newsgroup-selected-overlay
8860 ;; Move old overlay.
8862 gnus-newsgroup-selected-overlay from to (current-buffer))
8863 ;; Create new overlay.
8865 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8866 'face gnus-summary-selected-face))))))
8868 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8869 (defun gnus-summary-highlight-line ()
8870 "Highlight current line according to `gnus-summary-highlight'."
8871 (let* ((list gnus-summary-highlight)
8873 (end (progn (end-of-line) (point)))
8874 ;; now find out where the line starts and leave point there.
8875 (beg (progn (beginning-of-line) (point)))
8876 (article (gnus-summary-article-number))
8877 (score (or (cdr (assq (or article gnus-current-article)
8878 gnus-newsgroup-scored))
8879 gnus-summary-default-score 0))
8880 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8881 (inhibit-read-only t))
8882 ;; Eval the cars of the lists until we find a match.
8883 (let ((default gnus-summary-default-score))
8885 (not (eval (caar list))))
8886 (setq list (cdr list))))
8887 (let ((face (cdar list)))
8888 (unless (eq face (get-text-property beg 'face))
8889 (gnus-put-text-property
8891 (setq face (if (boundp face) (symbol-value face) face)))
8892 (when gnus-summary-highlight-line-function
8893 (funcall gnus-summary-highlight-line-function article face))))
8896 (defun gnus-update-read-articles (group unread &optional compute)
8897 "Update the list of read articles in GROUP."
8898 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8899 (entry (gnus-gethash group gnus-newsrc-hashtb))
8900 (info (nth 2 entry))
8902 (unread (sort (copy-sequence unread) '<))
8904 (if (or (not info) (not active))
8905 ;; There is no info on this group if it was, in fact,
8906 ;; killed. Gnus stores no information on killed groups, so
8907 ;; there's nothing to be done.
8908 ;; One could store the information somewhere temporarily,
8909 ;; perhaps... Hmmm...
8911 ;; Remove any negative articles numbers.
8912 (while (and unread (< (car unread) 0))
8913 (setq unread (cdr unread)))
8914 ;; Remove any expired article numbers
8915 (while (and unread (< (car unread) (car active)))
8916 (setq unread (cdr unread)))
8917 ;; Compute the ranges of read articles by looking at the list of
8920 (when (/= (car unread) prev)
8921 (push (if (= prev (1- (car unread))) prev
8922 (cons prev (1- (car unread))))
8924 (setq prev (1+ (car unread)))
8925 (setq unread (cdr unread)))
8926 (when (<= prev (cdr active))
8927 (push (cons prev (cdr active)) read))
8929 (if (> (length read) 1) (nreverse read) read)
8931 (set-buffer gnus-group-buffer)
8934 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8935 (gnus-info-set-read ',info ',(gnus-info-read info))
8936 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8937 (gnus-group-update-group ,group t))))
8938 ;; Enter this list into the group info.
8940 info (if (> (length read) 1) (nreverse read) read))
8941 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8942 (gnus-get-unread-articles-in-group info (gnus-active group))
8945 (defun gnus-offer-save-summaries ()
8946 "Offer to save all active summary buffers."
8948 (let ((buflist (buffer-list))
8950 ;; Go through all buffers and find all summaries.
8952 (and (setq bufname (buffer-name (car buflist)))
8953 (string-match "Summary" bufname)
8955 (set-buffer bufname)
8956 ;; We check that this is, indeed, a summary buffer.
8957 (and (eq major-mode 'gnus-summary-mode)
8958 ;; Also make sure this isn't bogus.
8959 gnus-newsgroup-prepared
8960 ;; Also make sure that this isn't a dead summary buffer.
8961 (not gnus-dead-summary-mode)))
8962 (push bufname buffers))
8963 (setq buflist (cdr buflist)))
8964 ;; Go through all these summary buffers and offer to save them.
8967 "Update summary buffer %s? "
8968 (lambda (buf) (switch-to-buffer buf) (gnus-summary-exit))
8972 ;;; @ for mime-partial
8975 (defun gnus-mime-partial-preview-function ()
8976 (gnus-summary-preview-mime-message (gnus-summary-article-number))
8979 (autoload 'mime-combine-message/partials-automatically
8981 "Internal method to combine message/partial messages automatically.")
8983 (set-atype 'mime-acting-condition
8984 '((type . "message/partial")
8985 (method . mime-combine-message/partials-automatically)
8986 (major-mode . gnus-original-article-mode)
8987 (summary-buffer-exp . gnus-summary-buffer)
8990 (set-alist 'mime-view-partial-message-method-alist
8991 'gnus-original-article-mode
8992 'gnus-mime-partial-preview-function)
9002 (run-hooks 'gnus-sum-load-hook)
9004 ;;; gnus-sum.el ends here