Output alists with dotted pair notation in .dir-locals.el
[emacs.git] / lisp / gnus / gnus-sum.el
blobf56b822ac579153ae9f0e97ab67fc0e6d20b6260
1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;;; Code:
27 (require 'cl-lib)
29 (defvar tool-bar-mode)
30 (defvar gnus-tmp-header)
32 (require 'gnus)
33 (require 'gnus-group)
34 (require 'gnus-spec)
35 (require 'gnus-range)
36 (require 'gnus-int)
37 (require 'gnus-undo)
38 (require 'gnus-util)
39 (require 'gmm-utils)
40 (require 'mm-decode)
41 (require 'nnoo)
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
55 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
56 (autoload 'nnir-article-group "nnir" nil nil 'macro)
58 (defcustom gnus-kill-summary-on-exit t
59 "If non-nil, kill the summary buffer when you exit from it.
60 If nil, the summary will become a \"*Dead Summary*\" buffer, and
61 it will be killed sometime later."
62 :group 'gnus-summary-exit
63 :type 'boolean)
65 (defcustom gnus-summary-next-group-on-exit t
66 "If non-nil, go to the next unread newsgroup on summary exit.
67 See `gnus-group-goto-unread'."
68 :link '(custom-manual "(gnus)Group Maneuvering")
69 :group 'gnus-summary-exit
70 :version "23.1" ;; No Gnus
71 :type 'boolean)
73 (defcustom gnus-summary-stop-at-end-of-message nil
74 "If non-nil, don't select the next message when using `SPC'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-maneuvering
77 :version "24.1"
78 :type 'boolean)
80 (defcustom gnus-fetch-old-headers nil
81 "Non-nil means that Gnus will try to build threads by grabbing old headers.
82 If an unread article in the group refers to an older, already
83 read (or just marked as read) article, the old article will not
84 normally be displayed in the Summary buffer. If this variable is
85 t, Gnus will attempt to grab the headers to the old articles, and
86 thereby build complete threads. If it has the value `some', all
87 old headers will be fetched but only enough headers to connect
88 otherwise loose threads will be displayed. This variable can
89 also be a number. In that case, no more than that number of old
90 headers will be fetched. If it has the value `invisible', all
91 old headers will be fetched, but none will be displayed.
93 The server has to support NOV for any of this to work.
95 This feature can seriously impact performance it ignores all
96 locally cached header entries. Setting it to t for groups for a
97 server that doesn't expire articles (such as news.gmane.org),
98 leads to very slow summary generation."
99 :group 'gnus-thread
100 :type '(choice (const :tag "off" nil)
101 (const :tag "on" t)
102 (const some)
103 (const invisible)
104 number
105 (sexp :menu-tag "other" t)))
107 (defcustom gnus-refer-thread-limit 500
108 "The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
109 If t, fetch all the available old headers."
110 :group 'gnus-thread
111 :type '(choice number
112 (sexp :menu-tag "other" t)))
114 (defcustom gnus-refer-thread-use-nnir nil
115 "Use nnir to search an entire server when referring threads. A
116 nil value will only search for thread-related articles in the
117 current group."
118 :version "24.1"
119 :group 'gnus-thread
120 :type 'boolean)
122 (defcustom gnus-refer-thread-limit-to-thread nil
123 "If non-nil referring a thread will limit the summary buffer to
124 articles in the thread. A nil value will add the thread articles
125 to the summary buffer."
126 :version "25.1"
127 :group 'gnus-thread
128 :type 'boolean)
130 (defcustom gnus-summary-make-false-root 'adopt
131 "nil means that Gnus won't gather loose threads.
132 If the root of a thread has expired or been read in a previous
133 session, the information necessary to build a complete thread has been
134 lost. Instead of having many small sub-threads from this original thread
135 scattered all over the summary buffer, Gnus can gather them.
137 If non-nil, Gnus will try to gather all loose sub-threads from an
138 original thread into one large thread.
140 If this variable is non-nil, it should be one of `none', `adopt',
141 `dummy' or `empty'.
143 If this variable is `none', Gnus will not make a false root, but just
144 present the sub-threads after another.
145 If this variable is `dummy', Gnus will create a dummy root that will
146 have all the sub-threads as children.
147 If this variable is `adopt', Gnus will make one of the \"children\"
148 the parent and mark all the step-children as such.
149 If this variable is `empty', the \"children\" are printed with empty
150 subject fields. (Or rather, they will be printed with a string
151 given by the `gnus-summary-same-subject' variable.)"
152 :group 'gnus-thread
153 :type '(choice (const :tag "off" nil)
154 (const none)
155 (const dummy)
156 (const adopt)
157 (const empty)))
159 (defcustom gnus-summary-make-false-root-always nil
160 "Always make a false dummy root."
161 :version "22.1"
162 :group 'gnus-thread
163 :type 'boolean)
165 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
166 "A regexp to match subjects to be excluded from loose thread gathering.
167 As loose thread gathering is done on subjects only, that means that
168 there can be many false gatherings performed. By rooting out certain
169 common subjects, gathering might become saner."
170 :group 'gnus-thread
171 :type 'regexp)
173 (defcustom gnus-summary-gather-subject-limit nil
174 "Maximum length of subject comparisons when gathering loose threads.
175 Use nil to compare full subjects. Setting this variable to a low
176 number will help gather threads that have been corrupted by
177 newsreaders chopping off subject lines, but it might also mean that
178 unrelated articles that have subject that happen to begin with the
179 same few characters will be incorrectly gathered.
181 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
182 comparing subjects."
183 :group 'gnus-thread
184 :type '(choice (const :tag "off" nil)
185 (const fuzzy)
186 (sexp :menu-tag "on" t)))
188 (defcustom gnus-simplify-subject-functions nil
189 "List of functions taking a string argument that simplify subjects.
190 The functions are applied recursively.
192 Useful functions to put in this list include:
193 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
194 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
195 :group 'gnus-thread
196 :type '(repeat function))
198 (defcustom gnus-simplify-ignored-prefixes nil
199 "Remove matches for this regexp from subject lines when simplifying fuzzily."
200 :group 'gnus-thread
201 :type '(choice (const :tag "off" nil)
202 regexp))
204 (defcustom gnus-build-sparse-threads nil
205 "If non-nil, fill in the gaps in threads.
206 If `some', only fill in the gaps that are needed to tie loose threads
207 together. If `more', fill in all leaf nodes that Gnus can find. If
208 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
209 :group 'gnus-thread
210 :type '(choice (const :tag "off" nil)
211 (const some)
212 (const more)
213 (sexp :menu-tag "all" t)))
215 (defcustom gnus-summary-thread-gathering-function
216 'gnus-gather-threads-by-subject
217 "Function used for gathering loose threads.
218 There are two pre-defined functions: `gnus-gather-threads-by-subject',
219 which only takes Subjects into consideration; and
220 `gnus-gather-threads-by-references', which compared the References
221 headers of the articles to find matches."
222 :group 'gnus-thread
223 :type '(radio (function-item gnus-gather-threads-by-subject)
224 (function-item gnus-gather-threads-by-references)
225 (function :tag "other")))
227 (defcustom gnus-summary-same-subject ""
228 "String indicating that the current article has the same subject as the previous.
229 This variable will only be used if the value of
230 `gnus-summary-make-false-root' is `empty'."
231 :group 'gnus-summary-format
232 :type 'string)
234 (defcustom gnus-summary-goto-unread nil
235 "If t, many commands will go to the next unread article.
236 This applies to marking commands as well as other commands that
237 \"naturally\" select the next article, like, for instance, `SPC' at
238 the end of an article.
240 If nil, the marking commands do NOT go to the next unread article
241 \(they go to the next article instead). If `never', commands that
242 usually go to the next unread article, will go to the next article,
243 whether it is read or not."
244 :version "24.1"
245 :group 'gnus-summary-marks
246 :link '(custom-manual "(gnus)Setting Marks")
247 :type '(choice (const :tag "off" nil)
248 (const never)
249 (sexp :menu-tag "on" t)))
251 (defcustom gnus-summary-default-score 0
252 "Default article score level.
253 All scores generated by the score files will be added to this score.
254 If this variable is nil, scoring will be disabled."
255 :group 'gnus-score-default
256 :type '(choice (const :tag "disable")
257 integer))
259 (defcustom gnus-summary-default-high-score 0
260 "Default threshold for a high scored article.
261 An article will be highlighted as high scored if its score is greater
262 than this score."
263 :version "22.1"
264 :group 'gnus-score-default
265 :type 'integer)
267 (defcustom gnus-summary-default-low-score 0
268 "Default threshold for a low scored article.
269 An article will be highlighted as low scored if its score is smaller
270 than this score."
271 :version "22.1"
272 :group 'gnus-score-default
273 :type 'integer)
275 (defcustom gnus-summary-zcore-fuzz 0
276 "Fuzziness factor for the zcore in the summary buffer.
277 Articles with scores closer than this to `gnus-summary-default-score'
278 will not be marked."
279 :group 'gnus-summary-format
280 :type 'integer)
282 (defcustom gnus-simplify-subject-fuzzy-regexp nil
283 "Strings to be removed when doing fuzzy matches.
284 This can either be a regular expression or list of regular expressions
285 that will be removed from subject strings if fuzzy subject
286 simplification is selected."
287 :group 'gnus-thread
288 :type '(repeat regexp))
290 (defcustom gnus-show-threads t
291 "If non-nil, display threads in summary mode."
292 :group 'gnus-thread
293 :type 'boolean)
295 (defcustom gnus-thread-hide-subtree nil
296 "If non-nil, hide all threads initially.
297 This can be a predicate specifier which says which threads to hide.
298 If threads are hidden, you have to run the command
299 `gnus-summary-show-thread' by hand or select an article."
300 :group 'gnus-thread
301 :type '(radio (sexp :format "Non-nil\n"
302 :match (lambda (widget value)
303 (not (or (consp value) (functionp value))))
304 :value t)
305 (const nil)
306 (sexp :tag "Predicate specifier")))
308 (defcustom gnus-thread-hide-killed t
309 "If non-nil, hide killed threads automatically."
310 :group 'gnus-thread
311 :type 'boolean)
313 (defcustom gnus-thread-ignore-subject t
314 "If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
315 If nil, articles that have different subjects from their parents will
316 start separate threads."
317 :group 'gnus-thread
318 :type 'boolean)
320 (defcustom gnus-thread-operation-ignore-subject t
321 "If non-nil, subjects will be ignored when doing thread commands.
322 This affects commands like `gnus-summary-kill-thread' and
323 `gnus-summary-lower-thread'.
325 If this variable is nil, articles in the same thread with different
326 subjects will not be included in the operation in question. If this
327 variable is `fuzzy', only articles that have subjects that are fuzzily
328 equal will be included."
329 :group 'gnus-thread
330 :type '(choice (const :tag "off" nil)
331 (const fuzzy)
332 (sexp :tag "on" t)))
334 (defcustom gnus-thread-indent-level 4
335 "Number that says how much each sub-thread should be indented."
336 :group 'gnus-thread
337 :type 'integer)
339 (defcustom gnus-auto-extend-newsgroup t
340 "If non-nil, extend newsgroup forward and backward when requested."
341 :group 'gnus-summary-choose
342 :type 'boolean)
344 (defcustom gnus-auto-select-first t
345 "If non-nil, select an article on group entry.
346 An article is selected automatically when entering a group
347 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
348 `gnus-summary-catchup-and-goto-next-group'.
350 Which article is selected is controlled by the variable
351 `gnus-auto-select-subject'.
353 If you want to prevent automatic selection of articles in some
354 newsgroups, set the variable to nil in `gnus-select-group-hook'."
355 ;; Commands include...
356 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
358 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
359 :group 'gnus-group-select
360 :type '(choice (const :tag "none" nil)
361 (sexp :menu-tag "first" t)))
363 (defcustom gnus-auto-select-subject 'unseen-or-unread
364 "Says what subject to place under point when entering a group.
366 This variable can either be the symbols `first' (place point on the
367 first subject), `unread' (place point on the subject line of the first
368 unread article), `best' (place point on the subject line of the
369 highest-scored article), `unseen' (place point on the subject line of
370 the first unseen article), `unseen-or-unread' (place point on the subject
371 line of the first unseen article or, if all articles have been seen, on the
372 subject line of the first unread article), or a function to be called to
373 place point on some subject line."
374 :version "24.1"
375 :group 'gnus-group-select
376 :type '(choice (const best)
377 (const unread)
378 (const first)
379 (const unseen)
380 (const unseen-or-unread)
381 (function :tag "Function to call")))
383 (defcustom gnus-auto-select-next t
384 "If non-nil, offer to go to the next group from the end of the previous.
385 If the value is t and the next newsgroup is empty, Gnus will exit
386 summary mode and go back to group mode. If the value is neither nil
387 nor t, Gnus will select the following unread newsgroup. In
388 particular, if the value is the symbol `quietly', the next unread
389 newsgroup will be selected without any confirmation, and if it is
390 `almost-quietly', the next group will be selected without any
391 confirmation if you are located on the last article in the group.
392 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
393 will go to the next group without confirmation."
394 :group 'gnus-summary-maneuvering
395 :type '(choice (const :tag "off" nil)
396 (const quietly)
397 (const almost-quietly)
398 (const slightly-quietly)
399 (sexp :menu-tag "on" t)))
401 (defcustom gnus-auto-select-same nil
402 "If non-nil, select the next article with the same subject.
403 If there are no more articles with the same subject, go to
404 the first unread article."
405 :group 'gnus-summary-maneuvering
406 :type 'boolean)
408 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
409 "What article should be selected after exiting an ephemeral group.
410 Valid values include:
412 `next'
413 Select the next article.
414 `next-unread'
415 Select the next unread article.
416 `next-noselect'
417 Move the cursor to the next article. This is the default.
418 `next-unread-noselect'
419 Move the cursor to the next unread article.
421 If it has any other value or there is no next (unread) article, the
422 article selected before entering to the ephemeral group will appear."
423 :version "23.1" ;; No Gnus
424 :group 'gnus-summary-maneuvering
425 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
426 (const next) (const next-unread)
427 (const next-noselect) (const next-unread-noselect)
428 (sexp :tag "other" :value nil)))
430 (defcustom gnus-auto-goto-ignores 'unfetched
431 "Says how to handle unfetched articles when maneuvering.
433 This variable can either be the symbols nil (maneuver to any
434 article), `undownloaded' (maneuvering while unplugged ignores articles
435 that have not been fetched), `always-undownloaded' (maneuvering always
436 ignores articles that have not been fetched), `unfetched' (maneuvering
437 ignores articles whose headers have not been fetched).
439 NOTE: The list of unfetched articles will always be nil when plugged
440 and, when unplugged, a subset of the undownloaded article list."
441 :version "22.1"
442 :group 'gnus-summary-maneuvering
443 :type '(choice (const :tag "None" nil)
444 (const :tag "Undownloaded when unplugged" undownloaded)
445 (const :tag "Undownloaded" always-undownloaded)
446 (const :tag "Unfetched" unfetched)))
448 (defcustom gnus-summary-check-current nil
449 "If non-nil, consider the current article when moving.
450 The \"unread\" movement commands will stay on the same line if the
451 current article is unread."
452 :group 'gnus-summary-maneuvering
453 :type 'boolean)
455 (defcustom gnus-auto-center-summary
456 (max (or (bound-and-true-p scroll-margin) 0) 2)
457 "If non-nil, always center the current summary buffer.
458 In particular, if `vertical' do only vertical recentering. If non-nil
459 and non-`vertical', do both horizontal and vertical recentering."
460 :group 'gnus-summary-maneuvering
461 :type '(choice (const :tag "none" nil)
462 (const vertical)
463 (integer :tag "height")
464 (sexp :menu-tag "both" t)))
466 (defcustom gnus-auto-center-group t
467 "If non-nil, always center the group buffer."
468 :group 'gnus-summary-maneuvering
469 :type 'boolean)
471 (defcustom gnus-show-all-headers nil
472 "If non-nil, don't hide any headers."
473 :group 'gnus-article-hiding
474 :group 'gnus-article-headers
475 :type 'boolean)
477 (defcustom gnus-summary-ignore-duplicates nil
478 "If non-nil, ignore articles with identical Message-ID headers."
479 :group 'gnus-summary
480 :type 'boolean)
482 (defcustom gnus-single-article-buffer nil
483 "If non-nil, display all articles in the same buffer.
484 If nil, each group will get its own article buffer."
485 :version "24.1"
486 :group 'gnus-article-various
487 :type 'boolean)
489 (defcustom gnus-widen-article-window nil
490 "If non-nil, selecting the article buffer will display only the article buffer."
491 :version "24.1"
492 :group 'gnus-article-various
493 :type 'boolean)
495 (defcustom gnus-break-pages t
496 "If non-nil, do page breaking on articles.
497 The page delimiter is specified by the `gnus-page-delimiter'
498 variable."
499 :group 'gnus-article-various
500 :type 'boolean)
502 (defcustom gnus-move-split-methods nil
503 "Variable used to suggest where articles are to be moved to.
504 It uses the same syntax as the `gnus-split-methods' variable.
505 However, whereas `gnus-split-methods' specifies file names as targets,
506 this variable specifies group names."
507 :group 'gnus-summary-mail
508 :type '(repeat (choice (list :value (fun) function)
509 (cons :value ("" "") regexp (repeat string))
510 (sexp :value nil))))
512 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
513 "Function used to compute default prefix for article move/copy/etc prompts.
514 The function should take one argument, a group name, and return a
515 string with the suggested prefix."
516 :group 'gnus-summary-mail
517 :type 'function)
519 ;; FIXME: Although the custom type is `character' for the following variables,
520 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
522 (defcustom gnus-unread-mark ? ;Whitespace
523 "Mark used for unread articles."
524 :group 'gnus-summary-marks
525 :type 'character)
527 (defcustom gnus-ticked-mark ?!
528 "Mark used for ticked articles."
529 :group 'gnus-summary-marks
530 :type 'character)
532 (defcustom gnus-dormant-mark ??
533 "Mark used for dormant articles."
534 :group 'gnus-summary-marks
535 :type 'character)
537 (defcustom gnus-del-mark ?r
538 "Mark used for del'd articles."
539 :group 'gnus-summary-marks
540 :type 'character)
542 (defcustom gnus-read-mark ?R
543 "Mark used for read articles."
544 :group 'gnus-summary-marks
545 :type 'character)
547 (defcustom gnus-expirable-mark ?E
548 "Mark used for expirable articles."
549 :group 'gnus-summary-marks
550 :type 'character)
552 (defcustom gnus-killed-mark ?K
553 "Mark used for killed articles."
554 :group 'gnus-summary-marks
555 :type 'character)
557 (defcustom gnus-spam-mark ?$
558 "Mark used for spam articles."
559 :version "22.1"
560 :group 'gnus-summary-marks
561 :type 'character)
563 (defcustom gnus-kill-file-mark ?X
564 "Mark used for articles killed by kill files."
565 :group 'gnus-summary-marks
566 :type 'character)
568 (defcustom gnus-low-score-mark ?Y
569 "Mark used for articles with a low score."
570 :group 'gnus-summary-marks
571 :type 'character)
573 (defcustom gnus-catchup-mark ?C
574 "Mark used for articles that are caught up."
575 :group 'gnus-summary-marks
576 :type 'character)
578 (defcustom gnus-replied-mark ?A
579 "Mark used for articles that have been replied to."
580 :group 'gnus-summary-marks
581 :type 'character)
583 (defcustom gnus-forwarded-mark ?F
584 "Mark used for articles that have been forwarded."
585 :version "22.1"
586 :group 'gnus-summary-marks
587 :type 'character)
589 (defcustom gnus-recent-mark ?N
590 "Mark used for articles that are recent."
591 :version "22.1"
592 :group 'gnus-summary-marks
593 :type 'character)
595 (defcustom gnus-cached-mark ?*
596 "Mark used for articles that are in the cache."
597 :group 'gnus-summary-marks
598 :type 'character)
600 (defcustom gnus-saved-mark ?S
601 "Mark used for articles that have been saved."
602 :group 'gnus-summary-marks
603 :type 'character)
605 (defcustom gnus-unseen-mark ?.
606 "Mark used for articles that haven't been seen."
607 :version "22.1"
608 :group 'gnus-summary-marks
609 :type 'character)
611 (defcustom gnus-no-mark ? ;Whitespace
612 "Mark used for articles that have no other secondary mark."
613 :version "22.1"
614 :group 'gnus-summary-marks
615 :type 'character)
617 (defcustom gnus-ancient-mark ?O
618 "Mark used for ancient articles."
619 :group 'gnus-summary-marks
620 :type 'character)
622 (defcustom gnus-sparse-mark ?Q
623 "Mark used for sparsely reffed articles."
624 :group 'gnus-summary-marks
625 :type 'character)
627 (defcustom gnus-canceled-mark ?G
628 "Mark used for canceled articles."
629 :group 'gnus-summary-marks
630 :type 'character)
632 (defcustom gnus-duplicate-mark ?M
633 "Mark used for duplicate articles."
634 :group 'gnus-summary-marks
635 :type 'character)
637 (defcustom gnus-undownloaded-mark ?-
638 "Mark used for articles that weren't downloaded."
639 :version "22.1"
640 :group 'gnus-summary-marks
641 :type 'character)
643 (defcustom gnus-downloaded-mark ?+
644 "Mark used for articles that were downloaded."
645 :group 'gnus-summary-marks
646 :type 'character)
648 (defcustom gnus-downloadable-mark ?%
649 "Mark used for articles that are to be downloaded."
650 :group 'gnus-summary-marks
651 :type 'character)
653 (defcustom gnus-unsendable-mark ?=
654 "Mark used for articles that won't be sent."
655 :group 'gnus-summary-marks
656 :type 'character)
658 (defcustom gnus-score-over-mark ?+
659 "Score mark used for articles with high scores."
660 :group 'gnus-summary-marks
661 :type 'character)
663 (defcustom gnus-score-below-mark ?-
664 "Score mark used for articles with low scores."
665 :group 'gnus-summary-marks
666 :type 'character)
668 (defcustom gnus-empty-thread-mark ? ;Whitespace
669 "There is no thread under the article."
670 :group 'gnus-summary-marks
671 :type 'character)
673 (defcustom gnus-not-empty-thread-mark ?=
674 "There is a thread under the article."
675 :group 'gnus-summary-marks
676 :type 'character)
678 (defcustom gnus-view-pseudo-asynchronously nil
679 "If non-nil, Gnus will view pseudo-articles asynchronously."
680 :group 'gnus-extract-view
681 :type 'boolean)
683 (defcustom gnus-auto-expirable-marks
684 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
685 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
686 gnus-duplicate-mark)
687 "The list of marks converted into expiration if a group is auto-expirable."
688 :version "24.1"
689 :group 'gnus-summary
690 :type '(repeat character))
692 (defcustom gnus-inhibit-user-auto-expire t
693 "If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
694 :version "21.1"
695 :group 'gnus-summary
696 :type 'boolean)
698 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
699 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
700 If nil, the expirable marks will be unchanged except that the marks
701 will be removed when copying or moving articles to a group that has
702 not turned auto-expire on. If non-nil, articles that have been read
703 will be marked as expirable when being copied or moved to a group in
704 which auto-expire is turned on."
705 :version "23.2"
706 :type 'boolean
707 :group 'gnus-summary-marks)
709 (defcustom gnus-view-pseudos nil
710 "If `automatic', pseudo-articles will be viewed automatically.
711 If `not-confirm', pseudos will be viewed automatically, and the user
712 will not be asked to confirm the command."
713 :group 'gnus-extract-view
714 :type '(choice (const :tag "off" nil)
715 (const automatic)
716 (const not-confirm)))
718 (defcustom gnus-view-pseudos-separately t
719 "If non-nil, one pseudo-article will be created for each file to be viewed.
720 If nil, all files that use the same viewing command will be given as a
721 list of parameters to that command."
722 :group 'gnus-extract-view
723 :type 'boolean)
725 (defcustom gnus-insert-pseudo-articles t
726 "If non-nil, insert pseudo-articles when decoding articles."
727 :group 'gnus-extract-view
728 :type 'boolean)
730 (defcustom gnus-summary-dummy-line-format
731 " %(: :%) %S\n"
732 "The format specification for the dummy roots in the summary buffer.
733 It works along the same lines as a normal formatting string,
734 with some simple extensions.
736 %S The subject
738 General format specifiers can also be used.
739 See `(gnus)Formatting Variables'."
740 :link '(custom-manual "(gnus)Formatting Variables")
741 :group 'gnus-threading
742 :type 'string)
744 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
745 "The format specification for the summary mode line.
746 It works along the same lines as a normal formatting string,
747 with some simple extensions:
749 %G Group name
750 %p Unprefixed group name
751 %A Current article number
752 %z Current article score
753 %V Gnus version
754 %U Number of unread articles in the group
755 %e Number of unselected articles in the group
756 %Z A string with unread/unselected article counts
757 %g Shortish group name
758 %S Subject of the current article
759 %u User-defined spec
760 %s Current score file name
761 %d Number of dormant articles
762 %r Number of articles that have been marked as read in this session
763 %E Number of articles expunged by the score files"
764 :group 'gnus-summary-format
765 :type 'string)
767 (defcustom gnus-list-identifiers nil
768 "Regexp that matches list identifiers to be removed from subject.
769 This can also be a list of regexps."
770 :version "21.1"
771 :group 'gnus-summary-format
772 :group 'gnus-article-hiding
773 :type '(choice (const :tag "none" nil)
774 (regexp :value ".*")
775 (repeat :value (".*") regexp)))
777 (defcustom gnus-summary-mark-below 0
778 "Mark all articles with a score below this variable as read.
779 This variable is local to each summary buffer and usually set by the
780 score file."
781 :group 'gnus-score-default
782 :type 'integer)
784 (defun gnus-widget-reversible-match (widget value)
785 "Ignoring WIDGET, convert VALUE to internal form.
786 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
787 ;; (debug value)
788 (or (symbolp value)
789 (and (listp value)
790 (eq (length value) 2)
791 (eq (nth 0 value) 'not)
792 (symbolp (nth 1 value)))))
794 (defun gnus-widget-reversible-to-internal (widget value)
795 "Ignoring WIDGET, convert VALUE to internal form.
796 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
797 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
798 ;; (debug value)
799 (if (atom value)
800 (list value nil)
801 (list (nth 1 value) t)))
803 (defun gnus-widget-reversible-to-external (widget value)
804 "Ignoring WIDGET, convert VALUE to external form.
805 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
806 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
807 ;; (debug value)
808 (if (nth 1 value)
809 (list 'not (nth 0 value))
810 (nth 0 value)))
812 (define-widget 'gnus-widget-reversible 'group
813 "A `group' that convert values."
814 :match 'gnus-widget-reversible-match
815 :value-to-internal 'gnus-widget-reversible-to-internal
816 :value-to-external 'gnus-widget-reversible-to-external)
818 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
819 "List of functions used for sorting articles in the summary buffer.
821 Each function takes two articles and returns non-nil if the first
822 article should be sorted before the other. If you use more than one
823 function, the primary sort function should be the last. You should
824 probably always include `gnus-article-sort-by-number' in the list of
825 sorting functions -- preferably first. Also note that sorting by date
826 is often much slower than sorting by number, and the sorting order is
827 very similar. (Sorting by date means sorting by the time the message
828 was sent, sorting by number means sorting by arrival time.)
830 Each item can also be a list `(not F)' where F is a function;
831 this reverses the sort order.
833 Ready-made functions include `gnus-article-sort-by-number',
834 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
835 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
836 and `gnus-article-sort-by-score'.
838 When threading is turned on, the variable `gnus-thread-sort-functions'
839 controls how articles are sorted."
840 :group 'gnus-summary-sort
841 :type '(repeat (gnus-widget-reversible
842 (choice (function-item gnus-article-sort-by-number)
843 (function-item gnus-article-sort-by-author)
844 (function-item gnus-article-sort-by-subject)
845 (function-item gnus-article-sort-by-date)
846 (function-item gnus-article-sort-by-score)
847 (function-item gnus-article-sort-by-random)
848 (function :tag "other"))
849 (boolean :tag "Reverse order"))))
851 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
852 "List of functions used for sorting threads in the summary buffer.
853 By default, threads are sorted by article number.
855 Each function takes two threads and returns non-nil if the first
856 thread should be sorted before the other. If you use more than one
857 function, the primary sort function should be the last. You should
858 probably always include `gnus-thread-sort-by-number' in the list of
859 sorting functions -- preferably first. Also note that sorting by date
860 is often much slower than sorting by number, and the sorting order is
861 very similar. (Sorting by date means sorting by the time the message
862 was sent, sorting by number means sorting by arrival time.)
864 Each list item can also be a list `(not F)' where F is a
865 function; this specifies reversed sort order.
867 Ready-made functions include `gnus-thread-sort-by-number',
868 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
869 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
870 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
871 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
872 and `gnus-thread-sort-by-total-score' (see
873 `gnus-thread-score-function').
875 When threading is turned off, the variable
876 `gnus-article-sort-functions' controls how articles are sorted.
878 By default, threads and their subthreads are sorted according to
879 the value of this variable. To use a different sorting order for
880 subthreads, customize `gnus-subthread-sort-functions'."
881 :group 'gnus-summary-sort
882 :type '(repeat
883 (gnus-widget-reversible
884 (choice (function-item gnus-thread-sort-by-number)
885 (function-item gnus-thread-sort-by-author)
886 (function-item gnus-thread-sort-by-recipient)
887 (function-item gnus-thread-sort-by-subject)
888 (function-item gnus-thread-sort-by-date)
889 (function-item gnus-thread-sort-by-score)
890 (function-item gnus-thread-sort-by-most-recent-number)
891 (function-item gnus-thread-sort-by-most-recent-date)
892 (function-item gnus-thread-sort-by-random)
893 (function-item gnus-thread-sort-by-total-score)
894 (function :tag "other"))
895 (boolean :tag "Reverse order"))))
897 (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
898 "List of functions used for sorting subthreads in the summary buffer.
899 By default, subthreads are sorted the same as threads, i.e.,
900 according to the value of `gnus-thread-sort-functions'."
901 :version "24.4"
902 :group 'gnus-summary-sort
903 :type '(choice
904 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
905 (repeat
906 (gnus-widget-reversible
907 (choice (function-item gnus-thread-sort-by-number)
908 (function-item gnus-thread-sort-by-author)
909 (function-item gnus-thread-sort-by-recipient)
910 (function-item gnus-thread-sort-by-subject)
911 (function-item gnus-thread-sort-by-date)
912 (function-item gnus-thread-sort-by-score)
913 (function-item gnus-thread-sort-by-most-recent-number)
914 (function-item gnus-thread-sort-by-most-recent-date)
915 (function-item gnus-thread-sort-by-random)
916 (function-item gnus-thread-sort-by-total-score)
917 (function :tag "other"))
918 (boolean :tag "Reverse order")))))
920 (defcustom gnus-thread-score-function '+
921 "Function used for calculating the total score of a thread.
923 The function is called with the scores of the article and each
924 subthread and should then return the score of the thread.
926 Some functions you can use are `+', `max', or `min'."
927 :group 'gnus-summary-sort
928 :type 'function)
930 (defcustom gnus-summary-expunge-below nil
931 "All articles that have a score less than this variable will be expunged.
932 This variable is local to the summary buffers."
933 :group 'gnus-score-default
934 :type '(choice (const :tag "off" nil)
935 integer))
937 (defcustom gnus-thread-expunge-below nil
938 "All threads that have a total score less than this variable will be expunged.
939 See `gnus-thread-score-function' for en explanation of what a
940 \"thread score\" is.
942 This variable is local to the summary buffers."
943 :group 'gnus-threading
944 :group 'gnus-score-default
945 :type '(choice (const :tag "off" nil)
946 integer))
948 (defcustom gnus-summary-mode-hook nil
949 "A hook for Gnus summary mode.
950 This hook is run before any variables are set in the summary buffer."
951 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
952 :group 'gnus-summary-various
953 :type 'hook)
955 (defcustom gnus-summary-menu-hook nil
956 "Hook run after the creation of the summary mode menu."
957 :group 'gnus-summary-visual
958 :type 'hook)
960 (defcustom gnus-summary-exit-hook nil
961 "A hook called on exit from the summary buffer.
962 It will be called with point in the group buffer."
963 :group 'gnus-summary-exit
964 :type 'hook)
966 (defcustom gnus-summary-prepare-hook nil
967 "A hook called after the summary buffer has been generated.
968 If you want to modify the summary buffer, you can use this hook."
969 :group 'gnus-summary-various
970 :type 'hook)
972 (defcustom gnus-summary-prepared-hook nil
973 "A hook called as the last thing after the summary buffer has been generated."
974 :group 'gnus-summary-various
975 :type 'hook)
977 (defcustom gnus-summary-generate-hook nil
978 "A hook run just before generating the summary buffer.
979 This hook is commonly used to customize threading variables and the
980 like."
981 :group 'gnus-summary-various
982 :type 'hook)
984 (defcustom gnus-select-group-hook nil
985 "A hook called when a newsgroup is selected.
987 If you'd like to simplify subjects like the
988 `gnus-summary-next-same-subject' command does, you can use the
989 following hook:
991 (add-hook gnus-select-group-hook
992 (lambda ()
993 (mapcar (lambda (header)
994 (mail-header-set-subject
995 header
996 (gnus-simplify-subject
997 (mail-header-subject header) \\='re-only)))
998 gnus-newsgroup-headers)))"
999 :group 'gnus-group-select
1000 :type 'hook)
1002 (defcustom gnus-select-article-hook nil
1003 "A hook called when an article is selected."
1004 :group 'gnus-summary-choose
1005 :options '(gnus-agent-fetch-selected-article)
1006 :type 'hook)
1008 (defcustom gnus-visual-mark-article-hook
1009 (list 'gnus-highlight-selected-summary)
1010 "Hook run after selecting an article in the summary buffer.
1011 It is meant to be used for highlighting the article in some way. It
1012 is not run if `gnus-visual' is nil."
1013 :group 'gnus-summary-visual
1014 :type 'hook)
1016 (defcustom gnus-parse-headers-hook nil
1017 "A hook called before parsing the headers."
1018 :group 'gnus-various
1019 :type 'hook)
1021 (defcustom gnus-exit-group-hook nil
1022 "A hook called when exiting summary mode.
1023 This hook is not called from the non-updating exit commands like `Q'."
1024 :group 'gnus-various
1025 :type 'hook)
1027 (defcustom gnus-summary-update-hook nil
1028 "A hook called when a summary line is changed.
1029 The hook will not be called if `gnus-visual' is nil.
1031 The default function `gnus-summary-highlight-line' will
1032 highlight the line according to the `gnus-summary-highlight'
1033 variable."
1034 :group 'gnus-summary-visual
1035 :type 'hook)
1037 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1038 "A hook called when an article is selected for the first time.
1039 The hook is intended to mark an article as read (or unread)
1040 automatically when it is selected."
1041 :group 'gnus-summary-choose
1042 :type 'hook)
1044 (defcustom gnus-group-no-more-groups-hook nil
1045 "A hook run when returning to group mode having no more (unread) groups."
1046 :group 'gnus-group-select
1047 :type 'hook)
1049 (defcustom gnus-ps-print-hook nil
1050 "A hook run before ps-printing something from Gnus."
1051 :group 'gnus-summary
1052 :type 'hook)
1054 (defcustom gnus-summary-article-move-hook nil
1055 "A hook called after an article is moved, copied, respooled, or crossposted."
1056 :version "22.1"
1057 :group 'gnus-summary
1058 :type 'hook)
1060 (defcustom gnus-summary-article-delete-hook nil
1061 "A hook called after an article is deleted."
1062 :version "22.1"
1063 :group 'gnus-summary
1064 :type 'hook)
1066 (defcustom gnus-summary-article-expire-hook nil
1067 "A hook called after an article is expired."
1068 :version "22.1"
1069 :group 'gnus-summary
1070 :type 'hook)
1072 (defcustom gnus-summary-display-arrow (display-graphic-p)
1073 "If non-nil, display an arrow highlighting the current article."
1074 :version "22.1"
1075 :group 'gnus-summary
1076 :type 'boolean)
1078 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1079 "Face used for highlighting the current article in the summary buffer."
1080 :group 'gnus-summary-visual
1081 :type 'face)
1083 (defvar gnus-tmp-downloaded nil)
1085 (defcustom gnus-summary-highlight
1086 '(((eq mark gnus-canceled-mark)
1087 . gnus-summary-cancelled)
1088 ((and uncached (> score default-high))
1089 . gnus-summary-high-undownloaded)
1090 ((and uncached (< score default-low))
1091 . gnus-summary-low-undownloaded)
1092 (uncached
1093 . gnus-summary-normal-undownloaded)
1094 ((and (> score default-high)
1095 (or (eq mark gnus-dormant-mark)
1096 (eq mark gnus-ticked-mark)))
1097 . gnus-summary-high-ticked)
1098 ((and (< score default-low)
1099 (or (eq mark gnus-dormant-mark)
1100 (eq mark gnus-ticked-mark)))
1101 . gnus-summary-low-ticked)
1102 ((or (eq mark gnus-dormant-mark)
1103 (eq mark gnus-ticked-mark))
1104 . gnus-summary-normal-ticked)
1105 ((and (> score default-high) (eq mark gnus-ancient-mark))
1106 . gnus-summary-high-ancient)
1107 ((and (< score default-low) (eq mark gnus-ancient-mark))
1108 . gnus-summary-low-ancient)
1109 ((eq mark gnus-ancient-mark)
1110 . gnus-summary-normal-ancient)
1111 ((and (> score default-high) (eq mark gnus-unread-mark))
1112 . gnus-summary-high-unread)
1113 ((and (< score default-low) (eq mark gnus-unread-mark))
1114 . gnus-summary-low-unread)
1115 ((eq mark gnus-unread-mark)
1116 . gnus-summary-normal-unread)
1117 ((> score default-high)
1118 . gnus-summary-high-read)
1119 ((< score default-low)
1120 . gnus-summary-low-read)
1122 . gnus-summary-normal-read))
1123 "Controls the highlighting of summary buffer lines.
1125 A list of (FORM . FACE) pairs. When deciding how a particular
1126 summary line should be displayed, each form is evaluated. The content
1127 of the face field after the first true form is used. You can change
1128 how those summary lines are displayed, by editing the face field.
1130 You can use the following variables in the FORM field.
1132 score: The article's score.
1133 default: The default article score.
1134 default-high: The default score for high scored articles.
1135 default-low: The default score for low scored articles.
1136 mark: The article's mark.
1137 uncached: Non-nil if the article is uncached."
1138 :group 'gnus-summary-visual
1139 :type '(repeat (cons (sexp :tag "Form" nil)
1140 face)))
1141 (put 'gnus-summary-highlight 'risky-local-variable t)
1143 (defcustom gnus-alter-header-function nil
1144 "Function called to allow alteration of article header structures.
1145 The function is called with one parameter, the article header vector,
1146 which it may alter in any way."
1147 :type '(choice (const :tag "None" nil)
1148 function)
1149 :group 'gnus-summary)
1151 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1152 "Function used to decode a string with encoded words.")
1154 (defvar gnus-decode-encoded-address-function
1155 'mail-decode-encoded-address-string
1156 "Function used to decode addresses with encoded words.")
1158 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
1159 "Extra headers to parse."
1160 :version "25.1"
1161 :group 'gnus-summary
1162 :type '(repeat symbol))
1164 (defcustom gnus-ignored-from-addresses
1165 (and user-mail-address
1166 (not (string= user-mail-address ""))
1167 (regexp-quote user-mail-address))
1168 "From headers that may be suppressed in favor of To headers.
1169 This can be a regexp, a list of regexps or a function.
1171 If a function, an email string is passed as the argument."
1172 :version "21.1"
1173 :group 'gnus-summary
1174 :type '(choice regexp
1175 (repeat :tag "Regexp List" regexp)
1176 function))
1178 (defsubst gnus-ignored-from-addresses ()
1179 (cond ((functionp gnus-ignored-from-addresses)
1180 gnus-ignored-from-addresses)
1181 (t (gmm-regexp-concat gnus-ignored-from-addresses))))
1183 (defcustom gnus-summary-to-prefix "-> "
1184 "String prefixed to the To field in the summary line when
1185 using `gnus-ignored-from-addresses'."
1186 :version "22.1"
1187 :group 'gnus-summary
1188 :type 'string)
1190 (defcustom gnus-summary-newsgroup-prefix "=> "
1191 "String prefixed to the Newsgroup field in the summary
1192 line when using the option `gnus-ignored-from-addresses'."
1193 :version "22.1"
1194 :group 'gnus-summary
1195 :type 'string)
1197 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1198 "List of charsets that should be ignored.
1199 When these charsets are used in the \"charset\" parameter, the
1200 default charset will be used instead."
1201 :version "21.1"
1202 :type '(repeat symbol)
1203 :group 'gnus-charset)
1205 (defcustom gnus-newsgroup-maximum-articles nil
1206 "The maximum number of articles a newsgroup.
1207 If this is a number, old articles in a newsgroup exceeding this number
1208 are silently ignored. If it is nil, no article is ignored. Note that
1209 setting this variable to a number might prevent you from reading very
1210 old articles."
1211 :group 'gnus-group-select
1212 :version "22.2"
1213 :type '(choice (const :tag "No limit" nil)
1214 integer))
1216 (gnus-define-group-parameter
1217 ignored-charsets
1218 :type list
1219 :function-document
1220 "Return the ignored charsets of GROUP."
1221 :variable gnus-group-ignored-charsets-alist
1222 :variable-default
1223 '(("alt\\.chinese\\.text" iso-8859-1))
1224 :variable-document
1225 "Alist of regexps (to match group names) and charsets that should be ignored.
1226 When these charsets are used in the \"charset\" parameter, the
1227 default charset will be used instead."
1228 :variable-group gnus-charset
1229 :variable-type '(repeat (cons (regexp :tag "Group")
1230 (repeat symbol)))
1231 :parameter-type '(choice :tag "Ignored charsets"
1232 :value nil
1233 (repeat (symbol)))
1234 :parameter-document "\
1235 List of charsets that should be ignored.
1237 When these charsets are used in the \"charset\" parameter, the
1238 default charset will be used instead.")
1240 (defcustom gnus-group-highlight-words-alist nil
1241 "Alist of group regexps and highlight regexps.
1242 This variable uses the same syntax as `gnus-emphasis-alist'."
1243 :version "21.1"
1244 :type '(repeat (cons (regexp :tag "Group")
1245 (repeat (list (regexp :tag "Highlight regexp")
1246 (number :tag "Group for entire word" 0)
1247 (number :tag "Group for displayed part" 0)
1248 (symbol :tag "Face"
1249 gnus-emphasis-highlight-words)))))
1250 :group 'gnus-summary-visual)
1252 (defcustom gnus-summary-show-article-charset-alist
1254 "Alist of number and charset.
1255 The article will be shown with the charset corresponding to the
1256 numbered argument.
1257 For example: ((1 . cn-gb-2312) (2 . big5))."
1258 :version "21.1"
1259 :type '(repeat (cons (number :tag "Argument" 1)
1260 (symbol :tag "Charset")))
1261 :group 'gnus-charset)
1263 (defcustom gnus-preserve-marks t
1264 "Whether marks are preserved when moving, copying and respooling messages."
1265 :version "21.1"
1266 :type 'boolean
1267 :group 'gnus-summary-marks)
1269 (defcustom gnus-alter-articles-to-read-function
1270 (lambda (_group article-list) article-list)
1271 "Function to be called to alter the list of articles to be selected.
1272 This option defaults to a lambda form that simply returns the
1273 list of articles unchanged. Use `add-function' to set one or
1274 more custom filter functions."
1275 :type 'function
1276 :group 'gnus-summary)
1278 (defcustom gnus-orphan-score nil
1279 "All orphans get this score added. Set in the score file."
1280 :group 'gnus-score-default
1281 :type '(choice (const nil)
1282 integer))
1284 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1285 "A regexp to match MIME parts when saving multiple parts of a
1286 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1287 This regexp will be used by default when prompting the user for which
1288 type of files to save."
1289 :group 'gnus-summary
1290 :type 'regexp)
1292 (defcustom gnus-read-all-available-headers nil
1293 "Whether Gnus should parse all headers made available to it.
1294 This is mostly relevant for slow back ends where the user may
1295 wish to widen the summary buffer to include all headers
1296 that were fetched."
1297 :version "22.1"
1298 :group 'gnus-summary
1299 :type '(choice boolean regexp))
1301 (defcustom gnus-summary-pipe-output-default-command nil
1302 "Command (and optional arguments) used to pipe article to subprocess.
1303 This will be used as the default command if it is non-nil. The value
1304 will be updated if you modify it when executing the command
1305 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1306 :version "23.1" ;; No Gnus
1307 :group 'gnus-summary
1308 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1310 (defcustom gnus-summary-muttprint-program "muttprint"
1311 "Command (and optional arguments) used to run Muttprint.
1312 The value will be updated if you modify it when executing the command
1313 `gnus-summary-muttprint'."
1314 :version "22.1"
1315 :group 'gnus-summary
1316 :type 'string)
1318 (defcustom gnus-article-loose-mime t
1319 "If non-nil, don't require MIME-Version header.
1320 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1321 supply the MIME-Version header or deliberately strip it from the mail.
1322 If non-nil (the default), Gnus will treat some articles as MIME
1323 even if the MIME-Version header is missing."
1324 :version "22.1"
1325 :type 'boolean
1326 :group 'gnus-article-mime)
1328 (defcustom gnus-article-emulate-mime t
1329 "If non-nil, use MIME emulation for uuencode and the like.
1330 This means that Gnus will search message bodies for text that look
1331 like uuencoded bits, yEncoded bits, and so on, and present that using
1332 the normal Gnus MIME machinery."
1333 :version "22.1"
1334 :type 'boolean
1335 :group 'gnus-article-mime)
1337 ;;; Internal variables
1339 (defvar gnus-summary-display-cache nil)
1340 (defvar gnus-article-mime-handles nil)
1341 (defvar gnus-article-decoded-p nil)
1342 (defvar gnus-article-charset nil)
1343 (defvar gnus-article-ignored-charsets nil)
1344 (defvar gnus-scores-exclude-files nil)
1345 (defvar gnus-page-broken nil)
1347 (defvar gnus-original-article nil)
1348 (defvar gnus-article-internal-prepare-hook nil)
1349 (defvar gnus-newsgroup-process-stack nil)
1351 (defvar gnus-thread-indent-array nil)
1352 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1353 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1354 "Function called to sort the articles within a thread after it has been gathered together.")
1356 (defvar gnus-summary-save-parts-type-history nil)
1357 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1359 ;; Avoid highlighting in kill files.
1360 (defvar gnus-summary-inhibit-highlight nil)
1361 (defvar gnus-newsgroup-selected-overlay nil)
1362 (defvar gnus-inhibit-limiting nil)
1363 (defvar gnus-newsgroup-adaptive-score-file nil)
1364 (defvar gnus-current-score-file nil)
1365 (defvar gnus-current-move-group nil)
1366 (defvar gnus-current-copy-group nil)
1367 (defvar gnus-current-crosspost-group nil)
1368 (defvar gnus-newsgroup-display nil)
1370 (defvar gnus-newsgroup-dependencies nil)
1371 (defvar gnus-newsgroup-adaptive nil)
1372 (defvar gnus-summary-display-article-function nil)
1373 (defvar gnus-summary-highlight-line-function nil
1374 "Function called after highlighting a summary line.")
1376 (defvar gnus-summary-line-format-alist
1377 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1378 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1379 (?s gnus-tmp-subject-or-nil ?s)
1380 (?n gnus-tmp-name ?s)
1381 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1383 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1384 gnus-tmp-from) ?s)
1385 (?F gnus-tmp-from ?s)
1386 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1387 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1388 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1389 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1390 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1391 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1392 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1393 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1394 (?L gnus-tmp-lines ?s)
1395 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1396 0) ?d)
1397 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1398 "") ?s)
1399 (?g (or (gnus-group-short-name
1400 (nnir-article-group (mail-header-number gnus-tmp-header)))
1401 "") ?s)
1402 (?O gnus-tmp-downloaded ?c)
1403 (?I gnus-tmp-indentation ?s)
1404 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1405 (?R gnus-tmp-replied ?c)
1406 (?\[ gnus-tmp-opening-bracket ?c)
1407 (?\] gnus-tmp-closing-bracket ?c)
1408 (?\> (make-string gnus-tmp-level ? ) ?s)
1409 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1410 (?i gnus-tmp-score ?d)
1411 (?z gnus-tmp-score-char ?c)
1412 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1413 (?U gnus-tmp-unread ?c)
1414 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1416 (?t (gnus-summary-number-of-articles-in-thread
1417 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1419 (?e (gnus-summary-number-of-articles-in-thread
1420 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1422 (?u gnus-tmp-user-defined ?s)
1423 (?P (gnus-pick-line-number) ?d)
1424 (?B gnus-tmp-thread-tree-header-string ?s)
1425 (user-date (gnus-user-date
1426 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1427 "An alist of format specifications that can appear in summary lines.
1428 These are paired with what variables they correspond with, along with
1429 the type of the variable (string, integer, character, etc).")
1431 (defvar gnus-summary-dummy-line-format-alist
1432 `((?S gnus-tmp-subject ?s)
1433 (?N gnus-tmp-number ?d)
1434 (?u gnus-tmp-user-defined ?s)))
1436 (defvar gnus-summary-mode-line-format-alist
1437 `((?G gnus-tmp-group-name ?s)
1438 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1439 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1440 (?A gnus-tmp-article-number ?d)
1441 (?Z gnus-tmp-unread-and-unselected ?s)
1442 (?V gnus-version ?s)
1443 (?U gnus-tmp-unread-and-unticked ?d)
1444 (?S gnus-tmp-subject ?s)
1445 (?e gnus-tmp-unselected ?d)
1446 (?u gnus-tmp-user-defined ?s)
1447 (?d (length gnus-newsgroup-dormant) ?d)
1448 (?t (length gnus-newsgroup-marked) ?d)
1449 (?h (length gnus-newsgroup-spam-marked) ?d)
1450 (?r (length gnus-newsgroup-reads) ?d)
1451 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1452 (?E gnus-newsgroup-expunged-tally ?d)
1453 (?s (gnus-current-score-file-nondirectory) ?s)))
1455 ;; This is here rather than in gnus-art for compilation reasons.
1456 (defvar gnus-article-mode-line-format-alist
1457 (nconc '((?w (gnus-article-wash-status) ?s)
1458 (?m (gnus-article-mime-part-status) ?s))
1459 gnus-summary-mode-line-format-alist))
1461 (defvar gnus-last-search-regexp nil
1462 "Default regexp for article search command.")
1464 (defvar gnus-last-shell-command nil
1465 "Default shell command on article.")
1467 (defvar gnus-newsgroup-agentized nil
1468 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1469 (defvar gnus-newsgroup-begin nil)
1470 (defvar gnus-newsgroup-end nil)
1471 (defvar gnus-newsgroup-last-rmail nil)
1472 (defvar gnus-newsgroup-last-mail nil)
1473 (defvar gnus-newsgroup-last-folder nil)
1474 (defvar gnus-newsgroup-last-file nil)
1475 (defvar gnus-newsgroup-last-directory nil)
1476 (defvar gnus-newsgroup-auto-expire nil)
1477 (defvar gnus-newsgroup-active nil)
1478 (defvar gnus-newsgroup-highest nil)
1480 (defvar gnus-newsgroup-data nil)
1481 (defvar gnus-newsgroup-data-reverse nil)
1482 (defvar gnus-newsgroup-limit nil)
1483 (defvar gnus-newsgroup-limits nil)
1484 (defvar gnus-summary-use-undownloaded-faces nil)
1486 (defvar gnus-newsgroup-unreads nil
1487 "Sorted list of unread articles in the current newsgroup.")
1489 (defvar gnus-newsgroup-unselected nil
1490 "Sorted list of unselected unread articles in the current newsgroup.")
1492 (defvar gnus-newsgroup-reads nil
1493 "Alist of read articles and article marks in the current newsgroup.")
1495 (defvar gnus-newsgroup-expunged-tally nil)
1497 (defvar gnus-newsgroup-marked nil
1498 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1500 (defvar gnus-newsgroup-spam-marked nil
1501 "List of ranges of articles that have been marked as spam.")
1503 (defvar gnus-newsgroup-killed nil
1504 "List of ranges of articles that have been through the scoring process.")
1506 (defvar gnus-newsgroup-cached nil
1507 "Sorted list of articles that come from the article cache.")
1509 (defvar gnus-newsgroup-saved nil
1510 "List of articles that have been saved.")
1512 (defvar gnus-newsgroup-kill-headers nil)
1514 (defvar gnus-newsgroup-replied nil
1515 "List of articles that have been replied to in the current newsgroup.")
1517 (defvar gnus-newsgroup-forwarded nil
1518 "List of articles that have been forwarded in the current newsgroup.")
1520 (defvar gnus-newsgroup-expirable nil
1521 "Sorted list of articles in the current newsgroup that can be expired.")
1523 (defvar gnus-newsgroup-processable nil
1524 "List of articles in the current newsgroup that can be processed.")
1526 (defvar gnus-newsgroup-downloadable nil
1527 "Sorted list of articles in the current newsgroup that can be processed.")
1529 (defvar gnus-newsgroup-unfetched nil
1530 "Sorted list of articles in the current newsgroup whose headers have
1531 not been fetched into the agent.
1533 This list will always be a subset of gnus-newsgroup-undownloaded.")
1535 (defvar gnus-newsgroup-undownloaded nil
1536 "List of articles in the current newsgroup that haven't been downloaded.")
1538 (defvar gnus-newsgroup-unsendable nil
1539 "List of articles in the current newsgroup that won't be sent.")
1541 (defvar gnus-newsgroup-bookmarks nil
1542 "List of articles in the current newsgroup that have bookmarks.")
1544 (defvar gnus-newsgroup-dormant nil
1545 "Sorted list of dormant articles in the current newsgroup.")
1547 (defvar gnus-newsgroup-unseen nil
1548 "List of unseen articles in the current newsgroup.")
1550 (defvar gnus-newsgroup-seen nil
1551 "Range of seen articles in the current newsgroup.")
1553 (defvar gnus-newsgroup-unexist nil
1554 "Range of unexisting articles in the current newsgroup.")
1556 (defvar gnus-newsgroup-articles nil
1557 "List of articles in the current newsgroup.")
1559 (defvar gnus-newsgroup-scored nil
1560 "List of scored articles in the current newsgroup.")
1562 (defvar gnus-newsgroup-headers nil
1563 "List of article headers in the current newsgroup.")
1565 (defvar gnus-newsgroup-threads nil)
1567 (defvar gnus-newsgroup-prepared nil
1568 "Whether the current group has been prepared properly.")
1570 (defvar gnus-newsgroup-ancient nil
1571 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1573 (defvar gnus-newsgroup-sparse nil)
1575 (defvar gnus-current-article nil)
1576 (defvar gnus-article-current nil)
1577 (defvar gnus-current-headers nil)
1578 (defvar gnus-have-all-headers nil)
1579 (defvar gnus-last-article nil)
1580 (defvar gnus-newsgroup-history nil)
1581 (defvar gnus-newsgroup-charset nil)
1582 (defvar gnus-newsgroup-ephemeral-charset nil)
1583 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1585 (defvar gnus-article-before-search nil)
1587 (defvar gnus-summary-local-variables
1588 '(gnus-newsgroup-name
1590 ;; Marks lists
1591 gnus-newsgroup-unreads
1592 gnus-newsgroup-unselected
1593 gnus-newsgroup-marked
1594 gnus-newsgroup-spam-marked
1595 gnus-newsgroup-reads
1596 gnus-newsgroup-saved
1597 gnus-newsgroup-replied
1598 gnus-newsgroup-forwarded
1599 gnus-newsgroup-expirable
1600 gnus-newsgroup-killed
1601 gnus-newsgroup-unseen
1602 gnus-newsgroup-seen
1603 gnus-newsgroup-unexist
1604 gnus-newsgroup-cached
1605 gnus-newsgroup-downloadable
1606 gnus-newsgroup-undownloaded
1607 gnus-newsgroup-unsendable
1609 gnus-newsgroup-begin gnus-newsgroup-end
1610 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1611 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1612 gnus-newsgroup-last-directory
1613 gnus-newsgroup-auto-expire
1614 gnus-newsgroup-processable
1615 gnus-newsgroup-unfetched
1616 gnus-newsgroup-articles
1617 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1618 gnus-newsgroup-headers gnus-newsgroup-threads
1619 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1620 gnus-current-article gnus-current-headers gnus-have-all-headers
1621 gnus-last-article gnus-article-internal-prepare-hook
1622 (gnus-summary-article-delete-hook . global)
1623 (gnus-summary-article-move-hook . global)
1624 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1625 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1626 gnus-thread-expunge-below
1627 gnus-score-alist gnus-current-score-file
1628 (gnus-summary-expunge-below . global)
1629 (gnus-summary-mark-below . global)
1630 (gnus-orphan-score . global)
1631 gnus-newsgroup-active gnus-scores-exclude-files
1632 gnus-newsgroup-highest
1633 gnus-newsgroup-history gnus-newsgroup-ancient
1634 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1635 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1636 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1637 (gnus-newsgroup-expunged-tally . 0)
1638 gnus-cache-removable-articles
1639 gnus-newsgroup-data gnus-newsgroup-data-reverse
1640 gnus-newsgroup-limit gnus-newsgroup-limits
1641 gnus-newsgroup-charset gnus-newsgroup-display
1642 gnus-summary-use-undownloaded-faces)
1643 "Variables that are buffer-local to the summary buffers.")
1645 (defvar gnus-newsgroup-variables nil
1646 "A list of variables that have separate values in different newsgroups.
1647 A list of newsgroup (summary buffer) local variables, or cons of
1648 variables and their default expressions to be evalled (when the default
1649 values are not nil), that should be made global while the summary buffer
1650 is active.
1652 Note: The default expressions will be evaluated (using function `eval')
1653 before assignment to the local variable rather than just assigned to it.
1654 If the default expression is the symbol `global', that symbol will not
1655 be evaluated but the global value of the local variable will be used
1656 instead.
1658 These variables can be used to set variables in the group parameters
1659 while still allowing them to affect operations done in other buffers.
1660 For example:
1662 \(setq gnus-newsgroup-variables
1663 \\='(message-use-followup-to
1664 (gnus-visible-headers .
1665 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1668 (eval-when-compile
1669 ;; Bind features so that require will believe that gnus-sum has
1670 ;; already been loaded (avoids infinite recursion)
1671 (let ((features (cons 'gnus-sum features)))
1672 (require 'gnus-art)))
1674 ;; MIME stuff.
1676 (defvar gnus-decode-encoded-word-methods
1677 '(mail-decode-encoded-word-string)
1678 "List of methods used to decode encoded words.
1680 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1681 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1682 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1683 whose names match REGEXP.
1685 For example:
1686 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1687 mail-decode-encoded-word-string
1688 (\"chinese\" . rfc1843-decode-string))")
1690 (defvar gnus-decode-encoded-word-methods-cache nil)
1692 (defun gnus-multi-decode-encoded-word-string (string)
1693 "Apply the functions from `gnus-encoded-word-methods' that match."
1694 (unless (and gnus-decode-encoded-word-methods-cache
1695 (eq gnus-newsgroup-name
1696 (car gnus-decode-encoded-word-methods-cache)))
1697 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1698 (dolist (method gnus-decode-encoded-word-methods)
1699 (if (symbolp method)
1700 (nconc gnus-decode-encoded-word-methods-cache (list method))
1701 (if (and gnus-newsgroup-name
1702 (string-match (car method) gnus-newsgroup-name))
1703 (nconc gnus-decode-encoded-word-methods-cache
1704 (list (cdr method)))))))
1705 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1706 (setq string (funcall method string))))
1708 ;; Subject simplification.
1710 (defun gnus-simplify-whitespace (str)
1711 "Remove excessive whitespace from STR."
1712 ;; Multiple spaces.
1713 (while (string-match "[ \t][ \t]+" str)
1714 (setq str (concat (substring str 0 (match-beginning 0))
1716 (substring str (match-end 0)))))
1717 ;; Leading spaces.
1718 (when (string-match "^[ \t]+" str)
1719 (setq str (substring str (match-end 0))))
1720 ;; Trailing spaces.
1721 (when (string-match "[ \t]+$" str)
1722 (setq str (substring str 0 (match-beginning 0))))
1723 str)
1725 (defun gnus-simplify-all-whitespace (str)
1726 "Remove all whitespace from STR."
1727 (while (string-match "[ \t\n]+" str)
1728 (setq str (replace-match "" nil nil str)))
1729 str)
1731 (defsubst gnus-simplify-subject-re (subject)
1732 "Remove \"Re:\" from subject lines."
1733 (if (string-match message-subject-re-regexp subject)
1734 (substring subject (match-end 0))
1735 subject))
1737 (defun gnus-simplify-subject (subject &optional re-only)
1738 "Remove `Re:' and words in parentheses.
1739 If RE-ONLY is non-nil, strip leading `Re:'s only."
1740 (let ((case-fold-search t)) ;Ignore case.
1741 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1742 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1743 (setq subject (substring subject (match-end 0))))
1744 ;; Remove uninteresting prefixes.
1745 (when (and (not re-only)
1746 gnus-simplify-ignored-prefixes
1747 (string-match gnus-simplify-ignored-prefixes subject))
1748 (setq subject (substring subject (match-end 0))))
1749 ;; Remove words in parentheses from end.
1750 (unless re-only
1751 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1752 (setq subject (substring subject 0 (match-beginning 0)))))
1753 ;; Return subject string.
1754 subject))
1756 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1757 ;; all whitespace.
1758 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1759 (goto-char (point-min))
1760 (while (re-search-forward regexp nil t)
1761 (replace-match (or newtext ""))))
1763 (defun gnus-simplify-buffer-fuzzy (regexp)
1764 "Simplify string in the buffer fuzzily.
1765 The string in the accessible portion of the current buffer is simplified.
1766 It is assumed to be a single-line subject.
1767 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1768 matter is removed. Additional things can be deleted by setting
1769 `gnus-simplify-subject-fuzzy-regexp'."
1770 (let ((case-fold-search t)
1771 (modified-tick))
1772 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1774 (while (not (eq modified-tick (buffer-modified-tick)))
1775 (setq modified-tick (buffer-modified-tick))
1776 (cond
1777 ((listp regexp)
1778 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1779 (regexp
1780 (gnus-simplify-buffer-fuzzy-step regexp)))
1781 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1782 (gnus-simplify-buffer-fuzzy-step
1783 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1784 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1786 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1787 (gnus-simplify-buffer-fuzzy-step " +" " ")
1788 (gnus-simplify-buffer-fuzzy-step " $")
1789 (gnus-simplify-buffer-fuzzy-step "^ +")))
1791 (defun gnus-simplify-subject-fuzzy (subject)
1792 "Simplify a subject string fuzzily.
1793 See `gnus-simplify-buffer-fuzzy' for details."
1794 (save-excursion
1795 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1796 (gnus-set-work-buffer)
1797 (let ((case-fold-search t))
1798 ;; Remove uninteresting prefixes.
1799 (when (and gnus-simplify-ignored-prefixes
1800 (string-match gnus-simplify-ignored-prefixes subject))
1801 (setq subject (substring subject (match-end 0))))
1802 (insert subject)
1803 (inline (gnus-simplify-buffer-fuzzy regexp))
1804 (buffer-string)))))
1806 (defsubst gnus-simplify-subject-fully (subject)
1807 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1808 (cond
1809 (gnus-simplify-subject-functions
1810 (gnus-map-function gnus-simplify-subject-functions subject))
1811 ((null gnus-summary-gather-subject-limit)
1812 (gnus-simplify-subject-re subject))
1813 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1814 (gnus-simplify-subject-fuzzy subject))
1815 ((numberp gnus-summary-gather-subject-limit)
1816 (truncate-string-to-width (gnus-simplify-subject-re subject)
1817 gnus-summary-gather-subject-limit))
1819 subject)))
1821 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1822 "Check whether two subjects are equal.
1823 If optional argument SIMPLE-FIRST is t, first argument is already
1824 simplified."
1825 (cond
1826 ((null simple-first)
1827 (equal (gnus-simplify-subject-fully s1)
1828 (gnus-simplify-subject-fully s2)))
1830 (equal s1
1831 (gnus-simplify-subject-fully s2)))))
1833 (defun gnus-summary-bubble-group ()
1834 "Increase the score of the current group.
1835 This is a handy function to add to `gnus-summary-exit-hook' to
1836 increase the score of each group you read."
1837 (gnus-group-add-score gnus-newsgroup-name))
1841 ;;; Gnus summary mode
1844 (put 'gnus-summary-mode 'mode-class 'special)
1846 (defvar gnus-article-commands-menu)
1848 ;; Non-orthogonal keys
1850 (gnus-define-keys gnus-summary-mode-map
1851 " " gnus-summary-next-page
1852 [?\S-\ ] gnus-summary-prev-page
1853 "\177" gnus-summary-prev-page
1854 [delete] gnus-summary-prev-page
1855 "\r" gnus-summary-scroll-up
1856 "\M-\r" gnus-summary-scroll-down
1857 "n" gnus-summary-next-unread-article
1858 "p" gnus-summary-prev-unread-article
1859 "N" gnus-summary-next-article
1860 "P" gnus-summary-prev-article
1861 "\M-\C-n" gnus-summary-next-same-subject
1862 "\M-\C-p" gnus-summary-prev-same-subject
1863 "\M-n" gnus-summary-next-unread-subject
1864 "\M-p" gnus-summary-prev-unread-subject
1865 "." gnus-summary-first-unread-article
1866 "," gnus-summary-best-unread-article
1867 "\M-s" gnus-summary-search-article-forward
1868 "\M-r" gnus-summary-search-article-backward
1869 "\M-S" gnus-summary-repeat-search-article-forward
1870 "\M-R" gnus-summary-repeat-search-article-backward
1871 "<" gnus-summary-beginning-of-article
1872 ">" gnus-summary-end-of-article
1873 "j" gnus-summary-goto-article
1874 "^" gnus-summary-refer-parent-article
1875 "\M-^" gnus-summary-refer-article
1876 "u" gnus-summary-tick-article-forward
1877 "!" gnus-summary-tick-article-forward
1878 "U" gnus-summary-tick-article-backward
1879 "d" gnus-summary-mark-as-read-forward
1880 "D" gnus-summary-mark-as-read-backward
1881 "E" gnus-summary-mark-as-expirable
1882 "\M-u" gnus-summary-clear-mark-forward
1883 "\M-U" gnus-summary-clear-mark-backward
1884 "k" gnus-summary-kill-same-subject-and-select
1885 "\C-k" gnus-summary-kill-same-subject
1886 "\M-\C-k" gnus-summary-kill-thread
1887 "\M-\C-l" gnus-summary-lower-thread
1888 "e" gnus-summary-edit-article
1889 "#" gnus-summary-mark-as-processable
1890 "\M-#" gnus-summary-unmark-as-processable
1891 "\M-\C-t" gnus-summary-toggle-threads
1892 "\M-\C-s" gnus-summary-show-thread
1893 "\M-\C-h" gnus-summary-hide-thread
1894 "\M-\C-f" gnus-summary-next-thread
1895 "\M-\C-b" gnus-summary-prev-thread
1896 [(meta down)] gnus-summary-next-thread
1897 [(meta up)] gnus-summary-prev-thread
1898 "\M-\C-u" gnus-summary-up-thread
1899 "\M-\C-d" gnus-summary-down-thread
1900 "&" gnus-summary-execute-command
1901 "c" gnus-summary-catchup-and-exit
1902 "\C-w" gnus-summary-mark-region-as-read
1903 "\C-t" toggle-truncate-lines
1904 "?" gnus-summary-mark-as-dormant
1905 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1906 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1907 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1908 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1909 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1910 "\C-c\C-s\C-m\C-m" gnus-summary-sort-by-marks
1911 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1912 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1913 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1914 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1915 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1916 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1917 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1918 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1919 "=" gnus-summary-expand-window
1920 "\C-x\C-s" gnus-summary-reselect-current-group
1921 "\M-g" gnus-summary-rescan-group
1922 "\C-c\C-r" gnus-summary-caesar-message
1923 "f" gnus-summary-followup
1924 "F" gnus-summary-followup-with-original
1925 "C" gnus-summary-cancel-article
1926 "r" gnus-summary-reply
1927 "R" gnus-summary-reply-with-original
1928 "\C-c\C-f" gnus-summary-mail-forward
1929 "o" gnus-summary-save-article
1930 "\C-o" gnus-summary-save-article-mail
1931 "|" gnus-summary-pipe-output
1932 "\M-k" gnus-summary-edit-local-kill
1933 "\M-K" gnus-summary-edit-global-kill
1934 ;; "V" gnus-version
1935 "\C-c\C-d" gnus-summary-describe-group
1936 "q" gnus-summary-exit
1937 "Q" gnus-summary-exit-no-update
1938 "\C-c\C-i" gnus-info-find-node
1939 [mouse-2] gnus-mouse-pick-article
1940 [follow-link] mouse-face
1941 "m" gnus-summary-mail-other-window
1942 "a" gnus-summary-post-news
1943 "x" gnus-summary-limit-to-unread
1944 "s" gnus-summary-isearch-article
1945 "\t" gnus-summary-widget-forward
1946 [backtab] gnus-summary-widget-backward
1947 "t" gnus-summary-toggle-header
1948 "g" gnus-summary-show-article
1949 "l" gnus-summary-goto-last-article
1950 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1951 "\C-d" gnus-summary-enter-digest-group
1952 "\M-\C-d" gnus-summary-read-document
1953 "\M-\C-e" gnus-summary-edit-parameters
1954 "\M-\C-a" gnus-summary-customize-parameters
1955 "\C-c\C-b" gnus-bug
1956 "*" gnus-cache-enter-article
1957 "\M-*" gnus-cache-remove-article
1958 "\M-&" gnus-summary-universal-argument
1959 "\C-l" gnus-recenter
1960 "I" gnus-summary-increase-score
1961 "L" gnus-summary-lower-score
1962 "\M-i" gnus-symbolic-argument
1963 "h" gnus-summary-select-article-buffer
1965 "b" gnus-article-view-part
1966 "\M-t" gnus-summary-toggle-display-buttonized
1968 "V" gnus-summary-score-map
1969 "X" gnus-uu-extract-map
1970 "S" gnus-summary-send-map)
1972 ;; Sort of orthogonal keymap
1973 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1974 "t" gnus-summary-tick-article-forward
1975 "!" gnus-summary-tick-article-forward
1976 "d" gnus-summary-mark-as-read-forward
1977 "r" gnus-summary-mark-as-read-forward
1978 "c" gnus-summary-clear-mark-forward
1979 " " gnus-summary-clear-mark-forward
1980 "e" gnus-summary-mark-as-expirable
1981 "x" gnus-summary-mark-as-expirable
1982 "?" gnus-summary-mark-as-dormant
1983 "b" gnus-summary-set-bookmark
1984 "B" gnus-summary-remove-bookmark
1985 "#" gnus-summary-mark-as-processable
1986 "\M-#" gnus-summary-unmark-as-processable
1987 "S" gnus-summary-limit-include-expunged
1988 "C" gnus-summary-catchup
1989 "H" gnus-summary-catchup-to-here
1990 "h" gnus-summary-catchup-from-here
1991 "\C-c" gnus-summary-catchup-all
1992 "k" gnus-summary-kill-same-subject-and-select
1993 "K" gnus-summary-kill-same-subject
1994 "P" gnus-uu-mark-map)
1996 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1997 "c" gnus-summary-clear-above
1998 "u" gnus-summary-tick-above
1999 "m" gnus-summary-mark-above
2000 "k" gnus-summary-kill-below)
2002 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
2003 "/" gnus-summary-limit-to-subject
2004 "n" gnus-summary-limit-to-articles
2005 "b" gnus-summary-limit-to-bodies
2006 "h" gnus-summary-limit-to-headers
2007 "w" gnus-summary-pop-limit
2008 "s" gnus-summary-limit-to-subject
2009 "a" gnus-summary-limit-to-author
2010 "u" gnus-summary-limit-to-unread
2011 "m" gnus-summary-limit-to-marks
2012 "M" gnus-summary-limit-exclude-marks
2013 "v" gnus-summary-limit-to-score
2014 "*" gnus-summary-limit-include-cached
2015 "D" gnus-summary-limit-include-dormant
2016 "T" gnus-summary-limit-include-thread
2017 "d" gnus-summary-limit-exclude-dormant
2018 "t" gnus-summary-limit-to-age
2019 "." gnus-summary-limit-to-unseen
2020 "x" gnus-summary-limit-to-extra
2021 "p" gnus-summary-limit-to-display-predicate
2022 "E" gnus-summary-limit-include-expunged
2023 "c" gnus-summary-limit-exclude-childless-dormant
2024 "C" gnus-summary-limit-mark-excluded-as-read
2025 "o" gnus-summary-insert-old-articles
2026 "N" gnus-summary-insert-new-articles
2027 "S" gnus-summary-limit-to-singletons
2028 "r" gnus-summary-limit-to-replied
2029 "R" gnus-summary-limit-to-recipient
2030 "A" gnus-summary-limit-to-address)
2032 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2033 "n" gnus-summary-next-unread-article
2034 "p" gnus-summary-prev-unread-article
2035 "N" gnus-summary-next-article
2036 "P" gnus-summary-prev-article
2037 "\C-n" gnus-summary-next-same-subject
2038 "\C-p" gnus-summary-prev-same-subject
2039 "\M-n" gnus-summary-next-unread-subject
2040 "\M-p" gnus-summary-prev-unread-subject
2041 "f" gnus-summary-first-unread-article
2042 "b" gnus-summary-best-unread-article
2043 "j" gnus-summary-goto-article
2044 "g" gnus-summary-goto-subject
2045 "l" gnus-summary-goto-last-article
2046 "o" gnus-summary-pop-article)
2048 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2049 "k" gnus-summary-kill-thread
2050 "E" gnus-summary-expire-thread
2051 "l" gnus-summary-lower-thread
2052 "i" gnus-summary-raise-thread
2053 "T" gnus-summary-toggle-threads
2054 "t" gnus-summary-rethread-current
2055 "^" gnus-summary-reparent-thread
2056 "\M-^" gnus-summary-reparent-children
2057 "s" gnus-summary-show-thread
2058 "S" gnus-summary-show-all-threads
2059 "h" gnus-summary-hide-thread
2060 "H" gnus-summary-hide-all-threads
2061 "n" gnus-summary-next-thread
2062 "p" gnus-summary-prev-thread
2063 "u" gnus-summary-up-thread
2064 "o" gnus-summary-top-thread
2065 "d" gnus-summary-down-thread
2066 "#" gnus-uu-mark-thread
2067 "\M-#" gnus-uu-unmark-thread)
2069 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2070 "g" gnus-summary-prepare
2071 "c" gnus-summary-insert-cached-articles
2072 "d" gnus-summary-insert-dormant-articles
2073 "t" gnus-summary-insert-ticked-articles)
2075 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2076 "c" gnus-summary-catchup-and-exit
2077 "C" gnus-summary-catchup-all-and-exit
2078 "E" gnus-summary-exit-no-update
2079 "Q" gnus-summary-exit
2080 "Z" gnus-summary-exit
2081 "n" gnus-summary-catchup-and-goto-next-group
2082 "p" gnus-summary-catchup-and-goto-prev-group
2083 "R" gnus-summary-reselect-current-group
2084 "G" gnus-summary-rescan-group
2085 "N" gnus-summary-next-group
2086 "s" gnus-summary-save-newsrc
2087 "P" gnus-summary-prev-group)
2089 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2090 " " gnus-summary-next-page
2091 "n" gnus-summary-next-page
2092 [?\S-\ ] gnus-summary-prev-page
2093 "\177" gnus-summary-prev-page
2094 [delete] gnus-summary-prev-page
2095 "p" gnus-summary-prev-page
2096 "\r" gnus-summary-scroll-up
2097 "\M-\r" gnus-summary-scroll-down
2098 "<" gnus-summary-beginning-of-article
2099 ">" gnus-summary-end-of-article
2100 "b" gnus-summary-beginning-of-article
2101 "e" gnus-summary-end-of-article
2102 "^" gnus-summary-refer-parent-article
2103 "r" gnus-summary-refer-parent-article
2104 "C" gnus-summary-show-complete-article
2105 "D" gnus-summary-enter-digest-group
2106 "R" gnus-summary-refer-references
2107 "T" gnus-summary-refer-thread
2108 "W" gnus-warp-to-article
2109 "g" gnus-summary-show-article
2110 "s" gnus-summary-isearch-article
2111 "\t" gnus-summary-widget-forward
2112 [backtab] gnus-summary-widget-backward
2113 "P" gnus-summary-print-article
2114 "S" gnus-sticky-article
2115 "M" gnus-mailing-list-insinuate
2116 "t" gnus-article-babel)
2118 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2119 "b" gnus-article-add-buttons
2120 "B" gnus-article-add-buttons-to-head
2121 "o" gnus-article-treat-overstrike
2122 "e" gnus-article-emphasize
2123 "w" gnus-article-fill-cited-article
2124 "Q" gnus-article-fill-long-lines
2125 "L" gnus-article-toggle-truncate-lines
2126 "C" gnus-article-capitalize-sentences
2127 "c" gnus-article-remove-cr
2128 "q" gnus-article-de-quoted-unreadable
2129 "6" gnus-article-de-base64-unreadable
2130 "Z" gnus-article-decode-HZ
2131 "A" gnus-article-treat-ansi-sequences
2132 "h" gnus-article-wash-html
2133 "u" gnus-article-unsplit-urls
2134 "s" gnus-summary-force-verify-and-decrypt
2135 "f" gnus-article-display-x-face
2136 "l" gnus-summary-stop-page-breaking
2137 "r" gnus-summary-caesar-message
2138 "m" gnus-summary-morse-message
2139 "t" gnus-summary-toggle-header
2140 "g" gnus-treat-smiley
2141 "v" gnus-summary-verbose-headers
2142 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2143 "p" gnus-article-verify-x-pgp-sig
2144 "d" gnus-article-treat-dumbquotes
2145 "U" gnus-article-treat-non-ascii
2146 "i" gnus-summary-idna-message)
2148 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2149 ;; mnemonic: deuglif*Y*
2150 "u" gnus-article-outlook-unwrap-lines
2151 "a" gnus-article-outlook-repair-attribution
2152 "c" gnus-article-outlook-rearrange-citation
2153 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2155 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2156 "a" gnus-article-hide
2157 "h" gnus-article-hide-headers
2158 "b" gnus-article-hide-boring-headers
2159 "s" gnus-article-hide-signature
2160 "c" gnus-article-hide-citation
2161 "C" gnus-article-hide-citation-in-followups
2162 "l" gnus-article-hide-list-identifiers
2163 "B" gnus-article-strip-banner
2164 "P" gnus-article-hide-pem
2165 "\C-c" gnus-article-hide-citation-maybe)
2167 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2168 "a" gnus-article-highlight
2169 "h" gnus-article-highlight-headers
2170 "c" gnus-article-highlight-citation
2171 "s" gnus-article-highlight-signature)
2173 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2174 "f" gnus-article-treat-fold-headers
2175 "u" gnus-article-treat-unfold-headers
2176 "n" gnus-article-treat-fold-newsgroups)
2178 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2179 "x" gnus-article-display-x-face
2180 "d" gnus-article-display-face
2181 "s" gnus-treat-smiley
2182 "D" gnus-article-remove-images
2183 "W" gnus-article-show-images
2184 "f" gnus-treat-from-picon
2185 "m" gnus-treat-mail-picon
2186 "n" gnus-treat-newsgroups-picon
2187 "g" gnus-treat-from-gravatar
2188 "h" gnus-treat-mail-gravatar)
2190 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2191 "w" gnus-article-decode-mime-words
2192 "c" gnus-article-decode-charset
2193 "h" gnus-mime-buttonize-attachments-in-header
2194 "v" gnus-mime-view-all-parts
2195 "b" gnus-article-view-part)
2197 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2198 "z" gnus-article-date-ut
2199 "u" gnus-article-date-ut
2200 "l" gnus-article-date-local
2201 "p" gnus-article-date-english
2202 "e" gnus-article-date-lapsed
2203 "o" gnus-article-date-original
2204 "i" gnus-article-date-iso8601
2205 "s" gnus-article-date-user)
2207 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2208 "t" gnus-article-remove-trailing-blank-lines
2209 "l" gnus-article-strip-leading-blank-lines
2210 "m" gnus-article-strip-multiple-blank-lines
2211 "a" gnus-article-strip-blank-lines
2212 "A" gnus-article-strip-all-blank-lines
2213 "s" gnus-article-strip-leading-space
2214 "e" gnus-article-strip-trailing-space
2215 "w" gnus-article-remove-leading-whitespace)
2217 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2218 "v" gnus-version
2219 "d" gnus-summary-describe-group
2220 "h" gnus-summary-describe-briefly
2221 "i" gnus-info-find-node)
2223 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2224 "e" gnus-summary-expire-articles
2225 "\M-\C-e" gnus-summary-expire-articles-now
2226 "\177" gnus-summary-delete-article
2227 [delete] gnus-summary-delete-article
2228 [backspace] gnus-summary-delete-article
2229 "m" gnus-summary-move-article
2230 "r" gnus-summary-respool-article
2231 "w" gnus-summary-edit-article
2232 "c" gnus-summary-copy-article
2233 "B" gnus-summary-crosspost-article
2234 "q" gnus-summary-respool-query
2235 "t" gnus-summary-respool-trace
2236 "i" gnus-summary-import-article
2237 "I" gnus-summary-create-article
2238 "p" gnus-summary-article-posted-p)
2240 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2241 "o" gnus-summary-save-article
2242 "m" gnus-summary-save-article-mail
2243 "F" gnus-summary-write-article-file
2244 "r" gnus-summary-save-article-rmail
2245 "f" gnus-summary-save-article-file
2246 "b" gnus-summary-save-article-body-file
2247 "B" gnus-summary-write-article-body-file
2248 "h" gnus-summary-save-article-folder
2249 "v" gnus-summary-save-article-vm
2250 "p" gnus-summary-pipe-output
2251 "P" gnus-summary-muttprint)
2253 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2254 "b" gnus-summary-display-buttonized
2255 "m" gnus-summary-repair-multipart
2256 "v" gnus-article-view-part
2257 "o" gnus-article-save-part
2258 "O" gnus-article-save-part-and-strip
2259 "r" gnus-article-replace-part
2260 "d" gnus-article-delete-part
2261 "t" gnus-article-view-part-as-type
2262 "j" gnus-article-jump-to-part
2263 "c" gnus-article-copy-part
2264 "C" gnus-article-view-part-as-charset
2265 "e" gnus-article-view-part-externally
2266 "H" gnus-article-browse-html-article
2267 "E" gnus-article-encrypt-body
2268 "i" gnus-article-inline-part
2269 "|" gnus-article-pipe-part)
2271 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2272 "p" gnus-summary-mark-as-processable
2273 "u" gnus-summary-unmark-as-processable
2274 "U" gnus-summary-unmark-all-processable
2275 "v" gnus-uu-mark-over
2276 "s" gnus-uu-mark-series
2277 "r" gnus-uu-mark-region
2278 "g" gnus-uu-unmark-region
2279 "R" gnus-uu-mark-by-regexp
2280 "G" gnus-uu-unmark-by-regexp
2281 "t" gnus-uu-mark-thread
2282 "T" gnus-uu-unmark-thread
2283 "a" gnus-uu-mark-all
2284 "b" gnus-uu-mark-buffer
2285 "S" gnus-uu-mark-sparse
2286 "k" gnus-summary-kill-process-mark
2287 "y" gnus-summary-yank-process-mark
2288 "w" gnus-summary-save-process-mark
2289 "i" gnus-uu-invert-processable)
2291 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2292 ;;"x" gnus-uu-extract-any
2293 "m" gnus-summary-save-parts
2294 "u" gnus-uu-decode-uu
2295 "U" gnus-uu-decode-uu-and-save
2296 "s" gnus-uu-decode-unshar
2297 "S" gnus-uu-decode-unshar-and-save
2298 "o" gnus-uu-decode-save
2299 "O" gnus-uu-decode-save
2300 "b" gnus-uu-decode-binhex
2301 "B" gnus-uu-decode-binhex
2302 "Y" gnus-uu-decode-yenc
2303 "p" gnus-uu-decode-postscript
2304 "P" gnus-uu-decode-postscript-and-save)
2306 (gnus-define-keys
2307 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2308 "u" gnus-uu-decode-uu-view
2309 "U" gnus-uu-decode-uu-and-save-view
2310 "s" gnus-uu-decode-unshar-view
2311 "S" gnus-uu-decode-unshar-and-save-view
2312 "o" gnus-uu-decode-save-view
2313 "O" gnus-uu-decode-save-view
2314 "b" gnus-uu-decode-binhex-view
2315 "B" gnus-uu-decode-binhex-view
2316 "p" gnus-uu-decode-postscript-view
2317 "P" gnus-uu-decode-postscript-and-save-view)
2319 (defvar gnus-article-post-menu nil)
2321 (defconst gnus-summary-menu-maxlen 20)
2323 (defun gnus-summary-menu-split (menu)
2324 ;; If we have lots of elements, divide them into groups of 20
2325 ;; and make a pane (or submenu) for each one.
2326 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2327 (let ((menu menu) sublists next
2328 (i 1))
2329 (while menu
2330 ;; Pull off the next gnus-summary-menu-maxlen elements
2331 ;; and make them the next element of sublist.
2332 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2333 (if next
2334 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2335 nil))
2336 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2337 (aref (car (last menu)) 0)) menu)
2338 sublists))
2339 (setq i (1+ i))
2340 (setq menu next))
2341 (nreverse sublists))
2342 ;; Few elements--put them all in one pane.
2343 menu))
2345 (defun gnus-summary-make-menu-bar ()
2346 (gnus-turn-off-edit-menu 'summary)
2348 (unless (boundp 'gnus-summary-misc-menu)
2350 (easy-menu-define
2351 gnus-summary-kill-menu gnus-summary-mode-map ""
2352 (cons
2353 "Score"
2354 (nconc
2355 (list
2356 ["Customize" gnus-score-customize t])
2357 (gnus-make-score-map 'increase)
2358 (gnus-make-score-map 'lower)
2359 '(("Mark"
2360 ["Kill below" gnus-summary-kill-below t]
2361 ["Mark above" gnus-summary-mark-above t]
2362 ["Tick above" gnus-summary-tick-above t]
2363 ["Clear above" gnus-summary-clear-above t])
2364 ["Current article score" gnus-summary-current-score t]
2365 ["Current thread score" (gnus-summary-current-score 'total) t]
2366 ["Set score" gnus-summary-set-score t]
2367 ["Switch current score file..." gnus-score-change-score-file t]
2368 ["Set mark below..." gnus-score-set-mark-below t]
2369 ["Set expunge below..." gnus-score-set-expunge-below t]
2370 ["Edit current score file" gnus-score-edit-current-scores t]
2371 ["Edit score file..." gnus-score-edit-file t]
2372 ["Trace score" gnus-score-find-trace t]
2373 ["Find words" gnus-score-find-favorite-words t]
2374 ["Rescore buffer" gnus-summary-rescore t]
2375 ["Increase score..." gnus-summary-increase-score t]
2376 ["Lower score..." gnus-summary-lower-score t]))))
2378 ;; Define both the Article menu in the summary buffer and the
2379 ;; equivalent Commands menu in the article buffer here for
2380 ;; consistency.
2381 (let ((innards
2382 `(("Hide"
2383 ["All" gnus-article-hide t]
2384 ["Headers" gnus-article-hide-headers t]
2385 ["Signature" gnus-article-hide-signature t]
2386 ["Citation" gnus-article-hide-citation t]
2387 ["List identifiers" gnus-article-hide-list-identifiers t]
2388 ["Banner" gnus-article-strip-banner t]
2389 ["Boring headers" gnus-article-hide-boring-headers t])
2390 ("Highlight"
2391 ["All" gnus-article-highlight t]
2392 ["Headers" gnus-article-highlight-headers t]
2393 ["Signature" gnus-article-highlight-signature t]
2394 ["Citation" gnus-article-highlight-citation t])
2395 ("MIME"
2396 ["Words" gnus-article-decode-mime-words t]
2397 ["Charset" gnus-article-decode-charset t]
2398 ["QP" gnus-article-de-quoted-unreadable t]
2399 ["Base64" gnus-article-de-base64-unreadable t]
2400 ["View MIME buttons" gnus-summary-display-buttonized t]
2401 ["View MIME buttons in header"
2402 gnus-mime-buttonize-attachments-in-header t]
2403 ["View all" gnus-mime-view-all-parts t]
2404 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2405 ["Encrypt body" gnus-article-encrypt-body
2406 :active (not (gnus-group-read-only-p))
2407 :help "Encrypt the message body on disk"]
2408 ["Extract all parts..." gnus-summary-save-parts t]
2409 ("Multipart"
2410 ["Repair multipart" gnus-summary-repair-multipart t]
2411 ["Pipe part..." gnus-article-pipe-part t]
2412 ["Inline part" gnus-article-inline-part t]
2413 ["View part as type..." gnus-article-view-part-as-type t]
2414 ["Encrypt body" gnus-article-encrypt-body
2415 :active (not (gnus-group-read-only-p))
2416 :help "Encrypt the message body on disk"]
2417 ["View part externally" gnus-article-view-part-externally t]
2418 ["View HTML parts in browser" gnus-article-browse-html-article t]
2419 ["View part with charset..." gnus-article-view-part-as-charset t]
2420 ["Copy part" gnus-article-copy-part t]
2421 ["Save part..." gnus-article-save-part t]
2422 ["View part" gnus-article-view-part t]))
2423 ("Date"
2424 ["Local" gnus-article-date-local t]
2425 ["ISO8601" gnus-article-date-iso8601 t]
2426 ["UT" gnus-article-date-ut t]
2427 ["Original" gnus-article-date-original t]
2428 ["Lapsed" gnus-article-date-lapsed t]
2429 ["User-defined" gnus-article-date-user t])
2430 ("Display"
2431 ["Display HTML images" gnus-article-show-images t]
2432 ["Remove images" gnus-article-remove-images t]
2433 ["Toggle smiley" gnus-treat-smiley t]
2434 ["Show X-Face" gnus-article-display-x-face t]
2435 ["Show picons in From" gnus-treat-from-picon t]
2436 ["Show picons in mail headers" gnus-treat-mail-picon t]
2437 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2438 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2439 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2440 ("View as different encoding"
2441 ,@(gnus-summary-menu-split
2442 (mapcar
2443 (lambda (cs)
2444 ;; Since easymenu under Emacs doesn't allow
2445 ;; lambda forms for menu commands, we should
2446 ;; provide intern'ed function symbols.
2447 (let ((command (intern (format "\
2448 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2449 (fset command
2450 `(lambda ()
2451 (interactive)
2452 (let ((gnus-summary-show-article-charset-alist
2453 '((1 . ,cs))))
2454 (gnus-summary-show-article 1))))
2455 `[,(symbol-name cs) ,command t]))
2456 (sort (coding-system-list) 'string<)))))
2457 ("Washing"
2458 ("Remove Blanks"
2459 ["Leading" gnus-article-strip-leading-blank-lines t]
2460 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2461 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2462 ["All of the above" gnus-article-strip-blank-lines t]
2463 ["All" gnus-article-strip-all-blank-lines t]
2464 ["Leading space" gnus-article-strip-leading-space t]
2465 ["Trailing space" gnus-article-strip-trailing-space t]
2466 ["Leading space in headers"
2467 gnus-article-remove-leading-whitespace t])
2468 ["Overstrike" gnus-article-treat-overstrike t]
2469 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2470 ["Non-ASCII" gnus-article-treat-non-ascii t]
2471 ["Emphasis" gnus-article-emphasize t]
2472 ["Word wrap" gnus-article-fill-cited-article t]
2473 ["Fill long lines" gnus-article-fill-long-lines t]
2474 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2475 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2476 ["Remove CR" gnus-article-remove-cr t]
2477 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2478 ["Base64" gnus-article-de-base64-unreadable t]
2479 ["Rot 13" gnus-summary-caesar-message
2480 :help "\"Caesar rotate\" article by 13"]
2481 ["De-IDNA" gnus-summary-idna-message t]
2482 ["Morse decode" gnus-summary-morse-message t]
2483 ["Unix pipe..." gnus-summary-pipe-message t]
2484 ["Add buttons" gnus-article-add-buttons t]
2485 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2486 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2487 ["Verbose header" gnus-summary-verbose-headers t]
2488 ["Toggle header" gnus-summary-toggle-header t]
2489 ["Unfold headers" gnus-article-treat-unfold-headers t]
2490 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2491 ["Html" gnus-article-wash-html t]
2492 ["Unsplit URLs" gnus-article-unsplit-urls t]
2493 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2494 ["Decode HZ" gnus-article-decode-HZ t]
2495 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2496 ("(Outlook) Deuglify"
2497 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2498 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2499 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2500 ["Full (Outlook) deuglify"
2501 gnus-article-outlook-deuglify-article t])
2503 ("Output"
2504 ["Save in default format..." gnus-summary-save-article
2505 :help "Save article using default method"]
2506 ["Save in file..." gnus-summary-save-article-file
2507 :help "Save article in file"]
2508 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2509 ["Save in MH folder..." gnus-summary-save-article-folder t]
2510 ["Save in VM folder..." gnus-summary-save-article-vm t]
2511 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2512 ["Save body in file..." gnus-summary-save-article-body-file t]
2513 ["Pipe through a filter..." gnus-summary-pipe-output t]
2514 ["Print with Muttprint..." gnus-summary-muttprint t]
2515 ["Print" gnus-summary-print-article
2516 :help "Generate and print a PostScript image"])
2517 ("Copy, move,... (Backend)"
2518 :help "Copying, moving, expiring articles..."
2519 ["Respool article..." gnus-summary-respool-article t]
2520 ["Move article..." gnus-summary-move-article
2521 (gnus-check-backend-function
2522 'request-move-article gnus-newsgroup-name)]
2523 ["Copy article..." gnus-summary-copy-article t]
2524 ["Crosspost article..." gnus-summary-crosspost-article
2525 (gnus-check-backend-function
2526 'request-replace-article gnus-newsgroup-name)]
2527 ["Import file..." gnus-summary-import-article
2528 (gnus-check-backend-function
2529 'request-accept-article gnus-newsgroup-name)]
2530 ["Create article..." gnus-summary-create-article
2531 (gnus-check-backend-function
2532 'request-accept-article gnus-newsgroup-name)]
2533 ["Check if posted" gnus-summary-article-posted-p t]
2534 ["Edit article" gnus-summary-edit-article
2535 (not (gnus-group-read-only-p))]
2536 ["Delete article" gnus-summary-delete-article
2537 (gnus-check-backend-function
2538 'request-expire-articles gnus-newsgroup-name)]
2539 ["Query respool" gnus-summary-respool-query t]
2540 ["Trace respool" gnus-summary-respool-trace t]
2541 ["Delete expirable articles" gnus-summary-expire-articles-now
2542 (gnus-check-backend-function
2543 'request-expire-articles gnus-newsgroup-name)])
2544 ("Extract"
2545 ["Uudecode" gnus-uu-decode-uu :help "Decode uuencoded article(s)"]
2546 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2547 ["Unshar" gnus-uu-decode-unshar t]
2548 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2549 ["Save" gnus-uu-decode-save t]
2550 ["Binhex" gnus-uu-decode-binhex t]
2551 ["PostScript" gnus-uu-decode-postscript t]
2552 ["All MIME parts" gnus-summary-save-parts t])
2553 ("Cache"
2554 ["Enter article" gnus-cache-enter-article t]
2555 ["Remove article" gnus-cache-remove-article t])
2556 ["Translate" gnus-article-babel t]
2557 ["Select article buffer" gnus-summary-select-article-buffer t]
2558 ["Make article buffer sticky" gnus-sticky-article t]
2559 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2560 ["Isearch article..." gnus-summary-isearch-article t]
2561 ["Beginning of the article" gnus-summary-beginning-of-article t]
2562 ["End of the article" gnus-summary-end-of-article t]
2563 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2564 ["Fetch referenced articles" gnus-summary-refer-references t]
2565 ["Fetch current thread" gnus-summary-refer-thread t]
2566 ["Fetch article with id..." gnus-summary-refer-article t]
2567 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2568 ["Redisplay" gnus-summary-show-article t]
2569 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2570 (easy-menu-define
2571 gnus-summary-article-menu gnus-summary-mode-map ""
2572 (cons "Article" innards))
2574 (if (not (keymapp gnus-summary-article-menu))
2575 (easy-menu-define
2576 gnus-article-commands-menu gnus-article-mode-map ""
2577 (cons "Commands" innards))
2578 ;; Don't share the menu.
2579 (setq gnus-article-commands-menu
2580 (copy-keymap gnus-summary-article-menu))
2581 (define-key gnus-article-mode-map [menu-bar commands]
2582 (cons "Commands" gnus-article-commands-menu))))
2584 (easy-menu-define
2585 gnus-summary-thread-menu gnus-summary-mode-map ""
2586 '("Threads"
2587 ["Find all messages in thread" gnus-summary-refer-thread t]
2588 ["Toggle threading" gnus-summary-toggle-threads t]
2589 ["Hide threads" gnus-summary-hide-all-threads t]
2590 ["Show threads" gnus-summary-show-all-threads t]
2591 ["Hide thread" gnus-summary-hide-thread t]
2592 ["Show thread" gnus-summary-show-thread t]
2593 ["Go to next thread" gnus-summary-next-thread t]
2594 ["Go to previous thread" gnus-summary-prev-thread t]
2595 ["Go down thread" gnus-summary-down-thread t]
2596 ["Go up thread" gnus-summary-up-thread t]
2597 ["Top of thread" gnus-summary-top-thread t]
2598 ["Mark thread as read" gnus-summary-kill-thread t]
2599 ["Mark thread as expired" gnus-summary-expire-thread t]
2600 ["Lower thread score" gnus-summary-lower-thread t]
2601 ["Raise thread score" gnus-summary-raise-thread t]
2602 ["Rethread current" gnus-summary-rethread-current t]))
2604 (easy-menu-define
2605 gnus-summary-post-menu gnus-summary-mode-map ""
2606 `("Post"
2607 ["Send a message (mail or news)" gnus-summary-post-news
2608 :help "Compose a new message (mail or news)"]
2609 ["Followup" gnus-summary-followup
2610 :help "Post followup to this article"]
2611 ["Followup and yank" gnus-summary-followup-with-original
2612 :help "Post followup to this article, quoting its contents"]
2613 ["Supersede article" gnus-summary-supersede-article t]
2614 ["Cancel article" gnus-summary-cancel-article
2615 :help "Cancel an article you posted"]
2616 ["Reply" gnus-summary-reply t]
2617 ["Reply and yank" gnus-summary-reply-with-original t]
2618 ["Wide reply" gnus-summary-wide-reply t]
2619 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2620 :help "Mail a reply, quoting this article"]
2621 ["Very wide reply" gnus-summary-very-wide-reply t]
2622 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2623 :help "Mail a very wide reply, quoting this article"]
2624 ["Mail forward" gnus-summary-mail-forward t]
2625 ["Post forward" gnus-summary-post-forward t]
2626 ["Digest and mail" gnus-uu-digest-mail-forward t]
2627 ["Digest and post" gnus-uu-digest-post-forward t]
2628 ["Resend message" gnus-summary-resend-message t]
2629 ["Resend message edit" gnus-summary-resend-message-edit t]
2630 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2631 ["Send a mail" gnus-summary-mail-other-window t]
2632 ["Attach article to outgoing message" gnus-summary-attach-article t]
2633 ["Create a local message" gnus-summary-news-other-window t]
2634 ["Uuencode and post" gnus-uu-post-news
2635 :help "Post a uuencoded article"]
2636 ["Followup via news" gnus-summary-followup-to-mail t]
2637 ["Followup via news and yank"
2638 gnus-summary-followup-to-mail-with-original t]
2639 ["Strip signature on reply"
2640 (lambda ()
2641 (interactive)
2642 (setq message-cite-function
2643 (if (eq message-cite-function
2644 'message-cite-original-without-signature)
2645 'message-cite-original
2646 'message-cite-original-without-signature)))
2647 :visible (memq message-cite-function
2648 '(message-cite-original-without-signature
2649 message-cite-original))
2650 :style toggle
2651 :selected (eq message-cite-function
2652 'message-cite-original-without-signature)
2653 :help "Strip signature from cited article when replying."]))
2655 (cond
2656 ((not (keymapp gnus-summary-post-menu))
2657 (setq gnus-article-post-menu gnus-summary-post-menu))
2658 ((not gnus-article-post-menu)
2659 ;; Don't share post menu.
2660 (setq gnus-article-post-menu
2661 (copy-keymap gnus-summary-post-menu))))
2662 (define-key gnus-article-mode-map [menu-bar post]
2663 (cons "Post" gnus-article-post-menu))
2665 (easy-menu-define
2666 gnus-summary-misc-menu gnus-summary-mode-map ""
2667 `("Gnus"
2668 ("Mark Read"
2669 ["Mark as read" gnus-summary-mark-as-read-forward t]
2670 ["Mark same subject and select"
2671 gnus-summary-kill-same-subject-and-select t]
2672 ["Mark same subject" gnus-summary-kill-same-subject t]
2673 ["Catchup" gnus-summary-catchup
2674 :help "Mark unread articles in this group as read"]
2675 ["Catchup all" gnus-summary-catchup-all t]
2676 ["Catchup to here" gnus-summary-catchup-to-here t]
2677 ["Catchup from here" gnus-summary-catchup-from-here t]
2678 ["Catchup region" gnus-summary-mark-region-as-read mark-active]
2679 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2680 ("Mark Various"
2681 ["Tick" gnus-summary-tick-article-forward t]
2682 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2683 ["Remove marks" gnus-summary-clear-mark-forward t]
2684 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2685 ["Set bookmark" gnus-summary-set-bookmark t]
2686 ["Remove bookmark" gnus-summary-remove-bookmark t])
2687 ("Limit to"
2688 ["Marks..." gnus-summary-limit-to-marks t]
2689 ["Subject..." gnus-summary-limit-to-subject t]
2690 ["Author..." gnus-summary-limit-to-author t]
2691 ["Recipient..." gnus-summary-limit-to-recipient t]
2692 ["Address..." gnus-summary-limit-to-address t]
2693 ["Age..." gnus-summary-limit-to-age t]
2694 ["Extra..." gnus-summary-limit-to-extra t]
2695 ["Score..." gnus-summary-limit-to-score t]
2696 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2697 ["Unread" gnus-summary-limit-to-unread t]
2698 ["Unseen" gnus-summary-limit-to-unseen t]
2699 ["Singletons" gnus-summary-limit-to-singletons t]
2700 ["Replied" gnus-summary-limit-to-replied t]
2701 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2702 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2703 ["Pop limit" gnus-summary-pop-limit t]
2704 ["Show dormant" gnus-summary-limit-include-dormant t]
2705 ["Hide childless dormant"
2706 gnus-summary-limit-exclude-childless-dormant t]
2707 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2708 ["Hide marked" gnus-summary-limit-exclude-marks t]
2709 ["Show expunged" gnus-summary-limit-include-expunged t])
2710 ("Process Mark"
2711 ["Set mark" gnus-summary-mark-as-processable t]
2712 ["Remove mark" gnus-summary-unmark-as-processable t]
2713 ["Remove all marks" gnus-summary-unmark-all-processable t]
2714 ["Invert marks" gnus-uu-invert-processable t]
2715 ["Mark above" gnus-uu-mark-over t]
2716 ["Mark series" gnus-uu-mark-series t]
2717 ["Mark region" gnus-uu-mark-region mark-active]
2718 ["Unmark region" gnus-uu-unmark-region mark-active]
2719 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2720 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2721 ["Mark all" gnus-uu-mark-all t]
2722 ["Mark buffer" gnus-uu-mark-buffer t]
2723 ["Mark sparse" gnus-uu-mark-sparse t]
2724 ["Mark thread" gnus-uu-mark-thread t]
2725 ["Unmark thread" gnus-uu-unmark-thread t]
2726 ("Process Mark Sets"
2727 ["Kill" gnus-summary-kill-process-mark t]
2728 ["Yank" gnus-summary-yank-process-mark
2729 gnus-newsgroup-process-stack]
2730 ["Save" gnus-summary-save-process-mark t]
2731 ["Run command on marked..." gnus-summary-universal-argument t]))
2732 ("Registry Marks")
2733 ("Scroll article"
2734 ["Page forward" gnus-summary-next-page
2735 :help "Show next page of article"]
2736 ["Page backward" gnus-summary-prev-page
2737 :help "Show previous page of article"]
2738 ["Line forward" gnus-summary-scroll-up t])
2739 ("Move"
2740 ["Next unread article" gnus-summary-next-unread-article t]
2741 ["Previous unread article" gnus-summary-prev-unread-article t]
2742 ["Next article" gnus-summary-next-article t]
2743 ["Previous article" gnus-summary-prev-article t]
2744 ["Next unread subject" gnus-summary-next-unread-subject t]
2745 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2746 ["Next article same subject" gnus-summary-next-same-subject t]
2747 ["Previous article same subject" gnus-summary-prev-same-subject t]
2748 ["First unread article" gnus-summary-first-unread-article t]
2749 ["Best unread article" gnus-summary-best-unread-article t]
2750 ["Go to subject number..." gnus-summary-goto-subject t]
2751 ["Go to article number..." gnus-summary-goto-article t]
2752 ["Go to the last article" gnus-summary-goto-last-article t]
2753 ["Pop article off history" gnus-summary-pop-article t])
2754 ("Sort"
2755 ["Sort by number" gnus-summary-sort-by-number t]
2756 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2757 ["Sort by author" gnus-summary-sort-by-author t]
2758 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2759 ["Sort by subject" gnus-summary-sort-by-subject t]
2760 ["Sort by date" gnus-summary-sort-by-date t]
2761 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2762 ["Sort by score" gnus-summary-sort-by-score t]
2763 ["Sort by lines" gnus-summary-sort-by-lines t]
2764 ["Sort by characters" gnus-summary-sort-by-chars t]
2765 ["Sort by marks" gnus-summary-sort-by-marks t]
2766 ["Randomize" gnus-summary-sort-by-random t]
2767 ["Original sort" gnus-summary-sort-by-original t])
2768 ("Help"
2769 ["Describe group" gnus-summary-describe-group t]
2770 ["Read manual" gnus-info-find-node t])
2771 ("Modes"
2772 ["Pick and read" gnus-pick-mode t]
2773 ["Binary" gnus-binary-mode t])
2774 ("Regeneration"
2775 ["Regenerate" gnus-summary-prepare t]
2776 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2777 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2778 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2779 ["Toggle threading" gnus-summary-toggle-threads t])
2780 ["See old articles" gnus-summary-insert-old-articles t]
2781 ["See new articles" gnus-summary-insert-new-articles t]
2782 ["Filter articles..." gnus-summary-execute-command t]
2783 ["Run command on articles..." gnus-summary-universal-argument t]
2784 ["Search articles forward..." gnus-summary-search-article-forward t]
2785 ["Search articles backward..." gnus-summary-search-article-backward t]
2786 ["Toggle line truncation" toggle-truncate-lines t]
2787 ["Expand window" gnus-summary-expand-window t]
2788 ["Expire expirable articles" gnus-summary-expire-articles
2789 (gnus-check-backend-function
2790 'request-expire-articles gnus-newsgroup-name)]
2791 ["Edit local kill file" gnus-summary-edit-local-kill t]
2792 ["Edit main kill file" gnus-summary-edit-global-kill t]
2793 ["Edit group parameters" gnus-summary-edit-parameters t]
2794 ["Customize group parameters" gnus-summary-customize-parameters t]
2795 ["Send a bug report" gnus-bug t]
2796 ("Exit"
2797 ["Catchup and exit" gnus-summary-catchup-and-exit
2798 :help "Mark unread articles in this group as read, then exit"]
2799 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2800 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2801 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2802 ["Exit group" gnus-summary-exit
2803 :help "Exit current group, return to group selection mode"]
2804 ["Exit group without updating" gnus-summary-exit-no-update t]
2805 ["Exit and goto next group" gnus-summary-next-group t]
2806 ["Exit and goto prev group" gnus-summary-prev-group t]
2807 ["Reselect group" gnus-summary-reselect-current-group t]
2808 ["Rescan group" gnus-summary-rescan-group t]
2809 ["Update dribble" gnus-summary-save-newsrc t])))
2811 (gnus-run-hooks 'gnus-summary-menu-hook)))
2813 (defvar gnus-summary-tool-bar-map nil)
2815 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2816 ;; affect _new_ message buffers. We might add a function that walks thru all
2817 ;; summary-mode buffers and force the update.
2818 (defun gnus-summary-tool-bar-update (&optional symbol value)
2819 "Update summary mode toolbar.
2820 Setter function for custom variables."
2821 (setq-default gnus-summary-tool-bar-map nil)
2822 (when symbol
2823 ;; When used as ":set" function:
2824 (set-default symbol value))
2825 (when (gnus-buffer-live-p gnus-summary-buffer)
2826 (with-current-buffer gnus-summary-buffer
2827 (gnus-summary-make-tool-bar))))
2829 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2830 'gnus-summary-tool-bar-gnome
2831 'gnus-summary-tool-bar-retro)
2832 "Specifies the Gnus summary tool bar.
2834 It can be either a list or a symbol referring to a list. See
2835 `gmm-tool-bar-from-list' for the format of the list. The
2836 default key map is `gnus-summary-mode-map'.
2838 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2839 `gnus-summary-tool-bar-retro'."
2840 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2841 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2842 (repeat :tag "User defined list" gmm-tool-bar-item)
2843 (symbol))
2844 :version "23.1" ;; No Gnus
2845 :initialize 'custom-initialize-default
2846 :set 'gnus-summary-tool-bar-update
2847 :group 'gnus-summary)
2849 (defcustom gnus-summary-tool-bar-gnome
2850 '((gnus-summary-post-news "mail/compose" nil)
2851 (gnus-summary-insert-new-articles "mail/inbox" nil
2852 :visible (or (not gnus-agent)
2853 gnus-plugged))
2854 (gnus-summary-reply-with-original "mail/reply")
2855 (gnus-summary-reply "mail/reply" nil :visible nil)
2856 (gnus-summary-followup-with-original "mail/reply-all")
2857 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2858 (gnus-summary-mail-forward "mail/forward")
2859 (gnus-summary-save-article "mail/save")
2860 (gnus-summary-search-article-forward "search" nil :visible nil)
2861 (gnus-summary-print-article "print")
2862 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2863 ;; Some new commands that may need more suitable icons:
2864 (gnus-summary-save-newsrc "save" nil :visible nil)
2865 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2866 (gnus-summary-prev-article "left-arrow")
2867 (gnus-summary-next-article "right-arrow")
2868 (gnus-summary-next-page "next-page")
2869 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2871 ;; Maybe some sort-by-... could be added:
2872 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2873 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2874 (gnus-summary-mark-as-expirable
2875 "delete" nil
2876 :visible (gnus-check-backend-function 'request-expire-articles
2877 gnus-newsgroup-name))
2878 (gnus-summary-mark-as-spam
2879 "mail/spam" t
2880 :visible (and (fboundp 'spam-group-ham-contents-p)
2881 (spam-group-ham-contents-p gnus-newsgroup-name))
2882 :help "Mark as spam")
2883 (gnus-summary-mark-as-read-forward
2884 "mail/not-spam" nil
2885 :visible (and (fboundp 'spam-group-spam-contents-p)
2886 (spam-group-spam-contents-p gnus-newsgroup-name)))
2888 (gnus-summary-exit "exit")
2889 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2890 (gnus-info-find-node "help"))
2891 "List of functions for the summary tool bar (GNOME style).
2893 See `gmm-tool-bar-from-list' for the format of the list."
2894 :type '(repeat gmm-tool-bar-item)
2895 :version "23.1" ;; No Gnus
2896 :initialize 'custom-initialize-default
2897 :set 'gnus-summary-tool-bar-update
2898 :group 'gnus-summary)
2900 (defcustom gnus-summary-tool-bar-retro
2901 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2902 (gnus-summary-next-unread-article "gnus/next-ur")
2903 (gnus-summary-post-news "gnus/post")
2904 (gnus-summary-followup-with-original "gnus/fuwo")
2905 (gnus-summary-followup "gnus/followup")
2906 (gnus-summary-reply-with-original "gnus/reply-wo")
2907 (gnus-summary-reply "gnus/reply")
2908 (gnus-summary-caesar-message "gnus/rot13")
2909 (gnus-uu-decode-uu "gnus/uu-decode")
2910 (gnus-summary-save-article-file "gnus/save-aif")
2911 (gnus-summary-save-article "gnus/save-art")
2912 (gnus-uu-post-news "gnus/uu-post")
2913 (gnus-summary-catchup "gnus/catchup")
2914 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2915 (gnus-summary-exit "gnus/exit-summ")
2916 ;; Some new command that may need more suitable icons:
2917 (gnus-summary-print-article "gnus/print" nil :visible nil)
2918 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2919 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2920 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2921 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2922 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2923 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2925 (gnus-info-find-node "gnus/help" nil :visible nil))
2926 "List of functions for the summary tool bar (retro look).
2928 See `gmm-tool-bar-from-list' for the format of the list."
2929 :type '(repeat gmm-tool-bar-item)
2930 :version "23.1" ;; No Gnus
2931 :initialize 'custom-initialize-default
2932 :set 'gnus-summary-tool-bar-update
2933 :group 'gnus-summary)
2935 (defcustom gnus-summary-tool-bar-zap-list t
2936 "List of icon items from the global tool bar.
2937 These items are not displayed in the Gnus summary mode tool bar.
2939 See `gmm-tool-bar-from-list' for the format of the list."
2940 :type 'gmm-tool-bar-zap-list
2941 :version "23.1" ;; No Gnus
2942 :initialize 'custom-initialize-default
2943 :set 'gnus-summary-tool-bar-update
2944 :group 'gnus-summary)
2946 (defvar image-load-path)
2947 (defvar tool-bar-map)
2948 (declare-function image-load-path-for-library "image"
2949 (library image &optional path no-error))
2951 (defun gnus-summary-make-tool-bar (&optional force)
2952 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2953 When FORCE, rebuild the tool bar."
2954 (when (and (boundp 'tool-bar-mode)
2955 tool-bar-mode
2956 (or (not gnus-summary-tool-bar-map) force))
2957 (let* ((load-path
2958 (image-load-path-for-library "gnus" "mail/save.xpm" nil t))
2959 (image-load-path (cons (car load-path) image-load-path))
2960 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2961 gnus-summary-tool-bar-zap-list
2962 'gnus-summary-mode-map)))
2963 (when map
2964 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2965 ;; uses its value.
2966 (setq gnus-summary-tool-bar-map map))))
2967 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2969 (defun gnus-make-score-map (type)
2970 "Make a summary score map of type TYPE."
2971 (if t
2973 (let ((headers '(("author" "from" string)
2974 ("subject" "subject" string)
2975 ("article body" "body" string)
2976 ("article head" "head" string)
2977 ("xref" "xref" string)
2978 ("extra header" "extra" string)
2979 ("lines" "lines" number)
2980 ("followups to author" "followup" string)))
2981 (types '((number ("less than" <)
2982 ("greater than" >)
2983 ("equal" =))
2984 (string ("substring" s)
2985 ("exact string" e)
2986 ("fuzzy string" f)
2987 ("regexp" r))))
2988 (perms '(("temporary" (current-time-string))
2989 ("permanent" nil)
2990 ("immediate" now)))
2991 header)
2992 (list
2993 (apply
2994 'nconc
2995 (list
2996 (if (eq type 'lower)
2997 "Lower score"
2998 "Increase score"))
2999 (let (outh)
3000 (while headers
3001 (setq header (car headers))
3002 (setq outh
3003 (cons
3004 (apply
3005 'nconc
3006 (list (car header))
3007 (let ((ts (cdr (assoc (nth 2 header) types)))
3008 outt)
3009 (while ts
3010 (setq outt
3011 (cons
3012 (apply
3013 'nconc
3014 (list (caar ts))
3015 (let ((ps perms)
3016 outp)
3017 (while ps
3018 (setq outp
3019 (cons
3020 (vector
3021 (caar ps)
3022 (list
3023 'gnus-summary-score-entry
3024 (nth 1 header)
3025 (if (or (string= (nth 1 header)
3026 "head")
3027 (string= (nth 1 header)
3028 "body"))
3030 (list 'gnus-summary-header
3031 (nth 1 header)))
3032 (list 'quote (nth 1 (car ts)))
3033 (list 'gnus-score-delta-default
3034 nil)
3035 (nth 1 (car ps))
3038 outp))
3039 (setq ps (cdr ps)))
3040 (list (nreverse outp))))
3041 outt))
3042 (setq ts (cdr ts)))
3043 (list (nreverse outt))))
3044 outh))
3045 (setq headers (cdr headers)))
3046 (list (nreverse outh))))))))
3049 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3050 (defvar bookmark-make-record-function)
3052 (defvar bidi-paragraph-direction)
3054 (defun gnus-summary-mode (&optional group)
3055 "Major mode for reading articles.
3057 All normal editing commands are switched off.
3058 \\<gnus-summary-mode-map>
3059 Each line in this buffer represents one article. To read an
3060 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3061 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3062 respectively.
3064 You can also post articles and send mail from this buffer. To
3065 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3066 of an article, type `\\[gnus-summary-reply]'.
3068 There are approx. one gazillion commands you can execute in this
3069 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3071 The following commands are available:
3073 \\{gnus-summary-mode-map}"
3074 ;; FIXME: Use define-derived-mode.
3075 (interactive)
3076 (kill-all-local-variables)
3077 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3078 (gnus-summary-make-local-variables))
3079 (gnus-summary-make-local-variables)
3080 (setq gnus-newsgroup-name group)
3081 (when (gnus-visual-p 'summary-menu 'menu)
3082 (gnus-summary-make-menu-bar)
3083 (gnus-summary-make-tool-bar))
3084 (gnus-make-thread-indent-array)
3085 (gnus-simplify-mode-line)
3086 (setq major-mode 'gnus-summary-mode)
3087 (setq mode-name "Summary")
3088 (use-local-map gnus-summary-mode-map)
3089 (buffer-disable-undo)
3090 (setq buffer-read-only t
3091 show-trailing-whitespace nil
3092 truncate-lines t
3093 bidi-paragraph-direction 'left-to-right)
3094 (add-to-invisibility-spec '(gnus-sum . t))
3095 (gnus-summary-set-display-table)
3096 (gnus-set-default-directory)
3097 (make-local-variable 'gnus-summary-line-format)
3098 (make-local-variable 'gnus-summary-line-format-spec)
3099 (make-local-variable 'gnus-summary-dummy-line-format)
3100 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3101 (make-local-variable 'gnus-summary-mark-positions)
3102 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3103 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3104 (turn-on-gnus-mailing-list-mode)
3105 (mm-enable-multibyte)
3106 (set (make-local-variable 'bookmark-make-record-function)
3107 'gnus-summary-bookmark-make-record)
3108 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3109 (gnus-update-summary-mark-positions))
3111 (defun gnus-summary-make-local-variables ()
3112 "Make all the local summary buffer variables."
3113 (let (global)
3114 (dolist (local gnus-summary-local-variables)
3115 (if (consp local)
3116 (progn
3117 (if (eq (cdr local) 'global)
3118 ;; Copy the global value of the variable.
3119 (setq global (symbol-value (car local)))
3120 ;; Use the value from the list.
3121 (setq global (eval (cdr local))))
3122 (set (make-local-variable (car local)) global))
3123 ;; Simple nil-valued local variable.
3124 (set (make-local-variable local) nil)))))
3126 ;; Summary data functions.
3128 (defmacro gnus-data-number (data)
3129 `(car ,data))
3131 (defmacro gnus-data-set-number (data number)
3132 `(setcar ,data ,number))
3134 (defmacro gnus-data-mark (data)
3135 `(nth 1 ,data))
3137 (defmacro gnus-data-set-mark (data mark)
3138 `(setcar (nthcdr 1 ,data) ,mark))
3140 (defmacro gnus-data-pos (data)
3141 `(nth 2 ,data))
3143 (defmacro gnus-data-set-pos (data pos)
3144 `(setcar (nthcdr 2 ,data) ,pos))
3146 (defmacro gnus-data-header (data)
3147 `(nth 3 ,data))
3149 (defmacro gnus-data-set-header (data header)
3150 `(setf (nth 3 ,data) ,header))
3152 (defmacro gnus-data-level (data)
3153 `(nth 4 ,data))
3155 (defmacro gnus-data-unread-p (data)
3156 `(= (nth 1 ,data) gnus-unread-mark))
3158 (defmacro gnus-data-read-p (data)
3159 `(/= (nth 1 ,data) gnus-unread-mark))
3161 (defmacro gnus-data-pseudo-p (data)
3162 `(consp (nth 3 ,data)))
3164 (defmacro gnus-data-find (number)
3165 `(assq ,number gnus-newsgroup-data))
3167 (defmacro gnus-data-find-list (number &optional data)
3168 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3169 (memq (assq ,number bdata)
3170 bdata)))
3172 (defmacro gnus-data-make (number mark pos header level)
3173 `(list ,number ,mark ,pos ,header ,level))
3175 (defun gnus-data-enter (after-article number mark pos header level offset)
3176 (let ((data (gnus-data-find-list after-article)))
3177 (unless data
3178 (error "No such article: %d" after-article))
3179 (setcdr data (cons (gnus-data-make number mark pos header level)
3180 (cdr data)))
3181 (setq gnus-newsgroup-data-reverse nil)
3182 (gnus-data-update-list (cddr data) offset)))
3184 (defun gnus-data-enter-list (after-article list &optional offset)
3185 (when list
3186 (let ((data (and after-article (gnus-data-find-list after-article)))
3187 (ilist list))
3188 (if (not (or data
3189 after-article))
3190 (let ((odata gnus-newsgroup-data))
3191 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3192 (when offset
3193 (gnus-data-update-list odata offset)))
3194 ;; Find the last element in the list to be spliced into the main
3195 ;; list.
3196 (setq list (last list))
3197 (if (not data)
3198 (progn
3199 (setcdr list gnus-newsgroup-data)
3200 (setq gnus-newsgroup-data ilist)
3201 (when offset
3202 (gnus-data-update-list (cdr list) offset)))
3203 (setcdr list (cdr data))
3204 (setcdr data ilist)
3205 (when offset
3206 (gnus-data-update-list (cdr list) offset))))
3207 (setq gnus-newsgroup-data-reverse nil))))
3209 (defun gnus-data-remove (article &optional offset)
3210 (let ((data gnus-newsgroup-data))
3211 (if (= (gnus-data-number (car data)) article)
3212 (progn
3213 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3214 gnus-newsgroup-data-reverse nil)
3215 (when offset
3216 (gnus-data-update-list gnus-newsgroup-data offset)))
3217 (while (cdr data)
3218 (when (= (gnus-data-number (cadr data)) article)
3219 (setcdr data (cddr data))
3220 (when offset
3221 (gnus-data-update-list (cdr data) offset))
3222 (setq data nil
3223 gnus-newsgroup-data-reverse nil))
3224 (setq data (cdr data))))))
3226 (defmacro gnus-data-list (backward)
3227 `(if ,backward
3228 (or gnus-newsgroup-data-reverse
3229 (setq gnus-newsgroup-data-reverse
3230 (reverse gnus-newsgroup-data)))
3231 gnus-newsgroup-data))
3233 (defun gnus-data-update-list (data offset)
3234 "Add OFFSET to the POS of all data entries in DATA."
3235 (setq gnus-newsgroup-data-reverse nil)
3236 (while data
3237 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3238 (setq data (cdr data))))
3240 (defun gnus-summary-article-pseudo-p (article)
3241 "Say whether this article is a pseudo article or not."
3242 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3244 (defmacro gnus-summary-article-sparse-p (article)
3245 "Say whether this article is a sparse article or not."
3246 `(memq ,article gnus-newsgroup-sparse))
3248 (defmacro gnus-summary-article-ancient-p (article)
3249 "Say whether this article is a sparse article or not."
3250 `(memq ,article gnus-newsgroup-ancient))
3252 (defun gnus-article-children (number)
3253 "Return a list of all children to NUMBER."
3254 (let* ((data (gnus-data-find-list number))
3255 (level (gnus-data-level (car data)))
3256 children)
3257 (setq data (cdr data))
3258 (while (and data
3259 (= (gnus-data-level (car data)) (1+ level)))
3260 (push (gnus-data-number (car data)) children)
3261 (setq data (cdr data)))
3262 children))
3264 (defmacro gnus-summary-skip-intangible ()
3265 "If the current article is intangible, then jump to a different article."
3266 '(let ((to (get-text-property (point) 'gnus-intangible)))
3267 (and to (gnus-summary-goto-subject to))))
3269 (defmacro gnus-summary-article-intangible-p ()
3270 "Say whether this article is intangible or not."
3271 '(get-text-property (point) 'gnus-intangible))
3273 ;; Some summary mode macros.
3275 (defmacro gnus-summary-article-number ()
3276 "The article number of the article on the current line.
3277 If there isn't an article number here, then we return the current
3278 article number."
3279 '(progn
3280 (gnus-summary-skip-intangible)
3281 (or (get-text-property (point) 'gnus-number)
3282 (gnus-summary-last-subject))))
3284 (defmacro gnus-summary-article-header (&optional number)
3285 "Return the header of article NUMBER."
3286 `(gnus-data-header (gnus-data-find
3287 ,(or number '(gnus-summary-article-number)))))
3289 (defmacro gnus-summary-thread-level (&optional number)
3290 "Return the level of thread that starts with article NUMBER."
3291 `(if (and (eq gnus-summary-make-false-root 'dummy)
3292 (get-text-property (point) 'gnus-intangible))
3294 (gnus-data-level (gnus-data-find
3295 ,(or number '(gnus-summary-article-number))))))
3297 (defmacro gnus-summary-article-mark (&optional number)
3298 "Return the mark of article NUMBER."
3299 `(gnus-data-mark (gnus-data-find
3300 ,(or number '(gnus-summary-article-number)))))
3302 (defmacro gnus-summary-article-pos (&optional number)
3303 "Return the position of the line of article NUMBER."
3304 `(gnus-data-pos (gnus-data-find
3305 ,(or number '(gnus-summary-article-number)))))
3307 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3308 (defmacro gnus-summary-article-subject (&optional number)
3309 "Return current subject string or nil if nothing."
3310 `(let ((headers
3311 ,(if number
3312 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3313 '(gnus-data-header (assq (gnus-summary-article-number)
3314 gnus-newsgroup-data)))))
3315 (and headers
3316 (vectorp headers)
3317 (mail-header-subject headers))))
3319 (defmacro gnus-summary-article-score (&optional number)
3320 "Return current article score."
3321 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3322 gnus-newsgroup-scored))
3323 gnus-summary-default-score 0))
3325 (defun gnus-summary-article-children (&optional number)
3326 "Return a list of article numbers that are children of article NUMBER."
3327 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3328 (level (gnus-data-level (car data)))
3329 l children)
3330 (while (and (setq data (cdr data))
3331 (> (setq l (gnus-data-level (car data))) level))
3332 (and (= (1+ level) l)
3333 (push (gnus-data-number (car data))
3334 children)))
3335 (nreverse children)))
3337 (defun gnus-summary-article-parent (&optional number)
3338 "Return the article number of the parent of article NUMBER."
3339 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3340 (gnus-data-list t)))
3341 (level (gnus-data-level (car data))))
3342 (if (zerop level)
3343 () ; This is a root.
3344 ;; We search until we find an article with a level less than
3345 ;; this one. That function has to be the parent.
3346 (while (and (setq data (cdr data))
3347 (not (< (gnus-data-level (car data)) level))))
3348 (and data (gnus-data-number (car data))))))
3350 (defun gnus-unread-mark-p (mark)
3351 "Say whether MARK is the unread mark."
3352 (= mark gnus-unread-mark))
3354 (defun gnus-read-mark-p (mark)
3355 "Say whether MARK is one of the marks that mark as read.
3356 This is all marks except unread, ticked, dormant, and expirable."
3357 (not (or (= mark gnus-unread-mark)
3358 (= mark gnus-ticked-mark)
3359 (= mark gnus-spam-mark)
3360 (= mark gnus-dormant-mark)
3361 (= mark gnus-expirable-mark))))
3363 (defmacro gnus-article-mark (number)
3364 "Return the MARK of article NUMBER.
3365 This macro should only be used when computing the mark the \"first\"
3366 time; i.e., when generating the summary lines. After that,
3367 `gnus-summary-article-mark' should be used to examine the
3368 marks of articles."
3369 `(cond
3370 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3371 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3372 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3373 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3374 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3375 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3376 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3377 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3378 gnus-ancient-mark))))
3380 ;; Saving hidden threads.
3382 (defmacro gnus-save-hidden-threads (&rest forms)
3383 "Save hidden threads, eval FORMS, and restore the hidden threads."
3384 (let ((config (make-symbol "config")))
3385 `(let ((,config (gnus-hidden-threads-configuration)))
3386 (unwind-protect
3387 (save-excursion
3388 ,@forms)
3389 (gnus-restore-hidden-threads-configuration ,config)))))
3390 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3391 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3393 (defun gnus-data-compute-positions ()
3394 "Compute the positions of all articles."
3395 (setq gnus-newsgroup-data-reverse nil)
3396 (let ((data gnus-newsgroup-data))
3397 (save-excursion
3398 (gnus-save-hidden-threads
3399 (gnus-summary-show-all-threads)
3400 (goto-char (point-min))
3401 (while data
3402 (while (get-text-property (point) 'gnus-intangible)
3403 (forward-line 1))
3404 (gnus-data-set-pos (car data) (+ (point) 3))
3405 (setq data (cdr data))
3406 (forward-line 1))))))
3408 (defun gnus-hidden-threads-configuration ()
3409 "Return the current hidden threads configuration."
3410 (save-excursion
3411 (let (config)
3412 (goto-char (point-min))
3413 (while (not (eobp))
3414 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3415 (push (save-excursion (forward-line 0) (point)) config))
3416 (forward-line 1))
3417 config)))
3419 (defun gnus-restore-hidden-threads-configuration (config)
3420 "Restore hidden threads configuration from CONFIG."
3421 (save-excursion
3422 (let (point (inhibit-read-only t))
3423 (while (setq point (pop config))
3424 (goto-char point)
3425 (gnus-summary-hide-thread)))))
3427 ;; Various summary mode internalish functions.
3429 (defun gnus-mouse-pick-article (e)
3430 (interactive "e")
3431 (mouse-set-point e)
3432 (gnus-summary-next-page nil t))
3434 (defun gnus-summary-set-display-table ()
3435 "Change the display table.
3436 Odd characters have a tendency to mess
3437 up nicely formatted displays - we make all possible glyphs
3438 display only a single character."
3440 ;; We start from the standard display table, if any.
3441 (let ((table (or (copy-sequence standard-display-table)
3442 (make-display-table)))
3443 (i 32))
3444 ;; Nix out all the control chars...
3445 (while (>= (setq i (1- i)) 0)
3446 (aset table i [??]))
3447 ;; ... but not newline and cr, of course. (cr is necessary for the
3448 ;; selective display).
3449 (aset table ?\n nil)
3450 (aset table ?\r nil)
3451 ;; We keep TAB as well.
3452 (aset table ?\t nil)
3453 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3454 ;; Emacs 23 (unicode), that are not set already.
3455 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3457 256)))
3458 (while (>= (setq i (1- i)) 127)
3459 ;; Only modify if the entry is nil.
3460 (unless (aref table i)
3461 (aset table i [??]))))
3462 (setq buffer-display-table table)))
3464 (defun gnus-summary-set-article-display-arrow (pos)
3465 "Update the overlay arrow to point to line at position POS."
3466 (when gnus-summary-display-arrow
3467 (make-local-variable 'overlay-arrow-position)
3468 (make-local-variable 'overlay-arrow-string)
3469 (save-excursion
3470 (goto-char pos)
3471 (beginning-of-line)
3472 (unless overlay-arrow-position
3473 (setq overlay-arrow-position (make-marker)))
3474 (setq overlay-arrow-string "=>"
3475 overlay-arrow-position (set-marker overlay-arrow-position
3476 (point)
3477 (current-buffer))))))
3479 (defun gnus-summary-setup-buffer (group)
3480 "Initialize summary buffer.
3481 If the setup was successful, non-nil is returned."
3482 (let ((buffer (gnus-summary-buffer-name group))
3483 (dead-name (concat "*Dead Summary "
3484 (gnus-group-decoded-name group) "*")))
3485 ;; If a dead summary buffer exists, we kill it.
3486 (when (gnus-buffer-live-p dead-name)
3487 (gnus-kill-buffer dead-name))
3488 (if (get-buffer buffer)
3489 (progn
3490 (set-buffer buffer)
3491 (setq gnus-summary-buffer (current-buffer))
3492 (not gnus-newsgroup-prepared))
3493 (set-buffer (gnus-get-buffer-create buffer))
3494 (setq gnus-summary-buffer (current-buffer))
3495 (gnus-summary-mode group)
3496 (when (gnus-group-quit-config group)
3497 (set (make-local-variable 'gnus-single-article-buffer) nil))
3498 (make-local-variable 'gnus-article-buffer)
3499 (make-local-variable 'gnus-article-current)
3500 (make-local-variable 'gnus-original-article-buffer)
3501 (setq gnus-newsgroup-name group)
3502 ;; Set any local variables in the group parameters.
3503 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3504 t)))
3506 (defun gnus-set-global-variables ()
3507 "Set the global equivalents of the buffer-local variables.
3508 They are set to the latest values they had. These reflect the summary
3509 buffer that was in action when the last article was fetched."
3510 (when (derived-mode-p 'gnus-summary-mode)
3511 (setq gnus-summary-buffer (current-buffer))
3512 (let ((name gnus-newsgroup-name)
3513 (marked gnus-newsgroup-marked)
3514 (spam gnus-newsgroup-spam-marked)
3515 (unread gnus-newsgroup-unreads)
3516 (headers gnus-current-headers)
3517 (data gnus-newsgroup-data)
3518 (summary gnus-summary-buffer)
3519 (article-buffer gnus-article-buffer)
3520 (original gnus-original-article-buffer)
3521 (gac gnus-article-current)
3522 (reffed gnus-reffed-article-number)
3523 (score-file gnus-current-score-file)
3524 (default-charset gnus-newsgroup-charset)
3525 vlist)
3526 (let ((locals gnus-newsgroup-variables))
3527 (while locals
3528 (if (consp (car locals))
3529 (push (eval (caar locals)) vlist)
3530 (push (eval (car locals)) vlist))
3531 (setq locals (cdr locals)))
3532 (setq vlist (nreverse vlist)))
3533 (with-temp-buffer
3534 (setq gnus-newsgroup-name name
3535 gnus-newsgroup-marked marked
3536 gnus-newsgroup-spam-marked spam
3537 gnus-newsgroup-unreads unread
3538 gnus-current-headers headers
3539 gnus-newsgroup-data data
3540 gnus-article-current gac
3541 gnus-summary-buffer summary
3542 gnus-article-buffer article-buffer
3543 gnus-original-article-buffer original
3544 gnus-reffed-article-number reffed
3545 gnus-current-score-file score-file
3546 gnus-newsgroup-charset default-charset)
3547 (let ((locals gnus-newsgroup-variables))
3548 (while locals
3549 (if (consp (car locals))
3550 (set (caar locals) (pop vlist))
3551 (set (car locals) (pop vlist)))
3552 (setq locals (cdr locals))))))))
3554 (defun gnus-summary-article-unread-p (article)
3555 "Say whether ARTICLE is unread or not."
3556 (memq article gnus-newsgroup-unreads))
3558 (defun gnus-summary-first-article-p (&optional article)
3559 "Return whether ARTICLE is the first article in the buffer."
3560 (if (not (setq article (or article (gnus-summary-article-number))))
3562 (eq article (caar gnus-newsgroup-data))))
3564 (defun gnus-summary-last-article-p (&optional article)
3565 "Return whether ARTICLE is the last article in the buffer."
3566 (if (not (setq article (or article (gnus-summary-article-number))))
3567 ;; All non-existent numbers are the last article. :-)
3569 (not (cdr (gnus-data-find-list article)))))
3571 (defun gnus-make-thread-indent-array (&optional n)
3572 (when (or n
3573 (progn (setq n 200) nil)
3574 (null gnus-thread-indent-array)
3575 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3576 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3577 gnus-thread-indent-array-level gnus-thread-indent-level)
3578 (while (>= n 0)
3579 (aset gnus-thread-indent-array n
3580 (make-string (* n gnus-thread-indent-level) ? ))
3581 (setq n (1- n)))))
3583 (defun gnus-update-summary-mark-positions ()
3584 "Compute where the summary marks are to go."
3585 (save-excursion
3586 (when (gnus-buffer-exists-p gnus-summary-buffer)
3587 (set-buffer gnus-summary-buffer))
3588 (let ((spec gnus-summary-line-format-spec)
3589 pos)
3590 (save-excursion
3591 (gnus-set-work-buffer)
3592 (let ((gnus-tmp-unread ?Z)
3593 (gnus-replied-mark ?Z)
3594 (gnus-score-below-mark ?Z)
3595 (gnus-score-over-mark ?Z)
3596 (gnus-undownloaded-mark ?Z)
3597 (gnus-summary-line-format-spec spec)
3598 (gnus-newsgroup-downloadable '(0))
3599 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3600 case-fold-search ignores)
3601 ;; Here, all marks are bound to Z.
3602 (gnus-summary-insert-line header
3603 0 nil t gnus-tmp-unread t nil "" nil 1)
3604 (goto-char (point-min))
3605 ;; Memorize the positions of the same characters as dummy marks.
3606 (while (re-search-forward "[A-D]" nil t)
3607 (push (point) ignores))
3608 (erase-buffer)
3609 ;; We use A-D as dummy marks in order to know column positions
3610 ;; where marks should be inserted.
3611 (setq gnus-tmp-unread ?A
3612 gnus-replied-mark ?B
3613 gnus-score-below-mark ?C
3614 gnus-score-over-mark ?C
3615 gnus-undownloaded-mark ?D)
3616 (gnus-summary-insert-line header
3617 0 nil t gnus-tmp-unread t nil "" nil 1)
3618 ;; Ignore characters which aren't dummy marks.
3619 (dolist (p ignores)
3620 (delete-region (goto-char (1- p)) p)
3621 (insert ?Z))
3622 (goto-char (point-min))
3623 (setq pos (list (cons 'unread
3624 (and (search-forward "A" nil t)
3625 (- (point) (point-min) 1)))))
3626 (goto-char (point-min))
3627 (push (cons 'replied (and (search-forward "B" nil t)
3628 (- (point) (point-min) 1)))
3629 pos)
3630 (goto-char (point-min))
3631 (push (cons 'score (and (search-forward "C" nil t)
3632 (- (point) (point-min) 1)))
3633 pos)
3634 (goto-char (point-min))
3635 (push (cons 'download (and (search-forward "D" nil t)
3636 (- (point) (point-min) 1)))
3637 pos)))
3638 (setq gnus-summary-mark-positions pos))))
3640 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3641 "Insert a dummy root in the summary buffer."
3642 (beginning-of-line)
3643 (add-text-properties
3644 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3645 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3647 (defun gnus-summary-extract-address-component (from)
3648 (or (car (funcall gnus-extract-address-components from))
3649 from))
3651 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3652 (let ((mail-parse-charset gnus-newsgroup-charset)
3653 ;; Is it really necessary to do this next part for each summary line?
3654 ;; Luckily, doesn't seem to slow things down much.
3655 (mail-parse-ignored-charsets
3656 (with-current-buffer gnus-summary-buffer
3657 gnus-newsgroup-ignored-charsets)))
3659 (and gnus-ignored-from-addresses
3660 (cond ((functionp gnus-ignored-from-addresses)
3661 (funcall gnus-ignored-from-addresses
3662 (mail-strip-quoted-names gnus-tmp-from)))
3663 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3664 (let ((extra-headers (mail-header-extra header))
3666 newsgroups)
3667 (cond
3668 ((setq to (cdr (assq 'To extra-headers)))
3669 (concat gnus-summary-to-prefix
3670 (inline
3671 (gnus-summary-extract-address-component
3672 (funcall gnus-decode-encoded-address-function to)))))
3673 ((setq newsgroups
3675 (cdr (assq 'Newsgroups extra-headers))
3676 (and
3677 (memq 'Newsgroups gnus-extra-headers)
3678 (eq (car (gnus-find-method-for-group
3679 gnus-newsgroup-name)) 'nntp)
3680 (gnus-group-real-name gnus-newsgroup-name))))
3681 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3682 (bidi-string-mark-left-to-right
3683 (inline
3684 (gnus-summary-extract-address-component gnus-tmp-from))))))
3686 (defun gnus-summary-insert-line (gnus-tmp-header
3687 gnus-tmp-level gnus-tmp-current
3688 undownloaded gnus-tmp-unread gnus-tmp-replied
3689 gnus-tmp-expirable gnus-tmp-subject-or-nil
3690 &optional gnus-tmp-dummy gnus-tmp-score
3691 gnus-tmp-process)
3692 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3693 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3694 gnus-tmp-level)))
3695 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3696 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3697 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3698 (gnus-tmp-score-char
3699 (if (or (null gnus-summary-default-score)
3700 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3701 gnus-summary-zcore-fuzz))
3702 ? ;Whitespace
3703 (if (< gnus-tmp-score gnus-summary-default-score)
3704 gnus-score-below-mark gnus-score-over-mark)))
3705 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3706 (gnus-tmp-replied
3707 (cond (gnus-tmp-process gnus-process-mark)
3708 ((memq gnus-tmp-current gnus-newsgroup-cached)
3709 gnus-cached-mark)
3710 (gnus-tmp-replied gnus-replied-mark)
3711 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3712 gnus-forwarded-mark)
3713 ((memq gnus-tmp-current gnus-newsgroup-saved)
3714 gnus-saved-mark)
3715 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3716 gnus-unseen-mark)
3717 (t gnus-no-mark)))
3718 (gnus-tmp-downloaded
3719 (cond (undownloaded
3720 gnus-undownloaded-mark)
3721 (gnus-newsgroup-agentized
3722 gnus-downloaded-mark)
3724 gnus-no-mark)))
3725 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3726 (gnus-tmp-name
3727 (cond
3728 ((string-match "<[^>]+> *$" gnus-tmp-from)
3729 (let ((beg (match-beginning 0)))
3730 (or (and (string-match "^\".+\"" gnus-tmp-from)
3731 (substring gnus-tmp-from 1 (1- (match-end 0))))
3732 (substring gnus-tmp-from 0 beg))))
3733 ((string-match "(.+)" gnus-tmp-from)
3734 (substring gnus-tmp-from
3735 (1+ (match-beginning 0)) (1- (match-end 0))))
3736 (t gnus-tmp-from)))
3737 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3738 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3739 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3740 (inhibit-read-only t))
3741 (when (string= gnus-tmp-name "")
3742 (setq gnus-tmp-name gnus-tmp-from))
3743 (unless (numberp gnus-tmp-lines)
3744 (setq gnus-tmp-lines -1))
3745 (if (= gnus-tmp-lines -1)
3746 (setq gnus-tmp-lines "?")
3747 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3748 (condition-case ()
3749 (put-text-property
3750 (point)
3751 (progn (eval gnus-summary-line-format-spec) (point))
3752 'gnus-number gnus-tmp-number)
3753 (error (gnus-message 5 "Error updating the summary line")))
3754 (when (gnus-visual-p 'summary-highlight 'highlight)
3755 (forward-line -1)
3756 (gnus-summary-highlight-line)
3757 (gnus-run-hooks 'gnus-summary-update-hook)
3758 (forward-line 1))))
3760 (defun gnus-summary-update-line (&optional dont-update)
3761 "Update summary line after change."
3762 (when (and gnus-summary-default-score
3763 (not gnus-summary-inhibit-highlight))
3764 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3765 (article (gnus-summary-article-number))
3766 (score (gnus-summary-article-score article)))
3767 (unless dont-update
3768 (if (and gnus-summary-mark-below
3769 (< (gnus-summary-article-score)
3770 gnus-summary-mark-below))
3771 ;; This article has a low score, so we mark it as read.
3772 (when (memq article gnus-newsgroup-unreads)
3773 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3774 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3775 ;; This article was previously marked as read on account
3776 ;; of a low score, but now it has risen, so we mark it as
3777 ;; unread.
3778 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3779 (gnus-summary-update-mark
3780 (if (or (null gnus-summary-default-score)
3781 (<= (abs (- score gnus-summary-default-score))
3782 gnus-summary-zcore-fuzz))
3783 ? ;Whitespace
3784 (if (< score gnus-summary-default-score)
3785 gnus-score-below-mark gnus-score-over-mark))
3786 'score))
3787 ;; Do visual highlighting.
3788 (when (gnus-visual-p 'summary-highlight 'highlight)
3789 (gnus-summary-highlight-line)
3790 (gnus-run-hooks 'gnus-summary-update-hook)))))
3792 (defvar gnus-tmp-new-adopts nil)
3794 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3795 "Return the number of articles in THREAD.
3796 This may be 0 in some cases -- if none of the articles in
3797 the thread are to be displayed."
3798 (let* ((number
3799 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3800 (cond
3801 ((not (listp thread))
3803 ((and (consp thread) (cdr thread))
3804 (apply
3805 '+ 1 (mapcar
3806 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3807 ((null thread)
3809 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3811 (t 0))))
3812 (when (and level (zerop level) gnus-tmp-new-adopts)
3813 (cl-incf number
3814 (apply '+ (mapcar
3815 'gnus-summary-number-of-articles-in-thread
3816 gnus-tmp-new-adopts))))
3817 (if char
3818 (if (> number 1) gnus-not-empty-thread-mark
3819 gnus-empty-thread-mark)
3820 number)))
3822 (defsubst gnus-summary-line-message-size (head)
3823 "Return pretty-printed version of message size.
3824 This function is intended to be used in
3825 `gnus-summary-line-format-alist'."
3826 (let ((c (or (mail-header-chars head) -1)))
3827 (cond ((< c 0) "n/a") ; chars not available
3828 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3829 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3830 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3831 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3833 (defcustom gnus-user-date-format-alist
3834 '(((gnus-seconds-today) . "Today, %H:%M")
3835 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3836 (604800 . "%A %H:%M") ; That's one week
3837 ((gnus-seconds-month) . "%A %d")
3838 ((gnus-seconds-year) . "%B %d")
3839 (t . "%b %d %Y")) ; This one is used when no other
3840 ; does match
3841 "Specifies date format depending on age of article.
3842 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3843 seconds) or a Lisp expression evaluating to a number. When the age of
3844 the article is less than this number, then use `format-time-string'
3845 with the corresponding FORMAT for displaying the date of the article.
3846 If AGE is not a number or a Lisp expression evaluating to a
3847 non-number, then the corresponding FORMAT is used as a default value.
3849 Note that the list is processed from the beginning, so it should be
3850 sorted by ascending AGE. Also note that items following the first
3851 non-number AGE will be ignored.
3853 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3854 and `gnus-seconds-year' in the AGE spec. They return the number of
3855 seconds passed since the start of today, of this month, of this year,
3856 respectively."
3857 :version "24.1"
3858 :group 'gnus-summary-format
3859 :type '(alist :key-type sexp :value-type string))
3861 (defun gnus-user-date (messy-date)
3862 "Format the messy-date according to `gnus-user-date-format-alist'.
3863 Returns \" ? \" if there's bad input or if another error occurs.
3864 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3865 (condition-case ()
3866 (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
3867 (now (float-time))
3868 ;;If we don't find something suitable we'll use this one
3869 (my-format "%b %d '%y"))
3870 (let* ((difference (- now messy-date))
3871 (templist gnus-user-date-format-alist)
3872 (top (eval (caar templist))))
3873 (while (if (numberp top) (< top difference) (not top))
3874 (progn
3875 (setq templist (cdr templist))
3876 (setq top (eval (caar templist)))))
3877 (if (stringp (cdr (car templist)))
3878 (setq my-format (cdr (car templist)))))
3879 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3880 (error " ? ")))
3882 (defun gnus-summary-set-local-parameters (group)
3883 "Go through the local params of GROUP and set all variable specs in that list."
3884 (let ((vars '(quit-config active))) ; Ignore things that aren't
3885 ; really variables.
3886 (dolist (elem (gnus-group-find-parameter group))
3887 (and (consp elem) ; Has to be a cons.
3888 (consp (cdr elem)) ; The cdr has to be a list.
3889 (symbolp (car elem)) ; Has to be a symbol in there.
3890 (not (memq (car elem) vars))
3891 (ignore-errors
3892 (push (car elem) vars)
3893 ;; Variables like `gnus-show-threads' that are globally
3894 ;; bound, if used as group parameters, need to get to be
3895 ;; buffer-local, whereas just parameters like `gcc-self',
3896 ;; `timestamp', etc. should not be bound as variables.
3897 (if (boundp (car elem))
3898 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3899 (eval (nth 1 elem))))))))
3901 (defun gnus-summary-read-group (group &optional show-all no-article
3902 kill-buffer no-display backward
3903 select-articles)
3904 "Start reading news in newsgroup GROUP.
3905 If SHOW-ALL is non-nil, already read articles are also listed.
3906 If NO-ARTICLE is non-nil, no article is selected initially.
3907 If NO-DISPLAY, don't generate the summary buffer contents.
3908 If KILL-BUFFER, it should be a buffer that's killed once the new
3909 summary buffer has been generated.
3910 If BACKWARD, move point to the previous group in the group buffer
3911 If SELECT-ARTICLES, only select those articles from GROUP."
3912 (let (result)
3913 (while (and group
3914 (null (setq result
3915 (let ((gnus-auto-select-next nil))
3916 (or (gnus-summary-read-group-1
3917 group show-all no-article
3918 kill-buffer no-display
3919 select-articles)
3920 (setq show-all nil
3921 select-articles nil)))))
3922 (eq gnus-auto-select-next 'quietly))
3923 (set-buffer gnus-group-buffer)
3924 ;; The entry function called above goes to the next
3925 ;; group automatically, so we go two groups back
3926 ;; if we are searching for the previous group.
3927 (when backward
3928 (gnus-group-prev-unread-group 2))
3929 (if (not (equal group (gnus-group-group-name)))
3930 (setq group (gnus-group-group-name))
3931 (setq group nil)))
3932 result))
3934 (defun gnus-summary-read-group-1 (group show-all no-article
3935 kill-buffer no-display
3936 &optional select-articles)
3937 ;; Killed foreign groups can't be entered.
3938 ;; (when (and (not (gnus-group-native-p group))
3939 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3940 ;; (error "Dead non-native groups can't be entered"))
3941 (gnus-message 7 "Retrieving newsgroup: %s..."
3942 (gnus-group-decoded-name group))
3943 (let* ((new-group (gnus-summary-setup-buffer group))
3944 (quit-config (gnus-group-quit-config group))
3945 (did-select (and new-group (gnus-select-newsgroup
3946 group show-all select-articles))))
3947 (cond
3948 ;; This summary buffer exists already, so we just select it.
3949 ((not new-group)
3950 (gnus-set-global-variables)
3951 (when kill-buffer
3952 (gnus-kill-or-deaden-summary kill-buffer))
3953 (gnus-configure-windows 'summary 'force)
3954 (gnus-set-mode-line 'summary)
3955 (gnus-summary-position-point)
3956 (message "")
3958 ;; We couldn't select this group.
3959 ((null did-select)
3960 (when (and (derived-mode-p 'gnus-summary-mode)
3961 (not (equal (current-buffer) kill-buffer)))
3962 (kill-buffer (current-buffer))
3963 (if (not quit-config)
3964 (progn
3965 ;; Update the info -- marks might need to be removed,
3966 ;; for instance.
3967 (gnus-summary-update-info)
3968 (set-buffer gnus-group-buffer)
3969 (gnus-group-jump-to-group group)
3970 (gnus-group-next-unread-group 1))
3971 (gnus-handle-ephemeral-exit quit-config)))
3972 (if (null (gnus-list-of-unread-articles group))
3973 (gnus-message 3 "Group %s contains no messages"
3974 (gnus-group-decoded-name group))
3975 (gnus-message 3 "Can't select group"))
3976 nil)
3977 ;; The user did a `C-g' while prompting for number of articles,
3978 ;; so we exit this group.
3979 ((eq did-select 'quit)
3980 (and (derived-mode-p 'gnus-summary-mode)
3981 (not (equal (current-buffer) kill-buffer))
3982 (kill-buffer (current-buffer)))
3983 (when kill-buffer
3984 (gnus-kill-or-deaden-summary kill-buffer))
3985 (if (not quit-config)
3986 (progn
3987 (set-buffer gnus-group-buffer)
3988 (gnus-group-jump-to-group group)
3989 (gnus-configure-windows 'group 'force))
3990 (gnus-handle-ephemeral-exit quit-config))
3991 ;; Finally signal the quit.
3992 (signal 'quit nil))
3993 ;; The group was successfully selected.
3995 (gnus-set-global-variables)
3996 (when (boundp 'gnus-pick-line-number)
3997 (setq gnus-pick-line-number 0))
3998 (when (boundp 'spam-install-hooks)
3999 (spam-initialize))
4000 ;; Save the active value in effect when the group was entered.
4001 (setq gnus-newsgroup-active
4002 (copy-tree
4003 (gnus-active gnus-newsgroup-name)))
4004 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4005 ;; You can change the summary buffer in some way with this hook.
4006 (gnus-run-hooks 'gnus-select-group-hook)
4007 (when (memq 'summary (gnus-update-format-specifications
4008 nil 'summary 'summary-mode 'summary-dummy))
4009 ;; The format specification for the summary line was updated,
4010 ;; so we need to update the mark positions as well.
4011 (gnus-update-summary-mark-positions))
4012 ;; Do score processing.
4013 (when gnus-use-scoring
4014 (gnus-possibly-score-headers))
4015 ;; Check whether to fill in the gaps in the threads.
4016 (when gnus-build-sparse-threads
4017 (gnus-build-sparse-threads))
4018 ;; Find the initial limit.
4019 (if show-all
4020 (let ((gnus-newsgroup-dormant nil))
4021 (gnus-summary-initial-limit show-all))
4022 (gnus-summary-initial-limit show-all))
4023 ;; Generate the summary buffer.
4024 (unless no-display
4025 (gnus-summary-prepare))
4026 (when gnus-use-trees
4027 (gnus-tree-open)
4028 (setq gnus-summary-highlight-line-function
4029 'gnus-tree-highlight-article))
4030 ;; If the summary buffer is empty, but there are some low-scored
4031 ;; articles or some excluded dormants, we include these in the
4032 ;; buffer.
4033 (when (and (zerop (buffer-size))
4034 (not no-display))
4035 (cond (gnus-newsgroup-dormant
4036 (gnus-summary-limit-include-dormant))
4037 ((and gnus-newsgroup-scored show-all)
4038 (gnus-summary-limit-include-expunged t))))
4039 ;; Function `gnus-apply-kill-file' must be called in this hook.
4040 (gnus-run-hooks 'gnus-apply-kill-hook)
4041 (if (and (zerop (buffer-size))
4042 (not no-display))
4043 (progn
4044 ;; This newsgroup is empty.
4045 (gnus-summary-catchup-and-exit nil t)
4046 (gnus-message 6 "No unread news")
4047 (when kill-buffer
4048 (gnus-kill-or-deaden-summary kill-buffer))
4049 ;; Return nil from this function.
4050 nil)
4051 ;; Hide conversation thread subtrees. We cannot do this in
4052 ;; gnus-summary-prepare-hook since kill processing may not
4053 ;; work with hidden articles.
4054 (gnus-summary-maybe-hide-threads)
4055 (gnus-configure-windows 'summary)
4056 (when kill-buffer
4057 (gnus-kill-or-deaden-summary kill-buffer))
4058 (gnus-summary-auto-select-subject)
4059 ;; Don't mark any articles as selected if we haven't done that.
4060 (when no-article
4061 (setq overlay-arrow-position nil))
4062 ;; Show first unread article if requested.
4063 (if (and (not no-article)
4064 (not no-display)
4065 gnus-newsgroup-unreads
4066 gnus-auto-select-first)
4067 (progn
4068 (let ((art (gnus-summary-article-number)))
4069 (when (and art
4070 gnus-plugged
4071 (not (memq art gnus-newsgroup-undownloaded))
4072 (not (memq art gnus-newsgroup-downloadable)))
4073 (gnus-summary-goto-article art))))
4074 ;; Don't select any articles.
4075 (gnus-summary-position-point)
4076 (gnus-configure-windows 'summary 'force)
4077 (gnus-set-mode-line 'summary))
4078 (when (and gnus-auto-center-group
4079 (get-buffer-window gnus-group-buffer t))
4080 ;; Gotta use windows, because recenter does weird stuff if
4081 ;; the current buffer ain't the displayed window.
4082 (let ((owin (selected-window)))
4083 (select-window (get-buffer-window gnus-group-buffer t))
4084 (when (gnus-group-goto-group group)
4085 (recenter))
4086 (select-window owin)))
4087 ;; Mark this buffer as "prepared".
4088 (setq gnus-newsgroup-prepared t)
4089 (gnus-run-hooks 'gnus-summary-prepared-hook)
4090 (unless (gnus-ephemeral-group-p group)
4091 (gnus-group-update-group group nil t))
4092 t)))))
4094 (defun gnus-summary-auto-select-subject ()
4095 "Select the subject line on initial group entry."
4096 (goto-char (point-min))
4097 (cond
4098 ((eq gnus-auto-select-subject 'best)
4099 (gnus-summary-best-unread-subject))
4100 ((eq gnus-auto-select-subject 'unread)
4101 (gnus-summary-first-unread-subject))
4102 ((eq gnus-auto-select-subject 'unseen)
4103 (gnus-summary-first-unseen-subject))
4104 ((eq gnus-auto-select-subject 'unseen-or-unread)
4105 (gnus-summary-first-unseen-or-unread-subject))
4106 ((eq gnus-auto-select-subject 'first)
4107 ;; Do nothing.
4109 ((functionp gnus-auto-select-subject)
4110 (funcall gnus-auto-select-subject))))
4112 (defun gnus-summary-prepare ()
4113 "Generate the summary buffer."
4114 (interactive)
4115 (let ((inhibit-read-only t))
4116 (erase-buffer)
4117 (setq gnus-newsgroup-data nil
4118 gnus-newsgroup-data-reverse nil)
4119 (gnus-run-hooks 'gnus-summary-generate-hook)
4120 ;; Generate the buffer, either with threads or without.
4121 (when gnus-newsgroup-headers
4122 (gnus-summary-prepare-threads
4123 (if gnus-show-threads
4124 (gnus-sort-gathered-threads
4125 (funcall gnus-summary-thread-gathering-function
4126 (gnus-sort-threads
4127 (gnus-cut-threads (gnus-make-threads)))))
4128 ;; Unthreaded display.
4129 (gnus-sort-articles gnus-newsgroup-headers))))
4130 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4131 ;; Call hooks for modifying summary buffer.
4132 (goto-char (point-min))
4133 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4135 (defsubst gnus-general-simplify-subject (subject)
4136 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4137 (setq subject
4138 (cond
4139 ;; Truncate the subject.
4140 (gnus-simplify-subject-functions
4141 (gnus-map-function gnus-simplify-subject-functions subject))
4142 ((numberp gnus-summary-gather-subject-limit)
4143 (setq subject (gnus-simplify-subject-re subject))
4144 (if (> (length subject) gnus-summary-gather-subject-limit)
4145 (substring subject 0 gnus-summary-gather-subject-limit)
4146 subject))
4147 ;; Fuzzily simplify it.
4148 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4149 (gnus-simplify-subject-fuzzy subject))
4150 ;; Just remove the leading "Re:".
4152 (gnus-simplify-subject-re subject))))
4154 (if (and gnus-summary-gather-exclude-subject
4155 (string-match gnus-summary-gather-exclude-subject subject))
4156 nil ; This article shouldn't be gathered
4157 subject))
4159 (defun gnus-summary-simplify-subject-query ()
4160 "Query where the respool algorithm would put this article."
4161 (interactive)
4162 (gnus-summary-select-article)
4163 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4165 (defun gnus-gather-threads-by-subject (threads)
4166 "Gather threads by looking at Subject headers."
4167 (if (not gnus-summary-make-false-root)
4168 threads
4169 (let ((hashtb (gnus-make-hashtable 1024))
4170 (prev threads)
4171 (result threads)
4172 subject hthread whole-subject)
4173 (while threads
4174 (setq subject (gnus-general-simplify-subject
4175 (setq whole-subject (mail-header-subject
4176 (caar threads)))))
4177 (when subject
4178 (if (setq hthread (gnus-gethash subject hashtb))
4179 (progn
4180 ;; We enter a dummy root into the thread, if we
4181 ;; haven't done that already.
4182 (unless (stringp (caar hthread))
4183 (setcar hthread (list whole-subject (car hthread))))
4184 ;; We add this new gathered thread to this gathered
4185 ;; thread.
4186 (setcdr (car hthread)
4187 (nconc (cdar hthread) (list (car threads))))
4188 ;; Remove it from the list of threads.
4189 (setcdr prev (cdr threads))
4190 (setq threads prev))
4191 ;; Enter this thread into the hash table.
4192 (gnus-sethash subject
4193 (if gnus-summary-make-false-root-always
4194 (progn
4195 ;; If you want a dummy root above all
4196 ;; threads...
4197 (setcar threads (list whole-subject
4198 (car threads)))
4199 threads)
4200 threads)
4201 hashtb)))
4202 (setq prev threads)
4203 (setq threads (cdr threads)))
4204 result)))
4206 (defun gnus-gather-threads-by-references (threads)
4207 "Gather threads by looking at References headers."
4208 (let ((idhashtb (gnus-make-hashtable 1024))
4209 (thhashtb (gnus-make-hashtable 1024))
4210 (prev threads)
4211 (result threads)
4212 ids references id gthread gid entered ref)
4213 (while threads
4214 (when (setq references (mail-header-references (caar threads)))
4215 (setq id (mail-header-id (caar threads))
4216 ids (inline (gnus-split-references references))
4217 entered nil)
4218 (while (setq ref (pop ids))
4219 (setq ids (delete ref ids))
4220 (if (not (setq gid (gnus-gethash ref idhashtb)))
4221 (progn
4222 (gnus-sethash ref id idhashtb)
4223 (gnus-sethash id threads thhashtb))
4224 (setq gthread (gnus-gethash gid thhashtb))
4225 (unless entered
4226 ;; We enter a dummy root into the thread, if we
4227 ;; haven't done that already.
4228 (unless (stringp (caar gthread))
4229 (setcar gthread (list (mail-header-subject (caar gthread))
4230 (car gthread))))
4231 ;; We add this new gathered thread to this gathered
4232 ;; thread.
4233 (setcdr (car gthread)
4234 (nconc (cdar gthread) (list (car threads)))))
4235 ;; Add it into the thread hash table.
4236 (gnus-sethash id gthread thhashtb)
4237 (setq entered t)
4238 ;; Remove it from the list of threads.
4239 (setcdr prev (cdr threads))
4240 (setq threads prev))))
4241 (setq prev threads)
4242 (setq threads (cdr threads)))
4243 result))
4245 (defun gnus-sort-gathered-threads (threads)
4246 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4247 (let ((result threads))
4248 (while threads
4249 (when (stringp (caar threads))
4250 (setcdr (car threads)
4251 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4252 (setq threads (cdr threads)))
4253 result))
4255 (defun gnus-thread-loop-p (root thread)
4256 "Say whether ROOT is in THREAD."
4257 (let ((stack (list thread))
4258 (infloop 0)
4260 (while (setq thread (pop stack))
4261 (setq th (cdr thread))
4262 (while (and th
4263 (not (eq (caar th) root)))
4264 (pop th))
4265 (if th
4266 ;; We have found a loop.
4267 (let (ref-dep)
4268 (setcdr thread (delq (car th) (cdr thread)))
4269 (if (boundp (setq ref-dep (intern "none"
4270 gnus-newsgroup-dependencies)))
4271 (setcdr (symbol-value ref-dep)
4272 (nconc (cdr (symbol-value ref-dep))
4273 (list (car th))))
4274 (set ref-dep (list nil (car th))))
4275 (setq infloop 1
4276 stack nil))
4277 ;; Push all the subthreads onto the stack.
4278 (push (cdr thread) stack)))
4279 infloop))
4281 (defun gnus-make-threads ()
4282 "Go through the dependency hashtb and find the roots. Return all threads."
4283 (let (threads)
4284 (while (catch 'infloop
4285 (mapatoms
4286 (lambda (refs)
4287 ;; Deal with self-referencing References loops.
4288 (when (and (car (symbol-value refs))
4289 (not (zerop
4290 (apply
4292 (mapcar
4293 (lambda (thread)
4294 (gnus-thread-loop-p
4295 (car (symbol-value refs)) thread))
4296 (cdr (symbol-value refs)))))))
4297 (setq threads nil)
4298 (throw 'infloop t))
4299 (unless (car (symbol-value refs))
4300 ;; These threads do not refer back to any other
4301 ;; articles, so they're roots.
4302 (setq threads (append (cdr (symbol-value refs)) threads))))
4303 gnus-newsgroup-dependencies)))
4304 threads))
4306 ;; Build the thread tree.
4307 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4308 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4310 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4311 if it was already present.
4313 If `gnus-summary-ignore-duplicates' is non-nil then duplicate
4314 Message-IDs will not be entered in the DEPENDENCIES table.
4315 Otherwise duplicate Message-IDs will be renamed to a unique
4316 Message-ID before being entered.
4318 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4319 (let* ((id (mail-header-id header))
4320 (id-dep (and id (intern id dependencies)))
4321 parent-id ref ref-dep ref-header replaced)
4322 ;; Enter this `header' in the `dependencies' table.
4323 (cond
4324 ((not id-dep)
4325 (setq header nil))
4326 ;; The first two cases do the normal part: enter a new `header'
4327 ;; in the `dependencies' table.
4328 ((not (boundp id-dep))
4329 (set id-dep (list header)))
4330 ((null (car (symbol-value id-dep)))
4331 (setcar (symbol-value id-dep) header))
4333 ;; From here the `header' was already present in the
4334 ;; `dependencies' table.
4335 (force-new
4336 ;; Overrides an existing entry;
4337 ;; just set the header part of the entry.
4338 (setcar (symbol-value id-dep) header)
4339 (setq replaced t))
4341 ;; Renames the existing `header' to a unique Message-ID.
4342 ((not gnus-summary-ignore-duplicates)
4343 ;; An article with this Message-ID has already been seen.
4344 ;; We rename the Message-ID.
4345 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4346 (list header))
4347 (mail-header-set-id header id))
4349 ;; The last case ignores an existing entry, except it adds any
4350 ;; additional Xrefs (in case the two articles came from different
4351 ;; servers.
4352 ;; Also sets `header' to nil meaning that the `dependencies'
4353 ;; table was *not* modified.
4355 (mail-header-set-xref
4356 (car (symbol-value id-dep))
4357 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4359 (or (mail-header-xref header) "")))
4360 (setq header nil)))
4362 (when (and header (not replaced))
4363 ;; First check that we are not creating a References loop.
4364 (setq parent-id (gnus-parent-id (mail-header-references header)))
4365 (setq ref parent-id)
4366 (while (and ref
4367 (setq ref-dep (intern-soft ref dependencies))
4368 (boundp ref-dep)
4369 (setq ref-header (car (symbol-value ref-dep))))
4370 (if (string= id ref)
4371 ;; Yuk! This is a reference loop. Make the article be a
4372 ;; root article.
4373 (progn
4374 (mail-header-set-references (car (symbol-value id-dep)) "none")
4375 (setq ref nil)
4376 (setq parent-id nil))
4377 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4378 (setq ref-dep (intern (or parent-id "none") dependencies))
4379 (if (boundp ref-dep)
4380 (setcdr (symbol-value ref-dep)
4381 (nconc (cdr (symbol-value ref-dep))
4382 (list (symbol-value id-dep))))
4383 (set ref-dep (list nil (symbol-value id-dep)))))
4384 header))
4386 (defun gnus-extract-message-id-from-in-reply-to (string)
4387 (if (string-match "<[^>]+>" string)
4388 (substring string (match-beginning 0) (match-end 0))
4389 nil))
4391 (defun gnus-build-sparse-threads ()
4392 (let ((headers gnus-newsgroup-headers)
4393 (mail-parse-charset gnus-newsgroup-charset)
4394 (gnus-summary-ignore-duplicates t)
4395 header references generation relations
4396 subject child end new-child date)
4397 ;; First we create an alist of generations/relations, where
4398 ;; generations is how much we trust the relation, and the relation
4399 ;; is parent/child.
4400 (gnus-message 7 "Making sparse threads...")
4401 (save-excursion
4402 (nnheader-set-temp-buffer " *gnus sparse threads*")
4403 (while (setq header (pop headers))
4404 (when (and (setq references (mail-header-references header))
4405 (not (string= references "")))
4406 (insert references)
4407 (setq child (mail-header-id header)
4408 subject (mail-header-subject header)
4409 date (mail-header-date header)
4410 generation 0)
4411 (while (search-backward ">" nil t)
4412 (setq end (1+ (point)))
4413 (when (search-backward "<" nil t)
4414 (setq new-child (buffer-substring (point) end))
4415 (push (list (cl-incf generation)
4416 child (setq child new-child)
4417 subject date)
4418 relations)))
4419 (when child
4420 (push (list (1+ generation) child nil subject) relations))
4421 (erase-buffer)))
4422 (kill-buffer (current-buffer)))
4423 ;; Sort over trustworthiness.
4424 (dolist (relation (sort relations 'car-less-than-car))
4425 (when (gnus-dependencies-add-header
4426 (make-full-mail-header
4427 gnus-reffed-article-number
4428 (nth 3 relation) "" (or (nth 4 relation) "")
4429 (nth 1 relation)
4430 (or (nth 2 relation) "") 0 0 "")
4431 gnus-newsgroup-dependencies nil)
4432 (push gnus-reffed-article-number gnus-newsgroup-limit)
4433 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4434 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4435 gnus-newsgroup-reads)
4436 (cl-decf gnus-reffed-article-number)))
4437 (gnus-message 7 "Making sparse threads...done")))
4439 (defun gnus-build-old-threads ()
4440 ;; Look at all the articles that refer back to old articles, and
4441 ;; fetch the headers for the articles that aren't there. This will
4442 ;; build complete threads - if the roots haven't been expired by the
4443 ;; server, that is.
4444 (let ((mail-parse-charset gnus-newsgroup-charset)
4445 id heads)
4446 (mapatoms
4447 (lambda (refs)
4448 (when (not (car (symbol-value refs)))
4449 (setq heads (cdr (symbol-value refs)))
4450 (while heads
4451 (if (memq (mail-header-number (caar heads))
4452 gnus-newsgroup-dormant)
4453 (setq heads (cdr heads))
4454 (setq id (symbol-name refs))
4455 (while (and (setq id (gnus-build-get-header id))
4456 (not (car (gnus-id-to-thread id)))))
4457 (setq heads nil)))))
4458 gnus-newsgroup-dependencies)))
4460 (defsubst gnus-remove-odd-characters (string)
4461 "Translate STRING into something that doesn't contain weird characters."
4462 (subst-char-in-string
4463 ?\r ?\-
4464 (subst-char-in-string ?\n ?\- string t) t))
4466 ;; This function has to be called with point after the article number
4467 ;; on the beginning of the line.
4468 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4469 (let ((eol (point-at-eol))
4470 (buffer (current-buffer))
4471 header references in-reply-to)
4473 ;; overview: [num subject from date id refs chars lines misc]
4474 (unwind-protect
4475 (let (x)
4476 (narrow-to-region (point) eol)
4477 (unless (eobp)
4478 (forward-char))
4480 (setq header
4481 (make-full-mail-header
4482 number ; number
4483 (condition-case () ; subject
4484 (gnus-remove-odd-characters
4485 (funcall gnus-decode-encoded-word-function
4486 (setq x (nnheader-nov-field))))
4487 (error x))
4488 (condition-case () ; from
4489 (gnus-remove-odd-characters
4490 (funcall gnus-decode-encoded-address-function
4491 (setq x (nnheader-nov-field))))
4492 (error x))
4493 (nnheader-nov-field) ; date
4494 (nnheader-nov-read-message-id number) ; id
4495 (setq references (nnheader-nov-field)) ; refs
4496 (nnheader-nov-read-integer) ; chars
4497 (nnheader-nov-read-integer) ; lines
4498 (unless (eobp)
4499 (if (looking-at "Xref: ")
4500 (goto-char (match-end 0)))
4501 (nnheader-nov-field)) ; Xref
4502 (nnheader-nov-parse-extra)))) ; extra
4504 (widen))
4506 (when (and (string= references "")
4507 (setq in-reply-to (mail-header-extra header))
4508 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4509 (mail-header-set-references
4510 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4512 (when gnus-alter-header-function
4513 (funcall gnus-alter-header-function header))
4514 (gnus-dependencies-add-header header dependencies force-new)))
4516 (defun gnus-build-get-header (id)
4517 "Look through the buffer of NOV lines and find the header to ID.
4518 Enter this line into the dependencies hash table, and return
4519 the id of the parent article (if any)."
4520 (let ((deps gnus-newsgroup-dependencies)
4521 found header)
4522 (prog1
4523 (with-current-buffer nntp-server-buffer
4524 (let ((case-fold-search nil))
4525 (goto-char (point-min))
4526 (while (and (not found)
4527 (search-forward id nil t))
4528 (beginning-of-line)
4529 (setq found (looking-at
4530 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4531 (regexp-quote id))))
4532 (or found (beginning-of-line 2)))
4533 (when found
4534 (beginning-of-line)
4535 (and
4536 (setq header (gnus-nov-parse-line
4537 (read (current-buffer)) deps))
4538 (gnus-parent-id (mail-header-references header))))))
4539 (when header
4540 (let ((number (mail-header-number header)))
4541 (push number gnus-newsgroup-limit)
4542 (push header gnus-newsgroup-headers)
4543 (if (memq number gnus-newsgroup-unselected)
4544 (progn
4545 (setq gnus-newsgroup-unreads
4546 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4547 number))
4548 (setq gnus-newsgroup-unselected
4549 (delq number gnus-newsgroup-unselected)))
4550 (push number gnus-newsgroup-ancient)))))))
4552 (defun gnus-build-all-threads ()
4553 "Read all the headers."
4554 (let ((gnus-summary-ignore-duplicates t)
4555 (mail-parse-charset gnus-newsgroup-charset)
4556 (dependencies gnus-newsgroup-dependencies)
4557 header article)
4558 (with-current-buffer nntp-server-buffer
4559 (let ((case-fold-search nil))
4560 (goto-char (point-min))
4561 (while (not (eobp))
4562 (ignore-errors
4563 (setq article (read (current-buffer))
4564 header (gnus-nov-parse-line article dependencies t)))
4565 (when header
4566 (with-current-buffer gnus-summary-buffer
4567 (push header gnus-newsgroup-headers)
4568 (if (memq (setq article (mail-header-number header))
4569 gnus-newsgroup-unselected)
4570 (progn
4571 (setq gnus-newsgroup-unreads
4572 (gnus-add-to-sorted-list
4573 gnus-newsgroup-unreads article))
4574 (setq gnus-newsgroup-unselected
4575 (delq article gnus-newsgroup-unselected)))
4576 (push article gnus-newsgroup-ancient)))
4577 (forward-line 1)))))))
4579 (defun gnus-summary-update-article-line (article header)
4580 "Update the line for ARTICLE using HEADER."
4581 (let* ((id (mail-header-id header))
4582 (thread (gnus-id-to-thread id)))
4583 (unless thread
4584 (error "Article in no thread"))
4585 ;; Update the thread.
4586 (setcar thread header)
4587 (gnus-summary-goto-subject article)
4588 (let* ((datal (gnus-data-find-list article))
4589 (data (car datal))
4590 (inhibit-read-only t)
4591 (level (gnus-summary-thread-level)))
4592 (gnus-delete-line)
4593 (let ((inserted (- (point)
4594 (progn
4595 (gnus-summary-insert-line
4596 header level nil
4597 (memq article gnus-newsgroup-undownloaded)
4598 (gnus-article-mark article)
4599 (memq article gnus-newsgroup-replied)
4600 (memq article gnus-newsgroup-expirable)
4601 ;; Only insert the Subject string when it's different
4602 ;; from the previous Subject string.
4603 (if (and
4604 gnus-show-threads
4605 (gnus-subject-equal
4606 (condition-case ()
4607 (mail-header-subject
4608 (gnus-data-header
4609 (cadr
4610 (gnus-data-find-list
4611 article
4612 (gnus-data-list t)))))
4613 ;; Error on the side of excessive subjects.
4614 (error ""))
4615 (mail-header-subject header)))
4617 (mail-header-subject header))
4618 nil (cdr (assq article gnus-newsgroup-scored))
4619 (memq article gnus-newsgroup-processable))
4620 (point)))))
4621 (when (cdr datal)
4622 (gnus-data-update-list
4623 (cdr datal)
4624 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4626 (defun gnus-summary-update-article (article &optional iheader)
4627 "Update ARTICLE in the summary buffer."
4628 (set-buffer gnus-summary-buffer)
4629 (let* ((header (gnus-summary-article-header article))
4630 (id (mail-header-id header))
4631 (data (gnus-data-find article))
4632 (thread (gnus-id-to-thread id))
4633 (references (mail-header-references header))
4634 (parent
4635 (gnus-id-to-thread
4636 (or (gnus-parent-id
4637 (when (and references
4638 (not (equal "" references)))
4639 references))
4640 "none")))
4641 (inhibit-read-only t)
4642 (old (car thread)))
4643 (when thread
4644 (unless iheader
4645 (setcar thread nil)
4646 (when parent
4647 (delq thread parent)))
4648 (if (gnus-summary-insert-subject id header)
4649 ;; Set the (possibly) new article number in the data structure.
4650 (gnus-data-set-number data (gnus-id-to-article id))
4651 (setcar thread old)
4652 nil))))
4654 (defun gnus-rebuild-thread (id &optional line)
4655 "Rebuild the thread containing ID.
4656 If LINE, insert the rebuilt thread starting on line LINE."
4657 (let ((inhibit-read-only t)
4658 old-pos current thread data)
4659 (if (not gnus-show-threads)
4660 (setq thread (list (car (gnus-id-to-thread id))))
4661 ;; Get the thread this article is part of.
4662 (setq thread (gnus-remove-thread id)))
4663 (setq old-pos (point-at-bol))
4664 (setq current (save-excursion
4665 (and (re-search-backward "[\r\n]" nil t)
4666 (gnus-summary-article-number))))
4667 ;; If this is a gathered thread, we have to go some re-gathering.
4668 (when (stringp (car thread))
4669 (let ((subject (car thread))
4670 roots thr)
4671 (setq thread (cdr thread))
4672 (while thread
4673 (unless (memq (setq thr (gnus-id-to-thread
4674 (gnus-root-id
4675 (mail-header-id (caar thread)))))
4676 roots)
4677 (push thr roots))
4678 (setq thread (cdr thread)))
4679 ;; We now have all (unique) roots.
4680 (if (= (length roots) 1)
4681 ;; All the loose roots are now one solid root.
4682 (setq thread (car roots))
4683 (setq thread (cons subject (gnus-sort-threads roots))))))
4684 (let (threads)
4685 ;; We then insert this thread into the summary buffer.
4686 (when line
4687 (goto-char (point-min))
4688 (forward-line (1- line)))
4689 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4690 (if gnus-show-threads
4691 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4692 (gnus-summary-prepare-unthreaded thread))
4693 (setq data (nreverse gnus-newsgroup-data))
4694 (setq threads gnus-newsgroup-threads))
4695 ;; We splice the new data into the data structure.
4696 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4697 ;;!!! then we want to insert at the beginning of the buffer.
4698 ;;!!! That happens to be true with Gnus now, but that may
4699 ;;!!! change in the future. Perhaps.
4700 (gnus-data-enter-list
4701 (if line nil current) data (- (point) old-pos))
4702 (setq gnus-newsgroup-threads
4703 (nconc threads gnus-newsgroup-threads))
4704 (gnus-data-compute-positions))))
4706 (defun gnus-number-to-header (number)
4707 "Return the header for article NUMBER."
4708 (let ((headers gnus-newsgroup-headers))
4709 (while (and headers
4710 (not (= number (mail-header-number (car headers)))))
4711 (pop headers))
4712 (when headers
4713 (car headers))))
4715 (defun gnus-parent-headers (in-headers &optional generation)
4716 "Return the headers of the GENERATIONth parent of HEADERS."
4717 (unless generation
4718 (setq generation 1))
4719 (let ((parent t)
4720 (headers in-headers)
4721 references)
4722 (while (and parent
4723 (not (zerop generation))
4724 (setq references (mail-header-references headers)))
4725 (setq headers (if (and references
4726 (setq parent (gnus-parent-id references)))
4727 (car (gnus-id-to-thread parent))
4728 nil))
4729 (cl-decf generation))
4730 (and (not (eq headers in-headers))
4731 headers)))
4733 (defun gnus-id-to-thread (id)
4734 "Return the (sub-)thread where ID appears."
4735 (gnus-gethash id gnus-newsgroup-dependencies))
4737 (defun gnus-id-to-article (id)
4738 "Return the article number of ID."
4739 (let ((thread (gnus-id-to-thread id)))
4740 (when (and thread
4741 (car thread))
4742 (mail-header-number (car thread)))))
4744 (defun gnus-id-to-header (id)
4745 "Return the article headers of ID."
4746 (car (gnus-id-to-thread id)))
4748 (defun gnus-article-displayed-root-p (article)
4749 "Say whether ARTICLE is a root(ish) article."
4750 (let ((level (gnus-summary-thread-level article))
4751 (refs (mail-header-references (gnus-summary-article-header article)))
4752 particle)
4753 (cond
4754 ((null level) nil)
4755 ((zerop level) t)
4756 ((null refs) t)
4757 ((null (gnus-parent-id refs)) t)
4758 ((and (= 1 level)
4759 (null (setq particle (gnus-id-to-article
4760 (gnus-parent-id refs))))
4761 (null (gnus-summary-thread-level particle)))))))
4763 (defun gnus-root-id (id)
4764 "Return the id of the root of the thread where ID appears."
4765 (let (last-id prev)
4766 (while (and id (setq prev (car (gnus-id-to-thread id))))
4767 (setq last-id id
4768 id (gnus-parent-id (mail-header-references prev))))
4769 last-id))
4771 (defun gnus-articles-in-thread (thread)
4772 "Return the list of articles in THREAD."
4773 (cons (mail-header-number (car thread))
4774 (mapcan 'gnus-articles-in-thread (cdr thread))))
4776 (defun gnus-remove-thread (id &optional dont-remove)
4777 "Remove the thread that has ID in it."
4778 (let (headers thread last-id)
4779 ;; First go up in this thread until we find the root.
4780 (setq last-id (gnus-root-id id)
4781 headers (message-flatten-list (gnus-id-to-thread last-id)))
4782 ;; We have now found the real root of this thread. It might have
4783 ;; been gathered into some loose thread, so we have to search
4784 ;; through the threads to find the thread we wanted.
4785 (let ((threads gnus-newsgroup-threads)
4786 sub)
4787 (while threads
4788 (setq sub (car threads))
4789 (if (stringp (car sub))
4790 ;; This is a gathered thread, so we look at the roots
4791 ;; below it to find whether this article is in this
4792 ;; gathered root.
4793 (progn
4794 (setq sub (cdr sub))
4795 (while sub
4796 (when (member (caar sub) headers)
4797 (setq thread (car threads)
4798 threads nil
4799 sub nil))
4800 (setq sub (cdr sub))))
4801 ;; It's an ordinary thread, so we check it.
4802 (when (eq (car sub) (car headers))
4803 (setq thread sub
4804 threads nil)))
4805 (setq threads (cdr threads)))
4806 ;; If this article is in no thread, then it's a root.
4807 (if thread
4808 (unless dont-remove
4809 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4810 (setq thread (gnus-id-to-thread last-id)))
4811 (when thread
4812 (prog1
4813 thread ; We return this thread.
4814 (unless dont-remove
4815 (if (stringp (car thread))
4816 (progn
4817 ;; If we use dummy roots, then we have to remove the
4818 ;; dummy root as well.
4819 (when (eq gnus-summary-make-false-root 'dummy)
4820 ;; We go to the dummy root by going to
4821 ;; the first sub-"thread", and then one line up.
4822 (gnus-summary-goto-article
4823 (mail-header-number (caadr thread)))
4824 (forward-line -1)
4825 (gnus-delete-line)
4826 (gnus-data-compute-positions))
4827 (setq thread (cdr thread))
4828 (while thread
4829 (gnus-remove-thread-1 (car thread))
4830 (setq thread (cdr thread))))
4831 (gnus-remove-thread-1 thread))))))))
4833 (defun gnus-remove-thread-1 (thread)
4834 "Remove the thread THREAD recursively."
4835 (let ((number (mail-header-number (pop thread)))
4837 (setq thread (reverse thread))
4838 (while thread
4839 (gnus-remove-thread-1 (pop thread)))
4840 (when (setq d (gnus-data-find number))
4841 (goto-char (gnus-data-pos d))
4842 (gnus-summary-show-thread)
4843 (gnus-data-remove
4844 number
4845 (- (point-at-bol)
4846 (prog1
4847 (1+ (point-at-eol))
4848 (gnus-delete-line)))))))
4850 (defun gnus-sort-threads-recursive (threads func)
4851 ;; Responsible for sorting the root articles of threads.
4852 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4853 'gnus-thread-sort-functions)
4854 func
4855 (gnus-make-sort-function
4856 gnus-subthread-sort-functions))))
4857 (sort (mapcar (lambda (thread)
4858 (cons (car thread)
4859 (and (cdr thread)
4860 (gnus-sort-subthreads-recursive
4861 (cdr thread) subthread-sort-func))))
4862 threads) func)))
4864 (defun gnus-sort-subthreads-recursive (threads func)
4865 ;; Responsible for sorting subthreads.
4866 (sort (mapcar (lambda (thread)
4867 (cons (car thread)
4868 (and (cdr thread)
4869 (gnus-sort-subthreads-recursive (cdr thread) func))))
4870 threads) func))
4872 (defun gnus-sort-threads-loop (threads func)
4873 (let* ((superthread (cons nil threads))
4874 (stack (list (cons superthread threads)))
4875 remaining-threads thread)
4876 (while stack
4877 (setq remaining-threads (cdr (car stack)))
4878 (if remaining-threads
4879 (progn (setq thread (car remaining-threads))
4880 (setcdr (car stack) (cdr remaining-threads))
4881 (if (cdr thread)
4882 (push (cons thread (cdr thread)) stack)))
4883 (setq thread (caar stack))
4884 (setcdr thread (sort (cdr thread) func))
4885 (pop stack)))
4886 (cdr superthread)))
4888 (defun gnus-sort-threads (threads)
4889 "Sort THREADS."
4890 (if (not gnus-thread-sort-functions)
4891 threads
4892 (gnus-message 8 "Sorting threads...")
4893 (prog1
4894 (condition-case nil
4895 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4896 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4897 (gnus-sort-threads-recursive threads sort-func))
4898 ;; Even after binding max-lisp-eval-depth, the recursive
4899 ;; sorter might fail for very long threads. In that case,
4900 ;; try using a (less well-tested) non-recursive sorter.
4901 (error (gnus-message 9 "Sorting threads with loop...")
4902 (gnus-sort-threads-loop
4903 threads (gnus-make-sort-function
4904 gnus-thread-sort-functions))))
4905 (gnus-message 8 "Sorting threads...done"))))
4907 (defun gnus-sort-articles (articles)
4908 "Sort ARTICLES."
4909 (when gnus-article-sort-functions
4910 (gnus-message 7 "Sorting articles...")
4911 (prog1
4912 (setq gnus-newsgroup-headers
4913 (sort articles (gnus-make-sort-function
4914 gnus-article-sort-functions)))
4915 (gnus-message 7 "Sorting articles...done"))))
4917 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4918 (defmacro gnus-thread-header (thread)
4919 "Return header of first article in THREAD.
4920 Note that THREAD must never, ever be anything else than a variable -
4921 using some other form will lead to serious barfage."
4922 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4923 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4924 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4925 (vector thread) 2))
4927 (defsubst gnus-article-sort-by-number (h1 h2)
4928 "Sort articles by article number."
4929 (< (mail-header-number h1)
4930 (mail-header-number h2)))
4932 (defun gnus-thread-sort-by-number (h1 h2)
4933 "Sort threads by root article number."
4934 (gnus-article-sort-by-number
4935 (gnus-thread-header h1) (gnus-thread-header h2)))
4937 (defsubst gnus-article-sort-by-random (h1 h2)
4938 "Sort articles randomly."
4939 (zerop (random 2)))
4941 (defun gnus-thread-sort-by-random (h1 h2)
4942 "Sort threads randomly."
4943 (gnus-article-sort-by-random
4944 (gnus-thread-header h1) (gnus-thread-header h2)))
4946 (defsubst gnus-article-sort-by-lines (h1 h2)
4947 "Sort articles by article Lines header."
4948 (< (mail-header-lines h1)
4949 (mail-header-lines h2)))
4951 (defun gnus-thread-sort-by-lines (h1 h2)
4952 "Sort threads by root article Lines header."
4953 (gnus-article-sort-by-lines
4954 (gnus-thread-header h1) (gnus-thread-header h2)))
4956 (defsubst gnus-article-sort-by-chars (h1 h2)
4957 "Sort articles by octet length."
4958 (< (mail-header-chars h1)
4959 (mail-header-chars h2)))
4961 (defun gnus-thread-sort-by-chars (h1 h2)
4962 "Sort threads by root article octet length."
4963 (gnus-article-sort-by-chars
4964 (gnus-thread-header h1) (gnus-thread-header h2)))
4966 (defsubst gnus-article-sort-by-marks (h1 h2)
4967 "Sort articles by octet length."
4968 (< (gnus-article-mark (mail-header-number h1))
4969 (gnus-article-mark (mail-header-number h2))))
4971 (defun gnus-thread-sort-by-marks (h1 h2)
4972 "Sort threads by root article octet length."
4973 (gnus-article-sort-by-marks
4974 (gnus-thread-header h1) (gnus-thread-header h2)))
4976 (defsubst gnus-article-sort-by-author (h1 h2)
4977 "Sort articles by root author."
4978 (gnus-string<
4979 (let ((extract (funcall
4980 gnus-extract-address-components
4981 (mail-header-from h1))))
4982 (or (car extract) (cadr extract) ""))
4983 (let ((extract (funcall
4984 gnus-extract-address-components
4985 (mail-header-from h2))))
4986 (or (car extract) (cadr extract) ""))))
4988 (defun gnus-thread-sort-by-author (h1 h2)
4989 "Sort threads by root author."
4990 (gnus-article-sort-by-author
4991 (gnus-thread-header h1) (gnus-thread-header h2)))
4993 (defsubst gnus-article-sort-by-recipient (h1 h2)
4994 "Sort articles by recipient."
4995 (gnus-string<
4996 (let ((extract (funcall
4997 gnus-extract-address-components
4998 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4999 (or (car extract) (cadr extract)))
5000 (let ((extract (funcall
5001 gnus-extract-address-components
5002 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5003 (or (car extract) (cadr extract)))))
5005 (defun gnus-thread-sort-by-recipient (h1 h2)
5006 "Sort threads by root recipient."
5007 (gnus-article-sort-by-recipient
5008 (gnus-thread-header h1) (gnus-thread-header h2)))
5010 (defsubst gnus-article-sort-by-subject (h1 h2)
5011 "Sort articles by root subject."
5012 (gnus-string<
5013 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5014 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5016 (defun gnus-thread-sort-by-subject (h1 h2)
5017 "Sort threads by root subject."
5018 (gnus-article-sort-by-subject
5019 (gnus-thread-header h1) (gnus-thread-header h2)))
5021 (defsubst gnus-article-sort-by-date (h1 h2)
5022 "Sort articles by root article date."
5023 (time-less-p
5024 (gnus-date-get-time (mail-header-date h1))
5025 (gnus-date-get-time (mail-header-date h2))))
5027 (defun gnus-thread-sort-by-date (h1 h2)
5028 "Sort threads by root article date."
5029 (gnus-article-sort-by-date
5030 (gnus-thread-header h1) (gnus-thread-header h2)))
5032 (defsubst gnus-article-sort-by-score (h1 h2)
5033 "Sort articles by root article score.
5034 Unscored articles will be counted as having a score of zero."
5035 (> (or (cdr (assq (mail-header-number h1)
5036 gnus-newsgroup-scored))
5037 gnus-summary-default-score 0)
5038 (or (cdr (assq (mail-header-number h2)
5039 gnus-newsgroup-scored))
5040 gnus-summary-default-score 0)))
5042 (defun gnus-thread-sort-by-score (h1 h2)
5043 "Sort threads by root article score."
5044 (gnus-article-sort-by-score
5045 (gnus-thread-header h1) (gnus-thread-header h2)))
5047 (defun gnus-thread-sort-by-total-score (h1 h2)
5048 "Sort threads by the sum of all scores in the thread.
5049 Unscored articles will be counted as having a score of zero."
5050 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5052 (defun gnus-thread-total-score (thread)
5053 ;; This function find the total score of THREAD.
5054 (cond
5055 ((null thread)
5057 ((consp thread)
5058 (if (stringp (car thread))
5059 (apply gnus-thread-score-function 0
5060 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5061 (gnus-thread-total-score-1 thread)))
5063 (gnus-thread-total-score-1 (list thread)))))
5065 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5066 "Sort articles by number."
5067 (gnus-article-sort-by-number h1 h2))
5069 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5070 "Sort threads such that the thread with the most recently arrived article comes first."
5071 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5073 (defun gnus-thread-highest-number (thread)
5074 "Return the highest article number in THREAD."
5075 (apply 'max (mapcar (lambda (header)
5076 (mail-header-number header))
5077 (message-flatten-list thread))))
5079 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5080 "Sort articles by number."
5081 (gnus-article-sort-by-date h1 h2))
5083 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5084 "Sort threads such that the thread with the most recently dated article comes first."
5085 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5087 ; Since this is called not only to sort the top-level threads, but
5088 ; also in recursive sorts to order the articles within a thread, each
5089 ; article will be processed many times. Thus it speeds things up
5090 ; quite a bit to use gnus-date-get-time, which caches the time value.
5091 (defun gnus-thread-latest-date (thread)
5092 "Return the highest article date in THREAD."
5093 (apply 'max
5094 (mapcar (lambda (header) (float-time
5095 (gnus-date-get-time
5096 (mail-header-date header))))
5097 (message-flatten-list thread))))
5099 (defun gnus-thread-total-score-1 (root)
5100 ;; This function find the total score of the thread below ROOT.
5101 (setq root (car root))
5102 (apply gnus-thread-score-function
5103 (or (append
5104 (mapcar 'gnus-thread-total-score
5105 (cdr (gnus-id-to-thread (mail-header-id root))))
5106 (when (> (mail-header-number root) 0)
5107 (list (or (cdr (assq (mail-header-number root)
5108 gnus-newsgroup-scored))
5109 gnus-summary-default-score 0))))
5110 (list gnus-summary-default-score)
5111 '(0))))
5113 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5114 (defvar gnus-tmp-prev-subject nil)
5115 (defvar gnus-tmp-false-parent nil)
5116 (defvar gnus-tmp-root-expunged nil)
5117 (defvar gnus-tmp-dummy-line nil)
5119 (defun gnus-extra-header (type &optional header)
5120 "Return the extra header of TYPE."
5121 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5122 ""))
5124 (defvar gnus-tmp-thread-tree-header-string "")
5126 (defcustom gnus-sum-thread-tree-root "> "
5127 "With %B spec, used for the root of a thread.
5128 If nil, use subject instead."
5129 :version "22.1"
5130 :type '(radio (const :format "%v " nil) string)
5131 :group 'gnus-thread)
5133 (defcustom gnus-sum-thread-tree-false-root "> "
5134 "With %B spec, used for a false root of a thread.
5135 If nil, use subject instead."
5136 :version "22.1"
5137 :type '(radio (const :format "%v " nil) string)
5138 :group 'gnus-thread)
5140 (defcustom gnus-sum-thread-tree-single-indent ""
5141 "With %B spec, used for a thread with just one message.
5142 If nil, use subject instead."
5143 :version "22.1"
5144 :type '(radio (const :format "%v " nil) string)
5145 :group 'gnus-thread)
5147 (defcustom gnus-sum-thread-tree-vertical "| "
5148 "With %B spec, used for drawing a vertical line."
5149 :version "22.1"
5150 :type 'string
5151 :group 'gnus-thread)
5153 (defcustom gnus-sum-thread-tree-indent " "
5154 "With %B spec, used for indenting."
5155 :version "22.1"
5156 :type 'string
5157 :group 'gnus-thread)
5159 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5160 "With %B spec, used for a leaf with brothers."
5161 :version "22.1"
5162 :type 'string
5163 :group 'gnus-thread)
5165 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5166 "With %B spec, used for a leaf without brothers."
5167 :version "22.1"
5168 :type 'string
5169 :group 'gnus-thread)
5171 (defcustom gnus-summary-display-while-building nil
5172 "If non-nil, show and update the summary buffer as it's being built.
5173 If the value is t, update the buffer after every line is inserted. If
5174 the value is an integer (N), update the display every N lines."
5175 :version "22.1"
5176 :group 'gnus-thread
5177 :type '(choice (const :tag "off" nil)
5178 number
5179 (const :tag "frequently" t)))
5181 (defun gnus-summary-prepare-threads (threads)
5182 "Prepare summary buffer from THREADS and indentation LEVEL.
5183 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5184 or a straight list of headers."
5185 (gnus-message 7 "Generating summary...")
5187 (setq gnus-newsgroup-threads threads)
5188 (beginning-of-line)
5190 (let ((gnus-tmp-level 0)
5191 (default-score (or gnus-summary-default-score 0))
5192 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5193 (building-line-count gnus-summary-display-while-building)
5194 (building-count (integerp gnus-summary-display-while-building))
5195 thread number subject stack state gnus-tmp-gathered beg-match
5196 new-roots gnus-tmp-new-adopts thread-end simp-subject
5197 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5198 gnus-tmp-replied gnus-tmp-subject-or-nil
5199 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5200 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5201 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5202 tree-stack)
5204 (setq gnus-tmp-prev-subject nil
5205 gnus-tmp-thread-tree-header-string "")
5207 (if (vectorp (car threads))
5208 ;; If this is a straight (sic) list of headers, then a
5209 ;; threaded summary display isn't required, so we just create
5210 ;; an unthreaded one.
5211 (gnus-summary-prepare-unthreaded threads)
5213 ;; Do the threaded display.
5215 (if gnus-summary-display-while-building
5216 (switch-to-buffer (buffer-name)))
5217 (while (or threads stack gnus-tmp-new-adopts new-roots)
5219 (if (and (= gnus-tmp-level 0)
5220 (or (not stack)
5221 (= (caar stack) 0))
5222 (not gnus-tmp-false-parent)
5223 (or gnus-tmp-new-adopts new-roots))
5224 (if gnus-tmp-new-adopts
5225 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5226 thread (list (car gnus-tmp-new-adopts))
5227 gnus-tmp-header (caar thread)
5228 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5229 (when new-roots
5230 (setq thread (list (car new-roots))
5231 gnus-tmp-header (caar thread)
5232 new-roots (cdr new-roots))))
5234 (if threads
5235 ;; If there are some threads, we do them before the
5236 ;; threads on the stack.
5237 (setq thread threads
5238 gnus-tmp-header (caar thread))
5239 ;; There were no current threads, so we pop something off
5240 ;; the stack.
5241 (setq state (car stack)
5242 gnus-tmp-level (car state)
5243 tree-stack (cadr state)
5244 thread (caddr state)
5245 stack (cdr stack)
5246 gnus-tmp-header (caar thread))))
5248 (setq gnus-tmp-false-parent nil)
5249 (setq gnus-tmp-root-expunged nil)
5250 (setq thread-end nil)
5252 (if (stringp gnus-tmp-header)
5253 ;; The header is a dummy root.
5254 (cond
5255 ((eq gnus-summary-make-false-root 'adopt)
5256 ;; We let the first article adopt the rest.
5257 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5258 (cddar thread)))
5259 (setq gnus-tmp-gathered
5260 (nconc (mapcar
5261 (lambda (h) (mail-header-number (car h)))
5262 (cddar thread))
5263 gnus-tmp-gathered))
5264 (setq thread (cons (list (caar thread)
5265 (cadar thread))
5266 (cdr thread)))
5267 (setq gnus-tmp-level -1
5268 gnus-tmp-false-parent t))
5269 ((eq gnus-summary-make-false-root 'empty)
5270 ;; We print adopted articles with empty subject fields.
5271 (setq gnus-tmp-gathered
5272 (nconc (mapcar
5273 (lambda (h) (mail-header-number (car h)))
5274 (cddar thread))
5275 gnus-tmp-gathered))
5276 (setq gnus-tmp-level -1))
5277 ((eq gnus-summary-make-false-root 'dummy)
5278 ;; We remember that we probably want to output a dummy
5279 ;; root.
5280 (setq gnus-tmp-dummy-line gnus-tmp-header)
5281 (setq gnus-tmp-prev-subject gnus-tmp-header))
5283 ;; We do not make a root for the gathered
5284 ;; sub-threads at all.
5285 (setq gnus-tmp-level -1)))
5287 (setq number (mail-header-number gnus-tmp-header)
5288 subject (mail-header-subject gnus-tmp-header)
5289 simp-subject (gnus-simplify-subject-fully subject))
5291 (cond
5292 ;; If the thread has changed subject, we might want to make
5293 ;; this subthread into a root.
5294 ((and (null gnus-thread-ignore-subject)
5295 (not (zerop gnus-tmp-level))
5296 gnus-tmp-prev-subject
5297 (not (string= gnus-tmp-prev-subject simp-subject)))
5298 (setq new-roots (nconc new-roots (list (car thread)))
5299 thread-end t
5300 gnus-tmp-header nil))
5301 ;; If the article lies outside the current limit,
5302 ;; then we do not display it.
5303 ((not (memq number gnus-newsgroup-limit))
5304 (setq gnus-tmp-gathered
5305 (nconc (mapcar
5306 (lambda (h) (mail-header-number (car h)))
5307 (cdar thread))
5308 gnus-tmp-gathered))
5309 (setq gnus-tmp-new-adopts (if (cdar thread)
5310 (append gnus-tmp-new-adopts
5311 (cdar thread))
5312 gnus-tmp-new-adopts)
5313 thread-end t
5314 gnus-tmp-header nil)
5315 (when (zerop gnus-tmp-level)
5316 (setq gnus-tmp-root-expunged t)))
5317 ;; Perhaps this article is to be marked as read?
5318 ((and gnus-summary-mark-below
5319 (< (or (cdr (assq number gnus-newsgroup-scored))
5320 default-score)
5321 gnus-summary-mark-below)
5322 ;; Don't touch sparse articles.
5323 (not (gnus-summary-article-sparse-p number))
5324 (not (gnus-summary-article-ancient-p number)))
5325 (setq gnus-newsgroup-unreads
5326 (delq number gnus-newsgroup-unreads))
5327 (if gnus-newsgroup-auto-expire
5328 (setq gnus-newsgroup-expirable
5329 (gnus-add-to-sorted-list
5330 gnus-newsgroup-expirable number))
5331 (push (cons number gnus-low-score-mark)
5332 gnus-newsgroup-reads))))
5334 (when gnus-tmp-header
5335 ;; We may have an old dummy line to output before this
5336 ;; article.
5337 (when (and gnus-tmp-dummy-line
5338 (gnus-subject-equal
5339 gnus-tmp-dummy-line
5340 (mail-header-subject gnus-tmp-header)))
5341 (gnus-summary-insert-dummy-line
5342 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5343 (setq gnus-tmp-dummy-line nil))
5345 ;; Compute the mark.
5346 (setq gnus-tmp-unread (gnus-article-mark number))
5348 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5349 gnus-tmp-header gnus-tmp-level)
5350 gnus-newsgroup-data)
5352 ;; Actually insert the line.
5353 (setq
5354 gnus-tmp-subject-or-nil
5355 (cond
5356 ((and gnus-thread-ignore-subject
5357 gnus-tmp-prev-subject
5358 (not (string= gnus-tmp-prev-subject simp-subject)))
5359 subject)
5360 ((zerop gnus-tmp-level)
5361 (if (and (eq gnus-summary-make-false-root 'empty)
5362 (memq number gnus-tmp-gathered)
5363 gnus-tmp-prev-subject
5364 (string= gnus-tmp-prev-subject simp-subject))
5365 gnus-summary-same-subject
5366 subject))
5367 (t gnus-summary-same-subject)))
5368 (if (and (eq gnus-summary-make-false-root 'adopt)
5369 (= gnus-tmp-level 1)
5370 (memq number gnus-tmp-gathered))
5371 (setq gnus-tmp-opening-bracket ?\<
5372 gnus-tmp-closing-bracket ?\>)
5373 (setq gnus-tmp-opening-bracket ?\[
5374 gnus-tmp-closing-bracket ?\]))
5375 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5376 (gnus-make-thread-indent-array
5377 (max (* 2 (length gnus-thread-indent-array))
5378 gnus-tmp-level)))
5379 (setq
5380 gnus-tmp-indentation
5381 (aref gnus-thread-indent-array gnus-tmp-level)
5382 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5383 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5384 gnus-summary-default-score 0)
5385 gnus-tmp-score-char
5386 (if (or (null gnus-summary-default-score)
5387 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5388 gnus-summary-zcore-fuzz))
5389 ? ;Whitespace
5390 (if (< gnus-tmp-score gnus-summary-default-score)
5391 gnus-score-below-mark gnus-score-over-mark))
5392 gnus-tmp-replied
5393 (cond ((memq number gnus-newsgroup-processable)
5394 gnus-process-mark)
5395 ((memq number gnus-newsgroup-cached)
5396 gnus-cached-mark)
5397 ((memq number gnus-newsgroup-replied)
5398 gnus-replied-mark)
5399 ((memq number gnus-newsgroup-forwarded)
5400 gnus-forwarded-mark)
5401 ((memq number gnus-newsgroup-saved)
5402 gnus-saved-mark)
5403 ((memq number gnus-newsgroup-unseen)
5404 gnus-unseen-mark)
5405 (t gnus-no-mark))
5406 gnus-tmp-downloaded
5407 (cond ((memq number gnus-newsgroup-undownloaded)
5408 gnus-undownloaded-mark)
5409 (gnus-newsgroup-agentized
5410 gnus-downloaded-mark)
5412 gnus-no-mark))
5413 gnus-tmp-from (mail-header-from gnus-tmp-header)
5414 gnus-tmp-name
5415 (cond
5416 ((string-match "<[^>]+> *$" gnus-tmp-from)
5417 (setq beg-match (match-beginning 0))
5418 (or (and (string-match "^\".+\"" gnus-tmp-from)
5419 (substring gnus-tmp-from 1 (1- (match-end 0))))
5420 (substring gnus-tmp-from 0 beg-match)))
5421 ((string-match "(.+)" gnus-tmp-from)
5422 (substring gnus-tmp-from
5423 (1+ (match-beginning 0)) (1- (match-end 0))))
5424 (t gnus-tmp-from))
5426 ;; Do the %B string
5427 gnus-tmp-thread-tree-header-string
5428 (cond
5429 ((not gnus-show-threads) "")
5430 ((zerop gnus-tmp-level)
5431 (cond ((cdar thread)
5432 (or gnus-sum-thread-tree-root subject))
5433 (gnus-tmp-new-adopts
5434 (or gnus-sum-thread-tree-false-root subject))
5436 (or gnus-sum-thread-tree-single-indent subject))))
5438 (concat (apply 'concat
5439 (mapcar (lambda (item)
5440 (if (= item 1)
5441 gnus-sum-thread-tree-vertical
5442 gnus-sum-thread-tree-indent))
5443 (cdr (reverse tree-stack))))
5444 (if (nth 1 thread)
5445 gnus-sum-thread-tree-leaf-with-other
5446 gnus-sum-thread-tree-single-leaf)))))
5447 (when (string= gnus-tmp-name "")
5448 (setq gnus-tmp-name gnus-tmp-from))
5449 (unless (numberp gnus-tmp-lines)
5450 (setq gnus-tmp-lines -1))
5451 (if (= gnus-tmp-lines -1)
5452 (setq gnus-tmp-lines "?")
5453 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5454 (put-text-property
5455 (point)
5456 (progn (eval gnus-summary-line-format-spec) (point))
5457 'gnus-number number)
5458 (when gnus-visual-p
5459 (forward-line -1)
5460 (gnus-summary-highlight-line)
5461 (when gnus-summary-update-hook
5462 (gnus-run-hooks 'gnus-summary-update-hook))
5463 (forward-line 1))
5465 (setq gnus-tmp-prev-subject simp-subject)))
5467 (when (nth 1 thread)
5468 (push (list (max 0 gnus-tmp-level)
5469 (copy-sequence tree-stack)
5470 (nthcdr 1 thread))
5471 stack))
5472 (push (if (nth 1 thread) 1 0) tree-stack)
5473 (cl-incf gnus-tmp-level)
5474 (setq threads (if thread-end nil (cdar thread)))
5475 (if gnus-summary-display-while-building
5476 (if building-count
5477 (progn
5478 ;; use a set frequency
5479 (setq building-line-count (1- building-line-count))
5480 (when (= building-line-count 0)
5481 (sit-for 0)
5482 (setq building-line-count
5483 gnus-summary-display-while-building)))
5484 ;; always
5485 (sit-for 0)))
5486 (unless threads
5487 (setq gnus-tmp-level 0)))))
5488 (gnus-message 7 "Generating summary...done"))
5490 (defun gnus-summary-prepare-unthreaded (headers)
5491 "Generate an unthreaded summary buffer based on HEADERS."
5492 (let (header number mark)
5494 (beginning-of-line)
5496 (while headers
5497 ;; We may have to root out some bad articles...
5498 (when (memq (setq number (mail-header-number
5499 (setq header (pop headers))))
5500 gnus-newsgroup-limit)
5501 ;; Mark article as read when it has a low score.
5502 (when (and gnus-summary-mark-below
5503 (< (or (cdr (assq number gnus-newsgroup-scored))
5504 gnus-summary-default-score 0)
5505 gnus-summary-mark-below)
5506 (not (gnus-summary-article-ancient-p number)))
5507 (setq gnus-newsgroup-unreads
5508 (delq number gnus-newsgroup-unreads))
5509 (if gnus-newsgroup-auto-expire
5510 (push number gnus-newsgroup-expirable)
5511 (push (cons number gnus-low-score-mark)
5512 gnus-newsgroup-reads)))
5514 (setq mark (gnus-article-mark number))
5515 (push (gnus-data-make number mark (1+ (point)) header 0)
5516 gnus-newsgroup-data)
5517 (gnus-summary-insert-line
5518 header 0 number
5519 (memq number gnus-newsgroup-undownloaded)
5520 mark (memq number gnus-newsgroup-replied)
5521 (memq number gnus-newsgroup-expirable)
5522 (mail-header-subject header) nil
5523 (cdr (assq number gnus-newsgroup-scored))
5524 (memq number gnus-newsgroup-processable))))))
5526 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5528 (defun gnus-group-get-list-identifiers (group)
5529 "Get list identifier regexp for GROUP."
5530 (or (gnus-parameter-list-identifier group)
5531 (if (consp gnus-list-identifiers)
5532 (mapconcat 'identity gnus-list-identifiers " *\\|")
5533 gnus-list-identifiers)))
5535 (defun gnus-summary-remove-list-identifiers ()
5536 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5537 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5538 changed subject)
5539 (when regexp
5540 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5541 (dolist (header gnus-newsgroup-headers)
5542 (setq subject (mail-header-subject header)
5543 changed nil)
5544 (while (string-match regexp subject)
5545 (setq subject
5546 (concat (substring subject 0 (match-beginning 1))
5547 (substring subject (match-end 0)))
5548 changed t))
5549 (when changed
5550 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5551 (setq subject
5552 (concat (substring subject 0 (match-beginning 1))
5553 (substring subject (match-end 1)))))
5554 (mail-header-set-subject header subject))))))
5556 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5557 "Fetch headers of ARTICLES."
5558 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5559 (gnus-message 7 "Fetching headers for %s..." name)
5560 (prog1
5561 (if (eq 'nov
5562 (setq gnus-headers-retrieved-by
5563 (gnus-retrieve-headers
5564 articles gnus-newsgroup-name
5565 (or limit
5566 ;; We might want to fetch old headers, but
5567 ;; not if there is only 1 article.
5568 (and (or (and
5569 (not (eq gnus-fetch-old-headers 'some))
5570 (not (numberp gnus-fetch-old-headers)))
5571 (> (length articles) 1))
5572 gnus-fetch-old-headers)))))
5573 (gnus-get-newsgroup-headers-xover
5574 articles force-new dependencies gnus-newsgroup-name t)
5575 (gnus-get-newsgroup-headers dependencies force-new))
5576 (gnus-message 7 "Fetching headers for %s...done" name))))
5578 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5579 "Select newsgroup GROUP.
5580 If READ-ALL is non-nil, all articles in the group are selected.
5581 If SELECT-ARTICLES, only select those articles from GROUP."
5582 (let* ((entry (gnus-group-entry group))
5583 ;;!!! Dirty hack; should be removed.
5584 (gnus-summary-ignore-duplicates
5585 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5587 gnus-summary-ignore-duplicates))
5588 (info (nth 2 entry))
5589 charset articles fetched-articles cached)
5591 (unless (gnus-check-server
5592 (set (make-local-variable 'gnus-current-select-method)
5593 (gnus-find-method-for-group group)))
5594 (error "Couldn't open server"))
5595 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5597 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5598 (gnus-activate-group group) ; Or we can activate it...
5599 (progn ; Or we bug out.
5600 (when (derived-mode-p 'gnus-summary-mode)
5601 (gnus-kill-buffer (current-buffer)))
5602 (error
5603 "Couldn't activate group %s: %s"
5604 (decode-coding-string group charset)
5605 (decode-coding-string (gnus-status-message group) charset))))
5607 (unless (gnus-request-group group t nil (gnus-get-info group))
5608 (when (derived-mode-p 'gnus-summary-mode)
5609 (gnus-kill-buffer (current-buffer)))
5610 (error "Couldn't request group %s: %s"
5611 (decode-coding-string group charset)
5612 (decode-coding-string (gnus-status-message group) charset)))
5614 (when (and gnus-agent
5615 (gnus-active group))
5616 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5618 (setq gnus-summary-use-undownloaded-faces
5619 (gnus-agent-find-parameter
5620 group
5621 'agent-enable-undownloaded-faces)))
5623 (setq gnus-newsgroup-name group
5624 gnus-newsgroup-unselected nil
5625 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5627 (let ((display (gnus-group-find-parameter group 'display)))
5628 (setq gnus-newsgroup-display
5629 (cond
5630 ((not (zerop (or (car-safe read-all) 0)))
5631 ;; The user entered the group with C-u SPC/RET, let's show
5632 ;; all articles.
5633 'gnus-not-ignore)
5634 ((eq display 'all)
5635 'gnus-not-ignore)
5636 ((arrayp display)
5637 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5638 ((numberp display)
5639 ;; The following is probably the "correct" solution, but
5640 ;; it makes Gnus fetch all headers and then limit the
5641 ;; articles (which is slow), so instead we hack the
5642 ;; select-articles parameter instead. -- Simon Josefsson
5643 ;; <jas@kth.se>
5645 ;; (gnus-byte-compile
5646 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5647 ;; display)))))
5648 (setq select-articles
5649 (gnus-uncompress-range
5650 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5651 (if (> tmp 0)
5654 (cdr (gnus-active group)))))
5655 nil)
5657 nil))))
5659 (gnus-summary-setup-default-charset)
5661 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5662 (when (gnus-virtual-group-p group)
5663 (setq cached gnus-newsgroup-cached))
5665 (setq gnus-newsgroup-unreads
5666 (gnus-sorted-ndifference
5667 (gnus-sorted-ndifference gnus-newsgroup-unreads
5668 gnus-newsgroup-marked)
5669 gnus-newsgroup-dormant))
5671 (setq gnus-newsgroup-processable nil)
5673 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5675 ;; Adjust and set lists of article marks.
5676 (when info
5677 (gnus-adjust-marked-articles info))
5678 (if (setq articles select-articles)
5679 (setq gnus-newsgroup-unselected
5680 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5681 (setq articles (gnus-articles-to-read group read-all)))
5683 (cond
5684 ((null articles)
5685 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5686 'quit)
5687 ((eq articles 0) nil)
5689 ;; Init the dependencies hash table.
5690 (setq gnus-newsgroup-dependencies
5691 (gnus-make-hashtable (length articles)))
5692 (if (gnus-buffer-live-p gnus-group-buffer)
5693 (gnus-set-global-variables)
5694 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5695 ;; Retrieve the headers and read them in.
5697 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5699 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5700 (when cached
5701 (setq gnus-newsgroup-cached cached))
5703 ;; Suppress duplicates?
5704 (when gnus-suppress-duplicates
5705 (gnus-dup-suppress-articles))
5707 ;; Set the initial limit.
5708 (setq gnus-newsgroup-limit (copy-sequence articles))
5709 ;; Remove canceled articles from the list of unread articles.
5710 (setq fetched-articles
5711 (mapcar (lambda (headers) (mail-header-number headers))
5712 gnus-newsgroup-headers))
5713 (setq gnus-newsgroup-articles fetched-articles)
5714 (setq gnus-newsgroup-unreads
5715 (gnus-sorted-nintersection
5716 gnus-newsgroup-unreads fetched-articles))
5717 (gnus-compute-unseen-list)
5719 ;; Removed marked articles that do not exist.
5720 (gnus-update-missing-marks
5721 (gnus-sorted-difference articles fetched-articles))
5722 ;; We might want to build some more threads first.
5723 (when (and gnus-fetch-old-headers
5724 (eq gnus-headers-retrieved-by 'nov))
5725 (if (eq gnus-fetch-old-headers 'invisible)
5726 (gnus-build-all-threads)
5727 (gnus-build-old-threads)))
5728 ;; Let the Gnus agent mark articles as read.
5729 (when gnus-agent
5730 (gnus-agent-get-undownloaded-list))
5731 ;; Remove list identifiers from subject
5732 (gnus-summary-remove-list-identifiers)
5733 ;; Check whether auto-expire is to be done in this group.
5734 (setq gnus-newsgroup-auto-expire
5735 (and (gnus-group-auto-expirable-p group)
5736 (not (gnus-group-read-only-p group))))
5737 ;; Set up the article buffer now, if necessary.
5738 (unless (and gnus-single-article-buffer
5739 (equal gnus-article-buffer "*Article*"))
5740 (gnus-article-setup-buffer))
5741 ;; First and last article in this newsgroup.
5742 (when gnus-newsgroup-headers
5743 (setq gnus-newsgroup-begin
5744 (mail-header-number (car gnus-newsgroup-headers))
5745 gnus-newsgroup-end
5746 (mail-header-number
5747 (car (last gnus-newsgroup-headers)))))
5748 ;; GROUP is successfully selected.
5749 (or gnus-newsgroup-headers t)))))
5751 (defun gnus-compute-unseen-list ()
5752 ;; The `seen' marks are treated specially.
5753 (if (not gnus-newsgroup-seen)
5754 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5755 (setq gnus-newsgroup-unseen
5756 (gnus-inverse-list-range-intersection
5757 gnus-newsgroup-articles gnus-newsgroup-seen))))
5759 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5761 (defun gnus-summary-display-make-predicate (display)
5762 (require 'gnus-agent)
5763 (when (= (length display) 1)
5764 (setq display (car display)))
5765 (unless gnus-summary-display-cache
5766 (dolist (elem (append '((unread . unread)
5767 (read . read)
5768 (unseen . unseen))
5769 gnus-article-mark-lists))
5770 (push (cons (cdr elem)
5771 (gnus-byte-compile ;Why bother?
5772 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5773 gnus-summary-display-cache)))
5774 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5775 (gnus-category-predicate-cache gnus-summary-display-cache))
5776 (gnus-get-predicate display)))
5778 ;; Uses the dynamically bound `gnus-number' variable.
5779 (defvar gnus-number)
5780 (defun gnus-article-marked-p (type &optional article)
5781 (let ((article (or article gnus-number)))
5782 (cond
5783 ((eq type 'tick)
5784 (memq article gnus-newsgroup-marked))
5785 ((eq type 'spam)
5786 (memq article gnus-newsgroup-spam-marked))
5787 ((eq type 'unsend)
5788 (memq article gnus-newsgroup-unsendable))
5789 ((eq type 'undownload)
5790 (memq article gnus-newsgroup-undownloaded))
5791 ((eq type 'download)
5792 (memq article gnus-newsgroup-downloadable))
5793 ((eq type 'unread)
5794 (memq article gnus-newsgroup-unreads))
5795 ((eq type 'read)
5796 (memq article gnus-newsgroup-reads))
5797 ((eq type 'dormant)
5798 (memq article gnus-newsgroup-dormant) )
5799 ((eq type 'expire)
5800 (memq article gnus-newsgroup-expirable))
5801 ((eq type 'reply)
5802 (memq article gnus-newsgroup-replied))
5803 ((eq type 'killed)
5804 (memq article gnus-newsgroup-killed))
5805 ((eq type 'bookmark)
5806 (assq article gnus-newsgroup-bookmarks))
5807 ((eq type 'score)
5808 (assq article gnus-newsgroup-scored))
5809 ((eq type 'save)
5810 (memq article gnus-newsgroup-saved))
5811 ((eq type 'cache)
5812 (memq article gnus-newsgroup-cached))
5813 ((eq type 'forward)
5814 (memq article gnus-newsgroup-forwarded))
5815 ((eq type 'seen)
5816 (not (memq article gnus-newsgroup-unseen)))
5817 (t t))))
5819 (defun gnus-articles-to-read (group &optional read-all)
5820 "Find out what articles the user wants to read."
5821 (let* ((only-read-p t)
5822 (articles
5823 (gnus-list-range-difference
5824 ;; Select all articles if `read-all' is non-nil, or if there
5825 ;; are no unread articles.
5826 (if (or read-all
5827 (and (zerop (length gnus-newsgroup-marked))
5828 (zerop (length gnus-newsgroup-unreads)))
5829 ;; Fetch all if the predicate is non-nil.
5830 gnus-newsgroup-display)
5831 ;; We want to select the headers for all the articles in
5832 ;; the group, so we select either all the active
5833 ;; articles in the group, or (if that's nil), the
5834 ;; articles in the cache.
5836 (if gnus-newsgroup-maximum-articles
5837 (let ((active (gnus-active group)))
5838 (gnus-uncompress-range
5839 (cons (max (car active)
5840 (- (cdr active)
5841 gnus-newsgroup-maximum-articles
5842 -1))
5843 (cdr active))))
5844 (gnus-uncompress-range (gnus-active group)))
5845 (gnus-cache-articles-in-group group))
5846 ;; Select only the "normal" subset of articles.
5847 (setq only-read-p nil)
5848 (gnus-sorted-nunion
5849 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5850 gnus-newsgroup-unreads))
5851 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5852 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5853 (scored (length scored-list))
5854 (number (length articles))
5855 (marked (+ (length gnus-newsgroup-marked)
5856 (length gnus-newsgroup-dormant)))
5857 (select
5858 (cond
5859 ((numberp read-all)
5860 read-all)
5861 ((numberp gnus-newsgroup-display)
5862 gnus-newsgroup-display)
5864 (condition-case ()
5865 (cond
5866 ((and (or (<= scored marked) (= scored number))
5867 (numberp gnus-large-newsgroup)
5868 (> number gnus-large-newsgroup))
5869 (let* ((cursor-in-echo-area nil)
5870 (initial (gnus-parameter-large-newsgroup-initial
5871 gnus-newsgroup-name))
5872 (default (if only-read-p
5873 (or initial gnus-large-newsgroup)
5874 number))
5875 (input
5876 (read-string
5877 (if only-read-p
5878 (format
5879 "How many articles from %s (available %d, default %d): "
5880 (gnus-group-real-name
5881 (gnus-group-decoded-name gnus-newsgroup-name))
5882 number default)
5883 (format
5884 "How many articles from %s (%d default): "
5885 (gnus-group-real-name
5886 (gnus-group-decoded-name gnus-newsgroup-name))
5887 default))
5890 (number-to-string default))))
5891 (if (string-match "^[ \t]*$" input) number input)))
5892 ((and (> scored marked) (< scored number)
5893 (> (- scored number) 20))
5894 (let ((input
5895 (read-string
5896 (format "%s %s (%d scored, %d total): "
5897 "How many articles from"
5898 (gnus-group-decoded-name
5899 (gnus-group-real-name gnus-newsgroup-name))
5900 scored number))))
5901 (if (string-match "^[ \t]*$" input)
5902 number input)))
5903 (t number))
5904 (quit
5905 (message "Quit getting the articles to read")
5906 nil))))))
5907 (setq select (if (stringp select) (string-to-number select) select))
5908 (if (or (null select) (zerop select))
5909 select
5910 (if (and (not (zerop scored)) (<= (abs select) scored))
5911 (progn
5912 (setq articles (sort scored-list '<))
5913 (setq number (length articles)))
5914 (setq articles (copy-sequence articles)))
5916 (when (< (abs select) number)
5917 (if (< select 0)
5918 ;; Select the N oldest articles.
5919 (setcdr (nthcdr (1- (abs select)) articles) nil)
5920 ;; Select the N most recent articles.
5921 (setq articles (nthcdr (- number select) articles))))
5922 (setq gnus-newsgroup-unselected
5923 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5924 (when (functionp gnus-alter-articles-to-read-function)
5925 (setq articles
5926 (sort
5927 (funcall gnus-alter-articles-to-read-function
5928 gnus-newsgroup-name articles)
5929 '<)))
5930 articles)))
5932 (defun gnus-killed-articles (killed articles)
5933 (let (out)
5934 (while articles
5935 (when (inline (gnus-member-of-range (car articles) killed))
5936 (push (car articles) out))
5937 (setq articles (cdr articles)))
5938 out))
5940 (defun gnus-article-mark-to-type (mark)
5941 "Return the type of MARK."
5942 (or (cadr (assq mark gnus-article-special-mark-lists))
5943 'list))
5945 (defun gnus-article-unpropagatable-p (mark)
5946 "Return whether MARK should be propagated to back end."
5947 (memq mark gnus-article-unpropagated-mark-lists))
5949 (defun gnus-adjust-marked-articles (info)
5950 "Set all article lists and remove all marks that are no longer valid."
5951 (let* ((marked-lists (gnus-info-marks info))
5952 (active (gnus-active (gnus-info-group info)))
5953 (min (car active))
5954 (max (cdr active))
5955 (types gnus-article-mark-lists)
5956 marks var articles article mark mark-type
5957 bgn end)
5958 ;; Hack to avoid adjusting marks for imap.
5959 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5960 'nnimap)
5961 (setq min 1))
5963 (dolist (marks marked-lists)
5964 (setq mark (car marks)
5965 mark-type (gnus-article-mark-to-type mark)
5966 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5967 ;; We set the variable according to the type of the marks list,
5968 ;; and then adjust the marks to a subset of the active articles.
5969 (cond
5970 ;; Adjust "simple" lists - compressed yet unsorted
5971 ((eq mark-type 'list)
5972 ;; Simultaneously uncompress and clip to active range
5973 ;; See gnus-uncompress-range for a description of possible marks
5974 (let (l lh)
5975 (if (not (cadr marks))
5976 (set var nil)
5977 (setq articles (if (numberp (cddr marks))
5978 (list (cdr marks))
5979 (cdr marks))
5980 lh (cons nil nil)
5981 l lh)
5983 (while (setq article (pop articles))
5984 (cond ((consp article)
5985 (setq bgn (max (car article) min)
5986 end (min (cdr article) max))
5987 (while (<= bgn end)
5988 (setq l (setcdr l (cons bgn nil))
5989 bgn (1+ bgn))))
5990 ((and (<= min article)
5991 (>= max article))
5992 (setq l (setcdr l (cons article nil))))))
5993 (set var (cdr lh)))))
5994 ;; Adjust assocs.
5995 ((eq mark-type 'tuple)
5996 (set var (setq articles (cdr marks)))
5997 (when (not (listp (cdr (symbol-value var))))
5998 (set var (list (symbol-value var))))
5999 (when (not (listp (cdr articles)))
6000 (setq articles (list articles)))
6001 (while articles
6002 (when (or (not (consp (setq article (pop articles))))
6003 (< (car article) min)
6004 (> (car article) max))
6005 (set var (delq article (symbol-value var))))))
6006 ;; Adjust ranges (sloppily).
6007 ((eq mark-type 'range)
6008 (cond
6009 ((eq mark 'seen)
6010 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6011 ;; It should be (seen (NUM1 . NUM2)).
6012 (when (numberp (cddr marks))
6013 (setcdr marks (list (cdr marks))))
6014 (setq articles (cdr marks))
6015 (while (and articles
6016 (or (and (consp (car articles))
6017 (> min (cdar articles)))
6018 (and (numberp (car articles))
6019 (> min (car articles)))))
6020 (pop articles))
6021 (set var articles))
6022 ((eq mark 'unexist)
6023 (set var (cdr marks)))))))))
6025 (defun gnus-update-missing-marks (missing)
6026 "Go through the list of MISSING articles and remove them from the mark lists."
6027 (when missing
6028 (let (var m)
6029 ;; Go through all types.
6030 (dolist (elem gnus-article-mark-lists)
6031 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6032 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6033 (when (symbol-value var)
6034 ;; This list has articles. So we delete all missing
6035 ;; articles from it.
6036 (setq m missing)
6037 (while m
6038 (set var (delq (pop m) (symbol-value var))))))))))
6040 (defun gnus-update-marks ()
6041 "Enter the various lists of marked articles into the newsgroup info list."
6042 (let ((types gnus-article-mark-lists)
6043 (info (gnus-get-info gnus-newsgroup-name))
6044 type list newmarked symbol delta-marks)
6045 (when info
6046 ;; Add all marks lists to the list of marks lists.
6047 (while (setq type (pop types))
6048 (setq list (symbol-value
6049 (setq symbol
6050 (intern (format "gnus-newsgroup-%s" (car type))))))
6052 (when list
6053 ;; Get rid of the entries of the articles that have the
6054 ;; default score.
6055 (when (and (eq (cdr type) 'score)
6056 gnus-save-score
6057 list)
6058 (let* ((arts list)
6059 (prev (cons nil list))
6060 (all prev))
6061 (while arts
6062 (if (or (not (consp (car arts)))
6063 (= (cdar arts) gnus-summary-default-score))
6064 (setcdr prev (cdr arts))
6065 (setq prev arts))
6066 (setq arts (cdr arts)))
6067 (setq list (cdr all)))))
6069 ;; When exiting the group, everything that's previously been
6070 ;; unseen is now seen.
6071 (when (eq (cdr type) 'seen)
6072 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6074 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6075 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6077 (when (and (gnus-check-backend-function
6078 'request-set-mark gnus-newsgroup-name)
6079 (not (gnus-article-unpropagatable-p (cdr type))))
6080 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6081 ;; Don't do anything about marks for articles we
6082 ;; didn't actually get any headers for.
6083 (del
6084 (gnus-list-range-intersection
6085 gnus-newsgroup-articles
6086 (gnus-remove-from-range (copy-tree old) list)))
6087 (add
6088 (gnus-list-range-intersection
6089 gnus-newsgroup-articles
6090 (gnus-remove-from-range
6091 (copy-tree list) old))))
6092 (when add
6093 (push (list add 'add (list (cdr type))) delta-marks))
6094 (when del
6095 ;; Don't delete marks from outside the active range.
6096 ;; This shouldn't happen, but is a sanity check.
6097 (setq del (gnus-sorted-range-intersection
6098 (gnus-active gnus-newsgroup-name) del))
6099 (push (list del 'del (list (cdr type))) delta-marks))))
6101 (when (or list
6102 (eq (cdr type) 'unexist))
6103 (push (cons (cdr type) list) newmarked)))
6105 (when delta-marks
6106 (unless (gnus-check-group gnus-newsgroup-name)
6107 (error "Can't open server for %s" gnus-newsgroup-name))
6108 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6110 ;; Enter these new marks into the info of the group.
6111 (if (nthcdr 3 info)
6112 (setcar (nthcdr 3 info) newmarked)
6113 ;; Add the marks lists to the end of the info.
6114 (when newmarked
6115 (setcdr (nthcdr 2 info) (list newmarked))))
6117 ;; Cut off the end of the info if there's nothing else there.
6118 (let ((i 5))
6119 (while (and (> i 2)
6120 (not (nth i info)))
6121 (when (nthcdr (cl-decf i) info)
6122 (setcdr (nthcdr i info) nil)))))))
6124 (defun gnus-set-mode-line (where)
6125 "Set the mode line of the article or summary buffers.
6126 If WHERE is `summary', the summary mode line format will be used."
6127 ;; Is this mode line one we keep updated?
6128 (when (and (memq where gnus-updated-mode-lines)
6129 (symbol-value
6130 (intern (format "gnus-%s-mode-line-format-spec" where))))
6131 (let (mode-string)
6132 ;; We evaluate this in the summary buffer since these
6133 ;; variables are buffer-local to that buffer.
6134 (with-current-buffer gnus-summary-buffer
6135 ;; We bind all these variables that are used in the `eval' form
6136 ;; below.
6137 (let* ((mformat (symbol-value
6138 (intern
6139 (format "gnus-%s-mode-line-format-spec" where))))
6140 (gnus-tmp-group-name (gnus-mode-string-quote
6141 (gnus-group-decoded-name
6142 gnus-newsgroup-name)))
6143 (gnus-tmp-article-number (or gnus-current-article 0))
6144 (gnus-tmp-unread gnus-newsgroup-unreads)
6145 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6146 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6147 (gnus-tmp-unread-and-unselected
6148 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6149 (zerop gnus-tmp-unselected))
6151 ((zerop gnus-tmp-unselected)
6152 (format "{%d more}" gnus-tmp-unread-and-unticked))
6153 (t (format "{%d(+%d) more}"
6154 gnus-tmp-unread-and-unticked
6155 gnus-tmp-unselected))))
6156 (gnus-tmp-subject
6157 (if (and gnus-current-headers
6158 (vectorp gnus-current-headers))
6159 (gnus-mode-string-quote
6160 (mail-header-subject gnus-current-headers))
6161 ""))
6162 bufname-length max-len
6163 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6164 (setq mode-string (eval mformat))
6165 (setq bufname-length (if (string-match "%b" mode-string)
6166 (- (length
6167 (buffer-name
6168 (if (eq where 'summary)
6170 (get-buffer gnus-article-buffer))))
6173 (setq max-len (max 4 (if gnus-mode-non-string-length
6174 (- (window-width)
6175 gnus-mode-non-string-length
6176 bufname-length)
6177 (length mode-string))))
6178 ;; We might have to chop a bit of the string off...
6179 (when (> (length mode-string) max-len)
6180 (setq mode-string
6181 (concat (truncate-string-to-width mode-string (- max-len 3))
6182 "...")))))
6183 ;; Update the mode line.
6184 (setq mode-line-buffer-identification
6185 (gnus-mode-line-buffer-identification (list mode-string)))
6186 (set-buffer-modified-p t))))
6188 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6189 "Go through the HEADERS list and add all Xrefs to a hash table.
6190 The resulting hash table is returned, or nil if no Xrefs were found."
6191 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6192 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6193 (xref-hashtb (gnus-make-hashtable))
6194 start group entry number xrefs header)
6195 (while headers
6196 (setq header (pop headers))
6197 (when (and (setq xrefs (mail-header-xref header))
6198 (not (memq (setq number (mail-header-number header))
6199 unreads)))
6200 (setq start 0)
6201 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6202 (setq start (match-end 0))
6203 (setq group (if prefix
6204 (concat prefix (substring xrefs (match-beginning 1)
6205 (match-end 1)))
6206 (substring xrefs (match-beginning 1) (match-end 1))))
6207 (setq number
6208 (string-to-number (substring xrefs (match-beginning 2)
6209 (match-end 2))))
6210 (if (setq entry (gnus-gethash group xref-hashtb))
6211 (setcdr entry (cons number (cdr entry)))
6212 (gnus-sethash group (cons number nil) xref-hashtb)))))
6213 (and start xref-hashtb)))
6215 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6216 "Look through all the headers and mark the Xrefs as read."
6217 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6218 name info xref-hashtb idlist method nth4)
6219 (with-current-buffer gnus-group-buffer
6220 (when (setq xref-hashtb
6221 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6222 (mapatoms
6223 (lambda (group)
6224 (unless (string= from-newsgroup (setq name (symbol-name group)))
6225 (setq idlist (symbol-value group))
6226 ;; Dead groups are not updated.
6227 (and (prog1
6228 (setq info (gnus-get-info name))
6229 (when (stringp (setq nth4 (gnus-info-method info)))
6230 (setq nth4 (gnus-server-to-method nth4))))
6231 ;; Only do the xrefs if the group has the same
6232 ;; select method as the group we have just read.
6233 (or (gnus-methods-equal-p
6234 nth4 (gnus-find-method-for-group from-newsgroup))
6235 virtual
6236 (equal nth4 (setq method (gnus-find-method-for-group
6237 from-newsgroup)))
6238 (and (equal (car nth4) (car method))
6239 (equal (nth 1 nth4) (nth 1 method))))
6240 gnus-use-cross-reference
6241 (or (not (eq gnus-use-cross-reference t))
6242 virtual
6243 ;; Only do cross-references on subscribed
6244 ;; groups, if that is what is wanted.
6245 (<= (gnus-info-level info) gnus-level-subscribed))
6246 (gnus-group-make-articles-read name idlist))))
6247 xref-hashtb)))))
6249 (defun gnus-compute-read-articles (group articles)
6250 (let* ((entry (gnus-group-entry group))
6251 (info (nth 2 entry))
6252 (active (gnus-active group))
6253 ninfo)
6254 (when entry
6255 ;; First peel off all invalid article numbers.
6256 (when active
6257 (let ((ids articles)
6258 id first)
6259 (while (setq id (pop ids))
6260 (when (and first (> id (cdr active)))
6261 ;; We'll end up in this situation in one particular
6262 ;; obscure situation. If you re-scan a group and get
6263 ;; a new article that is cross-posted to a different
6264 ;; group that has not been re-scanned, you might get
6265 ;; crossposted article that has a higher number than
6266 ;; Gnus believes possible. So we re-activate this
6267 ;; group as well. This might mean doing the
6268 ;; crossposting thingy will *increase* the number
6269 ;; of articles in some groups. Tsk, tsk.
6270 (setq active (or (gnus-activate-group group) active)))
6271 (when (or (> id (cdr active))
6272 (< id (car active)))
6273 (setq articles (delq id articles))))))
6274 ;; If the read list is nil, we init it.
6275 (if (and active
6276 (null (gnus-info-read info))
6277 (> (car active) 1))
6278 (setq ninfo (cons 1 (1- (car active))))
6279 (setq ninfo (gnus-info-read info)))
6280 ;; Then we add the read articles to the range.
6281 (gnus-add-to-range
6282 ninfo (setq articles (sort articles '<))))))
6284 (defun gnus-group-make-articles-read (group articles)
6285 "Update the info of GROUP to say that ARTICLES are read."
6286 (let* ((num 0)
6287 (entry (gnus-group-entry group))
6288 (info (nth 2 entry))
6289 (active (gnus-active group))
6290 (set-marks
6291 (gnus-method-option-p
6292 (gnus-find-method-for-group group)
6293 'server-marks))
6294 range)
6295 (if (not entry)
6296 ;; Group that Gnus doesn't know exists, but still allow the
6297 ;; backend to set marks.
6298 (when set-marks
6299 (gnus-request-set-mark
6300 group (list (list (gnus-compress-sequence (sort articles #'<))
6301 'add '(read)))))
6302 ;; Normal, subscribed groups.
6303 (setq range (gnus-compute-read-articles group articles))
6304 (with-current-buffer gnus-group-buffer
6305 (gnus-undo-register
6306 `(progn
6307 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6308 (gnus-info-set-read ',info ',(gnus-info-read info))
6309 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6310 (when ,set-marks
6311 (gnus-request-set-mark
6312 ,group (list (list ',range 'del '(read)))))
6313 (gnus-group-jump-to-group ,group)
6314 (gnus-group-update-group ,group t))))
6315 ;; Add the read articles to the range.
6316 (gnus-info-set-read info range)
6317 (when set-marks
6318 (gnus-request-set-mark group (list (list range 'add '(read)))))
6319 ;; Then we have to re-compute how many unread
6320 ;; articles there are in this group.
6321 (when active
6322 (cond
6323 ((not range)
6324 (setq num (- (1+ (cdr active)) (car active))))
6325 ((not (listp (cdr range)))
6326 (setq num (- (cdr active) (- (1+ (cdr range))
6327 (car range)))))
6329 (while range
6330 (if (numberp (car range))
6331 (setq num (1+ num))
6332 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6333 (setq range (cdr range)))
6334 (setq num (- (cdr active) num))))
6335 ;; Update the number of unread articles.
6336 (setcar entry num)
6337 ;; Update the group buffer.
6338 (unless (gnus-ephemeral-group-p group)
6339 (gnus-group-update-group group t))))))
6341 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6342 (let ((cur nntp-server-buffer)
6343 (dependencies
6344 (or dependencies
6345 (with-current-buffer gnus-summary-buffer
6346 gnus-newsgroup-dependencies)))
6347 headers id end ref number
6348 (mail-parse-charset gnus-newsgroup-charset)
6349 (mail-parse-ignored-charsets
6350 (save-current-buffer (condition-case nil
6351 (set-buffer gnus-summary-buffer)
6352 (error))
6353 gnus-newsgroup-ignored-charsets)))
6354 (with-current-buffer nntp-server-buffer
6355 ;; Translate all TAB characters into SPACE characters.
6356 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6357 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6358 (ietf-drums-unfold-fws)
6359 (gnus-run-hooks 'gnus-parse-headers-hook)
6360 (let ((case-fold-search t)
6361 in-reply-to header p lines chars)
6362 (goto-char (point-min))
6363 ;; Search to the beginning of the next header. Error messages
6364 ;; do not begin with 2 or 3.
6365 (while (re-search-forward "^[23][0-9]+ " nil t)
6366 (setq id nil
6367 ref nil)
6368 ;; This implementation of this function, with nine
6369 ;; search-forwards instead of the one re-search-forward and
6370 ;; a case (which basically was the old function) is actually
6371 ;; about twice as fast, even though it looks messier. You
6372 ;; can't have everything, I guess. Speed and elegance
6373 ;; doesn't always go hand in hand.
6374 (setq
6375 header
6376 (vector
6377 ;; Number.
6378 (prog1
6379 (setq number (read cur))
6380 (end-of-line)
6381 (setq p (point))
6382 (narrow-to-region (point)
6383 (or (and (search-forward "\n.\n" nil t)
6384 (- (point) 2))
6385 (point))))
6386 ;; Subject.
6387 (progn
6388 (goto-char p)
6389 (if (search-forward "\nsubject:" nil t)
6390 (funcall gnus-decode-encoded-word-function
6391 (nnheader-header-value))
6392 "(none)"))
6393 ;; From.
6394 (progn
6395 (goto-char p)
6396 (if (search-forward "\nfrom:" nil t)
6397 (funcall gnus-decode-encoded-address-function
6398 (nnheader-header-value))
6399 "(nobody)"))
6400 ;; Date.
6401 (progn
6402 (goto-char p)
6403 (if (search-forward "\ndate:" nil t)
6404 (nnheader-header-value) ""))
6405 ;; Message-ID.
6406 (progn
6407 (goto-char p)
6408 (setq id (if (re-search-forward
6409 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6410 ;; We do it this way to make sure the Message-ID
6411 ;; is (somewhat) syntactically valid.
6412 (buffer-substring (match-beginning 1)
6413 (match-end 1))
6414 ;; If there was no message-id, we just fake one
6415 ;; to make subsequent routines simpler.
6416 (nnheader-generate-fake-message-id number))))
6417 ;; References.
6418 (progn
6419 (goto-char p)
6420 (if (search-forward "\nreferences:" nil t)
6421 (progn
6422 (setq end (point))
6423 (prog1
6424 (nnheader-header-value)
6425 (setq ref
6426 (buffer-substring
6427 (progn
6428 (end-of-line)
6429 (search-backward ">" end t)
6430 (1+ (point)))
6431 (progn
6432 (search-backward "<" end t)
6433 (point))))))
6434 ;; Get the references from the in-reply-to header if there
6435 ;; were no references and the in-reply-to header looks
6436 ;; promising.
6437 (if (and (search-forward "\nin-reply-to:" nil t)
6438 (setq in-reply-to (nnheader-header-value))
6439 (string-match "<[^>]+>" in-reply-to))
6440 (let (ref2)
6441 (setq ref (substring in-reply-to (match-beginning 0)
6442 (match-end 0)))
6443 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6444 (setq ref2 (substring in-reply-to (match-beginning 0)
6445 (match-end 0)))
6446 (when (> (length ref2) (length ref))
6447 (setq ref ref2)))
6448 ref)
6449 (setq ref nil))))
6450 ;; Chars.
6451 (progn
6452 (goto-char p)
6453 (if (search-forward "\nchars: " nil t)
6454 (if (numberp (setq chars (ignore-errors (read cur))))
6455 chars -1)
6456 -1))
6457 ;; Lines.
6458 (progn
6459 (goto-char p)
6460 (if (search-forward "\nlines: " nil t)
6461 (if (numberp (setq lines (ignore-errors (read cur))))
6462 lines -1)
6463 -1))
6464 ;; Xref.
6465 (progn
6466 (goto-char p)
6467 (and (search-forward "\nxref:" nil t)
6468 (nnheader-header-value)))
6469 ;; Extra.
6470 (when gnus-extra-headers
6471 (let ((extra gnus-extra-headers)
6472 out)
6473 (while extra
6474 (goto-char p)
6475 (when (search-forward
6476 (concat "\n" (symbol-name (car extra)) ":") nil t)
6477 (push (cons (car extra) (nnheader-header-value))
6478 out))
6479 (pop extra))
6480 out))))
6481 (when (equal id ref)
6482 (setq ref nil))
6484 (when gnus-alter-header-function
6485 (funcall gnus-alter-header-function header)
6486 (setq id (mail-header-id header)
6487 ref (gnus-parent-id (mail-header-references header))))
6489 (when (setq header
6490 (gnus-dependencies-add-header
6491 header dependencies force-new))
6492 (push header headers))
6493 (goto-char (point-max))
6494 (widen))
6495 (nreverse headers)))))
6497 ;; Goes through the xover lines and returns a list of vectors
6498 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6499 force-new dependencies
6500 group also-fetch-heads)
6501 "Parse the news overview data in the server buffer.
6502 Return a list of headers that match SEQUENCE (see
6503 `nntp-retrieve-headers')."
6504 ;; Get the Xref when the users reads the articles since most/some
6505 ;; NNTP servers do not include Xrefs when using XOVER.
6506 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6507 (let ((mail-parse-charset gnus-newsgroup-charset)
6508 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6509 (cur nntp-server-buffer)
6510 (dependencies (or dependencies gnus-newsgroup-dependencies))
6511 (allp (cond
6512 ((eq gnus-read-all-available-headers t)
6514 ((and (stringp gnus-read-all-available-headers)
6515 group)
6516 (string-match gnus-read-all-available-headers group))
6518 nil)))
6519 number headers header)
6520 (with-current-buffer nntp-server-buffer
6521 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6522 ;; Allow the user to mangle the headers before parsing them.
6523 (gnus-run-hooks 'gnus-parse-headers-hook)
6524 (goto-char (point-min))
6525 (gnus-parse-without-error
6526 (while (and (or sequence allp)
6527 (not (eobp)))
6528 (setq number (read cur))
6529 (when (not allp)
6530 (while (and sequence
6531 (< (car sequence) number))
6532 (setq sequence (cdr sequence))))
6533 (when (and (or allp
6534 (and sequence
6535 (eq number (car sequence))))
6536 (progn
6537 (setq sequence (cdr sequence))
6538 (setq header (inline
6539 (gnus-nov-parse-line
6540 number dependencies force-new)))))
6541 (push header headers))
6542 (forward-line 1)))
6543 ;; A common bug in inn is that if you have posted an article and
6544 ;; then retrieves the active file, it will answer correctly --
6545 ;; the new article is included. However, a NOV entry for the
6546 ;; article may not have been generated yet, so this may fail.
6547 ;; We work around this problem by retrieving the last few
6548 ;; headers using HEAD.
6549 (if (or (not also-fetch-heads)
6550 (not sequence))
6551 ;; We (probably) got all the headers.
6552 (nreverse headers)
6553 (let ((gnus-nov-is-evil t))
6554 (nconc
6555 (nreverse headers)
6556 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6557 (gnus-get-newsgroup-headers))))))))
6559 (defun gnus-article-get-xrefs ()
6560 "Fill in the Xref value in `gnus-current-headers', if necessary.
6561 This is meant to be called in `gnus-article-internal-prepare-hook'."
6562 (let ((headers (with-current-buffer gnus-summary-buffer
6563 gnus-current-headers)))
6564 (or (not gnus-use-cross-reference)
6565 (not headers)
6566 (and (mail-header-xref headers)
6567 (not (string= (mail-header-xref headers) "")))
6568 (let ((case-fold-search t)
6569 xref)
6570 (save-restriction
6571 (nnheader-narrow-to-headers)
6572 (goto-char (point-min))
6573 (when (or (and (not (eobp))
6574 (eq (downcase (char-after)) ?x)
6575 (looking-at "Xref:"))
6576 (search-forward "\nXref:" nil t))
6577 (goto-char (1+ (match-end 0)))
6578 (setq xref (buffer-substring (point) (point-at-eol)))
6579 (mail-header-set-xref headers xref)))))))
6581 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6582 "Find article ID and insert the summary line for that article.
6583 OLD-HEADER can either be a header or a line number to insert
6584 the subject line on.
6585 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6586 and OLD-HEADER will be used when the summary line is inserted,
6587 too, instead of trying to fetch new headers."
6588 (let* ((line (and (numberp old-header) old-header))
6589 (old-header (and (vectorp old-header) old-header))
6590 (header (cond ((and old-header use-old-header)
6591 old-header)
6592 ((and (numberp id)
6593 (gnus-number-to-header id))
6594 (gnus-number-to-header id))
6596 (gnus-read-header id))))
6597 (number (and (numberp id) id))
6599 (when header
6600 ;; Rebuild the thread that this article is part of and go to the
6601 ;; article we have fetched.
6602 (when (and (not gnus-show-threads)
6603 old-header)
6604 (when (and number
6605 (setq d (gnus-data-find (mail-header-number old-header))))
6606 (goto-char (gnus-data-pos d))
6607 (gnus-data-remove
6608 number
6609 (- (point-at-bol)
6610 (prog1
6611 (1+ (point-at-eol))
6612 (gnus-delete-line))))))
6613 ;; Remove list identifiers from subject.
6614 (let ((gnus-newsgroup-headers (list header)))
6615 (gnus-summary-remove-list-identifiers))
6616 (when old-header
6617 (mail-header-set-number header (mail-header-number old-header)))
6618 (setq gnus-newsgroup-sparse
6619 (delq (setq number (mail-header-number header))
6620 gnus-newsgroup-sparse))
6621 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6622 (push number gnus-newsgroup-limit)
6623 (gnus-rebuild-thread (mail-header-id header) line)
6624 (gnus-summary-goto-subject number nil t))
6625 (when (and (numberp number)
6626 (> number 0))
6627 ;; We have to update the boundaries even if we can't fetch the
6628 ;; article if ID is a number -- so that the next `P' or `N'
6629 ;; command will fetch the previous (or next) article even
6630 ;; if the one we tried to fetch this time has been canceled.
6631 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6632 (setq gnus-newsgroup-end number))
6633 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6634 (setq gnus-newsgroup-begin number))
6635 (setq gnus-newsgroup-unselected
6636 (delq number gnus-newsgroup-unselected)))
6637 ;; Report back a success?
6638 (and header (mail-header-number header))))
6640 ;;; Process/prefix in the summary buffer
6642 (defun gnus-summary-work-articles (n)
6643 "Return a list of articles to be worked upon.
6644 The prefix argument, the list of process marked articles, and the
6645 current article will be taken into consideration."
6646 (with-current-buffer gnus-summary-buffer
6647 (cond
6649 ;; A numerical prefix has been given.
6650 (setq n (prefix-numeric-value n))
6651 (let ((backward (< n 0))
6652 (n (abs (prefix-numeric-value n)))
6653 articles article)
6654 (save-excursion
6655 (while
6656 (and (> n 0)
6657 (push (setq article (gnus-summary-article-number))
6658 articles)
6659 (if backward
6660 (gnus-summary-find-prev nil article)
6661 (gnus-summary-find-next nil article)))
6662 (cl-decf n)))
6663 (nreverse articles)))
6664 ((and (and transient-mark-mode mark-active) (mark))
6665 (message "region active")
6666 ;; Work on the region between point and mark.
6667 (let ((max (max (point) (mark)))
6668 articles article)
6669 (save-excursion
6670 (goto-char (min (point) (mark)))
6671 (while
6672 (and
6673 (push (setq article (gnus-summary-article-number)) articles)
6674 (gnus-summary-find-next nil article)
6675 (< (point) max)))
6676 (nreverse articles))))
6677 (gnus-newsgroup-processable
6678 ;; There are process-marked articles present.
6679 ;; Save current state.
6680 (gnus-summary-save-process-mark)
6681 ;; Return the list.
6682 (reverse gnus-newsgroup-processable))
6684 ;; Just return the current article.
6685 (list (gnus-summary-article-number))))))
6687 (defmacro gnus-summary-iterate (arg &rest forms)
6688 "Iterate over the process/prefixed articles and do FORMS.
6689 ARG is the interactive prefix given to the command. FORMS will be
6690 executed with point over the summary line of the articles."
6691 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6692 `(let ((,articles (gnus-summary-work-articles ,arg)))
6693 (while ,articles
6694 (gnus-summary-goto-subject (car ,articles))
6695 ,@forms
6696 (pop ,articles)))))
6698 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6699 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6701 (defun gnus-summary-save-process-mark ()
6702 "Push the current set of process marked articles on the stack."
6703 (interactive)
6704 (push (copy-sequence gnus-newsgroup-processable)
6705 gnus-newsgroup-process-stack))
6707 (defun gnus-summary-kill-process-mark ()
6708 "Push the current set of process marked articles on the stack and unmark."
6709 (interactive)
6710 (gnus-summary-save-process-mark)
6711 (gnus-summary-unmark-all-processable))
6713 (defun gnus-summary-yank-process-mark ()
6714 "Pop the last process mark state off the stack and restore it."
6715 (interactive)
6716 (unless gnus-newsgroup-process-stack
6717 (error "Empty mark stack"))
6718 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6720 (defun gnus-summary-process-mark-set (set)
6721 "Make SET into the current process marked articles."
6722 (gnus-summary-unmark-all-processable)
6723 (mapc 'gnus-summary-set-process-mark set))
6725 ;;; Searching and stuff
6727 (defun gnus-summary-search-group (&optional backward use-level)
6728 "Search for next unread newsgroup.
6729 If optional argument BACKWARD is non-nil, search backward instead."
6730 (with-current-buffer gnus-group-buffer
6731 (when (gnus-group-search-forward
6732 backward nil (if use-level (gnus-group-group-level) nil))
6733 (gnus-group-group-name))))
6735 (defun gnus-summary-best-group (&optional exclude-group)
6736 "Find the name of the best unread group.
6737 If EXCLUDE-GROUP, do not go to this group."
6738 (with-current-buffer gnus-group-buffer
6739 (save-excursion
6740 (gnus-group-best-unread-group exclude-group))))
6742 (defun gnus-summary-find-next (&optional unread article backward)
6743 (if backward
6744 (gnus-summary-find-prev unread article)
6745 (let* ((dummy (gnus-summary-article-intangible-p))
6746 (article (or article (gnus-summary-article-number)))
6747 (data (gnus-data-find-list article))
6748 result)
6749 (when (and (not dummy)
6750 (or (not gnus-summary-check-current)
6751 (not unread)
6752 (not (gnus-data-unread-p (car data)))))
6753 (setq data (cdr data)))
6754 (when (setq result
6755 (if unread
6756 (progn
6757 (while data
6758 (unless (memq (gnus-data-number (car data))
6759 (cond
6760 ((eq gnus-auto-goto-ignores
6761 'always-undownloaded)
6762 gnus-newsgroup-undownloaded)
6763 (gnus-plugged
6764 nil)
6765 ((eq gnus-auto-goto-ignores
6766 'unfetched)
6767 gnus-newsgroup-unfetched)
6768 ((eq gnus-auto-goto-ignores
6769 'undownloaded)
6770 gnus-newsgroup-undownloaded)))
6771 (when (gnus-data-unread-p (car data))
6772 (setq result (car data)
6773 data nil)))
6774 (setq data (cdr data)))
6775 result)
6776 (car data)))
6777 (goto-char (gnus-data-pos result))
6778 (gnus-data-number result)))))
6780 (defun gnus-summary-find-prev (&optional unread article)
6781 (let* ((eobp (eobp))
6782 (article (or article (gnus-summary-article-number)))
6783 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6784 result)
6785 (when (and (not eobp)
6786 (or (not gnus-summary-check-current)
6787 (not unread)
6788 (not (gnus-data-unread-p (car data)))))
6789 (setq data (cdr data)))
6790 (when (setq result
6791 (if unread
6792 (progn
6793 (while data
6794 (unless (memq (gnus-data-number (car data))
6795 (cond
6796 ((eq gnus-auto-goto-ignores
6797 'always-undownloaded)
6798 gnus-newsgroup-undownloaded)
6799 (gnus-plugged
6800 nil)
6801 ((eq gnus-auto-goto-ignores
6802 'unfetched)
6803 gnus-newsgroup-unfetched)
6804 ((eq gnus-auto-goto-ignores
6805 'undownloaded)
6806 gnus-newsgroup-undownloaded)))
6807 (when (gnus-data-unread-p (car data))
6808 (setq result (car data)
6809 data nil)))
6810 (setq data (cdr data)))
6811 result)
6812 (car data)))
6813 (goto-char (gnus-data-pos result))
6814 (gnus-data-number result))))
6816 (defun gnus-summary-find-subject (subject &optional unread backward article)
6817 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6818 (article (or article (gnus-summary-article-number)))
6819 (articles (gnus-data-list backward))
6820 (arts (gnus-data-find-list article articles))
6821 result)
6822 (when (or (not gnus-summary-check-current)
6823 (not unread)
6824 (not (gnus-data-unread-p (car arts))))
6825 (setq arts (cdr arts)))
6826 (while arts
6827 (and (or (not unread)
6828 (gnus-data-unread-p (car arts)))
6829 (vectorp (gnus-data-header (car arts)))
6830 (gnus-subject-equal
6831 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6832 (setq result (car arts)
6833 arts nil))
6834 (setq arts (cdr arts)))
6835 (and result
6836 (goto-char (gnus-data-pos result))
6837 (gnus-data-number result))))
6839 (defun gnus-summary-search-forward (&optional unread subject backward)
6840 "Search forward for an article.
6841 If UNREAD, look for unread articles. If SUBJECT, look for
6842 articles with that subject. If BACKWARD, search backward instead."
6843 (cond (subject (gnus-summary-find-subject subject unread backward))
6844 (backward (gnus-summary-find-prev unread))
6845 (t (gnus-summary-find-next unread))))
6847 (defun gnus-recenter (&optional n)
6848 "Center point in window and redisplay frame.
6849 Also do horizontal recentering."
6850 (interactive "P")
6851 (when (and gnus-auto-center-summary
6852 (not (eq gnus-auto-center-summary 'vertical)))
6853 (gnus-horizontal-recenter))
6854 (recenter-top-bottom n))
6856 (put 'gnus-recenter 'isearch-scroll t)
6858 (defun gnus-forward-line-ignore-invisible (n)
6859 "Move N lines forward (backward if N is negative).
6860 Like forward-line, but skip over (and don't count) invisible lines."
6861 (let (done)
6862 (while (and (> n 0) (not done))
6863 ;; If the following character is currently invisible,
6864 ;; skip all characters with that same `invisible' property value.
6865 (while (invisible-p (point))
6866 (goto-char (next-char-property-change (point))))
6867 (forward-line 1)
6868 (if (eobp)
6869 (setq done t)
6870 (setq n (1- n))))
6871 (while (and (< n 0) (not done))
6872 (forward-line -1)
6873 (if (bobp) (setq done t)
6874 (setq n (1+ n))
6875 (while (and (not (bobp)) (invisible-p (1- (point))))
6876 (goto-char (previous-char-property-change (point))))))))
6878 (defun gnus-summary-recenter ()
6879 "Center point in the summary window.
6880 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6881 displayed, no centering will be performed."
6882 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6883 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6884 (interactive)
6885 ;; The user has to want it.
6886 (when gnus-auto-center-summary
6887 (let* ((top (cond ((< (window-height) 4) 0)
6888 ((< (window-height) 7) 1)
6889 (t (if (numberp gnus-auto-center-summary)
6890 gnus-auto-center-summary
6891 (/ (1- (window-height)) 2)))))
6892 (height (1- (window-height)))
6893 (bottom (save-excursion
6894 (goto-char (point-max))
6895 (gnus-forward-line-ignore-invisible (- height))
6896 (point)))
6897 (window (get-buffer-window (current-buffer))))
6898 (when (get-buffer-window gnus-article-buffer)
6899 ;; Only do recentering when the article buffer is displayed,
6900 ;; Set the window start to either `bottom', which is the biggest
6901 ;; possible valid number, or the second line from the top,
6902 ;; whichever is the least.
6903 (let ((top-pos (save-excursion
6904 (gnus-forward-line-ignore-invisible (- top))
6905 (point))))
6906 (if (> bottom top-pos)
6907 ;; Keep the second line from the top visible
6908 (set-window-start window top-pos)
6909 ;; Try to keep the bottom line visible; if it's partially
6910 ;; obscured, either scroll one more line to make it fully
6911 ;; visible, or revert to using TOP-POS.
6912 (save-excursion
6913 (goto-char (point-max))
6914 (gnus-forward-line-ignore-invisible -1)
6915 (let ((last-line-start (point)))
6916 (goto-char bottom)
6917 (set-window-start window (point) t)
6918 (when (not (pos-visible-in-window-p last-line-start window))
6919 (gnus-forward-line-ignore-invisible 1)
6920 (set-window-start window (min (point) top-pos) t)))))))
6921 ;; Do horizontal recentering while we're at it.
6922 (when (and (get-buffer-window (current-buffer) t)
6923 (not (eq gnus-auto-center-summary 'vertical)))
6924 (let ((selected (selected-window)))
6925 (select-window (get-buffer-window (current-buffer) t))
6926 (gnus-summary-position-point)
6927 (gnus-horizontal-recenter)
6928 (select-window selected))))))
6930 (defun gnus-summary-jump-to-group (newsgroup)
6931 "Move point to NEWSGROUP in group mode buffer."
6932 ;; Keep update point of group mode buffer if visible.
6933 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6934 (save-window-excursion
6935 ;; Take care of tree window mode.
6936 (when (get-buffer-window gnus-group-buffer)
6937 (pop-to-buffer gnus-group-buffer))
6938 (gnus-group-jump-to-group newsgroup))
6939 (save-excursion
6940 ;; Take care of tree window mode.
6941 (if (get-buffer-window gnus-group-buffer 0)
6942 (pop-to-buffer gnus-group-buffer t)
6943 (set-buffer gnus-group-buffer))
6944 (gnus-group-jump-to-group newsgroup))))
6946 ;; This function returns a list of article numbers based on the
6947 ;; difference between the ranges of read articles in this group and
6948 ;; the range of active articles.
6949 (defun gnus-list-of-unread-articles (group)
6950 (let* ((read (gnus-info-read (gnus-get-info group)))
6951 (active (or (gnus-active group) (gnus-activate-group group)))
6952 (last (or (cdr active)
6953 (error "Group %s couldn't be activated " group)))
6954 (bottom (if gnus-newsgroup-maximum-articles
6955 (max (car active)
6956 (- last gnus-newsgroup-maximum-articles -1))
6957 (car active)))
6958 first nlast unread)
6959 ;; If none are read, then all are unread.
6960 (if (not read)
6961 (setq first bottom)
6962 ;; If the range of read articles is a single range, then the
6963 ;; first unread article is the article after the last read
6964 ;; article. Sounds logical, doesn't it?
6965 (if (and (not (listp (cdr read)))
6966 (or (< (car read) bottom)
6967 (progn (setq read (list read))
6968 nil)))
6969 (setq first (max bottom (1+ (cdr read))))
6970 ;; `read' is a list of ranges.
6971 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6972 (caar read)))
6974 (setq first bottom))
6975 (while read
6976 (when first
6977 (while (< first nlast)
6978 (setq unread (cons first unread)
6979 first (1+ first))))
6980 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6981 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6982 (setq read (cdr read)))))
6983 ;; And add the last unread articles.
6984 (while (<= first last)
6985 (setq unread (cons first unread)
6986 first (1+ first)))
6987 ;; Return the list of unread articles.
6988 (delq 0 (nreverse unread))))
6990 (defun gnus-list-of-read-articles (group)
6991 "Return a list of unread, unticked and non-dormant articles."
6992 (let* ((info (gnus-get-info group))
6993 (marked (gnus-info-marks info))
6994 (active (gnus-active group)))
6995 (and info active
6996 (gnus-list-range-difference
6997 (gnus-list-range-difference
6998 (gnus-sorted-complement
6999 (gnus-uncompress-range
7000 (if gnus-newsgroup-maximum-articles
7001 (cons (max (car active)
7002 (- (cdr active)
7003 gnus-newsgroup-maximum-articles
7004 -1))
7005 (cdr active))
7006 active))
7007 (gnus-list-of-unread-articles group))
7008 (cdr (assq 'dormant marked)))
7009 (cdr (assq 'tick marked))))))
7011 ;; This function returns a sequence of article numbers based on the
7012 ;; difference between the ranges of read articles in this group and
7013 ;; the range of active articles.
7014 (defun gnus-sequence-of-unread-articles (group)
7015 (let* ((read (gnus-info-read (gnus-get-info group)))
7016 (active (or (gnus-active group) (gnus-activate-group group)))
7017 (last (cdr active))
7018 (bottom (if gnus-newsgroup-maximum-articles
7019 (max (car active)
7020 (- last gnus-newsgroup-maximum-articles -1))
7021 (car active)))
7022 first nlast unread)
7023 ;; If none are read, then all are unread.
7024 (if (not read)
7025 (setq first bottom)
7026 ;; If the range of read articles is a single range, then the
7027 ;; first unread article is the article after the last read
7028 ;; article. Sounds logical, doesn't it?
7029 (if (and (not (listp (cdr read)))
7030 (or (< (car read) bottom)
7031 (progn (setq read (list read))
7032 nil)))
7033 (setq first (max bottom (1+ (cdr read))))
7034 ;; `read' is a list of ranges.
7035 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7036 (caar read)))
7038 (setq first bottom))
7039 (while read
7040 (when first
7041 (push (cons first nlast) unread))
7042 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7043 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7044 (setq read (cdr read)))))
7045 ;; And add the last unread articles.
7046 (cond ((not (and first last))
7047 nil)
7048 ((< first last)
7049 (push (cons first last) unread))
7050 ((= first last)
7051 (push first unread)))
7052 ;; Return the sequence of unread articles.
7053 (delq 0 (nreverse unread))))
7055 ;; Various summary commands
7057 (defun gnus-summary-select-article-buffer ()
7058 "Reconfigure windows to show the article buffer.
7059 If `gnus-widen-article-window' is set, show only the article
7060 buffer."
7061 (interactive)
7062 (if (not (gnus-buffer-live-p gnus-article-buffer))
7063 (error "There is no article buffer for this summary buffer")
7064 (or (get-buffer-window gnus-article-buffer)
7065 (eq gnus-current-article (gnus-summary-article-number))
7066 (gnus-summary-show-article))
7067 (let ((point (with-current-buffer gnus-article-buffer
7068 (point))))
7069 (gnus-configure-windows
7070 (if gnus-widen-article-window
7071 'only-article
7072 'article)
7074 (select-window (get-buffer-window gnus-article-buffer))
7075 ;; If we've just selected the message, place point at the start of
7076 ;; the body because that's probably where we want to be.
7077 (if (not (= point (point-min)))
7078 (goto-char point)
7079 (article-goto-body)
7080 (forward-char -1)))))
7082 (defun gnus-summary-universal-argument (arg)
7083 "Perform any operation on all articles that are process/prefixed."
7084 (interactive "P")
7085 (let ((articles (gnus-summary-work-articles arg))
7086 func article)
7087 (if (eq
7088 (setq
7089 func
7090 (key-binding
7091 (read-key-sequence
7092 (substitute-command-keys
7093 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7094 'undefined)
7095 (gnus-error 1 "Undefined key")
7096 (save-excursion
7097 (while articles
7098 (gnus-summary-goto-subject (setq article (pop articles)))
7099 (let (gnus-newsgroup-processable)
7100 (command-execute func))
7101 (gnus-summary-remove-process-mark article)))))
7102 (gnus-summary-position-point))
7104 (define-obsolete-function-alias
7105 'gnus-summary-toggle-truncation 'toggle-truncate-lines "26.1")
7107 (defun gnus-summary-find-for-reselect ()
7108 "Return the number of an article to stay on across a reselect.
7109 The current article is considered, then following articles, then previous
7110 articles. An article is sought which is not canceled and isn't a temporary
7111 insertion from another group. If there's no such then return a dummy 0."
7112 (let (found)
7113 (dolist (rev '(nil t))
7114 (unless found ; don't demand the reverse list if we don't need it
7115 (let ((data (gnus-data-find-list
7116 (gnus-summary-article-number) (gnus-data-list rev))))
7117 (while (and data (not found))
7118 (if (and (< 0 (gnus-data-number (car data)))
7119 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7120 (setq found (gnus-data-number (car data))))
7121 (setq data (cdr data))))))
7122 (or found 0)))
7124 (defun gnus-summary-reselect-current-group (&optional all rescan)
7125 "Exit and then reselect the current newsgroup.
7126 The prefix argument ALL means to select all articles."
7127 (interactive "P")
7128 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7129 (error "Ephemeral groups can't be reselected"))
7130 (let ((current-subject (gnus-summary-find-for-reselect))
7131 (group gnus-newsgroup-name))
7132 (setq gnus-newsgroup-begin nil)
7133 (gnus-summary-exit nil 'leave-hidden)
7134 ;; We have to adjust the point of group mode buffer because
7135 ;; point was moved to the next unread newsgroup by exiting.
7136 (gnus-summary-jump-to-group group)
7137 (when rescan
7138 (save-excursion
7139 (gnus-group-get-new-news-this-group 1)))
7140 (gnus-group-read-group all t)
7141 (gnus-summary-goto-subject current-subject nil t)))
7143 (defun gnus-summary-rescan-group (&optional all)
7144 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7145 (interactive "P")
7146 (let ((config gnus-current-window-configuration))
7147 (gnus-summary-reselect-current-group all t)
7148 (gnus-configure-windows config)
7149 (when (eq config 'article)
7150 (gnus-summary-select-article))))
7152 (defun gnus-summary-update-info (&optional non-destructive)
7153 (save-excursion
7154 (let ((group gnus-newsgroup-name))
7155 (when group
7156 (when gnus-newsgroup-kill-headers
7157 (setq gnus-newsgroup-killed
7158 (gnus-compress-sequence
7159 (gnus-sorted-union
7160 (gnus-list-range-intersection
7161 gnus-newsgroup-unselected gnus-newsgroup-killed)
7162 gnus-newsgroup-unreads)
7163 t)))
7164 (unless (listp (cdr gnus-newsgroup-killed))
7165 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7166 (let ((headers gnus-newsgroup-headers)
7167 (ephemeral-p (gnus-ephemeral-group-p group))
7168 info)
7169 (unless ephemeral-p
7170 (setq info (copy-sequence (gnus-get-info group))
7171 info (delq (gnus-info-params info) info)))
7172 ;; Set the new ranges of read articles.
7173 (with-current-buffer gnus-group-buffer
7174 (gnus-undo-force-boundary))
7175 (gnus-update-read-articles
7176 group (gnus-sorted-union
7177 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7178 ;; Set the current article marks.
7179 (let ((gnus-newsgroup-scored
7180 (if (and (not gnus-save-score)
7181 (not non-destructive))
7183 gnus-newsgroup-scored)))
7184 (save-excursion
7185 (gnus-update-marks)))
7186 ;; Do the cross-ref thing.
7187 (when gnus-use-cross-reference
7188 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7189 ;; Do not switch windows but change the buffer to work.
7190 (set-buffer gnus-group-buffer)
7191 (unless ephemeral-p
7192 (gnus-group-update-group
7193 group nil
7194 (equal info
7195 (setq info (copy-sequence (gnus-get-info group))
7196 info (delq (gnus-info-params info) info))))))))))
7198 (defun gnus-summary-save-newsrc (&optional force)
7199 "Save the current number of read/marked articles in the dribble buffer.
7200 The dribble buffer will then be saved.
7201 If FORCE (the prefix), also save the .newsrc file(s)."
7202 (interactive "P")
7203 (gnus-summary-update-info t)
7204 (if force
7205 (gnus-save-newsrc-file)
7206 (gnus-dribble-save)))
7208 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7209 (declare-function gnus-article-stop-animations "gnus-art" ())
7211 (defun gnus-summary-exit (&optional temporary leave-hidden)
7212 "Exit reading current newsgroup, and then return to group selection mode.
7213 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7214 (interactive)
7215 (gnus-set-global-variables)
7216 (when (gnus-buffer-live-p gnus-article-buffer)
7217 (with-current-buffer gnus-article-buffer
7218 (mm-destroy-parts gnus-article-mime-handles)
7219 ;; Set it to nil for safety reason.
7220 (setq gnus-article-mime-handle-alist nil)
7221 (setq gnus-article-mime-handles nil)))
7222 (gnus-kill-save-kill-buffer)
7223 (gnus-async-halt-prefetch)
7224 (let* ((group gnus-newsgroup-name)
7225 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7226 (gnus-group-is-exiting-p t)
7227 (article-buffer gnus-article-buffer)
7228 (original-article-buffer gnus-original-article-buffer)
7229 (mode major-mode)
7230 (group-point nil)
7231 (buf (current-buffer))
7232 ;; `gnus-single-article-buffer' is nil buffer-locally in
7233 ;; ephemeral group of which summary buffer will be killed,
7234 ;; but the global value may be non-nil.
7235 (single-article-buffer gnus-single-article-buffer))
7236 (unless quit-config
7237 ;; Do adaptive scoring, and possibly save score files.
7238 (when gnus-newsgroup-adaptive
7239 (gnus-score-adaptive))
7240 (when gnus-use-scoring
7241 (gnus-score-save)))
7242 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7243 (when gnus-use-cache
7244 (gnus-cache-possibly-remove-articles)
7245 (gnus-cache-save-buffers))
7246 (gnus-async-prefetch-remove-group group)
7247 (when gnus-suppress-duplicates
7248 (gnus-dup-enter-articles))
7249 (when gnus-use-trees
7250 (gnus-tree-close))
7251 (when gnus-use-cache
7252 (gnus-cache-write-active))
7253 ;; Remove entries for this group.
7254 (nnmail-purge-split-history (gnus-group-real-name group))
7255 ;; Make all changes in this group permanent.
7256 (unless quit-config
7257 (gnus-run-hooks 'gnus-exit-group-hook)
7258 (gnus-summary-update-info))
7259 (gnus-close-group group)
7260 ;; Make sure where we were, and go to next newsgroup.
7261 (when (buffer-live-p (get-buffer gnus-group-buffer))
7262 (set-buffer gnus-group-buffer))
7263 (unless quit-config
7264 (gnus-group-jump-to-group group))
7265 (gnus-run-hooks 'gnus-summary-exit-hook)
7266 (unless (or quit-config
7267 (not gnus-summary-next-group-on-exit)
7268 ;; If this group has disappeared from the summary
7269 ;; buffer, don't skip forwards.
7270 (not (string= group (gnus-group-group-name))))
7271 (gnus-group-next-unread-group 1))
7272 (setq group-point (point))
7273 (gnus-article-stop-animations)
7274 (if temporary
7275 nil ;Nothing to do.
7276 (set-buffer buf)
7277 (if (not gnus-kill-summary-on-exit)
7278 (progn
7279 (gnus-deaden-summary)
7280 (setq mode nil))
7281 (when (get-buffer gnus-article-buffer)
7282 (bury-buffer gnus-article-buffer))
7283 ;; Return to group mode buffer.
7284 (when (eq mode 'gnus-summary-mode)
7285 (gnus-kill-buffer buf)))
7287 (setq gnus-current-select-method gnus-select-method)
7288 (when (gnus-buffer-live-p gnus-group-buffer)
7289 (set-buffer gnus-group-buffer))
7290 (if quit-config
7291 (gnus-handle-ephemeral-exit quit-config)
7292 (goto-char group-point)
7293 (unless leave-hidden
7294 (gnus-configure-windows 'group 'force))
7295 ;; If gnus-group-buffer is already displayed, make sure we also move
7296 ;; the cursor in the window that displays it.
7297 (let ((win (get-buffer-window (current-buffer) 0)))
7298 (goto-char group-point)
7299 (if win (set-window-point win (point)))))
7301 ;; If we have several article buffers, we kill them at exit.
7302 (unless single-article-buffer
7303 (when (gnus-buffer-live-p article-buffer)
7304 (with-current-buffer article-buffer
7305 ;; Don't kill sticky article buffers
7306 (unless (eq major-mode 'gnus-sticky-article-mode)
7307 (gnus-kill-buffer article-buffer)
7308 (setq gnus-article-current nil))))
7309 (gnus-kill-buffer original-article-buffer))
7311 ;; Clear the current group name.
7312 (unless quit-config
7313 (setq gnus-newsgroup-name nil)))))
7315 (declare-function gnus-stop-downloads "gnus-art" ())
7317 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7318 (defun gnus-summary-exit-no-update (&optional no-questions)
7319 "Quit reading current newsgroup without updating read article info."
7320 (interactive)
7321 (let* ((group gnus-newsgroup-name)
7322 (gnus-group-is-exiting-p t)
7323 (gnus-group-is-exiting-without-update-p t)
7324 (quit-config (gnus-group-quit-config group)))
7325 (when (or no-questions
7326 (gnus-ephemeral-group-p group)
7327 gnus-expert-user
7328 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7329 (gnus-async-halt-prefetch)
7330 (run-hooks 'gnus-summary-prepare-exit-hook)
7331 (when (gnus-buffer-live-p gnus-article-buffer)
7332 (with-current-buffer gnus-article-buffer
7333 (gnus-article-stop-animations)
7334 (gnus-stop-downloads)
7335 (mm-destroy-parts gnus-article-mime-handles)
7336 ;; Set it to nil for safety reason.
7337 (setq gnus-article-mime-handle-alist nil)
7338 (setq gnus-article-mime-handles nil)))
7339 ;; If we have several article buffers, we kill them at exit.
7340 (unless gnus-single-article-buffer
7341 (gnus-kill-buffer gnus-article-buffer)
7342 (gnus-kill-buffer gnus-original-article-buffer)
7343 (setq gnus-article-current nil))
7344 ;; Return to the group buffer.
7345 (if (not gnus-kill-summary-on-exit)
7346 (progn
7347 (gnus-deaden-summary)
7348 (gnus-configure-windows 'group 'force))
7349 (gnus-configure-windows 'group 'force)
7350 (gnus-close-group group)
7351 (gnus-kill-buffer gnus-summary-buffer))
7352 (unless gnus-single-article-buffer
7353 (setq gnus-article-current nil))
7354 (when gnus-use-trees
7355 (gnus-tree-close))
7356 (gnus-async-prefetch-remove-group group)
7357 (when (get-buffer gnus-article-buffer)
7358 (bury-buffer gnus-article-buffer))
7359 ;; Clear the current group name.
7360 (setq gnus-newsgroup-name nil)
7361 (unless (gnus-ephemeral-group-p group)
7362 (gnus-group-update-group group nil t))
7363 (when (gnus-group-goto-group group)
7364 (gnus-group-next-unread-group 1))
7365 (gnus-article-stop-animations)
7366 (when quit-config
7367 (gnus-handle-ephemeral-exit quit-config)))))
7369 (defun gnus-handle-ephemeral-exit (quit-config)
7370 "Handle movement when leaving an ephemeral group.
7371 The state which existed when entering the ephemeral is reset."
7372 (if (not (buffer-live-p (car quit-config)))
7373 (when (gnus-buffer-live-p gnus-group-buffer)
7374 (gnus-configure-windows 'group 'force))
7375 (set-buffer (car quit-config))
7376 (unless (eq (cdr quit-config) 'group)
7377 (setq gnus-current-select-method
7378 (gnus-find-method-for-group gnus-newsgroup-name)))
7379 (cond ((derived-mode-p 'gnus-summary-mode)
7380 (gnus-set-global-variables))
7381 ((derived-mode-p 'gnus-article-mode)
7382 (save-current-buffer
7383 ;; The `gnus-summary-buffer' variable may point
7384 ;; to the old summary buffer when using a single
7385 ;; article buffer.
7386 (unless (gnus-buffer-live-p gnus-summary-buffer)
7387 (set-buffer gnus-group-buffer))
7388 (set-buffer gnus-summary-buffer)
7389 (gnus-set-global-variables))))
7390 (if (or (eq (cdr quit-config) 'article)
7391 (eq (cdr quit-config) 'pick))
7392 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7393 (gnus-configure-windows 'pick 'force)
7394 (gnus-configure-windows (cdr quit-config) 'force))
7395 (gnus-configure-windows (cdr quit-config) 'force))
7396 (when (derived-mode-p 'gnus-summary-mode)
7397 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7398 next-unread-noselect))
7399 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7400 'next-noselect)
7401 (gnus-summary-next-subject 1 nil t))
7402 ((eq gnus-auto-select-on-ephemeral-exit
7403 'next-unread-noselect)
7404 (gnus-summary-next-subject 1 t t))))
7405 ;; Hide the article buffer which displays the article different
7406 ;; from the one that the cursor points to in the summary buffer.
7407 (gnus-configure-windows 'summary 'force))
7408 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7409 (gnus-summary-next-subject 1))
7410 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7411 (gnus-summary-next-subject 1 t))))
7412 (gnus-summary-recenter)
7413 (gnus-summary-position-point))))
7415 ;;; Dead summaries.
7417 (defvar gnus-dead-summary-mode-map
7418 (let ((map (make-keymap)))
7419 (suppress-keymap map)
7420 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7421 (dolist (key '("\C-d" "\r" "\177" [delete]))
7422 (define-key map key 'gnus-summary-wake-up-the-dead))
7423 (dolist (key '("q" "Q"))
7424 (define-key map key 'bury-buffer))
7425 map))
7427 (define-minor-mode gnus-dead-summary-mode
7428 "Minor mode for Gnus summary buffers."
7429 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7430 (unless (derived-mode-p 'gnus-summary-mode)
7431 (setq gnus-dead-summary-mode nil)))
7433 (defun gnus-deaden-summary ()
7434 "Make the current summary buffer into a dead summary buffer."
7435 ;; Kill any previous dead summary buffer.
7436 (when (and gnus-dead-summary
7437 (buffer-name gnus-dead-summary))
7438 (with-current-buffer gnus-dead-summary
7439 (when gnus-dead-summary-mode
7440 (kill-buffer (current-buffer)))))
7441 ;; Make this the current dead summary.
7442 (setq gnus-dead-summary (current-buffer))
7443 (gnus-dead-summary-mode 1)
7444 (let ((name (buffer-name)))
7445 (when (string-match "Summary" name)
7446 (rename-buffer
7447 (concat (substring name 0 (match-beginning 0)) "Dead "
7448 (substring name (match-beginning 0)))
7450 (bury-buffer))))
7452 (defun gnus-kill-or-deaden-summary (buffer)
7453 "Kill or deaden the summary BUFFER."
7454 (save-excursion
7455 (when (and (buffer-name buffer)
7456 (not gnus-single-article-buffer))
7457 (with-current-buffer buffer
7458 (gnus-kill-buffer gnus-article-buffer)
7459 (gnus-kill-buffer gnus-original-article-buffer)))
7460 (cond
7461 ;; Kill the buffer.
7462 (gnus-kill-summary-on-exit
7463 (when (and gnus-use-trees
7464 (gnus-buffer-exists-p buffer))
7465 (with-current-buffer buffer
7466 (gnus-tree-close)))
7467 (gnus-kill-buffer buffer))
7468 ;; Deaden the buffer.
7469 ((gnus-buffer-exists-p buffer)
7470 (with-current-buffer buffer
7471 (gnus-deaden-summary))))))
7473 (defun gnus-summary-wake-up-the-dead (&rest args)
7474 "Wake up the dead summary buffer."
7475 (interactive)
7476 (gnus-dead-summary-mode -1)
7477 (let ((name (buffer-name)))
7478 (when (string-match "Dead " name)
7479 (rename-buffer
7480 (concat (substring name 0 (match-beginning 0))
7481 (substring name (match-end 0)))
7482 t)))
7483 (gnus-message 3 "This dead summary is now alive again"))
7485 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7486 (defun gnus-summary-describe-group (&optional force)
7487 "Describe the current newsgroup."
7488 (interactive "P")
7489 (gnus-group-describe-group force gnus-newsgroup-name))
7491 (defun gnus-summary-describe-briefly ()
7492 "Describe summary mode commands briefly."
7493 (interactive)
7494 (gnus-message 6 "%s" (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")))
7496 ;; Walking around group mode buffer from summary mode.
7498 (defun gnus-summary-next-group (&optional no-article target-group backward)
7499 "Exit current newsgroup and then select next unread newsgroup.
7500 If prefix argument NO-ARTICLE is non-nil, no article is selected
7501 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7502 previous group instead."
7503 (interactive "P")
7504 ;; Stop pre-fetching.
7505 (gnus-async-halt-prefetch)
7506 (let ((current-group gnus-newsgroup-name)
7507 (current-buffer (current-buffer))
7508 entered)
7509 ;; First we semi-exit this group to update Xrefs and all variables.
7510 ;; We can't do a real exit, because the window conf must remain
7511 ;; the same in case the user is prompted for info, and we don't
7512 ;; want the window conf to change before that...
7513 (gnus-summary-exit t)
7514 (while (not entered)
7515 ;; Then we find what group we are supposed to enter.
7516 (set-buffer gnus-group-buffer)
7517 (gnus-group-jump-to-group current-group)
7518 (setq target-group
7519 (or target-group
7520 (if (eq gnus-keep-same-level 'best)
7521 (gnus-summary-best-group gnus-newsgroup-name)
7522 (gnus-summary-search-group backward gnus-keep-same-level))))
7523 (if (not target-group)
7524 ;; There are no further groups, so we return to the group
7525 ;; buffer.
7526 (progn
7527 (gnus-message 5 "Returning to the group buffer")
7528 (setq entered t)
7529 (when (gnus-buffer-live-p current-buffer)
7530 (set-buffer current-buffer)
7531 (gnus-summary-exit))
7532 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7533 ;; We try to enter the target group.
7534 (gnus-group-jump-to-group target-group)
7535 (let ((unreads (gnus-group-group-unread)))
7536 (if (and (or (eq t unreads)
7537 (and unreads (not (zerop unreads))))
7538 (gnus-summary-read-group
7539 target-group nil no-article
7540 (and (buffer-name current-buffer) current-buffer)
7541 nil backward))
7542 (setq entered t)
7543 (setq current-group target-group
7544 target-group nil)))))))
7546 (defun gnus-summary-prev-group (&optional no-article)
7547 "Exit current newsgroup and then select previous unread newsgroup.
7548 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7549 (interactive "P")
7550 (gnus-summary-next-group no-article nil t))
7552 ;; Walking around summary lines.
7554 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7555 "Go to the first subject satisfying any non-nil constraint.
7556 If UNREAD is non-nil, the article should be unread.
7557 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7558 If UNSEEN is non-nil, the article should be unseen as well as unread.
7559 Returns the article selected or nil if there are no matching articles."
7560 (interactive "P")
7561 (cond
7562 ;; Empty summary.
7563 ((null gnus-newsgroup-data)
7564 (gnus-message 3 "No articles in the group")
7565 nil)
7566 ;; Pick the first article.
7567 ((not (or unread undownloaded unseen))
7568 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7569 (gnus-data-number (car gnus-newsgroup-data)))
7570 ;; Find the first unread article.
7572 (let ((data gnus-newsgroup-data))
7573 (while (and data
7574 (let ((num (gnus-data-number (car data))))
7575 (or (memq num gnus-newsgroup-unfetched)
7576 (not (or (and unread
7577 (memq num gnus-newsgroup-unreads))
7578 (and undownloaded
7579 (memq num gnus-newsgroup-undownloaded))
7580 (and unseen
7581 (memq num gnus-newsgroup-unseen)
7582 (memq num gnus-newsgroup-unreads)))))))
7583 (setq data (cdr data)))
7584 (prog1
7585 (if data
7586 (progn
7587 (goto-char (gnus-data-pos (car data)))
7588 (gnus-data-number (car data)))
7589 (gnus-message 3 "No more%s articles"
7590 (let* ((r (when unread " unread"))
7591 (d (when undownloaded " undownloaded"))
7592 (s (when unseen " unseen"))
7593 (l (delq nil (list r d s))))
7594 (cond ((= 3 (length l))
7595 (concat r "," d ", or" s))
7596 ((= 2 (length l))
7597 (concat (car l) ", or" (cadr l)))
7598 ((= 1 (length l))
7599 (car l))
7601 ""))))
7604 (gnus-summary-position-point))))))
7606 (defun gnus-summary-next-subject (n &optional unread dont-display)
7607 "Go to next N'th summary line.
7608 If N is negative, go to the previous N'th subject line.
7609 If UNREAD is non-nil, only unread articles are selected.
7610 The difference between N and the actual number of steps taken is
7611 returned."
7612 (interactive "p")
7613 (let ((backward (< n 0))
7614 (n (abs n)))
7615 (while (and (> n 0)
7616 (if backward
7617 (gnus-summary-find-prev unread)
7618 (gnus-summary-find-next unread)))
7619 (unless (zerop (setq n (1- n)))
7620 (gnus-summary-show-thread)))
7621 (when (/= 0 n)
7622 (gnus-message 7 "No more%s articles"
7623 (if unread " unread" "")))
7624 (unless dont-display
7625 (gnus-summary-recenter)
7626 (gnus-summary-position-point))
7629 (defun gnus-summary-next-unread-subject (n)
7630 "Go to next N'th unread summary line."
7631 (interactive "p")
7632 (gnus-summary-next-subject n t))
7634 (defun gnus-summary-prev-subject (n &optional unread)
7635 "Go to previous N'th summary line.
7636 If optional argument UNREAD is non-nil, only unread article is selected."
7637 (interactive "p")
7638 (gnus-summary-next-subject (- n) unread))
7640 (defun gnus-summary-prev-unread-subject (n)
7641 "Go to previous N'th unread summary line."
7642 (interactive "p")
7643 (gnus-summary-next-subject (- n) t))
7645 (defun gnus-summary-goto-subjects (articles)
7646 "Insert the subject header for ARTICLES in the current buffer."
7647 (save-excursion
7648 (dolist (article articles)
7649 (gnus-summary-goto-subject article t)))
7650 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7651 (gnus-summary-position-point))
7653 (defun gnus-summary-goto-subject (article &optional force silent)
7654 "Go to the subject line of ARTICLE.
7655 If FORCE, also allow jumping to articles not currently shown."
7656 (interactive "nArticle number: ")
7657 (unless (numberp article)
7658 (error "Article %s is not a number" article))
7659 (let ((b (point))
7660 (data (gnus-data-find article)))
7661 ;; We read in the article if we have to.
7662 (and (not data)
7663 force
7664 (gnus-summary-insert-subject
7665 article
7666 (if (or (numberp force) (vectorp force)) force)
7668 (setq data (gnus-data-find article)))
7669 (goto-char b)
7670 (if (not data)
7671 (progn
7672 (unless silent
7673 (gnus-message 3 "Can't find article %d" article))
7674 nil)
7675 (let ((pt (gnus-data-pos data)))
7676 (goto-char pt)
7677 (gnus-summary-set-article-display-arrow pt))
7678 (gnus-summary-position-point)
7679 article)))
7681 ;; Walking around summary lines with displaying articles.
7683 (defun gnus-summary-expand-window (&optional arg)
7684 "Make the summary buffer take up the entire Emacs frame.
7685 Given a prefix, will force an `article' buffer configuration."
7686 (interactive "P")
7687 (if arg
7688 (gnus-configure-windows 'article 'force)
7689 (gnus-configure-windows 'summary 'force)))
7691 (defun gnus-summary-display-article (article &optional all-header)
7692 "Display ARTICLE in article buffer."
7693 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7694 (with-current-buffer gnus-article-buffer
7695 (derived-mode-p 'gnus-article-mode)))
7696 (gnus-article-setup-buffer))
7697 (gnus-set-global-variables)
7698 (with-current-buffer gnus-article-buffer
7699 (setq gnus-article-charset gnus-newsgroup-charset)
7700 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7701 (mm-enable-multibyte))
7702 (if (null article)
7704 (prog1
7705 (if gnus-summary-display-article-function
7706 (funcall gnus-summary-display-article-function article all-header)
7707 (gnus-article-prepare article all-header))
7708 (gnus-run-hooks 'gnus-select-article-hook)
7709 (when (and gnus-current-article
7710 (not (zerop gnus-current-article)))
7711 (gnus-summary-goto-subject gnus-current-article))
7712 (gnus-summary-recenter)
7713 (when (and gnus-use-trees gnus-show-threads)
7714 (gnus-possibly-generate-tree article)
7715 (gnus-highlight-selected-tree article))
7716 ;; Successfully display article.
7717 (gnus-article-set-window-start
7718 (cdr (assq article gnus-newsgroup-bookmarks))))))
7720 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7721 "Select the current article.
7722 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7723 non-nil, the article will be re-fetched even if it already present in
7724 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7725 be displayed."
7726 ;; Make sure we are in the summary buffer to work around bbdb bug.
7727 (unless (derived-mode-p 'gnus-summary-mode)
7728 (set-buffer gnus-summary-buffer))
7729 (let ((article (or article (gnus-summary-article-number)))
7730 (all-headers (not (not all-headers))) ;Must be t or nil.
7731 gnus-summary-display-article-function)
7732 (and (not pseudo)
7733 (gnus-summary-article-pseudo-p article)
7734 (error "This is a pseudo-article"))
7735 (with-current-buffer gnus-summary-buffer
7736 (if (or (and gnus-single-article-buffer
7737 (or (null gnus-current-article)
7738 (null gnus-article-current)
7739 (null (get-buffer gnus-article-buffer))
7740 (not (eq article (cdr gnus-article-current)))
7741 (not (equal (car gnus-article-current)
7742 gnus-newsgroup-name))
7743 (not (get-buffer gnus-original-article-buffer))))
7744 (and (not gnus-single-article-buffer)
7745 (or (null gnus-current-article)
7746 (not (get-buffer gnus-original-article-buffer))
7747 (not (eq gnus-current-article article))))
7748 force)
7749 ;; The requested article is different from the current article.
7750 (progn
7751 (gnus-summary-display-article article all-headers)
7752 (when (gnus-buffer-live-p gnus-article-buffer)
7753 (with-current-buffer gnus-article-buffer
7754 (if (not gnus-article-decoded-p) ;; a local variable
7755 (mm-disable-multibyte))))
7756 (gnus-article-set-window-start
7757 (cdr (assq article gnus-newsgroup-bookmarks)))
7758 article)
7759 'old))))
7761 (defun gnus-summary-force-verify-and-decrypt ()
7762 "Display buttons for signed/encrypted parts and verify/decrypt them."
7763 (interactive)
7764 (let ((mm-verify-option 'known)
7765 (mm-decrypt-option 'known)
7766 (gnus-article-emulate-mime t)
7767 (gnus-buttonized-mime-types (append (list "multipart/signed"
7768 "multipart/encrypted")
7769 gnus-buttonized-mime-types)))
7770 (gnus-summary-select-article nil 'force)))
7772 (defun gnus-summary-next-article (&optional unread subject backward push)
7773 "Select the next article.
7774 If UNREAD, only unread articles are selected.
7775 If SUBJECT, only articles with SUBJECT are selected.
7776 If BACKWARD, the previous article is selected instead of the next."
7777 (interactive "P")
7778 ;; Make sure we are in the summary buffer.
7779 (unless (derived-mode-p 'gnus-summary-mode)
7780 (set-buffer gnus-summary-buffer))
7781 (cond
7782 ;; Is there such an article?
7783 ((and (gnus-summary-search-forward unread subject backward)
7784 (or (gnus-summary-display-article (gnus-summary-article-number))
7785 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7786 (gnus-summary-position-point))
7787 ;; If not, we try the first unread, if that is wanted.
7788 ((and subject
7789 gnus-auto-select-same
7790 (gnus-summary-first-unread-article))
7791 (gnus-summary-position-point)
7792 (gnus-message 6 "Wrapped"))
7793 ;; Try to get next/previous article not displayed in this group.
7794 ((and gnus-auto-extend-newsgroup
7795 (not unread) (not subject))
7796 (gnus-summary-goto-article
7797 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7798 nil (count-lines (point-min) (point))))
7799 ;; Go to next/previous group.
7801 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7802 (gnus-summary-jump-to-group gnus-newsgroup-name))
7803 (let ((cmd last-command-event)
7804 (point
7805 (with-current-buffer gnus-group-buffer
7806 (point)))
7807 (current-summary (current-buffer))
7808 (group
7809 (if (eq gnus-keep-same-level 'best)
7810 (gnus-summary-best-group gnus-newsgroup-name)
7811 (gnus-summary-search-group backward gnus-keep-same-level))))
7812 ;; Select next unread newsgroup automagically.
7813 (cond
7814 ((or (not gnus-auto-select-next)
7815 (not cmd))
7816 (unless (eq gnus-auto-select-next 'quietly)
7817 (gnus-message 6 "No more%s articles" (if unread " unread" ""))))
7818 ((or (eq gnus-auto-select-next 'quietly)
7819 (and (eq gnus-auto-select-next 'slightly-quietly)
7820 push)
7821 (and (eq gnus-auto-select-next 'almost-quietly)
7822 (gnus-summary-last-article-p)))
7823 ;; Select quietly.
7824 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7825 (gnus-summary-exit)
7826 (unless (eq gnus-auto-select-next 'quietly)
7827 (gnus-message 6 "No more%s articles (%s)..."
7828 (if unread " unread" "")
7829 (if group (concat "selecting " group)
7830 "exiting")))
7831 (gnus-summary-next-group nil group backward)))
7833 (when (numberp last-input-event)
7834 ;; Somehow or other, we may now have selected a different
7835 ;; window. Make point go back to the summary buffer.
7836 (when (eq current-summary (current-buffer))
7837 ;; FIXME: This burps when get-buffer-window returns nil.
7838 (select-window (get-buffer-window current-summary 0)))
7839 (gnus-summary-walk-group-buffer
7840 gnus-newsgroup-name cmd unread backward point))))))))
7842 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7843 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7844 (?\C-p (gnus-group-prev-unread-group 1))))
7845 (cursor-in-echo-area t)
7846 keve key group ended prompt)
7847 (with-current-buffer gnus-group-buffer
7848 (goto-char start)
7849 (setq group
7850 (if (eq gnus-keep-same-level 'best)
7851 (gnus-summary-best-group gnus-newsgroup-name)
7852 (gnus-summary-search-group backward gnus-keep-same-level))))
7853 (while (not ended)
7854 (setq prompt
7855 (format
7856 "No more%s articles%s " (if unread " unread" "")
7857 (if (and group
7858 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7859 (format " (Type %s for %s [%s])"
7860 (single-key-description cmd)
7861 (gnus-group-decoded-name group)
7862 (gnus-group-unread group))
7863 (format " (Type %s to exit %s)"
7864 (single-key-description cmd)
7865 (gnus-group-decoded-name gnus-newsgroup-name)))))
7866 ;; Confirm auto selection.
7867 (setq key (car (setq keve (gnus-read-event-char prompt)))
7868 ended t)
7869 (cond
7870 ((assq key keystrokes)
7871 (let ((obuf (current-buffer)))
7872 (switch-to-buffer gnus-group-buffer)
7873 (when group
7874 (gnus-group-jump-to-group group))
7875 (eval (cadr (assq key keystrokes)))
7876 (setq group (gnus-group-group-name))
7877 (switch-to-buffer obuf))
7878 (setq ended nil))
7879 ((equal key cmd)
7880 (if (or (not group)
7881 (gnus-ephemeral-group-p gnus-newsgroup-name))
7882 (gnus-summary-exit)
7883 (gnus-summary-next-group nil group backward)))
7885 (push (cdr keve) unread-command-events))))))
7887 (defun gnus-summary-next-unread-article ()
7888 "Select unread article after current one."
7889 (interactive)
7890 (gnus-summary-next-article
7891 (or (not (eq gnus-summary-goto-unread 'never))
7892 (gnus-summary-last-article-p (gnus-summary-article-number)))
7893 (and gnus-auto-select-same
7894 (gnus-summary-article-subject))))
7896 (defun gnus-summary-prev-article (&optional unread subject)
7897 "Select the article before the current one.
7898 If UNREAD is non-nil, only unread articles are selected."
7899 (interactive "P")
7900 (gnus-summary-next-article unread subject t))
7902 (defun gnus-summary-prev-unread-article ()
7903 "Select unread article before current one."
7904 (interactive)
7905 (gnus-summary-prev-article
7906 (or (not (eq gnus-summary-goto-unread 'never))
7907 (gnus-summary-first-article-p (gnus-summary-article-number)))
7908 (and gnus-auto-select-same
7909 (gnus-summary-article-subject))))
7911 (declare-function gnus-article-only-boring-p "gnus-art" ())
7913 (defun gnus-summary-next-page (&optional lines circular stop)
7914 "Show next page of the selected article.
7915 If at the end of the current article, select the next article.
7916 LINES says how many lines should be scrolled up.
7918 If CIRCULAR is non-nil, go to the start of the article instead of
7919 selecting the next article when reaching the end of the current
7920 article.
7922 If STOP is non-nil, just stop when reaching the end of the message.
7924 Also see the variable `gnus-article-skip-boring'."
7925 (interactive "P")
7926 (gnus-set-global-variables)
7927 (let ((article (gnus-summary-article-number))
7928 (article-window (get-buffer-window gnus-article-buffer t))
7929 endp)
7930 ;; If the buffer is empty, we have no article.
7931 (unless article
7932 (error "No article to select"))
7933 (gnus-configure-windows 'article)
7934 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7935 (if (and (eq gnus-summary-goto-unread 'never)
7936 (not (gnus-summary-last-article-p article)))
7937 (gnus-summary-next-article)
7938 (gnus-summary-next-unread-article))
7939 (if (or (null gnus-current-article)
7940 (null gnus-article-current)
7941 (/= article (cdr gnus-article-current))
7942 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7943 ;; Selected subject is different from current article's.
7944 (gnus-summary-display-article article)
7945 (when article-window
7946 (gnus-eval-in-buffer-window gnus-article-buffer
7947 (setq endp (or (gnus-article-next-page lines)
7948 (gnus-article-only-boring-p))))
7949 (when endp
7950 (cond ((or stop gnus-summary-stop-at-end-of-message)
7951 (gnus-message 3 "End of message"))
7952 (circular
7953 (gnus-summary-beginning-of-article))
7954 (lines
7955 (gnus-message 3 "End of message"))
7956 ((null lines)
7957 (if (and (eq gnus-summary-goto-unread 'never)
7958 (not (gnus-summary-last-article-p article)))
7959 (gnus-summary-next-article)
7960 (gnus-summary-next-unread-article))))))))
7961 (gnus-summary-recenter)
7962 (gnus-summary-position-point)))
7964 (defun gnus-summary-prev-page (&optional lines move)
7965 "Show previous page of selected article.
7966 Argument LINES specifies lines to be scrolled down.
7967 If MOVE, move to the previous unread article if point is at
7968 the beginning of the buffer."
7969 (interactive "P")
7970 (let ((article (gnus-summary-article-number))
7971 (article-window (get-buffer-window gnus-article-buffer t))
7972 endp)
7973 (gnus-configure-windows 'article)
7974 (if (or (null gnus-current-article)
7975 (null gnus-article-current)
7976 (/= article (cdr gnus-article-current))
7977 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7978 ;; Selected subject is different from current article's.
7979 (gnus-summary-display-article article)
7980 (gnus-summary-recenter)
7981 (when article-window
7982 (gnus-eval-in-buffer-window gnus-article-buffer
7983 (setq endp (gnus-article-prev-page lines)))
7984 (when (and move endp)
7985 (cond (lines
7986 (gnus-message 3 "Beginning of message"))
7987 ((null lines)
7988 (if (and (eq gnus-summary-goto-unread 'never)
7989 (not (gnus-summary-first-article-p article)))
7990 (gnus-summary-prev-article)
7991 (gnus-summary-prev-unread-article))))))))
7992 (gnus-summary-position-point))
7994 (defun gnus-summary-prev-page-or-article (&optional lines)
7995 "Show previous page of selected article.
7996 Argument LINES specifies lines to be scrolled down.
7997 If at the beginning of the article, go to the next article."
7998 (interactive "P")
7999 (gnus-summary-prev-page lines t))
8001 (defun gnus-summary-scroll-up (lines)
8002 "Scroll up (or down) one line current article.
8003 Argument LINES specifies lines to be scrolled up (or down if negative).
8004 If no article is selected, then the current article will be selected first."
8005 (interactive "p")
8006 (gnus-configure-windows 'article)
8007 (gnus-summary-show-thread)
8008 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8009 (gnus-eval-in-buffer-window gnus-article-buffer
8010 (cond ((> lines 0)
8011 (when (gnus-article-next-page lines)
8012 (gnus-message 3 "End of message")))
8013 ((< lines 0)
8014 (gnus-article-prev-page (- lines))))))
8015 (gnus-summary-recenter)
8016 (gnus-summary-position-point))
8018 (defun gnus-summary-scroll-down (lines)
8019 "Scroll down (or up) one line current article.
8020 Argument LINES specifies lines to be scrolled down (or up if negative).
8021 If no article is selected, then the current article will be selected first."
8022 (interactive "p")
8023 (gnus-summary-scroll-up (- lines)))
8025 (defun gnus-summary-next-same-subject ()
8026 "Select next article which has the same subject as current one."
8027 (interactive)
8028 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8030 (defun gnus-summary-prev-same-subject ()
8031 "Select previous article which has the same subject as current one."
8032 (interactive)
8033 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8035 (defun gnus-summary-next-unread-same-subject ()
8036 "Select next unread article which has the same subject as current one."
8037 (interactive)
8038 (gnus-summary-next-article t (gnus-summary-article-subject)))
8040 (defun gnus-summary-prev-unread-same-subject ()
8041 "Select previous unread article which has the same subject as current one."
8042 (interactive)
8043 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8045 (defun gnus-summary-first-unread-article ()
8046 "Select the first unread article.
8047 Return nil if there are no unread articles."
8048 (interactive)
8049 (prog1
8050 (when (gnus-summary-first-subject t)
8051 (gnus-summary-show-thread)
8052 (gnus-summary-first-subject t)
8053 (gnus-summary-display-article (gnus-summary-article-number)))
8054 (gnus-summary-position-point)))
8056 (defun gnus-summary-first-unread-subject ()
8057 "Place the point on the subject line of the first unread article.
8058 Return nil if there are no unread articles."
8059 (interactive)
8060 (prog1
8061 (when (gnus-summary-first-subject t)
8062 (gnus-summary-show-thread)
8063 (gnus-summary-first-subject t))
8064 (gnus-summary-position-point)))
8066 (defun gnus-summary-first-unseen-subject ()
8067 "Place the point on the subject line of the first unseen article.
8068 Return nil if there are no unseen articles."
8069 (interactive)
8070 (prog1
8071 (when (gnus-summary-first-subject nil nil t)
8072 (gnus-summary-show-thread)
8073 (gnus-summary-first-subject nil nil t))
8074 (gnus-summary-position-point)))
8076 (defun gnus-summary-first-unseen-or-unread-subject ()
8077 "Place the point on the subject line of the first unseen and unread article.
8078 If all article have been seen, on the subject line of the first unread
8079 article."
8080 (interactive)
8081 (prog1
8082 (unless (when (gnus-summary-first-subject nil nil t)
8083 (gnus-summary-show-thread)
8084 (gnus-summary-first-subject nil nil t))
8085 (when (gnus-summary-first-subject t)
8086 (gnus-summary-show-thread)
8087 (gnus-summary-first-subject t)))
8088 (gnus-summary-position-point)))
8090 (defun gnus-summary-first-article ()
8091 "Select the first article.
8092 Return nil if there are no articles."
8093 (interactive)
8094 (prog1
8095 (when (gnus-summary-first-subject)
8096 (gnus-summary-show-thread)
8097 (gnus-summary-first-subject)
8098 (gnus-summary-display-article (gnus-summary-article-number)))
8099 (gnus-summary-position-point)))
8101 (defun gnus-summary-best-unread-article (&optional arg)
8102 "Select the unread article with the highest score.
8103 If given a prefix argument, select the next unread article that has a
8104 score higher than the default score."
8105 (interactive "P")
8106 (let ((article (if arg
8107 (gnus-summary-better-unread-subject)
8108 (gnus-summary-best-unread-subject))))
8109 (if article
8110 (gnus-summary-goto-article article)
8111 (error "No unread articles"))))
8113 (defun gnus-summary-best-unread-subject ()
8114 "Select the unread subject with the highest score."
8115 (interactive)
8116 (let ((best -1000000)
8117 (data gnus-newsgroup-data)
8118 article score)
8119 (while data
8120 (and (gnus-data-unread-p (car data))
8121 (> (setq score
8122 (gnus-summary-article-score (gnus-data-number (car data))))
8123 best)
8124 (setq best score
8125 article (gnus-data-number (car data))))
8126 (setq data (cdr data)))
8127 (when article
8128 (gnus-summary-goto-subject article))
8129 (gnus-summary-position-point)
8130 article))
8132 (defun gnus-summary-better-unread-subject ()
8133 "Select the first unread subject that has a score over the default score."
8134 (interactive)
8135 (let ((data gnus-newsgroup-data)
8136 article score)
8137 (while (and (setq article (gnus-data-number (car data)))
8138 (or (gnus-data-read-p (car data))
8139 (not (> (gnus-summary-article-score article)
8140 gnus-summary-default-score))))
8141 (setq data (cdr data)))
8142 (when article
8143 (gnus-summary-goto-subject article))
8144 (gnus-summary-position-point)
8145 article))
8147 (defun gnus-summary-last-subject ()
8148 "Go to the last displayed subject line in the group."
8149 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8150 (when article
8151 (gnus-summary-goto-subject article))))
8153 (defun gnus-summary-goto-article (article &optional all-headers force)
8154 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8155 If ALL-HEADERS is non-nil, no header lines are hidden.
8156 If FORCE, go to the article even if it isn't displayed. If FORCE
8157 is a number, it is the line the article is to be displayed on."
8158 (interactive
8159 (list
8160 (gnus-completing-read
8161 "Article number or Message-ID"
8162 (mapcar 'int-to-string gnus-newsgroup-limit))
8163 current-prefix-arg
8165 (prog1
8166 (if (and (stringp article)
8167 (string-match "@\\|%40" article))
8168 (gnus-summary-refer-article article)
8169 (when (stringp article)
8170 (setq article (string-to-number article)))
8171 (if (gnus-summary-goto-subject article force)
8172 (gnus-summary-display-article article all-headers)
8173 (gnus-message 4 "Couldn't go to article %s" article) nil))
8174 (gnus-summary-position-point)))
8176 (defun gnus-summary-goto-last-article ()
8177 "Go to the previously read article."
8178 (interactive)
8179 (prog1
8180 (when gnus-last-article
8181 (gnus-summary-goto-article gnus-last-article nil t))
8182 (gnus-summary-position-point)))
8184 (defun gnus-summary-pop-article (number)
8185 "Pop one article off the history and go to the previous.
8186 NUMBER articles will be popped off."
8187 (interactive "p")
8188 (let (to)
8189 (setq gnus-newsgroup-history
8190 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8191 (if to
8192 (gnus-summary-goto-article (car to) nil t)
8193 (error "Article history empty")))
8194 (gnus-summary-position-point))
8196 ;; Summary commands and functions for limiting the summary buffer.
8198 (defun gnus-summary-limit-to-articles (n)
8199 "Limit the summary buffer to the next N articles.
8200 If not given a prefix, use the process marked articles instead."
8201 (interactive "P")
8202 (prog1
8203 (let ((articles (gnus-summary-work-articles n)))
8204 (setq gnus-newsgroup-processable nil)
8205 (gnus-summary-limit articles))
8206 (gnus-summary-position-point)))
8208 (defun gnus-summary-pop-limit (&optional total)
8209 "Restore the previous limit.
8210 If given a prefix, remove all limits."
8211 (interactive "P")
8212 (when total
8213 (setq gnus-newsgroup-limits
8214 (list (mapcar (lambda (h) (mail-header-number h))
8215 gnus-newsgroup-headers))))
8216 (unless gnus-newsgroup-limits
8217 (error "No limit to pop"))
8218 (prog1
8219 (gnus-summary-limit nil 'pop)
8220 (gnus-summary-position-point)))
8222 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8223 "Limit the summary buffer to articles that have subjects that match a regexp.
8224 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8225 (interactive
8226 (list (read-string (if current-prefix-arg
8227 "Exclude subject (regexp): "
8228 "Limit to subject (regexp): "))
8229 nil current-prefix-arg))
8230 (unless header
8231 (setq header "subject"))
8232 (when (not (equal "" subject))
8233 (prog1
8234 (let ((articles (gnus-summary-find-matching
8235 (or header "subject") subject 'all nil nil
8236 not-matching)))
8237 (unless articles
8238 (error "Found no matches for \"%s\"" subject))
8239 (gnus-summary-limit articles))
8240 (gnus-summary-position-point))))
8242 (defun gnus-summary-limit-to-author (from &optional not-matching)
8243 "Limit the summary buffer to articles that have authors that match a regexp.
8244 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8245 (interactive
8246 (list (let* ((header (gnus-summary-article-header))
8247 (default (and header (car (mail-header-parse-address
8248 (mail-header-from header))))))
8249 (read-string (concat (if current-prefix-arg
8250 "Exclude author (regexp"
8251 "Limit to author (regexp")
8252 (if default
8253 (concat ", default \"" default "\"): ")
8254 "): "))
8255 nil nil
8256 default))
8257 current-prefix-arg))
8258 (gnus-summary-limit-to-subject from "from" not-matching))
8260 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8261 "Limit the summary buffer to articles with the given RECIPIENT.
8263 If NOT-MATCHING, exclude RECIPIENT.
8265 To and Cc headers are checked. You need to include them in
8266 `nnmail-extra-headers'."
8267 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8268 (interactive
8269 (list (read-string (format "%s recipient (regexp): "
8270 (if current-prefix-arg "Exclude" "Limit to")))
8271 current-prefix-arg))
8272 (when (not (equal "" recipient))
8273 (prog1 (let* ((to
8274 (if (memq 'To nnmail-extra-headers)
8275 (gnus-summary-find-matching
8276 (cons 'extra 'To) recipient 'all nil nil
8277 not-matching)
8278 (gnus-message
8279 1 "`To' isn't present in `nnmail-extra-headers'")
8280 (sit-for 1)
8281 nil))
8283 (if (memq 'Cc nnmail-extra-headers)
8284 (gnus-summary-find-matching
8285 (cons 'extra 'Cc) recipient 'all nil nil
8286 not-matching)
8287 (gnus-message
8288 1 "`Cc' isn't present in `nnmail-extra-headers'")
8289 (sit-for 1)
8290 nil))
8291 (articles
8292 (if not-matching
8293 ;; We need the numbers that are in both lists:
8294 (mapcar (lambda (a)
8295 (and (memq a to) a))
8297 (nconc to cc))))
8298 (unless articles
8299 (error "Found no matches for \"%s\"" recipient))
8300 (gnus-summary-limit articles))
8301 (gnus-summary-position-point))))
8303 (defun gnus-summary-limit-to-address (address &optional not-matching)
8304 "Limit the summary buffer to articles with the given ADDRESS.
8306 If NOT-MATCHING, exclude ADDRESS.
8308 To, Cc and From headers are checked. You need to include `To' and `Cc'
8309 in `nnmail-extra-headers'."
8310 (interactive
8311 (list (read-string (format "%s address (regexp): "
8312 (if current-prefix-arg "Exclude" "Limit to")))
8313 current-prefix-arg))
8314 (when (not (equal "" address))
8315 (prog1 (let* ((to
8316 (if (memq 'To nnmail-extra-headers)
8317 (gnus-summary-find-matching
8318 (cons 'extra 'To) address 'all nil nil
8319 not-matching)
8320 (gnus-message
8321 1 "`To' isn't present in `nnmail-extra-headers'")
8322 (sit-for 1)
8325 (if (memq 'Cc nnmail-extra-headers)
8326 (gnus-summary-find-matching
8327 (cons 'extra 'Cc) address 'all nil nil
8328 not-matching)
8329 (gnus-message
8330 1 "`Cc' isn't present in `nnmail-extra-headers'")
8331 (sit-for 1)
8333 (from
8334 (gnus-summary-find-matching "from" address
8335 'all nil nil not-matching))
8336 (articles
8337 (if not-matching
8338 ;; We need the numbers that are in all lists:
8339 (if (eq cc t)
8340 (if (eq to t)
8341 from
8342 (mapcar (lambda (a) (car (memq a from))) to))
8343 (if (eq to t)
8344 (mapcar (lambda (a) (car (memq a from))) cc)
8345 (mapcar (lambda (a) (car (memq a from)))
8346 (mapcar (lambda (a) (car (memq a to)))
8347 cc))))
8348 (nconc (if (eq to t) nil to)
8349 (if (eq cc t) nil cc)
8350 from))))
8351 (unless articles
8352 (error "Found no matches for \"%s\"" address))
8353 (gnus-summary-limit articles))
8354 (gnus-summary-position-point))))
8356 (defun gnus-summary-limit-strange-charsets-predicate (header)
8357 (let ((string (concat (mail-header-subject header)
8358 (mail-header-from header)))
8359 charset found)
8360 (dotimes (i (1- (length string)))
8361 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8362 (when (string-match "unicode\\|big\\|japanese" charset)
8363 (setq found t)))
8364 found))
8366 (defun gnus-summary-limit-to-predicate (predicate)
8367 "Limit to articles where PREDICATE returns non-nil.
8368 PREDICATE will be called with the header structures of the
8369 articles."
8370 (let ((articles nil)
8371 (case-fold-search t))
8372 (dolist (header gnus-newsgroup-headers)
8373 (when (funcall predicate header)
8374 (push (mail-header-number header) articles)))
8375 (gnus-summary-limit (nreverse articles))))
8377 (defun gnus-summary-limit-to-age (age &optional younger-p)
8378 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8379 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8380 articles that are younger than AGE days."
8381 (interactive
8382 (let ((younger current-prefix-arg)
8383 (days-got nil)
8384 days)
8385 (while (not days-got)
8386 (setq days (if younger
8387 (read-string "Limit to articles younger than (in days, older when negative): ")
8388 (read-string
8389 "Limit to articles older than (in days, younger when negative): ")))
8390 (when (> (length days) 0)
8391 (setq days (read days)))
8392 (if (numberp days)
8393 (progn
8394 (setq days-got t)
8395 (when (< days 0)
8396 (setq younger (not younger))
8397 (setq days (* days -1))))
8398 (message "Please enter a number.")
8399 (sleep-for 1)))
8400 (list days younger)))
8401 (prog1
8402 (let ((data gnus-newsgroup-data)
8403 (cutoff (days-to-time age))
8404 articles d date is-younger)
8405 (while (setq d (pop data))
8406 (when (and (vectorp (gnus-data-header d))
8407 (setq date (mail-header-date (gnus-data-header d))))
8408 (setq is-younger (time-less-p
8409 (time-since (gnus-date-get-time date))
8410 cutoff))
8411 (when (if younger-p
8412 is-younger
8413 (not is-younger))
8414 (push (gnus-data-number d) articles))))
8415 (gnus-summary-limit (nreverse articles)))
8416 (gnus-summary-position-point)))
8418 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8419 "Limit the summary buffer to articles that match an `extra' header."
8420 (interactive
8421 (let ((header
8422 (intern
8423 (gnus-completing-read
8424 (if current-prefix-arg
8425 "Exclude extra header"
8426 "Limit extra header")
8427 (mapcar 'symbol-name gnus-extra-headers)
8428 t nil nil
8429 (symbol-name (car gnus-extra-headers))))))
8430 (list header
8431 (read-string (format "%s header %s (regexp): "
8432 (if current-prefix-arg "Exclude" "Limit to")
8433 header))
8434 current-prefix-arg)))
8435 (when (not (equal "" regexp))
8436 (prog1
8437 (let ((articles (gnus-summary-find-matching
8438 (cons 'extra header) regexp 'all nil nil
8439 not-matching)))
8440 (unless articles
8441 (error "Found no matches for \"%s\"" regexp))
8442 (gnus-summary-limit articles))
8443 (gnus-summary-position-point))))
8445 (defun gnus-summary-limit-to-display-predicate ()
8446 "Limit the summary buffer to the predicated in the `display' group parameter."
8447 (interactive)
8448 (unless gnus-newsgroup-display
8449 (error "There is no `display' group parameter"))
8450 (let (articles)
8451 (dolist (gnus-number gnus-newsgroup-articles)
8452 (when (funcall gnus-newsgroup-display)
8453 (push gnus-number articles)))
8454 (gnus-summary-limit articles))
8455 (gnus-summary-position-point))
8457 (defun gnus-summary-limit-to-unread (&optional all)
8458 "Limit the summary buffer to articles that are not marked as read.
8459 If ALL is non-nil, limit strictly to unread articles."
8460 (interactive "P")
8461 (if all
8462 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8463 (gnus-summary-limit-to-marks
8464 ;; Concat all the marks that say that an article is read and have
8465 ;; those removed.
8466 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8467 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8468 gnus-low-score-mark gnus-expirable-mark
8469 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8470 gnus-duplicate-mark)
8471 'reverse)))
8473 (defun gnus-summary-limit-to-headers (match &optional reverse)
8474 "Limit the summary buffer to articles that have headers that match MATCH.
8475 If REVERSE (the prefix), limit to articles that don't match."
8476 (interactive "sMatch headers (regexp): \nP")
8477 (gnus-summary-limit-to-bodies match reverse t))
8479 (declare-function article-goto-body "gnus-art" ())
8481 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8482 "Limit the summary buffer to articles that have bodies that match MATCH.
8483 If REVERSE (the prefix), limit to articles that don't match."
8484 (interactive "sMatch body (regexp): \nP")
8485 (let ((articles nil)
8486 (gnus-select-article-hook nil) ;Disable hook.
8487 (gnus-article-prepare-hook nil)
8488 (gnus-use-article-prefetch nil)
8489 (gnus-keep-backlog nil)
8490 (gnus-break-pages nil)
8491 (gnus-summary-display-arrow nil)
8492 (gnus-updated-mode-lines nil)
8493 (gnus-auto-center-summary nil)
8494 (gnus-display-mime-function nil))
8495 (dolist (data gnus-newsgroup-data)
8496 (let (gnus-mark-article-hook)
8497 (gnus-summary-select-article t t nil (gnus-data-number data)))
8498 (with-current-buffer gnus-article-buffer
8499 (article-goto-body)
8500 (let* ((case-fold-search t)
8501 (found (if headersp
8502 (re-search-backward match nil t)
8503 (re-search-forward match nil t))))
8504 (when (or (and found
8505 (not reverse))
8506 (and (not found)
8507 reverse))
8508 (push (gnus-data-number data) articles)))))
8509 (if (not articles)
8510 (message "No messages matched")
8511 (gnus-summary-limit articles)))
8512 (gnus-summary-position-point))
8514 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8515 "Limit the summary buffer to articles that aren't part on any thread.
8516 If THREADSP (the prefix), limit to articles that are in threads."
8517 (interactive "P")
8518 (let ((articles nil)
8519 thread-articles
8520 threads)
8521 (dolist (thread gnus-newsgroup-threads)
8522 (if (stringp (car thread))
8523 (dolist (thread (cdr thread))
8524 (push thread threads))
8525 (push thread threads)))
8526 (dolist (thread threads)
8527 (setq thread-articles (gnus-articles-in-thread thread))
8528 (when (or (and threadsp
8529 (> (length thread-articles) 1))
8530 (and (not threadsp)
8531 (= (length thread-articles) 1)))
8532 (setq articles (nconc thread-articles articles))))
8533 (if (not articles)
8534 (message "No messages matched")
8535 (gnus-summary-limit articles))
8536 (gnus-summary-position-point)))
8538 (defun gnus-summary-limit-to-replied (&optional unreplied)
8539 "Limit the summary buffer to replied articles.
8540 If UNREPLIED (the prefix), limit to unreplied articles."
8541 (interactive "P")
8542 (if unreplied
8543 (gnus-summary-limit
8544 (gnus-set-difference gnus-newsgroup-articles
8545 gnus-newsgroup-replied))
8546 (gnus-summary-limit gnus-newsgroup-replied))
8547 (gnus-summary-position-point))
8549 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8550 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8551 If REVERSE, limit the summary buffer to articles that are marked
8552 with MARKS. MARKS can either be a string of marks or a list of marks.
8553 Returns how many articles were removed."
8554 (interactive "sMarks: ")
8555 (gnus-summary-limit-to-marks marks t))
8557 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8558 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8559 If REVERSE (the prefix), limit the summary buffer to articles that are
8560 not marked with MARKS. MARKS can either be a string of marks or a
8561 list of marks.
8562 Returns how many articles were removed."
8563 (interactive "sMarks: \nP")
8564 (prog1
8565 (let ((data gnus-newsgroup-data)
8566 (marks (if (listp marks) marks
8567 (append marks nil))) ; Transform to list.
8568 articles)
8569 (while data
8570 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8571 (memq (gnus-data-mark (car data)) marks))
8572 (push (gnus-data-number (car data)) articles))
8573 (setq data (cdr data)))
8574 (gnus-summary-limit articles))
8575 (gnus-summary-position-point)))
8577 (defun gnus-summary-limit-to-score (score &optional below)
8578 "Limit to articles with score at or above SCORE.
8580 With a prefix argument, limit to articles with score at or below
8581 SCORE."
8582 (interactive (list (string-to-number
8583 (read-string
8584 (format "Limit to articles with score of at %s: "
8585 (if current-prefix-arg "most" "least"))))))
8586 (let ((data gnus-newsgroup-data)
8587 (compare (if (or below current-prefix-arg) #'<= #'>=))
8588 articles)
8589 (while data
8590 (when (funcall compare (gnus-summary-article-score
8591 (gnus-data-number (car data)))
8592 score)
8593 (push (gnus-data-number (car data)) articles))
8594 (setq data (cdr data)))
8595 (prog1
8596 (gnus-summary-limit articles)
8597 (gnus-summary-position-point))))
8599 (defun gnus-summary-limit-to-unseen ()
8600 "Limit to unseen articles."
8601 (interactive)
8602 (prog1
8603 (gnus-summary-limit gnus-newsgroup-unseen)
8604 (gnus-summary-position-point)))
8606 (defun gnus-summary-limit-include-thread (id &optional thread-only)
8607 "Display all hidden articles belonging to thread ID.
8608 When called interactively, ID is the Message-ID of the current
8609 article. If thread-only is non-nil limit the summary buffer to
8610 these articles."
8611 (interactive (list (mail-header-id (gnus-summary-article-header))))
8612 (let ((articles (gnus-articles-in-thread
8613 (gnus-id-to-thread (gnus-root-id id))))
8614 ;;we REALLY want the whole thread---this prevents cut-threads
8615 ;;from removing the thread we want to include.
8616 (gnus-fetch-old-headers nil)
8617 (gnus-build-sparse-threads nil))
8618 (prog1
8619 (gnus-summary-limit (if thread-only articles
8620 (nconc articles gnus-newsgroup-limit)))
8621 (gnus-summary-limit-include-matching-articles
8622 "subject"
8623 (regexp-quote (gnus-general-simplify-subject
8624 (mail-header-subject (gnus-id-to-header id)))))
8625 ;; the previous two calls each push a limit onto the limit
8626 ;; stack. the first pop remove the articles that match the
8627 ;; subject, while the second pop gets us back to the state
8628 ;; before we started to deal with the thread. presumably we want
8629 ;; to think of the thread and its associated subject matches as
8630 ;; a single thing so that we need to pop only once to get back
8631 ;; to the original view.
8632 (pop gnus-newsgroup-limits)
8633 (gnus-summary-position-point))))
8635 (defun gnus-summary-limit-include-matching-articles (header regexp)
8636 "Display all the hidden articles that have HEADERs that match REGEXP."
8637 (interactive (list (read-string "Match on header: ")
8638 (read-string "Regexp: ")))
8639 (let ((articles (gnus-find-matching-articles header regexp)))
8640 (prog1
8641 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8642 (gnus-summary-position-point))))
8644 (defun gnus-summary-insert-dormant-articles ()
8645 "Insert all the dormant articles for this group into the current buffer."
8646 (interactive)
8647 (let ((gnus-verbose (max 6 gnus-verbose)))
8648 (if (not gnus-newsgroup-dormant)
8649 (gnus-message 3 "No dormant articles for this group")
8650 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8652 (defun gnus-summary-insert-ticked-articles ()
8653 "Insert ticked articles for this group into the current buffer."
8654 (interactive)
8655 (let ((gnus-verbose (max 6 gnus-verbose)))
8656 (if (not gnus-newsgroup-marked)
8657 (gnus-message 3 "No ticked articles for this group")
8658 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8660 (defun gnus-summary-limit-include-dormant ()
8661 "Display all the hidden articles that are marked as dormant.
8662 Note that this command only works on a subset of the articles currently
8663 fetched for this group."
8664 (interactive)
8665 (unless gnus-newsgroup-dormant
8666 (error "There are no dormant articles in this group"))
8667 (prog1
8668 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8669 (gnus-summary-position-point)))
8671 (defun gnus-summary-include-articles (articles)
8672 "Fetch the headers for ARTICLES and then display the summary lines."
8673 (let ((gnus-inhibit-demon t)
8674 (gnus-agent nil)
8675 (gnus-read-all-available-headers t))
8676 (setq gnus-newsgroup-headers
8677 (cl-merge
8678 'list gnus-newsgroup-headers
8679 (gnus-fetch-headers articles nil t)
8680 'gnus-article-sort-by-number))
8681 (setq gnus-newsgroup-articles
8682 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8683 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8685 (defun gnus-summary-limit-exclude-dormant ()
8686 "Hide all dormant articles."
8687 (interactive)
8688 (prog1
8689 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8690 (gnus-summary-position-point)))
8692 (defun gnus-summary-limit-exclude-childless-dormant ()
8693 "Hide all dormant articles that have no children."
8694 (interactive)
8695 (let ((data (gnus-data-list t))
8696 articles d children)
8697 ;; Find all articles that are either not dormant or have
8698 ;; children.
8699 (while (setq d (pop data))
8700 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8701 (and (setq children
8702 (gnus-article-children (gnus-data-number d)))
8703 (let (found)
8704 (while children
8705 (when (memq (car children) articles)
8706 (setq children nil
8707 found t))
8708 (pop children))
8709 found)))
8710 (push (gnus-data-number d) articles)))
8711 ;; Do the limiting.
8712 (prog1
8713 (gnus-summary-limit articles)
8714 (gnus-summary-position-point))))
8716 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8717 "Mark all unread excluded articles as read.
8718 If ALL, mark even excluded ticked and dormants as read."
8719 (interactive "P")
8720 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8721 (let ((articles (gnus-sorted-ndifference
8722 (sort
8723 (mapcar (lambda (h) (mail-header-number h))
8724 gnus-newsgroup-headers)
8726 gnus-newsgroup-limit))
8727 article)
8728 (setq gnus-newsgroup-unreads
8729 (gnus-sorted-intersection gnus-newsgroup-unreads
8730 gnus-newsgroup-limit))
8731 (if all
8732 (setq gnus-newsgroup-dormant nil
8733 gnus-newsgroup-marked nil
8734 gnus-newsgroup-reads
8735 (nconc
8736 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8737 gnus-newsgroup-reads))
8738 (while (setq article (pop articles))
8739 (unless (or (memq article gnus-newsgroup-dormant)
8740 (memq article gnus-newsgroup-marked))
8741 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8743 (defun gnus-summary-limit (articles &optional pop)
8744 (if pop
8745 ;; We pop the previous limit off the stack and use that.
8746 (setq articles (car gnus-newsgroup-limits)
8747 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8748 ;; We use the new limit, so we push the old limit on the stack.
8749 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8750 ;; Set the limit.
8751 (setq gnus-newsgroup-limit articles)
8752 (let ((total (length gnus-newsgroup-data))
8753 (data (gnus-data-find-list (gnus-summary-article-number)))
8754 (gnus-summary-mark-below nil) ; Inhibit this.
8755 found)
8756 ;; This will do all the work of generating the new summary buffer
8757 ;; according to the new limit.
8758 (gnus-summary-prepare)
8759 ;; Hide any threads, possibly.
8760 (gnus-summary-maybe-hide-threads)
8761 ;; Try to return to the article you were at, or one in the
8762 ;; neighborhood.
8763 (when data
8764 ;; We try to find some article after the current one.
8765 (while data
8766 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8767 (setq data nil
8768 found t))
8769 (setq data (cdr data))))
8770 (unless found
8771 ;; If there is no data, that means that we were after the last
8772 ;; article. The same goes when we can't find any articles
8773 ;; after the current one.
8774 (goto-char (point-max))
8775 (gnus-summary-find-prev))
8776 (gnus-set-mode-line 'summary)
8777 ;; We return how many articles were removed from the summary
8778 ;; buffer as a result of the new limit.
8779 (- total (length gnus-newsgroup-data))))
8781 (defsubst gnus-invisible-cut-children (threads)
8782 (let ((num 0))
8783 (while threads
8784 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8785 (cl-incf num))
8786 (pop threads))
8787 (< num 2)))
8789 (defsubst gnus-cut-thread (thread)
8790 "Go forwards in the thread until we find an article that we want to display."
8791 (when (or (eq gnus-fetch-old-headers 'some)
8792 (eq gnus-fetch-old-headers 'invisible)
8793 (numberp gnus-fetch-old-headers)
8794 (eq gnus-build-sparse-threads 'some)
8795 (eq gnus-build-sparse-threads 'more))
8796 ;; Deal with old-fetched headers and sparse threads.
8797 (while (and
8798 thread
8800 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8801 (gnus-summary-article-ancient-p
8802 (mail-header-number (car thread))))
8803 (if (or (<= (length (cdr thread)) 1)
8804 (eq gnus-fetch-old-headers 'invisible))
8805 (setq gnus-newsgroup-limit
8806 (delq (mail-header-number (car thread))
8807 gnus-newsgroup-limit)
8808 thread (cadr thread))
8809 (when (gnus-invisible-cut-children (cdr thread))
8810 (let ((th (cdr thread)))
8811 (while th
8812 (if (memq (mail-header-number (caar th))
8813 gnus-newsgroup-limit)
8814 (setq thread (car th)
8815 th nil)
8816 (setq th (cdr th))))))))))
8817 thread)
8819 (defun gnus-cut-threads (threads)
8820 "Cut off all uninteresting articles from the beginning of THREADS."
8821 (when (or (eq gnus-fetch-old-headers 'some)
8822 (eq gnus-fetch-old-headers 'invisible)
8823 (numberp gnus-fetch-old-headers)
8824 (eq gnus-build-sparse-threads 'some)
8825 (eq gnus-build-sparse-threads 'more))
8826 (let ((th threads))
8827 (while th
8828 (setcar th (gnus-cut-thread (car th)))
8829 (setq th (cdr th)))))
8830 ;; Remove nixed out threads.
8831 (delq nil threads))
8833 (defun gnus-summary-initial-limit (&optional show-if-empty)
8834 "Figure out what the initial limit is supposed to be on group entry.
8835 This entails weeding out unwanted dormants, low-scored articles,
8836 fetch-old-headers verbiage, and so on."
8837 ;; Most groups have nothing to remove.
8838 (unless (or gnus-inhibit-limiting
8839 (and (null gnus-newsgroup-dormant)
8840 (eq gnus-newsgroup-display 'gnus-not-ignore)
8841 (not (eq gnus-fetch-old-headers 'some))
8842 (not (numberp gnus-fetch-old-headers))
8843 (not (eq gnus-fetch-old-headers 'invisible))
8844 (null gnus-summary-expunge-below)
8845 (not (eq gnus-build-sparse-threads 'some))
8846 (not (eq gnus-build-sparse-threads 'more))
8847 (null gnus-thread-expunge-below)))
8848 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8849 (setq gnus-newsgroup-limit nil)
8850 (mapatoms
8851 (lambda (node)
8852 (unless (car (symbol-value node))
8853 ;; These threads have no parents -- they are roots.
8854 (let ((nodes (cdr (symbol-value node)))
8855 thread)
8856 (while nodes
8857 (if (and gnus-thread-expunge-below
8858 (< (gnus-thread-total-score (car nodes))
8859 gnus-thread-expunge-below))
8860 (gnus-expunge-thread (pop nodes))
8861 (setq thread (pop nodes))
8862 (gnus-summary-limit-children thread))))))
8863 gnus-newsgroup-dependencies)
8864 ;; If this limitation resulted in an empty group, we might
8865 ;; pop the previous limit and use it instead.
8866 (when (and (not gnus-newsgroup-limit)
8867 show-if-empty)
8868 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8869 gnus-newsgroup-limit))
8871 (defun gnus-summary-limit-children (thread)
8872 "Return 1 if this subthread is visible and 0 if it is not."
8873 ;; First we get the number of visible children to this thread. This
8874 ;; is done by recursing down the thread using this function, so this
8875 ;; will really go down to a leaf article first, before slowly
8876 ;; working its way up towards the root.
8877 (when thread
8878 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8879 (children
8880 (if (cdr thread)
8881 (apply '+ (mapcar 'gnus-summary-limit-children
8882 (cdr thread)))
8884 (number (mail-header-number (car thread)))
8885 score)
8886 (if (and
8887 (not (memq number gnus-newsgroup-marked))
8889 ;; If this article is dormant and has absolutely no visible
8890 ;; children, then this article isn't visible.
8891 (and (memq number gnus-newsgroup-dormant)
8892 (zerop children))
8893 ;; If this is "fetch-old-headered" and there is no
8894 ;; visible children, then we don't want this article.
8895 (and (or (eq gnus-fetch-old-headers 'some)
8896 (numberp gnus-fetch-old-headers))
8897 (gnus-summary-article-ancient-p number)
8898 (zerop children))
8899 ;; If this is "fetch-old-headered" and `invisible', then
8900 ;; we don't want this article.
8901 (and (eq gnus-fetch-old-headers 'invisible)
8902 (gnus-summary-article-ancient-p number))
8903 ;; If this is a sparsely inserted article with no children,
8904 ;; we don't want it.
8905 (and (eq gnus-build-sparse-threads 'some)
8906 (gnus-summary-article-sparse-p number)
8907 (zerop children))
8908 ;; If we use expunging, and this article is really
8909 ;; low-scored, then we don't want this article.
8910 (when (and gnus-summary-expunge-below
8911 (< (setq score
8912 (or (cdr (assq number gnus-newsgroup-scored))
8913 gnus-summary-default-score))
8914 gnus-summary-expunge-below))
8915 ;; We increase the expunge-tally here, but that has
8916 ;; nothing to do with the limits, really.
8917 (cl-incf gnus-newsgroup-expunged-tally)
8918 ;; We also mark as read here, if that's wanted.
8919 (when (and gnus-summary-mark-below
8920 (< score gnus-summary-mark-below))
8921 (setq gnus-newsgroup-unreads
8922 (delq number gnus-newsgroup-unreads))
8923 (if gnus-newsgroup-auto-expire
8924 (push number gnus-newsgroup-expirable)
8925 (push (cons number gnus-low-score-mark)
8926 gnus-newsgroup-reads)))
8928 ;; Do the `display' group parameter.
8929 (and gnus-newsgroup-display
8930 (let ((gnus-number number))
8931 (not (funcall gnus-newsgroup-display))))))
8932 ;; Nope, invisible article.
8934 ;; Ok, this article is to be visible, so we add it to the limit
8935 ;; and return 1.
8936 (push number gnus-newsgroup-limit)
8937 1))))
8939 (defun gnus-expunge-thread (thread)
8940 "Mark all articles in THREAD as read."
8941 (let* ((number (mail-header-number (car thread))))
8942 (cl-incf gnus-newsgroup-expunged-tally)
8943 ;; We also mark as read here, if that's wanted.
8944 (setq gnus-newsgroup-unreads
8945 (delq number gnus-newsgroup-unreads))
8946 (if gnus-newsgroup-auto-expire
8947 (push number gnus-newsgroup-expirable)
8948 (push (cons number gnus-low-score-mark)
8949 gnus-newsgroup-reads)))
8950 ;; Go recursively through all subthreads.
8951 (mapcar 'gnus-expunge-thread (cdr thread)))
8953 ;; Summary article oriented commands
8955 (defun gnus-summary-refer-parent-article (n)
8956 "Refer parent article N times.
8957 If N is negative, go to ancestor -N instead.
8958 The difference between N and the number of articles fetched is returned."
8959 (interactive "p")
8960 (let ((skip 1)
8961 error header ref)
8962 (when (not (natnump n))
8963 (setq skip (abs n)
8964 n 1))
8965 (while (and (> n 0)
8966 (not error))
8967 (setq header (gnus-summary-article-header))
8968 (if (and (eq (mail-header-number header)
8969 (cdr gnus-article-current))
8970 (equal gnus-newsgroup-name
8971 (car gnus-article-current)))
8972 ;; If we try to find the parent of the currently
8973 ;; displayed article, then we take a look at the actual
8974 ;; References header, since this is slightly more
8975 ;; reliable than the References field we got from the
8976 ;; server.
8977 (with-current-buffer gnus-original-article-buffer
8978 (nnheader-narrow-to-headers)
8979 (unless (setq ref (message-fetch-field "references"))
8980 (when (setq ref (message-fetch-field "in-reply-to"))
8981 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8982 (widen))
8983 (setq ref
8984 ;; It's not the current article, so we take a bet on
8985 ;; the value we got from the server.
8986 (mail-header-references header)))
8987 (if (and ref
8988 (not (equal ref "")))
8989 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8990 (gnus-message 1 "Couldn't find parent"))
8991 (gnus-message 1 "No references in article %d"
8992 (gnus-summary-article-number))
8993 (setq error t))
8994 (cl-decf n))
8995 (gnus-summary-position-point)
8998 (defun gnus-summary-refer-references ()
8999 "Fetch all articles mentioned in the References header.
9000 Return the number of articles fetched."
9001 (interactive)
9002 (let ((ref (mail-header-references (gnus-summary-article-header)))
9003 (current (gnus-summary-article-number))
9004 (n 0))
9005 (if (or (not ref)
9006 (equal ref ""))
9007 (error "No References in the current article")
9008 ;; For each Message-ID in the References header...
9009 (while (string-match "<[^>]*>" ref)
9010 (cl-incf n)
9011 ;; ... fetch that article.
9012 (gnus-summary-refer-article
9013 (prog1 (match-string 0 ref)
9014 (setq ref (substring ref (match-end 0))))))
9015 (gnus-summary-goto-subject current)
9016 (gnus-summary-position-point)
9017 n)))
9019 (defun gnus-delete-duplicate-headers (headers)
9020 ;; First remove leading duplicates.
9021 (while (and (> (length headers) 1)
9022 (= (mail-header-number (car headers))
9023 (mail-header-number (cadr headers))))
9024 (pop headers))
9025 ;; Then the rest.
9026 (let ((result headers))
9027 (while (> (length headers) 1)
9028 (if (= (mail-header-number (car headers))
9029 (mail-header-number (cadr headers)))
9030 (setcdr headers (cddr headers))
9031 (pop headers)))
9032 result))
9034 (defun gnus-summary-refer-thread (&optional limit)
9035 "Fetch all articles in the current thread. For backends that
9036 know how to search for threads (currently only 'nnimap) a
9037 non-numeric prefix arg will use nnir to search the entire
9038 server; without a prefix arg only the current group is
9039 searched. If the variable `gnus-refer-thread-use-nnir' is
9040 non-nil the prefix arg has the reverse meaning. If no
9041 backend-specific 'request-thread function is available fetch
9042 LIMIT (the numerical prefix) old headers. If LIMIT is
9043 non-numeric or nil fetch the number specified by the
9044 `gnus-refer-thread-limit' variable."
9045 (interactive "P")
9046 (let* ((header (gnus-summary-article-header))
9047 (id (mail-header-id header))
9048 (gnus-inhibit-demon t)
9049 (gnus-summary-ignore-duplicates t)
9050 (gnus-read-all-available-headers t)
9051 (gnus-refer-thread-use-nnir
9052 (if (and (not (null limit)) (listp limit))
9053 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9054 (new-headers
9055 (if (gnus-check-backend-function
9056 'request-thread gnus-newsgroup-name)
9057 (gnus-request-thread header gnus-newsgroup-name)
9058 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9059 gnus-refer-thread-limit))
9060 (last (if (numberp limit)
9061 (min (+ (mail-header-number header)
9062 limit)
9063 gnus-newsgroup-highest)
9064 gnus-newsgroup-highest))
9065 (subject (gnus-simplify-subject
9066 (mail-header-subject header)))
9067 (refs (split-string (or (mail-header-references header)
9068 "")))
9069 (gnus-parse-headers-hook
9070 `(lambda () (goto-char (point-min))
9071 (keep-lines
9072 (regexp-opt ',(append refs (list id subject)))))))
9073 (gnus-fetch-headers (list last) (if (numberp limit)
9074 (* 2 limit) limit) t))))
9075 article-ids new-unreads)
9076 (when (listp new-headers)
9077 (dolist (header new-headers)
9078 (push (mail-header-number header) article-ids))
9079 (setq article-ids (nreverse article-ids))
9080 (setq new-unreads
9081 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9082 (setq gnus-newsgroup-unselected
9083 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9084 (setq gnus-newsgroup-unreads
9085 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9086 (setq gnus-newsgroup-headers
9087 (gnus-delete-duplicate-headers
9088 (cl-merge
9089 'list gnus-newsgroup-headers new-headers
9090 'gnus-article-sort-by-number)))
9091 (setq gnus-newsgroup-articles
9092 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9093 (gnus-summary-limit-include-thread id gnus-refer-thread-limit-to-thread)))
9094 (gnus-summary-show-thread))
9096 (defun gnus-summary-open-group-with-article (message-id)
9097 "Open a group containing the article with the given MESSAGE-ID."
9098 (interactive "sMessage-ID: ")
9099 (require 'nndoc)
9100 (with-temp-buffer
9101 ;; Prepare a dummy article
9102 (erase-buffer)
9103 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9105 ;; Prepare pretty modelines for summary and article buffers
9106 (let ((gnus-summary-mode-line-format "Found %G")
9107 (gnus-article-mode-line-format
9108 ;; Group names just get in the way here, especially the
9109 ;; abbreviated ones
9110 (if (string-match "%[gG]" gnus-article-mode-line-format)
9111 (concat (substring gnus-article-mode-line-format
9112 0 (match-beginning 0))
9113 (substring gnus-article-mode-line-format (match-end 0)))
9114 gnus-article-mode-line-format)))
9116 ;; Build an ephemeral group containing the dummy article (hidden)
9117 (gnus-group-read-ephemeral-group
9118 message-id
9119 `(nndoc ,message-id
9120 (nndoc-address ,(current-buffer))
9121 (nndoc-article-type mbox))
9122 :activate
9123 (cons (current-buffer) gnus-current-window-configuration)
9124 (not :request-only)
9125 '(-1) ; :select-articles
9126 (not :parameters)
9127 0)) ; :number
9128 ;; Fetch the desired article
9129 (gnus-summary-refer-article message-id)))
9131 (defun gnus-summary-refer-article (message-id)
9132 "Fetch an article specified by MESSAGE-ID."
9133 (interactive "sMessage-ID: ")
9134 (when (and (stringp message-id)
9135 (not (zerop (length message-id))))
9136 (setq message-id (replace-regexp-in-string " " "" message-id))
9137 ;; Construct the correct Message-ID if necessary.
9138 ;; Suggested by tale@pawl.rpi.edu.
9139 (unless (string-match "^<" message-id)
9140 (setq message-id (concat "<" message-id)))
9141 (unless (string-match ">$" message-id)
9142 (setq message-id (concat message-id ">")))
9143 ;; People often post MIDs from URLs, so unhex it:
9144 (unless (string-match "@" message-id)
9145 (setq message-id (gnus-url-unhex-string message-id)))
9146 (let* ((header (gnus-id-to-header message-id))
9147 (sparse (and header
9148 (gnus-summary-article-sparse-p
9149 (mail-header-number header))
9150 (memq (mail-header-number header)
9151 gnus-newsgroup-limit)))
9152 number)
9153 (cond
9154 ;; If the article is present in the buffer we just go to it.
9155 ((and header
9156 (or (not (gnus-summary-article-sparse-p
9157 (mail-header-number header)))
9158 sparse))
9159 (prog1
9160 (gnus-summary-goto-article
9161 (mail-header-number header) nil t)
9162 (when sparse
9163 (gnus-summary-update-article (mail-header-number header)))))
9165 ;; We fetch the article.
9166 (catch 'found
9167 (dolist (gnus-override-method (gnus-refer-article-methods))
9168 (when (and (gnus-check-server gnus-override-method)
9169 ;; Fetch the header,
9170 (setq number (gnus-summary-insert-subject message-id)))
9171 ;; and display the article.
9172 (gnus-summary-select-article nil nil nil number)
9173 (throw 'found t)))
9174 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9176 (defun gnus-refer-article-methods ()
9177 "Return a list of referable methods."
9178 (cond
9179 ;; No method, so we default to current and native.
9180 ((null gnus-refer-article-method)
9181 (list gnus-current-select-method gnus-select-method))
9182 ;; Current.
9183 ((eq 'current gnus-refer-article-method)
9184 (list gnus-current-select-method))
9185 ;; List of select methods.
9186 ((not (and (symbolp (car gnus-refer-article-method))
9187 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9188 (let (out)
9189 (dolist (method gnus-refer-article-method)
9190 (push (if (eq 'current method)
9191 gnus-current-select-method
9192 (if (eq 'nnir (car method))
9193 (list
9194 'nnir
9195 (or (cadr method)
9196 (gnus-method-to-server gnus-current-select-method)))
9197 method))
9198 out))
9199 (nreverse out)))
9200 ;; One single select method.
9202 (list gnus-refer-article-method))))
9204 (defun gnus-summary-edit-parameters ()
9205 "Edit the group parameters of the current group."
9206 (interactive)
9207 (gnus-group-edit-group gnus-newsgroup-name 'params))
9209 (defun gnus-summary-customize-parameters ()
9210 "Customize the group parameters of the current group."
9211 (interactive)
9212 (gnus-group-customize gnus-newsgroup-name))
9214 (defun gnus-summary-enter-digest-group (&optional force)
9215 "Enter an nndoc group based on the current article.
9216 If FORCE, force a digest interpretation. If not, try to guess
9217 what the document format is.
9219 To control what happens when you exit the group, see the
9220 `gnus-auto-select-on-ephemeral-exit' variable."
9221 (interactive "P")
9222 (let ((conf gnus-current-window-configuration))
9223 (save-window-excursion
9224 (save-excursion
9225 (let (gnus-article-prepare-hook
9226 gnus-display-mime-function
9227 gnus-break-pages)
9228 (gnus-summary-select-article))))
9229 (setq gnus-current-window-configuration conf)
9230 (let* ((name (format "%s-%d"
9231 (gnus-group-prefixed-name
9232 gnus-newsgroup-name (list 'nndoc ""))
9233 (with-current-buffer gnus-summary-buffer
9234 gnus-current-article)))
9235 (ogroup gnus-newsgroup-name)
9236 (params (append (gnus-info-params (gnus-get-info ogroup))
9237 (list (cons 'to-group ogroup))
9238 (list (cons 'parent-group ogroup))
9239 (list (cons 'save-article-group ogroup))))
9240 (case-fold-search t)
9241 (buf (current-buffer))
9242 dig to-address charset)
9243 (with-current-buffer gnus-original-article-buffer
9244 ;; Have the digest group inherit the main mail address of
9245 ;; the parent article.
9246 (when (setq to-address (or (gnus-fetch-field "reply-to")
9247 (gnus-fetch-field "from")))
9248 (setq params
9249 (append
9250 params
9251 (list (cons 'to-address
9252 (funcall gnus-decode-encoded-address-function
9253 to-address))))))
9254 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9255 (insert-buffer-substring gnus-original-article-buffer)
9256 (narrow-to-region
9257 (goto-char (point-min))
9258 (or (search-forward "\n\n" nil t) (point)))
9259 ;; Remove lines that may lead nndoc to misinterpret the
9260 ;; document type.
9261 (goto-char (point-min))
9262 (delete-matching-lines "^Path:\\|^From ")
9263 ;; Parse charset, and decode content transfer encoding.
9264 (setq charset (mail-content-type-get
9265 (mail-header-parse-content-type
9266 (or (gnus-fetch-field "content-type") ""))
9267 'charset))
9268 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9269 (when encoding
9270 (message-remove-header "content-transfer-encoding")
9271 (goto-char (point-max))
9272 (widen)
9273 (narrow-to-region (point) (point-max))
9274 (mm-decode-content-transfer-encoding
9275 (intern (downcase (mail-header-strip-cte encoding))))))
9276 (widen))
9277 (unwind-protect
9278 (if (let ((gnus-newsgroup-ephemeral-charset
9279 (if charset
9280 (intern (downcase (gnus-strip-whitespace charset)))
9281 gnus-newsgroup-charset))
9282 (gnus-newsgroup-ephemeral-ignored-charsets
9283 gnus-newsgroup-ignored-charsets))
9284 (gnus-group-read-ephemeral-group
9285 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9286 (nndoc-article-type
9287 ,(if force 'mbox 'guess)))
9288 t nil nil nil
9289 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9290 "ADAPT")))))
9291 ;; Make all postings to this group go to the parent group.
9292 (nconc (gnus-info-params (gnus-get-info name))
9293 params)
9294 ;; Couldn't select this doc group.
9295 (switch-to-buffer buf)
9296 (gnus-set-global-variables)
9297 (gnus-configure-windows 'summary)
9298 (gnus-message 3 "Article couldn't be entered?"))
9299 (kill-buffer dig)))))
9301 (defun gnus-summary-read-document (n)
9302 "Open a new group based on the current article(s).
9303 This will allow you to read digests and other similar
9304 documents as newsgroups.
9305 Obeys the standard process/prefix convention."
9306 (interactive "P")
9307 (let* ((ogroup gnus-newsgroup-name)
9308 (params (append (gnus-info-params (gnus-get-info ogroup))
9309 (list (cons 'to-group ogroup))))
9310 group egroup groups vgroup)
9311 (dolist (article (gnus-summary-work-articles n))
9312 (setq group (format "%s-%d" gnus-newsgroup-name article))
9313 (gnus-summary-remove-process-mark article)
9314 (when (gnus-summary-display-article article)
9315 (save-excursion ;;What for?
9316 (with-temp-buffer
9317 (insert-buffer-substring gnus-original-article-buffer)
9318 ;; Remove some headers that may lead nndoc to make
9319 ;; the wrong guess.
9320 (message-narrow-to-head)
9321 (goto-char (point-min))
9322 (delete-matching-lines "^Path:\\|^From ")
9323 (widen)
9324 (if (setq egroup
9325 (gnus-group-read-ephemeral-group
9326 group `(nndoc ,group (nndoc-address ,(current-buffer))
9327 (nndoc-article-type guess))
9328 t nil t))
9329 (progn
9330 ;; Make all postings to this group go to the parent group.
9331 (nconc (gnus-info-params (gnus-get-info egroup))
9332 params)
9333 (push egroup groups))
9334 ;; Couldn't select this doc group.
9335 (gnus-error 3 "Article couldn't be entered"))))))
9336 ;; Now we have selected all the documents.
9337 (cond
9338 ((not groups)
9339 (error "None of the articles could be interpreted as documents"))
9340 ((gnus-group-read-ephemeral-group
9341 (setq vgroup (format
9342 "nnvirtual:%s-%s" gnus-newsgroup-name
9343 (format-time-string "%Y%m%dT%H%M%S")))
9344 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9346 (cons (current-buffer) 'summary)))
9348 (error "Couldn't select virtual nndoc group")))))
9350 (defun gnus-summary-widget-forward (arg)
9351 "Move point to the next field or button in the article.
9352 With optional ARG, move across that many fields."
9353 (interactive "p")
9354 (gnus-summary-select-article)
9355 (gnus-configure-windows 'article)
9356 (select-window (gnus-get-buffer-window gnus-article-buffer))
9357 (widget-forward arg))
9359 (defun gnus-summary-widget-backward (arg)
9360 "Move point to the previous field or button in the article.
9361 With optional ARG, move across that many fields."
9362 (interactive "p")
9363 (gnus-summary-select-article)
9364 (gnus-configure-windows 'article)
9365 (select-window (gnus-get-buffer-window gnus-article-buffer))
9366 (unless (widget-at (point))
9367 (goto-char (point-max)))
9368 (widget-backward arg))
9370 (defun gnus-summary-isearch-article (&optional regexp-p)
9371 "Do incremental search forward on the current article.
9372 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9373 (interactive "P")
9374 (gnus-summary-select-article)
9375 (gnus-configure-windows 'article)
9376 (gnus-eval-in-buffer-window gnus-article-buffer
9377 (save-restriction
9378 (widen)
9379 (isearch-forward regexp-p))))
9381 (defun gnus-summary-repeat-search-article-forward ()
9382 "Repeat the previous search forwards."
9383 (interactive)
9384 (unless gnus-last-search-regexp
9385 (error "No previous search"))
9386 (gnus-summary-search-article-forward gnus-last-search-regexp))
9388 (defun gnus-summary-repeat-search-article-backward ()
9389 "Repeat the previous search backwards."
9390 (interactive)
9391 (unless gnus-last-search-regexp
9392 (error "No previous search"))
9393 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9395 (defun gnus-summary-search-article-forward (regexp &optional backward)
9396 "Search for an article containing REGEXP forward.
9397 If BACKWARD, search backward instead."
9398 (interactive
9399 (list (read-string
9400 (format "Search article %s (regexp%s): "
9401 (if current-prefix-arg "backward" "forward")
9402 (if gnus-last-search-regexp
9403 (concat ", default " gnus-last-search-regexp)
9404 "")))
9405 current-prefix-arg))
9406 (if (string-equal regexp "")
9407 (setq regexp (or gnus-last-search-regexp ""))
9408 (setq gnus-last-search-regexp regexp)
9409 (setq gnus-article-before-search gnus-current-article))
9410 ;; Intentionally set gnus-last-article.
9411 (setq gnus-last-article gnus-article-before-search)
9412 (let ((gnus-last-article gnus-last-article))
9413 (if (gnus-summary-search-article regexp backward)
9414 (gnus-summary-show-thread)
9415 (signal 'search-failed (list regexp)))))
9417 (defun gnus-summary-search-article-backward (regexp)
9418 "Search for an article containing REGEXP backward."
9419 (interactive
9420 (list (read-string
9421 (format "Search article backward (regexp%s): "
9422 (if gnus-last-search-regexp
9423 (concat ", default " gnus-last-search-regexp)
9424 "")))))
9425 (gnus-summary-search-article-forward regexp 'backward))
9427 (defun gnus-summary-search-article (regexp &optional backward)
9428 "Search for an article containing REGEXP.
9429 Optional argument BACKWARD means do search for backward.
9430 `gnus-select-article-hook' is not called during the search."
9431 ;; We have to require this here to make sure that the following
9432 ;; dynamic binding isn't shadowed by autoloading.
9433 (require 'gnus-async)
9434 (require 'gnus-art)
9435 (let ((gnus-select-article-hook nil) ;Disable hook.
9436 (gnus-article-prepare-hook nil)
9437 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9438 (gnus-use-article-prefetch nil)
9439 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9440 (gnus-visual nil)
9441 (gnus-keep-backlog nil)
9442 (gnus-break-pages nil)
9443 (gnus-summary-display-arrow nil)
9444 (gnus-updated-mode-lines nil)
9445 (gnus-auto-center-summary nil)
9446 (sum (current-buffer))
9447 (gnus-display-mime-function nil)
9448 (found nil)
9449 point)
9450 (gnus-save-hidden-threads
9451 (gnus-summary-select-article)
9452 (set-buffer gnus-article-buffer)
9453 (goto-char (window-point (get-buffer-window (current-buffer))))
9454 (when backward
9455 (forward-line -1))
9456 (while (not found)
9457 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9458 (if (if backward
9459 (re-search-backward regexp nil t)
9460 (re-search-forward regexp nil t))
9461 ;; We found the regexp.
9462 (progn
9463 (setq found 'found)
9464 (beginning-of-line)
9465 (set-window-start
9466 (get-buffer-window (current-buffer))
9467 (point))
9468 (forward-line 1)
9469 (set-window-point
9470 (get-buffer-window (current-buffer))
9471 (point))
9472 (set-buffer sum)
9473 (setq point (point)))
9474 ;; We didn't find it, so we go to the next article.
9475 (set-buffer sum)
9476 (setq found 'not)
9477 (while (eq found 'not)
9478 (if (not (if backward (gnus-summary-find-prev)
9479 (gnus-summary-find-next)))
9480 ;; No more articles.
9481 (setq found t)
9482 ;; Select the next article and adjust point.
9483 (unless (gnus-summary-article-sparse-p
9484 (gnus-summary-article-number))
9485 (setq found nil)
9486 (gnus-summary-select-article)
9487 (set-buffer gnus-article-buffer)
9488 (widen)
9489 (goto-char (if backward (point-max) (point-min))))))))
9490 (gnus-message 7 ""))
9491 ;; Return whether we found the regexp.
9492 (when (eq found 'found)
9493 (goto-char point)
9494 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9495 (gnus-summary-show-thread)
9496 (gnus-summary-goto-subject gnus-current-article)
9497 (gnus-summary-position-point)
9498 t)))
9500 (defun gnus-find-matching-articles (header regexp)
9501 "Return a list of all articles that match REGEXP on HEADER.
9502 This search includes all articles in the current group that Gnus has
9503 fetched headers for, whether they are displayed or not."
9504 (let ((articles nil)
9505 ;; Can't eta-reduce because it's a macro.
9506 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9507 (case-fold-search t))
9508 (dolist (header gnus-newsgroup-headers)
9509 (when (string-match regexp (funcall func header))
9510 (push (mail-header-number header) articles)))
9511 (nreverse articles)))
9513 (defun gnus-summary-find-matching (header regexp &optional backward unread
9514 not-case-fold not-matching)
9515 "Return a list of all articles that match REGEXP on HEADER.
9516 The search stars on the current article and goes forwards unless
9517 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9518 If UNREAD is non-nil, only unread articles will
9519 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9520 in the comparisons. If NOT-MATCHING, return a list of all articles that
9521 not match REGEXP on HEADER."
9522 (let ((case-fold-search (not not-case-fold))
9523 articles d func)
9524 (if (consp header)
9525 (if (eq (car header) 'extra)
9526 (setq func
9527 `(lambda (h)
9528 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9529 "")))
9530 (error "%s is an invalid header" header))
9531 (unless (fboundp (intern (concat "mail-header-" header)))
9532 (error "%s is not a valid header" header))
9533 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9534 (dolist (d (if (eq backward 'all)
9535 gnus-newsgroup-data
9536 (gnus-data-find-list
9537 (gnus-summary-article-number)
9538 (gnus-data-list backward))))
9539 (when (and (or (not unread) ; We want all articles...
9540 (gnus-data-unread-p d)) ; Or just unreads.
9541 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9542 (if not-matching
9543 (not (string-match
9544 regexp
9545 (funcall func (gnus-data-header d))))
9546 (string-match regexp
9547 (funcall func (gnus-data-header d)))))
9548 (push (gnus-data-number d) articles))) ; Success!
9549 (nreverse articles)))
9551 (defun gnus-summary-execute-command (header regexp command &optional backward)
9552 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9553 If HEADER is an empty string (or nil), the match is done on the entire
9554 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9555 (interactive
9556 (list (let ((completion-ignore-case t))
9557 (gnus-completing-read
9558 "Header name"
9559 (mapcar 'symbol-name
9560 (append
9561 '(Number Subject From Lines Date
9562 Message-ID Xref References Body)
9563 gnus-extra-headers))
9564 'require-match))
9565 (read-string "Regexp: ")
9566 (read-key-sequence "Command: ")
9567 current-prefix-arg))
9568 (when (equal header "Body")
9569 (setq header ""))
9570 ;; Hidden thread subtrees must be searched as well.
9571 (gnus-summary-show-all-threads)
9572 ;; We don't want to change current point nor window configuration.
9573 (save-excursion
9574 (save-window-excursion
9575 (let (gnus-visual
9576 gnus-treat-strip-trailing-blank-lines
9577 gnus-treat-strip-leading-blank-lines
9578 gnus-treat-strip-multiple-blank-lines
9579 gnus-treat-hide-boring-headers
9580 gnus-treat-fold-newsgroups
9581 gnus-article-prepare-hook)
9582 (gnus-message 6 "Executing %s..." (key-description command))
9583 ;; We'd like to execute COMMAND interactively so as to give arguments.
9584 (gnus-execute header regexp
9585 `(call-interactively ',(key-binding command))
9586 backward)
9587 (gnus-message 6 "Executing %s...done" (key-description command))))))
9589 (defun gnus-summary-beginning-of-article ()
9590 "Scroll the article back to the beginning."
9591 (interactive)
9592 (gnus-summary-select-article)
9593 (gnus-configure-windows 'article)
9594 (gnus-eval-in-buffer-window gnus-article-buffer
9595 (widen)
9596 (goto-char (point-min))
9597 (when gnus-break-pages
9598 (gnus-narrow-to-page))))
9600 (defun gnus-summary-end-of-article ()
9601 "Scroll to the end of the article."
9602 (interactive)
9603 (gnus-summary-select-article)
9604 (gnus-configure-windows 'article)
9605 (gnus-eval-in-buffer-window gnus-article-buffer
9606 (widen)
9607 (goto-char (point-max))
9608 (recenter -3)
9609 (when gnus-break-pages
9610 (gnus-narrow-to-page))))
9612 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9613 "Truncate to LEN and quote all \"(\"'s in STRING."
9614 (replace-regexp-in-string "[()]" "\\\\\\&"
9615 (if (and len (> (length string) len))
9616 (substring string 0 len)
9617 string)))
9619 (defun gnus-summary-print-article (&optional filename n)
9620 "Generate and print a PostScript image of the process-marked (mail) articles.
9622 If used interactively, print the current article if none are
9623 process-marked. With prefix arg, prompt the user for the name of the
9624 file to save in.
9626 When used from Lisp, accept two optional args FILENAME and N. N means
9627 to print the next N articles. If N is negative, print the N previous
9628 articles. If N is nil and articles have been marked with the process
9629 mark, print these instead.
9631 If the optional first argument FILENAME is nil, send the image to the
9632 printer. If FILENAME is a string, save the PostScript image in a file with
9633 that name. If FILENAME is a number, prompt the user for the name of the file
9634 to save in."
9635 (interactive (list (ps-print-preprint current-prefix-arg)))
9636 (dolist (article (gnus-summary-work-articles n))
9637 (gnus-summary-select-article nil nil 'pseudo article)
9638 (gnus-eval-in-buffer-window gnus-article-buffer
9639 (gnus-print-buffer))
9640 (gnus-summary-remove-process-mark article))
9641 (ps-despool filename))
9643 (defun gnus-print-buffer ()
9644 (let ((ps-left-header
9645 (list
9646 (concat "("
9647 (gnus-summary-print-truncate-and-quote
9648 (mail-header-subject gnus-current-headers)
9649 66) ")")
9650 (concat "("
9651 (gnus-summary-print-truncate-and-quote
9652 (mail-header-from gnus-current-headers)
9653 45) ")")))
9654 (ps-right-header
9655 (list
9656 "/pagenumberstring load"
9657 (concat "("
9658 (mail-header-date gnus-current-headers) ")"))))
9659 (gnus-run-hooks 'gnus-ps-print-hook)
9660 (save-excursion
9661 (if ps-print-color-p
9662 (ps-spool-buffer-with-faces)
9663 (ps-spool-buffer)))))
9665 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9667 (defun gnus-summary-show-complete-article ()
9668 "Show a complete version of the current article.
9669 This is only useful if you're looking at a partial version of the
9670 article currently."
9671 (interactive)
9672 (let ((gnus-keep-backlog nil)
9673 (gnus-use-cache nil)
9674 (gnus-agent nil)
9675 (variable (intern
9676 (format "%s-fetch-partial-articles"
9677 (car (gnus-find-method-for-group
9678 gnus-newsgroup-name)))
9679 obarray))
9680 old-val)
9681 (unwind-protect
9682 (progn
9683 (setq old-val (symbol-value variable))
9684 (set variable nil)
9685 (gnus-flush-original-article-buffer)
9686 (gnus-summary-show-article))
9687 (set variable old-val))))
9689 (defun gnus-summary-show-article (&optional arg)
9690 "Force redisplaying of the current article.
9691 If ARG (the prefix) is a number, show the article with the charset
9692 defined in `gnus-summary-show-article-charset-alist', or the charset
9693 input.
9694 If ARG (the prefix) is non-nil and not a number, show the article,
9695 but without running any of the article treatment functions
9696 article. Normally, the keystroke is `C-u g'. When using `C-u
9697 C-u g', show the raw article."
9698 (interactive "P")
9699 (cond
9700 ((numberp arg)
9701 (gnus-summary-show-article t)
9702 (let ((gnus-newsgroup-charset
9703 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9704 (read-coding-system
9705 "View as charset: " ;; actually it is coding system.
9706 (with-current-buffer gnus-article-buffer
9707 (mm-detect-coding-region (point) (point-max))))))
9708 (gnus-newsgroup-ignored-charsets 'gnus-all))
9709 (gnus-summary-select-article nil 'force)
9710 (let ((deps gnus-newsgroup-dependencies)
9711 head header lines)
9712 (with-current-buffer gnus-original-article-buffer
9713 (save-restriction
9714 (message-narrow-to-head)
9715 (setq head (buffer-string))
9716 (goto-char (point-min))
9717 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9718 (goto-char (point-max))
9719 (widen)
9720 (setq lines (1- (count-lines (point) (point-max))))))
9721 (with-temp-buffer
9722 (insert (format "211 %d Article retrieved.\n"
9723 (cdr gnus-article-current)))
9724 (insert head)
9725 (if lines (insert (format "Lines: %d\n" lines)))
9726 (insert ".\n")
9727 (let ((nntp-server-buffer (current-buffer)))
9728 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9729 (gnus-data-set-header
9730 (gnus-data-find (cdr gnus-article-current))
9731 header)
9732 (gnus-summary-update-article-line
9733 (cdr gnus-article-current) header)
9734 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9735 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9736 ((not arg)
9737 ;; Select the article the normal way.
9738 (if (eq mm-text-html-renderer 'shr)
9739 (progn
9740 (require 'shr)
9741 (let ((shr-ignore-cache t))
9742 (gnus-summary-select-article nil 'force)))
9743 (gnus-summary-select-article nil 'force)))
9744 ((equal arg '(16))
9745 ;; C-u C-u g
9746 (let ((gnus-inhibit-article-treatments t))
9747 (gnus-summary-select-article nil 'force)))
9749 ;; We have to require this here to make sure that the following
9750 ;; dynamic binding isn't shadowed by autoloading.
9751 (require 'gnus-async)
9752 (require 'gnus-art)
9753 ;; Bind the article treatment functions to nil.
9754 (let ((gnus-have-all-headers t)
9755 gnus-article-prepare-hook
9756 gnus-article-decode-hook
9757 gnus-display-mime-function
9758 gnus-break-pages)
9759 ;; Destroy any MIME parts.
9760 (when (gnus-buffer-live-p gnus-article-buffer)
9761 (with-current-buffer gnus-article-buffer
9762 (gnus-article-stop-animations)
9763 (gnus-stop-downloads)
9764 (mm-destroy-parts gnus-article-mime-handles)
9765 ;; Set it to nil for safety reason.
9766 (setq gnus-article-mime-handle-alist nil)
9767 (setq gnus-article-mime-handles nil)))
9768 (gnus-summary-select-article nil 'force))))
9769 (gnus-summary-goto-subject gnus-current-article)
9770 (gnus-summary-position-point))
9772 (defun gnus-summary-show-raw-article ()
9773 "Show the raw article without any article massaging functions being run."
9774 (interactive)
9775 (gnus-summary-show-article t))
9777 (defun gnus-summary-verbose-headers (&optional arg)
9778 "Toggle permanent full header display.
9779 If ARG is a positive number, turn header display on.
9780 If ARG is a negative number, turn header display off."
9781 (interactive "P")
9782 (setq gnus-show-all-headers
9783 (cond ((or (not (numberp arg))
9784 (zerop arg))
9785 (not gnus-show-all-headers))
9786 ((natnump arg)
9787 t)))
9788 (gnus-summary-show-article))
9790 (declare-function article-narrow-to-head "gnus-art" ())
9791 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9792 (declare-function gnus-delete-wash-type "gnus-art" (type))
9793 (declare-function gnus-mime-buttonize-attachments-in-header
9794 "gnus-art" (&optional interactive))
9796 (defun gnus-summary-toggle-header (&optional arg)
9797 "Show the headers if they are hidden, or hide them if they are shown.
9798 If ARG is a positive number, show the entire header.
9799 If ARG is a negative number, hide the unwanted header lines."
9800 (interactive "P")
9801 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9802 (get-buffer-window gnus-article-buffer t))))
9803 (with-current-buffer gnus-article-buffer
9804 (widen)
9805 (article-narrow-to-head)
9806 (let* ((inhibit-read-only t)
9807 (inhibit-point-motion-hooks t)
9808 (hidden (if (numberp arg)
9809 (>= arg 0)
9811 ;; The case where there's no visible header
9812 ;; that matches `gnus-visible-headers'.
9813 (looking-at "\n?\\'")
9814 (gnus-article-hidden-text-p 'headers))))
9815 s e)
9816 (delete-region (point-min) (point-max))
9817 (with-current-buffer gnus-original-article-buffer
9818 (goto-char (setq s (point-min)))
9819 (setq e (if (search-forward "\n\n" nil t)
9820 (1- (point))
9821 (point-max))))
9822 (insert-buffer-substring gnus-original-article-buffer s e)
9823 (run-hooks 'gnus-article-decode-hook)
9824 (if hidden
9825 (let ((gnus-treat-hide-headers nil)
9826 (gnus-treat-hide-boring-headers nil))
9827 (gnus-delete-wash-type 'headers)
9828 (gnus-treat-article 'head))
9829 (gnus-treat-article 'head)
9830 ;; Add attachment buttons to the header.
9831 (when gnus-mime-display-attachment-buttons-in-header
9832 (gnus-mime-buttonize-attachments-in-header)))
9833 (widen)
9834 (if window
9835 (set-window-start window (goto-char (point-min))))
9836 (if gnus-break-pages
9837 (gnus-narrow-to-page)
9838 (when (gnus-visual-p 'page-marker)
9839 (let ((inhibit-read-only t))
9840 (gnus-remove-text-with-property 'gnus-prev)
9841 (gnus-remove-text-with-property 'gnus-next))))
9842 (gnus-set-mode-line 'article)))))
9844 (defun gnus-summary-show-all-headers ()
9845 "Make all header lines visible."
9846 (interactive)
9847 (gnus-summary-toggle-header 1))
9849 (defun gnus-summary-caesar-message (&optional arg)
9850 "Caesar rotate the current article by 13.
9851 With a non-numerical prefix, also rotate headers. A numerical
9852 prefix specifies how many places to rotate each letter forward."
9853 (interactive "P")
9854 (gnus-summary-select-article)
9855 (let ((mail-header-separator ""))
9856 (gnus-eval-in-buffer-window gnus-article-buffer
9857 (save-restriction
9858 (widen)
9859 (let ((start (window-start))
9860 (inhibit-read-only t))
9861 (if (equal arg '(4))
9862 (message-caesar-buffer-body nil t)
9863 (message-caesar-buffer-body arg))
9864 (set-window-start (get-buffer-window (current-buffer)) start)))))
9865 ;; Create buttons and stuff...
9866 (gnus-treat-article nil))
9868 (defun gnus-summary-idna-message (&optional arg)
9869 "Decode IDNA encoded domain names in the current articles.
9870 IDNA encoded domain names looks like `xn--bar'. If a string
9871 remain unencoded after running this function, it is likely an
9872 invalid IDNA string (`xn--bar' is invalid).
9874 You must have GNU Libidn (URL `https://www.gnu.org/software/libidn/')
9875 installed for this command to work."
9876 (interactive "P")
9877 (gnus-summary-select-article)
9878 (let ((mail-header-separator ""))
9879 (gnus-eval-in-buffer-window gnus-article-buffer
9880 (save-restriction
9881 (widen)
9882 (let ((start (window-start))
9883 buffer-read-only)
9884 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9885 (replace-match (puny-decode-domain (match-string 1))))
9886 (set-window-start (get-buffer-window (current-buffer)) start))))))
9888 (defun gnus-summary-morse-message (&optional arg)
9889 "Morse decode the current article."
9890 (interactive "P")
9891 (gnus-summary-select-article)
9892 (let ((mail-header-separator ""))
9893 (gnus-eval-in-buffer-window gnus-article-buffer
9894 (save-excursion
9895 (save-restriction
9896 (widen)
9897 (let ((pos (window-start))
9898 (inhibit-read-only t))
9899 (goto-char (point-min))
9900 (when (message-goto-body)
9901 (gnus-narrow-to-body))
9902 (goto-char (point-min))
9903 (while (search-forward "·" (point-max) t)
9904 (replace-match "."))
9905 (unmorse-region (point-min) (point-max))
9906 (widen)
9907 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9909 (defun gnus-summary-stop-page-breaking ()
9910 "Stop page breaking in the current article."
9911 (interactive)
9912 (gnus-summary-select-article)
9913 (gnus-eval-in-buffer-window gnus-article-buffer
9914 (widen)
9915 (when (gnus-visual-p 'page-marker)
9916 (let ((inhibit-read-only t))
9917 (gnus-remove-text-with-property 'gnus-prev)
9918 (gnus-remove-text-with-property 'gnus-next))
9919 (setq gnus-page-broken nil))))
9921 (defun gnus-summary-move-article (&optional n to-newsgroup
9922 select-method action)
9923 "Move the current article to a different newsgroup.
9924 If N is a positive number, move the N next articles.
9925 If N is a negative number, move the N previous articles.
9926 If N is nil and any articles have been marked with the process mark,
9927 move those articles instead.
9928 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9929 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9930 re-spool using this method.
9932 When called interactively with TO-NEWSGROUP being nil, the value of
9933 the variable `gnus-move-split-methods' is used for finding a default
9934 for the target newsgroup.
9936 For this function to work, both the current newsgroup and the
9937 newsgroup that you want to move to have to support the `request-move'
9938 and `request-accept' functions.
9940 ACTION can be either `move' (the default), `crosspost' or `copy'."
9941 (interactive "P")
9942 (unless action
9943 (setq action 'move))
9944 ;; Check whether the source group supports the required functions.
9945 (cond ((and (eq action 'move)
9946 (not (gnus-check-backend-function
9947 'request-move-article gnus-newsgroup-name)))
9948 (error "The current group does not support article moving"))
9949 ((and (eq action 'crosspost)
9950 (not (gnus-check-backend-function
9951 'request-replace-article gnus-newsgroup-name)))
9952 (error "The current group does not support article editing")))
9953 (let ((articles (gnus-summary-work-articles n))
9954 (prefix (if (gnus-check-backend-function
9955 'request-move-article gnus-newsgroup-name)
9956 (funcall gnus-move-group-prefix-function
9957 gnus-newsgroup-name)
9958 ""))
9959 (names '((move "Move" "Moving")
9960 (copy "Copy" "Copying")
9961 (crosspost "Crosspost" "Crossposting")))
9962 (copy-buf (save-excursion
9963 (nnheader-set-temp-buffer " *copy article*")))
9964 art-group to-method new-xref article to-groups
9965 articles-to-update-marks encoded)
9966 (unless (assq action names)
9967 (error "Unknown action %s" action))
9968 ;; Read the newsgroup name.
9969 (when (and (not to-newsgroup)
9970 (not select-method))
9971 (if (and gnus-move-split-methods
9972 (not
9973 (and (memq gnus-current-article articles)
9974 (gnus-buffer-live-p gnus-original-article-buffer))))
9975 ;; When `gnus-move-split-methods' is non-nil, we have to
9976 ;; select an article to give `gnus-read-move-group-name' an
9977 ;; opportunity to suggest an appropriate default. However,
9978 ;; we needn't render or mark the article.
9979 (let ((gnus-display-mime-function nil)
9980 (gnus-article-prepare-hook nil)
9981 (gnus-mark-article-hook nil))
9982 (gnus-summary-select-article nil nil nil (car articles))))
9983 (setq to-newsgroup (gnus-read-move-group-name
9984 (cadr (assq action names))
9985 (symbol-value
9986 (intern (format "gnus-current-%s-group" action)))
9987 articles prefix)
9988 encoded to-newsgroup
9989 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9990 (set (intern (format "gnus-current-%s-group" action))
9991 (decode-coding-string
9992 to-newsgroup
9993 (gnus-group-name-charset to-method to-newsgroup))))
9994 (unless to-method
9995 (setq to-method (or select-method
9996 (gnus-server-to-method
9997 (gnus-group-method to-newsgroup)))))
9998 (setq to-newsgroup
9999 (or encoded
10000 (and to-newsgroup
10001 (encode-coding-string
10002 to-newsgroup
10003 (gnus-group-name-charset to-method to-newsgroup)))))
10004 ;; Check the method we are to move this article to...
10005 (unless (gnus-check-backend-function
10006 'request-accept-article (car to-method))
10007 (error "%s does not support article copying" (car to-method)))
10008 (unless (gnus-check-server to-method)
10009 (error "Can't open server %s" (car to-method)))
10010 (gnus-message 6 "%s to %s: %s..."
10011 (caddr (assq action names))
10012 (or (car select-method)
10013 (gnus-group-decoded-name to-newsgroup))
10014 articles)
10015 (while articles
10016 (setq article (pop articles))
10017 ;; Set any marks that may have changed in the summary buffer.
10018 (when gnus-preserve-marks
10019 (gnus-summary-push-marks-to-backend article))
10020 (setq
10021 art-group
10022 (cond
10023 ;; Move the article.
10024 ((eq action 'move)
10025 ;; Remove this article from future suppression.
10026 (gnus-dup-unsuppress-article article)
10027 (let* ((from-method (gnus-find-method-for-group
10028 gnus-newsgroup-name))
10029 (to-method (or select-method
10030 (gnus-find-method-for-group to-newsgroup)))
10031 (move-is-internal (gnus-server-equal from-method to-method)))
10032 (gnus-request-move-article
10033 article ; Article to move
10034 gnus-newsgroup-name ; From newsgroup
10035 (nth 1 (gnus-find-method-for-group
10036 gnus-newsgroup-name)) ; Server
10037 (list 'gnus-request-accept-article
10038 to-newsgroup (list 'quote select-method)
10039 (not articles) t) ; Accept form
10040 (not articles) ; Only save nov last time
10041 (and move-is-internal
10042 to-newsgroup ; Not respooling
10043 ; Is this move internal?
10044 (gnus-group-real-name to-newsgroup)))))
10045 ;; Copy the article.
10046 ((eq action 'copy)
10047 (with-current-buffer copy-buf
10048 (when (gnus-request-article-this-buffer article
10049 gnus-newsgroup-name)
10050 (save-restriction
10051 (nnheader-narrow-to-headers)
10052 (dolist (hdr gnus-copy-article-ignored-headers)
10053 (message-remove-header hdr t)))
10054 (gnus-request-accept-article
10055 to-newsgroup select-method (not articles) t))))
10056 ;; Crosspost the article.
10057 ((eq action 'crosspost)
10058 (let ((xref (message-tokenize-header
10059 (mail-header-xref (gnus-summary-article-header
10060 article))
10061 " ")))
10062 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10063 ":" (number-to-string article)))
10064 (unless xref
10065 (setq xref (list (system-name))))
10066 (setq new-xref
10067 (concat
10068 (mapconcat 'identity
10069 (delete "Xref:" (delete new-xref xref))
10070 " ")
10071 " " new-xref))
10072 (with-current-buffer copy-buf
10073 ;; First put the article in the destination group.
10074 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10075 (when (consp (setq art-group
10076 (gnus-request-accept-article
10077 to-newsgroup select-method (not articles)
10078 t)))
10079 (setq new-xref (concat new-xref " " (car art-group)
10081 (number-to-string (cdr art-group))))
10082 ;; Now we have the new Xrefs header, so we insert
10083 ;; it and replace the new article.
10084 (nnheader-replace-header "Xref" new-xref)
10085 (gnus-request-replace-article
10086 (cdr art-group) to-newsgroup (current-buffer) t)
10087 art-group))))))
10088 (cond
10089 ((not art-group)
10090 (gnus-message 1 "Couldn't %s article %s: %s"
10091 (cadr (assq action names)) article
10092 (nnheader-get-report (car to-method))))
10093 ((eq art-group 'junk)
10094 (when (eq action 'move)
10095 (gnus-summary-mark-article article gnus-canceled-mark)
10096 (gnus-message 4 "Deleted article %s" article)
10097 ;; run the delete hook
10098 (run-hook-with-args 'gnus-summary-article-delete-hook
10099 action
10100 (gnus-data-header
10101 (assoc article (gnus-data-list nil)))
10102 gnus-newsgroup-name nil
10103 select-method)))
10105 (let* ((pto-group (gnus-group-prefixed-name
10106 (car art-group) to-method))
10107 (info (gnus-get-info pto-group))
10108 (to-group (gnus-info-group info))
10109 to-marks)
10110 ;; Update the group that has been moved to.
10111 (when (and info
10112 (memq action '(move copy)))
10113 (unless (member to-group to-groups)
10114 (push to-group to-groups))
10116 (when (and (not (memq article gnus-newsgroup-unreads))
10117 (cdr art-group))
10118 (push 'read to-marks)
10119 (gnus-info-set-read
10120 info (gnus-add-to-range (gnus-info-read info)
10121 (list (cdr art-group)))))
10123 ;; See whether the article is to be put in the cache.
10124 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10125 (marks (if expirable
10126 gnus-article-mark-lists
10127 (delete '(expirable . expire)
10128 (copy-sequence
10129 gnus-article-mark-lists))))
10130 (to-article (cdr art-group)))
10132 ;; Enter the article into the cache in the new group,
10133 ;; if that is required.
10134 (when (and to-article
10135 gnus-use-cache)
10136 (gnus-cache-possibly-enter-article
10137 to-group to-article
10138 (memq article gnus-newsgroup-marked)
10139 (memq article gnus-newsgroup-dormant)
10140 (memq article gnus-newsgroup-unreads)))
10142 (when (and gnus-preserve-marks
10143 to-article)
10144 ;; Copy any marks over to the new group.
10145 (when (and (equal to-group gnus-newsgroup-name)
10146 (not (memq article gnus-newsgroup-unreads)))
10147 ;; Mark this article as read in this group.
10148 (push (cons to-article gnus-read-mark)
10149 gnus-newsgroup-reads)
10150 ;; Increase the active status of this group.
10151 (setcdr (gnus-active to-group) to-article)
10152 (setcdr gnus-newsgroup-active to-article))
10154 (while marks
10155 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10156 (when (memq article (symbol-value
10157 (intern (format "gnus-newsgroup-%s"
10158 (caar marks)))))
10159 (push (cdar marks) to-marks)
10160 ;; If the other group is the same as this group,
10161 ;; then we have to add the mark to the list.
10162 (when (equal to-group gnus-newsgroup-name)
10163 (set (intern (format "gnus-newsgroup-%s"
10164 (caar marks)))
10165 (cons to-article
10166 (symbol-value
10167 (intern (format "gnus-newsgroup-%s"
10168 (caar marks)))))))
10169 ;; Copy the marks to other group.
10170 (gnus-add-marked-articles
10171 to-group (cdar marks) (list to-article) info)))
10172 (setq marks (cdr marks)))
10174 (when (and expirable
10175 gnus-mark-copied-or-moved-articles-as-expirable
10176 (not (memq 'expire to-marks)))
10177 ;; Mark this article as expirable.
10178 (push 'expire to-marks)
10179 (when (equal to-group gnus-newsgroup-name)
10180 (push to-article gnus-newsgroup-expirable))
10181 ;; Copy the expirable mark to other group.
10182 (gnus-add-marked-articles
10183 to-group 'expire (list to-article) info))
10185 (when (and to-marks
10186 (gnus-method-option-p
10187 (gnus-find-method-for-group to-group)
10188 'server-marks))
10189 (gnus-request-set-mark
10190 to-group (list (list (list to-article) 'add to-marks)))))
10192 (gnus-dribble-enter
10193 (concat "(gnus-group-set-info '"
10194 (gnus-prin1-to-string (gnus-get-info to-group))
10195 ")")
10196 (concat "^(gnus-group-set-info '(\""
10197 (regexp-quote to-group) "\""))))
10199 ;; Update the Xref header in this article to point to
10200 ;; the new crossposted article we have just created.
10201 (when (eq action 'crosspost)
10202 (with-current-buffer copy-buf
10203 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10204 (nnheader-replace-header "Xref" new-xref)
10205 (gnus-request-replace-article
10206 article gnus-newsgroup-name (current-buffer) t)))
10208 ;; run the move/copy/crosspost/respool hook
10209 (run-hook-with-args 'gnus-summary-article-move-hook
10210 action
10211 (gnus-data-header
10212 (assoc article (gnus-data-list nil)))
10213 gnus-newsgroup-name
10214 to-newsgroup
10215 select-method))
10217 ;;;!!!Why is this necessary?
10218 (set-buffer gnus-summary-buffer)
10220 (when (eq action 'move)
10221 (save-excursion
10222 (gnus-summary-goto-subject article)
10223 (gnus-summary-mark-article article gnus-canceled-mark)))))
10224 (push article articles-to-update-marks))
10226 (save-excursion
10227 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10228 ;; Re-activate all groups that have been moved to.
10229 (with-current-buffer gnus-group-buffer
10230 (let ((gnus-group-marked to-groups))
10231 (gnus-group-get-new-news-this-group nil t)))
10233 (gnus-kill-buffer copy-buf)
10234 (gnus-summary-position-point)
10235 (gnus-set-mode-line 'summary)))
10237 (defun gnus-summary-push-marks-to-backend (article)
10238 (let ((set nil)
10239 (del nil)
10240 (marks gnus-article-mark-lists))
10241 (unless (memq article gnus-newsgroup-unreads)
10242 (push 'read set))
10243 (while marks
10244 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10245 (memq article (symbol-value
10246 (intern (format "gnus-newsgroup-%s"
10247 (caar marks))))))
10248 (push (cdar marks) set)
10249 (push (cdar marks) del))
10250 (pop marks))
10251 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10252 ((,article) del ,del)))))
10254 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10255 "Copy the current article to some other group.
10256 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10257 When called interactively, if TO-NEWSGROUP is nil, use the value of
10258 the variable `gnus-move-split-methods' for finding a default target
10259 newsgroup.
10260 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10261 re-spool using this method."
10262 (interactive "P")
10263 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10265 (defun gnus-summary-crosspost-article (&optional n)
10266 "Crosspost the current article to some other group."
10267 (interactive "P")
10268 (gnus-summary-move-article n nil nil 'crosspost))
10270 (defcustom gnus-summary-respool-default-method nil
10271 "Default method type for respooling an article.
10272 If nil, use to the current newsgroup method."
10273 :type 'symbol
10274 :group 'gnus-summary-mail)
10276 (defun gnus-summary-respool-article (&optional n method)
10277 "Respool the current article.
10278 The article will be squeezed through the mail spooling process again,
10279 which means that it will be put in some mail newsgroup or other
10280 depending on `nnmail-split-methods'.
10281 If N is a positive number, respool the N next articles.
10282 If N is a negative number, respool the N previous articles.
10283 If N is nil and any articles have been marked with the process mark,
10284 respool those articles instead.
10286 Respooling can be done both from mail groups and \"real\" newsgroups.
10287 In the former case, the articles in question will be moved from the
10288 current group into whatever groups they are destined to. In the
10289 latter case, they will be copied into the relevant groups."
10290 (interactive
10291 (list current-prefix-arg
10292 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10293 (methname
10294 (symbol-name (or gnus-summary-respool-default-method
10295 (car (gnus-find-method-for-group
10296 gnus-newsgroup-name)))))
10297 (method
10298 (gnus-completing-read
10299 "Backend to use when respooling"
10300 methods t nil 'gnus-mail-method-history methname))
10302 (cond
10303 ((zerop (length (setq ms (gnus-servers-using-backend
10304 (intern method)))))
10305 (list (intern method) ""))
10306 ((= 1 (length ms))
10307 (car ms))
10309 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10310 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10311 ms-alist))))))))
10312 (unless method
10313 (error "No method given for respooling"))
10314 (if (assoc (symbol-name
10315 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10316 (gnus-methods-using 'respool))
10317 (gnus-summary-move-article n nil method)
10318 (gnus-summary-copy-article n nil method)))
10320 (defun gnus-summary-import-article (file &optional edit)
10321 "Import an arbitrary file into a mail newsgroup."
10322 (interactive "fImport file: \nP")
10323 (let ((group gnus-newsgroup-name)
10324 atts lines group-art)
10325 (unless (gnus-check-backend-function 'request-accept-article group)
10326 (error "%s does not support article importing" group))
10327 (or (file-readable-p file)
10328 (not (file-regular-p file))
10329 (error "Can't read %s" file))
10330 (with-current-buffer (gnus-get-buffer-create " *import file*")
10331 (erase-buffer)
10332 (nnheader-insert-file-contents file)
10333 (goto-char (point-min))
10334 (if (nnheader-article-p)
10335 (save-restriction
10336 (goto-char (point-min))
10337 (search-forward "\n\n" nil t)
10338 (narrow-to-region (point-min) (1- (point)))
10339 (goto-char (point-min))
10340 (unless (re-search-forward "^date:" nil t)
10341 (goto-char (point-max))
10342 (setq atts (file-attributes file))
10343 (insert "Date: " (message-make-date
10344 (file-attribute-modification-time atts))
10345 "\n")))
10346 ;; This doesn't look like an article, so we fudge some headers.
10347 (setq atts (file-attributes file)
10348 lines (count-lines (point-min) (point-max)))
10349 (insert "From: " (read-string "From: ") "\n"
10350 "Subject: " (read-string "Subject: ") "\n"
10351 "Date: " (message-make-date
10352 (file-attribute-modification-time atts)) "\n"
10353 "Message-ID: " (message-make-message-id) "\n"
10354 "Lines: " (int-to-string lines) "\n"
10355 "Chars: " (int-to-string (file-attribute-size atts)) "\n\n"))
10356 (setq group-art (gnus-request-accept-article group nil t))
10357 (kill-buffer (current-buffer)))
10358 (setq gnus-newsgroup-active (gnus-activate-group group))
10359 (forward-line 1)
10360 (gnus-summary-goto-article (cdr group-art) nil t)
10361 (when edit
10362 (gnus-summary-edit-article))))
10364 (defun gnus-summary-create-article ()
10365 "Create an article in a mail newsgroup."
10366 (interactive)
10367 (let ((group gnus-newsgroup-name)
10368 (now (current-time))
10369 group-art)
10370 (unless (gnus-check-backend-function 'request-accept-article group)
10371 (error "%s does not support article importing" group))
10372 (with-current-buffer (gnus-get-buffer-create " *import file*")
10373 (erase-buffer)
10374 (goto-char (point-min))
10375 ;; This doesn't look like an article, so we fudge some headers.
10376 (insert "From: " (read-string "From: ") "\n"
10377 "Subject: " (read-string "Subject: ") "\n"
10378 "Date: " (message-make-date now) "\n"
10379 "Message-ID: " (message-make-message-id) "\n")
10380 (setq group-art (gnus-request-accept-article group nil t))
10381 (kill-buffer (current-buffer)))
10382 (setq gnus-newsgroup-active (gnus-activate-group group))
10383 (forward-line 1)
10384 (gnus-summary-goto-article (cdr group-art) nil t)
10385 (gnus-summary-edit-article)))
10387 (defun gnus-summary-article-posted-p ()
10388 "Say whether the current (mail) article is available from news as well.
10389 This will be the case if the article has both been mailed and posted."
10390 (interactive)
10391 (let ((id (mail-header-references (gnus-summary-article-header)))
10392 (gnus-override-method (car (gnus-refer-article-methods))))
10393 (if (gnus-request-head id "")
10394 (gnus-message 2 "The current message was found on %s"
10395 gnus-override-method)
10396 (gnus-message 2 "The current message couldn't be found on %s"
10397 gnus-override-method)
10398 nil)))
10400 (defun gnus-summary-expire-articles (&optional now)
10401 "Expire all articles that are marked as expirable in the current group."
10402 (interactive)
10403 (when (and (not gnus-group-is-exiting-without-update-p)
10404 (gnus-check-backend-function
10405 'request-expire-articles gnus-newsgroup-name))
10406 ;; This backend supports expiry.
10407 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10408 (expirable
10409 (gnus-list-range-difference
10410 (if total
10411 (progn
10412 ;; We need to update the info for
10413 ;; this group for `gnus-list-of-read-articles'
10414 ;; to give us the right answer.
10415 (gnus-run-hooks 'gnus-exit-group-hook)
10416 (gnus-summary-update-info)
10417 (gnus-list-of-read-articles gnus-newsgroup-name))
10418 (setq gnus-newsgroup-expirable
10419 (sort gnus-newsgroup-expirable '<)))
10420 gnus-newsgroup-unexist))
10421 (expiry-wait (if now 'immediate
10422 (gnus-group-find-parameter
10423 gnus-newsgroup-name 'expiry-wait)))
10424 (nnmail-expiry-target
10425 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10426 nnmail-expiry-target))
10428 (when expirable
10429 ;; There are expirable articles in this group, so we run them
10430 ;; through the expiry process.
10431 (gnus-message 6 "Expiring articles...")
10432 (when (gnus-check-group gnus-newsgroup-name)
10433 ;; The list of articles that weren't expired is returned.
10434 (save-excursion
10435 (if expiry-wait
10436 (let ((nnmail-expiry-wait-function nil)
10437 (nnmail-expiry-wait expiry-wait))
10438 (setq es (gnus-request-expire-articles
10439 expirable gnus-newsgroup-name)))
10440 (setq es (gnus-request-expire-articles
10441 expirable gnus-newsgroup-name)))
10442 (unless total
10443 (setq gnus-newsgroup-expirable es))
10444 ;; We go through the old list of expirable, and mark all
10445 ;; really expired articles as nonexistent.
10446 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10447 (let ((gnus-use-cache nil))
10448 (dolist (article expirable)
10449 (when (and (not (memq article es))
10450 (gnus-data-find article))
10451 (gnus-summary-mark-article article gnus-canceled-mark)
10452 (run-hook-with-args
10453 'gnus-summary-article-expire-hook
10454 'delete
10455 (gnus-data-header (assoc article (gnus-data-list nil)))
10456 gnus-newsgroup-name
10457 (cond
10458 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10459 ((eq nnmail-expiry-target 'delete) nil)
10461 (let ((rescall (funcall nnmail-expiry-target
10462 gnus-newsgroup-name)))
10463 (if (stringp rescall) rescall nil))))
10464 nil)))))))
10465 (gnus-message 6 "Expiring articles...done")))))
10467 (defun gnus-summary-expire-articles-now ()
10468 "Expunge all expirable articles in the current group.
10469 This means that *all* articles that are marked as expirable will be
10470 deleted forever, right now."
10471 (interactive)
10472 (or gnus-expert-user
10473 (gnus-yes-or-no-p
10474 "Are you really, really sure you want to delete all expirable messages? ")
10475 (error "Phew!"))
10476 (gnus-summary-expire-articles t))
10478 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10479 (defun gnus-summary-delete-article (&optional n)
10480 "Delete the N next (mail) articles.
10481 This command actually deletes articles. This is not a marking
10482 command. The article will disappear forever from your life, never to
10483 return.
10485 If N is negative, delete backwards.
10486 If N is nil and articles have been marked with the process mark,
10487 delete these instead.
10489 If `gnus-novice-user' is non-nil you will be asked for
10490 confirmation before the articles are deleted."
10491 (interactive "P")
10492 (unless (gnus-check-backend-function 'request-expire-articles
10493 gnus-newsgroup-name)
10494 (error "The current newsgroup does not support article deletion"))
10495 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10496 (error "Couldn't open server"))
10497 ;; Compute the list of articles to delete.
10498 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10499 (nnmail-expiry-target 'delete)
10500 not-deleted)
10501 (if (and gnus-novice-user
10502 (not (gnus-yes-or-no-p
10503 (format "Do you really want to delete %s forever? "
10504 (if (> (length articles) 1)
10505 (format "these %s articles" (length articles))
10506 "this article")))))
10508 ;; Delete the articles.
10509 (setq not-deleted (gnus-request-expire-articles
10510 articles gnus-newsgroup-name 'force))
10511 (save-excursion
10512 (while articles
10513 (gnus-summary-remove-process-mark (car articles))
10514 ;; The backend might not have been able to delete the article
10515 ;; after all.
10516 (unless (memq (car articles) not-deleted)
10517 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10518 (let* ((article (car articles))
10519 (ghead (gnus-data-header
10520 (assoc article (gnus-data-list nil)))))
10521 (run-hook-with-args 'gnus-summary-article-delete-hook
10522 'delete ghead gnus-newsgroup-name nil
10523 nil)))
10524 (setq articles (cdr articles))))
10525 (when not-deleted
10526 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10527 (gnus-summary-position-point)
10528 (gnus-set-mode-line 'summary)
10529 not-deleted))
10531 (defun gnus-summary-edit-article (&optional arg)
10532 "Edit the current article.
10533 This will have permanent effect only in mail groups.
10534 If ARG is nil, edit the decoded articles.
10535 If ARG is 1, edit the raw articles.
10536 If ARG is 2, edit the raw articles even in read-only groups.
10537 If ARG is 3, edit the articles with the current handles.
10538 Otherwise, allow editing of articles even in read-only
10539 groups."
10540 (interactive "P")
10541 (let (force raw current-handles)
10542 (cond
10543 ((null arg))
10544 ((eq arg 1)
10545 (setq raw t))
10546 ((eq arg 2)
10547 (setq raw t
10548 force t))
10549 ((eq arg 3)
10550 (setq current-handles
10551 (and (gnus-buffer-live-p gnus-article-buffer)
10552 (with-current-buffer gnus-article-buffer
10553 (prog1
10554 gnus-article-mime-handles
10555 (setq gnus-article-mime-handles nil))))))
10557 (setq force t)))
10558 (when (and raw (not force)
10559 (member gnus-newsgroup-name '("nndraft:delayed"
10560 "nndraft:drafts"
10561 "nndraft:queue")))
10562 (error "Can't edit the raw article in group %s"
10563 gnus-newsgroup-name))
10564 (with-current-buffer gnus-summary-buffer
10565 (let ((mail-parse-charset gnus-newsgroup-charset)
10566 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10567 (gnus-set-global-variables)
10568 (when (and (not force)
10569 (gnus-group-read-only-p))
10570 (error "The current newsgroup does not support article editing"))
10571 (gnus-summary-show-article t)
10572 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10573 (with-current-buffer gnus-article-buffer
10574 (mm-enable-multibyte)))
10575 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10576 (setq raw t))
10577 (gnus-article-edit-article
10578 (if raw 'ignore
10579 `(lambda ()
10580 (let ((mbl mml-buffer-list))
10581 (setq mml-buffer-list nil)
10582 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10583 (mime-to-mml ,'current-handles))
10584 (let ((mbl1 mml-buffer-list))
10585 (setq mml-buffer-list mbl)
10586 (set (make-local-variable 'mml-buffer-list) mbl1))
10587 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10588 `(lambda (no-highlight)
10589 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10590 (message-options message-options)
10591 (message-options-set-recipient)
10592 (mail-parse-ignored-charsets
10593 ',gnus-newsgroup-ignored-charsets)
10594 (rfc2047-header-encoding-alist
10595 ',(let ((charset (gnus-group-name-charset
10596 (gnus-find-method-for-group
10597 gnus-newsgroup-name)
10598 gnus-newsgroup-name)))
10599 (append (list (cons "Newsgroups" charset)
10600 (cons "Followup-To" charset)
10601 (cons "Xref" charset))
10602 rfc2047-header-encoding-alist))))
10603 ,(if (not raw) '(progn
10604 (mml-to-mime)
10605 (mml-destroy-buffers)
10606 (remove-hook 'kill-buffer-hook
10607 'mml-destroy-buffers t)
10608 (kill-local-variable 'mml-buffer-list)))
10609 (gnus-summary-edit-article-done
10610 ,(or (mail-header-references gnus-current-headers) "")
10611 ,(gnus-group-read-only-p)
10612 ,gnus-summary-buffer no-highlight))))))))
10614 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10616 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10617 no-highlight)
10618 "Make edits to the current article permanent."
10619 (interactive)
10620 (save-excursion
10621 ;; The buffer restriction contains the entire article if it exists.
10622 (when (article-goto-body)
10623 (let ((lines (count-lines (point) (point-max)))
10624 (length (- (point-max) (point)))
10625 (case-fold-search t)
10626 (body (point-marker)))
10627 (goto-char (point-min))
10628 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10629 (delete-region (match-beginning 1) (match-end 1))
10630 (insert (number-to-string length)))
10631 (goto-char (point-min))
10632 (when (re-search-forward
10633 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10634 (delete-region (match-beginning 1) (match-end 1))
10635 (insert (number-to-string length)))
10636 (goto-char (point-min))
10637 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10638 (delete-region (match-beginning 1) (match-end 1))
10639 (insert (number-to-string lines))))))
10640 ;; Replace the article.
10641 (let ((buf (current-buffer))
10642 (article (cdr gnus-article-current))
10643 replace-result)
10644 (with-temp-buffer
10645 (insert-buffer-substring buf)
10646 (if (and (not read-only)
10647 (not (setq replace-result
10648 (gnus-request-replace-article
10649 article (car gnus-article-current)
10650 (current-buffer) t))))
10651 (error "Couldn't replace article")
10652 ;; If we got a number back, then that's the new article number
10653 ;; for this article. Otherwise, the article number didn't change.
10654 (when (numberp replace-result)
10655 (with-current-buffer gnus-summary-buffer
10656 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10657 (gnus-summary-limit gnus-newsgroup-limit)
10658 (setq article replace-result)
10659 (gnus-summary-goto-subject article t)))
10660 ;; Update the summary buffer.
10661 (if (and references
10662 (equal (message-tokenize-header references " ")
10663 (message-tokenize-header
10664 (or (message-fetch-field "references") "") " ")))
10665 ;; We only have to update this line.
10666 (save-excursion
10667 (save-restriction
10668 (message-narrow-to-head)
10669 (let ((head (buffer-substring-no-properties
10670 (point-min) (point-max)))
10671 header)
10672 (with-temp-buffer
10673 (insert (format "211 %d Article retrieved.\n" article))
10674 (insert head)
10675 (insert ".\n")
10676 (let ((nntp-server-buffer (current-buffer)))
10677 (setq header (car (gnus-get-newsgroup-headers nil t))))
10678 (with-current-buffer gnus-summary-buffer
10679 (gnus-data-set-header (gnus-data-find article) header)
10680 (gnus-summary-update-article-line article header)
10681 (if (gnus-summary-goto-subject article nil t)
10682 (gnus-summary-update-secondary-mark article)))))))
10683 ;; Update threads.
10684 (set-buffer (or buffer gnus-summary-buffer))
10685 (gnus-summary-update-article article)
10686 (if (gnus-summary-goto-subject article nil t)
10687 (gnus-summary-update-secondary-mark article)))
10688 ;; Prettify the article buffer again.
10689 (unless no-highlight
10690 (with-current-buffer gnus-article-buffer
10691 ;;!!! Fix this -- article should be rehighlighted.
10692 ;;(gnus-run-hooks 'gnus-article-display-hook)
10693 (set-buffer gnus-original-article-buffer)
10694 (gnus-request-article
10695 article (car gnus-article-current) (current-buffer))))
10696 ;; Prettify the summary buffer line.
10697 (when (gnus-visual-p 'summary-highlight 'highlight)
10698 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10700 (defun gnus-summary-edit-wash (key)
10701 "Perform editing command KEY in the article buffer."
10702 (interactive
10703 (list
10704 (progn
10705 (message "%s" (concat (this-command-keys) "- "))
10706 (read-char))))
10707 (message "")
10708 (gnus-summary-edit-article)
10709 (execute-kbd-macro (concat (this-command-keys) key))
10710 (gnus-article-edit-done))
10712 ;;; Respooling
10714 (defvar nnimap-split-fancy)
10715 (defvar nnimap-split-methods)
10717 (defun gnus-summary-respool-query (&optional silent trace)
10718 "Query where the respool algorithm would put this article."
10719 (interactive)
10720 (let (gnus-mark-article-hook)
10721 (gnus-summary-select-article)
10722 (with-current-buffer gnus-original-article-buffer
10723 (let ((groups
10724 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10725 'nnimap)
10726 ;; nnimap has its own splitting variables.
10727 (let ((nnmail-split-methods
10728 (cond
10729 ((eq nnimap-split-methods 'default)
10730 nnmail-split-methods)
10731 (nnimap-split-methods
10732 nnimap-split-methods)
10733 (nnimap-split-fancy
10734 'nnmail-split-fancy)))
10735 (nnmail-split-fancy (or nnimap-split-fancy
10736 nnmail-split-fancy)))
10737 (nnmail-article-group 'identity trace))
10738 (nnmail-article-group 'identity trace))))
10739 (unless silent
10740 (if groups
10741 (message "This message would go to %s"
10742 (mapconcat 'car groups ", "))
10743 (message "This message would go to no groups"))
10744 groups)))))
10746 (defun gnus-summary-respool-trace ()
10747 "Trace where the respool algorithm would put this article.
10748 Display a buffer showing all fancy splitting patterns which matched."
10749 (interactive)
10750 (gnus-summary-respool-query nil t))
10752 ;; Summary marking commands.
10754 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10755 "Mark articles which has the same subject as read, and then select the next.
10756 If UNMARK is positive, remove any kind of mark.
10757 If UNMARK is negative, tick articles."
10758 (interactive "P")
10759 (when unmark
10760 (setq unmark (prefix-numeric-value unmark)))
10761 (let ((count
10762 (gnus-summary-mark-same-subject
10763 (gnus-summary-article-subject) unmark)))
10764 ;; Select next unread article. If auto-select-same mode, should
10765 ;; select the first unread article.
10766 (gnus-summary-next-article t (and gnus-auto-select-same
10767 (gnus-summary-article-subject)))
10768 (gnus-message 7 "%d article%s marked as %s"
10769 count (if (= count 1) " is" "s are")
10770 (if unmark "unread" "read"))))
10772 (defun gnus-summary-kill-same-subject (&optional unmark)
10773 "Mark articles which has the same subject as read.
10774 If UNMARK is positive, remove any kind of mark.
10775 If UNMARK is negative, tick articles."
10776 (interactive "P")
10777 (when unmark
10778 (setq unmark (prefix-numeric-value unmark)))
10779 (let ((count
10780 (gnus-summary-mark-same-subject
10781 (gnus-summary-article-subject) unmark)))
10782 ;; If marked as read, go to next unread subject.
10783 (when (null unmark)
10784 ;; Go to next unread subject.
10785 (gnus-summary-next-subject 1 t))
10786 (gnus-message 7 "%d articles are marked as %s"
10787 count (if unmark "unread" "read"))))
10789 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10790 "Mark articles with same SUBJECT as read, and return marked number.
10791 If optional argument UNMARK is positive, remove any kinds of marks.
10792 If optional argument UNMARK is negative, mark articles as unread instead."
10793 (let ((count 1))
10794 (save-excursion
10795 (cond
10796 ((null unmark) ; Mark as read.
10797 (while (and
10798 (progn
10799 (gnus-summary-mark-article-as-read gnus-killed-mark)
10800 (gnus-summary-show-thread) t)
10801 (gnus-summary-find-subject subject))
10802 (setq count (1+ count))))
10803 ((> unmark 0) ; Tick.
10804 (while (and
10805 (progn
10806 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10807 (gnus-summary-show-thread) t)
10808 (gnus-summary-find-subject subject))
10809 (setq count (1+ count))))
10810 (t ; Mark as unread.
10811 (while (and
10812 (progn
10813 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10814 (gnus-summary-show-thread) t)
10815 (gnus-summary-find-subject subject))
10816 (setq count (1+ count)))))
10817 (gnus-set-mode-line 'summary)
10818 ;; Return the number of marked articles.
10819 count)))
10821 (defun gnus-summary-mark-as-processable (n &optional unmark)
10822 "Set the process mark on the next N articles.
10823 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10824 the process mark instead. The difference between N and the actual
10825 number of articles marked is returned."
10826 (interactive "P")
10827 (if (and (null n) (and transient-mark-mode mark-active))
10828 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10829 (setq n (prefix-numeric-value n))
10830 (let ((backward (< n 0))
10831 (n (abs n)))
10832 (while (and
10833 (> n 0)
10834 (if unmark
10835 (gnus-summary-remove-process-mark
10836 (gnus-summary-article-number))
10837 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10838 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10839 (setq n (1- n)))
10840 (when (/= 0 n)
10841 (gnus-message 7 "No more articles"))
10842 (gnus-summary-recenter)
10843 (gnus-summary-position-point)
10844 n)))
10846 (defun gnus-summary-unmark-as-processable (n)
10847 "Remove the process mark from the next N articles.
10848 If N is negative, unmark backward instead. The difference between N and
10849 the actual number of articles unmarked is returned."
10850 (interactive "P")
10851 (gnus-summary-mark-as-processable n t))
10853 (defun gnus-summary-unmark-all-processable ()
10854 "Remove the process mark from all articles."
10855 (interactive)
10856 (save-excursion
10857 (while gnus-newsgroup-processable
10858 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10859 (gnus-summary-position-point))
10861 (defun gnus-summary-add-mark (article type)
10862 "Mark ARTICLE with a mark of TYPE."
10863 (let ((vtype (car (assq type gnus-article-mark-lists)))
10864 var)
10865 (if (not vtype)
10866 (error "No such mark type: %s" type)
10867 (setq var (intern (format "gnus-newsgroup-%s" type)))
10868 (set var (cons article (symbol-value var)))
10869 (if (memq type '(processable cached replied forwarded recent saved))
10870 (gnus-summary-update-secondary-mark article)
10871 ;;; !!! This is bogus. We should find out what primary
10872 ;;; !!! mark we want to set.
10873 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10875 (defun gnus-summary-mark-as-expirable (n)
10876 "Mark N articles forward as expirable.
10877 If N is negative, mark backward instead. The difference between N and
10878 the actual number of articles marked is returned."
10879 (interactive "p")
10880 (gnus-summary-mark-forward n gnus-expirable-mark))
10882 (defun gnus-summary-mark-as-spam (n)
10883 "Mark N articles forward as spam.
10884 If N is negative, mark backward instead. The difference between N and
10885 the actual number of articles marked is returned."
10886 (interactive "p")
10887 (gnus-summary-mark-forward n gnus-spam-mark))
10889 (defun gnus-summary-mark-article-as-replied (article)
10890 "Mark ARTICLE as replied to and update the summary line.
10891 ARTICLE can also be a list of articles."
10892 (interactive (list (gnus-summary-article-number)))
10893 (let ((articles (if (listp article) article (list article))))
10894 (dolist (article articles)
10895 (unless (numberp article)
10896 (error "%s is not a number" article))
10897 (push article gnus-newsgroup-replied)
10898 (let ((inhibit-read-only t))
10899 (when (gnus-summary-goto-subject article nil t)
10900 (gnus-summary-update-secondary-mark article))))))
10902 (defun gnus-summary-mark-article-as-forwarded (article)
10903 "Mark ARTICLE as forwarded and update the summary line.
10904 ARTICLE can also be a list of articles."
10905 (let ((articles (if (listp article) article (list article))))
10906 (dolist (article articles)
10907 (push article gnus-newsgroup-forwarded)
10908 (let ((inhibit-read-only t))
10909 (when (gnus-summary-goto-subject article nil t)
10910 (gnus-summary-update-secondary-mark article))))))
10912 (defun gnus-summary-set-bookmark (article)
10913 "Set a bookmark in current article."
10914 (interactive (list (gnus-summary-article-number)))
10915 (when (or (not (get-buffer gnus-article-buffer))
10916 (not gnus-current-article)
10917 (not gnus-article-current)
10918 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10919 (error "No current article selected"))
10920 ;; Remove old bookmark, if one exists.
10921 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10922 ;; Set the new bookmark, which is on the form
10923 ;; (article-number . line-number-in-body).
10924 (push
10925 (cons article
10926 (with-current-buffer gnus-article-buffer
10927 (count-lines
10928 (min (point)
10929 (save-excursion
10930 (article-goto-body)
10931 (point)))
10932 (point))))
10933 gnus-newsgroup-bookmarks)
10934 (gnus-message 6 "A bookmark has been added to the current article."))
10936 (defun gnus-summary-remove-bookmark (article)
10937 "Remove the bookmark from the current article."
10938 (interactive (list (gnus-summary-article-number)))
10939 ;; Remove old bookmark, if one exists.
10940 (if (not (assq article gnus-newsgroup-bookmarks))
10941 (gnus-message 6 "No bookmark in current article.")
10942 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10943 (gnus-message 6 "Removed bookmark.")))
10945 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10946 (defun gnus-summary-mark-as-dormant (n)
10947 "Mark N articles forward as dormant.
10948 If N is negative, mark backward instead. The difference between N and
10949 the actual number of articles marked is returned."
10950 (interactive "p")
10951 (gnus-summary-mark-forward n gnus-dormant-mark))
10953 (defun gnus-summary-set-process-mark (article)
10954 "Set the process mark on ARTICLE and update the summary line."
10955 (setq gnus-newsgroup-processable
10956 (cons article
10957 (delq article gnus-newsgroup-processable)))
10958 (when (gnus-summary-goto-subject article)
10959 (gnus-summary-show-thread)
10960 (gnus-summary-goto-subject article)
10961 (gnus-summary-update-secondary-mark article)))
10963 (defun gnus-summary-remove-process-mark (&rest articles)
10964 "Remove the process mark from ARTICLES and update the summary line."
10965 (dolist (article articles)
10966 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10967 (when (gnus-summary-goto-subject article)
10968 (gnus-summary-show-thread)
10969 (gnus-summary-goto-subject article)
10970 (gnus-summary-update-secondary-mark article)))
10973 (defun gnus-summary-set-saved-mark (article)
10974 "Set the process mark on ARTICLE and update the summary line."
10975 (push article gnus-newsgroup-saved)
10976 (when (gnus-summary-goto-subject article)
10977 (gnus-summary-update-secondary-mark article)))
10979 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10980 "Mark N articles as read forwards.
10981 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10982 The difference between N and the actual number of articles marked is
10983 returned.
10984 If NO-EXPIRE, auto-expiry will be inhibited."
10985 (interactive "p")
10986 (gnus-summary-show-thread)
10987 (let ((backward (< n 0))
10988 (gnus-summary-goto-unread
10989 (and gnus-summary-goto-unread
10990 (not (eq gnus-summary-goto-unread 'never))
10991 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10992 gnus-ticked-mark gnus-dormant-mark)))))
10993 (n (abs n))
10994 (mark (or mark gnus-del-mark)))
10995 (while (and (> n 0)
10996 (gnus-summary-mark-article nil mark no-expire)
10997 (zerop (gnus-summary-next-subject
10998 (if backward -1 1)
10999 (and gnus-summary-goto-unread
11000 (not (eq gnus-summary-goto-unread 'never)))
11001 t)))
11002 (setq n (1- n)))
11003 (when (/= 0 n)
11004 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11005 (gnus-summary-recenter)
11006 (gnus-summary-position-point)
11007 (gnus-set-mode-line 'summary)
11010 (defun gnus-summary-mark-article-as-read (mark)
11011 "Mark the current article quickly as read with MARK."
11012 (let ((article (gnus-summary-article-number)))
11013 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11014 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11015 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11016 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11017 (push (cons article mark) gnus-newsgroup-reads)
11018 ;; Possibly remove from cache, if that is used.
11019 (when gnus-use-cache
11020 (gnus-cache-enter-remove-article article))
11021 ;; Allow the backend to change the mark.
11022 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11023 ;; Check for auto-expiry.
11024 (when (and gnus-newsgroup-auto-expire
11025 (memq mark gnus-auto-expirable-marks))
11026 (setq mark gnus-expirable-mark)
11027 ;; Let the backend know about the mark change.
11028 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11029 (push article gnus-newsgroup-expirable))
11030 ;; Set the mark in the buffer.
11031 (gnus-summary-update-mark mark 'unread)
11034 (defun gnus-summary-mark-article-as-unread (mark)
11035 "Mark the current article quickly as unread with MARK."
11036 (let* ((article (gnus-summary-article-number))
11037 (old-mark (gnus-summary-article-mark article)))
11038 ;; Allow the backend to change the mark.
11039 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11040 (if (eq mark old-mark)
11042 (if (<= article 0)
11043 (progn
11044 (gnus-error 1 "Can't mark negative article numbers")
11045 nil)
11046 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11047 (setq gnus-newsgroup-spam-marked
11048 (delq article gnus-newsgroup-spam-marked))
11049 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11050 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11051 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11052 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11053 (cond ((= mark gnus-ticked-mark)
11054 (setq gnus-newsgroup-marked
11055 (gnus-add-to-sorted-list gnus-newsgroup-marked
11056 article)))
11057 ((= mark gnus-spam-mark)
11058 (setq gnus-newsgroup-spam-marked
11059 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11060 article)))
11061 ((= mark gnus-dormant-mark)
11062 (setq gnus-newsgroup-dormant
11063 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11064 article)))
11066 (setq gnus-newsgroup-unreads
11067 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11068 article))))
11069 (gnus-alist-pull article gnus-newsgroup-reads)
11071 ;; See whether the article is to be put in the cache.
11072 (and gnus-use-cache
11073 (vectorp (gnus-summary-article-header article))
11074 (save-excursion
11075 (gnus-cache-possibly-enter-article
11076 gnus-newsgroup-name article
11077 (= mark gnus-ticked-mark)
11078 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11080 ;; Fix the mark.
11081 (gnus-summary-update-mark mark 'unread)
11082 t))))
11084 (defun gnus-summary-mark-article (&optional article mark no-expire)
11085 "Mark ARTICLE with MARK. MARK can be any character.
11086 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11087 `??' (dormant) and `?E' (expirable).
11088 If MARK is nil, then the default character `?r' is used.
11089 If ARTICLE is nil, then the article on the current line will be
11090 marked.
11091 If NO-EXPIRE, auto-expiry will be inhibited."
11092 ;; The mark might be a string.
11093 (when (stringp mark)
11094 (setq mark (aref mark 0)))
11095 ;; If no mark is given, then we check auto-expiring.
11096 (when (null mark)
11097 (setq mark gnus-del-mark))
11098 (when (and (not no-expire)
11099 gnus-newsgroup-auto-expire
11100 (memq mark gnus-auto-expirable-marks))
11101 (setq mark gnus-expirable-mark))
11102 (let ((article (or article (gnus-summary-article-number)))
11103 (old-mark (gnus-summary-article-mark article)))
11104 ;; Allow the backend to change the mark.
11105 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11106 (if (eq mark old-mark)
11108 (unless article
11109 (error "No article on current line"))
11110 (if (not (if (or (= mark gnus-unread-mark)
11111 (= mark gnus-ticked-mark)
11112 (= mark gnus-spam-mark)
11113 (= mark gnus-dormant-mark))
11114 (gnus-mark-article-as-unread article mark)
11115 (gnus-mark-article-as-read article mark)))
11117 ;; See whether the article is to be put in the cache.
11118 (and gnus-use-cache
11119 (not (= mark gnus-canceled-mark))
11120 (vectorp (gnus-summary-article-header article))
11121 (save-excursion
11122 (gnus-cache-possibly-enter-article
11123 gnus-newsgroup-name article
11124 (= mark gnus-ticked-mark)
11125 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11127 (when (gnus-summary-goto-subject article nil t)
11128 (let ((inhibit-read-only t))
11129 (gnus-summary-show-thread)
11130 ;; Fix the mark.
11131 (gnus-summary-update-mark mark 'unread)
11132 t))))))
11134 (defun gnus-summary-update-secondary-mark (article)
11135 "Update the secondary (read, process, cache) mark."
11136 (gnus-summary-update-mark
11137 (cond ((memq article gnus-newsgroup-processable)
11138 gnus-process-mark)
11139 ((memq article gnus-newsgroup-cached)
11140 gnus-cached-mark)
11141 ((memq article gnus-newsgroup-replied)
11142 gnus-replied-mark)
11143 ((memq article gnus-newsgroup-forwarded)
11144 gnus-forwarded-mark)
11145 ((memq article gnus-newsgroup-saved)
11146 gnus-saved-mark)
11147 ((memq article gnus-newsgroup-unseen)
11148 gnus-unseen-mark)
11149 (t gnus-no-mark))
11150 'replied)
11151 (when (gnus-visual-p 'summary-highlight 'highlight)
11152 (gnus-summary-highlight-line)
11153 (gnus-run-hooks 'gnus-summary-update-hook))
11156 (defun gnus-summary-update-download-mark (article)
11157 "Update the download mark."
11158 (gnus-summary-update-mark
11159 (cond ((memq article gnus-newsgroup-undownloaded)
11160 gnus-undownloaded-mark)
11161 (gnus-newsgroup-agentized
11162 gnus-downloaded-mark)
11164 gnus-no-mark))
11165 'download)
11166 (gnus-summary-update-line t)
11169 (defun gnus-summary-update-mark (mark type)
11170 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11171 (inhibit-read-only t))
11172 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11173 (when forward
11174 (when (looking-at "\r")
11175 (cl-incf forward))
11176 (when (<= (+ forward (point)) (point-max))
11177 ;; Go to the right position on the line.
11178 (goto-char (+ forward (point)))
11179 ;; Replace the old mark with the new mark.
11180 (let ((to-insert
11181 (subst-char-in-string
11182 (char-after) mark
11183 (buffer-substring (point) (1+ (point))))))
11184 (delete-region (point) (1+ (point)))
11185 (insert to-insert))
11186 ;; Optionally update the marks by some user rule.
11187 (when (eq type 'unread)
11188 (gnus-data-set-mark
11189 (gnus-data-find (gnus-summary-article-number)) mark)
11190 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11192 (defun gnus-mark-article-as-read (article &optional mark)
11193 "Enter ARTICLE in the pertinent lists and remove it from others."
11194 ;; Make the article expirable.
11195 (let ((mark (or mark gnus-del-mark)))
11196 (setq gnus-newsgroup-expirable
11197 (if (= mark gnus-expirable-mark)
11198 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11199 (delq article gnus-newsgroup-expirable)))
11200 ;; Remove from unread and marked lists.
11201 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11202 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11203 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11204 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11205 (push (cons article mark) gnus-newsgroup-reads)
11206 ;; Possibly remove from cache, if that is used.
11207 (when gnus-use-cache
11208 (gnus-cache-enter-remove-article article))
11211 (defun gnus-mark-article-as-unread (article &optional mark)
11212 "Enter ARTICLE in the pertinent lists and remove it from others."
11213 (let ((mark (or mark gnus-ticked-mark)))
11214 (if (<= article 0)
11215 (progn
11216 (gnus-error 1 "Can't mark negative article numbers")
11217 nil)
11218 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11219 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11220 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11221 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11222 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11224 ;; Unsuppress duplicates?
11225 (when gnus-suppress-duplicates
11226 (gnus-dup-unsuppress-article article))
11228 (cond ((= mark gnus-ticked-mark)
11229 (setq gnus-newsgroup-marked
11230 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11231 ((= mark gnus-spam-mark)
11232 (setq gnus-newsgroup-spam-marked
11233 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11234 article)))
11235 ((= mark gnus-dormant-mark)
11236 (setq gnus-newsgroup-dormant
11237 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11239 (setq gnus-newsgroup-unreads
11240 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11241 (gnus-alist-pull article gnus-newsgroup-reads)
11242 t)))
11244 (defun gnus-summary-tick-article-forward (n)
11245 "Tick N articles forwards.
11246 If N is negative, tick backwards instead.
11247 The difference between N and the number of articles ticked is returned."
11248 (interactive "p")
11249 (gnus-summary-mark-forward n gnus-ticked-mark))
11251 (defun gnus-summary-tick-article-backward (n)
11252 "Tick N articles backwards.
11253 The difference between N and the number of articles ticked is returned."
11254 (interactive "p")
11255 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11257 (defun gnus-summary-tick-article (&optional article clear-mark)
11258 "Mark current article as unread.
11259 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11260 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11261 (interactive)
11262 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11263 gnus-ticked-mark)))
11265 (defun gnus-summary-mark-as-read-forward (n)
11266 "Mark N articles as read forwards.
11267 If N is negative, mark backwards instead.
11268 The difference between N and the actual number of articles marked is
11269 returned."
11270 (interactive "p")
11271 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11273 (defun gnus-summary-mark-as-read-backward (n)
11274 "Mark the N articles as read backwards.
11275 The difference between N and the actual number of articles marked is
11276 returned."
11277 (interactive "p")
11278 (gnus-summary-mark-forward
11279 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11281 (defun gnus-summary-mark-as-read (&optional article mark)
11282 "Mark current article as read.
11283 ARTICLE specifies the article to be marked as read.
11284 MARK specifies a string to be inserted at the beginning of the line."
11285 (gnus-summary-mark-article article mark))
11287 (defun gnus-summary-clear-mark-forward (n)
11288 "Clear marks from N articles forward.
11289 If N is negative, clear backward instead.
11290 The difference between N and the number of marks cleared is returned."
11291 (interactive "p")
11292 (gnus-summary-mark-forward n gnus-unread-mark))
11294 (defun gnus-summary-clear-mark-backward (n)
11295 "Clear marks from N articles backward.
11296 The difference between N and the number of marks cleared is returned."
11297 (interactive "p")
11298 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11300 (defun gnus-summary-mark-unread-as-read ()
11301 "Intended to be used by `gnus-mark-article-hook'."
11302 (when (memq gnus-current-article gnus-newsgroup-unreads)
11303 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11305 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11306 "Intended to be used by `gnus-mark-article-hook'."
11307 (let ((mark (gnus-summary-article-mark)))
11308 (when (or (gnus-unread-mark-p mark)
11309 (gnus-read-mark-p mark))
11310 (gnus-summary-mark-article gnus-current-article
11311 (or new-mark gnus-read-mark)))))
11313 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11314 "Intended to be used by `gnus-mark-article-hook'."
11315 (let ((mark (gnus-summary-article-mark)))
11316 (when (or (gnus-unread-mark-p mark)
11317 (gnus-read-mark-p mark))
11318 (gnus-summary-mark-article (gnus-summary-article-number)
11319 (or new-mark gnus-read-mark)))))
11321 (defun gnus-summary-mark-unread-as-ticked ()
11322 "Intended to be used by `gnus-mark-article-hook'."
11323 (when (memq gnus-current-article gnus-newsgroup-unreads)
11324 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11326 (defun gnus-summary-mark-region-as-read (point mark all)
11327 "Mark all unread articles between point and mark as read.
11328 If given a prefix, mark all articles between point and mark as read,
11329 even ticked and dormant ones."
11330 (interactive "r\nP")
11331 (save-excursion
11332 (let (article)
11333 (goto-char point)
11334 (beginning-of-line)
11335 (while (and
11336 (< (point) mark)
11337 (progn
11338 (when (or all
11339 (memq (setq article (gnus-summary-article-number))
11340 gnus-newsgroup-unreads))
11341 (gnus-summary-mark-article article gnus-del-mark))
11343 (gnus-summary-find-next))))))
11345 (defun gnus-summary-mark-below (score mark)
11346 "Mark articles with score less than SCORE with MARK."
11347 (interactive "P\ncMark: ")
11348 (setq score (if score
11349 (prefix-numeric-value score)
11350 (or gnus-summary-default-score 0)))
11351 (with-current-buffer gnus-summary-buffer
11352 (goto-char (point-min))
11353 (while
11354 (progn
11355 (and (< (gnus-summary-article-score) score)
11356 (gnus-summary-mark-article nil mark))
11357 (gnus-summary-find-next)))))
11359 (defun gnus-summary-kill-below (&optional score)
11360 "Mark articles with score below SCORE as read."
11361 (interactive "P")
11362 (gnus-summary-mark-below score gnus-killed-mark))
11364 (defun gnus-summary-clear-above (&optional score)
11365 "Clear all marks from articles with score above SCORE."
11366 (interactive "P")
11367 (gnus-summary-mark-above score gnus-unread-mark))
11369 (defun gnus-summary-tick-above (&optional score)
11370 "Tick all articles with score above SCORE."
11371 (interactive "P")
11372 (gnus-summary-mark-above score gnus-ticked-mark))
11374 (defun gnus-summary-mark-above (score mark)
11375 "Mark articles with score over SCORE with MARK."
11376 (interactive "P\ncMark: ")
11377 (setq score (if score
11378 (prefix-numeric-value score)
11379 (or gnus-summary-default-score 0)))
11380 (with-current-buffer gnus-summary-buffer
11381 (goto-char (point-min))
11382 (while (and (progn
11383 (when (> (gnus-summary-article-score) score)
11384 (gnus-summary-mark-article nil mark))
11386 (gnus-summary-find-next)))))
11388 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11389 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11390 (defun gnus-summary-limit-include-expunged (&optional no-error)
11391 "Display all the hidden articles that were expunged for low scores."
11392 (interactive)
11393 (let ((inhibit-read-only t))
11394 (let ((scored gnus-newsgroup-scored)
11395 headers h)
11396 (while scored
11397 (unless (gnus-summary-article-header (caar scored))
11398 (and (setq h (gnus-number-to-header (caar scored)))
11399 (< (cdar scored) gnus-summary-expunge-below)
11400 (push h headers)))
11401 (setq scored (cdr scored)))
11402 (if (not headers)
11403 (when (not no-error)
11404 (error "No expunged articles hidden"))
11405 (goto-char (point-min))
11406 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11407 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11408 (dolist (x headers)
11409 (push (mail-header-number x) gnus-newsgroup-limit))
11410 (gnus-summary-prepare-unthreaded (nreverse headers))
11411 (goto-char (point-min))
11412 (gnus-summary-position-point)
11413 t))))
11415 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11416 "Mark all unread articles in this newsgroup as read.
11417 If prefix argument ALL is non-nil, ticked and dormant articles will
11418 also be marked as read.
11419 If QUIETLY is non-nil, no questions will be asked.
11421 If TO-HERE is non-nil, it should be a point in the buffer. All
11422 articles before (after, if REVERSE is set) this point will be marked
11423 as read.
11425 Note that this function will only catch up the unread article
11426 in the current summary buffer limitation.
11428 The number of articles marked as read is returned."
11429 (interactive "P")
11430 (prog1
11431 (save-excursion
11432 (when (or quietly
11433 (not gnus-interactive-catchup) ;Without confirmation?
11434 gnus-expert-user
11435 (gnus-y-or-n-p
11436 (if all
11437 "Mark absolutely all articles as read? "
11438 "Mark all unread articles as read? ")))
11439 (if (and not-mark
11440 (not gnus-newsgroup-adaptive)
11441 (not gnus-newsgroup-auto-expire)
11442 (not gnus-suppress-duplicates)
11443 (or (not gnus-use-cache)
11444 (eq gnus-use-cache 'passive)))
11445 (progn
11446 (when all
11447 (setq gnus-newsgroup-marked nil
11448 gnus-newsgroup-spam-marked nil
11449 gnus-newsgroup-dormant nil))
11450 (setq gnus-newsgroup-unreads
11451 (gnus-sorted-nunion
11452 (gnus-sorted-intersection gnus-newsgroup-unreads
11453 gnus-newsgroup-downloadable)
11454 (gnus-sorted-difference gnus-newsgroup-unfetched
11455 gnus-newsgroup-cached))))
11456 ;; We actually mark all articles as canceled, which we
11457 ;; have to do when using auto-expiry or adaptive scoring.
11458 (gnus-summary-show-all-threads)
11459 (if (and to-here reverse)
11460 (progn
11461 (goto-char to-here)
11462 (gnus-summary-mark-current-read-and-unread-as-read
11463 gnus-catchup-mark)
11464 (while (gnus-summary-find-next (not all))
11465 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11466 (when (gnus-summary-first-subject (not all))
11467 (while (and
11468 (if to-here (< (point) to-here) t)
11469 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11470 (gnus-summary-find-next (not all))))))
11471 (gnus-set-mode-line 'summary))
11473 (gnus-summary-position-point)))
11475 (defun gnus-summary-catchup-to-here (&optional all)
11476 "Mark all unticked articles before the current one as read.
11477 If ALL is non-nil, also mark ticked and dormant articles as read."
11478 (interactive "P")
11479 (save-excursion
11480 (gnus-save-hidden-threads
11481 (let ((beg (point)))
11482 ;; We check that there are unread articles.
11483 (when (or all (gnus-summary-find-prev))
11484 (gnus-summary-catchup all t beg)))))
11485 (gnus-summary-position-point))
11487 (defun gnus-summary-catchup-from-here (&optional all)
11488 "Mark all unticked articles after (and including) the current one as read.
11489 If ALL is non-nil, also mark ticked and dormant articles as read."
11490 (interactive "P")
11491 (save-excursion
11492 (gnus-save-hidden-threads
11493 (let ((beg (point)))
11494 ;; We check that there are unread articles.
11495 (when (or all (gnus-summary-find-next))
11496 (gnus-summary-catchup all t beg nil t)))))
11497 (gnus-summary-position-point))
11499 (defun gnus-summary-catchup-all (&optional quietly)
11500 "Mark all articles in this newsgroup as read.
11501 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11502 instead, which marks only unread articles as read."
11503 (interactive "P")
11504 (gnus-summary-catchup t quietly))
11506 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11507 "Mark all unread articles in this group as read, then exit.
11508 If prefix argument ALL is non-nil, all articles are marked as read.
11509 If QUIETLY is non-nil, no questions will be asked."
11510 (interactive "P")
11511 (when (gnus-summary-catchup all quietly nil 'fast)
11512 ;; Select next newsgroup or exit.
11513 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11514 (eq gnus-auto-select-next 'quietly))
11515 (gnus-summary-next-group nil)
11516 (gnus-summary-exit))))
11518 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11519 "Mark all articles in this newsgroup as read, and then exit.
11520 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11521 instead, which marks only unread articles as read."
11522 (interactive "P")
11523 (gnus-summary-catchup-and-exit t quietly))
11525 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11526 "Mark all articles in this group as read and select the next group.
11527 If given a prefix, mark all articles, unread as well as ticked, as
11528 read."
11529 (interactive "P")
11530 (save-excursion
11531 (gnus-summary-catchup all))
11532 (gnus-summary-next-group))
11534 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11535 "Mark all articles in this group as read and select the previous group.
11536 If given a prefix, mark all articles, unread as well as ticked, as
11537 read."
11538 (interactive "P")
11539 (save-excursion
11540 (gnus-summary-catchup all))
11541 (gnus-summary-next-group nil nil t))
11544 ;;; with article
11547 (defmacro gnus-with-article (article &rest forms)
11548 "Select ARTICLE and perform FORMS in the original article buffer.
11549 Then replace the article with the result."
11550 `(progn
11551 ;; We don't want the article to be marked as read.
11552 (let (gnus-mark-article-hook)
11553 (gnus-summary-select-article t t nil ,article))
11554 (set-buffer gnus-original-article-buffer)
11555 ,@forms
11556 (if (not (gnus-check-backend-function
11557 'request-replace-article (car gnus-article-current)))
11558 (gnus-message 5 "Read-only group; not replacing")
11559 (unless (gnus-request-replace-article
11560 ,article (car gnus-article-current)
11561 (current-buffer) t)
11562 (error "Couldn't replace article")))
11563 ;; The cache and backlog have to be flushed somewhat.
11564 (when gnus-keep-backlog
11565 (gnus-backlog-remove-article
11566 (car gnus-article-current) (cdr gnus-article-current)))
11567 (when gnus-use-cache
11568 (gnus-cache-update-article
11569 (car gnus-article-current) (cdr gnus-article-current)))))
11571 (put 'gnus-with-article 'lisp-indent-function 1)
11572 (put 'gnus-with-article 'edebug-form-spec '(form body))
11574 ;; Thread-based commands.
11576 (defun gnus-summary-articles-in-thread (&optional article)
11577 "Return a list of all articles in the current thread.
11578 If ARTICLE is non-nil, return all articles in the thread that starts
11579 with that article."
11580 (let* ((article (or article (gnus-summary-article-number)))
11581 (data (gnus-data-find-list article))
11582 (top-level (gnus-data-level (car data)))
11583 (top-subject
11584 (cond ((null gnus-thread-operation-ignore-subject)
11585 (gnus-simplify-subject-re
11586 (mail-header-subject (gnus-data-header (car data)))))
11587 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11588 (gnus-simplify-subject-fuzzy
11589 (mail-header-subject (gnus-data-header (car data)))))
11590 (t nil)))
11591 (end-point (save-excursion
11592 (goto-char (gnus-data-pos (car data)))
11593 (if (gnus-summary-go-to-next-thread)
11594 (point) (point-max))))
11595 articles)
11596 (while (and data
11597 (< (gnus-data-pos (car data)) end-point))
11598 (when (or (not top-subject)
11599 (string= top-subject
11600 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11601 (gnus-simplify-subject-fuzzy
11602 (mail-header-subject
11603 (gnus-data-header (car data))))
11604 (gnus-simplify-subject-re
11605 (mail-header-subject
11606 (gnus-data-header (car data)))))))
11607 (push (gnus-data-number (car data)) articles))
11608 (unless (and (setq data (cdr data))
11609 (> (gnus-data-level (car data)) top-level))
11610 (setq data nil)))
11611 ;; Return the list of articles.
11612 (nreverse articles)))
11614 (defun gnus-summary-rethread-current ()
11615 "Rethread the thread the current article is part of."
11616 (interactive)
11617 (let* ((gnus-show-threads t)
11618 (article (gnus-summary-article-number))
11619 (id (mail-header-id (gnus-summary-article-header)))
11620 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11621 (unless id
11622 (error "No article on the current line"))
11623 (gnus-rebuild-thread id)
11624 (gnus-summary-goto-subject article)))
11626 (defun gnus-summary-reparent-thread ()
11627 "Make the current article child of the marked (or previous) article.
11629 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11630 is non-nil or the Subject: of both articles are the same."
11631 (interactive)
11632 (unless (not (gnus-group-read-only-p))
11633 (error "The current newsgroup does not support article editing"))
11634 (unless (<= (length gnus-newsgroup-processable) 1)
11635 (error "No more than one article may be marked"))
11636 (let ((child (gnus-summary-article-number))
11637 ;; First grab the marked article, otherwise one line up.
11638 (parent (if (not (null gnus-newsgroup-processable))
11639 (car gnus-newsgroup-processable)
11640 (save-excursion
11641 (if (eq (forward-line -1) 0)
11642 (gnus-summary-article-number)
11643 (error "Beginning of summary buffer"))))))
11644 (gnus-summary-reparent-children parent (list child))))
11646 (defun gnus-summary-reparent-children (parent children)
11647 "Make PARENT the parent of CHILDREN.
11648 When called interactively, PARENT is the current article and CHILDREN
11649 are the process-marked articles."
11650 (interactive
11651 (list (gnus-summary-article-number)
11652 (gnus-summary-work-articles nil)))
11653 (dolist (child children)
11654 (save-window-excursion
11655 (let ((gnus-article-buffer " *reparent*"))
11656 (unless (not (eq parent child))
11657 (error "An article may not be self-referential"))
11658 (let ((message-id (mail-header-id
11659 (gnus-summary-article-header parent))))
11660 (unless (and message-id (not (equal message-id "")))
11661 (error "No message-id in desired parent"))
11662 (gnus-with-article child
11663 (save-restriction
11664 (goto-char (point-min))
11665 (message-narrow-to-head)
11666 (if (re-search-forward "^References: " nil t)
11667 (progn
11668 (re-search-forward "^[^ \t]" nil t)
11669 (forward-line -1)
11670 (end-of-line)
11671 (insert " " message-id))
11672 (insert "References: " message-id "\n"))))
11673 (set-buffer gnus-summary-buffer)
11674 (gnus-summary-unmark-all-processable)
11675 (gnus-summary-update-article child)
11676 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11677 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11678 (gnus-summary-rethread-current)
11679 (gnus-message 3 "Article %d is now the child of article %d"
11680 child parent))))))
11682 (defun gnus-summary-toggle-threads (&optional arg)
11683 "Toggle showing conversation threads.
11684 If ARG is positive number, turn showing conversation threads on."
11685 (interactive "P")
11686 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11687 (setq gnus-show-threads
11688 (if (null arg) (not gnus-show-threads)
11689 (> (prefix-numeric-value arg) 0)))
11690 (gnus-summary-prepare)
11691 (gnus-summary-goto-subject current)
11692 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11693 (gnus-summary-position-point)))
11695 (defun gnus-summary-show-all-threads ()
11696 "Show all threads."
11697 (interactive)
11698 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11699 (gnus-summary-position-point))
11701 (defsubst gnus-summary--inv (p)
11702 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11704 (defun gnus-summary-show-thread ()
11705 "Show thread subtrees.
11706 Returns nil if no thread was there to be shown."
11707 (interactive)
11708 (let* ((orig (point))
11709 (end (point-at-eol))
11710 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11711 ;; Leave point at bol
11712 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11713 (eoi (and end (next-single-char-property-change end 'invisible))))
11714 (when eoi
11715 (remove-overlays beg eoi 'invisible 'gnus-sum)
11716 (goto-char orig)
11717 (gnus-summary-position-point)
11718 eoi)))
11720 (defun gnus-summary-maybe-hide-threads ()
11721 "If requested, hide the threads that should be hidden."
11722 (when (and gnus-show-threads
11723 gnus-thread-hide-subtree)
11724 (gnus-summary-hide-all-threads
11725 (if (or (consp gnus-thread-hide-subtree)
11726 (functionp gnus-thread-hide-subtree))
11727 (gnus-make-predicate gnus-thread-hide-subtree)
11728 nil))))
11730 ;;; Hiding predicates.
11732 (defun gnus-article-unread-p (header)
11733 (memq (mail-header-number header) gnus-newsgroup-unreads))
11735 (defun gnus-article-unseen-p (header)
11736 (memq (mail-header-number header) gnus-newsgroup-unseen))
11738 (defun gnus-map-articles (predicate articles)
11739 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11740 (apply 'gnus-or (mapcar predicate
11741 (mapcar (lambda (number)
11742 (gnus-summary-article-header number))
11743 articles))))
11745 (defun gnus-summary-hide-all-threads (&optional predicate)
11746 "Hide all thread subtrees.
11747 If PREDICATE is supplied, threads that satisfy this predicate
11748 will not be hidden."
11749 (interactive)
11750 (save-excursion
11751 (goto-char (point-min))
11752 (let ((end nil)
11753 (count 0))
11754 (while (not end)
11755 (cl-incf count)
11756 (when (zerop (mod count 1000))
11757 (message "Hiding all threads... %d" count))
11758 (when (or (not predicate)
11759 (gnus-map-articles
11760 predicate (gnus-summary-article-children)))
11761 (gnus-summary-hide-thread))
11762 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11763 (gnus-summary-position-point))
11765 (defun gnus-summary-hide-thread ()
11766 "Hide thread subtrees.
11767 If PREDICATE is supplied, threads that satisfy this predicate
11768 will not be hidden.
11769 Returns nil if no threads were there to be hidden."
11770 (interactive)
11771 (beginning-of-line)
11772 (let ((start (point))
11773 (starteol (line-end-position))
11774 (article (gnus-summary-article-number)))
11775 ;; Go forward until either the buffer ends or the subthread ends.
11776 (when (and (not (eobp))
11777 (or (zerop (gnus-summary-next-thread 1 t))
11778 (goto-char (point-max))))
11779 (if (and (> (point) start)
11780 ;; FIXME: this should actually search for a non-invisible \n.
11781 (search-backward "\n" start t))
11782 (progn
11783 (when (> (point) starteol)
11784 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11785 (let ((ol (make-overlay starteol (point) nil t nil)))
11786 (overlay-put ol 'invisible 'gnus-sum)
11787 (overlay-put ol 'evaporate t)))
11788 (gnus-summary-goto-subject article)
11789 (when (> start (point))
11790 (message "Hiding the thread moved us backwards, aborting!")
11791 (goto-char (point-max))))
11792 (goto-char start)
11793 nil))))
11795 (defun gnus-summary-go-to-next-thread (&optional previous)
11796 "Go to the same level (or less) next thread.
11797 If PREVIOUS is non-nil, go to previous thread instead.
11798 Return the article number moved to, or nil if moving was impossible."
11799 (let ((level (gnus-summary-thread-level))
11800 (way (if previous -1 1))
11801 (beg (point)))
11802 (forward-line way)
11803 (while (and (not (eobp))
11804 (< level (gnus-summary-thread-level)))
11805 (forward-line way))
11806 (if (eobp)
11807 (progn
11808 (goto-char beg)
11809 nil)
11810 (setq beg (point))
11811 (prog1
11812 (gnus-summary-article-number)
11813 (goto-char beg)))))
11815 (defun gnus-summary-next-thread (n &optional silent)
11816 "Go to the same level next N'th thread.
11817 If N is negative, search backward instead.
11818 Returns the difference between N and the number of skips actually
11819 done.
11821 If SILENT, don't output messages."
11822 (interactive "p")
11823 (let ((backward (< n 0))
11824 (n (abs n)))
11825 (while (and (> n 0)
11826 (gnus-summary-go-to-next-thread backward))
11827 (cl-decf n))
11828 (unless silent
11829 (gnus-summary-position-point))
11830 (when (and (not silent) (/= 0 n))
11831 (gnus-message 7 "No more threads"))
11834 (defun gnus-summary-prev-thread (n)
11835 "Go to the same level previous N'th thread.
11836 Returns the difference between N and the number of skips actually
11837 done."
11838 (interactive "p")
11839 (gnus-summary-next-thread (- n)))
11841 (defun gnus-summary-go-down-thread ()
11842 "Go down one level in the current thread."
11843 (let ((children (gnus-summary-article-children)))
11844 (when children
11845 (gnus-summary-goto-subject (car children)))))
11847 (defun gnus-summary-go-up-thread ()
11848 "Go up one level in the current thread."
11849 (let ((parent (gnus-summary-article-parent)))
11850 (when parent
11851 (gnus-summary-goto-subject parent))))
11853 (defun gnus-summary-down-thread (n)
11854 "Go down thread N steps.
11855 If N is negative, go up instead.
11856 Returns the difference between N and how many steps down that were
11857 taken."
11858 (interactive "p")
11859 (let ((up (< n 0))
11860 (n (abs n)))
11861 (while (and (> n 0)
11862 (if up (gnus-summary-go-up-thread)
11863 (gnus-summary-go-down-thread)))
11864 (setq n (1- n)))
11865 (gnus-summary-position-point)
11866 (when (/= 0 n)
11867 (gnus-message 7 "Can't go further"))
11870 (defun gnus-summary-up-thread (n)
11871 "Go up thread N steps.
11872 If N is negative, go down instead.
11873 Returns the difference between N and how many steps down that were
11874 taken."
11875 (interactive "p")
11876 (gnus-summary-down-thread (- n)))
11878 (defun gnus-summary-top-thread ()
11879 "Go to the top of the thread."
11880 (interactive)
11881 (while (gnus-summary-go-up-thread))
11882 (gnus-summary-article-number))
11884 (defun gnus-summary-expire-thread ()
11885 "Mark articles under current thread as expired."
11886 (interactive)
11887 (gnus-summary-kill-thread 0))
11889 (defun gnus-summary-kill-thread (&optional unmark)
11890 "Mark articles under current thread as read.
11891 If the prefix argument is positive, remove any kinds of marks.
11892 If the prefix argument is zero, mark thread as expired.
11893 If the prefix argument is negative, tick articles instead."
11894 (interactive "P")
11895 (when unmark
11896 (setq unmark (prefix-numeric-value unmark)))
11897 (let ((articles (gnus-summary-articles-in-thread))
11898 (hide (or (null unmark) (= unmark 0))))
11899 (save-excursion
11900 ;; Expand the thread.
11901 (gnus-summary-show-thread)
11902 ;; Mark all the articles.
11903 (while articles
11904 (gnus-summary-goto-subject (car articles))
11905 (cond ((null unmark)
11906 (gnus-summary-mark-article-as-read gnus-killed-mark))
11907 ((> unmark 0)
11908 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11909 ((= unmark 0)
11910 (gnus-summary-mark-article nil gnus-expirable-mark))
11912 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11913 (setq articles (cdr articles))))
11914 ;; Hide killed subtrees when hide is true.
11915 (and hide
11916 gnus-thread-hide-killed
11917 (gnus-summary-hide-thread))
11918 ;; If hide is t, go to next unread subject.
11919 (when hide
11920 ;; Go to next unread subject.
11921 (gnus-summary-next-subject 1 t)))
11922 (gnus-set-mode-line 'summary))
11924 ;; Summary sorting commands
11926 (defun gnus-summary-sort-by-number (&optional reverse)
11927 "Sort the summary buffer by article number.
11928 Argument REVERSE means reverse order."
11929 (interactive "P")
11930 (gnus-summary-sort 'number reverse))
11932 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11933 "Sort the summary buffer by most recent article number.
11934 Argument REVERSE means reverse order."
11935 (interactive "P")
11936 (gnus-summary-sort 'most-recent-number reverse))
11938 (defun gnus-summary-sort-by-random (&optional reverse)
11939 "Randomize the order in the summary buffer.
11940 Argument REVERSE means to randomize in reverse order."
11941 (interactive "P")
11942 (gnus-summary-sort 'random reverse))
11944 (defun gnus-summary-sort-by-author (&optional reverse)
11945 "Sort the summary buffer by author name alphabetically.
11946 If `case-fold-search' is non-nil, case of letters is ignored.
11947 Argument REVERSE means reverse order."
11948 (interactive "P")
11949 (gnus-summary-sort 'author reverse))
11951 (defun gnus-summary-sort-by-recipient (&optional reverse)
11952 "Sort the summary buffer by recipient name alphabetically.
11953 If `case-fold-search' is non-nil, case of letters is ignored.
11954 Argument REVERSE means reverse order."
11955 (interactive "P")
11956 (gnus-summary-sort 'recipient reverse))
11958 (defun gnus-summary-sort-by-subject (&optional reverse)
11959 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11960 If `case-fold-search' is non-nil, case of letters is ignored.
11961 Argument REVERSE means reverse order."
11962 (interactive "P")
11963 (gnus-summary-sort 'subject reverse))
11965 (defun gnus-summary-sort-by-date (&optional reverse)
11966 "Sort the summary buffer by date.
11967 Argument REVERSE means reverse order."
11968 (interactive "P")
11969 (gnus-summary-sort 'date reverse))
11971 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11972 "Sort the summary buffer by most recent date.
11973 Argument REVERSE means reverse order."
11974 (interactive "P")
11975 (gnus-summary-sort 'most-recent-date reverse))
11977 (defun gnus-summary-sort-by-score (&optional reverse)
11978 "Sort the summary buffer by score.
11979 Argument REVERSE means reverse order."
11980 (interactive "P")
11981 (gnus-summary-sort 'score reverse))
11983 (defun gnus-summary-sort-by-lines (&optional reverse)
11984 "Sort the summary buffer by the number of lines.
11985 Argument REVERSE means reverse order."
11986 (interactive "P")
11987 (gnus-summary-sort 'lines reverse))
11989 (defun gnus-summary-sort-by-chars (&optional reverse)
11990 "Sort the summary buffer by article length.
11991 Argument REVERSE means reverse order."
11992 (interactive "P")
11993 (gnus-summary-sort 'chars reverse))
11995 (defun gnus-summary-sort-by-marks (&optional reverse)
11996 "Sort the summary buffer by article marks.
11997 Argument REVERSE means reverse order."
11998 (interactive "P")
11999 (gnus-summary-sort 'marks reverse))
12001 (defun gnus-summary-sort-by-original (&optional reverse)
12002 "Sort the summary buffer using the default sorting method.
12003 Argument REVERSE means reverse order."
12004 (interactive "P")
12005 (let* ((inhibit-read-only t)
12006 (gnus-summary-prepare-hook nil))
12007 ;; We do the sorting by regenerating the threads.
12008 (gnus-summary-prepare)
12009 ;; Hide subthreads if needed.
12010 (gnus-summary-maybe-hide-threads)))
12012 (defun gnus-summary-sort (predicate reverse)
12013 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12014 (let* ((current (gnus-summary-article-number))
12015 (thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12016 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12017 (gnus-thread-sort-functions
12018 (if (not reverse)
12019 thread
12020 `(lambda (t1 t2)
12021 (,thread t2 t1))))
12022 (gnus-sort-gathered-threads-function
12023 gnus-thread-sort-functions)
12024 (gnus-article-sort-functions
12025 (if (not reverse)
12026 article
12027 `(lambda (t1 t2)
12028 (,article t2 t1))))
12029 (inhibit-read-only t)
12030 (gnus-summary-prepare-hook nil))
12031 ;; We do the sorting by regenerating the threads.
12032 (gnus-summary-prepare)
12033 ;; Hide subthreads if needed.
12034 (gnus-summary-maybe-hide-threads)
12035 ;; Restore point.
12036 (gnus-summary-goto-subject current)))
12038 ;; Summary saving commands.
12040 (defun gnus-summary-save-article (&optional n not-saved)
12041 "Save the current article using the default saver function.
12042 If N is a positive number, save the N next articles.
12043 If N is a negative number, save the N previous articles.
12044 If N is nil and any articles have been marked with the process mark,
12045 save those articles instead.
12046 The variable `gnus-default-article-saver' specifies the saver function.
12048 If the optional second argument NOT-SAVED is non-nil, articles saved
12049 will not be marked as saved.
12051 The `gnus-prompt-before-saving' variable says how prompting is
12052 performed."
12053 (interactive "P")
12054 (require 'gnus-art)
12055 (let* ((articles (gnus-summary-work-articles n))
12056 (save-buffer (save-excursion
12057 (nnheader-set-temp-buffer " *Gnus Save*")))
12058 (num (length articles))
12059 ;; Whether to save decoded articles or raw articles.
12060 (decode (when gnus-article-save-coding-system
12061 (get gnus-default-article-saver :decode)))
12062 ;; When saving many articles in a single file, use the other
12063 ;; function to save articles other than the first one.
12064 (saver2 (get gnus-default-article-saver :function))
12065 (gnus-prompt-before-saving (if saver2
12067 gnus-prompt-before-saving))
12068 (gnus-default-article-saver gnus-default-article-saver)
12069 header file)
12070 (dolist (article articles)
12071 (setq header (gnus-summary-article-header article))
12072 (if (not (vectorp header))
12073 ;; This is a pseudo-article.
12074 (if (assq 'name header)
12075 (gnus-copy-file (cdr (assq 'name header)))
12076 (gnus-message 1 "Article %d is unsavable" article))
12077 ;; This is a real article.
12078 (save-window-excursion
12079 (gnus-summary-select-article decode decode nil article)
12080 (gnus-summary-goto-subject article))
12081 (with-current-buffer save-buffer
12082 (erase-buffer)
12083 (insert-buffer-substring (if decode
12084 gnus-article-buffer
12085 gnus-original-article-buffer)))
12086 (setq file (gnus-article-save save-buffer file num))
12087 (gnus-summary-remove-process-mark article)
12088 (unless not-saved
12089 (gnus-summary-set-saved-mark article)))
12090 (when saver2
12091 (setq gnus-default-article-saver saver2
12092 saver2 nil)))
12093 (gnus-kill-buffer save-buffer)
12094 (gnus-summary-position-point)
12095 (gnus-set-mode-line 'summary)
12098 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12100 (defun gnus-summary-pipe-output (&optional n sym)
12101 "Pipe the current article to a subprocess.
12102 If N is a positive number, pipe the N next articles.
12103 If N is a negative number, pipe the N previous articles.
12104 If N is nil and any articles have been marked with the process mark,
12105 pipe those articles instead.
12106 The default command to which articles are piped is specified by the
12107 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12108 will be prompted for the command.
12110 The properties `:decode' and `:headers' that are put to the function
12111 symbol `gnus-summary-save-in-pipe' control whether this function
12112 decodes articles and what headers to keep (see the doc string for the
12113 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12114 is neither omitted nor the symbol `r', force including all headers
12115 regardless of the `:headers' property. If it is the symbol `r',
12116 articles that are not decoded and include all headers will be piped
12117 no matter what the properties `:decode' and `:headers' are."
12118 (interactive (gnus-interactive "P\ny"))
12119 (require 'gnus-art)
12120 (let* ((articles (gnus-summary-work-articles n))
12121 (result-buffer "*Shell Command Output*")
12122 (all-headers (not (memq sym '(nil r))))
12123 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12124 (raw (eq sym 'r))
12125 (headers (get 'gnus-summary-save-in-pipe :headers))
12126 command result)
12127 (unless (numberp (car articles))
12128 (error "No article to pipe"))
12129 (setq command (read-shell-command
12130 (concat "Shell command on "
12131 (if (cdr articles)
12132 (format "these %d articles" (length articles))
12133 "this article")
12134 ": ")
12135 gnus-summary-pipe-output-default-command))
12136 (when (string-equal command "")
12137 (error "A command is required"))
12138 (when all-headers
12139 (put 'gnus-summary-save-in-pipe :headers nil))
12140 (unwind-protect
12141 (while articles
12142 (gnus-summary-goto-subject (pop articles))
12143 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12144 (when (and (get-buffer result-buffer)
12145 (not (zerop (buffer-size (get-buffer result-buffer)))))
12146 (setq result (concat result (with-current-buffer result-buffer
12147 (buffer-string))))))
12148 (put 'gnus-summary-save-in-pipe :headers headers))
12149 (unless (zerop (length result))
12150 (if (with-current-buffer (get-buffer-create result-buffer)
12151 (erase-buffer)
12152 (insert result)
12153 (prog1
12154 (and (= (count-lines (point-min) (point)) 1)
12155 (progn
12156 (end-of-line 0)
12157 (<= (current-column)
12158 (window-width (minibuffer-window)))))
12159 (goto-char (point-min))))
12160 (message "%s" (substring result 0 -1))
12161 (message nil)
12162 (gnus-configure-windows 'pipe)))))
12164 (defun gnus-summary-save-article-mail (&optional arg)
12165 "Append the current article to a Unix mail box file.
12166 If N is a positive number, save the N next articles.
12167 If N is a negative number, save the N previous articles.
12168 If N is nil and any articles have been marked with the process mark,
12169 save those articles instead."
12170 (interactive "P")
12171 (require 'gnus-art)
12172 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12173 (gnus-summary-save-article arg)))
12175 (defun gnus-summary-save-article-rmail (&optional arg)
12176 "Append the current article to an rmail file.
12177 If N is a positive number, save the N next articles.
12178 If N is a negative number, save the N previous articles.
12179 If N is nil and any articles have been marked with the process mark,
12180 save those articles instead."
12181 (interactive "P")
12182 (require 'gnus-art)
12183 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12184 (gnus-summary-save-article arg)))
12186 (defun gnus-summary-save-article-file (&optional arg)
12187 "Append the current article to a file.
12188 If N is a positive number, save the N next articles.
12189 If N is a negative number, save the N previous articles.
12190 If N is nil and any articles have been marked with the process mark,
12191 save those articles instead."
12192 (interactive "P")
12193 (require 'gnus-art)
12194 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12195 (gnus-summary-save-article arg)))
12197 (defun gnus-summary-write-article-file (&optional arg)
12198 "Write the current article to a file, deleting the previous file.
12199 If N is a positive number, save the N next articles.
12200 If N is a negative number, save the N previous articles.
12201 If N is nil and any articles have been marked with the process mark,
12202 save those articles instead."
12203 (interactive "P")
12204 (require 'gnus-art)
12205 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12206 (gnus-summary-save-article arg)))
12208 (defun gnus-summary-save-article-body-file (&optional arg)
12209 "Append the current article body to a file.
12210 If N is a positive number, save the N next articles.
12211 If N is a negative number, save the N previous articles.
12212 If N is nil and any articles have been marked with the process mark,
12213 save those articles instead."
12214 (interactive "P")
12215 (require 'gnus-art)
12216 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12217 (gnus-summary-save-article arg)))
12219 (defun gnus-summary-write-article-body-file (&optional arg)
12220 "Write the current article body to a file, deleting the previous file.
12221 If N is a positive number, save the N next articles.
12222 If N is a negative number, save the N previous articles.
12223 If N is nil and any articles have been marked with the process mark,
12224 save those articles instead."
12225 (interactive "P")
12226 (require 'gnus-art)
12227 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12228 (gnus-summary-save-article arg)))
12230 (defun gnus-summary-muttprint (&optional arg)
12231 "Print the current article using Muttprint.
12232 If N is a positive number, save the N next articles.
12233 If N is a negative number, save the N previous articles.
12234 If N is nil and any articles have been marked with the process mark,
12235 save those articles instead."
12236 (interactive "P")
12237 (require 'gnus-art)
12238 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12239 (gnus-summary-save-article arg t)))
12241 (defun gnus-summary-pipe-message (program)
12242 "Pipe the current article through PROGRAM."
12243 (interactive "sProgram: ")
12244 (gnus-summary-select-article)
12245 (let ((mail-header-separator ""))
12246 (gnus-eval-in-buffer-window gnus-article-buffer
12247 (save-restriction
12248 (widen)
12249 (let ((start (window-start))
12250 (inhibit-read-only t))
12251 (message-pipe-buffer-body program)
12252 (set-window-start (get-buffer-window (current-buffer)) start))))))
12254 (defun gnus-get-split-value (methods)
12255 "Return a value based on the split METHODS."
12256 (let (split-name method result match)
12257 (when methods
12258 (with-current-buffer gnus-original-article-buffer
12259 (save-restriction
12260 (nnheader-narrow-to-headers)
12261 (while (and methods (not split-name))
12262 (goto-char (point-min))
12263 (setq method (pop methods))
12264 (setq match (car method))
12265 (when (cond
12266 ((stringp match)
12267 ;; Regular expression.
12268 (ignore-errors
12269 (re-search-forward match nil t)))
12270 ((functionp match)
12271 ;; Function.
12272 (save-restriction
12273 (widen)
12274 (setq result (funcall match gnus-newsgroup-name))))
12275 ((consp match)
12276 ;; Form.
12277 (save-restriction
12278 (widen)
12279 (setq result (eval match)))))
12280 (setq split-name (cdr method))
12281 (cond ((stringp result)
12282 (push (expand-file-name
12283 result gnus-article-save-directory)
12284 split-name))
12285 ((consp result)
12286 (setq split-name (append result split-name)))))))))
12287 (nreverse split-name)))
12289 (defun gnus-valid-move-group-p (group)
12290 (and (symbolp group)
12291 (boundp group)
12292 (symbol-name group)
12293 (symbol-value group)
12294 (gnus-get-function (gnus-find-method-for-group
12295 (symbol-name group)) 'request-accept-article t)))
12297 (defun gnus-read-move-group-name (prompt default articles prefix)
12298 "Read a group name."
12299 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12300 (prom
12301 (format "%s %s to"
12302 prompt
12303 (if (> (length articles) 1)
12304 (format "these %d articles" (length articles))
12305 "this article")))
12306 valid-names
12307 (to-newsgroup
12308 (progn
12309 (mapatoms (lambda (g)
12310 (when (gnus-valid-move-group-p g)
12311 (push g valid-names)))
12312 gnus-active-hashtb)
12313 (cond
12314 ((null split-name)
12315 (gnus-group-completing-read
12316 prom
12317 valid-names
12318 nil prefix nil default))
12319 ((= 1 (length split-name))
12320 (gnus-group-completing-read
12321 prom
12322 valid-names
12323 nil prefix 'gnus-group-history (car split-name)))
12325 (gnus-completing-read
12326 prom (nreverse split-name) nil nil 'gnus-group-history)))))
12327 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12328 encoded)
12329 (when to-newsgroup
12330 (if (or (string= to-newsgroup "")
12331 (string= to-newsgroup prefix))
12332 (setq to-newsgroup default))
12333 (unless to-newsgroup
12334 (error "No group name entered"))
12335 (setq encoded (encode-coding-string
12336 to-newsgroup
12337 (gnus-group-name-charset to-method to-newsgroup)))
12338 (or (gnus-active encoded)
12339 (gnus-activate-group encoded nil nil to-method)
12340 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12341 to-newsgroup))
12342 (or (and (gnus-request-create-group encoded to-method)
12343 (gnus-activate-group encoded nil nil to-method)
12344 (gnus-subscribe-group encoded))
12345 (error "Couldn't create group %s" to-newsgroup)))
12346 (error "No such group: %s" to-newsgroup))
12347 encoded)))
12349 (defvar gnus-summary-save-parts-counter)
12350 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12352 (defun gnus-summary-save-parts (type dir n &optional reverse)
12353 "Save parts matching TYPE to DIR.
12354 If REVERSE, save parts that do not match TYPE."
12355 (interactive
12356 (list (read-string "Save parts of type: "
12357 (or (car gnus-summary-save-parts-type-history)
12358 gnus-summary-save-parts-default-mime)
12359 'gnus-summary-save-parts-type-history)
12360 (setq gnus-summary-save-parts-last-directory
12361 (read-directory-name "Save to directory: "
12362 gnus-summary-save-parts-last-directory
12363 nil t))
12364 current-prefix-arg))
12365 (gnus-summary-iterate n
12366 (let ((gnus-display-mime-function nil)
12367 gnus-article-prepare-hook
12368 gnus-article-decode-hook
12369 gnus-display-mime-function
12370 gnus-break-pages
12371 (gnus-inhibit-treatment t))
12372 (gnus-summary-select-article))
12373 (with-current-buffer gnus-article-buffer
12374 (let ((handles (or gnus-article-mime-handles
12375 (mm-dissect-buffer nil gnus-article-loose-mime)
12376 (and gnus-article-emulate-mime
12377 (mm-uu-dissect))))
12378 (gnus-summary-save-parts-counter 1))
12379 (when handles
12380 (gnus-summary-save-parts-1 type dir handles reverse)
12381 (unless gnus-article-mime-handles ;; Don't destroy this case.
12382 (mm-destroy-parts handles)))))))
12384 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12385 (if (stringp (car handle))
12386 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12387 (cdr handle))
12388 (when (if reverse
12389 (not (string-match type (mm-handle-media-type handle)))
12390 (string-match type (mm-handle-media-type handle)))
12391 (let ((file (expand-file-name
12392 (gnus-map-function
12393 mm-file-name-rewrite-functions
12394 (file-name-nondirectory
12396 (mm-handle-filename handle)
12397 (format "%s.%d.%d" gnus-newsgroup-name
12398 (cdr gnus-article-current)
12399 gnus-summary-save-parts-counter))))
12400 dir)))
12401 (cl-incf gnus-summary-save-parts-counter)
12402 (unless (file-exists-p file)
12403 (mm-save-part-to-file handle file))))))
12405 ;; Summary extract commands
12407 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12408 (let ((inhibit-read-only t)
12409 (article (gnus-summary-article-number))
12410 after-article b e)
12411 (unless (gnus-summary-goto-subject article)
12412 (error "No such article: %d" article))
12413 (gnus-summary-position-point)
12414 ;; If all commands are to be bunched up on one line, we collect
12415 ;; them here.
12416 (unless gnus-view-pseudos-separately
12417 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12418 files action)
12419 (while ps
12420 (setq action (cdr (assq 'action (car ps))))
12421 (setq files (list (cdr (assq 'name (car ps)))))
12422 (while (and ps (cdr ps)
12423 (string= (or action "1")
12424 (or (cdr (assq 'action (cadr ps))) "2")))
12425 (push (cdr (assq 'name (cadr ps))) files)
12426 (setcdr ps (cddr ps)))
12427 (when files
12428 (when (not (string-match "%s" action))
12429 (push " " files))
12430 (push " " files)
12431 (when (assq 'execute (car ps))
12432 (setcdr (assq 'execute (car ps))
12433 (funcall (if (string-match "%s" action)
12434 'format 'concat)
12435 action
12436 (mapconcat
12437 (lambda (f)
12438 (if (equal f " ")
12440 (shell-quote-argument f)))
12441 files " ")))))
12442 (setq ps (cdr ps)))))
12443 (if (and gnus-view-pseudos (not not-view))
12444 (while pslist
12445 (when (assq 'execute (car pslist))
12446 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12447 (eq gnus-view-pseudos 'not-confirm)))
12448 (setq pslist (cdr pslist)))
12449 (save-excursion
12450 (while pslist
12451 (setq after-article (or (cdr (assq 'article (car pslist)))
12452 (gnus-summary-article-number)))
12453 (gnus-summary-goto-subject after-article)
12454 (forward-line 1)
12455 (setq b (point))
12456 (insert " " (file-name-nondirectory
12457 (cdr (assq 'name (car pslist))))
12458 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12459 (setq e (point))
12460 (forward-line -1) ; back to `b'
12461 (add-text-properties
12462 b (1- e) (list 'gnus-number gnus-reffed-article-number
12463 'mouse-face gnus-mouse-face))
12464 (gnus-data-enter
12465 after-article gnus-reffed-article-number
12466 gnus-unread-mark b (car pslist) 0 (- e b))
12467 (setq gnus-newsgroup-unreads
12468 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12469 gnus-reffed-article-number))
12470 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12471 (setq pslist (cdr pslist)))))))
12473 (defun gnus-pseudos< (p1 p2)
12474 (let ((c1 (cdr (assq 'action p1)))
12475 (c2 (cdr (assq 'action p2))))
12476 (and c1 c2 (string< c1 c2))))
12478 (defun gnus-request-pseudo-article (props)
12479 (cond ((assq 'execute props)
12480 (gnus-execute-command (cdr (assq 'execute props)))))
12481 (let ((gnus-current-article (gnus-summary-article-number)))
12482 (gnus-run-hooks 'gnus-mark-article-hook)))
12484 (defun gnus-execute-command (command &optional automatic)
12485 (save-excursion
12486 (gnus-article-setup-buffer)
12487 (set-buffer gnus-article-buffer)
12488 (setq buffer-read-only nil)
12489 (let ((command (if automatic command
12490 (read-string "Command: " (cons command 0)))))
12491 (erase-buffer)
12492 (insert "$ " command "\n\n")
12493 (if gnus-view-pseudo-asynchronously
12494 (start-process "gnus-execute" (current-buffer) shell-file-name
12495 shell-command-switch command)
12496 (call-process shell-file-name nil t nil
12497 shell-command-switch command)))))
12499 ;; Summary kill commands.
12501 (defun gnus-summary-edit-global-kill (article)
12502 "Edit the \"global\" kill file."
12503 (interactive (list (gnus-summary-article-number)))
12504 (gnus-group-edit-global-kill article))
12506 (defun gnus-summary-edit-local-kill ()
12507 "Edit a local kill file applied to the current newsgroup."
12508 (interactive)
12509 (setq gnus-current-headers (gnus-summary-article-header))
12510 (gnus-group-edit-local-kill
12511 (gnus-summary-article-number) gnus-newsgroup-name))
12513 ;;; Header reading.
12515 (defun gnus-read-header (id &optional header)
12516 "Read the headers of article ID and enter them into the Gnus system."
12517 (let ((group gnus-newsgroup-name)
12518 (gnus-override-method
12520 gnus-override-method
12521 (and (gnus-news-group-p gnus-newsgroup-name)
12522 (car (gnus-refer-article-methods)))))
12523 where)
12524 ;; First we check to see whether the header in question is already
12525 ;; fetched.
12526 (if (stringp id)
12527 ;; This is a Message-ID.
12528 (setq header (or header (gnus-id-to-header id)))
12529 ;; This is an article number.
12530 (setq header (or header (gnus-summary-article-header id))))
12531 (if (and header
12532 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12533 ;; We have found the header.
12534 header
12535 ;; We have to really fetch the header to this article.
12536 (with-current-buffer nntp-server-buffer
12537 (when (setq where (gnus-request-head id group))
12538 (nnheader-fold-continuation-lines)
12539 (goto-char (point-max))
12540 (insert ".\n")
12541 (goto-char (point-min))
12542 (insert "211 ")
12543 (princ (cond
12544 ((numberp id) id)
12545 ((cdr where) (cdr where))
12546 (header (mail-header-number header))
12547 (t gnus-reffed-article-number))
12548 (current-buffer))
12549 (insert " Article retrieved.\n"))
12550 (if (or (not where)
12551 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12552 () ; Malformed head.
12553 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12554 (when (and (bound-and-true-p gnus-registry-enabled)
12555 (not (gnus-ephemeral-group-p (car where))))
12556 (gnus-registry-handle-action
12557 (mail-header-id header) nil
12558 (gnus-group-prefixed-name
12559 (car where)
12560 (or gnus-override-method (gnus-find-method-for-group group)))
12561 (mail-header-subject header)
12562 (mail-header-from header)))
12563 (when (and (stringp id)
12565 (not (string= (gnus-group-real-name group)
12566 (car where)))
12567 (not (gnus-server-equal gnus-override-method
12568 (gnus-group-method group)))))
12569 ;; If we fetched by Message-ID and the article came from
12570 ;; a different group (or server), we fudge some bogus
12571 ;; article numbers for this article.
12572 (mail-header-set-number header gnus-reffed-article-number))
12573 (with-current-buffer gnus-summary-buffer
12574 (cl-decf gnus-reffed-article-number)
12575 (gnus-remove-header (mail-header-number header))
12576 (push header gnus-newsgroup-headers)
12577 (setq gnus-current-headers header)
12578 (push (mail-header-number header) gnus-newsgroup-limit)))
12579 header)))))
12581 (defun gnus-remove-header (number)
12582 "Remove header NUMBER from `gnus-newsgroup-headers'."
12583 (if (and gnus-newsgroup-headers
12584 (= number (mail-header-number (car gnus-newsgroup-headers))))
12585 (pop gnus-newsgroup-headers)
12586 (let ((headers gnus-newsgroup-headers))
12587 (while (and (cdr headers)
12588 (not (= number (mail-header-number (cadr headers)))))
12589 (pop headers))
12590 (when (cdr headers)
12591 (setcdr headers (cddr headers))))))
12594 ;;; summary highlights
12597 (defun gnus-highlight-selected-summary ()
12598 "Highlight selected article in summary buffer."
12599 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12600 (when gnus-summary-selected-face
12601 (save-excursion
12602 (let* ((beg (point-at-bol))
12603 (end (point-at-eol))
12604 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12605 (from (if (get-text-property beg 'mouse-face)
12607 (or (next-single-property-change
12608 beg 'mouse-face nil end)
12609 beg)))
12611 (if (= from end)
12612 (- from 2)
12613 (or (next-single-property-change
12614 from 'mouse-face nil end)
12615 end))))
12616 ;; If no mouse-face prop on line we will have to = from = end,
12617 ;; so we highlight the entire line instead.
12618 (when (= (+ to 2) from)
12619 (setq from beg)
12620 (setq to end))
12621 (if gnus-newsgroup-selected-overlay
12622 ;; Move old overlay.
12623 (move-overlay
12624 gnus-newsgroup-selected-overlay from to (current-buffer))
12625 ;; Create new overlay.
12626 (overlay-put
12627 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12628 'face gnus-summary-selected-face))))))
12630 (defvar gnus-summary-highlight-line-cached nil)
12631 (defvar gnus-summary-highlight-line-trigger nil)
12633 (defun gnus-summary-highlight-line-0 ()
12634 (if (and (eq gnus-summary-highlight-line-trigger
12635 gnus-summary-highlight)
12636 gnus-summary-highlight-line-cached)
12637 gnus-summary-highlight-line-cached
12638 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12639 gnus-summary-highlight-line-cached
12640 (let* ((cond (list 'cond))
12641 (c cond)
12642 (list gnus-summary-highlight))
12643 (while list
12644 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12645 nil))
12646 (setq c (cdr c)
12647 list (cdr list)))
12648 (gnus-byte-compile (list 'lambda nil cond))))))
12650 (defun gnus-summary-highlight-line ()
12651 "Highlight current line according to `gnus-summary-highlight'."
12652 (let* ((beg (point-at-bol))
12653 (article (or (gnus-summary-article-number) gnus-current-article))
12654 (score (or (cdr (assq article
12655 gnus-newsgroup-scored))
12656 gnus-summary-default-score 0))
12657 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12658 (inhibit-read-only t)
12659 (default gnus-summary-default-score)
12660 (default-high gnus-summary-default-high-score)
12661 (default-low gnus-summary-default-low-score)
12662 (uncached (and gnus-summary-use-undownloaded-faces
12663 (memq article gnus-newsgroup-undownloaded)
12664 (not (memq article gnus-newsgroup-cached)))))
12665 (let ((face (funcall (gnus-summary-highlight-line-0))))
12666 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12667 (gnus-put-text-property-excluding-characters-with-faces
12668 beg (point-at-eol) 'face
12669 (setq face (if (boundp face) (symbol-value face) face)))
12670 (when gnus-summary-highlight-line-function
12671 (funcall gnus-summary-highlight-line-function article face))))))
12673 (defun gnus-update-read-articles (group unread &optional compute)
12674 "Update the list of read articles in GROUP.
12675 UNREAD is a sorted list."
12676 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12677 (info (gnus-get-info group))
12678 (prev 1)
12679 read)
12680 (if (or (not info) (not active))
12681 ;; There is no info on this group if it was, in fact,
12682 ;; killed. Gnus stores no information on killed groups, so
12683 ;; there's nothing to be done.
12684 ;; One could store the information somewhere temporarily,
12685 ;; perhaps... Hmmm...
12687 ;; Remove any negative articles numbers.
12688 (while (and unread (< (car unread) 0))
12689 (setq unread (cdr unread)))
12690 ;; Remove any expired article numbers
12691 (while (and unread (< (car unread) (car active)))
12692 (setq unread (cdr unread)))
12693 ;; Compute the ranges of read articles by looking at the list of
12694 ;; unread articles.
12695 (while unread
12696 (when (/= (car unread) prev)
12697 (push (if (= prev (1- (car unread))) prev
12698 (cons prev (1- (car unread))))
12699 read))
12700 (setq prev (1+ (car unread)))
12701 (setq unread (cdr unread)))
12702 (when (<= prev (cdr active))
12703 (push (cons prev (cdr active)) read))
12704 (setq read (if (> (length read) 1) (nreverse read) read))
12705 (if compute
12706 read
12707 (save-excursion
12708 (let (setmarkundo)
12709 ;; Propagate the read marks to the backend.
12710 (when (and (gnus-method-option-p
12711 (gnus-find-method-for-group group)
12712 'server-marks)
12713 (gnus-check-backend-function 'request-set-mark group))
12714 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12715 (add (gnus-remove-from-range read (gnus-info-read info))))
12716 (when (or add del)
12717 (unless (gnus-check-group group)
12718 (error "Can't open server for %s" group))
12719 (gnus-request-set-mark
12720 group (delq nil (list (if add (list add 'add '(read)))
12721 (if del (list del 'del '(read))))))
12722 (setq setmarkundo
12723 `(gnus-request-set-mark
12724 ,group
12725 ',(delq nil (list
12726 (if del (list del 'add '(read)))
12727 (if add (list add 'del '(read))))))))))
12728 (set-buffer gnus-group-buffer)
12729 (gnus-undo-register
12730 `(progn
12731 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12732 (gnus-info-set-read ',info ',(gnus-info-read info))
12733 (gnus-group-jump-to-group ,group)
12734 (gnus-get-unread-articles-in-group ',info
12735 (gnus-active ,group))
12736 (gnus-group-update-group ,group t)
12737 ,setmarkundo))))
12738 ;; Enter this list into the group info.
12739 (gnus-info-set-read info read)
12740 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12741 (gnus-get-unread-articles-in-group info (gnus-active group))
12742 t))))
12744 (defun gnus-offer-save-summaries ()
12745 "Offer to save all active summary buffers."
12746 (let (buffers)
12747 ;; Go through all buffers and find all summaries.
12748 (dolist (buffer (buffer-list))
12749 (when (and (setq buffer (buffer-name buffer))
12750 (string-match "Summary" buffer)
12751 (with-current-buffer buffer
12752 ;; We check that this is, indeed, a summary buffer.
12753 (and (derived-mode-p 'gnus-summary-mode)
12754 ;; Also make sure this isn't bogus.
12755 gnus-newsgroup-prepared
12756 ;; Also make sure that this isn't a
12757 ;; dead summary buffer.
12758 (not gnus-dead-summary-mode))))
12759 (push buffer buffers)))
12760 ;; Go through all these summary buffers and offer to save them.
12761 (when buffers
12762 (save-excursion
12763 (if (eq gnus-interactive-exit 'quiet)
12764 (dolist (buffer buffers)
12765 (switch-to-buffer buffer)
12766 (gnus-summary-exit))
12767 (map-y-or-n-p
12768 "Update summary buffer %s? "
12769 (lambda (buf)
12770 (switch-to-buffer buf)
12771 (gnus-summary-exit))
12772 buffers))))))
12774 (defun gnus-summary-setup-default-charset ()
12775 "Setup newsgroup default charset."
12776 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12777 (setq gnus-newsgroup-charset nil)
12778 (let* ((ignored-charsets
12779 (or gnus-newsgroup-ephemeral-ignored-charsets
12780 (append
12781 (and gnus-newsgroup-name
12782 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12783 gnus-newsgroup-ignored-charsets))))
12784 (setq gnus-newsgroup-charset
12785 (or gnus-newsgroup-ephemeral-charset
12786 (and gnus-newsgroup-name
12787 (gnus-parameter-charset gnus-newsgroup-name))
12788 gnus-default-charset))
12789 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12790 ignored-charsets))))
12793 ;;; Mime Commands
12796 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12797 "Display the current article buffer fully MIME-buttonized.
12798 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12799 treated as multipart/mixed."
12800 (interactive "P")
12801 (require 'gnus-art)
12802 (let ((gnus-unbuttonized-mime-types nil)
12803 (gnus-mime-display-multipart-as-mixed show-all-parts))
12804 (gnus-summary-show-article)))
12806 (defun gnus-summary-repair-multipart (article)
12807 "Add a Content-Type header to a multipart article without one."
12808 (interactive (list (gnus-summary-article-number)))
12809 (gnus-with-article article
12810 (message-narrow-to-head)
12811 (message-remove-header "Mime-Version")
12812 (goto-char (point-max))
12813 (insert "Mime-Version: 1.0\n")
12814 (widen)
12815 (when (search-forward "\n--" nil t)
12816 (let ((separator (buffer-substring (point) (point-at-eol))))
12817 (message-narrow-to-head)
12818 (message-remove-header "Content-Type")
12819 (goto-char (point-max))
12820 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12821 separator))
12822 (widen))))
12823 (let (gnus-mark-article-hook)
12824 (gnus-summary-select-article t t nil article)))
12826 (defun gnus-summary-toggle-display-buttonized ()
12827 "Toggle the buttonizing of the article buffer."
12828 (interactive)
12829 (require 'gnus-art)
12830 (if (setq gnus-inhibit-mime-unbuttonizing
12831 (not gnus-inhibit-mime-unbuttonizing))
12832 (let ((gnus-unbuttonized-mime-types nil))
12833 (gnus-summary-show-article))
12834 (gnus-summary-show-article)))
12837 ;;; Generic summary marking commands
12840 (defvar gnus-summary-marking-alist
12841 '((read gnus-del-mark "d")
12842 (unread gnus-unread-mark "u")
12843 (ticked gnus-ticked-mark "!")
12844 (dormant gnus-dormant-mark "?")
12845 (expirable gnus-expirable-mark "e"))
12846 "An alist of names/marks/keystrokes.")
12848 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12849 (defvar gnus-summary-mark-map)
12851 (defun gnus-summary-make-all-marking-commands ()
12852 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12853 (dolist (elem gnus-summary-marking-alist)
12854 (apply 'gnus-summary-make-marking-command elem)))
12856 (defun gnus-summary-make-marking-command (name mark keystroke)
12857 (let ((map (make-sparse-keymap)))
12858 (define-key gnus-summary-generic-mark-map keystroke map)
12859 (dolist (lway `((next "next" next nil "n")
12860 (next-unread "next unread" next t "N")
12861 (prev "previous" prev nil "p")
12862 (prev-unread "previous unread" prev t "P")
12863 (nomove "" nil nil ,keystroke)))
12864 (let ((func (gnus-summary-make-marking-command-1
12865 mark (car lway) lway name)))
12866 (setq func (eval func))
12867 (define-key map (nth 4 lway) func)))))
12869 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12870 `(defun ,(intern
12871 (format "gnus-summary-put-mark-as-%s%s"
12872 name (if (eq way 'nomove)
12874 (concat "-" (symbol-name way)))))
12876 ,(format
12877 "Mark the current article as %s%s.
12878 If N, the prefix, then repeat N times.
12879 If N is negative, move in reverse order.
12880 The difference between N and the actual number of articles marked is
12881 returned."
12882 name (cadr lway))
12883 (interactive "p")
12884 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12886 (defun gnus-summary-generic-mark (n mark move unread)
12887 "Mark N articles with MARK."
12888 (unless (derived-mode-p 'gnus-summary-mode)
12889 (error "This command can only be used in the summary buffer"))
12890 (gnus-summary-show-thread)
12891 (let ((nummove
12892 (cond
12893 ((eq move 'next) 1)
12894 ((eq move 'prev) -1)
12895 (t 0))))
12896 (if (zerop nummove)
12897 (setq n 1)
12898 (when (< n 0)
12899 (setq n (abs n)
12900 nummove (* -1 nummove))))
12901 (while (and (> n 0)
12902 (gnus-summary-mark-article nil mark)
12903 (zerop (gnus-summary-next-subject nummove unread t)))
12904 (setq n (1- n)))
12905 (when (/= 0 n)
12906 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12907 (gnus-summary-recenter)
12908 (gnus-summary-position-point)
12909 (gnus-set-mode-line 'summary)
12912 (defun gnus-summary-insert-articles (articles)
12913 (when (setq articles
12914 (gnus-sorted-difference articles
12915 (mapcar (lambda (h)
12916 (mail-header-number h))
12917 gnus-newsgroup-headers)))
12918 (setq gnus-newsgroup-headers
12919 (cl-merge 'list
12920 gnus-newsgroup-headers
12921 (gnus-fetch-headers articles nil t)
12922 'gnus-article-sort-by-number))
12923 (setq gnus-newsgroup-articles
12924 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12925 ;; Suppress duplicates?
12926 (when gnus-suppress-duplicates
12927 (gnus-dup-suppress-articles))
12929 (if (and gnus-fetch-old-headers
12930 (eq gnus-headers-retrieved-by 'nov))
12931 ;; We might want to build some more threads first.
12932 (if (eq gnus-fetch-old-headers 'invisible)
12933 (gnus-build-all-threads)
12934 (gnus-build-old-threads))
12935 ;; Mark the inserted articles that are unread as unread.
12936 (setq gnus-newsgroup-unreads
12937 (gnus-sorted-nunion
12938 gnus-newsgroup-unreads
12939 (gnus-sorted-nintersection
12940 (gnus-list-of-unread-articles gnus-newsgroup-name)
12941 articles)))
12942 ;; Mark the inserted articles as selected so that the information
12943 ;; of the marks having been changed by a user may be updated when
12944 ;; exiting this group. See `gnus-summary-update-info'.
12945 (dolist (art articles)
12946 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12947 ;; Let the Gnus agent mark articles as read.
12948 (when gnus-agent
12949 (gnus-agent-get-undownloaded-list))
12950 ;; Remove list identifiers from subject
12951 (gnus-summary-remove-list-identifiers)
12952 ;; First and last article in this newsgroup.
12953 (when gnus-newsgroup-headers
12954 (setq gnus-newsgroup-begin
12955 (mail-header-number (car gnus-newsgroup-headers))
12956 gnus-newsgroup-end
12957 (mail-header-number
12958 (car (last gnus-newsgroup-headers)))))
12959 (when gnus-use-scoring
12960 (gnus-possibly-score-headers))))
12962 (defun gnus-summary-insert-old-articles (&optional all)
12963 "Insert all old articles in this group.
12964 If ALL is non-nil, already read articles become readable.
12965 If ALL is a number, fetch this number of articles."
12966 (interactive "P")
12967 (prog1
12968 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12969 older len)
12970 (setq older
12971 ;; Some nntp servers lie about their active range. When
12972 ;; this happens, the active range can be in the millions.
12973 ;; Use a compressed range to avoid creating a huge list.
12974 (gnus-range-difference
12975 (gnus-range-difference (list gnus-newsgroup-active) old)
12976 gnus-newsgroup-unexist))
12977 (setq len (gnus-range-length older))
12978 (cond
12979 ((null older) nil)
12980 ((numberp all)
12981 (if (< all len)
12982 (let ((older-range (nreverse older)))
12983 (setq older nil)
12985 (while (> all 0)
12986 (let* ((r (pop older-range))
12987 (min (if (numberp r) r (car r)))
12988 (max (if (numberp r) r (cdr r))))
12989 (while (and (<= min max)
12990 (> all 0))
12991 (push max older)
12992 (setq all (1- all)
12993 max (1- max))))))
12994 (setq older (gnus-uncompress-range older))))
12995 (all
12996 (setq older (gnus-uncompress-range older)))
12998 (when (and (numberp gnus-large-newsgroup)
12999 (> len gnus-large-newsgroup))
13000 (let* ((cursor-in-echo-area nil)
13001 (initial (gnus-parameter-large-newsgroup-initial
13002 gnus-newsgroup-name))
13003 (input
13004 (read-string
13005 (format
13006 "How many articles from %s (%s %d): "
13007 (gnus-group-decoded-name gnus-newsgroup-name)
13008 (if initial "max" "default")
13009 len)
13010 nil nil
13011 (and initial
13012 (number-to-string initial)))))
13013 (unless (string-match "^[ \t]*$" input)
13014 (setq all (string-to-number input))
13015 (if (< all len)
13016 (let ((older-range (nreverse older)))
13017 (setq older nil)
13019 (while (> all 0)
13020 (let* ((r (pop older-range))
13021 (min (if (numberp r) r (car r)))
13022 (max (if (numberp r) r (cdr r))))
13023 (while (and (<= min max)
13024 (> all 0))
13025 (push max older)
13026 (setq all (1- all)
13027 max (1- max))))))))))
13028 (setq older (gnus-uncompress-range older))))
13029 (if (not older)
13030 (message "No old news.")
13031 (gnus-summary-insert-articles older)
13032 (gnus-summary-limit (gnus-sorted-nunion old older))))
13033 (gnus-summary-position-point)))
13035 (defun gnus-summary-insert-new-articles ()
13036 "Insert all new articles in this group."
13037 (interactive)
13038 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
13039 (old-high gnus-newsgroup-highest)
13040 (nnmail-fetched-sources (list t))
13041 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13042 i new)
13043 (unless new-active
13044 (error "Couldn't fetch new data"))
13045 (setq gnus-newsgroup-active (copy-tree new-active))
13046 (setq i (cdr gnus-newsgroup-active)
13047 gnus-newsgroup-highest i)
13048 (while (> i old-high)
13049 (push i new)
13050 (cl-decf i))
13051 (if (not new)
13052 (message "No gnus is bad news")
13053 (gnus-summary-insert-articles new)
13054 (setq gnus-newsgroup-unreads
13055 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13056 (gnus-summary-limit (gnus-sorted-nunion old new))))
13057 (gnus-summary-position-point))
13059 ;;; Bookmark support for Gnus.
13060 (declare-function gnus-article-show-summary "gnus-art" ())
13061 (declare-function bookmark-make-record-default
13062 "bookmark" (&optional no-file no-context posn))
13063 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13064 (declare-function bookmark-default-handler "bookmark" (bmk))
13065 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13066 (defvar bookmark-yank-point)
13067 (defvar bookmark-current-buffer)
13069 (defun gnus-summary-bookmark-make-record ()
13070 "Make a bookmark entry for a Gnus summary buffer."
13071 (let (pos buf)
13072 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13073 (save-restriction ; FIXME is it necessary to widen?
13074 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13075 (setq buf "art") ; We are recording bookmark from article buffer.
13076 (setq bookmark-yank-point (point))
13077 (setq bookmark-current-buffer (current-buffer))
13078 (gnus-article-show-summary)) ; Go back in summary buffer.
13079 ;; We are now recording bookmark from summary buffer.
13080 (unless buf (setq buf "sum"))
13081 (let* ((subject (elt (gnus-summary-article-header) 1))
13082 (grp (car gnus-article-current))
13083 (art (cdr gnus-article-current))
13084 (head (gnus-summary-article-header art))
13085 (id (mail-header-id head)))
13086 `(,subject
13087 ,@(condition-case nil
13088 (bookmark-make-record-default 'no-file 'no-context pos)
13089 (wrong-number-of-arguments
13090 (bookmark-make-record-default 'point-only)))
13091 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13092 (group . ,grp) (article . ,art)
13093 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13095 ;;;###autoload
13096 (defun gnus-summary-bookmark-jump (bookmark)
13097 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13098 BOOKMARK is a bookmark name or a bookmark record."
13099 (let ((group (bookmark-prop-get bookmark 'group))
13100 (article (bookmark-prop-get bookmark 'article))
13101 (id (bookmark-prop-get bookmark 'message-id))
13102 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13103 (gnus-fetch-group group (list article))
13104 (gnus-summary-insert-cached-articles)
13105 (gnus-summary-goto-article id nil 'force)
13106 ;; FIXME we have to wait article buffer is ready (only large buffer)
13107 ;; Is there a better solution to know that?
13108 ;; If we don't wait `bookmark-default-handler' will have no chance
13109 ;; to set position. However there is no error, just wrong pos.
13110 (sit-for 1)
13111 (when (string= buf "Gnus-art")
13112 (other-window 1))
13113 (bookmark-default-handler
13114 `(""
13115 (buffer . ,(current-buffer))
13116 . ,(bookmark-get-bookmark-record bookmark)))))
13118 (gnus-summary-make-all-marking-commands)
13120 (provide 'gnus-sum)
13122 (run-hooks 'gnus-sum-load-hook)
13124 ;; Local Variables:
13125 ;; coding: utf-8
13126 ;; End:
13128 ;;; gnus-sum.el ends here