1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
36 (defvar gnus-kill-summary-on-exit t
37 "*If non-nil, kill the summary buffer when you exit from it.
38 If nil, the summary will become a \"*Dead Summary*\" buffer, and
39 it will be killed sometime later.")
41 (defvar gnus-fetch-old-headers nil
42 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
43 If an unread article in the group refers to an older, already read (or
44 just marked as read) article, the old article will not normally be
45 displayed in the Summary buffer. If this variable is non-nil, Gnus
46 will attempt to grab the headers to the old articles, and thereby
47 build complete threads. If it has the value `some', only enough
48 headers to connect otherwise loose threads will be displayed.
49 This variable can also be a number. In that case, no more than that
50 number of old headers will be fetched.
52 The server has to support NOV for any of this to work.")
54 (defvar gnus-summary-make-false-root 'adopt
55 "*nil means that Gnus won't gather loose threads.
56 If the root of a thread has expired or been read in a previous
57 session, the information necessary to build a complete thread has been
58 lost. Instead of having many small sub-threads from this original thread
59 scattered all over the summary buffer, Gnus can gather them.
61 If non-nil, Gnus will try to gather all loose sub-threads from an
62 original thread into one large thread.
64 If this variable is non-nil, it should be one of `none', `adopt',
67 If this variable is `none', Gnus will not make a false root, but just
68 present the sub-threads after another.
69 If this variable is `dummy', Gnus will create a dummy root that will
70 have all the sub-threads as children.
71 If this variable is `adopt', Gnus will make one of the \"children\"
72 the parent and mark all the step-children as such.
73 If this variable is `empty', the \"children\" are printed with empty
74 subject fields. (Or rather, they will be printed with a string
75 given by the `gnus-summary-same-subject' variable.)")
77 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
78 "*A regexp to match subjects to be excluded from loose thread gathering.
79 As loose thread gathering is done on subjects only, that means that
80 there can be many false gatherings performed. By rooting out certain
81 common subjects, gathering might become saner.")
83 (defvar gnus-summary-gather-subject-limit nil
84 "*Maximum length of subject comparisons when gathering loose threads.
85 Use nil to compare full subjects. Setting this variable to a low
86 number will help gather threads that have been corrupted by
87 newsreaders chopping off subject lines, but it might also mean that
88 unrelated articles that have subject that happen to begin with the
89 same few characters will be incorrectly gathered.
91 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
94 (defvar gnus-simplify-ignored-prefixes nil
95 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.")
97 (defvar gnus-build-sparse-threads nil
98 "*If non-nil, fill in the gaps in threads.
99 If `some', only fill in the gaps that are needed to tie loose threads
100 together. If `more', fill in all leaf nodes that Gnus can find. If
101 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
103 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
104 "Function used for gathering loose threads.
105 There are two pre-defined functions: `gnus-gather-threads-by-subject',
106 which only takes Subjects into consideration; and
107 `gnus-gather-threads-by-references', which compared the References
108 headers of the articles to find matches.")
110 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
111 (defvar gnus-summary-same-subject ""
112 "*String indicating that the current article has the same subject as the previous.
113 This variable will only be used if the value of
114 `gnus-summary-make-false-root' is `empty'.")
116 (defvar gnus-summary-goto-unread t
117 "*If non-nil, marking commands will go to the next unread article.
118 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
119 whether it is read or not.")
121 (defvar gnus-summary-default-score 0
122 "*Default article score level.
123 If this variable is nil, scoring will be disabled.")
125 (defvar gnus-summary-zcore-fuzz 0
126 "*Fuzziness factor for the zcore in the summary buffer.
127 Articles with scores closer than this to `gnus-summary-default-score'
128 will not be marked.")
130 (defvar gnus-simplify-subject-fuzzy-regexp nil
131 "*Strings to be removed when doing fuzzy matches.
132 This can either be a regular expression or list of regular expressions
133 that will be removed from subject strings if fuzzy subject
134 simplification is selected.")
136 (defvar gnus-show-threads t
137 "*If non-nil, display threads in summary mode.")
139 (defvar gnus-thread-hide-subtree nil
140 "*If non-nil, hide all threads initially.
141 If threads are hidden, you have to run the command
142 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
143 to expose hidden threads.")
145 (defvar gnus-thread-hide-killed t
146 "*If non-nil, hide killed threads automatically.")
148 (defvar gnus-thread-ignore-subject nil
149 "*If non-nil, ignore subjects and do all threading based on the Reference header.
150 If nil, which is the default, articles that have different subjects
151 from their parents will start separate threads.")
153 (defvar gnus-thread-operation-ignore-subject t
154 "*If non-nil, subjects will be ignored when doing thread commands.
155 This affects commands like `gnus-summary-kill-thread' and
156 `gnus-summary-lower-thread'.
158 If this variable is nil, articles in the same thread with different
159 subjects will not be included in the operation in question. If this
160 variable is `fuzzy', only articles that have subjects that are fuzzily
161 equal will be included.")
163 (defvar gnus-thread-indent-level 4
164 "*Number that says how much each sub-thread should be indented.")
166 (defvar gnus-auto-extend-newsgroup t
167 "*If non-nil, extend newsgroup forward and backward when requested.")
169 (defvar gnus-auto-select-first t
170 "*If nil, don't select the first unread article when entering a group.
171 If this variable is `best', select the highest-scored unread article
172 in the group. If neither nil nor `best', select the first unread
175 If you want to prevent automatic selection of the first unread article
176 in some newsgroups, set the variable to nil in
177 `gnus-select-group-hook'.")
179 (defvar gnus-auto-select-next t
180 "*If non-nil, offer to go to the next group from the end of the previous.
181 If the value is t and the next newsgroup is empty, Gnus will exit
182 summary mode and go back to group mode. If the value is neither nil
183 nor t, Gnus will select the following unread newsgroup. In
184 particular, if the value is the symbol `quietly', the next unread
185 newsgroup will be selected without any confirmation, and if it is
186 `almost-quietly', the next group will be selected without any
187 confirmation if you are located on the last article in the group.
188 Finally, if this variable is `slightly-quietly', the `Z n' command
189 will go to the next group without confirmation.")
191 (defvar gnus-auto-select-same nil
192 "*If non-nil, select the next article with the same subject.")
194 (defvar gnus-summary-check-current nil
195 "*If non-nil, consider the current article when moving.
196 The \"unread\" movement commands will stay on the same line if the
197 current article is unread.")
199 (defvar gnus-auto-center-summary t
200 "*If non-nil, always center the current summary buffer.
201 In particular, if `vertical' do only vertical recentering. If non-nil
202 and non-`vertical', do both horizontal and vertical recentering.")
204 (defvar gnus-show-all-headers nil
205 "*If non-nil, don't hide any headers.")
207 (defvar gnus-single-article-buffer t
208 "*If non-nil, display all articles in the same buffer.
209 If nil, each group will get its own article buffer.")
211 (defvar gnus-break-pages t
212 "*If non-nil, do page breaking on articles.
213 The page delimiter is specified by the `gnus-page-delimiter'
216 (defvar gnus-show-mime nil
217 "*If non-nil, do mime processing of articles.
218 The articles will simply be fed to the function given by
219 `gnus-show-mime-method'.")
221 (defvar gnus-move-split-methods nil
222 "*Variable used to suggest where articles are to be moved to.
223 It uses the same syntax as the `gnus-split-methods' variable.")
225 ;; Mark variables suggested by Thomas Michanek
226 ;; <Thomas.Michanek@telelogic.se>.
227 (defvar gnus-unread-mark ?
228 "*Mark used for unread articles.")
229 (defvar gnus-ticked-mark ?!
230 "*Mark used for ticked articles.")
231 (defvar gnus-dormant-mark ??
232 "*Mark used for dormant articles.")
233 (defvar gnus-del-mark ?r
234 "*Mark used for del'd articles.")
235 (defvar gnus-read-mark ?R
236 "*Mark used for read articles.")
237 (defvar gnus-expirable-mark ?E
238 "*Mark used for expirable articles.")
239 (defvar gnus-killed-mark ?K
240 "*Mark used for killed articles.")
241 (defvar gnus-souped-mark ?F
242 "*Mark used for killed articles.")
243 (defvar gnus-kill-file-mark ?X
244 "*Mark used for articles killed by kill files.")
245 (defvar gnus-low-score-mark ?Y
246 "*Mark used for articles with a low score.")
247 (defvar gnus-catchup-mark ?C
248 "*Mark used for articles that are caught up.")
249 (defvar gnus-replied-mark ?A
250 "*Mark used for articles that have been replied to.")
251 (defvar gnus-cached-mark ?*
252 "*Mark used for articles that are in the cache.")
253 (defvar gnus-saved-mark ?S
254 "*Mark used for articles that have been saved to.")
255 (defvar gnus-ancient-mark ?O
256 "*Mark used for ancient articles.")
257 (defvar gnus-sparse-mark ?Q
258 "*Mark used for sparsely reffed articles.")
259 (defvar gnus-canceled-mark ?G
260 "*Mark used for canceled articles.")
261 (defvar gnus-duplicate-mark ?M
262 "*Mark used for duplicate articles.")
263 (defvar gnus-score-over-mark ?+
264 "*Score mark used for articles with high scores.")
265 (defvar gnus-score-below-mark ?-
266 "*Score mark used for articles with low scores.")
267 (defvar gnus-empty-thread-mark ?
268 "*There is no thread under the article.")
269 (defvar gnus-not-empty-thread-mark ?=
270 "*There is a thread under the article.")
272 (defvar gnus-view-pseudo-asynchronously nil
273 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
275 (defvar gnus-view-pseudos nil
276 "*If `automatic', pseudo-articles will be viewed automatically.
277 If `not-confirm', pseudos will be viewed automatically, and the user
278 will not be asked to confirm the command.")
280 (defvar gnus-view-pseudos-separately t
281 "*If non-nil, one pseudo-article will be created for each file to be viewed.
282 If nil, all files that use the same viewing command will be given as a
283 list of parameters to that command.")
285 (defvar gnus-insert-pseudo-articles t
286 "*If non-nil, insert pseudo-articles when decoding articles.")
288 (defvar gnus-summary-dummy-line-format
290 "*The format specification for the dummy roots in the summary buffer.
291 It works along the same lines as a normal formatting string,
292 with some simple extensions.
296 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
297 "*The format specification for the summary mode line.
298 It works along the same lines as a normal formatting string,
299 with some simple extensions:
302 %p Unprefixed group name
303 %A Current article number
305 %U Number of unread articles in the group
306 %e Number of unselected articles in the group
307 %Z A string with unread/unselected article counts
308 %g Shortish group name
309 %S Subject of the current article
311 %s Current score file name
312 %d Number of dormant articles
313 %r Number of articles that have been marked as read in this session
314 %E Number of articles expunged by the score files")
316 (defvar gnus-summary-mark-below 0
317 "*Mark all articles with a score below this variable as read.
318 This variable is local to each summary buffer and usually set by the
321 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
322 "*List of functions used for sorting articles in the summary buffer.
323 This variable is only used when not using a threaded display.")
325 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
326 "*List of functions used for sorting threads in the summary buffer.
327 By default, threads are sorted by article number.
329 Each function takes two threads and return non-nil if the first thread
330 should be sorted before the other. If you use more than one function,
331 the primary sort function should be the last. You should probably
332 always include `gnus-thread-sort-by-number' in the list of sorting
333 functions -- preferably first.
335 Ready-made functions include `gnus-thread-sort-by-number',
336 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
337 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
338 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
340 (defvar gnus-thread-score-function '+
341 "*Function used for calculating the total score of a thread.
343 The function is called with the scores of the article and each
344 subthread and should then return the score of the thread.
346 Some functions you can use are `+', `max', or `min'.")
348 (defvar gnus-summary-expunge-below nil
349 "All articles that have a score less than this variable will be expunged.")
351 (defvar gnus-thread-expunge-below nil
352 "All threads that have a total score less than this variable will be expunged.
353 See `gnus-thread-score-function' for en explanation of what a
354 \"thread score\" is.")
356 (defvar gnus-summary-mode-hook nil
357 "*A hook for Gnus summary mode.
358 This hook is run before any variables are set in the summary buffer.")
360 (defvar gnus-summary-menu-hook nil
361 "*Hook run after the creation of the summary mode menu.")
363 (defvar gnus-summary-exit-hook nil
364 "*A hook called on exit from the summary buffer.")
366 (defvar gnus-summary-prepare-hook nil
367 "*A hook called after the summary buffer has been generated.
368 If you want to modify the summary buffer, you can use this hook.")
370 (defvar gnus-summary-generate-hook nil
371 "*A hook run just before generating the summary buffer.
372 This hook is commonly used to customize threading variables and the
375 (defvar gnus-select-group-hook nil
376 "*A hook called when a newsgroup is selected.
378 If you'd like to simplify subjects like the
379 `gnus-summary-next-same-subject' command does, you can use the
382 (setq gnus-select-group-hook
385 (mapcar (lambda (header)
386 (mail-header-set-subject
388 (gnus-simplify-subject
389 (mail-header-subject header) 're-only)))
390 gnus-newsgroup-headers))))")
392 (defvar gnus-select-article-hook nil
393 "*A hook called when an article is selected.")
395 (defvar gnus-visual-mark-article-hook
396 (list 'gnus-highlight-selected-summary)
397 "*Hook run after selecting an article in the summary buffer.
398 It is meant to be used for highlighting the article in some way. It
399 is not run if `gnus-visual' is nil.")
401 (defvar gnus-parse-headers-hook nil
402 "*A hook called before parsing the headers.")
403 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
405 (defvar gnus-exit-group-hook nil
406 "*A hook called when exiting (not quitting) summary mode.")
408 (defvar gnus-summary-update-hook
409 (list 'gnus-summary-highlight-line)
410 "*A hook called when a summary line is changed.
411 The hook will not be called if `gnus-visual' is nil.
413 The default function `gnus-summary-highlight-line' will
414 highlight the line according to the `gnus-summary-highlight'
417 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
418 "*A hook called when an article is selected for the first time.
419 The hook is intended to mark an article as read (or unread)
420 automatically when it is selected.")
422 (defvar gnus-group-no-more-groups-hook nil
423 "*A hook run when returning to group mode having no more (unread) groups.")
425 (defvar gnus-summary-selected-face 'underline
426 "Face used for highlighting the current article in the summary buffer.")
428 (defvar gnus-summary-highlight
430 ((not (eq gnus-display-type 'color))
431 '(((> score default) . bold)
432 ((< score default) . italic)))
433 ((eq gnus-background-mode 'dark)
436 '(= mark gnus-canceled-mark)
437 (custom-face-lookup "yellow" "black" nil
439 (cons '(and (> score default)
440 (or (= mark gnus-dormant-mark)
441 (= mark gnus-ticked-mark)))
443 "pink" nil nil t nil nil))
444 (cons '(and (< score default)
445 (or (= mark gnus-dormant-mark)
446 (= mark gnus-ticked-mark)))
447 (custom-face-lookup "pink" nil nil
449 (cons '(or (= mark gnus-dormant-mark)
450 (= mark gnus-ticked-mark))
452 "pink" nil nil nil nil nil))
455 '(and (> score default) (= mark gnus-ancient-mark))
456 (custom-face-lookup "medium blue" nil nil t
459 '(and (< score default) (= mark gnus-ancient-mark))
460 (custom-face-lookup "SkyBlue" nil nil
463 '(= mark gnus-ancient-mark)
464 (custom-face-lookup "SkyBlue" nil nil
466 (cons '(and (> score default) (= mark gnus-unread-mark))
467 (custom-face-lookup "white" nil nil t
469 (cons '(and (< score default) (= mark gnus-unread-mark))
470 (custom-face-lookup "white" nil nil
472 (cons '(= mark gnus-unread-mark)
474 "white" nil nil nil nil nil))
476 (cons '(> score default) 'bold)
477 (cons '(< score default) 'italic)))
481 '(= mark gnus-canceled-mark)
483 "yellow" "black" nil nil nil nil))
484 (cons '(and (> score default)
485 (or (= mark gnus-dormant-mark)
486 (= mark gnus-ticked-mark)))
487 (custom-face-lookup "firebrick" nil nil
489 (cons '(and (< score default)
490 (or (= mark gnus-dormant-mark)
491 (= mark gnus-ticked-mark)))
492 (custom-face-lookup "firebrick" nil nil
495 '(or (= mark gnus-dormant-mark)
496 (= mark gnus-ticked-mark))
498 "firebrick" nil nil nil nil nil))
500 (cons '(and (> score default) (= mark gnus-ancient-mark))
501 (custom-face-lookup "RoyalBlue" nil nil
503 (cons '(and (< score default) (= mark gnus-ancient-mark))
504 (custom-face-lookup "RoyalBlue" nil nil
507 '(= mark gnus-ancient-mark)
509 "RoyalBlue" nil nil nil nil nil))
511 (cons '(and (> score default) (/= mark gnus-unread-mark))
512 (custom-face-lookup "DarkGreen" nil nil
514 (cons '(and (< score default) (/= mark gnus-unread-mark))
515 (custom-face-lookup "DarkGreen" nil nil
518 '(/= mark gnus-unread-mark)
519 (custom-face-lookup "DarkGreen" nil nil
522 (cons '(> score default) 'bold)
523 (cons '(< score default) 'italic))))
524 "Controls the highlighting of summary buffer lines.
526 Below is a list of `Form'/`Face' pairs. When deciding how a a
527 particular summary line should be displayed, each form is
528 evaluated. The content of the face field after the first true form is
529 used. You can change how those summary lines are displayed, by
530 editing the face field.
532 It is also possible to change and add form fields, but currently that
533 requires an understanding of Lisp expressions. Hopefully this will
534 change in a future release. For now, you can use the following
535 variables in the Lisp expression:
537 score: The article's score
538 default: The default article score.
539 below: The score below which articles are automatically marked as read.
540 mark: The article's mark.")
542 ;;; Internal variables
544 (defvar gnus-scores-exclude-files nil)
546 (defvar gnus-summary-display-table
547 ;; Change the display table. Odd characters have a tendency to mess
548 ;; up nicely formatted displays - we make all possible glyphs
549 ;; display only a single character.
551 ;; We start from the standard display table, if any.
552 (let ((table (or (copy-sequence standard-display-table)
553 (make-display-table)))
554 ;; Nix out all the control chars...
556 (while (>= (setq i (1- i)) 0)
558 ;; ... but not newline and cr, of course. (cr is necessary for the
559 ;; selective display).
562 ;; We nix out any glyphs over 126 that are not set already.
564 (while (>= (setq i (1- i)) 127)
565 ;; Only modify if the entry is nil.
567 (aset table i [??]))))
569 "Display table used in summary mode buffers.")
571 (defvar gnus-original-article nil)
572 (defvar gnus-article-internal-prepare-hook nil)
573 (defvar gnus-newsgroup-process-stack nil)
575 (defvar gnus-thread-indent-array nil)
576 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
578 ;; Avoid highlighting in kill files.
579 (defvar gnus-summary-inhibit-highlight nil)
580 (defvar gnus-newsgroup-selected-overlay nil)
581 (defvar gnus-inhibit-limiting nil)
582 (defvar gnus-newsgroup-adaptive-score-file nil)
583 (defvar gnus-current-score-file nil)
584 (defvar gnus-current-move-group nil)
585 (defvar gnus-current-copy-group nil)
586 (defvar gnus-current-crosspost-group nil)
588 (defvar gnus-newsgroup-dependencies nil)
589 (defvar gnus-newsgroup-adaptive nil)
590 (defvar gnus-summary-display-article-function nil)
591 (defvar gnus-summary-highlight-line-function nil
592 "Function called after highlighting a summary line.")
594 (defvar gnus-summary-line-format-alist
595 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
596 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
597 (?s gnus-tmp-subject-or-nil ?s)
598 (?n gnus-tmp-name ?s)
599 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
601 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
603 (?F gnus-tmp-from ?s)
604 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
605 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
606 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
607 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
608 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
609 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
610 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
611 (?L gnus-tmp-lines ?d)
612 (?I gnus-tmp-indentation ?s)
613 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
614 (?R gnus-tmp-replied ?c)
615 (?\[ gnus-tmp-opening-bracket ?c)
616 (?\] gnus-tmp-closing-bracket ?c)
617 (?\> (make-string gnus-tmp-level ? ) ?s)
618 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
619 (?i gnus-tmp-score ?d)
620 (?z gnus-tmp-score-char ?c)
621 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
622 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
623 (?U gnus-tmp-unread ?c)
624 (?t (gnus-summary-number-of-articles-in-thread
625 (and (boundp 'thread) (car thread)) gnus-tmp-level)
627 (?e (gnus-summary-number-of-articles-in-thread
628 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
630 (?u gnus-tmp-user-defined ?s)
631 (?P (gnus-pick-line-number) ?d))
632 "An alist of format specifications that can appear in summary lines,
633 and what variables they correspond with, along with the type of the
634 variable (string, integer, character, etc).")
636 (defvar gnus-summary-dummy-line-format-alist
637 `((?S gnus-tmp-subject ?s)
638 (?N gnus-tmp-number ?d)
639 (?u gnus-tmp-user-defined ?s)))
641 (defvar gnus-summary-mode-line-format-alist
642 `((?G gnus-tmp-group-name ?s)
643 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
644 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
645 (?A gnus-tmp-article-number ?d)
646 (?Z gnus-tmp-unread-and-unselected ?s)
648 (?U gnus-tmp-unread-and-unticked ?d)
649 (?S gnus-tmp-subject ?s)
650 (?e gnus-tmp-unselected ?d)
651 (?u gnus-tmp-user-defined ?s)
652 (?d (length gnus-newsgroup-dormant) ?d)
653 (?t (length gnus-newsgroup-marked) ?d)
654 (?r (length gnus-newsgroup-reads) ?d)
655 (?E gnus-newsgroup-expunged-tally ?d)
656 (?s (gnus-current-score-file-nondirectory) ?s)))
658 (defvar gnus-last-search-regexp nil
659 "Default regexp for article search command.")
661 (defvar gnus-last-shell-command nil
662 "Default shell command on article.")
664 (defvar gnus-newsgroup-begin nil)
665 (defvar gnus-newsgroup-end nil)
666 (defvar gnus-newsgroup-last-rmail nil)
667 (defvar gnus-newsgroup-last-mail nil)
668 (defvar gnus-newsgroup-last-folder nil)
669 (defvar gnus-newsgroup-last-file nil)
670 (defvar gnus-newsgroup-auto-expire nil)
671 (defvar gnus-newsgroup-active nil)
673 (defvar gnus-newsgroup-data nil)
674 (defvar gnus-newsgroup-data-reverse nil)
675 (defvar gnus-newsgroup-limit nil)
676 (defvar gnus-newsgroup-limits nil)
678 (defvar gnus-newsgroup-unreads nil
679 "List of unread articles in the current newsgroup.")
681 (defvar gnus-newsgroup-unselected nil
682 "List of unselected unread articles in the current newsgroup.")
684 (defvar gnus-newsgroup-reads nil
685 "Alist of read articles and article marks in the current newsgroup.")
687 (defvar gnus-newsgroup-expunged-tally nil)
689 (defvar gnus-newsgroup-marked nil
690 "List of ticked articles in the current newsgroup (a subset of unread art).")
692 (defvar gnus-newsgroup-killed nil
693 "List of ranges of articles that have been through the scoring process.")
695 (defvar gnus-newsgroup-cached nil
696 "List of articles that come from the article cache.")
698 (defvar gnus-newsgroup-saved nil
699 "List of articles that have been saved.")
701 (defvar gnus-newsgroup-kill-headers nil)
703 (defvar gnus-newsgroup-replied nil
704 "List of articles that have been replied to in the current newsgroup.")
706 (defvar gnus-newsgroup-expirable nil
707 "List of articles in the current newsgroup that can be expired.")
709 (defvar gnus-newsgroup-processable nil
710 "List of articles in the current newsgroup that can be processed.")
712 (defvar gnus-newsgroup-bookmarks nil
713 "List of articles in the current newsgroup that have bookmarks.")
715 (defvar gnus-newsgroup-dormant nil
716 "List of dormant articles in the current newsgroup.")
718 (defvar gnus-newsgroup-scored nil
719 "List of scored articles in the current newsgroup.")
721 (defvar gnus-newsgroup-headers nil
722 "List of article headers in the current newsgroup.")
724 (defvar gnus-newsgroup-threads nil)
726 (defvar gnus-newsgroup-prepared nil
727 "Whether the current group has been prepared properly.")
729 (defvar gnus-newsgroup-ancient nil
730 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
732 (defvar gnus-newsgroup-sparse nil)
734 (defvar gnus-current-article nil)
735 (defvar gnus-article-current nil)
736 (defvar gnus-current-headers nil)
737 (defvar gnus-have-all-headers nil)
738 (defvar gnus-last-article nil)
739 (defvar gnus-newsgroup-history nil)
741 (defconst gnus-summary-local-variables
742 '(gnus-newsgroup-name
743 gnus-newsgroup-begin gnus-newsgroup-end
744 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
745 gnus-newsgroup-last-folder gnus-newsgroup-last-file
746 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
747 gnus-newsgroup-unselected gnus-newsgroup-marked
748 gnus-newsgroup-reads gnus-newsgroup-saved
749 gnus-newsgroup-replied gnus-newsgroup-expirable
750 gnus-newsgroup-processable gnus-newsgroup-killed
751 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
752 gnus-newsgroup-headers gnus-newsgroup-threads
753 gnus-newsgroup-prepared gnus-summary-highlight-line-function
754 gnus-current-article gnus-current-headers gnus-have-all-headers
755 gnus-last-article gnus-article-internal-prepare-hook
756 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
757 gnus-newsgroup-scored gnus-newsgroup-kill-headers
758 gnus-thread-expunge-below
759 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
760 (gnus-summary-mark-below . global)
761 gnus-newsgroup-active gnus-scores-exclude-files
762 gnus-newsgroup-history gnus-newsgroup-ancient
763 gnus-newsgroup-sparse gnus-newsgroup-process-stack
764 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
765 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
766 (gnus-newsgroup-expunged-tally . 0)
767 gnus-cache-removable-articles gnus-newsgroup-cached
768 gnus-newsgroup-data gnus-newsgroup-data-reverse
769 gnus-newsgroup-limit gnus-newsgroup-limits)
770 "Variables that are buffer-local to the summary buffers.")
772 ;; Byte-compiler warning.
773 (defvar gnus-article-mode-map)
775 ;; Subject simplification.
777 (defsubst gnus-simplify-subject-re (subject)
778 "Remove \"Re:\" from subject lines."
779 (if (string-match "^[Rr][Ee]: *" subject)
780 (substring subject (match-end 0))
783 (defun gnus-simplify-subject (subject &optional re-only)
784 "Remove `Re:' and words in parentheses.
785 If RE-ONLY is non-nil, strip leading `Re:'s only."
786 (let ((case-fold-search t)) ;Ignore case.
787 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
788 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
789 (setq subject (substring subject (match-end 0))))
790 ;; Remove uninteresting prefixes.
791 (if (and (not re-only)
792 gnus-simplify-ignored-prefixes
793 (string-match gnus-simplify-ignored-prefixes subject))
794 (setq subject (substring subject (match-end 0))))
795 ;; Remove words in parentheses from end.
797 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
798 (setq subject (substring subject 0 (match-beginning 0)))))
799 ;; Return subject string.
802 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
804 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
805 (defun gnus-simplify-buffer-fuzzy ()
806 (let ((case-fold-search t))
807 (goto-char (point-min))
808 (while (search-forward "\t" nil t)
809 (replace-match " " t t))
810 (goto-char (point-min))
811 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
812 (goto-char (match-beginning 0))
814 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
815 (looking-at "^[[].*: .*[]]$"))
816 (goto-char (point-min))
817 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
819 (replace-match "" t t))
820 (goto-char (point-min))
821 (while (re-search-forward "^[[].*: .*[]]$" nil t)
822 (goto-char (match-end 0))
825 (progn (goto-char (match-beginning 0)))
826 (re-search-forward ":"))))
827 (goto-char (point-min))
828 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
829 (replace-match "" t t))
830 (goto-char (point-min))
831 (while (re-search-forward " +" nil t)
832 (replace-match " " t t))
833 (goto-char (point-min))
834 (while (re-search-forward " $" nil t)
835 (replace-match "" t t))
836 (goto-char (point-min))
837 (while (re-search-forward "^ +" nil t)
838 (replace-match "" t t))
839 (goto-char (point-min))
840 (when gnus-simplify-subject-fuzzy-regexp
841 (if (listp gnus-simplify-subject-fuzzy-regexp)
842 (let ((list gnus-simplify-subject-fuzzy-regexp))
844 (goto-char (point-min))
845 (while (re-search-forward (car list) nil t)
846 (replace-match "" t t))
847 (setq list (cdr list))))
848 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
849 (replace-match "" t t))))))
851 (defun gnus-simplify-subject-fuzzy (subject)
852 "Simplify a subject string fuzzily."
854 (gnus-set-work-buffer)
855 (let ((case-fold-search t))
857 (inline (gnus-simplify-buffer-fuzzy))
860 (defsubst gnus-simplify-subject-fully (subject)
861 "Simplify a subject string according to the user's wishes."
863 ((null gnus-summary-gather-subject-limit)
864 (gnus-simplify-subject-re subject))
865 ((eq gnus-summary-gather-subject-limit 'fuzzy)
866 (gnus-simplify-subject-fuzzy subject))
867 ((numberp gnus-summary-gather-subject-limit)
868 (gnus-limit-string (gnus-simplify-subject-re subject)
869 gnus-summary-gather-subject-limit))
873 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
874 "Check whether two subjects are equal. If optional argument
875 simple-first is t, first argument is already simplified."
878 (equal (gnus-simplify-subject-fully s1)
879 (gnus-simplify-subject-fully s2)))
882 (gnus-simplify-subject-fully s2)))))
884 (defun gnus-offer-save-summaries ()
885 "Offer to save all active summary buffers."
887 (let ((buflist (buffer-list))
889 ;; Go through all buffers and find all summaries.
891 (and (setq bufname (buffer-name (car buflist)))
892 (string-match "Summary" bufname)
895 ;; We check that this is, indeed, a summary buffer.
896 (and (eq major-mode 'gnus-summary-mode)
897 ;; Also make sure this isn't bogus.
898 gnus-newsgroup-prepared))
899 (push bufname buffers))
900 (setq buflist (cdr buflist)))
901 ;; Go through all these summary buffers and offer to save them.
904 "Update summary buffer %s? "
905 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
908 (defun gnus-summary-bubble-group ()
909 "Increase the score of the current group.
910 This is a handy function to add to `gnus-summary-exit-hook' to
911 increase the score of each group you read."
912 (gnus-group-add-score gnus-newsgroup-name))
916 ;;; Gnus summary mode
919 (put 'gnus-summary-mode 'mode-class 'special)
922 ;; Non-orthogonal keys
924 (gnus-define-keys gnus-summary-mode-map
925 " " gnus-summary-next-page
926 "\177" gnus-summary-prev-page
927 [delete] gnus-summary-prev-page
928 "\r" gnus-summary-scroll-up
929 "n" gnus-summary-next-unread-article
930 "p" gnus-summary-prev-unread-article
931 "N" gnus-summary-next-article
932 "P" gnus-summary-prev-article
933 "\M-\C-n" gnus-summary-next-same-subject
934 "\M-\C-p" gnus-summary-prev-same-subject
935 "\M-n" gnus-summary-next-unread-subject
936 "\M-p" gnus-summary-prev-unread-subject
937 "." gnus-summary-first-unread-article
938 "," gnus-summary-best-unread-article
939 "\M-s" gnus-summary-search-article-forward
940 "\M-r" gnus-summary-search-article-backward
941 "<" gnus-summary-beginning-of-article
942 ">" gnus-summary-end-of-article
943 "j" gnus-summary-goto-article
944 "^" gnus-summary-refer-parent-article
945 "\M-^" gnus-summary-refer-article
946 "u" gnus-summary-tick-article-forward
947 "!" gnus-summary-tick-article-forward
948 "U" gnus-summary-tick-article-backward
949 "d" gnus-summary-mark-as-read-forward
950 "D" gnus-summary-mark-as-read-backward
951 "E" gnus-summary-mark-as-expirable
952 "\M-u" gnus-summary-clear-mark-forward
953 "\M-U" gnus-summary-clear-mark-backward
954 "k" gnus-summary-kill-same-subject-and-select
955 "\C-k" gnus-summary-kill-same-subject
956 "\M-\C-k" gnus-summary-kill-thread
957 "\M-\C-l" gnus-summary-lower-thread
958 "e" gnus-summary-edit-article
959 "#" gnus-summary-mark-as-processable
960 "\M-#" gnus-summary-unmark-as-processable
961 "\M-\C-t" gnus-summary-toggle-threads
962 "\M-\C-s" gnus-summary-show-thread
963 "\M-\C-h" gnus-summary-hide-thread
964 "\M-\C-f" gnus-summary-next-thread
965 "\M-\C-b" gnus-summary-prev-thread
966 "\M-\C-u" gnus-summary-up-thread
967 "\M-\C-d" gnus-summary-down-thread
968 "&" gnus-summary-execute-command
969 "c" gnus-summary-catchup-and-exit
970 "\C-w" gnus-summary-mark-region-as-read
971 "\C-t" gnus-summary-toggle-truncation
972 "?" gnus-summary-mark-as-dormant
973 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
974 "\C-c\C-s\C-n" gnus-summary-sort-by-number
975 "\C-c\C-s\C-a" gnus-summary-sort-by-author
976 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
977 "\C-c\C-s\C-d" gnus-summary-sort-by-date
978 "\C-c\C-s\C-i" gnus-summary-sort-by-score
979 "=" gnus-summary-expand-window
980 "\C-x\C-s" gnus-summary-reselect-current-group
981 "\M-g" gnus-summary-rescan-group
982 "w" gnus-summary-stop-page-breaking
983 "\C-c\C-r" gnus-summary-caesar-message
984 "\M-t" gnus-summary-toggle-mime
985 "f" gnus-summary-followup
986 "F" gnus-summary-followup-with-original
987 "C" gnus-summary-cancel-article
988 "r" gnus-summary-reply
989 "R" gnus-summary-reply-with-original
990 "\C-c\C-f" gnus-summary-mail-forward
991 "o" gnus-summary-save-article
992 "\C-o" gnus-summary-save-article-mail
993 "|" gnus-summary-pipe-output
994 "\M-k" gnus-summary-edit-local-kill
995 "\M-K" gnus-summary-edit-global-kill
997 "\C-c\C-d" gnus-summary-describe-group
998 "q" gnus-summary-exit
999 "Q" gnus-summary-exit-no-update
1000 "\C-c\C-i" gnus-info-find-node
1001 gnus-mouse-2 gnus-mouse-pick-article
1002 "m" gnus-summary-mail-other-window
1003 "a" gnus-summary-post-news
1004 "x" gnus-summary-limit-to-unread
1005 "s" gnus-summary-isearch-article
1006 "t" gnus-article-hide-headers
1007 "g" gnus-summary-show-article
1008 "l" gnus-summary-goto-last-article
1009 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1010 "\C-d" gnus-summary-enter-digest-group
1011 "\M-\C-d" gnus-summary-read-document
1013 "*" gnus-cache-enter-article
1014 "\M-*" gnus-cache-remove-article
1015 "\M-&" gnus-summary-universal-argument
1016 "\C-l" gnus-recenter
1017 "I" gnus-summary-increase-score
1018 "L" gnus-summary-lower-score
1020 "V" gnus-summary-score-map
1021 "X" gnus-uu-extract-map
1022 "S" gnus-summary-send-map)
1024 ;; Sort of orthogonal keymap
1025 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1026 "t" gnus-summary-tick-article-forward
1027 "!" gnus-summary-tick-article-forward
1028 "d" gnus-summary-mark-as-read-forward
1029 "r" gnus-summary-mark-as-read-forward
1030 "c" gnus-summary-clear-mark-forward
1031 " " gnus-summary-clear-mark-forward
1032 "e" gnus-summary-mark-as-expirable
1033 "x" gnus-summary-mark-as-expirable
1034 "?" gnus-summary-mark-as-dormant
1035 "b" gnus-summary-set-bookmark
1036 "B" gnus-summary-remove-bookmark
1037 "#" gnus-summary-mark-as-processable
1038 "\M-#" gnus-summary-unmark-as-processable
1039 "S" gnus-summary-limit-include-expunged
1040 "C" gnus-summary-catchup
1041 "H" gnus-summary-catchup-to-here
1042 "\C-c" gnus-summary-catchup-all
1043 "k" gnus-summary-kill-same-subject-and-select
1044 "K" gnus-summary-kill-same-subject
1045 "P" gnus-uu-mark-map)
1047 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1048 "c" gnus-summary-clear-above
1049 "u" gnus-summary-tick-above
1050 "m" gnus-summary-mark-above
1051 "k" gnus-summary-kill-below)
1053 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1054 "/" gnus-summary-limit-to-subject
1055 "n" gnus-summary-limit-to-articles
1056 "w" gnus-summary-pop-limit
1057 "s" gnus-summary-limit-to-subject
1058 "a" gnus-summary-limit-to-author
1059 "u" gnus-summary-limit-to-unread
1060 "m" gnus-summary-limit-to-marks
1061 "v" gnus-summary-limit-to-score
1062 "D" gnus-summary-limit-include-dormant
1063 "d" gnus-summary-limit-exclude-dormant
1064 ;; "t" gnus-summary-limit-exclude-thread
1065 "E" gnus-summary-limit-include-expunged
1066 "c" gnus-summary-limit-exclude-childless-dormant
1067 "C" gnus-summary-limit-mark-excluded-as-read)
1069 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1070 "n" gnus-summary-next-unread-article
1071 "p" gnus-summary-prev-unread-article
1072 "N" gnus-summary-next-article
1073 "P" gnus-summary-prev-article
1074 "\C-n" gnus-summary-next-same-subject
1075 "\C-p" gnus-summary-prev-same-subject
1076 "\M-n" gnus-summary-next-unread-subject
1077 "\M-p" gnus-summary-prev-unread-subject
1078 "f" gnus-summary-first-unread-article
1079 "b" gnus-summary-best-unread-article
1080 "j" gnus-summary-goto-article
1081 "g" gnus-summary-goto-subject
1082 "l" gnus-summary-goto-last-article
1083 "p" gnus-summary-pop-article)
1085 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1086 "k" gnus-summary-kill-thread
1087 "l" gnus-summary-lower-thread
1088 "i" gnus-summary-raise-thread
1089 "T" gnus-summary-toggle-threads
1090 "t" gnus-summary-rethread-current
1091 "^" gnus-summary-reparent-thread
1092 "s" gnus-summary-show-thread
1093 "S" gnus-summary-show-all-threads
1094 "h" gnus-summary-hide-thread
1095 "H" gnus-summary-hide-all-threads
1096 "n" gnus-summary-next-thread
1097 "p" gnus-summary-prev-thread
1098 "u" gnus-summary-up-thread
1099 "o" gnus-summary-top-thread
1100 "d" gnus-summary-down-thread
1101 "#" gnus-uu-mark-thread
1102 "\M-#" gnus-uu-unmark-thread)
1104 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1105 "g" gnus-summary-prepare
1106 "c" gnus-summary-insert-cached-articles)
1108 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1109 "c" gnus-summary-catchup-and-exit
1110 "C" gnus-summary-catchup-all-and-exit
1111 "E" gnus-summary-exit-no-update
1112 "Q" gnus-summary-exit
1113 "Z" gnus-summary-exit
1114 "n" gnus-summary-catchup-and-goto-next-group
1115 "R" gnus-summary-reselect-current-group
1116 "G" gnus-summary-rescan-group
1117 "N" gnus-summary-next-group
1118 "P" gnus-summary-prev-group)
1120 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1121 " " gnus-summary-next-page
1122 "n" gnus-summary-next-page
1123 "\177" gnus-summary-prev-page
1124 [delete] gnus-summary-prev-page
1125 "p" gnus-summary-prev-page
1126 "\r" gnus-summary-scroll-up
1127 "<" gnus-summary-beginning-of-article
1128 ">" gnus-summary-end-of-article
1129 "b" gnus-summary-beginning-of-article
1130 "e" gnus-summary-end-of-article
1131 "^" gnus-summary-refer-parent-article
1132 "r" gnus-summary-refer-parent-article
1133 "R" gnus-summary-refer-references
1134 "g" gnus-summary-show-article
1135 "s" gnus-summary-isearch-article)
1137 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1138 "b" gnus-article-add-buttons
1139 "B" gnus-article-add-buttons-to-head
1140 "o" gnus-article-treat-overstrike
1141 "e" gnus-article-emphasize
1142 "w" gnus-article-fill-cited-article
1143 "c" gnus-article-remove-cr
1144 "q" gnus-article-de-quoted-unreadable
1145 "f" gnus-article-display-x-face
1146 "l" gnus-summary-stop-page-breaking
1147 "r" gnus-summary-caesar-message
1148 "t" gnus-article-hide-headers
1149 "v" gnus-summary-verbose-headers
1150 "m" gnus-summary-toggle-mime)
1152 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1153 "a" gnus-article-hide
1154 "h" gnus-article-hide-headers
1155 "b" gnus-article-hide-boring-headers
1156 "s" gnus-article-hide-signature
1157 "c" gnus-article-hide-citation
1158 "p" gnus-article-hide-pgp
1159 "P" gnus-article-hide-pem
1160 "\C-c" gnus-article-hide-citation-maybe)
1162 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1163 "a" gnus-article-highlight
1164 "h" gnus-article-highlight-headers
1165 "c" gnus-article-highlight-citation
1166 "s" gnus-article-highlight-signature)
1168 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1169 "z" gnus-article-date-ut
1170 "u" gnus-article-date-ut
1171 "l" gnus-article-date-local
1172 "e" gnus-article-date-lapsed
1173 "o" gnus-article-date-original)
1175 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1176 "t" gnus-article-remove-trailing-blank-lines
1177 "l" gnus-article-strip-leading-blank-lines
1178 "m" gnus-article-strip-multiple-blank-lines
1179 "a" gnus-article-strip-blank-lines)
1181 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1183 "f" gnus-summary-fetch-faq
1184 "d" gnus-summary-describe-group
1185 "h" gnus-summary-describe-briefly
1186 "i" gnus-info-find-node)
1188 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1189 "e" gnus-summary-expire-articles
1190 "\M-\C-e" gnus-summary-expire-articles-now
1191 "\177" gnus-summary-delete-article
1192 [delete] gnus-summary-delete-article
1193 "m" gnus-summary-move-article
1194 "r" gnus-summary-respool-article
1195 "w" gnus-summary-edit-article
1196 "c" gnus-summary-copy-article
1197 "B" gnus-summary-crosspost-article
1198 "q" gnus-summary-respool-query
1199 "i" gnus-summary-import-article
1200 "p" gnus-summary-article-posted-p)
1202 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1203 "o" gnus-summary-save-article
1204 "m" gnus-summary-save-article-mail
1205 "r" gnus-summary-save-article-rmail
1206 "f" gnus-summary-save-article-file
1207 "b" gnus-summary-save-article-body-file
1208 "h" gnus-summary-save-article-folder
1209 "v" gnus-summary-save-article-vm
1210 "p" gnus-summary-pipe-output
1211 "s" gnus-soup-add-article))
1213 (defun gnus-summary-make-menu-bar ()
1214 (gnus-turn-off-edit-menu 'summary)
1216 (unless (boundp 'gnus-summary-misc-menu)
1219 gnus-summary-kill-menu gnus-summary-mode-map ""
1224 ["Enter score..." gnus-summary-score-entry t])
1225 (gnus-make-score-map 'increase)
1226 (gnus-make-score-map 'lower)
1228 ["Kill below" gnus-summary-kill-below t]
1229 ["Mark above" gnus-summary-mark-above t]
1230 ["Tick above" gnus-summary-tick-above t]
1231 ["Clear above" gnus-summary-clear-above t])
1232 ["Current score" gnus-summary-current-score t]
1233 ["Set score" gnus-summary-set-score t]
1234 ["Switch current score file..." gnus-score-change-score-file t]
1235 ["Set mark below..." gnus-score-set-mark-below t]
1236 ["Set expunge below..." gnus-score-set-expunge-below t]
1237 ["Edit current score file" gnus-score-edit-current-scores t]
1238 ["Edit score file" gnus-score-edit-file t]
1239 ["Trace score" gnus-score-find-trace t]
1240 ["Find words" gnus-score-find-favourite-words t]
1241 ["Rescore buffer" gnus-summary-rescore t]
1242 ["Increase score..." gnus-summary-increase-score t]
1243 ["Lower score..." gnus-summary-lower-score t]))))
1246 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1248 :selected (null gnus-score-default-header)]
1249 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1251 :selected (eq gnus-score-default-header 'a)]
1252 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1254 :selected (eq gnus-score-default-header 's)]
1256 (gnus-score-set-default 'gnus-score-default-header 'b)
1258 :selected (eq gnus-score-default-header 'b )]
1260 (gnus-score-set-default 'gnus-score-default-header 'h)
1262 :selected (eq gnus-score-default-header 'h )]
1263 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1265 :selected (eq gnus-score-default-header 'i )]
1266 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1268 :selected (eq gnus-score-default-header 't )]
1270 (gnus-score-set-default 'gnus-score-default-header 'x)
1272 :selected (eq gnus-score-default-header 'x )]
1273 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1275 :selected (eq gnus-score-default-header 'l )]
1276 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1278 :selected (eq gnus-score-default-header 'd )]
1279 ["Followups to author"
1280 (gnus-score-set-default 'gnus-score-default-header 'f)
1282 :selected (eq gnus-score-default-header 'f )])
1284 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1286 :selected (null gnus-score-default-type)]
1287 ;; The `:active' key is commented out in the following,
1288 ;; because the GNU Emacs hack to support radio buttons use
1289 ;; active to indicate which button is selected.
1290 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1292 ;; :active (not (memq gnus-score-default-header '(l d)))
1293 :selected (eq gnus-score-default-type 's)]
1294 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1296 ;; :active (not (memq gnus-score-default-header '(l d)))
1297 :selected (eq gnus-score-default-type 'r)]
1298 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1300 ;; :active (not (memq gnus-score-default-header '(l d)))
1301 :selected (eq gnus-score-default-type 'e)]
1302 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1304 ;; :active (not (memq gnus-score-default-header '(l d)))
1305 :selected (eq gnus-score-default-type 'f)]
1306 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1308 ;; :active (eq (gnus-score-default-header 'd))
1309 :selected (eq gnus-score-default-type 'b)]
1310 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1312 ;; :active (eq (gnus-score-default-header 'd))
1313 :selected (eq gnus-score-default-type 'n)]
1314 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1316 ;; :active (eq (gnus-score-default-header 'd))
1317 :selected (eq gnus-score-default-type 'a)]
1319 (gnus-score-set-default 'gnus-score-default-type '<)
1321 ;; :active (eq (gnus-score-default-header 'l))
1322 :selected (eq gnus-score-default-type '<)]
1324 (gnus-score-set-default 'gnus-score-default-type '=)
1326 ;; :active (eq (gnus-score-default-header 'l))
1327 :selected (eq gnus-score-default-type '=)]
1328 ["Greater than number"
1329 (gnus-score-set-default 'gnus-score-default-type '>)
1331 ;; :active (eq (gnus-score-default-header 'l))
1332 :selected (eq gnus-score-default-type '>)])
1333 ["Default fold" gnus-score-default-fold-toggle
1335 :selected gnus-score-default-fold]
1337 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1339 :selected (null gnus-score-default-duration)]
1341 (gnus-score-set-default 'gnus-score-default-duration 'p)
1343 :selected (eq gnus-score-default-duration 'p)]
1345 (gnus-score-set-default 'gnus-score-default-duration 't)
1347 :selected (eq gnus-score-default-duration 't)]
1349 (gnus-score-set-default 'gnus-score-default-duration 'i)
1351 :selected (eq gnus-score-default-duration 'i)]))
1354 gnus-summary-article-menu gnus-summary-mode-map ""
1357 ["All" gnus-article-hide t]
1358 ["Headers" gnus-article-hide-headers t]
1359 ["Signature" gnus-article-hide-signature t]
1360 ["Citation" gnus-article-hide-citation t]
1361 ["PGP" gnus-article-hide-pgp t]
1362 ["Boring headers" gnus-article-hide-boring-headers t])
1364 ["All" gnus-article-highlight t]
1365 ["Headers" gnus-article-highlight-headers t]
1366 ["Signature" gnus-article-highlight-signature t]
1367 ["Citation" gnus-article-highlight-citation t])
1369 ["Local" gnus-article-date-local t]
1370 ["UT" gnus-article-date-ut t]
1371 ["Original" gnus-article-date-original t]
1372 ["Lapsed" gnus-article-date-lapsed t])
1375 ["Leading" gnus-article-strip-leading-blank-lines t]
1376 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1377 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1378 ["All of the above" gnus-article-strip-blank-lines t])
1379 ["Overstrike" gnus-article-treat-overstrike t]
1380 ["Emphasis" gnus-article-emphasize t]
1381 ["Word wrap" gnus-article-fill-cited-article t]
1382 ["CR" gnus-article-remove-cr t]
1383 ["Show X-Face" gnus-article-display-x-face t]
1384 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1385 ["Rot 13" gnus-summary-caesar-message t]
1386 ["Add buttons" gnus-article-add-buttons t]
1387 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1388 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1389 ["Toggle MIME" gnus-summary-toggle-mime t]
1390 ["Verbose header" gnus-summary-verbose-headers t]
1391 ["Toggle header" gnus-summary-toggle-header t])
1393 ["Save in default format" gnus-summary-save-article t]
1394 ["Save in file" gnus-summary-save-article-file t]
1395 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1396 ["Save in MH folder" gnus-summary-save-article-folder t]
1397 ["Save in VM folder" gnus-summary-save-article-vm t]
1398 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1399 ["Save body in file" gnus-summary-save-article-body-file t]
1400 ["Pipe through a filter" gnus-summary-pipe-output t]
1401 ["Add to SOUP packet" gnus-soup-add-article t])
1403 ["Respool article..." gnus-summary-respool-article t]
1404 ["Move article..." gnus-summary-move-article
1405 (gnus-check-backend-function
1406 'request-move-article gnus-newsgroup-name)]
1407 ["Copy article..." gnus-summary-copy-article t]
1408 ["Crosspost article..." gnus-summary-crosspost-article
1409 (gnus-check-backend-function
1410 'request-replace-article gnus-newsgroup-name)]
1411 ["Import file..." gnus-summary-import-article t]
1412 ["Check if posted" gnus-summary-article-posted-p t]
1413 ["Edit article" gnus-summary-edit-article
1414 (not (gnus-group-read-only-p))]
1415 ["Delete article" gnus-summary-delete-article
1416 (gnus-check-backend-function
1417 'request-expire-articles gnus-newsgroup-name)]
1418 ["Query respool" gnus-summary-respool-query t]
1419 ["Delete expirable articles" gnus-summary-expire-articles-now
1420 (gnus-check-backend-function
1421 'request-expire-articles gnus-newsgroup-name)])
1423 ["Uudecode" gnus-uu-decode-uu t]
1424 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1425 ["Unshar" gnus-uu-decode-unshar t]
1426 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1427 ["Save" gnus-uu-decode-save t]
1428 ["Binhex" gnus-uu-decode-binhex t]
1429 ["Postscript" gnus-uu-decode-postscript t])
1430 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1431 ["Isearch article..." gnus-summary-isearch-article t]
1432 ["Search articles forward..." gnus-summary-search-article-forward t]
1433 ["Search articles backward..." gnus-summary-search-article-backward t]
1434 ["Beginning of the article" gnus-summary-beginning-of-article t]
1435 ["End of the article" gnus-summary-end-of-article t]
1436 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1437 ["Fetch referenced articles" gnus-summary-refer-references t]
1438 ["Fetch article with id..." gnus-summary-refer-article t]
1439 ["Redisplay" gnus-summary-show-article t]))
1442 gnus-summary-thread-menu gnus-summary-mode-map ""
1444 ["Toggle threading" gnus-summary-toggle-threads t]
1445 ["Hide threads" gnus-summary-hide-all-threads t]
1446 ["Show threads" gnus-summary-show-all-threads t]
1447 ["Hide thread" gnus-summary-hide-thread t]
1448 ["Show thread" gnus-summary-show-thread t]
1449 ["Go to next thread" gnus-summary-next-thread t]
1450 ["Go to previous thread" gnus-summary-prev-thread t]
1451 ["Go down thread" gnus-summary-down-thread t]
1452 ["Go up thread" gnus-summary-up-thread t]
1453 ["Top of thread" gnus-summary-top-thread t]
1454 ["Mark thread as read" gnus-summary-kill-thread t]
1455 ["Lower thread score" gnus-summary-lower-thread t]
1456 ["Raise thread score" gnus-summary-raise-thread t]
1457 ["Rethread current" gnus-summary-rethread-current t]
1461 gnus-summary-post-menu gnus-summary-mode-map ""
1463 ["Post an article" gnus-summary-post-news t]
1464 ["Followup" gnus-summary-followup t]
1465 ["Followup and yank" gnus-summary-followup-with-original t]
1466 ["Supersede article" gnus-summary-supersede-article t]
1467 ["Cancel article" gnus-summary-cancel-article t]
1468 ["Reply" gnus-summary-reply t]
1469 ["Reply and yank" gnus-summary-reply-with-original t]
1470 ["Mail forward" gnus-summary-mail-forward t]
1471 ["Post forward" gnus-summary-post-forward t]
1472 ["Digest and mail" gnus-uu-digest-mail-forward t]
1473 ["Digest and post" gnus-uu-digest-post-forward t]
1474 ["Resend message" gnus-summary-resend-message t]
1475 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1476 ["Send a mail" gnus-summary-mail-other-window t]
1477 ["Uuencode and post" gnus-uu-post-news t]
1479 ;;["Send" gnus-summary-send-draft t]
1480 ;;["Send bounced" gnus-resend-bounced-mail t])
1484 gnus-summary-misc-menu gnus-summary-mode-map ""
1488 ["Mark as read" gnus-summary-mark-as-read-forward t]
1489 ["Mark same subject and select"
1490 gnus-summary-kill-same-subject-and-select t]
1491 ["Mark same subject" gnus-summary-kill-same-subject t]
1492 ["Catchup" gnus-summary-catchup t]
1493 ["Catchup all" gnus-summary-catchup-all t]
1494 ["Catchup to here" gnus-summary-catchup-to-here t]
1495 ["Catchup region" gnus-summary-mark-region-as-read t]
1496 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1498 ["Tick" gnus-summary-tick-article-forward t]
1499 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1500 ["Remove marks" gnus-summary-clear-mark-forward t]
1501 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1502 ["Set bookmark" gnus-summary-set-bookmark t]
1503 ["Remove bookmark" gnus-summary-remove-bookmark t])
1505 ["Marks..." gnus-summary-limit-to-marks t]
1506 ["Subject..." gnus-summary-limit-to-subject t]
1507 ["Author..." gnus-summary-limit-to-author t]
1508 ["Score" gnus-summary-limit-to-score t]
1509 ["Unread" gnus-summary-limit-to-unread t]
1510 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1511 ["Articles" gnus-summary-limit-to-articles t]
1512 ["Pop limit" gnus-summary-pop-limit t]
1513 ["Show dormant" gnus-summary-limit-include-dormant t]
1514 ["Hide childless dormant"
1515 gnus-summary-limit-exclude-childless-dormant t]
1516 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1517 ["Show expunged" gnus-summary-show-all-expunged t])
1519 ["Set mark" gnus-summary-mark-as-processable t]
1520 ["Remove mark" gnus-summary-unmark-as-processable t]
1521 ["Remove all marks" gnus-summary-unmark-all-processable t]
1522 ["Mark above" gnus-uu-mark-over t]
1523 ["Mark series" gnus-uu-mark-series t]
1524 ["Mark region" gnus-uu-mark-region t]
1525 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1526 ["Mark all" gnus-uu-mark-all t]
1527 ["Mark buffer" gnus-uu-mark-buffer t]
1528 ["Mark sparse" gnus-uu-mark-sparse t]
1529 ["Mark thread" gnus-uu-mark-thread t]
1530 ["Unmark thread" gnus-uu-unmark-thread t]
1531 ("Process Mark Sets"
1532 ["Kill" gnus-summary-kill-process-mark t]
1533 ["Yank" gnus-summary-yank-process-mark
1534 gnus-newsgroup-process-stack]
1535 ["Save" gnus-summary-save-process-mark t])))
1537 ["Page forward" gnus-summary-next-page t]
1538 ["Page backward" gnus-summary-prev-page t]
1539 ["Line forward" gnus-summary-scroll-up t])
1541 ["Next unread article" gnus-summary-next-unread-article t]
1542 ["Previous unread article" gnus-summary-prev-unread-article t]
1543 ["Next article" gnus-summary-next-article t]
1544 ["Previous article" gnus-summary-prev-article t]
1545 ["Next unread subject" gnus-summary-next-unread-subject t]
1546 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1547 ["Next article same subject" gnus-summary-next-same-subject t]
1548 ["Previous article same subject" gnus-summary-prev-same-subject t]
1549 ["First unread article" gnus-summary-first-unread-article t]
1550 ["Best unread article" gnus-summary-best-unread-article t]
1551 ["Go to subject number..." gnus-summary-goto-subject t]
1552 ["Go to article number..." gnus-summary-goto-article t]
1553 ["Go to the last article" gnus-summary-goto-last-article t]
1554 ["Pop article off history" gnus-summary-pop-article t])
1556 ["Sort by number" gnus-summary-sort-by-number t]
1557 ["Sort by author" gnus-summary-sort-by-author t]
1558 ["Sort by subject" gnus-summary-sort-by-subject t]
1559 ["Sort by date" gnus-summary-sort-by-date t]
1560 ["Sort by score" gnus-summary-sort-by-score t])
1562 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1563 ["Describe group" gnus-summary-describe-group t]
1564 ["Read manual" gnus-info-find-node t])
1566 ["Enter article" gnus-cache-enter-article t]
1567 ["Remove article" gnus-cache-remove-article t])
1569 ["Pick and read" gnus-pick-mode t]
1570 ["Binary" gnus-binary-mode t])
1571 ["Filter articles..." gnus-summary-execute-command t]
1572 ["Run command on subjects..." gnus-summary-universal-argument t]
1573 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1574 ["Expand window" gnus-summary-expand-window t]
1575 ["Expire expirable articles" gnus-summary-expire-articles
1576 (gnus-check-backend-function
1577 'request-expire-articles gnus-newsgroup-name)]
1578 ["Regenerate buffer" gnus-summary-prepare t]
1579 ["Edit local kill file" gnus-summary-edit-local-kill t]
1580 ["Edit main kill file" gnus-summary-edit-global-kill t]
1582 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1583 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1584 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1585 ["Exit group" gnus-summary-exit t]
1586 ["Exit group without updating" gnus-summary-exit-no-update t]
1587 ["Exit and goto next group" gnus-summary-next-group t]
1588 ["Exit and goto prev group" gnus-summary-prev-group t]
1589 ["Reselect group" gnus-summary-reselect-current-group t]
1590 ["Rescan group" gnus-summary-rescan-group t])))
1592 (run-hooks 'gnus-summary-menu-hook)))
1594 (defun gnus-score-set-default (var value)
1595 "A version of set that updates the GNU Emacs menu-bar."
1597 ;; It is the message that forces the active status to be updated.
1600 (defun gnus-make-score-map (type)
1601 "Make a summary score map of type TYPE."
1604 (let ((headers '(("author" "from" string)
1605 ("subject" "subject" string)
1606 ("article body" "body" string)
1607 ("article head" "head" string)
1608 ("xref" "xref" string)
1609 ("lines" "lines" number)
1610 ("followups to author" "followup" string)))
1611 (types '((number ("less than" <)
1614 (string ("substring" s)
1618 (perms '(("temporary" (current-time-string))
1626 (if (eq type 'lower)
1631 (setq header (car headers))
1637 (let ((ts (cdr (assoc (nth 2 header) types)))
1653 'gnus-summary-score-entry
1655 (if (or (string= (nth 1 header)
1657 (string= (nth 1 header)
1660 (list 'gnus-summary-header
1662 (list 'quote (nth 1 (car ts)))
1663 (list 'gnus-score-default nil)
1669 (list (nreverse outp))))
1672 (list (nreverse outt))))
1674 (setq headers (cdr headers)))
1675 (list (nreverse outh))))))))
1679 (defun gnus-summary-mode (&optional group)
1680 "Major mode for reading articles.
1682 All normal editing commands are switched off.
1683 \\<gnus-summary-mode-map>
1684 Each line in this buffer represents one article. To read an
1685 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1686 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1689 You can also post articles and send mail from this buffer. To
1690 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1691 of an article, type `\\[gnus-summary-reply]'.
1693 There are approx. one gazillion commands you can execute in this
1694 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1696 The following commands are available:
1698 \\{gnus-summary-mode-map}"
1700 (when (and menu-bar-mode
1701 (gnus-visual-p 'summary-menu 'menu))
1702 (gnus-summary-make-menu-bar))
1703 (kill-all-local-variables)
1704 (gnus-summary-make-local-variables)
1705 (gnus-make-thread-indent-array)
1706 (gnus-simplify-mode-line)
1707 (setq major-mode 'gnus-summary-mode)
1708 (setq mode-name "Summary")
1709 (make-local-variable 'minor-mode-alist)
1710 (use-local-map gnus-summary-mode-map)
1711 (buffer-disable-undo (current-buffer))
1712 (setq buffer-read-only t) ;Disable modification
1713 (setq truncate-lines t)
1714 (setq selective-display t)
1715 (setq selective-display-ellipses t) ;Display `...'
1716 (setq buffer-display-table gnus-summary-display-table)
1717 (gnus-set-default-directory)
1718 (setq gnus-newsgroup-name group)
1719 (make-local-variable 'gnus-summary-line-format)
1720 (make-local-variable 'gnus-summary-line-format-spec)
1721 (make-local-variable 'gnus-summary-mark-positions)
1722 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1723 (gnus-update-summary-mark-positions)
1724 (gnus-make-local-hook 'post-command-hook)
1725 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1726 (run-hooks 'gnus-summary-mode-hook))
1728 (defun gnus-summary-make-local-variables ()
1729 "Make all the local summary buffer variables."
1730 (let ((locals gnus-summary-local-variables)
1732 (while (setq local (pop locals))
1735 (if (eq (cdr local) 'global)
1736 ;; Copy the global value of the variable.
1737 (setq global (symbol-value (car local)))
1738 ;; Use the value from the list.
1739 (setq global (eval (cdr local))))
1740 (make-local-variable (car local))
1741 (set (car local) global))
1742 ;; Simple nil-valued local variable.
1743 (make-local-variable local)
1746 (defun gnus-summary-clear-local-variables ()
1747 (let ((locals gnus-summary-local-variables))
1749 (if (consp (car locals))
1750 (and (vectorp (caar locals))
1751 (set (caar locals) nil))
1752 (and (vectorp (car locals))
1753 (set (car locals) nil)))
1754 (setq locals (cdr locals)))))
1756 ;; Summary data functions.
1758 (defmacro gnus-data-number (data)
1761 (defmacro gnus-data-set-number (data number)
1762 `(setcar ,data ,number))
1764 (defmacro gnus-data-mark (data)
1767 (defmacro gnus-data-set-mark (data mark)
1768 `(setcar (nthcdr 1 ,data) ,mark))
1770 (defmacro gnus-data-pos (data)
1773 (defmacro gnus-data-set-pos (data pos)
1774 `(setcar (nthcdr 2 ,data) ,pos))
1776 (defmacro gnus-data-header (data)
1779 (defmacro gnus-data-level (data)
1782 (defmacro gnus-data-unread-p (data)
1783 `(= (nth 1 ,data) gnus-unread-mark))
1785 (defmacro gnus-data-read-p (data)
1786 `(/= (nth 1 ,data) gnus-unread-mark))
1788 (defmacro gnus-data-pseudo-p (data)
1789 `(consp (nth 3 ,data)))
1791 (defmacro gnus-data-find (number)
1792 `(assq ,number gnus-newsgroup-data))
1794 (defmacro gnus-data-find-list (number &optional data)
1795 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1796 (memq (assq ,number bdata)
1799 (defmacro gnus-data-make (number mark pos header level)
1800 `(list ,number ,mark ,pos ,header ,level))
1802 (defun gnus-data-enter (after-article number mark pos header level offset)
1803 (let ((data (gnus-data-find-list after-article)))
1804 (or data (error "No such article: %d" after-article))
1805 (setcdr data (cons (gnus-data-make number mark pos header level)
1807 (setq gnus-newsgroup-data-reverse nil)
1808 (gnus-data-update-list (cddr data) offset)))
1810 (defun gnus-data-enter-list (after-article list &optional offset)
1812 (let ((data (and after-article (gnus-data-find-list after-article)))
1814 (or data (not after-article) (error "No such article: %d" after-article))
1815 ;; Find the last element in the list to be spliced into the main
1818 (setq list (cdr list)))
1821 (setcdr list gnus-newsgroup-data)
1822 (setq gnus-newsgroup-data ilist)
1823 (and offset (gnus-data-update-list (cdr list) offset)))
1824 (setcdr list (cdr data))
1826 (and offset (gnus-data-update-list (cdr data) offset)))
1827 (setq gnus-newsgroup-data-reverse nil))))
1829 (defun gnus-data-remove (article &optional offset)
1830 (let ((data gnus-newsgroup-data))
1831 (if (= (gnus-data-number (car data)) article)
1832 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1833 gnus-newsgroup-data-reverse nil)
1835 (and (= (gnus-data-number (cadr data)) article)
1837 (setcdr data (cddr data))
1838 (and offset (gnus-data-update-list (cdr data) offset))
1840 gnus-newsgroup-data-reverse nil)))
1841 (setq data (cdr data))))))
1843 (defmacro gnus-data-list (backward)
1845 (or gnus-newsgroup-data-reverse
1846 (setq gnus-newsgroup-data-reverse
1847 (reverse gnus-newsgroup-data)))
1848 gnus-newsgroup-data))
1850 (defun gnus-data-update-list (data offset)
1851 "Add OFFSET to the POS of all data entries in DATA."
1853 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
1854 (setq data (cdr data))))
1856 (defun gnus-data-compute-positions ()
1857 "Compute the positions of all articles."
1858 (let ((data gnus-newsgroup-data)
1861 (when (setq pos (text-property-any
1862 (point-min) (point-max)
1863 'gnus-number (gnus-data-number (car data))))
1864 (gnus-data-set-pos (car data) (+ pos 3)))
1865 (setq data (cdr data)))))
1867 (defun gnus-summary-article-pseudo-p (article)
1868 "Say whether this article is a pseudo article or not."
1869 (not (vectorp (gnus-data-header (gnus-data-find article)))))
1871 (defun gnus-article-parent-p (number)
1872 "Say whether this article is a parent or not."
1873 (let ((data (gnus-data-find-list number)))
1874 (and (cdr data) ; There has to be an article after...
1875 (< (gnus-data-level (car data)) ; And it has to have a higher level.
1876 (gnus-data-level (nth 1 data))))))
1878 (defun gnus-article-children (number)
1879 "Return a list of all children to NUMBER."
1880 (let* ((data (gnus-data-find-list number))
1881 (level (gnus-data-level (car data)))
1883 (setq data (cdr data))
1885 (= (gnus-data-level (car data)) (1+ level)))
1886 (push (gnus-data-number (car data)) children)
1887 (setq data (cdr data)))
1890 (defmacro gnus-summary-skip-intangible ()
1891 "If the current article is intangible, then jump to a different article."
1892 '(let ((to (get-text-property (point) 'gnus-intangible)))
1893 (and to (gnus-summary-goto-subject to))))
1895 (defmacro gnus-summary-article-intangible-p ()
1896 "Say whether this article is intangible or not."
1897 '(get-text-property (point) 'gnus-intangible))
1899 (defun gnus-article-read-p (article)
1900 "Say whether ARTICLE is read or not."
1901 (not (or (memq article gnus-newsgroup-marked)
1902 (memq article gnus-newsgroup-unreads)
1903 (memq article gnus-newsgroup-unselected)
1904 (memq article gnus-newsgroup-dormant))))
1906 ;; Some summary mode macros.
1908 (defmacro gnus-summary-article-number ()
1909 "The article number of the article on the current line.
1910 If there isn's an article number here, then we return the current
1913 (gnus-summary-skip-intangible)
1914 (or (get-text-property (point) 'gnus-number)
1915 (gnus-summary-last-subject))))
1917 (defmacro gnus-summary-article-header (&optional number)
1918 `(gnus-data-header (gnus-data-find
1919 ,(or number '(gnus-summary-article-number)))))
1921 (defmacro gnus-summary-thread-level (&optional number)
1922 `(if (and (eq gnus-summary-make-false-root 'dummy)
1923 (get-text-property (point) 'gnus-intangible))
1925 (gnus-data-level (gnus-data-find
1926 ,(or number '(gnus-summary-article-number))))))
1928 (defmacro gnus-summary-article-mark (&optional number)
1929 `(gnus-data-mark (gnus-data-find
1930 ,(or number '(gnus-summary-article-number)))))
1932 (defmacro gnus-summary-article-pos (&optional number)
1933 `(gnus-data-pos (gnus-data-find
1934 ,(or number '(gnus-summary-article-number)))))
1936 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
1937 (defmacro gnus-summary-article-subject (&optional number)
1938 "Return current subject string or nil if nothing."
1941 `(gnus-data-header (assq ,number gnus-newsgroup-data))
1942 '(gnus-data-header (assq (gnus-summary-article-number)
1943 gnus-newsgroup-data)))))
1946 (mail-header-subject headers))))
1948 (defmacro gnus-summary-article-score (&optional number)
1949 "Return current article score."
1950 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
1951 gnus-newsgroup-scored))
1952 gnus-summary-default-score 0))
1954 (defun gnus-summary-article-children (&optional number)
1955 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
1956 (level (gnus-data-level (car data)))
1958 (while (and (setq data (cdr data))
1959 (> (setq l (gnus-data-level (car data))) level))
1960 (and (= (1+ level) l)
1961 (setq children (cons (gnus-data-number (car data))
1963 (nreverse children)))
1965 (defun gnus-summary-article-parent (&optional number)
1966 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
1967 (gnus-data-list t)))
1968 (level (gnus-data-level (car data))))
1970 () ; This is a root.
1971 ;; We search until we find an article with a level less than
1972 ;; this one. That function has to be the parent.
1973 (while (and (setq data (cdr data))
1974 (not (< (gnus-data-level (car data)) level))))
1975 (and data (gnus-data-number (car data))))))
1977 (defun gnus-unread-mark-p (mark)
1978 "Say whether MARK is the unread mark."
1979 (= mark gnus-unread-mark))
1981 (defun gnus-read-mark-p (mark)
1982 "Say whether MARK is one of the marks that mark as read.
1983 This is all marks except unread, ticked, dormant, and expirable."
1984 (not (or (= mark gnus-unread-mark)
1985 (= mark gnus-ticked-mark)
1986 (= mark gnus-dormant-mark)
1987 (= mark gnus-expirable-mark))))
1989 (defmacro gnus-article-mark (number)
1991 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
1992 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
1993 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
1994 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
1995 (t (or (cdr (assq ,number gnus-newsgroup-reads))
1996 gnus-ancient-mark))))
1998 ;; Saving hidden threads.
2000 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2001 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
2002 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2004 (defmacro gnus-save-hidden-threads (&rest forms)
2005 "Save hidden threads, eval FORMS, and restore the hidden threads."
2006 (let ((config (make-symbol "config")))
2007 `(let ((,config (gnus-hidden-threads-configuration)))
2011 (gnus-restore-hidden-threads-configuration ,config)))))
2013 (defun gnus-hidden-threads-configuration ()
2014 "Return the current hidden threads configuration."
2017 (goto-char (point-min))
2018 (while (search-forward "\r" nil t)
2019 (push (1- (point)) config))
2022 (defun gnus-restore-hidden-threads-configuration (config)
2023 "Restore hidden threads configuration from CONFIG."
2024 (let (point buffer-read-only)
2025 (while (setq point (pop config))
2026 (when (and (< point (point-max))
2028 (= (following-char) ?\n))
2029 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2031 ;; Various summary mode internalish functions.
2033 (defun gnus-mouse-pick-article (e)
2036 (gnus-summary-next-page nil t))
2038 (defun gnus-summary-setup-buffer (group)
2039 "Initialize summary buffer."
2040 (let ((buffer (concat "*Summary " group "*")))
2041 (if (get-buffer buffer)
2044 (setq gnus-summary-buffer (current-buffer))
2045 (not gnus-newsgroup-prepared))
2046 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2047 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2048 (gnus-add-current-to-buffer-list)
2049 (gnus-summary-mode group)
2051 (gnus-carpal-setup-buffer 'summary))
2052 (unless gnus-single-article-buffer
2053 (make-local-variable 'gnus-article-buffer)
2054 (make-local-variable 'gnus-article-current)
2055 (make-local-variable 'gnus-original-article-buffer))
2056 (setq gnus-newsgroup-name group)
2059 (defun gnus-set-global-variables ()
2060 ;; Set the global equivalents of the summary buffer-local variables
2061 ;; to the latest values they had. These reflect the summary buffer
2062 ;; that was in action when the last article was fetched.
2063 (when (eq major-mode 'gnus-summary-mode)
2064 (setq gnus-summary-buffer (current-buffer))
2065 (let ((name gnus-newsgroup-name)
2066 (marked gnus-newsgroup-marked)
2067 (unread gnus-newsgroup-unreads)
2068 (headers gnus-current-headers)
2069 (data gnus-newsgroup-data)
2070 (summary gnus-summary-buffer)
2071 (article-buffer gnus-article-buffer)
2072 (original gnus-original-article-buffer)
2073 (gac gnus-article-current)
2074 (reffed gnus-reffed-article-number)
2075 (score-file gnus-current-score-file))
2077 (set-buffer gnus-group-buffer)
2078 (setq gnus-newsgroup-name name)
2079 (setq gnus-newsgroup-marked marked)
2080 (setq gnus-newsgroup-unreads unread)
2081 (setq gnus-current-headers headers)
2082 (setq gnus-newsgroup-data data)
2083 (setq gnus-article-current gac)
2084 (setq gnus-summary-buffer summary)
2085 (setq gnus-article-buffer article-buffer)
2086 (setq gnus-original-article-buffer original)
2087 (setq gnus-reffed-article-number reffed)
2088 (setq gnus-current-score-file score-file)
2089 ;; The article buffer also has local variables.
2090 (when (gnus-buffer-live-p gnus-article-buffer)
2091 (set-buffer gnus-article-buffer)
2092 (setq gnus-summary-buffer summary))))))
2094 (defun gnus-summary-last-article-p (&optional article)
2095 "Return whether ARTICLE is the last article in the buffer."
2096 (if (not (setq article (or article (gnus-summary-article-number))))
2097 t ; All non-existent numbers are the last article. :-)
2098 (not (cdr (gnus-data-find-list article)))))
2100 (defun gnus-make-thread-indent-array ()
2102 (unless (and gnus-thread-indent-array
2103 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2104 (setq gnus-thread-indent-array (make-vector 201 "")
2105 gnus-thread-indent-array-level gnus-thread-indent-level)
2107 (aset gnus-thread-indent-array n
2108 (make-string (* n gnus-thread-indent-level) ? ))
2111 (defun gnus-update-summary-mark-positions ()
2112 "Compute where the summary marks are to go."
2114 (when (and gnus-summary-buffer
2115 (get-buffer gnus-summary-buffer)
2116 (buffer-name (get-buffer gnus-summary-buffer)))
2117 (set-buffer gnus-summary-buffer))
2118 (let ((gnus-replied-mark 129)
2119 (gnus-score-below-mark 130)
2120 (gnus-score-over-mark 130)
2123 (spec gnus-summary-line-format-spec)
2126 (gnus-set-work-buffer)
2127 (let ((gnus-summary-line-format-spec spec))
2128 (gnus-summary-insert-line
2129 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2130 (goto-char (point-min))
2131 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2133 (goto-char (point-min))
2134 (push (cons 'replied (and (search-forward "\201" nil t)
2137 (goto-char (point-min))
2138 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2140 (setq gnus-summary-mark-positions pos))))
2142 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2143 "Insert a dummy root in the summary buffer."
2145 (gnus-add-text-properties
2146 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2147 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2149 (defun gnus-summary-insert-line (gnus-tmp-header
2150 gnus-tmp-level gnus-tmp-current
2151 gnus-tmp-unread gnus-tmp-replied
2152 gnus-tmp-expirable gnus-tmp-subject-or-nil
2153 &optional gnus-tmp-dummy gnus-tmp-score
2155 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2156 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2157 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2158 (gnus-tmp-score-char
2159 (if (or (null gnus-summary-default-score)
2160 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2161 gnus-summary-zcore-fuzz)) ?
2162 (if (< gnus-tmp-score gnus-summary-default-score)
2163 gnus-score-below-mark gnus-score-over-mark)))
2164 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
2165 ((memq gnus-tmp-current gnus-newsgroup-cached)
2167 (gnus-tmp-replied gnus-replied-mark)
2168 ((memq gnus-tmp-current gnus-newsgroup-saved)
2170 (t gnus-unread-mark)))
2171 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2174 ((string-match "(.+)" gnus-tmp-from)
2175 (substring gnus-tmp-from
2176 (1+ (match-beginning 0)) (1- (match-end 0))))
2177 ((string-match "<[^>]+> *$" gnus-tmp-from)
2178 (let ((beg (match-beginning 0)))
2179 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2180 (substring gnus-tmp-from (1+ (match-beginning 0))
2181 (1- (match-end 0))))
2182 (substring gnus-tmp-from 0 beg))))
2184 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2185 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2186 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2187 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2188 (buffer-read-only nil))
2189 (when (string= gnus-tmp-name "")
2190 (setq gnus-tmp-name gnus-tmp-from))
2191 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
2192 (gnus-put-text-property
2194 (progn (eval gnus-summary-line-format-spec) (point))
2195 'gnus-number gnus-tmp-number)
2196 (when (gnus-visual-p 'summary-highlight 'highlight)
2198 (run-hooks 'gnus-summary-update-hook)
2201 (defun gnus-summary-update-line (&optional dont-update)
2202 ;; Update summary line after change.
2203 (when (and gnus-summary-default-score
2204 (not gnus-summary-inhibit-highlight))
2205 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2206 (article (gnus-summary-article-number))
2207 (score (gnus-summary-article-score article)))
2209 (if (and gnus-summary-mark-below
2210 (< (gnus-summary-article-score)
2211 gnus-summary-mark-below))
2212 ;; This article has a low score, so we mark it as read.
2213 (when (memq article gnus-newsgroup-unreads)
2214 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2215 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2216 ;; This article was previously marked as read on account
2217 ;; of a low score, but now it has risen, so we mark it as
2219 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2220 (gnus-summary-update-mark
2221 (if (or (null gnus-summary-default-score)
2222 (<= (abs (- score gnus-summary-default-score))
2223 gnus-summary-zcore-fuzz)) ?
2224 (if (< score gnus-summary-default-score)
2225 gnus-score-below-mark gnus-score-over-mark)) 'score))
2226 ;; Do visual highlighting.
2227 (when (gnus-visual-p 'summary-highlight 'highlight)
2228 (run-hooks 'gnus-summary-update-hook)))))
2230 (defvar gnus-tmp-new-adopts nil)
2232 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2233 "Return the number of articles in THREAD.
2234 This may be 0 in some cases -- if none of the articles in
2235 the thread are to be displayed."
2237 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2239 ((not (listp thread))
2241 ((and (consp thread) (cdr thread))
2244 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2247 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2250 (when (and level (zerop level) gnus-tmp-new-adopts)
2253 'gnus-summary-number-of-articles-in-thread
2254 gnus-tmp-new-adopts))))
2256 (if (> number 1) gnus-not-empty-thread-mark
2257 gnus-empty-thread-mark)
2260 (defun gnus-summary-set-local-parameters (group)
2261 "Go through the local params of GROUP and set all variable specs in that list."
2262 (let ((params (gnus-group-find-parameter group))
2265 (setq elem (car params)
2266 params (cdr params))
2267 (and (consp elem) ; Has to be a cons.
2268 (consp (cdr elem)) ; The cdr has to be a list.
2269 (symbolp (car elem)) ; Has to be a symbol in there.
2270 (not (memq (car elem)
2271 '(quit-config to-address to-list to-group)))
2272 (progn ; So we set it.
2273 (make-local-variable (car elem))
2274 (set (car elem) (eval (nth 1 elem))))))))
2276 (defun gnus-summary-read-group (group &optional show-all no-article
2277 kill-buffer no-display)
2278 "Start reading news in newsgroup GROUP.
2279 If SHOW-ALL is non-nil, already read articles are also listed.
2280 If NO-ARTICLE is non-nil, no article is selected initially.
2281 If NO-DISPLAY, don't generate a summary buffer."
2282 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2283 (let* ((new-group (gnus-summary-setup-buffer group))
2284 (quit-config (gnus-group-quit-config group))
2285 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2287 ;; This summary buffer exists already, so we just select it.
2289 (gnus-set-global-variables)
2291 (gnus-kill-or-deaden-summary kill-buffer))
2292 (gnus-configure-windows 'summary 'force)
2293 (gnus-set-mode-line 'summary)
2294 (gnus-summary-position-point)
2297 ;; We couldn't select this group.
2299 (when (and (eq major-mode 'gnus-summary-mode)
2300 (not (equal (current-buffer) kill-buffer)))
2301 (kill-buffer (current-buffer))
2302 (if (not quit-config)
2304 (set-buffer gnus-group-buffer)
2305 (gnus-group-jump-to-group group)
2306 (gnus-group-next-unread-group 1))
2307 (if (not (buffer-name (car quit-config)))
2308 (gnus-configure-windows 'group 'force)
2309 (set-buffer (car quit-config))
2310 (and (eq major-mode 'gnus-summary-mode)
2311 (gnus-set-global-variables))
2312 (gnus-configure-windows (cdr quit-config)))))
2313 (gnus-message 3 "Can't select group")
2315 ;; The user did a `C-g' while prompting for number of articles,
2316 ;; so we exit this group.
2317 ((eq did-select 'quit)
2318 (and (eq major-mode 'gnus-summary-mode)
2319 (not (equal (current-buffer) kill-buffer))
2320 (kill-buffer (current-buffer)))
2322 (gnus-kill-or-deaden-summary kill-buffer))
2323 (if (not quit-config)
2325 (set-buffer gnus-group-buffer)
2326 (gnus-group-jump-to-group group)
2327 (gnus-group-next-unread-group 1)
2328 (gnus-configure-windows 'group 'force))
2329 (if (not (buffer-name (car quit-config)))
2330 (gnus-configure-windows 'group 'force)
2331 (set-buffer (car quit-config))
2332 (and (eq major-mode 'gnus-summary-mode)
2333 (gnus-set-global-variables))
2334 (gnus-configure-windows (cdr quit-config))))
2335 ;; Finally signal the quit.
2337 ;; The group was successfully selected.
2339 (gnus-set-global-variables)
2340 ;; Save the active value in effect when the group was entered.
2341 (setq gnus-newsgroup-active
2343 (gnus-active gnus-newsgroup-name)))
2344 ;; You can change the summary buffer in some way with this hook.
2345 (run-hooks 'gnus-select-group-hook)
2346 ;; Set any local variables in the group parameters.
2347 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2348 (gnus-update-format-specifications
2349 nil 'summary 'summary-mode 'summary-dummy)
2350 ;; Do score processing.
2351 (when gnus-use-scoring
2352 (gnus-possibly-score-headers))
2353 ;; Check whether to fill in the gaps in the threads.
2354 (when gnus-build-sparse-threads
2355 (gnus-build-sparse-threads))
2356 ;; Find the initial limit.
2357 (if gnus-show-threads
2359 (let ((gnus-newsgroup-dormant nil))
2360 (gnus-summary-initial-limit show-all))
2361 (gnus-summary-initial-limit show-all))
2362 (setq gnus-newsgroup-limit
2364 (lambda (header) (mail-header-number header))
2365 gnus-newsgroup-headers)))
2366 ;; Generate the summary buffer.
2368 (gnus-summary-prepare))
2369 (when gnus-use-trees
2370 (gnus-tree-open group)
2371 (setq gnus-summary-highlight-line-function
2372 'gnus-tree-highlight-article))
2373 ;; If the summary buffer is empty, but there are some low-scored
2374 ;; articles or some excluded dormants, we include these in the
2376 (when (and (zerop (buffer-size))
2378 (cond (gnus-newsgroup-dormant
2379 (gnus-summary-limit-include-dormant))
2380 ((and gnus-newsgroup-scored show-all)
2381 (gnus-summary-limit-include-expunged t))))
2382 ;; Function `gnus-apply-kill-file' must be called in this hook.
2383 (run-hooks 'gnus-apply-kill-hook)
2384 (if (and (zerop (buffer-size))
2387 ;; This newsgroup is empty.
2388 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2389 (gnus-message 6 "No unread news")
2391 (gnus-kill-or-deaden-summary kill-buffer))
2392 ;; Return nil from this function.
2394 ;; Hide conversation thread subtrees. We cannot do this in
2395 ;; gnus-summary-prepare-hook since kill processing may not
2396 ;; work with hidden articles.
2397 (and gnus-show-threads
2398 gnus-thread-hide-subtree
2399 (gnus-summary-hide-all-threads))
2400 ;; Show first unread article if requested.
2401 (if (and (not no-article)
2403 gnus-newsgroup-unreads
2404 gnus-auto-select-first)
2405 (unless (if (eq gnus-auto-select-first 'best)
2406 (gnus-summary-best-unread-article)
2407 (gnus-summary-first-unread-article))
2408 (gnus-configure-windows 'summary))
2409 ;; Don't select any articles, just move point to the first
2410 ;; article in the group.
2411 (goto-char (point-min))
2412 (gnus-summary-position-point)
2413 (gnus-set-mode-line 'summary)
2414 (gnus-configure-windows 'summary 'force))
2416 (gnus-kill-or-deaden-summary kill-buffer))
2417 (when (get-buffer-window gnus-group-buffer t)
2418 ;; Gotta use windows, because recenter does weird stuff if
2419 ;; the current buffer ain't the displayed window.
2420 (let ((owin (selected-window)))
2421 (select-window (get-buffer-window gnus-group-buffer t))
2422 (when (gnus-group-goto-group group)
2424 (select-window owin))))
2425 ;; Mark this buffer as "prepared".
2426 (setq gnus-newsgroup-prepared t)
2429 (defun gnus-summary-prepare ()
2430 "Generate the summary buffer."
2432 (let ((buffer-read-only nil))
2434 (setq gnus-newsgroup-data nil
2435 gnus-newsgroup-data-reverse nil)
2436 (run-hooks 'gnus-summary-generate-hook)
2437 ;; Generate the buffer, either with threads or without.
2438 (when gnus-newsgroup-headers
2439 (gnus-summary-prepare-threads
2440 (if gnus-show-threads
2441 (gnus-sort-gathered-threads
2442 (funcall gnus-summary-thread-gathering-function
2444 (gnus-cut-threads (gnus-make-threads)))))
2445 ;; Unthreaded display.
2446 (gnus-sort-articles gnus-newsgroup-headers))))
2447 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2448 ;; Call hooks for modifying summary buffer.
2449 (goto-char (point-min))
2450 (run-hooks 'gnus-summary-prepare-hook)))
2452 (defsubst gnus-general-simplify-subject (subject)
2453 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2456 ;; Truncate the subject.
2457 ((numberp gnus-summary-gather-subject-limit)
2458 (setq subject (gnus-simplify-subject-re subject))
2459 (if (> (length subject) gnus-summary-gather-subject-limit)
2460 (substring subject 0 gnus-summary-gather-subject-limit)
2462 ;; Fuzzily simplify it.
2463 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2464 (gnus-simplify-subject-fuzzy subject))
2465 ;; Just remove the leading "Re:".
2467 (gnus-simplify-subject-re subject))))
2469 (if (and gnus-summary-gather-exclude-subject
2470 (string-match gnus-summary-gather-exclude-subject subject))
2471 nil ; This article shouldn't be gathered
2474 (defun gnus-summary-simplify-subject-query ()
2475 "Query where the respool algorithm would put this article."
2477 (gnus-set-global-variables)
2478 (gnus-summary-select-article)
2479 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2481 (defun gnus-gather-threads-by-subject (threads)
2482 "Gather threads by looking at Subject headers."
2483 (if (not gnus-summary-make-false-root)
2485 (let ((hashtb (gnus-make-hashtable 1023))
2488 subject hthread whole-subject)
2490 (setq subject (gnus-general-simplify-subject
2491 (setq whole-subject (mail-header-subject
2494 (if (setq hthread (gnus-gethash subject hashtb))
2496 ;; We enter a dummy root into the thread, if we
2497 ;; haven't done that already.
2498 (unless (stringp (caar hthread))
2499 (setcar hthread (list whole-subject (car hthread))))
2500 ;; We add this new gathered thread to this gathered
2502 (setcdr (car hthread)
2503 (nconc (cdar hthread) (list (car threads))))
2504 ;; Remove it from the list of threads.
2505 (setcdr prev (cdr threads))
2506 (setq threads prev))
2507 ;; Enter this thread into the hash table.
2508 (gnus-sethash subject threads hashtb)))
2510 (setq threads (cdr threads)))
2513 (defun gnus-gather-threads-by-references (threads)
2514 "Gather threads by looking at References headers."
2515 (let ((idhashtb (gnus-make-hashtable 1023))
2516 (thhashtb (gnus-make-hashtable 1023))
2519 ids references id gthread gid entered ref)
2521 (when (setq references (mail-header-references (caar threads)))
2522 (setq id (mail-header-id (caar threads))
2523 ids (gnus-split-references references)
2525 (while (setq ref (pop ids))
2526 (setq ids (delete ref ids))
2527 (if (not (setq gid (gnus-gethash ref idhashtb)))
2529 (gnus-sethash ref id idhashtb)
2530 (gnus-sethash id threads thhashtb))
2531 (setq gthread (gnus-gethash gid thhashtb))
2533 ;; We enter a dummy root into the thread, if we
2534 ;; haven't done that already.
2535 (unless (stringp (caar gthread))
2536 (setcar gthread (list (mail-header-subject (caar gthread))
2538 ;; We add this new gathered thread to this gathered
2540 (setcdr (car gthread)
2541 (nconc (cdar gthread) (list (car threads)))))
2542 ;; Add it into the thread hash table.
2543 (gnus-sethash id gthread thhashtb)
2545 ;; Remove it from the list of threads.
2546 (setcdr prev (cdr threads))
2547 (setq threads prev))))
2549 (setq threads (cdr threads)))
2552 (defun gnus-sort-gathered-threads (threads)
2553 "Sort subtreads inside each gathered thread by article number."
2554 (let ((result threads))
2556 (when (stringp (caar threads))
2557 (setcdr (car threads)
2558 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2559 (setq threads (cdr threads)))
2562 (defun gnus-make-threads ()
2563 "Go through the dependency hashtb and find the roots. Return all threads."
2567 (unless (car (symbol-value refs))
2568 ;; These threads do not refer back to any other articles,
2569 ;; so they're roots.
2570 (setq threads (append (cdr (symbol-value refs)) threads))))
2571 gnus-newsgroup-dependencies)
2574 (defun gnus-build-sparse-threads ()
2575 (let ((headers gnus-newsgroup-headers)
2576 (deps gnus-newsgroup-dependencies)
2577 header references generation relations
2578 cthread subject child end pthread relation)
2579 ;; First we create an alist of generations/relations, where
2580 ;; generations is how much we trust the relation, and the relation
2582 (gnus-message 7 "Making sparse threads...")
2584 (nnheader-set-temp-buffer " *gnus sparse threads*")
2585 (while (setq header (pop headers))
2586 (when (and (setq references (mail-header-references header))
2587 (not (string= references "")))
2589 (setq child (mail-header-id header)
2590 subject (mail-header-subject header))
2592 (while (search-backward ">" nil t)
2593 (setq end (1+ (point)))
2594 (when (search-backward "<" nil t)
2595 (push (list (incf generation)
2596 child (setq child (buffer-substring (point) end))
2599 (push (list (1+ generation) child nil subject) relations)
2601 (kill-buffer (current-buffer)))
2602 ;; Sort over trustworthiness.
2603 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2604 (while (setq relation (pop relations))
2605 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2606 (unless (car (symbol-value cthread))
2607 ;; Make this article the parent of these threads.
2608 (setcar (symbol-value cthread)
2609 (vector gnus-reffed-article-number
2613 (or (caddr relation) "") 0 0 "")))
2614 (set cthread (list (vector gnus-reffed-article-number
2616 "" "" (cadr relation)
2617 (or (caddr relation) "") 0 0 ""))))
2618 (push gnus-reffed-article-number gnus-newsgroup-limit)
2619 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2620 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2621 gnus-newsgroup-reads)
2622 (decf gnus-reffed-article-number)
2623 ;; Make this new thread the child of its parent.
2624 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2625 (setcdr (symbol-value pthread)
2626 (nconc (cdr (symbol-value pthread))
2627 (list (symbol-value cthread))))
2628 (set pthread (list nil (symbol-value cthread))))))
2629 (gnus-message 7 "Making sparse threads...done")))
2631 (defun gnus-build-old-threads ()
2632 ;; Look at all the articles that refer back to old articles, and
2633 ;; fetch the headers for the articles that aren't there. This will
2634 ;; build complete threads - if the roots haven't been expired by the
2639 (when (not (car (symbol-value refs)))
2640 (setq heads (cdr (symbol-value refs)))
2642 (if (memq (mail-header-number (caar heads))
2643 gnus-newsgroup-dormant)
2644 (setq heads (cdr heads))
2645 (setq id (symbol-name refs))
2646 (while (and (setq id (gnus-build-get-header id))
2647 (not (car (gnus-gethash
2648 id gnus-newsgroup-dependencies)))))
2649 (setq heads nil)))))
2650 gnus-newsgroup-dependencies)))
2652 (defun gnus-build-get-header (id)
2653 ;; Look through the buffer of NOV lines and find the header to
2654 ;; ID. Enter this line into the dependencies hash table, and return
2655 ;; the id of the parent article (if any).
2656 (let ((deps gnus-newsgroup-dependencies)
2660 (set-buffer nntp-server-buffer)
2661 (goto-char (point-min))
2662 (while (and (not found) (search-forward id nil t))
2664 (setq found (looking-at
2665 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2666 (regexp-quote id))))
2667 (or found (beginning-of-line 2)))
2671 (setq header (gnus-nov-parse-line
2672 (read (current-buffer)) deps))
2673 (gnus-parent-id (mail-header-references header)))))
2675 (let ((number (mail-header-number header)))
2676 (push number gnus-newsgroup-limit)
2677 (push header gnus-newsgroup-headers)
2678 (if (memq number gnus-newsgroup-unselected)
2680 (push number gnus-newsgroup-unreads)
2681 (setq gnus-newsgroup-unselected
2682 (delq number gnus-newsgroup-unselected)))
2683 (push number gnus-newsgroup-ancient)))))))
2685 (defun gnus-summary-update-article-line (article header)
2686 "Update the line for ARTICLE using HEADERS."
2687 (let* ((id (mail-header-id header))
2688 (thread (gnus-id-to-thread id)))
2690 (error "Article in no thread"))
2691 ;; Update the thread.
2692 (setcar thread header)
2693 (gnus-summary-goto-subject article)
2694 (let* ((datal (gnus-data-find-list article))
2696 (length (when (cdr datal)
2697 (- (gnus-data-pos data)
2698 (gnus-data-pos (cadr datal)))))
2699 (buffer-read-only nil)
2700 (level (gnus-summary-thread-level)))
2702 (gnus-summary-insert-line
2703 header level nil (gnus-article-mark article)
2704 (memq article gnus-newsgroup-replied)
2705 (memq article gnus-newsgroup-expirable)
2706 (mail-header-subject header)
2707 nil (cdr (assq article gnus-newsgroup-scored))
2708 (memq article gnus-newsgroup-processable))
2710 (gnus-data-update-list
2711 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2713 (defun gnus-summary-update-article (article &optional iheader)
2714 "Update ARTICLE in the summary buffer."
2715 (set-buffer gnus-summary-buffer)
2716 (let* ((header (or iheader (gnus-summary-article-header article)))
2717 (id (mail-header-id header))
2718 (data (gnus-data-find article))
2719 (thread (gnus-id-to-thread id))
2720 (references (mail-header-references header))
2725 (not (equal "" references)))
2728 (buffer-read-only nil)
2730 (number (mail-header-number header))
2733 ;; !!! Should this be in or not?
2735 (setcar thread nil))
2737 (delq thread parent))
2738 (if (gnus-summary-insert-subject id header iheader)
2739 ;; Set the (possibly) new article number in the data structure.
2740 (gnus-data-set-number data (gnus-id-to-article id))
2744 (defun gnus-rebuild-thread (id)
2745 "Rebuild the thread containing ID."
2746 (let ((buffer-read-only nil)
2747 current thread data)
2748 (if (not gnus-show-threads)
2749 (setq thread (list (car (gnus-id-to-thread id))))
2750 ;; Get the thread this article is part of.
2751 (setq thread (gnus-remove-thread id)))
2752 (setq current (save-excursion
2753 (and (zerop (forward-line -1))
2754 (gnus-summary-article-number))))
2755 ;; If this is a gathered thread, we have to go some re-gathering.
2756 (when (stringp (car thread))
2757 (let ((subject (car thread))
2759 (setq thread (cdr thread))
2761 (unless (memq (setq thr (gnus-id-to-thread
2763 (mail-header-id (caar thread)))))
2766 (setq thread (cdr thread)))
2767 ;; We now have all (unique) roots.
2768 (if (= (length roots) 1)
2769 ;; All the loose roots are now one solid root.
2770 (setq thread (car roots))
2771 (setq thread (cons subject (gnus-sort-threads roots))))))
2773 ;; We then insert this thread into the summary buffer.
2774 (let (gnus-newsgroup-data gnus-newsgroup-threads)
2775 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
2776 (setq data (nreverse gnus-newsgroup-data))
2777 (setq threads gnus-newsgroup-threads))
2778 ;; We splice the new data into the data structure.
2779 (gnus-data-enter-list current data)
2780 (gnus-data-compute-positions)
2781 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
2783 (defun gnus-number-to-header (number)
2784 "Return the header for article NUMBER."
2785 (let ((headers gnus-newsgroup-headers))
2787 (not (= number (mail-header-number (car headers)))))
2792 (defun gnus-parent-headers (headers &optional generation)
2793 "Return the headers of the GENERATIONeth parent of HEADERS."
2795 (setq generation 1))
2796 (let (references parent)
2797 (while (and headers (not (zerop generation)))
2798 (setq references (mail-header-references headers))
2799 (when (and references
2800 (setq parent (gnus-parent-id references))
2801 (setq headers (car (gnus-id-to-thread parent))))
2805 (defun gnus-id-to-thread (id)
2806 "Return the (sub-)thread where ID appears."
2807 (gnus-gethash id gnus-newsgroup-dependencies))
2809 (defun gnus-id-to-article (id)
2810 "Return the article number of ID."
2811 (let ((thread (gnus-id-to-thread id)))
2814 (mail-header-number (car thread)))))
2816 (defun gnus-id-to-header (id)
2817 "Return the article headers of ID."
2818 (car (gnus-id-to-thread id)))
2820 (defun gnus-article-displayed-root-p (article)
2821 "Say whether ARTICLE is a root(ish) article."
2822 (let ((level (gnus-summary-thread-level article))
2823 (refs (mail-header-references (gnus-summary-article-header article)))
2829 ((null (gnus-parent-id refs)) t)
2831 (null (setq particle (gnus-id-to-article
2832 (gnus-parent-id refs))))
2833 (null (gnus-summary-thread-level particle)))))))
2835 (defun gnus-root-id (id)
2836 "Return the id of the root of the thread where ID appears."
2838 (while (and id (setq prev (car (gnus-gethash
2839 id gnus-newsgroup-dependencies))))
2841 id (gnus-parent-id (mail-header-references prev))))
2844 (defun gnus-remove-thread (id &optional dont-remove)
2845 "Remove the thread that has ID in it."
2846 (let ((dep gnus-newsgroup-dependencies)
2847 headers thread last-id)
2848 ;; First go up in this thread until we find the root.
2849 (setq last-id (gnus-root-id id))
2850 (setq headers (list (car (gnus-id-to-thread last-id))
2851 (caadr (gnus-id-to-thread last-id))))
2852 ;; We have now found the real root of this thread. It might have
2853 ;; been gathered into some loose thread, so we have to search
2854 ;; through the threads to find the thread we wanted.
2855 (let ((threads gnus-newsgroup-threads)
2858 (setq sub (car threads))
2859 (if (stringp (car sub))
2860 ;; This is a gathered thread, so we look at the roots
2861 ;; below it to find whether this article is in this
2864 (setq sub (cdr sub))
2866 (when (member (caar sub) headers)
2867 (setq thread (car threads)
2870 (setq sub (cdr sub))))
2871 ;; It's an ordinary thread, so we check it.
2872 (when (eq (car sub) (car headers))
2875 (setq threads (cdr threads)))
2876 ;; If this article is in no thread, then it's a root.
2879 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
2880 (setq thread (gnus-gethash last-id dep)))
2883 thread ; We return this thread.
2885 (if (stringp (car thread))
2887 ;; If we use dummy roots, then we have to remove the
2888 ;; dummy root as well.
2889 (when (eq gnus-summary-make-false-root 'dummy)
2892 (setq thread (cdr thread))
2894 (gnus-remove-thread-1 (car thread))
2895 (setq thread (cdr thread))))
2896 (gnus-remove-thread-1 thread))))))))
2898 (defun gnus-remove-thread-1 (thread)
2899 "Remove the thread THREAD recursively."
2900 (let ((number (mail-header-number (car thread)))
2902 (when (setq pos (text-property-any
2903 (point-min) (point-max) 'gnus-number number))
2906 (gnus-data-remove number))
2907 (setq thread (cdr thread))
2909 (gnus-remove-thread-1 (pop thread)))))
2911 (defun gnus-sort-threads (threads)
2913 (if (not gnus-thread-sort-functions)
2915 (gnus-message 7 "Sorting threads...")
2917 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
2918 (gnus-message 7 "Sorting threads...done"))))
2920 (defun gnus-sort-articles (articles)
2922 (when gnus-article-sort-functions
2923 (gnus-message 7 "Sorting articles...")
2925 (setq gnus-newsgroup-headers
2926 (sort articles (gnus-make-sort-function
2927 gnus-article-sort-functions)))
2928 (gnus-message 7 "Sorting articles...done"))))
2930 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2931 (defmacro gnus-thread-header (thread)
2932 ;; Return header of first article in THREAD.
2933 ;; Note that THREAD must never, ever be anything else than a variable -
2934 ;; using some other form will lead to serious barfage.
2935 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
2936 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
2937 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
2940 (defsubst gnus-article-sort-by-number (h1 h2)
2941 "Sort articles by article number."
2942 (< (mail-header-number h1)
2943 (mail-header-number h2)))
2945 (defun gnus-thread-sort-by-number (h1 h2)
2946 "Sort threads by root article number."
2947 (gnus-article-sort-by-number
2948 (gnus-thread-header h1) (gnus-thread-header h2)))
2950 (defsubst gnus-article-sort-by-author (h1 h2)
2951 "Sort articles by root author."
2953 (let ((extract (funcall
2954 gnus-extract-address-components
2955 (mail-header-from h1))))
2956 (or (car extract) (cdr extract)))
2957 (let ((extract (funcall
2958 gnus-extract-address-components
2959 (mail-header-from h2))))
2960 (or (car extract) (cdr extract)))))
2962 (defun gnus-thread-sort-by-author (h1 h2)
2963 "Sort threads by root author."
2964 (gnus-article-sort-by-author
2965 (gnus-thread-header h1) (gnus-thread-header h2)))
2967 (defsubst gnus-article-sort-by-subject (h1 h2)
2968 "Sort articles by root subject."
2970 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
2971 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
2973 (defun gnus-thread-sort-by-subject (h1 h2)
2974 "Sort threads by root subject."
2975 (gnus-article-sort-by-subject
2976 (gnus-thread-header h1) (gnus-thread-header h2)))
2978 (defsubst gnus-article-sort-by-date (h1 h2)
2979 "Sort articles by root article date."
2981 (inline (gnus-sortable-date (mail-header-date h1)))
2982 (inline (gnus-sortable-date (mail-header-date h2)))))
2984 (defun gnus-thread-sort-by-date (h1 h2)
2985 "Sort threads by root article date."
2986 (gnus-article-sort-by-date
2987 (gnus-thread-header h1) (gnus-thread-header h2)))
2989 (defsubst gnus-article-sort-by-score (h1 h2)
2990 "Sort articles by root article score.
2991 Unscored articles will be counted as having a score of zero."
2992 (> (or (cdr (assq (mail-header-number h1)
2993 gnus-newsgroup-scored))
2994 gnus-summary-default-score 0)
2995 (or (cdr (assq (mail-header-number h2)
2996 gnus-newsgroup-scored))
2997 gnus-summary-default-score 0)))
2999 (defun gnus-thread-sort-by-score (h1 h2)
3000 "Sort threads by root article score."
3001 (gnus-article-sort-by-score
3002 (gnus-thread-header h1) (gnus-thread-header h2)))
3004 (defun gnus-thread-sort-by-total-score (h1 h2)
3005 "Sort threads by the sum of all scores in the thread.
3006 Unscored articles will be counted as having a score of zero."
3007 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3009 (defun gnus-thread-total-score (thread)
3010 ;; This function find the total score of THREAD.
3011 (cond ((null thread)
3014 (if (stringp (car thread))
3015 (apply gnus-thread-score-function 0
3016 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3017 (gnus-thread-total-score-1 thread)))
3019 (gnus-thread-total-score-1 (list thread)))))
3021 (defun gnus-thread-total-score-1 (root)
3022 ;; This function find the total score of the thread below ROOT.
3023 (setq root (car root))
3024 (apply gnus-thread-score-function
3026 (mapcar 'gnus-thread-total-score
3027 (cdr (gnus-gethash (mail-header-id root)
3028 gnus-newsgroup-dependencies)))
3029 (if (> (mail-header-number root) 0)
3030 (list (or (cdr (assq (mail-header-number root)
3031 gnus-newsgroup-scored))
3032 gnus-summary-default-score 0))))
3033 (list gnus-summary-default-score)
3036 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3037 (defvar gnus-tmp-prev-subject nil)
3038 (defvar gnus-tmp-false-parent nil)
3039 (defvar gnus-tmp-root-expunged nil)
3040 (defvar gnus-tmp-dummy-line nil)
3042 (defun gnus-summary-prepare-threads (threads)
3043 "Prepare summary buffer from THREADS and indentation LEVEL.
3044 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3045 or a straight list of headers."
3046 (gnus-message 7 "Generating summary...")
3048 (setq gnus-newsgroup-threads threads)
3051 (let ((gnus-tmp-level 0)
3052 (default-score (or gnus-summary-default-score 0))
3053 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3054 thread number subject stack state gnus-tmp-gathered beg-match
3055 new-roots gnus-tmp-new-adopts thread-end
3056 gnus-tmp-header gnus-tmp-unread
3057 gnus-tmp-replied gnus-tmp-subject-or-nil
3058 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3059 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3060 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3062 (setq gnus-tmp-prev-subject nil)
3064 (if (vectorp (car threads))
3065 ;; If this is a straight (sic) list of headers, then a
3066 ;; threaded summary display isn't required, so we just create
3067 ;; an unthreaded one.
3068 (gnus-summary-prepare-unthreaded threads)
3070 ;; Do the threaded display.
3072 (while (or threads stack gnus-tmp-new-adopts new-roots)
3074 (if (and (= gnus-tmp-level 0)
3075 (not (setq gnus-tmp-dummy-line nil))
3078 (not gnus-tmp-false-parent)
3079 (or gnus-tmp-new-adopts new-roots))
3080 (if gnus-tmp-new-adopts
3081 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3082 thread (list (car gnus-tmp-new-adopts))
3083 gnus-tmp-header (caar thread)
3084 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3086 (setq thread (list (car new-roots))
3087 gnus-tmp-header (caar thread)
3088 new-roots (cdr new-roots))))
3091 ;; If there are some threads, we do them before the
3092 ;; threads on the stack.
3093 (setq thread threads
3094 gnus-tmp-header (caar thread))
3095 ;; There were no current threads, so we pop something off
3097 (setq state (car stack)
3098 gnus-tmp-level (car state)
3101 gnus-tmp-header (caar thread))))
3103 (setq gnus-tmp-false-parent nil)
3104 (setq gnus-tmp-root-expunged nil)
3105 (setq thread-end nil)
3107 (if (stringp gnus-tmp-header)
3108 ;; The header is a dummy root.
3110 ((eq gnus-summary-make-false-root 'adopt)
3111 ;; We let the first article adopt the rest.
3112 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3114 (setq gnus-tmp-gathered
3116 (lambda (h) (mail-header-number (car h)))
3119 (setq thread (cons (list (caar thread)
3122 (setq gnus-tmp-level -1
3123 gnus-tmp-false-parent t))
3124 ((eq gnus-summary-make-false-root 'empty)
3125 ;; We print adopted articles with empty subject fields.
3126 (setq gnus-tmp-gathered
3128 (lambda (h) (mail-header-number (car h)))
3131 (setq gnus-tmp-level -1))
3132 ((eq gnus-summary-make-false-root 'dummy)
3133 ;; We remember that we probably want to output a dummy
3135 (setq gnus-tmp-dummy-line gnus-tmp-header)
3136 (setq gnus-tmp-prev-subject gnus-tmp-header))
3138 ;; We do not make a root for the gathered
3139 ;; sub-threads at all.
3140 (setq gnus-tmp-level -1)))
3142 (setq number (mail-header-number gnus-tmp-header)
3143 subject (mail-header-subject gnus-tmp-header))
3146 ;; If the thread has changed subject, we might want to make
3147 ;; this subthread into a root.
3148 ((and (null gnus-thread-ignore-subject)
3149 (not (zerop gnus-tmp-level))
3150 gnus-tmp-prev-subject
3152 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3153 (setq new-roots (nconc new-roots (list (car thread)))
3155 gnus-tmp-header nil))
3156 ;; If the article lies outside the current limit,
3157 ;; then we do not display it.
3158 ((and (not (memq number gnus-newsgroup-limit))
3159 (not gnus-tmp-dummy-line))
3160 (setq gnus-tmp-gathered
3162 (lambda (h) (mail-header-number (car h)))
3165 (setq gnus-tmp-new-adopts (if (cdar thread)
3166 (append gnus-tmp-new-adopts
3168 gnus-tmp-new-adopts)
3170 gnus-tmp-header nil)
3171 (when (zerop gnus-tmp-level)
3172 (setq gnus-tmp-root-expunged t)))
3173 ;; Perhaps this article is to be marked as read?
3174 ((and gnus-summary-mark-below
3175 (< (or (cdr (assq number gnus-newsgroup-scored))
3177 gnus-summary-mark-below)
3178 ;; Don't touch sparse articles.
3179 (not (memq number gnus-newsgroup-sparse))
3180 (not (memq number gnus-newsgroup-ancient)))
3181 (setq gnus-newsgroup-unreads
3182 (delq number gnus-newsgroup-unreads))
3183 (if gnus-newsgroup-auto-expire
3184 (push number gnus-newsgroup-expirable)
3185 (push (cons number gnus-low-score-mark)
3186 gnus-newsgroup-reads))))
3188 (when gnus-tmp-header
3189 ;; We may have an old dummy line to output before this
3191 (when gnus-tmp-dummy-line
3192 (gnus-summary-insert-dummy-line
3193 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3194 (setq gnus-tmp-dummy-line nil))
3196 ;; Compute the mark.
3197 (setq gnus-tmp-unread (gnus-article-mark number))
3199 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3200 gnus-tmp-header gnus-tmp-level)
3201 gnus-newsgroup-data)
3203 ;; Actually insert the line.
3205 gnus-tmp-subject-or-nil
3207 ((and gnus-thread-ignore-subject
3208 gnus-tmp-prev-subject
3209 (not (inline (gnus-subject-equal
3210 gnus-tmp-prev-subject subject))))
3212 ((zerop gnus-tmp-level)
3213 (if (and (eq gnus-summary-make-false-root 'empty)
3214 (memq number gnus-tmp-gathered)
3215 gnus-tmp-prev-subject
3216 (inline (gnus-subject-equal
3217 gnus-tmp-prev-subject subject)))
3218 gnus-summary-same-subject
3220 (t gnus-summary-same-subject)))
3221 (if (and (eq gnus-summary-make-false-root 'adopt)
3222 (= gnus-tmp-level 1)
3223 (memq number gnus-tmp-gathered))
3224 (setq gnus-tmp-opening-bracket ?\<
3225 gnus-tmp-closing-bracket ?\>)
3226 (setq gnus-tmp-opening-bracket ?\[
3227 gnus-tmp-closing-bracket ?\]))
3229 gnus-tmp-indentation
3230 (aref gnus-thread-indent-array gnus-tmp-level)
3231 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3232 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3233 gnus-summary-default-score 0)
3235 (if (or (null gnus-summary-default-score)
3236 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3237 gnus-summary-zcore-fuzz)) ?
3238 (if (< gnus-tmp-score gnus-summary-default-score)
3239 gnus-score-below-mark gnus-score-over-mark))
3241 (cond ((memq number gnus-newsgroup-processable)
3243 ((memq number gnus-newsgroup-cached)
3245 ((memq number gnus-newsgroup-replied)
3247 ((memq number gnus-newsgroup-saved)
3249 (t gnus-unread-mark))
3250 gnus-tmp-from (mail-header-from gnus-tmp-header)
3253 ((string-match "(.+)" gnus-tmp-from)
3254 (substring gnus-tmp-from
3255 (1+ (match-beginning 0)) (1- (match-end 0))))
3256 ((string-match "<[^>]+> *$" gnus-tmp-from)
3257 (setq beg-match (match-beginning 0))
3258 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3259 (substring gnus-tmp-from (1+ (match-beginning 0))
3260 (1- (match-end 0))))
3261 (substring gnus-tmp-from 0 beg-match)))
3263 (when (string= gnus-tmp-name "")
3264 (setq gnus-tmp-name gnus-tmp-from))
3265 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
3266 (gnus-put-text-property
3268 (progn (eval gnus-summary-line-format-spec) (point))
3269 'gnus-number number)
3272 (run-hooks 'gnus-summary-update-hook)
3275 (setq gnus-tmp-prev-subject subject)))
3277 (when (nth 1 thread)
3278 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3279 (incf gnus-tmp-level)
3280 (setq threads (if thread-end nil (cdar thread)))
3282 (setq gnus-tmp-level 0)))))
3283 (gnus-message 7 "Generating summary...done"))
3285 (defun gnus-summary-prepare-unthreaded (headers)
3286 "Generate an unthreaded summary buffer based on HEADERS."
3287 (let (header number mark)
3290 ;; We may have to root out some bad articles...
3291 (when (memq (setq number (mail-header-number
3292 (setq header (pop headers))))
3293 gnus-newsgroup-limit)
3294 ;; Mark article as read when it has a low score.
3295 (when (and gnus-summary-mark-below
3296 (< (or (cdr (assq number gnus-newsgroup-scored))
3297 gnus-summary-default-score 0)
3298 gnus-summary-mark-below)
3299 (not (memq number gnus-newsgroup-ancient)))
3300 (setq gnus-newsgroup-unreads
3301 (delq number gnus-newsgroup-unreads))
3302 (if gnus-newsgroup-auto-expire
3303 (push number gnus-newsgroup-expirable)
3304 (push (cons number gnus-low-score-mark)
3305 gnus-newsgroup-reads)))
3307 (setq mark (gnus-article-mark number))
3308 (setq gnus-newsgroup-data
3309 (cons (gnus-data-make number mark (1+ (point)) header 0)
3310 gnus-newsgroup-data))
3311 (gnus-summary-insert-line
3312 header 0 nil mark (memq number gnus-newsgroup-replied)
3313 (memq number gnus-newsgroup-expirable)
3314 (mail-header-subject header) nil
3315 (cdr (assq number gnus-newsgroup-scored))
3316 (memq number gnus-newsgroup-processable))))))
3318 (defun gnus-select-newsgroup (group &optional read-all)
3319 "Select newsgroup GROUP.
3320 If READ-ALL is non-nil, all articles in the group are selected."
3321 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3322 (info (nth 2 entry))
3323 articles fetched-articles cached)
3325 (or (gnus-check-server
3326 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3327 (error "Couldn't open server"))
3329 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3330 (gnus-activate-group group) ; Or we can activate it...
3331 (progn ; Or we bug out.
3332 (when (equal major-mode 'gnus-summary-mode)
3333 (kill-buffer (current-buffer)))
3334 (error "Couldn't request group %s: %s"
3335 group (gnus-status-message group))))
3337 (unless (gnus-request-group group t)
3338 (when (equal major-mode 'gnus-summary-mode)
3339 (kill-buffer (current-buffer)))
3340 (error "Couldn't request group %s: %s"
3341 group (gnus-status-message group)))
3343 (setq gnus-newsgroup-name group)
3344 (setq gnus-newsgroup-unselected nil)
3345 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3347 ;; Adjust and set lists of article marks.
3349 (gnus-adjust-marked-articles info))
3351 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3352 (when (gnus-virtual-group-p group)
3353 (setq cached gnus-newsgroup-cached))
3355 (setq gnus-newsgroup-unreads
3356 (gnus-set-difference
3357 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3358 gnus-newsgroup-dormant))
3360 (setq gnus-newsgroup-processable nil)
3362 (setq articles (gnus-articles-to-read group read-all))
3366 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3368 ((eq articles 0) nil)
3370 ;; Init the dependencies hash table.
3371 (setq gnus-newsgroup-dependencies
3372 (gnus-make-hashtable (length articles)))
3373 ;; Retrieve the headers and read them in.
3374 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3375 (setq gnus-newsgroup-headers
3377 (setq gnus-headers-retrieved-by
3378 (gnus-retrieve-headers
3379 articles gnus-newsgroup-name
3380 ;; We might want to fetch old headers, but
3381 ;; not if there is only 1 article.
3382 (and gnus-fetch-old-headers
3384 (not (eq gnus-fetch-old-headers 'some))
3385 (not (numberp gnus-fetch-old-headers)))
3386 (> (length articles) 1))))))
3387 (gnus-get-newsgroup-headers-xover articles)
3388 (gnus-get-newsgroup-headers)))
3389 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3391 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3393 (setq gnus-newsgroup-cached cached))
3395 ;; Suppress duplicates?
3396 (when gnus-suppress-duplicates
3397 (gnus-dup-suppress-articles))
3399 ;; Set the initial limit.
3400 (setq gnus-newsgroup-limit (copy-sequence articles))
3401 ;; Remove canceled articles from the list of unread articles.
3402 (setq gnus-newsgroup-unreads
3403 (gnus-set-sorted-intersection
3404 gnus-newsgroup-unreads
3405 (setq fetched-articles
3406 (mapcar (lambda (headers) (mail-header-number headers))
3407 gnus-newsgroup-headers))))
3408 ;; Removed marked articles that do not exist.
3409 (gnus-update-missing-marks
3410 (gnus-sorted-complement fetched-articles articles))
3411 ;; We might want to build some more threads first.
3412 (and gnus-fetch-old-headers
3413 (eq gnus-headers-retrieved-by 'nov)
3414 (gnus-build-old-threads))
3415 ;; Check whether auto-expire is to be done in this group.
3416 (setq gnus-newsgroup-auto-expire
3417 (gnus-group-auto-expirable-p group))
3418 ;; Set up the article buffer now, if necessary.
3419 (unless gnus-single-article-buffer
3420 (gnus-article-setup-buffer))
3421 ;; First and last article in this newsgroup.
3422 (when gnus-newsgroup-headers
3423 (setq gnus-newsgroup-begin
3424 (mail-header-number (car gnus-newsgroup-headers))
3427 (gnus-last-element gnus-newsgroup-headers))))
3428 ;; GROUP is successfully selected.
3429 (or gnus-newsgroup-headers t)))))
3431 (defun gnus-articles-to-read (group read-all)
3432 ;; Find out what articles the user wants to read.
3434 ;; Select all articles if `read-all' is non-nil, or if there
3435 ;; are no unread articles.
3437 (and (zerop (length gnus-newsgroup-marked))
3438 (zerop (length gnus-newsgroup-unreads)))
3439 (eq (gnus-group-find-parameter group 'display)
3441 (gnus-uncompress-range (gnus-active group))
3442 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3443 (copy-sequence gnus-newsgroup-unreads))
3445 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3446 (scored (length scored-list))
3447 (number (length articles))
3448 (marked (+ (length gnus-newsgroup-marked)
3449 (length gnus-newsgroup-dormant)))
3457 ((and (or (<= scored marked) (= scored number))
3458 (numberp gnus-large-newsgroup)
3459 (> number gnus-large-newsgroup))
3463 "How many articles from %s (default %d): "
3464 gnus-newsgroup-name number))))
3465 (if (string-match "^[ \t]*$" input) number input)))
3466 ((and (> scored marked) (< scored number)
3467 (> (- scored number) 20))
3470 (format "%s %s (%d scored, %d total): "
3471 "How many articles from"
3472 group scored number))))
3473 (if (string-match "^[ \t]*$" input)
3477 (setq select (if (stringp select) (string-to-number select) select))
3478 (if (or (null select) (zerop select))
3480 (if (and (not (zerop scored)) (<= (abs select) scored))
3482 (setq articles (sort scored-list '<))
3483 (setq number (length articles)))
3484 (setq articles (copy-sequence articles)))
3486 (if (< (abs select) number)
3488 ;; Select the N oldest articles.
3489 (setcdr (nthcdr (1- (abs select)) articles) nil)
3490 ;; Select the N most recent articles.
3491 (setq articles (nthcdr (- number select) articles))))
3492 (setq gnus-newsgroup-unselected
3493 (gnus-sorted-intersection
3494 gnus-newsgroup-unreads
3495 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3498 (defun gnus-killed-articles (killed articles)
3501 (if (inline (gnus-member-of-range (car articles) killed))
3502 (setq out (cons (car articles) out)))
3503 (setq articles (cdr articles)))
3506 (defun gnus-uncompress-marks (marks)
3507 "Uncompress the mark ranges in MARKS."
3508 (let ((uncompressed '(score bookmark))
3511 (if (memq (caar marks) uncompressed)
3512 (push (car marks) out)
3513 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3514 (setq marks (cdr marks)))
3517 (defun gnus-adjust-marked-articles (info)
3518 "Set all article lists and remove all marks that are no longer legal."
3519 (let* ((marked-lists (gnus-info-marks info))
3520 (active (gnus-active (gnus-info-group info)))
3523 (types gnus-article-mark-lists)
3524 (uncompressed '(score bookmark killed))
3525 marks var articles article mark)
3528 (setq marks (pop marked-lists))
3529 (set (setq var (intern (format "gnus-newsgroup-%s"
3530 (car (rassq (setq mark (car marks))
3532 (if (memq (car marks) uncompressed) (cdr marks)
3533 (gnus-uncompress-range (cdr marks))))
3535 (setq articles (symbol-value var))
3537 ;; All articles have to be subsets of the active articles.
3539 ;; Adjust "simple" lists.
3540 ((memq mark '(tick dormant expirable reply save))
3542 (when (or (< (setq article (pop articles)) min) (> article max))
3543 (set var (delq article (symbol-value var))))))
3545 ((memq mark uncompressed)
3547 (when (or (not (consp (setq article (pop articles))))
3548 (< (car article) min)
3549 (> (car article) max))
3550 (set var (delq article (symbol-value var))))))))))
3552 (defun gnus-update-missing-marks (missing)
3553 "Go through the list of MISSING articles and remove them mark lists."
3555 (let ((types gnus-article-mark-lists)
3557 ;; Go through all types.
3559 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3560 (when (symbol-value var)
3561 ;; This list has articles. So we delete all missing articles
3565 (set var (delq (pop m) (symbol-value var)))))))))
3567 (defun gnus-update-marks ()
3568 "Enter the various lists of marked articles into the newsgroup info list."
3569 (let ((types gnus-article-mark-lists)
3570 (info (gnus-get-info gnus-newsgroup-name))
3571 (uncompressed '(score bookmark killed))
3572 type list newmarked symbol)
3574 ;; Add all marks lists that are non-nil to the list of marks lists.
3576 (setq type (pop types))
3577 (when (setq list (symbol-value
3579 (intern (format "gnus-newsgroup-%s"
3581 (push (cons (cdr type)
3582 (if (memq (cdr type) uncompressed) list
3583 (gnus-compress-sequence
3584 (set symbol (sort list '<)) t)))
3587 ;; Enter these new marks into the info of the group.
3589 (setcar (nthcdr 3 info) newmarked)
3590 ;; Add the marks lists to the end of the info.
3592 (setcdr (nthcdr 2 info) (list newmarked))))
3594 ;; Cut off the end of the info if there's nothing else there.
3598 (when (nthcdr (decf i) info)
3599 (setcdr (nthcdr i info) nil)))))))
3601 (defun gnus-set-mode-line (where)
3602 "This function sets the mode line of the article or summary buffers.
3603 If WHERE is `summary', the summary mode line format will be used."
3604 ;; Is this mode line one we keep updated?
3605 (when (memq where gnus-updated-mode-lines)
3608 ;; We evaluate this in the summary buffer since these
3609 ;; variables are buffer-local to that buffer.
3610 (set-buffer gnus-summary-buffer)
3611 ;; We bind all these variables that are used in the `eval' form
3613 (let* ((mformat (symbol-value
3615 (format "gnus-%s-mode-line-format-spec" where))))
3616 (gnus-tmp-group-name gnus-newsgroup-name)
3617 (gnus-tmp-article-number (or gnus-current-article 0))
3618 (gnus-tmp-unread gnus-newsgroup-unreads)
3619 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3620 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3621 (gnus-tmp-unread-and-unselected
3622 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3623 (zerop gnus-tmp-unselected)) "")
3624 ((zerop gnus-tmp-unselected)
3625 (format "{%d more}" gnus-tmp-unread-and-unticked))
3626 (t (format "{%d(+%d) more}"
3627 gnus-tmp-unread-and-unticked
3628 gnus-tmp-unselected))))
3630 (if (and gnus-current-headers
3631 (vectorp gnus-current-headers))
3632 (gnus-mode-string-quote
3633 (mail-header-subject gnus-current-headers)) ""))
3635 gnus-tmp-header);; passed as argument to any user-format-funcs
3636 (setq mode-string (eval mformat))
3637 (setq max-len (max 4 (if gnus-mode-non-string-length
3639 gnus-mode-non-string-length)
3640 (length mode-string))))
3641 ;; We might have to chop a bit of the string off...
3642 (when (> (length mode-string) max-len)
3644 (concat (gnus-truncate-string mode-string (- max-len 3))
3646 ;; Pad the mode string a bit.
3647 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3648 ;; Update the mode line.
3649 (setq mode-line-buffer-identification
3650 (gnus-mode-line-buffer-identification
3651 (list mode-string)))
3652 (set-buffer-modified-p t))))
3654 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3655 "Go through the HEADERS list and add all Xrefs to a hash table.
3656 The resulting hash table is returned, or nil if no Xrefs were found."
3657 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3658 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3659 (xref-hashtb (make-vector 63 0))
3660 start group entry number xrefs header)
3662 (setq header (pop headers))
3663 (when (and (setq xrefs (mail-header-xref header))
3664 (not (memq (setq number (mail-header-number header))
3667 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3668 (setq start (match-end 0))
3669 (setq group (if prefix
3670 (concat prefix (substring xrefs (match-beginning 1)
3672 (substring xrefs (match-beginning 1) (match-end 1))))
3674 (string-to-int (substring xrefs (match-beginning 2)
3676 (if (setq entry (gnus-gethash group xref-hashtb))
3677 (setcdr entry (cons number (cdr entry)))
3678 (gnus-sethash group (cons number nil) xref-hashtb)))))
3679 (and start xref-hashtb)))
3681 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3682 "Look through all the headers and mark the Xrefs as read."
3683 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3684 name entry info xref-hashtb idlist method nth4)
3686 (set-buffer gnus-group-buffer)
3687 (when (setq xref-hashtb
3688 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3691 (unless (string= from-newsgroup (setq name (symbol-name group)))
3692 (setq idlist (symbol-value group))
3693 ;; Dead groups are not updated.
3695 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3697 (if (stringp (setq nth4 (gnus-info-method info)))
3698 (setq nth4 (gnus-server-to-method nth4))))
3699 ;; Only do the xrefs if the group has the same
3700 ;; select method as the group we have just read.
3701 (or (gnus-methods-equal-p
3702 nth4 (gnus-find-method-for-group from-newsgroup))
3704 (equal nth4 (setq method (gnus-find-method-for-group
3706 (and (equal (car nth4) (car method))
3707 (equal (nth 1 nth4) (nth 1 method))))
3708 gnus-use-cross-reference
3709 (or (not (eq gnus-use-cross-reference t))
3711 ;; Only do cross-references on subscribed
3712 ;; groups, if that is what is wanted.
3713 (<= (gnus-info-level info) gnus-level-subscribed))
3714 (gnus-group-make-articles-read name idlist))))
3717 (defun gnus-group-make-articles-read (group articles)
3718 "Update the info of GROUP to say that only ARTICLES are unread."
3720 (entry (gnus-gethash group gnus-newsrc-hashtb))
3721 (info (nth 2 entry))
3722 (active (gnus-active group))
3724 ;; First peel off all illegal article numbers.
3726 (let ((ids articles)
3728 (while (setq id (pop ids))
3729 (when (and first (> id (cdr active)))
3730 ;; We'll end up in this situation in one particular
3731 ;; obscure situation. If you re-scan a group and get
3732 ;; a new article that is cross-posted to a different
3733 ;; group that has not been re-scanned, you might get
3734 ;; crossposted article that has a higher number than
3735 ;; Gnus believes possible. So we re-activate this
3736 ;; group as well. This might mean doing the
3737 ;; crossposting thingy will *increase* the number
3738 ;; of articles in some groups. Tsk, tsk.
3739 (setq active (or (gnus-activate-group group) active)))
3740 (when (or (> id (cdr active))
3741 (< id (car active)))
3742 (setq articles (delq id articles))))))
3745 (gnus-info-set-marks ,info ,(gnus-info-marks info))
3746 (gnus-info-set-read ,info ,(gnus-info-read info))
3747 (gnus-group-update-group group t)))
3748 ;; If the read list is nil, we init it.
3750 (null (gnus-info-read info))
3752 (gnus-info-set-read info (cons 1 (1- (car active)))))
3753 ;; Then we add the read articles to the range.
3758 (gnus-info-read info) (setq articles (sort articles '<)))))
3759 ;; Then we have to re-compute how many unread
3760 ;; articles there are in this group.
3764 (setq num (- (1+ (cdr active)) (car active))))
3765 ((not (listp (cdr range)))
3766 (setq num (- (cdr active) (- (1+ (cdr range))
3770 (if (numberp (car range))
3772 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
3773 (setq range (cdr range)))
3774 (setq num (- (cdr active) num))))
3775 ;; Update the number of unread articles.
3777 ;; Update the group buffer.
3778 (gnus-group-update-group group t))))
3780 (defun gnus-methods-equal-p (m1 m2)
3781 (let ((m1 (or m1 gnus-select-method))
3782 (m2 (or m2 gnus-select-method)))
3784 (and (eq (car m1) (car m2))
3785 (or (not (memq 'address (assoc (symbol-name (car m1))
3786 gnus-valid-select-methods)))
3787 (equal (nth 1 m1) (nth 1 m2)))))))
3789 (defsubst gnus-header-value ()
3790 (buffer-substring (match-end 0) (gnus-point-at-eol)))
3792 (defvar gnus-newsgroup-none-id 0)
3794 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
3795 (let ((cur nntp-server-buffer)
3798 (save-excursion (set-buffer gnus-summary-buffer)
3799 gnus-newsgroup-dependencies)))
3800 headers id id-dep ref-dep end ref)
3802 (set-buffer nntp-server-buffer)
3803 ;; Translate all TAB characters into SPACE characters.
3804 (subst-char-in-region (point-min) (point-max) ?\t ? t)
3805 (run-hooks 'gnus-parse-headers-hook)
3806 (let ((case-fold-search t)
3807 in-reply-to header p lines)
3808 (goto-char (point-min))
3809 ;; Search to the beginning of the next header. Error messages
3810 ;; do not begin with 2 or 3.
3811 (while (re-search-forward "^[23][0-9]+ " nil t)
3814 ;; This implementation of this function, with nine
3815 ;; search-forwards instead of the one re-search-forward and
3816 ;; a case (which basically was the old function) is actually
3817 ;; about twice as fast, even though it looks messier. You
3818 ;; can't have everything, I guess. Speed and elegance
3819 ;; doesn't always go hand in hand.
3828 (narrow-to-region (point)
3829 (or (and (search-forward "\n.\n" nil t)
3835 (if (search-forward "\nsubject: " nil t)
3836 (gnus-header-value) "(none)"))
3840 (if (search-forward "\nfrom: " nil t)
3841 (gnus-header-value) "(nobody)"))
3845 (if (search-forward "\ndate: " nil t)
3846 (gnus-header-value) ""))
3850 (if (search-forward "\nmessage-id: " nil t)
3851 (setq id (gnus-header-value))
3852 ;; If there was no message-id, we just fake one to make
3853 ;; subsequent routines simpler.
3854 (setq id (concat "none+"
3856 (setq gnus-newsgroup-none-id
3857 (1+ gnus-newsgroup-none-id)))))))
3861 (if (search-forward "\nreferences: " nil t)
3870 (search-backward ">" end t)
3873 (search-backward "<" end t)
3875 ;; Get the references from the in-reply-to header if there
3876 ;; were no references and the in-reply-to header looks
3878 (if (and (search-forward "\nin-reply-to: " nil t)
3879 (setq in-reply-to (gnus-header-value))
3880 (string-match "<[^>]+>" in-reply-to))
3881 (setq ref (substring in-reply-to (match-beginning 0)
3889 (if (search-forward "\nlines: " nil t)
3890 (if (numberp (setq lines (read cur)))
3896 (and (search-forward "\nxref: " nil t)
3897 (gnus-header-value)))))
3898 (when (equal id ref)
3900 ;; We do the threading while we read the headers. The
3901 ;; message-id and the last reference are both entered into
3902 ;; the same hash table. Some tippy-toeing around has to be
3903 ;; done in case an article has arrived before the article
3904 ;; which it refers to.
3905 (if (boundp (setq id-dep (intern id dependencies)))
3906 (if (and (car (symbol-value id-dep))
3908 ;; An article with this Message-ID has already
3909 ;; been seen, so we ignore this one, except we add
3910 ;; any additional Xrefs (in case the two articles
3911 ;; came from different servers).
3913 (mail-header-set-xref
3914 (car (symbol-value id-dep))
3915 (concat (or (mail-header-xref
3916 (car (symbol-value id-dep))) "")
3917 (or (mail-header-xref header) "")))
3919 (setcar (symbol-value id-dep) header))
3920 (set id-dep (list header)))
3922 (if (boundp (setq ref-dep (intern ref dependencies)))
3923 (setcdr (symbol-value ref-dep)
3924 (nconc (cdr (symbol-value ref-dep))
3925 (list (symbol-value id-dep))))
3926 (set ref-dep (list nil (symbol-value id-dep))))
3927 (setq headers (cons header headers)))
3928 (goto-char (point-max))
3930 (nreverse headers)))))
3932 ;; The following macros and functions were written by Felix Lee
3933 ;; <flee@cse.psu.edu>.
3935 (defmacro gnus-nov-read-integer ()
3937 (if (= (following-char) ?\t)
3939 (let ((num (condition-case nil (read buffer) (error nil))))
3940 (if (numberp num) num 0)))
3941 (or (eobp) (forward-char 1))))
3943 (defmacro gnus-nov-skip-field ()
3944 '(search-forward "\t" eol 'move))
3946 (defmacro gnus-nov-field ()
3947 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3949 ;; This function has to be called with point after the article number
3950 ;; on the beginning of the line.
3951 (defun gnus-nov-parse-line (number dependencies &optional force-new)
3953 (eol (gnus-point-at-eol))
3954 (buffer (current-buffer))
3955 header ref id id-dep ref-dep)
3957 ;; overview: [num subject from date id refs chars lines misc]
3958 (narrow-to-region (point) eol)
3959 (or (eobp) (forward-char))
3964 (gnus-nov-field) ; subject
3965 (gnus-nov-field) ; from
3966 (gnus-nov-field) ; date
3967 (setq id (or (gnus-nov-field)
3970 (setq none (1+ none)))))) ; id
3973 (let ((beg (point)))
3974 (search-forward "\t" eol)
3975 (if (search-backward ">" beg t)
3979 (search-backward "<" beg t)))
3981 (gnus-nov-field)) ; refs
3982 (gnus-nov-read-integer) ; chars
3983 (gnus-nov-read-integer) ; lines
3984 (if (= (following-char) ?\n)
3986 (gnus-nov-field)) ; misc
3991 ;; We build the thread tree.
3992 (when (equal id ref)
3993 ;; This article refers back to itself. Naughty, naughty.
3995 (if (boundp (setq id-dep (intern id dependencies)))
3996 (if (and (car (symbol-value id-dep))
3998 ;; An article with this Message-ID has already been seen,
3999 ;; so we ignore this one, except we add any additional
4000 ;; Xrefs (in case the two articles came from different
4003 (mail-header-set-xref
4004 (car (symbol-value id-dep))
4005 (concat (or (mail-header-xref
4006 (car (symbol-value id-dep))) "")
4007 (or (mail-header-xref header) "")))
4009 (setcar (symbol-value id-dep) header))
4010 (set id-dep (list header)))
4011 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4012 (setcdr (symbol-value ref-dep)
4013 (nconc (cdr (symbol-value ref-dep))
4014 (list (symbol-value id-dep))))
4015 (set ref-dep (list nil (symbol-value id-dep))))
4018 ;; Goes through the xover lines and returns a list of vectors
4019 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4020 force-new dependencies)
4021 "Parse the news overview data in the server buffer, and return a
4022 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4023 ;; Get the Xref when the users reads the articles since most/some
4024 ;; NNTP servers do not include Xrefs when using XOVER.
4025 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4026 (let ((cur nntp-server-buffer)
4027 (dependencies (or dependencies gnus-newsgroup-dependencies))
4028 number headers header)
4030 (set-buffer nntp-server-buffer)
4031 ;; Allow the user to mangle the headers before parsing them.
4032 (run-hooks 'gnus-parse-headers-hook)
4033 (goto-char (point-min))
4036 (while (and sequence (not (eobp)))
4037 (setq number (read cur))
4038 (while (and sequence
4039 (< (car sequence) number))
4040 (setq sequence (cdr sequence)))
4042 (eq number (car sequence))
4044 (setq sequence (cdr sequence))
4045 (push (inline (gnus-nov-parse-line
4046 number dependencies force-new))
4051 (gnus-error 4 "Strange nov line")
4052 (forward-line 1)))))
4053 (nreverse headers))))
4055 (defun gnus-article-get-xrefs ()
4056 "Fill in the Xref value in `gnus-current-headers', if necessary.
4057 This is meant to be called in `gnus-article-internal-prepare-hook'."
4058 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4059 gnus-current-headers)))
4060 (or (not gnus-use-cross-reference)
4062 (and (mail-header-xref headers)
4063 (not (string= (mail-header-xref headers) "")))
4064 (let ((case-fold-search t)
4067 (nnheader-narrow-to-headers)
4068 (goto-char (point-min))
4069 (if (or (and (eq (downcase (following-char)) ?x)
4070 (looking-at "Xref:"))
4071 (search-forward "\nXref:" nil t))
4073 (goto-char (1+ (match-end 0)))
4074 (setq xref (buffer-substring (point)
4075 (progn (end-of-line) (point))))
4076 (mail-header-set-xref headers xref))))))))
4078 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4079 "Find article ID and insert the summary line for that article."
4080 (let ((header (if (and old-header use-old-header)
4081 old-header (gnus-read-header id)))
4082 (number (and (numberp id) id))
4085 ;; Rebuild the thread that this article is part of and go to the
4086 ;; article we have fetched.
4087 (when (and (not gnus-show-threads)
4089 (when (setq pos (text-property-any
4090 (point-min) (point-max) 'gnus-number
4091 (mail-header-number old-header)))
4094 (gnus-data-remove (mail-header-number old-header))))
4096 (mail-header-set-number header (mail-header-number old-header)))
4097 (setq gnus-newsgroup-sparse
4098 (delq (setq number (mail-header-number header))
4099 gnus-newsgroup-sparse))
4100 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4101 (gnus-rebuild-thread (mail-header-id header))
4102 (gnus-summary-goto-subject number nil t))
4103 (when (and (numberp number)
4105 ;; We have to update the boundaries even if we can't fetch the
4106 ;; article if ID is a number -- so that the next `P' or `N'
4107 ;; command will fetch the previous (or next) article even
4108 ;; if the one we tried to fetch this time has been canceled.
4109 (and (> number gnus-newsgroup-end)
4110 (setq gnus-newsgroup-end number))
4111 (and (< number gnus-newsgroup-begin)
4112 (setq gnus-newsgroup-begin number))
4113 (setq gnus-newsgroup-unselected
4114 (delq number gnus-newsgroup-unselected)))
4115 ;; Report back a success?
4116 (and header (mail-header-number header))))
4118 ;;; Process/prefix in the summary buffer
4120 (defun gnus-summary-work-articles (n)
4121 "Return a list of articles to be worked upon. The prefix argument,
4122 the list of process marked articles, and the current article will be
4123 taken into consideration."
4126 ;; A numerical prefix has been given.
4127 (let ((backward (< n 0))
4128 (n (abs (prefix-numeric-value n)))
4133 (push (setq article (gnus-summary-article-number))
4136 (gnus-summary-find-prev nil article)
4137 (gnus-summary-find-next nil article)))
4139 (nreverse articles)))
4140 ((and (boundp 'transient-mark-mode)
4143 ;; Work on the region between point and mark.
4144 (let ((max (max (point) (mark)))
4147 (goto-char (min (point) (mark)))
4150 (push (setq article (gnus-summary-article-number)) articles)
4151 (gnus-summary-find-next nil article)
4153 (nreverse articles))))
4154 (gnus-newsgroup-processable
4155 ;; There are process-marked articles present.
4156 ;; Save current state.
4157 (gnus-summary-save-process-mark)
4159 (reverse gnus-newsgroup-processable))
4161 ;; Just return the current article.
4162 (list (gnus-summary-article-number)))))
4164 (defun gnus-summary-save-process-mark ()
4165 "Push the current set of process marked articles on the stack."
4167 (push (copy-sequence gnus-newsgroup-processable)
4168 gnus-newsgroup-process-stack))
4170 (defun gnus-summary-kill-process-mark ()
4171 "Push the current set of process marked articles on the stack and unmark."
4173 (gnus-summary-save-process-mark)
4174 (gnus-summary-unmark-all-processable))
4176 (defun gnus-summary-yank-process-mark ()
4177 "Pop the last process mark state off the stack and restore it."
4179 (unless gnus-newsgroup-process-stack
4180 (error "Empty mark stack"))
4181 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4183 (defun gnus-summary-process-mark-set (set)
4184 "Make SET into the current process marked articles."
4185 (gnus-summary-unmark-all-processable)
4187 (gnus-summary-set-process-mark (pop set))))
4189 ;;; Searching and stuff
4191 (defun gnus-summary-search-group (&optional backward use-level)
4192 "Search for next unread newsgroup.
4193 If optional argument BACKWARD is non-nil, search backward instead."
4195 (set-buffer gnus-group-buffer)
4196 (if (gnus-group-search-forward
4197 backward nil (if use-level (gnus-group-group-level) nil))
4198 (gnus-group-group-name))))
4200 (defun gnus-summary-best-group (&optional exclude-group)
4201 "Find the name of the best unread group.
4202 If EXCLUDE-GROUP, do not go to this group."
4204 (set-buffer gnus-group-buffer)
4206 (gnus-group-best-unread-group exclude-group))))
4208 (defun gnus-summary-find-next (&optional unread article backward)
4209 (if backward (gnus-summary-find-prev)
4210 (let* ((dummy (gnus-summary-article-intangible-p))
4211 (article (or article (gnus-summary-article-number)))
4212 (arts (gnus-data-find-list article))
4214 (when (and (not dummy)
4215 (or (not gnus-summary-check-current)
4217 (not (gnus-data-unread-p (car arts)))))
4218 (setq arts (cdr arts)))
4223 (when (gnus-data-unread-p (car arts))
4224 (setq result (car arts)
4226 (setq arts (cdr arts)))
4229 (goto-char (gnus-data-pos result))
4230 (gnus-data-number result)))))
4232 (defun gnus-summary-find-prev (&optional unread article)
4233 (let* ((eobp (eobp))
4234 (article (or article (gnus-summary-article-number)))
4235 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4237 (when (and (not eobp)
4238 (or (not gnus-summary-check-current)
4240 (not (gnus-data-unread-p (car arts)))))
4241 (setq arts (cdr arts)))
4246 (and (gnus-data-unread-p (car arts))
4247 (setq result (car arts)
4249 (setq arts (cdr arts)))
4253 (goto-char (gnus-data-pos result))
4254 (gnus-data-number result)))))
4256 (defun gnus-summary-find-subject (subject &optional unread backward article)
4257 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4258 (article (or article (gnus-summary-article-number)))
4259 (articles (gnus-data-list backward))
4260 (arts (gnus-data-find-list article articles))
4262 (when (or (not gnus-summary-check-current)
4264 (not (gnus-data-unread-p (car arts))))
4265 (setq arts (cdr arts)))
4267 (and (or (not unread)
4268 (gnus-data-unread-p (car arts)))
4269 (vectorp (gnus-data-header (car arts)))
4271 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4272 (setq result (car arts)
4274 (setq arts (cdr arts)))
4276 (goto-char (gnus-data-pos result))
4277 (gnus-data-number result))))
4279 (defun gnus-summary-search-forward (&optional unread subject backward)
4280 "Search forward for an article.
4281 If UNREAD, look for unread articles. If SUBJECT, look for
4282 articles with that subject. If BACKWARD, search backward instead."
4283 (cond (subject (gnus-summary-find-subject subject unread backward))
4284 (backward (gnus-summary-find-prev unread))
4285 (t (gnus-summary-find-next unread))))
4287 (defun gnus-recenter (&optional n)
4288 "Center point in window and redisplay frame.
4289 Also do horizontal recentering."
4291 (when (and gnus-auto-center-summary
4292 (not (eq gnus-auto-center-summary 'vertical)))
4293 (gnus-horizontal-recenter))
4296 (defun gnus-summary-recenter ()
4297 "Center point in the summary window.
4298 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4299 displayed, no centering will be performed."
4300 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4301 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4302 (let* ((top (cond ((< (window-height) 4) 0)
4303 ((< (window-height) 7) 1)
4305 (height (1- (window-height)))
4306 (bottom (save-excursion (goto-char (point-max))
4307 (forward-line (- height))
4309 (window (get-buffer-window (current-buffer))))
4310 ;; The user has to want it.
4311 (when gnus-auto-center-summary
4312 (when (get-buffer-window gnus-article-buffer)
4313 ;; Only do recentering when the article buffer is displayed,
4314 ;; Set the window start to either `bottom', which is the biggest
4315 ;; possible valid number, or the second line from the top,
4316 ;; whichever is the least.
4318 window (min bottom (save-excursion
4319 (forward-line (- top)) (point)))))
4320 ;; Do horizontal recentering while we're at it.
4321 (when (and (get-buffer-window (current-buffer) t)
4322 (not (eq gnus-auto-center-summary 'vertical)))
4323 (let ((selected (selected-window)))
4324 (select-window (get-buffer-window (current-buffer) t))
4325 (gnus-summary-position-point)
4326 (gnus-horizontal-recenter)
4327 (select-window selected))))))
4329 (defun gnus-summary-jump-to-group (newsgroup)
4330 "Move point to NEWSGROUP in group mode buffer."
4331 ;; Keep update point of group mode buffer if visible.
4332 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4333 (save-window-excursion
4334 ;; Take care of tree window mode.
4335 (if (get-buffer-window gnus-group-buffer)
4336 (pop-to-buffer gnus-group-buffer))
4337 (gnus-group-jump-to-group newsgroup))
4339 ;; Take care of tree window mode.
4340 (if (get-buffer-window gnus-group-buffer)
4341 (pop-to-buffer gnus-group-buffer)
4342 (set-buffer gnus-group-buffer))
4343 (gnus-group-jump-to-group newsgroup))))
4345 ;; This function returns a list of article numbers based on the
4346 ;; difference between the ranges of read articles in this group and
4347 ;; the range of active articles.
4348 (defun gnus-list-of-unread-articles (group)
4349 (let* ((read (gnus-info-read (gnus-get-info group)))
4350 (active (or (gnus-active group) (gnus-activate-group group)))
4353 ;; If none are read, then all are unread.
4355 (setq first (car active))
4356 ;; If the range of read articles is a single range, then the
4357 ;; first unread article is the article after the last read
4358 ;; article. Sounds logical, doesn't it?
4359 (if (not (listp (cdr read)))
4360 (setq first (1+ (cdr read)))
4361 ;; `read' is a list of ranges.
4362 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
4367 (while (< first nlast)
4368 (setq unread (cons first unread))
4369 (setq first (1+ first))))
4370 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4371 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4372 (setq read (cdr read)))))
4373 ;; And add the last unread articles.
4374 (while (<= first last)
4375 (setq unread (cons first unread))
4376 (setq first (1+ first)))
4377 ;; Return the list of unread articles.
4380 (defun gnus-list-of-read-articles (group)
4381 "Return a list of unread, unticked and non-dormant articles."
4382 (let* ((info (gnus-get-info group))
4383 (marked (gnus-info-marks info))
4384 (active (gnus-active group)))
4386 (gnus-set-difference
4387 (gnus-sorted-complement
4388 (gnus-uncompress-range active)
4389 (gnus-list-of-unread-articles group))
4391 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4392 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4394 ;; Various summary commands
4396 (defun gnus-summary-universal-argument (arg)
4397 "Perform any operation on all articles that are process/prefixed."
4399 (gnus-set-global-variables)
4400 (let ((articles (gnus-summary-work-articles arg))
4407 (substitute-command-keys
4408 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4411 (gnus-error 1 "Undefined key")
4414 (gnus-summary-goto-subject (setq article (pop articles)))
4415 (command-execute func)
4416 (gnus-summary-remove-process-mark article)))))
4417 (gnus-summary-position-point))
4419 (defun gnus-summary-toggle-truncation (&optional arg)
4420 "Toggle truncation of summary lines.
4421 With arg, turn line truncation on iff arg is positive."
4423 (setq truncate-lines
4424 (if (null arg) (not truncate-lines)
4425 (> (prefix-numeric-value arg) 0)))
4428 (defun gnus-summary-reselect-current-group (&optional all rescan)
4429 "Exit and then reselect the current newsgroup.
4430 The prefix argument ALL means to select all articles."
4432 (gnus-set-global-variables)
4433 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4434 (error "Ephemeral groups can't be reselected"))
4435 (let ((current-subject (gnus-summary-article-number))
4436 (group gnus-newsgroup-name))
4437 (setq gnus-newsgroup-begin nil)
4439 ;; We have to adjust the point of group mode buffer because the
4440 ;; current point was moved to the next unread newsgroup by
4442 (gnus-summary-jump-to-group group)
4445 (gnus-group-get-new-news-this-group 1)))
4446 (gnus-group-read-group all t)
4447 (gnus-summary-goto-subject current-subject nil t)))
4449 (defun gnus-summary-rescan-group (&optional all)
4450 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4452 (gnus-summary-reselect-current-group all t))
4454 (defun gnus-summary-update-info ()
4455 (let ((group gnus-newsgroup-name))
4456 (when gnus-newsgroup-kill-headers
4457 (setq gnus-newsgroup-killed
4458 (gnus-compress-sequence
4460 (gnus-set-sorted-intersection
4461 (gnus-uncompress-range gnus-newsgroup-killed)
4462 (setq gnus-newsgroup-unselected
4463 (sort gnus-newsgroup-unselected '<)))
4464 (setq gnus-newsgroup-unreads
4465 (sort gnus-newsgroup-unreads '<))) t)))
4466 (unless (listp (cdr gnus-newsgroup-killed))
4467 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4468 (let ((headers gnus-newsgroup-headers))
4469 (run-hooks 'gnus-exit-group-hook)
4470 (unless gnus-save-score
4471 (setq gnus-newsgroup-scored nil))
4472 ;; Set the new ranges of read articles.
4473 (gnus-update-read-articles
4474 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4475 ;; Set the current article marks.
4477 ;; Do the cross-ref thing.
4478 (when gnus-use-cross-reference
4479 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4480 ;; Do adaptive scoring, and possibly save score files.
4481 (when gnus-newsgroup-adaptive
4482 (gnus-score-adaptive))
4483 (when gnus-use-scoring
4485 ;; Do not switch windows but change the buffer to work.
4486 (set-buffer gnus-group-buffer)
4487 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4488 (gnus-group-update-group group)))))
4490 (defun gnus-summary-exit (&optional temporary)
4491 "Exit reading current newsgroup, and then return to group selection mode.
4492 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4494 (gnus-set-global-variables)
4495 (gnus-kill-save-kill-buffer)
4496 (let* ((group gnus-newsgroup-name)
4497 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4499 (buf (current-buffer)))
4500 (run-hooks 'gnus-summary-prepare-exit-hook)
4501 ;; If we have several article buffers, we kill them at exit.
4502 (unless gnus-single-article-buffer
4503 (gnus-kill-buffer gnus-original-article-buffer)
4504 (setq gnus-article-current nil))
4505 (when gnus-use-cache
4506 (gnus-cache-possibly-remove-articles)
4507 (gnus-cache-save-buffers))
4508 (gnus-async-prefetch-remove-group group)
4509 (when gnus-suppress-duplicates
4510 (gnus-dup-enter-articles))
4511 (when gnus-use-trees
4512 (gnus-tree-close group))
4513 ;; Make all changes in this group permanent.
4515 (gnus-summary-update-info))
4516 (gnus-close-group group)
4517 ;; Make sure where I was, and go to next newsgroup.
4518 (set-buffer gnus-group-buffer)
4520 (gnus-group-jump-to-group group))
4521 (run-hooks 'gnus-summary-exit-hook)
4523 (gnus-group-next-unread-group 1))
4526 ;; If we have several article buffers, we kill them at exit.
4527 (unless gnus-single-article-buffer
4528 (gnus-kill-buffer gnus-article-buffer)
4529 (gnus-kill-buffer gnus-original-article-buffer)
4530 (setq gnus-article-current nil))
4532 (if (not gnus-kill-summary-on-exit)
4533 (gnus-deaden-summary)
4534 ;; We set all buffer-local variables to nil. It is unclear why
4535 ;; this is needed, but if we don't, buffer-local variables are
4536 ;; not garbage-collected, it seems. This would the lead to en
4537 ;; ever-growing Emacs.
4538 (gnus-summary-clear-local-variables)
4539 (when (get-buffer gnus-article-buffer)
4540 (bury-buffer gnus-article-buffer))
4541 ;; We clear the global counterparts of the buffer-local
4542 ;; variables as well, just to be on the safe side.
4543 (set-buffer gnus-group-buffer)
4544 (gnus-summary-clear-local-variables)
4545 ;; Return to group mode buffer.
4546 (if (eq mode 'gnus-summary-mode)
4547 (gnus-kill-buffer buf)))
4548 (setq gnus-current-select-method gnus-select-method)
4549 (pop-to-buffer gnus-group-buffer)
4550 ;; Clear the current group name.
4551 (if (not quit-config)
4553 (gnus-group-jump-to-group group)
4554 (gnus-group-next-unread-group 1)
4555 (gnus-configure-windows 'group 'force))
4556 (if (not (buffer-name (car quit-config)))
4557 (gnus-configure-windows 'group 'force)
4558 (set-buffer (car quit-config))
4559 (cond ((eq major-mode 'gnus-summary-mode)
4560 (gnus-set-global-variables))
4561 ((eq major-mode 'gnus-article-mode)
4563 ;; The `gnus-summary-buffer' variable may point
4564 ;; to the old summary buffer when using a single
4566 (unless (gnus-buffer-live-p gnus-summary-buffer)
4567 (set-buffer gnus-group-buffer))
4568 (set-buffer gnus-summary-buffer)
4569 (gnus-set-global-variables))))
4570 (gnus-configure-windows (cdr quit-config) 'force)))
4572 (setq gnus-newsgroup-name nil)))))
4574 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4575 (defun gnus-summary-exit-no-update (&optional no-questions)
4576 "Quit reading current newsgroup without updating read article info."
4578 (gnus-set-global-variables)
4579 (let* ((group gnus-newsgroup-name)
4580 (quit-config (gnus-group-quit-config group)))
4581 (when (or no-questions
4583 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4584 ;; If we have several article buffers, we kill them at exit.
4585 (unless gnus-single-article-buffer
4586 (gnus-kill-buffer gnus-article-buffer)
4587 (gnus-kill-buffer gnus-original-article-buffer)
4588 (setq gnus-article-current nil))
4589 (if (not gnus-kill-summary-on-exit)
4590 (gnus-deaden-summary)
4591 (gnus-close-group group)
4592 (gnus-summary-clear-local-variables)
4593 (set-buffer gnus-group-buffer)
4594 (gnus-summary-clear-local-variables)
4595 (when (get-buffer gnus-summary-buffer)
4596 (kill-buffer gnus-summary-buffer)))
4597 (unless gnus-single-article-buffer
4598 (setq gnus-article-current nil))
4599 (when gnus-use-trees
4600 (gnus-tree-close group))
4601 (gnus-async-prefetch-remove-group group)
4602 (when (get-buffer gnus-article-buffer)
4603 (bury-buffer gnus-article-buffer))
4604 ;; Return to the group buffer.
4605 (gnus-configure-windows 'group 'force)
4606 ;; Clear the current group name.
4607 (setq gnus-newsgroup-name nil)
4608 (when (equal (gnus-group-group-name) group)
4609 (gnus-group-next-unread-group 1))
4611 (if (not (buffer-name (car quit-config)))
4612 (gnus-configure-windows 'group 'force)
4613 (set-buffer (car quit-config))
4614 (when (eq major-mode 'gnus-summary-mode)
4615 (gnus-set-global-variables))
4616 (gnus-configure-windows (cdr quit-config)))))))
4620 (defvar gnus-dead-summary-mode-map nil)
4622 (unless gnus-dead-summary-mode-map
4623 (setq gnus-dead-summary-mode-map (make-keymap))
4624 (suppress-keymap gnus-dead-summary-mode-map)
4625 (substitute-key-definition
4626 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4627 (let ((keys '("\C-d" "\r" "\177")))
4629 (define-key gnus-dead-summary-mode-map
4630 (pop keys) 'gnus-summary-wake-up-the-dead))))
4632 (defvar gnus-dead-summary-mode nil
4633 "Minor mode for Gnus summary buffers.")
4635 (defun gnus-dead-summary-mode (&optional arg)
4636 "Minor mode for Gnus summary buffers."
4638 (when (eq major-mode 'gnus-summary-mode)
4639 (make-local-variable 'gnus-dead-summary-mode)
4640 (setq gnus-dead-summary-mode
4641 (if (null arg) (not gnus-dead-summary-mode)
4642 (> (prefix-numeric-value arg) 0)))
4643 (when gnus-dead-summary-mode
4644 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4645 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4646 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4647 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4648 minor-mode-map-alist)))))
4650 (defun gnus-deaden-summary ()
4651 "Make the current summary buffer into a dead summary buffer."
4652 ;; Kill any previous dead summary buffer.
4653 (when (and gnus-dead-summary
4654 (buffer-name gnus-dead-summary))
4656 (set-buffer gnus-dead-summary)
4657 (when gnus-dead-summary-mode
4658 (kill-buffer (current-buffer)))))
4659 ;; Make this the current dead summary.
4660 (setq gnus-dead-summary (current-buffer))
4661 (gnus-dead-summary-mode 1)
4662 (let ((name (buffer-name)))
4663 (when (string-match "Summary" name)
4665 (concat (substring name 0 (match-beginning 0)) "Dead "
4666 (substring name (match-beginning 0))) t))))
4668 (defun gnus-kill-or-deaden-summary (buffer)
4669 "Kill or deaden the summary BUFFER."
4670 (when (and (buffer-name buffer)
4671 (not gnus-single-article-buffer))
4674 (gnus-kill-buffer gnus-article-buffer)
4675 (gnus-kill-buffer gnus-original-article-buffer)))
4676 (cond (gnus-kill-summary-on-exit
4677 (when (and gnus-use-trees
4678 (and (get-buffer buffer)
4679 (buffer-name (get-buffer buffer))))
4681 (set-buffer (get-buffer buffer))
4682 (gnus-tree-close gnus-newsgroup-name)))
4683 (gnus-kill-buffer buffer))
4684 ((and (get-buffer buffer)
4685 (buffer-name (get-buffer buffer)))
4688 (gnus-deaden-summary)))))
4690 (defun gnus-summary-wake-up-the-dead (&rest args)
4691 "Wake up the dead summary buffer."
4693 (gnus-dead-summary-mode -1)
4694 (let ((name (buffer-name)))
4695 (when (string-match "Dead " name)
4697 (concat (substring name 0 (match-beginning 0))
4698 (substring name (match-end 0))) t)))
4699 (gnus-message 3 "This dead summary is now alive again"))
4701 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
4702 (defun gnus-summary-fetch-faq (&optional faq-dir)
4703 "Fetch the FAQ for the current group.
4704 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
4708 (if current-prefix-arg
4710 "Faq dir: " (and (listp gnus-group-faq-directory)
4711 gnus-group-faq-directory)))))
4712 (let (gnus-faq-buffer)
4713 (and (setq gnus-faq-buffer
4714 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
4715 (gnus-configure-windows 'summary-faq))))
4717 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4718 (defun gnus-summary-describe-group (&optional force)
4719 "Describe the current newsgroup."
4721 (gnus-group-describe-group force gnus-newsgroup-name))
4723 (defun gnus-summary-describe-briefly ()
4724 "Describe summary mode commands briefly."
4727 (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")))
4729 ;; Walking around group mode buffer from summary mode.
4731 (defun gnus-summary-next-group (&optional no-article target-group backward)
4732 "Exit current newsgroup and then select next unread newsgroup.
4733 If prefix argument NO-ARTICLE is non-nil, no article is selected
4734 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
4735 previous group instead."
4737 (gnus-set-global-variables)
4738 (let ((current-group gnus-newsgroup-name)
4739 (current-buffer (current-buffer))
4741 ;; First we semi-exit this group to update Xrefs and all variables.
4742 ;; We can't do a real exit, because the window conf must remain
4743 ;; the same in case the user is prompted for info, and we don't
4744 ;; want the window conf to change before that...
4745 (gnus-summary-exit t)
4746 (while (not entered)
4747 ;; Then we find what group we are supposed to enter.
4748 (set-buffer gnus-group-buffer)
4749 (gnus-group-jump-to-group current-group)
4752 (if (eq gnus-keep-same-level 'best)
4753 (gnus-summary-best-group gnus-newsgroup-name)
4754 (gnus-summary-search-group backward gnus-keep-same-level))))
4755 (if (not target-group)
4756 ;; There are no further groups, so we return to the group
4759 (gnus-message 5 "Returning to the group buffer")
4761 (set-buffer current-buffer)
4763 (run-hooks 'gnus-group-no-more-groups-hook))
4764 ;; We try to enter the target group.
4765 (gnus-group-jump-to-group target-group)
4766 (let ((unreads (gnus-group-group-unread)))
4767 (if (and (or (eq t unreads)
4768 (and unreads (not (zerop unreads))))
4769 (gnus-summary-read-group
4770 target-group nil no-article current-buffer))
4772 (setq current-group target-group
4773 target-group nil)))))))
4775 (defun gnus-summary-prev-group (&optional no-article)
4776 "Exit current newsgroup and then select previous unread newsgroup.
4777 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
4779 (gnus-summary-next-group no-article nil t))
4781 ;; Walking around summary lines.
4783 (defun gnus-summary-first-subject (&optional unread)
4784 "Go to the first unread subject.
4785 If UNREAD is non-nil, go to the first unread article.
4786 Returns the article selected or nil if there are no unread articles."
4791 ((null gnus-newsgroup-data)
4792 (gnus-message 3 "No articles in the group")
4794 ;; Pick the first article.
4796 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
4797 (gnus-data-number (car gnus-newsgroup-data)))
4798 ;; No unread articles.
4799 ((null gnus-newsgroup-unreads)
4800 (gnus-message 3 "No more unread articles")
4802 ;; Find the first unread article.
4804 (let ((data gnus-newsgroup-data))
4806 (not (gnus-data-unread-p (car data))))
4807 (setq data (cdr data)))
4810 (goto-char (gnus-data-pos (car data)))
4811 (gnus-data-number (car data)))))))
4812 (gnus-summary-position-point)))
4814 (defun gnus-summary-next-subject (n &optional unread dont-display)
4815 "Go to next N'th summary line.
4816 If N is negative, go to the previous N'th subject line.
4817 If UNREAD is non-nil, only unread articles are selected.
4818 The difference between N and the actual number of steps taken is
4821 (let ((backward (< n 0))
4825 (gnus-summary-find-prev unread)
4826 (gnus-summary-find-next unread)))
4828 (if (/= 0 n) (gnus-message 7 "No more%s articles"
4829 (if unread " unread" "")))
4830 (unless dont-display
4831 (gnus-summary-recenter)
4832 (gnus-summary-position-point))
4835 (defun gnus-summary-next-unread-subject (n)
4836 "Go to next N'th unread summary line."
4838 (gnus-summary-next-subject n t))
4840 (defun gnus-summary-prev-subject (n &optional unread)
4841 "Go to previous N'th summary line.
4842 If optional argument UNREAD is non-nil, only unread article is selected."
4844 (gnus-summary-next-subject (- n) unread))
4846 (defun gnus-summary-prev-unread-subject (n)
4847 "Go to previous N'th unread summary line."
4849 (gnus-summary-next-subject (- n) t))
4851 (defun gnus-summary-goto-subject (article &optional force silent)
4852 "Go the subject line of ARTICLE.
4853 If FORCE, also allow jumping to articles not currently shown."
4854 (interactive "nArticle number: ")
4856 (data (gnus-data-find article)))
4857 ;; We read in the article if we have to.
4860 (gnus-summary-insert-subject article (and (vectorp force) force) t)
4861 (setq data (gnus-data-find article)))
4866 (gnus-message 3 "Can't find article %d" article))
4868 (goto-char (gnus-data-pos data))
4871 ;; Walking around summary lines with displaying articles.
4873 (defun gnus-summary-expand-window (&optional arg)
4874 "Make the summary buffer take up the entire Emacs frame.
4875 Given a prefix, will force an `article' buffer configuration."
4877 (gnus-set-global-variables)
4879 (gnus-configure-windows 'article 'force)
4880 (gnus-configure-windows 'summary 'force)))
4882 (defun gnus-summary-display-article (article &optional all-header)
4883 "Display ARTICLE in article buffer."
4884 (gnus-set-global-variables)
4888 (if gnus-summary-display-article-function
4889 (funcall gnus-summary-display-article-function article all-header)
4890 (gnus-article-prepare article all-header))
4891 (run-hooks 'gnus-select-article-hook)
4892 (when (and gnus-current-article
4893 (not (zerop gnus-current-article)))
4894 (gnus-summary-goto-subject gnus-current-article))
4895 (gnus-summary-recenter)
4896 (when gnus-use-trees
4897 (gnus-possibly-generate-tree article)
4898 (gnus-highlight-selected-tree article))
4899 ;; Successfully display article.
4900 (gnus-article-set-window-start
4901 (cdr (assq article gnus-newsgroup-bookmarks))))))
4903 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
4904 "Select the current article.
4905 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
4906 non-nil, the article will be re-fetched even if it already present in
4907 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
4909 ;; Make sure we are in the summary buffer to work around bbdb bug.
4910 (unless (eq major-mode 'gnus-summary-mode)
4911 (set-buffer gnus-summary-buffer))
4912 (let ((article (or article (gnus-summary-article-number)))
4913 (all-headers (not (not all-headers))) ;Must be T or NIL.
4914 gnus-summary-display-article-function
4917 (gnus-summary-article-pseudo-p article)
4918 (error "This is a pseudo-article."))
4921 (set-buffer gnus-summary-buffer)
4922 (if (or (and gnus-single-article-buffer
4923 (or (null gnus-current-article)
4924 (null gnus-article-current)
4925 (null (get-buffer gnus-article-buffer))
4926 (not (eq article (cdr gnus-article-current)))
4927 (not (equal (car gnus-article-current)
4928 gnus-newsgroup-name))))
4929 (and (not gnus-single-article-buffer)
4930 (or (null gnus-current-article)
4931 (not (eq gnus-current-article article))))
4933 ;; The requested article is different from the current article.
4935 (gnus-summary-display-article article all-headers)
4937 (if (or all-headers gnus-show-all-headers)
4938 (gnus-article-show-all-headers))
4941 (gnus-article-set-window-start
4942 (cdr (assq article gnus-newsgroup-bookmarks)))))))
4944 (defun gnus-summary-set-current-mark (&optional current-mark)
4945 "Obsolete function."
4948 (defun gnus-summary-next-article (&optional unread subject backward push)
4949 "Select the next article.
4950 If UNREAD, only unread articles are selected.
4951 If SUBJECT, only articles with SUBJECT are selected.
4952 If BACKWARD, the previous article is selected instead of the next."
4954 (gnus-set-global-variables)
4956 ;; Is there such an article?
4957 ((and (gnus-summary-search-forward unread subject backward)
4958 (or (gnus-summary-display-article (gnus-summary-article-number))
4959 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
4960 (gnus-summary-position-point))
4961 ;; If not, we try the first unread, if that is wanted.
4963 gnus-auto-select-same
4964 ;; Make sure that we don't select the current article.
4965 (not (eq (gnus-summary-article-number)
4967 (gnus-summary-first-subject t)
4968 (gnus-summary-article-number))))
4969 (gnus-summary-first-unread-article))
4970 (gnus-summary-position-point)
4971 (gnus-message 6 "Wrapped"))
4972 ;; Try to get next/previous article not displayed in this group.
4973 ((and gnus-auto-extend-newsgroup
4974 (not unread) (not subject))
4975 (gnus-summary-goto-article
4976 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
4978 ;; Go to next/previous group.
4980 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4981 (gnus-summary-jump-to-group gnus-newsgroup-name))
4982 (let ((cmd last-command-char)
4984 (if (eq gnus-keep-same-level 'best)
4985 (gnus-summary-best-group gnus-newsgroup-name)
4986 (gnus-summary-search-group backward gnus-keep-same-level))))
4987 ;; For some reason, the group window gets selected. We change
4989 (select-window (get-buffer-window (current-buffer)))
4990 ;; Select next unread newsgroup automagically.
4992 ((or (not gnus-auto-select-next)
4994 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
4995 ((or (eq gnus-auto-select-next 'quietly)
4996 (and (eq gnus-auto-select-next 'slightly-quietly)
4998 (and (eq gnus-auto-select-next 'almost-quietly)
4999 (gnus-summary-last-article-p)))
5001 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5003 (gnus-message 7 "No more%s articles (%s)..."
5004 (if unread " unread" "")
5005 (if group (concat "selecting " group)
5007 (gnus-summary-next-group nil group backward)))
5009 (gnus-summary-walk-group-buffer
5010 gnus-newsgroup-name cmd unread backward)))))))
5012 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
5013 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5014 (?\C-p (gnus-group-prev-unread-group 1))))
5015 (cursor-in-echo-area t)
5016 keve key group ended)
5018 (set-buffer gnus-group-buffer)
5019 (gnus-summary-jump-to-group from-group)
5021 (if (eq gnus-keep-same-level 'best)
5022 (gnus-summary-best-group gnus-newsgroup-name)
5023 (gnus-summary-search-group backward gnus-keep-same-level))))
5026 5 "No more%s articles%s" (if unread " unread" "")
5028 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5029 (format " (Type %s for %s [%s])"
5030 (single-key-description cmd) group
5031 (car (gnus-gethash group gnus-newsrc-hashtb)))
5032 (format " (Type %s to exit %s)"
5033 (single-key-description cmd)
5034 gnus-newsgroup-name)))
5035 ;; Confirm auto selection.
5036 (setq key (car (setq keve (gnus-read-event-char))))
5039 ((assq key keystrokes)
5040 (let ((obuf (current-buffer)))
5041 (switch-to-buffer gnus-group-buffer)
5043 (gnus-group-jump-to-group group))
5044 (eval (cadr (assq key keystrokes)))
5045 (setq group (gnus-group-group-name))
5046 (switch-to-buffer obuf))
5050 (gnus-ephemeral-group-p gnus-newsgroup-name))
5052 (gnus-summary-next-group nil group backward)))
5054 (push (cdr keve) unread-command-events))))))
5056 (defun gnus-summary-next-unread-article ()
5057 "Select unread article after current one."
5059 (gnus-summary-next-article t (and gnus-auto-select-same
5060 (gnus-summary-article-subject))))
5062 (defun gnus-summary-prev-article (&optional unread subject)
5063 "Select the article after the current one.
5064 If UNREAD is non-nil, only unread articles are selected."
5066 (gnus-summary-next-article unread subject t))
5068 (defun gnus-summary-prev-unread-article ()
5069 "Select unread article before current one."
5071 (gnus-summary-prev-article t (and gnus-auto-select-same
5072 (gnus-summary-article-subject))))
5074 (defun gnus-summary-next-page (&optional lines circular)
5075 "Show next page of the selected article.
5076 If at the end of the current article, select the next article.
5077 LINES says how many lines should be scrolled up.
5079 If CIRCULAR is non-nil, go to the start of the article instead of
5080 selecting the next article when reaching the end of the current
5083 (setq gnus-summary-buffer (current-buffer))
5084 (gnus-set-global-variables)
5085 (let ((article (gnus-summary-article-number))
5087 (gnus-configure-windows 'article)
5088 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5089 (if (and (eq gnus-summary-goto-unread 'never)
5090 (not (gnus-summary-last-article-p article)))
5091 (gnus-summary-next-article)
5092 (gnus-summary-next-unread-article))
5093 (if (or (null gnus-current-article)
5094 (null gnus-article-current)
5095 (/= article (cdr gnus-article-current))
5096 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5097 ;; Selected subject is different from current article's.
5098 (gnus-summary-display-article article)
5099 (gnus-eval-in-buffer-window gnus-article-buffer
5100 (setq endp (gnus-article-next-page lines)))
5103 (gnus-summary-beginning-of-article))
5105 (gnus-message 3 "End of message"))
5107 (if (and (eq gnus-summary-goto-unread 'never)
5108 (not (gnus-summary-last-article-p article)))
5109 (gnus-summary-next-article)
5110 (gnus-summary-next-unread-article)))))))
5111 (gnus-summary-recenter)
5112 (gnus-summary-position-point)))
5114 (defun gnus-summary-prev-page (&optional lines)
5115 "Show previous page of selected article.
5116 Argument LINES specifies lines to be scrolled down."
5118 (gnus-set-global-variables)
5119 (let ((article (gnus-summary-article-number)))
5120 (gnus-configure-windows 'article)
5121 (if (or (null gnus-current-article)
5122 (null gnus-article-current)
5123 (/= article (cdr gnus-article-current))
5124 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5125 ;; Selected subject is different from current article's.
5126 (gnus-summary-display-article article)
5127 (gnus-summary-recenter)
5128 (gnus-eval-in-buffer-window gnus-article-buffer
5129 (gnus-article-prev-page lines))))
5130 (gnus-summary-position-point))
5132 (defun gnus-summary-scroll-up (lines)
5133 "Scroll up (or down) one line current article.
5134 Argument LINES specifies lines to be scrolled up (or down if negative)."
5136 (gnus-set-global-variables)
5137 (gnus-configure-windows 'article)
5138 (gnus-summary-show-thread)
5139 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5140 (gnus-eval-in-buffer-window gnus-article-buffer
5142 (if (gnus-article-next-page lines)
5143 (gnus-message 3 "End of message")))
5145 (gnus-article-prev-page (- lines))))))
5146 (gnus-summary-recenter)
5147 (gnus-summary-position-point))
5149 (defun gnus-summary-next-same-subject ()
5150 "Select next article which has the same subject as current one."
5152 (gnus-set-global-variables)
5153 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5155 (defun gnus-summary-prev-same-subject ()
5156 "Select previous article which has the same subject as current one."
5158 (gnus-set-global-variables)
5159 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5161 (defun gnus-summary-next-unread-same-subject ()
5162 "Select next unread article which has the same subject as current one."
5164 (gnus-set-global-variables)
5165 (gnus-summary-next-article t (gnus-summary-article-subject)))
5167 (defun gnus-summary-prev-unread-same-subject ()
5168 "Select previous unread article which has the same subject as current one."
5170 (gnus-set-global-variables)
5171 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5173 (defun gnus-summary-first-unread-article ()
5174 "Select the first unread article.
5175 Return nil if there are no unread articles."
5177 (gnus-set-global-variables)
5179 (when (gnus-summary-first-subject t)
5180 (gnus-summary-show-thread)
5181 (gnus-summary-first-subject t)
5182 (gnus-summary-display-article (gnus-summary-article-number)))
5183 (gnus-summary-position-point)))
5185 (defun gnus-summary-best-unread-article ()
5186 "Select the unread article with the highest score."
5188 (gnus-set-global-variables)
5189 (let ((best -1000000)
5190 (data gnus-newsgroup-data)
5193 (and (gnus-data-unread-p (car data))
5195 (gnus-summary-article-score (gnus-data-number (car data))))
5198 article (gnus-data-number (car data))))
5199 (setq data (cdr data)))
5202 (gnus-summary-goto-article article)
5203 (error "No unread articles"))
5204 (gnus-summary-position-point))))
5206 (defun gnus-summary-last-subject ()
5207 "Go to the last displayed subject line in the group."
5208 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5210 (gnus-summary-goto-subject article))))
5212 (defun gnus-summary-goto-article (article &optional all-headers force)
5213 "Fetch ARTICLE and display it if it exists.
5214 If ALL-HEADERS is non-nil, no header lines are hidden."
5220 (mapcar (lambda (number) (list (int-to-string number)))
5221 gnus-newsgroup-limit)))
5225 (if (gnus-summary-goto-subject article force)
5226 (gnus-summary-display-article article all-headers)
5227 (gnus-message 4 "Couldn't go to article %s" article) nil)
5228 (gnus-summary-position-point)))
5230 (defun gnus-summary-goto-last-article ()
5231 "Go to the previously read article."
5234 (and gnus-last-article
5235 (gnus-summary-goto-article gnus-last-article))
5236 (gnus-summary-position-point)))
5238 (defun gnus-summary-pop-article (number)
5239 "Pop one article off the history and go to the previous.
5240 NUMBER articles will be popped off."
5243 (setq gnus-newsgroup-history
5244 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5246 (gnus-summary-goto-article (car to))
5247 (error "Article history empty")))
5248 (gnus-summary-position-point))
5250 ;; Summary commands and functions for limiting the summary buffer.
5252 (defun gnus-summary-limit-to-articles (n)
5253 "Limit the summary buffer to the next N articles.
5254 If not given a prefix, use the process marked articles instead."
5256 (gnus-set-global-variables)
5258 (let ((articles (gnus-summary-work-articles n)))
5259 (setq gnus-newsgroup-processable nil)
5260 (gnus-summary-limit articles))
5261 (gnus-summary-position-point)))
5263 (defun gnus-summary-pop-limit (&optional total)
5264 "Restore the previous limit.
5265 If given a prefix, remove all limits."
5267 (gnus-set-global-variables)
5269 (setq gnus-newsgroup-limits
5270 (list (mapcar (lambda (h) (mail-header-number h))
5271 gnus-newsgroup-headers))))
5272 (unless gnus-newsgroup-limits
5273 (error "No limit to pop"))
5275 (gnus-summary-limit nil 'pop)
5276 (gnus-summary-position-point)))
5278 (defun gnus-summary-limit-to-subject (subject &optional header)
5279 "Limit the summary buffer to articles that have subjects that match a regexp."
5280 (interactive "sRegexp: ")
5282 (setq header "subject"))
5283 (when (not (equal "" subject))
5285 (let ((articles (gnus-summary-find-matching
5286 (or header "subject") subject 'all)))
5287 (or articles (error "Found no matches for \"%s\"" subject))
5288 (gnus-summary-limit articles))
5289 (gnus-summary-position-point))))
5291 (defun gnus-summary-limit-to-author (from)
5292 "Limit the summary buffer to articles that have authors that match a regexp."
5293 (interactive "sRegexp: ")
5294 (gnus-summary-limit-to-subject from "from"))
5296 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5298 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5300 (defun gnus-summary-limit-to-unread (&optional all)
5301 "Limit the summary buffer to articles that are not marked as read.
5302 If ALL is non-nil, limit strictly to unread articles."
5305 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5306 (gnus-summary-limit-to-marks
5307 ;; Concat all the marks that say that an article is read and have
5309 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5310 gnus-killed-mark gnus-kill-file-mark
5311 gnus-low-score-mark gnus-expirable-mark
5312 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5313 gnus-duplicate-mark)
5316 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5317 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5319 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5320 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5321 If REVERSE, limit the summary buffer to articles that are not marked
5322 with MARKS. MARKS can either be a string of marks or a list of marks.
5323 Returns how many articles were removed."
5324 (interactive "sMarks: ")
5325 (gnus-set-global-variables)
5327 (let ((data gnus-newsgroup-data)
5328 (marks (if (listp marks) marks
5329 (append marks nil))) ; Transform to list.
5332 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
5333 (memq (gnus-data-mark (car data)) marks))
5334 (setq articles (cons (gnus-data-number (car data)) articles)))
5335 (setq data (cdr data)))
5336 (gnus-summary-limit articles))
5337 (gnus-summary-position-point)))
5339 (defun gnus-summary-limit-to-score (&optional score)
5340 "Limit to articles with score at or above SCORE."
5342 (gnus-set-global-variables)
5343 (setq score (if score
5344 (prefix-numeric-value score)
5345 (or gnus-summary-default-score 0)))
5346 (let ((data gnus-newsgroup-data)
5349 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5351 (push (gnus-data-number (car data)) articles))
5352 (setq data (cdr data)))
5354 (gnus-summary-limit articles)
5355 (gnus-summary-position-point))))
5357 (defun gnus-summary-limit-include-dormant ()
5358 "Display all the hidden articles that are marked as dormant."
5360 (gnus-set-global-variables)
5361 (or gnus-newsgroup-dormant
5362 (error "There are no dormant articles in this group"))
5364 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5365 (gnus-summary-position-point)))
5367 (defun gnus-summary-limit-exclude-dormant ()
5368 "Hide all dormant articles."
5370 (gnus-set-global-variables)
5372 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5373 (gnus-summary-position-point)))
5375 (defun gnus-summary-limit-exclude-childless-dormant ()
5376 "Hide all dormant articles that have no children."
5378 (gnus-set-global-variables)
5379 (let ((data (gnus-data-list t))
5380 articles d children)
5381 ;; Find all articles that are either not dormant or have
5383 (while (setq d (pop data))
5384 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5386 (gnus-article-children (gnus-data-number d)))
5389 (when (memq (car children) articles)
5394 (push (gnus-data-number d) articles)))
5397 (gnus-summary-limit articles)
5398 (gnus-summary-position-point))))
5400 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5401 "Mark all unread excluded articles as read.
5402 If ALL, mark even excluded ticked and dormants as read."
5404 (let ((articles (gnus-sorted-complement
5406 (mapcar (lambda (h) (mail-header-number h))
5407 gnus-newsgroup-headers)
5409 (sort gnus-newsgroup-limit '<)))
5411 (setq gnus-newsgroup-unreads nil)
5413 (setq gnus-newsgroup-dormant nil
5414 gnus-newsgroup-marked nil
5415 gnus-newsgroup-reads
5417 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5418 gnus-newsgroup-reads))
5419 (while (setq article (pop articles))
5420 (unless (or (memq article gnus-newsgroup-dormant)
5421 (memq article gnus-newsgroup-marked))
5422 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5424 (defun gnus-summary-limit (articles &optional pop)
5426 ;; We pop the previous limit off the stack and use that.
5427 (setq articles (car gnus-newsgroup-limits)
5428 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5429 ;; We use the new limit, so we push the old limit on the stack.
5430 (setq gnus-newsgroup-limits
5431 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
5433 (setq gnus-newsgroup-limit articles)
5434 (let ((total (length gnus-newsgroup-data))
5435 (data (gnus-data-find-list (gnus-summary-article-number)))
5436 (gnus-summary-mark-below nil) ; Inhibit this.
5438 ;; This will do all the work of generating the new summary buffer
5439 ;; according to the new limit.
5440 (gnus-summary-prepare)
5441 ;; Hide any threads, possibly.
5442 (and gnus-show-threads
5443 gnus-thread-hide-subtree
5444 (gnus-summary-hide-all-threads))
5445 ;; Try to return to the article you were at, or one in the
5448 ;; We try to find some article after the current one.
5450 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5453 (setq data (cdr data))))
5455 ;; If there is no data, that means that we were after the last
5456 ;; article. The same goes when we can't find any articles
5457 ;; after the current one.
5458 (goto-char (point-max))
5459 (gnus-summary-find-prev))
5460 ;; We return how many articles were removed from the summary
5461 ;; buffer as a result of the new limit.
5462 (- total (length gnus-newsgroup-data))))
5464 (defsubst gnus-invisible-cut-children (threads)
5467 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5472 (defsubst gnus-cut-thread (thread)
5473 "Go forwards in the thread until we find an article that we want to display."
5474 (when (or (eq gnus-fetch-old-headers 'some)
5475 (eq gnus-build-sparse-threads 'some)
5476 (eq gnus-build-sparse-threads 'more))
5477 ;; Deal with old-fetched headers and sparse threads.
5481 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5482 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5483 (or (<= (length (cdr thread)) 1)
5484 (gnus-invisible-cut-children (cdr thread))))
5485 (setq thread (cadr thread))))
5488 (defun gnus-cut-threads (threads)
5489 "Cut off all uninteresting articles from the beginning of threads."
5490 (when (or (eq gnus-fetch-old-headers 'some)
5491 (eq gnus-build-sparse-threads 'some)
5492 (eq gnus-build-sparse-threads 'more))
5495 (setcar th (gnus-cut-thread (car th)))
5496 (setq th (cdr th)))))
5497 ;; Remove nixed out threads.
5500 (defun gnus-summary-initial-limit (&optional show-if-empty)
5501 "Figure out what the initial limit is supposed to be on group entry.
5502 This entails weeding out unwanted dormants, low-scored articles,
5503 fetch-old-headers verbiage, and so on."
5504 ;; Most groups have nothing to remove.
5505 (if (or gnus-inhibit-limiting
5506 (and (null gnus-newsgroup-dormant)
5507 (not (eq gnus-fetch-old-headers 'some))
5508 (null gnus-summary-expunge-below)
5509 (not (eq gnus-build-sparse-threads 'some))
5510 (not (eq gnus-build-sparse-threads 'more))
5511 (null gnus-thread-expunge-below)
5512 (not gnus-use-nocem)))
5514 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5515 (setq gnus-newsgroup-limit nil)
5518 (unless (car (symbol-value node))
5519 ;; These threads have no parents -- they are roots.
5520 (let ((nodes (cdr (symbol-value node)))
5523 (if (and gnus-thread-expunge-below
5524 (< (gnus-thread-total-score (car nodes))
5525 gnus-thread-expunge-below))
5526 (gnus-expunge-thread (pop nodes))
5527 (setq thread (pop nodes))
5528 (gnus-summary-limit-children thread))))))
5529 gnus-newsgroup-dependencies)
5530 ;; If this limitation resulted in an empty group, we might
5531 ;; pop the previous limit and use it instead.
5532 (when (and (not gnus-newsgroup-limit)
5534 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5535 gnus-newsgroup-limit))
5537 (defun gnus-summary-limit-children (thread)
5538 "Return 1 if this subthread is visible and 0 if it is not."
5539 ;; First we get the number of visible children to this thread. This
5540 ;; is done by recursing down the thread using this function, so this
5541 ;; will really go down to a leaf article first, before slowly
5542 ;; working its way up towards the root.
5546 (apply '+ (mapcar 'gnus-summary-limit-children
5549 (number (mail-header-number (car thread)))
5552 (not (memq number gnus-newsgroup-marked))
5554 ;; If this article is dormant and has absolutely no visible
5555 ;; children, then this article isn't visible.
5556 (and (memq number gnus-newsgroup-dormant)
5558 ;; If this is "fetch-old-headered" and there is only one
5559 ;; visible child (or less), then we don't want this article.
5560 (and (eq gnus-fetch-old-headers 'some)
5561 (memq number gnus-newsgroup-ancient)
5563 ;; If this is a sparsely inserted article with no children,
5564 ;; we don't want it.
5565 (and (eq gnus-build-sparse-threads 'some)
5566 (memq number gnus-newsgroup-sparse)
5568 ;; If we use expunging, and this article is really
5569 ;; low-scored, then we don't want this article.
5570 (when (and gnus-summary-expunge-below
5572 (or (cdr (assq number gnus-newsgroup-scored))
5573 gnus-summary-default-score))
5574 gnus-summary-expunge-below))
5575 ;; We increase the expunge-tally here, but that has
5576 ;; nothing to do with the limits, really.
5577 (incf gnus-newsgroup-expunged-tally)
5578 ;; We also mark as read here, if that's wanted.
5579 (when (and gnus-summary-mark-below
5580 (< score gnus-summary-mark-below))
5581 (setq gnus-newsgroup-unreads
5582 (delq number gnus-newsgroup-unreads))
5583 (if gnus-newsgroup-auto-expire
5584 (push number gnus-newsgroup-expirable)
5585 (push (cons number gnus-low-score-mark)
5586 gnus-newsgroup-reads)))
5588 ;; Check NoCeM things.
5590 (gnus-nocem-unwanted-article-p
5591 (mail-header-id (car thread))))))
5592 ;; Nope, invisible article.
5594 ;; Ok, this article is to be visible, so we add it to the limit
5596 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
5599 (defun gnus-expunge-thread (thread)
5600 "Mark all articles in THREAD as read."
5601 (let* ((number (mail-header-number (car thread))))
5602 (incf gnus-newsgroup-expunged-tally)
5603 ;; We also mark as read here, if that's wanted.
5604 (setq gnus-newsgroup-unreads
5605 (delq number gnus-newsgroup-unreads))
5606 (if gnus-newsgroup-auto-expire
5607 (push number gnus-newsgroup-expirable)
5608 (push (cons number gnus-low-score-mark)
5609 gnus-newsgroup-reads)))
5610 ;; Go recursively through all subthreads.
5611 (mapcar 'gnus-expunge-thread (cdr thread)))
5613 ;; Summary article oriented commands
5615 (defun gnus-summary-refer-parent-article (n)
5616 "Refer parent article N times.
5617 If N is negative, go to ancestor -N instead.
5618 The difference between N and the number of articles fetched is returned."
5620 (gnus-set-global-variables)
5623 (when (not (natnump n))
5628 (setq header (gnus-summary-article-header))
5630 ;; If we try to find the parent of the currently
5631 ;; displayed article, then we take a look at the actual
5632 ;; References header, since this is slightly more
5633 ;; reliable than the References field we got from the
5635 (if (and (eq (mail-header-number header)
5636 (cdr gnus-article-current))
5637 (equal gnus-newsgroup-name
5638 (car gnus-article-current)))
5640 (set-buffer gnus-original-article-buffer)
5641 (nnheader-narrow-to-headers)
5643 (message-fetch-field "references")
5645 ;; It's not the current article, so we take a bet on
5646 ;; the value we got from the server.
5647 (mail-header-references header)))
5649 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
5650 (gnus-message 1 "Couldn't find parent"))
5651 (gnus-message 1 "No references in article %d"
5652 (gnus-summary-article-number))
5655 (gnus-summary-position-point)
5658 (defun gnus-summary-refer-references ()
5659 "Fetch all articles mentioned in the References header.
5660 Return how many articles were fetched."
5662 (gnus-set-global-variables)
5663 (let ((ref (mail-header-references (gnus-summary-article-header)))
5664 (current (gnus-summary-article-number))
5666 ;; For each Message-ID in the References header...
5667 (while (string-match "<[^>]*>" ref)
5669 ;; ... fetch that article.
5670 (gnus-summary-refer-article
5671 (prog1 (match-string 0 ref)
5672 (setq ref (substring ref (match-end 0))))))
5673 (gnus-summary-goto-subject current)
5674 (gnus-summary-position-point)
5677 (defun gnus-summary-refer-article (message-id)
5678 "Fetch an article specified by MESSAGE-ID."
5679 (interactive "sMessage-ID: ")
5680 (when (and (stringp message-id)
5681 (not (zerop (length message-id))))
5682 ;; Construct the correct Message-ID if necessary.
5683 ;; Suggested by tale@pawl.rpi.edu.
5684 (unless (string-match "^<" message-id)
5685 (setq message-id (concat "<" message-id)))
5686 (unless (string-match ">$" message-id)
5687 (setq message-id (concat message-id ">")))
5688 (let* ((header (gnus-id-to-header message-id))
5690 (memq (mail-header-number header)
5691 gnus-newsgroup-sparse))))
5694 ;; The article is present in the buffer, to we just go to it.
5695 (gnus-summary-goto-article
5696 (mail-header-number header) nil header)
5698 (gnus-summary-update-article (mail-header-number header))))
5699 ;; We fetch the article
5700 (let ((gnus-override-method
5701 (and (gnus-news-group-p gnus-newsgroup-name)
5702 gnus-refer-article-method))
5704 ;; Start the special refer-article method, if necessary.
5705 (when (and gnus-refer-article-method
5706 (gnus-news-group-p gnus-newsgroup-name))
5707 (gnus-check-server gnus-refer-article-method))
5708 ;; Fetch the header, and display the article.
5709 (if (setq number (gnus-summary-insert-subject message-id))
5710 (gnus-summary-select-article nil nil nil number)
5711 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
5713 (defun gnus-summary-enter-digest-group (&optional force)
5714 "Enter an nndoc group based on the current article.
5715 If FORCE, force a digest interpretation. If not, try
5716 to guess what the document format is."
5718 (gnus-set-global-variables)
5719 (let ((conf gnus-current-window-configuration))
5721 (gnus-summary-select-article))
5722 (setq gnus-current-window-configuration conf)
5723 (let* ((name (format "%s-%d"
5724 (gnus-group-prefixed-name
5725 gnus-newsgroup-name (list 'nndoc ""))
5727 (set-buffer gnus-summary-buffer)
5728 gnus-current-article)))
5729 (ogroup gnus-newsgroup-name)
5730 (params (append (gnus-info-params (gnus-get-info ogroup))
5731 (list (cons 'to-group ogroup))))
5732 (case-fold-search t)
5733 (buf (current-buffer))
5736 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
5737 (insert-buffer-substring gnus-original-article-buffer)
5738 ;; Remove lines that may lead nndoc to misinterpret the
5741 (goto-char (point-min))
5742 (or (search-forward "\n\n" nil t) (point)))
5743 (goto-char (point-min))
5744 (delete-matching-lines "^\\(Path\\):\\|^From ")
5747 (let ((gnus-current-window-configuration
5748 (if (and (boundp 'gnus-pick-mode)
5749 (symbol-value (intern "gnus-pick-mode")))
5751 (if (gnus-group-read-ephemeral-group
5752 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
5754 ,(if force 'digest 'guess))) t)
5755 ;; Make all postings to this group go to the parent group.
5756 (nconc (gnus-info-params (gnus-get-info name))
5758 ;; Couldn't select this doc group.
5759 (switch-to-buffer buf)
5760 (gnus-set-global-variables)
5761 (gnus-configure-windows 'summary)
5762 (gnus-message 3 "Article couldn't be entered?")))
5763 (kill-buffer dig)))))
5765 (defun gnus-summary-read-document (n)
5766 "Open a new group based on the current article(s).
5767 Obeys the standard process/prefix convention."
5769 (let* ((articles (gnus-summary-work-articles n))
5770 (ogroup gnus-newsgroup-name)
5771 (params (append (gnus-info-params (gnus-get-info ogroup))
5772 (list (cons 'to-group ogroup))))
5773 article group egroup groups vgroup)
5774 (while (setq article (pop articles))
5775 (setq group (format "%s-%d" gnus-newsgroup-name article))
5776 (gnus-summary-remove-process-mark article)
5777 (when (gnus-summary-display-article article)
5779 (nnheader-temp-write nil
5780 (insert-buffer-substring gnus-original-article-buffer)
5781 ;; Remove some headers that may lead nndoc to make
5783 (message-narrow-to-head)
5784 (goto-char (point-min))
5785 (delete-matching-lines "^\\(Path\\):\\|^From ")
5788 (gnus-group-read-ephemeral-group
5789 group `(nndoc ,group (nndoc-address ,(current-buffer))
5790 (nndoc-article-type guess))
5793 ;; Make all postings to this group go to the parent group.
5794 (nconc (gnus-info-params (gnus-get-info egroup))
5796 (push egroup groups))
5797 ;; Couldn't select this doc group.
5798 (gnus-error 3 "Article couldn't be entered"))))))
5799 ;; Now we have selected all the documents.
5802 (error "None of the articles could be interpreted as documents"))
5803 ((gnus-group-read-ephemeral-group
5804 (setq vgroup (format
5805 "nnvirtual:%s-%s" gnus-newsgroup-name
5806 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
5807 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
5809 (cons (current-buffer) 'summary)))
5811 (error "Couldn't select virtual nndoc group")))))
5813 (defun gnus-summary-isearch-article (&optional regexp-p)
5814 "Do incremental search forward on the current article.
5815 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
5817 (gnus-set-global-variables)
5818 (gnus-summary-select-article)
5819 (gnus-configure-windows 'article)
5820 (gnus-eval-in-buffer-window gnus-article-buffer
5821 ;;(goto-char (point-min))
5822 (isearch-forward regexp-p)))
5824 (defun gnus-summary-search-article-forward (regexp &optional backward)
5825 "Search for an article containing REGEXP forward.
5826 If BACKWARD, search backward instead."
5829 (format "Search article %s (regexp%s): "
5830 (if current-prefix-arg "backward" "forward")
5831 (if gnus-last-search-regexp
5832 (concat ", default " gnus-last-search-regexp)
5834 current-prefix-arg))
5835 (gnus-set-global-variables)
5836 (if (string-equal regexp "")
5837 (setq regexp (or gnus-last-search-regexp ""))
5838 (setq gnus-last-search-regexp regexp))
5839 (if (gnus-summary-search-article regexp backward)
5840 (gnus-summary-show-thread)
5841 (error "Search failed: \"%s\"" regexp)))
5843 (defun gnus-summary-search-article-backward (regexp)
5844 "Search for an article containing REGEXP backward."
5847 (format "Search article backward (regexp%s): "
5848 (if gnus-last-search-regexp
5849 (concat ", default " gnus-last-search-regexp)
5851 (gnus-summary-search-article-forward regexp 'backward))
5853 (defun gnus-summary-search-article (regexp &optional backward)
5854 "Search for an article containing REGEXP.
5855 Optional argument BACKWARD means do search for backward.
5856 `gnus-select-article-hook' is not called during the search."
5857 (let ((gnus-select-article-hook nil) ;Disable hook.
5858 (gnus-article-display-hook nil)
5859 (gnus-mark-article-hook nil) ;Inhibit marking as read.
5860 (gnus-use-article-prefetch nil)
5861 (sum (current-buffer))
5864 (gnus-save-hidden-threads
5865 (gnus-summary-select-article)
5866 (set-buffer gnus-article-buffer)
5870 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
5872 (re-search-backward regexp nil t)
5873 (re-search-forward regexp nil t))
5874 ;; We found the regexp.
5879 (get-buffer-window (current-buffer))
5883 (setq point (point)))
5884 ;; We didn't find it, so we go to the next article.
5886 (if (not (if backward (gnus-summary-find-prev)
5887 (gnus-summary-find-next)))
5888 ;; No more articles.
5890 ;; Select the next article and adjust point.
5891 (gnus-summary-select-article)
5892 (set-buffer gnus-article-buffer)
5894 (goto-char (if backward (point-max) (point-min))))))
5895 (gnus-message 7 ""))
5896 ;; Return whether we found the regexp.
5897 (when (eq found 'found)
5899 (gnus-summary-show-thread)
5900 (gnus-summary-goto-subject gnus-current-article)
5901 (gnus-summary-position-point)
5904 (defun gnus-summary-find-matching (header regexp &optional backward unread
5906 "Return a list of all articles that match REGEXP on HEADER.
5907 The search stars on the current article and goes forwards unless
5908 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
5909 If UNREAD is non-nil, only unread articles will
5910 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
5911 in the comparisons."
5912 (let ((data (if (eq backward 'all) gnus-newsgroup-data
5913 (gnus-data-find-list
5914 (gnus-summary-article-number) (gnus-data-list backward))))
5915 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
5916 (case-fold-search (not not-case-fold))
5918 (or (fboundp (intern (concat "mail-header-" header)))
5919 (error "%s is not a valid header" header))
5922 (and (or (not unread) ; We want all articles...
5923 (gnus-data-unread-p d)) ; Or just unreads.
5924 (vectorp (gnus-data-header d)) ; It's not a pseudo.
5925 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
5926 (setq articles (cons (gnus-data-number d) articles))) ; Success!
5927 (setq data (cdr data)))
5928 (nreverse articles)))
5930 (defun gnus-summary-execute-command (header regexp command &optional backward)
5931 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
5932 If HEADER is an empty string (or nil), the match is done on the entire
5933 article. If BACKWARD (the prefix) is non-nil, search backward instead."
5935 (list (let ((completion-ignore-case t))
5938 (mapcar (lambda (string) (list string))
5939 '("Number" "Subject" "From" "Lines" "Date"
5940 "Message-ID" "Xref" "References" "Body"))
5941 nil 'require-match))
5942 (read-string "Regexp: ")
5943 (read-key-sequence "Command: ")
5944 current-prefix-arg))
5945 (when (equal header "Body")
5947 (gnus-set-global-variables)
5948 ;; Hidden thread subtrees must be searched as well.
5949 (gnus-summary-show-all-threads)
5950 ;; We don't want to change current point nor window configuration.
5952 (save-window-excursion
5953 (gnus-message 6 "Executing %s..." (key-description command))
5954 ;; We'd like to execute COMMAND interactively so as to give arguments.
5955 (gnus-execute header regexp
5956 `(call-interactively ',(key-binding command))
5958 (gnus-message 6 "Executing %s...done" (key-description command)))))
5960 (defun gnus-summary-beginning-of-article ()
5961 "Scroll the article back to the beginning."
5963 (gnus-set-global-variables)
5964 (gnus-summary-select-article)
5965 (gnus-configure-windows 'article)
5966 (gnus-eval-in-buffer-window gnus-article-buffer
5968 (goto-char (point-min))
5969 (and gnus-break-pages (gnus-narrow-to-page))))
5971 (defun gnus-summary-end-of-article ()
5972 "Scroll to the end of the article."
5974 (gnus-set-global-variables)
5975 (gnus-summary-select-article)
5976 (gnus-configure-windows 'article)
5977 (gnus-eval-in-buffer-window gnus-article-buffer
5979 (goto-char (point-max))
5981 (and gnus-break-pages (gnus-narrow-to-page))))
5983 (defun gnus-summary-show-article (&optional arg)
5984 "Force re-fetching of the current article.
5985 If ARG (the prefix) is non-nil, show the raw article without any
5986 article massaging functions being run."
5988 (gnus-set-global-variables)
5990 ;; Select the article the normal way.
5991 (gnus-summary-select-article nil 'force)
5992 ;; Bind the article treatment functions to nil.
5993 (let ((gnus-have-all-headers t)
5994 gnus-article-display-hook
5995 gnus-article-prepare-hook
5998 (gnus-summary-select-article nil 'force)))
5999 (gnus-summary-goto-subject gnus-current-article)
6000 ; (gnus-configure-windows 'article)
6001 (gnus-summary-position-point))
6003 (defun gnus-summary-verbose-headers (&optional arg)
6004 "Toggle permanent full header display.
6005 If ARG is a positive number, turn header display on.
6006 If ARG is a negative number, turn header display off."
6008 (gnus-set-global-variables)
6009 (setq gnus-show-all-headers
6010 (cond ((or (not (numberp arg))
6012 (not gnus-show-all-headers))
6015 (gnus-summary-show-article))
6017 (defun gnus-summary-toggle-header (&optional arg)
6018 "Show the headers if they are hidden, or hide them if they are shown.
6019 If ARG is a positive number, show the entire header.
6020 If ARG is a negative number, hide the unwanted header lines."
6022 (gnus-set-global-variables)
6024 (set-buffer gnus-article-buffer)
6025 (let* ((buffer-read-only nil)
6026 (inhibit-point-motion-hooks t)
6027 (hidden (text-property-any
6028 (goto-char (point-min)) (search-forward "\n\n")
6031 (goto-char (point-min))
6032 (when (search-forward "\n\n" nil t)
6033 (delete-region (point-min) (1- (point))))
6034 (goto-char (point-min))
6036 (set-buffer gnus-original-article-buffer)
6037 (goto-char (point-min))
6038 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6039 (insert-buffer-substring gnus-original-article-buffer 1 e)
6040 (let ((article-inhibit-hiding t))
6041 (run-hooks 'gnus-article-display-hook))
6042 (if (or (not hidden) (and (numberp arg) (< arg 0)))
6043 (gnus-article-hide-headers)))))
6045 (defun gnus-summary-show-all-headers ()
6046 "Make all header lines visible."
6048 (gnus-set-global-variables)
6049 (gnus-article-show-all-headers))
6051 (defun gnus-summary-toggle-mime (&optional arg)
6052 "Toggle MIME processing.
6053 If ARG is a positive number, turn MIME processing on."
6055 (gnus-set-global-variables)
6056 (setq gnus-show-mime
6057 (if (null arg) (not gnus-show-mime)
6058 (> (prefix-numeric-value arg) 0)))
6059 (gnus-summary-select-article t 'force))
6061 (defun gnus-summary-caesar-message (&optional arg)
6062 "Caesar rotate the current article by 13.
6063 The numerical prefix specifies how manu places to rotate each letter
6066 (gnus-set-global-variables)
6067 (gnus-summary-select-article)
6068 (let ((mail-header-separator ""))
6069 (gnus-eval-in-buffer-window gnus-article-buffer
6072 (let ((start (window-start))
6074 (message-caesar-buffer-body arg)
6075 (set-window-start (get-buffer-window (current-buffer)) start))))))
6077 (defun gnus-summary-stop-page-breaking ()
6078 "Stop page breaking in the current article."
6080 (gnus-set-global-variables)
6081 (gnus-summary-select-article)
6082 (gnus-eval-in-buffer-window gnus-article-buffer
6085 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
6086 "Move the current article to a different newsgroup.
6087 If N is a positive number, move the N next articles.
6088 If N is a negative number, move the N previous articles.
6089 If N is nil and any articles have been marked with the process mark,
6090 move those articles instead.
6091 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6092 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6093 re-spool using this method.
6095 For this function to work, both the current newsgroup and the
6096 newsgroup that you want to move to have to support the `request-move'
6097 and `request-accept' functions."
6099 (unless action (setq action 'move))
6100 (gnus-set-global-variables)
6101 ;; Check whether the source group supports the required functions.
6102 (cond ((and (eq action 'move)
6103 (not (gnus-check-backend-function
6104 'request-move-article gnus-newsgroup-name)))
6105 (error "The current group does not support article moving"))
6106 ((and (eq action 'crosspost)
6107 (not (gnus-check-backend-function
6108 'request-replace-article gnus-newsgroup-name)))
6109 (error "The current group does not support article editing")))
6110 (let ((articles (gnus-summary-work-articles n))
6111 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6112 (names '((move "Move" "Moving")
6113 (copy "Copy" "Copying")
6114 (crosspost "Crosspost" "Crossposting")))
6115 (copy-buf (save-excursion
6116 (nnheader-set-temp-buffer " *copy article*")))
6117 art-group to-method new-xref article to-groups)
6118 (unless (assq action names)
6119 (error "Unknown action %s" action))
6120 ;; Read the newsgroup name.
6121 (when (and (not to-newsgroup)
6122 (not select-method))
6124 (gnus-read-move-group-name
6125 (cadr (assq action names))
6126 (symbol-value (intern (format "gnus-current-%s-group" action)))
6128 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6129 (setq to-method (or select-method
6130 (gnus-group-name-to-method to-newsgroup)))
6131 ;; Check the method we are to move this article to...
6132 (or (gnus-check-backend-function 'request-accept-article (car to-method))
6133 (error "%s does not support article copying" (car to-method)))
6134 (or (gnus-check-server to-method)
6135 (error "Can't open server %s" (car to-method)))
6136 (gnus-message 6 "%s to %s: %s..."
6137 (caddr (assq action names))
6138 (or (car select-method) to-newsgroup) articles)
6140 (setq article (pop articles))
6144 ;; Move the article.
6146 (gnus-request-move-article
6147 article ; Article to move
6148 gnus-newsgroup-name ; From newsgroup
6149 (nth 1 (gnus-find-method-for-group
6150 gnus-newsgroup-name)) ; Server
6151 (list 'gnus-request-accept-article
6152 to-newsgroup (list 'quote select-method)
6153 (not articles)) ; Accept form
6154 (not articles))) ; Only save nov last time
6155 ;; Copy the article.
6158 (set-buffer copy-buf)
6159 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6160 (gnus-request-accept-article
6161 to-newsgroup select-method (not articles))))
6162 ;; Crosspost the article.
6163 ((eq action 'crosspost)
6164 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
6165 (setq new-xref (concat gnus-newsgroup-name ":" article))
6166 (if (and xref (not (string= xref "")))
6168 (when (string-match "^Xref: " xref)
6169 (setq xref (substring xref (match-end 0))))
6170 (setq new-xref (concat xref " " new-xref)))
6171 (setq new-xref (concat (system-name) " " new-xref)))
6173 (set-buffer copy-buf)
6174 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6175 (nnheader-replace-header "xref" new-xref)
6176 (gnus-request-accept-article
6177 to-newsgroup select-method (not articles)))))))
6179 (gnus-message 1 "Couldn't %s article %s"
6180 (cadr (assq action names)) article)
6183 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6185 (gnus-group-prefixed-name
6188 (gnus-find-method-for-group to-newsgroup)))
6189 gnus-newsrc-hashtb)))
6190 (info (nth 2 entry))
6191 (to-group (gnus-info-group info)))
6192 ;; Update the group that has been moved to.
6194 (memq action '(move copy)))
6195 (unless (member to-group to-groups)
6196 (push to-group to-groups))
6198 (unless (memq article gnus-newsgroup-unreads)
6200 info (gnus-add-to-range (gnus-info-read info)
6201 (list (cdr art-group)))))
6203 ;; Copy any marks over to the new group.
6204 (let ((marks gnus-article-mark-lists)
6205 (to-article (cdr art-group)))
6207 ;; See whether the article is to be put in the cache.
6208 (when gnus-use-cache
6209 (gnus-cache-possibly-enter-article
6211 (let ((header (copy-sequence
6212 (gnus-summary-article-header article))))
6213 (mail-header-set-number header to-article)
6215 (memq article gnus-newsgroup-marked)
6216 (memq article gnus-newsgroup-dormant)
6217 (memq article gnus-newsgroup-unreads)))
6220 (when (memq article (symbol-value
6221 (intern (format "gnus-newsgroup-%s"
6223 ;; If the other group is the same as this group,
6224 ;; then we have to add the mark to the list.
6225 (when (equal to-group gnus-newsgroup-name)
6226 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6229 (intern (format "gnus-newsgroup-%s"
6231 ;; Copy mark to other group.
6232 (gnus-add-marked-articles
6233 to-group (cdar marks) (list to-article) info))
6234 (setq marks (cdr marks)))))
6236 ;; Update the Xref header in this article to point to
6237 ;; the new crossposted article we have just created.
6238 (when (eq action 'crosspost)
6240 (set-buffer copy-buf)
6241 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6242 (nnheader-replace-header
6243 "xref" (concat new-xref " " (gnus-group-prefixed-name
6244 (car art-group) to-method)
6245 ":" (cdr art-group)))
6246 (gnus-request-replace-article
6247 article gnus-newsgroup-name (current-buffer)))))
6249 (gnus-summary-goto-subject article)
6250 (when (eq action 'move)
6251 (gnus-summary-mark-article article gnus-canceled-mark)))
6252 (gnus-summary-remove-process-mark article))
6253 ;; Re-activate all groups that have been moved to.
6255 (gnus-activate-group (pop to-groups)))
6257 (gnus-kill-buffer copy-buf)
6258 (gnus-summary-position-point)
6259 (gnus-set-mode-line 'summary)))
6261 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6262 "Move the current article to a different newsgroup.
6263 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6264 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6265 re-spool using this method."
6267 (gnus-summary-move-article n nil select-method 'copy))
6269 (defun gnus-summary-crosspost-article (&optional n)
6270 "Crosspost the current article to some other group."
6272 (gnus-summary-move-article n nil nil 'crosspost))
6274 (defvar gnus-summary-respool-default-method nil
6275 "Default method for respooling an article.
6276 If nil, use to the current newsgroup method.")
6278 (defun gnus-summary-respool-article (&optional n method)
6279 "Respool the current article.
6280 The article will be squeezed through the mail spooling process again,
6281 which means that it will be put in some mail newsgroup or other
6282 depending on `nnmail-split-methods'.
6283 If N is a positive number, respool the N next articles.
6284 If N is a negative number, respool the N previous articles.
6285 If N is nil and any articles have been marked with the process mark,
6286 respool those articles instead.
6288 Respooling can be done both from mail groups and \"real\" newsgroups.
6289 In the former case, the articles in question will be moved from the
6290 current group into whatever groups they are destined to. In the
6291 latter case, they will be copied into the relevant groups."
6293 (list current-prefix-arg
6294 (let* ((methods (gnus-methods-using 'respool))
6296 (symbol-name (or gnus-summary-respool-default-method
6297 (car (gnus-find-method-for-group
6298 gnus-newsgroup-name)))))
6300 (gnus-completing-read
6301 methname "What backend do you want to use when respooling?"
6302 methods nil t nil 'gnus-method-history))
6305 ((zerop (length (setq ms (gnus-servers-using-backend method))))
6306 (list (intern method) ""))
6310 (cdr (completing-read
6312 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
6313 (gnus-set-global-variables)
6315 (error "No method given for respooling"))
6316 (if (assoc (symbol-name
6317 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6318 (gnus-methods-using 'respool))
6319 (gnus-summary-move-article n nil method)
6320 (gnus-summary-copy-article n nil method)))
6322 (defun gnus-summary-import-article (file)
6323 "Import a random file into a mail newsgroup."
6324 (interactive "fImport file: ")
6325 (gnus-set-global-variables)
6326 (let ((group gnus-newsgroup-name)
6327 (now (current-time))
6329 (or (gnus-check-backend-function 'request-accept-article group)
6330 (error "%s does not support article importing" group))
6331 (or (file-readable-p file)
6332 (not (file-regular-p file))
6333 (error "Can't read %s" file))
6335 (set-buffer (get-buffer-create " *import file*"))
6336 (buffer-disable-undo (current-buffer))
6338 (insert-file-contents file)
6339 (goto-char (point-min))
6340 (unless (nnheader-article-p)
6341 ;; This doesn't look like an article, so we fudge some headers.
6342 (setq atts (file-attributes file)
6343 lines (count-lines (point-min) (point-max)))
6344 (insert "From: " (read-string "From: ") "\n"
6345 "Subject: " (read-string "Subject: ") "\n"
6346 "Date: " (timezone-make-date-arpa-standard
6347 (current-time-string (nth 5 atts))
6348 (current-time-zone now)
6349 (current-time-zone now)) "\n"
6350 "Message-ID: " (message-make-message-id) "\n"
6351 "Lines: " (int-to-string lines) "\n"
6352 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6353 (gnus-request-accept-article group nil t)
6354 (kill-buffer (current-buffer)))))
6356 (defun gnus-summary-article-posted-p ()
6357 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6358 This will be the case if the article has both been mailed and posted."
6360 (let ((id (mail-header-references (gnus-summary-article-header)))
6361 (gnus-override-method
6362 (or gnus-refer-article-method gnus-select-method)))
6363 (if (gnus-request-head id "")
6364 (gnus-message 2 "The current message was found on %s"
6365 gnus-override-method)
6366 (gnus-message 2 "The current message couldn't be found on %s"
6367 gnus-override-method)
6370 (defun gnus-summary-expire-articles (&optional now)
6371 "Expire all articles that are marked as expirable in the current group."
6373 (gnus-set-global-variables)
6374 (when (gnus-check-backend-function
6375 'request-expire-articles gnus-newsgroup-name)
6376 ;; This backend supports expiry.
6377 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6378 (expirable (if total
6379 (gnus-list-of-read-articles gnus-newsgroup-name)
6380 (setq gnus-newsgroup-expirable
6381 (sort gnus-newsgroup-expirable '<))))
6382 (expiry-wait (if now 'immediate
6383 (gnus-group-find-parameter
6384 gnus-newsgroup-name 'expiry-wait)))
6387 ;; There are expirable articles in this group, so we run them
6388 ;; through the expiry process.
6389 (gnus-message 6 "Expiring articles...")
6390 ;; The list of articles that weren't expired is returned.
6392 (let ((nnmail-expiry-wait-function nil)
6393 (nnmail-expiry-wait expiry-wait))
6394 (setq es (gnus-request-expire-articles
6395 expirable gnus-newsgroup-name)))
6396 (setq es (gnus-request-expire-articles
6397 expirable gnus-newsgroup-name)))
6399 (setq gnus-newsgroup-expirable es))
6400 ;; We go through the old list of expirable, and mark all
6401 ;; really expired articles as nonexistent.
6402 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6403 (let ((gnus-use-cache nil))
6405 (unless (memq (car expirable) es)
6406 (when (gnus-data-find (car expirable))
6407 (gnus-summary-mark-article
6408 (car expirable) gnus-canceled-mark)))
6409 (setq expirable (cdr expirable)))))
6410 (gnus-message 6 "Expiring articles...done")))))
6412 (defun gnus-summary-expire-articles-now ()
6413 "Expunge all expirable articles in the current group.
6414 This means that *all* articles that are marked as expirable will be
6415 deleted forever, right now."
6417 (gnus-set-global-variables)
6418 (or gnus-expert-user
6420 "Are you really, really, really sure you want to delete all these messages? ")
6422 (gnus-summary-expire-articles t))
6424 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6425 (defun gnus-summary-delete-article (&optional n)
6426 "Delete the N next (mail) articles.
6427 This command actually deletes articles. This is not a marking
6428 command. The article will disappear forever from your life, never to
6430 If N is negative, delete backwards.
6431 If N is nil and articles have been marked with the process mark,
6432 delete these instead."
6434 (gnus-set-global-variables)
6435 (or (gnus-check-backend-function 'request-expire-articles
6436 gnus-newsgroup-name)
6437 (error "The current newsgroup does not support article deletion."))
6438 ;; Compute the list of articles to delete.
6439 (let ((articles (gnus-summary-work-articles n))
6441 (if (and gnus-novice-user
6443 (format "Do you really want to delete %s forever? "
6444 (if (> (length articles) 1)
6445 (format "these %s articles" (length articles))
6448 ;; Delete the articles.
6449 (setq not-deleted (gnus-request-expire-articles
6450 articles gnus-newsgroup-name 'force))
6452 (gnus-summary-remove-process-mark (car articles))
6453 ;; The backend might not have been able to delete the article
6455 (or (memq (car articles) not-deleted)
6456 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6457 (setq articles (cdr articles))))
6458 (gnus-summary-position-point)
6459 (gnus-set-mode-line 'summary)
6462 (defun gnus-summary-edit-article (&optional force)
6463 "Edit the current article.
6464 This will have permanent effect only in mail groups.
6465 If FORCE is non-nil, allow editing of articles even in read-only
6469 (set-buffer gnus-summary-buffer)
6470 (gnus-set-global-variables)
6471 (when (and (not force)
6472 (gnus-group-read-only-p))
6473 (error "The current newsgroup does not support article editing."))
6474 ;; Select article if needed.
6475 (unless (eq (gnus-summary-article-number)
6476 gnus-current-article)
6477 (gnus-summary-select-article t))
6478 (gnus-article-edit-article
6480 (gnus-summary-edit-article-done
6481 ,(or (mail-header-references gnus-current-headers) "")
6482 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6484 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6486 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6487 "Make edits to the current article permanent."
6489 ;; Replace the article.
6490 (if (and (not read-only)
6491 (not (gnus-request-replace-article
6492 (cdr gnus-article-current) (car gnus-article-current)
6494 (error "Couldn't replace article.")
6495 ;; Update the summary buffer.
6497 (equal (message-tokenize-header references " ")
6498 (message-tokenize-header
6499 (or (message-fetch-field "references") "") " ")))
6500 ;; We only have to update this line.
6503 (message-narrow-to-head)
6504 (let ((header (nnheader-parse-head t)))
6506 (mail-header-set-number header (cdr gnus-article-current))
6507 (gnus-summary-update-article-line
6508 (cdr gnus-article-current) header))))
6510 (set-buffer (or buffer gnus-summary-buffer))
6511 (gnus-summary-update-article (cdr gnus-article-current)))
6512 ;; Prettify the article buffer again.
6514 (set-buffer gnus-article-buffer)
6515 (run-hooks 'gnus-article-display-hook))
6516 ;; Prettify the summary buffer line.
6517 (when (gnus-visual-p 'summary-highlight 'highlight)
6518 (run-hooks 'gnus-visual-mark-article-hook))))
6520 (defun gnus-summary-edit-wash (key)
6521 "Perform editing command in the article buffer."
6525 (message "%s" (concat (this-command-keys) "- "))
6528 (gnus-summary-edit-article)
6529 (execute-kbd-macro (concat (this-command-keys) key))
6530 (gnus-article-edit-done))
6534 (defun gnus-summary-respool-query ()
6535 "Query where the respool algorithm would put this article."
6537 (gnus-set-global-variables)
6538 (gnus-summary-select-article)
6540 (set-buffer gnus-article-buffer)
6542 (goto-char (point-min))
6543 (search-forward "\n\n")
6544 (narrow-to-region (point-min) (point))
6545 (message "This message would go to %s"
6546 (mapconcat 'car (nnmail-article-group 'identity) ", ")))))
6548 ;; Summary marking commands.
6550 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6551 "Mark articles which has the same subject as read, and then select the next.
6552 If UNMARK is positive, remove any kind of mark.
6553 If UNMARK is negative, tick articles."
6555 (gnus-set-global-variables)
6557 (setq unmark (prefix-numeric-value unmark)))
6559 (gnus-summary-mark-same-subject
6560 (gnus-summary-article-subject) unmark)))
6561 ;; Select next unread article. If auto-select-same mode, should
6562 ;; select the first unread article.
6563 (gnus-summary-next-article t (and gnus-auto-select-same
6564 (gnus-summary-article-subject)))
6565 (gnus-message 7 "%d article%s marked as %s"
6566 count (if (= count 1) " is" "s are")
6567 (if unmark "unread" "read"))))
6569 (defun gnus-summary-kill-same-subject (&optional unmark)
6570 "Mark articles which has the same subject as read.
6571 If UNMARK is positive, remove any kind of mark.
6572 If UNMARK is negative, tick articles."
6574 (gnus-set-global-variables)
6576 (setq unmark (prefix-numeric-value unmark)))
6578 (gnus-summary-mark-same-subject
6579 (gnus-summary-article-subject) unmark)))
6580 ;; If marked as read, go to next unread subject.
6582 ;; Go to next unread subject.
6583 (gnus-summary-next-subject 1 t))
6584 (gnus-message 7 "%d articles are marked as %s"
6585 count (if unmark "unread" "read"))))
6587 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6588 "Mark articles with same SUBJECT as read, and return marked number.
6589 If optional argument UNMARK is positive, remove any kinds of marks.
6590 If optional argument UNMARK is negative, mark articles as unread instead."
6594 ((null unmark) ; Mark as read.
6597 (gnus-summary-mark-article-as-read gnus-killed-mark)
6598 (gnus-summary-show-thread) t)
6599 (gnus-summary-find-subject subject))
6600 (setq count (1+ count))))
6601 ((> unmark 0) ; Tick.
6604 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6605 (gnus-summary-show-thread) t)
6606 (gnus-summary-find-subject subject))
6607 (setq count (1+ count))))
6608 (t ; Mark as unread.
6611 (gnus-summary-mark-article-as-unread gnus-unread-mark)
6612 (gnus-summary-show-thread) t)
6613 (gnus-summary-find-subject subject))
6614 (setq count (1+ count)))))
6615 (gnus-set-mode-line 'summary)
6616 ;; Return the number of marked articles.
6619 (defun gnus-summary-mark-as-processable (n &optional unmark)
6620 "Set the process mark on the next N articles.
6621 If N is negative, mark backward instead. If UNMARK is non-nil, remove
6622 the process mark instead. The difference between N and the actual
6623 number of articles marked is returned."
6625 (gnus-set-global-variables)
6626 (let ((backward (< n 0))
6631 (gnus-summary-remove-process-mark
6632 (gnus-summary-article-number))
6633 (gnus-summary-set-process-mark (gnus-summary-article-number)))
6634 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
6636 (if (/= 0 n) (gnus-message 7 "No more articles"))
6637 (gnus-summary-recenter)
6638 (gnus-summary-position-point)
6641 (defun gnus-summary-unmark-as-processable (n)
6642 "Remove the process mark from the next N articles.
6643 If N is negative, mark backward instead. The difference between N and
6644 the actual number of articles marked is returned."
6646 (gnus-set-global-variables)
6647 (gnus-summary-mark-as-processable n t))
6649 (defun gnus-summary-unmark-all-processable ()
6650 "Remove the process mark from all articles."
6652 (gnus-set-global-variables)
6654 (while gnus-newsgroup-processable
6655 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
6656 (gnus-summary-position-point))
6658 (defun gnus-summary-mark-as-expirable (n)
6659 "Mark N articles forward as expirable.
6660 If N is negative, mark backward instead. The difference between N and
6661 the actual number of articles marked is returned."
6663 (gnus-set-global-variables)
6664 (gnus-summary-mark-forward n gnus-expirable-mark))
6666 (defun gnus-summary-mark-article-as-replied (article)
6667 "Mark ARTICLE replied and update the summary line."
6668 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
6669 (let ((buffer-read-only nil))
6670 (when (gnus-summary-goto-subject article)
6671 (gnus-summary-update-secondary-mark article))))
6673 (defun gnus-summary-set-bookmark (article)
6674 "Set a bookmark in current article."
6675 (interactive (list (gnus-summary-article-number)))
6676 (gnus-set-global-variables)
6677 (if (or (not (get-buffer gnus-article-buffer))
6678 (not gnus-current-article)
6679 (not gnus-article-current)
6680 (not (equal gnus-newsgroup-name (car gnus-article-current))))
6681 (error "No current article selected"))
6682 ;; Remove old bookmark, if one exists.
6683 (let ((old (assq article gnus-newsgroup-bookmarks)))
6684 (if old (setq gnus-newsgroup-bookmarks
6685 (delq old gnus-newsgroup-bookmarks))))
6686 ;; Set the new bookmark, which is on the form
6687 ;; (article-number . line-number-in-body).
6688 (setq gnus-newsgroup-bookmarks
6692 (set-buffer gnus-article-buffer)
6696 (goto-char (point-min))
6697 (search-forward "\n\n" nil t)
6700 gnus-newsgroup-bookmarks))
6701 (gnus-message 6 "A bookmark has been added to the current article."))
6703 (defun gnus-summary-remove-bookmark (article)
6704 "Remove the bookmark from the current article."
6705 (interactive (list (gnus-summary-article-number)))
6706 (gnus-set-global-variables)
6707 ;; Remove old bookmark, if one exists.
6708 (let ((old (assq article gnus-newsgroup-bookmarks)))
6711 (setq gnus-newsgroup-bookmarks
6712 (delq old gnus-newsgroup-bookmarks))
6713 (gnus-message 6 "Removed bookmark."))
6714 (gnus-message 6 "No bookmark in current article."))))
6716 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6717 (defun gnus-summary-mark-as-dormant (n)
6718 "Mark N articles forward as dormant.
6719 If N is negative, mark backward instead. The difference between N and
6720 the actual number of articles marked is returned."
6722 (gnus-set-global-variables)
6723 (gnus-summary-mark-forward n gnus-dormant-mark))
6725 (defun gnus-summary-set-process-mark (article)
6726 "Set the process mark on ARTICLE and update the summary line."
6727 (setq gnus-newsgroup-processable
6729 (delq article gnus-newsgroup-processable)))
6730 (when (gnus-summary-goto-subject article)
6731 (gnus-summary-show-thread)
6732 (gnus-summary-update-secondary-mark article)))
6734 (defun gnus-summary-remove-process-mark (article)
6735 "Remove the process mark from ARTICLE and update the summary line."
6736 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
6737 (when (gnus-summary-goto-subject article)
6738 (gnus-summary-show-thread)
6739 (gnus-summary-update-secondary-mark article)))
6741 (defun gnus-summary-set-saved-mark (article)
6742 "Set the process mark on ARTICLE and update the summary line."
6743 (push article gnus-newsgroup-saved)
6744 (when (gnus-summary-goto-subject article)
6745 (gnus-summary-update-secondary-mark article)))
6747 (defun gnus-summary-mark-forward (n &optional mark no-expire)
6748 "Mark N articles as read forwards.
6749 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
6750 The difference between N and the actual number of articles marked is
6753 (gnus-set-global-variables)
6754 (let ((backward (< n 0))
6755 (gnus-summary-goto-unread
6756 (and gnus-summary-goto-unread
6757 (not (eq gnus-summary-goto-unread 'never))
6758 (not (memq mark (list gnus-unread-mark
6759 gnus-ticked-mark gnus-dormant-mark)))))
6761 (mark (or mark gnus-del-mark)))
6763 (gnus-summary-mark-article nil mark no-expire)
6764 (zerop (gnus-summary-next-subject
6766 (and gnus-summary-goto-unread
6767 (not (eq gnus-summary-goto-unread 'never)))
6770 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
6771 (gnus-summary-recenter)
6772 (gnus-summary-position-point)
6773 (gnus-set-mode-line 'summary)
6776 (defun gnus-summary-mark-article-as-read (mark)
6777 "Mark the current article quickly as read with MARK."
6778 (let ((article (gnus-summary-article-number)))
6779 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6780 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6781 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6782 (setq gnus-newsgroup-reads
6783 (cons (cons article mark) gnus-newsgroup-reads))
6784 ;; Possibly remove from cache, if that is used.
6785 (and gnus-use-cache (gnus-cache-enter-remove-article article))
6786 ;; Allow the backend to change the mark.
6787 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
6788 ;; Check for auto-expiry.
6789 (when (and gnus-newsgroup-auto-expire
6790 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6791 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6792 (= mark gnus-ancient-mark)
6793 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6794 (= mark gnus-duplicate-mark)))
6795 (setq mark gnus-expirable-mark)
6796 (push article gnus-newsgroup-expirable))
6797 ;; Set the mark in the buffer.
6798 (gnus-summary-update-mark mark 'unread)
6801 (defun gnus-summary-mark-article-as-unread (mark)
6802 "Mark the current article quickly as unread with MARK."
6803 (let ((article (gnus-summary-article-number)))
6805 (gnus-error 1 "Unmarkable article")
6806 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6807 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6808 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
6809 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
6810 (cond ((= mark gnus-ticked-mark)
6811 (push article gnus-newsgroup-marked))
6812 ((= mark gnus-dormant-mark)
6813 (push article gnus-newsgroup-dormant))
6815 (push article gnus-newsgroup-unreads)))
6816 (setq gnus-newsgroup-reads
6817 (delq (assq article gnus-newsgroup-reads)
6818 gnus-newsgroup-reads))
6820 ;; See whether the article is to be put in the cache.
6822 (vectorp (gnus-summary-article-header article))
6824 (gnus-cache-possibly-enter-article
6825 gnus-newsgroup-name article
6826 (gnus-summary-article-header article)
6827 (= mark gnus-ticked-mark)
6828 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6831 (gnus-summary-update-mark mark 'unread))
6834 (defun gnus-summary-mark-article (&optional article mark no-expire)
6835 "Mark ARTICLE with MARK. MARK can be any character.
6836 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
6837 `??' (dormant) and `?E' (expirable).
6838 If MARK is nil, then the default character `?D' is used.
6839 If ARTICLE is nil, then the article on the current line will be
6841 ;; The mark might be a string.
6843 (setq mark (aref mark 0)))
6844 ;; If no mark is given, then we check auto-expiring.
6845 (and (not no-expire)
6846 gnus-newsgroup-auto-expire
6849 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6850 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6851 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6852 (= mark gnus-duplicate-mark))))
6853 (setq mark gnus-expirable-mark))
6854 (let* ((mark (or mark gnus-del-mark))
6855 (article (or article (gnus-summary-article-number))))
6856 (or article (error "No article on current line"))
6857 (if (or (= mark gnus-unread-mark)
6858 (= mark gnus-ticked-mark)
6859 (= mark gnus-dormant-mark))
6860 (gnus-mark-article-as-unread article mark)
6861 (gnus-mark-article-as-read article mark))
6863 ;; See whether the article is to be put in the cache.
6865 (not (= mark gnus-canceled-mark))
6866 (vectorp (gnus-summary-article-header article))
6868 (gnus-cache-possibly-enter-article
6869 gnus-newsgroup-name article
6870 (gnus-summary-article-header article)
6871 (= mark gnus-ticked-mark)
6872 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6874 (if (gnus-summary-goto-subject article nil t)
6875 (let ((buffer-read-only nil))
6876 (gnus-summary-show-thread)
6878 (gnus-summary-update-mark mark 'unread)
6881 (defun gnus-summary-update-secondary-mark (article)
6882 "Update the secondary (read, process, cache) mark."
6883 (gnus-summary-update-mark
6884 (cond ((memq article gnus-newsgroup-processable)
6886 ((memq article gnus-newsgroup-cached)
6888 ((memq article gnus-newsgroup-replied)
6890 ((memq article gnus-newsgroup-saved)
6892 (t gnus-unread-mark))
6894 (when (gnus-visual-p 'summary-highlight 'highlight)
6895 (run-hooks 'gnus-summary-update-hook))
6898 (defun gnus-summary-update-mark (mark type)
6899 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
6900 (buffer-read-only nil))
6901 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
6902 (when (looking-at "\r")
6905 (<= (+ forward (point)) (point-max)))
6906 ;; Go to the right position on the line.
6907 (goto-char (+ forward (point)))
6908 ;; Replace the old mark with the new mark.
6909 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
6910 ;; Optionally update the marks by some user rule.
6911 (when (eq type 'unread)
6913 (gnus-data-find (gnus-summary-article-number)) mark)
6914 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
6916 (defun gnus-mark-article-as-read (article &optional mark)
6917 "Enter ARTICLE in the pertinent lists and remove it from others."
6918 ;; Make the article expirable.
6919 (let ((mark (or mark gnus-del-mark)))
6920 (if (= mark gnus-expirable-mark)
6921 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
6922 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
6923 ;; Remove from unread and marked lists.
6924 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6925 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6926 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6927 (push (cons article mark) gnus-newsgroup-reads)
6928 ;; Possibly remove from cache, if that is used.
6929 (when gnus-use-cache
6930 (gnus-cache-enter-remove-article article))))
6932 (defun gnus-mark-article-as-unread (article &optional mark)
6933 "Enter ARTICLE in the pertinent lists and remove it from others."
6934 (let ((mark (or mark gnus-ticked-mark)))
6935 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
6936 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
6937 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
6938 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6940 ;; Unsuppress duplicates?
6941 (when gnus-suppress-duplicates
6942 (gnus-dup-unsuppress-article article))
6944 (cond ((= mark gnus-ticked-mark)
6945 (push article gnus-newsgroup-marked))
6946 ((= mark gnus-dormant-mark)
6947 (push article gnus-newsgroup-dormant))
6949 (push article gnus-newsgroup-unreads)))
6950 (setq gnus-newsgroup-reads
6951 (delq (assq article gnus-newsgroup-reads)
6952 gnus-newsgroup-reads))))
6954 (defalias 'gnus-summary-mark-as-unread-forward
6955 'gnus-summary-tick-article-forward)
6956 (make-obsolete 'gnus-summary-mark-as-unread-forward
6957 'gnus-summary-tick-article-forward)
6958 (defun gnus-summary-tick-article-forward (n)
6959 "Tick N articles forwards.
6960 If N is negative, tick backwards instead.
6961 The difference between N and the number of articles ticked is returned."
6963 (gnus-summary-mark-forward n gnus-ticked-mark))
6965 (defalias 'gnus-summary-mark-as-unread-backward
6966 'gnus-summary-tick-article-backward)
6967 (make-obsolete 'gnus-summary-mark-as-unread-backward
6968 'gnus-summary-tick-article-backward)
6969 (defun gnus-summary-tick-article-backward (n)
6970 "Tick N articles backwards.
6971 The difference between N and the number of articles ticked is returned."
6973 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
6975 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6976 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6977 (defun gnus-summary-tick-article (&optional article clear-mark)
6978 "Mark current article as unread.
6979 Optional 1st argument ARTICLE specifies article number to be marked as unread.
6980 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
6982 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
6985 (defun gnus-summary-mark-as-read-forward (n)
6986 "Mark N articles as read forwards.
6987 If N is negative, mark backwards instead.
6988 The difference between N and the actual number of articles marked is
6991 (gnus-summary-mark-forward n gnus-del-mark t))
6993 (defun gnus-summary-mark-as-read-backward (n)
6994 "Mark the N articles as read backwards.
6995 The difference between N and the actual number of articles marked is
6998 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7000 (defun gnus-summary-mark-as-read (&optional article mark)
7001 "Mark current article as read.
7002 ARTICLE specifies the article to be marked as read.
7003 MARK specifies a string to be inserted at the beginning of the line."
7004 (gnus-summary-mark-article article mark))
7006 (defun gnus-summary-clear-mark-forward (n)
7007 "Clear marks from N articles forward.
7008 If N is negative, clear backward instead.
7009 The difference between N and the number of marks cleared is returned."
7011 (gnus-summary-mark-forward n gnus-unread-mark))
7013 (defun gnus-summary-clear-mark-backward (n)
7014 "Clear marks from N articles backward.
7015 The difference between N and the number of marks cleared is returned."
7017 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7019 (defun gnus-summary-mark-unread-as-read ()
7020 "Intended to be used by `gnus-summary-mark-article-hook'."
7021 (when (memq gnus-current-article gnus-newsgroup-unreads)
7022 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7024 (defun gnus-summary-mark-read-and-unread-as-read ()
7025 "Intended to be used by `gnus-summary-mark-article-hook'."
7026 (let ((mark (gnus-summary-article-mark)))
7027 (when (or (gnus-unread-mark-p mark)
7028 (gnus-read-mark-p mark))
7029 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7031 (defun gnus-summary-mark-region-as-read (point mark all)
7032 "Mark all unread articles between point and mark as read.
7033 If given a prefix, mark all articles between point and mark as read,
7034 even ticked and dormant ones."
7035 (interactive "r\nP")
7044 (memq (setq article (gnus-summary-article-number))
7045 gnus-newsgroup-unreads))
7046 (gnus-summary-mark-article article gnus-del-mark))
7048 (gnus-summary-find-next))))))
7050 (defun gnus-summary-mark-below (score mark)
7051 "Mark articles with score less than SCORE with MARK."
7052 (interactive "P\ncMark: ")
7053 (gnus-set-global-variables)
7054 (setq score (if score
7055 (prefix-numeric-value score)
7056 (or gnus-summary-default-score 0)))
7058 (set-buffer gnus-summary-buffer)
7059 (goto-char (point-min))
7062 (and (< (gnus-summary-article-score) score)
7063 (gnus-summary-mark-article nil mark))
7064 (gnus-summary-find-next)))))
7066 (defun gnus-summary-kill-below (&optional score)
7067 "Mark articles with score below SCORE as read."
7069 (gnus-set-global-variables)
7070 (gnus-summary-mark-below score gnus-killed-mark))
7072 (defun gnus-summary-clear-above (&optional score)
7073 "Clear all marks from articles with score above SCORE."
7075 (gnus-set-global-variables)
7076 (gnus-summary-mark-above score gnus-unread-mark))
7078 (defun gnus-summary-tick-above (&optional score)
7079 "Tick all articles with score above SCORE."
7081 (gnus-set-global-variables)
7082 (gnus-summary-mark-above score gnus-ticked-mark))
7084 (defun gnus-summary-mark-above (score mark)
7085 "Mark articles with score over SCORE with MARK."
7086 (interactive "P\ncMark: ")
7087 (gnus-set-global-variables)
7088 (setq score (if score
7089 (prefix-numeric-value score)
7090 (or gnus-summary-default-score 0)))
7092 (set-buffer gnus-summary-buffer)
7093 (goto-char (point-min))
7095 (if (> (gnus-summary-article-score) score)
7096 (gnus-summary-mark-article nil mark))
7098 (gnus-summary-find-next)))))
7100 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7101 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7102 (defun gnus-summary-limit-include-expunged (&optional no-error)
7103 "Display all the hidden articles that were expunged for low scores."
7105 (gnus-set-global-variables)
7106 (let ((buffer-read-only nil))
7107 (let ((scored gnus-newsgroup-scored)
7110 (or (gnus-summary-goto-subject (caar scored))
7111 (and (setq h (gnus-summary-article-header (caar scored)))
7112 (< (cdar scored) gnus-summary-expunge-below)
7113 (setq headers (cons h headers))))
7114 (setq scored (cdr scored)))
7116 (when (not no-error)
7117 (error "No expunged articles hidden."))
7118 (goto-char (point-min))
7119 (gnus-summary-prepare-unthreaded (nreverse headers))
7120 (goto-char (point-min))
7121 (gnus-summary-position-point)
7124 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7125 "Mark all articles not marked as unread in this newsgroup as read.
7126 If prefix argument ALL is non-nil, all articles are marked as read.
7127 If QUIETLY is non-nil, no questions will be asked.
7128 If TO-HERE is non-nil, it should be a point in the buffer. All
7129 articles before this point will be marked as read.
7130 The number of articles marked as read is returned."
7132 (gnus-set-global-variables)
7135 (not gnus-interactive-catchup) ;Without confirmation?
7139 "Mark absolutely all articles as read? "
7140 "Mark all unread articles as read? ")))
7142 (not gnus-newsgroup-adaptive)
7143 (not gnus-newsgroup-auto-expire)
7144 (not gnus-suppress-duplicates))
7147 (setq gnus-newsgroup-marked nil
7148 gnus-newsgroup-dormant nil))
7149 (setq gnus-newsgroup-unreads nil))
7150 ;; We actually mark all articles as canceled, which we
7151 ;; have to do when using auto-expiry or adaptive scoring.
7152 (gnus-summary-show-all-threads)
7153 (when (gnus-summary-first-subject (not all))
7155 (if to-here (< (point) to-here) t)
7156 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7157 (gnus-summary-find-next (not all)))))
7159 (setq gnus-newsgroup-unreads nil))
7160 (gnus-set-mode-line 'summary)))
7161 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
7162 (when (and (not to-here) (eq 'nnvirtual (car method)))
7163 (nnvirtual-catchup-group
7164 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
7165 (gnus-summary-position-point)))
7167 (defun gnus-summary-catchup-to-here (&optional all)
7168 "Mark all unticked articles before the current one as read.
7169 If ALL is non-nil, also mark ticked and dormant articles as read."
7171 (gnus-set-global-variables)
7173 (gnus-save-hidden-threads
7174 (let ((beg (point)))
7175 ;; We check that there are unread articles.
7176 (when (or all (gnus-summary-find-prev))
7177 (gnus-summary-catchup all t beg)))))
7178 (gnus-summary-position-point))
7180 (defun gnus-summary-catchup-all (&optional quietly)
7181 "Mark all articles in this newsgroup as read."
7183 (gnus-set-global-variables)
7184 (gnus-summary-catchup t quietly))
7186 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7187 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7188 If prefix argument ALL is non-nil, all articles are marked as read."
7190 (gnus-set-global-variables)
7191 (gnus-summary-catchup all quietly nil 'fast)
7192 ;; Select next newsgroup or exit.
7193 (if (eq gnus-auto-select-next 'quietly)
7194 (gnus-summary-next-group nil)
7195 (gnus-summary-exit)))
7197 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7198 "Mark all articles in this newsgroup as read, and then exit."
7200 (gnus-set-global-variables)
7201 (gnus-summary-catchup-and-exit t quietly))
7203 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7204 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7205 "Mark all articles in this group as read and select the next group.
7206 If given a prefix, mark all articles, unread as well as ticked, as
7209 (gnus-set-global-variables)
7211 (gnus-summary-catchup all))
7212 (gnus-summary-next-article t nil nil t))
7214 ;; Thread-based commands.
7216 (defun gnus-summary-articles-in-thread (&optional article)
7217 "Return a list of all articles in the current thread.
7218 If ARTICLE is non-nil, return all articles in the thread that starts
7220 (let* ((article (or article (gnus-summary-article-number)))
7221 (data (gnus-data-find-list article))
7222 (top-level (gnus-data-level (car data)))
7224 (cond ((null gnus-thread-operation-ignore-subject)
7225 (gnus-simplify-subject-re
7226 (mail-header-subject (gnus-data-header (car data)))))
7227 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7228 (gnus-simplify-subject-fuzzy
7229 (mail-header-subject (gnus-data-header (car data)))))
7231 (end-point (save-excursion
7232 (if (gnus-summary-go-to-next-thread)
7233 (point) (point-max))))
7236 (< (gnus-data-pos (car data)) end-point))
7237 (when (or (not top-subject)
7238 (string= top-subject
7239 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7240 (gnus-simplify-subject-fuzzy
7241 (mail-header-subject
7242 (gnus-data-header (car data))))
7243 (gnus-simplify-subject-re
7244 (mail-header-subject
7245 (gnus-data-header (car data)))))))
7246 (push (gnus-data-number (car data)) articles))
7247 (unless (and (setq data (cdr data))
7248 (> (gnus-data-level (car data)) top-level))
7250 ;; Return the list of articles.
7251 (nreverse articles)))
7253 (defun gnus-summary-rethread-current ()
7254 "Rethread the thread the current article is part of."
7256 (gnus-set-global-variables)
7257 (let* ((gnus-show-threads t)
7258 (article (gnus-summary-article-number))
7259 (id (mail-header-id (gnus-summary-article-header)))
7260 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7262 (error "No article on the current line"))
7263 (gnus-rebuild-thread id)
7264 (gnus-summary-goto-subject article)))
7266 (defun gnus-summary-reparent-thread ()
7267 "Make current article child of the marked (or previous) article.
7269 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7270 is non-nil or the Subject: of both articles are the same."
7272 (or (not (gnus-group-read-only-p))
7273 (error "The current newsgroup does not support article editing."))
7274 (or (<= (length gnus-newsgroup-processable) 1)
7275 (error "No more than one article may be marked."))
7276 (save-window-excursion
7277 (let ((gnus-article-buffer " *reparent*")
7278 (current-article (gnus-summary-article-number))
7279 ; first grab the marked article, otherwise one line up.
7280 (parent-article (if (not (null gnus-newsgroup-processable))
7281 (car gnus-newsgroup-processable)
7283 (if (eq (forward-line -1) 0)
7284 (gnus-summary-article-number)
7285 (error "Beginning of summary buffer."))))))
7286 (or (not (eq current-article parent-article))
7287 (error "An article may not be self-referential."))
7288 (let ((message-id (mail-header-id
7289 (gnus-summary-article-header parent-article))))
7290 (or (and message-id (not (equal message-id "")))
7291 (error "No message-id in desired parent."))
7292 (gnus-summary-select-article t t nil current-article)
7293 (set-buffer gnus-article-buffer)
7294 (setq buffer-read-only nil)
7295 (let ((buf (format "%s" (buffer-string))))
7298 (goto-char (point-min))
7299 (if (search-forward-regexp "^References: " nil t)
7300 (insert message-id " " )
7301 (insert "References: " message-id "\n"))
7302 (or (gnus-request-replace-article current-article
7303 (car gnus-article-current)
7304 gnus-article-buffer)
7305 (error "Couldn't replace article."))
7306 (set-buffer gnus-summary-buffer)
7307 (gnus-summary-unmark-all-processable)
7308 (gnus-summary-rethread-current)
7309 (gnus-message 3 "Article %d is now the child of article %d."
7310 current-article parent-article)))))
7312 (defun gnus-summary-toggle-threads (&optional arg)
7313 "Toggle showing conversation threads.
7314 If ARG is positive number, turn showing conversation threads on."
7316 (gnus-set-global-variables)
7317 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7318 (setq gnus-show-threads
7319 (if (null arg) (not gnus-show-threads)
7320 (> (prefix-numeric-value arg) 0)))
7321 (gnus-summary-prepare)
7322 (gnus-summary-goto-subject current)
7323 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7324 (gnus-summary-position-point)))
7326 (defun gnus-summary-show-all-threads ()
7329 (gnus-set-global-variables)
7331 (let ((buffer-read-only nil))
7332 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7333 (gnus-summary-position-point))
7335 (defun gnus-summary-show-thread ()
7336 "Show thread subtrees.
7337 Returns nil if no thread was there to be shown."
7339 (gnus-set-global-variables)
7340 (let ((buffer-read-only nil)
7342 ;; first goto end then to beg, to have point at beg after let
7343 (end (progn (end-of-line) (point)))
7344 (beg (progn (beginning-of-line) (point))))
7346 ;; Any hidden lines here?
7347 (search-forward "\r" end t)
7348 (subst-char-in-region beg end ?\^M ?\n t)
7350 (gnus-summary-position-point))))
7352 (defun gnus-summary-hide-all-threads ()
7353 "Hide all thread subtrees."
7355 (gnus-set-global-variables)
7357 (goto-char (point-min))
7358 (gnus-summary-hide-thread)
7359 (while (zerop (gnus-summary-next-thread 1 t))
7360 (gnus-summary-hide-thread)))
7361 (gnus-summary-position-point))
7363 (defun gnus-summary-hide-thread ()
7364 "Hide thread subtrees.
7365 Returns nil if no threads were there to be hidden."
7367 (gnus-set-global-variables)
7368 (let ((buffer-read-only nil)
7370 (article (gnus-summary-article-number)))
7372 ;; Go forward until either the buffer ends or the subthread
7374 (when (and (not (eobp))
7375 (or (zerop (gnus-summary-next-thread 1 t))
7376 (goto-char (point-max))))
7378 (if (and (> (point) start)
7379 (search-backward "\n" start t))
7381 (subst-char-in-region start (point) ?\n ?\^M)
7382 (gnus-summary-goto-subject article))
7385 ;;(gnus-summary-position-point)
7388 (defun gnus-summary-go-to-next-thread (&optional previous)
7389 "Go to the same level (or less) next thread.
7390 If PREVIOUS is non-nil, go to previous thread instead.
7391 Return the article number moved to, or nil if moving was impossible."
7392 (let ((level (gnus-summary-thread-level))
7393 (way (if previous -1 1))
7396 (while (and (not (eobp))
7397 (< level (gnus-summary-thread-level)))
7405 (gnus-summary-article-number)
7408 (defun gnus-summary-next-thread (n &optional silent)
7409 "Go to the same level next N'th thread.
7410 If N is negative, search backward instead.
7411 Returns the difference between N and the number of skips actually
7414 If SILENT, don't output messages."
7416 (gnus-set-global-variables)
7417 (let ((backward (< n 0))
7420 (gnus-summary-go-to-next-thread backward))
7423 (gnus-summary-position-point))
7424 (when (and (not silent) (/= 0 n))
7425 (gnus-message 7 "No more threads"))
7428 (defun gnus-summary-prev-thread (n)
7429 "Go to the same level previous N'th thread.
7430 Returns the difference between N and the number of skips actually
7433 (gnus-set-global-variables)
7434 (gnus-summary-next-thread (- n)))
7436 (defun gnus-summary-go-down-thread ()
7437 "Go down one level in the current thread."
7438 (let ((children (gnus-summary-article-children)))
7440 (gnus-summary-goto-subject (car children)))))
7442 (defun gnus-summary-go-up-thread ()
7443 "Go up one level in the current thread."
7444 (let ((parent (gnus-summary-article-parent)))
7446 (gnus-summary-goto-subject parent))))
7448 (defun gnus-summary-down-thread (n)
7449 "Go down thread N steps.
7450 If N is negative, go up instead.
7451 Returns the difference between N and how many steps down that were
7454 (gnus-set-global-variables)
7458 (if up (gnus-summary-go-up-thread)
7459 (gnus-summary-go-down-thread)))
7461 (gnus-summary-position-point)
7462 (if (/= 0 n) (gnus-message 7 "Can't go further"))
7465 (defun gnus-summary-up-thread (n)
7466 "Go up thread N steps.
7467 If N is negative, go up instead.
7468 Returns the difference between N and how many steps down that were
7471 (gnus-set-global-variables)
7472 (gnus-summary-down-thread (- n)))
7474 (defun gnus-summary-top-thread ()
7475 "Go to the top of the thread."
7477 (gnus-set-global-variables)
7478 (while (gnus-summary-go-up-thread))
7479 (gnus-summary-article-number))
7481 (defun gnus-summary-kill-thread (&optional unmark)
7482 "Mark articles under current thread as read.
7483 If the prefix argument is positive, remove any kinds of marks.
7484 If the prefix argument is negative, tick articles instead."
7486 (gnus-set-global-variables)
7488 (setq unmark (prefix-numeric-value unmark)))
7489 (let ((articles (gnus-summary-articles-in-thread)))
7491 ;; Expand the thread.
7492 (gnus-summary-show-thread)
7493 ;; Mark all the articles.
7495 (gnus-summary-goto-subject (car articles))
7496 (cond ((null unmark)
7497 (gnus-summary-mark-article-as-read gnus-killed-mark))
7499 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7501 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7502 (setq articles (cdr articles))))
7503 ;; Hide killed subtrees.
7505 gnus-thread-hide-killed
7506 (gnus-summary-hide-thread))
7507 ;; If marked as read, go to next unread subject.
7509 ;; Go to next unread subject.
7510 (gnus-summary-next-subject 1 t)))
7511 (gnus-set-mode-line 'summary))
7513 ;; Summary sorting commands
7515 (defun gnus-summary-sort-by-number (&optional reverse)
7516 "Sort summary buffer by article number.
7517 Argument REVERSE means reverse order."
7519 (gnus-summary-sort 'number reverse))
7521 (defun gnus-summary-sort-by-author (&optional reverse)
7522 "Sort summary buffer by author name alphabetically.
7523 If case-fold-search is non-nil, case of letters is ignored.
7524 Argument REVERSE means reverse order."
7526 (gnus-summary-sort 'author reverse))
7528 (defun gnus-summary-sort-by-subject (&optional reverse)
7529 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
7530 If case-fold-search is non-nil, case of letters is ignored.
7531 Argument REVERSE means reverse order."
7533 (gnus-summary-sort 'subject reverse))
7535 (defun gnus-summary-sort-by-date (&optional reverse)
7536 "Sort summary buffer by date.
7537 Argument REVERSE means reverse order."
7539 (gnus-summary-sort 'date reverse))
7541 (defun gnus-summary-sort-by-score (&optional reverse)
7542 "Sort summary buffer by score.
7543 Argument REVERSE means reverse order."
7545 (gnus-summary-sort 'score reverse))
7547 (defun gnus-summary-sort (predicate reverse)
7548 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7549 (gnus-set-global-variables)
7550 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7551 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7552 (gnus-thread-sort-functions
7558 (gnus-article-sort-functions
7563 (,article t2 t1)))))
7565 (gnus-summary-prepare-hook nil))
7566 ;; We do the sorting by regenerating the threads.
7567 (gnus-summary-prepare)
7568 ;; Hide subthreads if needed.
7569 (when (and gnus-show-threads gnus-thread-hide-subtree)
7570 (gnus-summary-hide-all-threads))))
7572 ;; Summary saving commands.
7574 (defun gnus-summary-save-article (&optional n not-saved)
7575 "Save the current article using the default saver function.
7576 If N is a positive number, save the N next articles.
7577 If N is a negative number, save the N previous articles.
7578 If N is nil and any articles have been marked with the process mark,
7579 save those articles instead.
7580 The variable `gnus-default-article-saver' specifies the saver function."
7582 (gnus-set-global-variables)
7583 (let* ((articles (gnus-summary-work-articles n))
7584 (save-buffer (save-excursion
7585 (nnheader-set-temp-buffer " *Gnus Save*")))
7586 (num (length articles))
7587 header article file)
7589 (setq header (gnus-summary-article-header
7590 (setq article (pop articles))))
7591 (if (not (vectorp header))
7592 ;; This is a pseudo-article.
7593 (if (assq 'name header)
7594 (gnus-copy-file (cdr (assq 'name header)))
7595 (gnus-message 1 "Article %d is unsaveable" article))
7596 ;; This is a real article.
7597 (save-window-excursion
7598 (gnus-summary-select-article t nil nil article))
7600 (set-buffer save-buffer)
7602 (insert-buffer-substring gnus-original-article-buffer))
7603 (setq file (gnus-article-save save-buffer file num))
7604 (gnus-summary-remove-process-mark article)
7606 (gnus-summary-set-saved-mark article))))
7607 (gnus-kill-buffer save-buffer)
7608 (gnus-summary-position-point)
7611 (defun gnus-summary-pipe-output (&optional arg)
7612 "Pipe the current article to a subprocess.
7613 If N is a positive number, pipe the N next articles.
7614 If N is a negative number, pipe the N previous articles.
7615 If N is nil and any articles have been marked with the process mark,
7616 pipe those articles instead."
7618 (gnus-set-global-variables)
7619 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
7620 (gnus-summary-save-article arg t))
7621 (gnus-configure-windows 'pipe))
7623 (defun gnus-summary-save-article-mail (&optional arg)
7624 "Append the current article to an mail file.
7625 If N is a positive number, save the N next articles.
7626 If N is a negative number, save the N previous articles.
7627 If N is nil and any articles have been marked with the process mark,
7628 save those articles instead."
7630 (gnus-set-global-variables)
7631 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
7632 (gnus-summary-save-article arg)))
7634 (defun gnus-summary-save-article-rmail (&optional arg)
7635 "Append the current article to an rmail file.
7636 If N is a positive number, save the N next articles.
7637 If N is a negative number, save the N previous articles.
7638 If N is nil and any articles have been marked with the process mark,
7639 save those articles instead."
7641 (gnus-set-global-variables)
7642 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
7643 (gnus-summary-save-article arg)))
7645 (defun gnus-summary-save-article-file (&optional arg)
7646 "Append the current article to a file.
7647 If N is a positive number, save the N next articles.
7648 If N is a negative number, save the N previous articles.
7649 If N is nil and any articles have been marked with the process mark,
7650 save those articles instead."
7652 (gnus-set-global-variables)
7653 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
7654 (gnus-summary-save-article arg)))
7656 (defun gnus-summary-save-article-body-file (&optional arg)
7657 "Append the current article body to a file.
7658 If N is a positive number, save the N next articles.
7659 If N is a negative number, save the N previous articles.
7660 If N is nil and any articles have been marked with the process mark,
7661 save those articles instead."
7663 (gnus-set-global-variables)
7664 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
7665 (gnus-summary-save-article arg)))
7667 (defun gnus-get-split-value (methods)
7668 "Return a value based on the split METHODS."
7669 (let (split-name method result match)
7672 (set-buffer gnus-original-article-buffer)
7674 (nnheader-narrow-to-headers)
7676 (goto-char (point-min))
7677 (setq method (pop methods))
7678 (setq match (car method))
7681 ;; Regular expression.
7683 (re-search-forward match nil t)
7685 ((gnus-functionp match)
7689 (setq result (funcall match gnus-newsgroup-name))))
7694 (setq result (eval match)))))
7695 (setq split-name (append (cdr method) split-name))
7696 (cond ((stringp result)
7697 (push result split-name))
7699 (setq split-name (append result split-name)))))))))
7702 (defun gnus-read-move-group-name (prompt default articles prefix)
7703 "Read a group name."
7704 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
7705 (minibuffer-confirm-incomplete nil) ; XEmacs
7713 (car (gnus-find-method-for-group
7715 gnus-valid-select-methods))
7716 (push (list (symbol-name g)) group-map)))
7717 gnus-active-hashtb))
7721 (if (> (length articles) 1)
7722 (format "these %d articles" (length articles))
7727 (gnus-completing-read default prom
7728 group-map nil nil prefix
7729 'gnus-group-history))
7730 ((= 1 (length split-name))
7731 (gnus-completing-read (car split-name) prom group-map
7733 'gnus-group-history))
7735 (gnus-completing-read nil prom
7736 (mapcar (lambda (el) (list el))
7737 (nreverse split-name))
7739 'gnus-group-history)))))
7741 (if (or (string= to-newsgroup "")
7742 (string= to-newsgroup prefix))
7743 (setq to-newsgroup (or default "")))
7744 (or (gnus-active to-newsgroup)
7745 (gnus-activate-group to-newsgroup)
7746 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
7748 (or (and (gnus-request-create-group
7749 to-newsgroup (gnus-group-name-to-method to-newsgroup))
7750 (gnus-activate-group to-newsgroup nil nil
7751 (gnus-group-name-to-method
7753 (error "Couldn't create group %s" to-newsgroup)))
7754 (error "No such group: %s" to-newsgroup)))
7757 ;; Summary extract commands
7759 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
7760 (let ((buffer-read-only nil)
7761 (article (gnus-summary-article-number))
7763 (or (gnus-summary-goto-subject article)
7764 (error (format "No such article: %d" article)))
7765 (gnus-summary-position-point)
7766 ;; If all commands are to be bunched up on one line, we collect
7768 (if gnus-view-pseudos-separately
7770 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
7773 (setq action (cdr (assq 'action (car ps))))
7774 (setq files (list (cdr (assq 'name (car ps)))))
7775 (while (and ps (cdr ps)
7776 (string= (or action "1")
7777 (or (cdr (assq 'action (cadr ps))) "2")))
7778 (setq files (cons (cdr (assq 'name (cadr ps))) files))
7779 (setcdr ps (cddr ps)))
7782 (if (not (string-match "%s" action))
7783 (setq files (cons " " files)))
7784 (setq files (cons " " files))
7785 (and (assq 'execute (car ps))
7786 (setcdr (assq 'execute (car ps))
7787 (funcall (if (string-match "%s" action)
7790 (mapconcat (lambda (f) f) files " ")))))
7791 (setq ps (cdr ps)))))
7792 (if (and gnus-view-pseudos (not not-view))
7794 (and (assq 'execute (car pslist))
7795 (gnus-execute-command (cdr (assq 'execute (car pslist)))
7796 (eq gnus-view-pseudos 'not-confirm)))
7797 (setq pslist (cdr pslist)))
7800 (setq after-article (or (cdr (assq 'article (car pslist)))
7801 (gnus-summary-article-number)))
7802 (gnus-summary-goto-subject after-article)
7805 (insert " " (file-name-nondirectory
7806 (cdr (assq 'name (car pslist))))
7807 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
7809 (forward-line -1) ; back to `b'
7810 (gnus-add-text-properties
7811 b (1- e) (list 'gnus-number gnus-reffed-article-number
7812 gnus-mouse-face-prop gnus-mouse-face))
7814 after-article gnus-reffed-article-number
7815 gnus-unread-mark b (car pslist) 0 (- e b))
7816 (push gnus-reffed-article-number gnus-newsgroup-unreads)
7817 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
7818 (setq pslist (cdr pslist)))))))
7820 (defun gnus-pseudos< (p1 p2)
7821 (let ((c1 (cdr (assq 'action p1)))
7822 (c2 (cdr (assq 'action p2))))
7823 (and c1 c2 (string< c1 c2))))
7825 (defun gnus-request-pseudo-article (props)
7826 (cond ((assq 'execute props)
7827 (gnus-execute-command (cdr (assq 'execute props)))))
7828 (let ((gnus-current-article (gnus-summary-article-number)))
7829 (run-hooks 'gnus-mark-article-hook)))
7831 (defun gnus-execute-command (command &optional automatic)
7833 (gnus-article-setup-buffer)
7834 (set-buffer gnus-article-buffer)
7835 (setq buffer-read-only nil)
7836 (let ((command (if automatic command (read-string "Command: " command)))
7837 ;; Just binding this here doesn't help, because there might
7838 ;; be output from the process after exiting the scope of
7840 ;; (buffer-read-only nil)
7843 (insert "$ " command "\n\n")
7844 (if gnus-view-pseudo-asynchronously
7845 (start-process "gnus-execute" nil shell-file-name
7846 shell-command-switch command)
7847 (call-process shell-file-name nil t nil
7848 shell-command-switch command)))))
7850 ;; Summary kill commands.
7852 (defun gnus-summary-edit-global-kill (article)
7853 "Edit the \"global\" kill file."
7854 (interactive (list (gnus-summary-article-number)))
7855 (gnus-set-global-variables)
7856 (gnus-group-edit-global-kill article))
7858 (defun gnus-summary-edit-local-kill ()
7859 "Edit a local kill file applied to the current newsgroup."
7861 (gnus-set-global-variables)
7862 (setq gnus-current-headers (gnus-summary-article-header))
7863 (gnus-set-global-variables)
7864 (gnus-group-edit-local-kill
7865 (gnus-summary-article-number) gnus-newsgroup-name))
7869 (defun gnus-read-header (id &optional header)
7870 "Read the headers of article ID and enter them into the Gnus system."
7871 (let ((group gnus-newsgroup-name)
7872 (gnus-override-method
7873 (and (gnus-news-group-p gnus-newsgroup-name)
7874 gnus-refer-article-method))
7876 ;; First we check to see whether the header in question is already
7879 ;; This is a Message-ID.
7880 (setq header (or header (gnus-id-to-header id)))
7881 ;; This is an article number.
7882 (setq header (or header (gnus-summary-article-header id))))
7884 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
7885 ;; We have found the header.
7887 ;; We have to really fetch the header to this article.
7888 (when (setq where (gnus-request-head id group))
7890 (set-buffer nntp-server-buffer)
7891 (goto-char (point-max))
7893 (goto-char (point-min))
7897 ((cdr where) (cdr where))
7898 (header (mail-header-number header))
7899 (t gnus-reffed-article-number))
7901 (insert " Article retrieved.\n"))
7902 (if (not (setq header (car (gnus-get-newsgroup-headers))))
7903 () ; Malformed head.
7904 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
7905 (if (and (stringp id)
7906 (not (string= (gnus-group-real-name group)
7908 ;; If we fetched by Message-ID and the article came
7909 ;; from a different group, we fudge some bogus article
7910 ;; numbers for this article.
7911 (mail-header-set-number header gnus-reffed-article-number))
7912 (decf gnus-reffed-article-number)
7913 (gnus-remove-header (mail-header-number header))
7914 (push header gnus-newsgroup-headers)
7915 (setq gnus-current-headers header)
7916 (push (mail-header-number header) gnus-newsgroup-limit))
7919 (defun gnus-remove-header (number)
7920 "Remove header NUMBER from `gnus-newsgroup-headers'."
7921 (if (and gnus-newsgroup-headers
7922 (= number (mail-header-number (car gnus-newsgroup-headers))))
7923 (pop gnus-newsgroup-headers)
7924 (let ((headers gnus-newsgroup-headers))
7925 (while (and (cdr headers)
7926 (not (= number (mail-header-number (cadr headers)))))
7929 (setcdr headers (cddr headers))))))
7932 ;;; summary highlights
7935 (defun gnus-highlight-selected-summary ()
7936 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7937 ;; Highlight selected article in summary buffer
7938 (when gnus-summary-selected-face
7940 (let* ((beg (progn (beginning-of-line) (point)))
7941 (end (progn (end-of-line) (point)))
7942 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
7943 (from (if (get-text-property beg gnus-mouse-face-prop)
7945 (or (next-single-property-change
7946 beg gnus-mouse-face-prop nil end)
7951 (or (next-single-property-change
7952 from gnus-mouse-face-prop nil end)
7954 ;; If no mouse-face prop on line we will have to = from = end,
7955 ;; so we highlight the entire line instead.
7956 (when (= (+ to 2) from)
7959 (if gnus-newsgroup-selected-overlay
7960 ;; Move old overlay.
7962 gnus-newsgroup-selected-overlay from to (current-buffer))
7963 ;; Create new overlay.
7965 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
7966 'face gnus-summary-selected-face))))))
7968 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
7969 (defun gnus-summary-highlight-line ()
7970 "Highlight current line according to `gnus-summary-highlight'."
7971 (let* ((list gnus-summary-highlight)
7973 (end (progn (end-of-line) (point)))
7974 ;; now find out where the line starts and leave point there.
7975 (beg (progn (beginning-of-line) (point)))
7976 (article (gnus-summary-article-number))
7977 (score (or (cdr (assq (or article gnus-current-article)
7978 gnus-newsgroup-scored))
7979 gnus-summary-default-score 0))
7980 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
7981 (inhibit-read-only t))
7982 ;; Eval the cars of the lists until we find a match.
7983 (let ((default gnus-summary-default-score))
7985 (not (eval (caar list))))
7986 (setq list (cdr list))))
7987 (let ((face (cdar list)))
7988 (unless (eq face (get-text-property beg 'face))
7989 (gnus-put-text-property
7991 (setq face (if (boundp face) (symbol-value face) face)))
7992 (when gnus-summary-highlight-line-function
7993 (funcall gnus-summary-highlight-line-function article face))))
7996 (defun gnus-update-read-articles (group unread)
7997 "Update the list of read articles in GROUP."
7998 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
7999 (entry (gnus-gethash group gnus-newsrc-hashtb))
8000 (info (nth 2 entry))
8002 (unread (sort (copy-sequence unread) '<))
8004 (if (or (not info) (not active))
8005 ;; There is no info on this group if it was, in fact,
8006 ;; killed. Gnus stores no information on killed groups, so
8007 ;; there's nothing to be done.
8008 ;; One could store the information somewhere temporarily,
8009 ;; perhaps... Hmmm...
8011 ;; Remove any negative articles numbers.
8012 (while (and unread (< (car unread) 0))
8013 (setq unread (cdr unread)))
8014 ;; Remove any expired article numbers
8015 (while (and unread (< (car unread) (car active)))
8016 (setq unread (cdr unread)))
8017 ;; Compute the ranges of read articles by looking at the list of
8020 (if (/= (car unread) prev)
8021 (setq read (cons (if (= prev (1- (car unread))) prev
8022 (cons prev (1- (car unread)))) read)))
8023 (setq prev (1+ (car unread)))
8024 (setq unread (cdr unread)))
8025 (when (<= prev (cdr active))
8026 (setq read (cons (cons prev (cdr active)) read)))
8029 (gnus-info-set-marks ,info ,(gnus-info-marks info))
8030 (gnus-info-set-read ,info ,(gnus-info-read info))
8031 (gnus-get-unread-articles-in-group ,info (gnus-active ,group))))
8032 ;; Enter this list into the group info.
8034 info (if (> (length read) 1) (nreverse read) read))
8035 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8036 (gnus-get-unread-articles-in-group info (gnus-active group))
8041 ;;; gnus-sum.el ends here