1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
36 (defvar gnus-kill-summary-on-exit t
37 "*If non-nil, kill the summary buffer when you exit from it.
38 If nil, the summary will become a \"*Dead Summary*\" buffer, and
39 it will be killed sometime later.")
41 (defvar gnus-fetch-old-headers nil
42 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
43 If an unread article in the group refers to an older, already read (or
44 just marked as read) article, the old article will not normally be
45 displayed in the Summary buffer. If this variable is non-nil, Gnus
46 will attempt to grab the headers to the old articles, and thereby
47 build complete threads. If it has the value `some', only enough
48 headers to connect otherwise loose threads will be displayed.
49 This variable can also be a number. In that case, no more than that
50 number of old headers will be fetched.
52 The server has to support NOV for any of this to work.")
54 (defvar gnus-summary-make-false-root 'adopt
55 "*nil means that Gnus won't gather loose threads.
56 If the root of a thread has expired or been read in a previous
57 session, the information necessary to build a complete thread has been
58 lost. Instead of having many small sub-threads from this original thread
59 scattered all over the summary buffer, Gnus can gather them.
61 If non-nil, Gnus will try to gather all loose sub-threads from an
62 original thread into one large thread.
64 If this variable is non-nil, it should be one of `none', `adopt',
67 If this variable is `none', Gnus will not make a false root, but just
68 present the sub-threads after another.
69 If this variable is `dummy', Gnus will create a dummy root that will
70 have all the sub-threads as children.
71 If this variable is `adopt', Gnus will make one of the \"children\"
72 the parent and mark all the step-children as such.
73 If this variable is `empty', the \"children\" are printed with empty
74 subject fields. (Or rather, they will be printed with a string
75 given by the `gnus-summary-same-subject' variable.)")
77 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
78 "*A regexp to match subjects to be excluded from loose thread gathering.
79 As loose thread gathering is done on subjects only, that means that
80 there can be many false gatherings performed. By rooting out certain
81 common subjects, gathering might become saner.")
83 (defvar gnus-summary-gather-subject-limit nil
84 "*Maximum length of subject comparisons when gathering loose threads.
85 Use nil to compare full subjects. Setting this variable to a low
86 number will help gather threads that have been corrupted by
87 newsreaders chopping off subject lines, but it might also mean that
88 unrelated articles that have subject that happen to begin with the
89 same few characters will be incorrectly gathered.
91 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
94 (defvar gnus-simplify-ignored-prefixes nil
95 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.")
97 (defvar gnus-build-sparse-threads nil
98 "*If non-nil, fill in the gaps in threads.
99 If `some', only fill in the gaps that are needed to tie loose threads
100 together. If `more', fill in all leaf nodes that Gnus can find. If
101 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
103 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
104 "Function used for gathering loose threads.
105 There are two pre-defined functions: `gnus-gather-threads-by-subject',
106 which only takes Subjects into consideration; and
107 `gnus-gather-threads-by-references', which compared the References
108 headers of the articles to find matches.")
110 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
111 (defvar gnus-summary-same-subject ""
112 "*String indicating that the current article has the same subject as the previous.
113 This variable will only be used if the value of
114 `gnus-summary-make-false-root' is `empty'.")
116 (defvar gnus-summary-goto-unread t
117 "*If non-nil, marking commands will go to the next unread article.
118 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
119 whether it is read or not.")
121 (defvar gnus-summary-default-score 0
122 "*Default article score level.
123 If this variable is nil, scoring will be disabled.")
125 (defvar gnus-summary-zcore-fuzz 0
126 "*Fuzziness factor for the zcore in the summary buffer.
127 Articles with scores closer than this to `gnus-summary-default-score'
128 will not be marked.")
130 (defvar gnus-simplify-subject-fuzzy-regexp nil
131 "*Strings to be removed when doing fuzzy matches.
132 This can either be a regular expression or list of regular expressions
133 that will be removed from subject strings if fuzzy subject
134 simplification is selected.")
136 (defvar gnus-show-threads t
137 "*If non-nil, display threads in summary mode.")
139 (defvar gnus-thread-hide-subtree nil
140 "*If non-nil, hide all threads initially.
141 If threads are hidden, you have to run the command
142 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
143 to expose hidden threads.")
145 (defvar gnus-thread-hide-killed t
146 "*If non-nil, hide killed threads automatically.")
148 (defvar gnus-thread-ignore-subject nil
149 "*If non-nil, ignore subjects and do all threading based on the Reference header.
150 If nil, which is the default, articles that have different subjects
151 from their parents will start separate threads.")
153 (defvar gnus-thread-operation-ignore-subject t
154 "*If non-nil, subjects will be ignored when doing thread commands.
155 This affects commands like `gnus-summary-kill-thread' and
156 `gnus-summary-lower-thread'.
158 If this variable is nil, articles in the same thread with different
159 subjects will not be included in the operation in question. If this
160 variable is `fuzzy', only articles that have subjects that are fuzzily
161 equal will be included.")
163 (defvar gnus-thread-indent-level 4
164 "*Number that says how much each sub-thread should be indented.")
166 (defvar gnus-auto-extend-newsgroup t
167 "*If non-nil, extend newsgroup forward and backward when requested.")
169 (defvar gnus-auto-select-first t
170 "*If nil, don't select the first unread article when entering a group.
171 If this variable is `best', select the highest-scored unread article
172 in the group. If neither nil nor `best', select the first unread
175 If you want to prevent automatic selection of the first unread article
176 in some newsgroups, set the variable to nil in
177 `gnus-select-group-hook'.")
179 (defvar gnus-auto-select-next t
180 "*If non-nil, offer to go to the next group from the end of the previous.
181 If the value is t and the next newsgroup is empty, Gnus will exit
182 summary mode and go back to group mode. If the value is neither nil
183 nor t, Gnus will select the following unread newsgroup. In
184 particular, if the value is the symbol `quietly', the next unread
185 newsgroup will be selected without any confirmation, and if it is
186 `almost-quietly', the next group will be selected without any
187 confirmation if you are located on the last article in the group.
188 Finally, if this variable is `slightly-quietly', the `Z n' command
189 will go to the next group without confirmation.")
191 (defvar gnus-auto-select-same nil
192 "*If non-nil, select the next article with the same subject.")
194 (defvar gnus-summary-check-current nil
195 "*If non-nil, consider the current article when moving.
196 The \"unread\" movement commands will stay on the same line if the
197 current article is unread.")
199 (defvar gnus-auto-center-summary t
200 "*If non-nil, always center the current summary buffer.
201 In particular, if `vertical' do only vertical recentering. If non-nil
202 and non-`vertical', do both horizontal and vertical recentering.")
204 (defvar gnus-show-all-headers nil
205 "*If non-nil, don't hide any headers.")
207 (defvar gnus-single-article-buffer t
208 "*If non-nil, display all articles in the same buffer.
209 If nil, each group will get its own article buffer.")
211 (defvar gnus-break-pages t
212 "*If non-nil, do page breaking on articles.
213 The page delimiter is specified by the `gnus-page-delimiter'
216 (defvar gnus-show-mime nil
217 "*If non-nil, do mime processing of articles.
218 The articles will simply be fed to the function given by
219 `gnus-show-mime-method'.")
221 (defvar gnus-move-split-methods nil
222 "*Variable used to suggest where articles are to be moved to.
223 It uses the same syntax as the `gnus-split-methods' variable.")
225 ;; Mark variables suggested by Thomas Michanek
226 ;; <Thomas.Michanek@telelogic.se>.
227 (defvar gnus-unread-mark ?
228 "*Mark used for unread articles.")
229 (defvar gnus-ticked-mark ?!
230 "*Mark used for ticked articles.")
231 (defvar gnus-dormant-mark ??
232 "*Mark used for dormant articles.")
233 (defvar gnus-del-mark ?r
234 "*Mark used for del'd articles.")
235 (defvar gnus-read-mark ?R
236 "*Mark used for read articles.")
237 (defvar gnus-expirable-mark ?E
238 "*Mark used for expirable articles.")
239 (defvar gnus-killed-mark ?K
240 "*Mark used for killed articles.")
241 (defvar gnus-souped-mark ?F
242 "*Mark used for killed articles.")
243 (defvar gnus-kill-file-mark ?X
244 "*Mark used for articles killed by kill files.")
245 (defvar gnus-low-score-mark ?Y
246 "*Mark used for articles with a low score.")
247 (defvar gnus-catchup-mark ?C
248 "*Mark used for articles that are caught up.")
249 (defvar gnus-replied-mark ?A
250 "*Mark used for articles that have been replied to.")
251 (defvar gnus-cached-mark ?*
252 "*Mark used for articles that are in the cache.")
253 (defvar gnus-saved-mark ?S
254 "*Mark used for articles that have been saved to.")
255 (defvar gnus-ancient-mark ?O
256 "*Mark used for ancient articles.")
257 (defvar gnus-sparse-mark ?Q
258 "*Mark used for sparsely reffed articles.")
259 (defvar gnus-canceled-mark ?G
260 "*Mark used for canceled articles.")
261 (defvar gnus-duplicate-mark ?M
262 "*Mark used for duplicate articles.")
263 (defvar gnus-score-over-mark ?+
264 "*Score mark used for articles with high scores.")
265 (defvar gnus-score-below-mark ?-
266 "*Score mark used for articles with low scores.")
267 (defvar gnus-empty-thread-mark ?
268 "*There is no thread under the article.")
269 (defvar gnus-not-empty-thread-mark ?=
270 "*There is a thread under the article.")
272 (defvar gnus-view-pseudo-asynchronously nil
273 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
275 (defvar gnus-view-pseudos nil
276 "*If `automatic', pseudo-articles will be viewed automatically.
277 If `not-confirm', pseudos will be viewed automatically, and the user
278 will not be asked to confirm the command.")
280 (defvar gnus-view-pseudos-separately t
281 "*If non-nil, one pseudo-article will be created for each file to be viewed.
282 If nil, all files that use the same viewing command will be given as a
283 list of parameters to that command.")
285 (defvar gnus-insert-pseudo-articles t
286 "*If non-nil, insert pseudo-articles when decoding articles.")
288 (defvar gnus-summary-dummy-line-format
290 "*The format specification for the dummy roots in the summary buffer.
291 It works along the same lines as a normal formatting string,
292 with some simple extensions.
296 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
297 "*The format specification for the summary mode line.
298 It works along the same lines as a normal formatting string,
299 with some simple extensions:
302 %p Unprefixed group name
303 %A Current article number
305 %U Number of unread articles in the group
306 %e Number of unselected articles in the group
307 %Z A string with unread/unselected article counts
308 %g Shortish group name
309 %S Subject of the current article
311 %s Current score file name
312 %d Number of dormant articles
313 %r Number of articles that have been marked as read in this session
314 %E Number of articles expunged by the score files")
316 (defvar gnus-summary-mark-below 0
317 "*Mark all articles with a score below this variable as read.
318 This variable is local to each summary buffer and usually set by the
321 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
322 "*List of functions used for sorting articles in the summary buffer.
323 This variable is only used when not using a threaded display.")
325 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
326 "*List of functions used for sorting threads in the summary buffer.
327 By default, threads are sorted by article number.
329 Each function takes two threads and return non-nil if the first thread
330 should be sorted before the other. If you use more than one function,
331 the primary sort function should be the last. You should probably
332 always include `gnus-thread-sort-by-number' in the list of sorting
333 functions -- preferably first.
335 Ready-mady functions include `gnus-thread-sort-by-number',
336 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
337 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
338 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
340 (defvar gnus-thread-score-function '+
341 "*Function used for calculating the total score of a thread.
343 The function is called with the scores of the article and each
344 subthread and should then return the score of the thread.
346 Some functions you can use are `+', `max', or `min'.")
348 (defvar gnus-summary-expunge-below nil
349 "All articles that have a score less than this variable will be expunged.")
351 (defvar gnus-thread-expunge-below nil
352 "All threads that have a total score less than this variable will be expunged.
353 See `gnus-thread-score-function' for en explanation of what a
354 \"thread score\" is.")
356 (defvar gnus-summary-mode-hook nil
357 "*A hook for Gnus summary mode.
358 This hook is run before any variables are set in the summary buffer.")
360 (defvar gnus-summary-menu-hook nil
361 "*Hook run after the creation of the summary mode menu.")
363 (defvar gnus-summary-exit-hook nil
364 "*A hook called on exit from the summary buffer.")
366 (defvar gnus-summary-prepare-hook nil
367 "*A hook called after the summary buffer has been generated.
368 If you want to modify the summary buffer, you can use this hook.")
370 (defvar gnus-summary-generate-hook nil
371 "*A hook run just before generating the summary buffer.
372 This hook is commonly used to customize threading variables and the
375 (defvar gnus-select-group-hook nil
376 "*A hook called when a newsgroup is selected.
378 If you'd like to simplify subjects like the
379 `gnus-summary-next-same-subject' command does, you can use the
382 (setq gnus-select-group-hook
385 (mapcar (lambda (header)
386 (mail-header-set-subject
388 (gnus-simplify-subject
389 (mail-header-subject header) 're-only)))
390 gnus-newsgroup-headers))))")
392 (defvar gnus-select-article-hook nil
393 "*A hook called when an article is selected.")
395 (defvar gnus-visual-mark-article-hook
396 (list 'gnus-highlight-selected-summary)
397 "*Hook run after selecting an article in the summary buffer.
398 It is meant to be used for highlighting the article in some way. It
399 is not run if `gnus-visual' is nil.")
401 (defvar gnus-parse-headers-hook nil
402 "*A hook called before parsing the headers.")
403 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
405 (defvar gnus-exit-group-hook nil
406 "*A hook called when exiting (not quitting) summary mode.")
408 (defvar gnus-summary-update-hook
409 (list 'gnus-summary-highlight-line)
410 "*A hook called when a summary line is changed.
411 The hook will not be called if `gnus-visual' is nil.
413 The default function `gnus-summary-highlight-line' will
414 highlight the line according to the `gnus-summary-highlight'
417 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
418 "*A hook called when an article is selected for the first time.
419 The hook is intended to mark an article as read (or unread)
420 automatically when it is selected.")
422 (defvar gnus-summary-display-table
423 ;; Change the display table. Odd characters have a tendency to mess
424 ;; up nicely formatted displays - we make all possible glyphs
425 ;; display only a single character.
427 ;; We start from the standard display table, if any.
428 (let ((table (or (copy-sequence standard-display-table)
429 (make-display-table)))
430 ;; Nix out all the control chars...
432 (while (>= (setq i (1- i)) 0)
434 ;; ... but not newline and cr, of course. (cr is necessary for the
435 ;; selective display).
438 ;; We nix out any glyphs over 126 that are not set already.
440 (while (>= (setq i (1- i)) 127)
441 ;; Only modify if the entry is nil.
443 (aset table i [??]))))
445 "Display table used in summary mode buffers.")
447 ;;; Internal variables
449 (defvar gnus-original-article nil)
450 (defvar gnus-article-internal-prepare-hook nil)
451 (defvar gnus-newsgroup-process-stack nil)
453 (defvar gnus-thread-indent-array nil)
454 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
456 ;; Avoid highlighting in kill files.
457 (defvar gnus-summary-inhibit-highlight nil)
458 (defvar gnus-newsgroup-selected-overlay nil)
459 (defvar gnus-inhibit-limiting nil)
460 (defvar gnus-newsgroup-adaptive-score-file nil)
461 (defvar gnus-current-score-file nil)
462 (defvar gnus-current-move-group nil)
463 (defvar gnus-current-copy-group nil)
464 (defvar gnus-current-crosspost-group nil)
466 (defvar gnus-newsgroup-dependencies nil)
467 (defvar gnus-newsgroup-adaptive nil)
468 (defvar gnus-summary-display-article-function nil)
469 (defvar gnus-summary-highlight-line-function nil
470 "Function called after highlighting a summary line.")
472 (defvar gnus-summary-line-format-alist
473 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
474 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
475 (?s gnus-tmp-subject-or-nil ?s)
476 (?n gnus-tmp-name ?s)
477 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
479 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
481 (?F gnus-tmp-from ?s)
482 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
483 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
484 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
485 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
486 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
487 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
488 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
489 (?L gnus-tmp-lines ?d)
490 (?I gnus-tmp-indentation ?s)
491 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
492 (?R gnus-tmp-replied ?c)
493 (?\[ gnus-tmp-opening-bracket ?c)
494 (?\] gnus-tmp-closing-bracket ?c)
495 (?\> (make-string gnus-tmp-level ? ) ?s)
496 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
497 (?i gnus-tmp-score ?d)
498 (?z gnus-tmp-score-char ?c)
499 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
500 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
501 (?U gnus-tmp-unread ?c)
502 (?t (gnus-summary-number-of-articles-in-thread
503 (and (boundp 'thread) (car thread)) gnus-tmp-level)
505 (?e (gnus-summary-number-of-articles-in-thread
506 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
508 (?u gnus-tmp-user-defined ?s)
509 (?P (gnus-pick-line-number) ?d))
510 "An alist of format specifications that can appear in summary lines,
511 and what variables they correspond with, along with the type of the
512 variable (string, integer, character, etc).")
514 (defvar gnus-summary-dummy-line-format-alist
515 `((?S gnus-tmp-subject ?s)
516 (?N gnus-tmp-number ?d)
517 (?u gnus-tmp-user-defined ?s)))
519 (defvar gnus-summary-mode-line-format-alist
520 `((?G gnus-tmp-group-name ?s)
521 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
522 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
523 (?A gnus-tmp-article-number ?d)
524 (?Z gnus-tmp-unread-and-unselected ?s)
526 (?U gnus-tmp-unread-and-unticked ?d)
527 (?S gnus-tmp-subject ?s)
528 (?e gnus-tmp-unselected ?d)
529 (?u gnus-tmp-user-defined ?s)
530 (?d (length gnus-newsgroup-dormant) ?d)
531 (?t (length gnus-newsgroup-marked) ?d)
532 (?r (length gnus-newsgroup-reads) ?d)
533 (?E gnus-newsgroup-expunged-tally ?d)
534 (?s (gnus-current-score-file-nondirectory) ?s)))
536 (defvar gnus-last-search-regexp nil
537 "Default regexp for article search command.")
539 (defvar gnus-last-shell-command nil
540 "Default shell command on article.")
542 (defvar gnus-newsgroup-begin nil)
543 (defvar gnus-newsgroup-end nil)
544 (defvar gnus-newsgroup-last-rmail nil)
545 (defvar gnus-newsgroup-last-mail nil)
546 (defvar gnus-newsgroup-last-folder nil)
547 (defvar gnus-newsgroup-last-file nil)
548 (defvar gnus-newsgroup-auto-expire nil)
549 (defvar gnus-newsgroup-active nil)
551 (defvar gnus-newsgroup-data nil)
552 (defvar gnus-newsgroup-data-reverse nil)
553 (defvar gnus-newsgroup-limit nil)
554 (defvar gnus-newsgroup-limits nil)
556 (defvar gnus-newsgroup-unreads nil
557 "List of unread articles in the current newsgroup.")
559 (defvar gnus-newsgroup-unselected nil
560 "List of unselected unread articles in the current newsgroup.")
562 (defvar gnus-newsgroup-reads nil
563 "Alist of read articles and article marks in the current newsgroup.")
565 (defvar gnus-newsgroup-expunged-tally nil)
567 (defvar gnus-newsgroup-marked nil
568 "List of ticked articles in the current newsgroup (a subset of unread art).")
570 (defvar gnus-newsgroup-killed nil
571 "List of ranges of articles that have been through the scoring process.")
573 (defvar gnus-newsgroup-cached nil
574 "List of articles that come from the article cache.")
576 (defvar gnus-newsgroup-saved nil
577 "List of articles that have been saved.")
579 (defvar gnus-newsgroup-kill-headers nil)
581 (defvar gnus-newsgroup-replied nil
582 "List of articles that have been replied to in the current newsgroup.")
584 (defvar gnus-newsgroup-expirable nil
585 "List of articles in the current newsgroup that can be expired.")
587 (defvar gnus-newsgroup-processable nil
588 "List of articles in the current newsgroup that can be processed.")
590 (defvar gnus-newsgroup-bookmarks nil
591 "List of articles in the current newsgroup that have bookmarks.")
593 (defvar gnus-newsgroup-dormant nil
594 "List of dormant articles in the current newsgroup.")
596 (defvar gnus-newsgroup-scored nil
597 "List of scored articles in the current newsgroup.")
599 (defvar gnus-newsgroup-headers nil
600 "List of article headers in the current newsgroup.")
602 (defvar gnus-newsgroup-threads nil)
604 (defvar gnus-newsgroup-prepared nil
605 "Whether the current group has been prepared properly.")
607 (defvar gnus-newsgroup-ancient nil
608 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
610 (defvar gnus-newsgroup-sparse nil)
612 (defvar gnus-current-article nil)
613 (defvar gnus-article-current nil)
614 (defvar gnus-current-headers nil)
615 (defvar gnus-have-all-headers nil)
616 (defvar gnus-last-article nil)
617 (defvar gnus-newsgroup-history nil)
619 (defconst gnus-summary-local-variables
620 '(gnus-newsgroup-name
621 gnus-newsgroup-begin gnus-newsgroup-end
622 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
623 gnus-newsgroup-last-folder gnus-newsgroup-last-file
624 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
625 gnus-newsgroup-unselected gnus-newsgroup-marked
626 gnus-newsgroup-reads gnus-newsgroup-saved
627 gnus-newsgroup-replied gnus-newsgroup-expirable
628 gnus-newsgroup-processable gnus-newsgroup-killed
629 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
630 gnus-newsgroup-headers gnus-newsgroup-threads
631 gnus-newsgroup-prepared gnus-summary-highlight-line-function
632 gnus-current-article gnus-current-headers gnus-have-all-headers
633 gnus-last-article gnus-article-internal-prepare-hook
634 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
635 gnus-newsgroup-scored gnus-newsgroup-kill-headers
636 gnus-thread-expunge-below
637 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
638 (gnus-summary-mark-below . global)
639 gnus-newsgroup-active gnus-scores-exclude-files
640 gnus-newsgroup-history gnus-newsgroup-ancient
641 gnus-newsgroup-sparse gnus-newsgroup-process-stack
642 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
643 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
644 (gnus-newsgroup-expunged-tally . 0)
645 gnus-cache-removable-articles gnus-newsgroup-cached
646 gnus-newsgroup-data gnus-newsgroup-data-reverse
647 gnus-newsgroup-limit gnus-newsgroup-limits)
648 "Variables that are buffer-local to the summary buffers.")
650 ;; Byte-compiler warning.
651 (defvar gnus-article-mode-map)
653 ;; Subject simplification.
655 (defsubst gnus-simplify-subject-re (subject)
656 "Remove \"Re:\" from subject lines."
657 (if (string-match "^[Rr][Ee]: *" subject)
658 (substring subject (match-end 0))
661 (defun gnus-simplify-subject (subject &optional re-only)
662 "Remove `Re:' and words in parentheses.
663 If RE-ONLY is non-nil, strip leading `Re:'s only."
664 (let ((case-fold-search t)) ;Ignore case.
665 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
666 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
667 (setq subject (substring subject (match-end 0))))
668 ;; Remove uninteresting prefixes.
669 (if (and (not re-only)
670 gnus-simplify-ignored-prefixes
671 (string-match gnus-simplify-ignored-prefixes subject))
672 (setq subject (substring subject (match-end 0))))
673 ;; Remove words in parentheses from end.
675 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
676 (setq subject (substring subject 0 (match-beginning 0)))))
677 ;; Return subject string.
680 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
682 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
683 (defun gnus-simplify-buffer-fuzzy ()
684 (let ((case-fold-search t))
685 (goto-char (point-min))
686 (while (search-forward "\t" nil t)
687 (replace-match " " t t))
688 (goto-char (point-min))
689 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
690 (goto-char (match-beginning 0))
692 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
693 (looking-at "^[[].*: .*[]]$"))
694 (goto-char (point-min))
695 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
697 (replace-match "" t t))
698 (goto-char (point-min))
699 (while (re-search-forward "^[[].*: .*[]]$" nil t)
700 (goto-char (match-end 0))
703 (progn (goto-char (match-beginning 0)))
704 (re-search-forward ":"))))
705 (goto-char (point-min))
706 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
707 (replace-match "" t t))
708 (goto-char (point-min))
709 (while (re-search-forward " +" nil t)
710 (replace-match " " t t))
711 (goto-char (point-min))
712 (while (re-search-forward " $" nil t)
713 (replace-match "" t t))
714 (goto-char (point-min))
715 (while (re-search-forward "^ +" nil t)
716 (replace-match "" t t))
717 (goto-char (point-min))
718 (when gnus-simplify-subject-fuzzy-regexp
719 (if (listp gnus-simplify-subject-fuzzy-regexp)
720 (let ((list gnus-simplify-subject-fuzzy-regexp))
722 (goto-char (point-min))
723 (while (re-search-forward (car list) nil t)
724 (replace-match "" t t))
725 (setq list (cdr list))))
726 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
727 (replace-match "" t t))))))
729 (defun gnus-simplify-subject-fuzzy (subject)
730 "Siplify a subject string fuzzily."
732 (gnus-set-work-buffer)
733 (let ((case-fold-search t))
735 (inline (gnus-simplify-buffer-fuzzy))
738 (defsubst gnus-simplify-subject-fully (subject)
739 "Simplify a subject string according to the user's wishes."
741 ((null gnus-summary-gather-subject-limit)
742 (gnus-simplify-subject-re subject))
743 ((eq gnus-summary-gather-subject-limit 'fuzzy)
744 (gnus-simplify-subject-fuzzy subject))
745 ((numberp gnus-summary-gather-subject-limit)
746 (gnus-limit-string (gnus-simplify-subject-re subject)
747 gnus-summary-gather-subject-limit))
751 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
752 "Check whether two subjects are equal. If optional argument
753 simple-first is t, first argument is already simplified."
756 (equal (gnus-simplify-subject-fully s1)
757 (gnus-simplify-subject-fully s2)))
760 (gnus-simplify-subject-fully s2)))))
762 (defun gnus-offer-save-summaries ()
763 "Offer to save all active summary buffers."
765 (let ((buflist (buffer-list))
767 ;; Go through all buffers and find all summaries.
769 (and (setq bufname (buffer-name (car buflist)))
770 (string-match "Summary" bufname)
773 ;; We check that this is, indeed, a summary buffer.
774 (and (eq major-mode 'gnus-summary-mode)
775 ;; Also make sure this isn't bogus.
776 gnus-newsgroup-prepared))
777 (push bufname buffers))
778 (setq buflist (cdr buflist)))
779 ;; Go through all these summary buffers and offer to save them.
782 "Update summary buffer %s? "
783 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
786 (defun gnus-summary-bubble-group ()
787 "Increase the score of the current group.
788 This is a handy function to add to `gnus-summary-exit-hook' to
789 increase the score of each group you read."
790 (gnus-group-add-score gnus-newsgroup-name))
794 ;;; Gnus summary mode
797 (put 'gnus-summary-mode 'mode-class 'special)
800 ;; Non-orthogonal keys
802 (gnus-define-keys gnus-summary-mode-map
803 " " gnus-summary-next-page
804 "\177" gnus-summary-prev-page
805 [delete] gnus-summary-prev-page
806 "\r" gnus-summary-scroll-up
807 "n" gnus-summary-next-unread-article
808 "p" gnus-summary-prev-unread-article
809 "N" gnus-summary-next-article
810 "P" gnus-summary-prev-article
811 "\M-\C-n" gnus-summary-next-same-subject
812 "\M-\C-p" gnus-summary-prev-same-subject
813 "\M-n" gnus-summary-next-unread-subject
814 "\M-p" gnus-summary-prev-unread-subject
815 "." gnus-summary-first-unread-article
816 "," gnus-summary-best-unread-article
817 "\M-s" gnus-summary-search-article-forward
818 "\M-r" gnus-summary-search-article-backward
819 "<" gnus-summary-beginning-of-article
820 ">" gnus-summary-end-of-article
821 "j" gnus-summary-goto-article
822 "^" gnus-summary-refer-parent-article
823 "\M-^" gnus-summary-refer-article
824 "u" gnus-summary-tick-article-forward
825 "!" gnus-summary-tick-article-forward
826 "U" gnus-summary-tick-article-backward
827 "d" gnus-summary-mark-as-read-forward
828 "D" gnus-summary-mark-as-read-backward
829 "E" gnus-summary-mark-as-expirable
830 "\M-u" gnus-summary-clear-mark-forward
831 "\M-U" gnus-summary-clear-mark-backward
832 "k" gnus-summary-kill-same-subject-and-select
833 "\C-k" gnus-summary-kill-same-subject
834 "\M-\C-k" gnus-summary-kill-thread
835 "\M-\C-l" gnus-summary-lower-thread
836 "e" gnus-summary-edit-article
837 "#" gnus-summary-mark-as-processable
838 "\M-#" gnus-summary-unmark-as-processable
839 "\M-\C-t" gnus-summary-toggle-threads
840 "\M-\C-s" gnus-summary-show-thread
841 "\M-\C-h" gnus-summary-hide-thread
842 "\M-\C-f" gnus-summary-next-thread
843 "\M-\C-b" gnus-summary-prev-thread
844 "\M-\C-u" gnus-summary-up-thread
845 "\M-\C-d" gnus-summary-down-thread
846 "&" gnus-summary-execute-command
847 "c" gnus-summary-catchup-and-exit
848 "\C-w" gnus-summary-mark-region-as-read
849 "\C-t" gnus-summary-toggle-truncation
850 "?" gnus-summary-mark-as-dormant
851 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
852 "\C-c\C-s\C-n" gnus-summary-sort-by-number
853 "\C-c\C-s\C-a" gnus-summary-sort-by-author
854 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
855 "\C-c\C-s\C-d" gnus-summary-sort-by-date
856 "\C-c\C-s\C-i" gnus-summary-sort-by-score
857 "=" gnus-summary-expand-window
858 "\C-x\C-s" gnus-summary-reselect-current-group
859 "\M-g" gnus-summary-rescan-group
860 "w" gnus-summary-stop-page-breaking
861 "\C-c\C-r" gnus-summary-caesar-message
862 "\M-t" gnus-summary-toggle-mime
863 "f" gnus-summary-followup
864 "F" gnus-summary-followup-with-original
865 "C" gnus-summary-cancel-article
866 "r" gnus-summary-reply
867 "R" gnus-summary-reply-with-original
868 "\C-c\C-f" gnus-summary-mail-forward
869 "o" gnus-summary-save-article
870 "\C-o" gnus-summary-save-article-mail
871 "|" gnus-summary-pipe-output
872 "\M-k" gnus-summary-edit-local-kill
873 "\M-K" gnus-summary-edit-global-kill
875 "\C-c\C-d" gnus-summary-describe-group
876 "q" gnus-summary-exit
877 "Q" gnus-summary-exit-no-update
878 "\C-c\C-i" gnus-info-find-node
879 gnus-mouse-2 gnus-mouse-pick-article
880 "m" gnus-summary-mail-other-window
881 "a" gnus-summary-post-news
882 "x" gnus-summary-limit-to-unread
883 "s" gnus-summary-isearch-article
884 "t" gnus-article-hide-headers
885 "g" gnus-summary-show-article
886 "l" gnus-summary-goto-last-article
887 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
888 "\C-d" gnus-summary-enter-digest-group
889 "\M-\C-d" gnus-summary-read-document
891 "*" gnus-cache-enter-article
892 "\M-*" gnus-cache-remove-article
893 "\M-&" gnus-summary-universal-argument
895 "I" gnus-summary-increase-score
896 "L" gnus-summary-lower-score
898 "V" gnus-summary-score-map
899 "X" gnus-uu-extract-map
900 "S" gnus-summary-send-map)
902 ;; Sort of orthogonal keymap
903 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
904 "t" gnus-summary-tick-article-forward
905 "!" gnus-summary-tick-article-forward
906 "d" gnus-summary-mark-as-read-forward
907 "r" gnus-summary-mark-as-read-forward
908 "c" gnus-summary-clear-mark-forward
909 " " gnus-summary-clear-mark-forward
910 "e" gnus-summary-mark-as-expirable
911 "x" gnus-summary-mark-as-expirable
912 "?" gnus-summary-mark-as-dormant
913 "b" gnus-summary-set-bookmark
914 "B" gnus-summary-remove-bookmark
915 "#" gnus-summary-mark-as-processable
916 "\M-#" gnus-summary-unmark-as-processable
917 "S" gnus-summary-limit-include-expunged
918 "C" gnus-summary-catchup
919 "H" gnus-summary-catchup-to-here
920 "\C-c" gnus-summary-catchup-all
921 "k" gnus-summary-kill-same-subject-and-select
922 "K" gnus-summary-kill-same-subject
923 "P" gnus-uu-mark-map)
925 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
926 "c" gnus-summary-clear-above
927 "u" gnus-summary-tick-above
928 "m" gnus-summary-mark-above
929 "k" gnus-summary-kill-below)
931 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
932 "/" gnus-summary-limit-to-subject
933 "n" gnus-summary-limit-to-articles
934 "w" gnus-summary-pop-limit
935 "s" gnus-summary-limit-to-subject
936 "a" gnus-summary-limit-to-author
937 "u" gnus-summary-limit-to-unread
938 "m" gnus-summary-limit-to-marks
939 "v" gnus-summary-limit-to-score
940 "D" gnus-summary-limit-include-dormant
941 "d" gnus-summary-limit-exclude-dormant
942 ;; "t" gnus-summary-limit-exclude-thread
943 "E" gnus-summary-limit-include-expunged
944 "c" gnus-summary-limit-exclude-childless-dormant
945 "C" gnus-summary-limit-mark-excluded-as-read)
947 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
948 "n" gnus-summary-next-unread-article
949 "p" gnus-summary-prev-unread-article
950 "N" gnus-summary-next-article
951 "P" gnus-summary-prev-article
952 "\C-n" gnus-summary-next-same-subject
953 "\C-p" gnus-summary-prev-same-subject
954 "\M-n" gnus-summary-next-unread-subject
955 "\M-p" gnus-summary-prev-unread-subject
956 "f" gnus-summary-first-unread-article
957 "b" gnus-summary-best-unread-article
958 "j" gnus-summary-goto-article
959 "g" gnus-summary-goto-subject
960 "l" gnus-summary-goto-last-article
961 "p" gnus-summary-pop-article)
963 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
964 "k" gnus-summary-kill-thread
965 "l" gnus-summary-lower-thread
966 "i" gnus-summary-raise-thread
967 "T" gnus-summary-toggle-threads
968 "t" gnus-summary-rethread-current
969 "^" gnus-summary-reparent-thread
970 "s" gnus-summary-show-thread
971 "S" gnus-summary-show-all-threads
972 "h" gnus-summary-hide-thread
973 "H" gnus-summary-hide-all-threads
974 "n" gnus-summary-next-thread
975 "p" gnus-summary-prev-thread
976 "u" gnus-summary-up-thread
977 "o" gnus-summary-top-thread
978 "d" gnus-summary-down-thread
979 "#" gnus-uu-mark-thread
980 "\M-#" gnus-uu-unmark-thread)
982 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
983 "c" gnus-summary-catchup-and-exit
984 "C" gnus-summary-catchup-all-and-exit
985 "E" gnus-summary-exit-no-update
986 "Q" gnus-summary-exit
987 "Z" gnus-summary-exit
988 "n" gnus-summary-catchup-and-goto-next-group
989 "R" gnus-summary-reselect-current-group
990 "G" gnus-summary-rescan-group
991 "N" gnus-summary-next-group
992 "P" gnus-summary-prev-group)
994 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
995 " " gnus-summary-next-page
996 "n" gnus-summary-next-page
997 "\177" gnus-summary-prev-page
998 [delete] gnus-summary-prev-page
999 "p" gnus-summary-prev-page
1000 "\r" gnus-summary-scroll-up
1001 "<" gnus-summary-beginning-of-article
1002 ">" gnus-summary-end-of-article
1003 "b" gnus-summary-beginning-of-article
1004 "e" gnus-summary-end-of-article
1005 "^" gnus-summary-refer-parent-article
1006 "r" gnus-summary-refer-parent-article
1007 "R" gnus-summary-refer-references
1008 "g" gnus-summary-show-article
1009 "s" gnus-summary-isearch-article)
1011 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1012 "b" gnus-article-add-buttons
1013 "B" gnus-article-add-buttons-to-head
1014 "o" gnus-article-treat-overstrike
1015 "e" gnus-article-emphasize
1016 "w" gnus-article-fill-cited-article
1017 "c" gnus-article-remove-cr
1018 "L" gnus-article-remove-trailing-blank-lines
1019 "q" gnus-article-de-quoted-unreadable
1020 "f" gnus-article-display-x-face
1021 "l" gnus-summary-stop-page-breaking
1022 "r" gnus-summary-caesar-message
1023 "t" gnus-article-hide-headers
1024 "v" gnus-summary-verbose-headers
1025 "m" gnus-summary-toggle-mime)
1027 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1028 "a" gnus-article-hide
1029 "h" gnus-article-hide-headers
1030 "b" gnus-article-hide-boring-headers
1031 "s" gnus-article-hide-signature
1032 "c" gnus-article-hide-citation
1033 "p" gnus-article-hide-pgp
1034 "P" gnus-article-hide-pem
1035 "\C-c" gnus-article-hide-citation-maybe)
1037 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1038 "a" gnus-article-highlight
1039 "h" gnus-article-highlight-headers
1040 "c" gnus-article-highlight-citation
1041 "s" gnus-article-highlight-signature)
1043 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1044 "z" gnus-article-date-ut
1045 "u" gnus-article-date-ut
1046 "l" gnus-article-date-local
1047 "e" gnus-article-date-lapsed
1048 "o" gnus-article-date-original)
1050 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1052 "f" gnus-summary-fetch-faq
1053 "d" gnus-summary-describe-group
1054 "h" gnus-summary-describe-briefly
1055 "i" gnus-info-find-node)
1057 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1058 "e" gnus-summary-expire-articles
1059 "\M-\C-e" gnus-summary-expire-articles-now
1060 "\177" gnus-summary-delete-article
1061 [delete] gnus-summary-delete-article
1062 "m" gnus-summary-move-article
1063 "r" gnus-summary-respool-article
1064 "w" gnus-summary-edit-article
1065 "c" gnus-summary-copy-article
1066 "B" gnus-summary-crosspost-article
1067 "q" gnus-summary-respool-query
1068 "i" gnus-summary-import-article)
1070 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1071 "o" gnus-summary-save-article
1072 "m" gnus-summary-save-article-mail
1073 "r" gnus-summary-save-article-rmail
1074 "f" gnus-summary-save-article-file
1075 "b" gnus-summary-save-article-body-file
1076 "h" gnus-summary-save-article-folder
1077 "v" gnus-summary-save-article-vm
1078 "p" gnus-summary-pipe-output
1079 "s" gnus-soup-add-article)
1082 (defun gnus-summary-make-menu-bar ()
1083 (gnus-turn-off-edit-menu 'summary)
1085 (unless (boundp 'gnus-summary-misc-menu)
1088 gnus-summary-kill-menu gnus-summary-mode-map ""
1093 ["Enter score..." gnus-summary-score-entry t])
1094 (gnus-make-score-map 'increase)
1095 (gnus-make-score-map 'lower)
1097 ["Kill below" gnus-summary-kill-below t]
1098 ["Mark above" gnus-summary-mark-above t]
1099 ["Tick above" gnus-summary-tick-above t]
1100 ["Clear above" gnus-summary-clear-above t])
1101 ["Current score" gnus-summary-current-score t]
1102 ["Set score" gnus-summary-set-score t]
1103 ["Customize score file" gnus-score-customize t]
1104 ["Switch current score file..." gnus-score-change-score-file t]
1105 ["Set mark below..." gnus-score-set-mark-below t]
1106 ["Set expunge below..." gnus-score-set-expunge-below t]
1107 ["Edit current score file" gnus-score-edit-current-scores t]
1108 ["Edit score file" gnus-score-edit-file t]
1109 ["Trace score" gnus-score-find-trace t]
1110 ["Find words" gnus-score-find-favuorite-words t]
1111 ["Rescore buffer" gnus-summary-rescore t]
1112 ["Increase score..." gnus-summary-increase-score t]
1113 ["Lower score..." gnus-summary-lower-score t]))))
1116 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1118 :selected (null gnus-score-default-header)]
1119 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1121 :selected (eq gnus-score-default-header 'a)]
1122 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1124 :selected (eq gnus-score-default-header 's)]
1126 (gnus-score-set-default 'gnus-score-default-header 'b)
1128 :selected (eq gnus-score-default-header 'b )]
1130 (gnus-score-set-default 'gnus-score-default-header 'h)
1132 :selected (eq gnus-score-default-header 'h )]
1133 ["Message-Id" (gnus-score-set-default 'gnus-score-default-header 'i)
1135 :selected (eq gnus-score-default-header 'i )]
1136 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1138 :selected (eq gnus-score-default-header 't )]
1140 (gnus-score-set-default 'gnus-score-default-header 'x)
1142 :selected (eq gnus-score-default-header 'x )]
1143 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1145 :selected (eq gnus-score-default-header 'l )]
1146 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1148 :selected (eq gnus-score-default-header 'd )]
1149 ["Followups to author"
1150 (gnus-score-set-default 'gnus-score-default-header 'f)
1152 :selected (eq gnus-score-default-header 'f )])
1154 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1156 :selected (null gnus-score-default-type)]
1157 ;; The `:active' key is commented out in the following,
1158 ;; because the GNU Emacs hack to support radio buttons use
1159 ;; active to indicate which button is selected.
1160 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1162 ;; :active (not (memq gnus-score-default-header '(l d)))
1163 :selected (eq gnus-score-default-type 's)]
1164 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1166 ;; :active (not (memq gnus-score-default-header '(l d)))
1167 :selected (eq gnus-score-default-type 'r)]
1168 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1170 ;; :active (not (memq gnus-score-default-header '(l d)))
1171 :selected (eq gnus-score-default-type 'e)]
1172 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1174 ;; :active (not (memq gnus-score-default-header '(l d)))
1175 :selected (eq gnus-score-default-type 'f)]
1176 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1178 ;; :active (eq (gnus-score-default-header 'd))
1179 :selected (eq gnus-score-default-type 'b)]
1180 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1182 ;; :active (eq (gnus-score-default-header 'd))
1183 :selected (eq gnus-score-default-type 'n)]
1184 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1186 ;; :active (eq (gnus-score-default-header 'd))
1187 :selected (eq gnus-score-default-type 'a)]
1189 (gnus-score-set-default 'gnus-score-default-type '<)
1191 ;; :active (eq (gnus-score-default-header 'l))
1192 :selected (eq gnus-score-default-type '<)]
1194 (gnus-score-set-default 'gnus-score-default-type '=)
1196 ;; :active (eq (gnus-score-default-header 'l))
1197 :selected (eq gnus-score-default-type '=)]
1198 ["Greater than number"
1199 (gnus-score-set-default 'gnus-score-default-type '>)
1201 ;; :active (eq (gnus-score-default-header 'l))
1202 :selected (eq gnus-score-default-type '>)])
1203 ["Default fold" gnus-score-default-fold-toggle
1205 :selected gnus-score-default-fold]
1207 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1209 :selected (null gnus-score-default-duration)]
1211 (gnus-score-set-default 'gnus-score-default-duration 'p)
1213 :selected (eq gnus-score-default-duration 'p)]
1215 (gnus-score-set-default 'gnus-score-default-duration 't)
1217 :selected (eq gnus-score-default-duration 't)]
1219 (gnus-score-set-default 'gnus-score-default-duration 'i)
1221 :selected (eq gnus-score-default-duration 'i)]))
1224 gnus-summary-article-menu gnus-summary-mode-map ""
1227 ["All" gnus-article-hide t]
1228 ["Headers" gnus-article-hide-headers t]
1229 ["Signature" gnus-article-hide-signature t]
1230 ["Citation" gnus-article-hide-citation t]
1231 ["PGP" gnus-article-hide-pgp t]
1232 ["Boring headers" gnus-article-hide-boring-headers t])
1234 ["All" gnus-article-highlight t]
1235 ["Headers" gnus-article-highlight-headers t]
1236 ["Signature" gnus-article-highlight-signature t]
1237 ["Citation" gnus-article-highlight-citation t])
1239 ["Local" gnus-article-date-local t]
1240 ["UT" gnus-article-date-ut t]
1241 ["Original" gnus-article-date-original t]
1242 ["Lapsed" gnus-article-date-lapsed t])
1244 ["Overstrike" gnus-article-treat-overstrike t]
1245 ["Emphasis" gnus-article-emphasize t]
1246 ["Word wrap" gnus-article-fill-cited-article t]
1247 ["CR" gnus-article-remove-cr t]
1248 ["Trailing blank lines" gnus-article-remove-trailing-blank-lines t]
1249 ["Show X-Face" gnus-article-display-x-face t]
1250 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1251 ["Rot 13" gnus-summary-caesar-message t]
1252 ["Add buttons" gnus-article-add-buttons t]
1253 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1254 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1255 ["Toggle MIME" gnus-summary-toggle-mime t]
1256 ["Verbose header" gnus-summary-verbose-headers t]
1257 ["Toggle header" gnus-summary-toggle-header t])
1259 ["Save in default format" gnus-summary-save-article t]
1260 ["Save in file" gnus-summary-save-article-file t]
1261 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1262 ["Save in MH folder" gnus-summary-save-article-folder t]
1263 ["Save in VM folder" gnus-summary-save-article-vm t]
1264 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1265 ["Save body in file" gnus-summary-save-article-body-file t]
1266 ["Pipe through a filter" gnus-summary-pipe-output t]
1267 ["Add to SOUP packet" gnus-soup-add-article t])
1269 ["Respool article..." gnus-summary-respool-article t]
1270 ["Move article..." gnus-summary-move-article
1271 (gnus-check-backend-function
1272 'request-move-article gnus-newsgroup-name)]
1273 ["Copy article..." gnus-summary-copy-article t]
1274 ["Crosspost article..." gnus-summary-crosspost-article
1275 (gnus-check-backend-function
1276 'request-replace-article gnus-newsgroup-name)]
1277 ["Import file..." gnus-summary-import-article t]
1278 ["Edit article" gnus-summary-edit-article
1279 (not (gnus-group-read-only-p))]
1280 ["Delete article" gnus-summary-delete-article
1281 (gnus-check-backend-function
1282 'request-expire-articles gnus-newsgroup-name)]
1283 ["Query respool" gnus-summary-respool-query t]
1284 ["Delete expirable articles" gnus-summary-expire-articles-now
1285 (gnus-check-backend-function
1286 'request-expire-articles gnus-newsgroup-name)])
1288 ["Uudecode" gnus-uu-decode-uu t]
1289 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1290 ["Unshar" gnus-uu-decode-unshar t]
1291 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1292 ["Save" gnus-uu-decode-save t]
1293 ["Binhex" gnus-uu-decode-binhex t]
1294 ["Postscript" gnus-uu-decode-postscript t])
1295 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1296 ["Isearch article..." gnus-summary-isearch-article t]
1297 ["Search articles forward..." gnus-summary-search-article-forward t]
1298 ["Search articles backward..." gnus-summary-search-article-backward t]
1299 ["Beginning of the article" gnus-summary-beginning-of-article t]
1300 ["End of the article" gnus-summary-end-of-article t]
1301 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1302 ["Fetch referenced articles" gnus-summary-refer-references t]
1303 ["Fetch article with id..." gnus-summary-refer-article t]
1304 ["Redisplay" gnus-summary-show-article t]))
1307 gnus-summary-thread-menu gnus-summary-mode-map ""
1309 ["Toggle threading" gnus-summary-toggle-threads t]
1310 ["Hide threads" gnus-summary-hide-all-threads t]
1311 ["Show threads" gnus-summary-show-all-threads t]
1312 ["Hide thread" gnus-summary-hide-thread t]
1313 ["Show thread" gnus-summary-show-thread t]
1314 ["Go to next thread" gnus-summary-next-thread t]
1315 ["Go to previous thread" gnus-summary-prev-thread t]
1316 ["Go down thread" gnus-summary-down-thread t]
1317 ["Go up thread" gnus-summary-up-thread t]
1318 ["Top of thread" gnus-summary-top-thread t]
1319 ["Mark thread as read" gnus-summary-kill-thread t]
1320 ["Lower thread score" gnus-summary-lower-thread t]
1321 ["Raise thread score" gnus-summary-raise-thread t]
1322 ["Rethread current" gnus-summary-rethread-current t]
1326 gnus-summary-post-menu gnus-summary-mode-map ""
1328 ["Post an article" gnus-summary-post-news t]
1329 ["Followup" gnus-summary-followup t]
1330 ["Followup and yank" gnus-summary-followup-with-original t]
1331 ["Supersede article" gnus-summary-supersede-article t]
1332 ["Cancel article" gnus-summary-cancel-article t]
1333 ["Reply" gnus-summary-reply t]
1334 ["Reply and yank" gnus-summary-reply-with-original t]
1335 ["Mail forward" gnus-summary-mail-forward t]
1336 ["Post forward" gnus-summary-post-forward t]
1337 ["Digest and mail" gnus-uu-digest-mail-forward t]
1338 ["Digest and post" gnus-uu-digest-post-forward t]
1339 ["Resend message" gnus-summary-resend-message t]
1340 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1341 ["Send a mail" gnus-summary-mail-other-window t]
1342 ["Uuencode and post" gnus-uu-post-news t]
1344 ;;["Send" gnus-summary-send-draft t]
1345 ;;["Send bounced" gnus-resend-bounced-mail t])
1349 gnus-summary-misc-menu gnus-summary-mode-map ""
1353 ["Mark as read" gnus-summary-mark-as-read-forward t]
1354 ["Mark same subject and select"
1355 gnus-summary-kill-same-subject-and-select t]
1356 ["Mark same subject" gnus-summary-kill-same-subject t]
1357 ["Catchup" gnus-summary-catchup t]
1358 ["Catchup all" gnus-summary-catchup-all t]
1359 ["Catchup to here" gnus-summary-catchup-to-here t]
1360 ["Catchup region" gnus-summary-mark-region-as-read t]
1361 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1363 ["Tick" gnus-summary-tick-article-forward t]
1364 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1365 ["Remove marks" gnus-summary-clear-mark-forward t]
1366 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1367 ["Set bookmark" gnus-summary-set-bookmark t]
1368 ["Remove bookmark" gnus-summary-remove-bookmark t])
1370 ["Marks..." gnus-summary-limit-to-marks t]
1371 ["Subject..." gnus-summary-limit-to-subject t]
1372 ["Author..." gnus-summary-limit-to-author t]
1373 ["Score" gnus-summary-limit-to-score t]
1374 ["Unread" gnus-summary-limit-to-unread t]
1375 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1376 ["Articles" gnus-summary-limit-to-articles t]
1377 ["Pop limit" gnus-summary-pop-limit t]
1378 ["Show dormant" gnus-summary-limit-include-dormant t]
1379 ["Hide childless dormant"
1380 gnus-summary-limit-exclude-childless-dormant t]
1381 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1382 ["Show expunged" gnus-summary-show-all-expunged t])
1384 ["Set mark" gnus-summary-mark-as-processable t]
1385 ["Remove mark" gnus-summary-unmark-as-processable t]
1386 ["Remove all marks" gnus-summary-unmark-all-processable t]
1387 ["Mark above" gnus-uu-mark-over t]
1388 ["Mark series" gnus-uu-mark-series t]
1389 ["Mark region" gnus-uu-mark-region t]
1390 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1391 ["Mark all" gnus-uu-mark-all t]
1392 ["Mark buffer" gnus-uu-mark-buffer t]
1393 ["Mark sparse" gnus-uu-mark-sparse t]
1394 ["Mark thread" gnus-uu-mark-thread t]
1395 ["Unmark thread" gnus-uu-unmark-thread t]
1396 ("Process Mark Sets"
1397 ["Kill" gnus-summary-kill-process-mark t]
1398 ["Yank" gnus-summary-yank-process-mark
1399 gnus-newsgroup-process-stack]
1400 ["Save" gnus-summary-save-process-mark t])))
1402 ["Page forward" gnus-summary-next-page t]
1403 ["Page backward" gnus-summary-prev-page t]
1404 ["Line forward" gnus-summary-scroll-up t])
1406 ["Next unread article" gnus-summary-next-unread-article t]
1407 ["Previous unread article" gnus-summary-prev-unread-article t]
1408 ["Next article" gnus-summary-next-article t]
1409 ["Previous article" gnus-summary-prev-article t]
1410 ["Next unread subject" gnus-summary-next-unread-subject t]
1411 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1412 ["Next article same subject" gnus-summary-next-same-subject t]
1413 ["Previous article same subject" gnus-summary-prev-same-subject t]
1414 ["First unread article" gnus-summary-first-unread-article t]
1415 ["Best unread article" gnus-summary-best-unread-article t]
1416 ["Go to subject number..." gnus-summary-goto-subject t]
1417 ["Go to article number..." gnus-summary-goto-article t]
1418 ["Go to the last article" gnus-summary-goto-last-article t]
1419 ["Pop article off history" gnus-summary-pop-article t])
1421 ["Sort by number" gnus-summary-sort-by-number t]
1422 ["Sort by author" gnus-summary-sort-by-author t]
1423 ["Sort by subject" gnus-summary-sort-by-subject t]
1424 ["Sort by date" gnus-summary-sort-by-date t]
1425 ["Sort by score" gnus-summary-sort-by-score t])
1427 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1428 ["Describe group" gnus-summary-describe-group t]
1429 ["Read manual" gnus-info-find-node t])
1431 ["Enter article" gnus-cache-enter-article t]
1432 ["Remove article" gnus-cache-remove-article t])
1434 ["Pick and read" gnus-pick-mode t]
1435 ["Binary" gnus-binary-mode t])
1436 ["Filter articles..." gnus-summary-execute-command t]
1437 ["Run command on subjects..." gnus-summary-universal-argument t]
1438 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1439 ["Expand window" gnus-summary-expand-window t]
1440 ["Expire expirable articles" gnus-summary-expire-articles
1441 (gnus-check-backend-function
1442 'request-expire-articles gnus-newsgroup-name)]
1443 ["Edit local kill file" gnus-summary-edit-local-kill t]
1444 ["Edit main kill file" gnus-summary-edit-global-kill t]
1446 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1447 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1448 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1449 ["Exit group" gnus-summary-exit t]
1450 ["Exit group without updating" gnus-summary-exit-no-update t]
1451 ["Exit and goto next group" gnus-summary-next-group t]
1452 ["Exit and goto prev group" gnus-summary-prev-group t]
1453 ["Reselect group" gnus-summary-reselect-current-group t]
1454 ["Rescan group" gnus-summary-rescan-group t])))
1456 (run-hooks 'gnus-summary-menu-hook)))
1458 (defun gnus-score-set-default (var value)
1459 "A version of set that updates the GNU Emacs menu-bar."
1461 ;; It is the message that forces the active status to be updated.
1464 (defun gnus-make-score-map (type)
1465 "Make a summary score map of type TYPE."
1468 (let ((headers '(("author" "from" string)
1469 ("subject" "subject" string)
1470 ("article body" "body" string)
1471 ("article head" "head" string)
1472 ("xref" "xref" string)
1473 ("lines" "lines" number)
1474 ("followups to author" "followup" string)))
1475 (types '((number ("less than" <)
1478 (string ("substring" s)
1482 (perms '(("temporary" (current-time-string))
1490 (if (eq type 'lower)
1495 (setq header (car headers))
1501 (let ((ts (cdr (assoc (nth 2 header) types)))
1517 'gnus-summary-score-entry
1519 (if (or (string= (nth 1 header)
1521 (string= (nth 1 header)
1524 (list 'gnus-summary-header
1526 (list 'quote (nth 1 (car ts)))
1527 (list 'gnus-score-default nil)
1533 (list (nreverse outp))))
1536 (list (nreverse outt))))
1538 (setq headers (cdr headers)))
1539 (list (nreverse outh))))))))
1543 (defun gnus-summary-mode (&optional group)
1544 "Major mode for reading articles.
1546 All normal editing commands are switched off.
1547 \\<gnus-summary-mode-map>
1548 Each line in this buffer represents one article. To read an
1549 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1550 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1553 You can also post articles and send mail from this buffer. To
1554 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1555 of an article, type `\\[gnus-summary-reply]'.
1557 There are approx. one gazillion commands you can execute in this
1558 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1560 The following commands are available:
1562 \\{gnus-summary-mode-map}"
1564 (when (and menu-bar-mode
1565 (gnus-visual-p 'summary-menu 'menu))
1566 (gnus-summary-make-menu-bar))
1567 (kill-all-local-variables)
1568 (gnus-summary-make-local-variables)
1569 (gnus-make-thread-indent-array)
1570 (gnus-simplify-mode-line)
1571 (setq major-mode 'gnus-summary-mode)
1572 (setq mode-name "Summary")
1573 (make-local-variable 'minor-mode-alist)
1574 (use-local-map gnus-summary-mode-map)
1575 (buffer-disable-undo (current-buffer))
1576 (setq buffer-read-only t) ;Disable modification
1577 (setq truncate-lines t)
1578 (setq selective-display t)
1579 (setq selective-display-ellipses t) ;Display `...'
1580 (setq buffer-display-table gnus-summary-display-table)
1581 (gnus-set-default-directory)
1582 (setq gnus-newsgroup-name group)
1583 (make-local-variable 'gnus-summary-line-format)
1584 (make-local-variable 'gnus-summary-line-format-spec)
1585 (make-local-variable 'gnus-summary-mark-positions)
1586 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1587 (gnus-update-summary-mark-positions)
1588 (gnus-make-local-hook 'post-command-hook)
1589 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1590 (run-hooks 'gnus-summary-mode-hook))
1592 (defun gnus-summary-make-local-variables ()
1593 "Make all the local summary buffer variables."
1594 (let ((locals gnus-summary-local-variables)
1596 (while (setq local (pop locals))
1599 (if (eq (cdr local) 'global)
1600 ;; Copy the global value of the variable.
1601 (setq global (symbol-value (car local)))
1602 ;; Use the value from the list.
1603 (setq global (eval (cdr local))))
1604 (make-local-variable (car local))
1605 (set (car local) global))
1606 ;; Simple nil-valued local variable.
1607 (make-local-variable local)
1610 (defun gnus-summary-clear-local-variables ()
1611 (let ((locals gnus-summary-local-variables))
1613 (if (consp (car locals))
1614 (and (vectorp (caar locals))
1615 (set (caar locals) nil))
1616 (and (vectorp (car locals))
1617 (set (car locals) nil)))
1618 (setq locals (cdr locals)))))
1620 ;; Summary data functions.
1622 (defmacro gnus-data-number (data)
1625 (defmacro gnus-data-set-number (data number)
1626 `(setcar ,data ,number))
1628 (defmacro gnus-data-mark (data)
1631 (defmacro gnus-data-set-mark (data mark)
1632 `(setcar (nthcdr 1 ,data) ,mark))
1634 (defmacro gnus-data-pos (data)
1637 (defmacro gnus-data-set-pos (data pos)
1638 `(setcar (nthcdr 2 ,data) ,pos))
1640 (defmacro gnus-data-header (data)
1643 (defmacro gnus-data-level (data)
1646 (defmacro gnus-data-unread-p (data)
1647 `(= (nth 1 ,data) gnus-unread-mark))
1649 (defmacro gnus-data-read-p (data)
1650 `(/= (nth 1 ,data) gnus-unread-mark))
1652 (defmacro gnus-data-pseudo-p (data)
1653 `(consp (nth 3 ,data)))
1655 (defmacro gnus-data-find (number)
1656 `(assq ,number gnus-newsgroup-data))
1658 (defmacro gnus-data-find-list (number &optional data)
1659 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1660 (memq (assq ,number bdata)
1663 (defmacro gnus-data-make (number mark pos header level)
1664 `(list ,number ,mark ,pos ,header ,level))
1666 (defun gnus-data-enter (after-article number mark pos header level offset)
1667 (let ((data (gnus-data-find-list after-article)))
1668 (or data (error "No such article: %d" after-article))
1669 (setcdr data (cons (gnus-data-make number mark pos header level)
1671 (setq gnus-newsgroup-data-reverse nil)
1672 (gnus-data-update-list (cddr data) offset)))
1674 (defun gnus-data-enter-list (after-article list &optional offset)
1676 (let ((data (and after-article (gnus-data-find-list after-article)))
1678 (or data (not after-article) (error "No such article: %d" after-article))
1679 ;; Find the last element in the list to be spliced into the main
1682 (setq list (cdr list)))
1685 (setcdr list gnus-newsgroup-data)
1686 (setq gnus-newsgroup-data ilist)
1687 (and offset (gnus-data-update-list (cdr list) offset)))
1688 (setcdr list (cdr data))
1690 (and offset (gnus-data-update-list (cdr data) offset)))
1691 (setq gnus-newsgroup-data-reverse nil))))
1693 (defun gnus-data-remove (article &optional offset)
1694 (let ((data gnus-newsgroup-data))
1695 (if (= (gnus-data-number (car data)) article)
1696 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
1697 gnus-newsgroup-data-reverse nil)
1699 (and (= (gnus-data-number (cadr data)) article)
1701 (setcdr data (cddr data))
1702 (and offset (gnus-data-update-list (cdr data) offset))
1704 gnus-newsgroup-data-reverse nil)))
1705 (setq data (cdr data))))))
1707 (defmacro gnus-data-list (backward)
1709 (or gnus-newsgroup-data-reverse
1710 (setq gnus-newsgroup-data-reverse
1711 (reverse gnus-newsgroup-data)))
1712 gnus-newsgroup-data))
1714 (defun gnus-data-update-list (data offset)
1715 "Add OFFSET to the POS of all data entries in DATA."
1717 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
1718 (setq data (cdr data))))
1720 (defun gnus-data-compute-positions ()
1721 "Compute the positions of all articles."
1722 (let ((data gnus-newsgroup-data)
1725 (when (setq pos (text-property-any
1726 (point-min) (point-max)
1727 'gnus-number (gnus-data-number (car data))))
1728 (gnus-data-set-pos (car data) (+ pos 3)))
1729 (setq data (cdr data)))))
1731 (defun gnus-summary-article-pseudo-p (article)
1732 "Say whether this article is a pseudo article or not."
1733 (not (vectorp (gnus-data-header (gnus-data-find article)))))
1735 (defun gnus-article-parent-p (number)
1736 "Say whether this article is a parent or not."
1737 (let ((data (gnus-data-find-list number)))
1738 (and (cdr data) ; There has to be an article after...
1739 (< (gnus-data-level (car data)) ; And it has to have a higher level.
1740 (gnus-data-level (nth 1 data))))))
1742 (defun gnus-article-children (number)
1743 "Return a list of all children to NUMBER."
1744 (let* ((data (gnus-data-find-list number))
1745 (level (gnus-data-level (car data)))
1747 (setq data (cdr data))
1749 (= (gnus-data-level (car data)) (1+ level)))
1750 (push (gnus-data-number (car data)) children)
1751 (setq data (cdr data)))
1754 (defmacro gnus-summary-skip-intangible ()
1755 "If the current article is intangible, then jump to a different article."
1756 '(let ((to (get-text-property (point) 'gnus-intangible)))
1757 (and to (gnus-summary-goto-subject to))))
1759 (defmacro gnus-summary-article-intangible-p ()
1760 "Say whether this article is intangible or not."
1761 '(get-text-property (point) 'gnus-intangible))
1763 ;; Some summary mode macros.
1765 (defmacro gnus-summary-article-number ()
1766 "The article number of the article on the current line.
1767 If there isn's an article number here, then we return the current
1770 (gnus-summary-skip-intangible)
1771 (or (get-text-property (point) 'gnus-number)
1772 (gnus-summary-last-subject))))
1774 (defmacro gnus-summary-article-header (&optional number)
1775 `(gnus-data-header (gnus-data-find
1776 ,(or number '(gnus-summary-article-number)))))
1778 (defmacro gnus-summary-thread-level (&optional number)
1779 `(if (and (eq gnus-summary-make-false-root 'dummy)
1780 (get-text-property (point) 'gnus-intangible))
1782 (gnus-data-level (gnus-data-find
1783 ,(or number '(gnus-summary-article-number))))))
1785 (defmacro gnus-summary-article-mark (&optional number)
1786 `(gnus-data-mark (gnus-data-find
1787 ,(or number '(gnus-summary-article-number)))))
1789 (defmacro gnus-summary-article-pos (&optional number)
1790 `(gnus-data-pos (gnus-data-find
1791 ,(or number '(gnus-summary-article-number)))))
1793 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
1794 (defmacro gnus-summary-article-subject (&optional number)
1795 "Return current subject string or nil if nothing."
1798 `(gnus-data-header (assq ,number gnus-newsgroup-data))
1799 '(gnus-data-header (assq (gnus-summary-article-number)
1800 gnus-newsgroup-data)))))
1803 (mail-header-subject headers))))
1805 (defmacro gnus-summary-article-score (&optional number)
1806 "Return current article score."
1807 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
1808 gnus-newsgroup-scored))
1809 gnus-summary-default-score 0))
1811 (defun gnus-summary-article-children (&optional number)
1812 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
1813 (level (gnus-data-level (car data)))
1815 (while (and (setq data (cdr data))
1816 (> (setq l (gnus-data-level (car data))) level))
1817 (and (= (1+ level) l)
1818 (setq children (cons (gnus-data-number (car data))
1820 (nreverse children)))
1822 (defun gnus-summary-article-parent (&optional number)
1823 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
1824 (gnus-data-list t)))
1825 (level (gnus-data-level (car data))))
1827 () ; This is a root.
1828 ;; We search until we find an article with a level less than
1829 ;; this one. That function has to be the parent.
1830 (while (and (setq data (cdr data))
1831 (not (< (gnus-data-level (car data)) level))))
1832 (and data (gnus-data-number (car data))))))
1834 (defun gnus-unread-mark-p (mark)
1835 "Say whether MARK is the unread mark."
1836 (= mark gnus-unread-mark))
1838 (defun gnus-read-mark-p (mark)
1839 "Say whether MARK is one of the marks that mark as read.
1840 This is all marks except unread, ticked, dormant, and expirable."
1841 (not (or (= mark gnus-unread-mark)
1842 (= mark gnus-ticked-mark)
1843 (= mark gnus-dormant-mark)
1844 (= mark gnus-expirable-mark))))
1846 (defmacro gnus-article-mark (number)
1848 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
1849 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
1850 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
1851 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
1852 (t (or (cdr (assq ,number gnus-newsgroup-reads))
1853 gnus-ancient-mark))))
1855 ;; Saving hidden threads.
1857 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
1858 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
1859 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
1861 (defmacro gnus-save-hidden-threads (&rest forms)
1862 "Save hidden threads, eval FORMS, and restore the hidden threads."
1863 (let ((config (make-symbol "config")))
1864 `(let ((,config (gnus-hidden-threads-configuration)))
1868 (gnus-restore-hidden-threads-configuration ,config)))))
1870 (defun gnus-hidden-threads-configuration ()
1871 "Return the current hidden threads configuration."
1874 (goto-char (point-min))
1875 (while (search-forward "\r" nil t)
1876 (push (1- (point)) config))
1879 (defun gnus-restore-hidden-threads-configuration (config)
1880 "Restore hidden threads configuration from CONFIG."
1881 (let (point buffer-read-only)
1882 (while (setq point (pop config))
1883 (when (and (< point (point-max))
1885 (= (following-char) ?\n))
1886 (subst-char-in-region point (1+ point) ?\n ?\r)))))
1888 ;; Various summary mode internalish functions.
1890 (defun gnus-mouse-pick-article (e)
1893 (gnus-summary-next-page nil t))
1895 (defun gnus-summary-setup-buffer (group)
1896 "Initialize summary buffer."
1897 (let ((buffer (concat "*Summary " group "*")))
1898 (if (get-buffer buffer)
1901 (setq gnus-summary-buffer (current-buffer))
1902 (not gnus-newsgroup-prepared))
1903 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
1904 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
1905 (gnus-add-current-to-buffer-list)
1906 (gnus-summary-mode group)
1908 (gnus-carpal-setup-buffer 'summary))
1909 (unless gnus-single-article-buffer
1910 (make-local-variable 'gnus-article-buffer)
1911 (make-local-variable 'gnus-article-current)
1912 (make-local-variable 'gnus-original-article-buffer))
1913 (setq gnus-newsgroup-name group)
1916 (defun gnus-set-global-variables ()
1917 ;; Set the global equivalents of the summary buffer-local variables
1918 ;; to the latest values they had. These reflect the summary buffer
1919 ;; that was in action when the last article was fetched.
1920 (when (eq major-mode 'gnus-summary-mode)
1921 (setq gnus-summary-buffer (current-buffer))
1922 (let ((name gnus-newsgroup-name)
1923 (marked gnus-newsgroup-marked)
1924 (unread gnus-newsgroup-unreads)
1925 (headers gnus-current-headers)
1926 (data gnus-newsgroup-data)
1927 (summary gnus-summary-buffer)
1928 (article-buffer gnus-article-buffer)
1929 (original gnus-original-article-buffer)
1930 (gac gnus-article-current)
1931 (reffed gnus-reffed-article-number)
1932 (score-file gnus-current-score-file))
1934 (set-buffer gnus-group-buffer)
1935 (setq gnus-newsgroup-name name)
1936 (setq gnus-newsgroup-marked marked)
1937 (setq gnus-newsgroup-unreads unread)
1938 (setq gnus-current-headers headers)
1939 (setq gnus-newsgroup-data data)
1940 (setq gnus-article-current gac)
1941 (setq gnus-summary-buffer summary)
1942 (setq gnus-article-buffer article-buffer)
1943 (setq gnus-original-article-buffer original)
1944 (setq gnus-reffed-article-number reffed)
1945 (setq gnus-current-score-file score-file)))))
1947 (defun gnus-summary-last-article-p (&optional article)
1948 "Return whether ARTICLE is the last article in the buffer."
1949 (if (not (setq article (or article (gnus-summary-article-number))))
1950 t ; All non-existant numbers are the last article. :-)
1951 (not (cdr (gnus-data-find-list article)))))
1953 (defun gnus-make-thread-indent-array ()
1955 (unless (and gnus-thread-indent-array
1956 (= gnus-thread-indent-level gnus-thread-indent-array-level))
1957 (setq gnus-thread-indent-array (make-vector 201 "")
1958 gnus-thread-indent-array-level gnus-thread-indent-level)
1960 (aset gnus-thread-indent-array n
1961 (make-string (* n gnus-thread-indent-level) ? ))
1964 (defun gnus-update-summary-mark-positions ()
1965 "Compute where the summary marks are to go."
1967 (when (and gnus-summary-buffer
1968 (get-buffer gnus-summary-buffer)
1969 (buffer-name (get-buffer gnus-summary-buffer)))
1970 (set-buffer gnus-summary-buffer))
1971 (let ((gnus-replied-mark 129)
1972 (gnus-score-below-mark 130)
1973 (gnus-score-over-mark 130)
1976 (spec gnus-summary-line-format-spec)
1979 (gnus-set-work-buffer)
1980 (let ((gnus-summary-line-format-spec spec))
1981 (gnus-summary-insert-line
1982 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1983 (goto-char (point-min))
1984 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1986 (goto-char (point-min))
1987 (push (cons 'replied (and (search-forward "\201" nil t)
1990 (goto-char (point-min))
1991 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
1993 (setq gnus-summary-mark-positions pos))))
1995 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
1996 "Insert a dummy root in the summary buffer."
1998 (gnus-add-text-properties
1999 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2000 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2002 (defun gnus-summary-insert-line
2003 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
2004 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
2005 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
2006 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2007 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2008 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2009 (gnus-tmp-score-char
2010 (if (or (null gnus-summary-default-score)
2011 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2012 gnus-summary-zcore-fuzz)) ?
2013 (if (< gnus-tmp-score gnus-summary-default-score)
2014 gnus-score-below-mark gnus-score-over-mark)))
2015 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
2016 ((memq gnus-tmp-current gnus-newsgroup-cached)
2018 (gnus-tmp-replied gnus-replied-mark)
2019 ((memq gnus-tmp-current gnus-newsgroup-saved)
2021 (t gnus-unread-mark)))
2022 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2025 ((string-match "(.+)" gnus-tmp-from)
2026 (substring gnus-tmp-from
2027 (1+ (match-beginning 0)) (1- (match-end 0))))
2028 ((string-match "<[^>]+> *$" gnus-tmp-from)
2029 (let ((beg (match-beginning 0)))
2030 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2031 (substring gnus-tmp-from (1+ (match-beginning 0))
2032 (1- (match-end 0))))
2033 (substring gnus-tmp-from 0 beg))))
2035 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2036 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2037 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2038 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2039 (buffer-read-only nil))
2040 (when (string= gnus-tmp-name "")
2041 (setq gnus-tmp-name gnus-tmp-from))
2042 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
2043 (gnus-put-text-property
2045 (progn (eval gnus-summary-line-format-spec) (point))
2046 'gnus-number gnus-tmp-number)
2047 (when (gnus-visual-p 'summary-highlight 'highlight)
2049 (run-hooks 'gnus-summary-update-hook)
2052 (defun gnus-summary-update-line (&optional dont-update)
2053 ;; Update summary line after change.
2054 (when (and gnus-summary-default-score
2055 (not gnus-summary-inhibit-highlight))
2056 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2057 (article (gnus-summary-article-number))
2058 (score (gnus-summary-article-score article)))
2060 (if (and gnus-summary-mark-below
2061 (< (gnus-summary-article-score)
2062 gnus-summary-mark-below))
2063 ;; This article has a low score, so we mark it as read.
2064 (when (memq article gnus-newsgroup-unreads)
2065 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2066 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2067 ;; This article was previously marked as read on account
2068 ;; of a low score, but now it has risen, so we mark it as
2070 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2071 (gnus-summary-update-mark
2072 (if (or (null gnus-summary-default-score)
2073 (<= (abs (- score gnus-summary-default-score))
2074 gnus-summary-zcore-fuzz)) ?
2075 (if (< score gnus-summary-default-score)
2076 gnus-score-below-mark gnus-score-over-mark)) 'score))
2077 ;; Do visual highlighting.
2078 (when (gnus-visual-p 'summary-highlight 'highlight)
2079 (run-hooks 'gnus-summary-update-hook)))))
2081 (defvar gnus-tmp-new-adopts nil)
2083 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2084 ;; Sum up all elements (and sub-elements) in a list.
2086 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2088 ((and (consp thread) (cdr thread))
2091 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2094 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2097 (when (and level (zerop level) gnus-tmp-new-adopts)
2100 'gnus-summary-number-of-articles-in-thread
2101 gnus-tmp-new-adopts))))
2103 (if (> number 1) gnus-not-empty-thread-mark
2104 gnus-empty-thread-mark)
2107 (defun gnus-summary-set-local-parameters (group)
2108 "Go through the local params of GROUP and set all variable specs in that list."
2109 (let ((params (gnus-group-find-parameter group))
2112 (setq elem (car params)
2113 params (cdr params))
2114 (and (consp elem) ; Has to be a cons.
2115 (consp (cdr elem)) ; The cdr has to be a list.
2116 (symbolp (car elem)) ; Has to be a symbol in there.
2117 (not (memq (car elem)
2118 '(quit-config to-address to-list to-group)))
2119 (progn ; So we set it.
2120 (make-local-variable (car elem))
2121 (set (car elem) (eval (nth 1 elem))))))))
2123 (defun gnus-summary-read-group (group &optional show-all no-article
2124 kill-buffer no-display)
2125 "Start reading news in newsgroup GROUP.
2126 If SHOW-ALL is non-nil, already read articles are also listed.
2127 If NO-ARTICLE is non-nil, no article is selected initially.
2128 If NO-DISPLAY, don't generate a summary buffer."
2129 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2130 (let* ((new-group (gnus-summary-setup-buffer group))
2131 (quit-config (gnus-group-quit-config group))
2132 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2134 ;; This summary buffer exists already, so we just select it.
2136 (gnus-set-global-variables)
2138 (gnus-kill-or-deaden-summary kill-buffer))
2139 (gnus-configure-windows 'summary 'force)
2140 (gnus-set-mode-line 'summary)
2141 (gnus-summary-position-point)
2144 ;; We couldn't select this group.
2146 (when (and (eq major-mode 'gnus-summary-mode)
2147 (not (equal (current-buffer) kill-buffer)))
2148 (kill-buffer (current-buffer))
2149 (if (not quit-config)
2151 (set-buffer gnus-group-buffer)
2152 (gnus-group-jump-to-group group)
2153 (gnus-group-next-unread-group 1))
2154 (if (not (buffer-name (car quit-config)))
2155 (gnus-configure-windows 'group 'force)
2156 (set-buffer (car quit-config))
2157 (and (eq major-mode 'gnus-summary-mode)
2158 (gnus-set-global-variables))
2159 (gnus-configure-windows (cdr quit-config)))))
2160 (gnus-message 3 "Can't select group")
2162 ;; The user did a `C-g' while prompting for number of articles,
2163 ;; so we exit this group.
2164 ((eq did-select 'quit)
2165 (and (eq major-mode 'gnus-summary-mode)
2166 (not (equal (current-buffer) kill-buffer))
2167 (kill-buffer (current-buffer)))
2169 (gnus-kill-or-deaden-summary kill-buffer))
2170 (if (not quit-config)
2172 (set-buffer gnus-group-buffer)
2173 (gnus-group-jump-to-group group)
2174 (gnus-group-next-unread-group 1)
2175 (gnus-configure-windows 'group 'force))
2176 (if (not (buffer-name (car quit-config)))
2177 (gnus-configure-windows 'group 'force)
2178 (set-buffer (car quit-config))
2179 (and (eq major-mode 'gnus-summary-mode)
2180 (gnus-set-global-variables))
2181 (gnus-configure-windows (cdr quit-config))))
2182 ;; Finally signal the quit.
2184 ;; The group was successfully selected.
2186 (gnus-set-global-variables)
2187 ;; Save the active value in effect when the group was entered.
2188 (setq gnus-newsgroup-active
2190 (gnus-active gnus-newsgroup-name)))
2191 ;; You can change the summary buffer in some way with this hook.
2192 (run-hooks 'gnus-select-group-hook)
2193 ;; Set any local variables in the group parameters.
2194 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2195 (gnus-update-format-specifications)
2196 ;; Do score processing.
2197 (when gnus-use-scoring
2198 (gnus-possibly-score-headers))
2199 ;; Check whether to fill in the gaps in the threads.
2200 (when gnus-build-sparse-threads
2201 (gnus-build-sparse-threads))
2202 ;; Find the initial limit.
2203 (if gnus-show-threads
2205 (let ((gnus-newsgroup-dormant nil))
2206 (gnus-summary-initial-limit show-all))
2207 (gnus-summary-initial-limit show-all))
2208 (setq gnus-newsgroup-limit
2210 (lambda (header) (mail-header-number header))
2211 gnus-newsgroup-headers)))
2212 ;; Generate the summary buffer.
2214 (gnus-summary-prepare))
2215 (when gnus-use-trees
2216 (gnus-tree-open group)
2217 (setq gnus-summary-highlight-line-function
2218 'gnus-tree-highlight-article))
2219 ;; If the summary buffer is empty, but there are some low-scored
2220 ;; articles or some excluded dormants, we include these in the
2222 (when (and (zerop (buffer-size))
2224 (cond (gnus-newsgroup-dormant
2225 (gnus-summary-limit-include-dormant))
2226 ((and gnus-newsgroup-scored show-all)
2227 (gnus-summary-limit-include-expunged t))))
2228 ;; Function `gnus-apply-kill-file' must be called in this hook.
2229 (run-hooks 'gnus-apply-kill-hook)
2230 (if (and (zerop (buffer-size))
2233 ;; This newsgroup is empty.
2234 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2235 (gnus-message 6 "No unread news")
2237 (gnus-kill-or-deaden-summary kill-buffer))
2238 ;; Return nil from this function.
2240 ;; Hide conversation thread subtrees. We cannot do this in
2241 ;; gnus-summary-prepare-hook since kill processing may not
2242 ;; work with hidden articles.
2243 (and gnus-show-threads
2244 gnus-thread-hide-subtree
2245 (gnus-summary-hide-all-threads))
2246 ;; Show first unread article if requested.
2247 (if (and (not no-article)
2249 gnus-newsgroup-unreads
2250 gnus-auto-select-first)
2251 (unless (if (eq gnus-auto-select-first 'best)
2252 (gnus-summary-best-unread-article)
2253 (gnus-summary-first-unread-article))
2254 (gnus-configure-windows 'summary))
2255 ;; Don't select any articles, just move point to the first
2256 ;; article in the group.
2257 (goto-char (point-min))
2258 (gnus-summary-position-point)
2259 (gnus-set-mode-line 'summary)
2260 (gnus-configure-windows 'summary 'force))
2262 (gnus-kill-or-deaden-summary kill-buffer))
2263 (when (get-buffer-window gnus-group-buffer t)
2264 ;; Gotta use windows, because recenter does wierd stuff if
2265 ;; the current buffer ain't the displayed window.
2266 (let ((owin (selected-window)))
2267 (select-window (get-buffer-window gnus-group-buffer t))
2268 (when (gnus-group-goto-group group)
2270 (select-window owin))))
2271 ;; Mark this buffer as "prepared".
2272 (setq gnus-newsgroup-prepared t)
2275 (defun gnus-summary-prepare ()
2276 "Generate the summary buffer."
2277 (let ((buffer-read-only nil))
2279 (setq gnus-newsgroup-data nil
2280 gnus-newsgroup-data-reverse nil)
2281 (run-hooks 'gnus-summary-generate-hook)
2282 ;; Generate the buffer, either with threads or without.
2283 (when gnus-newsgroup-headers
2284 (gnus-summary-prepare-threads
2285 (if gnus-show-threads
2286 (gnus-sort-gathered-threads
2287 (funcall gnus-summary-thread-gathering-function
2289 (gnus-cut-threads (gnus-make-threads)))))
2290 ;; Unthreaded display.
2291 (gnus-sort-articles gnus-newsgroup-headers))))
2292 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2293 ;; Call hooks for modifying summary buffer.
2294 (goto-char (point-min))
2295 (run-hooks 'gnus-summary-prepare-hook)))
2297 (defsubst gnus-general-simplify-subject (subject)
2298 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2301 ;; Truncate the subject.
2302 ((numberp gnus-summary-gather-subject-limit)
2303 (setq subject (gnus-simplify-subject-re subject))
2304 (if (> (length subject) gnus-summary-gather-subject-limit)
2305 (substring subject 0 gnus-summary-gather-subject-limit)
2307 ;; Fuzzily simplify it.
2308 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2309 (gnus-simplify-subject-fuzzy subject))
2310 ;; Just remove the leading "Re:".
2312 (gnus-simplify-subject-re subject))))
2314 (if (and gnus-summary-gather-exclude-subject
2315 (string-match gnus-summary-gather-exclude-subject subject))
2316 nil ; This article shouldn't be gathered
2319 (defun gnus-summary-simplify-subject-query ()
2320 "Query where the respool algorithm would put this article."
2322 (gnus-set-global-variables)
2323 (gnus-summary-select-article)
2324 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2326 (defun gnus-gather-threads-by-subject (threads)
2327 "Gather threads by looking at Subject headers."
2328 (if (not gnus-summary-make-false-root)
2330 (let ((hashtb (gnus-make-hashtable 1023))
2333 subject hthread whole-subject)
2335 (setq subject (gnus-general-simplify-subject
2336 (setq whole-subject (mail-header-subject
2339 (if (setq hthread (gnus-gethash subject hashtb))
2341 ;; We enter a dummy root into the thread, if we
2342 ;; haven't done that already.
2343 (unless (stringp (caar hthread))
2344 (setcar hthread (list whole-subject (car hthread))))
2345 ;; We add this new gathered thread to this gathered
2347 (setcdr (car hthread)
2348 (nconc (cdar hthread) (list (car threads))))
2349 ;; Remove it from the list of threads.
2350 (setcdr prev (cdr threads))
2351 (setq threads prev))
2352 ;; Enter this thread into the hash table.
2353 (gnus-sethash subject threads hashtb)))
2355 (setq threads (cdr threads)))
2358 (defun gnus-gather-threads-by-references (threads)
2359 "Gather threads by looking at References headers."
2360 (let ((idhashtb (gnus-make-hashtable 1023))
2361 (thhashtb (gnus-make-hashtable 1023))
2364 ids references id gthread gid entered)
2366 (when (setq references (mail-header-references (caar threads)))
2367 (setq id (mail-header-id (caar threads)))
2368 (setq ids (gnus-split-references references))
2371 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
2373 (gnus-sethash (car ids) id idhashtb)
2374 (gnus-sethash id threads thhashtb))
2375 (setq gthread (gnus-gethash gid thhashtb))
2377 ;; We enter a dummy root into the thread, if we
2378 ;; haven't done that already.
2379 (unless (stringp (caar gthread))
2380 (setcar gthread (list (mail-header-subject (caar gthread))
2382 ;; We add this new gathered thread to this gathered
2384 (setcdr (car gthread)
2385 (nconc (cdar gthread) (list (car threads)))))
2386 ;; Add it into the thread hash table.
2387 (gnus-sethash id gthread thhashtb)
2389 ;; Remove it from the list of threads.
2390 (setcdr prev (cdr threads))
2391 (setq threads prev))
2392 (setq ids (cdr ids))))
2394 (setq threads (cdr threads)))
2397 (defun gnus-sort-gathered-threads (threads)
2398 "Sort subtreads inside each gathered thread by article number."
2399 (let ((result threads))
2401 (when (stringp (caar threads))
2402 (setcdr (car threads)
2403 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2404 (setq threads (cdr threads)))
2407 (defun gnus-make-threads ()
2408 "Go through the dependency hashtb and find the roots. Return all threads."
2412 (unless (car (symbol-value refs))
2413 ;; These threads do not refer back to any other articles,
2414 ;; so they're roots.
2415 (setq threads (append (cdr (symbol-value refs)) threads))))
2416 gnus-newsgroup-dependencies)
2419 (defun gnus-build-sparse-threads ()
2420 (let ((headers gnus-newsgroup-headers)
2421 (deps gnus-newsgroup-dependencies)
2422 header references generation relations
2423 cthread subject child end pthread relation)
2424 ;; First we create an alist of generations/relations, where
2425 ;; generations is how much we trust the ralation, and the relation
2427 (gnus-message 7 "Making sparse threads...")
2429 (nnheader-set-temp-buffer " *gnus sparse threads*")
2430 (while (setq header (pop headers))
2431 (when (and (setq references (mail-header-references header))
2432 (not (string= references "")))
2434 (setq child (mail-header-id header)
2435 subject (mail-header-subject header))
2437 (while (search-backward ">" nil t)
2438 (setq end (1+ (point)))
2439 (when (search-backward "<" nil t)
2440 (push (list (incf generation)
2441 child (setq child (buffer-substring (point) end))
2444 (push (list (1+ generation) child nil subject) relations)
2446 (kill-buffer (current-buffer)))
2447 ;; Sort over trustworthiness.
2448 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2449 (while (setq relation (pop relations))
2450 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2451 (unless (car (symbol-value cthread))
2452 ;; Make this article the parent of these threads.
2453 (setcar (symbol-value cthread)
2454 (vector gnus-reffed-article-number
2458 (or (caddr relation) "") 0 0 "")))
2459 (set cthread (list (vector gnus-reffed-article-number
2461 "" "" (cadr relation)
2462 (or (caddr relation) "") 0 0 ""))))
2463 (push gnus-reffed-article-number gnus-newsgroup-limit)
2464 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2465 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2466 gnus-newsgroup-reads)
2467 (decf gnus-reffed-article-number)
2468 ;; Make this new thread the child of its parent.
2469 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2470 (setcdr (symbol-value pthread)
2471 (nconc (cdr (symbol-value pthread))
2472 (list (symbol-value cthread))))
2473 (set pthread (list nil (symbol-value cthread))))))
2474 (gnus-message 7 "Making sparse threads...done")))
2476 (defun gnus-build-old-threads ()
2477 ;; Look at all the articles that refer back to old articles, and
2478 ;; fetch the headers for the articles that aren't there. This will
2479 ;; build complete threads - if the roots haven't been expired by the
2484 (when (not (car (symbol-value refs)))
2485 (setq heads (cdr (symbol-value refs)))
2487 (if (memq (mail-header-number (caar heads))
2488 gnus-newsgroup-dormant)
2489 (setq heads (cdr heads))
2490 (setq id (symbol-name refs))
2491 (while (and (setq id (gnus-build-get-header id))
2492 (not (car (gnus-gethash
2493 id gnus-newsgroup-dependencies)))))
2494 (setq heads nil)))))
2495 gnus-newsgroup-dependencies)))
2497 (defun gnus-build-get-header (id)
2498 ;; Look through the buffer of NOV lines and find the header to
2499 ;; ID. Enter this line into the dependencies hash table, and return
2500 ;; the id of the parent article (if any).
2501 (let ((deps gnus-newsgroup-dependencies)
2505 (set-buffer nntp-server-buffer)
2506 (goto-char (point-min))
2507 (while (and (not found) (search-forward id nil t))
2509 (setq found (looking-at
2510 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2511 (regexp-quote id))))
2512 (or found (beginning-of-line 2)))
2516 (setq header (gnus-nov-parse-line
2517 (read (current-buffer)) deps))
2518 (gnus-parent-id (mail-header-references header)))))
2520 (let ((number (mail-header-number header)))
2521 (push number gnus-newsgroup-limit)
2522 (push header gnus-newsgroup-headers)
2523 (if (memq number gnus-newsgroup-unselected)
2525 (push number gnus-newsgroup-unreads)
2526 (setq gnus-newsgroup-unselected
2527 (delq number gnus-newsgroup-unselected)))
2528 (push number gnus-newsgroup-ancient)))))))
2530 (defun gnus-summary-update-article-line (article header)
2531 "Update the line for ARTICLE using HEADERS."
2532 (let* ((id (mail-header-id header))
2533 (thread (gnus-id-to-thread id)))
2535 (error "Article in no thread"))
2536 ;; Update the thread.
2537 (setcar thread header)
2538 (gnus-summary-goto-subject article)
2539 (let* ((datal (gnus-data-find-list article))
2541 (length (when (cdr datal)
2542 (- (gnus-data-pos data)
2543 (gnus-data-pos (cadr datal)))))
2544 (buffer-read-only nil)
2545 (level (gnus-summary-thread-level)))
2547 (gnus-summary-insert-line
2548 header level nil (gnus-article-mark article)
2549 (memq article gnus-newsgroup-replied)
2550 (memq article gnus-newsgroup-expirable)
2551 (mail-header-subject header)
2552 nil (cdr (assq article gnus-newsgroup-scored))
2553 (memq article gnus-newsgroup-processable))
2555 (gnus-data-update-list
2556 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2558 (defun gnus-summary-update-article (article &optional iheader)
2559 "Update ARTICLE in the summary buffer."
2560 (set-buffer gnus-summary-buffer)
2561 (let* ((header (or iheader (gnus-summary-article-header article)))
2562 (id (mail-header-id header))
2563 (data (gnus-data-find article))
2564 (thread (gnus-id-to-thread id))
2565 (references (mail-header-references header))
2570 (not (equal "" references)))
2573 (buffer-read-only nil)
2575 (number (mail-header-number header))
2578 ;; !!! Should this be in or not?
2580 (setcar thread nil))
2582 (delq thread parent))
2583 (if (gnus-summary-insert-subject id header iheader)
2584 ;; Set the (possibly) new article number in the data structure.
2585 (gnus-data-set-number data (gnus-id-to-article id))
2589 (defun gnus-rebuild-thread (id)
2590 "Rebuild the thread containing ID."
2591 (let ((buffer-read-only nil)
2592 current thread data)
2593 (if (not gnus-show-threads)
2594 (setq thread (list (car (gnus-id-to-thread id))))
2595 ;; Get the thread this article is part of.
2596 (setq thread (gnus-remove-thread id)))
2597 (setq current (save-excursion
2598 (and (zerop (forward-line -1))
2599 (gnus-summary-article-number))))
2600 ;; If this is a gathered thread, we have to go some re-gathering.
2601 (when (stringp (car thread))
2602 (let ((subject (car thread))
2604 (setq thread (cdr thread))
2606 (unless (memq (setq thr (gnus-id-to-thread
2608 (mail-header-id (caar thread)))))
2611 (setq thread (cdr thread)))
2612 ;; We now have all (unique) roots.
2613 (if (= (length roots) 1)
2614 ;; All the loose roots are now one solid root.
2615 (setq thread (car roots))
2616 (setq thread (cons subject (gnus-sort-threads roots))))))
2618 ;; We then insert this thread into the summary buffer.
2619 (let (gnus-newsgroup-data gnus-newsgroup-threads)
2620 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
2621 (setq data (nreverse gnus-newsgroup-data))
2622 (setq threads gnus-newsgroup-threads))
2623 ;; We splice the new data into the data structure.
2624 (gnus-data-enter-list current data)
2625 (gnus-data-compute-positions)
2626 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
2628 (defun gnus-number-to-header (number)
2629 "Return the header for article NUMBER."
2630 (let ((headers gnus-newsgroup-headers))
2632 (not (= number (mail-header-number (car headers)))))
2637 (defun gnus-parent-headers (headers &optional generation)
2638 "Return the headers of the GENERATIONeth parent of HEADERS."
2640 (setq generation 1))
2641 (let (references parent)
2642 (while (and headers (not (zerop generation)))
2643 (setq references (mail-header-references headers))
2644 (when (and references
2645 (setq parent (gnus-parent-id references))
2646 (setq headers (car (gnus-id-to-thread parent))))
2650 (defun gnus-id-to-thread (id)
2651 "Return the (sub-)thread where ID appears."
2652 (gnus-gethash id gnus-newsgroup-dependencies))
2654 (defun gnus-id-to-article (id)
2655 "Return the article number of ID."
2656 (let ((thread (gnus-id-to-thread id)))
2659 (mail-header-number (car thread)))))
2661 (defun gnus-id-to-header (id)
2662 "Return the article headers of ID."
2663 (car (gnus-id-to-thread id)))
2665 (defun gnus-article-displayed-root-p (article)
2666 "Say whether ARTICLE is a root(ish) article."
2667 (let ((level (gnus-summary-thread-level article))
2668 (refs (mail-header-references (gnus-summary-article-header article)))
2674 ((null (gnus-parent-id refs)) t)
2676 (null (setq particle (gnus-id-to-article
2677 (gnus-parent-id refs))))
2678 (null (gnus-summary-thread-level particle)))))))
2680 (defun gnus-root-id (id)
2681 "Return the id of the root of the thread where ID appears."
2683 (while (and id (setq prev (car (gnus-gethash
2684 id gnus-newsgroup-dependencies))))
2686 id (gnus-parent-id (mail-header-references prev))))
2689 (defun gnus-remove-thread (id &optional dont-remove)
2690 "Remove the thread that has ID in it."
2691 (let ((dep gnus-newsgroup-dependencies)
2692 headers thread last-id)
2693 ;; First go up in this thread until we find the root.
2694 (setq last-id (gnus-root-id id))
2695 (setq headers (list (car (gnus-id-to-thread last-id))
2696 (caadr (gnus-id-to-thread last-id))))
2697 ;; We have now found the real root of this thread. It might have
2698 ;; been gathered into some loose thread, so we have to search
2699 ;; through the threads to find the thread we wanted.
2700 (let ((threads gnus-newsgroup-threads)
2703 (setq sub (car threads))
2704 (if (stringp (car sub))
2705 ;; This is a gathered thread, so we look at the roots
2706 ;; below it to find whether this article is in this
2709 (setq sub (cdr sub))
2711 (when (member (caar sub) headers)
2712 (setq thread (car threads)
2715 (setq sub (cdr sub))))
2716 ;; It's an ordinary thread, so we check it.
2717 (when (eq (car sub) (car headers))
2720 (setq threads (cdr threads)))
2721 ;; If this article is in no thread, then it's a root.
2724 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
2725 (setq thread (gnus-gethash last-id dep)))
2728 thread ; We return this thread.
2730 (if (stringp (car thread))
2732 ;; If we use dummy roots, then we have to remove the
2733 ;; dummy root as well.
2734 (when (eq gnus-summary-make-false-root 'dummy)
2737 (setq thread (cdr thread))
2739 (gnus-remove-thread-1 (car thread))
2740 (setq thread (cdr thread))))
2741 (gnus-remove-thread-1 thread))))))))
2743 (defun gnus-remove-thread-1 (thread)
2744 "Remove the thread THREAD recursively."
2745 (let ((number (mail-header-number (car thread)))
2747 (when (setq pos (text-property-any
2748 (point-min) (point-max) 'gnus-number number))
2751 (gnus-data-remove number))
2752 (setq thread (cdr thread))
2754 (gnus-remove-thread-1 (pop thread)))))
2756 (defun gnus-sort-threads (threads)
2758 (if (not gnus-thread-sort-functions)
2760 (let ((func (if (= 1 (length gnus-thread-sort-functions))
2761 (car gnus-thread-sort-functions)
2763 ,(gnus-make-sort-function
2764 (reverse gnus-thread-sort-functions))))))
2765 (gnus-message 7 "Sorting threads...")
2768 (gnus-message 7 "Sorting threads...done")))))
2770 (defun gnus-sort-articles (articles)
2772 (when gnus-article-sort-functions
2773 (let ((func (if (= 1 (length gnus-article-sort-functions))
2774 (car gnus-article-sort-functions)
2776 ,(gnus-make-sort-function
2777 (reverse gnus-article-sort-functions))))))
2778 (gnus-message 7 "Sorting articles...")
2780 (setq gnus-newsgroup-headers (sort articles func))
2781 (gnus-message 7 "Sorting articles...done")))))
2783 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2784 (defmacro gnus-thread-header (thread)
2785 ;; Return header of first article in THREAD.
2786 ;; Note that THREAD must never, ever be anything else than a variable -
2787 ;; using some other form will lead to serious barfage.
2788 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
2789 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
2790 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
2793 (defsubst gnus-article-sort-by-number (h1 h2)
2794 "Sort articles by article number."
2795 (< (mail-header-number h1)
2796 (mail-header-number h2)))
2798 (defun gnus-thread-sort-by-number (h1 h2)
2799 "Sort threads by root article number."
2800 (gnus-article-sort-by-number
2801 (gnus-thread-header h1) (gnus-thread-header h2)))
2803 (defsubst gnus-article-sort-by-author (h1 h2)
2804 "Sort articles by root author."
2806 (let ((extract (funcall
2807 gnus-extract-address-components
2808 (mail-header-from h1))))
2809 (or (car extract) (cdr extract)))
2810 (let ((extract (funcall
2811 gnus-extract-address-components
2812 (mail-header-from h2))))
2813 (or (car extract) (cdr extract)))))
2815 (defun gnus-thread-sort-by-author (h1 h2)
2816 "Sort threads by root author."
2817 (gnus-article-sort-by-author
2818 (gnus-thread-header h1) (gnus-thread-header h2)))
2820 (defsubst gnus-article-sort-by-subject (h1 h2)
2821 "Sort articles by root subject."
2823 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
2824 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
2826 (defun gnus-thread-sort-by-subject (h1 h2)
2827 "Sort threads by root subject."
2828 (gnus-article-sort-by-subject
2829 (gnus-thread-header h1) (gnus-thread-header h2)))
2831 (defsubst gnus-article-sort-by-date (h1 h2)
2832 "Sort articles by root article date."
2834 (inline (gnus-sortable-date (mail-header-date h1)))
2835 (inline (gnus-sortable-date (mail-header-date h2)))))
2837 (defun gnus-thread-sort-by-date (h1 h2)
2838 "Sort threads by root article date."
2839 (gnus-article-sort-by-date
2840 (gnus-thread-header h1) (gnus-thread-header h2)))
2842 (defsubst gnus-article-sort-by-score (h1 h2)
2843 "Sort articles by root article score.
2844 Unscored articles will be counted as having a score of zero."
2845 (> (or (cdr (assq (mail-header-number h1)
2846 gnus-newsgroup-scored))
2847 gnus-summary-default-score 0)
2848 (or (cdr (assq (mail-header-number h2)
2849 gnus-newsgroup-scored))
2850 gnus-summary-default-score 0)))
2852 (defun gnus-thread-sort-by-score (h1 h2)
2853 "Sort threads by root article score."
2854 (gnus-article-sort-by-score
2855 (gnus-thread-header h1) (gnus-thread-header h2)))
2857 (defun gnus-thread-sort-by-total-score (h1 h2)
2858 "Sort threads by the sum of all scores in the thread.
2859 Unscored articles will be counted as having a score of zero."
2860 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
2862 (defun gnus-thread-total-score (thread)
2863 ;; This function find the total score of THREAD.
2864 (cond ((null thread)
2867 (if (stringp (car thread))
2868 (apply gnus-thread-score-function 0
2869 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
2870 (gnus-thread-total-score-1 thread)))
2872 (gnus-thread-total-score-1 (list thread)))))
2874 (defun gnus-thread-total-score-1 (root)
2875 ;; This function find the total score of the thread below ROOT.
2876 (setq root (car root))
2877 (apply gnus-thread-score-function
2879 (mapcar 'gnus-thread-total-score
2880 (cdr (gnus-gethash (mail-header-id root)
2881 gnus-newsgroup-dependencies)))
2882 (if (> (mail-header-number root) 0)
2883 (list (or (cdr (assq (mail-header-number root)
2884 gnus-newsgroup-scored))
2885 gnus-summary-default-score 0))))
2886 (list gnus-summary-default-score)
2889 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
2890 (defvar gnus-tmp-prev-subject nil)
2891 (defvar gnus-tmp-false-parent nil)
2892 (defvar gnus-tmp-root-expunged nil)
2893 (defvar gnus-tmp-dummy-line nil)
2895 (defun gnus-summary-prepare-threads (threads)
2896 "Prepare summary buffer from THREADS and indentation LEVEL.
2897 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
2898 or a straight list of headers."
2899 (gnus-message 7 "Generating summary...")
2901 (setq gnus-newsgroup-threads threads)
2904 (let ((gnus-tmp-level 0)
2905 (default-score (or gnus-summary-default-score 0))
2906 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
2907 thread number subject stack state gnus-tmp-gathered beg-match
2908 new-roots gnus-tmp-new-adopts thread-end
2909 gnus-tmp-header gnus-tmp-unread
2910 gnus-tmp-replied gnus-tmp-subject-or-nil
2911 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
2912 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
2913 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
2915 (setq gnus-tmp-prev-subject nil)
2917 (if (vectorp (car threads))
2918 ;; If this is a straight (sic) list of headers, then a
2919 ;; threaded summary display isn't required, so we just create
2920 ;; an unthreaded one.
2921 (gnus-summary-prepare-unthreaded threads)
2923 ;; Do the threaded display.
2925 (while (or threads stack gnus-tmp-new-adopts new-roots)
2927 (if (and (= gnus-tmp-level 0)
2928 (not (setq gnus-tmp-dummy-line nil))
2931 (not gnus-tmp-false-parent)
2932 (or gnus-tmp-new-adopts new-roots))
2933 (if gnus-tmp-new-adopts
2934 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
2935 thread (list (car gnus-tmp-new-adopts))
2936 gnus-tmp-header (caar thread)
2937 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
2939 (setq thread (list (car new-roots))
2940 gnus-tmp-header (caar thread)
2941 new-roots (cdr new-roots))))
2944 ;; If there are some threads, we do them before the
2945 ;; threads on the stack.
2946 (setq thread threads
2947 gnus-tmp-header (caar thread))
2948 ;; There were no current threads, so we pop something off
2950 (setq state (car stack)
2951 gnus-tmp-level (car state)
2954 gnus-tmp-header (caar thread))))
2956 (setq gnus-tmp-false-parent nil)
2957 (setq gnus-tmp-root-expunged nil)
2958 (setq thread-end nil)
2960 (if (stringp gnus-tmp-header)
2961 ;; The header is a dummy root.
2963 ((eq gnus-summary-make-false-root 'adopt)
2964 ;; We let the first article adopt the rest.
2965 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
2967 (setq gnus-tmp-gathered
2969 (lambda (h) (mail-header-number (car h)))
2972 (setq thread (cons (list (caar thread)
2975 (setq gnus-tmp-level -1
2976 gnus-tmp-false-parent t))
2977 ((eq gnus-summary-make-false-root 'empty)
2978 ;; We print adopted articles with empty subject fields.
2979 (setq gnus-tmp-gathered
2981 (lambda (h) (mail-header-number (car h)))
2984 (setq gnus-tmp-level -1))
2985 ((eq gnus-summary-make-false-root 'dummy)
2986 ;; We remember that we probably want to output a dummy
2988 (setq gnus-tmp-dummy-line gnus-tmp-header)
2989 (setq gnus-tmp-prev-subject gnus-tmp-header))
2991 ;; We do not make a root for the gathered
2992 ;; sub-threads at all.
2993 (setq gnus-tmp-level -1)))
2995 (setq number (mail-header-number gnus-tmp-header)
2996 subject (mail-header-subject gnus-tmp-header))
2999 ;; If the thread has changed subject, we might want to make
3000 ;; this subthread into a root.
3001 ((and (null gnus-thread-ignore-subject)
3002 (not (zerop gnus-tmp-level))
3003 gnus-tmp-prev-subject
3005 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3006 (setq new-roots (nconc new-roots (list (car thread)))
3008 gnus-tmp-header nil))
3009 ;; If the article lies outside the current limit,
3010 ;; then we do not display it.
3011 ((and (not (memq number gnus-newsgroup-limit))
3012 (not gnus-tmp-dummy-line))
3013 (setq gnus-tmp-gathered
3015 (lambda (h) (mail-header-number (car h)))
3018 (setq gnus-tmp-new-adopts (if (cdar thread)
3019 (append gnus-tmp-new-adopts
3021 gnus-tmp-new-adopts)
3023 gnus-tmp-header nil)
3024 (when (zerop gnus-tmp-level)
3025 (setq gnus-tmp-root-expunged t)))
3026 ;; Perhaps this article is to be marked as read?
3027 ((and gnus-summary-mark-below
3028 (< (or (cdr (assq number gnus-newsgroup-scored))
3030 gnus-summary-mark-below)
3031 ;; Don't touch sparse articles.
3032 (not (memq number gnus-newsgroup-sparse))
3033 (not (memq number gnus-newsgroup-ancient)))
3034 (setq gnus-newsgroup-unreads
3035 (delq number gnus-newsgroup-unreads))
3036 (if gnus-newsgroup-auto-expire
3037 (push number gnus-newsgroup-expirable)
3038 (push (cons number gnus-low-score-mark)
3039 gnus-newsgroup-reads))))
3041 (when gnus-tmp-header
3042 ;; We may have an old dummy line to output before this
3044 (when gnus-tmp-dummy-line
3045 (gnus-summary-insert-dummy-line
3046 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3047 (setq gnus-tmp-dummy-line nil))
3049 ;; Compute the mark.
3050 (setq gnus-tmp-unread (gnus-article-mark number))
3052 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3053 gnus-tmp-header gnus-tmp-level)
3054 gnus-newsgroup-data)
3056 ;; Actually insert the line.
3058 gnus-tmp-subject-or-nil
3060 ((and gnus-thread-ignore-subject
3061 gnus-tmp-prev-subject
3062 (not (inline (gnus-subject-equal
3063 gnus-tmp-prev-subject subject))))
3065 ((zerop gnus-tmp-level)
3066 (if (and (eq gnus-summary-make-false-root 'empty)
3067 (memq number gnus-tmp-gathered)
3068 gnus-tmp-prev-subject
3069 (inline (gnus-subject-equal
3070 gnus-tmp-prev-subject subject)))
3071 gnus-summary-same-subject
3073 (t gnus-summary-same-subject)))
3074 (if (and (eq gnus-summary-make-false-root 'adopt)
3075 (= gnus-tmp-level 1)
3076 (memq number gnus-tmp-gathered))
3077 (setq gnus-tmp-opening-bracket ?\<
3078 gnus-tmp-closing-bracket ?\>)
3079 (setq gnus-tmp-opening-bracket ?\[
3080 gnus-tmp-closing-bracket ?\]))
3082 gnus-tmp-indentation
3083 (aref gnus-thread-indent-array gnus-tmp-level)
3084 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3085 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3086 gnus-summary-default-score 0)
3088 (if (or (null gnus-summary-default-score)
3089 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3090 gnus-summary-zcore-fuzz)) ?
3091 (if (< gnus-tmp-score gnus-summary-default-score)
3092 gnus-score-below-mark gnus-score-over-mark))
3094 (cond ((memq number gnus-newsgroup-processable)
3096 ((memq number gnus-newsgroup-cached)
3098 ((memq number gnus-newsgroup-replied)
3100 ((memq number gnus-newsgroup-saved)
3102 (t gnus-unread-mark))
3103 gnus-tmp-from (mail-header-from gnus-tmp-header)
3106 ((string-match "(.+)" gnus-tmp-from)
3107 (substring gnus-tmp-from
3108 (1+ (match-beginning 0)) (1- (match-end 0))))
3109 ((string-match "<[^>]+> *$" gnus-tmp-from)
3110 (setq beg-match (match-beginning 0))
3111 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3112 (substring gnus-tmp-from (1+ (match-beginning 0))
3113 (1- (match-end 0))))
3114 (substring gnus-tmp-from 0 beg-match)))
3116 (when (string= gnus-tmp-name "")
3117 (setq gnus-tmp-name gnus-tmp-from))
3118 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
3119 (gnus-put-text-property
3121 (progn (eval gnus-summary-line-format-spec) (point))
3122 'gnus-number number)
3125 (run-hooks 'gnus-summary-update-hook)
3128 (setq gnus-tmp-prev-subject subject)))
3130 (when (nth 1 thread)
3131 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3132 (incf gnus-tmp-level)
3133 (setq threads (if thread-end nil (cdar thread)))
3135 (setq gnus-tmp-level 0)))))
3136 (gnus-message 7 "Generating summary...done"))
3138 (defun gnus-summary-prepare-unthreaded (headers)
3139 "Generate an unthreaded summary buffer based on HEADERS."
3140 (let (header number mark)
3143 ;; We may have to root out some bad articles...
3144 (when (memq (setq number (mail-header-number
3145 (setq header (pop headers))))
3146 gnus-newsgroup-limit)
3147 ;; Mark article as read when it has a low score.
3148 (when (and gnus-summary-mark-below
3149 (< (or (cdr (assq number gnus-newsgroup-scored))
3150 gnus-summary-default-score 0)
3151 gnus-summary-mark-below)
3152 (not (memq number gnus-newsgroup-ancient)))
3153 (setq gnus-newsgroup-unreads
3154 (delq number gnus-newsgroup-unreads))
3155 (if gnus-newsgroup-auto-expire
3156 (push number gnus-newsgroup-expirable)
3157 (push (cons number gnus-low-score-mark)
3158 gnus-newsgroup-reads)))
3160 (setq mark (gnus-article-mark number))
3161 (setq gnus-newsgroup-data
3162 (cons (gnus-data-make number mark (1+ (point)) header 0)
3163 gnus-newsgroup-data))
3164 (gnus-summary-insert-line
3165 header 0 nil mark (memq number gnus-newsgroup-replied)
3166 (memq number gnus-newsgroup-expirable)
3167 (mail-header-subject header) nil
3168 (cdr (assq number gnus-newsgroup-scored))
3169 (memq number gnus-newsgroup-processable))))))
3171 (defun gnus-select-newsgroup (group &optional read-all)
3172 "Select newsgroup GROUP.
3173 If READ-ALL is non-nil, all articles in the group are selected."
3174 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3175 (info (nth 2 entry))
3176 articles fetched-articles cached)
3178 (or (gnus-check-server
3179 (setq gnus-current-select-method (gnus-find-method-for-group group)))
3180 (error "Couldn't open server"))
3182 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3183 (gnus-activate-group group) ; Or we can activate it...
3184 (progn ; Or we bug out.
3185 (when (equal major-mode 'gnus-summary-mode)
3186 (kill-buffer (current-buffer)))
3187 (error "Couldn't request group %s: %s"
3188 group (gnus-status-message group))))
3190 (unless (gnus-request-group group t)
3191 (when (equal major-mode 'gnus-summary-mode)
3192 (kill-buffer (current-buffer)))
3193 (error "Couldn't request group %s: %s"
3194 group (gnus-status-message group)))
3196 (setq gnus-newsgroup-name group)
3197 (setq gnus-newsgroup-unselected nil)
3198 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3200 ;; Adjust and set lists of article marks.
3202 (gnus-adjust-marked-articles info))
3204 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3205 (when (gnus-virtual-group-p group)
3206 (setq cached gnus-newsgroup-cached))
3208 (setq gnus-newsgroup-unreads
3209 (gnus-set-difference
3210 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3211 gnus-newsgroup-dormant))
3213 (setq gnus-newsgroup-processable nil)
3215 (setq articles (gnus-articles-to-read group read-all))
3219 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3221 ((eq articles 0) nil)
3223 ;; Init the dependencies hash table.
3224 (setq gnus-newsgroup-dependencies
3225 (gnus-make-hashtable (length articles)))
3226 ;; Retrieve the headers and read them in.
3227 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3228 (setq gnus-newsgroup-headers
3230 (setq gnus-headers-retrieved-by
3231 (gnus-retrieve-headers
3232 articles gnus-newsgroup-name
3233 ;; We might want to fetch old headers, but
3234 ;; not if there is only 1 article.
3235 (and gnus-fetch-old-headers
3237 (not (eq gnus-fetch-old-headers 'some))
3238 (not (numberp gnus-fetch-old-headers)))
3239 (> (length articles) 1))))))
3240 (gnus-get-newsgroup-headers-xover articles)
3241 (gnus-get-newsgroup-headers)))
3242 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3244 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3246 (setq gnus-newsgroup-cached cached))
3248 ;; Suppress duplicates?
3249 (when gnus-suppress-duplicates
3250 (gnus-dup-suppress-articles))
3252 ;; Set the initial limit.
3253 (setq gnus-newsgroup-limit (copy-sequence articles))
3254 ;; Remove canceled articles from the list of unread articles.
3255 (setq gnus-newsgroup-unreads
3256 (gnus-set-sorted-intersection
3257 gnus-newsgroup-unreads
3258 (setq fetched-articles
3259 (mapcar (lambda (headers) (mail-header-number headers))
3260 gnus-newsgroup-headers))))
3261 ;; Removed marked articles that do not exist.
3262 (gnus-update-missing-marks
3263 (gnus-sorted-complement fetched-articles articles))
3264 ;; We might want to build some more threads first.
3265 (and gnus-fetch-old-headers
3266 (eq gnus-headers-retrieved-by 'nov)
3267 (gnus-build-old-threads))
3268 ;; Check whether auto-expire is to be done in this group.
3269 (setq gnus-newsgroup-auto-expire
3270 (gnus-group-auto-expirable-p group))
3271 ;; Set up the article buffer now, if necessary.
3272 (unless gnus-single-article-buffer
3273 (gnus-article-setup-buffer))
3274 ;; First and last article in this newsgroup.
3275 (when gnus-newsgroup-headers
3276 (setq gnus-newsgroup-begin
3277 (mail-header-number (car gnus-newsgroup-headers))
3280 (gnus-last-element gnus-newsgroup-headers))))
3281 ;; GROUP is successfully selected.
3282 (or gnus-newsgroup-headers t)))))
3284 (defun gnus-articles-to-read (group read-all)
3285 ;; Find out what articles the user wants to read.
3287 ;; Select all articles if `read-all' is non-nil, or if there
3288 ;; are no unread articles.
3290 (and (zerop (length gnus-newsgroup-marked))
3291 (zerop (length gnus-newsgroup-unreads))))
3292 (gnus-uncompress-range (gnus-active group))
3293 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3294 (copy-sequence gnus-newsgroup-unreads))
3296 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3297 (scored (length scored-list))
3298 (number (length articles))
3299 (marked (+ (length gnus-newsgroup-marked)
3300 (length gnus-newsgroup-dormant)))
3308 ((and (or (<= scored marked) (= scored number))
3309 (numberp gnus-large-newsgroup)
3310 (> number gnus-large-newsgroup))
3314 "How many articles from %s (default %d): "
3315 gnus-newsgroup-name number))))
3316 (if (string-match "^[ \t]*$" input) number input)))
3317 ((and (> scored marked) (< scored number)
3318 (> (- scored number) 20))
3321 (format "%s %s (%d scored, %d total): "
3322 "How many articles from"
3323 group scored number))))
3324 (if (string-match "^[ \t]*$" input)
3328 (setq select (if (stringp select) (string-to-number select) select))
3329 (if (or (null select) (zerop select))
3331 (if (and (not (zerop scored)) (<= (abs select) scored))
3333 (setq articles (sort scored-list '<))
3334 (setq number (length articles)))
3335 (setq articles (copy-sequence articles)))
3337 (if (< (abs select) number)
3339 ;; Select the N oldest articles.
3340 (setcdr (nthcdr (1- (abs select)) articles) nil)
3341 ;; Select the N most recent articles.
3342 (setq articles (nthcdr (- number select) articles))))
3343 (setq gnus-newsgroup-unselected
3344 (gnus-sorted-intersection
3345 gnus-newsgroup-unreads
3346 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3349 (defun gnus-killed-articles (killed articles)
3352 (if (inline (gnus-member-of-range (car articles) killed))
3353 (setq out (cons (car articles) out)))
3354 (setq articles (cdr articles)))
3357 (defun gnus-uncompress-marks (marks)
3358 "Uncompress the mark ranges in MARKS."
3359 (let ((uncompressed '(score bookmark))
3362 (if (memq (caar marks) uncompressed)
3363 (push (car marks) out)
3364 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3365 (setq marks (cdr marks)))
3368 (defun gnus-adjust-marked-articles (info)
3369 "Set all article lists and remove all marks that are no longer legal."
3370 (let* ((marked-lists (gnus-info-marks info))
3371 (active (gnus-active (gnus-info-group info)))
3374 (types gnus-article-mark-lists)
3375 (uncompressed '(score bookmark killed))
3376 marks var articles article mark)
3379 (setq marks (pop marked-lists))
3380 (set (setq var (intern (format "gnus-newsgroup-%s"
3381 (car (rassq (setq mark (car marks))
3383 (if (memq (car marks) uncompressed) (cdr marks)
3384 (gnus-uncompress-range (cdr marks))))
3386 (setq articles (symbol-value var))
3388 ;; All articles have to be subsets of the active articles.
3390 ;; Adjust "simple" lists.
3391 ((memq mark '(tick dormant expirable reply save))
3393 (when (or (< (setq article (pop articles)) min) (> article max))
3394 (set var (delq article (symbol-value var))))))
3396 ((memq mark uncompressed)
3398 (when (or (not (consp (setq article (pop articles))))
3399 (< (car article) min)
3400 (> (car article) max))
3401 (set var (delq article (symbol-value var))))))))))
3403 (defun gnus-update-missing-marks (missing)
3404 "Go through the list of MISSING articles and remove them mark lists."
3406 (let ((types gnus-article-mark-lists)
3408 ;; Go through all types.
3410 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3411 (when (symbol-value var)
3412 ;; This list has articles. So we delete all missing articles
3416 (set var (delq (pop m) (symbol-value var)))))))))
3418 (defun gnus-update-marks ()
3419 "Enter the various lists of marked articles into the newsgroup info list."
3420 (let ((types gnus-article-mark-lists)
3421 (info (gnus-get-info gnus-newsgroup-name))
3422 (uncompressed '(score bookmark killed))
3423 type list newmarked symbol)
3425 ;; Add all marks lists that are non-nil to the list of marks lists.
3427 (setq type (pop types))
3428 (when (setq list (symbol-value
3430 (intern (format "gnus-newsgroup-%s"
3432 (push (cons (cdr type)
3433 (if (memq (cdr type) uncompressed) list
3434 (gnus-compress-sequence
3435 (set symbol (sort list '<)) t)))
3438 ;; Enter these new marks into the info of the group.
3440 (setcar (nthcdr 3 info) newmarked)
3441 ;; Add the marks lists to the end of the info.
3443 (setcdr (nthcdr 2 info) (list newmarked))))
3445 ;; Cut off the end of the info if there's nothing else there.
3449 (when (nthcdr (decf i) info)
3450 (setcdr (nthcdr i info) nil)))))))
3452 (defun gnus-set-mode-line (where)
3453 "This function sets the mode line of the article or summary buffers.
3454 If WHERE is `summary', the summary mode line format will be used."
3455 ;; Is this mode line one we keep updated?
3456 (when (memq where gnus-updated-mode-lines)
3459 ;; We evaluate this in the summary buffer since these
3460 ;; variables are buffer-local to that buffer.
3461 (set-buffer gnus-summary-buffer)
3462 ;; We bind all these variables that are used in the `eval' form
3464 (let* ((mformat (symbol-value
3466 (format "gnus-%s-mode-line-format-spec" where))))
3467 (gnus-tmp-group-name gnus-newsgroup-name)
3468 (gnus-tmp-article-number (or gnus-current-article 0))
3469 (gnus-tmp-unread gnus-newsgroup-unreads)
3470 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3471 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3472 (gnus-tmp-unread-and-unselected
3473 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3474 (zerop gnus-tmp-unselected)) "")
3475 ((zerop gnus-tmp-unselected)
3476 (format "{%d more}" gnus-tmp-unread-and-unticked))
3477 (t (format "{%d(+%d) more}"
3478 gnus-tmp-unread-and-unticked
3479 gnus-tmp-unselected))))
3481 (if (and gnus-current-headers
3482 (vectorp gnus-current-headers))
3483 (gnus-mode-string-quote
3484 (mail-header-subject gnus-current-headers)) ""))
3486 gnus-tmp-header);; passed as argument to any user-format-funcs
3487 (setq mode-string (eval mformat))
3488 (setq max-len (max 4 (if gnus-mode-non-string-length
3490 gnus-mode-non-string-length)
3491 (length mode-string))))
3492 ;; We might have to chop a bit of the string off...
3493 (when (> (length mode-string) max-len)
3495 (concat (gnus-truncate-string mode-string (- max-len 3))
3497 ;; Pad the mode string a bit.
3498 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3499 ;; Update the mode line.
3500 (setq mode-line-buffer-identification
3501 (gnus-mode-line-buffer-identification
3502 (list mode-string)))
3503 (set-buffer-modified-p t))))
3505 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3506 "Go through the HEADERS list and add all Xrefs to a hash table.
3507 The resulting hash table is returned, or nil if no Xrefs were found."
3508 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3509 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3510 (xref-hashtb (make-vector 63 0))
3511 start group entry number xrefs header)
3513 (setq header (pop headers))
3514 (when (and (setq xrefs (mail-header-xref header))
3515 (not (memq (setq number (mail-header-number header))
3518 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3519 (setq start (match-end 0))
3520 (setq group (if prefix
3521 (concat prefix (substring xrefs (match-beginning 1)
3523 (substring xrefs (match-beginning 1) (match-end 1))))
3525 (string-to-int (substring xrefs (match-beginning 2)
3527 (if (setq entry (gnus-gethash group xref-hashtb))
3528 (setcdr entry (cons number (cdr entry)))
3529 (gnus-sethash group (cons number nil) xref-hashtb)))))
3530 (and start xref-hashtb)))
3532 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3533 "Look through all the headers and mark the Xrefs as read."
3534 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3535 name entry info xref-hashtb idlist method nth4)
3537 (set-buffer gnus-group-buffer)
3538 (when (setq xref-hashtb
3539 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3542 (unless (string= from-newsgroup (setq name (symbol-name group)))
3543 (setq idlist (symbol-value group))
3544 ;; Dead groups are not updated.
3546 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3548 (if (stringp (setq nth4 (gnus-info-method info)))
3549 (setq nth4 (gnus-server-to-method nth4))))
3550 ;; Only do the xrefs if the group has the same
3551 ;; select method as the group we have just read.
3552 (or (gnus-methods-equal-p
3553 nth4 (gnus-find-method-for-group from-newsgroup))
3555 (equal nth4 (setq method (gnus-find-method-for-group
3557 (and (equal (car nth4) (car method))
3558 (equal (nth 1 nth4) (nth 1 method))))
3559 gnus-use-cross-reference
3560 (or (not (eq gnus-use-cross-reference t))
3562 ;; Only do cross-references on subscribed
3563 ;; groups, if that is what is wanted.
3564 (<= (gnus-info-level info) gnus-level-subscribed))
3565 (gnus-group-make-articles-read name idlist))))
3568 (defun gnus-group-make-articles-read (group articles)
3569 "Update the info of GROUP to say that only ARTICLES are unread."
3571 (entry (gnus-gethash group gnus-newsrc-hashtb))
3572 (info (nth 2 entry))
3573 (active (gnus-active group))
3575 ;; First peel off all illegal article numbers.
3577 (let ((ids articles)
3579 (while (setq id (pop ids))
3580 (when (and first (> id (cdr active)))
3581 ;; We'll end up in this situation in one particular
3582 ;; obscure situation. If you re-scan a group and get
3583 ;; a new article that is cross-posted to a different
3584 ;; group that has not been re-scanned, you might get
3585 ;; crossposted article that has a higher number than
3586 ;; Gnus believes possible. So we re-activate this
3587 ;; group as well. This might mean doing the
3588 ;; crossposting thingy will *increase* the number
3589 ;; of articles in some groups. Tsk, tsk.
3590 (setq active (or (gnus-activate-group group) active)))
3591 (when (or (> id (cdr active))
3592 (< id (car active)))
3593 (setq articles (delq id articles))))))
3596 (gnus-info-set-marks ,info ,(gnus-info-marks info))
3597 (gnus-info-set-read ,info ,(gnus-info-read info))
3598 (gnus-group-update-group group t)))
3599 ;; If the read list is nil, we init it.
3601 (null (gnus-info-read info))
3603 (gnus-info-set-read info (cons 1 (1- (car active)))))
3604 ;; Then we add the read articles to the range.
3609 (gnus-info-read info) (setq articles (sort articles '<)))))
3610 ;; Then we have to re-compute how many unread
3611 ;; articles there are in this group.
3615 (setq num (- (1+ (cdr active)) (car active))))
3616 ((not (listp (cdr range)))
3617 (setq num (- (cdr active) (- (1+ (cdr range))
3621 (if (numberp (car range))
3623 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
3624 (setq range (cdr range)))
3625 (setq num (- (cdr active) num))))
3626 ;; Update the number of unread articles.
3628 ;; Update the group buffer.
3629 (gnus-group-update-group group t))))
3631 (defun gnus-methods-equal-p (m1 m2)
3632 (let ((m1 (or m1 gnus-select-method))
3633 (m2 (or m2 gnus-select-method)))
3635 (and (eq (car m1) (car m2))
3636 (or (not (memq 'address (assoc (symbol-name (car m1))
3637 gnus-valid-select-methods)))
3638 (equal (nth 1 m1) (nth 1 m2)))))))
3640 (defsubst gnus-header-value ()
3641 (buffer-substring (match-end 0) (gnus-point-at-eol)))
3643 (defvar gnus-newsgroup-none-id 0)
3645 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
3646 (let ((cur nntp-server-buffer)
3649 (save-excursion (set-buffer gnus-summary-buffer)
3650 gnus-newsgroup-dependencies)))
3651 headers id id-dep ref-dep end ref)
3653 (set-buffer nntp-server-buffer)
3654 (run-hooks 'gnus-parse-headers-hook)
3655 (let ((case-fold-search t)
3656 in-reply-to header p lines)
3657 (goto-char (point-min))
3658 ;; Search to the beginning of the next header. Error messages
3659 ;; do not begin with 2 or 3.
3660 (while (re-search-forward "^[23][0-9]+ " nil t)
3663 ;; This implementation of this function, with nine
3664 ;; search-forwards instead of the one re-search-forward and
3665 ;; a case (which basically was the old function) is actually
3666 ;; about twice as fast, even though it looks messier. You
3667 ;; can't have everything, I guess. Speed and elegance
3668 ;; doesn't always go hand in hand.
3677 (narrow-to-region (point)
3678 (or (and (search-forward "\n.\n" nil t)
3684 (if (search-forward "\nsubject: " nil t)
3685 (gnus-header-value) "(none)"))
3689 (if (search-forward "\nfrom: " nil t)
3690 (gnus-header-value) "(nobody)"))
3694 (if (search-forward "\ndate: " nil t)
3695 (gnus-header-value) ""))
3699 (if (search-forward "\nmessage-id: " nil t)
3700 (setq id (gnus-header-value))
3701 ;; If there was no message-id, we just fake one to make
3702 ;; subsequent routines simpler.
3703 (setq id (concat "none+"
3705 (setq gnus-newsgroup-none-id
3706 (1+ gnus-newsgroup-none-id)))))))
3710 (if (search-forward "\nreferences: " nil t)
3719 (search-backward ">" end t)
3722 (search-backward "<" end t)
3724 ;; Get the references from the in-reply-to header if there
3725 ;; were no references and the in-reply-to header looks
3727 (if (and (search-forward "\nin-reply-to: " nil t)
3728 (setq in-reply-to (gnus-header-value))
3729 (string-match "<[^>]+>" in-reply-to))
3730 (setq ref (substring in-reply-to (match-beginning 0)
3738 (if (search-forward "\nlines: " nil t)
3739 (if (numberp (setq lines (read cur)))
3745 (and (search-forward "\nxref: " nil t)
3746 (gnus-header-value)))))
3747 ;; We do the threading while we read the headers. The
3748 ;; message-id and the last reference are both entered into
3749 ;; the same hash table. Some tippy-toeing around has to be
3750 ;; done in case an article has arrived before the article
3751 ;; which it refers to.
3752 (if (boundp (setq id-dep (intern id dependencies)))
3753 (if (and (car (symbol-value id-dep))
3755 ;; An article with this Message-ID has already
3756 ;; been seen, so we ignore this one, except we add
3757 ;; any additional Xrefs (in case the two articles
3758 ;; came from different servers).
3760 (mail-header-set-xref
3761 (car (symbol-value id-dep))
3762 (concat (or (mail-header-xref
3763 (car (symbol-value id-dep))) "")
3764 (or (mail-header-xref header) "")))
3766 (setcar (symbol-value id-dep) header))
3767 (set id-dep (list header)))
3769 (if (boundp (setq ref-dep (intern ref dependencies)))
3770 (setcdr (symbol-value ref-dep)
3771 (nconc (cdr (symbol-value ref-dep))
3772 (list (symbol-value id-dep))))
3773 (set ref-dep (list nil (symbol-value id-dep))))
3774 (setq headers (cons header headers)))
3775 (goto-char (point-max))
3777 (nreverse headers)))))
3779 ;; The following macros and functions were written by Felix Lee
3780 ;; <flee@cse.psu.edu>.
3782 (defmacro gnus-nov-read-integer ()
3784 (if (= (following-char) ?\t)
3786 (let ((num (condition-case nil (read buffer) (error nil))))
3787 (if (numberp num) num 0)))
3788 (or (eobp) (forward-char 1))))
3790 (defmacro gnus-nov-skip-field ()
3791 '(search-forward "\t" eol 'move))
3793 (defmacro gnus-nov-field ()
3794 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3796 ;; Goes through the xover lines and returns a list of vectors
3797 (defun gnus-get-newsgroup-headers-xover (sequence &optional
3798 force-new dependencies)
3799 "Parse the news overview data in the server buffer, and return a
3800 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
3801 ;; Get the Xref when the users reads the articles since most/some
3802 ;; NNTP servers do not include Xrefs when using XOVER.
3803 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
3804 (let ((cur nntp-server-buffer)
3805 (dependencies (or dependencies gnus-newsgroup-dependencies))
3806 number headers header)
3808 (set-buffer nntp-server-buffer)
3809 ;; Allow the user to mangle the headers before parsing them.
3810 (run-hooks 'gnus-parse-headers-hook)
3811 (goto-char (point-min))
3812 (while (and sequence (not (eobp)))
3813 (setq number (read cur))
3814 (while (and sequence (< (car sequence) number))
3815 (setq sequence (cdr sequence)))
3817 (eq number (car sequence))
3819 (setq sequence (cdr sequence))
3821 (inline (gnus-nov-parse-line
3822 number dependencies force-new)))
3823 (setq headers (cons header headers)))))
3825 (setq headers (nreverse headers)))
3828 ;; This function has to be called with point after the article number
3829 ;; on the beginning of the line.
3830 (defun gnus-nov-parse-line (number dependencies &optional force-new)
3832 (eol (gnus-point-at-eol))
3833 (buffer (current-buffer))
3834 header ref id id-dep ref-dep)
3836 ;; overview: [num subject from date id refs chars lines misc]
3837 (narrow-to-region (point) eol)
3838 (or (eobp) (forward-char))
3844 (gnus-nov-field) ; subject
3845 (gnus-nov-field) ; from
3846 (gnus-nov-field) ; date
3847 (setq id (or (gnus-nov-field)
3850 (setq none (1+ none)))))) ; id
3853 (let ((beg (point)))
3854 (search-forward "\t" eol)
3855 (if (search-backward ">" beg t)
3859 (search-backward "<" beg t)))
3861 (gnus-nov-field)) ; refs
3862 (gnus-nov-read-integer) ; chars
3863 (gnus-nov-read-integer) ; lines
3864 (if (= (following-char) ?\n)
3866 (gnus-nov-field)) ; misc
3869 (gnus-error 4 "Strange nov line")
3875 ;; We build the thread tree.
3877 (if (boundp (setq id-dep (intern id dependencies)))
3878 (if (and (car (symbol-value id-dep))
3880 ;; An article with this Message-ID has already been seen,
3881 ;; so we ignore this one, except we add any additional
3882 ;; Xrefs (in case the two articles came from different
3885 (mail-header-set-xref
3886 (car (symbol-value id-dep))
3887 (concat (or (mail-header-xref
3888 (car (symbol-value id-dep))) "")
3889 (or (mail-header-xref header) "")))
3891 (setcar (symbol-value id-dep) header))
3892 (set id-dep (list header))))
3894 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
3895 (setcdr (symbol-value ref-dep)
3896 (nconc (cdr (symbol-value ref-dep))
3897 (list (symbol-value id-dep))))
3898 (set ref-dep (list nil (symbol-value id-dep)))))
3901 (defun gnus-article-get-xrefs ()
3902 "Fill in the Xref value in `gnus-current-headers', if necessary.
3903 This is meant to be called in `gnus-article-internal-prepare-hook'."
3904 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
3905 gnus-current-headers)))
3906 (or (not gnus-use-cross-reference)
3908 (and (mail-header-xref headers)
3909 (not (string= (mail-header-xref headers) "")))
3910 (let ((case-fold-search t)
3913 (nnheader-narrow-to-headers)
3914 (goto-char (point-min))
3915 (if (or (and (eq (downcase (following-char)) ?x)
3916 (looking-at "Xref:"))
3917 (search-forward "\nXref:" nil t))
3919 (goto-char (1+ (match-end 0)))
3920 (setq xref (buffer-substring (point)
3921 (progn (end-of-line) (point))))
3922 (mail-header-set-xref headers xref))))))))
3924 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
3925 "Find article ID and insert the summary line for that article."
3926 (let ((header (if (and old-header use-old-header)
3927 old-header (gnus-read-header id)))
3928 (number (and (numberp id) id))
3931 ;; Rebuild the thread that this article is part of and go to the
3932 ;; article we have fetched.
3933 (when (and (not gnus-show-threads)
3935 (when (setq pos (text-property-any
3936 (point-min) (point-max) 'gnus-number
3937 (mail-header-number old-header)))
3940 (gnus-data-remove (mail-header-number old-header))))
3942 (mail-header-set-number header (mail-header-number old-header)))
3943 (setq gnus-newsgroup-sparse
3944 (delq (setq number (mail-header-number header))
3945 gnus-newsgroup-sparse))
3946 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
3947 (gnus-rebuild-thread (mail-header-id header))
3948 (gnus-summary-goto-subject number nil t))
3949 (when (and (numberp number)
3951 ;; We have to update the boundaries even if we can't fetch the
3952 ;; article if ID is a number -- so that the next `P' or `N'
3953 ;; command will fetch the previous (or next) article even
3954 ;; if the one we tried to fetch this time has been canceled.
3955 (and (> number gnus-newsgroup-end)
3956 (setq gnus-newsgroup-end number))
3957 (and (< number gnus-newsgroup-begin)
3958 (setq gnus-newsgroup-begin number))
3959 (setq gnus-newsgroup-unselected
3960 (delq number gnus-newsgroup-unselected)))
3961 ;; Report back a success?
3962 (and header (mail-header-number header))))
3964 ;;; Process/prefix in the summary buffer
3966 (defun gnus-summary-work-articles (n)
3967 "Return a list of articles to be worked upon. The prefix argument,
3968 the list of process marked articles, and the current article will be
3969 taken into consideration."
3972 ;; A numerical prefix has been given.
3973 (let ((backward (< n 0))
3974 (n (abs (prefix-numeric-value n)))
3979 (push (setq article (gnus-summary-article-number))
3982 (gnus-summary-find-prev nil article)
3983 (gnus-summary-find-next nil article)))
3985 (nreverse articles)))
3986 ((and (boundp 'transient-mark-mode)
3989 ;; Work on the region between point and mark.
3990 (let ((max (max (point) (mark)))
3993 (goto-char (min (point) (mark)))
3996 (push (setq article (gnus-summary-article-number)) articles)
3997 (gnus-summary-find-next nil article)
3999 (nreverse articles))))
4000 (gnus-newsgroup-processable
4001 ;; There are process-marked articles present.
4002 ;; Save current state.
4003 (gnus-summary-save-process-mark)
4005 (reverse gnus-newsgroup-processable))
4007 ;; Just return the current article.
4008 (list (gnus-summary-article-number)))))
4010 (defun gnus-summary-save-process-mark ()
4011 "Push the current set of process marked articles on the stack."
4013 (push (copy-sequence gnus-newsgroup-processable)
4014 gnus-newsgroup-process-stack))
4016 (defun gnus-summary-kill-process-mark ()
4017 "Push the current set of process marked articles on the stack and unmark."
4019 (gnus-summary-save-process-mark)
4020 (gnus-summary-unmark-all-processable))
4022 (defun gnus-summary-yank-process-mark ()
4023 "Pop the last process mark state off the stack and restore it."
4025 (unless gnus-newsgroup-process-stack
4026 (error "Empty mark stack"))
4027 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4029 (defun gnus-summary-process-mark-set (set)
4030 "Make SET into the current process marked articles."
4031 (gnus-summary-unmark-all-processable)
4033 (gnus-summary-set-process-mark (pop set))))
4035 ;;; Searching and stuff
4037 (defun gnus-summary-search-group (&optional backward use-level)
4038 "Search for next unread newsgroup.
4039 If optional argument BACKWARD is non-nil, search backward instead."
4041 (set-buffer gnus-group-buffer)
4042 (if (gnus-group-search-forward
4043 backward nil (if use-level (gnus-group-group-level) nil))
4044 (gnus-group-group-name))))
4046 (defun gnus-summary-best-group (&optional exclude-group)
4047 "Find the name of the best unread group.
4048 If EXCLUDE-GROUP, do not go to this group."
4050 (set-buffer gnus-group-buffer)
4052 (gnus-group-best-unread-group exclude-group))))
4054 (defun gnus-summary-find-next (&optional unread article backward)
4055 (if backward (gnus-summary-find-prev)
4056 (let* ((dummy (gnus-summary-article-intangible-p))
4057 (article (or article (gnus-summary-article-number)))
4058 (arts (gnus-data-find-list article))
4060 (when (and (not dummy)
4061 (or (not gnus-summary-check-current)
4063 (not (gnus-data-unread-p (car arts)))))
4064 (setq arts (cdr arts)))
4069 (when (gnus-data-unread-p (car arts))
4070 (setq result (car arts)
4072 (setq arts (cdr arts)))
4075 (goto-char (gnus-data-pos result))
4076 (gnus-data-number result)))))
4078 (defun gnus-summary-find-prev (&optional unread article)
4079 (let* ((eobp (eobp))
4080 (article (or article (gnus-summary-article-number)))
4081 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4083 (when (and (not eobp)
4084 (or (not gnus-summary-check-current)
4086 (not (gnus-data-unread-p (car arts)))))
4087 (setq arts (cdr arts)))
4092 (and (gnus-data-unread-p (car arts))
4093 (setq result (car arts)
4095 (setq arts (cdr arts)))
4099 (goto-char (gnus-data-pos result))
4100 (gnus-data-number result)))))
4102 (defun gnus-summary-find-subject (subject &optional unread backward article)
4103 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4104 (article (or article (gnus-summary-article-number)))
4105 (articles (gnus-data-list backward))
4106 (arts (gnus-data-find-list article articles))
4108 (when (or (not gnus-summary-check-current)
4110 (not (gnus-data-unread-p (car arts))))
4111 (setq arts (cdr arts)))
4113 (and (or (not unread)
4114 (gnus-data-unread-p (car arts)))
4115 (vectorp (gnus-data-header (car arts)))
4117 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4118 (setq result (car arts)
4120 (setq arts (cdr arts)))
4122 (goto-char (gnus-data-pos result))
4123 (gnus-data-number result))))
4125 (defun gnus-summary-search-forward (&optional unread subject backward)
4126 "Search forward for an article.
4127 If UNREAD, look for unread articles. If SUBJECT, look for
4128 articles with that subject. If BACKWARD, search backward instead."
4129 (cond (subject (gnus-summary-find-subject subject unread backward))
4130 (backward (gnus-summary-find-prev unread))
4131 (t (gnus-summary-find-next unread))))
4133 (defun gnus-recenter (&optional n)
4134 "Center point in window and redisplay frame.
4135 Also do horizontal recentering."
4137 (when (and gnus-auto-center-summary
4138 (not (eq gnus-auto-center-summary 'vertical)))
4139 (gnus-horizontal-recenter))
4142 (defun gnus-summary-recenter ()
4143 "Center point in the summary window.
4144 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4145 displayed, no centering will be performed."
4146 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4147 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4148 (let* ((top (cond ((< (window-height) 4) 0)
4149 ((< (window-height) 7) 1)
4151 (height (1- (window-height)))
4152 (bottom (save-excursion (goto-char (point-max))
4153 (forward-line (- height))
4155 (window (get-buffer-window (current-buffer))))
4156 ;; The user has to want it.
4157 (when gnus-auto-center-summary
4158 (when (get-buffer-window gnus-article-buffer)
4159 ;; Only do recentering when the article buffer is displayed,
4160 ;; Set the window start to either `bottom', which is the biggest
4161 ;; possible valid number, or the second line from the top,
4162 ;; whichever is the least.
4164 window (min bottom (save-excursion
4165 (forward-line (- top)) (point)))))
4166 ;; Do horizontal recentering while we're at it.
4167 (when (and (get-buffer-window (current-buffer) t)
4168 (not (eq gnus-auto-center-summary 'vertical)))
4169 (let ((selected (selected-window)))
4170 (select-window (get-buffer-window (current-buffer) t))
4171 (gnus-summary-position-point)
4172 (gnus-horizontal-recenter)
4173 (select-window selected))))))
4175 (defun gnus-summary-jump-to-group (newsgroup)
4176 "Move point to NEWSGROUP in group mode buffer."
4177 ;; Keep update point of group mode buffer if visible.
4178 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4179 (save-window-excursion
4180 ;; Take care of tree window mode.
4181 (if (get-buffer-window gnus-group-buffer)
4182 (pop-to-buffer gnus-group-buffer))
4183 (gnus-group-jump-to-group newsgroup))
4185 ;; Take care of tree window mode.
4186 (if (get-buffer-window gnus-group-buffer)
4187 (pop-to-buffer gnus-group-buffer)
4188 (set-buffer gnus-group-buffer))
4189 (gnus-group-jump-to-group newsgroup))))
4191 ;; This function returns a list of article numbers based on the
4192 ;; difference between the ranges of read articles in this group and
4193 ;; the range of active articles.
4194 (defun gnus-list-of-unread-articles (group)
4195 (let* ((read (gnus-info-read (gnus-get-info group)))
4196 (active (gnus-active group))
4199 ;; If none are read, then all are unread.
4201 (setq first (car active))
4202 ;; If the range of read articles is a single range, then the
4203 ;; first unread article is the article after the last read
4204 ;; article. Sounds logical, doesn't it?
4205 (if (not (listp (cdr read)))
4206 (setq first (1+ (cdr read)))
4207 ;; `read' is a list of ranges.
4208 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
4213 (while (< first nlast)
4214 (setq unread (cons first unread))
4215 (setq first (1+ first))))
4216 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4217 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4218 (setq read (cdr read)))))
4219 ;; And add the last unread articles.
4220 (while (<= first last)
4221 (setq unread (cons first unread))
4222 (setq first (1+ first)))
4223 ;; Return the list of unread articles.
4226 (defun gnus-list-of-read-articles (group)
4227 "Return a list of unread, unticked and non-dormant articles."
4228 (let* ((info (gnus-get-info group))
4229 (marked (gnus-info-marks info))
4230 (active (gnus-active group)))
4232 (gnus-set-difference
4233 (gnus-sorted-complement
4234 (gnus-uncompress-range active)
4235 (gnus-list-of-unread-articles group))
4237 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4238 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4240 ;; Various summary commands
4242 (defun gnus-summary-universal-argument (arg)
4243 "Perform any operation on all articles that are process/prefixed."
4245 (gnus-set-global-variables)
4246 (let ((articles (gnus-summary-work-articles arg))
4253 (substitute-command-keys
4254 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4257 (gnus-error 1 "Undefined key")
4260 (gnus-summary-goto-subject (setq article (pop articles)))
4261 (command-execute func)
4262 (gnus-summary-remove-process-mark article)))))
4263 (gnus-summary-position-point))
4265 (defun gnus-summary-toggle-truncation (&optional arg)
4266 "Toggle truncation of summary lines.
4267 With arg, turn line truncation on iff arg is positive."
4269 (setq truncate-lines
4270 (if (null arg) (not truncate-lines)
4271 (> (prefix-numeric-value arg) 0)))
4274 (defun gnus-summary-reselect-current-group (&optional all rescan)
4275 "Exit and then reselect the current newsgroup.
4276 The prefix argument ALL means to select all articles."
4278 (gnus-set-global-variables)
4279 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4280 (error "Ephemeral groups can't be reselected"))
4281 (let ((current-subject (gnus-summary-article-number))
4282 (group gnus-newsgroup-name))
4283 (setq gnus-newsgroup-begin nil)
4285 ;; We have to adjust the point of group mode buffer because the
4286 ;; current point was moved to the next unread newsgroup by
4288 (gnus-summary-jump-to-group group)
4291 (gnus-group-get-new-news-this-group 1)))
4292 (gnus-group-read-group all t)
4293 (gnus-summary-goto-subject current-subject nil t)))
4295 (defun gnus-summary-rescan-group (&optional all)
4296 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4298 (gnus-summary-reselect-current-group all t))
4300 (defun gnus-summary-update-info ()
4301 (let ((group gnus-newsgroup-name))
4302 (when gnus-newsgroup-kill-headers
4303 (setq gnus-newsgroup-killed
4304 (gnus-compress-sequence
4306 (gnus-set-sorted-intersection
4307 (gnus-uncompress-range gnus-newsgroup-killed)
4308 (setq gnus-newsgroup-unselected
4309 (sort gnus-newsgroup-unselected '<)))
4310 (setq gnus-newsgroup-unreads
4311 (sort gnus-newsgroup-unreads '<))) t)))
4312 (unless (listp (cdr gnus-newsgroup-killed))
4313 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4314 (let ((headers gnus-newsgroup-headers))
4315 (run-hooks 'gnus-exit-group-hook)
4316 (unless gnus-save-score
4317 (setq gnus-newsgroup-scored nil))
4318 ;; Set the new ranges of read articles.
4319 (gnus-update-read-articles
4320 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4321 ;; Set the current article marks.
4323 ;; Do the cross-ref thing.
4324 (when gnus-use-cross-reference
4325 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4326 ;; Do adaptive scoring, and possibly save score files.
4327 (when gnus-newsgroup-adaptive
4328 (gnus-score-adaptive))
4329 (when gnus-use-scoring
4331 ;; Do not switch windows but change the buffer to work.
4332 (set-buffer gnus-group-buffer)
4333 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4334 (gnus-group-update-group group)))))
4336 (defun gnus-summary-exit (&optional temporary)
4337 "Exit reading current newsgroup, and then return to group selection mode.
4338 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4340 (gnus-set-global-variables)
4341 (gnus-kill-save-kill-buffer)
4342 (let* ((group gnus-newsgroup-name)
4343 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4345 (buf (current-buffer)))
4346 (run-hooks 'gnus-summary-prepare-exit-hook)
4347 ;; If we have several article buffers, we kill them at exit.
4348 (unless gnus-single-article-buffer
4349 (gnus-kill-buffer gnus-original-article-buffer)
4350 (setq gnus-article-current nil))
4351 (when gnus-use-cache
4352 (gnus-cache-possibly-remove-articles)
4353 (gnus-cache-save-buffers))
4354 (gnus-async-prefetch-remove-group group)
4355 (when gnus-suppress-duplicates
4356 (gnus-dup-enter-articles))
4357 (when gnus-use-trees
4358 (gnus-tree-close group))
4359 ;; Make all changes in this group permanent.
4361 (gnus-summary-update-info))
4362 (gnus-close-group group)
4363 ;; Make sure where I was, and go to next newsgroup.
4364 (set-buffer gnus-group-buffer)
4366 (gnus-group-jump-to-group group))
4367 (run-hooks 'gnus-summary-exit-hook)
4369 (gnus-group-next-unread-group 1))
4372 ;; If we have several article buffers, we kill them at exit.
4373 (unless gnus-single-article-buffer
4374 (gnus-kill-buffer gnus-article-buffer)
4375 (gnus-kill-buffer gnus-original-article-buffer)
4376 (setq gnus-article-current nil))
4378 (if (not gnus-kill-summary-on-exit)
4379 (gnus-deaden-summary)
4380 ;; We set all buffer-local variables to nil. It is unclear why
4381 ;; this is needed, but if we don't, buffer-local variables are
4382 ;; not garbage-collected, it seems. This would the lead to en
4383 ;; ever-growing Emacs.
4384 (gnus-summary-clear-local-variables)
4385 (when (get-buffer gnus-article-buffer)
4386 (bury-buffer gnus-article-buffer))
4387 ;; We clear the global counterparts of the buffer-local
4388 ;; variables as well, just to be on the safe side.
4389 (gnus-configure-windows 'group 'force)
4390 (gnus-summary-clear-local-variables)
4391 ;; Return to group mode buffer.
4392 (if (eq mode 'gnus-summary-mode)
4393 (gnus-kill-buffer buf)))
4394 (setq gnus-current-select-method gnus-select-method)
4395 (pop-to-buffer gnus-group-buffer)
4396 ;; Clear the current group name.
4397 (if (not quit-config)
4399 (gnus-group-jump-to-group group)
4400 (gnus-group-next-unread-group 1)
4401 (gnus-configure-windows 'group 'force))
4402 (if (not (buffer-name (car quit-config)))
4403 (gnus-configure-windows 'group 'force)
4404 (set-buffer (car quit-config))
4405 (and (eq major-mode 'gnus-summary-mode)
4406 (gnus-set-global-variables))
4407 (gnus-configure-windows (cdr quit-config))))
4409 (setq gnus-newsgroup-name nil)))))
4411 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4412 (defun gnus-summary-exit-no-update (&optional no-questions)
4413 "Quit reading current newsgroup without updating read article info."
4415 (gnus-set-global-variables)
4416 (let* ((group gnus-newsgroup-name)
4417 (quit-config (gnus-group-quit-config group)))
4418 (when (or no-questions
4420 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
4421 ;; If we have several article buffers, we kill them at exit.
4422 (unless gnus-single-article-buffer
4423 (gnus-kill-buffer gnus-article-buffer)
4424 (gnus-kill-buffer gnus-original-article-buffer)
4425 (setq gnus-article-current nil))
4426 (if (not gnus-kill-summary-on-exit)
4427 (gnus-deaden-summary)
4428 (gnus-close-group group)
4429 (gnus-summary-clear-local-variables)
4430 (set-buffer gnus-group-buffer)
4431 (gnus-summary-clear-local-variables)
4432 (when (get-buffer gnus-summary-buffer)
4433 (kill-buffer gnus-summary-buffer)))
4434 (unless gnus-single-article-buffer
4435 (setq gnus-article-current nil))
4436 (when gnus-use-trees
4437 (gnus-tree-close group))
4438 (gnus-async-prefetch-remove-group group)
4439 (when (get-buffer gnus-article-buffer)
4440 (bury-buffer gnus-article-buffer))
4441 ;; Return to the group buffer.
4442 (gnus-configure-windows 'group 'force)
4443 ;; Clear the current group name.
4444 (setq gnus-newsgroup-name nil)
4445 (when (equal (gnus-group-group-name) group)
4446 (gnus-group-next-unread-group 1))
4448 (if (not (buffer-name (car quit-config)))
4449 (gnus-configure-windows 'group 'force)
4450 (set-buffer (car quit-config))
4451 (when (eq major-mode 'gnus-summary-mode)
4452 (gnus-set-global-variables))
4453 (gnus-configure-windows (cdr quit-config)))))))
4457 (defvar gnus-dead-summary-mode-map nil)
4459 (if gnus-dead-summary-mode-map
4461 (setq gnus-dead-summary-mode-map (make-keymap))
4462 (suppress-keymap gnus-dead-summary-mode-map)
4463 (substitute-key-definition
4464 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4465 (let ((keys '("\C-d" "\r" "\177")))
4467 (define-key gnus-dead-summary-mode-map
4468 (pop keys) 'gnus-summary-wake-up-the-dead))))
4470 (defvar gnus-dead-summary-mode nil
4471 "Minor mode for Gnus summary buffers.")
4473 (defun gnus-dead-summary-mode (&optional arg)
4474 "Minor mode for Gnus summary buffers."
4476 (when (eq major-mode 'gnus-summary-mode)
4477 (make-local-variable 'gnus-dead-summary-mode)
4478 (setq gnus-dead-summary-mode
4479 (if (null arg) (not gnus-dead-summary-mode)
4480 (> (prefix-numeric-value arg) 0)))
4481 (when gnus-dead-summary-mode
4482 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4483 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4484 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4485 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4486 minor-mode-map-alist)))))
4488 (defun gnus-deaden-summary ()
4489 "Make the current summary buffer into a dead summary buffer."
4490 ;; Kill any previous dead summary buffer.
4491 (when (and gnus-dead-summary
4492 (buffer-name gnus-dead-summary))
4494 (set-buffer gnus-dead-summary)
4495 (when gnus-dead-summary-mode
4496 (kill-buffer (current-buffer)))))
4497 ;; Make this the current dead summary.
4498 (setq gnus-dead-summary (current-buffer))
4499 (gnus-dead-summary-mode 1)
4500 (let ((name (buffer-name)))
4501 (when (string-match "Summary" name)
4503 (concat (substring name 0 (match-beginning 0)) "Dead "
4504 (substring name (match-beginning 0))) t))))
4506 (defun gnus-kill-or-deaden-summary (buffer)
4507 "Kill or deaden the summary BUFFER."
4508 (when (and (buffer-name buffer)
4509 (not gnus-single-article-buffer))
4512 (gnus-kill-buffer gnus-article-buffer)
4513 (gnus-kill-buffer gnus-original-article-buffer)))
4514 (cond (gnus-kill-summary-on-exit
4515 (when (and gnus-use-trees
4516 (and (get-buffer buffer)
4517 (buffer-name (get-buffer buffer))))
4519 (set-buffer (get-buffer buffer))
4520 (gnus-tree-close gnus-newsgroup-name)))
4521 (gnus-kill-buffer buffer))
4522 ((and (get-buffer buffer)
4523 (buffer-name (get-buffer buffer)))
4526 (gnus-deaden-summary)))))
4528 (defun gnus-summary-wake-up-the-dead (&rest args)
4529 "Wake up the dead summary buffer."
4531 (gnus-dead-summary-mode -1)
4532 (let ((name (buffer-name)))
4533 (when (string-match "Dead " name)
4535 (concat (substring name 0 (match-beginning 0))
4536 (substring name (match-end 0))) t)))
4537 (gnus-message 3 "This dead summary is now alive again"))
4539 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
4540 (defun gnus-summary-fetch-faq (&optional faq-dir)
4541 "Fetch the FAQ for the current group.
4542 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
4546 (if current-prefix-arg
4548 "Faq dir: " (and (listp gnus-group-faq-directory)
4549 gnus-group-faq-directory)))))
4550 (let (gnus-faq-buffer)
4551 (and (setq gnus-faq-buffer
4552 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
4553 (gnus-configure-windows 'summary-faq))))
4555 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4556 (defun gnus-summary-describe-group (&optional force)
4557 "Describe the current newsgroup."
4559 (gnus-group-describe-group force gnus-newsgroup-name))
4561 (defun gnus-summary-describe-briefly ()
4562 "Describe summary mode commands briefly."
4565 (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")))
4567 ;; Walking around group mode buffer from summary mode.
4569 (defun gnus-summary-next-group (&optional no-article target-group backward)
4570 "Exit current newsgroup and then select next unread newsgroup.
4571 If prefix argument NO-ARTICLE is non-nil, no article is selected
4572 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
4573 previous group instead."
4575 (gnus-set-global-variables)
4576 (let ((current-group gnus-newsgroup-name)
4577 (current-buffer (current-buffer))
4579 ;; First we semi-exit this group to update Xrefs and all variables.
4580 ;; We can't do a real exit, because the window conf must remain
4581 ;; the same in case the user is prompted for info, and we don't
4582 ;; want the window conf to change before that...
4583 (gnus-summary-exit t)
4584 (while (not entered)
4585 ;; Then we find what group we are supposed to enter.
4586 (set-buffer gnus-group-buffer)
4587 (gnus-group-jump-to-group current-group)
4590 (if (eq gnus-keep-same-level 'best)
4591 (gnus-summary-best-group gnus-newsgroup-name)
4592 (gnus-summary-search-group backward gnus-keep-same-level))))
4593 (if (not target-group)
4594 ;; There are no further groups, so we return to the group
4597 (gnus-message 5 "Returning to the group buffer")
4599 (set-buffer current-buffer)
4600 (gnus-summary-exit))
4601 ;; We try to enter the target group.
4602 (gnus-group-jump-to-group target-group)
4603 (let ((unreads (gnus-group-group-unread)))
4604 (if (and (or (eq t unreads)
4605 (and unreads (not (zerop unreads))))
4606 (gnus-summary-read-group
4607 target-group nil no-article current-buffer))
4609 (setq current-group target-group
4610 target-group nil)))))))
4612 (defun gnus-summary-prev-group (&optional no-article)
4613 "Exit current newsgroup and then select previous unread newsgroup.
4614 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
4616 (gnus-summary-next-group no-article nil t))
4618 ;; Walking around summary lines.
4620 (defun gnus-summary-first-subject (&optional unread)
4621 "Go to the first unread subject.
4622 If UNREAD is non-nil, go to the first unread article.
4623 Returns the article selected or nil if there are no unread articles."
4628 ((null gnus-newsgroup-data)
4629 (gnus-message 3 "No articles in the group")
4631 ;; Pick the first article.
4633 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
4634 (gnus-data-number (car gnus-newsgroup-data)))
4635 ;; No unread articles.
4636 ((null gnus-newsgroup-unreads)
4637 (gnus-message 3 "No more unread articles")
4639 ;; Find the first unread article.
4641 (let ((data gnus-newsgroup-data))
4643 (not (gnus-data-unread-p (car data))))
4644 (setq data (cdr data)))
4647 (goto-char (gnus-data-pos (car data)))
4648 (gnus-data-number (car data)))))))
4649 (gnus-summary-position-point)))
4651 (defun gnus-summary-next-subject (n &optional unread dont-display)
4652 "Go to next N'th summary line.
4653 If N is negative, go to the previous N'th subject line.
4654 If UNREAD is non-nil, only unread articles are selected.
4655 The difference between N and the actual number of steps taken is
4658 (let ((backward (< n 0))
4662 (gnus-summary-find-prev unread)
4663 (gnus-summary-find-next unread)))
4665 (if (/= 0 n) (gnus-message 7 "No more%s articles"
4666 (if unread " unread" "")))
4667 (unless dont-display
4668 (gnus-summary-recenter)
4669 (gnus-summary-position-point))
4672 (defun gnus-summary-next-unread-subject (n)
4673 "Go to next N'th unread summary line."
4675 (gnus-summary-next-subject n t))
4677 (defun gnus-summary-prev-subject (n &optional unread)
4678 "Go to previous N'th summary line.
4679 If optional argument UNREAD is non-nil, only unread article is selected."
4681 (gnus-summary-next-subject (- n) unread))
4683 (defun gnus-summary-prev-unread-subject (n)
4684 "Go to previous N'th unread summary line."
4686 (gnus-summary-next-subject (- n) t))
4688 (defun gnus-summary-goto-subject (article &optional force silent)
4689 "Go the subject line of ARTICLE.
4690 If FORCE, also allow jumping to articles not currently shown."
4692 (data (gnus-data-find article)))
4693 ;; We read in the article if we have to.
4696 (gnus-summary-insert-subject article (and (vectorp force) force) t)
4697 (setq data (gnus-data-find article)))
4702 (gnus-message 3 "Can't find article %d" article))
4704 (goto-char (gnus-data-pos data))
4707 ;; Walking around summary lines with displaying articles.
4709 (defun gnus-summary-expand-window (&optional arg)
4710 "Make the summary buffer take up the entire Emacs frame.
4711 Given a prefix, will force an `article' buffer configuration."
4713 (gnus-set-global-variables)
4715 (gnus-configure-windows 'article 'force)
4716 (gnus-configure-windows 'summary 'force)))
4718 (defun gnus-summary-display-article (article &optional all-header)
4719 "Display ARTICLE in article buffer."
4720 (gnus-set-global-variables)
4724 (if gnus-summary-display-article-function
4725 (funcall gnus-summary-display-article-function article all-header)
4726 (gnus-article-prepare article all-header))
4727 (run-hooks 'gnus-select-article-hook)
4728 (unless (zerop gnus-current-article)
4729 (gnus-summary-goto-subject gnus-current-article))
4730 (gnus-summary-recenter)
4731 (when gnus-use-trees
4732 (gnus-possibly-generate-tree article)
4733 (gnus-highlight-selected-tree article))
4734 ;; Successfully display article.
4735 (gnus-article-set-window-start
4736 (cdr (assq article gnus-newsgroup-bookmarks))))))
4738 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
4739 "Select the current article.
4740 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
4741 non-nil, the article will be re-fetched even if it already present in
4742 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
4744 ;; Make sure we are in the summary buffer to work around bbdb bug.
4745 (unless (eq major-mode 'gnus-summary-mode)
4746 (set-buffer gnus-summary-buffer))
4747 (let ((article (or article (gnus-summary-article-number)))
4748 (all-headers (not (not all-headers))) ;Must be T or NIL.
4749 gnus-summary-display-article-function
4752 (gnus-summary-article-pseudo-p article)
4753 (error "This is a pseudo-article."))
4756 (set-buffer gnus-summary-buffer)
4757 (if (or (and gnus-single-article-buffer
4758 (or (null gnus-current-article)
4759 (null gnus-article-current)
4760 (null (get-buffer gnus-article-buffer))
4761 (not (eq article (cdr gnus-article-current)))
4762 (not (equal (car gnus-article-current)
4763 gnus-newsgroup-name))))
4764 (and (not gnus-single-article-buffer)
4765 (or (null gnus-current-article)
4766 (not (eq gnus-current-article article))))
4768 ;; The requested article is different from the current article.
4770 (gnus-summary-display-article article all-headers)
4772 (if (or all-headers gnus-show-all-headers)
4773 (gnus-article-show-all-headers))
4776 (gnus-article-set-window-start
4777 (cdr (assq article gnus-newsgroup-bookmarks)))))))
4779 (defun gnus-summary-set-current-mark (&optional current-mark)
4780 "Obsolete function."
4783 (defun gnus-summary-next-article (&optional unread subject backward push)
4784 "Select the next article.
4785 If UNREAD, only unread articles are selected.
4786 If SUBJECT, only articles with SUBJECT are selected.
4787 If BACKWARD, the previous article is selected instead of the next."
4789 (gnus-set-global-variables)
4791 ;; Is there such an article?
4792 ((and (gnus-summary-search-forward unread subject backward)
4793 (or (gnus-summary-display-article (gnus-summary-article-number))
4794 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
4795 (gnus-summary-position-point))
4796 ;; If not, we try the first unread, if that is wanted.
4798 gnus-auto-select-same
4799 ;; Make sure that we don't select the current article.
4800 (not (eq (gnus-summary-article-number)
4802 (gnus-summary-first-subject t)
4803 (gnus-summary-article-number))))
4804 (gnus-summary-first-unread-article))
4805 (gnus-summary-position-point)
4806 (gnus-message 6 "Wrapped"))
4807 ;; Try to get next/previous article not displayed in this group.
4808 ((and gnus-auto-extend-newsgroup
4809 (not unread) (not subject))
4810 (gnus-summary-goto-article
4811 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
4813 ;; Go to next/previous group.
4815 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
4816 (gnus-summary-jump-to-group gnus-newsgroup-name))
4817 (let ((cmd last-command-char)
4819 (if (eq gnus-keep-same-level 'best)
4820 (gnus-summary-best-group gnus-newsgroup-name)
4821 (gnus-summary-search-group backward gnus-keep-same-level))))
4822 ;; For some reason, the group window gets selected. We change
4824 (select-window (get-buffer-window (current-buffer)))
4825 ;; Select next unread newsgroup automagically.
4827 ((or (not gnus-auto-select-next)
4829 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
4830 ((or (eq gnus-auto-select-next 'quietly)
4831 (and (eq gnus-auto-select-next 'slightly-quietly)
4833 (and (eq gnus-auto-select-next 'almost-quietly)
4834 (gnus-summary-last-article-p)))
4836 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
4838 (gnus-message 7 "No more%s articles (%s)..."
4839 (if unread " unread" "")
4840 (if group (concat "selecting " group)
4842 (gnus-summary-next-group nil group backward)))
4844 (gnus-summary-walk-group-buffer
4845 gnus-newsgroup-name cmd unread backward)))))))
4847 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
4848 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
4849 (?\C-p (gnus-group-prev-unread-group 1))))
4850 (cursor-in-echo-area t)
4851 keve key group ended)
4853 (set-buffer gnus-group-buffer)
4854 (gnus-summary-jump-to-group from-group)
4856 (if (eq gnus-keep-same-level 'best)
4857 (gnus-summary-best-group gnus-newsgroup-name)
4858 (gnus-summary-search-group backward gnus-keep-same-level))))
4861 5 "No more%s articles%s" (if unread " unread" "")
4863 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
4864 (format " (Type %s for %s [%s])"
4865 (single-key-description cmd) group
4866 (car (gnus-gethash group gnus-newsrc-hashtb)))
4867 (format " (Type %s to exit %s)"
4868 (single-key-description cmd)
4869 gnus-newsgroup-name)))
4870 ;; Confirm auto selection.
4871 (setq key (car (setq keve (gnus-read-event-char))))
4874 ((assq key keystrokes)
4875 (let ((obuf (current-buffer)))
4876 (switch-to-buffer gnus-group-buffer)
4878 (gnus-group-jump-to-group group))
4879 (eval (cadr (assq key keystrokes)))
4880 (setq group (gnus-group-group-name))
4881 (switch-to-buffer obuf))
4885 (gnus-ephemeral-group-p gnus-newsgroup-name))
4887 (gnus-summary-next-group nil group backward)))
4889 (push (cdr keve) unread-command-events))))))
4891 (defun gnus-summary-next-unread-article ()
4892 "Select unread article after current one."
4894 (gnus-summary-next-article t (and gnus-auto-select-same
4895 (gnus-summary-article-subject))))
4897 (defun gnus-summary-prev-article (&optional unread subject)
4898 "Select the article after the current one.
4899 If UNREAD is non-nil, only unread articles are selected."
4901 (gnus-summary-next-article unread subject t))
4903 (defun gnus-summary-prev-unread-article ()
4904 "Select unread article before current one."
4906 (gnus-summary-prev-article t (and gnus-auto-select-same
4907 (gnus-summary-article-subject))))
4909 (defun gnus-summary-next-page (&optional lines circular)
4910 "Show next page of the selected article.
4911 If at the end of the current article, select the next article.
4912 LINES says how many lines should be scrolled up.
4914 If CIRCULAR is non-nil, go to the start of the article instead of
4915 selecting the next article when reaching the end of the current
4918 (setq gnus-summary-buffer (current-buffer))
4919 (gnus-set-global-variables)
4920 (let ((article (gnus-summary-article-number))
4922 (gnus-configure-windows 'article)
4923 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
4924 (if (and (eq gnus-summary-goto-unread 'never)
4925 (not (gnus-summary-last-article-p article)))
4926 (gnus-summary-next-article)
4927 (gnus-summary-next-unread-article))
4928 (if (or (null gnus-current-article)
4929 (null gnus-article-current)
4930 (/= article (cdr gnus-article-current))
4931 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4932 ;; Selected subject is different from current article's.
4933 (gnus-summary-display-article article)
4934 (gnus-eval-in-buffer-window gnus-article-buffer
4935 (setq endp (gnus-article-next-page lines)))
4938 (gnus-summary-beginning-of-article))
4940 (gnus-message 3 "End of message"))
4942 (if (and (eq gnus-summary-goto-unread 'never)
4943 (not (gnus-summary-last-article-p article)))
4944 (gnus-summary-next-article)
4945 (gnus-summary-next-unread-article)))))))
4946 (gnus-summary-recenter)
4947 (gnus-summary-position-point)))
4949 (defun gnus-summary-prev-page (&optional lines)
4950 "Show previous page of selected article.
4951 Argument LINES specifies lines to be scrolled down."
4953 (gnus-set-global-variables)
4954 (let ((article (gnus-summary-article-number)))
4955 (gnus-configure-windows 'article)
4956 (if (or (null gnus-current-article)
4957 (null gnus-article-current)
4958 (/= article (cdr gnus-article-current))
4959 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
4960 ;; Selected subject is different from current article's.
4961 (gnus-summary-display-article article)
4962 (gnus-summary-recenter)
4963 (gnus-eval-in-buffer-window gnus-article-buffer
4964 (gnus-article-prev-page lines))))
4965 (gnus-summary-position-point))
4967 (defun gnus-summary-scroll-up (lines)
4968 "Scroll up (or down) one line current article.
4969 Argument LINES specifies lines to be scrolled up (or down if negative)."
4971 (gnus-set-global-variables)
4972 (gnus-configure-windows 'article)
4973 (gnus-summary-show-thread)
4974 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
4975 (gnus-eval-in-buffer-window gnus-article-buffer
4977 (if (gnus-article-next-page lines)
4978 (gnus-message 3 "End of message")))
4980 (gnus-article-prev-page (- lines))))))
4981 (gnus-summary-recenter)
4982 (gnus-summary-position-point))
4984 (defun gnus-summary-next-same-subject ()
4985 "Select next article which has the same subject as current one."
4987 (gnus-set-global-variables)
4988 (gnus-summary-next-article nil (gnus-summary-article-subject)))
4990 (defun gnus-summary-prev-same-subject ()
4991 "Select previous article which has the same subject as current one."
4993 (gnus-set-global-variables)
4994 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
4996 (defun gnus-summary-next-unread-same-subject ()
4997 "Select next unread article which has the same subject as current one."
4999 (gnus-set-global-variables)
5000 (gnus-summary-next-article t (gnus-summary-article-subject)))
5002 (defun gnus-summary-prev-unread-same-subject ()
5003 "Select previous unread article which has the same subject as current one."
5005 (gnus-set-global-variables)
5006 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5008 (defun gnus-summary-first-unread-article ()
5009 "Select the first unread article.
5010 Return nil if there are no unread articles."
5012 (gnus-set-global-variables)
5014 (when (gnus-summary-first-subject t)
5015 (gnus-summary-show-thread)
5016 (gnus-summary-first-subject t)
5017 (gnus-summary-display-article (gnus-summary-article-number)))
5018 (gnus-summary-position-point)))
5020 (defun gnus-summary-best-unread-article ()
5021 "Select the unread article with the highest score."
5023 (gnus-set-global-variables)
5024 (let ((best -1000000)
5025 (data gnus-newsgroup-data)
5028 (and (gnus-data-unread-p (car data))
5030 (gnus-summary-article-score (gnus-data-number (car data))))
5033 article (gnus-data-number (car data))))
5034 (setq data (cdr data)))
5037 (gnus-summary-goto-article article)
5038 (error "No unread articles"))
5039 (gnus-summary-position-point))))
5041 (defun gnus-summary-last-subject ()
5042 "Go to the last displayed subject line in the group."
5043 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5045 (gnus-summary-goto-subject article))))
5047 (defun gnus-summary-goto-article (article &optional all-headers force)
5048 "Fetch ARTICLE and display it if it exists.
5049 If ALL-HEADERS is non-nil, no header lines are hidden."
5055 (mapcar (lambda (number) (list (int-to-string number)))
5056 gnus-newsgroup-limit)))
5060 (if (gnus-summary-goto-subject article force)
5061 (gnus-summary-display-article article all-headers)
5062 (gnus-message 4 "Couldn't go to article %s" article) nil)
5063 (gnus-summary-position-point)))
5065 (defun gnus-summary-goto-last-article ()
5066 "Go to the previously read article."
5069 (and gnus-last-article
5070 (gnus-summary-goto-article gnus-last-article))
5071 (gnus-summary-position-point)))
5073 (defun gnus-summary-pop-article (number)
5074 "Pop one article off the history and go to the previous.
5075 NUMBER articles will be popped off."
5078 (setq gnus-newsgroup-history
5079 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5081 (gnus-summary-goto-article (car to))
5082 (error "Article history empty")))
5083 (gnus-summary-position-point))
5085 ;; Summary commands and functions for limiting the summary buffer.
5087 (defun gnus-summary-limit-to-articles (n)
5088 "Limit the summary buffer to the next N articles.
5089 If not given a prefix, use the process marked articles instead."
5091 (gnus-set-global-variables)
5093 (let ((articles (gnus-summary-work-articles n)))
5094 (setq gnus-newsgroup-processable nil)
5095 (gnus-summary-limit articles))
5096 (gnus-summary-position-point)))
5098 (defun gnus-summary-pop-limit (&optional total)
5099 "Restore the previous limit.
5100 If given a prefix, remove all limits."
5102 (gnus-set-global-variables)
5104 (setq gnus-newsgroup-limits
5105 (list (mapcar (lambda (h) (mail-header-number h))
5106 gnus-newsgroup-headers))))
5107 (unless gnus-newsgroup-limits
5108 (error "No limit to pop"))
5110 (gnus-summary-limit nil 'pop)
5111 (gnus-summary-position-point)))
5113 (defun gnus-summary-limit-to-subject (subject &optional header)
5114 "Limit the summary buffer to articles that have subjects that match a regexp."
5115 (interactive "sRegexp: ")
5117 (setq header "subject"))
5118 (when (not (equal "" subject))
5120 (let ((articles (gnus-summary-find-matching
5121 (or header "subject") subject 'all)))
5122 (or articles (error "Found no matches for \"%s\"" subject))
5123 (gnus-summary-limit articles))
5124 (gnus-summary-position-point))))
5126 (defun gnus-summary-limit-to-author (from)
5127 "Limit the summary buffer to articles that have authors that match a regexp."
5128 (interactive "sRegexp: ")
5129 (gnus-summary-limit-to-subject from "from"))
5131 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5133 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5135 (defun gnus-summary-limit-to-unread (&optional all)
5136 "Limit the summary buffer to articles that are not marked as read.
5137 If ALL is non-nil, limit strictly to unread articles."
5140 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5141 (gnus-summary-limit-to-marks
5142 ;; Concat all the marks that say that an article is read and have
5144 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5145 gnus-killed-mark gnus-kill-file-mark
5146 gnus-low-score-mark gnus-expirable-mark
5147 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5148 gnus-duplicate-mark)
5151 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5152 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
5154 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5155 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5156 If REVERSE, limit the summary buffer to articles that are not marked
5157 with MARKS. MARKS can either be a string of marks or a list of marks.
5158 Returns how many articles were removed."
5159 (interactive "sMarks: ")
5160 (gnus-set-global-variables)
5162 (let ((data gnus-newsgroup-data)
5163 (marks (if (listp marks) marks
5164 (append marks nil))) ; Transform to list.
5167 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
5168 (memq (gnus-data-mark (car data)) marks))
5169 (setq articles (cons (gnus-data-number (car data)) articles)))
5170 (setq data (cdr data)))
5171 (gnus-summary-limit articles))
5172 (gnus-summary-position-point)))
5174 (defun gnus-summary-limit-to-score (&optional score)
5175 "Limit to articles with score at or above SCORE."
5177 (gnus-set-global-variables)
5178 (setq score (if score
5179 (prefix-numeric-value score)
5180 (or gnus-summary-default-score 0)))
5181 (let ((data gnus-newsgroup-data)
5184 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5186 (push (gnus-data-number (car data)) articles))
5187 (setq data (cdr data)))
5189 (gnus-summary-limit articles)
5190 (gnus-summary-position-point))))
5192 (defun gnus-summary-limit-include-dormant ()
5193 "Display all the hidden articles that are marked as dormant."
5195 (gnus-set-global-variables)
5196 (or gnus-newsgroup-dormant
5197 (error "There are no dormant articles in this group"))
5199 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5200 (gnus-summary-position-point)))
5202 (defun gnus-summary-limit-exclude-dormant ()
5203 "Hide all dormant articles."
5205 (gnus-set-global-variables)
5207 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5208 (gnus-summary-position-point)))
5210 (defun gnus-summary-limit-exclude-childless-dormant ()
5211 "Hide all dormant articles that have no children."
5213 (gnus-set-global-variables)
5214 (let ((data (gnus-data-list t))
5215 articles d children)
5216 ;; Find all articles that are either not dormant or have
5218 (while (setq d (pop data))
5219 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5221 (gnus-article-children (gnus-data-number d)))
5224 (when (memq (car children) articles)
5229 (push (gnus-data-number d) articles)))
5232 (gnus-summary-limit articles)
5233 (gnus-summary-position-point))))
5235 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5236 "Mark all unread excluded articles as read.
5237 If ALL, mark even excluded ticked and dormants as read."
5239 (let ((articles (gnus-sorted-complement
5241 (mapcar (lambda (h) (mail-header-number h))
5242 gnus-newsgroup-headers)
5244 (sort gnus-newsgroup-limit '<)))
5246 (setq gnus-newsgroup-unreads nil)
5248 (setq gnus-newsgroup-dormant nil
5249 gnus-newsgroup-marked nil
5250 gnus-newsgroup-reads
5252 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5253 gnus-newsgroup-reads))
5254 (while (setq article (pop articles))
5255 (unless (or (memq article gnus-newsgroup-dormant)
5256 (memq article gnus-newsgroup-marked))
5257 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5259 (defun gnus-summary-limit (articles &optional pop)
5261 ;; We pop the previous limit off the stack and use that.
5262 (setq articles (car gnus-newsgroup-limits)
5263 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5264 ;; We use the new limit, so we push the old limit on the stack.
5265 (setq gnus-newsgroup-limits
5266 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
5268 (setq gnus-newsgroup-limit articles)
5269 (let ((total (length gnus-newsgroup-data))
5270 (data (gnus-data-find-list (gnus-summary-article-number)))
5271 (gnus-summary-mark-below nil) ; Inhibit this.
5273 ;; This will do all the work of generating the new summary buffer
5274 ;; according to the new limit.
5275 (gnus-summary-prepare)
5276 ;; Hide any threads, possibly.
5277 (and gnus-show-threads
5278 gnus-thread-hide-subtree
5279 (gnus-summary-hide-all-threads))
5280 ;; Try to return to the article you were at, or one in the
5283 ;; We try to find some article after the current one.
5285 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5288 (setq data (cdr data))))
5290 ;; If there is no data, that means that we were after the last
5291 ;; article. The same goes when we can't find any articles
5292 ;; after the current one.
5293 (goto-char (point-max))
5294 (gnus-summary-find-prev))
5295 ;; We return how many articles were removed from the summary
5296 ;; buffer as a result of the new limit.
5297 (- total (length gnus-newsgroup-data))))
5299 (defsubst gnus-invisible-cut-children (threads)
5302 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5307 (defsubst gnus-cut-thread (thread)
5308 "Go forwards in the thread until we find an article that we want to display."
5309 (when (or (eq gnus-fetch-old-headers 'some)
5310 (eq gnus-build-sparse-threads 'some)
5311 (eq gnus-build-sparse-threads 'more))
5312 ;; Deal with old-fetched headers and sparse threads.
5316 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
5317 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
5318 (or (<= (length (cdr thread)) 1)
5319 (gnus-invisible-cut-children (cdr thread))))
5320 (setq thread (cadr thread))))
5323 (defun gnus-cut-threads (threads)
5324 "Cut off all uninteresting articles from the beginning of threads."
5325 (when (or (eq gnus-fetch-old-headers 'some)
5326 (eq gnus-build-sparse-threads 'some)
5327 (eq gnus-build-sparse-threads 'more))
5330 (setcar th (gnus-cut-thread (car th)))
5331 (setq th (cdr th)))))
5332 ;; Remove nixed out threads.
5335 (defun gnus-summary-initial-limit (&optional show-if-empty)
5336 "Figure out what the initial limit is supposed to be on group entry.
5337 This entails weeding out unwanted dormants, low-scored articles,
5338 fetch-old-headers verbiage, and so on."
5339 ;; Most groups have nothing to remove.
5340 (if (or gnus-inhibit-limiting
5341 (and (null gnus-newsgroup-dormant)
5342 (not (eq gnus-fetch-old-headers 'some))
5343 (null gnus-summary-expunge-below)
5344 (not (eq gnus-build-sparse-threads 'some))
5345 (not (eq gnus-build-sparse-threads 'more))
5346 (null gnus-thread-expunge-below)
5347 (not gnus-use-nocem)))
5349 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5350 (setq gnus-newsgroup-limit nil)
5353 (unless (car (symbol-value node))
5354 ;; These threads have no parents -- they are roots.
5355 (let ((nodes (cdr (symbol-value node)))
5358 (if (and gnus-thread-expunge-below
5359 (< (gnus-thread-total-score (car nodes))
5360 gnus-thread-expunge-below))
5361 (gnus-expunge-thread (pop nodes))
5362 (setq thread (pop nodes))
5363 (gnus-summary-limit-children thread))))))
5364 gnus-newsgroup-dependencies)
5365 ;; If this limitation resulted in an empty group, we might
5366 ;; pop the previous limit and use it instead.
5367 (when (and (not gnus-newsgroup-limit)
5369 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5370 gnus-newsgroup-limit))
5372 (defun gnus-summary-limit-children (thread)
5373 "Return 1 if this subthread is visible and 0 if it is not."
5374 ;; First we get the number of visible children to this thread. This
5375 ;; is done by recursing down the thread using this function, so this
5376 ;; will really go down to a leaf article first, before slowly
5377 ;; working its way up towards the root.
5381 (apply '+ (mapcar 'gnus-summary-limit-children
5384 (number (mail-header-number (car thread)))
5387 ;; If this article is dormant and has absolutely no visible
5388 ;; children, then this article isn't visible.
5389 (and (memq number gnus-newsgroup-dormant)
5391 ;; If this is "fetch-old-headered" and there is only one
5392 ;; visible child (or less), then we don't want this article.
5393 (and (eq gnus-fetch-old-headers 'some)
5394 (memq number gnus-newsgroup-ancient)
5396 ;; If this is a sparsely inserted article with no children,
5397 ;; we don't want it.
5398 (and (eq gnus-build-sparse-threads 'some)
5399 (memq number gnus-newsgroup-sparse)
5401 ;; If we use expunging, and this article is really
5402 ;; low-scored, then we don't want this article.
5403 (when (and gnus-summary-expunge-below
5405 (or (cdr (assq number gnus-newsgroup-scored))
5406 gnus-summary-default-score))
5407 gnus-summary-expunge-below))
5408 ;; We increase the expunge-tally here, but that has
5409 ;; nothing to do with the limits, really.
5410 (incf gnus-newsgroup-expunged-tally)
5411 ;; We also mark as read here, if that's wanted.
5412 (when (and gnus-summary-mark-below
5413 (< score gnus-summary-mark-below))
5414 (setq gnus-newsgroup-unreads
5415 (delq number gnus-newsgroup-unreads))
5416 (if gnus-newsgroup-auto-expire
5417 (push number gnus-newsgroup-expirable)
5418 (push (cons number gnus-low-score-mark)
5419 gnus-newsgroup-reads)))
5422 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
5423 ;; Nope, invisible article.
5425 ;; Ok, this article is to be visible, so we add it to the limit
5427 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
5430 (defun gnus-expunge-thread (thread)
5431 "Mark all articles in THREAD as read."
5432 (let* ((number (mail-header-number (car thread))))
5433 (incf gnus-newsgroup-expunged-tally)
5434 ;; We also mark as read here, if that's wanted.
5435 (setq gnus-newsgroup-unreads
5436 (delq number gnus-newsgroup-unreads))
5437 (if gnus-newsgroup-auto-expire
5438 (push number gnus-newsgroup-expirable)
5439 (push (cons number gnus-low-score-mark)
5440 gnus-newsgroup-reads)))
5441 ;; Go recursively through all subthreads.
5442 (mapcar 'gnus-expunge-thread (cdr thread)))
5444 ;; Summary article oriented commands
5446 (defun gnus-summary-refer-parent-article (n)
5447 "Refer parent article N times.
5448 The difference between N and the number of articles fetched is returned."
5450 (gnus-set-global-variables)
5454 (let* ((header (gnus-summary-article-header))
5456 ;; If we try to find the parent of the currently
5457 ;; displayed article, then we take a look at the actual
5458 ;; References header, since this is slightly more
5459 ;; reliable than the References field we got from the
5461 (if (and (eq (mail-header-number header)
5462 (cdr gnus-article-current))
5463 (equal gnus-newsgroup-name
5464 (car gnus-article-current)))
5466 (set-buffer gnus-original-article-buffer)
5467 (nnheader-narrow-to-headers)
5469 (message-fetch-field "references")
5471 ;; It's not the current article, so we take a bet on
5472 ;; the value we got from the server.
5473 (mail-header-references header))))
5474 (if (setq ref (or ref (mail-header-references header)))
5475 (or (gnus-summary-refer-article (gnus-parent-id ref))
5476 (gnus-message 1 "Couldn't find parent"))
5477 (gnus-message 1 "No references in article %d"
5478 (gnus-summary-article-number))
5481 (gnus-summary-position-point)
5484 (defun gnus-summary-refer-references ()
5485 "Fetch all articles mentioned in the References header.
5486 Return how many articles were fetched."
5488 (gnus-set-global-variables)
5489 (let ((ref (mail-header-references (gnus-summary-article-header)))
5490 (current (gnus-summary-article-number))
5492 ;; For each Message-ID in the References header...
5493 (while (string-match "<[^>]*>" ref)
5495 ;; ... fetch that article.
5496 (gnus-summary-refer-article
5497 (prog1 (match-string 0 ref)
5498 (setq ref (substring ref (match-end 0))))))
5499 (gnus-summary-goto-subject current)
5500 (gnus-summary-position-point)
5503 (defun gnus-summary-refer-article (message-id)
5504 "Fetch an article specified by MESSAGE-ID."
5505 (interactive "sMessage-ID: ")
5506 (when (and (stringp message-id)
5507 (not (zerop (length message-id))))
5508 ;; Construct the correct Message-ID if necessary.
5509 ;; Suggested by tale@pawl.rpi.edu.
5510 (unless (string-match "^<" message-id)
5511 (setq message-id (concat "<" message-id)))
5512 (unless (string-match ">$" message-id)
5513 (setq message-id (concat message-id ">")))
5514 (let* ((header (gnus-id-to-header message-id))
5516 (memq (mail-header-number header)
5517 gnus-newsgroup-sparse))))
5520 ;; The article is present in the buffer, to we just go to it.
5521 (gnus-summary-goto-article
5522 (mail-header-number header) nil header)
5524 (gnus-summary-update-article (mail-header-number header))))
5525 ;; We fetch the article
5526 (let ((gnus-override-method
5527 (and (gnus-news-group-p gnus-newsgroup-name)
5528 gnus-refer-article-method))
5530 ;; Start the special refer-article method, if necessary.
5531 (when (and gnus-refer-article-method
5532 (gnus-news-group-p gnus-newsgroup-name))
5533 (gnus-check-server gnus-refer-article-method))
5534 ;; Fetch the header, and display the article.
5535 (if (setq number (gnus-summary-insert-subject message-id))
5536 (gnus-summary-select-article nil nil nil number)
5537 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
5539 (defun gnus-summary-enter-digest-group (&optional force)
5540 "Enter an nndoc group based on the current article.
5541 If FORCE, force a digest interpretation. If not, try
5542 to guess what the document format is."
5544 (gnus-set-global-variables)
5545 (gnus-summary-select-article)
5546 (let ((name (format "%s-%d"
5547 (gnus-group-prefixed-name
5548 gnus-newsgroup-name (list 'nndoc ""))
5549 gnus-current-article))
5550 (ogroup gnus-newsgroup-name)
5551 (case-fold-search t)
5552 (buf (current-buffer))
5555 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
5556 (insert-buffer-substring gnus-original-article-buffer)
5558 (goto-char (point-min))
5559 (or (search-forward "\n\n" nil t) (point)))
5560 (goto-char (point-min))
5561 (delete-matching-lines "^\\(Path\\):\\|^From ")
5564 (if (gnus-group-read-ephemeral-group
5565 name `(nndoc ,name (nndoc-address
5567 (nndoc-article-type ,(if force 'digest 'guess))) t)
5568 ;; Make all postings to this group go to the parent group.
5569 (nconc (gnus-info-params (gnus-get-info name))
5570 (list (cons 'to-group ogroup)))
5571 ;; Couldn't select this doc group.
5572 (switch-to-buffer buf)
5573 (gnus-set-global-variables)
5574 (gnus-configure-windows 'summary)
5575 (gnus-message 3 "Article couldn't be entered?"))
5576 (kill-buffer dig))))
5578 (defun gnus-summary-read-document (n)
5579 "Open a new group based on the current article(s).
5580 Obeys the standard process/prefix convention."
5582 (let ((articles (gnus-summary-work-articles n))
5583 (ogroup gnus-newsgroup-name)
5584 article group egroup groups vgroup)
5585 (while (setq article (pop articles))
5586 (setq group (format "%s-%d" gnus-newsgroup-name gnus-current-article))
5587 (gnus-summary-remove-process-mark article)
5588 (when (gnus-summary-display-article article)
5590 (nnheader-temp-write nil
5591 (insert-buffer-substring gnus-original-article-buffer)
5592 ;; Remove some headers that may lead nndoc to make
5594 (message-narrow-to-head)
5595 (goto-char (point-min))
5596 (delete-matching-lines "^\\(Path\\):\\|^From ")
5599 (gnus-group-read-ephemeral-group
5600 group `(nndoc ,group (nndoc-address ,(current-buffer))
5601 (nndoc-article-type guess))
5604 ;; Make all postings to this group go to the parent group.
5605 (nconc (gnus-info-params (gnus-get-info egroup))
5606 (list (cons 'to-group ogroup)))
5607 (push egroup groups))
5608 ;; Couldn't select this doc group.
5609 (gnus-error 3 "Article couldn't be entered"))))))
5610 ;; Now we have selected all the documents.
5613 (error "None of the articles could be interpreted as documents"))
5614 ((gnus-group-read-ephemeral-group
5615 (setq vgroup (format "%s-%s" gnus-newsgroup-name (current-time-string)))
5616 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
5619 (error "Couldn't select virtual nndoc group")))))
5621 (defun gnus-summary-isearch-article (&optional regexp-p)
5622 "Do incremental search forward on the current article.
5623 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
5625 (gnus-set-global-variables)
5626 (gnus-summary-select-article)
5627 (gnus-configure-windows 'article)
5628 (gnus-eval-in-buffer-window gnus-article-buffer
5629 ;;(goto-char (point-min))
5630 (isearch-forward regexp-p)))
5632 (defun gnus-summary-search-article-forward (regexp &optional backward)
5633 "Search for an article containing REGEXP forward.
5634 If BACKWARD, search backward instead."
5637 (format "Search article %s (regexp%s): "
5638 (if current-prefix-arg "backward" "forward")
5639 (if gnus-last-search-regexp
5640 (concat ", default " gnus-last-search-regexp)
5642 current-prefix-arg))
5643 (gnus-set-global-variables)
5644 (if (string-equal regexp "")
5645 (setq regexp (or gnus-last-search-regexp ""))
5646 (setq gnus-last-search-regexp regexp))
5647 (if (gnus-summary-search-article regexp backward)
5648 (gnus-summary-show-thread)
5649 (error "Search failed: \"%s\"" regexp)))
5651 (defun gnus-summary-search-article-backward (regexp)
5652 "Search for an article containing REGEXP backward."
5655 (format "Search article backward (regexp%s): "
5656 (if gnus-last-search-regexp
5657 (concat ", default " gnus-last-search-regexp)
5659 (gnus-summary-search-article-forward regexp 'backward))
5661 (defun gnus-summary-search-article (regexp &optional backward)
5662 "Search for an article containing REGEXP.
5663 Optional argument BACKWARD means do search for backward.
5664 `gnus-select-article-hook' is not called during the search."
5665 (let ((gnus-select-article-hook nil) ;Disable hook.
5666 (gnus-article-display-hook nil)
5667 (gnus-mark-article-hook nil) ;Inhibit marking as read.
5668 (gnus-use-article-prefetch nil)
5671 're-search-backward 're-search-forward))
5672 (sum (current-buffer))
5674 (gnus-save-hidden-threads
5675 (gnus-summary-select-article)
5676 (set-buffer gnus-article-buffer)
5680 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
5682 (re-search-backward regexp nil t)
5683 (re-search-forward regexp nil t))
5684 ;; We found the regexp.
5689 (get-buffer-window (current-buffer))
5693 ;; We didn't find it, so we go to the next article.
5695 (if (not (if backward (gnus-summary-find-prev)
5696 (gnus-summary-find-next)))
5697 ;; No more articles.
5699 ;; Select the next article and adjust point.
5700 (gnus-summary-select-article)
5701 (set-buffer gnus-article-buffer)
5703 (goto-char (if backward (point-max) (point-min))))))
5704 (gnus-message 7 ""))
5705 ;; Return whether we found the regexp.
5706 (when (eq found 'found)
5707 (gnus-summary-show-thread)
5708 (gnus-summary-goto-subject gnus-current-article)
5709 (gnus-summary-position-point)
5712 (defun gnus-summary-find-matching (header regexp &optional backward unread
5714 "Return a list of all articles that match REGEXP on HEADER.
5715 The search stars on the current article and goes forwards unless
5716 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
5717 If UNREAD is non-nil, only unread articles will
5718 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
5719 in the comparisons."
5720 (let ((data (if (eq backward 'all) gnus-newsgroup-data
5721 (gnus-data-find-list
5722 (gnus-summary-article-number) (gnus-data-list backward))))
5723 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
5724 (case-fold-search (not not-case-fold))
5726 (or (fboundp (intern (concat "mail-header-" header)))
5727 (error "%s is not a valid header" header))
5730 (and (or (not unread) ; We want all articles...
5731 (gnus-data-unread-p d)) ; Or just unreads.
5732 (vectorp (gnus-data-header d)) ; It's not a pseudo.
5733 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
5734 (setq articles (cons (gnus-data-number d) articles))) ; Success!
5735 (setq data (cdr data)))
5736 (nreverse articles)))
5738 (defun gnus-summary-execute-command (header regexp command &optional backward)
5739 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
5740 If HEADER is an empty string (or nil), the match is done on the entire
5741 article. If BACKWARD (the prefix) is non-nil, search backward instead."
5743 (list (let ((completion-ignore-case t))
5746 (mapcar (lambda (string) (list string))
5747 '("Number" "Subject" "From" "Lines" "Date"
5748 "Message-ID" "Xref" "References" "Body"))
5749 nil 'require-match))
5750 (read-string "Regexp: ")
5751 (read-key-sequence "Command: ")
5752 current-prefix-arg))
5753 (when (equal header "Body")
5755 (gnus-set-global-variables)
5756 ;; Hidden thread subtrees must be searched as well.
5757 (gnus-summary-show-all-threads)
5758 ;; We don't want to change current point nor window configuration.
5760 (save-window-excursion
5761 (gnus-message 6 "Executing %s..." (key-description command))
5762 ;; We'd like to execute COMMAND interactively so as to give arguments.
5763 (gnus-execute header regexp
5764 `(lambda () (call-interactively ',(key-binding command)))
5766 (gnus-message 6 "Executing %s...done" (key-description command)))))
5768 (defun gnus-summary-beginning-of-article ()
5769 "Scroll the article back to the beginning."
5771 (gnus-set-global-variables)
5772 (gnus-summary-select-article)
5773 (gnus-configure-windows 'article)
5774 (gnus-eval-in-buffer-window gnus-article-buffer
5776 (goto-char (point-min))
5777 (and gnus-break-pages (gnus-narrow-to-page))))
5779 (defun gnus-summary-end-of-article ()
5780 "Scroll to the end of the article."
5782 (gnus-set-global-variables)
5783 (gnus-summary-select-article)
5784 (gnus-configure-windows 'article)
5785 (gnus-eval-in-buffer-window gnus-article-buffer
5787 (goto-char (point-max))
5789 (and gnus-break-pages (gnus-narrow-to-page))))
5791 (defun gnus-summary-show-article (&optional arg)
5792 "Force re-fetching of the current article.
5793 If ARG (the prefix) is non-nil, show the raw article without any
5794 article massaging functions being run."
5796 (gnus-set-global-variables)
5798 ;; Select the article the normal way.
5799 (gnus-summary-select-article nil 'force)
5800 ;; Bind the article treatment functions to nil.
5801 (let ((gnus-have-all-headers t)
5802 gnus-article-display-hook
5803 gnus-article-prepare-hook
5806 (gnus-summary-select-article nil 'force)))
5807 (gnus-summary-goto-subject gnus-current-article)
5808 ; (gnus-configure-windows 'article)
5809 (gnus-summary-position-point))
5811 (defun gnus-summary-verbose-headers (&optional arg)
5812 "Toggle permanent full header display.
5813 If ARG is a positive number, turn header display on.
5814 If ARG is a negative number, turn header display off."
5816 (gnus-set-global-variables)
5817 (gnus-summary-toggle-header arg)
5818 (setq gnus-show-all-headers
5819 (cond ((or (not (numberp arg))
5821 (not gnus-show-all-headers))
5825 (defun gnus-summary-toggle-header (&optional arg)
5826 "Show the headers if they are hidden, or hide them if they are shown.
5827 If ARG is a positive number, show the entire header.
5828 If ARG is a negative number, hide the unwanted header lines."
5830 (gnus-set-global-variables)
5832 (set-buffer gnus-article-buffer)
5833 (let* ((buffer-read-only nil)
5834 (inhibit-point-motion-hooks t)
5835 (hidden (text-property-any
5836 (goto-char (point-min)) (search-forward "\n\n")
5839 (goto-char (point-min))
5840 (when (search-forward "\n\n" nil t)
5841 (delete-region (point-min) (1- (point))))
5842 (goto-char (point-min))
5844 (set-buffer gnus-original-article-buffer)
5845 (goto-char (point-min))
5846 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
5847 (insert-buffer-substring gnus-original-article-buffer 1 e)
5848 (let ((article-inhibit-hiding t))
5849 (run-hooks 'gnus-article-display-hook))
5850 (if (or (not hidden) (and (numberp arg) (< arg 0)))
5851 (gnus-article-hide-headers)))))
5853 (defun gnus-summary-show-all-headers ()
5854 "Make all header lines visible."
5856 (gnus-set-global-variables)
5857 (gnus-article-show-all-headers))
5859 (defun gnus-summary-toggle-mime (&optional arg)
5860 "Toggle MIME processing.
5861 If ARG is a positive number, turn MIME processing on."
5863 (gnus-set-global-variables)
5864 (setq gnus-show-mime
5865 (if (null arg) (not gnus-show-mime)
5866 (> (prefix-numeric-value arg) 0)))
5867 (gnus-summary-select-article t 'force))
5869 (defun gnus-summary-caesar-message (&optional arg)
5870 "Caesar rotate the current article by 13.
5871 The numerical prefix specifies how manu places to rotate each letter
5874 (gnus-set-global-variables)
5875 (gnus-summary-select-article)
5876 (let ((mail-header-separator ""))
5877 (gnus-eval-in-buffer-window gnus-article-buffer
5880 (let ((start (window-start))
5882 (message-caesar-buffer-body arg)
5883 (set-window-start (get-buffer-window (current-buffer)) start))))))
5885 (defun gnus-summary-stop-page-breaking ()
5886 "Stop page breaking in the current article."
5888 (gnus-set-global-variables)
5889 (gnus-summary-select-article)
5890 (gnus-eval-in-buffer-window gnus-article-buffer
5893 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
5894 "Move the current article to a different newsgroup.
5895 If N is a positive number, move the N next articles.
5896 If N is a negative number, move the N previous articles.
5897 If N is nil and any articles have been marked with the process mark,
5898 move those articles instead.
5899 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
5900 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
5901 re-spool using this method.
5903 For this function to work, both the current newsgroup and the
5904 newsgroup that you want to move to have to support the `request-move'
5905 and `request-accept' functions."
5907 (unless action (setq action 'move))
5908 (gnus-set-global-variables)
5909 ;; Check whether the source group supports the required functions.
5910 (cond ((and (eq action 'move)
5911 (not (gnus-check-backend-function
5912 'request-move-article gnus-newsgroup-name)))
5913 (error "The current group does not support article moving"))
5914 ((and (eq action 'crosspost)
5915 (not (gnus-check-backend-function
5916 'request-replace-article gnus-newsgroup-name)))
5917 (error "The current group does not support article editing")))
5918 (let ((articles (gnus-summary-work-articles n))
5919 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
5920 (names '((move "Move" "Moving")
5921 (copy "Copy" "Copying")
5922 (crosspost "Crosspost" "Crossposting")))
5923 (copy-buf (save-excursion
5924 (nnheader-set-temp-buffer " *copy article*")))
5925 art-group to-method new-xref article to-groups)
5926 (unless (assq action names)
5927 (error "Unknown action %s" action))
5928 ;; Read the newsgroup name.
5929 (when (and (not to-newsgroup)
5930 (not select-method))
5932 (gnus-read-move-group-name
5933 (cadr (assq action names))
5934 (symbol-value (intern (format "gnus-current-%s-group" action)))
5936 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
5937 (setq to-method (or select-method
5938 (gnus-group-name-to-method to-newsgroup)))
5939 ;; Check the method we are to move this article to...
5940 (or (gnus-check-backend-function 'request-accept-article (car to-method))
5941 (error "%s does not support article copying" (car to-method)))
5942 (or (gnus-check-server to-method)
5943 (error "Can't open server %s" (car to-method)))
5944 (gnus-message 6 "%s to %s: %s..."
5945 (caddr (assq action names))
5946 (or (car select-method) to-newsgroup) articles)
5948 (setq article (pop articles))
5952 ;; Move the article.
5954 (gnus-request-move-article
5955 article ; Article to move
5956 gnus-newsgroup-name ; From newsgrouo
5957 (nth 1 (gnus-find-method-for-group
5958 gnus-newsgroup-name)) ; Server
5959 (list 'gnus-request-accept-article
5960 to-newsgroup (list 'quote select-method)
5961 (not articles)) ; Accept form
5962 (not articles))) ; Only save nov last time
5963 ;; Copy the article.
5966 (set-buffer copy-buf)
5967 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5968 (gnus-request-accept-article
5969 to-newsgroup select-method (not articles))))
5970 ;; Crosspost the article.
5971 ((eq action 'crosspost)
5972 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
5973 (setq new-xref (concat gnus-newsgroup-name ":" article))
5974 (if (and xref (not (string= xref "")))
5976 (when (string-match "^Xref: " xref)
5977 (setq xref (substring xref (match-end 0))))
5978 (setq new-xref (concat xref " " new-xref)))
5979 (setq new-xref (concat (system-name) " " new-xref)))
5981 (set-buffer copy-buf)
5982 (gnus-request-article-this-buffer article gnus-newsgroup-name)
5983 (nnheader-replace-header "xref" new-xref)
5984 (gnus-request-accept-article
5985 to-newsgroup select-method (not articles)))))))
5987 (gnus-message 1 "Couldn't %s article %s"
5988 (cadr (assq action names)) article)
5991 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
5993 (gnus-group-prefixed-name
5996 (gnus-find-method-for-group to-newsgroup)))
5997 gnus-newsrc-hashtb)))
5998 (info (nth 2 entry))
5999 (to-group (gnus-info-group info)))
6000 ;; Update the group that has been moved to.
6002 (memq action '(move copy)))
6003 (unless (member to-group to-groups)
6004 (push to-group to-groups))
6006 (unless (memq article gnus-newsgroup-unreads)
6008 info (gnus-add-to-range (gnus-info-read info)
6009 (list (cdr art-group)))))
6011 ;; Copy any marks over to the new group.
6012 (let ((marks gnus-article-mark-lists)
6013 (to-article (cdr art-group)))
6015 ;; See whether the article is to be put in the cache.
6016 (when gnus-use-cache
6017 (gnus-cache-possibly-enter-article
6019 (let ((header (copy-sequence
6020 (gnus-summary-article-header article))))
6021 (mail-header-set-number header to-article)
6023 (memq article gnus-newsgroup-marked)
6024 (memq article gnus-newsgroup-dormant)
6025 (memq article gnus-newsgroup-unreads)))
6028 (when (memq article (symbol-value
6029 (intern (format "gnus-newsgroup-%s"
6031 ;; If the other group is the same as this group,
6032 ;; then we have to add the mark to the list.
6033 (when (equal to-group gnus-newsgroup-name)
6034 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6037 (intern (format "gnus-newsgroup-%s"
6039 ;; Copy mark to other group.
6040 (gnus-add-marked-articles
6041 to-group (cdar marks) (list to-article) info))
6042 (setq marks (cdr marks)))))
6044 ;; Update the Xref header in this article to point to
6045 ;; the new crossposted article we have just created.
6046 (when (eq action 'crosspost)
6048 (set-buffer copy-buf)
6049 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6050 (nnheader-replace-header
6051 "xref" (concat new-xref " " (gnus-group-prefixed-name
6052 (car art-group) to-method)
6053 ":" (cdr art-group)))
6054 (gnus-request-replace-article
6055 article gnus-newsgroup-name (current-buffer)))))
6057 (gnus-summary-goto-subject article)
6058 (when (eq action 'move)
6059 (gnus-summary-mark-article article gnus-canceled-mark)))
6060 (gnus-summary-remove-process-mark article))
6061 ;; Re-activate all groups that have been moved to.
6063 (gnus-activate-group (pop to-groups)))
6065 (gnus-kill-buffer copy-buf)
6066 (gnus-summary-position-point)
6067 (gnus-set-mode-line 'summary)))
6069 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6070 "Move the current article to a different newsgroup.
6071 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6072 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6073 re-spool using this method."
6075 (gnus-summary-move-article n nil select-method 'copy))
6077 (defun gnus-summary-crosspost-article (&optional n)
6078 "Crosspost the current article to some other group."
6080 (gnus-summary-move-article n nil nil 'crosspost))
6082 (defvar gnus-summary-respool-default-method nil
6083 "Default method for respooling an article.
6084 If nil, use to the current newsgroup method.")
6086 (defun gnus-summary-respool-article (&optional n method)
6087 "Respool the current article.
6088 The article will be squeezed through the mail spooling process again,
6089 which means that it will be put in some mail newsgroup or other
6090 depending on `nnmail-split-methods'.
6091 If N is a positive number, respool the N next articles.
6092 If N is a negative number, respool the N previous articles.
6093 If N is nil and any articles have been marked with the process mark,
6094 respool those articles instead.
6096 Respooling can be done both from mail groups and \"real\" newsgroups.
6097 In the former case, the articles in question will be moved from the
6098 current group into whatever groups they are destined to. In the
6099 latter case, they will be copied into the relevant groups."
6101 (list current-prefix-arg
6102 (let* ((methods (gnus-methods-using 'respool))
6104 (symbol-name (or gnus-summary-respool-default-method
6105 (car (gnus-find-method-for-group
6106 gnus-newsgroup-name)))))
6108 (gnus-completing-read
6109 methname "What backend do you want to use when respooling?"
6110 methods nil t nil 'gnus-method-history))
6113 ((zerop (length (setq ms (gnus-servers-using-backend method))))
6114 (list (intern method) ""))
6118 (cdr (completing-read
6120 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
6121 (gnus-set-global-variables)
6123 (error "No method given for respooling"))
6124 (if (assoc (symbol-name
6125 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6126 (gnus-methods-using 'respool))
6127 (gnus-summary-move-article n nil method)
6128 (gnus-summary-copy-article n nil method)))
6130 (defun gnus-summary-import-article (file)
6131 "Import a random file into a mail newsgroup."
6132 (interactive "fImport file: ")
6133 (gnus-set-global-variables)
6134 (let ((group gnus-newsgroup-name)
6135 (now (current-time))
6137 (or (gnus-check-backend-function 'request-accept-article group)
6138 (error "%s does not support article importing" group))
6139 (or (file-readable-p file)
6140 (not (file-regular-p file))
6141 (error "Can't read %s" file))
6143 (set-buffer (get-buffer-create " *import file*"))
6144 (buffer-disable-undo (current-buffer))
6146 (insert-file-contents file)
6147 (goto-char (point-min))
6148 (unless (nnheader-article-p)
6149 ;; This doesn't look like an article, so we fudge some headers.
6150 (setq atts (file-attributes file)
6151 lines (count-lines (point-min) (point-max)))
6152 (insert "From: " (read-string "From: ") "\n"
6153 "Subject: " (read-string "Subject: ") "\n"
6154 "Date: " (timezone-make-date-arpa-standard
6155 (current-time-string (nth 5 atts))
6156 (current-time-zone now)
6157 (current-time-zone now)) "\n"
6158 "Message-ID: " (message-make-message-id) "\n"
6159 "Lines: " (int-to-string lines) "\n"
6160 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6161 (gnus-request-accept-article group nil t)
6162 (kill-buffer (current-buffer)))))
6164 (defun gnus-summary-expire-articles (&optional now)
6165 "Expire all articles that are marked as expirable in the current group."
6167 (gnus-set-global-variables)
6168 (when (gnus-check-backend-function
6169 'request-expire-articles gnus-newsgroup-name)
6170 ;; This backend supports expiry.
6171 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6172 (expirable (if total
6173 (gnus-list-of-read-articles gnus-newsgroup-name)
6174 (setq gnus-newsgroup-expirable
6175 (sort gnus-newsgroup-expirable '<))))
6176 (expiry-wait (if now 'immediate
6177 (gnus-group-find-parameter
6178 gnus-newsgroup-name 'expiry-wait)))
6181 ;; There are expirable articles in this group, so we run them
6182 ;; through the expiry process.
6183 (gnus-message 6 "Expiring articles...")
6184 ;; The list of articles that weren't expired is returned.
6186 (let ((nnmail-expiry-wait-function nil)
6187 (nnmail-expiry-wait expiry-wait))
6188 (setq es (gnus-request-expire-articles
6189 expirable gnus-newsgroup-name)))
6190 (setq es (gnus-request-expire-articles
6191 expirable gnus-newsgroup-name)))
6193 (setq gnus-newsgroup-expirable es))
6194 ;; We go through the old list of expirable, and mark all
6195 ;; really expired articles as nonexistent.
6196 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6197 (let ((gnus-use-cache nil))
6199 (unless (memq (car expirable) es)
6200 (when (gnus-data-find (car expirable))
6201 (gnus-summary-mark-article
6202 (car expirable) gnus-canceled-mark)))
6203 (setq expirable (cdr expirable)))))
6204 (gnus-message 6 "Expiring articles...done")))))
6206 (defun gnus-summary-expire-articles-now ()
6207 "Expunge all expirable articles in the current group.
6208 This means that *all* articles that are marked as expirable will be
6209 deleted forever, right now."
6211 (gnus-set-global-variables)
6212 (or gnus-expert-user
6214 "Are you really, really, really sure you want to delete all these messages? ")
6216 (gnus-summary-expire-articles t))
6218 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6219 (defun gnus-summary-delete-article (&optional n)
6220 "Delete the N next (mail) articles.
6221 This command actually deletes articles. This is not a marking
6222 command. The article will disappear forever from your life, never to
6224 If N is negative, delete backwards.
6225 If N is nil and articles have been marked with the process mark,
6226 delete these instead."
6228 (gnus-set-global-variables)
6229 (or (gnus-check-backend-function 'request-expire-articles
6230 gnus-newsgroup-name)
6231 (error "The current newsgroup does not support article deletion."))
6232 ;; Compute the list of articles to delete.
6233 (let ((articles (gnus-summary-work-articles n))
6235 (if (and gnus-novice-user
6237 (format "Do you really want to delete %s forever? "
6238 (if (> (length articles) 1)
6239 (format "these %s articles" (length articles))
6242 ;; Delete the articles.
6243 (setq not-deleted (gnus-request-expire-articles
6244 articles gnus-newsgroup-name 'force))
6246 (gnus-summary-remove-process-mark (car articles))
6247 ;; The backend might not have been able to delete the article
6249 (or (memq (car articles) not-deleted)
6250 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6251 (setq articles (cdr articles))))
6252 (gnus-summary-position-point)
6253 (gnus-set-mode-line 'summary)
6256 (defun gnus-summary-edit-article (&optional force)
6257 "Edit the current article.
6258 This will have permanent effect only in mail groups.
6259 If FORCE is non-nil, allow editing of articles even in read-only
6263 (set-buffer gnus-summary-buffer)
6264 (gnus-set-global-variables)
6265 (when (and (not force)
6266 (gnus-group-read-only-p))
6267 (error "The current newsgroup does not support article editing."))
6268 ;; Select article if needed.
6269 (unless (eq (gnus-summary-article-number)
6270 gnus-current-article)
6271 (gnus-summary-select-article t))
6272 (gnus-article-edit-article
6274 (gnus-summary-edit-article-done
6275 ,(or (mail-header-references gnus-current-headers) "")
6276 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6278 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6280 (defun gnus-summary-edit-article-done (references read-only buffer)
6281 "Make edits to the current article permanent."
6283 ;; Replace the article.
6284 (if (and (not read-only)
6285 (not (gnus-request-replace-article
6286 (cdr gnus-article-current) (car gnus-article-current)
6288 (error "Couldn't replace article.")
6289 ;; Update the summary buffer.
6290 (if (equal (message-tokenize-header references " ")
6291 (message-tokenize-header
6292 (or (message-fetch-field "references") "") " "))
6293 ;; We only have to update this line.
6296 (message-narrow-to-head)
6297 (let ((header (nnheader-parse-head t)))
6299 (mail-header-set-number header (cdr gnus-article-current))
6300 (gnus-summary-update-article-line
6301 (cdr gnus-article-current) header))))
6304 (gnus-summary-update-article (cdr gnus-article-current)))
6305 ;; Prettify the article buffer again.
6307 (set-buffer gnus-article-buffer)
6308 (run-hooks 'gnus-article-display-hook))
6309 ;; Prettify the summary buffer line.
6310 (when (gnus-visual-p 'summary-highlight 'highlight)
6311 (run-hooks 'gnus-visual-mark-article-hook))))
6313 (defun gnus-summary-edit-wash (key)
6314 "Perform editing command in the article buffer."
6318 (message "%s" (concat (this-command-keys) "- "))
6321 (gnus-summary-edit-article)
6322 (execute-kbd-macro (concat (this-command-keys) key))
6323 (gnus-article-edit-done))
6327 (defun gnus-summary-respool-query ()
6328 "Query where the respool algorithm would put this article."
6330 (gnus-set-global-variables)
6331 (gnus-summary-select-article)
6333 (set-buffer gnus-article-buffer)
6335 (goto-char (point-min))
6336 (search-forward "\n\n")
6337 (narrow-to-region (point-min) (point))
6339 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
6341 ;; Summary marking commands.
6343 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6344 "Mark articles which has the same subject as read, and then select the next.
6345 If UNMARK is positive, remove any kind of mark.
6346 If UNMARK is negative, tick articles."
6348 (gnus-set-global-variables)
6350 (setq unmark (prefix-numeric-value unmark)))
6352 (gnus-summary-mark-same-subject
6353 (gnus-summary-article-subject) unmark)))
6354 ;; Select next unread article. If auto-select-same mode, should
6355 ;; select the first unread article.
6356 (gnus-summary-next-article t (and gnus-auto-select-same
6357 (gnus-summary-article-subject)))
6358 (gnus-message 7 "%d article%s marked as %s"
6359 count (if (= count 1) " is" "s are")
6360 (if unmark "unread" "read"))))
6362 (defun gnus-summary-kill-same-subject (&optional unmark)
6363 "Mark articles which has the same subject as read.
6364 If UNMARK is positive, remove any kind of mark.
6365 If UNMARK is negative, tick articles."
6367 (gnus-set-global-variables)
6369 (setq unmark (prefix-numeric-value unmark)))
6371 (gnus-summary-mark-same-subject
6372 (gnus-summary-article-subject) unmark)))
6373 ;; If marked as read, go to next unread subject.
6375 ;; Go to next unread subject.
6376 (gnus-summary-next-subject 1 t))
6377 (gnus-message 7 "%d articles are marked as %s"
6378 count (if unmark "unread" "read"))))
6380 (defun gnus-summary-mark-same-subject (subject &optional unmark)
6381 "Mark articles with same SUBJECT as read, and return marked number.
6382 If optional argument UNMARK is positive, remove any kinds of marks.
6383 If optional argument UNMARK is negative, mark articles as unread instead."
6387 ((null unmark) ; Mark as read.
6390 (gnus-summary-mark-article-as-read gnus-killed-mark)
6391 (gnus-summary-show-thread) t)
6392 (gnus-summary-find-subject subject))
6393 (setq count (1+ count))))
6394 ((> unmark 0) ; Tick.
6397 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
6398 (gnus-summary-show-thread) t)
6399 (gnus-summary-find-subject subject))
6400 (setq count (1+ count))))
6401 (t ; Mark as unread.
6404 (gnus-summary-mark-article-as-unread gnus-unread-mark)
6405 (gnus-summary-show-thread) t)
6406 (gnus-summary-find-subject subject))
6407 (setq count (1+ count)))))
6408 (gnus-set-mode-line 'summary)
6409 ;; Return the number of marked articles.
6412 (defun gnus-summary-mark-as-processable (n &optional unmark)
6413 "Set the process mark on the next N articles.
6414 If N is negative, mark backward instead. If UNMARK is non-nil, remove
6415 the process mark instead. The difference between N and the actual
6416 number of articles marked is returned."
6418 (gnus-set-global-variables)
6419 (let ((backward (< n 0))
6424 (gnus-summary-remove-process-mark
6425 (gnus-summary-article-number))
6426 (gnus-summary-set-process-mark (gnus-summary-article-number)))
6427 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
6429 (if (/= 0 n) (gnus-message 7 "No more articles"))
6430 (gnus-summary-recenter)
6431 (gnus-summary-position-point)
6434 (defun gnus-summary-unmark-as-processable (n)
6435 "Remove the process mark from the next N articles.
6436 If N is negative, mark backward instead. The difference between N and
6437 the actual number of articles marked is returned."
6439 (gnus-set-global-variables)
6440 (gnus-summary-mark-as-processable n t))
6442 (defun gnus-summary-unmark-all-processable ()
6443 "Remove the process mark from all articles."
6445 (gnus-set-global-variables)
6447 (while gnus-newsgroup-processable
6448 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
6449 (gnus-summary-position-point))
6451 (defun gnus-summary-mark-as-expirable (n)
6452 "Mark N articles forward as expirable.
6453 If N is negative, mark backward instead. The difference between N and
6454 the actual number of articles marked is returned."
6456 (gnus-set-global-variables)
6457 (gnus-summary-mark-forward n gnus-expirable-mark))
6459 (defun gnus-summary-mark-article-as-replied (article)
6460 "Mark ARTICLE replied and update the summary line."
6461 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
6462 (let ((buffer-read-only nil))
6463 (when (gnus-summary-goto-subject article)
6464 (gnus-summary-update-secondary-mark article))))
6466 (defun gnus-summary-set-bookmark (article)
6467 "Set a bookmark in current article."
6468 (interactive (list (gnus-summary-article-number)))
6469 (gnus-set-global-variables)
6470 (if (or (not (get-buffer gnus-article-buffer))
6471 (not gnus-current-article)
6472 (not gnus-article-current)
6473 (not (equal gnus-newsgroup-name (car gnus-article-current))))
6474 (error "No current article selected"))
6475 ;; Remove old bookmark, if one exists.
6476 (let ((old (assq article gnus-newsgroup-bookmarks)))
6477 (if old (setq gnus-newsgroup-bookmarks
6478 (delq old gnus-newsgroup-bookmarks))))
6479 ;; Set the new bookmark, which is on the form
6480 ;; (article-number . line-number-in-body).
6481 (setq gnus-newsgroup-bookmarks
6485 (set-buffer gnus-article-buffer)
6489 (goto-char (point-min))
6490 (search-forward "\n\n" nil t)
6493 gnus-newsgroup-bookmarks))
6494 (gnus-message 6 "A bookmark has been added to the current article."))
6496 (defun gnus-summary-remove-bookmark (article)
6497 "Remove the bookmark from the current article."
6498 (interactive (list (gnus-summary-article-number)))
6499 (gnus-set-global-variables)
6500 ;; Remove old bookmark, if one exists.
6501 (let ((old (assq article gnus-newsgroup-bookmarks)))
6504 (setq gnus-newsgroup-bookmarks
6505 (delq old gnus-newsgroup-bookmarks))
6506 (gnus-message 6 "Removed bookmark."))
6507 (gnus-message 6 "No bookmark in current article."))))
6509 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6510 (defun gnus-summary-mark-as-dormant (n)
6511 "Mark N articles forward as dormant.
6512 If N is negative, mark backward instead. The difference between N and
6513 the actual number of articles marked is returned."
6515 (gnus-set-global-variables)
6516 (gnus-summary-mark-forward n gnus-dormant-mark))
6518 (defun gnus-summary-set-process-mark (article)
6519 "Set the process mark on ARTICLE and update the summary line."
6520 (setq gnus-newsgroup-processable
6522 (delq article gnus-newsgroup-processable)))
6523 (when (gnus-summary-goto-subject article)
6524 (gnus-summary-show-thread)
6525 (gnus-summary-update-secondary-mark article)))
6527 (defun gnus-summary-remove-process-mark (article)
6528 "Remove the process mark from ARTICLE and update the summary line."
6529 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
6530 (when (gnus-summary-goto-subject article)
6531 (gnus-summary-show-thread)
6532 (gnus-summary-update-secondary-mark article)))
6534 (defun gnus-summary-set-saved-mark (article)
6535 "Set the process mark on ARTICLE and update the summary line."
6536 (push article gnus-newsgroup-saved)
6537 (when (gnus-summary-goto-subject article)
6538 (gnus-summary-update-secondary-mark article)))
6540 (defun gnus-summary-mark-forward (n &optional mark no-expire)
6541 "Mark N articles as read forwards.
6542 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
6543 The difference between N and the actual number of articles marked is
6546 (gnus-set-global-variables)
6547 (let ((backward (< n 0))
6548 (gnus-summary-goto-unread
6549 (and gnus-summary-goto-unread
6550 (not (eq gnus-summary-goto-unread 'never))
6551 (not (memq mark (list gnus-unread-mark
6552 gnus-ticked-mark gnus-dormant-mark)))))
6554 (mark (or mark gnus-del-mark)))
6556 (gnus-summary-mark-article nil mark no-expire)
6557 (zerop (gnus-summary-next-subject
6559 (and gnus-summary-goto-unread
6560 (not (eq gnus-summary-goto-unread 'never)))
6563 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
6564 (gnus-summary-recenter)
6565 (gnus-summary-position-point)
6566 (gnus-set-mode-line 'summary)
6569 (defun gnus-summary-mark-article-as-read (mark)
6570 "Mark the current article quickly as read with MARK."
6571 (let ((article (gnus-summary-article-number)))
6572 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6573 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6574 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6575 (setq gnus-newsgroup-reads
6576 (cons (cons article mark) gnus-newsgroup-reads))
6577 ;; Possibly remove from cache, if that is used.
6578 (and gnus-use-cache (gnus-cache-enter-remove-article article))
6579 ;; Allow the backend to change the mark.
6580 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
6581 ;; Check for auto-expiry.
6582 (when (and gnus-newsgroup-auto-expire
6583 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6584 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6585 (= mark gnus-ancient-mark)
6586 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6587 (= mark gnus-duplicate-mark)))
6588 (setq mark gnus-expirable-mark)
6589 (push article gnus-newsgroup-expirable))
6590 ;; Set the mark in the buffer.
6591 (gnus-summary-update-mark mark 'unread)
6594 (defun gnus-summary-mark-article-as-unread (mark)
6595 "Mark the current article quickly as unread with MARK."
6596 (let ((article (gnus-summary-article-number)))
6598 (gnus-error 1 "Unmarkable article")
6599 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6600 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6601 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
6602 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
6603 (cond ((= mark gnus-ticked-mark)
6604 (push article gnus-newsgroup-marked))
6605 ((= mark gnus-dormant-mark)
6606 (push article gnus-newsgroup-dormant))
6608 (push article gnus-newsgroup-unreads)))
6609 (setq gnus-newsgroup-reads
6610 (delq (assq article gnus-newsgroup-reads)
6611 gnus-newsgroup-reads))
6613 ;; See whether the article is to be put in the cache.
6615 (vectorp (gnus-summary-article-header article))
6617 (gnus-cache-possibly-enter-article
6618 gnus-newsgroup-name article
6619 (gnus-summary-article-header article)
6620 (= mark gnus-ticked-mark)
6621 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6624 (gnus-summary-update-mark mark 'unread))
6627 (defun gnus-summary-mark-article (&optional article mark no-expire)
6628 "Mark ARTICLE with MARK. MARK can be any character.
6629 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
6630 `??' (dormant) and `?E' (expirable).
6631 If MARK is nil, then the default character `?D' is used.
6632 If ARTICLE is nil, then the article on the current line will be
6634 ;; The mark might be a string.
6636 (setq mark (aref mark 0)))
6637 ;; If no mark is given, then we check auto-expiring.
6638 (and (not no-expire)
6639 gnus-newsgroup-auto-expire
6642 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
6643 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
6644 (= mark gnus-read-mark) (= mark gnus-souped-mark)
6645 (= mark gnus-duplicate-mark))))
6646 (setq mark gnus-expirable-mark))
6647 (let* ((mark (or mark gnus-del-mark))
6648 (article (or article (gnus-summary-article-number))))
6649 (or article (error "No article on current line"))
6650 (if (or (= mark gnus-unread-mark)
6651 (= mark gnus-ticked-mark)
6652 (= mark gnus-dormant-mark))
6653 (gnus-mark-article-as-unread article mark)
6654 (gnus-mark-article-as-read article mark))
6656 ;; See whether the article is to be put in the cache.
6658 (not (= mark gnus-canceled-mark))
6659 (vectorp (gnus-summary-article-header article))
6661 (gnus-cache-possibly-enter-article
6662 gnus-newsgroup-name article
6663 (gnus-summary-article-header article)
6664 (= mark gnus-ticked-mark)
6665 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
6667 (if (gnus-summary-goto-subject article nil t)
6668 (let ((buffer-read-only nil))
6669 (gnus-summary-show-thread)
6671 (gnus-summary-update-mark mark 'unread)
6674 (defun gnus-summary-update-secondary-mark (article)
6675 "Update the secondary (read, process, cache) mark."
6676 (gnus-summary-update-mark
6677 (cond ((memq article gnus-newsgroup-processable)
6679 ((memq article gnus-newsgroup-cached)
6681 ((memq article gnus-newsgroup-replied)
6683 ((memq article gnus-newsgroup-saved)
6685 (t gnus-unread-mark))
6687 (when (gnus-visual-p 'summary-highlight 'highlight)
6688 (run-hooks 'gnus-summary-update-hook))
6691 (defun gnus-summary-update-mark (mark type)
6692 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
6693 (buffer-read-only nil))
6694 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
6695 (and (looking-at "\r") (setq forward (1+ forward)))
6697 (<= (+ forward (point)) (point-max)))
6698 ;; Go to the right position on the line.
6699 (goto-char (+ forward (point)))
6700 ;; Replace the old mark with the new mark.
6701 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
6702 ;; Optionally update the marks by some user rule.
6703 (when (eq type 'unread)
6705 (gnus-data-find (gnus-summary-article-number)) mark)
6706 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
6708 (defun gnus-mark-article-as-read (article &optional mark)
6709 "Enter ARTICLE in the pertinent lists and remove it from others."
6710 ;; Make the article expirable.
6711 (let ((mark (or mark gnus-del-mark)))
6712 (if (= mark gnus-expirable-mark)
6713 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
6714 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
6715 ;; Remove from unread and marked lists.
6716 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6717 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
6718 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
6719 (push (cons article mark) gnus-newsgroup-reads)
6720 ;; Possibly remove from cache, if that is used.
6721 (when gnus-use-cache
6722 (gnus-cache-enter-remove-article article))))
6724 (defun gnus-mark-article-as-unread (article &optional mark)
6725 "Enter ARTICLE in the pertinent lists and remove it from others."
6726 (let ((mark (or mark gnus-ticked-mark)))
6727 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
6728 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
6729 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
6730 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
6732 ;; Unsuppress duplicates?
6733 (when gnus-suppress-duplicates
6734 (gnus-dup-unsuppress-article article))
6736 (cond ((= mark gnus-ticked-mark)
6737 (push article gnus-newsgroup-marked))
6738 ((= mark gnus-dormant-mark)
6739 (push article gnus-newsgroup-dormant))
6741 (push article gnus-newsgroup-unreads)))
6742 (setq gnus-newsgroup-reads
6743 (delq (assq article gnus-newsgroup-reads)
6744 gnus-newsgroup-reads))))
6746 (defalias 'gnus-summary-mark-as-unread-forward
6747 'gnus-summary-tick-article-forward)
6748 (make-obsolete 'gnus-summary-mark-as-unread-forward
6749 'gnus-summary-tick-article-forward)
6750 (defun gnus-summary-tick-article-forward (n)
6751 "Tick N articles forwards.
6752 If N is negative, tick backwards instead.
6753 The difference between N and the number of articles ticked is returned."
6755 (gnus-summary-mark-forward n gnus-ticked-mark))
6757 (defalias 'gnus-summary-mark-as-unread-backward
6758 'gnus-summary-tick-article-backward)
6759 (make-obsolete 'gnus-summary-mark-as-unread-backward
6760 'gnus-summary-tick-article-backward)
6761 (defun gnus-summary-tick-article-backward (n)
6762 "Tick N articles backwards.
6763 The difference between N and the number of articles ticked is returned."
6765 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
6767 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6768 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
6769 (defun gnus-summary-tick-article (&optional article clear-mark)
6770 "Mark current article as unread.
6771 Optional 1st argument ARTICLE specifies article number to be marked as unread.
6772 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
6774 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
6777 (defun gnus-summary-mark-as-read-forward (n)
6778 "Mark N articles as read forwards.
6779 If N is negative, mark backwards instead.
6780 The difference between N and the actual number of articles marked is
6783 (gnus-summary-mark-forward n gnus-del-mark t))
6785 (defun gnus-summary-mark-as-read-backward (n)
6786 "Mark the N articles as read backwards.
6787 The difference between N and the actual number of articles marked is
6790 (gnus-summary-mark-forward (- n) gnus-del-mark t))
6792 (defun gnus-summary-mark-as-read (&optional article mark)
6793 "Mark current article as read.
6794 ARTICLE specifies the article to be marked as read.
6795 MARK specifies a string to be inserted at the beginning of the line."
6796 (gnus-summary-mark-article article mark))
6798 (defun gnus-summary-clear-mark-forward (n)
6799 "Clear marks from N articles forward.
6800 If N is negative, clear backward instead.
6801 The difference between N and the number of marks cleared is returned."
6803 (gnus-summary-mark-forward n gnus-unread-mark))
6805 (defun gnus-summary-clear-mark-backward (n)
6806 "Clear marks from N articles backward.
6807 The difference between N and the number of marks cleared is returned."
6809 (gnus-summary-mark-forward (- n) gnus-unread-mark))
6811 (defun gnus-summary-mark-unread-as-read ()
6812 "Intended to be used by `gnus-summary-mark-article-hook'."
6813 (when (memq gnus-current-article gnus-newsgroup-unreads)
6814 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
6816 (defun gnus-summary-mark-read-and-unread-as-read ()
6817 "Intended to be used by `gnus-summary-mark-article-hook'."
6818 (let ((mark (gnus-summary-article-mark)))
6819 (when (or (gnus-unread-mark-p mark)
6820 (gnus-read-mark-p mark))
6821 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
6823 (defun gnus-summary-mark-region-as-read (point mark all)
6824 "Mark all unread articles between point and mark as read.
6825 If given a prefix, mark all articles between point and mark as read,
6826 even ticked and dormant ones."
6827 (interactive "r\nP")
6836 (memq (setq article (gnus-summary-article-number))
6837 gnus-newsgroup-unreads))
6838 (gnus-summary-mark-article article gnus-del-mark))
6840 (gnus-summary-find-next))))))
6842 (defun gnus-summary-mark-below (score mark)
6843 "Mark articles with score less than SCORE with MARK."
6844 (interactive "P\ncMark: ")
6845 (gnus-set-global-variables)
6846 (setq score (if score
6847 (prefix-numeric-value score)
6848 (or gnus-summary-default-score 0)))
6850 (set-buffer gnus-summary-buffer)
6851 (goto-char (point-min))
6854 (and (< (gnus-summary-article-score) score)
6855 (gnus-summary-mark-article nil mark))
6856 (gnus-summary-find-next)))))
6858 (defun gnus-summary-kill-below (&optional score)
6859 "Mark articles with score below SCORE as read."
6861 (gnus-set-global-variables)
6862 (gnus-summary-mark-below score gnus-killed-mark))
6864 (defun gnus-summary-clear-above (&optional score)
6865 "Clear all marks from articles with score above SCORE."
6867 (gnus-set-global-variables)
6868 (gnus-summary-mark-above score gnus-unread-mark))
6870 (defun gnus-summary-tick-above (&optional score)
6871 "Tick all articles with score above SCORE."
6873 (gnus-set-global-variables)
6874 (gnus-summary-mark-above score gnus-ticked-mark))
6876 (defun gnus-summary-mark-above (score mark)
6877 "Mark articles with score over SCORE with MARK."
6878 (interactive "P\ncMark: ")
6879 (gnus-set-global-variables)
6880 (setq score (if score
6881 (prefix-numeric-value score)
6882 (or gnus-summary-default-score 0)))
6884 (set-buffer gnus-summary-buffer)
6885 (goto-char (point-min))
6887 (if (> (gnus-summary-article-score) score)
6888 (gnus-summary-mark-article nil mark))
6890 (gnus-summary-find-next)))))
6892 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
6893 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
6894 (defun gnus-summary-limit-include-expunged (&optional no-error)
6895 "Display all the hidden articles that were expunged for low scores."
6897 (gnus-set-global-variables)
6898 (let ((buffer-read-only nil))
6899 (let ((scored gnus-newsgroup-scored)
6902 (or (gnus-summary-goto-subject (caar scored))
6903 (and (setq h (gnus-summary-article-header (caar scored)))
6904 (< (cdar scored) gnus-summary-expunge-below)
6905 (setq headers (cons h headers))))
6906 (setq scored (cdr scored)))
6908 (when (not no-error)
6909 (error "No expunged articles hidden."))
6910 (goto-char (point-min))
6911 (gnus-summary-prepare-unthreaded (nreverse headers))
6912 (goto-char (point-min))
6913 (gnus-summary-position-point)
6916 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
6917 "Mark all articles not marked as unread in this newsgroup as read.
6918 If prefix argument ALL is non-nil, all articles are marked as read.
6919 If QUIETLY is non-nil, no questions will be asked.
6920 If TO-HERE is non-nil, it should be a point in the buffer. All
6921 articles before this point will be marked as read.
6922 The number of articles marked as read is returned."
6924 (gnus-set-global-variables)
6927 (not gnus-interactive-catchup) ;Without confirmation?
6931 "Mark absolutely all articles as read? "
6932 "Mark all unread articles as read? ")))
6934 (not gnus-newsgroup-adaptive)
6935 (not gnus-newsgroup-auto-expire))
6938 (setq gnus-newsgroup-marked nil
6939 gnus-newsgroup-dormant nil))
6940 (setq gnus-newsgroup-unreads nil))
6941 ;; We actually mark all articles as canceled, which we
6942 ;; have to do when using auto-expiry or adaptive scoring.
6943 (gnus-summary-show-all-threads)
6944 (when (gnus-summary-first-subject (not all))
6946 (if to-here (< (point) to-here) t)
6947 (gnus-summary-mark-article-as-read gnus-catchup-mark)
6948 (gnus-summary-find-next (not all)))))
6950 (setq gnus-newsgroup-unreads nil))
6951 (gnus-set-mode-line 'summary)))
6952 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
6953 (when (and (not to-here) (eq 'nnvirtual (car method)))
6954 (nnvirtual-catchup-group
6955 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
6956 (gnus-summary-position-point)))
6958 (defun gnus-summary-catchup-to-here (&optional all)
6959 "Mark all unticked articles before the current one as read.
6960 If ALL is non-nil, also mark ticked and dormant articles as read."
6962 (gnus-set-global-variables)
6964 (gnus-save-hidden-threads
6965 (let ((beg (point)))
6966 ;; We check that there are unread articles.
6967 (when (or all (gnus-summary-find-prev))
6968 (gnus-summary-catchup all t beg)))))
6969 (gnus-summary-position-point))
6971 (defun gnus-summary-catchup-all (&optional quietly)
6972 "Mark all articles in this newsgroup as read."
6974 (gnus-set-global-variables)
6975 (gnus-summary-catchup t quietly))
6977 (defun gnus-summary-catchup-and-exit (&optional all quietly)
6978 "Mark all articles not marked as unread in this newsgroup as read, then exit.
6979 If prefix argument ALL is non-nil, all articles are marked as read."
6981 (gnus-set-global-variables)
6982 (gnus-summary-catchup all quietly nil 'fast)
6983 ;; Select next newsgroup or exit.
6984 (if (eq gnus-auto-select-next 'quietly)
6985 (gnus-summary-next-group nil)
6986 (gnus-summary-exit)))
6988 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
6989 "Mark all articles in this newsgroup as read, and then exit."
6991 (gnus-set-global-variables)
6992 (gnus-summary-catchup-and-exit t quietly))
6994 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
6995 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
6996 "Mark all articles in this group as read and select the next group.
6997 If given a prefix, mark all articles, unread as well as ticked, as
7000 (gnus-set-global-variables)
7002 (gnus-summary-catchup all))
7003 (gnus-summary-next-article t nil nil t))
7005 ;; Thread-based commands.
7007 (defun gnus-summary-articles-in-thread (&optional article)
7008 "Return a list of all articles in the current thread.
7009 If ARTICLE is non-nil, return all articles in the thread that starts
7011 (let* ((article (or article (gnus-summary-article-number)))
7012 (data (gnus-data-find-list article))
7013 (top-level (gnus-data-level (car data)))
7015 (cond ((null gnus-thread-operation-ignore-subject)
7016 (gnus-simplify-subject-re
7017 (mail-header-subject (gnus-data-header (car data)))))
7018 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7019 (gnus-simplify-subject-fuzzy
7020 (mail-header-subject (gnus-data-header (car data)))))
7022 (end-point (save-excursion
7023 (if (gnus-summary-go-to-next-thread)
7024 (point) (point-max))))
7027 (< (gnus-data-pos (car data)) end-point))
7028 (when (or (not top-subject)
7029 (string= top-subject
7030 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7031 (gnus-simplify-subject-fuzzy
7032 (mail-header-subject
7033 (gnus-data-header (car data))))
7034 (gnus-simplify-subject-re
7035 (mail-header-subject
7036 (gnus-data-header (car data)))))))
7037 (push (gnus-data-number (car data)) articles))
7038 (unless (and (setq data (cdr data))
7039 (> (gnus-data-level (car data)) top-level))
7041 ;; Return the list of articles.
7042 (nreverse articles)))
7044 (defun gnus-summary-rethread-current ()
7045 "Rethread the thread the current article is part of."
7047 (gnus-set-global-variables)
7048 (let* ((gnus-show-threads t)
7049 (article (gnus-summary-article-number))
7050 (id (mail-header-id (gnus-summary-article-header)))
7051 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7053 (error "No article on the current line"))
7054 (gnus-rebuild-thread id)
7055 (gnus-summary-goto-subject article)))
7057 (defun gnus-summary-reparent-thread ()
7058 "Make current article child of the marked (or previous) article.
7060 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7061 is non-nil or the Subject: of both articles are the same."
7063 (or (not (gnus-group-read-only-p))
7064 (error "The current newsgroup does not support article editing."))
7065 (or (<= (length gnus-newsgroup-processable) 1)
7066 (error "No more than one article may be marked."))
7067 (save-window-excursion
7068 (let ((gnus-article-buffer " *reparent*")
7069 (current-article (gnus-summary-article-number))
7070 ; first grab the marked article, otherwise one line up.
7071 (parent-article (if (not (null gnus-newsgroup-processable))
7072 (car gnus-newsgroup-processable)
7074 (if (eq (forward-line -1) 0)
7075 (gnus-summary-article-number)
7076 (error "Beginning of summary buffer."))))))
7077 (or (not (eq current-article parent-article))
7078 (error "An article may not be self-referential."))
7079 (let ((message-id (mail-header-id
7080 (gnus-summary-article-header parent-article))))
7081 (or (and message-id (not (equal message-id "")))
7082 (error "No message-id in desired parent."))
7083 (gnus-summary-select-article t t nil current-article)
7084 (set-buffer gnus-article-buffer)
7085 (setq buffer-read-only nil)
7086 (let ((buf (format "%s" (buffer-string))))
7089 (goto-char (point-min))
7090 (if (search-forward-regexp "^References: " nil t)
7091 (insert message-id " " )
7092 (insert "References: " message-id "\n"))
7093 (or (gnus-request-replace-article current-article
7094 (car gnus-article-current)
7095 gnus-article-buffer)
7096 (error "Couldn't replace article."))
7097 (set-buffer gnus-summary-buffer)
7098 (gnus-summary-unmark-all-processable)
7099 (gnus-summary-rethread-current)
7100 (gnus-message 3 "Article %d is now the child of article %d."
7101 current-article parent-article)))))
7103 (defun gnus-summary-toggle-threads (&optional arg)
7104 "Toggle showing conversation threads.
7105 If ARG is positive number, turn showing conversation threads on."
7107 (gnus-set-global-variables)
7108 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7109 (setq gnus-show-threads
7110 (if (null arg) (not gnus-show-threads)
7111 (> (prefix-numeric-value arg) 0)))
7112 (gnus-summary-prepare)
7113 (gnus-summary-goto-subject current)
7114 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7115 (gnus-summary-position-point)))
7117 (defun gnus-summary-show-all-threads ()
7120 (gnus-set-global-variables)
7122 (let ((buffer-read-only nil))
7123 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7124 (gnus-summary-position-point))
7126 (defun gnus-summary-show-thread ()
7127 "Show thread subtrees.
7128 Returns nil if no thread was there to be shown."
7130 (gnus-set-global-variables)
7131 (let ((buffer-read-only nil)
7133 ;; first goto end then to beg, to have point at beg after let
7134 (end (progn (end-of-line) (point)))
7135 (beg (progn (beginning-of-line) (point))))
7137 ;; Any hidden lines here?
7138 (search-forward "\r" end t)
7139 (subst-char-in-region beg end ?\^M ?\n t)
7141 (gnus-summary-position-point))))
7143 (defun gnus-summary-hide-all-threads ()
7144 "Hide all thread subtrees."
7146 (gnus-set-global-variables)
7148 (goto-char (point-min))
7149 (gnus-summary-hide-thread)
7150 (while (zerop (gnus-summary-next-thread 1 t))
7151 (gnus-summary-hide-thread)))
7152 (gnus-summary-position-point))
7154 (defun gnus-summary-hide-thread ()
7155 "Hide thread subtrees.
7156 Returns nil if no threads were there to be hidden."
7158 (gnus-set-global-variables)
7159 (let ((buffer-read-only nil)
7161 (article (gnus-summary-article-number)))
7163 ;; Go forward until either the buffer ends or the subthread
7165 (when (and (not (eobp))
7166 (or (zerop (gnus-summary-next-thread 1 t))
7167 (goto-char (point-max))))
7169 (if (and (> (point) start)
7170 (search-backward "\n" start t))
7172 (subst-char-in-region start (point) ?\n ?\^M)
7173 (gnus-summary-goto-subject article))
7176 ;;(gnus-summary-position-point)
7179 (defun gnus-summary-go-to-next-thread (&optional previous)
7180 "Go to the same level (or less) next thread.
7181 If PREVIOUS is non-nil, go to previous thread instead.
7182 Return the article number moved to, or nil if moving was impossible."
7183 (let ((level (gnus-summary-thread-level))
7184 (way (if previous -1 1))
7187 (while (and (not (eobp))
7188 (< level (gnus-summary-thread-level)))
7196 (gnus-summary-article-number)
7199 (defun gnus-summary-go-to-next-thread-old (&optional previous)
7200 "Go to the same level (or less) next thread.
7201 If PREVIOUS is non-nil, go to previous thread instead.
7202 Return the article number moved to, or nil if moving was impossible."
7203 (if (and (eq gnus-summary-make-false-root 'dummy)
7204 (gnus-summary-article-intangible-p))
7205 (let ((beg (point)))
7206 (while (and (zerop (forward-line 1))
7207 (not (gnus-summary-article-intangible-p))
7208 (not (zerop (save-excursion
7209 (gnus-summary-thread-level))))))
7215 (let* ((level (gnus-summary-thread-level))
7216 (article (gnus-summary-article-number))
7217 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
7220 (if (<= (gnus-data-level (car data)) level)
7221 (setq oart (gnus-data-number (car data))
7223 (setq data (cdr data))))
7225 (gnus-summary-goto-subject oart)))))
7227 (defun gnus-summary-next-thread (n &optional silent)
7228 "Go to the same level next N'th thread.
7229 If N is negative, search backward instead.
7230 Returns the difference between N and the number of skips actually
7233 If SILENT, don't output messages."
7235 (gnus-set-global-variables)
7236 (let ((backward (< n 0))
7240 (gnus-summary-go-to-next-thread backward))
7243 (gnus-summary-position-point))
7244 (when (and (not silent) (/= 0 n))
7245 (gnus-message 7 "No more threads"))
7248 (defun gnus-summary-prev-thread (n)
7249 "Go to the same level previous N'th thread.
7250 Returns the difference between N and the number of skips actually
7253 (gnus-set-global-variables)
7254 (gnus-summary-next-thread (- n)))
7256 (defun gnus-summary-go-down-thread ()
7257 "Go down one level in the current thread."
7258 (let ((children (gnus-summary-article-children)))
7260 (gnus-summary-goto-subject (car children)))))
7262 (defun gnus-summary-go-up-thread ()
7263 "Go up one level in the current thread."
7264 (let ((parent (gnus-summary-article-parent)))
7266 (gnus-summary-goto-subject parent))))
7268 (defun gnus-summary-down-thread (n)
7269 "Go down thread N steps.
7270 If N is negative, go up instead.
7271 Returns the difference between N and how many steps down that were
7274 (gnus-set-global-variables)
7278 (if up (gnus-summary-go-up-thread)
7279 (gnus-summary-go-down-thread)))
7281 (gnus-summary-position-point)
7282 (if (/= 0 n) (gnus-message 7 "Can't go further"))
7285 (defun gnus-summary-up-thread (n)
7286 "Go up thread N steps.
7287 If N is negative, go up instead.
7288 Returns the difference between N and how many steps down that were
7291 (gnus-set-global-variables)
7292 (gnus-summary-down-thread (- n)))
7294 (defun gnus-summary-top-thread ()
7295 "Go to the top of the thread."
7297 (gnus-set-global-variables)
7298 (while (gnus-summary-go-up-thread))
7299 (gnus-summary-article-number))
7301 (defun gnus-summary-kill-thread (&optional unmark)
7302 "Mark articles under current thread as read.
7303 If the prefix argument is positive, remove any kinds of marks.
7304 If the prefix argument is negative, tick articles instead."
7306 (gnus-set-global-variables)
7308 (setq unmark (prefix-numeric-value unmark)))
7309 (let ((articles (gnus-summary-articles-in-thread)))
7311 ;; Expand the thread.
7312 (gnus-summary-show-thread)
7313 ;; Mark all the articles.
7315 (gnus-summary-goto-subject (car articles))
7316 (cond ((null unmark)
7317 (gnus-summary-mark-article-as-read gnus-killed-mark))
7319 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7321 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7322 (setq articles (cdr articles))))
7323 ;; Hide killed subtrees.
7325 gnus-thread-hide-killed
7326 (gnus-summary-hide-thread))
7327 ;; If marked as read, go to next unread subject.
7329 ;; Go to next unread subject.
7330 (gnus-summary-next-subject 1 t)))
7331 (gnus-set-mode-line 'summary))
7333 ;; Summary sorting commands
7335 (defun gnus-summary-sort-by-number (&optional reverse)
7336 "Sort summary buffer by article number.
7337 Argument REVERSE means reverse order."
7339 (gnus-summary-sort 'number reverse))
7341 (defun gnus-summary-sort-by-author (&optional reverse)
7342 "Sort summary buffer by author name alphabetically.
7343 If case-fold-search is non-nil, case of letters is ignored.
7344 Argument REVERSE means reverse order."
7346 (gnus-summary-sort 'author reverse))
7348 (defun gnus-summary-sort-by-subject (&optional reverse)
7349 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
7350 If case-fold-search is non-nil, case of letters is ignored.
7351 Argument REVERSE means reverse order."
7353 (gnus-summary-sort 'subject reverse))
7355 (defun gnus-summary-sort-by-date (&optional reverse)
7356 "Sort summary buffer by date.
7357 Argument REVERSE means reverse order."
7359 (gnus-summary-sort 'date reverse))
7361 (defun gnus-summary-sort-by-score (&optional reverse)
7362 "Sort summary buffer by score.
7363 Argument REVERSE means reverse order."
7365 (gnus-summary-sort 'score reverse))
7367 (defun gnus-summary-sort (predicate reverse)
7368 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7369 (gnus-set-global-variables)
7370 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7371 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7372 (gnus-thread-sort-functions
7378 (gnus-article-sort-functions
7383 (,article t2 t1)))))
7385 (gnus-summary-prepare-hook nil))
7386 ;; We do the sorting by regenerating the threads.
7387 (gnus-summary-prepare)
7388 ;; Hide subthreads if needed.
7389 (when (and gnus-show-threads gnus-thread-hide-subtree)
7390 (gnus-summary-hide-all-threads))))
7392 ;; Summary saving commands.
7394 (defun gnus-summary-save-article (&optional n not-saved)
7395 "Save the current article using the default saver function.
7396 If N is a positive number, save the N next articles.
7397 If N is a negative number, save the N previous articles.
7398 If N is nil and any articles have been marked with the process mark,
7399 save those articles instead.
7400 The variable `gnus-default-article-saver' specifies the saver function."
7402 (gnus-set-global-variables)
7403 (let* ((articles (gnus-summary-work-articles n))
7404 (save-buffer (save-excursion
7405 (nnheader-set-temp-buffer " *Gnus Save*")))
7406 (num (length articles))
7407 header article file)
7409 (setq header (gnus-summary-article-header
7410 (setq article (pop articles))))
7411 (if (not (vectorp header))
7412 ;; This is a pseudo-article.
7413 (if (assq 'name header)
7414 (gnus-copy-file (cdr (assq 'name header)))
7415 (gnus-message 1 "Article %d is unsaveable" article))
7416 ;; This is a real article.
7417 (save-window-excursion
7418 (gnus-summary-select-article t nil nil article))
7420 (set-buffer save-buffer)
7422 (insert-buffer-substring gnus-original-article-buffer))
7423 (setq file (gnus-article-save save-buffer file num))
7424 (gnus-summary-remove-process-mark article)
7426 (gnus-summary-set-saved-mark article))))
7427 (gnus-kill-buffer save-buffer)
7428 (gnus-summary-position-point)
7431 (defun gnus-summary-pipe-output (&optional arg)
7432 "Pipe the current article to a subprocess.
7433 If N is a positive number, pipe the N next articles.
7434 If N is a negative number, pipe the N previous articles.
7435 If N is nil and any articles have been marked with the process mark,
7436 pipe those articles instead."
7438 (gnus-set-global-variables)
7439 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
7440 (gnus-summary-save-article arg t))
7441 (gnus-configure-windows 'pipe))
7443 (defun gnus-summary-save-article-mail (&optional arg)
7444 "Append the current article to an mail file.
7445 If N is a positive number, save the N next articles.
7446 If N is a negative number, save the N previous articles.
7447 If N is nil and any articles have been marked with the process mark,
7448 save those articles instead."
7450 (gnus-set-global-variables)
7451 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
7452 (gnus-summary-save-article arg)))
7454 (defun gnus-summary-save-article-rmail (&optional arg)
7455 "Append the current article to an rmail file.
7456 If N is a positive number, save the N next articles.
7457 If N is a negative number, save the N previous articles.
7458 If N is nil and any articles have been marked with the process mark,
7459 save those articles instead."
7461 (gnus-set-global-variables)
7462 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
7463 (gnus-summary-save-article arg)))
7465 (defun gnus-summary-save-article-file (&optional arg)
7466 "Append the current article to a file.
7467 If N is a positive number, save the N next articles.
7468 If N is a negative number, save the N previous articles.
7469 If N is nil and any articles have been marked with the process mark,
7470 save those articles instead."
7472 (gnus-set-global-variables)
7473 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
7474 (gnus-summary-save-article arg)))
7476 (defun gnus-summary-save-article-body-file (&optional arg)
7477 "Append the current article body to a file.
7478 If N is a positive number, save the N next articles.
7479 If N is a negative number, save the N previous articles.
7480 If N is nil and any articles have been marked with the process mark,
7481 save those articles instead."
7483 (gnus-set-global-variables)
7484 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
7485 (gnus-summary-save-article arg)))
7487 (defun gnus-get-split-value (methods)
7488 "Return a value based on the split METHODS."
7489 (let (split-name method result match)
7492 (set-buffer gnus-original-article-buffer)
7494 (nnheader-narrow-to-headers)
7496 (goto-char (point-min))
7497 (setq method (pop methods))
7498 (setq match (car method))
7501 ;; Regular expression.
7503 (re-search-forward match nil t)
7505 ((gnus-functionp match)
7509 (setq result (funcall match gnus-newsgroup-name))))
7514 (setq result (eval match)))))
7515 (setq split-name (append (cdr method) split-name))
7516 (cond ((stringp result)
7517 (push result split-name))
7519 (setq split-name (append result split-name)))))))))
7522 (defun gnus-read-move-group-name (prompt default articles prefix)
7523 "Read a group name."
7524 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
7525 (minibuffer-confirm-incomplete nil) ; XEmacs
7533 (car (gnus-find-method-for-group
7535 gnus-valid-select-methods))
7536 (push (list (symbol-name g)) group-map)))
7537 gnus-active-hashtb))
7541 (if (> (length articles) 1)
7542 (format "these %d articles" (length articles))
7547 (gnus-completing-read default prom
7548 group-map nil nil prefix
7549 'gnus-group-history))
7550 ((= 1 (length split-name))
7551 (gnus-completing-read (car split-name) prom group-map
7553 'gnus-group-history))
7555 (gnus-completing-read nil prom
7556 (mapcar (lambda (el) (list el))
7557 (nreverse split-name))
7559 'gnus-group-history)))))
7561 (if (or (string= to-newsgroup "")
7562 (string= to-newsgroup prefix))
7563 (setq to-newsgroup (or default "")))
7564 (or (gnus-active to-newsgroup)
7565 (gnus-activate-group to-newsgroup)
7566 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
7568 (or (and (gnus-request-create-group
7569 to-newsgroup (gnus-group-name-to-method to-newsgroup))
7570 (gnus-activate-group to-newsgroup nil nil
7571 (gnus-group-name-to-method
7573 (error "Couldn't create group %s" to-newsgroup)))
7574 (error "No such group: %s" to-newsgroup)))
7577 ;; Summary extract commands
7579 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
7580 (let ((buffer-read-only nil)
7581 (article (gnus-summary-article-number))
7583 (or (gnus-summary-goto-subject article)
7584 (error (format "No such article: %d" article)))
7585 (gnus-summary-position-point)
7586 ;; If all commands are to be bunched up on one line, we collect
7588 (if gnus-view-pseudos-separately
7590 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
7593 (setq action (cdr (assq 'action (car ps))))
7594 (setq files (list (cdr (assq 'name (car ps)))))
7595 (while (and ps (cdr ps)
7596 (string= (or action "1")
7597 (or (cdr (assq 'action (cadr ps))) "2")))
7598 (setq files (cons (cdr (assq 'name (cadr ps))) files))
7599 (setcdr ps (cddr ps)))
7602 (if (not (string-match "%s" action))
7603 (setq files (cons " " files)))
7604 (setq files (cons " " files))
7605 (and (assq 'execute (car ps))
7606 (setcdr (assq 'execute (car ps))
7607 (funcall (if (string-match "%s" action)
7610 (mapconcat (lambda (f) f) files " ")))))
7611 (setq ps (cdr ps)))))
7612 (if (and gnus-view-pseudos (not not-view))
7614 (and (assq 'execute (car pslist))
7615 (gnus-execute-command (cdr (assq 'execute (car pslist)))
7616 (eq gnus-view-pseudos 'not-confirm)))
7617 (setq pslist (cdr pslist)))
7620 (setq after-article (or (cdr (assq 'article (car pslist)))
7621 (gnus-summary-article-number)))
7622 (gnus-summary-goto-subject after-article)
7625 (insert " " (file-name-nondirectory
7626 (cdr (assq 'name (car pslist))))
7627 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
7629 (forward-line -1) ; back to `b'
7630 (gnus-add-text-properties
7631 b (1- e) (list 'gnus-number gnus-reffed-article-number
7632 gnus-mouse-face-prop gnus-mouse-face))
7634 after-article gnus-reffed-article-number
7635 gnus-unread-mark b (car pslist) 0 (- e b))
7636 (push gnus-reffed-article-number gnus-newsgroup-unreads)
7637 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
7638 (setq pslist (cdr pslist)))))))
7640 (defun gnus-pseudos< (p1 p2)
7641 (let ((c1 (cdr (assq 'action p1)))
7642 (c2 (cdr (assq 'action p2))))
7643 (and c1 c2 (string< c1 c2))))
7645 (defun gnus-request-pseudo-article (props)
7646 (cond ((assq 'execute props)
7647 (gnus-execute-command (cdr (assq 'execute props)))))
7648 (let ((gnus-current-article (gnus-summary-article-number)))
7649 (run-hooks 'gnus-mark-article-hook)))
7651 (defun gnus-execute-command (command &optional automatic)
7653 (gnus-article-setup-buffer)
7654 (set-buffer gnus-article-buffer)
7655 (setq buffer-read-only nil)
7656 (let ((command (if automatic command (read-string "Command: " command)))
7657 ;; Just binding this here doesn't help, because there might
7658 ;; be output from the process after exiting the scope of
7660 ;; (buffer-read-only nil)
7663 (insert "$ " command "\n\n")
7664 (if gnus-view-pseudo-asynchronously
7665 (start-process "gnus-execute" nil shell-file-name
7666 shell-command-switch command)
7667 (call-process shell-file-name nil t nil
7668 shell-command-switch command)))))
7670 ;; Summary kill commands.
7672 (defun gnus-summary-edit-global-kill (article)
7673 "Edit the \"global\" kill file."
7674 (interactive (list (gnus-summary-article-number)))
7675 (gnus-set-global-variables)
7676 (gnus-group-edit-global-kill article))
7678 (defun gnus-summary-edit-local-kill ()
7679 "Edit a local kill file applied to the current newsgroup."
7681 (gnus-set-global-variables)
7682 (setq gnus-current-headers (gnus-summary-article-header))
7683 (gnus-set-global-variables)
7684 (gnus-group-edit-local-kill
7685 (gnus-summary-article-number) gnus-newsgroup-name))
7689 (defun gnus-read-header (id &optional header)
7690 "Read the headers of article ID and enter them into the Gnus system."
7691 (let ((group gnus-newsgroup-name)
7692 (gnus-override-method
7693 (and (gnus-news-group-p gnus-newsgroup-name)
7694 gnus-refer-article-method))
7696 ;; First we check to see whether the header in question is already
7699 ;; This is a Message-ID.
7700 (setq header (or header (gnus-id-to-header id)))
7701 ;; This is an article number.
7702 (setq header (or header (gnus-summary-article-header id))))
7704 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
7705 ;; We have found the header.
7707 ;; We have to really fetch the header to this article.
7708 (when (setq where (gnus-request-head id group))
7710 (set-buffer nntp-server-buffer)
7711 (goto-char (point-max))
7713 (goto-char (point-min))
7717 ((cdr where) (cdr where))
7718 (header (mail-header-number header))
7719 (t gnus-reffed-article-number))
7721 (insert " Article retrieved.\n"))
7723 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
7724 ; (setcar (gnus-id-to-thread id) nil))
7725 (if (not (setq header (car (gnus-get-newsgroup-headers))))
7726 () ; Malformed head.
7727 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
7728 (if (and (stringp id)
7729 (not (string= (gnus-group-real-name group)
7731 ;; If we fetched by Message-ID and the article came
7732 ;; from a different group, we fudge some bogus article
7733 ;; numbers for this article.
7734 (mail-header-set-number header gnus-reffed-article-number))
7735 (decf gnus-reffed-article-number)
7736 (gnus-remove-header (mail-header-number header))
7737 (push header gnus-newsgroup-headers)
7738 (setq gnus-current-headers header)
7739 (push (mail-header-number header) gnus-newsgroup-limit))
7742 (defun gnus-remove-header (number)
7743 "Remove header NUMBER from `gnus-newsgroup-headers'."
7744 (if (and gnus-newsgroup-headers
7745 (= number (mail-header-number (car gnus-newsgroup-headers))))
7746 (pop gnus-newsgroup-headers)
7747 (let ((headers gnus-newsgroup-headers))
7748 (while (and (cdr headers)
7749 (not (= number (mail-header-number (cadr headers)))))
7752 (setcdr headers (cddr headers))))))
7755 ;;; summary highlights
7758 (defun gnus-highlight-selected-summary ()
7759 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7760 ;; Highlight selected article in summary buffer
7761 (when gnus-summary-selected-face
7763 (let* ((beg (progn (beginning-of-line) (point)))
7764 (end (progn (end-of-line) (point)))
7765 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
7766 (from (if (get-text-property beg gnus-mouse-face-prop)
7768 (1+ (or (next-single-property-change
7769 beg gnus-mouse-face-prop nil end)
7774 (1- (or (next-single-property-change
7775 from gnus-mouse-face-prop nil end)
7777 ;; If no mouse-face prop on line we will have to = from = end,
7778 ;; so we highlight the entire line instead.
7779 (when (= (+ to 2) from)
7782 (if gnus-newsgroup-selected-overlay
7783 ;; Move old overlay.
7785 gnus-newsgroup-selected-overlay from to (current-buffer))
7786 ;; Create new overlay.
7788 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
7789 'face gnus-summary-selected-face))))))
7791 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
7792 (defun gnus-summary-highlight-line ()
7793 "Highlight current line according to `gnus-summary-highlight'."
7794 (let* ((list gnus-summary-highlight)
7796 (end (progn (end-of-line) (point)))
7797 ;; now find out where the line starts and leave point there.
7798 (beg (progn (beginning-of-line) (point)))
7799 (article (gnus-summary-article-number))
7800 (score (or (cdr (assq (or article gnus-current-article)
7801 gnus-newsgroup-scored))
7802 gnus-summary-default-score 0))
7803 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
7804 (inhibit-read-only t))
7805 ;; Eval the cars of the lists until we find a match.
7806 (let ((default gnus-summary-default-score))
7808 (not (eval (caar list))))
7809 (setq list (cdr list))))
7810 (let ((face (cdar list)))
7811 (unless (eq face (get-text-property beg 'face))
7812 (gnus-put-text-property
7814 (setq face (if (boundp face) (symbol-value face) face)))
7815 (when gnus-summary-highlight-line-function
7816 (funcall gnus-summary-highlight-line-function article face))))
7821 ;;; gnus-sum.el ends here