1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
36 (eval-when-compile (require 'cl))
38 ;; Site dependent variables. These variables should be defined in
41 (defvar gnus-default-nntp-server nil
42 "Specify a default NNTP server.
43 This variable should be defined in paths.el, and should never be set
45 If you want to change servers, you should use `gnus-select-method'.
46 See the documentation to that variable.")
48 (defvar gnus-backup-default-subscribed-newsgroups
49 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
50 "Default default new newsgroups the first time Gnus is run.
51 Should be set in paths.el, and shouldn't be touched by the user.")
53 (defvar gnus-local-domain nil
54 "Local domain name without a host name.
55 The DOMAINNAME environment variable is used instead if it is defined.
56 If the `system-name' function returns the full Internet name, there is
57 no need to set this variable.")
59 (defvar gnus-local-organization nil
60 "String with a description of what organization (if any) the user belongs to.
61 The ORGANIZATION environment variable is used instead if it is defined.
62 If this variable contains a function, this function will be called
63 with the current newsgroup name as the argument. The function should
66 In any case, if the string (either in the variable, in the environment
67 variable, or returned by the function) is a file name, the contents of
68 this file will be used as the organization.")
70 ;; Customization variables
72 ;; Don't touch this variable.
73 (defvar gnus-nntp-service "nntp"
74 "*NNTP service name (\"nntp\" or 119).
75 This is an obsolete variable, which is scarcely used. If you use an
76 nntp server for your newsgroup and want to change the port number
77 used to 899, you would say something along these lines:
79 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
81 (defvar gnus-nntpserver-file "/etc/nntpserver"
82 "*A file with only the name of the nntp server in it.")
84 ;; This function is used to check both the environment variable
85 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
86 ;; an nntp server name default.
87 (defun gnus-getenv-nntpserver ()
88 (or (getenv "NNTPSERVER")
89 (and (file-readable-p gnus-nntpserver-file)
91 (set-buffer (get-buffer-create " *gnus nntp*"))
92 (buffer-disable-undo (current-buffer))
93 (insert-file-contents gnus-nntpserver-file)
94 (let ((name (buffer-string)))
96 (if (string-match "^[ \t\n]*$" name)
99 (kill-buffer (current-buffer))))))))
101 (defvar gnus-select-method
103 (list 'nntp (or (condition-case ()
104 (gnus-getenv-nntpserver)
106 (if (and gnus-default-nntp-server
107 (not (string= gnus-default-nntp-server "")))
108 gnus-default-nntp-server)
110 (if (or (null gnus-nntp-service)
111 (equal gnus-nntp-service "nntp"))
113 (list gnus-nntp-service)))
114 "*Default method for selecting a newsgroup.
115 This variable should be a list, where the first element is how the
116 news is to be fetched, the second is the address.
118 For instance, if you want to get your news via NNTP from
119 \"flab.flab.edu\", you could say:
121 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
123 If you want to use your local spool, say:
125 (setq gnus-select-method (list 'nnspool (system-name)))
127 If you use this variable, you must set `gnus-nntp-server' to nil.
129 There is a lot more to know about select methods and virtual servers -
130 see the manual for details.")
132 (defvar gnus-message-archive-method
133 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
134 (nnfolder-active-file "~/Mail/archive/active")
135 (nnfolder-get-new-mail nil)
136 (nnfolder-inhibit-expiry t))
137 "*Method used for archiving messages you've sent.
138 This should be a mail method.")
140 (defvar gnus-refer-article-method nil
141 "*Preferred method for fetching an article by Message-ID.
142 If you are reading news from the local spool (with nnspool), fetching
143 articles by Message-ID is painfully slow. By setting this method to an
144 nntp method, you might get acceptable results.
146 The value of this variable must be a valid select method as discussed
147 in the documentation of `gnus-select-method'.")
149 (defvar gnus-secondary-select-methods nil
150 "*A list of secondary methods that will be used for reading news.
151 This is a list where each element is a complete select method (see
152 `gnus-select-method').
154 If, for instance, you want to read your mail with the nnml backend,
155 you could set this variable:
157 (setq gnus-secondary-select-methods '((nnml \"\")))")
159 (defvar gnus-secondary-servers nil
160 "*List of NNTP servers that the user can choose between interactively.
161 To make Gnus query you for a server, you have to give `gnus' a
162 non-numeric prefix - `C-u M-x gnus', in short.")
164 (defvar gnus-nntp-server nil
165 "*The name of the host running the NNTP server.
166 This variable is semi-obsolete. Use the `gnus-select-method'
169 (defvar gnus-startup-file "~/.newsrc"
170 "*Your `.newsrc' file.
171 `.newsrc-SERVER' will be used instead if that exists.")
173 (defvar gnus-init-file "~/.gnus"
174 "*Your Gnus elisp startup file.
175 If a file with the .el or .elc suffixes exist, it will be read
178 (defvar gnus-group-faq-directory
179 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
180 "/ftp@sunsite.auc.dk:/pub/usenet/"
181 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
182 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
183 "/ftp@rtfm.mit.edu:/pub/usenet/"
184 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
185 "/ftp@ftp.sunet.se:/pub/usenet/"
186 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
187 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
188 "/ftp@ftp.hk.super.net:/mirror/faqs/")
189 "*Directory where the group FAQs are stored.
190 This will most commonly be on a remote machine, and the file will be
193 This variable can also be a list of directories. In that case, the
194 first element in the list will be used by default, and the others will
195 be used as backup sites.
197 Note that Gnus uses an aol machine as the default directory. If this
198 feels fundamentally unclean, just think of it as a way to finally get
199 something of value back from them.
201 If the default site is too slow, try one of these:
203 North America: mirrors.aol.com /pub/rtfm/usenet
204 ftp.seas.gwu.edu /pub/rtfm
205 rtfm.mit.edu /pub/usenet
206 Europe: ftp.uni-paderborn.de /pub/FAQ
207 src.doc.ic.ac.uk /usenet/news-FAQS
208 ftp.sunet.se /pub/usenet
209 sunsite.auc.dk /pub/usenet
210 Asia: nctuccca.edu.tw /USENET/FAQ
211 hwarang.postech.ac.kr /pub/usenet
212 ftp.hk.super.net /mirror/faqs")
214 (defvar gnus-group-archive-directory
215 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
216 "*The address of the (ding) archives.")
218 (defvar gnus-group-recent-archive-directory
219 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
220 "*The address of the most recent (ding) articles.")
222 (defvar gnus-default-subscribed-newsgroups nil
223 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
224 It should be a list of strings.
225 If it is `t', Gnus will not do anything special the first time it is
226 started; it'll just use the normal newsgroups subscription methods.")
228 (defvar gnus-use-cross-reference t
229 "*Non-nil means that cross referenced articles will be marked as read.
230 If nil, ignore cross references. If t, mark articles as read in
231 subscribed newsgroups. If neither t nor nil, mark as read in all
234 (defvar gnus-single-article-buffer t
235 "*If non-nil, display all articles in the same buffer.
236 If nil, each group will get its own article buffer.")
238 (defvar gnus-use-dribble-file t
239 "*Non-nil means that Gnus will use a dribble file to store user updates.
240 If Emacs should crash without saving the .newsrc files, complete
241 information can be restored from the dribble file.")
243 (defvar gnus-dribble-directory nil
244 "*The directory where dribble files will be saved.
245 If this variable is nil, the directory where the .newsrc files are
246 saved will be used.")
248 (defvar gnus-asynchronous nil
249 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
251 (defvar gnus-kill-summary-on-exit t
252 "*If non-nil, kill the summary buffer when you exit from it.
253 If nil, the summary will become a \"*Dead Summary*\" buffer, and
254 it will be killed sometime later.")
256 (defvar gnus-large-newsgroup 200
257 "*The number of articles which indicates a large newsgroup.
258 If the number of articles in a newsgroup is greater than this value,
259 confirmation is required for selecting the newsgroup.")
261 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
262 (defvar gnus-no-groups-message "No news is horrible news"
263 "*Message displayed by Gnus when no groups are available.")
265 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
266 "*Non-nil means that the default name of a file to save articles in is the group name.
267 If it's nil, the directory form of the group name is used instead.
269 If this variable is a list, and the list contains the element
270 `not-score', long file names will not be used for score files; if it
271 contains the element `not-save', long file names will not be used for
272 saving; and if it contains the element `not-kill', long file names
273 will not be used for kill files.")
275 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
276 "*Name of the directory articles will be saved in (default \"~/News\").
277 Initialized from the SAVEDIR environment variable.")
279 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
280 "*Name of the directory where kill files will be stored (default \"~/News\").
281 Initialized from the SAVEDIR environment variable.")
283 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
284 "*A function to save articles in your favorite format.
285 The function must be interactively callable (in other words, it must
286 be an Emacs command).
288 Gnus provides the following functions:
290 * gnus-summary-save-in-rmail (Rmail format)
291 * gnus-summary-save-in-mail (Unix mail format)
292 * gnus-summary-save-in-folder (MH folder)
293 * gnus-summary-save-in-file (article format).
294 * gnus-summary-save-in-vm (use VM's folder format).")
296 (defvar gnus-prompt-before-saving 'always
297 "*This variable says how much prompting is to be done when saving articles.
298 If it is nil, no prompting will be done, and the articles will be
299 saved to the default files. If this variable is `always', each and
300 every article that is saved will be preceded by a prompt, even when
301 saving large batches of articles. If this variable is neither nil not
302 `always', there the user will be prompted once for a file name for
303 each invocation of the saving commands.")
305 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
306 "*A function generating a file name to save articles in Rmail format.
307 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
309 (defvar gnus-mail-save-name (function gnus-plain-save-name)
310 "*A function generating a file name to save articles in Unix mail format.
311 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
313 (defvar gnus-folder-save-name (function gnus-folder-save-name)
314 "*A function generating a file name to save articles in MH folder.
315 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
317 (defvar gnus-file-save-name (function gnus-numeric-save-name)
318 "*A function generating a file name to save articles in article format.
319 The function is called with NEWSGROUP, HEADERS, and optional
322 (defvar gnus-split-methods
323 '((gnus-article-archive-name))
324 "*Variable used to suggest where articles are to be saved.
325 For instance, if you would like to save articles related to Gnus in
326 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
327 you could set this variable to something like:
329 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
330 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
332 This variable is an alist where the where the key is the match and the
333 value is a list of possible files to save in if the match is non-nil.
335 If the match is a string, it is used as a regexp match on the
336 article. If the match is a symbol, that symbol will be funcalled
337 from the buffer of the article to be saved with the newsgroup as the
338 parameter. If it is a list, it will be evaled in the same buffer.
340 If this form or function returns a string, this string will be used as
341 a possible file name; and if it returns a non-nil list, that list will
342 be used as possible file names.")
344 (defvar gnus-move-split-methods nil
345 "*Variable used to suggest where articles are to be moved to.
346 It uses the same syntax as the `gnus-split-methods' variable.")
348 (defvar gnus-save-score nil
349 "*If non-nil, save group scoring info.")
351 (defvar gnus-use-adaptive-scoring nil
352 "*If non-nil, use some adaptive scoring scheme.")
354 (defvar gnus-use-cache nil
355 "*If nil, Gnus will ignore the article cache.
356 If `passive', it will allow entering (and reading) articles
357 explicitly entered into the cache. If anything else, use the
358 cache to the full extent of the law.")
360 (defvar gnus-use-trees nil
361 "*If non-nil, display a thread tree buffer.")
363 (defvar gnus-use-grouplens nil
364 "*If non-nil, use GroupLens ratings.")
366 (defvar gnus-keep-backlog nil
367 "*If non-nil, Gnus will keep read articles for later re-retrieval.
368 If it is a number N, then Gnus will only keep the last N articles
369 read. If it is neither nil nor a number, Gnus will keep all read
370 articles. This is not a good idea.")
372 (defvar gnus-use-nocem nil
373 "*If non-nil, Gnus will read NoCeM cancel messages.")
375 (defvar gnus-use-demon nil
376 "If non-nil, Gnus might use some demons.")
378 (defvar gnus-use-scoring t
379 "*If non-nil, enable scoring.")
381 (defvar gnus-use-picons nil
382 "*If non-nil, display picons.")
384 (defvar gnus-fetch-old-headers nil
385 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
386 If an unread article in the group refers to an older, already read (or
387 just marked as read) article, the old article will not normally be
388 displayed in the Summary buffer. If this variable is non-nil, Gnus
389 will attempt to grab the headers to the old articles, and thereby
390 build complete threads. If it has the value `some', only enough
391 headers to connect otherwise loose threads will be displayed.
392 This variable can also be a number. In that case, no more than that
393 number of old headers will be fetched.
395 The server has to support NOV for any of this to work.")
398 ;(defvar gnus-visual t
399 ; "*If non-nil, will do various highlighting.
400 ;If nil, no mouse highlights (or any other highlights) will be
401 ;performed. This might speed up Gnus some when generating large group
402 ;and summary buffers.")
404 (defvar gnus-novice-user t
405 "*Non-nil means that you are a usenet novice.
406 If non-nil, verbose messages may be displayed and confirmations may be
409 (defvar gnus-expert-user nil
410 "*Non-nil means that you will never be asked for confirmation about anything.
411 And that means *anything*.")
413 (defvar gnus-verbose 7
414 "*Integer that says how verbose Gnus should be.
415 The higher the number, the more messages Gnus will flash to say what
416 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
417 display most important messages; and at ten, Gnus will keep on
418 jabbering all the time.")
420 (defvar gnus-keep-same-level nil
421 "*Non-nil means that the next newsgroup after the current will be on the same level.
422 When you type, for instance, `n' after reading the last article in the
423 current newsgroup, you will go to the next newsgroup. If this variable
424 is nil, the next newsgroup will be the next from the group
426 If this variable is non-nil, Gnus will either put you in the
427 next newsgroup with the same level, or, if no such newsgroup is
428 available, the next newsgroup with the lowest possible level higher
429 than the current level.
430 If this variable is `best', Gnus will make the next newsgroup the one
431 with the best level.")
433 (defvar gnus-summary-make-false-root 'adopt
434 "*nil means that Gnus won't gather loose threads.
435 If the root of a thread has expired or been read in a previous
436 session, the information necessary to build a complete thread has been
437 lost. Instead of having many small sub-threads from this original thread
438 scattered all over the summary buffer, Gnus can gather them.
440 If non-nil, Gnus will try to gather all loose sub-threads from an
441 original thread into one large thread.
443 If this variable is non-nil, it should be one of `none', `adopt',
446 If this variable is `none', Gnus will not make a false root, but just
447 present the sub-threads after another.
448 If this variable is `dummy', Gnus will create a dummy root that will
449 have all the sub-threads as children.
450 If this variable is `adopt', Gnus will make one of the \"children\"
451 the parent and mark all the step-children as such.
452 If this variable is `empty', the \"children\" are printed with empty
453 subject fields. (Or rather, they will be printed with a string
454 given by the `gnus-summary-same-subject' variable.)")
456 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
457 "*A regexp to match subjects to be excluded from loose thread gathering.
458 As loose thread gathering is done on subjects only, that means that
459 there can be many false gatherings performed. By rooting out certain
460 common subjects, gathering might become saner.")
462 (defvar gnus-summary-gather-subject-limit nil
463 "*Maximum length of subject comparisons when gathering loose threads.
464 Use nil to compare full subjects. Setting this variable to a low
465 number will help gather threads that have been corrupted by
466 newsreaders chopping off subject lines, but it might also mean that
467 unrelated articles that have subject that happen to begin with the
468 same few characters will be incorrectly gathered.
470 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
471 comparing subjects.")
473 (defvar gnus-simplify-ignored-prefixes nil
474 "*Regexp, matches for which are removed from subject lines when simplifying.")
476 (defvar gnus-build-sparse-threads nil
477 "*If non-nil, fill in the gaps in threads.
478 If `some', only fill in the gaps that are needed to tie loose threads
479 together. If `more', fill in all leaf nodes that Gnus can find. If
480 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
482 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
483 "Function used for gathering loose threads.
484 There are two pre-defined functions: `gnus-gather-threads-by-subject',
485 which only takes Subjects into consideration; and
486 `gnus-gather-threads-by-references', which compared the References
487 headers of the articles to find matches.")
489 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
490 (defvar gnus-summary-same-subject ""
491 "*String indicating that the current article has the same subject as the previous.
492 This variable will only be used if the value of
493 `gnus-summary-make-false-root' is `empty'.")
495 (defvar gnus-summary-goto-unread t
496 "*If non-nil, marking commands will go to the next unread article.
497 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
498 whether it is read or not.")
500 (defvar gnus-group-goto-unread t
501 "*If non-nil, movement commands will go to the next unread and subscribed group.")
503 (defvar gnus-goto-next-group-when-activating t
504 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
506 (defvar gnus-check-new-newsgroups t
507 "*Non-nil means that Gnus will add new newsgroups at startup.
508 If this variable is `ask-server', Gnus will ask the server for new
509 groups since the last time it checked. This means that the killed list
510 is no longer necessary, so you could set `gnus-save-killed-list' to
513 A variant is to have this variable be a list of select methods. Gnus
514 will then use the `ask-server' method on all these select methods to
515 query for new groups from all those servers.
518 (setq gnus-check-new-newsgroups
519 '((nntp \"some.server\") (nntp \"other.server\")))
521 If this variable is nil, then you have to tell Gnus explicitly to
522 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
524 (defvar gnus-check-bogus-newsgroups nil
525 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
526 If this variable is nil, then you have to tell Gnus explicitly to
527 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
529 (defvar gnus-read-active-file t
530 "*Non-nil means that Gnus will read the entire active file at startup.
531 If this variable is nil, Gnus will only know about the groups in your
534 If this variable is `some', Gnus will try to only read the relevant
535 parts of the active file from the server. Not all servers support
536 this, and it might be quite slow with other servers, but this should
537 generally be faster than both the t and nil value.
539 If you set this variable to nil or `some', you probably still want to
540 be told about new newsgroups that arrive. To do that, set
541 `gnus-check-new-newsgroups' to `ask-server'. This may not work
542 properly with all servers.")
544 (defvar gnus-level-subscribed 5
545 "*Groups with levels less than or equal to this variable are subscribed.")
547 (defvar gnus-level-unsubscribed 7
548 "*Groups with levels less than or equal to this variable are unsubscribed.
549 Groups with levels less than `gnus-level-subscribed', which should be
550 less than this variable, are subscribed.")
552 (defvar gnus-level-zombie 8
553 "*Groups with this level are zombie groups.")
555 (defvar gnus-level-killed 9
556 "*Groups with this level are killed.")
558 (defvar gnus-level-default-subscribed 3
559 "*New subscribed groups will be subscribed at this level.")
561 (defvar gnus-level-default-unsubscribed 6
562 "*New unsubscribed groups will be unsubscribed at this level.")
564 (defvar gnus-activate-level (1+ gnus-level-subscribed)
565 "*Groups higher than this level won't be activated on startup.
566 Setting this variable to something log might save lots of time when
567 you have many groups that you aren't interested in.")
569 (defvar gnus-activate-foreign-newsgroups 4
570 "*If nil, Gnus will not check foreign newsgroups at startup.
571 If it is non-nil, it should be a number between one and nine. Foreign
572 newsgroups that have a level lower or equal to this number will be
573 activated on startup. For instance, if you want to active all
574 subscribed newsgroups, but not the rest, you'd set this variable to
575 `gnus-level-subscribed'.
577 If you subscribe to lots of newsgroups from different servers, startup
578 might take a while. By setting this variable to nil, you'll save time,
579 but you won't be told how many unread articles there are in the
582 (defvar gnus-save-newsrc-file t
583 "*Non-nil means that Gnus will save the `.newsrc' file.
584 Gnus always saves its own startup file, which is called
585 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
586 be readily understood by other newsreaders. If you don't plan on
587 using other newsreaders, set this variable to nil to save some time on
590 (defvar gnus-save-killed-list t
591 "*If non-nil, save the list of killed groups to the startup file.
592 If you set this variable to nil, you'll save both time (when starting
593 and quitting) and space (both memory and disk), but it will also mean
594 that Gnus has no record of which groups are new and which are old, so
595 the automatic new newsgroups subscription methods become meaningless.
597 You should always set `gnus-check-new-newsgroups' to `ask-server' or
598 nil if you set this variable to nil.")
600 (defvar gnus-interactive-catchup t
601 "*If non-nil, require your confirmation when catching up a group.")
603 (defvar gnus-interactive-post t
604 "*If non-nil, group name will be asked for when posting.")
606 (defvar gnus-interactive-exit t
607 "*If non-nil, require your confirmation when exiting Gnus.")
609 (defvar gnus-kill-killed t
610 "*If non-nil, Gnus will apply kill files to already killed articles.
611 If it is nil, Gnus will never apply kill files to articles that have
612 already been through the scoring process, which might very well save lots
615 (defvar gnus-extract-address-components 'gnus-extract-address-components
616 "*Function for extracting address components from a From header.
617 Two pre-defined function exist: `gnus-extract-address-components',
618 which is the default, quite fast, and too simplistic solution, and
619 `mail-extract-address-components', which works much better, but is
622 (defvar gnus-summary-default-score 0
623 "*Default article score level.
624 If this variable is nil, scoring will be disabled.")
626 (defvar gnus-summary-zcore-fuzz 0
627 "*Fuzziness factor for the zcore in the summary buffer.
628 Articles with scores closer than this to `gnus-summary-default-score'
629 will not be marked.")
631 (defvar gnus-simplify-subject-fuzzy-regexp nil
632 "*Strings to be removed when doing fuzzy matches.
633 This can either be a regular expression or list of regular expressions
634 that will be removed from subject strings if fuzzy subject
635 simplification is selected.")
637 (defvar gnus-permanently-visible-groups nil
638 "*Regexp to match groups that should always be listed in the group buffer.
639 This means that they will still be listed when there are no unread
640 articles in the groups.")
642 (defvar gnus-list-groups-with-ticked-articles t
643 "*If non-nil, list groups that have only ticked articles.
644 If nil, only list groups that have unread articles.")
646 (defvar gnus-group-default-list-level gnus-level-subscribed
647 "*Default listing level.
648 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
650 (defvar gnus-group-use-permanent-levels nil
651 "*If non-nil, once you set a level, Gnus will use this level.")
653 (defvar gnus-group-list-inactive-groups t
654 "*If non-nil, inactive groups will be listed.")
656 (defvar gnus-show-mime nil
657 "*If non-nil, do mime processing of articles.
658 The articles will simply be fed to the function given by
659 `gnus-show-mime-method'.")
661 (defvar gnus-strict-mime t
662 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
664 (defvar gnus-show-mime-method 'metamail-buffer
665 "*Function to process a MIME message.
666 The function is called from the article buffer.")
668 (defvar gnus-decode-encoded-word-method (lambda ())
669 "*Function to decode a MIME encoded-words.
670 The function is called from the article buffer.")
672 (defvar gnus-show-threads t
673 "*If non-nil, display threads in summary mode.")
675 (defvar gnus-thread-hide-subtree nil
676 "*If non-nil, hide all threads initially.
677 If threads are hidden, you have to run the command
678 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
679 to expose hidden threads.")
681 (defvar gnus-thread-hide-killed t
682 "*If non-nil, hide killed threads automatically.")
684 (defvar gnus-thread-ignore-subject nil
685 "*If non-nil, ignore subjects and do all threading based on the Reference header.
686 If nil, which is the default, articles that have different subjects
687 from their parents will start separate threads.")
689 (defvar gnus-thread-operation-ignore-subject t
690 "*If non-nil, subjects will be ignored when doing thread commands.
691 This affects commands like `gnus-summary-kill-thread' and
692 `gnus-summary-lower-thread'.
694 If this variable is nil, articles in the same thread with different
695 subjects will not be included in the operation in question. If this
696 variable is `fuzzy', only articles that have subjects that are fuzzily
697 equal will be included.")
699 (defvar gnus-thread-indent-level 4
700 "*Number that says how much each sub-thread should be indented.")
702 (defvar gnus-ignored-newsgroups
703 (purecopy (mapconcat 'identity
704 '("^to\\." ; not "real" groups
705 "^[0-9. \t]+ " ; all digits in name
706 "[][\"#'()]" ; bogus characters
709 "*A regexp to match uninteresting newsgroups in the active file.
710 Any lines in the active file matching this regular expression are
711 removed from the newsgroup list before anything else is done to it,
712 thus making them effectively non-existent.")
714 (defvar gnus-ignored-headers
715 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
716 "*All headers that match this regexp will be hidden.
717 This variable can also be a list of regexps of headers to be ignored.
718 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
720 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-"
721 "*All headers that do not match this regexp will be hidden.
722 This variable can also be a list of regexp of headers to remain visible.
723 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
725 (defvar gnus-sorted-header-list
726 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
727 "^Cc:" "^Date:" "^Organization:")
728 "*This variable is a list of regular expressions.
729 If it is non-nil, headers that match the regular expressions will
730 be placed first in the article buffer in the sequence specified by
733 (defvar gnus-boring-article-headers
734 '(empty followup-to reply-to)
735 "*Headers that are only to be displayed if they have interesting data.
736 Possible values in this list are `empty', `newsgroups', `followup-to',
737 `reply-to', and `date'.")
739 (defvar gnus-show-all-headers nil
740 "*If non-nil, don't hide any headers.")
742 (defvar gnus-save-all-headers t
743 "*If non-nil, don't remove any headers before saving.")
745 (defvar gnus-saved-headers gnus-visible-headers
746 "*Headers to keep if `gnus-save-all-headers' is nil.
747 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
748 If that variable is nil, however, all headers that match this regexp
749 will be kept while the rest will be deleted before saving.")
751 (defvar gnus-inhibit-startup-message nil
752 "*If non-nil, the startup message will not be displayed.")
754 (defvar gnus-signature-separator "^-- *$"
755 "Regexp matching signature separator.")
757 (defvar gnus-signature-limit nil
758 "Provide a limit to what is considered a signature.
759 If it is a number, no signature may not be longer (in characters) than
760 that number. If it is a function, the function will be called without
761 any parameters, and if it returns nil, there is no signature in the
762 buffer. If it is a string, it will be used as a regexp. If it
763 matches, the text in question is not a signature.")
765 (defvar gnus-auto-extend-newsgroup t
766 "*If non-nil, extend newsgroup forward and backward when requested.")
768 (defvar gnus-auto-select-first t
769 "*If nil, don't select the first unread article when entering a group.
770 If this variable is `best', select the highest-scored unread article
771 in the group. If neither nil nor `best', select the first unread
774 If you want to prevent automatic selection of the first unread article
775 in some newsgroups, set the variable to nil in
776 `gnus-select-group-hook'.")
778 (defvar gnus-auto-select-next t
779 "*If non-nil, offer to go to the next group from the end of the previous.
780 If the value is t and the next newsgroup is empty, Gnus will exit
781 summary mode and go back to group mode. If the value is neither nil
782 nor t, Gnus will select the following unread newsgroup. In
783 particular, if the value is the symbol `quietly', the next unread
784 newsgroup will be selected without any confirmation, and if it is
785 `almost-quietly', the next group will be selected without any
786 confirmation if you are located on the last article in the group.
787 Finally, if this variable is `slightly-quietly', the `Z n' command
788 will go to the next group without confirmation.")
790 (defvar gnus-auto-select-same nil
791 "*If non-nil, select the next article with the same subject.")
793 (defvar gnus-summary-check-current nil
794 "*If non-nil, consider the current article when moving.
795 The \"unread\" movement commands will stay on the same line if the
796 current article is unread.")
798 (defvar gnus-auto-center-summary t
799 "*If non-nil, always center the current summary buffer.
800 In particular, if `vertical' do only vertical recentering. If non-nil
801 and non-`vertical', do both horizontal and vertical recentering.")
803 (defvar gnus-break-pages t
804 "*If non-nil, do page breaking on articles.
805 The page delimiter is specified by the `gnus-page-delimiter'
808 (defvar gnus-page-delimiter "^\^L"
809 "*Regexp describing what to use as article page delimiters.
810 The default value is \"^\^L\", which is a form linefeed at the
811 beginning of a line.")
813 (defvar gnus-use-full-window t
814 "*If non-nil, use the entire Emacs screen.")
816 (defvar gnus-window-configuration nil
817 "Obsolete variable. See `gnus-buffer-configuration'.")
819 (defvar gnus-window-min-width 2
820 "*Minimum width of Gnus buffers.")
822 (defvar gnus-window-min-height 1
823 "*Minimum height of Gnus buffers.")
825 (defvar gnus-buffer-configuration
829 (if gnus-carpal '(group-carpal 4))))
833 (if gnus-carpal '(summary-carpal 4))))
840 (if gnus-carpal '(summary-carpal 4))
842 (vertical ((height . 5) (width . 15)
844 (left . -1) (top . 1))
854 (if gnus-carpal '(summary-carpal 4))
855 (if gnus-use-trees '(tree 0.25))
860 (if gnus-carpal '(server-carpal 2))))
864 (if gnus-carpal '(browse-carpal 2))))
867 (message 1.0 point)))
870 (article 1.0 point)))
881 (edit-group 1.0 point)))
885 (edit-server 1.0 point)))
889 (edit-score 1.0 point)))
896 (message 1.0 point)))
899 (message 1.0 point)))
902 (message 1.0 point)))
906 (message 1.0 point)))
913 (if gnus-carpal '(summary-carpal 4))
914 ("*Shell Command Output*" 1.0)))
917 ("*Gnus Help Bug*" 0.5)
918 ("*Gnus Bug*" 1.0 point)))
922 (message 1.0 point))))
923 "Window configuration for all possible Gnus buffers.
924 This variable is a list of lists. Each of these lists has a NAME and
925 a RULE. The NAMEs are commonsense names like `group', which names a
926 rule used when displaying the group buffer; `summary', which names a
927 rule for what happens when you enter a group and do not display an
928 article buffer; and so on. See the value of this variable for a
929 complete list of NAMEs.
931 Each RULE is a list of vectors. The first element in this vector is
932 the name of the buffer to be displayed; the second element is the
933 percentage of the screen this buffer is to occupy (a number in the
934 0.0-0.99 range); the optional third element is `point', which should
935 be present to denote which buffer point is to go to after making this
936 buffer configuration.")
938 (defvar gnus-window-to-buffer
939 '((group . gnus-group-buffer)
940 (summary . gnus-summary-buffer)
941 (article . gnus-article-buffer)
942 (server . gnus-server-buffer)
943 (browse . "*Gnus Browse Server*")
944 (edit-group . gnus-group-edit-buffer)
945 (edit-server . gnus-server-edit-buffer)
946 (group-carpal . gnus-carpal-group-buffer)
947 (summary-carpal . gnus-carpal-summary-buffer)
948 (server-carpal . gnus-carpal-server-buffer)
949 (browse-carpal . gnus-carpal-browse-buffer)
950 (edit-score . gnus-score-edit-buffer)
951 (message . gnus-message-buffer)
952 (mail . gnus-message-buffer)
953 (post-news . gnus-message-buffer)
954 (faq . gnus-faq-buffer)
955 (picons . "*Picons*")
956 (tree . gnus-tree-buffer)
957 (info . gnus-info-buffer)
958 (article-copy . gnus-article-copy)
959 (draft . gnus-draft-buffer))
960 "Mapping from short symbols to buffer names or buffer variables.")
962 (defvar gnus-carpal nil
963 "*If non-nil, display clickable icons.")
965 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
966 "*Function called with a group name when new group is detected.
967 A few pre-made functions are supplied: `gnus-subscribe-randomly'
968 inserts new groups at the beginning of the list of groups;
969 `gnus-subscribe-alphabetically' inserts new groups in strict
970 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
971 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
972 for your decision; `gnus-subscribe-killed' kills all new groups.")
974 ;; Suggested by a bug report by Hallvard B Furuseth.
975 ;; <h.b.furuseth@usit.uio.no>.
976 (defvar gnus-subscribe-options-newsgroup-method
977 (function gnus-subscribe-alphabetically)
978 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
979 If, for instance, you want to subscribe to all newsgroups in the
980 \"no\" and \"alt\" hierarchies, you'd put the following in your
983 options -n no.all alt.all
985 Gnus will the subscribe all new newsgroups in these hierarchies with
986 the subscription method in this variable.")
988 (defvar gnus-subscribe-hierarchical-interactive nil
989 "*If non-nil, Gnus will offer to subscribe hierarchically.
990 When a new hierarchy appears, Gnus will ask the user:
992 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
994 If the user pressed `d', Gnus will descend the hierarchy, `y' will
995 subscribe to all newsgroups in the hierarchy and `s' will skip this
996 hierarchy in its entirety.")
998 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
999 "*Function used for sorting the group buffer.
1000 This function will be called with group info entries as the arguments
1001 for the groups to be sorted. Pre-made functions include
1002 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1003 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1004 `gnus-group-sort-by-rank'.
1006 This variable can also be a list of sorting functions. In that case,
1007 the most significant sort function should be the last function in the
1010 ;; Mark variables suggested by Thomas Michanek
1011 ;; <Thomas.Michanek@telelogic.se>.
1012 (defvar gnus-unread-mark ?
1013 "*Mark used for unread articles.")
1014 (defvar gnus-ticked-mark ?!
1015 "*Mark used for ticked articles.")
1016 (defvar gnus-dormant-mark ??
1017 "*Mark used for dormant articles.")
1018 (defvar gnus-del-mark ?r
1019 "*Mark used for del'd articles.")
1020 (defvar gnus-read-mark ?R
1021 "*Mark used for read articles.")
1022 (defvar gnus-expirable-mark ?E
1023 "*Mark used for expirable articles.")
1024 (defvar gnus-killed-mark ?K
1025 "*Mark used for killed articles.")
1026 (defvar gnus-souped-mark ?F
1027 "*Mark used for killed articles.")
1028 (defvar gnus-kill-file-mark ?X
1029 "*Mark used for articles killed by kill files.")
1030 (defvar gnus-low-score-mark ?Y
1031 "*Mark used for articles with a low score.")
1032 (defvar gnus-catchup-mark ?C
1033 "*Mark used for articles that are caught up.")
1034 (defvar gnus-replied-mark ?A
1035 "*Mark used for articles that have been replied to.")
1036 (defvar gnus-cached-mark ?*
1037 "*Mark used for articles that are in the cache.")
1038 (defvar gnus-saved-mark ?S
1039 "*Mark used for articles that have been saved to.")
1040 (defvar gnus-process-mark ?#
1042 (defvar gnus-ancient-mark ?O
1043 "*Mark used for ancient articles.")
1044 (defvar gnus-sparse-mark ?Q
1045 "*Mark used for sparsely reffed articles.")
1046 (defvar gnus-canceled-mark ?G
1047 "*Mark used for canceled articles.")
1048 (defvar gnus-score-over-mark ?+
1049 "*Score mark used for articles with high scores.")
1050 (defvar gnus-score-below-mark ?-
1051 "*Score mark used for articles with low scores.")
1052 (defvar gnus-empty-thread-mark ?
1053 "*There is no thread under the article.")
1054 (defvar gnus-not-empty-thread-mark ?=
1055 "*There is a thread under the article.")
1057 (defvar gnus-view-pseudo-asynchronously nil
1058 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1060 (defvar gnus-view-pseudos nil
1061 "*If `automatic', pseudo-articles will be viewed automatically.
1062 If `not-confirm', pseudos will be viewed automatically, and the user
1063 will not be asked to confirm the command.")
1065 (defvar gnus-view-pseudos-separately t
1066 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1067 If nil, all files that use the same viewing command will be given as a
1068 list of parameters to that command.")
1070 (defvar gnus-insert-pseudo-articles t
1071 "*If non-nil, insert pseudo-articles when decoding articles.")
1073 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1074 "*Format of group lines.
1075 It works along the same lines as a normal formatting string,
1076 with some simple extensions.
1078 %M Only marked articles (character, \"*\" or \" \")
1079 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1080 %L Level of subscribedness (integer)
1081 %N Number of unread articles (integer)
1082 %I Number of dormant articles (integer)
1083 %i Number of ticked and dormant (integer)
1084 %T Number of ticked articles (integer)
1085 %R Number of read articles (integer)
1086 %t Total number of articles (integer)
1087 %y Number of unread, unticked articles (integer)
1088 %G Group name (string)
1089 %g Qualified group name (string)
1090 %D Group description (string)
1091 %s Select method (string)
1092 %o Moderated group (char, \"m\")
1093 %p Process mark (char)
1094 %O Moderated group (string, \"(m)\" or \"\")
1095 %P Topic indentation (string)
1096 %l Whether there are GroupLens predictions for this group (string)
1097 %n Select from where (string)
1098 %z A string that look like `<%s:%n>' if a foreign select method is used
1099 %u User defined specifier. The next character in the format string should
1100 be a letter. Gnus will call the function gnus-user-format-function-X,
1101 where X is the letter following %u. The function will be passed the
1102 current header as argument. The function should return a string, which
1103 will be inserted into the buffer just like information from any other
1106 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1107 the mouse point move inside the area. There can only be one such area.
1109 Note that this format specification is not always respected. For
1110 reasons of efficiency, when listing killed groups, this specification
1111 is ignored altogether. If the spec is changed considerably, your
1112 output may end up looking strange when listing both alive and killed
1115 If you use %o or %O, reading the active file will be slower and quite
1116 a bit of extra memory will be used. %D will also worsen performance.
1117 Also note that if you change the format specification to include any
1118 of these specs, you must probably re-start Gnus to see them go into
1121 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1122 "*The format specification of the lines in the summary buffer.
1124 It works along the same lines as a normal formatting string,
1125 with some simple extensions.
1127 %N Article number, left padded with spaces (string)
1129 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1130 %n Name of the poster (string)
1131 %a Extracted name of the poster (string)
1132 %A Extracted address of the poster (string)
1133 %F Contents of the From: header (string)
1134 %x Contents of the Xref: header (string)
1135 %D Date of the article (string)
1136 %d Date of the article (string) in DD-MMM format
1137 %M Message-id of the article (string)
1138 %r References of the article (string)
1139 %c Number of characters in the article (integer)
1140 %L Number of lines in the article (integer)
1141 %I Indentation based on thread level (a string of spaces)
1142 %T A string with two possible values: 80 spaces if the article
1143 is on thread level two or larger and 0 spaces on level one
1144 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1145 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1146 %[ Opening bracket (character, \"[\" or \"<\")
1147 %] Closing bracket (character, \"]\" or \">\")
1148 %> Spaces of length thread-level (string)
1149 %< Spaces of length (- 20 thread-level) (string)
1150 %i Article score (number)
1151 %z Article zcore (character)
1152 %t Number of articles under the current thread (number).
1153 %e Whether the thread is empty or not (character).
1154 %l GroupLens score (string).
1155 %u User defined specifier. The next character in the format string should
1156 be a letter. Gnus will call the function gnus-user-format-function-X,
1157 where X is the letter following %u. The function will be passed the
1158 current header as argument. The function should return a string, which
1159 will be inserted into the summary just like information from any other
1162 Text between %( and %) will be highlighted with `gnus-mouse-face'
1163 when the mouse point is placed inside the area. There can only be one
1166 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1167 with care. For reasons of efficiency, Gnus will compute what column
1168 these characters will end up in, and \"hard-code\" that. This means that
1169 it is illegal to have these specs after a variable-length spec. Well,
1170 you might not be arrested, but your summary buffer will look strange,
1171 which is bad enough.
1173 The smart choice is to have these specs as for to the left as
1176 This restriction may disappear in later versions of Gnus.")
1178 (defvar gnus-summary-dummy-line-format
1180 "*The format specification for the dummy roots in the summary buffer.
1181 It works along the same lines as a normal formatting string,
1182 with some simple extensions.
1186 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1187 "*The format specification for the summary mode line.
1188 It works along the same lines as a normal formatting string,
1189 with some simple extensions:
1192 %p Unprefixed group name
1193 %A Current article number
1195 %U Number of unread articles in the group
1196 %e Number of unselected articles in the group
1197 %Z A string with unread/unselected article counts
1198 %g Shortish group name
1199 %S Subject of the current article
1200 %u User-defined spec
1201 %s Current score file name
1202 %d Number of dormant articles
1203 %r Number of articles that have been marked as read in this session
1204 %E Number of articles expunged by the score files")
1206 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1207 "*The format specification for the article mode line.
1208 See `gnus-summary-mode-line-format' for a closer description.")
1210 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1211 "*The format specification for the group mode line.
1212 It works along the same lines as a normal formatting string,
1213 with some simple extensions:
1215 %S The native news server.
1216 %M The native select method.")
1218 (defvar gnus-valid-select-methods
1219 '(("nntp" post address prompt-address)
1220 ("nnspool" post address)
1221 ("nnvirtual" post-mail virtual prompt-address)
1222 ("nnmbox" mail respool address)
1223 ("nnml" mail respool address)
1224 ("nnmh" mail respool address)
1225 ("nndir" post-mail prompt-address address)
1226 ("nneething" none address prompt-address)
1227 ("nndoc" none address prompt-address)
1228 ("nnbabyl" mail address respool)
1229 ("nnkiboze" post address virtual)
1230 ("nnsoup" post-mail address)
1231 ("nndraft" post-mail)
1232 ("nnfolder" mail respool address))
1233 "An alist of valid select methods.
1234 The first element of each list lists should be a string with the name
1235 of the select method. The other elements may be be the category of
1236 this method (ie. `post', `mail', `none' or whatever) or other
1237 properties that this method has (like being respoolable).
1238 If you implement a new select method, all you should have to change is
1239 this variable. I think.")
1241 (defvar gnus-updated-mode-lines '(group article summary tree)
1242 "*List of buffers that should update their mode lines.
1243 The list may contain the symbols `group', `article' and `summary'. If
1244 the corresponding symbol is present, Gnus will keep that mode line
1245 updated with information that may be pertinent.
1246 If this variable is nil, screen refresh may be quicker.")
1248 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1249 (defvar gnus-mode-non-string-length nil
1250 "*Max length of mode-line non-string contents.
1251 If this is nil, Gnus will take space as is needed, leaving the rest
1252 of the modeline intact.")
1255 ;(defvar gnus-mouse-face 'highlight
1256 ; "*Face used for mouse highlighting in Gnus.
1257 ;No mouse highlights will be done if `gnus-visual' is nil.")
1259 (defvar gnus-summary-mark-below nil
1260 "*Mark all articles with a score below this variable as read.
1261 This variable is local to each summary buffer and usually set by the
1264 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1265 "*List of functions used for sorting articles in the summary buffer.
1266 This variable is only used when not using a threaded display.")
1268 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1269 "*List of functions used for sorting threads in the summary buffer.
1270 By default, threads are sorted by article number.
1272 Each function takes two threads and return non-nil if the first thread
1273 should be sorted before the other. If you use more than one function,
1274 the primary sort function should be the last. You should probably
1275 always include `gnus-thread-sort-by-number' in the list of sorting
1276 functions -- preferably first.
1278 Ready-mady functions include `gnus-thread-sort-by-number',
1279 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1280 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1281 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1283 (defvar gnus-thread-score-function '+
1284 "*Function used for calculating the total score of a thread.
1286 The function is called with the scores of the article and each
1287 subthread and should then return the score of the thread.
1289 Some functions you can use are `+', `max', or `min'.")
1291 (defvar gnus-summary-expunge-below nil
1292 "All articles that have a score less than this variable will be expunged.")
1294 (defvar gnus-thread-expunge-below nil
1295 "All threads that have a total score less than this variable will be expunged.
1296 See `gnus-thread-score-function' for en explanation of what a
1297 \"thread score\" is.")
1299 (defvar gnus-auto-subscribed-groups
1300 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1301 "*All new groups that match this regexp will be subscribed automatically.
1302 Note that this variable only deals with new groups. It has no effect
1303 whatsoever on old groups.")
1305 (defvar gnus-options-subscribe nil
1306 "*All new groups matching this regexp will be subscribed unconditionally.
1307 Note that this variable deals only with new newsgroups. This variable
1308 does not affect old newsgroups.")
1310 (defvar gnus-options-not-subscribe nil
1311 "*All new groups matching this regexp will be ignored.
1312 Note that this variable deals only with new newsgroups. This variable
1313 does not affect old (already subscribed) newsgroups.")
1315 (defvar gnus-auto-expirable-newsgroups nil
1316 "*Groups in which to automatically mark read articles as expirable.
1317 If non-nil, this should be a regexp that should match all groups in
1318 which to perform auto-expiry. This only makes sense for mail groups.")
1320 (defvar gnus-total-expirable-newsgroups nil
1321 "*Groups in which to perform expiry of all read articles.
1322 Use with extreme caution. All groups that match this regexp will be
1323 expiring - which means that all read articles will be deleted after
1324 (say) one week. (This only goes for mail groups and the like, of
1327 (defvar gnus-group-uncollapsed-levels 1
1328 "Number of group name elements to leave alone when making a short group name.")
1330 (defvar gnus-hidden-properties '(invisible t intangible t)
1331 "Property list to use for hiding text.")
1333 (defvar gnus-modtime-botch nil
1334 "*Non-nil means .newsrc should be deleted prior to save.
1335 Its use is due to the bogus appearance that .newsrc was modified on
1340 (defvar gnus-group-mode-hook nil
1341 "*A hook for Gnus group mode.")
1343 (defvar gnus-summary-mode-hook nil
1344 "*A hook for Gnus summary mode.
1345 This hook is run before any variables are set in the summary buffer.")
1347 (defvar gnus-article-mode-hook nil
1348 "*A hook for Gnus article mode.")
1350 (defvar gnus-summary-prepare-exit-hook nil
1351 "*A hook called when preparing to exit from the summary buffer.
1352 It calls `gnus-summary-expire-articles' by default.")
1353 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1355 (defvar gnus-summary-exit-hook nil
1356 "*A hook called on exit from the summary buffer.")
1358 (defvar gnus-group-catchup-group-hook nil
1359 "*A hook run when catching up a group from the group buffer.")
1361 (defvar gnus-open-server-hook nil
1362 "*A hook called just before opening connection to the news server.")
1364 (defvar gnus-load-hook nil
1365 "*A hook run while Gnus is loaded.")
1367 (defvar gnus-startup-hook nil
1368 "*A hook called at startup.
1369 This hook is called after Gnus is connected to the NNTP server.")
1371 (defvar gnus-get-new-news-hook nil
1372 "*A hook run just before Gnus checks for new news.")
1374 (defvar gnus-after-getting-new-news-hook nil
1375 "*A hook run after Gnus checks for new news.")
1377 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1378 "*A function that is called to generate the group buffer.
1379 The function is called with three arguments: The first is a number;
1380 all group with a level less or equal to that number should be listed,
1381 if the second is non-nil, empty groups should also be displayed. If
1382 the third is non-nil, it is a number. No groups with a level lower
1383 than this number should be displayed.
1385 The only current function implemented is `gnus-group-prepare-flat'.")
1387 (defvar gnus-group-prepare-hook nil
1388 "*A hook called after the group buffer has been generated.
1389 If you want to modify the group buffer, you can use this hook.")
1391 (defvar gnus-summary-prepare-hook nil
1392 "*A hook called after the summary buffer has been generated.
1393 If you want to modify the summary buffer, you can use this hook.")
1395 (defvar gnus-summary-generate-hook nil
1396 "*A hook run just before generating the summary buffer.
1397 This hook is commonly used to customize threading variables and the
1400 (defvar gnus-article-prepare-hook nil
1401 "*A hook called after an article has been prepared in the article buffer.
1402 If you want to run a special decoding program like nkf, use this hook.")
1404 ;(defvar gnus-article-display-hook nil
1405 ; "*A hook called after the article is displayed in the article buffer.
1406 ;The hook is designed to change the contents of the article
1407 ;buffer. Typical functions that this hook may contain are
1408 ;`gnus-article-hide-headers' (hide selected headers),
1409 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1410 ;`gnus-article-hide-signature' (hide signature) and
1411 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1412 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1413 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1414 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1416 (defvar gnus-article-x-face-command
1417 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1418 "String or function to be executed to display an X-Face header.
1419 If it is a string, the command will be executed in a sub-shell
1420 asynchronously. The compressed face will be piped to this command.")
1422 (defvar gnus-article-x-face-too-ugly nil
1423 "Regexp matching posters whose face shouldn't be shown automatically.")
1425 (defvar gnus-select-group-hook nil
1426 "*A hook called when a newsgroup is selected.
1428 If you'd like to simplify subjects like the
1429 `gnus-summary-next-same-subject' command does, you can use the
1432 (setq gnus-select-group-hook
1435 (mapcar (lambda (header)
1436 (mail-header-set-subject
1438 (gnus-simplify-subject
1439 (mail-header-subject header) 're-only)))
1440 gnus-newsgroup-headers))))")
1442 (defvar gnus-select-article-hook nil
1443 "*A hook called when an article is selected.")
1445 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1446 "*A hook called to apply kill files to a group.
1447 This hook is intended to apply a kill file to the selected newsgroup.
1448 The function `gnus-apply-kill-file' is called by default.
1450 Since a general kill file is too heavy to use only for a few
1451 newsgroups, I recommend you to use a lighter hook function. For
1452 example, if you'd like to apply a kill file to articles which contains
1453 a string `rmgroup' in subject in newsgroup `control', you can use the
1456 (setq gnus-apply-kill-hook
1459 (cond ((string-match \"control\" gnus-newsgroup-name)
1460 (gnus-kill \"Subject\" \"rmgroup\")
1461 (gnus-expunge \"X\"))))))")
1463 (defvar gnus-visual-mark-article-hook
1464 (list 'gnus-highlight-selected-summary)
1465 "*Hook run after selecting an article in the summary buffer.
1466 It is meant to be used for highlighting the article in some way. It
1467 is not run if `gnus-visual' is nil.")
1469 (defvar gnus-parse-headers-hook nil
1470 "*A hook called before parsing the headers.")
1471 (add-hook 'gnus-parse-headers-hook 'gnus-headers-decode-quoted-printable)
1473 (defvar gnus-exit-group-hook nil
1474 "*A hook called when exiting (not quitting) summary mode.")
1476 (defvar gnus-suspend-gnus-hook nil
1477 "*A hook called when suspending (not exiting) Gnus.")
1479 (defvar gnus-exit-gnus-hook nil
1480 "*A hook called when exiting Gnus.")
1482 (defvar gnus-after-exiting-gnus-hook nil
1483 "*A hook called after exiting Gnus.")
1485 (defvar gnus-save-newsrc-hook nil
1486 "*A hook called before saving any of the newsrc files.")
1488 (defvar gnus-save-quick-newsrc-hook nil
1489 "*A hook called just before saving the quick newsrc file.
1490 Can be used to turn version control on or off.")
1492 (defvar gnus-save-standard-newsrc-hook nil
1493 "*A hook called just before saving the standard newsrc file.
1494 Can be used to turn version control on or off.")
1496 (defvar gnus-summary-update-hook
1497 (list 'gnus-summary-highlight-line)
1498 "*A hook called when a summary line is changed.
1499 The hook will not be called if `gnus-visual' is nil.
1501 The default function `gnus-summary-highlight-line' will
1502 highlight the line according to the `gnus-summary-highlight'
1505 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1506 "*A hook called when a group line is changed.
1507 The hook will not be called if `gnus-visual' is nil.
1509 The default function `gnus-group-highlight-line' will
1510 highlight the line according to the `gnus-group-highlight'
1513 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1514 "*A hook called when an article is selected for the first time.
1515 The hook is intended to mark an article as read (or unread)
1516 automatically when it is selected.")
1518 (defvar gnus-group-change-level-function nil
1519 "Function run when a group level is changed.
1520 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1522 ;; Remove any hilit infestation.
1523 (add-hook 'gnus-startup-hook
1525 (remove-hook 'gnus-summary-prepare-hook
1526 'hilit-rehighlight-buffer-quietly)
1527 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1528 (setq gnus-mark-article-hook
1529 '(gnus-summary-mark-read-and-unread-as-read))
1530 (remove-hook 'gnus-article-prepare-hook
1531 'hilit-rehighlight-buffer-quietly)))
1534 ;; Internal variables
1536 (defvar gnus-thread-indent-array nil)
1537 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1539 (defvar gnus-newsrc-file-version nil)
1541 (defvar gnus-method-history nil)
1542 ;; Variable holding the user answers to all method prompts.
1544 (defvar gnus-server-alist nil
1545 "List of available servers.")
1547 (defvar gnus-group-indentation-function nil)
1549 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1551 (defvar gnus-goto-missing-group-function nil)
1553 (defvar gnus-override-subscribe-method nil)
1555 (defvar gnus-group-goto-next-group-function nil
1556 "Function to override finding the next group after listing groups.")
1558 (defconst gnus-article-mark-lists
1559 '((marked . tick) (replied . reply)
1560 (expirable . expire) (killed . killed)
1561 (bookmarks . bookmark) (dormant . dormant)
1562 (scored . score) (saved . save)
1566 ;; Avoid highlighting in kill files.
1567 (defvar gnus-summary-inhibit-highlight nil)
1568 (defvar gnus-newsgroup-selected-overlay nil)
1570 (defvar gnus-inhibit-hiding nil)
1571 (defvar gnus-group-indentation "")
1572 (defvar gnus-inhibit-limiting nil)
1573 (defvar gnus-created-frames nil)
1575 (defvar gnus-article-mode-map nil)
1576 (defvar gnus-dribble-buffer nil)
1577 (defvar gnus-headers-retrieved-by nil)
1578 (defvar gnus-article-reply nil)
1579 (defvar gnus-override-method nil)
1580 (defvar gnus-article-check-size nil)
1582 (defvar gnus-current-score-file nil)
1583 (defvar gnus-newsgroup-adaptive-score-file nil)
1584 (defvar gnus-scores-exclude-files nil)
1586 (defvar gnus-opened-servers nil)
1588 (defvar gnus-current-move-group nil)
1590 (defvar gnus-newsgroup-dependencies nil)
1591 (defvar gnus-newsgroup-async nil)
1592 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1594 (defvar gnus-newsgroup-adaptive nil)
1596 (defvar gnus-summary-display-table nil)
1597 (defvar gnus-summary-display-article-function nil)
1599 (defvar gnus-summary-highlight-line-function nil
1600 "Function called after highlighting a summary line.")
1602 (defvar gnus-group-line-format-alist
1603 `((?M gnus-tmp-marked-mark ?c)
1604 (?S gnus-tmp-subscribed ?c)
1605 (?L gnus-tmp-level ?d)
1606 (?N (cond ((eq number t) "*" )
1610 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1611 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1613 (?R gnus-tmp-number-of-read ?s)
1614 (?t gnus-tmp-number-total ?d)
1615 (?y gnus-tmp-number-of-unread ?s)
1616 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1617 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1618 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1619 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1620 (?g gnus-tmp-group ?s)
1621 (?G gnus-tmp-qualified-group ?s)
1622 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1623 (?D gnus-tmp-newsgroup-description ?s)
1624 (?o gnus-tmp-moderated ?c)
1625 (?O gnus-tmp-moderated-string ?s)
1626 (?p gnus-tmp-process-marked ?c)
1627 (?s gnus-tmp-news-server ?s)
1628 (?n gnus-tmp-news-method ?s)
1629 (?P gnus-group-indentation ?s)
1630 (?l gnus-tmp-grouplens ?s)
1631 (?z gnus-tmp-news-method-string ?s)
1632 (?u gnus-tmp-user-defined ?s)))
1634 (defvar gnus-summary-line-format-alist
1635 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1636 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1637 (?s gnus-tmp-subject-or-nil ?s)
1638 (?n gnus-tmp-name ?s)
1639 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1641 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1643 (?F gnus-tmp-from ?s)
1644 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1645 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1646 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1647 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1648 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1649 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1650 (?L gnus-tmp-lines ?d)
1651 (?I gnus-tmp-indentation ?s)
1652 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1653 (?R gnus-tmp-replied ?c)
1654 (?\[ gnus-tmp-opening-bracket ?c)
1655 (?\] gnus-tmp-closing-bracket ?c)
1656 (?\> (make-string gnus-tmp-level ? ) ?s)
1657 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1658 (?i gnus-tmp-score ?d)
1659 (?z gnus-tmp-score-char ?c)
1660 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1661 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1662 (?U gnus-tmp-unread ?c)
1663 (?t (gnus-summary-number-of-articles-in-thread
1664 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1666 (?e (gnus-summary-number-of-articles-in-thread
1667 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1669 (?u gnus-tmp-user-defined ?s))
1670 "An alist of format specifications that can appear in summary lines,
1671 and what variables they correspond with, along with the type of the
1672 variable (string, integer, character, etc).")
1674 (defvar gnus-summary-dummy-line-format-alist
1675 `((?S gnus-tmp-subject ?s)
1676 (?N gnus-tmp-number ?d)
1677 (?u gnus-tmp-user-defined ?s)))
1679 (defvar gnus-summary-mode-line-format-alist
1680 `((?G gnus-tmp-group-name ?s)
1681 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1682 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1683 (?A gnus-tmp-article-number ?d)
1684 (?Z gnus-tmp-unread-and-unselected ?s)
1685 (?V gnus-version ?s)
1686 (?U gnus-tmp-unread ?d)
1687 (?S gnus-tmp-subject ?s)
1688 (?e gnus-tmp-unselected ?d)
1689 (?u gnus-tmp-user-defined ?s)
1690 (?d (length gnus-newsgroup-dormant) ?d)
1691 (?t (length gnus-newsgroup-marked) ?d)
1692 (?r (length gnus-newsgroup-reads) ?d)
1693 (?E gnus-newsgroup-expunged-tally ?d)
1694 (?s (gnus-current-score-file-nondirectory) ?s)))
1696 (defvar gnus-article-mode-line-format-alist
1697 gnus-summary-mode-line-format-alist)
1699 (defvar gnus-group-mode-line-format-alist
1700 `((?S gnus-tmp-news-server ?s)
1701 (?M gnus-tmp-news-method ?s)
1702 (?u gnus-tmp-user-defined ?s)))
1704 (defvar gnus-have-read-active-file nil)
1706 (defconst gnus-maintainer
1707 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1708 "The mail address of the Gnus maintainers.")
1710 (defconst gnus-version "September Gnus v0.78"
1711 "Version number for this version of Gnus.")
1713 (defvar gnus-info-nodes
1714 '((gnus-group-mode "(gnus)The Group Buffer")
1715 (gnus-summary-mode "(gnus)The Summary Buffer")
1716 (gnus-article-mode "(gnus)The Article Buffer"))
1717 "Assoc list of major modes and related Info nodes.")
1719 (defvar gnus-group-buffer "*Group*")
1720 (defvar gnus-summary-buffer "*Summary*")
1721 (defvar gnus-article-buffer "*Article*")
1722 (defvar gnus-server-buffer "*Server*")
1724 (defvar gnus-work-buffer " *gnus work*")
1726 (defvar gnus-original-article-buffer " *Original Article*")
1727 (defvar gnus-original-article nil)
1729 (defvar gnus-buffer-list nil
1730 "Gnus buffers that should be killed on exit.")
1732 (defvar gnus-slave nil
1733 "Whether this Gnus is a slave or not.")
1735 (defvar gnus-variable-list
1736 '(gnus-newsrc-options gnus-newsrc-options-n
1737 gnus-newsrc-last-checked-date
1738 gnus-newsrc-alist gnus-server-alist
1739 gnus-killed-list gnus-zombie-list
1740 gnus-topic-topology gnus-topic-alist
1742 "Gnus variables saved in the quick startup file.")
1744 (defvar gnus-newsrc-options nil
1745 "Options line in the .newsrc file.")
1747 (defvar gnus-newsrc-options-n nil
1748 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1750 (defvar gnus-newsrc-last-checked-date nil
1751 "Date Gnus last asked server for new newsgroups.")
1753 (defvar gnus-topic-topology nil
1754 "The complete topic hierarchy.")
1756 (defvar gnus-topic-alist nil
1757 "The complete topic-group alist.")
1759 (defvar gnus-newsrc-alist nil
1760 "Assoc list of read articles.
1761 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1763 (defvar gnus-newsrc-hashtb nil
1764 "Hashtable of gnus-newsrc-alist.")
1766 (defvar gnus-killed-list nil
1767 "List of killed newsgroups.")
1769 (defvar gnus-killed-hashtb nil
1770 "Hash table equivalent of gnus-killed-list.")
1772 (defvar gnus-zombie-list nil
1773 "List of almost dead newsgroups.")
1775 (defvar gnus-description-hashtb nil
1776 "Descriptions of newsgroups.")
1778 (defvar gnus-list-of-killed-groups nil
1779 "List of newsgroups that have recently been killed by the user.")
1781 (defvar gnus-active-hashtb nil
1782 "Hashtable of active articles.")
1784 (defvar gnus-moderated-list nil
1785 "List of moderated newsgroups.")
1787 (defvar gnus-group-marked nil)
1789 (defvar gnus-current-startup-file nil
1790 "Startup file for the current host.")
1792 (defvar gnus-last-search-regexp nil
1793 "Default regexp for article search command.")
1795 (defvar gnus-last-shell-command nil
1796 "Default shell command on article.")
1798 (defvar gnus-current-select-method nil
1799 "The current method for selecting a newsgroup.")
1801 (defvar gnus-group-list-mode nil)
1803 (defvar gnus-article-internal-prepare-hook nil)
1805 (defvar gnus-newsgroup-name nil)
1806 (defvar gnus-newsgroup-begin nil)
1807 (defvar gnus-newsgroup-end nil)
1808 (defvar gnus-newsgroup-last-rmail nil)
1809 (defvar gnus-newsgroup-last-mail nil)
1810 (defvar gnus-newsgroup-last-folder nil)
1811 (defvar gnus-newsgroup-last-file nil)
1812 (defvar gnus-newsgroup-auto-expire nil)
1813 (defvar gnus-newsgroup-active nil)
1815 (defvar gnus-newsgroup-data nil)
1816 (defvar gnus-newsgroup-data-reverse nil)
1817 (defvar gnus-newsgroup-limit nil)
1818 (defvar gnus-newsgroup-limits nil)
1820 (defvar gnus-newsgroup-unreads nil
1821 "List of unread articles in the current newsgroup.")
1823 (defvar gnus-newsgroup-unselected nil
1824 "List of unselected unread articles in the current newsgroup.")
1826 (defvar gnus-newsgroup-reads nil
1827 "Alist of read articles and article marks in the current newsgroup.")
1829 (defvar gnus-newsgroup-expunged-tally nil)
1831 (defvar gnus-newsgroup-marked nil
1832 "List of ticked articles in the current newsgroup (a subset of unread art).")
1834 (defvar gnus-newsgroup-killed nil
1835 "List of ranges of articles that have been through the scoring process.")
1837 (defvar gnus-newsgroup-cached nil
1838 "List of articles that come from the article cache.")
1840 (defvar gnus-newsgroup-saved nil
1841 "List of articles that have been saved.")
1843 (defvar gnus-newsgroup-kill-headers nil)
1845 (defvar gnus-newsgroup-replied nil
1846 "List of articles that have been replied to in the current newsgroup.")
1848 (defvar gnus-newsgroup-expirable nil
1849 "List of articles in the current newsgroup that can be expired.")
1851 (defvar gnus-newsgroup-processable nil
1852 "List of articles in the current newsgroup that can be processed.")
1854 (defvar gnus-newsgroup-bookmarks nil
1855 "List of articles in the current newsgroup that have bookmarks.")
1857 (defvar gnus-newsgroup-dormant nil
1858 "List of dormant articles in the current newsgroup.")
1860 (defvar gnus-newsgroup-scored nil
1861 "List of scored articles in the current newsgroup.")
1863 (defvar gnus-newsgroup-headers nil
1864 "List of article headers in the current newsgroup.")
1866 (defvar gnus-newsgroup-threads nil)
1868 (defvar gnus-newsgroup-prepared nil
1869 "Whether the current group has been prepared properly.")
1871 (defvar gnus-newsgroup-ancient nil
1872 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1874 (defvar gnus-newsgroup-sparse nil)
1876 (defvar gnus-current-article nil)
1877 (defvar gnus-article-current nil)
1878 (defvar gnus-current-headers nil)
1879 (defvar gnus-have-all-headers nil)
1880 (defvar gnus-last-article nil)
1881 (defvar gnus-newsgroup-history nil)
1882 (defvar gnus-current-kill-article nil)
1884 ;; Save window configuration.
1885 (defvar gnus-prev-winconf nil)
1887 (defvar gnus-summary-mark-positions nil)
1888 (defvar gnus-group-mark-positions nil)
1890 (defvar gnus-reffed-article-number nil)
1892 ;;; Let the byte-compiler know that we know about this variable.
1893 (defvar rmail-default-rmail-file)
1895 (defvar gnus-cache-removable-articles nil)
1897 (defvar gnus-dead-summary nil)
1899 (defconst gnus-summary-local-variables
1900 '(gnus-newsgroup-name
1901 gnus-newsgroup-begin gnus-newsgroup-end
1902 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1903 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1904 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1905 gnus-newsgroup-unselected gnus-newsgroup-marked
1906 gnus-newsgroup-reads gnus-newsgroup-saved
1907 gnus-newsgroup-replied gnus-newsgroup-expirable
1908 gnus-newsgroup-processable gnus-newsgroup-killed
1909 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1910 gnus-newsgroup-headers gnus-newsgroup-threads
1911 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1912 gnus-current-article gnus-current-headers gnus-have-all-headers
1913 gnus-last-article gnus-article-internal-prepare-hook
1914 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1915 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1916 gnus-newsgroup-async gnus-thread-expunge-below
1917 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1918 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1919 gnus-newsgroup-history gnus-newsgroup-ancient
1920 gnus-newsgroup-sparse
1921 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1922 gnus-newsgroup-adaptive-score-file
1923 (gnus-newsgroup-expunged-tally . 0)
1924 gnus-cache-removable-articles gnus-newsgroup-cached
1925 gnus-newsgroup-data gnus-newsgroup-data-reverse
1926 gnus-newsgroup-limit gnus-newsgroup-limits)
1927 "Variables that are buffer-local to the summary buffers.")
1929 (defconst gnus-bug-message
1930 "Sending a bug report to the Gnus Towers.
1931 ========================================
1933 The buffer below is a mail buffer. When you press `C-c C-c', it will
1934 be sent to the Gnus Bug Exterminators.
1936 At the bottom of the buffer you'll see lots of variable settings.
1937 Please do not delete those. They will tell the Bug People what your
1938 environment is, so that it will be easier to locate the bugs.
1940 If you have found a bug that makes Emacs go \"beep\", set
1941 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1942 and include the backtrace in your bug report.
1944 Please describe the bug in annoying, painstaking detail.
1946 Thank you for your help in stamping out bugs.
1949 ;;; End of variables.
1951 ;; Define some autoload functions Gnus might use.
1954 ;; This little mapcar goes through the list below and marks the
1955 ;; symbols in question as autoloaded functions.
1958 (let ((interactive (nth 1 (memq ':interactive package))))
1962 (when (consp function)
1963 (setq keymap (car (memq 'keymap function)))
1964 (setq function (car function)))
1965 (autoload function (car package) nil interactive keymap)))
1966 (if (eq (nth 1 package) ':interactive)
1969 '(("metamail" metamail-buffer)
1970 ("info" Info-goto-node)
1971 ("hexl" hexl-hex-string-to-integer)
1972 ("pp" pp pp-to-string pp-eval-expression)
1973 ("mail-extr" mail-extract-address-components)
1974 ("nnmail" nnmail-split-fancy nnmail-article-group)
1975 ("nnvirtual" nnvirtual-catchup-group)
1976 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1977 timezone-make-sortable-date timezone-make-time-string)
1978 ("sendmail" mail-position-on-field mail-setup)
1979 ("rmailout" rmail-output)
1980 ("rnewspost" news-mail-other-window news-reply-yank-original
1981 news-caesar-buffer-body)
1982 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1984 ("gnus-soup" :interactive t
1985 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1986 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1987 ("nnsoup" nnsoup-pack-replies)
1988 ("gnus-scomo" :interactive t gnus-score-mode)
1989 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1990 gnus-Folder-save-name gnus-folder-save-name)
1991 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1992 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1993 gnus-server-make-menu-bar gnus-article-make-menu-bar
1994 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1995 gnus-summary-highlight-line gnus-carpal-setup-buffer
1996 gnus-group-highlight-line
1997 gnus-article-add-button gnus-insert-next-page-button
1998 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1999 ("gnus-vis" :interactive t
2000 gnus-article-push-button gnus-article-press-button
2001 gnus-article-highlight gnus-article-highlight-some
2002 gnus-article-highlight-headers gnus-article-highlight-signature
2003 gnus-article-add-buttons gnus-article-add-buttons-to-head
2004 gnus-article-next-button gnus-article-prev-button)
2005 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2006 gnus-demon-add-disconnection gnus-demon-add-handler
2007 gnus-demon-remove-handler)
2008 ("gnus-demon" :interactive t
2009 gnus-demon-init gnus-demon-cancel)
2010 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2011 gnus-tree-open gnus-tree-close)
2012 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2013 gnus-nocem-unwanted-article-p)
2014 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2015 ("gnus-srvr" gnus-browse-foreign-server)
2016 ("gnus-cite" :interactive t
2017 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2018 gnus-article-hide-citation gnus-article-fill-cited-article)
2019 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2020 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2021 gnus-execute gnus-expunge)
2022 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2023 gnus-cache-possibly-remove-articles gnus-cache-request-article
2024 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2025 gnus-cache-enter-remove-article gnus-cached-article-p
2026 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2027 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2028 gnus-cache-remove-article)
2029 ("gnus-score" :interactive t
2030 gnus-summary-increase-score gnus-summary-lower-score
2031 gnus-score-flush-cache gnus-score-close
2032 gnus-score-raise-same-subject-and-select
2033 gnus-score-raise-same-subject gnus-score-default
2034 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2035 gnus-score-lower-same-subject gnus-score-lower-thread
2036 gnus-possibly-score-headers)
2038 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2039 gnus-current-score-file-nondirectory gnus-score-adaptive
2040 gnus-score-find-trace gnus-score-file-name)
2041 ("gnus-edit" :interactive t gnus-score-customize)
2042 ("gnus-topic" :interactive t gnus-topic-mode)
2043 ("gnus-topic" gnus-topic-remove-group)
2044 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2045 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2046 ("gnus-uu" :interactive t
2047 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2048 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2049 gnus-uu-mark-by-regexp gnus-uu-mark-all
2050 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2051 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2052 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2053 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2054 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2055 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2056 gnus-uu-decode-binhex-view)
2057 ("gnus-msg" (gnus-summary-send-map keymap)
2058 gnus-mail-yank-original gnus-mail-send-and-exit
2059 gnus-sendmail-setup-mail gnus-article-mail
2060 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2061 ("gnus-msg" :interactive t
2062 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2063 gnus-summary-followup gnus-summary-followup-with-original
2064 gnus-summary-followup-and-reply
2065 gnus-summary-followup-and-reply-with-original
2066 gnus-summary-cancel-article gnus-summary-supersede-article
2067 gnus-post-news gnus-inews-news gnus-cancel-news
2068 gnus-summary-reply gnus-summary-reply-with-original
2069 gnus-summary-mail-forward gnus-summary-mail-other-window
2071 ("gnus-picon" :interactive t gnus-article-display-picons
2072 gnus-group-display-picons gnus-picons-article-display-x-face)
2073 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2074 gnus-grouplens-mode)
2075 ("gnus-vm" gnus-vm-mail-setup)
2076 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2077 gnus-summary-save-article-vm gnus-yank-article))))
2081 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2082 ;; If you want the cursor to go somewhere else, set these two
2083 ;; functions in some startup hook to whatever you want.
2084 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2085 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2087 ;;; Various macros and substs.
2089 (defun gnus-header-from (header)
2090 (mail-header-from header))
2092 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2093 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2094 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2095 `(let ((,tempvar (selected-window)))
2098 (pop-to-buffer ,buffer)
2100 (select-window ,tempvar)))))
2102 (defmacro gnus-gethash (string hashtable)
2103 "Get hash value of STRING in HASHTABLE."
2104 `(symbol-value (intern-soft ,string ,hashtable)))
2106 (defmacro gnus-sethash (string value hashtable)
2107 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2108 `(set (intern ,string ,hashtable) ,value))
2110 (defmacro gnus-intern-safe (string hashtable)
2111 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2112 `(let ((symbol (intern ,string ,hashtable)))
2117 (defmacro gnus-group-unread (group)
2118 "Get the currently computed number of unread articles in GROUP."
2119 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2121 (defmacro gnus-group-entry (group)
2122 "Get the newsrc entry for GROUP."
2123 `(gnus-gethash ,group gnus-newsrc-hashtb))
2125 (defmacro gnus-active (group)
2126 "Get active info on GROUP."
2127 `(gnus-gethash ,group gnus-active-hashtb))
2129 (defmacro gnus-set-active (group active)
2130 "Set GROUP's active info."
2131 `(gnus-sethash ,group ,active gnus-active-hashtb))
2133 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2134 ;; function `substring' might cut on a middle of multi-octet
2136 (defun gnus-truncate-string (str width)
2137 (substring str 0 width))
2139 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2140 ;; to limit the length of a string. This function is necessary since
2141 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2142 (defsubst gnus-limit-string (str width)
2143 (if (> (length str) width)
2144 (substring str 0 width)
2147 (defsubst gnus-simplify-subject-re (subject)
2148 "Remove \"Re:\" from subject lines."
2149 (if (string-match "^[Rr][Ee]: *" subject)
2150 (substring subject (match-end 0))
2153 (defsubst gnus-functionp (form)
2154 "Return non-nil if FORM is funcallable."
2155 (or (and (symbolp form) (fboundp form))
2156 (and (listp form) (eq (car form) 'lambda))))
2158 (defsubst gnus-goto-char (point)
2159 (and point (goto-char point)))
2161 (defmacro gnus-buffer-exists-p (buffer)
2162 `(let ((buffer ,buffer))
2164 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2167 (defmacro gnus-kill-buffer (buffer)
2168 `(let ((buf ,buffer))
2169 (if (gnus-buffer-exists-p buf)
2170 (kill-buffer buf))))
2172 (defsubst gnus-point-at-bol ()
2173 "Return point at the beginning of the line."
2180 (defsubst gnus-point-at-eol ()
2181 "Return point at the end of the line."
2188 (defun gnus-alive-p ()
2189 "Say whether Gnus is running or not."
2190 (and gnus-group-buffer
2191 (get-buffer gnus-group-buffer)))
2193 ;; Delete the current line (and the next N lines.);
2194 (defmacro gnus-delete-line (&optional n)
2195 `(delete-region (progn (beginning-of-line) (point))
2196 (progn (forward-line ,(or n 1)) (point))))
2198 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2199 (defvar gnus-init-inhibit nil)
2200 (defun gnus-read-init-file (&optional inhibit-next)
2201 (if gnus-init-inhibit
2202 (setq gnus-init-inhibit nil)
2203 (setq gnus-init-inhibit inhibit-next)
2205 (or (and (file-exists-p gnus-init-file)
2206 ;; Don't try to load a directory.
2207 (not (file-directory-p gnus-init-file)))
2208 (file-exists-p (concat gnus-init-file ".el"))
2209 (file-exists-p (concat gnus-init-file ".elc")))
2211 (load gnus-init-file nil t)
2213 (error "Error in %s: %s" gnus-init-file var))))))
2215 ;; Info access macros.
2217 (defmacro gnus-info-group (info)
2219 (defmacro gnus-info-rank (info)
2221 (defmacro gnus-info-read (info)
2223 (defmacro gnus-info-marks (info)
2225 (defmacro gnus-info-method (info)
2227 (defmacro gnus-info-params (info)
2230 (defmacro gnus-info-level (info)
2231 `(let ((rank (gnus-info-rank ,info)))
2235 (defmacro gnus-info-score (info)
2236 `(let ((rank (gnus-info-rank ,info)))
2237 (or (and (consp rank) (cdr rank)) 0)))
2239 (defmacro gnus-info-set-group (info group)
2240 `(setcar ,info ,group))
2241 (defmacro gnus-info-set-rank (info rank)
2242 `(setcar (nthcdr 1 ,info) ,rank))
2243 (defmacro gnus-info-set-read (info read)
2244 `(setcar (nthcdr 2 ,info) ,read))
2245 (defmacro gnus-info-set-marks (info marks)
2246 `(setcar (nthcdr 3 ,info) ,marks))
2247 (defmacro gnus-info-set-method (info method)
2248 `(setcar (nthcdr 4 ,info) ,method))
2249 (defmacro gnus-info-set-params (info params)
2250 `(setcar (nthcdr 5 ,info) ,params))
2252 (defmacro gnus-info-set-level (info level)
2253 `(let ((rank (cdr ,info)))
2254 (if (consp (car rank))
2255 (setcar (car rank) ,level)
2256 (setcar rank ,level))))
2257 (defmacro gnus-info-set-score (info score)
2258 `(let ((rank (cdr ,info)))
2259 (if (consp (car rank))
2260 (setcdr (car rank) ,score)
2261 (setcar rank (cons (car rank) ,score)))))
2263 (defmacro gnus-get-info (group)
2264 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2266 (defun gnus-byte-code (func)
2267 "Return a form that can be `eval'ed based on FUNC."
2268 (let ((fval (symbol-function func)))
2269 (if (byte-code-function-p fval)
2270 (let ((flist (append fval nil)))
2271 (setcar flist 'byte-code)
2273 (cons 'progn (cddr fval)))))
2275 ;;; Load the compatability functions.
2285 (defvar gnus-shutdown-alist nil)
2287 (defun gnus-add-shutdown (function &rest symbols)
2288 "Run FUNCTION whenever one of SYMBOLS is shut down."
2289 (push (cons function symbols) gnus-shutdown-alist))
2291 (defun gnus-shutdown (symbol)
2292 "Shut down everything that waits for SYMBOL."
2293 (let ((alist gnus-shutdown-alist)
2295 (while (setq entry (pop alist))
2296 (when (memq symbol (cdr entry))
2297 (funcall (car entry))))))
2301 ;; Format specs. The chunks below are the machine-generated forms
2302 ;; that are to be evaled as the result of the default format strings.
2303 ;; We write them in here to get them byte-compiled. That way the
2304 ;; default actions will be quite fast, while still retaining the full
2305 ;; flexibility of the user-defined format specs.
2307 ;; First we have lots of dummy defvars to let the compiler know these
2308 ;; are really dynamic variables.
2310 (defvar gnus-tmp-unread)
2311 (defvar gnus-tmp-replied)
2312 (defvar gnus-tmp-score-char)
2313 (defvar gnus-tmp-indentation)
2314 (defvar gnus-tmp-opening-bracket)
2315 (defvar gnus-tmp-lines)
2316 (defvar gnus-tmp-name)
2317 (defvar gnus-tmp-closing-bracket)
2318 (defvar gnus-tmp-subject-or-nil)
2319 (defvar gnus-tmp-subject)
2320 (defvar gnus-tmp-marked)
2321 (defvar gnus-tmp-marked-mark)
2322 (defvar gnus-tmp-subscribed)
2323 (defvar gnus-tmp-process-marked)
2324 (defvar gnus-tmp-number-of-unread)
2325 (defvar gnus-tmp-group-name)
2326 (defvar gnus-tmp-group)
2327 (defvar gnus-tmp-article-number)
2328 (defvar gnus-tmp-unread-and-unselected)
2329 (defvar gnus-tmp-news-method)
2330 (defvar gnus-tmp-news-server)
2331 (defvar gnus-tmp-article-number)
2332 (defvar gnus-mouse-face)
2333 (defvar gnus-mouse-face-prop)
2335 (defun gnus-summary-line-format-spec ()
2336 (insert gnus-tmp-unread gnus-tmp-replied
2337 gnus-tmp-score-char gnus-tmp-indentation)
2342 gnus-tmp-opening-bracket
2343 (format "%4d: %-20s"
2345 (if (> (length gnus-tmp-name) 20)
2346 (substring gnus-tmp-name 0 20)
2348 gnus-tmp-closing-bracket)
2350 gnus-mouse-face-prop gnus-mouse-face)
2351 (insert " " gnus-tmp-subject-or-nil "\n"))
2353 (defvar gnus-summary-line-format-spec
2354 (gnus-byte-code 'gnus-summary-line-format-spec))
2356 (defun gnus-summary-dummy-line-format-spec ()
2363 gnus-mouse-face-prop gnus-mouse-face)
2364 (insert " " gnus-tmp-subject "\n"))
2366 (defvar gnus-summary-dummy-line-format-spec
2367 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2369 (defun gnus-group-line-format-spec ()
2370 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2371 gnus-tmp-process-marked
2372 gnus-group-indentation
2373 (format "%5s: " gnus-tmp-number-of-unread))
2377 (insert gnus-tmp-group "\n")
2379 gnus-mouse-face-prop gnus-mouse-face))
2380 (defvar gnus-group-line-format-spec
2381 (gnus-byte-code 'gnus-group-line-format-spec))
2383 (defvar gnus-format-specs
2384 `((version . ,emacs-version)
2385 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2386 (summary-dummy ,gnus-summary-dummy-line-format
2387 ,gnus-summary-dummy-line-format-spec)
2388 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2390 (defvar gnus-article-mode-line-format-spec nil)
2391 (defvar gnus-summary-mode-line-format-spec nil)
2392 (defvar gnus-group-mode-line-format-spec nil)
2394 ;;; Phew. All that gruft is over, fortunately.
2398 ;;; Gnus Utility Functions
2401 (defun gnus-extract-address-components (from)
2403 ;; First find the address - the thing with the @ in it. This may
2404 ;; not be accurate in mail addresses, but does the trick most of
2405 ;; the time in news messages.
2406 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2407 (setq address (substring from (match-beginning 0) (match-end 0))))
2408 ;; Then we check whether the "name <address>" format is used.
2410 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2411 ;; Linear white space is not required.
2412 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2413 (and (setq name (substring from 0 (match-beginning 0)))
2414 ;; Strip any quotes from the name.
2415 (string-match "\".*\"" name)
2416 (setq name (substring name 1 (1- (match-end 0))))))
2417 ;; If not, then "address (name)" is used.
2419 (and (string-match "(.+)" from)
2420 (setq name (substring from (1+ (match-beginning 0))
2421 (1- (match-end 0)))))
2422 (and (string-match "()" from)
2423 (setq name address))
2424 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2425 ;; XOVER might not support folded From headers.
2426 (and (string-match "(.*" from)
2427 (setq name (substring from (1+ (match-beginning 0))
2429 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2430 (list (or name from) (or address from))))
2432 (defun gnus-fetch-field (field)
2433 "Return the value of the header FIELD of current article."
2436 (let ((case-fold-search t)
2437 (inhibit-point-motion-hooks t))
2438 (nnheader-narrow-to-headers)
2439 (mail-fetch-field field)))))
2441 (defun gnus-goto-colon ()
2443 (search-forward ":" (gnus-point-at-eol) t))
2446 (defun gnus-update-format (var)
2447 "Update the format specification near point."
2452 ;; Find the end of the current word.
2453 (re-search-forward "[ \t\n]" nil t)
2455 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2456 (match-string 1)))))
2457 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2458 (match-string 1 var))))
2459 (entry (assq type gnus-format-specs))
2462 (setq gnus-format-specs (delq entry gnus-format-specs)))
2464 (intern (format "%s-spec" var))
2465 (gnus-parse-format (setq value (symbol-value (intern var)))
2466 (symbol-value (intern (format "%s-alist" var)))
2467 (not (string-match "mode" var))))
2468 (setq spec (symbol-value (intern (format "%s-spec" var))))
2469 (push (list type value spec) gnus-format-specs)
2471 (pop-to-buffer "*Gnus Format*")
2473 (lisp-interaction-mode)
2474 (insert (pp-to-string spec))))
2476 (defun gnus-update-format-specifications (&optional force)
2477 "Update all (necessary) format specifications."
2478 ;; Make the indentation array.
2479 (gnus-make-thread-indent-array)
2481 ;; See whether all the stored info needs to be flushed.
2483 (not (equal emacs-version
2484 (cdr (assq 'version gnus-format-specs)))))
2485 (setq gnus-format-specs nil))
2487 ;; Go through all the formats and see whether they need updating.
2488 (let ((types '(summary summary-dummy group
2489 summary-mode group-mode article-mode))
2490 new-format entry type val)
2491 (while (setq type (pop types))
2492 ;; Jump to the proper buffer to find out the value of
2493 ;; the variable, if possible. (It may be buffer-local.)
2495 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2497 (when (and (boundp buffer)
2498 (setq val (symbol-value buffer))
2500 (buffer-name (get-buffer val)))
2501 (set-buffer (get-buffer val)))
2502 (setq new-format (symbol-value
2503 (intern (format "gnus-%s-line-format" type))))))
2504 (setq entry (cdr (assq type gnus-format-specs)))
2506 (equal (car entry) new-format))
2507 ;; Use the old format.
2508 (set (intern (format "gnus-%s-line-format-spec" type))
2510 ;; This is a new format.
2512 (if (not (stringp new-format))
2513 ;; This is a function call or something.
2515 ;; This is a "real" format.
2519 (intern (format "gnus-%s-line-format-alist"
2520 (if (eq type 'article-mode)
2521 'summary-mode type))))
2522 (not (string-match "mode$" (symbol-name type))))))
2523 ;; Enter the new format spec into the list.
2526 (setcar (cdr entry) val)
2527 (setcar entry new-format))
2528 (push (list type new-format val) gnus-format-specs))
2529 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2531 (unless (assq 'version gnus-format-specs)
2532 (push (cons 'version emacs-version) gnus-format-specs))
2534 (gnus-update-group-mark-positions)
2535 (gnus-update-summary-mark-positions))
2537 (defun gnus-update-summary-mark-positions ()
2538 "Compute where the summary marks are to go."
2540 (let ((gnus-replied-mark 129)
2541 (gnus-score-below-mark 130)
2542 (gnus-score-over-mark 130)
2546 (gnus-set-work-buffer)
2547 (gnus-summary-insert-line
2548 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2549 (goto-char (point-min))
2550 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2552 (goto-char (point-min))
2553 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2555 (goto-char (point-min))
2556 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2558 (setq gnus-summary-mark-positions pos))))
2560 (defun gnus-update-group-mark-positions ()
2562 (let ((gnus-process-mark 128)
2563 (gnus-group-marked '("dummy.group")))
2564 (gnus-set-active "dummy.group" '(0 . 0))
2565 (gnus-set-work-buffer)
2566 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2567 (goto-char (point-min))
2568 (setq gnus-group-mark-positions
2569 (list (cons 'process (and (search-forward "\200" nil t)
2570 (- (point) 2))))))))
2572 (defvar gnus-mouse-face-0 'highlight)
2573 (defvar gnus-mouse-face-1 'highlight)
2574 (defvar gnus-mouse-face-2 'highlight)
2575 (defvar gnus-mouse-face-3 'highlight)
2576 (defvar gnus-mouse-face-4 'highlight)
2578 (defun gnus-mouse-face-function (form type)
2580 (point) (progn ,@form (point))
2581 gnus-mouse-face-prop
2584 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2586 (defvar gnus-face-0 'bold)
2587 (defvar gnus-face-1 'italic)
2588 (defvar gnus-face-2 'bold-italic)
2589 (defvar gnus-face-3 'bold)
2590 (defvar gnus-face-4 'bold)
2592 (defun gnus-face-face-function (form type)
2594 (point) (progn ,@form (point))
2595 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2597 (defun gnus-max-width-function (el max-width)
2598 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2600 `(if (> (length ,el) ,max-width)
2601 (substring ,el 0 ,max-width)
2603 `(let ((val (eval ,el)))
2605 (setq val (int-to-string val)))
2606 (if (> (length val) ,max-width)
2607 (substring val 0 ,max-width)
2610 (defun gnus-parse-format (format spec-alist &optional insert)
2611 ;; This function parses the FORMAT string with the help of the
2612 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2613 ;; string. If the FORMAT string contains the specifiers %( and %)
2614 ;; the text between them will have the mouse-face text property.
2616 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2618 (gnus-parse-complex-format format spec-alist)
2619 ;; This is a simple format.
2620 (gnus-parse-simple-format format spec-alist insert)))
2622 (defun gnus-parse-complex-format (format spec-alist)
2624 (gnus-set-work-buffer)
2626 (goto-char (point-min))
2627 (while (re-search-forward "\"" nil t)
2628 (replace-match "\\\"" nil t))
2629 (goto-char (point-min))
2631 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2632 (let ((number (if (match-beginning 1)
2633 (match-string 1) "0"))
2634 (delim (aref (match-string 2) 0)))
2635 (if (or (= delim ?\() (= delim ?\{))
2636 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2638 (replace-match "\")\""))))
2639 (goto-char (point-max))
2641 (goto-char (point-min))
2642 (let ((form (read (current-buffer))))
2643 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2645 (defun gnus-complex-form-to-spec (form spec-alist)
2650 (gnus-parse-simple-format sform spec-alist t)
2651 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2652 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2656 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2657 ;; This function parses the FORMAT string with the help of the
2658 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2661 spec flist fstring newspec elem beg result dontinsert)
2663 (gnus-set-work-buffer)
2665 (goto-char (point-min))
2666 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2668 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2670 beg (1+ (match-beginning 0)))
2671 ;; First check if there are any specs that look anything like
2672 ;; "%12,12A", ie. with a "max width specification". These have
2673 ;; to be treated specially.
2674 (if (setq beg (match-beginning 1))
2678 (1+ (match-beginning 1)) (match-end 1))))
2680 (setq beg (match-beginning 2)))
2681 ;; Find the specification from `spec-alist'.
2682 (unless (setq elem (cdr (assq spec spec-alist)))
2683 (setq elem '("*" ?s)))
2684 ;; Treat user defined format specifiers specially.
2685 (when (eq (car elem) 'gnus-tmp-user-defined)
2688 (list (intern (concat "gnus-user-format-function-"
2690 'gnus-tmp-header) ?s))
2691 (delete-region (match-beginning 3) (match-end 3)))
2692 (if (not (zerop max-width))
2693 (let ((el (car elem)))
2694 (cond ((= (cadr elem) ?c)
2695 (setq el (list 'char-to-string el)))
2697 (setq el (list 'int-to-string el))))
2698 (setq flist (cons (gnus-max-width-function el max-width)
2702 (setq flist (cons (car elem) flist))
2703 (setq newspec (cadr elem)))))
2704 ;; Remove the old specification (and possibly a ",12" string).
2705 (delete-region beg (match-end 2))
2706 ;; Insert the new specification.
2709 (setq fstring (buffer-substring 1 (point-max))))
2710 ;; Do some postprocessing to increase efficiency.
2715 ((string= fstring "")
2717 ;; Not a format string.
2718 ((not (string-match "%" fstring))
2720 ;; A format string with just a single string spec.
2721 ((string= fstring "%s")
2723 ;; A single character.
2724 ((string= fstring "%c")
2727 ((string= fstring "%d")
2730 (list `(princ ,(car flist)))
2731 (list `(int-to-string ,(car flist)))))
2732 ;; Just lots of chars and strings.
2733 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2735 ;; A single string spec at the beginning of the spec.
2736 ((string-match "\\`%[sc][^%]+\\'" fstring)
2737 (list (car flist) (substring fstring 2)))
2738 ;; A single string spec in the middle of the spec.
2739 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2740 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2741 ;; A single string spec in the end of the spec.
2742 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2743 (list (match-string 1 fstring) (car flist)))
2744 ;; A more complex spec.
2746 (list (cons 'format (cons fstring (nreverse flist)))))))
2752 (cons 'insert result)))
2753 (cond ((stringp result)
2756 (cons 'concat result))
2759 (defun gnus-eval-format (format &optional alist props)
2760 "Eval the format variable FORMAT, using ALIST.
2761 If PROPS, insert the result."
2762 (let ((form (gnus-parse-format format alist props)))
2764 (add-text-properties (point) (progn (eval form) (point)) props)
2767 (defun gnus-remove-text-with-property (prop)
2768 "Delete all text in the current buffer with text property PROP."
2770 (goto-char (point-min))
2772 (while (get-text-property (point) prop)
2774 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2776 (defun gnus-set-work-buffer ()
2777 (if (get-buffer gnus-work-buffer)
2779 (set-buffer gnus-work-buffer)
2781 (set-buffer (get-buffer-create gnus-work-buffer))
2782 (kill-all-local-variables)
2783 (buffer-disable-undo (current-buffer))
2784 (gnus-add-current-to-buffer-list)))
2786 ;; Article file names when saving.
2788 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2789 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2790 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2791 Otherwise, it is like ~/News/news/group/num."
2794 (concat (if (gnus-use-long-file-name 'not-save)
2795 (gnus-capitalize-newsgroup newsgroup)
2796 (gnus-newsgroup-directory-form newsgroup))
2797 "/" (int-to-string (mail-header-number headers)))
2798 (or gnus-article-save-directory "~/News"))))
2800 (string-equal (file-name-directory default)
2801 (file-name-directory last-file))
2802 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2804 (or last-file default))))
2806 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2807 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2808 If variable `gnus-use-long-file-name' is non-nil, it is
2809 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2812 (concat (if (gnus-use-long-file-name 'not-save)
2814 (gnus-newsgroup-directory-form newsgroup))
2815 "/" (int-to-string (mail-header-number headers)))
2816 (or gnus-article-save-directory "~/News"))))
2818 (string-equal (file-name-directory default)
2819 (file-name-directory last-file))
2820 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2822 (or last-file default))))
2824 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2825 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2826 If variable `gnus-use-long-file-name' is non-nil, it is
2827 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2830 (if (gnus-use-long-file-name 'not-save)
2831 (gnus-capitalize-newsgroup newsgroup)
2832 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2833 (or gnus-article-save-directory "~/News"))))
2835 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2836 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2837 If variable `gnus-use-long-file-name' is non-nil, it is
2838 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2841 (if (gnus-use-long-file-name 'not-save)
2843 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2844 (or gnus-article-save-directory "~/News"))))
2846 ;; For subscribing new newsgroup
2848 (defun gnus-subscribe-hierarchical-interactive (groups)
2849 (let ((groups (sort groups 'string<))
2850 prefixes prefix start ans group starts)
2852 (setq prefixes (list "^"))
2853 (while (and groups prefixes)
2854 (while (not (string-match (car prefixes) (car groups)))
2855 (setq prefixes (cdr prefixes)))
2856 (setq prefix (car prefixes))
2857 (setq start (1- (length prefix)))
2858 (if (and (string-match "[^\\.]\\." (car groups) start)
2861 (concat "^" (substring (car groups) 0 (match-end 0))))
2862 (string-match prefix (cadr groups)))
2864 (setq prefixes (cons prefix prefixes))
2865 (message "Descend hierarchy %s? ([y]nsq): "
2866 (substring prefix 1 (1- (length prefix))))
2867 (setq ans (read-char))
2870 (string-match prefix
2871 (setq group (car groups))))
2872 (setq gnus-killed-list
2873 (cons group gnus-killed-list))
2874 (gnus-sethash group group gnus-killed-hashtb)
2875 (setq groups (cdr groups)))
2876 (setq starts (cdr starts)))
2879 (string-match prefix
2880 (setq group (car groups))))
2881 (gnus-sethash group group gnus-killed-hashtb)
2882 (gnus-subscribe-alphabetically (car groups))
2883 (setq groups (cdr groups)))
2884 (setq starts (cdr starts)))
2887 (setq group (car groups))
2888 (setq gnus-killed-list (cons group gnus-killed-list))
2889 (gnus-sethash group group gnus-killed-hashtb)
2890 (setq groups (cdr groups))))
2892 (message "Subscribe %s? ([n]yq)" (car groups))
2893 (setq ans (read-char))
2894 (setq group (car groups))
2896 (gnus-subscribe-alphabetically (car groups))
2897 (gnus-sethash group group gnus-killed-hashtb))
2900 (setq group (car groups))
2901 (setq gnus-killed-list (cons group gnus-killed-list))
2902 (gnus-sethash group group gnus-killed-hashtb)
2903 (setq groups (cdr groups))))
2905 (setq gnus-killed-list (cons group gnus-killed-list))
2906 (gnus-sethash group group gnus-killed-hashtb)))
2907 (setq groups (cdr groups)))))))
2909 (defun gnus-subscribe-randomly (newsgroup)
2910 "Subscribe new NEWSGROUP by making it the first newsgroup."
2911 (gnus-subscribe-newsgroup newsgroup))
2913 (defun gnus-subscribe-alphabetically (newgroup)
2914 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2915 (let ((groups (cdr gnus-newsrc-alist))
2917 (while (and (not before) groups)
2918 (if (string< newgroup (caar groups))
2919 (setq before (caar groups))
2920 (setq groups (cdr groups))))
2921 (gnus-subscribe-newsgroup newgroup before)))
2923 (defun gnus-subscribe-hierarchically (newgroup)
2924 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2925 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2927 (set-buffer (find-file-noselect gnus-current-startup-file))
2928 (let ((groupkey newgroup)
2930 (while (and (not before) groupkey)
2931 (goto-char (point-min))
2933 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2934 (while (and (re-search-forward groupkey-re nil t)
2936 (setq before (match-string 1))
2937 (string< before newgroup)))))
2938 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2940 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2941 (substring groupkey (match-beginning 1) (match-end 1)))))
2942 (gnus-subscribe-newsgroup newgroup before))))
2944 (defun gnus-subscribe-interactively (group)
2945 "Subscribe the new GROUP interactively.
2946 It is inserted in hierarchical newsgroup order if subscribed. If not,
2948 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2949 (gnus-subscribe-hierarchically group)
2950 (push group gnus-killed-list)))
2952 (defun gnus-subscribe-zombies (group)
2953 "Make the new GROUP into a zombie group."
2954 (push group gnus-zombie-list))
2956 (defun gnus-subscribe-killed (group)
2957 "Make the new GROUP a killed group."
2958 (push group gnus-killed-list))
2960 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2961 "Subscribe new NEWSGROUP.
2962 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2963 the first newsgroup."
2964 ;; We subscribe the group by changing its level to `subscribed'.
2965 (gnus-group-change-level
2966 newsgroup gnus-level-default-subscribed
2967 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2968 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2972 (defun gnus-newsgroup-directory-form (newsgroup)
2973 "Make hierarchical directory name from NEWSGROUP name."
2974 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2975 (len (length newsgroup))
2977 ;; If this is a foreign group, we don't want to translate the
2979 (if (setq idx (string-match ":" newsgroup))
2980 (aset newsgroup idx ?/)
2982 ;; Replace all occurrences of `.' with `/'.
2984 (if (= (aref newsgroup idx) ?.)
2985 (aset newsgroup idx ?/))
2986 (setq idx (1+ idx)))
2989 (defun gnus-newsgroup-savable-name (group)
2990 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2992 (nnheader-replace-chars-in-string group ?/ ?.))
2994 (defun gnus-make-directory (dir)
2995 "Make DIRECTORY recursively."
2996 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2997 ;; of the many mysteries of the universe.
2998 (let* ((dir (expand-file-name dir default-directory))
3000 (if (string-match "/$" dir)
3001 (setq dir (substring dir 0 (match-beginning 0))))
3002 ;; First go down the path until we find a directory that exists.
3003 (while (not (file-exists-p dir))
3004 (setq dirs (cons dir dirs))
3005 (string-match "/[^/]+$" dir)
3006 (setq dir (substring dir 0 (match-beginning 0))))
3007 ;; Then create all the subdirs.
3008 (while (and dirs (not err))
3010 (make-directory (car dirs))
3011 (error (setq err t)))
3012 (setq dirs (cdr dirs)))
3013 ;; We return whether we were successful or not.
3016 (defun gnus-capitalize-newsgroup (newsgroup)
3017 "Capitalize NEWSGROUP name."
3018 (and (not (zerop (length newsgroup)))
3019 (concat (char-to-string (upcase (aref newsgroup 0)))
3020 (substring newsgroup 1))))
3022 ;; Various... things.
3024 (defun gnus-simplify-subject (subject &optional re-only)
3025 "Remove `Re:' and words in parentheses.
3026 If RE-ONLY is non-nil, strip leading `Re:'s only."
3027 (let ((case-fold-search t)) ;Ignore case.
3028 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3029 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3030 (setq subject (substring subject (match-end 0))))
3031 ;; Remove uninteresting prefixes.
3032 (if (and (not re-only)
3033 gnus-simplify-ignored-prefixes
3034 (string-match gnus-simplify-ignored-prefixes subject))
3035 (setq subject (substring subject (match-end 0))))
3036 ;; Remove words in parentheses from end.
3038 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3039 (setq subject (substring subject 0 (match-beginning 0)))))
3040 ;; Return subject string.
3043 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3045 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3046 (defun gnus-simplify-buffer-fuzzy ()
3047 (goto-char (point-min))
3048 (while (search-forward "\t" nil t)
3049 (replace-match " " t t))
3050 (goto-char (point-min))
3051 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3052 (goto-char (match-beginning 0))
3054 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3055 (looking-at "^[[].*: .*[]]$"))
3056 (goto-char (point-min))
3057 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3059 (replace-match "" t t))
3060 (goto-char (point-min))
3061 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3062 (goto-char (match-end 0))
3065 (progn (goto-char (match-beginning 0)))
3066 (re-search-forward ":"))))
3067 (goto-char (point-min))
3068 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3069 (replace-match "" t t))
3070 (goto-char (point-min))
3071 (while (re-search-forward " +" nil t)
3072 (replace-match " " t t))
3073 (goto-char (point-min))
3074 (while (re-search-forward " $" nil t)
3075 (replace-match "" t t))
3076 (goto-char (point-min))
3077 (while (re-search-forward "^ +" nil t)
3078 (replace-match "" t t))
3079 (goto-char (point-min))
3080 (when gnus-simplify-subject-fuzzy-regexp
3081 (if (listp gnus-simplify-subject-fuzzy-regexp)
3082 (let ((list gnus-simplify-subject-fuzzy-regexp))
3084 (goto-char (point-min))
3085 (while (re-search-forward (car list) nil t)
3086 (replace-match "" t t))
3087 (setq list (cdr list))))
3088 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3089 (replace-match "" t t)))))
3091 (defun gnus-simplify-subject-fuzzy (subject)
3092 "Siplify a subject string fuzzily."
3094 (gnus-set-work-buffer)
3095 (let ((case-fold-search t))
3097 (inline (gnus-simplify-buffer-fuzzy))
3100 ;; Add the current buffer to the list of buffers to be killed on exit.
3101 (defun gnus-add-current-to-buffer-list ()
3102 (or (memq (current-buffer) gnus-buffer-list)
3103 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3105 (defun gnus-string> (s1 s2)
3106 (not (or (string< s1 s2)
3109 ;;; General various misc type functions.
3111 (defun gnus-clear-system ()
3112 "Clear all variables and buffers."
3113 ;; Clear Gnus variables.
3114 (let ((variables gnus-variable-list))
3116 (set (car variables) nil)
3117 (setq variables (cdr variables))))
3118 ;; Clear other internal variables.
3119 (setq gnus-list-of-killed-groups nil
3120 gnus-have-read-active-file nil
3121 gnus-newsrc-alist nil
3122 gnus-newsrc-hashtb nil
3123 gnus-killed-list nil
3124 gnus-zombie-list nil
3125 gnus-killed-hashtb nil
3126 gnus-active-hashtb nil
3127 gnus-moderated-list nil
3128 gnus-description-hashtb nil
3129 gnus-current-headers nil
3130 gnus-thread-indent-array nil
3131 gnus-newsgroup-headers nil
3132 gnus-newsgroup-name nil
3133 gnus-server-alist nil
3134 gnus-group-list-mode nil
3135 gnus-opened-servers nil
3136 gnus-current-select-method nil)
3137 (gnus-shutdown 'gnus)
3138 ;; Kill the startup file.
3139 (and gnus-current-startup-file
3140 (get-file-buffer gnus-current-startup-file)
3141 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3142 ;; Clear the dribble buffer.
3143 (gnus-dribble-clear)
3144 ;; Kill global KILL file buffer.
3145 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3146 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3147 (gnus-kill-buffer nntp-server-buffer)
3148 ;; Kill Gnus buffers.
3149 (while gnus-buffer-list
3150 (gnus-kill-buffer (pop gnus-buffer-list)))
3151 ;; Remove Gnus frames.
3152 (while gnus-created-frames
3153 (when (frame-live-p (car gnus-created-frames))
3154 ;; We slap a condition-case around this `delete-frame' to ensure
3155 ;; agains errors if we try do delete the single frame that's left.
3157 (delete-frame (car gnus-created-frames))
3159 (pop gnus-created-frames)))
3161 (defun gnus-windows-old-to-new (setting)
3162 ;; First we take care of the really, really old Gnus 3 actions.
3163 (when (symbolp setting)
3165 ;; Take care of ooold GNUS 3.x values.
3166 (cond ((eq setting 'SelectArticle) 'article)
3167 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3168 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3170 (if (or (listp setting)
3171 (not (and gnus-window-configuration
3172 (memq setting '(group summary article)))))
3174 (let* ((setting (if (eq setting 'group)
3175 (if (assq 'newsgroup gnus-window-configuration)
3177 'newsgroups) setting))
3178 (elem (cadr (assq setting gnus-window-configuration)))
3179 (total (apply '+ elem))
3180 (types '(group summary article))
3181 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3186 (or (not (numberp (nth i elem)))
3187 (zerop (nth i elem))
3189 (setq perc (/ (float (nth 0 elem)) total))
3190 (setq out (cons (if (eq pbuf (nth i types))
3191 (vector (nth i types) perc 'point)
3192 (vector (nth i types) perc))
3195 (list (nreverse out)))))
3198 (defun gnus-add-configuration (conf)
3199 "Add the window configuration CONF to `gnus-buffer-configuration'."
3200 (setq gnus-buffer-configuration
3201 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3202 gnus-buffer-configuration))))
3204 (defvar gnus-frame-list nil)
3206 (defun gnus-configure-frame (split &optional window)
3207 "Split WINDOW according to SPLIT."
3209 (setq window (get-buffer-window (current-buffer))))
3210 (select-window window)
3211 ;; This might be an old-stylee buffer config.
3212 (when (vectorp split)
3213 (setq split (append split nil)))
3214 (when (or (consp (car split))
3215 (vectorp (car split)))
3217 (push 'vertical split))
3218 ;; The SPLIT might be something that is to be evaled to
3219 ;; return a new SPLIT.
3220 (while (and (not (assq (car split) gnus-window-to-buffer))
3221 (gnus-functionp (car split)))
3222 (setq split (eval split)))
3223 (let* ((type (car split))
3225 (len (if (eq type 'horizontal) (window-width) (window-height)))
3227 (window-min-width (or gnus-window-min-width window-min-width))
3228 (window-min-height (or gnus-window-min-height window-min-height))
3229 s result new-win rest comp-subs size sub)
3231 ;; Nothing to do here.
3233 ;; Don't switch buffers.
3235 (and (memq 'point split) window))
3236 ;; This is a buffer to be selected.
3237 ((not (memq type '(frame horizontal vertical)))
3238 (let ((buffer (cond ((stringp type) type)
3239 (t (cdr (assq type gnus-window-to-buffer)))))
3242 (error "Illegal buffer type: %s" type))
3243 (unless (setq buf (get-buffer (if (symbolp buffer)
3244 (symbol-value buffer) buffer)))
3245 (setq buf (get-buffer-create (if (symbolp buffer)
3246 (symbol-value buffer) buffer))))
3247 (switch-to-buffer buf)
3248 ;; We return the window if it has the `point' spec.
3249 (and (memq 'point split) window)))
3250 ;; This is a frame split.
3252 (unless gnus-frame-list
3253 (setq gnus-frame-list (list (window-frame
3254 (get-buffer-window (current-buffer))))))
3256 params frame fresult)
3257 (while (< i (length subs))
3258 ;; Frame parameter is gotten from the sub-split.
3259 (setq params (cadr (elt subs i)))
3260 ;; It should be a list.
3261 (unless (listp params)
3263 ;; Create a new frame?
3264 (unless (setq frame (elt gnus-frame-list i))
3265 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3266 (push frame gnus-created-frames))
3267 ;; Is the old frame still alive?
3268 (unless (frame-live-p frame)
3269 (setcar (nthcdr i gnus-frame-list)
3270 (setq frame (make-frame params))))
3271 ;; Select the frame in question and do more splits there.
3272 (select-frame frame)
3273 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3275 ;; Select the frame that has the selected buffer.
3277 (select-frame (window-frame fresult)))))
3278 ;; This is a normal split.
3280 (when (> (length subs) 0)
3281 ;; First we have to compute the sizes of all new windows.
3283 (setq sub (append (pop subs) nil))
3284 (while (and (not (assq (car sub) gnus-window-to-buffer))
3285 (gnus-functionp (car sub)))
3286 (setq sub (eval sub)))
3288 (push sub comp-subs)
3289 (setq size (cadar comp-subs))
3290 (cond ((equal size 1.0)
3291 (setq rest (car comp-subs))
3294 (setq s (floor (* size len))))
3298 (error "Illegal size: %s" size)))
3299 ;; Try to make sure that we are inside the safe limits.
3301 ((eq type 'horizontal)
3302 (setq s (max s window-min-width)))
3303 ((eq type 'vertical)
3304 (setq s (max s window-min-height))))
3305 (setcar (cdar comp-subs) s)
3307 ;; Take care of the "1.0" spec.
3309 (setcar (cdr rest) (- len total))
3310 (error "No 1.0 specs in %s" split))
3311 ;; The we do the actual splitting in a nice recursive
3313 (setq comp-subs (nreverse comp-subs))
3315 (if (null (cdr comp-subs))
3316 (setq new-win window)
3318 (split-window window (cadar comp-subs)
3319 (eq type 'horizontal))))
3320 (setq result (or (gnus-configure-frame
3321 (car comp-subs) window) result))
3322 (select-window new-win)
3323 (setq window new-win)
3324 (setq comp-subs (cdr comp-subs))))
3325 ;; Return the proper window, if any.
3327 (select-window result))))))
3329 (defvar gnus-frame-split-p nil)
3331 (defun gnus-configure-windows (setting &optional force)
3332 (setq setting (gnus-windows-old-to-new setting))
3333 (let ((split (if (symbolp setting)
3334 (cadr (assq setting gnus-buffer-configuration))
3338 (setq gnus-frame-split-p nil)
3341 (error "No such setting: %s" setting))
3343 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3345 ;; All the windows mentioned are already visible, so we just
3346 ;; put point in the assigned buffer, and do not touch the
3348 (select-window all-visible)
3350 ;; Either remove all windows or just remove all Gnus windows.
3351 (let ((frame (selected-frame)))
3353 (if gnus-use-full-window
3354 ;; We want to remove all other windows.
3355 (if (not gnus-frame-split-p)
3356 ;; This is not a `frame' split, so we ignore the
3358 (delete-other-windows)
3359 ;; This is a `frame' split, so we delete all windows
3363 (unless (eq (cdr (assq 'minibuffer
3364 (frame-parameters frame)))
3366 (select-frame frame)
3367 (delete-other-windows)))
3369 ;; Just remove some windows.
3370 (gnus-remove-some-windows)
3371 (switch-to-buffer nntp-server-buffer))
3372 (select-frame frame)))
3374 (switch-to-buffer nntp-server-buffer)
3375 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3377 (defun gnus-all-windows-visible-p (split)
3378 "Say whether all buffers in SPLIT are currently visible.
3379 In particular, the value returned will be the window that
3381 (let ((stack (list split))
3383 type buffer win buf)
3384 (while (and (setq split (pop stack))
3386 ;; Be backwards compatible.
3387 (when (vectorp split)
3388 (setq split (append split nil)))
3389 (when (or (consp (car split))
3390 (vectorp (car split)))
3392 (push 'vertical split))
3393 ;; The SPLIT might be something that is to be evaled to
3394 ;; return a new SPLIT.
3395 (while (and (not (assq (car split) gnus-window-to-buffer))
3396 (gnus-functionp (car split)))
3397 (setq split (eval split)))
3399 (setq type (elt split 0))
3404 ((not (memq type '(horizontal vertical frame)))
3405 (setq buffer (cond ((stringp type) type)
3406 (t (cdr (assq type gnus-window-to-buffer)))))
3408 (error "Illegal buffer type: %s" type))
3409 (when (setq buf (get-buffer (if (symbolp buffer)
3410 (symbol-value buffer)
3412 (setq win (get-buffer-window buf t)))
3414 (when (memq 'point split)
3415 (setq all-visible win))
3416 (setq all-visible nil)))
3418 (when (eq type 'frame)
3419 (setq gnus-frame-split-p t))
3420 (setq stack (append (cddr split) stack)))))
3421 (unless (eq all-visible t)
3424 (defun gnus-window-top-edge (&optional window)
3425 (nth 1 (window-edges window)))
3427 (defun gnus-remove-some-windows ()
3428 (let ((buffers gnus-window-to-buffer)
3429 buf bufs lowest-buf lowest)
3431 ;; Remove windows on all known Gnus buffers.
3433 (setq buf (cdar buffers))
3435 (setq buf (and (boundp buf) (symbol-value buf))))
3437 (get-buffer-window buf)
3439 (setq bufs (cons buf bufs))
3441 (if (or (not lowest)
3442 (< (gnus-window-top-edge) lowest))
3444 (setq lowest (gnus-window-top-edge))
3445 (setq lowest-buf buf)))))
3446 (setq buffers (cdr buffers)))
3447 ;; Remove windows on *all* summary buffers.
3450 (let ((buf (window-buffer win)))
3451 (if (string-match "^\\*Summary" (buffer-name buf))
3453 (setq bufs (cons buf bufs))
3455 (if (or (not lowest)
3456 (< (gnus-window-top-edge) lowest))
3458 (setq lowest-buf buf)
3459 (setq lowest (gnus-window-top-edge)))))))))
3462 (pop-to-buffer lowest-buf)
3463 (switch-to-buffer nntp-server-buffer)))
3465 (and (not (eq (car bufs) lowest-buf))
3466 (delete-windows-on (car bufs)))
3467 (setq bufs (cdr bufs))))))
3469 (defun gnus-version ()
3470 "Version numbers of this version of Gnus."
3472 (let ((methods gnus-valid-select-methods)
3475 ;; Go through all the legal select methods and add their version
3476 ;; numbers to the total version string. Only the backends that are
3477 ;; currently in use will have their message numbers taken into
3480 (setq meth (intern (concat (caar methods) "-version")))
3482 (stringp (symbol-value meth))
3483 (setq mess (concat mess "; " (symbol-value meth))))
3484 (setq methods (cdr methods)))
3485 (gnus-message 2 mess)))
3487 (defun gnus-info-find-node ()
3488 "Find Info documentation of Gnus."
3490 ;; Enlarge info window if needed.
3491 (let ((mode major-mode)
3493 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3494 (setq gnus-info-buffer (current-buffer))
3495 (gnus-configure-windows 'info)))
3497 (defun gnus-days-between (date1 date2)
3498 ;; Return the number of days between date1 and date2.
3499 (- (gnus-day-number date1) (gnus-day-number date2)))
3501 (defun gnus-day-number (date)
3502 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3503 (timezone-parse-date date))))
3504 (timezone-absolute-from-gregorian
3505 (nth 1 dat) (nth 2 dat) (car dat))))
3507 (defun gnus-encode-date (date)
3508 "Convert DATE to internal time."
3509 (let* ((parse (timezone-parse-date date))
3510 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3511 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3512 (encode-time (caddr time) (cadr time) (car time)
3513 (caddr date) (cadr date) (car date) (nth 4 date))))
3515 (defun gnus-time-minus (t1 t2)
3516 "Subtract two internal times."
3517 (let ((borrow (< (cadr t1) (cadr t2))))
3518 (list (- (car t1) (car t2) (if borrow 1 0))
3519 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3521 (defun gnus-file-newer-than (file date)
3522 (let ((fdate (nth 5 (file-attributes file))))
3523 (or (> (car fdate) (car date))
3524 (and (= (car fdate) (car date))
3525 (> (nth 1 fdate) (nth 1 date))))))
3527 (defmacro gnus-local-set-keys (&rest plist)
3528 "Set the keys in PLIST in the current keymap."
3529 `(gnus-define-keys-1 (current-local-map) ',plist))
3531 (defmacro gnus-define-keys (keymap &rest plist)
3532 "Define all keys in PLIST in KEYMAP."
3533 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3535 (put 'gnus-define-keys 'lisp-indent-function 1)
3536 (put 'gnus-define-keys 'lisp-indent-hook 1)
3537 (put 'gnus-define-keymap 'lisp-indent-function 1)
3538 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3540 (defmacro gnus-define-keymap (keymap &rest plist)
3541 "Define all keys in PLIST in KEYMAP."
3542 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3544 (defun gnus-define-keys-1 (keymap plist)
3546 (error "Can't set keys in a null keymap"))
3547 (cond ((symbolp keymap)
3548 (setq keymap (symbol-value keymap)))
3551 (set (car keymap) nil)
3552 (define-prefix-command (car keymap))
3553 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3554 (setq keymap (symbol-value (car keymap)))))
3557 (when (symbolp (setq key (pop plist)))
3558 (setq key (symbol-value key)))
3559 (define-key keymap key (pop plist)))))
3561 (defun gnus-group-read-only-p (&optional group)
3562 "Check whether GROUP supports editing or not.
3563 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3564 that that variable is buffer-local to the summary buffers."
3565 (let ((group (or group gnus-newsgroup-name)))
3566 (not (gnus-check-backend-function 'request-replace-article group))))
3568 (defun gnus-group-total-expirable-p (group)
3569 "Check whether GROUP is total-expirable or not."
3570 (let ((params (gnus-info-params (gnus-get-info group))))
3571 (or (memq 'total-expire params)
3572 (cdr (assq 'total-expire params)) ; (total-expire . t)
3573 (and gnus-total-expirable-newsgroups ; Check var.
3574 (string-match gnus-total-expirable-newsgroups group)))))
3576 (defun gnus-group-auto-expirable-p (group)
3577 "Check whether GROUP is total-expirable or not."
3578 (let ((params (gnus-info-params (gnus-get-info group))))
3579 (or (memq 'auto-expire params)
3580 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3581 (and gnus-auto-expirable-newsgroups ; Check var.
3582 (string-match gnus-auto-expirable-newsgroups group)))))
3584 (defun gnus-virtual-group-p (group)
3585 "Say whether GROUP is virtual or not."
3586 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3587 gnus-valid-select-methods)))
3589 (defun gnus-news-group-p (group &optional article)
3590 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3591 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3592 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3593 (eq (gnus-request-type group article) 'news))))
3595 (defsubst gnus-simplify-subject-fully (subject)
3596 "Simplify a subject string according to the user's wishes."
3598 ((null gnus-summary-gather-subject-limit)
3599 (gnus-simplify-subject-re subject))
3600 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3601 (gnus-simplify-subject-fuzzy subject))
3602 ((numberp gnus-summary-gather-subject-limit)
3603 (gnus-limit-string (gnus-simplify-subject-re subject)
3604 gnus-summary-gather-subject-limit))
3608 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3609 "Check whether two subjects are equal. If optional argument
3610 simple-first is t, first argument is already simplified."
3612 ((null simple-first)
3613 (equal (gnus-simplify-subject-fully s1)
3614 (gnus-simplify-subject-fully s2)))
3617 (gnus-simplify-subject-fully s2)))))
3619 ;; Returns a list of writable groups.
3620 (defun gnus-writable-groups ()
3621 (let ((alist gnus-newsrc-alist)
3623 (while (setq group (car (pop alist)))
3624 (unless (gnus-group-read-only-p group)
3625 (push group groups)))
3628 (defun gnus-completing-read (default prompt &rest args)
3629 ;; Like `completing-read', except that DEFAULT is the default argument.
3630 (let* ((prompt (concat prompt " (default " default ") "))
3631 (answer (apply 'completing-read prompt args)))
3632 (if (or (null answer) (zerop (length answer)))
3636 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3638 (defun gnus-y-or-n-p (prompt)
3643 (defun gnus-yes-or-no-p (prompt)
3645 (yes-or-no-p prompt)
3648 ;; Check whether to use long file names.
3649 (defun gnus-use-long-file-name (symbol)
3650 ;; The variable has to be set...
3651 (and gnus-use-long-file-name
3652 ;; If it isn't a list, then we return t.
3653 (or (not (listp gnus-use-long-file-name))
3654 ;; If it is a list, and the list contains `symbol', we
3656 (not (memq symbol gnus-use-long-file-name)))))
3658 ;; I suspect there's a better way, but I haven't taken the time to do
3659 ;; it yet. -erik selberg@cs.washington.edu
3660 (defun gnus-dd-mmm (messy-date)
3661 "Return a string like DD-MMM from a big messy string"
3662 (let ((datevec (timezone-parse-date messy-date)))
3665 ;; Make sure leading zeroes are stripped.
3666 (number-to-string (string-to-number (aref datevec 2)))
3670 (nth (1- (string-to-number (aref datevec 1)))
3671 timezone-months-assoc))
3674 ;; Make a hash table (default and minimum size is 255).
3675 ;; Optional argument HASHSIZE specifies the table size.
3676 (defun gnus-make-hashtable (&optional hashsize)
3677 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3679 ;; Make a number that is suitable for hashing; bigger than MIN and one
3681 (defun gnus-create-hash-size (min)
3687 ;; Show message if message has a lower level than `gnus-verbose'.
3688 ;; Guideline for numbers:
3689 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3690 ;; for things that take a long time, 7 - not very important messages
3691 ;; on stuff, 9 - messages inside loops.
3692 (defun gnus-message (level &rest args)
3693 (if (<= level gnus-verbose)
3694 (apply 'message args)
3695 ;; We have to do this format thingy here even if the result isn't
3696 ;; shown - the return value has to be the same as the return value
3698 (apply 'format args)))
3700 (defun gnus-error (level &rest args)
3701 "Beep an error if `gnus-verbose' is on LEVEL or less."
3702 (when (<= (floor level) gnus-verbose)
3703 (apply 'message args)
3706 (when (and (floatp level)
3707 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3708 (sit-for duration))))
3711 ;; Generate a unique new group name.
3712 (defun gnus-generate-new-group-name (leaf)
3715 (while (gnus-gethash name gnus-newsrc-hashtb)
3716 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3719 (defsubst gnus-hide-text (b e props)
3720 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3721 (add-text-properties b e props)
3722 (when (memq 'intangible props)
3723 (put-text-property (max (1- b) (point-min))
3724 b 'intangible (cddr (memq 'intangible props)))))
3726 (defsubst gnus-unhide-text (b e)
3727 "Remove hidden text properties from region between B and E."
3728 (remove-text-properties b e gnus-hidden-properties)
3729 (when (memq 'intangible gnus-hidden-properties)
3730 (put-text-property (max (1- b) (point-min))
3731 b 'intangible nil)))
3733 (defun gnus-hide-text-type (b e type)
3734 "Hide text of TYPE between B and E."
3735 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3737 ;; Find out whether the gnus-visual TYPE is wanted.
3738 (defun gnus-visual-p (&optional type class)
3739 (and gnus-visual ; Has to be non-nil, at least.
3740 (if (not type) ; We don't care about type.
3742 (if (listp gnus-visual) ; It's a list, so we check it.
3743 (or (memq type gnus-visual)
3744 (memq class gnus-visual))
3747 (defun gnus-parent-id (references)
3748 "Return the last Message-ID in REFERENCES."
3749 (when (and references
3750 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3751 (substring references (match-beginning 1) (match-end 1))))
3753 (defun gnus-split-references (references)
3754 "Return a list of Message-IDs in REFERENCES."
3757 (while (string-match "<[^>]+>" references beg)
3758 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3762 (defun gnus-buffer-live-p (buffer)
3763 "Say whether BUFFER is alive or not."
3766 (buffer-name (get-buffer buffer))))
3768 (defun gnus-ephemeral-group-p (group)
3769 "Say whether GROUP is ephemeral or not."
3770 (gnus-group-get-parameter group 'quit-config))
3772 (defun gnus-group-quit-config (group)
3773 "Return the quit-config of GROUP."
3774 (gnus-group-get-parameter group 'quit-config))
3776 (defun gnus-simplify-mode-line ()
3777 "Make mode lines a bit simpler."
3778 (setq mode-line-modified "-- ")
3779 (when (listp mode-line-format)
3780 (make-local-variable 'mode-line-format)
3781 (setq mode-line-format (copy-sequence mode-line-format))
3782 (when (equal (nth 3 mode-line-format) " ")
3783 (setcar (nthcdr 3 mode-line-format) " "))))
3785 ;;; List and range functions
3787 (defun gnus-last-element (list)
3788 "Return last element of LIST."
3790 (setq list (cdr list)))
3793 (defun gnus-copy-sequence (list)
3794 "Do a complete, total copy of a list."
3795 (if (and (consp list) (not (consp (cdr list))))
3796 (cons (car list) (cdr list))
3797 (mapcar (lambda (elem) (if (consp elem)
3798 (if (consp (cdr elem))
3799 (gnus-copy-sequence elem)
3800 (cons (car elem) (cdr elem)))
3804 (defun gnus-set-difference (list1 list2)
3805 "Return a list of elements of LIST1 that do not appear in LIST2."
3806 (let ((list1 (copy-sequence list1)))
3808 (setq list1 (delq (car list2) list1))
3809 (setq list2 (cdr list2)))
3812 (defun gnus-sorted-complement (list1 list2)
3813 "Return a list of elements of LIST1 that do not appear in LIST2.
3814 Both lists have to be sorted over <."
3816 (if (or (null list1) (null list2))
3818 (while (and list1 list2)
3819 (cond ((= (car list1) (car list2))
3820 (setq list1 (cdr list1)
3822 ((< (car list1) (car list2))
3823 (setq out (cons (car list1) out))
3824 (setq list1 (cdr list1)))
3826 (setq out (cons (car list2) out))
3827 (setq list2 (cdr list2)))))
3828 (nconc (nreverse out) (or list1 list2)))))
3830 (defun gnus-intersection (list1 list2)
3833 (if (memq (car list2) list1)
3834 (setq result (cons (car list2) result)))
3835 (setq list2 (cdr list2)))
3838 (defun gnus-sorted-intersection (list1 list2)
3839 ;; LIST1 and LIST2 have to be sorted over <.
3841 (while (and list1 list2)
3842 (cond ((= (car list1) (car list2))
3843 (setq out (cons (car list1) out)
3846 ((< (car list1) (car list2))
3847 (setq list1 (cdr list1)))
3849 (setq list2 (cdr list2)))))
3852 (defun gnus-set-sorted-intersection (list1 list2)
3853 ;; LIST1 and LIST2 have to be sorted over <.
3854 ;; This function modifies LIST1.
3855 (let* ((top (cons nil list1))
3857 (while (and list1 list2)
3858 (cond ((= (car list1) (car list2))
3862 ((< (car list1) (car list2))
3863 (setcdr prev (cdr list1))
3864 (setq list1 (cdr list1)))
3866 (setq list2 (cdr list2)))))
3870 (defun gnus-compress-sequence (numbers &optional always-list)
3871 "Convert list of numbers to a list of ranges or a single range.
3872 If ALWAYS-LIST is non-nil, this function will always release a list of
3874 (let* ((first (car numbers))
3875 (last (car numbers))
3879 (if (not (listp (cdr numbers)))
3882 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3883 ((= (1+ last) (car numbers)) ;Still in sequence
3884 (setq last (car numbers)))
3885 (t ;End of one sequence
3887 (cons (if (= first last) first
3888 (cons first last)) result))
3889 (setq first (car numbers))
3890 (setq last (car numbers))))
3891 (setq numbers (cdr numbers)))
3892 (if (and (not always-list) (null result))
3893 (if (= first last) (list first) (cons first last))
3894 (nreverse (cons (if (= first last) first (cons first last))
3897 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3898 (defun gnus-uncompress-range (ranges)
3899 "Expand a list of ranges into a list of numbers.
3900 RANGES is either a single range on the form `(num . num)' or a list of
3902 (let (first last result)
3906 ((not (listp (cdr ranges)))
3907 (setq first (car ranges))
3908 (setq last (cdr ranges))
3909 (while (<= first last)
3910 (setq result (cons first result))
3911 (setq first (1+ first)))
3915 (if (atom (car ranges))
3916 (if (numberp (car ranges))
3917 (setq result (cons (car ranges) result)))
3918 (setq first (caar ranges))
3919 (setq last (cdar ranges))
3920 (while (<= first last)
3921 (setq result (cons first result))
3922 (setq first (1+ first))))
3923 (setq ranges (cdr ranges)))
3924 (nreverse result)))))
3926 (defun gnus-add-to-range (ranges list)
3927 "Return a list of ranges that has all articles from both RANGES and LIST.
3928 Note: LIST has to be sorted over `<'."
3930 (gnus-compress-sequence list t)
3931 (setq list (copy-sequence list))
3932 (or (listp (cdr ranges))
3933 (setq ranges (list ranges)))
3935 ilist lowest highest temp)
3936 (while (and ranges list)
3938 (setq lowest (or (and (atom (car ranges)) (car ranges))
3940 (while (and list (cdr list) (< (cadr list) lowest))
3941 (setq list (cdr list)))
3942 (if (< (car ilist) lowest)
3945 (setq list (cdr list))
3947 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3948 (setq highest (or (and (atom (car ranges)) (car ranges))
3950 (while (and list (<= (car list) highest))
3951 (setq list (cdr list)))
3952 (setq ranges (cdr ranges)))
3954 (setq out (nconc (gnus-compress-sequence list t) out)))
3955 (setq out (sort out (lambda (r1 r2)
3956 (< (or (and (atom r1) r1) (car r1))
3957 (or (and (atom r2) r2) (car r2))))))
3960 (if (atom (car ranges))
3962 (if (atom (cadr ranges))
3963 (if (= (1+ (car ranges)) (cadr ranges))
3965 (setcar ranges (cons (car ranges)
3967 (setcdr ranges (cddr ranges))))
3968 (if (= (1+ (car ranges)) (caadr ranges))
3970 (setcar (cadr ranges) (car ranges))
3971 (setcar ranges (cadr ranges))
3972 (setcdr ranges (cddr ranges))))))
3974 (if (atom (cadr ranges))
3975 (if (= (1+ (cdar ranges)) (cadr ranges))
3977 (setcdr (car ranges) (cadr ranges))
3978 (setcdr ranges (cddr ranges))))
3979 (if (= (1+ (cdar ranges)) (caadr ranges))
3981 (setcdr (car ranges) (cdadr ranges))
3982 (setcdr ranges (cddr ranges)))))))
3983 (setq ranges (cdr ranges)))
3986 (defun gnus-remove-from-range (ranges list)
3987 "Return a list of ranges that has all articles from LIST removed from RANGES.
3988 Note: LIST has to be sorted over `<'."
3989 ;; !!! This function shouldn't look like this, but I've got a headache.
3990 (gnus-compress-sequence
3991 (gnus-sorted-complement
3992 (gnus-uncompress-range ranges) list)))
3994 (defun gnus-member-of-range (number ranges)
3995 (if (not (listp (cdr ranges)))
3996 (and (>= number (car ranges))
3997 (<= number (cdr ranges)))
4000 (if (numberp (car ranges))
4001 (>= number (car ranges))
4002 (>= number (caar ranges)))
4004 (if (if (numberp (car ranges))
4005 (= number (car ranges))
4006 (and (>= number (caar ranges))
4007 (<= number (cdar ranges))))
4008 (setq not-stop nil))
4009 (setq ranges (cdr ranges)))
4012 (defun gnus-range-length (range)
4013 "Return the length RANGE would have if uncompressed."
4014 (length (gnus-uncompress-range range)))
4016 (defun gnus-sublist-p (list sublist)
4017 "Test whether all elements in SUBLIST are members of LIST."
4020 (unless (memq (pop sublist) list)
4030 (defvar gnus-group-mode-map nil)
4031 (put 'gnus-group-mode 'mode-class 'special)
4033 (unless gnus-group-mode-map
4034 (setq gnus-group-mode-map (make-keymap))
4035 (suppress-keymap gnus-group-mode-map)
4037 (gnus-define-keys gnus-group-mode-map
4038 " " gnus-group-read-group
4039 "=" gnus-group-select-group
4040 "\r" gnus-group-select-group
4041 "\M-\r" gnus-group-quick-select-group
4042 "j" gnus-group-jump-to-group
4043 "n" gnus-group-next-unread-group
4044 "p" gnus-group-prev-unread-group
4045 "\177" gnus-group-prev-unread-group
4046 [delete] gnus-group-prev-unread-group
4047 "N" gnus-group-next-group
4048 "P" gnus-group-prev-group
4049 "\M-n" gnus-group-next-unread-group-same-level
4050 "\M-p" gnus-group-prev-unread-group-same-level
4051 "," gnus-group-best-unread-group
4052 "." gnus-group-first-unread-group
4053 "u" gnus-group-unsubscribe-current-group
4054 "U" gnus-group-unsubscribe-group
4055 "c" gnus-group-catchup-current
4056 "C" gnus-group-catchup-current-all
4057 "l" gnus-group-list-groups
4058 "L" gnus-group-list-all-groups
4060 "g" gnus-group-get-new-news
4061 "\M-g" gnus-group-get-new-news-this-group
4062 "R" gnus-group-restart
4063 "r" gnus-group-read-init-file
4064 "B" gnus-group-browse-foreign-server
4065 "b" gnus-group-check-bogus-groups
4066 "F" gnus-find-new-newsgroups
4067 "\C-c\C-d" gnus-group-describe-group
4068 "\M-d" gnus-group-describe-all-groups
4069 "\C-c\C-a" gnus-group-apropos
4070 "\C-c\M-\C-a" gnus-group-description-apropos
4071 "a" gnus-group-post-news
4072 "\ek" gnus-group-edit-local-kill
4073 "\eK" gnus-group-edit-global-kill
4074 "\C-k" gnus-group-kill-group
4075 "\C-y" gnus-group-yank-group
4076 "\C-w" gnus-group-kill-region
4077 "\C-x\C-t" gnus-group-transpose-groups
4078 "\C-c\C-l" gnus-group-list-killed
4079 "\C-c\C-x" gnus-group-expire-articles
4080 "\C-c\M-\C-x" gnus-group-expire-all-groups
4082 "s" gnus-group-save-newsrc
4083 "z" gnus-group-suspend
4084 "Z" gnus-group-clear-dribble
4087 "?" gnus-group-describe-briefly
4088 "\C-c\C-i" gnus-info-find-node
4089 "\M-e" gnus-group-edit-group-method
4090 "^" gnus-group-enter-server-mode
4091 gnus-mouse-2 gnus-mouse-pick-group
4092 "<" beginning-of-buffer
4095 "\C-c\C-s" gnus-group-sort-groups
4097 "\C-c\M-g" gnus-activate-all-groups
4098 "\M-&" gnus-group-universal-argument
4099 "#" gnus-group-mark-group
4100 "\M-#" gnus-group-unmark-group)
4102 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4103 "m" gnus-group-mark-group
4104 "u" gnus-group-unmark-group
4105 "w" gnus-group-mark-region
4106 "m" gnus-group-mark-buffer
4107 "r" gnus-group-mark-regexp
4108 "U" gnus-group-unmark-all-groups)
4110 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4111 "d" gnus-group-make-directory-group
4112 "h" gnus-group-make-help-group
4113 "a" gnus-group-make-archive-group
4114 "k" gnus-group-make-kiboze-group
4115 "m" gnus-group-make-group
4116 "E" gnus-group-edit-group
4117 "e" gnus-group-edit-group-method
4118 "p" gnus-group-edit-group-parameters
4119 "v" gnus-group-add-to-virtual
4120 "V" gnus-group-make-empty-virtual
4121 "D" gnus-group-enter-directory
4122 "f" gnus-group-make-doc-group
4123 "r" gnus-group-rename-group
4124 "\177" gnus-group-delete-group
4125 [delete] gnus-group-delete-group)
4127 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4128 "b" gnus-group-brew-soup
4129 "w" gnus-soup-save-areas
4130 "s" gnus-soup-send-replies
4131 "p" gnus-soup-pack-packet
4132 "r" nnsoup-pack-replies)
4134 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4135 "s" gnus-group-sort-groups
4136 "a" gnus-group-sort-groups-by-alphabet
4137 "u" gnus-group-sort-groups-by-unread
4138 "l" gnus-group-sort-groups-by-level
4139 "v" gnus-group-sort-groups-by-score
4140 "r" gnus-group-sort-groups-by-rank
4141 "m" gnus-group-sort-groups-by-method)
4143 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4144 "k" gnus-group-list-killed
4145 "z" gnus-group-list-zombies
4146 "s" gnus-group-list-groups
4147 "u" gnus-group-list-all-groups
4148 "A" gnus-group-list-active
4149 "a" gnus-group-apropos
4150 "d" gnus-group-description-apropos
4151 "m" gnus-group-list-matching
4152 "M" gnus-group-list-all-matching
4153 "l" gnus-group-list-level)
4155 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4156 "f" gnus-score-flush-cache)
4158 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4159 "f" gnus-group-fetch-faq)
4161 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4162 "l" gnus-group-set-current-level
4163 "t" gnus-group-unsubscribe-current-group
4164 "s" gnus-group-unsubscribe-group
4165 "k" gnus-group-kill-group
4166 "y" gnus-group-yank-group
4167 "w" gnus-group-kill-region
4168 "\C-k" gnus-group-kill-level
4169 "z" gnus-group-kill-all-zombies))
4171 (defun gnus-group-mode ()
4172 "Major mode for reading news.
4174 All normal editing commands are switched off.
4175 \\<gnus-group-mode-map>
4176 The group buffer lists (some of) the groups available. For instance,
4177 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4178 lists all zombie groups.
4180 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4181 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4183 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4185 The following commands are available:
4187 \\{gnus-group-mode-map}"
4189 (when (and menu-bar-mode
4190 (gnus-visual-p 'group-menu 'menu))
4191 (gnus-group-make-menu-bar))
4192 (kill-all-local-variables)
4193 (gnus-simplify-mode-line)
4194 (setq major-mode 'gnus-group-mode)
4195 (setq mode-name "Group")
4196 (gnus-group-set-mode-line)
4197 (setq mode-line-process nil)
4198 (use-local-map gnus-group-mode-map)
4199 (buffer-disable-undo (current-buffer))
4200 (setq truncate-lines t)
4201 (setq buffer-read-only t)
4202 (run-hooks 'gnus-group-mode-hook))
4204 (defun gnus-mouse-pick-group (e)
4205 "Enter the group under the mouse pointer."
4208 (gnus-group-read-group nil))
4210 ;; Look at LEVEL and find out what the level is really supposed to be.
4211 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4212 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4213 (defun gnus-group-default-level (&optional level number-or-nil)
4215 (gnus-group-use-permanent-levels
4216 ; (setq gnus-group-default-list-level
4217 ; (or level gnus-group-default-list-level))
4218 (or level gnus-group-default-list-level gnus-level-subscribed))
4222 (or level gnus-group-default-list-level gnus-level-subscribed))))
4225 (defun gnus-slave-no-server (&optional arg)
4226 "Read network news as a slave, without connecting to local server"
4228 (gnus-no-server arg t))
4231 (defun gnus-no-server (&optional arg slave)
4233 If ARG is a positive number, Gnus will use that as the
4234 startup level. If ARG is nil, Gnus will be started at level 2.
4235 If ARG is non-nil and not a positive number, Gnus will
4236 prompt the user for the name of an NNTP server to use.
4237 As opposed to `gnus', this command will not connect to the local server."
4239 (let ((gnus-group-use-permanent-levels t))
4240 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4241 (make-local-variable 'gnus-group-use-permanent-levels)
4242 (setq gnus-group-use-permanent-levels t))
4245 (defun gnus-slave (&optional arg)
4246 "Read news as a slave."
4248 (gnus arg nil 'slave))
4251 (defun gnus-other-frame (&optional arg)
4252 "Pop up a frame to read news."
4254 (if (get-buffer gnus-group-buffer)
4255 (let ((pop-up-frames t))
4257 (select-frame (make-frame))
4261 (defun gnus (&optional arg dont-connect slave)
4263 If ARG is non-nil and a positive number, Gnus will use that as the
4264 startup level. If ARG is non-nil and not a positive number, Gnus will
4265 prompt the user for the name of an NNTP server to use."
4268 (if (get-buffer gnus-group-buffer)
4270 (switch-to-buffer gnus-group-buffer)
4271 (gnus-group-get-new-news))
4274 (nnheader-init-server-buffer)
4275 (gnus-read-init-file)
4276 (setq gnus-slave slave)
4278 (gnus-group-setup-buffer)
4279 (let ((buffer-read-only nil))
4281 (if (not gnus-inhibit-startup-message)
4283 (gnus-group-startup-message)
4286 (let ((level (and (numberp arg) (> arg 0) arg))
4292 (gnus-start-news-server (and arg (not level))))))
4293 (if (and (not dont-connect)
4296 (run-hooks 'gnus-startup-hook)
4297 ;; NNTP server is successfully open.
4299 ;; Find the current startup file name.
4300 (setq gnus-current-startup-file
4301 (gnus-make-newsrc-file gnus-startup-file))
4303 ;; Read the dribble file.
4304 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4306 ;; Allow using GroupLens predictions.
4307 (when gnus-use-grouplens
4309 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4311 (gnus-summary-make-display-table)
4312 ;; Do the actual startup.
4313 (gnus-setup-news nil level dont-connect)
4314 ;; Generate the group buffer.
4315 (gnus-group-list-groups level)
4316 (gnus-group-first-unread-group)
4317 (gnus-configure-windows 'group)
4318 (gnus-group-set-mode-line))))))
4320 (defun gnus-unload ()
4321 "Unload all Gnus features."
4323 (or (boundp 'load-history)
4324 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4325 (let ((history load-history)
4328 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4329 (setq feature (cdr (assq 'provide (car history))))
4330 (unload-feature feature 'force))
4331 (setq history (cdr history)))))
4333 (defun gnus-compile ()
4334 "Byte-compile the user-defined format specs."
4336 (let ((entries gnus-format-specs)
4337 entry gnus-tmp-func)
4339 (gnus-message 7 "Compiling format specs...")
4342 (setq entry (pop entries))
4343 (if (eq (car entry) 'version)
4344 (setq gnus-format-specs (delq entry gnus-format-specs))
4345 (when (and (listp (caddr entry))
4346 (not (eq 'byte-code (caaddr entry))))
4347 (fset 'gnus-tmp-func
4348 `(lambda () ,(caddr entry)))
4349 (byte-compile 'gnus-tmp-func)
4350 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4352 (push (cons 'version emacs-version) gnus-format-specs)
4354 (gnus-message 7 "Compiling user specs...done"))))
4356 (defun gnus-indent-rigidly (start end arg)
4357 "Indent rigidly using only spaces and no tabs."
4360 (narrow-to-region start end)
4361 (indent-rigidly start end arg)
4362 (goto-char (point-min))
4363 (while (search-forward "\t" nil t)
4364 (replace-match " " t t)))))
4366 (defun gnus-group-startup-message (&optional x y)
4367 "Insert startup message in current buffer."
4368 ;; Insert the message.
4373 _ ___ __ ___ __ _ ___
4392 ;; And then hack it.
4393 (gnus-indent-rigidly (point-min) (point-max)
4394 (/ (max (- (window-width) (or x 46)) 0) 2))
4395 (goto-char (point-min))
4397 (let* ((pheight (count-lines (point-min) (point-max)))
4398 (wheight (window-height))
4399 (rest (- wheight pheight)))
4400 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4402 (goto-char (point-min))
4403 (and (search-forward "Praxis" nil t)
4404 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4405 (goto-char (point-min))
4406 (let* ((mode-string (gnus-group-set-mode-line)))
4407 (setq mode-line-buffer-identification
4408 (list (concat gnus-version (substring (car mode-string) 4))))
4409 (set-buffer-modified-p t)))
4411 (defun gnus-group-setup-buffer ()
4412 (or (get-buffer gnus-group-buffer)
4414 (switch-to-buffer gnus-group-buffer)
4415 (gnus-add-current-to-buffer-list)
4417 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4419 (defun gnus-group-list-groups (&optional level unread lowest)
4420 "List newsgroups with level LEVEL or lower that have unread articles.
4421 Default is all subscribed groups.
4422 If argument UNREAD is non-nil, groups with no unread articles are also
4424 (interactive (list (if current-prefix-arg
4425 (prefix-numeric-value current-prefix-arg)
4427 (gnus-group-default-level nil t)
4428 gnus-group-default-list-level
4429 gnus-level-subscribed))))
4431 (setq level (car gnus-group-list-mode)
4432 unread (cdr gnus-group-list-mode)))
4433 (setq level (gnus-group-default-level level))
4434 (gnus-group-setup-buffer) ;May call from out of group buffer
4435 (gnus-update-format-specifications)
4436 (let ((case-fold-search nil)
4437 (props (text-properties-at (gnus-point-at-bol)))
4438 (group (gnus-group-group-name)))
4439 (set-buffer gnus-group-buffer)
4440 (funcall gnus-group-prepare-function level unread lowest)
4441 (if (zerop (buffer-size))
4442 (gnus-message 5 gnus-no-groups-message)
4443 (goto-char (point-max))
4444 (when (or (not gnus-group-goto-next-group-function)
4445 (not (funcall gnus-group-goto-next-group-function
4448 ;; Go to the first group with unread articles.
4449 (gnus-group-search-forward t)
4450 ;; Find the right group to put point on. If the current group
4451 ;; has disappeared in the new listing, try to find the next
4452 ;; one. If no next one can be found, just leave point at the
4453 ;; first newsgroup in the buffer.
4454 (if (not (gnus-goto-char
4456 (point-min) (point-max)
4457 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4458 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4460 (not (gnus-goto-char
4462 (point-min) (point-max) 'gnus-group
4464 (caar newsrc) gnus-active-hashtb)))))
4465 (setq newsrc (cdr newsrc)))
4466 (or newsrc (progn (goto-char (point-max))
4467 (forward-line -1)))))))
4468 ;; Adjust cursor point.
4469 (gnus-group-position-point))))
4471 (defun gnus-group-list-level (level &optional all)
4472 "List groups on LEVEL.
4473 If ALL (the prefix), also list groups that have no unread articles."
4474 (interactive "nList groups on level: \nP")
4475 (gnus-group-list-groups level all level))
4477 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4478 "List all newsgroups with unread articles of level LEVEL or lower.
4479 If ALL is non-nil, list groups that have no unread articles.
4480 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4481 If REGEXP, only list groups matching REGEXP."
4482 (set-buffer gnus-group-buffer)
4483 (let ((buffer-read-only nil)
4484 (newsrc (cdr gnus-newsrc-alist))
4485 (lowest (or lowest 1))
4486 info clevel unread group params)
4488 (if (< lowest gnus-level-zombie)
4489 ;; List living groups.
4491 (setq info (car newsrc)
4492 group (gnus-info-group info)
4493 params (gnus-info-params info)
4495 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4496 (and unread ; This group might be bogus
4498 (string-match regexp group))
4499 (<= (setq clevel (gnus-info-level info)) level)
4501 (or all ; We list all groups?
4502 (if (eq unread t) ; Unactivated?
4503 gnus-group-list-inactive-groups ; We list unactivated
4504 (> unread 0)) ; We list groups with unread articles
4505 (and gnus-list-groups-with-ticked-articles
4506 (cdr (assq 'tick (gnus-info-marks info))))
4507 ; And groups with tickeds
4508 ;; Check for permanent visibility.
4509 (and gnus-permanently-visible-groups
4510 (string-match gnus-permanently-visible-groups
4512 (memq 'visible params)
4513 (cdr (assq 'visible params)))
4514 (gnus-group-insert-group-line
4515 group (gnus-info-level info)
4516 (gnus-info-marks info) unread (gnus-info-method info)))))
4518 ;; List dead groups.
4519 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4520 (gnus-group-prepare-flat-list-dead
4521 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4522 gnus-level-zombie ?Z
4524 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4525 (gnus-group-prepare-flat-list-dead
4526 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4527 gnus-level-killed ?K regexp))
4529 (gnus-group-set-mode-line)
4530 (setq gnus-group-list-mode (cons level all))
4531 (run-hooks 'gnus-group-prepare-hook)))
4533 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4534 ;; List zombies and killed lists somewhat faster, which was
4535 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4536 ;; this by ignoring the group format specification altogether.
4539 ;; This loop is used when listing groups that match some
4542 (setq group (pop groups))
4543 (when (string-match regexp group)
4544 (add-text-properties
4545 (point) (prog1 (1+ (point))
4546 (insert " " mark " *: " group "\n"))
4547 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4549 'gnus-level level))))
4550 ;; This loop is used when listing all groups.
4552 (add-text-properties
4553 (point) (prog1 (1+ (point))
4554 (insert " " mark " *: "
4555 (setq group (pop groups)) "\n"))
4556 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4558 'gnus-level level))))))
4560 (defmacro gnus-group-real-name (group)
4561 "Find the real name of a foreign newsgroup."
4562 `(let ((gname ,group))
4563 (if (string-match ":[^:]+$" gname)
4564 (substring gname (1+ (match-beginning 0)))
4567 (defsubst gnus-server-add-address (method)
4568 (let ((method-name (symbol-name (car method))))
4569 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4570 (not (assq (intern (concat method-name "-address")) method)))
4571 (append method (list (list (intern (concat method-name "-address"))
4575 (defsubst gnus-server-get-method (group method)
4576 ;; Input either a server name, and extended server name, or a
4577 ;; select method, and return a select method.
4578 (cond ((stringp method)
4579 (gnus-server-to-method method))
4580 ((equal method gnus-select-method)
4582 ((and (stringp (car method)) group)
4583 (gnus-server-extend-method group method))
4584 ((and method (not group)
4585 (equal (cadr method) ""))
4588 (gnus-server-add-address method))))
4590 (defun gnus-server-to-method (server)
4591 "Map virtual server names to select methods."
4593 ;; Perhaps this is the native server?
4594 (and (equal server "native") gnus-select-method)
4595 ;; It should be in the server alist.
4596 (cdr (assoc server gnus-server-alist))
4597 ;; If not, we look through all the opened server
4598 ;; to see whether we can find it there.
4599 (let ((opened gnus-opened-servers))
4601 (not (equal server (format "%s:%s" (caaar opened)
4606 (defmacro gnus-method-equal (ss1 ss2)
4607 "Say whether two servers are equal."
4611 (and (= (length s1) (length s2))
4613 (while (and s1 (member (car s1) s2))
4617 (defun gnus-server-equal (m1 m2)
4618 "Say whether two methods are equal."
4619 (let ((m1 (cond ((null m1) gnus-select-method)
4620 ((stringp m1) (gnus-server-to-method m1))
4622 (m2 (cond ((null m2) gnus-select-method)
4623 ((stringp m2) (gnus-server-to-method m2))
4625 (gnus-method-equal m1 m2)))
4627 (defun gnus-servers-using-backend (backend)
4628 "Return a list of known servers using BACKEND."
4629 (let ((opened gnus-opened-servers)
4632 (when (eq backend (caaar opened))
4633 (push (caar opened) out))
4637 (defun gnus-group-prefixed-name (group method)
4638 "Return the whole name from GROUP and METHOD."
4639 (and (stringp method) (setq method (gnus-server-to-method method)))
4640 (concat (format "%s" (car method))
4642 (or (assoc (format "%s" (car method))
4643 (gnus-methods-using 'address))
4644 (gnus-server-equal method gnus-message-archive-method))
4646 (not (string= (nth 1 method) "")))
4647 (concat "+" (nth 1 method)))
4650 (defun gnus-group-real-prefix (group)
4651 "Return the prefix of the current group name."
4652 (if (string-match "^[^:]+:" group)
4653 (substring group 0 (match-end 0))
4656 (defun gnus-group-method (group)
4657 "Return the server or method used for selecting GROUP."
4658 (let ((prefix (gnus-group-real-prefix group)))
4659 (if (equal prefix "")
4661 (let ((servers gnus-opened-servers)
4663 backend possible found)
4664 (if (string-match "^[^\\+]+\\+" prefix)
4665 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4666 server (substring prefix (match-end 0) (1- (length prefix))))
4667 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4669 (when (eq (caaar servers) backend)
4670 (setq possible (caar servers))
4671 (when (equal (cadaar servers) server)
4672 (setq found (caar servers))))
4674 (or (car (rassoc found gnus-server-alist))
4676 (car (rassoc possible gnus-server-alist))
4678 (list backend server))))))
4680 (defsubst gnus-secondary-method-p (method)
4681 "Return whether METHOD is a secondary select method."
4682 (let ((methods gnus-secondary-select-methods)
4683 (gmethod (gnus-server-get-method nil method)))
4685 (not (equal (gnus-server-get-method nil (car methods))
4687 (setq methods (cdr methods)))
4690 (defun gnus-group-foreign-p (group)
4691 "Say whether a group is foreign or not."
4692 (and (not (gnus-group-native-p group))
4693 (not (gnus-group-secondary-p group))))
4695 (defun gnus-group-native-p (group)
4696 "Say whether the group is native or not."
4697 (not (string-match ":" group)))
4699 (defun gnus-group-secondary-p (group)
4700 "Say whether the group is secondary or not."
4701 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4703 (defun gnus-group-get-parameter (group &optional symbol)
4704 "Returns the group parameters for GROUP.
4705 If SYMBOL, return the value of that symbol in the group parameters."
4706 (let ((params (gnus-info-params (gnus-get-info group))))
4708 (gnus-group-parameter-value params symbol)
4711 (defun gnus-group-parameter-value (params symbol)
4712 "Return the value of SYMBOL in group PARAMS."
4713 (or (car (memq symbol params)) ; It's either a simple symbol
4714 (cdr (assq symbol params)))) ; or a cons.
4716 (defun gnus-group-add-parameter (group param)
4717 "Add parameter PARAM to GROUP."
4718 (let ((info (gnus-get-info group)))
4720 () ; This is a dead group. We just ignore it.
4721 ;; Cons the new param to the old one and update.
4722 (gnus-group-set-info (cons param (gnus-info-params info))
4725 (defun gnus-group-set-parameter (group name value)
4726 "Set parameter NAME to VALUE in GROUP."
4727 (let ((info (gnus-get-info group)))
4729 () ; This is a dead group. We just ignore it.
4730 (let ((old-params (gnus-info-params info))
4731 (new-params (list (cons name value))))
4733 (if (or (not (listp (car old-params)))
4734 (not (eq (caar old-params) name)))
4735 (setq new-params (append new-params (list (car old-params)))))
4736 (setq old-params (cdr old-params)))
4737 (gnus-group-set-info new-params group 'params)))))
4739 (defun gnus-group-add-score (group &optional score)
4740 "Add SCORE to the GROUP score.
4741 If SCORE is nil, add 1 to the score of GROUP."
4742 (let ((info (gnus-get-info group)))
4744 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4746 (defun gnus-summary-bubble-group ()
4747 "Increase the score of the current group.
4748 This is a handy function to add to `gnus-summary-exit-hook' to
4749 increase the score of each group you read."
4750 (gnus-group-add-score gnus-newsgroup-name))
4752 (defun gnus-group-set-info (info &optional method-only-group part)
4753 (let* ((entry (gnus-gethash
4754 (or method-only-group (gnus-info-group info))
4755 gnus-newsrc-hashtb))
4757 (info (if method-only-group (nth 2 entry) info))
4759 (when method-only-group
4761 (error "Trying to change non-existent group %s" method-only-group))
4762 ;; We have received parts of the actual group info - either the
4763 ;; select method or the group parameters. We first check
4764 ;; whether we have to extend the info, and if so, do that.
4765 (let ((len (length info))
4766 (total (if (eq part 'method) 5 6)))
4768 (setcdr (nthcdr (1- len) info)
4769 (make-list (- total len) nil)))
4770 ;; Then we enter the new info.
4771 (setcar (nthcdr (1- total) info) part-info)))
4773 ;; This is a new group, so we just create it.
4775 (set-buffer gnus-group-buffer)
4776 (setq method (gnus-info-method info))
4777 (when (gnus-server-equal method "native")
4780 (set-buffer gnus-group-buffer)
4782 ;; It's a foreign group...
4783 (gnus-group-make-group
4784 (gnus-group-real-name (gnus-info-group info))
4785 (if (stringp method) method
4786 (prin1-to-string (car method)))
4788 (nth 1 (gnus-info-method info))))
4789 ;; It's a native group.
4790 (gnus-group-make-group (gnus-info-group info))))
4791 (gnus-message 6 "Note: New group created")
4793 (gnus-gethash (gnus-group-prefixed-name
4794 (gnus-group-real-name (gnus-info-group info))
4795 (or (gnus-info-method info) gnus-select-method))
4796 gnus-newsrc-hashtb))))
4797 ;; Whether it was a new group or not, we now have the entry, so we
4798 ;; can do the update.
4801 (setcar (nthcdr 2 entry) info)
4802 (when (and (not (eq (car entry) t))
4803 (gnus-active (gnus-info-group info)))
4804 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4805 (error "No such group: %s" (gnus-info-group info)))))
4807 (defun gnus-group-set-method-info (group select-method)
4808 (gnus-group-set-info select-method group 'method))
4810 (defun gnus-group-set-params-info (group params)
4811 (gnus-group-set-info params group 'params))
4813 (defun gnus-group-update-group-line ()
4814 "Update the current line in the group buffer."
4815 (let* ((buffer-read-only nil)
4816 (group (gnus-group-group-name))
4817 (gnus-group-indentation (gnus-group-group-indentation))
4818 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4820 (not (gnus-ephemeral-group-p group))
4822 (concat "(gnus-group-set-info '"
4823 (prin1-to-string (nth 2 entry)) ")")))
4825 (gnus-group-insert-group-line-info group)
4827 (gnus-group-position-point)))
4829 (defun gnus-group-insert-group-line-info (group)
4830 "Insert GROUP on the current line."
4831 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4833 (setq gnus-group-indentation (gnus-group-group-indentation))
4836 ;; (Un)subscribed group.
4837 (setq info (nth 2 entry))
4838 (gnus-group-insert-group-line
4839 group (gnus-info-level info) (gnus-info-marks info)
4840 (or (car entry) t) (gnus-info-method info)))
4841 ;; This group is dead.
4842 (gnus-group-insert-group-line
4844 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4846 (if (setq active (gnus-active group))
4847 (- (1+ (cdr active)) (car active)) 0)
4850 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4851 gnus-tmp-marked number
4853 "Insert a group line in the group buffer."
4854 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4855 (gnus-tmp-number-total
4857 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4859 (gnus-tmp-number-of-unread
4860 (if (numberp number) (int-to-string (max 0 number))
4862 (gnus-tmp-number-of-read
4863 (if (numberp number)
4864 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4866 (gnus-tmp-subscribed
4867 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4868 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4869 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4871 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4872 (gnus-tmp-newsgroup-description
4873 (if gnus-description-hashtb
4874 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4877 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4878 (gnus-tmp-moderated-string
4879 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4881 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4882 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4883 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4884 (gnus-tmp-news-method-string
4886 (format "(%s:%s)" (car gnus-tmp-method)
4887 (cadr gnus-tmp-method)) ""))
4888 (gnus-tmp-marked-mark
4889 (if (and (numberp number)
4891 (cdr (assq 'tick gnus-tmp-marked)))
4893 (gnus-tmp-process-marked
4894 (if (member gnus-tmp-group gnus-group-marked)
4895 gnus-process-mark ? ))
4897 (or (and gnus-use-grouplens
4898 (bbb-grouplens-group-p gnus-tmp-group))
4900 (buffer-read-only nil)
4901 header gnus-tmp-header) ; passed as parameter to user-funcs.
4903 (add-text-properties
4907 (eval gnus-group-line-format-spec))
4908 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4909 gnus-unread ,(if (numberp number)
4910 (string-to-int gnus-tmp-number-of-unread)
4912 gnus-marked ,gnus-tmp-marked-mark
4913 gnus-indentation ,gnus-group-indentation
4914 gnus-level ,gnus-tmp-level))
4915 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4917 (run-hooks 'gnus-group-update-hook)
4919 ;; Allow XEmacs to remove front-sticky text properties.
4920 (gnus-group-remove-excess-properties)))
4922 (defun gnus-group-update-group (group &optional visible-only)
4923 "Update all lines where GROUP appear.
4924 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4927 (set-buffer gnus-group-buffer)
4928 ;; The buffer may be narrowed.
4931 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4933 found buffer-read-only)
4934 ;; Enter the current status into the dribble buffer.
4935 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4936 (if (and entry (not (gnus-ephemeral-group-p group)))
4938 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4940 ;; Find all group instances. If topics are in use, each group
4941 ;; may be listed in more than once.
4942 (while (setq loc (text-property-any
4943 loc (point-max) 'gnus-group ident))
4946 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4948 (gnus-group-insert-group-line-info group))
4949 (setq loc (1+ loc)))
4950 (unless (or found visible-only)
4951 ;; No such line in the buffer, find out where it's supposed to
4952 ;; go, and insert it there (or at the end of the buffer).
4953 (if gnus-goto-missing-group-function
4954 (funcall gnus-goto-missing-group-function group)
4955 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4956 (while (and entry (car entry)
4960 (point-min) (point-max)
4961 'gnus-group (gnus-intern-safe
4962 (caar entry) gnus-active-hashtb)))))
4963 (setq entry (cdr entry)))
4964 (or entry (goto-char (point-max)))))
4965 ;; Finally insert the line.
4966 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4967 (gnus-group-insert-group-line-info group)))
4968 (gnus-group-set-mode-line)))))
4970 (defun gnus-group-set-mode-line ()
4971 (when (memq 'group gnus-updated-mode-lines)
4972 (let* ((gformat (or gnus-group-mode-line-format-spec
4973 (setq gnus-group-mode-line-format-spec
4975 gnus-group-mode-line-format
4976 gnus-group-mode-line-format-alist))))
4977 (gnus-tmp-news-server (cadr gnus-select-method))
4978 (gnus-tmp-news-method (car gnus-select-method))
4980 gnus-tmp-header ;Dummy binding for user-defined formats
4981 ;; Get the resulting string.
4982 (mode-string (eval gformat)))
4983 ;; If the line is too long, we chop it off.
4984 (when (> (length mode-string) max-len)
4985 (setq mode-string (substring mode-string 0 (- max-len 4))))
4987 (setq mode-line-buffer-identification (list mode-string))
4988 (set-buffer-modified-p t)))))
4990 (defun gnus-group-group-name ()
4991 "Get the name of the newsgroup on the current line."
4992 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4993 (and group (symbol-name group))))
4995 (defun gnus-group-group-level ()
4996 "Get the level of the newsgroup on the current line."
4997 (get-text-property (gnus-point-at-bol) 'gnus-level))
4999 (defun gnus-group-group-indentation ()
5000 "Get the indentation of the newsgroup on the current line."
5001 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5002 (and gnus-group-indentation-function
5003 (funcall gnus-group-indentation-function))
5006 (defun gnus-group-group-unread ()
5007 "Get the number of unread articles of the newsgroup on the current line."
5008 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5010 (defun gnus-group-search-forward (&optional backward all level first-too)
5011 "Find the next newsgroup with unread articles.
5012 If BACKWARD is non-nil, find the previous newsgroup instead.
5013 If ALL is non-nil, just find any newsgroup.
5014 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5016 If FIRST-TOO, the current line is also eligible as a target."
5017 (let ((way (if backward -1 1))
5018 (low gnus-level-killed)
5021 (if (and backward (progn (beginning-of-line)) (bobp))
5023 (or first-too (forward-line way))
5031 (get-text-property (point) 'gnus-unread)))
5032 (and (numberp unread) (> unread 0)))
5033 (setq lev (get-text-property (point)
5035 (<= lev gnus-level-subscribed)))
5037 (and (setq lev (get-text-property (point)
5046 (zerop (forward-line way)))))
5048 (progn (gnus-group-position-point) t)
5049 (goto-char (or pos beg))
5052 ;;; Gnus group mode commands
5056 (defun gnus-group-mark-group (n &optional unmark no-advance)
5057 "Mark the current group."
5059 (let ((buffer-read-only nil)
5063 (setq group (gnus-group-group-name))
5067 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5072 (setq gnus-group-marked (delete group gnus-group-marked)))
5074 (setq gnus-group-marked
5075 (cons group (delete group gnus-group-marked))))
5077 (or no-advance (zerop (gnus-group-next-group 1))))
5079 (gnus-summary-position-point)
5082 (defun gnus-group-unmark-group (n)
5083 "Remove the mark from the current group."
5085 (gnus-group-mark-group n 'unmark)
5086 (gnus-group-position-point))
5088 (defun gnus-group-unmark-all-groups ()
5089 "Unmark all groups."
5091 (let ((groups gnus-group-marked))
5094 (gnus-group-remove-mark (pop groups)))))
5095 (gnus-group-position-point))
5097 (defun gnus-group-mark-region (unmark beg end)
5098 "Mark all groups between point and mark.
5099 If UNMARK, remove the mark instead."
5100 (interactive "P\nr")
5101 (let ((num (count-lines beg end)))
5104 (- num (gnus-group-mark-group num unmark)))))
5106 (defun gnus-group-mark-buffer (&optional unmark)
5107 "Mark all groups in the buffer.
5108 If UNMARK, remove the mark instead."
5110 (gnus-group-mark-region unmark (point-min) (point-max)))
5112 (defun gnus-group-mark-regexp (regexp)
5113 "Mark all groups that match some regexp."
5114 (interactive "sMark (regexp): ")
5115 (let ((alist (cdr gnus-newsrc-alist))
5118 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5119 (gnus-group-set-mark group))))
5120 (gnus-group-position-point))
5122 (defun gnus-group-remove-mark (group)
5123 "Remove the process mark from GROUP and move point there.
5124 Return nil if the group isn't displayed."
5125 (if (gnus-group-goto-group group)
5127 (gnus-group-mark-group 1 'unmark t)
5129 (setq gnus-group-marked
5130 (delete group gnus-group-marked))
5133 (defun gnus-group-set-mark (group)
5134 "Set the process mark on GROUP."
5135 (if (gnus-group-goto-group group)
5137 (gnus-group-mark-group 1 nil t))
5138 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5140 (defun gnus-group-universal-argument (arg &optional groups func)
5141 "Perform any command on all groups accoring to the process/prefix convention."
5143 (let ((groups (or groups (gnus-group-process-prefix arg)))
5145 (if (eq (setq func (or func
5148 (substitute-command-keys
5149 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5151 (gnus-error 1 "Undefined key")
5153 (gnus-group-remove-mark (setq group (pop groups)))
5154 (command-execute func))))
5155 (gnus-group-position-point))
5157 (defun gnus-group-process-prefix (n)
5158 "Return a list of groups to work on.
5159 Take into consideration N (the prefix) and the list of marked groups."
5162 (setq n (prefix-numeric-value n))
5163 ;; There is a prefix, so we return a list of the N next
5165 (let ((way (if (< n 0) -1 1))
5170 (setq group (gnus-group-group-name)))
5171 (setq groups (cons group groups))
5173 (gnus-group-next-group way)))
5175 ((and (boundp 'transient-mark-mode)
5178 ;; Work on the region between point and mark.
5179 (let ((max (max (point) (mark)))
5182 (goto-char (min (point) (mark)))
5185 (push (gnus-group-group-name) groups)
5186 (zerop (gnus-group-next-group 1))
5188 (nreverse groups))))
5190 ;; No prefix, but a list of marked articles.
5191 (reverse gnus-group-marked))
5193 ;; Neither marked articles or a prefix, so we return the
5195 (let ((group (gnus-group-group-name)))
5196 (and group (list group))))))
5198 ;; Selecting groups.
5200 (defun gnus-group-read-group (&optional all no-article group)
5201 "Read news in this newsgroup.
5202 If the prefix argument ALL is non-nil, already read articles become
5203 readable. IF ALL is a number, fetch this number of articles. If the
5204 optional argument NO-ARTICLE is non-nil, no article will be
5205 auto-selected upon group entry. If GROUP is non-nil, fetch that
5208 (let ((group (or group (gnus-group-group-name)))
5209 number active marked entry)
5210 (or group (error "No group on current line"))
5211 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5212 group gnus-newsrc-hashtb)))))
5213 ;; This group might be a dead group. In that case we have to get
5214 ;; the number of unread articles from `gnus-active-hashtb'.
5216 (cond ((numberp all) all)
5218 ((setq active (gnus-active group))
5219 (- (1+ (cdr active)) (car active)))))
5220 (gnus-summary-read-group
5221 group (or all (and (numberp number)
5222 (zerop (+ number (length (cdr (assq 'tick marked)))
5223 (length (cdr (assq 'dormant marked)))))))
5226 (defun gnus-group-select-group (&optional all)
5227 "Select this newsgroup.
5228 No article is selected automatically.
5229 If ALL is non-nil, already read articles become readable.
5230 If ALL is a number, fetch this number of articles."
5232 (gnus-group-read-group all t))
5234 (defun gnus-group-quick-select-group (&optional all)
5235 "Select the current group \"quickly\".
5236 This means that no highlighting or scoring will be performed."
5239 gnus-score-find-score-files-function
5240 gnus-apply-kill-hook
5241 gnus-summary-expunge-below)
5242 (gnus-group-read-group all t)))
5244 (defun gnus-group-visible-select-group (&optional all)
5245 "Select the current group without hiding any articles."
5247 (let ((gnus-inhibit-limiting t))
5248 (gnus-group-read-group all t)))
5251 (defun gnus-fetch-group (group)
5252 "Start Gnus if necessary and enter GROUP.
5253 Returns whether the fetching was successful or not."
5254 (interactive "sGroup name: ")
5255 (or (get-buffer gnus-group-buffer)
5257 (gnus-group-read-group nil nil group))
5259 ;; Enter a group that is not in the group buffer. Non-nil is returned
5260 ;; if selection was successful.
5261 (defun gnus-group-read-ephemeral-group
5262 (group method &optional activate quit-config)
5263 (let ((group (if (gnus-group-foreign-p group) group
5264 (gnus-group-prefixed-name group method))))
5267 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5268 ((quit-config . ,(if quit-config quit-config
5269 (cons (current-buffer) 'summary))))))
5271 (set-buffer gnus-group-buffer)
5272 (or (gnus-check-server method)
5273 (error "Unable to contact server: %s" (gnus-status-message method)))
5274 (if activate (or (gnus-request-group group)
5275 (error "Couldn't request group")))
5277 (gnus-group-read-group t t group)
5281 (defun gnus-group-jump-to-group (group)
5282 "Jump to newsgroup GROUP."
5284 (list (completing-read
5285 "Group: " gnus-active-hashtb nil
5286 (memq gnus-select-method gnus-have-read-active-file))))
5288 (when (equal group "")
5289 (error "Empty group name"))
5291 (when (string-match "[\000-\032]" group)
5292 (error "Control characters in group: %s" group))
5294 (let ((b (text-property-any
5295 (point-min) (point-max)
5296 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5297 (unless (gnus-ephemeral-group-p group)
5299 ;; Either go to the line in the group buffer...
5301 ;; ... or insert the line.
5304 (gnus-activate-group group)
5305 (error "%s error: %s" group (gnus-status-message group)))
5307 (gnus-group-update-group group)
5308 (goto-char (text-property-any
5309 (point-min) (point-max)
5310 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5311 ;; Adjust cursor point.
5312 (gnus-group-position-point)))
5314 (defun gnus-group-goto-group (group)
5315 "Goto to newsgroup GROUP."
5317 (let ((b (text-property-any (point-min) (point-max)
5318 'gnus-group (gnus-intern-safe
5319 group gnus-active-hashtb))))
5320 (and b (goto-char b)))))
5322 (defun gnus-group-next-group (n)
5323 "Go to next N'th newsgroup.
5324 If N is negative, search backward instead.
5325 Returns the difference between N and the number of skips actually
5328 (gnus-group-next-unread-group n t))
5330 (defun gnus-group-next-unread-group (n &optional all level)
5331 "Go to next N'th unread newsgroup.
5332 If N is negative, search backward instead.
5333 If ALL is non-nil, choose any newsgroup, unread or not.
5334 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5335 such group can be found, the next group with a level higher than
5337 Returns the difference between N and the number of skips actually
5340 (let ((backward (< n 0))
5343 (gnus-group-search-forward
5344 backward (or (not gnus-group-goto-unread) all) level))
5346 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5347 (if level " on this level or higher" "")))
5350 (defun gnus-group-prev-group (n)
5351 "Go to previous N'th newsgroup.
5352 Returns the difference between N and the number of skips actually
5355 (gnus-group-next-unread-group (- n) t))
5357 (defun gnus-group-prev-unread-group (n)
5358 "Go to previous N'th unread newsgroup.
5359 Returns the difference between N and the number of skips actually
5362 (gnus-group-next-unread-group (- n)))
5364 (defun gnus-group-next-unread-group-same-level (n)
5365 "Go to next N'th unread newsgroup on the same level.
5366 If N is negative, search backward instead.
5367 Returns the difference between N and the number of skips actually
5370 (gnus-group-next-unread-group n t (gnus-group-group-level))
5371 (gnus-group-position-point))
5373 (defun gnus-group-prev-unread-group-same-level (n)
5374 "Go to next N'th unread newsgroup on the same level.
5375 Returns the difference between N and the number of skips actually
5378 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5379 (gnus-group-position-point))
5381 (defun gnus-group-best-unread-group (&optional exclude-group)
5382 "Go to the group with the highest level.
5383 If EXCLUDE-GROUP, do not go to that group."
5385 (goto-char (point-min))
5389 (setq unread (get-text-property (point) 'gnus-unread))
5390 (if (and (numberp unread) (> unread 0))
5392 (if (and (get-text-property (point) 'gnus-level)
5393 (< (get-text-property (point) 'gnus-level) best)
5394 (or (not exclude-group)
5395 (not (equal exclude-group (gnus-group-group-name)))))
5397 (setq best (get-text-property (point) 'gnus-level))
5398 (setq best-point (point))))))
5400 (if best-point (goto-char best-point))
5401 (gnus-summary-position-point)
5402 (and best-point (gnus-group-group-name))))
5404 (defun gnus-group-first-unread-group ()
5405 "Go to the first group with unread articles."
5408 (let ((opoint (point))
5410 (goto-char (point-min))
5411 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5412 (and (numberp unread) ; Not a topic.
5413 (not (zerop unread))) ; Has unread articles.
5414 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5417 nil)) ; Not success.
5418 (gnus-group-position-point)))
5420 (defun gnus-group-enter-server-mode ()
5421 "Jump to the server buffer."
5423 (gnus-enter-server-buffer))
5425 (defun gnus-group-make-group (name &optional method address)
5426 "Add a new newsgroup.
5427 The user will be prompted for a NAME, for a select METHOD, and an
5431 (read-string "Group name: ")
5434 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5435 nil t nil 'gnus-method-history)))
5436 (cond ((assoc method gnus-valid-select-methods)
5438 (if (memq 'prompt-address
5439 (assoc method gnus-valid-select-methods))
5440 (read-string "Address: ")
5442 ((assoc method gnus-server-alist)
5445 (list method ""))))))
5447 (let* ((meth (and method (if address (list (intern method) address)
5449 (nname (if method (gnus-group-prefixed-name name meth) name))
5451 (when (gnus-gethash nname gnus-newsrc-hashtb)
5452 (error "Group %s already exists" nname))
5453 ;; Subscribe to the new group.
5454 (gnus-group-change-level
5455 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5456 gnus-level-default-subscribed gnus-level-killed
5457 (and (gnus-group-group-name)
5458 (gnus-gethash (gnus-group-group-name)
5459 gnus-newsrc-hashtb))
5462 (gnus-set-active nname (cons 1 0))
5463 (or (gnus-ephemeral-group-p name)
5465 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5467 (gnus-group-insert-group-line-info nname)
5469 (gnus-group-position-point)
5471 ;; Load the backend and try to make the backend create
5472 ;; the group as well.
5473 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5475 gnus-valid-select-methods)
5477 (gnus-check-server meth)
5478 (and (gnus-check-backend-function 'request-create-group nname)
5479 (gnus-request-create-group nname))
5482 (defun gnus-group-delete-group (group &optional force)
5483 "Delete the current group.
5484 If FORCE (the prefix) is non-nil, all the articles in the group will
5485 be deleted. This is \"deleted\" as in \"removed forever from the face
5486 of the Earth\". There is no undo."
5488 (list (gnus-group-group-name)
5489 current-prefix-arg))
5490 (or group (error "No group to rename"))
5491 (or (gnus-check-backend-function 'request-delete-group group)
5492 (error "This backend does not support group deletion"))
5494 (if (not (gnus-yes-or-no-p
5496 "Do you really want to delete %s%s? "
5497 group (if force " and all its contents" ""))))
5499 (gnus-message 6 "Deleting group %s..." group)
5500 (if (not (gnus-request-delete-group group force))
5501 (gnus-error 3 "Couldn't delete group %s" group)
5502 (gnus-message 6 "Deleting group %s...done" group)
5503 (gnus-group-goto-group group)
5504 (gnus-group-kill-group 1 t)
5505 (gnus-sethash group nil gnus-active-hashtb)
5507 (gnus-group-position-point)))
5509 (defun gnus-group-rename-group (group new-name)
5512 (gnus-group-group-name)
5514 (or (gnus-check-backend-function
5515 'request-rename-group (gnus-group-group-name))
5516 (error "This backend does not support renaming groups"))
5517 (read-string "New group name: "))))
5519 (or (gnus-check-backend-function 'request-rename-group group)
5520 (error "This backend does not support renaming groups"))
5522 (or group (error "No group to rename"))
5523 (and (string-match "^[ \t]*$" new-name)
5524 (error "Not a valid group name"))
5526 ;; We find the proper prefixed name.
5528 (gnus-group-prefixed-name
5529 (gnus-group-real-name new-name)
5530 (gnus-info-method (gnus-get-info group))))
5532 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5534 (if (not (gnus-request-rename-group group new-name))
5535 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5536 ;; We rename the group internally by killing it...
5537 (gnus-group-goto-group group)
5538 (gnus-group-kill-group)
5539 ;; ... changing its name ...
5540 (setcar (cdar gnus-list-of-killed-groups) new-name)
5541 ;; ... and then yanking it. Magic!
5542 (gnus-group-yank-group)
5543 (gnus-set-active new-name (gnus-active group))
5544 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5546 (gnus-group-position-point)))
5548 (defun gnus-group-edit-group (group &optional part)
5549 "Edit the group on the current line."
5550 (interactive (list (gnus-group-group-name)))
5551 (let* ((part (or part 'info))
5552 (done-func `(lambda ()
5553 "Exit editing mode and update the information."
5555 (gnus-group-edit-group-done ',part ,group)))
5556 (winconf (current-window-configuration))
5558 (or group (error "No group on current line"))
5559 (or (setq info (gnus-get-info group))
5560 (error "Killed group; can't be edited"))
5561 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5562 (gnus-configure-windows 'edit-group)
5563 (gnus-add-current-to-buffer-list)
5565 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5566 (use-local-map (copy-keymap emacs-lisp-mode-map))
5567 (local-set-key "\C-c\C-c" done-func)
5568 (make-local-variable 'gnus-prev-winconf)
5569 (setq gnus-prev-winconf winconf)
5574 ";; Type `C-c C-c' after editing the select method.\n\n")
5576 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5578 ";; Type `C-c C-c' after editing the group info.\n\n")))
5581 (cond ((eq part 'method)
5582 (or (gnus-info-method info) "native"))
5584 (gnus-info-params info))
5588 (defun gnus-group-edit-group-method (group)
5589 "Edit the select method of GROUP."
5590 (interactive (list (gnus-group-group-name)))
5591 (gnus-group-edit-group group 'method))
5593 (defun gnus-group-edit-group-parameters (group)
5594 "Edit the group parameters of GROUP."
5595 (interactive (list (gnus-group-group-name)))
5596 (gnus-group-edit-group group 'params))
5598 (defun gnus-group-edit-group-done (part group)
5599 "Get info from buffer, update variables and jump to the group buffer."
5600 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5601 (goto-char (point-min))
5602 (let* ((form (read (current-buffer)))
5603 (winconf gnus-prev-winconf)
5604 (method (cond ((eq part 'info) (nth 4 form))
5605 ((eq part 'method) form)
5607 (info (cond ((eq part 'info) form)
5608 ((eq part 'method) (gnus-get-info group))
5611 (if (or (not method)
5613 gnus-select-method method))
5614 (gnus-group-real-name (car info))
5615 (gnus-group-prefixed-name
5616 (gnus-group-real-name (car info)) method))
5618 (when (and new-group
5619 (not (equal new-group group)))
5620 (when (gnus-group-goto-group group)
5621 (gnus-group-kill-group 1))
5622 (gnus-activate-group new-group))
5624 (if (and info new-group)
5626 (setq info (gnus-copy-sequence info))
5627 (setcar info new-group)
5628 (unless (gnus-server-equal method "native")
5629 (unless (nthcdr 3 info)
5630 (nconc info (list nil nil)))
5631 (unless (nthcdr 4 info)
5632 (nconc info (list nil)))
5633 (gnus-info-set-method info method))
5634 (gnus-group-set-info info))
5635 (gnus-group-set-info form (or new-group group) part))
5636 (kill-buffer (current-buffer))
5637 (and winconf (set-window-configuration winconf))
5638 (set-buffer gnus-group-buffer)
5639 (gnus-group-update-group (or new-group group))
5640 (gnus-group-position-point)))
5642 (defun gnus-group-make-help-group ()
5643 "Create the Gnus documentation group."
5645 (let ((path load-path)
5646 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5648 (and (gnus-gethash name gnus-newsrc-hashtb)
5649 (error "Documentation group already exists"))
5651 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5653 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5655 (setq file (concat (file-name-directory
5656 (directory-file-name dir))
5657 "etc/gnus-tut.txt"))))
5660 (gnus-message 1 "Couldn't find doc group")
5661 (gnus-group-make-group
5662 (gnus-group-real-name name)
5663 (list 'nndoc "gnus-help"
5664 (list 'nndoc-address file)
5665 (list 'nndoc-article-type 'mbox)))))
5666 (gnus-group-position-point))
5668 (defun gnus-group-make-doc-group (file type)
5669 "Create a group that uses a single file as the source."
5671 (list (read-file-name "File name: ")
5672 (and current-prefix-arg 'ask)))
5673 (when (eq type 'ask)
5678 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5680 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5681 ((= char ?b) 'babyl)
5682 ((= char ?d) 'digest)
5683 ((= char ?f) 'forward)
5685 (t (setq err (format "%c unknown. " char))
5688 (let* ((file (expand-file-name file))
5689 (name (gnus-generate-new-group-name
5690 (gnus-group-prefixed-name
5691 (file-name-nondirectory file) '(nndoc "")))))
5692 (gnus-group-make-group
5693 (gnus-group-real-name name)
5694 (list 'nndoc (file-name-nondirectory file)
5695 (list 'nndoc-address file)
5696 (list 'nndoc-article-type (or type 'guess))))))
5698 (defun gnus-group-make-archive-group (&optional all)
5699 "Create the (ding) Gnus archive group of the most recent articles.
5700 Given a prefix, create a full group."
5702 (let ((group (gnus-group-prefixed-name
5703 (if all "ding.archives" "ding.recent") '(nndir ""))))
5704 (and (gnus-gethash group gnus-newsrc-hashtb)
5705 (error "Archive group already exists"))
5706 (gnus-group-make-group
5707 (gnus-group-real-name group)
5708 (list 'nndir (if all "hpc" "edu")
5709 (list 'nndir-directory
5710 (if all gnus-group-archive-directory
5711 gnus-group-recent-archive-directory))))))
5713 (defun gnus-group-make-directory-group (dir)
5714 "Create an nndir group.
5715 The user will be prompted for a directory. The contents of this
5716 directory will be used as a newsgroup. The directory should contain
5717 mail messages or news articles in files that have numeric names."
5719 (list (read-file-name "Create group from directory: ")))
5720 (or (file-exists-p dir) (error "No such directory"))
5721 (or (file-directory-p dir) (error "Not a directory"))
5725 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5727 (gnus-group-prefixed-name
5728 (concat (file-name-as-directory (directory-file-name dir))
5731 (setq ext (format "<%d>" (setq i (1+ i)))))
5732 (gnus-group-make-group
5733 (gnus-group-real-name group)
5734 (list 'nndir group (list 'nndir-directory dir)))))
5736 (defun gnus-group-make-kiboze-group (group address scores)
5737 "Create an nnkiboze group.
5738 The user will be prompted for a name, a regexp to match groups, and
5739 score file entries for articles to include in the group."
5742 (read-string "nnkiboze group name: ")
5743 (read-string "Source groups (regexp): ")
5744 (let ((headers (mapcar (lambda (group) (list group))
5745 '("subject" "from" "number" "date" "message-id"
5746 "references" "chars" "lines" "xref"
5747 "followup" "all" "body" "head")))
5748 scores header regexp regexps)
5749 (while (not (equal "" (setq header (completing-read
5750 "Match on header: " headers nil t))))
5752 (while (not (equal "" (setq regexp (read-string
5753 (format "Match on %s (string): "
5755 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5756 (setq scores (cons (cons header regexps) scores)))
5758 (gnus-group-make-group group "nnkiboze" address)
5759 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5760 (let (emacs-lisp-mode-hook)
5761 (pp scores (current-buffer)))))
5763 (defun gnus-group-add-to-virtual (n vgroup)
5764 "Add the current group to a virtual group."
5766 (list current-prefix-arg
5767 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5769 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5770 (error "%s is not an nnvirtual group" vgroup))
5771 (let* ((groups (gnus-group-process-prefix n))
5772 (method (gnus-info-method (gnus-get-info vgroup))))
5773 (setcar (cdr method)
5775 (nth 1 method) "\\|"
5778 (gnus-group-remove-mark s)
5779 (concat "\\(^" (regexp-quote s) "$\\)"))
5781 (gnus-group-position-point))
5783 (defun gnus-group-make-empty-virtual (group)
5784 "Create a new, fresh, empty virtual group."
5785 (interactive "sCreate new, empty virtual group: ")
5786 (let* ((method (list 'nnvirtual "^$"))
5787 (pgroup (gnus-group-prefixed-name group method)))
5788 ;; Check whether it exists already.
5789 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5790 (error "Group %s already exists." pgroup))
5791 ;; Subscribe the new group after the group on the current line.
5792 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5793 (gnus-group-update-group pgroup)
5795 (gnus-group-position-point)))
5797 (defun gnus-group-enter-directory (dir)
5798 "Enter an ephemeral nneething group."
5799 (interactive "DDirectory to read: ")
5800 (let* ((method (list 'nneething dir))
5801 (leaf (gnus-group-prefixed-name
5802 (file-name-nondirectory (directory-file-name dir))
5804 (name (gnus-generate-new-group-name leaf)))
5805 (let ((nneething-read-only t))
5806 (or (gnus-group-read-ephemeral-group
5808 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5810 (error "Couldn't enter %s" dir)))))
5812 ;; Group sorting commands
5813 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5815 (defun gnus-group-sort-groups (func &optional reverse)
5816 "Sort the group buffer according to FUNC.
5817 If REVERSE, reverse the sorting order."
5818 (interactive (list gnus-group-sort-function
5819 current-prefix-arg))
5821 ((not (listp func)) func)
5823 ((= 1 (length func)) (car func))
5825 ,(gnus-make-sort-function
5826 (reverse func)))))))
5827 ;; We peel off the dummy group from the alist.
5829 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5830 (pop gnus-newsrc-alist))
5832 (setq gnus-newsrc-alist
5833 (sort gnus-newsrc-alist func))
5835 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5836 ;; Regenerate the hash table.
5837 (gnus-make-hashtable-from-newsrc-alist)
5838 (gnus-group-list-groups))))
5840 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5841 "Sort the group buffer alphabetically by group name.
5842 If REVERSE, sort in reverse order."
5844 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5846 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5847 "Sort the group buffer by number of unread articles.
5848 If REVERSE, sort in reverse order."
5850 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5852 (defun gnus-group-sort-groups-by-level (&optional reverse)
5853 "Sort the group buffer by group level.
5854 If REVERSE, sort in reverse order."
5856 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5858 (defun gnus-group-sort-groups-by-score (&optional reverse)
5859 "Sort the group buffer by group score.
5860 If REVERSE, sort in reverse order."
5862 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5864 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5865 "Sort the group buffer by group rank.
5866 If REVERSE, sort in reverse order."
5868 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5870 (defun gnus-group-sort-groups-by-method (&optional reverse)
5871 "Sort the group buffer alphabetically by backend name.
5872 If REVERSE, sort in reverse order."
5874 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5876 (defun gnus-group-sort-by-alphabet (info1 info2)
5877 "Sort alphabetically."
5878 (string< (gnus-info-group info1) (gnus-info-group info2)))
5880 (defun gnus-group-sort-by-unread (info1 info2)
5881 "Sort by number of unread articles."
5882 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5883 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5884 (< (or (and (numberp n1) n1) 0)
5885 (or (and (numberp n2) n2) 0))))
5887 (defun gnus-group-sort-by-level (info1 info2)
5889 (< (gnus-info-level info1) (gnus-info-level info2)))
5891 (defun gnus-group-sort-by-method (info1 info2)
5892 "Sort alphabetically by backend name."
5893 (string< (symbol-name (car (gnus-find-method-for-group
5894 (gnus-info-group info1) info1)))
5895 (symbol-name (car (gnus-find-method-for-group
5896 (gnus-info-group info2) info2)))))
5898 (defun gnus-group-sort-by-score (info1 info2)
5899 "Sort by group score."
5900 (< (gnus-info-score info1) (gnus-info-score info2)))
5902 (defun gnus-group-sort-by-rank (info1 info2)
5903 "Sort by level and score."
5904 (let ((level1 (gnus-info-level info1))
5905 (level2 (gnus-info-level info2)))
5906 (or (< level1 level2)
5907 (and (= level1 level2)
5908 (< (gnus-info-score info1) (gnus-info-score info2))))))
5910 ;; Group catching up.
5912 (defun gnus-group-clear-data (n)
5913 "Clear all marks and read ranges from the current group."
5915 (let ((groups (gnus-group-process-prefix n))
5917 (while (setq group (pop groups))
5918 (setq info (gnus-get-info group))
5919 (gnus-info-set-read info nil)
5920 (when (gnus-info-marks info)
5921 (gnus-info-set-marks info nil))
5922 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5923 (when (gnus-group-goto-group group)
5924 (gnus-group-remove-mark group)
5925 (gnus-group-update-group-line)))))
5927 (defun gnus-group-catchup-current (&optional n all)
5928 "Mark all articles not marked as unread in current newsgroup as read.
5929 If prefix argument N is numeric, the ARG next newsgroups will be
5930 caught up. If ALL is non-nil, marked articles will also be marked as
5931 read. Cross references (Xref: header) of articles are ignored.
5932 The difference between N and actual number of newsgroups that were
5933 caught up is returned."
5935 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5939 "Do you really want to mark all articles as read? "
5940 "Mark all unread articles as read? "))))
5942 (let ((groups (gnus-group-process-prefix n))
5945 ;; Virtual groups have to be given special treatment.
5946 (let ((method (gnus-find-method-for-group (car groups))))
5947 (if (eq 'nnvirtual (car method))
5948 (nnvirtual-catchup-group
5949 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5950 (gnus-group-remove-mark (car groups))
5951 (if (>= (gnus-group-group-level) gnus-level-zombie)
5952 (gnus-message 2 "Dead groups can't be caught up")
5954 (gnus-group-goto-group (car groups))
5955 (gnus-group-catchup (car groups) all))
5956 (gnus-group-update-group-line)
5957 (setq ret (1+ ret))))
5958 (setq groups (cdr groups)))
5959 (gnus-group-next-unread-group 1)
5962 (defun gnus-group-catchup-current-all (&optional n)
5963 "Mark all articles in current newsgroup as read.
5964 Cross references (Xref: header) of articles are ignored."
5966 (gnus-group-catchup-current n 'all))
5968 (defun gnus-group-catchup (group &optional all)
5969 "Mark all articles in GROUP as read.
5970 If ALL is non-nil, all articles are marked as read.
5971 The return value is the number of articles that were marked as read,
5972 or nil if no action could be taken."
5973 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5975 ;; Do the updating only if the newsgroup isn't killed.
5976 (if (not (numberp (car entry)))
5977 (gnus-message 1 "Can't catch up; non-active group")
5978 ;; Do auto-expirable marks if that's required.
5979 (when (gnus-group-auto-expirable-p group)
5980 (gnus-add-marked-articles
5981 group 'expire (gnus-list-of-unread-articles group))
5983 (let ((marks (nth 3 (nth 2 entry))))
5984 (gnus-add-marked-articles
5985 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5986 (gnus-add-marked-articles
5987 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5989 (gnus-update-read-articles group nil)
5990 ;; Also nix out the lists of marks and dormants.
5992 (gnus-add-marked-articles group 'tick nil nil 'force)
5993 (gnus-add-marked-articles group 'dormant nil nil 'force))
5994 (run-hooks 'gnus-group-catchup-group-hook)
5997 (defun gnus-group-expire-articles (&optional n)
5998 "Expire all expirable articles in the current newsgroup."
6000 (let ((groups (gnus-group-process-prefix n))
6003 (error "No groups to expire"))
6004 (while (setq group (pop groups))
6005 (gnus-group-remove-mark group)
6006 (when (gnus-check-backend-function 'request-expire-articles group)
6007 (gnus-message 6 "Expiring articles in %s..." group)
6008 (let* ((info (gnus-get-info group))
6009 (expirable (if (gnus-group-total-expirable-p group)
6010 (cons nil (gnus-list-of-read-articles group))
6011 (assq 'expire (gnus-info-marks info))))
6012 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6016 (gnus-compress-sequence
6018 ;; We set the expiry variables to the groupp
6020 (let ((nnmail-expiry-wait-function nil)
6021 (nnmail-expiry-wait expiry-wait))
6022 (gnus-request-expire-articles
6023 (gnus-uncompress-sequence (cdr expirable)) group))
6024 ;; Just expire using the normal expiry values.
6025 (gnus-request-expire-articles
6026 (gnus-uncompress-sequence (cdr expirable)) group)))))
6027 (gnus-message 6 "Expiring articles in %s...done" group)))
6028 (gnus-group-position-point))))
6030 (defun gnus-group-expire-all-groups ()
6031 "Expire all expirable articles in all newsgroups."
6034 (gnus-message 5 "Expiring...")
6035 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6036 (cdr gnus-newsrc-alist))))
6037 (gnus-group-expire-articles nil)))
6038 (gnus-group-position-point)
6039 (gnus-message 5 "Expiring...done"))
6041 (defun gnus-group-set-current-level (n level)
6042 "Set the level of the next N groups to LEVEL."
6047 (let ((s (read-string
6048 (format "Level (default %s): "
6049 (or (gnus-group-group-level)
6050 gnus-level-default-subscribed)))))
6051 (if (string-match "^\\s-*$" s)
6052 (int-to-string (or (gnus-group-group-level)
6053 gnus-level-default-subscribed))
6055 (or (and (>= level 1) (<= level gnus-level-killed))
6056 (error "Illegal level: %d" level))
6057 (let ((groups (gnus-group-process-prefix n))
6059 (while (setq group (pop groups))
6060 (gnus-group-remove-mark group)
6061 (gnus-message 6 "Changed level of %s from %d to %d"
6062 group (or (gnus-group-group-level) gnus-level-killed)
6064 (gnus-group-change-level
6065 group level (or (gnus-group-group-level) gnus-level-killed))
6066 (gnus-group-update-group-line)))
6067 (gnus-group-position-point))
6069 (defun gnus-group-unsubscribe-current-group (&optional n)
6070 "Toggle subscription of the current group.
6071 If given numerical prefix, toggle the N next groups."
6073 (let ((groups (gnus-group-process-prefix n))
6076 (setq group (car groups)
6077 groups (cdr groups))
6078 (gnus-group-remove-mark group)
6079 (gnus-group-unsubscribe-group
6080 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6081 gnus-level-default-unsubscribed
6082 gnus-level-default-subscribed) t)
6083 (gnus-group-update-group-line))
6084 (gnus-group-next-group 1)))
6086 (defun gnus-group-unsubscribe-group (group &optional level silent)
6087 "Toggle subscription to GROUP.
6088 Killed newsgroups are subscribed. If SILENT, don't try to update the
6091 (list (completing-read
6092 "Group: " gnus-active-hashtb nil
6093 (memq gnus-select-method gnus-have-read-active-file))))
6094 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6096 ((string-match "^[ \t]$" group)
6097 (error "Empty group name"))
6099 ;; Toggle subscription flag.
6100 (gnus-group-change-level
6101 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6102 gnus-level-subscribed)
6103 (1+ gnus-level-subscribed)
6104 gnus-level-default-subscribed)))
6106 (gnus-group-update-group group)))
6107 ((and (stringp group)
6108 (or (not (memq gnus-select-method gnus-have-read-active-file))
6109 (gnus-active group)))
6110 ;; Add new newsgroup.
6111 (gnus-group-change-level
6113 (if level level gnus-level-default-subscribed)
6114 (or (and (member group gnus-zombie-list)
6117 (and (gnus-group-group-name)
6118 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6120 (gnus-group-update-group group)))
6121 (t (error "No such newsgroup: %s" group)))
6122 (gnus-group-position-point)))
6124 (defun gnus-group-transpose-groups (n)
6125 "Move the current newsgroup up N places.
6126 If given a negative prefix, move down instead. The difference between
6127 N and the number of steps taken is returned."
6129 (or (gnus-group-group-name)
6130 (error "No group on current line"))
6131 (gnus-group-kill-group 1)
6133 (forward-line (- n))
6134 (gnus-group-yank-group)
6135 (gnus-group-position-point)))
6137 (defun gnus-group-kill-all-zombies ()
6138 "Kill all zombie newsgroups."
6140 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6141 (setq gnus-zombie-list nil)
6142 (gnus-group-list-groups))
6144 (defun gnus-group-kill-region (begin end)
6145 "Kill newsgroups in current region (excluding current point).
6146 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6161 (beginning-of-line) ;Important when LINES < 1
6162 (gnus-group-kill-group lines)))
6164 (defun gnus-group-kill-group (&optional n discard)
6165 "Kill the next N groups.
6166 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6167 However, only groups that were alive can be yanked; already killed
6168 groups or zombie groups can't be yanked.
6169 The return value is the name of the group that was killed, or a list
6172 (let ((buffer-read-only nil)
6173 (groups (gnus-group-process-prefix n))
6174 group entry level out)
6175 (if (< (length groups) 10)
6176 ;; This is faster when there are few groups.
6178 (push (setq group (pop groups)) out)
6179 (gnus-group-remove-mark group)
6180 (setq level (gnus-group-group-level))
6182 (when (and (not discard)
6183 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6184 (push (cons (car entry) (nth 2 entry))
6185 gnus-list-of-killed-groups))
6186 (gnus-group-change-level
6187 (if entry entry group) gnus-level-killed (if entry nil level)))
6188 ;; If there are lots and lots of groups to be killed, we use
6189 ;; this thing instead.
6191 (setq groups (nreverse groups))
6193 (gnus-group-remove-mark (setq group (pop groups)))
6196 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6197 (push (cons (car entry) (nth 2 entry))
6198 gnus-list-of-killed-groups)
6199 (setcdr (cdr entry) (cdddr entry)))
6200 ((member group gnus-zombie-list)
6201 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6202 (gnus-make-hashtable-from-newsrc-alist)))
6204 (gnus-group-position-point)
6205 (if (< (length out) 2) (car out) (nreverse out))))
6207 (defun gnus-group-yank-group (&optional arg)
6208 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6209 inserting it before the current newsgroup. The numeric ARG specifies
6210 how many newsgroups are to be yanked. The name of the newsgroup yanked
6211 is returned, or (if several groups are yanked) a list of yanked groups
6214 (setq arg (or arg 1))
6215 (let (info group prev out)
6216 (while (>= (decf arg) 0)
6217 (if (not (setq info (pop gnus-list-of-killed-groups)))
6218 (error "No more newsgroups to yank"))
6219 (push (setq group (nth 1 info)) out)
6220 ;; Find which newsgroup to insert this one before - search
6221 ;; backward until something suitable is found. If there are no
6222 ;; other newsgroups in this buffer, just make this newsgroup the
6224 (setq prev (gnus-group-group-name))
6225 (gnus-group-change-level
6226 info (gnus-info-level (cdr info)) gnus-level-killed
6227 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6229 (gnus-group-insert-group-line-info group))
6231 (gnus-group-position-point)
6232 (if (< (length out) 2) (car out) (nreverse out))))
6234 (defun gnus-group-kill-level (level)
6235 "Kill all groups that is on a certain LEVEL."
6236 (interactive "nKill all groups on level: ")
6238 ((= level gnus-level-zombie)
6239 (setq gnus-killed-list
6240 (nconc gnus-zombie-list gnus-killed-list))
6241 (setq gnus-zombie-list nil))
6242 ((and (< level gnus-level-zombie)
6244 (or gnus-expert-user
6247 "Do you really want to kill all groups on level %d? "
6249 (let* ((prev gnus-newsrc-alist)
6252 (if (= (gnus-info-level level) level)
6253 (setcdr prev (cdr alist))
6255 (setq alist (cdr alist)))
6256 (gnus-make-hashtable-from-newsrc-alist)
6257 (gnus-group-list-groups)))
6259 (error "Can't kill; illegal level: %d" level))))
6261 (defun gnus-group-list-all-groups (&optional arg)
6262 "List all newsgroups with level ARG or lower.
6263 Default is gnus-level-unsubscribed, which lists all subscribed and most
6264 unsubscribed groups."
6266 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6268 ;; Redefine this to list ALL killed groups if prefix arg used.
6269 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6270 (defun gnus-group-list-killed (&optional arg)
6271 "List all killed newsgroups in the group buffer.
6272 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6273 entail asking the server for the groups."
6275 ;; Find all possible killed newsgroups if arg.
6277 ;; First make sure active file has been read.
6278 (unless gnus-have-read-active-file
6279 (let ((gnus-read-active-file t))
6280 (gnus-read-active-file)))
6281 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6282 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6286 (group (symbol-name sym)))
6287 (if (or (null group)
6288 (gnus-gethash group gnus-killed-hashtb)
6289 (gnus-gethash group gnus-newsrc-hashtb))
6291 (let ((do-sub (gnus-matches-options-n group)))
6292 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6294 (setq groups (1+ groups))
6295 (setq gnus-killed-list
6296 (cons group gnus-killed-list))
6297 (gnus-sethash group group gnus-killed-hashtb))))))
6298 gnus-active-hashtb))
6299 (if (not gnus-killed-list)
6300 (gnus-message 6 "No killed groups")
6301 (let (gnus-group-list-mode)
6302 (funcall gnus-group-prepare-function
6303 gnus-level-killed t gnus-level-killed))
6304 (goto-char (point-min)))
6305 (gnus-group-position-point))
6307 (defun gnus-group-list-zombies ()
6308 "List all zombie newsgroups in the group buffer."
6310 (if (not gnus-zombie-list)
6311 (gnus-message 6 "No zombie groups")
6312 (let (gnus-group-list-mode)
6313 (funcall gnus-group-prepare-function
6314 gnus-level-zombie t gnus-level-zombie))
6315 (goto-char (point-min)))
6316 (gnus-group-position-point))
6318 (defun gnus-group-list-active ()
6319 "List all groups that are available from the server(s)."
6321 ;; First we make sure that we have really read the active file.
6322 (unless gnus-have-read-active-file
6323 (let ((gnus-read-active-file t))
6324 (gnus-read-active-file)))
6325 ;; Find all groups and sort them.
6331 (and (symbol-value sym)
6332 (setq list (cons (symbol-name sym) list))))
6336 (buffer-read-only nil))
6339 (gnus-group-insert-group-line-info (pop groups)))
6340 (goto-char (point-min))))
6342 (defun gnus-activate-all-groups (level)
6343 "Activate absolutely all groups."
6344 (interactive (list 7))
6345 (let ((gnus-activate-level level)
6346 (gnus-activate-foreign-newsgroups level))
6347 (gnus-group-get-new-news)))
6349 (defun gnus-group-get-new-news (&optional arg)
6350 "Get newly arrived articles.
6351 If ARG is a number, it specifies which levels you are interested in
6352 re-scanning. If ARG is non-nil and not a number, this will force
6353 \"hard\" re-reading of the active files from all servers."
6355 (run-hooks 'gnus-get-new-news-hook)
6356 ;; We might read in new NoCeM messages here.
6357 (when (and gnus-use-nocem
6359 (gnus-nocem-scan-groups))
6360 ;; If ARG is not a number, then we read the active file.
6361 (when (and arg (not (numberp arg)))
6362 (let ((gnus-read-active-file t))
6363 (gnus-read-active-file))
6366 (setq arg (gnus-group-default-level arg t))
6367 (if (and gnus-read-active-file (not arg))
6369 (gnus-read-active-file)
6370 (gnus-get-unread-articles arg))
6371 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6372 (gnus-get-unread-articles arg)))
6373 (run-hooks 'gnus-after-getting-new-news-hook)
6374 (gnus-group-list-groups))
6376 (defun gnus-group-get-new-news-this-group (&optional n)
6377 "Check for newly arrived news in the current group (and the N-1 next groups).
6378 The difference between N and the number of newsgroup checked is returned.
6379 If N is negative, this group and the N-1 previous groups will be checked."
6381 (let* ((groups (gnus-group-process-prefix n))
6382 (ret (if (numberp n) (- n (length groups)) 0))
6383 (beg (unless n (point)))
6385 (while (setq group (pop groups))
6386 (gnus-group-remove-mark group)
6387 (if (gnus-activate-group group 'scan)
6389 (gnus-get-unread-articles-in-group
6390 (gnus-get-info group) (gnus-active group) t)
6391 (unless (gnus-virtual-group-p group)
6392 (gnus-close-group group))
6393 (gnus-group-update-group group))
6394 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6395 (when beg (goto-char beg))
6396 (when gnus-goto-next-group-when-activating
6397 (gnus-group-next-unread-group 1 t))
6398 (gnus-summary-position-point)
6401 (defun gnus-group-fetch-faq (group &optional faq-dir)
6402 "Fetch the FAQ for the current group."
6405 (gnus-group-real-name (gnus-group-group-name))
6406 (cond (current-prefix-arg
6408 "Faq dir: " (and (listp gnus-group-faq-directory)
6409 gnus-group-faq-directory))))))
6411 (setq faq-dir (if (listp gnus-group-faq-directory)
6412 (car gnus-group-faq-directory)
6413 gnus-group-faq-directory)))
6414 (or group (error "No group name given"))
6415 (let ((file (concat (file-name-as-directory faq-dir)
6416 (gnus-group-real-name group))))
6417 (if (not (file-exists-p file))
6418 (error "No such file: %s" file)
6421 (defun gnus-group-describe-group (force &optional group)
6422 "Display a description of the current newsgroup."
6423 (interactive (list current-prefix-arg (gnus-group-group-name)))
6424 (and force (setq gnus-description-hashtb nil))
6425 (let ((method (gnus-find-method-for-group group))
6427 (or group (error "No group name given"))
6428 (and (or (and gnus-description-hashtb
6429 ;; We check whether this group's method has been
6430 ;; queried for a description file.
6432 (gnus-group-prefixed-name "" method)
6433 gnus-description-hashtb))
6434 (setq desc (gnus-group-get-description group))
6435 (gnus-read-descriptions-file method))
6437 (or desc (gnus-gethash group gnus-description-hashtb)
6438 "No description available")))))
6440 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6441 (defun gnus-group-describe-all-groups (&optional force)
6442 "Pop up a buffer with descriptions of all newsgroups."
6444 (and force (setq gnus-description-hashtb nil))
6445 (if (not (or gnus-description-hashtb
6446 (gnus-read-all-descriptions-files)))
6447 (error "Couldn't request descriptions file"))
6448 (let ((buffer-read-only nil)
6454 (insert (format " *: %-20s %s\n" (symbol-name group)
6455 (symbol-value group)))
6456 (add-text-properties
6457 b (1+ b) (list 'gnus-group group
6458 'gnus-unread t 'gnus-marked nil
6459 'gnus-level (1+ gnus-level-subscribed))))
6460 gnus-description-hashtb)
6461 (goto-char (point-min))
6462 (gnus-group-position-point)))
6464 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6465 (defun gnus-group-apropos (regexp &optional search-description)
6466 "List all newsgroups that have names that match a regexp."
6467 (interactive "sGnus apropos (regexp): ")
6469 (obuf (current-buffer))
6471 ;; Go through all newsgroups that are known to Gnus.
6474 (and (symbol-name group)
6475 (string-match regexp (symbol-name group))
6476 (setq groups (cons (symbol-name group) groups))))
6478 ;; Also go through all descriptions that are known to Gnus.
6479 (when search-description
6482 (and (string-match regexp (symbol-value group))
6483 (gnus-active (symbol-name group))
6484 (setq groups (cons (symbol-name group) groups))))
6485 gnus-description-hashtb))
6487 (gnus-message 3 "No groups matched \"%s\"." regexp)
6488 ;; Print out all the groups.
6490 (pop-to-buffer "*Gnus Help*")
6491 (buffer-disable-undo (current-buffer))
6493 (setq groups (sort groups 'string<))
6495 ;; Groups may be entered twice into the list of groups.
6496 (if (not (string= (car groups) prev))
6498 (insert (setq prev (car groups)) "\n")
6499 (if (and gnus-description-hashtb
6500 (setq des (gnus-gethash (car groups)
6501 gnus-description-hashtb)))
6502 (insert " " des "\n"))))
6503 (setq groups (cdr groups)))
6504 (goto-char (point-min))))
6505 (pop-to-buffer obuf)))
6507 (defun gnus-group-description-apropos (regexp)
6508 "List all newsgroups that have names or descriptions that match a regexp."
6509 (interactive "sGnus description apropos (regexp): ")
6510 (if (not (or gnus-description-hashtb
6511 (gnus-read-all-descriptions-files)))
6512 (error "Couldn't request descriptions file"))
6513 (gnus-group-apropos regexp t))
6515 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6516 (defun gnus-group-list-matching (level regexp &optional all lowest)
6517 "List all groups with unread articles that match REGEXP.
6518 If the prefix LEVEL is non-nil, it should be a number that says which
6519 level to cut off listing groups.
6520 If ALL, also list groups with no unread articles.
6521 If LOWEST, don't list groups with level lower than LOWEST."
6522 (interactive "P\nsList newsgroups matching: ")
6523 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6524 all (or lowest 1) regexp)
6525 (goto-char (point-min))
6526 (gnus-group-position-point))
6528 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6529 "List all groups that match REGEXP.
6530 If the prefix LEVEL is non-nil, it should be a number that says which
6531 level to cut off listing groups.
6532 If LOWEST, don't list groups with level lower than LOWEST."
6533 (interactive "P\nsList newsgroups matching: ")
6534 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6536 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6537 (defun gnus-group-save-newsrc (&optional force)
6538 "Save the Gnus startup files.
6539 If FORCE, force saving whether it is necessary or not."
6541 (gnus-save-newsrc-file force))
6543 (defun gnus-group-restart (&optional arg)
6544 "Force Gnus to read the .newsrc file."
6546 (when (gnus-yes-or-no-p
6547 (format "Are you sure you want to read %s? "
6548 gnus-current-startup-file))
6549 (gnus-save-newsrc-file)
6550 (gnus-setup-news 'force)
6551 (gnus-group-list-groups arg)))
6553 (defun gnus-group-read-init-file ()
6554 "Read the Gnus elisp init file."
6556 (gnus-read-init-file))
6558 (defun gnus-group-check-bogus-groups (&optional silent)
6559 "Check bogus newsgroups.
6560 If given a prefix, don't ask for confirmation before removing a bogus
6563 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6564 (gnus-group-list-groups))
6566 (defun gnus-group-edit-global-kill (&optional article group)
6567 "Edit the global kill file.
6568 If GROUP, edit that local kill file instead."
6570 (setq gnus-current-kill-article article)
6571 (gnus-kill-file-edit-file group)
6574 (substitute-command-keys
6575 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6576 (if group "local" "global")))))
6578 (defun gnus-group-edit-local-kill (article group)
6579 "Edit a local kill file."
6580 (interactive (list nil (gnus-group-group-name)))
6581 (gnus-group-edit-global-kill article group))
6583 (defun gnus-group-force-update ()
6584 "Update `.newsrc' file."
6586 (gnus-save-newsrc-file))
6588 (defun gnus-group-suspend ()
6589 "Suspend the current Gnus session.
6590 In fact, cleanup buffers except for group mode buffer.
6591 The hook gnus-suspend-gnus-hook is called before actually suspending."
6593 (run-hooks 'gnus-suspend-gnus-hook)
6594 ;; Kill Gnus buffers except for group mode buffer.
6595 (let ((group-buf (get-buffer gnus-group-buffer)))
6596 ;; Do this on a separate list in case the user does a ^G before we finish
6597 (let ((gnus-buffer-list
6598 (delq group-buf (delq gnus-dribble-buffer
6599 (append gnus-buffer-list nil)))))
6600 (while gnus-buffer-list
6601 (gnus-kill-buffer (car gnus-buffer-list))
6602 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6605 (setq gnus-buffer-list (list group-buf))
6606 (bury-buffer group-buf)
6607 (delete-windows-on group-buf t)))))
6609 (defun gnus-group-clear-dribble ()
6610 "Clear all information from the dribble buffer."
6612 (gnus-dribble-clear)
6613 (gnus-message 7 "Cleared dribble buffer"))
6615 (defun gnus-group-exit ()
6616 "Quit reading news after updating .newsrc.eld and .newsrc.
6617 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6620 (or noninteractive ;For gnus-batch-kill
6621 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6622 (not gnus-interactive-exit) ;Without confirmation
6624 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6625 (run-hooks 'gnus-exit-gnus-hook)
6626 ;; Offer to save data from non-quitted summary buffers.
6627 (gnus-offer-save-summaries)
6628 ;; Save the newsrc file(s).
6629 (gnus-save-newsrc-file)
6631 (gnus-close-backends)
6632 ;; Reset everything.
6634 ;; Allow the user to do things after cleaning up.
6635 (run-hooks 'gnus-after-exiting-gnus-hook)))
6637 (defun gnus-close-backends ()
6638 ;; Send a close request to all backends that support such a request.
6639 (let ((methods gnus-valid-select-methods)
6642 (if (fboundp (setq func (intern (concat (caar methods)
6643 "-request-close"))))
6645 (setq methods (cdr methods)))))
6647 (defun gnus-group-quit ()
6648 "Quit reading news without updating .newsrc.eld or .newsrc.
6649 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6651 (when (or noninteractive ;For gnus-batch-kill
6652 (zerop (buffer-size))
6653 (not (gnus-server-opened gnus-select-method))
6655 (not gnus-current-startup-file)
6657 (format "Quit reading news without saving %s? "
6658 (file-name-nondirectory gnus-current-startup-file))))
6659 (run-hooks 'gnus-exit-gnus-hook)
6660 (if gnus-use-full-window
6661 (delete-other-windows)
6662 (gnus-remove-some-windows))
6664 (gnus-close-backends)
6666 ;; Allow the user to do things after cleaning up.
6667 (run-hooks 'gnus-after-exiting-gnus-hook)))
6669 (defun gnus-offer-save-summaries ()
6670 "Offer to save all active summary buffers."
6672 (let ((buflist (buffer-list))
6674 ;; Go through all buffers and find all summaries.
6676 (and (setq bufname (buffer-name (car buflist)))
6677 (string-match "Summary" bufname)
6679 (set-buffer bufname)
6680 ;; We check that this is, indeed, a summary buffer.
6681 (and (eq major-mode 'gnus-summary-mode)
6682 ;; Also make sure this isn't bogus.
6683 gnus-newsgroup-prepared))
6684 (push bufname buffers))
6685 (setq buflist (cdr buflist)))
6686 ;; Go through all these summary buffers and offer to save them.
6689 "Update summary buffer %s? "
6690 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6693 (defun gnus-group-describe-briefly ()
6694 "Give a one line description of the group mode commands."
6696 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
6698 (defun gnus-group-browse-foreign-server (method)
6699 "Browse a foreign news server.
6700 If called interactively, this function will ask for a select method
6701 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6702 If not, METHOD should be a list where the first element is the method
6703 and the second element is the address."
6705 (list (let ((how (completing-read
6707 (append gnus-valid-select-methods gnus-server-alist)
6708 nil t (cons "nntp" 0) 'gnus-method-history)))
6709 ;; We either got a backend name or a virtual server name.
6710 ;; If the first, we also need an address.
6711 (if (assoc how gnus-valid-select-methods)
6713 ;; Suggested by mapjph@bath.ac.uk.
6716 (mapcar (lambda (server) (list server))
6717 gnus-secondary-servers)))
6718 ;; We got a server name, so we find the method.
6719 (gnus-server-to-method how)))))
6720 (gnus-browse-foreign-server method))
6724 ;;; Gnus summary mode
6727 (defvar gnus-summary-mode-map nil)
6729 (put 'gnus-summary-mode 'mode-class 'special)
6731 (unless gnus-summary-mode-map
6732 (setq gnus-summary-mode-map (make-keymap))
6733 (suppress-keymap gnus-summary-mode-map)
6735 ;; Non-orthogonal keys
6737 (gnus-define-keys gnus-summary-mode-map
6738 " " gnus-summary-next-page
6739 "\177" gnus-summary-prev-page
6740 [delete] gnus-summary-prev-page
6741 "\r" gnus-summary-scroll-up
6742 "n" gnus-summary-next-unread-article
6743 "p" gnus-summary-prev-unread-article
6744 "N" gnus-summary-next-article
6745 "P" gnus-summary-prev-article
6746 "\M-\C-n" gnus-summary-next-same-subject
6747 "\M-\C-p" gnus-summary-prev-same-subject
6748 "\M-n" gnus-summary-next-unread-subject
6749 "\M-p" gnus-summary-prev-unread-subject
6750 "." gnus-summary-first-unread-article
6751 "," gnus-summary-best-unread-article
6752 "\M-s" gnus-summary-search-article-forward
6753 "\M-r" gnus-summary-search-article-backward
6754 "<" gnus-summary-beginning-of-article
6755 ">" gnus-summary-end-of-article
6756 "j" gnus-summary-goto-article
6757 "^" gnus-summary-refer-parent-article
6758 "\M-^" gnus-summary-refer-article
6759 "u" gnus-summary-tick-article-forward
6760 "!" gnus-summary-tick-article-forward
6761 "U" gnus-summary-tick-article-backward
6762 "d" gnus-summary-mark-as-read-forward
6763 "D" gnus-summary-mark-as-read-backward
6764 "E" gnus-summary-mark-as-expirable
6765 "\M-u" gnus-summary-clear-mark-forward
6766 "\M-U" gnus-summary-clear-mark-backward
6767 "k" gnus-summary-kill-same-subject-and-select
6768 "\C-k" gnus-summary-kill-same-subject
6769 "\M-\C-k" gnus-summary-kill-thread
6770 "\M-\C-l" gnus-summary-lower-thread
6771 "e" gnus-summary-edit-article
6772 "#" gnus-summary-mark-as-processable
6773 "\M-#" gnus-summary-unmark-as-processable
6774 "\M-\C-t" gnus-summary-toggle-threads
6775 "\M-\C-s" gnus-summary-show-thread
6776 "\M-\C-h" gnus-summary-hide-thread
6777 "\M-\C-f" gnus-summary-next-thread
6778 "\M-\C-b" gnus-summary-prev-thread
6779 "\M-\C-u" gnus-summary-up-thread
6780 "\M-\C-d" gnus-summary-down-thread
6781 "&" gnus-summary-execute-command
6782 "c" gnus-summary-catchup-and-exit
6783 "\C-w" gnus-summary-mark-region-as-read
6784 "\C-t" gnus-summary-toggle-truncation
6785 "?" gnus-summary-mark-as-dormant
6786 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6787 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6788 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6789 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6790 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6791 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6792 "=" gnus-summary-expand-window
6793 "\C-x\C-s" gnus-summary-reselect-current-group
6794 "\M-g" gnus-summary-rescan-group
6795 "w" gnus-summary-stop-page-breaking
6796 "\C-c\C-r" gnus-summary-caesar-message
6797 "\M-t" gnus-summary-toggle-mime
6798 "f" gnus-summary-followup
6799 "F" gnus-summary-followup-with-original
6800 "C" gnus-summary-cancel-article
6801 "r" gnus-summary-reply
6802 "R" gnus-summary-reply-with-original
6803 "\C-c\C-f" gnus-summary-mail-forward
6804 "o" gnus-summary-save-article
6805 "\C-o" gnus-summary-save-article-mail
6806 "|" gnus-summary-pipe-output
6807 "\M-k" gnus-summary-edit-local-kill
6808 "\M-K" gnus-summary-edit-global-kill
6810 "\C-c\C-d" gnus-summary-describe-group
6811 "q" gnus-summary-exit
6812 "Q" gnus-summary-exit-no-update
6813 "\C-c\C-i" gnus-info-find-node
6814 gnus-mouse-2 gnus-mouse-pick-article
6815 "m" gnus-summary-mail-other-window
6816 "a" gnus-summary-post-news
6817 "x" gnus-summary-limit-to-unread
6818 "s" gnus-summary-isearch-article
6819 "t" gnus-article-hide-headers
6820 "g" gnus-summary-show-article
6821 "l" gnus-summary-goto-last-article
6822 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6823 "\C-d" gnus-summary-enter-digest-group
6825 "*" gnus-cache-enter-article
6826 "\M-*" gnus-cache-remove-article
6827 "\M-&" gnus-summary-universal-argument
6828 "\C-l" gnus-recenter
6829 "I" gnus-summary-increase-score
6830 "L" gnus-summary-lower-score
6832 "V" gnus-summary-score-map
6833 "X" gnus-uu-extract-map
6834 "S" gnus-summary-send-map)
6836 ;; Sort of orthogonal keymap
6837 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6838 "t" gnus-summary-tick-article-forward
6839 "!" gnus-summary-tick-article-forward
6840 "d" gnus-summary-mark-as-read-forward
6841 "r" gnus-summary-mark-as-read-forward
6842 "c" gnus-summary-clear-mark-forward
6843 " " gnus-summary-clear-mark-forward
6844 "e" gnus-summary-mark-as-expirable
6845 "x" gnus-summary-mark-as-expirable
6846 "?" gnus-summary-mark-as-dormant
6847 "b" gnus-summary-set-bookmark
6848 "B" gnus-summary-remove-bookmark
6849 "#" gnus-summary-mark-as-processable
6850 "\M-#" gnus-summary-unmark-as-processable
6851 "S" gnus-summary-limit-include-expunged
6852 "C" gnus-summary-catchup
6853 "H" gnus-summary-catchup-to-here
6854 "\C-c" gnus-summary-catchup-all
6855 "k" gnus-summary-kill-same-subject-and-select
6856 "K" gnus-summary-kill-same-subject
6857 "P" gnus-uu-mark-map)
6859 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6860 "c" gnus-summary-clear-above
6861 "u" gnus-summary-tick-above
6862 "m" gnus-summary-mark-above
6863 "k" gnus-summary-kill-below)
6865 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6866 "/" gnus-summary-limit-to-subject
6867 "n" gnus-summary-limit-to-articles
6868 "w" gnus-summary-pop-limit
6869 "s" gnus-summary-limit-to-subject
6870 "a" gnus-summary-limit-to-author
6871 "u" gnus-summary-limit-to-unread
6872 "m" gnus-summary-limit-to-marks
6873 "v" gnus-summary-limit-to-score
6874 "D" gnus-summary-limit-include-dormant
6875 "d" gnus-summary-limit-exclude-dormant
6876 ;; "t" gnus-summary-limit-exclude-thread
6877 "E" gnus-summary-limit-include-expunged
6878 "c" gnus-summary-limit-exclude-childless-dormant
6879 "C" gnus-summary-limit-mark-excluded-as-read)
6881 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6882 "n" gnus-summary-next-unread-article
6883 "p" gnus-summary-prev-unread-article
6884 "N" gnus-summary-next-article
6885 "P" gnus-summary-prev-article
6886 "\C-n" gnus-summary-next-same-subject
6887 "\C-p" gnus-summary-prev-same-subject
6888 "\M-n" gnus-summary-next-unread-subject
6889 "\M-p" gnus-summary-prev-unread-subject
6890 "f" gnus-summary-first-unread-article
6891 "b" gnus-summary-best-unread-article
6892 "j" gnus-summary-goto-article
6893 "g" gnus-summary-goto-subject
6894 "l" gnus-summary-goto-last-article
6895 "p" gnus-summary-pop-article)
6897 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6898 "k" gnus-summary-kill-thread
6899 "l" gnus-summary-lower-thread
6900 "i" gnus-summary-raise-thread
6901 "T" gnus-summary-toggle-threads
6902 "t" gnus-summary-rethread-current
6903 "^" gnus-summary-reparent-thread
6904 "s" gnus-summary-show-thread
6905 "S" gnus-summary-show-all-threads
6906 "h" gnus-summary-hide-thread
6907 "H" gnus-summary-hide-all-threads
6908 "n" gnus-summary-next-thread
6909 "p" gnus-summary-prev-thread
6910 "u" gnus-summary-up-thread
6911 "o" gnus-summary-top-thread
6912 "d" gnus-summary-down-thread
6913 "#" gnus-uu-mark-thread
6914 "\M-#" gnus-uu-unmark-thread)
6916 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6917 "c" gnus-summary-catchup-and-exit
6918 "C" gnus-summary-catchup-all-and-exit
6919 "E" gnus-summary-exit-no-update
6920 "Q" gnus-summary-exit
6921 "Z" gnus-summary-exit
6922 "n" gnus-summary-catchup-and-goto-next-group
6923 "R" gnus-summary-reselect-current-group
6924 "G" gnus-summary-rescan-group
6925 "N" gnus-summary-next-group
6926 "P" gnus-summary-prev-group)
6928 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6929 " " gnus-summary-next-page
6930 "n" gnus-summary-next-page
6931 "\177" gnus-summary-prev-page
6932 [delete] gnus-summary-prev-page
6933 "p" gnus-summary-prev-page
6934 "\r" gnus-summary-scroll-up
6935 "<" gnus-summary-beginning-of-article
6936 ">" gnus-summary-end-of-article
6937 "b" gnus-summary-beginning-of-article
6938 "e" gnus-summary-end-of-article
6939 "^" gnus-summary-refer-parent-article
6940 "r" gnus-summary-refer-parent-article
6941 "R" gnus-summary-refer-references
6942 "g" gnus-summary-show-article
6943 "s" gnus-summary-isearch-article)
6945 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6946 "b" gnus-article-add-buttons
6947 "B" gnus-article-add-buttons-to-head
6948 "o" gnus-article-treat-overstrike
6949 ;; "w" gnus-article-word-wrap
6950 "w" gnus-article-fill-cited-article
6951 "c" gnus-article-remove-cr
6952 "L" gnus-article-remove-trailing-blank-lines
6953 "q" gnus-article-de-quoted-unreadable
6954 "f" gnus-article-display-x-face
6955 "l" gnus-summary-stop-page-breaking
6956 "r" gnus-summary-caesar-message
6957 "t" gnus-article-hide-headers
6958 "v" gnus-summary-verbose-headers
6959 "m" gnus-summary-toggle-mime)
6961 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6962 "a" gnus-article-hide
6963 "h" gnus-article-hide-headers
6964 "b" gnus-article-hide-boring-headers
6965 "s" gnus-article-hide-signature
6966 "c" gnus-article-hide-citation
6967 "p" gnus-article-hide-pgp
6968 "\C-c" gnus-article-hide-citation-maybe)
6970 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6971 "a" gnus-article-highlight
6972 "h" gnus-article-highlight-headers
6973 "c" gnus-article-highlight-citation
6974 "s" gnus-article-highlight-signature)
6976 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6977 "z" gnus-article-date-ut
6978 "u" gnus-article-date-ut
6979 "l" gnus-article-date-local
6980 "e" gnus-article-date-lapsed
6981 "o" gnus-article-date-original)
6983 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6985 "f" gnus-summary-fetch-faq
6986 "d" gnus-summary-describe-group
6987 "h" gnus-summary-describe-briefly
6988 "i" gnus-info-find-node)
6990 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6991 "e" gnus-summary-expire-articles
6992 "\M-\C-e" gnus-summary-expire-articles-now
6993 "\177" gnus-summary-delete-article
6994 [delete] gnus-summary-delete-article
6995 "m" gnus-summary-move-article
6996 "r" gnus-summary-respool-article
6997 "w" gnus-summary-edit-article
6998 "c" gnus-summary-copy-article
6999 "B" gnus-summary-crosspost-article
7000 "q" gnus-summary-respool-query
7001 "i" gnus-summary-import-article)
7003 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7004 "o" gnus-summary-save-article
7005 "m" gnus-summary-save-article-mail
7006 "r" gnus-summary-save-article-rmail
7007 "f" gnus-summary-save-article-file
7008 "b" gnus-summary-save-article-body-file
7009 "h" gnus-summary-save-article-folder
7010 "v" gnus-summary-save-article-vm
7011 "p" gnus-summary-pipe-output
7012 "s" gnus-soup-add-article)
7017 (defun gnus-summary-mode (&optional group)
7018 "Major mode for reading articles.
7020 All normal editing commands are switched off.
7021 \\<gnus-summary-mode-map>
7022 Each line in this buffer represents one article. To read an
7023 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7024 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7027 You can also post articles and send mail from this buffer. To
7028 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7029 of an article, type `\\[gnus-summary-reply]'.
7031 There are approx. one gazillion commands you can execute in this
7032 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7034 The following commands are available:
7036 \\{gnus-summary-mode-map}"
7038 (when (and menu-bar-mode
7039 (gnus-visual-p 'summary-menu 'menu))
7040 (gnus-summary-make-menu-bar))
7041 (kill-all-local-variables)
7042 (let ((locals gnus-summary-local-variables))
7044 (if (consp (car locals))
7046 (make-local-variable (caar locals))
7047 (set (caar locals) (eval (cdar locals))))
7048 (make-local-variable (car locals))
7049 (set (car locals) nil))
7050 (setq locals (cdr locals))))
7051 (gnus-make-thread-indent-array)
7052 (gnus-simplify-mode-line)
7053 (setq major-mode 'gnus-summary-mode)
7054 (setq mode-name "Summary")
7055 (make-local-variable 'minor-mode-alist)
7056 (use-local-map gnus-summary-mode-map)
7057 (buffer-disable-undo (current-buffer))
7058 (setq buffer-read-only t) ;Disable modification
7059 (setq truncate-lines t)
7060 (setq selective-display t)
7061 (setq selective-display-ellipses t) ;Display `...'
7062 (setq buffer-display-table gnus-summary-display-table)
7063 (setq gnus-newsgroup-name group)
7064 (make-local-variable 'gnus-summary-line-format)
7065 (make-local-variable 'gnus-summary-line-format-spec)
7066 (run-hooks 'gnus-summary-mode-hook))
7068 (defun gnus-summary-make-display-table ()
7069 ;; Change the display table. Odd characters have a tendency to mess
7070 ;; up nicely formatted displays - we make all possible glyphs
7071 ;; display only a single character.
7073 ;; We start from the standard display table, if any.
7074 (setq gnus-summary-display-table
7075 (or (copy-sequence standard-display-table)
7076 (make-display-table)))
7077 ;; Nix out all the control chars...
7079 (while (>= (setq i (1- i)) 0)
7080 (aset gnus-summary-display-table i [??])))
7081 ;; ... but not newline and cr, of course. (cr is necessary for the
7082 ;; selective display).
7083 (aset gnus-summary-display-table ?\n nil)
7084 (aset gnus-summary-display-table ?\r nil)
7085 ;; We nix out any glyphs over 126 that are not set already.
7087 (while (>= (setq i (1- i)) 127)
7088 ;; Only modify if the entry is nil.
7089 (or (aref gnus-summary-display-table i)
7090 (aset gnus-summary-display-table i [??])))))
7092 (defun gnus-summary-clear-local-variables ()
7093 (let ((locals gnus-summary-local-variables))
7095 (if (consp (car locals))
7096 (and (vectorp (caar locals))
7097 (set (caar locals) nil))
7098 (and (vectorp (car locals))
7099 (set (car locals) nil)))
7100 (setq locals (cdr locals)))))
7102 ;; Summary data functions.
7104 (defmacro gnus-data-number (data)
7107 (defmacro gnus-data-set-number (data number)
7108 `(setcar ,data ,number))
7110 (defmacro gnus-data-mark (data)
7113 (defmacro gnus-data-set-mark (data mark)
7114 `(setcar (nthcdr 1 ,data) ,mark))
7116 (defmacro gnus-data-pos (data)
7119 (defmacro gnus-data-set-pos (data pos)
7120 `(setcar (nthcdr 2 ,data) ,pos))
7122 (defmacro gnus-data-header (data)
7125 (defmacro gnus-data-level (data)
7128 (defmacro gnus-data-unread-p (data)
7129 `(= (nth 1 ,data) gnus-unread-mark))
7131 (defmacro gnus-data-pseudo-p (data)
7132 `(consp (nth 3 ,data)))
7134 (defmacro gnus-data-find (number)
7135 `(assq ,number gnus-newsgroup-data))
7137 (defmacro gnus-data-find-list (number &optional data)
7138 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7139 (memq (assq ,number bdata)
7142 (defmacro gnus-data-make (number mark pos header level)
7143 `(list ,number ,mark ,pos ,header ,level))
7145 (defun gnus-data-enter (after-article number mark pos header level offset)
7146 (let ((data (gnus-data-find-list after-article)))
7147 (or data (error "No such article: %d" after-article))
7148 (setcdr data (cons (gnus-data-make number mark pos header level)
7150 (setq gnus-newsgroup-data-reverse nil)
7151 (gnus-data-update-list (cddr data) offset)))
7153 (defun gnus-data-enter-list (after-article list &optional offset)
7155 (let ((data (and after-article (gnus-data-find-list after-article)))
7157 (or data (not after-article) (error "No such article: %d" after-article))
7158 ;; Find the last element in the list to be spliced into the main
7161 (setq list (cdr list)))
7164 (setcdr list gnus-newsgroup-data)
7165 (setq gnus-newsgroup-data ilist)
7166 (and offset (gnus-data-update-list (cdr list) offset)))
7167 (setcdr list (cdr data))
7169 (and offset (gnus-data-update-list (cdr data) offset)))
7170 (setq gnus-newsgroup-data-reverse nil))))
7172 (defun gnus-data-remove (article &optional offset)
7173 (let ((data gnus-newsgroup-data))
7174 (if (= (gnus-data-number (car data)) article)
7175 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7176 gnus-newsgroup-data-reverse nil)
7178 (and (= (gnus-data-number (cadr data)) article)
7180 (setcdr data (cddr data))
7181 (and offset (gnus-data-update-list (cdr data) offset))
7183 gnus-newsgroup-data-reverse nil)))
7184 (setq data (cdr data))))))
7186 (defmacro gnus-data-list (backward)
7188 (or gnus-newsgroup-data-reverse
7189 (setq gnus-newsgroup-data-reverse
7190 (reverse gnus-newsgroup-data)))
7191 gnus-newsgroup-data))
7193 (defun gnus-data-update-list (data offset)
7194 "Add OFFSET to the POS of all data entries in DATA."
7196 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7197 (setq data (cdr data))))
7199 (defun gnus-data-compute-positions ()
7200 "Compute the positions of all articles."
7201 (let ((data gnus-newsgroup-data)
7204 (when (setq pos (text-property-any
7205 (point-min) (point-max)
7206 'gnus-number (gnus-data-number (car data))))
7207 (gnus-data-set-pos (car data) (+ pos 3)))
7208 (setq data (cdr data)))))
7210 (defun gnus-summary-article-pseudo-p (article)
7211 "Say whether this article is a pseudo article or not."
7212 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7214 (defun gnus-article-parent-p (number)
7215 "Say whether this article is a parent or not."
7216 (let ((data (gnus-data-find-list number)))
7217 (and (cdr data) ; There has to be an article after...
7218 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7219 (gnus-data-level (nth 1 data))))))
7221 (defun gnus-article-children (number)
7222 "Return a list of all children to NUMBER."
7223 (let* ((data (gnus-data-find-list number))
7224 (level (gnus-data-level (car data)))
7226 (setq data (cdr data))
7228 (= (gnus-data-level (car data)) (1+ level)))
7229 (push (gnus-data-number (car data)) children)
7230 (setq data (cdr data)))
7233 (defmacro gnus-summary-skip-intangible ()
7234 "If the current article is intangible, then jump to a different article."
7235 '(let ((to (get-text-property (point) 'gnus-intangible)))
7236 (and to (gnus-summary-goto-subject to))))
7238 (defmacro gnus-summary-article-intangible-p ()
7239 "Say whether this article is intangible or not."
7240 '(get-text-property (point) 'gnus-intangible))
7242 ;; Some summary mode macros.
7244 (defmacro gnus-summary-article-number ()
7245 "The article number of the article on the current line.
7246 If there isn's an article number here, then we return the current
7249 (gnus-summary-skip-intangible)
7250 (or (get-text-property (point) 'gnus-number)
7251 (gnus-summary-last-subject))))
7253 (defmacro gnus-summary-article-header (&optional number)
7254 `(gnus-data-header (gnus-data-find
7255 ,(or number '(gnus-summary-article-number)))))
7257 (defmacro gnus-summary-thread-level (&optional number)
7258 `(if (and (eq gnus-summary-make-false-root 'dummy)
7259 (get-text-property (point) 'gnus-intangible))
7261 (gnus-data-level (gnus-data-find
7262 ,(or number '(gnus-summary-article-number))))))
7264 (defmacro gnus-summary-article-mark (&optional number)
7265 `(gnus-data-mark (gnus-data-find
7266 ,(or number '(gnus-summary-article-number)))))
7268 (defmacro gnus-summary-article-pos (&optional number)
7269 `(gnus-data-pos (gnus-data-find
7270 ,(or number '(gnus-summary-article-number)))))
7272 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7273 (defmacro gnus-summary-article-subject (&optional number)
7274 "Return current subject string or nil if nothing."
7277 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7278 '(gnus-data-header (assq (gnus-summary-article-number)
7279 gnus-newsgroup-data)))))
7282 (mail-header-subject headers))))
7284 (defmacro gnus-summary-article-score (&optional number)
7285 "Return current article score."
7286 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7287 gnus-newsgroup-scored))
7288 gnus-summary-default-score 0))
7290 (defun gnus-summary-article-children (&optional number)
7291 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7292 (level (gnus-data-level (car data)))
7294 (while (and (setq data (cdr data))
7295 (> (setq l (gnus-data-level (car data))) level))
7296 (and (= (1+ level) l)
7297 (setq children (cons (gnus-data-number (car data))
7299 (nreverse children)))
7301 (defun gnus-summary-article-parent (&optional number)
7302 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7303 (gnus-data-list t)))
7304 (level (gnus-data-level (car data))))
7306 () ; This is a root.
7307 ;; We search until we find an article with a level less than
7308 ;; this one. That function has to be the parent.
7309 (while (and (setq data (cdr data))
7310 (not (< (gnus-data-level (car data)) level))))
7311 (and data (gnus-data-number (car data))))))
7313 (defun gnus-unread-mark-p (mark)
7314 "Say whether MARK is the unread mark."
7315 (= mark gnus-unread-mark))
7317 (defun gnus-read-mark-p (mark)
7318 "Say whether MARK is one of the marks that mark as read.
7319 This is all marks except unread, ticked, dormant, and expirable."
7320 (not (or (= mark gnus-unread-mark)
7321 (= mark gnus-ticked-mark)
7322 (= mark gnus-dormant-mark)
7323 (= mark gnus-expirable-mark))))
7325 ;; Various summary mode internalish functions.
7327 (defun gnus-mouse-pick-article (e)
7330 (gnus-summary-next-page nil t))
7332 (defun gnus-summary-setup-buffer (group)
7333 "Initialize summary buffer."
7334 (let ((buffer (concat "*Summary " group "*")))
7335 (if (get-buffer buffer)
7338 (setq gnus-summary-buffer (current-buffer))
7339 (not gnus-newsgroup-prepared))
7340 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7341 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7342 (gnus-add-current-to-buffer-list)
7343 (gnus-summary-mode group)
7345 (gnus-carpal-setup-buffer 'summary))
7346 (unless gnus-single-article-buffer
7347 (make-local-variable 'gnus-article-buffer)
7348 (make-local-variable 'gnus-article-current)
7349 (make-local-variable 'gnus-original-article-buffer))
7350 (setq gnus-newsgroup-name group)
7353 (defun gnus-set-global-variables ()
7354 ;; Set the global equivalents of the summary buffer-local variables
7355 ;; to the latest values they had. These reflect the summary buffer
7356 ;; that was in action when the last article was fetched.
7357 (when (eq major-mode 'gnus-summary-mode)
7358 (setq gnus-summary-buffer (current-buffer))
7359 (let ((name gnus-newsgroup-name)
7360 (marked gnus-newsgroup-marked)
7361 (unread gnus-newsgroup-unreads)
7362 (headers gnus-current-headers)
7363 (data gnus-newsgroup-data)
7364 (summary gnus-summary-buffer)
7365 (article-buffer gnus-article-buffer)
7366 (original gnus-original-article-buffer)
7367 (gac gnus-article-current)
7368 (score-file gnus-current-score-file))
7370 (set-buffer gnus-group-buffer)
7371 (setq gnus-newsgroup-name name)
7372 (setq gnus-newsgroup-marked marked)
7373 (setq gnus-newsgroup-unreads unread)
7374 (setq gnus-current-headers headers)
7375 (setq gnus-newsgroup-data data)
7376 (setq gnus-article-current gac)
7377 (setq gnus-summary-buffer summary)
7378 (setq gnus-article-buffer article-buffer)
7379 (setq gnus-original-article-buffer original)
7380 (setq gnus-current-score-file score-file)))))
7382 (defun gnus-summary-last-article-p (&optional article)
7383 "Return whether ARTICLE is the last article in the buffer."
7384 (if (not (setq article (or article (gnus-summary-article-number))))
7385 t ; All non-existant numbers are the last article. :-)
7386 (not (cdr (gnus-data-find-list article)))))
7388 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7389 "Insert a dummy root in the summary buffer."
7391 (add-text-properties
7392 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7393 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7395 (defun gnus-make-thread-indent-array ()
7397 (unless (and gnus-thread-indent-array
7398 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7399 (setq gnus-thread-indent-array (make-vector 201 "")
7400 gnus-thread-indent-array-level gnus-thread-indent-level)
7402 (aset gnus-thread-indent-array n
7403 (make-string (* n gnus-thread-indent-level) ? ))
7406 (defun gnus-summary-insert-line
7407 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7408 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7409 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7410 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7411 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7412 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7413 (gnus-tmp-score-char
7414 (if (or (null gnus-summary-default-score)
7415 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7416 gnus-summary-zcore-fuzz)) ?
7417 (if (< gnus-tmp-score gnus-summary-default-score)
7418 gnus-score-below-mark gnus-score-over-mark)))
7419 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7420 ((memq gnus-tmp-current gnus-newsgroup-cached)
7422 (gnus-tmp-replied gnus-replied-mark)
7423 ((memq gnus-tmp-current gnus-newsgroup-saved)
7425 (t gnus-unread-mark)))
7426 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7429 ((string-match "(.+)" gnus-tmp-from)
7430 (substring gnus-tmp-from
7431 (1+ (match-beginning 0)) (1- (match-end 0))))
7432 ((string-match "<[^>]+> *$" gnus-tmp-from)
7433 (let ((beg (match-beginning 0)))
7434 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7435 (substring gnus-tmp-from (1+ (match-beginning 0))
7436 (1- (match-end 0))))
7437 (substring gnus-tmp-from 0 beg))))
7439 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7440 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7441 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7442 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7443 (buffer-read-only nil))
7444 (when (string= gnus-tmp-name "")
7445 (setq gnus-tmp-name gnus-tmp-from))
7446 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7449 (progn (eval gnus-summary-line-format-spec) (point))
7450 'gnus-number gnus-tmp-number)
7451 (when (gnus-visual-p 'summary-highlight 'highlight)
7453 (run-hooks 'gnus-summary-update-hook)
7456 (defun gnus-summary-update-line (&optional dont-update)
7457 ;; Update summary line after change.
7458 (when (and gnus-summary-default-score
7459 (not gnus-summary-inhibit-highlight))
7460 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7461 (article (gnus-summary-article-number))
7462 (score (gnus-summary-article-score article)))
7464 (if (and gnus-summary-mark-below
7465 (< (gnus-summary-article-score)
7466 gnus-summary-mark-below))
7467 ;; This article has a low score, so we mark it as read.
7468 (when (memq article gnus-newsgroup-unreads)
7469 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7470 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7471 ;; This article was previously marked as read on account
7472 ;; of a low score, but now it has risen, so we mark it as
7474 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7475 (gnus-summary-update-mark
7476 (if (or (null gnus-summary-default-score)
7477 (<= (abs (- score gnus-summary-default-score))
7478 gnus-summary-zcore-fuzz)) ?
7479 (if (< score gnus-summary-default-score)
7480 gnus-score-below-mark gnus-score-over-mark)) 'score))
7481 ;; Do visual highlighting.
7482 (when (gnus-visual-p 'summary-highlight 'highlight)
7483 (run-hooks 'gnus-summary-update-hook)))))
7485 (defvar gnus-tmp-new-adopts nil)
7487 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7488 ;; Sum up all elements (and sub-elements) in a list.
7490 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7492 ((and (consp thread) (cdr thread))
7495 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7498 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7501 (when (and level (zerop level) gnus-tmp-new-adopts)
7504 'gnus-summary-number-of-articles-in-thread
7505 gnus-tmp-new-adopts))))
7507 (if (> number 1) gnus-not-empty-thread-mark
7508 gnus-empty-thread-mark)
7511 (defun gnus-summary-set-local-parameters (group)
7512 "Go through the local params of GROUP and set all variable specs in that list."
7513 (let ((params (gnus-info-params (gnus-get-info group)))
7516 (setq elem (car params)
7517 params (cdr params))
7518 (and (consp elem) ; Has to be a cons.
7519 (consp (cdr elem)) ; The cdr has to be a list.
7520 (symbolp (car elem)) ; Has to be a symbol in there.
7521 (not (memq (car elem)
7522 '(quit-config to-address to-list to-group)))
7523 (progn ; So we set it.
7524 (make-local-variable (car elem))
7525 (set (car elem) (eval (nth 1 elem))))))))
7527 (defun gnus-summary-read-group (group &optional show-all no-article
7528 kill-buffer no-display)
7529 "Start reading news in newsgroup GROUP.
7530 If SHOW-ALL is non-nil, already read articles are also listed.
7531 If NO-ARTICLE is non-nil, no article is selected initially.
7532 If NO-DISPLAY, don't generate a summary buffer."
7533 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7534 (let* ((new-group (gnus-summary-setup-buffer group))
7535 (quit-config (gnus-group-quit-config group))
7536 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7538 ;; This summary buffer exists already, so we just select it.
7540 (gnus-set-global-variables)
7542 (gnus-kill-or-deaden-summary kill-buffer))
7543 (gnus-configure-windows 'summary 'force)
7544 (gnus-set-mode-line 'summary)
7545 (gnus-summary-position-point)
7548 ;; We couldn't select this group.
7550 (when (and (eq major-mode 'gnus-summary-mode)
7551 (not (equal (current-buffer) kill-buffer)))
7552 (kill-buffer (current-buffer))
7553 (if (not quit-config)
7555 (set-buffer gnus-group-buffer)
7556 (gnus-group-jump-to-group group)
7557 (gnus-group-next-unread-group 1))
7558 (if (not (buffer-name (car quit-config)))
7559 (gnus-configure-windows 'group 'force)
7560 (set-buffer (car quit-config))
7561 (and (eq major-mode 'gnus-summary-mode)
7562 (gnus-set-global-variables))
7563 (gnus-configure-windows (cdr quit-config)))))
7564 (gnus-message 3 "Can't select group")
7566 ;; The user did a `C-g' while prompting for number of articles,
7567 ;; so we exit this group.
7568 ((eq did-select 'quit)
7569 (and (eq major-mode 'gnus-summary-mode)
7570 (not (equal (current-buffer) kill-buffer))
7571 (kill-buffer (current-buffer)))
7573 (gnus-kill-or-deaden-summary kill-buffer))
7574 (if (not quit-config)
7576 (set-buffer gnus-group-buffer)
7577 (gnus-group-jump-to-group group)
7578 (gnus-group-next-unread-group 1)
7579 (gnus-configure-windows 'group 'force))
7580 (if (not (buffer-name (car quit-config)))
7581 (gnus-configure-windows 'group 'force)
7582 (set-buffer (car quit-config))
7583 (and (eq major-mode 'gnus-summary-mode)
7584 (gnus-set-global-variables))
7585 (gnus-configure-windows (cdr quit-config))))
7586 ;; Finally signal the quit.
7588 ;; The group was successfully selected.
7590 (gnus-set-global-variables)
7591 ;; Save the active value in effect when the group was entered.
7592 (setq gnus-newsgroup-active
7594 (gnus-active gnus-newsgroup-name)))
7595 ;; You can change the summary buffer in some way with this hook.
7596 (run-hooks 'gnus-select-group-hook)
7597 ;; Set any local variables in the group parameters.
7598 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7599 (gnus-update-format-specifications)
7600 ;; Do score processing.
7601 (when gnus-use-scoring
7602 (gnus-possibly-score-headers))
7603 ;; Check whether to fill in the gaps in the threads.
7604 (when gnus-build-sparse-threads
7605 (gnus-build-sparse-threads))
7606 ;; Find the initial limit.
7607 (if gnus-show-threads
7609 (let ((gnus-newsgroup-dormant nil))
7610 (gnus-summary-initial-limit show-all))
7611 (gnus-summary-initial-limit show-all))
7612 (setq gnus-newsgroup-limit
7614 (lambda (header) (mail-header-number header))
7615 gnus-newsgroup-headers)))
7616 ;; Generate the summary buffer.
7618 (gnus-summary-prepare))
7619 (when gnus-use-trees
7620 (gnus-tree-open group)
7621 (setq gnus-summary-highlight-line-function
7622 'gnus-tree-highlight-article))
7623 ;; If the summary buffer is empty, but there are some low-scored
7624 ;; articles or some excluded dormants, we include these in the
7626 (when (and (zerop (buffer-size))
7628 (cond (gnus-newsgroup-dormant
7629 (gnus-summary-limit-include-dormant))
7630 ((and gnus-newsgroup-scored show-all)
7631 (gnus-summary-limit-include-expunged))))
7632 ;; Function `gnus-apply-kill-file' must be called in this hook.
7633 (run-hooks 'gnus-apply-kill-hook)
7634 (if (and (zerop (buffer-size))
7637 ;; This newsgroup is empty.
7638 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7639 (gnus-message 6 "No unread news")
7641 (gnus-kill-or-deaden-summary kill-buffer))
7642 ;; Return nil from this function.
7644 ;; Hide conversation thread subtrees. We cannot do this in
7645 ;; gnus-summary-prepare-hook since kill processing may not
7646 ;; work with hidden articles.
7647 (and gnus-show-threads
7648 gnus-thread-hide-subtree
7649 (gnus-summary-hide-all-threads))
7650 ;; Show first unread article if requested.
7651 (if (and (not no-article)
7653 gnus-newsgroup-unreads
7654 gnus-auto-select-first)
7655 (unless (if (eq gnus-auto-select-first 'best)
7656 (gnus-summary-best-unread-article)
7657 (gnus-summary-first-unread-article))
7658 (gnus-configure-windows 'summary))
7659 ;; Don't select any articles, just move point to the first
7660 ;; article in the group.
7661 (goto-char (point-min))
7662 (gnus-summary-position-point)
7663 (gnus-set-mode-line 'summary)
7664 (gnus-configure-windows 'summary 'force))
7665 ;; If we are in async mode, we send some info to the backend.
7666 (when gnus-newsgroup-async
7667 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7669 (gnus-kill-or-deaden-summary kill-buffer))
7670 (when (get-buffer-window gnus-group-buffer t)
7671 ;; Gotta use windows, because recenter does wierd stuff if
7672 ;; the current buffer ain't the displayed window.
7673 (let ((owin (selected-window)))
7674 (select-window (get-buffer-window gnus-group-buffer t))
7675 (when (gnus-group-goto-group group)
7677 (select-window owin))))
7678 ;; Mark this buffer as "prepared".
7679 (setq gnus-newsgroup-prepared t)
7682 (defun gnus-summary-prepare ()
7683 "Generate the summary buffer."
7684 (let ((buffer-read-only nil))
7686 (setq gnus-newsgroup-data nil
7687 gnus-newsgroup-data-reverse nil)
7688 (run-hooks 'gnus-summary-generate-hook)
7689 ;; Generate the buffer, either with threads or without.
7690 (when gnus-newsgroup-headers
7691 (gnus-summary-prepare-threads
7692 (if gnus-show-threads
7693 (gnus-sort-gathered-threads
7694 (funcall gnus-summary-thread-gathering-function
7696 (gnus-cut-threads (gnus-make-threads)))))
7697 ;; Unthreaded display.
7698 (gnus-sort-articles gnus-newsgroup-headers))))
7699 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7700 ;; Call hooks for modifying summary buffer.
7701 (goto-char (point-min))
7702 (run-hooks 'gnus-summary-prepare-hook)))
7704 (defun gnus-gather-threads-by-subject (threads)
7705 "Gather threads by looking at Subject headers."
7706 (if (not gnus-summary-make-false-root)
7708 (let ((hashtb (gnus-make-hashtable 1023))
7711 subject hthread whole-subject)
7713 (setq whole-subject (mail-header-subject (caar threads)))
7716 ;; Truncate the subject.
7717 ((numberp gnus-summary-gather-subject-limit)
7718 (setq subject (gnus-simplify-subject-re whole-subject))
7719 (if (> (length subject) gnus-summary-gather-subject-limit)
7720 (substring subject 0 gnus-summary-gather-subject-limit)
7722 ;; Fuzzily simplify it.
7723 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7724 (gnus-simplify-subject-fuzzy whole-subject))
7725 ;; Just remove the leading "Re:".
7727 (gnus-simplify-subject-re whole-subject))))
7729 (if (and gnus-summary-gather-exclude-subject
7730 (string-match gnus-summary-gather-exclude-subject
7732 () ; We don't want to do anything with this article.
7733 ;; We simplify the subject before looking it up in the
7736 (if (setq hthread (gnus-gethash subject hashtb))
7738 ;; We enter a dummy root into the thread, if we
7739 ;; haven't done that already.
7740 (unless (stringp (caar hthread))
7741 (setcar hthread (list whole-subject (car hthread))))
7742 ;; We add this new gathered thread to this gathered
7744 (setcdr (car hthread)
7745 (nconc (cdar hthread) (list (car threads))))
7746 ;; Remove it from the list of threads.
7747 (setcdr prev (cdr threads))
7748 (setq threads prev))
7749 ;; Enter this thread into the hash table.
7750 (gnus-sethash subject threads hashtb)))
7752 (setq threads (cdr threads)))
7755 (defun gnus-gather-threads-by-references (threads)
7756 "Gather threads by looking at References headers."
7757 (let ((idhashtb (gnus-make-hashtable 1023))
7758 (thhashtb (gnus-make-hashtable 1023))
7761 ids references id gthread gid entered)
7763 (when (setq references (mail-header-references (caar threads)))
7764 (setq id (mail-header-id (caar threads)))
7765 (setq ids (gnus-split-references references))
7768 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7770 (gnus-sethash (car ids) id idhashtb)
7771 (gnus-sethash id threads thhashtb))
7772 (setq gthread (gnus-gethash gid thhashtb))
7774 ;; We enter a dummy root into the thread, if we
7775 ;; haven't done that already.
7776 (unless (stringp (caar gthread))
7777 (setcar gthread (list (mail-header-subject (caar gthread))
7779 ;; We add this new gathered thread to this gathered
7781 (setcdr (car gthread)
7782 (nconc (cdar gthread) (list (car threads)))))
7783 ;; Add it into the thread hash table.
7784 (gnus-sethash id gthread thhashtb)
7786 ;; Remove it from the list of threads.
7787 (setcdr prev (cdr threads))
7788 (setq threads prev))
7789 (setq ids (cdr ids))))
7791 (setq threads (cdr threads)))
7794 (defun gnus-sort-gathered-threads (threads)
7795 "Sort subtreads inside each gathered thread by article number."
7796 (let ((result threads))
7798 (when (stringp (caar threads))
7799 (setcdr (car threads)
7800 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7801 (setq threads (cdr threads)))
7804 (defun gnus-make-threads ()
7805 "Go through the dependency hashtb and find the roots. Return all threads."
7809 (unless (car (symbol-value refs))
7810 ;; These threads do not refer back to any other articles,
7811 ;; so they're roots.
7812 (setq threads (append (cdr (symbol-value refs)) threads))))
7813 gnus-newsgroup-dependencies)
7816 (defun gnus-build-sparse-threads ()
7817 (let ((headers gnus-newsgroup-headers)
7818 (deps gnus-newsgroup-dependencies)
7819 header references generation relations
7820 cthread subject child end pthread relation)
7821 ;; First we create an alist of generations/relations, where
7822 ;; generations is how much we trust the ralation, and the relation
7824 (gnus-message 7 "Making sparse threads...")
7826 (nnheader-set-temp-buffer " *gnus sparse threads*")
7827 (while (setq header (pop headers))
7828 (when (and (setq references (mail-header-references header))
7829 (not (string= references "")))
7831 (setq child (mail-header-id header)
7832 subject (mail-header-subject header))
7834 (while (search-backward ">" nil t)
7835 (setq end (1+ (point)))
7836 (when (search-backward "<" nil t)
7837 (push (list (incf generation)
7838 child (setq child (buffer-substring (point) end))
7841 (push (list (1+ generation) child nil subject) relations)
7843 (kill-buffer (current-buffer)))
7844 ;; Sort over trustworthiness.
7845 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7846 (while (setq relation (pop relations))
7847 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7848 (unless (car (symbol-value cthread))
7849 ;; Make this article the parent of these threads.
7850 (setcar (symbol-value cthread)
7851 (vector gnus-reffed-article-number
7855 (or (caddr relation) "") 0 0 "")))
7856 (set cthread (list (vector gnus-reffed-article-number
7858 "" "" (cadr relation)
7859 (or (caddr relation) "") 0 0 ""))))
7860 (push gnus-reffed-article-number gnus-newsgroup-limit)
7861 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7862 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7863 gnus-newsgroup-reads)
7864 (decf gnus-reffed-article-number)
7865 ;; Make this new thread the child of its parent.
7866 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7867 (setcdr (symbol-value pthread)
7868 (nconc (cdr (symbol-value pthread))
7869 (list (symbol-value cthread))))
7870 (set pthread (list nil (symbol-value cthread))))))
7871 (gnus-message 7 "Making sparse threads...done")))
7873 (defun gnus-build-old-threads ()
7874 ;; Look at all the articles that refer back to old articles, and
7875 ;; fetch the headers for the articles that aren't there. This will
7876 ;; build complete threads - if the roots haven't been expired by the
7881 (when (not (car (symbol-value refs)))
7882 (setq heads (cdr (symbol-value refs)))
7884 (if (memq (mail-header-number (caar heads))
7885 gnus-newsgroup-dormant)
7886 (setq heads (cdr heads))
7887 (setq id (symbol-name refs))
7888 (while (and (setq id (gnus-build-get-header id))
7889 (not (car (gnus-gethash
7890 id gnus-newsgroup-dependencies)))))
7891 (setq heads nil)))))
7892 gnus-newsgroup-dependencies)))
7894 (defun gnus-build-get-header (id)
7895 ;; Look through the buffer of NOV lines and find the header to
7896 ;; ID. Enter this line into the dependencies hash table, and return
7897 ;; the id of the parent article (if any).
7898 (let ((deps gnus-newsgroup-dependencies)
7902 (set-buffer nntp-server-buffer)
7903 (goto-char (point-min))
7904 (while (and (not found) (search-forward id nil t))
7906 (setq found (looking-at
7907 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7908 (regexp-quote id))))
7909 (or found (beginning-of-line 2)))
7913 (setq header (gnus-nov-parse-line
7914 (read (current-buffer)) deps))
7915 (gnus-parent-id (mail-header-references header)))))
7917 (let ((number (mail-header-number header)))
7918 (push number gnus-newsgroup-limit)
7919 (push header gnus-newsgroup-headers)
7920 (if (memq number gnus-newsgroup-unselected)
7922 (push number gnus-newsgroup-unreads)
7923 (setq gnus-newsgroup-unselected
7924 (delq number gnus-newsgroup-unselected)))
7925 (push number gnus-newsgroup-ancient)))))))
7927 (defun gnus-summary-update-article (article &optional header)
7928 "Update ARTICLE in the summary buffer."
7929 (set-buffer gnus-summary-buffer)
7930 (let* ((header (or header (gnus-summary-article-header article)))
7931 (id (mail-header-id header))
7932 (data (gnus-data-find article))
7933 (thread (gnus-id-to-thread id))
7935 (gnus-id-to-thread (or (gnus-parent-id
7936 (mail-header-references header))
7938 (buffer-read-only nil)
7940 (number (mail-header-number header))
7945 (delq thread parent))
7946 (if (gnus-summary-insert-subject id header)
7947 ;; Set the (possibly) new article number in the data structure.
7948 (gnus-data-set-number data (gnus-id-to-article id))
7952 (defun gnus-rebuild-thread (id)
7953 "Rebuild the thread containing ID."
7954 (let ((buffer-read-only nil)
7955 current thread data)
7956 (if (not gnus-show-threads)
7957 (setq thread (list (car (gnus-id-to-thread id))))
7958 ;; Get the thread this article is part of.
7959 (setq thread (gnus-remove-thread id)))
7960 (setq current (save-excursion
7961 (and (zerop (forward-line -1))
7962 (gnus-summary-article-number))))
7963 ;; If this is a gathered thread, we have to go some re-gathering.
7964 (when (stringp (car thread))
7965 (let ((subject (car thread))
7967 (setq thread (cdr thread))
7969 (unless (memq (setq thr (gnus-id-to-thread
7971 (mail-header-id (caar thread)))))
7974 (setq thread (cdr thread)))
7975 ;; We now have all (unique) roots.
7976 (if (= (length roots) 1)
7977 ;; All the loose roots are now one solid root.
7978 (setq thread (car roots))
7979 (setq thread (cons subject (gnus-sort-threads roots))))))
7981 ;; We then insert this thread into the summary buffer.
7982 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7983 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
7984 (setq data (nreverse gnus-newsgroup-data))
7985 (setq threads gnus-newsgroup-threads))
7986 ;; We splice the new data into the data structure.
7987 (gnus-data-enter-list current data)
7988 (gnus-data-compute-positions)
7989 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7991 (defun gnus-id-to-thread (id)
7992 "Return the (sub-)thread where ID appears."
7993 (gnus-gethash id gnus-newsgroup-dependencies))
7995 (defun gnus-id-to-article (id)
7996 "Return the article number of ID."
7997 (let ((thread (gnus-id-to-thread id)))
7999 (mail-header-number (car thread)))))
8001 (defun gnus-id-to-header (id)
8002 "Return the article headers of ID."
8003 (car (gnus-id-to-thread id)))
8005 (defun gnus-article-displayed-root-p (article)
8006 "Say whether ARTICLE is a root(ish) article."
8007 (let ((level (gnus-summary-thread-level article))
8013 (null (setq particle (gnus-id-to-article
8015 (mail-header-references
8016 (gnus-summary-article-header article))))))
8017 (null (gnus-summary-thread-level particle)))))))
8019 (defun gnus-root-id (id)
8020 "Return the id of the root of the thread where ID appears."
8022 (while (and id (setq prev (car (gnus-gethash
8023 id gnus-newsgroup-dependencies))))
8025 id (gnus-parent-id (mail-header-references prev))))
8028 (defun gnus-remove-thread (id &optional dont-remove)
8029 "Remove the thread that has ID in it."
8030 (let ((dep gnus-newsgroup-dependencies)
8031 headers thread last-id)
8032 ;; First go up in this thread until we find the root.
8033 (setq last-id (gnus-root-id id))
8034 (setq headers (list (car (gnus-id-to-thread last-id))
8035 (caadr (gnus-id-to-thread last-id))))
8036 ;; We have now found the real root of this thread. It might have
8037 ;; been gathered into some loose thread, so we have to search
8038 ;; through the threads to find the thread we wanted.
8039 (let ((threads gnus-newsgroup-threads)
8042 (setq sub (car threads))
8043 (if (stringp (car sub))
8044 ;; This is a gathered threads, so we look at the roots
8045 ;; below it to find whether this article in in this
8048 (setq sub (cdr sub))
8050 (when (member (caar sub) headers)
8051 (setq thread (car threads)
8054 (setq sub (cdr sub))))
8055 ;; It's an ordinary thread, so we check it.
8056 (when (eq (car sub) (car headers))
8059 (setq threads (cdr threads)))
8060 ;; If this article is in no thread, then it's a root.
8063 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8064 (setq thread (gnus-gethash last-id dep)))
8067 thread ; We return this thread.
8069 (if (stringp (car thread))
8071 ;; If we use dummy roots, then we have to remove the
8072 ;; dummy root as well.
8073 (when (eq gnus-summary-make-false-root 'dummy)
8076 (setq thread (cdr thread))
8078 (gnus-remove-thread-1 (car thread))
8079 (setq thread (cdr thread))))
8080 (gnus-remove-thread-1 thread))))))))
8082 (defun gnus-remove-thread-1 (thread)
8083 "Remove the thread THREAD recursively."
8084 (let ((number (mail-header-number (car thread)))
8086 (when (setq pos (text-property-any
8087 (point-min) (point-max) 'gnus-number number))
8090 (gnus-data-remove number))
8091 (setq thread (cdr thread))
8093 (gnus-remove-thread-1 (pop thread)))))
8095 (defun gnus-sort-threads (threads)
8097 (if (not gnus-thread-sort-functions)
8099 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8100 (car gnus-thread-sort-functions)
8102 ,(gnus-make-sort-function
8103 (reverse gnus-thread-sort-functions))))))
8104 (gnus-message 7 "Sorting threads...")
8107 (gnus-message 7 "Sorting threads...done")))))
8109 (defun gnus-sort-articles (articles)
8111 (when gnus-article-sort-functions
8112 (let ((func (if (= 1 (length gnus-article-sort-functions))
8113 (car gnus-article-sort-functions)
8115 ,(gnus-make-sort-function
8116 (reverse gnus-article-sort-functions))))))
8117 (gnus-message 7 "Sorting articles...")
8119 (setq gnus-newsgroup-headers (sort articles func))
8120 (gnus-message 7 "Sorting articles...done")))))
8122 (defun gnus-make-sort-function (funs)
8123 "Return a composite sort condition based on the functions in FUNC."
8125 `(or (,(car funs) t1 t2)
8126 (and (not (,(car funs) t2 t1))
8127 ,(gnus-make-sort-function (cdr funs))))
8128 `(,(car funs) t1 t2)))
8130 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8131 (defmacro gnus-thread-header (thread)
8132 ;; Return header of first article in THREAD.
8133 ;; Note that THREAD must never, ever be anything else than a variable -
8134 ;; using some other form will lead to serious barfage.
8135 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8136 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8137 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8140 (defsubst gnus-article-sort-by-number (h1 h2)
8141 "Sort articles by article number."
8142 (< (mail-header-number h1)
8143 (mail-header-number h2)))
8145 (defun gnus-thread-sort-by-number (h1 h2)
8146 "Sort threads by root article number."
8147 (gnus-article-sort-by-number
8148 (gnus-thread-header h1) (gnus-thread-header h2)))
8150 (defsubst gnus-article-sort-by-author (h1 h2)
8151 "Sort articles by root author."
8153 (let ((extract (funcall
8154 gnus-extract-address-components
8155 (mail-header-from h1))))
8156 (or (car extract) (cdr extract)))
8157 (let ((extract (funcall
8158 gnus-extract-address-components
8159 (mail-header-from h2))))
8160 (or (car extract) (cdr extract)))))
8162 (defun gnus-thread-sort-by-author (h1 h2)
8163 "Sort threads by root author."
8164 (gnus-article-sort-by-author
8165 (gnus-thread-header h1) (gnus-thread-header h2)))
8167 (defsubst gnus-article-sort-by-subject (h1 h2)
8168 "Sort articles by root subject."
8170 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8171 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8173 (defun gnus-thread-sort-by-subject (h1 h2)
8174 "Sort threads by root subject."
8175 (gnus-article-sort-by-subject
8176 (gnus-thread-header h1) (gnus-thread-header h2)))
8178 (defsubst gnus-article-sort-by-date (h1 h2)
8179 "Sort articles by root article date."
8181 (gnus-sortable-date (mail-header-date h1))
8182 (gnus-sortable-date (mail-header-date h2))))
8184 (defun gnus-thread-sort-by-date (h1 h2)
8185 "Sort threads by root article date."
8186 (gnus-article-sort-by-date
8187 (gnus-thread-header h1) (gnus-thread-header h2)))
8189 (defsubst gnus-article-sort-by-score (h1 h2)
8190 "Sort articles by root article score.
8191 Unscored articles will be counted as having a score of zero."
8192 (> (or (cdr (assq (mail-header-number h1)
8193 gnus-newsgroup-scored))
8194 gnus-summary-default-score 0)
8195 (or (cdr (assq (mail-header-number h2)
8196 gnus-newsgroup-scored))
8197 gnus-summary-default-score 0)))
8199 (defun gnus-thread-sort-by-score (h1 h2)
8200 "Sort threads by root article score."
8201 (gnus-article-sort-by-score
8202 (gnus-thread-header h1) (gnus-thread-header h2)))
8204 (defun gnus-thread-sort-by-total-score (h1 h2)
8205 "Sort threads by the sum of all scores in the thread.
8206 Unscored articles will be counted as having a score of zero."
8207 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8209 (defun gnus-thread-total-score (thread)
8210 ;; This function find the total score of THREAD.
8212 (if (stringp (car thread))
8213 (apply gnus-thread-score-function 0
8214 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8215 (gnus-thread-total-score-1 thread))
8216 (gnus-thread-total-score-1 (list thread))))
8218 (defun gnus-thread-total-score-1 (root)
8219 ;; This function find the total score of the thread below ROOT.
8220 (setq root (car root))
8221 (apply gnus-thread-score-function
8222 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8223 gnus-summary-default-score 0)
8224 (mapcar 'gnus-thread-total-score
8225 (cdr (gnus-gethash (mail-header-id root)
8226 gnus-newsgroup-dependencies)))))
8228 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8229 (defvar gnus-tmp-prev-subject nil)
8230 (defvar gnus-tmp-false-parent nil)
8231 (defvar gnus-tmp-root-expunged nil)
8232 (defvar gnus-tmp-dummy-line nil)
8234 (defun gnus-summary-prepare-threads (threads)
8235 "Prepare summary buffer from THREADS and indentation LEVEL.
8236 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8237 or a straight list of headers."
8238 (gnus-message 7 "Generating summary...")
8240 (setq gnus-newsgroup-threads threads)
8243 (let ((gnus-tmp-level 0)
8244 (default-score (or gnus-summary-default-score 0))
8245 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8246 thread number subject stack state gnus-tmp-gathered beg-match
8247 new-roots gnus-tmp-new-adopts thread-end
8248 gnus-tmp-header gnus-tmp-unread
8249 gnus-tmp-replied gnus-tmp-subject-or-nil
8250 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8251 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8252 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8254 (setq gnus-tmp-prev-subject nil)
8256 (if (vectorp (car threads))
8257 ;; If this is a straight (sic) list of headers, then a
8258 ;; threaded summary display isn't required, so we just create
8259 ;; an unthreaded one.
8260 (gnus-summary-prepare-unthreaded threads)
8262 ;; Do the threaded display.
8264 (while (or threads stack gnus-tmp-new-adopts new-roots)
8266 (if (and (= gnus-tmp-level 0)
8267 (not (setq gnus-tmp-dummy-line nil))
8270 (not gnus-tmp-false-parent)
8271 (or gnus-tmp-new-adopts new-roots))
8272 (if gnus-tmp-new-adopts
8273 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8274 thread (list (car gnus-tmp-new-adopts))
8275 gnus-tmp-header (caar thread)
8276 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8278 (setq thread (list (car new-roots))
8279 gnus-tmp-header (caar thread)
8280 new-roots (cdr new-roots))))
8283 ;; If there are some threads, we do them before the
8284 ;; threads on the stack.
8285 (setq thread threads
8286 gnus-tmp-header (caar thread))
8287 ;; There were no current threads, so we pop something off
8289 (setq state (car stack)
8290 gnus-tmp-level (car state)
8293 gnus-tmp-header (caar thread))))
8295 (setq gnus-tmp-false-parent nil)
8296 (setq gnus-tmp-root-expunged nil)
8297 (setq thread-end nil)
8299 (if (stringp gnus-tmp-header)
8300 ;; The header is a dummy root.
8302 ((eq gnus-summary-make-false-root 'adopt)
8303 ;; We let the first article adopt the rest.
8304 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8306 (setq gnus-tmp-gathered
8308 (lambda (h) (mail-header-number (car h)))
8311 (setq thread (cons (list (caar thread)
8314 (setq gnus-tmp-level -1
8315 gnus-tmp-false-parent t))
8316 ((eq gnus-summary-make-false-root 'empty)
8317 ;; We print adopted articles with empty subject fields.
8318 (setq gnus-tmp-gathered
8320 (lambda (h) (mail-header-number (car h)))
8323 (setq gnus-tmp-level -1))
8324 ((eq gnus-summary-make-false-root 'dummy)
8325 ;; We remember that we probably want to output a dummy
8327 (setq gnus-tmp-dummy-line gnus-tmp-header)
8328 (setq gnus-tmp-prev-subject gnus-tmp-header))
8330 ;; We do not make a root for the gathered
8331 ;; sub-threads at all.
8332 (setq gnus-tmp-level -1)))
8334 (setq number (mail-header-number gnus-tmp-header)
8335 subject (mail-header-subject gnus-tmp-header))
8338 ;; If the thread has changed subject, we might want to make
8339 ;; this subthread into a root.
8340 ((and (null gnus-thread-ignore-subject)
8341 (not (zerop gnus-tmp-level))
8342 gnus-tmp-prev-subject
8344 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8345 (setq new-roots (nconc new-roots (list (car thread)))
8347 gnus-tmp-header nil))
8348 ;; If the article lies outside the current limit,
8349 ;; then we do not display it.
8350 ((and (not (memq number gnus-newsgroup-limit))
8351 (not gnus-tmp-dummy-line))
8352 (setq gnus-tmp-gathered
8354 (lambda (h) (mail-header-number (car h)))
8357 (setq gnus-tmp-new-adopts (if (cdar thread)
8358 (append gnus-tmp-new-adopts
8360 gnus-tmp-new-adopts)
8362 gnus-tmp-header nil)
8363 (when (zerop gnus-tmp-level)
8364 (setq gnus-tmp-root-expunged t)))
8365 ;; Perhaps this article is to be marked as read?
8366 ((and gnus-summary-mark-below
8367 (< (or (cdr (assq number gnus-newsgroup-scored))
8369 gnus-summary-mark-below)
8370 ;; Don't touch sparse articles.
8371 (not (memq number gnus-newsgroup-sparse)))
8372 (setq gnus-newsgroup-unreads
8373 (delq number gnus-newsgroup-unreads))
8374 (if gnus-newsgroup-auto-expire
8375 (push number gnus-newsgroup-expirable)
8376 (push (cons number gnus-low-score-mark)
8377 gnus-newsgroup-reads))))
8379 (when gnus-tmp-header
8380 ;; We may have an old dummy line to output before this
8382 (when gnus-tmp-dummy-line
8383 (gnus-summary-insert-dummy-line
8384 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8385 (setq gnus-tmp-dummy-line nil))
8387 ;; Compute the mark.
8391 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8392 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8393 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8394 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8395 (t (or (cdr (assq number gnus-newsgroup-reads))
8396 gnus-ancient-mark))))
8398 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8399 gnus-tmp-header gnus-tmp-level)
8400 gnus-newsgroup-data)
8402 ;; Actually insert the line.
8404 gnus-tmp-subject-or-nil
8406 ((and gnus-thread-ignore-subject
8407 gnus-tmp-prev-subject
8408 (not (inline (gnus-subject-equal
8409 gnus-tmp-prev-subject subject))))
8411 ((zerop gnus-tmp-level)
8412 (if (and (eq gnus-summary-make-false-root 'empty)
8413 (memq number gnus-tmp-gathered)
8414 gnus-tmp-prev-subject
8415 (inline (gnus-subject-equal
8416 gnus-tmp-prev-subject subject)))
8417 gnus-summary-same-subject
8419 (t gnus-summary-same-subject)))
8420 (if (and (eq gnus-summary-make-false-root 'adopt)
8421 (= gnus-tmp-level 1)
8422 (memq number gnus-tmp-gathered))
8423 (setq gnus-tmp-opening-bracket ?\<
8424 gnus-tmp-closing-bracket ?\>)
8425 (setq gnus-tmp-opening-bracket ?\[
8426 gnus-tmp-closing-bracket ?\]))
8428 gnus-tmp-indentation
8429 (aref gnus-thread-indent-array gnus-tmp-level)
8430 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8431 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8432 gnus-summary-default-score 0)
8434 (if (or (null gnus-summary-default-score)
8435 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8436 gnus-summary-zcore-fuzz)) ?
8437 (if (< gnus-tmp-score gnus-summary-default-score)
8438 gnus-score-below-mark gnus-score-over-mark))
8440 (cond ((memq number gnus-newsgroup-processable)
8442 ((memq number gnus-newsgroup-cached)
8444 ((memq number gnus-newsgroup-replied)
8446 (t gnus-unread-mark))
8447 gnus-tmp-from (mail-header-from gnus-tmp-header)
8450 ((string-match "(.+)" gnus-tmp-from)
8451 (substring gnus-tmp-from
8452 (1+ (match-beginning 0)) (1- (match-end 0))))
8453 ((string-match "<[^>]+> *$" gnus-tmp-from)
8454 (setq beg-match (match-beginning 0))
8455 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8456 (substring gnus-tmp-from (1+ (match-beginning 0))
8457 (1- (match-end 0))))
8458 (substring gnus-tmp-from 0 beg-match)))
8460 (when (string= gnus-tmp-name "")
8461 (setq gnus-tmp-name gnus-tmp-from))
8462 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8465 (progn (eval gnus-summary-line-format-spec) (point))
8466 'gnus-number number)
8469 (run-hooks 'gnus-summary-update-hook)
8472 (setq gnus-tmp-prev-subject subject)))
8474 (when (nth 1 thread)
8475 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8476 (incf gnus-tmp-level)
8477 (setq threads (if thread-end nil (cdar thread)))
8479 (setq gnus-tmp-level 0)))))
8480 (gnus-message 7 "Generating summary...done"))
8482 (defun gnus-summary-prepare-unthreaded (headers)
8483 "Generate an unthreaded summary buffer based on HEADERS."
8484 (let (header number mark)
8487 ;; We may have to root out some bad articles...
8488 (when (memq (setq number (mail-header-number
8489 (setq header (pop headers))))
8490 gnus-newsgroup-limit)
8491 ;; Mark article as read when it has a low score.
8492 (when (and gnus-summary-mark-below
8493 (< (or (cdr (assq number gnus-newsgroup-scored))
8494 gnus-summary-default-score 0)
8495 gnus-summary-mark-below))
8496 (setq gnus-newsgroup-unreads
8497 (delq number gnus-newsgroup-unreads))
8498 (if gnus-newsgroup-auto-expire
8499 (push number gnus-newsgroup-expirable)
8500 (push (cons number gnus-low-score-mark)
8501 gnus-newsgroup-reads)))
8505 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8506 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8507 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8508 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8509 (t (or (cdr (assq number gnus-newsgroup-reads))
8510 gnus-ancient-mark))))
8511 (setq gnus-newsgroup-data
8512 (cons (gnus-data-make number mark (1+ (point)) header 0)
8513 gnus-newsgroup-data))
8514 (gnus-summary-insert-line
8515 header 0 nil mark (memq number gnus-newsgroup-replied)
8516 (memq number gnus-newsgroup-expirable)
8517 (mail-header-subject header) nil
8518 (cdr (assq number gnus-newsgroup-scored))
8519 (memq number gnus-newsgroup-processable))))))
8521 (defun gnus-select-newsgroup (group &optional read-all)
8522 "Select newsgroup GROUP.
8523 If READ-ALL is non-nil, all articles in the group are selected."
8524 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8525 (info (nth 2 entry))
8526 articles fetched-articles cached)
8528 (or (gnus-check-server
8529 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8530 (error "Couldn't open server"))
8532 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8533 (gnus-activate-group group) ; Or we can activate it...
8534 (progn ; Or we bug out.
8535 (when (equal major-mode 'gnus-summary-mode)
8536 (kill-buffer (current-buffer)))
8537 (error "Couldn't request group %s: %s"
8538 group (gnus-status-message group))))
8540 (setq gnus-newsgroup-name group)
8541 (setq gnus-newsgroup-unselected nil)
8542 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8544 (and gnus-asynchronous
8545 (gnus-check-backend-function
8546 'request-asynchronous gnus-newsgroup-name)
8547 (setq gnus-newsgroup-async
8548 (gnus-request-asynchronous gnus-newsgroup-name)))
8550 ;; Adjust and set lists of article marks.
8552 (gnus-adjust-marked-articles info))
8554 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8555 (when (gnus-virtual-group-p group)
8556 (setq cached gnus-newsgroup-cached))
8558 (setq gnus-newsgroup-unreads
8559 (gnus-set-difference
8560 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8561 gnus-newsgroup-dormant))
8563 (setq gnus-newsgroup-processable nil)
8565 (setq articles (gnus-articles-to-read group read-all))
8569 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8571 ((eq articles 0) nil)
8573 ;; Init the dependencies hash table.
8574 (setq gnus-newsgroup-dependencies
8575 (gnus-make-hashtable (length articles)))
8576 ;; Retrieve the headers and read them in.
8577 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8578 (setq gnus-newsgroup-headers
8580 (setq gnus-headers-retrieved-by
8581 (gnus-retrieve-headers
8582 articles gnus-newsgroup-name
8583 ;; We might want to fetch old headers, but
8584 ;; not if there is only 1 article.
8585 (and gnus-fetch-old-headers
8587 (not (eq gnus-fetch-old-headers 'some))
8588 (not (numberp gnus-fetch-old-headers)))
8589 (> (length articles) 1))))))
8590 (gnus-get-newsgroup-headers-xover articles)
8591 (gnus-get-newsgroup-headers)))
8592 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8594 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8596 (setq gnus-newsgroup-cached cached))
8598 ;; Set the initial limit.
8599 (setq gnus-newsgroup-limit (copy-sequence articles))
8600 ;; Remove canceled articles from the list of unread articles.
8601 (setq gnus-newsgroup-unreads
8602 (gnus-set-sorted-intersection
8603 gnus-newsgroup-unreads
8604 (setq fetched-articles
8605 (mapcar (lambda (headers) (mail-header-number headers))
8606 gnus-newsgroup-headers))))
8607 ;; Removed marked articles that do not exist.
8608 (gnus-update-missing-marks
8609 (gnus-sorted-complement fetched-articles articles))
8610 ;; We might want to build some more threads first.
8611 (and gnus-fetch-old-headers
8612 (eq gnus-headers-retrieved-by 'nov)
8613 (gnus-build-old-threads))
8614 ;; Check whether auto-expire is to be done in this group.
8615 (setq gnus-newsgroup-auto-expire
8616 (gnus-group-auto-expirable-p group))
8617 ;; Set up the article buffer now, if necessary.
8618 (unless gnus-single-article-buffer
8619 (gnus-article-setup-buffer))
8620 ;; First and last article in this newsgroup.
8621 (and gnus-newsgroup-headers
8622 (setq gnus-newsgroup-begin
8623 (mail-header-number (car gnus-newsgroup-headers)))
8624 (setq gnus-newsgroup-end
8626 (gnus-last-element gnus-newsgroup-headers))))
8627 (setq gnus-reffed-article-number -1)
8628 ;; GROUP is successfully selected.
8629 (or gnus-newsgroup-headers t)))))
8631 (defun gnus-articles-to-read (group read-all)
8632 ;; Find out what articles the user wants to read.
8634 ;; Select all articles if `read-all' is non-nil, or if there
8635 ;; are no unread articles.
8637 (and (zerop (length gnus-newsgroup-marked))
8638 (zerop (length gnus-newsgroup-unreads))))
8639 (gnus-uncompress-range (gnus-active group))
8640 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8641 (copy-sequence gnus-newsgroup-unreads))
8643 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8644 (scored (length scored-list))
8645 (number (length articles))
8646 (marked (+ (length gnus-newsgroup-marked)
8647 (length gnus-newsgroup-dormant)))
8655 ((and (or (<= scored marked) (= scored number))
8656 (numberp gnus-large-newsgroup)
8657 (> number gnus-large-newsgroup))
8661 "How many articles from %s (default %d): "
8662 gnus-newsgroup-name number))))
8663 (if (string-match "^[ \t]*$" input) number input)))
8664 ((and (> scored marked) (< scored number))
8667 (format "%s %s (%d scored, %d total): "
8668 "How many articles from"
8669 group scored number))))
8670 (if (string-match "^[ \t]*$" input)
8674 (setq select (if (stringp select) (string-to-number select) select))
8675 (if (or (null select) (zerop select))
8677 (if (and (not (zerop scored)) (<= (abs select) scored))
8679 (setq articles (sort scored-list '<))
8680 (setq number (length articles)))
8681 (setq articles (copy-sequence articles)))
8683 (if (< (abs select) number)
8685 ;; Select the N oldest articles.
8686 (setcdr (nthcdr (1- (abs select)) articles) nil)
8687 ;; Select the N most recent articles.
8688 (setq articles (nthcdr (- number select) articles))))
8689 (setq gnus-newsgroup-unselected
8690 (gnus-sorted-intersection
8691 gnus-newsgroup-unreads
8692 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8695 (defun gnus-killed-articles (killed articles)
8698 (if (inline (gnus-member-of-range (car articles) killed))
8699 (setq out (cons (car articles) out)))
8700 (setq articles (cdr articles)))
8703 (defun gnus-uncompress-marks (marks)
8704 "Uncompress the mark ranges in MARKS."
8705 (let ((uncompressed '(score bookmark))
8708 (if (memq (caar marks) uncompressed)
8709 (push (car marks) out)
8710 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8711 (setq marks (cdr marks)))
8714 (defun gnus-adjust-marked-articles (info)
8715 "Set all article lists and remove all marks that are no longer legal."
8716 (let* ((marked-lists (gnus-info-marks info))
8717 (active (gnus-active (gnus-info-group info)))
8720 (types gnus-article-mark-lists)
8721 (uncompressed '(score bookmark))
8722 marks var articles article mark)
8725 (setq marks (pop marked-lists))
8726 (set (setq var (intern (format "gnus-newsgroup-%s"
8727 (car (rassq (setq mark (car marks))
8729 (if (memq (car marks) uncompressed) (cdr marks)
8730 (gnus-uncompress-range (cdr marks))))
8732 (setq articles (symbol-value var))
8734 ;; All articles have to be subsets of the active articles.
8736 ;; Adjust "simple" lists.
8737 ((memq mark '(tick dormant expirable reply killed save))
8739 (when (or (< (setq article (pop articles)) min) (> article max))
8740 (set var (delq article (symbol-value var))))))
8742 ((memq mark '(score bookmark))
8744 (when (or (< (car (setq article (pop articles))) min)
8745 (> (car article) max))
8746 (set var (delq article (symbol-value var))))))))))
8748 (defun gnus-update-missing-marks (missing)
8749 "Go through the list of MISSING articles and remove them mark lists."
8751 (let ((types gnus-article-mark-lists)
8753 ;; Go through all types.
8755 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8756 (when (symbol-value var)
8757 ;; This list has articles. So we delete all missing articles
8761 (set var (delq (pop m) (symbol-value var)))))))))
8763 (defun gnus-update-marks ()
8764 "Enter the various lists of marked articles into the newsgroup info list."
8765 (let ((types gnus-article-mark-lists)
8766 (info (gnus-get-info gnus-newsgroup-name))
8767 (uncompressed '(score bookmark killed))
8768 type list newmarked symbol)
8770 ;; Add all marks lists that are non-nil to the list of marks lists.
8772 (setq type (pop types))
8773 (when (setq list (symbol-value
8775 (intern (format "gnus-newsgroup-%s"
8777 (push (cons (cdr type)
8778 (if (memq (cdr type) uncompressed) list
8779 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8782 ;; Enter these new marks into the info of the group.
8784 (setcar (nthcdr 3 info) newmarked)
8785 ;; Add the marks lists to the end of the info.
8787 (setcdr (nthcdr 2 info) (list newmarked))))
8789 ;; Cut off the end of the info if there's nothing else there.
8793 (when (nthcdr (decf i) info)
8794 (setcdr (nthcdr i info) nil)))))))
8796 (defun gnus-add-marked-articles (group type articles &optional info force)
8797 ;; Add ARTICLES of TYPE to the info of GROUP.
8798 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8799 ;; add, but replace marked articles of TYPE with ARTICLES.
8800 (let ((info (or info (gnus-get-info group)))
8801 (uncompressed '(score bookmark killed))
8804 (and (not (setq marked (nthcdr 3 info)))
8806 (setcdr (nthcdr 2 info)
8807 (list (list (cons type (gnus-compress-sequence
8809 (and (not (setq m (assq type (car marked))))
8812 (cons (cons type (gnus-compress-sequence articles t) )
8816 (setcar (nthcdr 3 info)
8817 (delq (assq type (car marked)) (car marked)))
8818 (setcdr m (gnus-compress-sequence articles t)))
8819 (setcdr m (gnus-compress-sequence
8820 (sort (nconc (gnus-uncompress-range (cdr m))
8821 (copy-sequence articles)) '<) t))))))
8823 (defun gnus-set-mode-line (where)
8824 "This function sets the mode line of the article or summary buffers.
8825 If WHERE is `summary', the summary mode line format will be used."
8826 ;; Is this mode line one we keep updated?
8827 (when (memq where gnus-updated-mode-lines)
8830 ;; We evaluate this in the summary buffer since these
8831 ;; variables are buffer-local to that buffer.
8832 (set-buffer gnus-summary-buffer)
8833 ;; We bind all these variables that are used in the `eval' form
8835 (let* ((mformat (symbol-value
8837 (format "gnus-%s-mode-line-format-spec" where))))
8838 (gnus-tmp-group-name gnus-newsgroup-name)
8839 (gnus-tmp-article-number (or gnus-current-article 0))
8840 (gnus-tmp-unread gnus-newsgroup-unreads)
8841 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8842 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8843 (gnus-tmp-unread-and-unselected
8844 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8845 (zerop gnus-tmp-unselected)) "")
8846 ((zerop gnus-tmp-unselected)
8847 (format "{%d more}" gnus-tmp-unread-and-unticked))
8848 (t (format "{%d(+%d) more}"
8849 gnus-tmp-unread-and-unticked
8850 gnus-tmp-unselected))))
8852 (if (and gnus-current-headers
8853 (vectorp gnus-current-headers))
8854 (mail-header-subject gnus-current-headers) ""))
8856 gnus-tmp-header);; passed as argument to any user-format-funcs
8857 (setq mode-string (eval mformat))
8858 (setq max-len (max 4 (if gnus-mode-non-string-length
8860 gnus-mode-non-string-length)
8861 (length mode-string))))
8862 ;; We might have to chop a bit of the string off...
8863 (when (> (length mode-string) max-len)
8865 (concat (gnus-truncate-string mode-string (- max-len 3))
8867 ;; Pad the mode string a bit.
8868 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8869 ;; Update the mode line.
8870 (setq mode-line-buffer-identification (list mode-string))
8871 (set-buffer-modified-p t))))
8873 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8874 "Go through the HEADERS list and add all Xrefs to a hash table.
8875 The resulting hash table is returned, or nil if no Xrefs were found."
8876 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8877 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8878 (xref-hashtb (make-vector 63 0))
8879 start group entry number xrefs header)
8881 (setq header (pop headers))
8882 (when (and (setq xrefs (mail-header-xref header))
8883 (not (memq (setq number (mail-header-number header))
8886 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8887 (setq start (match-end 0))
8888 (setq group (if prefix
8889 (concat prefix (substring xrefs (match-beginning 1)
8891 (substring xrefs (match-beginning 1) (match-end 1))))
8893 (string-to-int (substring xrefs (match-beginning 2)
8895 (if (setq entry (gnus-gethash group xref-hashtb))
8896 (setcdr entry (cons number (cdr entry)))
8897 (gnus-sethash group (cons number nil) xref-hashtb)))))
8898 (and start xref-hashtb)))
8900 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8901 "Look through all the headers and mark the Xrefs as read."
8902 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8903 name entry info xref-hashtb idlist method nth4)
8905 (set-buffer gnus-group-buffer)
8906 (when (setq xref-hashtb
8907 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8910 (unless (string= from-newsgroup (setq name (symbol-name group)))
8911 (setq idlist (symbol-value group))
8912 ;; Dead groups are not updated.
8914 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8916 (if (stringp (setq nth4 (gnus-info-method info)))
8917 (setq nth4 (gnus-server-to-method nth4))))
8918 ;; Only do the xrefs if the group has the same
8919 ;; select method as the group we have just read.
8920 (or (gnus-methods-equal-p
8921 nth4 (gnus-find-method-for-group from-newsgroup))
8923 (equal nth4 (setq method (gnus-find-method-for-group
8925 (and (equal (car nth4) (car method))
8926 (equal (nth 1 nth4) (nth 1 method))))
8927 gnus-use-cross-reference
8928 (or (not (eq gnus-use-cross-reference t))
8930 ;; Only do cross-references on subscribed
8931 ;; groups, if that is what is wanted.
8932 (<= (gnus-info-level info) gnus-level-subscribed))
8933 (gnus-group-make-articles-read name idlist))))
8936 (defun gnus-group-make-articles-read (group articles)
8938 (entry (gnus-gethash group gnus-newsrc-hashtb))
8939 (info (nth 2 entry))
8940 (active (gnus-active group))
8942 ;; First peel off all illegal article numbers.
8944 (let ((ids articles)
8948 (if (and first (> id (cdr active)))
8950 ;; We'll end up in this situation in one particular
8951 ;; obscure situation. If you re-scan a group and get
8952 ;; a new article that is cross-posted to a different
8953 ;; group that has not been re-scanned, you might get
8954 ;; crossposted article that has a higher number than
8955 ;; Gnus believes possible. So we re-activate this
8956 ;; group as well. This might mean doing the
8957 ;; crossposting thingy will *increase* the number
8958 ;; of articles in some groups. Tsk, tsk.
8959 (setq active (or (gnus-activate-group group) active))))
8960 (if (or (> id (cdr active))
8961 (< id (car active)))
8962 (setq articles (delq id articles)))
8963 (setq ids (cdr ids)))))
8964 ;; If the read list is nil, we init it.
8966 (null (gnus-info-read info))
8968 (gnus-info-set-read info (cons 1 (1- (car active)))))
8969 ;; Then we add the read articles to the range.
8974 (gnus-info-read info) (setq articles (sort articles '<)))))
8975 ;; Then we have to re-compute how many unread
8976 ;; articles there are in this group.
8981 (setq num (- (1+ (cdr active)) (car active))))
8982 ((not (listp (cdr range)))
8983 (setq num (- (cdr active) (- (1+ (cdr range))
8987 (if (numberp (car range))
8989 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8990 (setq range (cdr range)))
8991 (setq num (- (cdr active) num))))
8992 ;; Update the number of unread articles.
8994 ;; Update the group buffer.
8995 (gnus-group-update-group group t)))))
8997 (defun gnus-methods-equal-p (m1 m2)
8998 (let ((m1 (or m1 gnus-select-method))
8999 (m2 (or m2 gnus-select-method)))
9001 (and (eq (car m1) (car m2))
9002 (or (not (memq 'address (assoc (symbol-name (car m1))
9003 gnus-valid-select-methods)))
9004 (equal (nth 1 m1) (nth 1 m2)))))))
9006 (defsubst gnus-header-value ()
9007 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9009 (defvar gnus-newsgroup-none-id 0)
9011 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9012 (let ((cur nntp-server-buffer)
9015 (save-excursion (set-buffer gnus-summary-buffer)
9016 gnus-newsgroup-dependencies)))
9017 headers id id-dep ref-dep end ref)
9019 (set-buffer nntp-server-buffer)
9020 (run-hooks 'gnus-parse-headers-hook)
9021 (let ((case-fold-search t)
9022 in-reply-to header p lines)
9023 (goto-char (point-min))
9024 ;; Search to the beginning of the next header. Error messages
9025 ;; do not begin with 2 or 3.
9026 (while (re-search-forward "^[23][0-9]+ " nil t)
9029 ;; This implementation of this function, with nine
9030 ;; search-forwards instead of the one re-search-forward and
9031 ;; a case (which basically was the old function) is actually
9032 ;; about twice as fast, even though it looks messier. You
9033 ;; can't have everything, I guess. Speed and elegance
9034 ;; doesn't always go hand in hand.
9043 (narrow-to-region (point)
9044 (or (and (search-forward "\n.\n" nil t)
9050 (if (search-forward "\nsubject: " nil t)
9051 (gnus-header-value) "(none)"))
9055 (if (search-forward "\nfrom: " nil t)
9056 (gnus-header-value) "(nobody)"))
9060 (if (search-forward "\ndate: " nil t)
9061 (gnus-header-value) ""))
9065 (if (search-forward "\nmessage-id: " nil t)
9066 (setq id (gnus-header-value))
9067 ;; If there was no message-id, we just fake one to make
9068 ;; subsequent routines simpler.
9069 (setq id (concat "none+"
9071 (setq gnus-newsgroup-none-id
9072 (1+ gnus-newsgroup-none-id)))))))
9076 (if (search-forward "\nreferences: " nil t)
9079 (setq end (match-end 0))
9085 (search-backward ">" end t)
9088 (search-backward "<" end t)
9090 ;; Get the references from the in-reply-to header if there
9091 ;; were no references and the in-reply-to header looks
9093 (if (and (search-forward "\nin-reply-to: " nil t)
9094 (setq in-reply-to (gnus-header-value))
9095 (string-match "<[^>]+>" in-reply-to))
9096 (setq ref (substring in-reply-to (match-beginning 0)
9104 (if (search-forward "\nlines: " nil t)
9105 (if (numberp (setq lines (read cur)))
9111 (and (search-forward "\nxref: " nil t)
9112 (gnus-header-value)))))
9113 ;; We do the threading while we read the headers. The
9114 ;; message-id and the last reference are both entered into
9115 ;; the same hash table. Some tippy-toeing around has to be
9116 ;; done in case an article has arrived before the article
9117 ;; which it refers to.
9118 (if (boundp (setq id-dep (intern id dependencies)))
9119 (if (and (car (symbol-value id-dep))
9121 ;; An article with this Message-ID has already
9122 ;; been seen, so we ignore this one, except we add
9123 ;; any additional Xrefs (in case the two articles
9124 ;; came from different servers).
9126 (mail-header-set-xref
9127 (car (symbol-value id-dep))
9128 (concat (or (mail-header-xref
9129 (car (symbol-value id-dep))) "")
9130 (or (mail-header-xref header) "")))
9132 (setcar (symbol-value id-dep) header))
9133 (set id-dep (list header)))
9135 (if (boundp (setq ref-dep (intern ref dependencies)))
9136 (setcdr (symbol-value ref-dep)
9137 (nconc (cdr (symbol-value ref-dep))
9138 (list (symbol-value id-dep))))
9139 (set ref-dep (list nil (symbol-value id-dep))))
9140 (setq headers (cons header headers)))
9141 (goto-char (point-max))
9143 (nreverse headers)))))
9145 ;; The following macros and functions were written by Felix Lee
9146 ;; <flee@cse.psu.edu>.
9148 (defmacro gnus-nov-read-integer ()
9150 (if (= (following-char) ?\t)
9152 (let ((num (condition-case nil (read buffer) (error nil))))
9153 (if (numberp num) num 0)))
9154 (or (eobp) (forward-char 1))))
9156 (defmacro gnus-nov-skip-field ()
9157 '(search-forward "\t" eol 'move))
9159 (defmacro gnus-nov-field ()
9160 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9162 ;; Goes through the xover lines and returns a list of vectors
9163 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9164 force-new dependencies)
9165 "Parse the news overview data in the server buffer, and return a
9166 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9167 ;; Get the Xref when the users reads the articles since most/some
9168 ;; NNTP servers do not include Xrefs when using XOVER.
9169 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9170 (let ((cur nntp-server-buffer)
9171 (dependencies (or dependencies gnus-newsgroup-dependencies))
9172 number headers header)
9174 (set-buffer nntp-server-buffer)
9175 ;; Allow the user to mangle the headers before parsing them.
9176 (run-hooks 'gnus-parse-headers-hook)
9177 (goto-char (point-min))
9178 (while (and sequence (not (eobp)))
9179 (setq number (read cur))
9180 (while (and sequence (< (car sequence) number))
9181 (setq sequence (cdr sequence)))
9183 (eq number (car sequence))
9185 (setq sequence (cdr sequence))
9187 (inline (gnus-nov-parse-line
9188 number dependencies force-new)))
9189 (setq headers (cons header headers)))))
9191 (setq headers (nreverse headers)))
9194 ;; This function has to be called with point after the article number
9195 ;; on the beginning of the line.
9196 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9198 (eol (gnus-point-at-eol))
9199 (buffer (current-buffer))
9200 header ref id id-dep ref-dep)
9202 ;; overview: [num subject from date id refs chars lines misc]
9203 (narrow-to-region (point) eol)
9204 (or (eobp) (forward-char))
9210 (gnus-nov-field) ; subject
9211 (gnus-nov-field) ; from
9212 (gnus-nov-field) ; date
9213 (setq id (or (gnus-nov-field)
9216 (setq none (1+ none)))))) ; id
9219 (let ((beg (point)))
9220 (search-forward "\t" eol)
9221 (if (search-backward ">" beg t)
9225 (search-backward "<" beg t)))
9227 (gnus-nov-field)) ; refs
9228 (gnus-nov-read-integer) ; chars
9229 (gnus-nov-read-integer) ; lines
9230 (if (= (following-char) ?\n)
9232 (gnus-nov-field)) ; misc
9235 (gnus-error 4 "Strange nov line")
9241 ;; We build the thread tree.
9243 (if (boundp (setq id-dep (intern id dependencies)))
9244 (if (and (car (symbol-value id-dep))
9246 ;; An article with this Message-ID has already been seen,
9247 ;; so we ignore this one, except we add any additional
9248 ;; Xrefs (in case the two articles came from different
9251 (mail-header-set-xref
9252 (car (symbol-value id-dep))
9253 (concat (or (mail-header-xref
9254 (car (symbol-value id-dep))) "")
9255 (or (mail-header-xref header) "")))
9257 (setcar (symbol-value id-dep) header))
9258 (set id-dep (list header))))
9261 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9262 (setcdr (symbol-value ref-dep)
9263 (nconc (cdr (symbol-value ref-dep))
9264 (list (symbol-value id-dep))))
9265 (set ref-dep (list nil (symbol-value id-dep))))))
9268 (defun gnus-article-get-xrefs ()
9269 "Fill in the Xref value in `gnus-current-headers', if necessary.
9270 This is meant to be called in `gnus-article-internal-prepare-hook'."
9271 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9272 gnus-current-headers)))
9273 (or (not gnus-use-cross-reference)
9275 (and (mail-header-xref headers)
9276 (not (string= (mail-header-xref headers) "")))
9277 (let ((case-fold-search t)
9280 (nnheader-narrow-to-headers)
9281 (goto-char (point-min))
9282 (if (or (and (eq (downcase (following-char)) ?x)
9283 (looking-at "Xref:"))
9284 (search-forward "\nXref:" nil t))
9286 (goto-char (1+ (match-end 0)))
9287 (setq xref (buffer-substring (point)
9288 (progn (end-of-line) (point))))
9289 (mail-header-set-xref headers xref))))))))
9291 (defun gnus-summary-insert-subject (id &optional old-header)
9292 "Find article ID and insert the summary line for that article."
9293 (let ((header (gnus-read-header id))
9294 (number (and (numberp id) id))
9297 ;; Rebuild the thread that this article is part of and go to the
9298 ;; article we have fetched.
9300 (when (setq pos (text-property-any
9301 (point-min) (point-max) 'gnus-number
9302 (mail-header-number old-header)))
9305 (gnus-data-remove (mail-header-number old-header))))
9306 (gnus-rebuild-thread (mail-header-id header))
9307 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9308 (when (and (numberp number)
9310 ;; We have to update the boundaries even if we can't fetch the
9311 ;; article if ID is a number -- so that the next `P' or `N'
9312 ;; command will fetch the previous (or next) article even
9313 ;; if the one we tried to fetch this time has been canceled.
9314 (and (> number gnus-newsgroup-end)
9315 (setq gnus-newsgroup-end number))
9316 (and (< number gnus-newsgroup-begin)
9317 (setq gnus-newsgroup-begin number))
9318 (setq gnus-newsgroup-unselected
9319 (delq number gnus-newsgroup-unselected)))
9320 ;; Report back a success?
9321 (and header (mail-header-number header))))
9323 (defun gnus-summary-work-articles (n)
9324 "Return a list of articles to be worked upon. The prefix argument,
9325 the list of process marked articles, and the current article will be
9326 taken into consideration."
9328 ((and n (numberp n))
9329 ;; A numerical prefix has been given.
9330 (let ((backward (< n 0))
9336 (push (setq article (gnus-summary-article-number))
9339 (gnus-summary-find-prev nil article)
9340 (gnus-summary-find-next nil article)))
9342 (nreverse articles)))
9343 ((and (boundp 'transient-mark-mode)
9346 ;; Work on the region between point and mark.
9347 (let ((max (max (point) (mark)))
9350 (goto-char (min (point) (mark)))
9353 (push (setq article (gnus-summary-article-number)) articles)
9354 (gnus-summary-find-next nil article)
9356 (nreverse articles))))
9357 (gnus-newsgroup-processable
9358 ;; There are process-marked articles present.
9359 (reverse gnus-newsgroup-processable))
9361 ;; Just return the current article.
9362 (list (gnus-summary-article-number)))))
9364 (defun gnus-summary-search-group (&optional backward use-level)
9365 "Search for next unread newsgroup.
9366 If optional argument BACKWARD is non-nil, search backward instead."
9368 (set-buffer gnus-group-buffer)
9369 (if (gnus-group-search-forward
9370 backward nil (if use-level (gnus-group-group-level) nil))
9371 (gnus-group-group-name))))
9373 (defun gnus-summary-best-group (&optional exclude-group)
9374 "Find the name of the best unread group.
9375 If EXCLUDE-GROUP, do not go to this group."
9377 (set-buffer gnus-group-buffer)
9379 (gnus-group-best-unread-group exclude-group))))
9381 (defun gnus-summary-find-next (&optional unread article backward)
9382 (if backward (gnus-summary-find-prev)
9383 (let* ((dummy (gnus-summary-article-intangible-p))
9384 (article (or article (gnus-summary-article-number)))
9385 (arts (gnus-data-find-list article))
9387 (when (and (not dummy)
9388 (or (not gnus-summary-check-current)
9390 (not (gnus-data-unread-p (car arts)))))
9391 (setq arts (cdr arts)))
9396 (when (gnus-data-unread-p (car arts))
9397 (setq result (car arts)
9399 (setq arts (cdr arts)))
9402 (goto-char (gnus-data-pos result))
9403 (gnus-data-number result)))))
9405 (defun gnus-summary-find-prev (&optional unread article)
9406 (let* ((article (or article (gnus-summary-article-number)))
9407 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9409 (when (or (not gnus-summary-check-current)
9411 (not (gnus-data-unread-p (car arts))))
9412 (setq arts (cdr arts)))
9417 (and (gnus-data-unread-p (car arts))
9418 (setq result (car arts)
9420 (setq arts (cdr arts)))
9424 (goto-char (gnus-data-pos result))
9425 (gnus-data-number result)))))
9427 (defun gnus-summary-find-subject (subject &optional unread backward article)
9428 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9429 (article (or article (gnus-summary-article-number)))
9430 (articles (gnus-data-list backward))
9431 (arts (gnus-data-find-list article articles))
9433 (when (or (not gnus-summary-check-current)
9435 (not (gnus-data-unread-p (car arts))))
9436 (setq arts (cdr arts)))
9438 (and (or (not unread)
9439 (gnus-data-unread-p (car arts)))
9440 (vectorp (gnus-data-header (car arts)))
9442 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9443 (setq result (car arts)
9445 (setq arts (cdr arts)))
9447 (goto-char (gnus-data-pos result))
9448 (gnus-data-number result))))
9450 (defun gnus-summary-search-forward (&optional unread subject backward)
9451 "Search forward for an article.
9452 If UNREAD, look for unread articles. If SUBJECT, look for
9453 articles with that subject. If BACKWARD, search backward instead."
9454 (cond (subject (gnus-summary-find-subject subject unread backward))
9455 (backward (gnus-summary-find-prev unread))
9456 (t (gnus-summary-find-next unread))))
9458 (defun gnus-recenter (&optional n)
9459 "Center point in window and redisplay frame.
9460 Also do horizontal recentering."
9462 (when (and gnus-auto-center-summary
9463 (not (eq gnus-auto-center-summary 'vertical)))
9464 (gnus-horizontal-recenter))
9467 (defun gnus-summary-recenter ()
9468 "Center point in the summary window.
9469 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9470 displayed, no centering will be performed."
9471 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9472 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9473 (let* ((top (cond ((< (window-height) 4) 0)
9474 ((< (window-height) 7) 1)
9476 (height (1- (window-height)))
9477 (bottom (save-excursion (goto-char (point-max))
9478 (forward-line (- height))
9480 (window (get-buffer-window (current-buffer))))
9481 ;; The user has to want it.
9482 (when gnus-auto-center-summary
9483 (when (get-buffer-window gnus-article-buffer)
9484 ;; Only do recentering when the article buffer is displayed,
9485 ;; Set the window start to either `bottom', which is the biggest
9486 ;; possible valid number, or the second line from the top,
9487 ;; whichever is the least.
9489 window (min bottom (save-excursion
9490 (forward-line (- top)) (point)))))
9491 ;; Do horizontal recentering while we're at it.
9492 (when (and (get-buffer-window (current-buffer) t)
9493 (not (eq gnus-auto-center-summary 'vertical)))
9494 (let ((selected (selected-window)))
9495 (select-window (get-buffer-window (current-buffer) t))
9496 (gnus-summary-position-point)
9497 (gnus-horizontal-recenter)
9498 (select-window selected))))))
9500 (defun gnus-horizontal-recenter ()
9501 "Recenter the current buffer horizontally."
9502 (if (< (current-column) (/ (window-width) 2))
9503 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9504 (let* ((orig (point))
9505 (end (window-end (get-buffer-window (current-buffer) t)))
9507 ;; Find the longest line currently displayed in the window.
9508 (goto-char (window-start))
9509 (while (and (not (eobp))
9512 (setq max (max max (current-column)))
9515 ;; Scroll horizontally to center (sort of) the point.
9516 (if (> max (window-width))
9518 (get-buffer-window (current-buffer) t)
9519 (min (- (current-column) (/ (window-width) 3))
9520 (+ 2 (- max (window-width)))))
9521 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9524 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9525 (defun gnus-short-group-name (group &optional levels)
9526 "Collapse GROUP name LEVELS."
9533 (while (string-match "\\." group skip)
9534 (setq skip (match-end 0)
9537 (if (string-match ":" group)
9538 (setq foreign (substring group 0 (match-end 0))
9539 group (substring group (match-end 0))))
9541 (if (and (string-match "\\." group)
9542 (> levels (- gnus-group-uncollapsed-levels 1)))
9543 (setq name (concat name (substring group 0 1))
9544 group (substring group (match-end 0))
9546 name (concat name "."))
9547 (setq name (concat foreign name group)
9551 (defun gnus-summary-jump-to-group (newsgroup)
9552 "Move point to NEWSGROUP in group mode buffer."
9553 ;; Keep update point of group mode buffer if visible.
9554 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9555 (save-window-excursion
9556 ;; Take care of tree window mode.
9557 (if (get-buffer-window gnus-group-buffer)
9558 (pop-to-buffer gnus-group-buffer))
9559 (gnus-group-jump-to-group newsgroup))
9561 ;; Take care of tree window mode.
9562 (if (get-buffer-window gnus-group-buffer)
9563 (pop-to-buffer gnus-group-buffer)
9564 (set-buffer gnus-group-buffer))
9565 (gnus-group-jump-to-group newsgroup))))
9567 ;; This function returns a list of article numbers based on the
9568 ;; difference between the ranges of read articles in this group and
9569 ;; the range of active articles.
9570 (defun gnus-list-of-unread-articles (group)
9571 (let* ((read (gnus-info-read (gnus-get-info group)))
9572 (active (gnus-active group))
9575 ;; If none are read, then all are unread.
9577 (setq first (car active))
9578 ;; If the range of read articles is a single range, then the
9579 ;; first unread article is the article after the last read
9580 ;; article. Sounds logical, doesn't it?
9581 (if (not (listp (cdr read)))
9582 (setq first (1+ (cdr read)))
9583 ;; `read' is a list of ranges.
9584 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9589 (while (< first nlast)
9590 (setq unread (cons first unread))
9591 (setq first (1+ first))))
9592 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9593 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9594 (setq read (cdr read)))))
9595 ;; And add the last unread articles.
9596 (while (<= first last)
9597 (setq unread (cons first unread))
9598 (setq first (1+ first)))
9599 ;; Return the list of unread articles.
9602 (defun gnus-list-of-read-articles (group)
9603 "Return a list of unread, unticked and non-dormant articles."
9604 (let* ((info (gnus-get-info group))
9605 (marked (gnus-info-marks info))
9606 (active (gnus-active group)))
9608 (gnus-set-difference
9609 (gnus-sorted-complement
9610 (gnus-uncompress-range active)
9611 (gnus-list-of-unread-articles group))
9613 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9614 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9616 ;; Various summary commands
9618 (defun gnus-summary-universal-argument (arg)
9619 "Perform any operation on all articles that are process/prefixed."
9621 (gnus-set-global-variables)
9622 (let ((articles (gnus-summary-work-articles arg))
9629 (substitute-command-keys
9630 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9633 (gnus-error 1 "Undefined key")
9636 (gnus-summary-goto-subject (setq article (pop articles)))
9637 (command-execute func)
9638 (gnus-summary-remove-process-mark article)))))
9639 (gnus-summary-position-point))
9641 (defun gnus-summary-toggle-truncation (&optional arg)
9642 "Toggle truncation of summary lines.
9643 With arg, turn line truncation on iff arg is positive."
9645 (setq truncate-lines
9646 (if (null arg) (not truncate-lines)
9647 (> (prefix-numeric-value arg) 0)))
9650 (defun gnus-summary-reselect-current-group (&optional all rescan)
9651 "Exit and then reselect the current newsgroup.
9652 The prefix argument ALL means to select all articles."
9654 (gnus-set-global-variables)
9655 (let ((current-subject (gnus-summary-article-number))
9656 (group gnus-newsgroup-name))
9657 (setq gnus-newsgroup-begin nil)
9659 ;; We have to adjust the point of group mode buffer because the
9660 ;; current point was moved to the next unread newsgroup by
9662 (gnus-summary-jump-to-group group)
9665 (gnus-group-get-new-news-this-group 1)))
9666 (gnus-group-read-group all t)
9667 (gnus-summary-goto-subject current-subject)))
9669 (defun gnus-summary-rescan-group (&optional all)
9670 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9672 (gnus-summary-reselect-current-group all t))
9674 (defun gnus-summary-update-info ()
9675 (let* ((group gnus-newsgroup-name))
9676 (when gnus-newsgroup-kill-headers
9677 (setq gnus-newsgroup-killed
9678 (gnus-compress-sequence
9680 (gnus-set-sorted-intersection
9681 (gnus-uncompress-range gnus-newsgroup-killed)
9682 (setq gnus-newsgroup-unselected
9683 (sort gnus-newsgroup-unselected '<)))
9684 (setq gnus-newsgroup-unreads
9685 (sort gnus-newsgroup-unreads '<))) t)))
9686 (unless (listp (cdr gnus-newsgroup-killed))
9687 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9688 (let ((headers gnus-newsgroup-headers))
9689 (run-hooks 'gnus-exit-group-hook)
9690 (unless gnus-save-score
9691 (setq gnus-newsgroup-scored nil))
9692 ;; Set the new ranges of read articles.
9693 (gnus-update-read-articles
9694 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9695 ;; Set the current article marks.
9697 ;; Do the cross-ref thing.
9698 (when gnus-use-cross-reference
9699 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9700 ;; Do adaptive scoring, and possibly save score files.
9701 (when gnus-newsgroup-adaptive
9702 (gnus-score-adaptive))
9703 (when gnus-use-scoring
9705 ;; Do not switch windows but change the buffer to work.
9706 (set-buffer gnus-group-buffer)
9707 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9708 (gnus-group-update-group group)))))
9710 (defun gnus-summary-exit (&optional temporary)
9711 "Exit reading current newsgroup, and then return to group selection mode.
9712 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9714 (gnus-set-global-variables)
9715 (gnus-kill-save-kill-buffer)
9716 (let* ((group gnus-newsgroup-name)
9717 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9719 (buf (current-buffer)))
9720 (run-hooks 'gnus-summary-prepare-exit-hook)
9721 ;; If we have several article buffers, we kill them at exit.
9722 (unless gnus-single-article-buffer
9723 (gnus-kill-buffer gnus-article-buffer)
9724 (gnus-kill-buffer gnus-original-article-buffer)
9725 (setq gnus-article-current nil))
9726 (when gnus-use-cache
9727 (gnus-cache-possibly-remove-articles)
9728 (gnus-cache-save-buffers))
9729 (when gnus-use-trees
9730 (gnus-tree-close group))
9731 ;; Make all changes in this group permanent.
9733 (gnus-summary-update-info))
9734 (gnus-close-group group)
9735 ;; Make sure where I was, and go to next newsgroup.
9736 (set-buffer gnus-group-buffer)
9738 (gnus-group-jump-to-group group)
9739 (gnus-group-next-unread-group 1))
9740 (run-hooks 'gnus-summary-exit-hook)
9741 (unless gnus-single-article-buffer
9742 (setq gnus-article-current nil))
9745 ;; If we have several article buffers, we kill them at exit.
9746 (unless gnus-single-article-buffer
9747 (gnus-kill-buffer gnus-article-buffer)
9748 (gnus-kill-buffer gnus-original-article-buffer)
9749 (setq gnus-article-current nil))
9751 (if (not gnus-kill-summary-on-exit)
9752 (gnus-deaden-summary)
9753 ;; We set all buffer-local variables to nil. It is unclear why
9754 ;; this is needed, but if we don't, buffer-local variables are
9755 ;; not garbage-collected, it seems. This would the lead to en
9756 ;; ever-growing Emacs.
9757 (gnus-summary-clear-local-variables)
9758 (when (get-buffer gnus-article-buffer)
9759 (bury-buffer gnus-article-buffer))
9760 ;; We clear the global counterparts of the buffer-local
9761 ;; variables as well, just to be on the safe side.
9762 (gnus-configure-windows 'group 'force)
9763 (gnus-summary-clear-local-variables)
9764 ;; Return to group mode buffer.
9765 (if (eq mode 'gnus-summary-mode)
9766 (gnus-kill-buffer buf)))
9767 (setq gnus-current-select-method gnus-select-method)
9768 (pop-to-buffer gnus-group-buffer)
9769 ;; Clear the current group name.
9770 (if (not quit-config)
9772 (gnus-group-jump-to-group group)
9773 (gnus-group-next-unread-group 1)
9774 (gnus-configure-windows 'group 'force))
9775 (if (not (buffer-name (car quit-config)))
9776 (gnus-configure-windows 'group 'force)
9777 (set-buffer (car quit-config))
9778 (and (eq major-mode 'gnus-summary-mode)
9779 (gnus-set-global-variables))
9780 (gnus-configure-windows (cdr quit-config))))
9782 (setq gnus-newsgroup-name nil)))))
9784 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9785 (defun gnus-summary-exit-no-update (&optional no-questions)
9786 "Quit reading current newsgroup without updating read article info."
9788 (gnus-set-global-variables)
9789 (let* ((group gnus-newsgroup-name)
9790 (quit-config (gnus-group-quit-config group)))
9791 (when (or no-questions
9793 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9794 ;; If we have several article buffers, we kill them at exit.
9795 (unless gnus-single-article-buffer
9796 (gnus-kill-buffer gnus-article-buffer)
9797 (gnus-kill-buffer gnus-original-article-buffer)
9798 (setq gnus-article-current nil))
9799 (if (not gnus-kill-summary-on-exit)
9800 (gnus-deaden-summary)
9801 (gnus-close-group group)
9802 (gnus-summary-clear-local-variables)
9803 (set-buffer gnus-group-buffer)
9804 (gnus-summary-clear-local-variables)
9805 (when (get-buffer gnus-summary-buffer)
9806 (kill-buffer gnus-summary-buffer)))
9807 (unless gnus-single-article-buffer
9808 (setq gnus-article-current nil))
9809 (when gnus-use-trees
9810 (gnus-tree-close group))
9811 (when (get-buffer gnus-article-buffer)
9812 (bury-buffer gnus-article-buffer))
9813 ;; Return to the group buffer.
9814 (gnus-configure-windows 'group 'force)
9815 ;; Clear the current group name.
9816 (setq gnus-newsgroup-name nil)
9817 (when (equal (gnus-group-group-name) group)
9818 (gnus-group-next-unread-group 1))
9820 (if (not (buffer-name (car quit-config)))
9821 (gnus-configure-windows 'group 'force)
9822 (set-buffer (car quit-config))
9823 (when (eq major-mode 'gnus-summary-mode)
9824 (gnus-set-global-variables))
9825 (gnus-configure-windows (cdr quit-config)))))))
9829 (defvar gnus-dead-summary-mode-map nil)
9831 (if gnus-dead-summary-mode-map
9833 (setq gnus-dead-summary-mode-map (make-keymap))
9834 (suppress-keymap gnus-dead-summary-mode-map)
9835 (substitute-key-definition
9836 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9837 (let ((keys '("\C-d" "\r" "\177")))
9839 (define-key gnus-dead-summary-mode-map
9840 (pop keys) 'gnus-summary-wake-up-the-dead))))
9842 (defvar gnus-dead-summary-mode nil
9843 "Minor mode for Gnus summary buffers.")
9845 (defun gnus-dead-summary-mode (&optional arg)
9846 "Minor mode for Gnus summary buffers."
9848 (when (eq major-mode 'gnus-summary-mode)
9849 (make-local-variable 'gnus-dead-summary-mode)
9850 (setq gnus-dead-summary-mode
9851 (if (null arg) (not gnus-dead-summary-mode)
9852 (> (prefix-numeric-value arg) 0)))
9853 (when gnus-dead-summary-mode
9854 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9855 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9856 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9857 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9858 minor-mode-map-alist)))))
9860 (defun gnus-deaden-summary ()
9861 "Make the current summary buffer into a dead summary buffer."
9862 ;; Kill any previous dead summary buffer.
9863 (when (and gnus-dead-summary
9864 (buffer-name gnus-dead-summary))
9866 (set-buffer gnus-dead-summary)
9867 (when gnus-dead-summary-mode
9868 (kill-buffer (current-buffer)))))
9869 ;; Make this the current dead summary.
9870 (setq gnus-dead-summary (current-buffer))
9871 (gnus-dead-summary-mode 1)
9872 (let ((name (buffer-name)))
9873 (when (string-match "Summary" name)
9875 (concat (substring name 0 (match-beginning 0)) "Dead "
9876 (substring name (match-beginning 0))) t))))
9878 (defun gnus-kill-or-deaden-summary (buffer)
9879 "Kill or deaden the summary BUFFER."
9880 (cond (gnus-kill-summary-on-exit
9881 (when (and gnus-use-trees
9882 (and (get-buffer buffer)
9883 (buffer-name (get-buffer buffer))))
9885 (set-buffer (get-buffer buffer))
9886 (gnus-tree-close gnus-newsgroup-name)))
9887 (gnus-kill-buffer buffer))
9888 ((and (get-buffer buffer)
9889 (buffer-name (get-buffer buffer)))
9892 (gnus-deaden-summary)))))
9894 (defun gnus-summary-wake-up-the-dead (&rest args)
9895 "Wake up the dead summary buffer."
9897 (gnus-dead-summary-mode -1)
9898 (let ((name (buffer-name)))
9899 (when (string-match "Dead " name)
9901 (concat (substring name 0 (match-beginning 0))
9902 (substring name (match-end 0))) t)))
9903 (gnus-message 3 "This dead summary is now alive again"))
9905 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9906 (defun gnus-summary-fetch-faq (&optional faq-dir)
9907 "Fetch the FAQ for the current group.
9908 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9912 (if current-prefix-arg
9914 "Faq dir: " (and (listp gnus-group-faq-directory)
9915 gnus-group-faq-directory)))))
9916 (let (gnus-faq-buffer)
9917 (and (setq gnus-faq-buffer
9918 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9919 (gnus-configure-windows 'summary-faq))))
9921 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9922 (defun gnus-summary-describe-group (&optional force)
9923 "Describe the current newsgroup."
9925 (gnus-group-describe-group force gnus-newsgroup-name))
9927 (defun gnus-summary-describe-briefly ()
9928 "Describe summary mode commands briefly."
9931 (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")))
9933 ;; Walking around group mode buffer from summary mode.
9935 (defun gnus-summary-next-group (&optional no-article target-group backward)
9936 "Exit current newsgroup and then select next unread newsgroup.
9937 If prefix argument NO-ARTICLE is non-nil, no article is selected
9938 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9939 previous group instead."
9941 (gnus-set-global-variables)
9942 (let ((current-group gnus-newsgroup-name)
9943 (current-buffer (current-buffer))
9945 ;; First we semi-exit this group to update Xrefs and all variables.
9946 ;; We can't do a real exit, because the window conf must remain
9947 ;; the same in case the user is prompted for info, and we don't
9948 ;; want the window conf to change before that...
9949 (gnus-summary-exit t)
9950 (while (not entered)
9951 ;; Then we find what group we are supposed to enter.
9952 (set-buffer gnus-group-buffer)
9953 (gnus-group-jump-to-group current-group)
9956 (if (eq gnus-keep-same-level 'best)
9957 (gnus-summary-best-group gnus-newsgroup-name)
9958 (gnus-summary-search-group backward gnus-keep-same-level))))
9959 (if (not target-group)
9960 ;; There are no further groups, so we return to the group
9963 (gnus-message 5 "Returning to the group buffer")
9965 (set-buffer current-buffer)
9966 (gnus-summary-exit))
9967 ;; We try to enter the target group.
9968 (gnus-group-jump-to-group target-group)
9969 (let ((unreads (gnus-group-group-unread)))
9970 (if (and (or (eq t unreads)
9971 (and unreads (not (zerop unreads))))
9972 (gnus-summary-read-group
9973 target-group nil no-article current-buffer))
9975 (setq current-group target-group
9976 target-group nil)))))))
9978 (defun gnus-summary-prev-group (&optional no-article)
9979 "Exit current newsgroup and then select previous unread newsgroup.
9980 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9982 (gnus-summary-next-group no-article nil t))
9984 ;; Walking around summary lines.
9986 (defun gnus-summary-first-subject (&optional unread)
9987 "Go to the first unread subject.
9988 If UNREAD is non-nil, go to the first unread article.
9989 Returns the article selected or nil if there are no unread articles."
9994 ((null gnus-newsgroup-data)
9995 (gnus-message 3 "No articles in the group")
9997 ;; Pick the first article.
9999 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10000 (gnus-data-number (car gnus-newsgroup-data)))
10001 ;; No unread articles.
10002 ((null gnus-newsgroup-unreads)
10003 (gnus-message 3 "No more unread articles")
10005 ;; Find the first unread article.
10007 (let ((data gnus-newsgroup-data))
10009 (not (gnus-data-unread-p (car data))))
10010 (setq data (cdr data)))
10013 (goto-char (gnus-data-pos (car data)))
10014 (gnus-data-number (car data)))))))
10015 (gnus-summary-position-point)))
10017 (defun gnus-summary-next-subject (n &optional unread dont-display)
10018 "Go to next N'th summary line.
10019 If N is negative, go to the previous N'th subject line.
10020 If UNREAD is non-nil, only unread articles are selected.
10021 The difference between N and the actual number of steps taken is
10024 (let ((backward (< n 0))
10026 (while (and (> n 0)
10028 (gnus-summary-find-prev unread)
10029 (gnus-summary-find-next unread)))
10031 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10032 (if unread " unread" "")))
10033 (unless dont-display
10034 (gnus-summary-recenter)
10035 (gnus-summary-position-point))
10038 (defun gnus-summary-next-unread-subject (n)
10039 "Go to next N'th unread summary line."
10041 (gnus-summary-next-subject n t))
10043 (defun gnus-summary-prev-subject (n &optional unread)
10044 "Go to previous N'th summary line.
10045 If optional argument UNREAD is non-nil, only unread article is selected."
10047 (gnus-summary-next-subject (- n) unread))
10049 (defun gnus-summary-prev-unread-subject (n)
10050 "Go to previous N'th unread summary line."
10052 (gnus-summary-next-subject (- n) t))
10054 (defun gnus-summary-goto-subject (article &optional force silent)
10055 "Go the subject line of ARTICLE.
10056 If FORCE, also allow jumping to articles not currently shown."
10058 (data (gnus-data-find article)))
10059 ;; We read in the article if we have to.
10062 (gnus-summary-insert-subject article)
10063 (setq data (gnus-data-find article)))
10068 (gnus-message 3 "Can't find article %d" article))
10070 (goto-char (gnus-data-pos data))
10073 ;; Walking around summary lines with displaying articles.
10075 (defun gnus-summary-expand-window (&optional arg)
10076 "Make the summary buffer take up the entire Emacs frame.
10077 Given a prefix, will force an `article' buffer configuration."
10079 (gnus-set-global-variables)
10081 (gnus-configure-windows 'article 'force)
10082 (gnus-configure-windows 'summary 'force)))
10084 (defun gnus-summary-display-article (article &optional all-header)
10085 "Display ARTICLE in article buffer."
10086 (gnus-set-global-variables)
10090 (if gnus-summary-display-article-function
10091 (funcall gnus-summary-display-article-function article all-header)
10092 (gnus-article-prepare article all-header))
10093 (run-hooks 'gnus-select-article-hook)
10094 (gnus-summary-recenter)
10095 (gnus-summary-goto-subject article)
10096 (when gnus-use-trees
10097 (gnus-possibly-generate-tree article)
10098 (gnus-highlight-selected-tree article))
10099 ;; Successfully display article.
10100 (gnus-article-set-window-start
10101 (cdr (assq article gnus-newsgroup-bookmarks)))
10104 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10105 "Select the current article.
10106 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10107 non-nil, the article will be re-fetched even if it already present in
10108 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10110 (let ((article (or article (gnus-summary-article-number)))
10111 (all-headers (not (not all-headers))) ;Must be T or NIL.
10112 gnus-summary-display-article-function
10115 (gnus-summary-article-pseudo-p article)
10116 (error "This is a pseudo-article."))
10119 (set-buffer gnus-summary-buffer)
10120 (if (or (and gnus-single-article-buffer
10121 (or (null gnus-current-article)
10122 (null gnus-article-current)
10123 (null (get-buffer gnus-article-buffer))
10124 (not (eq article (cdr gnus-article-current)))
10125 (not (equal (car gnus-article-current)
10126 gnus-newsgroup-name))))
10127 (and (not gnus-single-article-buffer)
10128 (or (null gnus-current-article)
10129 (not (eq gnus-current-article article))))
10131 ;; The requested article is different from the current article.
10133 (gnus-summary-display-article article all-headers)
10134 (setq did article))
10135 (if (or all-headers gnus-show-all-headers)
10136 (gnus-article-show-all-headers))
10139 (gnus-article-set-window-start
10140 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10142 (defun gnus-summary-set-current-mark (&optional current-mark)
10143 "Obsolete function."
10146 (defun gnus-summary-next-article (&optional unread subject backward push)
10147 "Select the next article.
10148 If UNREAD, only unread articles are selected.
10149 If SUBJECT, only articles with SUBJECT are selected.
10150 If BACKWARD, the previous article is selected instead of the next."
10152 (gnus-set-global-variables)
10154 ;; Is there such an article?
10155 ((and (gnus-summary-search-forward unread subject backward)
10156 (or (gnus-summary-display-article (gnus-summary-article-number))
10157 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10158 (gnus-summary-position-point))
10159 ;; If not, we try the first unread, if that is wanted.
10161 gnus-auto-select-same
10162 (or (gnus-summary-first-unread-article)
10163 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10164 (gnus-summary-position-point)
10165 (gnus-message 6 "Wrapped"))
10166 ;; Try to get next/previous article not displayed in this group.
10167 ((and gnus-auto-extend-newsgroup
10168 (not unread) (not subject))
10169 (gnus-summary-goto-article
10170 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10172 ;; Go to next/previous group.
10174 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10175 (gnus-summary-jump-to-group gnus-newsgroup-name))
10176 (let ((cmd last-command-char)
10178 (if (eq gnus-keep-same-level 'best)
10179 (gnus-summary-best-group gnus-newsgroup-name)
10180 (gnus-summary-search-group backward gnus-keep-same-level))))
10181 ;; For some reason, the group window gets selected. We change
10183 (select-window (get-buffer-window (current-buffer)))
10184 ;; Select next unread newsgroup automagically.
10186 ((not gnus-auto-select-next)
10187 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10188 ((or (eq gnus-auto-select-next 'quietly)
10189 (and (eq gnus-auto-select-next 'slightly-quietly)
10191 (and (eq gnus-auto-select-next 'almost-quietly)
10192 (gnus-summary-last-article-p)))
10194 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10195 (gnus-summary-exit)
10196 (gnus-message 7 "No more%s articles (%s)..."
10197 (if unread " unread" "")
10198 (if group (concat "selecting " group)
10200 (gnus-summary-next-group nil group backward)))
10202 (gnus-summary-walk-group-buffer
10203 gnus-newsgroup-name cmd unread backward)))))))
10205 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10206 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10207 (?\C-p (gnus-group-prev-unread-group 1))))
10208 keve key group ended)
10210 (set-buffer gnus-group-buffer)
10211 (gnus-summary-jump-to-group from-group)
10213 (if (eq gnus-keep-same-level 'best)
10214 (gnus-summary-best-group gnus-newsgroup-name)
10215 (gnus-summary-search-group backward gnus-keep-same-level))))
10218 5 "No more%s articles%s" (if unread " unread" "")
10220 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10221 (format " (Type %s for %s [%s])"
10222 (single-key-description cmd) group
10223 (car (gnus-gethash group gnus-newsrc-hashtb)))
10224 (format " (Type %s to exit %s)"
10225 (single-key-description cmd)
10226 gnus-newsgroup-name)))
10227 ;; Confirm auto selection.
10228 (setq key (car (setq keve (gnus-read-event-char))))
10231 ((assq key keystrokes)
10232 (let ((obuf (current-buffer)))
10233 (switch-to-buffer gnus-group-buffer)
10235 (gnus-group-jump-to-group group))
10236 (eval (cadr (assq key keystrokes)))
10237 (setq group (gnus-group-group-name))
10238 (switch-to-buffer obuf))
10241 (if (or (not group)
10242 (gnus-ephemeral-group-p gnus-newsgroup-name))
10243 (gnus-summary-exit)
10244 (gnus-summary-next-group nil group backward)))
10246 (push (cdr keve) unread-command-events))))))
10248 (defun gnus-read-event-char ()
10249 "Get the next event."
10250 (let ((event (read-event)))
10251 (cons (and (numberp event) event) event)))
10253 (defun gnus-summary-next-unread-article ()
10254 "Select unread article after current one."
10256 (gnus-summary-next-article t (and gnus-auto-select-same
10257 (gnus-summary-article-subject))))
10259 (defun gnus-summary-prev-article (&optional unread subject)
10260 "Select the article after the current one.
10261 If UNREAD is non-nil, only unread articles are selected."
10263 (gnus-summary-next-article unread subject t))
10265 (defun gnus-summary-prev-unread-article ()
10266 "Select unred article before current one."
10268 (gnus-summary-prev-article t (and gnus-auto-select-same
10269 (gnus-summary-article-subject))))
10271 (defun gnus-summary-next-page (&optional lines circular)
10272 "Show next page of the selected article.
10273 If at the end of the current article, select the next article.
10274 LINES says how many lines should be scrolled up.
10276 If CIRCULAR is non-nil, go to the start of the article instead of
10277 selecting the next article when reaching the end of the current
10280 (setq gnus-summary-buffer (current-buffer))
10281 (gnus-set-global-variables)
10282 (let ((article (gnus-summary-article-number))
10284 (gnus-configure-windows 'article)
10285 (if (or (null gnus-current-article)
10286 (null gnus-article-current)
10287 (/= article (cdr gnus-article-current))
10288 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10289 ;; Selected subject is different from current article's.
10290 (gnus-summary-display-article article)
10291 (gnus-eval-in-buffer-window
10292 gnus-article-buffer
10293 (setq endp (gnus-article-next-page lines)))
10296 (gnus-summary-beginning-of-article))
10298 (gnus-message 3 "End of message"))
10300 (if (and (eq gnus-summary-goto-unread 'never)
10301 (not (gnus-summary-last-article-p article)))
10302 (gnus-summary-next-article)
10303 (gnus-summary-next-unread-article))))))
10304 (gnus-summary-recenter)
10305 (gnus-summary-position-point)))
10307 (defun gnus-summary-prev-page (&optional lines)
10308 "Show previous page of selected article.
10309 Argument LINES specifies lines to be scrolled down."
10311 (gnus-set-global-variables)
10312 (let ((article (gnus-summary-article-number)))
10313 (gnus-configure-windows 'article)
10314 (if (or (null gnus-current-article)
10315 (null gnus-article-current)
10316 (/= article (cdr gnus-article-current))
10317 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10318 ;; Selected subject is different from current article's.
10319 (gnus-summary-display-article article)
10320 (gnus-summary-recenter)
10321 (gnus-eval-in-buffer-window gnus-article-buffer
10322 (gnus-article-prev-page lines))))
10323 (gnus-summary-position-point))
10325 (defun gnus-summary-scroll-up (lines)
10326 "Scroll up (or down) one line current article.
10327 Argument LINES specifies lines to be scrolled up (or down if negative)."
10329 (gnus-set-global-variables)
10330 (gnus-configure-windows 'article)
10331 (gnus-summary-show-thread)
10332 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10333 (gnus-eval-in-buffer-window
10334 gnus-article-buffer
10336 (if (gnus-article-next-page lines)
10337 (gnus-message 3 "End of message")))
10339 (gnus-article-prev-page (- lines))))))
10340 (gnus-summary-recenter)
10341 (gnus-summary-position-point))
10343 (defun gnus-summary-next-same-subject ()
10344 "Select next article which has the same subject as current one."
10346 (gnus-set-global-variables)
10347 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10349 (defun gnus-summary-prev-same-subject ()
10350 "Select previous article which has the same subject as current one."
10352 (gnus-set-global-variables)
10353 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10355 (defun gnus-summary-next-unread-same-subject ()
10356 "Select next unread article which has the same subject as current one."
10358 (gnus-set-global-variables)
10359 (gnus-summary-next-article t (gnus-summary-article-subject)))
10361 (defun gnus-summary-prev-unread-same-subject ()
10362 "Select previous unread article which has the same subject as current one."
10364 (gnus-set-global-variables)
10365 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10367 (defun gnus-summary-first-unread-article ()
10368 "Select the first unread article.
10369 Return nil if there are no unread articles."
10371 (gnus-set-global-variables)
10373 (if (gnus-summary-first-subject t)
10375 (gnus-summary-show-thread)
10376 (gnus-summary-first-subject t)
10377 (gnus-summary-display-article (gnus-summary-article-number))))
10378 (gnus-summary-position-point)))
10380 (defun gnus-summary-best-unread-article ()
10381 "Select the unread article with the highest score."
10383 (gnus-set-global-variables)
10384 (let ((best -1000000)
10385 (data gnus-newsgroup-data)
10388 (and (gnus-data-unread-p (car data))
10390 (gnus-summary-article-score (gnus-data-number (car data))))
10393 article (gnus-data-number (car data))))
10394 (setq data (cdr data)))
10397 (gnus-summary-goto-article article)
10398 (error "No unread articles"))
10399 (gnus-summary-position-point))))
10401 (defun gnus-summary-last-subject ()
10402 "Go to the last displayed subject line in the group."
10403 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10405 (gnus-summary-goto-subject article))))
10407 (defun gnus-summary-goto-article (article &optional all-headers force)
10408 "Fetch ARTICLE and display it if it exists.
10409 If ALL-HEADERS is non-nil, no header lines are hidden."
10415 (mapcar (lambda (number) (list (int-to-string number)))
10416 gnus-newsgroup-limit)))
10420 (if (gnus-summary-goto-subject article force)
10421 (gnus-summary-display-article article all-headers)
10422 (gnus-message 4 "Couldn't go to article %s" article) nil)
10423 (gnus-summary-position-point)))
10425 (defun gnus-summary-goto-last-article ()
10426 "Go to the previously read article."
10429 (and gnus-last-article
10430 (gnus-summary-goto-article gnus-last-article))
10431 (gnus-summary-position-point)))
10433 (defun gnus-summary-pop-article (number)
10434 "Pop one article off the history and go to the previous.
10435 NUMBER articles will be popped off."
10438 (setq gnus-newsgroup-history
10439 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10441 (gnus-summary-goto-article (car to))
10442 (error "Article history empty")))
10443 (gnus-summary-position-point))
10445 ;; Summary commands and functions for limiting the summary buffer.
10447 (defun gnus-summary-limit-to-articles (n)
10448 "Limit the summary buffer to the next N articles.
10449 If not given a prefix, use the process marked articles instead."
10451 (gnus-set-global-variables)
10453 (let ((articles (gnus-summary-work-articles n)))
10454 (setq gnus-newsgroup-processable nil)
10455 (gnus-summary-limit articles))
10456 (gnus-summary-position-point)))
10458 (defun gnus-summary-pop-limit (&optional total)
10459 "Restore the previous limit.
10460 If given a prefix, remove all limits."
10462 (gnus-set-global-variables)
10464 (setq gnus-newsgroup-limits
10465 (list (mapcar (lambda (h) (mail-header-number h))
10466 gnus-newsgroup-headers))))
10467 (unless gnus-newsgroup-limits
10468 (error "No limit to pop"))
10470 (gnus-summary-limit nil 'pop)
10471 (gnus-summary-position-point)))
10473 (defun gnus-summary-limit-to-subject (subject &optional header)
10474 "Limit the summary buffer to articles that have subjects that match a regexp."
10475 (interactive "sRegexp: ")
10477 (setq header "subject"))
10478 (when (not (equal "" subject))
10480 (let ((articles (gnus-summary-find-matching
10481 (or header "subject") subject 'all)))
10482 (or articles (error "Found no matches for \"%s\"" subject))
10483 (gnus-summary-limit articles))
10484 (gnus-summary-position-point))))
10486 (defun gnus-summary-limit-to-author (from)
10487 "Limit the summary buffer to articles that have authors that match a regexp."
10488 (interactive "sRegexp: ")
10489 (gnus-summary-limit-to-subject from "from"))
10491 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10493 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10495 (defun gnus-summary-limit-to-unread (&optional all)
10496 "Limit the summary buffer to articles that are not marked as read.
10497 If ALL is non-nil, limit strictly to unread articles."
10500 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10501 (gnus-summary-limit-to-marks
10502 ;; Concat all the marks that say that an article is read and have
10504 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10505 gnus-killed-mark gnus-kill-file-mark
10506 gnus-low-score-mark gnus-expirable-mark
10507 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10510 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10511 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10513 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10514 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10515 If REVERSE, limit the summary buffer to articles that are not marked
10516 with MARKS. MARKS can either be a string of marks or a list of marks.
10517 Returns how many articles were removed."
10518 (interactive "sMarks: ")
10519 (gnus-set-global-variables)
10521 (let ((data gnus-newsgroup-data)
10522 (marks (if (listp marks) marks
10523 (append marks nil))) ; Transform to list.
10526 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10527 (memq (gnus-data-mark (car data)) marks))
10528 (setq articles (cons (gnus-data-number (car data)) articles)))
10529 (setq data (cdr data)))
10530 (gnus-summary-limit articles))
10531 (gnus-summary-position-point)))
10533 (defun gnus-summary-limit-to-score (&optional score)
10534 "Limit to articles with score at or above SCORE."
10536 (gnus-set-global-variables)
10537 (setq score (if score
10538 (prefix-numeric-value score)
10539 (or gnus-summary-default-score 0)))
10540 (let ((data gnus-newsgroup-data)
10543 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10545 (push (gnus-data-number (car data)) articles))
10546 (setq data (cdr data)))
10548 (gnus-summary-limit articles)
10549 (gnus-summary-position-point))))
10551 (defun gnus-summary-limit-include-dormant ()
10552 "Display all the hidden articles that are marked as dormant."
10554 (gnus-set-global-variables)
10555 (or gnus-newsgroup-dormant
10556 (error "There are no dormant articles in this group"))
10558 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10559 (gnus-summary-position-point)))
10561 (defun gnus-summary-limit-exclude-dormant ()
10562 "Hide all dormant articles."
10564 (gnus-set-global-variables)
10566 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10567 (gnus-summary-position-point)))
10569 (defun gnus-summary-limit-exclude-childless-dormant ()
10570 "Hide all dormant articles that have no children."
10572 (gnus-set-global-variables)
10573 (let ((data (gnus-data-list t))
10574 articles d children)
10575 ;; Find all articles that are either not dormant or have
10577 (while (setq d (pop data))
10578 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10579 (and (setq children
10580 (gnus-article-children (gnus-data-number d)))
10583 (when (memq (car children) articles)
10588 (push (gnus-data-number d) articles)))
10589 ;; Do the limiting.
10591 (gnus-summary-limit articles)
10592 (gnus-summary-position-point))))
10594 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10595 "Mark all unread excluded articles as read.
10596 If ALL, mark even excluded ticked and dormants as read."
10598 (let ((articles (gnus-sorted-complement
10600 (mapcar (lambda (h) (mail-header-number h))
10601 gnus-newsgroup-headers)
10603 (sort gnus-newsgroup-limit '<)))
10605 (setq gnus-newsgroup-unreads nil)
10607 (setq gnus-newsgroup-dormant nil
10608 gnus-newsgroup-marked nil
10609 gnus-newsgroup-reads
10611 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10612 gnus-newsgroup-reads))
10613 (while (setq article (pop articles))
10614 (unless (or (memq article gnus-newsgroup-dormant)
10615 (memq article gnus-newsgroup-marked))
10616 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10618 (defun gnus-summary-limit (articles &optional pop)
10620 ;; We pop the previous limit off the stack and use that.
10621 (setq articles (car gnus-newsgroup-limits)
10622 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10623 ;; We use the new limit, so we push the old limit on the stack.
10624 (setq gnus-newsgroup-limits
10625 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10627 (setq gnus-newsgroup-limit articles)
10628 (let ((total (length gnus-newsgroup-data))
10629 (data (gnus-data-find-list (gnus-summary-article-number)))
10631 ;; This will do all the work of generating the new summary buffer
10632 ;; according to the new limit.
10633 (gnus-summary-prepare)
10634 ;; Hide any threads, possibly.
10635 (and gnus-show-threads
10636 gnus-thread-hide-subtree
10637 (gnus-summary-hide-all-threads))
10638 ;; Try to return to the article you were at, or one in the
10641 ;; We try to find some article after the current one.
10643 (and (gnus-summary-goto-subject
10644 (gnus-data-number (car data)) nil t)
10647 (setq data (cdr data))))
10649 ;; If there is no data, that means that we were after the last
10650 ;; article. The same goes when we can't find any articles
10651 ;; after the current one.
10653 (goto-char (point-max))
10654 (gnus-summary-find-prev)))
10655 ;; We return how many articles were removed from the summary
10656 ;; buffer as a result of the new limit.
10657 (- total (length gnus-newsgroup-data))))
10659 (defsubst gnus-cut-thread (thread)
10660 "Go forwards in the thread until we find an article that we want to display."
10661 (when (eq gnus-fetch-old-headers 'some)
10662 ;; Deal with old-fetched headers.
10664 (memq (mail-header-number (car thread))
10665 gnus-newsgroup-ancient)
10666 (<= (length (cdr thread)) 1))
10667 (setq thread (cadr thread))))
10668 ;; Deal with sparse threads.
10669 (when (or (eq gnus-build-sparse-threads 'some)
10670 (eq gnus-build-sparse-threads 'more))
10672 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10673 (= (length (cdr thread)) 1))
10674 (setq thread (cadr thread))))
10677 (defun gnus-cut-threads (threads)
10678 "Cut off all uninteresting articles from the beginning of threads."
10679 (when (or (eq gnus-fetch-old-headers 'some)
10680 (eq gnus-build-sparse-threads 'some)
10681 (eq gnus-build-sparse-threads 'more))
10682 (let ((th threads))
10684 (setcar th (gnus-cut-thread (car th)))
10685 (setq th (cdr th)))))
10686 ;; Remove nixed out threads.
10687 (delq nil threads))
10689 (defun gnus-summary-initial-limit (&optional show-if-empty)
10690 "Figure out what the initial limit is supposed to be on group entry.
10691 This entails weeding out unwanted dormants, low-scored articles,
10692 fetch-old-headers verbiage, and so on."
10693 ;; Most groups have nothing to remove.
10694 (if (or gnus-inhibit-limiting
10695 (and (null gnus-newsgroup-dormant)
10696 (not (eq gnus-fetch-old-headers 'some))
10697 (null gnus-summary-expunge-below)
10698 (not (eq gnus-build-sparse-threads 'some))
10699 (not (eq gnus-build-sparse-threads 'more))
10700 (null gnus-thread-expunge-below)
10701 (not gnus-use-nocem)))
10703 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10704 (setq gnus-newsgroup-limit nil)
10707 (unless (car (symbol-value node))
10708 ;; These threads have no parents -- they are roots.
10709 (let ((nodes (cdr (symbol-value node)))
10712 (if (and gnus-thread-expunge-below
10713 (< (gnus-thread-total-score (car nodes))
10714 gnus-thread-expunge-below))
10715 (gnus-expunge-thread (pop nodes))
10716 (setq thread (pop nodes))
10717 (gnus-summary-limit-children thread))))))
10718 gnus-newsgroup-dependencies)
10719 ;; If this limitation resulted in an empty group, we might
10720 ;; pop the previous limit and use it instead.
10721 (when (and (not gnus-newsgroup-limit)
10723 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10724 gnus-newsgroup-limit))
10726 (defun gnus-summary-limit-children (thread)
10727 "Return 1 if this subthread is visible and 0 if it is not."
10728 ;; First we get the number of visible children to this thread. This
10729 ;; is done by recursing down the thread using this function, so this
10730 ;; will really go down to a leaf article first, before slowly
10731 ;; working its way up towards the root.
10735 (apply '+ (mapcar 'gnus-summary-limit-children
10738 (number (mail-header-number (car thread)))
10741 ;; If this article is dormant and has absolutely no visible
10742 ;; children, then this article isn't visible.
10743 (and (memq number gnus-newsgroup-dormant)
10745 ;; If this is a "fetch-old-headered" and there is only one
10746 ;; visible child (or less), then we don't want this article.
10747 (and (eq gnus-fetch-old-headers 'some)
10748 (memq number gnus-newsgroup-ancient)
10750 ;; If this is a sparsely inserted article with no children,
10751 ;; we don't want it.
10752 (and (eq gnus-build-sparse-threads 'some)
10753 (memq number gnus-newsgroup-sparse)
10755 ;; If we use expunging, and this article is really
10756 ;; low-scored, then we don't want this article.
10757 (when (and gnus-summary-expunge-below
10759 (or (cdr (assq number gnus-newsgroup-scored))
10760 gnus-summary-default-score))
10761 gnus-summary-expunge-below))
10762 ;; We increase the expunge-tally here, but that has
10763 ;; nothing to do with the limits, really.
10764 (incf gnus-newsgroup-expunged-tally)
10765 ;; We also mark as read here, if that's wanted.
10766 (when (and gnus-summary-mark-below
10767 (< score gnus-summary-mark-below))
10768 (setq gnus-newsgroup-unreads
10769 (delq number gnus-newsgroup-unreads))
10770 (if gnus-newsgroup-auto-expire
10771 (push number gnus-newsgroup-expirable)
10772 (push (cons number gnus-low-score-mark)
10773 gnus-newsgroup-reads)))
10775 (and gnus-use-nocem
10776 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10777 ;; Nope, invisible article.
10779 ;; Ok, this article is to be visible, so we add it to the limit
10781 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10784 (defun gnus-expunge-thread (thread)
10785 "Mark all articles in THREAD as read."
10786 (let* ((number (mail-header-number (car thread))))
10787 (incf gnus-newsgroup-expunged-tally)
10788 ;; We also mark as read here, if that's wanted.
10789 (setq gnus-newsgroup-unreads
10790 (delq number gnus-newsgroup-unreads))
10791 (if gnus-newsgroup-auto-expire
10792 (push number gnus-newsgroup-expirable)
10793 (push (cons number gnus-low-score-mark)
10794 gnus-newsgroup-reads)))
10795 ;; Go recursively through all subthreads.
10796 (mapcar 'gnus-expunge-thread (cdr thread)))
10798 ;; Summary article oriented commands
10800 (defun gnus-summary-refer-parent-article (n)
10801 "Refer parent article N times.
10802 The difference between N and the number of articles fetched is returned."
10804 (gnus-set-global-variables)
10808 (let* ((header (gnus-summary-article-header))
10810 ;; If we try to find the parent of the currently
10811 ;; displayed article, then we take a look at the actual
10812 ;; References header, since this is slightly more
10813 ;; reliable than the References field we got from the
10815 (if (and (eq (mail-header-number header)
10816 (cdr gnus-article-current))
10817 (equal gnus-newsgroup-name
10818 (car gnus-article-current)))
10820 (set-buffer gnus-original-article-buffer)
10821 (nnheader-narrow-to-headers)
10823 (mail-fetch-field "references")
10825 ;; It's not the current article, so we take a bet on
10826 ;; the value we got from the server.
10827 (mail-header-references header))))
10828 (if (setq ref (or ref (mail-header-references header)))
10829 (or (gnus-summary-refer-article (gnus-parent-id ref))
10830 (gnus-message 1 "Couldn't find parent"))
10831 (gnus-message 1 "No references in article %d"
10832 (gnus-summary-article-number))
10835 (gnus-summary-position-point)
10838 (defun gnus-summary-refer-references ()
10839 "Fetch all articles mentioned in the References header.
10840 Return how many articles were fetched."
10842 (gnus-set-global-variables)
10843 (let ((ref (mail-header-references (gnus-summary-article-header)))
10844 (current (gnus-summary-article-number))
10846 ;; For each Message-ID in the References header...
10847 (while (string-match "<[^>]*>" ref)
10849 ;; ... fetch that article.
10850 (gnus-summary-refer-article
10851 (prog1 (match-string 0 ref)
10852 (setq ref (substring ref (match-end 0))))))
10853 (gnus-summary-goto-subject current)
10854 (gnus-summary-position-point)
10857 (defun gnus-summary-refer-article (message-id)
10858 "Fetch an article specified by MESSAGE-ID."
10859 (interactive "sMessage-ID: ")
10860 (when (and (stringp message-id)
10861 (not (zerop (length message-id))))
10862 ;; Construct the correct Message-ID if necessary.
10863 ;; Suggested by tale@pawl.rpi.edu.
10864 (unless (string-match "^<" message-id)
10865 (setq message-id (concat "<" message-id)))
10866 (unless (string-match ">$" message-id)
10867 (setq message-id (concat message-id ">")))
10868 (let ((header (car (gnus-gethash message-id
10869 gnus-newsgroup-dependencies))))
10871 ;; The article is present in the buffer, to we just go to it.
10872 (gnus-summary-goto-article (mail-header-number header) nil t)
10873 ;; We fetch the article
10874 (let ((gnus-override-method
10875 (and (gnus-news-group-p gnus-newsgroup-name)
10876 gnus-refer-article-method))
10878 ;; Start the special refer-article method, if necessary.
10879 (when gnus-refer-article-method
10880 (gnus-check-server gnus-refer-article-method))
10881 ;; Fetch the header, and display the article.
10882 (if (setq number (gnus-summary-insert-subject message-id))
10883 (gnus-summary-select-article nil nil nil number)
10884 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10886 (defun gnus-summary-enter-digest-group (&optional force)
10887 "Enter a digest group based on the current article."
10889 (gnus-set-global-variables)
10890 (gnus-summary-select-article)
10891 (let ((name (format "%s-%d"
10892 (gnus-group-prefixed-name
10893 gnus-newsgroup-name (list 'nndoc ""))
10894 gnus-current-article))
10895 (ogroup gnus-newsgroup-name)
10896 (case-fold-search t)
10897 (buf (current-buffer))
10900 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10901 (insert-buffer-substring gnus-original-article-buffer)
10903 (goto-char (point-min))
10904 (or (search-forward "\n\n" nil t) (point)))
10905 (goto-char (point-min))
10906 (delete-matching-lines "^\\(Path\\):\\|^From ")
10909 (if (gnus-group-read-ephemeral-group
10910 name `(nndoc ,name (nndoc-address
10912 (nndoc-article-type ,(if force 'digest 'guess))) t)
10913 ;; Make all postings to this group go to the parent group.
10914 (nconc (gnus-info-params (gnus-get-info name))
10915 (list (cons 'to-group ogroup)))
10916 ;; Couldn't select this doc group.
10917 (switch-to-buffer buf)
10918 (gnus-set-global-variables)
10919 (gnus-configure-windows 'summary)
10920 (gnus-message 3 "Article couldn't be entered?"))
10921 (kill-buffer dig))))
10923 (defun gnus-summary-isearch-article (&optional regexp-p)
10924 "Do incremental search forward on the current article.
10925 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10927 (gnus-set-global-variables)
10928 (gnus-summary-select-article)
10929 (gnus-configure-windows 'article)
10930 (gnus-eval-in-buffer-window
10931 gnus-article-buffer
10932 (goto-char (point-min))
10933 (isearch-forward regexp-p)))
10935 (defun gnus-summary-search-article-forward (regexp &optional backward)
10936 "Search for an article containing REGEXP forward.
10937 If BACKWARD, search backward instead."
10940 (format "Search article %s (regexp%s): "
10941 (if current-prefix-arg "backward" "forward")
10942 (if gnus-last-search-regexp
10943 (concat ", default " gnus-last-search-regexp)
10945 current-prefix-arg))
10946 (gnus-set-global-variables)
10947 (if (string-equal regexp "")
10948 (setq regexp (or gnus-last-search-regexp ""))
10949 (setq gnus-last-search-regexp regexp))
10950 (if (gnus-summary-search-article regexp backward)
10951 (gnus-article-set-window-start
10952 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10953 (error "Search failed: \"%s\"" regexp)))
10955 (defun gnus-summary-search-article-backward (regexp)
10956 "Search for an article containing REGEXP backward."
10959 (format "Search article backward (regexp%s): "
10960 (if gnus-last-search-regexp
10961 (concat ", default " gnus-last-search-regexp)
10963 (gnus-summary-search-article-forward regexp 'backward))
10965 (defun gnus-summary-search-article (regexp &optional backward)
10966 "Search for an article containing REGEXP.
10967 Optional argument BACKWARD means do search for backward.
10968 gnus-select-article-hook is not called during the search."
10969 (let ((gnus-select-article-hook nil) ;Disable hook.
10970 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10973 (function re-search-backward) (function re-search-forward)))
10976 ;; Hidden thread subtrees must be searched for ,too.
10977 (gnus-summary-show-all-threads)
10978 ;; First of all, search current article.
10979 ;; We don't want to read article again from NNTP server nor reset
10981 (gnus-summary-select-article)
10982 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10983 (setq last gnus-current-article)
10984 (gnus-eval-in-buffer-window
10985 gnus-article-buffer
10988 ;; Begin search from current point.
10989 (setq found (funcall re-search regexp nil t))))
10990 ;; Then search next articles.
10991 (while (and (not found)
10992 (gnus-summary-display-article
10993 (if backward (gnus-summary-find-prev)
10994 (gnus-summary-find-next))))
10995 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10996 (gnus-eval-in-buffer-window
10997 gnus-article-buffer
11000 (goto-char (if backward (point-max) (point-min)))
11001 (setq found (funcall re-search regexp nil t)))))
11003 ;; Adjust article pointer.
11004 (or (eq last gnus-current-article)
11005 (setq gnus-last-article last))
11006 ;; Return T if found such article.
11009 (defun gnus-summary-find-matching (header regexp &optional backward unread
11011 "Return a list of all articles that match REGEXP on HEADER.
11012 The search stars on the current article and goes forwards unless
11013 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11014 If UNREAD is non-nil, only unread articles will
11015 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11016 in the comparisons."
11017 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11018 (gnus-data-find-list
11019 (gnus-summary-article-number) (gnus-data-list backward))))
11020 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11021 (case-fold-search (not not-case-fold))
11023 (or (fboundp (intern (concat "mail-header-" header)))
11024 (error "%s is not a valid header" header))
11026 (setq d (car data))
11027 (and (or (not unread) ; We want all articles...
11028 (gnus-data-unread-p d)) ; Or just unreads.
11029 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11030 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11031 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11032 (setq data (cdr data)))
11033 (nreverse articles)))
11035 (defun gnus-summary-execute-command (header regexp command &optional backward)
11036 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11037 If HEADER is an empty string (or nil), the match is done on the entire
11038 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11040 (list (let ((completion-ignore-case t))
11043 (mapcar (lambda (string) (list string))
11044 '("Number" "Subject" "From" "Lines" "Date"
11045 "Message-ID" "Xref" "References" "Body"))
11046 nil 'require-match))
11047 (read-string "Regexp: ")
11048 (read-key-sequence "Command: ")
11049 current-prefix-arg))
11050 (when (equal header "Body")
11052 (gnus-set-global-variables)
11053 ;; Hidden thread subtrees must be searched as well.
11054 (gnus-summary-show-all-threads)
11055 ;; We don't want to change current point nor window configuration.
11057 (save-window-excursion
11058 (gnus-message 6 "Executing %s..." (key-description command))
11059 ;; We'd like to execute COMMAND interactively so as to give arguments.
11060 (gnus-execute header regexp
11061 `(lambda () (call-interactively ',(key-binding command)))
11063 (gnus-message 6 "Executing %s...done" (key-description command)))))
11065 (defun gnus-summary-beginning-of-article ()
11066 "Scroll the article back to the beginning."
11068 (gnus-set-global-variables)
11069 (gnus-summary-select-article)
11070 (gnus-configure-windows 'article)
11071 (gnus-eval-in-buffer-window
11072 gnus-article-buffer
11074 (goto-char (point-min))
11075 (and gnus-break-pages (gnus-narrow-to-page))))
11077 (defun gnus-summary-end-of-article ()
11078 "Scroll to the end of the article."
11080 (gnus-set-global-variables)
11081 (gnus-summary-select-article)
11082 (gnus-configure-windows 'article)
11083 (gnus-eval-in-buffer-window
11084 gnus-article-buffer
11086 (goto-char (point-max))
11088 (and gnus-break-pages (gnus-narrow-to-page))))
11090 (defun gnus-summary-show-article (&optional arg)
11091 "Force re-fetching of the current article.
11092 If ARG (the prefix) is non-nil, show the raw article without any
11093 article massaging functions being run."
11095 (gnus-set-global-variables)
11097 ;; Select the article the normal way.
11098 (gnus-summary-select-article nil 'force)
11099 ;; Bind the article treatment functions to nil.
11100 (let ((gnus-have-all-headers t)
11101 gnus-article-display-hook
11102 gnus-article-prepare-hook
11105 (gnus-summary-select-article nil 'force)))
11106 ; (gnus-configure-windows 'article)
11107 (gnus-summary-position-point))
11109 (defun gnus-summary-verbose-headers (&optional arg)
11110 "Toggle permanent full header display.
11111 If ARG is a positive number, turn header display on.
11112 If ARG is a negative number, turn header display off."
11114 (gnus-set-global-variables)
11115 (gnus-summary-toggle-header arg)
11116 (setq gnus-show-all-headers
11117 (cond ((or (not (numberp arg))
11119 (not gnus-show-all-headers))
11123 (defun gnus-summary-toggle-header (&optional arg)
11124 "Show the headers if they are hidden, or hide them if they are shown.
11125 If ARG is a positive number, show the entire header.
11126 If ARG is a negative number, hide the unwanted header lines."
11128 (gnus-set-global-variables)
11130 (set-buffer gnus-article-buffer)
11131 (let* ((buffer-read-only nil)
11132 (inhibit-point-motion-hooks t)
11133 (hidden (text-property-any
11134 (goto-char (point-min)) (search-forward "\n\n")
11137 (goto-char (point-min))
11138 (when (search-forward "\n\n" nil t)
11139 (delete-region (point-min) (1- (point))))
11140 (goto-char (point-min))
11142 (set-buffer gnus-original-article-buffer)
11143 (goto-char (point-min))
11144 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11145 (insert-buffer-substring gnus-original-article-buffer 1 e)
11146 (let ((gnus-inhibit-hiding t))
11147 (run-hooks 'gnus-article-display-hook))
11148 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11149 (gnus-article-hide-headers)))))
11151 (defun gnus-summary-show-all-headers ()
11152 "Make all header lines visible."
11154 (gnus-set-global-variables)
11155 (gnus-article-show-all-headers))
11157 (defun gnus-summary-toggle-mime (&optional arg)
11158 "Toggle MIME processing.
11159 If ARG is a positive number, turn MIME processing on."
11161 (gnus-set-global-variables)
11162 (setq gnus-show-mime
11163 (if (null arg) (not gnus-show-mime)
11164 (> (prefix-numeric-value arg) 0)))
11165 (gnus-summary-select-article t 'force))
11167 (defun gnus-summary-caesar-message (&optional arg)
11168 "Caesar rotate the current article by 13.
11169 The numerical prefix specifies how manu places to rotate each letter
11172 (gnus-set-global-variables)
11173 (gnus-summary-select-article)
11174 (let ((mail-header-separator ""))
11175 (gnus-eval-in-buffer-window
11176 gnus-article-buffer
11179 (let ((start (window-start)))
11180 (news-caesar-buffer-body arg)
11181 (set-window-start (get-buffer-window (current-buffer)) start))))))
11183 (defun gnus-summary-stop-page-breaking ()
11184 "Stop page breaking in the current article."
11186 (gnus-set-global-variables)
11187 (gnus-summary-select-article)
11188 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11190 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11191 "Move the current article to a different newsgroup.
11192 If N is a positive number, move the N next articles.
11193 If N is a negative number, move the N previous articles.
11194 If N is nil and any articles have been marked with the process mark,
11195 move those articles instead.
11196 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11197 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11198 re-spool using this method.
11200 For this function to work, both the current newsgroup and the
11201 newsgroup that you want to move to have to support the `request-move'
11202 and `request-accept' functions."
11204 (unless action (setq action 'move))
11205 (gnus-set-global-variables)
11206 ;; Check whether the source group supports the required functions.
11207 (cond ((and (eq action 'move)
11208 (not (gnus-check-backend-function
11209 'request-move-article gnus-newsgroup-name)))
11210 (error "The current group does not support article moving"))
11211 ((and (eq action 'crosspost)
11212 (not (gnus-check-backend-function
11213 'request-replace-article gnus-newsgroup-name)))
11214 (error "The current group does not support article editing")))
11215 (let ((articles (gnus-summary-work-articles n))
11216 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11217 (names '((move "move" "Moving")
11218 (copy "copy" "Copying")
11219 (crosspost "crosspost" "Crossposting")))
11220 (copy-buf (save-excursion
11221 (nnheader-set-temp-buffer " *copy article*")))
11222 art-group to-method new-xref article to-groups)
11223 (unless (assq action names)
11224 (error "Unknown action %s" action))
11225 ;; Read the newsgroup name.
11226 (when (and (not to-newsgroup)
11227 (not select-method))
11229 (gnus-read-move-group-name
11230 (cadr (assq action names))
11231 gnus-current-move-group articles prefix))
11232 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11233 (setq to-method (or select-method
11234 (gnus-find-method-for-group to-newsgroup)))
11235 ;; Check the method we are to move this article to...
11236 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11237 (error "%s does not support article copying" (car to-method)))
11238 (or (gnus-check-server to-method)
11239 (error "Can't open server %s" (car to-method)))
11240 (gnus-message 6 "%s to %s: %s..."
11241 (caddr (assq action names))
11242 (or (car select-method) to-newsgroup) articles)
11244 (setq article (pop articles))
11248 ;; Move the article.
11250 (gnus-request-move-article
11251 article ; Article to move
11252 gnus-newsgroup-name ; From newsgrouo
11253 (nth 1 (gnus-find-method-for-group
11254 gnus-newsgroup-name)) ; Server
11255 (list 'gnus-request-accept-article
11256 to-newsgroup (list 'quote select-method)
11257 (not articles)) ; Accept form
11258 (not articles))) ; Only save nov last time
11259 ;; Copy the article.
11262 (set-buffer copy-buf)
11263 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11264 (gnus-request-accept-article
11265 to-newsgroup select-method (not articles))))
11266 ;; Crosspost the article.
11267 ((eq action 'crosspost)
11268 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11269 (setq new-xref (concat gnus-newsgroup-name ":" article))
11270 (if (and xref (not (string= xref "")))
11272 (when (string-match "^Xref: " xref)
11273 (setq xref (substring xref (match-end 0))))
11274 (setq new-xref (concat xref " " new-xref)))
11275 (setq new-xref (concat (system-name) " " new-xref)))
11277 (set-buffer copy-buf)
11278 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11279 (nnheader-replace-header "xref" new-xref)
11280 (gnus-request-accept-article
11281 to-newsgroup select-method (not articles)))))))
11282 (if (not art-group)
11283 (gnus-message 1 "Couldn't %s article %s"
11284 (cadr (assq action names)) article)
11287 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11289 (gnus-group-prefixed-name
11292 (gnus-find-method-for-group to-newsgroup)))
11293 gnus-newsrc-hashtb)))
11294 (info (nth 2 entry))
11295 (to-group (gnus-info-group info)))
11296 ;; Update the group that has been moved to.
11298 (memq action '(move copy)))
11299 (unless (member to-group to-groups)
11300 (push to-group to-groups))
11302 (unless (memq article gnus-newsgroup-unreads)
11303 (gnus-info-set-read
11304 info (gnus-add-to-range (gnus-info-read info)
11305 (list (cdr art-group)))))
11307 ;; Copy any marks over to the new group.
11308 (let ((marks gnus-article-mark-lists)
11309 (to-article (cdr art-group)))
11311 ;; See whether the article is to be put in the cache.
11312 (when gnus-use-cache
11313 (gnus-cache-possibly-enter-article
11314 to-group to-article
11315 (let ((header (copy-sequence
11316 (gnus-summary-article-header article))))
11317 (mail-header-set-number header to-article)
11319 (memq article gnus-newsgroup-marked)
11320 (memq article gnus-newsgroup-dormant)
11321 (memq article gnus-newsgroup-unreads)))
11324 (when (memq article (symbol-value
11325 (intern (format "gnus-newsgroup-%s"
11327 ;; If the other group is the same as this group,
11328 ;; then we have to add the mark to the list.
11329 (when (equal to-group gnus-newsgroup-name)
11330 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11333 (intern (format "gnus-newsgroup-%s"
11335 ;; Copy mark to other group.
11336 (gnus-add-marked-articles
11337 to-group (cdar marks) (list to-article) info))
11338 (setq marks (cdr marks)))))
11340 ;; Update the Xref header in this article to point to
11341 ;; the new crossposted article we have just created.
11342 (when (eq action 'crosspost)
11344 (set-buffer copy-buf)
11345 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11346 (nnheader-replace-header
11347 "xref" (concat new-xref " " (gnus-group-prefixed-name
11348 (car art-group) to-method)
11349 ":" (cdr art-group)))
11350 (gnus-request-replace-article
11351 article gnus-newsgroup-name (current-buffer)))))
11353 (gnus-summary-goto-subject article)
11354 (when (eq action 'move)
11355 (gnus-summary-mark-article article gnus-canceled-mark)))
11356 (gnus-summary-remove-process-mark article))
11357 ;; Re-activate all groups that have been moved to.
11359 (gnus-activate-group (pop to-groups)))
11361 (gnus-kill-buffer copy-buf)
11362 (gnus-summary-position-point)
11363 (gnus-set-mode-line 'summary)))
11365 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11366 "Move the current article to a different newsgroup.
11367 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11368 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11369 re-spool using this method."
11371 (gnus-summary-move-article n nil select-method 'copy))
11373 (defun gnus-summary-crosspost-article (&optional n)
11374 "Crosspost the current article to some other group."
11376 (gnus-summary-move-article n nil nil 'crosspost))
11378 (defvar gnus-summary-respool-default-method nil
11379 "Default method for respooling an article.
11380 If nil, use to the current newsgroup method.")
11382 (defun gnus-summary-respool-article (&optional n method)
11383 "Respool the current article.
11384 The article will be squeezed through the mail spooling process again,
11385 which means that it will be put in some mail newsgroup or other
11386 depending on `nnmail-split-methods'.
11387 If N is a positive number, respool the N next articles.
11388 If N is a negative number, respool the N previous articles.
11389 If N is nil and any articles have been marked with the process mark,
11390 respool those articles instead.
11392 Respooling can be done both from mail groups and \"real\" newsgroups.
11393 In the former case, the articles in question will be moved from the
11394 current group into whatever groups they are destined to. In the
11395 latter case, they will be copied into the relevant groups."
11397 (list current-prefix-arg
11398 (let* ((methods (gnus-methods-using 'respool))
11400 (symbol-name (or gnus-summary-respool-default-method
11401 (car (gnus-find-method-for-group
11402 gnus-newsgroup-name)))))
11404 (gnus-completing-read
11405 methname "What backend do you want to use when? "
11406 methods nil t nil 'gnus-method-history))
11409 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11410 (list (intern method) ""))
11414 (cdr (completing-read
11416 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11417 (gnus-set-global-variables)
11419 (error "No method given for respooling"))
11420 (if (assoc (symbol-name
11421 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11422 (gnus-methods-using 'respool))
11423 (gnus-summary-move-article n nil method)
11424 (gnus-summary-copy-article n nil method)))
11426 (defun gnus-summary-import-article (file)
11427 "Import a random file into a mail newsgroup."
11428 (interactive "fImport file: ")
11429 (gnus-set-global-variables)
11430 (let ((group gnus-newsgroup-name)
11431 (now (current-time))
11433 (or (gnus-check-backend-function 'request-accept-article group)
11434 (error "%s does not support article importing" group))
11435 (or (file-readable-p file)
11436 (not (file-regular-p file))
11437 (error "Can't read %s" file))
11439 (set-buffer (get-buffer-create " *import file*"))
11440 (buffer-disable-undo (current-buffer))
11442 (insert-file-contents file)
11443 (goto-char (point-min))
11444 (unless (nnheader-article-p)
11445 ;; This doesn't look like an article, so we fudge some headers.
11446 (setq atts (file-attributes file)
11447 lines (count-lines (point-min) (point-max)))
11448 (insert "From: " (read-string "From: ") "\n"
11449 "Subject: " (read-string "Subject: ") "\n"
11450 "Date: " (timezone-make-date-arpa-standard
11451 (current-time-string (nth 5 atts))
11452 (current-time-zone now)
11453 (current-time-zone now)) "\n"
11454 "Message-ID: " (gnus-inews-message-id) "\n"
11455 "Lines: " (int-to-string lines) "\n"
11456 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11457 (gnus-request-accept-article group nil t)
11458 (kill-buffer (current-buffer)))))
11460 (defun gnus-summary-expire-articles ()
11461 "Expire all articles that are marked as expirable in the current group."
11463 (gnus-set-global-variables)
11464 (when (gnus-check-backend-function
11465 'request-expire-articles gnus-newsgroup-name)
11466 ;; This backend supports expiry.
11467 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11468 (expirable (if total
11469 (gnus-list-of-read-articles gnus-newsgroup-name)
11470 (setq gnus-newsgroup-expirable
11471 (sort gnus-newsgroup-expirable '<))))
11472 (expiry-wait (gnus-group-get-parameter
11473 gnus-newsgroup-name 'expiry-wait))
11476 ;; There are expirable articles in this group, so we run them
11477 ;; through the expiry process.
11478 (gnus-message 6 "Expiring articles...")
11479 ;; The list of articles that weren't expired is returned.
11481 (let ((nnmail-expiry-wait-function nil)
11482 (nnmail-expiry-wait expiry-wait))
11483 (setq es (gnus-request-expire-articles
11484 expirable gnus-newsgroup-name)))
11485 (setq es (gnus-request-expire-articles
11486 expirable gnus-newsgroup-name)))
11487 (or total (setq gnus-newsgroup-expirable es))
11488 ;; We go through the old list of expirable, and mark all
11489 ;; really expired articles as nonexistent.
11490 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11491 (let ((gnus-use-cache nil))
11493 (unless (memq (car expirable) es)
11494 (when (gnus-data-find (car expirable))
11495 (gnus-summary-mark-article
11496 (car expirable) gnus-canceled-mark)))
11497 (setq expirable (cdr expirable)))))
11498 (gnus-message 6 "Expiring articles...done")))))
11500 (defun gnus-summary-expire-articles-now ()
11501 "Expunge all expirable articles in the current group.
11502 This means that *all* articles that are marked as expirable will be
11503 deleted forever, right now."
11505 (gnus-set-global-variables)
11506 (or gnus-expert-user
11508 "Are you really, really, really sure you want to expunge? ")
11510 (let ((nnmail-expiry-wait 'immediate)
11511 (nnmail-expiry-wait-function nil))
11512 (gnus-summary-expire-articles)))
11514 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11515 (defun gnus-summary-delete-article (&optional n)
11516 "Delete the N next (mail) articles.
11517 This command actually deletes articles. This is not a marking
11518 command. The article will disappear forever from your life, never to
11520 If N is negative, delete backwards.
11521 If N is nil and articles have been marked with the process mark,
11522 delete these instead."
11524 (gnus-set-global-variables)
11525 (or (gnus-check-backend-function 'request-expire-articles
11526 gnus-newsgroup-name)
11527 (error "The current newsgroup does not support article deletion."))
11528 ;; Compute the list of articles to delete.
11529 (let ((articles (gnus-summary-work-articles n))
11531 (if (and gnus-novice-user
11532 (not (gnus-y-or-n-p
11533 (format "Do you really want to delete %s forever? "
11534 (if (> (length articles) 1) "these articles"
11535 "this article")))))
11537 ;; Delete the articles.
11538 (setq not-deleted (gnus-request-expire-articles
11539 articles gnus-newsgroup-name 'force))
11541 (gnus-summary-remove-process-mark (car articles))
11542 ;; The backend might not have been able to delete the article
11544 (or (memq (car articles) not-deleted)
11545 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11546 (setq articles (cdr articles))))
11547 (gnus-summary-position-point)
11548 (gnus-set-mode-line 'summary)
11551 (defun gnus-summary-edit-article (&optional force)
11552 "Enter into a buffer and edit the current article.
11553 This will have permanent effect only in mail groups.
11554 If FORCE is non-nil, allow editing of articles even in read-only
11558 (set-buffer gnus-summary-buffer)
11559 (gnus-set-global-variables)
11560 (when (and (not force)
11561 (gnus-group-read-only-p))
11562 (error "The current newsgroup does not support article editing."))
11563 (gnus-summary-select-article t nil t)
11564 (gnus-configure-windows 'article)
11565 (select-window (get-buffer-window gnus-article-buffer))
11566 (gnus-message 6 "C-c C-c to end edits")
11567 (setq buffer-read-only nil)
11569 (use-local-map (copy-keymap (current-local-map)))
11570 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11571 (buffer-enable-undo)
11573 (goto-char (point-min))
11574 (search-forward "\n\n" nil t)))
11576 (defun gnus-summary-edit-article-done ()
11577 "Make edits to the current article permanent."
11579 (if (gnus-group-read-only-p)
11581 (gnus-summary-edit-article-postpone)
11583 1 "The current newsgroup does not support article editing."))
11584 (let ((buf (format "%s" (buffer-string))))
11587 (if (not (gnus-request-replace-article
11588 (cdr gnus-article-current) (car gnus-article-current)
11590 (error "Couldn't replace article.")
11591 (gnus-article-mode)
11592 (use-local-map gnus-article-mode-map)
11593 (setq buffer-read-only t)
11594 (buffer-disable-undo (current-buffer))
11595 (gnus-configure-windows 'summary)
11596 (gnus-summary-update-article (cdr gnus-article-current))
11597 (when gnus-use-cache
11598 (gnus-cache-update-article
11599 (cdr gnus-article-current) (car gnus-article-current))))
11600 (run-hooks 'gnus-article-display-hook)
11601 (and (gnus-visual-p 'summary-highlight 'highlight)
11602 (run-hooks 'gnus-visual-mark-article-hook)))))
11604 (defun gnus-summary-edit-article-postpone ()
11605 "Postpone changes to the current article."
11607 (gnus-article-mode)
11608 (use-local-map gnus-article-mode-map)
11609 (setq buffer-read-only t)
11610 (buffer-disable-undo (current-buffer))
11611 (gnus-configure-windows 'summary)
11612 (and (gnus-visual-p 'summary-highlight 'highlight)
11613 (run-hooks 'gnus-visual-mark-article-hook)))
11615 (defun gnus-summary-respool-query ()
11616 "Query where the respool algorithm would put this article."
11618 (gnus-set-global-variables)
11619 (gnus-summary-select-article)
11621 (set-buffer gnus-article-buffer)
11623 (goto-char (point-min))
11624 (search-forward "\n\n")
11625 (narrow-to-region (point-min) (point))
11626 (pp-eval-expression
11627 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11629 ;; Summary score commands.
11631 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11633 (defun gnus-summary-raise-score (n)
11634 "Raise the score of the current article by N."
11636 (gnus-set-global-variables)
11637 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11639 (defun gnus-summary-set-score (n)
11640 "Set the score of the current article to N."
11642 (gnus-set-global-variables)
11644 (gnus-summary-show-thread)
11645 (let ((buffer-read-only nil))
11647 (gnus-summary-update-mark
11648 (if (= n (or gnus-summary-default-score 0)) ?
11649 (if (< n (or gnus-summary-default-score 0))
11650 gnus-score-below-mark gnus-score-over-mark)) 'score))
11651 (let* ((article (gnus-summary-article-number))
11652 (score (assq article gnus-newsgroup-scored)))
11653 (if score (setcdr score n)
11654 (setq gnus-newsgroup-scored
11655 (cons (cons article n) gnus-newsgroup-scored))))
11656 (gnus-summary-update-line)))
11658 (defun gnus-summary-current-score ()
11659 "Return the score of the current article."
11661 (gnus-set-global-variables)
11662 (gnus-message 1 "%s" (gnus-summary-article-score)))
11664 ;; Summary marking commands.
11666 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11667 "Mark articles which has the same subject as read, and then select the next.
11668 If UNMARK is positive, remove any kind of mark.
11669 If UNMARK is negative, tick articles."
11671 (gnus-set-global-variables)
11673 (setq unmark (prefix-numeric-value unmark)))
11675 (gnus-summary-mark-same-subject
11676 (gnus-summary-article-subject) unmark)))
11677 ;; Select next unread article. If auto-select-same mode, should
11678 ;; select the first unread article.
11679 (gnus-summary-next-article t (and gnus-auto-select-same
11680 (gnus-summary-article-subject)))
11681 (gnus-message 7 "%d article%s marked as %s"
11682 count (if (= count 1) " is" "s are")
11683 (if unmark "unread" "read"))))
11685 (defun gnus-summary-kill-same-subject (&optional unmark)
11686 "Mark articles which has the same subject as read.
11687 If UNMARK is positive, remove any kind of mark.
11688 If UNMARK is negative, tick articles."
11690 (gnus-set-global-variables)
11692 (setq unmark (prefix-numeric-value unmark)))
11694 (gnus-summary-mark-same-subject
11695 (gnus-summary-article-subject) unmark)))
11696 ;; If marked as read, go to next unread subject.
11698 ;; Go to next unread subject.
11699 (gnus-summary-next-subject 1 t))
11700 (gnus-message 7 "%d articles are marked as %s"
11701 count (if unmark "unread" "read"))))
11703 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11704 "Mark articles with same SUBJECT as read, and return marked number.
11705 If optional argument UNMARK is positive, remove any kinds of marks.
11706 If optional argument UNMARK is negative, mark articles as unread instead."
11710 ((null unmark) ; Mark as read.
11713 (gnus-summary-mark-article-as-read gnus-killed-mark)
11714 (gnus-summary-show-thread) t)
11715 (gnus-summary-find-subject subject))
11716 (setq count (1+ count))))
11717 ((> unmark 0) ; Tick.
11720 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11721 (gnus-summary-show-thread) t)
11722 (gnus-summary-find-subject subject))
11723 (setq count (1+ count))))
11724 (t ; Mark as unread.
11727 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11728 (gnus-summary-show-thread) t)
11729 (gnus-summary-find-subject subject))
11730 (setq count (1+ count)))))
11731 (gnus-set-mode-line 'summary)
11732 ;; Return the number of marked articles.
11735 (defun gnus-summary-mark-as-processable (n &optional unmark)
11736 "Set the process mark on the next N articles.
11737 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11738 the process mark instead. The difference between N and the actual
11739 number of articles marked is returned."
11741 (gnus-set-global-variables)
11742 (let ((backward (< n 0))
11747 (gnus-summary-remove-process-mark
11748 (gnus-summary-article-number))
11749 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11750 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11752 (if (/= 0 n) (gnus-message 7 "No more articles"))
11753 (gnus-summary-recenter)
11754 (gnus-summary-position-point)
11757 (defun gnus-summary-unmark-as-processable (n)
11758 "Remove the process mark from the next N articles.
11759 If N is negative, mark backward instead. The difference between N and
11760 the actual number of articles marked is returned."
11762 (gnus-set-global-variables)
11763 (gnus-summary-mark-as-processable n t))
11765 (defun gnus-summary-unmark-all-processable ()
11766 "Remove the process mark from all articles."
11768 (gnus-set-global-variables)
11770 (while gnus-newsgroup-processable
11771 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11772 (gnus-summary-position-point))
11774 (defun gnus-summary-mark-as-expirable (n)
11775 "Mark N articles forward as expirable.
11776 If N is negative, mark backward instead. The difference between N and
11777 the actual number of articles marked is returned."
11779 (gnus-set-global-variables)
11780 (gnus-summary-mark-forward n gnus-expirable-mark))
11782 (defun gnus-summary-mark-article-as-replied (article)
11783 "Mark ARTICLE replied and update the summary line."
11784 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11785 (let ((buffer-read-only nil))
11786 (when (gnus-summary-goto-subject article)
11787 (gnus-summary-update-secondary-mark article))))
11789 (defun gnus-summary-set-bookmark (article)
11790 "Set a bookmark in current article."
11791 (interactive (list (gnus-summary-article-number)))
11792 (gnus-set-global-variables)
11793 (if (or (not (get-buffer gnus-article-buffer))
11794 (not gnus-current-article)
11795 (not gnus-article-current)
11796 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11797 (error "No current article selected"))
11798 ;; Remove old bookmark, if one exists.
11799 (let ((old (assq article gnus-newsgroup-bookmarks)))
11800 (if old (setq gnus-newsgroup-bookmarks
11801 (delq old gnus-newsgroup-bookmarks))))
11802 ;; Set the new bookmark, which is on the form
11803 ;; (article-number . line-number-in-body).
11804 (setq gnus-newsgroup-bookmarks
11808 (set-buffer gnus-article-buffer)
11812 (goto-char (point-min))
11813 (search-forward "\n\n" nil t)
11816 gnus-newsgroup-bookmarks))
11817 (gnus-message 6 "A bookmark has been added to the current article."))
11819 (defun gnus-summary-remove-bookmark (article)
11820 "Remove the bookmark from the current article."
11821 (interactive (list (gnus-summary-article-number)))
11822 (gnus-set-global-variables)
11823 ;; Remove old bookmark, if one exists.
11824 (let ((old (assq article gnus-newsgroup-bookmarks)))
11827 (setq gnus-newsgroup-bookmarks
11828 (delq old gnus-newsgroup-bookmarks))
11829 (gnus-message 6 "Removed bookmark."))
11830 (gnus-message 6 "No bookmark in current article."))))
11832 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11833 (defun gnus-summary-mark-as-dormant (n)
11834 "Mark N articles forward as dormant.
11835 If N is negative, mark backward instead. The difference between N and
11836 the actual number of articles marked is returned."
11838 (gnus-set-global-variables)
11839 (gnus-summary-mark-forward n gnus-dormant-mark))
11841 (defun gnus-summary-set-process-mark (article)
11842 "Set the process mark on ARTICLE and update the summary line."
11843 (setq gnus-newsgroup-processable
11845 (delq article gnus-newsgroup-processable)))
11846 (when (gnus-summary-goto-subject article)
11847 (gnus-summary-show-thread)
11848 (gnus-summary-update-secondary-mark article)))
11850 (defun gnus-summary-remove-process-mark (article)
11851 "Remove the process mark from ARTICLE and update the summary line."
11852 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11853 (when (gnus-summary-goto-subject article)
11854 (gnus-summary-show-thread)
11855 (gnus-summary-update-secondary-mark article)))
11857 (defun gnus-summary-set-saved-mark (article)
11858 "Set the process mark on ARTICLE and update the summary line."
11859 (push article gnus-newsgroup-saved)
11860 (when (gnus-summary-goto-subject article)
11861 (gnus-summary-update-secondary-mark article)))
11863 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11864 "Mark N articles as read forwards.
11865 If N is negative, mark backwards instead.
11866 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11868 The difference between N and the actual number of articles marked is
11871 (gnus-set-global-variables)
11872 (let ((backward (< n 0))
11873 (gnus-summary-goto-unread
11874 (and gnus-summary-goto-unread
11875 (not (eq gnus-summary-goto-unread 'never))
11876 (not (memq mark (list gnus-unread-mark
11877 gnus-ticked-mark gnus-dormant-mark)))))
11879 (mark (or mark gnus-del-mark)))
11880 (while (and (> n 0)
11881 (gnus-summary-mark-article nil mark no-expire)
11882 (zerop (gnus-summary-next-subject
11884 (and gnus-summary-goto-unread
11885 (not (eq gnus-summary-goto-unread 'never)))
11888 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11889 (gnus-summary-recenter)
11890 (gnus-summary-position-point)
11891 (gnus-set-mode-line 'summary)
11894 (defun gnus-summary-mark-article-as-read (mark)
11895 "Mark the current article quickly as read with MARK."
11896 (let ((article (gnus-summary-article-number)))
11897 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11898 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11899 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11900 (setq gnus-newsgroup-reads
11901 (cons (cons article mark) gnus-newsgroup-reads))
11902 ;; Possibly remove from cache, if that is used.
11903 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11904 ;; Allow the backend to change the mark.
11905 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11906 ;; Check for auto-expiry.
11907 (when (and gnus-newsgroup-auto-expire
11908 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11909 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11910 (= mark gnus-ancient-mark)
11911 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11912 (setq mark gnus-expirable-mark)
11913 (push article gnus-newsgroup-expirable))
11914 ;; Set the mark in the buffer.
11915 (gnus-summary-update-mark mark 'unread)
11918 (defun gnus-summary-mark-article-as-unread (mark)
11919 "Mark the current article quickly as unread with MARK."
11920 (let ((article (gnus-summary-article-number)))
11921 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11922 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11923 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11924 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11925 (cond ((= mark gnus-ticked-mark)
11926 (push article gnus-newsgroup-marked))
11927 ((= mark gnus-dormant-mark)
11928 (push article gnus-newsgroup-dormant))
11930 (push article gnus-newsgroup-unreads)))
11931 (setq gnus-newsgroup-reads
11932 (delq (assq article gnus-newsgroup-reads)
11933 gnus-newsgroup-reads))
11935 ;; See whether the article is to be put in the cache.
11936 (and gnus-use-cache
11937 (vectorp (gnus-summary-article-header article))
11939 (gnus-cache-possibly-enter-article
11940 gnus-newsgroup-name article
11941 (gnus-summary-article-header article)
11942 (= mark gnus-ticked-mark)
11943 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11946 (gnus-summary-update-mark mark 'unread)
11949 (defun gnus-summary-mark-article (&optional article mark no-expire)
11950 "Mark ARTICLE with MARK. MARK can be any character.
11951 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11952 `??' (dormant) and `?E' (expirable).
11953 If MARK is nil, then the default character `?D' is used.
11954 If ARTICLE is nil, then the article on the current line will be
11956 ;; The mark might be a string.
11957 (and (stringp mark)
11958 (setq mark (aref mark 0)))
11959 ;; If no mark is given, then we check auto-expiring.
11960 (and (not no-expire)
11961 gnus-newsgroup-auto-expire
11963 (and (numberp mark)
11964 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11965 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11966 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11967 (setq mark gnus-expirable-mark))
11968 (let* ((mark (or mark gnus-del-mark))
11969 (article (or article (gnus-summary-article-number))))
11970 (or article (error "No article on current line"))
11971 (if (or (= mark gnus-unread-mark)
11972 (= mark gnus-ticked-mark)
11973 (= mark gnus-dormant-mark))
11974 (gnus-mark-article-as-unread article mark)
11975 (gnus-mark-article-as-read article mark))
11977 ;; See whether the article is to be put in the cache.
11978 (and gnus-use-cache
11979 (not (= mark gnus-canceled-mark))
11980 (vectorp (gnus-summary-article-header article))
11982 (gnus-cache-possibly-enter-article
11983 gnus-newsgroup-name article
11984 (gnus-summary-article-header article)
11985 (= mark gnus-ticked-mark)
11986 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11988 (if (gnus-summary-goto-subject article nil t)
11989 (let ((buffer-read-only nil))
11990 (gnus-summary-show-thread)
11992 (gnus-summary-update-mark mark 'unread)
11995 (defun gnus-summary-update-secondary-mark (article)
11996 "Update the secondary (read, process, cache) mark."
11997 (gnus-summary-update-mark
11998 (cond ((memq article gnus-newsgroup-processable)
12000 ((memq article gnus-newsgroup-cached)
12002 ((memq article gnus-newsgroup-replied)
12004 ((memq article gnus-newsgroup-saved)
12006 (t gnus-unread-mark))
12008 (when (gnus-visual-p 'summary-highlight 'highlight)
12009 (run-hooks 'gnus-summary-update-hook))
12012 (defun gnus-summary-update-mark (mark type)
12013 (beginning-of-line)
12014 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12015 (buffer-read-only nil))
12017 (<= (+ forward (point)) (point-max)))
12018 ;; Go to the right position on the line.
12019 (goto-char (+ forward (point)))
12020 ;; Replace the old mark with the new mark.
12021 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12022 ;; Optionally update the marks by some user rule.
12023 (when (eq type 'unread)
12024 (gnus-data-set-mark
12025 (gnus-data-find (gnus-summary-article-number)) mark)
12026 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12028 (defun gnus-mark-article-as-read (article &optional mark)
12029 "Enter ARTICLE in the pertinent lists and remove it from others."
12030 ;; Make the article expirable.
12031 (let ((mark (or mark gnus-del-mark)))
12032 (if (= mark gnus-expirable-mark)
12033 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12034 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12035 ;; Remove from unread and marked lists.
12036 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12037 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12038 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12039 (push (cons article mark) gnus-newsgroup-reads)
12040 ;; Possibly remove from cache, if that is used.
12041 (when gnus-use-cache
12042 (gnus-cache-enter-remove-article article))))
12044 (defun gnus-mark-article-as-unread (article &optional mark)
12045 "Enter ARTICLE in the pertinent lists and remove it from others."
12046 (let ((mark (or mark gnus-ticked-mark)))
12047 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12048 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12049 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12050 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12051 (cond ((= mark gnus-ticked-mark)
12052 (push article gnus-newsgroup-marked))
12053 ((= mark gnus-dormant-mark)
12054 (push article gnus-newsgroup-dormant))
12056 (push article gnus-newsgroup-unreads)))
12057 (setq gnus-newsgroup-reads
12058 (delq (assq article gnus-newsgroup-reads)
12059 gnus-newsgroup-reads))))
12061 (defalias 'gnus-summary-mark-as-unread-forward
12062 'gnus-summary-tick-article-forward)
12063 (make-obsolete 'gnus-summary-mark-as-unread-forward
12064 'gnus-summary-tick-article-forward)
12065 (defun gnus-summary-tick-article-forward (n)
12066 "Tick N articles forwards.
12067 If N is negative, tick backwards instead.
12068 The difference between N and the number of articles ticked is returned."
12070 (gnus-summary-mark-forward n gnus-ticked-mark))
12072 (defalias 'gnus-summary-mark-as-unread-backward
12073 'gnus-summary-tick-article-backward)
12074 (make-obsolete 'gnus-summary-mark-as-unread-backward
12075 'gnus-summary-tick-article-backward)
12076 (defun gnus-summary-tick-article-backward (n)
12077 "Tick N articles backwards.
12078 The difference between N and the number of articles ticked is returned."
12080 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12082 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12083 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12084 (defun gnus-summary-tick-article (&optional article clear-mark)
12085 "Mark current article as unread.
12086 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12087 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12089 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12090 gnus-ticked-mark)))
12092 (defun gnus-summary-mark-as-read-forward (n)
12093 "Mark N articles as read forwards.
12094 If N is negative, mark backwards instead.
12095 The difference between N and the actual number of articles marked is
12098 (gnus-summary-mark-forward n gnus-del-mark t))
12100 (defun gnus-summary-mark-as-read-backward (n)
12101 "Mark the N articles as read backwards.
12102 The difference between N and the actual number of articles marked is
12105 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12107 (defun gnus-summary-mark-as-read (&optional article mark)
12108 "Mark current article as read.
12109 ARTICLE specifies the article to be marked as read.
12110 MARK specifies a string to be inserted at the beginning of the line."
12111 (gnus-summary-mark-article article mark))
12113 (defun gnus-summary-clear-mark-forward (n)
12114 "Clear marks from N articles forward.
12115 If N is negative, clear backward instead.
12116 The difference between N and the number of marks cleared is returned."
12118 (gnus-summary-mark-forward n gnus-unread-mark))
12120 (defun gnus-summary-clear-mark-backward (n)
12121 "Clear marks from N articles backward.
12122 The difference between N and the number of marks cleared is returned."
12124 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12126 (defun gnus-summary-mark-unread-as-read ()
12127 "Intended to be used by `gnus-summary-mark-article-hook'."
12128 (when (memq gnus-current-article gnus-newsgroup-unreads)
12129 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12131 (defun gnus-summary-mark-read-and-unread-as-read ()
12132 "Intended to be used by `gnus-summary-mark-article-hook'."
12133 (let ((mark (gnus-summary-article-mark)))
12134 (when (or (gnus-unread-mark-p mark)
12135 (gnus-read-mark-p mark))
12136 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12138 (defun gnus-summary-mark-region-as-read (point mark all)
12139 "Mark all unread articles between point and mark as read.
12140 If given a prefix, mark all articles between point and mark as read,
12141 even ticked and dormant ones."
12142 (interactive "r\nP")
12146 (beginning-of-line)
12151 (memq (setq article (gnus-summary-article-number))
12152 gnus-newsgroup-unreads))
12153 (gnus-summary-mark-article article gnus-del-mark))
12155 (gnus-summary-find-next))))))
12157 (defun gnus-summary-mark-below (score mark)
12158 "Mark articles with score less than SCORE with MARK."
12159 (interactive "P\ncMark: ")
12160 (gnus-set-global-variables)
12161 (setq score (if score
12162 (prefix-numeric-value score)
12163 (or gnus-summary-default-score 0)))
12165 (set-buffer gnus-summary-buffer)
12166 (goto-char (point-min))
12169 (and (< (gnus-summary-article-score) score)
12170 (gnus-summary-mark-article nil mark))
12171 (gnus-summary-find-next)))))
12173 (defun gnus-summary-kill-below (&optional score)
12174 "Mark articles with score below SCORE as read."
12176 (gnus-set-global-variables)
12177 (gnus-summary-mark-below score gnus-killed-mark))
12179 (defun gnus-summary-clear-above (&optional score)
12180 "Clear all marks from articles with score above SCORE."
12182 (gnus-set-global-variables)
12183 (gnus-summary-mark-above score gnus-unread-mark))
12185 (defun gnus-summary-tick-above (&optional score)
12186 "Tick all articles with score above SCORE."
12188 (gnus-set-global-variables)
12189 (gnus-summary-mark-above score gnus-ticked-mark))
12191 (defun gnus-summary-mark-above (score mark)
12192 "Mark articles with score over SCORE with MARK."
12193 (interactive "P\ncMark: ")
12194 (gnus-set-global-variables)
12195 (setq score (if score
12196 (prefix-numeric-value score)
12197 (or gnus-summary-default-score 0)))
12199 (set-buffer gnus-summary-buffer)
12200 (goto-char (point-min))
12202 (if (> (gnus-summary-article-score) score)
12203 (gnus-summary-mark-article nil mark))
12205 (gnus-summary-find-next)))))
12207 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12208 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12209 (defun gnus-summary-limit-include-expunged ()
12210 "Display all the hidden articles that were expunged for low scores."
12212 (gnus-set-global-variables)
12213 (let ((buffer-read-only nil))
12214 (let ((scored gnus-newsgroup-scored)
12217 (or (gnus-summary-goto-subject (caar scored))
12218 (and (setq h (gnus-summary-article-header (caar scored)))
12219 (< (cdar scored) gnus-summary-expunge-below)
12220 (setq headers (cons h headers))))
12221 (setq scored (cdr scored)))
12222 (or headers (error "No expunged articles hidden."))
12223 (goto-char (point-min))
12224 (gnus-summary-prepare-unthreaded (nreverse headers)))
12225 (goto-char (point-min))
12226 (gnus-summary-position-point)))
12228 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12229 "Mark all articles not marked as unread in this newsgroup as read.
12230 If prefix argument ALL is non-nil, all articles are marked as read.
12231 If QUIETLY is non-nil, no questions will be asked.
12232 If TO-HERE is non-nil, it should be a point in the buffer. All
12233 articles before this point will be marked as read.
12234 The number of articles marked as read is returned."
12236 (gnus-set-global-variables)
12239 (not gnus-interactive-catchup) ;Without confirmation?
12243 "Mark absolutely all articles as read? "
12244 "Mark all unread articles as read? ")))
12246 (not gnus-newsgroup-adaptive)
12247 (not gnus-newsgroup-auto-expire))
12250 (setq gnus-newsgroup-marked nil
12251 gnus-newsgroup-dormant nil))
12252 (setq gnus-newsgroup-unreads nil))
12253 ;; We actually mark all articles as canceled, which we
12254 ;; have to do when using auto-expiry or adaptive scoring.
12255 (gnus-summary-show-all-threads)
12256 (if (gnus-summary-first-subject (not all))
12258 (if to-here (< (point) to-here) t)
12259 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12260 (gnus-summary-find-next (not all)))))
12262 (setq gnus-newsgroup-unreads nil))
12263 (gnus-set-mode-line 'summary)))
12264 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12265 (if (and (not to-here) (eq 'nnvirtual (car method)))
12266 (nnvirtual-catchup-group
12267 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12268 (gnus-summary-position-point)))
12270 (defun gnus-summary-catchup-to-here (&optional all)
12271 "Mark all unticked articles before the current one as read.
12272 If ALL is non-nil, also mark ticked and dormant articles as read."
12274 (gnus-set-global-variables)
12276 (let ((beg (point)))
12277 ;; We check that there are unread articles.
12278 (when (or all (gnus-summary-find-prev))
12279 (gnus-summary-catchup all t beg))))
12280 (gnus-summary-position-point))
12282 (defun gnus-summary-catchup-all (&optional quietly)
12283 "Mark all articles in this newsgroup as read."
12285 (gnus-set-global-variables)
12286 (gnus-summary-catchup t quietly))
12288 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12289 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12290 If prefix argument ALL is non-nil, all articles are marked as read."
12292 (gnus-set-global-variables)
12293 (gnus-summary-catchup all quietly nil 'fast)
12294 ;; Select next newsgroup or exit.
12295 (if (eq gnus-auto-select-next 'quietly)
12296 (gnus-summary-next-group nil)
12297 (gnus-summary-exit)))
12299 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12300 "Mark all articles in this newsgroup as read, and then exit."
12302 (gnus-set-global-variables)
12303 (gnus-summary-catchup-and-exit t quietly))
12305 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12306 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12307 "Mark all articles in this group as read and select the next group.
12308 If given a prefix, mark all articles, unread as well as ticked, as
12311 (gnus-set-global-variables)
12313 (gnus-summary-catchup all))
12314 (gnus-summary-next-article t nil nil t))
12316 ;; Thread-based commands.
12318 (defun gnus-summary-articles-in-thread (&optional article)
12319 "Return a list of all articles in the current thread.
12320 If ARTICLE is non-nil, return all articles in the thread that starts
12321 with that article."
12322 (let* ((article (or article (gnus-summary-article-number)))
12323 (data (gnus-data-find-list article))
12324 (top-level (gnus-data-level (car data)))
12326 (cond ((null gnus-thread-operation-ignore-subject)
12327 (gnus-simplify-subject-re
12328 (mail-header-subject (gnus-data-header (car data)))))
12329 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12330 (gnus-simplify-subject-fuzzy
12331 (mail-header-subject (gnus-data-header (car data)))))
12333 (end-point (save-excursion
12334 (gnus-summary-go-to-next-thread) (point)))
12337 (< (gnus-data-pos (car data)) end-point))
12338 (and (or (not top-subject)
12339 (string= top-subject
12340 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12341 (gnus-simplify-subject-fuzzy
12342 (mail-header-subject
12343 (gnus-data-header (car data))))
12344 (gnus-simplify-subject-re
12345 (mail-header-subject
12346 (gnus-data-header (car data)))))))
12347 (setq articles (cons (gnus-data-number (car data)) articles)))
12348 (unless (and (setq data (cdr data))
12349 (> (gnus-data-level (car data)) top-level))
12351 ;; Return the list of articles.
12352 (nreverse articles)))
12354 (defun gnus-summary-rethread-current ()
12355 "Rethread the thread the current article is part of."
12357 (gnus-set-global-variables)
12358 (let* ((gnus-show-threads t)
12359 (article (gnus-summary-article-number))
12360 (id (mail-header-id (gnus-summary-article-header)))
12361 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12363 (error "No article on the current line"))
12364 (gnus-rebuild-thread id)
12365 (gnus-summary-goto-subject article)))
12367 (defun gnus-summary-reparent-thread ()
12368 "Make current article child of the marked (or previous) article.
12370 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12371 is non-nil or the Subject: of both articles are the same."
12373 (or (not (gnus-group-read-only-p))
12374 (error "The current newsgroup does not support article editing."))
12375 (or (<= (length gnus-newsgroup-processable) 1)
12376 (error "No more than one article may be marked."))
12377 (save-window-excursion
12378 (let ((gnus-article-buffer " *reparent*")
12379 (current-article (gnus-summary-article-number))
12380 ; first grab the marked article, otherwise one line up.
12381 (parent-article (if (not (null gnus-newsgroup-processable))
12382 (car gnus-newsgroup-processable)
12384 (if (eq (forward-line -1) 0)
12385 (gnus-summary-article-number)
12386 (error "Beginning of summary buffer."))))))
12387 (or (not (eq current-article parent-article))
12388 (error "An article may not be self-referential."))
12389 (let ((message-id (mail-header-id
12390 (gnus-summary-article-header parent-article))))
12391 (or (and message-id (not (equal message-id "")))
12392 (error "No message-id in desired parent."))
12393 (gnus-summary-select-article t t nil current-article)
12394 (set-buffer gnus-article-buffer)
12395 (setq buffer-read-only nil)
12396 (let ((buf (format "%s" (buffer-string))))
12399 (goto-char (point-min))
12400 (if (search-forward-regexp "^References: " nil t)
12401 (insert message-id " " )
12402 (insert "References: " message-id "\n"))
12403 (or (gnus-request-replace-article current-article
12404 (car gnus-article-current)
12405 gnus-article-buffer)
12406 (error "Couldn't replace article."))
12407 (set-buffer gnus-summary-buffer)
12408 (gnus-summary-unmark-all-processable)
12409 (gnus-summary-rethread-current)
12410 (gnus-message 3 "Article %d is now the child of article %d."
12411 current-article parent-article)))))
12413 (defun gnus-summary-toggle-threads (&optional arg)
12414 "Toggle showing conversation threads.
12415 If ARG is positive number, turn showing conversation threads on."
12417 (gnus-set-global-variables)
12418 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12419 (setq gnus-show-threads
12420 (if (null arg) (not gnus-show-threads)
12421 (> (prefix-numeric-value arg) 0)))
12422 (gnus-summary-prepare)
12423 (gnus-summary-goto-subject current)
12424 (gnus-summary-position-point)))
12426 (defun gnus-summary-show-all-threads ()
12427 "Show all threads."
12429 (gnus-set-global-variables)
12431 (let ((buffer-read-only nil))
12432 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12433 (gnus-summary-position-point))
12435 (defun gnus-summary-show-thread ()
12436 "Show thread subtrees.
12437 Returns nil if no thread was there to be shown."
12439 (gnus-set-global-variables)
12440 (let ((buffer-read-only nil)
12442 ;; first goto end then to beg, to have point at beg after let
12443 (end (progn (end-of-line) (point)))
12444 (beg (progn (beginning-of-line) (point))))
12446 ;; Any hidden lines here?
12447 (search-forward "\r" end t)
12448 (subst-char-in-region beg end ?\^M ?\n t)
12450 (gnus-summary-position-point))))
12452 (defun gnus-summary-hide-all-threads ()
12453 "Hide all thread subtrees."
12455 (gnus-set-global-variables)
12457 (goto-char (point-min))
12458 (gnus-summary-hide-thread)
12459 (while (zerop (gnus-summary-next-thread 1 t))
12460 (gnus-summary-hide-thread)))
12461 (gnus-summary-position-point))
12463 (defun gnus-summary-hide-thread ()
12464 "Hide thread subtrees.
12465 Returns nil if no threads were there to be hidden."
12467 (gnus-set-global-variables)
12468 (let ((buffer-read-only nil)
12470 (article (gnus-summary-article-number)))
12472 ;; Go forward until either the buffer ends or the subthread
12474 (when (and (not (eobp))
12475 (or (zerop (gnus-summary-next-thread 1 t))
12476 (goto-char (point-max))))
12478 (if (and (> (point) start)
12479 (search-backward "\n" start t))
12481 (subst-char-in-region start (point) ?\n ?\^M)
12482 (gnus-summary-goto-subject article))
12485 ;;(gnus-summary-position-point)
12488 (defun gnus-summary-go-to-next-thread (&optional previous)
12489 "Go to the same level (or less) next thread.
12490 If PREVIOUS is non-nil, go to previous thread instead.
12491 Return the article number moved to, or nil if moving was impossible."
12492 (let ((level (gnus-summary-thread-level))
12493 (way (if previous -1 1))
12496 (while (and (not (eobp))
12497 (< level (gnus-summary-thread-level)))
12498 (forward-line way))
12505 (gnus-summary-article-number)
12506 (goto-char beg)))))
12508 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12509 "Go to the same level (or less) next thread.
12510 If PREVIOUS is non-nil, go to previous thread instead.
12511 Return the article number moved to, or nil if moving was impossible."
12512 (if (and (eq gnus-summary-make-false-root 'dummy)
12513 (gnus-summary-article-intangible-p))
12514 (let ((beg (point)))
12515 (while (and (zerop (forward-line 1))
12516 (not (gnus-summary-article-intangible-p))
12517 (not (zerop (save-excursion
12518 (gnus-summary-thread-level))))))
12524 (let* ((level (gnus-summary-thread-level))
12525 (article (gnus-summary-article-number))
12526 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12529 (if (<= (gnus-data-level (car data)) level)
12530 (setq oart (gnus-data-number (car data))
12532 (setq data (cdr data))))
12534 (gnus-summary-goto-subject oart)))))
12536 (defun gnus-summary-next-thread (n &optional silent)
12537 "Go to the same level next N'th thread.
12538 If N is negative, search backward instead.
12539 Returns the difference between N and the number of skips actually
12542 If SILENT, don't output messages."
12544 (gnus-set-global-variables)
12545 (let ((backward (< n 0))
12548 (while (and (> n 0)
12549 (gnus-summary-go-to-next-thread backward))
12552 (gnus-summary-position-point))
12553 (when (and (not silent) (/= 0 n))
12554 (gnus-message 7 "No more threads"))
12557 (defun gnus-summary-prev-thread (n)
12558 "Go to the same level previous N'th thread.
12559 Returns the difference between N and the number of skips actually
12562 (gnus-set-global-variables)
12563 (gnus-summary-next-thread (- n)))
12565 (defun gnus-summary-go-down-thread ()
12566 "Go down one level in the current thread."
12567 (let ((children (gnus-summary-article-children)))
12569 (gnus-summary-goto-subject (car children)))))
12571 (defun gnus-summary-go-up-thread ()
12572 "Go up one level in the current thread."
12573 (let ((parent (gnus-summary-article-parent)))
12575 (gnus-summary-goto-subject parent))))
12577 (defun gnus-summary-down-thread (n)
12578 "Go down thread N steps.
12579 If N is negative, go up instead.
12580 Returns the difference between N and how many steps down that were
12583 (gnus-set-global-variables)
12586 (while (and (> n 0)
12587 (if up (gnus-summary-go-up-thread)
12588 (gnus-summary-go-down-thread)))
12590 (gnus-summary-position-point)
12591 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12594 (defun gnus-summary-up-thread (n)
12595 "Go up thread N steps.
12596 If N is negative, go up instead.
12597 Returns the difference between N and how many steps down that were
12600 (gnus-set-global-variables)
12601 (gnus-summary-down-thread (- n)))
12603 (defun gnus-summary-top-thread ()
12604 "Go to the top of the thread."
12606 (gnus-set-global-variables)
12607 (while (gnus-summary-go-up-thread))
12608 (gnus-summary-article-number))
12610 (defun gnus-summary-kill-thread (&optional unmark)
12611 "Mark articles under current thread as read.
12612 If the prefix argument is positive, remove any kinds of marks.
12613 If the prefix argument is negative, tick articles instead."
12615 (gnus-set-global-variables)
12617 (setq unmark (prefix-numeric-value unmark)))
12618 (let ((articles (gnus-summary-articles-in-thread)))
12620 ;; Expand the thread.
12621 (gnus-summary-show-thread)
12622 ;; Mark all the articles.
12624 (gnus-summary-goto-subject (car articles))
12625 (cond ((null unmark)
12626 (gnus-summary-mark-article-as-read gnus-killed-mark))
12628 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12630 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12631 (setq articles (cdr articles))))
12632 ;; Hide killed subtrees.
12634 gnus-thread-hide-killed
12635 (gnus-summary-hide-thread))
12636 ;; If marked as read, go to next unread subject.
12638 ;; Go to next unread subject.
12639 (gnus-summary-next-subject 1 t)))
12640 (gnus-set-mode-line 'summary))
12642 ;; Summary sorting commands
12644 (defun gnus-summary-sort-by-number (&optional reverse)
12645 "Sort summary buffer by article number.
12646 Argument REVERSE means reverse order."
12648 (gnus-summary-sort 'number reverse))
12650 (defun gnus-summary-sort-by-author (&optional reverse)
12651 "Sort summary buffer by author name alphabetically.
12652 If case-fold-search is non-nil, case of letters is ignored.
12653 Argument REVERSE means reverse order."
12655 (gnus-summary-sort 'author reverse))
12657 (defun gnus-summary-sort-by-subject (&optional reverse)
12658 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12659 If case-fold-search is non-nil, case of letters is ignored.
12660 Argument REVERSE means reverse order."
12662 (gnus-summary-sort 'subject reverse))
12664 (defun gnus-summary-sort-by-date (&optional reverse)
12665 "Sort summary buffer by date.
12666 Argument REVERSE means reverse order."
12668 (gnus-summary-sort 'date reverse))
12670 (defun gnus-summary-sort-by-score (&optional reverse)
12671 "Sort summary buffer by score.
12672 Argument REVERSE means reverse order."
12674 (gnus-summary-sort 'score reverse))
12676 (defun gnus-summary-sort (predicate reverse)
12677 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12678 (gnus-set-global-variables)
12679 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12680 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12681 (gnus-thread-sort-functions
12686 (,thread t2 t1)))))
12687 (gnus-article-sort-functions
12692 (,article t2 t1)))))
12694 (gnus-summary-prepare-hook nil))
12695 ;; We do the sorting by regenerating the threads.
12696 (gnus-summary-prepare)
12697 ;; Hide subthreads if needed.
12698 (when (and gnus-show-threads gnus-thread-hide-subtree)
12699 (gnus-summary-hide-all-threads)))
12700 ;; If in async mode, we send some info to the backend.
12701 (when gnus-newsgroup-async
12702 (gnus-request-asynchronous
12703 gnus-newsgroup-name gnus-newsgroup-data)))
12705 (defun gnus-sortable-date (date)
12706 "Make sortable string by string-lessp from DATE.
12707 Timezone package is used."
12708 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12709 (year (aref date 0))
12710 (month (aref date 1))
12711 (day (aref date 2)))
12712 (timezone-make-sortable-date
12714 (timezone-make-time-string
12715 (aref date 3) (aref date 4) (aref date 5)))))
12717 ;; Summary saving commands.
12719 (defun gnus-summary-save-article (&optional n not-saved)
12720 "Save the current article using the default saver function.
12721 If N is a positive number, save the N next articles.
12722 If N is a negative number, save the N previous articles.
12723 If N is nil and any articles have been marked with the process mark,
12724 save those articles instead.
12725 The variable `gnus-default-article-saver' specifies the saver function."
12727 (gnus-set-global-variables)
12728 (let ((articles (gnus-summary-work-articles n))
12729 file header article)
12731 (setq header (gnus-summary-article-header
12732 (setq article (pop articles))))
12733 (if (not (vectorp header))
12734 ;; This is a pseudo-article.
12735 (if (assq 'name header)
12736 (gnus-copy-file (cdr (assq 'name header)))
12737 (gnus-message 1 "Article %d is unsaveable" article))
12738 ;; This is a real article.
12739 (save-window-excursion
12740 (gnus-summary-select-article t nil nil article))
12741 (unless gnus-save-all-headers
12742 ;; Remove headers accoring to `gnus-saved-headers'.
12743 (let ((gnus-visible-headers
12744 (or gnus-saved-headers gnus-visible-headers)))
12745 (gnus-article-hide-headers nil t)))
12746 ;; Remove any X-Gnus lines.
12748 (set-buffer gnus-article-buffer)
12750 (let ((buffer-read-only nil))
12751 (nnheader-narrow-to-headers)
12752 (while (re-search-forward "^X-Gnus" nil t)
12753 (gnus-delete-line)))))
12754 (save-window-excursion
12755 (if (not gnus-default-article-saver)
12756 (error "No default saver is defined.")
12757 (setq file (funcall
12758 gnus-default-article-saver
12760 ((not gnus-prompt-before-saving)
12762 ((eq gnus-prompt-before-saving 'always)
12765 (gnus-summary-remove-process-mark article)
12767 (gnus-summary-set-saved-mark article))))
12768 (gnus-summary-position-point)
12771 (defun gnus-summary-pipe-output (&optional arg)
12772 "Pipe the current article to a subprocess.
12773 If N is a positive number, pipe the N next articles.
12774 If N is a negative number, pipe the N previous articles.
12775 If N is nil and any articles have been marked with the process mark,
12776 pipe those articles instead."
12778 (gnus-set-global-variables)
12779 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12780 (gnus-summary-save-article arg t))
12781 (gnus-configure-windows 'pipe))
12783 (defun gnus-summary-save-article-mail (&optional arg)
12784 "Append the current article to an mail file.
12785 If N is a positive number, save the N next articles.
12786 If N is a negative number, save the N previous articles.
12787 If N is nil and any articles have been marked with the process mark,
12788 save those articles instead."
12790 (gnus-set-global-variables)
12791 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12792 (gnus-summary-save-article arg)))
12794 (defun gnus-summary-save-article-rmail (&optional arg)
12795 "Append the current article to an rmail file.
12796 If N is a positive number, save the N next articles.
12797 If N is a negative number, save the N previous articles.
12798 If N is nil and any articles have been marked with the process mark,
12799 save those articles instead."
12801 (gnus-set-global-variables)
12802 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12803 (gnus-summary-save-article arg)))
12805 (defun gnus-summary-save-article-file (&optional arg)
12806 "Append the current article to a file.
12807 If N is a positive number, save the N next articles.
12808 If N is a negative number, save the N previous articles.
12809 If N is nil and any articles have been marked with the process mark,
12810 save those articles instead."
12812 (gnus-set-global-variables)
12813 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12814 (gnus-summary-save-article arg)))
12816 (defun gnus-summary-save-article-body-file (&optional arg)
12817 "Append the current article body to a file.
12818 If N is a positive number, save the N next articles.
12819 If N is a negative number, save the N previous articles.
12820 If N is nil and any articles have been marked with the process mark,
12821 save those articles instead."
12823 (gnus-set-global-variables)
12824 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12825 (gnus-summary-save-article arg)))
12827 (defun gnus-get-split-value (methods)
12828 "Return a value based on the split METHODS."
12829 (let (split-name method result match)
12832 (set-buffer gnus-original-article-buffer)
12834 (nnheader-narrow-to-headers)
12836 (goto-char (point-min))
12837 (setq method (pop methods))
12838 (setq match (car method))
12841 ;; Regular expression.
12843 (re-search-forward match nil t)
12845 ((gnus-functionp match)
12849 (setq result (funcall match gnus-newsgroup-name))))
12854 (setq result (eval match)))))
12855 (setq split-name (append (cdr method) split-name))
12856 (cond ((stringp result)
12857 (push result split-name))
12859 (setq split-name (append result split-name)))))))))
12862 (defun gnus-read-move-group-name (prompt default articles prefix)
12863 "Read a group name."
12864 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12866 (format "Where do you want to %s %s? "
12868 (if (> (length articles) 1)
12869 (format "these %d articles" (length articles))
12877 (format "(default %s) " default)
12879 gnus-active-hashtb nil nil prefix))
12880 ((= 1 (length split-name))
12881 (completing-read prom gnus-active-hashtb
12882 nil nil (cons (car split-name) 0)))
12885 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12888 (if (or (string= to-newsgroup "")
12889 (string= to-newsgroup prefix))
12890 (setq to-newsgroup (or default "")))
12891 (or (gnus-active to-newsgroup)
12892 (gnus-activate-group to-newsgroup)
12893 (error "No such group: %s" to-newsgroup)))
12896 (defun gnus-read-save-file-name (prompt default-name)
12897 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12899 ;; Let the split methods have their say.
12901 ;; No split name was found.
12904 (concat prompt " (default "
12905 (file-name-nondirectory default-name) ") ")
12906 (file-name-directory default-name)
12908 ;; A single split name was found
12909 ((= 1 (length split-name))
12911 (concat prompt " (default " (car split-name) ") ")
12912 gnus-article-save-directory
12913 (concat gnus-article-save-directory (car split-name))))
12914 ;; A list of splits was found.
12916 (setq split-name (mapcar (lambda (el) (list el))
12917 (nreverse split-name)))
12918 (let ((result (completing-read
12919 (concat prompt " ") split-name nil nil)))
12920 (concat gnus-article-save-directory
12921 (if (string= result "")
12924 ;; If we have read a directory, we append the default file name.
12925 (when (file-directory-p file)
12926 (setq file (concat (file-name-as-directory file)
12927 (file-name-nondirectory default-name))))
12928 ;; Possibly translate some charaters.
12929 (nnheader-translate-file-chars file)))
12931 (defun gnus-article-archive-name (group)
12932 "Return the first instance of an \"Archive-name\" in the current buffer."
12933 (let ((case-fold-search t))
12934 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12935 (match-string 1))))
12937 (defun gnus-summary-save-in-rmail (&optional filename)
12938 "Append this article to Rmail file.
12939 Optional argument FILENAME specifies file name.
12940 Directory to save to is default to `gnus-article-save-directory' which
12941 is initialized from the SAVEDIR environment variable."
12943 (gnus-set-global-variables)
12944 (let ((default-name
12945 (funcall gnus-rmail-save-name gnus-newsgroup-name
12946 gnus-current-headers gnus-newsgroup-last-rmail)))
12948 (cond ((eq filename 'default)
12950 (filename filename)
12951 (t (gnus-read-save-file-name
12952 "Save in rmail file:" default-name))))
12953 (gnus-make-directory (file-name-directory filename))
12954 (gnus-eval-in-buffer-window
12955 gnus-original-article-buffer
12959 (gnus-output-to-rmail filename))))
12960 ;; Remember the directory name to save articles
12961 (setq gnus-newsgroup-last-rmail filename)))
12963 (defun gnus-summary-save-in-mail (&optional filename)
12964 "Append this article to Unix mail file.
12965 Optional argument FILENAME specifies file name.
12966 Directory to save to is default to `gnus-article-save-directory' which
12967 is initialized from the SAVEDIR environment variable."
12969 (gnus-set-global-variables)
12970 (let ((default-name
12971 (funcall gnus-mail-save-name gnus-newsgroup-name
12972 gnus-current-headers gnus-newsgroup-last-mail)))
12974 (cond ((eq filename 'default)
12976 (filename filename)
12977 (t (gnus-read-save-file-name
12978 "Save in Unix mail file:" default-name))))
12980 (expand-file-name filename
12982 (file-name-directory default-name))))
12983 (gnus-make-directory (file-name-directory filename))
12984 (gnus-eval-in-buffer-window
12985 gnus-original-article-buffer
12989 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12990 (gnus-output-to-rmail filename)
12991 (let ((mail-use-rfc822 t))
12992 (rmail-output filename 1 t t))))))
12993 ;; Remember the directory name to save articles.
12994 (setq gnus-newsgroup-last-mail filename)))
12996 (defun gnus-summary-save-in-file (&optional filename)
12997 "Append this article to file.
12998 Optional argument FILENAME specifies file name.
12999 Directory to save to is default to `gnus-article-save-directory' which
13000 is initialized from the SAVEDIR environment variable."
13002 (gnus-set-global-variables)
13003 (let ((default-name
13004 (funcall gnus-file-save-name gnus-newsgroup-name
13005 gnus-current-headers gnus-newsgroup-last-file)))
13007 (cond ((eq filename 'default)
13009 (filename filename)
13010 (t (gnus-read-save-file-name
13011 "Save in file:" default-name))))
13012 (gnus-make-directory (file-name-directory filename))
13013 (gnus-eval-in-buffer-window
13014 gnus-original-article-buffer
13018 (gnus-output-to-file filename))))
13019 ;; Remember the directory name to save articles.
13020 (setq gnus-newsgroup-last-file filename)))
13022 (defun gnus-summary-save-body-in-file (&optional filename)
13023 "Append this article body to a file.
13024 Optional argument FILENAME specifies file name.
13025 The directory to save in defaults to `gnus-article-save-directory' which
13026 is initialized from the SAVEDIR environment variable."
13028 (gnus-set-global-variables)
13029 (let ((default-name
13030 (funcall gnus-file-save-name gnus-newsgroup-name
13031 gnus-current-headers gnus-newsgroup-last-file)))
13033 (cond ((eq filename 'default)
13035 (filename filename)
13036 (t (gnus-read-save-file-name
13037 "Save body in file:" default-name))))
13038 (gnus-make-directory (file-name-directory filename))
13039 (gnus-eval-in-buffer-window
13040 gnus-article-buffer
13044 (goto-char (point-min))
13045 (and (search-forward "\n\n" nil t)
13046 (narrow-to-region (point) (point-max)))
13047 (gnus-output-to-file filename))))
13048 ;; Remember the directory name to save articles.
13049 (setq gnus-newsgroup-last-file filename)))
13051 (defun gnus-summary-save-in-pipe (&optional command)
13052 "Pipe this article to subprocess."
13054 (gnus-set-global-variables)
13056 (cond ((eq command 'default)
13057 gnus-last-shell-command)
13059 (t (read-string "Shell command on article: "
13060 gnus-last-shell-command))))
13061 (if (string-equal command "")
13062 (setq command gnus-last-shell-command))
13063 (gnus-eval-in-buffer-window
13064 gnus-article-buffer
13067 (shell-command-on-region (point-min) (point-max) command nil)))
13068 (setq gnus-last-shell-command command))
13070 ;; Summary extract commands
13072 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13073 (let ((buffer-read-only nil)
13074 (article (gnus-summary-article-number))
13076 (or (gnus-summary-goto-subject article)
13077 (error (format "No such article: %d" article)))
13078 (gnus-summary-position-point)
13079 ;; If all commands are to be bunched up on one line, we collect
13081 (if gnus-view-pseudos-separately
13083 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13086 (setq action (cdr (assq 'action (car ps))))
13087 (setq files (list (cdr (assq 'name (car ps)))))
13088 (while (and ps (cdr ps)
13089 (string= (or action "1")
13090 (or (cdr (assq 'action (cadr ps))) "2")))
13091 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13092 (setcdr ps (cddr ps)))
13095 (if (not (string-match "%s" action))
13096 (setq files (cons " " files)))
13097 (setq files (cons " " files))
13098 (and (assq 'execute (car ps))
13099 (setcdr (assq 'execute (car ps))
13100 (funcall (if (string-match "%s" action)
13103 (mapconcat (lambda (f) f) files " ")))))
13104 (setq ps (cdr ps)))))
13105 (if (and gnus-view-pseudos (not not-view))
13107 (and (assq 'execute (car pslist))
13108 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13109 (eq gnus-view-pseudos 'not-confirm)))
13110 (setq pslist (cdr pslist)))
13113 (setq after-article (or (cdr (assq 'article (car pslist)))
13114 (gnus-summary-article-number)))
13115 (gnus-summary-goto-subject after-article)
13118 (insert " " (file-name-nondirectory
13119 (cdr (assq 'name (car pslist))))
13120 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13122 (forward-line -1) ; back to `b'
13123 (add-text-properties
13124 b e (list 'gnus-number gnus-reffed-article-number
13125 gnus-mouse-face-prop gnus-mouse-face))
13127 after-article gnus-reffed-article-number
13128 gnus-unread-mark b (car pslist) 0 (- e b))
13129 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13130 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13131 (setq pslist (cdr pslist)))))))
13133 (defun gnus-pseudos< (p1 p2)
13134 (let ((c1 (cdr (assq 'action p1)))
13135 (c2 (cdr (assq 'action p2))))
13136 (and c1 c2 (string< c1 c2))))
13138 (defun gnus-request-pseudo-article (props)
13139 (cond ((assq 'execute props)
13140 (gnus-execute-command (cdr (assq 'execute props)))))
13141 (let ((gnus-current-article (gnus-summary-article-number)))
13142 (run-hooks 'gnus-mark-article-hook)))
13144 (defun gnus-execute-command (command &optional automatic)
13146 (gnus-article-setup-buffer)
13147 (set-buffer gnus-article-buffer)
13148 (let ((command (if automatic command (read-string "Command: " command)))
13149 (buffer-read-only nil))
13151 (insert "$ " command "\n\n")
13152 (if gnus-view-pseudo-asynchronously
13153 (start-process "gnus-execute" nil "sh" "-c" command)
13154 (call-process "sh" nil t nil "-c" command)))))
13156 (defun gnus-copy-file (file &optional to)
13159 (list (read-file-name "Copy file: " default-directory)
13160 (read-file-name "Copy file to: " default-directory)))
13161 (gnus-set-global-variables)
13162 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13163 (and (file-directory-p to)
13164 (setq to (concat (file-name-as-directory to)
13165 (file-name-nondirectory file))))
13166 (copy-file file to))
13168 ;; Summary kill commands.
13170 (defun gnus-summary-edit-global-kill (article)
13171 "Edit the \"global\" kill file."
13172 (interactive (list (gnus-summary-article-number)))
13173 (gnus-set-global-variables)
13174 (gnus-group-edit-global-kill article))
13176 (defun gnus-summary-edit-local-kill ()
13177 "Edit a local kill file applied to the current newsgroup."
13179 (gnus-set-global-variables)
13180 (setq gnus-current-headers (gnus-summary-article-header))
13181 (gnus-set-global-variables)
13182 (gnus-group-edit-local-kill
13183 (gnus-summary-article-number) gnus-newsgroup-name))
13187 ;;; Gnus article mode
13190 (put 'gnus-article-mode 'mode-class 'special)
13192 (if gnus-article-mode-map
13194 (setq gnus-article-mode-map (make-keymap))
13195 (suppress-keymap gnus-article-mode-map)
13197 (gnus-define-keys gnus-article-mode-map
13198 " " gnus-article-goto-next-page
13199 "\177" gnus-article-goto-prev-page
13200 [delete] gnus-article-goto-prev-page
13201 "\C-c^" gnus-article-refer-article
13202 "h" gnus-article-show-summary
13203 "s" gnus-article-show-summary
13204 "\C-c\C-m" gnus-article-mail
13205 "?" gnus-article-describe-briefly
13206 gnus-mouse-2 gnus-article-push-button
13207 "\r" gnus-article-press-button
13208 "\t" gnus-article-next-button
13209 "\M-\t" gnus-article-prev-button
13210 "\C-c\C-b" gnus-bug)
13212 (substitute-key-definition
13213 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13215 (defun gnus-article-mode ()
13216 "Major mode for displaying an article.
13218 All normal editing commands are switched off.
13220 The following commands are available:
13222 \\<gnus-article-mode-map>
13223 \\[gnus-article-next-page]\t Scroll the article one page forwards
13224 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13225 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13226 \\[gnus-article-show-summary]\t Display the summary buffer
13227 \\[gnus-article-mail]\t Send a reply to the address near point
13228 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13229 \\[gnus-info-find-node]\t Go to the Gnus info node"
13231 (when (and menu-bar-mode
13232 (gnus-visual-p 'article-menu 'menu))
13233 (gnus-article-make-menu-bar))
13234 (kill-all-local-variables)
13235 (gnus-simplify-mode-line)
13236 (setq mode-name "Article")
13237 (setq major-mode 'gnus-article-mode)
13238 (make-local-variable 'minor-mode-alist)
13239 (or (assq 'gnus-show-mime minor-mode-alist)
13240 (setq minor-mode-alist
13241 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13242 (use-local-map gnus-article-mode-map)
13243 (make-local-variable 'page-delimiter)
13244 (setq page-delimiter gnus-page-delimiter)
13245 (buffer-disable-undo (current-buffer))
13246 (setq buffer-read-only t) ;Disable modification
13247 (run-hooks 'gnus-article-mode-hook))
13249 (defun gnus-article-setup-buffer ()
13250 "Initialize the article buffer."
13251 (let* ((name (if gnus-single-article-buffer "*Article*"
13252 (concat "*Article " gnus-newsgroup-name "*")))
13254 (progn (string-match "\\*Article" name)
13255 (concat " *Original Article"
13256 (substring name (match-end 0))))))
13257 (setq gnus-article-buffer name)
13258 (setq gnus-original-article-buffer original)
13259 ;; This might be a variable local to the summary buffer.
13260 (unless gnus-single-article-buffer
13262 (set-buffer gnus-summary-buffer)
13263 (setq gnus-article-buffer name)
13264 (setq gnus-original-article-buffer original)
13265 (gnus-set-global-variables))
13266 (make-local-variable 'gnus-summary-buffer))
13267 ;; Init original article buffer.
13269 (set-buffer (get-buffer-create gnus-original-article-buffer))
13270 (buffer-disable-undo (current-buffer))
13271 (setq major-mode 'gnus-original-article-mode)
13272 (make-local-variable 'gnus-original-article))
13273 (if (get-buffer name)
13276 (buffer-disable-undo (current-buffer))
13277 (setq buffer-read-only t)
13278 (gnus-add-current-to-buffer-list)
13279 (or (eq major-mode 'gnus-article-mode)
13280 (gnus-article-mode))
13283 (set-buffer (get-buffer-create name))
13284 (gnus-add-current-to-buffer-list)
13285 (gnus-article-mode)
13286 (current-buffer)))))
13288 ;; Set article window start at LINE, where LINE is the number of lines
13289 ;; from the head of the article.
13290 (defun gnus-article-set-window-start (&optional line)
13292 (get-buffer-window gnus-article-buffer)
13294 (set-buffer gnus-article-buffer)
13295 (goto-char (point-min))
13298 (gnus-message 6 "Moved to bookmark")
13299 (search-forward "\n\n" nil t)
13300 (forward-line line)
13303 (defun gnus-kill-all-overlays ()
13304 "Delete all overlays in the current buffer."
13305 (when (fboundp 'overlay-lists)
13306 (let* ((overlayss (overlay-lists))
13307 (buffer-read-only nil)
13308 (overlays (nconc (car overlayss) (cdr overlayss))))
13310 (delete-overlay (pop overlays))))))
13312 (defun gnus-request-article-this-buffer (article group)
13313 "Get an article and insert it into this buffer."
13314 (let (do-update-line)
13318 (gnus-kill-all-overlays)
13319 (setq group (or group gnus-newsgroup-name))
13321 ;; Open server if it has closed.
13322 (gnus-check-server (gnus-find-method-for-group group))
13324 ;; Using `gnus-request-article' directly will insert the article into
13325 ;; `nntp-server-buffer' - so we'll save some time by not having to
13326 ;; copy it from the server buffer into the article buffer.
13328 ;; We only request an article by message-id when we do not have the
13329 ;; headers for it, so we'll have to get those.
13330 (when (stringp article)
13331 (let ((gnus-override-method gnus-refer-article-method))
13332 (gnus-read-header article)))
13334 ;; If the article number is negative, that means that this article
13335 ;; doesn't belong in this newsgroup (possibly), so we find its
13336 ;; message-id and request it by id instead of number.
13337 (when (and (numberp article)
13338 gnus-summary-buffer
13339 (get-buffer gnus-summary-buffer)
13340 (buffer-name (get-buffer gnus-summary-buffer)))
13342 (set-buffer gnus-summary-buffer)
13343 (let ((header (gnus-summary-article-header article)))
13346 ((memq article gnus-newsgroup-sparse)
13347 ;; This is a sparse gap article.
13348 (setq do-update-line article)
13349 (setq article (mail-header-id header))
13350 (let ((gnus-override-method gnus-refer-article-method))
13351 (gnus-read-header article)))
13353 ;; It's a real article.
13354 (setq article (mail-header-id header)))
13356 ;; It is an extracted pseudo-article.
13357 (setq article 'pseudo)
13358 (gnus-request-pseudo-article header))))
13360 (let ((method (gnus-find-method-for-group
13361 gnus-newsgroup-name)))
13362 (if (not (eq (car method) 'nneething))
13364 (let ((dir (concat (file-name-as-directory (nth 1 method))
13365 (mail-header-subject header))))
13366 (if (file-directory-p dir)
13368 (setq article 'nneething)
13369 (gnus-group-enter-directory dir)))))))))
13372 ;; We first check `gnus-original-article-buffer'.
13373 ((and (get-buffer gnus-original-article-buffer)
13375 (set-buffer gnus-original-article-buffer)
13376 (and (equal (car gnus-original-article) group)
13377 (eq (cdr gnus-original-article) article))))
13378 (insert-buffer-substring gnus-original-article-buffer)
13380 ;; Check the backlog.
13381 ((and gnus-keep-backlog
13382 (gnus-backlog-request-article group article (current-buffer)))
13384 ;; Check the cache.
13385 ((and gnus-use-cache
13387 (gnus-cache-request-article article group))
13389 ;; Get the article and put into the article buffer.
13390 ((or (stringp article) (numberp article))
13391 (let ((gnus-override-method
13392 (and (stringp article) gnus-refer-article-method))
13393 (buffer-read-only nil))
13395 (gnus-kill-all-overlays)
13396 (if (gnus-request-article article group (current-buffer))
13398 (and gnus-keep-backlog
13400 (gnus-backlog-enter-article
13401 group article (current-buffer)))
13403 ;; It was a pseudo.
13406 ;; Take the article from the original article buffer
13407 ;; and place it in the buffer it's supposed to be in.
13408 (when (and (get-buffer gnus-article-buffer)
13409 (equal (buffer-name (current-buffer))
13410 (buffer-name (get-buffer gnus-article-buffer))))
13412 (if (get-buffer gnus-original-article-buffer)
13413 (set-buffer (get-buffer gnus-original-article-buffer))
13414 (set-buffer (get-buffer-create gnus-original-article-buffer))
13415 (buffer-disable-undo (current-buffer))
13416 (setq major-mode 'gnus-original-article-mode)
13417 (setq buffer-read-only t)
13418 (gnus-add-current-to-buffer-list))
13419 (let (buffer-read-only)
13421 (insert-buffer-substring gnus-article-buffer))
13422 (setq gnus-original-article (cons group article))))
13424 ;; Update sparse articles.
13425 (when do-update-line
13427 (set-buffer gnus-summary-buffer)
13428 (gnus-summary-update-article do-update-line)
13429 (gnus-summary-goto-subject do-update-line)
13430 (set-window-point (get-buffer-window (current-buffer) t)
13433 (defun gnus-read-header (id &optional header)
13434 "Read the headers of article ID and enter them into the Gnus system."
13435 (let ((group gnus-newsgroup-name)
13436 (gnus-override-method
13437 (and (gnus-news-group-p gnus-newsgroup-name)
13438 gnus-refer-article-method))
13440 ;; First we check to see whether the header in question is already
13443 ;; This is a Message-ID.
13444 (setq header (or header (gnus-id-to-header id)))
13445 ;; This is an article number.
13446 (setq header (or header (gnus-summary-article-header id))))
13448 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13449 ;; We have found the header.
13451 ;; We have to really fetch the header to this article.
13453 (if (gnus-check-backend-function 'request-head group)
13454 (gnus-request-head id group)
13455 (gnus-request-article id group)))
13457 (set-buffer nntp-server-buffer)
13458 (and (search-forward "\n\n" nil t)
13459 (delete-region (1- (point)) (point-max)))
13460 (goto-char (point-max))
13462 (goto-char (point-min))
13466 ((cdr where) (cdr where))
13467 (header (mail-header-number header))
13468 (t gnus-reffed-article-number))
13470 (insert " Article retrieved.\n"))
13472 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13473 ; (setcar (gnus-id-to-thread id) nil))
13474 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13475 () ; Malformed head.
13476 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13477 (if (and (stringp id)
13478 (not (string= (gnus-group-real-name group)
13480 ;; If we fetched by Message-ID and the article came
13481 ;; from a different group, we fudge some bogus article
13482 ;; numbers for this article.
13483 (mail-header-set-number header gnus-reffed-article-number))
13484 (decf gnus-reffed-article-number)
13485 (push header gnus-newsgroup-headers)
13486 (setq gnus-current-headers header)
13487 (push (mail-header-number header) gnus-newsgroup-limit))
13490 (defun gnus-article-prepare (article &optional all-headers header)
13491 "Prepare ARTICLE in article mode buffer.
13492 ARTICLE should either be an article number or a Message-ID.
13493 If ARTICLE is an id, HEADER should be the article headers.
13494 If ALL-HEADERS is non-nil, no headers are hidden."
13496 ;; Make sure we start in a summary buffer.
13497 (unless (eq major-mode 'gnus-summary-mode)
13498 (set-buffer gnus-summary-buffer))
13499 (setq gnus-summary-buffer (current-buffer))
13500 ;; Make sure the connection to the server is alive.
13501 (unless (gnus-server-opened
13502 (gnus-find-method-for-group gnus-newsgroup-name))
13503 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13504 (gnus-request-group gnus-newsgroup-name t))
13505 (let* ((article (if header (mail-header-number header) article))
13506 (summary-buffer (current-buffer))
13507 (internal-hook gnus-article-internal-prepare-hook)
13508 (group gnus-newsgroup-name)
13511 (gnus-article-setup-buffer)
13512 (set-buffer gnus-article-buffer)
13513 ;; Deactivate active regions.
13514 (when (and (boundp 'transient-mark-mode)
13515 transient-mark-mode)
13516 (setq mark-active nil))
13517 (if (not (setq result (let ((buffer-read-only nil))
13518 (gnus-request-article-this-buffer
13520 ;; There is no such article.
13522 (when (and (numberp article)
13523 (not (memq article gnus-newsgroup-sparse)))
13524 (setq gnus-article-current
13525 (cons gnus-newsgroup-name article))
13526 (set-buffer gnus-summary-buffer)
13527 (setq gnus-current-article article)
13528 (gnus-summary-mark-article article gnus-canceled-mark))
13529 (unless (memq article gnus-newsgroup-sparse)
13531 1 "No such article (may have expired or been canceled)")))
13532 (if (or (eq result 'pseudo) (eq result 'nneething))
13535 (set-buffer summary-buffer)
13536 (setq gnus-last-article gnus-current-article
13537 gnus-newsgroup-history (cons gnus-current-article
13538 gnus-newsgroup-history)
13539 gnus-current-article 0
13540 gnus-current-headers nil
13541 gnus-article-current nil)
13542 (if (eq result 'nneething)
13543 (gnus-configure-windows 'summary)
13544 (gnus-configure-windows 'article))
13545 (gnus-set-global-variables))
13546 (gnus-set-mode-line 'article))
13547 ;; The result from the `request' was an actual article -
13548 ;; or at least some text that is now displayed in the
13550 (if (and (numberp article)
13551 (not (eq article gnus-current-article)))
13552 ;; Seems like a new article has been selected.
13553 ;; `gnus-current-article' must be an article number.
13555 (set-buffer summary-buffer)
13556 (setq gnus-last-article gnus-current-article
13557 gnus-newsgroup-history (cons gnus-current-article
13558 gnus-newsgroup-history)
13559 gnus-current-article article
13560 gnus-current-headers
13561 (gnus-summary-article-header gnus-current-article)
13562 gnus-article-current
13563 (cons gnus-newsgroup-name gnus-current-article))
13564 (unless (vectorp gnus-current-headers)
13565 (setq gnus-current-headers nil))
13566 (gnus-summary-show-thread)
13567 (run-hooks 'gnus-mark-article-hook)
13568 (gnus-set-mode-line 'summary)
13569 (and (gnus-visual-p 'article-highlight 'highlight)
13570 (run-hooks 'gnus-visual-mark-article-hook))
13571 ;; Set the global newsgroup variables here.
13572 ;; Suggested by Jim Sisolak
13573 ;; <sisolak@trans4.neep.wisc.edu>.
13574 (gnus-set-global-variables)
13575 (setq gnus-have-all-headers
13576 (or all-headers gnus-show-all-headers))
13577 (and gnus-use-cache
13578 (vectorp (gnus-summary-article-header article))
13579 (gnus-cache-possibly-enter-article
13581 (gnus-summary-article-header article)
13582 (memq article gnus-newsgroup-marked)
13583 (memq article gnus-newsgroup-dormant)
13584 (memq article gnus-newsgroup-unreads)))))
13585 ;; Hooks for getting information from the article.
13586 ;; This hook must be called before being narrowed.
13587 (let (buffer-read-only)
13588 (run-hooks 'internal-hook)
13589 (run-hooks 'gnus-article-prepare-hook)
13590 ;; Decode MIME message.
13592 (if (or (not gnus-strict-mime)
13593 (gnus-fetch-field "Mime-Version"))
13594 (funcall gnus-show-mime-method)
13595 (funcall gnus-decode-encoded-word-method)))
13596 ;; Perform the article display hooks.
13597 (run-hooks 'gnus-article-display-hook))
13599 (goto-char (point-min))
13600 (and gnus-break-pages (gnus-narrow-to-page))
13601 (gnus-set-mode-line 'article)
13602 (gnus-configure-windows 'article)
13603 (goto-char (point-min))
13606 (defun gnus-article-show-all-headers ()
13607 "Show all article headers in article mode buffer."
13609 (gnus-article-setup-buffer)
13610 (set-buffer gnus-article-buffer)
13611 (let ((buffer-read-only nil))
13612 (gnus-unhide-text (point-min) (point-max)))))
13614 (defun gnus-article-hide-headers-if-wanted ()
13615 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13616 Provided for backwards compatibility."
13617 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13618 gnus-inhibit-hiding
13619 (gnus-article-hide-headers)))
13621 (defsubst gnus-article-header-rank ()
13622 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13623 (let ((list gnus-sorted-header-list)
13626 (when (looking-at (car list))
13628 (setq list (cdr list))
13632 (defun gnus-article-hide-headers (&optional arg delete)
13633 "Toggle whether to hide unwanted headers and possibly sort them as well.
13634 If given a negative prefix, always show; if given a positive prefix,
13637 (unless (gnus-article-check-hidden-text 'headers arg)
13638 ;; This function might be inhibited.
13639 (unless gnus-inhibit-hiding
13641 (set-buffer gnus-article-buffer)
13643 (let ((buffer-read-only nil)
13644 (props (nconc (list 'gnus-type 'headers)
13645 gnus-hidden-properties))
13646 (max (1+ (length gnus-sorted-header-list)))
13647 (ignored (when (not (stringp gnus-visible-headers))
13648 (cond ((stringp gnus-ignored-headers)
13649 gnus-ignored-headers)
13650 ((listp gnus-ignored-headers)
13651 (mapconcat 'identity gnus-ignored-headers
13654 (cond ((stringp gnus-visible-headers)
13655 gnus-visible-headers)
13656 ((and gnus-visible-headers
13657 (listp gnus-visible-headers))
13658 (mapconcat 'identity gnus-visible-headers "\\|"))))
13660 ;; First we narrow to just the headers.
13662 (goto-char (point-min))
13663 ;; Hide any "From " lines at the beginning of (mail) articles.
13664 (while (looking-at "From ")
13667 (gnus-hide-text (point-min) (point) props))
13668 ;; Then treat the rest of the header lines.
13671 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13672 ;; Then we use the two regular expressions
13673 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13674 ;; select which header lines is to remain visible in the
13676 (goto-char (point-min))
13677 (while (re-search-forward "^[^ \t]*:" nil t)
13678 (beginning-of-line)
13679 ;; We add the headers we want to keep to a list and delete
13680 ;; them from the buffer.
13682 (point) (1+ (point)) 'message-rank
13683 (if (or (and visible (looking-at visible))
13685 (not (looking-at ignored))))
13686 (gnus-article-header-rank)
13689 (message-sort-headers-1)
13690 (when (setq beg (text-property-any
13691 (point-min) (point-max) 'message-rank (+ 2 max)))
13692 ;; We make the unwanted headers invisible.
13694 (delete-region beg (point-max))
13695 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13696 (gnus-hide-text-type beg (point-max) 'headers)))))))))
13698 (defun gnus-article-hide-boring-headers (&optional arg)
13699 "Toggle hiding of headers that aren't very interesting.
13700 If given a negative prefix, always show; if given a positive prefix,
13703 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13705 (set-buffer gnus-article-buffer)
13707 (let ((buffer-read-only nil)
13708 (list gnus-boring-article-headers)
13709 (inhibit-point-motion-hooks t)
13711 (nnheader-narrow-to-headers)
13713 (setq elem (pop list))
13714 (goto-char (point-min))
13716 ;; Hide empty headers.
13718 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13720 (gnus-hide-text-type
13721 (progn (beginning-of-line) (point))
13724 (if (re-search-forward "^[^ \t]" nil t)
13725 (match-beginning 0)
13728 ;; Hide boring Newsgroups header.
13729 ((eq elem 'newsgroups)
13730 (when (equal (mail-fetch-field "newsgroups")
13731 (gnus-group-real-name gnus-newsgroup-name))
13732 (gnus-article-hide-header "newsgroups")))
13733 ((eq elem 'followup-to)
13734 (when (equal (mail-fetch-field "followup-to")
13735 (mail-fetch-field "newsgroups"))
13736 (gnus-article-hide-header "followup-to")))
13737 ((eq elem 'reply-to)
13738 (let ((from (mail-fetch-field "from"))
13739 (reply-to (mail-fetch-field "reply-to")))
13743 (nth 1 (funcall gnus-extract-address-components from))
13744 (nth 1 (funcall gnus-extract-address-components
13746 (gnus-article-hide-header "reply-to"))))
13748 (let ((date (mail-fetch-field "date")))
13750 (< (gnus-days-between date (current-time-string))
13752 (gnus-article-hide-header "date")))))))))))
13754 (defun gnus-article-hide-header (header)
13756 (goto-char (point-min))
13757 (when (re-search-forward (concat "^" header ":") nil t)
13758 (gnus-hide-text-type
13759 (progn (beginning-of-line) (point))
13762 (if (re-search-forward "^[^ \t]" nil t)
13763 (match-beginning 0)
13765 'boring-headers))))
13767 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13768 (defun gnus-article-treat-overstrike ()
13769 "Translate overstrikes into bold text."
13772 (set-buffer gnus-article-buffer)
13773 (let ((buffer-read-only nil))
13774 (while (search-forward "\b" nil t)
13775 (let ((next (following-char))
13776 (previous (char-after (- (point) 2))))
13777 (cond ((eq next previous)
13778 (put-text-property (- (point) 2) (point) 'invisible t)
13779 (put-text-property (point) (1+ (point)) 'face 'bold))
13781 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13783 (- (point) 2) (1- (point)) 'face 'underline))
13785 (put-text-property (- (point) 2) (point) 'invisible t)
13787 (point) (1+ (point)) 'face 'underline))))))))
13789 (defun gnus-article-word-wrap ()
13790 "Format too long lines."
13793 (set-buffer gnus-article-buffer)
13794 (let ((buffer-read-only nil))
13796 (goto-char (point-min))
13797 (search-forward "\n\n" nil t)
13799 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13800 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13801 (adaptive-fill-mode t))
13802 (while (not (eobp))
13803 (and (>= (current-column) (min fill-column (window-width)))
13804 (/= (preceding-char) ?:)
13805 (fill-paragraph nil))
13806 (end-of-line 2))))))
13808 (defun gnus-article-remove-cr ()
13809 "Remove carriage returns from an article."
13812 (set-buffer gnus-article-buffer)
13813 (let ((buffer-read-only nil))
13814 (goto-char (point-min))
13815 (while (search-forward "\r" nil t)
13816 (replace-match "" t t)))))
13818 (defun gnus-article-remove-trailing-blank-lines ()
13819 "Remove all trailing blank lines from the article."
13822 (set-buffer gnus-article-buffer)
13823 (let ((buffer-read-only nil))
13824 (goto-char (point-max))
13828 (while (looking-at "^[ \t]*$")
13833 (defun gnus-article-display-x-face (&optional force)
13834 "Look for an X-Face header and display it if present."
13835 (interactive (list 'force))
13837 (set-buffer gnus-article-buffer)
13838 ;; Delete the old process, if any.
13839 (when (process-status "gnus-x-face")
13840 (delete-process "gnus-x-face"))
13841 (let ((inhibit-point-motion-hooks t)
13842 (case-fold-search nil)
13845 (nnheader-narrow-to-headers)
13846 (setq from (mail-fetch-field "from"))
13847 (goto-char (point-min))
13848 (when (and gnus-article-x-face-command
13850 ;; Check whether this face is censored.
13851 (not gnus-article-x-face-too-ugly)
13852 (and gnus-article-x-face-too-ugly from
13853 (not (string-match gnus-article-x-face-too-ugly
13855 ;; Has to be present.
13856 (re-search-forward "^X-Face: " nil t))
13857 ;; We now have the area of the buffer where the X-Face is stored.
13858 (let ((beg (point))
13859 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13860 ;; We display the face.
13861 (if (symbolp gnus-article-x-face-command)
13862 ;; The command is a lisp function, so we call it.
13863 (if (gnus-functionp gnus-article-x-face-command)
13864 (funcall gnus-article-x-face-command beg end)
13865 (error "%s is not a function" gnus-article-x-face-command))
13866 ;; The command is a string, so we interpret the command
13867 ;; as a, well, command, and fork it off.
13868 (let ((process-connection-type nil))
13869 (process-kill-without-query
13871 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13872 (process-send-region "gnus-x-face" beg end)
13873 (process-send-eof "gnus-x-face")))))))))
13875 (defun gnus-headers-decode-quoted-printable ()
13876 "Hack to remove QP encoding from headers."
13877 (let ((case-fold-search t)
13878 (inhibit-point-motion-hooks t)
13880 (goto-char (point-min))
13881 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13882 (setq string (match-string 1))
13883 (narrow-to-region (match-beginning 0) (match-end 0))
13884 (delete-region (point-min) (point-max))
13886 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13887 (subst-char-in-region (point-min) (point-max) ?_ ? )
13889 (goto-char (point-min)))))
13891 (defun gnus-article-de-quoted-unreadable (&optional force)
13892 "Do a naive translation of a quoted-printable-encoded article.
13893 This is in no way, shape or form meant as a replacement for real MIME
13894 processing, but is simply a stop-gap measure until MIME support is
13896 If FORCE, decode the article whether it is marked as quoted-printable
13898 (interactive (list 'force))
13900 (set-buffer gnus-article-buffer)
13901 (let ((case-fold-search t)
13902 (buffer-read-only nil)
13903 (type (gnus-fetch-field "content-transfer-encoding")))
13905 (and type (string-match "quoted-printable" (downcase type))))
13906 (gnus-headers-decode-quoted-printable)
13907 (goto-char (point-min))
13908 (search-forward "\n\n" nil 'move)
13909 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13911 (defun gnus-mime-decode-quoted-printable (from to)
13912 "Decode Quoted-Printable in the region between FROM and TO."
13915 (while (search-forward "=" to t)
13916 (cond ((eq (following-char) ?\n)
13919 ((looking-at "[0-9A-F][0-9A-F]")
13921 (insert (hexl-hex-string-to-integer
13922 (buffer-substring (point) (+ 2 (point)))))
13926 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13928 (defun gnus-article-hide-pgp (&optional arg)
13929 "Toggle hiding of any PGP headers and signatures in the current article.
13930 If given a negative prefix, always show; if given a positive prefix,
13933 (unless (gnus-article-check-hidden-text 'pgp arg)
13935 (set-buffer gnus-article-buffer)
13936 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13937 buffer-read-only beg end)
13939 (goto-char (point-min))
13940 ;; Hide the "header".
13941 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13942 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13944 ;; Hide the actual signature.
13945 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13946 (setq end (1+ (match-beginning 0)))
13949 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13951 ;; Perhaps we shouldn't hide to the end of the buffer
13952 ;; if there is no end to the signature?
13955 ;; Hide "- " PGP quotation markers.
13956 (when (and beg end)
13957 (narrow-to-region beg end)
13958 (goto-char (point-min))
13959 (while (re-search-forward "^- " nil t)
13960 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13963 (defun gnus-article-hide-signature (&optional arg)
13964 "Hide the signature in the current article.
13965 If given a negative prefix, always show; if given a positive prefix,
13968 (unless (gnus-article-check-hidden-text 'signature arg)
13970 (set-buffer gnus-article-buffer)
13972 (let ((buffer-read-only nil))
13973 (when (gnus-narrow-to-signature)
13974 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13976 (defun gnus-article-strip-leading-blank-lines ()
13977 "Remove all blank lines from the beginning of the article."
13980 (set-buffer gnus-article-buffer)
13981 (let (buffer-read-only)
13982 (goto-char (point-min))
13983 (when (search-forward "\n\n" nil t)
13984 (while (looking-at "[ \t]$")
13985 (gnus-delete-line))))))
13987 (defun gnus-narrow-to-signature ()
13988 "Narrow to the signature."
13990 (goto-char (point-max))
13991 (when (re-search-backward gnus-signature-separator nil t)
13993 (when (or (null gnus-signature-limit)
13994 (and (numberp gnus-signature-limit)
13995 (< (- (point-max) (point)) gnus-signature-limit))
13996 (and (gnus-functionp gnus-signature-limit)
13997 (funcall gnus-signature-limit))
13998 (and (stringp gnus-signature-limit)
13999 (not (re-search-forward gnus-signature-limit nil t))))
14000 (narrow-to-region (point) (point-max))
14003 (defun gnus-article-check-hidden-text (type arg)
14004 "Return nil if hiding is necessary."
14006 (set-buffer gnus-article-buffer)
14007 (let ((hide (gnus-article-hidden-text-p type)))
14008 (cond ((or (and (null arg) (eq hide 'hidden))
14009 (and arg (< 0 (prefix-numeric-value arg))))
14010 (gnus-article-show-hidden-text type))
14012 (gnus-article-show-hidden-text type t))
14015 (defun gnus-article-hidden-text-p (type)
14016 "Say whether the current buffer contains hidden text of type TYPE."
14017 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14019 (if (get-text-property pos 'invisible)
14023 (defun gnus-article-hide (&optional arg force)
14024 "Hide all the gruft in the current article.
14025 This means that PGP stuff, signatures, cited text and (some)
14026 headers will be hidden.
14027 If given a prefix, show the hidden text instead."
14028 (interactive (list current-prefix-arg 'force))
14029 (gnus-article-hide-headers arg)
14030 (gnus-article-hide-pgp arg)
14031 (gnus-article-hide-citation-maybe arg force)
14032 (gnus-article-hide-signature arg))
14034 (defun gnus-article-show-hidden-text (type &optional hide)
14035 "Show all hidden text of type TYPE.
14036 If HIDE, hide the text instead."
14038 (set-buffer gnus-article-buffer)
14039 (let ((buffer-read-only nil)
14040 (inhibit-point-motion-hooks t)
14042 (while (gnus-goto-char (text-property-any
14043 beg (point-max) 'gnus-type type))
14047 (gnus-hide-text beg (point) gnus-hidden-properties)
14048 (gnus-unhide-text beg (point)))
14049 (setq beg (point)))
14052 (defvar gnus-article-time-units
14053 `((year . ,(* 365.25 24 60 60))
14054 (week . ,(* 7 24 60 60))
14055 (day . ,(* 24 60 60))
14056 (hour . ,(* 60 60))
14059 "Mapping from time units to seconds.")
14061 (defun gnus-article-date-ut (&optional type highlight)
14062 "Convert DATE date to universal time in the current article.
14063 If TYPE is `local', convert to local time; if it is `lapsed', output
14064 how much time has lapsed since DATE."
14065 (interactive (list 'ut t))
14066 (let* ((header (or gnus-current-headers
14067 (gnus-summary-article-header) ""))
14068 (date (and (vectorp header) (mail-header-date header)))
14069 (date-regexp "^Date: \\|^X-Sent: ")
14070 (now (current-time))
14071 (inhibit-point-motion-hooks t)
14073 (when (and date (not (string= date "")))
14075 (set-buffer gnus-article-buffer)
14077 (nnheader-narrow-to-headers)
14078 (let ((buffer-read-only nil))
14079 ;; Delete any old Date headers.
14080 (if (re-search-forward date-regexp nil t)
14082 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14083 eface (get-text-property (gnus-point-at-eol) 'face))
14084 (message-remove-header date-regexp t)
14085 (beginning-of-line))
14086 (goto-char (point-max)))
14089 ;; Convert to the local timezone. We have to slap a
14090 ;; `condition-case' round the calls to the timezone
14091 ;; functions since they aren't particularly resistant to
14094 (concat "Date: " (condition-case ()
14095 (timezone-make-date-arpa-standard date)
14098 ;; Convert to Universal Time.
14102 (timezone-make-date-arpa-standard date nil "UT")
14105 ;; Get the original date from the article.
14106 ((eq type 'original)
14107 (concat "Date: " date "\n"))
14108 ;; Do an X-Sent lapsed format.
14110 ;; If the date is seriously mangled, the timezone
14111 ;; functions are liable to bug out, so we condition-case
14112 ;; the entire thing.
14117 (timezone-make-date-arpa-standard
14118 (current-time-string now)
14119 (current-time-zone now) "UT"))
14121 (timezone-make-date-arpa-standard
14124 (real-sec (+ (* (float (car real-time)) 65536)
14126 (sec (abs real-sec))
14132 ;; This is a bit convoluted, but basically we go
14133 ;; through the time units for years, weeks, etc,
14134 ;; and divide things to see whether that results
14135 ;; in positive answers.
14138 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14139 ;; The (remaining) seconds are too few to
14140 ;; be divided into this time unit.
14142 ;; It's big enough, so we output it.
14143 (setq sec (- sec (* num (cdr unit))))
14145 (concat (if prev ", " "") (int-to-string
14147 " " (symbol-name (car unit))
14148 (if (> num 1) "s" ""))
14150 gnus-article-time-units "")
14151 ;; If dates are odd, then it might appear like the
14152 ;; article was sent in the future.
14155 " in the future\n")))))
14157 (error "Unknown conversion type: %s" type)))))
14158 ;; Do highlighting.
14159 (beginning-of-line)
14160 (when (and highlight (gnus-visual-p 'article-highlight 'highlight)
14161 (looking-at "\\([^:]\\): *\\(.*\\)$"))
14162 (put-text-property (match-beginning 1) (match-end 1)
14164 (put-text-property (match-beginning 2) (match-end 2)
14167 (defun gnus-article-date-local (&optional highlight)
14168 "Convert the current article date to the local timezone."
14169 (interactive (list t))
14170 (gnus-article-date-ut 'local highlight))
14172 (defun gnus-article-date-original (&optional highlight)
14173 "Convert the current article date to what it was originally.
14174 This is only useful if you have used some other date conversion
14175 function and want to see what the date was before converting."
14176 (interactive (list t))
14177 (gnus-article-date-ut 'original highlight))
14179 (defun gnus-article-date-lapsed (&optional highlight)
14180 "Convert the current article date to time lapsed since it was sent."
14181 (interactive (list t))
14182 (gnus-article-date-ut 'lapsed highlight))
14184 (defun gnus-article-maybe-highlight ()
14185 "Do some article highlighting if `gnus-visual' is non-nil."
14186 (if (gnus-visual-p 'article-highlight 'highlight)
14187 (gnus-article-highlight-some)))
14191 (defun gnus-output-to-rmail (file-name)
14192 "Append the current article to an Rmail file named FILE-NAME."
14194 ;; Most of these codes are borrowed from rmailout.el.
14195 (setq file-name (expand-file-name file-name))
14196 (setq rmail-default-rmail-file file-name)
14197 (let ((artbuf (current-buffer))
14198 (tmpbuf (get-buffer-create " *Gnus-output*")))
14200 (or (get-file-buffer file-name)
14201 (file-exists-p file-name)
14202 (if (gnus-yes-or-no-p
14203 (concat "\"" file-name "\" does not exist, create it? "))
14204 (let ((file-buffer (create-file-buffer file-name)))
14206 (set-buffer file-buffer)
14207 (rmail-insert-rmail-file-header)
14208 (let ((require-final-newline nil))
14209 (write-region (point-min) (point-max) file-name t 1)))
14210 (kill-buffer file-buffer))
14211 (error "Output file does not exist")))
14212 (set-buffer tmpbuf)
14213 (buffer-disable-undo (current-buffer))
14215 (insert-buffer-substring artbuf)
14216 (gnus-convert-article-to-rmail)
14217 ;; Decide whether to append to a file or to an Emacs buffer.
14218 (let ((outbuf (get-file-buffer file-name)))
14220 (append-to-file (point-min) (point-max) file-name)
14221 ;; File has been visited, in buffer OUTBUF.
14222 (set-buffer outbuf)
14223 (let ((buffer-read-only nil)
14224 (msg (and (boundp 'rmail-current-message)
14225 (symbol-value 'rmail-current-message))))
14226 ;; If MSG is non-nil, buffer is in RMAIL mode.
14229 (narrow-to-region (point-max) (point-max))))
14230 (insert-buffer-substring tmpbuf)
14233 (goto-char (point-min))
14235 (search-backward "\^_")
14236 (narrow-to-region (point) (point-max))
14237 (goto-char (1+ (point-min)))
14238 (rmail-count-new-messages t)
14239 (rmail-show-message msg)))))))
14240 (kill-buffer tmpbuf)))
14242 (defun gnus-output-to-file (file-name)
14243 "Append the current article to a file named FILE-NAME."
14244 (setq file-name (expand-file-name file-name))
14245 (let ((artbuf (current-buffer))
14246 (tmpbuf (get-buffer-create " *Gnus-output*")))
14248 (set-buffer tmpbuf)
14249 (buffer-disable-undo (current-buffer))
14251 (insert-buffer-substring artbuf)
14252 ;; Append newline at end of the buffer as separator, and then
14253 ;; save it to file.
14254 (goto-char (point-max))
14256 (append-to-file (point-min) (point-max) file-name))
14257 (kill-buffer tmpbuf)))
14259 (defun gnus-convert-article-to-rmail ()
14260 "Convert article in current buffer to Rmail message format."
14261 (let ((buffer-read-only nil))
14262 ;; Convert article directly into Babyl format.
14263 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14264 (goto-char (point-min))
14265 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14266 (while (search-forward "\n\^_" nil t) ;single char
14267 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14268 (goto-char (point-max))
14271 (defun gnus-narrow-to-page (&optional arg)
14272 "Narrow the article buffer to a page.
14273 If given a numerical ARG, move forward ARG pages."
14275 (setq arg (if arg (prefix-numeric-value arg) 0))
14277 (set-buffer gnus-article-buffer)
14278 (goto-char (point-min))
14280 (when (gnus-visual-p 'page-marker)
14281 (let ((buffer-read-only nil))
14282 (gnus-remove-text-with-property 'gnus-prev)
14283 (gnus-remove-text-with-property 'gnus-next)))
14286 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14288 (re-search-forward page-delimiter nil 'move arg)))
14289 (goto-char (match-end 0)))
14292 (if (re-search-forward page-delimiter nil 'move)
14293 (match-beginning 0)
14295 (when (and (gnus-visual-p 'page-marker)
14296 (not (= (point-min) 1)))
14298 (goto-char (point-min))
14299 (gnus-insert-prev-page-button)))
14300 (when (and (gnus-visual-p 'page-marker)
14301 (not (= (1- (point-max)) (buffer-size))))
14303 (goto-char (point-max))
14304 (gnus-insert-next-page-button)))))
14306 ;; Article mode commands
14308 (defun gnus-article-goto-next-page ()
14309 "Show the next page of the article."
14311 (when (gnus-article-next-page)
14312 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14314 (defun gnus-article-goto-prev-page ()
14315 "Show the next page of the article."
14317 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14318 (gnus-article-prev-page nil)))
14320 (defun gnus-article-next-page (&optional lines)
14321 "Show the next page of the current article.
14322 If end of article, return non-nil. Otherwise return nil.
14323 Argument LINES specifies lines to be scrolled up."
14325 (move-to-window-line -1)
14326 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14327 (if (save-excursion
14329 (and (pos-visible-in-window-p) ;Not continuation line.
14331 ;; Nothing in this page.
14332 (if (or (not gnus-break-pages)
14335 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14337 (gnus-narrow-to-page 1) ;Go to next page.
14339 ;; More in this page.
14343 ;; Long lines may cause an end-of-buffer error.
14344 (goto-char (point-max))))
14345 (move-to-window-line 0)
14348 (defun gnus-article-prev-page (&optional lines)
14349 "Show previous page of current article.
14350 Argument LINES specifies lines to be scrolled down."
14352 (move-to-window-line 0)
14353 (if (and gnus-break-pages
14355 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14357 (gnus-narrow-to-page -1) ;Go to previous page.
14358 (goto-char (point-max))
14362 (scroll-down lines)
14364 (move-to-window-line 0))))
14366 (defun gnus-article-refer-article ()
14367 "Read article specified by message-id around point."
14369 (let ((point (point)))
14370 (search-forward ">" nil t) ;Move point to end of "<....>".
14371 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14372 (let ((message-id (match-string 1)))
14374 (set-buffer gnus-summary-buffer)
14375 (gnus-summary-refer-article message-id))
14376 (goto-char (point))
14377 (error "No references around point"))))
14379 (defun gnus-article-show-summary ()
14380 "Reconfigure windows to show summary buffer."
14382 (gnus-configure-windows 'article)
14383 (gnus-summary-goto-subject gnus-current-article))
14385 (defun gnus-article-describe-briefly ()
14386 "Describe article mode commands briefly."
14389 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14391 (defun gnus-article-summary-command ()
14392 "Execute the last keystroke in the summary buffer."
14394 (let ((obuf (current-buffer))
14395 (owin (current-window-configuration))
14397 (switch-to-buffer gnus-summary-buffer 'norecord)
14398 (setq func (lookup-key (current-local-map) (this-command-keys)))
14399 (call-interactively func)
14401 (set-window-configuration owin)
14402 (set-window-point (get-buffer-window (current-buffer)) (point))))
14404 (defun gnus-article-summary-command-nosave ()
14405 "Execute the last keystroke in the summary buffer."
14408 (pop-to-buffer gnus-summary-buffer 'norecord)
14409 (setq func (lookup-key (current-local-map) (this-command-keys)))
14410 (call-interactively func)))
14412 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14413 "Read a summary buffer key sequence and execute it from the article buffer."
14416 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14417 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14421 (set-buffer gnus-summary-buffer)
14422 (push (or key last-command-event) unread-command-events)
14423 (setq keys (read-key-sequence nil)))
14426 (if (member keys nosaves)
14428 (pop-to-buffer gnus-summary-buffer 'norecord)
14429 (if (setq func (lookup-key (current-local-map) keys))
14430 (call-interactively func)
14432 (let ((obuf (current-buffer))
14433 (owin (current-window-configuration))
14436 (if not-restore-window
14437 (pop-to-buffer gnus-summary-buffer 'norecord)
14438 (switch-to-buffer gnus-summary-buffer 'norecord))
14439 (setq in-buffer (current-buffer))
14440 (if (setq func (lookup-key (current-local-map) keys))
14441 (call-interactively func)
14443 (when (eq in-buffer (current-buffer))
14445 (unless not-restore-window
14446 (set-window-configuration owin))
14447 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14451 ;;; Kill file handling.
14455 (defalias 'gnus-batch-kill 'gnus-batch-score)
14457 (defun gnus-batch-score ()
14458 "Run batched scoring.
14459 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14460 Newsgroups is a list of strings in Bnews format. If you want to score
14461 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14462 score the alt hierarchy, you'd say \"!alt.all\"."
14465 (gnus-newsrc-parse-options
14466 (apply (function concat)
14467 (mapcar (lambda (g) (concat g " "))
14468 command-line-args-left))))
14469 (gnus-expert-user t)
14470 (nnmail-spool-file nil)
14471 (gnus-use-dribble-file nil)
14472 (yes (car yes-and-no))
14473 (no (cdr yes-and-no))
14475 ;; Disable verbose message.
14476 gnus-novice-user gnus-large-newsgroup)
14477 ;; Eat all arguments.
14478 (setq command-line-args-left nil)
14481 ;; Apply kills to specified newsgroups in command line arguments.
14482 (setq newsrc (cdr gnus-newsrc-alist))
14484 (setq group (caar newsrc))
14485 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14486 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14488 (or (eq (car entry) t)
14489 (not (zerop (car entry)))))
14490 (if yes (string-match yes group) t)
14491 (or (null no) (not (string-match no group))))
14493 (gnus-summary-read-group group nil t nil t)
14494 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14495 (gnus-summary-exit))))
14496 (setq newsrc (cdr newsrc)))
14498 (switch-to-buffer gnus-group-buffer)
14499 (gnus-group-save-newsrc)))
14501 (defun gnus-apply-kill-file ()
14502 "Apply a kill file to the current newsgroup.
14503 Returns the number of articles marked as read."
14504 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14505 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14506 (gnus-apply-kill-file-internal)
14509 (defun gnus-kill-save-kill-buffer ()
14510 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14511 (when (get-file-buffer file)
14513 (set-buffer (get-file-buffer file))
14514 (and (buffer-modified-p) (save-buffer))
14515 (kill-buffer (current-buffer))))))
14517 (defvar gnus-kill-file-name "KILL"
14518 "Suffix of the kill files.")
14520 (defun gnus-newsgroup-kill-file (newsgroup)
14521 "Return the name of a kill file name for NEWSGROUP.
14522 If NEWSGROUP is nil, return the global kill file name instead."
14524 ;; The global KILL file is placed at top of the directory.
14525 ((or (null newsgroup)
14526 (string-equal newsgroup ""))
14527 (expand-file-name gnus-kill-file-name
14528 (or gnus-kill-files-directory "~/News")))
14529 ;; Append ".KILL" to newsgroup name.
14530 ((gnus-use-long-file-name 'not-kill)
14531 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14532 "." gnus-kill-file-name)
14533 (or gnus-kill-files-directory "~/News")))
14534 ;; Place "KILL" under the hierarchical directory.
14536 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14537 "/" gnus-kill-file-name)
14538 (or gnus-kill-files-directory "~/News")))))
14545 (defvar gnus-dribble-ignore nil)
14546 (defvar gnus-dribble-eval-file nil)
14548 (defun gnus-dribble-file-name ()
14549 "Return the dribble file for the current .newsrc."
14551 (if gnus-dribble-directory
14552 (concat (file-name-as-directory gnus-dribble-directory)
14553 (file-name-nondirectory gnus-current-startup-file))
14554 gnus-current-startup-file)
14557 (defun gnus-dribble-enter (string)
14558 "Enter STRING into the dribble buffer."
14559 (if (and (not gnus-dribble-ignore)
14560 gnus-dribble-buffer
14561 (buffer-name gnus-dribble-buffer))
14562 (let ((obuf (current-buffer)))
14563 (set-buffer gnus-dribble-buffer)
14564 (insert string "\n")
14565 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14566 (set-buffer obuf))))
14568 (defun gnus-dribble-read-file ()
14569 "Read the dribble file from disk."
14570 (let ((dribble-file (gnus-dribble-file-name)))
14572 (set-buffer (setq gnus-dribble-buffer
14574 (file-name-nondirectory dribble-file))))
14575 (gnus-add-current-to-buffer-list)
14577 (setq buffer-file-name dribble-file)
14579 (buffer-disable-undo (current-buffer))
14580 (bury-buffer (current-buffer))
14581 (set-buffer-modified-p nil)
14582 (let ((auto (make-auto-save-file-name))
14583 (gnus-dribble-ignore t))
14584 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14585 ;; Load whichever file is newest -- the auto save file
14586 ;; or the "real" file.
14587 (if (file-newer-than-file-p auto dribble-file)
14588 (insert-file-contents auto)
14589 (insert-file-contents dribble-file))
14590 (unless (zerop (buffer-size))
14591 (set-buffer-modified-p t))
14592 ;; Set the file modes to reflect the .newsrc file modes.
14594 (when (file-exists-p gnus-current-startup-file)
14595 (set-file-modes dribble-file
14596 (file-modes gnus-current-startup-file)))
14597 ;; Possibly eval the file later.
14598 (when (gnus-y-or-n-p
14599 "Auto-save file exists. Do you want to read it? ")
14600 (setq gnus-dribble-eval-file t)))))))
14602 (defun gnus-dribble-eval-file ()
14603 (if (not gnus-dribble-eval-file)
14605 (setq gnus-dribble-eval-file nil)
14607 (let ((gnus-dribble-ignore t))
14608 (set-buffer gnus-dribble-buffer)
14609 (eval-buffer (current-buffer))))))
14611 (defun gnus-dribble-delete-file ()
14612 (if (file-exists-p (gnus-dribble-file-name))
14613 (delete-file (gnus-dribble-file-name)))
14614 (if gnus-dribble-buffer
14616 (set-buffer gnus-dribble-buffer)
14617 (let ((auto (make-auto-save-file-name)))
14618 (if (file-exists-p auto)
14619 (delete-file auto))
14621 (set-buffer-modified-p nil)))))
14623 (defun gnus-dribble-save ()
14624 (if (and gnus-dribble-buffer
14625 (buffer-name gnus-dribble-buffer))
14627 (set-buffer gnus-dribble-buffer)
14630 (defun gnus-dribble-clear ()
14632 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14634 (set-buffer gnus-dribble-buffer)
14636 (set-buffer-modified-p nil)
14637 (setq buffer-saved-size (buffer-size))))))
14641 ;;; Server Communication
14644 (defun gnus-start-news-server (&optional confirm)
14645 "Open a method for getting news.
14646 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14648 (if gnus-current-select-method
14649 ;; Stream is already opened.
14651 ;; Open NNTP server.
14652 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14655 ;; Read server name with completion.
14656 (setq gnus-nntp-server
14657 (completing-read "NNTP server: "
14658 (mapcar (lambda (server) (list server))
14659 (cons (list gnus-nntp-server)
14660 gnus-secondary-servers))
14661 nil nil gnus-nntp-server))))
14663 (if (and gnus-nntp-server
14664 (stringp gnus-nntp-server)
14665 (not (string= gnus-nntp-server "")))
14666 (setq gnus-select-method
14667 (cond ((or (string= gnus-nntp-server "")
14668 (string= gnus-nntp-server "::"))
14669 (list 'nnspool (system-name)))
14670 ((string-match "^:" gnus-nntp-server)
14671 (list 'nnmh gnus-nntp-server
14672 (list 'nnmh-directory
14673 (file-name-as-directory
14675 (concat "~/" (substring
14676 gnus-nntp-server 1)))))
14677 (list 'nnmh-get-new-mail nil)))
14679 (list 'nntp gnus-nntp-server)))))
14681 (setq how (car gnus-select-method))
14682 (cond ((eq how 'nnspool)
14684 (gnus-message 5 "Looking up local news spool..."))
14687 (gnus-message 5 "Looking up mh spool..."))
14690 (setq gnus-current-select-method gnus-select-method)
14691 (run-hooks 'gnus-open-server-hook)
14693 ;; gnus-open-server-hook might have opened it
14694 (gnus-server-opened gnus-select-method)
14695 (gnus-open-server gnus-select-method)
14698 "%s (%s) open error: '%s'. Continue? "
14699 (car gnus-select-method) (cadr gnus-select-method)
14700 (gnus-status-message gnus-select-method)))
14701 (gnus-error 1 "Couldn't open server on %s"
14702 (nth 1 gnus-select-method))))))
14704 (defun gnus-check-group (group)
14705 "Try to make sure that the server where GROUP exists is alive."
14706 (let ((method (gnus-find-method-for-group group)))
14707 (or (gnus-server-opened method)
14708 (gnus-open-server method))))
14710 (defun gnus-check-server (&optional method silent)
14711 "Check whether the connection to METHOD is down.
14712 If METHOD is nil, use `gnus-select-method'.
14713 If it is down, start it up (again)."
14714 (let ((method (or method gnus-select-method)))
14715 ;; Transform virtual server names into select methods.
14716 (when (stringp method)
14717 (setq method (gnus-server-to-method method)))
14718 (if (gnus-server-opened method)
14719 ;; The stream is already opened.
14721 ;; Open the server.
14723 (gnus-message 5 "Opening %s server%s..." (car method)
14724 (if (equal (nth 1 method) "") ""
14725 (format " on %s" (nth 1 method)))))
14726 (run-hooks 'gnus-open-server-hook)
14728 (gnus-open-server method)
14732 (defun gnus-get-function (method function)
14733 "Return a function symbol based on METHOD and FUNCTION."
14734 ;; Translate server names into methods.
14736 (error "Attempted use of a nil select method"))
14737 (when (stringp method)
14738 (setq method (gnus-server-to-method method)))
14739 (let ((func (intern (format "%s-%s" (car method) function))))
14740 ;; If the functions isn't bound, we require the backend in
14742 (unless (fboundp func)
14743 (require (car method))
14744 (unless (fboundp func)
14745 ;; This backend doesn't implement this function.
14746 (error "No such function: %s" func)))
14751 ;;; Interface functions to the backends.
14754 (defun gnus-open-server (method)
14755 "Open a connection to METHOD."
14756 (when (stringp method)
14757 (setq method (gnus-server-to-method method)))
14758 (let ((elem (assoc method gnus-opened-servers)))
14759 ;; If this method was previously denied, we just return nil.
14760 (if (eq (nth 1 elem) 'denied)
14762 (gnus-message 1 "Denied server")
14764 ;; Open the server.
14766 (funcall (gnus-get-function method 'open-server)
14767 (nth 1 method) (nthcdr 2 method))))
14768 ;; If this hasn't been opened before, we add it to the list.
14770 (setq elem (list method nil)
14771 gnus-opened-servers (cons elem gnus-opened-servers)))
14772 ;; Set the status of this server.
14773 (setcar (cdr elem) (if result 'ok 'denied))
14774 ;; Return the result from the "open" call.
14777 (defun gnus-close-server (method)
14778 "Close the connection to METHOD."
14779 (when (stringp method)
14780 (setq method (gnus-server-to-method method)))
14781 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14783 (defun gnus-request-list (method)
14784 "Request the active file from METHOD."
14785 (when (stringp method)
14786 (setq method (gnus-server-to-method method)))
14787 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14789 (defun gnus-request-list-newsgroups (method)
14790 "Request the newsgroups file from METHOD."
14791 (when (stringp method)
14792 (setq method (gnus-server-to-method method)))
14793 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14795 (defun gnus-request-newgroups (date method)
14796 "Request all new groups since DATE from METHOD."
14797 (when (stringp method)
14798 (setq method (gnus-server-to-method method)))
14799 (funcall (gnus-get-function method 'request-newgroups)
14800 date (nth 1 method)))
14802 (defun gnus-server-opened (method)
14803 "Check whether a connection to METHOD has been opened."
14804 (when (stringp method)
14805 (setq method (gnus-server-to-method method)))
14806 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14808 (defun gnus-status-message (method)
14809 "Return the status message from METHOD.
14810 If METHOD is a string, it is interpreted as a group name. The method
14811 this group uses will be queried."
14812 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14814 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14816 (defun gnus-request-group (group &optional dont-check method)
14817 "Request GROUP. If DONT-CHECK, no information is required."
14818 (let ((method (or method (gnus-find-method-for-group group))))
14819 (when (stringp method)
14820 (setq method (gnus-server-to-method method)))
14821 (funcall (gnus-get-function method 'request-group)
14822 (gnus-group-real-name group) (nth 1 method) dont-check)))
14824 (defun gnus-request-asynchronous (group &optional articles)
14825 "Request that GROUP behave asynchronously.
14826 ARTICLES is the `data' of the group."
14827 (let ((method (gnus-find-method-for-group group)))
14828 (funcall (gnus-get-function method 'request-asynchronous)
14829 (gnus-group-real-name group) (nth 1 method) articles)))
14831 (defun gnus-list-active-group (group)
14832 "Request active information on GROUP."
14833 (let ((method (gnus-find-method-for-group group))
14834 (func 'list-active-group))
14835 (when (gnus-check-backend-function func group)
14836 (funcall (gnus-get-function method func)
14837 (gnus-group-real-name group) (nth 1 method)))))
14839 (defun gnus-request-group-description (group)
14840 "Request a description of GROUP."
14841 (let ((method (gnus-find-method-for-group group))
14842 (func 'request-group-description))
14843 (when (gnus-check-backend-function func group)
14844 (funcall (gnus-get-function method func)
14845 (gnus-group-real-name group) (nth 1 method)))))
14847 (defun gnus-close-group (group)
14848 "Request the GROUP be closed."
14849 (let ((method (gnus-find-method-for-group group)))
14850 (funcall (gnus-get-function method 'close-group)
14851 (gnus-group-real-name group) (nth 1 method))))
14853 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14854 "Request headers for ARTICLES in GROUP.
14855 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14856 (let ((method (gnus-find-method-for-group group)))
14857 (if (and gnus-use-cache (numberp (car articles)))
14858 (gnus-cache-retrieve-headers articles group fetch-old)
14859 (funcall (gnus-get-function method 'retrieve-headers)
14860 articles (gnus-group-real-name group) (nth 1 method)
14863 (defun gnus-retrieve-groups (groups method)
14864 "Request active information on GROUPS from METHOD."
14865 (when (stringp method)
14866 (setq method (gnus-server-to-method method)))
14867 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14869 (defun gnus-request-type (group &optional article)
14870 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14871 (let ((method (gnus-find-method-for-group group)))
14872 (if (not (gnus-check-backend-function 'request-type (car method)))
14874 (funcall (gnus-get-function method 'request-type)
14875 (gnus-group-real-name group) article))))
14877 (defun gnus-request-update-mark (group article mark)
14878 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14879 (let ((method (gnus-find-method-for-group group)))
14880 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14882 (funcall (gnus-get-function method 'request-update-mark)
14883 (gnus-group-real-name group) article mark))))
14885 (defun gnus-request-article (article group &optional buffer)
14886 "Request the ARTICLE in GROUP.
14887 ARTICLE can either be an article number or an article Message-ID.
14888 If BUFFER, insert the article in that group."
14889 (let ((method (gnus-find-method-for-group group)))
14890 (funcall (gnus-get-function method 'request-article)
14891 article (gnus-group-real-name group) (nth 1 method) buffer)))
14893 (defun gnus-request-head (article group)
14894 "Request the head of ARTICLE in GROUP."
14895 (let ((method (gnus-find-method-for-group group)))
14896 (funcall (gnus-get-function method 'request-head)
14897 article (gnus-group-real-name group) (nth 1 method))))
14899 (defun gnus-request-body (article group)
14900 "Request the body of ARTICLE in GROUP."
14901 (let ((method (gnus-find-method-for-group group)))
14902 (funcall (gnus-get-function method 'request-body)
14903 article (gnus-group-real-name group) (nth 1 method))))
14905 (defun gnus-request-post (method)
14906 "Post the current buffer using METHOD."
14907 (when (stringp method)
14908 (setq method (gnus-server-to-method method)))
14909 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14911 (defun gnus-request-scan (group method)
14912 "Request a SCAN being performed in GROUP from METHOD.
14913 If GROUP is nil, all groups on METHOD are scanned."
14914 (let ((method (if group (gnus-find-method-for-group group) method)))
14915 (funcall (gnus-get-function method 'request-scan)
14916 (and group (gnus-group-real-name group)) (nth 1 method))))
14918 (defsubst gnus-request-update-info (info method)
14919 "Request that METHOD update INFO."
14920 (when (stringp method)
14921 (setq method (gnus-server-to-method method)))
14922 (when (gnus-check-backend-function 'request-update-info (car method))
14923 (funcall (gnus-get-function method 'request-update-info)
14924 (gnus-group-real-name (gnus-info-group info))
14925 info (nth 1 method))))
14927 (defun gnus-request-expire-articles (articles group &optional force)
14928 (let ((method (gnus-find-method-for-group group)))
14929 (funcall (gnus-get-function method 'request-expire-articles)
14930 articles (gnus-group-real-name group) (nth 1 method)
14933 (defun gnus-request-move-article
14934 (article group server accept-function &optional last)
14935 (let ((method (gnus-find-method-for-group group)))
14936 (funcall (gnus-get-function method 'request-move-article)
14937 article (gnus-group-real-name group)
14938 (nth 1 method) accept-function last)))
14940 (defun gnus-request-accept-article (group method &optional last)
14941 ;; Make sure there's a newline at the end of the article.
14942 (when (stringp method)
14943 (setq method (gnus-server-to-method method)))
14944 (when (and (not method)
14946 (setq method (gnus-find-method-for-group group)))
14947 (goto-char (point-max))
14950 (let ((func (car (or method (gnus-find-method-for-group group)))))
14951 (funcall (intern (format "%s-request-accept-article" func))
14952 (if (stringp group) (gnus-group-real-name group) group)
14956 (defun gnus-request-replace-article (article group buffer)
14957 (let ((func (car (gnus-find-method-for-group group))))
14958 (funcall (intern (format "%s-request-replace-article" func))
14959 article (gnus-group-real-name group) buffer)))
14961 (defun gnus-request-associate-buffer (group)
14962 (let ((method (gnus-find-method-for-group group)))
14963 (funcall (gnus-get-function method 'request-associate-buffer)
14964 (gnus-group-real-name group))))
14966 (defun gnus-request-restore-buffer (article group)
14967 "Request a new buffer restored to the state of ARTICLE."
14968 (let ((method (gnus-find-method-for-group group)))
14969 (funcall (gnus-get-function method 'request-restore-buffer)
14970 article (gnus-group-real-name group) (nth 1 method))))
14972 (defun gnus-request-create-group (group &optional method)
14973 (when (stringp method)
14974 (setq method (gnus-server-to-method method)))
14975 (let ((method (or method (gnus-find-method-for-group group))))
14976 (funcall (gnus-get-function method 'request-create-group)
14977 (gnus-group-real-name group) (nth 1 method))))
14979 (defun gnus-request-delete-group (group &optional force)
14980 (let ((method (gnus-find-method-for-group group)))
14981 (funcall (gnus-get-function method 'request-delete-group)
14982 (gnus-group-real-name group) force (nth 1 method))))
14984 (defun gnus-request-rename-group (group new-name)
14985 (let ((method (gnus-find-method-for-group group)))
14986 (funcall (gnus-get-function method 'request-rename-group)
14987 (gnus-group-real-name group)
14988 (gnus-group-real-name new-name) (nth 1 method))))
14990 (defun gnus-member-of-valid (symbol group)
14991 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14992 (memq symbol (assoc
14993 (symbol-name (car (gnus-find-method-for-group group)))
14994 gnus-valid-select-methods)))
14996 (defun gnus-method-option-p (method option)
14997 "Return non-nil if select METHOD has OPTION as a parameter."
14998 (when (stringp method)
14999 (setq method (gnus-server-to-method method)))
15000 (memq option (assoc (format "%s" (car method))
15001 gnus-valid-select-methods)))
15003 (defun gnus-server-extend-method (group method)
15004 ;; This function "extends" a virtual server. If the server is
15005 ;; "hello", and the select method is ("hello" (my-var "something"))
15006 ;; in the group "alt.alt", this will result in a new virtual server
15007 ;; called "hello+alt.alt".
15009 (gnus-copy-sequence
15010 (if (equal (car method) "native") gnus-select-method
15011 (cdr (assoc (car method) gnus-server-alist))))))
15012 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15013 (nconc entry (cdr method))))
15015 (defun gnus-find-method-for-group (group &optional info)
15016 "Find the select method that GROUP uses."
15017 (or gnus-override-method
15019 gnus-select-method)
15020 (let ((info (or info (gnus-get-info group)))
15023 (not (setq method (gnus-info-method info)))
15024 (equal method "native"))
15027 (cond ((stringp method)
15028 (gnus-server-to-method method))
15029 ((stringp (car method))
15030 (gnus-server-extend-method group method))
15033 (cond ((equal (cadr method) "")
15035 ((null (cadr method))
15036 (list (car method) ""))
15038 (gnus-server-add-address method)))))))
15040 (defun gnus-check-backend-function (func group)
15041 "Check whether GROUP supports function FUNC."
15042 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15044 (fboundp (intern (format "%s-%s" method func)))))
15046 (defun gnus-methods-using (feature)
15047 "Find all methods that have FEATURE."
15048 (let ((valids gnus-valid-select-methods)
15051 (if (memq feature (car valids))
15052 (setq outs (cons (car valids) outs)))
15053 (setq valids (cdr valids)))
15058 ;;; Active & Newsrc File Handling
15061 (defun gnus-setup-news (&optional rawfile level dont-connect)
15062 "Setup news information.
15063 If RAWFILE is non-nil, the .newsrc file will also be read.
15064 If LEVEL is non-nil, the news will be set up at level LEVEL."
15065 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15068 ;; Clear some variables to re-initialize news information.
15069 (setq gnus-newsrc-alist nil
15070 gnus-active-hashtb nil)
15071 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15072 (gnus-read-newsrc-file rawfile))
15074 (when (and (not (assoc "archive" gnus-server-alist))
15075 gnus-message-archive-method)
15076 (push (cons "archive" gnus-message-archive-method)
15077 gnus-server-alist))
15079 ;; If we don't read the complete active file, we fill in the
15081 (if (or (null gnus-read-active-file)
15082 (eq gnus-read-active-file 'some))
15083 (gnus-update-active-hashtb-from-killed))
15085 ;; Read the active file and create `gnus-active-hashtb'.
15086 ;; If `gnus-read-active-file' is nil, then we just create an empty
15087 ;; hash table. The partial filling out of the hash table will be
15088 ;; done in `gnus-get-unread-articles'.
15089 (and gnus-read-active-file
15091 (gnus-read-active-file))
15093 (or gnus-active-hashtb
15094 (setq gnus-active-hashtb (make-vector 4095 0)))
15096 ;; Initialize the cache.
15097 (when gnus-use-cache
15100 ;; Possibly eval the dribble file.
15101 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15103 (gnus-update-format-specifications)
15105 ;; See whether we need to read the description file.
15106 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15107 (not gnus-description-hashtb)
15109 gnus-read-active-file)
15110 (gnus-read-all-descriptions-files))
15112 ;; Find new newsgroups and treat them.
15113 (if (and init gnus-check-new-newsgroups (not level)
15114 (gnus-check-server gnus-select-method))
15115 (gnus-find-new-newsgroups))
15117 ;; We might read in new NoCeM messages here.
15118 (when (and gnus-use-nocem
15120 (not dont-connect))
15121 (gnus-nocem-scan-groups))
15123 ;; Find the number of unread articles in each non-dead group.
15124 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15125 (gnus-get-unread-articles level))
15127 (if (and init gnus-check-bogus-newsgroups
15128 gnus-read-active-file (not level)
15129 (gnus-server-opened gnus-select-method))
15130 (gnus-check-bogus-newsgroups))))
15132 (defun gnus-find-new-newsgroups (&optional arg)
15133 "Search for new newsgroups and add them.
15134 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15135 The `-n' option line from .newsrc is respected.
15136 If ARG (the prefix), use the `ask-server' method to query
15137 the server for new groups."
15139 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15140 (null gnus-read-active-file)
15141 (eq gnus-read-active-file 'some))
15142 'ask-server gnus-check-new-newsgroups)))
15143 (unless (gnus-check-first-time-used)
15144 (if (or (consp check)
15145 (eq check 'ask-server))
15146 ;; Ask the server for new groups.
15147 (gnus-ask-server-for-new-groups)
15148 ;; Go through the active hashtb and look for new groups.
15150 group new-newsgroups)
15151 (gnus-message 5 "Looking for new newsgroups...")
15152 (unless gnus-have-read-active-file
15153 (gnus-read-active-file))
15154 (setq gnus-newsrc-last-checked-date (current-time-string))
15155 (unless gnus-killed-hashtb
15156 (gnus-make-hashtable-from-killed))
15157 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15158 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15161 (if (or (null (setq group (symbol-name sym)))
15163 (null (symbol-value sym))
15164 (gnus-gethash group gnus-killed-hashtb)
15165 (gnus-gethash group gnus-newsrc-hashtb))
15167 (let ((do-sub (gnus-matches-options-n group)))
15169 ((eq do-sub 'subscribe)
15170 (setq groups (1+ groups))
15171 (gnus-sethash group group gnus-killed-hashtb)
15172 (funcall gnus-subscribe-options-newsgroup-method group))
15173 ((eq do-sub 'ignore)
15176 (setq groups (1+ groups))
15177 (gnus-sethash group group gnus-killed-hashtb)
15178 (if gnus-subscribe-hierarchical-interactive
15179 (setq new-newsgroups (cons group new-newsgroups))
15180 (funcall gnus-subscribe-newsgroup-method group)))))))
15181 gnus-active-hashtb)
15182 (when new-newsgroups
15183 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15184 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15186 (gnus-message 6 "%d new newsgroup%s arrived."
15187 groups (if (> groups 1) "s have" " has"))
15188 (gnus-message 6 "No new newsgroups.")))))))
15190 (defun gnus-matches-options-n (group)
15191 ;; Returns `subscribe' if the group is to be unconditionally
15192 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15193 ;; no match for the group.
15195 ;; First we check the two user variables.
15197 ((and gnus-options-subscribe
15198 (string-match gnus-options-subscribe group))
15200 ((and gnus-auto-subscribed-groups
15201 (string-match gnus-auto-subscribed-groups group))
15203 ((and gnus-options-not-subscribe
15204 (string-match gnus-options-not-subscribe group))
15206 ;; Then we go through the list that was retrieved from the .newsrc
15207 ;; file. This list has elements on the form
15208 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15209 ;; is in the reverse order of the options line) is returned.
15211 (let ((regs gnus-newsrc-options-n))
15213 (not (string-match (caar regs) group)))
15214 (setq regs (cdr regs)))
15215 (and regs (cdar regs))))))
15217 (defun gnus-ask-server-for-new-groups ()
15218 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15219 (methods (cons gnus-select-method
15221 (when gnus-message-archive-method
15224 (and (consp gnus-check-new-newsgroups)
15225 gnus-check-new-newsgroups)
15226 gnus-secondary-select-methods))))
15228 (new-date (current-time-string))
15229 group new-newsgroups got-new method hashtb
15230 gnus-override-subscribe-method)
15231 ;; Go through both primary and secondary select methods and
15232 ;; request new newsgroups.
15233 (while (setq method (gnus-server-get-method nil (pop methods)))
15234 (setq new-newsgroups nil)
15235 (setq gnus-override-subscribe-method method)
15236 (when (and (gnus-check-server method)
15237 (gnus-request-newgroups date method))
15240 (setq hashtb (gnus-make-hashtable 100))
15241 (set-buffer nntp-server-buffer)
15242 ;; Enter all the new groups into a hashtable.
15243 (gnus-active-to-gnus-format method hashtb 'ignore))
15244 ;; Now all new groups from `method' are in `hashtb'.
15246 (lambda (group-sym)
15247 (if (or (null (setq group (symbol-name group-sym)))
15248 (not (boundp group-sym))
15249 (null (symbol-value group-sym))
15250 (gnus-gethash group gnus-newsrc-hashtb)
15251 (member group gnus-zombie-list)
15252 (member group gnus-killed-list))
15253 ;; The group is already known.
15255 ;; Make this group active.
15256 (when (symbol-value group-sym)
15257 (gnus-set-active group (symbol-value group-sym)))
15258 ;; Check whether we want it or not.
15259 (let ((do-sub (gnus-matches-options-n group)))
15261 ((eq do-sub 'subscribe)
15263 (gnus-sethash group group gnus-killed-hashtb)
15264 (funcall gnus-subscribe-options-newsgroup-method group))
15265 ((eq do-sub 'ignore)
15269 (gnus-sethash group group gnus-killed-hashtb)
15270 (if gnus-subscribe-hierarchical-interactive
15271 (push group new-newsgroups)
15272 (funcall gnus-subscribe-newsgroup-method group)))))))
15274 (when new-newsgroups
15275 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15276 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15278 (gnus-message 6 "%d new newsgroup%s arrived."
15279 groups (if (> groups 1) "s have" " has")))
15280 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15283 (defun gnus-check-first-time-used ()
15284 (if (or (> (length gnus-newsrc-alist) 1)
15285 (file-exists-p gnus-startup-file)
15286 (file-exists-p (concat gnus-startup-file ".el"))
15287 (file-exists-p (concat gnus-startup-file ".eld")))
15289 (gnus-message 6 "First time user; subscribing you to default groups")
15290 (unless gnus-have-read-active-file
15291 (gnus-read-active-file))
15292 (setq gnus-newsrc-last-checked-date (current-time-string))
15293 (let ((groups gnus-default-subscribed-newsgroups)
15297 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15300 (if (null (setq group (symbol-name sym)))
15302 (let ((do-sub (gnus-matches-options-n group)))
15304 ((eq do-sub 'subscribe)
15305 (gnus-sethash group group gnus-killed-hashtb)
15306 (funcall gnus-subscribe-options-newsgroup-method group))
15307 ((eq do-sub 'ignore)
15310 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15311 gnus-active-hashtb)
15313 (if (gnus-active (car groups))
15314 (gnus-group-change-level
15315 (car groups) gnus-level-default-subscribed gnus-level-killed))
15316 (setq groups (cdr groups)))
15317 (gnus-group-make-help-group)
15318 (and gnus-novice-user
15319 (gnus-message 7 "`A k' to list killed groups"))))))
15321 (defun gnus-subscribe-group (group previous &optional method)
15322 (gnus-group-change-level
15324 (list t group gnus-level-default-subscribed nil nil method)
15326 gnus-level-default-subscribed gnus-level-killed previous t))
15328 ;; `gnus-group-change-level' is the fundamental function for changing
15329 ;; subscription levels of newsgroups. This might mean just changing
15330 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15331 ;; again, which subscribes/unsubscribes a group, which is equally
15332 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15333 ;; from 8-9 to 1-7 means that you remove the group from the list of
15334 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15335 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15336 ;; which is trivial.
15337 ;; ENTRY can either be a string (newsgroup name) or a list (if
15338 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15339 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15341 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15342 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15344 (defun gnus-group-change-level (entry level &optional oldlevel
15345 previous fromkilled)
15346 (let (group info active num)
15347 ;; Glean what info we can from the arguments
15349 (if fromkilled (setq group (nth 1 entry))
15350 (setq group (car (nth 2 entry))))
15351 (setq group entry))
15352 (if (and (stringp entry)
15354 (< oldlevel gnus-level-zombie))
15355 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15356 (if (and (not oldlevel)
15358 (setq oldlevel (gnus-info-level (nth 2 entry)))
15359 (setq oldlevel (or oldlevel 9)))
15360 (if (stringp previous)
15361 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15363 (if (and (>= oldlevel gnus-level-zombie)
15364 (gnus-gethash group gnus-newsrc-hashtb))
15365 ;; We are trying to subscribe a group that is already
15369 (or (gnus-ephemeral-group-p group)
15370 (gnus-dribble-enter
15371 (format "(gnus-group-change-level %S %S %S %S %S)"
15372 group level oldlevel (car (nth 2 previous)) fromkilled)))
15374 ;; Then we remove the newgroup from any old structures, if needed.
15375 ;; If the group was killed, we remove it from the killed or zombie
15376 ;; list. If not, and it is in fact going to be killed, we remove
15377 ;; it from the newsrc hash table and assoc.
15379 ((>= oldlevel gnus-level-zombie)
15380 (if (= oldlevel gnus-level-zombie)
15381 (setq gnus-zombie-list (delete group gnus-zombie-list))
15382 (setq gnus-killed-list (delete group gnus-killed-list))))
15384 (if (and (>= level gnus-level-zombie)
15387 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15389 (setcdr (gnus-gethash (car (nth 3 entry))
15390 gnus-newsrc-hashtb)
15392 (setcdr (cdr entry) (cdddr entry))))))
15394 ;; Finally we enter (if needed) the list where it is supposed to
15395 ;; go, and change the subscription level. If it is to be killed,
15396 ;; we enter it into the killed or zombie list.
15398 ((>= level gnus-level-zombie)
15399 ;; Remove from the hash table.
15400 (gnus-sethash group nil gnus-newsrc-hashtb)
15401 ;; We do not enter foreign groups into the list of dead
15403 (unless (gnus-group-foreign-p group)
15404 (if (= level gnus-level-zombie)
15405 (setq gnus-zombie-list (cons group gnus-zombie-list))
15406 (setq gnus-killed-list (cons group gnus-killed-list)))))
15408 ;; If the list is to be entered into the newsrc assoc, and
15409 ;; it was killed, we have to create an entry in the newsrc
15410 ;; hashtb format and fix the pointers in the newsrc assoc.
15411 (if (< oldlevel gnus-level-zombie)
15412 ;; It was alive, and it is going to stay alive, so we
15413 ;; just change the level and don't change any pointers or
15414 ;; hash table entries.
15415 (setcar (cdaddr entry) level)
15417 (setq info (cdr entry)
15419 (setq active (gnus-active group))
15421 (if active (- (1+ (cdr active)) (car active)) t))
15422 ;; Check whether the group is foreign. If so, the
15423 ;; foreign select method has to be entered into the
15425 (let ((method (or gnus-override-subscribe-method
15426 (gnus-group-method group))))
15427 (if (eq method gnus-select-method)
15428 (setq info (list group level nil))
15429 (setq info (list group level nil nil method)))))
15432 (let ((p gnus-newsrc-alist))
15436 (setq entry (cons info (cddr previous)))
15439 (setcdr (cdr previous) entry)
15440 (gnus-sethash group (cons num (cdr previous))
15441 gnus-newsrc-hashtb))
15442 (setcdr previous entry)
15443 (gnus-sethash group (cons num previous)
15444 gnus-newsrc-hashtb))
15446 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15447 (when gnus-group-change-level-function
15448 (funcall gnus-group-change-level-function group level oldlevel)))))
15450 (defun gnus-kill-newsgroup (newsgroup)
15451 "Obsolete function. Kills a newsgroup."
15452 (gnus-group-change-level
15453 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15455 (defun gnus-check-bogus-newsgroups (&optional confirm)
15456 "Remove bogus newsgroups.
15457 If CONFIRM is non-nil, the user has to confirm the deletion of every
15459 (let ((newsrc (cdr gnus-newsrc-alist))
15460 bogus group entry info)
15461 (gnus-message 5 "Checking bogus newsgroups...")
15462 (unless gnus-have-read-active-file
15463 (gnus-read-active-file))
15464 (when (member gnus-select-method gnus-have-read-active-file)
15465 ;; Find all bogus newsgroup that are subscribed.
15467 (setq info (pop newsrc)
15468 group (gnus-info-group info))
15469 (unless (or (gnus-active group) ; Active
15470 (gnus-info-method info) ; Foreign
15472 (not (gnus-y-or-n-p
15473 (format "Remove bogus newsgroup: %s " group)))))
15474 ;; Found a bogus newsgroup.
15475 (push group bogus)))
15476 ;; Remove all bogus subscribed groups by first killing them, and
15477 ;; then removing them from the list of killed groups.
15479 (when (setq entry (gnus-gethash (setq group (pop bogus))
15480 gnus-newsrc-hashtb))
15481 (gnus-group-change-level entry gnus-level-killed)
15482 (setq gnus-killed-list (delete group gnus-killed-list))))
15483 ;; Then we remove all bogus groups from the list of killed and
15484 ;; zombie groups. They are are removed without confirmation.
15485 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15488 (setq killed (symbol-value (car dead-lists)))
15490 (unless (gnus-active (setq group (pop killed)))
15491 ;; The group is bogus.
15492 ;; !!!Slow as hell.
15493 (set (car dead-lists)
15494 (delete group (symbol-value (car dead-lists))))))
15495 (setq dead-lists (cdr dead-lists))))
15496 (gnus-message 5 "Checking bogus newsgroups...done"))))
15498 (defun gnus-check-duplicate-killed-groups ()
15499 "Remove duplicates from the list of killed groups."
15501 (let ((killed gnus-killed-list))
15503 (gnus-message 9 "%d" (length killed))
15504 (setcdr killed (delete (car killed) (cdr killed)))
15505 (setq killed (cdr killed)))))
15507 ;; We want to inline a function from gnus-cache, so we cheat here:
15510 (require 'gnus-cache))
15512 (defun gnus-get-unread-articles-in-group (info active &optional update)
15514 ;; Allow the backend to update the info in the group.
15516 (gnus-request-update-info
15517 info (gnus-find-method-for-group (gnus-info-group info))))
15518 (gnus-activate-group (gnus-info-group info) nil t))
15519 (let* ((range (gnus-info-read info))
15521 ;; If a cache is present, we may have to alter the active info.
15522 (when (and gnus-use-cache info)
15523 (inline (gnus-cache-possibly-alter-active
15524 (gnus-info-group info) active)))
15525 ;; Modify the list of read articles according to what articles
15526 ;; are available; then tally the unread articles and add the
15527 ;; number to the group hash table entry.
15529 ((zerop (cdr active))
15532 (setq num (- (1+ (cdr active)) (car active))))
15533 ((not (listp (cdr range)))
15534 ;; Fix a single (num . num) range according to the
15535 ;; active hash table.
15536 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15537 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15538 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15539 ;; Compute number of unread articles.
15540 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15542 ;; The read list is a list of ranges. Fix them according to
15543 ;; the active hash table.
15544 ;; First peel off any elements that are below the lower
15546 (while (and (cdr range)
15548 (or (and (atom (cadr range)) (cadr range))
15550 (if (numberp (car range))
15553 (or (and (numberp (cadr range))
15556 (setcdr (car range)
15557 (or (and (numberp (nth 1 range)) (nth 1 range))
15559 (setcdr range (cddr range)))
15560 ;; Adjust the first element to be the same as the lower limit.
15561 (if (and (not (atom (car range)))
15562 (< (cdar range) (car active)))
15563 (setcdr (car range) (1- (car active))))
15564 ;; Then we want to peel off any elements that are higher
15565 ;; than the upper active limit.
15566 (let ((srange range))
15567 ;; Go past all legal elements.
15568 (while (and (cdr srange)
15569 (<= (or (and (atom (cadr srange))
15571 (caadr srange)) (cdr active)))
15572 (setq srange (cdr srange)))
15574 ;; Nuke all remaining illegal elements.
15575 (setcdr srange nil))
15577 ;; Adjust the final element.
15578 (if (and (not (atom (car srange)))
15579 (> (cdar srange) (cdr active)))
15580 (setcdr (car srange) (cdr active))))
15581 ;; Compute the number of unread articles.
15583 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15585 (or (and (atom (car range)) (car range))
15587 (setq range (cdr range)))
15588 (setq num (max 0 (- (cdr active) num)))))
15589 ;; Set the number of unread articles.
15591 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15594 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15595 ;; and compute how many unread articles there are in each group.
15596 (defun gnus-get-unread-articles (&optional level)
15597 (let* ((newsrc (cdr gnus-newsrc-alist))
15598 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15601 (cond ((and gnus-activate-foreign-newsgroups
15602 (not (numberp gnus-activate-foreign-newsgroups)))
15603 (1+ gnus-level-subscribed))
15604 ((numberp gnus-activate-foreign-newsgroups)
15605 gnus-activate-foreign-newsgroups)
15608 info group active method)
15609 (gnus-message 5 "Checking new news...")
15612 (setq active (gnus-active (setq group (gnus-info-group
15613 (setq info (pop newsrc))))))
15615 ;; Check newsgroups. If the user doesn't want to check them, or
15616 ;; they can't be checked (for instance, if the news server can't
15617 ;; be reached) we just set the number of unread articles in this
15618 ;; newsgroup to t. This means that Gnus thinks that there are
15619 ;; unread articles, but it has no idea how many.
15620 (if (and (setq method (gnus-info-method info))
15621 (not (gnus-server-equal
15623 (setq method (gnus-server-get-method nil method))))
15624 (not (gnus-secondary-method-p method)))
15625 ;; These groups are foreign. Check the level.
15626 (when (<= (gnus-info-level info) foreign-level)
15627 (setq active (gnus-activate-group group 'scan))
15628 (unless (inline (gnus-virtual-group-p group))
15629 (inline (gnus-close-group group))))
15631 ;; These groups are native or secondary.
15632 (when (and (<= (gnus-info-level info) level)
15633 (not gnus-read-active-file))
15634 (setq active (gnus-activate-group group 'scan))
15635 (inline (gnus-close-group group))))
15638 (inline (gnus-get-unread-articles-in-group
15641 (fboundp (intern (concat (symbol-name (car method))
15642 "-request-update-info"))))))
15643 ;; The group couldn't be reached, so we nix out the number of
15644 ;; unread articles and stuff.
15645 (gnus-set-active group nil)
15646 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15648 (gnus-message 5 "Checking new news...done")))
15650 ;; Create a hash table out of the newsrc alist. The `car's of the
15651 ;; alist elements are used as keys.
15652 (defun gnus-make-hashtable-from-newsrc-alist ()
15653 (let ((alist gnus-newsrc-alist)
15654 (ohashtb gnus-newsrc-hashtb)
15656 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15658 (setq prev (setq gnus-newsrc-alist
15659 (if (equal (caar gnus-newsrc-alist)
15662 (cons (list "dummy.group" 0 nil) alist)))))
15666 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15668 gnus-newsrc-hashtb)
15670 alist (cdr alist)))))
15672 (defun gnus-make-hashtable-from-killed ()
15673 "Create a hash table from the killed and zombie lists."
15674 (let ((lists '(gnus-killed-list gnus-zombie-list))
15676 (setq gnus-killed-hashtb
15677 (gnus-make-hashtable
15678 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15679 (while (setq list (pop lists))
15680 (setq list (symbol-value list))
15682 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15684 (defun gnus-activate-group (group &optional scan dont-check)
15685 ;; Check whether a group has been activated or not.
15686 ;; If SCAN, request a scan of that group as well.
15687 (let ((method (gnus-find-method-for-group group))
15689 (and (gnus-check-server method)
15690 ;; We escape all bugs and quit here to make it possible to
15691 ;; continue if a group is so out-there that it reports bugs
15695 (gnus-check-backend-function 'request-scan (car method))
15696 (gnus-request-scan group method))
15699 (gnus-request-group group dont-check)
15703 (set-buffer nntp-server-buffer)
15704 (goto-char (point-min))
15705 ;; Parse the result we got from `gnus-request-group'.
15706 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15708 (goto-char (match-beginning 1))
15710 group (setq active (cons (read (current-buffer))
15711 (read (current-buffer)))))
15712 ;; Return the new active info.
15715 (defun gnus-update-read-articles (group unread)
15716 "Update the list of read and ticked articles in GROUP using the
15717 UNREAD and TICKED lists.
15718 Note: UNSELECTED has to be sorted over `<'.
15719 Returns whether the updating was successful."
15720 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15721 (entry (gnus-gethash group gnus-newsrc-hashtb))
15722 (info (nth 2 entry))
15724 (unread (sort (copy-sequence unread) '<))
15726 (if (or (not info) (not active))
15727 ;; There is no info on this group if it was, in fact,
15728 ;; killed. Gnus stores no information on killed groups, so
15729 ;; there's nothing to be done.
15730 ;; One could store the information somewhere temporarily,
15731 ;; perhaps... Hmmm...
15733 ;; Remove any negative articles numbers.
15734 (while (and unread (< (car unread) 0))
15735 (setq unread (cdr unread)))
15736 ;; Remove any expired article numbers
15737 (while (and unread (< (car unread) (car active)))
15738 (setq unread (cdr unread)))
15739 ;; Compute the ranges of read articles by looking at the list of
15740 ;; unread articles.
15742 (if (/= (car unread) prev)
15743 (setq read (cons (if (= prev (1- (car unread))) prev
15744 (cons prev (1- (car unread)))) read)))
15745 (setq prev (1+ (car unread)))
15746 (setq unread (cdr unread)))
15747 (when (<= prev (cdr active))
15748 (setq read (cons (cons prev (cdr active)) read)))
15749 ;; Enter this list into the group info.
15750 (gnus-info-set-read
15751 info (if (> (length read) 1) (nreverse read) read))
15752 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15753 (gnus-get-unread-articles-in-group info (gnus-active group))
15756 (defun gnus-make-articles-unread (group articles)
15757 "Mark ARTICLES in GROUP as unread."
15758 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15759 (gnus-gethash (gnus-group-real-name group)
15760 gnus-newsrc-hashtb))))
15761 (ranges (gnus-info-read info))
15764 (when (gnus-member-of-range
15765 (setq article (pop articles)) ranges)
15766 (setq news (cons article news))))
15768 (gnus-info-set-read
15769 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15770 (gnus-group-update-group group t))))
15772 ;; Enter all dead groups into the hashtb.
15773 (defun gnus-update-active-hashtb-from-killed ()
15774 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15775 (lists (list gnus-killed-list gnus-zombie-list))
15778 (setq killed (car lists))
15780 (gnus-sethash (car killed) nil hashtb)
15781 (setq killed (cdr killed)))
15782 (setq lists (cdr lists)))))
15784 ;; Get the active file(s) from the backend(s).
15785 (defun gnus-read-active-file ()
15786 (gnus-group-set-mode-line)
15789 (if (gnus-check-server gnus-select-method)
15790 ;; The native server is available.
15791 (cons gnus-select-method gnus-secondary-select-methods)
15792 ;; The native server is down, so we just do the
15794 gnus-secondary-select-methods)
15795 ;; Also read from the archive server.
15796 (when gnus-message-archive-method
15797 (list "archive"))))
15799 (setq gnus-have-read-active-file nil)
15801 (set-buffer nntp-server-buffer)
15803 (let* ((method (if (stringp (car methods))
15804 (gnus-server-get-method nil (car methods))
15806 (where (nth 1 method))
15807 (mesg (format "Reading active file%s via %s..."
15808 (if (and where (not (zerop (length where))))
15809 (concat " from " where) "")
15811 (gnus-message 5 mesg)
15812 (when (gnus-check-server method)
15813 ;; Request that the backend scan its incoming messages.
15814 (and (gnus-check-backend-function 'request-scan (car method))
15815 (gnus-request-scan nil method))
15817 ((and (eq gnus-read-active-file 'some)
15818 (gnus-check-backend-function 'retrieve-groups (car method)))
15819 (let ((newsrc (cdr gnus-newsrc-alist))
15820 (gmethod (gnus-server-get-method nil method))
15822 (while (setq info (pop newsrc))
15823 (when (gnus-server-equal
15824 (gnus-find-method-for-group
15825 (gnus-info-group info) info)
15827 (push (gnus-group-real-name (gnus-info-group info))
15830 (gnus-check-server method)
15831 (setq list-type (gnus-retrieve-groups groups method))
15835 1.2 "Cannot read partial active file from %s server."
15837 ((eq list-type 'active)
15838 (gnus-active-to-gnus-format method gnus-active-hashtb))
15840 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15842 (if (not (gnus-request-list method))
15843 (unless (equal method gnus-message-archive-method)
15844 (gnus-error 1 "Cannot read active file from %s server."
15846 (gnus-active-to-gnus-format method gnus-active-hashtb)
15847 ;; We mark this active file as read.
15848 (push method gnus-have-read-active-file)
15849 (gnus-message 5 "%sdone" mesg))))))
15850 (setq methods (cdr methods))))))
15852 ;; Read an active file and place the results in `gnus-active-hashtb'.
15853 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15855 (setq method gnus-select-method))
15856 (let ((cur (current-buffer))
15858 (if (and gnus-active-hashtb
15859 (not (equal method gnus-select-method)))
15861 (setq gnus-active-hashtb
15862 (if (equal method gnus-select-method)
15863 (gnus-make-hashtable
15864 (count-lines (point-min) (point-max)))
15865 (gnus-make-hashtable 4096)))))))
15866 ;; Delete unnecessary lines.
15867 (goto-char (point-min))
15868 (while (search-forward "\nto." nil t)
15869 (delete-region (1+ (match-beginning 0))
15870 (progn (forward-line 1) (point))))
15871 (or (string= gnus-ignored-newsgroups "")
15873 (goto-char (point-min))
15874 (delete-matching-lines gnus-ignored-newsgroups)))
15875 ;; Make the group names readable as a lisp expression even if they
15876 ;; contain special characters.
15877 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15878 (goto-char (point-max))
15879 (while (re-search-backward "[][';?()#]" nil t)
15881 ;; If these are groups from a foreign select method, we insert the
15882 ;; group prefix in front of the group names.
15883 (and method (not (gnus-server-equal
15884 (gnus-server-get-method nil method)
15885 (gnus-server-get-method nil gnus-select-method)))
15886 (let ((prefix (gnus-group-prefixed-name "" method)))
15887 (goto-char (point-min))
15888 (while (and (not (eobp))
15889 (progn (insert prefix)
15890 (zerop (forward-line 1)))))))
15891 ;; Store the active file in a hash table.
15892 (goto-char (point-min))
15893 (if (string-match "%[oO]" gnus-group-line-format)
15894 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15895 ;; If we want information on moderated groups, we use this
15897 (let* ((mod-hashtb (make-vector 7 0))
15898 (m (intern "m" mod-hashtb))
15900 (while (not (eobp))
15901 (condition-case nil
15903 (narrow-to-region (point) (gnus-point-at-eol))
15904 (setq group (let ((obarray hashtb)) (read cur)))
15905 (if (and (numberp (setq max (read cur)))
15906 (numberp (setq min (read cur)))
15908 (skip-chars-forward " \t")
15910 (or (= (following-char) ?=)
15911 (= (following-char) ?x)
15912 (= (following-char) ?j)))))
15913 (set group (cons min max))
15915 ;; Enter moderated groups into a list.
15916 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15917 (setq gnus-moderated-list
15918 (cons (symbol-name group) gnus-moderated-list))))
15925 ;; And if we do not care about moderation, we use this loop,
15926 ;; which is faster.
15927 (let (group max min)
15928 (while (not (eobp))
15931 (narrow-to-region (point) (gnus-point-at-eol))
15932 ;; group gets set to a symbol interned in the hash table
15933 ;; (what a hack!!) - jwz
15934 (setq group (let ((obarray hashtb)) (read cur)))
15935 (if (and (numberp (setq max (read cur)))
15936 (numberp (setq min (read cur)))
15938 (skip-chars-forward " \t")
15940 (or (= (following-char) ?=)
15941 (= (following-char) ?x)
15942 (= (following-char) ?j)))))
15943 (set group (cons min max))
15951 (gnus-message 3 "Warning - illegal active: %s"
15953 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15955 (forward-line 1))))))
15957 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15958 ;; Parse a "groups" active file.
15959 (let ((cur (current-buffer))
15961 (if (and method gnus-active-hashtb)
15963 (setq gnus-active-hashtb
15964 (gnus-make-hashtable
15965 (count-lines (point-min) (point-max)))))))
15966 (prefix (and method
15967 (not (gnus-server-equal
15968 (gnus-server-get-method nil method)
15969 (gnus-server-get-method nil gnus-select-method)))
15970 (gnus-group-prefixed-name "" method))))
15972 (goto-char (point-min))
15973 ;; We split this into to separate loops, one with the prefix
15974 ;; and one without to speed the reading up somewhat.
15976 (let (min max opoint group)
15977 (while (not (eobp))
15980 (read cur) (read cur)
15981 (setq min (read cur)
15984 (skip-chars-forward " \t")
15987 (set (let ((obarray hashtb)) (read cur))
15989 (error (and group (symbolp group) (set group nil))))
15991 (let (min max group)
15992 (while (not (eobp))
15994 (if (= (following-char) ?2)
15996 (read cur) (read cur)
15997 (setq min (read cur)
15999 (set (setq group (let ((obarray hashtb)) (read cur)))
16001 (error (and group (symbolp group) (set group nil))))
16002 (forward-line 1))))))
16004 (defun gnus-read-newsrc-file (&optional force)
16005 "Read startup file.
16006 If FORCE is non-nil, the .newsrc file is read."
16007 ;; Reset variables that might be defined in the .newsrc.eld file.
16008 (let ((variables gnus-variable-list))
16010 (set (car variables) nil)
16011 (setq variables (cdr variables))))
16012 (let* ((newsrc-file gnus-current-startup-file)
16013 (quick-file (concat newsrc-file ".el")))
16015 ;; We always load the .newsrc.eld file. If always contains
16016 ;; much information that can not be gotten from the .newsrc
16017 ;; file (ticked articles, killed groups, foreign methods, etc.)
16018 (gnus-read-newsrc-el-file quick-file)
16020 (if (and (file-exists-p gnus-current-startup-file)
16022 (and (file-newer-than-file-p newsrc-file quick-file)
16023 (file-newer-than-file-p newsrc-file
16024 (concat quick-file "d")))
16025 (not gnus-newsrc-alist)))
16026 ;; We read the .newsrc file. Note that if there if a
16027 ;; .newsrc.eld file exists, it has already been read, and
16028 ;; the `gnus-newsrc-hashtb' has been created. While reading
16029 ;; the .newsrc file, Gnus will only use the information it
16030 ;; can find there for changing the data already read -
16031 ;; ie. reading the .newsrc file will not trash the data
16032 ;; already read (except for read articles).
16034 (gnus-message 5 "Reading %s..." newsrc-file)
16035 (set-buffer (find-file-noselect newsrc-file))
16036 (buffer-disable-undo (current-buffer))
16037 (gnus-newsrc-to-gnus-format)
16038 (kill-buffer (current-buffer))
16039 (gnus-message 5 "Reading %s...done" newsrc-file)))
16041 ;; Read any slave files.
16043 (gnus-master-read-slave-newsrc))
16045 ;; Convert old to new.
16046 (gnus-convert-old-newsrc))))
16048 (defun gnus-continuum-version (version)
16049 "Return VERSION as a floating point number."
16050 (when (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16051 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16052 (number (match-string 2 version))
16054 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16055 (setq major (string-to-number (match-string 1 number)))
16056 (setq minor (string-to-number (match-string 2 number)))
16057 (setq least (if (match-beginning 3)
16058 (string-to-number (match-string 3 number))
16062 (format "%s00%02d%02d"
16064 ((string= alpha "(ding)") "4.99")
16065 ((string= alpha "September") "5.01")
16066 ((string= alpha "Red") "5.03"))
16068 (format "%d.%02d%20d" major minor least))))))
16070 (defun gnus-convert-old-newsrc ()
16071 "Convert old newsrc into the new format, if needed."
16072 (let ((fcv (gnus-continuum-version gnus-newsrc-file-version)))
16074 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16075 (gnus-convert-old-ticks)))))
16077 (defun gnus-convert-old-ticks ()
16078 (let ((newsrc (cdr gnus-newsrc-alist))
16079 marks info dormant ticked)
16080 (while (setq info (pop newsrc))
16081 (when (setq marks (gnus-info-marks info))
16082 (setq dormant (cdr (assq 'dormant marks))
16083 ticked (cdr (assq 'tick marks)))
16084 (when (or dormant ticked)
16085 (gnus-info-set-read
16088 (gnus-info-read info)
16089 (nconc (gnus-uncompress-range dormant)
16090 (gnus-uncompress-range ticked)))))))))
16092 (defun gnus-read-newsrc-el-file (file)
16093 (let ((ding-file (concat file "d")))
16094 ;; We always, always read the .eld file.
16095 (gnus-message 5 "Reading %s..." ding-file)
16096 (let (gnus-newsrc-assoc)
16097 (condition-case nil
16098 (load ding-file t t t)
16100 (gnus-error 1 "Error in %s" ding-file)))
16101 (when gnus-newsrc-assoc
16102 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16103 (gnus-make-hashtable-from-newsrc-alist)
16104 (when (file-newer-than-file-p file ding-file)
16105 ;; Old format quick file
16106 (gnus-message 5 "Reading %s..." file)
16107 ;; The .el file is newer than the .eld file, so we read that one
16109 (gnus-read-old-newsrc-el-file file))))
16111 ;; Parse the old-style quick startup file
16112 (defun gnus-read-old-newsrc-el-file (file)
16113 (let (newsrc killed marked group m info)
16115 (let ((gnus-killed-assoc nil)
16116 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16118 (condition-case nil
16121 (setq newsrc gnus-newsrc-assoc
16122 killed gnus-killed-assoc
16123 marked gnus-marked-assoc)))
16124 (setq gnus-newsrc-alist nil)
16125 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16128 (gnus-info-set-read info (cddr group))
16129 (gnus-info-set-level
16130 info (if (nth 1 group) gnus-level-default-subscribed
16131 gnus-level-default-unsubscribed))
16132 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16135 (if (nth 1 group) gnus-level-default-subscribed
16136 gnus-level-default-unsubscribed)
16138 gnus-newsrc-alist))
16139 ;; Copy marks into info.
16140 (when (setq m (assoc (car group) marked))
16141 (unless (nthcdr 3 info)
16142 (nconc info (list nil)))
16143 (gnus-info-set-marks
16144 info (list (cons 'tick (gnus-compress-sequence
16145 (sort (cdr m) '<) t))))))
16146 (setq newsrc killed)
16148 (setcar newsrc (caar newsrc))
16149 (setq newsrc (cdr newsrc)))
16150 (setq gnus-killed-list killed))
16151 ;; The .el file version of this variable does not begin with
16152 ;; "options", while the .eld version does, so we just add it if it
16155 gnus-newsrc-options
16157 (and (not (string-match "^ *options" gnus-newsrc-options))
16158 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16159 (and (not (string-match "\n$" gnus-newsrc-options))
16160 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16161 ;; Finally, if we read some options lines, we parse them.
16162 (or (string= gnus-newsrc-options "")
16163 (gnus-newsrc-parse-options gnus-newsrc-options))))
16165 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16166 (gnus-make-hashtable-from-newsrc-alist)))
16168 (defun gnus-make-newsrc-file (file)
16169 "Make server dependent file name by catenating FILE and server host name."
16170 (let* ((file (expand-file-name file nil))
16171 (real-file (concat file "-" (nth 1 gnus-select-method))))
16172 (if (or (file-exists-p real-file)
16173 (file-exists-p (concat real-file ".el"))
16174 (file-exists-p (concat real-file ".eld")))
16177 (defun gnus-newsrc-to-gnus-format ()
16178 (setq gnus-newsrc-options "")
16179 (setq gnus-newsrc-options-n nil)
16181 (or gnus-active-hashtb
16182 (setq gnus-active-hashtb (make-vector 4095 0)))
16183 (let ((buf (current-buffer))
16184 (already-read (> (length gnus-newsrc-alist) 1))
16185 group subscribed options-symbol newsrc Options-symbol
16187 (goto-char (point-min))
16188 ;; We intern the symbol `options' in the active hashtb so that we
16189 ;; can `eq' against it later.
16190 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16191 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16193 (while (not (eobp))
16194 ;; We first read the first word on the line by narrowing and
16195 ;; then reading into `gnus-active-hashtb'. Most groups will
16196 ;; already exist in that hashtb, so this will save some string
16200 (progn (skip-chars-forward "^ \t!:\n") (point)))
16201 (goto-char (point-min))
16203 (and (/= (point-min) (point-max))
16204 (let ((obarray gnus-active-hashtb)) (read buf))))
16206 ;; Now, the symbol we have read is either `options' or a group
16207 ;; name. If it is an options line, we just add it to a string.
16209 ((or (eq symbol options-symbol)
16210 (eq symbol Options-symbol))
16211 (setq gnus-newsrc-options
16212 ;; This concating is quite inefficient, but since our
16213 ;; thorough studies show that approx 99.37% of all
16214 ;; .newsrc files only contain a single options line, we
16215 ;; don't give a damn, frankly, my dear.
16216 (concat gnus-newsrc-options
16218 (gnus-point-at-bol)
16219 ;; Options may continue on the next line.
16220 (or (and (re-search-forward "^[^ \t]" nil 'move)
16221 (progn (beginning-of-line) (point)))
16225 ;; Group names can be just numbers.
16226 (when (numberp symbol)
16227 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16228 (or (boundp symbol) (set symbol nil))
16229 ;; It was a group name.
16230 (setq subscribed (= (following-char) ?:)
16231 group (symbol-name symbol)
16234 ;; If the line ends here, this is clearly a buggy line, so
16235 ;; we put point a the beginning of line and let the cond
16236 ;; below do the error handling.
16237 (beginning-of-line)
16238 ;; We skip to the beginning of the ranges.
16239 (skip-chars-forward "!: \t"))
16240 ;; We are now at the beginning of the list of read articles.
16241 ;; We read them range by range.
16244 ((looking-at "[0-9]+")
16245 ;; We narrow and read a number instead of buffer-substring/
16246 ;; string-to-int because it's faster. narrow/widen is
16247 ;; faster than save-restriction/narrow, and save-restriction
16248 ;; produces a garbage object.
16250 (narrow-to-region (match-beginning 0) (match-end 0))
16253 ;; If the next character is a dash, then this is a range.
16254 (if (= (following-char) ?-)
16256 ;; We read the upper bound of the range.
16258 (if (not (looking-at "[0-9]+"))
16259 ;; This is a buggy line, by we pretend that
16260 ;; it's kinda OK. Perhaps the user should be
16262 (setq reads (cons num1 reads))
16267 (narrow-to-region (match-beginning 0)
16272 ;; It was just a simple number, so we add it to the
16274 (setq reads (cons num1 reads)))
16275 ;; If the next char in ?\n, then we have reached the end
16276 ;; of the line and return nil.
16277 (/= (following-char) ?\n))
16278 ((= (following-char) ?\n)
16279 ;; End of line, so we end.
16282 ;; Not numbers and not eol, so this might be a buggy
16285 ;; If it was eob instead of ?\n, we allow it.
16287 ;; The line was buggy.
16289 (gnus-error 3.1 "Mangled line: %s"
16290 (buffer-substring (gnus-point-at-bol)
16291 (gnus-point-at-eol)))))
16293 ;; Skip past ", ". Spaces are illegal in these ranges, but
16294 ;; we allow them, because it's a common mistake to put a
16295 ;; space after the comma.
16296 (skip-chars-forward ", "))
16298 ;; We have already read .newsrc.eld, so we gently update the
16299 ;; data in the hash table with the information we have just
16302 (let ((info (gnus-get-info group))
16305 ;; There is an entry for this file in the alist.
16307 (gnus-info-set-read info (nreverse reads))
16308 ;; We update the level very gently. In fact, we
16309 ;; only change it if there's been a status change
16310 ;; from subscribed to unsubscribed, or vice versa.
16311 (setq level (gnus-info-level info))
16312 (cond ((and (<= level gnus-level-subscribed)
16314 (setq level (if reads
16315 gnus-level-default-unsubscribed
16316 (1+ gnus-level-default-unsubscribed))))
16317 ((and (> level gnus-level-subscribed) subscribed)
16318 (setq level gnus-level-default-subscribed)))
16319 (gnus-info-set-level info level))
16320 ;; This is a new group.
16321 (setq info (list group
16323 gnus-level-default-subscribed
16325 (1+ gnus-level-subscribed)
16326 gnus-level-default-unsubscribed))
16327 (nreverse reads))))
16328 (setq newsrc (cons info newsrc))))))
16331 (setq newsrc (nreverse newsrc))
16333 (if (not already-read)
16335 ;; We now have two newsrc lists - `newsrc', which is what we
16336 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16337 ;; what we've read from .newsrc.eld. We have to merge these
16338 ;; lists. We do this by "attaching" any (foreign) groups in the
16339 ;; gnus-newsrc-alist to the (native) group that precedes them.
16340 (let ((rc (cdr gnus-newsrc-alist))
16341 (prev gnus-newsrc-alist)
16344 (or (null (nth 4 (car rc))) ; It's a native group.
16345 (assoc (caar rc) newsrc) ; It's already in the alist.
16346 (if (setq entry (assoc (caar prev) newsrc))
16347 (setcdr (setq mentry (memq entry newsrc))
16348 (cons (car rc) (cdr mentry)))
16349 (setq newsrc (cons (car rc) newsrc))))
16353 (setq gnus-newsrc-alist newsrc)
16354 ;; We make the newsrc hashtb.
16355 (gnus-make-hashtable-from-newsrc-alist)
16357 ;; Finally, if we read some options lines, we parse them.
16358 (or (string= gnus-newsrc-options "")
16359 (gnus-newsrc-parse-options gnus-newsrc-options))))
16361 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16362 ;; The return value will be a list on the form
16363 ;; ((regexp1 . ignore)
16364 ;; (regexp2 . subscribe)...)
16365 ;; When handling new newsgroups, groups that match a `ignore' regexp
16366 ;; will be ignored, and groups that match a `subscribe' regexp will be
16367 ;; subscribed. A line like
16368 ;; options -n !all rec.all
16369 ;; will lead to a list that looks like
16370 ;; (("^rec\\..+" . subscribe)
16371 ;; ("^.+" . ignore))
16372 ;; So all "rec.*" groups will be subscribed, while all the other
16373 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16374 ;; different from "options -n rec.all !all".
16375 (defun gnus-newsrc-parse-options (options)
16378 (gnus-set-work-buffer)
16379 (insert (regexp-quote options))
16380 ;; First we treat all continuation lines.
16381 (goto-char (point-min))
16382 (while (re-search-forward "\n[ \t]+" nil t)
16383 (replace-match " " t t))
16384 ;; Then we transform all "all"s into ".+"s.
16385 (goto-char (point-min))
16386 (while (re-search-forward "\\ball\\b" nil t)
16387 (replace-match ".+" t t))
16388 (goto-char (point-min))
16389 ;; We remove all other options than the "-n" ones.
16390 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16391 (replace-match " ")
16393 (goto-char (point-min))
16395 ;; We are only interested in "options -n" lines - we
16396 ;; ignore the other option lines.
16397 (while (re-search-forward "[ \t]-n" nil t)
16399 (or (save-excursion
16400 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16402 (gnus-point-at-eol)))
16403 ;; Search for all "words"...
16404 (while (re-search-forward "[^ \t,\n]+" eol t)
16405 (if (= (char-after (match-beginning 0)) ?!)
16406 ;; If the word begins with a bang (!), this is a "not"
16407 ;; spec. We put this spec (minus the bang) and the
16408 ;; symbol `ignore' into the list.
16409 (setq out (cons (cons (concat
16410 "^" (buffer-substring
16411 (1+ (match-beginning 0))
16414 ;; There was no bang, so this is a "yes" spec.
16415 (setq out (cons (cons (concat "^" (match-string 0))
16416 'subscribe) out)))))
16418 (setq gnus-newsrc-options-n out))))
16420 (defun gnus-save-newsrc-file (&optional force)
16421 "Save .newsrc file."
16422 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16423 ;; from the variable gnus-newsrc-alist.
16424 (when (and (or gnus-newsrc-alist gnus-killed-list)
16425 gnus-current-startup-file)
16427 (if (and (or gnus-use-dribble-file gnus-slave)
16429 (or (not gnus-dribble-buffer)
16430 (not (buffer-name gnus-dribble-buffer))
16431 (zerop (save-excursion
16432 (set-buffer gnus-dribble-buffer)
16434 (gnus-message 4 "(No changes need to be saved)")
16435 (run-hooks 'gnus-save-newsrc-hook)
16437 (gnus-slave-save-newsrc)
16439 (when gnus-save-newsrc-file
16440 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16441 (gnus-gnus-to-newsrc-format)
16442 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16443 ;; Save .newsrc.eld.
16444 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16445 (make-local-variable 'version-control)
16446 (setq version-control 'never)
16447 (setq buffer-file-name
16448 (concat gnus-current-startup-file ".eld"))
16449 (gnus-add-current-to-buffer-list)
16450 (buffer-disable-undo (current-buffer))
16452 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16453 (gnus-gnus-to-quick-newsrc-format)
16454 (run-hooks 'gnus-save-quick-newsrc-hook)
16456 (kill-buffer (current-buffer))
16458 5 "Saving %s.eld...done" gnus-current-startup-file))
16459 (gnus-dribble-delete-file)))))
16461 (defun gnus-gnus-to-quick-newsrc-format ()
16462 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16463 (insert ";; Gnus startup file.\n")
16464 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16465 (insert ";; to read .newsrc.\n")
16466 (insert "(setq gnus-newsrc-file-version "
16467 (prin1-to-string gnus-version) ")\n")
16469 (if gnus-save-killed-list gnus-variable-list
16470 ;; Remove the `gnus-killed-list' from the list of variables
16471 ;; to be saved, if required.
16472 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16473 ;; Peel off the "dummy" group.
16474 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16476 ;; Insert the variables into the file.
16478 (when (and (boundp (setq variable (pop variables)))
16479 (symbol-value variable))
16480 (insert "(setq " (symbol-name variable) " '")
16481 (prin1 (symbol-value variable) (current-buffer))
16484 (defun gnus-gnus-to-newsrc-format ()
16485 ;; Generate and save the .newsrc file.
16487 (set-buffer (create-file-buffer gnus-current-startup-file))
16488 (let ((newsrc (cdr gnus-newsrc-alist))
16489 (standard-output (current-buffer))
16490 info ranges range method)
16491 (setq buffer-file-name gnus-current-startup-file)
16492 (buffer-disable-undo (current-buffer))
16495 (if gnus-newsrc-options (insert gnus-newsrc-options))
16496 ;; Write subscribed and unsubscribed.
16497 (while (setq info (pop newsrc))
16498 ;; Don't write foreign groups to .newsrc.
16499 (when (or (null (setq method (gnus-info-method info)))
16500 (equal method "native")
16501 (gnus-server-equal method gnus-select-method))
16502 (insert (gnus-info-group info)
16503 (if (> (gnus-info-level info) gnus-level-subscribed)
16505 (when (setq ranges (gnus-info-read info))
16507 (if (not (listp (cdr ranges)))
16508 (if (= (car ranges) (cdr ranges))
16509 (princ (car ranges))
16510 (princ (car ranges))
16512 (princ (cdr ranges)))
16513 (while (setq range (pop ranges))
16514 (if (or (atom range) (= (car range) (cdr range)))
16515 (princ (or (and (atom range) range) (car range)))
16516 (princ (car range))
16518 (princ (cdr range)))
16519 (if ranges (insert ",")))))
16521 (make-local-variable 'version-control)
16522 (setq version-control 'never)
16523 ;; It has been reported that sometime the modtime on the .newsrc
16524 ;; file seems to be off. We really do want to overwrite it, so
16525 ;; we clear the modtime here before saving. It's a bit odd,
16527 ;; sometimes the modtime clear isn't sufficient. most brute force:
16528 ;; delete the silly thing entirely first. but this fails to provide
16529 ;; such niceties as .newsrc~ creation.
16530 (if gnus-modtime-botch
16531 (delete-file gnus-startup-file)
16532 (clear-visited-file-modtime))
16533 (run-hooks 'gnus-save-standard-newsrc-hook)
16535 (kill-buffer (current-buffer)))))
16539 ;;; Slave functions.
16542 (defun gnus-slave-save-newsrc ()
16544 (set-buffer gnus-dribble-buffer)
16546 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16547 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16549 (defun gnus-master-read-slave-newsrc ()
16552 (file-name-directory gnus-current-startup-file)
16556 (file-name-nondirectory gnus-current-startup-file)
16560 (if (not slave-files)
16561 () ; There are no slave files to read.
16562 (gnus-message 7 "Reading slave newsrcs...")
16564 (set-buffer (get-buffer-create " *gnus slave*"))
16565 (buffer-disable-undo (current-buffer))
16567 (sort (mapcar (lambda (file)
16568 (list (nth 5 (file-attributes file)) file))
16571 (or (< (caar f1) (caar f2))
16572 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16575 (setq file (nth 1 (car slave-files)))
16576 (insert-file-contents file)
16577 (if (condition-case ()
16579 (eval-buffer (current-buffer))
16582 (gnus-error 3.2 "Possible error in %s" file)
16584 (or gnus-slave ; Slaves shouldn't delete these files.
16588 (setq slave-files (cdr slave-files))))
16589 (gnus-message 7 "Reading slave newsrcs...done"))))
16593 ;;; Group description.
16596 (defun gnus-read-all-descriptions-files ()
16597 (let ((methods (cons gnus-select-method
16599 (when gnus-message-archive-method
16601 gnus-secondary-select-methods))))
16603 (gnus-read-descriptions-file (car methods))
16604 (setq methods (cdr methods)))
16607 (defun gnus-read-descriptions-file (&optional method)
16608 (let ((method (or method gnus-select-method)))
16609 (when (stringp method)
16610 (setq method (gnus-server-to-method method)))
16611 ;; We create the hashtable whether we manage to read the desc file
16612 ;; to avoid trying to re-read after a failed read.
16613 (or gnus-description-hashtb
16614 (setq gnus-description-hashtb
16615 (gnus-make-hashtable (length gnus-active-hashtb))))
16616 ;; Mark this method's desc file as read.
16617 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16618 gnus-description-hashtb)
16620 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16622 ((not (gnus-check-server method))
16623 (gnus-message 1 "Couldn't open server")
16625 ((not (gnus-request-list-newsgroups method))
16626 (gnus-message 1 "Couldn't read newsgroups descriptions")
16632 (set-buffer nntp-server-buffer)
16633 (goto-char (point-min))
16634 (if (or (search-forward "\n.\n" nil t)
16635 (goto-char (point-max)))
16637 (beginning-of-line)
16638 (narrow-to-region (point-min) (point))))
16639 (goto-char (point-min))
16640 (while (not (eobp))
16641 ;; If we get an error, we set group to 0, which is not a
16645 (let ((obarray gnus-description-hashtb))
16646 ;; Group is set to a symbol interned in this
16648 (read nntp-server-buffer))
16650 (skip-chars-forward " \t")
16651 ;; ... which leads to this line being effectively ignored.
16652 (and (symbolp group)
16653 (set group (buffer-substring
16654 (point) (progn (end-of-line) (point)))))
16655 (forward-line 1))))
16656 (gnus-message 5 "Reading descriptions file...done")
16659 (defun gnus-group-get-description (group)
16660 "Get the description of a group by sending XGTITLE to the server."
16661 (when (gnus-request-group-description group)
16663 (set-buffer nntp-server-buffer)
16664 (goto-char (point-min))
16665 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16666 (match-string 1)))))
16670 ;;; Buffering of read articles.
16673 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16674 (defvar gnus-backlog-articles nil)
16675 (defvar gnus-backlog-hashtb nil)
16677 (defun gnus-backlog-buffer ()
16678 "Return the backlog buffer."
16679 (or (get-buffer gnus-backlog-buffer)
16681 (set-buffer (get-buffer-create gnus-backlog-buffer))
16682 (buffer-disable-undo (current-buffer))
16683 (setq buffer-read-only t)
16684 (gnus-add-current-to-buffer-list)
16685 (get-buffer gnus-backlog-buffer))))
16687 (defun gnus-backlog-setup ()
16688 "Initialize backlog variables."
16689 (unless gnus-backlog-hashtb
16690 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16692 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16694 (defun gnus-backlog-shutdown ()
16695 "Clear all backlog variables and buffers."
16696 (when (get-buffer gnus-backlog-buffer)
16697 (kill-buffer gnus-backlog-buffer))
16698 (setq gnus-backlog-hashtb nil
16699 gnus-backlog-articles nil))
16701 (defun gnus-backlog-enter-article (group number buffer)
16702 (gnus-backlog-setup)
16703 (let ((ident (intern (concat group ":" (int-to-string number))
16704 gnus-backlog-hashtb))
16706 (if (memq ident gnus-backlog-articles)
16707 () ; It's already kept.
16708 ;; Remove the oldest article, if necessary.
16709 (and (numberp gnus-keep-backlog)
16710 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16711 (gnus-backlog-remove-oldest-article))
16712 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16713 ;; Insert the new article.
16715 (set-buffer (gnus-backlog-buffer))
16716 (let (buffer-read-only)
16717 (goto-char (point-max))
16718 (or (bolp) (insert "\n"))
16720 (insert-buffer-substring buffer)
16721 ;; Tag the beginning of the article with the ident.
16722 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16724 (defun gnus-backlog-remove-oldest-article ()
16726 (set-buffer (gnus-backlog-buffer))
16727 (goto-char (point-min))
16728 (if (zerop (buffer-size))
16729 () ; The buffer is empty.
16730 (let ((ident (get-text-property (point) 'gnus-backlog))
16732 ;; Remove the ident from the list of articles.
16734 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16735 ;; Delete the article itself.
16737 (point) (next-single-property-change
16738 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16740 (defun gnus-backlog-request-article (group number buffer)
16741 (when (numberp number)
16742 (gnus-backlog-setup)
16743 (let ((ident (intern (concat group ":" (int-to-string number))
16744 gnus-backlog-hashtb))
16746 (when (memq ident gnus-backlog-articles)
16747 ;; It was in the backlog.
16749 (set-buffer (gnus-backlog-buffer))
16750 (if (not (setq beg (text-property-any
16751 (point-min) (point-max) 'gnus-backlog
16753 ;; It wasn't in the backlog after all.
16755 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16756 ;; Find the end (i. e., the beginning of the next article).
16758 (next-single-property-change
16759 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16760 (let ((buffer-read-only nil))
16762 (insert-buffer-substring gnus-backlog-buffer beg end)
16765 ;; Allow redefinition of Gnus functions.
16767 (gnus-ems-redefine)
16771 ;;; gnus.el ends here