Commit | Line | Data |
---|---|---|
eec82323 | 1 | ;;; gnus-sum.el --- summary mode commands for Gnus |
e84b4b86 | 2 | |
ba318903 | 3 | ;; Copyright (C) 1996-2014 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 | ||
5e809f55 | 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
eec82323 | 11 | ;; it under the terms of the GNU General Public License as published by |
5e809f55 GM |
12 | ;; the Free Software Foundation, either version 3 of the License, or |
13 | ;; (at your option) any later version. | |
eec82323 LMI |
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 | |
01ccbb85 | 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
eec82323 LMI |
18 | ;; GNU General Public License for more details. |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
5e809f55 | 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
eec82323 LMI |
22 | |
23 | ;;; Commentary: | |
24 | ||
25 | ;;; Code: | |
26 | ||
23f87bed | 27 | (eval-when-compile |
9efa445f | 28 | (require 'cl)) |
d029b5d2 KY |
29 | (eval-when-compile |
30 | (when (featurep 'xemacs) | |
31 | (require 'easy-mmode))) ; for `define-minor-mode' | |
9efa445f DN |
32 | |
33 | (defvar tool-bar-mode) | |
34 | (defvar gnus-tmp-header) | |
5ab7173c | 35 | |
eec82323 LMI |
36 | (require 'gnus) |
37 | (require 'gnus-group) | |
38 | (require 'gnus-spec) | |
39 | (require 'gnus-range) | |
40 | (require 'gnus-int) | |
41 | (require 'gnus-undo) | |
6748645f | 42 | (require 'gnus-util) |
18c06a99 | 43 | (require 'gmm-utils) |
16409b0b | 44 | (require 'mm-decode) |
08c9a385 | 45 | (require 'nnoo) |
23f87bed | 46 | |
6748645f | 47 | (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t) |
d4dfaa19 | 48 | (autoload 'gnus-cache-write-active "gnus-cache") |
23f87bed MB |
49 | (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t) |
50 | (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t) | |
531e5812 | 51 | (autoload 'gnus-pick-line-number "gnus-salt" nil t) |
08c9a385 | 52 | (autoload 'mm-uu-dissect "mm-uu") |
23f87bed MB |
53 | (autoload 'gnus-article-outlook-deuglify-article "deuglify" |
54 | "Deuglify broken Outlook (Express) articles and redisplay." | |
55 | t) | |
56 | (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t) | |
57 | (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t) | |
58 | (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t) | |
1b811c90 AC |
59 | (autoload 'nnir-article-rsv "nnir" nil nil 'macro) |
60 | (autoload 'nnir-article-group "nnir" nil nil 'macro) | |
eec82323 LMI |
61 | |
62 | (defcustom gnus-kill-summary-on-exit t | |
63 | "*If non-nil, kill the summary buffer when you exit from it. | |
64 | If nil, the summary will become a \"*Dead Summary*\" buffer, and | |
65 | it will be killed sometime later." | |
66 | :group 'gnus-summary-exit | |
67 | :type 'boolean) | |
68 | ||
01c52d31 MB |
69 | (defcustom gnus-summary-next-group-on-exit t |
70 | "If non-nil, go to the next unread newsgroup on summary exit. | |
71 | See `gnus-group-goto-unread'." | |
72 | :link '(custom-manual "(gnus)Group Maneuvering") | |
73 | :group 'gnus-summary-exit | |
330f707b | 74 | :version "23.1" ;; No Gnus |
01c52d31 MB |
75 | :type 'boolean) |
76 | ||
b1992461 KY |
77 | (defcustom gnus-summary-stop-at-end-of-message nil |
78 | "If non-nil, don't select the next message when using `SPC'." | |
79 | :link '(custom-manual "(gnus)Group Maneuvering") | |
80 | :group 'gnus-summary-maneuvering | |
1a10d421 | 81 | :version "24.1" |
b1992461 KY |
82 | :type 'boolean) |
83 | ||
eec82323 LMI |
84 | (defcustom gnus-fetch-old-headers nil |
85 | "*Non-nil means that Gnus will try to build threads by grabbing old headers. | |
01c52d31 MB |
86 | If an unread article in the group refers to an older, already |
87 | read (or just marked as read) article, the old article will not | |
88 | normally be displayed in the Summary buffer. If this variable is | |
89 | t, Gnus will attempt to grab the headers to the old articles, and | |
90 | thereby build complete threads. If it has the value `some', all | |
91 | old headers will be fetched but only enough headers to connect | |
92 | otherwise loose threads will be displayed. This variable can | |
93 | also be a number. In that case, no more than that number of old | |
94 | headers will be fetched. If it has the value `invisible', all | |
6748645f | 95 | old headers will be fetched, but none will be displayed. |
eec82323 | 96 | |
01c52d31 MB |
97 | The server has to support NOV for any of this to work. |
98 | ||
99 | This feature can seriously impact performance it ignores all | |
f394fa25 MB |
100 | locally cached header entries. Setting it to t for groups for a |
101 | server that doesn't expire articles (such as news.gmane.org), | |
102 | leads to very slow summary generation." | |
eec82323 LMI |
103 | :group 'gnus-thread |
104 | :type '(choice (const :tag "off" nil) | |
1232b9cb | 105 | (const :tag "on" t) |
eec82323 | 106 | (const some) |
1232b9cb | 107 | (const invisible) |
eec82323 LMI |
108 | number |
109 | (sexp :menu-tag "other" t))) | |
110 | ||
01c52d31 | 111 | (defcustom gnus-refer-thread-limit 500 |
6748645f LMI |
112 | "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread]. |
113 | If t, fetch all the available old headers." | |
114 | :group 'gnus-thread | |
115 | :type '(choice number | |
116 | (sexp :menu-tag "other" t))) | |
117 | ||
47f0b35e AC |
118 | (defcustom gnus-refer-thread-use-nnir nil |
119 | "*Use nnir to search an entire server when referring threads. A | |
120 | nil value will only search for thread-related articles in the | |
121 | current group." | |
2bed3f04 | 122 | :version "24.1" |
47f0b35e AC |
123 | :group 'gnus-thread |
124 | :type 'boolean) | |
125 | ||
eec82323 LMI |
126 | (defcustom gnus-summary-make-false-root 'adopt |
127 | "*nil means that Gnus won't gather loose threads. | |
128 | If the root of a thread has expired or been read in a previous | |
129 | session, the information necessary to build a complete thread has been | |
130 | lost. Instead of having many small sub-threads from this original thread | |
131 | scattered all over the summary buffer, Gnus can gather them. | |
132 | ||
133 | If non-nil, Gnus will try to gather all loose sub-threads from an | |
134 | original thread into one large thread. | |
135 | ||
136 | If this variable is non-nil, it should be one of `none', `adopt', | |
137 | `dummy' or `empty'. | |
138 | ||
139 | If this variable is `none', Gnus will not make a false root, but just | |
140 | present the sub-threads after another. | |
141 | If this variable is `dummy', Gnus will create a dummy root that will | |
142 | have all the sub-threads as children. | |
143 | If this variable is `adopt', Gnus will make one of the \"children\" | |
144 | the parent and mark all the step-children as such. | |
145 | If this variable is `empty', the \"children\" are printed with empty | |
01ccbb85 | 146 | subject fields. (Or rather, they will be printed with a string |
eec82323 LMI |
147 | given by the `gnus-summary-same-subject' variable.)" |
148 | :group 'gnus-thread | |
149 | :type '(choice (const :tag "off" nil) | |
150 | (const none) | |
151 | (const dummy) | |
152 | (const adopt) | |
153 | (const empty))) | |
154 | ||
23f87bed MB |
155 | (defcustom gnus-summary-make-false-root-always nil |
156 | "Always make a false dummy root." | |
bf247b6e | 157 | :version "22.1" |
23f87bed MB |
158 | :group 'gnus-thread |
159 | :type 'boolean) | |
160 | ||
eec82323 LMI |
161 | (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$" |
162 | "*A regexp to match subjects to be excluded from loose thread gathering. | |
163 | As loose thread gathering is done on subjects only, that means that | |
164 | there can be many false gatherings performed. By rooting out certain | |
165 | common subjects, gathering might become saner." | |
166 | :group 'gnus-thread | |
167 | :type 'regexp) | |
168 | ||
169 | (defcustom gnus-summary-gather-subject-limit nil | |
170 | "*Maximum length of subject comparisons when gathering loose threads. | |
171 | Use nil to compare full subjects. Setting this variable to a low | |
172 | number will help gather threads that have been corrupted by | |
173 | newsreaders chopping off subject lines, but it might also mean that | |
174 | unrelated articles that have subject that happen to begin with the | |
175 | same few characters will be incorrectly gathered. | |
176 | ||
177 | If this variable is `fuzzy', Gnus will use a fuzzy algorithm when | |
178 | comparing subjects." | |
179 | :group 'gnus-thread | |
180 | :type '(choice (const :tag "off" nil) | |
181 | (const fuzzy) | |
182 | (sexp :menu-tag "on" t))) | |
183 | ||
6748645f LMI |
184 | (defcustom gnus-simplify-subject-functions nil |
185 | "List of functions taking a string argument that simplify subjects. | |
186 | The functions are applied recursively. | |
187 | ||
23f87bed MB |
188 | Useful functions to put in this list include: |
189 | `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy', | |
190 | `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'." | |
6748645f LMI |
191 | :group 'gnus-thread |
192 | :type '(repeat function)) | |
193 | ||
eec82323 | 194 | (defcustom gnus-simplify-ignored-prefixes nil |
23f87bed | 195 | "*Remove matches for this regexp from subject lines when simplifying fuzzily." |
eec82323 LMI |
196 | :group 'gnus-thread |
197 | :type '(choice (const :tag "off" nil) | |
198 | regexp)) | |
199 | ||
200 | (defcustom gnus-build-sparse-threads nil | |
201 | "*If non-nil, fill in the gaps in threads. | |
202 | If `some', only fill in the gaps that are needed to tie loose threads | |
203 | together. If `more', fill in all leaf nodes that Gnus can find. If | |
204 | non-nil and non-`some', fill in all gaps that Gnus manages to guess." | |
205 | :group 'gnus-thread | |
206 | :type '(choice (const :tag "off" nil) | |
207 | (const some) | |
208 | (const more) | |
209 | (sexp :menu-tag "all" t))) | |
210 | ||
211 | (defcustom gnus-summary-thread-gathering-function | |
212 | 'gnus-gather-threads-by-subject | |
6748645f | 213 | "*Function used for gathering loose threads. |
eec82323 LMI |
214 | There are two pre-defined functions: `gnus-gather-threads-by-subject', |
215 | which only takes Subjects into consideration; and | |
216 | `gnus-gather-threads-by-references', which compared the References | |
217 | headers of the articles to find matches." | |
218 | :group 'gnus-thread | |
22115a9e RS |
219 | :type '(radio (function-item gnus-gather-threads-by-subject) |
220 | (function-item gnus-gather-threads-by-references) | |
221 | (function :tag "other"))) | |
eec82323 | 222 | |
eec82323 LMI |
223 | (defcustom gnus-summary-same-subject "" |
224 | "*String indicating that the current article has the same subject as the previous. | |
225 | This variable will only be used if the value of | |
226 | `gnus-summary-make-false-root' is `empty'." | |
227 | :group 'gnus-summary-format | |
228 | :type 'string) | |
229 | ||
1d297c49 | 230 | (defcustom gnus-summary-goto-unread nil |
16409b0b GM |
231 | "*If t, many commands will go to the next unread article. |
232 | This applies to marking commands as well as other commands that | |
233 | \"naturally\" select the next article, like, for instance, `SPC' at | |
234 | the end of an article. | |
235 | ||
236 | If nil, the marking commands do NOT go to the next unread article | |
2642ac8f | 237 | \(they go to the next article instead). If `never', commands that |
16409b0b GM |
238 | usually go to the next unread article, will go to the next article, |
239 | whether it is read or not." | |
1d297c49 | 240 | :version "24.1" |
eec82323 LMI |
241 | :group 'gnus-summary-marks |
242 | :link '(custom-manual "(gnus)Setting Marks") | |
243 | :type '(choice (const :tag "off" nil) | |
244 | (const never) | |
245 | (sexp :menu-tag "on" t))) | |
246 | ||
247 | (defcustom gnus-summary-default-score 0 | |
248 | "*Default article score level. | |
249 | All scores generated by the score files will be added to this score. | |
250 | If this variable is nil, scoring will be disabled." | |
251 | :group 'gnus-score-default | |
252 | :type '(choice (const :tag "disable") | |
253 | integer)) | |
254 | ||
23f87bed MB |
255 | (defcustom gnus-summary-default-high-score 0 |
256 | "*Default threshold for a high scored article. | |
257 | An article will be highlighted as high scored if its score is greater | |
258 | than this score." | |
bf247b6e | 259 | :version "22.1" |
23f87bed MB |
260 | :group 'gnus-score-default |
261 | :type 'integer) | |
262 | ||
263 | (defcustom gnus-summary-default-low-score 0 | |
264 | "*Default threshold for a low scored article. | |
265 | An article will be highlighted as low scored if its score is smaller | |
266 | than this score." | |
bf247b6e | 267 | :version "22.1" |
23f87bed MB |
268 | :group 'gnus-score-default |
269 | :type 'integer) | |
270 | ||
eec82323 LMI |
271 | (defcustom gnus-summary-zcore-fuzz 0 |
272 | "*Fuzziness factor for the zcore in the summary buffer. | |
273 | Articles with scores closer than this to `gnus-summary-default-score' | |
274 | will not be marked." | |
275 | :group 'gnus-summary-format | |
276 | :type 'integer) | |
277 | ||
278 | (defcustom gnus-simplify-subject-fuzzy-regexp nil | |
279 | "*Strings to be removed when doing fuzzy matches. | |
280 | This can either be a regular expression or list of regular expressions | |
281 | that will be removed from subject strings if fuzzy subject | |
282 | simplification is selected." | |
283 | :group 'gnus-thread | |
284 | :type '(repeat regexp)) | |
285 | ||
286 | (defcustom gnus-show-threads t | |
287 | "*If non-nil, display threads in summary mode." | |
288 | :group 'gnus-thread | |
289 | :type 'boolean) | |
290 | ||
291 | (defcustom gnus-thread-hide-subtree nil | |
292 | "*If non-nil, hide all threads initially. | |
23f87bed | 293 | This can be a predicate specifier which says which threads to hide. |
eec82323 | 294 | If threads are hidden, you have to run the command |
4a2358e9 | 295 | `gnus-summary-show-thread' by hand or select an article." |
eec82323 | 296 | :group 'gnus-thread |
23f87bed MB |
297 | :type '(radio (sexp :format "Non-nil\n" |
298 | :match (lambda (widget value) | |
299 | (not (or (consp value) (functionp value)))) | |
300 | :value t) | |
301 | (const nil) | |
ad136a7c | 302 | (sexp :tag "Predicate specifier"))) |
eec82323 LMI |
303 | |
304 | (defcustom gnus-thread-hide-killed t | |
305 | "*If non-nil, hide killed threads automatically." | |
306 | :group 'gnus-thread | |
307 | :type 'boolean) | |
308 | ||
6748645f LMI |
309 | (defcustom gnus-thread-ignore-subject t |
310 | "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header. | |
311 | If nil, articles that have different subjects from their parents will | |
312 | start separate threads." | |
eec82323 LMI |
313 | :group 'gnus-thread |
314 | :type 'boolean) | |
315 | ||
316 | (defcustom gnus-thread-operation-ignore-subject t | |
317 | "*If non-nil, subjects will be ignored when doing thread commands. | |
318 | This affects commands like `gnus-summary-kill-thread' and | |
319 | `gnus-summary-lower-thread'. | |
320 | ||
321 | If this variable is nil, articles in the same thread with different | |
322 | subjects will not be included in the operation in question. If this | |
323 | variable is `fuzzy', only articles that have subjects that are fuzzily | |
324 | equal will be included." | |
325 | :group 'gnus-thread | |
326 | :type '(choice (const :tag "off" nil) | |
327 | (const fuzzy) | |
328 | (sexp :tag "on" t))) | |
329 | ||
330 | (defcustom gnus-thread-indent-level 4 | |
331 | "*Number that says how much each sub-thread should be indented." | |
332 | :group 'gnus-thread | |
333 | :type 'integer) | |
334 | ||
335 | (defcustom gnus-auto-extend-newsgroup t | |
336 | "*If non-nil, extend newsgroup forward and backward when requested." | |
337 | :group 'gnus-summary-choose | |
338 | :type 'boolean) | |
339 | ||
340 | (defcustom gnus-auto-select-first t | |
651408cb MB |
341 | "If non-nil, select an article on group entry. |
342 | An article is selected automatically when entering a group | |
343 | e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or | |
344 | `gnus-summary-catchup-and-goto-next-group'. | |
345 | ||
346 | Which article is selected is controlled by the variable | |
347 | `gnus-auto-select-subject'. | |
23f87bed MB |
348 | |
349 | If you want to prevent automatic selection of articles in some | |
350 | newsgroups, set the variable to nil in `gnus-select-group-hook'." | |
651408cb MB |
351 | ;; Commands include... |
352 | ;; \\<gnus-group-mode-map>\\[gnus-group-read-group] | |
353 | ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page] | |
354 | ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group] | |
eec82323 LMI |
355 | :group 'gnus-group-select |
356 | :type '(choice (const :tag "none" nil) | |
23f87bed MB |
357 | (sexp :menu-tag "first" t))) |
358 | ||
a1347097 | 359 | (defcustom gnus-auto-select-subject 'unseen-or-unread |
23f87bed MB |
360 | "*Says what subject to place under point when entering a group. |
361 | ||
362 | This variable can either be the symbols `first' (place point on the | |
363 | first subject), `unread' (place point on the subject line of the first | |
364 | unread article), `best' (place point on the subject line of the | |
3ed8598c | 365 | highest-scored article), `unseen' (place point on the subject line of |
99b5aab7 | 366 | the first unseen article), `unseen-or-unread' (place point on the subject |
647559c2 | 367 | line of the first unseen article or, if all articles have been seen, on the |
23f87bed MB |
368 | subject line of the first unread article), or a function to be called to |
369 | place point on some subject line." | |
a1347097 | 370 | :version "24.1" |
23f87bed MB |
371 | :group 'gnus-group-select |
372 | :type '(choice (const best) | |
373 | (const unread) | |
374 | (const first) | |
375 | (const unseen) | |
4d9db491 G |
376 | (const unseen-or-unread) |
377 | (function :tag "Function to call"))) | |
eec82323 LMI |
378 | |
379 | (defcustom gnus-auto-select-next t | |
380 | "*If non-nil, offer to go to the next group from the end of the previous. | |
381 | If the value is t and the next newsgroup is empty, Gnus will exit | |
23f87bed MB |
382 | summary mode and go back to group mode. If the value is neither nil |
383 | nor t, Gnus will select the following unread newsgroup. In | |
eec82323 LMI |
384 | particular, if the value is the symbol `quietly', the next unread |
385 | newsgroup will be selected without any confirmation, and if it is | |
386 | `almost-quietly', the next group will be selected without any | |
387 | confirmation if you are located on the last article in the group. | |
23f87bed | 388 | Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command |
eec82323 LMI |
389 | will go to the next group without confirmation." |
390 | :group 'gnus-summary-maneuvering | |
391 | :type '(choice (const :tag "off" nil) | |
392 | (const quietly) | |
393 | (const almost-quietly) | |
394 | (const slightly-quietly) | |
395 | (sexp :menu-tag "on" t))) | |
396 | ||
397 | (defcustom gnus-auto-select-same nil | |
6748645f LMI |
398 | "*If non-nil, select the next article with the same subject. |
399 | If there are no more articles with the same subject, go to | |
400 | the first unread article." | |
eec82323 LMI |
401 | :group 'gnus-summary-maneuvering |
402 | :type 'boolean) | |
403 | ||
01c52d31 MB |
404 | (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect |
405 | "What article should be selected after exiting an ephemeral group. | |
406 | Valid values include: | |
407 | ||
408 | `next' | |
409 | Select the next article. | |
410 | `next-unread' | |
411 | Select the next unread article. | |
412 | `next-noselect' | |
413 | Move the cursor to the next article. This is the default. | |
414 | `next-unread-noselect' | |
415 | Move the cursor to the next unread article. | |
416 | ||
417 | If it has any other value or there is no next (unread) article, the | |
418 | article selected before entering to the ephemeral group will appear." | |
330f707b | 419 | :version "23.1" ;; No Gnus |
01c52d31 MB |
420 | :group 'gnus-summary-maneuvering |
421 | :type '(choice :format "%{%t%}:\n %[Value Menu%] %v" | |
422 | (const next) (const next-unread) | |
423 | (const next-noselect) (const next-unread-noselect) | |
424 | (sexp :tag "other" :value nil))) | |
425 | ||
23f87bed MB |
426 | (defcustom gnus-auto-goto-ignores 'unfetched |
427 | "*Says how to handle unfetched articles when maneuvering. | |
428 | ||
429 | This variable can either be the symbols nil (maneuver to any | |
430 | article), `undownloaded' (maneuvering while unplugged ignores articles | |
431 | that have not been fetched), `always-undownloaded' (maneuvering always | |
432 | ignores articles that have not been fetched), `unfetched' (maneuvering | |
433 | ignores articles whose headers have not been fetched). | |
434 | ||
435 | NOTE: The list of unfetched articles will always be nil when plugged | |
436 | and, when unplugged, a subset of the undownloaded article list." | |
bf247b6e | 437 | :version "22.1" |
23f87bed MB |
438 | :group 'gnus-summary-maneuvering |
439 | :type '(choice (const :tag "None" nil) | |
440 | (const :tag "Undownloaded when unplugged" undownloaded) | |
441 | (const :tag "Undownloaded" always-undownloaded) | |
442 | (const :tag "Unfetched" unfetched))) | |
443 | ||
eec82323 LMI |
444 | (defcustom gnus-summary-check-current nil |
445 | "*If non-nil, consider the current article when moving. | |
446 | The \"unread\" movement commands will stay on the same line if the | |
447 | current article is unread." | |
448 | :group 'gnus-summary-maneuvering | |
449 | :type 'boolean) | |
450 | ||
c38e0c97 | 451 | (defcustom gnus-auto-center-summary |
89b163db | 452 | (max (or (bound-and-true-p scroll-margin) 0) 2) |
eec82323 LMI |
453 | "*If non-nil, always center the current summary buffer. |
454 | In particular, if `vertical' do only vertical recentering. If non-nil | |
455 | and non-`vertical', do both horizontal and vertical recentering." | |
456 | :group 'gnus-summary-maneuvering | |
457 | :type '(choice (const :tag "none" nil) | |
458 | (const vertical) | |
16409b0b | 459 | (integer :tag "height") |
eec82323 LMI |
460 | (sexp :menu-tag "both" t))) |
461 | ||
2d04f304 G |
462 | (defcustom gnus-auto-center-group t |
463 | "If non-nil, always center the group buffer." | |
464 | :group 'gnus-summary-maneuvering | |
465 | :type 'boolean) | |
23f87bed | 466 | |
eec82323 LMI |
467 | (defcustom gnus-show-all-headers nil |
468 | "*If non-nil, don't hide any headers." | |
469 | :group 'gnus-article-hiding | |
470 | :group 'gnus-article-headers | |
471 | :type 'boolean) | |
472 | ||
473 | (defcustom gnus-summary-ignore-duplicates nil | |
474 | "*If non-nil, ignore articles with identical Message-ID headers." | |
475 | :group 'gnus-summary | |
476 | :type 'boolean) | |
6748645f | 477 | |
1d297c49 | 478 | (defcustom gnus-single-article-buffer nil |
eec82323 LMI |
479 | "*If non-nil, display all articles in the same buffer. |
480 | If nil, each group will get its own article buffer." | |
1d297c49 | 481 | :version "24.1" |
eec82323 LMI |
482 | :group 'gnus-article-various |
483 | :type 'boolean) | |
484 | ||
71e691a5 G |
485 | (defcustom gnus-widen-article-window nil |
486 | "If non-nil, selecting the article buffer will display only the article buffer." | |
487 | :version "24.1" | |
488 | :group 'gnus-article-various | |
489 | :type 'boolean) | |
490 | ||
eec82323 LMI |
491 | (defcustom gnus-break-pages t |
492 | "*If non-nil, do page breaking on articles. | |
493 | The page delimiter is specified by the `gnus-page-delimiter' | |
494 | variable." | |
495 | :group 'gnus-article-various | |
496 | :type 'boolean) | |
497 | ||
eec82323 LMI |
498 | (defcustom gnus-move-split-methods nil |
499 | "*Variable used to suggest where articles are to be moved to. | |
23f87bed MB |
500 | It uses the same syntax as the `gnus-split-methods' variable. |
501 | However, whereas `gnus-split-methods' specifies file names as targets, | |
502 | this variable specifies group names." | |
eec82323 | 503 | :group 'gnus-summary-mail |
6748645f LMI |
504 | :type '(repeat (choice (list :value (fun) function) |
505 | (cons :value ("" "") regexp (repeat string)) | |
506 | (sexp :value nil)))) | |
eec82323 | 507 | |
01c52d31 MB |
508 | (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix |
509 | "Function used to compute default prefix for article move/copy/etc prompts. | |
510 | The function should take one argument, a group name, and return a | |
511 | string with the suggested prefix." | |
512 | :group 'gnus-summary-mail | |
513 | :type 'function) | |
514 | ||
e62e7654 MB |
515 | ;; FIXME: Although the custom type is `character' for the following variables, |
516 | ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs | |
517 | ||
23f87bed | 518 | (defcustom gnus-unread-mark ? ;Whitespace |
eec82323 LMI |
519 | "*Mark used for unread articles." |
520 | :group 'gnus-summary-marks | |
521 | :type 'character) | |
522 | ||
523 | (defcustom gnus-ticked-mark ?! | |
524 | "*Mark used for ticked articles." | |
525 | :group 'gnus-summary-marks | |
526 | :type 'character) | |
527 | ||
528 | (defcustom gnus-dormant-mark ?? | |
529 | "*Mark used for dormant articles." | |
530 | :group 'gnus-summary-marks | |
531 | :type 'character) | |
532 | ||
533 | (defcustom gnus-del-mark ?r | |
534 | "*Mark used for del'd articles." | |
535 | :group 'gnus-summary-marks | |
536 | :type 'character) | |
537 | ||
538 | (defcustom gnus-read-mark ?R | |
539 | "*Mark used for read articles." | |
540 | :group 'gnus-summary-marks | |
541 | :type 'character) | |
542 | ||
543 | (defcustom gnus-expirable-mark ?E | |
544 | "*Mark used for expirable articles." | |
545 | :group 'gnus-summary-marks | |
546 | :type 'character) | |
547 | ||
548 | (defcustom gnus-killed-mark ?K | |
549 | "*Mark used for killed articles." | |
550 | :group 'gnus-summary-marks | |
551 | :type 'character) | |
552 | ||
23f87bed MB |
553 | (defcustom gnus-spam-mark ?$ |
554 | "*Mark used for spam articles." | |
bf247b6e | 555 | :version "22.1" |
23f87bed MB |
556 | :group 'gnus-summary-marks |
557 | :type 'character) | |
558 | ||
eec82323 LMI |
559 | (defcustom gnus-kill-file-mark ?X |
560 | "*Mark used for articles killed by kill files." | |
561 | :group 'gnus-summary-marks | |
562 | :type 'character) | |
563 | ||
564 | (defcustom gnus-low-score-mark ?Y | |
565 | "*Mark used for articles with a low score." | |
566 | :group 'gnus-summary-marks | |
567 | :type 'character) | |
568 | ||
569 | (defcustom gnus-catchup-mark ?C | |
570 | "*Mark used for articles that are caught up." | |
571 | :group 'gnus-summary-marks | |
572 | :type 'character) | |
573 | ||
574 | (defcustom gnus-replied-mark ?A | |
575 | "*Mark used for articles that have been replied to." | |
576 | :group 'gnus-summary-marks | |
577 | :type 'character) | |
578 | ||
23f87bed MB |
579 | (defcustom gnus-forwarded-mark ?F |
580 | "*Mark used for articles that have been forwarded." | |
bf247b6e | 581 | :version "22.1" |
23f87bed MB |
582 | :group 'gnus-summary-marks |
583 | :type 'character) | |
584 | ||
585 | (defcustom gnus-recent-mark ?N | |
586 | "*Mark used for articles that are recent." | |
bf247b6e | 587 | :version "22.1" |
23f87bed MB |
588 | :group 'gnus-summary-marks |
589 | :type 'character) | |
590 | ||
eec82323 LMI |
591 | (defcustom gnus-cached-mark ?* |
592 | "*Mark used for articles that are in the cache." | |
593 | :group 'gnus-summary-marks | |
594 | :type 'character) | |
595 | ||
596 | (defcustom gnus-saved-mark ?S | |
23f87bed MB |
597 | "*Mark used for articles that have been saved." |
598 | :group 'gnus-summary-marks | |
599 | :type 'character) | |
600 | ||
601 | (defcustom gnus-unseen-mark ?. | |
602 | "*Mark used for articles that haven't been seen." | |
bf247b6e | 603 | :version "22.1" |
23f87bed MB |
604 | :group 'gnus-summary-marks |
605 | :type 'character) | |
606 | ||
607 | (defcustom gnus-no-mark ? ;Whitespace | |
608 | "*Mark used for articles that have no other secondary mark." | |
bf247b6e | 609 | :version "22.1" |
eec82323 LMI |
610 | :group 'gnus-summary-marks |
611 | :type 'character) | |
612 | ||
613 | (defcustom gnus-ancient-mark ?O | |
614 | "*Mark used for ancient articles." | |
615 | :group 'gnus-summary-marks | |
616 | :type 'character) | |
617 | ||
618 | (defcustom gnus-sparse-mark ?Q | |
619 | "*Mark used for sparsely reffed articles." | |
620 | :group 'gnus-summary-marks | |
621 | :type 'character) | |
622 | ||
623 | (defcustom gnus-canceled-mark ?G | |
624 | "*Mark used for canceled articles." | |
625 | :group 'gnus-summary-marks | |
626 | :type 'character) | |
627 | ||
628 | (defcustom gnus-duplicate-mark ?M | |
629 | "*Mark used for duplicate articles." | |
630 | :group 'gnus-summary-marks | |
631 | :type 'character) | |
632 | ||
23f87bed | 633 | (defcustom gnus-undownloaded-mark ?- |
6748645f | 634 | "*Mark used for articles that weren't downloaded." |
bf247b6e | 635 | :version "22.1" |
6748645f LMI |
636 | :group 'gnus-summary-marks |
637 | :type 'character) | |
638 | ||
23f87bed MB |
639 | (defcustom gnus-downloaded-mark ?+ |
640 | "*Mark used for articles that were downloaded." | |
641 | :group 'gnus-summary-marks | |
642 | :type 'character) | |
643 | ||
6748645f LMI |
644 | (defcustom gnus-downloadable-mark ?% |
645 | "*Mark used for articles that are to be downloaded." | |
646 | :group 'gnus-summary-marks | |
647 | :type 'character) | |
648 | ||
649 | (defcustom gnus-unsendable-mark ?= | |
650 | "*Mark used for articles that won't be sent." | |
651 | :group 'gnus-summary-marks | |
652 | :type 'character) | |
653 | ||
eec82323 LMI |
654 | (defcustom gnus-score-over-mark ?+ |
655 | "*Score mark used for articles with high scores." | |
656 | :group 'gnus-summary-marks | |
657 | :type 'character) | |
658 | ||
659 | (defcustom gnus-score-below-mark ?- | |
660 | "*Score mark used for articles with low scores." | |
661 | :group 'gnus-summary-marks | |
662 | :type 'character) | |
663 | ||
23f87bed | 664 | (defcustom gnus-empty-thread-mark ? ;Whitespace |
eec82323 LMI |
665 | "*There is no thread under the article." |
666 | :group 'gnus-summary-marks | |
667 | :type 'character) | |
668 | ||
669 | (defcustom gnus-not-empty-thread-mark ?= | |
670 | "*There is a thread under the article." | |
671 | :group 'gnus-summary-marks | |
672 | :type 'character) | |
673 | ||
674 | (defcustom gnus-view-pseudo-asynchronously nil | |
675 | "*If non-nil, Gnus will view pseudo-articles asynchronously." | |
676 | :group 'gnus-extract-view | |
677 | :type 'boolean) | |
678 | ||
16409b0b GM |
679 | (defcustom gnus-auto-expirable-marks |
680 | (list gnus-killed-mark gnus-del-mark gnus-catchup-mark | |
681 | gnus-low-score-mark gnus-ancient-mark gnus-read-mark | |
c4d82de8 | 682 | gnus-duplicate-mark) |
16409b0b | 683 | "*The list of marks converted into expiration if a group is auto-expirable." |
b0e30310 | 684 | :version "24.1" |
16409b0b GM |
685 | :group 'gnus-summary |
686 | :type '(repeat character)) | |
687 | ||
688 | (defcustom gnus-inhibit-user-auto-expire t | |
689 | "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on." | |
58e39d05 | 690 | :version "21.1" |
16409b0b GM |
691 | :group 'gnus-summary |
692 | :type 'boolean) | |
693 | ||
b0b63450 MB |
694 | (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil |
695 | "If non-nil, mark articles copied or moved to auto-expire group as expirable. | |
696 | If nil, the expirable marks will be unchanged except that the marks | |
697 | will be removed when copying or moving articles to a group that has | |
698 | not turned auto-expire on. If non-nil, articles that have been read | |
699 | will be marked as expirable when being copied or moved to a group in | |
700 | which auto-expire is turned on." | |
701 | :version "23.2" | |
702 | :type 'boolean | |
703 | :group 'gnus-summary-marks) | |
704 | ||
eec82323 LMI |
705 | (defcustom gnus-view-pseudos nil |
706 | "*If `automatic', pseudo-articles will be viewed automatically. | |
707 | If `not-confirm', pseudos will be viewed automatically, and the user | |
708 | will not be asked to confirm the command." | |
709 | :group 'gnus-extract-view | |
710 | :type '(choice (const :tag "off" nil) | |
711 | (const automatic) | |
712 | (const not-confirm))) | |
713 | ||
714 | (defcustom gnus-view-pseudos-separately t | |
715 | "*If non-nil, one pseudo-article will be created for each file to be viewed. | |
716 | If nil, all files that use the same viewing command will be given as a | |
717 | list of parameters to that command." | |
718 | :group 'gnus-extract-view | |
719 | :type 'boolean) | |
720 | ||
721 | (defcustom gnus-insert-pseudo-articles t | |
722 | "*If non-nil, insert pseudo-articles when decoding articles." | |
723 | :group 'gnus-extract-view | |
724 | :type 'boolean) | |
725 | ||
726 | (defcustom gnus-summary-dummy-line-format | |
23f87bed | 727 | " %(: :%) %S\n" |
eec82323 LMI |
728 | "*The format specification for the dummy roots in the summary buffer. |
729 | It works along the same lines as a normal formatting string, | |
730 | with some simple extensions. | |
731 | ||
23f87bed MB |
732 | %S The subject |
733 | ||
734 | General format specifiers can also be used. | |
735 | See `(gnus)Formatting Variables'." | |
736 | :link '(custom-manual "(gnus)Formatting Variables") | |
eec82323 LMI |
737 | :group 'gnus-threading |
738 | :type 'string) | |
739 | ||
16409b0b | 740 | (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z" |
eec82323 LMI |
741 | "*The format specification for the summary mode line. |
742 | It works along the same lines as a normal formatting string, | |
743 | with some simple extensions: | |
744 | ||
745 | %G Group name | |
746 | %p Unprefixed group name | |
747 | %A Current article number | |
6748645f | 748 | %z Current article score |
eec82323 LMI |
749 | %V Gnus version |
750 | %U Number of unread articles in the group | |
751 | %e Number of unselected articles in the group | |
752 | %Z A string with unread/unselected article counts | |
753 | %g Shortish group name | |
754 | %S Subject of the current article | |
755 | %u User-defined spec | |
756 | %s Current score file name | |
757 | %d Number of dormant articles | |
758 | %r Number of articles that have been marked as read in this session | |
759 | %E Number of articles expunged by the score files" | |
760 | :group 'gnus-summary-format | |
761 | :type 'string) | |
762 | ||
16409b0b GM |
763 | (defcustom gnus-list-identifiers nil |
764 | "Regexp that matches list identifiers to be removed from subject. | |
765 | This can also be a list of regexps." | |
58e39d05 | 766 | :version "21.1" |
16409b0b GM |
767 | :group 'gnus-summary-format |
768 | :group 'gnus-article-hiding | |
769 | :type '(choice (const :tag "none" nil) | |
770 | (regexp :value ".*") | |
771 | (repeat :value (".*") regexp))) | |
772 | ||
eec82323 LMI |
773 | (defcustom gnus-summary-mark-below 0 |
774 | "*Mark all articles with a score below this variable as read. | |
775 | This variable is local to each summary buffer and usually set by the | |
776 | score file." | |
777 | :group 'gnus-score-default | |
778 | :type 'integer) | |
779 | ||
01c52d31 MB |
780 | (defun gnus-widget-reversible-match (widget value) |
781 | "Ignoring WIDGET, convert VALUE to internal form. | |
782 | VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol." | |
783 | ;; (debug value) | |
784 | (or (symbolp value) | |
785 | (and (listp value) | |
786 | (eq (length value) 2) | |
787 | (eq (nth 0 value) 'not) | |
788 | (symbolp (nth 1 value))))) | |
789 | ||
790 | (defun gnus-widget-reversible-to-internal (widget value) | |
791 | "Ignoring WIDGET, convert VALUE to internal form. | |
792 | VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom. | |
793 | FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)." | |
794 | ;; (debug value) | |
795 | (if (atom value) | |
796 | (list value nil) | |
797 | (list (nth 1 value) t))) | |
798 | ||
799 | (defun gnus-widget-reversible-to-external (widget value) | |
800 | "Ignoring WIDGET, convert VALUE to external form. | |
801 | VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom. | |
802 | \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)." | |
803 | ;; (debug value) | |
804 | (if (nth 1 value) | |
805 | (list 'not (nth 0 value)) | |
806 | (nth 0 value))) | |
807 | ||
808 | (define-widget 'gnus-widget-reversible 'group | |
809 | "A `group' that convert values." | |
810 | :match 'gnus-widget-reversible-match | |
811 | :value-to-internal 'gnus-widget-reversible-to-internal | |
812 | :value-to-external 'gnus-widget-reversible-to-external) | |
813 | ||
eec82323 LMI |
814 | (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number) |
815 | "*List of functions used for sorting articles in the summary buffer. | |
23f87bed MB |
816 | |
817 | Each function takes two articles and returns non-nil if the first | |
818 | article should be sorted before the other. If you use more than one | |
819 | function, the primary sort function should be the last. You should | |
820 | probably always include `gnus-article-sort-by-number' in the list of | |
821 | sorting functions -- preferably first. Also note that sorting by date | |
822 | is often much slower than sorting by number, and the sorting order is | |
823 | very similar. (Sorting by date means sorting by the time the message | |
824 | was sent, sorting by number means sorting by arrival time.) | |
825 | ||
01c52d31 MB |
826 | Each item can also be a list `(not F)' where F is a function; |
827 | this reverses the sort order. | |
828 | ||
23f87bed MB |
829 | Ready-made functions include `gnus-article-sort-by-number', |
830 | `gnus-article-sort-by-author', `gnus-article-sort-by-subject', | |
831 | `gnus-article-sort-by-date', `gnus-article-sort-by-random' | |
832 | and `gnus-article-sort-by-score'. | |
833 | ||
834 | When threading is turned on, the variable `gnus-thread-sort-functions' | |
835 | controls how articles are sorted." | |
eec82323 | 836 | :group 'gnus-summary-sort |
01c52d31 MB |
837 | :type '(repeat (gnus-widget-reversible |
838 | (choice (function-item gnus-article-sort-by-number) | |
839 | (function-item gnus-article-sort-by-author) | |
840 | (function-item gnus-article-sort-by-subject) | |
841 | (function-item gnus-article-sort-by-date) | |
842 | (function-item gnus-article-sort-by-score) | |
843 | (function-item gnus-article-sort-by-random) | |
844 | (function :tag "other")) | |
845 | (boolean :tag "Reverse order")))) | |
846 | ||
eec82323 LMI |
847 | (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number) |
848 | "*List of functions used for sorting threads in the summary buffer. | |
849 | By default, threads are sorted by article number. | |
850 | ||
23f87bed MB |
851 | Each function takes two threads and returns non-nil if the first |
852 | thread should be sorted before the other. If you use more than one | |
853 | function, the primary sort function should be the last. You should | |
854 | probably always include `gnus-thread-sort-by-number' in the list of | |
855 | sorting functions -- preferably first. Also note that sorting by date | |
856 | is often much slower than sorting by number, and the sorting order is | |
857 | very similar. (Sorting by date means sorting by the time the message | |
858 | was sent, sorting by number means sorting by arrival time.) | |
eec82323 | 859 | |
01c52d31 MB |
860 | Each list item can also be a list `(not F)' where F is a |
861 | function; this specifies reversed sort order. | |
862 | ||
eec82323 | 863 | Ready-made functions include `gnus-thread-sort-by-number', |
01c52d31 MB |
864 | `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient' |
865 | `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date', | |
866 | `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number', | |
867 | `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random', | |
868 | and `gnus-thread-sort-by-total-score' (see | |
869 | `gnus-thread-score-function'). | |
23f87bed MB |
870 | |
871 | When threading is turned off, the variable | |
a3fd87cb TH |
872 | `gnus-article-sort-functions' controls how articles are sorted. |
873 | ||
874 | By default, threads and their subthreads are sorted according to | |
875 | the value of this variable. To use a different sorting order for | |
876 | subthreads, customize `gnus-subthread-sort-functions'." | |
eec82323 | 877 | :group 'gnus-summary-sort |
01c52d31 MB |
878 | :type '(repeat |
879 | (gnus-widget-reversible | |
880 | (choice (function-item gnus-thread-sort-by-number) | |
881 | (function-item gnus-thread-sort-by-author) | |
882 | (function-item gnus-thread-sort-by-recipient) | |
883 | (function-item gnus-thread-sort-by-subject) | |
884 | (function-item gnus-thread-sort-by-date) | |
885 | (function-item gnus-thread-sort-by-score) | |
886 | (function-item gnus-thread-sort-by-most-recent-number) | |
887 | (function-item gnus-thread-sort-by-most-recent-date) | |
888 | (function-item gnus-thread-sort-by-random) | |
889 | (function-item gnus-thread-sort-by-total-score) | |
890 | (function :tag "other")) | |
891 | (boolean :tag "Reverse order")))) | |
eec82323 | 892 | |
a3fd87cb TH |
893 | (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions |
894 | "*List of functions used for sorting subthreads in the summary buffer. | |
895 | By default, subthreads are sorted the same as threads, i.e., | |
896 | according to the value of `gnus-thread-sort-functions'." | |
bb098075 | 897 | :version "24.4" |
a3fd87cb TH |
898 | :group 'gnus-summary-sort |
899 | :type '(choice | |
900 | (const :tag "Sort subthreads like threads" gnus-thread-sort-functions) | |
901 | (repeat | |
902 | (gnus-widget-reversible | |
903 | (choice (function-item gnus-thread-sort-by-number) | |
904 | (function-item gnus-thread-sort-by-author) | |
905 | (function-item gnus-thread-sort-by-recipient) | |
906 | (function-item gnus-thread-sort-by-subject) | |
907 | (function-item gnus-thread-sort-by-date) | |
908 | (function-item gnus-thread-sort-by-score) | |
909 | (function-item gnus-thread-sort-by-most-recent-number) | |
910 | (function-item gnus-thread-sort-by-most-recent-date) | |
911 | (function-item gnus-thread-sort-by-random) | |
912 | (function-item gnus-thread-sort-by-total-score) | |
913 | (function :tag "other")) | |
914 | (boolean :tag "Reverse order"))))) | |
915 | ||
eec82323 LMI |
916 | (defcustom gnus-thread-score-function '+ |
917 | "*Function used for calculating the total score of a thread. | |
918 | ||
919 | The function is called with the scores of the article and each | |
920 | subthread and should then return the score of the thread. | |
921 | ||
922 | Some functions you can use are `+', `max', or `min'." | |
923 | :group 'gnus-summary-sort | |
924 | :type 'function) | |
925 | ||
926 | (defcustom gnus-summary-expunge-below nil | |
6748645f LMI |
927 | "All articles that have a score less than this variable will be expunged. |
928 | This variable is local to the summary buffers." | |
eec82323 LMI |
929 | :group 'gnus-score-default |
930 | :type '(choice (const :tag "off" nil) | |
931 | integer)) | |
932 | ||
933 | (defcustom gnus-thread-expunge-below nil | |
934 | "All threads that have a total score less than this variable will be expunged. | |
935 | See `gnus-thread-score-function' for en explanation of what a | |
6748645f LMI |
936 | \"thread score\" is. |
937 | ||
938 | This variable is local to the summary buffers." | |
16409b0b | 939 | :group 'gnus-threading |
eec82323 LMI |
940 | :group 'gnus-score-default |
941 | :type '(choice (const :tag "off" nil) | |
942 | integer)) | |
943 | ||
944 | (defcustom gnus-summary-mode-hook nil | |
945 | "*A hook for Gnus summary mode. | |
946 | This hook is run before any variables are set in the summary buffer." | |
23f87bed | 947 | :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode) |
eec82323 LMI |
948 | :group 'gnus-summary-various |
949 | :type 'hook) | |
950 | ||
23f87bed MB |
951 | ;; Extracted from gnus-xmas-redefine in order to preserve user settings |
952 | (when (featurep 'xemacs) | |
953 | (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add) | |
954 | (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar) | |
955 | (add-hook 'gnus-summary-mode-hook | |
956 | 'gnus-xmas-switch-horizontal-scrollbar-off)) | |
957 | ||
eec82323 LMI |
958 | (defcustom gnus-summary-menu-hook nil |
959 | "*Hook run after the creation of the summary mode menu." | |
960 | :group 'gnus-summary-visual | |
961 | :type 'hook) | |
962 | ||
963 | (defcustom gnus-summary-exit-hook nil | |
964 | "*A hook called on exit from the summary buffer. | |
965 | It will be called with point in the group buffer." | |
966 | :group 'gnus-summary-exit | |
967 | :type 'hook) | |
968 | ||
969 | (defcustom gnus-summary-prepare-hook nil | |
970 | "*A hook called after the summary buffer has been generated. | |
971 | If you want to modify the summary buffer, you can use this hook." | |
972 | :group 'gnus-summary-various | |
973 | :type 'hook) | |
974 | ||
6748645f LMI |
975 | (defcustom gnus-summary-prepared-hook nil |
976 | "*A hook called as the last thing after the summary buffer has been generated." | |
977 | :group 'gnus-summary-various | |
978 | :type 'hook) | |
979 | ||
eec82323 LMI |
980 | (defcustom gnus-summary-generate-hook nil |
981 | "*A hook run just before generating the summary buffer. | |
982 | This hook is commonly used to customize threading variables and the | |
983 | like." | |
984 | :group 'gnus-summary-various | |
985 | :type 'hook) | |
986 | ||
987 | (defcustom gnus-select-group-hook nil | |
988 | "*A hook called when a newsgroup is selected. | |
989 | ||
990 | If you'd like to simplify subjects like the | |
991 | `gnus-summary-next-same-subject' command does, you can use the | |
992 | following hook: | |
993 | ||
23f87bed MB |
994 | (add-hook gnus-select-group-hook |
995 | (lambda () | |
996 | (mapcar (lambda (header) | |
997 | (mail-header-set-subject | |
998 | header | |
999 | (gnus-simplify-subject | |
1000 | (mail-header-subject header) 're-only))) | |
1001 | gnus-newsgroup-headers)))" | |
eec82323 LMI |
1002 | :group 'gnus-group-select |
1003 | :type 'hook) | |
1004 | ||
1005 | (defcustom gnus-select-article-hook nil | |
1006 | "*A hook called when an article is selected." | |
1007 | :group 'gnus-summary-choose | |
23f87bed | 1008 | :options '(gnus-agent-fetch-selected-article) |
eec82323 LMI |
1009 | :type 'hook) |
1010 | ||
1011 | (defcustom gnus-visual-mark-article-hook | |
1012 | (list 'gnus-highlight-selected-summary) | |
1013 | "*Hook run after selecting an article in the summary buffer. | |
1014 | It is meant to be used for highlighting the article in some way. It | |
1015 | is not run if `gnus-visual' is nil." | |
1016 | :group 'gnus-summary-visual | |
1017 | :type 'hook) | |
1018 | ||
16409b0b | 1019 | (defcustom gnus-parse-headers-hook nil |
eec82323 LMI |
1020 | "*A hook called before parsing the headers." |
1021 | :group 'gnus-various | |
1022 | :type 'hook) | |
1023 | ||
1024 | (defcustom gnus-exit-group-hook nil | |
16409b0b GM |
1025 | "*A hook called when exiting summary mode. |
1026 | This hook is not called from the non-updating exit commands like `Q'." | |
eec82323 LMI |
1027 | :group 'gnus-various |
1028 | :type 'hook) | |
1029 | ||
a9ec34f4 | 1030 | (defcustom gnus-summary-update-hook nil |
eec82323 LMI |
1031 | "*A hook called when a summary line is changed. |
1032 | The hook will not be called if `gnus-visual' is nil. | |
1033 | ||
1034 | The default function `gnus-summary-highlight-line' will | |
1035 | highlight the line according to the `gnus-summary-highlight' | |
1036 | variable." | |
1037 | :group 'gnus-summary-visual | |
1038 | :type 'hook) | |
1039 | ||
1040 | (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read) | |
1041 | "*A hook called when an article is selected for the first time. | |
1042 | The hook is intended to mark an article as read (or unread) | |
1043 | automatically when it is selected." | |
1044 | :group 'gnus-summary-choose | |
1045 | :type 'hook) | |
1046 | ||
1047 | (defcustom gnus-group-no-more-groups-hook nil | |
1048 | "*A hook run when returning to group mode having no more (unread) groups." | |
1049 | :group 'gnus-group-select | |
1050 | :type 'hook) | |
1051 | ||
1052 | (defcustom gnus-ps-print-hook nil | |
1053 | "*A hook run before ps-printing something from Gnus." | |
1054 | :group 'gnus-summary | |
1055 | :type 'hook) | |
1056 | ||
23f87bed MB |
1057 | (defcustom gnus-summary-article-move-hook nil |
1058 | "*A hook called after an article is moved, copied, respooled, or crossposted." | |
bf247b6e | 1059 | :version "22.1" |
23f87bed MB |
1060 | :group 'gnus-summary |
1061 | :type 'hook) | |
1062 | ||
1063 | (defcustom gnus-summary-article-delete-hook nil | |
1064 | "*A hook called after an article is deleted." | |
bf247b6e | 1065 | :version "22.1" |
23f87bed MB |
1066 | :group 'gnus-summary |
1067 | :type 'hook) | |
1068 | ||
1069 | (defcustom gnus-summary-article-expire-hook nil | |
1070 | "*A hook called after an article is expired." | |
bf247b6e | 1071 | :version "22.1" |
23f87bed MB |
1072 | :group 'gnus-summary |
1073 | :type 'hook) | |
1074 | ||
1075 | (defcustom gnus-summary-display-arrow | |
1076 | (and (fboundp 'display-graphic-p) | |
1077 | (display-graphic-p)) | |
1078 | "*If non-nil, display an arrow highlighting the current article." | |
bf247b6e | 1079 | :version "22.1" |
23f87bed MB |
1080 | :group 'gnus-summary |
1081 | :type 'boolean) | |
1082 | ||
0f49874b | 1083 | (defcustom gnus-summary-selected-face 'gnus-summary-selected |
eec82323 LMI |
1084 | "Face used for highlighting the current article in the summary buffer." |
1085 | :group 'gnus-summary-visual | |
1086 | :type 'face) | |
1087 | ||
23f87bed MB |
1088 | (defvar gnus-tmp-downloaded nil) |
1089 | ||
eec82323 | 1090 | (defcustom gnus-summary-highlight |
23f87bed | 1091 | '(((eq mark gnus-canceled-mark) |
0f49874b | 1092 | . gnus-summary-cancelled) |
23f87bed | 1093 | ((and uncached (> score default-high)) |
0f49874b | 1094 | . gnus-summary-high-undownloaded) |
23f87bed | 1095 | ((and uncached (< score default-low)) |
0f49874b | 1096 | . gnus-summary-low-undownloaded) |
23f87bed | 1097 | (uncached |
0f49874b | 1098 | . gnus-summary-normal-undownloaded) |
23f87bed MB |
1099 | ((and (> score default-high) |
1100 | (or (eq mark gnus-dormant-mark) | |
1101 | (eq mark gnus-ticked-mark))) | |
0f49874b | 1102 | . gnus-summary-high-ticked) |
23f87bed MB |
1103 | ((and (< score default-low) |
1104 | (or (eq mark gnus-dormant-mark) | |
1105 | (eq mark gnus-ticked-mark))) | |
0f49874b | 1106 | . gnus-summary-low-ticked) |
23f87bed MB |
1107 | ((or (eq mark gnus-dormant-mark) |
1108 | (eq mark gnus-ticked-mark)) | |
0f49874b | 1109 | . gnus-summary-normal-ticked) |
23f87bed | 1110 | ((and (> score default-high) (eq mark gnus-ancient-mark)) |
0f49874b | 1111 | . gnus-summary-high-ancient) |
23f87bed | 1112 | ((and (< score default-low) (eq mark gnus-ancient-mark)) |
0f49874b | 1113 | . gnus-summary-low-ancient) |
23f87bed | 1114 | ((eq mark gnus-ancient-mark) |
0f49874b | 1115 | . gnus-summary-normal-ancient) |
23f87bed | 1116 | ((and (> score default-high) (eq mark gnus-unread-mark)) |
0f49874b | 1117 | . gnus-summary-high-unread) |
23f87bed | 1118 | ((and (< score default-low) (eq mark gnus-unread-mark)) |
0f49874b | 1119 | . gnus-summary-low-unread) |
23f87bed | 1120 | ((eq mark gnus-unread-mark) |
0f49874b | 1121 | . gnus-summary-normal-unread) |
23f87bed | 1122 | ((> score default-high) |
0f49874b | 1123 | . gnus-summary-high-read) |
23f87bed | 1124 | ((< score default-low) |
0f49874b | 1125 | . gnus-summary-low-read) |
eec82323 | 1126 | (t |
0f49874b | 1127 | . gnus-summary-normal-read)) |
6748645f | 1128 | "*Controls the highlighting of summary buffer lines. |
eec82323 | 1129 | |
107cf8ec | 1130 | A list of (FORM . FACE) pairs. When deciding how a particular |
23f87bed MB |
1131 | summary line should be displayed, each form is evaluated. The content |
1132 | of the face field after the first true form is used. You can change | |
1133 | how those summary lines are displayed, by editing the face field. | |
eec82323 LMI |
1134 | |
1135 | You can use the following variables in the FORM field. | |
1136 | ||
107cf8ec | 1137 | score: The article's score. |
23f87bed MB |
1138 | default: The default article score. |
1139 | default-high: The default score for high scored articles. | |
1140 | default-low: The default score for low scored articles. | |
23f87bed MB |
1141 | mark: The article's mark. |
1142 | uncached: Non-nil if the article is uncached." | |
eec82323 LMI |
1143 | :group 'gnus-summary-visual |
1144 | :type '(repeat (cons (sexp :tag "Form" nil) | |
1145 | face))) | |
c12ecb0a | 1146 | (put 'gnus-summary-highlight 'risky-local-variable t) |
eec82323 | 1147 | |
6748645f LMI |
1148 | (defcustom gnus-alter-header-function nil |
1149 | "Function called to allow alteration of article header structures. | |
1150 | The function is called with one parameter, the article header vector, | |
0ab0f2d3 SZ |
1151 | which it may alter in any way." |
1152 | :type '(choice (const :tag "None" nil) | |
1153 | function) | |
1154 | :group 'gnus-summary) | |
eec82323 | 1155 | |
16409b0b | 1156 | (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string |
343d6628 MB |
1157 | "Function used to decode a string with encoded words.") |
1158 | ||
1159 | (defvar gnus-decode-encoded-address-function | |
1160 | 'mail-decode-encoded-address-string | |
1161 | "Function used to decode addresses with encoded words.") | |
16409b0b | 1162 | |
a6e77075 | 1163 | (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups) |
16409b0b | 1164 | "*Extra headers to parse." |
81de9236 | 1165 | :version "24.1" ; added Cc Keywords Gcc |
16409b0b GM |
1166 | :group 'gnus-summary |
1167 | :type '(repeat symbol)) | |
1168 | ||
1169 | (defcustom gnus-ignored-from-addresses | |
343d6628 | 1170 | (and user-mail-address |
7cd9f860 CY |
1171 | (not (string= user-mail-address "")) |
1172 | (regexp-quote user-mail-address)) | |
01c52d31 MB |
1173 | "*From headers that may be suppressed in favor of To headers. |
1174 | This can be a regexp or a list of regexps." | |
58e39d05 | 1175 | :version "21.1" |
16409b0b | 1176 | :group 'gnus-summary |
01c52d31 MB |
1177 | :type '(choice regexp |
1178 | (repeat :tag "Regexp List" regexp))) | |
1179 | ||
1180 | (defsubst gnus-ignored-from-addresses () | |
1181 | (gmm-regexp-concat gnus-ignored-from-addresses)) | |
1182 | ||
1183 | (defcustom gnus-summary-to-prefix "-> " | |
1184 | "*String prefixed to the To field in the summary line when | |
1185 | using `gnus-ignored-from-addresses'." | |
1186 | :version "22.1" | |
1187 | :group 'gnus-summary | |
1188 | :type 'string) | |
1189 | ||
1190 | (defcustom gnus-summary-newsgroup-prefix "=> " | |
1191 | "*String prefixed to the Newsgroup field in the summary | |
9fc9a531 | 1192 | line when using the option `gnus-ignored-from-addresses'." |
01c52d31 MB |
1193 | :version "22.1" |
1194 | :group 'gnus-summary | |
1195 | :type 'string) | |
16409b0b | 1196 | |
16409b0b GM |
1197 | (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown) |
1198 | "List of charsets that should be ignored. | |
1199 | When these charsets are used in the \"charset\" parameter, the | |
1200 | default charset will be used instead." | |
58e39d05 | 1201 | :version "21.1" |
16409b0b GM |
1202 | :type '(repeat symbol) |
1203 | :group 'gnus-charset) | |
1204 | ||
4b70e299 MB |
1205 | (defcustom gnus-newsgroup-maximum-articles nil |
1206 | "The maximum number of articles a newsgroup. | |
1207 | If this is a number, old articles in a newsgroup exceeding this number | |
1208 | are silently ignored. If it is nil, no article is ignored. Note that | |
1209 | setting this variable to a number might prevent you from reading very | |
1210 | old articles." | |
1211 | :group 'gnus-group-select | |
1212 | :version "22.2" | |
1213 | :type '(choice (const :tag "No limit" nil) | |
1214 | integer)) | |
1215 | ||
23f87bed MB |
1216 | (gnus-define-group-parameter |
1217 | ignored-charsets | |
1218 | :type list | |
1219 | :function-document | |
1220 | "Return the ignored charsets of GROUP." | |
1221 | :variable gnus-group-ignored-charsets-alist | |
1222 | :variable-default | |
1223 | '(("alt\\.chinese\\.text" iso-8859-1)) | |
1224 | :variable-document | |
1225 | "Alist of regexps (to match group names) and charsets that should be ignored. | |
16409b0b GM |
1226 | When these charsets are used in the \"charset\" parameter, the |
1227 | default charset will be used instead." | |
23f87bed MB |
1228 | :variable-group gnus-charset |
1229 | :variable-type '(repeat (cons (regexp :tag "Group") | |
1230 | (repeat symbol))) | |
1231 | :parameter-type '(choice :tag "Ignored charsets" | |
1232 | :value nil | |
1233 | (repeat (symbol))) | |
1234 | :parameter-document "\ | |
1235 | List of charsets that should be ignored. | |
1236 | ||
1237 | When these charsets are used in the \"charset\" parameter, the | |
1238 | default charset will be used instead.") | |
16409b0b GM |
1239 | |
1240 | (defcustom gnus-group-highlight-words-alist nil | |
1241 | "Alist of group regexps and highlight regexps. | |
1242 | This variable uses the same syntax as `gnus-emphasis-alist'." | |
58e39d05 | 1243 | :version "21.1" |
16409b0b GM |
1244 | :type '(repeat (cons (regexp :tag "Group") |
1245 | (repeat (list (regexp :tag "Highlight regexp") | |
1246 | (number :tag "Group for entire word" 0) | |
1247 | (number :tag "Group for displayed part" 0) | |
1248 | (symbol :tag "Face" | |
1249 | gnus-emphasis-highlight-words))))) | |
1250 | :group 'gnus-summary-visual) | |
1251 | ||
1252 | (defcustom gnus-summary-show-article-charset-alist | |
1253 | nil | |
1254 | "Alist of number and charset. | |
1255 | The article will be shown with the charset corresponding to the | |
1256 | numbered argument. | |
1257 | For example: ((1 . cn-gb-2312) (2 . big5))." | |
58e39d05 | 1258 | :version "21.1" |
16409b0b GM |
1259 | :type '(repeat (cons (number :tag "Argument" 1) |
1260 | (symbol :tag "Charset"))) | |
1261 | :group 'gnus-charset) | |
1262 | ||
1263 | (defcustom gnus-preserve-marks t | |
1264 | "Whether marks are preserved when moving, copying and respooling messages." | |
58e39d05 | 1265 | :version "21.1" |
16409b0b GM |
1266 | :type 'boolean |
1267 | :group 'gnus-summary-marks) | |
1268 | ||
1269 | (defcustom gnus-alter-articles-to-read-function nil | |
1270 | "Function to be called to alter the list of articles to be selected." | |
8fc7a9a1 | 1271 | :type '(choice (const nil) function) |
16409b0b GM |
1272 | :group 'gnus-summary) |
1273 | ||
1274 | (defcustom gnus-orphan-score nil | |
1275 | "*All orphans get this score added. Set in the score file." | |
1276 | :group 'gnus-score-default | |
1277 | :type '(choice (const nil) | |
1278 | integer)) | |
1279 | ||
8b93df01 | 1280 | (defcustom gnus-summary-save-parts-default-mime "image/.*" |
23f87bed MB |
1281 | "*A regexp to match MIME parts when saving multiple parts of a |
1282 | message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]). | |
1283 | This regexp will be used by default when prompting the user for which | |
1284 | type of files to save." | |
8b93df01 DL |
1285 | :group 'gnus-summary |
1286 | :type 'regexp) | |
1287 | ||
23f87bed MB |
1288 | (defcustom gnus-read-all-available-headers nil |
1289 | "Whether Gnus should parse all headers made available to it. | |
1290 | This is mostly relevant for slow back ends where the user may | |
1291 | wish to widen the summary buffer to include all headers | |
c4d82de8 | 1292 | that were fetched." |
bf247b6e | 1293 | :version "22.1" |
23f87bed MB |
1294 | :group 'gnus-summary |
1295 | :type '(choice boolean regexp)) | |
1296 | ||
89167438 MB |
1297 | (defcustom gnus-summary-pipe-output-default-command nil |
1298 | "Command (and optional arguments) used to pipe article to subprocess. | |
1299 | This will be used as the default command if it is non-nil. The value | |
1300 | will be updated if you modify it when executing the command | |
1301 | `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'." | |
1302 | :version "23.1" ;; No Gnus | |
1303 | :group 'gnus-summary | |
1304 | :type '(radio (const :tag "None" nil) (string :tag "Command"))) | |
1305 | ||
23f87bed | 1306 | (defcustom gnus-summary-muttprint-program "muttprint" |
89167438 MB |
1307 | "Command (and optional arguments) used to run Muttprint. |
1308 | The value will be updated if you modify it when executing the command | |
1309 | `gnus-summary-muttprint'." | |
bf247b6e | 1310 | :version "22.1" |
23f87bed MB |
1311 | :group 'gnus-summary |
1312 | :type 'string) | |
1313 | ||
01c52d31 | 1314 | (defcustom gnus-article-loose-mime t |
23f87bed MB |
1315 | "If non-nil, don't require MIME-Version header. |
1316 | Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not | |
a08b59c9 | 1317 | supply the MIME-Version header or deliberately strip it from the mail. |
01c52d31 MB |
1318 | If non-nil (the default), Gnus will treat some articles as MIME |
1319 | even if the MIME-Version header is missing." | |
bf247b6e | 1320 | :version "22.1" |
23f87bed MB |
1321 | :type 'boolean |
1322 | :group 'gnus-article-mime) | |
1323 | ||
1324 | (defcustom gnus-article-emulate-mime t | |
1325 | "If non-nil, use MIME emulation for uuencode and the like. | |
1326 | This means that Gnus will search message bodies for text that look | |
1327 | like uuencoded bits, yEncoded bits, and so on, and present that using | |
1328 | the normal Gnus MIME machinery." | |
bf247b6e | 1329 | :version "22.1" |
23f87bed MB |
1330 | :type 'boolean |
1331 | :group 'gnus-article-mime) | |
8b93df01 | 1332 | |
eec82323 LMI |
1333 | ;;; Internal variables |
1334 | ||
23f87bed | 1335 | (defvar gnus-summary-display-cache nil) |
16409b0b GM |
1336 | (defvar gnus-article-mime-handles nil) |
1337 | (defvar gnus-article-decoded-p nil) | |
23f87bed MB |
1338 | (defvar gnus-article-charset nil) |
1339 | (defvar gnus-article-ignored-charsets nil) | |
eec82323 LMI |
1340 | (defvar gnus-scores-exclude-files nil) |
1341 | (defvar gnus-page-broken nil) | |
1342 | ||
1343 | (defvar gnus-original-article nil) | |
1344 | (defvar gnus-article-internal-prepare-hook nil) | |
1345 | (defvar gnus-newsgroup-process-stack nil) | |
1346 | ||
1347 | (defvar gnus-thread-indent-array nil) | |
1348 | (defvar gnus-thread-indent-array-level gnus-thread-indent-level) | |
16409b0b GM |
1349 | (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number |
1350 | "Function called to sort the articles within a thread after it has been gathered together.") | |
eec82323 | 1351 | |
8b93df01 | 1352 | (defvar gnus-summary-save-parts-type-history nil) |
23f87bed | 1353 | (defvar gnus-summary-save-parts-last-directory mm-default-directory) |
8b93df01 | 1354 | |
eec82323 LMI |
1355 | ;; Avoid highlighting in kill files. |
1356 | (defvar gnus-summary-inhibit-highlight nil) | |
1357 | (defvar gnus-newsgroup-selected-overlay nil) | |
1358 | (defvar gnus-inhibit-limiting nil) | |
1359 | (defvar gnus-newsgroup-adaptive-score-file nil) | |
1360 | (defvar gnus-current-score-file nil) | |
1361 | (defvar gnus-current-move-group nil) | |
1362 | (defvar gnus-current-copy-group nil) | |
1363 | (defvar gnus-current-crosspost-group nil) | |
23f87bed | 1364 | (defvar gnus-newsgroup-display nil) |
eec82323 LMI |
1365 | |
1366 | (defvar gnus-newsgroup-dependencies nil) | |
1367 | (defvar gnus-newsgroup-adaptive nil) | |
1368 | (defvar gnus-summary-display-article-function nil) | |
1369 | (defvar gnus-summary-highlight-line-function nil | |
1370 | "Function called after highlighting a summary line.") | |
1371 | ||
1372 | (defvar gnus-summary-line-format-alist | |
1373 | `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d) | |
1374 | (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s) | |
1375 | (?s gnus-tmp-subject-or-nil ?s) | |
1376 | (?n gnus-tmp-name ?s) | |
1377 | (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from))) | |
1378 | ?s) | |
1379 | (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from)) | |
1380 | gnus-tmp-from) ?s) | |
1381 | (?F gnus-tmp-from ?s) | |
1382 | (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s) | |
1383 | (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s) | |
1384 | (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s) | |
6748645f | 1385 | (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s) |
eec82323 LMI |
1386 | (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s) |
1387 | (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s) | |
1388 | (?c (or (mail-header-chars gnus-tmp-header) 0) ?d) | |
23f87bed MB |
1389 | (?k (gnus-summary-line-message-size gnus-tmp-header) ?s) |
1390 | (?L gnus-tmp-lines ?s) | |
18cd34c1 | 1391 | (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header)) |
ed797193 | 1392 | 0) ?d) |
18cd34c1 | 1393 | (?G (or (nnir-article-group (mail-header-number gnus-tmp-header)) |
ed797193 | 1394 | "") ?s) |
18cd34c1 LI |
1395 | (?g (or (gnus-group-short-name |
1396 | (nnir-article-group (mail-header-number gnus-tmp-header))) | |
ed797193 | 1397 | "") ?s) |
23f87bed | 1398 | (?O gnus-tmp-downloaded ?c) |
eec82323 LMI |
1399 | (?I gnus-tmp-indentation ?s) |
1400 | (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s) | |
1401 | (?R gnus-tmp-replied ?c) | |
1402 | (?\[ gnus-tmp-opening-bracket ?c) | |
1403 | (?\] gnus-tmp-closing-bracket ?c) | |
1404 | (?\> (make-string gnus-tmp-level ? ) ?s) | |
1405 | (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s) | |
1406 | (?i gnus-tmp-score ?d) | |
1407 | (?z gnus-tmp-score-char ?c) | |
eec82323 LMI |
1408 | (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d) |
1409 | (?U gnus-tmp-unread ?c) | |
23f87bed MB |
1410 | (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from) |
1411 | ?s) | |
eec82323 LMI |
1412 | (?t (gnus-summary-number-of-articles-in-thread |
1413 | (and (boundp 'thread) (car thread)) gnus-tmp-level) | |
1414 | ?d) | |
1415 | (?e (gnus-summary-number-of-articles-in-thread | |
1416 | (and (boundp 'thread) (car thread)) gnus-tmp-level t) | |
1417 | ?c) | |
1418 | (?u gnus-tmp-user-defined ?s) | |
23f87bed MB |
1419 | (?P (gnus-pick-line-number) ?d) |
1420 | (?B gnus-tmp-thread-tree-header-string ?s) | |
ec72bf63 | 1421 | (user-date (gnus-user-date |
23f87bed | 1422 | ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s)) |
16409b0b GM |
1423 | "An alist of format specifications that can appear in summary lines. |
1424 | These are paired with what variables they correspond with, along with | |
1425 | the type of the variable (string, integer, character, etc).") | |
eec82323 LMI |
1426 | |
1427 | (defvar gnus-summary-dummy-line-format-alist | |
1428 | `((?S gnus-tmp-subject ?s) | |
1429 | (?N gnus-tmp-number ?d) | |
1430 | (?u gnus-tmp-user-defined ?s))) | |
1431 | ||
1432 | (defvar gnus-summary-mode-line-format-alist | |
1433 | `((?G gnus-tmp-group-name ?s) | |
1434 | (?g (gnus-short-group-name gnus-tmp-group-name) ?s) | |
1435 | (?p (gnus-group-real-name gnus-tmp-group-name) ?s) | |
1436 | (?A gnus-tmp-article-number ?d) | |
1437 | (?Z gnus-tmp-unread-and-unselected ?s) | |
1438 | (?V gnus-version ?s) | |
1439 | (?U gnus-tmp-unread-and-unticked ?d) | |
1440 | (?S gnus-tmp-subject ?s) | |
1441 | (?e gnus-tmp-unselected ?d) | |
1442 | (?u gnus-tmp-user-defined ?s) | |
1443 | (?d (length gnus-newsgroup-dormant) ?d) | |
1444 | (?t (length gnus-newsgroup-marked) ?d) | |
23f87bed | 1445 | (?h (length gnus-newsgroup-spam-marked) ?d) |
eec82323 | 1446 | (?r (length gnus-newsgroup-reads) ?d) |
6748645f | 1447 | (?z (gnus-summary-article-score gnus-tmp-article-number) ?d) |
eec82323 LMI |
1448 | (?E gnus-newsgroup-expunged-tally ?d) |
1449 | (?s (gnus-current-score-file-nondirectory) ?s))) | |
1450 | ||
c1717fbd GM |
1451 | ;; This is here rather than in gnus-art for compilation reasons. |
1452 | (defvar gnus-article-mode-line-format-alist | |
1453 | (nconc '((?w (gnus-article-wash-status) ?s) | |
1454 | (?m (gnus-article-mime-part-status) ?s)) | |
1455 | gnus-summary-mode-line-format-alist)) | |
1456 | ||
eec82323 LMI |
1457 | (defvar gnus-last-search-regexp nil |
1458 | "Default regexp for article search command.") | |
1459 | ||
1460 | (defvar gnus-last-shell-command nil | |
1461 | "Default shell command on article.") | |
1462 | ||
23f87bed MB |
1463 | (defvar gnus-newsgroup-agentized nil |
1464 | "Locally bound in each summary buffer to indicate whether the server has been agentized.") | |
eec82323 LMI |
1465 | (defvar gnus-newsgroup-begin nil) |
1466 | (defvar gnus-newsgroup-end nil) | |
1467 | (defvar gnus-newsgroup-last-rmail nil) | |
1468 | (defvar gnus-newsgroup-last-mail nil) | |
1469 | (defvar gnus-newsgroup-last-folder nil) | |
1470 | (defvar gnus-newsgroup-last-file nil) | |
26c9afc3 | 1471 | (defvar gnus-newsgroup-last-directory nil) |
eec82323 LMI |
1472 | (defvar gnus-newsgroup-auto-expire nil) |
1473 | (defvar gnus-newsgroup-active nil) | |
9f2d52e7 | 1474 | (defvar gnus-newsgroup-highest nil) |
eec82323 LMI |
1475 | |
1476 | (defvar gnus-newsgroup-data nil) | |
1477 | (defvar gnus-newsgroup-data-reverse nil) | |
1478 | (defvar gnus-newsgroup-limit nil) | |
1479 | (defvar gnus-newsgroup-limits nil) | |
23f87bed | 1480 | (defvar gnus-summary-use-undownloaded-faces nil) |
eec82323 LMI |
1481 | |
1482 | (defvar gnus-newsgroup-unreads nil | |
23f87bed | 1483 | "Sorted list of unread articles in the current newsgroup.") |
eec82323 LMI |
1484 | |
1485 | (defvar gnus-newsgroup-unselected nil | |
23f87bed | 1486 | "Sorted list of unselected unread articles in the current newsgroup.") |
eec82323 LMI |
1487 | |
1488 | (defvar gnus-newsgroup-reads nil | |
1489 | "Alist of read articles and article marks in the current newsgroup.") | |
1490 | ||
1491 | (defvar gnus-newsgroup-expunged-tally nil) | |
1492 | ||
1493 | (defvar gnus-newsgroup-marked nil | |
23f87bed MB |
1494 | "Sorted list of ticked articles in the current newsgroup (a subset of unread art).") |
1495 | ||
1496 | (defvar gnus-newsgroup-spam-marked nil | |
1497 | "List of ranges of articles that have been marked as spam.") | |
eec82323 LMI |
1498 | |
1499 | (defvar gnus-newsgroup-killed nil | |
1500 | "List of ranges of articles that have been through the scoring process.") | |
1501 | ||
1502 | (defvar gnus-newsgroup-cached nil | |
23f87bed | 1503 | "Sorted list of articles that come from the article cache.") |
eec82323 LMI |
1504 | |
1505 | (defvar gnus-newsgroup-saved nil | |
1506 | "List of articles that have been saved.") | |
1507 | ||
1508 | (defvar gnus-newsgroup-kill-headers nil) | |
1509 | ||
1510 | (defvar gnus-newsgroup-replied nil | |
1511 | "List of articles that have been replied to in the current newsgroup.") | |
1512 | ||
23f87bed MB |
1513 | (defvar gnus-newsgroup-forwarded nil |
1514 | "List of articles that have been forwarded in the current newsgroup.") | |
1515 | ||
eec82323 | 1516 | (defvar gnus-newsgroup-expirable nil |
23f87bed | 1517 | "Sorted list of articles in the current newsgroup that can be expired.") |
eec82323 LMI |
1518 | |
1519 | (defvar gnus-newsgroup-processable nil | |
1520 | "List of articles in the current newsgroup that can be processed.") | |
1521 | ||
6748645f | 1522 | (defvar gnus-newsgroup-downloadable nil |
23f87bed MB |
1523 | "Sorted list of articles in the current newsgroup that can be processed.") |
1524 | ||
1525 | (defvar gnus-newsgroup-unfetched nil | |
1526 | "Sorted list of articles in the current newsgroup whose headers have | |
1527 | not been fetched into the agent. | |
1528 | ||
1529 | This list will always be a subset of gnus-newsgroup-undownloaded.") | |
6748645f LMI |
1530 | |
1531 | (defvar gnus-newsgroup-undownloaded nil | |
23f87bed | 1532 | "List of articles in the current newsgroup that haven't been downloaded.") |
6748645f LMI |
1533 | |
1534 | (defvar gnus-newsgroup-unsendable nil | |
1535 | "List of articles in the current newsgroup that won't be sent.") | |
1536 | ||
eec82323 LMI |
1537 | (defvar gnus-newsgroup-bookmarks nil |
1538 | "List of articles in the current newsgroup that have bookmarks.") | |
1539 | ||
1540 | (defvar gnus-newsgroup-dormant nil | |
23f87bed MB |
1541 | "Sorted list of dormant articles in the current newsgroup.") |
1542 | ||
1543 | (defvar gnus-newsgroup-unseen nil | |
1544 | "List of unseen articles in the current newsgroup.") | |
1545 | ||
1546 | (defvar gnus-newsgroup-seen nil | |
1547 | "Range of seen articles in the current newsgroup.") | |
1548 | ||
eaa610c3 | 1549 | (defvar gnus-newsgroup-unexist nil |
3af1c868 | 1550 | "Range of unexisting articles in the current newsgroup.") |
eaa610c3 | 1551 | |
23f87bed MB |
1552 | (defvar gnus-newsgroup-articles nil |
1553 | "List of articles in the current newsgroup.") | |
eec82323 LMI |
1554 | |
1555 | (defvar gnus-newsgroup-scored nil | |
1556 | "List of scored articles in the current newsgroup.") | |
1557 | ||
1558 | (defvar gnus-newsgroup-headers nil | |
1559 | "List of article headers in the current newsgroup.") | |
1560 | ||
1561 | (defvar gnus-newsgroup-threads nil) | |
1562 | ||
1563 | (defvar gnus-newsgroup-prepared nil | |
1564 | "Whether the current group has been prepared properly.") | |
1565 | ||
1566 | (defvar gnus-newsgroup-ancient nil | |
1567 | "List of `gnus-fetch-old-headers' articles in the current newsgroup.") | |
1568 | ||
1569 | (defvar gnus-newsgroup-sparse nil) | |
1570 | ||
1571 | (defvar gnus-current-article nil) | |
1572 | (defvar gnus-article-current nil) | |
1573 | (defvar gnus-current-headers nil) | |
1574 | (defvar gnus-have-all-headers nil) | |
1575 | (defvar gnus-last-article nil) | |
1576 | (defvar gnus-newsgroup-history nil) | |
16409b0b GM |
1577 | (defvar gnus-newsgroup-charset nil) |
1578 | (defvar gnus-newsgroup-ephemeral-charset nil) | |
1579 | (defvar gnus-newsgroup-ephemeral-ignored-charsets nil) | |
eec82323 | 1580 | |
23f87bed MB |
1581 | (defvar gnus-article-before-search nil) |
1582 | ||
1583 | (defvar gnus-summary-local-variables | |
eec82323 | 1584 | '(gnus-newsgroup-name |
b1ae92ba G |
1585 | |
1586 | ;; Marks lists | |
1587 | gnus-newsgroup-unreads | |
1588 | gnus-newsgroup-unselected | |
1589 | gnus-newsgroup-marked | |
1590 | gnus-newsgroup-spam-marked | |
1591 | gnus-newsgroup-reads | |
1592 | gnus-newsgroup-saved | |
1593 | gnus-newsgroup-replied | |
1594 | gnus-newsgroup-forwarded | |
b1ae92ba G |
1595 | gnus-newsgroup-expirable |
1596 | gnus-newsgroup-killed | |
1597 | gnus-newsgroup-unseen | |
1598 | gnus-newsgroup-seen | |
eaa610c3 | 1599 | gnus-newsgroup-unexist |
b1ae92ba G |
1600 | gnus-newsgroup-cached |
1601 | gnus-newsgroup-downloadable | |
1602 | gnus-newsgroup-undownloaded | |
1603 | gnus-newsgroup-unsendable | |
1604 | ||
eec82323 LMI |
1605 | gnus-newsgroup-begin gnus-newsgroup-end |
1606 | gnus-newsgroup-last-rmail gnus-newsgroup-last-mail | |
1607 | gnus-newsgroup-last-folder gnus-newsgroup-last-file | |
26c9afc3 | 1608 | gnus-newsgroup-last-directory |
b1ae92ba G |
1609 | gnus-newsgroup-auto-expire |
1610 | gnus-newsgroup-processable | |
23f87bed | 1611 | gnus-newsgroup-unfetched |
b1ae92ba | 1612 | gnus-newsgroup-articles |
eec82323 LMI |
1613 | gnus-newsgroup-bookmarks gnus-newsgroup-dormant |
1614 | gnus-newsgroup-headers gnus-newsgroup-threads | |
1615 | gnus-newsgroup-prepared gnus-summary-highlight-line-function | |
1616 | gnus-current-article gnus-current-headers gnus-have-all-headers | |
1617 | gnus-last-article gnus-article-internal-prepare-hook | |
ed797193 G |
1618 | (gnus-summary-article-delete-hook . global) |
1619 | (gnus-summary-article-move-hook . global) | |
eec82323 LMI |
1620 | gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay |
1621 | gnus-newsgroup-scored gnus-newsgroup-kill-headers | |
1622 | gnus-thread-expunge-below | |
16409b0b GM |
1623 | gnus-score-alist gnus-current-score-file |
1624 | (gnus-summary-expunge-below . global) | |
eec82323 | 1625 | (gnus-summary-mark-below . global) |
16409b0b | 1626 | (gnus-orphan-score . global) |
eec82323 | 1627 | gnus-newsgroup-active gnus-scores-exclude-files |
9f2d52e7 | 1628 | gnus-newsgroup-highest |
eec82323 LMI |
1629 | gnus-newsgroup-history gnus-newsgroup-ancient |
1630 | gnus-newsgroup-sparse gnus-newsgroup-process-stack | |
1631 | (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring) | |
1632 | gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1) | |
1633 | (gnus-newsgroup-expunged-tally . 0) | |
b1ae92ba | 1634 | gnus-cache-removable-articles |
eec82323 | 1635 | gnus-newsgroup-data gnus-newsgroup-data-reverse |
16409b0b | 1636 | gnus-newsgroup-limit gnus-newsgroup-limits |
23f87bed MB |
1637 | gnus-newsgroup-charset gnus-newsgroup-display |
1638 | gnus-summary-use-undownloaded-faces) | |
eec82323 LMI |
1639 | "Variables that are buffer-local to the summary buffers.") |
1640 | ||
23f87bed MB |
1641 | (defvar gnus-newsgroup-variables nil |
1642 | "A list of variables that have separate values in different newsgroups. | |
1643 | A list of newsgroup (summary buffer) local variables, or cons of | |
1644 | variables and their default expressions to be evalled (when the default | |
1645 | values are not nil), that should be made global while the summary buffer | |
1646 | is active. | |
1647 | ||
1648 | Note: The default expressions will be evaluated (using function `eval') | |
1649 | before assignment to the local variable rather than just assigned to it. | |
1650 | If the default expression is the symbol `global', that symbol will not | |
1651 | be evaluated but the global value of the local variable will be used | |
1652 | instead. | |
1653 | ||
1654 | These variables can be used to set variables in the group parameters | |
1655 | while still allowing them to affect operations done in other buffers. | |
1656 | For example: | |
1657 | ||
1658 | \(setq gnus-newsgroup-variables | |
1659 | '(message-use-followup-to | |
1660 | (gnus-visible-headers . | |
1661 | \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\"))) | |
1662 | ") | |
1663 | ||
23f87bed MB |
1664 | (eval-when-compile |
1665 | ;; Bind features so that require will believe that gnus-sum has | |
1666 | ;; already been loaded (avoids infinite recursion) | |
1667 | (let ((features (cons 'gnus-sum features))) | |
23f87bed | 1668 | (require 'gnus-art))) |
eec82323 | 1669 | |
16409b0b GM |
1670 | ;; MIME stuff. |
1671 | ||
1672 | (defvar gnus-decode-encoded-word-methods | |
1673 | '(mail-decode-encoded-word-string) | |
1674 | "List of methods used to decode encoded words. | |
1675 | ||
23f87bed MB |
1676 | This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item |
1677 | is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a | |
40ba43b4 | 1678 | \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups |
16409b0b GM |
1679 | whose names match REGEXP. |
1680 | ||
1681 | For example: | |
23f87bed | 1682 | \((\"chinese\" . gnus-decode-encoded-word-string-by-guess) |
16409b0b GM |
1683 | mail-decode-encoded-word-string |
1684 | (\"chinese\" . rfc1843-decode-string))") | |
1685 | ||
1686 | (defvar gnus-decode-encoded-word-methods-cache nil) | |
1687 | ||
1688 | (defun gnus-multi-decode-encoded-word-string (string) | |
1689 | "Apply the functions from `gnus-encoded-word-methods' that match." | |
1690 | (unless (and gnus-decode-encoded-word-methods-cache | |
1691 | (eq gnus-newsgroup-name | |
1692 | (car gnus-decode-encoded-word-methods-cache))) | |
1693 | (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name)) | |
01c52d31 MB |
1694 | (dolist (method gnus-decode-encoded-word-methods) |
1695 | (if (symbolp method) | |
1696 | (nconc gnus-decode-encoded-word-methods-cache (list method)) | |
1697 | (if (and gnus-newsgroup-name | |
1698 | (string-match (car method) gnus-newsgroup-name)) | |
1699 | (nconc gnus-decode-encoded-word-methods-cache | |
1700 | (list (cdr method))))))) | |
1701 | (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string) | |
1702 | (setq string (funcall method string)))) | |
16409b0b | 1703 | |
eec82323 LMI |
1704 | ;; Subject simplification. |
1705 | ||
6748645f | 1706 | (defun gnus-simplify-whitespace (str) |
16409b0b | 1707 | "Remove excessive whitespace from STR." |
23f87bed MB |
1708 | ;; Multiple spaces. |
1709 | (while (string-match "[ \t][ \t]+" str) | |
1710 | (setq str (concat (substring str 0 (match-beginning 0)) | |
1711 | " " | |
1712 | (substring str (match-end 0))))) | |
1713 | ;; Leading spaces. | |
1714 | (when (string-match "^[ \t]+" str) | |
1715 | (setq str (substring str (match-end 0)))) | |
1716 | ;; Trailing spaces. | |
1717 | (when (string-match "[ \t]+$" str) | |
1718 | (setq str (substring str 0 (match-beginning 0)))) | |
1719 | str) | |
1720 | ||
1721 | (defun gnus-simplify-all-whitespace (str) | |
1722 | "Remove all whitespace from STR." | |
1723 | (while (string-match "[ \t\n]+" str) | |
1724 | (setq str (replace-match "" nil nil str))) | |
1725 | str) | |
6748645f | 1726 | |
eec82323 LMI |
1727 | (defsubst gnus-simplify-subject-re (subject) |
1728 | "Remove \"Re:\" from subject lines." | |
23f87bed | 1729 | (if (string-match message-subject-re-regexp subject) |
eec82323 LMI |
1730 | (substring subject (match-end 0)) |
1731 | subject)) | |
1732 | ||
1733 | (defun gnus-simplify-subject (subject &optional re-only) | |
1734 | "Remove `Re:' and words in parentheses. | |
1735 | If RE-ONLY is non-nil, strip leading `Re:'s only." | |
1736 | (let ((case-fold-search t)) ;Ignore case. | |
1737 | ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'. | |
1738 | (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject) | |
1739 | (setq subject (substring subject (match-end 0)))) | |
1740 | ;; Remove uninteresting prefixes. | |
1741 | (when (and (not re-only) | |
1742 | gnus-simplify-ignored-prefixes | |
1743 | (string-match gnus-simplify-ignored-prefixes subject)) | |
1744 | (setq subject (substring subject (match-end 0)))) | |
1745 | ;; Remove words in parentheses from end. | |
1746 | (unless re-only | |
1747 | (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject) | |
1748 | (setq subject (substring subject 0 (match-beginning 0))))) | |
1749 | ;; Return subject string. | |
1750 | subject)) | |
1751 | ||
1752 | ;; Remove any leading "re:"s, any trailing paren phrases, and simplify | |
1753 | ;; all whitespace. | |
1754 | (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext) | |
1755 | (goto-char (point-min)) | |
1756 | (while (re-search-forward regexp nil t) | |
16409b0b | 1757 | (replace-match (or newtext "")))) |
eec82323 | 1758 | |
a5954fa5 | 1759 | (defun gnus-simplify-buffer-fuzzy (regexp) |
eec82323 LMI |
1760 | "Simplify string in the buffer fuzzily. |
1761 | The string in the accessible portion of the current buffer is simplified. | |
1762 | It is assumed to be a single-line subject. | |
1763 | Whitespace is generally cleaned up, and miscellaneous leading/trailing | |
1764 | matter is removed. Additional things can be deleted by setting | |
16409b0b | 1765 | `gnus-simplify-subject-fuzzy-regexp'." |
eec82323 LMI |
1766 | (let ((case-fold-search t) |
1767 | (modified-tick)) | |
1768 | (gnus-simplify-buffer-fuzzy-step "\t" " ") | |
1769 | ||
1770 | (while (not (eq modified-tick (buffer-modified-tick))) | |
1771 | (setq modified-tick (buffer-modified-tick)) | |
1772 | (cond | |
a5954fa5 G |
1773 | ((listp regexp) |
1774 | (mapc 'gnus-simplify-buffer-fuzzy-step regexp)) | |
1775 | (regexp | |
1776 | (gnus-simplify-buffer-fuzzy-step regexp))) | |
eec82323 LMI |
1777 | (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *") |
1778 | (gnus-simplify-buffer-fuzzy-step | |
1779 | "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *") | |
1780 | (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1")) | |
1781 | ||
1782 | (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$") | |
1783 | (gnus-simplify-buffer-fuzzy-step " +" " ") | |
1784 | (gnus-simplify-buffer-fuzzy-step " $") | |
1785 | (gnus-simplify-buffer-fuzzy-step "^ +"))) | |
1786 | ||
1787 | (defun gnus-simplify-subject-fuzzy (subject) | |
1788 | "Simplify a subject string fuzzily. | |
6748645f | 1789 | See `gnus-simplify-buffer-fuzzy' for details." |
eec82323 | 1790 | (save-excursion |
a5954fa5 G |
1791 | (let ((regexp gnus-simplify-subject-fuzzy-regexp)) |
1792 | (gnus-set-work-buffer) | |
1793 | (let ((case-fold-search t)) | |
1794 | ;; Remove uninteresting prefixes. | |
1795 | (when (and gnus-simplify-ignored-prefixes | |
1796 | (string-match gnus-simplify-ignored-prefixes subject)) | |
1797 | (setq subject (substring subject (match-end 0)))) | |
1798 | (insert subject) | |
1799 | (inline (gnus-simplify-buffer-fuzzy regexp)) | |
1800 | (buffer-string))))) | |
eec82323 LMI |
1801 | |
1802 | (defsubst gnus-simplify-subject-fully (subject) | |
23f87bed | 1803 | "Simplify a subject string according to `gnus-summary-gather-subject-limit'." |
eec82323 | 1804 | (cond |
6748645f LMI |
1805 | (gnus-simplify-subject-functions |
1806 | (gnus-map-function gnus-simplify-subject-functions subject)) | |
eec82323 LMI |
1807 | ((null gnus-summary-gather-subject-limit) |
1808 | (gnus-simplify-subject-re subject)) | |
1809 | ((eq gnus-summary-gather-subject-limit 'fuzzy) | |
1810 | (gnus-simplify-subject-fuzzy subject)) | |
1811 | ((numberp gnus-summary-gather-subject-limit) | |
01c52d31 MB |
1812 | (truncate-string-to-width (gnus-simplify-subject-re subject) |
1813 | gnus-summary-gather-subject-limit)) | |
eec82323 LMI |
1814 | (t |
1815 | subject))) | |
1816 | ||
1817 | (defsubst gnus-subject-equal (s1 s2 &optional simple-first) | |
6748645f | 1818 | "Check whether two subjects are equal. |
23f87bed | 1819 | If optional argument SIMPLE-FIRST is t, first argument is already |
6748645f | 1820 | simplified." |
eec82323 LMI |
1821 | (cond |
1822 | ((null simple-first) | |
1823 | (equal (gnus-simplify-subject-fully s1) | |
1824 | (gnus-simplify-subject-fully s2))) | |
1825 | (t | |
1826 | (equal s1 | |
1827 | (gnus-simplify-subject-fully s2))))) | |
1828 | ||
1829 | (defun gnus-summary-bubble-group () | |
1830 | "Increase the score of the current group. | |
1831 | This is a handy function to add to `gnus-summary-exit-hook' to | |
1832 | increase the score of each group you read." | |
1833 | (gnus-group-add-score gnus-newsgroup-name)) | |
1834 | ||
1835 | \f | |
1836 | ;;; | |
1837 | ;;; Gnus summary mode | |
1838 | ;;; | |
1839 | ||
1840 | (put 'gnus-summary-mode 'mode-class 'special) | |
1841 | ||
1653df0f SZ |
1842 | (defvar gnus-article-commands-menu) |
1843 | ||
23f87bed MB |
1844 | ;; Non-orthogonal keys |
1845 | ||
1846 | (gnus-define-keys gnus-summary-mode-map | |
1847 | " " gnus-summary-next-page | |
9cec74cf | 1848 | [?\S-\ ] gnus-summary-prev-page |
23f87bed MB |
1849 | "\177" gnus-summary-prev-page |
1850 | [delete] gnus-summary-prev-page | |
23f87bed MB |
1851 | "\r" gnus-summary-scroll-up |
1852 | "\M-\r" gnus-summary-scroll-down | |
1853 | "n" gnus-summary-next-unread-article | |
1854 | "p" gnus-summary-prev-unread-article | |
1855 | "N" gnus-summary-next-article | |
1856 | "P" gnus-summary-prev-article | |
1857 | "\M-\C-n" gnus-summary-next-same-subject | |
1858 | "\M-\C-p" gnus-summary-prev-same-subject | |
1859 | "\M-n" gnus-summary-next-unread-subject | |
1860 | "\M-p" gnus-summary-prev-unread-subject | |
1861 | "." gnus-summary-first-unread-article | |
1862 | "," gnus-summary-best-unread-article | |
1863 | "\M-s" gnus-summary-search-article-forward | |
1864 | "\M-r" gnus-summary-search-article-backward | |
01c52d31 MB |
1865 | "\M-S" gnus-summary-repeat-search-article-forward |
1866 | "\M-R" gnus-summary-repeat-search-article-backward | |
23f87bed MB |
1867 | "<" gnus-summary-beginning-of-article |
1868 | ">" gnus-summary-end-of-article | |
1869 | "j" gnus-summary-goto-article | |
1870 | "^" gnus-summary-refer-parent-article | |
1871 | "\M-^" gnus-summary-refer-article | |
1872 | "u" gnus-summary-tick-article-forward | |
1873 | "!" gnus-summary-tick-article-forward | |
1874 | "U" gnus-summary-tick-article-backward | |
1875 | "d" gnus-summary-mark-as-read-forward | |
1876 | "D" gnus-summary-mark-as-read-backward | |
1877 | "E" gnus-summary-mark-as-expirable | |
1878 | "\M-u" gnus-summary-clear-mark-forward | |
1879 | "\M-U" gnus-summary-clear-mark-backward | |
1880 | "k" gnus-summary-kill-same-subject-and-select | |
1881 | "\C-k" gnus-summary-kill-same-subject | |
1882 | "\M-\C-k" gnus-summary-kill-thread | |
1883 | "\M-\C-l" gnus-summary-lower-thread | |
1884 | "e" gnus-summary-edit-article | |
1885 | "#" gnus-summary-mark-as-processable | |
1886 | "\M-#" gnus-summary-unmark-as-processable | |
1887 | "\M-\C-t" gnus-summary-toggle-threads | |
1888 | "\M-\C-s" gnus-summary-show-thread | |
1889 | "\M-\C-h" gnus-summary-hide-thread | |
1890 | "\M-\C-f" gnus-summary-next-thread | |
1891 | "\M-\C-b" gnus-summary-prev-thread | |
1892 | [(meta down)] gnus-summary-next-thread | |
1893 | [(meta up)] gnus-summary-prev-thread | |
1894 | "\M-\C-u" gnus-summary-up-thread | |
1895 | "\M-\C-d" gnus-summary-down-thread | |
1896 | "&" gnus-summary-execute-command | |
1897 | "c" gnus-summary-catchup-and-exit | |
1898 | "\C-w" gnus-summary-mark-region-as-read | |
1899 | "\C-t" gnus-summary-toggle-truncation | |
1900 | "?" gnus-summary-mark-as-dormant | |
1901 | "\C-c\M-\C-s" gnus-summary-limit-include-expunged | |
1902 | "\C-c\C-s\C-n" gnus-summary-sort-by-number | |
6ecfe5c2 | 1903 | "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number |
23f87bed MB |
1904 | "\C-c\C-s\C-l" gnus-summary-sort-by-lines |
1905 | "\C-c\C-s\C-c" gnus-summary-sort-by-chars | |
1906 | "\C-c\C-s\C-a" gnus-summary-sort-by-author | |
01c52d31 | 1907 | "\C-c\C-s\C-t" gnus-summary-sort-by-recipient |
23f87bed MB |
1908 | "\C-c\C-s\C-s" gnus-summary-sort-by-subject |
1909 | "\C-c\C-s\C-d" gnus-summary-sort-by-date | |
6ecfe5c2 | 1910 | "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date |
23f87bed MB |
1911 | "\C-c\C-s\C-i" gnus-summary-sort-by-score |
1912 | "\C-c\C-s\C-o" gnus-summary-sort-by-original | |
1913 | "\C-c\C-s\C-r" gnus-summary-sort-by-random | |
1914 | "=" gnus-summary-expand-window | |
1915 | "\C-x\C-s" gnus-summary-reselect-current-group | |
1916 | "\M-g" gnus-summary-rescan-group | |
23f87bed MB |
1917 | "\C-c\C-r" gnus-summary-caesar-message |
1918 | "f" gnus-summary-followup | |
1919 | "F" gnus-summary-followup-with-original | |
1920 | "C" gnus-summary-cancel-article | |
1921 | "r" gnus-summary-reply | |
1922 | "R" gnus-summary-reply-with-original | |
1923 | "\C-c\C-f" gnus-summary-mail-forward | |
1924 | "o" gnus-summary-save-article | |
1925 | "\C-o" gnus-summary-save-article-mail | |
1926 | "|" gnus-summary-pipe-output | |
1927 | "\M-k" gnus-summary-edit-local-kill | |
1928 | "\M-K" gnus-summary-edit-global-kill | |
1929 | ;; "V" gnus-version | |
1930 | "\C-c\C-d" gnus-summary-describe-group | |
1931 | "q" gnus-summary-exit | |
1932 | "Q" gnus-summary-exit-no-update | |
1933 | "\C-c\C-i" gnus-info-find-node | |
1934 | gnus-mouse-2 gnus-mouse-pick-article | |
132cf96d | 1935 | [follow-link] mouse-face |
23f87bed MB |
1936 | "m" gnus-summary-mail-other-window |
1937 | "a" gnus-summary-post-news | |
23f87bed MB |
1938 | "x" gnus-summary-limit-to-unread |
1939 | "s" gnus-summary-isearch-article | |
061c3227 | 1940 | "\t" gnus-summary-widget-forward |
89b163db | 1941 | [backtab] gnus-summary-widget-backward |
23f87bed MB |
1942 | "t" gnus-summary-toggle-header |
1943 | "g" gnus-summary-show-article | |
1944 | "l" gnus-summary-goto-last-article | |
1945 | "\C-c\C-v\C-v" gnus-uu-decode-uu-view | |
1946 | "\C-d" gnus-summary-enter-digest-group | |
1947 | "\M-\C-d" gnus-summary-read-document | |
1948 | "\M-\C-e" gnus-summary-edit-parameters | |
1949 | "\M-\C-a" gnus-summary-customize-parameters | |
1950 | "\C-c\C-b" gnus-bug | |
1951 | "*" gnus-cache-enter-article | |
1952 | "\M-*" gnus-cache-remove-article | |
1953 | "\M-&" gnus-summary-universal-argument | |
1954 | "\C-l" gnus-recenter | |
1955 | "I" gnus-summary-increase-score | |
1956 | "L" gnus-summary-lower-score | |
1957 | "\M-i" gnus-symbolic-argument | |
1958 | "h" gnus-summary-select-article-buffer | |
1959 | ||
1960 | "b" gnus-article-view-part | |
1961 | "\M-t" gnus-summary-toggle-display-buttonized | |
1962 | ||
1963 | "V" gnus-summary-score-map | |
1964 | "X" gnus-uu-extract-map | |
1965 | "S" gnus-summary-send-map) | |
1966 | ||
1967 | ;; Sort of orthogonal keymap | |
1968 | (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map) | |
1969 | "t" gnus-summary-tick-article-forward | |
1970 | "!" gnus-summary-tick-article-forward | |
1971 | "d" gnus-summary-mark-as-read-forward | |
1972 | "r" gnus-summary-mark-as-read-forward | |
1973 | "c" gnus-summary-clear-mark-forward | |
1974 | " " gnus-summary-clear-mark-forward | |
1975 | "e" gnus-summary-mark-as-expirable | |
1976 | "x" gnus-summary-mark-as-expirable | |
1977 | "?" gnus-summary-mark-as-dormant | |
1978 | "b" gnus-summary-set-bookmark | |
1979 | "B" gnus-summary-remove-bookmark | |
1980 | "#" gnus-summary-mark-as-processable | |
1981 | "\M-#" gnus-summary-unmark-as-processable | |
1982 | "S" gnus-summary-limit-include-expunged | |
1983 | "C" gnus-summary-catchup | |
1984 | "H" gnus-summary-catchup-to-here | |
1985 | "h" gnus-summary-catchup-from-here | |
1986 | "\C-c" gnus-summary-catchup-all | |
1987 | "k" gnus-summary-kill-same-subject-and-select | |
1988 | "K" gnus-summary-kill-same-subject | |
1989 | "P" gnus-uu-mark-map) | |
1990 | ||
1991 | (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map) | |
1992 | "c" gnus-summary-clear-above | |
1993 | "u" gnus-summary-tick-above | |
1994 | "m" gnus-summary-mark-above | |
1995 | "k" gnus-summary-kill-below) | |
1996 | ||
1997 | (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map) | |
1998 | "/" gnus-summary-limit-to-subject | |
1999 | "n" gnus-summary-limit-to-articles | |
01c52d31 MB |
2000 | "b" gnus-summary-limit-to-bodies |
2001 | "h" gnus-summary-limit-to-headers | |
23f87bed MB |
2002 | "w" gnus-summary-pop-limit |
2003 | "s" gnus-summary-limit-to-subject | |
2004 | "a" gnus-summary-limit-to-author | |
2005 | "u" gnus-summary-limit-to-unread | |
2006 | "m" gnus-summary-limit-to-marks | |
2007 | "M" gnus-summary-limit-exclude-marks | |
2008 | "v" gnus-summary-limit-to-score | |
2009 | "*" gnus-summary-limit-include-cached | |
2010 | "D" gnus-summary-limit-include-dormant | |
2011 | "T" gnus-summary-limit-include-thread | |
2012 | "d" gnus-summary-limit-exclude-dormant | |
2013 | "t" gnus-summary-limit-to-age | |
2014 | "." gnus-summary-limit-to-unseen | |
2015 | "x" gnus-summary-limit-to-extra | |
2016 | "p" gnus-summary-limit-to-display-predicate | |
2017 | "E" gnus-summary-limit-include-expunged | |
2018 | "c" gnus-summary-limit-exclude-childless-dormant | |
2019 | "C" gnus-summary-limit-mark-excluded-as-read | |
2020 | "o" gnus-summary-insert-old-articles | |
01c52d31 MB |
2021 | "N" gnus-summary-insert-new-articles |
2022 | "S" gnus-summary-limit-to-singletons | |
2023 | "r" gnus-summary-limit-to-replied | |
2024 | "R" gnus-summary-limit-to-recipient | |
2025 | "A" gnus-summary-limit-to-address) | |
23f87bed MB |
2026 | |
2027 | (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map) | |
2028 | "n" gnus-summary-next-unread-article | |
2029 | "p" gnus-summary-prev-unread-article | |
2030 | "N" gnus-summary-next-article | |
2031 | "P" gnus-summary-prev-article | |
2032 | "\C-n" gnus-summary-next-same-subject | |
2033 | "\C-p" gnus-summary-prev-same-subject | |
2034 | "\M-n" gnus-summary-next-unread-subject | |
2035 | "\M-p" gnus-summary-prev-unread-subject | |
2036 | "f" gnus-summary-first-unread-article | |
2037 | "b" gnus-summary-best-unread-article | |
2038 | "j" gnus-summary-goto-article | |
2039 | "g" gnus-summary-goto-subject | |
2040 | "l" gnus-summary-goto-last-article | |
2041 | "o" gnus-summary-pop-article) | |
2042 | ||
2043 | (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map) | |
2044 | "k" gnus-summary-kill-thread | |
01c52d31 | 2045 | "E" gnus-summary-expire-thread |
23f87bed MB |
2046 | "l" gnus-summary-lower-thread |
2047 | "i" gnus-summary-raise-thread | |
2048 | "T" gnus-summary-toggle-threads | |
2049 | "t" gnus-summary-rethread-current | |
2050 | "^" gnus-summary-reparent-thread | |
01c52d31 | 2051 | "\M-^" gnus-summary-reparent-children |
23f87bed MB |
2052 | "s" gnus-summary-show-thread |
2053 | "S" gnus-summary-show-all-threads | |
2054 | "h" gnus-summary-hide-thread | |
2055 | "H" gnus-summary-hide-all-threads | |
2056 | "n" gnus-summary-next-thread | |
2057 | "p" gnus-summary-prev-thread | |
2058 | "u" gnus-summary-up-thread | |
2059 | "o" gnus-summary-top-thread | |
2060 | "d" gnus-summary-down-thread | |
2061 | "#" gnus-uu-mark-thread | |
2062 | "\M-#" gnus-uu-unmark-thread) | |
2063 | ||
2064 | (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map) | |
2065 | "g" gnus-summary-prepare | |
2066 | "c" gnus-summary-insert-cached-articles | |
01c52d31 MB |
2067 | "d" gnus-summary-insert-dormant-articles |
2068 | "t" gnus-summary-insert-ticked-articles) | |
23f87bed MB |
2069 | |
2070 | (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map) | |
2071 | "c" gnus-summary-catchup-and-exit | |
2072 | "C" gnus-summary-catchup-all-and-exit | |
2073 | "E" gnus-summary-exit-no-update | |
2074 | "Q" gnus-summary-exit | |
2075 | "Z" gnus-summary-exit | |
2076 | "n" gnus-summary-catchup-and-goto-next-group | |
01c52d31 | 2077 | "p" gnus-summary-catchup-and-goto-prev-group |
23f87bed MB |
2078 | "R" gnus-summary-reselect-current-group |
2079 | "G" gnus-summary-rescan-group | |
2080 | "N" gnus-summary-next-group | |
2081 | "s" gnus-summary-save-newsrc | |
2082 | "P" gnus-summary-prev-group) | |
2083 | ||
2084 | (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map) | |
2085 | " " gnus-summary-next-page | |
2086 | "n" gnus-summary-next-page | |
9cec74cf | 2087 | [?\S-\ ] gnus-summary-prev-page |
23f87bed MB |
2088 | "\177" gnus-summary-prev-page |
2089 | [delete] gnus-summary-prev-page | |
2090 | "p" gnus-summary-prev-page | |
2091 | "\r" gnus-summary-scroll-up | |
2092 | "\M-\r" gnus-summary-scroll-down | |
2093 | "<" gnus-summary-beginning-of-article | |
2094 | ">" gnus-summary-end-of-article | |
2095 | "b" gnus-summary-beginning-of-article | |
2096 | "e" gnus-summary-end-of-article | |
2097 | "^" gnus-summary-refer-parent-article | |
2098 | "r" gnus-summary-refer-parent-article | |
8ccbef23 | 2099 | "C" gnus-summary-show-complete-article |
23f87bed MB |
2100 | "D" gnus-summary-enter-digest-group |
2101 | "R" gnus-summary-refer-references | |
2102 | "T" gnus-summary-refer-thread | |
4ddab346 | 2103 | "W" gnus-warp-to-article |
23f87bed MB |
2104 | "g" gnus-summary-show-article |
2105 | "s" gnus-summary-isearch-article | |
061c3227 | 2106 | "\t" gnus-summary-widget-forward |
89b163db | 2107 | [backtab] gnus-summary-widget-backward |
23f87bed | 2108 | "P" gnus-summary-print-article |
01c52d31 | 2109 | "S" gnus-sticky-article |
23f87bed MB |
2110 | "M" gnus-mailing-list-insinuate |
2111 | "t" gnus-article-babel) | |
2112 | ||
2113 | (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map) | |
2114 | "b" gnus-article-add-buttons | |
2115 | "B" gnus-article-add-buttons-to-head | |
2116 | "o" gnus-article-treat-overstrike | |
2117 | "e" gnus-article-emphasize | |
2118 | "w" gnus-article-fill-cited-article | |
2119 | "Q" gnus-article-fill-long-lines | |
01c52d31 | 2120 | "L" gnus-article-toggle-truncate-lines |
23f87bed MB |
2121 | "C" gnus-article-capitalize-sentences |
2122 | "c" gnus-article-remove-cr | |
2123 | "q" gnus-article-de-quoted-unreadable | |
2124 | "6" gnus-article-de-base64-unreadable | |
2125 | "Z" gnus-article-decode-HZ | |
01c52d31 | 2126 | "A" gnus-article-treat-ansi-sequences |
23f87bed MB |
2127 | "h" gnus-article-wash-html |
2128 | "u" gnus-article-unsplit-urls | |
2129 | "s" gnus-summary-force-verify-and-decrypt | |
2130 | "f" gnus-article-display-x-face | |
2131 | "l" gnus-summary-stop-page-breaking | |
2132 | "r" gnus-summary-caesar-message | |
2133 | "m" gnus-summary-morse-message | |
2134 | "t" gnus-summary-toggle-header | |
2135 | "g" gnus-treat-smiley | |
2136 | "v" gnus-summary-verbose-headers | |
2137 | "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive | |
2138 | "p" gnus-article-verify-x-pgp-sig | |
01c52d31 | 2139 | "d" gnus-article-treat-dumbquotes |
be3c11b3 | 2140 | "U" gnus-article-treat-non-ascii |
01c52d31 | 2141 | "i" gnus-summary-idna-message) |
23f87bed MB |
2142 | |
2143 | (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map) | |
2144 | ;; mnemonic: deuglif*Y* | |
2145 | "u" gnus-article-outlook-unwrap-lines | |
2146 | "a" gnus-article-outlook-repair-attribution | |
2147 | "c" gnus-article-outlook-rearrange-citation | |
2148 | "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify | |
2149 | ||
2150 | (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map) | |
2151 | "a" gnus-article-hide | |
2152 | "h" gnus-article-hide-headers | |
2153 | "b" gnus-article-hide-boring-headers | |
2154 | "s" gnus-article-hide-signature | |
2155 | "c" gnus-article-hide-citation | |
2156 | "C" gnus-article-hide-citation-in-followups | |
2157 | "l" gnus-article-hide-list-identifiers | |
2158 | "B" gnus-article-strip-banner | |
2159 | "P" gnus-article-hide-pem | |
2160 | "\C-c" gnus-article-hide-citation-maybe) | |
2161 | ||
2162 | (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map) | |
2163 | "a" gnus-article-highlight | |
2164 | "h" gnus-article-highlight-headers | |
2165 | "c" gnus-article-highlight-citation | |
2166 | "s" gnus-article-highlight-signature) | |
2167 | ||
2168 | (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map) | |
2169 | "f" gnus-article-treat-fold-headers | |
2170 | "u" gnus-article-treat-unfold-headers | |
2171 | "n" gnus-article-treat-fold-newsgroups) | |
2172 | ||
2173 | (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map) | |
2174 | "x" gnus-article-display-x-face | |
2175 | "d" gnus-article-display-face | |
2176 | "s" gnus-treat-smiley | |
2177 | "D" gnus-article-remove-images | |
8b6f6573 | 2178 | "W" gnus-article-show-images |
23f87bed MB |
2179 | "f" gnus-treat-from-picon |
2180 | "m" gnus-treat-mail-picon | |
61b1af82 G |
2181 | "n" gnus-treat-newsgroups-picon |
2182 | "g" gnus-treat-from-gravatar | |
2183 | "h" gnus-treat-mail-gravatar) | |
23f87bed MB |
2184 | |
2185 | (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map) | |
2186 | "w" gnus-article-decode-mime-words | |
2187 | "c" gnus-article-decode-charset | |
4d2226bf | 2188 | "h" gnus-mime-buttonize-attachments-in-header |
23f87bed MB |
2189 | "v" gnus-mime-view-all-parts |
2190 | "b" gnus-article-view-part) | |
2191 | ||
2192 | (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map) | |
2193 | "z" gnus-article-date-ut | |
2194 | "u" gnus-article-date-ut | |
2195 | "l" gnus-article-date-local | |
2196 | "p" gnus-article-date-english | |
2197 | "e" gnus-article-date-lapsed | |
2198 | "o" gnus-article-date-original | |
2199 | "i" gnus-article-date-iso8601 | |
2200 | "s" gnus-article-date-user) | |
2201 | ||
2202 | (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map) | |
2203 | "t" gnus-article-remove-trailing-blank-lines | |
2204 | "l" gnus-article-strip-leading-blank-lines | |
2205 | "m" gnus-article-strip-multiple-blank-lines | |
2206 | "a" gnus-article-strip-blank-lines | |
2207 | "A" gnus-article-strip-all-blank-lines | |
2208 | "s" gnus-article-strip-leading-space | |
2209 | "e" gnus-article-strip-trailing-space | |
2210 | "w" gnus-article-remove-leading-whitespace) | |
2211 | ||
2212 | (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map) | |
2213 | "v" gnus-version | |
23f87bed MB |
2214 | "d" gnus-summary-describe-group |
2215 | "h" gnus-summary-describe-briefly | |
837ba704 | 2216 | "i" gnus-info-find-node) |
23f87bed MB |
2217 | |
2218 | (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map) | |
2219 | "e" gnus-summary-expire-articles | |
2220 | "\M-\C-e" gnus-summary-expire-articles-now | |
2221 | "\177" gnus-summary-delete-article | |
2222 | [delete] gnus-summary-delete-article | |
23f87bed MB |
2223 | "m" gnus-summary-move-article |
2224 | "r" gnus-summary-respool-article | |
2225 | "w" gnus-summary-edit-article | |
2226 | "c" gnus-summary-copy-article | |
2227 | "B" gnus-summary-crosspost-article | |
2228 | "q" gnus-summary-respool-query | |
2229 | "t" gnus-summary-respool-trace | |
2230 | "i" gnus-summary-import-article | |
2231 | "I" gnus-summary-create-article | |
2232 | "p" gnus-summary-article-posted-p) | |
2233 | ||
2234 | (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map) | |
2235 | "o" gnus-summary-save-article | |
2236 | "m" gnus-summary-save-article-mail | |
2237 | "F" gnus-summary-write-article-file | |
2238 | "r" gnus-summary-save-article-rmail | |
2239 | "f" gnus-summary-save-article-file | |
2240 | "b" gnus-summary-save-article-body-file | |
26c9afc3 | 2241 | "B" gnus-summary-write-article-body-file |
23f87bed MB |
2242 | "h" gnus-summary-save-article-folder |
2243 | "v" gnus-summary-save-article-vm | |
2244 | "p" gnus-summary-pipe-output | |
c4d82de8 | 2245 | "P" gnus-summary-muttprint) |
23f87bed MB |
2246 | |
2247 | (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map) | |
2248 | "b" gnus-summary-display-buttonized | |
2249 | "m" gnus-summary-repair-multipart | |
2250 | "v" gnus-article-view-part | |
2251 | "o" gnus-article-save-part | |
01c52d31 MB |
2252 | "O" gnus-article-save-part-and-strip |
2253 | "r" gnus-article-replace-part | |
2254 | "d" gnus-article-delete-part | |
2255 | "t" gnus-article-view-part-as-type | |
2256 | "j" gnus-article-jump-to-part | |
23f87bed MB |
2257 | "c" gnus-article-copy-part |
2258 | "C" gnus-article-view-part-as-charset | |
2259 | "e" gnus-article-view-part-externally | |
01c52d31 | 2260 | "H" gnus-article-browse-html-article |
23f87bed MB |
2261 | "E" gnus-article-encrypt-body |
2262 | "i" gnus-article-inline-part | |
2263 | "|" gnus-article-pipe-part) | |
2264 | ||
2265 | (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map) | |
2266 | "p" gnus-summary-mark-as-processable | |
2267 | "u" gnus-summary-unmark-as-processable | |
2268 | "U" gnus-summary-unmark-all-processable | |
2269 | "v" gnus-uu-mark-over | |
2270 | "s" gnus-uu-mark-series | |
2271 | "r" gnus-uu-mark-region | |
2272 | "g" gnus-uu-unmark-region | |
2273 | "R" gnus-uu-mark-by-regexp | |
2274 | "G" gnus-uu-unmark-by-regexp | |
2275 | "t" gnus-uu-mark-thread | |
2276 | "T" gnus-uu-unmark-thread | |
2277 | "a" gnus-uu-mark-all | |
2278 | "b" gnus-uu-mark-buffer | |
2279 | "S" gnus-uu-mark-sparse | |
2280 | "k" gnus-summary-kill-process-mark | |
2281 | "y" gnus-summary-yank-process-mark | |
2282 | "w" gnus-summary-save-process-mark | |
2283 | "i" gnus-uu-invert-processable) | |
2284 | ||
2285 | (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map) | |
2286 | ;;"x" gnus-uu-extract-any | |
2287 | "m" gnus-summary-save-parts | |
2288 | "u" gnus-uu-decode-uu | |
2289 | "U" gnus-uu-decode-uu-and-save | |
2290 | "s" gnus-uu-decode-unshar | |
2291 | "S" gnus-uu-decode-unshar-and-save | |
2292 | "o" gnus-uu-decode-save | |
2293 | "O" gnus-uu-decode-save | |
2294 | "b" gnus-uu-decode-binhex | |
2295 | "B" gnus-uu-decode-binhex | |
b890d447 | 2296 | "Y" gnus-uu-decode-yenc |
23f87bed MB |
2297 | "p" gnus-uu-decode-postscript |
2298 | "P" gnus-uu-decode-postscript-and-save) | |
2299 | ||
2300 | (gnus-define-keys | |
2301 | (gnus-uu-extract-view-map "v" gnus-uu-extract-map) | |
2302 | "u" gnus-uu-decode-uu-view | |
2303 | "U" gnus-uu-decode-uu-and-save-view | |
2304 | "s" gnus-uu-decode-unshar-view | |
2305 | "S" gnus-uu-decode-unshar-and-save-view | |
2306 | "o" gnus-uu-decode-save-view | |
2307 | "O" gnus-uu-decode-save-view | |
2308 | "b" gnus-uu-decode-binhex-view | |
2309 | "B" gnus-uu-decode-binhex-view | |
2310 | "p" gnus-uu-decode-postscript-view | |
2311 | "P" gnus-uu-decode-postscript-and-save-view) | |
2312 | ||
2313 | (defvar gnus-article-post-menu nil) | |
2314 | ||
2315 | (defconst gnus-summary-menu-maxlen 20) | |
2316 | ||
2317 | (defun gnus-summary-menu-split (menu) | |
2318 | ;; If we have lots of elements, divide them into groups of 20 | |
2319 | ;; and make a pane (or submenu) for each one. | |
2320 | (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2)) | |
2321 | (let ((menu menu) sublists next | |
2322 | (i 1)) | |
2323 | (while menu | |
2324 | ;; Pull off the next gnus-summary-menu-maxlen elements | |
2325 | ;; and make them the next element of sublist. | |
2326 | (setq next (nthcdr gnus-summary-menu-maxlen menu)) | |
2327 | (if next | |
2328 | (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu) | |
2329 | nil)) | |
2330 | (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0) | |
2331 | (aref (car (last menu)) 0)) menu) | |
2332 | sublists)) | |
2333 | (setq i (1+ i)) | |
2334 | (setq menu next)) | |
2335 | (nreverse sublists)) | |
2336 | ;; Few elements--put them all in one pane. | |
2337 | menu)) | |
eec82323 LMI |
2338 | |
2339 | (defun gnus-summary-make-menu-bar () | |
2340 | (gnus-turn-off-edit-menu 'summary) | |
2341 | ||
2342 | (unless (boundp 'gnus-summary-misc-menu) | |
2343 | ||
2344 | (easy-menu-define | |
23f87bed MB |
2345 | gnus-summary-kill-menu gnus-summary-mode-map "" |
2346 | (cons | |
2347 | "Score" | |
2348 | (nconc | |
2349 | (list | |
2350 | ["Customize" gnus-score-customize t]) | |
2351 | (gnus-make-score-map 'increase) | |
2352 | (gnus-make-score-map 'lower) | |
2353 | '(("Mark" | |
2354 | ["Kill below" gnus-summary-kill-below t] | |
2355 | ["Mark above" gnus-summary-mark-above t] | |
2356 | ["Tick above" gnus-summary-tick-above t] | |
2357 | ["Clear above" gnus-summary-clear-above t]) | |
3eb9b5fd G |
2358 | ["Current article score" gnus-summary-current-score t] |
2359 | ["Current thread score" (gnus-summary-current-score 'total) t] | |
23f87bed MB |
2360 | ["Set score" gnus-summary-set-score t] |
2361 | ["Switch current score file..." gnus-score-change-score-file t] | |
2362 | ["Set mark below..." gnus-score-set-mark-below t] | |
2363 | ["Set expunge below..." gnus-score-set-expunge-below t] | |
2364 | ["Edit current score file" gnus-score-edit-current-scores t] | |
59429511 | 2365 | ["Edit score file..." gnus-score-edit-file t] |
23f87bed MB |
2366 | ["Trace score" gnus-score-find-trace t] |
2367 | ["Find words" gnus-score-find-favourite-words t] | |
2368 | ["Rescore buffer" gnus-summary-rescore t] | |
2369 | ["Increase score..." gnus-summary-increase-score t] | |
2370 | ["Lower score..." gnus-summary-lower-score t])))) | |
2371 | ||
2372 | ;; Define both the Article menu in the summary buffer and the | |
2373 | ;; equivalent Commands menu in the article buffer here for | |
2374 | ;; consistency. | |
6748645f | 2375 | (let ((innards |
23f87bed MB |
2376 | `(("Hide" |
2377 | ["All" gnus-article-hide t] | |
2378 | ["Headers" gnus-article-hide-headers t] | |
2379 | ["Signature" gnus-article-hide-signature t] | |
2380 | ["Citation" gnus-article-hide-citation t] | |
16409b0b | 2381 | ["List identifiers" gnus-article-hide-list-identifiers t] |
16409b0b | 2382 | ["Banner" gnus-article-strip-banner t] |
23f87bed MB |
2383 | ["Boring headers" gnus-article-hide-boring-headers t]) |
2384 | ("Highlight" | |
2385 | ["All" gnus-article-highlight t] | |
2386 | ["Headers" gnus-article-highlight-headers t] | |
2387 | ["Signature" gnus-article-highlight-signature t] | |
2388 | ["Citation" gnus-article-highlight-citation t]) | |
16409b0b GM |
2389 | ("MIME" |
2390 | ["Words" gnus-article-decode-mime-words t] | |
2391 | ["Charset" gnus-article-decode-charset t] | |
2392 | ["QP" gnus-article-de-quoted-unreadable t] | |
2393 | ["Base64" gnus-article-de-base64-unreadable t] | |
23f87bed | 2394 | ["View MIME buttons" gnus-summary-display-buttonized t] |
4d2226bf G |
2395 | ["View MIME buttons in header" |
2396 | gnus-mime-buttonize-attachments-in-header t] | |
23f87bed MB |
2397 | ["View all" gnus-mime-view-all-parts t] |
2398 | ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t] | |
2399 | ["Encrypt body" gnus-article-encrypt-body | |
2400 | :active (not (gnus-group-read-only-p)) | |
2401 | ,@(if (featurep 'xemacs) nil | |
2402 | '(:help "Encrypt the message body on disk"))] | |
2403 | ["Extract all parts..." gnus-summary-save-parts t] | |
2404 | ("Multipart" | |
2405 | ["Repair multipart" gnus-summary-repair-multipart t] | |
2406 | ["Pipe part..." gnus-article-pipe-part t] | |
2407 | ["Inline part" gnus-article-inline-part t] | |
01c52d31 | 2408 | ["View part as type..." gnus-article-view-part-as-type t] |
23f87bed MB |
2409 | ["Encrypt body" gnus-article-encrypt-body |
2410 | :active (not (gnus-group-read-only-p)) | |
2411 | ,@(if (featurep 'xemacs) nil | |
2412 | '(:help "Encrypt the message body on disk"))] | |
2413 | ["View part externally" gnus-article-view-part-externally t] | |
01c52d31 | 2414 | ["View HTML parts in browser" gnus-article-browse-html-article t] |
23f87bed MB |
2415 | ["View part with charset..." gnus-article-view-part-as-charset t] |
2416 | ["Copy part" gnus-article-copy-part t] | |
2417 | ["Save part..." gnus-article-save-part t] | |
2418 | ["View part" gnus-article-view-part t])) | |
2419 | ("Date" | |
2420 | ["Local" gnus-article-date-local t] | |
2421 | ["ISO8601" gnus-article-date-iso8601 t] | |
2422 | ["UT" gnus-article-date-ut t] | |
2423 | ["Original" gnus-article-date-original t] | |
2424 | ["Lapsed" gnus-article-date-lapsed t] | |
2425 | ["User-defined" gnus-article-date-user t]) | |
2426 | ("Display" | |
2427 | ["Remove images" gnus-article-remove-images t] | |
2428 | ["Toggle smiley" gnus-treat-smiley t] | |
2429 | ["Show X-Face" gnus-article-display-x-face t] | |
2430 | ["Show picons in From" gnus-treat-from-picon t] | |
2431 | ["Show picons in mail headers" gnus-treat-mail-picon t] | |
2432 | ["Show picons in news headers" gnus-treat-newsgroups-picon t] | |
61b1af82 G |
2433 | ["Show Gravatars in From" gnus-treat-from-gravatar t] |
2434 | ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t] | |
23f87bed MB |
2435 | ("View as different encoding" |
2436 | ,@(gnus-summary-menu-split | |
2437 | (mapcar | |
2438 | (lambda (cs) | |
2439 | ;; Since easymenu under Emacs doesn't allow | |
2440 | ;; lambda forms for menu commands, we should | |
2441 | ;; provide intern'ed function symbols. | |
2442 | (let ((command (intern (format "\ | |
2443 | gnus-summary-show-article-from-menu-as-charset-%s" cs)))) | |
2444 | (fset command | |
2445 | `(lambda () | |
2446 | (interactive) | |
2447 | (let ((gnus-summary-show-article-charset-alist | |
2448 | '((1 . ,cs)))) | |
2449 | (gnus-summary-show-article 1)))) | |
2450 | `[,(symbol-name cs) ,command t])) | |
2451 | (sort (if (fboundp 'coding-system-list) | |
2452 | (coding-system-list) | |
2453 | (mapcar 'car mm-mime-mule-charset-alist)) | |
2454 | 'string<))))) | |
2455 | ("Washing" | |
2456 | ("Remove Blanks" | |
2457 | ["Leading" gnus-article-strip-leading-blank-lines t] | |
2458 | ["Multiple" gnus-article-strip-multiple-blank-lines t] | |
2459 | ["Trailing" gnus-article-remove-trailing-blank-lines t] | |
2460 | ["All of the above" gnus-article-strip-blank-lines t] | |
2461 | ["All" gnus-article-strip-all-blank-lines t] | |
2462 | ["Leading space" gnus-article-strip-leading-space t] | |
2463 | ["Trailing space" gnus-article-strip-trailing-space t] | |
2464 | ["Leading space in headers" | |
2465 | gnus-article-remove-leading-whitespace t]) | |
2466 | ["Overstrike" gnus-article-treat-overstrike t] | |
2467 | ["Dumb quotes" gnus-article-treat-dumbquotes t] | |
be3c11b3 | 2468 | ["Non-ASCII" gnus-article-treat-non-ascii t] |
23f87bed MB |
2469 | ["Emphasis" gnus-article-emphasize t] |
2470 | ["Word wrap" gnus-article-fill-cited-article t] | |
16409b0b | 2471 | ["Fill long lines" gnus-article-fill-long-lines t] |
01c52d31 | 2472 | ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t] |
16409b0b | 2473 | ["Capitalize sentences" gnus-article-capitalize-sentences t] |
23f87bed MB |
2474 | ["Remove CR" gnus-article-remove-cr t] |
2475 | ["Quoted-Printable" gnus-article-de-quoted-unreadable t] | |
2476 | ["Base64" gnus-article-de-base64-unreadable t] | |
2477 | ["Rot 13" gnus-summary-caesar-message | |
2478 | ,@(if (featurep 'xemacs) '(t) | |
2479 | '(:help "\"Caesar rotate\" article by 13"))] | |
01c52d31 | 2480 | ["De-IDNA" gnus-summary-idna-message t] |
23f87bed MB |
2481 | ["Morse decode" gnus-summary-morse-message t] |
2482 | ["Unix pipe..." gnus-summary-pipe-message t] | |
2483 | ["Add buttons" gnus-article-add-buttons t] | |
2484 | ["Add buttons to head" gnus-article-add-buttons-to-head t] | |
2485 | ["Stop page breaking" gnus-summary-stop-page-breaking t] | |
2486 | ["Verbose header" gnus-summary-verbose-headers t] | |
2487 | ["Toggle header" gnus-summary-toggle-header t] | |
2488 | ["Unfold headers" gnus-article-treat-unfold-headers t] | |
2489 | ["Fold newsgroups" gnus-article-treat-fold-newsgroups t] | |
16409b0b | 2490 | ["Html" gnus-article-wash-html t] |
23f87bed MB |
2491 | ["Unsplit URLs" gnus-article-unsplit-urls t] |
2492 | ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t] | |
2493 | ["Decode HZ" gnus-article-decode-HZ t] | |
01c52d31 | 2494 | ["ANSI sequences" gnus-article-treat-ansi-sequences t] |
23f87bed MB |
2495 | ("(Outlook) Deuglify" |
2496 | ["Unwrap lines" gnus-article-outlook-unwrap-lines t] | |
2497 | ["Repair attribution" gnus-article-outlook-repair-attribution t] | |
2498 | ["Rearrange citation" gnus-article-outlook-rearrange-citation t] | |
2499 | ["Full (Outlook) deuglify" | |
2500 | gnus-article-outlook-deuglify-article t]) | |
2501 | ) | |
2502 | ("Output" | |
2503 | ["Save in default format..." gnus-summary-save-article | |
2504 | ,@(if (featurep 'xemacs) '(t) | |
2505 | '(:help "Save article using default method"))] | |
2506 | ["Save in file..." gnus-summary-save-article-file | |
2507 | ,@(if (featurep 'xemacs) '(t) | |
2508 | '(:help "Save article in file"))] | |
2509 | ["Save in Unix mail format..." gnus-summary-save-article-mail t] | |
2510 | ["Save in MH folder..." gnus-summary-save-article-folder t] | |
2511 | ["Save in VM folder..." gnus-summary-save-article-vm t] | |
2512 | ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t] | |
2513 | ["Save body in file..." gnus-summary-save-article-body-file t] | |
2514 | ["Pipe through a filter..." gnus-summary-pipe-output t] | |
23f87bed | 2515 | ["Print with Muttprint..." gnus-summary-muttprint t] |
531e5812 MB |
2516 | ["Print" gnus-summary-print-article |
2517 | ,@(if (featurep 'xemacs) '(t) | |
2518 | '(:help "Generate and print a PostScript image"))]) | |
2519 | ("Copy, move,... (Backend)" | |
707f2b38 | 2520 | ,@(if (featurep 'xemacs) nil |
531e5812 | 2521 | '(:help "Copying, moving, expiring articles...")) |
23f87bed MB |
2522 | ["Respool article..." gnus-summary-respool-article t] |
2523 | ["Move article..." gnus-summary-move-article | |
2524 | (gnus-check-backend-function | |
2525 | 'request-move-article gnus-newsgroup-name)] | |
2526 | ["Copy article..." gnus-summary-copy-article t] | |
2527 | ["Crosspost article..." gnus-summary-crosspost-article | |
2528 | (gnus-check-backend-function | |
2529 | 'request-replace-article gnus-newsgroup-name)] | |
2530 | ["Import file..." gnus-summary-import-article | |
2531 | (gnus-check-backend-function | |
2532 | 'request-accept-article gnus-newsgroup-name)] | |
2533 | ["Create article..." gnus-summary-create-article | |
2534 | (gnus-check-backend-function | |
2535 | 'request-accept-article gnus-newsgroup-name)] | |
2536 | ["Check if posted" gnus-summary-article-posted-p t] | |
2537 | ["Edit article" gnus-summary-edit-article | |
2538 | (not (gnus-group-read-only-p))] | |
2539 | ["Delete article" gnus-summary-delete-article | |
2540 | (gnus-check-backend-function | |
2541 | 'request-expire-articles gnus-newsgroup-name)] | |
2542 | ["Query respool" gnus-summary-respool-query t] | |
6748645f | 2543 | ["Trace respool" gnus-summary-respool-trace t] |
23f87bed MB |
2544 | ["Delete expirable articles" gnus-summary-expire-articles-now |
2545 | (gnus-check-backend-function | |
2546 | 'request-expire-articles gnus-newsgroup-name)]) | |
2547 | ("Extract" | |
2548 | ["Uudecode" gnus-uu-decode-uu | |
2549 | ,@(if (featurep 'xemacs) '(t) | |
2550 | '(:help "Decode uuencoded article(s)"))] | |
2551 | ["Uudecode and save" gnus-uu-decode-uu-and-save t] | |
2552 | ["Unshar" gnus-uu-decode-unshar t] | |
2553 | ["Unshar and save" gnus-uu-decode-unshar-and-save t] | |
2554 | ["Save" gnus-uu-decode-save t] | |
2555 | ["Binhex" gnus-uu-decode-binhex t] | |
7877f373 | 2556 | ["PostScript" gnus-uu-decode-postscript t] |
23f87bed MB |
2557 | ["All MIME parts" gnus-summary-save-parts t]) |
2558 | ("Cache" | |
2559 | ["Enter article" gnus-cache-enter-article t] | |
2560 | ["Remove article" gnus-cache-remove-article t]) | |
16409b0b | 2561 | ["Translate" gnus-article-babel t] |
23f87bed | 2562 | ["Select article buffer" gnus-summary-select-article-buffer t] |
01c52d31 | 2563 | ["Make article buffer sticky" gnus-sticky-article t] |
23f87bed MB |
2564 | ["Enter digest buffer" gnus-summary-enter-digest-group t] |
2565 | ["Isearch article..." gnus-summary-isearch-article t] | |
2566 | ["Beginning of the article" gnus-summary-beginning-of-article t] | |
2567 | ["End of the article" gnus-summary-end-of-article t] | |
2568 | ["Fetch parent of article" gnus-summary-refer-parent-article t] | |
2569 | ["Fetch referenced articles" gnus-summary-refer-references t] | |
2570 | ["Fetch current thread" gnus-summary-refer-thread t] | |
2571 | ["Fetch article with id..." gnus-summary-refer-article t] | |
2572 | ["Setup Mailing List Params" gnus-mailing-list-insinuate t] | |
2573 | ["Redisplay" gnus-summary-show-article t] | |
2574 | ["Raw article" gnus-summary-show-raw-article :keys "C-u g"]))) | |
6748645f | 2575 | (easy-menu-define |
23f87bed MB |
2576 | gnus-summary-article-menu gnus-summary-mode-map "" |
2577 | (cons "Article" innards)) | |
6748645f | 2578 | |
1653df0f SZ |
2579 | (if (not (keymapp gnus-summary-article-menu)) |
2580 | (easy-menu-define | |
2581 | gnus-article-commands-menu gnus-article-mode-map "" | |
2582 | (cons "Commands" innards)) | |
2583 | ;; in Emacs, don't share menu. | |
a1506d29 | 2584 | (setq gnus-article-commands-menu |
1653df0f SZ |
2585 | (copy-keymap gnus-summary-article-menu)) |
2586 | (define-key gnus-article-mode-map [menu-bar commands] | |
2587 | (cons "Commands" gnus-article-commands-menu)))) | |
eec82323 LMI |
2588 | |
2589 | (easy-menu-define | |
23f87bed MB |
2590 | gnus-summary-thread-menu gnus-summary-mode-map "" |
2591 | '("Threads" | |
2592 | ["Find all messages in thread" gnus-summary-refer-thread t] | |
2593 | ["Toggle threading" gnus-summary-toggle-threads t] | |
2594 | ["Hide threads" gnus-summary-hide-all-threads t] | |
2595 | ["Show threads" gnus-summary-show-all-threads t] | |
2596 | ["Hide thread" gnus-summary-hide-thread t] | |
2597 | ["Show thread" gnus-summary-show-thread t] | |
2598 | ["Go to next thread" gnus-summary-next-thread t] | |
2599 | ["Go to previous thread" gnus-summary-prev-thread t] | |
2600 | ["Go down thread" gnus-summary-down-thread t] | |
2601 | ["Go up thread" gnus-summary-up-thread t] | |
2602 | ["Top of thread" gnus-summary-top-thread t] | |
2603 | ["Mark thread as read" gnus-summary-kill-thread t] | |
01c52d31 | 2604 | ["Mark thread as expired" gnus-summary-expire-thread t] |
23f87bed MB |
2605 | ["Lower thread score" gnus-summary-lower-thread t] |
2606 | ["Raise thread score" gnus-summary-raise-thread t] | |
2607 | ["Rethread current" gnus-summary-rethread-current t])) | |
eec82323 LMI |
2608 | |
2609 | (easy-menu-define | |
23f87bed MB |
2610 | gnus-summary-post-menu gnus-summary-mode-map "" |
2611 | `("Post" | |
2612 | ["Send a message (mail or news)" gnus-summary-post-news | |
2613 | ,@(if (featurep 'xemacs) '(t) | |
531e5812 | 2614 | '(:help "Compose a new message (mail or news)"))] |
23f87bed MB |
2615 | ["Followup" gnus-summary-followup |
2616 | ,@(if (featurep 'xemacs) '(t) | |
2617 | '(:help "Post followup to this article"))] | |
2618 | ["Followup and yank" gnus-summary-followup-with-original | |
2619 | ,@(if (featurep 'xemacs) '(t) | |
2620 | '(:help "Post followup to this article, quoting its contents"))] | |
2621 | ["Supersede article" gnus-summary-supersede-article t] | |
2622 | ["Cancel article" gnus-summary-cancel-article | |
2623 | ,@(if (featurep 'xemacs) '(t) | |
2624 | '(:help "Cancel an article you posted"))] | |
2625 | ["Reply" gnus-summary-reply t] | |
2626 | ["Reply and yank" gnus-summary-reply-with-original t] | |
2627 | ["Wide reply" gnus-summary-wide-reply t] | |
2628 | ["Wide reply and yank" gnus-summary-wide-reply-with-original | |
2629 | ,@(if (featurep 'xemacs) '(t) | |
2630 | '(:help "Mail a reply, quoting this article"))] | |
2631 | ["Very wide reply" gnus-summary-very-wide-reply t] | |
2632 | ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original | |
2633 | ,@(if (featurep 'xemacs) '(t) | |
2634 | '(:help "Mail a very wide reply, quoting this article"))] | |
2635 | ["Mail forward" gnus-summary-mail-forward t] | |
2636 | ["Post forward" gnus-summary-post-forward t] | |
2637 | ["Digest and mail" gnus-uu-digest-mail-forward t] | |
2638 | ["Digest and post" gnus-uu-digest-post-forward t] | |
2639 | ["Resend message" gnus-summary-resend-message t] | |
2640 | ["Resend message edit" gnus-summary-resend-message-edit t] | |
2641 | ["Send bounced mail" gnus-summary-resend-bounced-mail t] | |
2642 | ["Send a mail" gnus-summary-mail-other-window t] | |
2643 | ["Create a local message" gnus-summary-news-other-window t] | |
2644 | ["Uuencode and post" gnus-uu-post-news | |
2645 | ,@(if (featurep 'xemacs) '(t) | |
2646 | '(:help "Post a uuencoded article"))] | |
2647 | ["Followup via news" gnus-summary-followup-to-mail t] | |
2648 | ["Followup via news and yank" | |
2649 | gnus-summary-followup-to-mail-with-original t] | |
9b3ebcb6 MB |
2650 | ["Strip signature on reply" |
2651 | (lambda () | |
2652 | (interactive) | |
2653 | (if (not (memq message-cite-function | |
2654 | '(message-cite-original-without-signature | |
2655 | message-cite-original))) | |
2656 | ;; Stupid workaround for XEmacs not honoring :visible. | |
2657 | (message "Can't toggle this value of `message-cite-function'") | |
2658 | (setq message-cite-function | |
2659 | (if (eq message-cite-function | |
2660 | 'message-cite-original-without-signature) | |
2661 | 'message-cite-original | |
2662 | 'message-cite-original-without-signature)))) | |
2663 | ;; XEmacs barfs on :visible. | |
2664 | ,@(if (featurep 'xemacs) nil | |
2665 | '(:visible (memq message-cite-function | |
2666 | '(message-cite-original-without-signature | |
2667 | message-cite-original)))) | |
2668 | :style toggle | |
2669 | :selected (eq message-cite-function | |
2670 | 'message-cite-original-without-signature) | |
2671 | ,@(if (featurep 'xemacs) nil | |
2672 | '(:help "Strip signature from cited article when replying."))] | |
23f87bed MB |
2673 | ;;("Draft" |
2674 | ;;["Send" gnus-summary-send-draft t] | |
2675 | ;;["Send bounced" gnus-resend-bounced-mail t]) | |
2676 | )) | |
2677 | ||
2678 | (cond | |
2679 | ((not (keymapp gnus-summary-post-menu)) | |
2680 | (setq gnus-article-post-menu gnus-summary-post-menu)) | |
2681 | ((not gnus-article-post-menu) | |
2682 | ;; Don't share post menu. | |
2683 | (setq gnus-article-post-menu | |
2684 | (copy-keymap gnus-summary-post-menu)))) | |
2685 | (define-key gnus-article-mode-map [menu-bar post] | |
2686 | (cons "Post" gnus-article-post-menu)) | |
eec82323 LMI |
2687 | |
2688 | (easy-menu-define | |
23f87bed MB |
2689 | gnus-summary-misc-menu gnus-summary-mode-map "" |
2690 | `("Gnus" | |
2691 | ("Mark Read" | |
2692 | ["Mark as read" gnus-summary-mark-as-read-forward t] | |
2693 | ["Mark same subject and select" | |
2694 | gnus-summary-kill-same-subject-and-select t] | |
2695 | ["Mark same subject" gnus-summary-kill-same-subject t] | |
2696 | ["Catchup" gnus-summary-catchup | |
2697 | ,@(if (featurep 'xemacs) '(t) | |
2698 | '(:help "Mark unread articles in this group as read"))] | |
2699 | ["Catchup all" gnus-summary-catchup-all t] | |
2700 | ["Catchup to here" gnus-summary-catchup-to-here t] | |
2701 | ["Catchup from here" gnus-summary-catchup-from-here t] | |
2702 | ["Catchup region" gnus-summary-mark-region-as-read | |
2703 | (gnus-mark-active-p)] | |
2704 | ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t]) | |
2705 | ("Mark Various" | |
2706 | ["Tick" gnus-summary-tick-article-forward t] | |
2707 | ["Mark as dormant" gnus-summary-mark-as-dormant t] | |
2708 | ["Remove marks" gnus-summary-clear-mark-forward t] | |
2709 | ["Set expirable mark" gnus-summary-mark-as-expirable t] | |
2710 | ["Set bookmark" gnus-summary-set-bookmark t] | |
2711 | ["Remove bookmark" gnus-summary-remove-bookmark t]) | |
2712 | ("Limit to" | |
2713 | ["Marks..." gnus-summary-limit-to-marks t] | |
2714 | ["Subject..." gnus-summary-limit-to-subject t] | |
2715 | ["Author..." gnus-summary-limit-to-author t] | |
01c52d31 MB |
2716 | ["Recipient..." gnus-summary-limit-to-recipient t] |
2717 | ["Address..." gnus-summary-limit-to-address t] | |
23f87bed MB |
2718 | ["Age..." gnus-summary-limit-to-age t] |
2719 | ["Extra..." gnus-summary-limit-to-extra t] | |
2720 | ["Score..." gnus-summary-limit-to-score t] | |
2721 | ["Display Predicate" gnus-summary-limit-to-display-predicate t] | |
2722 | ["Unread" gnus-summary-limit-to-unread t] | |
2723 | ["Unseen" gnus-summary-limit-to-unseen t] | |
01c52d31 MB |
2724 | ["Singletons" gnus-summary-limit-to-singletons t] |
2725 | ["Replied" gnus-summary-limit-to-replied t] | |
23f87bed | 2726 | ["Non-dormant" gnus-summary-limit-exclude-dormant t] |
996aa8c1 | 2727 | ["Next or process marked articles" gnus-summary-limit-to-articles t] |
23f87bed MB |
2728 | ["Pop limit" gnus-summary-pop-limit t] |
2729 | ["Show dormant" gnus-summary-limit-include-dormant t] | |
2730 | ["Hide childless dormant" | |
2731 | gnus-summary-limit-exclude-childless-dormant t] | |
2732 | ;;["Hide thread" gnus-summary-limit-exclude-thread t] | |
2733 | ["Hide marked" gnus-summary-limit-exclude-marks t] | |
2734 | ["Show expunged" gnus-summary-limit-include-expunged t]) | |
2735 | ("Process Mark" | |
2736 | ["Set mark" gnus-summary-mark-as-processable t] | |
2737 | ["Remove mark" gnus-summary-unmark-as-processable t] | |
2738 | ["Remove all marks" gnus-summary-unmark-all-processable t] | |
01c52d31 | 2739 | ["Invert marks" gnus-uu-invert-processable t] |
23f87bed MB |
2740 | ["Mark above" gnus-uu-mark-over t] |
2741 | ["Mark series" gnus-uu-mark-series t] | |
2742 | ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)] | |
2743 | ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)] | |
2744 | ["Mark by regexp..." gnus-uu-mark-by-regexp t] | |
2745 | ["Unmark by regexp..." gnus-uu-unmark-by-regexp t] | |
2746 | ["Mark all" gnus-uu-mark-all t] | |
2747 | ["Mark buffer" gnus-uu-mark-buffer t] | |
2748 | ["Mark sparse" gnus-uu-mark-sparse t] | |
2749 | ["Mark thread" gnus-uu-mark-thread t] | |
2750 | ["Unmark thread" gnus-uu-unmark-thread t] | |
2751 | ("Process Mark Sets" | |
2752 | ["Kill" gnus-summary-kill-process-mark t] | |
2753 | ["Yank" gnus-summary-yank-process-mark | |
2754 | gnus-newsgroup-process-stack] | |
2755 | ["Save" gnus-summary-save-process-mark t] | |
2756 | ["Run command on marked..." gnus-summary-universal-argument t])) | |
ec7995fa | 2757 | ("Registry Marks") |
23f87bed MB |
2758 | ("Scroll article" |
2759 | ["Page forward" gnus-summary-next-page | |
2760 | ,@(if (featurep 'xemacs) '(t) | |
2761 | '(:help "Show next page of article"))] | |
2762 | ["Page backward" gnus-summary-prev-page | |
2763 | ,@(if (featurep 'xemacs) '(t) | |
2764 | '(:help "Show previous page of article"))] | |
2765 | ["Line forward" gnus-summary-scroll-up t]) | |
2766 | ("Move" | |
2767 | ["Next unread article" gnus-summary-next-unread-article t] | |
2768 | ["Previous unread article" gnus-summary-prev-unread-article t] | |
2769 | ["Next article" gnus-summary-next-article t] | |
2770 | ["Previous article" gnus-summary-prev-article t] | |
2771 | ["Next unread subject" gnus-summary-next-unread-subject t] | |
2772 | ["Previous unread subject" gnus-summary-prev-unread-subject t] | |
2773 | ["Next article same subject" gnus-summary-next-same-subject t] | |
2774 | ["Previous article same subject" gnus-summary-prev-same-subject t] | |
2775 | ["First unread article" gnus-summary-first-unread-article t] | |
2776 | ["Best unread article" gnus-summary-best-unread-article t] | |
2777 | ["Go to subject number..." gnus-summary-goto-subject t] | |
2778 | ["Go to article number..." gnus-summary-goto-article t] | |
2779 | ["Go to the last article" gnus-summary-goto-last-article t] | |
2780 | ["Pop article off history" gnus-summary-pop-article t]) | |
2781 | ("Sort" | |
2782 | ["Sort by number" gnus-summary-sort-by-number t] | |
6ecfe5c2 | 2783 | ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t] |
23f87bed | 2784 | ["Sort by author" gnus-summary-sort-by-author t] |
01c52d31 | 2785 | ["Sort by recipient" gnus-summary-sort-by-recipient t] |
23f87bed MB |
2786 | ["Sort by subject" gnus-summary-sort-by-subject t] |
2787 | ["Sort by date" gnus-summary-sort-by-date t] | |
6ecfe5c2 | 2788 | ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t] |
23f87bed MB |
2789 | ["Sort by score" gnus-summary-sort-by-score t] |
2790 | ["Sort by lines" gnus-summary-sort-by-lines t] | |
2791 | ["Sort by characters" gnus-summary-sort-by-chars t] | |
2792 | ["Randomize" gnus-summary-sort-by-random t] | |
2793 | ["Original sort" gnus-summary-sort-by-original t]) | |
2794 | ("Help" | |
23f87bed | 2795 | ["Describe group" gnus-summary-describe-group t] |
23f87bed MB |
2796 | ["Read manual" gnus-info-find-node t]) |
2797 | ("Modes" | |
2798 | ["Pick and read" gnus-pick-mode t] | |
2799 | ["Binary" gnus-binary-mode t]) | |
2800 | ("Regeneration" | |
2801 | ["Regenerate" gnus-summary-prepare t] | |
2802 | ["Insert cached articles" gnus-summary-insert-cached-articles t] | |
2803 | ["Insert dormant articles" gnus-summary-insert-dormant-articles t] | |
01c52d31 | 2804 | ["Insert ticked articles" gnus-summary-insert-ticked-articles t] |
23f87bed MB |
2805 | ["Toggle threading" gnus-summary-toggle-threads t]) |
2806 | ["See old articles" gnus-summary-insert-old-articles t] | |
2807 | ["See new articles" gnus-summary-insert-new-articles t] | |
2808 | ["Filter articles..." gnus-summary-execute-command t] | |
2809 | ["Run command on articles..." gnus-summary-universal-argument t] | |
2810 | ["Search articles forward..." gnus-summary-search-article-forward t] | |
2811 | ["Search articles backward..." gnus-summary-search-article-backward t] | |
2812 | ["Toggle line truncation" gnus-summary-toggle-truncation t] | |
2813 | ["Expand window" gnus-summary-expand-window t] | |
2814 | ["Expire expirable articles" gnus-summary-expire-articles | |
2815 | (gnus-check-backend-function | |
2816 | 'request-expire-articles gnus-newsgroup-name)] | |
2817 | ["Edit local kill file" gnus-summary-edit-local-kill t] | |
2818 | ["Edit main kill file" gnus-summary-edit-global-kill t] | |
2819 | ["Edit group parameters" gnus-summary-edit-parameters t] | |
2820 | ["Customize group parameters" gnus-summary-customize-parameters t] | |
2821 | ["Send a bug report" gnus-bug t] | |
2822 | ("Exit" | |
2823 | ["Catchup and exit" gnus-summary-catchup-and-exit | |
2824 | ,@(if (featurep 'xemacs) '(t) | |
2825 | '(:help "Mark unread articles in this group as read, then exit"))] | |
2826 | ["Catchup all and exit" gnus-summary-catchup-all-and-exit t] | |
2827 | ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t] | |
01c52d31 | 2828 | ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t] |
23f87bed MB |
2829 | ["Exit group" gnus-summary-exit |
2830 | ,@(if (featurep 'xemacs) '(t) | |
2831 | '(:help "Exit current group, return to group selection mode"))] | |
2832 | ["Exit group without updating" gnus-summary-exit-no-update t] | |
2833 | ["Exit and goto next group" gnus-summary-next-group t] | |
2834 | ["Exit and goto prev group" gnus-summary-prev-group t] | |
2835 | ["Reselect group" gnus-summary-reselect-current-group t] | |
2836 | ["Rescan group" gnus-summary-rescan-group t] | |
2837 | ["Update dribble" gnus-summary-save-newsrc t]))) | |
eec82323 | 2838 | |
6748645f | 2839 | (gnus-run-hooks 'gnus-summary-menu-hook))) |
eec82323 | 2840 | |
60bd5589 DL |
2841 | (defvar gnus-summary-tool-bar-map nil) |
2842 | ||
18c06a99 RS |
2843 | ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only |
2844 | ;; affect _new_ message buffers. We might add a function that walks thru all | |
2845 | ;; summary-mode buffers and force the update. | |
2846 | (defun gnus-summary-tool-bar-update (&optional symbol value) | |
2847 | "Update summary mode toolbar. | |
2848 | Setter function for custom variables." | |
2849 | (setq-default gnus-summary-tool-bar-map nil) | |
2850 | (when symbol | |
2851 | ;; When used as ":set" function: | |
2852 | (set-default symbol value)) | |
2853 | (when (gnus-buffer-live-p gnus-summary-buffer) | |
2854 | (with-current-buffer gnus-summary-buffer | |
2855 | (gnus-summary-make-tool-bar)))) | |
2856 | ||
2857 | (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome) | |
2858 | 'gnus-summary-tool-bar-gnome | |
2859 | 'gnus-summary-tool-bar-retro) | |
2860 | "Specifies the Gnus summary tool bar. | |
2861 | ||
fac916bf | 2862 | It can be either a list or a symbol referring to a list. See |
18c06a99 RS |
2863 | `gmm-tool-bar-from-list' for the format of the list. The |
2864 | default key map is `gnus-summary-mode-map'. | |
2865 | ||
2866 | Pre-defined symbols include `gnus-summary-tool-bar-gnome' and | |
2867 | `gnus-summary-tool-bar-retro'." | |
2868 | :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome) | |
2869 | (const :tag "Retro look" gnus-summary-tool-bar-retro) | |
2870 | (repeat :tag "User defined list" gmm-tool-bar-item) | |
2871 | (symbol)) | |
330f707b | 2872 | :version "23.1" ;; No Gnus |
18c06a99 RS |
2873 | :initialize 'custom-initialize-default |
2874 | :set 'gnus-summary-tool-bar-update | |
2875 | :group 'gnus-summary) | |
2876 | ||
2877 | (defcustom gnus-summary-tool-bar-gnome | |
2878 | '((gnus-summary-post-news "mail/compose" nil) | |
2879 | (gnus-summary-insert-new-articles "mail/inbox" nil | |
2880 | :visible (or (not gnus-agent) | |
2881 | gnus-plugged)) | |
2882 | (gnus-summary-reply-with-original "mail/reply") | |
2883 | (gnus-summary-reply "mail/reply" nil :visible nil) | |
2884 | (gnus-summary-followup-with-original "mail/reply-all") | |
2885 | (gnus-summary-followup "mail/reply-all" nil :visible nil) | |
2886 | (gnus-summary-mail-forward "mail/forward") | |
2887 | (gnus-summary-save-article "mail/save") | |
2888 | (gnus-summary-search-article-forward "search" nil :visible nil) | |
2889 | (gnus-summary-print-article "print") | |
2890 | (gnus-summary-tick-article-forward "flag-followup" nil :visible nil) | |
2891 | ;; Some new commands that may need more suitable icons: | |
2892 | (gnus-summary-save-newsrc "save" nil :visible nil) | |
2893 | ;; (gnus-summary-show-article "stock_message-display" nil :visible nil) | |
2894 | (gnus-summary-prev-article "left-arrow") | |
2895 | (gnus-summary-next-article "right-arrow") | |
2896 | (gnus-summary-next-page "next-page") | |
2897 | ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil) | |
2898 | ;; | |
2899 | ;; Maybe some sort-by-... could be added: | |
2900 | ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil) | |
2901 | ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil) | |
2902 | (gnus-summary-mark-as-expirable | |
2903 | "delete" nil | |
2904 | :visible (gnus-check-backend-function 'request-expire-articles | |
2905 | gnus-newsgroup-name)) | |
2906 | (gnus-summary-mark-as-spam | |
2907 | "mail/spam" t | |
2908 | :visible (and (fboundp 'spam-group-ham-contents-p) | |
2909 | (spam-group-ham-contents-p gnus-newsgroup-name)) | |
2910 | :help "Mark as spam") | |
2911 | (gnus-summary-mark-as-read-forward | |
2912 | "mail/not-spam" nil | |
2913 | :visible (and (fboundp 'spam-group-spam-contents-p) | |
2914 | (spam-group-spam-contents-p gnus-newsgroup-name))) | |
2915 | ;; | |
2916 | (gnus-summary-exit "exit") | |
2917 | (gmm-customize-mode "preferences" t :help "Edit mode preferences") | |
2918 | (gnus-info-find-node "help")) | |
2919 | "List of functions for the summary tool bar (GNOME style). | |
2920 | ||
2921 | See `gmm-tool-bar-from-list' for the format of the list." | |
2922 | :type '(repeat gmm-tool-bar-item) | |
330f707b | 2923 | :version "23.1" ;; No Gnus |
18c06a99 RS |
2924 | :initialize 'custom-initialize-default |
2925 | :set 'gnus-summary-tool-bar-update | |
2926 | :group 'gnus-summary) | |
2927 | ||
2928 | (defcustom gnus-summary-tool-bar-retro | |
2929 | '((gnus-summary-prev-unread-article "gnus/prev-ur") | |
2930 | (gnus-summary-next-unread-article "gnus/next-ur") | |
2931 | (gnus-summary-post-news "gnus/post") | |
2932 | (gnus-summary-followup-with-original "gnus/fuwo") | |
2933 | (gnus-summary-followup "gnus/followup") | |
2934 | (gnus-summary-reply-with-original "gnus/reply-wo") | |
2935 | (gnus-summary-reply "gnus/reply") | |
2936 | (gnus-summary-caesar-message "gnus/rot13") | |
2937 | (gnus-uu-decode-uu "gnus/uu-decode") | |
2938 | (gnus-summary-save-article-file "gnus/save-aif") | |
2939 | (gnus-summary-save-article "gnus/save-art") | |
2940 | (gnus-uu-post-news "gnus/uu-post") | |
2941 | (gnus-summary-catchup "gnus/catchup") | |
2942 | (gnus-summary-catchup-and-exit "gnus/cu-exit") | |
2943 | (gnus-summary-exit "gnus/exit-summ") | |
2944 | ;; Some new command that may need more suitable icons: | |
2945 | (gnus-summary-print-article "gnus/print" nil :visible nil) | |
2946 | (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil) | |
2947 | (gnus-summary-save-newsrc "gnus/save" nil :visible nil) | |
2948 | ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil) | |
2949 | (gnus-summary-search-article-forward "gnus/search" nil :visible nil) | |
2950 | ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil) | |
2951 | ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil) | |
2952 | ;; | |
2953 | (gnus-info-find-node "gnus/help" nil :visible nil)) | |
2954 | "List of functions for the summary tool bar (retro look). | |
2955 | ||
2956 | See `gmm-tool-bar-from-list' for the format of the list." | |
2957 | :type '(repeat gmm-tool-bar-item) | |
330f707b | 2958 | :version "23.1" ;; No Gnus |
18c06a99 RS |
2959 | :initialize 'custom-initialize-default |
2960 | :set 'gnus-summary-tool-bar-update | |
2961 | :group 'gnus-summary) | |
2962 | ||
2963 | (defcustom gnus-summary-tool-bar-zap-list t | |
2964 | "List of icon items from the global tool bar. | |
2965 | These items are not displayed in the Gnus summary mode tool bar. | |
2966 | ||
2967 | See `gmm-tool-bar-from-list' for the format of the list." | |
2968 | :type 'gmm-tool-bar-zap-list | |
330f707b | 2969 | :version "23.1" ;; No Gnus |
18c06a99 RS |
2970 | :initialize 'custom-initialize-default |
2971 | :set 'gnus-summary-tool-bar-update | |
2972 | :group 'gnus-summary) | |
2973 | ||
2974 | (defvar image-load-path) | |
f654fa04 | 2975 | (defvar tool-bar-map) |
18c06a99 RS |
2976 | |
2977 | (defun gnus-summary-make-tool-bar (&optional force) | |
2978 | "Make a summary mode tool bar from `gnus-summary-tool-bar'. | |
2979 | When FORCE, rebuild the tool bar." | |
2980 | (when (and (not (featurep 'xemacs)) | |
2981 | (boundp 'tool-bar-mode) | |
2982 | tool-bar-mode | |
2983 | (or (not gnus-summary-tool-bar-map) force)) | |
2984 | (let* ((load-path | |
2985 | (gmm-image-load-path-for-library "gnus" | |
2986 | "mail/save.xpm" | |
2987 | nil t)) | |
2988 | (image-load-path (cons (car load-path) | |
2989 | (when (boundp 'image-load-path) | |
2990 | image-load-path))) | |
2991 | (map (gmm-tool-bar-from-list gnus-summary-tool-bar | |
2992 | gnus-summary-tool-bar-zap-list | |
2993 | 'gnus-summary-mode-map))) | |
2994 | (when map | |
2995 | ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode' | |
a98edce9 | 2996 | ;; uses its value. |
18c06a99 RS |
2997 | (setq gnus-summary-tool-bar-map map)))) |
2998 | (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)) | |
60bd5589 | 2999 | |
eec82323 LMI |
3000 | (defun gnus-make-score-map (type) |
3001 | "Make a summary score map of type TYPE." | |
3002 | (if t | |
3003 | nil | |
3004 | (let ((headers '(("author" "from" string) | |
3005 | ("subject" "subject" string) | |
3006 | ("article body" "body" string) | |
3007 | ("article head" "head" string) | |
3008 | ("xref" "xref" string) | |
16409b0b | 3009 | ("extra header" "extra" string) |
eec82323 LMI |
3010 | ("lines" "lines" number) |
3011 | ("followups to author" "followup" string))) | |
3012 | (types '((number ("less than" <) | |
3013 | ("greater than" >) | |
3014 | ("equal" =)) | |
3015 | (string ("substring" s) | |
3016 | ("exact string" e) | |
3017 | ("fuzzy string" f) | |
3018 | ("regexp" r)))) | |
3019 | (perms '(("temporary" (current-time-string)) | |
3020 | ("permanent" nil) | |
3021 | ("immediate" now))) | |
3022 | header) | |
3023 | (list | |
3024 | (apply | |
3025 | 'nconc | |
3026 | (list | |
3027 | (if (eq type 'lower) | |
3028 | "Lower score" | |
3029 | "Increase score")) | |
3030 | (let (outh) | |
3031 | (while headers | |
3032 | (setq header (car headers)) | |
3033 | (setq outh | |
3034 | (cons | |
3035 | (apply | |
3036 | 'nconc | |
3037 | (list (car header)) | |
3038 | (let ((ts (cdr (assoc (nth 2 header) types))) | |
3039 | outt) | |
3040 | (while ts | |
3041 | (setq outt | |
3042 | (cons | |
3043 | (apply | |
3044 | 'nconc | |
3045 | (list (caar ts)) | |
3046 | (let ((ps perms) | |
3047 | outp) | |
3048 | (while ps | |
3049 | (setq outp | |
3050 | (cons | |
3051 | (vector | |
3052 | (caar ps) | |
3053 | (list | |
3054 | 'gnus-summary-score-entry | |
3055 | (nth 1 header) | |
3056 | (if (or (string= (nth 1 header) | |
3057 | "head") | |
3058 | (string= (nth 1 header) | |
3059 | "body")) | |
3060 | "" | |
3061 | (list 'gnus-summary-header | |
3062 | (nth 1 header))) | |
3063 | (list 'quote (nth 1 (car ts))) | |
16409b0b GM |
3064 | (list 'gnus-score-delta-default |
3065 | nil) | |
eec82323 LMI |
3066 | (nth 1 (car ps)) |
3067 | t) | |
3068 | t) | |
3069 | outp)) | |
3070 | (setq ps (cdr ps))) | |
3071 | (list (nreverse outp)))) | |
3072 | outt)) | |
3073 | (setq ts (cdr ts))) | |
3074 | (list (nreverse outt)))) | |
3075 | outh)) | |
3076 | (setq headers (cdr headers))) | |
3077 | (list (nreverse outh)))))))) | |
3078 | ||
704f1663 GM |
3079 | |
3080 | (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ()) | |
398a825b | 3081 | (defvar bookmark-make-record-function) |
eec82323 | 3082 | \f |
97c0d1ac | 3083 | (defvar bidi-paragraph-direction) |
eec82323 LMI |
3084 | |
3085 | (defun gnus-summary-mode (&optional group) | |
3086 | "Major mode for reading articles. | |
3087 | ||
3088 | All normal editing commands are switched off. | |
3089 | \\<gnus-summary-mode-map> | |
3090 | Each line in this buffer represents one article. To read an | |
3091 | article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards | |
3092 | and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]', | |
3093 | respectively. | |
3094 | ||
3095 | You can also post articles and send mail from this buffer. To | |
23f87bed | 3096 | follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author |
eec82323 LMI |
3097 | of an article, type `\\[gnus-summary-reply]'. |
3098 | ||
3099 | There are approx. one gazillion commands you can execute in this | |
3100 | buffer; read the info pages for more information (`\\[gnus-info-find-node]'). | |
3101 | ||
3102 | The following commands are available: | |
3103 | ||
3104 | \\{gnus-summary-mode-map}" | |
c2e9e9ef | 3105 | ;; FIXME: Use define-derived-mode. |
eec82323 | 3106 | (interactive) |
eec82323 | 3107 | (kill-all-local-variables) |
01c52d31 MB |
3108 | (let ((gnus-summary-local-variables gnus-newsgroup-variables)) |
3109 | (gnus-summary-make-local-variables)) | |
3110 | (gnus-summary-make-local-variables) | |
3111 | (setq gnus-newsgroup-name group) | |
60bd5589 DL |
3112 | (when (gnus-visual-p 'summary-menu 'menu) |
3113 | (gnus-summary-make-menu-bar) | |
3114 | (gnus-summary-make-tool-bar)) | |
eec82323 LMI |
3115 | (gnus-make-thread-indent-array) |
3116 | (gnus-simplify-mode-line) | |
3117 | (setq major-mode 'gnus-summary-mode) | |
3118 | (setq mode-name "Summary") | |
eec82323 | 3119 | (use-local-map gnus-summary-mode-map) |
16409b0b | 3120 | (buffer-disable-undo) |
01c52d31 MB |
3121 | (setq buffer-read-only t ;Disable modification |
3122 | show-trailing-whitespace nil) | |
eec82323 | 3123 | (setq truncate-lines t) |
f4887f8b | 3124 | ;; Force paragraph direction to be left-to-right. Don't make it |
367a344f | 3125 | ;; bound globally in old Emacsen and XEmacsen. |
f4887f8b | 3126 | (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right) |
9bfd9a76 | 3127 | (add-to-invisibility-spec '(gnus-sum . t)) |
eec82323 LMI |
3128 | (gnus-summary-set-display-table) |
3129 | (gnus-set-default-directory) | |
eec82323 LMI |
3130 | (make-local-variable 'gnus-summary-line-format) |
3131 | (make-local-variable 'gnus-summary-line-format-spec) | |
6748645f LMI |
3132 | (make-local-variable 'gnus-summary-dummy-line-format) |
3133 | (make-local-variable 'gnus-summary-dummy-line-format-spec) | |
eec82323 | 3134 | (make-local-variable 'gnus-summary-mark-positions) |
23f87bed | 3135 | (gnus-make-local-hook 'pre-command-hook) |
6748645f | 3136 | (add-hook 'pre-command-hook 'gnus-set-global-variables nil t) |
cfcd5c91 | 3137 | (gnus-run-mode-hooks 'gnus-summary-mode-hook) |
23f87bed | 3138 | (turn-on-gnus-mailing-list-mode) |
87545352 | 3139 | (mm-enable-multibyte) |
45be326a TV |
3140 | (set (make-local-variable 'bookmark-make-record-function) |
3141 | 'gnus-summary-bookmark-make-record) | |
eec82323 LMI |
3142 | (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy) |
3143 | (gnus-update-summary-mark-positions)) | |
3144 | ||
3145 | (defun gnus-summary-make-local-variables () | |
3146 | "Make all the local summary buffer variables." | |
16409b0b GM |
3147 | (let (global) |
3148 | (dolist (local gnus-summary-local-variables) | |
eec82323 LMI |
3149 | (if (consp local) |
3150 | (progn | |
3151 | (if (eq (cdr local) 'global) | |
3152 | ;; Copy the global value of the variable. | |
3153 | (setq global (symbol-value (car local))) | |
3154 | ;; Use the value from the list. | |
3155 | (setq global (eval (cdr local)))) | |
16409b0b | 3156 | (set (make-local-variable (car local)) global)) |
eec82323 | 3157 | ;; Simple nil-valued local variable. |
16409b0b | 3158 | (set (make-local-variable local) nil))))) |
eec82323 | 3159 | |
eec82323 LMI |
3160 | ;; Summary data functions. |
3161 | ||
3162 | (defmacro gnus-data-number (data) | |
3163 | `(car ,data)) | |
3164 | ||
3165 | (defmacro gnus-data-set-number (data number) | |
3166 | `(setcar ,data ,number)) | |
3167 | ||
3168 | (defmacro gnus-data-mark (data) | |
3169 | `(nth 1 ,data)) | |
3170 | ||
3171 | (defmacro gnus-data-set-mark (data mark) | |
3172 | `(setcar (nthcdr 1 ,data) ,mark)) | |
3173 | ||
3174 | (defmacro gnus-data-pos (data) | |
3175 | `(nth 2 ,data)) | |
3176 | ||
3177 | (defmacro gnus-data-set-pos (data pos) | |
3178 | `(setcar (nthcdr 2 ,data) ,pos)) | |
3179 | ||
3180 | (defmacro gnus-data-header (data) | |
3181 | `(nth 3 ,data)) | |
3182 | ||
3183 | (defmacro gnus-data-set-header (data header) | |
3184 | `(setf (nth 3 ,data) ,header)) | |
3185 | ||
3186 | (defmacro gnus-data-level (data) | |
3187 | `(nth 4 ,data)) | |
3188 | ||
3189 | (defmacro gnus-data-unread-p (data) | |
3190 | `(= (nth 1 ,data) gnus-unread-mark)) | |
3191 | ||
3192 | (defmacro gnus-data-read-p (data) | |
3193 | `(/= (nth 1 ,data) gnus-unread-mark)) | |
3194 | ||
3195 | (defmacro gnus-data-pseudo-p (data) | |
3196 | `(consp (nth 3 ,data))) | |
3197 | ||
3198 | (defmacro gnus-data-find (number) | |
3199 | `(assq ,number gnus-newsgroup-data)) | |
3200 | ||
3201 | (defmacro gnus-data-find-list (number &optional data) | |
3202 | `(let ((bdata ,(or data 'gnus-newsgroup-data))) | |
3203 | (memq (assq ,number bdata) | |
3204 | bdata))) | |
3205 | ||
3206 | (defmacro gnus-data-make (number mark pos header level) | |
3207 | `(list ,number ,mark ,pos ,header ,level)) | |
3208 | ||
3209 | (defun gnus-data-enter (after-article number mark pos header level offset) | |
3210 | (let ((data (gnus-data-find-list after-article))) | |
3211 | (unless data | |
3212 | (error "No such article: %d" after-article)) | |
3213 | (setcdr data (cons (gnus-data-make number mark pos header level) | |
3214 | (cdr data))) | |
3215 | (setq gnus-newsgroup-data-reverse nil) | |
3216 | (gnus-data-update-list (cddr data) offset))) | |
3217 | ||
3218 | (defun gnus-data-enter-list (after-article list &optional offset) | |
3219 | (when list | |
3220 | (let ((data (and after-article (gnus-data-find-list after-article))) | |
3221 | (ilist list)) | |
6748645f LMI |
3222 | (if (not (or data |
3223 | after-article)) | |
3224 | (let ((odata gnus-newsgroup-data)) | |
3225 | (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data)) | |
eec82323 | 3226 | (when offset |
6748645f | 3227 | (gnus-data-update-list odata offset))) |
01c52d31 | 3228 | ;; Find the last element in the list to be spliced into the main |
6748645f | 3229 | ;; list. |
01c52d31 | 3230 | (setq list (last list)) |
6748645f LMI |
3231 | (if (not data) |
3232 | (progn | |
3233 | (setcdr list gnus-newsgroup-data) | |
3234 | (setq gnus-newsgroup-data ilist) | |
3235 | (when offset | |
3236 | (gnus-data-update-list (cdr list) offset))) | |
3237 | (setcdr list (cdr data)) | |
3238 | (setcdr data ilist) | |
3239 | (when offset | |
3240 | (gnus-data-update-list (cdr list) offset)))) | |
eec82323 LMI |
3241 | (setq gnus-newsgroup-data-reverse nil)))) |
3242 | ||
3243 | (defun gnus-data-remove (article &optional offset) | |
3244 | (let ((data gnus-newsgroup-data)) | |
3245 | (if (= (gnus-data-number (car data)) article) | |
3246 | (progn | |
3247 | (setq gnus-newsgroup-data (cdr gnus-newsgroup-data) | |
3248 | gnus-newsgroup-data-reverse nil) | |
3249 | (when offset | |
3250 | (gnus-data-update-list gnus-newsgroup-data offset))) | |
3251 | (while (cdr data) | |
3252 | (when (= (gnus-data-number (cadr data)) article) | |
3253 | (setcdr data (cddr data)) | |
3254 | (when offset | |
3255 | (gnus-data-update-list (cdr data) offset)) | |
3256 | (setq data nil | |
3257 | gnus-newsgroup-data-reverse nil)) | |
3258 | (setq data (cdr data)))))) | |
3259 | ||
3260 | (defmacro gnus-data-list (backward) | |
3261 | `(if ,backward | |
3262 | (or gnus-newsgroup-data-reverse | |
3263 | (setq gnus-newsgroup-data-reverse | |
3264 | (reverse gnus-newsgroup-data))) | |
3265 | gnus-newsgroup-data)) | |
3266 | ||
3267 | (defun gnus-data-update-list (data offset) | |
3268 | "Add OFFSET to the POS of all data entries in DATA." | |
6748645f | 3269 | (setq gnus-newsgroup-data-reverse nil) |
eec82323 LMI |
3270 | (while data |
3271 | (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data)))) | |
3272 | (setq data (cdr data)))) | |
3273 | ||
eec82323 LMI |
3274 | (defun gnus-summary-article-pseudo-p (article) |
3275 | "Say whether this article is a pseudo article or not." | |
3276 | (not (vectorp (gnus-data-header (gnus-data-find article))))) | |
3277 | ||
3278 | (defmacro gnus-summary-article-sparse-p (article) | |
3279 | "Say whether this article is a sparse article or not." | |
a8151ef7 | 3280 | `(memq ,article gnus-newsgroup-sparse)) |
eec82323 LMI |
3281 | |
3282 | (defmacro gnus-summary-article-ancient-p (article) | |
3283 | "Say whether this article is a sparse article or not." | |
3284 | `(memq ,article gnus-newsgroup-ancient)) | |
3285 | ||
eec82323 LMI |
3286 | (defun gnus-article-children (number) |
3287 | "Return a list of all children to NUMBER." | |
3288 | (let* ((data (gnus-data-find-list number)) | |
3289 | (level (gnus-data-level (car data))) | |
3290 | children) | |
3291 | (setq data (cdr data)) | |
3292 | (while (and data | |
3293 | (= (gnus-data-level (car data)) (1+ level))) | |
3294 | (push (gnus-data-number (car data)) children) | |
3295 | (setq data (cdr data))) | |
3296 | children)) | |
3297 | ||
3298 | (defmacro gnus-summary-skip-intangible () | |
3299 | "If the current article is intangible, then jump to a different article." | |
3300 | '(let ((to (get-text-property (point) 'gnus-intangible))) | |
3301 | (and to (gnus-summary-goto-subject to)))) | |
3302 | ||
3303 | (defmacro gnus-summary-article-intangible-p () | |
3304 | "Say whether this article is intangible or not." | |
3305 | '(get-text-property (point) 'gnus-intangible)) | |
3306 | ||
eec82323 LMI |
3307 | ;; Some summary mode macros. |
3308 | ||
3309 | (defmacro gnus-summary-article-number () | |
3310 | "The article number of the article on the current line. | |
8f688cb0 | 3311 | If there isn't an article number here, then we return the current |
eec82323 LMI |
3312 | article number." |
3313 | '(progn | |
3314 | (gnus-summary-skip-intangible) | |
3315 | (or (get-text-property (point) 'gnus-number) | |
3316 | (gnus-summary-last-subject)))) | |
3317 | ||
3318 | (defmacro gnus-summary-article-header (&optional number) | |
6748645f | 3319 | "Return the header of article NUMBER." |
eec82323 LMI |
3320 | `(gnus-data-header (gnus-data-find |
3321 | ,(or number '(gnus-summary-article-number))))) | |
3322 | ||
3323 | (defmacro gnus-summary-thread-level (&optional number) | |
6748645f | 3324 | "Return the level of thread that starts with article NUMBER." |
eec82323 LMI |
3325 | `(if (and (eq gnus-summary-make-false-root 'dummy) |
3326 | (get-text-property (point) 'gnus-intangible)) | |
3327 | 0 | |
3328 | (gnus-data-level (gnus-data-find | |
3329 | ,(or number '(gnus-summary-article-number)))))) | |
3330 | ||
3331 | (defmacro gnus-summary-article-mark (&optional number) | |
6748645f | 3332 | "Return the mark of article NUMBER." |
eec82323 LMI |
3333 | `(gnus-data-mark (gnus-data-find |
3334 | ,(or number '(gnus-summary-article-number))))) | |
3335 | ||
3336 | (defmacro gnus-summary-article-pos (&optional number) | |
6748645f | 3337 | "Return the position of the line of article NUMBER." |
eec82323 LMI |
3338 | `(gnus-data-pos (gnus-data-find |
3339 | ,(or number '(gnus-summary-article-number))))) | |
3340 | ||
3341 | (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject) | |
3342 | (defmacro gnus-summary-article-subject (&optional number) | |
3343 | "Return current subject string or nil if nothing." | |
3344 | `(let ((headers | |
3345 | ,(if number | |
3346 | `(gnus-data-header (assq ,number gnus-newsgroup-data)) | |
3347 | '(gnus-data-header (assq (gnus-summary-article-number) | |
3348 | gnus-newsgroup-data))))) | |
3349 | (and headers | |
3350 | (vectorp headers) | |
3351 | (mail-header-subject headers)))) | |
3352 | ||
3353 | (defmacro gnus-summary-article-score (&optional number) | |
3354 | "Return current article score." | |
3355 | `(or (cdr (assq ,(or number '(gnus-summary-article-number)) | |
3356 | gnus-newsgroup-scored)) | |
3357 | gnus-summary-default-score 0)) | |
3358 | ||
3359 | (defun gnus-summary-article-children (&optional number) | |
6748645f | 3360 | "Return a list of article numbers that are children of article NUMBER." |
eec82323 LMI |
3361 | (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)))) |
3362 | (level (gnus-data-level (car data))) | |
3363 | l children) | |
3364 | (while (and (setq data (cdr data)) | |
3365 | (> (setq l (gnus-data-level (car data))) level)) | |
3366 | (and (= (1+ level) l) | |
3367 | (push (gnus-data-number (car data)) | |
3368 | children))) | |
3369 | (nreverse children))) | |
3370 | ||
3371 | (defun gnus-summary-article-parent (&optional number) | |
6748645f | 3372 | "Return the article number of the parent of article NUMBER." |
eec82323 LMI |
3373 | (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number)) |
3374 | (gnus-data-list t))) | |
3375 | (level (gnus-data-level (car data)))) | |
3376 | (if (zerop level) | |
3377 | () ; This is a root. | |
3378 | ;; We search until we find an article with a level less than | |
3379 | ;; this one. That function has to be the parent. | |
3380 | (while (and (setq data (cdr data)) | |
3381 | (not (< (gnus-data-level (car data)) level)))) | |
3382 | (and data (gnus-data-number (car data)))))) | |
3383 | ||
3384 | (defun gnus-unread-mark-p (mark) | |
3385 | "Say whether MARK is the unread mark." | |
3386 | (= mark gnus-unread-mark)) | |
3387 | ||
3388 | (defun gnus-read-mark-p (mark) | |
3389 | "Say whether MARK is one of the marks that mark as read. | |
3390 | This is all marks except unread, ticked, dormant, and expirable." | |
3391 | (not (or (= mark gnus-unread-mark) | |
3392 | (= mark gnus-ticked-mark) | |
23f87bed | 3393 | (= mark gnus-spam-mark) |
eec82323 LMI |
3394 | (= mark gnus-dormant-mark) |
3395 | (= mark gnus-expirable-mark)))) | |
3396 | ||
3397 | (defmacro gnus-article-mark (number) | |
6748645f LMI |
3398 | "Return the MARK of article NUMBER. |
3399 | This macro should only be used when computing the mark the \"first\" | |
3400 | time; i.e., when generating the summary lines. After that, | |
3401 | `gnus-summary-article-mark' should be used to examine the | |
3402 | marks of articles." | |
eec82323 | 3403 | `(cond |
6748645f | 3404 | ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark) |
6748645f | 3405 | ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark) |
eec82323 LMI |
3406 | ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark) |
3407 | ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark) | |
23f87bed | 3408 | ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark) |
eec82323 LMI |
3409 | ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark) |
3410 | ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark) | |
3411 | (t (or (cdr (assq ,number gnus-newsgroup-reads)) | |
3412 | gnus-ancient-mark)))) | |
3413 | ||
3414 | ;; Saving hidden threads. | |
3415 | ||
eec82323 LMI |
3416 | (defmacro gnus-save-hidden-threads (&rest forms) |
3417 | "Save hidden threads, eval FORMS, and restore the hidden threads." | |
3418 | (let ((config (make-symbol "config"))) | |
3419 | `(let ((,config (gnus-hidden-threads-configuration))) | |
3420 | (unwind-protect | |
3421 | (save-excursion | |
3422 | ,@forms) | |
3423 | (gnus-restore-hidden-threads-configuration ,config))))) | |
23f87bed MB |
3424 | (put 'gnus-save-hidden-threads 'lisp-indent-function 0) |
3425 | (put 'gnus-save-hidden-threads 'edebug-form-spec '(body)) | |
eec82323 | 3426 | |
107ecebb AS |
3427 | (defun gnus-data-compute-positions () |
3428 | "Compute the positions of all articles." | |
3429 | (setq gnus-newsgroup-data-reverse nil) | |
3430 | (let ((data gnus-newsgroup-data)) | |
3431 | (save-excursion | |
3432 | (gnus-save-hidden-threads | |
3433 | (gnus-summary-show-all-threads) | |
3434 | (goto-char (point-min)) | |
3435 | (while data | |
3436 | (while (get-text-property (point) 'gnus-intangible) | |
3437 | (forward-line 1)) | |
3438 | (gnus-data-set-pos (car data) (+ (point) 3)) | |
3439 | (setq data (cdr data)) | |
3440 | (forward-line 1)))))) | |
3441 | ||
16409b0b GM |
3442 | (defun gnus-hidden-threads-configuration () |
3443 | "Return the current hidden threads configuration." | |
3444 | (save-excursion | |
3445 | (let (config) | |
3446 | (goto-char (point-min)) | |
62a83cc8 KY |
3447 | (while (not (eobp)) |
3448 | (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum) | |
3449 | (push (save-excursion (forward-line 0) (point)) config)) | |
3450 | (forward-line 1)) | |
16409b0b GM |
3451 | config))) |
3452 | ||
3453 | (defun gnus-restore-hidden-threads-configuration (config) | |
3454 | "Restore hidden threads configuration from CONFIG." | |
3455 | (save-excursion | |
c7a91ce1 | 3456 | (let (point (inhibit-read-only t)) |
16409b0b | 3457 | (while (setq point (pop config)) |
62a83cc8 KY |
3458 | (goto-char point) |
3459 | (gnus-summary-hide-thread))))) | |
16409b0b | 3460 | |
eec82323 LMI |
3461 | ;; Various summary mode internalish functions. |
3462 | ||
3463 | (defun gnus-mouse-pick-article (e) | |
3464 | (interactive "e") | |
3465 | (mouse-set-point e) | |
3466 | (gnus-summary-next-page nil t)) | |
3467 | ||
3468 | (defun gnus-summary-set-display-table () | |
16409b0b GM |
3469 | "Change the display table. |
3470 | Odd characters have a tendency to mess | |
3471 | up nicely formatted displays - we make all possible glyphs | |
3472 | display only a single character." | |
eec82323 LMI |
3473 | |
3474 | ;; We start from the standard display table, if any. | |
3475 | (let ((table (or (copy-sequence standard-display-table) | |
3476 | (make-display-table))) | |
3477 | (i 32)) | |
3478 | ;; Nix out all the control chars... | |
3479 | (while (>= (setq i (1- i)) 0) | |
2b968687 | 3480 | (gnus-put-display-table i [??] table)) |
23f87bed | 3481 | ;; ... but not newline and cr, of course. (cr is necessary for the |
eec82323 | 3482 | ;; selective display). |
2b968687 MB |
3483 | (gnus-put-display-table ?\n nil table) |
3484 | (gnus-put-display-table ?\r nil table) | |
6748645f | 3485 | ;; We keep TAB as well. |
2b968687 | 3486 | (gnus-put-display-table ?\t nil table) |
719120ef | 3487 | ;; We nix out any glyphs 127 through 255, or 127 through 159 in |
fe62aacc | 3488 | ;; Emacs 23 (unicode), that are not set already. |
719120ef MB |
3489 | (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160)) |
3490 | 160 | |
3491 | 256))) | |
eec82323 LMI |
3492 | (while (>= (setq i (1- i)) 127) |
3493 | ;; Only modify if the entry is nil. | |
2b968687 MB |
3494 | (unless (gnus-get-display-table i table) |
3495 | (gnus-put-display-table i [??] table)))) | |
eec82323 LMI |
3496 | (setq buffer-display-table table))) |
3497 | ||
23f87bed MB |
3498 | (defun gnus-summary-set-article-display-arrow (pos) |
3499 | "Update the overlay arrow to point to line at position POS." | |
e3e955fe MB |
3500 | (when gnus-summary-display-arrow |
3501 | (make-local-variable 'overlay-arrow-position) | |
3502 | (make-local-variable 'overlay-arrow-string) | |
23f87bed MB |
3503 | (save-excursion |
3504 | (goto-char pos) | |
3505 | (beginning-of-line) | |
3506 | (unless overlay-arrow-position | |
3507 | (setq overlay-arrow-position (make-marker))) | |
3508 | (setq overlay-arrow-string "=>" | |
3509 | overlay-arrow-position (set-marker overlay-arrow-position | |
3510 | (point) | |
3511 | (current-buffer)))))) | |
3512 | ||
eec82323 | 3513 | (defun gnus-summary-setup-buffer (group) |
a363cbed LMI |
3514 | "Initialize summary buffer. |
3515 | If the setup was successful, non-nil is returned." | |
23f87bed MB |
3516 | (let ((buffer (gnus-summary-buffer-name group)) |
3517 | (dead-name (concat "*Dead Summary " | |
3518 | (gnus-group-decoded-name group) "*"))) | |
3519 | ;; If a dead summary buffer exists, we kill it. | |
3520 | (when (gnus-buffer-live-p dead-name) | |
3521 | (gnus-kill-buffer dead-name)) | |
eec82323 LMI |
3522 | (if (get-buffer buffer) |
3523 | (progn | |
3524 | (set-buffer buffer) | |
3525 | (setq gnus-summary-buffer (current-buffer)) | |
3526 | (not gnus-newsgroup-prepared)) | |
cc21c235 G |
3527 | (set-buffer (gnus-get-buffer-create buffer)) |
3528 | (setq gnus-summary-buffer (current-buffer)) | |
eec82323 | 3529 | (gnus-summary-mode group) |
01c52d31 MB |
3530 | (when (gnus-group-quit-config group) |
3531 | (set (make-local-variable 'gnus-single-article-buffer) nil)) | |
3532 | (make-local-variable 'gnus-article-buffer) | |
3533 | (make-local-variable 'gnus-article-current) | |
3534 | (make-local-variable 'gnus-original-article-buffer) | |
eec82323 | 3535 | (setq gnus-newsgroup-name group) |
23f87bed MB |
3536 | ;; Set any local variables in the group parameters. |
3537 | (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
eec82323 LMI |
3538 | t))) |
3539 | ||
3540 | (defun gnus-set-global-variables () | |
16409b0b GM |
3541 | "Set the global equivalents of the buffer-local variables. |
3542 | They are set to the latest values they had. These reflect the summary | |
3543 | buffer that was in action when the last article was fetched." | |
c2e9e9ef | 3544 | (when (derived-mode-p 'gnus-summary-mode) |
eec82323 LMI |
3545 | (setq gnus-summary-buffer (current-buffer)) |
3546 | (let ((name gnus-newsgroup-name) | |
3547 | (marked gnus-newsgroup-marked) | |
23f87bed | 3548 | (spam gnus-newsgroup-spam-marked) |
eec82323 LMI |
3549 | (unread gnus-newsgroup-unreads) |
3550 | (headers gnus-current-headers) | |
3551 | (data gnus-newsgroup-data) | |
3552 | (summary gnus-summary-buffer) | |
3553 | (article-buffer gnus-article-buffer) | |
3554 | (original gnus-original-article-buffer) | |
3555 | (gac gnus-article-current) | |
3556 | (reffed gnus-reffed-article-number) | |
16409b0b | 3557 | (score-file gnus-current-score-file) |
23f87bed MB |
3558 | (default-charset gnus-newsgroup-charset) |
3559 | vlist) | |
3560 | (let ((locals gnus-newsgroup-variables)) | |
3561 | (while locals | |
3562 | (if (consp (car locals)) | |
3563 | (push (eval (caar locals)) vlist) | |
3564 | (push (eval (car locals)) vlist)) | |
3565 | (setq locals (cdr locals))) | |
3566 | (setq vlist (nreverse vlist))) | |
89b163db | 3567 | (with-temp-buffer |
6748645f LMI |
3568 | (setq gnus-newsgroup-name name |
3569 | gnus-newsgroup-marked marked | |
23f87bed | 3570 | gnus-newsgroup-spam-marked spam |
6748645f LMI |
3571 | gnus-newsgroup-unreads unread |
3572 | gnus-current-headers headers | |
3573 | gnus-newsgroup-data data | |
3574 | gnus-article-current gac | |
3575 | gnus-summary-buffer summary | |
3576 | gnus-article-buffer article-buffer | |
3577 | gnus-original-article-buffer original | |
3578 | gnus-reffed-article-number reffed | |
16409b0b GM |
3579 | gnus-current-score-file score-file |
3580 | gnus-newsgroup-charset default-charset) | |
23f87bed MB |
3581 | (let ((locals gnus-newsgroup-variables)) |
3582 | (while locals | |
3583 | (if (consp (car locals)) | |
3584 | (set (caar locals) (pop vlist)) | |
3585 | (set (car locals) (pop vlist))) | |
cc21c235 | 3586 | (setq locals (cdr locals)))))))) |
eec82323 LMI |
3587 | |
3588 | (defun gnus-summary-article-unread-p (article) | |
3589 | "Say whether ARTICLE is unread or not." | |
3590 | (memq article gnus-newsgroup-unreads)) | |
3591 | ||
3592 | (defun gnus-summary-first-article-p (&optional article) | |
3593 | "Return whether ARTICLE is the first article in the buffer." | |
3594 | (if (not (setq article (or article (gnus-summary-article-number)))) | |
3595 | nil | |
3596 | (eq article (caar gnus-newsgroup-data)))) | |
3597 | ||
3598 | (defun gnus-summary-last-article-p (&optional article) | |
3599 | "Return whether ARTICLE is the last article in the buffer." | |
3600 | (if (not (setq article (or article (gnus-summary-article-number)))) | |
16409b0b GM |
3601 | ;; All non-existent numbers are the last article. :-) |
3602 | t | |
eec82323 LMI |
3603 | (not (cdr (gnus-data-find-list article))))) |
3604 | ||
4921bbdd CY |
3605 | (defun gnus-make-thread-indent-array (&optional n) |
3606 | (when (or n | |
3607 | (progn (setq n 200) nil) | |
3608 | (null gnus-thread-indent-array) | |
3609 | (/= gnus-thread-indent-level gnus-thread-indent-array-level)) | |
3610 | (setq gnus-thread-indent-array (make-vector (1+ n) "") | |
3611 | gnus-thread-indent-array-level gnus-thread-indent-level) | |
3612 | (while (>= n 0) | |
3613 | (aset gnus-thread-indent-array n | |
6a30c01d | 3614 | (make-string (* n gnus-thread-indent-level) ? )) |
4921bbdd | 3615 | (setq n (1- n))))) |
eec82323 LMI |
3616 | |
3617 | (defun gnus-update-summary-mark-positions () | |
3618 | "Compute where the summary marks are to go." | |
3619 | (save-excursion | |
6748645f | 3620 | (when (gnus-buffer-exists-p gnus-summary-buffer) |
eec82323 | 3621 | (set-buffer gnus-summary-buffer)) |
5153a47a MB |
3622 | (let ((spec gnus-summary-line-format-spec) |
3623 | pos) | |
eec82323 LMI |
3624 | (save-excursion |
3625 | (gnus-set-work-buffer) | |
5153a47a MB |
3626 | (let ((gnus-tmp-unread ?Z) |
3627 | (gnus-replied-mark ?Z) | |
3628 | (gnus-score-below-mark ?Z) | |
3629 | (gnus-score-over-mark ?Z) | |
3630 | (gnus-undownloaded-mark ?Z) | |
3631 | (gnus-summary-line-format-spec spec) | |
54506618 | 3632 | (gnus-newsgroup-downloadable '(0)) |
5153a47a MB |
3633 | (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]) |
3634 | case-fold-search ignores) | |
3635 | ;; Here, all marks are bound to Z. | |
3636 | (gnus-summary-insert-line header | |
3637 | 0 nil t gnus-tmp-unread t nil "" nil 1) | |
3638 | (goto-char (point-min)) | |
3639 | ;; Memorize the positions of the same characters as dummy marks. | |
3640 | (while (re-search-forward "[A-D]" nil t) | |
3641 | (push (point) ignores)) | |
54506618 | 3642 | (erase-buffer) |
5153a47a MB |
3643 | ;; We use A-D as dummy marks in order to know column positions |
3644 | ;; where marks should be inserted. | |
3645 | (setq gnus-tmp-unread ?A | |
3646 | gnus-replied-mark ?B | |
3647 | gnus-score-below-mark ?C | |
3648 | gnus-score-over-mark ?C | |
3649 | gnus-undownloaded-mark ?D) | |
3650 | (gnus-summary-insert-line header | |
3651 | 0 nil t gnus-tmp-unread t nil "" nil 1) | |
3652 | ;; Ignore characters which aren't dummy marks. | |
3653 | (dolist (p ignores) | |
3654 | (delete-region (goto-char (1- p)) p) | |
3655 | (insert ?Z)) | |
eec82323 | 3656 | (goto-char (point-min)) |
7c3bb5a5 | 3657 | (setq pos (list (cons 'unread |
5153a47a | 3658 | (and (search-forward "A" nil t) |
7c3bb5a5 | 3659 | (- (point) (point-min) 1))))) |
eec82323 | 3660 | (goto-char (point-min)) |
5153a47a | 3661 | (push (cons 'replied (and (search-forward "B" nil t) |
667e0ba6 | 3662 | (- (point) (point-min) 1))) |
eec82323 LMI |
3663 | pos) |
3664 | (goto-char (point-min)) | |
5153a47a | 3665 | (push (cons 'score (and (search-forward "C" nil t) |
667e0ba6 | 3666 | (- (point) (point-min) 1))) |
6748645f LMI |
3667 | pos) |
3668 | (goto-char (point-min)) | |
5153a47a | 3669 | (push (cons 'download (and (search-forward "D" nil t) |
7c3bb5a5 | 3670 | (- (point) (point-min) 1))) |
eec82323 LMI |
3671 | pos))) |
3672 | (setq gnus-summary-mark-positions pos)))) | |
3673 | ||
3674 | (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number) | |
3675 | "Insert a dummy root in the summary buffer." | |
3676 | (beginning-of-line) | |
3677 | (gnus-add-text-properties | |
3678 | (point) (progn (eval gnus-summary-dummy-line-format-spec) (point)) | |
3679 | (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number))) | |
3680 | ||
23f87bed MB |
3681 | (defun gnus-summary-extract-address-component (from) |
3682 | (or (car (funcall gnus-extract-address-components from)) | |
3683 | from)) | |
3684 | ||
527769f7 | 3685 | (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from) |
23f87bed | 3686 | (let ((mail-parse-charset gnus-newsgroup-charset) |
527769f7 KY |
3687 | (ignored-from-addresses (gnus-ignored-from-addresses)) |
3688 | ;; Is it really necessary to do this next part for each summary line? | |
3689 | ;; Luckily, doesn't seem to slow things down much. | |
3690 | (mail-parse-ignored-charsets | |
3691 | (with-current-buffer gnus-summary-buffer | |
3692 | gnus-newsgroup-ignored-charsets))) | |
23f87bed | 3693 | (or |
01c52d31 | 3694 | (and ignored-from-addresses |
527769f7 | 3695 | (string-match ignored-from-addresses gnus-tmp-from) |
23f87bed MB |
3696 | (let ((extra-headers (mail-header-extra header)) |
3697 | to | |
3698 | newsgroups) | |
3699 | (cond | |
3700 | ((setq to (cdr (assq 'To extra-headers))) | |
01c52d31 | 3701 | (concat gnus-summary-to-prefix |
23f87bed MB |
3702 | (inline |
3703 | (gnus-summary-extract-address-component | |
343d6628 | 3704 | (funcall gnus-decode-encoded-address-function to))))) |
01c52d31 MB |
3705 | ((setq newsgroups |
3706 | (or | |
3707 | (cdr (assq 'Newsgroups extra-headers)) | |
3708 | (and | |
3709 | (memq 'Newsgroups gnus-extra-headers) | |
527769f7 KY |
3710 | (eq (car (gnus-find-method-for-group |
3711 | gnus-newsgroup-name)) 'nntp) | |
01c52d31 MB |
3712 | (gnus-group-real-name gnus-newsgroup-name)))) |
3713 | (concat gnus-summary-newsgroup-prefix newsgroups))))) | |
527769f7 KY |
3714 | (gnus-string-mark-left-to-right |
3715 | (inline | |
3716 | (gnus-summary-extract-address-component gnus-tmp-from)))))) | |
16409b0b | 3717 | |
eec82323 LMI |
3718 | (defun gnus-summary-insert-line (gnus-tmp-header |
3719 | gnus-tmp-level gnus-tmp-current | |
23f87bed | 3720 | undownloaded gnus-tmp-unread gnus-tmp-replied |
eec82323 LMI |
3721 | gnus-tmp-expirable gnus-tmp-subject-or-nil |
3722 | &optional gnus-tmp-dummy gnus-tmp-score | |
3723 | gnus-tmp-process) | |
4921bbdd CY |
3724 | (if (>= gnus-tmp-level (length gnus-thread-indent-array)) |
3725 | (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array)) | |
3726 | gnus-tmp-level))) | |
eec82323 LMI |
3727 | (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) |
3728 | (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) | |
3729 | (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) | |
3730 | (gnus-tmp-score-char | |
3731 | (if (or (null gnus-summary-default-score) | |
3732 | (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
3733 | gnus-summary-zcore-fuzz)) | |
23f87bed | 3734 | ? ;Whitespace |
eec82323 LMI |
3735 | (if (< gnus-tmp-score gnus-summary-default-score) |
3736 | gnus-score-below-mark gnus-score-over-mark))) | |
23f87bed | 3737 | (gnus-tmp-number (mail-header-number gnus-tmp-header)) |
eec82323 LMI |
3738 | (gnus-tmp-replied |
3739 | (cond (gnus-tmp-process gnus-process-mark) | |
3740 | ((memq gnus-tmp-current gnus-newsgroup-cached) | |
3741 | gnus-cached-mark) | |
3742 | (gnus-tmp-replied gnus-replied-mark) | |
23f87bed MB |
3743 | ((memq gnus-tmp-current gnus-newsgroup-forwarded) |
3744 | gnus-forwarded-mark) | |
eec82323 LMI |
3745 | ((memq gnus-tmp-current gnus-newsgroup-saved) |
3746 | gnus-saved-mark) | |
23f87bed MB |
3747 | ((memq gnus-tmp-number gnus-newsgroup-unseen) |
3748 | gnus-unseen-mark) | |
3749 | (t gnus-no-mark))) | |
3750 | (gnus-tmp-downloaded | |
3751 | (cond (undownloaded | |
3752 | gnus-undownloaded-mark) | |
3753 | (gnus-newsgroup-agentized | |
3754 | gnus-downloaded-mark) | |
3755 | (t | |
3756 | gnus-no-mark))) | |
eec82323 LMI |
3757 | (gnus-tmp-from (mail-header-from gnus-tmp-header)) |
3758 | (gnus-tmp-name | |
3759 | (cond | |
3760 | ((string-match "<[^>]+> *$" gnus-tmp-from) | |
3761 | (let ((beg (match-beginning 0))) | |
23f87bed MB |
3762 | (or (and (string-match "^\".+\"" gnus-tmp-from) |
3763 | (substring gnus-tmp-from 1 (1- (match-end 0)))) | |
eec82323 LMI |
3764 | (substring gnus-tmp-from 0 beg)))) |
3765 | ((string-match "(.+)" gnus-tmp-from) | |
3766 | (substring gnus-tmp-from | |
3767 | (1+ (match-beginning 0)) (1- (match-end 0)))) | |
3768 | (t gnus-tmp-from))) | |
3769 | (gnus-tmp-subject (mail-header-subject gnus-tmp-header)) | |
eec82323 LMI |
3770 | (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[)) |
3771 | (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\])) | |
c7a91ce1 | 3772 | (inhibit-read-only t)) |
eec82323 LMI |
3773 | (when (string= gnus-tmp-name "") |
3774 | (setq gnus-tmp-name gnus-tmp-from)) | |
3775 | (unless (numberp gnus-tmp-lines) | |
23f87bed MB |
3776 | (setq gnus-tmp-lines -1)) |
3777 | (if (= gnus-tmp-lines -1) | |
3778 | (setq gnus-tmp-lines "?") | |
3779 | (setq gnus-tmp-lines (number-to-string gnus-tmp-lines))) | |
64763fe3 MB |
3780 | (condition-case () |
3781 | (gnus-put-text-property | |
3782 | (point) | |
3783 | (progn (eval gnus-summary-line-format-spec) (point)) | |
3784 | 'gnus-number gnus-tmp-number) | |
3785 | (error (gnus-message 5 "Error updating the summary line"))) | |
eec82323 LMI |
3786 | (when (gnus-visual-p 'summary-highlight 'highlight) |
3787 | (forward-line -1) | |
a9ec34f4 | 3788 | (gnus-summary-highlight-line) |
6748645f | 3789 | (gnus-run-hooks 'gnus-summary-update-hook) |
eec82323 LMI |
3790 | (forward-line 1)))) |
3791 | ||
3792 | (defun gnus-summary-update-line (&optional dont-update) | |
16409b0b | 3793 | "Update summary line after change." |
eec82323 LMI |
3794 | (when (and gnus-summary-default-score |
3795 | (not gnus-summary-inhibit-highlight)) | |
3796 | (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion. | |
3797 | (article (gnus-summary-article-number)) | |
3798 | (score (gnus-summary-article-score article))) | |
3799 | (unless dont-update | |
3800 | (if (and gnus-summary-mark-below | |
3801 | (< (gnus-summary-article-score) | |
3802 | gnus-summary-mark-below)) | |
3803 | ;; This article has a low score, so we mark it as read. | |
3804 | (when (memq article gnus-newsgroup-unreads) | |
3805 | (gnus-summary-mark-article-as-read gnus-low-score-mark)) | |
3806 | (when (eq (gnus-summary-article-mark) gnus-low-score-mark) | |
3807 | ;; This article was previously marked as read on account | |
3808 | ;; of a low score, but now it has risen, so we mark it as | |
3809 | ;; unread. | |
3810 | (gnus-summary-mark-article-as-unread gnus-unread-mark))) | |
3811 | (gnus-summary-update-mark | |
3812 | (if (or (null gnus-summary-default-score) | |
3813 | (<= (abs (- score gnus-summary-default-score)) | |
3814 | gnus-summary-zcore-fuzz)) | |
23f87bed | 3815 | ? ;Whitespace |
eec82323 LMI |
3816 | (if (< score gnus-summary-default-score) |
3817 | gnus-score-below-mark gnus-score-over-mark)) | |
3818 | 'score)) | |
3819 | ;; Do visual highlighting. | |
3820 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
a9ec34f4 | 3821 | (gnus-summary-highlight-line) |
6748645f | 3822 | (gnus-run-hooks 'gnus-summary-update-hook))))) |
eec82323 LMI |
3823 | |
3824 | (defvar gnus-tmp-new-adopts nil) | |
3825 | ||
3826 | (defun gnus-summary-number-of-articles-in-thread (thread &optional level char) | |
3827 | "Return the number of articles in THREAD. | |
3828 | This may be 0 in some cases -- if none of the articles in | |
3829 | the thread are to be displayed." | |
3830 | (let* ((number | |
23f87bed | 3831 | ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>. |
eec82323 LMI |
3832 | (cond |
3833 | ((not (listp thread)) | |
3834 | 1) | |
3835 | ((and (consp thread) (cdr thread)) | |
3836 | (apply | |
3837 | '+ 1 (mapcar | |
3838 | 'gnus-summary-number-of-articles-in-thread (cdr thread)))) | |
3839 | ((null thread) | |
3840 | 1) | |
3841 | ((memq (mail-header-number (car thread)) gnus-newsgroup-limit) | |
3842 | 1) | |
3843 | (t 0)))) | |
3844 | (when (and level (zerop level) gnus-tmp-new-adopts) | |
3845 | (incf number | |
3846 | (apply '+ (mapcar | |
3847 | 'gnus-summary-number-of-articles-in-thread | |
3848 | gnus-tmp-new-adopts)))) | |
3849 | (if char | |
3850 | (if (> number 1) gnus-not-empty-thread-mark | |
3851 | gnus-empty-thread-mark) | |
3852 | number))) | |
3853 | ||
23f87bed MB |
3854 | (defsubst gnus-summary-line-message-size (head) |
3855 | "Return pretty-printed version of message size. | |
3856 | This function is intended to be used in | |
3857 | `gnus-summary-line-format-alist'." | |
3858 | (let ((c (or (mail-header-chars head) -1))) | |
3859 | (cond ((< c 0) "n/a") ; chars not available | |
3860 | ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0))) | |
3861 | ((< c (* 1000 100)) (format "%dk" (/ c 1024.0))) | |
3862 | ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024)))) | |
3863 | (t (format "%dM" (/ c (* 1024.0 1024))))))) | |
3864 | ||
4a3988d5 | 3865 | (defcustom gnus-user-date-format-alist |
0d1c2cc8 G |
3866 | '(((gnus-seconds-today) . "Today, %H:%M") |
3867 | ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M") | |
3868 | (604800 . "%A %H:%M") ; That's one week | |
3869 | ((gnus-seconds-month) . "%A %d") | |
3870 | ((gnus-seconds-year) . "%B %d") | |
3871 | (t . "%b %d %Y")) ; This one is used when no other | |
3872 | ; does match | |
3873 | "Specifies date format depending on age of article. | |
3874 | This is an alist of items (AGE . FORMAT). AGE can be a number (of | |
3875 | seconds) or a Lisp expression evaluating to a number. When the age of | |
3876 | the article is less than this number, then use `format-time-string' | |
3877 | with the corresponding FORMAT for displaying the date of the article. | |
3878 | If AGE is not a number or a Lisp expression evaluating to a | |
3879 | non-number, then the corresponding FORMAT is used as a default value. | |
3880 | ||
3881 | Note that the list is processed from the beginning, so it should be | |
3882 | sorted by ascending AGE. Also note that items following the first | |
3883 | non-number AGE will be ignored. | |
3884 | ||
3885 | You can use the functions `gnus-seconds-today', `gnus-seconds-month' | |
3886 | and `gnus-seconds-year' in the AGE spec. They return the number of | |
3887 | seconds passed since the start of today, of this month, of this year, | |
3888 | respectively." | |
3889 | :version "24.1" | |
3890 | :group 'gnus-summary-format | |
3891 | :type '(alist :key-type sexp :value-type string)) | |
0d1c2cc8 | 3892 | |
ec72bf63 | 3893 | (defun gnus-user-date (messy-date) |
4a3988d5 | 3894 | "Format the messy-date according to `gnus-user-date-format-alist'. |
0d1c2cc8 G |
3895 | Returns \" ? \" if there's bad input or if another error occurs. |
3896 | Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"." | |
3897 | (condition-case () | |
3898 | (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date))) | |
3899 | (now (gnus-float-time)) | |
3900 | ;;If we don't find something suitable we'll use this one | |
3901 | (my-format "%b %d '%y")) | |
3902 | (let* ((difference (- now messy-date)) | |
4a3988d5 | 3903 | (templist gnus-user-date-format-alist) |
0d1c2cc8 G |
3904 | (top (eval (caar templist)))) |
3905 | (while (if (numberp top) (< top difference) (not top)) | |
3906 | (progn | |
3907 | (setq templist (cdr templist)) | |
3908 | (setq top (eval (caar templist))))) | |
3909 | (if (stringp (cdr (car templist))) | |
3910 | (setq my-format (cdr (car templist))))) | |
3911 | (format-time-string (eval my-format) (seconds-to-time messy-date))) | |
3912 | (error " ? "))) | |
23f87bed | 3913 | |
eec82323 LMI |
3914 | (defun gnus-summary-set-local-parameters (group) |
3915 | "Go through the local params of GROUP and set all variable specs in that list." | |
dab0271f G |
3916 | (let ((vars '(quit-config active))) ; Ignore things that aren't |
3917 | ; really variables. | |
01c52d31 | 3918 | (dolist (elem (gnus-group-find-parameter group)) |
eec82323 LMI |
3919 | (and (consp elem) ; Has to be a cons. |
3920 | (consp (cdr elem)) ; The cdr has to be a list. | |
3921 | (symbolp (car elem)) ; Has to be a symbol in there. | |
23f87bed | 3922 | (not (memq (car elem) vars)) |
e3e955fe | 3923 | (ignore-errors |
23f87bed | 3924 | (push (car elem) vars) |
e3e955fe MB |
3925 | ;; Variables like `gnus-show-threads' that are globally |
3926 | ;; bound, if used as group parameters, need to get to be | |
3927 | ;; buffer-local, whereas just parameters like `gcc-self', | |
3928 | ;; `timestamp', etc. should not be bound as variables. | |
3929 | (if (boundp (car elem)) | |
3930 | (set (make-local-variable (car elem)) (eval (nth 1 elem))) | |
3931 | (eval (nth 1 elem)))))))) | |
eec82323 LMI |
3932 | |
3933 | (defun gnus-summary-read-group (group &optional show-all no-article | |
6748645f LMI |
3934 | kill-buffer no-display backward |
3935 | select-articles) | |
eec82323 LMI |
3936 | "Start reading news in newsgroup GROUP. |
3937 | If SHOW-ALL is non-nil, already read articles are also listed. | |
3938 | If NO-ARTICLE is non-nil, no article is selected initially. | |
a363cbed LMI |
3939 | If NO-DISPLAY, don't generate the summary buffer contents. |
3940 | If KILL-BUFFER, it should be a buffer that's killed once the new | |
3941 | summary buffer has been generated. | |
3942 | If BACKWARD, move point to the previous group in the group buffer | |
3943 | If SELECT-ARTICLES, only select those articles from GROUP." | |
eec82323 LMI |
3944 | (let (result) |
3945 | (while (and group | |
3946 | (null (setq result | |
3947 | (let ((gnus-auto-select-next nil)) | |
6748645f LMI |
3948 | (or (gnus-summary-read-group-1 |
3949 | group show-all no-article | |
3950 | kill-buffer no-display | |
3951 | select-articles) | |
3952 | (setq show-all nil | |
16409b0b | 3953 | select-articles nil))))) |
eec82323 LMI |
3954 | (eq gnus-auto-select-next 'quietly)) |
3955 | (set-buffer gnus-group-buffer) | |
6748645f LMI |
3956 | ;; The entry function called above goes to the next |
3957 | ;; group automatically, so we go two groups back | |
3958 | ;; if we are searching for the previous group. | |
3959 | (when backward | |
3960 | (gnus-group-prev-unread-group 2)) | |
eec82323 LMI |
3961 | (if (not (equal group (gnus-group-group-name))) |
3962 | (setq group (gnus-group-group-name)) | |
3963 | (setq group nil))) | |
3964 | result)) | |
3965 | ||
3966 | (defun gnus-summary-read-group-1 (group show-all no-article | |
6748645f LMI |
3967 | kill-buffer no-display |
3968 | &optional select-articles) | |
eec82323 | 3969 | ;; Killed foreign groups can't be entered. |
23f87bed MB |
3970 | ;; (when (and (not (gnus-group-native-p group)) |
3971 | ;; (not (gnus-gethash group gnus-newsrc-hashtb))) | |
3972 | ;; (error "Dead non-native groups can't be entered")) | |
7985478f | 3973 | (gnus-message 7 "Retrieving newsgroup: %s..." |
23f87bed | 3974 | (gnus-group-decoded-name group)) |
eec82323 LMI |
3975 | (let* ((new-group (gnus-summary-setup-buffer group)) |
3976 | (quit-config (gnus-group-quit-config group)) | |
6748645f LMI |
3977 | (did-select (and new-group (gnus-select-newsgroup |
3978 | group show-all select-articles)))) | |
eec82323 LMI |
3979 | (cond |
3980 | ;; This summary buffer exists already, so we just select it. | |
3981 | ((not new-group) | |
3982 | (gnus-set-global-variables) | |
3983 | (when kill-buffer | |
3984 | (gnus-kill-or-deaden-summary kill-buffer)) | |
3985 | (gnus-configure-windows 'summary 'force) | |
3986 | (gnus-set-mode-line 'summary) | |
3987 | (gnus-summary-position-point) | |
3988 | (message "") | |
3989 | t) | |
3990 | ;; We couldn't select this group. | |
3991 | ((null did-select) | |
c2e9e9ef | 3992 | (when (and (derived-mode-p 'gnus-summary-mode) |
eec82323 LMI |
3993 | (not (equal (current-buffer) kill-buffer))) |
3994 | (kill-buffer (current-buffer)) | |
3995 | (if (not quit-config) | |
3996 | (progn | |
6748645f LMI |
3997 | ;; Update the info -- marks might need to be removed, |
3998 | ;; for instance. | |
3999 | (gnus-summary-update-info) | |
eec82323 LMI |
4000 | (set-buffer gnus-group-buffer) |
4001 | (gnus-group-jump-to-group group) | |
4002 | (gnus-group-next-unread-group 1)) | |
4003 | (gnus-handle-ephemeral-exit quit-config))) | |
8937ef6e LI |
4004 | (if (null (gnus-list-of-unread-articles group)) |
4005 | (gnus-message 3 "Group %s contains no messages" group) | |
4006 | (gnus-message 3 "Can't select group")) | |
eec82323 LMI |
4007 | nil) |
4008 | ;; The user did a `C-g' while prompting for number of articles, | |
4009 | ;; so we exit this group. | |
4010 | ((eq did-select 'quit) | |
c2e9e9ef | 4011 | (and (derived-mode-p 'gnus-summary-mode) |
eec82323 LMI |
4012 | (not (equal (current-buffer) kill-buffer)) |
4013 | (kill-buffer (current-buffer))) | |
4014 | (when kill-buffer | |
4015 | (gnus-kill-or-deaden-summary kill-buffer)) | |
4016 | (if (not quit-config) | |
4017 | (progn | |
4018 | (set-buffer gnus-group-buffer) | |
4019 | (gnus-group-jump-to-group group) | |
eec82323 LMI |
4020 | (gnus-configure-windows 'group 'force)) |
4021 | (gnus-handle-ephemeral-exit quit-config)) | |
4022 | ;; Finally signal the quit. | |
4023 | (signal 'quit nil)) | |
4024 | ;; The group was successfully selected. | |
4025 | (t | |
4026 | (gnus-set-global-variables) | |
4e2b87d8 G |
4027 | (when (boundp 'spam-install-hooks) |
4028 | (spam-initialize)) | |
eec82323 LMI |
4029 | ;; Save the active value in effect when the group was entered. |
4030 | (setq gnus-newsgroup-active | |
4031 | (gnus-copy-sequence | |
4032 | (gnus-active gnus-newsgroup-name))) | |
9f2d52e7 | 4033 | (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active)) |
eec82323 | 4034 | ;; You can change the summary buffer in some way with this hook. |
6748645f | 4035 | (gnus-run-hooks 'gnus-select-group-hook) |
5153a47a MB |
4036 | (when (memq 'summary (gnus-update-format-specifications |
4037 | nil 'summary 'summary-mode 'summary-dummy)) | |
4038 | ;; The format specification for the summary line was updated, | |
4039 | ;; so we need to update the mark positions as well. | |
4040 | (gnus-update-summary-mark-positions)) | |
eec82323 LMI |
4041 | ;; Do score processing. |
4042 | (when gnus-use-scoring | |
4043 | (gnus-possibly-score-headers)) | |
4044 | ;; Check whether to fill in the gaps in the threads. | |
4045 | (when gnus-build-sparse-threads | |
4046 | (gnus-build-sparse-threads)) | |
4047 | ;; Find the initial limit. | |
26c9afc3 MB |
4048 | (if show-all |
4049 | (let ((gnus-newsgroup-dormant nil)) | |
eec82323 | 4050 | (gnus-summary-initial-limit show-all)) |
26c9afc3 | 4051 | (gnus-summary-initial-limit show-all)) |
eec82323 LMI |
4052 | ;; Generate the summary buffer. |
4053 | (unless no-display | |
4054 | (gnus-summary-prepare)) | |
4055 | (when gnus-use-trees | |
c2e9e9ef | 4056 | (gnus-tree-open) |
eec82323 LMI |
4057 | (setq gnus-summary-highlight-line-function |
4058 | 'gnus-tree-highlight-article)) | |
4059 | ;; If the summary buffer is empty, but there are some low-scored | |
4060 | ;; articles or some excluded dormants, we include these in the | |
4061 | ;; buffer. | |
4062 | (when (and (zerop (buffer-size)) | |
4063 | (not no-display)) | |
4064 | (cond (gnus-newsgroup-dormant | |
4065 | (gnus-summary-limit-include-dormant)) | |
4066 | ((and gnus-newsgroup-scored show-all) | |
4067 | (gnus-summary-limit-include-expunged t)))) | |
4068 | ;; Function `gnus-apply-kill-file' must be called in this hook. | |
6748645f | 4069 | (gnus-run-hooks 'gnus-apply-kill-hook) |
eec82323 LMI |
4070 | (if (and (zerop (buffer-size)) |
4071 | (not no-display)) | |
4072 | (progn | |
4073 | ;; This newsgroup is empty. | |
4074 | (gnus-summary-catchup-and-exit nil t) | |
4075 | (gnus-message 6 "No unread news") | |
4076 | (when kill-buffer | |
4077 | (gnus-kill-or-deaden-summary kill-buffer)) | |
4078 | ;; Return nil from this function. | |
4079 | nil) | |
4080 | ;; Hide conversation thread subtrees. We cannot do this in | |
4081 | ;; gnus-summary-prepare-hook since kill processing may not | |
4082 | ;; work with hidden articles. | |
23f87bed | 4083 | (gnus-summary-maybe-hide-threads) |
5415d076 | 4084 | (gnus-configure-windows 'summary) |
6748645f LMI |
4085 | (when kill-buffer |
4086 | (gnus-kill-or-deaden-summary kill-buffer)) | |
23f87bed | 4087 | (gnus-summary-auto-select-subject) |
eec82323 LMI |
4088 | ;; Show first unread article if requested. |
4089 | (if (and (not no-article) | |
4090 | (not no-display) | |
4091 | gnus-newsgroup-unreads | |
4092 | gnus-auto-select-first) | |
16409b0b | 4093 | (progn |
23f87bed | 4094 | (let ((art (gnus-summary-article-number))) |
bb677ef7 LMI |
4095 | (when (and art |
4096 | gnus-plugged | |
4097 | (not (memq art gnus-newsgroup-undownloaded)) | |
4098 | (not (memq art gnus-newsgroup-downloadable))) | |
23f87bed MB |
4099 | (gnus-summary-goto-article art)))) |
4100 | ;; Don't select any articles. | |
eec82323 | 4101 | (gnus-summary-position-point) |
6748645f LMI |
4102 | (gnus-configure-windows 'summary 'force) |
4103 | (gnus-set-mode-line 'summary)) | |
23f87bed MB |
4104 | (when (and gnus-auto-center-group |
4105 | (get-buffer-window gnus-group-buffer t)) | |
eec82323 LMI |
4106 | ;; Gotta use windows, because recenter does weird stuff if |
4107 | ;; the current buffer ain't the displayed window. | |
4108 | (let ((owin (selected-window))) | |
4109 | (select-window (get-buffer-window gnus-group-buffer t)) | |
4110 | (when (gnus-group-goto-group group) | |
4111 | (recenter)) | |
4112 | (select-window owin))) | |
4113 | ;; Mark this buffer as "prepared". | |
4114 | (setq gnus-newsgroup-prepared t) | |
6748645f | 4115 | (gnus-run-hooks 'gnus-summary-prepared-hook) |
23f87bed | 4116 | (unless (gnus-ephemeral-group-p group) |
b229f37d | 4117 | (gnus-group-update-group group nil t)) |
eec82323 LMI |
4118 | t))))) |
4119 | ||
23f87bed MB |
4120 | (defun gnus-summary-auto-select-subject () |
4121 | "Select the subject line on initial group entry." | |
4122 | (goto-char (point-min)) | |
4123 | (cond | |
4124 | ((eq gnus-auto-select-subject 'best) | |
4125 | (gnus-summary-best-unread-subject)) | |
4126 | ((eq gnus-auto-select-subject 'unread) | |
4127 | (gnus-summary-first-unread-subject)) | |
4128 | ((eq gnus-auto-select-subject 'unseen) | |
4129 | (gnus-summary-first-unseen-subject)) | |
4130 | ((eq gnus-auto-select-subject 'unseen-or-unread) | |
4131 | (gnus-summary-first-unseen-or-unread-subject)) | |
4132 | ((eq gnus-auto-select-subject 'first) | |
4133 | ;; Do nothing. | |
4134 | ) | |
4135 | ((functionp gnus-auto-select-subject) | |
4136 | (funcall gnus-auto-select-subject)))) | |
4137 | ||
eec82323 LMI |
4138 | (defun gnus-summary-prepare () |
4139 | "Generate the summary buffer." | |
4140 | (interactive) | |
c7a91ce1 | 4141 | (let ((inhibit-read-only t)) |
eec82323 LMI |
4142 | (erase-buffer) |
4143 | (setq gnus-newsgroup-data nil | |
4144 | gnus-newsgroup-data-reverse nil) | |
6748645f | 4145 | (gnus-run-hooks 'gnus-summary-generate-hook) |
eec82323 LMI |
4146 | ;; Generate the buffer, either with threads or without. |
4147 | (when gnus-newsgroup-headers | |
4148 | (gnus-summary-prepare-threads | |
4149 | (if gnus-show-threads | |
4150 | (gnus-sort-gathered-threads | |
4151 | (funcall gnus-summary-thread-gathering-function | |
4152 | (gnus-sort-threads | |
4153 | (gnus-cut-threads (gnus-make-threads))))) | |
4154 | ;; Unthreaded display. | |
4155 | (gnus-sort-articles gnus-newsgroup-headers)))) | |
4156 | (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data)) | |
4157 | ;; Call hooks for modifying summary buffer. | |
4158 | (goto-char (point-min)) | |
6748645f | 4159 | (gnus-run-hooks 'gnus-summary-prepare-hook))) |
eec82323 LMI |
4160 | |
4161 | (defsubst gnus-general-simplify-subject (subject) | |
23f87bed | 4162 | "Simplify subject by the same rules as `gnus-gather-threads-by-subject'." |
eec82323 LMI |
4163 | (setq subject |
4164 | (cond | |
4165 | ;; Truncate the subject. | |
6748645f LMI |
4166 | (gnus-simplify-subject-functions |
4167 | (gnus-map-function gnus-simplify-subject-functions subject)) | |
eec82323 LMI |
4168 | ((numberp gnus-summary-gather-subject-limit) |
4169 | (setq subject (gnus-simplify-subject-re subject)) | |
4170 | (if (> (length subject) gnus-summary-gather-subject-limit) | |
4171 | (substring subject 0 gnus-summary-gather-subject-limit) | |
4172 | subject)) | |
4173 | ;; Fuzzily simplify it. | |
4174 | ((eq 'fuzzy gnus-summary-gather-subject-limit) | |
4175 | (gnus-simplify-subject-fuzzy subject)) | |
4176 | ;; Just remove the leading "Re:". | |
4177 | (t | |
4178 | (gnus-simplify-subject-re subject)))) | |
4179 | ||
4180 | (if (and gnus-summary-gather-exclude-subject | |
4181 | (string-match gnus-summary-gather-exclude-subject subject)) | |
23f87bed | 4182 | nil ; This article shouldn't be gathered |
eec82323 LMI |
4183 | subject)) |
4184 | ||
4185 | (defun gnus-summary-simplify-subject-query () | |
4186 | "Query where the respool algorithm would put this article." | |
4187 | (interactive) | |
eec82323 | 4188 | (gnus-summary-select-article) |
274f1353 | 4189 | (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject)))) |
eec82323 LMI |
4190 | |
4191 | (defun gnus-gather-threads-by-subject (threads) | |
4192 | "Gather threads by looking at Subject headers." | |
4193 | (if (not gnus-summary-make-false-root) | |
4194 | threads | |
4195 | (let ((hashtb (gnus-make-hashtable 1024)) | |
4196 | (prev threads) | |
4197 | (result threads) | |
4198 | subject hthread whole-subject) | |
4199 | (while threads | |
4200 | (setq subject (gnus-general-simplify-subject | |
4201 | (setq whole-subject (mail-header-subject | |
4202 | (caar threads))))) | |
4203 | (when subject | |
4204 | (if (setq hthread (gnus-gethash subject hashtb)) | |
4205 | (progn | |
4206 | ;; We enter a dummy root into the thread, if we | |
4207 | ;; haven't done that already. | |
4208 | (unless (stringp (caar hthread)) | |
4209 | (setcar hthread (list whole-subject (car hthread)))) | |
4210 | ;; We add this new gathered thread to this gathered | |
4211 | ;; thread. | |
4212 | (setcdr (car hthread) | |
4213 | (nconc (cdar hthread) (list (car threads)))) | |
4214 | ;; Remove it from the list of threads. | |
4215 | (setcdr prev (cdr threads)) | |
4216 | (setq threads prev)) | |
4217 | ;; Enter this thread into the hash table. | |
23f87bed MB |
4218 | (gnus-sethash subject |
4219 | (if gnus-summary-make-false-root-always | |
4220 | (progn | |
4221 | ;; If you want a dummy root above all | |
4222 | ;; threads... | |
4223 | (setcar threads (list whole-subject | |
4224 | (car threads))) | |
4225 | threads) | |
4226 | threads) | |
4227 | hashtb))) | |
eec82323 LMI |
4228 | (setq prev threads) |
4229 | (setq threads (cdr threads))) | |
4230 | result))) | |
4231 | ||
4232 | (defun gnus-gather-threads-by-references (threads) | |
4233 | "Gather threads by looking at References headers." | |
4234 | (let ((idhashtb (gnus-make-hashtable 1024)) | |
4235 | (thhashtb (gnus-make-hashtable 1024)) | |
4236 | (prev threads) | |
4237 | (result threads) | |
4238 | ids references id gthread gid entered ref) | |
4239 | (while threads | |
4240 | (when (setq references (mail-header-references (caar threads))) | |
4241 | (setq id (mail-header-id (caar threads)) | |
23f87bed | 4242 | ids (inline (gnus-split-references references)) |
eec82323 LMI |
4243 | entered nil) |
4244 | (while (setq ref (pop ids)) | |
4245 | (setq ids (delete ref ids)) | |
4246 | (if (not (setq gid (gnus-gethash ref idhashtb))) | |
4247 | (progn | |
4248 | (gnus-sethash ref id idhashtb) | |
4249 | (gnus-sethash id threads thhashtb)) | |
4250 | (setq gthread (gnus-gethash gid thhashtb)) | |
4251 | (unless entered | |
4252 | ;; We enter a dummy root into the thread, if we | |
4253 | ;; haven't done that already. | |
4254 | (unless (stringp (caar gthread)) | |
4255 | (setcar gthread (list (mail-header-subject (caar gthread)) | |
4256 | (car gthread)))) | |
4257 | ;; We add this new gathered thread to this gathered | |
4258 | ;; thread. | |
4259 | (setcdr (car gthread) | |
4260 | (nconc (cdar gthread) (list (car threads))))) | |
4261 | ;; Add it into the thread hash table. | |
4262 | (gnus-sethash id gthread thhashtb) | |
4263 | (setq entered t) | |
4264 | ;; Remove it from the list of threads. | |
4265 | (setcdr prev (cdr threads)) | |
4266 | (setq threads prev)))) | |
4267 | (setq prev threads) | |
4268 | (setq threads (cdr threads))) | |
4269 | result)) | |
4270 | ||
4271 | (defun gnus-sort-gathered-threads (threads) | |
22bcf204 | 4272 | "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'." |
eec82323 LMI |
4273 | (let ((result threads)) |
4274 | (while threads | |
4275 | (when (stringp (caar threads)) | |
4276 | (setcdr (car threads) | |
16409b0b | 4277 | (sort (cdar threads) gnus-sort-gathered-threads-function))) |
eec82323 LMI |
4278 | (setq threads (cdr threads))) |
4279 | result)) | |
4280 | ||
4281 | (defun gnus-thread-loop-p (root thread) | |
4282 | "Say whether ROOT is in THREAD." | |
4283 | (let ((stack (list thread)) | |
4284 | (infloop 0) | |
4285 | th) | |
4286 | (while (setq thread (pop stack)) | |
4287 | (setq th (cdr thread)) | |
4288 | (while (and th | |
4289 | (not (eq (caar th) root))) | |
4290 | (pop th)) | |
4291 | (if th | |
4292 | ;; We have found a loop. | |
4293 | (let (ref-dep) | |
4294 | (setcdr thread (delq (car th) (cdr thread))) | |
4295 | (if (boundp (setq ref-dep (intern "none" | |
4296 | gnus-newsgroup-dependencies))) | |
4297 | (setcdr (symbol-value ref-dep) | |
4298 | (nconc (cdr (symbol-value ref-dep)) | |
4299 | (list (car th)))) | |
4300 | (set ref-dep (list nil (car th)))) | |
4301 | (setq infloop 1 | |
4302 | stack nil)) | |
4303 | ;; Push all the subthreads onto the stack. | |
4304 | (push (cdr thread) stack))) | |
4305 | infloop)) | |
4306 | ||
4307 | (defun gnus-make-threads () | |
01ccbb85 | 4308 | "Go through the dependency hashtb and find the roots. Return all threads." |
eec82323 LMI |
4309 | (let (threads) |
4310 | (while (catch 'infloop | |
4311 | (mapatoms | |
4312 | (lambda (refs) | |
4313 | ;; Deal with self-referencing References loops. | |
4314 | (when (and (car (symbol-value refs)) | |
4315 | (not (zerop | |
4316 | (apply | |
4317 | '+ | |
4318 | (mapcar | |
4319 | (lambda (thread) | |
4320 | (gnus-thread-loop-p | |
4321 | (car (symbol-value refs)) thread)) | |
4322 | (cdr (symbol-value refs))))))) | |
4323 | (setq threads nil) | |
4324 | (throw 'infloop t)) | |
4325 | (unless (car (symbol-value refs)) | |
23f87bed MB |
4326 | ;; These threads do not refer back to any other |
4327 | ;; articles, so they're roots. | |
eec82323 LMI |
4328 | (setq threads (append (cdr (symbol-value refs)) threads)))) |
4329 | gnus-newsgroup-dependencies))) | |
4330 | threads)) | |
4331 | ||
6748645f | 4332 | ;; Build the thread tree. |
16409b0b | 4333 | (defsubst gnus-dependencies-add-header (header dependencies force-new) |
6748645f LMI |
4334 | "Enter HEADER into the DEPENDENCIES table if it is not already there. |
4335 | ||
4336 | If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even | |
4337 | if it was already present. | |
4338 | ||
4339 | If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs | |
4340 | will not be entered in the DEPENDENCIES table. Otherwise duplicate | |
23f87bed MB |
4341 | Message-IDs will be renamed to a unique Message-ID before being |
4342 | entered. | |
6748645f LMI |
4343 | |
4344 | Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise." | |
4345 | (let* ((id (mail-header-id header)) | |
4346 | (id-dep (and id (intern id dependencies))) | |
23f87bed | 4347 | parent-id ref ref-dep ref-header replaced) |
6748645f LMI |
4348 | ;; Enter this `header' in the `dependencies' table. |
4349 | (cond | |
4350 | ((not id-dep) | |
4351 | (setq header nil)) | |
4352 | ;; The first two cases do the normal part: enter a new `header' | |
4353 | ;; in the `dependencies' table. | |
4354 | ((not (boundp id-dep)) | |
4355 | (set id-dep (list header))) | |
4356 | ((null (car (symbol-value id-dep))) | |
4357 | (setcar (symbol-value id-dep) header)) | |
4358 | ||
4359 | ;; From here the `header' was already present in the | |
4360 | ;; `dependencies' table. | |
4361 | (force-new | |
4362 | ;; Overrides an existing entry; | |
4363 | ;; just set the header part of the entry. | |
23f87bed MB |
4364 | (setcar (symbol-value id-dep) header) |
4365 | (setq replaced t)) | |
6748645f LMI |
4366 | |
4367 | ;; Renames the existing `header' to a unique Message-ID. | |
4368 | ((not gnus-summary-ignore-duplicates) | |
4369 | ;; An article with this Message-ID has already been seen. | |
4370 | ;; We rename the Message-ID. | |
4371 | (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies)) | |
4372 | (list header)) | |
4373 | (mail-header-set-id header id)) | |
4374 | ||
4375 | ;; The last case ignores an existing entry, except it adds any | |
4376 | ;; additional Xrefs (in case the two articles came from different | |
4377 | ;; servers. | |
4378 | ;; Also sets `header' to `nil' meaning that the `dependencies' | |
4379 | ;; table was *not* modified. | |
4380 | (t | |
4381 | (mail-header-set-xref | |
4382 | (car (symbol-value id-dep)) | |
4383 | (concat (or (mail-header-xref (car (symbol-value id-dep))) | |
4384 | "") | |
4385 | (or (mail-header-xref header) ""))) | |
4386 | (setq header nil))) | |
4387 | ||
23f87bed MB |
4388 | (when (and header (not replaced)) |
4389 | ;; First check that we are not creating a References loop. | |
4390 | (setq parent-id (gnus-parent-id (mail-header-references header))) | |
4391 | (setq ref parent-id) | |
6748645f LMI |
4392 | (while (and ref |
4393 | (setq ref-dep (intern-soft ref dependencies)) | |
4394 | (boundp ref-dep) | |
4395 | (setq ref-header (car (symbol-value ref-dep)))) | |
4396 | (if (string= id ref) | |
4397 | ;; Yuk! This is a reference loop. Make the article be a | |
4398 | ;; root article. | |
4399 | (progn | |
4400 | (mail-header-set-references (car (symbol-value id-dep)) "none") | |
23f87bed MB |
4401 | (setq ref nil) |
4402 | (setq parent-id nil)) | |
6748645f | 4403 | (setq ref (gnus-parent-id (mail-header-references ref-header))))) |
23f87bed | 4404 | (setq ref-dep (intern (or parent-id "none") dependencies)) |
6748645f LMI |
4405 | (if (boundp ref-dep) |
4406 | (setcdr (symbol-value ref-dep) | |
4407 | (nconc (cdr (symbol-value ref-dep)) | |
4408 | (list (symbol-value id-dep)))) | |
4409 | (set ref-dep (list nil (symbol-value id-dep))))) | |
4410 | header)) | |
4411 | ||
23f87bed MB |
4412 | (defun gnus-extract-message-id-from-in-reply-to (string) |
4413 | (if (string-match "<[^>]+>" string) | |
4414 | (substring string (match-beginning 0) (match-end 0)) | |
4415 | nil)) | |
4416 | ||
eec82323 LMI |
4417 | (defun gnus-build-sparse-threads () |
4418 | (let ((headers gnus-newsgroup-headers) | |
16409b0b | 4419 | (mail-parse-charset gnus-newsgroup-charset) |
6748645f | 4420 | (gnus-summary-ignore-duplicates t) |
eec82323 | 4421 | header references generation relations |
6748645f | 4422 | subject child end new-child date) |
eec82323 LMI |
4423 | ;; First we create an alist of generations/relations, where |
4424 | ;; generations is how much we trust the relation, and the relation | |
4425 | ;; is parent/child. | |
4426 | (gnus-message 7 "Making sparse threads...") | |
4427 | (save-excursion | |
4428 | (nnheader-set-temp-buffer " *gnus sparse threads*") | |
4429 | (while (setq header (pop headers)) | |
4430 | (when (and (setq references (mail-header-references header)) | |
4431 | (not (string= references ""))) | |
4432 | (insert references) | |
4433 | (setq child (mail-header-id header) | |
6748645f LMI |
4434 | subject (mail-header-subject header) |
4435 | date (mail-header-date header) | |
4436 | generation 0) | |
eec82323 LMI |
4437 | (while (search-backward ">" nil t) |
4438 | (setq end (1+ (point))) | |
4439 | (when (search-backward "<" nil t) | |
6748645f | 4440 | (setq new-child (buffer-substring (point) end)) |
eec82323 | 4441 | (push (list (incf generation) |
6748645f LMI |
4442 | child (setq child new-child) |
4443 | subject date) | |
eec82323 | 4444 | relations))) |
6748645f LMI |
4445 | (when child |
4446 | (push (list (1+ generation) child nil subject) relations)) | |
eec82323 LMI |
4447 | (erase-buffer))) |
4448 | (kill-buffer (current-buffer))) | |
4449 | ;; Sort over trustworthiness. | |
01c52d31 MB |
4450 | (dolist (relation (sort relations 'car-less-than-car)) |
4451 | (when (gnus-dependencies-add-header | |
4452 | (make-full-mail-header | |
4453 | gnus-reffed-article-number | |
4454 | (nth 3 relation) "" (or (nth 4 relation) "") | |
4455 | (nth 1 relation) | |
4456 | (or (nth 2 relation) "") 0 0 "") | |
4457 | gnus-newsgroup-dependencies nil) | |
4458 | (push gnus-reffed-article-number gnus-newsgroup-limit) | |
4459 | (push gnus-reffed-article-number gnus-newsgroup-sparse) | |
4460 | (push (cons gnus-reffed-article-number gnus-sparse-mark) | |
4461 | gnus-newsgroup-reads) | |
4462 | (decf gnus-reffed-article-number))) | |
eec82323 LMI |
4463 | (gnus-message 7 "Making sparse threads...done"))) |
4464 | ||
4465 | (defun gnus-build-old-threads () | |
4466 | ;; Look at all the articles that refer back to old articles, and | |
4467 | ;; fetch the headers for the articles that aren't there. This will | |
4468 | ;; build complete threads - if the roots haven't been expired by the | |
4469 | ;; server, that is. | |
16409b0b GM |
4470 | (let ((mail-parse-charset gnus-newsgroup-charset) |
4471 | id heads) | |
eec82323 LMI |
4472 | (mapatoms |
4473 | (lambda (refs) | |
4474 | (when (not (car (symbol-value refs))) | |
4475 | (setq heads (cdr (symbol-value refs))) | |
4476 | (while heads | |
4477 | (if (memq (mail-header-number (caar heads)) | |
4478 | gnus-newsgroup-dormant) | |
4479 | (setq heads (cdr heads)) | |
4480 | (setq id (symbol-name refs)) | |
4481 | (while (and (setq id (gnus-build-get-header id)) | |
6748645f | 4482 | (not (car (gnus-id-to-thread id))))) |
eec82323 LMI |
4483 | (setq heads nil))))) |
4484 | gnus-newsgroup-dependencies))) | |
4485 | ||
23f87bed MB |
4486 | (defsubst gnus-remove-odd-characters (string) |
4487 | "Translate STRING into something that doesn't contain weird characters." | |
4488 | (mm-subst-char-in-string | |
4489 | ?\r ?\- | |
01c52d31 | 4490 | (mm-subst-char-in-string ?\n ?\- string t) t)) |
23f87bed | 4491 | |
6748645f LMI |
4492 | ;; This function has to be called with point after the article number |
4493 | ;; on the beginning of the line. | |
4494 | (defsubst gnus-nov-parse-line (number dependencies &optional force-new) | |
01c52d31 | 4495 | (let ((eol (point-at-eol)) |
6748645f | 4496 | (buffer (current-buffer)) |
23f87bed | 4497 | header references in-reply-to) |
6748645f LMI |
4498 | |
4499 | ;; overview: [num subject from date id refs chars lines misc] | |
4500 | (unwind-protect | |
23f87bed | 4501 | (let (x) |
6748645f LMI |
4502 | (narrow-to-region (point) eol) |
4503 | (unless (eobp) | |
4504 | (forward-char)) | |
4505 | ||
4506 | (setq header | |
4507 | (make-full-mail-header | |
4508 | number ; number | |
23f87bed MB |
4509 | (condition-case () ; subject |
4510 | (gnus-remove-odd-characters | |
4511 | (funcall gnus-decode-encoded-word-function | |
4512 | (setq x (nnheader-nov-field)))) | |
4513 | (error x)) | |
4514 | (condition-case () ; from | |
4515 | (gnus-remove-odd-characters | |
343d6628 | 4516 | (funcall gnus-decode-encoded-address-function |
23f87bed MB |
4517 | (setq x (nnheader-nov-field)))) |
4518 | (error x)) | |
16409b0b | 4519 | (nnheader-nov-field) ; date |
01c52d31 | 4520 | (nnheader-nov-read-message-id number) ; id |
23f87bed | 4521 | (setq references (nnheader-nov-field)) ; refs |
16409b0b GM |
4522 | (nnheader-nov-read-integer) ; chars |
4523 | (nnheader-nov-read-integer) ; lines | |
4524 | (unless (eobp) | |
8b93df01 DL |
4525 | (if (looking-at "Xref: ") |
4526 | (goto-char (match-end 0))) | |
4527 | (nnheader-nov-field)) ; Xref | |
16409b0b | 4528 | (nnheader-nov-parse-extra)))) ; extra |
6748645f LMI |
4529 | |
4530 | (widen)) | |
4531 | ||
23f87bed MB |
4532 | (when (and (string= references "") |
4533 | (setq in-reply-to (mail-header-extra header)) | |
4534 | (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to)))) | |
4535 | (mail-header-set-references | |
4536 | header (gnus-extract-message-id-from-in-reply-to in-reply-to))) | |
4537 | ||
6748645f LMI |
4538 | (when gnus-alter-header-function |
4539 | (funcall gnus-alter-header-function header)) | |
4540 | (gnus-dependencies-add-header header dependencies force-new))) | |
4541 | ||
eec82323 | 4542 | (defun gnus-build-get-header (id) |
16409b0b GM |
4543 | "Look through the buffer of NOV lines and find the header to ID. |
4544 | Enter this line into the dependencies hash table, and return | |
4545 | the id of the parent article (if any)." | |
eec82323 LMI |
4546 | (let ((deps gnus-newsgroup-dependencies) |
4547 | found header) | |
4548 | (prog1 | |
c7a91ce1 | 4549 | (with-current-buffer nntp-server-buffer |
eec82323 LMI |
4550 | (let ((case-fold-search nil)) |
4551 | (goto-char (point-min)) | |
4552 | (while (and (not found) | |
4553 | (search-forward id nil t)) | |
4554 | (beginning-of-line) | |
4555 | (setq found (looking-at | |
4556 | (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s" | |
4557 | (regexp-quote id)))) | |
4558 | (or found (beginning-of-line 2))) | |
4559 | (when found | |
4560 | (beginning-of-line) | |
4561 | (and | |
4562 | (setq header (gnus-nov-parse-line | |
4563 | (read (current-buffer)) deps)) | |
4564 | (gnus-parent-id (mail-header-references header)))))) | |
4565 | (when header | |
4566 | (let ((number (mail-header-number header))) | |
4567 | (push number gnus-newsgroup-limit) | |
4568 | (push header gnus-newsgroup-headers) | |
4569 | (if (memq number gnus-newsgroup-unselected) | |
4570 | (progn | |
23f87bed MB |
4571 | (setq gnus-newsgroup-unreads |
4572 | (gnus-add-to-sorted-list gnus-newsgroup-unreads | |
4573 | number)) | |
eec82323 LMI |
4574 | (setq gnus-newsgroup-unselected |
4575 | (delq number gnus-newsgroup-unselected))) | |
4576 | (push number gnus-newsgroup-ancient))))))) | |
4577 | ||
6748645f LMI |
4578 | (defun gnus-build-all-threads () |
4579 | "Read all the headers." | |
4580 | (let ((gnus-summary-ignore-duplicates t) | |
16409b0b | 4581 | (mail-parse-charset gnus-newsgroup-charset) |
6748645f LMI |
4582 | (dependencies gnus-newsgroup-dependencies) |
4583 | header article) | |
c7a91ce1 | 4584 | (with-current-buffer nntp-server-buffer |
6748645f LMI |
4585 | (let ((case-fold-search nil)) |
4586 | (goto-char (point-min)) | |
4587 | (while (not (eobp)) | |
4588 | (ignore-errors | |
4589 | (setq article (read (current-buffer)) | |
181cb5fb | 4590 | header (gnus-nov-parse-line article dependencies t))) |
6748645f | 4591 | (when header |
01c52d31 | 4592 | (with-current-buffer gnus-summary-buffer |
6748645f LMI |
4593 | (push header gnus-newsgroup-headers) |
4594 | (if (memq (setq article (mail-header-number header)) | |
4595 | gnus-newsgroup-unselected) | |
4596 | (progn | |
23f87bed MB |
4597 | (setq gnus-newsgroup-unreads |
4598 | (gnus-add-to-sorted-list | |
4599 | gnus-newsgroup-unreads article)) | |
6748645f LMI |
4600 | (setq gnus-newsgroup-unselected |
4601 | (delq article gnus-newsgroup-unselected))) | |
4602 | (push article gnus-newsgroup-ancient))) | |
4603 | (forward-line 1))))))) | |
4604 | ||
eec82323 | 4605 | (defun gnus-summary-update-article-line (article header) |
23f87bed | 4606 | "Update the line for ARTICLE using HEADER." |
eec82323 LMI |
4607 | (let* ((id (mail-header-id header)) |
4608 | (thread (gnus-id-to-thread id))) | |
4609 | (unless thread | |
4610 | (error "Article in no thread")) | |
4611 | ;; Update the thread. | |
4612 | (setcar thread header) | |
4613 | (gnus-summary-goto-subject article) | |
4614 | (let* ((datal (gnus-data-find-list article)) | |
4615 | (data (car datal)) | |
c7a91ce1 | 4616 | (inhibit-read-only t) |
eec82323 LMI |
4617 | (level (gnus-summary-thread-level))) |
4618 | (gnus-delete-line) | |
23f87bed MB |
4619 | (let ((inserted (- (point) |
4620 | (progn | |
4621 | (gnus-summary-insert-line | |
4622 | header level nil | |
4623 | (memq article gnus-newsgroup-undownloaded) | |
4624 | (gnus-article-mark article) | |
4625 | (memq article gnus-newsgroup-replied) | |
4626 | (memq article gnus-newsgroup-expirable) | |
4627 | ;; Only insert the Subject string when it's different | |
4628 | ;; from the previous Subject string. | |
4629 | (if (and | |
4630 | gnus-show-threads | |
4631 | (gnus-subject-equal | |
4632 | (condition-case () | |
4633 | (mail-header-subject | |
4634 | (gnus-data-header | |
4635 | (cadr | |
4636 | (gnus-data-find-list | |
4637 | article | |
4638 | (gnus-data-list t))))) | |
4639 | ;; Error on the side of excessive subjects. | |
4640 | (error "")) | |
4641 | (mail-header-subject header))) | |
4642 | "" | |
4643 | (mail-header-subject header)) | |
4644 | nil (cdr (assq article gnus-newsgroup-scored)) | |
4645 | (memq article gnus-newsgroup-processable)) | |
4646 | (point))))) | |
4647 | (when (cdr datal) | |
4648 | (gnus-data-update-list | |
4649 | (cdr datal) | |
4650 | (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted))))))) | |
eec82323 LMI |
4651 | |
4652 | (defun gnus-summary-update-article (article &optional iheader) | |
4653 | "Update ARTICLE in the summary buffer." | |
4654 | (set-buffer gnus-summary-buffer) | |
6748645f | 4655 | (let* ((header (gnus-summary-article-header article)) |
eec82323 LMI |
4656 | (id (mail-header-id header)) |
4657 | (data (gnus-data-find article)) | |
4658 | (thread (gnus-id-to-thread id)) | |
4659 | (references (mail-header-references header)) | |
4660 | (parent | |
4661 | (gnus-id-to-thread | |
4662 | (or (gnus-parent-id | |
4663 | (when (and references | |
4664 | (not (equal "" references))) | |
4665 | references)) | |
4666 | "none"))) | |
c7a91ce1 | 4667 | (inhibit-read-only t) |
6748645f | 4668 | (old (car thread))) |
eec82323 | 4669 | (when thread |
eec82323 | 4670 | (unless iheader |
6748645f LMI |
4671 | (setcar thread nil) |
4672 | (when parent | |
4673 | (delq thread parent))) | |
4674 | (if (gnus-summary-insert-subject id header) | |
eec82323 LMI |
4675 | ;; Set the (possibly) new article number in the data structure. |
4676 | (gnus-data-set-number data (gnus-id-to-article id)) | |
4677 | (setcar thread old) | |
4678 | nil)))) | |
4679 | ||
6748645f LMI |
4680 | (defun gnus-rebuild-thread (id &optional line) |
4681 | "Rebuild the thread containing ID. | |
4682 | If LINE, insert the rebuilt thread starting on line LINE." | |
c7a91ce1 | 4683 | (let ((inhibit-read-only t) |
eec82323 LMI |
4684 | old-pos current thread data) |
4685 | (if (not gnus-show-threads) | |
4686 | (setq thread (list (car (gnus-id-to-thread id)))) | |
4687 | ;; Get the thread this article is part of. | |
4688 | (setq thread (gnus-remove-thread id))) | |
01c52d31 | 4689 | (setq old-pos (point-at-bol)) |
eec82323 | 4690 | (setq current (save-excursion |
94384150 | 4691 | (and (re-search-backward "[\r\n]" nil t) |
eec82323 LMI |
4692 | (gnus-summary-article-number)))) |
4693 | ;; If this is a gathered thread, we have to go some re-gathering. | |
4694 | (when (stringp (car thread)) | |
4695 | (let ((subject (car thread)) | |
4696 | roots thr) | |
4697 | (setq thread (cdr thread)) | |
4698 | (while thread | |
4699 | (unless (memq (setq thr (gnus-id-to-thread | |
4700 | (gnus-root-id | |
4701 | (mail-header-id (caar thread))))) | |
4702 | roots) | |
4703 | (push thr roots)) | |
4704 | (setq thread (cdr thread))) | |
4705 | ;; We now have all (unique) roots. | |
4706 | (if (= (length roots) 1) | |
4707 | ;; All the loose roots are now one solid root. | |
4708 | (setq thread (car roots)) | |
4709 | (setq thread (cons subject (gnus-sort-threads roots)))))) | |
4710 | (let (threads) | |
4711 | ;; We then insert this thread into the summary buffer. | |
6748645f LMI |
4712 | (when line |
4713 | (goto-char (point-min)) | |
4714 | (forward-line (1- line))) | |
eec82323 LMI |
4715 | (let (gnus-newsgroup-data gnus-newsgroup-threads) |
4716 | (if gnus-show-threads | |
4717 | (gnus-summary-prepare-threads (gnus-cut-threads (list thread))) | |
4718 | (gnus-summary-prepare-unthreaded thread)) | |
4719 | (setq data (nreverse gnus-newsgroup-data)) | |
4720 | (setq threads gnus-newsgroup-threads)) | |
4721 | ;; We splice the new data into the data structure. | |
6748645f LMI |
4722 | ;;!!! This is kinda bogus. We assume that in LINE is non-nil, |
4723 | ;;!!! then we want to insert at the beginning of the buffer. | |
4724 | ;;!!! That happens to be true with Gnus now, but that may | |
4725 | ;;!!! change in the future. Perhaps. | |
4726 | (gnus-data-enter-list | |
4727 | (if line nil current) data (- (point) old-pos)) | |
4728 | (setq gnus-newsgroup-threads | |
4729 | (nconc threads gnus-newsgroup-threads)) | |
4730 | (gnus-data-compute-positions)))) | |
eec82323 LMI |
4731 | |
4732 | (defun gnus-number-to-header (number) | |
4733 | "Return the header for article NUMBER." | |
4734 | (let ((headers gnus-newsgroup-headers)) | |
4735 | (while (and headers | |
4736 | (not (= number (mail-header-number (car headers))))) | |
4737 | (pop headers)) | |
4738 | (when headers | |
4739 | (car headers)))) | |
4740 | ||
6748645f | 4741 | (defun gnus-parent-headers (in-headers &optional generation) |
f6b1b0a8 | 4742 | "Return the headers of the GENERATIONth parent of HEADERS." |
eec82323 LMI |
4743 | (unless generation |
4744 | (setq generation 1)) | |
a8151ef7 | 4745 | (let ((parent t) |
6748645f | 4746 | (headers in-headers) |
a8151ef7 | 4747 | references) |
6748645f LMI |
4748 | (while (and parent |
4749 | (not (zerop generation)) | |
4750 | (setq references (mail-header-references headers))) | |
4751 | (setq headers (if (and references | |
4752 | (setq parent (gnus-parent-id references))) | |
4753 | (car (gnus-id-to-thread parent)) | |
4754 | nil)) | |
4755 | (decf generation)) | |
4756 | (and (not (eq headers in-headers)) | |
4757 | headers))) | |
eec82323 LMI |
4758 | |
4759 | (defun gnus-id-to-thread (id) | |
4760 | "Return the (sub-)thread where ID appears." | |
4761 | (gnus-gethash id gnus-newsgroup-dependencies)) | |
4762 | ||
4763 | (defun gnus-id-to-article (id) | |
4764 | "Return the article number of ID." | |
4765 | (let ((thread (gnus-id-to-thread id))) | |
4766 | (when (and thread | |
4767 | (car thread)) | |
4768 | (mail-header-number (car thread))))) | |
4769 | ||
4770 | (defun gnus-id-to-header (id) | |
4771 | "Return the article headers of ID." | |
4772 | (car (gnus-id-to-thread id))) | |
4773 | ||
4774 | (defun gnus-article-displayed-root-p (article) | |
4775 | "Say whether ARTICLE is a root(ish) article." | |
4776 | (let ((level (gnus-summary-thread-level article)) | |
4777 | (refs (mail-header-references (gnus-summary-article-header article))) | |
4778 | particle) | |
4779 | (cond | |
4780 | ((null level) nil) | |
4781 | ((zerop level) t) | |
4782 | ((null refs) t) | |
4783 | ((null (gnus-parent-id refs)) t) | |
4784 | ((and (= 1 level) | |
4785 | (null (setq particle (gnus-id-to-article | |
4786 | (gnus-parent-id refs)))) | |
4787 | (null (gnus-summary-thread-level particle))))))) | |
4788 | ||
4789 | (defun gnus-root-id (id) | |
4790 | "Return the id of the root of the thread where ID appears." | |
4791 | (let (last-id prev) | |
6748645f | 4792 | (while (and id (setq prev (car (gnus-id-to-thread id)))) |
eec82323 LMI |
4793 | (setq last-id id |
4794 | id (gnus-parent-id (mail-header-references prev)))) | |
4795 | last-id)) | |
4796 | ||
6748645f LMI |
4797 | (defun gnus-articles-in-thread (thread) |
4798 | "Return the list of articles in THREAD." | |
4799 | (cons (mail-header-number (car thread)) | |
4800 | (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread))))) | |
4801 | ||
eec82323 LMI |
4802 | (defun gnus-remove-thread (id &optional dont-remove) |
4803 | "Remove the thread that has ID in it." | |
6748645f | 4804 | (let (headers thread last-id) |
eec82323 | 4805 | ;; First go up in this thread until we find the root. |
6748645f LMI |
4806 | (setq last-id (gnus-root-id id) |
4807 | headers (message-flatten-list (gnus-id-to-thread last-id))) | |
01ccbb85 | 4808 | ;; We have now found the real root of this thread. It might have |
eec82323 LMI |
4809 | ;; been gathered into some loose thread, so we have to search |
4810 | ;; through the threads to find the thread we wanted. | |
4811 | (let ((threads gnus-newsgroup-threads) | |
4812 | sub) | |
4813 | (while threads | |
4814 | (setq sub (car threads)) | |
4815 | (if (stringp (car sub)) | |
4816 | ;; This is a gathered thread, so we look at the roots | |
4817 | ;; below it to find whether this article is in this | |
4818 | ;; gathered root. | |
4819 | (progn | |
4820 | (setq sub (cdr sub)) | |
4821 | (while sub | |
4822 | (when (member (caar sub) headers) | |
4823 | (setq thread (car threads) | |
4824 | threads nil | |
4825 | sub nil)) | |
4826 | (setq sub (cdr sub)))) | |
4827 | ;; It's an ordinary thread, so we check it. | |
4828 | (when (eq (car sub) (car headers)) | |
4829 | (setq thread sub | |
4830 | threads nil))) | |
4831 | (setq threads (cdr threads))) | |
4832 | ;; If this article is in no thread, then it's a root. | |
4833 | (if thread | |
4834 | (unless dont-remove | |
4835 | (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads))) | |
6748645f | 4836 | (setq thread (gnus-id-to-thread last-id))) |
eec82323 LMI |
4837 | (when thread |
4838 | (prog1 | |
4839 | thread ; We return this thread. | |
4840 | (unless dont-remove | |
4841 | (if (stringp (car thread)) | |
4842 | (progn | |
4843 | ;; If we use dummy roots, then we have to remove the | |
4844 | ;; dummy root as well. | |
4845 | (when (eq gnus-summary-make-false-root 'dummy) | |
6748645f LMI |
4846 | ;; We go to the dummy root by going to |
4847 | ;; the first sub-"thread", and then one line up. | |
4848 | (gnus-summary-goto-article | |
4849 | (mail-header-number (caadr thread))) | |
4850 | (forward-line -1) | |
eec82323 LMI |
4851 | (gnus-delete-line) |
4852 | (gnus-data-compute-positions)) | |
4853 | (setq thread (cdr thread)) | |
4854 | (while thread | |
4855 | (gnus-remove-thread-1 (car thread)) | |
4856 | (setq thread (cdr thread)))) | |
4857 | (gnus-remove-thread-1 thread)))))))) | |
4858 | ||
4859 | (defun gnus-remove-thread-1 (thread) | |
4860 | "Remove the thread THREAD recursively." | |
4861 | (let ((number (mail-header-number (pop thread))) | |
4862 | d) | |
4863 | (setq thread (reverse thread)) | |
4864 | (while thread | |
4865 | (gnus-remove-thread-1 (pop thread))) | |
4866 | (when (setq d (gnus-data-find number)) | |
4867 | (goto-char (gnus-data-pos d)) | |
16409b0b | 4868 | (gnus-summary-show-thread) |
eec82323 LMI |
4869 | (gnus-data-remove |
4870 | number | |
01c52d31 | 4871 | (- (point-at-bol) |
eec82323 | 4872 | (prog1 |
01c52d31 | 4873 | (1+ (point-at-eol)) |
eec82323 LMI |
4874 | (gnus-delete-line))))))) |
4875 | ||
4921bbdd | 4876 | (defun gnus-sort-threads-recursive (threads func) |
a3fd87cb TH |
4877 | ;; Responsible for sorting the root articles of threads. |
4878 | (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions | |
4879 | 'gnus-thread-sort-functions) | |
4880 | func | |
4881 | (gnus-make-sort-function | |
4882 | gnus-subthread-sort-functions)))) | |
4883 | (sort (mapcar (lambda (thread) | |
4884 | (cons (car thread) | |
4885 | (and (cdr thread) | |
4886 | (gnus-sort-subthreads-recursive | |
4887 | (cdr thread) subthread-sort-func)))) | |
4888 | threads) func))) | |
4889 | ||
4890 | (defun gnus-sort-subthreads-recursive (threads func) | |
4891 | ;; Responsible for sorting subthreads. | |
16409b0b GM |
4892 | (sort (mapcar (lambda (thread) |
4893 | (cons (car thread) | |
4894 | (and (cdr thread) | |
a3fd87cb | 4895 | (gnus-sort-subthreads-recursive (cdr thread) func)))) |
16409b0b GM |
4896 | threads) func)) |
4897 | ||
4921bbdd CY |
4898 | (defun gnus-sort-threads-loop (threads func) |
4899 | (let* ((superthread (cons nil threads)) | |
4900 | (stack (list (cons superthread threads))) | |
4901 | remaining-threads thread) | |
4902 | (while stack | |
4903 | (setq remaining-threads (cdr (car stack))) | |
4904 | (if remaining-threads | |
4905 | (progn (setq thread (car remaining-threads)) | |
4906 | (setcdr (car stack) (cdr remaining-threads)) | |
4907 | (if (cdr thread) | |
4908 | (push (cons thread (cdr thread)) stack))) | |
4909 | (setq thread (caar stack)) | |
4910 | (setcdr thread (sort (cdr thread) func)) | |
4911 | (pop stack))) | |
4912 | (cdr superthread))) | |
4913 | ||
eec82323 LMI |
4914 | (defun gnus-sort-threads (threads) |
4915 | "Sort THREADS." | |
4916 | (if (not gnus-thread-sort-functions) | |
4917 | threads | |
6748645f | 4918 | (gnus-message 8 "Sorting threads...") |
4921bbdd CY |
4919 | (prog1 |
4920 | (condition-case nil | |
13afd560 TH |
4921 | (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)) |
4922 | (sort-func (gnus-make-sort-function gnus-thread-sort-functions))) | |
a3fd87cb | 4923 | (gnus-sort-threads-recursive threads sort-func)) |
4921bbdd CY |
4924 | ;; Even after binding max-lisp-eval-depth, the recursive |
4925 | ;; sorter might fail for very long threads. In that case, | |
4926 | ;; try using a (less well-tested) non-recursive sorter. | |
3d6e7a43 KY |
4927 | (error (gnus-message 9 "Sorting threads with loop...") |
4928 | (gnus-sort-threads-loop | |
4921bbdd CY |
4929 | threads (gnus-make-sort-function |
4930 | gnus-thread-sort-functions)))) | |
4931 | (gnus-message 8 "Sorting threads...done")))) | |
eec82323 LMI |
4932 | |
4933 | (defun gnus-sort-articles (articles) | |
4934 | "Sort ARTICLES." | |
4935 | (when gnus-article-sort-functions | |
4936 | (gnus-message 7 "Sorting articles...") | |
4937 | (prog1 | |
4938 | (setq gnus-newsgroup-headers | |
4939 | (sort articles (gnus-make-sort-function | |
4940 | gnus-article-sort-functions))) | |
4941 | (gnus-message 7 "Sorting articles...done")))) | |
4942 | ||
4943 | ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>. | |
4944 | (defmacro gnus-thread-header (thread) | |
16409b0b GM |
4945 | "Return header of first article in THREAD. |
4946 | Note that THREAD must never, ever be anything else than a variable - | |
4947 | using some other form will lead to serious barfage." | |
eec82323 LMI |
4948 | (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread))) |
4949 | ;; (8% speedup to gnus-summary-prepare, just for fun :-) | |
16409b0b | 4950 | (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" |
eec82323 LMI |
4951 | (vector thread) 2)) |
4952 | ||
4953 | (defsubst gnus-article-sort-by-number (h1 h2) | |
4954 | "Sort articles by article number." | |
4955 | (< (mail-header-number h1) | |
4956 | (mail-header-number h2))) | |
4957 | ||
4958 | (defun gnus-thread-sort-by-number (h1 h2) | |
4959 | "Sort threads by root article number." | |
4960 | (gnus-article-sort-by-number | |
4961 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4962 | ||
23f87bed | 4963 | (defsubst gnus-article-sort-by-random (h1 h2) |
0b6799c3 | 4964 | "Sort articles randomly." |
23f87bed MB |
4965 | (zerop (random 2))) |
4966 | ||
4967 | (defun gnus-thread-sort-by-random (h1 h2) | |
0b6799c3 | 4968 | "Sort threads randomly." |
23f87bed MB |
4969 | (gnus-article-sort-by-random |
4970 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4971 | ||
eec82323 LMI |
4972 | (defsubst gnus-article-sort-by-lines (h1 h2) |
4973 | "Sort articles by article Lines header." | |
4974 | (< (mail-header-lines h1) | |
4975 | (mail-header-lines h2))) | |
4976 | ||
4977 | (defun gnus-thread-sort-by-lines (h1 h2) | |
4978 | "Sort threads by root article Lines header." | |
4979 | (gnus-article-sort-by-lines | |
4980 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4981 | ||
16409b0b GM |
4982 | (defsubst gnus-article-sort-by-chars (h1 h2) |
4983 | "Sort articles by octet length." | |
4984 | (< (mail-header-chars h1) | |
4985 | (mail-header-chars h2))) | |
4986 | ||
4987 | (defun gnus-thread-sort-by-chars (h1 h2) | |
4988 | "Sort threads by root article octet length." | |
4989 | (gnus-article-sort-by-chars | |
4990 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
4991 | ||
eec82323 LMI |
4992 | (defsubst gnus-article-sort-by-author (h1 h2) |
4993 | "Sort articles by root author." | |
b4fde39f | 4994 | (gnus-string< |
eec82323 LMI |
4995 | (let ((extract (funcall |
4996 | gnus-extract-address-components | |
4997 | (mail-header-from h1)))) | |
4998 | (or (car extract) (cadr extract) "")) | |
4999 | (let ((extract (funcall | |
5000 | gnus-extract-address-components | |
5001 | (mail-header-from h2)))) | |
5002 | (or (car extract) (cadr extract) "")))) | |
5003 | ||
5004 | (defun gnus-thread-sort-by-author (h1 h2) | |
5005 | "Sort threads by root author." | |
5006 | (gnus-article-sort-by-author | |
5007 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
5008 | ||
01c52d31 MB |
5009 | (defsubst gnus-article-sort-by-recipient (h1 h2) |
5010 | "Sort articles by recipient." | |
5011 | (gnus-string< | |
5012 | (let ((extract (funcall | |
5013 | gnus-extract-address-components | |
5014 | (or (cdr (assq 'To (mail-header-extra h1))) "")))) | |
5015 | (or (car extract) (cadr extract))) | |
5016 | (let ((extract (funcall | |
5017 | gnus-extract-address-components | |
5018 | (or (cdr (assq 'To (mail-header-extra h2))) "")))) | |
5019 | (or (car extract) (cadr extract))))) | |
5020 | ||
5021 | (defun gnus-thread-sort-by-recipient (h1 h2) | |
5022 | "Sort threads by root recipient." | |
5023 | (gnus-article-sort-by-recipient | |
5024 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
5025 | ||
eec82323 LMI |
5026 | (defsubst gnus-article-sort-by-subject (h1 h2) |
5027 | "Sort articles by root subject." | |
b4fde39f | 5028 | (gnus-string< |
eec82323 LMI |
5029 | (downcase (gnus-simplify-subject-re (mail-header-subject h1))) |
5030 | (downcase (gnus-simplify-subject-re (mail-header-subject h2))))) | |
5031 | ||
5032 | (defun gnus-thread-sort-by-subject (h1 h2) | |
5033 | "Sort threads by root subject." | |
5034 | (gnus-article-sort-by-subject | |
5035 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
5036 | ||
5037 | (defsubst gnus-article-sort-by-date (h1 h2) | |
5038 | "Sort articles by root article date." | |
16409b0b | 5039 | (time-less-p |
eec82323 LMI |
5040 | (gnus-date-get-time (mail-header-date h1)) |
5041 | (gnus-date-get-time (mail-header-date h2)))) | |
5042 | ||
5043 | (defun gnus-thread-sort-by-date (h1 h2) | |
5044 | "Sort threads by root article date." | |
5045 | (gnus-article-sort-by-date | |
5046 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
5047 | ||
5048 | (defsubst gnus-article-sort-by-score (h1 h2) | |
5049 | "Sort articles by root article score. | |
5050 | Unscored articles will be counted as having a score of zero." | |
5051 | (> (or (cdr (assq (mail-header-number h1) | |
5052 | gnus-newsgroup-scored)) | |
5053 | gnus-summary-default-score 0) | |
5054 | (or (cdr (assq (mail-header-number h2) | |
5055 | gnus-newsgroup-scored)) | |
5056 | gnus-summary-default-score 0))) | |
5057 | ||
5058 | (defun gnus-thread-sort-by-score (h1 h2) | |
5059 | "Sort threads by root article score." | |
5060 | (gnus-article-sort-by-score | |
5061 | (gnus-thread-header h1) (gnus-thread-header h2))) | |
5062 | ||
5063 | (defun gnus-thread-sort-by-total-score (h1 h2) | |
5064 | "Sort threads by the sum of all scores in the thread. | |
5065 | Unscored articles will be counted as having a score of zero." | |
5066 | (> (gnus-thread-total-score h1) (gnus-thread-total-score h2))) | |
5067 | ||
5068 | (defun gnus-thread-total-score (thread) | |
16409b0b | 5069 | ;; This function find the total score of THREAD. |
23f87bed MB |
5070 | (cond |
5071 | ((null thread) | |
5072 | 0) | |
5073 | ((consp thread) | |
5074 | (if (stringp (car thread)) | |
5075 | (apply gnus-thread-score-function 0 | |
5076 | (mapcar 'gnus-thread-total-score-1 (cdr thread))) | |
5077 | (gnus-thread-total-score-1 thread))) | |
5078 | (t | |
5079 | (gnus-thread-total-score-1 (list thread))))) | |
5080 | ||
130e977f LMI |
5081 | (defun gnus-article-sort-by-most-recent-number (h1 h2) |
5082 | "Sort articles by number." | |
5083 | (gnus-article-sort-by-number h1 h2)) | |
5084 | ||
23f87bed MB |
5085 | (defun gnus-thread-sort-by-most-recent-number (h1 h2) |
5086 | "Sort threads such that the thread with the most recently arrived article comes first." | |
5087 | (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2))) | |
5088 | ||
5089 | (defun gnus-thread-highest-number (thread) | |
5090 | "Return the highest article number in THREAD." | |
5091 | (apply 'max (mapcar (lambda (header) | |
5092 | (mail-header-number header)) | |
5093 | (message-flatten-list thread)))) | |
5094 | ||
130e977f LMI |
5095 | (defun gnus-article-sort-by-most-recent-date (h1 h2) |
5096 | "Sort articles by number." | |
5097 | (gnus-article-sort-by-date h1 h2)) | |
5098 | ||
23f87bed MB |
5099 | (defun gnus-thread-sort-by-most-recent-date (h1 h2) |
5100 | "Sort threads such that the thread with the most recently dated article comes first." | |
5101 | (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2))) | |
5102 | ||
3d6e7a43 KY |
5103 | ; Since this is called not only to sort the top-level threads, but |
5104 | ; also in recursive sorts to order the articles within a thread, each | |
5105 | ; article will be processed many times. Thus it speeds things up | |
5106 | ; quite a bit to use gnus-date-get-time, which caches the time value. | |
23f87bed MB |
5107 | (defun gnus-thread-latest-date (thread) |
5108 | "Return the highest article date in THREAD." | |
3d6e7a43 KY |
5109 | (apply 'max |
5110 | (mapcar (lambda (header) (gnus-float-time | |
5111 | (gnus-date-get-time | |
5112 | (mail-header-date header)))) | |
5113 | (message-flatten-list thread)))) | |
eec82323 LMI |
5114 | |
5115 | (defun gnus-thread-total-score-1 (root) | |
5116 | ;; This function find the total score of the thread below ROOT. | |
5117 | (setq root (car root)) | |
5118 | (apply gnus-thread-score-function | |
5119 | (or (append | |
5120 | (mapcar 'gnus-thread-total-score | |
6748645f | 5121 | (cdr (gnus-id-to-thread (mail-header-id root)))) |
eec82323 LMI |
5122 | (when (> (mail-header-number root) 0) |
5123 | (list (or (cdr (assq (mail-header-number root) | |
5124 | gnus-newsgroup-scored)) | |
5125 | gnus-summary-default-score 0)))) | |
5126 | (list gnus-summary-default-score) | |
5127 | '(0)))) | |
5128 | ||
5129 | ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. | |
5130 | (defvar gnus-tmp-prev-subject nil) | |
5131 | (defvar gnus-tmp-false-parent nil) | |
5132 | (defvar gnus-tmp-root-expunged nil) | |
5133 | (defvar gnus-tmp-dummy-line nil) | |
5134 | ||
16409b0b GM |
5135 | (defun gnus-extra-header (type &optional header) |
5136 | "Return the extra header of TYPE." | |
5137 | (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header)))) | |
5138 | "")) | |
5139 | ||
23f87bed MB |
5140 | (defvar gnus-tmp-thread-tree-header-string "") |
5141 | ||
5142 | (defcustom gnus-sum-thread-tree-root "> " | |
5143 | "With %B spec, used for the root of a thread. | |
5144 | If nil, use subject instead." | |
bf247b6e | 5145 | :version "22.1" |
ad136a7c | 5146 | :type '(radio (const :format "%v " nil) string) |
23f87bed | 5147 | :group 'gnus-thread) |
01c52d31 | 5148 | |
23f87bed MB |
5149 | (defcustom gnus-sum-thread-tree-false-root "> " |
5150 | "With %B spec, used for a false root of a thread. | |
5151 | If nil, use subject instead." | |
bf247b6e | 5152 | :version "22.1" |
ad136a7c | 5153 | :type '(radio (const :format "%v " nil) string) |
23f87bed | 5154 | :group 'gnus-thread) |
01c52d31 | 5155 | |
23f87bed MB |
5156 | (defcustom gnus-sum-thread-tree-single-indent "" |
5157 | "With %B spec, used for a thread with just one message. | |
5158 | If nil, use subject instead." | |
bf247b6e | 5159 | :version "22.1" |
ad136a7c | 5160 | :type '(radio (const :format "%v " nil) string) |
23f87bed | 5161 | :group 'gnus-thread) |
01c52d31 | 5162 | |
23f87bed MB |
5163 | (defcustom gnus-sum-thread-tree-vertical "| " |
5164 | "With %B spec, used for drawing a vertical line." | |
bf247b6e | 5165 | :version "22.1" |
23f87bed MB |
5166 | :type 'string |
5167 | :group 'gnus-thread) | |
01c52d31 | 5168 | |
23f87bed MB |
5169 | (defcustom gnus-sum-thread-tree-indent " " |
5170 | "With %B spec, used for indenting." | |
bf247b6e | 5171 | :version "22.1" |
23f87bed MB |
5172 | :type 'string |
5173 | :group 'gnus-thread) | |
01c52d31 | 5174 | |
23f87bed MB |
5175 | (defcustom gnus-sum-thread-tree-leaf-with-other "+-> " |
5176 | "With %B spec, used for a leaf with brothers." | |
bf247b6e | 5177 | :version "22.1" |
23f87bed MB |
5178 | :type 'string |
5179 | :group 'gnus-thread) | |
01c52d31 | 5180 | |
23f87bed MB |
5181 | (defcustom gnus-sum-thread-tree-single-leaf "\\-> " |
5182 | "With %B spec, used for a leaf without brothers." | |
bf247b6e | 5183 | :version "22.1" |
23f87bed MB |
5184 | :type 'string |
5185 | :group 'gnus-thread) | |
5186 | ||
1fc34624 GM |
5187 | (defcustom gnus-summary-display-while-building nil |
5188 | "If non-nil, show and update the summary buffer as it's being built. | |
5189 | If the value is t, update the buffer after every line is inserted. If | |
5190 | the value is an integer (N), update the display every N lines." | |
5191 | :version "22.1" | |
5192 | :group 'gnus-thread | |
5193 | :type '(choice (const :tag "off" nil) | |
5194 | number | |
5195 | (const :tag "frequently" t))) | |
5196 | ||
eec82323 LMI |
5197 | (defun gnus-summary-prepare-threads (threads) |
5198 | "Prepare summary buffer from THREADS and indentation LEVEL. | |
5199 | THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])' | |
5200 | or a straight list of headers." | |
5201 | (gnus-message 7 "Generating summary...") | |
5202 | ||
5203 | (setq gnus-newsgroup-threads threads) | |
5204 | (beginning-of-line) | |
5205 | ||
5206 | (let ((gnus-tmp-level 0) | |
5207 | (default-score (or gnus-summary-default-score 0)) | |
5208 | (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight)) | |
23f87bed MB |
5209 | (building-line-count gnus-summary-display-while-building) |
5210 | (building-count (integerp gnus-summary-display-while-building)) | |
eec82323 | 5211 | thread number subject stack state gnus-tmp-gathered beg-match |
23f87bed MB |
5212 | new-roots gnus-tmp-new-adopts thread-end simp-subject |
5213 | gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded | |
eec82323 LMI |
5214 | gnus-tmp-replied gnus-tmp-subject-or-nil |
5215 | gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score | |
5216 | gnus-tmp-score-char gnus-tmp-from gnus-tmp-name | |
23f87bed MB |
5217 | gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket |
5218 | tree-stack) | |
eec82323 | 5219 | |
23f87bed MB |
5220 | (setq gnus-tmp-prev-subject nil |
5221 | gnus-tmp-thread-tree-header-string "") | |
eec82323 LMI |
5222 | |
5223 | (if (vectorp (car threads)) | |
5224 | ;; If this is a straight (sic) list of headers, then a | |
5225 | ;; threaded summary display isn't required, so we just create | |
5226 | ;; an unthreaded one. | |
5227 | (gnus-summary-prepare-unthreaded threads) | |
5228 | ||
5229 | ;; Do the threaded display. | |
5230 | ||
23f87bed MB |
5231 | (if gnus-summary-display-while-building |
5232 | (switch-to-buffer (buffer-name))) | |
eec82323 LMI |
5233 | (while (or threads stack gnus-tmp-new-adopts new-roots) |
5234 | ||
5235 | (if (and (= gnus-tmp-level 0) | |
eec82323 LMI |
5236 | (or (not stack) |
5237 | (= (caar stack) 0)) | |
5238 | (not gnus-tmp-false-parent) | |
5239 | (or gnus-tmp-new-adopts new-roots)) | |
5240 | (if gnus-tmp-new-adopts | |
5241 | (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1) | |
5242 | thread (list (car gnus-tmp-new-adopts)) | |
5243 | gnus-tmp-header (caar thread) | |
5244 | gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts)) | |
5245 | (when new-roots | |
5246 | (setq thread (list (car new-roots)) | |
5247 | gnus-tmp-header (caar thread) | |
5248 | new-roots (cdr new-roots)))) | |
5249 | ||
5250 | (if threads | |
5251 | ;; If there are some threads, we do them before the | |
5252 | ;; threads on the stack. | |
5253 | (setq thread threads | |
5254 | gnus-tmp-header (caar thread)) | |
5255 | ;; There were no current threads, so we pop something off | |
5256 | ;; the stack. | |
5257 | (setq state (car stack) | |
5258 | gnus-tmp-level (car state) | |
23f87bed MB |
5259 | tree-stack (cadr state) |
5260 | thread (caddr state) | |
eec82323 LMI |
5261 | stack (cdr stack) |
5262 | gnus-tmp-header (caar thread)))) | |
5263 | ||
5264 | (setq gnus-tmp-false-parent nil) | |
5265 | (setq gnus-tmp-root-expunged nil) | |
5266 | (setq thread-end nil) | |
5267 | ||
5268 | (if (stringp gnus-tmp-header) | |
5269 | ;; The header is a dummy root. | |
5270 | (cond | |
5271 | ((eq gnus-summary-make-false-root 'adopt) | |
5272 | ;; We let the first article adopt the rest. | |
5273 | (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts | |
5274 | (cddar thread))) | |
5275 | (setq gnus-tmp-gathered | |
5276 | (nconc (mapcar | |
5277 | (lambda (h) (mail-header-number (car h))) | |
5278 | (cddar thread)) | |
5279 | gnus-tmp-gathered)) | |
5280 | (setq thread (cons (list (caar thread) | |
5281 | (cadar thread)) | |
5282 | (cdr thread))) | |
5283 | (setq gnus-tmp-level -1 | |
5284 | gnus-tmp-false-parent t)) | |
5285 | ((eq gnus-summary-make-false-root 'empty) | |
5286 | ;; We print adopted articles with empty subject fields. | |
5287 | (setq gnus-tmp-gathered | |
5288 | (nconc (mapcar | |
5289 | (lambda (h) (mail-header-number (car h))) | |
5290 | (cddar thread)) | |
5291 | gnus-tmp-gathered)) | |
5292 | (setq gnus-tmp-level -1)) | |
5293 | ((eq gnus-summary-make-false-root 'dummy) | |
5294 | ;; We remember that we probably want to output a dummy | |
5295 | ;; root. | |
5296 | (setq gnus-tmp-dummy-line gnus-tmp-header) | |
5297 | (setq gnus-tmp-prev-subject gnus-tmp-header)) | |
5298 | (t | |
5299 | ;; We do not make a root for the gathered | |
5300 | ;; sub-threads at all. | |
5301 | (setq gnus-tmp-level -1))) | |
5302 | ||
5303 | (setq number (mail-header-number gnus-tmp-header) | |
23f87bed MB |
5304 | subject (mail-header-subject gnus-tmp-header) |
5305 | simp-subject (gnus-simplify-subject-fully subject)) | |
eec82323 LMI |
5306 | |
5307 | (cond | |
5308 | ;; If the thread has changed subject, we might want to make | |
5309 | ;; this subthread into a root. | |
5310 | ((and (null gnus-thread-ignore-subject) | |
5311 | (not (zerop gnus-tmp-level)) | |
5312 | gnus-tmp-prev-subject | |
23f87bed | 5313 | (not (string= gnus-tmp-prev-subject simp-subject))) |
eec82323 LMI |
5314 | (setq new-roots (nconc new-roots (list (car thread))) |
5315 | thread-end t | |
5316 | gnus-tmp-header nil)) | |
5317 | ;; If the article lies outside the current limit, | |
5318 | ;; then we do not display it. | |
5319 | ((not (memq number gnus-newsgroup-limit)) | |
5320 | (setq gnus-tmp-gathered | |
5321 | (nconc (mapcar | |
5322 | (lambda (h) (mail-header-number (car h))) | |
5323 | (cdar thread)) | |
5324 | gnus-tmp-gathered)) | |
5325 | (setq gnus-tmp-new-adopts (if (cdar thread) | |
5326 | (append gnus-tmp-new-adopts | |
5327 | (cdar thread)) | |
5328 | gnus-tmp-new-adopts) | |
5329 | thread-end t | |
5330 | gnus-tmp-header nil) | |
5331 | (when (zerop gnus-tmp-level) | |
5332 | (setq gnus-tmp-root-expunged t))) | |
5333 | ;; Perhaps this article is to be marked as read? | |
5334 | ((and gnus-summary-mark-below | |
5335 | (< (or (cdr (assq number gnus-newsgroup-scored)) | |
5336 | default-score) | |
5337 | gnus-summary-mark-below) | |
5338 | ;; Don't touch sparse articles. | |
5339 | (not (gnus-summary-article-sparse-p number)) | |
5340 | (not (gnus-summary-article-ancient-p number))) | |
5341 | (setq gnus-newsgroup-unreads | |
5342 | (delq number gnus-newsgroup-unreads)) | |
5343 | (if gnus-newsgroup-auto-expire | |
23f87bed MB |
5344 | (setq gnus-newsgroup-expirable |
5345 | (gnus-add-to-sorted-list | |
5346 | gnus-newsgroup-expirable number)) | |
eec82323 LMI |
5347 | (push (cons number gnus-low-score-mark) |
5348 | gnus-newsgroup-reads)))) | |
5349 | ||
5350 | (when gnus-tmp-header | |
5351 | ;; We may have an old dummy line to output before this | |
5352 | ;; article. | |
6748645f LMI |
5353 | (when (and gnus-tmp-dummy-line |
5354 | (gnus-subject-equal | |
5355 | gnus-tmp-dummy-line | |
5356 | (mail-header-subject gnus-tmp-header))) | |
eec82323 LMI |
5357 | (gnus-summary-insert-dummy-line |
5358 | gnus-tmp-dummy-line (mail-header-number gnus-tmp-header)) | |
5359 | (setq gnus-tmp-dummy-line nil)) | |
5360 | ||
5361 | ;; Compute the mark. | |
5362 | (setq gnus-tmp-unread (gnus-article-mark number)) | |
5363 | ||
5364 | (push (gnus-data-make number gnus-tmp-unread (1+ (point)) | |
5365 | gnus-tmp-header gnus-tmp-level) | |
5366 | gnus-newsgroup-data) | |
5367 | ||
5368 | ;; Actually insert the line. | |
5369 | (setq | |
5370 | gnus-tmp-subject-or-nil | |
5371 | (cond | |
5372 | ((and gnus-thread-ignore-subject | |
5373 | gnus-tmp-prev-subject | |
23f87bed | 5374 | (not (string= gnus-tmp-prev-subject simp-subject))) |
eec82323 LMI |
5375 | subject) |
5376 | ((zerop gnus-tmp-level) | |
5377 | (if (and (eq gnus-summary-make-false-root 'empty) | |
5378 | (memq number gnus-tmp-gathered) | |
5379 | gnus-tmp-prev-subject | |
23f87bed | 5380 | (string= gnus-tmp-prev-subject simp-subject)) |
eec82323 LMI |
5381 | gnus-summary-same-subject |
5382 | subject)) | |
5383 | (t gnus-summary-same-subject))) | |
5384 | (if (and (eq gnus-summary-make-false-root 'adopt) | |
5385 | (= gnus-tmp-level 1) | |
5386 | (memq number gnus-tmp-gathered)) | |
5387 | (setq gnus-tmp-opening-bracket ?\< | |
5388 | gnus-tmp-closing-bracket ?\>) | |
5389 | (setq gnus-tmp-opening-bracket ?\[ | |
5390 | gnus-tmp-closing-bracket ?\])) | |
4921bbdd CY |
5391 | (if (>= gnus-tmp-level (length gnus-thread-indent-array)) |
5392 | (gnus-make-thread-indent-array | |
5393 | (max (* 2 (length gnus-thread-indent-array)) | |
5394 | gnus-tmp-level))) | |
eec82323 LMI |
5395 | (setq |
5396 | gnus-tmp-indentation | |
5397 | (aref gnus-thread-indent-array gnus-tmp-level) | |
5398 | gnus-tmp-lines (mail-header-lines gnus-tmp-header) | |
5399 | gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored)) | |
5400 | gnus-summary-default-score 0) | |
5401 | gnus-tmp-score-char | |
5402 | (if (or (null gnus-summary-default-score) | |
5403 | (<= (abs (- gnus-tmp-score gnus-summary-default-score)) | |
5404 | gnus-summary-zcore-fuzz)) | |
23f87bed | 5405 | ? ;Whitespace |
eec82323 LMI |
5406 | (if (< gnus-tmp-score gnus-summary-default-score) |
5407 | gnus-score-below-mark gnus-score-over-mark)) | |
5408 | gnus-tmp-replied | |
5409 | (cond ((memq number gnus-newsgroup-processable) | |
5410 | gnus-process-mark) | |
5411 | ((memq number gnus-newsgroup-cached) | |
5412 | gnus-cached-mark) | |
5413 | ((memq number gnus-newsgroup-replied) | |
5414 | gnus-replied-mark) | |
23f87bed MB |
5415 | ((memq number gnus-newsgroup-forwarded) |
5416 | gnus-forwarded-mark) | |
eec82323 LMI |
5417 | ((memq number gnus-newsgroup-saved) |
5418 | gnus-saved-mark) | |
23f87bed MB |
5419 | ((memq number gnus-newsgroup-unseen) |
5420 | gnus-unseen-mark) | |
5421 | (t gnus-no-mark)) | |
5422 | gnus-tmp-downloaded | |
5423 | (cond ((memq number gnus-newsgroup-undownloaded) | |
5424 | gnus-undownloaded-mark) | |
5425 | (gnus-newsgroup-agentized | |
5426 | gnus-downloaded-mark) | |
5427 | (t | |
5428 | gnus-no-mark)) | |
eec82323 LMI |
5429 | gnus-tmp-from (mail-header-from gnus-tmp-header) |
5430 | gnus-tmp-name | |
5431 | (cond | |
5432 | ((string-match "<[^>]+> *$" gnus-tmp-from) | |
5433 | (setq beg-match (match-beginning 0)) | |
23f87bed MB |
5434 | (or (and (string-match "^\".+\"" gnus-tmp-from) |
5435 | (substring gnus-tmp-from 1 (1- (match-end 0)))) | |
eec82323 LMI |
5436 | (substring gnus-tmp-from 0 beg-match))) |
5437 | ((string-match "(.+)" gnus-tmp-from) | |
5438 | (substring gnus-tmp-from | |
5439 | (1+ (match-beginning 0)) (1- (match-end 0)))) | |
23f87bed MB |
5440 | (t gnus-tmp-from)) |
5441 | ||
5442 | ;; Do the %B string | |
5443 | gnus-tmp-thread-tree-header-string | |
5444 | (cond | |
5445 | ((not gnus-show-threads) "") | |
5446 | ((zerop gnus-tmp-level) | |
5447 | (cond ((cdar thread) | |
5448 | (or gnus-sum-thread-tree-root subject)) | |
5449 | (gnus-tmp-new-adopts | |
5450 | (or gnus-sum-thread-tree-false-root subject)) | |
5451 | (t | |
5452 | (or gnus-sum-thread-tree-single-indent subject)))) | |
5453 | (t | |
5454 | (concat (apply 'concat | |
5455 | (mapcar (lambda (item) | |
5456 | (if (= item 1) | |
5457 | gnus-sum-thread-tree-vertical | |
5458 | gnus-sum-thread-tree-indent)) | |
5459 | (cdr (reverse tree-stack)))) | |
5460 | (if (nth 1 thread) | |
5461 | gnus-sum-thread-tree-leaf-with-other | |
5462 | gnus-sum-thread-tree-single-leaf))))) | |
eec82323 LMI |
5463 | (when (string= gnus-tmp-name "") |
5464 | (setq gnus-tmp-name gnus-tmp-from)) | |
5465 | (unless (numberp gnus-tmp-lines) | |
23f87bed MB |
5466 | (setq gnus-tmp-lines -1)) |
5467 | (if (= gnus-tmp-lines -1) | |
5468 | (setq gnus-tmp-lines "?") | |
5469 | (setq gnus-tmp-lines (number-to-string gnus-tmp-lines))) | |
61b1af82 G |
5470 | (gnus-put-text-property |
5471 | (point) | |
5472 | (progn (eval gnus-summary-line-format-spec) (point)) | |
5473 | 'gnus-number number) | |
5474 | (when gnus-visual-p | |
5475 | (forward-line -1) | |
5476 | (gnus-summary-highlight-line) | |
5477 | (when gnus-summary-update-hook | |
5478 | (gnus-run-hooks 'gnus-summary-update-hook)) | |
5479 | (forward-line 1)) | |
5480 | ||
5481 | (setq gnus-tmp-prev-subject simp-subject))) | |
eec82323 LMI |
5482 | |
5483 | (when (nth 1 thread) | |
23f87bed MB |
5484 | (push (list (max 0 gnus-tmp-level) |
5485 | (copy-sequence tree-stack) | |
5486 | (nthcdr 1 thread)) | |
5487 | stack)) | |
5488 | (push (if (nth 1 thread) 1 0) tree-stack) | |
eec82323 LMI |
5489 | (incf gnus-tmp-level) |
5490 | (setq threads (if thread-end nil (cdar thread))) | |
23f87bed MB |
5491 | (if gnus-summary-display-while-building |
5492 | (if building-count | |
5493 | (progn | |
5494 | ;; use a set frequency | |
5495 | (setq building-line-count (1- building-line-count)) | |
5496 | (when (= building-line-count 0) | |
5497 | (sit-for 0) | |
5498 | (setq building-line-count | |
5499 | gnus-summary-display-while-building))) | |
5500 | ;; always | |
5501 | (sit-for 0))) | |
eec82323 LMI |
5502 | (unless threads |
5503 | (setq gnus-tmp-level 0))))) | |
5504 | (gnus-message 7 "Generating summary...done")) | |
5505 | ||
5506 | (defun gnus-summary-prepare-unthreaded (headers) | |
5507 | "Generate an unthreaded summary buffer based on HEADERS." | |
5508 | (let (header number mark) | |
5509 | ||
5510 | (beginning-of-line) | |
5511 | ||
5512 | (while headers | |
5513 | ;; We may have to root out some bad articles... | |
5514 | (when (memq (setq number (mail-header-number | |
5515 | (setq header (pop headers)))) | |
5516 | gnus-newsgroup-limit) | |
5517 | ;; Mark article as read when it has a low score. | |
5518 | (when (and gnus-summary-mark-below | |
5519 | (< (or (cdr (assq number gnus-newsgroup-scored)) | |
5520 | gnus-summary-default-score 0) | |
5521 | gnus-summary-mark-below) | |
5522 | (not (gnus-summary-article-ancient-p number))) | |
5523 | (setq gnus-newsgroup-unreads | |
5524 | (delq number gnus-newsgroup-unreads)) | |
5525 | (if gnus-newsgroup-auto-expire | |
5526 | (push number gnus-newsgroup-expirable) | |
5527 | (push (cons number gnus-low-score-mark) | |
5528 | gnus-newsgroup-reads))) | |
5529 | ||
5530 | (setq mark (gnus-article-mark number)) | |
5531 | (push (gnus-data-make number mark (1+ (point)) header 0) | |
5532 | gnus-newsgroup-data) | |
5533 | (gnus-summary-insert-line | |
5534 | header 0 number | |
23f87bed | 5535 | (memq number gnus-newsgroup-undownloaded) |
eec82323 LMI |
5536 | mark (memq number gnus-newsgroup-replied) |
5537 | (memq number gnus-newsgroup-expirable) | |
5538 | (mail-header-subject header) nil | |
5539 | (cdr (assq number gnus-newsgroup-scored)) | |
5540 | (memq number gnus-newsgroup-processable)))))) | |
5541 | ||
cf6a9685 GM |
5542 | (declare-function gnus-parameter-list-identifier "gnus-art" (name) t) |
5543 | ||
d6cd56f1 JD |
5544 | (defun gnus-group-get-list-identifiers (group) |
5545 | "Get list identifier regexp for GROUP." | |
5546 | (or (gnus-parameter-list-identifier group) | |
5547 | (if (consp gnus-list-identifiers) | |
5548 | (mapconcat 'identity gnus-list-identifiers " *\\|") | |
5549 | gnus-list-identifiers))) | |
5550 | ||
16409b0b GM |
5551 | (defun gnus-summary-remove-list-identifiers () |
5552 | "Remove list identifiers in `gnus-list-identifiers' from articles in the current group." | |
d6cd56f1 JD |
5553 | (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name)) |
5554 | changed subject) | |
23f87bed | 5555 | (when regexp |
01c52d31 | 5556 | (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)")) |
23f87bed MB |
5557 | (dolist (header gnus-newsgroup-headers) |
5558 | (setq subject (mail-header-subject header) | |
5559 | changed nil) | |
01c52d31 | 5560 | (while (string-match regexp subject) |
23f87bed | 5561 | (setq subject |
01c52d31 | 5562 | (concat (substring subject 0 (match-beginning 1)) |
23f87bed MB |
5563 | (substring subject (match-end 0))) |
5564 | changed t)) | |
23f87bed | 5565 | (when changed |
01c52d31 MB |
5566 | (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject) |
5567 | (setq subject | |
5568 | (concat (substring subject 0 (match-beginning 1)) | |
5569 | (substring subject (match-end 1))))) | |
23f87bed MB |
5570 | (mail-header-set-subject header subject)))))) |
5571 | ||
4ddab346 | 5572 | (defun gnus-fetch-headers (articles &optional limit force-new dependencies) |
23f87bed MB |
5573 | "Fetch headers of ARTICLES." |
5574 | (let ((name (gnus-group-decoded-name gnus-newsgroup-name))) | |
0afb49a1 | 5575 | (gnus-message 7 "Fetching headers for %s..." name) |
23f87bed MB |
5576 | (prog1 |
5577 | (if (eq 'nov | |
5578 | (setq gnus-headers-retrieved-by | |
5579 | (gnus-retrieve-headers | |
5580 | articles gnus-newsgroup-name | |
4ddab346 G |
5581 | (or limit |
5582 | ;; We might want to fetch old headers, but | |
5583 | ;; not if there is only 1 article. | |
5584 | (and (or (and | |
5585 | (not (eq gnus-fetch-old-headers 'some)) | |
5586 | (not (numberp gnus-fetch-old-headers))) | |
5587 | (> (length articles) 1)) | |
5588 | gnus-fetch-old-headers))))) | |
23f87bed | 5589 | (gnus-get-newsgroup-headers-xover |
4ddab346 G |
5590 | articles force-new dependencies gnus-newsgroup-name t) |
5591 | (gnus-get-newsgroup-headers dependencies force-new)) | |
0afb49a1 | 5592 | (gnus-message 7 "Fetching headers for %s...done" name)))) |
16409b0b | 5593 | |
6748645f | 5594 | (defun gnus-select-newsgroup (group &optional read-all select-articles) |
eec82323 | 5595 | "Select newsgroup GROUP. |
6748645f LMI |
5596 | If READ-ALL is non-nil, all articles in the group are selected. |
5597 | If SELECT-ARTICLES, only select those articles from GROUP." | |
01c52d31 | 5598 | (let* ((entry (gnus-group-entry group)) |
eec82323 LMI |
5599 | ;;!!! Dirty hack; should be removed. |
5600 | (gnus-summary-ignore-duplicates | |
23f87bed | 5601 | (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual) |
eec82323 LMI |
5602 | t |
5603 | gnus-summary-ignore-duplicates)) | |
5604 | (info (nth 2 entry)) | |
01c52d31 | 5605 | charset articles fetched-articles cached) |
eec82323 LMI |
5606 | |
5607 | (unless (gnus-check-server | |
475e0e0c GM |
5608 | (set (make-local-variable 'gnus-current-select-method) |
5609 | (gnus-find-method-for-group group))) | |
eec82323 | 5610 | (error "Couldn't open server")) |
01c52d31 | 5611 | (setq charset (gnus-group-name-charset gnus-current-select-method group)) |
eec82323 LMI |
5612 | |
5613 | (or (and entry (not (eq (car entry) t))) ; Either it's active... | |
5614 | (gnus-activate-group group) ; Or we can activate it... | |
5615 | (progn ; Or we bug out. | |
c2e9e9ef | 5616 | (when (derived-mode-p 'gnus-summary-mode) |
23f87bed | 5617 | (gnus-kill-buffer (current-buffer))) |
01c52d31 MB |
5618 | (error |
5619 | "Couldn't activate group %s: %s" | |
5620 | (mm-decode-coding-string group charset) | |
5621 | (mm-decode-coding-string (gnus-status-message group) charset)))) | |
eec82323 LMI |
5622 | |
5623 | (unless (gnus-request-group group t) | |
c2e9e9ef | 5624 | (when (derived-mode-p 'gnus-summary-mode) |
20a673b2 KY |
5625 | (gnus-kill-buffer (current-buffer))) |
5626 | (error "Couldn't request group %s: %s" | |
5627 | (mm-decode-coding-string group charset) | |
5628 | (mm-decode-coding-string (gnus-status-message group) charset))) | |
eec82323 | 5629 | |
54b6f6ed G |
5630 | (when (and gnus-agent |
5631 | (gnus-active group)) | |
54506618 | 5632 | (gnus-agent-possibly-alter-active group (gnus-active group) info) |
132cf96d | 5633 | |
23f87bed MB |
5634 | (setq gnus-summary-use-undownloaded-faces |
5635 | (gnus-agent-find-parameter | |
5636 | group | |
5637 | 'agent-enable-undownloaded-faces))) | |
5638 | ||
5639 | (setq gnus-newsgroup-name group | |
5640 | gnus-newsgroup-unselected nil | |
5641 | gnus-newsgroup-unreads (gnus-list-of-unread-articles group)) | |
5642 | ||
5643 | (let ((display (gnus-group-find-parameter group 'display))) | |
5644 | (setq gnus-newsgroup-display | |
5645 | (cond | |
5646 | ((not (zerop (or (car-safe read-all) 0))) | |
5647 | ;; The user entered the group with C-u SPC/RET, let's show | |
5648 | ;; all articles. | |
5649 | 'gnus-not-ignore) | |
5650 | ((eq display 'all) | |
5651 | 'gnus-not-ignore) | |
5652 | ((arrayp display) | |
5653 | (gnus-summary-display-make-predicate (mapcar 'identity display))) | |
5654 | ((numberp display) | |
5655 | ;; The following is probably the "correct" solution, but | |
5656 | ;; it makes Gnus fetch all headers and then limit the | |
5657 | ;; articles (which is slow), so instead we hack the | |
5658 | ;; select-articles parameter instead. -- Simon Josefsson | |
5659 | ;; <jas@kth.se> | |
5660 | ;; | |
5661 | ;; (gnus-byte-compile | |
5662 | ;; `(lambda () (> number ,(- (cdr (gnus-active group)) | |
5663 | ;; display))))) | |
5664 | (setq select-articles | |
5665 | (gnus-uncompress-range | |
5666 | (cons (let ((tmp (- (cdr (gnus-active group)) display))) | |
5667 | (if (> tmp 0) | |
5668 | tmp | |
5669 | 1)) | |
5670 | (cdr (gnus-active group))))) | |
5671 | nil) | |
5672 | (t | |
5673 | nil)))) | |
eec82323 | 5674 | |
23f87bed | 5675 | (gnus-summary-setup-default-charset) |
eec82323 LMI |
5676 | |
5677 | ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
5678 | (when (gnus-virtual-group-p group) | |
5679 | (setq cached gnus-newsgroup-cached)) | |
5680 | ||
5681 | (setq gnus-newsgroup-unreads | |
23f87bed MB |
5682 | (gnus-sorted-ndifference |
5683 | (gnus-sorted-ndifference gnus-newsgroup-unreads | |
5684 | gnus-newsgroup-marked) | |
eec82323 LMI |
5685 | gnus-newsgroup-dormant)) |
5686 | ||
5687 | (setq gnus-newsgroup-processable nil) | |
5688 | ||
bb7f5cbc | 5689 | (gnus-update-read-articles group gnus-newsgroup-unreads t) |
eec82323 | 5690 | |
23f87bed MB |
5691 | ;; Adjust and set lists of article marks. |
5692 | (when info | |
5693 | (gnus-adjust-marked-articles info)) | |
6748645f LMI |
5694 | (if (setq articles select-articles) |
5695 | (setq gnus-newsgroup-unselected | |
23f87bed | 5696 | (gnus-sorted-difference gnus-newsgroup-unreads articles)) |
6748645f | 5697 | (setq articles (gnus-articles-to-read group read-all))) |
eec82323 LMI |
5698 | |
5699 | (cond | |
5700 | ((null articles) | |
5701 | ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display") | |
5702 | 'quit) | |
5703 | ((eq articles 0) nil) | |
5704 | (t | |
5705 | ;; Init the dependencies hash table. | |
5706 | (setq gnus-newsgroup-dependencies | |
5707 | (gnus-make-hashtable (length articles))) | |
59aadc36 G |
5708 | (if (gnus-buffer-live-p gnus-group-buffer) |
5709 | (gnus-set-global-variables) | |
5710 | (set-default 'gnus-newsgroup-name gnus-newsgroup-name)) | |
eec82323 | 5711 | ;; Retrieve the headers and read them in. |
23f87bed MB |
5712 | |
5713 | (setq gnus-newsgroup-headers (gnus-fetch-headers articles)) | |
eec82323 LMI |
5714 | |
5715 | ;; Kludge to avoid having cached articles nixed out in virtual groups. | |
5716 | (when cached | |
5717 | (setq gnus-newsgroup-cached cached)) | |
5718 | ||
5719 | ;; Suppress duplicates? | |
5720 | (when gnus-suppress-duplicates | |
5721 | (gnus-dup-suppress-articles)) | |
5722 | ||
5723 | ;; Set the initial limit. | |
5724 | (setq gnus-newsgroup-limit (copy-sequence articles)) | |
5725 | ;; Remove canceled articles from the list of unread articles. | |
23f87bed MB |
5726 | (setq fetched-articles |
5727 | (mapcar (lambda (headers) (mail-header-number headers)) | |
5728 | gnus-newsgroup-headers)) | |
5729 | (setq gnus-newsgroup-articles fetched-articles) | |
eec82323 | 5730 | (setq gnus-newsgroup-unreads |
23f87bed MB |
5731 | (gnus-sorted-nintersection |
5732 | gnus-newsgroup-unreads fetched-articles)) | |
5733 | (gnus-compute-unseen-list) | |
5734 | ||
eec82323 LMI |
5735 | ;; Removed marked articles that do not exist. |
5736 | (gnus-update-missing-marks | |
23f87bed | 5737 | (gnus-sorted-difference articles fetched-articles)) |
eec82323 | 5738 | ;; We might want to build some more threads first. |
6748645f LMI |
5739 | (when (and gnus-fetch-old-headers |
5740 | (eq gnus-headers-retrieved-by 'nov)) | |
5741 | (if (eq gnus-fetch-old-headers 'invisible) | |
5742 | (gnus-build-all-threads) | |
5743 | (gnus-build-old-threads))) | |
5744 | ;; Let the Gnus agent mark articles as read. | |
5745 | (when gnus-agent | |
5746 | (gnus-agent-get-undownloaded-list)) | |
16409b0b | 5747 | ;; Remove list identifiers from subject |
d6cd56f1 | 5748 | (gnus-summary-remove-list-identifiers) |
eec82323 LMI |
5749 | ;; Check whether auto-expire is to be done in this group. |
5750 | (setq gnus-newsgroup-auto-expire | |
b5244046 LMI |
5751 | (and (gnus-group-auto-expirable-p group) |
5752 | (not (gnus-group-read-only-p group)))) | |
eec82323 | 5753 | ;; Set up the article buffer now, if necessary. |
01c52d31 MB |
5754 | (unless (and gnus-single-article-buffer |
5755 | (equal gnus-article-buffer "*Article*")) | |
eec82323 LMI |
5756 | (gnus-article-setup-buffer)) |
5757 | ;; First and last article in this newsgroup. | |
5758 | (when gnus-newsgroup-headers | |
5759 | (setq gnus-newsgroup-begin | |
5760 | (mail-header-number (car gnus-newsgroup-headers)) | |
5761 | gnus-newsgroup-end | |
5762 | (mail-header-number | |
5763 | (gnus-last-element gnus-newsgroup-headers)))) | |
5764 | ;; GROUP is successfully selected. | |
5765 | (or gnus-newsgroup-headers t))))) | |
5766 | ||
23f87bed MB |
5767 | (defun gnus-compute-unseen-list () |
5768 | ;; The `seen' marks are treated specially. | |
5769 | (if (not gnus-newsgroup-seen) | |
5770 | (setq gnus-newsgroup-unseen gnus-newsgroup-articles) | |
5771 | (setq gnus-newsgroup-unseen | |
5772 | (gnus-inverse-list-range-intersection | |
5773 | gnus-newsgroup-articles gnus-newsgroup-seen)))) | |
5774 | ||
d09ae6ca GM |
5775 | (declare-function gnus-get-predicate "gnus-agent" (predicate)) |
5776 | ||
23f87bed MB |
5777 | (defun gnus-summary-display-make-predicate (display) |
5778 | (require 'gnus-agent) | |
5779 | (when (= (length display) 1) | |
5780 | (setq display (car display))) | |
5781 | (unless gnus-summary-display-cache | |
5782 | (dolist (elem (append '((unread . unread) | |
5783 | (read . read) | |
5784 | (unseen . unseen)) | |
5785 | gnus-article-mark-lists)) | |
5786 | (push (cons (cdr elem) | |
3a3cbf0a | 5787 | (gnus-byte-compile ;Why bother? |
23f87bed MB |
5788 | `(lambda () (gnus-article-marked-p ',(cdr elem))))) |
5789 | gnus-summary-display-cache))) | |
5790 | (let ((gnus-category-predicate-alist gnus-summary-display-cache) | |
5791 | (gnus-category-predicate-cache gnus-summary-display-cache)) | |
5792 | (gnus-get-predicate display))) | |
5793 | ||
3a3cbf0a SM |
5794 | ;; Uses the dynamically bound `gnus-number' variable. |
5795 | (defvar gnus-number) | |
23f87bed | 5796 | (defun gnus-article-marked-p (type &optional article) |
3a3cbf0a | 5797 | (let ((article (or article gnus-number))) |
23f87bed MB |
5798 | (cond |
5799 | ((eq type 'tick) | |
5800 | (memq article gnus-newsgroup-marked)) | |
5801 | ((eq type 'spam) | |
5802 | (memq article gnus-newsgroup-spam-marked)) | |
5803 | ((eq type 'unsend) | |
5804 | (memq article gnus-newsgroup-unsendable)) | |
5805 | ((eq type 'undownload) | |
5806 | (memq article gnus-newsgroup-undownloaded)) | |
5807 | ((eq type 'download) | |
5808 | (memq article gnus-newsgroup-downloadable)) | |
5809 | ((eq type 'unread) | |
5810 | (memq article gnus-newsgroup-unreads)) | |
5811 | ((eq type 'read) | |
5812 | (memq article gnus-newsgroup-reads)) | |
5813 | ((eq type 'dormant) | |
5814 | (memq article gnus-newsgroup-dormant) ) | |
5815 | ((eq type 'expire) | |
5816 | (memq article gnus-newsgroup-expirable)) | |
5817 | ((eq type 'reply) | |
5818 | (memq article gnus-newsgroup-replied)) | |
5819 | ((eq type 'killed) | |
5820 | (memq article gnus-newsgroup-killed)) | |
5821 | ((eq type 'bookmark) | |
5822 | (assq article gnus-newsgroup-bookmarks)) | |
5823 | ((eq type 'score) | |
5824 | (assq article gnus-newsgroup-scored)) | |
5825 | ((eq type 'save) | |
5826 | (memq article gnus-newsgroup-saved)) | |
5827 | ((eq type 'cache) | |
5828 | (memq article gnus-newsgroup-cached)) | |
5829 | ((eq type 'forward) | |
5830 | (memq article gnus-newsgroup-forwarded)) | |
5831 | ((eq type 'seen) | |
5832 | (not (memq article gnus-newsgroup-unseen))) | |
23f87bed MB |
5833 | (t t)))) |
5834 | ||
eec82323 | 5835 | (defun gnus-articles-to-read (group &optional read-all) |
16409b0b | 5836 | "Find out what articles the user wants to read." |
4c7468f6 LMI |
5837 | (let* ((only-read-p t) |
5838 | (articles | |
eaa610c3 | 5839 | (gnus-list-range-difference |
eec82323 LMI |
5840 | ;; Select all articles if `read-all' is non-nil, or if there |
5841 | ;; are no unread articles. | |
5842 | (if (or read-all | |
5843 | (and (zerop (length gnus-newsgroup-marked)) | |
5844 | (zerop (length gnus-newsgroup-unreads))) | |
23f87bed MB |
5845 | ;; Fetch all if the predicate is non-nil. |
5846 | gnus-newsgroup-display) | |
5847 | ;; We want to select the headers for all the articles in | |
5848 | ;; the group, so we select either all the active | |
5849 | ;; articles in the group, or (if that's nil), the | |
5850 | ;; articles in the cache. | |
16409b0b | 5851 | (or |
4b70e299 | 5852 | (if gnus-newsgroup-maximum-articles |
11abff8e MB |
5853 | (let ((active (gnus-active group))) |
5854 | (gnus-uncompress-range | |
5855 | (cons (max (car active) | |
4b70e299 MB |
5856 | (- (cdr active) |
5857 | gnus-newsgroup-maximum-articles | |
5858 | -1)) | |
11abff8e MB |
5859 | (cdr active)))) |
5860 | (gnus-uncompress-range (gnus-active group))) | |
16409b0b | 5861 | (gnus-cache-articles-in-group group)) |
23f87bed | 5862 | ;; Select only the "normal" subset of articles. |
4c7468f6 | 5863 | (setq only-read-p nil) |
23f87bed MB |
5864 | (gnus-sorted-nunion |
5865 | (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked) | |
eaa610c3 KY |
5866 | gnus-newsgroup-unreads)) |
5867 | (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group)))))) | |
eec82323 LMI |
5868 | (scored-list (gnus-killed-articles gnus-newsgroup-killed articles)) |
5869 | (scored (length scored-list)) | |
5870 | (number (length articles)) | |
5871 | (marked (+ (length gnus-newsgroup-marked) | |
5872 | (length gnus-newsgroup-dormant))) | |
5873 | (select | |
5874 | (cond | |
5875 | ((numberp read-all) | |
5876 | read-all) | |
23f87bed MB |
5877 | ((numberp gnus-newsgroup-display) |
5878 | gnus-newsgroup-display) | |
eec82323 LMI |
5879 | (t |
5880 | (condition-case () | |
5881 | (cond | |
5882 | ((and (or (<= scored marked) (= scored number)) | |
5883 | (numberp gnus-large-newsgroup) | |
5884 | (> number gnus-large-newsgroup)) | |
23f87bed MB |
5885 | (let* ((cursor-in-echo-area nil) |
5886 | (initial (gnus-parameter-large-newsgroup-initial | |
5887 | gnus-newsgroup-name)) | |
4c7468f6 LMI |
5888 | (default (if only-read-p |
5889 | (or initial gnus-large-newsgroup) | |
5890 | number)) | |
23f87bed MB |
5891 | (input |
5892 | (read-string | |
4c7468f6 LMI |
5893 | (if only-read-p |
5894 | (format | |
56c31147 | 5895 | "How many articles from %s (available %d, default %d): " |
4c7468f6 LMI |
5896 | (gnus-group-decoded-name |
5897 | (gnus-group-real-name gnus-newsgroup-name)) | |
56c31147 LMI |
5898 | number default) |
5899 | (format | |
5900 | "How many articles from %s (%d default): " | |
5901 | (gnus-group-decoded-name | |
5902 | (gnus-group-real-name gnus-newsgroup-name)) | |
5903 | default)) | |
a123622d G |
5904 | nil |
5905 | nil | |
4c7468f6 | 5906 | (number-to-string default)))) |
eec82323 LMI |
5907 | (if (string-match "^[ \t]*$" input) number input))) |
5908 | ((and (> scored marked) (< scored number) | |
5909 | (> (- scored number) 20)) | |
5910 | (let ((input | |
5911 | (read-string | |
5912 | (format "%s %s (%d scored, %d total): " | |
5913 | "How many articles from" | |
448e0f79 LMI |
5914 | (gnus-group-decoded-name |
5915 | (gnus-group-real-name gnus-newsgroup-name)) | |
23f87bed | 5916 | scored number)))) |
eec82323 LMI |
5917 | (if (string-match "^[ \t]*$" input) |
5918 | number input))) | |
5919 | (t number)) | |
d4dfaa19 DL |
5920 | (quit |
5921 | (message "Quit getting the articles to read") | |
5922 | nil)))))) | |
eec82323 LMI |
5923 | (setq select (if (stringp select) (string-to-number select) select)) |
5924 | (if (or (null select) (zerop select)) | |
5925 | select | |
5926 | (if (and (not (zerop scored)) (<= (abs select) scored)) | |
5927 | (progn | |
5928 | (setq articles (sort scored-list '<)) | |
5929 | (setq number (length articles))) | |
5930 | (setq articles (copy-sequence articles))) | |
5931 | ||
5932 | (when (< (abs select) number) | |
5933 | (if (< select 0) | |
5934 | ;; Select the N oldest articles. | |
5935 | (setcdr (nthcdr (1- (abs select)) articles) nil) | |
5936 | ;; Select the N most recent articles. | |
5937 | (setq articles (nthcdr (- number select) articles)))) | |
5938 | (setq gnus-newsgroup-unselected | |
23f87bed | 5939 | (gnus-sorted-difference gnus-newsgroup-unreads articles)) |
16409b0b | 5940 | (when gnus-alter-articles-to-read-function |
23f87bed | 5941 | (setq articles |
a1506d29 | 5942 | (sort |
16409b0b | 5943 | (funcall gnus-alter-articles-to-read-function |
23f87bed | 5944 | gnus-newsgroup-name articles) |
16409b0b | 5945 | '<))) |
eec82323 LMI |
5946 | articles))) |
5947 | ||
5948 | (defun gnus-killed-articles (killed articles) | |
5949 | (let (out) | |
5950 | (while articles | |
5951 | (when (inline (gnus-member-of-range (car articles) killed)) | |
5952 | (push (car articles) out)) | |
5953 | (setq articles (cdr articles))) | |
5954 | out)) | |
5955 | ||
23f87bed MB |
5956 | (defun gnus-article-mark-to-type (mark) |
5957 | "Return the type of MARK." | |
5958 | (or (cadr (assq mark gnus-article-special-mark-lists)) | |
5959 | 'list)) | |
5960 | ||
5961 | (defun gnus-article-unpropagatable-p (mark) | |
5962 | "Return whether MARK should be propagated to back end." | |
5963 | (memq mark gnus-article-unpropagated-mark-lists)) | |
5964 | ||
eec82323 | 5965 | (defun gnus-adjust-marked-articles (info) |
16409b0b | 5966 | "Set all article lists and remove all marks that are no longer valid." |
eec82323 LMI |
5967 | (let* ((marked-lists (gnus-info-marks info)) |
5968 | (active (gnus-active (gnus-info-group info))) | |
5969 | (min (car active)) | |
5970 | (max (cdr active)) | |
5971 | (types gnus-article-mark-lists) | |
54506618 MB |
5972 | marks var articles article mark mark-type |
5973 | bgn end) | |
0617bb00 LMI |
5974 | ;; Hack to avoid adjusting marks for imap. |
5975 | (when (eq (car (gnus-find-method-for-group (gnus-info-group info))) | |
5976 | 'nnimap) | |
5977 | (setq min 1)) | |
eec82323 | 5978 | |
23f87bed MB |
5979 | (dolist (marks marked-lists) |
5980 | (setq mark (car marks) | |
5981 | mark-type (gnus-article-mark-to-type mark) | |
5982 | var (intern (format "gnus-newsgroup-%s" (car (rassq mark types))))) | |
23f87bed MB |
5983 | ;; We set the variable according to the type of the marks list, |
5984 | ;; and then adjust the marks to a subset of the active articles. | |
eec82323 | 5985 | (cond |
54506618 | 5986 | ;; Adjust "simple" lists - compressed yet unsorted |
23f87bed | 5987 | ((eq mark-type 'list) |
54506618 MB |
5988 | ;; Simultaneously uncompress and clip to active range |
5989 | ;; See gnus-uncompress-range for a description of possible marks | |
5990 | (let (l lh) | |
5991 | (if (not (cadr marks)) | |
5992 | (set var nil) | |
5993 | (setq articles (if (numberp (cddr marks)) | |
5994 | (list (cdr marks)) | |
5995 | (cdr marks)) | |
5996 | lh (cons nil nil) | |
5997 | l lh) | |
5998 | ||
5999 | (while (setq article (pop articles)) | |
6000 | (cond ((consp article) | |
6001 | (setq bgn (max (car article) min) | |
6002 | end (min (cdr article) max)) | |
6003 | (while (<= bgn end) | |
6004 | (setq l (setcdr l (cons bgn nil)) | |
6005 | bgn (1+ bgn)))) | |
6006 | ((and (<= min article) | |
6007 | (>= max article)) | |
6008 | (setq l (setcdr l (cons article nil)))))) | |
6009 | (set var (cdr lh))))) | |
eec82323 | 6010 | ;; Adjust assocs. |
23f87bed MB |
6011 | ((eq mark-type 'tuple) |
6012 | (set var (setq articles (cdr marks))) | |
a8151ef7 LMI |
6013 | (when (not (listp (cdr (symbol-value var)))) |
6014 | (set var (list (symbol-value var)))) | |
6015 | (when (not (listp (cdr articles))) | |
6016 | (setq articles (list articles))) | |
eec82323 LMI |
6017 | (while articles |
6018 | (when (or (not (consp (setq article (pop articles)))) | |
6019 | (< (car article) min) | |
6020 | (> (car article) max)) | |
23f87bed MB |
6021 | (set var (delq article (symbol-value var)))))) |
6022 | ;; Adjust ranges (sloppily). | |
6023 | ((eq mark-type 'range) | |
6024 | (cond | |
6025 | ((eq mark 'seen) | |
6026 | ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2). | |
6027 | ;; It should be (seen (NUM1 . NUM2)). | |
6028 | (when (numberp (cddr marks)) | |
6029 | (setcdr marks (list (cdr marks)))) | |
6030 | (setq articles (cdr marks)) | |
6031 | (while (and articles | |
6032 | (or (and (consp (car articles)) | |
6033 | (> min (cdar articles))) | |
6034 | (and (numberp (car articles)) | |
6035 | (> min (car articles))))) | |
6036 | (pop articles)) | |
eaa610c3 KY |
6037 | (set var articles)) |
6038 | ((eq mark 'unexist) | |
6039 | (set var (cdr marks))))))))) | |
eec82323 LMI |
6040 | |
6041 | (defun gnus-update-missing-marks (missing) | |
6748645f | 6042 | "Go through the list of MISSING articles and remove them from the mark lists." |
eec82323 | 6043 | (when missing |
23f87bed | 6044 | (let (var m) |
eec82323 | 6045 | ;; Go through all types. |
23f87bed MB |
6046 | (dolist (elem gnus-article-mark-lists) |
6047 | (when (eq (gnus-article-mark-to-type (cdr elem)) 'list) | |
6048 | (setq var (intern (format "gnus-newsgroup-%s" (car elem)))) | |
6049 | (when (symbol-value var) | |
6050 | ;; This list has articles. So we delete all missing | |
6051 | ;; articles from it. | |
6052 | (setq m missing) | |
6053 | (while m | |
6054 | (set var (delq (pop m) (symbol-value var)))))))))) | |
eec82323 LMI |
6055 | |
6056 | (defun gnus-update-marks () | |
6057 | "Enter the various lists of marked articles into the newsgroup info list." | |
6058 | (let ((types gnus-article-mark-lists) | |
6059 | (info (gnus-get-info gnus-newsgroup-name)) | |
16409b0b | 6060 | type list newmarked symbol delta-marks) |
eec82323 | 6061 | (when info |
16409b0b | 6062 | ;; Add all marks lists to the list of marks lists. |
eec82323 | 6063 | (while (setq type (pop types)) |
16409b0b GM |
6064 | (setq list (symbol-value |
6065 | (setq symbol | |
23f87bed | 6066 | (intern (format "gnus-newsgroup-%s" (car type)))))) |
eec82323 | 6067 | |
16409b0b | 6068 | (when list |
eec82323 LMI |
6069 | ;; Get rid of the entries of the articles that have the |
6070 | ;; default score. | |
6071 | (when (and (eq (cdr type) 'score) | |
6072 | gnus-save-score | |
6073 | list) | |
6074 | (let* ((arts list) | |
6075 | (prev (cons nil list)) | |
6076 | (all prev)) | |
6077 | (while arts | |
6078 | (if (or (not (consp (car arts))) | |
6079 | (= (cdar arts) gnus-summary-default-score)) | |
6080 | (setcdr prev (cdr arts)) | |
6081 | (setq prev arts)) | |
6082 | (setq arts (cdr arts))) | |
16409b0b GM |
6083 | (setq list (cdr all))))) |
6084 | ||
23f87bed MB |
6085 | (when (eq (cdr type) 'seen) |
6086 | (setq list (gnus-range-add list gnus-newsgroup-unseen))) | |
6087 | ||
6088 | (when (eq (gnus-article-mark-to-type (cdr type)) 'list) | |
16409b0b | 6089 | (setq list (gnus-compress-sequence (set symbol (sort list '<)) t))) |
a1506d29 | 6090 | |
23f87bed MB |
6091 | (when (and (gnus-check-backend-function |
6092 | 'request-set-mark gnus-newsgroup-name) | |
6093 | (not (gnus-article-unpropagatable-p (cdr type)))) | |
6094 | (let* ((old (cdr (assq (cdr type) (gnus-info-marks info)))) | |
a5954fa5 G |
6095 | ;; Don't do anything about marks for articles we |
6096 | ;; didn't actually get any headers for. | |
a5954fa5 | 6097 | (del |
d451951a LMI |
6098 | (gnus-list-range-intersection |
6099 | gnus-newsgroup-articles | |
6100 | (gnus-remove-from-range (gnus-copy-sequence old) list))) | |
a5954fa5 | 6101 | (add |
d451951a LMI |
6102 | (gnus-list-range-intersection |
6103 | gnus-newsgroup-articles | |
6104 | (gnus-remove-from-range | |
6105 | (gnus-copy-sequence list) old)))) | |
23f87bed MB |
6106 | (when add |
6107 | (push (list add 'add (list (cdr type))) delta-marks)) | |
6108 | (when del | |
a5954fa5 G |
6109 | ;; Don't delete marks from outside the active range. |
6110 | ;; This shouldn't happen, but is a sanity check. | |
b069e5a6 G |
6111 | (setq del (gnus-sorted-range-intersection |
6112 | (gnus-active gnus-newsgroup-name) del)) | |
23f87bed | 6113 | (push (list del 'del (list (cdr type))) delta-marks)))) |
a1506d29 | 6114 | |
eaa610c3 KY |
6115 | (when (or list |
6116 | (eq (cdr type) 'unexist)) | |
16409b0b GM |
6117 | (push (cons (cdr type) list) newmarked))) |
6118 | ||
6119 | (when delta-marks | |
6120 | (unless (gnus-check-group gnus-newsgroup-name) | |
6121 | (error "Can't open server for %s" gnus-newsgroup-name)) | |
6122 | (gnus-request-set-mark gnus-newsgroup-name delta-marks)) | |
a1506d29 | 6123 | |
eec82323 LMI |
6124 | ;; Enter these new marks into the info of the group. |
6125 | (if (nthcdr 3 info) | |
6126 | (setcar (nthcdr 3 info) newmarked) | |
6127 | ;; Add the marks lists to the end of the info. | |
6128 | (when newmarked | |
6129 | (setcdr (nthcdr 2 info) (list newmarked)))) | |
6130 | ||
6131 | ;; Cut off the end of the info if there's nothing else there. | |
6132 | (let ((i 5)) | |
6133 | (while (and (> i 2) | |
6134 | (not (nth i info))) | |
6135 | (when (nthcdr (decf i) info) | |
6136 | (setcdr (nthcdr i info) nil))))))) | |
6137 | ||
6138 | (defun gnus-set-mode-line (where) | |
16409b0b | 6139 | "Set the mode line of the article or summary buffers. |
eec82323 LMI |
6140 | If WHERE is `summary', the summary mode line format will be used." |
6141 | ;; Is this mode line one we keep updated? | |
16409b0b GM |
6142 | (when (and (memq where gnus-updated-mode-lines) |
6143 | (symbol-value | |
6144 | (intern (format "gnus-%s-mode-line-format-spec" where)))) | |
eec82323 | 6145 | (let (mode-string) |
c7a91ce1 SM |
6146 | ;; We evaluate this in the summary buffer since these |
6147 | ;; variables are buffer-local to that buffer. | |
6148 | (with-current-buffer gnus-summary-buffer | |
6149 | ;; We bind all these variables that are used in the `eval' form | |
eec82323 LMI |
6150 | ;; below. |
6151 | (let* ((mformat (symbol-value | |
6152 | (intern | |
6153 | (format "gnus-%s-mode-line-format-spec" where)))) | |
b90a6149 MB |
6154 | (gnus-tmp-group-name (gnus-mode-string-quote |
6155 | (gnus-group-decoded-name | |
6156 | gnus-newsgroup-name))) | |
eec82323 LMI |
6157 | (gnus-tmp-article-number (or gnus-current-article 0)) |
6158 | (gnus-tmp-unread gnus-newsgroup-unreads) | |
6159 | (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads)) | |
6160 | (gnus-tmp-unselected (length gnus-newsgroup-unselected)) | |
6161 | (gnus-tmp-unread-and-unselected | |
6162 | (cond ((and (zerop gnus-tmp-unread-and-unticked) | |
6163 | (zerop gnus-tmp-unselected)) | |
6164 | "") | |
6165 | ((zerop gnus-tmp-unselected) | |
6166 | (format "{%d more}" gnus-tmp-unread-and-unticked)) | |
6167 | (t (format "{%d(+%d) more}" | |
6168 | gnus-tmp-unread-and-unticked | |
6169 | gnus-tmp-unselected)))) | |
6170 | (gnus-tmp-subject | |
6171 | (if (and gnus-current-headers | |
6172 | (vectorp gnus-current-headers)) | |
6173 | (gnus-mode-string-quote | |
6174 | (mail-header-subject gnus-current-headers)) | |
6175 | "")) | |
6176 | bufname-length max-len | |
23f87bed | 6177 | gnus-tmp-header) ;; passed as argument to any user-format-funcs |
eec82323 LMI |
6178 | (setq mode-string (eval mformat)) |
6179 | (setq bufname-length (if (string-match "%b" mode-string) | |
6180 | (- (length | |
6181 | (buffer-name | |
6182 | (if (eq where 'summary) | |
6183 | nil | |
6184 | (get-buffer gnus-article-buffer)))) | |
6185 | 2) | |
6186 | 0)) | |
6187 | (setq max-len (max 4 (if gnus-mode-non-string-length | |
6188 | (- (window-width) | |
6189 | gnus-mode-non-string-length | |
6190 | bufname-length) | |
6191 | (length mode-string)))) | |
6192 | ;; We might have to chop a bit of the string off... | |
6193 | (when (> (length mode-string) max-len) | |
6194 | (setq mode-string | |
16409b0b | 6195 | (concat (truncate-string-to-width mode-string (- max-len 3)) |
29d31b55 | 6196 | "..."))))) |
eec82323 LMI |
6197 | ;; Update the mode line. |
6198 | (setq mode-line-buffer-identification | |
6199 | (gnus-mode-line-buffer-identification (list mode-string))) | |
6200 | (set-buffer-modified-p t)))) | |
6201 | ||
6202 | (defun gnus-create-xref-hashtb (from-newsgroup headers unreads) | |
6203 | "Go through the HEADERS list and add all Xrefs to a hash table. | |
6204 | The resulting hash table is returned, or nil if no Xrefs were found." | |
6205 | (let* ((virtual (gnus-virtual-group-p from-newsgroup)) | |
6206 | (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup))) | |
6207 | (xref-hashtb (gnus-make-hashtable)) | |
6208 | start group entry number xrefs header) | |
6209 | (while headers | |
6210 | (setq header (pop headers)) | |
6211 | (when (and (setq xrefs (mail-header-xref header)) | |
6212 | (not (memq (setq number (mail-header-number header)) | |
6213 | unreads))) | |
6214 | (setq start 0) | |
6215 | (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start) | |
6216 | (setq start (match-end 0)) | |
6217 | (setq group (if prefix | |
6218 | (concat prefix (substring xrefs (match-beginning 1) | |
6219 | (match-end 1))) | |
6220 | (substring xrefs (match-beginning 1) (match-end 1)))) | |
6221 | (setq number | |
e9bd5782 | 6222 | (string-to-number (substring xrefs (match-beginning 2) |
eec82323 LMI |
6223 | (match-end 2)))) |
6224 | (if (setq entry (gnus-gethash group xref-hashtb)) | |
6225 | (setcdr entry (cons number (cdr entry))) | |
6226 | (gnus-sethash group (cons number nil) xref-hashtb))))) | |
6227 | (and start xref-hashtb))) | |
6228 | ||
6229 | (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads) | |
6230 | "Look through all the headers and mark the Xrefs as read." | |
6231 | (let ((virtual (gnus-virtual-group-p from-newsgroup)) | |
01c52d31 | 6232 | name info xref-hashtb idlist method nth4) |
398a825b | 6233 | (with-current-buffer gnus-group-buffer |
eec82323 LMI |
6234 | (when (setq xref-hashtb |
6235 | (gnus-create-xref-hashtb from-newsgroup headers unreads)) | |
6236 | (mapatoms | |
6237 | (lambda (group) | |
6238 | (unless (string= from-newsgroup (setq name (symbol-name group))) | |
6239 | (setq idlist (symbol-value group)) | |
6240 | ;; Dead groups are not updated. | |
6241 | (and (prog1 | |
01c52d31 | 6242 | (setq info (gnus-get-info name)) |
eec82323 LMI |
6243 | (when (stringp (setq nth4 (gnus-info-method info))) |
6244 | (setq nth4 (gnus-server-to-method nth4)))) | |
6245 | ;; Only do the xrefs if the group has the same | |
6246 | ;; select method as the group we have just read. | |
6247 | (or (gnus-methods-equal-p | |
6248 | nth4 (gnus-find-method-for-group from-newsgroup)) | |
6249 | virtual | |
6250 | (equal nth4 (setq method (gnus-find-method-for-group | |
6251 | from-newsgroup))) | |
6252 | (and (equal (car nth4) (car method)) | |
6253 | (equal (nth 1 nth4) (nth 1 method)))) | |
6254 | gnus-use-cross-reference | |
6255 | (or (not (eq gnus-use-cross-reference t)) | |
6256 | virtual | |
6257 | ;; Only do cross-references on subscribed | |
6258 | ;; groups, if that is what is wanted. | |
6259 | (<= (gnus-info-level info) gnus-level-subscribed)) | |
6260 | (gnus-group-make-articles-read name idlist)))) | |
6261 | xref-hashtb))))) | |
6262 | ||
6748645f | 6263 | (defun gnus-compute-read-articles (group articles) |
01c52d31 | 6264 | (let* ((entry (gnus-group-entry group)) |
6748645f LMI |
6265 | (info (nth 2 entry)) |
6266 | (active (gnus-active group)) | |
6267 | ninfo) | |
6268 | (when entry | |
16409b0b | 6269 | ;; First peel off all invalid article numbers. |
6748645f LMI |
6270 | (when active |
6271 | (let ((ids articles) | |
6272 | id first) | |
6273 | (while (setq id (pop ids)) | |
6274 | (when (and first (> id (cdr active))) | |
6275 | ;; We'll end up in this situation in one particular | |
6276 | ;; obscure situation. If you re-scan a group and get | |
6277 | ;; a new article that is cross-posted to a different | |
6278 | ;; group that has not been re-scanned, you might get | |
6279 | ;; crossposted article that has a higher number than | |
6280 | ;; Gnus believes possible. So we re-activate this | |
6281 | ;; group as well. This might mean doing the | |
6282 | ;; crossposting thingy will *increase* the number | |
6283 | ;; of articles in some groups. Tsk, tsk. | |
6284 | (setq active (or (gnus-activate-group group) active))) | |
6285 | (when (or (> id (cdr active)) | |
6286 | (< id (car active))) | |
6287 | (setq articles (delq id articles)))))) | |
6288 | ;; If the read list is nil, we init it. | |
6289 | (if (and active | |
6290 | (null (gnus-info-read info)) | |
6291 | (> (car active) 1)) | |
6292 | (setq ninfo (cons 1 (1- (car active)))) | |
6293 | (setq ninfo (gnus-info-read info))) | |
6294 | ;; Then we add the read articles to the range. | |
6295 | (gnus-add-to-range | |
6296 | ninfo (setq articles (sort articles '<)))))) | |
6297 | ||
eec82323 LMI |
6298 | (defun gnus-group-make-articles-read (group articles) |
6299 | "Update the info of GROUP to say that ARTICLES are read." | |
6300 | (let* ((num 0) | |
01c52d31 | 6301 | (entry (gnus-group-entry group)) |
eec82323 LMI |
6302 | (info (nth 2 entry)) |
6303 | (active (gnus-active group)) | |
f4887f8b | 6304 | (set-marks |
89b163db G |
6305 | (gnus-method-option-p |
6306 | (gnus-find-method-for-group group) | |
6307 | 'server-marks)) | |
eec82323 | 6308 | range) |
de635afe G |
6309 | (if (not entry) |
6310 | ;; Group that Gnus doesn't know exists, but still allow the | |
6311 | ;; backend to set marks. | |
f4887f8b G |
6312 | (when set-marks |
6313 | (gnus-request-set-mark | |
6314 | group (list (list (gnus-compress-sequence (sort articles #'<)) | |
6315 | 'add '(read))))) | |
de635afe | 6316 | ;; Normal, subscribed groups. |
6748645f | 6317 | (setq range (gnus-compute-read-articles group articles)) |
01c52d31 | 6318 | (with-current-buffer gnus-group-buffer |
6748645f LMI |
6319 | (gnus-undo-register |
6320 | `(progn | |
6321 | (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
6322 | (gnus-info-set-read ',info ',(gnus-info-read info)) | |
6323 | (gnus-get-unread-articles-in-group ',info (gnus-active ,group)) | |
f4887f8b G |
6324 | (when ,set-marks |
6325 | (gnus-request-set-mark | |
6326 | ,group (list (list ',range 'del '(read))))) | |
6748645f LMI |
6327 | (gnus-group-update-group ,group t)))) |
6328 | ;; Add the read articles to the range. | |
6329 | (gnus-info-set-read info range) | |
f4887f8b G |
6330 | (when set-marks |
6331 | (gnus-request-set-mark group (list (list range 'add '(read))))) | |
6748645f LMI |
6332 | ;; Then we have to re-compute how many unread |
6333 | ;; articles there are in this group. | |
6334 | (when active | |
6335 | (cond | |
6336 | ((not range) | |
6337 | (setq num (- (1+ (cdr active)) (car active)))) | |
6338 | ((not (listp (cdr range))) | |
6339 | (setq num (- (cdr active) (- (1+ (cdr range)) | |
6340 | (car range))))) | |
6341 | (t | |
6342 | (while range | |
6343 | (if (numberp (car range)) | |
6344 | (setq num (1+ num)) | |
6345 | (setq num (+ num (- (1+ (cdar range)) (caar range))))) | |
6346 | (setq range (cdr range))) | |
6347 | (setq num (- (cdr active) num)))) | |
6348 | ;; Update the number of unread articles. | |
6349 | (setcar entry num) | |
6350 | ;; Update the group buffer. | |
23f87bed MB |
6351 | (unless (gnus-ephemeral-group-p group) |
6352 | (gnus-group-update-group group t)))))) | |
eec82323 | 6353 | |
eec82323 LMI |
6354 | (defun gnus-get-newsgroup-headers (&optional dependencies force-new) |
6355 | (let ((cur nntp-server-buffer) | |
6356 | (dependencies | |
6357 | (or dependencies | |
01c52d31 MB |
6358 | (with-current-buffer gnus-summary-buffer |
6359 | gnus-newsgroup-dependencies))) | |
6360 | headers id end ref number | |
16409b0b GM |
6361 | (mail-parse-charset gnus-newsgroup-charset) |
6362 | (mail-parse-ignored-charsets | |
c7a91ce1 SM |
6363 | (save-current-buffer (condition-case nil |
6364 | (set-buffer gnus-summary-buffer) | |
6365 | (error)) | |
6366 | gnus-newsgroup-ignored-charsets))) | |
6367 | (with-current-buffer nntp-server-buffer | |
eec82323 LMI |
6368 | ;; Translate all TAB characters into SPACE characters. |
6369 | (subst-char-in-region (point-min) (point-max) ?\t ? t) | |
16409b0b | 6370 | (subst-char-in-region (point-min) (point-max) ?\r ? t) |
23f87bed | 6371 | (ietf-drums-unfold-fws) |
6748645f | 6372 | (gnus-run-hooks 'gnus-parse-headers-hook) |
eec82323 | 6373 | (let ((case-fold-search t) |
6748645f | 6374 | in-reply-to header p lines chars) |
eec82323 | 6375 | (goto-char (point-min)) |
01ccbb85 | 6376 | ;; Search to the beginning of the next header. Error messages |
eec82323 LMI |
6377 | ;; do not begin with 2 or 3. |
6378 | (while (re-search-forward "^[23][0-9]+ " nil t) | |
6379 | (setq id nil | |
6380 | ref nil) | |
6381 | ;; This implementation of this function, with nine | |
6382 | ;; search-forwards instead of the one re-search-forward and | |
6383 | ;; a case (which basically was the old function) is actually | |
01ccbb85 | 6384 | ;; about twice as fast, even though it looks messier. You |
eec82323 LMI |
6385 | ;; can't have everything, I guess. Speed and elegance |
6386 | ;; doesn't always go hand in hand. | |
6387 | (setq | |
6388 | header | |
6389 | (vector | |
6390 | ;; Number. | |
6391 | (prog1 | |
01c52d31 | 6392 | (setq number (read cur)) |
eec82323 LMI |
6393 | (end-of-line) |
6394 | (setq p (point)) | |
6395 | (narrow-to-region (point) | |
6396 | (or (and (search-forward "\n.\n" nil t) | |
6397 | (- (point) 2)) | |
6398 | (point)))) | |
6399 | ;; Subject. | |
6400 | (progn | |
6401 | (goto-char p) | |
23f87bed | 6402 | (if (search-forward "\nsubject:" nil t) |
16409b0b GM |
6403 | (funcall gnus-decode-encoded-word-function |
6404 | (nnheader-header-value)) | |
2bd3dcae | 6405 | "(none)")) |
eec82323 LMI |
6406 | ;; From. |
6407 | (progn | |
6408 | (goto-char p) | |
23f87bed | 6409 | (if (search-forward "\nfrom:" nil t) |
343d6628 | 6410 | (funcall gnus-decode-encoded-address-function |
16409b0b | 6411 | (nnheader-header-value)) |
2bd3dcae | 6412 | "(nobody)")) |
eec82323 LMI |
6413 | ;; Date. |
6414 | (progn | |
6415 | (goto-char p) | |
23f87bed | 6416 | (if (search-forward "\ndate:" nil t) |
eec82323 LMI |
6417 | (nnheader-header-value) "")) |
6418 | ;; Message-ID. | |
6419 | (progn | |
6420 | (goto-char p) | |
6748645f LMI |
6421 | (setq id (if (re-search-forward |
6422 | "^message-id: *\\(<[^\n\t> ]+>\\)" nil t) | |
6423 | ;; We do it this way to make sure the Message-ID | |
6424 | ;; is (somewhat) syntactically valid. | |
6425 | (buffer-substring (match-beginning 1) | |
6426 | (match-end 1)) | |
eec82323 LMI |
6427 | ;; If there was no message-id, we just fake one |
6428 | ;; to make subsequent routines simpler. | |
01c52d31 | 6429 | (nnheader-generate-fake-message-id number)))) |
eec82323 LMI |
6430 | ;; References. |
6431 | (progn | |
6432 | (goto-char p) | |
23f87bed | 6433 | (if (search-forward "\nreferences:" nil t) |
eec82323 LMI |
6434 | (progn |
6435 | (setq end (point)) | |
6436 | (prog1 | |
6437 | (nnheader-header-value) | |
6438 | (setq ref | |
6439 | (buffer-substring | |
6440 | (progn | |
6441 | (end-of-line) | |
6442 | (search-backward ">" end t) | |
6443 | (1+ (point))) | |
6444 | (progn | |
6445 | (search-backward "<" end t) | |
6446 | (point)))))) | |
6447 | ;; Get the references from the in-reply-to header if there | |
6448 | ;; were no references and the in-reply-to header looks | |
6449 | ;; promising. | |
23f87bed | 6450 | (if (and (search-forward "\nin-reply-to:" nil t) |
eec82323 LMI |
6451 | (setq in-reply-to (nnheader-header-value)) |
6452 | (string-match "<[^>]+>" in-reply-to)) | |
6748645f LMI |
6453 | (let (ref2) |
6454 | (setq ref (substring in-reply-to (match-beginning 0) | |
6455 | (match-end 0))) | |
6456 | (while (string-match "<[^>]+>" in-reply-to (match-end 0)) | |
6457 | (setq ref2 (substring in-reply-to (match-beginning 0) | |
6458 | (match-end 0))) | |
6459 | (when (> (length ref2) (length ref)) | |
6460 | (setq ref ref2))) | |
6461 | ref) | |
eec82323 LMI |
6462 | (setq ref nil)))) |
6463 | ;; Chars. | |
6748645f LMI |
6464 | (progn |
6465 | (goto-char p) | |
6466 | (if (search-forward "\nchars: " nil t) | |
6467 | (if (numberp (setq chars (ignore-errors (read cur)))) | |
23f87bed MB |
6468 | chars -1) |
6469 | -1)) | |
eec82323 LMI |
6470 | ;; Lines. |
6471 | (progn | |
6472 | (goto-char p) | |
6473 | (if (search-forward "\nlines: " nil t) | |
a8151ef7 | 6474 | (if (numberp (setq lines (ignore-errors (read cur)))) |
23f87bed MB |
6475 | lines -1) |
6476 | -1)) | |
eec82323 LMI |
6477 | ;; Xref. |
6478 | (progn | |
6479 | (goto-char p) | |
23f87bed | 6480 | (and (search-forward "\nxref:" nil t) |
16409b0b GM |
6481 | (nnheader-header-value))) |
6482 | ;; Extra. | |
6483 | (when gnus-extra-headers | |
6484 | (let ((extra gnus-extra-headers) | |
6485 | out) | |
6486 | (while extra | |
6487 | (goto-char p) | |
6488 | (when (search-forward | |
23f87bed | 6489 | (concat "\n" (symbol-name (car extra)) ":") nil t) |
16409b0b GM |
6490 | (push (cons (car extra) (nnheader-header-value)) |
6491 | out)) | |
6492 | (pop extra)) | |
6493 | out)))) | |
eec82323 LMI |
6494 | (when (equal id ref) |
6495 | (setq ref nil)) | |
6748645f LMI |
6496 | |
6497 | (when gnus-alter-header-function | |
6498 | (funcall gnus-alter-header-function header) | |
6499 | (setq id (mail-header-id header) | |
6500 | ref (gnus-parent-id (mail-header-references header)))) | |
6501 | ||
6502 | (when (setq header | |
6503 | (gnus-dependencies-add-header | |
6504 | header dependencies force-new)) | |
eec82323 LMI |
6505 | (push header headers)) |
6506 | (goto-char (point-max)) | |
6507 | (widen)) | |
6508 | (nreverse headers))))) | |
6509 | ||
eec82323 LMI |
6510 | ;; Goes through the xover lines and returns a list of vectors |
6511 | (defun gnus-get-newsgroup-headers-xover (sequence &optional | |
6512 | force-new dependencies | |
6513 | group also-fetch-heads) | |
16409b0b GM |
6514 | "Parse the news overview data in the server buffer. |
6515 | Return a list of headers that match SEQUENCE (see | |
6516 | `nntp-retrieve-headers')." | |
eec82323 LMI |
6517 | ;; Get the Xref when the users reads the articles since most/some |
6518 | ;; NNTP servers do not include Xrefs when using XOVER. | |
6519 | (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs)) | |
16409b0b GM |
6520 | (let ((mail-parse-charset gnus-newsgroup-charset) |
6521 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets) | |
6522 | (cur nntp-server-buffer) | |
eec82323 | 6523 | (dependencies (or dependencies gnus-newsgroup-dependencies)) |
23f87bed MB |
6524 | (allp (cond |
6525 | ((eq gnus-read-all-available-headers t) | |
6526 | t) | |
14e6dc54 MB |
6527 | ((and (stringp gnus-read-all-available-headers) |
6528 | group) | |
23f87bed MB |
6529 | (string-match gnus-read-all-available-headers group)) |
6530 | (t | |
6531 | nil))) | |
eec82323 | 6532 | number headers header) |
c7a91ce1 | 6533 | (with-current-buffer nntp-server-buffer |
16409b0b | 6534 | (subst-char-in-region (point-min) (point-max) ?\r ? t) |
eec82323 | 6535 | ;; Allow the user to mangle the headers before parsing them. |
6748645f | 6536 | (gnus-run-hooks 'gnus-parse-headers-hook) |
eec82323 | 6537 | (goto-char (point-min)) |
23f87bed MB |
6538 | (gnus-parse-without-error |
6539 | (while (and (or sequence allp) | |
6540 | (not (eobp))) | |
6541 | (setq number (read cur)) | |
6542 | (when (not allp) | |
6543 | (while (and sequence | |
6544 | (< (car sequence) number)) | |
6545 | (setq sequence (cdr sequence)))) | |
6546 | (when (and (or allp | |
6547 | (and sequence | |
6548 | (eq number (car sequence)))) | |
6549 | (progn | |
6550 | (setq sequence (cdr sequence)) | |
6551 | (setq header (inline | |
6552 | (gnus-nov-parse-line | |
6553 | number dependencies force-new))))) | |
6554 | (push header headers)) | |
6555 | (forward-line 1))) | |
eec82323 LMI |
6556 | ;; A common bug in inn is that if you have posted an article and |
6557 | ;; then retrieves the active file, it will answer correctly -- | |
6558 | ;; the new article is included. However, a NOV entry for the | |
6559 | ;; article may not have been generated yet, so this may fail. | |
6560 | ;; We work around this problem by retrieving the last few | |
6561 | ;; headers using HEAD. | |
6562 | (if (or (not also-fetch-heads) | |
6563 | (not sequence)) | |
6564 | ;; We (probably) got all the headers. | |
6565 | (nreverse headers) | |
6566 | (let ((gnus-nov-is-evil t)) | |
6567 | (nconc | |
6568 | (nreverse headers) | |
23f87bed | 6569 | (when (eq (gnus-retrieve-headers sequence group) 'headers) |
eec82323 LMI |
6570 | (gnus-get-newsgroup-headers)))))))) |
6571 | ||
6572 | (defun gnus-article-get-xrefs () | |
6573 | "Fill in the Xref value in `gnus-current-headers', if necessary. | |
6574 | This is meant to be called in `gnus-article-internal-prepare-hook'." | |
01c52d31 MB |
6575 | (let ((headers (with-current-buffer gnus-summary-buffer |
6576 | gnus-current-headers))) | |
eec82323 LMI |
6577 | (or (not gnus-use-cross-reference) |
6578 | (not headers) | |
6579 | (and (mail-header-xref headers) | |
6580 | (not (string= (mail-header-xref headers) ""))) | |
6581 | (let ((case-fold-search t) | |
6582 | xref) | |
6583 | (save-restriction | |
6584 | (nnheader-narrow-to-headers) | |
6585 | (goto-char (point-min)) | |
16409b0b GM |
6586 | (when (or (and (not (eobp)) |
6587 | (eq (downcase (char-after)) ?x) | |
eec82323 LMI |
6588 | (looking-at "Xref:")) |
6589 | (search-forward "\nXref:" nil t)) | |
6590 | (goto-char (1+ (match-end 0))) | |
01c52d31 | 6591 | (setq xref (buffer-substring (point) (point-at-eol))) |
eec82323 LMI |
6592 | (mail-header-set-xref headers xref))))))) |
6593 | ||
6594 | (defun gnus-summary-insert-subject (id &optional old-header use-old-header) | |
6748645f LMI |
6595 | "Find article ID and insert the summary line for that article. |
6596 | OLD-HEADER can either be a header or a line number to insert | |
ae97e645 G |
6597 | the subject line on. |
6598 | If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header, | |
6599 | and OLD-HEADER will be used when the summary line is inserted, | |
6600 | too, instead of trying to fetch new headers." | |
6748645f LMI |
6601 | (let* ((line (and (numberp old-header) old-header)) |
6602 | (old-header (and (vectorp old-header) old-header)) | |
6603 | (header (cond ((and old-header use-old-header) | |
16409b0b GM |
6604 | old-header) |
6605 | ((and (numberp id) | |
6606 | (gnus-number-to-header id)) | |
6607 | (gnus-number-to-header id)) | |
6608 | (t | |
6609 | (gnus-read-header id)))) | |
6610 | (number (and (numberp id) id)) | |
6611 | d) | |
eec82323 LMI |
6612 | (when header |
6613 | ;; Rebuild the thread that this article is part of and go to the | |
6614 | ;; article we have fetched. | |
6615 | (when (and (not gnus-show-threads) | |
6616 | old-header) | |
6748645f LMI |
6617 | (when (and number |
6618 | (setq d (gnus-data-find (mail-header-number old-header)))) | |
eec82323 LMI |
6619 | (goto-char (gnus-data-pos d)) |
6620 | (gnus-data-remove | |
6621 | number | |
01c52d31 | 6622 | (- (point-at-bol) |
eec82323 | 6623 | (prog1 |
01c52d31 | 6624 | (1+ (point-at-eol)) |
eec82323 | 6625 | (gnus-delete-line)))))) |
23f87bed | 6626 | ;; Remove list identifiers from subject. |
d6cd56f1 JD |
6627 | (let ((gnus-newsgroup-headers (list header))) |
6628 | (gnus-summary-remove-list-identifiers)) | |
eec82323 LMI |
6629 | (when old-header |
6630 | (mail-header-set-number header (mail-header-number old-header))) | |
6631 | (setq gnus-newsgroup-sparse | |
6632 | (delq (setq number (mail-header-number header)) | |
6633 | gnus-newsgroup-sparse)) | |
6634 | (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient)) | |
6748645f LMI |
6635 | (push number gnus-newsgroup-limit) |
6636 | (gnus-rebuild-thread (mail-header-id header) line) | |
eec82323 LMI |
6637 | (gnus-summary-goto-subject number nil t)) |
6638 | (when (and (numberp number) | |
6639 | (> number 0)) | |
6640 | ;; We have to update the boundaries even if we can't fetch the | |
6641 | ;; article if ID is a number -- so that the next `P' or `N' | |
6642 | ;; command will fetch the previous (or next) article even | |
6643 | ;; if the one we tried to fetch this time has been canceled. | |
89b163db | 6644 | (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end)) |
eec82323 | 6645 | (setq gnus-newsgroup-end number)) |
89b163db | 6646 | (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin)) |
eec82323 LMI |
6647 | (setq gnus-newsgroup-begin number)) |
6648 | (setq gnus-newsgroup-unselected | |
6649 | (delq number gnus-newsgroup-unselected))) | |
6650 | ;; Report back a success? | |
6651 | (and header (mail-header-number header)))) | |
6652 | ||
6653 | ;;; Process/prefix in the summary buffer | |
6654 | ||
6655 | (defun gnus-summary-work-articles (n) | |
6748645f LMI |
6656 | "Return a list of articles to be worked upon. |
6657 | The prefix argument, the list of process marked articles, and the | |
6658 | current article will be taken into consideration." | |
c7a91ce1 | 6659 | (with-current-buffer gnus-summary-buffer |
6748645f LMI |
6660 | (cond |
6661 | (n | |
6662 | ;; A numerical prefix has been given. | |
6663 | (setq n (prefix-numeric-value n)) | |
6664 | (let ((backward (< n 0)) | |
6665 | (n (abs (prefix-numeric-value n))) | |
6666 | articles article) | |
6667 | (save-excursion | |
6668 | (while | |
6669 | (and (> n 0) | |
6670 | (push (setq article (gnus-summary-article-number)) | |
6671 | articles) | |
6672 | (if backward | |
6673 | (gnus-summary-find-prev nil article) | |
6674 | (gnus-summary-find-next nil article))) | |
6675 | (decf n))) | |
6676 | (nreverse articles))) | |
6677 | ((and (gnus-region-active-p) (mark)) | |
6678 | (message "region active") | |
6679 | ;; Work on the region between point and mark. | |
6680 | (let ((max (max (point) (mark))) | |
6681 | articles article) | |
6682 | (save-excursion | |
7dafe00b | 6683 | (goto-char (min (point) (mark))) |
6748645f LMI |
6684 | (while |
6685 | (and | |
6686 | (push (setq article (gnus-summary-article-number)) articles) | |
6687 | (gnus-summary-find-next nil article) | |
6688 | (< (point) max))) | |
6689 | (nreverse articles)))) | |
6690 | (gnus-newsgroup-processable | |
6691 | ;; There are process-marked articles present. | |
6692 | ;; Save current state. | |
6693 | (gnus-summary-save-process-mark) | |
6694 | ;; Return the list. | |
6695 | (reverse gnus-newsgroup-processable)) | |
6696 | (t | |
6697 | ;; Just return the current article. | |
6698 | (list (gnus-summary-article-number)))))) | |
6699 | ||
6700 | (defmacro gnus-summary-iterate (arg &rest forms) | |
6701 | "Iterate over the process/prefixed articles and do FORMS. | |
6702 | ARG is the interactive prefix given to the command. FORMS will be | |
6703 | executed with point over the summary line of the articles." | |
6704 | (let ((articles (make-symbol "gnus-summary-iterate-articles"))) | |
6705 | `(let ((,articles (gnus-summary-work-articles ,arg))) | |
6706 | (while ,articles | |
6707 | (gnus-summary-goto-subject (car ,articles)) | |
16409b0b GM |
6708 | ,@forms |
6709 | (pop ,articles))))) | |
6748645f LMI |
6710 | |
6711 | (put 'gnus-summary-iterate 'lisp-indent-function 1) | |
6712 | (put 'gnus-summary-iterate 'edebug-form-spec '(form body)) | |
eec82323 LMI |
6713 | |
6714 | (defun gnus-summary-save-process-mark () | |
6715 | "Push the current set of process marked articles on the stack." | |
6716 | (interactive) | |
6717 | (push (copy-sequence gnus-newsgroup-processable) | |
6718 | gnus-newsgroup-process-stack)) | |
6719 | ||
6720 | (defun gnus-summary-kill-process-mark () | |
6721 | "Push the current set of process marked articles on the stack and unmark." | |
6722 | (interactive) | |
6723 | (gnus-summary-save-process-mark) | |
6724 | (gnus-summary-unmark-all-processable)) | |
6725 | ||
6726 | (defun gnus-summary-yank-process-mark () | |
6727 | "Pop the last process mark state off the stack and restore it." | |
6728 | (interactive) | |
6729 | (unless gnus-newsgroup-process-stack | |
6730 | (error "Empty mark stack")) | |
6731 | (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack))) | |
6732 | ||
6733 | (defun gnus-summary-process-mark-set (set) | |
6734 | "Make SET into the current process marked articles." | |
6735 | (gnus-summary-unmark-all-processable) | |
01c52d31 | 6736 | (mapc 'gnus-summary-set-process-mark set)) |
eec82323 LMI |
6737 | |
6738 | ;;; Searching and stuff | |
6739 | ||
6740 | (defun gnus-summary-search-group (&optional backward use-level) | |
6741 | "Search for next unread newsgroup. | |
6742 | If optional argument BACKWARD is non-nil, search backward instead." | |
c7a91ce1 | 6743 | (with-current-buffer gnus-group-buffer |
eec82323 LMI |
6744 | (when (gnus-group-search-forward |
6745 | backward nil (if use-level (gnus-group-group-level) nil)) | |
6746 | (gnus-group-group-name)))) | |
6747 | ||
6748 | (defun gnus-summary-best-group (&optional exclude-group) | |
6749 | "Find the name of the best unread group. | |
6750 | If EXCLUDE-GROUP, do not go to this group." | |
01c52d31 | 6751 | (with-current-buffer gnus-group-buffer |
eec82323 LMI |
6752 | (save-excursion |
6753 | (gnus-group-best-unread-group exclude-group)))) | |
6754 | ||
23f87bed MB |
6755 | (defun gnus-summary-find-next (&optional unread article backward) |
6756 | (if backward | |
6757 | (gnus-summary-find-prev unread article) | |
eec82323 LMI |
6758 | (let* ((dummy (gnus-summary-article-intangible-p)) |
6759 | (article (or article (gnus-summary-article-number))) | |
23f87bed | 6760 | (data (gnus-data-find-list article)) |
eec82323 LMI |
6761 | result) |
6762 | (when (and (not dummy) | |
6763 | (or (not gnus-summary-check-current) | |
6764 | (not unread) | |
23f87bed MB |
6765 | (not (gnus-data-unread-p (car data))))) |
6766 | (setq data (cdr data))) | |
eec82323 LMI |
6767 | (when (setq result |
6768 | (if unread | |
6769 | (progn | |
23f87bed MB |
6770 | (while data |
6771 | (unless (memq (gnus-data-number (car data)) | |
6772 | (cond | |
6773 | ((eq gnus-auto-goto-ignores | |
6774 | 'always-undownloaded) | |
6775 | gnus-newsgroup-undownloaded) | |
6776 | (gnus-plugged | |
6777 | nil) | |
6778 | ((eq gnus-auto-goto-ignores | |
6779 | 'unfetched) | |
6780 | gnus-newsgroup-unfetched) | |
6781 | ((eq gnus-auto-goto-ignores | |
6782 | 'undownloaded) | |
6783 | gnus-newsgroup-undownloaded))) | |
6784 | (when (gnus-data-unread-p (car data)) | |
6785 | (setq result (car data) | |
6786 | data nil))) | |
6787 | (setq data (cdr data))) | |
eec82323 | 6788 | result) |
23f87bed | 6789 | (car data))) |
eec82323 LMI |
6790 | (goto-char (gnus-data-pos result)) |
6791 | (gnus-data-number result))))) | |
6792 | ||
6793 | (defun gnus-summary-find-prev (&optional unread article) | |
6794 | (let* ((eobp (eobp)) | |
6795 | (article (or article (gnus-summary-article-number))) | |
23f87bed | 6796 | (data (gnus-data-find-list article (gnus-data-list 'rev))) |
eec82323 LMI |
6797 | result) |
6798 | (when (and (not eobp) | |
6799 | (or (not gnus-summary-check-current) | |
6800 | (not unread) | |
23f87bed MB |
6801 | (not (gnus-data-unread-p (car data))))) |
6802 | (setq data (cdr data))) | |
eec82323 LMI |
6803 | (when (setq result |
6804 | (if unread | |
6805 | (progn | |
23f87bed MB |
6806 | (while data |
6807 | (unless (memq (gnus-data-number (car data)) | |
6808 | (cond | |
6809 | ((eq gnus-auto-goto-ignores | |
6810 | 'always-undownloaded) | |
6811 | gnus-newsgroup-undownloaded) | |
6812 | (gnus-plugged | |
6813 | nil) | |
6814 | ((eq gnus-auto-goto-ignores | |
6815 | 'unfetched) | |
6816 | gnus-newsgroup-unfetched) | |
6817 | ((eq gnus-auto-goto-ignores | |
6818 | 'undownloaded) | |
6819 | gnus-newsgroup-undownloaded))) | |
6820 | (when (gnus-data-unread-p (car data)) | |
6821 | (setq result (car data) | |
6822 | data nil))) | |
6823 | (setq data (cdr data))) | |
eec82323 | 6824 | result) |
23f87bed | 6825 | (car data))) |
eec82323 LMI |
6826 | (goto-char (gnus-data-pos result)) |
6827 | (gnus-data-number result)))) | |
6828 | ||
6829 | (defun gnus-summary-find-subject (subject &optional unread backward article) | |
6830 | (let* ((simp-subject (gnus-simplify-subject-fully subject)) | |
6831 | (article (or article (gnus-summary-article-number))) | |
6832 | (articles (gnus-data-list backward)) | |
6833 | (arts (gnus-data-find-list article articles)) | |
6834 | result) | |
6835 | (when (or (not gnus-summary-check-current) | |
6836 | (not unread) | |
6837 | (not (gnus-data-unread-p (car arts)))) | |
6838 | (setq arts (cdr arts))) | |
6839 | (while arts | |
6840 | (and (or (not unread) | |
6841 | (gnus-data-unread-p (car arts))) | |
6842 | (vectorp (gnus-data-header (car arts))) | |
6843 | (gnus-subject-equal | |
6844 | simp-subject (mail-header-subject (gnus-data-header (car arts))) t) | |
6845 | (setq result (car arts) | |
6846 | arts nil)) | |
6847 | (setq arts (cdr arts))) | |
6848 | (and result | |
6849 | (goto-char (gnus-data-pos result)) | |
6850 | (gnus-data-number result)))) | |
6851 | ||
6852 | (defun gnus-summary-search-forward (&optional unread subject backward) | |
6853 | "Search forward for an article. | |
6854 | If UNREAD, look for unread articles. If SUBJECT, look for | |
6855 | articles with that subject. If BACKWARD, search backward instead." | |
6856 | (cond (subject (gnus-summary-find-subject subject unread backward)) | |
6857 | (backward (gnus-summary-find-prev unread)) | |
6858 | (t (gnus-summary-find-next unread)))) | |
6859 | ||
6860 | (defun gnus-recenter (&optional n) | |
6861 | "Center point in window and redisplay frame. | |
6862 | Also do horizontal recentering." | |
6863 | (interactive "P") | |
6864 | (when (and gnus-auto-center-summary | |
6865 | (not (eq gnus-auto-center-summary 'vertical))) | |
6866 | (gnus-horizontal-recenter)) | |
5aa75bd8 JL |
6867 | (if (fboundp 'recenter-top-bottom) |
6868 | (recenter-top-bottom n) | |
6869 | (recenter n))) | |
6870 | ||
6871 | (put 'gnus-recenter 'isearch-scroll t) | |
eec82323 | 6872 | |
7b47345b AS |
6873 | (defun gnus-forward-line-ignore-invisible (n) |
6874 | "Move N lines forward (backward if N is negative). | |
6875 | Like forward-line, but skip over (and don't count) invisible lines." | |
6876 | (let (done) | |
6877 | (while (and (> n 0) (not done)) | |
6878 | ;; If the following character is currently invisible, | |
6879 | ;; skip all characters with that same `invisible' property value. | |
770d9a1f KY |
6880 | (while (gnus-invisible-p (point)) |
6881 | (goto-char (gnus-next-char-property-change (point)))) | |
7b47345b AS |
6882 | (forward-line 1) |
6883 | (if (eobp) | |
6884 | (setq done t) | |
6885 | (setq n (1- n)))) | |
6886 | (while (and (< n 0) (not done)) | |
6887 | (forward-line -1) | |
6888 | (if (bobp) (setq done t) | |
6889 | (setq n (1+ n)) | |
770d9a1f KY |
6890 | (while (and (not (bobp)) (gnus-invisible-p (1- (point)))) |
6891 | (goto-char (gnus-previous-char-property-change (point)))))))) | |
6892 | ||
eec82323 LMI |
6893 | (defun gnus-summary-recenter () |
6894 | "Center point in the summary window. | |
6895 | If `gnus-auto-center-summary' is nil, or the article buffer isn't | |
6896 | displayed, no centering will be performed." | |
6897 | ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle). | |
6898 | ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu. | |
16409b0b | 6899 | (interactive) |
23f87bed MB |
6900 | ;; The user has to want it. |
6901 | (when gnus-auto-center-summary | |
6902 | (let* ((top (cond ((< (window-height) 4) 0) | |
6903 | ((< (window-height) 7) 1) | |
6904 | (t (if (numberp gnus-auto-center-summary) | |
6905 | gnus-auto-center-summary | |
01c52d31 | 6906 | (/ (1- (window-height)) 2))))) |
23f87bed | 6907 | (height (1- (window-height))) |
7b47345b AS |
6908 | (bottom (save-excursion |
6909 | (goto-char (point-max)) | |
6910 | (gnus-forward-line-ignore-invisible (- height)) | |
6911 | (point))) | |
23f87bed | 6912 | (window (get-buffer-window (current-buffer)))) |
eec82323 LMI |
6913 | (when (get-buffer-window gnus-article-buffer) |
6914 | ;; Only do recentering when the article buffer is displayed, | |
6915 | ;; Set the window start to either `bottom', which is the biggest | |
6916 | ;; possible valid number, or the second line from the top, | |
6917 | ;; whichever is the least. | |
7b47345b AS |
6918 | (let ((top-pos (save-excursion |
6919 | (gnus-forward-line-ignore-invisible (- top)) | |
6920 | (point)))) | |
db7ebd73 MB |
6921 | (if (> bottom top-pos) |
6922 | ;; Keep the second line from the top visible | |
01c52d31 | 6923 | (set-window-start window top-pos) |
db7ebd73 MB |
6924 | ;; Try to keep the bottom line visible; if it's partially |
6925 | ;; obscured, either scroll one more line to make it fully | |
6926 | ;; visible, or revert to using TOP-POS. | |
6927 | (save-excursion | |
6928 | (goto-char (point-max)) | |
7b47345b | 6929 | (gnus-forward-line-ignore-invisible -1) |
db7ebd73 MB |
6930 | (let ((last-line-start (point))) |
6931 | (goto-char bottom) | |
6932 | (set-window-start window (point) t) | |
6933 | (when (not (pos-visible-in-window-p last-line-start window)) | |
7b47345b | 6934 | (gnus-forward-line-ignore-invisible 1) |
db7ebd73 | 6935 | (set-window-start window (min (point) top-pos) t))))))) |
eec82323 LMI |
6936 | ;; Do horizontal recentering while we're at it. |
6937 | (when (and (get-buffer-window (current-buffer) t) | |
6938 | (not (eq gnus-auto-center-summary 'vertical))) | |
6939 | (let ((selected (selected-window))) | |
6940 | (select-window (get-buffer-window (current-buffer) t)) | |
6941 | (gnus-summary-position-point) | |
6942 | (gnus-horizontal-recenter) | |
6943 | (select-window selected)))))) | |
6944 | ||
6945 | (defun gnus-summary-jump-to-group (newsgroup) | |
6946 | "Move point to NEWSGROUP in group mode buffer." | |
6947 | ;; Keep update point of group mode buffer if visible. | |
6948 | (if (eq (current-buffer) (get-buffer gnus-group-buffer)) | |
6949 | (save-window-excursion | |
6950 | ;; Take care of tree window mode. | |
6951 | (when (get-buffer-window gnus-group-buffer) | |
6952 | (pop-to-buffer gnus-group-buffer)) | |
6953 | (gnus-group-jump-to-group newsgroup)) | |
6954 | (save-excursion | |
6955 | ;; Take care of tree window mode. | |
c7a91ce1 | 6956 | (if (get-buffer-window gnus-group-buffer 0) |
eec82323 LMI |
6957 | (pop-to-buffer gnus-group-buffer) |
6958 | (set-buffer gnus-group-buffer)) | |
6959 | (gnus-group-jump-to-group newsgroup)))) | |
6960 | ||
6961 | ;; This function returns a list of article numbers based on the | |
6962 | ;; difference between the ranges of read articles in this group and | |
6963 | ;; the range of active articles. | |
6964 | (defun gnus-list-of-unread-articles (group) | |
6965 | (let* ((read (gnus-info-read (gnus-get-info group))) | |
6966 | (active (or (gnus-active group) (gnus-activate-group group))) | |
01c52d31 MB |
6967 | (last (or (cdr active) |
6968 | (error "Group %s couldn't be activated " group))) | |
4b70e299 MB |
6969 | (bottom (if gnus-newsgroup-maximum-articles |
6970 | (max (car active) | |
6971 | (- last gnus-newsgroup-maximum-articles -1)) | |
11abff8e | 6972 | (car active))) |
eec82323 LMI |
6973 | first nlast unread) |
6974 | ;; If none are read, then all are unread. | |
6975 | (if (not read) | |
11abff8e | 6976 | (setq first bottom) |
eec82323 LMI |
6977 | ;; If the range of read articles is a single range, then the |
6978 | ;; first unread article is the article after the last read | |
6979 | ;; article. Sounds logical, doesn't it? | |
16409b0b | 6980 | (if (and (not (listp (cdr read))) |
11abff8e | 6981 | (or (< (car read) bottom) |
16409b0b GM |
6982 | (progn (setq read (list read)) |
6983 | nil))) | |
11abff8e | 6984 | (setq first (max bottom (1+ (cdr read)))) |
eec82323 LMI |
6985 | ;; `read' is a list of ranges. |
6986 | (when (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
6987 | (caar read))) | |
6988 | 1) | |
11abff8e | 6989 | (setq first bottom)) |
eec82323 LMI |
6990 | (while read |
6991 | (when first | |
6992 | (while (< first nlast) | |
54506618 MB |
6993 | (setq unread (cons first unread) |
6994 | first (1+ first)))) | |
eec82323 LMI |
6995 | (setq first (1+ (if (atom (car read)) (car read) (cdar read)))) |
6996 | (setq nlast (if (atom (cadr read)) (cadr read) (caadr read))) | |
6997 | (setq read (cdr read))))) | |
6998 | ;; And add the last unread articles. | |
6999 | (while (<= first last) | |
54506618 MB |
7000 | (setq unread (cons first unread) |
7001 | first (1+ first))) | |
eec82323 | 7002 | ;; Return the list of unread articles. |
6748645f | 7003 | (delq 0 (nreverse unread)))) |
eec82323 LMI |
7004 | |
7005 | (defun gnus-list-of-read-articles (group) | |
7006 | "Return a list of unread, unticked and non-dormant articles." | |
7007 | (let* ((info (gnus-get-info group)) | |
7008 | (marked (gnus-info-marks info)) | |
7009 | (active (gnus-active group))) | |
7010 | (and info active | |
23f87bed MB |
7011 | (gnus-list-range-difference |
7012 | (gnus-list-range-difference | |
7013 | (gnus-sorted-complement | |
11abff8e | 7014 | (gnus-uncompress-range |
4b70e299 | 7015 | (if gnus-newsgroup-maximum-articles |
11abff8e | 7016 | (cons (max (car active) |
4b70e299 MB |
7017 | (- (cdr active) |
7018 | gnus-newsgroup-maximum-articles | |
7019 | -1)) | |
11abff8e MB |
7020 | (cdr active)) |
7021 | active)) | |
23f87bed MB |
7022 | (gnus-list-of-unread-articles group)) |
7023 | (cdr (assq 'dormant marked))) | |
7024 | (cdr (assq 'tick marked)))))) | |
eec82323 | 7025 | |
54506618 MB |
7026 | ;; This function returns a sequence of article numbers based on the |
7027 | ;; difference between the ranges of read articles in this group and | |
7028 | ;; the range of active articles. | |
7029 | (defun gnus-sequence-of-unread-articles (group) | |
7030 | (let* ((read (gnus-info-read (gnus-get-info group))) | |
7031 | (active (or (gnus-active group) (gnus-activate-group group))) | |
7032 | (last (cdr active)) | |
4b70e299 MB |
7033 | (bottom (if gnus-newsgroup-maximum-articles |
7034 | (max (car active) | |
7035 | (- last gnus-newsgroup-maximum-articles -1)) | |
11abff8e | 7036 | (car active))) |
54506618 MB |
7037 | first nlast unread) |
7038 | ;; If none are read, then all are unread. | |
7039 | (if (not read) | |
11abff8e | 7040 | (setq first bottom) |
54506618 MB |
7041 | ;; If the range of read articles is a single range, then the |
7042 | ;; first unread article is the article after the last read | |
7043 | ;; article. Sounds logical, doesn't it? | |
7044 | (if (and (not (listp (cdr read))) | |
11abff8e | 7045 | (or (< (car read) bottom) |
54506618 MB |
7046 | (progn (setq read (list read)) |
7047 | nil))) | |
11abff8e | 7048 | (setq first (max bottom (1+ (cdr read)))) |
54506618 MB |
7049 | ;; `read' is a list of ranges. |
7050 | (when (/= (setq nlast (or (and (numberp (car read)) (car read)) | |
7051 | (caar read))) | |
7052 | 1) | |
11abff8e | 7053 | (setq first bottom)) |
54506618 MB |
7054 | (while read |
7055 | (when first | |
7056 | (push (cons first nlast) unread)) | |
7057 | (setq first (1+ (if (atom (car read)) (car read) (cdar read)))) | |
7058 | (setq nlast (if (atom (cadr read)) (cadr read) (caadr read))) | |
7059 | (setq read (cdr read))))) | |
7060 | ;; And add the last unread articles. | |
ba0226dd MB |
7061 | (cond ((not (and first last)) |
7062 | nil) | |
7063 | ((< first last) | |
7064 | (push (cons first last) unread)) | |
7065 | ((= first last) | |
7066 | (push first unread))) | |
54506618 MB |
7067 | ;; Return the sequence of unread articles. |
7068 | (delq 0 (nreverse unread)))) | |
7069 | ||
eec82323 LMI |
7070 | ;; Various summary commands |
7071 | ||
6748645f | 7072 | (defun gnus-summary-select-article-buffer () |
de635afe | 7073 | "Reconfigure windows to show the article buffer. |
1e3b6001 | 7074 | If `gnus-widen-article-window' is set, show only the article |
de635afe | 7075 | buffer." |
6748645f LMI |
7076 | (interactive) |
7077 | (if (not (gnus-buffer-live-p gnus-article-buffer)) | |
7078 | (error "There is no article buffer for this summary buffer") | |
a41c2e6d G |
7079 | (unless (get-buffer-window gnus-article-buffer) |
7080 | (gnus-summary-show-article)) | |
71e691a5 G |
7081 | (gnus-configure-windows |
7082 | (if gnus-widen-article-window | |
7083 | 'only-article | |
7084 | 'article) | |
7085 | t) | |
a41c2e6d | 7086 | (select-window (get-buffer-window gnus-article-buffer)))) |
6748645f | 7087 | |
eec82323 LMI |
7088 | (defun gnus-summary-universal-argument (arg) |
7089 | "Perform any operation on all articles that are process/prefixed." | |
7090 | (interactive "P") | |
eec82323 LMI |
7091 | (let ((articles (gnus-summary-work-articles arg)) |
7092 | func article) | |
7093 | (if (eq | |
7094 | (setq | |
7095 | func | |
7096 | (key-binding | |
7097 | (read-key-sequence | |
7098 | (substitute-command-keys | |
16409b0b | 7099 | "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]")))) |
eec82323 LMI |
7100 | 'undefined) |
7101 | (gnus-error 1 "Undefined key") | |
7102 | (save-excursion | |
7103 | (while articles | |
7104 | (gnus-summary-goto-subject (setq article (pop articles))) | |
7105 | (let (gnus-newsgroup-processable) | |
7106 | (command-execute func)) | |
7107 | (gnus-summary-remove-process-mark article))))) | |
7108 | (gnus-summary-position-point)) | |
7109 | ||
7110 | (defun gnus-summary-toggle-truncation (&optional arg) | |
7111 | "Toggle truncation of summary lines. | |
23f87bed | 7112 | With ARG, turn line truncation on if ARG is positive." |
eec82323 LMI |
7113 | (interactive "P") |
7114 | (setq truncate-lines | |
7115 | (if (null arg) (not truncate-lines) | |
7116 | (> (prefix-numeric-value arg) 0))) | |
7117 | (redraw-display)) | |
7118 | ||
23f87bed MB |
7119 | (defun gnus-summary-find-for-reselect () |
7120 | "Return the number of an article to stay on across a reselect. | |
7121 | The current article is considered, then following articles, then previous | |
c80e3b4a | 7122 | articles. An article is sought which is not canceled and isn't a temporary |
23f87bed MB |
7123 | insertion from another group. If there's no such then return a dummy 0." |
7124 | (let (found) | |
7125 | (dolist (rev '(nil t)) | |
7126 | (unless found ; don't demand the reverse list if we don't need it | |
7127 | (let ((data (gnus-data-find-list | |
7128 | (gnus-summary-article-number) (gnus-data-list rev)))) | |
7129 | (while (and data (not found)) | |
7130 | (if (and (< 0 (gnus-data-number (car data))) | |
7131 | (not (eq gnus-canceled-mark (gnus-data-mark (car data))))) | |
7132 | (setq found (gnus-data-number (car data)))) | |
7133 | (setq data (cdr data)))))) | |
7134 | (or found 0))) | |
7135 | ||
eec82323 LMI |
7136 | (defun gnus-summary-reselect-current-group (&optional all rescan) |
7137 | "Exit and then reselect the current newsgroup. | |
7138 | The prefix argument ALL means to select all articles." | |
7139 | (interactive "P") | |
eec82323 LMI |
7140 | (when (gnus-ephemeral-group-p gnus-newsgroup-name) |
7141 | (error "Ephemeral groups can't be reselected")) | |
23f87bed | 7142 | (let ((current-subject (gnus-summary-find-for-reselect)) |
eec82323 LMI |
7143 | (group gnus-newsgroup-name)) |
7144 | (setq gnus-newsgroup-begin nil) | |
23f87bed | 7145 | (gnus-summary-exit nil 'leave-hidden) |
eec82323 LMI |
7146 | ;; We have to adjust the point of group mode buffer because |
7147 | ;; point was moved to the next unread newsgroup by exiting. | |
7148 | (gnus-summary-jump-to-group group) | |
7149 | (when rescan | |
7150 | (save-excursion | |
7151 | (gnus-group-get-new-news-this-group 1))) | |
7152 | (gnus-group-read-group all t) | |
7153 | (gnus-summary-goto-subject current-subject nil t))) | |
7154 | ||
7155 | (defun gnus-summary-rescan-group (&optional all) | |
7156 | "Exit the newsgroup, ask for new articles, and select the newsgroup." | |
7157 | (interactive "P") | |
eb9df2c9 LMI |
7158 | (let ((config gnus-current-window-configuration)) |
7159 | (gnus-summary-reselect-current-group all t) | |
7160 | (gnus-configure-windows config) | |
7161 | (when (eq config 'article) | |
7162 | (gnus-summary-select-article)))) | |
eec82323 LMI |
7163 | |
7164 | (defun gnus-summary-update-info (&optional non-destructive) | |
7165 | (save-excursion | |
7166 | (let ((group gnus-newsgroup-name)) | |
6748645f LMI |
7167 | (when group |
7168 | (when gnus-newsgroup-kill-headers | |
7169 | (setq gnus-newsgroup-killed | |
7170 | (gnus-compress-sequence | |
23f87bed MB |
7171 | (gnus-sorted-union |
7172 | (gnus-list-range-intersection | |
7173 | gnus-newsgroup-unselected gnus-newsgroup-killed) | |
7174 | gnus-newsgroup-unreads) | |
6748645f LMI |
7175 | t))) |
7176 | (unless (listp (cdr gnus-newsgroup-killed)) | |
7177 | (setq gnus-newsgroup-killed (list gnus-newsgroup-killed))) | |
b229f37d KY |
7178 | (let ((headers gnus-newsgroup-headers) |
7179 | (ephemeral-p (gnus-ephemeral-group-p group)) | |
7180 | info) | |
7181 | (unless ephemeral-p | |
7182 | (setq info (copy-sequence (gnus-get-info group)) | |
7183 | info (delq (gnus-info-params info) info))) | |
6748645f | 7184 | ;; Set the new ranges of read articles. |
01c52d31 | 7185 | (with-current-buffer gnus-group-buffer |
6748645f LMI |
7186 | (gnus-undo-force-boundary)) |
7187 | (gnus-update-read-articles | |
23f87bed MB |
7188 | group (gnus-sorted-union |
7189 | gnus-newsgroup-unreads gnus-newsgroup-unselected)) | |
6748645f LMI |
7190 | ;; Set the current article marks. |
7191 | (let ((gnus-newsgroup-scored | |
7192 | (if (and (not gnus-save-score) | |
7193 | (not non-destructive)) | |
7194 | nil | |
7195 | gnus-newsgroup-scored))) | |
7196 | (save-excursion | |
7197 | (gnus-update-marks))) | |
7198 | ;; Do the cross-ref thing. | |
7199 | (when gnus-use-cross-reference | |
7200 | (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads)) | |
7201 | ;; Do not switch windows but change the buffer to work. | |
a8151ef7 | 7202 | (set-buffer gnus-group-buffer) |
b229f37d KY |
7203 | (unless ephemeral-p |
7204 | (gnus-group-update-group | |
7205 | group nil | |
7206 | (equal info | |
7207 | (setq info (copy-sequence (gnus-get-info group)) | |
7208 | info (delq (gnus-info-params info) info)))))))))) | |
eec82323 LMI |
7209 | |
7210 | (defun gnus-summary-save-newsrc (&optional force) | |
7211 | "Save the current number of read/marked articles in the dribble buffer. | |
7212 | The dribble buffer will then be saved. | |
7213 | If FORCE (the prefix), also save the .newsrc file(s)." | |
7214 | (interactive "P") | |
7215 | (gnus-summary-update-info t) | |
7216 | (if force | |
7217 | (gnus-save-newsrc-file) | |
7218 | (gnus-dribble-save))) | |
7219 | ||
704f1663 | 7220 | (declare-function gnus-cache-write-active "gnus-cache" (&optional force)) |
d1e12aef | 7221 | (declare-function gnus-article-stop-animations "gnus-art" ()) |
704f1663 | 7222 | |
23f87bed | 7223 | (defun gnus-summary-exit (&optional temporary leave-hidden) |
eec82323 | 7224 | "Exit reading current newsgroup, and then return to group selection mode. |
16409b0b | 7225 | `gnus-exit-group-hook' is called with no arguments if that value is non-nil." |
eec82323 LMI |
7226 | (interactive) |
7227 | (gnus-set-global-variables) | |
16409b0b | 7228 | (when (gnus-buffer-live-p gnus-article-buffer) |
c7a91ce1 | 7229 | (with-current-buffer gnus-article-buffer |
16409b0b GM |
7230 | (mm-destroy-parts gnus-article-mime-handles) |
7231 | ;; Set it to nil for safety reason. | |
7232 | (setq gnus-article-mime-handle-alist nil) | |
7233 | (setq gnus-article-mime-handles nil))) | |
eec82323 | 7234 | (gnus-kill-save-kill-buffer) |
6748645f | 7235 | (gnus-async-halt-prefetch) |
eec82323 LMI |
7236 | (let* ((group gnus-newsgroup-name) |
7237 | (quit-config (gnus-group-quit-config gnus-newsgroup-name)) | |
23f87bed | 7238 | (gnus-group-is-exiting-p t) |
5415d076 | 7239 | (article-buffer gnus-article-buffer) |
bbd6590c | 7240 | (original-article-buffer gnus-original-article-buffer) |
eec82323 | 7241 | (mode major-mode) |
23f87bed | 7242 | (group-point nil) |
1a3c7209 KY |
7243 | (buf (current-buffer)) |
7244 | ;; `gnus-single-article-buffer' is nil buffer-locally in | |
7245 | ;; ephemeral group of which summary buffer will be killed, | |
7246 | ;; but the global value may be non-nil. | |
7247 | (single-article-buffer gnus-single-article-buffer)) | |
16409b0b GM |
7248 | (unless quit-config |
7249 | ;; Do adaptive scoring, and possibly save score files. | |
7250 | (when gnus-newsgroup-adaptive | |
7251 | (gnus-score-adaptive)) | |
7252 | (when gnus-use-scoring | |
7253 | (gnus-score-save))) | |
6748645f | 7254 | (gnus-run-hooks 'gnus-summary-prepare-exit-hook) |
eec82323 LMI |
7255 | (when gnus-use-cache |
7256 | (gnus-cache-possibly-remove-articles) | |
7257 | (gnus-cache-save-buffers)) | |
7258 | (gnus-async-prefetch-remove-group group) | |
7259 | (when gnus-suppress-duplicates | |
7260 | (gnus-dup-enter-articles)) | |
7261 | (when gnus-use-trees | |
c2e9e9ef | 7262 | (gnus-tree-close)) |
16409b0b GM |
7263 | (when gnus-use-cache |
7264 | (gnus-cache-write-active)) | |
6748645f LMI |
7265 | ;; Remove entries for this group. |
7266 | (nnmail-purge-split-history (gnus-group-real-name group)) | |
eec82323 LMI |
7267 | ;; Make all changes in this group permanent. |
7268 | (unless quit-config | |
6748645f | 7269 | (gnus-run-hooks 'gnus-exit-group-hook) |
16409b0b | 7270 | (gnus-summary-update-info)) |
eec82323 LMI |
7271 | (gnus-close-group group) |
7272 | ;; Make sure where we were, and go to next newsgroup. | |
89b163db G |
7273 | (when (buffer-live-p (get-buffer gnus-group-buffer)) |
7274 | (set-buffer gnus-group-buffer)) | |
eec82323 LMI |
7275 | (unless quit-config |
7276 | (gnus-group-jump-to-group group)) | |
6748645f LMI |
7277 | (gnus-run-hooks 'gnus-summary-exit-hook) |
7278 | (unless (or quit-config | |
01c52d31 | 7279 | (not gnus-summary-next-group-on-exit) |
6748645f LMI |
7280 | ;; If this group has disappeared from the summary |
7281 | ;; buffer, don't skip forwards. | |
7282 | (not (string= group (gnus-group-group-name)))) | |
eec82323 | 7283 | (gnus-group-next-unread-group 1)) |
a8151ef7 | 7284 | (setq group-point (point)) |
af3efc32 | 7285 | (gnus-article-stop-animations) |
eec82323 LMI |
7286 | (if temporary |
7287 | nil ;Nothing to do. | |
eec82323 LMI |
7288 | (set-buffer buf) |
7289 | (if (not gnus-kill-summary-on-exit) | |
23f87bed MB |
7290 | (progn |
7291 | (gnus-deaden-summary) | |
7292 | (setq mode nil)) | |
eec82323 LMI |
7293 | (when (get-buffer gnus-article-buffer) |
7294 | (bury-buffer gnus-article-buffer)) | |
eec82323 LMI |
7295 | ;; Return to group mode buffer. |
7296 | (when (eq mode 'gnus-summary-mode) | |
7297 | (gnus-kill-buffer buf))) | |
9f2d52e7 | 7298 | |
eec82323 | 7299 | (setq gnus-current-select-method gnus-select-method) |
89b163db G |
7300 | (when (gnus-buffer-live-p gnus-group-buffer) |
7301 | (set-buffer gnus-group-buffer)) | |
d61c212b SM |
7302 | (if quit-config |
7303 | (gnus-handle-ephemeral-exit quit-config) | |
4e90f2b9 SM |
7304 | (goto-char group-point) |
7305 | ;; If gnus-group-buffer is already displayed, make sure we also move | |
7306 | ;; the cursor in the window that displays it. | |
7307 | (let ((win (get-buffer-window (current-buffer) 0))) | |
7308 | (if win (set-window-point win (point)))) | |
d61c212b | 7309 | (unless leave-hidden |
4e90f2b9 | 7310 | (gnus-configure-windows 'group 'force))) |
5415d076 G |
7311 | |
7312 | ;; If we have several article buffers, we kill them at exit. | |
1a3c7209 | 7313 | (unless single-article-buffer |
5415d076 G |
7314 | (when (gnus-buffer-live-p article-buffer) |
7315 | (with-current-buffer article-buffer | |
7316 | ;; Don't kill sticky article buffers | |
7317 | (unless (eq major-mode 'gnus-sticky-article-mode) | |
7318 | (gnus-kill-buffer article-buffer) | |
7319 | (setq gnus-article-current nil)))) | |
bbd6590c | 7320 | (gnus-kill-buffer original-article-buffer)) |
5415d076 | 7321 | |
6748645f | 7322 | ;; Clear the current group name. |
eec82323 LMI |
7323 | (unless quit-config |
7324 | (setq gnus-newsgroup-name nil))))) | |
7325 | ||
cf6a9685 GM |
7326 | (declare-function gnus-stop-downloads "gnus-art" ()) |
7327 | ||
eec82323 LMI |
7328 | (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update) |
7329 | (defun gnus-summary-exit-no-update (&optional no-questions) | |
7330 | "Quit reading current newsgroup without updating read article info." | |
7331 | (interactive) | |
eec82323 | 7332 | (let* ((group gnus-newsgroup-name) |
23f87bed MB |
7333 | (gnus-group-is-exiting-p t) |
7334 | (gnus-group-is-exiting-without-update-p t) | |
eec82323 LMI |
7335 | (quit-config (gnus-group-quit-config group))) |
7336 | (when (or no-questions | |
7337 | gnus-expert-user | |
7338 | (gnus-y-or-n-p "Discard changes to this group and exit? ")) | |
6748645f | 7339 | (gnus-async-halt-prefetch) |
23f87bed | 7340 | (run-hooks 'gnus-summary-prepare-exit-hook) |
16409b0b | 7341 | (when (gnus-buffer-live-p gnus-article-buffer) |
c7a91ce1 | 7342 | (with-current-buffer gnus-article-buffer |
c146ad85 | 7343 | (gnus-article-stop-animations) |
4eff9c1a | 7344 | (gnus-stop-downloads) |
16409b0b GM |
7345 | (mm-destroy-parts gnus-article-mime-handles) |
7346 | ;; Set it to nil for safety reason. | |
7347 | (setq gnus-article-mime-handle-alist nil) | |
7348 | (setq gnus-article-mime-handles nil))) | |
eec82323 LMI |
7349 | ;; If we have several article buffers, we kill them at exit. |
7350 | (unless gnus-single-article-buffer | |
7351 | (gnus-kill-buffer gnus-article-buffer) | |
7352 | (gnus-kill-buffer gnus-original-article-buffer) | |
7353 | (setq gnus-article-current nil)) | |
5415d076 | 7354 | ;; Return to the group buffer. |
eec82323 | 7355 | (if (not gnus-kill-summary-on-exit) |
9ed5a258 LI |
7356 | (progn |
7357 | (gnus-deaden-summary) | |
7358 | (gnus-configure-windows 'group 'force)) | |
7359 | (gnus-configure-windows 'group 'force) | |
eec82323 | 7360 | (gnus-close-group group) |
23f87bed | 7361 | (gnus-kill-buffer gnus-summary-buffer)) |
eec82323 LMI |
7362 | (unless gnus-single-article-buffer |
7363 | (setq gnus-article-current nil)) | |
7364 | (when gnus-use-trees | |
c2e9e9ef | 7365 | (gnus-tree-close)) |
eec82323 LMI |
7366 | (gnus-async-prefetch-remove-group group) |
7367 | (when (get-buffer gnus-article-buffer) | |
7368 | (bury-buffer gnus-article-buffer)) | |
eec82323 LMI |
7369 | ;; Clear the current group name. |
7370 | (setq gnus-newsgroup-name nil) | |
23f87bed | 7371 | (unless (gnus-ephemeral-group-p group) |
b229f37d | 7372 | (gnus-group-update-group group nil t)) |
eec82323 LMI |
7373 | (when (equal (gnus-group-group-name) group) |
7374 | (gnus-group-next-unread-group 1)) | |
af3efc32 | 7375 | (gnus-article-stop-animations) |
eec82323 | 7376 | (when quit-config |
23f87bed | 7377 | (gnus-handle-ephemeral-exit quit-config))))) |
eec82323 LMI |
7378 | |
7379 | (defun gnus-handle-ephemeral-exit (quit-config) | |
6748645f LMI |
7380 | "Handle movement when leaving an ephemeral group. |
7381 | The state which existed when entering the ephemeral is reset." | |
15562805 | 7382 | (if (not (buffer-live-p (car quit-config))) |
89b163db G |
7383 | (when (gnus-buffer-live-p gnus-group-buffer) |
7384 | (gnus-configure-windows 'group 'force)) | |
eec82323 | 7385 | (set-buffer (car quit-config)) |
af92e247 AC |
7386 | (unless (eq (cdr quit-config) 'group) |
7387 | (setq gnus-current-select-method | |
7388 | (gnus-find-method-for-group gnus-newsgroup-name))) | |
c2e9e9ef | 7389 | (cond ((derived-mode-p 'gnus-summary-mode) |
23f87bed | 7390 | (gnus-set-global-variables)) |
c2e9e9ef | 7391 | ((derived-mode-p 'gnus-article-mode) |
c7a91ce1 | 7392 | (save-current-buffer |
23f87bed MB |
7393 | ;; The `gnus-summary-buffer' variable may point |
7394 | ;; to the old summary buffer when using a single | |
7395 | ;; article buffer. | |
7396 | (unless (gnus-buffer-live-p gnus-summary-buffer) | |
7397 | (set-buffer gnus-group-buffer)) | |
7398 | (set-buffer gnus-summary-buffer) | |
7399 | (gnus-set-global-variables)))) | |
eec82323 | 7400 | (if (or (eq (cdr quit-config) 'article) |
23f87bed | 7401 | (eq (cdr quit-config) 'pick)) |
01c52d31 MB |
7402 | (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode)) |
7403 | (gnus-configure-windows 'pick 'force) | |
7404 | (gnus-configure-windows (cdr quit-config) 'force)) | |
eec82323 | 7405 | (gnus-configure-windows (cdr quit-config) 'force)) |
c2e9e9ef | 7406 | (when (derived-mode-p 'gnus-summary-mode) |
01c52d31 MB |
7407 | (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect |
7408 | next-unread-noselect)) | |
7409 | (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit | |
7410 | 'next-noselect) | |
7411 | (gnus-summary-next-subject 1 nil t)) | |
7412 | ((eq gnus-auto-select-on-ephemeral-exit | |
7413 | 'next-unread-noselect) | |
7414 | (gnus-summary-next-subject 1 t t)))) | |
7415 | ;; Hide the article buffer which displays the article different | |
7416 | ;; from the one that the cursor points to in the summary buffer. | |
7417 | (gnus-configure-windows 'summary 'force)) | |
7418 | (cond ((eq gnus-auto-select-on-ephemeral-exit 'next) | |
7419 | (gnus-summary-next-subject 1)) | |
7420 | ((eq gnus-auto-select-on-ephemeral-exit 'next-unread) | |
7421 | (gnus-summary-next-subject 1 t)))) | |
eec82323 LMI |
7422 | (gnus-summary-recenter) |
7423 | (gnus-summary-position-point)))) | |
7424 | ||
7425 | ;;; Dead summaries. | |
7426 | ||
bbf52f1e SM |
7427 | (defvar gnus-dead-summary-mode-map |
7428 | (let ((map (make-keymap))) | |
7429 | (suppress-keymap map) | |
7430 | (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map) | |
7431 | (dolist (key '("\C-d" "\r" "\177" [delete])) | |
7432 | (define-key map key 'gnus-summary-wake-up-the-dead)) | |
7433 | (dolist (key '("q" "Q")) | |
7434 | (define-key map key 'bury-buffer)) | |
7435 | map)) | |
7436 | ||
7437 | (define-minor-mode gnus-dead-summary-mode | |
eec82323 | 7438 | "Minor mode for Gnus summary buffers." |
bbf52f1e SM |
7439 | :lighter " Dead" :keymap gnus-dead-summary-mode-map |
7440 | (unless (derived-mode-p 'gnus-summary-mode) | |
7441 | (setq gnus-dead-summary-mode nil))) | |
eec82323 LMI |
7442 | |
7443 | (defun gnus-deaden-summary () | |
7444 | "Make the current summary buffer into a dead summary buffer." | |
7445 | ;; Kill any previous dead summary buffer. | |
7446 | (when (and gnus-dead-summary | |
7447 | (buffer-name gnus-dead-summary)) | |
01c52d31 | 7448 | (with-current-buffer gnus-dead-summary |
eec82323 LMI |
7449 | (when gnus-dead-summary-mode |
7450 | (kill-buffer (current-buffer))))) | |
7451 | ;; Make this the current dead summary. | |
7452 | (setq gnus-dead-summary (current-buffer)) | |
7453 | (gnus-dead-summary-mode 1) | |
7454 | (let ((name (buffer-name))) | |
7455 | (when (string-match "Summary" name) | |
7456 | (rename-buffer | |
7457 | (concat (substring name 0 (match-beginning 0)) "Dead " | |
7458 | (substring name (match-beginning 0))) | |
16409b0b GM |
7459 | t) |
7460 | (bury-buffer)))) | |
eec82323 LMI |
7461 | |
7462 | (defun gnus-kill-or-deaden-summary (buffer) | |
7463 | "Kill or deaden the summary BUFFER." | |
6748645f LMI |
7464 | (save-excursion |
7465 | (when (and (buffer-name buffer) | |
7466 | (not gnus-single-article-buffer)) | |
01c52d31 | 7467 | (with-current-buffer buffer |
6748645f LMI |
7468 | (gnus-kill-buffer gnus-article-buffer) |
7469 | (gnus-kill-buffer gnus-original-article-buffer))) | |
23f87bed MB |
7470 | (cond |
7471 | ;; Kill the buffer. | |
7472 | (gnus-kill-summary-on-exit | |
7473 | (when (and gnus-use-trees | |
7474 | (gnus-buffer-exists-p buffer)) | |
c7a91ce1 | 7475 | (with-current-buffer buffer |
c2e9e9ef | 7476 | (gnus-tree-close))) |
23f87bed MB |
7477 | (gnus-kill-buffer buffer)) |
7478 | ;; Deaden the buffer. | |
7479 | ((gnus-buffer-exists-p buffer) | |
c7a91ce1 | 7480 | (with-current-buffer buffer |
23f87bed | 7481 | (gnus-deaden-summary)))))) |
eec82323 LMI |
7482 | |
7483 | (defun gnus-summary-wake-up-the-dead (&rest args) | |
7484 | "Wake up the dead summary buffer." | |
7485 | (interactive) | |
7486 | (gnus-dead-summary-mode -1) | |
7487 | (let ((name (buffer-name))) | |
7488 | (when (string-match "Dead " name) | |
7489 | (rename-buffer | |
7490 | (concat (substring name 0 (match-beginning 0)) | |
7491 | (substring name (match-end 0))) | |
7492 | t))) | |
7493 | (gnus-message 3 "This dead summary is now alive again")) | |
7494 | ||
eec82323 LMI |
7495 | ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>. |
7496 | (defun gnus-summary-describe-group (&optional force) | |
7497 | "Describe the current newsgroup." | |
7498 | (interactive "P") | |
7499 | (gnus-group-describe-group force gnus-newsgroup-name)) | |
7500 | ||
7501 | (defun gnus-summary-describe-briefly () | |
7502 | "Describe summary mode commands briefly." | |
7503 | (interactive) | |
bdaa75c7 | 7504 | (gnus-message 6 "%s" (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help"))) |
eec82323 LMI |
7505 | |
7506 | ;; Walking around group mode buffer from summary mode. | |
7507 | ||
7508 | (defun gnus-summary-next-group (&optional no-article target-group backward) | |
7509 | "Exit current newsgroup and then select next unread newsgroup. | |
7510 | If prefix argument NO-ARTICLE is non-nil, no article is selected | |
23f87bed | 7511 | initially. If TARGET-GROUP, go to this group. If BACKWARD, go to |
eec82323 LMI |
7512 | previous group instead." |
7513 | (interactive "P") | |
eec82323 LMI |
7514 | ;; Stop pre-fetching. |
7515 | (gnus-async-halt-prefetch) | |
7516 | (let ((current-group gnus-newsgroup-name) | |
7517 | (current-buffer (current-buffer)) | |
7518 | entered) | |
7519 | ;; First we semi-exit this group to update Xrefs and all variables. | |
7520 | ;; We can't do a real exit, because the window conf must remain | |
7521 | ;; the same in case the user is prompted for info, and we don't | |
7522 | ;; want the window conf to change before that... | |
7523 | (gnus-summary-exit t) | |
7524 | (while (not entered) | |
7525 | ;; Then we find what group we are supposed to enter. | |
7526 | (set-buffer gnus-group-buffer) | |
7527 | (gnus-group-jump-to-group current-group) | |
7528 | (setq target-group | |
7529 | (or target-group | |
7530 | (if (eq gnus-keep-same-level 'best) | |
7531 | (gnus-summary-best-group gnus-newsgroup-name) | |
7532 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
7533 | (if (not target-group) | |
7534 | ;; There are no further groups, so we return to the group | |
7535 | ;; buffer. | |
7536 | (progn | |
7537 | (gnus-message 5 "Returning to the group buffer") | |
7538 | (setq entered t) | |
7539 | (when (gnus-buffer-live-p current-buffer) | |
7540 | (set-buffer current-buffer) | |
7541 | (gnus-summary-exit)) | |
6748645f | 7542 | (gnus-run-hooks 'gnus-group-no-more-groups-hook)) |
eec82323 LMI |
7543 | ;; We try to enter the target group. |
7544 | (gnus-group-jump-to-group target-group) | |
7545 | (let ((unreads (gnus-group-group-unread))) | |
7546 | (if (and (or (eq t unreads) | |
7547 | (and unreads (not (zerop unreads)))) | |
23f87bed MB |
7548 | (gnus-summary-read-group |
7549 | target-group nil no-article | |
7550 | (and (buffer-name current-buffer) current-buffer) | |
7551 | nil backward)) | |
eec82323 LMI |
7552 | (setq entered t) |
7553 | (setq current-group target-group | |
7554 | target-group nil))))))) | |
7555 | ||
7556 | (defun gnus-summary-prev-group (&optional no-article) | |
7557 | "Exit current newsgroup and then select previous unread newsgroup. | |
7558 | If prefix argument NO-ARTICLE is non-nil, no article is selected initially." | |
7559 | (interactive "P") | |
7560 | (gnus-summary-next-group no-article nil t)) | |
7561 | ||
7562 | ;; Walking around summary lines. | |
7563 | ||
23f87bed MB |
7564 | (defun gnus-summary-first-subject (&optional unread undownloaded unseen) |
7565 | "Go to the first subject satisfying any non-nil constraint. | |
7566 | If UNREAD is non-nil, the article should be unread. | |
7567 | If UNDOWNLOADED is non-nil, the article should be undownloaded. | |
20a673b2 | 7568 | If UNSEEN is non-nil, the article should be unseen as well as unread. |
23f87bed | 7569 | Returns the article selected or nil if there are no matching articles." |
eec82323 | 7570 | (interactive "P") |
23f87bed MB |
7571 | (cond |
7572 | ;; Empty summary. | |
7573 | ((null gnus-newsgroup-data) | |
7574 | (gnus-message 3 "No articles in the group") | |
7575 | nil) | |
7576 | ;; Pick the first article. | |
7577 | ((not (or unread undownloaded unseen)) | |
7578 | (goto-char (gnus-data-pos (car gnus-newsgroup-data))) | |
7579 | (gnus-data-number (car gnus-newsgroup-data))) | |
7580 | ;; Find the first unread article. | |
7581 | (t | |
7582 | (let ((data gnus-newsgroup-data)) | |
7583 | (while (and data | |
7584 | (let ((num (gnus-data-number (car data)))) | |
7585 | (or (memq num gnus-newsgroup-unfetched) | |
7586 | (not (or (and unread | |
7587 | (memq num gnus-newsgroup-unreads)) | |
7588 | (and undownloaded | |
7589 | (memq num gnus-newsgroup-undownloaded)) | |
7590 | (and unseen | |
20a673b2 KY |
7591 | (memq num gnus-newsgroup-unseen) |
7592 | (memq num gnus-newsgroup-unreads))))))) | |
23f87bed MB |
7593 | (setq data (cdr data))) |
7594 | (prog1 | |
7595 | (if data | |
7596 | (progn | |
7597 | (goto-char (gnus-data-pos (car data))) | |
7598 | (gnus-data-number (car data))) | |
7599 | (gnus-message 3 "No more%s articles" | |
7600 | (let* ((r (when unread " unread")) | |
7601 | (d (when undownloaded " undownloaded")) | |
7602 | (s (when unseen " unseen")) | |
7603 | (l (delq nil (list r d s)))) | |
7604 | (cond ((= 3 (length l)) | |
7605 | (concat r "," d ", or" s)) | |
7606 | ((= 2 (length l)) | |
7607 | (concat (car l) ", or" (cadr l))) | |
7608 | ((= 1 (length l)) | |
7609 | (car l)) | |
7610 | (t | |
7611 | "")))) | |
7612 | nil | |
7613 | ) | |
7614 | (gnus-summary-position-point)))))) | |
eec82323 LMI |
7615 | |
7616 | (defun gnus-summary-next-subject (n &optional unread dont-display) | |
7617 | "Go to next N'th summary line. | |
7618 | If N is negative, go to the previous N'th subject line. | |
7619 | If UNREAD is non-nil, only unread articles are selected. | |
7620 | The difference between N and the actual number of steps taken is | |
7621 | returned." | |
7622 | (interactive "p") | |
7623 | (let ((backward (< n 0)) | |
7624 | (n (abs n))) | |
7625 | (while (and (> n 0) | |
7626 | (if backward | |
7627 | (gnus-summary-find-prev unread) | |
7628 | (gnus-summary-find-next unread))) | |
16409b0b GM |
7629 | (unless (zerop (setq n (1- n))) |
7630 | (gnus-summary-show-thread))) | |
eec82323 LMI |
7631 | (when (/= 0 n) |
7632 | (gnus-message 7 "No more%s articles" | |
7633 | (if unread " unread" ""))) | |
7634 | (unless dont-display | |
7635 | (gnus-summary-recenter) | |
7636 | (gnus-summary-position-point)) | |
7637 | n)) | |
7638 | ||
7639 | (defun gnus-summary-next-unread-subject (n) | |
7640 | "Go to next N'th unread summary line." | |
7641 | (interactive "p") | |
7642 | (gnus-summary-next-subject n t)) | |
7643 | ||
7644 | (defun gnus-summary-prev-subject (n &optional unread) | |
7645 | "Go to previous N'th summary line. | |
7646 | If optional argument UNREAD is non-nil, only unread article is selected." | |
7647 | (interactive "p") | |
7648 | (gnus-summary-next-subject (- n) unread)) | |
7649 | ||
7650 | (defun gnus-summary-prev-unread-subject (n) | |
7651 | "Go to previous N'th unread summary line." | |
7652 | (interactive "p") | |
7653 | (gnus-summary-next-subject (- n) t)) | |
7654 | ||
23f87bed MB |
7655 | (defun gnus-summary-goto-subjects (articles) |
7656 | "Insert the subject header for ARTICLES in the current buffer." | |
7657 | (save-excursion | |
7658 | (dolist (article articles) | |
7659 | (gnus-summary-goto-subject article t))) | |
7660 | (gnus-summary-limit (append articles gnus-newsgroup-limit)) | |
7661 | (gnus-summary-position-point)) | |
132cf96d | 7662 | |
eec82323 | 7663 | (defun gnus-summary-goto-subject (article &optional force silent) |
d55fe5bb | 7664 | "Go to the subject line of ARTICLE. |
eec82323 LMI |
7665 | If FORCE, also allow jumping to articles not currently shown." |
7666 | (interactive "nArticle number: ") | |
23f87bed MB |
7667 | (unless (numberp article) |
7668 | (error "Article %s is not a number" article)) | |
eec82323 LMI |
7669 | (let ((b (point)) |
7670 | (data (gnus-data-find article))) | |
7671 | ;; We read in the article if we have to. | |
7672 | (and (not data) | |
7673 | force | |
6748645f LMI |
7674 | (gnus-summary-insert-subject |
7675 | article | |
7676 | (if (or (numberp force) (vectorp force)) force) | |
7677 | t) | |
eec82323 LMI |
7678 | (setq data (gnus-data-find article))) |
7679 | (goto-char b) | |
7680 | (if (not data) | |
7681 | (progn | |
7682 | (unless silent | |
7683 | (gnus-message 3 "Can't find article %d" article)) | |
7684 | nil) | |
23f87bed MB |
7685 | (let ((pt (gnus-data-pos data))) |
7686 | (goto-char pt) | |
7687 | (gnus-summary-set-article-display-arrow pt)) | |
6748645f | 7688 | (gnus-summary-position-point) |
eec82323 LMI |
7689 | article))) |
7690 | ||
7691 | ;; Walking around summary lines with displaying articles. | |
7692 | ||
7693 | (defun gnus-summary-expand-window (&optional arg) | |
7694 | "Make the summary buffer take up the entire Emacs frame. | |
7695 | Given a prefix, will force an `article' buffer configuration." | |
7696 | (interactive "P") | |
eec82323 LMI |
7697 | (if arg |
7698 | (gnus-configure-windows 'article 'force) | |
7699 | (gnus-configure-windows 'summary 'force))) | |
7700 | ||
7701 | (defun gnus-summary-display-article (article &optional all-header) | |
7702 | "Display ARTICLE in article buffer." | |
01c52d31 MB |
7703 | (unless (and (gnus-buffer-live-p gnus-article-buffer) |
7704 | (with-current-buffer gnus-article-buffer | |
c2e9e9ef | 7705 | (derived-mode-p 'gnus-article-mode))) |
01c52d31 | 7706 | (gnus-article-setup-buffer)) |
eec82323 | 7707 | (gnus-set-global-variables) |
01c52d31 MB |
7708 | (with-current-buffer gnus-article-buffer |
7709 | (setq gnus-article-charset gnus-newsgroup-charset) | |
7710 | (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets) | |
7711 | (mm-enable-multibyte)) | |
eec82323 LMI |
7712 | (if (null article) |
7713 | nil | |
7714 | (prog1 | |
7715 | (if gnus-summary-display-article-function | |
7716 | (funcall gnus-summary-display-article-function article all-header) | |
7717 | (gnus-article-prepare article all-header)) | |
6748645f | 7718 | (gnus-run-hooks 'gnus-select-article-hook) |
eec82323 LMI |
7719 | (when (and gnus-current-article |
7720 | (not (zerop gnus-current-article))) | |
7721 | (gnus-summary-goto-subject gnus-current-article)) | |
7722 | (gnus-summary-recenter) | |
7723 | (when (and gnus-use-trees gnus-show-threads) | |
7724 | (gnus-possibly-generate-tree article) | |
7725 | (gnus-highlight-selected-tree article)) | |
7726 | ;; Successfully display article. | |
7727 | (gnus-article-set-window-start | |
7728 | (cdr (assq article gnus-newsgroup-bookmarks)))))) | |
7729 | ||
7730 | (defun gnus-summary-select-article (&optional all-headers force pseudo article) | |
7731 | "Select the current article. | |
7732 | If ALL-HEADERS is non-nil, show all header fields. If FORCE is | |
7733 | non-nil, the article will be re-fetched even if it already present in | |
7734 | the article buffer. If PSEUDO is non-nil, pseudo-articles will also | |
7735 | be displayed." | |
7736 | ;; Make sure we are in the summary buffer to work around bbdb bug. | |
c2e9e9ef | 7737 | (unless (derived-mode-p 'gnus-summary-mode) |
eec82323 LMI |
7738 | (set-buffer gnus-summary-buffer)) |
7739 | (let ((article (or article (gnus-summary-article-number))) | |
f0529b5b | 7740 | (all-headers (not (not all-headers))) ;Must be t or nil. |
16409b0b | 7741 | gnus-summary-display-article-function) |
eec82323 LMI |
7742 | (and (not pseudo) |
7743 | (gnus-summary-article-pseudo-p article) | |
a8151ef7 | 7744 | (error "This is a pseudo-article")) |
c7a91ce1 | 7745 | (with-current-buffer gnus-summary-buffer |
16409b0b GM |
7746 | (if (or (and gnus-single-article-buffer |
7747 | (or (null gnus-current-article) | |
7748 | (null gnus-article-current) | |
7749 | (null (get-buffer gnus-article-buffer)) | |
7750 | (not (eq article (cdr gnus-article-current))) | |
7751 | (not (equal (car gnus-article-current) | |
de635afe | 7752 | gnus-newsgroup-name)) |
28090d40 | 7753 | (not (get-buffer gnus-original-article-buffer)))) |
16409b0b GM |
7754 | (and (not gnus-single-article-buffer) |
7755 | (or (null gnus-current-article) | |
389b76fa | 7756 | (not (get-buffer gnus-original-article-buffer)) |
16409b0b GM |
7757 | (not (eq gnus-current-article article)))) |
7758 | force) | |
7759 | ;; The requested article is different from the current article. | |
7760 | (progn | |
16409b0b GM |
7761 | (gnus-summary-display-article article all-headers) |
7762 | (when (gnus-buffer-live-p gnus-article-buffer) | |
23f87bed | 7763 | (with-current-buffer gnus-article-buffer |
16409b0b | 7764 | (if (not gnus-article-decoded-p) ;; a local variable |
87545352 | 7765 | (mm-disable-multibyte)))) |
16409b0b GM |
7766 | (gnus-article-set-window-start |
7767 | (cdr (assq article gnus-newsgroup-bookmarks))) | |
7768 | article) | |
16409b0b | 7769 | 'old)))) |
eec82323 | 7770 | |
23f87bed MB |
7771 | (defun gnus-summary-force-verify-and-decrypt () |
7772 | "Display buttons for signed/encrypted parts and verify/decrypt them." | |
7773 | (interactive) | |
7774 | (let ((mm-verify-option 'known) | |
7775 | (mm-decrypt-option 'known) | |
7776 | (gnus-article-emulate-mime t) | |
7777 | (gnus-buttonized-mime-types (append (list "multipart/signed" | |
7778 | "multipart/encrypted") | |
7779 | gnus-buttonized-mime-types))) | |
7780 | (gnus-summary-select-article nil 'force))) | |
7781 | ||
eec82323 LMI |
7782 | (defun gnus-summary-next-article (&optional unread subject backward push) |
7783 | "Select the next article. | |
7784 | If UNREAD, only unread articles are selected. | |
7785 | If SUBJECT, only articles with SUBJECT are selected. | |
7786 | If BACKWARD, the previous article is selected instead of the next." | |
7787 | (interactive "P") | |
11e95b02 | 7788 | ;; Make sure we are in the summary buffer. |
c2e9e9ef | 7789 | (unless (derived-mode-p 'gnus-summary-mode) |
11e95b02 | 7790 | (set-buffer gnus-summary-buffer)) |
eec82323 LMI |
7791 | (cond |
7792 | ;; Is there such an article? | |
7793 | ((and (gnus-summary-search-forward unread subject backward) | |
7794 | (or (gnus-summary-display-article (gnus-summary-article-number)) | |
7795 | (eq (gnus-summary-article-mark) gnus-canceled-mark))) | |
7796 | (gnus-summary-position-point)) | |
7797 | ;; If not, we try the first unread, if that is wanted. | |
7798 | ((and subject | |
7799 | gnus-auto-select-same | |
7800 | (gnus-summary-first-unread-article)) | |
7801 | (gnus-summary-position-point) | |
7802 | (gnus-message 6 "Wrapped")) | |
7803 | ;; Try to get next/previous article not displayed in this group. | |
7804 | ((and gnus-auto-extend-newsgroup | |
7805 | (not unread) (not subject)) | |
7806 | (gnus-summary-goto-article | |
7807 | (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end)) | |
6748645f | 7808 | nil (count-lines (point-min) (point)))) |
eec82323 LMI |
7809 | ;; Go to next/previous group. |
7810 | (t | |
7811 | (unless (gnus-ephemeral-group-p gnus-newsgroup-name) | |
7812 | (gnus-summary-jump-to-group gnus-newsgroup-name)) | |
49e787c9 GM |
7813 | (let ((cmd (if (featurep 'xemacs) |
7814 | last-command-char | |
7815 | last-command-event)) | |
eec82323 | 7816 | (point |
01c52d31 | 7817 | (with-current-buffer gnus-group-buffer |
eec82323 | 7818 | (point))) |
06b840e0 | 7819 | (current-summary (current-buffer)) |
eec82323 LMI |
7820 | (group |
7821 | (if (eq gnus-keep-same-level 'best) | |
7822 | (gnus-summary-best-group gnus-newsgroup-name) | |
7823 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
eec82323 LMI |
7824 | ;; Select next unread newsgroup automagically. |
7825 | (cond | |
7826 | ((or (not gnus-auto-select-next) | |
7827 | (not cmd)) | |
7828 | (gnus-message 7 "No more%s articles" (if unread " unread" ""))) | |
7829 | ((or (eq gnus-auto-select-next 'quietly) | |
7830 | (and (eq gnus-auto-select-next 'slightly-quietly) | |
7831 | push) | |
7832 | (and (eq gnus-auto-select-next 'almost-quietly) | |
7833 | (gnus-summary-last-article-p))) | |
7834 | ;; Select quietly. | |
7835 | (if (gnus-ephemeral-group-p gnus-newsgroup-name) | |
7836 | (gnus-summary-exit) | |
7837 | (gnus-message 7 "No more%s articles (%s)..." | |
7838 | (if unread " unread" "") | |
7839 | (if group (concat "selecting " group) | |
7840 | "exiting")) | |
7841 | (gnus-summary-next-group nil group backward))) | |
7842 | (t | |
7843 | (when (gnus-key-press-event-p last-input-event) | |
06b840e0 LI |
7844 | ;; Somehow or other, we may now have selected a different |
7845 | ;; window. Make point go back to the summary buffer. | |
7846 | (when (eq current-summary (current-buffer)) | |
b87f32fc G |
7847 | ;; FIXME: This burps when get-buffer-window returns nil. |
7848 | (select-window (get-buffer-window current-summary 0))) | |
eec82323 LMI |
7849 | (gnus-summary-walk-group-buffer |
7850 | gnus-newsgroup-name cmd unread backward point)))))))) | |
7851 | ||
7852 | (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start) | |
7853 | (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1)) | |
7854 | (?\C-p (gnus-group-prev-unread-group 1)))) | |
7855 | (cursor-in-echo-area t) | |
23f87bed | 7856 | keve key group ended prompt) |
c7a91ce1 | 7857 | (with-current-buffer gnus-group-buffer |
eec82323 LMI |
7858 | (goto-char start) |
7859 | (setq group | |
7860 | (if (eq gnus-keep-same-level 'best) | |
7861 | (gnus-summary-best-group gnus-newsgroup-name) | |
7862 | (gnus-summary-search-group backward gnus-keep-same-level)))) | |
7863 | (while (not ended) | |
23f87bed MB |
7864 | (setq prompt |
7865 | (format | |
7866 | "No more%s articles%s " (if unread " unread" "") | |
7867 | (if (and group | |
7868 | (not (gnus-ephemeral-group-p gnus-newsgroup-name))) | |
7869 | (format " (Type %s for %s [%s])" | |
91472578 MB |
7870 | (single-key-description cmd) |
7871 | (gnus-group-decoded-name group) | |
01c52d31 | 7872 | (gnus-group-unread group)) |
23f87bed MB |
7873 | (format " (Type %s to exit %s)" |
7874 | (single-key-description cmd) | |
91472578 | 7875 | (gnus-group-decoded-name gnus-newsgroup-name))))) |
eec82323 | 7876 | ;; Confirm auto selection. |
23f87bed MB |
7877 | (setq key (car (setq keve (gnus-read-event-char prompt))) |
7878 | ended t) | |
eec82323 LMI |
7879 | (cond |
7880 | ((assq key keystrokes) | |
7881 | (let ((obuf (current-buffer))) | |
7882 | (switch-to-buffer gnus-group-buffer) | |
7883 | (when group | |
7884 | (gnus-group-jump-to-group group)) | |
7885 | (eval (cadr (assq key keystrokes))) | |
7886 | (setq group (gnus-group-group-name)) | |
7887 | (switch-to-buffer obuf)) | |
7888 | (setq ended nil)) | |
7889 | ((equal key cmd) | |
7890 | (if (or (not group) | |
7891 | (gnus-ephemeral-group-p gnus-newsgroup-name)) | |
7892 | (gnus-summary-exit) | |
7893 | (gnus-summary-next-group nil group backward))) | |
7894 | (t | |
7895 | (push (cdr keve) unread-command-events)))))) | |
7896 | ||
7897 | (defun gnus-summary-next-unread-article () | |
7898 | "Select unread article after current one." | |
7899 | (interactive) | |
7900 | (gnus-summary-next-article | |
7901 | (or (not (eq gnus-summary-goto-unread 'never)) | |
7902 | (gnus-summary-last-article-p (gnus-summary-article-number))) | |
7903 | (and gnus-auto-select-same | |
7904 | (gnus-summary-article-subject)))) | |
7905 | ||
7906 | (defun gnus-summary-prev-article (&optional unread subject) | |
bbbe940b | 7907 | "Select the article before the current one. |
eec82323 LMI |
7908 | If UNREAD is non-nil, only unread articles are selected." |
7909 | (interactive "P") | |
7910 | (gnus-summary-next-article unread subject t)) | |
7911 | ||
7912 | (defun gnus-summary-prev-unread-article () | |
7913 | "Select unread article before current one." | |
7914 | (interactive) | |
7915 | (gnus-summary-prev-article | |
7916 | (or (not (eq gnus-summary-goto-unread 'never)) | |
7917 | (gnus-summary-first-article-p (gnus-summary-article-number))) | |
7918 | (and gnus-auto-select-same | |
7919 | (gnus-summary-article-subject)))) | |
7920 | ||
cf6a9685 GM |
7921 | (declare-function gnus-article-only-boring-p "gnus-art" ()) |
7922 | ||
23f87bed | 7923 | (defun gnus-summary-next-page (&optional lines circular stop) |
eec82323 LMI |
7924 | "Show next page of the selected article. |
7925 | If at the end of the current article, select the next article. | |
7926 | LINES says how many lines should be scrolled up. | |
7927 | ||
7928 | If CIRCULAR is non-nil, go to the start of the article instead of | |
7929 | selecting the next article when reaching the end of the current | |
23f87bed MB |
7930 | article. |
7931 | ||
7932 | If STOP is non-nil, just stop when reaching the end of the message. | |
7933 | ||
7934 | Also see the variable `gnus-article-skip-boring'." | |
eec82323 | 7935 | (interactive "P") |
eec82323 LMI |
7936 | (gnus-set-global-variables) |
7937 | (let ((article (gnus-summary-article-number)) | |
7938 | (article-window (get-buffer-window gnus-article-buffer t)) | |
7939 | endp) | |
6748645f LMI |
7940 | ;; If the buffer is empty, we have no article. |
7941 | (unless article | |
7942 | (error "No article to select")) | |
eec82323 LMI |
7943 | (gnus-configure-windows 'article) |
7944 | (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark) | |
7945 | (if (and (eq gnus-summary-goto-unread 'never) | |
7946 | (not (gnus-summary-last-article-p article))) | |
7947 | (gnus-summary-next-article) | |
7948 | (gnus-summary-next-unread-article)) | |
7949 | (if (or (null gnus-current-article) | |
7950 | (null gnus-article-current) | |
7951 | (/= article (cdr gnus-article-current)) | |
7952 | (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
7953 | ;; Selected subject is different from current article's. | |
7954 | (gnus-summary-display-article article) | |
7955 | (when article-window | |
7956 | (gnus-eval-in-buffer-window gnus-article-buffer | |
23f87bed MB |
7957 | (setq endp (or (gnus-article-next-page lines) |
7958 | (gnus-article-only-boring-p)))) | |
eec82323 | 7959 | (when endp |
b1992461 | 7960 | (cond ((or stop gnus-summary-stop-at-end-of-message) |
23f87bed MB |
7961 | (gnus-message 3 "End of message")) |
7962 | (circular | |
eec82323 LMI |
7963 | (gnus-summary-beginning-of-article)) |
7964 | (lines | |
7965 | (gnus-message 3 "End of message")) | |
7966 | ((null lines) | |
7967 | (if (and (eq gnus-summary-goto-unread 'never) | |
7968 | (not (gnus-summary-last-article-p article))) | |
7969 | (gnus-summary-next-article) | |
7970 | (gnus-summary-next-unread-article)))))))) | |
7971 | (gnus-summary-recenter) | |
7972 | (gnus-summary-position-point))) | |
7973 | ||
7974 | (defun gnus-summary-prev-page (&optional lines move) | |
7975 | "Show previous page of selected article. | |
7976 | Argument LINES specifies lines to be scrolled down. | |
7977 | If MOVE, move to the previous unread article if point is at | |
7978 | the beginning of the buffer." | |
7979 | (interactive "P") | |
eec82323 LMI |
7980 | (let ((article (gnus-summary-article-number)) |
7981 | (article-window (get-buffer-window gnus-article-buffer t)) | |
7982 | endp) | |
7983 | (gnus-configure-windows 'article) | |
7984 | (if (or (null gnus-current-article) | |
7985 | (null gnus-article-current) | |
7986 | (/= article (cdr gnus-article-current)) | |
7987 | (not (equal (car gnus-article-current) gnus-newsgroup-name))) | |
7988 | ;; Selected subject is different from current article's. | |
7989 | (gnus-summary-display-article article) | |
7990 | (gnus-summary-recenter) | |
7991 | (when article-window | |
7992 | (gnus-eval-in-buffer-window gnus-article-buffer | |
7993 | (setq endp (gnus-article-prev-page lines))) | |
7994 | (when (and move endp) | |
7995 | (cond (lines | |
7996 | (gnus-message 3 "Beginning of message")) | |
7997 | ((null lines) | |
7998 | (if (and (eq gnus-summary-goto-unread 'never) | |
7999 | (not (gnus-summary-first-article-p article))) | |
8000 | (gnus-summary-prev-article) | |
8001 | (gnus-summary-prev-unread-article)))))))) | |
8002 | (gnus-summary-position-point)) | |
8003 | ||
8004 | (defun gnus-summary-prev-page-or-article (&optional lines) | |
8005 | "Show previous page of selected article. | |
8006 | Argument LINES specifies lines to be scrolled down. | |
8007 | If at the beginning of the article, go to the next article." | |
8008 | (interactive "P") | |
8009 | (gnus-summary-prev-page lines t)) | |
8010 | ||
8011 | (defun gnus-summary-scroll-up (lines) | |
8012 | "Scroll up (or down) one line current article. | |
a3f57c41 G |
8013 | Argument LINES specifies lines to be scrolled up (or down if negative). |
8014 | If no article is selected, then the current article will be selected first." | |
eec82323 | 8015 | (interactive "p") |
eec82323 LMI |
8016 | (gnus-configure-windows 'article) |
8017 | (gnus-summary-show-thread) | |
8018 | (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old) | |
8019 | (gnus-eval-in-buffer-window gnus-article-buffer | |
8020 | (cond ((> lines 0) | |
8021 | (when (gnus-article-next-page lines) | |
8022 | (gnus-message 3 "End of message"))) | |
8023 | ((< lines 0) | |
8024 | (gnus-article-prev-page (- lines)))))) | |
8025 | (gnus-summary-recenter) | |
8026 | (gnus-summary-position-point)) | |
8027 | ||
6748645f LMI |
8028 | (defun gnus-summary-scroll-down (lines) |
8029 | "Scroll down (or up) one line current article. | |
a3f57c41 G |
8030 | Argument LINES specifies lines to be scrolled down (or up if negative). |
8031 | If no article is selected, then the current article will be selected first." | |
6748645f LMI |
8032 | (interactive "p") |
8033 | (gnus-summary-scroll-up (- lines))) | |
8034 | ||
eec82323 LMI |
8035 | (defun gnus-summary-next-same-subject () |
8036 | "Select next article which has the same subject as current one." | |
8037 | (interactive) | |
eec82323 LMI |
8038 | (gnus-summary-next-article nil (gnus-summary-article-subject))) |
8039 | ||
8040 | (defun gnus-summary-prev-same-subject () | |
8041 | "Select previous article which has the same subject as current one." | |
8042 | (interactive) | |
eec82323 LMI |
8043 | (gnus-summary-prev-article nil (gnus-summary-article-subject))) |
8044 | ||
8045 | (defun gnus-summary-next-unread-same-subject () | |
8046 | "Select next unread article which has the same subject as current one." | |
8047 | (interactive) | |
eec82323 LMI |
8048 | (gnus-summary-next-article t (gnus-summary-article-subject))) |
8049 | ||
8050 | (defun gnus-summary-prev-unread-same-subject () | |
8051 | "Select previous unread article which has the same subject as current one." | |
8052 | (interactive) | |
eec82323 LMI |
8053 | (gnus-summary-prev-article t (gnus-summary-article-subject))) |
8054 | ||
8055 | (defun gnus-summary-first-unread-article () | |
8056 | "Select the first unread article. | |
8057 | Return nil if there are no unread articles." | |
8058 | (interactive) | |
eec82323 LMI |
8059 | (prog1 |
8060 | (when (gnus-summary-first-subject t) | |
8061 | (gnus-summary-show-thread) | |
8062 | (gnus-summary-first-subject t) | |
8063 | (gnus-summary-display-article (gnus-summary-article-number))) | |
8064 | (gnus-summary-position-point))) | |
8065 | ||
16409b0b GM |
8066 | (defun gnus-summary-first-unread-subject () |
8067 | "Place the point on the subject line of the first unread article. | |
8068 | Return nil if there are no unread articles." | |
8069 | (interactive) | |
8070 | (prog1 | |
8071 | (when (gnus-summary-first-subject t) | |
8072 | (gnus-summary-show-thread) | |
8073 | (gnus-summary-first-subject t)) | |
8074 | (gnus-summary-position-point))) | |
8075 | ||
23f87bed MB |
8076 | (defun gnus-summary-first-unseen-subject () |
8077 | "Place the point on the subject line of the first unseen article. | |
8078 | Return nil if there are no unseen articles." | |
8079 | (interactive) | |
8080 | (prog1 | |
8081 | (when (gnus-summary-first-subject nil nil t) | |
8082 | (gnus-summary-show-thread) | |
8083 | (gnus-summary-first-subject nil nil t)) | |
8084 | (gnus-summary-position-point))) | |
8085 | ||
8086 | (defun gnus-summary-first-unseen-or-unread-subject () | |
20a673b2 KY |
8087 | "Place the point on the subject line of the first unseen and unread article. |
8088 | If all article have been seen, on the subject line of the first unread | |
23f87bed MB |
8089 | article." |
8090 | (interactive) | |
8091 | (prog1 | |
8092 | (unless (when (gnus-summary-first-subject nil nil t) | |
8093 | (gnus-summary-show-thread) | |
8094 | (gnus-summary-first-subject nil nil t)) | |
8095 | (when (gnus-summary-first-subject t) | |
8096 | (gnus-summary-show-thread) | |
8097 | (gnus-summary-first-subject t))) | |
8098 | (gnus-summary-position-point))) | |
8099 | ||
eec82323 LMI |
8100 | (defun gnus-summary-first-article () |
8101 | "Select the first article. | |
8102 | Return nil if there are no articles." | |
8103 | (interactive) | |
eec82323 LMI |
8104 | (prog1 |
8105 | (when (gnus-summary-first-subject) | |
16409b0b GM |
8106 | (gnus-summary-show-thread) |
8107 | (gnus-summary-first-subject) | |
8108 | (gnus-summary-display-article (gnus-summary-article-number))) | |
eec82323 LMI |
8109 | (gnus-summary-position-point))) |
8110 | ||
23f87bed MB |
8111 | (defun gnus-summary-best-unread-article (&optional arg) |
8112 | "Select the unread article with the highest score. | |
8113 | If given a prefix argument, select the next unread article that has a | |
8114 | score higher than the default score." | |
8115 | (interactive "P") | |
8116 | (let ((article (if arg | |
8117 | (gnus-summary-better-unread-subject) | |
8118 | (gnus-summary-best-unread-subject)))) | |
8119 | (if article | |
8120 | (gnus-summary-goto-article article) | |
8121 | (error "No unread articles")))) | |
8122 | ||
8123 | (defun gnus-summary-best-unread-subject () | |
8124 | "Select the unread subject with the highest score." | |
eec82323 | 8125 | (interactive) |
eec82323 LMI |
8126 | (let ((best -1000000) |
8127 | (data gnus-newsgroup-data) | |
8128 | article score) | |
8129 | (while data | |
8130 | (and (gnus-data-unread-p (car data)) | |
8131 | (> (setq score | |
8132 | (gnus-summary-article-score (gnus-data-number (car data)))) | |
8133 | best) | |
8134 | (setq best score | |
8135 | article (gnus-data-number (car data)))) | |
8136 | (setq data (cdr data))) | |
23f87bed MB |
8137 | (when article |
8138 | (gnus-summary-goto-subject article)) | |
8139 | (gnus-summary-position-point) | |
8140 | article)) | |
8141 | ||
8142 | (defun gnus-summary-better-unread-subject () | |
8143 | "Select the first unread subject that has a score over the default score." | |
8144 | (interactive) | |
8145 | (let ((data gnus-newsgroup-data) | |
8146 | article score) | |
8147 | (while (and (setq article (gnus-data-number (car data))) | |
8148 | (or (gnus-data-read-p (car data)) | |
8149 | (not (> (gnus-summary-article-score article) | |
8150 | gnus-summary-default-score)))) | |
8151 | (setq data (cdr data))) | |
8152 | (when article | |
8153 | (gnus-summary-goto-subject article)) | |
8154 | (gnus-summary-position-point) | |
8155 | article)) | |
eec82323 LMI |
8156 | |
8157 | (defun gnus-summary-last-subject () | |
8158 | "Go to the last displayed subject line in the group." | |
8159 | (let ((article (gnus-data-number (car (gnus-data-list t))))) | |
8160 | (when article | |
8161 | (gnus-summary-goto-subject article)))) | |
8162 | ||
8163 | (defun gnus-summary-goto-article (article &optional all-headers force) | |
6748645f LMI |
8164 | "Fetch ARTICLE (article number or Message-ID) and display it if it exists. |
8165 | If ALL-HEADERS is non-nil, no header lines are hidden. | |
8166 | If FORCE, go to the article even if it isn't displayed. If FORCE | |
8167 | is a number, it is the line the article is to be displayed on." | |
eec82323 LMI |
8168 | (interactive |
8169 | (list | |
229b59da G |
8170 | (gnus-completing-read |
8171 | "Article number or Message-ID" | |
8172 | (mapcar 'int-to-string gnus-newsgroup-limit)) | |
eec82323 LMI |
8173 | current-prefix-arg |
8174 | t)) | |
8175 | (prog1 | |
6748645f | 8176 | (if (and (stringp article) |
23f87bed | 8177 | (string-match "@\\|%40" article)) |
6748645f LMI |
8178 | (gnus-summary-refer-article article) |
8179 | (when (stringp article) | |
8180 | (setq article (string-to-number article))) | |
8181 | (if (gnus-summary-goto-subject article force) | |
8182 | (gnus-summary-display-article article all-headers) | |
8183 | (gnus-message 4 "Couldn't go to article %s" article) nil)) | |
eec82323 LMI |
8184 | (gnus-summary-position-point))) |
8185 | ||
8186 | (defun gnus-summary-goto-last-article () | |
8187 | "Go to the previously read article." | |
8188 | (interactive) | |
8189 | (prog1 | |
8190 | (when gnus-last-article | |
6748645f | 8191 | (gnus-summary-goto-article gnus-last-article nil t)) |
eec82323 LMI |
8192 | (gnus-summary-position-point))) |
8193 | ||
8194 | (defun gnus-summary-pop-article (number) | |
8195 | "Pop one article off the history and go to the previous. | |
8196 | NUMBER articles will be popped off." | |
8197 | (interactive "p") | |
8198 | (let (to) | |
8199 | (setq gnus-newsgroup-history | |
8200 | (cdr (setq to (nthcdr number gnus-newsgroup-history)))) | |
8201 | (if to | |
6748645f | 8202 | (gnus-summary-goto-article (car to) nil t) |
eec82323 LMI |
8203 | (error "Article history empty"))) |
8204 | (gnus-summary-position-point)) | |
8205 | ||
8206 | ;; Summary commands and functions for limiting the summary buffer. | |
8207 | ||
8208 | (defun gnus-summary-limit-to-articles (n) | |
8209 | "Limit the summary buffer to the next N articles. | |
8210 | If not given a prefix, use the process marked articles instead." | |
8211 | (interactive "P") | |
eec82323 LMI |
8212 | (prog1 |
8213 | (let ((articles (gnus-summary-work-articles n))) | |
8214 | (setq gnus-newsgroup-processable nil) | |
8215 | (gnus-summary-limit articles)) | |
8216 | (gnus-summary-position-point))) | |
8217 | ||
8218 | (defun gnus-summary-pop-limit (&optional total) | |
8219 | "Restore the previous limit. | |
8220 | If given a prefix, remove all limits." | |
8221 | (interactive "P") | |
eec82323 LMI |
8222 | (when total |
8223 | (setq gnus-newsgroup-limits | |
8224 | (list (mapcar (lambda (h) (mail-header-number h)) | |
8225 | gnus-newsgroup-headers)))) | |
8226 | (unless gnus-newsgroup-limits | |
8227 | (error "No limit to pop")) | |
8228 | (prog1 | |
8229 | (gnus-summary-limit nil 'pop) | |
8230 | (gnus-summary-position-point))) | |
8231 | ||
47b63dfa SZ |
8232 | (defun gnus-summary-limit-to-subject (subject &optional header not-matching) |
8233 | "Limit the summary buffer to articles that have subjects that match a regexp. | |
8234 | If NOT-MATCHING, excluding articles that have subjects that match a regexp." | |
a1506d29 | 8235 | (interactive |
47b63dfa SZ |
8236 | (list (read-string (if current-prefix-arg |
8237 | "Exclude subject (regexp): " | |
a1506d29 | 8238 | "Limit to subject (regexp): ")) |
47b63dfa | 8239 | nil current-prefix-arg)) |
eec82323 LMI |
8240 | (unless header |
8241 | (setq header "subject")) | |
8242 | (when (not (equal "" subject)) | |
8243 | (prog1 | |
8244 | (let ((articles (gnus-summary-find-matching | |
a1506d29 | 8245 | (or header "subject") subject 'all nil nil |
47b63dfa | 8246 | not-matching))) |
eec82323 LMI |
8247 | (unless articles |
8248 | (error "Found no matches for \"%s\"" subject)) | |
8249 | (gnus-summary-limit articles)) | |
8250 | (gnus-summary-position-point)))) | |
8251 | ||
ef6e0ec7 | 8252 | (defun gnus-summary-limit-to-author (from &optional not-matching) |
47b63dfa SZ |
8253 | "Limit the summary buffer to articles that have authors that match a regexp. |
8254 | If NOT-MATCHING, excluding articles that have authors that match a regexp." | |
a1506d29 | 8255 | (interactive |
59aadc36 G |
8256 | (list (let* ((header (gnus-summary-article-header)) |
8257 | (default (and header (car (mail-header-parse-address | |
8258 | (mail-header-from header)))))) | |
8259 | (read-string (concat (if current-prefix-arg | |
8260 | "Exclude author (regexp" | |
8261 | "Limit to author (regexp") | |
8262 | (if default | |
8263 | (concat ", default \"" default "\"): ") | |
8264 | "): ")) | |
8265 | nil nil | |
8266 | default)) | |
ef6e0ec7 SZ |
8267 | current-prefix-arg)) |
8268 | (gnus-summary-limit-to-subject from "from" not-matching)) | |
eec82323 | 8269 | |
01c52d31 MB |
8270 | (defun gnus-summary-limit-to-recipient (recipient &optional not-matching) |
8271 | "Limit the summary buffer to articles with the given RECIPIENT. | |
8272 | ||
8273 | If NOT-MATCHING, exclude RECIPIENT. | |
8274 | ||
8275 | To and Cc headers are checked. You need to include them in | |
8276 | `nnmail-extra-headers'." | |
8277 | ;; Unlike `rmail-summary-by-recipients', doesn't include From. | |
8278 | (interactive | |
8279 | (list (read-string (format "%s recipient (regexp): " | |
8280 | (if current-prefix-arg "Exclude" "Limit to"))) | |
8281 | current-prefix-arg)) | |
8282 | (when (not (equal "" recipient)) | |
8283 | (prog1 (let* ((to | |
8284 | (if (memq 'To nnmail-extra-headers) | |
8285 | (gnus-summary-find-matching | |
8286 | (cons 'extra 'To) recipient 'all nil nil | |
8287 | not-matching) | |
8288 | (gnus-message | |
8289 | 1 "`To' isn't present in `nnmail-extra-headers'") | |
8290 | (sit-for 1) | |
8291 | nil)) | |
8292 | (cc | |
8293 | (if (memq 'Cc nnmail-extra-headers) | |
8294 | (gnus-summary-find-matching | |
8295 | (cons 'extra 'Cc) recipient 'all nil nil | |
8296 | not-matching) | |
8297 | (gnus-message | |
8298 | 1 "`Cc' isn't present in `nnmail-extra-headers'") | |
8299 | (sit-for 1) | |
8300 | nil)) | |
8301 | (articles | |
8302 | (if not-matching | |
8303 | ;; We need the numbers that are in both lists: | |
8304 | (mapcar (lambda (a) | |
8305 | (and (memq a to) a)) | |
8306 | cc) | |
8307 | (nconc to cc)))) | |
8308 | (unless articles | |
8309 | (error "Found no matches for \"%s\"" recipient)) | |
8310 | (gnus-summary-limit articles)) | |
8311 | (gnus-summary-position-point)))) | |
8312 | ||
8313 | (defun gnus-summary-limit-to-address (address &optional not-matching) | |
8314 | "Limit the summary buffer to articles with the given ADDRESS. | |
8315 | ||
8316 | If NOT-MATCHING, exclude ADDRESS. | |
8317 | ||
8318 | To, Cc and From headers are checked. You need to include `To' and `Cc' | |
8319 | in `nnmail-extra-headers'." | |
8320 | (interactive | |
8321 | (list (read-string (format "%s address (regexp): " | |
8322 | (if current-prefix-arg "Exclude" "Limit to"))) | |
8323 | current-prefix-arg)) | |
8324 | (when (not (equal "" address)) | |
8325 | (prog1 (let* ((to | |
8326 | (if (memq 'To nnmail-extra-headers) | |
8327 | (gnus-summary-find-matching | |
8328 | (cons 'extra 'To) address 'all nil nil | |
8329 | not-matching) | |
8330 | (gnus-message | |
8331 | 1 "`To' isn't present in `nnmail-extra-headers'") | |
8332 | (sit-for 1) | |
8333 | t)) | |
8334 | (cc | |
8335 | (if (memq 'Cc nnmail-extra-headers) | |
8336 | (gnus-summary-find-matching | |
8337 | (cons 'extra 'Cc) address 'all nil nil | |
8338 | not-matching) | |
8339 | (gnus-message | |
8340 | 1 "`Cc' isn't present in `nnmail-extra-headers'") | |
8341 | (sit-for 1) | |
8342 | t)) | |
8343 | (from | |
8344 | (gnus-summary-find-matching "from" address | |
8345 | 'all nil nil not-matching)) | |
8346 | (articles | |
8347 | (if not-matching | |
8348 | ;; We need the numbers that are in all lists: | |
8349 | (if (eq cc t) | |
8350 | (if (eq to t) | |
8351 | from | |
8352 | (mapcar (lambda (a) (car (memq a from))) to)) | |
8353 | (if (eq to t) | |
8354 | (mapcar (lambda (a) (car (memq a from))) cc) | |
8355 | (mapcar (lambda (a) (car (memq a from))) | |
8356 | (mapcar (lambda (a) (car (memq a to))) | |
8357 | cc)))) | |
8358 | (nconc (if (eq to t) nil to) | |
8359 | (if (eq cc t) nil cc) | |
8360 | from)))) | |
8361 | (unless articles | |
8362 | (error "Found no matches for \"%s\"" address)) | |
8363 | (gnus-summary-limit articles)) | |
8364 | (gnus-summary-position-point)))) | |
8365 | ||
8366 | (defun gnus-summary-limit-strange-charsets-predicate (header) | |
765d4319 KY |
8367 | (when (fboundp 'char-charset) |
8368 | (let ((string (concat (mail-header-subject header) | |
8369 | (mail-header-from header))) | |
8370 | charset found) | |
8371 | (dotimes (i (1- (length string))) | |
8372 | (setq charset (format "%s" (char-charset (aref string (1+ i))))) | |
8373 | (when (string-match "unicode\\|big\\|japanese" charset) | |
8374 | (setq found t))) | |
8375 | found))) | |
01c52d31 MB |
8376 | |
8377 | (defun gnus-summary-limit-to-predicate (predicate) | |
8378 | "Limit to articles where PREDICATE returns non-nil. | |
8379 | PREDICATE will be called with the header structures of the | |
8380 | articles." | |
8381 | (let ((articles nil) | |
8382 | (case-fold-search t)) | |
8383 | (dolist (header gnus-newsgroup-headers) | |
8384 | (when (funcall predicate header) | |
8385 | (push (mail-header-number header) articles))) | |
8386 | (gnus-summary-limit (nreverse articles)))) | |
8387 | ||
eec82323 LMI |
8388 | (defun gnus-summary-limit-to-age (age &optional younger-p) |
8389 | "Limit the summary buffer to articles that are older than (or equal) AGE days. | |
8390 | If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to | |
8391 | articles that are younger than AGE days." | |
16409b0b GM |
8392 | (interactive |
8393 | (let ((younger current-prefix-arg) | |
8394 | (days-got nil) | |
8395 | days) | |
8396 | (while (not days-got) | |
8397 | (setq days (if younger | |
23f87bed MB |
8398 | (read-string "Limit to articles younger than (in days, older when negative): ") |
8399 | (read-string | |
8400 | "Limit to articles older than (in days, younger when negative): "))) | |
16409b0b GM |
8401 | (when (> (length days) 0) |
8402 | (setq days (read days))) | |
8403 | (if (numberp days) | |
23f87bed MB |
8404 | (progn |
8405 | (setq days-got t) | |
01c52d31 MB |
8406 | (when (< days 0) |
8407 | (setq younger (not younger)) | |
8408 | (setq days (* days -1)))) | |
16409b0b GM |
8409 | (message "Please enter a number.") |
8410 | (sleep-for 1))) | |
8411 | (list days younger))) | |
eec82323 LMI |
8412 | (prog1 |
8413 | (let ((data gnus-newsgroup-data) | |
16409b0b | 8414 | (cutoff (days-to-time age)) |
eec82323 LMI |
8415 | articles d date is-younger) |
8416 | (while (setq d (pop data)) | |
8417 | (when (and (vectorp (gnus-data-header d)) | |
8418 | (setq date (mail-header-date (gnus-data-header d)))) | |
16409b0b | 8419 | (setq is-younger (time-less-p |
3d6e7a43 | 8420 | (time-since (gnus-date-get-time date)) |
eec82323 | 8421 | cutoff)) |
6748645f LMI |
8422 | (when (if younger-p |
8423 | is-younger | |
8424 | (not is-younger)) | |
eec82323 LMI |
8425 | (push (gnus-data-number d) articles)))) |
8426 | (gnus-summary-limit (nreverse articles))) | |
8427 | (gnus-summary-position-point))) | |
8428 | ||
47b63dfa | 8429 | (defun gnus-summary-limit-to-extra (header regexp &optional not-matching) |
16409b0b GM |
8430 | "Limit the summary buffer to articles that match an 'extra' header." |
8431 | (interactive | |
8432 | (let ((header | |
8433 | (intern | |
229b59da | 8434 | (gnus-completing-read |
47b63dfa | 8435 | (if current-prefix-arg |
81df110a RF |
8436 | "Exclude extra header" |
8437 | "Limit extra header") | |
229b59da G |
8438 | (mapcar 'symbol-name gnus-extra-headers) |
8439 | t nil nil | |
8440 | (symbol-name (car gnus-extra-headers)))))) | |
16409b0b | 8441 | (list header |
a1506d29 | 8442 | (read-string (format "%s header %s (regexp): " |
47b63dfa SZ |
8443 | (if current-prefix-arg "Exclude" "Limit to") |
8444 | header)) | |
8445 | current-prefix-arg))) | |
16409b0b GM |
8446 | (when (not (equal "" regexp)) |
8447 | (prog1 | |
8448 | (let ((articles (gnus-summary-find-matching | |
a1506d29 | 8449 | (cons 'extra header) regexp 'all nil nil |
47b63dfa | 8450 | not-matching))) |
16409b0b GM |
8451 | (unless articles |
8452 | (error "Found no matches for \"%s\"" regexp)) | |
8453 | (gnus-summary-limit articles)) | |
8454 | (gnus-summary-position-point)))) | |
8455 | ||
23f87bed MB |
8456 | (defun gnus-summary-limit-to-display-predicate () |
8457 | "Limit the summary buffer to the predicated in the `display' group parameter." | |
8458 | (interactive) | |
8459 | (unless gnus-newsgroup-display | |
8460 | (error "There is no `display' group parameter")) | |
8461 | (let (articles) | |
3a3cbf0a | 8462 | (dolist (gnus-number gnus-newsgroup-articles) |
23f87bed | 8463 | (when (funcall gnus-newsgroup-display) |
3a3cbf0a | 8464 | (push gnus-number articles))) |
23f87bed MB |
8465 | (gnus-summary-limit articles)) |
8466 | (gnus-summary-position-point)) | |
8467 | ||
eec82323 LMI |
8468 | (defun gnus-summary-limit-to-unread (&optional all) |
8469 | "Limit the summary buffer to articles that are not marked as read. | |
8470 | If ALL is non-nil, limit strictly to unread articles." | |
8471 | (interactive "P") | |
8472 | (if all | |
8473 | (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark)) | |
8474 | (gnus-summary-limit-to-marks | |
8475 | ;; Concat all the marks that say that an article is read and have | |
8476 | ;; those removed. | |
8477 | (list gnus-del-mark gnus-read-mark gnus-ancient-mark | |
23f87bed | 8478 | gnus-killed-mark gnus-spam-mark gnus-kill-file-mark |
eec82323 LMI |
8479 | gnus-low-score-mark gnus-expirable-mark |
8480 | gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark | |
c4d82de8 | 8481 | gnus-duplicate-mark) |
eec82323 LMI |
8482 | 'reverse))) |
8483 | ||
01c52d31 MB |
8484 | (defun gnus-summary-limit-to-headers (match &optional reverse) |
8485 | "Limit the summary buffer to articles that have headers that match MATCH. | |
8486 | If REVERSE (the prefix), limit to articles that don't match." | |
8487 | (interactive "sMatch headers (regexp): \nP") | |
8488 | (gnus-summary-limit-to-bodies match reverse t)) | |
8489 | ||
cf6a9685 GM |
8490 | (declare-function article-goto-body "gnus-art" ()) |
8491 | ||
01c52d31 MB |
8492 | (defun gnus-summary-limit-to-bodies (match &optional reverse headersp) |
8493 | "Limit the summary buffer to articles that have bodies that match MATCH. | |
8494 | If REVERSE (the prefix), limit to articles that don't match." | |
8495 | (interactive "sMatch body (regexp): \nP") | |
8496 | (let ((articles nil) | |
8497 | (gnus-select-article-hook nil) ;Disable hook. | |
8498 | (gnus-article-prepare-hook nil) | |
8499 | (gnus-use-article-prefetch nil) | |
8500 | (gnus-keep-backlog nil) | |
8501 | (gnus-break-pages nil) | |
8502 | (gnus-summary-display-arrow nil) | |
8503 | (gnus-updated-mode-lines nil) | |
8504 | (gnus-auto-center-summary nil) | |
8505 | (gnus-display-mime-function nil)) | |
8506 | (dolist (data gnus-newsgroup-data) | |
8507 | (let (gnus-mark-article-hook) | |
8508 | (gnus-summary-select-article t t nil (gnus-data-number data))) | |
398a825b | 8509 | (with-current-buffer gnus-article-buffer |
01c52d31 MB |
8510 | (article-goto-body) |
8511 | (let* ((case-fold-search t) | |
8512 | (found (if headersp | |
8513 | (re-search-backward match nil t) | |
8514 | (re-search-forward match nil t)))) | |
8515 | (when (or (and found | |
8516 | (not reverse)) | |
8517 | (and (not found) | |
8518 | reverse)) | |
8519 | (push (gnus-data-number data) articles))))) | |
8520 | (if (not articles) | |
8521 | (message "No messages matched") | |
8522 | (gnus-summary-limit articles))) | |
8523 | (gnus-summary-position-point)) | |
8524 | ||
8525 | (defun gnus-summary-limit-to-singletons (&optional threadsp) | |
8526 | "Limit the summary buffer to articles that aren't part on any thread. | |
8527 | If THREADSP (the prefix), limit to articles that are in threads." | |
8528 | (interactive "P") | |
8529 | (let ((articles nil) | |
8530 | thread-articles | |
8531 | threads) | |
8532 | (dolist (thread gnus-newsgroup-threads) | |
8533 | (if (stringp (car thread)) | |
8534 | (dolist (thread (cdr thread)) | |
8535 | (push thread threads)) | |
8536 | (push thread threads))) | |
8537 | (dolist (thread threads) | |
8538 | (setq thread-articles (gnus-articles-in-thread thread)) | |
8539 | (when (or (and threadsp | |
8540 | (> (length thread-articles) 1)) | |
8541 | (and (not threadsp) | |
8542 | (= (length thread-articles) 1))) | |
8543 | (setq articles (nconc thread-articles articles)))) | |
8544 | (if (not articles) | |
8545 | (message "No messages matched") | |
8546 | (gnus-summary-limit articles)) | |
8547 | (gnus-summary-position-point))) | |
8548 | ||
8549 | (defun gnus-summary-limit-to-replied (&optional unreplied) | |
8550 | "Limit the summary buffer to replied articles. | |
8551 | If UNREPLIED (the prefix), limit to unreplied articles." | |
8552 | (interactive "P") | |
8553 | (if unreplied | |
8554 | (gnus-summary-limit | |
8555 | (gnus-set-difference gnus-newsgroup-articles | |
8556 | gnus-newsgroup-replied)) | |
8557 | (gnus-summary-limit gnus-newsgroup-replied)) | |
8558 | (gnus-summary-position-point)) | |
8559 | ||
eec82323 LMI |
8560 | (defun gnus-summary-limit-exclude-marks (marks &optional reverse) |
8561 | "Exclude articles that are marked with MARKS (e.g. \"DK\"). | |
8562 | If REVERSE, limit the summary buffer to articles that are marked | |
8563 | with MARKS. MARKS can either be a string of marks or a list of marks. | |
8564 | Returns how many articles were removed." | |
8565 | (interactive "sMarks: ") | |
8566 | (gnus-summary-limit-to-marks marks t)) | |
8567 | ||
8568 | (defun gnus-summary-limit-to-marks (marks &optional reverse) | |
8569 | "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\"). | |
8570 | If REVERSE (the prefix), limit the summary buffer to articles that are | |
8571 | not marked with MARKS. MARKS can either be a string of marks or a | |
8572 | list of marks. | |
8573 | Returns how many articles were removed." | |
6748645f | 8574 | (interactive "sMarks: \nP") |
eec82323 LMI |
8575 | (prog1 |
8576 | (let ((data gnus-newsgroup-data) | |
8577 | (marks (if (listp marks) marks | |
8578 | (append marks nil))) ; Transform to list. | |
8579 | articles) | |
8580 | (while data | |
8581 | (when (if reverse (not (memq (gnus-data-mark (car data)) marks)) | |
8582 | (memq (gnus-data-mark (car data)) marks)) | |
8583 | (push (gnus-data-number (car data)) articles)) | |
8584 | (setq data (cdr data))) | |
8585 | (gnus-summary-limit articles)) | |
8586 | (gnus-summary-position-point))) | |
8587 | ||
23f87bed | 8588 | (defun gnus-summary-limit-to-score (score) |
eec82323 | 8589 | "Limit to articles with score at or above SCORE." |
23f87bed | 8590 | (interactive "NLimit to articles with score of at least: ") |
eec82323 LMI |
8591 | (let ((data gnus-newsgroup-data) |
8592 | articles) | |
8593 | (while data | |
8594 | (when (>= (gnus-summary-article-score (gnus-data-number (car data))) | |
8595 | score) | |
8596 | (push (gnus-data-number (car data)) articles)) | |
8597 | (setq data (cdr data))) | |
8598 | (prog1 | |
8599 | (gnus-summary-limit articles) | |
8600 | (gnus-summary-position-point)))) | |
8601 | ||
23f87bed MB |
8602 | (defun gnus-summary-limit-to-unseen () |
8603 | "Limit to unseen articles." | |
8604 | (interactive) | |
8605 | (prog1 | |
8606 | (gnus-summary-limit gnus-newsgroup-unseen) | |
8607 | (gnus-summary-position-point))) | |
8608 | ||
6748645f | 8609 | (defun gnus-summary-limit-include-thread (id) |
23f87bed MB |
8610 | "Display all the hidden articles that is in the thread with ID in it. |
8611 | When called interactively, ID is the Message-ID of the current | |
8612 | article." | |
6748645f LMI |
8613 | (interactive (list (mail-header-id (gnus-summary-article-header)))) |
8614 | (let ((articles (gnus-articles-in-thread | |
181cb5fb G |
8615 | (gnus-id-to-thread (gnus-root-id id)))) |
8616 | ;;we REALLY want the whole thread---this prevents cut-threads | |
8617 | ;;from removing the thread we want to include. | |
8618 | (gnus-fetch-old-headers nil) | |
8619 | (gnus-build-sparse-threads nil)) | |
6748645f LMI |
8620 | (prog1 |
8621 | (gnus-summary-limit (nconc articles gnus-newsgroup-limit)) | |
23f87bed MB |
8622 | (gnus-summary-limit-include-matching-articles |
8623 | "subject" | |
8624 | (regexp-quote (gnus-simplify-subject-re | |
8625 | (mail-header-subject (gnus-id-to-header id))))) | |
6748645f LMI |
8626 | (gnus-summary-position-point)))) |
8627 | ||
23f87bed MB |
8628 | (defun gnus-summary-limit-include-matching-articles (header regexp) |
8629 | "Display all the hidden articles that have HEADERs that match REGEXP." | |
8630 | (interactive (list (read-string "Match on header: ") | |
8631 | (read-string "Regexp: "))) | |
8632 | (let ((articles (gnus-find-matching-articles header regexp))) | |
8633 | (prog1 | |
8634 | (gnus-summary-limit (nconc articles gnus-newsgroup-limit)) | |
8635 | (gnus-summary-position-point)))) | |
8636 | ||
8637 | (defun gnus-summary-insert-dormant-articles () | |
8638 | "Insert all the dormant articles for this group into the current buffer." | |
8639 | (interactive) | |
8640 | (let ((gnus-verbose (max 6 gnus-verbose))) | |
8641 | (if (not gnus-newsgroup-dormant) | |
db629244 | 8642 | (gnus-message 3 "No dormant articles for this group") |
23f87bed MB |
8643 | (gnus-summary-goto-subjects gnus-newsgroup-dormant)))) |
8644 | ||
01c52d31 MB |
8645 | (defun gnus-summary-insert-ticked-articles () |
8646 | "Insert ticked articles for this group into the current buffer." | |
8647 | (interactive) | |
8648 | (let ((gnus-verbose (max 6 gnus-verbose))) | |
8649 | (if (not gnus-newsgroup-marked) | |
8650 | (gnus-message 3 "No ticked articles for this group") | |
8651 | (gnus-summary-goto-subjects gnus-newsgroup-marked)))) | |
8652 | ||
eec82323 | 8653 | (defun gnus-summary-limit-include-dormant () |
6748645f LMI |
8654 | "Display all the hidden articles that are marked as dormant. |
8655 | Note that this command only works on a subset of the articles currently | |
8656 | fetched for this group." | |
eec82323 | 8657 | (interactive) |
eec82323 LMI |
8658 | (unless gnus-newsgroup-dormant |
8659 | (error "There are no dormant articles in this group")) | |
8660 | (prog1 | |
8661 | (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit)) | |
8662 | (gnus-summary-position-point))) | |
8663 | ||
144b7b5c G |
8664 | (defun gnus-summary-include-articles (articles) |
8665 | "Fetch the headers for ARTICLES and then display the summary lines." | |
8666 | (let ((gnus-inhibit-demon t) | |
8667 | (gnus-agent nil) | |
8668 | (gnus-read-all-available-headers t)) | |
8669 | (setq gnus-newsgroup-headers | |
8670 | (gnus-merge | |
8671 | 'list gnus-newsgroup-headers | |
8672 | (gnus-fetch-headers articles nil t) | |
8673 | 'gnus-article-sort-by-number)) | |
6ed17f11 AC |
8674 | (setq gnus-newsgroup-articles |
8675 | (gnus-sorted-nunion gnus-newsgroup-articles articles)) | |
144b7b5c G |
8676 | (gnus-summary-limit (append articles gnus-newsgroup-limit)))) |
8677 | ||
eec82323 LMI |
8678 | (defun gnus-summary-limit-exclude-dormant () |
8679 | "Hide all dormant articles." | |
8680 | (interactive) | |
eec82323 LMI |
8681 | (prog1 |
8682 | (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse) | |
8683 | (gnus-summary-position-point))) | |
8684 | ||
8685 | (defun gnus-summary-limit-exclude-childless-dormant () | |
8686 | "Hide all dormant articles that have no children." | |
8687 | (interactive) | |
eec82323 LMI |
8688 | (let ((data (gnus-data-list t)) |
8689 | articles d children) | |
8690 | ;; Find all articles that are either not dormant or have | |
8691 | ;; children. | |
8692 | (while (setq d (pop data)) | |
8693 | (when (or (not (= (gnus-data-mark d) gnus-dormant-mark)) | |
8694 | (and (setq children | |
8695 | (gnus-article-children (gnus-data-number d))) | |
8696 | (let (found) | |
8697 | (while children | |
8698 | (when (memq (car children) articles) | |
8699 | (setq children nil | |
8700 | found t)) | |
8701 | (pop children)) | |
8702 | found))) | |
8703 | (push (gnus-data-number d) articles))) | |
8704 | ;; Do the limiting. | |
8705 | (prog1 | |
8706 | (gnus-summary-limit articles) | |
8707 | (gnus-summary-position-point)))) | |
8708 | ||
8709 | (defun gnus-summary-limit-mark-excluded-as-read (&optional all) | |
8710 | "Mark all unread excluded articles as read. | |
8711 | If ALL, mark even excluded ticked and dormants as read." | |
8712 | (interactive "P") | |
23f87bed MB |
8713 | (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<)) |
8714 | (let ((articles (gnus-sorted-ndifference | |
eec82323 LMI |
8715 | (sort |
8716 | (mapcar (lambda (h) (mail-header-number h)) | |
8717 | gnus-newsgroup-headers) | |
8718 | '<) | |
23f87bed | 8719 | gnus-newsgroup-limit)) |
eec82323 | 8720 | article) |
6748645f | 8721 | (setq gnus-newsgroup-unreads |
23f87bed MB |
8722 | (gnus-sorted-intersection gnus-newsgroup-unreads |
8723 | gnus-newsgroup-limit)) | |
eec82323 LMI |
8724 | (if all |
8725 | (setq gnus-newsgroup-dormant nil | |
8726 | gnus-newsgroup-marked nil | |
8727 | gnus-newsgroup-reads | |
8728 | (nconc | |
8729 | (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles) | |
8730 | gnus-newsgroup-reads)) | |
8731 | (while (setq article (pop articles)) | |
8732 | (unless (or (memq article gnus-newsgroup-dormant) | |
8733 | (memq article gnus-newsgroup-marked)) | |
8734 | (push (cons article gnus-catchup-mark) gnus-newsgroup-reads)))))) | |
8735 | ||
8736 | (defun gnus-summary-limit (articles &optional pop) | |
8737 | (if pop | |
8738 | ;; We pop the previous limit off the stack and use that. | |
8739 | (setq articles (car gnus-newsgroup-limits) | |
8740 | gnus-newsgroup-limits (cdr gnus-newsgroup-limits)) | |
8741 | ;; We use the new limit, so we push the old limit on the stack. | |
8742 | (push gnus-newsgroup-limit gnus-newsgroup-limits)) | |
8743 | ;; Set the limit. | |
8744 | (setq gnus-newsgroup-limit articles) | |
8745 | (let ((total (length gnus-newsgroup-data)) | |
8746 | (data (gnus-data-find-list (gnus-summary-article-number))) | |
8747 | (gnus-summary-mark-below nil) ; Inhibit this. | |
8748 | found) | |
8749 | ;; This will do all the work of generating the new summary buffer | |
8750 | ;; according to the new limit. | |
8751 | (gnus-summary-prepare) | |
8752 | ;; Hide any threads, possibly. | |
23f87bed | 8753 | (gnus-summary-maybe-hide-threads) |
eec82323 LMI |
8754 | ;; Try to return to the article you were at, or one in the |
8755 | ;; neighborhood. | |
8756 | (when data | |
8757 | ;; We try to find some article after the current one. | |
8758 | (while data | |
8759 | (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t) | |
8760 | (setq data nil | |
8761 | found t)) | |
8762 | (setq data (cdr data)))) | |
8763 | (unless found | |
8764 | ;; If there is no data, that means that we were after the last | |
8765 | ;; article. The same goes when we can't find any articles | |
8766 | ;; after the current one. | |
8767 | (goto-char (point-max)) | |
8768 | (gnus-summary-find-prev)) | |
6748645f | 8769 | (gnus-set-mode-line 'summary) |
eec82323 LMI |
8770 | ;; We return how many articles were removed from the summary |
8771 | ;; buffer as a result of the new limit. | |
8772 | (- total (length gnus-newsgroup-data)))) | |
8773 | ||
8774 | (defsubst gnus-invisible-cut-children (threads) | |
8775 | (let ((num 0)) | |
8776 | (while threads | |
8777 | (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit) | |
8778 | (incf num)) | |
8779 | (pop threads)) | |
8780 | (< num 2))) | |
8781 | ||
8782 | (defsubst gnus-cut-thread (thread) | |
8783 | "Go forwards in the thread until we find an article that we want to display." | |
8784 | (when (or (eq gnus-fetch-old-headers 'some) | |
6748645f | 8785 | (eq gnus-fetch-old-headers 'invisible) |
16409b0b | 8786 | (numberp gnus-fetch-old-headers) |
eec82323 LMI |
8787 | (eq gnus-build-sparse-threads 'some) |
8788 | (eq gnus-build-sparse-threads 'more)) | |
8789 | ;; Deal with old-fetched headers and sparse threads. | |
8790 | (while (and | |
8791 | thread | |
8792 | (or | |
8793 | (gnus-summary-article-sparse-p (mail-header-number (car thread))) | |
8794 | (gnus-summary-article-ancient-p | |
8795 | (mail-header-number (car thread)))) | |
6748645f LMI |
8796 | (if (or (<= (length (cdr thread)) 1) |
8797 | (eq gnus-fetch-old-headers 'invisible)) | |
8798 | (setq gnus-newsgroup-limit | |
8799 | (delq (mail-header-number (car thread)) | |
8800 | gnus-newsgroup-limit) | |
8801 | thread (cadr thread)) | |
8802 | (when (gnus-invisible-cut-children (cdr thread)) | |
8803 | (let ((th (cdr thread))) | |
8804 | (while th | |
8805 | (if (memq (mail-header-number (caar th)) | |
a8151ef7 | 8806 | gnus-newsgroup-limit) |
6748645f LMI |
8807 | (setq thread (car th) |
8808 | th nil) | |
8809 | (setq th (cdr th)))))))))) | |
eec82323 LMI |
8810 | thread) |
8811 | ||
8812 | (defun gnus-cut-threads (threads) | |
23f87bed | 8813 | "Cut off all uninteresting articles from the beginning of THREADS." |
eec82323 | 8814 | (when (or (eq gnus-fetch-old-headers 'some) |
6748645f | 8815 | (eq gnus-fetch-old-headers 'invisible) |
16409b0b | 8816 | (numberp gnus-fetch-old-headers) |
eec82323 LMI |
8817 | (eq gnus-build-sparse-threads 'some) |
8818 | (eq gnus-build-sparse-threads 'more)) | |
8819 | (let ((th threads)) | |
8820 | (while th | |
8821 | (setcar th (gnus-cut-thread (car th))) | |
8822 | (setq th (cdr th))))) | |
8823 | ;; Remove nixed out threads. | |
8824 | (delq nil threads)) | |
8825 | ||
8826 | (defun gnus-summary-initial-limit (&optional show-if-empty) | |
8827 | "Figure out what the initial limit is supposed to be on group entry. | |
8828 | This entails weeding out unwanted dormants, low-scored articles, | |
8829 | fetch-old-headers verbiage, and so on." | |
8830 | ;; Most groups have nothing to remove. | |
f394fa25 MB |
8831 | (unless (or gnus-inhibit-limiting |
8832 | (and (null gnus-newsgroup-dormant) | |
8833 | (eq gnus-newsgroup-display 'gnus-not-ignore) | |
8834 | (not (eq gnus-fetch-old-headers 'some)) | |
8835 | (not (numberp gnus-fetch-old-headers)) | |
8836 | (not (eq gnus-fetch-old-headers 'invisible)) | |
8837 | (null gnus-summary-expunge-below) | |
8838 | (not (eq gnus-build-sparse-threads 'some)) | |
8839 | (not (eq gnus-build-sparse-threads 'more)) | |
8ccbef23 | 8840 | (null gnus-thread-expunge-below))) |
eec82323 LMI |
8841 | (push gnus-newsgroup-limit gnus-newsgroup-limits) |
8842 | (setq gnus-newsgroup-limit nil) | |
8843 | (mapatoms | |
8844 | (lambda (node) | |
8845 | (unless (car (symbol-value node)) | |
8846 | ;; These threads have no parents -- they are roots. | |
8847 | (let ((nodes (cdr (symbol-value node))) | |
8848 | thread) | |
8849 | (while nodes | |
8850 | (if (and gnus-thread-expunge-below | |
8851 | (< (gnus-thread-total-score (car nodes)) | |
8852 | gnus-thread-expunge-below)) | |
8853 | (gnus-expunge-thread (pop nodes)) | |
8854 | (setq thread (pop nodes)) | |
8855 | (gnus-summary-limit-children thread)))))) | |
8856 | gnus-newsgroup-dependencies) | |
8857 | ;; If this limitation resulted in an empty group, we might | |
8858 | ;; pop the previous limit and use it instead. | |
8859 | (when (and (not gnus-newsgroup-limit) | |
8860 | show-if-empty) | |
8861 | (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits))) | |
8862 | gnus-newsgroup-limit)) | |
8863 | ||
8864 | (defun gnus-summary-limit-children (thread) | |
8865 | "Return 1 if this subthread is visible and 0 if it is not." | |
8866 | ;; First we get the number of visible children to this thread. This | |
8867 | ;; is done by recursing down the thread using this function, so this | |
8868 | ;; will really go down to a leaf article first, before slowly | |
8869 | ;; working its way up towards the root. | |
8870 | (when thread | |
04b61ae9 | 8871 | (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth)) |
23f87bed | 8872 | (children |
eec82323 LMI |
8873 | (if (cdr thread) |
8874 | (apply '+ (mapcar 'gnus-summary-limit-children | |
8875 | (cdr thread))) | |
8876 | 0)) | |
3d319c8f LMI |
8877 | (number (mail-header-number (car thread))) |
8878 | score) | |
eec82323 LMI |
8879 | (if (and |
8880 | (not (memq number gnus-newsgroup-marked)) | |
8881 | (or | |
8882 | ;; If this article is dormant and has absolutely no visible | |
8883 | ;; children, then this article isn't visible. | |
8884 | (and (memq number gnus-newsgroup-dormant) | |
8885 | (zerop children)) | |
8886 | ;; If this is "fetch-old-headered" and there is no | |
8887 | ;; visible children, then we don't want this article. | |
16409b0b GM |
8888 | (and (or (eq gnus-fetch-old-headers 'some) |
8889 | (numberp gnus-fetch-old-headers)) | |
eec82323 LMI |
8890 | (gnus-summary-article-ancient-p number) |
8891 | (zerop children)) | |
6748645f LMI |
8892 | ;; If this is "fetch-old-headered" and `invisible', then |
8893 | ;; we don't want this article. | |
8894 | (and (eq gnus-fetch-old-headers 'invisible) | |
8895 | (gnus-summary-article-ancient-p number)) | |
eec82323 LMI |
8896 | ;; If this is a sparsely inserted article with no children, |
8897 | ;; we don't want it. | |
8898 | (and (eq gnus-build-sparse-threads 'some) | |
8899 | (gnus-summary-article-sparse-p number) | |
8900 | (zerop children)) | |
8901 | ;; If we use expunging, and this article is really | |
8902 | ;; low-scored, then we don't want this article. | |
8903 | (when (and gnus-summary-expunge-below | |
8904 | (< (setq score | |
8905 | (or (cdr (assq number gnus-newsgroup-scored)) | |
8906 | gnus-summary-default-score)) | |
8907 | gnus-summary-expunge-below)) | |
8908 | ;; We increase the expunge-tally here, but that has | |
8909 | ;; nothing to do with the limits, really. | |
8910 | (incf gnus-newsgroup-expunged-tally) | |
8911 | ;; We also mark as read here, if that's wanted. | |
8912 | (when (and gnus-summary-mark-below | |
8913 | (< score gnus-summary-mark-below)) | |
8914 | (setq gnus-newsgroup-unreads | |
8915 | (delq number gnus-newsgroup-unreads)) | |
8916 | (if gnus-newsgroup-auto-expire | |
8917 | (push number gnus-newsgroup-expirable) | |
8918 | (push (cons number gnus-low-score-mark) | |
8919 | gnus-newsgroup-reads))) | |
8920 | t) | |
23f87bed MB |
8921 | ;; Do the `display' group parameter. |
8922 | (and gnus-newsgroup-display | |
3d319c8f LMI |
8923 | (let ((gnus-number number)) |
8924 | (not (funcall gnus-newsgroup-display)))))) | |
eec82323 LMI |
8925 | ;; Nope, invisible article. |
8926 | 0 | |
8927 | ;; Ok, this article is to be visible, so we add it to the limit | |
8928 | ;; and return 1. | |
8929 | (push number gnus-newsgroup-limit) | |
8930 | 1)))) | |
8931 | ||
8932 | (defun gnus-expunge-thread (thread) | |
8933 | "Mark all articles in THREAD as read." | |
8934 | (let* ((number (mail-header-number (car thread)))) | |
8935 | (incf gnus-newsgroup-expunged-tally) | |
8936 | ;; We also mark as read here, if that's wanted. | |
8937 | (setq gnus-newsgroup-unreads | |
8938 | (delq number gnus-newsgroup-unreads)) | |
8939 | (if gnus-newsgroup-auto-expire | |
8940 | (push number gnus-newsgroup-expirable) | |
8941 | (push (cons number gnus-low-score-mark) | |
8942 | gnus-newsgroup-reads))) | |
8943 | ;; Go recursively through all subthreads. | |
8944 | (mapcar 'gnus-expunge-thread (cdr thread))) | |
8945 | ||
8946 | ;; Summary article oriented commands | |
8947 | ||
8948 | (defun gnus-summary-refer-parent-article (n) | |
8949 | "Refer parent article N times. | |
8950 | If N is negative, go to ancestor -N instead. | |
8951 | The difference between N and the number of articles fetched is returned." | |
8952 | (interactive "p") | |
eec82323 LMI |
8953 | (let ((skip 1) |
8954 | error header ref) | |
8955 | (when (not (natnump n)) | |
8956 | (setq skip (abs n) | |
8957 | n 1)) | |
8958 | (while (and (> n 0) | |
8959 | (not error)) | |
8960 | (setq header (gnus-summary-article-header)) | |
8961 | (if (and (eq (mail-header-number header) | |
8962 | (cdr gnus-article-current)) | |
8963 | (equal gnus-newsgroup-name | |
8964 | (car gnus-article-current))) | |
8965 | ;; If we try to find the parent of the currently | |
8966 | ;; displayed article, then we take a look at the actual | |
8967 | ;; References header, since this is slightly more | |
8968 | ;; reliable than the References field we got from the | |
8969 | ;; server. | |
c7a91ce1 | 8970 | (with-current-buffer gnus-original-article-buffer |
eec82323 LMI |
8971 | (nnheader-narrow-to-headers) |
8972 | (unless (setq ref (message-fetch-field "references")) | |
23f87bed MB |
8973 | (when (setq ref (message-fetch-field "in-reply-to")) |
8974 | (setq ref (gnus-extract-message-id-from-in-reply-to ref)))) | |
eec82323 LMI |
8975 | (widen)) |
8976 | (setq ref | |
8977 | ;; It's not the current article, so we take a bet on | |
8978 | ;; the value we got from the server. | |
8979 | (mail-header-references header))) | |
8980 | (if (and ref | |
8981 | (not (equal ref ""))) | |
8982 | (unless (gnus-summary-refer-article (gnus-parent-id ref skip)) | |
8983 | (gnus-message 1 "Couldn't find parent")) | |
8984 | (gnus-message 1 "No references in article %d" | |
8985 | (gnus-summary-article-number)) | |
8986 | (setq error t)) | |
8987 | (decf n)) | |
8988 | (gnus-summary-position-point) | |
8989 | n)) | |
8990 | ||
8991 | (defun gnus-summary-refer-references () | |
8992 | "Fetch all articles mentioned in the References header. | |
6748645f | 8993 | Return the number of articles fetched." |
eec82323 | 8994 | (interactive) |
eec82323 LMI |
8995 | (let ((ref (mail-header-references (gnus-summary-article-header))) |
8996 | (current (gnus-summary-article-number)) | |
8997 | (n 0)) | |
8998 | (if (or (not ref) | |
8999 | (equal ref "")) | |
9000 | (error "No References in the current article") | |
9001 | ;; For each Message-ID in the References header... | |
9002 | (while (string-match "<[^>]*>" ref) | |
9003 | (incf n) | |
9004 | ;; ... fetch that article. | |
9005 | (gnus-summary-refer-article | |
9006 | (prog1 (match-string 0 ref) | |
9007 | (setq ref (substring ref (match-end 0)))))) | |
9008 | (gnus-summary-goto-subject current) | |
9009 | (gnus-summary-position-point) | |
9010 | n))) | |
9011 | ||
ae97e645 G |
9012 | (defun gnus-delete-duplicate-headers (headers) |
9013 | ;; First remove leading duplicates. | |
9014 | (while (and (> (length headers) 1) | |
9015 | (= (mail-header-number (car headers)) | |
9016 | (mail-header-number (cadr headers)))) | |
9017 | (pop headers)) | |
9018 | ;; Then the rest. | |
9019 | (let ((result headers)) | |
9020 | (while (> (length headers) 1) | |
9021 | (if (= (mail-header-number (car headers)) | |
9022 | (mail-header-number (cadr headers))) | |
9023 | (setcdr headers (cddr headers)) | |
9024 | (pop headers))) | |
9025 | result)) | |
9026 | ||
6748645f | 9027 | (defun gnus-summary-refer-thread (&optional limit) |
47f0b35e AC |
9028 | "Fetch all articles in the current thread. For backends that |
9029 | know how to search for threads (currently only 'nnimap) a | |
9030 | non-numeric prefix arg will use nnir to search the entire | |
9031 | server; without a prefix arg only the current group is | |
9032 | searched. If the variable `gnus-refer-thread-use-nnir' is | |
9033 | non-nil the prefix arg has the reverse meaning. If no | |
9034 | backend-specific 'request-thread function is available fetch | |
9035 | LIMIT (the numerical prefix) old headers. If LIMIT is | |
9036 | non-numeric or nil fetch the number specified by the | |
9037 | `gnus-refer-thread-limit' variable." | |
6748645f | 9038 | (interactive "P") |
4ddab346 | 9039 | (gnus-warp-to-article) |
70041e9a G |
9040 | (let* ((header (gnus-summary-article-header)) |
9041 | (id (mail-header-id header)) | |
9042 | (gnus-inhibit-demon t) | |
9043 | (gnus-summary-ignore-duplicates t) | |
9044 | (gnus-read-all-available-headers t) | |
47f0b35e AC |
9045 | (gnus-refer-thread-use-nnir |
9046 | (if (and (not (null limit)) (listp limit)) | |
9047 | (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir)) | |
ae97e645 G |
9048 | (new-headers |
9049 | (if (gnus-check-backend-function | |
9050 | 'request-thread gnus-newsgroup-name) | |
9051 | (gnus-request-thread header gnus-newsgroup-name) | |
47f0b35e AC |
9052 | (let* ((limit (if (numberp limit) (prefix-numeric-value limit) |
9053 | gnus-refer-thread-limit)) | |
9054 | (last (if (numberp limit) | |
ae97e645 G |
9055 | (min (+ (mail-header-number header) |
9056 | limit) | |
9057 | gnus-newsgroup-highest) | |
9058 | gnus-newsgroup-highest)) | |
9059 | (subject (gnus-simplify-subject | |
9060 | (mail-header-subject header))) | |
9061 | (refs (split-string (or (mail-header-references header) | |
9062 | ""))) | |
9063 | (gnus-parse-headers-hook | |
93855df9 | 9064 | `(lambda () (goto-char (point-min)) |
ae97e645 | 9065 | (keep-lines |
93855df9 | 9066 | (regexp-opt ',(append refs (list id subject))))))) |
ae97e645 | 9067 | (gnus-fetch-headers (list last) (if (numberp limit) |
6ed17f11 AC |
9068 | (* 2 limit) limit) t)))) |
9069 | article-ids) | |
47f0b35e AC |
9070 | (when (listp new-headers) |
9071 | (dolist (header new-headers) | |
6ed17f11 | 9072 | (push (mail-header-number header) article-ids) |
47f0b35e AC |
9073 | (when (member (mail-header-number header) gnus-newsgroup-unselected) |
9074 | (push (mail-header-number header) gnus-newsgroup-unreads) | |
9075 | (setq gnus-newsgroup-unselected | |
9076 | (delete (mail-header-number header) | |
9077 | gnus-newsgroup-unselected)))) | |
9078 | (setq gnus-newsgroup-headers | |
9079 | (gnus-delete-duplicate-headers | |
9080 | (gnus-merge | |
9081 | 'list gnus-newsgroup-headers new-headers | |
9082 | 'gnus-article-sort-by-number))) | |
6ed17f11 AC |
9083 | (setq gnus-newsgroup-articles |
9084 | (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids))) | |
e7719ea1 G |
9085 | (gnus-summary-limit-include-thread id))) |
9086 | (gnus-summary-show-thread)) | |
6748645f | 9087 | |
4d2226bf G |
9088 | (defun gnus-summary-open-group-with-article (message-id) |
9089 | "Open a group containing the article with the given MESSAGE-ID." | |
9090 | (interactive "sMessage-ID: ") | |
9091 | (require 'nndoc) | |
9092 | (with-temp-buffer | |
9093 | ;; Prepare a dummy article | |
9094 | (erase-buffer) | |
9095 | (insert "From nobody Tue Sep 13 22:05:34 2011\n\n") | |
9096 | ||
9097 | ;; Prepare pretty modelines for summary and article buffers | |
9098 | (let ((gnus-summary-mode-line-format "Found %G") | |
9099 | (gnus-article-mode-line-format | |
9100 | ;; Group names just get in the way here, especially the | |
9101 | ;; abbreviated ones | |
9102 | (if (string-match "%[gG]" gnus-article-mode-line-format) | |
9103 | (concat (substring gnus-article-mode-line-format | |
9104 | 0 (match-beginning 0)) | |
9105 | (substring gnus-article-mode-line-format (match-end 0))) | |
9106 | gnus-article-mode-line-format))) | |
9107 | ||
9108 | ;; Build an ephemeral group containing the dummy article (hidden) | |
9109 | (gnus-group-read-ephemeral-group | |
9110 | message-id | |
9111 | `(nndoc ,message-id | |
9112 | (nndoc-address ,(current-buffer)) | |
9113 | (nndoc-article-type mbox)) | |
9114 | :activate | |
9115 | (cons (current-buffer) gnus-current-window-configuration) | |
9116 | (not :request-only) | |
9117 | '(-1) ; :select-articles | |
9118 | (not :parameters) | |
9119 | 0)) ; :number | |
9120 | ;; Fetch the desired article | |
9121 | (gnus-summary-refer-article message-id))) | |
9122 | ||
16409b0b GM |
9123 | (defun gnus-summary-refer-article (message-id) |
9124 | "Fetch an article specified by MESSAGE-ID." | |
9125 | (interactive "sMessage-ID: ") | |
d747b53f | 9126 | (gnus-warp-to-article) |
eec82323 LMI |
9127 | (when (and (stringp message-id) |
9128 | (not (zerop (length message-id)))) | |
23f87bed | 9129 | (setq message-id (gnus-replace-in-string message-id " " "")) |
eec82323 LMI |
9130 | ;; Construct the correct Message-ID if necessary. |
9131 | ;; Suggested by tale@pawl.rpi.edu. | |
9132 | (unless (string-match "^<" message-id) | |
9133 | (setq message-id (concat "<" message-id))) | |
9134 | (unless (string-match ">$" message-id) | |
9135 | (setq message-id (concat message-id ">"))) | |
23f87bed MB |
9136 | ;; People often post MIDs from URLs, so unhex it: |
9137 | (unless (string-match "@" message-id) | |
9138 | (setq message-id (gnus-url-unhex-string message-id))) | |
eec82323 LMI |
9139 | (let* ((header (gnus-id-to-header message-id)) |
9140 | (sparse (and header | |
9141 | (gnus-summary-article-sparse-p | |
a8151ef7 LMI |
9142 | (mail-header-number header)) |
9143 | (memq (mail-header-number header) | |
16409b0b GM |
9144 | gnus-newsgroup-limit))) |
9145 | number) | |
6748645f LMI |
9146 | (cond |
9147 | ;; If the article is present in the buffer we just go to it. | |
9148 | ((and header | |
9149 | (or (not (gnus-summary-article-sparse-p | |
9150 | (mail-header-number header))) | |
9151 | sparse)) | |
9152 | (prog1 | |
9153 | (gnus-summary-goto-article | |
9154 | (mail-header-number header) nil t) | |
9155 | (when sparse | |
9156 | (gnus-summary-update-article (mail-header-number header))))) | |
9157 | (t | |
16409b0b GM |
9158 | ;; We fetch the article. |
9159 | (catch 'found | |
9160 | (dolist (gnus-override-method (gnus-refer-article-methods)) | |
23f87bed MB |
9161 | (when (and (gnus-check-server gnus-override-method) |
9162 | ;; Fetch the header, | |
9163 | (setq number (gnus-summary-insert-subject message-id))) | |
9164 | ;; and display the article. | |
eec82323 | 9165 | (gnus-summary-select-article nil nil nil number) |
16409b0b GM |
9166 | (throw 'found t))) |
9167 | (gnus-message 3 "Couldn't fetch article %s" message-id))))))) | |
9168 | ||
9169 | (defun gnus-refer-article-methods () | |
8f688cb0 | 9170 | "Return a list of referable methods." |
16409b0b GM |
9171 | (cond |
9172 | ;; No method, so we default to current and native. | |
9173 | ((null gnus-refer-article-method) | |
9174 | (list gnus-current-select-method gnus-select-method)) | |
9175 | ;; Current. | |
9176 | ((eq 'current gnus-refer-article-method) | |
9177 | (list gnus-current-select-method)) | |
9178 | ;; List of select methods. | |
d4dfaa19 DL |
9179 | ((not (and (symbolp (car gnus-refer-article-method)) |
9180 | (assq (car gnus-refer-article-method) nnoo-definition-alist))) | |
16409b0b GM |
9181 | (let (out) |
9182 | (dolist (method gnus-refer-article-method) | |
9183 | (push (if (eq 'current method) | |
9184 | gnus-current-select-method | |
b09c3fe0 G |
9185 | (if (eq 'nnir (car method)) |
9186 | (list | |
9187 | 'nnir | |
9188 | (or (cadr method) | |
9189 | (gnus-method-to-server gnus-current-select-method))) | |
9190 | method)) | |
16409b0b GM |
9191 | out)) |
9192 | (nreverse out))) | |
9193 | ;; One single select method. | |
9194 | (t | |
9195 | (list gnus-refer-article-method)))) | |
6748645f LMI |
9196 | |
9197 | (defun gnus-summary-edit-parameters () | |
9198 | "Edit the group parameters of the current group." | |
9199 | (interactive) | |
9200 | (gnus-group-edit-group gnus-newsgroup-name 'params)) | |
eec82323 | 9201 | |
16409b0b GM |
9202 | (defun gnus-summary-customize-parameters () |
9203 | "Customize the group parameters of the current group." | |
9204 | (interactive) | |
9205 | (gnus-group-customize gnus-newsgroup-name)) | |
9206 | ||
eec82323 LMI |
9207 | (defun gnus-summary-enter-digest-group (&optional force) |
9208 | "Enter an nndoc group based on the current article. | |
07176b2a LMI |
9209 | If FORCE, force a digest interpretation. If not, try to guess |
9210 | what the document format is. | |
9211 | ||
9212 | To control what happens when you exit the group, see the | |
9213 | `gnus-auto-select-on-ephemeral-exit' variable." | |
eec82323 | 9214 | (interactive "P") |
eec82323 | 9215 | (let ((conf gnus-current-window-configuration)) |
23f87bed MB |
9216 | (save-window-excursion |
9217 | (save-excursion | |
9218 | (let (gnus-article-prepare-hook | |
9219 | gnus-display-mime-function | |
9220 | gnus-break-pages) | |
9221 | (gnus-summary-select-article)))) | |
eec82323 LMI |
9222 | (setq gnus-current-window-configuration conf) |
9223 | (let* ((name (format "%s-%d" | |
9224 | (gnus-group-prefixed-name | |
9225 | gnus-newsgroup-name (list 'nndoc "")) | |
01c52d31 | 9226 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
9227 | gnus-current-article))) |
9228 | (ogroup gnus-newsgroup-name) | |
9229 | (params (append (gnus-info-params (gnus-get-info ogroup)) | |
9230 | (list (cons 'to-group ogroup)) | |
23f87bed | 9231 | (list (cons 'parent-group ogroup)) |
eec82323 LMI |
9232 | (list (cons 'save-article-group ogroup)))) |
9233 | (case-fold-search t) | |
9234 | (buf (current-buffer)) | |
cc319c03 | 9235 | dig to-address charset) |
c7a91ce1 | 9236 | (with-current-buffer gnus-original-article-buffer |
16409b0b GM |
9237 | ;; Have the digest group inherit the main mail address of |
9238 | ;; the parent article. | |
23f87bed MB |
9239 | (when (setq to-address (or (gnus-fetch-field "reply-to") |
9240 | (gnus-fetch-field "from"))) | |
343d6628 MB |
9241 | (setq params |
9242 | (append | |
ed88fb10 | 9243 | params |
343d6628 MB |
9244 | (list (cons 'to-address |
9245 | (funcall gnus-decode-encoded-address-function | |
9246 | to-address)))))) | |
eec82323 LMI |
9247 | (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*")) |
9248 | (insert-buffer-substring gnus-original-article-buffer) | |
eec82323 LMI |
9249 | (narrow-to-region |
9250 | (goto-char (point-min)) | |
9251 | (or (search-forward "\n\n" nil t) (point))) | |
cc319c03 KY |
9252 | ;; Remove lines that may lead nndoc to misinterpret the |
9253 | ;; document type. | |
eec82323 | 9254 | (goto-char (point-min)) |
16409b0b | 9255 | (delete-matching-lines "^Path:\\|^From ") |
cc319c03 KY |
9256 | ;; Parse charset, and decode content transfer encoding. |
9257 | (setq charset (mail-content-type-get | |
9258 | (mail-header-parse-content-type | |
9259 | (or (gnus-fetch-field "content-type") "")) | |
9260 | 'charset)) | |
9261 | (let ((encoding (gnus-fetch-field "content-transfer-encoding"))) | |
9262 | (when encoding | |
9263 | (message-remove-header "content-transfer-encoding") | |
9264 | (goto-char (point-max)) | |
9265 | (widen) | |
9266 | (narrow-to-region (point) (point-max)) | |
9267 | (mm-decode-content-transfer-encoding | |
9268 | (intern (downcase (mail-header-strip encoding)))))) | |
eec82323 LMI |
9269 | (widen)) |
9270 | (unwind-protect | |
cc319c03 KY |
9271 | (if (let ((gnus-newsgroup-ephemeral-charset |
9272 | (if charset | |
9273 | (intern (downcase (gnus-strip-whitespace charset))) | |
9274 | gnus-newsgroup-charset)) | |
16409b0b GM |
9275 | (gnus-newsgroup-ephemeral-ignored-charsets |
9276 | gnus-newsgroup-ignored-charsets)) | |
9277 | (gnus-group-read-ephemeral-group | |
9278 | name `(nndoc ,name (nndoc-address ,(get-buffer dig)) | |
9279 | (nndoc-article-type | |
23f87bed MB |
9280 | ,(if force 'mbox 'guess))) |
9281 | t nil nil nil | |
9282 | `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name | |
9283 | "ADAPT"))))) | |
16409b0b | 9284 | ;; Make all postings to this group go to the parent group. |
23f87bed MB |
9285 | (nconc (gnus-info-params (gnus-get-info name)) |
9286 | params) | |
9287 | ;; Couldn't select this doc group. | |
9288 | (switch-to-buffer buf) | |
9289 | (gnus-set-global-variables) | |
9290 | (gnus-configure-windows 'summary) | |
9291 | (gnus-message 3 "Article couldn't be entered?")) | |
eec82323 LMI |
9292 | (kill-buffer dig))))) |
9293 | ||
9294 | (defun gnus-summary-read-document (n) | |
9295 | "Open a new group based on the current article(s). | |
9296 | This will allow you to read digests and other similar | |
9297 | documents as newsgroups. | |
9298 | Obeys the standard process/prefix convention." | |
9299 | (interactive "P") | |
01c52d31 | 9300 | (let* ((ogroup gnus-newsgroup-name) |
eec82323 LMI |
9301 | (params (append (gnus-info-params (gnus-get-info ogroup)) |
9302 | (list (cons 'to-group ogroup)))) | |
01c52d31 MB |
9303 | group egroup groups vgroup) |
9304 | (dolist (article (gnus-summary-work-articles n)) | |
eec82323 LMI |
9305 | (setq group (format "%s-%d" gnus-newsgroup-name article)) |
9306 | (gnus-summary-remove-process-mark article) | |
9307 | (when (gnus-summary-display-article article) | |
398a825b | 9308 | (save-excursion ;;What for? |
16409b0b | 9309 | (with-temp-buffer |
eec82323 LMI |
9310 | (insert-buffer-substring gnus-original-article-buffer) |
9311 | ;; Remove some headers that may lead nndoc to make | |
9312 | ;; the wrong guess. | |
9313 | (message-narrow-to-head) | |
9314 | (goto-char (point-min)) | |
01c52d31 | 9315 | (delete-matching-lines "^Path:\\|^From ") |
eec82323 LMI |
9316 | (widen) |
9317 | (if (setq egroup | |
9318 | (gnus-group-read-ephemeral-group | |
9319 | group `(nndoc ,group (nndoc-address ,(current-buffer)) | |
9320 | (nndoc-article-type guess)) | |
9321 | t nil t)) | |
9322 | (progn | |
c7a91ce1 | 9323 | ;; Make all postings to this group go to the parent group. |
eec82323 LMI |
9324 | (nconc (gnus-info-params (gnus-get-info egroup)) |
9325 | params) | |
9326 | (push egroup groups)) | |
9327 | ;; Couldn't select this doc group. | |
9328 | (gnus-error 3 "Article couldn't be entered")))))) | |
9329 | ;; Now we have selected all the documents. | |
9330 | (cond | |
9331 | ((not groups) | |
9332 | (error "None of the articles could be interpreted as documents")) | |
9333 | ((gnus-group-read-ephemeral-group | |
9334 | (setq vgroup (format | |
9335 | "nnvirtual:%s-%s" gnus-newsgroup-name | |
9336 | (format-time-string "%Y%m%dT%H%M%S" (current-time)))) | |
9337 | `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups)) | |
9338 | t | |
9339 | (cons (current-buffer) 'summary))) | |
9340 | (t | |
9341 | (error "Couldn't select virtual nndoc group"))))) | |
9342 | ||
d50717f0 JD |
9343 | (defun gnus-summary-widget-forward (arg) |
9344 | "Move point to the next field or button in the article. | |
9345 | With optional ARG, move across that many fields." | |
9346 | (interactive "p") | |
9347 | (gnus-summary-select-article) | |
9348 | (gnus-configure-windows 'article) | |
9349 | (select-window (gnus-get-buffer-window gnus-article-buffer)) | |
9350 | (widget-forward arg)) | |
9351 | ||
89b163db G |
9352 | (defun gnus-summary-widget-backward (arg) |
9353 | "Move point to the previous field or button in the article. | |
9354 | With optional ARG, move across that many fields." | |
9355 | (interactive "p") | |
9356 | (gnus-summary-select-article) | |
9357 | (gnus-configure-windows 'article) | |
9358 | (select-window (gnus-get-buffer-window gnus-article-buffer)) | |
9359 | (unless (widget-at (point)) | |
9360 | (goto-char (point-max))) | |
9361 | (widget-backward arg)) | |
9362 | ||
eec82323 LMI |
9363 | (defun gnus-summary-isearch-article (&optional regexp-p) |
9364 | "Do incremental search forward on the current article. | |
9365 | If REGEXP-P (the prefix) is non-nil, do regexp isearch." | |
9366 | (interactive "P") | |
eec82323 LMI |
9367 | (gnus-summary-select-article) |
9368 | (gnus-configure-windows 'article) | |
9369 | (gnus-eval-in-buffer-window gnus-article-buffer | |
6748645f LMI |
9370 | (save-restriction |
9371 | (widen) | |
9372 | (isearch-forward regexp-p)))) | |
eec82323 | 9373 | |
01c52d31 MB |
9374 | (defun gnus-summary-repeat-search-article-forward () |
9375 | "Repeat the previous search forwards." | |
9376 | (interactive) | |
9377 | (unless gnus-last-search-regexp | |
9378 | (error "No previous search")) | |
9379 | (gnus-summary-search-article-forward gnus-last-search-regexp)) | |
9380 | ||
9381 | (defun gnus-summary-repeat-search-article-backward () | |
9382 | "Repeat the previous search backwards." | |
9383 | (interactive) | |
9384 | (unless gnus-last-search-regexp | |
9385 | (error "No previous search")) | |
9386 | (gnus-summary-search-article-forward gnus-last-search-regexp t)) | |
9387 | ||
eec82323 LMI |
9388 | (defun gnus-summary-search-article-forward (regexp &optional backward) |
9389 | "Search for an article containing REGEXP forward. | |
9390 | If BACKWARD, search backward instead." | |
9391 | (interactive | |
9392 | (list (read-string | |
9393 | (format "Search article %s (regexp%s): " | |
9394 | (if current-prefix-arg "backward" "forward") | |
9395 | (if gnus-last-search-regexp | |
9396 | (concat ", default " gnus-last-search-regexp) | |
9397 | ""))) | |
9398 | current-prefix-arg)) | |
eec82323 LMI |
9399 | (if (string-equal regexp "") |
9400 | (setq regexp (or gnus-last-search-regexp "")) | |
23f87bed MB |
9401 | (setq gnus-last-search-regexp regexp) |
9402 | (setq gnus-article-before-search gnus-current-article)) | |
9403 | ;; Intentionally set gnus-last-article. | |
9404 | (setq gnus-last-article gnus-article-before-search) | |
9405 | (let ((gnus-last-article gnus-last-article)) | |
9406 | (if (gnus-summary-search-article regexp backward) | |
9407 | (gnus-summary-show-thread) | |
abc40aab | 9408 | (signal 'search-failed (list regexp))))) |
eec82323 LMI |
9409 | |
9410 | (defun gnus-summary-search-article-backward (regexp) | |
9411 | "Search for an article containing REGEXP backward." | |
9412 | (interactive | |
9413 | (list (read-string | |
9414 | (format "Search article backward (regexp%s): " | |
9415 | (if gnus-last-search-regexp | |
9416 | (concat ", default " gnus-last-search-regexp) | |
9417 | ""))))) | |
9418 | (gnus-summary-search-article-forward regexp 'backward)) | |
9419 | ||
9420 | (defun gnus-summary-search-article (regexp &optional backward) | |
9421 | "Search for an article containing REGEXP. | |
9422 | Optional argument BACKWARD means do search for backward. | |
9423 | `gnus-select-article-hook' is not called during the search." | |
a8151ef7 LMI |
9424 | ;; We have to require this here to make sure that the following |
9425 | ;; dynamic binding isn't shadowed by autoloading. | |
9426 | (require 'gnus-async) | |
16409b0b | 9427 | (require 'gnus-art) |
eec82323 | 9428 | (let ((gnus-select-article-hook nil) ;Disable hook. |
16409b0b | 9429 | (gnus-article-prepare-hook nil) |
eec82323 LMI |
9430 | (gnus-mark-article-hook nil) ;Inhibit marking as read. |
9431 | (gnus-use-article-prefetch nil) | |
9432 | (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay. | |
a8151ef7 | 9433 | (gnus-use-trees nil) ;Inhibit updating tree buffer. |
23f87bed MB |
9434 | (gnus-visual nil) |
9435 | (gnus-keep-backlog nil) | |
9436 | (gnus-break-pages nil) | |
9437 | (gnus-summary-display-arrow nil) | |
9438 | (gnus-updated-mode-lines nil) | |
9439 | (gnus-auto-center-summary nil) | |
eec82323 | 9440 | (sum (current-buffer)) |
16409b0b | 9441 | (gnus-display-mime-function nil) |
eec82323 LMI |
9442 | (found nil) |
9443 | point) | |
9444 | (gnus-save-hidden-threads | |
9445 | (gnus-summary-select-article) | |
9446 | (set-buffer gnus-article-buffer) | |
16409b0b | 9447 | (goto-char (window-point (get-buffer-window (current-buffer)))) |
eec82323 LMI |
9448 | (when backward |
9449 | (forward-line -1)) | |
9450 | (while (not found) | |
9451 | (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current)) | |
9452 | (if (if backward | |
9453 | (re-search-backward regexp nil t) | |
9454 | (re-search-forward regexp nil t)) | |
9455 | ;; We found the regexp. | |
9456 | (progn | |
9457 | (setq found 'found) | |
9458 | (beginning-of-line) | |
9459 | (set-window-start | |
9460 | (get-buffer-window (current-buffer)) | |
9461 | (point)) | |
9462 | (forward-line 1) | |
16409b0b GM |
9463 | (set-window-point |
9464 | (get-buffer-window (current-buffer)) | |
9465 | (point)) | |
eec82323 LMI |
9466 | (set-buffer sum) |
9467 | (setq point (point))) | |
9468 | ;; We didn't find it, so we go to the next article. | |
9469 | (set-buffer sum) | |
9470 | (setq found 'not) | |
9471 | (while (eq found 'not) | |
9472 | (if (not (if backward (gnus-summary-find-prev) | |
9473 | (gnus-summary-find-next))) | |
9474 | ;; No more articles. | |
9475 | (setq found t) | |
9476 | ;; Select the next article and adjust point. | |
9477 | (unless (gnus-summary-article-sparse-p | |
9478 | (gnus-summary-article-number)) | |
9479 | (setq found nil) | |
9480 | (gnus-summary-select-article) | |
9481 | (set-buffer gnus-article-buffer) | |
9482 | (widen) | |
9483 | (goto-char (if backward (point-max) (point-min)))))))) | |
9484 | (gnus-message 7 "")) | |
9485 | ;; Return whether we found the regexp. | |
9486 | (when (eq found 'found) | |
9487 | (goto-char point) | |
9488 | (gnus-summary-show-thread) | |
9489 | (gnus-summary-goto-subject gnus-current-article) | |
9490 | (gnus-summary-position-point) | |
9491 | t))) | |
9492 | ||
23f87bed MB |
9493 | (defun gnus-find-matching-articles (header regexp) |
9494 | "Return a list of all articles that match REGEXP on HEADER. | |
9495 | This search includes all articles in the current group that Gnus has | |
9496 | fetched headers for, whether they are displayed or not." | |
9497 | (let ((articles nil) | |
c7a91ce1 | 9498 | ;; Can't eta-reduce because it's a macro. |
23f87bed MB |
9499 | (func `(lambda (h) (,(intern (concat "mail-header-" header)) h))) |
9500 | (case-fold-search t)) | |
9501 | (dolist (header gnus-newsgroup-headers) | |
9502 | (when (string-match regexp (funcall func header)) | |
9503 | (push (mail-header-number header) articles))) | |
9504 | (nreverse articles))) | |
9505 | ||
eec82323 | 9506 | (defun gnus-summary-find-matching (header regexp &optional backward unread |
47b63dfa | 9507 | not-case-fold not-matching) |
eec82323 LMI |
9508 | "Return a list of all articles that match REGEXP on HEADER. |
9509 | The search stars on the current article and goes forwards unless | |
9510 | BACKWARD is non-nil. If BACKWARD is `all', do all articles. | |
9511 | If UNREAD is non-nil, only unread articles will | |
9512 | be taken into consideration. If NOT-CASE-FOLD, case won't be folded | |
a1506d29 | 9513 | in the comparisons. If NOT-MATCHING, return a list of all articles that |
47b63dfa SZ |
9514 | not match REGEXP on HEADER." |
9515 | (let ((case-fold-search (not not-case-fold)) | |
16409b0b GM |
9516 | articles d func) |
9517 | (if (consp header) | |
9518 | (if (eq (car header) 'extra) | |
9519 | (setq func | |
9520 | `(lambda (h) | |
9521 | (or (cdr (assq ',(cdr header) (mail-header-extra h))) | |
9522 | ""))) | |
9523 | (error "%s is an invalid header" header)) | |
9524 | (unless (fboundp (intern (concat "mail-header-" header))) | |
9525 | (error "%s is not a valid header" header)) | |
9526 | (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))) | |
47b63dfa SZ |
9527 | (dolist (d (if (eq backward 'all) |
9528 | gnus-newsgroup-data | |
9529 | (gnus-data-find-list | |
9530 | (gnus-summary-article-number) | |
9531 | (gnus-data-list backward)))) | |
9532 | (when (and (or (not unread) ; We want all articles... | |
9533 | (gnus-data-unread-p d)) ; Or just unreads. | |
9534 | (vectorp (gnus-data-header d)) ; It's not a pseudo. | |
9535 | (if not-matching | |
a1506d29 | 9536 | (not (string-match |
47b63dfa SZ |
9537 | regexp |
9538 | (funcall func (gnus-data-header d)))) | |
9539 | (string-match regexp | |
9540 | (funcall func (gnus-data-header d))))) | |
9541 | (push (gnus-data-number d) articles))) ; Success! | |
eec82323 LMI |
9542 | (nreverse articles))) |
9543 | ||
9544 | (defun gnus-summary-execute-command (header regexp command &optional backward) | |
9545 | "Search forward for an article whose HEADER matches REGEXP and execute COMMAND. | |
9546 | If HEADER is an empty string (or nil), the match is done on the entire | |
9547 | article. If BACKWARD (the prefix) is non-nil, search backward instead." | |
9548 | (interactive | |
9549 | (list (let ((completion-ignore-case t)) | |
229b59da G |
9550 | (gnus-completing-read |
9551 | "Header name" | |
9552 | (mapcar 'symbol-name | |
23f87bed | 9553 | (append |
229b59da G |
9554 | '(Number Subject From Lines Date |
9555 | Message-ID Xref References Body) | |
23f87bed | 9556 | gnus-extra-headers)) |
229b59da | 9557 | 'require-match)) |
eec82323 LMI |
9558 | (read-string "Regexp: ") |
9559 | (read-key-sequence "Command: ") | |
9560 | current-prefix-arg)) | |
9561 | (when (equal header "Body") | |
9562 | (setq header "")) | |
eec82323 LMI |
9563 | ;; Hidden thread subtrees must be searched as well. |
9564 | (gnus-summary-show-all-threads) | |
9565 | ;; We don't want to change current point nor window configuration. | |
9566 | (save-excursion | |
9567 | (save-window-excursion | |
23f87bed MB |
9568 | (let (gnus-visual |
9569 | gnus-treat-strip-trailing-blank-lines | |
9570 | gnus-treat-strip-leading-blank-lines | |
9571 | gnus-treat-strip-multiple-blank-lines | |
9572 | gnus-treat-hide-boring-headers | |
9573 | gnus-treat-fold-newsgroups | |
9574 | gnus-article-prepare-hook) | |
9575 | (gnus-message 6 "Executing %s..." (key-description command)) | |
9576 | ;; We'd like to execute COMMAND interactively so as to give arguments. | |
9577 | (gnus-execute header regexp | |
9578 | `(call-interactively ',(key-binding command)) | |
9579 | backward) | |
9580 | (gnus-message 6 "Executing %s...done" (key-description command)))))) | |
eec82323 LMI |
9581 | |
9582 | (defun gnus-summary-beginning-of-article () | |
9583 | "Scroll the article back to the beginning." | |
9584 | (interactive) | |
eec82323 LMI |
9585 | (gnus-summary-select-article) |
9586 | (gnus-configure-windows 'article) | |
9587 | (gnus-eval-in-buffer-window gnus-article-buffer | |
9588 | (widen) | |
9589 | (goto-char (point-min)) | |
23f87bed | 9590 | (when gnus-break-pages |
eec82323 LMI |
9591 | (gnus-narrow-to-page)))) |
9592 | ||
9593 | (defun gnus-summary-end-of-article () | |
9594 | "Scroll to the end of the article." | |
9595 | (interactive) | |
eec82323 LMI |
9596 | (gnus-summary-select-article) |
9597 | (gnus-configure-windows 'article) | |
9598 | (gnus-eval-in-buffer-window gnus-article-buffer | |
9599 | (widen) | |
9600 | (goto-char (point-max)) | |
9601 | (recenter -3) | |
23f87bed | 9602 | (when gnus-break-pages |
eec82323 LMI |
9603 | (gnus-narrow-to-page)))) |
9604 | ||
23f87bed MB |
9605 | (defun gnus-summary-print-truncate-and-quote (string &optional len) |
9606 | "Truncate to LEN and quote all \"(\"'s in STRING." | |
9607 | (gnus-replace-in-string (if (and len (> (length string) len)) | |
9608 | (substring string 0 len) | |
9609 | string) | |
9610 | "[()]" "\\\\\\&")) | |
9611 | ||
6748645f | 9612 | (defun gnus-summary-print-article (&optional filename n) |
23f87bed MB |
9613 | "Generate and print a PostScript image of the process-marked (mail) articles. |
9614 | ||
9615 | If used interactively, print the current article if none are | |
9616 | process-marked. With prefix arg, prompt the user for the name of the | |
9617 | file to save in. | |
6748645f | 9618 | |
23f87bed MB |
9619 | When used from Lisp, accept two optional args FILENAME and N. N means |
9620 | to print the next N articles. If N is negative, print the N previous | |
9621 | articles. If N is nil and articles have been marked with the process | |
9622 | mark, print these instead. | |
eec82323 | 9623 | |
16409b0b | 9624 | If the optional first argument FILENAME is nil, send the image to the |
6748645f LMI |
9625 | printer. If FILENAME is a string, save the PostScript image in a file with |
9626 | that name. If FILENAME is a number, prompt the user for the name of the file | |
eec82323 | 9627 | to save in." |
676a7cc9 | 9628 | (interactive (list (ps-print-preprint current-prefix-arg))) |
6748645f LMI |
9629 | (dolist (article (gnus-summary-work-articles n)) |
9630 | (gnus-summary-select-article nil nil 'pseudo article) | |
9631 | (gnus-eval-in-buffer-window gnus-article-buffer | |
23f87bed | 9632 | (gnus-print-buffer)) |
676a7cc9 SZ |
9633 | (gnus-summary-remove-process-mark article)) |
9634 | (ps-despool filename)) | |
eec82323 | 9635 | |
23f87bed | 9636 | (defun gnus-print-buffer () |
285cf7c8 LMI |
9637 | (let ((ps-left-header |
9638 | (list | |
9639 | (concat "(" | |
9640 | (gnus-summary-print-truncate-and-quote | |
9641 | (mail-header-subject gnus-current-headers) | |
9642 | 66) ")") | |
9643 | (concat "(" | |
9644 | (gnus-summary-print-truncate-and-quote | |
9645 | (mail-header-from gnus-current-headers) | |
9646 | 45) ")"))) | |
9647 | (ps-right-header | |
9648 | (list | |
9649 | "/pagenumberstring load" | |
9650 | (concat "(" | |
9651 | (mail-header-date gnus-current-headers) ")")))) | |
9652 | (gnus-run-hooks 'gnus-ps-print-hook) | |
9653 | (save-excursion | |
9654 | (if ps-print-color-p | |
9655 | (ps-spool-buffer-with-faces) | |
9656 | (ps-spool-buffer))))) | |
23f87bed | 9657 | |
cf6a9685 GM |
9658 | (declare-function gnus-flush-original-article-buffer "gnus-art" ()) |
9659 | ||
8ccbef23 G |
9660 | (defun gnus-summary-show-complete-article () |
9661 | "Show a complete version of the current article. | |
9662 | This is only useful if you're looking at a partial version of the | |
9663 | article currently." | |
9664 | (interactive) | |
9665 | (let ((gnus-keep-backlog nil) | |
9666 | (gnus-use-cache nil) | |
9667 | (gnus-agent nil) | |
9f2d52e7 G |
9668 | (variable (intern |
9669 | (format "%s-fetch-partial-articles" | |
9670 | (car (gnus-find-method-for-group | |
9671 | gnus-newsgroup-name))) | |
9672 | obarray)) | |
9673 | old-val) | |
9674 | (unwind-protect | |
9675 | (progn | |
9676 | (setq old-val (symbol-value variable)) | |
9677 | (set variable nil) | |
9678 | (gnus-flush-original-article-buffer) | |
9679 | (gnus-summary-show-article)) | |
9680 | (set variable old-val)))) | |
8ccbef23 | 9681 | |
eec82323 | 9682 | (defun gnus-summary-show-article (&optional arg) |
23f87bed | 9683 | "Force redisplaying of the current article. |
16409b0b GM |
9684 | If ARG (the prefix) is a number, show the article with the charset |
9685 | defined in `gnus-summary-show-article-charset-alist', or the charset | |
23f87bed | 9686 | input. |
389b76fa G |
9687 | If ARG (the prefix) is non-nil and not a number, show the article, |
9688 | but without running any of the article treatment functions | |
9689 | article. Normally, the keystroke is `C-u g'. When using `C-u | |
9690 | C-u g', show the raw article." | |
eec82323 | 9691 | (interactive "P") |
16409b0b GM |
9692 | (cond |
9693 | ((numberp arg) | |
23f87bed | 9694 | (gnus-summary-show-article t) |
16409b0b GM |
9695 | (let ((gnus-newsgroup-charset |
9696 | (or (cdr (assq arg gnus-summary-show-article-charset-alist)) | |
23f87bed MB |
9697 | (mm-read-coding-system |
9698 | "View as charset: " ;; actually it is coding system. | |
01c52d31 | 9699 | (with-current-buffer gnus-article-buffer |
23f87bed | 9700 | (mm-detect-coding-region (point) (point-max)))))) |
16409b0b | 9701 | (gnus-newsgroup-ignored-charsets 'gnus-all)) |
23f87bed MB |
9702 | (gnus-summary-select-article nil 'force) |
9703 | (let ((deps gnus-newsgroup-dependencies) | |
9704 | head header lines) | |
c7a91ce1 | 9705 | (with-current-buffer gnus-original-article-buffer |
23f87bed MB |
9706 | (save-restriction |
9707 | (message-narrow-to-head) | |
9708 | (setq head (buffer-string)) | |
9709 | (goto-char (point-min)) | |
9710 | (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t) | |
9711 | (goto-char (point-max)) | |
9712 | (widen) | |
9713 | (setq lines (1- (count-lines (point) (point-max)))))) | |
9714 | (with-temp-buffer | |
9715 | (insert (format "211 %d Article retrieved.\n" | |
9716 | (cdr gnus-article-current))) | |
9717 | (insert head) | |
9718 | (if lines (insert (format "Lines: %d\n" lines))) | |
9719 | (insert ".\n") | |
9720 | (let ((nntp-server-buffer (current-buffer))) | |
9721 | (setq header (car (gnus-get-newsgroup-headers deps t)))))) | |
9722 | (gnus-data-set-header | |
9723 | (gnus-data-find (cdr gnus-article-current)) | |
9724 | header) | |
9725 | (gnus-summary-update-article-line | |
9726 | (cdr gnus-article-current) header) | |
9727 | (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t) | |
9728 | (gnus-summary-update-secondary-mark (cdr gnus-article-current)))))) | |
16409b0b | 9729 | ((not arg) |
8b8059de KY |
9730 | ;; Select the article the normal way. |
9731 | (if (eq mm-text-html-renderer 'shr) | |
9732 | (progn | |
9733 | (require 'shr) | |
9734 | (let ((shr-ignore-cache t)) | |
9735 | (gnus-summary-select-article nil 'force))) | |
728518c3 | 9736 | (gnus-summary-select-article nil 'force))) |
8e22bee0 | 9737 | ((equal arg '(16)) |
389b76fa | 9738 | ;; C-u C-u g |
04db63bc G |
9739 | (let ((gnus-inhibit-article-treatments t)) |
9740 | (gnus-summary-select-article nil 'force))) | |
9741 | (t | |
16409b0b GM |
9742 | ;; We have to require this here to make sure that the following |
9743 | ;; dynamic binding isn't shadowed by autoloading. | |
9744 | (require 'gnus-async) | |
9745 | (require 'gnus-art) | |
eec82323 LMI |
9746 | ;; Bind the article treatment functions to nil. |
9747 | (let ((gnus-have-all-headers t) | |
eec82323 | 9748 | gnus-article-prepare-hook |
16409b0b GM |
9749 | gnus-article-decode-hook |
9750 | gnus-display-mime-function | |
9751 | gnus-break-pages) | |
9752 | ;; Destroy any MIME parts. | |
9753 | (when (gnus-buffer-live-p gnus-article-buffer) | |
c7a91ce1 | 9754 | (with-current-buffer gnus-article-buffer |
c146ad85 | 9755 | (gnus-article-stop-animations) |
4eff9c1a | 9756 | (gnus-stop-downloads) |
16409b0b GM |
9757 | (mm-destroy-parts gnus-article-mime-handles) |
9758 | ;; Set it to nil for safety reason. | |
9759 | (setq gnus-article-mime-handle-alist nil) | |
9760 | (setq gnus-article-mime-handles nil))) | |
9761 | (gnus-summary-select-article nil 'force)))) | |
eec82323 LMI |
9762 | (gnus-summary-goto-subject gnus-current-article) |
9763 | (gnus-summary-position-point)) | |
9764 | ||
23f87bed MB |
9765 | (defun gnus-summary-show-raw-article () |
9766 | "Show the raw article without any article massaging functions being run." | |
9767 | (interactive) | |
9768 | (gnus-summary-show-article t)) | |
9769 | ||
eec82323 LMI |
9770 | (defun gnus-summary-verbose-headers (&optional arg) |
9771 | "Toggle permanent full header display. | |
9772 | If ARG is a positive number, turn header display on. | |
9773 | If ARG is a negative number, turn header display off." | |
9774 | (interactive "P") | |
eec82323 LMI |
9775 | (setq gnus-show-all-headers |
9776 | (cond ((or (not (numberp arg)) | |
9777 | (zerop arg)) | |
9778 | (not gnus-show-all-headers)) | |
9779 | ((natnump arg) | |
9780 | t))) | |
9781 | (gnus-summary-show-article)) | |
9782 | ||
cf6a9685 GM |
9783 | (declare-function article-narrow-to-head "gnus-art" ()) |
9784 | (declare-function gnus-article-hidden-text-p "gnus-art" (type)) | |
9785 | (declare-function gnus-delete-wash-type "gnus-art" (type)) | |
1fedc427 KY |
9786 | (declare-function gnus-mime-buttonize-attachments-in-header |
9787 | "gnus-art" (&optional interactive)) | |
cf6a9685 | 9788 | |
eec82323 LMI |
9789 | (defun gnus-summary-toggle-header (&optional arg) |
9790 | "Show the headers if they are hidden, or hide them if they are shown. | |
9791 | If ARG is a positive number, show the entire header. | |
9792 | If ARG is a negative number, hide the unwanted header lines." | |
9793 | (interactive "P") | |
23f87bed MB |
9794 | (let ((window (and (gnus-buffer-live-p gnus-article-buffer) |
9795 | (get-buffer-window gnus-article-buffer t)))) | |
9796 | (with-current-buffer gnus-article-buffer | |
9797 | (widen) | |
9798 | (article-narrow-to-head) | |
c7a91ce1 | 9799 | (let* ((inhibit-read-only t) |
16409b0b | 9800 | (inhibit-point-motion-hooks t) |
23f87bed MB |
9801 | (hidden (if (numberp arg) |
9802 | (>= arg 0) | |
f0096211 MB |
9803 | (or (not (looking-at "[^ \t\n]+:")) |
9804 | (gnus-article-hidden-text-p 'headers)))) | |
23f87bed MB |
9805 | s e) |
9806 | (delete-region (point-min) (point-max)) | |
667e0ba6 SM |
9807 | (with-current-buffer gnus-original-article-buffer |
9808 | (goto-char (setq s (point-min))) | |
23f87bed MB |
9809 | (setq e (if (search-forward "\n\n" nil t) |
9810 | (1- (point)) | |
9811 | (point-max)))) | |
667e0ba6 | 9812 | (insert-buffer-substring gnus-original-article-buffer s e) |
23f87bed MB |
9813 | (run-hooks 'gnus-article-decode-hook) |
9814 | (if hidden | |
9815 | (let ((gnus-treat-hide-headers nil) | |
9816 | (gnus-treat-hide-boring-headers nil)) | |
9817 | (gnus-delete-wash-type 'headers) | |
9818 | (gnus-treat-article 'head)) | |
4d2226bf G |
9819 | (gnus-treat-article 'head) |
9820 | ;; Add attachment buttons to the header. | |
9821 | (when gnus-mime-display-attachment-buttons-in-header | |
9822 | (gnus-mime-buttonize-attachments-in-header))) | |
23f87bed MB |
9823 | (widen) |
9824 | (if window | |
9825 | (set-window-start window (goto-char (point-min)))) | |
9826 | (if gnus-break-pages | |
9827 | (gnus-narrow-to-page) | |
9828 | (when (gnus-visual-p 'page-marker) | |
c7a91ce1 | 9829 | (let ((inhibit-read-only t)) |
23f87bed MB |
9830 | (gnus-remove-text-with-property 'gnus-prev) |
9831 | (gnus-remove-text-with-property 'gnus-next)))) | |
16409b0b | 9832 | (gnus-set-mode-line 'article))))) |
eec82323 LMI |
9833 | |
9834 | (defun gnus-summary-show-all-headers () | |
9835 | "Make all header lines visible." | |
9836 | (interactive) | |
23f87bed | 9837 | (gnus-summary-toggle-header 1)) |
eec82323 | 9838 | |
eec82323 LMI |
9839 | (defun gnus-summary-caesar-message (&optional arg) |
9840 | "Caesar rotate the current article by 13. | |
01c52d31 MB |
9841 | With a non-numerical prefix, also rotate headers. A numerical |
9842 | prefix specifies how many places to rotate each letter forward." | |
eec82323 | 9843 | (interactive "P") |
eec82323 LMI |
9844 | (gnus-summary-select-article) |
9845 | (let ((mail-header-separator "")) | |
9846 | (gnus-eval-in-buffer-window gnus-article-buffer | |
9847 | (save-restriction | |
9848 | (widen) | |
9849 | (let ((start (window-start)) | |
c7a91ce1 | 9850 | (inhibit-read-only t)) |
01c52d31 MB |
9851 | (if (equal arg '(4)) |
9852 | (message-caesar-buffer-body nil t) | |
9853 | (message-caesar-buffer-body arg)) | |
ff4d3926 MB |
9854 | (set-window-start (get-buffer-window (current-buffer)) start))))) |
9855 | ;; Create buttons and stuff... | |
9856 | (gnus-treat-article nil)) | |
eec82323 | 9857 | |
704f1663 GM |
9858 | (declare-function idna-to-unicode "ext:idna" (str)) |
9859 | ||
01c52d31 MB |
9860 | (defun gnus-summary-idna-message (&optional arg) |
9861 | "Decode IDNA encoded domain names in the current articles. | |
9862 | IDNA encoded domain names looks like `xn--bar'. If a string | |
9863 | remain unencoded after running this function, it is likely an | |
9864 | invalid IDNA string (`xn--bar' is invalid). | |
9865 | ||
0b10e437 | 9866 | You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/') |
01c52d31 MB |
9867 | installed for this command to work." |
9868 | (interactive "P") | |
9869 | (if (not (and (condition-case nil (require 'idna) | |
9870 | (file-error)) | |
9871 | (mm-coding-system-p 'utf-8) | |
9872 | (executable-find (symbol-value 'idna-program)))) | |
9873 | (gnus-message | |
9874 | 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)") | |
9875 | (gnus-summary-select-article) | |
9876 | (let ((mail-header-separator "")) | |
9877 | (gnus-eval-in-buffer-window gnus-article-buffer | |
9878 | (save-restriction | |
9879 | (widen) | |
9880 | (let ((start (window-start)) | |
9881 | buffer-read-only) | |
9882 | (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t) | |
9883 | (replace-match (idna-to-unicode (match-string 1)))) | |
9884 | (set-window-start (get-buffer-window (current-buffer)) start))))))) | |
23f87bed MB |
9885 | |
9886 | (defun gnus-summary-morse-message (&optional arg) | |
9887 | "Morse decode the current article." | |
9888 | (interactive "P") | |
9889 | (gnus-summary-select-article) | |
9890 | (let ((mail-header-separator "")) | |
9891 | (gnus-eval-in-buffer-window gnus-article-buffer | |
9892 | (save-excursion | |
9893 | (save-restriction | |
9894 | (widen) | |
9895 | (let ((pos (window-start)) | |
c7a91ce1 | 9896 | (inhibit-read-only t)) |
23f87bed MB |
9897 | (goto-char (point-min)) |
9898 | (when (message-goto-body) | |
9899 | (gnus-narrow-to-body)) | |
9900 | (goto-char (point-min)) | |
c38e0c97 | 9901 | (while (search-forward "·" (point-max) t) |
23f87bed MB |
9902 | (replace-match ".")) |
9903 | (unmorse-region (point-min) (point-max)) | |
9904 | (widen) | |
9905 | (set-window-start (get-buffer-window (current-buffer)) pos))))))) | |
9906 | ||
eec82323 LMI |
9907 | (defun gnus-summary-stop-page-breaking () |
9908 | "Stop page breaking in the current article." | |
9909 | (interactive) | |
eec82323 LMI |
9910 | (gnus-summary-select-article) |
9911 | (gnus-eval-in-buffer-window gnus-article-buffer | |
9912 | (widen) | |
9913 | (when (gnus-visual-p 'page-marker) | |
c7a91ce1 | 9914 | (let ((inhibit-read-only t)) |
eec82323 | 9915 | (gnus-remove-text-with-property 'gnus-prev) |
6748645f LMI |
9916 | (gnus-remove-text-with-property 'gnus-next)) |
9917 | (setq gnus-page-broken nil)))) | |
eec82323 LMI |
9918 | |
9919 | (defun gnus-summary-move-article (&optional n to-newsgroup | |
9920 | select-method action) | |
9921 | "Move the current article to a different newsgroup. | |
9922 | If N is a positive number, move the N next articles. | |
9923 | If N is a negative number, move the N previous articles. | |
9924 | If N is nil and any articles have been marked with the process mark, | |
9925 | move those articles instead. | |
9926 | If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | |
9927 | If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but | |
9928 | re-spool using this method. | |
9929 | ||
23f87bed MB |
9930 | When called interactively with TO-NEWSGROUP being nil, the value of |
9931 | the variable `gnus-move-split-methods' is used for finding a default | |
9932 | for the target newsgroup. | |
9933 | ||
eec82323 LMI |
9934 | For this function to work, both the current newsgroup and the |
9935 | newsgroup that you want to move to have to support the `request-move' | |
16409b0b GM |
9936 | and `request-accept' functions. |
9937 | ||
9938 | ACTION can be either `move' (the default), `crosspost' or `copy'." | |
eec82323 LMI |
9939 | (interactive "P") |
9940 | (unless action | |
9941 | (setq action 'move)) | |
eec82323 LMI |
9942 | ;; Check whether the source group supports the required functions. |
9943 | (cond ((and (eq action 'move) | |
9944 | (not (gnus-check-backend-function | |
9945 | 'request-move-article gnus-newsgroup-name))) | |
9946 | (error "The current group does not support article moving")) | |
9947 | ((and (eq action 'crosspost) | |
9948 | (not (gnus-check-backend-function | |
9949 | 'request-replace-article gnus-newsgroup-name))) | |
9950 | (error "The current group does not support article editing"))) | |
9951 | (let ((articles (gnus-summary-work-articles n)) | |
16409b0b | 9952 | (prefix (if (gnus-check-backend-function |
23f87bed | 9953 | 'request-move-article gnus-newsgroup-name) |
01c52d31 MB |
9954 | (funcall gnus-move-group-prefix-function |
9955 | gnus-newsgroup-name) | |
16409b0b | 9956 | "")) |
eec82323 LMI |
9957 | (names '((move "Move" "Moving") |
9958 | (copy "Copy" "Copying") | |
9959 | (crosspost "Crosspost" "Crossposting"))) | |
9960 | (copy-buf (save-excursion | |
9961 | (nnheader-set-temp-buffer " *copy article*"))) | |
01c52d31 MB |
9962 | art-group to-method new-xref article to-groups |
9963 | articles-to-update-marks encoded) | |
eec82323 LMI |
9964 | (unless (assq action names) |
9965 | (error "Unknown action %s" action)) | |
9966 | ;; Read the newsgroup name. | |
9967 | (when (and (not to-newsgroup) | |
9968 | (not select-method)) | |
23f87bed MB |
9969 | (if (and gnus-move-split-methods |
9970 | (not | |
9971 | (and (memq gnus-current-article articles) | |
9972 | (gnus-buffer-live-p gnus-original-article-buffer)))) | |
9973 | ;; When `gnus-move-split-methods' is non-nil, we have to | |
9974 | ;; select an article to give `gnus-read-move-group-name' an | |
9975 | ;; opportunity to suggest an appropriate default. However, | |
9976 | ;; we needn't render or mark the article. | |
9977 | (let ((gnus-display-mime-function nil) | |
9978 | (gnus-article-prepare-hook nil) | |
9979 | (gnus-mark-article-hook nil)) | |
9980 | (gnus-summary-select-article nil nil nil (car articles)))) | |
01c52d31 MB |
9981 | (setq to-newsgroup (gnus-read-move-group-name |
9982 | (cadr (assq action names)) | |
9983 | (symbol-value | |
9984 | (intern (format "gnus-current-%s-group" action))) | |
9985 | articles prefix) | |
9986 | encoded to-newsgroup | |
9987 | to-method (gnus-server-to-method (gnus-group-method to-newsgroup))) | |
9988 | (set (intern (format "gnus-current-%s-group" action)) | |
9989 | (mm-decode-coding-string | |
9990 | to-newsgroup | |
9991 | (gnus-group-name-charset to-method to-newsgroup)))) | |
9992 | (unless to-method | |
9993 | (setq to-method (or select-method | |
9994 | (gnus-server-to-method | |
9995 | (gnus-group-method to-newsgroup))))) | |
9996 | (setq to-newsgroup | |
9997 | (or encoded | |
9998 | (and to-newsgroup | |
9999 | (mm-encode-coding-string | |
10000 | to-newsgroup | |
10001 | (gnus-group-name-charset to-method to-newsgroup))))) | |
eec82323 LMI |
10002 | ;; Check the method we are to move this article to... |
10003 | (unless (gnus-check-backend-function | |
10004 | 'request-accept-article (car to-method)) | |
10005 | (error "%s does not support article copying" (car to-method))) | |
10006 | (unless (gnus-check-server to-method) | |
10007 | (error "Can't open server %s" (car to-method))) | |
10008 | (gnus-message 6 "%s to %s: %s..." | |
10009 | (caddr (assq action names)) | |
01c52d31 MB |
10010 | (or (car select-method) |
10011 | (gnus-group-decoded-name to-newsgroup)) | |
10012 | articles) | |
eec82323 LMI |
10013 | (while articles |
10014 | (setq article (pop articles)) | |
144b7b5c G |
10015 | ;; Set any marks that may have changed in the summary buffer. |
10016 | (when gnus-preserve-marks | |
10017 | (gnus-summary-push-marks-to-backend article)) | |
ed797193 G |
10018 | (setq |
10019 | art-group | |
10020 | (cond | |
10021 | ;; Move the article. | |
10022 | ((eq action 'move) | |
10023 | ;; Remove this article from future suppression. | |
10024 | (gnus-dup-unsuppress-article article) | |
10025 | (let* ((from-method (gnus-find-method-for-group | |
10026 | gnus-newsgroup-name)) | |
10027 | (to-method (or select-method | |
10028 | (gnus-find-method-for-group to-newsgroup))) | |
10029 | (move-is-internal (gnus-server-equal from-method to-method))) | |
10030 | (gnus-request-move-article | |
10031 | article ; Article to move | |
10032 | gnus-newsgroup-name ; From newsgroup | |
10033 | (nth 1 (gnus-find-method-for-group | |
10034 | gnus-newsgroup-name)) ; Server | |
10035 | (list 'gnus-request-accept-article | |
10036 | to-newsgroup (list 'quote select-method) | |
10037 | (not articles) t) ; Accept form | |
10038 | (not articles) ; Only save nov last time | |
10039 | (and move-is-internal | |
10040 | to-newsgroup ; Not respooling | |
3a7a03ad | 10041 | ; Is this move internal? |
ed797193 G |
10042 | (gnus-group-real-name to-newsgroup))))) |
10043 | ;; Copy the article. | |
10044 | ((eq action 'copy) | |
10045 | (with-current-buffer copy-buf | |
10046 | (when (gnus-request-article-this-buffer article | |
10047 | gnus-newsgroup-name) | |
10048 | (save-restriction | |
10049 | (nnheader-narrow-to-headers) | |
10050 | (dolist (hdr gnus-copy-article-ignored-headers) | |
10051 | (message-remove-header hdr t))) | |
10052 | (gnus-request-accept-article | |
10053 | to-newsgroup select-method (not articles) t)))) | |
10054 | ;; Crosspost the article. | |
10055 | ((eq action 'crosspost) | |
10056 | (let ((xref (message-tokenize-header | |
10057 | (mail-header-xref (gnus-summary-article-header | |
10058 | article)) | |
10059 | " "))) | |
10060 | (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name) | |
10061 | ":" (number-to-string article))) | |
10062 | (unless xref | |
10063 | (setq xref (list (system-name)))) | |
10064 | (setq new-xref | |
10065 | (concat | |
10066 | (mapconcat 'identity | |
10067 | (delete "Xref:" (delete new-xref xref)) | |
10068 | " ") | |
10069 | " " new-xref)) | |
c7a91ce1 | 10070 | (with-current-buffer copy-buf |
ed797193 G |
10071 | ;; First put the article in the destination group. |
10072 | (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
10073 | (when (consp (setq art-group | |
10074 | (gnus-request-accept-article | |
10075 | to-newsgroup select-method (not articles) | |
10076 | t))) | |
10077 | (setq new-xref (concat new-xref " " (car art-group) | |
10078 | ":" | |
10079 | (number-to-string (cdr art-group)))) | |
10080 | ;; Now we have the new Xrefs header, so we insert | |
10081 | ;; it and replace the new article. | |
10082 | (nnheader-replace-header "Xref" new-xref) | |
10083 | (gnus-request-replace-article | |
10084 | (cdr art-group) to-newsgroup (current-buffer) t) | |
10085 | art-group)))))) | |
10086 | (cond | |
10087 | ((not art-group) | |
10088 | (gnus-message 1 "Couldn't %s article %s: %s" | |
10089 | (cadr (assq action names)) article | |
10090 | (nnheader-get-report (car to-method)))) | |
10091 | ((eq art-group 'junk) | |
10092 | (when (eq action 'move) | |
10093 | (gnus-summary-mark-article article gnus-canceled-mark) | |
10094 | (gnus-message 4 "Deleted article %s" article) | |
10095 | ;; run the delete hook | |
10096 | (run-hook-with-args 'gnus-summary-article-delete-hook | |
10097 | action | |
10098 | (gnus-data-header | |
10099 | (assoc article (gnus-data-list nil))) | |
10100 | gnus-newsgroup-name nil | |
10101 | select-method))) | |
10102 | (t | |
10103 | (let* ((pto-group (gnus-group-prefixed-name | |
10104 | (car art-group) to-method)) | |
10105 | (info (gnus-get-info pto-group)) | |
10106 | (to-group (gnus-info-group info)) | |
10107 | to-marks) | |
10108 | ;; Update the group that has been moved to. | |
10109 | (when (and info | |
10110 | (memq action '(move copy))) | |
10111 | (unless (member to-group to-groups) | |
10112 | (push to-group to-groups)) | |
10113 | ||
9e928ac9 G |
10114 | (when (and (not (memq article gnus-newsgroup-unreads)) |
10115 | (cdr art-group)) | |
ed797193 G |
10116 | (push 'read to-marks) |
10117 | (gnus-info-set-read | |
10118 | info (gnus-add-to-range (gnus-info-read info) | |
10119 | (list (cdr art-group))))) | |
10120 | ||
10121 | ;; See whether the article is to be put in the cache. | |
10122 | (let* ((expirable (gnus-group-auto-expirable-p to-group)) | |
10123 | (marks (if expirable | |
10124 | gnus-article-mark-lists | |
10125 | (delete '(expirable . expire) | |
10126 | (copy-sequence | |
10127 | gnus-article-mark-lists)))) | |
10128 | (to-article (cdr art-group))) | |
10129 | ||
10130 | ;; Enter the article into the cache in the new group, | |
10131 | ;; if that is required. | |
9e928ac9 G |
10132 | (when (and to-article |
10133 | gnus-use-cache) | |
ed797193 G |
10134 | (gnus-cache-possibly-enter-article |
10135 | to-group to-article | |
10136 | (memq article gnus-newsgroup-marked) | |
10137 | (memq article gnus-newsgroup-dormant) | |
10138 | (memq article gnus-newsgroup-unreads))) | |
10139 | ||
9e928ac9 G |
10140 | (when (and gnus-preserve-marks |
10141 | to-article) | |
ed797193 G |
10142 | ;; Copy any marks over to the new group. |
10143 | (when (and (equal to-group gnus-newsgroup-name) | |
10144 | (not (memq article gnus-newsgroup-unreads))) | |
10145 | ;; Mark this article as read in this group. | |
10146 | (push (cons to-article gnus-read-mark) | |
10147 | gnus-newsgroup-reads) | |
10148 | ;; Increase the active status of this group. | |
10149 | (setcdr (gnus-active to-group) to-article) | |
10150 | (setcdr gnus-newsgroup-active to-article)) | |
10151 | ||
10152 | (while marks | |
10153 | (when (eq (gnus-article-mark-to-type (cdar marks)) 'list) | |
10154 | (when (memq article (symbol-value | |
10155 | (intern (format "gnus-newsgroup-%s" | |
10156 | (caar marks))))) | |
10157 | (push (cdar marks) to-marks) | |
10158 | ;; If the other group is the same as this group, | |
10159 | ;; then we have to add the mark to the list. | |
10160 | (when (equal to-group gnus-newsgroup-name) | |
10161 | (set (intern (format "gnus-newsgroup-%s" | |
10162 | (caar marks))) | |
10163 | (cons to-article | |
10164 | (symbol-value | |
10165 | (intern (format "gnus-newsgroup-%s" | |
10166 | (caar marks))))))) | |
10167 | ;; Copy the marks to other group. | |
10168 | (gnus-add-marked-articles | |
10169 | to-group (cdar marks) (list to-article) info))) | |
10170 | (setq marks (cdr marks))) | |
10171 | ||
10172 | (when (and expirable | |
10173 | gnus-mark-copied-or-moved-articles-as-expirable | |
10174 | (not (memq 'expire to-marks))) | |
10175 | ;; Mark this article as expirable. | |
10176 | (push 'expire to-marks) | |
10177 | (when (equal to-group gnus-newsgroup-name) | |
10178 | (push to-article gnus-newsgroup-expirable)) | |
10179 | ;; Copy the expirable mark to other group. | |
10180 | (gnus-add-marked-articles | |
10181 | to-group 'expire (list to-article) info)) | |
10182 | ||
f4887f8b | 10183 | (when (and to-marks |
89b163db G |
10184 | (gnus-method-option-p |
10185 | (gnus-find-method-for-group to-group) | |
10186 | 'server-marks)) | |
ed797193 G |
10187 | (gnus-request-set-mark |
10188 | to-group (list (list (list to-article) 'add to-marks))))) | |
10189 | ||
10190 | (gnus-dribble-enter | |
10191 | (concat "(gnus-group-set-info '" | |
10192 | (gnus-prin1-to-string (gnus-get-info to-group)) | |
b229f37d KY |
10193 | ")") |
10194 | (concat "^(gnus-group-set-info '(\"" | |
10195 | (regexp-quote to-group) "\"")))) | |
ed797193 G |
10196 | |
10197 | ;; Update the Xref header in this article to point to | |
10198 | ;; the new crossposted article we have just created. | |
10199 | (when (eq action 'crosspost) | |
10200 | (with-current-buffer copy-buf | |
10201 | (gnus-request-article-this-buffer article gnus-newsgroup-name) | |
10202 | (nnheader-replace-header "Xref" new-xref) | |
10203 | (gnus-request-replace-article | |
10204 | article gnus-newsgroup-name (current-buffer) t))) | |
10205 | ||
10206 | ;; run the move/copy/crosspost/respool hook | |
10207 | (run-hook-with-args 'gnus-summary-article-move-hook | |
10208 | action | |
10209 | (gnus-data-header | |
10210 | (assoc article (gnus-data-list nil))) | |
10211 | gnus-newsgroup-name | |
10212 | to-newsgroup | |
10213 | select-method)) | |
10214 | ||
10215 | ;;;!!!Why is this necessary? | |
10216 | (set-buffer gnus-summary-buffer) | |
04db63bc | 10217 | |
ed797193 G |
10218 | (when (eq action 'move) |
10219 | (save-excursion | |
10220 | (gnus-summary-goto-subject article) | |
10221 | (gnus-summary-mark-article article gnus-canceled-mark))))) | |
10222 | (push article articles-to-update-marks)) | |
01c52d31 | 10223 | |
dc6de553 KY |
10224 | (save-excursion |
10225 | (apply 'gnus-summary-remove-process-mark articles-to-update-marks)) | |
eec82323 | 10226 | ;; Re-activate all groups that have been moved to. |
c7a91ce1 | 10227 | (with-current-buffer gnus-group-buffer |
23f87bed MB |
10228 | (let ((gnus-group-marked to-groups)) |
10229 | (gnus-group-get-new-news-this-group nil t))) | |
eec82323 LMI |
10230 | |
10231 | (gnus-kill-buffer copy-buf) | |
10232 | (gnus-summary-position-point) | |
3a7a03ad | 10233 | (gnus-set-mode-line 'summary))) |
eec82323 | 10234 | |
144b7b5c | 10235 | (defun gnus-summary-push-marks-to-backend (article) |
5f285722 | 10236 | (let ((set nil) |
45dd6480 | 10237 | (del nil) |
144b7b5c | 10238 | (marks gnus-article-mark-lists)) |
549c9aed | 10239 | (unless (memq article gnus-newsgroup-unreads) |
5f285722 | 10240 | (push 'read set)) |
144b7b5c | 10241 | (while marks |
45dd6480 LI |
10242 | (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list) |
10243 | (memq article (symbol-value | |
10244 | (intern (format "gnus-newsgroup-%s" | |
10245 | (caar marks)))))) | |
10246 | (push (cdar marks) set) | |
10247 | (push (cdar marks) del)) | |
144b7b5c | 10248 | (pop marks)) |
45dd6480 LI |
10249 | (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set) |
10250 | ((,article) del ,del))))) | |
144b7b5c | 10251 | |
eec82323 | 10252 | (defun gnus-summary-copy-article (&optional n to-newsgroup select-method) |
ef3b7aae MB |
10253 | "Copy the current article to some other group. |
10254 | If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to. | |
23f87bed MB |
10255 | When called interactively, if TO-NEWSGROUP is nil, use the value of |
10256 | the variable `gnus-move-split-methods' for finding a default target | |
10257 | newsgroup. | |
eec82323 LMI |
10258 | If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but |
10259 | re-spool using this method." | |
10260 | (interactive "P") | |
10261 | (gnus-summary-move-article n to-newsgroup select-method 'copy)) | |
10262 | ||
10263 | (defun gnus-summary-crosspost-article (&optional n) | |
10264 | "Crosspost the current article to some other group." | |
10265 | (interactive "P") | |
10266 | (gnus-summary-move-article n nil nil 'crosspost)) | |
10267 | ||
10268 | (defcustom gnus-summary-respool-default-method nil | |
23f87bed | 10269 | "Default method type for respooling an article. |
eec82323 | 10270 | If nil, use to the current newsgroup method." |
23f87bed | 10271 | :type 'symbol |
eec82323 LMI |
10272 | :group 'gnus-summary-mail) |
10273 | ||
10274 | (defun gnus-summary-respool-article (&optional n method) | |
10275 | "Respool the current article. | |
10276 | The article will be squeezed through the mail spooling process again, | |
10277 | which means that it will be put in some mail newsgroup or other | |
10278 | depending on `nnmail-split-methods'. | |
10279 | If N is a positive number, respool the N next articles. | |
10280 | If N is a negative number, respool the N previous articles. | |
10281 | If N is nil and any articles have been marked with the process mark, | |
10282 | respool those articles instead. | |
10283 | ||
10284 | Respooling can be done both from mail groups and \"real\" newsgroups. | |
10285 | In the former case, the articles in question will be moved from the | |
10286 | current group into whatever groups they are destined to. In the | |
10287 | latter case, they will be copied into the relevant groups." | |
10288 | (interactive | |
10289 | (list current-prefix-arg | |
04db63bc | 10290 | (let* ((methods (mapcar #'car (gnus-methods-using 'respool))) |
eec82323 LMI |
10291 | (methname |
10292 | (symbol-name (or gnus-summary-respool-default-method | |
10293 | (car (gnus-find-method-for-group | |
10294 | gnus-newsgroup-name))))) | |
10295 | (method | |
229b59da G |
10296 | (gnus-completing-read |
10297 | "Backend to use when respooling" | |
10298 | methods t nil 'gnus-mail-method-history methname)) | |
eec82323 LMI |
10299 | ms) |
10300 | (cond | |
10301 | ((zerop (length (setq ms (gnus-servers-using-backend | |
10302 | (intern method))))) | |
10303 | (list (intern method) "")) | |
10304 | ((= 1 (length ms)) | |
10305 | (car ms)) | |
10306 | (t | |
10307 | (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms))) | |
229b59da | 10308 | (cdr (assoc (gnus-completing-read "Server name" ms-alist t) |
eec82323 | 10309 | ms-alist)))))))) |
eec82323 LMI |
10310 | (unless method |
10311 | (error "No method given for respooling")) | |
10312 | (if (assoc (symbol-name | |
10313 | (car (gnus-find-method-for-group gnus-newsgroup-name))) | |
10314 | (gnus-methods-using 'respool)) | |
10315 | (gnus-summary-move-article n nil method) | |
10316 | (gnus-summary-copy-article n nil method))) | |
10317 | ||
23f87bed | 10318 | (defun gnus-summary-import-article (file &optional edit) |
6748645f | 10319 | "Import an arbitrary file into a mail newsgroup." |
23f87bed | 10320 | (interactive "fImport file: \nP") |
eec82323 LMI |
10321 | (let ((group gnus-newsgroup-name) |
10322 | (now (current-time)) | |
23f87bed | 10323 | atts lines group-art) |
eec82323 LMI |
10324 | (unless (gnus-check-backend-function 'request-accept-article group) |
10325 | (error "%s does not support article importing" group)) | |
10326 | (or (file-readable-p file) | |
10327 | (not (file-regular-p file)) | |
10328 | (error "Can't read %s" file)) | |
c7a91ce1 | 10329 | (with-current-buffer (gnus-get-buffer-create " *import file*") |
eec82323 | 10330 | (erase-buffer) |
16409b0b | 10331 | (nnheader-insert-file-contents file) |
eec82323 | 10332 | (goto-char (point-min)) |
23f87bed MB |
10333 | (if (nnheader-article-p) |
10334 | (save-restriction | |
10335 | (goto-char (point-min)) | |
10336 | (search-forward "\n\n" nil t) | |
10337 | (narrow-to-region (point-min) (1- (point))) | |
10338 | (goto-char (point-min)) | |
10339 | (unless (re-search-forward "^date:" nil t) | |
10340 | (goto-char (point-max)) | |
10341 | (insert "Date: " (message-make-date (nth 5 atts)) "\n"))) | |
10342 | ;; This doesn't look like an article, so we fudge some headers. | |
eec82323 LMI |
10343 | (setq atts (file-attributes file) |
10344 | lines (count-lines (point-min) (point-max))) | |
10345 | (insert "From: " (read-string "From: ") "\n" | |
10346 | "Subject: " (read-string "Subject: ") "\n" | |
23f87bed | 10347 | "Date: " (message-make-date (nth 5 atts)) "\n" |
eec82323 LMI |
10348 | "Message-ID: " (message-make-message-id) "\n" |
10349 | "Lines: " (int-to-string lines) "\n" | |
10350 | "Chars: " (int-to-string (nth 7 atts)) "\n\n")) | |
23f87bed MB |
10351 | (setq group-art (gnus-request-accept-article group nil t)) |
10352 | (kill-buffer (current-buffer))) | |
10353 | (setq gnus-newsgroup-active (gnus-activate-group group)) | |
10354 | (forward-line 1) | |
10355 | (gnus-summary-goto-article (cdr group-art) nil t) | |
10356 | (when edit | |
10357 | (gnus-summary-edit-article)))) | |
10358 | ||
10359 | (defun gnus-summary-create-article () | |
10360 | "Create an article in a mail newsgroup." | |
10361 | (interactive) | |
10362 | (let ((group gnus-newsgroup-name) | |
10363 | (now (current-time)) | |
10364 | group-art) | |
10365 | (unless (gnus-check-backend-function 'request-accept-article group) | |
10366 | (error "%s does not support article importing" group)) | |
c7a91ce1 | 10367 | (with-current-buffer (gnus-get-buffer-create " *import file*") |
23f87bed MB |
10368 | (erase-buffer) |
10369 | (goto-char (point-min)) | |
10370 | ;; This doesn't look like an article, so we fudge some headers. | |
10371 | (insert "From: " (read-string "From: ") "\n" | |
10372 | "Subject: " (read-string "Subject: ") "\n" | |
10373 | "Date: " (message-make-date now) "\n" | |
10374 | "Message-ID: " (message-make-message-id) "\n") | |
10375 | (setq group-art (gnus-request-accept-article group nil t)) | |
10376 | (kill-buffer (current-buffer))) | |
10377 | (setq gnus-newsgroup-active (gnus-activate-group group)) | |
10378 | (forward-line 1) | |
10379 | (gnus-summary-goto-article (cdr group-art) nil t) | |
10380 | (gnus-summary-edit-article))) | |
eec82323 LMI |
10381 | |
10382 | (defun gnus-summary-article-posted-p () | |
16409b0b | 10383 | "Say whether the current (mail) article is available from news as well. |
eec82323 LMI |
10384 | This will be the case if the article has both been mailed and posted." |
10385 | (interactive) | |
10386 | (let ((id (mail-header-references (gnus-summary-article-header))) | |
16409b0b | 10387 | (gnus-override-method (car (gnus-refer-article-methods)))) |
eec82323 LMI |
10388 | (if (gnus-request-head id "") |
10389 | (gnus-message 2 "The current message was found on %s" | |
10390 | gnus-override-method) | |
10391 | (gnus-message 2 "The current message couldn't be found on %s" | |
10392 | gnus-override-method) | |
10393 | nil))) | |
10394 | ||
10395 | (defun gnus-summary-expire-articles (&optional now) | |
10396 | "Expire all articles that are marked as expirable in the current group." | |
10397 | (interactive) | |
23f87bed MB |
10398 | (when (and (not gnus-group-is-exiting-without-update-p) |
10399 | (gnus-check-backend-function | |
10400 | 'request-expire-articles gnus-newsgroup-name)) | |
eec82323 LMI |
10401 | ;; This backend supports expiry. |
10402 | (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name)) | |
eaa610c3 KY |
10403 | (expirable |
10404 | (gnus-list-range-difference | |
10405 | (if total | |
10406 | (progn | |
10407 | ;; We need to update the info for | |
10408 | ;; this group for `gnus-list-of-read-articles' | |
10409 | ;; to give us the right answer. | |
10410 | (gnus-run-hooks 'gnus-exit-group-hook) | |
10411 | (gnus-summary-update-info) | |
10412 | (gnus-list-of-read-articles gnus-newsgroup-name)) | |
10413 | (setq gnus-newsgroup-expirable | |
10414 | (sort gnus-newsgroup-expirable '<))) | |
10415 | gnus-newsgroup-unexist)) | |
eec82323 LMI |
10416 | (expiry-wait (if now 'immediate |
10417 | (gnus-group-find-parameter | |
10418 | gnus-newsgroup-name 'expiry-wait))) | |
16409b0b GM |
10419 | (nnmail-expiry-target |
10420 | (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target) | |
10421 | nnmail-expiry-target)) | |
eec82323 LMI |
10422 | es) |
10423 | (when expirable | |
10424 | ;; There are expirable articles in this group, so we run them | |
10425 | ;; through the expiry process. | |
10426 | (gnus-message 6 "Expiring articles...") | |
138c0212 LMI |
10427 | (when (gnus-check-group gnus-newsgroup-name) |
10428 | ;; The list of articles that weren't expired is returned. | |
10429 | (save-excursion | |
10430 | (if expiry-wait | |
10431 | (let ((nnmail-expiry-wait-function nil) | |
10432 | (nnmail-expiry-wait expiry-wait)) | |
10433 | (setq es (gnus-request-expire-articles | |
10434 | expirable gnus-newsgroup-name))) | |
10435 | (setq es (gnus-request-expire-articles | |
10436 | expirable gnus-newsgroup-name))) | |
10437 | (unless total | |
10438 | (setq gnus-newsgroup-expirable es)) | |
10439 | ;; We go through the old list of expirable, and mark all | |
10440 | ;; really expired articles as nonexistent. | |
10441 | (unless (eq es expirable) ;If nothing was expired, we don't mark. | |
10442 | (let ((gnus-use-cache nil)) | |
10443 | (dolist (article expirable) | |
10444 | (when (and (not (memq article es)) | |
10445 | (gnus-data-find article)) | |
10446 | (gnus-summary-mark-article article gnus-canceled-mark) | |
10447 | (run-hook-with-args 'gnus-summary-article-expire-hook | |
10448 | 'delete | |
10449 | (gnus-data-header | |
10450 | (assoc article (gnus-data-list nil))) | |
10451 | gnus-newsgroup-name | |
10452 | nil | |
10453 | nil))))))) | |
eec82323 LMI |
10454 | (gnus-message 6 "Expiring articles...done"))))) |
10455 | ||
10456 | (defun gnus-summary-expire-articles-now () | |
10457 | "Expunge all expirable articles in the current group. | |
10458 | This means that *all* articles that are marked as expirable will be | |
10459 | deleted forever, right now." | |
10460 | (interactive) | |
eec82323 LMI |
10461 | (or gnus-expert-user |
10462 | (gnus-yes-or-no-p | |
f18df03d | 10463 | "Are you really, really sure you want to delete all expirable messages? ") |
eec82323 LMI |
10464 | (error "Phew!")) |
10465 | (gnus-summary-expire-articles t)) | |
10466 | ||
10467 | ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. | |
10468 | (defun gnus-summary-delete-article (&optional n) | |
10469 | "Delete the N next (mail) articles. | |
7ce31649 | 10470 | This command actually deletes articles. This is not a marking |
eec82323 LMI |
10471 | command. The article will disappear forever from your life, never to |
10472 | return. | |
23f87bed | 10473 | |
eec82323 LMI |
10474 | If N is negative, delete backwards. |
10475 | If N is nil and articles have been marked with the process mark, | |
23f87bed MB |
10476 | delete these instead. |
10477 | ||
10478 | If `gnus-novice-user' is non-nil you will be asked for | |
10479 | confirmation before the articles are deleted." | |
eec82323 | 10480 | (interactive "P") |
eec82323 LMI |
10481 | (unless (gnus-check-backend-function 'request-expire-articles |
10482 | gnus-newsgroup-name) | |
a8151ef7 | 10483 | (error "The current newsgroup does not support article deletion")) |
16409b0b GM |
10484 | (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) |
10485 | (error "Couldn't open server")) | |
eec82323 | 10486 | ;; Compute the list of articles to delete. |
6748645f | 10487 | (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<)) |
23f87bed | 10488 | (nnmail-expiry-target 'delete) |
eec82323 LMI |
10489 | not-deleted) |
10490 | (if (and gnus-novice-user | |
10491 | (not (gnus-yes-or-no-p | |
10492 | (format "Do you really want to delete %s forever? " | |
10493 | (if (> (length articles) 1) | |
10494 | (format "these %s articles" (length articles)) | |
10495 | "this article"))))) | |
10496 | () | |
10497 | ;; Delete the articles. | |
10498 | (setq not-deleted (gnus-request-expire-articles | |
10499 | articles gnus-newsgroup-name 'force)) | |
dc6de553 KY |
10500 | (save-excursion |
10501 | (while articles | |
10502 | (gnus-summary-remove-process-mark (car articles)) | |
10503 | ;; The backend might not have been able to delete the article | |
10504 | ;; after all. | |
10505 | (unless (memq (car articles) not-deleted) | |
ed797193 G |
10506 | (gnus-summary-mark-article (car articles) gnus-canceled-mark) |
10507 | (let* ((article (car articles)) | |
10508 | (ghead (gnus-data-header | |
10509 | (assoc article (gnus-data-list nil))))) | |
10510 | (run-hook-with-args 'gnus-summary-article-delete-hook | |
10511 | 'delete ghead gnus-newsgroup-name nil | |
10512 | nil))) | |
dc6de553 | 10513 | (setq articles (cdr articles)))) |
eec82323 LMI |
10514 | (when not-deleted |
10515 | (gnus-message 4 "Couldn't delete articles %s" not-deleted))) | |
10516 | (gnus-summary-position-point) | |
10517 | (gnus-set-mode-line 'summary) | |
10518 | not-deleted)) | |
10519 | ||
16409b0b | 10520 | (defun gnus-summary-edit-article (&optional arg) |
eec82323 LMI |
10521 | "Edit the current article. |
10522 | This will have permanent effect only in mail groups. | |
16409b0b | 10523 | If ARG is nil, edit the decoded articles. |
a1506d29 | 10524 | If ARG is 1, edit the raw articles. |
16409b0b | 10525 | If ARG is 2, edit the raw articles even in read-only groups. |
23f87bed | 10526 | If ARG is 3, edit the articles with the current handles. |
16409b0b | 10527 | Otherwise, allow editing of articles even in read-only |
eec82323 LMI |
10528 | groups." |
10529 | (interactive "P") | |
23f87bed | 10530 | (let (force raw current-handles) |
a1506d29 | 10531 | (cond |
16409b0b | 10532 | ((null arg)) |
23f87bed MB |
10533 | ((eq arg 1) |
10534 | (setq raw t)) | |
10535 | ((eq arg 2) | |
10536 | (setq raw t | |
10537 | force t)) | |
10538 | ((eq arg 3) | |
10539 | (setq current-handles | |
10540 | (and (gnus-buffer-live-p gnus-article-buffer) | |
10541 | (with-current-buffer gnus-article-buffer | |
10542 | (prog1 | |
10543 | gnus-article-mime-handles | |
10544 | (setq gnus-article-mime-handles nil)))))) | |
10545 | (t | |
10546 | (setq force t))) | |
10547 | (when (and raw (not force) | |
10548 | (member gnus-newsgroup-name '("nndraft:delayed" | |
10549 | "nndraft:drafts" | |
10550 | "nndraft:queue"))) | |
10551 | (error "Can't edit the raw article in group %s" | |
10552 | gnus-newsgroup-name)) | |
c7a91ce1 | 10553 | (with-current-buffer gnus-summary-buffer |
16409b0b GM |
10554 | (let ((mail-parse-charset gnus-newsgroup-charset) |
10555 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)) | |
10556 | (gnus-set-global-variables) | |
10557 | (when (and (not force) | |
10558 | (gnus-group-read-only-p)) | |
10559 | (error "The current newsgroup does not support article editing")) | |
10560 | (gnus-summary-show-article t) | |
10561 | (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer)) | |
10562 | (with-current-buffer gnus-article-buffer | |
87545352 | 10563 | (mm-enable-multibyte))) |
23f87bed | 10564 | (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts")) |
16409b0b GM |
10565 | (setq raw t)) |
10566 | (gnus-article-edit-article | |
a1506d29 | 10567 | (if raw 'ignore |
23f87bed MB |
10568 | `(lambda () |
10569 | (let ((mbl mml-buffer-list)) | |
10570 | (setq mml-buffer-list nil) | |
270a576a MB |
10571 | (let ((rfc2047-quote-decoded-words-containing-tspecials t)) |
10572 | (mime-to-mml ,'current-handles)) | |
23f87bed MB |
10573 | (let ((mbl1 mml-buffer-list)) |
10574 | (setq mml-buffer-list mbl) | |
10575 | (set (make-local-variable 'mml-buffer-list) mbl1)) | |
10576 | (gnus-make-local-hook 'kill-buffer-hook) | |
10577 | (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))) | |
16409b0b GM |
10578 | `(lambda (no-highlight) |
10579 | (let ((mail-parse-charset ',gnus-newsgroup-charset) | |
23f87bed MB |
10580 | (message-options message-options) |
10581 | (message-options-set-recipient) | |
a1506d29 | 10582 | (mail-parse-ignored-charsets |
01c52d31 MB |
10583 | ',gnus-newsgroup-ignored-charsets) |
10584 | (rfc2047-header-encoding-alist | |
10585 | ',(let ((charset (gnus-group-name-charset | |
10586 | (gnus-find-method-for-group | |
10587 | gnus-newsgroup-name) | |
10588 | gnus-newsgroup-name))) | |
10589 | (append (list (cons "Newsgroups" charset) | |
10590 | (cons "Followup-To" charset) | |
10591 | (cons "Xref" charset)) | |
10592 | rfc2047-header-encoding-alist)))) | |
a1506d29 | 10593 | ,(if (not raw) '(progn |
16409b0b GM |
10594 | (mml-to-mime) |
10595 | (mml-destroy-buffers) | |
a1506d29 | 10596 | (remove-hook 'kill-buffer-hook |
16409b0b GM |
10597 | 'mml-destroy-buffers t) |
10598 | (kill-local-variable 'mml-buffer-list))) | |
10599 | (gnus-summary-edit-article-done | |
10600 | ,(or (mail-header-references gnus-current-headers) "") | |
a1506d29 | 10601 | ,(gnus-group-read-only-p) |
16409b0b | 10602 | ,gnus-summary-buffer no-highlight)))))))) |
eec82323 LMI |
10603 | |
10604 | (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit) | |
10605 | ||
6748645f LMI |
10606 | (defun gnus-summary-edit-article-done (&optional references read-only buffer |
10607 | no-highlight) | |
eec82323 LMI |
10608 | "Make edits to the current article permanent." |
10609 | (interactive) | |
23f87bed | 10610 | (save-excursion |
728fd3b9 | 10611 | ;; The buffer restriction contains the entire article if it exists. |
23f87bed MB |
10612 | (when (article-goto-body) |
10613 | (let ((lines (count-lines (point) (point-max))) | |
10614 | (length (- (point-max) (point))) | |
10615 | (case-fold-search t) | |
9c3883b4 | 10616 | (body (point-marker))) |
23f87bed MB |
10617 | (goto-char (point-min)) |
10618 | (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t) | |
10619 | (delete-region (match-beginning 1) (match-end 1)) | |
10620 | (insert (number-to-string length))) | |
10621 | (goto-char (point-min)) | |
10622 | (when (re-search-forward | |
10623 | "^x-content-length:[ \t]\\([0-9]+\\)" body t) | |
10624 | (delete-region (match-beginning 1) (match-end 1)) | |
10625 | (insert (number-to-string length))) | |
10626 | (goto-char (point-min)) | |
10627 | (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t) | |
10628 | (delete-region (match-beginning 1) (match-end 1)) | |
10629 | (insert (number-to-string lines)))))) | |
eec82323 | 10630 | ;; Replace the article. |
728fd3b9 | 10631 | (let ((buf (current-buffer)) |
1171414d KY |
10632 | (article (cdr gnus-article-current)) |
10633 | replace-result) | |
16409b0b GM |
10634 | (with-temp-buffer |
10635 | (insert-buffer-substring buf) | |
6748645f | 10636 | (if (and (not read-only) |
728fd3b9 LMI |
10637 | (not (setq replace-result |
10638 | (gnus-request-replace-article | |
10639 | article (car gnus-article-current) | |
10640 | (current-buffer) t)))) | |
6748645f | 10641 | (error "Couldn't replace article") |
728fd3b9 LMI |
10642 | ;; If we got a number back, then that's the new article number |
10643 | ;; for this article. Otherwise, the article number didn't change. | |
10644 | (when (numberp replace-result) | |
10645 | (with-current-buffer gnus-summary-buffer | |
10646 | (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit)) | |
10647 | (gnus-summary-limit gnus-newsgroup-limit) | |
10648 | (setq article replace-result) | |
10649 | (gnus-summary-goto-subject article t))) | |
6748645f LMI |
10650 | ;; Update the summary buffer. |
10651 | (if (and references | |
10652 | (equal (message-tokenize-header references " ") | |
10653 | (message-tokenize-header | |
10654 | (or (message-fetch-field "references") "") " "))) | |
10655 | ;; We only have to update this line. | |
10656 | (save-excursion | |
10657 | (save-restriction | |
10658 | (message-narrow-to-head) | |
6ff5b064 MB |
10659 | (let ((head (buffer-substring-no-properties |
10660 | (point-min) (point-max))) | |
6748645f | 10661 | header) |
16409b0b | 10662 | (with-temp-buffer |
728fd3b9 | 10663 | (insert (format "211 %d Article retrieved.\n" article)) |
6748645f LMI |
10664 | (insert head) |
10665 | (insert ".\n") | |
10666 | (let ((nntp-server-buffer (current-buffer))) | |
728fd3b9 | 10667 | (setq header (car (gnus-get-newsgroup-headers nil t)))) |
c7a91ce1 | 10668 | (with-current-buffer gnus-summary-buffer |
728fd3b9 LMI |
10669 | (gnus-data-set-header (gnus-data-find article) header) |
10670 | (gnus-summary-update-article-line article header) | |
10671 | (if (gnus-summary-goto-subject article nil t) | |
10672 | (gnus-summary-update-secondary-mark article))))))) | |
6748645f LMI |
10673 | ;; Update threads. |
10674 | (set-buffer (or buffer gnus-summary-buffer)) | |
728fd3b9 LMI |
10675 | (gnus-summary-update-article article) |
10676 | (if (gnus-summary-goto-subject article nil t) | |
10677 | (gnus-summary-update-secondary-mark article))) | |
6748645f LMI |
10678 | ;; Prettify the article buffer again. |
10679 | (unless no-highlight | |
c7a91ce1 | 10680 | (with-current-buffer gnus-article-buffer |
728fd3b9 LMI |
10681 | ;;!!! Fix this -- article should be rehighlighted. |
10682 | ;;(gnus-run-hooks 'gnus-article-display-hook) | |
6748645f LMI |
10683 | (set-buffer gnus-original-article-buffer) |
10684 | (gnus-request-article | |
728fd3b9 | 10685 | article (car gnus-article-current) (current-buffer)))) |
6748645f LMI |
10686 | ;; Prettify the summary buffer line. |
10687 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
10688 | (gnus-run-hooks 'gnus-visual-mark-article-hook)))))) | |
eec82323 LMI |
10689 | |
10690 | (defun gnus-summary-edit-wash (key) | |
6748645f | 10691 | "Perform editing command KEY in the article buffer." |
eec82323 LMI |
10692 | (interactive |
10693 | (list | |
10694 | (progn | |
10695 | (message "%s" (concat (this-command-keys) "- ")) | |
10696 | (read-char)))) | |
10697 | (message "") | |
10698 | (gnus-summary-edit-article) | |
10699 | (execute-kbd-macro (concat (this-command-keys) key)) | |
10700 | (gnus-article-edit-done)) | |
10701 | ||
10702 | ;;; Respooling | |
10703 | ||
d1e12aef KY |
10704 | (defvar nnimap-split-fancy) |
10705 | (defvar nnimap-split-methods) | |
10706 | ||
6748645f | 10707 | (defun gnus-summary-respool-query (&optional silent trace) |
eec82323 LMI |
10708 | "Query where the respool algorithm would put this article." |
10709 | (interactive) | |
eec82323 LMI |
10710 | (let (gnus-mark-article-hook) |
10711 | (gnus-summary-select-article) | |
c7a91ce1 | 10712 | (with-current-buffer gnus-original-article-buffer |
d96b72a5 LI |
10713 | (let ((groups |
10714 | (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name)) | |
10715 | 'nnimap) | |
10716 | ;; nnimap has its own splitting variables. | |
10717 | (let ((nnmail-split-methods | |
10718 | (cond | |
10719 | ((eq nnimap-split-methods 'default) | |
10720 | nnmail-split-methods) | |
10721 | (nnimap-split-methods | |
10722 | nnimap-split-methods) | |
10723 | (nnimap-split-fancy | |
10724 | 'nnmail-split-fancy))) | |
10725 | (nnmail-split-fancy (or nnimap-split-fancy | |
10726 | nnmail-split-fancy))) | |
10727 | (nnmail-article-group 'identity trace)) | |
10728 | (nnmail-article-group 'identity trace)))) | |
23f87bed MB |
10729 | (unless silent |
10730 | (if groups | |
10731 | (message "This message would go to %s" | |
10732 | (mapconcat 'car groups ", ")) | |
10733 | (message "This message would go to no groups")) | |
10734 | groups))))) | |
eec82323 | 10735 | |
6748645f LMI |
10736 | (defun gnus-summary-respool-trace () |
10737 | "Trace where the respool algorithm would put this article. | |
10738 | Display a buffer showing all fancy splitting patterns which matched." | |
10739 | (interactive) | |
10740 | (gnus-summary-respool-query nil t)) | |
10741 | ||
eec82323 LMI |
10742 | ;; Summary marking commands. |
10743 | ||
10744 | (defun gnus-summary-kill-same-subject-and-select (&optional unmark) | |
10745 | "Mark articles which has the same subject as read, and then select the next. | |
10746 | If UNMARK is positive, remove any kind of mark. | |
10747 | If UNMARK is negative, tick articles." | |
10748 | (interactive "P") | |
eec82323 LMI |
10749 | (when unmark |
10750 | (setq unmark (prefix-numeric-value unmark))) | |
10751 | (let ((count | |
10752 | (gnus-summary-mark-same-subject | |
10753 | (gnus-summary-article-subject) unmark))) | |
10754 | ;; Select next unread article. If auto-select-same mode, should | |
10755 | ;; select the first unread article. | |
10756 | (gnus-summary-next-article t (and gnus-auto-select-same | |
10757 | (gnus-summary-article-subject))) | |
10758 | (gnus-message 7 "%d article%s marked as %s" | |
10759 | count (if (= count 1) " is" "s are") | |
10760 | (if unmark "unread" "read")))) | |
10761 | ||
10762 | (defun gnus-summary-kill-same-subject (&optional unmark) | |
10763 | "Mark articles which has the same subject as read. | |
10764 | If UNMARK is positive, remove any kind of mark. | |
10765 | If UNMARK is negative, tick articles." | |
10766 | (interactive "P") | |
eec82323 LMI |
10767 | (when unmark |
10768 | (setq unmark (prefix-numeric-value unmark))) | |
10769 | (let ((count | |
10770 | (gnus-summary-mark-same-subject | |
10771 | (gnus-summary-article-subject) unmark))) | |
10772 | ;; If marked as read, go to next unread subject. | |
10773 | (when (null unmark) | |
10774 | ;; Go to next unread subject. | |
10775 | (gnus-summary-next-subject 1 t)) | |
10776 | (gnus-message 7 "%d articles are marked as %s" | |
10777 | count (if unmark "unread" "read")))) | |
10778 | ||
10779 | (defun gnus-summary-mark-same-subject (subject &optional unmark) | |
10780 | "Mark articles with same SUBJECT as read, and return marked number. | |
10781 | If optional argument UNMARK is positive, remove any kinds of marks. | |
10782 | If optional argument UNMARK is negative, mark articles as unread instead." | |
10783 | (let ((count 1)) | |
10784 | (save-excursion | |
10785 | (cond | |
10786 | ((null unmark) ; Mark as read. | |
10787 | (while (and | |
10788 | (progn | |
10789 | (gnus-summary-mark-article-as-read gnus-killed-mark) | |
10790 | (gnus-summary-show-thread) t) | |
10791 | (gnus-summary-find-subject subject)) | |
10792 | (setq count (1+ count)))) | |
10793 | ((> unmark 0) ; Tick. | |
10794 | (while (and | |
10795 | (progn | |
10796 | (gnus-summary-mark-article-as-unread gnus-ticked-mark) | |
10797 | (gnus-summary-show-thread) t) | |
10798 | (gnus-summary-find-subject subject)) | |
10799 | (setq count (1+ count)))) | |
10800 | (t ; Mark as unread. | |
10801 | (while (and | |
10802 | (progn | |
10803 | (gnus-summary-mark-article-as-unread gnus-unread-mark) | |
10804 | (gnus-summary-show-thread) t) | |
10805 | (gnus-summary-find-subject subject)) | |
10806 | (setq count (1+ count))))) | |
10807 | (gnus-set-mode-line 'summary) | |
10808 | ;; Return the number of marked articles. | |
10809 | count))) | |
10810 | ||
10811 | (defun gnus-summary-mark-as-processable (n &optional unmark) | |
10812 | "Set the process mark on the next N articles. | |
10813 | If N is negative, mark backward instead. If UNMARK is non-nil, remove | |
10814 | the process mark instead. The difference between N and the actual | |
10815 | number of articles marked is returned." | |
23f87bed MB |
10816 | (interactive "P") |
10817 | (if (and (null n) (gnus-region-active-p)) | |
10818 | (gnus-uu-mark-region (region-beginning) (region-end) unmark) | |
10819 | (setq n (prefix-numeric-value n)) | |
10820 | (let ((backward (< n 0)) | |
10821 | (n (abs n))) | |
10822 | (while (and | |
10823 | (> n 0) | |
10824 | (if unmark | |
10825 | (gnus-summary-remove-process-mark | |
10826 | (gnus-summary-article-number)) | |
10827 | (gnus-summary-set-process-mark (gnus-summary-article-number))) | |
10828 | (zerop (gnus-summary-next-subject (if backward -1 1) nil t))) | |
10829 | (setq n (1- n))) | |
10830 | (when (/= 0 n) | |
10831 | (gnus-message 7 "No more articles")) | |
10832 | (gnus-summary-recenter) | |
10833 | (gnus-summary-position-point) | |
10834 | n))) | |
eec82323 LMI |
10835 | |
10836 | (defun gnus-summary-unmark-as-processable (n) | |
10837 | "Remove the process mark from the next N articles. | |
6748645f LMI |
10838 | If N is negative, unmark backward instead. The difference between N and |
10839 | the actual number of articles unmarked is returned." | |
23f87bed | 10840 | (interactive "P") |
eec82323 LMI |
10841 | (gnus-summary-mark-as-processable n t)) |
10842 | ||
10843 | (defun gnus-summary-unmark-all-processable () | |
10844 | "Remove the process mark from all articles." | |
10845 | (interactive) | |
eec82323 LMI |
10846 | (save-excursion |
10847 | (while gnus-newsgroup-processable | |
10848 | (gnus-summary-remove-process-mark (car gnus-newsgroup-processable)))) | |
10849 | (gnus-summary-position-point)) | |
10850 | ||
23f87bed MB |
10851 | (defun gnus-summary-add-mark (article type) |
10852 | "Mark ARTICLE with a mark of TYPE." | |
10853 | (let ((vtype (car (assq type gnus-article-mark-lists))) | |
10854 | var) | |
10855 | (if (not vtype) | |
10856 | (error "No such mark type: %s" type) | |
10857 | (setq var (intern (format "gnus-newsgroup-%s" type))) | |
10858 | (set var (cons article (symbol-value var))) | |
10859 | (if (memq type '(processable cached replied forwarded recent saved)) | |
10860 | (gnus-summary-update-secondary-mark article) | |
10861 | ;;; !!! This is bogus. We should find out what primary | |
10862 | ;;; !!! mark we want to set. | |
10863 | (gnus-summary-update-mark gnus-del-mark 'unread))))) | |
10864 | ||
eec82323 LMI |
10865 | (defun gnus-summary-mark-as-expirable (n) |
10866 | "Mark N articles forward as expirable. | |
10867 | If N is negative, mark backward instead. The difference between N and | |
10868 | the actual number of articles marked is returned." | |
10869 | (interactive "p") | |
eec82323 LMI |
10870 | (gnus-summary-mark-forward n gnus-expirable-mark)) |
10871 | ||
23f87bed MB |
10872 | (defun gnus-summary-mark-as-spam (n) |
10873 | "Mark N articles forward as spam. | |
10874 | If N is negative, mark backward instead. The difference between N and | |
10875 | the actual number of articles marked is returned." | |
10876 | (interactive "p") | |
10877 | (gnus-summary-mark-forward n gnus-spam-mark)) | |
10878 | ||
eec82323 | 10879 | (defun gnus-summary-mark-article-as-replied (article) |
23f87bed MB |
10880 | "Mark ARTICLE as replied to and update the summary line. |
10881 | ARTICLE can also be a list of articles." | |
10882 | (interactive (list (gnus-summary-article-number))) | |
10883 | (let ((articles (if (listp article) article (list article)))) | |
10884 | (dolist (article articles) | |
10885 | (unless (numberp article) | |
10886 | (error "%s is not a number" article)) | |
10887 | (push article gnus-newsgroup-replied) | |
c7a91ce1 | 10888 | (let ((inhibit-read-only t)) |
23f87bed MB |
10889 | (when (gnus-summary-goto-subject article nil t) |
10890 | (gnus-summary-update-secondary-mark article)))))) | |
10891 | ||
10892 | (defun gnus-summary-mark-article-as-forwarded (article) | |
10893 | "Mark ARTICLE as forwarded and update the summary line. | |
10894 | ARTICLE can also be a list of articles." | |
10895 | (let ((articles (if (listp article) article (list article)))) | |
10896 | (dolist (article articles) | |
10897 | (push article gnus-newsgroup-forwarded) | |
c7a91ce1 | 10898 | (let ((inhibit-read-only t)) |
23f87bed MB |
10899 | (when (gnus-summary-goto-subject article nil t) |
10900 | (gnus-summary-update-secondary-mark article)))))) | |
eec82323 LMI |
10901 | |
10902 | (defun gnus-summary-set-bookmark (article) | |
10903 | "Set a bookmark in current article." | |
10904 | (interactive (list (gnus-summary-article-number))) | |
eec82323 LMI |
10905 | (when (or (not (get-buffer gnus-article-buffer)) |
10906 | (not gnus-current-article) | |
10907 | (not gnus-article-current) | |
10908 | (not (equal gnus-newsgroup-name (car gnus-article-current)))) | |
10909 | (error "No current article selected")) | |
10910 | ;; Remove old bookmark, if one exists. | |
36d3245f | 10911 | (gnus-alist-pull article gnus-newsgroup-bookmarks) |
eec82323 LMI |
10912 | ;; Set the new bookmark, which is on the form |
10913 | ;; (article-number . line-number-in-body). | |
10914 | (push | |
10915 | (cons article | |
01c52d31 | 10916 | (with-current-buffer gnus-article-buffer |
eec82323 LMI |
10917 | (count-lines |
10918 | (min (point) | |
10919 | (save-excursion | |
23f87bed | 10920 | (article-goto-body) |
eec82323 LMI |
10921 | (point))) |
10922 | (point)))) | |
10923 | gnus-newsgroup-bookmarks) | |
10924 | (gnus-message 6 "A bookmark has been added to the current article.")) | |
10925 | ||
10926 | (defun gnus-summary-remove-bookmark (article) | |
10927 | "Remove the bookmark from the current article." | |
10928 | (interactive (list (gnus-summary-article-number))) | |
eec82323 | 10929 | ;; Remove old bookmark, if one exists. |
23f87bed MB |
10930 | (if (not (assq article gnus-newsgroup-bookmarks)) |
10931 | (gnus-message 6 "No bookmark in current article.") | |
36d3245f | 10932 | (gnus-alist-pull article gnus-newsgroup-bookmarks) |
23f87bed | 10933 | (gnus-message 6 "Removed bookmark."))) |
eec82323 LMI |
10934 | |
10935 | ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
10936 | (defun gnus-summary-mark-as-dormant (n) | |
10937 | "Mark N articles forward as dormant. | |
10938 | If N is negative, mark backward instead. The difference between N and | |
10939 | the actual number of articles marked is returned." | |
10940 | (interactive "p") | |
eec82323 LMI |
10941 | (gnus-summary-mark-forward n gnus-dormant-mark)) |
10942 | ||
10943 | (defun gnus-summary-set-process-mark (article) | |
10944 | "Set the process mark on ARTICLE and update the summary line." | |
10945 | (setq gnus-newsgroup-processable | |
10946 | (cons article | |
10947 | (delq article gnus-newsgroup-processable))) | |
10948 | (when (gnus-summary-goto-subject article) | |
10949 | (gnus-summary-show-thread) | |
6748645f | 10950 | (gnus-summary-goto-subject article) |
eec82323 LMI |
10951 | (gnus-summary-update-secondary-mark article))) |
10952 | ||
01c52d31 MB |
10953 | (defun gnus-summary-remove-process-mark (&rest articles) |
10954 | "Remove the process mark from ARTICLES and update the summary line." | |
10955 | (dolist (article articles) | |
10956 | (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable)) | |
10957 | (when (gnus-summary-goto-subject article) | |
10958 | (gnus-summary-show-thread) | |
10959 | (gnus-summary-goto-subject article) | |
10960 | (gnus-summary-update-secondary-mark article))) | |
10961 | t) | |
eec82323 LMI |
10962 | |
10963 | (defun gnus-summary-set-saved-mark (article) | |
10964 | "Set the process mark on ARTICLE and update the summary line." | |
10965 | (push article gnus-newsgroup-saved) | |
10966 | (when (gnus-summary-goto-subject article) | |
10967 | (gnus-summary-update-secondary-mark article))) | |
10968 | ||
10969 | (defun gnus-summary-mark-forward (n &optional mark no-expire) | |
10970 | "Mark N articles as read forwards. | |
10971 | If N is negative, mark backwards instead. Mark with MARK, ?r by default. | |
10972 | The difference between N and the actual number of articles marked is | |
16409b0b | 10973 | returned. |
8f688cb0 | 10974 | If NO-EXPIRE, auto-expiry will be inhibited." |
eec82323 | 10975 | (interactive "p") |
16409b0b | 10976 | (gnus-summary-show-thread) |
eec82323 LMI |
10977 | (let ((backward (< n 0)) |
10978 | (gnus-summary-goto-unread | |
10979 | (and gnus-summary-goto-unread | |
10980 | (not (eq gnus-summary-goto-unread 'never)) | |
23f87bed | 10981 | (not (memq mark (list gnus-unread-mark gnus-spam-mark |
eec82323 LMI |
10982 | gnus-ticked-mark gnus-dormant-mark))))) |
10983 | (n (abs n)) | |
10984 | (mark (or mark gnus-del-mark))) | |
10985 | (while (and (> n 0) | |
10986 | (gnus-summary-mark-article nil mark no-expire) | |
10987 | (zerop (gnus-summary-next-subject | |
10988 | (if backward -1 1) | |
10989 | (and gnus-summary-goto-unread | |
10990 | (not (eq gnus-summary-goto-unread 'never))) | |
10991 | t))) | |
10992 | (setq n (1- n))) | |
10993 | (when (/= 0 n) | |
10994 | (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
10995 | (gnus-summary-recenter) | |
10996 | (gnus-summary-position-point) | |
10997 | (gnus-set-mode-line 'summary) | |
10998 | n)) | |
10999 | ||
11000 | (defun gnus-summary-mark-article-as-read (mark) | |
11001 | "Mark the current article quickly as read with MARK." | |
11002 | (let ((article (gnus-summary-article-number))) | |
11003 | (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
11004 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
23f87bed | 11005 | (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)) |
eec82323 LMI |
11006 | (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) |
11007 | (push (cons article mark) gnus-newsgroup-reads) | |
11008 | ;; Possibly remove from cache, if that is used. | |
11009 | (when gnus-use-cache | |
11010 | (gnus-cache-enter-remove-article article)) | |
11011 | ;; Allow the backend to change the mark. | |
11012 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
11013 | ;; Check for auto-expiry. | |
11014 | (when (and gnus-newsgroup-auto-expire | |
16409b0b | 11015 | (memq mark gnus-auto-expirable-marks)) |
eec82323 | 11016 | (setq mark gnus-expirable-mark) |
6748645f LMI |
11017 | ;; Let the backend know about the mark change. |
11018 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
eec82323 LMI |
11019 | (push article gnus-newsgroup-expirable)) |
11020 | ;; Set the mark in the buffer. | |
11021 | (gnus-summary-update-mark mark 'unread) | |
11022 | t)) | |
11023 | ||
11024 | (defun gnus-summary-mark-article-as-unread (mark) | |
11025 | "Mark the current article quickly as unread with MARK." | |
6748645f LMI |
11026 | (let* ((article (gnus-summary-article-number)) |
11027 | (old-mark (gnus-summary-article-mark article))) | |
11028 | ;; Allow the backend to change the mark. | |
11029 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
11030 | (if (eq mark old-mark) | |
11031 | t | |
11032 | (if (<= article 0) | |
11033 | (progn | |
11034 | (gnus-error 1 "Can't mark negative article numbers") | |
11035 | nil) | |
11036 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
23f87bed MB |
11037 | (setq gnus-newsgroup-spam-marked |
11038 | (delq article gnus-newsgroup-spam-marked)) | |
6748645f LMI |
11039 | (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) |
11040 | (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)) | |
11041 | (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads)) | |
e7719ea1 | 11042 | (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) |
6748645f | 11043 | (cond ((= mark gnus-ticked-mark) |
23f87bed MB |
11044 | (setq gnus-newsgroup-marked |
11045 | (gnus-add-to-sorted-list gnus-newsgroup-marked | |
11046 | article))) | |
11047 | ((= mark gnus-spam-mark) | |
11048 | (setq gnus-newsgroup-spam-marked | |
11049 | (gnus-add-to-sorted-list gnus-newsgroup-spam-marked | |
11050 | article))) | |
6748645f | 11051 | ((= mark gnus-dormant-mark) |
23f87bed MB |
11052 | (setq gnus-newsgroup-dormant |
11053 | (gnus-add-to-sorted-list gnus-newsgroup-dormant | |
11054 | article))) | |
6748645f | 11055 | (t |
23f87bed MB |
11056 | (setq gnus-newsgroup-unreads |
11057 | (gnus-add-to-sorted-list gnus-newsgroup-unreads | |
11058 | article)))) | |
36d3245f | 11059 | (gnus-alist-pull article gnus-newsgroup-reads) |
eec82323 | 11060 | |
6748645f LMI |
11061 | ;; See whether the article is to be put in the cache. |
11062 | (and gnus-use-cache | |
11063 | (vectorp (gnus-summary-article-header article)) | |
11064 | (save-excursion | |
11065 | (gnus-cache-possibly-enter-article | |
11066 | gnus-newsgroup-name article | |
6748645f LMI |
11067 | (= mark gnus-ticked-mark) |
11068 | (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
11069 | ||
11070 | ;; Fix the mark. | |
11071 | (gnus-summary-update-mark mark 'unread) | |
11072 | t)))) | |
eec82323 LMI |
11073 | |
11074 | (defun gnus-summary-mark-article (&optional article mark no-expire) | |
11075 | "Mark ARTICLE with MARK. MARK can be any character. | |
11076 | Four MARK strings are reserved: `? ' (unread), `?!' (ticked), | |
11077 | `??' (dormant) and `?E' (expirable). | |
16409b0b | 11078 | If MARK is nil, then the default character `?r' is used. |
eec82323 | 11079 | If ARTICLE is nil, then the article on the current line will be |
16409b0b | 11080 | marked. |
8f688cb0 | 11081 | If NO-EXPIRE, auto-expiry will be inhibited." |
eec82323 LMI |
11082 | ;; The mark might be a string. |
11083 | (when (stringp mark) | |
11084 | (setq mark (aref mark 0))) | |
11085 | ;; If no mark is given, then we check auto-expiring. | |
16409b0b GM |
11086 | (when (null mark) |
11087 | (setq mark gnus-del-mark)) | |
11088 | (when (and (not no-expire) | |
11089 | gnus-newsgroup-auto-expire | |
23f87bed | 11090 | (memq mark gnus-auto-expirable-marks)) |
16409b0b GM |
11091 | (setq mark gnus-expirable-mark)) |
11092 | (let ((article (or article (gnus-summary-article-number))) | |
11093 | (old-mark (gnus-summary-article-mark article))) | |
6748645f LMI |
11094 | ;; Allow the backend to change the mark. |
11095 | (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark)) | |
11096 | (if (eq mark old-mark) | |
11097 | t | |
11098 | (unless article | |
11099 | (error "No article on current line")) | |
11100 | (if (not (if (or (= mark gnus-unread-mark) | |
11101 | (= mark gnus-ticked-mark) | |
23f87bed | 11102 | (= mark gnus-spam-mark) |
6748645f LMI |
11103 | (= mark gnus-dormant-mark)) |
11104 | (gnus-mark-article-as-unread article mark) | |
11105 | (gnus-mark-article-as-read article mark))) | |
11106 | t | |
11107 | ;; See whether the article is to be put in the cache. | |
11108 | (and gnus-use-cache | |
11109 | (not (= mark gnus-canceled-mark)) | |
11110 | (vectorp (gnus-summary-article-header article)) | |
11111 | (save-excursion | |
11112 | (gnus-cache-possibly-enter-article | |
11113 | gnus-newsgroup-name article | |
6748645f LMI |
11114 | (= mark gnus-ticked-mark) |
11115 | (= mark gnus-dormant-mark) (= mark gnus-unread-mark)))) | |
11116 | ||
11117 | (when (gnus-summary-goto-subject article nil t) | |
c7a91ce1 | 11118 | (let ((inhibit-read-only t)) |
6748645f LMI |
11119 | (gnus-summary-show-thread) |
11120 | ;; Fix the mark. | |
11121 | (gnus-summary-update-mark mark 'unread) | |
11122 | t)))))) | |
eec82323 LMI |
11123 | |
11124 | (defun gnus-summary-update-secondary-mark (article) | |
11125 | "Update the secondary (read, process, cache) mark." | |
11126 | (gnus-summary-update-mark | |
11127 | (cond ((memq article gnus-newsgroup-processable) | |
11128 | gnus-process-mark) | |
11129 | ((memq article gnus-newsgroup-cached) | |
11130 | gnus-cached-mark) | |
11131 | ((memq article gnus-newsgroup-replied) | |
11132 | gnus-replied-mark) | |
23f87bed MB |
11133 | ((memq article gnus-newsgroup-forwarded) |
11134 | gnus-forwarded-mark) | |
eec82323 LMI |
11135 | ((memq article gnus-newsgroup-saved) |
11136 | gnus-saved-mark) | |
23f87bed MB |
11137 | ((memq article gnus-newsgroup-unseen) |
11138 | gnus-unseen-mark) | |
11139 | (t gnus-no-mark)) | |
eec82323 LMI |
11140 | 'replied) |
11141 | (when (gnus-visual-p 'summary-highlight 'highlight) | |
a9ec34f4 | 11142 | (gnus-summary-highlight-line) |
6748645f | 11143 | (gnus-run-hooks 'gnus-summary-update-hook)) |
eec82323 LMI |
11144 | t) |
11145 | ||
23f87bed MB |
11146 | (defun gnus-summary-update-download-mark (article) |
11147 | "Update the download mark." | |
11148 | (gnus-summary-update-mark | |
11149 | (cond ((memq article gnus-newsgroup-undownloaded) | |
11150 | gnus-undownloaded-mark) | |
11151 | (gnus-newsgroup-agentized | |
11152 | gnus-downloaded-mark) | |
11153 | (t | |
11154 | gnus-no-mark)) | |
11155 | 'download) | |
11156 | (gnus-summary-update-line t) | |
11157 | t) | |
11158 | ||
eec82323 LMI |
11159 | (defun gnus-summary-update-mark (mark type) |
11160 | (let ((forward (cdr (assq type gnus-summary-mark-positions))) | |
c7a91ce1 | 11161 | (inhibit-read-only t)) |
01c52d31 | 11162 | (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit) |
16409b0b GM |
11163 | (when forward |
11164 | (when (looking-at "\r") | |
11165 | (incf forward)) | |
11166 | (when (<= (+ forward (point)) (point-max)) | |
11167 | ;; Go to the right position on the line. | |
11168 | (goto-char (+ forward (point))) | |
11169 | ;; Replace the old mark with the new mark. | |
bdaa75c7 | 11170 | (let ((to-insert |
321fce93 KY |
11171 | (mm-subst-char-in-string |
11172 | (char-after) mark | |
11173 | (buffer-substring (point) (1+ (point)))))) | |
bdaa75c7 LMI |
11174 | (delete-region (point) (1+ (point))) |
11175 | (insert to-insert)) | |
16409b0b GM |
11176 | ;; Optionally update the marks by some user rule. |
11177 | (when (eq type 'unread) | |
11178 | (gnus-data-set-mark | |
11179 | (gnus-data-find (gnus-summary-article-number)) mark) | |
11180 | (gnus-summary-update-line (eq mark gnus-unread-mark))))))) | |
eec82323 LMI |
11181 | |
11182 | (defun gnus-mark-article-as-read (article &optional mark) | |
11183 | "Enter ARTICLE in the pertinent lists and remove it from others." | |
11184 | ;; Make the article expirable. | |
11185 | (let ((mark (or mark gnus-del-mark))) | |
23f87bed MB |
11186 | (setq gnus-newsgroup-expirable |
11187 | (if (= mark gnus-expirable-mark) | |
11188 | (gnus-add-to-sorted-list gnus-newsgroup-expirable article) | |
11189 | (delq article gnus-newsgroup-expirable))) | |
eec82323 LMI |
11190 | ;; Remove from unread and marked lists. |
11191 | (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
11192 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)) | |
23f87bed | 11193 | (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)) |
eec82323 LMI |
11194 | (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)) |
11195 | (push (cons article mark) gnus-newsgroup-reads) | |
11196 | ;; Possibly remove from cache, if that is used. | |
11197 | (when gnus-use-cache | |
6748645f LMI |
11198 | (gnus-cache-enter-remove-article article)) |
11199 | t)) | |
eec82323 LMI |
11200 | |
11201 | (defun gnus-mark-article-as-unread (article &optional mark) | |
11202 | "Enter ARTICLE in the pertinent lists and remove it from others." | |
11203 | (let ((mark (or mark gnus-ticked-mark))) | |
6748645f LMI |
11204 | (if (<= article 0) |
11205 | (progn | |
11206 | (gnus-error 1 "Can't mark negative article numbers") | |
11207 | nil) | |
11208 | (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked) | |
23f87bed | 11209 | gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked) |
6748645f LMI |
11210 | gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant) |
11211 | gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable) | |
11212 | gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads)) | |
eec82323 | 11213 | |
6748645f LMI |
11214 | ;; Unsuppress duplicates? |
11215 | (when gnus-suppress-duplicates | |
11216 | (gnus-dup-unsuppress-article article)) | |
11217 | ||
11218 | (cond ((= mark gnus-ticked-mark) | |
23f87bed MB |
11219 | (setq gnus-newsgroup-marked |
11220 | (gnus-add-to-sorted-list gnus-newsgroup-marked article))) | |
11221 | ((= mark gnus-spam-mark) | |
11222 | (setq gnus-newsgroup-spam-marked | |
11223 | (gnus-add-to-sorted-list gnus-newsgroup-spam-marked | |
11224 | article))) | |
6748645f | 11225 | ((= mark gnus-dormant-mark) |
23f87bed MB |
11226 | (setq gnus-newsgroup-dormant |
11227 | (gnus-add-to-sorted-list gnus-newsgroup-dormant article))) | |
6748645f | 11228 | (t |
23f87bed MB |
11229 | (setq gnus-newsgroup-unreads |
11230 | (gnus-add-to-sorted-list gnus-newsgroup-unreads article)))) | |
36d3245f | 11231 | (gnus-alist-pull article gnus-newsgroup-reads) |
6748645f | 11232 | t))) |
eec82323 | 11233 | |
eec82323 LMI |
11234 | (defun gnus-summary-tick-article-forward (n) |
11235 | "Tick N articles forwards. | |
11236 | If N is negative, tick backwards instead. | |
11237 | The difference between N and the number of articles ticked is returned." | |
11238 | (interactive "p") | |
11239 | (gnus-summary-mark-forward n gnus-ticked-mark)) | |
11240 | ||
eec82323 LMI |
11241 | (defun gnus-summary-tick-article-backward (n) |
11242 | "Tick N articles backwards. | |
11243 | The difference between N and the number of articles ticked is returned." | |
11244 | (interactive "p") | |
11245 | (gnus-summary-mark-forward (- n) gnus-ticked-mark)) | |
11246 | ||
eec82323 LMI |
11247 | (defun gnus-summary-tick-article (&optional article clear-mark) |
11248 | "Mark current article as unread. | |
11249 | Optional 1st argument ARTICLE specifies article number to be marked as unread. | |
11250 | Optional 2nd argument CLEAR-MARK remove any kinds of mark." | |
11251 | (interactive) | |
11252 | (gnus-summary-mark-article article (if clear-mark gnus-unread-mark | |
11253 | gnus-ticked-mark))) | |
11254 | ||
11255 | (defun gnus-summary-mark-as-read-forward (n) | |
11256 | "Mark N articles as read forwards. | |
11257 | If N is negative, mark backwards instead. | |
11258 | The difference between N and the actual number of articles marked is | |
11259 | returned." | |
11260 | (interactive "p") | |
16409b0b | 11261 | (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire)) |
eec82323 LMI |
11262 | |
11263 | (defun gnus-summary-mark-as-read-backward (n) | |
11264 | "Mark the N articles as read backwards. | |
11265 | The difference between N and the actual number of articles marked is | |
11266 | returned." | |
11267 | (interactive "p") | |
16409b0b GM |
11268 | (gnus-summary-mark-forward |
11269 | (- n) gnus-del-mark gnus-inhibit-user-auto-expire)) | |
eec82323 LMI |
11270 | |
11271 | (defun gnus-summary-mark-as-read (&optional article mark) | |
11272 | "Mark current article as read. | |
11273 | ARTICLE specifies the article to be marked as read. | |
11274 | MARK specifies a string to be inserted at the beginning of the line." | |
11275 | (gnus-summary-mark-article article mark)) | |
11276 | ||
11277 | (defun gnus-summary-clear-mark-forward (n) | |
11278 | "Clear marks from N articles forward. | |
11279 | If N is negative, clear backward instead. | |
11280 | The difference between N and the number of marks cleared is returned." | |
11281 | (interactive "p") | |
11282 | (gnus-summary-mark-forward n gnus-unread-mark)) | |
11283 | ||
11284 | (defun gnus-summary-clear-mark-backward (n) | |
11285 | "Clear marks from N articles backward. | |
11286 | The difference between N and the number of marks cleared is returned." | |
11287 | (interactive "p") | |
11288 | (gnus-summary-mark-forward (- n) gnus-unread-mark)) | |
11289 | ||
11290 | (defun gnus-summary-mark-unread-as-read () | |
bbbe940b | 11291 | "Intended to be used by `gnus-mark-article-hook'." |
eec82323 LMI |
11292 | (when (memq gnus-current-article gnus-newsgroup-unreads) |
11293 | (gnus-summary-mark-article gnus-current-article gnus-read-mark))) | |
11294 | ||
23f87bed | 11295 | (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark) |
bbbe940b | 11296 | "Intended to be used by `gnus-mark-article-hook'." |
eec82323 LMI |
11297 | (let ((mark (gnus-summary-article-mark))) |
11298 | (when (or (gnus-unread-mark-p mark) | |
11299 | (gnus-read-mark-p mark)) | |
23f87bed MB |
11300 | (gnus-summary-mark-article gnus-current-article |
11301 | (or new-mark gnus-read-mark))))) | |
11302 | ||
11303 | (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark) | |
bbbe940b | 11304 | "Intended to be used by `gnus-mark-article-hook'." |
23f87bed MB |
11305 | (let ((mark (gnus-summary-article-mark))) |
11306 | (when (or (gnus-unread-mark-p mark) | |
11307 | (gnus-read-mark-p mark)) | |
11308 | (gnus-summary-mark-article (gnus-summary-article-number) | |
11309 | (or new-mark gnus-read-mark))))) | |
11310 | ||
11311 | (defun gnus-summary-mark-unread-as-ticked () | |
bbbe940b | 11312 | "Intended to be used by `gnus-mark-article-hook'." |
23f87bed MB |
11313 | (when (memq gnus-current-article gnus-newsgroup-unreads) |
11314 | (gnus-summary-mark-article gnus-current-article gnus-ticked-mark))) | |
eec82323 LMI |
11315 | |
11316 | (defun gnus-summary-mark-region-as-read (point mark all) | |
11317 | "Mark all unread articles between point and mark as read. | |
11318 | If given a prefix, mark all articles between point and mark as read, | |
11319 | even ticked and dormant ones." | |
11320 | (interactive "r\nP") | |
11321 | (save-excursion | |
11322 | (let (article) | |
11323 | (goto-char point) | |
11324 | (beginning-of-line) | |
11325 | (while (and | |
11326 | (< (point) mark) | |
11327 | (progn | |
11328 | (when (or all | |
11329 | (memq (setq article (gnus-summary-article-number)) | |
11330 | gnus-newsgroup-unreads)) | |
11331 | (gnus-summary-mark-article article gnus-del-mark)) | |
11332 | t) | |
11333 | (gnus-summary-find-next)))))) | |
11334 | ||
11335 | (defun gnus-summary-mark-below (score mark) | |
11336 | "Mark articles with score less than SCORE with MARK." | |
11337 | (interactive "P\ncMark: ") | |
eec82323 LMI |
11338 | (setq score (if score |
11339 | (prefix-numeric-value score) | |
11340 | (or gnus-summary-default-score 0))) | |
c7a91ce1 | 11341 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
11342 | (goto-char (point-min)) |
11343 | (while | |
11344 | (progn | |
11345 | (and (< (gnus-summary-article-score) score) | |
11346 | (gnus-summary-mark-article nil mark)) | |
11347 | (gnus-summary-find-next))))) | |
11348 | ||
11349 | (defun gnus-summary-kill-below (&optional score) | |
11350 | "Mark articles with score below SCORE as read." | |
11351 | (interactive "P") | |
eec82323 LMI |
11352 | (gnus-summary-mark-below score gnus-killed-mark)) |
11353 | ||
11354 | (defun gnus-summary-clear-above (&optional score) | |
11355 | "Clear all marks from articles with score above SCORE." | |
11356 | (interactive "P") | |
eec82323 LMI |
11357 | (gnus-summary-mark-above score gnus-unread-mark)) |
11358 | ||
11359 | (defun gnus-summary-tick-above (&optional score) | |
11360 | "Tick all articles with score above SCORE." | |
11361 | (interactive "P") | |
eec82323 LMI |
11362 | (gnus-summary-mark-above score gnus-ticked-mark)) |
11363 | ||
11364 | (defun gnus-summary-mark-above (score mark) | |
11365 | "Mark articles with score over SCORE with MARK." | |
11366 | (interactive "P\ncMark: ") | |
eec82323 LMI |
11367 | (setq score (if score |
11368 | (prefix-numeric-value score) | |
11369 | (or gnus-summary-default-score 0))) | |
c7a91ce1 | 11370 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
11371 | (goto-char (point-min)) |
11372 | (while (and (progn | |
11373 | (when (> (gnus-summary-article-score) score) | |
11374 | (gnus-summary-mark-article nil mark)) | |
11375 | t) | |
11376 | (gnus-summary-find-next))))) | |
11377 | ||
11378 | ;; Suggested by Daniel Quinlan <quinlan@best.com>. | |
11379 | (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged) | |
11380 | (defun gnus-summary-limit-include-expunged (&optional no-error) | |
11381 | "Display all the hidden articles that were expunged for low scores." | |
11382 | (interactive) | |
c7a91ce1 | 11383 | (let ((inhibit-read-only t)) |
eec82323 LMI |
11384 | (let ((scored gnus-newsgroup-scored) |
11385 | headers h) | |
11386 | (while scored | |
23f87bed MB |
11387 | (unless (gnus-summary-article-header (caar scored)) |
11388 | (and (setq h (gnus-number-to-header (caar scored))) | |
eec82323 LMI |
11389 | (< (cdar scored) gnus-summary-expunge-below) |
11390 | (push h headers))) | |
11391 | (setq scored (cdr scored))) | |
11392 | (if (not headers) | |
11393 | (when (not no-error) | |
a8151ef7 | 11394 | (error "No expunged articles hidden")) |
eec82323 | 11395 | (goto-char (point-min)) |
23f87bed MB |
11396 | (push gnus-newsgroup-limit gnus-newsgroup-limits) |
11397 | (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit)) | |
01c52d31 MB |
11398 | (dolist (x headers) |
11399 | (push (mail-header-number x) gnus-newsgroup-limit)) | |
eec82323 LMI |
11400 | (gnus-summary-prepare-unthreaded (nreverse headers)) |
11401 | (goto-char (point-min)) | |
11402 | (gnus-summary-position-point) | |
11403 | t)))) | |
11404 | ||
23f87bed | 11405 | (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse) |
eec82323 LMI |
11406 | "Mark all unread articles in this newsgroup as read. |
11407 | If prefix argument ALL is non-nil, ticked and dormant articles will | |
11408 | also be marked as read. | |
11409 | If QUIETLY is non-nil, no questions will be asked. | |
23f87bed | 11410 | |
eec82323 | 11411 | If TO-HERE is non-nil, it should be a point in the buffer. All |
23f87bed MB |
11412 | articles before (after, if REVERSE is set) this point will be marked |
11413 | as read. | |
11414 | ||
eec82323 LMI |
11415 | Note that this function will only catch up the unread article |
11416 | in the current summary buffer limitation. | |
23f87bed | 11417 | |
eec82323 LMI |
11418 | The number of articles marked as read is returned." |
11419 | (interactive "P") | |
eec82323 LMI |
11420 | (prog1 |
11421 | (save-excursion | |
11422 | (when (or quietly | |
11423 | (not gnus-interactive-catchup) ;Without confirmation? | |
11424 | gnus-expert-user | |
11425 | (gnus-y-or-n-p | |
11426 | (if all | |
11427 | "Mark absolutely all articles as read? " | |
11428 | "Mark all unread articles as read? "))) | |
11429 | (if (and not-mark | |
11430 | (not gnus-newsgroup-adaptive) | |
11431 | (not gnus-newsgroup-auto-expire) | |
a8151ef7 LMI |
11432 | (not gnus-suppress-duplicates) |
11433 | (or (not gnus-use-cache) | |
6748645f | 11434 | (eq gnus-use-cache 'passive))) |
eec82323 LMI |
11435 | (progn |
11436 | (when all | |
11437 | (setq gnus-newsgroup-marked nil | |
23f87bed | 11438 | gnus-newsgroup-spam-marked nil |
eec82323 | 11439 | gnus-newsgroup-dormant nil)) |
23f87bed MB |
11440 | (setq gnus-newsgroup-unreads |
11441 | (gnus-sorted-nunion | |
4573e0df MB |
11442 | (gnus-sorted-intersection gnus-newsgroup-unreads |
11443 | gnus-newsgroup-downloadable) | |
60b0b668 MB |
11444 | (gnus-sorted-difference gnus-newsgroup-unfetched |
11445 | gnus-newsgroup-cached)))) | |
eec82323 LMI |
11446 | ;; We actually mark all articles as canceled, which we |
11447 | ;; have to do when using auto-expiry or adaptive scoring. | |
11448 | (gnus-summary-show-all-threads) | |
23f87bed MB |
11449 | (if (and to-here reverse) |
11450 | (progn | |
11451 | (goto-char to-here) | |
11452 | (gnus-summary-mark-current-read-and-unread-as-read | |
11453 | gnus-catchup-mark) | |
11454 | (while (gnus-summary-find-next (not all)) | |
11455 | (gnus-summary-mark-article-as-read gnus-catchup-mark))) | |
11456 | (when (gnus-summary-first-subject (not all)) | |
11457 | (while (and | |
11458 | (if to-here (< (point) to-here) t) | |
11459 | (gnus-summary-mark-article-as-read gnus-catchup-mark) | |
11460 | (gnus-summary-find-next (not all)))))) | |
eec82323 LMI |
11461 | (gnus-set-mode-line 'summary)) |
11462 | t)) | |
11463 | (gnus-summary-position-point))) | |
11464 | ||
11465 | (defun gnus-summary-catchup-to-here (&optional all) | |
11466 | "Mark all unticked articles before the current one as read. | |
11467 | If ALL is non-nil, also mark ticked and dormant articles as read." | |
11468 | (interactive "P") | |
eec82323 LMI |
11469 | (save-excursion |
11470 | (gnus-save-hidden-threads | |
11471 | (let ((beg (point))) | |
11472 | ;; We check that there are unread articles. | |
11473 | (when (or all (gnus-summary-find-prev)) | |
11474 | (gnus-summary-catchup all t beg))))) | |
11475 | (gnus-summary-position-point)) | |
11476 | ||
23f87bed MB |
11477 | (defun gnus-summary-catchup-from-here (&optional all) |
11478 | "Mark all unticked articles after (and including) the current one as read. | |
11479 | If ALL is non-nil, also mark ticked and dormant articles as read." | |
11480 | (interactive "P") | |
11481 | (save-excursion | |
11482 | (gnus-save-hidden-threads | |
11483 | (let ((beg (point))) | |
11484 | ;; We check that there are unread articles. | |
11485 | (when (or all (gnus-summary-find-next)) | |
11486 | (gnus-summary-catchup all t beg nil t))))) | |
11487 | (gnus-summary-position-point)) | |
11488 | ||
eec82323 | 11489 | (defun gnus-summary-catchup-all (&optional quietly) |
23f87bed MB |
11490 | "Mark all articles in this newsgroup as read. |
11491 | This command is dangerous. Normally, you want \\[gnus-summary-catchup] | |
11492 | instead, which marks only unread articles as read." | |
eec82323 | 11493 | (interactive "P") |
eec82323 LMI |
11494 | (gnus-summary-catchup t quietly)) |
11495 | ||
11496 | (defun gnus-summary-catchup-and-exit (&optional all quietly) | |
16409b0b | 11497 | "Mark all unread articles in this group as read, then exit. |
23f87bed MB |
11498 | If prefix argument ALL is non-nil, all articles are marked as read. |
11499 | If QUIETLY is non-nil, no questions will be asked." | |
eec82323 | 11500 | (interactive "P") |
eec82323 LMI |
11501 | (when (gnus-summary-catchup all quietly nil 'fast) |
11502 | ;; Select next newsgroup or exit. | |
6748645f LMI |
11503 | (if (and (not (gnus-group-quit-config gnus-newsgroup-name)) |
11504 | (eq gnus-auto-select-next 'quietly)) | |
eec82323 LMI |
11505 | (gnus-summary-next-group nil) |
11506 | (gnus-summary-exit)))) | |
11507 | ||
11508 | (defun gnus-summary-catchup-all-and-exit (&optional quietly) | |
23f87bed MB |
11509 | "Mark all articles in this newsgroup as read, and then exit. |
11510 | This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit] | |
11511 | instead, which marks only unread articles as read." | |
eec82323 | 11512 | (interactive "P") |
eec82323 LMI |
11513 | (gnus-summary-catchup-and-exit t quietly)) |
11514 | ||
eec82323 LMI |
11515 | (defun gnus-summary-catchup-and-goto-next-group (&optional all) |
11516 | "Mark all articles in this group as read and select the next group. | |
11517 | If given a prefix, mark all articles, unread as well as ticked, as | |
11518 | read." | |
11519 | (interactive "P") | |
eec82323 LMI |
11520 | (save-excursion |
11521 | (gnus-summary-catchup all)) | |
16409b0b GM |
11522 | (gnus-summary-next-group)) |
11523 | ||
01c52d31 MB |
11524 | (defun gnus-summary-catchup-and-goto-prev-group (&optional all) |
11525 | "Mark all articles in this group as read and select the previous group. | |
11526 | If given a prefix, mark all articles, unread as well as ticked, as | |
11527 | read." | |
11528 | (interactive "P") | |
11529 | (save-excursion | |
11530 | (gnus-summary-catchup all)) | |
11531 | (gnus-summary-next-group nil nil t)) | |
11532 | ||
16409b0b GM |
11533 | ;;; |
11534 | ;;; with article | |
11535 | ;;; | |
11536 | ||
11537 | (defmacro gnus-with-article (article &rest forms) | |
11538 | "Select ARTICLE and perform FORMS in the original article buffer. | |
11539 | Then replace the article with the result." | |
11540 | `(progn | |
11541 | ;; We don't want the article to be marked as read. | |
11542 | (let (gnus-mark-article-hook) | |
11543 | (gnus-summary-select-article t t nil ,article)) | |
11544 | (set-buffer gnus-original-article-buffer) | |
11545 | ,@forms | |
11546 | (if (not (gnus-check-backend-function | |
11547 | 'request-replace-article (car gnus-article-current))) | |
11548 | (gnus-message 5 "Read-only group; not replacing") | |
11549 | (unless (gnus-request-replace-article | |
11550 | ,article (car gnus-article-current) | |
11551 | (current-buffer) t) | |
11552 | (error "Couldn't replace article"))) | |
11553 | ;; The cache and backlog have to be flushed somewhat. | |
11554 | (when gnus-keep-backlog | |
11555 | (gnus-backlog-remove-article | |
11556 | (car gnus-article-current) (cdr gnus-article-current))) | |
11557 | (when gnus-use-cache | |
11558 | (gnus-cache-update-article | |
11559 | (car gnus-article-current) (cdr gnus-article-current))))) | |
11560 | ||
11561 | (put 'gnus-with-article 'lisp-indent-function 1) | |
11562 | (put 'gnus-with-article 'edebug-form-spec '(form body)) | |
eec82323 LMI |
11563 | |
11564 | ;; Thread-based commands. | |
11565 | ||
11566 | (defun gnus-summary-articles-in-thread (&optional article) | |
11567 | "Return a list of all articles in the current thread. | |
11568 | If ARTICLE is non-nil, return all articles in the thread that starts | |
11569 | with that article." | |
11570 | (let* ((article (or article (gnus-summary-article-number))) | |
11571 | (data (gnus-data-find-list article)) | |
11572 | (top-level (gnus-data-level (car data))) | |
11573 | (top-subject | |
11574 | (cond ((null gnus-thread-operation-ignore-subject) | |
11575 | (gnus-simplify-subject-re | |
11576 | (mail-header-subject (gnus-data-header (car data))))) | |
11577 | ((eq gnus-thread-operation-ignore-subject 'fuzzy) | |
11578 | (gnus-simplify-subject-fuzzy | |
11579 | (mail-header-subject (gnus-data-header (car data))))) | |
11580 | (t nil))) | |
11581 | (end-point (save-excursion | |
144b7b5c | 11582 | (goto-char (gnus-data-pos (car data))) |
eec82323 LMI |
11583 | (if (gnus-summary-go-to-next-thread) |
11584 | (point) (point-max)))) | |
11585 | articles) | |
11586 | (while (and data | |
11587 | (< (gnus-data-pos (car data)) end-point)) | |
11588 | (when (or (not top-subject) | |
11589 | (string= top-subject | |
11590 | (if (eq gnus-thread-operation-ignore-subject 'fuzzy) | |
11591 | (gnus-simplify-subject-fuzzy | |
11592 | (mail-header-subject | |
11593 | (gnus-data-header (car data)))) | |
11594 | (gnus-simplify-subject-re | |
11595 | (mail-header-subject | |
11596 | (gnus-data-header (car data))))))) | |
11597 | (push (gnus-data-number (car data)) articles)) | |
11598 | (unless (and (setq data (cdr data)) | |
11599 | (> (gnus-data-level (car data)) top-level)) | |
11600 | (setq data nil))) | |
11601 | ;; Return the list of articles. | |
11602 | (nreverse articles))) | |
11603 | ||
11604 | (defun gnus-summary-rethread-current () | |
11605 | "Rethread the thread the current article is part of." | |
11606 | (interactive) | |
eec82323 LMI |
11607 | (let* ((gnus-show-threads t) |
11608 | (article (gnus-summary-article-number)) | |
11609 | (id (mail-header-id (gnus-summary-article-header))) | |
11610 | (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id))))) | |
11611 | (unless id | |
11612 | (error "No article on the current line")) | |
11613 | (gnus-rebuild-thread id) | |
11614 | (gnus-summary-goto-subject article))) | |
11615 | ||
11616 | (defun gnus-summary-reparent-thread () | |
11617 | "Make the current article child of the marked (or previous) article. | |
11618 | ||
11619 | Note that the re-threading will only work if `gnus-thread-ignore-subject' | |
11620 | is non-nil or the Subject: of both articles are the same." | |
11621 | (interactive) | |
11622 | (unless (not (gnus-group-read-only-p)) | |
a8151ef7 | 11623 | (error "The current newsgroup does not support article editing")) |
eec82323 | 11624 | (unless (<= (length gnus-newsgroup-processable) 1) |
a8151ef7 | 11625 | (error "No more than one article may be marked")) |
01c52d31 MB |
11626 | (let ((child (gnus-summary-article-number)) |
11627 | ;; First grab the marked article, otherwise one line up. | |
11628 | (parent (if (not (null gnus-newsgroup-processable)) | |
11629 | (car gnus-newsgroup-processable) | |
11630 | (save-excursion | |
11631 | (if (eq (forward-line -1) 0) | |
11632 | (gnus-summary-article-number) | |
11633 | (error "Beginning of summary buffer")))))) | |
11634 | (gnus-summary-reparent-children parent (list child)))) | |
11635 | ||
11636 | (defun gnus-summary-reparent-children (parent children) | |
11637 | "Make PARENT the parent of CHILDREN. | |
11638 | When called interactively, PARENT is the current article and CHILDREN | |
11639 | are the process-marked articles." | |
11640 | (interactive | |
11641 | (list (gnus-summary-article-number) | |
11642 | (gnus-summary-work-articles nil))) | |
11643 | (dolist (child children) | |
11644 | (save-window-excursion | |
11645 | (let ((gnus-article-buffer " *reparent*")) | |
11646 | (unless (not (eq parent child)) | |
11647 | (error "An article may not be self-referential")) | |
11648 | (let ((message-id (mail-header-id | |
11649 | (gnus-summary-article-header parent)))) | |
11650 | (unless (and message-id (not (equal message-id ""))) | |
11651 | (error "No message-id in desired parent")) | |
11652 | (gnus-with-article child | |
11653 | (save-restriction | |
11654 | (goto-char (point-min)) | |
11655 | (message-narrow-to-head) | |
11656 | (if (re-search-forward "^References: " nil t) | |
11657 | (progn | |
11658 | (re-search-forward "^[^ \t]" nil t) | |
11659 | (forward-line -1) | |
11660 | (end-of-line) | |
11661 | (insert " " message-id)) | |
11662 | (insert "References: " message-id "\n")))) | |
11663 | (set-buffer gnus-summary-buffer) | |
11664 | (gnus-summary-unmark-all-processable) | |
11665 | (gnus-summary-update-article child) | |
11666 | (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t) | |
23f87bed | 11667 | (gnus-summary-update-secondary-mark (cdr gnus-article-current))) |
01c52d31 MB |
11668 | (gnus-summary-rethread-current) |
11669 | (gnus-message 3 "Article %d is now the child of article %d" | |
11670 | child parent)))))) | |
eec82323 LMI |
11671 | |
11672 | (defun gnus-summary-toggle-threads (&optional arg) | |
11673 | "Toggle showing conversation threads. | |
11674 | If ARG is positive number, turn showing conversation threads on." | |
11675 | (interactive "P") | |
eec82323 LMI |
11676 | (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end))) |
11677 | (setq gnus-show-threads | |
11678 | (if (null arg) (not gnus-show-threads) | |
11679 | (> (prefix-numeric-value arg) 0))) | |
11680 | (gnus-summary-prepare) | |
11681 | (gnus-summary-goto-subject current) | |
11682 | (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off")) | |
11683 | (gnus-summary-position-point))) | |
11684 | ||
6131a096 KY |
11685 | (eval-and-compile |
11686 | (if (fboundp 'remove-overlays) | |
11687 | (defalias 'gnus-remove-overlays 'remove-overlays) | |
11688 | (defun gnus-remove-overlays (beg end name val) | |
11689 | "Clear BEG and END of overlays whose property NAME has value VAL. | |
5843126b | 11690 | For compatibility with XEmacs." |
6131a096 KY |
11691 | (dolist (ov (gnus-overlays-in beg end)) |
11692 | (when (eq (gnus-overlay-get ov name) val) | |
11693 | (gnus-delete-overlay ov)))))) | |
9bfd9a76 | 11694 | |
eec82323 LMI |
11695 | (defun gnus-summary-show-all-threads () |
11696 | "Show all threads." | |
11697 | (interactive) | |
9bfd9a76 | 11698 | (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum) |
eec82323 LMI |
11699 | (gnus-summary-position-point)) |
11700 | ||
6b958814 G |
11701 | (defsubst gnus-summary--inv (p) |
11702 | (and (eq (get-char-property p 'invisible) 'gnus-sum) p)) | |
11703 | ||
eec82323 LMI |
11704 | (defun gnus-summary-show-thread () |
11705 | "Show thread subtrees. | |
11706 | Returns nil if no thread was there to be shown." | |
11707 | (interactive) | |
9bfd9a76 KY |
11708 | (let* ((orig (point)) |
11709 | (end (point-at-eol)) | |
6b958814 | 11710 | (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end)))) |
9bfd9a76 KY |
11711 | ;; Leave point at bol |
11712 | (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point))))) | |
6b958814 | 11713 | (eoi (when end |
9bfd9a76 | 11714 | (if (fboundp 'next-single-char-property-change) |
75ded89b KY |
11715 | ;; Note: XEmacs version of n-s-c-p-c may return nil |
11716 | (or (next-single-char-property-change end 'invisible) | |
11717 | (point-max)) | |
9bfd9a76 KY |
11718 | (while (progn |
11719 | (end-of-line 2) | |
11720 | (and (not (eobp)) | |
11721 | (eq (get-char-property (point) 'invisible) | |
11722 | 'gnus-sum)))) | |
11723 | (point))))) | |
11724 | (when eoi | |
11725 | (gnus-remove-overlays beg eoi 'invisible 'gnus-sum) | |
eec82323 | 11726 | (goto-char orig) |
9bfd9a76 KY |
11727 | (gnus-summary-position-point) |
11728 | eoi))) | |
eec82323 | 11729 | |
23f87bed MB |
11730 | (defun gnus-summary-maybe-hide-threads () |
11731 | "If requested, hide the threads that should be hidden." | |
11732 | (when (and gnus-show-threads | |
11733 | gnus-thread-hide-subtree) | |
11734 | (gnus-summary-hide-all-threads | |
11735 | (if (or (consp gnus-thread-hide-subtree) | |
11736 | (functionp gnus-thread-hide-subtree)) | |
11737 | (gnus-make-predicate gnus-thread-hide-subtree) | |
11738 | nil)))) | |
11739 | ||
11740 | ;;; Hiding predicates. | |
11741 | ||
11742 | (defun gnus-article-unread-p (header) | |
11743 | (memq (mail-header-number header) gnus-newsgroup-unreads)) | |
11744 | ||
11745 | (defun gnus-article-unseen-p (header) | |
11746 | (memq (mail-header-number header) gnus-newsgroup-unseen)) | |
11747 | ||
11748 | (defun gnus-map-articles (predicate articles) | |
11749 | "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil." | |
11750 | (apply 'gnus-or (mapcar predicate | |
d451514f MB |
11751 | (mapcar (lambda (number) |
11752 | (gnus-summary-article-header number)) | |
11753 | articles)))) | |
23f87bed MB |
11754 | |
11755 | (defun gnus-summary-hide-all-threads (&optional predicate) | |
11756 | "Hide all thread subtrees. | |
11757 | If PREDICATE is supplied, threads that satisfy this predicate | |
11758 | will not be hidden." | |
eec82323 | 11759 | (interactive) |
eec82323 LMI |
11760 | (save-excursion |
11761 | (goto-char (point-min)) | |
e5946384 TZ |
11762 | (let ((end nil) |
11763 | (count 0)) | |
23f87bed | 11764 | (while (not end) |
e5946384 TZ |
11765 | (incf count) |
11766 | (when (zerop (mod count 1000)) | |
11767 | (message "Hiding all threads... %d" count)) | |
23f87bed MB |
11768 | (when (or (not predicate) |
11769 | (gnus-map-articles | |
11770 | predicate (gnus-summary-article-children))) | |
11771 | (gnus-summary-hide-thread)) | |
11772 | (setq end (not (zerop (gnus-summary-next-thread 1 t))))))) | |
eec82323 LMI |
11773 | (gnus-summary-position-point)) |
11774 | ||
11775 | (defun gnus-summary-hide-thread () | |
11776 | "Hide thread subtrees. | |
23f87bed MB |
11777 | If PREDICATE is supplied, threads that satisfy this predicate |
11778 | will not be hidden. | |
eec82323 LMI |
11779 | Returns nil if no threads were there to be hidden." |
11780 | (interactive) | |
61bbede6 | 11781 | (beginning-of-line) |
9bfd9a76 KY |
11782 | (let ((start (point)) |
11783 | (starteol (line-end-position)) | |
eec82323 | 11784 | (article (gnus-summary-article-number))) |
c7a91ce1 | 11785 | ;; Go forward until either the buffer ends or the subthread ends. |
eec82323 LMI |
11786 | (when (and (not (eobp)) |
11787 | (or (zerop (gnus-summary-next-thread 1 t)) | |
11788 | (goto-char (point-max)))) | |
9bfd9a76 KY |
11789 | (if (and (> (point) start) |
11790 | ;; FIXME: this should actually search for a non-invisible \n. | |
11791 | (search-backward "\n" start t)) | |
11792 | (progn | |
11793 | (when (> (point) starteol) | |
11794 | (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum) | |
11795 | (let ((ol (gnus-make-overlay starteol (point) nil t nil))) | |
11796 | (gnus-overlay-put ol 'invisible 'gnus-sum) | |
11797 | (gnus-overlay-put ol 'evaporate t))) | |
b018a6c9 TZ |
11798 | (gnus-summary-goto-subject article) |
11799 | (when (> start (point)) | |
11800 | (message "Hiding the thread moved us backwards, aborting!") | |
11801 | (goto-char (point-max)))) | |
9bfd9a76 KY |
11802 | (goto-char start) |
11803 | nil)))) | |
eec82323 LMI |
11804 | |
11805 | (defun gnus-summary-go-to-next-thread (&optional previous) | |
11806 | "Go to the same level (or less) next thread. | |
11807 | If PREVIOUS is non-nil, go to previous thread instead. | |
11808 | Return the article number moved to, or nil if moving was impossible." | |
11809 | (let ((level (gnus-summary-thread-level)) | |
11810 | (way (if previous -1 1)) | |
11811 | (beg (point))) | |
11812 | (forward-line way) | |
11813 | (while (and (not (eobp)) | |
11814 | (< level (gnus-summary-thread-level))) | |
11815 | (forward-line way)) | |
11816 | (if (eobp) | |
11817 | (progn | |
11818 | (goto-char beg) | |
11819 | nil) | |
11820 | (setq beg (point)) | |
11821 | (prog1 | |
11822 | (gnus-summary-article-number) | |
11823 | (goto-char beg))))) | |
11824 | ||
11825 | (defun gnus-summary-next-thread (n &optional silent) | |
11826 | "Go to the same level next N'th thread. | |
11827 | If N is negative, search backward instead. | |
11828 | Returns the difference between N and the number of skips actually | |
11829 | done. | |
11830 | ||
11831 | If SILENT, don't output messages." | |
11832 | (interactive "p") | |
eec82323 LMI |
11833 | (let ((backward (< n 0)) |
11834 | (n (abs n))) | |
11835 | (while (and (> n 0) | |
11836 | (gnus-summary-go-to-next-thread backward)) | |
11837 | (decf n)) | |
11838 | (unless silent | |
11839 | (gnus-summary-position-point)) | |
11840 | (when (and (not silent) (/= 0 n)) | |
11841 | (gnus-message 7 "No more threads")) | |
11842 | n)) | |
11843 | ||
11844 | (defun gnus-summary-prev-thread (n) | |
11845 | "Go to the same level previous N'th thread. | |
11846 | Returns the difference between N and the number of skips actually | |
11847 | done." | |
11848 | (interactive "p") | |
eec82323 LMI |
11849 | (gnus-summary-next-thread (- n))) |
11850 | ||
11851 | (defun gnus-summary-go-down-thread () | |
11852 | "Go down one level in the current thread." | |
11853 | (let ((children (gnus-summary-article-children))) | |
11854 | (when children | |
11855 | (gnus-summary-goto-subject (car children))))) | |
11856 | ||
11857 | (defun gnus-summary-go-up-thread () | |
11858 | "Go up one level in the current thread." | |
11859 | (let ((parent (gnus-summary-article-parent))) | |
11860 | (when parent | |
11861 | (gnus-summary-goto-subject parent)))) | |
11862 | ||
11863 | (defun gnus-summary-down-thread (n) | |
11864 | "Go down thread N steps. | |
11865 | If N is negative, go up instead. | |
11866 | Returns the difference between N and how many steps down that were | |
11867 | taken." | |
11868 | (interactive "p") | |
eec82323 LMI |
11869 | (let ((up (< n 0)) |
11870 | (n (abs n))) | |
11871 | (while (and (> n 0) | |
11872 | (if up (gnus-summary-go-up-thread) | |
11873 | (gnus-summary-go-down-thread))) | |
11874 | (setq n (1- n))) | |
11875 | (gnus-summary-position-point) | |
11876 | (when (/= 0 n) | |
11877 | (gnus-message 7 "Can't go further")) | |
11878 | n)) | |
11879 | ||
11880 | (defun gnus-summary-up-thread (n) | |
11881 | "Go up thread N steps. | |
23f87bed | 11882 | If N is negative, go down instead. |
eec82323 LMI |
11883 | Returns the difference between N and how many steps down that were |
11884 | taken." | |
11885 | (interactive "p") | |
eec82323 LMI |
11886 | (gnus-summary-down-thread (- n))) |
11887 | ||
11888 | (defun gnus-summary-top-thread () | |
11889 | "Go to the top of the thread." | |
11890 | (interactive) | |
eec82323 LMI |
11891 | (while (gnus-summary-go-up-thread)) |
11892 | (gnus-summary-article-number)) | |
11893 | ||
01c52d31 MB |
11894 | (defun gnus-summary-expire-thread () |
11895 | "Mark articles under current thread as expired." | |
11896 | (interactive) | |
11897 | (gnus-summary-kill-thread 0)) | |
11898 | ||
eec82323 LMI |
11899 | (defun gnus-summary-kill-thread (&optional unmark) |
11900 | "Mark articles under current thread as read. | |
11901 | If the prefix argument is positive, remove any kinds of marks. | |
01c52d31 | 11902 | If the prefix argument is zero, mark thread as expired. |
eec82323 LMI |
11903 | If the prefix argument is negative, tick articles instead." |
11904 | (interactive "P") | |
eec82323 LMI |
11905 | (when unmark |
11906 | (setq unmark (prefix-numeric-value unmark))) | |
01c52d31 MB |
11907 | (let ((articles (gnus-summary-articles-in-thread)) |
11908 | (hide (or (null unmark) (= unmark 0)))) | |
eec82323 LMI |
11909 | (save-excursion |
11910 | ;; Expand the thread. | |
11911 | (gnus-summary-show-thread) | |
11912 | ;; Mark all the articles. | |
11913 | (while articles | |
11914 | (gnus-summary-goto-subject (car articles)) | |
11915 | (cond ((null unmark) | |
11916 | (gnus-summary-mark-article-as-read gnus-killed-mark)) | |
11917 | ((> unmark 0) | |
11918 | (gnus-summary-mark-article-as-unread gnus-unread-mark)) | |
01c52d31 | 11919 | ((= unmark 0) |
4767419a | 11920 | (gnus-summary-mark-article nil gnus-expirable-mark)) |
eec82323 LMI |
11921 | (t |
11922 | (gnus-summary-mark-article-as-unread gnus-ticked-mark))) | |
11923 | (setq articles (cdr articles)))) | |
01c52d31 MB |
11924 | ;; Hide killed subtrees when hide is true. |
11925 | (and hide | |
eec82323 LMI |
11926 | gnus-thread-hide-killed |
11927 | (gnus-summary-hide-thread)) | |
01c52d31 MB |
11928 | ;; If hide is t, go to next unread subject. |
11929 | (when hide | |
eec82323 LMI |
11930 | ;; Go to next unread subject. |
11931 | (gnus-summary-next-subject 1 t))) | |
11932 | (gnus-set-mode-line 'summary)) | |
11933 | ||
11934 | ;; Summary sorting commands | |
11935 | ||
11936 | (defun gnus-summary-sort-by-number (&optional reverse) | |
11937 | "Sort the summary buffer by article number. | |
11938 | Argument REVERSE means reverse order." | |
11939 | (interactive "P") | |
11940 | (gnus-summary-sort 'number reverse)) | |
11941 | ||
6ecfe5c2 MB |
11942 | (defun gnus-summary-sort-by-most-recent-number (&optional reverse) |
11943 | "Sort the summary buffer by most recent article number. | |
11944 | Argument REVERSE means reverse order." | |
11945 | (interactive "P") | |
11946 | (gnus-summary-sort 'most-recent-number reverse)) | |
11947 | ||
23f87bed MB |
11948 | (defun gnus-summary-sort-by-random (&optional reverse) |
11949 | "Randomize the order in the summary buffer. | |
11950 | Argument REVERSE means to randomize in reverse order." | |
11951 | (interactive "P") | |
11952 | (gnus-summary-sort 'random reverse)) | |
11953 | ||
eec82323 LMI |
11954 | (defun gnus-summary-sort-by-author (&optional reverse) |
11955 | "Sort the summary buffer by author name alphabetically. | |
16409b0b | 11956 | If `case-fold-search' is non-nil, case of letters is ignored. |
eec82323 LMI |
11957 | Argument REVERSE means reverse order." |
11958 | (interactive "P") | |
11959 | (gnus-summary-sort 'author reverse)) | |
11960 | ||
01c52d31 MB |
11961 | (defun gnus-summary-sort-by-recipient (&optional reverse) |
11962 | "Sort the summary buffer by recipient name alphabetically. | |
11963 | If `case-fold-search' is non-nil, case of letters is ignored. | |
11964 | Argument REVERSE means reverse order." | |
11965 | (interactive "P") | |
11966 | (gnus-summary-sort 'recipient reverse)) | |
11967 | ||
eec82323 LMI |
11968 | (defun gnus-summary-sort-by-subject (&optional reverse) |
11969 | "Sort the summary buffer by subject alphabetically. `Re:'s are ignored. | |
16409b0b | 11970 | If `case-fold-search' is non-nil, case of letters is ignored. |
eec82323 LMI |
11971 | Argument REVERSE means reverse order." |
11972 | (interactive "P") | |
11973 | (gnus-summary-sort 'subject reverse)) | |
11974 | ||
11975 | (defun gnus-summary-sort-by-date (&optional reverse) | |
11976 | "Sort the summary buffer by date. | |
11977 | Argument REVERSE means reverse order." | |
11978 | (interactive "P") | |
11979 | (gnus-summary-sort 'date reverse)) | |
11980 | ||
6ecfe5c2 MB |
11981 | (defun gnus-summary-sort-by-most-recent-date (&optional reverse) |
11982 | "Sort the summary buffer by most recent date. | |
11983 | Argument REVERSE means reverse order." | |
11984 | (interactive "P") | |
11985 | (gnus-summary-sort 'most-recent-date reverse)) | |
11986 | ||
eec82323 LMI |
11987 | (defun gnus-summary-sort-by-score (&optional reverse) |
11988 | "Sort the summary buffer by score. | |
11989 | Argument REVERSE means reverse order." | |
11990 | (interactive "P") | |
11991 | (gnus-summary-sort 'score reverse)) | |
11992 | ||
11993 | (defun gnus-summary-sort-by-lines (&optional reverse) | |
16409b0b | 11994 | "Sort the summary buffer by the number of lines. |
eec82323 LMI |
11995 | Argument REVERSE means reverse order." |
11996 | (interactive "P") | |
11997 | (gnus-summary-sort 'lines reverse)) | |
11998 | ||
16409b0b GM |
11999 | (defun gnus-summary-sort-by-chars (&optional reverse) |
12000 | "Sort the summary buffer by article length. | |
12001 | Argument REVERSE means reverse order." | |
12002 | (interactive "P") | |
12003 | (gnus-summary-sort 'chars reverse)) | |
12004 | ||
23f87bed MB |
12005 | (defun gnus-summary-sort-by-original (&optional reverse) |
12006 | "Sort the summary buffer using the default sorting method. | |
12007 | Argument REVERSE means reverse order." | |
12008 | (interactive "P") | |
c7a91ce1 | 12009 | (let* ((inhibit-read-only t) |
23f87bed MB |
12010 | (gnus-summary-prepare-hook nil)) |
12011 | ;; We do the sorting by regenerating the threads. | |
12012 | (gnus-summary-prepare) | |
12013 | ;; Hide subthreads if needed. | |
12014 | (gnus-summary-maybe-hide-threads))) | |
12015 | ||
eec82323 LMI |
12016 | (defun gnus-summary-sort (predicate reverse) |
12017 | "Sort summary buffer by PREDICATE. REVERSE means reverse order." | |
eec82323 LMI |
12018 | (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate))) |
12019 | (article (intern (format "gnus-article-sort-by-%s" predicate))) | |
12020 | (gnus-thread-sort-functions | |
16409b0b GM |
12021 | (if (not reverse) |
12022 | thread | |
12023 | `(lambda (t1 t2) | |
12024 | (,thread t2 t1)))) | |
12025 | (gnus-sort-gathered-threads-function | |
12026 | gnus-thread-sort-functions) | |
eec82323 | 12027 | (gnus-article-sort-functions |
16409b0b GM |
12028 | (if (not reverse) |
12029 | article | |
12030 | `(lambda (t1 t2) | |
12031 | (,article t2 t1)))) | |
c7a91ce1 | 12032 | (inhibit-read-only t) |
eec82323 LMI |
12033 | (gnus-summary-prepare-hook nil)) |
12034 | ;; We do the sorting by regenerating the threads. | |
12035 | (gnus-summary-prepare) | |
12036 | ;; Hide subthreads if needed. | |
23f87bed | 12037 | (gnus-summary-maybe-hide-threads))) |
eec82323 LMI |
12038 | |
12039 | ;; Summary saving commands. | |
12040 | ||
12041 | (defun gnus-summary-save-article (&optional n not-saved) | |
12042 | "Save the current article using the default saver function. | |
12043 | If N is a positive number, save the N next articles. | |
12044 | If N is a negative number, save the N previous articles. | |
12045 | If N is nil and any articles have been marked with the process mark, | |
12046 | save those articles instead. | |
26c9afc3 MB |
12047 | The variable `gnus-default-article-saver' specifies the saver function. |
12048 | ||
12049 | If the optional second argument NOT-SAVED is non-nil, articles saved | |
12050 | will not be marked as saved." | |
eec82323 | 12051 | (interactive "P") |
26c9afc3 | 12052 | (require 'gnus-art) |
eec82323 LMI |
12053 | (let* ((articles (gnus-summary-work-articles n)) |
12054 | (save-buffer (save-excursion | |
12055 | (nnheader-set-temp-buffer " *Gnus Save*"))) | |
12056 | (num (length articles)) | |
26c9afc3 MB |
12057 | ;; Whether to save decoded articles or raw articles. |
12058 | (decode (when gnus-article-save-coding-system | |
12059 | (get gnus-default-article-saver :decode))) | |
12060 | ;; When saving many articles in a single file, use the other | |
12061 | ;; function to save articles other than the first one. | |
12062 | (saver2 (get gnus-default-article-saver :function)) | |
12063 | (gnus-prompt-before-saving (if saver2 | |
12064 | t | |
12065 | gnus-prompt-before-saving)) | |
12066 | (gnus-default-article-saver gnus-default-article-saver) | |
16409b0b GM |
12067 | header file) |
12068 | (dolist (article articles) | |
12069 | (setq header (gnus-summary-article-header article)) | |
eec82323 LMI |
12070 | (if (not (vectorp header)) |
12071 | ;; This is a pseudo-article. | |
12072 | (if (assq 'name header) | |
12073 | (gnus-copy-file (cdr (assq 'name header))) | |
ee7683eb | 12074 | (gnus-message 1 "Article %d is unsavable" article)) |
eec82323 LMI |
12075 | ;; This is a real article. |
12076 | (save-window-excursion | |
d567e92f KY |
12077 | (gnus-summary-select-article decode decode nil article) |
12078 | (gnus-summary-goto-subject article)) | |
c7a91ce1 | 12079 | (with-current-buffer save-buffer |
eec82323 | 12080 | (erase-buffer) |
26c9afc3 MB |
12081 | (insert-buffer-substring (if decode |
12082 | gnus-article-buffer | |
12083 | gnus-original-article-buffer))) | |
eec82323 LMI |
12084 | (setq file (gnus-article-save save-buffer file num)) |
12085 | (gnus-summary-remove-process-mark article) | |
12086 | (unless not-saved | |
26c9afc3 MB |
12087 | (gnus-summary-set-saved-mark article))) |
12088 | (when saver2 | |
12089 | (setq gnus-default-article-saver saver2 | |
12090 | saver2 nil))) | |
eec82323 LMI |
12091 | (gnus-kill-buffer save-buffer) |
12092 | (gnus-summary-position-point) | |
12093 | (gnus-set-mode-line 'summary) | |
12094 | n)) | |
12095 | ||
cf6a9685 GM |
12096 | (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw)) |
12097 | ||
6ecfe5c2 | 12098 | (defun gnus-summary-pipe-output (&optional n sym) |
eec82323 LMI |
12099 | "Pipe the current article to a subprocess. |
12100 | If N is a positive number, pipe the N next articles. | |
12101 | If N is a negative number, pipe the N previous articles. | |
12102 | If N is nil and any articles have been marked with the process mark, | |
23f87bed | 12103 | pipe those articles instead. |
6ecfe5c2 MB |
12104 | The default command to which articles are piped is specified by the |
12105 | variable `gnus-summary-pipe-output-default-command'; if it is nil, you | |
12106 | will be prompted for the command. | |
12107 | ||
12108 | The properties `:decode' and `:headers' that are put to the function | |
12109 | symbol `gnus-summary-save-in-pipe' control whether this function | |
12110 | decodes articles and what headers to keep (see the doc string for the | |
12111 | `gnus-default-article-saver' variable). If SYM (the symbolic prefix) | |
12112 | is neither omitted nor the symbol `r', force including all headers | |
12113 | regardless of the `:headers' property. If it is the symbol `r', | |
12114 | articles that are not decoded and include all headers will be piped | |
12115 | no matter what the properties `:decode' and `:headers' are." | |
23f87bed | 12116 | (interactive (gnus-interactive "P\ny")) |
84169620 | 12117 | (require 'gnus-art) |
6ecfe5c2 MB |
12118 | (let* ((articles (gnus-summary-work-articles n)) |
12119 | (result-buffer "*Shell Command Output*") | |
12120 | (all-headers (not (memq sym '(nil r)))) | |
12121 | (gnus-save-all-headers (or all-headers gnus-save-all-headers)) | |
12122 | (raw (eq sym 'r)) | |
12123 | (headers (get 'gnus-summary-save-in-pipe :headers)) | |
12124 | command result) | |
12125 | (unless (numberp (car articles)) | |
12126 | (error "No article to pipe")) | |
12127 | (setq command (gnus-read-shell-command | |
12128 | (concat "Shell command on " | |
12129 | (if (cdr articles) | |
12130 | (format "these %d articles" (length articles)) | |
12131 | "this article") | |
12132 | ": ") | |
12133 | gnus-summary-pipe-output-default-command)) | |
12134 | (when (string-equal command "") | |
12135 | (error "A command is required")) | |
12136 | (when all-headers | |
12137 | (put 'gnus-summary-save-in-pipe :headers nil)) | |
12138 | (unwind-protect | |
12139 | (while articles | |
12140 | (gnus-summary-goto-subject (pop articles)) | |
12141 | (save-window-excursion (gnus-summary-save-in-pipe command raw)) | |
12142 | (when (and (get-buffer result-buffer) | |
12143 | (not (zerop (buffer-size (get-buffer result-buffer))))) | |
12144 | (setq result (concat result (with-current-buffer result-buffer | |
12145 | (buffer-string)))))) | |
12146 | (put 'gnus-summary-save-in-pipe :headers headers)) | |
12147 | (unless (zerop (length result)) | |
12148 | (if (with-current-buffer (get-buffer-create result-buffer) | |
12149 | (erase-buffer) | |
12150 | (insert result) | |
12151 | (prog1 | |
12152 | (and (= (count-lines (point-min) (point)) 1) | |
12153 | (progn | |
12154 | (end-of-line 0) | |
12155 | (<= (current-column) | |
12156 | (window-width (minibuffer-window))))) | |
12157 | (goto-char (point-min)))) | |
12158 | (message "%s" (substring result 0 -1)) | |
12159 | (message nil) | |
12160 | (gnus-configure-windows 'pipe))))) | |
eec82323 LMI |
12161 | |
12162 | (defun gnus-summary-save-article-mail (&optional arg) | |
f18df03d | 12163 | "Append the current article to a Unix mail box file. |
eec82323 LMI |
12164 | If N is a positive number, save the N next articles. |
12165 | If N is a negative number, save the N previous articles. | |
12166 | If N is nil and any articles have been marked with the process mark, | |
12167 | save those articles instead." | |
12168 | (interactive "P") | |
84169620 | 12169 | (require 'gnus-art) |
eec82323 LMI |
12170 | (let ((gnus-default-article-saver 'gnus-summary-save-in-mail)) |
12171 | (gnus-summary-save-article arg))) | |
12172 | ||
12173 | (defun gnus-summary-save-article-rmail (&optional arg) | |
12174 | "Append the current article to an rmail file. | |
12175 | If N is a positive number, save the N next articles. | |
12176 | If N is a negative number, save the N previous articles. | |
12177 | If N is nil and any articles have been marked with the process mark, | |
12178 | save those articles instead." | |
12179 | (interactive "P") | |
84169620 | 12180 | (require 'gnus-art) |
eec82323 LMI |
12181 | (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail)) |
12182 | (gnus-summary-save-article arg))) | |
12183 | ||
12184 | (defun gnus-summary-save-article-file (&optional arg) | |
12185 | "Append the current article to a file. | |
12186 | If N is a positive number, save the N next articles. | |
12187 | If N is a negative number, save the N previous articles. | |
12188 | If N is nil and any articles have been marked with the process mark, | |
12189 | save those articles instead." | |
12190 | (interactive "P") | |
84169620 | 12191 | (require 'gnus-art) |
eec82323 LMI |
12192 | (let ((gnus-default-article-saver 'gnus-summary-save-in-file)) |
12193 | (gnus-summary-save-article arg))) | |
12194 | ||
12195 | (defun gnus-summary-write-article-file (&optional arg) | |
12196 | "Write the current article to a file, deleting the previous file. | |
12197 | If N is a positive number, save the N next articles. | |
12198 | If N is a negative number, save the N previous articles. | |
12199 | If N is nil and any articles have been marked with the process mark, | |
12200 | save those articles instead." | |
12201 | (interactive "P") | |
84169620 | 12202 | (require 'gnus-art) |
eec82323 LMI |
12203 | (let ((gnus-default-article-saver 'gnus-summary-write-to-file)) |
12204 | (gnus-summary-save-article arg))) | |
12205 | ||
12206 | (defun gnus-summary-save-article-body-file (&optional arg) | |
12207 | "Append the current article body to a file. | |
12208 | If N is a positive number, save the N next articles. | |
12209 | If N is a negative number, save the N previous articles. | |
12210 | If N is nil and any articles have been marked with the process mark, | |
12211 | save those articles instead." | |
12212 | (interactive "P") | |
84169620 | 12213 | (require 'gnus-art) |
eec82323 LMI |
12214 | (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file)) |
12215 | (gnus-summary-save-article arg))) | |
12216 | ||
26c9afc3 MB |
12217 | (defun gnus-summary-write-article-body-file (&optional arg) |
12218 | "Write the current article body to a file, deleting the previous file. | |
12219 | If N is a positive number, save the N next articles. | |
12220 | If N is a negative number, save the N previous articles. | |
12221 | If N is nil and any articles have been marked with the process mark, | |
12222 | save those articles instead." | |
12223 | (interactive "P") | |
12224 | (require 'gnus-art) | |
12225 | (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file)) | |
12226 | (gnus-summary-save-article arg))) | |
12227 | ||
23f87bed MB |
12228 | (defun gnus-summary-muttprint (&optional arg) |
12229 | "Print the current article using Muttprint. | |
12230 | If N is a positive number, save the N next articles. | |
12231 | If N is a negative number, save the N previous articles. | |
12232 | If N is nil and any articles have been marked with the process mark, | |
12233 | save those articles instead." | |
12234 | (interactive "P") | |
12235 | (require 'gnus-art) | |
12236 | (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint)) | |
12237 | (gnus-summary-save-article arg t))) | |
12238 | ||
eec82323 LMI |
12239 | (defun gnus-summary-pipe-message (program) |
12240 | "Pipe the current article through PROGRAM." | |
12241 | (interactive "sProgram: ") | |
eec82323 | 12242 | (gnus-summary-select-article) |
6748645f | 12243 | (let ((mail-header-separator "")) |
eec82323 LMI |
12244 | (gnus-eval-in-buffer-window gnus-article-buffer |
12245 | (save-restriction | |
23f87bed MB |
12246 | (widen) |
12247 | (let ((start (window-start)) | |
c7a91ce1 | 12248 | (inhibit-read-only t)) |
23f87bed MB |
12249 | (message-pipe-buffer-body program) |
12250 | (set-window-start (get-buffer-window (current-buffer)) start)))))) | |
eec82323 LMI |
12251 | |
12252 | (defun gnus-get-split-value (methods) | |
12253 | "Return a value based on the split METHODS." | |
12254 | (let (split-name method result match) | |
12255 | (when methods | |
c7a91ce1 | 12256 | (with-current-buffer gnus-original-article-buffer |
eec82323 LMI |
12257 | (save-restriction |
12258 | (nnheader-narrow-to-headers) | |
d4dfaa19 | 12259 | (while (and methods (not split-name)) |
eec82323 LMI |
12260 | (goto-char (point-min)) |
12261 | (setq method (pop methods)) | |
12262 | (setq match (car method)) | |
12263 | (when (cond | |
12264 | ((stringp match) | |
12265 | ;; Regular expression. | |
12266 | (ignore-errors | |
12267 | (re-search-forward match nil t))) | |
23f87bed | 12268 | ((functionp match) |
eec82323 LMI |
12269 | ;; Function. |
12270 | (save-restriction | |
12271 | (widen) | |
12272 | (setq result (funcall match gnus-newsgroup-name)))) | |
12273 | ((consp match) | |
12274 | ;; Form. | |
12275 | (save-restriction | |
12276 | (widen) | |
12277 | (setq result (eval match))))) | |
d4dfaa19 | 12278 | (setq split-name (cdr method)) |
eec82323 LMI |
12279 | (cond ((stringp result) |
12280 | (push (expand-file-name | |
12281 | result gnus-article-save-directory) | |
12282 | split-name)) | |
12283 | ((consp result) | |
12284 | (setq split-name (append result split-name))))))))) | |
16409b0b | 12285 | (nreverse split-name))) |
eec82323 LMI |
12286 | |
12287 | (defun gnus-valid-move-group-p (group) | |
229b59da G |
12288 | (and (symbolp group) |
12289 | (boundp group) | |
eec82323 | 12290 | (symbol-name group) |
16409b0b GM |
12291 | (symbol-value group) |
12292 | (gnus-get-function (gnus-find-method-for-group | |
12293 | (symbol-name group)) 'request-accept-article t))) | |
eec82323 LMI |
12294 | |
12295 | (defun gnus-read-move-group-name (prompt default articles prefix) | |
12296 | "Read a group name." | |
12297 | (let* ((split-name (gnus-get-split-value gnus-move-split-methods)) | |
12298 | (minibuffer-confirm-incomplete nil) ; XEmacs | |
12299 | (prom | |
81df110a | 12300 | (format "%s %s to" |
eec82323 LMI |
12301 | prompt |
12302 | (if (> (length articles) 1) | |
12303 | (format "these %d articles" (length articles)) | |
12304 | "this article"))) | |
12305 | (to-newsgroup | |
229b59da G |
12306 | (cond |
12307 | ((null split-name) | |
12308 | (gnus-group-completing-read | |
12309 | prom | |
61c47336 | 12310 | (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t) |
229b59da G |
12311 | nil prefix nil default)) |
12312 | ((= 1 (length split-name)) | |
12313 | (gnus-group-completing-read | |
61c47336 KY |
12314 | prom |
12315 | (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t) | |
229b59da G |
12316 | nil prefix 'gnus-group-history (car split-name))) |
12317 | (t | |
12318 | (gnus-completing-read | |
12319 | prom (nreverse split-name) nil nil 'gnus-group-history)))) | |
12320 | (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))) | |
01c52d31 | 12321 | encoded) |
eec82323 LMI |
12322 | (when to-newsgroup |
12323 | (if (or (string= to-newsgroup "") | |
12324 | (string= to-newsgroup prefix)) | |
12325 | (setq to-newsgroup default)) | |
12326 | (unless to-newsgroup | |
12327 | (error "No group name entered")) | |
01c52d31 MB |
12328 | (setq encoded (mm-encode-coding-string |
12329 | to-newsgroup | |
12330 | (gnus-group-name-charset to-method to-newsgroup))) | |
12331 | (or (gnus-active encoded) | |
12332 | (gnus-activate-group encoded nil nil to-method) | |
eec82323 LMI |
12333 | (if (gnus-y-or-n-p (format "No such group: %s. Create it? " |
12334 | to-newsgroup)) | |
01c52d31 MB |
12335 | (or (and (gnus-request-create-group encoded to-method) |
12336 | (gnus-activate-group encoded nil nil to-method) | |
12337 | (gnus-subscribe-group encoded)) | |
eec82323 | 12338 | (error "Couldn't create group %s" to-newsgroup))) |
01c52d31 MB |
12339 | (error "No such group: %s" to-newsgroup)) |
12340 | encoded))) | |
12341 | ||
12342 | (defvar gnus-summary-save-parts-counter) | |
704f1663 | 12343 | (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type)) |
eec82323 | 12344 | |
16409b0b GM |
12345 | (defun gnus-summary-save-parts (type dir n &optional reverse) |
12346 | "Save parts matching TYPE to DIR. | |
12347 | If REVERSE, save parts that do not match TYPE." | |
12348 | (interactive | |
a1506d29 | 12349 | (list (read-string "Save parts of type: " |
8b93df01 DL |
12350 | (or (car gnus-summary-save-parts-type-history) |
12351 | gnus-summary-save-parts-default-mime) | |
12352 | 'gnus-summary-save-parts-type-history) | |
12353 | (setq gnus-summary-save-parts-last-directory | |
cec2114e AL |
12354 | (read-directory-name "Save to directory: " |
12355 | gnus-summary-save-parts-last-directory | |
12356 | nil t)) | |
16409b0b GM |
12357 | current-prefix-arg)) |
12358 | (gnus-summary-iterate n | |
12359 | (let ((gnus-display-mime-function nil) | |
3a23a519 MB |
12360 | gnus-article-prepare-hook |
12361 | gnus-article-decode-hook | |
12362 | gnus-display-mime-function | |
12363 | gnus-break-pages | |
16409b0b GM |
12364 | (gnus-inhibit-treatment t)) |
12365 | (gnus-summary-select-article)) | |
c7a91ce1 | 12366 | (with-current-buffer gnus-article-buffer |
16409b0b | 12367 | (let ((handles (or gnus-article-mime-handles |
23f87bed MB |
12368 | (mm-dissect-buffer nil gnus-article-loose-mime) |
12369 | (and gnus-article-emulate-mime | |
01c52d31 MB |
12370 | (mm-uu-dissect)))) |
12371 | (gnus-summary-save-parts-counter 1)) | |
16409b0b GM |
12372 | (when handles |
12373 | (gnus-summary-save-parts-1 type dir handles reverse) | |
12374 | (unless gnus-article-mime-handles ;; Don't destroy this case. | |
12375 | (mm-destroy-parts handles))))))) | |
12376 | ||
12377 | (defun gnus-summary-save-parts-1 (type dir handle reverse) | |
12378 | (if (stringp (car handle)) | |
12379 | (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse)) | |
12380 | (cdr handle)) | |
12381 | (when (if reverse | |
12382 | (not (string-match type (mm-handle-media-type handle))) | |
12383 | (string-match type (mm-handle-media-type handle))) | |
12384 | (let ((file (expand-file-name | |
23f87bed MB |
12385 | (gnus-map-function |
12386 | mm-file-name-rewrite-functions | |
12387 | (file-name-nondirectory | |
12388 | (or | |
247c22e1 | 12389 | (mm-handle-filename handle) |
01c52d31 MB |
12390 | (format "%s.%d.%d" gnus-newsgroup-name |
12391 | (cdr gnus-article-current) | |
12392 | gnus-summary-save-parts-counter)))) | |
16409b0b | 12393 | dir))) |
01c52d31 | 12394 | (incf gnus-summary-save-parts-counter) |
16409b0b GM |
12395 | (unless (file-exists-p file) |
12396 | (mm-save-part-to-file handle file)))))) | |
12397 | ||
eec82323 LMI |
12398 | ;; Summary extract commands |
12399 | ||
12400 | (defun gnus-summary-insert-pseudos (pslist &optional not-view) | |
c7a91ce1 | 12401 | (let ((inhibit-read-only t) |
eec82323 LMI |
12402 | (article (gnus-summary-article-number)) |
12403 | after-article b e) | |
12404 | (unless (gnus-summary-goto-subject article) | |
12405 | (error "No such article: %d" article)) | |
12406 | (gnus-summary-position-point) | |
12407 | ;; If all commands are to be bunched up on one line, we collect | |
12408 | ;; them here. | |
12409 | (unless gnus-view-pseudos-separately | |
12410 | (let ((ps (setq pslist (sort pslist 'gnus-pseudos<))) | |
12411 | files action) | |
12412 | (while ps | |
12413 | (setq action (cdr (assq 'action (car ps)))) | |
12414 | (setq files (list (cdr (assq 'name (car ps))))) | |
12415 | (while (and ps (cdr ps) | |
12416 | (string= (or action "1") | |
12417 | (or (cdr (assq 'action (cadr ps))) "2"))) | |
12418 | (push (cdr (assq 'name (cadr ps))) files) | |
12419 | (setcdr ps (cddr ps))) | |
12420 | (when files | |
12421 | (when (not (string-match "%s" action)) | |
12422 | (push " " files)) | |
12423 | (push " " files) | |
12424 | (when (assq 'execute (car ps)) | |
12425 | (setcdr (assq 'execute (car ps)) | |
12426 | (funcall (if (string-match "%s" action) | |
12427 | 'format 'concat) | |
12428 | action | |
12429 | (mapconcat | |
12430 | (lambda (f) | |
12431 | (if (equal f " ") | |
12432 | f | |
01c52d31 | 12433 | (shell-quote-argument f))) |
eec82323 LMI |
12434 | files " "))))) |
12435 | (setq ps (cdr ps))))) | |
12436 | (if (and gnus-view-pseudos (not not-view)) | |
12437 | (while pslist | |
12438 | (when (assq 'execute (car pslist)) | |
12439 | (gnus-execute-command (cdr (assq 'execute (car pslist))) | |
12440 | (eq gnus-view-pseudos 'not-confirm))) | |
12441 | (setq pslist (cdr pslist))) | |
12442 | (save-excursion | |
12443 | (while pslist | |
12444 | (setq after-article (or (cdr (assq 'article (car pslist))) | |
12445 | (gnus-summary-article-number))) | |
12446 | (gnus-summary-goto-subject after-article) | |
12447 | (forward-line 1) | |
12448 | (setq b (point)) | |
12449 | (insert " " (file-name-nondirectory | |
12450 | (cdr (assq 'name (car pslist)))) | |
12451 | ": " (or (cdr (assq 'execute (car pslist))) "") "\n") | |
12452 | (setq e (point)) | |
12453 | (forward-line -1) ; back to `b' | |
12454 | (gnus-add-text-properties | |
12455 | b (1- e) (list 'gnus-number gnus-reffed-article-number | |
12456 | gnus-mouse-face-prop gnus-mouse-face)) | |
12457 | (gnus-data-enter | |
12458 | after-article gnus-reffed-article-number | |
12459 | gnus-unread-mark b (car pslist) 0 (- e b)) | |
23f87bed MB |
12460 | (setq gnus-newsgroup-unreads |
12461 | (gnus-add-to-sorted-list gnus-newsgroup-unreads | |
12462 | gnus-reffed-article-number)) | |
eec82323 LMI |
12463 | (setq gnus-reffed-article-number (1- gnus-reffed-article-number)) |
12464 | (setq pslist (cdr pslist))))))) | |
12465 | ||
12466 | (defun gnus-pseudos< (p1 p2) | |
12467 | (let ((c1 (cdr (assq 'action p1))) | |
12468 | (c2 (cdr (assq 'action p2)))) | |
12469 | (and c1 c2 (string< c1 c2)))) | |
12470 | ||
12471 | (defun gnus-request-pseudo-article (props) | |
12472 | (cond ((assq 'execute props) | |
12473 | (gnus-execute-command (cdr (assq 'execute props))))) | |
12474 | (let ((gnus-current-article (gnus-summary-article-number))) | |
6748645f | 12475 | (gnus-run-hooks 'gnus-mark-article-hook))) |
eec82323 LMI |
12476 | |
12477 | (defun gnus-execute-command (command &optional automatic) | |
12478 | (save-excursion | |
12479 | (gnus-article-setup-buffer) | |
12480 | (set-buffer gnus-article-buffer) | |
12481 | (setq buffer-read-only nil) | |
a8151ef7 LMI |
12482 | (let ((command (if automatic command |
12483 | (read-string "Command: " (cons command 0))))) | |
eec82323 LMI |
12484 | (erase-buffer) |
12485 | (insert "$ " command "\n\n") | |
12486 | (if gnus-view-pseudo-asynchronously | |
12487 | (start-process "gnus-execute" (current-buffer) shell-file-name | |
12488 | shell-command-switch command) | |
12489 | (call-process shell-file-name nil t nil | |
12490 | shell-command-switch command))))) | |
12491 | ||
12492 | ;; Summary kill commands. | |
12493 | ||
12494 | (defun gnus-summary-edit-global-kill (article) | |
12495 | "Edit the \"global\" kill file." | |
12496 | (interactive (list (gnus-summary-article-number))) | |
eec82323 LMI |
12497 | (gnus-group-edit-global-kill article)) |
12498 | ||
12499 | (defun gnus-summary-edit-local-kill () | |
12500 | "Edit a local kill file applied to the current newsgroup." | |
12501 | (interactive) | |
eec82323 | 12502 | (setq gnus-current-headers (gnus-summary-article-header)) |
eec82323 LMI |
12503 | (gnus-group-edit-local-kill |
12504 | (gnus-summary-article-number) gnus-newsgroup-name)) | |
12505 | ||
12506 | ;;; Header reading. | |
12507 | ||
12508 | (defun gnus-read-header (id &optional header) | |
12509 | "Read the headers of article ID and enter them into the Gnus system." | |
12510 | (let ((group gnus-newsgroup-name) | |
12511 | (gnus-override-method | |
16409b0b GM |
12512 | (or |
12513 | gnus-override-method | |
12514 | (and (gnus-news-group-p gnus-newsgroup-name) | |
12515 | (car (gnus-refer-article-methods))))) | |
eec82323 LMI |
12516 | where) |
12517 | ;; First we check to see whether the header in question is already | |
12518 | ;; fetched. | |
12519 | (if (stringp id) | |
12520 | ;; This is a Message-ID. | |
12521 | (setq header (or header (gnus-id-to-header id))) | |
12522 | ;; This is an article number. | |
12523 | (setq header (or header (gnus-summary-article-header id)))) | |
12524 | (if (and header | |
12525 | (not (gnus-summary-article-sparse-p (mail-header-number header)))) | |
12526 | ;; We have found the header. | |
12527 | header | |
12528 | ;; We have to really fetch the header to this article. | |
c7a91ce1 | 12529 | (with-current-buffer nntp-server-buffer |
eec82323 LMI |
12530 | (when (setq where (gnus-request-head id group)) |
12531 | (nnheader-fold-continuation-lines) | |
12532 | (goto-char (point-max)) | |
12533 | (insert ".\n") | |
12534 | (goto-char (point-min)) | |
12535 | (insert "211 ") | |
12536 | (princ (cond | |
12537 | ((numberp id) id) | |
12538 | ((cdr where) (cdr where)) | |
12539 | (header (mail-header-number header)) | |
12540 | (t gnus-reffed-article-number)) | |
12541 | (current-buffer)) | |
12542 | (insert " Article retrieved.\n")) | |
12543 | (if (or (not where) | |
12544 | (not (setq header (car (gnus-get-newsgroup-headers nil t))))) | |
12545 | () ; Malformed head. | |
12546 | (unless (gnus-summary-article-sparse-p (mail-header-number header)) | |
89b163db G |
12547 | (when (and (bound-and-true-p gnus-registry-enabled) |
12548 | (not (gnus-ephemeral-group-p (car where)))) | |
12549 | (gnus-registry-handle-action | |
12550 | (mail-header-id header) nil | |
f4c7b20f AC |
12551 | (gnus-group-prefixed-name |
12552 | (car where) | |
12553 | (or gnus-override-method (gnus-find-method-for-group group))) | |
89b163db G |
12554 | (mail-header-subject header) |
12555 | (mail-header-from header))) | |
eec82323 | 12556 | (when (and (stringp id) |
01c52d31 MB |
12557 | (or |
12558 | (not (string= (gnus-group-real-name group) | |
12559 | (car where))) | |
12560 | (not (gnus-server-equal gnus-override-method | |
12561 | (gnus-group-method group))))) | |
12562 | ;; If we fetched by Message-ID and the article came from | |
12563 | ;; a different group (or server), we fudge some bogus | |
12564 | ;; article numbers for this article. | |
eec82323 | 12565 | (mail-header-set-number header gnus-reffed-article-number)) |
c7a91ce1 | 12566 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
12567 | (decf gnus-reffed-article-number) |
12568 | (gnus-remove-header (mail-header-number header)) | |
12569 | (push header gnus-newsgroup-headers) | |
12570 | (setq gnus-current-headers header) | |
12571 | (push (mail-header-number header) gnus-newsgroup-limit))) | |
12572 | header))))) | |
12573 | ||
12574 | (defun gnus-remove-header (number) | |
12575 | "Remove header NUMBER from `gnus-newsgroup-headers'." | |
12576 | (if (and gnus-newsgroup-headers | |
12577 | (= number (mail-header-number (car gnus-newsgroup-headers)))) | |
12578 | (pop gnus-newsgroup-headers) | |
12579 | (let ((headers gnus-newsgroup-headers)) | |
12580 | (while (and (cdr headers) | |
12581 | (not (= number (mail-header-number (cadr headers))))) | |
12582 | (pop headers)) | |
12583 | (when (cdr headers) | |
12584 | (setcdr headers (cddr headers)))))) | |
12585 | ||
12586 | ;;; | |
12587 | ;;; summary highlights | |
12588 | ;;; | |
12589 | ||
12590 | (defun gnus-highlight-selected-summary () | |
16409b0b | 12591 | "Highlight selected article in summary buffer." |
eec82323 | 12592 | ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>. |
eec82323 LMI |
12593 | (when gnus-summary-selected-face |
12594 | (save-excursion | |
01c52d31 MB |
12595 | (let* ((beg (point-at-bol)) |
12596 | (end (point-at-eol)) | |
eec82323 LMI |
12597 | ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>. |
12598 | (from (if (get-text-property beg gnus-mouse-face-prop) | |
12599 | beg | |
12600 | (or (next-single-property-change | |
12601 | beg gnus-mouse-face-prop nil end) | |
12602 | beg))) | |
12603 | (to | |
12604 | (if (= from end) | |
12605 | (- from 2) | |
12606 | (or (next-single-property-change | |
12607 | from gnus-mouse-face-prop nil end) | |
12608 | end)))) | |
12609 | ;; If no mouse-face prop on line we will have to = from = end, | |
12610 | ;; so we highlight the entire line instead. | |
12611 | (when (= (+ to 2) from) | |
12612 | (setq from beg) | |
12613 | (setq to end)) | |
12614 | (if gnus-newsgroup-selected-overlay | |
12615 | ;; Move old overlay. | |
12616 | (gnus-move-overlay | |
12617 | gnus-newsgroup-selected-overlay from to (current-buffer)) | |
12618 | ;; Create new overlay. | |
12619 | (gnus-overlay-put | |
12620 | (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to)) | |
12621 | 'face gnus-summary-selected-face)))))) | |
12622 | ||
23f87bed MB |
12623 | (defvar gnus-summary-highlight-line-cached nil) |
12624 | (defvar gnus-summary-highlight-line-trigger nil) | |
12625 | ||
12626 | (defun gnus-summary-highlight-line-0 () | |
12627 | (if (and (eq gnus-summary-highlight-line-trigger | |
12628 | gnus-summary-highlight) | |
12629 | gnus-summary-highlight-line-cached) | |
12630 | gnus-summary-highlight-line-cached | |
12631 | (setq gnus-summary-highlight-line-trigger gnus-summary-highlight | |
12632 | gnus-summary-highlight-line-cached | |
12633 | (let* ((cond (list 'cond)) | |
12634 | (c cond) | |
12635 | (list gnus-summary-highlight)) | |
12636 | (while list | |
12637 | (setcdr c (cons (list (caar list) (list 'quote (cdar list))) | |
12638 | nil)) | |
12639 | (setq c (cdr c) | |
12640 | list (cdr list))) | |
12641 | (gnus-byte-compile (list 'lambda nil cond)))))) | |
12642 | ||
eec82323 LMI |
12643 | (defun gnus-summary-highlight-line () |
12644 | "Highlight current line according to `gnus-summary-highlight'." | |
01c52d31 | 12645 | (let* ((beg (point-at-bol)) |
23f87bed MB |
12646 | (article (or (gnus-summary-article-number) gnus-current-article)) |
12647 | (score (or (cdr (assq article | |
eec82323 LMI |
12648 | gnus-newsgroup-scored)) |
12649 | gnus-summary-default-score 0)) | |
12650 | (mark (or (gnus-summary-article-mark) gnus-unread-mark)) | |
23f87bed MB |
12651 | (inhibit-read-only t) |
12652 | (default gnus-summary-default-score) | |
12653 | (default-high gnus-summary-default-high-score) | |
12654 | (default-low gnus-summary-default-low-score) | |
12655 | (uncached (and gnus-summary-use-undownloaded-faces | |
54506618 MB |
12656 | (memq article gnus-newsgroup-undownloaded) |
12657 | (not (memq article gnus-newsgroup-cached))))) | |
23f87bed | 12658 | (let ((face (funcall (gnus-summary-highlight-line-0)))) |
cc21c235 | 12659 | (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face)) |
1d43a35f CY |
12660 | (gnus-put-text-property-excluding-characters-with-faces |
12661 | beg (point-at-eol) 'face | |
12662 | (setq face (if (boundp face) (symbol-value face) face))) | |
eec82323 | 12663 | (when gnus-summary-highlight-line-function |
23f87bed | 12664 | (funcall gnus-summary-highlight-line-function article face)))))) |
eec82323 | 12665 | |
6748645f | 12666 | (defun gnus-update-read-articles (group unread &optional compute) |
23f87bed MB |
12667 | "Update the list of read articles in GROUP. |
12668 | UNREAD is a sorted list." | |
01c52d31 MB |
12669 | (let ((active (or gnus-newsgroup-active (gnus-active group))) |
12670 | (info (gnus-get-info group)) | |
12671 | (prev 1) | |
12672 | read) | |
eec82323 LMI |
12673 | (if (or (not info) (not active)) |
12674 | ;; There is no info on this group if it was, in fact, | |
12675 | ;; killed. Gnus stores no information on killed groups, so | |
12676 | ;; there's nothing to be done. | |
12677 | ;; One could store the information somewhere temporarily, | |
12678 | ;; perhaps... Hmmm... | |
12679 | () | |
12680 | ;; Remove any negative articles numbers. | |
12681 | (while (and unread (< (car unread) 0)) | |
12682 | (setq unread (cdr unread))) | |
12683 | ;; Remove any expired article numbers | |
12684 | (while (and unread (< (car unread) (car active))) | |
12685 | (setq unread (cdr unread))) | |
12686 | ;; Compute the ranges of read articles by looking at the list of | |
12687 | ;; unread articles. | |
12688 | (while unread | |
12689 | (when (/= (car unread) prev) | |
12690 | (push (if (= prev (1- (car unread))) prev | |
12691 | (cons prev (1- (car unread)))) | |
12692 | read)) | |
12693 | (setq prev (1+ (car unread))) | |
12694 | (setq unread (cdr unread))) | |
12695 | (when (<= prev (cdr active)) | |
12696 | (push (cons prev (cdr active)) read)) | |
16409b0b | 12697 | (setq read (if (> (length read) 1) (nreverse read) read)) |
6748645f | 12698 | (if compute |
16409b0b | 12699 | read |
6748645f | 12700 | (save-excursion |
16409b0b GM |
12701 | (let (setmarkundo) |
12702 | ;; Propagate the read marks to the backend. | |
89b163db G |
12703 | (when (and (gnus-method-option-p |
12704 | (gnus-find-method-for-group group) | |
12705 | 'server-marks) | |
3a23a519 | 12706 | (gnus-check-backend-function 'request-set-mark group)) |
16409b0b GM |
12707 | (let ((del (gnus-remove-from-range (gnus-info-read info) read)) |
12708 | (add (gnus-remove-from-range read (gnus-info-read info)))) | |
12709 | (when (or add del) | |
12710 | (unless (gnus-check-group group) | |
12711 | (error "Can't open server for %s" group)) | |
12712 | (gnus-request-set-mark | |
12713 | group (delq nil (list (if add (list add 'add '(read))) | |
12714 | (if del (list del 'del '(read)))))) | |
12715 | (setq setmarkundo | |
12716 | `(gnus-request-set-mark | |
12717 | ,group | |
12718 | ',(delq nil (list | |
12719 | (if del (list del 'add '(read))) | |
12720 | (if add (list add 'del '(read)))))))))) | |
12721 | (set-buffer gnus-group-buffer) | |
12722 | (gnus-undo-register | |
12723 | `(progn | |
12724 | (gnus-info-set-marks ',info ',(gnus-info-marks info) t) | |
12725 | (gnus-info-set-read ',info ',(gnus-info-read info)) | |
a1506d29 | 12726 | (gnus-get-unread-articles-in-group ',info |
16409b0b GM |
12727 | (gnus-active ,group)) |
12728 | (gnus-group-update-group ,group t) | |
12729 | ,setmarkundo)))) | |
6748645f | 12730 | ;; Enter this list into the group info. |
16409b0b | 12731 | (gnus-info-set-read info read) |
6748645f LMI |
12732 | ;; Set the number of unread articles in gnus-newsrc-hashtb. |
12733 | (gnus-get-unread-articles-in-group info (gnus-active group)) | |
12734 | t)))) | |
eec82323 LMI |
12735 | |
12736 | (defun gnus-offer-save-summaries () | |
12737 | "Offer to save all active summary buffers." | |
23f87bed MB |
12738 | (let (buffers) |
12739 | ;; Go through all buffers and find all summaries. | |
12740 | (dolist (buffer (buffer-list)) | |
12741 | (when (and (setq buffer (buffer-name buffer)) | |
12742 | (string-match "Summary" buffer) | |
01c52d31 | 12743 | (with-current-buffer buffer |
23f87bed | 12744 | ;; We check that this is, indeed, a summary buffer. |
c2e9e9ef | 12745 | (and (derived-mode-p 'gnus-summary-mode) |
23f87bed MB |
12746 | ;; Also make sure this isn't bogus. |
12747 | gnus-newsgroup-prepared | |
12748 | ;; Also make sure that this isn't a | |
12749 | ;; dead summary buffer. | |
12750 | (not gnus-dead-summary-mode)))) | |
12751 | (push buffer buffers))) | |
12752 | ;; Go through all these summary buffers and offer to save them. | |
12753 | (when buffers | |
12754 | (save-excursion | |
e21bac42 G |
12755 | (if (eq gnus-interactive-exit 'quiet) |
12756 | (dolist (buffer buffers) | |
12757 | (switch-to-buffer buffer) | |
12758 | (gnus-summary-exit)) | |
12759 | (map-y-or-n-p | |
12760 | "Update summary buffer %s? " | |
12761 | (lambda (buf) | |
12762 | (switch-to-buffer buf) | |
12763 | (gnus-summary-exit)) | |
12764 | buffers)))))) | |
eec82323 | 12765 | |
16409b0b GM |
12766 | (defun gnus-summary-setup-default-charset () |
12767 | "Setup newsgroup default charset." | |
23f87bed | 12768 | (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts")) |
16409b0b | 12769 | (setq gnus-newsgroup-charset nil) |
23f87bed | 12770 | (let* ((ignored-charsets |
16409b0b GM |
12771 | (or gnus-newsgroup-ephemeral-ignored-charsets |
12772 | (append | |
12773 | (and gnus-newsgroup-name | |
23f87bed | 12774 | (gnus-parameter-ignored-charsets gnus-newsgroup-name)) |
16409b0b GM |
12775 | gnus-newsgroup-ignored-charsets)))) |
12776 | (setq gnus-newsgroup-charset | |
12777 | (or gnus-newsgroup-ephemeral-charset | |
12778 | (and gnus-newsgroup-name | |
23f87bed | 12779 | (gnus-parameter-charset gnus-newsgroup-name)) |
16409b0b GM |
12780 | gnus-default-charset)) |
12781 | (set (make-local-variable 'gnus-newsgroup-ignored-charsets) | |
12782 | ignored-charsets)))) | |
12783 | ||
12784 | ;;; | |
12785 | ;;; Mime Commands | |
12786 | ;;; | |
12787 | ||
12788 | (defun gnus-summary-display-buttonized (&optional show-all-parts) | |
12789 | "Display the current article buffer fully MIME-buttonized. | |
12790 | If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are | |
12791 | treated as multipart/mixed." | |
12792 | (interactive "P") | |
12793 | (require 'gnus-art) | |
12794 | (let ((gnus-unbuttonized-mime-types nil) | |
12795 | (gnus-mime-display-multipart-as-mixed show-all-parts)) | |
12796 | (gnus-summary-show-article))) | |
12797 | ||
12798 | (defun gnus-summary-repair-multipart (article) | |
12799 | "Add a Content-Type header to a multipart article without one." | |
12800 | (interactive (list (gnus-summary-article-number))) | |
12801 | (gnus-with-article article | |
12802 | (message-narrow-to-head) | |
23f87bed | 12803 | (message-remove-header "Mime-Version") |
16409b0b | 12804 | (goto-char (point-max)) |
23f87bed | 12805 | (insert "Mime-Version: 1.0\n") |
16409b0b GM |
12806 | (widen) |
12807 | (when (search-forward "\n--" nil t) | |
01c52d31 | 12808 | (let ((separator (buffer-substring (point) (point-at-eol)))) |
16409b0b | 12809 | (message-narrow-to-head) |
16409b0b GM |
12810 | (message-remove-header "Content-Type") |
12811 | (goto-char (point-max)) | |
12812 | (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n" | |
12813 | separator)) | |
16409b0b GM |
12814 | (widen)))) |
12815 | (let (gnus-mark-article-hook) | |
12816 | (gnus-summary-select-article t t nil article))) | |
12817 | ||
12818 | (defun gnus-summary-toggle-display-buttonized () | |
12819 | "Toggle the buttonizing of the article buffer." | |
12820 | (interactive) | |
12821 | (require 'gnus-art) | |
12822 | (if (setq gnus-inhibit-mime-unbuttonizing | |
12823 | (not gnus-inhibit-mime-unbuttonizing)) | |
12824 | (let ((gnus-unbuttonized-mime-types nil)) | |
12825 | (gnus-summary-show-article)) | |
12826 | (gnus-summary-show-article))) | |
12827 | ||
12828 | ;;; | |
12829 | ;;; Generic summary marking commands | |
12830 | ;;; | |
12831 | ||
12832 | (defvar gnus-summary-marking-alist | |
12833 | '((read gnus-del-mark "d") | |
12834 | (unread gnus-unread-mark "u") | |
12835 | (ticked gnus-ticked-mark "!") | |
12836 | (dormant gnus-dormant-mark "?") | |
12837 | (expirable gnus-expirable-mark "e")) | |
12838 | "An alist of names/marks/keystrokes.") | |
12839 | ||
12840 | (defvar gnus-summary-generic-mark-map (make-sparse-keymap)) | |
12841 | (defvar gnus-summary-mark-map) | |
12842 | ||
12843 | (defun gnus-summary-make-all-marking-commands () | |
12844 | (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map) | |
12845 | (dolist (elem gnus-summary-marking-alist) | |
12846 | (apply 'gnus-summary-make-marking-command elem))) | |
12847 | ||
12848 | (defun gnus-summary-make-marking-command (name mark keystroke) | |
12849 | (let ((map (make-sparse-keymap))) | |
12850 | (define-key gnus-summary-generic-mark-map keystroke map) | |
12851 | (dolist (lway `((next "next" next nil "n") | |
12852 | (next-unread "next unread" next t "N") | |
12853 | (prev "previous" prev nil "p") | |
12854 | (prev-unread "previous unread" prev t "P") | |
12855 | (nomove "" nil nil ,keystroke))) | |
12856 | (let ((func (gnus-summary-make-marking-command-1 | |
12857 | mark (car lway) lway name))) | |
12858 | (setq func (eval func)) | |
12859 | (define-key map (nth 4 lway) func))))) | |
a1506d29 | 12860 | |
16409b0b GM |
12861 | (defun gnus-summary-make-marking-command-1 (mark way lway name) |
12862 | `(defun ,(intern | |
12863 | (format "gnus-summary-put-mark-as-%s%s" | |
12864 | name (if (eq way 'nomove) | |
12865 | "" | |
12866 | (concat "-" (symbol-name way))))) | |
12867 | (n) | |
12868 | ,(format | |
12869 | "Mark the current article as %s%s. | |
12870 | If N, the prefix, then repeat N times. | |
12871 | If N is negative, move in reverse order. | |
12872 | The difference between N and the actual number of articles marked is | |
12873 | returned." | |
12874 | name (cadr lway)) | |
12875 | (interactive "p") | |
12876 | (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway)))) | |
a1506d29 | 12877 | |
16409b0b GM |
12878 | (defun gnus-summary-generic-mark (n mark move unread) |
12879 | "Mark N articles with MARK." | |
c2e9e9ef | 12880 | (unless (derived-mode-p 'gnus-summary-mode) |
16409b0b GM |
12881 | (error "This command can only be used in the summary buffer")) |
12882 | (gnus-summary-show-thread) | |
12883 | (let ((nummove | |
12884 | (cond | |
12885 | ((eq move 'next) 1) | |
12886 | ((eq move 'prev) -1) | |
12887 | (t 0)))) | |
12888 | (if (zerop nummove) | |
12889 | (setq n 1) | |
12890 | (when (< n 0) | |
12891 | (setq n (abs n) | |
12892 | nummove (* -1 nummove)))) | |
12893 | (while (and (> n 0) | |
12894 | (gnus-summary-mark-article nil mark) | |
12895 | (zerop (gnus-summary-next-subject nummove unread t))) | |
12896 | (setq n (1- n))) | |
12897 | (when (/= 0 n) | |
12898 | (gnus-message 7 "No more %sarticles" (if mark "" "unread "))) | |
12899 | (gnus-summary-recenter) | |
12900 | (gnus-summary-position-point) | |
12901 | (gnus-set-mode-line 'summary) | |
12902 | n)) | |
12903 | ||
23f87bed MB |
12904 | (defun gnus-summary-insert-articles (articles) |
12905 | (when (setq articles | |
12906 | (gnus-sorted-difference articles | |
12907 | (mapcar (lambda (h) | |
12908 | (mail-header-number h)) | |
12909 | gnus-newsgroup-headers))) | |
12910 | (setq gnus-newsgroup-headers | |
12911 | (gnus-merge 'list | |
12912 | gnus-newsgroup-headers | |
60ad4779 | 12913 | (gnus-fetch-headers articles nil t) |
23f87bed | 12914 | 'gnus-article-sort-by-number)) |
6ed17f11 AC |
12915 | (setq gnus-newsgroup-articles |
12916 | (gnus-sorted-nunion gnus-newsgroup-articles articles)) | |
23f87bed MB |
12917 | ;; Suppress duplicates? |
12918 | (when gnus-suppress-duplicates | |
12919 | (gnus-dup-suppress-articles)) | |
12920 | ||
01c52d31 MB |
12921 | (if (and gnus-fetch-old-headers |
12922 | (eq gnus-headers-retrieved-by 'nov)) | |
12923 | ;; We might want to build some more threads first. | |
12924 | (if (eq gnus-fetch-old-headers 'invisible) | |
12925 | (gnus-build-all-threads) | |
12926 | (gnus-build-old-threads)) | |
12927 | ;; Mark the inserted articles that are unread as unread. | |
12928 | (setq gnus-newsgroup-unreads | |
12929 | (gnus-sorted-nunion | |
12930 | gnus-newsgroup-unreads | |
12931 | (gnus-sorted-nintersection | |
12932 | (gnus-list-of-unread-articles gnus-newsgroup-name) | |
12933 | articles))) | |
12934 | ;; Mark the inserted articles as selected so that the information | |
12935 | ;; of the marks having been changed by a user may be updated when | |
12936 | ;; exiting this group. See `gnus-summary-update-info'. | |
12937 | (dolist (art articles) | |
12938 | (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected)))) | |
23f87bed MB |
12939 | ;; Let the Gnus agent mark articles as read. |
12940 | (when gnus-agent | |
12941 | (gnus-agent-get-undownloaded-list)) | |
12942 | ;; Remove list identifiers from subject | |
d6cd56f1 | 12943 | (gnus-summary-remove-list-identifiers) |
23f87bed MB |
12944 | ;; First and last article in this newsgroup. |
12945 | (when gnus-newsgroup-headers | |
12946 | (setq gnus-newsgroup-begin | |
12947 | (mail-header-number (car gnus-newsgroup-headers)) | |
12948 | gnus-newsgroup-end | |
12949 | (mail-header-number | |
12950 | (gnus-last-element gnus-newsgroup-headers)))) | |
12951 | (when gnus-use-scoring | |
12952 | (gnus-possibly-score-headers)))) | |
12953 | ||
12954 | (defun gnus-summary-insert-old-articles (&optional all) | |
12955 | "Insert all old articles in this group. | |
12956 | If ALL is non-nil, already read articles become readable. | |
12957 | If ALL is a number, fetch this number of articles." | |
12958 | (interactive "P") | |
12959 | (prog1 | |
12960 | (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<)) | |
12961 | older len) | |
12962 | (setq older | |
12963 | ;; Some nntp servers lie about their active range. When | |
12964 | ;; this happens, the active range can be in the millions. | |
12965 | ;; Use a compressed range to avoid creating a huge list. | |
eaa610c3 KY |
12966 | (gnus-range-difference |
12967 | (gnus-range-difference (list gnus-newsgroup-active) old) | |
12968 | gnus-newsgroup-unexist)) | |
23f87bed MB |
12969 | (setq len (gnus-range-length older)) |
12970 | (cond | |
12971 | ((null older) nil) | |
12972 | ((numberp all) | |
12973 | (if (< all len) | |
12974 | (let ((older-range (nreverse older))) | |
12975 | (setq older nil) | |
12976 | ||
12977 | (while (> all 0) | |
12978 | (let* ((r (pop older-range)) | |
12979 | (min (if (numberp r) r (car r))) | |
12980 | (max (if (numberp r) r (cdr r)))) | |
12981 | (while (and (<= min max) | |
12982 | (> all 0)) | |
12983 | (push max older) | |
12984 | (setq all (1- all) | |
12985 | max (1- max)))))) | |
12986 | (setq older (gnus-uncompress-range older)))) | |
12987 | (all | |
12988 | (setq older (gnus-uncompress-range older))) | |
12989 | (t | |
12990 | (when (and (numberp gnus-large-newsgroup) | |
12991 | (> len gnus-large-newsgroup)) | |
12992 | (let* ((cursor-in-echo-area nil) | |
12993 | (initial (gnus-parameter-large-newsgroup-initial | |
12994 | gnus-newsgroup-name)) | |
12995 | (input | |
12996 | (read-string | |
12997 | (format | |
12998 | "How many articles from %s (%s %d): " | |
01c52d31 | 12999 | (gnus-group-decoded-name gnus-newsgroup-name) |
23f87bed MB |
13000 | (if initial "max" "default") |
13001 | len) | |
d3d42ed7 | 13002 | nil nil |
75a4d9cc LI |
13003 | (and initial |
13004 | (number-to-string initial))))) | |
23f87bed MB |
13005 | (unless (string-match "^[ \t]*$" input) |
13006 | (setq all (string-to-number input)) | |
13007 | (if (< all len) | |
13008 | (let ((older-range (nreverse older))) | |
13009 | (setq older nil) | |
13010 | ||
13011 | (while (> all 0) | |
13012 | (let* ((r (pop older-range)) | |
13013 | (min (if (numberp r) r (car r))) | |
13014 | (max (if (numberp r) r (cdr r)))) | |
13015 | (while (and (<= min max) | |
13016 | (> all 0)) | |
13017 | (push max older) | |
13018 | (setq all (1- all) | |
13019 | max (1- max)))))))))) | |
13020 | (setq older (gnus-uncompress-range older)))) | |
13021 | (if (not older) | |
13022 | (message "No old news.") | |
13023 | (gnus-summary-insert-articles older) | |
13024 | (gnus-summary-limit (gnus-sorted-nunion old older)))) | |
13025 | (gnus-summary-position-point))) | |
13026 | ||
13027 | (defun gnus-summary-insert-new-articles () | |
13028 | "Insert all new articles in this group." | |
13029 | (interactive) | |
93855df9 G |
13030 | (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<)) |
13031 | (old-high gnus-newsgroup-highest) | |
13032 | (nnmail-fetched-sources (list t)) | |
13033 | (new-active (gnus-activate-group gnus-newsgroup-name 'scan)) | |
13034 | i new) | |
13035 | (unless new-active | |
13036 | (error "Couldn't fetch new data")) | |
13037 | (setq gnus-newsgroup-active (gnus-copy-sequence new-active)) | |
13038 | (setq i (cdr gnus-newsgroup-active) | |
13039 | gnus-newsgroup-highest i) | |
13040 | (while (> i old-high) | |
13041 | (push i new) | |
13042 | (decf i)) | |
13043 | (if (not new) | |
13044 | (message "No gnus is bad news") | |
13045 | (gnus-summary-insert-articles new) | |
13046 | (setq gnus-newsgroup-unreads | |
13047 | (gnus-sorted-nunion gnus-newsgroup-unreads new)) | |
13048 | (gnus-summary-limit (gnus-sorted-nunion old new)))) | |
13049 | (gnus-summary-position-point)) | |
23f87bed | 13050 | |
398a825b | 13051 | ;;; Bookmark support for Gnus. |
cf6a9685 | 13052 | (declare-function gnus-article-show-summary "gnus-art" ()) |
e44fa724 KF |
13053 | (declare-function bookmark-make-record-default |
13054 | "bookmark" (&optional no-file no-context posn)) | |
398a825b SM |
13055 | (declare-function bookmark-prop-get "bookmark" (bookmark prop)) |
13056 | (declare-function bookmark-default-handler "bookmark" (bmk)) | |
13057 | (declare-function bookmark-get-bookmark-record "bookmark" (bmk)) | |
8e7d4ca1 | 13058 | (defvar bookmark-yank-point) |
cd24d7a9 | 13059 | (defvar bookmark-current-buffer) |
45be326a TV |
13060 | |
13061 | (defun gnus-summary-bookmark-make-record () | |
398a825b | 13062 | "Make a bookmark entry for a Gnus summary buffer." |
33b48483 KF |
13063 | (let (pos buf) |
13064 | (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current) | |
8f2eaa8a | 13065 | (save-restriction ; FIXME is it necessary to widen? |
33b48483 KF |
13066 | (widen) (setq pos (point))) ; Set position in gnus-article buffer. |
13067 | (setq buf "art") ; We are recording bookmark from article buffer. | |
8f2eaa8a TV |
13068 | (setq bookmark-yank-point (point)) |
13069 | (setq bookmark-current-buffer (current-buffer)) | |
13070 | (gnus-article-show-summary)) ; Go back in summary buffer. | |
33b48483 KF |
13071 | ;; We are now recording bookmark from summary buffer. |
13072 | (unless buf (setq buf "sum")) | |
13073 | (let* ((subject (elt (gnus-summary-article-header) 1)) | |
13074 | (grp (car gnus-article-current)) | |
13075 | (art (cdr gnus-article-current)) | |
13076 | (head (gnus-summary-article-header art)) | |
13077 | (id (mail-header-id head))) | |
13078 | `(,subject | |
e859bbda | 13079 | ,@(condition-case nil |
72897ff9 | 13080 | (bookmark-make-record-default 'no-file 'no-context pos) |
e859bbda KY |
13081 | (wrong-number-of-arguments |
13082 | (bookmark-make-record-default 'point-only))) | |
33b48483 KF |
13083 | (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id)) |
13084 | (group . ,grp) (article . ,art) | |
13085 | (message-id . ,id) (handler . gnus-summary-bookmark-jump))))) | |
45be326a | 13086 | |
398a825b | 13087 | ;;;###autoload |
45be326a TV |
13088 | (defun gnus-summary-bookmark-jump (bookmark) |
13089 | "Handler function for record returned by `gnus-summary-bookmark-make-record'. | |
13090 | BOOKMARK is a bookmark name or a bookmark record." | |
13091 | (let ((group (bookmark-prop-get bookmark 'group)) | |
13092 | (article (bookmark-prop-get bookmark 'article)) | |
33b48483 KF |
13093 | (id (bookmark-prop-get bookmark 'message-id)) |
13094 | (buf (car (split-string (bookmark-prop-get bookmark 'location))))) | |
45be326a TV |
13095 | (gnus-fetch-group group (list article)) |
13096 | (gnus-summary-insert-cached-articles) | |
13097 | (gnus-summary-goto-article id nil 'force) | |
33b48483 KF |
13098 | ;; FIXME we have to wait article buffer is ready (only large buffer) |
13099 | ;; Is there a better solution to know that? | |
13100 | ;; If we don't wait `bookmark-default-handler' will have no chance | |
13101 | ;; to set position. However there is no error, just wrong pos. | |
13102 | (sit-for 1) | |
13103 | (when (string= buf "Gnus-art") | |
13104 | (other-window 1)) | |
45be326a | 13105 | (bookmark-default-handler |
398a825b SM |
13106 | `("" |
13107 | (buffer . ,(current-buffer)) | |
13108 | . ,(bookmark-get-bookmark-record bookmark))))) | |
45be326a | 13109 | |
16409b0b GM |
13110 | (gnus-summary-make-all-marking-commands) |
13111 | ||
a8151ef7 LMI |
13112 | (gnus-ems-redefine) |
13113 | ||
eec82323 LMI |
13114 | (provide 'gnus-sum) |
13115 | ||
13116 | (run-hooks 'gnus-sum-load-hook) | |
13117 | ||
23f87bed | 13118 | ;; Local Variables: |
c38e0c97 | 13119 | ;; coding: utf-8 |
23f87bed MB |
13120 | ;; End: |
13121 | ||
eec82323 | 13122 | ;;; gnus-sum.el ends here |