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.
37 (defvar gnus-kill-summary-on-exit t
38 "*If non-nil, kill the summary buffer when you exit from it.
39 If nil, the summary will become a \"*Dead Summary*\" buffer, and
40 it will be killed sometime later.")
42 (defvar gnus-fetch-old-headers nil
43 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
44 If an unread article in the group refers to an older, already read (or
45 just marked as read) article, the old article will not normally be
46 displayed in the Summary buffer. If this variable is non-nil, Gnus
47 will attempt to grab the headers to the old articles, and thereby
48 build complete threads. If it has the value `some', only enough
49 headers to connect otherwise loose threads will be displayed.
50 This variable can also be a number. In that case, no more than that
51 number of old headers will be fetched.
53 The server has to support NOV for any of this to work.")
55 (defvar gnus-summary-make-false-root 'adopt
56 "*nil means that Gnus won't gather loose threads.
57 If the root of a thread has expired or been read in a previous
58 session, the information necessary to build a complete thread has been
59 lost. Instead of having many small sub-threads from this original thread
60 scattered all over the summary buffer, Gnus can gather them.
62 If non-nil, Gnus will try to gather all loose sub-threads from an
63 original thread into one large thread.
65 If this variable is non-nil, it should be one of `none', `adopt',
68 If this variable is `none', Gnus will not make a false root, but just
69 present the sub-threads after another.
70 If this variable is `dummy', Gnus will create a dummy root that will
71 have all the sub-threads as children.
72 If this variable is `adopt', Gnus will make one of the \"children\"
73 the parent and mark all the step-children as such.
74 If this variable is `empty', the \"children\" are printed with empty
75 subject fields. (Or rather, they will be printed with a string
76 given by the `gnus-summary-same-subject' variable.)")
78 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
79 "*A regexp to match subjects to be excluded from loose thread gathering.
80 As loose thread gathering is done on subjects only, that means that
81 there can be many false gatherings performed. By rooting out certain
82 common subjects, gathering might become saner.")
84 (defvar gnus-summary-gather-subject-limit nil
85 "*Maximum length of subject comparisons when gathering loose threads.
86 Use nil to compare full subjects. Setting this variable to a low
87 number will help gather threads that have been corrupted by
88 newsreaders chopping off subject lines, but it might also mean that
89 unrelated articles that have subject that happen to begin with the
90 same few characters will be incorrectly gathered.
92 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
95 (defvar gnus-simplify-ignored-prefixes nil
96 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.")
98 (defvar gnus-build-sparse-threads nil
99 "*If non-nil, fill in the gaps in threads.
100 If `some', only fill in the gaps that are needed to tie loose threads
101 together. If `more', fill in all leaf nodes that Gnus can find. If
102 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
104 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
105 "Function used for gathering loose threads.
106 There are two pre-defined functions: `gnus-gather-threads-by-subject',
107 which only takes Subjects into consideration; and
108 `gnus-gather-threads-by-references', which compared the References
109 headers of the articles to find matches.")
111 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
112 (defvar gnus-summary-same-subject ""
113 "*String indicating that the current article has the same subject as the previous.
114 This variable will only be used if the value of
115 `gnus-summary-make-false-root' is `empty'.")
117 (defvar gnus-summary-goto-unread t
118 "*If non-nil, marking commands will go to the next unread article.
119 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
120 whether it is read or not.")
122 (defvar gnus-summary-default-score 0
123 "*Default article score level.
124 If this variable is nil, scoring will be disabled.")
126 (defvar gnus-summary-zcore-fuzz 0
127 "*Fuzziness factor for the zcore in the summary buffer.
128 Articles with scores closer than this to `gnus-summary-default-score'
129 will not be marked.")
131 (defvar gnus-simplify-subject-fuzzy-regexp nil
132 "*Strings to be removed when doing fuzzy matches.
133 This can either be a regular expression or list of regular expressions
134 that will be removed from subject strings if fuzzy subject
135 simplification is selected.")
137 (defvar gnus-show-threads t
138 "*If non-nil, display threads in summary mode.")
140 (defvar gnus-thread-hide-subtree nil
141 "*If non-nil, hide all threads initially.
142 If threads are hidden, you have to run the command
143 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
144 to expose hidden threads.")
146 (defvar gnus-thread-hide-killed t
147 "*If non-nil, hide killed threads automatically.")
149 (defvar gnus-thread-ignore-subject nil
150 "*If non-nil, ignore subjects and do all threading based on the Reference header.
151 If nil, which is the default, articles that have different subjects
152 from their parents will start separate threads.")
154 (defvar gnus-thread-operation-ignore-subject t
155 "*If non-nil, subjects will be ignored when doing thread commands.
156 This affects commands like `gnus-summary-kill-thread' and
157 `gnus-summary-lower-thread'.
159 If this variable is nil, articles in the same thread with different
160 subjects will not be included in the operation in question. If this
161 variable is `fuzzy', only articles that have subjects that are fuzzily
162 equal will be included.")
164 (defvar gnus-thread-indent-level 4
165 "*Number that says how much each sub-thread should be indented.")
167 (defvar gnus-auto-extend-newsgroup t
168 "*If non-nil, extend newsgroup forward and backward when requested.")
170 (defvar gnus-auto-select-first t
171 "*If nil, don't select the first unread article when entering a group.
172 If this variable is `best', select the highest-scored unread article
173 in the group. If neither nil nor `best', select the first unread
176 If you want to prevent automatic selection of the first unread article
177 in some newsgroups, set the variable to nil in
178 `gnus-select-group-hook'.")
180 (defvar gnus-auto-select-next t
181 "*If non-nil, offer to go to the next group from the end of the previous.
182 If the value is t and the next newsgroup is empty, Gnus will exit
183 summary mode and go back to group mode. If the value is neither nil
184 nor t, Gnus will select the following unread newsgroup. In
185 particular, if the value is the symbol `quietly', the next unread
186 newsgroup will be selected without any confirmation, and if it is
187 `almost-quietly', the next group will be selected without any
188 confirmation if you are located on the last article in the group.
189 Finally, if this variable is `slightly-quietly', the `Z n' command
190 will go to the next group without confirmation.")
192 (defvar gnus-auto-select-same nil
193 "*If non-nil, select the next article with the same subject.")
195 (defvar gnus-summary-check-current nil
196 "*If non-nil, consider the current article when moving.
197 The \"unread\" movement commands will stay on the same line if the
198 current article is unread.")
200 (defvar gnus-auto-center-summary t
201 "*If non-nil, always center the current summary buffer.
202 In particular, if `vertical' do only vertical recentering. If non-nil
203 and non-`vertical', do both horizontal and vertical recentering.")
205 (defvar gnus-show-all-headers nil
206 "*If non-nil, don't hide any headers.")
208 (defvar gnus-single-article-buffer t
209 "*If non-nil, display all articles in the same buffer.
210 If nil, each group will get its own article buffer.")
212 (defvar gnus-break-pages t
213 "*If non-nil, do page breaking on articles.
214 The page delimiter is specified by the `gnus-page-delimiter'
217 (defvar gnus-show-mime nil
218 "*If non-nil, do mime processing of articles.
219 The articles will simply be fed to the function given by
220 `gnus-show-mime-method'.")
222 (defvar gnus-move-split-methods nil
223 "*Variable used to suggest where articles are to be moved to.
224 It uses the same syntax as the `gnus-split-methods' variable.")
226 ;; Mark variables suggested by Thomas Michanek
227 ;; <Thomas.Michanek@telelogic.se>.
228 (defvar gnus-unread-mark ?
229 "*Mark used for unread articles.")
230 (defvar gnus-ticked-mark ?!
231 "*Mark used for ticked articles.")
232 (defvar gnus-dormant-mark ??
233 "*Mark used for dormant articles.")
234 (defvar gnus-del-mark ?r
235 "*Mark used for del'd articles.")
236 (defvar gnus-read-mark ?R
237 "*Mark used for read articles.")
238 (defvar gnus-expirable-mark ?E
239 "*Mark used for expirable articles.")
240 (defvar gnus-killed-mark ?K
241 "*Mark used for killed articles.")
242 (defvar gnus-souped-mark ?F
243 "*Mark used for killed articles.")
244 (defvar gnus-kill-file-mark ?X
245 "*Mark used for articles killed by kill files.")
246 (defvar gnus-low-score-mark ?Y
247 "*Mark used for articles with a low score.")
248 (defvar gnus-catchup-mark ?C
249 "*Mark used for articles that are caught up.")
250 (defvar gnus-replied-mark ?A
251 "*Mark used for articles that have been replied to.")
252 (defvar gnus-cached-mark ?*
253 "*Mark used for articles that are in the cache.")
254 (defvar gnus-saved-mark ?S
255 "*Mark used for articles that have been saved to.")
256 (defvar gnus-ancient-mark ?O
257 "*Mark used for ancient articles.")
258 (defvar gnus-sparse-mark ?Q
259 "*Mark used for sparsely reffed articles.")
260 (defvar gnus-canceled-mark ?G
261 "*Mark used for canceled articles.")
262 (defvar gnus-duplicate-mark ?M
263 "*Mark used for duplicate articles.")
264 (defvar gnus-score-over-mark ?+
265 "*Score mark used for articles with high scores.")
266 (defvar gnus-score-below-mark ?-
267 "*Score mark used for articles with low scores.")
268 (defvar gnus-empty-thread-mark ?
269 "*There is no thread under the article.")
270 (defvar gnus-not-empty-thread-mark ?=
271 "*There is a thread under the article.")
273 (defvar gnus-view-pseudo-asynchronously nil
274 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
276 (defvar gnus-view-pseudos nil
277 "*If `automatic', pseudo-articles will be viewed automatically.
278 If `not-confirm', pseudos will be viewed automatically, and the user
279 will not be asked to confirm the command.")
281 (defvar gnus-view-pseudos-separately t
282 "*If non-nil, one pseudo-article will be created for each file to be viewed.
283 If nil, all files that use the same viewing command will be given as a
284 list of parameters to that command.")
286 (defvar gnus-insert-pseudo-articles t
287 "*If non-nil, insert pseudo-articles when decoding articles.")
289 (defvar gnus-summary-dummy-line-format
291 "*The format specification for the dummy roots in the summary buffer.
292 It works along the same lines as a normal formatting string,
293 with some simple extensions.
297 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
298 "*The format specification for the summary mode line.
299 It works along the same lines as a normal formatting string,
300 with some simple extensions:
303 %p Unprefixed group name
304 %A Current article number
306 %U Number of unread articles in the group
307 %e Number of unselected articles in the group
308 %Z A string with unread/unselected article counts
309 %g Shortish group name
310 %S Subject of the current article
312 %s Current score file name
313 %d Number of dormant articles
314 %r Number of articles that have been marked as read in this session
315 %E Number of articles expunged by the score files")
317 (defvar gnus-summary-mark-below 0
318 "*Mark all articles with a score below this variable as read.
319 This variable is local to each summary buffer and usually set by the
322 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
323 "*List of functions used for sorting articles in the summary buffer.
324 This variable is only used when not using a threaded display.")
326 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
327 "*List of functions used for sorting threads in the summary buffer.
328 By default, threads are sorted by article number.
330 Each function takes two threads and return non-nil if the first thread
331 should be sorted before the other. If you use more than one function,
332 the primary sort function should be the last. You should probably
333 always include `gnus-thread-sort-by-number' in the list of sorting
334 functions -- preferably first.
336 Ready-mady functions include `gnus-thread-sort-by-number',
337 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
338 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
339 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
341 (defvar gnus-thread-score-function '+
342 "*Function used for calculating the total score of a thread.
344 The function is called with the scores of the article and each
345 subthread and should then return the score of the thread.
347 Some functions you can use are `+', `max', or `min'.")
349 (defvar gnus-summary-expunge-below nil
350 "All articles that have a score less than this variable will be expunged.")
352 (defvar gnus-thread-expunge-below nil
353 "All threads that have a total score less than this variable will be expunged.
354 See `gnus-thread-score-function' for en explanation of what a
355 \"thread score\" is.")
357 (defvar gnus-summary-mode-hook nil
358 "*A hook for Gnus summary mode.
359 This hook is run before any variables are set in the summary buffer.")
361 (defvar gnus-summary-menu-hook nil
362 "*Hook run after the creation of the summary mode menu.")
364 (defvar gnus-summary-exit-hook nil
365 "*A hook called on exit from the summary buffer.")
367 (defvar gnus-summary-prepare-hook nil
368 "*A hook called after the summary buffer has been generated.
369 If you want to modify the summary buffer, you can use this hook.")
371 (defvar gnus-summary-generate-hook nil
372 "*A hook run just before generating the summary buffer.
373 This hook is commonly used to customize threading variables and the
376 (defvar gnus-select-group-hook nil
377 "*A hook called when a newsgroup is selected.
379 If you'd like to simplify subjects like the
380 `gnus-summary-next-same-subject' command does, you can use the
383 (setq gnus-select-group-hook
386 (mapcar (lambda (header)
387 (mail-header-set-subject
389 (gnus-simplify-subject
390 (mail-header-subject header) 're-only)))
391 gnus-newsgroup-headers))))")
393 (defvar gnus-select-article-hook nil
394 "*A hook called when an article is selected.")
396 (defvar gnus-visual-mark-article-hook
397 (list 'gnus-highlight-selected-summary)
398 "*Hook run after selecting an article in the summary buffer.
399 It is meant to be used for highlighting the article in some way. It
400 is not run if `gnus-visual' is nil.")
402 (defvar gnus-parse-headers-hook nil
403 "*A hook called before parsing the headers.")
404 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
406 (defvar gnus-exit-group-hook nil
407 "*A hook called when exiting (not quitting) summary mode.")
409 (defvar gnus-summary-update-hook
410 (list 'gnus-summary-highlight-line)
411 "*A hook called when a summary line is changed.
412 The hook will not be called if `gnus-visual' is nil.
414 The default function `gnus-summary-highlight-line' will
415 highlight the line according to the `gnus-summary-highlight'
418 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
419 "*A hook called when an article is selected for the first time.
420 The hook is intended to mark an article as read (or unread)
421 automatically when it is selected.")
423 (defvar gnus-summary-display-table
424 ;; Change the display table. Odd characters have a tendency to mess
425 ;; up nicely formatted displays - we make all possible glyphs
426 ;; display only a single character.
428 ;; We start from the standard display table, if any.
429 (let ((table (or (copy-sequence standard-display-table)
430 (make-display-table)))
431 ;; Nix out all the control chars...
433 (while (>= (setq i (1- i)) 0)
435 ;; ... but not newline and cr, of course. (cr is necessary for the
436 ;; selective display).
439 ;; We nix out any glyphs over 126 that are not set already.
441 (while (>= (setq i (1- i)) 127)
442 ;; Only modify if the entry is nil.
444 (aset table i [??]))))
446 "Display table used in summary mode buffers.")
448 ;;; Internal variables
450 (defvar gnus-original-article nil)
451 (defvar gnus-article-internal-prepare-hook nil)
452 (defvar gnus-newsgroup-process-stack nil)
454 (defvar gnus-thread-indent-array nil)
455 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
457 ;; Avoid highlighting in kill files.
458 (defvar gnus-summary-inhibit-highlight nil)
459 (defvar gnus-newsgroup-selected-overlay nil)
460 (defvar gnus-inhibit-limiting nil)
461 (defvar gnus-newsgroup-adaptive-score-file nil)
462 (defvar gnus-current-score-file nil)
463 (defvar gnus-current-move-group nil)
464 (defvar gnus-current-copy-group nil)
465 (defvar gnus-current-crosspost-group nil)
467 (defvar gnus-newsgroup-dependencies nil)
468 (defvar gnus-newsgroup-adaptive nil)
469 (defvar gnus-summary-display-article-function nil)
470 (defvar gnus-summary-highlight-line-function nil
471 "Function called after highlighting a summary line.")
473 (defvar gnus-summary-line-format-alist
474 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
475 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
476 (?s gnus-tmp-subject-or-nil ?s)
477 (?n gnus-tmp-name ?s)
478 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
480 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
482 (?F gnus-tmp-from ?s)
483 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
484 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
485 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
486 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
487 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
488 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
489 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
490 (?L gnus-tmp-lines ?d)
491 (?I gnus-tmp-indentation ?s)
492 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
493 (?R gnus-tmp-replied ?c)
494 (?\[ gnus-tmp-opening-bracket ?c)
495 (?\] gnus-tmp-closing-bracket ?c)
496 (?\> (make-string gnus-tmp-level ? ) ?s)
497 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
498 (?i gnus-tmp-score ?d)
499 (?z gnus-tmp-score-char ?c)
500 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
501 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
502 (?U gnus-tmp-unread ?c)
503 (?t (gnus-summary-number-of-articles-in-thread
504 (and (boundp 'thread) (car thread)) gnus-tmp-level)
506 (?e (gnus-summary-number-of-articles-in-thread
507 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
509 (?u gnus-tmp-user-defined ?s)
510 (?P (gnus-pick-line-number) ?d))
511 "An alist of format specifications that can appear in summary lines,
512 and what variables they correspond with, along with the type of the
513 variable (string, integer, character, etc).")
515 (defvar gnus-summary-dummy-line-format-alist
516 `((?S gnus-tmp-subject ?s)
517 (?N gnus-tmp-number ?d)
518 (?u gnus-tmp-user-defined ?s)))
520 (defvar gnus-summary-mode-line-format-alist
521 `((?G gnus-tmp-group-name ?s)
522 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
523 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
524 (?A gnus-tmp-article-number ?d)
525 (?Z gnus-tmp-unread-and-unselected ?s)
527 (?U gnus-tmp-unread-and-unticked ?d)
528 (?S gnus-tmp-subject ?s)
529 (?e gnus-tmp-unselected ?d)
530 (?u gnus-tmp-user-defined ?s)
531 (?d (length gnus-newsgroup-dormant) ?d)
532 (?t (length gnus-newsgroup-marked) ?d)
533 (?r (length gnus-newsgroup-reads) ?d)
534 (?E gnus-newsgroup-expunged-tally ?d)
535 (?s (gnus-current-score-file-nondirectory) ?s)))
537 (defvar gnus-last-search-regexp nil
538 "Default regexp for article search command.")
540 (defvar gnus-last-shell-command nil
541 "Default shell command on article.")
543 (defvar gnus-newsgroup-begin nil)
544 (defvar gnus-newsgroup-end nil)
545 (defvar gnus-newsgroup-last-rmail nil)
546 (defvar gnus-newsgroup-last-mail nil)
547 (defvar gnus-newsgroup-last-folder nil)
548 (defvar gnus-newsgroup-last-file nil)
549 (defvar gnus-newsgroup-auto-expire nil)
550 (defvar gnus-newsgroup-active nil)
552 (defvar gnus-newsgroup-data nil)
553 (defvar gnus-newsgroup-data-reverse nil)
554 (defvar gnus-newsgroup-limit nil)
555 (defvar gnus-newsgroup-limits nil)
557 (defvar gnus-newsgroup-unreads nil
558 "List of unread articles in the current newsgroup.")
560 (defvar gnus-newsgroup-unselected nil
561 "List of unselected unread articles in the current newsgroup.")
563 (defvar gnus-newsgroup-reads nil
564 "Alist of read articles and article marks in the current newsgroup.")
566 (defvar gnus-newsgroup-expunged-tally nil)
568 (defvar gnus-newsgroup-marked nil
569 "List of ticked articles in the current newsgroup (a subset of unread art).")
571 (defvar gnus-newsgroup-killed nil
572 "List of ranges of articles that have been through the scoring process.")
574 (defvar gnus-newsgroup-cached nil
575 "List of articles that come from the article cache.")
577 (defvar gnus-newsgroup-saved nil
578 "List of articles that have been saved.")
580 (defvar gnus-newsgroup-kill-headers nil)
582 (defvar gnus-newsgroup-replied nil
583 "List of articles that have been replied to in the current newsgroup.")
585 (defvar gnus-newsgroup-expirable nil
586 "List of articles in the current newsgroup that can be expired.")
588 (defvar gnus-newsgroup-processable nil
589 "List of articles in the current newsgroup that can be processed.")
591 (defvar gnus-newsgroup-bookmarks nil
592 "List of articles in the current newsgroup that have bookmarks.")
594 (defvar gnus-newsgroup-dormant nil
595 "List of dormant articles in the current newsgroup.")
597 (defvar gnus-newsgroup-scored nil
598 "List of scored articles in the current newsgroup.")
600 (defvar gnus-newsgroup-headers nil
601 "List of article headers in the current newsgroup.")
603 (defvar gnus-newsgroup-threads nil)
605 (defvar gnus-newsgroup-prepared nil
606 "Whether the current group has been prepared properly.")
608 (defvar gnus-newsgroup-ancient nil
609 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
611 (defvar gnus-newsgroup-sparse nil)
613 (defvar gnus-current-article nil)
614 (defvar gnus-article-current nil)
615 (defvar gnus-current-headers nil)
616 (defvar gnus-have-all-headers nil)
617 (defvar gnus-last-article nil)
618 (defvar gnus-newsgroup-history nil)
620 (defconst gnus-summary-local-variables
621 '(gnus-newsgroup-name
622 gnus-newsgroup-begin gnus-newsgroup-end
623 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
624 gnus-newsgroup-last-folder gnus-newsgroup-last-file
625 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
626 gnus-newsgroup-unselected gnus-newsgroup-marked
627 gnus-newsgroup-reads gnus-newsgroup-saved
628 gnus-newsgroup-replied gnus-newsgroup-expirable
629 gnus-newsgroup-processable gnus-newsgroup-killed
630 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
631 gnus-newsgroup-headers gnus-newsgroup-threads
632 gnus-newsgroup-prepared gnus-summary-highlight-line-function
633 gnus-current-article gnus-current-headers gnus-have-all-headers
634 gnus-last-article gnus-article-internal-prepare-hook
635 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
636 gnus-newsgroup-scored gnus-newsgroup-kill-headers
637 gnus-thread-expunge-below
638 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
639 (gnus-summary-mark-below . global)
640 gnus-newsgroup-active gnus-scores-exclude-files
641 gnus-newsgroup-history gnus-newsgroup-ancient
642 gnus-newsgroup-sparse gnus-newsgroup-process-stack
643 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
644 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
645 (gnus-newsgroup-expunged-tally . 0)
646 gnus-cache-removable-articles gnus-newsgroup-cached
647 gnus-newsgroup-data gnus-newsgroup-data-reverse
648 gnus-newsgroup-limit gnus-newsgroup-limits)
649 "Variables that are buffer-local to the summary buffers.")
651 ;; Byte-compiler warning.
652 (defvar gnus-article-mode-map)
654 ;; Subject simplification.
656 (defsubst gnus-simplify-subject-re (subject)
657 "Remove \"Re:\" from subject lines."
658 (if (string-match "^[Rr][Ee]: *" subject)
659 (substring subject (match-end 0))
662 (defun gnus-simplify-subject (subject &optional re-only)
663 "Remove `Re:' and words in parentheses.
664 If RE-ONLY is non-nil, strip leading `Re:'s only."
665 (let ((case-fold-search t)) ;Ignore case.
666 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
667 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
668 (setq subject (substring subject (match-end 0))))
669 ;; Remove uninteresting prefixes.
670 (if (and (not re-only)
671 gnus-simplify-ignored-prefixes
672 (string-match gnus-simplify-ignored-prefixes subject))
673 (setq subject (substring subject (match-end 0))))
674 ;; Remove words in parentheses from end.
676 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
677 (setq subject (substring subject 0 (match-beginning 0)))))
678 ;; Return subject string.
681 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
683 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
684 (defun gnus-simplify-buffer-fuzzy ()
685 (let ((case-fold-search t))
686 (goto-char (point-min))
687 (while (search-forward "\t" nil t)
688 (replace-match " " t t))
689 (goto-char (point-min))
690 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
691 (goto-char (match-beginning 0))
693 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
694 (looking-at "^[[].*: .*[]]$"))
695 (goto-char (point-min))
696 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
698 (replace-match "" t t))
699 (goto-char (point-min))
700 (while (re-search-forward "^[[].*: .*[]]$" nil t)
701 (goto-char (match-end 0))
704 (progn (goto-char (match-beginning 0)))
705 (re-search-forward ":"))))
706 (goto-char (point-min))
707 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
708 (replace-match "" t t))
709 (goto-char (point-min))
710 (while (re-search-forward " +" nil t)
711 (replace-match " " t t))
712 (goto-char (point-min))
713 (while (re-search-forward " $" nil t)
714 (replace-match "" t t))
715 (goto-char (point-min))
716 (while (re-search-forward "^ +" nil t)
717 (replace-match "" t t))
718 (goto-char (point-min))
719 (when gnus-simplify-subject-fuzzy-regexp
720 (if (listp gnus-simplify-subject-fuzzy-regexp)
721 (let ((list gnus-simplify-subject-fuzzy-regexp))
723 (goto-char (point-min))
724 (while (re-search-forward (car list) nil t)
725 (replace-match "" t t))
726 (setq list (cdr list))))
727 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
728 (replace-match "" t t))))))
730 (defun gnus-simplify-subject-fuzzy (subject)
731 "Siplify a subject string fuzzily."
733 (gnus-set-work-buffer)
734 (let ((case-fold-search t))
736 (inline (gnus-simplify-buffer-fuzzy))
739 (defsubst gnus-simplify-subject-fully (subject)
740 "Simplify a subject string according to the user's wishes."
742 ((null gnus-summary-gather-subject-limit)
743 (gnus-simplify-subject-re subject))
744 ((eq gnus-summary-gather-subject-limit 'fuzzy)
745 (gnus-simplify-subject-fuzzy subject))
746 ((numberp gnus-summary-gather-subject-limit)
747 (gnus-limit-string (gnus-simplify-subject-re subject)
748 gnus-summary-gather-subject-limit))
752 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
753 "Check whether two subjects are equal. If optional argument
754 simple-first is t, first argument is already simplified."
757 (equal (gnus-simplify-subject-fully s1)
758 (gnus-simplify-subject-fully s2)))
761 (gnus-simplify-subject-fully s2)))))
763 (defun gnus-offer-save-summaries ()
764 "Offer to save all active summary buffers."
766 (let ((buflist (buffer-list))
768 ;; Go through all buffers and find all summaries.
770 (and (setq bufname (buffer-name (car buflist)))
771 (string-match "Summary" bufname)
774 ;; We check that this is, indeed, a summary buffer.
775 (and (eq major-mode 'gnus-summary-mode)
776 ;; Also make sure this isn't bogus.
777 gnus-newsgroup-prepared))
778 (push bufname buffers))
779 (setq buflist (cdr buflist)))
780 ;; Go through all these summary buffers and offer to save them.
783 "Update summary buffer %s? "
784 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
787 (defun gnus-summary-bubble-group ()
788 "Increase the score of the current group.
789 This is a handy function to add to `gnus-summary-exit-hook' to
790 increase the score of each group you read."
791 (gnus-group-add-score gnus-newsgroup-name))
795 ;;; Gnus summary mode
798 (put 'gnus-summary-mode 'mode-class 'special)
801 ;; Non-orthogonal keys
803 (gnus-define-keys gnus-summary-mode-map
804 " " gnus-summary-next-page
805 "\177" gnus-summary-prev-page
806 [delete] gnus-summary-prev-page
807 "\r" gnus-summary-scroll-up
808 "n" gnus-summary-next-unread-article
809 "p" gnus-summary-prev-unread-article
810 "N" gnus-summary-next-article
811 "P" gnus-summary-prev-article
812 "\M-\C-n" gnus-summary-next-same-subject
813 "\M-\C-p" gnus-summary-prev-same-subject
814 "\M-n" gnus-summary-next-unread-subject
815 "\M-p" gnus-summary-prev-unread-subject
816 "." gnus-summary-first-unread-article
817 "," gnus-summary-best-unread-article
818 "\M-s" gnus-summary-search-article-forward
819 "\M-r" gnus-summary-search-article-backward
820 "<" gnus-summary-beginning-of-article
821 ">" gnus-summary-end-of-article
822 "j" gnus-summary-goto-article
823 "^" gnus-summary-refer-parent-article
824 "\M-^" gnus-summary-refer-article
825 "u" gnus-summary-tick-article-forward
826 "!" gnus-summary-tick-article-forward
827 "U" gnus-summary-tick-article-backward
828 "d" gnus-summary-mark-as-read-forward
829 "D" gnus-summary-mark-as-read-backward
830 "E" gnus-summary-mark-as-expirable
831 "\M-u" gnus-summary-clear-mark-forward
832 "\M-U" gnus-summary-clear-mark-backward
833 "k" gnus-summary-kill-same-subject-and-select
834 "\C-k" gnus-summary-kill-same-subject
835 "\M-\C-k" gnus-summary-kill-thread
836 "\M-\C-l" gnus-summary-lower-thread
837 "e" gnus-summary-edit-article
838 "#" gnus-summary-mark-as-processable
839 "\M-#" gnus-summary-unmark-as-processable
840 "\M-\C-t" gnus-summary-toggle-threads
841 "\M-\C-s" gnus-summary-show-thread
842 "\M-\C-h" gnus-summary-hide-thread
843 "\M-\C-f" gnus-summary-next-thread
844 "\M-\C-b" gnus-summary-prev-thread
845 "\M-\C-u" gnus-summary-up-thread
846 "\M-\C-d" gnus-summary-down-thread
847 "&" gnus-summary-execute-command
848 "c" gnus-summary-catchup-and-exit
849 "\C-w" gnus-summary-mark-region-as-read
850 "\C-t" gnus-summary-toggle-truncation
851 "?" gnus-summary-mark-as-dormant
852 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
853 "\C-c\C-s\C-n" gnus-summary-sort-by-number
854 "\C-c\C-s\C-a" gnus-summary-sort-by-author
855 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
856 "\C-c\C-s\C-d" gnus-summary-sort-by-date
857 "\C-c\C-s\C-i" gnus-summary-sort-by-score
858 "=" gnus-summary-expand-window
859 "\C-x\C-s" gnus-summary-reselect-current-group
860 "\M-g" gnus-summary-rescan-group
861 "w" gnus-summary-stop-page-breaking
862 "\C-c\C-r" gnus-summary-caesar-message
863 "\M-t" gnus-summary-toggle-mime
864 "f" gnus-summary-followup
865 "F" gnus-summary-followup-with-original
866 "C" gnus-summary-cancel-article
867 "r" gnus-summary-reply
868 "R" gnus-summary-reply-with-original
869 "\C-c\C-f" gnus-summary-mail-forward
870 "o" gnus-summary-save-article
871 "\C-o" gnus-summary-save-article-mail
872 "|" gnus-summary-pipe-output
873 "\M-k" gnus-summary-edit-local-kill
874 "\M-K" gnus-summary-edit-global-kill
876 "\C-c\C-d" gnus-summary-describe-group
877 "q" gnus-summary-exit
878 "Q" gnus-summary-exit-no-update
879 "\C-c\C-i" gnus-info-find-node
880 gnus-mouse-2 gnus-mouse-pick-article
881 "m" gnus-summary-mail-other-window
882 "a" gnus-summary-post-news
883 "x" gnus-summary-limit-to-unread
884 "s" gnus-summary-isearch-article
885 "t" gnus-article-hide-headers
886 "g" gnus-summary-show-article
887 "l" gnus-summary-goto-last-article
888 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
889 "\C-d" gnus-summary-enter-digest-group
890 "\M-\C-d" gnus-summary-read-document
892 "*" gnus-cache-enter-article
893 "\M-*" gnus-cache-remove-article
894 "\M-&" gnus-summary-universal-argument
896 "I" gnus-summary-increase-score
897 "L" gnus-summary-lower-score
899 "V" gnus-summary-score-map
900 "X" gnus-uu-extract-map
901 "S" gnus-summary-send-map)
903 ;; Sort of orthogonal keymap
904 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
905 "t" gnus-summary-tick-article-forward
906 "!" gnus-summary-tick-article-forward
907 "d" gnus-summary-mark-as-read-forward
908 "r" gnus-summary-mark-as-read-forward
909 "c" gnus-summary-clear-mark-forward
910 " " gnus-summary-clear-mark-forward
911 "e" gnus-summary-mark-as-expirable
912 "x" gnus-summary-mark-as-expirable
913 "?" gnus-summary-mark-as-dormant
914 "b" gnus-summary-set-bookmark
915 "B" gnus-summary-remove-bookmark
916 "#" gnus-summary-mark-as-processable
917 "\M-#" gnus-summary-unmark-as-processable
918 "S" gnus-summary-limit-include-expunged
919 "C" gnus-summary-catchup
920 "H" gnus-summary-catchup-to-here
921 "\C-c" gnus-summary-catchup-all
922 "k" gnus-summary-kill-same-subject-and-select
923 "K" gnus-summary-kill-same-subject
924 "P" gnus-uu-mark-map)
926 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
927 "c" gnus-summary-clear-above
928 "u" gnus-summary-tick-above
929 "m" gnus-summary-mark-above
930 "k" gnus-summary-kill-below)
932 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
933 "/" gnus-summary-limit-to-subject
934 "n" gnus-summary-limit-to-articles
935 "w" gnus-summary-pop-limit
936 "s" gnus-summary-limit-to-subject
937 "a" gnus-summary-limit-to-author
938 "u" gnus-summary-limit-to-unread
939 "m" gnus-summary-limit-to-marks
940 "v" gnus-summary-limit-to-score
941 "D" gnus-summary-limit-include-dormant
942 "d" gnus-summary-limit-exclude-dormant
943 ;; "t" gnus-summary-limit-exclude-thread
944 "E" gnus-summary-limit-include-expunged
945 "c" gnus-summary-limit-exclude-childless-dormant
946 "C" gnus-summary-limit-mark-excluded-as-read)
948 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
949 "n" gnus-summary-next-unread-article
950 "p" gnus-summary-prev-unread-article
951 "N" gnus-summary-next-article
952 "P" gnus-summary-prev-article
953 "\C-n" gnus-summary-next-same-subject
954 "\C-p" gnus-summary-prev-same-subject
955 "\M-n" gnus-summary-next-unread-subject
956 "\M-p" gnus-summary-prev-unread-subject
957 "f" gnus-summary-first-unread-article
958 "b" gnus-summary-best-unread-article
959 "j" gnus-summary-goto-article
960 "g" gnus-summary-goto-subject
961 "l" gnus-summary-goto-last-article
962 "p" gnus-summary-pop-article)
964 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
965 "k" gnus-summary-kill-thread
966 "l" gnus-summary-lower-thread
967 "i" gnus-summary-raise-thread
968 "T" gnus-summary-toggle-threads
969 "t" gnus-summary-rethread-current
970 "^" gnus-summary-reparent-thread
971 "s" gnus-summary-show-thread
972 "S" gnus-summary-show-all-threads
973 "h" gnus-summary-hide-thread
974 "H" gnus-summary-hide-all-threads
975 "n" gnus-summary-next-thread
976 "p" gnus-summary-prev-thread
977 "u" gnus-summary-up-thread
978 "o" gnus-summary-top-thread
979 "d" gnus-summary-down-thread
980 "#" gnus-uu-mark-thread
981 "\M-#" gnus-uu-unmark-thread)
983 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
984 "c" gnus-summary-catchup-and-exit
985 "C" gnus-summary-catchup-all-and-exit
986 "E" gnus-summary-exit-no-update
987 "Q" gnus-summary-exit
988 "Z" gnus-summary-exit
989 "n" gnus-summary-catchup-and-goto-next-group
990 "R" gnus-summary-reselect-current-group
991 "G" gnus-summary-rescan-group
992 "N" gnus-summary-next-group
993 "P" gnus-summary-prev-group)
995 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
996 " " gnus-summary-next-page
997 "n" gnus-summary-next-page
998 "\177" gnus-summary-prev-page
999 [delete] gnus-summary-prev-page
1000 "p" gnus-summary-prev-page
1001 "\r" gnus-summary-scroll-up
1002 "<" gnus-summary-beginning-of-article
1003 ">" gnus-summary-end-of-article
1004 "b" gnus-summary-beginning-of-article
1005 "e" gnus-summary-end-of-article
1006 "^" gnus-summary-refer-parent-article
1007 "r" gnus-summary-refer-parent-article
1008 "R" gnus-summary-refer-references
1009 "g" gnus-summary-show-article
1010 "s" gnus-summary-isearch-article)
1012 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1013 "b" gnus-article-add-buttons
1014 "B" gnus-article-add-buttons-to-head
1015 "o" gnus-article-treat-overstrike
1016 "e" gnus-article-emphasize
1017 "w" gnus-article-fill-cited-article
1018 "c" gnus-article-remove-cr
1019 "L" gnus-article-remove-trailing-blank-lines
1020 "q" gnus-article-de-quoted-unreadable
1021 "f" gnus-article-display-x-face
1022 "l" gnus-summary-stop-page-breaking
1023 "r" gnus-summary-caesar-message
1024 "t" gnus-article-hide-headers
1025 "v" gnus-summary-verbose-headers
1026 "m" gnus-summary-toggle-mime)
1028 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1029 "a" gnus-article-hide
1030 "h" gnus-article-hide-headers
1031 "b" gnus-article-hide-boring-headers
1032 "s" gnus-article-hide-signature
1033 "c" gnus-article-hide-citation
1034 "p" gnus-article-hide-pgp
1035 "P" gnus-article-hide-pem
1036 "\C-c" gnus-article-hide-citation-maybe)
1038 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1039 "a" gnus-article-highlight
1040 "h" gnus-article-highlight-headers
1041 "c" gnus-article-highlight-citation
1042 "s" gnus-article-highlight-signature)
1044 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1045 "z" gnus-article-date-ut
1046 "u" gnus-article-date-ut
1047 "l" gnus-article-date-local
1048 "e" gnus-article-date-lapsed
1049 "o" gnus-article-date-original)
1051 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1053 "f" gnus-summary-fetch-faq
1054 "d" gnus-summary-describe-group
1055 "h" gnus-summary-describe-briefly
1056 "i" gnus-info-find-node)
1058 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1059 "e" gnus-summary-expire-articles
1060 "\M-\C-e" gnus-summary-expire-articles-now
1061 "\177" gnus-summary-delete-article
1062 [delete] gnus-summary-delete-article
1063 "m" gnus-summary-move-article
1064 "r" gnus-summary-respool-article
1065 "w" gnus-summary-edit-article
1066 "c" gnus-summary-copy-article
1067 "B" gnus-summary-crosspost-article
1068 "q" gnus-summary-respool-query
1069 "i" gnus-summary-import-article)
1071 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1072 "o" gnus-summary-save-article
1073 "m" gnus-summary-save-article-mail
1074 "r" gnus-summary-save-article-rmail
1075 "f" gnus-summary-save-article-file
1076 "b" gnus-summary-save-article-body-file
1077 "h" gnus-summary-save-article-folder
1078 "v" gnus-summary-save-article-vm
1079 "p" gnus-summary-pipe-output
1080 "s" gnus-soup-add-article)
1083 (defun gnus-summary-make-menu-bar ()
1084 (gnus-turn-off-edit-menu 'summary)
1086 (unless (boundp 'gnus-summary-misc-menu)
1089 gnus-summary-kill-menu gnus-summary-mode-map ""
1094 ["Enter score..." gnus-summary-score-entry t])
1095 (gnus-make-score-map 'increase)
1096 (gnus-make-score-map 'lower)
1098 ["Kill below" gnus-summary-kill-below t]
1099 ["Mark above" gnus-summary-mark-above t]
1100 ["Tick above" gnus-summary-tick-above t]
1101 ["Clear above" gnus-summary-clear-above t])
1102 ["Current score" gnus-summary-current-score t]
1103 ["Set score" gnus-summary-set-score t]
1104 ["Customize score file" gnus-score-customize t]
1105 ["Switch current score file..." gnus-score-change-score-file t]
1106 ["Set mark below..." gnus-score-set-mark-below t]
1107 ["Set expunge below..." gnus-score-set-expunge-below t]
1108 ["Edit current score file" gnus-score-edit-current-scores t]
1109 ["Edit score file" gnus-score-edit-file t]
1110 ["Trace score" gnus-score-find-trace t]
1111 ["Find words" gnus-score-find-favuorite-words t]
1112 ["Rescore buffer" gnus-summary-rescore t]
1113 ["Increase score..." gnus-summary-increase-score t]
1114 ["Lower score..." gnus-summary-lower-score t]))))
1117 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1119 :selected (null gnus-score-default-header)]
1120 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1122 :selected (eq gnus-score-default-header 'a)]
1123 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1125 :selected (eq gnus-score-default-header 's)]
1127 (gnus-score-set-default 'gnus-score-default-header 'b)
1129 :selected (eq gnus-score-default-header 'b )]
1131 (gnus-score-set-default 'gnus-score-default-header 'h)
1133 :selected (eq gnus-score-default-header 'h )]
1134 ["Message-Id" (gnus-score-set-default 'gnus-score-default-header 'i)
1136 :selected (eq gnus-score-default-header 'i )]
1137 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1139 :selected (eq gnus-score-default-header 't )]
1141 (gnus-score-set-default 'gnus-score-default-header 'x)
1143 :selected (eq gnus-score-default-header 'x )]
1144 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1146 :selected (eq gnus-score-default-header 'l )]
1147 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1149 :selected (eq gnus-score-default-header 'd )]
1150 ["Followups to author"
1151 (gnus-score-set-default 'gnus-score-default-header 'f)
1153 :selected (eq gnus-score-default-header 'f )])
1155 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1157 :selected (null gnus-score-default-type)]
1158 ;; The `:active' key is commented out in the following,
1159 ;; because the GNU Emacs hack to support radio buttons use
1160 ;; active to indicate which button is selected.
1161 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1163 ;; :active (not (memq gnus-score-default-header '(l d)))
1164 :selected (eq gnus-score-default-type 's)]
1165 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1167 ;; :active (not (memq gnus-score-default-header '(l d)))
1168 :selected (eq gnus-score-default-type 'r)]
1169 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1171 ;; :active (not (memq gnus-score-default-header '(l d)))
1172 :selected (eq gnus-score-default-type 'e)]
1173 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1175 ;; :active (not (memq gnus-score-default-header '(l d)))
1176 :selected (eq gnus-score-default-type 'f)]
1177 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1179 ;; :active (eq (gnus-score-default-header 'd))
1180 :selected (eq gnus-score-default-type 'b)]
1181 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1183 ;; :active (eq (gnus-score-default-header 'd))
1184 :selected (eq gnus-score-default-type 'n)]
1185 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1187 ;; :active (eq (gnus-score-default-header 'd))
1188 :selected (eq gnus-score-default-type 'a)]
1190 (gnus-score-set-default 'gnus-score-default-type '<)
1192 ;; :active (eq (gnus-score-default-header 'l))
1193 :selected (eq gnus-score-default-type '<)]
1195 (gnus-score-set-default 'gnus-score-default-type '=)
1197 ;; :active (eq (gnus-score-default-header 'l))
1198 :selected (eq gnus-score-default-type '=)]
1199 ["Greater than number"
1200 (gnus-score-set-default 'gnus-score-default-type '>)
1202 ;; :active (eq (gnus-score-default-header 'l))
1203 :selected (eq gnus-score-default-type '>)])
1204 ["Default fold" gnus-score-default-fold-toggle
1206 :selected gnus-score-default-fold]
1208 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1210 :selected (null gnus-score-default-duration)]
1212 (gnus-score-set-default 'gnus-score-default-duration 'p)
1214 :selected (eq gnus-score-default-duration 'p)]
1216 (gnus-score-set-default 'gnus-score-default-duration 't)
1218 :selected (eq gnus-score-default-duration 't)]
1220 (gnus-score-set-default 'gnus-score-default-duration 'i)
1222 :selected (eq gnus-score-default-duration 'i)]))
1225 gnus-summary-article-menu gnus-summary-mode-map ""
1228 ["All" gnus-article-hide t]
1229 ["Headers" gnus-article-hide-headers t]
1230 ["Signature" gnus-article-hide-signature t]
1231 ["Citation" gnus-article-hide-citation t]
1232 ["PGP" gnus-article-hide-pgp t]
1233 ["Boring headers" gnus-article-hide-boring-headers t])
1235 ["All" gnus-article-highlight t]
1236 ["Headers" gnus-article-highlight-headers t]
1237 ["Signature" gnus-article-highlight-signature t]
1238 ["Citation" gnus-article-highlight-citation t])
1240 ["Local" gnus-article-date-local t]
1241 ["UT" gnus-article-date-ut t]
1242 ["Original" gnus-article-date-original t]
1243 ["Lapsed" gnus-article-date-lapsed t])
1245 ["Overstrike" gnus-article-treat-overstrike t]
1246 ["Emphasis" gnus-article-emphasize t]
1247 ["Word wrap" gnus-article-fill-cited-article t]
1248 ["CR" gnus-article-remove-cr t]
1249 ["Trailing blank lines" gnus-article-remove-trailing-blank-lines t]
1250 ["Show X-Face" gnus-article-display-x-face t]
1251 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1252 ["Rot 13" gnus-summary-caesar-message t]
1253 ["Add buttons" gnus-article-add-buttons t]
1254 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1255 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1256 ["Toggle MIME" gnus-summary-toggle-mime t]
1257 ["Verbose header" gnus-summary-verbose-headers t]
1258 ["Toggle header" gnus-summary-toggle-header t])
1260 ["Save in default format" gnus-summary-save-article t]
1261 ["Save in file" gnus-summary-save-article-file t]
1262 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1263 ["Save in MH folder" gnus-summary-save-article-folder t]
1264 ["Save in VM folder" gnus-summary-save-article-vm t]
1265 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1266 ["Save body in file" gnus-summary-save-article-body-file t]
1267 ["Pipe through a filter" gnus-summary-pipe-output t]
1268 ["Add to SOUP packet" gnus-soup-add-article t])
1270 ["Respool article..." gnus-summary-respool-article t]
1271 ["Move article..." gnus-summary-move-article
1272 (gnus-check-backend-function
1273 'request-move-article gnus-newsgroup-name)]
1274 ["Copy article..." gnus-summary-copy-article t]
1275 ["Crosspost article..." gnus-summary-crosspost-article
1276 (gnus-check-backend-function
1277 'request-replace-article gnus-newsgroup-name)]
1278 ["Import file..." gnus-summary-import-article t]
1279 ["Edit article" gnus-summary-edit-article
1280 (not (gnus-group-read-only-p))]
1281 ["Delete article" gnus-summary-delete-article
1282 (gnus-check-backend-function
1283 'request-expire-articles gnus-newsgroup-name)]
1284 ["Query respool" gnus-summary-respool-query t]
1285 ["Delete expirable articles" gnus-summary-expire-articles-now
1286 (gnus-check-backend-function
1287 'request-expire-articles gnus-newsgroup-name)])
1289 ["Uudecode" gnus-uu-decode-uu t]
1290 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1291 ["Unshar" gnus-uu-decode-unshar t]
1292 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1293 ["Save" gnus-uu-decode-save t]
1294 ["Binhex" gnus-uu-decode-binhex t]
1295 ["Postscript" gnus-uu-decode-postscript t])
1296 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1297 ["Isearch article..." gnus-summary-isearch-article t]
1298 ["Search articles forward..." gnus-summary-search-article-forward t]
1299 ["Search articles backward..." gnus-summary-search-article-backward t]
1300 ["Beginning of the article" gnus-summary-beginning-of-article t]
1301 ["End of the article" gnus-summary-end-of-article t]
1302 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1303 ["Fetch referenced articles" gnus-summary-refer-references t]
1304 ["Fetch article with id..." gnus-summary-refer-article t]
1305 ["Redisplay" gnus-summary-show-article t]))
1308 gnus-summary-thread-menu gnus-summary-mode-map ""
1310 ["Toggle threading" gnus-summary-toggle-threads t]
1311 ["Hide threads" gnus-summary-hide-all-threads t]
1312 ["Show threads" gnus-summary-show-all-threads t]
1313 ["Hide thread" gnus-summary-hide-thread t]
1314 ["Show thread" gnus-summary-show-thread t]
1315 ["Go to next thread" gnus-summary-next-thread t]
1316 ["Go to previous thread" gnus-summary-prev-thread t]
1317 ["Go down thread" gnus-summary-down-thread t]
1318 ["Go up thread" gnus-summary-up-thread t]
1319 ["Top of thread" gnus-summary-top-thread t]
1320 ["Mark thread as read" gnus-summary-kill-thread t]
1321 ["Lower thread score" gnus-summary-lower-thread t]
1322 ["Raise thread score" gnus-summary-raise-thread t]
1323 ["Rethread current" gnus-summary-rethread-current t]
1327 gnus-summary-post-menu gnus-summary-mode-map ""
1329 ["Post an article" gnus-summary-post-news t]
1330 ["Followup" gnus-summary-followup t]
1331 ["Followup and yank" gnus-summary-followup-with-original t]
1332 ["Supersede article" gnus-summary-supersede-article t]
1333 ["Cancel article" gnus-summary-cancel-article t]
1334 ["Reply" gnus-summary-reply t]
1335 ["Reply and yank" gnus-summary-reply-with-original t]
1336 ["Mail forward" gnus-summary-mail-forward t]
1337 ["Post forward" gnus-summary-post-forward t]
1338 ["Digest and mail" gnus-uu-digest-mail-forward t]
1339 ["Digest and post" gnus-uu-digest-post-forward t]
1340 ["Resend message" gnus-summary-resend-message t]
1341 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1342 ["Send a mail" gnus-summary-mail-other-window t]
1343 ["Uuencode and post" gnus-uu-post-news t]
1345 ;;["Send" gnus-summary-send-draft t]
1346 ;;["Send bounced" gnus-resend-bounced-mail t])
1350 gnus-summary-misc-menu gnus-summary-mode-map ""
1354 ["Mark as read" gnus-summary-mark-as-read-forward t]
1355 ["Mark same subject and select"
1356 gnus-summary-kill-same-subject-and-select t]
1357 ["Mark same subject" gnus-summary-kill-same-subject t]
1358 ["Catchup" gnus-summary-catchup t]
1359 ["Catchup all" gnus-summary-catchup-all t]
1360 ["Catchup to here" gnus-summary-catchup-to-here t]
1361 ["Catchup region" gnus-summary-mark-region-as-read t]
1362 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1364 ["Tick" gnus-summary-tick-article-forward t]
1365 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1366 ["Remove marks" gnus-summary-clear-mark-forward t]
1367 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1368 ["Set bookmark" gnus-summary-set-bookmark t]
1369 ["Remove bookmark" gnus-summary-remove-bookmark t])
1371 ["Marks..." gnus-summary-limit-to-marks t]
1372 ["Subject..." gnus-summary-limit-to-subject t]
1373 ["Author..." gnus-summary-limit-to-author t]
1374 ["Score" gnus-summary-limit-to-score t]
1375 ["Unread" gnus-summary-limit-to-unread t]
1376 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1377 ["Articles" gnus-summary-limit-to-articles t]
1378 ["Pop limit" gnus-summary-pop-limit t]
1379 ["Show dormant" gnus-summary-limit-include-dormant t]
1380 ["Hide childless dormant"
1381 gnus-summary-limit-exclude-childless-dormant t]
1382 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1383 ["Show expunged" gnus-summary-show-all-expunged t])
1385 ["Set mark" gnus-summary-mark-as-processable t]
1386 ["Remove mark" gnus-summary-unmark-as-processable t]
1387 ["Remove all marks" gnus-summary-unmark-all-processable t]
1388 ["Mark above" gnus-uu-mark-over t]
1389 ["Mark series" gnus-uu-mark-series t]
1390 ["Mark region" gnus-uu-mark-region t]
1391 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1392 ["Mark all" gnus-uu-mark-all t]
1393 ["Mark buffer" gnus-uu-mark-buffer t]
1394 ["Mark sparse" gnus-uu-mark-sparse t]
1395 ["Mark thread" gnus-uu-mark-thread t]
1396 ["Unmark thread" gnus-uu-unmark-thread t]
1397 ("Process Mark Sets"
1398 ["Kill" gnus-summary-kill-process-mark t]
1399 ["Yank" gnus-summary-yank-process-mark
1400 gnus-newsgroup-process-stack]
1401 ["Save" gnus-summary-save-process-mark t])))
1403 ["Page forward" gnus-summary-next-page t]
1404 ["Page backward" gnus-summary-prev-page t]
1405 ["Line forward" gnus-summary-scroll-up t])
1407 ["Next unread article" gnus-summary-next-unread-article t]
1408 ["Previous unread article" gnus-summary-prev-unread-article t]
1409 ["Next article" gnus-summary-next-article t]
1410 ["Previous article" gnus-summary-prev-article t]
1411 ["Next unread subject" gnus-summary-next-unread-subject t]
1412 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1413 ["Next article same subject" gnus-summary-next-same-subject t]
1414 ["Previous article same subject" gnus-summary-prev-same-subject t]
1415 ["First unread article" gnus-summary-first-unread-article t]
1416 ["Best unread article" gnus-summary-best-unread-article t]
1417 ["Go to subject number..." gnus-summary-goto-subject t]
1418 ["Go to article number..." gnus-summary-goto-article t]
1419 ["Go to the last article" gnus-summary-goto-last-article t]
1420 ["Pop article off history" gnus-summary-pop-article t])
1422 ["Sort by number" gnus-summary-sort-by-number t]
1423 ["Sort by author" gnus-summary-sort-by-author t]
1424 ["Sort by subject" gnus-summary-sort-by-subject t]
1425 ["Sort by date" gnus-summary-sort-by-date t]
1426 ["Sort by score" gnus-summary-sort-by-score t])
1428 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1429 ["Describe group" gnus-summary-describe-group t]
1430 ["Read manual" gnus-info-find-node t])
1432 ["Enter article" gnus-cache-enter-article t]
1433 ["Remove article" gnus-cache-remove-article t])
1435 ["Pick and read" gnus-pick-mode t]
1436 ["Binary" gnus-binary-mode t])
1437 ["Filter articles..." gnus-summary-execute-command t]
1438 ["Run command on subjects..." gnus-summary-universal-argument t]
1439 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1440 ["Expand window" gnus-summary-expand-window t]
1441 ["Expire expirable articles" gnus-summary-expire-articles
1442 (gnus-check-backend-function
1443 'request-expire-articles gnus-newsgroup-name)]
1444 ["Edit local kill file" gnus-summary-edit-local-kill t]
1445 ["Edit main kill file" gnus-summary-edit-global-kill t]
1447 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1448 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1449 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1450 ["Exit group" gnus-summary-exit t]
1451 ["Exit group without updating" gnus-summary-exit-no-update t]
1452 ["Exit and goto next group" gnus-summary-next-group t]
1453 ["Exit and goto prev group" gnus-summary-prev-group t]
1454 ["Reselect group" gnus-summary-reselect-current-group t]
1455 ["Rescan group" gnus-summary-rescan-group t])))
1457 (run-hooks 'gnus-summary-menu-hook)))
1459 (defun gnus-score-set-default (var value)
1460 "A version of set that updates the GNU Emacs menu-bar."
1462 ;; It is the message that forces the active status to be updated.
1465 (defun gnus-make-score-map (type)
1466 "Make a summary score map of type TYPE."
1469 (let ((headers '(("author" "from" string)
1470 ("subject" "subject" string)
1471 ("article body" "body" string)
1472 ("article head" "head" string)
1473 ("xref" "xref" string)
1474 ("lines" "lines" number)
1475 ("followups to author" "followup" string)))
1476 (types '((number ("less than" <)
1479 (string ("substring" s)
1483 (perms '(("temporary" (current-time-string))
1491 (if (eq type 'lower)
1496 (setq header (car headers))
1502 (let ((ts (cdr (assoc (nth 2 header) types)))
1518 'gnus-summary-score-entry
1520 (if (or (string= (nth 1 header)
1522 (string= (nth 1 header)
1525 (list 'gnus-summary-header
1527 (list 'quote (nth 1 (car ts)))
1528 (list 'gnus-score-default nil)
1534 (list (nreverse outp))))
1537 (list (nreverse outt))))
1539 (setq headers (cdr headers)))
1540 (list (nreverse outh))))))))
1544 (defun gnus-summary-mode (&optional group)
1545 "Major mode for reading articles.
1547 All normal editing commands are switched off.
1548 \\<gnus-summary-mode-map>
1549 Each line in this buffer represents one article. To read an
1550 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1551 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1554 You can also post articles and send mail from this buffer. To
1555 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1556 of an article, type `\\[gnus-summary-reply]'.
1558 There are approx. one gazillion commands you can execute in this
1559 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1561 The following commands are available:
1563 \\{gnus-summary-mode-map}"
1565 (when (and menu-bar-mode
1566 (gnus-visual-p 'summary-menu 'menu))
1567 (gnus-summary-make-menu-bar))
1568 (kill-all-local-variables)
1569 (gnus-summary-make-local-variables)
1570 (gnus-make-thread-indent-array)
1571 (gnus-simplify-mode-line)
1572 (setq major-mode 'gnus-summary-mode)
1573 (setq mode-name "Summary")
1574 (make-local-variable 'minor-mode-alist)
1575 (use-local-map gnus-summary-mode-map)
1576 (buffer-disable-undo (current-buffer))
1577 (setq buffer-read-only t) ;Disable modification
1578 (setq truncate-lines t)
1579 (setq selective-display t)
1580 (setq selective-display-ellipses t) ;Display `...'
1581 (setq buffer-display-table gnus-summary-display-table)
1582 (gnus-set-default-directory)
1583 (setq gnus-newsgroup-name group)
1584 (make-local-variable 'gnus-summary-line-format)
1585 (make-local-variable 'gnus-summary-line-format-spec)
1586 (make-local-variable 'gnus-summary-mark-positions)
1587 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1588 (gnus-update-summary-mark-positions)
1589 (gnus-make-local-hook 'post-command-hook)
1590 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1591 (run-hooks 'gnus-summary-mode-hook))
1593 (defun gnus-summary-make-local-variables ()
1594 "Make all the local summary buffer variables."
1595 (let ((locals gnus-summary-local-variables)
1597 (while (setq local (pop locals))
1600 (if (eq (cdr local) 'global)
1601 ;; Copy the global value of the variable.
1602 (setq global (symbol-value (car local)))
1603 ;; Use the value from the list.
1604 (setq global (eval (cdr local))))
1605 (make-local-variable (car local))
1606 (set (car local) global))
1607 ;; Simple nil-valued local variable.
1608 (make-local-variable local)
1611 (defun gnus-summary-clear-local-variables ()
1612 (let ((locals gnus-summary-local-variables))
1614 (if (consp (car locals))
1615 (and (vectorp (caar locals))
1616 (set (caar locals) nil))
1617 (and (vectorp (car locals))
1618 (set (car locals) nil)))
1619 (setq locals (cdr locals)))))
1621 ;; Summary data functions.
1623 (defmacro gnus-data-number (data)
1626 (defmacro gnus-data-set-number (data number)
1627 `(setcar ,data ,number))
1629 (defmacro gnus-data-mark (data)
1632 (defmacro gnus-data-set-mark (data mark)
1633 `(setcar (nthcdr 1 ,data) ,mark))
1635 (defmacro gnus-data-pos (data)
1638 (defmacro gnus-data-set-pos (data pos)
1639 `(setcar (nthcdr 2 ,data) ,pos))
1641 (defmacro gnus-data-header (data)
1644 (defmacro gnus-data-level (data)
1647 (defmacro gnus-data-unread-p (data)
1648 `(= (nth 1 ,data) gnus-unread-mark))
1650 (defmacro gnus-data-read-p (data)
1651 `(/= (nth 1 ,data) gnus-unread-mark))
1653 (defmacro gnus-data-pseudo-p (data)
1654 `(consp (nth 3 ,data)))
1656 (defmacro gnus-data-find (number)
1657 `(assq ,number gnus-newsgroup-data))
1659 (defmacro gnus-data-find-list (number &optional data)
1660 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1661 (memq (assq ,number bdata)
1664 (defmacro gnus-data-make (number mark pos header level)
1665 `(list ,number ,mark ,pos ,header ,level))
1667 (defun gnus-data-enter (after-article number mark pos header level offset)
1668 (let ((data (gnus-data-find-list after-article)))
1669 (or data (error "No such article: %d" after-article))
1670 (setcdr data (cons (gnus-data-make number mark pos header level)
1672 (setq gnus-newsgroup-data-reverse nil)
1673 (gnus-data-update-list (cddr data) offset)))
1675 (defun gnus-data-enter-list (after-article list &optional offset)
1677 (let ((data (and after-article (gnus-data-find-list after-article)))
1679 (or data (not after-article) (error "No such article: %d" after-article))
1680 ;; Find the last element in the list to be spliced into the main
1683 (setq list (cdr list)))
1686 (setcdr list gnus-newsgroup-data)
1687 (setq gnus-newsgroup-data ilist)
1688 (and offset (gnus-data-update-list (cdr list) offset)))
1689 (setcdr list (cdr data))
1691 (and offset (gnus-data-update-list (cdr data) offset)))
1692 (setq gnus-newsgroup-data-reverse nil))))
1694 (defun gnus-data-remove (article &optional offset)
1695 (let ((data gnus-newsgroup-data))
1696 (if (= (gnus-data-number (car data)) article)
1697 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1698 gnus-newsgroup-data-reverse nil)
1700 (and (= (gnus-data-number (cadr data)) article)
1702 (setcdr data (cddr data))
1703 (and offset (gnus-data-update-list (cdr data) offset))
1705 gnus-newsgroup-data-reverse nil)))
1706 (setq data (cdr data))))))
1708 (defmacro gnus-data-list (backward)
1710 (or gnus-newsgroup-data-reverse
1711 (setq gnus-newsgroup-data-reverse
1712 (reverse gnus-newsgroup-data)))
1713 gnus-newsgroup-data))
1715 (defun gnus-data-update-list (data offset)
1716 "Add OFFSET to the POS of all data entries in DATA."
1718 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
1719 (setq data (cdr data))))
1721 (defun gnus-data-compute-positions ()
1722 "Compute the positions of all articles."
1723 (let ((data gnus-newsgroup-data)
1726 (when (setq pos (text-property-any
1727 (point-min) (point-max)
1728 'gnus-number (gnus-data-number (car data))))
1729 (gnus-data-set-pos (car data) (+ pos 3)))
1730 (setq data (cdr data)))))
1732 (defun gnus-summary-article-pseudo-p (article)
1733 "Say whether this article is a pseudo article or not."
1734 (not (vectorp (gnus-data-header (gnus-data-find article)))))
1736 (defun gnus-article-parent-p (number)
1737 "Say whether this article is a parent or not."
1738 (let ((data (gnus-data-find-list number)))
1739 (and (cdr data) ; There has to be an article after...
1740 (< (gnus-data-level (car data)) ; And it has to have a higher level.
1741 (gnus-data-level (nth 1 data))))))
1743 (defun gnus-article-children (number)
1744 "Return a list of all children to NUMBER."
1745 (let* ((data (gnus-data-find-list number))
1746 (level (gnus-data-level (car data)))
1748 (setq data (cdr data))
1750 (= (gnus-data-level (car data)) (1+ level)))
1751 (push (gnus-data-number (car data)) children)
1752 (setq data (cdr data)))
1755 (defmacro gnus-summary-skip-intangible ()
1756 "If the current article is intangible, then jump to a different article."
1757 '(let ((to (get-text-property (point) 'gnus-intangible)))
1758 (and to (gnus-summary-goto-subject to))))
1760 (defmacro gnus-summary-article-intangible-p ()
1761 "Say whether this article is intangible or not."
1762 '(get-text-property (point) 'gnus-intangible))
1764 ;; Some summary mode macros.
1766 (defmacro gnus-summary-article-number ()
1767 "The article number of the article on the current line.
1768 If there isn's an article number here, then we return the current
1771 (gnus-summary-skip-intangible)
1772 (or (get-text-property (point) 'gnus-number)
1773 (gnus-summary-last-subject))))
1775 (defmacro gnus-summary-article-header (&optional number)
1776 `(gnus-data-header (gnus-data-find
1777 ,(or number '(gnus-summary-article-number)))))
1779 (defmacro gnus-summary-thread-level (&optional number)
1780 `(if (and (eq gnus-summary-make-false-root 'dummy)
1781 (get-text-property (point) 'gnus-intangible))
1783 (gnus-data-level (gnus-data-find
1784 ,(or number '(gnus-summary-article-number))))))
1786 (defmacro gnus-summary-article-mark (&optional number)
1787 `(gnus-data-mark (gnus-data-find
1788 ,(or number '(gnus-summary-article-number)))))
1790 (defmacro gnus-summary-article-pos (&optional number)
1791 `(gnus-data-pos (gnus-data-find
1792 ,(or number '(gnus-summary-article-number)))))
1794 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
1795 (defmacro gnus-summary-article-subject (&optional number)
1796 "Return current subject string or nil if nothing."
1799 `(gnus-data-header (assq ,number gnus-newsgroup-data))
1800 '(gnus-data-header (assq (gnus-summary-article-number)
1801 gnus-newsgroup-data)))))
1804 (mail-header-subject headers))))
1806 (defmacro gnus-summary-article-score (&optional number)
1807 "Return current article score."
1808 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
1809 gnus-newsgroup-scored))
1810 gnus-summary-default-score 0))
1812 (defun gnus-summary-article-children (&optional number)
1813 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
1814 (level (gnus-data-level (car data)))
1816 (while (and (setq data (cdr data))
1817 (> (setq l (gnus-data-level (car data))) level))
1818 (and (= (1+ level) l)
1819 (setq children (cons (gnus-data-number (car data))
1821 (nreverse children)))
1823 (defun gnus-summary-article-parent (&optional number)
1824 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
1825 (gnus-data-list t)))
1826 (level (gnus-data-level (car data))))
1828 () ; This is a root.
1829 ;; We search until we find an article with a level less than
1830 ;; this one. That function has to be the parent.
1831 (while (and (setq data (cdr data))
1832 (not (< (gnus-data-level (car data)) level))))
1833 (and data (gnus-data-number (car data))))))
1835 (defun gnus-unread-mark-p (mark)
1836 "Say whether MARK is the unread mark."
1837 (= mark gnus-unread-mark))
1839 (defun gnus-read-mark-p (mark)
1840 "Say whether MARK is one of the marks that mark as read.
1841 This is all marks except unread, ticked, dormant, and expirable."
1842 (not (or (= mark gnus-unread-mark)
1843 (= mark gnus-ticked-mark)
1844 (= mark gnus-dormant-mark)
1845 (= mark gnus-expirable-mark))))
1847 (defmacro gnus-article-mark (number)
1849 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
1850 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
1851 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
1852 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
1853 (t (or (cdr (assq ,number gnus-newsgroup-reads))
1854 gnus-ancient-mark))))
1856 ;; Saving hidden threads.
1858 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
1859 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
1860 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
1862 (defmacro gnus-save-hidden-threads (&rest forms)
1863 "Save hidden threads, eval FORMS, and restore the hidden threads."
1864 (let ((config (make-symbol "config")))
1865 `(let ((,config (gnus-hidden-threads-configuration)))
1869 (gnus-restore-hidden-threads-configuration ,config)))))
1871 (defun gnus-hidden-threads-configuration ()
1872 "Return the current hidden threads configuration."
1875 (goto-char (point-min))
1876 (while (search-forward "\r" nil t)
1877 (push (1- (point)) config))
1880 (defun gnus-restore-hidden-threads-configuration (config)
1881 "Restore hidden threads configuration from CONFIG."
1882 (let (point buffer-read-only)
1883 (while (setq point (pop config))
1884 (when (and (< point (point-max))
1886 (= (following-char) ?\n))
1887 (subst-char-in-region point (1+ point) ?\n ?\r)))))
1889 ;; Various summary mode internalish functions.
1891 (defun gnus-mouse-pick-article (e)
1894 (gnus-summary-next-page nil t))
1896 (defun gnus-summary-setup-buffer (group)
1897 "Initialize summary buffer."
1898 (let ((buffer (concat "*Summary " group "*")))
1899 (if (get-buffer buffer)
1902 (setq gnus-summary-buffer (current-buffer))
1903 (not gnus-newsgroup-prepared))
1904 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
1905 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
1906 (gnus-add-current-to-buffer-list)
1907 (gnus-summary-mode group)
1909 (gnus-carpal-setup-buffer 'summary))
1910 (unless gnus-single-article-buffer
1911 (make-local-variable 'gnus-article-buffer)
1912 (make-local-variable 'gnus-article-current)
1913 (make-local-variable 'gnus-original-article-buffer))
1914 (setq gnus-newsgroup-name group)
1917 (defun gnus-set-global-variables ()
1918 ;; Set the global equivalents of the summary buffer-local variables
1919 ;; to the latest values they had. These reflect the summary buffer
1920 ;; that was in action when the last article was fetched.
1921 (when (eq major-mode 'gnus-summary-mode)
1922 (setq gnus-summary-buffer (current-buffer))
1923 (let ((name gnus-newsgroup-name)
1924 (marked gnus-newsgroup-marked)
1925 (unread gnus-newsgroup-unreads)
1926 (headers gnus-current-headers)
1927 (data gnus-newsgroup-data)
1928 (summary gnus-summary-buffer)
1929 (article-buffer gnus-article-buffer)
1930 (original gnus-original-article-buffer)
1931 (gac gnus-article-current)
1932 (reffed gnus-reffed-article-number)
1933 (score-file gnus-current-score-file))
1935 (set-buffer gnus-group-buffer)
1936 (setq gnus-newsgroup-name name)
1937 (setq gnus-newsgroup-marked marked)
1938 (setq gnus-newsgroup-unreads unread)
1939 (setq gnus-current-headers headers)
1940 (setq gnus-newsgroup-data data)
1941 (setq gnus-article-current gac)
1942 (setq gnus-summary-buffer summary)
1943 (setq gnus-article-buffer article-buffer)
1944 (setq gnus-original-article-buffer original)
1945 (setq gnus-reffed-article-number reffed)
1946 (setq gnus-current-score-file score-file)))))
1948 (defun gnus-summary-last-article-p (&optional article)
1949 "Return whether ARTICLE is the last article in the buffer."
1950 (if (not (setq article (or article (gnus-summary-article-number))))
1951 t ; All non-existant numbers are the last article. :-)
1952 (not (cdr (gnus-data-find-list article)))))
1954 (defun gnus-make-thread-indent-array ()
1956 (unless (and gnus-thread-indent-array
1957 (= gnus-thread-indent-level gnus-thread-indent-array-level))
1958 (setq gnus-thread-indent-array (make-vector 201 "")
1959 gnus-thread-indent-array-level gnus-thread-indent-level)
1961 (aset gnus-thread-indent-array n
1962 (make-string (* n gnus-thread-indent-level) ? ))
1965 (defun gnus-update-summary-mark-positions ()
1966 "Compute where the summary marks are to go."
1968 (when (and gnus-summary-buffer
1969 (get-buffer gnus-summary-buffer)
1970 (buffer-name (get-buffer gnus-summary-buffer)))
1971 (set-buffer gnus-summary-buffer))
1972 (let ((gnus-replied-mark 129)
1973 (gnus-score-below-mark 130)
1974 (gnus-score-over-mark 130)
1977 (spec gnus-summary-line-format-spec)
1980 (gnus-set-work-buffer)
1981 (let ((gnus-summary-line-format-spec spec))
1982 (gnus-summary-insert-line
1983 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1984 (goto-char (point-min))
1985 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1987 (goto-char (point-min))
1988 (push (cons 'replied (and (search-forward "\201" nil t)
1991 (goto-char (point-min))
1992 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
1994 (setq gnus-summary-mark-positions pos))))
1996 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
1997 "Insert a dummy root in the summary buffer."
1999 (gnus-add-text-properties
2000 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2001 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2003 (defun gnus-summary-insert-line
2004 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
2005 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
2006 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
2007 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2008 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2009 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2010 (gnus-tmp-score-char
2011 (if (or (null gnus-summary-default-score)
2012 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2013 gnus-summary-zcore-fuzz)) ?
2014 (if (< gnus-tmp-score gnus-summary-default-score)
2015 gnus-score-below-mark gnus-score-over-mark)))
2016 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
2017 ((memq gnus-tmp-current gnus-newsgroup-cached)
2019 (gnus-tmp-replied gnus-replied-mark)
2020 ((memq gnus-tmp-current gnus-newsgroup-saved)
2022 (t gnus-unread-mark)))
2023 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2026 ((string-match "(.+)" gnus-tmp-from)
2027 (substring gnus-tmp-from
2028 (1+ (match-beginning 0)) (1- (match-end 0))))
2029 ((string-match "<[^>]+> *$" gnus-tmp-from)
2030 (let ((beg (match-beginning 0)))
2031 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2032 (substring gnus-tmp-from (1+ (match-beginning 0))
2033 (1- (match-end 0))))
2034 (substring gnus-tmp-from 0 beg))))
2036 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2037 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2038 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2039 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2040 (buffer-read-only nil))
2041 (when (string= gnus-tmp-name "")
2042 (setq gnus-tmp-name gnus-tmp-from))
2043 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
2044 (gnus-put-text-property
2046 (progn (eval gnus-summary-line-format-spec) (point))
2047 'gnus-number gnus-tmp-number)
2048 (when (gnus-visual-p 'summary-highlight 'highlight)
2050 (run-hooks 'gnus-summary-update-hook)
2053 (defun gnus-summary-update-line (&optional dont-update)
2054 ;; Update summary line after change.
2055 (when (and gnus-summary-default-score
2056 (not gnus-summary-inhibit-highlight))
2057 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2058 (article (gnus-summary-article-number))
2059 (score (gnus-summary-article-score article)))
2061 (if (and gnus-summary-mark-below
2062 (< (gnus-summary-article-score)
2063 gnus-summary-mark-below))
2064 ;; This article has a low score, so we mark it as read.
2065 (when (memq article gnus-newsgroup-unreads)
2066 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2067 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2068 ;; This article was previously marked as read on account
2069 ;; of a low score, but now it has risen, so we mark it as
2071 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2072 (gnus-summary-update-mark
2073 (if (or (null gnus-summary-default-score)
2074 (<= (abs (- score gnus-summary-default-score))
2075 gnus-summary-zcore-fuzz)) ?
2076 (if (< score gnus-summary-default-score)
2077 gnus-score-below-mark gnus-score-over-mark)) 'score))
2078 ;; Do visual highlighting.
2079 (when (gnus-visual-p 'summary-highlight 'highlight)
2080 (run-hooks 'gnus-summary-update-hook)))))
2082 (defvar gnus-tmp-new-adopts nil)
2084 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2085 ;; Sum up all elements (and sub-elements) in a list.
2087 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2089 ((and (consp thread) (cdr thread))
2092 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2095 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2098 (when (and level (zerop level) gnus-tmp-new-adopts)
2101 'gnus-summary-number-of-articles-in-thread
2102 gnus-tmp-new-adopts))))
2104 (if (> number 1) gnus-not-empty-thread-mark
2105 gnus-empty-thread-mark)
2108 (defun gnus-summary-set-local-parameters (group)
2109 "Go through the local params of GROUP and set all variable specs in that list."
2110 (let ((params (gnus-group-find-parameter group))
2113 (setq elem (car params)
2114 params (cdr params))
2115 (and (consp elem) ; Has to be a cons.
2116 (consp (cdr elem)) ; The cdr has to be a list.
2117 (symbolp (car elem)) ; Has to be a symbol in there.
2118 (not (memq (car elem)
2119 '(quit-config to-address to-list to-group)))
2120 (progn ; So we set it.
2121 (make-local-variable (car elem))
2122 (set (car elem) (eval (nth 1 elem))))))))
2124 (defun gnus-summary-read-group (group &optional show-all no-article
2125 kill-buffer no-display)
2126 "Start reading news in newsgroup GROUP.
2127 If SHOW-ALL is non-nil, already read articles are also listed.
2128 If NO-ARTICLE is non-nil, no article is selected initially.
2129 If NO-DISPLAY, don't generate a summary buffer."
2130 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2131 (let* ((new-group (gnus-summary-setup-buffer group))
2132 (quit-config (gnus-group-quit-config group))
2133 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2135 ;; This summary buffer exists already, so we just select it.
2137 (gnus-set-global-variables)
2139 (gnus-kill-or-deaden-summary kill-buffer))
2140 (gnus-configure-windows 'summary 'force)
2141 (gnus-set-mode-line 'summary)
2142 (gnus-summary-position-point)
2145 ;; We couldn't select this group.
2147 (when (and (eq major-mode 'gnus-summary-mode)
2148 (not (equal (current-buffer) kill-buffer)))
2149 (kill-buffer (current-buffer))
2150 (if (not quit-config)
2152 (set-buffer gnus-group-buffer)
2153 (gnus-group-jump-to-group group)
2154 (gnus-group-next-unread-group 1))
2155 (if (not (buffer-name (car quit-config)))
2156 (gnus-configure-windows 'group 'force)
2157 (set-buffer (car quit-config))
2158 (and (eq major-mode 'gnus-summary-mode)
2159 (gnus-set-global-variables))
2160 (gnus-configure-windows (cdr quit-config)))))
2161 (gnus-message 3 "Can't select group")
2163 ;; The user did a `C-g' while prompting for number of articles,
2164 ;; so we exit this group.
2165 ((eq did-select 'quit)
2166 (and (eq major-mode 'gnus-summary-mode)
2167 (not (equal (current-buffer) kill-buffer))
2168 (kill-buffer (current-buffer)))
2170 (gnus-kill-or-deaden-summary kill-buffer))
2171 (if (not quit-config)
2173 (set-buffer gnus-group-buffer)
2174 (gnus-group-jump-to-group group)
2175 (gnus-group-next-unread-group 1)
2176 (gnus-configure-windows 'group 'force))
2177 (if (not (buffer-name (car quit-config)))
2178 (gnus-configure-windows 'group 'force)
2179 (set-buffer (car quit-config))
2180 (and (eq major-mode 'gnus-summary-mode)
2181 (gnus-set-global-variables))
2182 (gnus-configure-windows (cdr quit-config))))
2183 ;; Finally signal the quit.
2185 ;; The group was successfully selected.
2187 (gnus-set-global-variables)
2188 ;; Save the active value in effect when the group was entered.
2189 (setq gnus-newsgroup-active
2191 (gnus-active gnus-newsgroup-name)))
2192 ;; You can change the summary buffer in some way with this hook.
2193 (run-hooks 'gnus-select-group-hook)
2194 ;; Set any local variables in the group parameters.
2195 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2196 (gnus-update-format-specifications)
2197 ;; Do score processing.
2198 (when gnus-use-scoring
2199 (gnus-possibly-score-headers))
2200 ;; Check whether to fill in the gaps in the threads.
2201 (when gnus-build-sparse-threads
2202 (gnus-build-sparse-threads))
2203 ;; Find the initial limit.
2204 (if gnus-show-threads
2206 (let ((gnus-newsgroup-dormant nil))
2207 (gnus-summary-initial-limit show-all))
2208 (gnus-summary-initial-limit show-all))
2209 (setq gnus-newsgroup-limit
2211 (lambda (header) (mail-header-number header))
2212 gnus-newsgroup-headers)))
2213 ;; Generate the summary buffer.
2215 (gnus-summary-prepare))
2216 (when gnus-use-trees
2217 (gnus-tree-open group)
2218 (setq gnus-summary-highlight-line-function
2219 'gnus-tree-highlight-article))
2220 ;; If the summary buffer is empty, but there are some low-scored
2221 ;; articles or some excluded dormants, we include these in the
2223 (when (and (zerop (buffer-size))
2225 (cond (gnus-newsgroup-dormant
2226 (gnus-summary-limit-include-dormant))
2227 ((and gnus-newsgroup-scored show-all)
2228 (gnus-summary-limit-include-expunged t))))
2229 ;; Function `gnus-apply-kill-file' must be called in this hook.
2230 (run-hooks 'gnus-apply-kill-hook)
2231 (if (and (zerop (buffer-size))
2234 ;; This newsgroup is empty.
2235 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2236 (gnus-message 6 "No unread news")
2238 (gnus-kill-or-deaden-summary kill-buffer))
2239 ;; Return nil from this function.
2241 ;; Hide conversation thread subtrees. We cannot do this in
2242 ;; gnus-summary-prepare-hook since kill processing may not
2243 ;; work with hidden articles.
2244 (and gnus-show-threads
2245 gnus-thread-hide-subtree
2246 (gnus-summary-hide-all-threads))
2247 ;; Show first unread article if requested.
2248 (if (and (not no-article)
2250 gnus-newsgroup-unreads
2251 gnus-auto-select-first)
2252 (unless (if (eq gnus-auto-select-first 'best)
2253 (gnus-summary-best-unread-article)
2254 (gnus-summary-first-unread-article))
2255 (gnus-configure-windows 'summary))
2256 ;; Don't select any articles, just move point to the first
2257 ;; article in the group.
2258 (goto-char (point-min))
2259 (gnus-summary-position-point)
2260 (gnus-set-mode-line 'summary)
2261 (gnus-configure-windows 'summary 'force))
2263 (gnus-kill-or-deaden-summary kill-buffer))
2264 (when (get-buffer-window gnus-group-buffer t)
2265 ;; Gotta use windows, because recenter does wierd stuff if
2266 ;; the current buffer ain't the displayed window.
2267 (let ((owin (selected-window)))
2268 (select-window (get-buffer-window gnus-group-buffer t))
2269 (when (gnus-group-goto-group group)
2271 (select-window owin))))
2272 ;; Mark this buffer as "prepared".
2273 (setq gnus-newsgroup-prepared t)
2276 (defun gnus-summary-prepare ()
2277 "Generate the summary buffer."
2278 (let ((buffer-read-only nil))
2280 (setq gnus-newsgroup-data nil
2281 gnus-newsgroup-data-reverse nil)
2282 (run-hooks 'gnus-summary-generate-hook)
2283 ;; Generate the buffer, either with threads or without.
2284 (when gnus-newsgroup-headers
2285 (gnus-summary-prepare-threads
2286 (if gnus-show-threads
2287 (gnus-sort-gathered-threads
2288 (funcall gnus-summary-thread-gathering-function
2290 (gnus-cut-threads (gnus-make-threads)))))
2291 ;; Unthreaded display.
2292 (gnus-sort-articles gnus-newsgroup-headers))))
2293 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2294 ;; Call hooks for modifying summary buffer.
2295 (goto-char (point-min))
2296 (run-hooks 'gnus-summary-prepare-hook)))
2298 (defsubst gnus-general-simplify-subject (subject)
2299 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2302 ;; Truncate the subject.
2303 ((numberp gnus-summary-gather-subject-limit)
2304 (setq subject (gnus-simplify-subject-re subject))
2305 (if (> (length subject) gnus-summary-gather-subject-limit)
2306 (substring subject 0 gnus-summary-gather-subject-limit)
2308 ;; Fuzzily simplify it.
2309 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2310 (gnus-simplify-subject-fuzzy subject))
2311 ;; Just remove the leading "Re:".
2313 (gnus-simplify-subject-re subject))))
2315 (if (and gnus-summary-gather-exclude-subject
2316 (string-match gnus-summary-gather-exclude-subject subject))
2317 nil ; This article shouldn't be gathered
2320 (defun gnus-summary-simplify-subject-query ()
2321 "Query where the respool algorithm would put this article."
2323 (gnus-set-global-variables)
2324 (gnus-summary-select-article)
2325 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2327 (defun gnus-gather-threads-by-subject (threads)
2328 "Gather threads by looking at Subject headers."
2329 (if (not gnus-summary-make-false-root)
2331 (let ((hashtb (gnus-make-hashtable 1023))
2334 subject hthread whole-subject)
2336 (setq subject (gnus-general-simplify-subject
2337 (setq whole-subject (mail-header-subject
2340 (if (setq hthread (gnus-gethash subject hashtb))
2342 ;; We enter a dummy root into the thread, if we
2343 ;; haven't done that already.
2344 (unless (stringp (caar hthread))
2345 (setcar hthread (list whole-subject (car hthread))))
2346 ;; We add this new gathered thread to this gathered
2348 (setcdr (car hthread)
2349 (nconc (cdar hthread) (list (car threads))))
2350 ;; Remove it from the list of threads.
2351 (setcdr prev (cdr threads))
2352 (setq threads prev))
2353 ;; Enter this thread into the hash table.
2354 (gnus-sethash subject threads hashtb)))
2356 (setq threads (cdr threads)))
2359 (defun gnus-gather-threads-by-references (threads)
2360 "Gather threads by looking at References headers."
2361 (let ((idhashtb (gnus-make-hashtable 1023))
2362 (thhashtb (gnus-make-hashtable 1023))
2365 ids references id gthread gid entered)
2367 (when (setq references (mail-header-references (caar threads)))
2368 (setq id (mail-header-id (caar threads)))
2369 (setq ids (gnus-split-references references))
2372 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
2374 (gnus-sethash (car ids) id idhashtb)
2375 (gnus-sethash id threads thhashtb))
2376 (setq gthread (gnus-gethash gid thhashtb))
2378 ;; We enter a dummy root into the thread, if we
2379 ;; haven't done that already.
2380 (unless (stringp (caar gthread))
2381 (setcar gthread (list (mail-header-subject (caar gthread))
2383 ;; We add this new gathered thread to this gathered
2385 (setcdr (car gthread)
2386 (nconc (cdar gthread) (list (car threads)))))
2387 ;; Add it into the thread hash table.
2388 (gnus-sethash id gthread thhashtb)
2390 ;; Remove it from the list of threads.
2391 (setcdr prev (cdr threads))
2392 (setq threads prev))
2393 (setq ids (cdr ids))))
2395 (setq threads (cdr threads)))
2398 (defun gnus-sort-gathered-threads (threads)
2399 "Sort subtreads inside each gathered thread by article number."
2400 (let ((result threads))
2402 (when (stringp (caar threads))
2403 (setcdr (car threads)
2404 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2405 (setq threads (cdr threads)))
2408 (defun gnus-make-threads ()
2409 "Go through the dependency hashtb and find the roots. Return all threads."
2413 (unless (car (symbol-value refs))
2414 ;; These threads do not refer back to any other articles,
2415 ;; so they're roots.
2416 (setq threads (append (cdr (symbol-value refs)) threads))))
2417 gnus-newsgroup-dependencies)
2420 (defun gnus-build-sparse-threads ()
2421 (let ((headers gnus-newsgroup-headers)
2422 (deps gnus-newsgroup-dependencies)
2423 header references generation relations
2424 cthread subject child end pthread relation)
2425 ;; First we create an alist of generations/relations, where
2426 ;; generations is how much we trust the ralation, and the relation
2428 (gnus-message 7 "Making sparse threads...")
2430 (nnheader-set-temp-buffer " *gnus sparse threads*")
2431 (while (setq header (pop headers))
2432 (when (and (setq references (mail-header-references header))
2433 (not (string= references "")))
2435 (setq child (mail-header-id header)
2436 subject (mail-header-subject header))
2438 (while (search-backward ">" nil t)
2439 (setq end (1+ (point)))
2440 (when (search-backward "<" nil t)
2441 (push (list (incf generation)
2442 child (setq child (buffer-substring (point) end))
2445 (push (list (1+ generation) child nil subject) relations)
2447 (kill-buffer (current-buffer)))
2448 ;; Sort over trustworthiness.
2449 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2450 (while (setq relation (pop relations))
2451 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2452 (unless (car (symbol-value cthread))
2453 ;; Make this article the parent of these threads.
2454 (setcar (symbol-value cthread)
2455 (vector gnus-reffed-article-number
2459 (or (caddr relation) "") 0 0 "")))
2460 (set cthread (list (vector gnus-reffed-article-number
2462 "" "" (cadr relation)
2463 (or (caddr relation) "") 0 0 ""))))
2464 (push gnus-reffed-article-number gnus-newsgroup-limit)
2465 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2466 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2467 gnus-newsgroup-reads)
2468 (decf gnus-reffed-article-number)
2469 ;; Make this new thread the child of its parent.
2470 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2471 (setcdr (symbol-value pthread)
2472 (nconc (cdr (symbol-value pthread))
2473 (list (symbol-value cthread))))
2474 (set pthread (list nil (symbol-value cthread))))))
2475 (gnus-message 7 "Making sparse threads...done")))
2477 (defun gnus-build-old-threads ()
2478 ;; Look at all the articles that refer back to old articles, and
2479 ;; fetch the headers for the articles that aren't there. This will
2480 ;; build complete threads - if the roots haven't been expired by the
2485 (when (not (car (symbol-value refs)))
2486 (setq heads (cdr (symbol-value refs)))
2488 (if (memq (mail-header-number (caar heads))
2489 gnus-newsgroup-dormant)
2490 (setq heads (cdr heads))
2491 (setq id (symbol-name refs))
2492 (while (and (setq id (gnus-build-get-header id))
2493 (not (car (gnus-gethash
2494 id gnus-newsgroup-dependencies)))))
2495 (setq heads nil)))))
2496 gnus-newsgroup-dependencies)))
2498 (defun gnus-build-get-header (id)
2499 ;; Look through the buffer of NOV lines and find the header to
2500 ;; ID. Enter this line into the dependencies hash table, and return
2501 ;; the id of the parent article (if any).
2502 (let ((deps gnus-newsgroup-dependencies)
2506 (set-buffer nntp-server-buffer)
2507 (goto-char (point-min))
2508 (while (and (not found) (search-forward id nil t))
2510 (setq found (looking-at
2511 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2512 (regexp-quote id))))
2513 (or found (beginning-of-line 2)))
2517 (setq header (gnus-nov-parse-line
2518 (read (current-buffer)) deps))
2519 (gnus-parent-id (mail-header-references header)))))
2521 (let ((number (mail-header-number header)))
2522 (push number gnus-newsgroup-limit)
2523 (push header gnus-newsgroup-headers)
2524 (if (memq number gnus-newsgroup-unselected)
2526 (push number gnus-newsgroup-unreads)
2527 (setq gnus-newsgroup-unselected
2528 (delq number gnus-newsgroup-unselected)))
2529 (push number gnus-newsgroup-ancient)))))))
2531 (defun gnus-summary-update-article-line (article header)
2532 "Update the line for ARTICLE using HEADERS."
2533 (let* ((id (mail-header-id header))
2534 (thread (gnus-id-to-thread id)))
2536 (error "Article in no thread"))
2537 ;; Update the thread.
2538 (setcar thread header)
2539 (gnus-summary-goto-subject article)
2540 (let* ((datal (gnus-data-find-list article))
2542 (length (when (cdr datal)
2543 (- (gnus-data-pos data)
2544 (gnus-data-pos (cadr datal)))))
2545 (buffer-read-only nil)
2546 (level (gnus-summary-thread-level)))
2548 (gnus-summary-insert-line
2549 header level nil (gnus-article-mark article)
2550 (memq article gnus-newsgroup-replied)
2551 (memq article gnus-newsgroup-expirable)
2552 (mail-header-subject header)
2553 nil (cdr (assq article gnus-newsgroup-scored))
2554 (memq article gnus-newsgroup-processable))
2556 (gnus-data-update-list
2557 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2559 (defun gnus-summary-update-article (article &optional iheader)
2560 "Update ARTICLE in the summary buffer."
2561 (set-buffer gnus-summary-buffer)
2562 (let* ((header (or iheader (gnus-summary-article-header article)))
2563 (id (mail-header-id header))
2564 (data (gnus-data-find article))
2565 (thread (gnus-id-to-thread id))
2566 (references (mail-header-references header))
2571 (not (equal "" references)))
2574 (buffer-read-only nil)
2576 (number (mail-header-number header))
2579 ;; !!! Should this be in or not?
2581 (setcar thread nil))
2583 (delq thread parent))
2584 (if (gnus-summary-insert-subject id header iheader)
2585 ;; Set the (possibly) new article number in the data structure.
2586 (gnus-data-set-number data (gnus-id-to-article id))
2590 (defun gnus-rebuild-thread (id)
2591 "Rebuild the thread containing ID."
2592 (let ((buffer-read-only nil)
2593 current thread data)
2594 (if (not gnus-show-threads)
2595 (setq thread (list (car (gnus-id-to-thread id))))
2596 ;; Get the thread this article is part of.
2597 (setq thread (gnus-remove-thread id)))
2598 (setq current (save-excursion
2599 (and (zerop (forward-line -1))
2600 (gnus-summary-article-number))))
2601 ;; If this is a gathered thread, we have to go some re-gathering.
2602 (when (stringp (car thread))
2603 (let ((subject (car thread))
2605 (setq thread (cdr thread))
2607 (unless (memq (setq thr (gnus-id-to-thread
2609 (mail-header-id (caar thread)))))
2612 (setq thread (cdr thread)))
2613 ;; We now have all (unique) roots.
2614 (if (= (length roots) 1)
2615 ;; All the loose roots are now one solid root.
2616 (setq thread (car roots))
2617 (setq thread (cons subject (gnus-sort-threads roots))))))
2619 ;; We then insert this thread into the summary buffer.
2620 (let (gnus-newsgroup-data gnus-newsgroup-threads)
2621 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
2622 (setq data (nreverse gnus-newsgroup-data))
2623 (setq threads gnus-newsgroup-threads))
2624 ;; We splice the new data into the data structure.
2625 (gnus-data-enter-list current data)
2626 (gnus-data-compute-positions)
2627 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
2629 (defun gnus-number-to-header (number)
2630 "Return the header for article NUMBER."
2631 (let ((headers gnus-newsgroup-headers))
2633 (not (= number (mail-header-number (car headers)))))
2638 (defun gnus-parent-headers (headers &optional generation)
2639 "Return the headers of the GENERATIONeth parent of HEADERS."
2641 (setq generation 1))
2642 (let (references parent)
2643 (while (and headers (not (zerop generation)))
2644 (setq references (mail-header-references headers))
2645 (when (and references
2646 (setq parent (gnus-parent-id references))
2647 (setq headers (car (gnus-id-to-thread parent))))
2651 (defun gnus-id-to-thread (id)
2652 "Return the (sub-)thread where ID appears."
2653 (gnus-gethash id gnus-newsgroup-dependencies))
2655 (defun gnus-id-to-article (id)
2656 "Return the article number of ID."
2657 (let ((thread (gnus-id-to-thread id)))
2660 (mail-header-number (car thread)))))
2662 (defun gnus-id-to-header (id)
2663 "Return the article headers of ID."
2664 (car (gnus-id-to-thread id)))
2666 (defun gnus-article-displayed-root-p (article)
2667 "Say whether ARTICLE is a root(ish) article."
2668 (let ((level (gnus-summary-thread-level article))
2669 (refs (mail-header-references (gnus-summary-article-header article)))
2675 ((null (gnus-parent-id refs)) t)
2677 (null (setq particle (gnus-id-to-article
2678 (gnus-parent-id refs))))
2679 (null (gnus-summary-thread-level particle)))))))
2681 (defun gnus-root-id (id)
2682 "Return the id of the root of the thread where ID appears."
2684 (while (and id (setq prev (car (gnus-gethash
2685 id gnus-newsgroup-dependencies))))
2687 id (gnus-parent-id (mail-header-references prev))))
2690 (defun gnus-remove-thread (id &optional dont-remove)
2691 "Remove the thread that has ID in it."
2692 (let ((dep gnus-newsgroup-dependencies)
2693 headers thread last-id)
2694 ;; First go up in this thread until we find the root.
2695 (setq last-id (gnus-root-id id))
2696 (setq headers (list (car (gnus-id-to-thread last-id))
2697 (caadr (gnus-id-to-thread last-id))))
2698 ;; We have now found the real root of this thread. It might have
2699 ;; been gathered into some loose thread, so we have to search
2700 ;; through the threads to find the thread we wanted.
2701 (let ((threads gnus-newsgroup-threads)
2704 (setq sub (car threads))
2705 (if (stringp (car sub))
2706 ;; This is a gathered thread, so we look at the roots
2707 ;; below it to find whether this article is in this
2710 (setq sub (cdr sub))
2712 (when (member (caar sub) headers)
2713 (setq thread (car threads)
2716 (setq sub (cdr sub))))
2717 ;; It's an ordinary thread, so we check it.
2718 (when (eq (car sub) (car headers))
2721 (setq threads (cdr threads)))
2722 ;; If this article is in no thread, then it's a root.
2725 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
2726 (setq thread (gnus-gethash last-id dep)))
2729 thread ; We return this thread.
2731 (if (stringp (car thread))
2733 ;; If we use dummy roots, then we have to remove the
2734 ;; dummy root as well.
2735 (when (eq gnus-summary-make-false-root 'dummy)
2738 (setq thread (cdr thread))
2740 (gnus-remove-thread-1 (car thread))
2741 (setq thread (cdr thread))))
2742 (gnus-remove-thread-1 thread))))))))
2744 (defun gnus-remove-thread-1 (thread)
2745 "Remove the thread THREAD recursively."
2746 (let ((number (mail-header-number (car thread)))
2748 (when (setq pos (text-property-any
2749 (point-min) (point-max) 'gnus-number number))
2752 (gnus-data-remove number))
2753 (setq thread (cdr thread))
2755 (gnus-remove-thread-1 (pop thread)))))
2757 (defun gnus-sort-threads (threads)
2759 (if (not gnus-thread-sort-functions)
2761 (let ((func (if (= 1 (length gnus-thread-sort-functions))
2762 (car gnus-thread-sort-functions)
2764 ,(gnus-make-sort-function
2765 (reverse gnus-thread-sort-functions))))))
2766 (gnus-message 7 "Sorting threads...")
2769 (gnus-message 7 "Sorting threads...done")))))
2771 (defun gnus-sort-articles (articles)
2773 (when gnus-article-sort-functions
2774 (let ((func (if (= 1 (length gnus-article-sort-functions))
2775 (car gnus-article-sort-functions)
2777 ,(gnus-make-sort-function
2778 (reverse gnus-article-sort-functions))))))
2779 (gnus-message 7 "Sorting articles...")
2781 (setq gnus-newsgroup-headers (sort articles func))
2782 (gnus-message 7 "Sorting articles...done")))))
2784 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2785 (defmacro gnus-thread-header (thread)
2786 ;; Return header of first article in THREAD.
2787 ;; Note that THREAD must never, ever be anything else than a variable -
2788 ;; using some other form will lead to serious barfage.
2789 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
2790 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
2791 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
2794 (defsubst gnus-article-sort-by-number (h1 h2)
2795 "Sort articles by article number."
2796 (< (mail-header-number h1)
2797 (mail-header-number h2)))
2799 (defun gnus-thread-sort-by-number (h1 h2)
2800 "Sort threads by root article number."
2801 (gnus-article-sort-by-number
2802 (gnus-thread-header h1) (gnus-thread-header h2)))
2804 (defsubst gnus-article-sort-by-author (h1 h2)
2805 "Sort articles by root author."
2807 (let ((extract (funcall
2808 gnus-extract-address-components
2809 (mail-header-from h1))))
2810 (or (car extract) (cdr extract)))
2811 (let ((extract (funcall
2812 gnus-extract-address-components
2813 (mail-header-from h2))))
2814 (or (car extract) (cdr extract)))))
2816 (defun gnus-thread-sort-by-author (h1 h2)
2817 "Sort threads by root author."
2818 (gnus-article-sort-by-author
2819 (gnus-thread-header h1) (gnus-thread-header h2)))
2821 (defsubst gnus-article-sort-by-subject (h1 h2)
2822 "Sort articles by root subject."
2824 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
2825 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
2827 (defun gnus-thread-sort-by-subject (h1 h2)
2828 "Sort threads by root subject."
2829 (gnus-article-sort-by-subject
2830 (gnus-thread-header h1) (gnus-thread-header h2)))
2832 (defsubst gnus-article-sort-by-date (h1 h2)
2833 "Sort articles by root article date."
2835 (inline (gnus-sortable-date (mail-header-date h1)))
2836 (inline (gnus-sortable-date (mail-header-date h2)))))
2838 (defun gnus-thread-sort-by-date (h1 h2)
2839 "Sort threads by root article date."
2840 (gnus-article-sort-by-date
2841 (gnus-thread-header h1) (gnus-thread-header h2)))
2843 (defsubst gnus-article-sort-by-score (h1 h2)
2844 "Sort articles by root article score.
2845 Unscored articles will be counted as having a score of zero."
2846 (> (or (cdr (assq (mail-header-number h1)
2847 gnus-newsgroup-scored))
2848 gnus-summary-default-score 0)
2849 (or (cdr (assq (mail-header-number h2)
2850 gnus-newsgroup-scored))
2851 gnus-summary-default-score 0)))
2853 (defun gnus-thread-sort-by-score (h1 h2)
2854 "Sort threads by root article score."
2855 (gnus-article-sort-by-score
2856 (gnus-thread-header h1) (gnus-thread-header h2)))
2858 (defun gnus-thread-sort-by-total-score (h1 h2)
2859 "Sort threads by the sum of all scores in the thread.
2860 Unscored articles will be counted as having a score of zero."
2861 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
2863 (defun gnus-thread-total-score (thread)
2864 ;; This function find the total score of THREAD.
2865 (cond ((null thread)
2868 (if (stringp (car thread))
2869 (apply gnus-thread-score-function 0
2870 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
2871 (gnus-thread-total-score-1 thread)))
2873 (gnus-thread-total-score-1 (list thread)))))
2875 (defun gnus-thread-total-score-1 (root)
2876 ;; This function find the total score of the thread below ROOT.
2877 (setq root (car root))
2878 (apply gnus-thread-score-function
2880 (mapcar 'gnus-thread-total-score
2881 (cdr (gnus-gethash (mail-header-id root)
2882 gnus-newsgroup-dependencies)))
2883 (if (> (mail-header-number root) 0)
2884 (list (or (cdr (assq (mail-header-number root)
2885 gnus-newsgroup-scored))
2886 gnus-summary-default-score 0))))
2887 (list gnus-summary-default-score)
2890 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
2891 (defvar gnus-tmp-prev-subject nil)
2892 (defvar gnus-tmp-false-parent nil)
2893 (defvar gnus-tmp-root-expunged nil)
2894 (defvar gnus-tmp-dummy-line nil)
2896 (defun gnus-summary-prepare-threads (threads)
2897 "Prepare summary buffer from THREADS and indentation LEVEL.
2898 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
2899 or a straight list of headers."
2900 (gnus-message 7 "Generating summary...")
2902 (setq gnus-newsgroup-threads threads)
2905 (let ((gnus-tmp-level 0)
2906 (default-score (or gnus-summary-default-score 0))
2907 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
2908 thread number subject stack state gnus-tmp-gathered beg-match
2909 new-roots gnus-tmp-new-adopts thread-end
2910 gnus-tmp-header gnus-tmp-unread
2911 gnus-tmp-replied gnus-tmp-subject-or-nil
2912 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
2913 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
2914 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
2916 (setq gnus-tmp-prev-subject nil)
2918 (if (vectorp (car threads))
2919 ;; If this is a straight (sic) list of headers, then a
2920 ;; threaded summary display isn't required, so we just create
2921 ;; an unthreaded one.
2922 (gnus-summary-prepare-unthreaded threads)
2924 ;; Do the threaded display.
2926 (while (or threads stack gnus-tmp-new-adopts new-roots)
2928 (if (and (= gnus-tmp-level 0)
2929 (not (setq gnus-tmp-dummy-line nil))
2932 (not gnus-tmp-false-parent)
2933 (or gnus-tmp-new-adopts new-roots))
2934 (if gnus-tmp-new-adopts
2935 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
2936 thread (list (car gnus-tmp-new-adopts))
2937 gnus-tmp-header (caar thread)
2938 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
2940 (setq thread (list (car new-roots))
2941 gnus-tmp-header (caar thread)
2942 new-roots (cdr new-roots))))
2945 ;; If there are some threads, we do them before the
2946 ;; threads on the stack.
2947 (setq thread threads
2948 gnus-tmp-header (caar thread))
2949 ;; There were no current threads, so we pop something off
2951 (setq state (car stack)
2952 gnus-tmp-level (car state)
2955 gnus-tmp-header (caar thread))))
2957 (setq gnus-tmp-false-parent nil)
2958 (setq gnus-tmp-root-expunged nil)
2959 (setq thread-end nil)
2961 (if (stringp gnus-tmp-header)
2962 ;; The header is a dummy root.
2964 ((eq gnus-summary-make-false-root 'adopt)
2965 ;; We let the first article adopt the rest.
2966 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
2968 (setq gnus-tmp-gathered
2970 (lambda (h) (mail-header-number (car h)))
2973 (setq thread (cons (list (caar thread)
2976 (setq gnus-tmp-level -1
2977 gnus-tmp-false-parent t))
2978 ((eq gnus-summary-make-false-root 'empty)
2979 ;; We print adopted articles with empty subject fields.
2980 (setq gnus-tmp-gathered
2982 (lambda (h) (mail-header-number (car h)))
2985 (setq gnus-tmp-level -1))
2986 ((eq gnus-summary-make-false-root 'dummy)
2987 ;; We remember that we probably want to output a dummy
2989 (setq gnus-tmp-dummy-line gnus-tmp-header)
2990 (setq gnus-tmp-prev-subject gnus-tmp-header))
2992 ;; We do not make a root for the gathered
2993 ;; sub-threads at all.
2994 (setq gnus-tmp-level -1)))
2996 (setq number (mail-header-number gnus-tmp-header)
2997 subject (mail-header-subject gnus-tmp-header))
3000 ;; If the thread has changed subject, we might want to make
3001 ;; this subthread into a root.
3002 ((and (null gnus-thread-ignore-subject)
3003 (not (zerop gnus-tmp-level))
3004 gnus-tmp-prev-subject
3006 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3007 (setq new-roots (nconc new-roots (list (car thread)))
3009 gnus-tmp-header nil))
3010 ;; If the article lies outside the current limit,
3011 ;; then we do not display it.
3012 ((and (not (memq number gnus-newsgroup-limit))
3013 (not gnus-tmp-dummy-line))
3014 (setq gnus-tmp-gathered
3016 (lambda (h) (mail-header-number (car h)))
3019 (setq gnus-tmp-new-adopts (if (cdar thread)
3020 (append gnus-tmp-new-adopts
3022 gnus-tmp-new-adopts)
3024 gnus-tmp-header nil)
3025 (when (zerop gnus-tmp-level)
3026 (setq gnus-tmp-root-expunged t)))
3027 ;; Perhaps this article is to be marked as read?
3028 ((and gnus-summary-mark-below
3029 (< (or (cdr (assq number gnus-newsgroup-scored))
3031 gnus-summary-mark-below)
3032 ;; Don't touch sparse articles.
3033 (not (memq number gnus-newsgroup-sparse))
3034 (not (memq number gnus-newsgroup-ancient)))
3035 (setq gnus-newsgroup-unreads
3036 (delq number gnus-newsgroup-unreads))
3037 (if gnus-newsgroup-auto-expire
3038 (push number gnus-newsgroup-expirable)
3039 (push (cons number gnus-low-score-mark)
3040 gnus-newsgroup-reads))))
3042 (when gnus-tmp-header
3043 ;; We may have an old dummy line to output before this
3045 (when gnus-tmp-dummy-line
3046 (gnus-summary-insert-dummy-line
3047 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3048 (setq gnus-tmp-dummy-line nil))
3050 ;; Compute the mark.
3051 (setq gnus-tmp-unread (gnus-article-mark number))
3053 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3054 gnus-tmp-header gnus-tmp-level)
3055 gnus-newsgroup-data)
3057 ;; Actually insert the line.
3059 gnus-tmp-subject-or-nil
3061 ((and gnus-thread-ignore-subject
3062 gnus-tmp-prev-subject
3063 (not (inline (gnus-subject-equal
3064 gnus-tmp-prev-subject subject))))
3066 ((zerop gnus-tmp-level)
3067 (if (and (eq gnus-summary-make-false-root 'empty)
3068 (memq number gnus-tmp-gathered)
3069 gnus-tmp-prev-subject
3070 (inline (gnus-subject-equal
3071 gnus-tmp-prev-subject subject)))
3072 gnus-summary-same-subject
3074 (t gnus-summary-same-subject)))
3075 (if (and (eq gnus-summary-make-false-root 'adopt)
3076 (= gnus-tmp-level 1)
3077 (memq number gnus-tmp-gathered))
3078 (setq gnus-tmp-opening-bracket ?\<
3079 gnus-tmp-closing-bracket ?\>)
3080 (setq gnus-tmp-opening-bracket ?\[
3081 gnus-tmp-closing-bracket ?\]))
3083 gnus-tmp-indentation
3084 (aref gnus-thread-indent-array gnus-tmp-level)
3085 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3086 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3087 gnus-summary-default-score 0)
3089 (if (or (null gnus-summary-default-score)
3090 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3091 gnus-summary-zcore-fuzz)) ?
3092 (if (< gnus-tmp-score gnus-summary-default-score)
3093 gnus-score-below-mark gnus-score-over-mark))
3095 (cond ((memq number gnus-newsgroup-processable)
3097 ((memq number gnus-newsgroup-cached)
3099 ((memq number gnus-newsgroup-replied)
3101 ((memq number gnus-newsgroup-saved)
3103 (t gnus-unread-mark))
3104 gnus-tmp-from (mail-header-from gnus-tmp-header)
3107 ((string-match "(.+)" gnus-tmp-from)
3108 (substring gnus-tmp-from
3109 (1+ (match-beginning 0)) (1- (match-end 0))))
3110 ((string-match "<[^>]+> *$" gnus-tmp-from)
3111 (setq beg-match (match-beginning 0))
3112 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3113 (substring gnus-tmp-from (1+ (match-beginning 0))
3114 (1- (match-end 0))))
3115 (substring gnus-tmp-from 0 beg-match)))
3117 (when (string= gnus-tmp-name "")
3118 (setq gnus-tmp-name gnus-tmp-from))
3119 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
3120 (gnus-put-text-property
3122 (progn (eval gnus-summary-line-format-spec) (point))
3123 'gnus-number number)
3126 (run-hooks 'gnus-summary-update-hook)
3129 (setq gnus-tmp-prev-subject subject)))
3131 (when (nth 1 thread)
3132 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3133 (incf gnus-tmp-level)
3134 (setq threads (if thread-end nil (cdar thread)))
3136 (setq gnus-tmp-level 0)))))
3137 (gnus-message 7 "Generating summary...done"))
3139 (defun gnus-summary-prepare-unthreaded (headers)
3140 "Generate an unthreaded summary buffer based on HEADERS."
3141 (let (header number mark)
3144 ;; We may have to root out some bad articles...
3145 (when (memq (setq number (mail-header-number
3146 (setq header (pop headers))))
3147 gnus-newsgroup-limit)
3148 ;; Mark article as read when it has a low score.
3149 (when (and gnus-summary-mark-below
3150 (< (or (cdr (assq number gnus-newsgroup-scored))
3151 gnus-summary-default-score 0)
3152 gnus-summary-mark-below)
3153 (not (memq number gnus-newsgroup-ancient)))
3154 (setq gnus-newsgroup-unreads
3155 (delq number gnus-newsgroup-unreads))
3156 (if gnus-newsgroup-auto-expire
3157 (push number gnus-newsgroup-expirable)
3158 (push (cons number gnus-low-score-mark)
3159 gnus-newsgroup-reads)))
3161 (setq mark (gnus-article-mark number))
3162 (setq gnus-newsgroup-data
3163 (cons (gnus-data-make number mark (1+ (point)) header 0)
3164 gnus-newsgroup-data))
3165 (gnus-summary-insert-line
3166 header 0 nil mark (memq number gnus-newsgroup-replied)
3167 (memq number gnus-newsgroup-expirable)
3168 (mail-header-subject header) nil
3169 (cdr (assq number gnus-newsgroup-scored))
3170 (memq number gnus-newsgroup-processable))))))
3172 (defun gnus-select-newsgroup (group &optional read-all)
3173 "Select newsgroup GROUP.
3174 If READ-ALL is non-nil, all articles in the group are selected."
3175 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3176 (info (nth 2 entry))
3177 articles fetched-articles cached)
3179 (or (gnus-check-server
3180 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3181 (error "Couldn't open server"))
3183 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3184 (gnus-activate-group group) ; Or we can activate it...
3185 (progn ; Or we bug out.
3186 (when (equal major-mode 'gnus-summary-mode)
3187 (kill-buffer (current-buffer)))
3188 (error "Couldn't request group %s: %s"
3189 group (gnus-status-message group))))
3191 (unless (gnus-request-group group t)
3192 (when (equal major-mode 'gnus-summary-mode)
3193 (kill-buffer (current-buffer)))
3194 (error "Couldn't request group %s: %s"
3195 group (gnus-status-message group)))
3197 (setq gnus-newsgroup-name group)
3198 (setq gnus-newsgroup-unselected nil)
3199 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3201 ;; Adjust and set lists of article marks.
3203 (gnus-adjust-marked-articles info))
3205 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3206 (when (gnus-virtual-group-p group)
3207 (setq cached gnus-newsgroup-cached))
3209 (setq gnus-newsgroup-unreads
3210 (gnus-set-difference
3211 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3212 gnus-newsgroup-dormant))
3214 (setq gnus-newsgroup-processable nil)
3216 (setq articles (gnus-articles-to-read group read-all))
3220 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3222 ((eq articles 0) nil)
3224 ;; Init the dependencies hash table.
3225 (setq gnus-newsgroup-dependencies
3226 (gnus-make-hashtable (length articles)))
3227 ;; Retrieve the headers and read them in.
3228 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3229 (setq gnus-newsgroup-headers
3231 (setq gnus-headers-retrieved-by
3232 (gnus-retrieve-headers
3233 articles gnus-newsgroup-name
3234 ;; We might want to fetch old headers, but
3235 ;; not if there is only 1 article.
3236 (and gnus-fetch-old-headers
3238 (not (eq gnus-fetch-old-headers 'some))
3239 (not (numberp gnus-fetch-old-headers)))
3240 (> (length articles) 1))))))
3241 (gnus-get-newsgroup-headers-xover articles)
3242 (gnus-get-newsgroup-headers)))
3243 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3245 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3247 (setq gnus-newsgroup-cached cached))
3249 ;; Suppress duplicates?
3250 (when gnus-suppress-duplicates
3251 (gnus-dup-suppress-articles))
3253 ;; Set the initial limit.
3254 (setq gnus-newsgroup-limit (copy-sequence articles))
3255 ;; Remove canceled articles from the list of unread articles.
3256 (setq gnus-newsgroup-unreads
3257 (gnus-set-sorted-intersection
3258 gnus-newsgroup-unreads
3259 (setq fetched-articles
3260 (mapcar (lambda (headers) (mail-header-number headers))
3261 gnus-newsgroup-headers))))
3262 ;; Removed marked articles that do not exist.
3263 (gnus-update-missing-marks
3264 (gnus-sorted-complement fetched-articles articles))
3265 ;; We might want to build some more threads first.
3266 (and gnus-fetch-old-headers
3267 (eq gnus-headers-retrieved-by 'nov)
3268 (gnus-build-old-threads))
3269 ;; Check whether auto-expire is to be done in this group.
3270 (setq gnus-newsgroup-auto-expire
3271 (gnus-group-auto-expirable-p group))
3272 ;; Set up the article buffer now, if necessary.
3273 (unless gnus-single-article-buffer
3274 (gnus-article-setup-buffer))
3275 ;; First and last article in this newsgroup.
3276 (when gnus-newsgroup-headers
3277 (setq gnus-newsgroup-begin
3278 (mail-header-number (car gnus-newsgroup-headers))
3281 (gnus-last-element gnus-newsgroup-headers))))
3282 ;; GROUP is successfully selected.
3283 (or gnus-newsgroup-headers t)))))
3285 (defun gnus-articles-to-read (group read-all)
3286 ;; Find out what articles the user wants to read.
3288 ;; Select all articles if `read-all' is non-nil, or if there
3289 ;; are no unread articles.
3291 (and (zerop (length gnus-newsgroup-marked))
3292 (zerop (length gnus-newsgroup-unreads))))
3293 (gnus-uncompress-range (gnus-active group))
3294 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3295 (copy-sequence gnus-newsgroup-unreads))
3297 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3298 (scored (length scored-list))
3299 (number (length articles))
3300 (marked (+ (length gnus-newsgroup-marked)
3301 (length gnus-newsgroup-dormant)))
3309 ((and (or (<= scored marked) (= scored number))
3310 (numberp gnus-large-newsgroup)
3311 (> number gnus-large-newsgroup))
3315 "How many articles from %s (default %d): "
3316 gnus-newsgroup-name number))))
3317 (if (string-match "^[ \t]*$" input) number input)))
3318 ((and (> scored marked) (< scored number)
3319 (> (- scored number) 20))
3322 (format "%s %s (%d scored, %d total): "
3323 "How many articles from"
3324 group scored number))))
3325 (if (string-match "^[ \t]*$" input)
3329 (setq select (if (stringp select) (string-to-number select) select))
3330 (if (or (null select) (zerop select))
3332 (if (and (not (zerop scored)) (<= (abs select) scored))
3334 (setq articles (sort scored-list '<))
3335 (setq number (length articles)))
3336 (setq articles (copy-sequence articles)))
3338 (if (< (abs select) number)
3340 ;; Select the N oldest articles.
3341 (setcdr (nthcdr (1- (abs select)) articles) nil)
3342 ;; Select the N most recent articles.
3343 (setq articles (nthcdr (- number select) articles))))
3344 (setq gnus-newsgroup-unselected
3345 (gnus-sorted-intersection
3346 gnus-newsgroup-unreads
3347 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3350 (defun gnus-killed-articles (killed articles)
3353 (if (inline (gnus-member-of-range (car articles) killed))
3354 (setq out (cons (car articles) out)))
3355 (setq articles (cdr articles)))
3358 (defun gnus-uncompress-marks (marks)
3359 "Uncompress the mark ranges in MARKS."
3360 (let ((uncompressed '(score bookmark))
3363 (if (memq (caar marks) uncompressed)
3364 (push (car marks) out)
3365 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3366 (setq marks (cdr marks)))
3369 (defun gnus-adjust-marked-articles (info)
3370 "Set all article lists and remove all marks that are no longer legal."
3371 (let* ((marked-lists (gnus-info-marks info))
3372 (active (gnus-active (gnus-info-group info)))
3375 (types gnus-article-mark-lists)
3376 (uncompressed '(score bookmark killed))
3377 marks var articles article mark)
3380 (setq marks (pop marked-lists))
3381 (set (setq var (intern (format "gnus-newsgroup-%s"
3382 (car (rassq (setq mark (car marks))
3384 (if (memq (car marks) uncompressed) (cdr marks)
3385 (gnus-uncompress-range (cdr marks))))
3387 (setq articles (symbol-value var))
3389 ;; All articles have to be subsets of the active articles.
3391 ;; Adjust "simple" lists.
3392 ((memq mark '(tick dormant expirable reply save))
3394 (when (or (< (setq article (pop articles)) min) (> article max))
3395 (set var (delq article (symbol-value var))))))
3397 ((memq mark uncompressed)
3399 (when (or (not (consp (setq article (pop articles))))
3400 (< (car article) min)
3401 (> (car article) max))
3402 (set var (delq article (symbol-value var))))))))))
3404 (defun gnus-update-missing-marks (missing)
3405 "Go through the list of MISSING articles and remove them mark lists."
3407 (let ((types gnus-article-mark-lists)
3409 ;; Go through all types.
3411 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3412 (when (symbol-value var)
3413 ;; This list has articles. So we delete all missing articles
3417 (set var (delq (pop m) (symbol-value var)))))))))
3419 (defun gnus-update-marks ()
3420 "Enter the various lists of marked articles into the newsgroup info list."
3421 (let ((types gnus-article-mark-lists)
3422 (info (gnus-get-info gnus-newsgroup-name))
3423 (uncompressed '(score bookmark killed))
3424 type list newmarked symbol)
3426 ;; Add all marks lists that are non-nil to the list of marks lists.
3428 (setq type (pop types))
3429 (when (setq list (symbol-value
3431 (intern (format "gnus-newsgroup-%s"
3433 (push (cons (cdr type)
3434 (if (memq (cdr type) uncompressed) list
3435 (gnus-compress-sequence
3436 (set symbol (sort list '<)) t)))
3439 ;; Enter these new marks into the info of the group.
3441 (setcar (nthcdr 3 info) newmarked)
3442 ;; Add the marks lists to the end of the info.
3444 (setcdr (nthcdr 2 info) (list newmarked))))
3446 ;; Cut off the end of the info if there's nothing else there.
3450 (when (nthcdr (decf i) info)
3451 (setcdr (nthcdr i info) nil)))))))
3453 (defun gnus-set-mode-line (where)
3454 "This function sets the mode line of the article or summary buffers.
3455 If WHERE is `summary', the summary mode line format will be used."
3456 ;; Is this mode line one we keep updated?
3457 (when (memq where gnus-updated-mode-lines)
3460 ;; We evaluate this in the summary buffer since these
3461 ;; variables are buffer-local to that buffer.
3462 (set-buffer gnus-summary-buffer)
3463 ;; We bind all these variables that are used in the `eval' form
3465 (let* ((mformat (symbol-value
3467 (format "gnus-%s-mode-line-format-spec" where))))
3468 (gnus-tmp-group-name gnus-newsgroup-name)
3469 (gnus-tmp-article-number (or gnus-current-article 0))
3470 (gnus-tmp-unread gnus-newsgroup-unreads)
3471 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3472 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3473 (gnus-tmp-unread-and-unselected
3474 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3475 (zerop gnus-tmp-unselected)) "")
3476 ((zerop gnus-tmp-unselected)
3477 (format "{%d more}" gnus-tmp-unread-and-unticked))
3478 (t (format "{%d(+%d) more}"
3479 gnus-tmp-unread-and-unticked
3480 gnus-tmp-unselected))))
3482 (if (and gnus-current-headers
3483 (vectorp gnus-current-headers))
3484 (gnus-mode-string-quote
3485 (mail-header-subject gnus-current-headers)) ""))
3487 gnus-tmp-header);; passed as argument to any user-format-funcs
3488 (setq mode-string (eval mformat))
3489 (setq max-len (max 4 (if gnus-mode-non-string-length
3491 gnus-mode-non-string-length)
3492 (length mode-string))))
3493 ;; We might have to chop a bit of the string off...
3494 (when (> (length mode-string) max-len)
3496 (concat (gnus-truncate-string mode-string (- max-len 3))
3498 ;; Pad the mode string a bit.
3499 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3500 ;; Update the mode line.
3501 (setq mode-line-buffer-identification
3502 (gnus-mode-line-buffer-identification
3503 (list mode-string)))
3504 (set-buffer-modified-p t))))
3506 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3507 "Go through the HEADERS list and add all Xrefs to a hash table.
3508 The resulting hash table is returned, or nil if no Xrefs were found."
3509 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3510 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3511 (xref-hashtb (make-vector 63 0))
3512 start group entry number xrefs header)
3514 (setq header (pop headers))
3515 (when (and (setq xrefs (mail-header-xref header))
3516 (not (memq (setq number (mail-header-number header))
3519 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3520 (setq start (match-end 0))
3521 (setq group (if prefix
3522 (concat prefix (substring xrefs (match-beginning 1)
3524 (substring xrefs (match-beginning 1) (match-end 1))))
3526 (string-to-int (substring xrefs (match-beginning 2)
3528 (if (setq entry (gnus-gethash group xref-hashtb))
3529 (setcdr entry (cons number (cdr entry)))
3530 (gnus-sethash group (cons number nil) xref-hashtb)))))
3531 (and start xref-hashtb)))
3533 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3534 "Look through all the headers and mark the Xrefs as read."
3535 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3536 name entry info xref-hashtb idlist method nth4)
3538 (set-buffer gnus-group-buffer)
3539 (when (setq xref-hashtb
3540 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3543 (unless (string= from-newsgroup (setq name (symbol-name group)))
3544 (setq idlist (symbol-value group))
3545 ;; Dead groups are not updated.
3547 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3549 (if (stringp (setq nth4 (gnus-info-method info)))
3550 (setq nth4 (gnus-server-to-method nth4))))
3551 ;; Only do the xrefs if the group has the same
3552 ;; select method as the group we have just read.
3553 (or (gnus-methods-equal-p
3554 nth4 (gnus-find-method-for-group from-newsgroup))
3556 (equal nth4 (setq method (gnus-find-method-for-group
3558 (and (equal (car nth4) (car method))
3559 (equal (nth 1 nth4) (nth 1 method))))
3560 gnus-use-cross-reference
3561 (or (not (eq gnus-use-cross-reference t))
3563 ;; Only do cross-references on subscribed
3564 ;; groups, if that is what is wanted.
3565 (<= (gnus-info-level info) gnus-level-subscribed))
3566 (gnus-group-make-articles-read name idlist))))
3569 (defun gnus-group-make-articles-read (group articles)
3570 "Update the info of GROUP to say that only ARTICLES are unread."
3572 (entry (gnus-gethash group gnus-newsrc-hashtb))
3573 (info (nth 2 entry))
3574 (active (gnus-active group))
3576 ;; First peel off all illegal article numbers.
3578 (let ((ids articles)
3580 (while (setq id (pop ids))
3581 (when (and first (> id (cdr active)))
3582 ;; We'll end up in this situation in one particular
3583 ;; obscure situation. If you re-scan a group and get
3584 ;; a new article that is cross-posted to a different
3585 ;; group that has not been re-scanned, you might get
3586 ;; crossposted article that has a higher number than
3587 ;; Gnus believes possible. So we re-activate this
3588 ;; group as well. This might mean doing the
3589 ;; crossposting thingy will *increase* the number
3590 ;; of articles in some groups. Tsk, tsk.
3591 (setq active (or (gnus-activate-group group) active)))
3592 (when (or (> id (cdr active))
3593 (< id (car active)))
3594 (setq articles (delq id articles))))))
3597 (gnus-info-set-marks ,info ,(gnus-info-marks info))
3598 (gnus-info-set-read ,info ,(gnus-info-read info))
3599 (gnus-group-update-group group t)))
3600 ;; If the read list is nil, we init it.
3602 (null (gnus-info-read info))
3604 (gnus-info-set-read info (cons 1 (1- (car active)))))
3605 ;; Then we add the read articles to the range.
3610 (gnus-info-read info) (setq articles (sort articles '<)))))
3611 ;; Then we have to re-compute how many unread
3612 ;; articles there are in this group.
3616 (setq num (- (1+ (cdr active)) (car active))))
3617 ((not (listp (cdr range)))
3618 (setq num (- (cdr active) (- (1+ (cdr range))
3622 (if (numberp (car range))
3624 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
3625 (setq range (cdr range)))
3626 (setq num (- (cdr active) num))))
3627 ;; Update the number of unread articles.
3629 ;; Update the group buffer.
3630 (gnus-group-update-group group t))))
3632 (defun gnus-methods-equal-p (m1 m2)
3633 (let ((m1 (or m1 gnus-select-method))
3634 (m2 (or m2 gnus-select-method)))
3636 (and (eq (car m1) (car m2))
3637 (or (not (memq 'address (assoc (symbol-name (car m1))
3638 gnus-valid-select-methods)))
3639 (equal (nth 1 m1) (nth 1 m2)))))))
3641 (defsubst gnus-header-value ()
3642 (buffer-substring (match-end 0) (gnus-point-at-eol)))
3644 (defvar gnus-newsgroup-none-id 0)
3646 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
3647 (let ((cur nntp-server-buffer)
3650 (save-excursion (set-buffer gnus-summary-buffer)
3651 gnus-newsgroup-dependencies)))
3652 headers id id-dep ref-dep end ref)
3654 (set-buffer nntp-server-buffer)
3655 (run-hooks 'gnus-parse-headers-hook)
3656 (let ((case-fold-search t)
3657 in-reply-to header p lines)
3658 (goto-char (point-min))
3659 ;; Search to the beginning of the next header. Error messages
3660 ;; do not begin with 2 or 3.
3661 (while (re-search-forward "^[23][0-9]+ " nil t)
3664 ;; This implementation of this function, with nine
3665 ;; search-forwards instead of the one re-search-forward and
3666 ;; a case (which basically was the old function) is actually
3667 ;; about twice as fast, even though it looks messier. You
3668 ;; can't have everything, I guess. Speed and elegance
3669 ;; doesn't always go hand in hand.
3678 (narrow-to-region (point)
3679 (or (and (search-forward "\n.\n" nil t)
3685 (if (search-forward "\nsubject: " nil t)
3686 (gnus-header-value) "(none)"))
3690 (if (search-forward "\nfrom: " nil t)
3691 (gnus-header-value) "(nobody)"))
3695 (if (search-forward "\ndate: " nil t)
3696 (gnus-header-value) ""))
3700 (if (search-forward "\nmessage-id: " nil t)
3701 (setq id (gnus-header-value))
3702 ;; If there was no message-id, we just fake one to make
3703 ;; subsequent routines simpler.
3704 (setq id (concat "none+"
3706 (setq gnus-newsgroup-none-id
3707 (1+ gnus-newsgroup-none-id)))))))
3711 (if (search-forward "\nreferences: " nil t)
3720 (search-backward ">" end t)
3723 (search-backward "<" end t)
3725 ;; Get the references from the in-reply-to header if there
3726 ;; were no references and the in-reply-to header looks
3728 (if (and (search-forward "\nin-reply-to: " nil t)
3729 (setq in-reply-to (gnus-header-value))
3730 (string-match "<[^>]+>" in-reply-to))
3731 (setq ref (substring in-reply-to (match-beginning 0)
3739 (if (search-forward "\nlines: " nil t)
3740 (if (numberp (setq lines (read cur)))
3746 (and (search-forward "\nxref: " nil t)
3747 (gnus-header-value)))))
3748 ;; We do the threading while we read the headers. The
3749 ;; message-id and the last reference are both entered into
3750 ;; the same hash table. Some tippy-toeing around has to be
3751 ;; done in case an article has arrived before the article
3752 ;; which it refers to.
3753 (if (boundp (setq id-dep (intern id dependencies)))
3754 (if (and (car (symbol-value id-dep))
3756 ;; An article with this Message-ID has already
3757 ;; been seen, so we ignore this one, except we add
3758 ;; any additional Xrefs (in case the two articles
3759 ;; came from different servers).
3761 (mail-header-set-xref
3762 (car (symbol-value id-dep))
3763 (concat (or (mail-header-xref
3764 (car (symbol-value id-dep))) "")
3765 (or (mail-header-xref header) "")))
3767 (setcar (symbol-value id-dep) header))
3768 (set id-dep (list header)))
3770 (if (boundp (setq ref-dep (intern ref dependencies)))
3771 (setcdr (symbol-value ref-dep)
3772 (nconc (cdr (symbol-value ref-dep))
3773 (list (symbol-value id-dep))))
3774 (set ref-dep (list nil (symbol-value id-dep))))
3775 (setq headers (cons header headers)))
3776 (goto-char (point-max))
3778 (nreverse headers)))))
3780 ;; The following macros and functions were written by Felix Lee
3781 ;; <flee@cse.psu.edu>.
3783 (defmacro gnus-nov-read-integer ()
3785 (if (= (following-char) ?\t)
3787 (let ((num (condition-case nil (read buffer) (error nil))))
3788 (if (numberp num) num 0)))
3789 (or (eobp) (forward-char 1))))
3791 (defmacro gnus-nov-skip-field ()
3792 '(search-forward "\t" eol 'move))
3794 (defmacro gnus-nov-field ()
3795 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3797 ;; Goes through the xover lines and returns a list of vectors
3798 (defun gnus-get-newsgroup-headers-xover (sequence &optional
3799 force-new dependencies)
3800 "Parse the news overview data in the server buffer, and return a
3801 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
3802 ;; Get the Xref when the users reads the articles since most/some
3803 ;; NNTP servers do not include Xrefs when using XOVER.
3804 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
3805 (let ((cur nntp-server-buffer)
3806 (dependencies (or dependencies gnus-newsgroup-dependencies))
3807 number headers header)
3809 (set-buffer nntp-server-buffer)
3810 ;; Allow the user to mangle the headers before parsing them.
3811 (run-hooks 'gnus-parse-headers-hook)
3812 (goto-char (point-min))
3813 (while (and sequence (not (eobp)))
3814 (setq number (read cur))
3815 (while (and sequence (< (car sequence) number))
3816 (setq sequence (cdr sequence)))
3818 (eq number (car sequence))
3820 (setq sequence (cdr sequence))
3822 (inline (gnus-nov-parse-line
3823 number dependencies force-new)))
3824 (setq headers (cons header headers)))))
3826 (setq headers (nreverse headers)))
3829 ;; This function has to be called with point after the article number
3830 ;; on the beginning of the line.
3831 (defun gnus-nov-parse-line (number dependencies &optional force-new)
3833 (eol (gnus-point-at-eol))
3834 (buffer (current-buffer))
3835 header ref id id-dep ref-dep)
3837 ;; overview: [num subject from date id refs chars lines misc]
3838 (narrow-to-region (point) eol)
3839 (or (eobp) (forward-char))
3845 (gnus-nov-field) ; subject
3846 (gnus-nov-field) ; from
3847 (gnus-nov-field) ; date
3848 (setq id (or (gnus-nov-field)
3851 (setq none (1+ none)))))) ; id
3854 (let ((beg (point)))
3855 (search-forward "\t" eol)
3856 (if (search-backward ">" beg t)
3860 (search-backward "<" beg t)))
3862 (gnus-nov-field)) ; refs
3863 (gnus-nov-read-integer) ; chars
3864 (gnus-nov-read-integer) ; lines
3865 (if (= (following-char) ?\n)
3867 (gnus-nov-field)) ; misc
3870 (gnus-error 4 "Strange nov line")
3876 ;; We build the thread tree.
3878 (if (boundp (setq id-dep (intern id dependencies)))
3879 (if (and (car (symbol-value id-dep))
3881 ;; An article with this Message-ID has already been seen,
3882 ;; so we ignore this one, except we add any additional
3883 ;; Xrefs (in case the two articles came from different
3886 (mail-header-set-xref
3887 (car (symbol-value id-dep))
3888 (concat (or (mail-header-xref
3889 (car (symbol-value id-dep))) "")
3890 (or (mail-header-xref header) "")))
3892 (setcar (symbol-value id-dep) header))
3893 (set id-dep (list header))))
3895 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
3896 (setcdr (symbol-value ref-dep)
3897 (nconc (cdr (symbol-value ref-dep))
3898 (list (symbol-value id-dep))))
3899 (set ref-dep (list nil (symbol-value id-dep)))))
3902 (defun gnus-article-get-xrefs ()
3903 "Fill in the Xref value in `gnus-current-headers', if necessary.
3904 This is meant to be called in `gnus-article-internal-prepare-hook'."
3905 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
3906 gnus-current-headers)))
3907 (or (not gnus-use-cross-reference)
3909 (and (mail-header-xref headers)
3910 (not (string= (mail-header-xref headers) "")))
3911 (let ((case-fold-search t)
3914 (nnheader-narrow-to-headers)
3915 (goto-char (point-min))
3916 (if (or (and (eq (downcase (following-char)) ?x)
3917 (looking-at "Xref:"))
3918 (search-forward "\nXref:" nil t))
3920 (goto-char (1+ (match-end 0)))
3921 (setq xref (buffer-substring (point)
3922 (progn (end-of-line) (point))))
3923 (mail-header-set-xref headers xref))))))))
3925 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
3926 "Find article ID and insert the summary line for that article."
3927 (let ((header (if (and old-header use-old-header)
3928 old-header (gnus-read-header id)))
3929 (number (and (numberp id) id))
3932 ;; Rebuild the thread that this article is part of and go to the
3933 ;; article we have fetched.
3934 (when (and (not gnus-show-threads)
3936 (when (setq pos (text-property-any
3937 (point-min) (point-max) 'gnus-number
3938 (mail-header-number old-header)))
3941 (gnus-data-remove (mail-header-number old-header))))
3943 (mail-header-set-number header (mail-header-number old-header)))
3944 (setq gnus-newsgroup-sparse
3945 (delq (setq number (mail-header-number header))
3946 gnus-newsgroup-sparse))
3947 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
3948 (gnus-rebuild-thread (mail-header-id header))
3949 (gnus-summary-goto-subject number nil t))
3950 (when (and (numberp number)
3952 ;; We have to update the boundaries even if we can't fetch the
3953 ;; article if ID is a number -- so that the next `P' or `N'
3954 ;; command will fetch the previous (or next) article even
3955 ;; if the one we tried to fetch this time has been canceled.
3956 (and (> number gnus-newsgroup-end)
3957 (setq gnus-newsgroup-end number))
3958 (and (< number gnus-newsgroup-begin)
3959 (setq gnus-newsgroup-begin number))
3960 (setq gnus-newsgroup-unselected
3961 (delq number gnus-newsgroup-unselected)))
3962 ;; Report back a success?
3963 (and header (mail-header-number header))))
3965 ;;; Process/prefix in the summary buffer
3967 (defun gnus-summary-work-articles (n)
3968 "Return a list of articles to be worked upon. The prefix argument,
3969 the list of process marked articles, and the current article will be
3970 taken into consideration."
3973 ;; A numerical prefix has been given.
3974 (let ((backward (< n 0))
3975 (n (abs (prefix-numeric-value n)))
3980 (push (setq article (gnus-summary-article-number))
3983 (gnus-summary-find-prev nil article)
3984 (gnus-summary-find-next nil article)))
3986 (nreverse articles)))
3987 ((and (boundp 'transient-mark-mode)
3990 ;; Work on the region between point and mark.
3991 (let ((max (max (point) (mark)))
3994 (goto-char (min (point) (mark)))
3997 (push (setq article (gnus-summary-article-number)) articles)
3998 (gnus-summary-find-next nil article)
4000 (nreverse articles))))
4001 (gnus-newsgroup-processable
4002 ;; There are process-marked articles present.
4003 ;; Save current state.
4004 (gnus-summary-save-process-mark)
4006 (reverse gnus-newsgroup-processable))
4008 ;; Just return the current article.
4009 (list (gnus-summary-article-number)))))
4011 (defun gnus-summary-save-process-mark ()
4012 "Push the current set of process marked articles on the stack."
4014 (push (copy-sequence gnus-newsgroup-processable)
4015 gnus-newsgroup-process-stack))
4017 (defun gnus-summary-kill-process-mark ()
4018 "Push the current set of process marked articles on the stack and unmark."
4020 (gnus-summary-save-process-mark)
4021 (gnus-summary-unmark-all-processable))
4023 (defun gnus-summary-yank-process-mark ()
4024 "Pop the last process mark state off the stack and restore it."
4026 (unless gnus-newsgroup-process-stack
4027 (error "Empty mark stack"))
4028 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4030 (defun gnus-summary-process-mark-set (set)
4031 "Make SET into the current process marked articles."
4032 (gnus-summary-unmark-all-processable)
4034 (gnus-summary-set-process-mark (pop set))))
4036 ;;; Searching and stuff
4038 (defun gnus-summary-search-group (&optional backward use-level)
4039 "Search for next unread newsgroup.
4040 If optional argument BACKWARD is non-nil, search backward instead."
4042 (set-buffer gnus-group-buffer)
4043 (if (gnus-group-search-forward
4044 backward nil (if use-level (gnus-group-group-level) nil))
4045 (gnus-group-group-name))))
4047 (defun gnus-summary-best-group (&optional exclude-group)
4048 "Find the name of the best unread group.
4049 If EXCLUDE-GROUP, do not go to this group."
4051 (set-buffer gnus-group-buffer)
4053 (gnus-group-best-unread-group exclude-group))))
4055 (defun gnus-summary-find-next (&optional unread article backward)
4056 (if backward (gnus-summary-find-prev)
4057 (let* ((dummy (gnus-summary-article-intangible-p))
4058 (article (or article (gnus-summary-article-number)))
4059 (arts (gnus-data-find-list article))
4061 (when (and (not dummy)
4062 (or (not gnus-summary-check-current)
4064 (not (gnus-data-unread-p (car arts)))))
4065 (setq arts (cdr arts)))
4070 (when (gnus-data-unread-p (car arts))
4071 (setq result (car arts)
4073 (setq arts (cdr arts)))
4076 (goto-char (gnus-data-pos result))
4077 (gnus-data-number result)))))
4079 (defun gnus-summary-find-prev (&optional unread article)
4080 (let* ((eobp (eobp))
4081 (article (or article (gnus-summary-article-number)))
4082 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4084 (when (and (not eobp)
4085 (or (not gnus-summary-check-current)
4087 (not (gnus-data-unread-p (car arts)))))
4088 (setq arts (cdr arts)))
4093 (and (gnus-data-unread-p (car arts))
4094 (setq result (car arts)
4096 (setq arts (cdr arts)))
4100 (goto-char (gnus-data-pos result))
4101 (gnus-data-number result)))))
4103 (defun gnus-summary-find-subject (subject &optional unread backward article)
4104 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4105 (article (or article (gnus-summary-article-number)))
4106 (articles (gnus-data-list backward))
4107 (arts (gnus-data-find-list article articles))
4109 (when (or (not gnus-summary-check-current)
4111 (not (gnus-data-unread-p (car arts))))
4112 (setq arts (cdr arts)))
4114 (and (or (not unread)
4115 (gnus-data-unread-p (car arts)))
4116 (vectorp (gnus-data-header (car arts)))
4118 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4119 (setq result (car arts)
4121 (setq arts (cdr arts)))
4123 (goto-char (gnus-data-pos result))
4124 (gnus-data-number result))))
4126 (defun gnus-summary-search-forward (&optional unread subject backward)
4127 "Search forward for an article.
4128 If UNREAD, look for unread articles. If SUBJECT, look for
4129 articles with that subject. If BACKWARD, search backward instead."
4130 (cond (subject (gnus-summary-find-subject subject unread backward))
4131 (backward (gnus-summary-find-prev unread))
4132 (t (gnus-summary-find-next unread))))
4134 (defun gnus-recenter (&optional n)
4135 "Center point in window and redisplay frame.
4136 Also do horizontal recentering."
4138 (when (and gnus-auto-center-summary
4139 (not (eq gnus-auto-center-summary 'vertical)))
4140 (gnus-horizontal-recenter))
4143 (defun gnus-summary-recenter ()
4144 "Center point in the summary window.
4145 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4146 displayed, no centering will be performed."
4147 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4148 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4149 (let* ((top (cond ((< (window-height) 4) 0)
4150 ((< (window-height) 7) 1)
4152 (height (1- (window-height)))
4153 (bottom (save-excursion (goto-char (point-max))
4154 (forward-line (- height))
4156 (window (get-buffer-window (current-buffer))))
4157 ;; The user has to want it.
4158 (when gnus-auto-center-summary
4159 (when (get-buffer-window gnus-article-buffer)
4160 ;; Only do recentering when the article buffer is displayed,
4161 ;; Set the window start to either `bottom', which is the biggest
4162 ;; possible valid number, or the second line from the top,
4163 ;; whichever is the least.
4165 window (min bottom (save-excursion
4166 (forward-line (- top)) (point)))))
4167 ;; Do horizontal recentering while we're at it.
4168 (when (and (get-buffer-window (current-buffer) t)
4169 (not (eq gnus-auto-center-summary 'vertical)))
4170 (let ((selected (selected-window)))
4171 (select-window (get-buffer-window (current-buffer) t))
4172 (gnus-summary-position-point)
4173 (gnus-horizontal-recenter)
4174 (select-window selected))))))
4176 (defun gnus-summary-jump-to-group (newsgroup)
4177 "Move point to NEWSGROUP in group mode buffer."
4178 ;; Keep update point of group mode buffer if visible.
4179 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4180 (save-window-excursion
4181 ;; Take care of tree window mode.
4182 (if (get-buffer-window gnus-group-buffer)
4183 (pop-to-buffer gnus-group-buffer))
4184 (gnus-group-jump-to-group newsgroup))
4186 ;; Take care of tree window mode.
4187 (if (get-buffer-window gnus-group-buffer)
4188 (pop-to-buffer gnus-group-buffer)
4189 (set-buffer gnus-group-buffer))
4190 (gnus-group-jump-to-group newsgroup))))
4192 ;; This function returns a list of article numbers based on the
4193 ;; difference between the ranges of read articles in this group and
4194 ;; the range of active articles.
4195 (defun gnus-list-of-unread-articles (group)
4196 (let* ((read (gnus-info-read (gnus-get-info group)))
4197 (active (gnus-active group))
4200 ;; If none are read, then all are unread.
4202 (setq first (car active))
4203 ;; If the range of read articles is a single range, then the
4204 ;; first unread article is the article after the last read
4205 ;; article. Sounds logical, doesn't it?
4206 (if (not (listp (cdr read)))
4207 (setq first (1+ (cdr read)))
4208 ;; `read' is a list of ranges.
4209 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
4214 (while (< first nlast)
4215 (setq unread (cons first unread))
4216 (setq first (1+ first))))
4217 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4218 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4219 (setq read (cdr read)))))
4220 ;; And add the last unread articles.
4221 (while (<= first last)
4222 (setq unread (cons first unread))
4223 (setq first (1+ first)))
4224 ;; Return the list of unread articles.
4227 (defun gnus-list-of-read-articles (group)
4228 "Return a list of unread, unticked and non-dormant articles."
4229 (let* ((info (gnus-get-info group))
4230 (marked (gnus-info-marks info))
4231 (active (gnus-active group)))
4233 (gnus-set-difference
4234 (gnus-sorted-complement
4235 (gnus-uncompress-range active)
4236 (gnus-list-of-unread-articles group))
4238 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4239 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4241 ;; Various summary commands
4243 (defun gnus-summary-universal-argument (arg)
4244 "Perform any operation on all articles that are process/prefixed."
4246 (gnus-set-global-variables)
4247 (let ((articles (gnus-summary-work-articles arg))
4254 (substitute-command-keys
4255 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4258 (gnus-error 1 "Undefined key")
4261 (gnus-summary-goto-subject (setq article (pop articles)))
4262 (command-execute func)
4263 (gnus-summary-remove-process-mark article)))))
4264 (gnus-summary-position-point))
4266 (defun gnus-summary-toggle-truncation (&optional arg)
4267 "Toggle truncation of summary lines.
4268 With arg, turn line truncation on iff arg is positive."
4270 (setq truncate-lines
4271 (if (null arg) (not truncate-lines)
4272 (> (prefix-numeric-value arg) 0)))
4275 (defun gnus-summary-reselect-current-group (&optional all rescan)
4276 "Exit and then reselect the current newsgroup.
4277 The prefix argument ALL means to select all articles."
4279 (gnus-set-global-variables)
4280 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4281 (error "Ephemeral groups can't be reselected"))
4282 (let ((current-subject (gnus-summary-article-number))
4283 (group gnus-newsgroup-name))
4284 (setq gnus-newsgroup-begin nil)
4286 ;; We have to adjust the point of group mode buffer because the
4287 ;; current point was moved to the next unread newsgroup by
4289 (gnus-summary-jump-to-group group)
4292 (gnus-group-get-new-news-this-group 1)))
4293 (gnus-group-read-group all t)
4294 (gnus-summary-goto-subject current-subject nil t)))
4296 (defun gnus-summary-rescan-group (&optional all)
4297 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4299 (gnus-summary-reselect-current-group all t))
4301 (defun gnus-summary-update-info ()
4302 (let ((group gnus-newsgroup-name))
4303 (when gnus-newsgroup-kill-headers
4304 (setq gnus-newsgroup-killed
4305 (gnus-compress-sequence
4307 (gnus-set-sorted-intersection
4308 (gnus-uncompress-range gnus-newsgroup-killed)
4309 (setq gnus-newsgroup-unselected
4310 (sort gnus-newsgroup-unselected '<)))
4311 (setq gnus-newsgroup-unreads
4312 (sort gnus-newsgroup-unreads '<))) t)))
4313 (unless (listp (cdr gnus-newsgroup-killed))
4314 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4315 (let ((headers gnus-newsgroup-headers))
4316 (run-hooks 'gnus-exit-group-hook)
4317 (unless gnus-save-score
4318 (setq gnus-newsgroup-scored nil))
4319 ;; Set the new ranges of read articles.
4320 (gnus-update-read-articles
4321 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4322 ;; Set the current article marks.
4324 ;; Do the cross-ref thing.
4325 (when gnus-use-cross-reference
4326 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4327 ;; Do adaptive scoring, and possibly save score files.
4328 (when gnus-newsgroup-adaptive
4329 (gnus-score-adaptive))
4330 (when gnus-use-scoring
4332 ;; Do not switch windows but change the buffer to work.
4333 (set-buffer gnus-group-buffer)
4334 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4335 (gnus-group-update-group group)))))
4337 (defun gnus-summary-exit (&optional temporary)
4338 "Exit reading current newsgroup, and then return to group selection mode.
4339 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4341 (gnus-set-global-variables)
4342 (gnus-kill-save-kill-buffer)
4343 (let* ((group gnus-newsgroup-name)
4344 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4346 (buf (current-buffer)))
4347 (run-hooks 'gnus-summary-prepare-exit-hook)
4348 ;; If we have several article buffers, we kill them at exit.
4349 (unless gnus-single-article-buffer
4350 (gnus-kill-buffer gnus-original-article-buffer)
4351 (setq gnus-article-current nil))
4352 (when gnus-use-cache
4353 (gnus-cache-possibly-remove-articles)
4354 (gnus-cache-save-buffers))
4355 (gnus-async-prefetch-remove-group group)
4356 (when gnus-suppress-duplicates
4357 (gnus-dup-enter-articles))
4358 (when gnus-use-trees
4359 (gnus-tree-close group))
4360 ;; Make all changes in this group permanent.
4362 (gnus-summary-update-info))
4363 (gnus-close-group group)
4364 ;; Make sure where I was, and go to next newsgroup.
4365 (set-buffer gnus-group-buffer)
4367 (gnus-group-jump-to-group group))
4368 (run-hooks 'gnus-summary-exit-hook)
4370 (gnus-group-next-unread-group 1))
4373 ;; If we have several article buffers, we kill them at exit.
4374 (unless gnus-single-article-buffer
4375 (gnus-kill-buffer gnus-article-buffer)
4376 (gnus-kill-buffer gnus-original-article-buffer)
4377 (setq gnus-article-current nil))
4379 (if (not gnus-kill-summary-on-exit)
4380 (gnus-deaden-summary)
4381 ;; We set all buffer-local variables to nil. It is unclear why
4382 ;; this is needed, but if we don't, buffer-local variables are
4383 ;; not garbage-collected, it seems. This would the lead to en
4384 ;; ever-growing Emacs.
4385 (gnus-summary-clear-local-variables)
4386 (when (get-buffer gnus-article-buffer)
4387 (bury-buffer gnus-article-buffer))
4388 ;; We clear the global counterparts of the buffer-local
4389 ;; variables as well, just to be on the safe side.
4390 (gnus-configure-windows 'group 'force)
4391 (gnus-summary-clear-local-variables)
4392 ;; Return to group mode buffer.
4393 (if (eq mode 'gnus-summary-mode)
4394 (gnus-kill-buffer buf)))
4395 (setq gnus-current-select-method gnus-select-method)
4396 (pop-to-buffer gnus-group-buffer)
4397 ;; Clear the current group name.
4398 (if (not quit-config)
4400 (gnus-group-jump-to-group group)
4401 (gnus-group-next-unread-group 1)
4402 (gnus-configure-windows 'group 'force))
4403 (if (not (buffer-name (car quit-config)))
4404 (gnus-configure-windows 'group 'force)
4405 (set-buffer (car quit-config))
4406 (and (eq major-mode 'gnus-summary-mode)
4407 (gnus-set-global-variables))
4408 (gnus-configure-windows (cdr quit-config))))
4410 (setq gnus-newsgroup-name nil)))))
4412 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4413 (defun gnus-summary-exit-no-update (&optional no-questions)
4414 "Quit reading current newsgroup without updating read article info."
4416 (gnus-set-global-variables)
4417 (let* ((group gnus-newsgroup-name)
4418 (quit-config (gnus-group-quit-config group)))
4419 (when (or no-questions
4421 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4422 ;; If we have several article buffers, we kill them at exit.
4423 (unless gnus-single-article-buffer
4424 (gnus-kill-buffer gnus-article-buffer)
4425 (gnus-kill-buffer gnus-original-article-buffer)
4426 (setq gnus-article-current nil))
4427 (if (not gnus-kill-summary-on-exit)
4428 (gnus-deaden-summary)
4429 (gnus-close-group group)
4430 (gnus-summary-clear-local-variables)
4431 (set-buffer gnus-group-buffer)
4432 (gnus-summary-clear-local-variables)
4433 (when (get-buffer gnus-summary-buffer)
4434 (kill-buffer gnus-summary-buffer)))
4435 (unless gnus-single-article-buffer
4436 (setq gnus-article-current nil))
4437 (when gnus-use-trees
4438 (gnus-tree-close group))
4439 (gnus-async-prefetch-remove-group group)
4440 (when (get-buffer gnus-article-buffer)
4441 (bury-buffer gnus-article-buffer))
4442 ;; Return to the group buffer.
4443 (gnus-configure-windows 'group 'force)
4444 ;; Clear the current group name.
4445 (setq gnus-newsgroup-name nil)
4446 (when (equal (gnus-group-group-name) group)
4447 (gnus-group-next-unread-group 1))
4449 (if (not (buffer-name (car quit-config)))
4450 (gnus-configure-windows 'group 'force)
4451 (set-buffer (car quit-config))
4452 (when (eq major-mode 'gnus-summary-mode)
4453 (gnus-set-global-variables))
4454 (gnus-configure-windows (cdr quit-config)))))))
4458 (defvar gnus-dead-summary-mode-map nil)
4460 (if gnus-dead-summary-mode-map
4462 (setq gnus-dead-summary-mode-map (make-keymap))
4463 (suppress-keymap gnus-dead-summary-mode-map)
4464 (substitute-key-definition
4465 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4466 (let ((keys '("\C-d" "\r" "\177")))
4468 (define-key gnus-dead-summary-mode-map
4469 (pop keys) 'gnus-summary-wake-up-the-dead))))
4471 (defvar gnus-dead-summary-mode nil
4472 "Minor mode for Gnus summary buffers.")
4474 (defun gnus-dead-summary-mode (&optional arg)
4475 "Minor mode for Gnus summary buffers."
4477 (when (eq major-mode 'gnus-summary-mode)
4478 (make-local-variable 'gnus-dead-summary-mode)
4479 (setq gnus-dead-summary-mode
4480 (if (null arg) (not gnus-dead-summary-mode)
4481 (> (prefix-numeric-value arg) 0)))
4482 (when gnus-dead-summary-mode
4483 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4484 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4485 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4486 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4487 minor-mode-map-alist)))))
4489 (defun gnus-deaden-summary ()
4490 "Make the current summary buffer into a dead summary buffer."
4491 ;; Kill any previous dead summary buffer.
4492 (when (and gnus-dead-summary
4493 (buffer-name gnus-dead-summary))
4495 (set-buffer gnus-dead-summary)
4496 (when gnus-dead-summary-mode
4497 (kill-buffer (current-buffer)))))
4498 ;; Make this the current dead summary.
4499 (setq gnus-dead-summary (current-buffer))
4500 (gnus-dead-summary-mode 1)
4501 (let ((name (buffer-name)))
4502 (when (string-match "Summary" name)
4504 (concat (substring name 0 (match-beginning 0)) "Dead "
4505 (substring name (match-beginning 0))) t))))
4507 (defun gnus-kill-or-deaden-summary (buffer)
4508 "Kill or deaden the summary BUFFER."
4509 (when (and (buffer-name buffer)
4510 (not gnus-single-article-buffer))
4513 (gnus-kill-buffer gnus-article-buffer)
4514 (gnus-kill-buffer gnus-original-article-buffer)))
4515 (cond (gnus-kill-summary-on-exit
4516 (when (and gnus-use-trees
4517 (and (get-buffer buffer)
4518 (buffer-name (get-buffer buffer))))
4520 (set-buffer (get-buffer buffer))
4521 (gnus-tree-close gnus-newsgroup-name)))
4522 (gnus-kill-buffer buffer))
4523 ((and (get-buffer buffer)
4524 (buffer-name (get-buffer buffer)))
4527 (gnus-deaden-summary)))))
4529 (defun gnus-summary-wake-up-the-dead (&rest args)
4530 "Wake up the dead summary buffer."
4532 (gnus-dead-summary-mode -1)
4533 (let ((name (buffer-name)))
4534 (when (string-match "Dead " name)
4536 (concat (substring name 0 (match-beginning 0))
4537 (substring name (match-end 0))) t)))
4538 (gnus-message 3 "This dead summary is now alive again"))
4540 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
4541 (defun gnus-summary-fetch-faq (&optional faq-dir)
4542 "Fetch the FAQ for the current group.
4543 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
4547 (if current-prefix-arg
4549 "Faq dir: " (and (listp gnus-group-faq-directory)
4550 gnus-group-faq-directory)))))
4551 (let (gnus-faq-buffer)
4552 (and (setq gnus-faq-buffer
4553 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
4554 (gnus-configure-windows 'summary-faq))))
4556 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4557 (defun gnus-summary-describe-group (&optional force)
4558 "Describe the current newsgroup."
4560 (gnus-group-describe-group force gnus-newsgroup-name))
4562 (defun gnus-summary-describe-briefly ()
4563 "Describe summary mode commands briefly."
4566 (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")))
4568 ;; Walking around group mode buffer from summary mode.
4570 (defun gnus-summary-next-group (&optional no-article target-group backward)
4571 "Exit current newsgroup and then select next unread newsgroup.
4572 If prefix argument NO-ARTICLE is non-nil, no article is selected
4573 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
4574 previous group instead."
4576 (gnus-set-global-variables)
4577 (let ((current-group gnus-newsgroup-name)
4578 (current-buffer (current-buffer))
4580 ;; First we semi-exit this group to update Xrefs and all variables.
4581 ;; We can't do a real exit, because the window conf must remain
4582 ;; the same in case the user is prompted for info, and we don't
4583 ;; want the window conf to change before that...
4584 (gnus-summary-exit t)
4585 (while (not entered)
4586 ;; Then we find what group we are supposed to enter.
4587 (set-buffer gnus-group-buffer)
4588 (gnus-group-jump-to-group current-group)
4591 (if (eq gnus-keep-same-level 'best)
4592 (gnus-summary-best-group gnus-newsgroup-name)
4593 (gnus-summary-search-group backward gnus-keep-same-level))))
4594 (if (not target-group)
4595 ;; There are no further groups, so we return to the group
4598 (gnus-message 5 "Returning to the group buffer")
4600 (set-buffer current-buffer)
4601 (gnus-summary-exit))
4602 ;; We try to enter the target group.
4603 (gnus-group-jump-to-group target-group)
4604 (let ((unreads (gnus-group-group-unread)))
4605 (if (and (or (eq t unreads)
4606 (and unreads (not (zerop unreads))))
4607 (gnus-summary-read-group
4608 target-group nil no-article current-buffer))
4610 (setq current-group target-group
4611 target-group nil)))))))
4613 (defun gnus-summary-prev-group (&optional no-article)
4614 "Exit current newsgroup and then select previous unread newsgroup.
4615 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
4617 (gnus-summary-next-group no-article nil t))
4619 ;; Walking around summary lines.
4621 (defun gnus-summary-first-subject (&optional unread)
4622 "Go to the first unread subject.
4623 If UNREAD is non-nil, go to the first unread article.
4624 Returns the article selected or nil if there are no unread articles."
4629 ((null gnus-newsgroup-data)
4630 (gnus-message 3 "No articles in the group")
4632 ;; Pick the first article.
4634 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
4635 (gnus-data-number (car gnus-newsgroup-data)))
4636 ;; No unread articles.
4637 ((null gnus-newsgroup-unreads)
4638 (gnus-message 3 "No more unread articles")
4640 ;; Find the first unread article.
4642 (let ((data gnus-newsgroup-data))
4644 (not (gnus-data-unread-p (car data))))
4645 (setq data (cdr data)))
4648 (goto-char (gnus-data-pos (car data)))
4649 (gnus-data-number (car data)))))))
4650 (gnus-summary-position-point)))
4652 (defun gnus-summary-next-subject (n &optional unread dont-display)
4653 "Go to next N'th summary line.
4654 If N is negative, go to the previous N'th subject line.
4655 If UNREAD is non-nil, only unread articles are selected.
4656 The difference between N and the actual number of steps taken is
4659 (let ((backward (< n 0))
4663 (gnus-summary-find-prev unread)
4664 (gnus-summary-find-next unread)))
4666 (if (/= 0 n) (gnus-message 7 "No more%s articles"
4667 (if unread " unread" "")))
4668 (unless dont-display
4669 (gnus-summary-recenter)
4670 (gnus-summary-position-point))
4673 (defun gnus-summary-next-unread-subject (n)
4674 "Go to next N'th unread summary line."
4676 (gnus-summary-next-subject n t))
4678 (defun gnus-summary-prev-subject (n &optional unread)
4679 "Go to previous N'th summary line.
4680 If optional argument UNREAD is non-nil, only unread article is selected."
4682 (gnus-summary-next-subject (- n) unread))
4684 (defun gnus-summary-prev-unread-subject (n)
4685 "Go to previous N'th unread summary line."
4687 (gnus-summary-next-subject (- n) t))
4689 (defun gnus-summary-goto-subject (article &optional force silent)
4690 "Go the subject line of ARTICLE.
4691 If FORCE, also allow jumping to articles not currently shown."
4693 (data (gnus-data-find article)))
4694 ;; We read in the article if we have to.
4697 (gnus-summary-insert-subject article (and (vectorp force) force) t)
4698 (setq data (gnus-data-find article)))
4703 (gnus-message 3 "Can't find article %d" article))
4705 (goto-char (gnus-data-pos data))
4708 ;; Walking around summary lines with displaying articles.
4710 (defun gnus-summary-expand-window (&optional arg)
4711 "Make the summary buffer take up the entire Emacs frame.
4712 Given a prefix, will force an `article' buffer configuration."
4714 (gnus-set-global-variables)
4716 (gnus-configure-windows 'article 'force)
4717 (gnus-configure-windows 'summary 'force)))
4719 (defun gnus-summary-display-article (article &optional all-header)
4720 "Display ARTICLE in article buffer."
4721 (gnus-set-global-variables)
4725 (if gnus-summary-display-article-function
4726 (funcall gnus-summary-display-article-function article all-header)
4727 (gnus-article-prepare article all-header))
4728 (run-hooks 'gnus-select-article-hook)
4729 (unless (zerop gnus-current-article)
4730 (gnus-summary-goto-subject gnus-current-article))
4731 (gnus-summary-recenter)
4732 (when gnus-use-trees
4733 (gnus-possibly-generate-tree article)
4734 (gnus-highlight-selected-tree article))
4735 ;; Successfully display article.
4736 (gnus-article-set-window-start
4737 (cdr (assq article gnus-newsgroup-bookmarks))))))
4739 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
4740 "Select the current article.
4741 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
4742 non-nil, the article will be re-fetched even if it already present in
4743 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
4745 ;; Make sure we are in the summary buffer to work around bbdb bug.
4746 (unless (eq major-mode 'gnus-summary-mode)
4747 (set-buffer gnus-summary-buffer))
4748 (let ((article (or article (gnus-summary-article-number)))
4749 (all-headers (not (not all-headers))) ;Must be T or NIL.
4750 gnus-summary-display-article-function
4753 (gnus-summary-article-pseudo-p article)
4754 (error "This is a pseudo-article."))
4757 (set-buffer gnus-summary-buffer)
4758 (if (or (and gnus-single-article-buffer
4759 (or (null gnus-current-article)
4760 (null gnus-article-current)
4761 (null (get-buffer gnus-article-buffer))
4762 (not (eq article (cdr gnus-article-current)))
4763 (not (equal (car gnus-article-current)
4764 gnus-newsgroup-name))))
4765 (and (not gnus-single-article-buffer)
4766 (or (null gnus-current-article)
4767 (not (eq gnus-current-article article))))
4769 ;; The requested article is different from the current article.
4771 (gnus-summary-display-article article all-headers)
4773 (if (or all-headers gnus-show-all-headers)
4774 (gnus-article-show-all-headers))
4777 (gnus-article-set-window-start
4778 (cdr (assq article gnus-newsgroup-bookmarks)))))))
4780 (defun gnus-summary-set-current-mark (&optional current-mark)
4781 "Obsolete function."
4784 (defun gnus-summary-next-article (&optional unread subject backward push)
4785 "Select the next article.
4786 If UNREAD, only unread articles are selected.
4787 If SUBJECT, only articles with SUBJECT are selected.
4788 If BACKWARD, the previous article is selected instead of the next."
4790 (gnus-set-global-variables)
4792 ;; Is there such an article?
4793 ((and (gnus-summary-search-forward unread subject backward)
4794 (or (gnus-summary-display-article (gnus-summary-article-number))
4795 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
4796 (gnus-summary-position-point))
4797 ;; If not, we try the first unread, if that is wanted.
4799 gnus-auto-select-same
4800 ;; Make sure that we don't select the current article.
4801 (not (eq (gnus-summary-article-number)
4803 (gnus-summary-first-subject t)
4804 (gnus-summary-article-number))))
4805 (gnus-summary-first-unread-article))
4806 (gnus-summary-position-point)
4807 (gnus-message 6 "Wrapped"))
4808 ;; Try to get next/previous article not displayed in this group.
4809 ((and gnus-auto-extend-newsgroup
4810 (not unread) (not subject))
4811 (gnus-summary-goto-article
4812 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
4814 ;; Go to next/previous group.
4816 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4817 (gnus-summary-jump-to-group gnus-newsgroup-name))
4818 (let ((cmd last-command-char)
4820 (if (eq gnus-keep-same-level 'best)
4821 (gnus-summary-best-group gnus-newsgroup-name)
4822 (gnus-summary-search-group backward gnus-keep-same-level))))
4823 ;; For some reason, the group window gets selected. We change
4825 (select-window (get-buffer-window (current-buffer)))
4826 ;; Select next unread newsgroup automagically.
4828 ((or (not gnus-auto-select-next)
4830 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
4831 ((or (eq gnus-auto-select-next 'quietly)
4832 (and (eq gnus-auto-select-next 'slightly-quietly)
4834 (and (eq gnus-auto-select-next 'almost-quietly)
4835 (gnus-summary-last-article-p)))
4837 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
4839 (gnus-message 7 "No more%s articles (%s)..."
4840 (if unread " unread" "")
4841 (if group (concat "selecting " group)
4843 (gnus-summary-next-group nil group backward)))
4845 (gnus-summary-walk-group-buffer
4846 gnus-newsgroup-name cmd unread backward)))))))
4848 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
4849 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
4850 (?\C-p (gnus-group-prev-unread-group 1))))
4851 (cursor-in-echo-area t)
4852 keve key group ended)
4854 (set-buffer gnus-group-buffer)
4855 (gnus-summary-jump-to-group from-group)
4857 (if (eq gnus-keep-same-level 'best)
4858 (gnus-summary-best-group gnus-newsgroup-name)
4859 (gnus-summary-search-group backward gnus-keep-same-level))))
4862 5 "No more%s articles%s" (if unread " unread" "")
4864 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
4865 (format " (Type %s for %s [%s])"
4866 (single-key-description cmd) group
4867 (car (gnus-gethash group gnus-newsrc-hashtb)))
4868 (format " (Type %s to exit %s)"
4869 (single-key-description cmd)
4870 gnus-newsgroup-name)))
4871 ;; Confirm auto selection.
4872 (setq key (car (setq keve (gnus-read-event-char))))
4875 ((assq key keystrokes)
4876 (let ((obuf (current-buffer)))
4877 (switch-to-buffer gnus-group-buffer)
4879 (gnus-group-jump-to-group group))
4880 (eval (cadr (assq key keystrokes)))
4881 (setq group (gnus-group-group-name))
4882 (switch-to-buffer obuf))
4886 (gnus-ephemeral-group-p gnus-newsgroup-name))
4888 (gnus-summary-next-group nil group backward)))
4890 (push (cdr keve) unread-command-events))))))
4892 (defun gnus-summary-next-unread-article ()
4893 "Select unread article after current one."
4895 (gnus-summary-next-article t (and gnus-auto-select-same
4896 (gnus-summary-article-subject))))
4898 (defun gnus-summary-prev-article (&optional unread subject)
4899 "Select the article after the current one.
4900 If UNREAD is non-nil, only unread articles are selected."
4902 (gnus-summary-next-article unread subject t))
4904 (defun gnus-summary-prev-unread-article ()
4905 "Select unread article before current one."
4907 (gnus-summary-prev-article t (and gnus-auto-select-same
4908 (gnus-summary-article-subject))))
4910 (defun gnus-summary-next-page (&optional lines circular)
4911 "Show next page of the selected article.
4912 If at the end of the current article, select the next article.
4913 LINES says how many lines should be scrolled up.
4915 If CIRCULAR is non-nil, go to the start of the article instead of
4916 selecting the next article when reaching the end of the current
4919 (setq gnus-summary-buffer (current-buffer))
4920 (gnus-set-global-variables)
4921 (let ((article (gnus-summary-article-number))
4923 (gnus-configure-windows 'article)
4924 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
4925 (if (and (eq gnus-summary-goto-unread 'never)
4926 (not (gnus-summary-last-article-p article)))
4927 (gnus-summary-next-article)
4928 (gnus-summary-next-unread-article))
4929 (if (or (null gnus-current-article)
4930 (null gnus-article-current)
4931 (/= article (cdr gnus-article-current))
4932 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4933 ;; Selected subject is different from current article's.
4934 (gnus-summary-display-article article)
4935 (gnus-eval-in-buffer-window gnus-article-buffer
4936 (setq endp (gnus-article-next-page lines)))
4939 (gnus-summary-beginning-of-article))
4941 (gnus-message 3 "End of message"))
4943 (if (and (eq gnus-summary-goto-unread 'never)
4944 (not (gnus-summary-last-article-p article)))
4945 (gnus-summary-next-article)
4946 (gnus-summary-next-unread-article)))))))
4947 (gnus-summary-recenter)
4948 (gnus-summary-position-point)))
4950 (defun gnus-summary-prev-page (&optional lines)
4951 "Show previous page of selected article.
4952 Argument LINES specifies lines to be scrolled down."
4954 (gnus-set-global-variables)
4955 (let ((article (gnus-summary-article-number)))
4956 (gnus-configure-windows 'article)
4957 (if (or (null gnus-current-article)
4958 (null gnus-article-current)
4959 (/= article (cdr gnus-article-current))
4960 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4961 ;; Selected subject is different from current article's.
4962 (gnus-summary-display-article article)
4963 (gnus-summary-recenter)
4964 (gnus-eval-in-buffer-window gnus-article-buffer
4965 (gnus-article-prev-page lines))))
4966 (gnus-summary-position-point))
4968 (defun gnus-summary-scroll-up (lines)
4969 "Scroll up (or down) one line current article.
4970 Argument LINES specifies lines to be scrolled up (or down if negative)."
4972 (gnus-set-global-variables)
4973 (gnus-configure-windows 'article)
4974 (gnus-summary-show-thread)
4975 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
4976 (gnus-eval-in-buffer-window gnus-article-buffer
4978 (if (gnus-article-next-page lines)
4979 (gnus-message 3 "End of message")))
4981 (gnus-article-prev-page (- lines))))))
4982 (gnus-summary-recenter)
4983 (gnus-summary-position-point))
4985 (defun gnus-summary-next-same-subject ()
4986 "Select next article which has the same subject as current one."
4988 (gnus-set-global-variables)
4989 (gnus-summary-next-article nil (gnus-summary-article-subject)))
4991 (defun gnus-summary-prev-same-subject ()
4992 "Select previous article which has the same subject as current one."
4994 (gnus-set-global-variables)
4995 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
4997 (defun gnus-summary-next-unread-same-subject ()
4998 "Select next unread article which has the same subject as current one."
5000 (gnus-set-global-variables)
5001 (gnus-summary-next-article t (gnus-summary-article-subject)))
5003 (defun gnus-summary-prev-unread-same-subject ()
5004 "Select previous unread article which has the same subject as current one."
5006 (gnus-set-global-variables)
5007 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5009 (defun gnus-summary-first-unread-article ()
5010 "Select the first unread article.
5011 Return nil if there are no unread articles."
5013 (gnus-set-global-variables)
5015 (when (gnus-summary-first-subject t)
5016 (gnus-summary-show-thread)
5017 (gnus-summary-first-subject t)
5018 (gnus-summary-display-article (gnus-summary-article-number)))
5019 (gnus-summary-position-point)))
5021 (defun gnus-summary-best-unread-article ()
5022 "Select the unread article with the highest score."
5024 (gnus-set-global-variables)
5025 (let ((best -1000000)
5026 (data gnus-newsgroup-data)
5029 (and (gnus-data-unread-p (car data))
5031 (gnus-summary-article-score (gnus-data-number (car data))))
5034 article (gnus-data-number (car data))))
5035 (setq data (cdr data)))
5038 (gnus-summary-goto-article article)
5039 (error "No unread articles"))
5040 (gnus-summary-position-point))))
5042 (defun gnus-summary-last-subject ()
5043 "Go to the last displayed subject line in the group."
5044 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5046 (gnus-summary-goto-subject article))))
5048 (defun gnus-summary-goto-article (article &optional all-headers force)
5049 "Fetch ARTICLE and display it if it exists.
5050 If ALL-HEADERS is non-nil, no header lines are hidden."
5056 (mapcar (lambda (number) (list (int-to-string number)))
5057 gnus-newsgroup-limit)))
5061 (if (gnus-summary-goto-subject article force)
5062 (gnus-summary-display-article article all-headers)
5063 (gnus-message 4 "Couldn't go to article %s" article) nil)
5064 (gnus-summary-position-point)))
5066 (defun gnus-summary-goto-last-article ()
5067 "Go to the previously read article."
5070 (and gnus-last-article
5071 (gnus-summary-goto-article gnus-last-article))
5072 (gnus-summary-position-point)))
5074 (defun gnus-summary-pop-article (number)
5075 "Pop one article off the history and go to the previous.
5076 NUMBER articles will be popped off."
5079 (setq gnus-newsgroup-history
5080 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5082 (gnus-summary-goto-article (car to))
5083 (error "Article history empty")))
5084 (gnus-summary-position-point))
5086 ;; Summary commands and functions for limiting the summary buffer.
5088 (defun gnus-summary-limit-to-articles (n)
5089 "Limit the summary buffer to the next N articles.
5090 If not given a prefix, use the process marked articles instead."
5092 (gnus-set-global-variables)
5094 (let ((articles (gnus-summary-work-articles n)))
5095 (setq gnus-newsgroup-processable nil)
5096 (gnus-summary-limit articles))
5097 (gnus-summary-position-point)))
5099 (defun gnus-summary-pop-limit (&optional total)
5100 "Restore the previous limit.
5101 If given a prefix, remove all limits."
5103 (gnus-set-global-variables)
5105 (setq gnus-newsgroup-limits
5106 (list (mapcar (lambda (h) (mail-header-number h))
5107 gnus-newsgroup-headers))))
5108 (unless gnus-newsgroup-limits
5109 (error "No limit to pop"))
5111 (gnus-summary-limit nil 'pop)
5112 (gnus-summary-position-point)))
5114 (defun gnus-summary-limit-to-subject (subject &optional header)
5115 "Limit the summary buffer to articles that have subjects that match a regexp."
5116 (interactive "sRegexp: ")
5118 (setq header "subject"))
5119 (when (not (equal "" subject))
5121 (let ((articles (gnus-summary-find-matching
5122 (or header "subject") subject 'all)))
5123 (or articles (error "Found no matches for \"%s\"" subject))
5124 (gnus-summary-limit articles))
5125 (gnus-summary-position-point))))
5127 (defun gnus-summary-limit-to-author (from)
5128 "Limit the summary buffer to articles that have authors that match a regexp."
5129 (interactive "sRegexp: ")
5130 (gnus-summary-limit-to-subject from "from"))
5132 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5134 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5136 (defun gnus-summary-limit-to-unread (&optional all)
5137 "Limit the summary buffer to articles that are not marked as read.
5138 If ALL is non-nil, limit strictly to unread articles."
5141 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5142 (gnus-summary-limit-to-marks
5143 ;; Concat all the marks that say that an article is read and have
5145 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5146 gnus-killed-mark gnus-kill-file-mark
5147 gnus-low-score-mark gnus-expirable-mark
5148 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5149 gnus-duplicate-mark)
5152 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5153 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5155 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5156 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5157 If REVERSE, limit the summary buffer to articles that are not marked
5158 with MARKS. MARKS can either be a string of marks or a list of marks.
5159 Returns how many articles were removed."
5160 (interactive "sMarks: ")
5161 (gnus-set-global-variables)
5163 (let ((data gnus-newsgroup-data)
5164 (marks (if (listp marks) marks
5165 (append marks nil))) ; Transform to list.
5168 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
5169 (memq (gnus-data-mark (car data)) marks))
5170 (setq articles (cons (gnus-data-number (car data)) articles)))
5171 (setq data (cdr data)))
5172 (gnus-summary-limit articles))
5173 (gnus-summary-position-point)))
5175 (defun gnus-summary-limit-to-score (&optional score)
5176 "Limit to articles with score at or above SCORE."
5178 (gnus-set-global-variables)
5179 (setq score (if score
5180 (prefix-numeric-value score)
5181 (or gnus-summary-default-score 0)))
5182 (let ((data gnus-newsgroup-data)
5185 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5187 (push (gnus-data-number (car data)) articles))
5188 (setq data (cdr data)))
5190 (gnus-summary-limit articles)
5191 (gnus-summary-position-point))))
5193 (defun gnus-summary-limit-include-dormant ()
5194 "Display all the hidden articles that are marked as dormant."
5196 (gnus-set-global-variables)
5197 (or gnus-newsgroup-dormant
5198 (error "There are no dormant articles in this group"))
5200 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5201 (gnus-summary-position-point)))
5203 (defun gnus-summary-limit-exclude-dormant ()
5204 "Hide all dormant articles."
5206 (gnus-set-global-variables)
5208 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5209 (gnus-summary-position-point)))
5211 (defun gnus-summary-limit-exclude-childless-dormant ()
5212 "Hide all dormant articles that have no children."
5214 (gnus-set-global-variables)
5215 (let ((data (gnus-data-list t))
5216 articles d children)
5217 ;; Find all articles that are either not dormant or have
5219 (while (setq d (pop data))
5220 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5222 (gnus-article-children (gnus-data-number d)))
5225 (when (memq (car children) articles)
5230 (push (gnus-data-number d) articles)))
5233 (gnus-summary-limit articles)
5234 (gnus-summary-position-point))))
5236 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5237 "Mark all unread excluded articles as read.
5238 If ALL, mark even excluded ticked and dormants as read."
5240 (let ((articles (gnus-sorted-complement
5242 (mapcar (lambda (h) (mail-header-number h))
5243 gnus-newsgroup-headers)
5245 (sort gnus-newsgroup-limit '<)))
5247 (setq gnus-newsgroup-unreads nil)
5249 (setq gnus-newsgroup-dormant nil
5250 gnus-newsgroup-marked nil
5251 gnus-newsgroup-reads
5253 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5254 gnus-newsgroup-reads))
5255 (while (setq article (pop articles))
5256 (unless (or (memq article gnus-newsgroup-dormant)
5257 (memq article gnus-newsgroup-marked))
5258 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5260 (defun gnus-summary-limit (articles &optional pop)
5262 ;; We pop the previous limit off the stack and use that.
5263 (setq articles (car gnus-newsgroup-limits)
5264 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5265 ;; We use the new limit, so we push the old limit on the stack.
5266 (setq gnus-newsgroup-limits
5267 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
5269 (setq gnus-newsgroup-limit articles)
5270 (let ((total (length gnus-newsgroup-data))
5271 (data (gnus-data-find-list (gnus-summary-article-number)))
5272 (gnus-summary-mark-below nil) ; Inhibit this.
5274 ;; This will do all the work of generating the new summary buffer
5275 ;; according to the new limit.
5276 (gnus-summary-prepare)
5277 ;; Hide any threads, possibly.
5278 (and gnus-show-threads
5279 gnus-thread-hide-subtree
5280 (gnus-summary-hide-all-threads))
5281 ;; Try to return to the article you were at, or one in the
5284 ;; We try to find some article after the current one.
5286 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5289 (setq data (cdr data))))
5291 ;; If there is no data, that means that we were after the last
5292 ;; article. The same goes when we can't find any articles
5293 ;; after the current one.
5294 (goto-char (point-max))
5295 (gnus-summary-find-prev))
5296 ;; We return how many articles were removed from the summary
5297 ;; buffer as a result of the new limit.
5298 (- total (length gnus-newsgroup-data))))
5300 (defsubst gnus-invisible-cut-children (threads)
5303 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5308 (defsubst gnus-cut-thread (thread)
5309 "Go forwards in the thread until we find an article that we want to display."
5310 (when (or (eq gnus-fetch-old-headers 'some)
5311 (eq gnus-build-sparse-threads 'some)
5312 (eq gnus-build-sparse-threads 'more))
5313 ;; Deal with old-fetched headers and sparse threads.
5317 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5318 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5319 (or (<= (length (cdr thread)) 1)
5320 (gnus-invisible-cut-children (cdr thread))))
5321 (setq thread (cadr thread))))
5324 (defun gnus-cut-threads (threads)
5325 "Cut off all uninteresting articles from the beginning of threads."
5326 (when (or (eq gnus-fetch-old-headers 'some)
5327 (eq gnus-build-sparse-threads 'some)
5328 (eq gnus-build-sparse-threads 'more))
5331 (setcar th (gnus-cut-thread (car th)))
5332 (setq th (cdr th)))))
5333 ;; Remove nixed out threads.
5336 (defun gnus-summary-initial-limit (&optional show-if-empty)
5337 "Figure out what the initial limit is supposed to be on group entry.
5338 This entails weeding out unwanted dormants, low-scored articles,
5339 fetch-old-headers verbiage, and so on."
5340 ;; Most groups have nothing to remove.
5341 (if (or gnus-inhibit-limiting
5342 (and (null gnus-newsgroup-dormant)
5343 (not (eq gnus-fetch-old-headers 'some))
5344 (null gnus-summary-expunge-below)
5345 (not (eq gnus-build-sparse-threads 'some))
5346 (not (eq gnus-build-sparse-threads 'more))
5347 (null gnus-thread-expunge-below)
5348 (not gnus-use-nocem)))
5350 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5351 (setq gnus-newsgroup-limit nil)
5354 (unless (car (symbol-value node))
5355 ;; These threads have no parents -- they are roots.
5356 (let ((nodes (cdr (symbol-value node)))
5359 (if (and gnus-thread-expunge-below
5360 (< (gnus-thread-total-score (car nodes))
5361 gnus-thread-expunge-below))
5362 (gnus-expunge-thread (pop nodes))
5363 (setq thread (pop nodes))
5364 (gnus-summary-limit-children thread))))))
5365 gnus-newsgroup-dependencies)
5366 ;; If this limitation resulted in an empty group, we might
5367 ;; pop the previous limit and use it instead.
5368 (when (and (not gnus-newsgroup-limit)
5370 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5371 gnus-newsgroup-limit))
5373 (defun gnus-summary-limit-children (thread)
5374 "Return 1 if this subthread is visible and 0 if it is not."
5375 ;; First we get the number of visible children to this thread. This
5376 ;; is done by recursing down the thread using this function, so this
5377 ;; will really go down to a leaf article first, before slowly
5378 ;; working its way up towards the root.
5382 (apply '+ (mapcar 'gnus-summary-limit-children
5385 (number (mail-header-number (car thread)))
5388 ;; If this article is dormant and has absolutely no visible
5389 ;; children, then this article isn't visible.
5390 (and (memq number gnus-newsgroup-dormant)
5392 ;; If this is "fetch-old-headered" and there is only one
5393 ;; visible child (or less), then we don't want this article.
5394 (and (eq gnus-fetch-old-headers 'some)
5395 (memq number gnus-newsgroup-ancient)
5397 ;; If this is a sparsely inserted article with no children,
5398 ;; we don't want it.
5399 (and (eq gnus-build-sparse-threads 'some)
5400 (memq number gnus-newsgroup-sparse)
5402 ;; If we use expunging, and this article is really
5403 ;; low-scored, then we don't want this article.
5404 (when (and gnus-summary-expunge-below
5406 (or (cdr (assq number gnus-newsgroup-scored))
5407 gnus-summary-default-score))
5408 gnus-summary-expunge-below))
5409 ;; We increase the expunge-tally here, but that has
5410 ;; nothing to do with the limits, really.
5411 (incf gnus-newsgroup-expunged-tally)
5412 ;; We also mark as read here, if that's wanted.
5413 (when (and gnus-summary-mark-below
5414 (< score gnus-summary-mark-below))
5415 (setq gnus-newsgroup-unreads
5416 (delq number gnus-newsgroup-unreads))
5417 (if gnus-newsgroup-auto-expire
5418 (push number gnus-newsgroup-expirable)
5419 (push (cons number gnus-low-score-mark)
5420 gnus-newsgroup-reads)))
5423 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
5424 ;; Nope, invisible article.
5426 ;; Ok, this article is to be visible, so we add it to the limit
5428 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
5431 (defun gnus-expunge-thread (thread)
5432 "Mark all articles in THREAD as read."
5433 (let* ((number (mail-header-number (car thread))))
5434 (incf gnus-newsgroup-expunged-tally)
5435 ;; We also mark as read here, if that's wanted.
5436 (setq gnus-newsgroup-unreads
5437 (delq number gnus-newsgroup-unreads))
5438 (if gnus-newsgroup-auto-expire
5439 (push number gnus-newsgroup-expirable)
5440 (push (cons number gnus-low-score-mark)
5441 gnus-newsgroup-reads)))
5442 ;; Go recursively through all subthreads.
5443 (mapcar 'gnus-expunge-thread (cdr thread)))
5445 ;; Summary article oriented commands
5447 (defun gnus-summary-refer-parent-article (n)
5448 "Refer parent article N times.
5449 The difference between N and the number of articles fetched is returned."
5451 (gnus-set-global-variables)
5455 (let* ((header (gnus-summary-article-header))
5457 ;; If we try to find the parent of the currently
5458 ;; displayed article, then we take a look at the actual
5459 ;; References header, since this is slightly more
5460 ;; reliable than the References field we got from the
5462 (if (and (eq (mail-header-number header)
5463 (cdr gnus-article-current))
5464 (equal gnus-newsgroup-name
5465 (car gnus-article-current)))
5467 (set-buffer gnus-original-article-buffer)
5468 (nnheader-narrow-to-headers)
5470 (message-fetch-field "references")
5472 ;; It's not the current article, so we take a bet on
5473 ;; the value we got from the server.
5474 (mail-header-references header))))
5475 (if (setq ref (or ref (mail-header-references header)))
5476 (or (gnus-summary-refer-article (gnus-parent-id ref))
5477 (gnus-message 1 "Couldn't find parent"))
5478 (gnus-message 1 "No references in article %d"
5479 (gnus-summary-article-number))
5482 (gnus-summary-position-point)
5485 (defun gnus-summary-refer-references ()
5486 "Fetch all articles mentioned in the References header.
5487 Return how many articles were fetched."
5489 (gnus-set-global-variables)
5490 (let ((ref (mail-header-references (gnus-summary-article-header)))
5491 (current (gnus-summary-article-number))
5493 ;; For each Message-ID in the References header...
5494 (while (string-match "<[^>]*>" ref)
5496 ;; ... fetch that article.
5497 (gnus-summary-refer-article
5498 (prog1 (match-string 0 ref)
5499 (setq ref (substring ref (match-end 0))))))
5500 (gnus-summary-goto-subject current)
5501 (gnus-summary-position-point)
5504 (defun gnus-summary-refer-article (message-id)
5505 "Fetch an article specified by MESSAGE-ID."
5506 (interactive "sMessage-ID: ")
5507 (when (and (stringp message-id)
5508 (not (zerop (length message-id))))
5509 ;; Construct the correct Message-ID if necessary.
5510 ;; Suggested by tale@pawl.rpi.edu.
5511 (unless (string-match "^<" message-id)
5512 (setq message-id (concat "<" message-id)))
5513 (unless (string-match ">$" message-id)
5514 (setq message-id (concat message-id ">")))
5515 (let* ((header (gnus-id-to-header message-id))
5517 (memq (mail-header-number header)
5518 gnus-newsgroup-sparse))))
5521 ;; The article is present in the buffer, to we just go to it.
5522 (gnus-summary-goto-article
5523 (mail-header-number header) nil header)
5525 (gnus-summary-update-article (mail-header-number header))))
5526 ;; We fetch the article
5527 (let ((gnus-override-method
5528 (and (gnus-news-group-p gnus-newsgroup-name)
5529 gnus-refer-article-method))
5531 ;; Start the special refer-article method, if necessary.
5532 (when (and gnus-refer-article-method
5533 (gnus-news-group-p gnus-newsgroup-name))
5534 (gnus-check-server gnus-refer-article-method))
5535 ;; Fetch the header, and display the article.
5536 (if (setq number (gnus-summary-insert-subject message-id))
5537 (gnus-summary-select-article nil nil nil number)
5538 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
5540 (defun gnus-summary-enter-digest-group (&optional force)
5541 "Enter an nndoc group based on the current article.
5542 If FORCE, force a digest interpretation. If not, try
5543 to guess what the document format is."
5545 (gnus-set-global-variables)
5546 (gnus-summary-select-article)
5547 (let ((name (format "%s-%d"
5548 (gnus-group-prefixed-name
5549 gnus-newsgroup-name (list 'nndoc ""))
5550 gnus-current-article))
5551 (ogroup gnus-newsgroup-name)
5552 (case-fold-search t)
5553 (buf (current-buffer))
5556 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
5557 (insert-buffer-substring gnus-original-article-buffer)
5559 (goto-char (point-min))
5560 (or (search-forward "\n\n" nil t) (point)))
5561 (goto-char (point-min))
5562 (delete-matching-lines "^\\(Path\\):\\|^From ")
5565 (if (gnus-group-read-ephemeral-group
5566 name `(nndoc ,name (nndoc-address
5568 (nndoc-article-type ,(if force 'digest 'guess))) t)
5569 ;; Make all postings to this group go to the parent group.
5570 (nconc (gnus-info-params (gnus-get-info name))
5571 (list (cons 'to-group ogroup)))
5572 ;; Couldn't select this doc group.
5573 (switch-to-buffer buf)
5574 (gnus-set-global-variables)
5575 (gnus-configure-windows 'summary)
5576 (gnus-message 3 "Article couldn't be entered?"))
5577 (kill-buffer dig))))
5579 (defun gnus-summary-read-document (n)
5580 "Open a new group based on the current article(s).
5581 Obeys the standard process/prefix convention."
5583 (let ((articles (gnus-summary-work-articles n))
5584 (ogroup gnus-newsgroup-name)
5585 article group egroup groups vgroup)
5586 (while (setq article (pop articles))
5587 (setq group (format "%s-%d" gnus-newsgroup-name gnus-current-article))
5588 (gnus-summary-remove-process-mark article)
5589 (when (gnus-summary-display-article article)
5591 (nnheader-temp-write nil
5592 (insert-buffer-substring gnus-original-article-buffer)
5593 ;; Remove some headers that may lead nndoc to make
5595 (message-narrow-to-head)
5596 (goto-char (point-min))
5597 (delete-matching-lines "^\\(Path\\):\\|^From ")
5600 (gnus-group-read-ephemeral-group
5601 group `(nndoc ,group (nndoc-address ,(current-buffer))
5602 (nndoc-article-type guess))
5605 ;; Make all postings to this group go to the parent group.
5606 (nconc (gnus-info-params (gnus-get-info egroup))
5607 (list (cons 'to-group ogroup)))
5608 (push egroup groups))
5609 ;; Couldn't select this doc group.
5610 (gnus-error 3 "Article couldn't be entered"))))))
5611 ;; Now we have selected all the documents.
5614 (error "None of the articles could be interpreted as documents"))
5615 ((gnus-group-read-ephemeral-group
5616 (setq vgroup (format "%s-%s" gnus-newsgroup-name (current-time-string)))
5617 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
5620 (error "Couldn't select virtual nndoc group")))))
5622 (defun gnus-summary-isearch-article (&optional regexp-p)
5623 "Do incremental search forward on the current article.
5624 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
5626 (gnus-set-global-variables)
5627 (gnus-summary-select-article)
5628 (gnus-configure-windows 'article)
5629 (gnus-eval-in-buffer-window gnus-article-buffer
5630 ;;(goto-char (point-min))
5631 (isearch-forward regexp-p)))
5633 (defun gnus-summary-search-article-forward (regexp &optional backward)
5634 "Search for an article containing REGEXP forward.
5635 If BACKWARD, search backward instead."
5638 (format "Search article %s (regexp%s): "
5639 (if current-prefix-arg "backward" "forward")
5640 (if gnus-last-search-regexp
5641 (concat ", default " gnus-last-search-regexp)
5643 current-prefix-arg))
5644 (gnus-set-global-variables)
5645 (if (string-equal regexp "")
5646 (setq regexp (or gnus-last-search-regexp ""))
5647 (setq gnus-last-search-regexp regexp))
5648 (if (gnus-summary-search-article regexp backward)
5649 (gnus-summary-show-thread)
5650 (error "Search failed: \"%s\"" regexp)))
5652 (defun gnus-summary-search-article-backward (regexp)
5653 "Search for an article containing REGEXP backward."
5656 (format "Search article backward (regexp%s): "
5657 (if gnus-last-search-regexp
5658 (concat ", default " gnus-last-search-regexp)
5660 (gnus-summary-search-article-forward regexp 'backward))
5662 (defun gnus-summary-search-article (regexp &optional backward)
5663 "Search for an article containing REGEXP.
5664 Optional argument BACKWARD means do search for backward.
5665 `gnus-select-article-hook' is not called during the search."
5666 (let ((gnus-select-article-hook nil) ;Disable hook.
5667 (gnus-article-display-hook nil)
5668 (gnus-mark-article-hook nil) ;Inhibit marking as read.
5669 (gnus-use-article-prefetch nil)
5672 're-search-backward 're-search-forward))
5673 (sum (current-buffer))
5675 (gnus-save-hidden-threads
5676 (gnus-summary-select-article)
5677 (set-buffer gnus-article-buffer)
5681 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
5683 (re-search-backward regexp nil t)
5684 (re-search-forward regexp nil t))
5685 ;; We found the regexp.
5690 (get-buffer-window (current-buffer))
5694 ;; We didn't find it, so we go to the next article.
5696 (if (not (if backward (gnus-summary-find-prev)
5697 (gnus-summary-find-next)))
5698 ;; No more articles.
5700 ;; Select the next article and adjust point.
5701 (gnus-summary-select-article)
5702 (set-buffer gnus-article-buffer)
5704 (goto-char (if backward (point-max) (point-min))))))
5705 (gnus-message 7 ""))
5706 ;; Return whether we found the regexp.
5707 (when (eq found 'found)
5708 (gnus-summary-show-thread)
5709 (gnus-summary-goto-subject gnus-current-article)
5710 (gnus-summary-position-point)
5713 (defun gnus-summary-find-matching (header regexp &optional backward unread
5715 "Return a list of all articles that match REGEXP on HEADER.
5716 The search stars on the current article and goes forwards unless
5717 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
5718 If UNREAD is non-nil, only unread articles will
5719 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
5720 in the comparisons."
5721 (let ((data (if (eq backward 'all) gnus-newsgroup-data
5722 (gnus-data-find-list
5723 (gnus-summary-article-number) (gnus-data-list backward))))
5724 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
5725 (case-fold-search (not not-case-fold))
5727 (or (fboundp (intern (concat "mail-header-" header)))
5728 (error "%s is not a valid header" header))
5731 (and (or (not unread) ; We want all articles...
5732 (gnus-data-unread-p d)) ; Or just unreads.
5733 (vectorp (gnus-data-header d)) ; It's not a pseudo.
5734 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
5735 (setq articles (cons (gnus-data-number d) articles))) ; Success!
5736 (setq data (cdr data)))
5737 (nreverse articles)))
5739 (defun gnus-summary-execute-command (header regexp command &optional backward)
5740 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
5741 If HEADER is an empty string (or nil), the match is done on the entire
5742 article. If BACKWARD (the prefix) is non-nil, search backward instead."
5744 (list (let ((completion-ignore-case t))
5747 (mapcar (lambda (string) (list string))
5748 '("Number" "Subject" "From" "Lines" "Date"
5749 "Message-ID" "Xref" "References" "Body"))
5750 nil 'require-match))
5751 (read-string "Regexp: ")
5752 (read-key-sequence "Command: ")
5753 current-prefix-arg))
5754 (when (equal header "Body")
5756 (gnus-set-global-variables)
5757 ;; Hidden thread subtrees must be searched as well.
5758 (gnus-summary-show-all-threads)
5759 ;; We don't want to change current point nor window configuration.
5761 (save-window-excursion
5762 (gnus-message 6 "Executing %s..." (key-description command))
5763 ;; We'd like to execute COMMAND interactively so as to give arguments.
5764 (gnus-execute header regexp
5765 `(lambda () (call-interactively ',(key-binding command)))
5767 (gnus-message 6 "Executing %s...done" (key-description command)))))
5769 (defun gnus-summary-beginning-of-article ()
5770 "Scroll the article back to the beginning."
5772 (gnus-set-global-variables)
5773 (gnus-summary-select-article)
5774 (gnus-configure-windows 'article)
5775 (gnus-eval-in-buffer-window gnus-article-buffer
5777 (goto-char (point-min))
5778 (and gnus-break-pages (gnus-narrow-to-page))))
5780 (defun gnus-summary-end-of-article ()
5781 "Scroll to the end of the article."
5783 (gnus-set-global-variables)
5784 (gnus-summary-select-article)
5785 (gnus-configure-windows 'article)
5786 (gnus-eval-in-buffer-window gnus-article-buffer
5788 (goto-char (point-max))
5790 (and gnus-break-pages (gnus-narrow-to-page))))
5792 (defun gnus-summary-show-article (&optional arg)
5793 "Force re-fetching of the current article.
5794 If ARG (the prefix) is non-nil, show the raw article without any
5795 article massaging functions being run."
5797 (gnus-set-global-variables)
5799 ;; Select the article the normal way.
5800 (gnus-summary-select-article nil 'force)
5801 ;; Bind the article treatment functions to nil.
5802 (let ((gnus-have-all-headers t)
5803 gnus-article-display-hook
5804 gnus-article-prepare-hook
5807 (gnus-summary-select-article nil 'force)))
5808 (gnus-summary-goto-subject gnus-current-article)
5809 ; (gnus-configure-windows 'article)
5810 (gnus-summary-position-point))
5812 (defun gnus-summary-verbose-headers (&optional arg)
5813 "Toggle permanent full header display.
5814 If ARG is a positive number, turn header display on.
5815 If ARG is a negative number, turn header display off."
5817 (gnus-set-global-variables)
5818 (gnus-summary-toggle-header arg)
5819 (setq gnus-show-all-headers
5820 (cond ((or (not (numberp arg))
5822 (not gnus-show-all-headers))
5826 (defun gnus-summary-toggle-header (&optional arg)
5827 "Show the headers if they are hidden, or hide them if they are shown.
5828 If ARG is a positive number, show the entire header.
5829 If ARG is a negative number, hide the unwanted header lines."
5831 (gnus-set-global-variables)
5833 (set-buffer gnus-article-buffer)
5834 (let* ((buffer-read-only nil)
5835 (inhibit-point-motion-hooks t)
5836 (hidden (text-property-any
5837 (goto-char (point-min)) (search-forward "\n\n")
5840 (goto-char (point-min))
5841 (when (search-forward "\n\n" nil t)
5842 (delete-region (point-min) (1- (point))))
5843 (goto-char (point-min))
5845 (set-buffer gnus-original-article-buffer)
5846 (goto-char (point-min))
5847 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
5848 (insert-buffer-substring gnus-original-article-buffer 1 e)
5849 (let ((article-inhibit-hiding t))
5850 (run-hooks 'gnus-article-display-hook))
5851 (if (or (not hidden) (and (numberp arg) (< arg 0)))
5852 (gnus-article-hide-headers)))))
5854 (defun gnus-summary-show-all-headers ()
5855 "Make all header lines visible."
5857 (gnus-set-global-variables)
5858 (gnus-article-show-all-headers))
5860 (defun gnus-summary-toggle-mime (&optional arg)
5861 "Toggle MIME processing.
5862 If ARG is a positive number, turn MIME processing on."
5864 (gnus-set-global-variables)
5865 (setq gnus-show-mime
5866 (if (null arg) (not gnus-show-mime)
5867 (> (prefix-numeric-value arg) 0)))
5868 (gnus-summary-select-article t 'force))
5870 (defun gnus-summary-caesar-message (&optional arg)
5871 "Caesar rotate the current article by 13.
5872 The numerical prefix specifies how manu places to rotate each letter
5875 (gnus-set-global-variables)
5876 (gnus-summary-select-article)
5877 (let ((mail-header-separator ""))
5878 (gnus-eval-in-buffer-window gnus-article-buffer
5881 (let ((start (window-start))
5883 (message-caesar-buffer-body arg)
5884 (set-window-start (get-buffer-window (current-buffer)) start))))))
5886 (defun gnus-summary-stop-page-breaking ()
5887 "Stop page breaking in the current article."
5889 (gnus-set-global-variables)
5890 (gnus-summary-select-article)
5891 (gnus-eval-in-buffer-window gnus-article-buffer
5894 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
5895 "Move the current article to a different newsgroup.
5896 If N is a positive number, move the N next articles.
5897 If N is a negative number, move the N previous articles.
5898 If N is nil and any articles have been marked with the process mark,
5899 move those articles instead.
5900 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
5901 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
5902 re-spool using this method.
5904 For this function to work, both the current newsgroup and the
5905 newsgroup that you want to move to have to support the `request-move'
5906 and `request-accept' functions."
5908 (unless action (setq action 'move))
5909 (gnus-set-global-variables)
5910 ;; Check whether the source group supports the required functions.
5911 (cond ((and (eq action 'move)
5912 (not (gnus-check-backend-function
5913 'request-move-article gnus-newsgroup-name)))
5914 (error "The current group does not support article moving"))
5915 ((and (eq action 'crosspost)
5916 (not (gnus-check-backend-function
5917 'request-replace-article gnus-newsgroup-name)))
5918 (error "The current group does not support article editing")))
5919 (let ((articles (gnus-summary-work-articles n))
5920 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
5921 (names '((move "Move" "Moving")
5922 (copy "Copy" "Copying")
5923 (crosspost "Crosspost" "Crossposting")))
5924 (copy-buf (save-excursion
5925 (nnheader-set-temp-buffer " *copy article*")))
5926 art-group to-method new-xref article to-groups)
5927 (unless (assq action names)
5928 (error "Unknown action %s" action))
5929 ;; Read the newsgroup name.
5930 (when (and (not to-newsgroup)
5931 (not select-method))
5933 (gnus-read-move-group-name
5934 (cadr (assq action names))
5935 (symbol-value (intern (format "gnus-current-%s-group" action)))
5937 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
5938 (setq to-method (or select-method
5939 (gnus-group-name-to-method to-newsgroup)))
5940 ;; Check the method we are to move this article to...
5941 (or (gnus-check-backend-function 'request-accept-article (car to-method))
5942 (error "%s does not support article copying" (car to-method)))
5943 (or (gnus-check-server to-method)
5944 (error "Can't open server %s" (car to-method)))
5945 (gnus-message 6 "%s to %s: %s..."
5946 (caddr (assq action names))
5947 (or (car select-method) to-newsgroup) articles)
5949 (setq article (pop articles))
5953 ;; Move the article.
5955 (gnus-request-move-article
5956 article ; Article to move
5957 gnus-newsgroup-name ; From newsgrouo
5958 (nth 1 (gnus-find-method-for-group
5959 gnus-newsgroup-name)) ; Server
5960 (list 'gnus-request-accept-article
5961 to-newsgroup (list 'quote select-method)
5962 (not articles)) ; Accept form
5963 (not articles))) ; Only save nov last time
5964 ;; Copy the article.
5967 (set-buffer copy-buf)
5968 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5969 (gnus-request-accept-article
5970 to-newsgroup select-method (not articles))))
5971 ;; Crosspost the article.
5972 ((eq action 'crosspost)
5973 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
5974 (setq new-xref (concat gnus-newsgroup-name ":" article))
5975 (if (and xref (not (string= xref "")))
5977 (when (string-match "^Xref: " xref)
5978 (setq xref (substring xref (match-end 0))))
5979 (setq new-xref (concat xref " " new-xref)))
5980 (setq new-xref (concat (system-name) " " new-xref)))
5982 (set-buffer copy-buf)
5983 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5984 (nnheader-replace-header "xref" new-xref)
5985 (gnus-request-accept-article
5986 to-newsgroup select-method (not articles)))))))
5988 (gnus-message 1 "Couldn't %s article %s"
5989 (cadr (assq action names)) article)
5992 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
5994 (gnus-group-prefixed-name
5997 (gnus-find-method-for-group to-newsgroup)))
5998 gnus-newsrc-hashtb)))
5999 (info (nth 2 entry))
6000 (to-group (gnus-info-group info)))
6001 ;; Update the group that has been moved to.
6003 (memq action '(move copy)))
6004 (unless (member to-group to-groups)
6005 (push to-group to-groups))
6007 (unless (memq article gnus-newsgroup-unreads)
6009 info (gnus-add-to-range (gnus-info-read info)
6010 (list (cdr art-group)))))
6012 ;; Copy any marks over to the new group.
6013 (let ((marks gnus-article-mark-lists)
6014 (to-article (cdr art-group)))
6016 ;; See whether the article is to be put in the cache.
6017 (when gnus-use-cache
6018 (gnus-cache-possibly-enter-article
6020 (let ((header (copy-sequence
6021 (gnus-summary-article-header article))))
6022 (mail-header-set-number header to-article)
6024 (memq article gnus-newsgroup-marked)
6025 (memq article gnus-newsgroup-dormant)
6026 (memq article gnus-newsgroup-unreads)))
6029 (when (memq article (symbol-value
6030 (intern (format "gnus-newsgroup-%s"
6032 ;; If the other group is the same as this group,
6033 ;; then we have to add the mark to the list.
6034 (when (equal to-group gnus-newsgroup-name)
6035 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6038 (intern (format "gnus-newsgroup-%s"
6040 ;; Copy mark to other group.
6041 (gnus-add-marked-articles
6042 to-group (cdar marks) (list to-article) info))
6043 (setq marks (cdr marks)))))
6045 ;; Update the Xref header in this article to point to
6046 ;; the new crossposted article we have just created.
6047 (when (eq action 'crosspost)
6049 (set-buffer copy-buf)
6050 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6051 (nnheader-replace-header
6052 "xref" (concat new-xref " " (gnus-group-prefixed-name
6053 (car art-group) to-method)
6054 ":" (cdr art-group)))
6055 (gnus-request-replace-article
6056 article gnus-newsgroup-name (current-buffer)))))
6058 (gnus-summary-goto-subject article)
6059 (when (eq action 'move)
6060 (gnus-summary-mark-article article gnus-canceled-mark)))
6061 (gnus-summary-remove-process-mark article))
6062 ;; Re-activate all groups that have been moved to.
6064 (gnus-activate-group (pop to-groups)))
6066 (gnus-kill-buffer copy-buf)
6067 (gnus-summary-position-point)
6068 (gnus-set-mode-line 'summary)))
6070 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6071 "Move the current article to a different newsgroup.
6072 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6073 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6074 re-spool using this method."
6076 (gnus-summary-move-article n nil select-method 'copy))
6078 (defun gnus-summary-crosspost-article (&optional n)
6079 "Crosspost the current article to some other group."
6081 (gnus-summary-move-article n nil nil 'crosspost))
6083 (defvar gnus-summary-respool-default-method nil
6084 "Default method for respooling an article.
6085 If nil, use to the current newsgroup method.")
6087 (defun gnus-summary-respool-article (&optional n method)
6088 "Respool the current article.
6089 The article will be squeezed through the mail spooling process again,
6090 which means that it will be put in some mail newsgroup or other
6091 depending on `nnmail-split-methods'.
6092 If N is a positive number, respool the N next articles.
6093 If N is a negative number, respool the N previous articles.
6094 If N is nil and any articles have been marked with the process mark,
6095 respool those articles instead.
6097 Respooling can be done both from mail groups and \"real\" newsgroups.
6098 In the former case, the articles in question will be moved from the
6099 current group into whatever groups they are destined to. In the
6100 latter case, they will be copied into the relevant groups."
6102 (list current-prefix-arg
6103 (let* ((methods (gnus-methods-using 'respool))
6105 (symbol-name (or gnus-summary-respool-default-method
6106 (car (gnus-find-method-for-group
6107 gnus-newsgroup-name)))))
6109 (gnus-completing-read
6110 methname "What backend do you want to use when respooling?"
6111 methods nil t nil 'gnus-method-history))
6114 ((zerop (length (setq ms (gnus-servers-using-backend method))))
6115 (list (intern method) ""))
6119 (cdr (completing-read
6121 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
6122 (gnus-set-global-variables)
6124 (error "No method given for respooling"))
6125 (if (assoc (symbol-name
6126 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6127 (gnus-methods-using 'respool))
6128 (gnus-summary-move-article n nil method)
6129 (gnus-summary-copy-article n nil method)))
6131 (defun gnus-summary-import-article (file)
6132 "Import a random file into a mail newsgroup."
6133 (interactive "fImport file: ")
6134 (gnus-set-global-variables)
6135 (let ((group gnus-newsgroup-name)
6136 (now (current-time))
6138 (or (gnus-check-backend-function 'request-accept-article group)
6139 (error "%s does not support article importing" group))
6140 (or (file-readable-p file)
6141 (not (file-regular-p file))
6142 (error "Can't read %s" file))
6144 (set-buffer (get-buffer-create " *import file*"))
6145 (buffer-disable-undo (current-buffer))
6147 (insert-file-contents file)
6148 (goto-char (point-min))
6149 (unless (nnheader-article-p)
6150 ;; This doesn't look like an article, so we fudge some headers.
6151 (setq atts (file-attributes file)
6152 lines (count-lines (point-min) (point-max)))
6153 (insert "From: " (read-string "From: ") "\n"
6154 "Subject: " (read-string "Subject: ") "\n"
6155 "Date: " (timezone-make-date-arpa-standard
6156 (current-time-string (nth 5 atts))
6157 (current-time-zone now)
6158 (current-time-zone now)) "\n"
6159 "Message-ID: " (message-make-message-id) "\n"
6160 "Lines: " (int-to-string lines) "\n"
6161 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6162 (gnus-request-accept-article group nil t)
6163 (kill-buffer (current-buffer)))))
6165 (defun gnus-summary-expire-articles (&optional now)
6166 "Expire all articles that are marked as expirable in the current group."
6168 (gnus-set-global-variables)
6169 (when (gnus-check-backend-function
6170 'request-expire-articles gnus-newsgroup-name)
6171 ;; This backend supports expiry.
6172 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6173 (expirable (if total
6174 (gnus-list-of-read-articles gnus-newsgroup-name)
6175 (setq gnus-newsgroup-expirable
6176 (sort gnus-newsgroup-expirable '<))))
6177 (expiry-wait (if now 'immediate
6178 (gnus-group-find-parameter
6179 gnus-newsgroup-name 'expiry-wait)))
6182 ;; There are expirable articles in this group, so we run them
6183 ;; through the expiry process.
6184 (gnus-message 6 "Expiring articles...")
6185 ;; The list of articles that weren't expired is returned.
6187 (let ((nnmail-expiry-wait-function nil)
6188 (nnmail-expiry-wait expiry-wait))
6189 (setq es (gnus-request-expire-articles
6190 expirable gnus-newsgroup-name)))
6191 (setq es (gnus-request-expire-articles
6192 expirable gnus-newsgroup-name)))
6194 (setq gnus-newsgroup-expirable es))
6195 ;; We go through the old list of expirable, and mark all
6196 ;; really expired articles as nonexistent.
6197 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6198 (let ((gnus-use-cache nil))
6200 (unless (memq (car expirable) es)
6201 (when (gnus-data-find (car expirable))
6202 (gnus-summary-mark-article
6203 (car expirable) gnus-canceled-mark)))
6204 (setq expirable (cdr expirable)))))
6205 (gnus-message 6 "Expiring articles...done")))))
6207 (defun gnus-summary-expire-articles-now ()
6208 "Expunge all expirable articles in the current group.
6209 This means that *all* articles that are marked as expirable will be
6210 deleted forever, right now."
6212 (gnus-set-global-variables)
6213 (or gnus-expert-user
6215 "Are you really, really, really sure you want to delete all these messages? ")
6217 (gnus-summary-expire-articles t))
6219 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6220 (defun gnus-summary-delete-article (&optional n)
6221 "Delete the N next (mail) articles.
6222 This command actually deletes articles. This is not a marking
6223 command. The article will disappear forever from your life, never to
6225 If N is negative, delete backwards.
6226 If N is nil and articles have been marked with the process mark,
6227 delete these instead."
6229 (gnus-set-global-variables)
6230 (or (gnus-check-backend-function 'request-expire-articles
6231 gnus-newsgroup-name)
6232 (error "The current newsgroup does not support article deletion."))
6233 ;; Compute the list of articles to delete.
6234 (let ((articles (gnus-summary-work-articles n))
6236 (if (and gnus-novice-user
6238 (format "Do you really want to delete %s forever? "
6239 (if (> (length articles) 1)
6240 (format "these %s articles" (length articles))
6243 ;; Delete the articles.
6244 (setq not-deleted (gnus-request-expire-articles
6245 articles gnus-newsgroup-name 'force))
6247 (gnus-summary-remove-process-mark (car articles))
6248 ;; The backend might not have been able to delete the article
6250 (or (memq (car articles) not-deleted)
6251 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6252 (setq articles (cdr articles))))
6253 (gnus-summary-position-point)
6254 (gnus-set-mode-line 'summary)
6257 (defun gnus-summary-edit-article (&optional force)
6258 "Edit the current article.
6259 This will have permanent effect only in mail groups.
6260 If FORCE is non-nil, allow editing of articles even in read-only
6264 (set-buffer gnus-summary-buffer)
6265 (gnus-set-global-variables)
6266 (when (and (not force)
6267 (gnus-group-read-only-p))
6268 (error "The current newsgroup does not support article editing."))
6269 ;; Select article if needed.
6270 (unless (eq (gnus-summary-article-number)
6271 gnus-current-article)
6272 (gnus-summary-select-article t))
6273 (gnus-article-edit-article
6275 (gnus-summary-edit-article-done
6276 ,(or (mail-header-references gnus-current-headers) "")
6277 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6279 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6281 (defun gnus-summary-edit-article-done (references read-only buffer)
6282 "Make edits to the current article permanent."
6284 ;; Replace the article.
6285 (if (and (not read-only)
6286 (not (gnus-request-replace-article
6287 (cdr gnus-article-current) (car gnus-article-current)
6289 (error "Couldn't replace article.")
6290 ;; Update the summary buffer.
6291 (if (equal (message-tokenize-header references " ")
6292 (message-tokenize-header
6293 (or (message-fetch-field "references") "") " "))
6294 ;; We only have to update this line.
6297 (message-narrow-to-head)
6298 (let ((header (nnheader-parse-head t)))
6300 (mail-header-set-number header (cdr gnus-article-current))
6301 (gnus-summary-update-article-line
6302 (cdr gnus-article-current) header))))
6305 (gnus-summary-update-article (cdr gnus-article-current)))
6306 ;; Prettify the article buffer again.
6308 (set-buffer gnus-article-buffer)
6309 (run-hooks 'gnus-article-display-hook))
6310 ;; Prettify the summary buffer line.
6311 (when (gnus-visual-p 'summary-highlight 'highlight)
6312 (run-hooks 'gnus-visual-mark-article-hook))))
6314 (defun gnus-summary-edit-wash (key)
6315 "Perform editing command in the article buffer."
6319 (message "%s" (concat (this-command-keys) "- "))
6322 (gnus-summary-edit-article)
6323 (execute-kbd-macro (concat (this-command-keys) key))
6324 (gnus-article-edit-done))
6328 (defun gnus-summary-respool-query ()
6329 "Query where the respool algorithm would put this article."
6331 (gnus-set-global-variables)
6332 (gnus-summary-select-article)
6334 (set-buffer gnus-article-buffer)
6336 (goto-char (point-min))
6337 (search-forward "\n\n")
6338 (narrow-to-region (point-min) (point))
6340 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
6342 ;; Summary marking commands.
6344 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6345 "Mark articles which has the same subject as read, and then select the next.
6346 If UNMARK is positive, remove any kind of mark.
6347 If UNMARK is negative, tick articles."
6349 (gnus-set-global-variables)
6351 (setq unmark (prefix-numeric-value unmark)))
6353 (gnus-summary-mark-same-subject
6354 (gnus-summary-article-subject) unmark)))
6355 ;; Select next unread article. If auto-select-same mode, should
6356 ;; select the first unread article.
6357 (gnus-summary-next-article t (and gnus-auto-select-same
6358 (gnus-summary-article-subject)))
6359 (gnus-message 7 "%d article%s marked as %s"
6360 count (if (= count 1) " is" "s are")
6361 (if unmark "unread" "read"))))
6363 (defun gnus-summary-kill-same-subject (&optional unmark)
6364 "Mark articles which has the same subject as read.
6365 If UNMARK is positive, remove any kind of mark.
6366 If UNMARK is negative, tick articles."
6368 (gnus-set-global-variables)
6370 (setq unmark (prefix-numeric-value unmark)))
6372 (gnus-summary-mark-same-subject
6373 (gnus-summary-article-subject) unmark)))
6374 ;; If marked as read, go to next unread subject.
6376 ;; Go to next unread subject.
6377 (gnus-summary-next-subject 1 t))
6378 (gnus-message 7 "%d articles are marked as %s"
6379 count (if unmark "unread" "read"))))
6381 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6382 "Mark articles with same SUBJECT as read, and return marked number.
6383 If optional argument UNMARK is positive, remove any kinds of marks.
6384 If optional argument UNMARK is negative, mark articles as unread instead."
6388 ((null unmark) ; Mark as read.
6391 (gnus-summary-mark-article-as-read gnus-killed-mark)
6392 (gnus-summary-show-thread) t)
6393 (gnus-summary-find-subject subject))
6394 (setq count (1+ count))))
6395 ((> unmark 0) ; Tick.
6398 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6399 (gnus-summary-show-thread) t)
6400 (gnus-summary-find-subject subject))
6401 (setq count (1+ count))))
6402 (t ; Mark as unread.
6405 (gnus-summary-mark-article-as-unread gnus-unread-mark)
6406 (gnus-summary-show-thread) t)
6407 (gnus-summary-find-subject subject))
6408 (setq count (1+ count)))))
6409 (gnus-set-mode-line 'summary)
6410 ;; Return the number of marked articles.
6413 (defun gnus-summary-mark-as-processable (n &optional unmark)
6414 "Set the process mark on the next N articles.
6415 If N is negative, mark backward instead. If UNMARK is non-nil, remove
6416 the process mark instead. The difference between N and the actual
6417 number of articles marked is returned."
6419 (gnus-set-global-variables)
6420 (let ((backward (< n 0))
6425 (gnus-summary-remove-process-mark
6426 (gnus-summary-article-number))
6427 (gnus-summary-set-process-mark (gnus-summary-article-number)))
6428 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
6430 (if (/= 0 n) (gnus-message 7 "No more articles"))
6431 (gnus-summary-recenter)
6432 (gnus-summary-position-point)
6435 (defun gnus-summary-unmark-as-processable (n)
6436 "Remove the process mark from the next N articles.
6437 If N is negative, mark backward instead. The difference between N and
6438 the actual number of articles marked is returned."
6440 (gnus-set-global-variables)
6441 (gnus-summary-mark-as-processable n t))
6443 (defun gnus-summary-unmark-all-processable ()
6444 "Remove the process mark from all articles."
6446 (gnus-set-global-variables)
6448 (while gnus-newsgroup-processable
6449 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
6450 (gnus-summary-position-point))
6452 (defun gnus-summary-mark-as-expirable (n)
6453 "Mark N articles forward as expirable.
6454 If N is negative, mark backward instead. The difference between N and
6455 the actual number of articles marked is returned."
6457 (gnus-set-global-variables)
6458 (gnus-summary-mark-forward n gnus-expirable-mark))
6460 (defun gnus-summary-mark-article-as-replied (article)
6461 "Mark ARTICLE replied and update the summary line."
6462 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
6463 (let ((buffer-read-only nil))
6464 (when (gnus-summary-goto-subject article)
6465 (gnus-summary-update-secondary-mark article))))
6467 (defun gnus-summary-set-bookmark (article)
6468 "Set a bookmark in current article."
6469 (interactive (list (gnus-summary-article-number)))
6470 (gnus-set-global-variables)
6471 (if (or (not (get-buffer gnus-article-buffer))
6472 (not gnus-current-article)
6473 (not gnus-article-current)
6474 (not (equal gnus-newsgroup-name (car gnus-article-current))))
6475 (error "No current article selected"))
6476 ;; Remove old bookmark, if one exists.
6477 (let ((old (assq article gnus-newsgroup-bookmarks)))
6478 (if old (setq gnus-newsgroup-bookmarks
6479 (delq old gnus-newsgroup-bookmarks))))
6480 ;; Set the new bookmark, which is on the form
6481 ;; (article-number . line-number-in-body).
6482 (setq gnus-newsgroup-bookmarks
6486 (set-buffer gnus-article-buffer)
6490 (goto-char (point-min))
6491 (search-forward "\n\n" nil t)
6494 gnus-newsgroup-bookmarks))
6495 (gnus-message 6 "A bookmark has been added to the current article."))
6497 (defun gnus-summary-remove-bookmark (article)
6498 "Remove the bookmark from the current article."
6499 (interactive (list (gnus-summary-article-number)))
6500 (gnus-set-global-variables)
6501 ;; Remove old bookmark, if one exists.
6502 (let ((old (assq article gnus-newsgroup-bookmarks)))
6505 (setq gnus-newsgroup-bookmarks
6506 (delq old gnus-newsgroup-bookmarks))
6507 (gnus-message 6 "Removed bookmark."))
6508 (gnus-message 6 "No bookmark in current article."))))
6510 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6511 (defun gnus-summary-mark-as-dormant (n)
6512 "Mark N articles forward as dormant.
6513 If N is negative, mark backward instead. The difference between N and
6514 the actual number of articles marked is returned."
6516 (gnus-set-global-variables)
6517 (gnus-summary-mark-forward n gnus-dormant-mark))
6519 (defun gnus-summary-set-process-mark (article)
6520 "Set the process mark on ARTICLE and update the summary line."
6521 (setq gnus-newsgroup-processable
6523 (delq article gnus-newsgroup-processable)))
6524 (when (gnus-summary-goto-subject article)
6525 (gnus-summary-show-thread)
6526 (gnus-summary-update-secondary-mark article)))
6528 (defun gnus-summary-remove-process-mark (article)
6529 "Remove the process mark from ARTICLE and update the summary line."
6530 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
6531 (when (gnus-summary-goto-subject article)
6532 (gnus-summary-show-thread)
6533 (gnus-summary-update-secondary-mark article)))
6535 (defun gnus-summary-set-saved-mark (article)
6536 "Set the process mark on ARTICLE and update the summary line."
6537 (push article gnus-newsgroup-saved)
6538 (when (gnus-summary-goto-subject article)
6539 (gnus-summary-update-secondary-mark article)))
6541 (defun gnus-summary-mark-forward (n &optional mark no-expire)
6542 "Mark N articles as read forwards.
6543 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
6544 The difference between N and the actual number of articles marked is
6547 (gnus-set-global-variables)
6548 (let ((backward (< n 0))
6549 (gnus-summary-goto-unread
6550 (and gnus-summary-goto-unread
6551 (not (eq gnus-summary-goto-unread 'never))
6552 (not (memq mark (list gnus-unread-mark
6553 gnus-ticked-mark gnus-dormant-mark)))))
6555 (mark (or mark gnus-del-mark)))
6557 (gnus-summary-mark-article nil mark no-expire)
6558 (zerop (gnus-summary-next-subject
6560 (and gnus-summary-goto-unread
6561 (not (eq gnus-summary-goto-unread 'never)))
6564 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
6565 (gnus-summary-recenter)
6566 (gnus-summary-position-point)
6567 (gnus-set-mode-line 'summary)
6570 (defun gnus-summary-mark-article-as-read (mark)
6571 "Mark the current article quickly as read with MARK."
6572 (let ((article (gnus-summary-article-number)))
6573 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6574 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6575 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6576 (setq gnus-newsgroup-reads
6577 (cons (cons article mark) gnus-newsgroup-reads))
6578 ;; Possibly remove from cache, if that is used.
6579 (and gnus-use-cache (gnus-cache-enter-remove-article article))
6580 ;; Allow the backend to change the mark.
6581 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
6582 ;; Check for auto-expiry.
6583 (when (and gnus-newsgroup-auto-expire
6584 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6585 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6586 (= mark gnus-ancient-mark)
6587 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6588 (= mark gnus-duplicate-mark)))
6589 (setq mark gnus-expirable-mark)
6590 (push article gnus-newsgroup-expirable))
6591 ;; Set the mark in the buffer.
6592 (gnus-summary-update-mark mark 'unread)
6595 (defun gnus-summary-mark-article-as-unread (mark)
6596 "Mark the current article quickly as unread with MARK."
6597 (let ((article (gnus-summary-article-number)))
6599 (gnus-error 1 "Unmarkable article")
6600 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6601 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6602 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
6603 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
6604 (cond ((= mark gnus-ticked-mark)
6605 (push article gnus-newsgroup-marked))
6606 ((= mark gnus-dormant-mark)
6607 (push article gnus-newsgroup-dormant))
6609 (push article gnus-newsgroup-unreads)))
6610 (setq gnus-newsgroup-reads
6611 (delq (assq article gnus-newsgroup-reads)
6612 gnus-newsgroup-reads))
6614 ;; See whether the article is to be put in the cache.
6616 (vectorp (gnus-summary-article-header article))
6618 (gnus-cache-possibly-enter-article
6619 gnus-newsgroup-name article
6620 (gnus-summary-article-header article)
6621 (= mark gnus-ticked-mark)
6622 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6625 (gnus-summary-update-mark mark 'unread))
6628 (defun gnus-summary-mark-article (&optional article mark no-expire)
6629 "Mark ARTICLE with MARK. MARK can be any character.
6630 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
6631 `??' (dormant) and `?E' (expirable).
6632 If MARK is nil, then the default character `?D' is used.
6633 If ARTICLE is nil, then the article on the current line will be
6635 ;; The mark might be a string.
6637 (setq mark (aref mark 0)))
6638 ;; If no mark is given, then we check auto-expiring.
6639 (and (not no-expire)
6640 gnus-newsgroup-auto-expire
6643 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6644 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6645 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6646 (= mark gnus-duplicate-mark))))
6647 (setq mark gnus-expirable-mark))
6648 (let* ((mark (or mark gnus-del-mark))
6649 (article (or article (gnus-summary-article-number))))
6650 (or article (error "No article on current line"))
6651 (if (or (= mark gnus-unread-mark)
6652 (= mark gnus-ticked-mark)
6653 (= mark gnus-dormant-mark))
6654 (gnus-mark-article-as-unread article mark)
6655 (gnus-mark-article-as-read article mark))
6657 ;; See whether the article is to be put in the cache.
6659 (not (= mark gnus-canceled-mark))
6660 (vectorp (gnus-summary-article-header article))
6662 (gnus-cache-possibly-enter-article
6663 gnus-newsgroup-name article
6664 (gnus-summary-article-header article)
6665 (= mark gnus-ticked-mark)
6666 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6668 (if (gnus-summary-goto-subject article nil t)
6669 (let ((buffer-read-only nil))
6670 (gnus-summary-show-thread)
6672 (gnus-summary-update-mark mark 'unread)
6675 (defun gnus-summary-update-secondary-mark (article)
6676 "Update the secondary (read, process, cache) mark."
6677 (gnus-summary-update-mark
6678 (cond ((memq article gnus-newsgroup-processable)
6680 ((memq article gnus-newsgroup-cached)
6682 ((memq article gnus-newsgroup-replied)
6684 ((memq article gnus-newsgroup-saved)
6686 (t gnus-unread-mark))
6688 (when (gnus-visual-p 'summary-highlight 'highlight)
6689 (run-hooks 'gnus-summary-update-hook))
6692 (defun gnus-summary-update-mark (mark type)
6693 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
6694 (buffer-read-only nil))
6695 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
6696 (and (looking-at "\r") (setq forward (1+ forward)))
6698 (<= (+ forward (point)) (point-max)))
6699 ;; Go to the right position on the line.
6700 (goto-char (+ forward (point)))
6701 ;; Replace the old mark with the new mark.
6702 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
6703 ;; Optionally update the marks by some user rule.
6704 (when (eq type 'unread)
6706 (gnus-data-find (gnus-summary-article-number)) mark)
6707 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
6709 (defun gnus-mark-article-as-read (article &optional mark)
6710 "Enter ARTICLE in the pertinent lists and remove it from others."
6711 ;; Make the article expirable.
6712 (let ((mark (or mark gnus-del-mark)))
6713 (if (= mark gnus-expirable-mark)
6714 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
6715 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
6716 ;; Remove from unread and marked lists.
6717 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6718 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6719 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6720 (push (cons article mark) gnus-newsgroup-reads)
6721 ;; Possibly remove from cache, if that is used.
6722 (when gnus-use-cache
6723 (gnus-cache-enter-remove-article article))))
6725 (defun gnus-mark-article-as-unread (article &optional mark)
6726 "Enter ARTICLE in the pertinent lists and remove it from others."
6727 (let ((mark (or mark gnus-ticked-mark)))
6728 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
6729 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
6730 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
6731 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6733 ;; Unsuppress duplicates?
6734 (when gnus-suppress-duplicates
6735 (gnus-dup-unsuppress-article article))
6737 (cond ((= mark gnus-ticked-mark)
6738 (push article gnus-newsgroup-marked))
6739 ((= mark gnus-dormant-mark)
6740 (push article gnus-newsgroup-dormant))
6742 (push article gnus-newsgroup-unreads)))
6743 (setq gnus-newsgroup-reads
6744 (delq (assq article gnus-newsgroup-reads)
6745 gnus-newsgroup-reads))))
6747 (defalias 'gnus-summary-mark-as-unread-forward
6748 'gnus-summary-tick-article-forward)
6749 (make-obsolete 'gnus-summary-mark-as-unread-forward
6750 'gnus-summary-tick-article-forward)
6751 (defun gnus-summary-tick-article-forward (n)
6752 "Tick N articles forwards.
6753 If N is negative, tick backwards instead.
6754 The difference between N and the number of articles ticked is returned."
6756 (gnus-summary-mark-forward n gnus-ticked-mark))
6758 (defalias 'gnus-summary-mark-as-unread-backward
6759 'gnus-summary-tick-article-backward)
6760 (make-obsolete 'gnus-summary-mark-as-unread-backward
6761 'gnus-summary-tick-article-backward)
6762 (defun gnus-summary-tick-article-backward (n)
6763 "Tick N articles backwards.
6764 The difference between N and the number of articles ticked is returned."
6766 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
6768 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6769 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6770 (defun gnus-summary-tick-article (&optional article clear-mark)
6771 "Mark current article as unread.
6772 Optional 1st argument ARTICLE specifies article number to be marked as unread.
6773 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
6775 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
6778 (defun gnus-summary-mark-as-read-forward (n)
6779 "Mark N articles as read forwards.
6780 If N is negative, mark backwards instead.
6781 The difference between N and the actual number of articles marked is
6784 (gnus-summary-mark-forward n gnus-del-mark t))
6786 (defun gnus-summary-mark-as-read-backward (n)
6787 "Mark the N articles as read backwards.
6788 The difference between N and the actual number of articles marked is
6791 (gnus-summary-mark-forward (- n) gnus-del-mark t))
6793 (defun gnus-summary-mark-as-read (&optional article mark)
6794 "Mark current article as read.
6795 ARTICLE specifies the article to be marked as read.
6796 MARK specifies a string to be inserted at the beginning of the line."
6797 (gnus-summary-mark-article article mark))
6799 (defun gnus-summary-clear-mark-forward (n)
6800 "Clear marks from N articles forward.
6801 If N is negative, clear backward instead.
6802 The difference between N and the number of marks cleared is returned."
6804 (gnus-summary-mark-forward n gnus-unread-mark))
6806 (defun gnus-summary-clear-mark-backward (n)
6807 "Clear marks from N articles backward.
6808 The difference between N and the number of marks cleared is returned."
6810 (gnus-summary-mark-forward (- n) gnus-unread-mark))
6812 (defun gnus-summary-mark-unread-as-read ()
6813 "Intended to be used by `gnus-summary-mark-article-hook'."
6814 (when (memq gnus-current-article gnus-newsgroup-unreads)
6815 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
6817 (defun gnus-summary-mark-read-and-unread-as-read ()
6818 "Intended to be used by `gnus-summary-mark-article-hook'."
6819 (let ((mark (gnus-summary-article-mark)))
6820 (when (or (gnus-unread-mark-p mark)
6821 (gnus-read-mark-p mark))
6822 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
6824 (defun gnus-summary-mark-region-as-read (point mark all)
6825 "Mark all unread articles between point and mark as read.
6826 If given a prefix, mark all articles between point and mark as read,
6827 even ticked and dormant ones."
6828 (interactive "r\nP")
6837 (memq (setq article (gnus-summary-article-number))
6838 gnus-newsgroup-unreads))
6839 (gnus-summary-mark-article article gnus-del-mark))
6841 (gnus-summary-find-next))))))
6843 (defun gnus-summary-mark-below (score mark)
6844 "Mark articles with score less than SCORE with MARK."
6845 (interactive "P\ncMark: ")
6846 (gnus-set-global-variables)
6847 (setq score (if score
6848 (prefix-numeric-value score)
6849 (or gnus-summary-default-score 0)))
6851 (set-buffer gnus-summary-buffer)
6852 (goto-char (point-min))
6855 (and (< (gnus-summary-article-score) score)
6856 (gnus-summary-mark-article nil mark))
6857 (gnus-summary-find-next)))))
6859 (defun gnus-summary-kill-below (&optional score)
6860 "Mark articles with score below SCORE as read."
6862 (gnus-set-global-variables)
6863 (gnus-summary-mark-below score gnus-killed-mark))
6865 (defun gnus-summary-clear-above (&optional score)
6866 "Clear all marks from articles with score above SCORE."
6868 (gnus-set-global-variables)
6869 (gnus-summary-mark-above score gnus-unread-mark))
6871 (defun gnus-summary-tick-above (&optional score)
6872 "Tick all articles with score above SCORE."
6874 (gnus-set-global-variables)
6875 (gnus-summary-mark-above score gnus-ticked-mark))
6877 (defun gnus-summary-mark-above (score mark)
6878 "Mark articles with score over SCORE with MARK."
6879 (interactive "P\ncMark: ")
6880 (gnus-set-global-variables)
6881 (setq score (if score
6882 (prefix-numeric-value score)
6883 (or gnus-summary-default-score 0)))
6885 (set-buffer gnus-summary-buffer)
6886 (goto-char (point-min))
6888 (if (> (gnus-summary-article-score) score)
6889 (gnus-summary-mark-article nil mark))
6891 (gnus-summary-find-next)))))
6893 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6894 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
6895 (defun gnus-summary-limit-include-expunged (&optional no-error)
6896 "Display all the hidden articles that were expunged for low scores."
6898 (gnus-set-global-variables)
6899 (let ((buffer-read-only nil))
6900 (let ((scored gnus-newsgroup-scored)
6903 (or (gnus-summary-goto-subject (caar scored))
6904 (and (setq h (gnus-summary-article-header (caar scored)))
6905 (< (cdar scored) gnus-summary-expunge-below)
6906 (setq headers (cons h headers))))
6907 (setq scored (cdr scored)))
6909 (when (not no-error)
6910 (error "No expunged articles hidden."))
6911 (goto-char (point-min))
6912 (gnus-summary-prepare-unthreaded (nreverse headers))
6913 (goto-char (point-min))
6914 (gnus-summary-position-point)
6917 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
6918 "Mark all articles not marked as unread in this newsgroup as read.
6919 If prefix argument ALL is non-nil, all articles are marked as read.
6920 If QUIETLY is non-nil, no questions will be asked.
6921 If TO-HERE is non-nil, it should be a point in the buffer. All
6922 articles before this point will be marked as read.
6923 The number of articles marked as read is returned."
6925 (gnus-set-global-variables)
6928 (not gnus-interactive-catchup) ;Without confirmation?
6932 "Mark absolutely all articles as read? "
6933 "Mark all unread articles as read? ")))
6935 (not gnus-newsgroup-adaptive)
6936 (not gnus-newsgroup-auto-expire))
6939 (setq gnus-newsgroup-marked nil
6940 gnus-newsgroup-dormant nil))
6941 (setq gnus-newsgroup-unreads nil))
6942 ;; We actually mark all articles as canceled, which we
6943 ;; have to do when using auto-expiry or adaptive scoring.
6944 (gnus-summary-show-all-threads)
6945 (when (gnus-summary-first-subject (not all))