Commit | Line | Data |
---|---|---|
eec82323 | 1 | ;;; gnus-sum.el --- summary mode commands for Gnus |
23f87bed | 2 | ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 |
16409b0b | 3 | ;; Free Software Foundation, Inc. |
eec82323 | 4 | |
6748645f | 5 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
eec82323 LMI |
6 | ;; Keywords: news |
7 | ||
8 | ;; This file is part of GNU Emacs. | |
9 | ||
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 | ;; it under the terms of the GNU General Public License as published by | |
12 | ;; the Free Software Foundation; either version 2, or (at your option) | |
13 | ;; any later version. | |
14 | ||
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. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
24 | ||
25 | ;;; Commentary: | |
26 | ||
27 | ;;; Code: | |
28 | ||
23f87bed MB |
29 | (eval-when-compile |
30 | (require 'cl) | |
31 | (defvar tool-bar-map)) | |
5ab7173c | 32 | |
eec82323 LMI |
33 | (require 'gnus) |
34 | (require 'gnus-group) | |
35 | (require 'gnus-spec) | |
36 | (require 'gnus-range) | |
37 | (require 'gnus-int) | |
38 | (require 'gnus-undo) | |
6748645f | 39 | (require 'gnus-util) |
16409b0b | 40 | (require 'mm-decode) |
08c9a385 | 41 | (require 'nnoo) |
23f87bed | 42 | |
6748645f | 43 | (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t) |
d4dfaa19 | 44 | (autoload 'gnus-cache-write-active "gnus-cache") |
23f87bed MB |
45 | (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t) |
46 | (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t) | |
08c9a385 | 47 | (autoload 'mm-uu-dissect "mm-uu") |
23f87bed MB |
48 | (autoload 'gnus-article-outlook-deuglify-article "deuglify" |
49 | "Deuglify broken Outlook (Express) articles and redisplay." | |
50 | t) | |
51 | (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t) | |
52 | (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t) | |
53 | (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t) | |
eec82323 LMI |
54 | |
55 | (defcustom gnus-kill-summary-on-exit t | |
56 | "*If non-nil, kill the summary buffer when you exit from it. | |
57 | If nil, the summary will become a \"*Dead Summary*\" buffer, and | |
58 | it will be killed sometime later." | |
59 | :group 'gnus-summary-exit | |
60 | :type 'boolean) | |
61 | ||
62 | (defcustom gnus-fetch-old-headers nil | |
63 | "*Non-nil means that Gnus will try to build threads by grabbing old headers. | |
64 | If an unread article in the group refers to an older, already read (or | |
65 | just marked as read) article, the old article will not normally be | |
1232b9cb | 66 | displayed in the Summary buffer. If this variable is t, Gnus |
eec82323 | 67 | will attempt to grab the headers to the old articles, and thereby |
6748645f LMI |
68 | build complete threads. If it has the value `some', only enough |
69 | headers to connect otherwise loose threads will be displayed. This | |
70 | variable can also be a number. In that case, no more than that number | |
71 | of old headers will be fetched. If it has the value `invisible', all | |
72 | old headers will be fetched, but none will be displayed. | |
eec82323 LMI |
73 | |
74 | The server has to support NOV for any of this to work." | |
75 | :group 'gnus-thread | |
76 | :type '(choice (const :tag "off" nil) | |
1232b9cb | 77 | (const :tag "on" t) |
eec82323 | 78 | (const some) |
1232b9cb | 79 | (const invisible) |
eec82323 LMI |
80 | number |
81 | (sexp :menu-tag "other" t))) | |
82 | ||
6748645f LMI |
83 | (defcustom gnus-refer-thread-limit 200 |
84 | "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread]. | |
85 | If t, fetch all the available old headers." | |
86 | :group 'gnus-thread | |
87 | :type '(choice number | |
88 | (sexp :menu-tag "other" t))) | |
89 | ||
eec82323 LMI |
90 | (defcustom gnus-summary-make-false-root 'adopt |
91 | "*nil means that Gnus won't gather loose threads. | |
92 | If the root of a thread has expired or been read in a previous | |
93 | session, the information necessary to build a complete thread has been | |
94 | lost. Instead of having many small sub-threads from this original thread | |
95 | scattered all over the summary buffer, Gnus can gather them. | |
96 | ||
97 | If non-nil, Gnus will try to gather all loose sub-threads from an | |
98 | original thread into one large thread. | |
99 | ||
100 | If this variable is non-nil, it should be one of `none', `adopt', | |
101 | `dummy' or `empty'. | |
102 | ||
103 | If this variable is `none', Gnus will not make a false root, but just | |
104 | present the sub-threads after another. | |
105 | If this variable is `dummy', Gnus will create a dummy root that will | |
106 | have all the sub-threads as children. | |
107 | If this variable is `adopt', Gnus will make one of the \"children\" | |
108 | the parent and mark all the step-children as such. | |
109 | If this variable is `empty', the \"children\" are printed with empty | |
110 | subject fields. (Or rather, they will be printed with a string | |
111 | given by the `gnus-summary-same-subject' variable.)" | |
112 | :group 'gnus-thread | |
113 | :type '(choice (const :tag "off" nil) | |
114 | (const none) | |
115 | (const dummy) | |
116 | (const adopt) | |
117 | (const empty))) | |
118 | ||
23f87bed MB |
119 | (defcustom gnus-summary-make-false-root-always nil |
120 | "Always make a false dummy root." | |
a08b59c9 | 121 | :version "21.4" |
23f87bed MB |
122 | :group 'gnus-thread |
123 | :type 'boolean) | |
124 | ||
eec82323 LMI |
125 | (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$" |
126 | "*A regexp to match subjects to be excluded from loose thread gathering. | |
127 | As loose thread gathering is done on subjects only, that means that | |
128 | there can be many false gatherings performed. By rooting out certain | |
129 | common subjects, gathering might become saner." | |
130 | :group 'gnus-thread | |
131 | :type 'regexp) | |
132 | ||
133 | (defcustom gnus-summary-gather-subject-limit nil | |
134 | "*Maximum length of subject comparisons when gathering loose threads. | |
135 | Use nil to compare full subjects. Setting this variable to a low | |
136 | number will help gather threads that have been corrupted by | |
137 | newsreaders chopping off subject lines, but it might also mean that | |
138 | unrelated articles that have subject that happen to begin with the | |
139 | same few characters will be incorrectly gathered. | |
140 | ||
141 | If this variable is `fuzzy', Gnus will use a fuzzy algorithm when | |
142 | comparing subjects." | |
143 | :group 'gnus-thread | |
144 | :type '(choice (const :tag "off" nil) | |
145 | (const fuzzy) | |
146 | (sexp :menu-tag "on" t))) | |
147 | ||
6748645f LMI |
148 | (defcustom gnus-simplify-subject-functions nil |
149 | "List of functions taking a string argument that simplify subjects. | |
150 | The functions are applied recursively. | |
151 | ||
23f87bed MB |
152 | Useful functions to put in this list include: |
153 | `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy', | |
154 | `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'." | |
6748645f LMI |
155 | :group 'gnus-thread |
156 | :type '(repeat function)) | |
157 | ||
eec82323 | 158 | (defcustom gnus-simplify-ignored-prefixes nil |
23f87bed | 159 | "*Remove matches for this regexp from subject lines when simplifying fuzzily." |
eec82323 LMI |
160 | :group 'gnus-thread |
161 | :type '(choice (const :tag "off" nil) | |
162 | regexp)) | |
163 | ||
164 | (defcustom gnus-build-sparse-threads nil | |
165 | "*If non-nil, fill in the gaps in threads. | |
166 | If `some', only fill in the gaps that are needed to tie loose threads | |
167 | together. If `more', fill in all leaf nodes that Gnus can find. If | |
168 | non-nil and non-`some', fill in all gaps that Gnus manages to guess." | |
169 | :group 'gnus-thread | |
170 | :type '(choice (const :tag "off" nil) | |
171 | (const some) | |
172 | (const more) | |
173 | (sexp :menu-tag "all" t))) | |
174 | ||
175 | (defcustom gnus-summary-thread-gathering-function | |
176 | 'gnus-gather-threads-by-subject | |
6748645f | 177 | "*Function used for gathering loose threads. |
eec82323 LMI |
178 | There are two pre-defined functions: `gnus-gather-threads-by-subject', |
179 | which only takes Subjects into consideration; and | |
180 | `gnus-gather-threads-by-references', which compared the References | |
181 | headers of the articles to find matches." | |
182 | :group 'gnus-thread | |
22115a9e RS |
183 | :type '(radio (function-item gnus-gather-threads-by-subject) |
184 | (function-item gnus-gather-threads-by-references) | |
185 | (function :tag "other"))) | |
eec82323 | 186 | |
eec82323 LMI |
187 | (defcustom gnus-summary-same-subject "" |
188 | "*String indicating that the current article has the same subject as the previous. | |
189 | This variable will only be used if the value of | |
190 | `gnus-summary-make-false-root' is `empty'." | |
191 | :group 'gnus-summary-format | |
192 | :type 'string) | |
193 | ||
194 | (defcustom gnus-summary-goto-unread t | |
16409b0b GM |
195 | "*If t, many commands will go to the next unread article. |
196 | This applies to marking commands as well as other commands that | |
197 | \"naturally\" select the next article, like, for instance, `SPC' at | |
198 | the end of an article. | |
199 | ||
200 | If nil, the marking commands do NOT go to the next unread article | |
2642ac8f | 201 | \(they go to the next article instead). If `never', commands that |
16409b0b GM |
202 | usually go to the next unread article, will go to the next article, |
203 | whether it is read or not." | |
eec82323 LMI |
204 | :group 'gnus-summary-marks |
205 | :link '(custom-manual "(gnus)Setting Marks") | |
206 | :type '(choice (const :tag "off" nil) | |
207 | (const never) | |
208 | (sexp :menu-tag "on" t))) | |
209 | ||
210 | (defcustom gnus-summary-default-score 0 | |
211 | "*Default article score level. | |
212 | All scores generated by the score files will be added to this score. | |
213 | If this variable is nil, scoring will be disabled." | |
214 | :group 'gnus-score-default | |
215 | :type '(choice (const :tag "disable") | |
216 | integer)) | |
217 | ||
23f87bed MB |
218 | (defcustom gnus-summary-default-high-score 0 |
219 | "*Default threshold for a high scored article. | |
220 | An article will be highlighted as high scored if its score is greater | |
221 | than this score." | |
a08b59c9 | 222 | :version "21.4" |
23f87bed MB |
223 | :group 'gnus-score-default |
224 | :type 'integer) | |
225 | ||
226 | (defcustom gnus-summary-default-low-score 0 | |
227 | "*Default threshold for a low scored article. | |
228 | An article will be highlighted as low scored if its score is smaller | |
229 | than this score." | |
a08b59c9 | 230 | :version "21.4" |
23f87bed MB |
231 | :group 'gnus-score-default |
232 | :type 'integer) | |
233 | ||
eec82323 LMI |
234 | (defcustom gnus-summary-zcore-fuzz 0 |
235 | "*Fuzziness factor for the zcore in the summary buffer. | |
236 | Articles with scores closer than this to `gnus-summary-default-score' | |
237 | will not be marked." | |
238 | :group 'gnus-summary-format | |
239 | :type 'integer) | |
240 | ||
241 | (defcustom gnus-simplify-subject-fuzzy-regexp nil | |
242 | "*Strings to be removed when doing fuzzy matches. | |
243 | This can either be a regular expression or list of regular expressions | |
244 | that will be removed from subject strings if fuzzy subject | |
245 | simplification is selected." | |
246 | :group 'gnus-thread | |
247 | :type '(repeat regexp)) | |
248 | ||
249 | (defcustom gnus-show-threads t | |
250 | "*If non-nil, display threads in summary mode." | |
251 | :group 'gnus-thread | |
252 | :type 'boolean) | |
253 | ||
254 | (defcustom gnus-thread-hide-subtree nil | |
255 | "*If non-nil, hide all threads initially. | |
23f87bed | 256 | This can be a predicate specifier which says which threads to hide. |
eec82323 LMI |
257 | If threads are hidden, you have to run the command |
258 | `gnus-summary-show-thread' by hand or use `gnus-select-article-hook' | |
259 | to expose hidden threads." | |
260 | :group 'gnus-thread | |
23f87bed MB |
261 | :type '(radio (sexp :format "Non-nil\n" |
262 | :match (lambda (widget value) | |
263 | (not (or (consp value) (functionp value)))) | |
264 | :value t) | |
265 | (const nil) | |
266 | (sexp :tag "Predicate specifier" :size 0))) | |
eec82323 LMI |
267 | |
268 | (defcustom gnus-thread-hide-killed t | |
269 | "*If non-nil, hide killed threads automatically." | |
270 | :group 'gnus-thread | |
271 | :type 'boolean) | |
272 | ||
6748645f LMI |
273 | (defcustom gnus-thread-ignore-subject t |
274 | "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header. | |
275 | If nil, articles that have different subjects from their parents will | |
276 | start separate threads." | |
eec82323 LMI |
277 | :group 'gnus-thread |
278 | :type 'boolean) | |
279 | ||
280 | (defcustom gnus-thread-operation-ignore-subject t | |
281 | "*If non-nil, subjects will be ignored when doing thread commands. | |
282 | This affects commands like `gnus-summary-kill-thread' and | |
283 | `gnus-summary-lower-thread'. | |
284 | ||
285 | If this variable is nil, articles in the same thread with different | |
286 | subjects will not be included in the operation in question. If this | |
287 | variable is `fuzzy', only articles that have subjects that are fuzzily | |
288 | equal will be included." | |
289 | :group 'gnus-thread | |
290 | :type '(choice (const :tag "off" nil) | |
291 | (const fuzzy) | |
292 | (sexp :tag "on" t))) | |
293 | ||
294 | (defcustom gnus-thread-indent-level 4 | |
295 | "*Number that says how much each sub-thread should be indented." | |
296 | :group 'gnus-thread | |
297 | :type 'integer) | |
298 | ||
299 | (defcustom gnus-auto-extend-newsgroup t | |
300 | "*If non-nil, extend newsgroup forward and backward when requested." | |
301 | :group 'gnus-summary-choose | |
302 | :type 'boolean) | |
303 | ||
304 | (defcustom gnus-auto-select-first t | |
23f87bed MB |
305 | "*If non-nil, select the article under point. |
306 | Which article this is is controlled by the `gnus-auto-select-subject' | |
307 | variable. | |
308 | ||
309 | If you want to prevent automatic selection of articles in some | |
310 | newsgroups, set the variable to nil in `gnus-select-group-hook'." | |
eec82323 LMI |
311 | :group 'gnus-group-select |
312 | :type '(choice (const :tag "none" nil) | |
23f87bed MB |
313 | (sexp :menu-tag "first" t))) |
314 | ||
315 | (defcustom gnus-auto-select-subject 'unread | |
316 | "*Says what subject to place under point when entering a group. | |
317 | ||
318 | This variable can either be the symbols `first' (place point on the | |
319 | first subject), `unread' (place point on the subject line of the first | |
320 | unread article), `best' (place point on the subject line of the | |
321 | higest-scored article), `unseen' (place point on the subject line of | |
322 | the first unseen article), 'unseen-or-unread' (place point on the subject | |
323 | line of the first unseen article or, if all article have been seen, on the | |
324 | subject line of the first unread article), or a function to be called to | |
325 | place point on some subject line." | |
a08b59c9 | 326 | :version "21.4" |
23f87bed MB |
327 | :group 'gnus-group-select |
328 | :type '(choice (const best) | |
329 | (const unread) | |
330 | (const first) | |
331 | (const unseen) | |
332 | (const unseen-or-unread))) | |
eec82323 LMI |
333 | |
334 | (defcustom gnus-auto-select-next t | |
335 | "*If non-nil, offer to go to the next group from the end of the previous. | |
336 | If the value is t and the next newsgroup is empty, Gnus will exit | |
23f87bed MB |
337 | summary mode and go back to group mode. If the value is neither nil |
338 | nor t, Gnus will select the following unread newsgroup. In | |
eec82323 LMI |
339 | particular, if the value is the symbol `quietly', the next unread |
340 | newsgroup will be selected without any confirmation, and if it is | |
341 | `almost-quietly', the next group will be selected without any | |
342 | confirmation if you are located on the last article in the group. | |
23f87bed | 343 | Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command |
eec82323 LMI |
344 | will go to the next group without confirmation." |
345 | :group 'gnus-summary-maneuvering | |
346 | :type '(choice (const :tag "off" nil) | |
347 | (const quietly) | |
348 | (const almost-quietly) | |
349 | (const slightly-quietly) | |
350 | (sexp :menu-tag "on" t))) | |
351 | ||
352 | (defcustom gnus-auto-select-same nil | |
6748645f LMI |
353 | "*If non-nil, select the next article with the same subject. |
354 | If there are no more articles with the same subject, go to | |
355 | the first unread article." | |
eec82323 LMI |
356 | :group 'gnus-summary-maneuvering |
357 | :type 'boolean) | |
358 | ||
23f87bed MB |
359 | (defcustom gnus-auto-goto-ignores 'unfetched |
360 | "*Says how to handle unfetched articles when maneuvering. | |
361 | ||
362 | This variable can either be the symbols nil (maneuver to any | |
363 | article), `undownloaded' (maneuvering while unplugged ignores articles | |
364 | that have not been fetched), `always-undownloaded' (maneuvering always | |
365 | ignores articles that have not been fetched), `unfetched' (maneuvering | |
366 | ignores articles whose headers have not been fetched). | |
367 | ||
368 | NOTE: The list of unfetched articles will always be nil when plugged | |
369 | and, when unplugged, a subset of the undownloaded article list." | |
a08b59c9 | 370 | :version "21.4" |
23f87bed MB |
371 | :group 'gnus-summary-maneuvering |
372 | :type '(choice (const :tag "None" nil) | |
373 | (const :tag "Undownloaded when unplugged" undownloaded) | |
374 | (const :tag "Undownloaded" always-undownloaded) | |
375 | (const :tag "Unfetched" unfetched))) | |
376 | ||
eec82323 LMI |
377 | (defcustom gnus-summary-check-current nil |
378 | "*If non-nil, consider the current article when moving. | |
379 | The \"unread\" movement commands will stay on the same line if the | |
380 | current article is unread." | |
381 | :group 'gnus-summary-maneuvering | |
382 | :type 'boolean) | |
383 | ||
384 | (defcustom gnus-auto-center-summary t | |
385 | "*If non-nil, always center the current summary buffer. | |
386 | In particular, if `vertical' do only vertical recentering. If non-nil | |
387 | and non-`vertical', do both horizontal and vertical recentering." | |
388 | :group 'gnus-summary-maneuvering | |
389 | :type '(choice (const :tag "none" nil) | |
390 | (const vertical) | |
16409b0b | 391 | (integer :tag "height") |
eec82323 LMI |
392 | (sexp :menu-tag "both" t))) |
393 | ||
23f87bed MB |
394 | (defvar gnus-auto-center-group t |
395 | "*If non-nil, always center the group buffer.") | |
396 | ||
eec82323 LMI |
397 | (defcustom gnus-show-all-headers nil |
398 | "*If non-nil, don't hide any headers." | |
399 | :group 'gnus-article-hiding | |
400 | :group 'gnus-article-headers | |
401 | :type 'boolean) | |
402 | ||
403 | (defcustom gnus-summary-ignore-duplicates nil | |
404 | "*If non-nil, ignore articles with identical Message-ID headers." | |
405 | :group 'gnus-summary | |
406 | :type 'boolean) | |
6748645f | 407 | |
eec82323 LMI |
408 | (defcustom gnus-single-article-buffer t |
409 | "*If non-nil, display all articles in the same buffer. | |
410 | If nil, each group will get its own article buffer." | |
411 | :group 'gnus-article-various | |
412 | :type 'boolean) | |
413 | ||
414 | (defcustom gnus-break-pages t | |
415 | "*If non-nil, do page breaking on articles. | |
416 | The page delimiter is specified by the `gnus-page-delimiter' | |
417 | variable." | |
418 | :group 'gnus-article-various | |
419 | :type 'boolean) | |
420 | ||
eec82323 LMI |
421 | (defcustom gnus-move-split-methods nil |
422 | "*Variable used to suggest where articles are to be moved to. | |
23f87bed MB |
423 | It uses the same syntax as the `gnus-split-methods' variable. |
424 | However, whereas `gnus-split-methods' specifies file names as targets, | |
425 | this variable specifies group names." | |
eec82323 | 426 | :group 'gnus-summary-mail |
6748645f LMI |
427 | :type '(repeat (choice (list :value (fun) function) |
428 | (cons :value ("" "") regexp (repeat string)) | |
429 | (sexp :value nil)))) | |
eec82323 | 430 | |
23f87bed | 431 | (defcustom gnus-unread-mark ? ;Whitespace |
eec82323 LMI |
432 | "*Mark used for unread articles." |
433 | :group 'gnus-summary-marks | |
434 | :type 'character) | |
435 | ||
436 | (defcustom gnus-ticked-mark ?! | |
437 | "*Mark used for ticked articles." | |
438 | :group 'gnus-summary-marks | |
439 | :type 'character) | |
440 | ||
441 | (defcustom gnus-dormant-mark ?? | |
442 | "*Mark used for dormant articles." | |
443 | :group 'gnus-summary-marks | |
444 | :type 'character) | |
445 | ||
446 | (defcustom gnus-del-mark ?r | |
447 | "*Mark used for del'd articles." | |
448 | :group 'gnus-summary-marks | |
449 | :type 'character) | |
450 | ||
451 | (defcustom gnus-read-mark ?R | |
452 | "*Mark used for read articles." | |
453 | :group 'gnus-summary-marks | |
454 | :type 'character) | |
455 | ||
456 | (defcustom gnus-expirable-mark ?E | |
457 | "*Mark used for expirable articles." | |
458 | :group 'gnus-summary-marks | |
459 | :type 'character) | |
460 | ||
461 | (defcustom gnus-killed-mark ?K | |
462 | "*Mark used for killed articles." | |
463 | :group 'gnus-summary-marks | |
464 | :type 'character) | |
465 | ||
23f87bed MB |
466 | (defcustom gnus-spam-mark ?$ |
467 | "*Mark used for spam articles." | |
468 | :group 'gnus-summary-marks | |
469 | :type 'character) | |
470 | ||
eec82323 | 471 | (defcustom gnus-souped-mark ?F |
23f87bed | 472 | "*Mark used for souped articles." |
eec82323 LMI |
473 | :group 'gnus-summary-marks |
474 | :type 'character) | |
475 | ||
476 | (defcustom gnus-kill-file-mark ?X | |
477 | "*Mark used for articles killed by kill files." | |
478 | :group 'gnus-summary-marks | |
479 | :type 'character) | |
480 | ||
481 | (defcustom gnus-low-score-mark ?Y | |
482 | "*Mark used for articles with a low score." | |
483 | :group 'gnus-summary-marks | |
484 | :type 'character) | |
485 | ||
486 | (defcustom gnus-catchup-mark ?C | |
487 | "*Mark used for articles that are caught up." | |
488 | :group 'gnus-summary-marks | |
489 | :type 'character) | |
490 | ||
491 | (defcustom gnus-replied-mark ?A | |
492 | "*Mark used for articles that have been replied to." | |
493 | :group 'gnus-summary-marks | |
494 | :type 'character) | |
495 | ||
23f87bed MB |
496 | (defcustom gnus-forwarded-mark ?F |
497 | "*Mark used for articles that have been forwarded." | |
a08b59c9 | 498 | :version "21.4" |
23f87bed MB |
499 | :group 'gnus-summary-marks |
500 | :type 'character) | |
501 | ||
502 | (defcustom gnus-recent-mark ?N | |
503 | "*Mark used for articles that are recent." | |
504 | :group 'gnus-summary-marks | |
505 | :type 'character) | |
506 | ||
eec82323 LMI |
507 | (defcustom gnus-cached-mark ?* |
508 | "*Mark used for articles that are in the cache." | |
509 | :group 'gnus-summary-marks | |
510 | :type 'character) | |
511 | ||
512 | (defcustom gnus-saved-mark ?S | |
23f87bed MB |
513 | "*Mark used for articles that have been saved." |
514 | :group 'gnus-summary-marks | |
515 | :type 'character) | |
516 | ||
517 | (defcustom gnus-unseen-mark ?. | |
518 | "*Mark used for articles that haven't been seen." | |
a08b59c9 | 519 | :version "21.4" |
23f87bed MB |
520 | :group 'gnus-summary-marks |
521 | :type 'character) | |
522 | ||
523 | (defcustom gnus-no-mark ? ;Whitespace | |
524 | "*Mark used for articles that have no other secondary mark." | |
a08b59c9 | 525 | :version "21.4" |
eec82323 LMI |
526 | :group 'gnus-summary-marks |
527 | :type 'character) | |
528 | ||
529 | (defcustom gnus-ancient-mark ?O | |
530 | "*Mark used for ancient articles." | |
531 | :group 'gnus-summary-marks | |
532 | :type 'character) | |
533 | ||
534 | (defcustom gnus-sparse-mark ?Q | |
535 | "*Mark used for sparsely reffed articles." | |
536 | :group 'gnus-summary-marks | |
537 | :type 'character) | |
538 | ||
539 | (defcustom gnus-canceled-mark ?G | |
540 | "*Mark used for canceled articles." | |
541 | :group 'gnus-summary-marks | |
542 | :type 'character) | |
543 | ||
544 | (defcustom gnus-duplicate-mark ?M | |
545 | "*Mark used for duplicate articles." | |
546 | :group 'gnus-summary-marks | |
547 | :type 'character) | |
548 | ||
23f87bed | 549 | (defcustom gnus-undownloaded-mark ?- |
6748645f LMI |
550 | "*Mark used for articles that weren't downloaded." |
551 | :group 'gnus-summary-marks | |
552 | :type 'character) | |
553 | ||
23f87bed MB |
554 | (defcustom gnus-downloaded-mark ?+ |
555 | "*Mark used for articles that were downloaded." | |
556 | :group 'gnus-summary-marks | |
557 | :type 'character) | |
558 | ||
6748645f LMI |
559 | (defcustom gnus-downloadable-mark ?% |
560 | "*Mark used for articles that are to be downloaded." | |
561 | :group 'gnus-summary-marks | |
562 | :type 'character) | |
563 | ||
564 | (defcustom gnus-unsendable-mark ?= | |
565 | "*Mark used for articles that won't be sent." | |
566 | :group 'gnus-summary-marks | |
567 | :type 'character) | |
568 | ||
eec82323 LMI |
569 | (defcustom gnus-score-over-mark ?+ |
570 | "*Score mark used for articles with high scores." | |
571 | :group 'gnus-summary-marks | |
572 | :type 'character) | |
573 | ||
574 | (defcustom gnus-score-below-mark ?- | |
575 | "*Score mark used for articles with low scores." | |
576 | :group 'gnus-summary-marks | |
577 | :type 'character) | |
578 | ||
23f87bed | 579 | (defcustom gnus-empty-thread-mark ? ;Whitespace |
eec82323 LMI |
580 | "*There is no thread under the article." |
581 | :group 'gnus-summary-marks | |
582 | :type 'character) | |
583 | ||
584 | (defcustom gnus-not-empty-thread-mark ?= | |
585 | "*There is a thread under the article." | |
586 | :group 'gnus-summary-marks | |
587 | :type 'character) | |
588 | ||
589 | (defcustom gnus-view-pseudo-asynchronously nil | |
590 | "*If non-nil, Gnus will view pseudo-articles asynchronously." | |
591 | :group 'gnus-extract-view | |
592 | :type 'boolean) | |
593 | ||
16409b0b GM |
594 | (defcustom gnus-auto-expirable-marks |
595 | (list gnus-killed-mark gnus-del-mark gnus-catchup-mark | |
596 | gnus-low-score-mark gnus-ancient-mark gnus-read-mark | |
597 | gnus-souped-mark gnus-duplicate-mark) | |
598 | "*The list of marks converted into expiration if a group is auto-expirable." | |
58e39d05 | 599 | :version "21.1" |
16409b0b GM |
600 | :group 'gnus-summary |
601 | :type '(repeat character)) | |
602 | ||
603 | (defcustom gnus-inhibit-user-auto-expire t | |
604 | "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on." | |
58e39d05 | 605 | :version "21.1" |
16409b0b GM |
606 | :group 'gnus-summary |
607 | :type 'boolean) | |
608 | ||
eec82323 LMI |
609 | (defcustom gnus-view-pseudos nil |
610 | "*If `automatic', pseudo-articles will be viewed automatically. | |
611 | If `not-confirm', pseudos will be viewed automatically, and the user | |
612 | will not be asked to confirm the command." | |
613 | :group 'gnus-extract-view | |
614 | :type '(choice (const :tag "off" nil) | |
615 | (const automatic) | |
616 | (const not-confirm))) | |
617 | ||
618 | (defcustom gnus-view-pseudos-separately t | |
619 | "*If non-nil, one pseudo-article will be created for each file to be viewed. | |
620 | If nil, all files that use the same viewing command will be given as a | |
621 | list of parameters to that command." | |
622 | :group 'gnus-extract-view | |
623 | :type 'boolean) | |
624 | ||
625 | (defcustom gnus-insert-pseudo-articles t | |
626 | "*If non-nil, insert pseudo-articles when decoding articles." | |
627 | :group 'gnus-extract-view | |
628 | :type 'boolean) | |
629 | ||
630 | (defcustom gnus-summary-dummy-line-format | |
23f87bed | 631 | " %(: :%) %S\n" |
eec82323 LMI |
632 | "*The format specification for the dummy roots in the summary buffer. |
633 | It works along the same lines as a normal formatting string, | |
634 | with some simple extensions. | |
635 | ||
23f87bed MB |
636 | %S The subject |
637 | ||
638 | General format specifiers can also be used. | |
639 | See `(gnus)Formatting Variables'." | |
640 | :link '(custom-manual "(gnus)Formatting Variables") | |
eec82323 LMI |
641 | :group 'gnus-threading |
642 | :type 'string) | |
643 | ||
16409b0b | 644 | (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z" |
eec82323 LMI |
645 | "*The format specification for the summary mode line. |
646 | It works along the same lines as a normal formatting string, | |
647 | with some simple extensions: | |
648 | ||
649 | %G Group name | |
650 | %p Unprefixed group name | |
651 | %A Current article number | |
6748645f | 652 | %z Current article score |
eec82323 LMI |
653 | %V Gnus version |
654 | %U Number of unread articles in the group | |
655 | %e Number of unselected articles in the group | |
656 | %Z A string with unread/unselected article counts | |
657 | %g Shortish group name | |
658 | %S Subject of the current article | |
659 | %u User-defined spec | |
660 | %s Current score file name | |
661 | %d Number of dormant articles | |
662 | %r Number of articles that have been marked as read in this session | |
663 | %E Number of articles expunged by the score files" | |
664 | :group 'gnus-summary-format | |
665 | :type 'string) | |
666 | ||
16409b0b GM |
667 | (defcustom gnus-list-identifiers nil |
668 | "Regexp that matches list identifiers to be removed from subject. | |
669 | This can also be a list of regexps." | |
58e39d05 | 670 | :version "21.1" |
16409b0b GM |
671 | :group 'gnus-summary-format |
672 | :group 'gnus-article-hiding | |
673 | :type '(choice (const :tag "none" nil) | |
674 | (regexp :value ".*") | |
675 | (repeat :value (".*") regexp))) | |
676 | ||
eec82323 LMI |
677 | (defcustom gnus-summary-mark-below 0 |
678 | "*Mark all articles with a score below this variable as read. | |
679 | This variable is local to each summary buffer and usually set by the | |
680 | score file." | |
681 | :group 'gnus-score-default | |
682 | :type 'integer) | |
683 | ||
684 | (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number) | |
685 | "*List of functions used for sorting articles in the summary buffer. | |
23f87bed MB |
686 | |
687 | Each function takes two articles and returns non-nil if the first | |
688 | article should be sorted before the other. If you use more than one | |
689 | function, the primary sort function should be the last. You should | |
690 | probably always include `gnus-article-sort-by-number' in the list of | |
691 | sorting functions -- preferably first. Also note that sorting by date | |
692 | is often much slower than sorting by number, and the sorting order is | |
693 | very similar. (Sorting by date means sorting by the time the message | |
694 | was sent, sorting by number means sorting by arrival time.) | |
695 | ||
696 | Ready-made functions include `gnus-article-sort-by-number', | |
697 | `gnus-article-sort-by-author', `gnus-article-sort-by-subject', | |
698 | `gnus-article-sort-by-date', `gnus-article-sort-by-random' | |
699 | and `gnus-article-sort-by-score'. | |
700 | ||
701 | When threading is turned on, the variable `gnus-thread-sort-functions' | |
702 | controls how articles are sorted." | |
eec82323 LMI |
703 | :group 'gnus-summary-sort |
704 | :type '(repeat (choice (function-item gnus-article-sort-by-number) | |
705 | (function-item gnus-article-sort-by-author) | |
706 | (function-item gnus-article-sort-by-subject) | |
707 | (function-item gnus-article-sort-by-date) | |
708 | (function-item gnus-article-sort-by-score) | |
23f87bed | 709 | (function-item gnus-article-sort-by-random) |
eec82323 LMI |
710 | (function :tag "other")))) |
711 | ||
712 | (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number) | |
713 | "*List of functions used for sorting threads in the summary buffer. | |
714 | By default, threads are sorted by article number. | |
715 | ||
23f87bed MB |
716 | Each function takes two threads and returns non-nil if the first |
717 | thread should be sorted before the other. If you use more than one | |
718 | function, the primary sort function should be the last. You should | |
719 | probably always include `gnus-thread-sort-by-number' in the list of | |
720 | sorting functions -- preferably first. Also note that sorting by date | |
721 | is often much slower than sorting by number, and the sorting order is | |
722 | very similar. (Sorting by date means sorting by the time the message | |
723 | was sent, sorting by number means sorting by arrival time.) | |
eec82323 LMI |
724 | |
725 | Ready-made functions include `gnus-thread-sort-by-number', | |
726 | `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject', | |
23f87bed MB |
727 | `gnus-thread-sort-by-date', `gnus-thread-sort-by-score', |
728 | `gnus-thread-sort-by-most-recent-number', | |
729 | `gnus-thread-sort-by-most-recent-date', | |
730 | `gnus-thread-sort-by-random', and | |
731 | `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function'). | |
732 | ||
733 | When threading is turned off, the variable | |
734 | `gnus-article-sort-functions' controls how articles are sorted." | |
eec82323 LMI |
735 | :group 'gnus-summary-sort |
736 | :type '(repeat (choice (function-item gnus-thread-sort-by-number) | |
737 | (function-item gnus-thread-sort-by-author) | |
738 | (function-item gnus-thread-sort-by-subject) | |
739 | (function-item gnus-thread-sort-by-date) | |
740 | (function-item gnus-thread-sort-by-score) | |
741 | (function-item gnus-thread-sort-by-total-score) | |
23f87bed | 742 | (function-item gnus-thread-sort-by-random) |
eec82323 LMI |
743 | (function :tag "other")))) |
744 | ||
745 | (defcustom gnus-thread-score-function '+ | |
746 | "*Function used for calculating the total score of a thread. | |
747 | ||
748 | The function is called with the scores of the article and each | |
749 | subthread and should then return the score of the thread. | |
750 | ||
751 | Some functions you can use are `+', `max', or `min'." | |
752 | :group 'gnus-summary-sort | |
753 | :type 'function) | |
754 | ||
755 | (defcustom gnus-summary-expunge-below nil | |
6748645f LMI |
756 | "All articles that have a score less than this variable will be expunged. |
757 | This variable is local to the summary buffers." | |
eec82323 LMI |
758 | :group 'gnus-score-default |
759 | :type '(choice (const :tag "off" nil) | |
760 | integer)) | |
761 | ||
762 | (defcustom gnus-thread-expunge-below nil | |
763 | "All threads that have a total score less than this variable will be expunged. | |
764 | See `gnus-thread-score-function' for en explanation of what a | |
6748645f LMI |
765 | \"thread score\" is. |
766 | ||
767 | This variable is local to the summary buffers." | |
16409b0b | 768 | :group 'gnus-threading |
eec82323 LMI |
769 | :group 'gnus-score-default |
770 | :type '(choice (const :tag "off" nil) | |
771 | integer)) | |
772 | ||
773 | (defcustom gnus-summary-mode-hook nil | |
774 | "*A hook for Gnus summary mode. | |
775 | This hook is run before any variables are set in the summary buffer." | |
23f87bed | 776 | :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode) |
eec82323 LMI |
777 | :group 'gnus-summary-various |
778 | :type 'hook) | |
779 | ||
23f87bed MB |
780 | ;; Extracted from gnus-xmas-redefine in order to preserve user settings |
781 | (when (featurep 'xemacs) | |
782 | (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add) | |
783 | (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar) | |
784 | (add-hook 'gnus-summary-mode-hook | |
785 | 'gnus-xmas-switch-horizontal-scrollbar-off)) | |
786 | ||
eec82323 LMI |
787 | (defcustom gnus-summary-menu-hook nil |
788 | "*Hook run after the creation of the summary mode menu." | |
789 | :group 'gnus-summary-visual | |
790 | :type 'hook) | |
791 | ||
792 | (defcustom gnus-summary-exit-hook nil | |
793 | "*A hook called on exit from the summary buffer. | |
794 | It will be called with point in the group buffer." | |
795 | :group 'gnus-summary-exit | |
796 | :type 'hook) | |
797 | ||
798 | (defcustom gnus-summary-prepare-hook nil | |
799 | "*A hook called after the summary buffer has been generated. | |
800 | If you want to modify the summary buffer, you can use this hook." | |
801 | :group 'gnus-summary-various | |
802 | :type 'hook) | |
803 | ||
6748645f LMI |
804 | (defcustom gnus-summary-prepared-hook nil |
805 | "*A hook called as the last thing after the summary buffer has been generated." | |
806 | :group 'gnus-summary-various | |
807 | :type 'hook) | |
808 | ||
eec82323 LMI |
809 | (defcustom gnus-summary-generate-hook nil |
810 | "*A hook run just before generating the summary buffer. | |
811 | This hook is commonly used to customize threading variables and the | |
812 | like." | |
813 | :group 'gnus-summary-various | |
814 | :type 'hook) | |
815 | ||
816 | (defcustom gnus-select-group-hook nil | |
817 | "*A hook called when a newsgroup is selected. | |
818 | ||
819 | If you'd like to simplify subjects like the | |
820 | `gnus-summary-next-same-subject' command does, you can use the | |
821 | following hook: | |
822 | ||
23f87bed MB |
823 | (add-hook gnus-select-group-hook |
824 | (lambda () | |
825 | (mapcar (lambda (header) | |
826 | (mail-header-set-subject | |
827 | header | |
828 | (gnus-simplify-subject | |
829 | (mail-header-subject header) 're-only))) | |
830 | gnus-newsgroup-headers)))" | |
eec82323 LMI |
831 | :group 'gnus-group-select |
832 | :type 'hook) | |
833 | ||
834 | (defcustom gnus-select-article-hook nil | |
835 | "*A hook called when an article is selected." | |
836 | :group 'gnus-summary-choose | |
23f87bed | 837 | :options '(gnus-agent-fetch-selected-article) |
eec82323 LMI |
838 | :type 'hook) |
839 | ||
840 | (defcustom gnus-visual-mark-article-hook | |
841 | (list 'gnus-highlight-selected-summary) | |
842 | "*Hook run after selecting an article in the summary buffer. | |
843 | It is meant to be used for highlighting the article in some way. It | |
844 | is not run if `gnus-visual' is nil." | |
845 | :group 'gnus-summary-visual | |
846 | :type 'hook) | |
847 | ||
16409b0b | 848 | (defcustom gnus-parse-headers-hook nil |
eec82323 LMI |
849 | "*A hook called before parsing the headers." |
850 | :group 'gnus-various | |
851 | :type 'hook) | |
852 | ||
853 | (defcustom gnus-exit-group-hook nil | |
16409b0b GM |
854 | "*A hook called when exiting summary mode. |
855 | This hook is not called from the non-updating exit commands like `Q'." | |
eec82323 LMI |
856 | :group 'gnus-various |
857 | :type 'hook) | |
858 | ||
859 | (defcustom gnus-summary-update-hook | |
860 | (list 'gnus-summary-highlight-line) | |
861 | "*A hook called when a summary line is changed. | |
862 | The hook will not be called if `gnus-visual' is nil. | |
863 | ||
864 | The default function `gnus-summary-highlight-line' will | |
865 | highlight the line according to the `gnus-summary-highlight' | |
866 | variable." | |
867 | :group 'gnus-summary-visual | |
868 | :type 'hook) | |
869 | ||
870 | (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read) | |
871 | "*A hook called when an article is selected for the first time. | |
872 | The hook is intended to mark an article as read (or unread) | |
873 | automatically when it is selected." | |
874 | :group 'gnus-summary-choose | |
875 | :type 'hook) | |
876 | ||
877 | (defcustom gnus-group-no-more-groups-hook nil | |
878 | "*A hook run when returning to group mode having no more (unread) groups." | |
879 | :group 'gnus-group-select | |
880 | :type 'hook) | |
881 | ||
882 | (defcustom gnus-ps-print-hook nil | |
883 | "*A hook run before ps-printing something from Gnus." | |
884 | :group 'gnus-summary | |
885 | :type 'hook) | |
886 | ||
23f87bed MB |
887 | (defcustom gnus-summary-article-move-hook nil |
888 | "*A hook called after an article is moved, copied, respooled, or crossposted." | |
889 | :group 'gnus-summary | |
890 | :type 'hook) | |
891 | ||
892 | (defcustom gnus-summary-article-delete-hook nil | |
893 | "*A hook called after an article is deleted." | |
894 | :group 'gnus-summary | |
895 | :type 'hook) | |
896 | ||
897 | (defcustom gnus-summary-article-expire-hook nil | |
898 | "*A hook called after an article is expired." | |
899 | :group 'gnus-summary | |
900 | :type 'hook) | |
901 | ||
902 | (defcustom gnus-summary-display-arrow | |
903 | (and (fboundp 'display-graphic-p) | |
904 | (display-graphic-p)) | |
905 | "*If non-nil, display an arrow highlighting the current article." | |
a08b59c9 | 906 | :version "21.4" |
23f87bed MB |
907 | :group 'gnus-summary |
908 | :type 'boolean) | |
909 | ||
eec82323 LMI |
910 | (defcustom gnus-summary-selected-face 'gnus-summary-selected-face |
911 | "Face used for highlighting the current article in the summary buffer." | |
912 | :group 'gnus-summary-visual | |
913 | :type 'face) | |
914 | ||
23f87bed MB |
915 | (defvar gnus-tmp-downloaded nil) |
916 | ||
eec82323 | 917 | (defcustom gnus-summary-highlight |
23f87bed | 918 | '(((eq mark gnus-canceled-mark) |
eec82323 | 919 | . gnus-summary-cancelled-face) |
23f87bed MB |
920 | ((and uncached (> score default-high)) |
921 | . gnus-summary-high-undownloaded-face) | |
922 | ((and uncached (< score default-low)) | |
923 | . gnus-summary-low-undownloaded-face) | |
924 | (uncached | |
925 | . gnus-summary-normal-undownloaded-face) | |
926 | ((and (> score default-high) | |
927 | (or (eq mark gnus-dormant-mark) | |
928 | (eq mark gnus-ticked-mark))) | |
eec82323 | 929 | . gnus-summary-high-ticked-face) |
23f87bed MB |
930 | ((and (< score default-low) |
931 | (or (eq mark gnus-dormant-mark) | |
932 | (eq mark gnus-ticked-mark))) | |
eec82323 | 933 | . gnus-summary-low-ticked-face) |
23f87bed MB |
934 | ((or (eq mark gnus-dormant-mark) |
935 | (eq mark gnus-ticked-mark)) | |
eec82323 | 936 | . gnus-summary-normal-ticked-face) |
23f87bed | 937 | ((and (> score default-high) (eq mark gnus-ancient-mark)) |
eec82323 | 938 | . gnus-summary-high-ancient-face) |
23f87bed | 939 | ((and (< score default-low) (eq mark gnus-ancient-mark)) |
eec82323 | 940 | . gnus-summary-low-ancient-face) |
23f87bed | 941 | ((eq mark gnus-ancient-mark) |
eec82323 | 942 | . gnus-summary-normal-ancient-face) |
23f87bed | 943 | ((and (> score default-high) (eq mark gnus-unread-mark)) |
eec82323 | 944 | . gnus-summary-high-unread-face) |
23f87bed | 945 | ((and (< score default-low) (eq mark gnus-unread-mark)) |
eec82323 | 946 | . gnus-summary-low-unread-face) |
23f87bed | 947 | ((eq mark gnus-unread-mark) |
6748645f | 948 | . gnus-summary-normal-unread-face) |
23f87bed | 949 | ((> score default-high) |
eec82323 | 950 | . gnus-summary-high-read-face) |
23f87bed | 951 | ((< score default-low) |
eec82323 LMI |
952 | . gnus-summary-low-read-face) |
953 | (t | |
954 | . gnus-summary-normal-read-face)) | |
6748645f | 955 | "*Controls the highlighting of summary buffer lines. |
eec82323 | 956 | |
23f87bed MB |
957 | A list of (FORM . FACE) pairs. When deciding how a a particular |
958 | summary line should be displayed, each form is evaluated. The content | |
959 | of the face field after the first true form is used. You can change | |
960 | how those summary lines are displayed, by editing the face field. | |
eec82323 LMI |
961 | |
962 | You can use the following variables in the FORM field. | |
963 | ||
23f87bed MB |
964 | score: The article's score |
965 | default: The default article score. | |
966 | default-high: The default score for high scored articles. | |
967 | default-low: The default score for low scored articles. | |
968 | below: The score below which articles are automatically marked as read. | |
969 | mark: The article's mark. | |
970 | uncached: Non-nil if the article is uncached." | |
eec82323 LMI |
971 | :group 'gnus-summary-visual |
972 | :type '(repeat (cons (sexp :tag "Form" nil) | |
973 | face))) | |
974 | ||
6748645f LMI |
975 | (defcustom gnus-alter-header-function nil |
976 | "Function called to allow alteration of article header structures. | |
977 | The function is called with one parameter, the article header vector, | |
0ab0f2d3 SZ |
978 | which it may alter in any way." |
979 | :type '(choice (const :tag "None" nil) | |
980 | function) | |
981 | :group 'gnus-summary) | |
eec82323 | 982 | |
16409b0b GM |
983 | (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string |
984 | "Variable that says which function should be used to decode a string with encoded words.") | |
985 | ||
23f87bed | 986 | (defcustom gnus-extra-headers '(To Newsgroups) |
16409b0b | 987 | "*Extra headers to parse." |
58e39d05 | 988 | :version "21.1" |
16409b0b GM |
989 | :group 'gnus-summary |
990 | :type '(repeat symbol)) | |
991 | ||
992 | (defcustom gnus-ignored-from-addresses | |
993 | (and user-mail-address (regexp-quote user-mail-address)) | |
994 | "*Regexp of From headers that may be suppressed in favor of To headers." | |
58e39d05 | 995 | :version "21.1" |
16409b0b GM |
996 | :group 'gnus-summary |
997 | :type 'regexp) | |
998 | ||
16409b0b GM |
999 | (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown) |
1000 | "List of charsets that should be ignored. | |
1001 | When these charsets are used in the \"charset\" parameter, the | |
1002 | default charset will be used instead." | |
58e39d05 | 1003 | :version "21.1" |
16409b0b GM |
1004 | :type '(repeat symbol) |
1005 | :group 'gnus-charset) | |
1006 | ||
23f87bed MB |
1007 | (gnus-define-group-parameter |
1008 | ignored-charsets | |
1009 | :type list | |
1010 | :function-document | |
1011 | "Return the ignored charsets of GROUP." | |
1012 | :variable gnus-group-ignored-charsets-alist | |
1013 | :variable-default | |
1014 | '(("alt\\.chinese\\.text" iso-8859-1)) | |
1015 | :variable-document | |
1016 | "Alist of regexps (to match group names) and charsets that should be ignored. | |
16409b0b GM |
1017 | When these charsets are used in the \"charset\" parameter, the |
1018 | default charset will be used instead." | |
23f87bed MB |
1019 | :variable-group gnus-charset |
1020 | :variable-type '(repeat (cons (regexp :tag "Group") | |
1021 | (repeat symbol))) | |
1022 | :parameter-type '(choice :tag "Ignored charsets" | |
1023 | :value nil | |
1024 | (repeat (symbol))) | |
1025 | :parameter-document "\ | |
1026 | List of charsets that should be ignored. | |
1027 | ||
1028 | When these charsets are used in the \"charset\" parameter, the | |
1029 | default charset will be used instead.") | |
16409b0b GM |
1030 | |
1031 | (defcustom gnus-group-highlight-words-alist nil | |
1032 | "Alist of group regexps and highlight regexps. | |
1033 | This variable uses the same syntax as `gnus-emphasis-alist'." | |
58e39d05 | 1034 | :version "21.1" |
16409b0b GM |
1035 | :type '(repeat (cons (regexp :tag "Group") |
1036 | (repeat (list (regexp :tag "Highlight regexp") | |
1037 | (number :tag "Group for entire word" 0) | |
1038 | (number :tag "Group for displayed part" 0) | |
1039 | (symbol :tag "Face" | |
1040 | gnus-emphasis-highlight-words))))) | |
1041 | :group 'gnus-summary-visual) | |
1042 | ||
1043 | (defcustom gnus-summary-show-article-charset-alist | |
1044 | nil | |
1045 | "Alist of number and charset. | |
1046 | The article will be shown with the charset corresponding to the | |
1047 | numbered argument. | |
1048 | For example: ((1 . cn-gb-2312) (2 . big5))." | |
58e39d05 | 1049 | :version "21.1" |
16409b0b GM |
1050 | :type '(repeat (cons (number :tag "Argument" 1) |
1051 | (symbol :tag "Charset"))) | |
1052 | :group 'gnus-charset) | |
1053 | ||
1054 | (defcustom gnus-preserve-marks t | |
1055 | "Whether marks are preserved when moving, copying and respooling messages." | |
58e39d05 | 1056 | :version "21.1" |
16409b0b GM |
1057 | :type 'boolean |
1058 | :group 'gnus-summary-marks) | |
1059 | ||
1060 | (defcustom gnus-alter-articles-to-read-function nil | |
1061 | "Function to be called to alter the list of articles to be selected." | |
8fc7a9a1 | 1062 | :type '(choice (const nil) function) |
16409b0b GM |
1063 | :group 'gnus-summary) |
1064 | ||
1065 | (defcustom gnus-orphan-score nil | |
1066 | "*All orphans get this score added. Set in the score file." | |
1067 | :group 'gnus-score-default | |
1068 | :type '(choice (const nil) | |
1069 | integer)) | |
1070 | ||
8b93df01 | 1071 | (defcustom gnus-summary-save-parts-default-mime "image/.*" |
23f87bed MB |
1072 | "*A regexp to match MIME parts when saving multiple parts of a |
1073 | message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]). | |
1074 | This regexp will be used by default when prompting the user for which | |
1075 | type of files to save." | |
8b93df01 DL |
1076 | :group 'gnus-summary |
1077 | :type 'regexp) | |
1078 | ||
23f87bed MB |
1079 | (defcustom gnus-read-all-available-headers nil |
1080 | "Whether Gnus should parse all headers made available to it. | |
1081 | This is mostly relevant for slow back ends where the user may | |
1082 | wish to widen the summary buffer to include all headers | |
1083 | that were fetched. Say, for nnultimate groups." | |
a08b59c9 | 1084 | :version "21.4" |
23f87bed MB |
1085 | :group 'gnus-summary |
1086 | :type '(choice boolean regexp)) | |
1087 | ||
1088 | (defcustom gnus-summary-muttprint-program "muttprint" | |
1089 | "Command (and optional arguments) used to run Muttprint." | |
a08b59c9 | 1090 | :version "21.4" |
23f87bed MB |
1091 | :group 'gnus-summary |
1092 | :type 'string) | |
1093 | ||
1094 | (defcustom gnus-article-loose-mime nil | |
1095 | "If non-nil, don't require MIME-Version header. | |
1096 | Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not | |
a08b59c9 | 1097 | supply the MIME-Version header or deliberately strip it from the mail. |
23f87bed MB |
1098 | Set it to non-nil, Gnus will treat some articles as MIME even if |
1099 | the MIME-Version header is missed." | |
a08b59c9 | 1100 | :version "21.4" |
23f87bed MB |
1101 | :type 'boolean |
1102 | :group 'gnus-article-mime) | |
1103 | ||
1104 | (defcustom gnus-article-emulate-mime t | |
1105 | "If non-nil, use MIME emulation for uuencode and the like. | |
1106 | This means that Gnus will search message bodies for text that look | |
1107 | like uuencoded bits, yEncoded bits, and so on, and present that using | |
1108 | the normal Gnus MIME machinery." | |
a08b59c9 | 1109 | :version "21.4" |
23f87bed MB |
1110 | :type 'boolean |
1111 | :group 'gnus-article-mime) | |
8b93df01 | 1112 | |
eec82323 LMI |
1113 | ;;; Internal variables |
1114 | ||
23f87bed | 1115 | (defvar gnus-summary-display-cache nil) |
16409b0b GM |
1116 | (defvar gnus-article-mime-handles nil) |
1117 | (defvar gnus-article-decoded-p nil) | |
23f87bed MB |
1118 | (defvar gnus-article-charset nil) |
1119 | (defvar gnus-article-ignored-charsets nil) | |
eec82323 LMI |
1120 | (defvar gnus-scores-exclude-files nil) |
1121 | (defvar gnus-page-broken nil) | |
1122 | ||
1123 | (defvar gnus-original-article nil) | |
1124 | (defvar gnus-article-internal-prepare-hook nil) | |
1125 | (defvar gnus-newsgroup-process-stack nil) | |
1126 | ||
1127 | (defvar gnus-thread-indent-array nil) | |
1128 | (defvar gnus-thread-indent-array-level gnus-thread-indent-level) | |
16409b0b GM |
1129 | (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number |
1130 | "Function called to sort the articles within a thread after it has been gathered together.") | |
eec82323 | 1131 | |
8b93df01 | 1132 | (defvar gnus-summary-save-parts-type-history nil) |
23f87bed | 1133 | (defvar gnus-summary-save-parts-last-directory mm-default-directory) |
8b93df01 | 1134 | |
eec82323 LMI |
1135 | ;; Avoid highlighting in kill files. |
1136 | (defvar gnus-summary-inhibit-highlight nil) | |
1137 | (defvar gnus-newsgroup-selected-overlay nil) | |
1138 | (defvar gnus-inhibit-limiting nil) | |
1139 | (defvar gnus-newsgroup-adaptive-score-file nil) | |
1140 | (defvar gnus-current-score-file nil) | |
1141 | (defvar gnus-current-move-group nil) | |
1142 | (defvar gnus-current-copy-group nil) | |
1143 | (defvar gnus-current-crosspost-group nil) | |
23f87bed | 1144 | (defvar gnus-newsgroup-display nil) |
eec82323 LMI |
1145 | |
1146 | (defvar gnus-newsgroup-dependencies nil) | |
1147 | (defvar gnus-newsgroup-adaptive nil) | |
1148 | (defvar gnus-summary-display-article-function nil) | |
1149 | (defvar gnus-summary-highlight-line-function nil | |
1150 | "Function called after highlighting a summary line.") | |
1151 | ||
1152 | (defvar gnus-summary-line-format-alist | |
1153 | `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d) | |
1154 | (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s) | |
1155 | (?s gnus-tmp-subject-or-nil ?s) | |
1156 | (?n gnus-tmp-name ?s) | |
1157 | (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from))) | |
1158 | ?s) | |
1159 | (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from)) | |
1160 | gnus-tmp-from) ?s) | |
1161 | (?F gnus-tmp-from ?s) | |
1162 | (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s) | |
1163 | (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s) | |
1164 | (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s) | |
6748645f | 1165 | (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s) |
eec82323 LMI |
1166 | (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s) |
1167 | (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s) | |
1168 | (?c (or (mail-header-chars gnus-tmp-header) 0) ?d) | |
23f87bed MB |
1169 | (?k (gnus-summary-line-message-size gnus-tmp-header) ?s) |
1170 | (?L gnus-tmp-lines ?s) | |
1171 | (?O gnus-tmp-downloaded ?c) | |
eec82323 LMI |
1172 | (?I gnus-tmp-indentation ?s) |
1173 | (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s) | |
1174 | (?R gnus-tmp-replied ?c) | |
1175 | (?\[ gnus-tmp-opening-bracket ?c) | |
1176 | (?\] gnus-tmp-closing-bracket ?c) | |
1177 | (?\> (make-string gnus-tmp-level ? ) ?s) | |
1178 | (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s) | |
1179 | (?i gnus-tmp-score ?d) | |
1180 | (?z gnus-tmp-score-char ?c) | |
1181 | (?l (bbb-grouplens-score gnus-tmp-header) ?s) | |
1182 | (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d) | |
1183 | (?U gnus-tmp-unread ?c) | |
23f87bed MB |
1184 | (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from) |
1185 | ?s) | |
eec82323 LMI |
1186 | (?t (gnus-summary-number-of-articles-in-thread |
1187 | (and (boundp 'thread) (car thread)) gnus-tmp-level) | |
1188 | ?d) | |
1189 | (?e (gnus-summary-number-of-articles-in-thread | |
1190 | (and (boundp 'thread) (car thread)) gnus-tmp-level t) | |
1191 | ?c) | |
1192 | (?u gnus-tmp-user-defined ?s) | |
23f87bed MB |
1193 | (?P (gnus-pick-line-number) ?d) |
1194 | (?B gnus-tmp-thread-tree-header-string ?s) | |
1195 | (user-date (gnus-user-date | |
1196 | ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s)) | |
16409b0b GM |
1197 | "An alist of format specifications that can appear in summary lines. |
1198 | These are paired with what variables they correspond with, along with | |
1199 | the type of the variable (string, integer, character, etc).") | |
eec82323 LMI |
1200 | |
1201 | (defvar gnus-summary-dummy-line-format-alist | |
1202 | `((?S gnus-tmp-subject ?s) | |
1203 | (?N gnus-tmp-number ?d) | |
1204 | (?u gnus-tmp-user-defined ?s))) | |
1205 | ||
1206 | (defvar gnus-summary-mode-line-format-alist | |
1207 | `((?G gnus-tmp-group-name ?s) | |
1208 | (?g (gnus-short-group-name gnus-tmp-group-name) ?s) | |
1209 | (?p (gnus-group-real-name gnus-tmp-group-name) ?s) | |
1210 | (?A gnus-tmp-article-number ?d) | |
1211 | (?Z gnus-tmp-unread-and-unselected ?s) | |
1212 | (?V gnus-version ?s) | |
1213 | (?U gnus-tmp-unread-and-unticked ?d) | |
1214 | (?S gnus-tmp-subject ?s) | |
1215 | (?e gnus-tmp-unselected ?d) | |
1216 | (?u gnus-tmp-user-defined ?s) | |
1217 | (?d (length gnus-newsgroup-dormant) ?d) | |
1218 | (?t (length gnus-newsgroup-marked) ?d) | |
23f87bed | 1219 | (?h (length gnus-newsgroup-spam-marked) ?d) |
eec82323 | 1220 | (?r (length gnus-newsgroup-reads) ?d) |
6748645f | 1221 | (?z (gnus-summary-article-score gnus-tmp-article-number) ?d) |
eec82323 LMI |
1222 | (?E gnus-newsgroup-expunged-tally ?d) |
1223 | (?s (gnus-current-score-file-nondirectory) ?s))) | |
1224 | ||
1225 | (defvar gnus-last-search-regexp nil | |
1226 | "Default regexp for article search command.") | |
1227 | ||
1228 | (defvar gnus-last-shell-command nil | |
1229 | "Default shell command on article.") | |
1230 | ||
23f87bed MB |
1231 | (defvar gnus-newsgroup-agentized nil |
1232 | "Locally bound in each summary buffer to indicate whether the server has been agentized.") | |
eec82323 LMI |
1233 | (defvar gnus-newsgroup-begin nil) |
1234 | (defvar gnus-newsgroup-end nil) | |
1235 | (defvar gnus-newsgroup-last-rmail nil) | |
1236 | (defvar gnus-newsgroup-last-mail nil) | |
1237 | (defvar gnus-newsgroup-last-folder nil) | |
1238 | (defvar gnus-newsgroup-last-file nil) | |
1239 | (defvar gnus-newsgroup-auto-expire nil) | |
1240 | (defvar gnus-newsgroup-active nil) | |
1241 | ||
1242 | (defvar gnus-newsgroup-data nil) | |
1243 | (defvar gnus-newsgroup-data-reverse nil) | |
1244 | (defvar gnus-newsgroup-limit nil) | |
1245 | (defvar gnus-newsgroup-limits nil) | |
23f87bed | 1246 | (defvar gnus-summary-use-undownloaded-faces nil) |
eec82323 LMI |
1247 | |
1248 | (defvar gnus-newsgroup-unreads nil | |
23f87bed | 1249 | "Sorted list of unread articles in the current newsgroup.") |
eec82323 LMI |
1250 | |
1251 | (defvar gnus-newsgroup-unselected nil | |
23f87bed | 1252 | "Sorted list of unselected unread articles in the current newsgroup.") |
eec82323 LMI |
1253 | |
1254 | (defvar gnus-newsgroup-reads nil | |
1255 | "Alist of read articles and article marks in the current newsgroup.") | |
1256 | ||
1257 | (defvar gnus-newsgroup-expunged-tally nil) | |
1258 | ||
1259 | (defvar gnus-newsgroup-marked nil | |
23f87bed MB |
1260 | "Sorted list of ticked articles in the current newsgroup (a subset of unread art).") |
1261 | ||
1262 | (defvar gnus-newsgroup-spam-marked nil | |
1263 | "List of ranges of articles that have been marked as spam.") | |
eec82323 LMI |
1264 | |
1265 | (defvar gnus-newsgroup-killed nil | |
1266 | "List of ranges of articles that have been through the scoring process.") | |
1267 | ||
1268 | (defvar gnus-newsgroup-cached nil | |
23f87bed | 1269 | "Sorted list of articles that come from the article cache.") |
eec82323 LMI |
1270 | |
1271 | (defvar gnus-newsgroup-saved nil | |
1272 | "List of articles that have been saved.") | |
1273 | ||
1274 | (defvar gnus-newsgroup-kill-headers nil) | |
1275 | ||
1276 | (defvar gnus-newsgroup-replied nil | |
1277 | "List of articles that have been replied to in the current newsgroup.") | |
1278 | ||
23f87bed MB |
1279 | (defvar gnus-newsgroup-forwarded nil |
1280 | "List of articles that have been forwarded in the current newsgroup.") | |
1281 | ||
1282 | (defvar gnus-newsgroup-recent nil | |
1283 | "List of articles that have are recent in the current newsgroup.") | |
1284 | ||
eec82323 | 1285 | (defvar gnus-newsgroup-expirable nil |
23f87bed | 1286 | "Sorted list of articles in the current newsgroup that can be expired.") |
eec82323 LMI |
1287 | |
1288 | (defvar gnus-newsgroup-processable nil | |
1289 | "List of articles in the current newsgroup that can be processed.") | |
1290 | ||
6748645f | 1291 | (defvar gnus-newsgroup-downloadable nil |
23f87bed MB |
1292 | "Sorted list of articles in the current newsgroup that can be processed.") |
1293 | ||
1294 | (defvar gnus-newsgroup-unfetched nil | |
1295 | "Sorted list of articles in the current newsgroup whose headers have | |
1296 | not been fetched into the agent. | |
1297 | ||
1298 | This list will always be a subset of gnus-newsgroup-undownloaded.") | |
6748645f LMI |
1299 | |
1300 | (defvar gnus-newsgroup-undownloaded nil | |
23f87bed | 1301 | "List of articles in the current newsgroup that haven't been downloaded.") |
6748645f LMI |
1302 | |
1303 | (defvar gnus-newsgroup-unsendable nil | |
1304 | "List of articles in the current newsgroup that won't be sent.") | |
1305 | ||
eec82323 LMI |
1306 | (defvar gnus-newsgroup-bookmarks nil |
1307 | "List of articles in the current newsgroup that have bookmarks.") | |
1308 | ||
1309 | (defvar gnus-newsgroup-dormant nil | |
23f87bed MB |
1310 | "Sorted list of dormant articles in the current newsgroup.") |
1311 | ||
1312 | (defvar gnus-newsgroup-unseen nil | |
1313 | "List of unseen articles in the current newsgroup.") | |
1314 | ||
1315 | (defvar gnus-newsgroup-seen nil | |
1316 | "Range of seen articles in the current newsgroup.") | |
1317 | ||
1318 | (defvar gnus-newsgroup-articles nil | |
1319 | "List of articles in the current newsgroup.") | |
eec82323 LMI |
1320 | |
1321 | (defvar gnus-newsgroup-scored nil | |
1322 | "List of scored articles in the current newsgroup.") | |
1323 | ||
1324 | (defvar gnus-newsgroup-headers nil | |
1325 | "List of article headers in the current newsgroup.") | |
1326 | ||
1327 | (defvar gnus-newsgroup-threads nil) | |
1328 | ||
1329 | (defvar gnus-newsgroup-prepared nil | |
1330 | "Whether the current group has been prepared properly.") | |
1331 | ||
1332 | (defvar gnus-newsgroup-ancient nil | |
1333 | "List of `gnus-fetch-old-headers' articles in the current newsgroup.") | |
1334 | ||
1335 | (defvar gnus-newsgroup-sparse nil) | |
1336 | ||
1337 | (defvar gnus-current-article nil) | |
1338 | (defvar gnus-article-current nil) | |
1339 | (defvar gnus-current-headers nil) | |
1340 | (defvar gnus-have-all-headers nil) | |
1341 | (defvar gnus-last-article nil) | |
1342 | (defvar gnus-newsgroup-history nil) | |
16409b0b GM |
1343 | (defvar gnus-newsgroup-charset nil) |
1344 | (defvar gnus-newsgroup-ephemeral-charset nil) | |
1345 | (defvar gnus-newsgroup-ephemeral-ignored-charsets nil) | |
eec82323 | 1346 | |
23f87bed MB |
1347 | (defvar gnus-article-before-search nil) |
1348 | ||
1349 | (defvar gnus-summary-local-variables | |
eec82323 LMI |
1350 | '(gnus-newsgroup-name |
1351 | gnus-newsgroup-begin gnus-newsgroup-end | |
1352 | gnus-newsgroup-last-rmail gnus-newsgroup-last-mail | |
1353 | gnus-newsgroup-last-folder gnus-newsgroup-last-file | |
1354 | gnus-newsgroup-auto-expire gnus-newsgroup-unreads | |
1355 | gnus-newsgroup-unselected gnus-newsgroup-marked | |
23f87bed | 1356 | gnus-newsgroup-spam-marked |
eec82323 | 1357 | gnus-newsgroup-reads gnus-newsgroup-saved |
23f87bed MB |
1358 | gnus-newsgroup-replied gnus-newsgroup-forwarded |
1359 | gnus-newsgroup-recent | |
1360 | gnus-newsgroup-expirable | |
eec82323 | 1361 | gnus-newsgroup-processable gnus-newsgroup-killed |
6748645f | 1362 | gnus-newsgroup-downloadable gnus-newsgroup-undownloaded |
23f87bed MB |
1363 | gnus-newsgroup-unfetched |
1364 | gnus-newsgroup-unsendable gnus-newsgroup-unseen | |
1365 | gnus-newsgroup-seen gnus-newsgroup-articles | |
eec82323 LMI |
1366 | gnus-newsgroup-bookmarks gnus-newsgroup-dormant |
1367 | gnus-newsgroup-headers gnus-newsgroup-threads | |
1368 | gnus-newsgroup-prepared gnus-summary-highlight-line-function | |
1369 | gnus-current-article gnus-current-headers gnus-have-all-headers | |
1370 | gnus-last-article gnus-article-internal-prepare-hook | |
1371 | gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay | |
1372 | gnus-newsgroup-scored gnus-newsgroup-kill-headers | |
1373 | gnus-thread-expunge-below | |
16409b0b GM |
1374 | gnus-score-alist gnus-current-score-file |
1375 | (gnus-summary-expunge-below . global) | |
eec82323 | 1376 | (gnus-summary-mark-below . global) |
16409b0b | 1377 | (gnus-orphan-score . global) |
eec82323 LMI |
1378 | gnus-newsgroup-active gnus-scores-exclude-files |
1379 | gnus-newsgroup-history gnus-newsgroup-ancient | |
1380 | gnus-newsgroup-sparse gnus-newsgroup-process-stack | |
1381 | (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring) | |
1382 | gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1) | |
1383 | (gnus-newsgroup-expunged-tally . 0) | |
1384 | gnus-cache-removable-articles gnus-newsgroup-cached | |
1385 | gnus-newsgroup-data gnus-newsgroup-data-reverse | |
16409b0b | 1386 | gnus-newsgroup-limit gnus-newsgroup-limits |
23f87bed MB |
1387 | gnus-newsgroup-charset gnus-newsgroup-display |
1388 | gnus-summary-use-undownloaded-faces) | |
eec82323 LMI |
1389 | "Variables that are buffer-local to the summary buffers.") |
1390 | ||
23f87bed MB |
1391 | (defvar gnus-newsgroup-variables nil |
1392 | "A list of variables that have separate values in different newsgroups. | |
1393 | A list of newsgroup (summary buffer) local variables, or cons of | |
1394 | variables and their default expressions to be evalled (when the default | |
1395 | values are not nil), that should be made global while the summary buffer | |
1396 | is active. | |
1397 | ||
1398 | Note: The default expressions will be evaluated (using function `eval') | |
1399 | before assignment to the local variable rather than just assigned to it. | |
1400 | If the default expression is the symbol `global', that symbol will not | |
1401 | be evaluated but the global value of the local variable will be used | |
1402 | instead. | |
1403 | ||
1404 | These variables can be used to set variables in the group parameters | |
1405 | while still allowing them to affect operations done in other buffers. | |
1406 | For example: | |
1407 | ||
1408 | \(setq gnus-newsgroup-variables | |
1409 | '(message-use-followup-to | |
1410 | (gnus-visible-headers . | |
1411 | \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\"))) | |
1412 | ") | |
1413 | ||
eec82323 | 1414 | ;; Byte-compiler warning. |
23f87bed MB |
1415 | (eval-when-compile |
1416 | ;; Bind features so that require will believe that gnus-sum has | |
1417 | ;; already been loaded (avoids infinite recursion) | |
1418 | (let ((features (cons 'gnus-sum features))) | |
1419 | ;; Several of the declarations in gnus-sum are needed to load the | |
1420 | ;; following files. Right now, these definitions have been | |
1421 | ;; compiled but not defined (evaluated). We could either do a | |
1422 | ;; eval-and-compile about all of the declarations or evaluate the | |
1423 | ;; source file. | |
1424 | (if (boundp 'gnus-newsgroup-variables) | |
1425 | nil | |
1426 | (load "gnus-sum.el" t t t)) | |
1427 | (require 'gnus) | |
1428 | (require 'gnus-agent) | |
1429 | (require 'gnus-art))) | |
eec82323 | 1430 | |
16409b0b GM |
1431 | ;; MIME stuff. |
1432 | ||
1433 | (defvar gnus-decode-encoded-word-methods | |
1434 | '(mail-decode-encoded-word-string) | |
1435 | "List of methods used to decode encoded words. | |
1436 | ||
23f87bed MB |
1437 | This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item |
1438 | is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a | |
1439 | \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups | |
16409b0b GM |
1440 | whose names match REGEXP. |
1441 | ||
1442 | For example: | |
23f87bed | 1443 | \((\"chinese\" . gnus-decode-encoded-word-string-by-guess) |
16409b0b GM |
1444 | mail-decode-encoded-word-string |
1445 | (\"chinese\" . rfc1843-decode-string))") | |
1446 | ||
1447 | (defvar gnus-decode-encoded-word-methods-cache nil) | |
1448 | ||
1449 | (defun gnus-multi-decode-encoded-word-string (string) | |
1450 | "Apply the functions from `gnus-encoded-word-methods' that match." | |
1451 | (unless (and gnus-decode-encoded-word-methods-cache | |
1452 | (eq gnus-newsgroup-name | |
1453 | (car gnus-decode-encoded-word-methods-cache))) | |
1454 | (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name)) | |
1455 | (mapcar (lambda (x) | |
1456 | (if (symbolp x) | |
1457 | (nconc gnus-decode-encoded-word-methods-cache (list x)) | |
1458 | (if (and gnus-newsgroup-name | |
1459 | (string-match (car x) gnus-newsgroup-name)) | |
1460 | (nconc gnus-decode-encoded-word-methods-cache | |
1461 | (list (cdr x)))))) | |
23f87bed | 1462 | gnus-decode-encoded-word-methods)) |
16409b0b GM |
1463 | (let ((xlist gnus-decode-encoded-word-methods-cache)) |
1464 | (pop xlist) | |
1465 | (while xlist | |
1466 | (setq string (funcall (pop xlist) string)))) | |
1467 | string) | |
1468 | ||
eec82323 LMI |
1469 | ;; Subject simplification. |
1470 | ||
6748645f | 1471 | (defun gnus-simplify-whitespace (str) |
16409b0b | 1472 | "Remove excessive whitespace from STR." |
23f87bed MB |
1473 | ;; Multiple spaces. |
1474 | (while (string-match "[ \t][ \t]+" str) | |
1475 | (setq str (concat (substring str 0 (match-beginning 0)) | |
1476 | " " | |
1477 | (substring str (match-end 0))))) | |
1478 | ;; Leading spaces. | |
1479 | (when (string-match "^[ \t]+" str) | |
1480 | (setq str (substring str (match-end 0)))) | |
1481 | ;; Trailing spaces. | |
1482 | (when (string-match "[ \t]+$" str) | |
1483 | (setq str (substring str 0 (match-beginning 0)))) | |
1484 | str) | |
1485 | ||
1486 | (defun gnus-simplify-all-whitespace (str) | |
1487 | "Remove all whitespace from STR." | |
1488 | (while (string-match "[ \t\n]+" str) | |
1489 | (setq str (replace-match "" nil nil str))) | |
1490 | str) | |
6748645f | 1491 | |
eec82323 LMI |
1492 | (defsubst gnus-simplify-subject-re (subject) |
1493 | "Remove \"Re:\" from subject lines." | |
23f87bed | 1494 | (if (string-match message-subject-re-regexp subject) |
eec82323 LMI |
1495 | (substring subject (match-end 0)) |
1496 | subject)) | |
1497 | ||
1498 | (defun gnus-simplify-subject (subject &optional re-only) | |
1499 | "Remove `Re:' and words in parentheses. | |
1500 | If RE-ONLY is non-nil, strip leading `Re:'s only." | |
1501 | (let ((case-fold-search t)) ;Ignore case. | |
1502 | ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'. | |
1503 | (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject) | |
1504 | (setq subject (substring subject (match-end 0)))) | |
1505 | ;; Remove uninteresting prefixes. | |
1506 | (when (and (not re-only) | |
1507 | gnus-simplify-ignored-prefixes | |
1508 | (string-match gnus-simplify-ignored-prefixes subject)) | |
1509 | (setq subject (substring subject (match-end 0)))) | |
1510 | ;; Remove words in parentheses from end. | |
1511 | (unless re-only | |
1512 | (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
1513 | (setq subject (substring subject 0 (match-beginning 0))))) | |
1514 | ;; Return subject string. | |
1515 | subject)) | |
1516 | ||
1517 | ;; Remove any leading "re:"s, any trailing paren phrases, and simplify | |
1518 | ;; all whitespace. | |
1519 | (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext) | |
1520 | (goto-char (point-min)) | |
1521 | (while (re-search-forward regexp nil t) | |
16409b0b | 1522 | (replace-match (or newtext "")))) |
eec82323 LMI |
1523 | |
1524 | (defun gnus-simplify-buffer-fuzzy () | |
1525 | "Simplify string in the buffer fuzzily. | |
1526 | The string in the accessible portion of the current buffer is simplified. | |
1527 | It is assumed to be a single-line subject. | |
1528 | Whitespace is generally cleaned up, and miscellaneous leading/trailing | |
1529 | matter is removed. Additional things can be deleted by setting | |
16409b0b | 1530 | `gnus-simplify-subject-fuzzy-regexp'." |
eec82323 LMI |
1531 | (let ((case-fold-search t) |
1532 | (modified-tick)) | |
1533 | (gnus-simplify-buffer-fuzzy-step "\t" " ") | |
1534 | ||
1535 | (while (not (eq modified-tick (buffer-modified-tick))) | |
1536 | (setq modified-tick (buffer-modified-tick)) | |
1537 | (cond | |
1538 | ((listp gnus-simplify-subject-fuzzy-regexp) | |
1539 | (mapcar 'gnus-simplify-buffer-fuzzy-step | |
1540 | gnus-simplify-subject-fuzzy-regexp)) | |
1541 | (gnus-simplify-subject-fuzzy-regexp | |
1542 | (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp))) | |
1543 | (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *") | |
1544 | (gnus-simplify-buffer-fuzzy-step | |
1545 | "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *") | |
1546 | (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1")) | |
1547 | ||
1548 | (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$") | |
1549 | (gnus-simplify-buffer-fuzzy-step " +" " ") | |
1550 | (gnus-simplify-buffer-fuzzy-step " $") | |
1551 | (gnus-simplify-buffer-fuzzy-step "^ +"))) | |
1552 | ||
1553 | (defun gnus-simplify-subject-fuzzy (subject) | |
1554 | "Simplify a subject string fuzzily. | |
6748645f | 1555 | See `gnus-simplify-buffer-fuzzy' for details." |
eec82323 LMI |
1556 | (save-excursion |
1557 | (gnus-set-work-buffer) | |
1558 | (let ((case-fold-search t)) | |
6748645f LMI |
1559 | ;; Remove uninteresting prefixes. |
1560 | (when (and gnus-simplify-ignored-prefixes | |
1561 | (string-match gnus-simplify-ignored-prefixes subject)) | |
1562 | (setq subject (substring subject (match-end 0)))) | |
eec82323 LMI |
1563 | (insert subject) |
1564 | (inline (gnus-simplify-buffer-fuzzy)) | |
1565 | (buffer-string)))) | |
1566 | ||
1567 | (defsubst gnus-simplify-subject-fully (subject) | |
23f87bed | 1568 | "Simplify a subject string according to `gnus-summary-gather-subject-limit'." |
eec82323 | 1569 | (cond |
6748645f LMI |
1570 | (gnus-simplify-subject-functions |
1571 | (gnus-map-function gnus-simplify-subject-functions subject)) | |
eec82323 LMI |
1572 | ((null gnus-summary-gather-subject-limit) |
1573 | (gnus-simplify-subject-re subject)) | |
1574 | ((eq gnus-summary-gather-subject-limit 'fuzzy) | |
1575 | (gnus-simplify-subject-fuzzy subject)) | |
1576 | ((numberp gnus-summary-gather-subject-limit) | |
1577 | (gnus-limit-string (gnus-simplify-subject-re subject) | |
1578 | gnus-summary-gather-subject-limit)) | |
1579 | (t | |
1580 | subject))) | |
1581 | ||
1582 | (defsubst gnus-subject-equal (s1 s2 &optional simple-first) | |
6748645f | 1583 | "Check whether two subjects are equal. |
23f87bed | 1584 | If optional argument SIMPLE-FIRST is t, first argument is already |
6748645f | 1585 | simplified." |
eec82323 LMI |
1586 | (cond |
1587 | ((null simple-first) | |
1588 | (equal (gnus-simplify-subject-fully s1) | |
1589 | (gnus-simplify-subject-fully s2))) | |
1590 | (t | |
1591 | (equal s1 | |
1592 | (gnus-simplify-subject-fully s2))))) | |
1593 | ||
1594 | (defun gnus-summary-bubble-group () | |
1595 | "Increase the score of the current group. | |
1596 | This is a handy function to add to `gnus-summary-exit-hook' to | |
1597 | increase the score of each group you read." | |
1598 | (gnus-group-add-score gnus-newsgroup-name)) | |
1599 | ||
1600 | \f | |
1601 | ;;; | |
1602 | ;;; Gnus summary mode | |
1603 | ;;; | |
1604 | ||
1605 | (put 'gnus-summary-mode 'mode-class 'special) | |
1606 | ||
1653df0f SZ |
1607 | (defvar gnus-article-commands-menu) |
1608 | ||
23f87bed MB |
1609 | ;; Non-orthogonal keys |
1610 | ||
1611 | (gnus-define-keys gnus-summary-mode-map | |
1612 | " " gnus-summary-next-page | |
1613 | "\177" gnus-summary-prev-page | |
1614 | [delete] gnus-summary-prev-page | |
1615 | [backspace] gnus-summary-prev-page | |
1616 | "\r" gnus-summary-scroll-up | |
1617 | "\M-\r" gnus-summary-scroll-down | |
1618 | "n" gnus-summary-next-unread-article | |
1619 | "p" gnus-summary-prev-unread-article | |
1620 | "N" gnus-summary-next-article | |
1621 | "P" gnus-summary-prev-article | |
1622 | "\M-\C-n" gnus-summary-next-same-subject | |
1623 | "\M-\C-p" gnus-summary-prev-same-subject | |
1624 | "\M-n" gnus-summary-next-unread-subject | |
1625 | "\M-p" gnus-summary-prev-unread-subject | |
1626 | "." gnus-summary-first-unread-article | |
1627 | "," gnus-summary-best-unread-article | |
1628 | "\M-s" gnus-summary-search-article-forward | |
1629 | "\M-r" gnus-summary-search-article-backward | |
1630 | "<" gnus-summary-beginning-of-article | |
1631 | ">" gnus-summary-end-of-article | |
1632 | "j" gnus-summary-goto-article | |
1633 | "^" gnus-summary-refer-parent-article | |
1634 | "\M-^" gnus-summary-refer-article | |
1635 | "u" gnus-summary-tick-article-forward | |
1636 | "!" gnus-summary-tick-article-forward | |
1637 | "U" gnus-summary-tick-article-backward | |
1638 | "d" gnus-summary-mark-as-read-forward | |
1639 | "D" gnus-summary-mark-as-read-backward | |
1640 | "E" gnus-summary-mark-as-expirable | |
1641 | "\M-u" gnus-summary-clear-mark-forward | |
1642 | "\M-U" gnus-summary-clear-mark-backward | |
1643 | "k" gnus-summary-kill-same-subject-and-select | |
1644 | "\C-k" gnus-summary-kill-same-subject | |
1645 | "\M-\C-k" gnus-summary-kill-thread | |
1646 | "\M-\C-l" gnus-summary-lower-thread | |
1647 | "e" gnus-summary-edit-article | |
1648 | "#" gnus-summary-mark-as-processable | |
1649 | "\M-#" gnus-summary-unmark-as-processable | |
1650 | "\M-\C-t" gnus-summary-toggle-threads | |
1651 | "\M-\C-s" gnus-summary-show-thread | |
1652 | "\M-\C-h" gnus-summary-hide-thread | |
1653 | "\M-\C-f" gnus-summary-next-thread | |
1654 | "\M-\C-b" gnus-summary-prev-thread | |
1655 | [(meta down)] gnus-summary-next-thread | |
1656 | [(meta up)] gnus-summary-prev-thread | |
1657 | "\M-\C-u" gnus-summary-up-thread | |
1658 | "\M-\C-d" gnus-summary-down-thread | |
1659 | "&" gnus-summary-execute-command | |
1660 | "c" gnus-summary-catchup-and-exit | |
1661 | "\C-w" gnus-summary-mark-region-as-read | |
1662 | "\C-t" gnus-summary-toggle-truncation | |
1663 | "?" gnus-summary-mark-as-dormant | |
1664 | "\C-c\M-\C-s" gnus-summary-limit-include-expunged | |
1665 | "\C-c\C-s\C-n" gnus-summary-sort-by-number | |
1666 | "\C-c\C-s\C-l" gnus-summary-sort-by-lines | |
1667 | "\C-c\C-s\C-c" gnus-summary-sort-by-chars | |
1668 | "\C-c\C-s\C-a" gnus-summary-sort-by-author | |
1669 | "\C-c\C-s\C-s" gnus-summary-sort-by-subject | |
1670 | "\C-c\C-s\C-d" gnus-summary-sort-by-date | |
1671 | "\C-c\C-s\C-i" gnus-summary-sort-by-score | |
1672 | "\C-c\C-s\C-o" gnus-summary-sort-by-original | |
1673 | "\C-c\C-s\C-r" gnus-summary-sort-by-random | |
1674 | "=" gnus-summary-expand-window | |
1675 | "\C-x\C-s" gnus-summary-reselect-current-group | |
1676 | "\M-g" gnus-summary-rescan-group | |
1677 | "w" gnus-summary-stop-page-breaking | |
1678 | "\C-c\C-r" gnus-summary-caesar-message | |
1679 | "f" gnus-summary-followup | |
1680 | "F" gnus-summary-followup-with-original | |
1681 | "C" gnus-summary-cancel-article | |
1682 | "r" gnus-summary-reply | |
1683 | "R" gnus-summary-reply-with-original | |
1684 | "\C-c\C-f" gnus-summary-mail-forward | |
1685 | "o" gnus-summary-save-article | |
1686 | "\C-o" gnus-summary-save-article-mail | |
1687 | "|" gnus-summary-pipe-output | |
1688 | "\M-k" gnus-summary-edit-local-kill | |
1689 | "\M-K" gnus-summary-edit-global-kill | |
1690 | ;; "V" gnus-version | |
1691 | "\C-c\C-d" gnus-summary-describe-group | |
1692 | "q" gnus-summary-exit | |
1693 | "Q" gnus-summary-exit-no-update | |
1694 | "\C-c\C-i" gnus-info-find-node | |
1695 | gnus-mouse-2 gnus-mouse-pick-article | |
1696 | "m" gnus-summary-mail-other-window | |
1697 | "a" gnus-summary-post-news | |
1698 | "i" gnus-summary-news-other-window | |
1699 | "x" gnus-summary-limit-to-unread | |
1700 | "s" gnus-summary-isearch-article | |
1701 | "t" gnus-summary-toggle-header | |
1702 | "g" gnus-summary-show-article | |
1703 | "l" gnus-summary-goto-last-article | |
1704 | "\C-c\C-v\C-v" gnus-uu-decode-uu-view | |
1705 | "\C-d" gnus-summary-enter-digest-group | |
1706 | "\M-\C-d" gnus-summary-read-document | |
1707 | "\M-\C-e" gnus-summary-edit-parameters | |
1708 | "\M-\C-a" gnus-summary-customize-parameters | |
1709 | "\C-c\C-b" gnus-bug | |
1710 | "*" gnus-cache-enter-article | |
1711 | "\M-*" gnus-cache-remove-article | |
1712 | "\M-&" gnus-summary-universal-argument | |
1713 | "\C-l" gnus-recenter | |
1714 | "I" gnus-summary-increase-score | |
1715 | "L" gnus-summary-lower-score | |
1716 | "\M-i" gnus-symbolic-argument | |
1717 | "h" gnus-summary-select-article-buffer | |
1718 | ||
1719 | "b" gnus-article-view-part | |
1720 | "\M-t" gnus-summary-toggle-display-buttonized | |
1721 | ||
1722 | "V" gnus-summary-score-map | |
1723 | "X" gnus-uu-extract-map | |
1724 | "S" gnus-summary-send-map) | |
1725 | ||
1726 | ;; Sort of orthogonal keymap | |
1727 | (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map) | |
1728 | "t" gnus-summary-tick-article-forward | |
1729 | "!" gnus-summary-tick-article-forward | |
1730 | "d" gnus-summary-mark-as-read-forward | |
1731 | "r" gnus-summary-mark-as-read-forward | |
1732 | "c" gnus-summary-clear-mark-forward | |
1733 | " " gnus-summary-clear-mark-forward | |
1734 | "e" gnus-summary-mark-as-expirable | |
1735 | "x" gnus-summary-mark-as-expirable | |
1736 | "?" gnus-summary-mark-as-dormant | |
1737 | "b" gnus-summary-set-bookmark | |
1738 | "B" gnus-summary-remove-bookmark | |
1739 | "#" gnus-summary-mark-as-processable | |
1740 | "\M-#" gnus-summary-unmark-as-processable | |
1741 | "S" gnus-summary-limit-include-expunged | |
1742 | "C" gnus-summary-catchup | |
1743 | "H" gnus-summary-catchup-to-here | |
1744 | "h" gnus-summary-catchup-from-here | |
1745 | "\C-c" gnus-summary-catchup-all | |
1746 | "k" gnus-summary-kill-same-subject-and-select | |
1747 | "K" gnus-summary-kill-same-subject | |
1748 | "P" gnus-uu-mark-map) | |
1749 | ||
1750 | (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map) | |
1751 | "c" gnus-summary-clear-above | |
1752 | "u" gnus-summary-tick-above | |
1753 | "m" gnus-summary-mark-above | |
1754 | "k" gnus-summary-kill-below) | |
1755 | ||
1756 | (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map) | |
1757 | "/" gnus-summary-limit-to-subject | |
1758 | "n" gnus-summary-limit-to-articles | |
1759 | "w" gnus-summary-pop-limit | |
1760 | "s" gnus-summary-limit-to-subject | |
1761 | "a" gnus-summary-limit-to-author | |
1762 | "u" gnus-summary-limit-to-unread | |
1763 | "m" gnus-summary-limit-to-marks | |
1764 | "M" gnus-summary-limit-exclude-marks | |
1765 | "v" gnus-summary-limit-to-score | |
1766 | "*" gnus-summary-limit-include-cached | |
1767 | "D" gnus-summary-limit-include-dormant | |
1768 | "T" gnus-summary-limit-include-thread | |
1769 | "d" gnus-summary-limit-exclude-dormant | |
1770 | "t" gnus-summary-limit-to-age | |
1771 | "." gnus-summary-limit-to-unseen | |
1772 | "x" gnus-summary-limit-to-extra | |
1773 | "p" gnus-summary-limit-to-display-predicate | |
1774 | "E" gnus-summary-limit-include-expunged | |
1775 | "c" gnus-summary-limit-exclude-childless-dormant | |
1776 | "C" gnus-summary-limit-mark-excluded-as-read | |
1777 | "o" gnus-summary-insert-old-articles | |
1778 | "N" gnus-summary-insert-new-articles) | |
1779 | ||
1780 | (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map) | |
1781 | "n" gnus-summary-next-unread-article | |
1782 | "p" gnus-summary-prev-unread-article | |
1783 | "N" gnus-summary-next-article | |
1784 | "P" gnus-summary-prev-article | |
1785 | "\C-n" gnus-summary-next-same-subject | |
1786 | "\C-p" gnus-summary-prev-same-subject | |
1787 | "\M-n" gnus-summary-next-unread-subject | |
1788 | "\M-p" gnus-summary-prev-unread-subject | |
1789 | "f" gnus-summary-first-unread-article | |
1790 | "b" gnus-summary-best-unread-article | |
1791 | "j" gnus-summary-goto-article | |
1792 | "g" gnus-summary-goto-subject | |
1793 | "l" gnus-summary-goto-last-article | |
1794 | "o" gnus-summary-pop-article) | |
1795 | ||
1796 | (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map) | |
1797 | "k" gnus-summary-kill-thread | |
1798 | "l" gnus-summary-lower-thread | |
1799 | "i" gnus-summary-raise-thread | |
1800 | "T" gnus-summary-toggle-threads | |
1801 | "t" gnus-summary-rethread-current | |
1802 | "^" gnus-summary-reparent-thread | |
1803 | "s" gnus-summary-show-thread | |
1804 | "S" gnus-summary-show-all-threads | |
1805 | "h" gnus-summary-hide-thread | |
1806 | "H" gnus-summary-hide-all-threads | |
1807 | "n" gnus-summary-next-thread | |
1808 | "p" gnus-summary-prev-thread | |
1809 | "u" gnus-summary-up-thread | |
1810 | "o" gnus-summary-top-thread | |
1811 | "d" gnus-summary-down-thread | |
1812 | "#" gnus-uu-mark-thread | |
1813 | "\M-#" gnus-uu-unmark-thread) | |
1814 | ||
1815 | (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map) | |
1816 | "g" gnus-summary-prepare | |
1817 | "c" gnus-summary-insert-cached-articles | |
1818 | "d" gnus-summary-insert-dormant-articles) | |
1819 | ||
1820 | (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map) | |
1821 | "c" gnus-summary-catchup-and-exit | |
1822 | "C" gnus-summary-catchup-all-and-exit | |
1823 | "E" gnus-summary-exit-no-update | |
1824 | "Q" gnus-summary-exit | |
1825 | "Z" gnus-summary-exit | |
1826 | "n" gnus-summary-catchup-and-goto-next-group | |
1827 | "R" gnus-summary-reselect-current-group | |
1828 | "G" gnus-summary-rescan-group | |
1829 | "N" gnus-summary-next-group | |
1830 | "s" gnus-summary-save-newsrc | |
1831 | "P" gnus-summary-prev-group) | |
1832 | ||
1833 | (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map) | |
1834 | " " gnus-summary-next-page | |
1835 | "n" gnus-summary-next-page | |
1836 | "\177" gnus-summary-prev-page | |
1837 | [delete] gnus-summary-prev-page | |
1838 | "p" gnus-summary-prev-page | |
1839 | "\r" gnus-summary-scroll-up | |
1840 | "\M-\r" gnus-summary-scroll-down | |
1841 | "<" gnus-summary-beginning-of-article | |
1842 | ">" gnus-summary-end-of-article | |
1843 | "b" gnus-summary-beginning-of-article | |
1844 | "e" gnus-summary-end-of-article | |
1845 | "^" gnus-summary-refer-parent-article | |
1846 | "r" gnus-summary-refer-parent-article | |
1847 | "D" gnus-summary-enter-digest-group | |
1848 | "R" gnus-summary-refer-references | |
1849 | "T" gnus-summary-refer-thread | |
1850 | "g" gnus-summary-show-article | |
1851 | "s" gnus-summary-isearch-article | |
1852 | "P" gnus-summary-print-article | |
1853 | "M" gnus-mailing-list-insinuate | |
1854 | "t" gnus-article-babel) | |
1855 | ||
1856 | (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map) | |
1857 | "b" gnus-article-add-buttons | |
1858 | "B" gnus-article-add-buttons-to-head | |
1859 | "o" gnus-article-treat-overstrike | |
1860 | "e" gnus-article-emphasize | |
1861 | "w" gnus-article-fill-cited-article | |
1862 | "Q" gnus-article-fill-long-lines | |
1863 | "C" gnus-article-capitalize-sentences | |
1864 | "c" gnus-article-remove-cr | |
1865 | "q" gnus-article-de-quoted-unreadable | |
1866 | "6" gnus-article-de-base64-unreadable | |
1867 | "Z" gnus-article-decode-HZ | |
1868 | "h" gnus-article-wash-html | |
1869 | "u" gnus-article-unsplit-urls | |
1870 | "s" gnus-summary-force-verify-and-decrypt | |
1871 | "f" gnus-article-display-x-face | |
1872 | "l" gnus-summary-stop-page-breaking | |
1873 | "r" gnus-summary-caesar-message | |
1874 | "m" gnus-summary-morse-message | |
1875 | "t" gnus-summary-toggle-header | |
1876 | "g" gnus-treat-smiley | |
1877 | "v" gnus-summary-verbose-headers | |
1878 | "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive | |
1879 | "p" gnus-article-verify-x-pgp-sig | |
1880 | "d" gnus-article-treat-dumbquotes) | |
1881 | ||
1882 | (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map) | |
1883 | ;; mnemonic: deuglif*Y* | |
1884 | "u" gnus-article-outlook-unwrap-lines | |
1885 | "a" gnus-article-outlook-repair-attribution | |
1886 | "c" gnus-article-outlook-rearrange-citation | |
1887 | "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify | |
1888 | ||
1889 | (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map) | |
1890 | "a" gnus-article-hide | |
1891 | "h" gnus-article-hide-headers | |
1892 | "b" gnus-article-hide-boring-headers | |
1893 | "s" gnus-article-hide-signature | |
1894 | "c" gnus-article-hide-citation | |
1895 | "C" gnus-article-hide-citation-in-followups | |
1896 | "l" gnus-article-hide-list-identifiers | |
1897 | "B" gnus-article-strip-banner | |
1898 | "P" gnus-article-hide-pem | |
1899 | "\C-c" gnus-article-hide-citation-maybe) | |
1900 | ||
1901 | (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map) | |
1902 | "a" gnus-article-highlight | |
1903 | "h" gnus-article-highlight-headers | |
1904 | "c" gnus-article-highlight-citation | |
1905 | "s" gnus-article-highlight-signature) | |
1906 | ||
1907 | (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map) | |
1908 | "f" gnus-article-treat-fold-headers | |
1909 | "u" gnus-article-treat-unfold-headers | |
1910 | "n" gnus-article-treat-fold-newsgroups) | |
1911 | ||
1912 | (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map) | |
1913 | "x" gnus-article-display-x-face | |
1914 | "d" gnus-article-display-face | |
1915 | "s" gnus-treat-smiley | |
1916 | "D" gnus-article-remove-images | |
1917 | "f" gnus-treat-from-picon | |
1918 | "m" gnus-treat-mail-picon | |
1919 | "n" gnus-treat-newsgroups-picon) | |
1920 | ||
1921 | (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map) | |
1922 | "w" gnus-article-decode-mime-words | |
1923 | "c" gnus-article-decode-charset | |
1924 | "v" gnus-mime-view-all-parts | |
1925 | "b" gnus-article-view-part) | |
1926 | ||
1927 | (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map) | |
1928 | "z" gnus-article-date-ut | |
1929 | "u" gnus-article-date-ut | |
1930 | "l" gnus-article-date-local | |
1931 | "p" gnus-article-date-english | |
1932 | "e" gnus-article-date-lapsed | |
1933 | "o" gnus-article-date-original | |
1934 | "i" gnus-article-date-iso8601 | |
1935 | "s" gnus-article-date-user) | |
1936 | ||
1937 | (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map) | |
1938 | "t" gnus-article-remove-trailing-blank-lines | |
1939 | "l" gnus-article-strip-leading-blank-lines | |
1940 | "m" gnus-article-strip-multiple-blank-lines | |
1941 | "a" gnus-article-strip-blank-lines | |
1942 | "A" gnus-article-strip-all-blank-lines | |
1943 | "s" gnus-article-strip-leading-space | |
1944 | "e" gnus-article-strip-trailing-space | |
1945 | "w" gnus-article-remove-leading-whitespace) | |
1946 | ||
1947 | (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map) | |
1948 | "v" gnus-version | |
1949 | "f" gnus-summary-fetch-faq | |
1950 | "d" gnus-summary-describe-group | |
1951 | "h" gnus-summary-describe-briefly | |
1952 | "i" gnus-info-find-node | |
1953 | "c" gnus-group-fetch-charter | |
1954 | "C" gnus-group-fetch-control) | |
1955 | ||
1956 | (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map) | |
1957 | "e" gnus-summary-expire-articles | |
1958 | "\M-\C-e" gnus-summary-expire-articles-now | |
1959 | "\177" gnus-summary-delete-article | |
1960 | [delete] gnus-summary-delete-article | |
1961 | [backspace] gnus-summary-delete-article | |
1962 | "m" gnus-summary-move-article | |
1963 | "r" gnus-summary-respool-article | |
1964 | "w" gnus-summary-edit-article | |
1965 | "c" gnus-summary-copy-article | |
1966 | "B" gnus-summary-crosspost-article | |
1967 | "q" gnus-summary-respool-query | |
1968 | "t" gnus-summary-respool-trace | |
1969 | "i" gnus-summary-import-article | |
1970 | "I" gnus-summary-create-article | |
1971 | "p" gnus-summary-article-posted-p) | |
1972 | ||
1973 | (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map) | |
1974 | "o" gnus-summary-save-article | |
1975 | "m" gnus-summary-save-article-mail | |
1976 | "F" gnus-summary-write-article-file | |
1977 | "r" gnus-summary-save-article-rmail | |
1978 | "f" gnus-summary-save-article-file | |
1979 | "b" gnus-summary-save-article-body-file | |
1980 | "h" gnus-summary-save-article-folder | |
1981 | "v" gnus-summary-save-article-vm | |
1982 | "p" gnus-summary-pipe-output | |
1983 | "P" gnus-summary-muttprint | |
1984 | "s" gnus-soup-add-article) | |
1985 | ||
1986 | (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map) | |
1987 | "b" gnus-summary-display-buttonized | |
1988 | "m" gnus-summary-repair-multipart | |
1989 | "v" gnus-article-view-part | |
1990 | "o" gnus-article-save-part | |
1991 | "c" gnus-article-copy-part | |
1992 | "C" gnus-article-view-part-as-charset | |
1993 | "e" gnus-article-view-part-externally | |
1994 | "E" gnus-article-encrypt-body | |
1995 | "i" gnus-article-inline-part | |
1996 | "|" gnus-article-pipe-part) | |
1997 | ||
1998 | (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map) | |
1999 | "p" gnus-summary-mark-as-processable | |
2000 | "u" gnus-summary-unmark-as-processable | |
2001 | "U" gnus-summary-unmark-all-processable | |
2002 | "v" gnus-uu-mark-over | |
2003 | "s" gnus-uu-mark-series | |
2004 | "r" gnus-uu-mark-region | |
2005 | "g" gnus-uu-unmark-region | |
2006 | "R" gnus-uu-mark-by-regexp | |
2007 | "G" gnus-uu-unmark-by-regexp | |
2008 | "t" gnus-uu-mark-thread | |
2009 | "T" gnus-uu-unmark-thread | |
2010 | "a" gnus-uu-mark-all | |
2011 | "b" gnus-uu-mark-buffer | |
2012 | "S" gnus-uu-mark-sparse | |
2013 | "k" gnus-summary-kill-process-mark | |
2014 | "y" gnus-summary-yank-process-mark | |
2015 | "w" gnus-summary-save-process-mark | |
2016 | "i" gnus-uu-invert-processable) | |
2017 | ||
2018 | (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map) | |
2019 | ;;"x" gnus-uu-extract-any | |
2020 | "m" gnus-summary-save-parts | |
2021 | "u" gnus-uu-decode-uu | |
2022 | "U" gnus-uu-decode-uu-and-save | |
2023 | "s" gnus-uu-decode-unshar | |
2024 | "S" gnus-uu-decode-unshar-and-save | |
2025 | "o" gnus-uu-decode-save | |
2026 | "O" gnus-uu-decode-save | |
2027 | "b" gnus-uu-decode-binhex | |
2028 | "B" gnus-uu-decode-binhex | |
2029 | "p" gnus-uu-decode-postscript | |
2030 | "P" gnus-uu-decode-postscript-and-save) | |
2031 | ||
2032 | (gnus-define-keys | |
2033 | (gnus-uu-extract-view-map "v" gnus-uu-extract-map) | |
2034 | "u" gnus-uu-decode-uu-view | |
2035 | "U" gnus-uu-decode-uu-and-save-view | |
2036 | "s" gnus-uu-decode-unshar-view | |
2037 | "S" gnus-uu-decode-unshar-and-save-view | |
2038 | "o" gnus-uu-decode-save-view | |
2039 | "O" gnus-uu-decode-save-view | |
2040 | "b" gnus-uu-decode-binhex-view | |
2041 | "B" gnus-uu-decode-binhex-view | |
2042 | "p" gnus-uu-decode-postscript-view | |
2043 | "P" gnus-uu-decode-postscript-and-save-view) | |
2044 | ||
2045 | (defvar gnus-article-post-menu nil) | |
2046 | ||
2047 | (defconst gnus-summary-menu-maxlen 20) | |
2048 | ||
2049 | (defun gnus-summary-menu-split (menu) | |
2050 | ;; If we have lots of elements, divide them into groups of 20 | |
2051 | ;; and make a pane (or submenu) for each one. | |
2052 | (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2)) | |
2053 | (let ((menu menu) sublists next | |
2054 | (i 1)) | |
2055 | (while menu | |
2056 | ;; Pull off the next gnus-summary-menu-maxlen elements | |
2057 | ;; and make them the next element of sublist. | |
2058 | (setq next (nthcdr gnus-summary-menu-maxlen menu)) | |
2059 | (if next | |
2060 | (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu) | |
2061 | nil)) | |
2062 | (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0) | |
2063 | (aref (car (last menu)) 0)) menu) | |
2064 | sublists)) | |
2065 | (setq i (1+ i)) | |
2066 | (setq menu next)) | |
2067 | (nreverse sublists)) | |
2068 | ;; Few elements--put them all in one pane. | |
2069 | menu)) | |
eec82323 LMI |
2070 | |
2071 | (defun gnus-summary-make-menu-bar () | |
2072 | (gnus-turn-off-edit-menu 'summary) | |
2073 | ||
2074 | (unless (boundp 'gnus-summary-misc-menu) | |
2075 | ||
2076 | (easy-menu-define | |
23f87bed MB |
2077 | gnus-summary-kill-menu gnus-summary-mode-map "" |
2078 | (cons | |
2079 | "Score" | |
2080 | (nconc | |
2081 | (list | |
2082 | ["Customize" gnus-score-customize t]) | |
2083 | (gnus-make-score-map 'increase) | |
2084 | (gnus-make-score-map 'lower) | |
2085 | '(("Mark" | |
2086 | ["Kill below" gnus-summary-kill-below t] | |
2087 | ["Mark above" gnus-summary-mark-above t] | |
2088 | ["Tick above" gnus-summary-tick-above t] | |
2089 | ["Clear above" gnus-summary-clear-above t]) | |
2090 | ["Current score" gnus-summary-current-score t] | |
2091 | ["Set score" gnus-summary-set-score t] | |
2092 | ["Switch current score file..." gnus-score-change-score-file t] | |
2093 | ["Set mark below..." gnus-score-set-mark-below t] | |
2094 | ["Set expunge below..." gnus-score-set-expunge-below t] | |
2095 | ["Edit current score file" gnus-score-edit-current-scores t] | |
2096 | ["Edit score file" gnus-score-edit-file t] | |
2097 | ["Trace score" gnus-score-find-trace t] | |
2098 | ["Find words" gnus-score-find-favourite-words t] | |
2099 | ["Rescore buffer" gnus-summary-rescore t] | |
2100 | ["Increase score..." gnus-summary-increase-score t] | |
2101 | ["Lower score..." gnus-summary-lower-score t])))) | |
2102 | ||
2103 | ;; Define both the Article menu in the summary buffer and the | |
2104 | ;; equivalent Commands menu in the article buffer here for | |
2105 | ;; consistency. | |
6748645f | 2106 | (let ((innards |
23f87bed MB |
2107 | `(("Hide" |
2108 | ["All" gnus-article-hide t] | |
2109 | ["Headers" gnus-article-hide-headers t] | |
2110 | ["Signature" gnus-article-hide-signature t] | |
2111 | ["Citation" gnus-article-hide-citation t] | |
16409b0b | 2112 | ["List identifiers" gnus-article-hide-list-identifiers t] |
16409b0b | 2113 | ["Banner" gnus-article-strip-banner t] |
23f87bed MB |
2114 | ["Boring headers" gnus-article-hide-boring-headers t]) |
2115 | ("Highlight" | |
2116 | ["All" gnus-article-highlight t] | |
2117 | ["Headers" gnus-article-highlight-headers t] | |
2118 | ["Signature" gnus-article-highlight-signature t] | |
2119 | ["Citation" gnus-article-highlight-citation t]) | |
16409b0b GM |
2120 | ("MIME" |
2121 | ["Words" gnus-article-decode-mime-words t] | |
2122 | ["Charset" gnus-article-decode-charset t] | |
2123 | ["QP" gnus-article-de-quoted-unreadable t] | |
2124 | ["Base64" gnus-article-de-base64-unreadable t] | |
23f87bed MB |
2125 | ["View MIME buttons" gnus-summary-display-buttonized t] |
2126 | ["View all" gnus-mime-view-all-parts t] | |
2127 | ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t] | |
2128 | ["Encrypt body" gnus-article-encrypt-body | |
2129 | :active (not (gnus-group-read-only-p)) | |
2130 | ,@(if (featurep 'xemacs) nil | |
2131 | '(:help "Encrypt the message body on disk"))] | |
2132 | ["Extract all parts..." gnus-summary-save-parts t] | |
2133 | ("Multipart" | |
2134 | ["Repair multipart" gnus-summary-repair-multipart t] | |
2135 | ["Pipe part..." gnus-article-pipe-part t] | |
2136 | ["Inline part" gnus-article-inline-part t] | |
2137 | ["Encrypt body" gnus-article-encrypt-body | |
2138 | :active (not (gnus-group-read-only-p)) | |
2139 | ,@(if (featurep 'xemacs) nil | |
2140 | '(:help "Encrypt the message body on disk"))] | |
2141 | ["View part externally" gnus-article-view-part-externally t] | |
2142 | ["View part with charset..." gnus-article-view-part-as-charset t] | |
2143 | ["Copy part" gnus-article-copy-part t] | |
2144 | ["Save part..." gnus-article-save-part t] | |
2145 | ["View part" gnus-article-view-part t])) | |
2146 | ("Date" | |
2147 | ["Local" gnus-article-date-local t] | |
2148 | ["ISO8601" gnus-article-date-iso8601 t] | |
2149 | ["UT" gnus-article-date-ut t] | |
2150 | ["Original" gnus-article-date-original t] | |
2151 | ["Lapsed" gnus-article-date-lapsed t] | |
2152 | ["User-defined" gnus-article-date-user t]) | |
2153 | ("Display" | |
2154 | ["Remove images" gnus-article-remove-images t] | |
2155 | ["Toggle smiley" gnus-treat-smiley t] | |
2156 | ["Show X-Face" gnus-article-display-x-face t] | |
2157 | ["Show picons in From" gnus-treat-from-picon t] | |
2158 | ["Show picons in mail headers" gnus-treat-mail-picon t] | |
2159 | ["Show picons in news headers" gnus-treat-newsgroups-picon t] | |
2160 | ("View as different encoding" | |
2161 | ,@(gnus-summary-menu-split | |
2162 | (mapcar | |
2163 | (lambda (cs) | |
2164 | ;; Since easymenu under Emacs doesn't allow | |
2165 | ;; lambda forms for menu commands, we should | |
2166 | ;; provide intern'ed function symbols. | |
2167 | (let ((command (intern (format "\ | |
2168 | gnus-summary-show-article-from-menu-as-charset-%s" cs)))) | |
2169 | (fset command | |
2170 | `(lambda () | |
2171 | (interactive) | |
2172 | (let ((gnus-summary-show-article-charset-alist | |
2173 | '((1 . ,cs)))) | |
2174 | (gnus-summary-show-article 1)))) | |
2175 | `[,(symbol-name cs) ,command t])) | |
2176 | (sort (if (fboundp 'coding-system-list) | |
2177 | (coding-system-list) | |
2178 | (mapcar 'car mm-mime-mule-charset-alist)) | |
2179 | 'string<))))) | |
2180 | ("Washing" | |
2181 | ("Remove Blanks" | |
2182 | ["Leading" gnus-article-strip-leading-blank-lines t] | |
2183 | ["Multiple" gnus-article-strip-multiple-blank-lines t] | |
2184 | ["Trailing" gnus-article-remove-trailing-blank-lines t] | |
2185 | ["All of the above" gnus-article-strip-blank-lines t] | |
2186 | ["All" gnus-article-strip-all-blank-lines t] | |
2187 | ["Leading space" gnus-article-strip-leading-space t] | |
2188 | ["Trailing space" gnus-article-strip-trailing-space t] | |
2189 | ["Leading space in headers" | |
2190 | gnus-article-remove-leading-whitespace t]) | |
2191 | ["Overstrike" gnus-article-treat-overstrike t] | |
2192 | ["Dumb quotes" gnus-article-treat-dumbquotes t] | |
2193 | ["Emphasis" gnus-article-emphasize t] | |
2194 | ["Word wrap" gnus-article-fill-cited-article t] | |
16409b0b GM |
2195 | ["Fill long lines" gnus-article-fill-long-lines t] |
2196 | ["Capitalize sentences" gnus-article-capitalize-sentences t] | |
23f87bed MB |
2197 | ["Remove CR" gnus-article-remove-cr t] |
2198 | ["Quoted-Printable" gnus-article-de-quoted-unreadable t] | |
2199 | ["Base64" gnus-article-de-base64-unreadable t] | |
2200 | ["Rot 13" gnus-summary-caesar-message | |
2201 | ,@(if (featurep 'xemacs) '(t) | |
2202 | '(:help "\"Caesar rotate\" article by 13"))] | |
2203 | ["Morse decode" gnus-summary-morse-message t] | |
2204 | ["Unix pipe..." gnus-summary-pipe-message t] | |
2205 | ["Add buttons" gnus-article-add-buttons t] | |
2206 | ["Add buttons to head" gnus-article-add-buttons-to-head t] | |
2207 | ["Stop page breaking" gnus-summary-stop-page-breaking t] | |
2208 | ["Verbose header" gnus-summary-verbose-headers t] | |
2209 | ["Toggle header" gnus-summary-toggle-header t] | |
2210 | ["Unfold headers" gnus-article-treat-unfold-headers t] | |
2211 | ["Fold newsgroups" gnus-article-treat-fold-newsgroups t] | |
16409b0b | 2212 | ["Html" gnus-article-wash-html t] |
23f87bed MB |
2213 | ["Unsplit URLs" gnus-article-unsplit-urls t] |
2214 | ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t] | |
2215 | ["Decode HZ" gnus-article-decode-HZ t] | |
2216 | ("(Outlook) Deuglify" | |
2217 | ["Unwrap lines" gnus-article-outlook-unwrap-lines t] | |
2218 | ["Repair attribution" gnus-article-outlook-repair-attribution t] | |
2219 | ["Rearrange citation" gnus-article-outlook-rearrange-citation t] | |
2220 | ["Full (Outlook) deuglify" | |
2221 | gnus-article-outlook-deuglify-article t]) | |
2222 | ) | |
2223 | ("Output" | |
2224 | ["Save in default format..." gnus-summary-save-article | |
2225 | ,@(if (featurep 'xemacs) '(t) | |
2226 | '(:help "Save article using default method"))] | |
2227 | ["Save in file..." gnus-summary-save-article-file | |
2228 | ,@(if (featurep 'xemacs) '(t) | |
2229 | '(:help "Save article in file"))] | |
2230 | ["Save in Unix mail format..." gnus-summary-save-article-mail t] | |
2231 | ["Save in MH folder..." gnus-summary-save-article-folder t] | |
2232 | ["Save in VM folder..." gnus-summary-save-article-vm t] | |
2233 | ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t] | |
2234 | ["Save body in file..." gnus-summary-save-article-body-file t] | |
2235 | ["Pipe through a filter..." gnus-summary-pipe-output t] | |
2236 | ["Add to SOUP packet" gnus-soup-add-article t] | |
2237 | ["Print with Muttprint..." gnus-summary-muttprint t] | |
2238 | ["Print" gnus-summary-print-article t]) | |
2239 | ("Backend" | |
2240 | ["Respool article..." gnus-summary-respool-article t] | |
2241 | ["Move article..." gnus-summary-move-article | |
2242 | (gnus-check-backend-function | |
2243 | 'request-move-article gnus-newsgroup-name)] | |
2244 | ["Copy article..." gnus-summary-copy-article t] | |
2245 | ["Crosspost article..." gnus-summary-crosspost-article | |
2246 | (gnus-check-backend-function | |
2247 | 'request-replace-article gnus-newsgroup-name)] | |
2248 | ["Import file..." gnus-summary-import-article | |
2249 | (gnus-check-backend-function | |
2250 | 'request-accept-article gnus-newsgroup-name)] | |
2251 | ["Create article..." gnus-summary-create-article | |
2252 | (gnus-check-backend-function | |
2253 | 'request-accept-article gnus-newsgroup-name)] | |
2254 | ["Check if posted" gnus-summary-article-posted-p t] | |
2255 | ["Edit article" gnus-summary-edit-article | |
2256 | (not (gnus-group-read-only-p))] | |
2257 | ["Delete article" gnus-summary-delete-article | |
2258 | (gnus-check-backend-function | |
2259 | 'request-expire-articles gnus-newsgroup-name)] | |
2260 | ["Query respool" gnus-summary-respool-query t] | |
6748645f | 2261 | ["Trace respool" gnus-summary-respool-trace t] |
23f87bed MB |
2262 | ["Delete expirable articles" gnus-summary-expire-articles-now |
2263 | (gnus-check-backend-function | |
2264 | 'request-expire-articles gnus-newsgroup-name)]) | |
2265 | ("Extract" | |
2266 | ["Uudecode" gnus-uu-decode-uu | |
2267 | ,@(if (featurep 'xemacs) '(t) | |
2268 | '(:help "Decode uuencoded article(s)"))] | |
2269 | ["Uudecode and save" gnus-uu-decode-uu-and-save t] | |
2270 | ["Unshar" gnus-uu-decode-unshar t] | |
2271 | ["Unshar and save" gnus-uu-decode-unshar-and-save t] | |
2272 | ["Save" gnus-uu-decode-save t] | |
2273 | ["Binhex" gnus-uu-decode-binhex t] | |
2274 | ["Postscript" gnus-uu-decode-postscript t] | |
2275 | ["All MIME parts" gnus-summary-save-parts t]) | |
2276 | ("Cache" | |
2277 | ["Enter article" gnus-cache-enter-article t] | |
2278 | ["Remove article" gnus-cache-remove-article t]) | |
16409b0b | 2279 | ["Translate" gnus-article-babel t] |
23f87bed MB |
2280 | ["Select article buffer" gnus-summary-select-article-buffer t] |
2281 | ["Enter digest buffer" gnus-summary-enter-digest-group t] | |
2282 | ["Isearch article..." gnus-summary-isearch-article t] | |
2283 | ["Beginning of the article" gnus-summary-beginning-of-article t] | |
2284 | ["End of the article" gnus-summary-end-of-article t] | |
2285 | ["Fetch parent of article" gnus-summary-refer-parent-article t] | |
2286 | ["Fetch referenced articles" gnus-summary-refer-references t] | |
2287 | ["Fetch current thread" gnus-summary-refer-thread t] | |
2288 | ["Fetch article with id..." gnus-summary-refer-article t] | |
2289 | ["Setup Mailing List Params" gnus-mailing-list-insinuate t] | |
2290 | ["Redisplay" gnus-summary-show-article t] | |
2291 | ["Raw article" gnus-summary-show-raw-article :keys "C-u g"]))) | |
6748645f | 2292 | (easy-menu-define |
23f87bed MB |
2293 | gnus-summary-article-menu gnus-summary-mode-map "" |
2294 | (cons "Article" innards)) | |
6748645f | 2295 | |
1653df0f SZ |
2296 | (if (not (keymapp gnus-summary-article-menu)) |
2297 | (easy-menu-define | |
2298 | gnus-article-commands-menu gnus-article-mode-map "" | |
2299 | (cons "Commands" innards)) | |
2300 | ;; in Emacs, don't share menu. | |
a1506d29 | 2301 | (setq gnus-article-commands-menu |
1653df0f SZ |
2302 | (copy-keymap gnus-summary-article-menu)) |
2303 | (define-key gnus-article-mode-map [menu-bar commands] | |
2304 | (cons "Commands" gnus-article-commands-menu)))) | |
eec82323 LMI |
2305 | |
2306 | (easy-menu-define | |
23f87bed MB |
2307 | gnus-summary-thread-menu gnus-summary-mode-map "" |
2308 | '("Threads" | |
2309 | ["Find all messages in thread" gnus-summary-refer-thread t] | |
2310 | ["Toggle threading" gnus-summary-toggle-threads t] | |
2311 | ["Hide threads" gnus-summary-hide-all-threads t] | |
2312 | ["Show threads" gnus-summary-show-all-threads t] | |
2313 | ["Hide thread" gnus-summary-hide-thread t] | |
2314 | ["Show thread" gnus-summary-show-thread t] | |
2315 | ["Go to next thread" gnus-summary-next-thread t] | |
2316 | ["Go to previous thread" gnus-summary-prev-thread t] | |
2317 | ["Go down thread" gnus-summary-down-thread t] | |
2318 | ["Go up thread" gnus-summary-up-thread t] | |
2319 | ["Top of thread" gnus-summary-top-thread t] | |
2320 | ["Mark thread as read" gnus-summary-kill-thread t] | |
2321 | ["Lower thread score" gnus-summary-lower-thread t] | |
2322 | ["Raise thread score" gnus-summary-raise-thread t] | |
2323 | ["Rethread current" gnus-summary-rethread-current t])) | |
eec82323 LMI |
2324 | |
2325 | (easy-menu-define | |
23f87bed MB |
2326 | gnus-summary-post-menu gnus-summary-mode-map "" |
2327 | `("Post" | |
2328 | ["Send a message (mail or news)" gnus-summary-post-news | |
2329 | ,@(if (featurep 'xemacs) '(t) | |
2330 | '(:help "Post an article"))] | |
2331 | ["Followup" gnus-summary-followup | |
2332 | ,@(if (featurep 'xemacs) '(t) | |
2333 | '(:help "Post followup to this article"))] | |
2334 | ["Followup and yank" gnus-summary-followup-with-original | |
2335 | ,@(if (featurep 'xemacs) '(t) | |
2336 | '(:help "Post followup to this article, quoting its contents"))] | |
2337 | ["Supersede article" gnus-summary-supersede-article t] | |
2338 | ["Cancel article" gnus-summary-cancel-article | |
2339 | ,@(if (featurep 'xemacs) '(t) | |
2340 | '(:help "Cancel an article you posted"))] | |
2341 | ["Reply" gnus-summary-reply t] | |
2342 | ["Reply and yank" gnus-summary-reply-with-original t] | |
2343 | ["Wide reply" gnus-summary-wide-reply t] | |
2344 | ["Wide reply and yank" gnus-summary-wide-reply-with-original | |
2345 | ,@(if (featurep 'xemacs) '(t) | |
2346 | '(:help "Mail a reply, quoting this article"))] | |
2347 | ["Very wide reply" gnus-summary-very-wide-reply t] | |
2348 | ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original | |
2349 | ,@(if (featurep 'xemacs) '(t) | |
2350 | '(:help "Mail a very wide reply, quoting this article"))] | |
2351 | ["Mail forward" gnus-summary-mail-forward t] | |
2352 | ["Post forward" gnus-summary-post-forward t] | |
2353 | ["Digest and mail" gnus-uu-digest-mail-forward t] | |
2354 | ["Digest and post" gnus-uu-digest-post-forward t] | |
2355 | ["Resend message" gnus-summary-resend-message t] | |
2356 | ["Resend message edit" gnus-summary-resend-message-edit t] | |
2357 | ["Send bounced mail" gnus-summary-resend-bounced-mail t] | |
2358 | ["Send a mail" gnus-summary-mail-other-window t] | |
2359 | ["Create a local message" gnus-summary-news-other-window t] | |
2360 | ["Uuencode and post" gnus-uu-post-news | |
2361 | ,@(if (featurep 'xemacs) '(t) | |
2362 | '(:help "Post a uuencoded article"))] | |
2363 | ["Followup via news" gnus-summary-followup-to-mail t] | |
2364 | ["Followup via news and yank" | |
2365 | gnus-summary-followup-to-mail-with-original t] | |
2366 | ;;("Draft" | |
2367 | ;;["Send" gnus-summary-send-draft t] | |
2368 | ;;["Send bounced" gnus-resend-bounced-mail t]) | |
2369 | )) | |
2370 | ||
2371 | (cond | |
2372 | ((not (keymapp gnus-summary-post-menu)) | |
2373 | (setq gnus-article-post-menu gnus-summary-post-menu)) | |
2374 | ((not gnus-article-post-menu) | |
2375 | ;; Don't share post menu. | |
2376 | (setq gnus-article-post-menu | |
2377 | (copy-keymap gnus-summary-post-menu)))) | |
2378 | (define-key gnus-article-mode-map [menu-bar post] | |
2379 | (cons "Post" gnus-article-post-menu)) | |
eec82323 LMI |
2380 | |
2381 | (easy-menu-define | |
23f87bed MB |
2382 | gnus-summary-misc-menu gnus-summary-mode-map "" |
2383 | `("Gnus" | |
2384 | ("Mark Read" | |
2385 | ["Mark as read" gnus-summary-mark-as-read-forward t] | |
2386 | ["Mark same subject and select" | |
2387 | gnus-summary-kill-same-subject-and-select t] | |
2388 | ["Mark same subject" gnus-summary-kill-same-subject t] | |
2389 | ["Catchup" gnus-summary-catchup | |
2390 | ,@(if (featurep 'xemacs) '(t) | |
2391 | '(:help "Mark unread articles in this group as read"))] | |
2392 | ["Catchup all" gnus-summary-catchup-all t] | |
2393 | ["Catchup to here" gnus-summary-catchup-to-here t] | |
2394 | ["Catchup from here" gnus-summary-catchup-from-here t] | |
2395 | ["Catchup region" gnus-summary-mark-region-as-read | |
2396 | (gnus-mark-active-p)] | |
2397 | ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t]) | |
2398 | ("Mark Various" | |
2399 | ["Tick" gnus-summary-tick-article-forward t] | |
2400 | ["Mark as dormant" gnus-summary-mark-as-dormant t] | |
2401 | ["Remove marks" gnus-summary-clear-mark-forward t] | |
2402 | ["Set expirable mark" gnus-summary-mark-as-expirable t] | |
2403 | ["Set bookmark" gnus-summary-set-bookmark t] | |
2404 | ["Remove bookmark" gnus-summary-remove-bookmark t]) | |
2405 | ("Limit to" | |
2406 | ["Marks..." gnus-summary-limit-to-marks t] | |
2407 | ["Subject..." gnus-summary-limit-to-subject t] | |
2408 | ["Author..." gnus-summary-limit-to-author t] | |
2409 | ["Age..." gnus-summary-limit-to-age t] | |
2410 | ["Extra..." gnus-summary-limit-to-extra t] | |
2411 | ["Score..." gnus-summary-limit-to-score t] | |
2412 | ["Display Predicate" gnus-summary-limit-to-display-predicate t] | |
2413 | ["Unread" gnus-summary-limit-to-unread t] | |
2414 | ["Unseen" gnus-summary-limit-to-unseen t] | |
2415 | ["Non-dormant" gnus-summary-limit-exclude-dormant t] | |
2416 | ["Next articles" gnus-summary-limit-to-articles t] | |
2417 | ["Pop limit" gnus-summary-pop-limit t] | |
2418 | ["Show dormant" gnus-summary-limit-include-dormant t] | |
2419 | ["Hide childless dormant" | |
2420 | gnus-summary-limit-exclude-childless-dormant t] | |
2421 | ;;["Hide thread" gnus-summary-limit-exclude-thread t] | |
2422 | ["Hide marked" gnus-summary-limit-exclude-marks t] | |
2423 | ["Show expunged" gnus-summary-limit-include-expunged t]) | |
2424 | ("Process Mark" | |
2425 | ["Set mark" gnus-summary-mark-as-processable t] | |
2426 | ["Remove mark" gnus-summary-unmark-as-processable t] | |
2427 | ["Remove all marks" gnus-summary-unmark-all-processable t] | |
2428 | ["Mark above" gnus-uu-mark-over t] | |
2429 | ["Mark series" gnus-uu-mark-series t] | |
2430 | ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)] | |
2431 | ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)] | |
2432 | ["Mark by regexp..." gnus-uu-mark-by-regexp t] | |
2433 | ["Unmark by regexp..." gnus-uu-unmark-by-regexp t] | |
2434 | ["Mark all" gnus-uu-mark-all t] | |
2435 | ["Mark buffer" gnus-uu-mark-buffer t] | |
2436 | ["Mark sparse" gnus-uu-mark-sparse t] | |
2437 | ["Mark thread" gnus-uu-mark-thread t] | |
2438 | ["Unmark thread" gnus-uu-unmark-thread t] | |
2439 | ("Process Mark Sets" | |
2440 | ["Kill" gnus-summary-kill-process-mark t] | |
2441 | ["Yank" gnus-summary-yank-process-mark | |
2442 | gnus-newsgroup-process-stack] | |
2443 | ["Save" gnus-summary-save-process-mark t] | |
2444 | ["Run command on marked..." gnus-summary-universal-argument t])) | |
2445 | ("Scroll article" | |
2446 | ["Page forward" gnus-summary-next-page | |
2447 | ,@(if (featurep 'xemacs) '(t) | |
2448 | '(:help "Show next page of article"))] | |
2449 | ["Page backward" gnus-summary-prev-page | |
2450 | ,@(if (featurep 'xemacs) '(t) | |
2451 | '(:help "Show previous page of article"))] | |
2452 | ["Line forward" gnus-summary-scroll-up t]) | |
2453 | ("Move" | |
2454 | ["Next unread article" gnus-summary-next-unread-article t] | |
2455 | ["Previous unread article" gnus-summary-prev-unread-article t] | |
2456 | ["Next article" gnus-summary-next-article t] | |
2457 | ["Previous article" gnus-summary-prev-article t] | |
2458 | ["Next unread subject" gnus-summary-next-unread-subject t] | |
2459 | ["Previous unread subject" gnus-summary-prev-unread-subject t] | |
2460 | ["Next article same subject" gnus-summary-next-same-subject t] | |
2461 | ["Previous article same subject" gnus-summary-prev-same-subject t] | |
2462 | ["First unread article" gnus-summary-first-unread-article t] | |
2463 | ["Best unread article" gnus-summary-best-unread-article t] | |
2464 | ["Go to subject number..." gnus-summary-goto-subject t] | |
2465 | ["Go to article number..." gnus-summary-goto-article t] | |
2466 | ["Go to the last article" gnus-summary-goto-last-article t] | |
2467 | ["Pop article off history" gnus-summary-pop-article t]) | |
2468 | ("Sort" | |
2469 | ["Sort by number" gnus-summary-sort-by-number t] | |
2470 | ["Sort by author" gnus-summary-sort-by-author t] | |
2471 | ["Sort by subject" gnus-summary-sort-by-subject t] | |
2472 | ["Sort by date" gnus-summary-sort-by-date t] | |
2473 | ["Sort by score" gnus-summary-sort-by-score t] | |
2474 | ["Sort by lines" gnus-summary-sort-by-lines t] | |
2475 | ["Sort by characters" gnus-summary-sort-by-chars t] | |
2476 | ["Randomize" gnus-summary-sort-by-random t] | |
2477 | ["Original sort" gnus-summary-sort-by-original t]) | |
2478 | ("Help" | |
2479 | ["Fetch group FAQ" gnus-summary-fetch-faq t] | |
2480 | ["Describe group" gnus-summary-describe-group t] | |
2481 | ["Fetch charter" gnus-group-fetch-charter | |
2482 | ,@(if (featurep 'xemacs) nil | |
2483 | '(:help "Display the charter of the current group"))] | |
2484 | ["Fetch control message" gnus-group-fetch-control | |
2485 | ,@(if (featurep 'xemacs) nil | |
2486 | '(:help "Display the archived control message for the current group"))] | |
2487 | ["Read manual" gnus-info-find-node t]) | |
2488 | ("Modes" | |
2489 | ["Pick and read" gnus-pick-mode t] | |
2490 | ["Binary" gnus-binary-mode t]) | |
2491 | ("Regeneration" | |
2492 | ["Regenerate" gnus-summary-prepare t] | |
2493 | ["Insert cached articles" gnus-summary-insert-cached-articles t] | |
2494 | ["Insert dormant articles" gnus-summary-insert-dormant-articles t] | |
2495 | ["Toggle threading" gnus-summary-toggle-threads t]) | |
2496 | ["See old articles" gnus-summary-insert-old-articles t] | |
2497 | ["See new articles" gnus-summary-insert-new-articles t] | |
2498 | ["Filter articles..." gnus-summary-execute-command t] | |
2499 | ["Run command on articles..." gnus-summary-universal-argument t] | |
2500 | ["Search articles forward..." gnus-summary-search-article-forward t] | |
2501 | ["Search articles backward..." gnus-summary-search-article-backward t] | |
2502 | ["Toggle line truncation" gnus-summary-toggle-truncation t] | |
2503 | ["Expand window" gnus-summary-expand-window t] | |
2504 | ["Expire expirable articles" gnus-summary-expire-articles | |
2505 | (gnus-check-backend-function | |
2506 | 'request-expire-articles gnus-newsgroup-name)] | |
2507 | ["Edit local kill file" gnus-summary-edit-local-kill t] | |
2508 | ["Edit main kill file" gnus-summary-edit-global-kill t] | |
2509 | ["Edit group parameters" gnus-summary-edit-parameters t] | |
2510 | ["Customize group parameters" gnus-summary-customize-parameters t] | |
2511 | ["Send a bug report" gnus-bug t] | |
2512 | ("Exit" | |
2513 | ["Catchup and exit" gnus-summary-catchup-and-exit | |
2514 | ,@(if (featurep 'xemacs) '(t) | |
2515 | '(:help "Mark unread articles in this group as read, then exit"))] | |
2516 | ["Catchup all and exit" gnus-summary-catchup-all-and-exit t] | |
2517 | ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t] | |
2518 | ["Exit group" gnus-summary-exit | |
2519 | ,@(if (featurep 'xemacs) '(t) | |
2520 | '(:help "Exit current group, return to group selection mode"))] | |
2521 | ["Exit group without updating" gnus-summary-exit-no-update t] | |
2522 | ["Exit and goto next group" gnus-summary-next-group t] | |
2523 | ["Exit and goto prev group" gnus-summary-prev-group t] | |
2524 | ["Reselect group" gnus-summary-reselect-current-group t] | |
2525 | ["Rescan group" gnus-summary-rescan-group t] | |
2526 | ["Update dribble" gnus-summary-save-newsrc t]))) | |
eec82323 | 2527 | |
6748645f | 2528 | (gnus-run-hooks 'gnus-summary-menu-hook))) |
eec82323 | 2529 | |
60bd5589 DL |
2530 | (defvar gnus-summary-tool-bar-map nil) |
2531 | ||
9a0026a6 | 2532 | ;; Emacs 21 tool bar. Should be no-op otherwise. |
60bd5589 | 2533 | (defun gnus-summary-make-tool-bar () |
23f87bed MB |
2534 | (if (and (fboundp 'tool-bar-add-item-from-menu) |
2535 | (default-value 'tool-bar-mode) | |
2536 | (not gnus-summary-tool-bar-map)) | |
60bd5589 | 2537 | (setq gnus-summary-tool-bar-map |
23f87bed MB |
2538 | (let ((tool-bar-map (make-sparse-keymap)) |
2539 | (load-path (mm-image-load-path))) | |
60bd5589 DL |
2540 | (tool-bar-add-item-from-menu |
2541 | 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map) | |
2542 | (tool-bar-add-item-from-menu | |
2543 | 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map) | |
2544 | (tool-bar-add-item-from-menu | |
2545 | 'gnus-summary-post-news "post" gnus-summary-mode-map) | |
2546 | (tool-bar-add-item-from-menu | |
2547 | 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map) | |
2548 | (tool-bar-add-item-from-menu | |
2549 | 'gnus-summary-followup "followup" gnus-summary-mode-map) | |
2550 | (tool-bar-add-item-from-menu | |
2551 | 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map) | |
2552 | (tool-bar-add-item-from-menu | |
2553 | 'gnus-summary-reply "reply" gnus-summary-mode-map) | |
2554 | (tool-bar-add-item-from-menu | |
2555 | 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map) | |
2556 | (tool-bar-add-item-from-menu | |
2557 | 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map) | |
2558 | (tool-bar-add-item-from-menu | |
2559 | 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map) | |
2560 | (tool-bar-add-item-from-menu | |
2561 | 'gnus-summary-save-article "save-art" gnus-summary-mode-map) | |
2562 | (tool-bar-add-item-from-menu | |
2563 | 'gnus-uu-post-news "uu-post" gnus-summary-mode-map) | |
2564 | (tool-bar-add-item-from-menu | |
2565 | 'gnus-summary-catchup "catchup" gnus-summary-mode-map) | |
2566 | (tool-bar-add-item-from-menu | |
2567 | 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map) | |
2568 | (tool-bar-add-item-from-menu | |
2569 | 'gnus-summary-exit "exit-summ" gnus-summary-mode-map) | |
2570 | tool-bar-map))) | |
2571 | (if gnus-summary-tool-bar-map | |
2572 | (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))) | |
2573 | ||
eec82323 LMI |
2574 | (defun gnus-score-set-default (var value) |
2575 | "A version of set that updates the GNU Emacs menu-bar." | |
2576 | (set var value) | |
2577 | ;; It is the message that forces the active status to be updated. | |
2578 | (message "")) | |
2579 | ||
2580 | (defun gnus-make-score-map (type) | |
2581 | "Make a summary score map of type TYPE." | |
2582 | (if t | |
2583 | nil | |
2584 | (let ((headers '(("author" "from" string) | |
2585 | ("subject" "subject" string) | |
2586 | ("article body" "body" string) | |
2587 | ("article head" "head" string) | |
2588 | ("xref" "xref" string) | |
16409b0b | 2589 | ("extra header" "extra" string) |
eec82323 LMI |
2590 | ("lines" "lines" number) |
2591 | ("followups to author" "followup" string))) | |
2592 | (types '((number ("less than" <) | |
2593 | ("greater than" >) | |
2594 | ("equal" =)) | |
2595 | (string ("substring" s) | |
2596 | ("exact string" e) | |
2597 | ("fuzzy string" f) | |
2598 | ("regexp" r)))) | |
2599 | (perms '(("temporary" (current-time-string)) | |
2600 | ("permanent" nil) | |
2601 | ("immediate" now))) | |
2602 | header) | |
2603 | (list | |
2604 | (apply | |
2605 | 'nconc | |
2606 | (list | |
2607 | (if (eq type 'lower) | |
2608 | "Lower score" | |
2609 | "Increase score")) | |
2610 | (let (outh) | |
2611 | (while headers | |
2612 | (setq header (car headers)) | |
2613 | (setq outh | |
2614 | (cons | |
2615 | (apply | |
2616 | 'nconc | |
2617 | (list (car header)) | |
2618 | (let ((ts (cdr (assoc (nth 2 header) types))) | |
2619 | outt) | |
2620 | (while ts | |
2621 | (setq outt | |
2622 | (cons | |
2623 | (apply | |
2624 | 'nconc | |
2625 | (list (caar ts)) | |
2626 | (let ((ps perms) | |
2627 | outp) | |
2628 | (while ps | |
2629 | (setq outp | |
2630 | (cons | |
2631 | (vector | |
2632 | (caar ps) | |
2633 | (list | |
2634 | 'gnus-summary-score-entry | |
2635 | (nth 1 header) | |
2636 | (if (or (string= (nth 1 header) | |
2637 | "head") | |
2638 | (string= (nth 1 header) | |
2639 | "body")) | |
2640 | "" | |
2641 | (list 'gnus-summary-header | |
2642 | (nth 1 header))) | |
2643 | (list 'quote (nth 1 (car ts))) | |
16409b0b GM |
2644 | (list 'gnus-score-delta-default |
2645 | nil) | |
eec82323 LMI |
2646 | (nth 1 (car ps)) |
2647 | t) | |
2648 | t) | |
2649 | outp)) | |
2650 | (setq ps (cdr ps))) | |
2651 | (list (nreverse outp)))) | |
2652 | outt)) | |
2653 | (setq ts (cdr ts))) | |
2654 | (list (nreverse outt)))) | |
2655 | outh)) | |
2656 | (setq headers (cdr headers))) | |
2657 | (list (nreverse outh)))))))) | |
2658 | ||
2659 | \f | |
2660 | ||
2661 | (defun gnus-summary-mode (&optional group) | |
2662 | "Major mode for reading articles. | |
2663 | ||
2664 | All normal editing commands are switched off. | |
2665 | \\<gnus-summary-mode-map> | |
2666 | Each line in this buffer represents one article. To read an | |
2667 | article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards | |
2668 | and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]', | |
2669 | respectively. | |
2670 | ||
2671 | You can also post articles and send mail from this buffer. To | |
23f87bed | 2672 | follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author |
eec82323 LMI |
2673 | of an article, type `\\[gnus-summary-reply]'. |
2674 | ||
2675 | There are approx. one gazillion commands you can execute in this | |
2676 | buffer; read the info pages for more information (`\\[gnus-info-find-node]'). | |
2677 | ||
2678 | The following commands are available: | |
2679 | ||
2680 | \\{gnus-summary-mode-map}" | |
2681 | (interactive) | |
eec82323 | 2682 | (kill-all-local-variables) |
60bd5589 DL |
2683 | (when (gnus-visual-p 'summary-menu 'menu) |
2684 | (gnus-summary-make-menu-bar) | |
2685 | (gnus-summary-make-tool-bar)) | |
eec82323 | 2686 | (gnus-summary-make-local-variables) |
23f87bed MB |
2687 | (let ((gnus-summary-local-variables gnus-newsgroup-variables)) |
2688 | (gnus-summary-make-local-variables)) | |
eec82323 LMI |
2689 | (gnus-make-thread-indent-array) |
2690 | (gnus-simplify-mode-line) | |
2691 | (setq major-mode 'gnus-summary-mode) | |
2692 | (setq mode-name "Summary") | |
2693 | (make-local-variable 'minor-mode-alist) | |
2694 | (use-local-map gnus-summary-mode-map) | |
16409b0b | 2695 | (buffer-disable-undo) |
eec82323 LMI |
2696 | (setq buffer-read-only t) ;Disable modification |
2697 | (setq truncate-lines t) | |
2698 | (setq selective-display t) | |
2699 | (setq selective-display-ellipses t) ;Display `...' | |
2700 | (gnus-summary-set-display-table) | |
2701 | (gnus-set-default-directory) | |
2702 | (setq gnus-newsgroup-name group) | |
2703 | (make-local-variable 'gnus-summary-line-format) | |
2704 | (make-local-variable 'gnus-summary-line-format-spec) | |
6748645f LMI |
2705 | (make-local-variable 'gnus-summary-dummy-line-format) |
2706 | (make-local-variable 'gnus-summary-dummy-line-format-spec) | |
eec82323 | 2707 | (make-local-variable 'gnus-summary-mark-positions) |
23f87bed | 2708 | (gnus-make-local-hook 'pre-command-hook) |
6748645f LMI |
2709 | (add-hook 'pre-command-hook 'gnus-set-global-variables nil t) |
2710 | (gnus-run-hooks 'gnus-summary-mode-hook) | |
23f87bed | 2711 | (turn-on-gnus-mailing-list-mode) |
87545352 | 2712 | (mm-enable-multibyte) |
eec82323 LMI |
2713 | (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy) |
2714 | (gnus-update-summary-mark-positions)) | |
2715 | ||
2716 | (defun gnus-summary-make-local-variables () | |
2717 | "Make all the local summary buffer variables." | |
16409b0b GM |
2718 | (let (global) |
2719 | (dolist (local gnus-summary-local-variables) | |
eec82323 LMI |
2720 | (if (consp local) |
2721 | (progn | |
2722 | (if (eq (cdr local) 'global) | |
2723 | ;; Copy the global value of the variable. | |
2724 | (setq global (symbol-value (car local))) | |
2725 | ;; Use the value from the list. | |
2726 | (setq global (eval (cdr local)))) | |
16409b0b | 2727 | (set (make-local-variable (car local)) global)) |
eec82323 | 2728 | ;; Simple nil-valued local variable. |
16409b0b | 2729 | (set (make-local-variable local) nil))))) |
eec82323 LMI |
2730 | |
2731 | (defun gnus-summary-clear-local-variables () | |
2732 | (let ((locals gnus-summary-local-variables)) | |
2733 | (while locals | |
2734 | (if (consp (car locals)) | |
2735 | (and (vectorp (caar locals)) | |
2736 | (set (caar locals) nil)) | |
2737 | (and (vectorp (car locals)) | |
2738 | (set (car locals) nil))) | |
2739 | (setq locals (cdr locals))))) | |
2740 | ||
2741 | ;; Summary data functions. | |
2742 | ||
2743 | (defmacro gnus-data-number (data) | |
2744 | `(car ,data)) | |
2745 | ||
2746 | (defmacro gnus-data-set-number (data number) | |
2747 | `(setcar ,data ,number)) | |
2748 | ||
2749 | (defmacro gnus-data-mark (data) | |
2750 | `(nth 1 ,data)) | |
2751 | ||
2752 | (defmacro gnus-data-set-mark (data mark) | |
2753 | `(setcar (nthcdr 1 ,data) ,mark)) | |
2754 | ||
2755 | (defmacro gnus-data-pos (data) | |
2756 | `(nth 2 ,data)) | |
2757 | ||
2758 | (defmacro gnus-data-set-pos (data pos) | |
2759 | `(setcar (nthcdr 2 ,data) ,pos)) | |
2760 | ||
2761 | (defmacro gnus-data-header (data) | |
2762 | `(nth 3 ,data)) | |
2763 | ||
2764 | (defmacro gnus-data-set-header (data header) | |
2765 | `(setf (nth 3 ,data) ,header)) | |
2766 | ||
2767 | (defmacro gnus-data-level (data) | |
2768 | `(nth 4 ,data)) | |
2769 | ||
2770 | (defmacro gnus-data-unread-p (data) | |
2771 | `(= (nth 1 ,data) gnus-unread-mark)) | |
2772 | ||
2773 | (defmacro gnus-data-read-p (data) | |
2774 | `(/= (nth 1 ,data) gnus-unread-mark)) | |
2775 | ||
2776 | (defmacro gnus-data-pseudo-p (data) | |
2777 | `(consp (nth 3 ,data))) | |
2778 | ||
2779 | (defmacro gnus-data-find (number) | |
2780 | `(assq ,number gnus-newsgroup-data)) | |
2781 | ||
2782 | (defmacro gnus-data-find-list (number &optional data) | |
2783 | `(let ((bdata ,(or data 'gnus-newsgroup-data))) | |
2784 | (memq (assq ,number bdata) | |
2785 | bdata))) | |
2786 | ||
2787 | (defmacro gnus-data-make (number mark pos header level) | |
2788 | `(list ,number ,mark ,pos ,header ,level)) | |
2789 | ||
2790 | (defun gnus-data-enter (after-article number mark pos header level offset) | |
2791 | (let ((data (gnus-data-find-list after-article))) | |
2792 | (unless data | |
2793 | (error "No such article: %d" after-article)) | |
2794 | (setcdr data (cons (gnus-data-make number mark pos header level) | |
2795 | (cdr data))) | |
2796 | (setq gnus-newsgroup-data-reverse nil) | |
2797 | (gnus-data-update-list (cddr data) offset))) | |
2798 | ||
2799 | (defun gnus-data-enter-list (after-article list &optional offset) | |
2800 | (when list | |
2801 | (let ((data (and after-article (gnus-data-find-list after-article))) | |
2802 | (ilist list)) | |
6748645f LMI |
2803 | (if (not (or data |
2804 | after-article)) | |
2805 | (let ((odata gnus-newsgroup-data)) | |
2806 | (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data)) | |
eec82323 | 2807 | (when offset |
6748645f | 2808 | (gnus-data-update-list odata offset))) |
23f87bed | 2809 | ;; Find the last element in the list to be spliced into the main |
6748645f LMI |
2810 | ;; list. |
2811 | (while (cdr list) | |
2812 | (setq list (cdr list))) | |
2813 | (if (not data) | |
2814 | (progn | |
2815 | (setcdr list gnus-newsgroup-data) | |
2816 | (setq gnus-newsgroup-data ilist) | |
2817 | (when offset | |
2818 | (gnus-data-update-list (cdr list) offset))) | |
2819 | (setcdr list (cdr data)) | |
2820 | (setcdr data ilist) | |
2821 | (when offset | |
2822 | (gnus-data-update-list (cdr list) offset)))) | |
eec82323 LMI |
2823 | (setq gnus-newsgroup-data-reverse nil)))) |
2824 | ||
2825 | (defun gnus-data-remove (article &optional offset) | |
2826 | (let ((data gnus-newsgroup-data)) | |
2827 | (if (= (gnus-data-number (car data)) article) | |
2828 | (progn | |
2829 | (setq gnus-newsgroup-data (cdr gnus-newsgroup-data) | |
2830 | gnus-newsgroup-data-reverse nil) | |
2831 | (when offset | |
2832 | (gnus-data-update-list gnus-newsgroup-data offset))) | |
2833 | (while (cdr data) | |
2834 | (when (= (gnus-data-number (cadr data)) article) | |
2835 | (setcdr data (cddr data)) | |
2836 | (when offset | |
2837 | (gnus-data-update-list (cdr data) offset)) | |
2838 | (setq data nil | |
2839 | gnus-newsgroup-data-reverse nil)) | |
2840 | (setq data (cdr data)))))) | |
2841 | ||
2842 | (defmacro gnus-data-list (backward) | |
2843 | `(if ,backward | |
2844 | (or gnus-newsgroup-data-reverse | |
2845 | (setq gnus-newsgroup-data-reverse | |
2846 | (reverse gnus-newsgroup-data))) | |
2847 | gnus-newsgroup-data)) | |
2848 | ||
2849 | (defun gnus-data-update-list (data offset) | |
2850 | "Add OFFSET to the POS of all data entries in DATA." | |
6748645f | 2851 | (setq gnus-newsgroup-data-reverse nil) |
eec82323 LMI |
2852 | (while data |
2853 | (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data)))) | |
2854 | (setq data (cdr data)))) | |
2855 | ||
eec82323 LMI |
2856 | (defun gnus-summary-article-pseudo-p (article) |
2857 | "Say whether this article is a pseudo article or not." | |
2858 | (not (vectorp (gnus-data-header (gnus-data-find article))))) | |
2859 | ||
2860 | (defmacro gnus-summary-article-sparse-p (article) | |
2861 | "Say whether this article is a sparse article or not." | |
a8151ef7 | 2862 | `(memq ,article gnus-newsgroup-sparse)) |
eec82323 LMI |
2863 | |
2864 | (defmacro gnus-summary-article-ancient-p (article) | |
2865 | "Say whether this article is a sparse article or not." | |
2866 | `(memq ,article gnus-newsgroup-ancient)) | |
2867 | ||
2868 | (defun gnus-article-parent-p (number) | |
2869 | "Say whether this article is a parent or not." | |
2870 | (let ((data (gnus-data-find-list number))) | |
23f87bed | 2871 | (and (cdr data) ; There has to be an article after... |
eec82323 LMI |
2872 | (< (gnus-data-level (car data)) ; And it has to have a higher level. |
2873 | (gnus-data-level (nth 1 data)))))) | |
2874 | ||
2875 | (defun gnus-article-children (number) | |
2876 | "Return a list of all children to NUMBER." | |
2877 | (let* ((data (gnus-data-find-list number)) | |
2878 | (level (gnus-data-level (car data))) | |
2879 | children) | |
2880 | (setq data (cdr data)) | |
2881 | (while (and data | |
2882 | (= (gnus-data-level (car data)) (1+ level))) | |
2883 | (push (gnus-data-number (car data)) children) | |
2884 | (setq data (cdr data))) | |
2885 | children)) | |
2886 | ||
2887 | (defmacro gnus-summary-skip-intangible () | |
2888 | "If the current article is intangible, then jump to a different article." | |
2889 | '(let ((to (get-text-property (point) 'gnus-intangible))) | |
2890 | (and to (gnus-summary-goto-subject to)))) | |
2891 | ||
2892 | (defmacro gnus-summary-article-intangible-p () | |
2893 | "Say whether this article is intangible or not." | |
2894 | '(get-text-property (point) 'gnus-intangible)) | |
2895 | ||
2896 | (defun gnus-article-read-p (article) | |
2897 | "Say whether ARTICLE is read or not." | |
2898 | (not (or (memq article gnus-newsgroup-marked) | |
23f87bed | 2899 | (memq article gnus-newsgroup-spam-marked) |
eec82323 LMI |
2900 | (memq article gnus-newsgroup-unreads) |
2901 | (memq article gnus-newsgroup-unselected) | |
2902 | (memq article gnus-newsgroup-dormant)))) | |
2903 | ||
2904 | ;; Some summary mode macros. | |
2905 | ||
2906 | (defmacro gnus-summary-article-number () | |
2907 | "The article number of the article on the current line. | |
8f688cb0 | 2908 | If there isn't an article number here, then we return the current |
eec82323 LMI |
2909 | article number." |
2910 | '(progn | |
2911 | (gnus-summary-skip-intangible) | |
2912 | (or (get-text-property (point) 'gnus-number) | |
2913 | (gnus-summary-last-subject)))) | |
2914 | ||
2915 | (defmacro gnus-summary-article-header (&optional number) | |
6748645f | 2916 | "Return the header of article NUMBER." |
eec82323 LMI |
2917 | `(gnus-data-header (gnus-data-find |
2918 | ,(or number '(gnus-summary-article-number))))) | |
2919 | ||
2920 | (defmacro gnus-summary-thread-level (&optional number) | |
6748645f | 2921 | "Return the level of thread that starts with article NUMBER." |
eec82323 LMI |
2922 | `(if (and (eq gnus-summary-make-false-root 'dummy) |
2923 | (get-text-property (point) 'gnus-intangible)) | |
2924 | 0 | |
2925 | (gnus-data-level (gnus-data-find | |
2926 | ,(or number '(gnus-summary-article-number)))))) | |
2927 | ||
2928 | (defmacro gnus-summary-article-mark (&optional number) | |
6748645f | 2929 | "Return the mark of article NUMBER." |
eec82323 LMI |
2930 | `(gnus-data-mark (gnus-data-find |
2931 | ,(or number '(gnus-summary-article-number))))) | |
2932 | ||
2933 | (defmacro gnus-summary-article-pos (&optional number) | |
6748645f | 2934 | "Return the position of the line of article NUMBER." |
eec82323 LMI |
2935 | `(gnus-data-pos (gnus-data-find |
2936 | ,(or number '(gnus-summary-article-number))))) | |
2937 | ||
2938 | (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject) | |
2939 | (defmacro gnus-summary-article-subject (&optional number) | |
2940 | "Return current subject string or nil if nothing." | |
2941 | `(let ((headers | |
2942 | ,(if number | |
2943 | `(gnus-data-header (assq ,number gnus-newsgroup-data)) | |
2944 | '(gnus-data-header (assq (gnus-summary-article-number) | |
2945 | gnus-newsgroup-data))))) | |
2946 | (and headers | |
2947 | (vectorp headers) | |
2948 | (mail-header-subject headers)))) | |
2949 | ||
2950 | (defmacro gnus-summary-article-score (&optional number) | |
2951 | "Return current article score." | |
2952 | `(or (cdr (assq ,(or number '(gnus-summary-article-number)) | |
2953 | gnus-newsgroup-scored)) | |
2954 | gnus-summary-default-score 0)) | |
2955 | ||
2956 | (defun gnus-summary-article-children (&optional number) | |
6748645f | 2957 | "Return a list of article numbers that are children of article NUMBER." |
eec82323 LMI |
2958 | (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)))) |
2959 | (level (gnus-data-level (car data))) | |
2960 | l children) | |
2961 | (while (and (setq data (cdr data)) | |
2962 | (> (setq l (gnus-data-level (car data))) level)) | |
2963 | (and (= (1+ level) l) | |
2964 | (push (gnus-data-number (car data)) | |
2965 | children))) | |
2966 | (nreverse children))) | |
2967 | ||
2968 | (defun gnus-summary-article-parent (&optional number) | |
6748645f | 2969 | "Return the article number of the parent of article NUMBER." |
eec82323 LMI |
2970 | (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)) |
2971 | (gnus-data-list t))) | |
2972 | (level (gnus-data-level (car data)))) | |
2973 | (if (zerop level) | |
2974 | () ; This is a root. | |
2975 | ;; We search until we find an article with a level less than | |
2976 | ;; this one. That function has to be the parent. | |
2977 | (while (and (setq data (cdr data)) | |
2978 | (not (< (gnus-data-level (car data)) level)))) | |
2979 | (and data (gnus-data-number (car data)))))) | |
2980 | ||
2981 | (defun gnus-unread-mark-p (mark) | |
2982 | "Say whether MARK is the unread mark." | |
2983 | (= mark gnus-unread-mark)) | |
2984 | ||
2985 | (defun gnus-read-mark-p (mark) | |
2986 | "Say whether MARK is one of the marks that mark as read. | |
2987 | This is all marks except unread, ticked, dormant, and expirable." | |
2988 | (not (or (= mark gnus-unread-mark) | |
2989 | (= mark gnus-ticked-mark) | |
23f87bed | 2990 | (= mark gnus-spam-mark) |
eec82323 LMI |
2991 | (= mark gnus-dormant-mark) |
2992 | (= mark gnus-expirable-mark)))) | |
2993 | ||
2994 | (defmacro gnus-article-mark (number) | |
6748645f LMI |
2995 | "Return the MARK of article NUMBER. |
2996 | This macro should only be used when computing the mark the \"first\" | |
2997 | time; i.e., when generating the summary lines. After that, | |
2998 | `gnus-summary-article-mark' should be used to examine the | |
2999 | marks of articles." | |
eec82323 | 3000 | `(cond |
6748645f | 3001 | ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark) |
6748645f | 3002 | ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark) |
eec82323 LMI |
3003 | ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark) |
3004 | ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark) | |
23f87bed | 3005 | ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark) |
eec82323 LMI |
3006 | ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark) |
3007 | ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark) | |
3008 | (t (or (cdr (assq ,number gnus-newsgroup-reads)) | |
3009 | gnus-ancient-mark)))) | |
3010 | ||
3011 | ;; Saving hidden threads. | |
3012 | ||
eec82323 LMI |
3013 | (defmacro gnus-save-hidden-threads (&rest forms) |
3014 | "Save hidden threads, eval FORMS, and restore the hidden threads." | |
3015 | (let ((config (make-symbol "config"))) | |
3016 | `(let ((,config (gnus-hidden-threads-configuration))) | |
3017 | (unwind-protect | |
3018 | (save-excursion | |
3019 | ,@forms) | |
3020 | (gnus-restore-hidden-threads-configuration ,config))))) | |
23f87bed MB |
3021 | (put 'gnus-save-hidden-threads 'lisp-indent-function 0) |
3022 | (put 'gnus-save-hidden-threads 'edebug-form-spec '(body)) | |
eec82323 | 3023 | |
107ecebb AS |
3024 | (defun gnus-data-compute-positions () |
3025 | "Compute the positions of all articles." | |
3026 | (setq gnus-newsgroup-data-reverse nil) | |
3027 | (let ((data gnus-newsgroup-data)) | |
3028 | (save-excursion | |
3029 | (gnus-save-hidden-threads | |
3030 | (gnus-summary-show-all-threads) | |
3031 | (goto-char (point-min)) | |
3032 | (while data | |
3033 | (while (get-text-property (point) 'gnus-intangible) | |
3034 | (forward-line 1)) | |
3035 | (gnus-data-set-pos (car data) (+ (point) 3)) | |
3036 | (setq data (cdr data)) | |
3037 | (forward-line 1)))))) | |
3038 | ||
16409b0b GM |
3039 | (defun gnus-hidden-threads-configuration () |
3040 | "Return the current hidden threads configuration." | |
3041 | (save-excursion | |
3042 | (let (config) | |
3043 | (goto-char (point-min)) | |
3044 | (while (search-forward "\r" nil t) | |
3045 | (push (1- (point)) config)) | |
3046 | config))) | |
3047 | ||
3048 | (defun gnus-restore-hidden-threads-configuration (config) | |
3049 | "Restore hidden threads configuration from CONFIG." | |
3050 | (save-excursion | |
3051 | (let (point buffer-read-only) | |
3052 | (while (setq point (pop config)) | |
3053 | (when (and (< point (point-max)) | |
3054 | (goto-char point) | |
3055 | (eq (char-after) ?\n)) | |
3056 | (subst-char-in-region point (1+ point) ?\n ?\r)))))) | |
3057 | ||
eec82323 LMI |
3058 | ;; Various summary mode internalish functions. |
3059 | ||
3060 | (defun gnus-mouse-pick-article (e) | |
3061 | (interactive "e") | |
3062 | (mouse-set-point e) | |
3063 | (gnus-summary-next-page nil t)) | |
3064 | ||
3065 | (defun gnus-summary-set-display-table () | |
16409b0b GM |
3066 | "Change the display table. |
3067 | Odd characters have a tendency to mess | |
3068 | up nicely formatted displays - we make all possible glyphs | |
3069 | display only a single character." | |
eec82323 LMI |
3070 | |
3071 | ;; We start from the standard display table, if any. | |
3072 | (let ((table (or (copy-sequence standard-display-table) | |
3073 | (make-display-table))) | |
3074 | (i 32)) | |
3075 | ;; Nix out all the control chars... | |
3076 | (while (>= (setq i (1- i)) 0) | |
3077 | (aset table i [??])) | |
23f87bed | 3078 | ;; ... but not newline and cr, of course. (cr is necessary for the |
eec82323 LMI |
3079 | ;; selective display). |
3080 | (aset table ?\n nil) | |
3081 | (aset table ?\r nil) | |
6748645f LMI |
3082 | ;; We keep TAB as well. |
3083 | (aset table ?\t nil) | |
eec82323 LMI |
3084 | ;; We nix out any glyphs over 126 that are not set already. |
3085 | (let ((i 256)) | |
3086 | (while (>= (setq i (1- i)) 127) | |
3087 | ;; Only modify if the entry is nil. | |
3088 | (unless (aref table i) | |
3089 | (aset table i [??])))) | |
3090 | (setq buffer-display-table table))) | |
3091 | ||
23f87bed MB |
3092 | (defun gnus-summary-set-article-display-arrow (pos) |
3093 | "Update the overlay arrow to point to line at position POS." | |
3094 | (when (and gnus-summary-display-arrow | |
3095 | (boundp 'overlay-arrow-position) | |
3096 | (boundp 'overlay-arrow-string)) | |
3097 | (save-excursion | |
3098 | (goto-char pos) | |
3099 | (beginning-of-line) | |
3100 | (unless overlay-arrow-position | |
3101 | (setq overlay-arrow-position (make-marker))) | |
3102 | (setq overlay-arrow-string "=>" | |
3103 | overlay-arrow-position (set-marker overlay-arrow-position | |
3104 | (point) | |
3105 | (current-buffer)))))) | |
3106 | ||
eec82323 LMI |
3107 | (defun gnus-summary-setup-buffer (group) |
3108 | "Initialize summary buffer." | |
23f87bed MB |
3109 | (let ((buffer (gnus-summary-buffer-name group)) |
3110 | (dead-name (concat "*Dead Summary " | |
3111 | (gnus-group-decoded-name group) "*"))) | |
3112 | ;; If a dead summary buffer exists, we kill it. | |
3113 | (when (gnus-buffer-live-p dead-name) | |
3114 | (gnus-kill-buffer dead-name)) | |
eec82323 LMI |
3115 | (if (get-buffer buffer) |
3116 | (progn | |
3117 | (set-buffer buffer) | |
3118 | (setq gnus-summary-buffer (current-buffer)) | |
3119 | (not gnus-newsgroup-prepared)) | |
3120 | ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu> | |
6748645f | 3121 | (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer))) |
eec82323 LMI |
3122 | (gnus-summary-mode group) |
3123 | (when gnus-carpal | |
3124 | (gnus-carpal-setup-buffer 'summary)) | |
3125 | (unless gnus-single-article-buffer | |
3126 | (make-local-variable 'gnus-article-buffer) | |
3127 | (make-local-variable 'gnus-article-current) | |
3128 | (make-local-variable 'gnus-original-article-buffer)) | |
3129 | (setq gnus-newsgroup-name group) | |
23f87bed MB |
3130 | ;; Set any local variables in the group parameters. |
3131 | (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
eec82323 LMI |
3132 | t))) |
3133 | ||
3134 | (defun gnus-set-global-variables () | |
16409b0b GM |
3135 | "Set the global equivalents of the buffer-local variables. |
3136 | They are set to the latest values they had. These reflect the summary | |
3137 | buffer that was in action when the last article was fetched." | |
eec82323 LMI |
3138 | (when (eq major-mode 'gnus-summary-mode) |
3139 | (setq gnus-summary-buffer (current-buffer)) | |
3140 | (let ((name gnus-newsgroup-name) | |
3141 | (marked gnus-newsgroup-marked) | |
23f87bed | 3142 | (spam gnus-newsgroup-spam-marked) |
eec82323 LMI |
3143 | (unread gnus-newsgroup-unreads) |
3144 | (headers gnus-current-headers) | |
3145 | (data gnus-newsgroup-data) | |
3146 | (summary gnus-summary-buffer) | |
3147 | (article-buffer gnus-article-buffer) | |
3148 | (original gnus-original-article-buffer) | |
3149 | (gac gnus-article-current) | |
3150 | (reffed gnus-reffed-article-number) | |
16409b0b | 3151 | (score-file gnus-current-score-file) |
23f87bed MB |
3152 | (default-charset gnus-newsgroup-charset) |
3153 | vlist) | |
3154 | (let ((locals gnus-newsgroup-variables)) | |
3155 | (while locals | |
3156 | (if (consp (car locals)) | |
3157 | (push (eval (caar locals)) vlist) | |
3158 | (push (eval (car locals)) vlist)) | |
3159 | (setq locals (cdr locals))) | |
3160 | (setq vlist (nreverse vlist))) | |
eec82323 LMI |
3161 | (save-excursion |
3162 | (set-buffer gnus-group-buffer) | |
6748645f LMI |
3163 | (setq gnus-newsgroup-name name |
3164 | gnus-newsgroup-marked marked | |
23f87bed | 3165 | gnus-newsgroup-spam-marked spam |
6748645f LMI |
3166 | gnus-newsgroup-unreads unread |
3167 | gnus-current-headers headers | |
3168 | gnus-newsgroup-data data | |
3169 | gnus-article-current gac | |
3170 | gnus-summary-buffer summary | |
3171 | gnus-article-buffer article-buffer | |
3172 | gnus-original-article-buffer original | |
3173 | gnus-reffed-article-number reffed | |
16409b0b GM |
3174 | gnus-current-score-file score-file |
3175 | gnus-newsgroup-charset default-charset) | |
23f87bed MB |
3176 | (let ((locals gnus-newsgroup-variables)) |
3177 | (while locals | |
3178 | (if (consp (car locals)) | |
3179 | (set (caar locals) (pop vlist)) | |
3180 | (set (car locals) (pop vlist))) | |
3181 | (setq locals (cdr locals)))) | |
eec82323 LMI |
3182 | ;; The article buffer also has local variables. |
3183 | (when (gnus-buffer-live-p gnus-article-buffer) | |
3184 | (set-buffer gnus-article-buffer) | |
3185 | (setq gnus-summary-buffer summary)))))) | |
3186 | ||
3187 | (defun gnus-summary-article-unread-p (article) | |
3188 | "Say whether ARTICLE is unread or not." | |
3189 | (memq article gnus-newsgroup-unreads)) | |
3190 | ||
3191 | (defun gnus-summary-first-article-p (&optional article) | |
3192 | "Return whether ARTICLE is the first article in the buffer." | |
3193 | (if (not (setq article (or article (gnus-summary-article-number)))) | |
3194 | nil | |
3195 | (eq article (caar gnus-newsgroup-data)))) | |
3196 | ||
3197 | (defun gnus-summary-last-article-p (&optional article) | |
3198 | "Return whether ARTICLE is the last article in the buffer." | |
3199 | (if (not (setq article (or article (gnus-summary-article-number)))) | |
16409b0b GM |
3200 | ;; All non-existent numbers are the last article. :-) |
3201 | t | |
eec82323 LMI |
3202 | (not (cdr (gnus-data-find-list article))))) |
3203 | ||
3204 | (defun gnus-make-thread-indent-array () | |
3205 | (let ((n 200)) | |
3206 | (unless (and gnus-thread-indent-array | |
3207 | (= gnus-thread-indent-level gnus-thread-indent-array-level)) | |
3208 | (setq gnus-thread-indent-array (make-vector 201 "") | |
3209 | gnus-thread-indent-array-level gnus-thread-indent-level) | |
3210 | (while (>= n 0) | |
3211 | (aset gnus-thread-indent-array n | |
3212 | (make-string (* n gnus-thread-indent-level) ? )) | |
3213 | (setq n (1- n)))))) | |
3214 | ||
3215 | (defun gnus-update-summary-mark-positions () | |
3216 | "Compute where the summary marks are to go." | |
3217 | (save-excursion | |
6748645f | 3218 | (when (gnus-buffer-exists-p gnus-summary-buffer) |
eec82323 LMI |
3219 | (set-buffer gnus-summary-buffer)) |
3220 | (let ((gnus-replied-mark 129) | |
3221 | (gnus-score-below-mark 130) | |
3222 | (gnus-score-over-mark 130) | |
23f87bed | 3223 | (gnus-undownloaded-mark 131) |
eec82323 | 3224 | (spec gnus-summary-line-format-spec) |
6748645f | 3225 | gnus-visual pos) |
eec82323 LMI |
3226 | (save-excursion |
3227 | (gnus-set-work-buffer) | |
6748645f | 3228 | (let ((gnus-summary-line-format-spec spec) |
23f87bed | 3229 | (gnus-newsgroup-downloadable '(0))) |
eec82323 | 3230 | (gnus-summary-insert-line |
23f87bed MB |
3231 | [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil] |
3232 | 0 nil t 128 t nil "" nil 1) | |
eec82323 LMI |
3233 | (goto-char (point-min)) |
3234 | (setq pos (list (cons 'unread (and (search-forward "\200" nil t) | |
667e0ba6 | 3235 | (- (point) (point-min) 1))))) |
eec82323 LMI |
3236 | (goto-char (point-min)) |
3237 | (push (cons 'replied (and (search-forward "\201" nil t) | |
667e0ba6 | 3238 | (- (point) (point-min) 1))) |
eec82323 LMI |
3239 | pos) |
3240 | (goto-char (point-min)) | |
667e0ba6 SM |
3241 | (push (cons 'score (and (search-forward "\202" nil t) |
3242 | (- (point) (point-min) 1))) | |
6748645f LMI |
3243 | pos) |
3244 | (goto-char (point-min)) | |
3245 | (push (cons 'download | |
667e0ba6 SM |
3246 | (and (search-forward "\203" nil t) |
3247 | (- (point) (point-min) 1))) | |
eec82323 LMI |
3248 | pos))) |
3249 | (setq gnus-summary-mark-positions pos)))) | |
3250 | ||
3251 | (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number) | |
3252 | "Insert a dummy root in the summary buffer." | |
3253 | (beginning-of-line) | |
3254 | (gnus-add-text-properties | |
3255 | (point) (progn (eval gnus-summary-dummy-line-format-spec) (point)) | |
3256 | (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number))) | |
3257 | ||
23f87bed MB |
3258 | (defun gnus-summary-extract-address-component (from) |
3259 | (or (car (funcall gnus-extract-address-components from)) | |
3260 | from)) | |
3261 | ||
3262 | (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from) | |
3263 | (let ((mail-parse-charset gnus-newsgroup-charset) | |
3264 | ; Is it really necessary to do this next part for each summary line? | |
3265 | ; Luckily, doesn't seem to slow things down much. | |
16409b0b GM |
3266 | (mail-parse-ignored-charsets |
3267 | (save-excursion (set-buffer gnus-summary-buffer) | |
3268 | gnus-newsgroup-ignored-charsets))) | |
23f87bed MB |
3269 | (or |
3270 | (and gnus-ignored-from-addresses | |
3271 | (string-match gnus-ignored-from-addresses gnus-tmp-from) | |
3272 | (let ((extra-headers (mail-header-extra header)) | |
3273 | to | |
3274 | newsgroups) | |
3275 | (cond | |
3276 | ((setq to (cdr (assq 'To extra-headers))) | |
3277 | (concat "-> " | |
3278 | (inline | |
3279 | (gnus-summary-extract-address-component | |
3280 | (funcall gnus-decode-encoded-word-function to))))) | |
3281 | ((setq newsgroups (cdr (assq 'Newsgroups extra-headers))) | |
3282 | (concat "=> " newsgroups))))) | |
3283 | (inline (gnus-summary-extract-address-component gnus-tmp-from))))) | |
16409b0b | 3284 | |
eec82323 LMI |
3285 | (defun gnus-summary-insert-line (gnus-tmp-header |
3286 | gnus-tmp-level gnus-tmp-current | |
23f87bed | 3287 | undownloaded gnus-tmp-unread gnus-tmp-replied |
eec82323 LMI |
3288 | gnus-tmp-expirable gnus-tmp-subject-or-nil |
3289 | &optional gnus-tmp-dummy gnus-tmp-score | |
3290 | gnus-tmp-process) | |
3291 | (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) | |
3292 | (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) | |
3293 | (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) | |
3294 | (gnus-tmp-score-char | |
3295 | (if (or (null gnus-summary-default-score) | |
3296 | (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
3297 | gnus-summary-zcore-fuzz)) | |
23f87bed | 3298 | ? ;Whitespace |
eec82323 LMI |
3299 | (if (< gnus-tmp-score gnus-summary-default-score) |
3300 | gnus-score-below-mark gnus-score-over-mark))) | |
23f87bed | 3301 | (gnus-tmp-number (mail-header-number gnus-tmp-header)) |
eec82323 LMI |
3302 | (gnus-tmp-replied |
3303 | (cond (gnus-tmp-process gnus-process-mark) | |
3304 | ((memq gnus-tmp-current gnus-newsgroup-cached) | |
3305 | gnus-cached-mark) | |
3306 | (gnus-tmp-replied gnus-replied-mark) | |
23f87bed MB |
3307 | ((memq gnus-tmp-current gnus-newsgroup-forwarded) |
3308 | gnus-forwarded-mark) | |
eec82323 LMI |
3309 | ((memq gnus-tmp-current gnus-newsgroup-saved) |
3310 | gnus-saved-mark) | |
23f87bed MB |
3311 | ((memq gnus-tmp-number gnus-newsgroup-recent) |
3312 | gnus-recent-mark) | |
3313 | ((memq gnus-tmp-number gnus-newsgroup-unseen) | |
3314 | gnus-unseen-mark) | |
3315 | (t gnus-no-mark))) | |
3316 | (gnus-tmp-downloaded | |
3317 | (cond (undownloaded | |
3318 | gnus-undownloaded-mark) | |
3319 | (gnus-newsgroup-agentized | |
3320 | gnus-downloaded-mark) | |
3321 | (t | |
3322 | gnus-no-mark))) | |
eec82323 LMI |
3323 | (gnus-tmp-from (mail-header-from gnus-tmp-header)) |
3324 | (gnus-tmp-name | |
3325 | (cond | |
3326 | ((string-match "<[^>]+> *$" gnus-tmp-from) | |
3327 | (let ((beg (match-beginning 0))) | |
23f87bed MB |
3328 | (or (and (string-match "^\".+\"" gnus-tmp-from) |
3329 | (substring gnus-tmp-from 1 (1- (match-end 0)))) | |
eec82323 LMI |
3330 | (substring gnus-tmp-from 0 beg)))) |
3331 | ((string-match "(.+)" gnus-tmp-from) | |
3332 | (substring gnus-tmp-from | |
3333 | (1+ (match-beginning 0)) (1- (match-end 0)))) | |
3334 | (t gnus-tmp-from))) | |
3335 | (gnus-tmp-subject (mail-header-subject gnus-tmp-header)) | |
eec82323 LMI |
3336 | (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[)) |
3337 | (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\])) | |
3338 | (buffer-read-only nil)) | |
3339 | (when (string= gnus-tmp-name "") | |
3340 | (setq gnus-tmp-name gnus-tmp-from)) | |
3341 | (unless (numberp gnus-tmp-lines) | |
23f87bed MB |
3342 | (setq gnus-tmp-lines -1)) |
3343 | (if (= gnus-tmp-lines -1) | |
3344 | (setq gnus-tmp-lines "?") | |
3345 | (setq gnus-tmp-lines (number-to-string gnus-tmp-lines))) | |
3346 | (gnus-put-text-property | |
eec82323 LMI |
3347 | (point) |
3348 | (progn (eval gnus-summary-line-format-spec) (point)) | |
23f87bed | 3349 | 'gnus-number gnus-tmp-number) |
eec82323 LMI |
3350 | (when (gnus-visual-p 'summary-highlight 'highlight) |
3351 | (forward-line -1) | |
6748645f | 3352 | (gnus-run-hooks 'gnus-summary-update-hook) |
eec82323 LMI |
3353 | (forward-line 1)))) |
3354 | ||
3355 | (defun gnus-summary-update-line (&optional dont-update) | |
16409b0b | 3356 | "Update summary line after change." |
eec82323 LMI |
3357 | (when (and gnus-summary-default-score |
3358 | (not gnus-summary-inhibit-highlight)) | |
3359 | (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion. | |
3360 | (article (gnus-summary-article-number)) | |
3361 | (score (gnus-summary-article-score article))) | |
3362 | (unless dont-update | |
3363 | (if (and gnus-summary-mark-below | |
3364 | (< (gnus-summary-article-score) | |
3365 | gnus-summary-mark-below)) | |
3366 | ;; This article has a low score, so we mark it as read. | |
3367 | (when (memq article gnus-newsgroup-unreads) | |
3368 | (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
3369 | (when (eq (gnus-summary-article-mark) gnus-low-score-mark) | |
3370 | ;; This article was previously marked as read on account | |
3371 | ;; of a low score, but now it has risen, so we mark it as | |
3372 | ;; unread. | |
3373 | (gnus-summary-mark-article-as-unread gnus-unread-mark))) | |
3374 | (gnus-summary-update-mark | |
3375 | (if (or (null gnus-summary-default-score) | |
3376 | (<= (abs (- score gnus-summary-default-score)) | |
3377 | gnus-summary-zcore-fuzz)) | |
23f87bed | 3378 | ? ;Whitespace |
eec82323 LMI |
3379 | (if (< score gnus-summary-default-score) |
3380 | gnus-score-below-mark gnus-score-over-mark)) | |
3381 | 'score)) | |
3382 | ;; Do visual highlighting. | |
3383 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
6748645f | 3384 | (gnus-run-hooks 'gnus-summary-update-hook))))) |
eec82323 LMI |
3385 | |
3386 | (defvar gnus-tmp-new-adopts nil) | |
3387 | ||
3388 | (defun gnus-summary-number-of-articles-in-thread (thread &optional level char) | |
3389 | "Return the number of articles in THREAD. | |
3390 | This may be 0 in some cases -- if none of the articles in | |
3391 | the thread are to be displayed." | |
3392 | (let* ((number | |
23f87bed | 3393 | ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. |
eec82323 LMI |
3394 | (cond |
3395 | ((not (listp thread)) | |
3396 | 1) | |
3397 | ((and (consp thread) (cdr thread)) | |
3398 | (apply | |
3399 | '+ 1 (mapcar | |
3400 | 'gnus-summary-number-of-articles-in-thread (cdr thread)))) | |
3401 | ((null thread) | |
3402 | 1) | |
3403 | ((memq (mail-header-number (car thread)) gnus-newsgroup-limit) | |
3404 | 1) | |
3405 | (t 0)))) | |
3406 | (when (and level (zerop level) gnus-tmp-new-adopts) | |
3407 | (incf number | |
3408 | (apply '+ (mapcar | |
3409 | 'gnus-summary-number-of-articles-in-thread | |
3410 | gnus-tmp-new-adopts)))) | |
3411 | (if char | |
3412 | (if (> number 1) gnus-not-empty-thread-mark | |
3413 | gnus-empty-thread-mark) | |
3414 | number))) | |
3415 | ||
23f87bed MB |
3416 | (defsubst gnus-summary-line-message-size (head) |
3417 | "Return pretty-printed version of message size. | |
3418 | This function is intended to be used in | |
3419 | `gnus-summary-line-format-alist'." | |
3420 | (let ((c (or (mail-header-chars head) -1))) | |
3421 | (cond ((< c 0) "n/a") ; chars not available | |
3422 | ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0))) | |
3423 | ((< c (* 1000 100)) (format "%dk" (/ c 1024.0))) | |
3424 | ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024)))) | |
3425 | (t (format "%dM" (/ c (* 1024.0 1024))))))) | |
3426 | ||
3427 | ||
eec82323 LMI |
3428 | (defun gnus-summary-set-local-parameters (group) |
3429 | "Go through the local params of GROUP and set all variable specs in that list." | |
3430 | (let ((params (gnus-group-find-parameter group)) | |
23f87bed | 3431 | (vars '(quit-config)) ; Ignore quit-config. |
eec82323 LMI |
3432 | elem) |
3433 | (while params | |
3434 | (setq elem (car params) | |
3435 | params (cdr params)) | |
3436 | (and (consp elem) ; Has to be a cons. | |
3437 | (consp (cdr elem)) ; The cdr has to be a list. | |
3438 | (symbolp (car elem)) ; Has to be a symbol in there. | |
23f87bed | 3439 | (not (memq (car elem) vars)) |
eec82323 | 3440 | (ignore-errors ; So we set it. |
23f87bed | 3441 | (push (car elem) vars) |
eec82323 LMI |
3442 | (make-local-variable (car elem)) |
3443 | (set (car elem) (eval (nth 1 elem)))))))) | |
3444 | ||
3445 | (defun gnus-summary-read-group (group &optional show-all no-article | |
6748645f LMI |
3446 | kill-buffer no-display backward |
3447 | select-articles) | |
eec82323 LMI |
3448 | "Start reading news in newsgroup GROUP. |
3449 | If SHOW-ALL is non-nil, already read articles are also listed. | |
3450 | If NO-ARTICLE is non-nil, no article is selected initially. | |
3451 | If NO-DISPLAY, don't generate a summary buffer." | |
3452 | (let (result) | |
3453 | (while (and group | |
3454 | (null (setq result | |
3455 | (let ((gnus-auto-select-next nil)) | |
6748645f LMI |
3456 | (or (gnus-summary-read-group-1 |
3457 | group show-all no-article | |
3458 | kill-buffer no-display | |
3459 | select-articles) | |
3460 | (setq show-all nil | |
16409b0b | 3461 | select-articles nil))))) |
eec82323 LMI |
3462 | (eq gnus-auto-select-next 'quietly)) |
3463 | (set-buffer gnus-group-buffer) | |
6748645f LMI |
3464 | ;; The entry function called above goes to the next |
3465 | ;; group automatically, so we go two groups back | |
3466 | ;; if we are searching for the previous group. | |
3467 | (when backward | |
3468 | (gnus-group-prev-unread-group 2)) | |
eec82323 LMI |
3469 | (if (not (equal group (gnus-group-group-name))) |
3470 | (setq group (gnus-group-group-name)) | |
3471 | (setq group nil))) | |
3472 | result)) | |
3473 | ||
3474 | (defun gnus-summary-read-group-1 (group show-all no-article | |
6748645f LMI |
3475 | kill-buffer no-display |
3476 | &optional select-articles) | |
eec82323 | 3477 | ;; Killed foreign groups can't be entered. |
23f87bed MB |
3478 | ;; (when (and (not (gnus-group-native-p group)) |
3479 | ;; (not (gnus-gethash group gnus-newsrc-hashtb))) | |
3480 | ;; (error "Dead non-native groups can't be entered")) | |
3481 | (gnus-message 5 "Retrieving newsgroup: %s..." | |
3482 | (gnus-group-decoded-name group)) | |
eec82323 LMI |
3483 | (let* ((new-group (gnus-summary-setup-buffer group)) |
3484 | (quit-config (gnus-group-quit-config group)) | |
6748645f LMI |
3485 | (did-select (and new-group (gnus-select-newsgroup |
3486 | group show-all select-articles)))) | |
eec82323 LMI |
3487 | (cond |
3488 | ;; This summary buffer exists already, so we just select it. | |
3489 | ((not new-group) | |
3490 | (gnus-set-global-variables) | |
3491 | (when kill-buffer | |
3492 | (gnus-kill-or-deaden-summary kill-buffer)) | |
3493 | (gnus-configure-windows 'summary 'force) | |
3494 | (gnus-set-mode-line 'summary) | |
3495 | (gnus-summary-position-point) | |
3496 | (message "") | |
3497 | t) | |
3498 | ;; We couldn't select this group. | |
3499 | ((null did-select) | |
3500 | (when (and (eq major-mode 'gnus-summary-mode) | |
3501 | (not (equal (current-buffer) kill-buffer))) | |
3502 | (kill-buffer (current-buffer)) | |
3503 | (if (not quit-config) | |
3504 | (progn | |
6748645f LMI |
3505 | ;; Update the info -- marks might need to be removed, |
3506 | ;; for instance. | |
3507 | (gnus-summary-update-info) | |
eec82323 LMI |
3508 | (set-buffer gnus-group-buffer) |
3509 | (gnus-group-jump-to-group group) | |
3510 | (gnus-group-next-unread-group 1)) | |
3511 | (gnus-handle-ephemeral-exit quit-config))) | |
23f87bed MB |
3512 | (let ((grpinfo (gnus-get-info group))) |
3513 | (if (null (gnus-info-read grpinfo)) | |
3514 | (gnus-message 3 "Group %s contains no messages" | |
3515 | (gnus-group-decoded-name group)) | |
3516 | (gnus-message 3 "Can't select group"))) | |
eec82323 LMI |
3517 | nil) |
3518 | ;; The user did a `C-g' while prompting for number of articles, | |
3519 | ;; so we exit this group. | |
3520 | ((eq did-select 'quit) | |
3521 | (and (eq major-mode 'gnus-summary-mode) | |
3522 | (not (equal (current-buffer) kill-buffer)) | |
3523 | (kill-buffer (current-buffer))) | |
3524 | (when kill-buffer | |
3525 | (gnus-kill-or-deaden-summary kill-buffer)) | |
3526 | (if (not quit-config) | |
3527 | (progn | |
3528 | (set-buffer gnus-group-buffer) | |
3529 | (gnus-group-jump-to-group group) | |
3530 | (gnus-group-next-unread-group 1) | |
3531 | (gnus-configure-windows 'group 'force)) | |
3532 | (gnus-handle-ephemeral-exit quit-config)) | |
3533 | ;; Finally signal the quit. | |
3534 | (signal 'quit nil)) | |
3535 | ;; The group was successfully selected. | |
3536 | (t | |
3537 | (gnus-set-global-variables) | |
3538 | ;; Save the active value in effect when the group was entered. | |
3539 | (setq gnus-newsgroup-active | |
3540 | (gnus-copy-sequence | |
3541 | (gnus-active gnus-newsgroup-name))) | |
3542 | ;; You can change the summary buffer in some way with this hook. | |
6748645f | 3543 | (gnus-run-hooks 'gnus-select-group-hook) |
eec82323 LMI |
3544 | (gnus-update-format-specifications |
3545 | nil 'summary 'summary-mode 'summary-dummy) | |
16409b0b | 3546 | (gnus-update-summary-mark-positions) |
eec82323 LMI |
3547 | ;; Do score processing. |
3548 | (when gnus-use-scoring | |
3549 | (gnus-possibly-score-headers)) | |
3550 | ;; Check whether to fill in the gaps in the threads. | |
3551 | (when gnus-build-sparse-threads | |
3552 | (gnus-build-sparse-threads)) | |
3553 | ;; Find the initial limit. | |
3554 | (if gnus-show-threads | |
3555 | (if show-all | |
3556 | (let ((gnus-newsgroup-dormant nil)) | |
3557 | (gnus-summary-initial-limit show-all)) | |
3558 | (gnus-summary-initial-limit show-all)) | |
8f688cb0 | 3559 | ;; When unthreaded, all articles are always shown. |
eec82323 LMI |
3560 | (setq gnus-newsgroup-limit |
3561 | (mapcar | |
3562 | (lambda (header) (mail-header-number header)) | |
3563 | gnus-newsgroup-headers))) | |
3564 | ;; Generate the summary buffer. | |
3565 | (unless no-display | |
3566 | (gnus-summary-prepare)) | |
3567 | (when gnus-use-trees | |
3568 | (gnus-tree-open group) | |
3569 | (setq gnus-summary-highlight-line-function | |
3570 | 'gnus-tree-highlight-article)) | |
3571 | ;; If the summary buffer is empty, but there are some low-scored | |
3572 | ;; articles or some excluded dormants, we include these in the | |
3573 | ;; buffer. | |
3574 | (when (and (zerop (buffer-size)) | |
3575 | (not no-display)) | |
3576 | (cond (gnus-newsgroup-dormant | |
3577 | (gnus-summary-limit-include-dormant)) | |
3578 | ((and gnus-newsgroup-scored show-all) | |
3579 | (gnus-summary-limit-include-expunged t)))) | |
3580 | ;; Function `gnus-apply-kill-file' must be called in this hook. | |
6748645f | 3581 | (gnus-run-hooks 'gnus-apply-kill-hook) |
eec82323 LMI |
3582 | (if (and (zerop (buffer-size)) |
3583 | (not no-display)) | |
3584 | (progn | |
3585 | ;; This newsgroup is empty. | |
3586 | (gnus-summary-catchup-and-exit nil t) | |
3587 | (gnus-message 6 "No unread news") | |
3588 | (when kill-buffer | |
3589 | (gnus-kill-or-deaden-summary kill-buffer)) | |
3590 | ;; Return nil from this function. | |
3591 | nil) | |
3592 | ;; Hide conversation thread subtrees. We cannot do this in | |
3593 | ;; gnus-summary-prepare-hook since kill processing may not | |
3594 | ;; work with hidden articles. | |
23f87bed | 3595 | (gnus-summary-maybe-hide-threads) |
6748645f LMI |
3596 | (when kill-buffer |
3597 | (gnus-kill-or-deaden-summary kill-buffer)) | |
23f87bed | 3598 | (gnus-summary-auto-select-subject) |
eec82323 LMI |
3599 | ;; Show first unread article if requested. |
3600 | (if (and (not no-article) | |
3601 | (not no-display) | |
3602 | gnus-newsgroup-unreads | |
3603 | gnus-auto-select-first) | |
16409b0b GM |
3604 | (progn |
3605 | (gnus-configure-windows 'summary) | |
23f87bed MB |
3606 | (let ((art (gnus-summary-article-number))) |
3607 | (unless (and (not gnus-plugged) | |
3608 | (or (memq art gnus-newsgroup-undownloaded) | |
3609 | (memq art gnus-newsgroup-downloadable))) | |
3610 | (gnus-summary-goto-article art)))) | |
3611 | ;; Don't select any articles. | |
eec82323 | 3612 | (gnus-summary-position-point) |
6748645f LMI |
3613 | (gnus-configure-windows 'summary 'force) |
3614 | (gnus-set-mode-line 'summary)) | |
23f87bed MB |
3615 | (when (and gnus-auto-center-group |
3616 | (get-buffer-window gnus-group-buffer t)) | |
eec82323 LMI |
3617 | ;; Gotta use windows, because recenter does weird stuff if |
3618 | ;; the current buffer ain't the displayed window. | |
3619 | (let ((owin (selected-window))) | |
3620 | (select-window (get-buffer-window gnus-group-buffer t)) | |
3621 | (when (gnus-group-goto-group group) | |
3622 | (recenter)) | |
3623 | (select-window owin))) | |
3624 | ;; Mark this buffer as "prepared". | |
3625 | (setq gnus-newsgroup-prepared t) | |
6748645f | 3626 | (gnus-run-hooks 'gnus-summary-prepared-hook) |
23f87bed MB |
3627 | (unless (gnus-ephemeral-group-p group) |
3628 | (gnus-group-update-group group)) | |
eec82323 LMI |
3629 | t))))) |
3630 | ||
23f87bed MB |
3631 | (defun gnus-summary-auto-select-subject () |
3632 | "Select the subject line on initial group entry." | |
3633 | (goto-char (point-min)) | |
3634 | (cond | |
3635 | ((eq gnus-auto-select-subject 'best) | |
3636 | (gnus-summary-best-unread-subject)) | |
3637 | ((eq gnus-auto-select-subject 'unread) | |
3638 | (gnus-summary-first-unread-subject)) | |
3639 | ((eq gnus-auto-select-subject 'unseen) | |
3640 | (gnus-summary-first-unseen-subject)) | |
3641 | ((eq gnus-auto-select-subject 'unseen-or-unread) | |
3642 | (gnus-summary-first-unseen-or-unread-subject)) | |
3643 | ((eq gnus-auto-select-subject 'first) | |
3644 | ;; Do nothing. | |
3645 | ) | |
3646 | ((functionp gnus-auto-select-subject) | |
3647 | (funcall gnus-auto-select-subject)))) | |
3648 | ||
eec82323 LMI |
3649 | (defun gnus-summary-prepare () |
3650 | "Generate the summary buffer." | |
3651 | (interactive) | |
3652 | (let ((buffer-read-only nil)) | |
3653 | (erase-buffer) | |
3654 | (setq gnus-newsgroup-data nil | |
3655 | gnus-newsgroup-data-reverse nil) | |
6748645f | 3656 | (gnus-run-hooks 'gnus-summary-generate-hook) |
eec82323 LMI |
3657 | ;; Generate the buffer, either with threads or without. |
3658 | (when gnus-newsgroup-headers | |
3659 | (gnus-summary-prepare-threads | |
3660 | (if gnus-show-threads | |
3661 | (gnus-sort-gathered-threads | |
3662 | (funcall gnus-summary-thread-gathering-function | |
3663 | (gnus-sort-threads | |
3664 | (gnus-cut-threads (gnus-make-threads))))) | |
3665 | ;; Unthreaded display. | |
3666 | (gnus-sort-articles gnus-newsgroup-headers)))) | |
3667 | (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data)) | |
3668 | ;; Call hooks for modifying summary buffer. | |
3669 | (goto-char (point-min)) | |
6748645f | 3670 | (gnus-run-hooks 'gnus-summary-prepare-hook))) |
eec82323 LMI |
3671 | |
3672 | (defsubst gnus-general-simplify-subject (subject) | |
23f87bed | 3673 | "Simplify subject by the same rules as `gnus-gather-threads-by-subject'." |
eec82323 LMI |
3674 | (setq subject |
3675 | (cond | |
3676 | ;; Truncate the subject. | |
6748645f LMI |
3677 | (gnus-simplify-subject-functions |
3678 | (gnus-map-function gnus-simplify-subject-functions subject)) | |
eec82323 LMI |
3679 | ((numberp gnus-summary-gather-subject-limit) |
3680 | (setq subject (gnus-simplify-subject-re subject)) | |
3681 | (if (> (length subject) gnus-summary-gather-subject-limit) | |
3682 | (substring subject 0 gnus-summary-gather-subject-limit) | |
3683 | subject)) | |
3684 | ;; Fuzzily simplify it. | |
3685 | ((eq 'fuzzy gnus-summary-gather-subject-limit) | |
3686 | (gnus-simplify-subject-fuzzy subject)) | |
3687 | ;; Just remove the leading "Re:". | |
3688 | (t | |
3689 | (gnus-simplify-subject-re subject)))) | |
3690 | ||
3691 | (if (and gnus-summary-gather-exclude-subject | |
3692 | (string-match gnus-summary-gather-exclude-subject subject)) | |
23f87bed | 3693 | nil ; This article shouldn't be gathered |
eec82323 LMI |
3694 | subject)) |
3695 | ||
3696 | (defun gnus-summary-simplify-subject-query () | |
3697 | "Query where the respool algorithm would put this article." | |
3698 | (interactive) | |
eec82323 LMI |
3699 | (gnus-summary-select-article) |
3700 | (message (gnus-general-simplify-subject (gnus-summary-article-subject)))) | |
3701 | ||
3702 | (defun gnus-gather-threads-by-subject (threads) | |
3703 | "Gather threads by looking at Subject headers." | |
3704 | (if (not gnus-summary-make-false-root) | |
3705 | threads | |
3706 | (let ((hashtb (gnus-make-hashtable 1024)) | |
3707 | (prev threads) | |
3708 | (result threads) | |
3709 | subject hthread whole-subject) | |
3710 | (while threads | |
3711 | (setq subject (gnus-general-simplify-subject | |
3712 | (setq whole-subject (mail-header-subject | |
3713 | (caar threads))))) | |
3714 | (when subject | |
3715 | (if (setq hthread (gnus-gethash subject hashtb)) | |
3716 | (progn | |
3717 | ;; We enter a dummy root into the thread, if we | |
3718 | ;; haven't done that already. | |
3719 | (unless (stringp (caar hthread)) | |
3720 | (setcar hthread (list whole-subject (car hthread)))) | |
3721 | ;; We add this new gathered thread to this gathered | |
3722 | ;; thread. | |
3723 | (setcdr (car hthread) | |
3724 | (nconc (cdar hthread) (list (car threads)))) | |
3725 | ;; Remove it from the list of threads. | |
3726 | (setcdr prev (cdr threads)) | |
3727 | (setq threads prev)) | |
3728 | ;; Enter this thread into the hash table. | |
23f87bed MB |
3729 | (gnus-sethash subject |
3730 | (if gnus-summary-make-false-root-always | |
3731 | (progn | |
3732 | ;; If you want a dummy root above all | |
3733 | ;; threads... | |
3734 | (setcar threads (list whole-subject | |
3735 | (car threads))) | |
3736 | threads) | |
3737 | threads) | |
3738 | hashtb))) | |
eec82323 LMI |
3739 | (setq prev threads) |
3740 | (setq threads (cdr threads))) | |
3741 | result))) | |
3742 | ||
3743 | (defun gnus-gather-threads-by-references (threads) | |
3744 | "Gather threads by looking at References headers." | |
3745 | (let ((idhashtb (gnus-make-hashtable 1024)) | |
3746 | (thhashtb (gnus-make-hashtable 1024)) | |
3747 | (prev threads) | |
3748 | (result threads) | |
3749 | ids references id gthread gid entered ref) | |
3750 | (while threads | |
3751 | (when (setq references (mail-header-references (caar threads))) | |
3752 | (setq id (mail-header-id (caar threads)) | |
23f87bed | 3753 | ids (inline (gnus-split-references references)) |
eec82323 LMI |
3754 | entered nil) |
3755 | (while (setq ref (pop ids)) | |
3756 | (setq ids (delete ref ids)) | |
3757 | (if (not (setq gid (gnus-gethash ref idhashtb))) | |
3758 | (progn | |
3759 | (gnus-sethash ref id idhashtb) | |
3760 | (gnus-sethash id threads thhashtb)) | |
3761 | (setq gthread (gnus-gethash gid thhashtb)) | |
3762 | (unless entered | |
3763 | ;; We enter a dummy root into the thread, if we | |
3764 | ;; haven't done that already. | |
3765 | (unless (stringp (caar gthread)) | |
3766 | (setcar gthread (list (mail-header-subject (caar gthread)) | |
3767 | (car gthread)))) | |
3768 | ;; We add this new gathered thread to this gathered | |
3769 | ;; thread. | |
3770 | (setcdr (car gthread) | |
3771 | (nconc (cdar gthread) (list (car threads))))) | |
3772 | ;; Add it into the thread hash table. | |
3773 | (gnus-sethash id gthread thhashtb) | |
3774 | (setq entered t) | |
3775 | ;; Remove it from the list of threads. | |
3776 | (setcdr prev (cdr threads)) | |
3777 | (setq threads prev)))) | |
3778 | (setq prev threads) | |
3779 | (setq threads (cdr threads))) | |
3780 | result)) | |
3781 | ||
3782 | (defun gnus-sort-gathered-threads (threads) | |
16409b0b | 3783 | "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'." |
eec82323 LMI |
3784 | (let ((result threads)) |
3785 | (while threads | |
3786 | (when (stringp (caar threads)) | |
3787 | (setcdr (car threads) | |
16409b0b | 3788 | (sort (cdar threads) gnus-sort-gathered-threads-function))) |
eec82323 LMI |
3789 | (setq threads (cdr threads))) |
3790 | result)) | |
3791 | ||
3792 | (defun gnus-thread-loop-p (root thread) | |
3793 | "Say whether ROOT is in THREAD." | |
3794 | (let ((stack (list thread)) | |
3795 | (infloop 0) | |
3796 | th) | |
3797 | (while (setq thread (pop stack)) | |
3798 | (setq th (cdr thread)) | |
3799 | (while (and th | |
3800 | (not (eq (caar th) root))) | |
3801 | (pop th)) | |
3802 | (if th | |
3803 | ;; We have found a loop. | |
3804 | (let (ref-dep) | |
3805 | (setcdr thread (delq (car th) (cdr thread))) | |
3806 | (if (boundp (setq ref-dep (intern "none" | |
3807 | gnus-newsgroup-dependencies))) | |
3808 | (setcdr (symbol-value ref-dep) | |
3809 | (nconc (cdr (symbol-value ref-dep)) | |
3810 | (list (car th)))) | |
3811 | (set ref-dep (list nil (car th)))) | |
3812 | (setq infloop 1 | |
3813 | stack nil)) | |
3814 | ;; Push all the subthreads onto the stack. | |
3815 | (push (cdr thread) stack))) | |
3816 | infloop)) | |
3817 | ||
3818 | (defun gnus-make-threads () | |
3819 | "Go through the dependency hashtb and find the roots. Return all threads." | |
3820 | (let (threads) | |
3821 | (while (catch 'infloop | |
3822 | (mapatoms | |
3823 | (lambda (refs) | |
3824 | ;; Deal with self-referencing References loops. | |
3825 | (when (and (car (symbol-value refs)) | |
3826 | (not (zerop | |
3827 | (apply | |
3828 | '+ | |
3829 | (mapcar | |
3830 | (lambda (thread) | |
3831 | (gnus-thread-loop-p | |
3832 | (car (symbol-value refs)) thread)) | |
3833 | (cdr (symbol-value refs))))))) | |
3834 | (setq threads nil) | |
3835 | (throw 'infloop t)) | |
3836 | (unless (car (symbol-value refs)) | |
23f87bed MB |
3837 | ;; These threads do not refer back to any other |
3838 | ;; articles, so they're roots. | |
eec82323 LMI |
3839 | (setq threads (append (cdr (symbol-value refs)) threads)))) |
3840 | gnus-newsgroup-dependencies))) | |
3841 | threads)) | |
3842 | ||
6748645f | 3843 | ;; Build the thread tree. |
16409b0b | 3844 | (defsubst gnus-dependencies-add-header (header dependencies force-new) |
6748645f LMI |
3845 | "Enter HEADER into the DEPENDENCIES table if it is not already there. |
3846 | ||
3847 | If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even | |
3848 | if it was already present. | |
3849 | ||
3850 | If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs | |
3851 | will not be entered in the DEPENDENCIES table. Otherwise duplicate | |
23f87bed MB |
3852 | Message-IDs will be renamed to a unique Message-ID before being |
3853 | entered. | |
6748645f LMI |
3854 | |
3855 | Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise." | |
3856 | (let* ((id (mail-header-id header)) | |
3857 | (id-dep (and id (intern id dependencies))) | |
23f87bed | 3858 | parent-id ref ref-dep ref-header replaced) |
6748645f LMI |
3859 | ;; Enter this `header' in the `dependencies' table. |
3860 | (cond | |
3861 | ((not id-dep) | |
3862 | (setq header nil)) | |
3863 | ;; The first two cases do the normal part: enter a new `header' | |
3864 | ;; in the `dependencies' table. | |
3865 | ((not (boundp id-dep)) | |
3866 | (set id-dep (list header))) | |
3867 | ((null (car (symbol-value id-dep))) | |
3868 | (setcar (symbol-value id-dep) header)) | |
3869 | ||
3870 | ;; From here the `header' was already present in the | |
3871 | ;; `dependencies' table. | |
3872 | (force-new | |
3873 | ;; Overrides an existing entry; | |
3874 | ;; just set the header part of the entry. | |
23f87bed MB |
3875 | (setcar (symbol-value id-dep) header) |
3876 | (setq replaced t)) | |
6748645f LMI |
3877 | |
3878 | ;; Renames the existing `header' to a unique Message-ID. | |
3879 | ((not gnus-summary-ignore-duplicates) | |
3880 | ;; An article with this Message-ID has already been seen. | |
3881 | ;; We rename the Message-ID. | |
3882 | (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies)) | |
3883 | (list header)) | |
3884 | (mail-header-set-id header id)) | |
3885 | ||
3886 | ;; The last case ignores an existing entry, except it adds any | |
3887 | ;; additional Xrefs (in case the two articles came from different | |
3888 | ;; servers. | |
3889 | ;; Also sets `header' to `nil' meaning that the `dependencies' | |
3890 | ;; table was *not* modified. | |
3891 | (t | |
3892 | (mail-header-set-xref | |
3893 | (car (symbol-value id-dep)) | |
3894 | (concat (or (mail-header-xref (car (symbol-value id-dep))) | |
3895 | "") | |
3896 | (or (mail-header-xref header) ""))) | |
3897 | (setq header nil))) | |
3898 | ||
23f87bed MB |
3899 | (when (and header (not replaced)) |
3900 | ;; First check that we are not creating a References loop. | |
3901 | (setq parent-id (gnus-parent-id (mail-header-references header))) | |
3902 | (setq ref parent-id) | |
6748645f LMI |
3903 | (while (and ref |
3904 | (setq ref-dep (intern-soft ref dependencies)) | |
3905 | (boundp ref-dep) | |
3906 | (setq ref-header (car (symbol-value ref-dep)))) | |
3907 | (if (string= id ref) | |
3908 | ;; Yuk! This is a reference loop. Make the article be a | |
3909 | ;; root article. | |
3910 | (progn | |
3911 | (mail-header-set-references (car (symbol-value id-dep)) "none") | |
23f87bed MB |
3912 | (setq ref nil) |
3913 | (setq parent-id nil)) | |
6748645f | 3914 | (setq ref (gnus-parent-id (mail-header-references ref-header))))) |
23f87bed | 3915 | (setq ref-dep (intern (or parent-id "none") dependencies)) |
6748645f LMI |
3916 | (if (boundp ref-dep) |
3917 | (setcdr (symbol-value ref-dep) | |
3918 | (nconc (cdr (symbol-value ref-dep)) | |
3919 | (list (symbol-value id-dep)))) | |
3920 | (set ref-dep (list nil (symbol-value id-dep))))) | |
3921 | header)) | |
3922 | ||
23f87bed MB |
3923 | (defun gnus-extract-message-id-from-in-reply-to (string) |
3924 | (if (string-match "<[^>]+>" string) | |
3925 | (substring string (match-beginning 0) (match-end 0)) | |
3926 | nil)) | |
3927 | ||
eec82323 LMI |
3928 | (defun gnus-build-sparse-threads () |
3929 | (let ((headers gnus-newsgroup-headers) | |
16409b0b | 3930 | (mail-parse-charset gnus-newsgroup-charset) |
6748645f | 3931 | (gnus-summary-ignore-duplicates t) |
eec82323 | 3932 | header references generation relations |
6748645f | 3933 | subject child end new-child date) |
eec82323 LMI |
3934 | ;; First we create an alist of generations/relations, where |
3935 | ;; generations is how much we trust the relation, and the relation | |
3936 | ;; is parent/child. | |
3937 | (gnus-message 7 "Making sparse threads...") | |
3938 | (save-excursion | |
3939 | (nnheader-set-temp-buffer " *gnus sparse threads*") | |
3940 | (while (setq header (pop headers)) | |
3941 | (when (and (setq references (mail-header-references header)) | |
3942 | (not (string= references ""))) | |
3943 | (insert references) | |
3944 | (setq child (mail-header-id header) | |
6748645f LMI |
3945 | subject (mail-header-subject header) |
3946 | date (mail-header-date header) | |
3947 | generation 0) | |
eec82323 LMI |
3948 | (while (search-backward ">" nil t) |
3949 | (setq end (1+ (point))) | |
3950 | (when (search-backward "<" nil t) | |
6748645f | 3951 | (setq new-child (buffer-substring (point) end)) |
eec82323 | 3952 | (push (list (incf generation) |
6748645f LMI |
3953 | child (setq child new-child) |
3954 | subject date) | |
eec82323 | 3955 | relations))) |
6748645f LMI |
3956 | (when child |
3957 | (push (list (1+ generation) child nil subject) relations)) | |
eec82323 LMI |
3958 | (erase-buffer))) |
3959 | (kill-buffer (current-buffer))) | |
3960 | ;; Sort over trustworthiness. | |
6748645f LMI |
3961 | (mapcar |
3962 | (lambda (relation) | |
3963 | (when (gnus-dependencies-add-header | |
3964 | (make-full-mail-header | |
3965 | gnus-reffed-article-number | |
3966 | (nth 3 relation) "" (or (nth 4 relation) "") | |
3967 | (nth 1 relation) | |
3968 | (or (nth 2 relation) "") 0 0 "") | |
3969 | gnus-newsgroup-dependencies nil) | |
3970 | (push gnus-reffed-article-number gnus-newsgroup-limit) | |
3971 | (push gnus-reffed-article-number gnus-newsgroup-sparse) | |
3972 | (push (cons gnus-reffed-article-number gnus-sparse-mark) | |
3973 | gnus-newsgroup-reads) | |
3974 | (decf gnus-reffed-article-number))) | |
3975 | (sort relations 'car-less-than-car)) | |
eec82323 LMI |
3976 | (gnus-message 7 "Making sparse threads...done"))) |
3977 | ||
3978 | (defun gnus-build-old-threads () | |
3979 | ;; Look at all the articles that refer back to old articles, and | |
3980 | ;; fetch the headers for the articles that aren't there. This will | |
3981 | ;; build complete threads - if the roots haven't been expired by the | |
3982 | ;; server, that is. | |
16409b0b GM |
3983 | (let ((mail-parse-charset gnus-newsgroup-charset) |
3984 | id heads) | |
eec82323 LMI |
3985 | (mapatoms |
3986 | (lambda (refs) | |
3987 | (when (not (car (symbol-value refs))) | |
3988 | (setq heads (cdr (symbol-value refs))) | |
3989 | (while heads | |
3990 | (if (memq (mail-header-number (caar heads)) | |
3991 | gnus-newsgroup-dormant) | |
3992 | (setq heads (cdr heads)) | |
3993 | (setq id (symbol-name refs)) | |
3994 | (while (and (setq id (gnus-build-get-header id)) | |
6748645f | 3995 | (not (car (gnus-id-to-thread id))))) |
eec82323 LMI |
3996 | (setq heads nil))))) |
3997 | gnus-newsgroup-dependencies))) | |
3998 | ||
23f87bed MB |
3999 | (defsubst gnus-remove-odd-characters (string) |
4000 | "Translate STRING into something that doesn't contain weird characters." | |
4001 | (mm-subst-char-in-string | |
4002 | ?\r ?\- | |
4003 | (mm-subst-char-in-string | |
4004 | ?\n ?\- string))) | |
4005 | ||
6748645f LMI |
4006 | ;; This function has to be called with point after the article number |
4007 | ;; on the beginning of the line. | |
4008 | (defsubst gnus-nov-parse-line (number dependencies &optional force-new) | |
4009 | (let ((eol (gnus-point-at-eol)) | |
4010 | (buffer (current-buffer)) | |
23f87bed | 4011 | header references in-reply-to) |
6748645f LMI |
4012 | |
4013 | ;; overview: [num subject from date id refs chars lines misc] | |
4014 | (unwind-protect | |
23f87bed | 4015 | (let (x) |
6748645f LMI |
4016 | (narrow-to-region (point) eol) |
4017 | (unless (eobp) | |
4018 | (forward-char)) | |
4019 | ||
4020 | (setq header | |
4021 | (make-full-mail-header | |
4022 | number ; number | |
23f87bed MB |
4023 | (condition-case () ; subject |
4024 | (gnus-remove-odd-characters | |
4025 | (funcall gnus-decode-encoded-word-function | |
4026 | (setq x (nnheader-nov-field)))) | |
4027 | (error x)) | |
4028 | (condition-case () ; from | |
4029 | (gnus-remove-odd-characters | |
4030 | (funcall gnus-decode-encoded-word-function | |
4031 | (setq x (nnheader-nov-field)))) | |
4032 | (error x)) | |
16409b0b GM |
4033 | (nnheader-nov-field) ; date |
4034 | (nnheader-nov-read-message-id) ; id | |
23f87bed | 4035 | (setq references (nnheader-nov-field)) ; refs |
16409b0b GM |
4036 | (nnheader-nov-read-integer) ; chars |
4037 | (nnheader-nov-read-integer) ; lines | |
4038 | (unless (eobp) | |
8b93df01 DL |
4039 | (if (looking-at "Xref: ") |
4040 | (goto-char (match-end 0))) | |
4041 | (nnheader-nov-field)) ; Xref | |
16409b0b | 4042 | (nnheader-nov-parse-extra)))) ; extra |
6748645f LMI |
4043 | |
4044 | (widen)) | |
4045 | ||
23f87bed MB |
4046 | (when (and (string= references "") |
4047 | (setq in-reply-to (mail-header-extra header)) | |
4048 | (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to)))) | |
4049 | (mail-header-set-references | |
4050 | header (gnus-extract-message-id-from-in-reply-to in-reply-to))) | |
4051 | ||
6748645f LMI |
4052 | (when gnus-alter-header-function |
4053 | (funcall gnus-alter-header-function header)) | |
4054 | (gnus-dependencies-add-header header dependencies force-new))) | |
4055 | ||
eec82323 | 4056 | (defun gnus-build-get-header (id) |
16409b0b GM |
4057 | "Look through the buffer of NOV lines and find the header to ID. |
4058 | Enter this line into the dependencies hash table, and return | |
4059 | the id of the parent article (if any)." | |
eec82323 LMI |
4060 | (let ((deps gnus-newsgroup-dependencies) |
4061 | found header) | |
4062 | (prog1 | |
4063 | (save-excursion | |
4064 | (set-buffer nntp-server-buffer) | |
4065 | (let ((case-fold-search nil)) | |
4066 | (goto-char (point-min)) | |
4067 | (while (and (not found) | |
4068 | (search-forward id nil t)) | |
4069 | (beginning-of-line) | |
4070 | (setq found (looking-at | |
4071 | (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s" | |
4072 | (regexp-quote id)))) | |
4073 | (or found (beginning-of-line 2))) | |
4074 | (when found | |
4075 | (beginning-of-line) | |
4076 | (and | |
4077 | (setq header (gnus-nov-parse-line | |
4078 | (read (current-buffer)) deps)) | |
4079 | (gnus-parent-id (mail-header-references header)))))) | |
4080 | (when header | |
4081 | (let ((number (mail-header-number header))) | |
4082 | (push number gnus-newsgroup-limit) | |
4083 | (push header gnus-newsgroup-headers) | |
4084 | (if (memq number gnus-newsgroup-unselected) | |
4085 | (progn | |
23f87bed MB |
4086 | (setq gnus-newsgroup-unreads |
4087 | (gnus-add-to-sorted-list gnus-newsgroup-unreads | |
4088 | number)) | |
eec82323 LMI |
4089 | (setq gnus-newsgroup-unselected |
4090 | (delq number gnus-newsgroup-unselected))) | |
4091 | (push number gnus-newsgroup-ancient))))))) | |
4092 | ||
6748645f LMI |
4093 | (defun gnus-build-all-threads () |
4094 | "Read all the headers." | |
4095 | (let ((gnus-summary-ignore-duplicates t) | |
16409b0b | 4096 | (mail-parse-charset gnus-newsgroup-charset) |
6748645f LMI |
4097 | (dependencies gnus-newsgroup-dependencies) |
4098 | header article) | |
4099 | (save-excursion | |
4100 | (set-buffer nntp-server-buffer) | |
4101 | (let ((case-fold-search nil)) | |
4102 | (goto-char (point-min)) | |
4103 | (while (not (eobp)) | |
4104 | (ignore-errors | |
4105 | (setq article (read (current-buffer)) | |
16409b0b | 4106 | header (gnus-nov-parse-line article dependencies))) |
6748645f LMI |
4107 | (when header |
4108 | (save-excursion | |
4109 | (set-buffer gnus-summary-buffer) | |
4110 | (push header gnus-newsgroup-headers) | |
4111 | (if (memq (setq article (mail-header-number header)) | |
4112 | gnus-newsgroup-unselected) | |
4113 | (progn | |
23f87bed MB |
4114 | (setq gnus-newsgroup-unreads |
4115 | (gnus-add-to-sorted-list | |
4116 | gnus-newsgroup-unreads article)) | |
6748645f LMI |
4117 | (setq gnus-newsgroup-unselected |
4118 | (delq article gnus-newsgroup-unselected))) | |
4119 | (push article gnus-newsgroup-ancient))) | |
4120 | (forward-line 1))))))) | |
4121 | ||
eec82323 | 4122 | (defun gnus-summary-update-article-line (article header) |
23f87bed | 4123 | "Update the line for ARTICLE using HEADER." |
eec82323 LMI |
4124 | (let* ((id (mail-header-id header)) |
4125 | (thread (gnus-id-to-thread id))) | |
4126 | (unless thread | |
4127 | (error "Article in no thread")) | |
4128 | ;; Update the thread. | |
4129 | (setcar thread header) | |
4130 | (gnus-summary-goto-subject article) | |
4131 | (let* ((datal (gnus-data-find-list article)) | |
4132 | (data (car datal)) | |
eec82323 LMI |
4133 | (buffer-read-only nil) |
4134 | (level (gnus-summary-thread-level))) | |
4135 | (gnus-delete-line) | |
23f87bed MB |
4136 | (let ((inserted (- (point) |
4137 | (progn | |
4138 | (gnus-summary-insert-line | |
4139 | header level nil | |
4140 | (memq article gnus-newsgroup-undownloaded) | |
4141 | (gnus-article-mark article) | |
4142 | (memq article gnus-newsgroup-replied) | |
4143 | (memq article gnus-newsgroup-expirable) | |
4144 | ;; Only insert the Subject string when it's different | |
4145 | ;; from the previous Subject string. | |
4146 | (if (and | |
4147 | gnus-show-threads | |
4148 | (gnus-subject-equal | |
4149 | (condition-case () | |
4150 | (mail-header-subject | |
4151 | (gnus-data-header | |
4152 | (cadr | |
4153 | (gnus-data-find-list | |
4154 | article | |
4155 | (gnus-data-list t))))) | |
4156 | ;; Error on the side of excessive subjects. | |
4157 | (error "")) | |
4158 | (mail-header-subject header))) | |
4159 | "" | |
4160 | (mail-header-subject header)) | |
4161 | nil (cdr (assq article gnus-newsgroup-scored)) | |
4162 | (memq article gnus-newsgroup-processable)) | |
4163 | (point))))) | |
4164 | (when (cdr datal) | |
4165 | (gnus-data-update-list | |
4166 | (cdr datal) | |
4167 | (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted))))))) | |
eec82323 LMI |
4168 | |
4169 | (defun gnus-summary-update-article (article &optional iheader) | |
4170 | "Update ARTICLE in the summary buffer." | |
4171 | (set-buffer gnus-summary-buffer) | |
6748645f | 4172 | (let* ((header (gnus-summary-article-header article)) |
eec82323 LMI |
4173 | (id (mail-header-id header)) |
4174 | (data (gnus-data-find article)) | |
4175 | (thread (gnus-id-to-thread id)) | |
4176 | (references (mail-header-references header)) | |
4177 | (parent | |
4178 | (gnus-id-to-thread | |
4179 | (or (gnus-parent-id | |
4180 | (when (and references | |
4181 | (not (equal "" references))) | |
4182 | references)) | |
4183 | "none"))) | |
4184 | (buffer-read-only nil) | |
6748645f | 4185 | (old (car thread))) |
eec82323 | 4186 | (when thread |
eec82323 | 4187 | (unless iheader |
6748645f LMI |
4188 | (setcar thread nil) |
4189 | (when parent | |
4190 | (delq thread parent))) | |
4191 | (if (gnus-summary-insert-subject id header) | |
eec82323 LMI |
4192 | ;; Set the (possibly) new article number in the data structure. |
4193 | (gnus-data-set-number data (gnus-id-to-article id)) | |
4194 | (setcar thread old) | |
4195 | nil)))) | |
4196 | ||
6748645f LMI |
4197 | (defun gnus-rebuild-thread (id &optional line) |
4198 | "Rebuild the thread containing ID. | |
4199 | If LINE, insert the rebuilt thread starting on line LINE." | |
eec82323 LMI |
4200 | (let ((buffer-read-only nil) |
4201 | old-pos current thread data) | |
4202 | (if (not gnus-show-threads) | |
4203 | (setq thread (list (car (gnus-id-to-thread id)))) | |
4204 | ;; Get the thread this article is part of. | |
4205 | (setq thread (gnus-remove-thread id))) | |
4206 | (setq old-pos (gnus-point-at-bol)) | |
4207 | (setq current (save-excursion | |
94384150 | 4208 | (and (re-search-backward "[\r\n]" nil t) |
eec82323 LMI |
4209 | (gnus-summary-article-number)))) |
4210 | ;; If this is a gathered thread, we have to go some re-gathering. | |
4211 | (when (stringp (car thread)) | |
4212 | (let ((subject (car thread)) | |
4213 | roots thr) | |
4214 | (setq thread (cdr thread)) | |
4215 | (while thread | |
4216 | (unless (memq (setq thr (gnus-id-to-thread | |
4217 | (gnus-root-id | |
4218 | (mail-header-id (caar thread))))) | |
4219 | roots) | |
4220 | (push thr roots)) | |
4221 | (setq thread (cdr thread))) | |
4222 | ;; We now have all (unique) roots. | |
4223 | (if (= (length roots) 1) | |
4224 | ;; All the loose roots are now one solid root. | |
4225 | (setq thread (car roots)) | |
4226 | (setq thread (cons subject (gnus-sort-threads roots)))))) | |
4227 | (let (threads) | |
4228 | ;; We then insert this thread into the summary buffer. | |
6748645f LMI |
4229 | (when line |
4230 | (goto-char (point-min)) | |
4231 | (forward-line (1- line))) | |
eec82323 LMI |
4232 | (let (gnus-newsgroup-data gnus-newsgroup-threads) |
4233 | (if gnus-show-threads | |
4234 | (gnus-summary-prepare-threads (gnus-cut-threads (list thread))) | |
4235 | (gnus-summary-prepare-unthreaded thread)) | |
4236 | (setq data (nreverse gnus-newsgroup-data)) | |
4237 | (setq threads gnus-newsgroup-threads)) | |
4238 | ;; We splice the new data into the data structure. | |
6748645f LMI |
4239 | ;;!!! This is kinda bogus. We assume that in LINE is non-nil, |
4240 | ;;!!! then we want to insert at the beginning of the buffer. | |
4241 | ;;!!! That happens to be true with Gnus now, but that may | |
4242 | ;;!!! change in the future. Perhaps. | |
4243 | (gnus-data-enter-list | |
4244 | (if line nil current) data (- (point) old-pos)) | |
4245 | (setq gnus-newsgroup-threads | |
4246 | (nconc threads gnus-newsgroup-threads)) | |
4247 | (gnus-data-compute-positions)))) | |
eec82323 LMI |
4248 | |
4249 | (defun gnus-number-to-header (number) | |
4250 | "Return the header for article NUMBER." | |
4251 | (let ((headers gnus-newsgroup-headers)) | |
4252 | (while (and headers | |
4253 | (not (= number (mail-header-number (car headers))))) | |
4254 | (pop headers)) | |
4255 | (when headers | |
4256 | (car headers)))) | |
4257 | ||
6748645f | 4258 | (defun gnus-parent-headers (in-headers &optional generation) |
eec82323 LMI |
4259 | "Return the headers of the GENERATIONeth parent of HEADERS." |
4260 | (unless generation | |
4261 | (setq generation 1)) | |
a8151ef7 | 4262 | (let ((parent t) |
6748645f | 4263 | (headers in-headers) |
a8151ef7 | 4264 | references) |
6748645f LMI |
4265 | (while (and parent |
4266 | (not (zerop generation)) | |
4267 | (setq references (mail-header-references headers))) | |
4268 | (setq headers (if (and references | |
4269 | (setq parent (gnus-parent-id references))) | |
4270 | (car (gnus-id-to-thread parent)) | |
4271 | nil)) | |
4272 | (decf generation)) | |
4273 | (and (not (eq headers in-headers)) | |
4274 | headers))) | |
eec82323 LMI |
4275 | |
4276 | (defun gnus-id-to-thread (id) | |
4277 | "Return the (sub-)thread where ID appears." | |
4278 | (gnus-gethash id gnus-newsgroup-dependencies)) | |
4279 | ||
4280 | (defun gnus-id-to-article (id) | |
4281 | "Return the article number of ID." | |
4282 | (let ((thread (gnus-id-to-thread id))) | |
4283 | (when (and thread | |
4284 | (car thread)) | |
4285 | (mail-header-number (car thread))))) | |
4286 | ||
4287 | (defun gnus-id-to-header (id) | |
4288 | "Return the article headers of ID." | |
4289 | (car (gnus-id-to-thread id))) | |
4290 | ||
4291 | (defun gnus-article-displayed-root-p (article) | |
4292 | "Say whether ARTICLE is a root(ish) article." | |
4293 | (let ((level (gnus-summary-thread-level article)) | |
4294 | (refs (mail-header-references (gnus-summary-article-header article))) | |
4295 | particle) | |
4296 | (cond | |
4297 | ((null level) nil) | |
4298 | ((zerop level) t) | |
4299 | ((null refs) t) | |
4300 | ((null (gnus-parent-id refs)) t) | |
4301 | ((and (= 1 level) | |
4302 | (null (setq particle (gnus-id-to-article | |
4303 | (gnus-parent-id refs)))) | |
4304 | (null (gnus-summary-thread-level particle))))))) | |
4305 | ||
4306 | (defun gnus-root-id (id) | |
4307 | "Return the id of the root of the thread where ID appears." | |
4308 | (let (last-id prev) | |
6748645f | 4309 | (while (and id (setq prev (car (gnus-id-to-thread id)))) |
eec82323 LMI |
4310 | (setq last-id id |
4311 | id (gnus-parent-id (mail-header-references prev)))) | |
4312 | last-id)) | |
4313 | ||
6748645f LMI |
4314 | (defun gnus-articles-in-thread (thread) |
4315 | "Return the list of articles in THREAD." | |
4316 | (cons (mail-header-number (car thread)) | |
4317 | (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread))))) | |
4318 | ||
eec82323 LMI |
4319 | (defun gnus-remove-thread (id &optional dont-remove) |
4320 | "Remove the thread that has ID in it." | |
6748645f | 4321 | (let (headers thread last-id) |
eec82323 | 4322 | ;; First go up in this thread until we find the root. |
6748645f LMI |
4323 | (setq last-id (gnus-root-id id) |
4324 | headers (message-flatten-list (gnus-id-to-thread last-id))) | |
eec82323 LMI |
4325 | ;; We have now found the real root of this thread. It might have |
4326 | ;; been gathered into some loose thread, so we have to search | |
4327 | ;; through the threads to find the thread we wanted. | |
4328 | (let ((threads gnus-newsgroup-threads) | |
4329 | sub) | |
4330 | (while threads | |
4331 | (setq sub (car threads)) | |
4332 | (if (stringp (car sub)) | |
4333 | ;; This is a gathered thread, so we look at the roots | |
4334 | ;; below it to find whether this article is in this | |
4335 | ;; gathered root. | |
4336 | (progn | |
4337 | (setq sub (cdr sub)) | |
4338 | (while sub | |
4339 | (when (member (caar sub) headers) | |
4340 | (setq thread (car threads) | |
4341 | threads nil | |
4342 | sub nil)) | |
4343 | (setq sub (cdr sub)))) | |
4344 | ;; It's an ordinary thread, so we check it. | |
4345 | (when (eq (car sub) (car headers)) | |
4346 | (setq thread sub | |
4347 | threads nil))) | |
4348 | (setq threads (cdr threads))) | |
4349 | ;; If this article is in no thread, then it's a root. | |
4350 | (if thread | |
4351 | (unless dont-remove | |
4352 | (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads))) | |
6748645f | 4353 | (setq thread (gnus-id-to-thread last-id))) |
eec82323 LMI |
4354 | (when thread |
4355 | (prog1 | |
4356 | thread ; We return this thread. | |
4357 | (unless dont-remove | |
4358 | (if (stringp (car thread)) | |
4359 | (progn | |
4360 | ;; If we use dummy roots, then we have to remove the | |
4361 | ;; dummy root as well. | |
4362 | (when (eq gnus-summary-make-false-root 'dummy) | |
6748645f LMI |
4363 | ;; We go to the dummy root by going to |
4364 | ;; the first sub-"thread", and then one line up. | |
4365 | (gnus-summary-goto-article | |
4366 | (mail-header-number (caadr thread))) | |
4367 | (forward-line -1) | |
eec82323 LMI |
4368 | (gnus-delete-line) |
4369 | (gnus-data-compute-positions)) | |
4370 | (setq thread (cdr thread)) | |
4371 | (while thread | |
4372 | (gnus-remove-thread-1 (car thread)) | |
4373 | (setq thread (cdr thread)))) | |
4374 | (gnus-remove-thread-1 thread)))))))) | |
4375 | ||
4376 | (defun gnus-remove-thread-1 (thread) | |
4377 | "Remove the thread THREAD recursively." | |
4378 | (let ((number (mail-header-number (pop thread))) | |
4379 | d) | |
4380 | (setq thread (reverse thread)) | |
4381 | (while thread | |
4382 | (gnus-remove-thread-1 (pop thread))) | |
4383 | (when (setq d (gnus-data-find number)) | |
4384 | (goto-char (gnus-data-pos d)) | |
16409b0b | 4385 | (gnus-summary-show-thread) |
eec82323 LMI |
4386 | (gnus-data-remove |
4387 | number | |
4388 | (- (gnus-point-at-bol) | |
4389 | (prog1 | |
4390 | (1+ (gnus-point-at-eol)) | |
4391 | (gnus-delete-line))))))) | |
4392 | ||
16409b0b GM |
4393 | (defun gnus-sort-threads-1 (threads func) |
4394 | (sort (mapcar (lambda (thread) | |
4395 | (cons (car thread) | |
4396 | (and (cdr thread) | |
4397 | (gnus-sort-threads-1 (cdr thread) func)))) | |
4398 | threads) func)) | |
4399 | ||
eec82323 LMI |
4400 | (defun gnus-sort-threads (threads) |
4401 | "Sort THREADS." | |
4402 | (if (not gnus-thread-sort-functions) | |
4403 | threads | |
6748645f | 4404 | (gnus-message 8 "Sorting threads...") |
23f87bed MB |
4405 | (let ((max-lisp-eval-depth 5000)) |
4406 | (prog1 (gnus-sort-threads-1 | |
a1506d29 | 4407 | threads |
16409b0b | 4408 | (gnus-make-sort-function gnus-thread-sort-functions)) |
23f87bed | 4409 | (gnus-message 8 "Sorting threads...done"))))) |
eec82323 LMI |
4410 | |
4411 | (defun gnus-sort-articles (articles) | |
4412 | "Sort ARTICLES." | |
4413 | (when gnus-article-sort-functions | |
4414 | (gnus-message 7 "Sorting articles...") | |
4415 | (prog1 | |
4416 | (setq gnus-newsgroup-headers | |
4417 | (sort articles (gnus-make-sort-function | |
4418 | gnus-article-sort-functions))) | |
4419 | (gnus-message 7 "Sorting articles...done")))) | |
4420 | ||
4421 | ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
4422 | (defmacro gnus-thread-header (thread) | |
16409b0b GM |
4423 | "Return header of first article in THREAD. |
4424 | Note that THREAD must never, ever be anything else than a variable - | |
4425 | using some other form will lead to serious barfage." | |
eec82323 LMI |
4426 | (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread))) |
4427 | ;; (8% speedup to gnus-summary-prepare, just for fun :-) | |
16409b0b | 4428 | (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" |
eec82323 LMI |
4429 | (vector thread) 2)) |
4430 | ||
4431 | (defsubst gnus-article-sort-by-number (h1 h2) | |
4432 | "Sort articles by article number." | |
4433 | (< (mail-header-number h1) | |
4434 | (mail-header-number h2))) | |
4435 | ||
4436 | (defun gnus-thread-sort-by-number (h1 h2) | |
4437 | "Sort threads by root article number." | |
4438 | (gnus-article-sort-by-number | |
4439 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4440 | ||
23f87bed MB |
4441 | (defsubst gnus-article-sort-by-random (h1 h2) |
4442 | "Sort articles by article number." | |
4443 | (zerop (random 2))) | |
4444 | ||
4445 | (defun gnus-thread-sort-by-random (h1 h2) | |
4446 | "Sort threads by root article number." | |
4447 | (gnus-article-sort-by-random | |
4448 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4449 | ||
eec82323 LMI |
4450 | (defsubst gnus-article-sort-by-lines (h1 h2) |
4451 | "Sort articles by article Lines header." | |
4452 | (< (mail-header-lines h1) | |
4453 | (mail-header-lines h2))) | |
4454 | ||
4455 | (defun gnus-thread-sort-by-lines (h1 h2) | |
4456 | "Sort threads by root article Lines header." | |
4457 | (gnus-article-sort-by-lines | |
4458 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4459 | ||
16409b0b GM |
4460 | (defsubst gnus-article-sort-by-chars (h1 h2) |
4461 | "Sort articles by octet length." | |
4462 | (< (mail-header-chars h1) | |
4463 | (mail-header-chars h2))) | |
4464 | ||
4465 | (defun gnus-thread-sort-by-chars (h1 h2) | |
4466 | "Sort threads by root article octet length." | |
4467 | (gnus-article-sort-by-chars | |
4468 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4469 | ||
eec82323 LMI |
4470 | (defsubst gnus-article-sort-by-author (h1 h2) |
4471 | "Sort articles by root author." | |
4472 | (string-lessp | |
4473 | (let ((extract (funcall | |
4474 | gnus-extract-address-components | |
4475 | (mail-header-from h1)))) | |
4476 | (or (car extract) (cadr extract) "")) | |
4477 | (let ((extract (funcall | |
4478 | gnus-extract-address-components | |
4479 | (mail-header-from h2)))) | |
4480 | (or (car extract) (cadr extract) "")))) | |
4481 | ||
4482 | (defun gnus-thread-sort-by-author (h1 h2) | |
4483 | "Sort threads by root author." | |
4484 | (gnus-article-sort-by-author | |
4485 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4486 | ||
4487 | (defsubst gnus-article-sort-by-subject (h1 h2) | |
4488 | "Sort articles by root subject." | |
4489 | (string-lessp | |
4490 | (downcase (gnus-simplify-subject-re (mail-header-subject h1))) | |
4491 | (downcase (gnus-simplify-subject-re (mail-header-subject h2))))) | |
4492 | ||
4493 | (defun gnus-thread-sort-by-subject (h1 h2) | |
4494 | "Sort threads by root subject." | |
4495 | (gnus-article-sort-by-subject | |
4496 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4497 | ||
4498 | (defsubst gnus-article-sort-by-date (h1 h2) | |
4499 | "Sort articles by root article date." | |
16409b0b | 4500 | (time-less-p |
eec82323 LMI |
4501 | (gnus-date-get-time (mail-header-date h1)) |
4502 | (gnus-date-get-time (mail-header-date h2)))) | |
4503 | ||
4504 | (defun gnus-thread-sort-by-date (h1 h2) | |
4505 | "Sort threads by root article date." | |
4506 | (gnus-article-sort-by-date | |
4507 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4508 | ||
4509 | (defsubst gnus-article-sort-by-score (h1 h2) | |
4510 | "Sort articles by root article score. | |
4511 | Unscored articles will be counted as having a score of zero." | |
4512 | (> (or (cdr (assq (mail-header-number h1) | |
4513 | gnus-newsgroup-scored)) | |
4514 | gnus-summary-default-score 0) | |
4515 | (or (cdr (assq (mail-header-number h2) | |
4516 | gnus-newsgroup-scored)) | |
4517 | gnus-summary-default-score 0))) | |
4518 | ||
4519 | (defun gnus-thread-sort-by-score (h1 h2) | |
4520 | "Sort threads by root article score." | |
4521 | (gnus-article-sort-by-score | |
4522 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4523 | ||
4524 | (defun gnus-thread-sort-by-total-score (h1 h2) | |
4525 | "Sort threads by the sum of all scores in the thread. | |
4526 | Unscored articles will be counted as having a score of zero." | |
4527 | (> (gnus-thread-total-score h1) (gnus-thread-total-score h2))) | |
4528 | ||
4529 | (defun gnus-thread-total-score (thread) | |
16409b0b | 4530 | ;; This function find the total score of THREAD. |
23f87bed MB |
4531 | (cond |
4532 | ((null thread) | |
4533 | 0) | |
4534 | ((consp thread) | |
4535 | (if (stringp (car thread)) | |
4536 | (apply gnus-thread-score-function 0 | |
4537 | (mapcar 'gnus-thread-total-score-1 (cdr thread))) | |
4538 | (gnus-thread-total-score-1 thread))) | |
4539 | (t | |
4540 | (gnus-thread-total-score-1 (list thread))))) | |
4541 | ||
4542 | (defun gnus-thread-sort-by-most-recent-number (h1 h2) | |
4543 | "Sort threads such that the thread with the most recently arrived article comes first." | |
4544 | (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2))) | |
4545 | ||
4546 | (defun gnus-thread-highest-number (thread) | |
4547 | "Return the highest article number in THREAD." | |
4548 | (apply 'max (mapcar (lambda (header) | |
4549 | (mail-header-number header)) | |
4550 | (message-flatten-list thread)))) | |
4551 | ||
4552 | (defun gnus-thread-sort-by-most-recent-date (h1 h2) | |
4553 | "Sort threads such that the thread with the most recently dated article comes first." | |
4554 | (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2))) | |
4555 | ||
4556 | (defun gnus-thread-latest-date (thread) | |
4557 | "Return the highest article date in THREAD." | |
4558 | (let ((previous-time 0)) | |
4559 | (apply 'max | |
4560 | (mapcar | |
4561 | (lambda (header) | |
4562 | (setq previous-time | |
4563 | (condition-case () | |
4564 | (time-to-seconds (mail-header-parse-date | |
4565 | (mail-header-date header))) | |
4566 | (error previous-time)))) | |
4567 | (sort | |
4568 | (message-flatten-list thread) | |
4569 | (lambda (h1 h2) | |
4570 | (< (mail-header-number h1) | |
4571 | (mail-header-number h2)))))))) | |
eec82323 LMI |
4572 | |
4573 | (defun gnus-thread-total-score-1 (root) | |
4574 | ;; This function find the total score of the thread below ROOT. | |
4575 | (setq root (car root)) | |
4576 | (apply gnus-thread-score-function | |
4577 | (or (append | |
4578 | (mapcar 'gnus-thread-total-score | |
6748645f | 4579 | (cdr (gnus-id-to-thread (mail-header-id root)))) |
eec82323 LMI |
4580 | (when (> (mail-header-number root) 0) |
4581 | (list (or (cdr (assq (mail-header-number root) | |
4582 | gnus-newsgroup-scored)) | |
4583 | gnus-summary-default-score 0)))) | |
4584 | (list gnus-summary-default-score) | |
4585 | '(0)))) | |
4586 | ||
4587 | ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
4588 | (defvar gnus-tmp-prev-subject nil) | |
4589 | (defvar gnus-tmp-false-parent nil) | |
4590 | (defvar gnus-tmp-root-expunged nil) | |
4591 | (defvar gnus-tmp-dummy-line nil) | |
4592 | ||
60bd5589 | 4593 | (eval-when-compile (defvar gnus-tmp-header)) |
16409b0b GM |
4594 | (defun gnus-extra-header (type &optional header) |
4595 | "Return the extra header of TYPE." | |
4596 | (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header)))) | |
4597 | "")) | |
4598 | ||
23f87bed MB |
4599 | (defvar gnus-tmp-thread-tree-header-string "") |
4600 | ||
4601 | (defcustom gnus-sum-thread-tree-root "> " | |
4602 | "With %B spec, used for the root of a thread. | |
4603 | If nil, use subject instead." | |
a08b59c9 | 4604 | :version "21.4" |
23f87bed MB |
4605 | :type '(radio (const :format "%v " nil) (string :size 0)) |
4606 | :group 'gnus-thread) | |
4607 | (defcustom gnus-sum-thread-tree-false-root "> " | |
4608 | "With %B spec, used for a false root of a thread. | |
4609 | If nil, use subject instead." | |
a08b59c9 | 4610 | :version "21.4" |
23f87bed MB |
4611 | :type '(radio (const :format "%v " nil) (string :size 0)) |
4612 | :group 'gnus-thread) | |
4613 | (defcustom gnus-sum-thread-tree-single-indent "" | |
4614 | "With %B spec, used for a thread with just one message. | |
4615 | If nil, use subject instead." | |
a08b59c9 | 4616 | :version "21.4" |
23f87bed MB |
4617 | :type '(radio (const :format "%v " nil) (string :size 0)) |
4618 | :group 'gnus-thread) | |
4619 | (defcustom gnus-sum-thread-tree-vertical "| " | |
4620 | "With %B spec, used for drawing a vertical line." | |
a08b59c9 | 4621 | :version "21.4" |
23f87bed MB |
4622 | :type 'string |
4623 | :group 'gnus-thread) | |
4624 | (defcustom gnus-sum-thread-tree-indent " " | |
4625 | "With %B spec, used for indenting." | |
a08b59c9 | 4626 | :version "21.4" |
23f87bed MB |
4627 | :type 'string |
4628 | :group 'gnus-thread) | |
4629 | (defcustom gnus-sum-thread-tree-leaf-with-other "+-> " | |
4630 | "With %B spec, used for a leaf with brothers." | |
a08b59c9 | 4631 | :version "21.4" |
23f87bed MB |
4632 | :type 'string |
4633 | :group 'gnus-thread) | |
4634 | (defcustom gnus-sum-thread-tree-single-leaf "\\-> " | |
4635 | "With %B spec, used for a leaf without brothers." | |
a08b59c9 | 4636 | :version "21.4" |
23f87bed MB |
4637 | :type 'string |
4638 | :group 'gnus-thread) | |
4639 | ||
eec82323 LMI |
4640 | (defun gnus-summary-prepare-threads (threads) |
4641 | "Prepare summary buffer from THREADS and indentation LEVEL. | |
4642 | THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])' | |
4643 | or a straight list of headers." | |
4644 | (gnus-message 7 "Generating summary...") | |
4645 | ||
4646 | (setq gnus-newsgroup-threads threads) | |
4647 | (beginning-of-line) | |
4648 | ||
4649 | (let ((gnus-tmp-level 0) | |
4650 | (default-score (or gnus-summary-default-score 0)) | |
4651 | (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight)) | |
23f87bed MB |
4652 | (building-line-count gnus-summary-display-while-building) |
4653 | (building-count (integerp gnus-summary-display-while-building)) | |
eec82323 | 4654 | thread number subject stack state gnus-tmp-gathered beg-match |
23f87bed MB |
4655 | new-roots gnus-tmp-new-adopts thread-end simp-subject |
4656 | gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded | |
eec82323 LMI |
4657 | gnus-tmp-replied gnus-tmp-subject-or-nil |
4658 | gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score | |
4659 | gnus-tmp-score-char gnus-tmp-from gnus-tmp-name | |
23f87bed MB |
4660 | gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket |
4661 | tree-stack) | |
eec82323 | 4662 | |
23f87bed MB |
4663 | (setq gnus-tmp-prev-subject nil |
4664 | gnus-tmp-thread-tree-header-string "") | |
eec82323 LMI |
4665 | |
4666 | (if (vectorp (car threads)) | |
4667 | ;; If this is a straight (sic) list of headers, then a | |
4668 | ;; threaded summary display isn't required, so we just create | |
4669 | ;; an unthreaded one. | |
4670 | (gnus-summary-prepare-unthreaded threads) | |
4671 | ||
4672 | ;; Do the threaded display. | |
4673 | ||
23f87bed MB |
4674 | (if gnus-summary-display-while-building |
4675 | (switch-to-buffer (buffer-name))) | |
eec82323 LMI |
4676 | (while (or threads stack gnus-tmp-new-adopts new-roots) |
4677 | ||
4678 | (if (and (= gnus-tmp-level 0) | |
eec82323 LMI |
4679 | (or (not stack) |
4680 | (= (caar stack) 0)) | |
4681 | (not gnus-tmp-false-parent) | |
4682 | (or gnus-tmp-new-adopts new-roots)) | |
4683 | (if gnus-tmp-new-adopts | |
4684 | (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1) | |
4685 | thread (list (car gnus-tmp-new-adopts)) | |
4686 | gnus-tmp-header (caar thread) | |
4687 | gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts)) | |
4688 | (when new-roots | |
4689 | (setq thread (list (car new-roots)) | |
4690 | gnus-tmp-header (caar thread) | |
4691 | new-roots (cdr new-roots)))) | |
4692 | ||
4693 | (if threads | |
4694 | ;; If there are some threads, we do them before the | |
4695 | ;; threads on the stack. | |
4696 | (setq thread threads | |
4697 | gnus-tmp-header (caar thread)) | |
4698 | ;; There were no current threads, so we pop something off | |
4699 | ;; the stack. | |
4700 | (setq state (car stack) | |
4701 | gnus-tmp-level (car state) | |
23f87bed MB |
4702 | tree-stack (cadr state) |
4703 | thread (caddr state) | |
eec82323 LMI |
4704 | stack (cdr stack) |
4705 | gnus-tmp-header (caar thread)))) | |
4706 | ||
4707 | (setq gnus-tmp-false-parent nil) | |
4708 | (setq gnus-tmp-root-expunged nil) | |
4709 | (setq thread-end nil) | |
4710 | ||
4711 | (if (stringp gnus-tmp-header) | |
4712 | ;; The header is a dummy root. | |
4713 | (cond | |
4714 | ((eq gnus-summary-make-false-root 'adopt) | |
4715 | ;; We let the first article adopt the rest. | |
4716 | (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts | |
4717 | (cddar thread))) | |
4718 | (setq gnus-tmp-gathered | |
4719 | (nconc (mapcar | |
4720 | (lambda (h) (mail-header-number (car h))) | |
4721 | (cddar thread)) | |
4722 | gnus-tmp-gathered)) | |
4723 | (setq thread (cons (list (caar thread) | |
4724 | (cadar thread)) | |
4725 | (cdr thread))) | |
4726 | (setq gnus-tmp-level -1 | |
4727 | gnus-tmp-false-parent t)) | |
4728 | ((eq gnus-summary-make-false-root 'empty) | |
4729 | ;; We print adopted articles with empty subject fields. | |
4730 | (setq gnus-tmp-gathered | |
4731 | (nconc (mapcar | |
4732 | (lambda (h) (mail-header-number (car h))) | |
4733 | (cddar thread)) | |
4734 | gnus-tmp-gathered)) | |
4735 | (setq gnus-tmp-level -1)) | |
4736 | ((eq gnus-summary-make-false-root 'dummy) | |
4737 | ;; We remember that we probably want to output a dummy | |
4738 | ;; root. | |
4739 | (setq gnus-tmp-dummy-line gnus-tmp-header) | |
4740 | (setq gnus-tmp-prev-subject gnus-tmp-header)) | |
4741 | (t | |
4742 | ;; We do not make a root for the gathered | |
4743 | ;; sub-threads at all. | |
4744 | (setq gnus-tmp-level -1))) | |
4745 | ||
4746 | (setq number (mail-header-number gnus-tmp-header) | |
23f87bed MB |
4747 | subject (mail-header-subject gnus-tmp-header) |
4748 | simp-subject (gnus-simplify-subject-fully subject)) | |
eec82323 LMI |
4749 | |
4750 | (cond | |
4751 | ;; If the thread has changed subject, we might want to make | |
4752 | ;; this subthread into a root. | |
4753 | ((and (null gnus-thread-ignore-subject) | |
4754 | (not (zerop gnus-tmp-level)) | |
4755 | gnus-tmp-prev-subject | |
23f87bed | 4756 | (not (string= gnus-tmp-prev-subject simp-subject))) |
eec82323 LMI |
4757 | (setq new-roots (nconc new-roots (list (car thread))) |
4758 | thread-end t | |
4759 | gnus-tmp-header nil)) | |
4760 | ;; If the article lies outside the current limit, | |
4761 | ;; then we do not display it. | |
4762 | ((not (memq number gnus-newsgroup-limit)) | |
4763 | (setq gnus-tmp-gathered | |
4764 | (nconc (mapcar | |
4765 | (lambda (h) (mail-header-number (car h))) | |
4766 | (cdar thread)) | |
4767 | gnus-tmp-gathered)) | |
4768 | (setq gnus-tmp-new-adopts (if (cdar thread) | |
4769 | (append gnus-tmp-new-adopts | |
4770 | (cdar thread)) | |
4771 | gnus-tmp-new-adopts) | |
4772 | thread-end t | |
4773 | gnus-tmp-header nil) | |
4774 | (when (zerop gnus-tmp-level) | |
4775 | (setq gnus-tmp-root-expunged t))) | |
4776 | ;; Perhaps this article is to be marked as read? | |
4777 | ((and gnus-summary-mark-below | |
4778 | (< (or (cdr (assq number gnus-newsgroup-scored)) | |
4779 | default-score) | |
4780 | gnus-summary-mark-below) | |
4781 | ;; Don't touch sparse articles. | |
4782 | (not (gnus-summary-article-sparse-p number)) | |
4783 | (not (gnus-summary-article-ancient-p number))) | |
4784 | (setq gnus-newsgroup-unreads | |
4785 | (delq number gnus-newsgroup-unreads)) | |
4786 | (if gnus-newsgroup-auto-expire | |
23f87bed MB |
4787 | (setq gnus-newsgroup-expirable |
4788 | (gnus-add-to-sorted-list | |
4789 | gnus-newsgroup-expirable number)) | |
eec82323 LMI |
4790 | (push (cons number gnus-low-score-mark) |
4791 | gnus-newsgroup-reads)))) | |
4792 | ||
4793 | (when gnus-tmp-header | |
4794 | ;; We may have an old dummy line to output before this | |
4795 | ;; article. | |
6748645f LMI |
4796 | (when (and gnus-tmp-dummy-line |
4797 | (gnus-subject-equal | |
4798 | gnus-tmp-dummy-line | |
4799 | (mail-header-subject gnus-tmp-header))) | |
eec82323 LMI |
4800 | (gnus-summary-insert-dummy-line |
4801 | gnus-tmp-dummy-line (mail-header-number gnus-tmp-header)) | |
4802 | (setq gnus-tmp-dummy-line nil)) | |
4803 | ||
4804 | ;; Compute the mark. | |
4805 | (setq gnus-tmp-unread (gnus-article-mark number)) | |
4806 | ||
4807 | (push (gnus-data-make number gnus-tmp-unread (1+ (point)) | |
4808 | gnus-tmp-header gnus-tmp-level) | |
4809 | gnus-newsgroup-data) | |
4810 | ||
4811 | ;; Actually insert the line. | |
4812 | (setq | |
4813 | gnus-tmp-subject-or-nil | |
4814 | (cond | |
4815 | ((and gnus-thread-ignore-subject | |
4816 | gnus-tmp-prev-subject | |
23f87bed | 4817 | (not (string= gnus-tmp-prev-subject simp-subject))) |
eec82323 LMI |
4818 | subject) |
4819 | ((zerop gnus-tmp-level) | |
4820 | (if (and (eq gnus-summary-make-false-root 'empty) | |
4821 | (memq number gnus-tmp-gathered) | |
4822 | gnus-tmp-prev-subject | |
23f87bed | 4823 | (string= gnus-tmp-prev-subject simp-subject)) |
eec82323 LMI |
4824 | gnus-summary-same-subject |
4825 | subject)) | |
4826 | (t gnus-summary-same-subject))) | |
4827 | (if (and (eq gnus-summary-make-false-root 'adopt) | |
4828 | (= gnus-tmp-level 1) | |
4829 | (memq number gnus-tmp-gathered)) | |
4830 | (setq gnus-tmp-opening-bracket ?\< | |
4831 | gnus-tmp-closing-bracket ?\>) | |
4832 | (setq gnus-tmp-opening-bracket ?\[ | |
4833 | gnus-tmp-closing-bracket ?\])) | |
4834 | (setq | |
4835 | gnus-tmp-indentation | |
4836 | (aref gnus-thread-indent-array gnus-tmp-level) | |
4837 | gnus-tmp-lines (mail-header-lines gnus-tmp-header) | |
4838 | gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored)) | |
4839 | gnus-summary-default-score 0) | |
4840 | gnus-tmp-score-char | |
4841 | (if (or (null gnus-summary-default-score) | |
4842 | (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
4843 | gnus-summary-zcore-fuzz)) | |
23f87bed | 4844 | ? ;Whitespace |
eec82323 LMI |
4845 | (if (< gnus-tmp-score gnus-summary-default-score) |
4846 | gnus-score-below-mark gnus-score-over-mark)) | |
4847 | gnus-tmp-replied | |
4848 | (cond ((memq number gnus-newsgroup-processable) | |
4849 | gnus-process-mark) | |
4850 | ((memq number gnus-newsgroup-cached) | |
4851 | gnus-cached-mark) | |
4852 | ((memq number gnus-newsgroup-replied) | |
4853 | gnus-replied-mark) | |
23f87bed MB |
4854 | ((memq number gnus-newsgroup-forwarded) |
4855 | gnus-forwarded-mark) | |
eec82323 LMI |
4856 | ((memq number gnus-newsgroup-saved) |
4857 | gnus-saved-mark) | |
23f87bed MB |
4858 | ((memq number gnus-newsgroup-recent) |
4859 | gnus-recent-mark) | |
4860 | ((memq number gnus-newsgroup-unseen) | |
4861 | gnus-unseen-mark) | |
4862 | (t gnus-no-mark)) | |
4863 | gnus-tmp-downloaded | |
4864 | (cond ((memq number gnus-newsgroup-undownloaded) | |
4865 | gnus-undownloaded-mark) | |
4866 | (gnus-newsgroup-agentized | |
4867 | gnus-downloaded-mark) | |
4868 | (t | |
4869 | gnus-no-mark)) | |
eec82323 LMI |
4870 | gnus-tmp-from (mail-header-from gnus-tmp-header) |
4871 | gnus-tmp-name | |
4872 | (cond | |
4873 | ((string-match "<[^>]+> *$" gnus-tmp-from) | |
4874 | (setq beg-match (match-beginning 0)) | |
23f87bed MB |
4875 | (or (and (string-match "^\".+\"" gnus-tmp-from) |
4876 | (substring gnus-tmp-from 1 (1- (match-end 0)))) | |
eec82323 LMI |
4877 | (substring gnus-tmp-from 0 beg-match))) |
4878 | ((string-match "(.+)" gnus-tmp-from) | |
4879 | (substring gnus-tmp-from | |
4880 | (1+ (match-beginning 0)) (1- (match-end 0)))) | |
23f87bed MB |
4881 | (t gnus-tmp-from)) |
4882 | ||
4883 | ;; Do the %B string | |
4884 | gnus-tmp-thread-tree-header-string | |
4885 | (cond | |
4886 | ((not gnus-show-threads) "") | |
4887 | ((zerop gnus-tmp-level) | |
4888 | (cond ((cdar thread) | |
4889 | (or gnus-sum-thread-tree-root subject)) | |
4890 | (gnus-tmp-new-adopts | |
4891 | (or gnus-sum-thread-tree-false-root subject)) | |
4892 | (t | |
4893 | (or gnus-sum-thread-tree-single-indent subject)))) | |
4894 | (t | |
4895 | (concat (apply 'concat | |
4896 | (mapcar (lambda (item) | |
4897 | (if (= item 1) | |
4898 | gnus-sum-thread-tree-vertical | |
4899 | gnus-sum-thread-tree-indent)) | |
4900 | (cdr (reverse tree-stack)))) | |
4901 | (if (nth 1 thread) | |
4902 | gnus-sum-thread-tree-leaf-with-other | |
4903 | gnus-sum-thread-tree-single-leaf))))) | |
eec82323 LMI |
4904 | (when (string= gnus-tmp-name "") |
4905 | (setq gnus-tmp-name gnus-tmp-from)) | |
4906 | (unless (numberp gnus-tmp-lines) | |
23f87bed MB |
4907 | (setq gnus-tmp-lines -1)) |
4908 | (if (= gnus-tmp-lines -1) | |
4909 | (setq gnus-tmp-lines "?") | |
4910 | (setq gnus-tmp-lines (number-to-string gnus-tmp-lines))) | |
4911 | (gnus-put-text-property | |
eec82323 LMI |
4912 | (point) |
4913 | (progn (eval gnus-summary-line-format-spec) (point)) | |
23f87bed | 4914 | 'gnus-number number) |
eec82323 LMI |
4915 | (when gnus-visual-p |
4916 | (forward-line -1) | |
6748645f | 4917 | (gnus-run-hooks 'gnus-summary-update-hook) |
eec82323 LMI |
4918 | (forward-line 1)) |
4919 | ||
23f87bed | 4920 | (setq gnus-tmp-prev-subject simp-subject))) |
eec82323 LMI |
4921 | |
4922 | (when (nth 1 thread) | |
23f87bed MB |
4923 | (push (list (max 0 gnus-tmp-level) |
4924 | (copy-sequence tree-stack) | |
4925 | (nthcdr 1 thread)) | |
4926 | stack)) | |
4927 | (push (if (nth 1 thread) 1 0) tree-stack) | |
eec82323 LMI |
4928 | (incf gnus-tmp-level) |
4929 | (setq threads (if thread-end nil (cdar thread))) | |
23f87bed MB |
4930 | (if gnus-summary-display-while-building |
4931 | (if building-count | |
4932 | (progn | |
4933 | ;; use a set frequency | |
4934 | (setq building-line-count (1- building-line-count)) | |
4935 | (when (= building-line-count 0) | |
4936 | (sit-for 0) | |
4937 | (setq building-line-count | |
4938 | gnus-summary-display-while-building))) | |
4939 | ;; always | |
4940 | (sit-for 0))) | |
eec82323 LMI |
4941 | (unless threads |
4942 | (setq gnus-tmp-level 0))))) | |
4943 | (gnus-message 7 "Generating summary...done")) | |
4944 | ||
4945 | (defun gnus-summary-prepare-unthreaded (headers) | |
4946 | "Generate an unthreaded summary buffer based on HEADERS." | |
4947 | (let (header number mark) | |
4948 | ||
4949 | (beginning-of-line) | |
4950 | ||
4951 | (while headers | |
4952 | ;; We may have to root out some bad articles... | |
4953 | (when (memq (setq number (mail-header-number | |
4954 | (setq header (pop headers)))) | |
4955 | gnus-newsgroup-limit) | |
4956 | ;; Mark article as read when it has a low score. | |
4957 | (when (and gnus-summary-mark-below | |
4958 | (< (or (cdr (assq number gnus-newsgroup-scored)) | |
4959 | gnus-summary-default-score 0) | |
4960 | gnus-summary-mark-below) | |
4961 | (not (gnus-summary-article-ancient-p number))) | |
4962 | (setq gnus-newsgroup-unreads | |
4963 | (delq number gnus-newsgroup-unreads)) | |
4964 | (if gnus-newsgroup-auto-expire | |
4965 | (push number gnus-newsgroup-expirable) | |
4966 | (push (cons number gnus-low-score-mark) | |
4967 | gnus-newsgroup-reads))) | |
4968 | ||
4969 | (setq mark (gnus-article-mark number)) | |
4970 | (push (gnus-data-make number mark (1+ (point)) header 0) | |
4971 | gnus-newsgroup-data) | |
4972 | (gnus-summary-insert-line | |
4973 | header 0 number | |
23f87bed | 4974 | (memq number gnus-newsgroup-undownloaded) |
eec82323 LMI |
4975 | mark (memq number gnus-newsgroup-replied) |
4976 | (memq number gnus-newsgroup-expirable) | |
4977 | (mail-header-subject header) nil | |
4978 | (cdr (assq number gnus-newsgroup-scored)) | |
4979 | (memq number gnus-newsgroup-processable)))))) | |
4980 | ||
16409b0b GM |
4981 | (defun gnus-summary-remove-list-identifiers () |
4982 | "Remove list identifiers in `gnus-list-identifiers' from articles in the current group." | |
23f87bed MB |
4983 | (let ((regexp (if (consp gnus-list-identifiers) |
4984 | (mapconcat 'identity gnus-list-identifiers " *\\|") | |
4985 | gnus-list-identifiers)) | |
4986 | changed subject) | |
4987 | (when regexp | |
4988 | (dolist (header gnus-newsgroup-headers) | |
4989 | (setq subject (mail-header-subject header) | |
4990 | changed nil) | |
4991 | (while (string-match | |
4992 | (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)") | |
4993 | subject) | |
4994 | (setq subject | |
4995 | (concat (substring subject 0 (match-beginning 2)) | |
4996 | (substring subject (match-end 0))) | |
4997 | changed t)) | |
4998 | (when (and changed | |
4999 | (string-match | |
5000 | "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject)) | |
5001 | (setq subject | |
5002 | (concat (substring subject 0 (match-beginning 1)) | |
5003 | (substring subject (match-end 1))))) | |
5004 | (when changed | |
5005 | (mail-header-set-subject header subject)))))) | |
5006 | ||
5007 | (defun gnus-fetch-headers (articles) | |
5008 | "Fetch headers of ARTICLES." | |
5009 | (let ((name (gnus-group-decoded-name gnus-newsgroup-name))) | |
5010 | (gnus-message 5 "Fetching headers for %s..." name) | |
5011 | (prog1 | |
5012 | (if (eq 'nov | |
5013 | (setq gnus-headers-retrieved-by | |
5014 | (gnus-retrieve-headers | |
5015 | articles gnus-newsgroup-name | |
5016 | ;; We might want to fetch old headers, but | |
5017 | ;; not if there is only 1 article. | |
5018 | (and (or (and | |
5019 | (not (eq gnus-fetch-old-headers 'some)) | |
5020 | (not (numberp gnus-fetch-old-headers))) | |
5021 | (> (length articles) 1)) | |
5022 | gnus-fetch-old-headers)))) | |
5023 | (gnus-get-newsgroup-headers-xover | |
5024 | articles nil nil gnus-newsgroup-name t) | |
5025 | (gnus-get-newsgroup-headers)) | |
5026 | (gnus-message 5 "Fetching headers for %s...done" name)))) | |
16409b0b | 5027 | |
6748645f | 5028 | (defun gnus-select-newsgroup (group &optional read-all select-articles) |
eec82323 | 5029 | "Select newsgroup GROUP. |
6748645f LMI |
5030 | If READ-ALL is non-nil, all articles in the group are selected. |
5031 | If SELECT-ARTICLES, only select those articles from GROUP." | |
eec82323 LMI |
5032 | (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) |
5033 | ;;!!! Dirty hack; should be removed. | |
5034 | (gnus-summary-ignore-duplicates | |
23f87bed | 5035 | (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual) |
eec82323 LMI |
5036 | t |
5037 | gnus-summary-ignore-duplicates)) | |
5038 | (info (nth 2 entry)) | |
5039 | articles fetched-articles cached) | |
5040 | ||
5041 | (unless (gnus-check-server | |
475e0e0c GM |
5042 | (set (make-local-variable 'gnus-current-select-method) |
5043 | (gnus-find-method-for-group group))) | |
eec82323 LMI |
5044 | (error "Couldn't open server")) |
5045 | ||
5046 | (or (and entry (not (eq (car entry) t))) ; Either it's active... | |
5047 | (gnus-activate-group group) ; Or we can activate it... | |
5048 | (progn ; Or we bug out. | |
5049 | (when (equal major-mode 'gnus-summary-mode) | |
23f87bed MB |
5050 | (gnus-kill-buffer (current-buffer))) |
5051 | (error "Couldn't activate group %s: %s" | |
eec82323 LMI |
5052 | group (gnus-status-message group)))) |
5053 | ||
5054 | (unless (gnus-request-group group t) | |
5055 | (when (equal major-mode 'gnus-summary-mode) | |
23f87bed | 5056 | (gnus-kill-buffer (current-buffer))) |
eec82323 LMI |
5057 | (error "Couldn't request group %s: %s" |
5058 | group (gnus-status-message group))) | |
5059 | ||
23f87bed MB |
5060 | (when gnus-agent |
5061 | ;; The agent may be storing articles that are no longer in the | |
5062 | ;; server's active range. If that is the case, the active range | |
5063 | ;; needs to be expanded such that the agent's articles can be | |
5064 | ;; included in the summary. | |
5065 | (let* ((gnus-command-method (gnus-find-method-for-group group)) | |
5066 | (alist (gnus-agent-load-alist group)) | |
5067 | (active (gnus-active group))) | |
5068 | (if (and (car alist) | |
5069 | (< (caar alist) (car active))) | |
5070 | (gnus-set-active group (cons (caar alist) (cdr active))))) | |
5071 | ||
5072 | (setq gnus-summary-use-undownloaded-faces | |
5073 | (gnus-agent-find-parameter | |
5074 | group | |
5075 | 'agent-enable-undownloaded-faces))) | |
5076 | ||
5077 | (setq gnus-newsgroup-name group | |
5078 | gnus-newsgroup-unselected nil | |
5079 | gnus-newsgroup-unreads (gnus-list-of-unread-articles group)) | |
5080 | ||
5081 | (let ((display (gnus-group-find-parameter group 'display))) | |
5082 | (setq gnus-newsgroup-display | |
5083 | (cond | |
5084 | ((not (zerop (or (car-safe read-all) 0))) | |
5085 | ;; The user entered the group with C-u SPC/RET, let's show | |
5086 | ;; all articles. | |
5087 | 'gnus-not-ignore) | |
5088 | ((eq display 'all) | |
5089 | 'gnus-not-ignore) | |
5090 | ((arrayp display) | |
5091 | (gnus-summary-display-make-predicate (mapcar 'identity display))) | |
5092 | ((numberp display) | |
5093 | ;; The following is probably the "correct" solution, but | |
5094 | ;; it makes Gnus fetch all headers and then limit the | |
5095 | ;; articles (which is slow), so instead we hack the | |
5096 | ;; select-articles parameter instead. -- Simon Josefsson | |
5097 | ;; <jas@kth.se> | |
5098 | ;; | |
5099 | ;; (gnus-byte-compile | |
5100 | ;; `(lambda () (> number ,(- (cdr (gnus-active group)) | |
5101 | ;; display))))) | |
5102 | (setq select-articles | |
5103 | (gnus-uncompress-range | |
5104 | (cons (let ((tmp (- (cdr (gnus-active group)) display))) | |
5105 | (if (> tmp 0) | |
5106 | tmp | |
5107 | 1)) | |
5108 | (cdr (gnus-active group))))) | |
5109 | nil) | |
5110 | (t | |
5111 | nil)))) | |
eec82323 | 5112 | |
23f87bed | 5113 | (gnus-summary-setup-default-charset) |
eec82323 LMI |
5114 | |
5115 | ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
5116 | (when (gnus-virtual-group-p group) | |
5117 | (setq cached gnus-newsgroup-cached)) | |
5118 | ||
5119 | (setq gnus-newsgroup-unreads | |
23f87bed MB |
5120 | (gnus-sorted-ndifference |
5121 | (gnus-sorted-ndifference gnus-newsgroup-unreads | |
5122 | gnus-newsgroup-marked) | |
eec82323 LMI |
5123 | gnus-newsgroup-dormant)) |
5124 | ||
5125 | (setq gnus-newsgroup-processable nil) | |
5126 | ||
5127 | (gnus-update-read-articles group gnus-newsgroup-unreads) | |
eec82323 | 5128 | |
23f87bed MB |
5129 | ;; Adjust and set lists of article marks. |
5130 | (when info | |
5131 | (gnus-adjust-marked-articles info)) | |
6748645f LMI |
5132 | (if (setq articles select-articles) |
5133 | (setq gnus-newsgroup-unselected | |
23f87bed | 5134 | (gnus-sorted-difference gnus-newsgroup-unreads articles)) |
6748645f | 5135 | (setq articles (gnus-articles-to-read group read-all))) |
eec82323 LMI |
5136 | |
5137 | (cond | |
5138 | ((null articles) | |
5139 | ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display") | |
5140 | 'quit) | |
5141 | ((eq articles 0) nil) | |
5142 | (t | |
5143 | ;; Init the dependencies hash table. | |
5144 | (setq gnus-newsgroup-dependencies | |
5145 | (gnus-make-hashtable (length articles))) | |
16409b0b | 5146 | (gnus-set-global-variables) |
eec82323 | 5147 | ;; Retrieve the headers and read them in. |
23f87bed MB |
5148 | |
5149 | (setq gnus-newsgroup-headers (gnus-fetch-headers articles)) | |
eec82323 LMI |
5150 | |
5151 | ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
5152 | (when cached | |
5153 | (setq gnus-newsgroup-cached cached)) | |
5154 | ||
5155 | ;; Suppress duplicates? | |
5156 | (when gnus-suppress-duplicates | |
5157 | (gnus-dup-suppress-articles)) | |
5158 | ||
5159 | ;; Set the initial limit. | |
5160 | (setq gnus-newsgroup-limit (copy-sequence articles)) | |
5161 | ;; Remove canceled articles from the list of unread articles. | |
23f87bed MB |
5162 | (setq fetched-articles |
5163 | (mapcar (lambda (headers) (mail-header-number headers)) | |
5164 | gnus-newsgroup-headers)) | |
5165 | (setq gnus-newsgroup-articles fetched-articles) | |
eec82323 | 5166 | (setq gnus-newsgroup-unreads |
23f87bed MB |
5167 | (gnus-sorted-nintersection |
5168 | gnus-newsgroup-unreads fetched-articles)) | |
5169 | (gnus-compute-unseen-list) | |
5170 | ||
eec82323 LMI |
5171 | ;; Removed marked articles that do not exist. |
5172 | (gnus-update-missing-marks | |
23f87bed | 5173 | (gnus-sorted-difference articles fetched-articles)) |
eec82323 | 5174 | ;; We might want to build some more threads first. |
6748645f LMI |
5175 | (when (and gnus-fetch-old-headers |
5176 | (eq gnus-headers-retrieved-by 'nov)) | |
5177 | (if (eq gnus-fetch-old-headers 'invisible) | |
5178 | (gnus-build-all-threads) | |
5179 | (gnus-build-old-threads))) | |
5180 | ;; Let the Gnus agent mark articles as read. | |
5181 | (when gnus-agent | |
5182 | (gnus-agent-get-undownloaded-list)) | |
16409b0b GM |
5183 | ;; Remove list identifiers from subject |
5184 | (when gnus-list-identifiers | |
5185 | (gnus-summary-remove-list-identifiers)) | |
eec82323 LMI |
5186 | ;; Check whether auto-expire is to be done in this group. |
5187 | (setq gnus-newsgroup-auto-expire | |
5188 | (gnus-group-auto-expirable-p group)) | |
5189 | ;; Set up the article buffer now, if necessary. | |
5190 | (unless gnus-single-article-buffer | |
5191 | (gnus-article-setup-buffer)) | |
5192 | ;; First and last article in this newsgroup. | |
5193 | (when gnus-newsgroup-headers | |
5194 | (setq gnus-newsgroup-begin | |
5195 | (mail-header-number (car gnus-newsgroup-headers)) | |
5196 | gnus-newsgroup-end | |
5197 | (mail-header-number | |
5198 | (gnus-last-element gnus-newsgroup-headers)))) | |
5199 | ;; GROUP is successfully selected. | |
5200 | (or gnus-newsgroup-headers t))))) | |
5201 | ||
23f87bed MB |
5202 | (defun gnus-compute-unseen-list () |
5203 | ;; The `seen' marks are treated specially. | |
5204 | (if (not gnus-newsgroup-seen) | |
5205 | (setq gnus-newsgroup-unseen gnus-newsgroup-articles) | |
5206 | (setq gnus-newsgroup-unseen | |
5207 | (gnus-inverse-list-range-intersection | |
5208 | gnus-newsgroup-articles gnus-newsgroup-seen)))) | |
5209 | ||
5210 | (defun gnus-summary-display-make-predicate (display) | |
5211 | (require 'gnus-agent) | |
5212 | (when (= (length display) 1) | |
5213 | (setq display (car display))) | |
5214 | (unless gnus-summary-display-cache | |
5215 | (dolist (elem (append '((unread . unread) | |
5216 | (read . read) | |
5217 | (unseen . unseen)) | |
5218 | gnus-article-mark-lists)) | |
5219 | (push (cons (cdr elem) | |
5220 | (gnus-byte-compile | |
5221 | `(lambda () (gnus-article-marked-p ',(cdr elem))))) | |
5222 | gnus-summary-display-cache))) | |
5223 | (let ((gnus-category-predicate-alist gnus-summary-display-cache) | |
5224 | (gnus-category-predicate-cache gnus-summary-display-cache)) | |
5225 | (gnus-get-predicate display))) | |
5226 | ||
5227 | ;; Uses the dynamically bound `number' variable. | |
5228 | (eval-when-compile | |
5229 | (defvar number)) | |
5230 | (defun gnus-article-marked-p (type &optional article) | |
5231 | (let ((article (or article number))) | |
5232 | (cond | |
5233 | ((eq type 'tick) | |
5234 | (memq article gnus-newsgroup-marked)) | |
5235 | ((eq type 'spam) | |
5236 | (memq article gnus-newsgroup-spam-marked)) | |
5237 | ((eq type 'unsend) | |
5238 | (memq article gnus-newsgroup-unsendable)) | |
5239 | ((eq type 'undownload) | |
5240 | (memq article gnus-newsgroup-undownloaded)) | |
5241 | ((eq type 'download) | |
5242 | (memq article gnus-newsgroup-downloadable)) | |
5243 | ((eq type 'unread) | |
5244 | (memq article gnus-newsgroup-unreads)) | |
5245 | ((eq type 'read) | |
5246 | (memq article gnus-newsgroup-reads)) | |
5247 | ((eq type 'dormant) | |
5248 | (memq article gnus-newsgroup-dormant) ) | |
5249 | ((eq type 'expire) | |
5250 | (memq article gnus-newsgroup-expirable)) | |
5251 | ((eq type 'reply) | |
5252 | (memq article gnus-newsgroup-replied)) | |
5253 | ((eq type 'killed) | |
5254 | (memq article gnus-newsgroup-killed)) | |
5255 | ((eq type 'bookmark) | |
5256 | (assq article gnus-newsgroup-bookmarks)) | |
5257 | ((eq type 'score) | |
5258 | (assq article gnus-newsgroup-scored)) | |
5259 | ((eq type 'save) | |
5260 | (memq article gnus-newsgroup-saved)) | |
5261 | ((eq type 'cache) | |
5262 | (memq article gnus-newsgroup-cached)) | |
5263 | ((eq type 'forward) | |
5264 | (memq article gnus-newsgroup-forwarded)) | |
5265 | ((eq type 'seen) | |
5266 | (not (memq article gnus-newsgroup-unseen))) | |
5267 | ((eq type 'recent) | |
5268 | (memq article gnus-newsgroup-recent)) | |
5269 | (t t)))) | |
5270 | ||
eec82323 | 5271 | (defun gnus-articles-to-read (group &optional read-all) |
16409b0b | 5272 | "Find out what articles the user wants to read." |
23f87bed MB |
5273 | (let* ((display (gnus-group-find-parameter group 'display)) |
5274 | (articles | |
eec82323 LMI |
5275 | ;; Select all articles if `read-all' is non-nil, or if there |
5276 | ;; are no unread articles. | |
5277 | (if (or read-all | |
5278 | (and (zerop (length gnus-newsgroup-marked)) | |
5279 | (zerop (length gnus-newsgroup-unreads))) | |
23f87bed MB |
5280 | ;; Fetch all if the predicate is non-nil. |
5281 | gnus-newsgroup-display) | |
5282 | ;; We want to select the headers for all the articles in | |
5283 | ;; the group, so we select either all the active | |
5284 | ;; articles in the group, or (if that's nil), the | |
5285 | ;; articles in the cache. | |
16409b0b GM |
5286 | (or |
5287 | (gnus-uncompress-range (gnus-active group)) | |
5288 | (gnus-cache-articles-in-group group)) | |
23f87bed MB |
5289 | ;; Select only the "normal" subset of articles. |
5290 | (gnus-sorted-nunion | |
5291 | (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked) | |
5292 | gnus-newsgroup-unreads))) | |
eec82323 LMI |
5293 | (scored-list (gnus-killed-articles gnus-newsgroup-killed articles)) |
5294 | (scored (length scored-list)) | |
5295 | (number (length articles)) | |
5296 | (marked (+ (length gnus-newsgroup-marked) | |
5297 | (length gnus-newsgroup-dormant))) | |
5298 | (select | |
5299 | (cond | |
5300 | ((numberp read-all) | |
5301 | read-all) | |
23f87bed MB |
5302 | ((numberp gnus-newsgroup-display) |
5303 | gnus-newsgroup-display) | |
eec82323 LMI |
5304 | (t |
5305 | (condition-case () | |
5306 | (cond | |
5307 | ((and (or (<= scored marked) (= scored number)) | |
5308 | (numberp gnus-large-newsgroup) | |
5309 | (> number gnus-large-newsgroup)) | |
23f87bed MB |
5310 | (let* ((cursor-in-echo-area nil) |
5311 | (initial (gnus-parameter-large-newsgroup-initial | |
5312 | gnus-newsgroup-name)) | |
5313 | (input | |
5314 | (read-string | |
5315 | (format | |
5316 | "How many articles from %s (%s %d): " | |
5317 | (gnus-limit-string | |
5318 | (gnus-group-decoded-name gnus-newsgroup-name) | |
5319 | 35) | |
5320 | (if initial "max" "default") | |
5321 | number) | |
5322 | (if initial | |
5323 | (cons (number-to-string initial) | |
5324 | 0))))) | |
eec82323 LMI |
5325 | (if (string-match "^[ \t]*$" input) number input))) |
5326 | ((and (> scored marked) (< scored number) | |
5327 | (> (- scored number) 20)) | |
5328 | (let ((input | |
5329 | (read-string | |
5330 | (format "%s %s (%d scored, %d total): " | |
5331 | "How many articles from" | |
23f87bed MB |
5332 | (gnus-group-decoded-name group) |
5333 | scored number)))) | |
eec82323 LMI |
5334 | (if (string-match "^[ \t]*$" input) |
5335 | number input))) | |
5336 | (t number)) | |
d4dfaa19 DL |
5337 | (quit |
5338 | (message "Quit getting the articles to read") | |
5339 | nil)))))) | |
eec82323 LMI |
5340 | (setq select (if (stringp select) (string-to-number select) select)) |
5341 | (if (or (null select) (zerop select)) | |
5342 | select | |
5343 | (if (and (not (zerop scored)) (<= (abs select) scored)) | |
5344 | (progn | |
5345 | (setq articles (sort scored-list '<)) | |
5346 | (setq number (length articles))) | |
5347 | (setq articles (copy-sequence articles))) | |
5348 | ||
5349 | (when (< (abs select) number) | |
5350 | (if (< select 0) | |
5351 | ;; Select the N oldest articles. | |
5352 | (setcdr (nthcdr (1- (abs select)) articles) nil) | |
5353 | ;; Select the N most recent articles. | |
5354 | (setq articles (nthcdr (- number select) articles)))) | |
5355 | (setq gnus-newsgroup-unselected | |
23f87bed | 5356 | (gnus-sorted-difference gnus-newsgroup-unreads articles)) |
16409b0b | 5357 | (when gnus-alter-articles-to-read-function |
23f87bed | 5358 | (setq articles |
a1506d29 | 5359 | (sort |
16409b0b | 5360 | (funcall gnus-alter-articles-to-read-function |
23f87bed | 5361 | gnus-newsgroup-name articles) |
16409b0b | 5362 | '<))) |
eec82323 LMI |
5363 | articles))) |
5364 | ||
5365 | (defun gnus-killed-articles (killed articles) | |
5366 | (let (out) | |
5367 | (while articles | |
5368 | (when (inline (gnus-member-of-range (car articles) killed)) | |
5369 | (push (car articles) out)) | |
5370 | (setq articles (cdr articles))) | |
5371 | out)) | |
5372 | ||
5373 | (defun gnus-uncompress-marks (marks) | |
5374 | "Uncompress the mark ranges in MARKS." | |
5375 | (let ((uncompressed '(score bookmark)) | |
5376 | out) | |
5377 | (while marks | |
5378 | (if (memq (caar marks) uncompressed) | |
5379 | (push (car marks) out) | |
5380 | (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out)) | |
5381 | (setq marks (cdr marks))) | |
5382 | out)) | |
5383 | ||
23f87bed MB |
5384 | (defun gnus-article-mark-to-type (mark) |
5385 | "Return the type of MARK." | |
5386 | (or (cadr (assq mark gnus-article-special-mark-lists)) | |
5387 | 'list)) | |
5388 | ||
5389 | (defun gnus-article-unpropagatable-p (mark) | |
5390 | "Return whether MARK should be propagated to back end." | |
5391 | (memq mark gnus-article-unpropagated-mark-lists)) | |
5392 | ||
eec82323 | 5393 | (defun gnus-adjust-marked-articles (info) |
16409b0b | 5394 | "Set all article lists and remove all marks that are no longer valid." |
eec82323 LMI |
5395 | (let* ((marked-lists (gnus-info-marks info)) |
5396 | (active (gnus-active (gnus-info-group info))) | |
5397 | (min (car active)) | |
5398 | (max (cdr active)) | |
5399 | (types gnus-article-mark-lists) | |
23f87bed | 5400 | marks var articles article mark mark-type) |
eec82323 | 5401 | |
23f87bed MB |
5402 | (dolist (marks marked-lists) |
5403 | (setq mark (car marks) | |
5404 | mark-type (gnus-article-mark-to-type mark) | |
5405 | var (intern (format "gnus-newsgroup-%s" (car (rassq mark types))))) | |
eec82323 | 5406 | |
23f87bed MB |
5407 | ;; We set the variable according to the type of the marks list, |
5408 | ;; and then adjust the marks to a subset of the active articles. | |
eec82323 LMI |
5409 | (cond |
5410 | ;; Adjust "simple" lists. | |
23f87bed MB |
5411 | ((eq mark-type 'list) |
5412 | (set var (setq articles (gnus-uncompress-range (cdr marks)))) | |
5413 | (when (memq mark '(tick dormant expire reply save)) | |
5414 | (while articles | |
5415 | (when (or (< (setq article (pop articles)) min) (> article max)) | |
5416 | (set var (delq article (symbol-value var))))))) | |
eec82323 | 5417 | ;; Adjust assocs. |
23f87bed MB |
5418 | ((eq mark-type 'tuple) |
5419 | (set var (setq articles (cdr marks))) | |
a8151ef7 LMI |
5420 | (when (not (listp (cdr (symbol-value var)))) |
5421 | (set var (list (symbol-value var)))) | |
5422 | (when (not (listp (cdr articles))) | |
5423 | (setq articles (list articles))) | |
eec82323 LMI |
5424 | (while articles |
5425 | (when (or (not (consp (setq article (pop articles)))) | |
5426 | (< (car article) min) | |
5427 | (> (car article) max)) | |
23f87bed MB |
5428 | (set var (delq article (symbol-value var)))))) |
5429 | ;; Adjust ranges (sloppily). | |
5430 | ((eq mark-type 'range) | |
5431 | (cond | |
5432 | ((eq mark 'seen) | |
5433 | ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2). | |
5434 | ;; It should be (seen (NUM1 . NUM2)). | |
5435 | (when (numberp (cddr marks)) | |
5436 | (setcdr marks (list (cdr marks)))) | |
5437 | (setq articles (cdr marks)) | |
5438 | (while (and articles | |
5439 | (or (and (consp (car articles)) | |
5440 | (> min (cdar articles))) | |
5441 | (and (numberp (car articles)) | |
5442 | (> min (car articles))))) | |
5443 | (pop articles)) | |
5444 | (set var articles)))))))) | |
eec82323 LMI |
5445 | |
5446 | (defun gnus-update-missing-marks (missing) | |
6748645f | 5447 | "Go through the list of MISSING articles and remove them from the mark lists." |
eec82323 | 5448 | (when missing |
23f87bed | 5449 | (let (var m) |
eec82323 | 5450 | ;; Go through all types. |
23f87bed MB |
5451 | (dolist (elem gnus-article-mark-lists) |
5452 | (when (eq (gnus-article-mark-to-type (cdr elem)) 'list) | |
5453 | (setq var (intern (format "gnus-newsgroup-%s" (car elem)))) | |
5454 | (when (symbol-value var) | |
5455 | ;; This list has articles. So we delete all missing | |
5456 | ;; articles from it. | |
5457 | (setq m missing) | |
5458 | (while m | |
5459 | (set var (delq (pop m) (symbol-value var)))))))))) | |
eec82323 LMI |
5460 | |
5461 | (defun gnus-update-marks () | |
5462 | "Enter the various lists of marked articles into the newsgroup info list." | |
5463 | (let ((types gnus-article-mark-lists) | |
5464 | (info (gnus-get-info gnus-newsgroup-name)) | |
16409b0b | 5465 | type list newmarked symbol delta-marks) |
eec82323 | 5466 | (when info |
16409b0b | 5467 | ;; Add all marks lists to the list of marks lists. |
eec82323 | 5468 | (while (setq type (pop types)) |
16409b0b GM |
5469 | (setq list (symbol-value |
5470 | (setq symbol | |
23f87bed | 5471 | (intern (format "gnus-newsgroup-%s" (car type)))))) |
eec82323 | 5472 | |
16409b0b | 5473 | (when list |
eec82323 LMI |
5474 | ;; Get rid of the entries of the articles that have the |
5475 | ;; default score. | |
5476 | (when (and (eq (cdr type) 'score) | |
5477 | gnus-save-score | |
5478 | list) | |
5479 | (let* ((arts list) | |
5480 | (prev (cons nil list)) | |
5481 | (all prev)) | |
5482 | (while arts | |
5483 | (if (or (not (consp (car arts))) | |
5484 | (= (cdar arts) gnus-summary-default-score)) | |
5485 | (setcdr prev (cdr arts)) | |
5486 | (setq prev arts)) | |
5487 | (setq arts (cdr arts))) | |
16409b0b GM |
5488 | (setq list (cdr all))))) |
5489 | ||
23f87bed MB |
5490 | (when (eq (cdr type) 'seen) |
5491 | (setq list (gnus-range-add list gnus-newsgroup-unseen))) | |
5492 | ||
5493 | (when (eq (gnus-article-mark-to-type (cdr type)) 'list) | |
16409b0b | 5494 | (setq list (gnus-compress-sequence (set symbol (sort list '<)) t))) |
a1506d29 | 5495 | |
23f87bed MB |
5496 | (when (and (gnus-check-backend-function |
5497 | 'request-set-mark gnus-newsgroup-name) | |
5498 | (not (gnus-article-unpropagatable-p (cdr type)))) | |
5499 | (let* ((old (cdr (assq (cdr type) (gnus-info-marks info)))) | |
5500 | (del (gnus-remove-from-range (gnus-copy-sequence old) list)) | |
5501 | (add (gnus-remove-from-range | |
5502 | (gnus-copy-sequence list) old))) | |
5503 | (when add | |
5504 | (push (list add 'add (list (cdr type))) delta-marks)) | |
5505 | (when del | |
5506 | (push (list del 'del (list (cdr type))) delta-marks)))) | |
a1506d29 | 5507 | |
16409b0b GM |
5508 | (when list |
5509 | (push (cons (cdr type) list) newmarked))) | |
5510 | ||
5511 | (when delta-marks | |
5512 | (unless (gnus-check-group gnus-newsgroup-name) | |
5513 | (error "Can't open server for %s" gnus-newsgroup-name)) | |
5514 | (gnus-request-set-mark gnus-newsgroup-name delta-marks)) | |
a1506d29 | 5515 | |
eec82323 LMI |
5516 | ;; Enter these new marks into the info of the group. |
5517 | (if (nthcdr 3 info) | |
5518 | (setcar (nthcdr 3 info) newmarked) | |
5519 | ;; Add the marks lists to the end of the info. | |
5520 | (when newmarked | |
5521 | (setcdr (nthcdr 2 info) (list newmarked)))) | |
5522 | ||
5523 | ;; Cut off the end of the info if there's nothing else there. | |
5524 | (let ((i 5)) | |
5525 | (while (and (> i 2) | |
5526 | (not (nth i info))) | |
5527 | (when (nthcdr (decf i) info) | |
5528 | (setcdr (nthcdr i info) nil))))))) | |
5529 | ||
5530 | (defun gnus-set-mode-line (where) | |
16409b0b | 5531 | "Set the mode line of the article or summary buffers. |
eec82323 LMI |
5532 | If WHERE is `summary', the summary mode line format will be used." |
5533 | ;; Is this mode line one we keep updated? | |
16409b0b GM |
5534 | (when (and (memq where gnus-updated-mode-lines) |
5535 | (symbol-value | |
5536 | (intern (format "gnus-%s-mode-line-format-spec" where)))) | |
eec82323 LMI |
5537 | (let (mode-string) |
5538 | (save-excursion | |
5539 | ;; We evaluate this in the summary buffer since these | |
5540 | ;; variables are buffer-local to that buffer. | |
5541 | (set-buffer gnus-summary-buffer) | |
23f87bed | 5542 | ;; We bind all these variables that are used in the `eval' form |
eec82323 LMI |
5543 | ;; below. |
5544 | (let* ((mformat (symbol-value | |
5545 | (intern | |
5546 | (format "gnus-%s-mode-line-format-spec" where)))) | |
23f87bed MB |
5547 | (gnus-tmp-group-name (gnus-group-decoded-name |
5548 | gnus-newsgroup-name)) | |
eec82323 LMI |
5549 | (gnus-tmp-article-number (or gnus-current-article 0)) |
5550 | (gnus-tmp-unread gnus-newsgroup-unreads) | |
5551 | (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads)) | |
5552 | (gnus-tmp-unselected (length gnus-newsgroup-unselected)) | |
5553 | (gnus-tmp-unread-and-unselected | |
5554 | (cond ((and (zerop gnus-tmp-unread-and-unticked) | |
5555 | (zerop gnus-tmp-unselected)) | |
5556 | "") | |
5557 | ((zerop gnus-tmp-unselected) | |
5558 | (format "{%d more}" gnus-tmp-unread-and-unticked)) | |
5559 | (t (format "{%d(+%d) more}" | |
5560 | gnus-tmp-unread-and-unticked | |
5561 | gnus-tmp-unselected)))) | |
5562 | (gnus-tmp-subject | |
5563 | (if (and gnus-current-headers | |
5564 | (vectorp gnus-current-headers)) | |
5565 | (gnus-mode-string-quote | |
5566 | (mail-header-subject gnus-current-headers)) | |
5567 | "")) | |
5568 | bufname-length max-len | |
23f87bed | 5569 | gnus-tmp-header) ;; passed as argument to any user-format-funcs |
eec82323 LMI |
5570 | (setq mode-string (eval mformat)) |
5571 | (setq bufname-length (if (string-match "%b" mode-string) | |
5572 | (- (length | |
5573 | (buffer-name | |
5574 | (if (eq where 'summary) | |
5575 | nil | |
5576 | (get-buffer gnus-article-buffer)))) | |
5577 | 2) | |
5578 | 0)) | |
5579 | (setq max-len (max 4 (if gnus-mode-non-string-length | |
5580 | (- (window-width) | |
5581 | gnus-mode-non-string-length | |
5582 | bufname-length) | |
5583 | (length mode-string)))) | |
5584 | ;; We might have to chop a bit of the string off... | |
5585 | (when (> (length mode-string) max-len) | |
5586 | (setq mode-string | |
16409b0b | 5587 | (concat (truncate-string-to-width mode-string (- max-len 3)) |
eec82323 LMI |
5588 | "..."))) |
5589 | ;; Pad the mode string a bit. | |
5590 | (setq mode-string (format (format "%%-%ds" max-len) mode-string)))) | |
5591 | ;; Update the mode line. | |
5592 | (setq mode-line-buffer-identification | |
5593 | (gnus-mode-line-buffer-identification (list mode-string))) | |
5594 | (set-buffer-modified-p t)))) | |
5595 | ||
5596 | (defun gnus-create-xref-hashtb (from-newsgroup headers unreads) | |
5597 | "Go through the HEADERS list and add all Xrefs to a hash table. | |
5598 | The resulting hash table is returned, or nil if no Xrefs were found." | |
5599 | (let* ((virtual (gnus-virtual-group-p from-newsgroup)) | |
5600 | (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup))) | |
5601 | (xref-hashtb (gnus-make-hashtable)) | |
5602 | start group entry number xrefs header) | |
5603 | (while headers | |
5604 | (setq header (pop headers)) | |
5605 | (when (and (setq xrefs (mail-header-xref header)) | |
5606 | (not (memq (setq number (mail-header-number header)) | |
5607 | unreads))) | |
5608 | (setq start 0) | |
5609 | (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start) | |
5610 | (setq start (match-end 0)) | |
5611 | (setq group (if prefix | |
5612 | (concat prefix (substring xrefs (match-beginning 1) | |
5613 | (match-end 1))) | |
5614 | (substring xrefs (match-beginning 1) (match-end 1)))) | |
5615 | (setq number | |
5616 | (string-to-int (substring xrefs (match-beginning 2) | |
5617 | (match-end 2)))) | |
5618 | (if (setq entry (gnus-gethash group xref-hashtb)) | |
5619 | (setcdr entry (cons number (cdr entry))) | |
5620 | (gnus-sethash group (cons number nil) xref-hashtb))))) | |
5621 | (and start xref-hashtb))) | |
5622 | ||
5623 | (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads) | |
5624 | "Look through all the headers and mark the Xrefs as read." | |
5625 | (let ((virtual (gnus-virtual-group-p from-newsgroup)) | |
5626 | name entry info xref-hashtb idlist method nth4) | |
5627 | (save-excursion | |
5628 | (set-buffer gnus-group-buffer) | |
5629 | (when (setq xref-hashtb | |
5630 | (gnus-create-xref-hashtb from-newsgroup headers unreads)) | |
5631 | (mapatoms | |
5632 | (lambda (group) | |
5633 | (unless (string= from-newsgroup (setq name (symbol-name group))) | |
5634 | (setq idlist (symbol-value group)) | |
5635 | ;; Dead groups are not updated. | |
5636 | (and (prog1 | |
5637 | (setq entry (gnus-gethash name gnus-newsrc-hashtb) | |
5638 | info (nth 2 entry)) | |
5639 | (when (stringp (setq nth4 (gnus-info-method info))) | |
5640 | (setq nth4 (gnus-server-to-method nth4)))) | |
5641 | ;; Only do the xrefs if the group has the same | |
5642 | ;; select method as the group we have just read. | |
5643 | (or (gnus-methods-equal-p | |
5644 | nth4 (gnus-find-method-for-group from-newsgroup)) | |
5645 | virtual | |
5646 | (equal nth4 (setq method (gnus-find-method-for-group | |
5647 | from-newsgroup))) | |
5648 | (and (equal (car nth4) (car method)) | |
5649 | (equal (nth 1 nth4) (nth 1 method)))) | |
5650 | gnus-use-cross-reference | |
5651 | (or (not (eq gnus-use-cross-reference t)) | |
5652 | virtual | |
5653 | ;; Only do cross-references on subscribed | |
5654 | ;; groups, if that is what is wanted. | |
5655 | (<= (gnus-info-level info) gnus-level-subscribed)) | |
5656 | (gnus-group-make-articles-read name idlist)))) | |
5657 | xref-hashtb))))) | |
5658 | ||
6748645f LMI |
5659 | (defun gnus-compute-read-articles (group articles) |
5660 | (let* ((entry (gnus-gethash group gnus-newsrc-hashtb)) | |
5661 | (info (nth 2 entry)) | |
5662 | (active (gnus-active group)) | |
5663 | ninfo) | |
5664 | (when entry | |
16409b0b | 5665 | ;; First peel off all invalid article numbers. |
6748645f LMI |
5666 | (when active |
5667 | (let ((ids articles) | |
5668 | id first) | |
5669 | (while (setq id (pop ids)) | |
5670 | (when (and first (> id (cdr active))) | |
5671 | ;; We'll end up in this situation in one particular | |
5672 | ;; obscure situation. If you re-scan a group and get | |
5673 | ;; a new article that is cross-posted to a different | |
5674 | ;; group that has not been re-scanned, you might get | |
5675 | ;; crossposted article that has a higher number than | |
5676 | ;; Gnus believes possible. So we re-activate this | |
5677 | ;; group as well. This might mean doing the | |
5678 | ;; crossposting thingy will *increase* the number | |
5679 | ;; of articles in some groups. Tsk, tsk. | |
5680 | (setq active (or (gnus-activate-group group) active))) | |
5681 | (when (or (> id (cdr active)) | |
5682 | (< id (car active))) | |
5683 | (setq articles (delq id articles)))))) | |
5684 | ;; If the read list is nil, we init it. | |
5685 | (if (and active | |
5686 | (null (gnus-info-read info)) | |
5687 | (> (car active) 1)) | |
5688 | (setq ninfo (cons 1 (1- (car active)))) | |
5689 | (setq ninfo (gnus-info-read info))) | |
5690 | ;; Then we add the read articles to the range. | |
5691 | (gnus-add-to-range | |
5692 | ninfo (setq articles (sort articles '<)))))) | |
5693 | ||
eec82323 LMI |
5694 | (defun gnus-group-make-articles-read (group articles) |
5695 | "Update the info of GROUP to say that ARTICLES are read." | |
5696 | (let* ((num 0) | |
5697 | (entry (gnus-gethash group gnus-newsrc-hashtb)) | |
5698 | (info (nth 2 entry)) | |
5699 | (active (gnus-active group)) | |
5700 | range) | |
6748645f LMI |
5701 | (when entry |
5702 | (setq range (gnus-compute-read-articles group articles)) | |
5703 | (save-excursion | |
5704 | (set-buffer gnus-group-buffer) | |
5705 | (gnus-undo-register | |
5706 | `(progn | |
5707 | (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
5708 | (gnus-info-set-read ',info ',(gnus-info-read info)) | |
5709 | (gnus-get-unread-articles-in-group ',info (gnus-active ,group)) | |
23f87bed | 5710 | (gnus-request-set-mark ,group (list (list ',range 'del '(read)))) |
6748645f LMI |
5711 | (gnus-group-update-group ,group t)))) |
5712 | ;; Add the read articles to the range. | |
5713 | (gnus-info-set-read info range) | |
23f87bed | 5714 | (gnus-request-set-mark group (list (list range 'add '(read)))) |
6748645f LMI |
5715 | ;; Then we have to re-compute how many unread |
5716 | ;; articles there are in this group. | |
5717 | (when active | |
5718 | (cond | |
5719 | ((not range) | |
5720 | (setq num (- (1+ (cdr active)) (car active)))) | |
5721 | ((not (listp (cdr range))) | |
5722 | (setq num (- (cdr active) (- (1+ (cdr range)) | |
5723 | (car range))))) | |
5724 | (t | |
5725 | (while range | |
5726 | (if (numberp (car range)) | |
5727 | (setq num (1+ num)) | |
5728 | (setq num (+ num (- (1+ (cdar range)) (caar range))))) | |
5729 | (setq range (cdr range))) | |
5730 | (setq num (- (cdr active) num)))) | |
5731 | ;; Update the number of unread articles. | |
5732 | (setcar entry num) | |
5733 | ;; Update the group buffer. | |
23f87bed MB |
5734 | (unless (gnus-ephemeral-group-p group) |
5735 | (gnus-group-update-group group t)))))) | |
eec82323 | 5736 | |
eec82323 LMI |
5737 | (defvar gnus-newsgroup-none-id 0) |
5738 | ||
5739 | (defun gnus-get-newsgroup-headers (&optional dependencies force-new) | |
5740 | (let ((cur nntp-server-buffer) | |
5741 | (dependencies | |
5742 | (or dependencies | |
5743 | (save-excursion (set-buffer gnus-summary-buffer) | |
5744 | gnus-newsgroup-dependencies))) | |
16409b0b GM |
5745 | headers id end ref |
5746 | (mail-parse-charset gnus-newsgroup-charset) | |
5747 | (mail-parse-ignored-charsets | |
5748 | (save-excursion (condition-case nil | |
5749 | (set-buffer gnus-summary-buffer) | |
5750 | (error)) | |
5751 | gnus-newsgroup-ignored-charsets))) | |
eec82323 LMI |
5752 | (save-excursion |
5753 | (set-buffer nntp-server-buffer) | |
5754 | ;; Translate all TAB characters into SPACE characters. | |
5755 | (subst-char-in-region (point-min) (point-max) ?\t ? t) | |
16409b0b | 5756 | (subst-char-in-region (point-min) (point-max) ?\r ? t) |
23f87bed | 5757 | (ietf-drums-unfold-fws) |
6748645f | 5758 | (gnus-run-hooks 'gnus-parse-headers-hook) |
eec82323 | 5759 | (let ((case-fold-search t) |
6748645f | 5760 | in-reply-to header p lines chars) |
eec82323 LMI |
5761 | (goto-char (point-min)) |
5762 | ;; Search to the beginning of the next header. Error messages | |
5763 | ;; do not begin with 2 or 3. | |
5764 | (while (re-search-forward "^[23][0-9]+ " nil t) | |
5765 | (setq id nil | |
5766 | ref nil) | |
5767 | ;; This implementation of this function, with nine | |
5768 | ;; search-forwards instead of the one re-search-forward and | |
5769 | ;; a case (which basically was the old function) is actually | |
5770 | ;; about twice as fast, even though it looks messier. You | |
5771 | ;; can't have everything, I guess. Speed and elegance | |
5772 | ;; doesn't always go hand in hand. | |
5773 | (setq | |
5774 | header | |
5775 | (vector | |
5776 | ;; Number. | |
5777 | (prog1 | |
5778 | (read cur) | |
5779 | (end-of-line) | |
5780 | (setq p (point)) | |
5781 | (narrow-to-region (point) | |
5782 | (or (and (search-forward "\n.\n" nil t) | |
5783 | (- (point) 2)) | |
5784 | (point)))) | |
5785 | ;; Subject. | |
5786 | (progn | |
5787 | (goto-char p) | |
23f87bed | 5788 | (if (search-forward "\nsubject:" nil t) |
16409b0b GM |
5789 | (funcall gnus-decode-encoded-word-function |
5790 | (nnheader-header-value)) | |
2bd3dcae | 5791 | "(none)")) |
eec82323 LMI |
5792 | ;; From. |
5793 | (progn | |
5794 | (goto-char p) | |
23f87bed | 5795 | (if (search-forward "\nfrom:" nil t) |
16409b0b GM |
5796 | (funcall gnus-decode-encoded-word-function |
5797 | (nnheader-header-value)) | |
2bd3dcae | 5798 | "(nobody)")) |
eec82323 LMI |
5799 | ;; Date. |
5800 | (progn | |
5801 | (goto-char p) | |
23f87bed | 5802 | (if (search-forward "\ndate:" nil t) |
eec82323 LMI |
5803 | (nnheader-header-value) "")) |
5804 | ;; Message-ID. | |
5805 | (progn | |
5806 | (goto-char p) | |
6748645f LMI |
5807 | (setq id (if (re-search-forward |
5808 | "^message-id: *\\(<[^\n\t> ]+>\\)" nil t) | |
5809 | ;; We do it this way to make sure the Message-ID | |
5810 | ;; is (somewhat) syntactically valid. | |
5811 | (buffer-substring (match-beginning 1) | |
5812 | (match-end 1)) | |
eec82323 LMI |
5813 | ;; If there was no message-id, we just fake one |
5814 | ;; to make subsequent routines simpler. | |
5815 | (nnheader-generate-fake-message-id)))) | |
5816 | ;; References. | |
5817 | (progn | |
5818 | (goto-char p) | |
23f87bed | 5819 | (if (search-forward "\nreferences:" nil t) |
eec82323 LMI |
5820 | (progn |
5821 | (setq end (point)) | |
5822 | (prog1 | |
5823 | (nnheader-header-value) | |
5824 | (setq ref | |
5825 | (buffer-substring | |
5826 | (progn | |
5827 | (end-of-line) | |
5828 | (search-backward ">" end t) | |
5829 | (1+ (point))) | |
5830 | (progn | |
5831 | (search-backward "<" end t) | |
5832 | (point)))))) | |
5833 | ;; Get the references from the in-reply-to header if there | |
5834 | ;; were no references and the in-reply-to header looks | |
5835 | ;; promising. | |
23f87bed | 5836 | (if (and (search-forward "\nin-reply-to:" nil t) |
eec82323 LMI |
5837 | (setq in-reply-to (nnheader-header-value)) |
5838 | (string-match "<[^>]+>" in-reply-to)) | |
6748645f LMI |
5839 | (let (ref2) |
5840 | (setq ref (substring in-reply-to (match-beginning 0) | |
5841 | (match-end 0))) | |
5842 | (while (string-match "<[^>]+>" in-reply-to (match-end 0)) | |
5843 | (setq ref2 (substring in-reply-to (match-beginning 0) | |
5844 | (match-end 0))) | |
5845 | (when (> (length ref2) (length ref)) | |
5846 | (setq ref ref2))) | |
5847 | ref) | |
eec82323 LMI |
5848 | (setq ref nil)))) |
5849 | ;; Chars. | |
6748645f LMI |
5850 | (progn |
5851 | (goto-char p) | |
5852 | (if (search-forward "\nchars: " nil t) | |
5853 | (if (numberp (setq chars (ignore-errors (read cur)))) | |
23f87bed MB |
5854 | chars -1) |
5855 | -1)) | |
eec82323 LMI |
5856 | ;; Lines. |
5857 | (progn | |
5858 | (goto-char p) | |
5859 | (if (search-forward "\nlines: " nil t) | |
a8151ef7 | 5860 | (if (numberp (setq lines (ignore-errors (read cur)))) |
23f87bed MB |
5861 | lines -1) |
5862 | -1)) | |
eec82323 LMI |
5863 | ;; Xref. |
5864 | (progn | |
5865 | (goto-char p) | |
23f87bed | 5866 | (and (search-forward "\nxref:" nil t) |
16409b0b GM |
5867 | (nnheader-header-value))) |
5868 | ;; Extra. | |
5869 | (when gnus-extra-headers | |
5870 | (let ((extra gnus-extra-headers) | |
5871 | out) | |
5872 | (while extra | |
5873 | (goto-char p) | |
5874 | (when (search-forward | |
23f87bed | 5875 | (concat "\n" (symbol-name (car extra)) ":") nil t) |
16409b0b GM |
5876 | (push (cons (car extra) (nnheader-header-value)) |
5877 | out)) | |
5878 | (pop extra)) | |
5879 | out)))) | |
eec82323 LMI |
5880 | (when (equal id ref) |
5881 | (setq ref nil)) | |
6748645f LMI |
5882 | |
5883 | (when gnus-alter-header-function | |
5884 | (funcall gnus-alter-header-function header) | |
5885 | (setq id (mail-header-id header) | |
5886 | ref (gnus-parent-id (mail-header-references header)))) | |
5887 | ||
5888 | (when (setq header | |
5889 | (gnus-dependencies-add-header | |
5890 | header dependencies force-new)) | |
eec82323 LMI |
5891 | (push header headers)) |
5892 | (goto-char (point-max)) | |
5893 | (widen)) | |
5894 | (nreverse headers))))) | |
5895 | ||
eec82323 LMI |
5896 | ;; Goes through the xover lines and returns a list of vectors |
5897 | (defun gnus-get-newsgroup-headers-xover (sequence &optional | |
5898 | force-new dependencies | |
5899 | group also-fetch-heads) | |
16409b0b GM |
5900 | "Parse the news overview data in the server buffer. |
5901 | Return a list of headers that match SEQUENCE (see | |
5902 | `nntp-retrieve-headers')." | |
eec82323 LMI |
5903 | ;; Get the Xref when the users reads the articles since most/some |
5904 | ;; NNTP servers do not include Xrefs when using XOVER. | |
5905 | (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs)) | |
16409b0b GM |
5906 | (let ((mail-parse-charset gnus-newsgroup-charset) |
5907 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets) | |
5908 | (cur nntp-server-buffer) | |
eec82323 | 5909 | (dependencies (or dependencies gnus-newsgroup-dependencies)) |
23f87bed MB |
5910 | (allp (cond |
5911 | ((eq gnus-read-all-available-headers t) | |
5912 | t) | |
5913 | ((stringp gnus-read-all-available-headers) | |
5914 | (string-match gnus-read-all-available-headers group)) | |
5915 | (t | |
5916 | nil))) | |
eec82323 LMI |
5917 | number headers header) |
5918 | (save-excursion | |
5919 | (set-buffer nntp-server-buffer) | |
16409b0b | 5920 | (subst-char-in-region (point-min) (point-max) ?\r ? t) |
eec82323 | 5921 | ;; Allow the user to mangle the headers before parsing them. |
6748645f | 5922 | (gnus-run-hooks 'gnus-parse-headers-hook) |
eec82323 | 5923 | (goto-char (point-min)) |
23f87bed MB |
5924 | (gnus-parse-without-error |
5925 | (while (and (or sequence allp) | |
5926 | (not (eobp))) | |
5927 | (setq number (read cur)) | |
5928 | (when (not allp) | |
5929 | (while (and sequence | |
5930 | (< (car sequence) number)) | |
5931 | (setq sequence (cdr sequence)))) | |
5932 | (when (and (or allp | |
5933 | (and sequence | |
5934 | (eq number (car sequence)))) | |
5935 | (progn | |
5936 | (setq sequence (cdr sequence)) | |
5937 | (setq header (inline | |
5938 | (gnus-nov-parse-line | |
5939 | number dependencies force-new))))) | |
5940 | (push header headers)) | |
5941 | (forward-line 1))) | |
eec82323 LMI |
5942 | ;; A common bug in inn is that if you have posted an article and |
5943 | ;; then retrieves the active file, it will answer correctly -- | |
5944 | ;; the new article is included. However, a NOV entry for the | |
5945 | ;; article may not have been generated yet, so this may fail. | |
5946 | ;; We work around this problem by retrieving the last few | |
5947 | ;; headers using HEAD. | |
5948 | (if (or (not also-fetch-heads) | |
5949 | (not sequence)) | |
5950 | ;; We (probably) got all the headers. | |
5951 | (nreverse headers) | |
5952 | (let ((gnus-nov-is-evil t)) | |
5953 | (nconc | |
5954 | (nreverse headers) | |
23f87bed | 5955 | (when (eq (gnus-retrieve-headers sequence group) 'headers) |
eec82323 LMI |
5956 | (gnus-get-newsgroup-headers)))))))) |
5957 | ||
5958 | (defun gnus-article-get-xrefs () | |
5959 | "Fill in the Xref value in `gnus-current-headers', if necessary. | |
5960 | This is meant to be called in `gnus-article-internal-prepare-hook'." | |
5961 | (let ((headers (save-excursion (set-buffer gnus-summary-buffer) | |
5962 | gnus-current-headers))) | |
5963 | (or (not gnus-use-cross-reference) | |
5964 | (not headers) | |
5965 | (and (mail-header-xref headers) | |
5966 | (not (string= (mail-header-xref headers) ""))) | |
5967 | (let ((case-fold-search t) | |
5968 | xref) | |
5969 | (save-restriction | |
5970 | (nnheader-narrow-to-headers) | |
5971 | (goto-char (point-min)) | |
16409b0b GM |
5972 | (when (or (and (not (eobp)) |
5973 | (eq (downcase (char-after)) ?x) | |
eec82323 LMI |
5974 | (looking-at "Xref:")) |
5975 | (search-forward "\nXref:" nil t)) | |
5976 | (goto-char (1+ (match-end 0))) | |
23f87bed | 5977 | (setq xref (buffer-substring (point) (gnus-point-at-eol))) |
eec82323 LMI |
5978 | (mail-header-set-xref headers xref))))))) |
5979 | ||
5980 | (defun gnus-summary-insert-subject (id &optional old-header use-old-header) | |
6748645f LMI |
5981 | "Find article ID and insert the summary line for that article. |
5982 | OLD-HEADER can either be a header or a line number to insert | |
5983 | the subject line on." | |
5984 | (let* ((line (and (numberp old-header) old-header)) | |
5985 | (old-header (and (vectorp old-header) old-header)) | |
5986 | (header (cond ((and old-header use-old-header) | |
16409b0b GM |
5987 | old-header) |
5988 | ((and (numberp id) | |
5989 | (gnus-number-to-header id)) | |
5990 | (gnus-number-to-header id)) | |
5991 | (t | |
5992 | (gnus-read-header id)))) | |
5993 | (number (and (numberp id) id)) | |
5994 | d) | |
eec82323 LMI |
5995 | (when header |
5996 | ;; Rebuild the thread that this article is part of and go to the | |
5997 | ;; article we have fetched. | |
5998 | (when (and (not gnus-show-threads) | |
5999 | old-header) | |
6748645f LMI |
6000 | (when (and number |
6001 | (setq d (gnus-data-find (mail-header-number old-header)))) | |
eec82323 LMI |
6002 | (goto-char (gnus-data-pos d)) |
6003 | (gnus-data-remove | |
6004 | number | |
6005 | (- (gnus-point-at-bol) | |
6006 | (prog1 | |
6007 | (1+ (gnus-point-at-eol)) | |
6008 | (gnus-delete-line)))))) | |
23f87bed MB |
6009 | ;; Remove list identifiers from subject. |
6010 | (when gnus-list-identifiers | |
6011 | (let ((gnus-newsgroup-headers (list header))) | |
6012 | (gnus-summary-remove-list-identifiers) | |
6013 | (setq header (car gnus-newsgroup-headers)))) | |
eec82323 LMI |
6014 | (when old-header |
6015 | (mail-header-set-number header (mail-header-number old-header))) | |
6016 | (setq gnus-newsgroup-sparse | |
6017 | (delq (setq number (mail-header-number header)) | |
6018 | gnus-newsgroup-sparse)) | |
6019 | (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient)) | |
6748645f LMI |
6020 | (push number gnus-newsgroup-limit) |
6021 | (gnus-rebuild-thread (mail-header-id header) line) | |
eec82323 LMI |
6022 | (gnus-summary-goto-subject number nil t)) |
6023 | (when (and (numberp number) | |
6024 | (> number 0)) | |
6025 | ;; We have to update the boundaries even if we can't fetch the | |
6026 | ;; article if ID is a number -- so that the next `P' or `N' | |
6027 | ;; command will fetch the previous (or next) article even | |
6028 | ;; if the one we tried to fetch this time has been canceled. | |
6029 | (when (> number gnus-newsgroup-end) | |
6030 | (setq gnus-newsgroup-end number)) | |
6031 | (when (< number gnus-newsgroup-begin) | |
6032 | (setq gnus-newsgroup-begin number)) | |
6033 | (setq gnus-newsgroup-unselected | |
6034 | (delq number gnus-newsgroup-unselected))) | |
6035 | ;; Report back a success? | |
6036 | (and header (mail-header-number header)))) | |
6037 | ||
6038 | ;;; Process/prefix in the summary buffer | |
6039 | ||
6040 | (defun gnus-summary-work-articles (n) | |
6748645f LMI |
6041 | "Return a list of articles to be worked upon. |
6042 | The prefix argument, the list of process marked articles, and the | |
6043 | current article will be taken into consideration." | |
6044 | (save-excursion | |
6045 | (set-buffer gnus-summary-buffer) | |
6046 | (cond | |
6047 | (n | |
6048 | ;; A numerical prefix has been given. | |
6049 | (setq n (prefix-numeric-value n)) | |
6050 | (let ((backward (< n 0)) | |
6051 | (n (abs (prefix-numeric-value n))) | |
6052 | articles article) | |
6053 | (save-excursion | |
6054 | (while | |
6055 | (and (> n 0) | |
6056 | (push (setq article (gnus-summary-article-number)) | |
6057 | articles) | |
6058 | (if backward | |
6059 | (gnus-summary-find-prev nil article) | |
6060 | (gnus-summary-find-next nil article))) | |
6061 | (decf n))) | |
6062 | (nreverse articles))) | |
6063 | ((and (gnus-region-active-p) (mark)) | |
6064 | (message "region active") | |
6065 | ;; Work on the region between point and mark. | |
6066 | (let ((max (max (point) (mark))) | |
6067 | articles article) | |
6068 | (save-excursion | |
6069 | (goto-char (min (min (point) (mark)))) | |
6070 | (while | |
6071 | (and | |
6072 | (push (setq article (gnus-summary-article-number)) articles) | |
6073 | (gnus-summary-find-next nil article) | |
6074 | (< (point) max))) | |
6075 | (nreverse articles)))) | |
6076 | (gnus-newsgroup-processable | |
6077 | ;; There are process-marked articles present. | |
6078 | ;; Save current state. | |
6079 | (gnus-summary-save-process-mark) | |
6080 | ;; Return the list. | |
6081 | (reverse gnus-newsgroup-processable)) | |
6082 | (t | |
6083 | ;; Just return the current article. | |
6084 | (list (gnus-summary-article-number)))))) | |
6085 | ||
6086 | (defmacro gnus-summary-iterate (arg &rest forms) | |
6087 | "Iterate over the process/prefixed articles and do FORMS. | |
6088 | ARG is the interactive prefix given to the command. FORMS will be | |
6089 | executed with point over the summary line of the articles." | |
6090 | (let ((articles (make-symbol "gnus-summary-iterate-articles"))) | |
6091 | `(let ((,articles (gnus-summary-work-articles ,arg))) | |
6092 | (while ,articles | |
6093 | (gnus-summary-goto-subject (car ,articles)) | |
16409b0b GM |
6094 | ,@forms |
6095 | (pop ,articles))))) | |
6748645f LMI |
6096 | |
6097 | (put 'gnus-summary-iterate 'lisp-indent-function 1) | |
6098 | (put 'gnus-summary-iterate 'edebug-form-spec '(form body)) | |
eec82323 LMI |
6099 | |
6100 | (defun gnus-summary-save-process-mark () | |
6101 | "Push the current set of process marked articles on the stack." | |
6102 | (interactive) | |
6103 | (push (copy-sequence gnus-newsgroup-processable) | |
6104 | gnus-newsgroup-process-stack)) | |
6105 | ||
6106 | (defun gnus-summary-kill-process-mark () | |
6107 | "Push the current set of process marked articles on the stack and unmark." | |
6108 | (interactive) | |
6109 | (gnus-summary-save-process-mark) | |
6110 | (gnus-summary-unmark-all-processable)) | |
6111 | ||
6112 | (defun gnus-summary-yank-process-mark () | |
6113 | "Pop the last process mark state off the stack and restore it." | |
6114 | (interactive) | |
6115 | (unless gnus-newsgroup-process-stack | |
6116 | (error "Empty mark stack")) | |
6117 | (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack))) | |
6118 | ||
6119 | (defun gnus-summary-process-mark-set (set) | |
6120 | "Make SET into the current process marked articles." | |
6121 | (gnus-summary-unmark-all-processable) | |
6122 | (while set | |
6123 | (gnus-summary-set-process-mark (pop set)))) | |
6124 | ||
6125 | ;;; Searching and stuff | |
6126 | ||
6127 | (defun gnus-summary-search-group (&optional backward use-level) | |
6128 | "Search for next unread newsgroup. | |
6129 | If optional argument BACKWARD is non-nil, search backward instead." | |
6130 | (save-excursion | |
6131 | (set-buffer gnus-group-buffer) | |
6132 | (when (gnus-group-search-forward | |
6133 | backward nil (if use-level (gnus-group-group-level) nil)) | |
6134 | (gnus-group-group-name)))) | |
6135 | ||
6136 | (defun gnus-summary-best-group (&optional exclude-group) | |
6137 | "Find the name of the best unread group. | |
6138 | If EXCLUDE-GROUP, do not go to this group." | |
6139 | (save-excursion | |
6140 | (set-buffer gnus-group-buffer) | |
6141 | (save-excursion | |
6142 | (gnus-group-best-unread-group exclude-group)))) | |
6143 | ||
23f87bed MB |
6144 | (defun gnus-summary-find-next (&optional unread article backward) |
6145 | (if backward | |
6146 | (gnus-summary-find-prev unread article) | |
eec82323 LMI |
6147 | (let* ((dummy (gnus-summary-article-intangible-p)) |
6148 | (article (or article (gnus-summary-article-number))) | |
23f87bed | 6149 | (data (gnus-data-find-list article)) |
eec82323 LMI |
6150 | result) |
6151 | (when (and (not dummy) | |
6152 | (or (not gnus-summary-check-current) | |
6153 | (not unread) | |
23f87bed MB |
6154 | (not (gnus-data-unread-p (car data))))) |
6155 | (setq data (cdr data))) | |
eec82323 LMI |
6156 | (when (setq result |
6157 | (if unread | |
6158 | (progn | |
23f87bed MB |
6159 | (while data |
6160 | (unless (memq (gnus-data-number (car data)) | |
6161 | (cond | |
6162 | ((eq gnus-auto-goto-ignores | |
6163 | 'always-undownloaded) | |
6164 | gnus-newsgroup-undownloaded) | |
6165 | (gnus-plugged | |
6166 | nil) | |
6167 | ((eq gnus-auto-goto-ignores | |
6168 | 'unfetched) | |
6169 | gnus-newsgroup-unfetched) | |
6170 | ((eq gnus-auto-goto-ignores | |
6171 | 'undownloaded) | |
6172 | gnus-newsgroup-undownloaded))) | |
6173 | (when (gnus-data-unread-p (car data)) | |
6174 | (setq result (car data) | |
6175 | data nil))) | |
6176 | (setq data (cdr data))) | |
eec82323 | 6177 | result) |
23f87bed | 6178 | (car data))) |
eec82323 LMI |
6179 | (goto-char (gnus-data-pos result)) |
6180 | (gnus-data-number result))))) | |
6181 | ||
6182 | (defun gnus-summary-find-prev (&optional unread article) | |
6183 | (let* ((eobp (eobp)) | |
6184 | (article (or article (gnus-summary-article-number))) | |
23f87bed | 6185 | (data (gnus-data-find-list article (gnus-data-list 'rev))) |
eec82323 LMI |
6186 | result) |
6187 | (when (and (not eobp) | |
6188 | (or (not gnus-summary-check-current) | |
6189 | (not unread) | |
23f87bed MB |
6190 | (not (gnus-data-unread-p (car data))))) |
6191 | (setq data (cdr data))) | |
eec82323 LMI |
6192 | (when (setq result |
6193 | (if unread | |
6194 | (progn | |
23f87bed MB |
6195 | (while data |
6196 | (unless (memq (gnus-data-number (car data)) | |
6197 | (cond | |
6198 | ((eq gnus-auto-goto-ignores | |
6199 | 'always-undownloaded) | |
6200 | gnus-newsgroup-undownloaded) | |
6201 | (gnus-plugged | |
6202 | nil) | |
6203 | ((eq gnus-auto-goto-ignores | |
6204 | 'unfetched) | |
6205 | gnus-newsgroup-unfetched) | |
6206 | ((eq gnus-auto-goto-ignores | |
6207 | 'undownloaded) | |
6208 | gnus-newsgroup-undownloaded))) | |
6209 | (when (gnus-data-unread-p (car data)) | |
6210 | (setq result (car data) | |
6211 | data nil))) | |
6212 | (setq data (cdr data))) | |
eec82323 | 6213 | result) |
23f87bed | 6214 | (car data))) |
eec82323 LMI |
6215 | (goto-char (gnus-data-pos result)) |
6216 | (gnus-data-number result)))) | |
6217 | ||
6218 | (defun gnus-summary-find-subject (subject &optional unread backward article) | |
6219 | (let* ((simp-subject (gnus-simplify-subject-fully subject)) | |
6220 | (article (or article (gnus-summary-article-number))) | |
6221 | (articles (gnus-data-list backward)) | |
6222 | (arts (gnus-data-find-list article articles)) | |
6223 | result) | |
6224 | (when (or (not gnus-summary-check-current) | |
6225 | (not unread) | |
6226 | (not (gnus-data-unread-p (car arts)))) | |
6227 | (setq arts (cdr arts))) | |
6228 | (while arts | |
6229 | (and (or (not unread) | |
6230 | (gnus-data-unread-p (car arts))) | |
6231 | (vectorp (gnus-data-header (car arts))) | |
6232 | (gnus-subject-equal | |
6233 | simp-subject (mail-header-subject (gnus-data-header (car arts))) t) | |
6234 | (setq result (car arts) | |
6235 | arts nil)) | |
6236 | (setq arts (cdr arts))) | |
6237 | (and result | |
6238 | (goto-char (gnus-data-pos result)) | |
6239 | (gnus-data-number result)))) | |
6240 | ||
6241 | (defun gnus-summary-search-forward (&optional unread subject backward) | |
6242 | "Search forward for an article. | |
6243 | If UNREAD, look for unread articles. If SUBJECT, look for | |
6244 | articles with that subject. If BACKWARD, search backward instead." | |
6245 | (cond (subject (gnus-summary-find-subject subject unread backward)) | |
6246 | (backward (gnus-summary-find-prev unread)) | |
6247 | (t (gnus-summary-find-next unread)))) | |
6248 | ||
6249 | (defun gnus-recenter (&optional n) | |
6250 | "Center point in window and redisplay frame. | |
6251 | Also do horizontal recentering." | |
6252 | (interactive "P") | |
6253 | (when (and gnus-auto-center-summary | |
6254 | (not (eq gnus-auto-center-summary 'vertical))) | |
6255 | (gnus-horizontal-recenter)) | |
6256 | (recenter n)) | |
6257 | ||
6258 | (defun gnus-summary-recenter () | |
6259 | "Center point in the summary window. | |
6260 | If `gnus-auto-center-summary' is nil, or the article buffer isn't | |
6261 | displayed, no centering will be performed." | |
6262 | ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
6263 | ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu. | |
16409b0b | 6264 | (interactive) |
23f87bed MB |
6265 | ;; The user has to want it. |
6266 | (when gnus-auto-center-summary | |
6267 | (let* ((top (cond ((< (window-height) 4) 0) | |
6268 | ((< (window-height) 7) 1) | |
6269 | (t (if (numberp gnus-auto-center-summary) | |
6270 | gnus-auto-center-summary | |
6271 | 2)))) | |
6272 | (height (1- (window-height))) | |
6273 | (bottom (save-excursion (goto-char (point-max)) | |
6274 | (forward-line (- height)) | |
6275 | (point))) | |
6276 | (window (get-buffer-window (current-buffer)))) | |
eec82323 LMI |
6277 | (when (get-buffer-window gnus-article-buffer) |
6278 | ;; Only do recentering when the article buffer is displayed, | |
6279 | ;; Set the window start to either `bottom', which is the biggest | |
6280 | ;; possible valid number, or the second line from the top, | |
6281 | ;; whichever is the least. | |
db7ebd73 MB |
6282 | (let ((top-pos (save-excursion (forward-line (- top)) (point)))) |
6283 | (if (> bottom top-pos) | |
6284 | ;; Keep the second line from the top visible | |
6285 | (set-window-start window top-pos t) | |
6286 | ;; Try to keep the bottom line visible; if it's partially | |
6287 | ;; obscured, either scroll one more line to make it fully | |
6288 | ;; visible, or revert to using TOP-POS. | |
6289 | (save-excursion | |
6290 | (goto-char (point-max)) | |
6291 | (forward-line -1) | |
6292 | (let ((last-line-start (point))) | |
6293 | (goto-char bottom) | |
6294 | (set-window-start window (point) t) | |
6295 | (when (not (pos-visible-in-window-p last-line-start window)) | |
6296 | (forward-line 1) | |
6297 | (set-window-start window (min (point) top-pos) t))))))) | |
eec82323 LMI |
6298 | ;; Do horizontal recentering while we're at it. |
6299 | (when (and (get-buffer-window (current-buffer) t) | |
6300 | (not (eq gnus-auto-center-summary 'vertical))) | |
6301 | (let ((selected (selected-window))) | |
6302 | (select-window (get-buffer-window (current-buffer) t)) | |
6303 | (gnus-summary-position-point) | |
6304 | (gnus-horizontal-recenter) | |
6305 | (select-window selected)))))) | |
6306 | ||
6307 | (defun gnus-summary-jump-to-group (newsgroup) | |
6308 | "Move point to NEWSGROUP in group mode buffer." | |
6309 | ;; Keep update point of group mode buffer if visible. | |
6310 | (if (eq (current-buffer) (get-buffer gnus-group-buffer)) | |
6311 | (save-window-excursion | |
6312 | ;; Take care of tree window mode. | |
6313 | (when (get-buffer-window gnus-group-buffer) | |
6314 | (pop-to-buffer gnus-group-buffer)) | |
6315 | (gnus-group-jump-to-group newsgroup)) | |
6316 | (save-excursion | |
6317 | ;; Take care of tree window mode. | |
6318 | (if (get-buffer-window gnus-group-buffer) | |
6319 | (pop-to-buffer gnus-group-buffer) | |
6320 | (set-buffer gnus-group-buffer)) | |
6321 | (gnus-group-jump-to-group newsgroup)))) | |
6322 | ||
6323 | ;; This function returns a list of article numbers based on the | |
6324 | ;; difference between the ranges of read articles in this group and | |
6325 | ;; the range of active articles. | |
6326 | (defun gnus-list-of-unread-articles (group) | |
6327 | (let* ((read (gnus-info-read (gnus-get-info group))) | |
6328 | (active (or (gnus-active group) (gnus-activate-group group))) | |
6329 | (last (cdr active)) | |
6330 | first nlast unread) | |
6331 | ;; If none are read, then all are unread. | |
6332 | (if (not read) | |
6333 | (setq first (car active)) | |
6334 | ;; If the range of read articles is a single range, then the | |
6335 | ;; first unread article is the article after the last read | |
6336 | ;; article. Sounds logical, doesn't it? | |
16409b0b GM |
6337 | (if (and (not (listp (cdr read))) |
6338 | (or (< (car read) (car active)) | |
6339 | (progn (setq read (list read)) | |
6340 | nil))) | |
6748645f | 6341 | (setq first (max (car active) (1+ (cdr read)))) |
eec82323 LMI |
6342 | ;; `read' is a list of ranges. |
6343 | (when (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
6344 | (caar read))) | |
6345 | 1) | |
6748645f | 6346 | (setq first (car active))) |
eec82323 LMI |
6347 | (while read |
6348 | (when first | |
6349 | (while (< first nlast) | |
6350 | (push first unread) | |
6351 | (setq first (1+ first)))) | |
6352 | (setq first (1+ (if (atom (car read)) (car read) (cdar read)))) | |
6353 | (setq nlast (if (atom (cadr read)) (cadr read) (caadr read))) | |
6354 | (setq read (cdr read))))) | |
6355 | ;; And add the last unread articles. | |
6356 | (while (<= first last) | |
6357 | (push first unread) | |
6358 | (setq first (1+ first))) | |
6359 | ;; Return the list of unread articles. | |
6748645f | 6360 | (delq 0 (nreverse unread)))) |
eec82323 LMI |
6361 | |
6362 | (defun gnus-list-of-read-articles (group) | |
6363 | "Return a list of unread, unticked and non-dormant articles." | |
6364 | (let* ((info (gnus-get-info group)) | |
6365 | (marked (gnus-info-marks info)) | |
6366 | (active (gnus-active group))) | |
6367 | (and info active | |
23f87bed MB |
6368 | (gnus-list-range-difference |
6369 | (gnus-list-range-difference | |
6370 | (gnus-sorted-complement | |
6371 | (gnus-uncompress-range active) | |
6372 | (gnus-list-of-unread-articles group)) | |
6373 | (cdr (assq 'dormant marked))) | |
6374 | (cdr (assq 'tick marked)))))) | |
eec82323 LMI |
6375 | |
6376 | ;; Various summary commands | |
6377 | ||
6748645f LMI |
6378 | (defun gnus-summary-select-article-buffer () |
6379 | "Reconfigure windows to show article buffer." | |
6380 | (interactive) | |
6381 | (if (not (gnus-buffer-live-p gnus-article-buffer)) | |
6382 | (error "There is no article buffer for this summary buffer") | |
6383 | (gnus-configure-windows 'article) | |
6384 | (select-window (get-buffer-window gnus-article-buffer)))) | |
6385 | ||
eec82323 LMI |
6386 | (defun gnus-summary-universal-argument (arg) |
6387 | "Perform any operation on all articles that are process/prefixed." | |
6388 | (interactive "P") | |
eec82323 LMI |
6389 | (let ((articles (gnus-summary-work-articles arg)) |
6390 | func article) | |
6391 | (if (eq | |
6392 | (setq | |
6393 | func | |
6394 | (key-binding | |
6395 | (read-key-sequence | |
6396 | (substitute-command-keys | |
16409b0b | 6397 | "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]")))) |
eec82323 LMI |
6398 | 'undefined) |
6399 | (gnus-error 1 "Undefined key") | |
6400 | (save-excursion | |
6401 | (while articles | |
6402 | (gnus-summary-goto-subject (setq article (pop articles))) | |
6403 | (let (gnus-newsgroup-processable) | |
6404 | (command-execute func)) | |
6405 | (gnus-summary-remove-process-mark article))))) | |
6406 | (gnus-summary-position-point)) | |
6407 | ||
6408 | (defun gnus-summary-toggle-truncation (&optional arg) | |
6409 | "Toggle truncation of summary lines. | |
23f87bed | 6410 | With ARG, turn line truncation on if ARG is positive." |
eec82323 LMI |
6411 | (interactive "P") |
6412 | (setq truncate-lines | |
6413 | (if (null arg) (not truncate-lines) | |
6414 | (> (prefix-numeric-value arg) 0))) | |
6415 | (redraw-display)) | |
6416 | ||
23f87bed MB |
6417 | (defun gnus-summary-find-for-reselect () |
6418 | "Return the number of an article to stay on across a reselect. | |
6419 | The current article is considered, then following articles, then previous | |
6420 | articles. An article is sought which is not cancelled and isn't a temporary | |
6421 | insertion from another group. If there's no such then return a dummy 0." | |
6422 | (let (found) | |
6423 | (dolist (rev '(nil t)) | |
6424 | (unless found ; don't demand the reverse list if we don't need it | |
6425 | (let ((data (gnus-data-find-list | |
6426 | (gnus-summary-article-number) (gnus-data-list rev)))) | |
6427 | (while (and data (not found)) | |
6428 | (if (and (< 0 (gnus-data-number (car data))) | |
6429 | (not (eq gnus-canceled-mark (gnus-data-mark (car data))))) | |
6430 | (setq found (gnus-data-number (car data)))) | |
6431 | (setq data (cdr data)))))) | |
6432 | (or found 0))) | |
6433 | ||
eec82323 LMI |
6434 | (defun gnus-summary-reselect-current-group (&optional all rescan) |
6435 | "Exit and then reselect the current newsgroup. | |
6436 | The prefix argument ALL means to select all articles." | |
6437 | (interactive "P") | |
eec82323 LMI |
6438 | (when (gnus-ephemeral-group-p gnus-newsgroup-name) |
6439 | (error "Ephemeral groups can't be reselected")) | |
23f87bed | 6440 | (let ((current-subject (gnus-summary-find-for-reselect)) |
eec82323 LMI |
6441 | (group gnus-newsgroup-name)) |
6442 | (setq gnus-newsgroup-begin nil) | |
23f87bed | 6443 | (gnus-summary-exit nil 'leave-hidden) |
eec82323 LMI |
6444 | ;; We have to adjust the point of group mode buffer because |
6445 | ;; point was moved to the next unread newsgroup by exiting. | |
6446 | (gnus-summary-jump-to-group group) | |
6447 | (when rescan | |
6448 | (save-excursion | |
6449 | (gnus-group-get-new-news-this-group 1))) | |
6450 | (gnus-group-read-group all t) | |
6451 | (gnus-summary-goto-subject current-subject nil t))) | |
6452 | ||
6453 | (defun gnus-summary-rescan-group (&optional all) | |
6454 | "Exit the newsgroup, ask for new articles, and select the newsgroup." | |
6455 | (interactive "P") | |
6456 | (gnus-summary-reselect-current-group all t)) | |
6457 | ||
6458 | (defun gnus-summary-update-info (&optional non-destructive) | |
6459 | (save-excursion | |
6460 | (let ((group gnus-newsgroup-name)) | |
6748645f LMI |
6461 | (when group |
6462 | (when gnus-newsgroup-kill-headers | |
6463 | (setq gnus-newsgroup-killed | |
6464 | (gnus-compress-sequence | |
23f87bed MB |
6465 | (gnus-sorted-union |
6466 | (gnus-list-range-intersection | |
6467 | gnus-newsgroup-unselected gnus-newsgroup-killed) | |
6468 | gnus-newsgroup-unreads) | |
6748645f LMI |
6469 | t))) |
6470 | (unless (listp (cdr gnus-newsgroup-killed)) | |
6471 | (setq gnus-newsgroup-killed (list gnus-newsgroup-killed))) | |
6472 | (let ((headers gnus-newsgroup-headers)) | |
6473 | ;; Set the new ranges of read articles. | |
6474 | (save-excursion | |
6475 | (set-buffer gnus-group-buffer) | |
6476 | (gnus-undo-force-boundary)) | |
6477 | (gnus-update-read-articles | |
23f87bed MB |
6478 | group (gnus-sorted-union |
6479 | gnus-newsgroup-unreads gnus-newsgroup-unselected)) | |
6748645f LMI |
6480 | ;; Set the current article marks. |
6481 | (let ((gnus-newsgroup-scored | |
6482 | (if (and (not gnus-save-score) | |
6483 | (not non-destructive)) | |
6484 | nil | |
6485 | gnus-newsgroup-scored))) | |
6486 | (save-excursion | |
6487 | (gnus-update-marks))) | |
6488 | ;; Do the cross-ref thing. | |
6489 | (when gnus-use-cross-reference | |
6490 | (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads)) | |
6491 | ;; Do not switch windows but change the buffer to work. | |
a8151ef7 | 6492 | (set-buffer gnus-group-buffer) |
6748645f LMI |
6493 | (unless (gnus-ephemeral-group-p group) |
6494 | (gnus-group-update-group group))))))) | |
eec82323 LMI |
6495 | |
6496 | (defun gnus-summary-save-newsrc (&optional force) | |
6497 | "Save the current number of read/marked articles in the dribble buffer. | |
6498 | The dribble buffer will then be saved. | |
6499 | If FORCE (the prefix), also save the .newsrc file(s)." | |
6500 | (interactive "P") | |
6501 | (gnus-summary-update-info t) | |
6502 | (if force | |
6503 | (gnus-save-newsrc-file) | |
6504 | (gnus-dribble-save))) | |
6505 | ||
23f87bed | 6506 | (defun gnus-summary-exit (&optional temporary leave-hidden) |
eec82323 | 6507 | "Exit reading current newsgroup, and then return to group selection mode. |
16409b0b | 6508 | `gnus-exit-group-hook' is called with no arguments if that value is non-nil." |
eec82323 LMI |
6509 | (interactive) |
6510 | (gnus-set-global-variables) | |
16409b0b GM |
6511 | (when (gnus-buffer-live-p gnus-article-buffer) |
6512 | (save-excursion | |
6513 | (set-buffer gnus-article-buffer) | |
6514 | (mm-destroy-parts gnus-article-mime-handles) | |
6515 | ;; Set it to nil for safety reason. | |
6516 | (setq gnus-article-mime-handle-alist nil) | |
6517 | (setq gnus-article-mime-handles nil))) | |
eec82323 | 6518 | (gnus-kill-save-kill-buffer) |
6748645f | 6519 | (gnus-async-halt-prefetch) |
eec82323 LMI |
6520 | (let* ((group gnus-newsgroup-name) |
6521 | (quit-config (gnus-group-quit-config gnus-newsgroup-name)) | |
23f87bed | 6522 | (gnus-group-is-exiting-p t) |
eec82323 | 6523 | (mode major-mode) |
23f87bed | 6524 | (group-point nil) |
eec82323 | 6525 | (buf (current-buffer))) |
16409b0b GM |
6526 | (unless quit-config |
6527 | ;; Do adaptive scoring, and possibly save score files. | |
6528 | (when gnus-newsgroup-adaptive | |
6529 | (gnus-score-adaptive)) | |
6530 | (when gnus-use-scoring | |
6531 | (gnus-score-save))) | |
6748645f | 6532 | (gnus-run-hooks 'gnus-summary-prepare-exit-hook) |
eec82323 LMI |
6533 | ;; If we have several article buffers, we kill them at exit. |
6534 | (unless gnus-single-article-buffer | |
6535 | (gnus-kill-buffer gnus-original-article-buffer) | |
6536 | (setq gnus-article-current nil)) | |
6537 | (when gnus-use-cache | |
6538 | (gnus-cache-possibly-remove-articles) | |
6539 | (gnus-cache-save-buffers)) | |
6540 | (gnus-async-prefetch-remove-group group) | |
6541 | (when gnus-suppress-duplicates | |
6542 | (gnus-dup-enter-articles)) | |
6543 | (when gnus-use-trees | |
6544 | (gnus-tree-close group)) | |
16409b0b GM |
6545 | (when gnus-use-cache |
6546 | (gnus-cache-write-active)) | |
6748645f LMI |
6547 | ;; Remove entries for this group. |
6548 | (nnmail-purge-split-history (gnus-group-real-name group)) | |
eec82323 LMI |
6549 | ;; Make all changes in this group permanent. |
6550 | (unless quit-config | |
6748645f | 6551 | (gnus-run-hooks 'gnus-exit-group-hook) |
16409b0b | 6552 | (gnus-summary-update-info)) |
eec82323 LMI |
6553 | (gnus-close-group group) |
6554 | ;; Make sure where we were, and go to next newsgroup. | |
6555 | (set-buffer gnus-group-buffer) | |
6556 | (unless quit-config | |
6557 | (gnus-group-jump-to-group group)) | |
6748645f LMI |
6558 | (gnus-run-hooks 'gnus-summary-exit-hook) |
6559 | (unless (or quit-config | |
6560 | ;; If this group has disappeared from the summary | |
6561 | ;; buffer, don't skip forwards. | |
6562 | (not (string= group (gnus-group-group-name)))) | |
eec82323 | 6563 | (gnus-group-next-unread-group 1)) |
a8151ef7 | 6564 | (setq group-point (point)) |
eec82323 LMI |
6565 | (if temporary |
6566 | nil ;Nothing to do. | |
6567 | ;; If we have several article buffers, we kill them at exit. | |
6568 | (unless gnus-single-article-buffer | |
6569 | (gnus-kill-buffer gnus-article-buffer) | |
6570 | (gnus-kill-buffer gnus-original-article-buffer) | |
6571 | (setq gnus-article-current nil)) | |
6572 | (set-buffer buf) | |
6573 | (if (not gnus-kill-summary-on-exit) | |
23f87bed MB |
6574 | (progn |
6575 | (gnus-deaden-summary) | |
6576 | (setq mode nil)) | |
eec82323 LMI |
6577 | ;; We set all buffer-local variables to nil. It is unclear why |
6578 | ;; this is needed, but if we don't, buffer-local variables are | |
6579 | ;; not garbage-collected, it seems. This would the lead to en | |
6580 | ;; ever-growing Emacs. | |
6581 | (gnus-summary-clear-local-variables) | |
23f87bed MB |
6582 | (let ((gnus-summary-local-variables gnus-newsgroup-variables)) |
6583 | (gnus-summary-clear-local-variables)) | |
eec82323 LMI |
6584 | (when (get-buffer gnus-article-buffer) |
6585 | (bury-buffer gnus-article-buffer)) | |
6586 | ;; We clear the global counterparts of the buffer-local | |
6587 | ;; variables as well, just to be on the safe side. | |
6588 | (set-buffer gnus-group-buffer) | |
6589 | (gnus-summary-clear-local-variables) | |
23f87bed MB |
6590 | (let ((gnus-summary-local-variables gnus-newsgroup-variables)) |
6591 | (gnus-summary-clear-local-variables)) | |
eec82323 LMI |
6592 | ;; Return to group mode buffer. |
6593 | (when (eq mode 'gnus-summary-mode) | |
6594 | (gnus-kill-buffer buf))) | |
6595 | (setq gnus-current-select-method gnus-select-method) | |
23f87bed MB |
6596 | (if leave-hidden |
6597 | (set-buffer gnus-group-buffer) | |
6598 | (pop-to-buffer gnus-group-buffer)) | |
eec82323 LMI |
6599 | (if (not quit-config) |
6600 | (progn | |
a8151ef7 | 6601 | (goto-char group-point) |
23f87bed MB |
6602 | (unless leave-hidden |
6603 | (gnus-configure-windows 'group 'force))) | |
eec82323 | 6604 | (gnus-handle-ephemeral-exit quit-config)) |
6748645f | 6605 | ;; Clear the current group name. |
eec82323 LMI |
6606 | (unless quit-config |
6607 | (setq gnus-newsgroup-name nil))))) | |
6608 | ||
6609 | (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update) | |
6610 | (defun gnus-summary-exit-no-update (&optional no-questions) | |
6611 | "Quit reading current newsgroup without updating read article info." | |
6612 | (interactive) | |
eec82323 | 6613 | (let* ((group gnus-newsgroup-name) |
23f87bed MB |
6614 | (gnus-group-is-exiting-p t) |
6615 | (gnus-group-is-exiting-without-update-p t) | |
eec82323 LMI |
6616 | (quit-config (gnus-group-quit-config group))) |
6617 | (when (or no-questions | |
6618 | gnus-expert-user | |
6619 | (gnus-y-or-n-p "Discard changes to this group and exit? ")) | |
6748645f | 6620 | (gnus-async-halt-prefetch) |
23f87bed | 6621 | (run-hooks 'gnus-summary-prepare-exit-hook) |
16409b0b GM |
6622 | (when (gnus-buffer-live-p gnus-article-buffer) |
6623 | (save-excursion | |
6624 | (set-buffer gnus-article-buffer) | |
6625 | (mm-destroy-parts gnus-article-mime-handles) | |
6626 | ;; Set it to nil for safety reason. | |
6627 | (setq gnus-article-mime-handle-alist nil) | |
6628 | (setq gnus-article-mime-handles nil))) | |
eec82323 LMI |
6629 | ;; If we have several article buffers, we kill them at exit. |
6630 | (unless gnus-single-article-buffer | |
6631 | (gnus-kill-buffer gnus-article-buffer) | |
6632 | (gnus-kill-buffer gnus-original-article-buffer) | |
6633 | (setq gnus-article-current nil)) | |
6634 | (if (not gnus-kill-summary-on-exit) | |
6635 | (gnus-deaden-summary) | |
6636 | (gnus-close-group group) | |
6637 | (gnus-summary-clear-local-variables) | |
23f87bed MB |
6638 | (let ((gnus-summary-local-variables gnus-newsgroup-variables)) |
6639 | (gnus-summary-clear-local-variables)) | |
eec82323 LMI |
6640 | (set-buffer gnus-group-buffer) |
6641 | (gnus-summary-clear-local-variables) | |
23f87bed MB |
6642 | (let ((gnus-summary-local-variables gnus-newsgroup-variables)) |
6643 | (gnus-summary-clear-local-variables)) | |
6644 | (gnus-kill-buffer gnus-summary-buffer)) | |
eec82323 LMI |
6645 | (unless gnus-single-article-buffer |
6646 | (setq gnus-article-current nil)) | |
6647 | (when gnus-use-trees | |
6648 | (gnus-tree-close group)) | |
6649 | (gnus-async-prefetch-remove-group group) | |
6650 | (when (get-buffer gnus-article-buffer) | |
6651 | (bury-buffer gnus-article-buffer)) | |
6652 | ;; Return to the group buffer. | |
6653 | (gnus-configure-windows 'group 'force) | |
6654 | ;; Clear the current group name. | |
6655 | (setq gnus-newsgroup-name nil) | |
23f87bed MB |
6656 | (unless (gnus-ephemeral-group-p group) |
6657 | (gnus-group-update-group group)) | |
eec82323 LMI |
6658 | (when (equal (gnus-group-group-name) group) |
6659 | (gnus-group-next-unread-group 1)) | |
6660 | (when quit-config | |
23f87bed | 6661 | (gnus-handle-ephemeral-exit quit-config))))) |
eec82323 LMI |
6662 | |
6663 | (defun gnus-handle-ephemeral-exit (quit-config) | |
6748645f LMI |
6664 | "Handle movement when leaving an ephemeral group. |
6665 | The state which existed when entering the ephemeral is reset." | |
eec82323 LMI |
6666 | (if (not (buffer-name (car quit-config))) |
6667 | (gnus-configure-windows 'group 'force) | |
6668 | (set-buffer (car quit-config)) | |
6669 | (cond ((eq major-mode 'gnus-summary-mode) | |
23f87bed MB |
6670 | (gnus-set-global-variables)) |
6671 | ((eq major-mode 'gnus-article-mode) | |
6672 | (save-excursion | |
6673 | ;; The `gnus-summary-buffer' variable may point | |
6674 | ;; to the old summary buffer when using a single | |
6675 | ;; article buffer. | |
6676 | (unless (gnus-buffer-live-p gnus-summary-buffer) | |
6677 | (set-buffer gnus-group-buffer)) | |
6678 | (set-buffer gnus-summary-buffer) | |
6679 | (gnus-set-global-variables)))) | |
eec82323 | 6680 | (if (or (eq (cdr quit-config) 'article) |
23f87bed MB |
6681 | (eq (cdr quit-config) 'pick)) |
6682 | (progn | |
6683 | ;; The current article may be from the ephemeral group | |
6684 | ;; thus it is best that we reload this article | |
6685 | ;; | |
6686 | ;; If we're exiting from a large digest, this can be | |
6687 | ;; extremely slow. So, it's better not to reload it. -- jh. | |
6688 | ;;(gnus-summary-show-article) | |
6689 | (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode)) | |
6690 | (gnus-configure-windows 'pick 'force) | |
6691 | (gnus-configure-windows (cdr quit-config) 'force))) | |
eec82323 LMI |
6692 | (gnus-configure-windows (cdr quit-config) 'force)) |
6693 | (when (eq major-mode 'gnus-summary-mode) | |
6694 | (gnus-summary-next-subject 1 nil t) | |
6695 | (gnus-summary-recenter) | |
6696 | (gnus-summary-position-point)))) | |
6697 | ||
6698 | ;;; Dead summaries. | |
6699 | ||
6700 | (defvar gnus-dead-summary-mode-map nil) | |
6701 | ||
6702 | (unless gnus-dead-summary-mode-map | |
6703 | (setq gnus-dead-summary-mode-map (make-keymap)) | |
6704 | (suppress-keymap gnus-dead-summary-mode-map) | |
6705 | (substitute-key-definition | |
6706 | 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map) | |
23f87bed MB |
6707 | (dolist (key '("\C-d" "\r" "\177" [delete])) |
6708 | (define-key gnus-dead-summary-mode-map | |
6709 | key 'gnus-summary-wake-up-the-dead)) | |
6710 | (dolist (key '("q" "Q")) | |
6711 | (define-key gnus-dead-summary-mode-map key 'bury-buffer))) | |
eec82323 LMI |
6712 | |
6713 | (defvar gnus-dead-summary-mode nil | |
6714 | "Minor mode for Gnus summary buffers.") | |
6715 | ||
6716 | (defun gnus-dead-summary-mode (&optional arg) | |
6717 | "Minor mode for Gnus summary buffers." | |
6718 | (interactive "P") | |
6719 | (when (eq major-mode 'gnus-summary-mode) | |
6720 | (make-local-variable 'gnus-dead-summary-mode) | |
6721 | (setq gnus-dead-summary-mode | |
6722 | (if (null arg) (not gnus-dead-summary-mode) | |
6723 | (> (prefix-numeric-value arg) 0))) | |
6724 | (when gnus-dead-summary-mode | |
a8151ef7 LMI |
6725 | (gnus-add-minor-mode |
6726 | 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map)))) | |
eec82323 LMI |
6727 | |
6728 | (defun gnus-deaden-summary () | |
6729 | "Make the current summary buffer into a dead summary buffer." | |
6730 | ;; Kill any previous dead summary buffer. | |
6731 | (when (and gnus-dead-summary | |
6732 | (buffer-name gnus-dead-summary)) | |
6733 | (save-excursion | |
6734 | (set-buffer gnus-dead-summary) | |
6735 | (when gnus-dead-summary-mode | |
6736 | (kill-buffer (current-buffer))))) | |
6737 | ;; Make this the current dead summary. | |
6738 | (setq gnus-dead-summary (current-buffer)) | |
6739 | (gnus-dead-summary-mode 1) | |
6740 | (let ((name (buffer-name))) | |
6741 | (when (string-match "Summary" name) | |
6742 | (rename-buffer | |
6743 | (concat (substring name 0 (match-beginning 0)) "Dead " | |
6744 | (substring name (match-beginning 0))) | |
16409b0b GM |
6745 | t) |
6746 | (bury-buffer)))) | |
eec82323 LMI |
6747 | |
6748 | (defun gnus-kill-or-deaden-summary (buffer) | |
6749 | "Kill or deaden the summary BUFFER." | |
6748645f LMI |
6750 | (save-excursion |
6751 | (when (and (buffer-name buffer) | |
6752 | (not gnus-single-article-buffer)) | |
6753 | (save-excursion | |
6754 | (set-buffer buffer) | |
6755 | (gnus-kill-buffer gnus-article-buffer) | |
6756 | (gnus-kill-buffer gnus-original-article-buffer))) | |
23f87bed MB |
6757 | (cond |
6758 | ;; Kill the buffer. | |
6759 | (gnus-kill-summary-on-exit | |
6760 | (when (and gnus-use-trees | |
6761 | (gnus-buffer-exists-p buffer)) | |
6762 | (save-excursion | |
6763 | (set-buffer buffer) | |
6764 | (gnus-tree-close gnus-newsgroup-name))) | |
6765 | (gnus-kill-buffer buffer)) | |
6766 | ;; Deaden the buffer. | |
6767 | ((gnus-buffer-exists-p buffer) | |
6768 | (save-excursion | |
6769 | (set-buffer buffer) | |
6770 | (gnus-deaden-summary)))))) | |
eec82323 LMI |
6771 | |
6772 | (defun gnus-summary-wake-up-the-dead (&rest args) | |
6773 | "Wake up the dead summary buffer." | |
6774 | (interactive) | |
6775 | (gnus-dead-summary-mode -1) | |
6776 | (let ((name (buffer-name))) | |
6777 | (when (string-match "Dead " name) | |
6778 | (rename-buffer | |
6779 | (concat (substring name 0 (match-beginning 0)) | |
6780 | (substring name (match-end 0))) | |
6781 | t))) | |
6782 | (gnus-message 3 "This dead summary is now alive again")) | |
6783 | ||
6784 | ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>. | |
6785 | (defun gnus-summary-fetch-faq (&optional faq-dir) | |
6786 | "Fetch the FAQ for the current group. | |
6787 | If FAQ-DIR (the prefix), prompt for a directory to search for the faq | |
6788 | in." | |
6789 | (interactive | |
6790 | (list | |
6791 | (when current-prefix-arg | |
6792 | (completing-read | |
8f688cb0 | 6793 | "FAQ dir: " (and (listp gnus-group-faq-directory) |
a8151ef7 LMI |
6794 | (mapcar (lambda (file) (list file)) |
6795 | gnus-group-faq-directory)))))) | |
eec82323 LMI |
6796 | (let (gnus-faq-buffer) |
6797 | (when (setq gnus-faq-buffer | |
6798 | (gnus-group-fetch-faq gnus-newsgroup-name faq-dir)) | |
6799 | (gnus-configure-windows 'summary-faq)))) | |
6800 | ||
6801 | ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. | |
6802 | (defun gnus-summary-describe-group (&optional force) | |
6803 | "Describe the current newsgroup." | |
6804 | (interactive "P") | |
6805 | (gnus-group-describe-group force gnus-newsgroup-name)) | |
6806 | ||
6807 | (defun gnus-summary-describe-briefly () | |
6808 | "Describe summary mode commands briefly." | |
6809 | (interactive) | |
16409b0b | 6810 | (gnus-message 6 (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"))) |
eec82323 LMI |
6811 | |
6812 | ;; Walking around group mode buffer from summary mode. | |
6813 | ||
6814 | (defun gnus-summary-next-group (&optional no-article target-group backward) | |
6815 | "Exit current newsgroup and then select next unread newsgroup. | |
6816 | If prefix argument NO-ARTICLE is non-nil, no article is selected | |
23f87bed | 6817 | initially. If TARGET-GROUP, go to this group. If BACKWARD, go to |
eec82323 LMI |
6818 | previous group instead." |
6819 | (interactive "P") | |
eec82323 LMI |
6820 | ;; Stop pre-fetching. |
6821 | (gnus-async-halt-prefetch) | |
6822 | (let ((current-group gnus-newsgroup-name) | |
6823 | (current-buffer (current-buffer)) | |
6824 | entered) | |
6825 | ;; First we semi-exit this group to update Xrefs and all variables. | |
6826 | ;; We can't do a real exit, because the window conf must remain | |
6827 | ;; the same in case the user is prompted for info, and we don't | |
6828 | ;; want the window conf to change before that... | |
6829 | (gnus-summary-exit t) | |
6830 | (while (not entered) | |
6831 | ;; Then we find what group we are supposed to enter. | |
6832 | (set-buffer gnus-group-buffer) | |
6833 | (gnus-group-jump-to-group current-group) | |
6834 | (setq target-group | |
6835 | (or target-group | |
6836 | (if (eq gnus-keep-same-level 'best) | |
6837 | (gnus-summary-best-group gnus-newsgroup-name) | |
6838 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
6839 | (if (not target-group) | |
6840 | ;; There are no further groups, so we return to the group | |
6841 | ;; buffer. | |
6842 | (progn | |
6843 | (gnus-message 5 "Returning to the group buffer") | |
6844 | (setq entered t) | |
6845 | (when (gnus-buffer-live-p current-buffer) | |
6846 | (set-buffer current-buffer) | |
6847 | (gnus-summary-exit)) | |
6748645f | 6848 | (gnus-run-hooks 'gnus-group-no-more-groups-hook)) |
eec82323 LMI |
6849 | ;; We try to enter the target group. |
6850 | (gnus-group-jump-to-group target-group) | |
6851 | (let ((unreads (gnus-group-group-unread))) | |
6852 | (if (and (or (eq t unreads) | |
6853 | (and unreads (not (zerop unreads)))) | |
23f87bed MB |
6854 | (gnus-summary-read-group |
6855 | target-group nil no-article | |
6856 | (and (buffer-name current-buffer) current-buffer) | |
6857 | nil backward)) | |
eec82323 LMI |
6858 | (setq entered t) |
6859 | (setq current-group target-group | |
6860 | target-group nil))))))) | |
6861 | ||
6862 | (defun gnus-summary-prev-group (&optional no-article) | |
6863 | "Exit current newsgroup and then select previous unread newsgroup. | |
6864 | If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
6865 | (interactive "P") | |
6866 | (gnus-summary-next-group no-article nil t)) | |
6867 | ||
6868 | ;; Walking around summary lines. | |
6869 | ||
23f87bed MB |
6870 | (defun gnus-summary-first-subject (&optional unread undownloaded unseen) |
6871 | "Go to the first subject satisfying any non-nil constraint. | |
6872 | If UNREAD is non-nil, the article should be unread. | |
6873 | If UNDOWNLOADED is non-nil, the article should be undownloaded. | |
6874 | If UNSEEN is non-nil, the article should be unseen. | |
6875 | Returns the article selected or nil if there are no matching articles." | |
eec82323 | 6876 | (interactive "P") |
23f87bed MB |
6877 | (cond |
6878 | ;; Empty summary. | |
6879 | ((null gnus-newsgroup-data) | |
6880 | (gnus-message 3 "No articles in the group") | |
6881 | nil) | |
6882 | ;; Pick the first article. | |
6883 | ((not (or unread undownloaded unseen)) | |
6884 | (goto-char (gnus-data-pos (car gnus-newsgroup-data))) | |
6885 | (gnus-data-number (car gnus-newsgroup-data))) | |
6886 | ;; Find the first unread article. | |
6887 | (t | |
6888 | (let ((data gnus-newsgroup-data)) | |
6889 | (while (and data | |
6890 | (let ((num (gnus-data-number (car data)))) | |
6891 | (or (memq num gnus-newsgroup-unfetched) | |
6892 | (not (or (and unread | |
6893 | (memq num gnus-newsgroup-unreads)) | |
6894 | (and undownloaded | |
6895 | (memq num gnus-newsgroup-undownloaded)) | |
6896 | (and unseen | |
6897 | (memq num gnus-newsgroup-unseen))))))) | |
6898 | (setq data (cdr data))) | |
6899 | (prog1 | |
6900 | (if data | |
6901 | (progn | |
6902 | (goto-char (gnus-data-pos (car data))) | |
6903 | (gnus-data-number (car data))) | |
6904 | (gnus-message 3 "No more%s articles" | |
6905 | (let* ((r (when unread " unread")) | |
6906 | (d (when undownloaded " undownloaded")) | |
6907 | (s (when unseen " unseen")) | |
6908 | (l (delq nil (list r d s)))) | |
6909 | (cond ((= 3 (length l)) | |
6910 | (concat r "," d ", or" s)) | |
6911 | ((= 2 (length l)) | |
6912 | (concat (car l) ", or" (cadr l))) | |
6913 | ((= 1 (length l)) | |
6914 | (car l)) | |
6915 | (t | |
6916 | "")))) | |
6917 | nil | |
6918 | ) | |
6919 | (gnus-summary-position-point)))))) | |
eec82323 LMI |
6920 | |
6921 | (defun gnus-summary-next-subject (n &optional unread dont-display) | |
6922 | "Go to next N'th summary line. | |
6923 | If N is negative, go to the previous N'th subject line. | |
6924 | If UNREAD is non-nil, only unread articles are selected. | |
6925 | The difference between N and the actual number of steps taken is | |
6926 | returned." | |
6927 | (interactive "p") | |
6928 | (let ((backward (< n 0)) | |
6929 | (n (abs n))) | |
6930 | (while (and (> n 0) | |
6931 | (if backward | |
6932 | (gnus-summary-find-prev unread) | |
6933 | (gnus-summary-find-next unread))) | |
16409b0b GM |
6934 | (unless (zerop (setq n (1- n))) |
6935 | (gnus-summary-show-thread))) | |
eec82323 LMI |
6936 | (when (/= 0 n) |
6937 | (gnus-message 7 "No more%s articles" | |
6938 | (if unread " unread" ""))) | |
6939 | (unless dont-display | |
6940 | (gnus-summary-recenter) | |
6941 | (gnus-summary-position-point)) | |
6942 | n)) | |
6943 | ||
6944 | (defun gnus-summary-next-unread-subject (n) | |
6945 | "Go to next N'th unread summary line." | |
6946 | (interactive "p") | |
6947 | (gnus-summary-next-subject n t)) | |
6948 | ||
6949 | (defun gnus-summary-prev-subject (n &optional unread) | |
6950 | "Go to previous N'th summary line. | |
6951 | If optional argument UNREAD is non-nil, only unread article is selected." | |
6952 | (interactive "p") | |
6953 | (gnus-summary-next-subject (- n) unread)) | |
6954 | ||
6955 | (defun gnus-summary-prev-unread-subject (n) | |
6956 | "Go to previous N'th unread summary line." | |
6957 | (interactive "p") | |
6958 | (gnus-summary-next-subject (- n) t)) | |
6959 | ||
23f87bed MB |
6960 | (defun gnus-summary-goto-subjects (articles) |
6961 | "Insert the subject header for ARTICLES in the current buffer." | |
6962 | (save-excursion | |
6963 | (dolist (article articles) | |
6964 | (gnus-summary-goto-subject article t))) | |
6965 | (gnus-summary-limit (append articles gnus-newsgroup-limit)) | |
6966 | (gnus-summary-position-point)) | |
6967 | ||
eec82323 LMI |
6968 | (defun gnus-summary-goto-subject (article &optional force silent) |
6969 | "Go the subject line of ARTICLE. | |
6970 | If FORCE, also allow jumping to articles not currently shown." | |
6971 | (interactive "nArticle number: ") | |
23f87bed MB |
6972 | (unless (numberp article) |
6973 | (error "Article %s is not a number" article)) | |
eec82323 LMI |
6974 | (let ((b (point)) |
6975 | (data (gnus-data-find article))) | |
6976 | ;; We read in the article if we have to. | |
6977 | (and (not data) | |
6978 | force | |
6748645f LMI |
6979 | (gnus-summary-insert-subject |
6980 | article | |
6981 | (if (or (numberp force) (vectorp force)) force) | |
6982 | t) | |
eec82323 LMI |
6983 | (setq data (gnus-data-find article))) |
6984 | (goto-char b) | |
6985 | (if (not data) | |
6986 | (progn | |
6987 | (unless silent | |
6988 | (gnus-message 3 "Can't find article %d" article)) | |
6989 | nil) | |
23f87bed MB |
6990 | (let ((pt (gnus-data-pos data))) |
6991 | (goto-char pt) | |
6992 | (gnus-summary-set-article-display-arrow pt)) | |
6748645f | 6993 | (gnus-summary-position-point) |
eec82323 LMI |
6994 | article))) |
6995 | ||
6996 | ;; Walking around summary lines with displaying articles. | |
6997 | ||
6998 | (defun gnus-summary-expand-window (&optional arg) | |
6999 | "Make the summary buffer take up the entire Emacs frame. | |
7000 | Given a prefix, will force an `article' buffer configuration." | |
7001 | (interactive "P") | |
eec82323 LMI |
7002 | (if arg |
7003 | (gnus-configure-windows 'article 'force) | |
7004 | (gnus-configure-windows 'summary 'force))) | |
7005 | ||
7006 | (defun gnus-summary-display-article (article &optional all-header) | |
7007 | "Display ARTICLE in article buffer." | |
d4dfaa19 DL |
7008 | (when (gnus-buffer-live-p gnus-article-buffer) |
7009 | (with-current-buffer gnus-article-buffer | |
87545352 | 7010 | (mm-enable-multibyte))) |
eec82323 | 7011 | (gnus-set-global-variables) |
23f87bed MB |
7012 | (when (gnus-buffer-live-p gnus-article-buffer) |
7013 | (with-current-buffer gnus-article-buffer | |
7014 | (setq gnus-article-charset gnus-newsgroup-charset) | |
7015 | (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets) | |
7016 | (mm-enable-multibyte))) | |
eec82323 LMI |
7017 | (if (null article) |
7018 | nil | |
7019 | (prog1 | |
7020 | (if gnus-summary-display-article-function | |
7021 | (funcall gnus-summary-display-article-function article all-header) | |
7022 | (gnus-article-prepare article all-header)) | |
6748645f | 7023 | (gnus-run-hooks 'gnus-select-article-hook) |
eec82323 LMI |
7024 | (when (and gnus-current-article |
7025 | (not (zerop gnus-current-article))) | |
7026 | (gnus-summary-goto-subject gnus-current-article)) | |
7027 | (gnus-summary-recenter) | |
7028 | (when (and gnus-use-trees gnus-show-threads) | |
7029 | (gnus-possibly-generate-tree article) | |
7030 | (gnus-highlight-selected-tree article)) | |
7031 | ;; Successfully display article. | |
7032 | (gnus-article-set-window-start | |
7033 | (cdr (assq article gnus-newsgroup-bookmarks)))))) | |
7034 | ||
7035 | (defun gnus-summary-select-article (&optional all-headers force pseudo article) | |
7036 | "Select the current article. | |
7037 | If ALL-HEADERS is non-nil, show all header fields. If FORCE is | |
7038 | non-nil, the article will be re-fetched even if it already present in | |
7039 | the article buffer. If PSEUDO is non-nil, pseudo-articles will also | |
7040 | be displayed." | |
7041 | ;; Make sure we are in the summary buffer to work around bbdb bug. | |
7042 | (unless (eq major-mode 'gnus-summary-mode) | |
7043 | (set-buffer gnus-summary-buffer)) | |
7044 | (let ((article (or article (gnus-summary-article-number))) | |
f0529b5b | 7045 | (all-headers (not (not all-headers))) ;Must be t or nil. |
16409b0b | 7046 | gnus-summary-display-article-function) |
eec82323 LMI |
7047 | (and (not pseudo) |
7048 | (gnus-summary-article-pseudo-p article) | |
a8151ef7 | 7049 | (error "This is a pseudo-article")) |
16409b0b GM |
7050 | (save-excursion |
7051 | (set-buffer gnus-summary-buffer) | |
7052 | (if (or (and gnus-single-article-buffer | |
7053 | (or (null gnus-current-article) | |
7054 | (null gnus-article-current) | |
7055 | (null (get-buffer gnus-article-buffer)) | |
7056 | (not (eq article (cdr gnus-article-current))) | |
7057 | (not (equal (car gnus-article-current) | |
7058 | gnus-newsgroup-name)))) | |
7059 | (and (not gnus-single-article-buffer) | |
7060 | (or (null gnus-current-article) | |
7061 | (not (eq gnus-current-article article)))) | |
7062 | force) | |
7063 | ;; The requested article is different from the current article. | |
7064 | (progn | |
16409b0b GM |
7065 | (gnus-summary-display-article article all-headers) |
7066 | (when (gnus-buffer-live-p gnus-article-buffer) | |
23f87bed | 7067 | (with-current-buffer gnus-article-buffer |
16409b0b | 7068 | (if (not gnus-article-decoded-p) ;; a local variable |
87545352 | 7069 | (mm-disable-multibyte)))) |
16409b0b GM |
7070 | (gnus-article-set-window-start |
7071 | (cdr (assq article gnus-newsgroup-bookmarks))) | |
7072 | article) | |
16409b0b | 7073 | 'old)))) |
eec82323 | 7074 | |
23f87bed MB |
7075 | (defun gnus-summary-force-verify-and-decrypt () |
7076 | "Display buttons for signed/encrypted parts and verify/decrypt them." | |
7077 | (interactive) | |
7078 | (let ((mm-verify-option 'known) | |
7079 | (mm-decrypt-option 'known) | |
7080 | (gnus-article-emulate-mime t) | |
7081 | (gnus-buttonized-mime-types (append (list "multipart/signed" | |
7082 | "multipart/encrypted") | |
7083 | gnus-buttonized-mime-types))) | |
7084 | (gnus-summary-select-article nil 'force))) | |
7085 | ||
eec82323 LMI |
7086 | (defun gnus-summary-set-current-mark (&optional current-mark) |
7087 | "Obsolete function." | |
7088 | nil) | |
7089 | ||
7090 | (defun gnus-summary-next-article (&optional unread subject backward push) | |
7091 | "Select the next article. | |
7092 | If UNREAD, only unread articles are selected. | |
7093 | If SUBJECT, only articles with SUBJECT are selected. | |
7094 | If BACKWARD, the previous article is selected instead of the next." | |
7095 | (interactive "P") | |
eec82323 LMI |
7096 | (cond |
7097 | ;; Is there such an article? | |
7098 | ((and (gnus-summary-search-forward unread subject backward) | |
7099 | (or (gnus-summary-display-article (gnus-summary-article-number)) | |
7100 | (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
7101 | (gnus-summary-position-point)) | |
7102 | ;; If not, we try the first unread, if that is wanted. | |
7103 | ((and subject | |
7104 | gnus-auto-select-same | |
7105 | (gnus-summary-first-unread-article)) | |
7106 | (gnus-summary-position-point) | |
7107 | (gnus-message 6 "Wrapped")) | |
7108 | ;; Try to get next/previous article not displayed in this group. | |
7109 | ((and gnus-auto-extend-newsgroup | |
7110 | (not unread) (not subject)) | |
7111 | (gnus-summary-goto-article | |
7112 | (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end)) | |
6748645f | 7113 | nil (count-lines (point-min) (point)))) |
eec82323 LMI |
7114 | ;; Go to next/previous group. |
7115 | (t | |
7116 | (unless (gnus-ephemeral-group-p gnus-newsgroup-name) | |
7117 | (gnus-summary-jump-to-group gnus-newsgroup-name)) | |
7118 | (let ((cmd last-command-char) | |
7119 | (point | |
7120 | (save-excursion | |
7121 | (set-buffer gnus-group-buffer) | |
7122 | (point))) | |
7123 | (group | |
7124 | (if (eq gnus-keep-same-level 'best) | |
7125 | (gnus-summary-best-group gnus-newsgroup-name) | |
7126 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
7127 | ;; For some reason, the group window gets selected. We change | |
7128 | ;; it back. | |
7129 | (select-window (get-buffer-window (current-buffer))) | |
7130 | ;; Select next unread newsgroup automagically. | |
7131 | (cond | |
7132 | ((or (not gnus-auto-select-next) | |
7133 | (not cmd)) | |
7134 | (gnus-message 7 "No more%s articles" (if unread " unread" ""))) | |
7135 | ((or (eq gnus-auto-select-next 'quietly) | |
7136 | (and (eq gnus-auto-select-next 'slightly-quietly) | |
7137 | push) | |
7138 | (and (eq gnus-auto-select-next 'almost-quietly) | |
7139 | (gnus-summary-last-article-p))) | |
7140 | ;; Select quietly. | |
7141 | (if (gnus-ephemeral-group-p gnus-newsgroup-name) | |
7142 | (gnus-summary-exit) | |
7143 | (gnus-message 7 "No more%s articles (%s)..." | |
7144 | (if unread " unread" "") | |
7145 | (if group (concat "selecting " group) | |
7146 | "exiting")) | |
7147 | (gnus-summary-next-group nil group backward))) | |
7148 | (t | |
7149 | (when (gnus-key-press-event-p last-input-event) | |
7150 | (gnus-summary-walk-group-buffer | |
7151 | gnus-newsgroup-name cmd unread backward point)))))))) | |
7152 | ||
7153 | (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start) | |
7154 | (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1)) | |
7155 | (?\C-p (gnus-group-prev-unread-group 1)))) | |
7156 | (cursor-in-echo-area t) | |
23f87bed | 7157 | keve key group ended prompt) |
eec82323 LMI |
7158 | (save-excursion |
7159 | (set-buffer gnus-group-buffer) | |
7160 | (goto-char start) | |
7161 | (setq group | |
7162 | (if (eq gnus-keep-same-level 'best) | |
7163 | (gnus-summary-best-group gnus-newsgroup-name) | |
7164 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
7165 | (while (not ended) | |
23f87bed MB |
7166 | (setq prompt |
7167 | (format | |
7168 | "No more%s articles%s " (if unread " unread" "") | |
7169 | (if (and group | |
7170 | (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
7171 | (format " (Type %s for %s [%s])" | |
7172 | (single-key-description cmd) group | |
7173 | (car (gnus-gethash group gnus-newsrc-hashtb))) | |
7174 | (format " (Type %s to exit %s)" | |
7175 | (single-key-description cmd) | |
7176 | gnus-newsgroup-name)))) | |
eec82323 | 7177 | ;; Confirm auto selection. |
23f87bed MB |
7178 | (setq key (car (setq keve (gnus-read-event-char prompt))) |
7179 | ended t) | |
eec82323 LMI |
7180 | (cond |
7181 | ((assq key keystrokes) | |
7182 | (let ((obuf (current-buffer))) | |
7183 | (switch-to-buffer gnus-group-buffer) | |
7184 | (when group | |
7185 | (gnus-group-jump-to-group group)) | |
7186 | (eval (cadr (assq key keystrokes))) | |
7187 | (setq group (gnus-group-group-name)) | |
7188 | (switch-to-buffer obuf)) | |
7189 | (setq ended nil)) | |
7190 | ((equal key cmd) | |
7191 | (if (or (not group) | |
7192 | (gnus-ephemeral-group-p gnus-newsgroup-name)) | |
7193 | (gnus-summary-exit) | |
7194 | (gnus-summary-next-group nil group backward))) | |
7195 | (t | |
7196 | (push (cdr keve) unread-command-events)))))) | |
7197 | ||
7198 | (defun gnus-summary-next-unread-article () | |
7199 | "Select unread article after current one." | |
7200 | (interactive) | |
7201 | (gnus-summary-next-article | |
7202 | (or (not (eq gnus-summary-goto-unread 'never)) | |
7203 | (gnus-summary-last-article-p (gnus-summary-article-number))) | |
7204 | (and gnus-auto-select-same | |
7205 | (gnus-summary-article-subject)))) | |
7206 | ||
7207 | (defun gnus-summary-prev-article (&optional unread subject) | |
7208 | "Select the article after the current one. | |
7209 | If UNREAD is non-nil, only unread articles are selected." | |
7210 | (interactive "P") | |
7211 | (gnus-summary-next-article unread subject t)) | |
7212 | ||
7213 | (defun gnus-summary-prev-unread-article () | |
7214 | "Select unread article before current one." | |
7215 | (interactive) | |
7216 | (gnus-summary-prev-article | |
7217 | (or (not (eq gnus-summary-goto-unread 'never)) | |
7218 | (gnus-summary-first-article-p (gnus-summary-article-number))) | |
7219 | (and gnus-auto-select-same | |
7220 | (gnus-summary-article-subject)))) | |
7221 | ||
23f87bed | 7222 | (defun gnus-summary-next-page (&optional lines circular stop) |
eec82323 LMI |
7223 | "Show next page of the selected article. |
7224 | If at the end of the current article, select the next article. | |
7225 | LINES says how many lines should be scrolled up. | |
7226 | ||
7227 | If CIRCULAR is non-nil, go to the start of the article instead of | |
7228 | selecting the next article when reaching the end of the current | |
23f87bed MB |
7229 | article. |
7230 | ||
7231 | If STOP is non-nil, just stop when reaching the end of the message. | |
7232 | ||
7233 | Also see the variable `gnus-article-skip-boring'." | |
eec82323 LMI |
7234 | (interactive "P") |
7235 | (setq gnus-summary-buffer (current-buffer)) | |
7236 | (gnus-set-global-variables) | |
7237 | (let ((article (gnus-summary-article-number)) | |
7238 | (article-window (get-buffer-window gnus-article-buffer t)) | |
7239 | endp) | |
6748645f LMI |
7240 | ;; If the buffer is empty, we have no article. |
7241 | (unless article | |
7242 | (error "No article to select")) | |
eec82323 LMI |
7243 | (gnus-configure-windows 'article) |
7244 | (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark) | |
7245 | (if (and (eq gnus-summary-goto-unread 'never) | |
7246 | (not (gnus-summary-last-article-p article))) | |
7247 | (gnus-summary-next-article) | |
7248 | (gnus-summary-next-unread-article)) | |
7249 | (if (or (null gnus-current-article) | |
7250 | (null gnus-article-current) | |
7251 | (/= article (cdr gnus-article-current)) | |
7252 | (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
7253 | ;; Selected subject is different from current article's. | |
7254 | (gnus-summary-display-article article) | |
7255 | (when article-window | |
7256 | (gnus-eval-in-buffer-window gnus-article-buffer | |
23f87bed MB |
7257 | (setq endp (or (gnus-article-next-page lines) |
7258 | (gnus-article-only-boring-p)))) | |
eec82323 | 7259 | (when endp |
23f87bed MB |
7260 | (cond (stop |
7261 | (gnus-message 3 "End of message")) | |
7262 | (circular | |
eec82323 LMI |
7263 | (gnus-summary-beginning-of-article)) |
7264 | (lines | |
7265 | (gnus-message 3 "End of message")) | |
7266 | ((null lines) | |
7267 | (if (and (eq gnus-summary-goto-unread 'never) | |
7268 | (not (gnus-summary-last-article-p article))) | |
7269 | (gnus-summary-next-article) | |
7270 | (gnus-summary-next-unread-article)))))))) | |
7271 | (gnus-summary-recenter) | |
7272 | (gnus-summary-position-point))) | |
7273 | ||
7274 | (defun gnus-summary-prev-page (&optional lines move) | |
7275 | "Show previous page of selected article. | |
7276 | Argument LINES specifies lines to be scrolled down. | |
7277 | If MOVE, move to the previous unread article if point is at | |
7278 | the beginning of the buffer." | |
7279 | (interactive "P") | |
eec82323 LMI |
7280 | (let ((article (gnus-summary-article-number)) |
7281 | (article-window (get-buffer-window gnus-article-buffer t)) | |
7282 | endp) | |
7283 | (gnus-configure-windows 'article) | |
7284 | (if (or (null gnus-current-article) | |
7285 | (null gnus-article-current) | |
7286 | (/= article (cdr gnus-article-current)) | |
7287 | (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
7288 | ;; Selected subject is different from current article's. | |
7289 | (gnus-summary-display-article article) | |
7290 | (gnus-summary-recenter) | |
7291 | (when article-window | |
7292 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7293 | (setq endp (gnus-article-prev-page lines))) | |
7294 | (when (and move endp) | |
7295 | (cond (lines | |
7296 | (gnus-message 3 "Beginning of message")) | |
7297 | ((null lines) | |
7298 | (if (and (eq gnus-summary-goto-unread 'never) | |
7299 | (not (gnus-summary-first-article-p article))) | |
7300 | (gnus-summary-prev-article) | |
7301 | (gnus-summary-prev-unread-article)))))))) | |
7302 | (gnus-summary-position-point)) | |
7303 | ||
7304 | (defun gnus-summary-prev-page-or-article (&optional lines) | |
7305 | "Show previous page of selected article. | |
7306 | Argument LINES specifies lines to be scrolled down. | |
7307 | If at the beginning of the article, go to the next article." | |
7308 | (interactive "P") | |
7309 | (gnus-summary-prev-page lines t)) | |
7310 | ||
7311 | (defun gnus-summary-scroll-up (lines) | |
7312 | "Scroll up (or down) one line current article. | |
7313 | Argument LINES specifies lines to be scrolled up (or down if negative)." | |
7314 | (interactive "p") | |
eec82323 LMI |
7315 | (gnus-configure-windows 'article) |
7316 | (gnus-summary-show-thread) | |
7317 | (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old) | |
7318 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7319 | (cond ((> lines 0) | |
7320 | (when (gnus-article-next-page lines) | |
7321 | (gnus-message 3 "End of message"))) | |
7322 | ((< lines 0) | |
7323 | (gnus-article-prev-page (- lines)))))) | |
7324 | (gnus-summary-recenter) | |
7325 | (gnus-summary-position-point)) | |
7326 | ||
6748645f LMI |
7327 | (defun gnus-summary-scroll-down (lines) |
7328 | "Scroll down (or up) one line current article. | |
7329 | Argument LINES specifies lines to be scrolled down (or up if negative)." | |
7330 | (interactive "p") | |
7331 | (gnus-summary-scroll-up (- lines))) | |
7332 | ||
eec82323 LMI |
7333 | (defun gnus-summary-next-same-subject () |
7334 | "Select next article which has the same subject as current one." | |
7335 | (interactive) | |
eec82323 LMI |
7336 | (gnus-summary-next-article nil (gnus-summary-article-subject))) |
7337 | ||
7338 | (defun gnus-summary-prev-same-subject () | |
7339 | "Select previous article which has the same subject as current one." | |
7340 | (interactive) | |
eec82323 LMI |
7341 | (gnus-summary-prev-article nil (gnus-summary-article-subject))) |
7342 | ||
7343 | (defun gnus-summary-next-unread-same-subject () | |
7344 | "Select next unread article which has the same subject as current one." | |
7345 | (interactive) | |
eec82323 LMI |
7346 | (gnus-summary-next-article t (gnus-summary-article-subject))) |
7347 | ||
7348 | (defun gnus-summary-prev-unread-same-subject () | |
7349 | "Select previous unread article which has the same subject as current one." | |
7350 | (interactive) | |
eec82323 LMI |
7351 | (gnus-summary-prev-article t (gnus-summary-article-subject))) |
7352 | ||
7353 | (defun gnus-summary-first-unread-article () | |
7354 | "Select the first unread article. | |
7355 | Return nil if there are no unread articles." | |
7356 | (interactive) | |
eec82323 LMI |
7357 | (prog1 |
7358 | (when (gnus-summary-first-subject t) | |
7359 | (gnus-summary-show-thread) | |
7360 | (gnus-summary-first-subject t) | |
7361 | (gnus-summary-display-article (gnus-summary-article-number))) | |
7362 | (gnus-summary-position-point))) | |
7363 | ||
16409b0b GM |
7364 | (defun gnus-summary-first-unread-subject () |
7365 | "Place the point on the subject line of the first unread article. | |
7366 | Return nil if there are no unread articles." | |
7367 | (interactive) | |
7368 | (prog1 | |
7369 | (when (gnus-summary-first-subject t) | |
7370 | (gnus-summary-show-thread) | |
7371 | (gnus-summary-first-subject t)) | |
7372 | (gnus-summary-position-point))) | |
7373 | ||
23f87bed MB |
7374 | (defun gnus-summary-first-unseen-subject () |
7375 | "Place the point on the subject line of the first unseen article. | |
7376 | Return nil if there are no unseen articles." | |
7377 | (interactive) | |
7378 | (prog1 | |
7379 | (when (gnus-summary-first-subject nil nil t) | |
7380 | (gnus-summary-show-thread) | |
7381 | (gnus-summary-first-subject nil nil t)) | |
7382 | (gnus-summary-position-point))) | |
7383 | ||
7384 | (defun gnus-summary-first-unseen-or-unread-subject () | |
7385 | "Place the point on the subject line of the first unseen article or, | |
7386 | if all article have been seen, on the subject line of the first unread | |
7387 | article." | |
7388 | (interactive) | |
7389 | (prog1 | |
7390 | (unless (when (gnus-summary-first-subject nil nil t) | |
7391 | (gnus-summary-show-thread) | |
7392 | (gnus-summary-first-subject nil nil t)) | |
7393 | (when (gnus-summary-first-subject t) | |
7394 | (gnus-summary-show-thread) | |
7395 | (gnus-summary-first-subject t))) | |
7396 | (gnus-summary-position-point))) | |
7397 | ||
eec82323 LMI |
7398 | (defun gnus-summary-first-article () |
7399 | "Select the first article. | |
7400 | Return nil if there are no articles." | |
7401 | (interactive) | |
eec82323 LMI |
7402 | (prog1 |
7403 | (when (gnus-summary-first-subject) | |
16409b0b GM |
7404 | (gnus-summary-show-thread) |
7405 | (gnus-summary-first-subject) | |
7406 | (gnus-summary-display-article (gnus-summary-article-number))) | |
eec82323 LMI |
7407 | (gnus-summary-position-point))) |
7408 | ||
23f87bed MB |
7409 | (defun gnus-summary-best-unread-article (&optional arg) |
7410 | "Select the unread article with the highest score. | |
7411 | If given a prefix argument, select the next unread article that has a | |
7412 | score higher than the default score." | |
7413 | (interactive "P") | |
7414 | (let ((article (if arg | |
7415 | (gnus-summary-better-unread-subject) | |
7416 | (gnus-summary-best-unread-subject)))) | |
7417 | (if article | |
7418 | (gnus-summary-goto-article article) | |
7419 | (error "No unread articles")))) | |
7420 | ||
7421 | (defun gnus-summary-best-unread-subject () | |
7422 | "Select the unread subject with the highest score." | |
eec82323 | 7423 | (interactive) |
eec82323 LMI |
7424 | (let ((best -1000000) |
7425 | (data gnus-newsgroup-data) | |
7426 | article score) | |
7427 | (while data | |
7428 | (and (gnus-data-unread-p (car data)) | |
7429 | (> (setq score | |
7430 | (gnus-summary-article-score (gnus-data-number (car data)))) | |
7431 | best) | |
7432 | (setq best score | |
7433 | article (gnus-data-number (car data)))) | |
7434 | (setq data (cdr data))) | |
23f87bed MB |
7435 | (when article |
7436 | (gnus-summary-goto-subject article)) | |
7437 | (gnus-summary-position-point) | |
7438 | article)) | |
7439 | ||
7440 | (defun gnus-summary-better-unread-subject () | |
7441 | "Select the first unread subject that has a score over the default score." | |
7442 | (interactive) | |
7443 | (let ((data gnus-newsgroup-data) | |
7444 | article score) | |
7445 | (while (and (setq article (gnus-data-number (car data))) | |
7446 | (or (gnus-data-read-p (car data)) | |
7447 | (not (> (gnus-summary-article-score article) | |
7448 | gnus-summary-default-score)))) | |
7449 | (setq data (cdr data))) | |
7450 | (when article | |
7451 | (gnus-summary-goto-subject article)) | |
7452 | (gnus-summary-position-point) | |
7453 | article)) | |
eec82323 LMI |
7454 | |
7455 | (defun gnus-summary-last-subject () | |
7456 | "Go to the last displayed subject line in the group." | |
7457 | (let ((article (gnus-data-number (car (gnus-data-list t))))) | |
7458 | (when article | |
7459 | (gnus-summary-goto-subject article)))) | |
7460 | ||
7461 | (defun gnus-summary-goto-article (article &optional all-headers force) | |
6748645f LMI |
7462 | "Fetch ARTICLE (article number or Message-ID) and display it if it exists. |
7463 | If ALL-HEADERS is non-nil, no header lines are hidden. | |
7464 | If FORCE, go to the article even if it isn't displayed. If FORCE | |
7465 | is a number, it is the line the article is to be displayed on." | |
eec82323 LMI |
7466 | (interactive |
7467 | (list | |
6748645f LMI |
7468 | (completing-read |
7469 | "Article number or Message-ID: " | |
7470 | (mapcar (lambda (number) (list (int-to-string number))) | |
7471 | gnus-newsgroup-limit)) | |
eec82323 LMI |
7472 | current-prefix-arg |
7473 | t)) | |
7474 | (prog1 | |
6748645f | 7475 | (if (and (stringp article) |
23f87bed | 7476 | (string-match "@\\|%40" article)) |
6748645f LMI |
7477 | (gnus-summary-refer-article article) |
7478 | (when (stringp article) | |
7479 | (setq article (string-to-number article))) | |
7480 | (if (gnus-summary-goto-subject article force) | |
7481 | (gnus-summary-display-article article all-headers) | |
7482 | (gnus-message 4 "Couldn't go to article %s" article) nil)) | |
eec82323 LMI |
7483 | (gnus-summary-position-point))) |
7484 | ||
7485 | (defun gnus-summary-goto-last-article () | |
7486 | "Go to the previously read article." | |
7487 | (interactive) | |
7488 | (prog1 | |
7489 | (when gnus-last-article | |
6748645f | 7490 | (gnus-summary-goto-article gnus-last-article nil t)) |
eec82323 LMI |
7491 | (gnus-summary-position-point))) |
7492 | ||
7493 | (defun gnus-summary-pop-article (number) | |
7494 | "Pop one article off the history and go to the previous. | |
7495 | NUMBER articles will be popped off." | |
7496 | (interactive "p") | |
7497 | (let (to) | |
7498 | (setq gnus-newsgroup-history | |
7499 | (cdr (setq to (nthcdr number gnus-newsgroup-history)))) | |
7500 | (if to | |
6748645f | 7501 | (gnus-summary-goto-article (car to) nil t) |
eec82323 LMI |
7502 | (error "Article history empty"))) |
7503 | (gnus-summary-position-point)) | |
7504 | ||
7505 | ;; Summary commands and functions for limiting the summary buffer. | |
7506 | ||
7507 | (defun gnus-summary-limit-to-articles (n) | |
7508 | "Limit the summary buffer to the next N articles. | |
7509 | If not given a prefix, use the process marked articles instead." | |
7510 | (interactive "P") | |
eec82323 LMI |
7511 | (prog1 |
7512 | (let ((articles (gnus-summary-work-articles n))) | |
7513 | (setq gnus-newsgroup-processable nil) | |
7514 | (gnus-summary-limit articles)) | |
7515 | (gnus-summary-position-point))) | |
7516 | ||
7517 | (defun gnus-summary-pop-limit (&optional total) | |
7518 | "Restore the previous limit. | |
7519 | If given a prefix, remove all limits." | |
7520 | (interactive "P") | |
eec82323 LMI |
7521 | (when total |
7522 | (setq gnus-newsgroup-limits | |
7523 | (list (mapcar (lambda (h) (mail-header-number h)) | |
7524 | gnus-newsgroup-headers)))) | |
7525 | (unless gnus-newsgroup-limits | |
7526 | (error "No limit to pop")) | |
7527 | (prog1 | |
7528 | (gnus-summary-limit nil 'pop) | |
7529 | (gnus-summary-position-point))) | |
7530 | ||
47b63dfa SZ |
7531 | (defun gnus-summary-limit-to-subject (subject &optional header not-matching) |
7532 | "Limit the summary buffer to articles that have subjects that match a regexp. | |
7533 | If NOT-MATCHING, excluding articles that have subjects that match a regexp." | |
a1506d29 | 7534 | (interactive |
47b63dfa SZ |
7535 | (list (read-string (if current-prefix-arg |
7536 | "Exclude subject (regexp): " | |
a1506d29 | 7537 | "Limit to subject (regexp): ")) |
47b63dfa | 7538 | nil current-prefix-arg)) |
eec82323 LMI |
7539 | (unless header |
7540 | (setq header "subject")) | |
7541 | (when (not (equal "" subject)) | |
7542 | (prog1 | |
7543 | (let ((articles (gnus-summary-find-matching | |
a1506d29 | 7544 | (or header "subject") subject 'all nil nil |
47b63dfa | 7545 | not-matching))) |
eec82323 LMI |
7546 | (unless articles |
7547 | (error "Found no matches for \"%s\"" subject)) | |
7548 | (gnus-summary-limit articles)) | |
7549 | (gnus-summary-position-point)))) | |
7550 | ||
ef6e0ec7 | 7551 | (defun gnus-summary-limit-to-author (from &optional not-matching) |
47b63dfa SZ |
7552 | "Limit the summary buffer to articles that have authors that match a regexp. |
7553 | If NOT-MATCHING, excluding articles that have authors that match a regexp." | |
a1506d29 | 7554 | (interactive |
47b63dfa SZ |
7555 | (list (read-string (if current-prefix-arg |
7556 | "Exclude author (regexp): " | |
a1506d29 | 7557 | "Limit to author (regexp): ")) |
ef6e0ec7 SZ |
7558 | current-prefix-arg)) |
7559 | (gnus-summary-limit-to-subject from "from" not-matching)) | |
eec82323 LMI |
7560 | |
7561 | (defun gnus-summary-limit-to-age (age &optional younger-p) | |
7562 | "Limit the summary buffer to articles that are older than (or equal) AGE days. | |
7563 | If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to | |
7564 | articles that are younger than AGE days." | |
16409b0b GM |
7565 | (interactive |
7566 | (let ((younger current-prefix-arg) | |
7567 | (days-got nil) | |
7568 | days) | |
7569 | (while (not days-got) | |
7570 | (setq days (if younger | |
23f87bed MB |
7571 | (read-string "Limit to articles younger than (in days, older when negative): ") |
7572 | (read-string | |
7573 | "Limit to articles older than (in days, younger when negative): "))) | |
16409b0b GM |
7574 | (when (> (length days) 0) |
7575 | (setq days (read days))) | |
7576 | (if (numberp days) | |
23f87bed MB |
7577 | (progn |
7578 | (setq days-got t) | |
7579 | (if (< days 0) | |
7580 | (progn | |
7581 | (setq younger (not younger)) | |
7582 | (setq days (* days -1))))) | |
16409b0b GM |
7583 | (message "Please enter a number.") |
7584 | (sleep-for 1))) | |
7585 | (list days younger))) | |
eec82323 LMI |
7586 | (prog1 |
7587 | (let ((data gnus-newsgroup-data) | |
16409b0b | 7588 | (cutoff (days-to-time age)) |
eec82323 LMI |
7589 | articles d date is-younger) |
7590 | (while (setq d (pop data)) | |
7591 | (when (and (vectorp (gnus-data-header d)) | |
7592 | (setq date (mail-header-date (gnus-data-header d)))) | |
16409b0b GM |
7593 | (setq is-younger (time-less-p |
7594 | (time-since (condition-case () | |
7595 | (date-to-time date) | |
7596 | (error '(0 0)))) | |
eec82323 | 7597 | cutoff)) |
6748645f LMI |
7598 | (when (if younger-p |
7599 | is-younger | |
7600 | (not is-younger)) | |
eec82323 LMI |
7601 | (push (gnus-data-number d) articles)))) |
7602 | (gnus-summary-limit (nreverse articles))) | |
7603 | (gnus-summary-position-point))) | |
7604 | ||
47b63dfa | 7605 | (defun gnus-summary-limit-to-extra (header regexp &optional not-matching) |
16409b0b GM |
7606 | "Limit the summary buffer to articles that match an 'extra' header." |
7607 | (interactive | |
7608 | (let ((header | |
7609 | (intern | |
23f87bed | 7610 | (gnus-completing-read-with-default |
16409b0b | 7611 | (symbol-name (car gnus-extra-headers)) |
47b63dfa SZ |
7612 | (if current-prefix-arg |
7613 | "Exclude extra header:" | |
7614 | "Limit extra header:") | |
16409b0b GM |
7615 | (mapcar (lambda (x) |
7616 | (cons (symbol-name x) x)) | |
7617 | gnus-extra-headers) | |
7618 | nil | |
7619 | t)))) | |
7620 | (list header | |
a1506d29 | 7621 | (read-string (format "%s header %s (regexp): " |
47b63dfa SZ |
7622 | (if current-prefix-arg "Exclude" "Limit to") |
7623 | header)) | |
7624 | current-prefix-arg))) | |
16409b0b GM |
7625 | (when (not (equal "" regexp)) |
7626 | (prog1 | |
7627 | (let ((articles (gnus-summary-find-matching | |
a1506d29 | 7628 | (cons 'extra header) regexp 'all nil nil |
47b63dfa | 7629 | not-matching))) |
16409b0b GM |
7630 | (unless articles |
7631 | (error "Found no matches for \"%s\"" regexp)) | |
7632 | (gnus-summary-limit articles)) | |
7633 | (gnus-summary-position-point)))) | |
7634 | ||
23f87bed MB |
7635 | (defun gnus-summary-limit-to-display-predicate () |
7636 | "Limit the summary buffer to the predicated in the `display' group parameter." | |
7637 | (interactive) | |
7638 | (unless gnus-newsgroup-display | |
7639 | (error "There is no `display' group parameter")) | |
7640 | (let (articles) | |
7641 | (dolist (number gnus-newsgroup-articles) | |
7642 | (when (funcall gnus-newsgroup-display) | |
7643 | (push number articles))) | |
7644 | (gnus-summary-limit articles)) | |
7645 | (gnus-summary-position-point)) | |
7646 | ||
eec82323 LMI |
7647 | (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) |
7648 | (make-obsolete | |
7649 | 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread) | |
7650 | ||
7651 | (defun gnus-summary-limit-to-unread (&optional all) | |
7652 | "Limit the summary buffer to articles that are not marked as read. | |
7653 | If ALL is non-nil, limit strictly to unread articles." | |
7654 | (interactive "P") | |
7655 | (if all | |
7656 | (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark)) | |
7657 | (gnus-summary-limit-to-marks | |
7658 | ;; Concat all the marks that say that an article is read and have | |
7659 | ;; those removed. | |
7660 | (list gnus-del-mark gnus-read-mark gnus-ancient-mark | |
23f87bed | 7661 | gnus-killed-mark gnus-spam-mark gnus-kill-file-mark |
eec82323 LMI |
7662 | gnus-low-score-mark gnus-expirable-mark |
7663 | gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark | |
7664 | gnus-duplicate-mark gnus-souped-mark) | |
7665 | 'reverse))) | |
7666 | ||
7667 | (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks) | |
7668 | (make-obsolete 'gnus-summary-delete-marked-with | |
81ceefe2 | 7669 | 'gnus-summary-limit-exclude-marks) |
eec82323 LMI |
7670 | |
7671 | (defun gnus-summary-limit-exclude-marks (marks &optional reverse) | |
7672 | "Exclude articles that are marked with MARKS (e.g. \"DK\"). | |
7673 | If REVERSE, limit the summary buffer to articles that are marked | |
7674 | with MARKS. MARKS can either be a string of marks or a list of marks. | |
7675 | Returns how many articles were removed." | |
7676 | (interactive "sMarks: ") | |
7677 | (gnus-summary-limit-to-marks marks t)) | |
7678 | ||
7679 | (defun gnus-summary-limit-to-marks (marks &optional reverse) | |
7680 | "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\"). | |
7681 | If REVERSE (the prefix), limit the summary buffer to articles that are | |
7682 | not marked with MARKS. MARKS can either be a string of marks or a | |
7683 | list of marks. | |
7684 | Returns how many articles were removed." | |
6748645f | 7685 | (interactive "sMarks: \nP") |
eec82323 LMI |
7686 | (prog1 |
7687 | (let ((data gnus-newsgroup-data) | |
7688 | (marks (if (listp marks) marks | |
7689 | (append marks nil))) ; Transform to list. | |
7690 | articles) | |
7691 | (while data | |
7692 | (when (if reverse (not (memq (gnus-data-mark (car data)) marks)) | |
7693 | (memq (gnus-data-mark (car data)) marks)) | |
7694 | (push (gnus-data-number (car data)) articles)) | |
7695 | (setq data (cdr data))) | |
7696 | (gnus-summary-limit articles)) | |
7697 | (gnus-summary-position-point))) | |
7698 | ||
23f87bed | 7699 | (defun gnus-summary-limit-to-score (score) |
eec82323 | 7700 | "Limit to articles with score at or above SCORE." |
23f87bed | 7701 | (interactive "NLimit to articles with score of at least: ") |
eec82323 LMI |
7702 | (let ((data gnus-newsgroup-data) |
7703 | articles) | |
7704 | (while data | |
7705 | (when (>= (gnus-summary-article-score (gnus-data-number (car data))) | |
7706 | score) | |
7707 | (push (gnus-data-number (car data)) articles)) | |
7708 | (setq data (cdr data))) | |
7709 | (prog1 | |
7710 | (gnus-summary-limit articles) | |
7711 | (gnus-summary-position-point)))) | |
7712 | ||
23f87bed MB |
7713 | (defun gnus-summary-limit-to-unseen () |
7714 | "Limit to unseen articles." | |
7715 | (interactive) | |
7716 | (prog1 | |
7717 | (gnus-summary-limit gnus-newsgroup-unseen) | |
7718 | (gnus-summary-position-point))) | |
7719 | ||
6748645f | 7720 | (defun gnus-summary-limit-include-thread (id) |
23f87bed MB |
7721 | "Display all the hidden articles that is in the thread with ID in it. |
7722 | When called interactively, ID is the Message-ID of the current | |
7723 | article." | |
6748645f LMI |
7724 | (interactive (list (mail-header-id (gnus-summary-article-header)))) |
7725 | (let ((articles (gnus-articles-in-thread | |
7726 | (gnus-id-to-thread (gnus-root-id id))))) | |
7727 | (prog1 | |
7728 | (gnus-summary-limit (nconc articles gnus-newsgroup-limit)) | |
23f87bed MB |
7729 | (gnus-summary-limit-include-matching-articles |
7730 | "subject" | |
7731 | (regexp-quote (gnus-simplify-subject-re | |
7732 | (mail-header-subject (gnus-id-to-header id))))) | |
6748645f LMI |
7733 | (gnus-summary-position-point)))) |
7734 | ||
23f87bed MB |
7735 | (defun gnus-summary-limit-include-matching-articles (header regexp) |
7736 | "Display all the hidden articles that have HEADERs that match REGEXP." | |
7737 | (interactive (list (read-string "Match on header: ") | |
7738 | (read-string "Regexp: "))) | |
7739 | (let ((articles (gnus-find-matching-articles header regexp))) | |
7740 | (prog1 | |
7741 | (gnus-summary-limit (nconc articles gnus-newsgroup-limit)) | |
7742 | (gnus-summary-position-point)))) | |
7743 | ||
7744 | (defun gnus-summary-insert-dormant-articles () | |
7745 | "Insert all the dormant articles for this group into the current buffer." | |
7746 | (interactive) | |
7747 | (let ((gnus-verbose (max 6 gnus-verbose))) | |
7748 | (if (not gnus-newsgroup-dormant) | |
7749 | (gnus-message 3 "No cached articles for this group") | |
7750 | (gnus-summary-goto-subjects gnus-newsgroup-dormant)))) | |
7751 | ||
eec82323 | 7752 | (defun gnus-summary-limit-include-dormant () |
6748645f LMI |
7753 | "Display all the hidden articles that are marked as dormant. |
7754 | Note that this command only works on a subset of the articles currently | |
7755 | fetched for this group." | |
eec82323 | 7756 | (interactive) |
eec82323 LMI |
7757 | (unless gnus-newsgroup-dormant |
7758 | (error "There are no dormant articles in this group")) | |
7759 | (prog1 | |
7760 | (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit)) | |
7761 | (gnus-summary-position-point))) | |
7762 | ||
7763 | (defun gnus-summary-limit-exclude-dormant () | |
7764 | "Hide all dormant articles." | |
7765 | (interactive) | |
eec82323 LMI |
7766 | (prog1 |
7767 | (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse) | |
7768 | (gnus-summary-position-point))) | |
7769 | ||
7770 | (defun gnus-summary-limit-exclude-childless-dormant () | |
7771 | "Hide all dormant articles that have no children." | |
7772 | (interactive) | |
eec82323 LMI |
7773 | (let ((data (gnus-data-list t)) |
7774 | articles d children) | |
7775 | ;; Find all articles that are either not dormant or have | |
7776 | ;; children. | |
7777 | (while (setq d (pop data)) | |
7778 | (when (or (not (= (gnus-data-mark d) gnus-dormant-mark)) | |
7779 | (and (setq children | |
7780 | (gnus-article-children (gnus-data-number d))) | |
7781 | (let (found) | |
7782 | (while children | |
7783 | (when (memq (car children) articles) | |
7784 | (setq children nil | |
7785 | found t)) | |
7786 | (pop children)) | |
7787 | found))) | |
7788 | (push (gnus-data-number d) articles))) | |
7789 | ;; Do the limiting. | |
7790 | (prog1 | |
7791 | (gnus-summary-limit articles) | |
7792 | (gnus-summary-position-point)))) | |
7793 | ||
7794 | (defun gnus-summary-limit-mark-excluded-as-read (&optional all) | |
7795 | "Mark all unread excluded articles as read. | |
7796 | If ALL, mark even excluded ticked and dormants as read." | |
7797 | (interactive "P") | |
23f87bed MB |
7798 | (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<)) |
7799 | (let ((articles (gnus-sorted-ndifference | |
eec82323 LMI |
7800 | (sort |
7801 | (mapcar (lambda (h) (mail-header-number h)) | |
7802 | gnus-newsgroup-headers) | |
7803 | '<) | |
23f87bed | 7804 | gnus-newsgroup-limit)) |
eec82323 | 7805 | article) |
6748645f | 7806 | (setq gnus-newsgroup-unreads |
23f87bed MB |
7807 | (gnus-sorted-intersection gnus-newsgroup-unreads |
7808 | gnus-newsgroup-limit)) | |
eec82323 LMI |
7809 | (if all |
7810 | (setq gnus-newsgroup-dormant nil | |
7811 | gnus-newsgroup-marked nil | |
7812 | gnus-newsgroup-reads | |
7813 | (nconc | |
7814 | (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles) | |
7815 | gnus-newsgroup-reads)) | |
7816 | (while (setq article (pop articles)) | |
7817 | (unless (or (memq article gnus-newsgroup-dormant) | |
7818 | (memq article gnus-newsgroup-marked)) | |
7819 | (push (cons article gnus-catchup-mark) gnus-newsgroup-reads)))))) | |
7820 | ||
7821 | (defun gnus-summary-limit (articles &optional pop) | |
7822 | (if pop | |
7823 | ;; We pop the previous limit off the stack and use that. | |
7824 | (setq articles (car gnus-newsgroup-limits) | |
7825 | gnus-newsgroup-limits (cdr gnus-newsgroup-limits)) | |
7826 | ;; We use the new limit, so we push the old limit on the stack. | |
7827 | (push gnus-newsgroup-limit gnus-newsgroup-limits)) | |
7828 | ;; Set the limit. | |
7829 | (setq gnus-newsgroup-limit articles) | |
7830 | (let ((total (length gnus-newsgroup-data)) | |
7831 | (data (gnus-data-find-list (gnus-summary-article-number))) | |
7832 | (gnus-summary-mark-below nil) ; Inhibit this. | |
7833 | found) | |
7834 | ;; This will do all the work of generating the new summary buffer | |
7835 | ;; according to the new limit. | |
7836 | (gnus-summary-prepare) | |
7837 | ;; Hide any threads, possibly. | |
23f87bed | 7838 | (gnus-summary-maybe-hide-threads) |
eec82323 LMI |
7839 | ;; Try to return to the article you were at, or one in the |
7840 | ;; neighborhood. | |
7841 | (when data | |
7842 | ;; We try to find some article after the current one. | |
7843 | (while data | |
7844 | (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t) | |
7845 | (setq data nil | |
7846 | found t)) | |
7847 | (setq data (cdr data)))) | |
7848 | (unless found | |
7849 | ;; If there is no data, that means that we were after the last | |
7850 | ;; article. The same goes when we can't find any articles | |
7851 | ;; after the current one. | |
7852 | (goto-char (point-max)) | |
7853 | (gnus-summary-find-prev)) | |
6748645f | 7854 | (gnus-set-mode-line 'summary) |
eec82323 LMI |
7855 | ;; We return how many articles were removed from the summary |
7856 | ;; buffer as a result of the new limit. | |
7857 | (- total (length gnus-newsgroup-data)))) | |
7858 | ||
7859 | (defsubst gnus-invisible-cut-children (threads) | |
7860 | (let ((num 0)) | |
7861 | (while threads | |
7862 | (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit) | |
7863 | (incf num)) | |
7864 | (pop threads)) | |
7865 | (< num 2))) | |
7866 | ||
7867 | (defsubst gnus-cut-thread (thread) | |
7868 | "Go forwards in the thread until we find an article that we want to display." | |
7869 | (when (or (eq gnus-fetch-old-headers 'some) | |
6748645f | 7870 | (eq gnus-fetch-old-headers 'invisible) |
16409b0b | 7871 | (numberp gnus-fetch-old-headers) |
eec82323 LMI |
7872 | (eq gnus-build-sparse-threads 'some) |
7873 | (eq gnus-build-sparse-threads 'more)) | |
7874 | ;; Deal with old-fetched headers and sparse threads. | |
7875 | (while (and | |
7876 | thread | |
7877 | (or | |
7878 | (gnus-summary-article-sparse-p (mail-header-number (car thread))) | |
7879 | (gnus-summary-article-ancient-p | |
7880 | (mail-header-number (car thread)))) | |
6748645f LMI |
7881 | (if (or (<= (length (cdr thread)) 1) |
7882 | (eq gnus-fetch-old-headers 'invisible)) | |
7883 | (setq gnus-newsgroup-limit | |
7884 | (delq (mail-header-number (car thread)) | |
7885 | gnus-newsgroup-limit) | |
7886 | thread (cadr thread)) | |
7887 | (when (gnus-invisible-cut-children (cdr thread)) | |
7888 | (let ((th (cdr thread))) | |
7889 | (while th | |
7890 | (if (memq (mail-header-number (caar th)) | |
a8151ef7 | 7891 | gnus-newsgroup-limit) |
6748645f LMI |
7892 | (setq thread (car th) |
7893 | th nil) | |
7894 | (setq th (cdr th)))))))))) | |
eec82323 LMI |
7895 | thread) |
7896 | ||
7897 | (defun gnus-cut-threads (threads) | |
23f87bed | 7898 | "Cut off all uninteresting articles from the beginning of THREADS." |
eec82323 | 7899 | (when (or (eq gnus-fetch-old-headers 'some) |
6748645f | 7900 | (eq gnus-fetch-old-headers 'invisible) |
16409b0b | 7901 | (numberp gnus-fetch-old-headers) |
eec82323 LMI |
7902 | (eq gnus-build-sparse-threads 'some) |
7903 | (eq gnus-build-sparse-threads 'more)) | |
7904 | (let ((th threads)) | |
7905 | (while th | |
7906 | (setcar th (gnus-cut-thread (car th))) | |
7907 | (setq th (cdr th))))) | |
7908 | ;; Remove nixed out threads. | |
7909 | (delq nil threads)) | |
7910 | ||
7911 | (defun gnus-summary-initial-limit (&optional show-if-empty) | |
7912 | "Figure out what the initial limit is supposed to be on group entry. | |
7913 | This entails weeding out unwanted dormants, low-scored articles, | |
7914 | fetch-old-headers verbiage, and so on." | |
7915 | ;; Most groups have nothing to remove. | |
7916 | (if (or gnus-inhibit-limiting | |
7917 | (and (null gnus-newsgroup-dormant) | |
23f87bed | 7918 | (eq gnus-newsgroup-display 'gnus-not-ignore) |
eec82323 | 7919 | (not (eq gnus-fetch-old-headers 'some)) |
16409b0b | 7920 | (not (numberp gnus-fetch-old-headers)) |
6748645f | 7921 | (not (eq gnus-fetch-old-headers 'invisible)) |
eec82323 LMI |
7922 | (null gnus-summary-expunge-below) |
7923 | (not (eq gnus-build-sparse-threads 'some)) | |
7924 | (not (eq gnus-build-sparse-threads 'more)) | |
7925 | (null gnus-thread-expunge-below) | |
7926 | (not gnus-use-nocem))) | |
7927 | () ; Do nothing. | |
7928 | (push gnus-newsgroup-limit gnus-newsgroup-limits) | |
7929 | (setq gnus-newsgroup-limit nil) | |
7930 | (mapatoms | |
7931 | (lambda (node) | |
7932 | (unless (car (symbol-value node)) | |
7933 | ;; These threads have no parents -- they are roots. | |
7934 | (let ((nodes (cdr (symbol-value node))) | |
7935 | thread) | |
7936 | (while nodes | |
7937 | (if (and gnus-thread-expunge-below | |
7938 | (< (gnus-thread-total-score (car nodes)) | |
7939 | gnus-thread-expunge-below)) | |
7940 | (gnus-expunge-thread (pop nodes)) | |
7941 | (setq thread (pop nodes)) | |
7942 | (gnus-summary-limit-children thread)))))) | |
7943 | gnus-newsgroup-dependencies) | |
7944 | ;; If this limitation resulted in an empty group, we might | |
7945 | ;; pop the previous limit and use it instead. | |
7946 | (when (and (not gnus-newsgroup-limit) | |
7947 | show-if-empty) | |
7948 | (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits))) | |
7949 | gnus-newsgroup-limit)) | |
7950 | ||
7951 | (defun gnus-summary-limit-children (thread) | |
7952 | "Return 1 if this subthread is visible and 0 if it is not." | |
7953 | ;; First we get the number of visible children to this thread. This | |
7954 | ;; is done by recursing down the thread using this function, so this | |
7955 | ;; will really go down to a leaf article first, before slowly | |
7956 | ;; working its way up towards the root. | |
7957 | (when thread | |
23f87bed MB |
7958 | (let* ((max-lisp-eval-depth 5000) |
7959 | (children | |
eec82323 LMI |
7960 | (if (cdr thread) |
7961 | (apply '+ (mapcar 'gnus-summary-limit-children | |
7962 | (cdr thread))) | |
7963 | 0)) | |
7964 | (number (mail-header-number (car thread))) | |
7965 | score) | |
7966 | (if (and | |
7967 | (not (memq number gnus-newsgroup-marked)) | |
7968 | (or | |
7969 | ;; If this article is dormant and has absolutely no visible | |
7970 | ;; children, then this article isn't visible. | |
7971 | (and (memq number gnus-newsgroup-dormant) | |
7972 | (zerop children)) | |
7973 | ;; If this is "fetch-old-headered" and there is no | |
7974 | ;; visible children, then we don't want this article. | |
16409b0b GM |
7975 | (and (or (eq gnus-fetch-old-headers 'some) |
7976 | (numberp gnus-fetch-old-headers)) | |
eec82323 LMI |
7977 | (gnus-summary-article-ancient-p number) |
7978 | (zerop children)) | |
6748645f LMI |
7979 | ;; If this is "fetch-old-headered" and `invisible', then |
7980 | ;; we don't want this article. | |
7981 | (and (eq gnus-fetch-old-headers 'invisible) | |
7982 | (gnus-summary-article-ancient-p number)) | |
eec82323 LMI |
7983 | ;; If this is a sparsely inserted article with no children, |
7984 | ;; we don't want it. | |
7985 | (and (eq gnus-build-sparse-threads 'some) | |
7986 | (gnus-summary-article-sparse-p number) | |
7987 | (zerop children)) | |
7988 | ;; If we use expunging, and this article is really | |
7989 | ;; low-scored, then we don't want this article. | |
7990 | (when (and gnus-summary-expunge-below | |
7991 | (< (setq score | |
7992 | (or (cdr (assq number gnus-newsgroup-scored)) | |
7993 | gnus-summary-default-score)) | |
7994 | gnus-summary-expunge-below)) | |
7995 | ;; We increase the expunge-tally here, but that has | |
7996 | ;; nothing to do with the limits, really. | |
7997 | (incf gnus-newsgroup-expunged-tally) | |
7998 | ;; We also mark as read here, if that's wanted. | |
7999 | (when (and gnus-summary-mark-below | |
8000 | (< score gnus-summary-mark-below)) | |
8001 | (setq gnus-newsgroup-unreads | |
8002 | (delq number gnus-newsgroup-unreads)) | |
8003 | (if gnus-newsgroup-auto-expire | |
8004 | (push number gnus-newsgroup-expirable) | |
8005 | (push (cons number gnus-low-score-mark) | |
8006 | gnus-newsgroup-reads))) | |
8007 | t) | |
23f87bed MB |
8008 | ;; Do the `display' group parameter. |
8009 | (and gnus-newsgroup-display | |
8010 | (not (funcall gnus-newsgroup-display))) | |
eec82323 LMI |
8011 | ;; Check NoCeM things. |
8012 | (if (and gnus-use-nocem | |
8013 | (gnus-nocem-unwanted-article-p | |
8014 | (mail-header-id (car thread)))) | |
8015 | (progn | |
a8151ef7 | 8016 | (setq gnus-newsgroup-unreads |
eec82323 LMI |
8017 | (delq number gnus-newsgroup-unreads)) |
8018 | t)))) | |
8019 | ;; Nope, invisible article. | |
8020 | 0 | |
8021 | ;; Ok, this article is to be visible, so we add it to the limit | |
8022 | ;; and return 1. | |
8023 | (push number gnus-newsgroup-limit) | |
8024 | 1)))) | |
8025 | ||
8026 | (defun gnus-expunge-thread (thread) | |
8027 | "Mark all articles in THREAD as read." | |
8028 | (let* ((number (mail-header-number (car thread)))) | |
8029 | (incf gnus-newsgroup-expunged-tally) | |
8030 | ;; We also mark as read here, if that's wanted. | |
8031 | (setq gnus-newsgroup-unreads | |
8032 | (delq number gnus-newsgroup-unreads)) | |
8033 | (if gnus-newsgroup-auto-expire | |
8034 | (push number gnus-newsgroup-expirable) | |
8035 | (push (cons number gnus-low-score-mark) | |
8036 | gnus-newsgroup-reads))) | |
8037 | ;; Go recursively through all subthreads. | |
8038 | (mapcar 'gnus-expunge-thread (cdr thread))) | |
8039 | ||
8040 | ;; Summary article oriented commands | |
8041 | ||
8042 | (defun gnus-summary-refer-parent-article (n) | |
8043 | "Refer parent article N times. | |
8044 | If N is negative, go to ancestor -N instead. | |
8045 | The difference between N and the number of articles fetched is returned." | |
8046 | (interactive "p") | |
eec82323 LMI |
8047 | (let ((skip 1) |
8048 | error header ref) | |
8049 | (when (not (natnump n)) | |
8050 | (setq skip (abs n) | |
8051 | n 1)) | |
8052 | (while (and (> n 0) | |
8053 | (not error)) | |
8054 | (setq header (gnus-summary-article-header)) | |
8055 | (if (and (eq (mail-header-number header) | |
8056 | (cdr gnus-article-current)) | |
8057 | (equal gnus-newsgroup-name | |
8058 | (car gnus-article-current))) | |
8059 | ;; If we try to find the parent of the currently | |
8060 | ;; displayed article, then we take a look at the actual | |
8061 | ;; References header, since this is slightly more | |
8062 | ;; reliable than the References field we got from the | |
8063 | ;; server. | |
8064 | (save-excursion | |
8065 | (set-buffer gnus-original-article-buffer) | |
8066 | (nnheader-narrow-to-headers) | |
8067 | (unless (setq ref (message-fetch-field "references")) | |
23f87bed MB |
8068 | (when (setq ref (message-fetch-field "in-reply-to")) |
8069 | (setq ref (gnus-extract-message-id-from-in-reply-to ref)))) | |
eec82323 LMI |
8070 | (widen)) |
8071 | (setq ref | |
8072 | ;; It's not the current article, so we take a bet on | |
8073 | ;; the value we got from the server. | |
8074 | (mail-header-references header))) | |
8075 | (if (and ref | |
8076 | (not (equal ref ""))) | |
8077 | (unless (gnus-summary-refer-article (gnus-parent-id ref skip)) | |
8078 | (gnus-message 1 "Couldn't find parent")) | |
8079 | (gnus-message 1 "No references in article %d" | |
8080 | (gnus-summary-article-number)) | |
8081 | (setq error t)) | |
8082 | (decf n)) | |
8083 | (gnus-summary-position-point) | |
8084 | n)) | |
8085 | ||
8086 | (defun gnus-summary-refer-references () | |
8087 | "Fetch all articles mentioned in the References header. | |
6748645f | 8088 | Return the number of articles fetched." |
eec82323 | 8089 | (interactive) |
eec82323 LMI |
8090 | (let ((ref (mail-header-references (gnus-summary-article-header))) |
8091 | (current (gnus-summary-article-number)) | |
8092 | (n 0)) | |
8093 | (if (or (not ref) | |
8094 | (equal ref "")) | |
8095 | (error "No References in the current article") | |
8096 | ;; For each Message-ID in the References header... | |
8097 | (while (string-match "<[^>]*>" ref) | |
8098 | (incf n) | |
8099 | ;; ... fetch that article. | |
8100 | (gnus-summary-refer-article | |
8101 | (prog1 (match-string 0 ref) | |
8102 | (setq ref (substring ref (match-end 0)))))) | |
8103 | (gnus-summary-goto-subject current) | |
8104 | (gnus-summary-position-point) | |
8105 | n))) | |
8106 | ||
6748645f LMI |
8107 | (defun gnus-summary-refer-thread (&optional limit) |
8108 | "Fetch all articles in the current thread. | |
8109 | If LIMIT (the numerical prefix), fetch that many old headers instead | |
8110 | of what's specified by the `gnus-refer-thread-limit' variable." | |
8111 | (interactive "P") | |
8112 | (let ((id (mail-header-id (gnus-summary-article-header))) | |
8113 | (limit (if limit (prefix-numeric-value limit) | |
8114 | gnus-refer-thread-limit))) | |
6748645f LMI |
8115 | (unless (eq gnus-fetch-old-headers 'invisible) |
8116 | (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name) | |
8117 | ;; Retrieve the headers and read them in. | |
23f87bed MB |
8118 | (if (eq (if (numberp limit) |
8119 | (gnus-retrieve-headers | |
8120 | (list (min | |
8121 | (+ (mail-header-number | |
8122 | (gnus-summary-article-header)) | |
8123 | limit) | |
8124 | gnus-newsgroup-end)) | |
8125 | gnus-newsgroup-name (* limit 2)) | |
8126 | ;; gnus-refer-thread-limit is t, i.e. fetch _all_ | |
8127 | ;; headers. | |
8128 | (gnus-retrieve-headers (list gnus-newsgroup-end) | |
8129 | gnus-newsgroup-name limit)) | |
6748645f LMI |
8130 | 'nov) |
8131 | (gnus-build-all-threads) | |
23f87bed | 8132 | (error "Can't fetch thread from back ends that don't support NOV")) |
6748645f LMI |
8133 | (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)) |
8134 | (gnus-summary-limit-include-thread id))) | |
8135 | ||
16409b0b GM |
8136 | (defun gnus-summary-refer-article (message-id) |
8137 | "Fetch an article specified by MESSAGE-ID." | |
8138 | (interactive "sMessage-ID: ") | |
eec82323 LMI |
8139 | (when (and (stringp message-id) |
8140 | (not (zerop (length message-id)))) | |
23f87bed | 8141 | (setq message-id (gnus-replace-in-string message-id " " "")) |
eec82323 LMI |
8142 | ;; Construct the correct Message-ID if necessary. |
8143 | ;; Suggested by tale@pawl.rpi.edu. | |
8144 | (unless (string-match "^<" message-id) | |
8145 | (setq message-id (concat "<" message-id))) | |
8146 | (unless (string-match ">$" message-id) | |
8147 | (setq message-id (concat message-id ">"))) | |
23f87bed MB |
8148 | ;; People often post MIDs from URLs, so unhex it: |
8149 | (unless (string-match "@" message-id) | |
8150 | (setq message-id (gnus-url-unhex-string message-id))) | |
eec82323 LMI |
8151 | (let* ((header (gnus-id-to-header message-id)) |
8152 | (sparse (and header | |
8153 | (gnus-summary-article-sparse-p | |
a8151ef7 LMI |
8154 | (mail-header-number header)) |
8155 | (memq (mail-header-number header) | |
16409b0b GM |
8156 | gnus-newsgroup-limit))) |
8157 | number) | |
6748645f LMI |
8158 | (cond |
8159 | ;; If the article is present in the buffer we just go to it. | |
8160 | ((and header | |
8161 | (or (not (gnus-summary-article-sparse-p | |
8162 | (mail-header-number header))) | |
8163 | sparse)) | |
8164 | (prog1 | |
8165 | (gnus-summary-goto-article | |
8166 | (mail-header-number header) nil t) | |
8167 | (when sparse | |
8168 | (gnus-summary-update-article (mail-header-number header))))) | |
8169 | (t | |
16409b0b GM |
8170 | ;; We fetch the article. |
8171 | (catch 'found | |
8172 | (dolist (gnus-override-method (gnus-refer-article-methods)) | |
23f87bed MB |
8173 | (when (and (gnus-check-server gnus-override-method) |
8174 | ;; Fetch the header, | |
8175 | (setq number (gnus-summary-insert-subject message-id))) | |
8176 | ;; and display the article. | |
eec82323 | 8177 | (gnus-summary-select-article nil nil nil number) |
16409b0b GM |
8178 | (throw 'found t))) |
8179 | (gnus-message 3 "Couldn't fetch article %s" message-id))))))) | |
8180 | ||
8181 | (defun gnus-refer-article-methods () | |
8f688cb0 | 8182 | "Return a list of referable methods." |
16409b0b GM |
8183 | (cond |
8184 | ;; No method, so we default to current and native. | |
8185 | ((null gnus-refer-article-method) | |
8186 | (list gnus-current-select-method gnus-select-method)) | |
8187 | ;; Current. | |
8188 | ((eq 'current gnus-refer-article-method) | |
8189 | (list gnus-current-select-method)) | |
8190 | ;; List of select methods. | |
d4dfaa19 DL |
8191 | ((not (and (symbolp (car gnus-refer-article-method)) |
8192 | (assq (car gnus-refer-article-method) nnoo-definition-alist))) | |
16409b0b GM |
8193 | (let (out) |
8194 | (dolist (method gnus-refer-article-method) | |
8195 | (push (if (eq 'current method) | |
8196 | gnus-current-select-method | |
8197 | method) | |
8198 | out)) | |
8199 | (nreverse out))) | |
8200 | ;; One single select method. | |
8201 | (t | |
8202 | (list gnus-refer-article-method)))) | |
6748645f LMI |
8203 | |
8204 | (defun gnus-summary-edit-parameters () | |
8205 | "Edit the group parameters of the current group." | |
8206 | (interactive) | |
8207 | (gnus-group-edit-group gnus-newsgroup-name 'params)) | |
eec82323 | 8208 | |
16409b0b GM |
8209 | (defun gnus-summary-customize-parameters () |
8210 | "Customize the group parameters of the current group." | |
8211 | (interactive) | |
8212 | (gnus-group-customize gnus-newsgroup-name)) | |
8213 | ||
eec82323 LMI |
8214 | (defun gnus-summary-enter-digest-group (&optional force) |
8215 | "Enter an nndoc group based on the current article. | |
8216 | If FORCE, force a digest interpretation. If not, try | |
8217 | to guess what the document format is." | |
8218 | (interactive "P") | |
eec82323 | 8219 | (let ((conf gnus-current-window-configuration)) |
23f87bed MB |
8220 | (save-window-excursion |
8221 | (save-excursion | |
8222 | (let (gnus-article-prepare-hook | |
8223 | gnus-display-mime-function | |
8224 | gnus-break-pages) | |
8225 | (gnus-summary-select-article)))) | |
eec82323 LMI |
8226 | (setq gnus-current-window-configuration conf) |
8227 | (let* ((name (format "%s-%d" | |
8228 | (gnus-group-prefixed-name | |
8229 | gnus-newsgroup-name (list 'nndoc "")) | |
8230 | (save-excursion | |
8231 | (set-buffer gnus-summary-buffer) | |
8232 | gnus-current-article))) | |
8233 | (ogroup gnus-newsgroup-name) | |
8234 | (params (append (gnus-info-params (gnus-get-info ogroup)) | |
8235 | (list (cons 'to-group ogroup)) | |
23f87bed | 8236 | (list (cons 'parent-group ogroup)) |
eec82323 LMI |
8237 | (list (cons 'save-article-group ogroup)))) |
8238 | (case-fold-search t) | |
8239 | (buf (current-buffer)) | |
16409b0b | 8240 | dig to-address) |
eec82323 | 8241 | (save-excursion |
16409b0b GM |
8242 | (set-buffer gnus-original-article-buffer) |
8243 | ;; Have the digest group inherit the main mail address of | |
8244 | ;; the parent article. | |
23f87bed MB |
8245 | (when (setq to-address (or (gnus-fetch-field "reply-to") |
8246 | (gnus-fetch-field "from"))) | |
a1506d29 JB |
8247 | (setq params (append |
8248 | (list (cons 'to-address | |
d4dfaa19 DL |
8249 | (funcall gnus-decode-encoded-word-function |
8250 | to-address)))))) | |
eec82323 LMI |
8251 | (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*")) |
8252 | (insert-buffer-substring gnus-original-article-buffer) | |
8253 | ;; Remove lines that may lead nndoc to misinterpret the | |
8254 | ;; document type. | |
8255 | (narrow-to-region | |
8256 | (goto-char (point-min)) | |
8257 | (or (search-forward "\n\n" nil t) (point))) | |
8258 | (goto-char (point-min)) | |
16409b0b | 8259 | (delete-matching-lines "^Path:\\|^From ") |
eec82323 LMI |
8260 | (widen)) |
8261 | (unwind-protect | |
23f87bed | 8262 | (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset) |
16409b0b GM |
8263 | (gnus-newsgroup-ephemeral-ignored-charsets |
8264 | gnus-newsgroup-ignored-charsets)) | |
8265 | (gnus-group-read-ephemeral-group | |
8266 | name `(nndoc ,name (nndoc-address ,(get-buffer dig)) | |
8267 | (nndoc-article-type | |
23f87bed MB |
8268 | ,(if force 'mbox 'guess))) |
8269 | t nil nil nil | |
8270 | `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name | |
8271 | "ADAPT"))))) | |
16409b0b | 8272 | ;; Make all postings to this group go to the parent group. |
23f87bed MB |
8273 | (nconc (gnus-info-params (gnus-get-info name)) |
8274 | params) | |
8275 | ;; Couldn't select this doc group. | |
8276 | (switch-to-buffer buf) | |
8277 | (gnus-set-global-variables) | |
8278 | (gnus-configure-windows 'summary) | |
8279 | (gnus-message 3 "Article couldn't be entered?")) | |
eec82323 LMI |
8280 | (kill-buffer dig))))) |
8281 | ||
8282 | (defun gnus-summary-read-document (n) | |
8283 | "Open a new group based on the current article(s). | |
8284 | This will allow you to read digests and other similar | |
8285 | documents as newsgroups. | |
8286 | Obeys the standard process/prefix convention." | |
8287 | (interactive "P") | |
8288 | (let* ((articles (gnus-summary-work-articles n)) | |
8289 | (ogroup gnus-newsgroup-name) | |
8290 | (params (append (gnus-info-params (gnus-get-info ogroup)) | |
8291 | (list (cons 'to-group ogroup)))) | |
8292 | article group egroup groups vgroup) | |
8293 | (while (setq article (pop articles)) | |
8294 | (setq group (format "%s-%d" gnus-newsgroup-name article)) | |
8295 | (gnus-summary-remove-process-mark article) | |
8296 | (when (gnus-summary-display-article article) | |
8297 | (save-excursion | |
16409b0b | 8298 | (with-temp-buffer |
eec82323 LMI |
8299 | (insert-buffer-substring gnus-original-article-buffer) |
8300 | ;; Remove some headers that may lead nndoc to make | |
8301 | ;; the wrong guess. | |
8302 | (message-narrow-to-head) | |
8303 | (goto-char (point-min)) | |
8304 | (delete-matching-lines "^\\(Path\\):\\|^From ") | |
8305 | (widen) | |
8306 | (if (setq egroup | |
8307 | (gnus-group-read-ephemeral-group | |
8308 | group `(nndoc ,group (nndoc-address ,(current-buffer)) | |
8309 | (nndoc-article-type guess)) | |
8310 | t nil t)) | |
8311 | (progn | |
23f87bed | 8312 | ;; Make all postings to this group go to the parent group. |
eec82323 LMI |
8313 | (nconc (gnus-info-params (gnus-get-info egroup)) |
8314 | params) | |
8315 | (push egroup groups)) | |
8316 | ;; Couldn't select this doc group. | |
8317 | (gnus-error 3 "Article couldn't be entered")))))) | |
8318 | ;; Now we have selected all the documents. | |
8319 | (cond | |
8320 | ((not groups) | |
8321 | (error "None of the articles could be interpreted as documents")) | |
8322 | ((gnus-group-read-ephemeral-group | |
8323 | (setq vgroup (format | |
8324 | "nnvirtual:%s-%s" gnus-newsgroup-name | |
8325 | (format-time-string "%Y%m%dT%H%M%S" (current-time)))) | |
8326 | `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups)) | |
8327 | t | |
8328 | (cons (current-buffer) 'summary))) | |
8329 | (t | |
8330 | (error "Couldn't select virtual nndoc group"))))) | |
8331 | ||
8332 | (defun gnus-summary-isearch-article (&optional regexp-p) | |
8333 | "Do incremental search forward on the current article. | |
8334 | If REGEXP-P (the prefix) is non-nil, do regexp isearch." | |
8335 | (interactive "P") | |
eec82323 LMI |
8336 | (gnus-summary-select-article) |
8337 | (gnus-configure-windows 'article) | |
8338 | (gnus-eval-in-buffer-window gnus-article-buffer | |
6748645f LMI |
8339 | (save-restriction |
8340 | (widen) | |
8341 | (isearch-forward regexp-p)))) | |
eec82323 LMI |
8342 | |
8343 | (defun gnus-summary-search-article-forward (regexp &optional backward) | |
8344 | "Search for an article containing REGEXP forward. | |
8345 | If BACKWARD, search backward instead." | |
8346 | (interactive | |
8347 | (list (read-string | |
8348 | (format "Search article %s (regexp%s): " | |
8349 | (if current-prefix-arg "backward" "forward") | |
8350 | (if gnus-last-search-regexp | |
8351 | (concat ", default " gnus-last-search-regexp) | |
8352 | ""))) | |
8353 | current-prefix-arg)) | |
eec82323 LMI |
8354 | (if (string-equal regexp "") |
8355 | (setq regexp (or gnus-last-search-regexp "")) | |
23f87bed MB |
8356 | (setq gnus-last-search-regexp regexp) |
8357 | (setq gnus-article-before-search gnus-current-article)) | |
8358 | ;; Intentionally set gnus-last-article. | |
8359 | (setq gnus-last-article gnus-article-before-search) | |
8360 | (let ((gnus-last-article gnus-last-article)) | |
8361 | (if (gnus-summary-search-article regexp backward) | |
8362 | (gnus-summary-show-thread) | |
abc40aab | 8363 | (signal 'search-failed (list regexp))))) |
eec82323 LMI |
8364 | |
8365 | (defun gnus-summary-search-article-backward (regexp) | |
8366 | "Search for an article containing REGEXP backward." | |
8367 | (interactive | |
8368 | (list (read-string | |
8369 | (format "Search article backward (regexp%s): " | |
8370 | (if gnus-last-search-regexp | |
8371 | (concat ", default " gnus-last-search-regexp) | |
8372 | ""))))) | |
8373 | (gnus-summary-search-article-forward regexp 'backward)) | |
8374 | ||
8375 | (defun gnus-summary-search-article (regexp &optional backward) | |
8376 | "Search for an article containing REGEXP. | |
8377 | Optional argument BACKWARD means do search for backward. | |
8378 | `gnus-select-article-hook' is not called during the search." | |
a8151ef7 LMI |
8379 | ;; We have to require this here to make sure that the following |
8380 | ;; dynamic binding isn't shadowed by autoloading. | |
8381 | (require 'gnus-async) | |
16409b0b | 8382 | (require 'gnus-art) |
eec82323 | 8383 | (let ((gnus-select-article-hook nil) ;Disable hook. |
16409b0b | 8384 | (gnus-article-prepare-hook nil) |
eec82323 LMI |
8385 | (gnus-mark-article-hook nil) ;Inhibit marking as read. |
8386 | (gnus-use-article-prefetch nil) | |
8387 | (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay. | |
a8151ef7 | 8388 | (gnus-use-trees nil) ;Inhibit updating tree buffer. |
23f87bed MB |
8389 | (gnus-visual nil) |
8390 | (gnus-keep-backlog nil) | |
8391 | (gnus-break-pages nil) | |
8392 | (gnus-summary-display-arrow nil) | |
8393 | (gnus-updated-mode-lines nil) | |
8394 | (gnus-auto-center-summary nil) | |
eec82323 | 8395 | (sum (current-buffer)) |
16409b0b | 8396 | (gnus-display-mime-function nil) |
eec82323 LMI |
8397 | (found nil) |
8398 | point) | |
8399 | (gnus-save-hidden-threads | |
8400 | (gnus-summary-select-article) | |
8401 | (set-buffer gnus-article-buffer) | |
16409b0b | 8402 | (goto-char (window-point (get-buffer-window (current-buffer)))) |
eec82323 LMI |
8403 | (when backward |
8404 | (forward-line -1)) | |
8405 | (while (not found) | |
8406 | (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current)) | |
8407 | (if (if backward | |
8408 | (re-search-backward regexp nil t) | |
8409 | (re-search-forward regexp nil t)) | |
8410 | ;; We found the regexp. | |
8411 | (progn | |
8412 | (setq found 'found) | |
8413 | (beginning-of-line) | |
8414 | (set-window-start | |
8415 | (get-buffer-window (current-buffer)) | |
8416 | (point)) | |
8417 | (forward-line 1) | |
16409b0b GM |
8418 | (set-window-point |
8419 | (get-buffer-window (current-buffer)) | |
8420 | (point)) | |
eec82323 LMI |
8421 | (set-buffer sum) |
8422 | (setq point (point))) | |
8423 | ;; We didn't find it, so we go to the next article. | |
8424 | (set-buffer sum) | |
8425 | (setq found 'not) | |
8426 | (while (eq found 'not) | |
8427 | (if (not (if backward (gnus-summary-find-prev) | |
8428 | (gnus-summary-find-next))) | |
8429 | ;; No more articles. | |
8430 | (setq found t) | |
8431 | ;; Select the next article and adjust point. | |
8432 | (unless (gnus-summary-article-sparse-p | |
8433 | (gnus-summary-article-number)) | |
8434 | (setq found nil) | |
8435 | (gnus-summary-select-article) | |
8436 | (set-buffer gnus-article-buffer) | |
8437 | (widen) | |
8438 | (goto-char (if backward (point-max) (point-min)))))))) | |
8439 | (gnus-message 7 "")) | |
8440 | ;; Return whether we found the regexp. | |
8441 | (when (eq found 'found) | |
8442 | (goto-char point) | |
8443 | (gnus-summary-show-thread) | |
8444 | (gnus-summary-goto-subject gnus-current-article) | |
8445 | (gnus-summary-position-point) | |
8446 | t))) | |
8447 | ||
23f87bed MB |
8448 | (defun gnus-find-matching-articles (header regexp) |
8449 | "Return a list of all articles that match REGEXP on HEADER. | |
8450 | This search includes all articles in the current group that Gnus has | |
8451 | fetched headers for, whether they are displayed or not." | |
8452 | (let ((articles nil) | |
8453 | (func `(lambda (h) (,(intern (concat "mail-header-" header)) h))) | |
8454 | (case-fold-search t)) | |
8455 | (dolist (header gnus-newsgroup-headers) | |
8456 | (when (string-match regexp (funcall func header)) | |
8457 | (push (mail-header-number header) articles))) | |
8458 | (nreverse articles))) | |
8459 | ||
eec82323 | 8460 | (defun gnus-summary-find-matching (header regexp &optional backward unread |
47b63dfa | 8461 | not-case-fold not-matching) |
eec82323 LMI |
8462 | "Return a list of all articles that match REGEXP on HEADER. |
8463 | The search stars on the current article and goes forwards unless | |
8464 | BACKWARD is non-nil. If BACKWARD is `all', do all articles. | |
8465 | If UNREAD is non-nil, only unread articles will | |
8466 | be taken into consideration. If NOT-CASE-FOLD, case won't be folded | |
a1506d29 | 8467 | in the comparisons. If NOT-MATCHING, return a list of all articles that |
47b63dfa SZ |
8468 | not match REGEXP on HEADER." |
8469 | (let ((case-fold-search (not not-case-fold)) | |
16409b0b GM |
8470 | articles d func) |
8471 | (if (consp header) | |
8472 | (if (eq (car header) 'extra) | |
8473 | (setq func | |
8474 | `(lambda (h) | |
8475 | (or (cdr (assq ',(cdr header) (mail-header-extra h))) | |
8476 | ""))) | |
8477 | (error "%s is an invalid header" header)) | |
8478 | (unless (fboundp (intern (concat "mail-header-" header))) | |
8479 | (error "%s is not a valid header" header)) | |
8480 | (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))) | |
47b63dfa SZ |
8481 | (dolist (d (if (eq backward 'all) |
8482 | gnus-newsgroup-data | |
8483 | (gnus-data-find-list | |
8484 | (gnus-summary-article-number) | |
8485 | (gnus-data-list backward)))) | |
8486 | (when (and (or (not unread) ; We want all articles... | |
8487 | (gnus-data-unread-p d)) ; Or just unreads. | |
8488 | (vectorp (gnus-data-header d)) ; It's not a pseudo. | |
8489 | (if not-matching | |
a1506d29 | 8490 | (not (string-match |
47b63dfa SZ |
8491 | regexp |
8492 | (funcall func (gnus-data-header d)))) | |
8493 | (string-match regexp | |
8494 | (funcall func (gnus-data-header d))))) | |
8495 | (push (gnus-data-number d) articles))) ; Success! | |
eec82323 LMI |
8496 | (nreverse articles))) |
8497 | ||
8498 | (defun gnus-summary-execute-command (header regexp command &optional backward) | |
8499 | "Search forward for an article whose HEADER matches REGEXP and execute COMMAND. | |
8500 | If HEADER is an empty string (or nil), the match is done on the entire | |
8501 | article. If BACKWARD (the prefix) is non-nil, search backward instead." | |
8502 | (interactive | |
8503 | (list (let ((completion-ignore-case t)) | |
8504 | (completing-read | |
8505 | "Header name: " | |
23f87bed MB |
8506 | (mapcar (lambda (header) (list (format "%s" header))) |
8507 | (append | |
8508 | '("Number" "Subject" "From" "Lines" "Date" | |
8509 | "Message-ID" "Xref" "References" "Body") | |
8510 | gnus-extra-headers)) | |
eec82323 LMI |
8511 | nil 'require-match)) |
8512 | (read-string "Regexp: ") | |
8513 | (read-key-sequence "Command: ") | |
8514 | current-prefix-arg)) | |
8515 | (when (equal header "Body") | |
8516 | (setq header "")) | |
eec82323 LMI |
8517 | ;; Hidden thread subtrees must be searched as well. |
8518 | (gnus-summary-show-all-threads) | |
8519 | ;; We don't want to change current point nor window configuration. | |
8520 | (save-excursion | |
8521 | (save-window-excursion | |
23f87bed MB |
8522 | (let (gnus-visual |
8523 | gnus-treat-strip-trailing-blank-lines | |
8524 | gnus-treat-strip-leading-blank-lines | |
8525 | gnus-treat-strip-multiple-blank-lines | |
8526 | gnus-treat-hide-boring-headers | |
8527 | gnus-treat-fold-newsgroups | |
8528 | gnus-article-prepare-hook) | |
8529 | (gnus-message 6 "Executing %s..." (key-description command)) | |
8530 | ;; We'd like to execute COMMAND interactively so as to give arguments. | |
8531 | (gnus-execute header regexp | |
8532 | `(call-interactively ',(key-binding command)) | |
8533 | backward) | |
8534 | (gnus-message 6 "Executing %s...done" (key-description command)))))) | |
eec82323 LMI |
8535 | |
8536 | (defun gnus-summary-beginning-of-article () | |
8537 | "Scroll the article back to the beginning." | |
8538 | (interactive) | |
eec82323 LMI |
8539 | (gnus-summary-select-article) |
8540 | (gnus-configure-windows 'article) | |
8541 | (gnus-eval-in-buffer-window gnus-article-buffer | |
8542 | (widen) | |
8543 | (goto-char (point-min)) | |
23f87bed | 8544 | (when gnus-break-pages |
eec82323 LMI |
8545 | (gnus-narrow-to-page)))) |
8546 | ||
8547 | (defun gnus-summary-end-of-article () | |
8548 | "Scroll to the end of the article." | |
8549 | (interactive) | |
eec82323 LMI |
8550 | (gnus-summary-select-article) |
8551 | (gnus-configure-windows 'article) | |
8552 | (gnus-eval-in-buffer-window gnus-article-buffer | |
8553 | (widen) | |
8554 | (goto-char (point-max)) | |
8555 | (recenter -3) | |
23f87bed MB |
8556 | (when gnus-break-pages |
8557 | (when (re-search-backward page-delimiter nil t) | |
8558 | (narrow-to-region (match-end 0) (point-max))) | |
eec82323 LMI |
8559 | (gnus-narrow-to-page)))) |
8560 | ||
23f87bed MB |
8561 | (defun gnus-summary-print-truncate-and-quote (string &optional len) |
8562 | "Truncate to LEN and quote all \"(\"'s in STRING." | |
8563 | (gnus-replace-in-string (if (and len (> (length string) len)) | |
8564 | (substring string 0 len) | |
8565 | string) | |
8566 | "[()]" "\\\\\\&")) | |
8567 | ||
6748645f | 8568 | (defun gnus-summary-print-article (&optional filename n) |
23f87bed MB |
8569 | "Generate and print a PostScript image of the process-marked (mail) articles. |
8570 | ||
8571 | If used interactively, print the current article if none are | |
8572 | process-marked. With prefix arg, prompt the user for the name of the | |
8573 | file to save in. | |
6748645f | 8574 | |
23f87bed MB |
8575 | When used from Lisp, accept two optional args FILENAME and N. N means |
8576 | to print the next N articles. If N is negative, print the N previous | |
8577 | articles. If N is nil and articles have been marked with the process | |
8578 | mark, print these instead. | |
eec82323 | 8579 | |
16409b0b | 8580 | If the optional first argument FILENAME is nil, send the image to the |
6748645f LMI |
8581 | printer. If FILENAME is a string, save the PostScript image in a file with |
8582 | that name. If FILENAME is a number, prompt the user for the name of the file | |
eec82323 | 8583 | to save in." |
676a7cc9 | 8584 | (interactive (list (ps-print-preprint current-prefix-arg))) |
6748645f LMI |
8585 | (dolist (article (gnus-summary-work-articles n)) |
8586 | (gnus-summary-select-article nil nil 'pseudo article) | |
8587 | (gnus-eval-in-buffer-window gnus-article-buffer | |
23f87bed | 8588 | (gnus-print-buffer)) |
676a7cc9 SZ |
8589 | (gnus-summary-remove-process-mark article)) |
8590 | (ps-despool filename)) | |
eec82323 | 8591 | |
23f87bed MB |
8592 | (defun gnus-print-buffer () |
8593 | (let ((buffer (generate-new-buffer " *print*"))) | |
8594 | (unwind-protect | |
8595 | (progn | |
8596 | (copy-to-buffer buffer (point-min) (point-max)) | |
8597 | (set-buffer buffer) | |
8598 | (gnus-remove-text-with-property 'gnus-decoration) | |
8599 | (when (gnus-visual-p 'article-highlight 'highlight) | |
8600 | ;; Copy-to-buffer doesn't copy overlay. So redo | |
8601 | ;; highlight. | |
8602 | (let ((gnus-article-buffer buffer)) | |
8603 | (gnus-article-highlight-citation t) | |
8604 | (gnus-article-highlight-signature) | |
8605 | (gnus-article-emphasize) | |
8606 | (gnus-article-delete-invisible-text))) | |
8607 | (let ((ps-left-header | |
8608 | (list | |
8609 | (concat "(" | |
8610 | (gnus-summary-print-truncate-and-quote | |
8611 | (mail-header-subject gnus-current-headers) | |
8612 | 66) ")") | |
8613 | (concat "(" | |
8614 | (gnus-summary-print-truncate-and-quote | |
8615 | (mail-header-from gnus-current-headers) | |
8616 | 45) ")"))) | |
8617 | (ps-right-header | |
8618 | (list | |
8619 | "/pagenumberstring load" | |
8620 | (concat "(" | |
8621 | (mail-header-date gnus-current-headers) ")")))) | |
8622 | (gnus-run-hooks 'gnus-ps-print-hook) | |
8623 | (save-excursion | |
8624 | (if window-system | |
8625 | (ps-spool-buffer-with-faces) | |
8626 | (ps-spool-buffer))))) | |
8627 | (kill-buffer buffer)))) | |
8628 | ||
eec82323 | 8629 | (defun gnus-summary-show-article (&optional arg) |
23f87bed | 8630 | "Force redisplaying of the current article. |
16409b0b GM |
8631 | If ARG (the prefix) is a number, show the article with the charset |
8632 | defined in `gnus-summary-show-article-charset-alist', or the charset | |
23f87bed | 8633 | input. |
16409b0b | 8634 | If ARG (the prefix) is non-nil and not a number, show the raw article |
23f87bed MB |
8635 | without any article massaging functions being run. Normally, the key |
8636 | strokes are `C-u g'." | |
eec82323 | 8637 | (interactive "P") |
16409b0b GM |
8638 | (cond |
8639 | ((numberp arg) | |
23f87bed | 8640 | (gnus-summary-show-article t) |
16409b0b GM |
8641 | (let ((gnus-newsgroup-charset |
8642 | (or (cdr (assq arg gnus-summary-show-article-charset-alist)) | |
23f87bed MB |
8643 | (mm-read-coding-system |
8644 | "View as charset: " ;; actually it is coding system. | |
8645 | (save-excursion | |
8646 | (set-buffer gnus-article-buffer) | |
8647 | (mm-detect-coding-region (point) (point-max)))))) | |
16409b0b | 8648 | (gnus-newsgroup-ignored-charsets 'gnus-all)) |
23f87bed MB |
8649 | (gnus-summary-select-article nil 'force) |
8650 | (let ((deps gnus-newsgroup-dependencies) | |
8651 | head header lines) | |
8652 | (save-excursion | |
8653 | (set-buffer gnus-original-article-buffer) | |
8654 | (save-restriction | |
8655 | (message-narrow-to-head) | |
8656 | (setq head (buffer-string)) | |
8657 | (goto-char (point-min)) | |
8658 | (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t) | |
8659 | (goto-char (point-max)) | |
8660 | (widen) | |
8661 | (setq lines (1- (count-lines (point) (point-max)))))) | |
8662 | (with-temp-buffer | |
8663 | (insert (format "211 %d Article retrieved.\n" | |
8664 | (cdr gnus-article-current))) | |
8665 | (insert head) | |
8666 | (if lines (insert (format "Lines: %d\n" lines))) | |
8667 | (insert ".\n") | |
8668 | (let ((nntp-server-buffer (current-buffer))) | |
8669 | (setq header (car (gnus-get-newsgroup-headers deps t)))))) | |
8670 | (gnus-data-set-header | |
8671 | (gnus-data-find (cdr gnus-article-current)) | |
8672 | header) | |
8673 | (gnus-summary-update-article-line | |
8674 | (cdr gnus-article-current) header) | |
8675 | (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t) | |
8676 | (gnus-summary-update-secondary-mark (cdr gnus-article-current)))))) | |
16409b0b GM |
8677 | ((not arg) |
8678 | ;; Select the article the normal way. | |
8679 | (gnus-summary-select-article nil 'force)) | |
8680 | (t | |
8681 | ;; We have to require this here to make sure that the following | |
8682 | ;; dynamic binding isn't shadowed by autoloading. | |
8683 | (require 'gnus-async) | |
8684 | (require 'gnus-art) | |
eec82323 LMI |
8685 | ;; Bind the article treatment functions to nil. |
8686 | (let ((gnus-have-all-headers t) | |
eec82323 | 8687 | gnus-article-prepare-hook |
16409b0b GM |
8688 | gnus-article-decode-hook |
8689 | gnus-display-mime-function | |
8690 | gnus-break-pages) | |
8691 | ;; Destroy any MIME parts. | |
8692 | (when (gnus-buffer-live-p gnus-article-buffer) | |
8693 | (save-excursion | |
8694 | (set-buffer gnus-article-buffer) | |
8695 | (mm-destroy-parts gnus-article-mime-handles) | |
8696 | ;; Set it to nil for safety reason. | |
8697 | (setq gnus-article-mime-handle-alist nil) | |
8698 | (setq gnus-article-mime-handles nil))) | |
8699 | (gnus-summary-select-article nil 'force)))) | |
eec82323 LMI |
8700 | (gnus-summary-goto-subject gnus-current-article) |
8701 | (gnus-summary-position-point)) | |
8702 | ||
23f87bed MB |
8703 | (defun gnus-summary-show-raw-article () |
8704 | "Show the raw article without any article massaging functions being run." | |
8705 | (interactive) | |
8706 | (gnus-summary-show-article t)) | |
8707 | ||
eec82323 LMI |
8708 | (defun gnus-summary-verbose-headers (&optional arg) |
8709 | "Toggle permanent full header display. | |
8710 | If ARG is a positive number, turn header display on. | |
8711 | If ARG is a negative number, turn header display off." | |
8712 | (interactive "P") | |
eec82323 LMI |
8713 | (setq gnus-show-all-headers |
8714 | (cond ((or (not (numberp arg)) | |
8715 | (zerop arg)) | |
8716 | (not gnus-show-all-headers)) | |
8717 | ((natnump arg) | |
8718 | t))) | |
8719 | (gnus-summary-show-article)) | |
8720 | ||
8721 | (defun gnus-summary-toggle-header (&optional arg) | |
8722 | "Show the headers if they are hidden, or hide them if they are shown. | |
8723 | If ARG is a positive number, show the entire header. | |
8724 | If ARG is a negative number, hide the unwanted header lines." | |
8725 | (interactive "P") | |
23f87bed MB |
8726 | (let ((window (and (gnus-buffer-live-p gnus-article-buffer) |
8727 | (get-buffer-window gnus-article-buffer t)))) | |
8728 | (with-current-buffer gnus-article-buffer | |
8729 | (widen) | |
8730 | (article-narrow-to-head) | |
16409b0b GM |
8731 | (let* ((buffer-read-only nil) |
8732 | (inhibit-point-motion-hooks t) | |
23f87bed MB |
8733 | (hidden (if (numberp arg) |
8734 | (>= arg 0) | |
8735 | (gnus-article-hidden-text-p 'headers))) | |
8736 | s e) | |
8737 | (delete-region (point-min) (point-max)) | |
667e0ba6 SM |
8738 | (with-current-buffer gnus-original-article-buffer |
8739 | (goto-char (setq s (point-min))) | |
23f87bed MB |
8740 | (setq e (if (search-forward "\n\n" nil t) |
8741 | (1- (point)) | |
8742 | (point-max)))) | |
667e0ba6 | 8743 | (insert-buffer-substring gnus-original-article-buffer s e) |
23f87bed MB |
8744 | (run-hooks 'gnus-article-decode-hook) |
8745 | (if hidden | |
8746 | (let ((gnus-treat-hide-headers nil) | |
8747 | (gnus-treat-hide-boring-headers nil)) | |
8748 | (gnus-delete-wash-type 'headers) | |
8749 | (gnus-treat-article 'head)) | |
8750 | (gnus-treat-article 'head)) | |
8751 | (widen) | |
8752 | (if window | |
8753 | (set-window-start window (goto-char (point-min)))) | |
8754 | (if gnus-break-pages | |
8755 | (gnus-narrow-to-page) | |
8756 | (when (gnus-visual-p 'page-marker) | |
8757 | (let ((buffer-read-only nil)) | |
8758 | (gnus-remove-text-with-property 'gnus-prev) | |
8759 | (gnus-remove-text-with-property 'gnus-next)))) | |
16409b0b | 8760 | (gnus-set-mode-line 'article))))) |
eec82323 LMI |
8761 | |
8762 | (defun gnus-summary-show-all-headers () | |
8763 | "Make all header lines visible." | |
8764 | (interactive) | |
23f87bed | 8765 | (gnus-summary-toggle-header 1)) |
eec82323 | 8766 | |
eec82323 LMI |
8767 | (defun gnus-summary-caesar-message (&optional arg) |
8768 | "Caesar rotate the current article by 13. | |
8769 | The numerical prefix specifies how many places to rotate each letter | |
8770 | forward." | |
8771 | (interactive "P") | |
eec82323 LMI |
8772 | (gnus-summary-select-article) |
8773 | (let ((mail-header-separator "")) | |
8774 | (gnus-eval-in-buffer-window gnus-article-buffer | |
8775 | (save-restriction | |
8776 | (widen) | |
8777 | (let ((start (window-start)) | |
8778 | buffer-read-only) | |
8779 | (message-caesar-buffer-body arg) | |
8780 | (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
8781 | ||
23f87bed MB |
8782 | (autoload 'unmorse-region "morse" |
8783 | "Convert morse coded text in region to ordinary ASCII text." | |
8784 | t) | |
8785 | ||
8786 | (defun gnus-summary-morse-message (&optional arg) | |
8787 | "Morse decode the current article." | |
8788 | (interactive "P") | |
8789 | (gnus-summary-select-article) | |
8790 | (let ((mail-header-separator "")) | |
8791 | (gnus-eval-in-buffer-window gnus-article-buffer | |
8792 | (save-excursion | |
8793 | (save-restriction | |
8794 | (widen) | |
8795 | (let ((pos (window-start)) | |
8796 | buffer-read-only) | |
8797 | (goto-char (point-min)) | |
8798 | (when (message-goto-body) | |
8799 | (gnus-narrow-to-body)) | |
8800 | (goto-char (point-min)) | |
8801 |