1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)The Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
217 :group 'gnus-article-hiding)
219 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
220 "Regexp matching signature separator.
221 This can also be a list of regexps. In that case, it will be checked
222 from head to tail looking for a separator. Searches will be done from
223 the end of the buffer."
224 :type '(repeat string)
225 :group 'gnus-article-signature)
227 (defcustom gnus-signature-limit nil
228 "Provide a limit to what is considered a signature.
229 If it is a number, no signature may not be longer (in characters) than
230 that number. If it is a floating point number, no signature may be
231 longer (in lines) than that number. If it is a function, the function
232 will be called without any parameters, and if it returns nil, there is
233 no signature in the buffer. If it is a string, it will be used as a
234 regexp. If it matches, the text in question is not a signature."
235 :type '(choice (integer :value 200)
237 (function :value fun)
238 (regexp :value ".*"))
239 :group 'gnus-article-signature)
241 (defcustom gnus-hidden-properties '(invisible t intangible t)
242 "Property list to use for hiding text."
244 :group 'gnus-article-hiding)
246 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
247 ;; frames in a session.
248 (defcustom gnus-article-x-face-command
249 (if (featurep 'xemacs)
250 (if (or (gnus-image-type-available-p 'xface)
251 (gnus-image-type-available-p 'pbm))
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
254 (if (gnus-image-type-available-p 'pbm)
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
258 "*String or function to be executed to display an X-Face header.
259 If it is a string, the command will be executed in a sub-shell
260 asynchronously. The compressed face will be piped to this command."
261 :type `(choice string
262 (function-item gnus-display-x-face-in-from)
266 :group 'gnus-article-washing)
268 (defcustom gnus-article-x-face-too-ugly nil
269 "Regexp matching posters whose face shouldn't be shown automatically."
270 :type '(choice regexp (const nil))
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-banner-alist nil
274 "Banner alist for stripping.
276 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
278 :type '(repeat (cons symbol regexp))
279 :group 'gnus-article-washing)
281 (gnus-define-group-parameter
284 "Alist of regexps (to match group names) and banner."
285 :variable-group gnus-article-washing
287 '(choice :tag "Banner"
289 (const :tag "Remove signature" signature)
290 (symbol :tag "Item in `gnus-article-banner-alist'" none)
292 (const :tag "None" nil))
294 "If non-nil, specify how to remove `banners' from articles.
296 Symbol `signature' means to remove signatures delimited by
297 `gnus-signature-separator'. Any other symbol is used to look up a
298 regular expression to match the banner in `gnus-article-banner-alist'.
299 A string is used as a regular expression to match the banner
302 (defcustom gnus-article-address-banner-alist nil
303 "Alist of mail addresses and banners.
304 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
305 to match a mail address in the From: header, BANNER is one of a symbol
306 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
307 If ADDRESS matches author's mail address, it will remove things like
308 advertisements. For example:
310 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
314 (regexp :tag "Address")
315 (choice :tag "Banner" :value nil
316 (const :tag "Remove signature" signature)
317 (symbol :tag "Item in `gnus-article-banner-alist'" none)
319 (const :tag "None" nil))))
320 :group 'gnus-article-washing)
322 (defcustom gnus-emphasis-alist
324 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
329 ("_/" "/_" underline-italic)
330 ("_\\*" "\\*_" underline-bold)
331 ("\\*/" "/\\*" bold-italic)
332 ("_\\*/" "/\\*_" underline-bold-italic))))
336 (format format (car spec) (cadr spec))
337 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
339 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
340 2 3 gnus-emphasis-strikethru)
341 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
342 2 3 gnus-emphasis-underline)))
343 "*Alist that says how to fontify certain phrases.
344 Each item looks like this:
346 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
348 The first element is a regular expression to be matched. The second
349 is a number that says what regular expression grouping used to find
350 the entire emphasized word. The third is a number that says what
351 regexp grouping should be displayed and highlighted. The fourth
352 is the face used for highlighting."
353 :type '(repeat (list :value ("" 0 0 default)
355 (integer :tag "Match group")
356 (integer :tag "Emphasize group")
358 :group 'gnus-article-emphasis)
360 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
361 "A regexp to describe whitespace which should not be emphasized.
362 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
363 The former avoids underlining of leading and trailing whitespace,
364 and the latter avoids underlining any whitespace at all."
366 :group 'gnus-article-emphasis
369 (defface gnus-emphasis-bold '((t (:bold t)))
370 "Face used for displaying strong emphasized text (*word*)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-italic '((t (:italic t)))
374 "Face used for displaying italic emphasized text (/word/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline '((t (:underline t)))
378 "Face used for displaying underlined emphasized text (_word_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
382 "Face used for displaying underlined bold emphasized text (_*word*_)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
386 "Face used for displaying underlined italic emphasized text (_/word/_)."
387 :group 'gnus-article-emphasis)
389 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
390 "Face used for displaying bold italic emphasized text (/*word*/)."
391 :group 'gnus-article-emphasis)
393 (defface gnus-emphasis-underline-bold-italic
394 '((t (:bold t :italic t :underline t)))
395 "Face used for displaying underlined bold italic emphasized text.
396 Example: (_/*word*/_)."
397 :group 'gnus-article-emphasis)
399 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
400 "Face used for displaying strike-through text (-word-)."
401 :group 'gnus-article-emphasis)
403 (defface gnus-emphasis-highlight-words
404 '((t (:background "black" :foreground "yellow")))
405 "Face used for displaying highlighted words."
406 :group 'gnus-article-emphasis)
408 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
409 "Format for display of Date headers in article bodies.
410 See `format-time-string' for the possible values.
412 The variable can also be function, which should return a complete Date
413 header. The function is called with one argument, the time, which can
414 be fed to `format-time-string'."
415 :type '(choice string symbol)
416 :link '(custom-manual "(gnus)Article Date")
417 :group 'gnus-article-washing)
420 (autoload 'mail-extract-address-components "mail-extr"))
422 (defcustom gnus-save-all-headers t
423 "*If non-nil, don't remove any headers before saving."
424 :group 'gnus-article-saving
427 (defcustom gnus-prompt-before-saving 'always
428 "*This variable says how much prompting is to be done when saving articles.
429 If it is nil, no prompting will be done, and the articles will be
430 saved to the default files. If this variable is `always', each and
431 every article that is saved will be preceded by a prompt, even when
432 saving large batches of articles. If this variable is neither nil not
433 `always', there the user will be prompted once for a file name for
434 each invocation of the saving commands."
435 :group 'gnus-article-saving
436 :type '(choice (item always)
437 (item :tag "never" nil)
438 (sexp :tag "once" :format "%t\n" :value t)))
440 (defcustom gnus-saved-headers gnus-visible-headers
441 "Headers to keep if `gnus-save-all-headers' is nil.
442 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
443 If that variable is nil, however, all headers that match this regexp
444 will be kept while the rest will be deleted before saving."
445 :group 'gnus-article-saving
448 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
449 "A function to save articles in your favourite format.
450 The function must be interactively callable (in other words, it must
451 be an Emacs command).
453 Gnus provides the following functions:
455 * gnus-summary-save-in-rmail (Rmail format)
456 * gnus-summary-save-in-mail (Unix mail format)
457 * gnus-summary-save-in-folder (MH folder)
458 * gnus-summary-save-in-file (article format)
459 * gnus-summary-save-body-in-file (article body)
460 * gnus-summary-save-in-vm (use VM's folder format)
461 * gnus-summary-write-to-file (article format -- overwrite)."
462 :group 'gnus-article-saving
463 :type '(radio (function-item gnus-summary-save-in-rmail)
464 (function-item gnus-summary-save-in-mail)
465 (function-item gnus-summary-save-in-folder)
466 (function-item gnus-summary-save-in-file)
467 (function-item gnus-summary-save-body-in-file)
468 (function-item gnus-summary-save-in-vm)
469 (function-item gnus-summary-write-to-file)))
471 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
472 "A function generating a file name to save articles in Rmail format.
473 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
474 :group 'gnus-article-saving
477 (defcustom gnus-mail-save-name 'gnus-plain-save-name
478 "A function generating a file name to save articles in Unix mail format.
479 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
480 :group 'gnus-article-saving
483 (defcustom gnus-folder-save-name 'gnus-folder-save-name
484 "A function generating a file name to save articles in MH folder.
485 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
486 :group 'gnus-article-saving
489 (defcustom gnus-file-save-name 'gnus-numeric-save-name
490 "A function generating a file name to save articles in article format.
491 The function is called with NEWSGROUP, HEADERS, and optional
493 :group 'gnus-article-saving
496 (defcustom gnus-split-methods
497 '((gnus-article-archive-name)
498 (gnus-article-nndoc-name))
499 "*Variable used to suggest where articles are to be saved.
500 For instance, if you would like to save articles related to Gnus in
501 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
502 you could set this variable to something like:
504 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
505 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
507 This variable is an alist where the where the key is the match and the
508 value is a list of possible files to save in if the match is non-nil.
510 If the match is a string, it is used as a regexp match on the
511 article. If the match is a symbol, that symbol will be funcalled
512 from the buffer of the article to be saved with the newsgroup as the
513 parameter. If it is a list, it will be evaled in the same buffer.
515 If this form or function returns a string, this string will be used as
516 a possible file name; and if it returns a non-nil list, that list will
517 be used as possible file names."
518 :group 'gnus-article-saving
519 :type '(repeat (choice (list :value (fun) function)
520 (cons :value ("" "") regexp (repeat string))
523 (defcustom gnus-page-delimiter "^\^L"
524 "*Regexp describing what to use as article page delimiters.
525 The default value is \"^\^L\", which is a form linefeed at the
526 beginning of a line."
528 :group 'gnus-article-various)
530 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
531 "*The format specification for the article mode line.
532 See `gnus-summary-mode-line-format' for a closer description.
534 The following additional specs are available:
536 %w The article washing status.
537 %m The number of MIME parts in the article."
539 :group 'gnus-article-various)
541 (defcustom gnus-article-mode-hook nil
542 "*A hook for Gnus article mode."
544 :group 'gnus-article-various)
546 (when (featurep 'xemacs)
547 ;; Extracted from gnus-xmas-define in order to preserve user settings
548 (when (fboundp 'turn-off-scroll-in-place)
549 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
550 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
551 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
553 (defcustom gnus-article-menu-hook nil
554 "*Hook run after the creation of the article mode menu."
556 :group 'gnus-article-various)
558 (defcustom gnus-article-prepare-hook nil
559 "*A hook called after an article has been prepared in the article buffer."
561 :group 'gnus-article-various)
563 (make-obsolete-variable 'gnus-article-hide-pgp-hook
564 "This variable is obsolete in Gnus 5.10.")
566 (defcustom gnus-article-button-face 'bold
567 "Face used for highlighting buttons in the article buffer.
569 An article button is a piece of text that you can activate by pressing
570 `RET' or `mouse-2' above it."
572 :group 'gnus-article-buttons)
574 (defcustom gnus-article-mouse-face 'highlight
575 "Face used for mouse highlighting in the article buffer.
577 Article buttons will be displayed in this face when the cursor is
580 :group 'gnus-article-buttons)
582 (defcustom gnus-signature-face 'gnus-signature-face
583 "Face used for highlighting a signature in the article buffer.
584 Obsolete; use the face `gnus-signature-face' for customizations instead."
586 :group 'gnus-article-highlight
587 :group 'gnus-article-signature)
589 (defface gnus-signature-face
592 "Face used for highlighting a signature in the article buffer."
593 :group 'gnus-article-highlight
594 :group 'gnus-article-signature)
596 (defface gnus-header-from-face
599 (:foreground "spring green"))
602 (:foreground "red3"))
605 "Face used for displaying from headers."
606 :group 'gnus-article-headers
607 :group 'gnus-article-highlight)
609 (defface gnus-header-subject-face
612 (:foreground "SeaGreen3"))
615 (:foreground "red4"))
617 (:bold t :italic t)))
618 "Face used for displaying subject headers."
619 :group 'gnus-article-headers
620 :group 'gnus-article-highlight)
622 (defface gnus-header-newsgroups-face
625 (:foreground "yellow" :italic t))
628 (:foreground "MidnightBlue" :italic t))
631 "Face used for displaying newsgroups headers.
632 In the default setup this face is only used for crossposted
634 :group 'gnus-article-headers
635 :group 'gnus-article-highlight)
637 (defface gnus-header-name-face
640 (:foreground "SeaGreen"))
643 (:foreground "maroon"))
646 "Face used for displaying header names."
647 :group 'gnus-article-headers
648 :group 'gnus-article-highlight)
650 (defface gnus-header-content-face
653 (:foreground "forest green" :italic t))
656 (:foreground "indianred4" :italic t))
658 (:italic t))) "Face used for displaying header content."
659 :group 'gnus-article-headers
660 :group 'gnus-article-highlight)
662 (defcustom gnus-header-face-alist
663 '(("From" nil gnus-header-from-face)
664 ("Subject" nil gnus-header-subject-face)
665 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
666 ("" gnus-header-name-face gnus-header-content-face))
667 "*Controls highlighting of article headers.
669 An alist of the form (HEADER NAME CONTENT).
671 HEADER is a regular expression which should match the name of a
672 header and NAME and CONTENT are either face names or nil.
674 The name of each header field will be displayed using the face
675 specified by the first element in the list where HEADER matches
676 the header name and NAME is non-nil. Similarly, the content will
677 be displayed by the first non-nil matching CONTENT face."
678 :group 'gnus-article-headers
679 :group 'gnus-article-highlight
680 :type '(repeat (list (regexp :tag "Header")
682 (item :tag "skip" nil)
683 (face :value default))
684 (choice :tag "Content"
685 (item :tag "skip" nil)
686 (face :value default)))))
688 (defcustom gnus-article-decode-hook
689 '(article-decode-charset article-decode-encoded-words
690 article-decode-group-name article-decode-idna-rhs)
691 "*Hook run to decode charsets in articles."
692 :group 'gnus-article-headers
695 (defcustom gnus-display-mime-function 'gnus-display-mime
696 "Function to display MIME articles."
697 :group 'gnus-article-mime
700 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
701 "Function used to decode headers.")
703 (defvar gnus-article-dumbquotes-map
723 "Table for MS-to-Latin1 translation.")
725 (defcustom gnus-ignored-mime-types nil
726 "List of MIME types that should be ignored by Gnus."
728 :group 'gnus-article-mime
729 :type '(repeat regexp))
731 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
732 "List of MIME types that should not be given buttons when rendered inline.
733 See also `gnus-buttonized-mime-types' which may override this variable.
734 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
736 :group 'gnus-article-mime
737 :type '(repeat regexp))
739 (defcustom gnus-buttonized-mime-types nil
740 "List of MIME types that should be given buttons when rendered inline.
741 If set, this variable overrides `gnus-unbuttonized-mime-types'.
742 To see e.g. security buttons you could set this to
743 `(\"multipart/signed\")'.
744 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
746 :group 'gnus-article-mime
747 :type '(repeat regexp))
749 (defcustom gnus-inhibit-mime-unbuttonizing nil
750 "If non-nil, all MIME parts get buttons.
751 When nil (the default value), then some MIME parts do not get buttons,
752 as described by the variables `gnus-buttonized-mime-types' and
753 `gnus-unbuttonized-mime-types'."
757 (defcustom gnus-body-boundary-delimiter "_"
758 "String used to delimit header and body.
759 This variable is used by `gnus-article-treat-body-boundary' which can
760 be controlled by `gnus-treat-body-boundary'."
761 :group 'gnus-article-various
762 :type '(choice (item :tag "None" :value nil)
765 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
766 "Defines the location of the faces database.
767 For information on obtaining this database of pretty pictures, please
768 see http://www.cs.indiana.edu/picons/ftp/index.html"
769 :type '(repeat directory)
770 :link '(url-link :tag "download"
771 "http://www.cs.indiana.edu/picons/ftp/index.html")
772 :link '(custom-manual "(gnus)Picons")
775 (defun gnus-picons-installed-p ()
776 "Say whether picons are installed on your machine."
777 (let ((installed nil))
778 (dolist (database gnus-picon-databases)
779 (when (file-exists-p database)
783 (defcustom gnus-article-mime-part-function nil
784 "Function called with a MIME handle as the argument.
785 This is meant for people who want to do something automatic based
786 on parts -- for instance, adding Vcard info to a database."
787 :group 'gnus-article-mime
790 (defcustom gnus-mime-multipart-functions nil
791 "An alist of MIME types to functions to display them."
793 :group 'gnus-article-mime
796 (defcustom gnus-article-date-lapsed-new-header nil
797 "Whether the X-Sent and Date headers can coexist.
798 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
799 either replace the old \"Date:\" header (if this variable is nil), or
800 be added below it (otherwise)."
802 :group 'gnus-article-headers
805 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
806 "Function called with a MIME handle as the argument.
807 This is meant for people who want to view first matched part.
808 For `undisplayed-alternative' (default), the first undisplayed
809 part or alternative part is used. For `undisplayed', the first
810 undisplayed part is used. For a function, the first part which
811 the function return t is used. For nil, the first part is
814 :group 'gnus-article-mime
816 (item :tag "first" :value nil)
817 (item :tag "undisplayed" :value undisplayed)
818 (item :tag "undisplayed or alternative"
819 :value undisplayed-alternative)
822 (defcustom gnus-mime-action-alist
823 '(("save to file" . gnus-mime-save-part)
824 ("save and strip" . gnus-mime-save-part-and-strip)
825 ("delete part" . gnus-mime-delete-part)
826 ("display as text" . gnus-mime-inline-part)
827 ("view the part" . gnus-mime-view-part)
828 ("pipe to command" . gnus-mime-pipe-part)
829 ("toggle display" . gnus-article-press-button)
830 ("toggle display" . gnus-article-view-part-as-charset)
831 ("view as type" . gnus-mime-view-part-as-type)
832 ("view internally" . gnus-mime-view-part-internally)
833 ("view externally" . gnus-mime-view-part-externally))
834 "An alist of actions that run on the MIME attachment."
835 :group 'gnus-article-mime
836 :type '(repeat (cons (string :tag "name")
840 ;;; The treatment variables
843 (defvar gnus-part-display-hook nil
844 "Hook called on parts that are to receive treatment.")
846 (defvar gnus-article-treat-custom
847 '(choice (const :tag "Off" nil)
849 (const :tag "Header" head)
850 (const :tag "Last" last)
851 (integer :tag "Less")
852 (repeat :tag "Groups" regexp)
853 (sexp :tag "Predicate")))
855 (defvar gnus-article-treat-head-custom
856 '(choice (const :tag "Off" nil)
857 (const :tag "Header" head)))
859 (defvar gnus-article-treat-types '("text/plain")
862 (defvar gnus-inhibit-treatment nil
863 "Whether to inhibit treatment.")
865 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
866 "Highlight the signature.
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See Info node `(gnus)Customizing Articles'."
869 :group 'gnus-article-treat
870 :link '(custom-manual "(gnus)Customizing Articles")
871 :type gnus-article-treat-custom)
872 (put 'gnus-treat-highlight-signature 'highlight t)
874 (defcustom gnus-treat-buttonize 100000
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See Info node `(gnus)Customizing Articles'."
878 :group 'gnus-article-treat
879 :link '(custom-manual "(gnus)Customizing Articles")
880 :type gnus-article-treat-custom)
881 (put 'gnus-treat-buttonize 'highlight t)
883 (defcustom gnus-treat-buttonize-head 'head
884 "Add buttons to the head.
885 Valid values are nil, t, `head', `last', an integer or a predicate.
886 See Info node `(gnus)Customizing Articles' for details."
887 :group 'gnus-article-treat
888 :link '(custom-manual "(gnus)Customizing Articles")
889 :type gnus-article-treat-head-custom)
890 (put 'gnus-treat-buttonize-head 'highlight t)
892 (defcustom gnus-treat-emphasize
893 (and (or window-system
895 (>= (string-to-number emacs-version) 21))
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :link '(custom-manual "(gnus)Customizing Articles")
902 :type gnus-article-treat-custom)
903 (put 'gnus-treat-emphasize 'highlight t)
905 (defcustom gnus-treat-strip-cr nil
906 "Remove carriage returns.
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles' for details."
909 :group 'gnus-article-treat
910 :link '(custom-manual "(gnus)Customizing Articles")
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-unsplit-urls nil
914 "Remove newlines from within URLs.
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See Info node `(gnus)Customizing Articles' for details."
917 :group 'gnus-article-treat
918 :link '(custom-manual "(gnus)Customizing Articles")
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-leading-whitespace nil
922 "Remove leading whitespace in headers.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :link '(custom-manual "(gnus)Customizing Articles")
927 :type gnus-article-treat-custom)
929 (defcustom gnus-treat-hide-headers 'head
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles' for details."
933 :group 'gnus-article-treat
934 :link '(custom-manual "(gnus)Customizing Articles")
935 :type gnus-article-treat-head-custom)
937 (defcustom gnus-treat-hide-boring-headers nil
938 "Hide boring headers.
939 Valid values are nil, t, `head', `last', an integer or a predicate.
940 See Info node `(gnus)Customizing Articles' for details."
941 :group 'gnus-article-treat
942 :link '(custom-manual "(gnus)Customizing Articles")
943 :type gnus-article-treat-head-custom)
945 (defcustom gnus-treat-hide-signature nil
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :link '(custom-manual "(gnus)Customizing Articles")
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-fill-article nil
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-hide-citation nil
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-hide-citation-maybe nil
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-custom)
977 (defcustom gnus-treat-strip-list-identifiers 'head
978 "Strip list identifiers from `gnus-list-identifiers`.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
982 :group 'gnus-article-treat
983 :link '(custom-manual "(gnus)Customizing Articles")
984 :type gnus-article-treat-custom)
986 (make-obsolete-variable 'gnus-treat-strip-pgp
987 "This option is obsolete in Gnus 5.10.")
989 (defcustom gnus-treat-strip-pem nil
990 "Strip PEM signatures.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
993 :group 'gnus-article-treat
994 :link '(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-strip-banner t
998 "Strip banners from articles.
999 The banner to be stripped is specified in the `banner' group parameter.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-custom)
1006 (defcustom gnus-treat-highlight-headers 'head
1007 "Highlight the headers.
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1013 (put 'gnus-treat-highlight-headers 'highlight t)
1015 (defcustom gnus-treat-highlight-citation t
1016 "Highlight cited text.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-custom)
1022 (put 'gnus-treat-highlight-citation 'highlight t)
1024 (defcustom gnus-treat-date-ut nil
1025 "Display the Date in UT (GMT).
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-head-custom)
1032 (defcustom gnus-treat-date-local nil
1033 "Display the Date in the local timezone.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :link '(custom-manual "(gnus)Customizing Articles")
1038 :type gnus-article-treat-head-custom)
1040 (defcustom gnus-treat-date-english nil
1041 "Display the Date in a format that can be read aloud in English.
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-head-custom)
1048 (defcustom gnus-treat-date-lapsed nil
1049 "Display the Date header in a way that says how much time has elapsed.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-head-custom)
1056 (defcustom gnus-treat-date-original nil
1057 "Display the date in the original timezone.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-date-iso8601 nil
1065 "Display the date in the ISO8601 format.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1073 (defcustom gnus-treat-date-user-defined nil
1074 "Display the date in a user-defined format.
1075 The format is defined by the `gnus-article-time-format' variable.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1078 :group 'gnus-article-treat
1079 :link '(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-head-custom)
1082 (defcustom gnus-treat-strip-headers-in-body t
1083 "Strip the X-No-Archive header line from the beginning of the body.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1091 (defcustom gnus-treat-strip-trailing-blank-lines nil
1092 "Strip trailing blank lines.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-custom)
1099 (defcustom gnus-treat-strip-leading-blank-lines nil
1100 "Strip leading blank lines.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-strip-multiple-blank-lines nil
1108 "Strip multiple blank lines.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-custom)
1115 (defcustom gnus-treat-unfold-headers 'head
1116 "Unfold folded header lines.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-custom)
1123 (defcustom gnus-treat-fold-headers nil
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1131 (defcustom gnus-treat-fold-newsgroups 'head
1132 "Fold the Newsgroups and Followup-To headers.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1139 (defcustom gnus-treat-overstrike t
1140 "Treat overstrike highlighting.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 See Info node `(gnus)Customizing Articles' for details."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1146 (put 'gnus-treat-overstrike 'highlight t)
1148 (defcustom gnus-treat-display-xface
1149 (and (not noninteractive)
1150 (or (and (fboundp 'image-type-available-p)
1151 (image-type-available-p 'xbm)
1152 (string-match "^0x" (shell-command-to-string "uncompface"))
1153 (executable-find "icontopbm"))
1154 (and (featurep 'xemacs)
1157 "Display X-Face headers.
1158 Valid values are nil, t, `head', `last', an integer or a predicate.
1159 See Info node `(gnus)Customizing Articles' and Info node
1160 `(gnus)X-Face' for details."
1161 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :link '(custom-manual "(gnus)X-Face")
1165 :type gnus-article-treat-head-custom)
1166 (put 'gnus-treat-display-xface 'highlight t)
1168 (defcustom gnus-treat-display-face
1169 (and (not noninteractive)
1170 (or (and (fboundp 'image-type-available-p)
1171 (image-type-available-p 'png))
1172 (and (featurep 'xemacs)
1175 "Display Face headers.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' and Info node
1178 `(gnus)X-Face' for details."
1179 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :link '(custom-manual "(gnus)X-Face")
1183 :type gnus-article-treat-head-custom)
1184 (put 'gnus-treat-display-xface 'highlight t)
1186 (defcustom gnus-treat-display-smileys
1187 (if (or (and (featurep 'xemacs)
1189 (and (fboundp 'image-type-available-p)
1190 (image-type-available-p 'pbm)))
1193 Valid values are nil, t, `head', `last', an integer or a predicate.
1194 See Info node `(gnus)Customizing Articles' and Info node
1195 `(gnus)Smileys' for details."
1196 :group 'gnus-article-treat
1198 :link '(custom-manual "(gnus)Customizing Articles")
1199 :link '(custom-manual "(gnus)Smileys")
1200 :type gnus-article-treat-custom)
1201 (put 'gnus-treat-display-smileys 'highlight t)
1203 (defcustom gnus-treat-from-picon
1204 (if (and (gnus-image-type-available-p 'xpm)
1205 (gnus-picons-installed-p))
1207 "Display picons in the From header.
1208 Valid values are nil, t, `head', `last', an integer or a predicate.
1209 See Info node `(gnus)Customizing Articles' and Info node
1210 `(gnus)Picons' for details."
1211 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :link '(custom-manual "(gnus)Picons")
1215 :type gnus-article-treat-head-custom)
1216 (put 'gnus-treat-from-picon 'highlight t)
1218 (defcustom gnus-treat-mail-picon
1219 (if (and (gnus-image-type-available-p 'xpm)
1220 (gnus-picons-installed-p))
1222 "Display picons in To and Cc headers.
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' and Info node
1225 `(gnus)Picons' for details."
1226 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :link '(custom-manual "(gnus)Picons")
1230 :type gnus-article-treat-head-custom)
1231 (put 'gnus-treat-mail-picon 'highlight t)
1233 (defcustom gnus-treat-newsgroups-picon
1234 (if (and (gnus-image-type-available-p 'xpm)
1235 (gnus-picons-installed-p))
1237 "Display picons in the Newsgroups and Followup-To headers.
1238 Valid values are nil, t, `head', `last', an integer or a predicate.
1239 See Info node `(gnus)Customizing Articles' and Info node
1240 `(gnus)Picons' for details."
1241 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :link '(custom-manual "(gnus)Picons")
1245 :type gnus-article-treat-head-custom)
1246 (put 'gnus-treat-newsgroups-picon 'highlight t)
1248 (defcustom gnus-treat-body-boundary
1249 (if (or gnus-treat-newsgroups-picon
1250 gnus-treat-mail-picon
1251 gnus-treat-from-picon)
1253 "Draw a boundary at the end of the headers.
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' for details."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-custom)
1261 (defcustom gnus-treat-capitalize-sentences nil
1262 "Capitalize sentence-starting words.
1263 Valid values are nil, t, `head', `last', an integer or a predicate.
1264 See Info node `(gnus)Customizing Articles' for details."
1266 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :type gnus-article-treat-custom)
1270 (defcustom gnus-treat-wash-html nil
1272 Valid values are nil, t, `head', `last', an integer or a predicate.
1273 See Info node `(gnus)Customizing Articles' for details."
1274 :group 'gnus-article-treat
1275 :link '(custom-manual "(gnus)Customizing Articles")
1276 :type gnus-article-treat-custom)
1278 (defcustom gnus-treat-fill-long-lines nil
1280 Valid values are nil, t, `head', `last', an integer or a predicate.
1281 See Info node `(gnus)Customizing Articles' for details."
1282 :group 'gnus-article-treat
1283 :link '(custom-manual "(gnus)Customizing Articles")
1284 :type gnus-article-treat-custom)
1286 (defcustom gnus-treat-play-sounds nil
1288 Valid values are nil, t, `head', `last', an integer or a predicate.
1289 See Info node `(gnus)Customizing Articles' for details."
1291 :group 'gnus-article-treat
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :type gnus-article-treat-custom)
1295 (defcustom gnus-treat-translate nil
1296 "Translate articles from one language to another.
1297 Valid values are nil, t, `head', `last', an integer or a predicate.
1298 See Info node `(gnus)Customizing Articles' for details."
1300 :group 'gnus-article-treat
1301 :link '(custom-manual "(gnus)Customizing Articles")
1302 :type gnus-article-treat-custom)
1304 (defcustom gnus-treat-x-pgp-sig nil
1306 To automatically treat X-PGP-Sig, set it to head.
1307 Valid values are nil, t, `head', `last', an integer or a predicate.
1308 See Info node `(gnus)Customizing Articles' for details."
1309 :group 'gnus-article-treat
1310 :group 'mime-security
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-custom)
1314 (defvar gnus-article-encrypt-protocol-alist
1315 '(("PGP" . mml2015-self-encrypt)))
1317 ;; Set to nil if more than one protocol added to
1318 ;; gnus-article-encrypt-protocol-alist.
1319 (defcustom gnus-article-encrypt-protocol "PGP"
1320 "The protocol used for encrypt articles.
1321 It is a string, such as \"PGP\". If nil, ask user."
1323 :group 'mime-security)
1325 (defvar gnus-article-wash-function nil
1326 "Function used for converting HTML into text.")
1328 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1329 (mm-coding-system-p 'utf-8)
1330 (executable-find idna-program))
1331 "Whether IDNA decoding of headers is used when viewing messages.
1332 This requires GNU Libidn, and by default only enabled if it is found."
1333 :group 'gnus-article-headers
1336 (defcustom gnus-article-over-scroll nil
1337 "If non-nil, allow scrolling the article buffer even when there no more text."
1338 :group 'gnus-article
1341 ;;; Internal variables
1343 (defvar gnus-english-month-names
1344 '("January" "February" "March" "April" "May" "June" "July" "August"
1345 "September" "October" "November" "December"))
1347 (defvar article-goto-body-goes-to-point-min-p nil)
1348 (defvar gnus-article-wash-types nil)
1349 (defvar gnus-article-emphasis-alist nil)
1350 (defvar gnus-article-image-alist nil)
1352 (defvar gnus-article-mime-handle-alist-1 nil)
1353 (defvar gnus-treatment-function-alist
1354 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1355 (gnus-treat-strip-banner gnus-article-strip-banner)
1356 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1357 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1358 (gnus-treat-buttonize gnus-article-add-buttons)
1359 (gnus-treat-fill-article gnus-article-fill-cited-article)
1360 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1361 (gnus-treat-strip-cr gnus-article-remove-cr)
1362 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1363 (gnus-treat-date-ut gnus-article-date-ut)
1364 (gnus-treat-date-local gnus-article-date-local)
1365 (gnus-treat-date-english gnus-article-date-english)
1366 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1367 (gnus-treat-date-original gnus-article-date-original)
1368 (gnus-treat-date-user-defined gnus-article-date-user)
1369 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1370 (gnus-treat-display-xface gnus-article-display-x-face)
1371 (gnus-treat-display-face gnus-article-display-face)
1372 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1373 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1374 (gnus-treat-hide-signature gnus-article-hide-signature)
1375 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1376 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1377 (gnus-treat-strip-pem gnus-article-hide-pem)
1378 (gnus-treat-from-picon gnus-treat-from-picon)
1379 (gnus-treat-mail-picon gnus-treat-mail-picon)
1380 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1381 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1382 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1383 (gnus-treat-strip-trailing-blank-lines
1384 gnus-article-remove-trailing-blank-lines)
1385 (gnus-treat-strip-leading-blank-lines
1386 gnus-article-strip-leading-blank-lines)
1387 (gnus-treat-strip-multiple-blank-lines
1388 gnus-article-strip-multiple-blank-lines)
1389 (gnus-treat-overstrike gnus-article-treat-overstrike)
1390 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1391 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1392 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1393 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1394 (gnus-treat-display-smileys gnus-treat-smiley)
1395 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1396 (gnus-treat-wash-html gnus-article-wash-html)
1397 (gnus-treat-emphasize gnus-article-emphasize)
1398 (gnus-treat-hide-citation gnus-article-hide-citation)
1399 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1400 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1401 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1402 (gnus-treat-play-sounds gnus-earcon-display)))
1404 (defvar gnus-article-mime-handle-alist nil)
1405 (defvar article-lapsed-timer nil)
1406 (defvar gnus-article-current-summary nil)
1408 (defvar gnus-article-mode-syntax-table
1409 (let ((table (copy-syntax-table text-mode-syntax-table)))
1410 ;; This causes the citation match run O(2^n).
1411 ;; (modify-syntax-entry ?- "w" table)
1412 (modify-syntax-entry ?> ")<" table)
1413 (modify-syntax-entry ?< "(>" table)
1414 ;; make M-. in article buffers work for `foo' strings
1415 (modify-syntax-entry ?' " " table)
1416 (modify-syntax-entry ?` " " table)
1418 "Syntax table used in article mode buffers.
1419 Initialized from `text-mode-syntax-table.")
1421 (defvar gnus-save-article-buffer nil)
1423 (defvar gnus-article-mode-line-format-alist
1424 (nconc '((?w (gnus-article-wash-status) ?s)
1425 (?m (gnus-article-mime-part-status) ?s))
1426 gnus-summary-mode-line-format-alist))
1428 (defvar gnus-number-of-articles-to-be-saved nil)
1430 (defvar gnus-inhibit-hiding nil)
1432 ;;; Macros for dealing with the article buffer.
1434 (defmacro gnus-with-article-headers (&rest forms)
1436 (set-buffer gnus-article-buffer)
1438 (let ((buffer-read-only nil)
1439 (inhibit-point-motion-hooks t)
1440 (case-fold-search t))
1441 (article-narrow-to-head)
1444 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1445 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1447 (defmacro gnus-with-article-buffer (&rest forms)
1449 (set-buffer gnus-article-buffer)
1450 (let ((buffer-read-only nil))
1453 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1454 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1456 (defun gnus-article-goto-header (header)
1457 "Go to HEADER, which is a regular expression."
1458 (re-search-forward (concat "^\\(" header "\\):") nil t))
1460 (defsubst gnus-article-hide-text (b e props)
1461 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1462 (gnus-add-text-properties-when 'article-type nil b e props)
1463 (when (memq 'intangible props)
1465 (max (1- b) (point-min))
1466 b 'intangible (cddr (memq 'intangible props)))))
1468 (defsubst gnus-article-unhide-text (b e)
1469 "Remove hidden text properties from region between B and E."
1470 (remove-text-properties b e gnus-hidden-properties)
1471 (when (memq 'intangible gnus-hidden-properties)
1472 (put-text-property (max (1- b) (point-min))
1473 b 'intangible nil)))
1475 (defun gnus-article-hide-text-type (b e type)
1476 "Hide text of TYPE between B and E."
1477 (gnus-add-wash-type type)
1478 (gnus-article-hide-text
1479 b e (cons 'article-type (cons type gnus-hidden-properties))))
1481 (defun gnus-article-unhide-text-type (b e type)
1482 "Unhide text of TYPE between B and E."
1483 (gnus-delete-wash-type type)
1484 (remove-text-properties
1485 b e (cons 'article-type (cons type gnus-hidden-properties)))
1486 (when (memq 'intangible gnus-hidden-properties)
1487 (put-text-property (max (1- b) (point-min))
1488 b 'intangible nil)))
1490 (defun gnus-article-hide-text-of-type (type)
1491 "Hide text of TYPE in the current buffer."
1493 (let ((b (point-min))
1495 (while (setq b (text-property-any b e 'article-type type))
1496 (add-text-properties b (incf b) gnus-hidden-properties)))))
1498 (defun gnus-article-delete-text-of-type (type)
1499 "Delete text of TYPE in the current buffer."
1501 (let ((b (point-min)))
1502 (while (setq b (text-property-any b (point-max) 'article-type type))
1504 b (or (text-property-not-all b (point-max) 'article-type type)
1507 (defun gnus-article-delete-invisible-text ()
1508 "Delete all invisible text in the current buffer."
1510 (let ((b (point-min)))
1511 (while (setq b (text-property-any b (point-max) 'invisible t))
1513 b (or (text-property-not-all b (point-max) 'invisible t)
1516 (defun gnus-article-text-type-exists-p (type)
1517 "Say whether any text of type TYPE exists in the buffer."
1518 (text-property-any (point-min) (point-max) 'article-type type))
1520 (defsubst gnus-article-header-rank ()
1521 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1522 (let ((list gnus-sorted-header-list)
1525 (if (looking-at (car list))
1527 (setq list (cdr list))
1531 (defun article-hide-headers (&optional arg delete)
1532 "Hide unwanted headers and possibly sort them as well."
1534 ;; This function might be inhibited.
1535 (unless gnus-inhibit-hiding
1538 (let ((buffer-read-only nil)
1539 (case-fold-search t)
1540 (max (1+ (length gnus-sorted-header-list)))
1541 (ignored (when (not gnus-visible-headers)
1542 (cond ((stringp gnus-ignored-headers)
1543 gnus-ignored-headers)
1544 ((listp gnus-ignored-headers)
1545 (mapconcat 'identity gnus-ignored-headers
1548 (cond ((stringp gnus-visible-headers)
1549 gnus-visible-headers)
1550 ((and gnus-visible-headers
1551 (listp gnus-visible-headers))
1552 (mapconcat 'identity gnus-visible-headers "\\|"))))
1553 (inhibit-point-motion-hooks t)
1555 ;; First we narrow to just the headers.
1556 (article-narrow-to-head)
1557 ;; Hide any "From " lines at the beginning of (mail) articles.
1558 (while (looking-at "From ")
1561 (delete-region (point-min) (point)))
1562 ;; Then treat the rest of the header lines.
1563 ;; Then we use the two regular expressions
1564 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1565 ;; select which header lines is to remain visible in the
1567 (while (re-search-forward "^[^ \t:]*:" nil t)
1569 ;; Mark the rank of the header.
1571 (point) (1+ (point)) 'message-rank
1572 (if (or (and visible (looking-at visible))
1574 (not (looking-at ignored))))
1575 (gnus-article-header-rank)
1578 (message-sort-headers-1)
1579 (when (setq beg (text-property-any
1580 (point-min) (point-max) 'message-rank (+ 2 max)))
1581 ;; We delete the unwanted headers.
1582 (gnus-add-wash-type 'headers)
1583 (add-text-properties (point-min) (+ 5 (point-min))
1584 '(article-type headers dummy-invisible t))
1585 (delete-region beg (point-max))))))))
1587 (defun article-hide-boring-headers (&optional arg)
1588 "Toggle hiding of headers that aren't very interesting.
1589 If given a negative prefix, always show; if given a positive prefix,
1591 (interactive (gnus-article-hidden-arg))
1592 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1593 (not gnus-show-all-headers))
1596 (let ((buffer-read-only nil)
1597 (list gnus-boring-article-headers)
1598 (inhibit-point-motion-hooks t)
1600 (article-narrow-to-head)
1602 (setq elem (pop list))
1603 (goto-char (point-min))
1605 ;; Hide empty headers.
1607 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1609 (gnus-article-hide-text-type
1613 (if (re-search-forward "^[^ \t]" nil t)
1617 ;; Hide boring Newsgroups header.
1618 ((eq elem 'newsgroups)
1619 (when (gnus-string-equal
1620 (gnus-fetch-field "newsgroups")
1621 (gnus-group-real-name
1622 (if (boundp 'gnus-newsgroup-name)
1625 (gnus-article-hide-header "newsgroups")))
1626 ((eq elem 'to-address)
1627 (let ((to (message-fetch-field "to"))
1629 (gnus-parameter-to-address
1630 (if (boundp 'gnus-newsgroup-name)
1631 gnus-newsgroup-name ""))))
1632 (when (and to to-address
1635 ;; only one address in To
1636 (nth 1 (mail-extract-address-components to))
1638 (gnus-article-hide-header "to"))))
1640 (let ((to (message-fetch-field "to"))
1642 (gnus-parameter-to-list
1643 (if (boundp 'gnus-newsgroup-name)
1644 gnus-newsgroup-name ""))))
1645 (when (and to to-list
1648 ;; only one address in To
1649 (nth 1 (mail-extract-address-components to))
1651 (gnus-article-hide-header "to"))))
1653 (let ((cc (message-fetch-field "cc"))
1655 (gnus-parameter-to-list
1656 (if (boundp 'gnus-newsgroup-name)
1657 gnus-newsgroup-name ""))))
1658 (when (and cc to-list
1661 ;; only one address in CC
1662 (nth 1 (mail-extract-address-components cc))
1664 (gnus-article-hide-header "cc"))))
1665 ((eq elem 'followup-to)
1666 (when (gnus-string-equal
1667 (message-fetch-field "followup-to")
1668 (message-fetch-field "newsgroups"))
1669 (gnus-article-hide-header "followup-to")))
1670 ((eq elem 'reply-to)
1671 (if (gnus-group-find-parameter
1672 gnus-newsgroup-name 'broken-reply-to)
1673 (gnus-article-hide-header "reply-to")
1674 (let ((from (message-fetch-field "from"))
1675 (reply-to (message-fetch-field "reply-to")))
1680 (nth 1 (mail-extract-address-components from))
1681 (nth 1 (mail-extract-address-components reply-to)))))
1682 (gnus-article-hide-header "reply-to")))))
1684 (let ((date (message-fetch-field "date")))
1686 (< (days-between (current-time-string) date)
1688 (gnus-article-hide-header "date"))))
1690 (let ((to (message-fetch-field "to"))
1691 (cc (message-fetch-field "cc")))
1692 (when (> (length to) 1024)
1693 (gnus-article-hide-header "to"))
1694 (when (> (length cc) 1024)
1695 (gnus-article-hide-header "cc"))))
1699 (goto-char (point-min))
1700 (while (re-search-forward "^to:" nil t)
1701 (setq to-count (1+ to-count)))
1702 (when (> to-count 1)
1703 (while (> to-count 0)
1704 (goto-char (point-min))
1706 (re-search-forward "^to:" nil nil to-count)
1708 (narrow-to-region (point) (point-max))
1709 (gnus-article-hide-header "to"))
1710 (setq to-count (1- to-count))))
1711 (goto-char (point-min))
1712 (while (re-search-forward "^cc:" nil t)
1713 (setq cc-count (1+ cc-count)))
1714 (when (> cc-count 1)
1715 (while (> cc-count 0)
1716 (goto-char (point-min))
1718 (re-search-forward "^cc:" nil nil cc-count)
1720 (narrow-to-region (point) (point-max))
1721 (gnus-article-hide-header "cc"))
1722 (setq cc-count (1- cc-count)))))))))))))
1724 (defun gnus-article-hide-header (header)
1726 (goto-char (point-min))
1727 (when (re-search-forward (concat "^" header ":") nil t)
1728 (gnus-article-hide-text-type
1732 (if (re-search-forward "^[^ \t]" nil t)
1737 (defvar gnus-article-normalized-header-length 40
1738 "Length of normalized headers.")
1740 (defun article-normalize-headers ()
1741 "Make all header lines 40 characters long."
1743 (let ((buffer-read-only nil)
1747 (article-narrow-to-head)
1750 ((< (setq column (- (gnus-point-at-eol) (point)))
1751 gnus-article-normalized-header-length)
1753 (insert (make-string
1754 (- gnus-article-normalized-header-length column)
1756 ((> column gnus-article-normalized-header-length)
1757 (gnus-put-text-property
1759 (forward-char gnus-article-normalized-header-length)
1766 (forward-line 1))))))
1768 (defun article-treat-dumbquotes ()
1769 "Translate M****s*** sm*rtq**t*s into proper text.
1770 Note that this function guesses whether a character is a sm*rtq**t* or
1771 not, so it should only be used interactively.
1773 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1774 in an attempt to provide more quoting characters. If you see
1775 something like \\222 or \\264 where you're expecting some kind of
1776 apostrophe or quotation mark, then try this wash."
1778 (article-translate-strings gnus-article-dumbquotes-map))
1780 (defun article-translate-characters (from to)
1781 "Translate all characters in the body of the article according to FROM and TO.
1782 FROM is a string of characters to translate from; to is a string of
1783 characters to translate to."
1785 (when (article-goto-body)
1786 (let ((buffer-read-only nil)
1787 (x (make-string 225 ?x))
1789 (while (< (incf i) (length x))
1792 (while (< i (length from))
1793 (aset x (aref from i) (aref to i))
1795 (translate-region (point) (point-max) x)))))
1797 (defun article-translate-strings (map)
1798 "Translate all string in the body of the article according to MAP.
1799 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1801 (when (article-goto-body)
1802 (let ((buffer-read-only nil)
1804 (while (setq elem (pop map))
1806 (while (search-forward (car elem) nil t)
1807 (replace-match (cadr elem)))))))))
1809 (defun article-treat-overstrike ()
1810 "Translate overstrikes into bold text."
1813 (when (article-goto-body)
1814 (let ((buffer-read-only nil))
1815 (while (search-forward "\b" nil t)
1816 (let ((next (char-after))
1817 (previous (char-after (- (point) 2))))
1818 ;; We do the boldification/underlining by hiding the
1819 ;; overstrikes and putting the proper text property
1823 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1824 (put-text-property (point) (1+ (point)) 'face 'bold))
1826 (gnus-article-hide-text-type
1827 (1- (point)) (1+ (point)) 'overstrike)
1829 (- (point) 2) (1- (point)) 'face 'underline))
1831 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1833 (point) (1+ (point)) 'face 'underline)))))))))
1835 (defun gnus-article-treat-unfold-headers ()
1836 "Unfold folded message headers.
1837 Only the headers that fit into the current window width will be
1840 (gnus-with-article-headers
1844 (mail-header-narrow-to-field)
1845 (let ((header (buffer-string)))
1848 (goto-char (point-min))
1849 (while (re-search-forward "\n[\t ]" nil t)
1850 (replace-match " " t t)))
1851 (setq length (- (point-max) (point-min) 1)))
1852 (when (< length (window-width))
1853 (while (re-search-forward "\n[\t ]" nil t)
1854 (replace-match " " t t)))
1855 (goto-char (point-max)))))))
1857 (defun gnus-article-treat-fold-headers ()
1858 "Fold message headers."
1860 (gnus-with-article-headers
1863 (mail-header-narrow-to-field)
1864 (mail-header-fold-field)
1865 (goto-char (point-max))))))
1867 (defun gnus-treat-smiley ()
1868 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1870 (gnus-with-article-buffer
1871 (if (memq 'smiley gnus-article-wash-types)
1872 (gnus-delete-images 'smiley)
1874 (let ((images (smiley-region (point) (point-max))))
1876 (gnus-add-wash-type 'smiley)
1877 (dolist (image images)
1878 (gnus-add-image 'smiley image)))))))
1880 (defun gnus-article-remove-images ()
1881 "Remove all images from the article buffer."
1883 (gnus-with-article-buffer
1884 (dolist (elem gnus-article-image-alist)
1885 (gnus-delete-images (car elem)))))
1887 (defun gnus-article-treat-fold-newsgroups ()
1888 "Unfold folded message headers.
1889 Only the headers that fit into the current window width will be
1892 (gnus-with-article-headers
1893 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1895 (mail-header-narrow-to-field)
1896 (while (re-search-forward ", *" nil t)
1897 (replace-match ", " t t))
1898 (mail-header-fold-field)
1899 (goto-char (point-max))))))
1901 (defun gnus-article-treat-body-boundary ()
1902 "Place a boundary line at the end of the headers."
1904 (when (and gnus-body-boundary-delimiter
1905 (> (length gnus-body-boundary-delimiter) 0))
1906 (gnus-with-article-headers
1907 (goto-char (point-max))
1908 (let ((start (point)))
1909 (insert "X-Boundary: ")
1910 (gnus-add-text-properties start (point) '(invisible t intangible t))
1912 (while (>= (1- (window-width)) (length str))
1913 (setq str (concat str gnus-body-boundary-delimiter)))
1914 (substring str 0 (1- (window-width))))
1916 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1918 (defun article-fill-long-lines ()
1919 "Fill lines that are wider than the window width."
1922 (let ((buffer-read-only nil)
1923 (width (window-width (get-buffer-window (current-buffer)))))
1926 (let ((adaptive-fill-mode nil)) ;Why? -sm
1929 (when (>= (current-column) (min fill-column width))
1930 (narrow-to-region (min (1+ (point)) (point-max))
1931 (gnus-point-at-bol))
1932 (let ((goback (point-marker)))
1933 (fill-paragraph nil)
1934 (goto-char (marker-position goback)))
1936 (forward-line 1)))))))
1938 (defun article-capitalize-sentences ()
1939 "Capitalize the first word in each sentence."
1942 (let ((buffer-read-only nil)
1943 (paragraph-start "^[\n\^L]"))
1947 (forward-sentence)))))
1949 (defun article-remove-cr ()
1950 "Remove trailing CRs and then translate remaining CRs into LFs."
1953 (let ((buffer-read-only nil))
1954 (goto-char (point-min))
1955 (while (re-search-forward "\r+$" nil t)
1956 (replace-match "" t t))
1957 (goto-char (point-min))
1958 (while (search-forward "\r" nil t)
1959 (replace-match "\n" t t)))))
1961 (defun article-remove-trailing-blank-lines ()
1962 "Remove all trailing blank lines from the article."
1965 (let ((buffer-read-only nil))
1966 (goto-char (point-max))
1970 (while (and (not (bobp))
1971 (looking-at "^[ \t]*$")
1972 (not (gnus-annotation-in-region-p
1973 (point) (gnus-point-at-eol))))
1978 (defun article-display-face ()
1979 "Display any Face headers in the header."
1981 (let ((wash-face-p buffer-read-only))
1982 (gnus-with-article-headers
1983 ;; When displaying parts, this function can be called several times on
1984 ;; the same article, without any intended toggle semantic (as typing `W
1985 ;; D d' would have). So face deletion must occur only when we come from
1986 ;; an interactive command, that is when the *Article* buffer is
1988 (if (and wash-face-p (memq 'face gnus-article-wash-types))
1989 (gnus-delete-images 'face)
1992 (when (and wash-face-p
1994 (goto-char (point-min))
1995 (not (re-search-forward "^Face:[\t ]*" nil t)))
1996 (gnus-buffer-live-p gnus-original-article-buffer))
1997 (set-buffer gnus-original-article-buffer))
1999 (mail-narrow-to-head)
2000 (while (gnus-article-goto-header "Face")
2001 (push (mail-header-field-value) faces))))
2002 (while (setq face (pop faces))
2003 (let ((png (gnus-convert-face-to-png face))
2006 (setq image (gnus-create-image png 'png t))
2007 (gnus-article-goto-header "from")
2009 (insert "From: [no `from' set]\n")
2011 (gnus-add-wash-type 'face)
2012 (gnus-add-image 'face image)
2013 (gnus-put-image image nil 'face))))))
2016 (defun article-display-x-face (&optional force)
2017 "Look for an X-Face header and display it if present."
2018 (interactive (list 'force))
2019 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2020 (gnus-with-article-headers
2021 ;; Delete the old process, if any.
2022 (when (process-status "article-x-face")
2023 (delete-process "article-x-face"))
2024 ;; See the comment in `article-display-face'.
2025 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2026 ;; We have already displayed X-Faces, so we remove them
2028 (gnus-delete-images 'xface)
2030 (let (x-faces from face)
2032 (when (and wash-face-p
2034 (goto-char (point-min))
2035 (not (re-search-forward
2036 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2037 (gnus-buffer-live-p gnus-original-article-buffer))
2038 ;; If type `W f', use gnus-original-article-buffer,
2039 ;; otherwise use the current buffer because displaying
2040 ;; RFC822 parts calls this function too.
2041 (set-buffer gnus-original-article-buffer))
2043 (mail-narrow-to-head)
2044 (while (gnus-article-goto-header "X-Face")
2045 (push (mail-header-field-value) x-faces))
2046 (setq from (message-fetch-field "from"))))
2047 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2048 ;; single external face.
2049 (when (stringp gnus-article-x-face-command)
2050 (setq x-faces (list (car x-faces))))
2051 (while (and (setq face (pop x-faces))
2052 gnus-article-x-face-command
2054 ;; Check whether this face is censored.
2055 (not gnus-article-x-face-too-ugly)
2056 (and gnus-article-x-face-too-ugly from
2057 (not (string-match gnus-article-x-face-too-ugly
2059 ;; We display the face.
2060 (if (symbolp gnus-article-x-face-command)
2061 ;; The command is a lisp function, so we call it.
2062 (if (functionp gnus-article-x-face-command)
2063 (funcall gnus-article-x-face-command face)
2064 (error "%s is not a function" gnus-article-x-face-command))
2065 ;; The command is a string, so we interpret the command
2066 ;; as a, well, command, and fork it off.
2067 (let ((process-connection-type nil))
2068 (process-kill-without-query
2070 "article-x-face" nil shell-file-name shell-command-switch
2071 gnus-article-x-face-command))
2074 (process-send-region "article-x-face"
2075 (point-min) (point-max)))
2076 (process-send-eof "article-x-face")))))))))
2078 (defun article-decode-mime-words ()
2079 "Decode all MIME-encoded words in the article."
2082 (set-buffer gnus-article-buffer)
2083 (let ((inhibit-point-motion-hooks t)
2085 (mail-parse-charset gnus-newsgroup-charset)
2086 (mail-parse-ignored-charsets
2087 (save-excursion (set-buffer gnus-summary-buffer)
2088 gnus-newsgroup-ignored-charsets)))
2089 (mail-decode-encoded-word-region (point-min) (point-max)))))
2091 (defun article-decode-charset (&optional prompt)
2092 "Decode charset-encoded text in the article.
2093 If PROMPT (the prefix), prompt for a coding system to use."
2095 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2097 (mail-parse-charset gnus-newsgroup-charset)
2098 (mail-parse-ignored-charsets
2099 (save-excursion (condition-case nil
2100 (set-buffer gnus-summary-buffer)
2102 gnus-newsgroup-ignored-charsets))
2103 ct cte ctl charset format)
2106 (article-narrow-to-head)
2107 (setq ct (message-fetch-field "Content-Type" t)
2108 cte (message-fetch-field "Content-Transfer-Encoding" t)
2109 ctl (and ct (ignore-errors
2110 (mail-header-parse-content-type ct)))
2113 (mm-read-coding-system "Charset to decode: "))
2115 (mail-content-type-get ctl 'charset)))
2116 format (and ctl (mail-content-type-get ctl 'format)))
2118 (setq cte (mail-header-strip cte)))
2119 (if (and ctl (not (string-match "/" (car ctl))))
2121 (goto-char (point-max)))
2124 (narrow-to-region (point) (point-max))
2125 (when (and (eq mail-parse-charset 'gnus-decoded)
2126 (eq (mm-body-7-or-8) '8bit))
2127 ;; The text code could have been decoded.
2128 (setq charset mail-parse-charset))
2129 (when (and (or (not ctl)
2130 (equal (car ctl) "text/plain"))
2131 (not format)) ;; article with format will decode later.
2133 charset (and cte (intern (downcase
2134 (gnus-strip-whitespace cte))))
2137 (defun article-decode-encoded-words ()
2138 "Remove encoded-word encoding from headers."
2139 (let ((inhibit-point-motion-hooks t)
2140 (mail-parse-charset gnus-newsgroup-charset)
2141 (mail-parse-ignored-charsets
2142 (save-excursion (condition-case nil
2143 (set-buffer gnus-summary-buffer)
2145 gnus-newsgroup-ignored-charsets))
2148 (article-narrow-to-head)
2149 (funcall gnus-decode-header-function (point-min) (point-max)))))
2151 (defun article-decode-group-name ()
2152 "Decode group names in `Newsgroups:'."
2153 (let ((inhibit-point-motion-hooks t)
2155 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2156 (when (and (or gnus-group-name-charset-method-alist
2157 gnus-group-name-charset-group-alist)
2158 (gnus-buffer-live-p gnus-original-article-buffer))
2160 (article-narrow-to-head)
2161 (with-current-buffer gnus-original-article-buffer
2162 (goto-char (point-min)))
2163 (while (re-search-forward
2164 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2165 (replace-match (save-match-data
2166 (gnus-decode-newsgroups
2167 ;; XXX how to use data in article buffer?
2168 (with-current-buffer gnus-original-article-buffer
2170 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2173 gnus-newsgroup-name method))
2175 (goto-char (point-min))
2176 (with-current-buffer gnus-original-article-buffer
2177 (goto-char (point-min)))
2178 (while (re-search-forward
2179 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2180 (replace-match (save-match-data
2181 (gnus-decode-newsgroups
2182 ;; XXX how to use data in article buffer?
2183 (with-current-buffer gnus-original-article-buffer
2185 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2188 gnus-newsgroup-name method))
2191 (autoload 'idna-to-unicode "idna")
2193 (defun article-decode-idna-rhs ()
2194 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2197 (let ((inhibit-point-motion-hooks t)
2199 (article-narrow-to-head)
2200 (goto-char (point-min))
2201 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2203 (when (save-match-data
2204 (and (setq ace (match-string 1))
2206 (and (re-search-backward "^[^ \t]" nil t)
2207 (looking-at "From\\|To\\|Cc")))
2208 (save-excursion (backward-char)
2209 (message-idna-inside-rhs-p))
2210 (setq unicode (idna-to-unicode ace))))
2211 (unless (string= ace unicode)
2212 (replace-match unicode nil nil nil 1)))))))))
2214 (defun article-de-quoted-unreadable (&optional force read-charset)
2215 "Translate a quoted-printable-encoded article.
2216 If FORCE, decode the article whether it is marked as quoted-printable
2218 If READ-CHARSET, ask for a coding system."
2219 (interactive (list 'force current-prefix-arg))
2221 (let ((buffer-read-only nil) type charset)
2222 (if (gnus-buffer-live-p gnus-original-article-buffer)
2223 (with-current-buffer gnus-original-article-buffer
2225 (gnus-fetch-field "content-transfer-encoding"))
2226 (let* ((ct (gnus-fetch-field "content-type"))
2229 (mail-header-parse-content-type ct)))))
2230 (setq charset (and ctl
2231 (mail-content-type-get ctl 'charset)))
2232 (if (stringp charset)
2233 (setq charset (intern (downcase charset)))))))
2235 (setq charset (mm-read-coding-system "Charset: " charset)))
2237 (setq charset gnus-newsgroup-charset))
2239 (and type (let ((case-fold-search t))
2240 (string-match "quoted-printable" type))))
2242 (quoted-printable-decode-region
2243 (point) (point-max) (mm-charset-to-coding-system charset))))))
2245 (defun article-de-base64-unreadable (&optional force read-charset)
2246 "Translate a base64 article.
2247 If FORCE, decode the article whether it is marked as base64 not.
2248 If READ-CHARSET, ask for a coding system."
2249 (interactive (list 'force current-prefix-arg))
2251 (let ((buffer-read-only nil) type charset)
2252 (if (gnus-buffer-live-p gnus-original-article-buffer)
2253 (with-current-buffer gnus-original-article-buffer
2255 (gnus-fetch-field "content-transfer-encoding"))
2256 (let* ((ct (gnus-fetch-field "content-type"))
2259 (mail-header-parse-content-type ct)))))
2260 (setq charset (and ctl
2261 (mail-content-type-get ctl 'charset)))
2262 (if (stringp charset)
2263 (setq charset (intern (downcase charset)))))))
2265 (setq charset (mm-read-coding-system "Charset: " charset)))
2267 (setq charset gnus-newsgroup-charset))
2269 (and type (let ((case-fold-search t))
2270 (string-match "base64" type))))
2273 (narrow-to-region (point) (point-max))
2274 (base64-decode-region (point-min) (point-max))
2275 (mm-decode-coding-region
2276 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2281 (defun article-decode-HZ ()
2282 "Translate a HZ-encoded article."
2286 (let ((buffer-read-only nil))
2287 (rfc1843-decode-region (point-min) (point-max)))))
2289 (defun article-unsplit-urls ()
2290 "Remove the newlines that some other mailers insert into URLs."
2293 (let ((buffer-read-only nil))
2294 (goto-char (point-min))
2295 (while (re-search-forward
2296 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2297 (replace-match "\\1\\3" t)))
2298 (when (interactive-p)
2299 (gnus-treat-article nil))))
2302 (defun article-wash-html (&optional read-charset)
2303 "Format an HTML article.
2304 If READ-CHARSET, ask for a coding system."
2307 (let ((buffer-read-only nil)
2309 (when (gnus-buffer-live-p gnus-original-article-buffer)
2310 (with-current-buffer gnus-original-article-buffer
2311 (let* ((ct (gnus-fetch-field "content-type"))
2314 (mail-header-parse-content-type ct)))))
2315 (setq charset (and ctl
2316 (mail-content-type-get ctl 'charset)))
2317 (when (stringp charset)
2318 (setq charset (intern (downcase charset)))))))
2320 (setq charset (mm-read-coding-system "Charset: " charset)))
2322 (setq charset gnus-newsgroup-charset))
2324 (save-window-excursion
2326 (narrow-to-region (point) (point-max))
2327 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2328 (entry (assq func mm-text-html-washer-alist)))
2330 (setq func (cdr entry)))
2335 (apply (car func) (cdr func))))))))))
2337 (defun gnus-article-wash-html-with-w3 ()
2338 "Wash the current buffer with w3."
2340 (let ((w3-strict-width (window-width))
2341 (url-standalone-mode t)
2342 (url-gateway-unplugged t)
2343 (w3-honor-stylesheets nil))
2345 (w3-region (point-min) (point-max))
2348 (defun gnus-article-wash-html-with-w3m ()
2349 "Wash the current buffer with emacs-w3m."
2352 (narrow-to-region (point) (point-max))
2353 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2356 w3m-force-redisplay)
2357 (w3m-region (point-min) (point-max)))
2358 (when mm-inline-text-html-with-w3m-keymap
2359 (add-text-properties
2360 (point-min) (point-max)
2361 (nconc (mm-w3m-local-map-property)
2362 '(mm-inline-text-html-with-w3m t))))))
2364 (defun article-hide-list-identifiers ()
2365 "Remove list identifies from the Subject header.
2366 The `gnus-list-identifiers' variable specifies what to do."
2368 (let ((inhibit-point-motion-hooks t)
2369 (regexp (if (consp gnus-list-identifiers)
2370 (mapconcat 'identity gnus-list-identifiers " *\\|")
2371 gnus-list-identifiers))
2376 (article-narrow-to-head)
2377 (goto-char (point-min))
2378 (while (re-search-forward
2379 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2381 (delete-region (match-beginning 2) (match-end 0))
2382 (beginning-of-line))
2383 (when (re-search-forward
2384 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2385 (delete-region (match-beginning 1) (match-end 1))))))))
2387 (defun article-hide-pem (&optional arg)
2388 "Toggle hiding of any PEM headers and signatures in the current article.
2389 If given a negative prefix, always show; if given a positive prefix,
2391 (interactive (gnus-article-hidden-arg))
2392 (unless (gnus-article-check-hidden-text 'pem arg)
2394 (let (buffer-read-only end)
2395 (goto-char (point-min))
2396 ;; Hide the horrendously ugly "header".
2397 (when (and (search-forward
2398 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2400 (setq end (1+ (match-beginning 0))))
2401 (gnus-add-wash-type 'pem)
2402 (gnus-article-hide-text-type
2404 (if (search-forward "\n\n" nil t)
2408 ;; Hide the trailer as well
2409 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2411 (gnus-article-hide-text-type
2412 (match-beginning 0) (match-end 0) 'pem)))))))
2414 (defun article-strip-banner ()
2415 "Strip the banners specified by the `banner' group parameter and by
2416 `gnus-article-address-banner-alist'."
2420 (let ((inhibit-point-motion-hooks t))
2421 (when (gnus-parameter-banner gnus-newsgroup-name)
2422 (article-really-strip-banner
2423 (gnus-parameter-banner gnus-newsgroup-name)))
2424 (when gnus-article-address-banner-alist
2425 (article-really-strip-banner
2426 (let ((from (save-restriction
2428 (article-narrow-to-head)
2429 (mail-fetch-field "from"))))
2432 (caar (mail-header-parse-addresses from))))
2434 (dolist (pair gnus-article-address-banner-alist)
2435 (when (string-match (car pair) from)
2436 (throw 'found (cdr pair)))))))))))))
2438 (defun article-really-strip-banner (banner)
2439 "Strip the banner specified by the argument."
2442 (let ((inhibit-point-motion-hooks t)
2443 (gnus-signature-limit nil)
2447 ((eq banner 'signature)
2448 (when (gnus-article-narrow-to-signature)
2451 (delete-region (point) (point-max))))
2453 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2454 (while (re-search-forward banner nil t)
2455 (delete-region (match-beginning 0) (match-end 0)))))
2457 (while (re-search-forward banner nil t)
2458 (delete-region (match-beginning 0) (match-end 0)))))))))
2460 (defun article-babel ()
2461 "Translate article using an online translation service."
2465 (set-buffer gnus-article-buffer)
2466 (when (article-goto-body)
2467 (let* ((buffer-read-only nil)
2470 (orig (buffer-substring start end))
2471 (trans (babel-as-string orig)))
2473 (narrow-to-region start end)
2474 (delete-region start end)
2477 (defun article-hide-signature (&optional arg)
2478 "Hide the signature in the current article.
2479 If given a negative prefix, always show; if given a positive prefix,
2481 (interactive (gnus-article-hidden-arg))
2482 (unless (gnus-article-check-hidden-text 'signature arg)
2485 (let ((buffer-read-only nil))
2486 (when (gnus-article-narrow-to-signature)
2487 (gnus-article-hide-text-type
2488 (point-min) (point-max) 'signature))))))
2489 (gnus-set-mode-line 'article))
2491 (defun article-strip-headers-in-body ()
2492 "Strip offensive headers from bodies."
2496 (let ((case-fold-search t))
2497 (when (looking-at "x-no-archive:")
2498 (gnus-delete-line)))))
2500 (defun article-strip-leading-blank-lines ()
2501 "Remove all blank lines from the beginning of the article."
2504 (let ((inhibit-point-motion-hooks t)
2506 (when (article-goto-body)
2507 (while (and (not (eobp))
2508 (looking-at "[ \t]*$"))
2509 (gnus-delete-line))))))
2511 (defun article-narrow-to-head ()
2512 "Narrow the buffer to the head of the message.
2513 Point is left at the beginning of the narrowed-to region."
2515 (goto-char (point-min))
2516 (if (search-forward "\n\n" nil 1)
2519 (goto-char (point-min)))
2521 (defun article-goto-body ()
2522 "Place point at the start of the body."
2523 (goto-char (point-min))
2525 ;; This variable is only bound when dealing with separate
2527 (article-goto-body-goes-to-point-min-p
2529 ((search-forward "\n\n" nil t)
2532 (goto-char (point-max))
2535 (defun article-strip-multiple-blank-lines ()
2536 "Replace consecutive blank lines with one empty line."
2539 (let ((inhibit-point-motion-hooks t)
2541 ;; First make all blank lines empty.
2543 (while (re-search-forward "^[ \t]+$" nil t)
2544 (unless (gnus-annotation-in-region-p
2545 (match-beginning 0) (match-end 0))
2546 (replace-match "" nil t)))
2547 ;; Then replace multiple empty lines with a single empty line.
2549 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2550 (unless (gnus-annotation-in-region-p
2551 (match-beginning 0) (match-end 0))
2552 (delete-region (match-beginning 1) (match-end 1)))))))
2554 (defun article-strip-leading-space ()
2555 "Remove all white space from the beginning of the lines in the article."
2558 (let ((inhibit-point-motion-hooks t)
2561 (while (re-search-forward "^[ \t]+" nil t)
2562 (replace-match "" t t)))))
2564 (defun article-strip-trailing-space ()
2565 "Remove all white space from the end of the lines in the article."
2568 (let ((inhibit-point-motion-hooks t)
2571 (while (re-search-forward "[ \t]+$" nil t)
2572 (replace-match "" t t)))))
2574 (defun article-strip-blank-lines ()
2575 "Strip leading, trailing and multiple blank lines."
2577 (article-strip-leading-blank-lines)
2578 (article-remove-trailing-blank-lines)
2579 (article-strip-multiple-blank-lines))
2581 (defun article-strip-all-blank-lines ()
2582 "Strip all blank lines."
2585 (let ((inhibit-point-motion-hooks t)
2588 (while (re-search-forward "^[ \t]*\n" nil t)
2589 (replace-match "" t t)))))
2591 (defun gnus-article-narrow-to-signature ()
2592 "Narrow to the signature; return t if a signature is found, else nil."
2593 (let ((inhibit-point-motion-hooks t))
2594 (when (gnus-article-search-signature)
2596 ;; Check whether we have some limits to what we consider
2597 ;; to be a signature.
2598 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2599 (list gnus-signature-limit)))
2601 (while (setq limit (pop limits))
2602 (if (or (and (integerp limit)
2603 (< (- (point-max) (point)) limit))
2605 (< (count-lines (point) (point-max)) limit))
2606 (and (functionp limit)
2608 (and (stringp limit)
2609 (not (re-search-forward limit nil t))))
2610 () ; This limit did not succeed.
2614 (narrow-to-region (point) (point-max))
2617 (defun gnus-article-search-signature ()
2618 "Search the current buffer for the signature separator.
2619 Put point at the beginning of the signature separator."
2620 (let ((cur (point)))
2621 (goto-char (point-max))
2622 (if (if (stringp gnus-signature-separator)
2623 (re-search-backward gnus-signature-separator nil t)
2624 (let ((seps gnus-signature-separator))
2626 (not (re-search-backward (car seps) nil t)))
2633 (defun gnus-article-hidden-arg ()
2634 "Return the current prefix arg as a number, or 0 if no prefix."
2635 (list (if current-prefix-arg
2636 (prefix-numeric-value current-prefix-arg)
2639 (defun gnus-article-check-hidden-text (type arg)
2640 "Return nil if hiding is necessary.
2641 Arg can be nil or a number. nil and positive means hide, negative
2642 means show, 0 means toggle."
2645 (let ((hide (gnus-article-hidden-text-p type)))
2651 (gnus-article-show-hidden-text type)
2654 (if (eq hide 'hidden)
2656 (gnus-article-show-hidden-text type)
2660 (defun gnus-article-hidden-text-p (type)
2661 "Say whether the current buffer contains hidden text of type TYPE."
2662 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2664 (not (get-text-property pos 'invisible))
2665 (not (get-text-property pos 'dummy-invisible)))
2667 (text-property-any (1+ pos) (point-max) 'article-type type)))
2672 (defun gnus-article-show-hidden-text (type &optional dummy)
2673 "Show all hidden text of type TYPE.
2674 Originally it is hide instead of DUMMY."
2675 (let ((buffer-read-only nil)
2676 (inhibit-point-motion-hooks t))
2677 (gnus-remove-text-properties-when
2679 (point-min) (point-max)
2680 (cons 'article-type (cons type
2681 gnus-hidden-properties)))
2682 (gnus-delete-wash-type type)))
2684 (defconst article-time-units
2685 `((year . ,(* 365.25 24 60 60))
2686 (week . ,(* 7 24 60 60))
2687 (day . ,(* 24 60 60))
2691 "Mapping from time units to seconds.")
2693 (defun gnus-article-forward-header ()
2694 "Move point to the start of the next header.
2695 If the current header is a continuation header, this can be several
2700 (if (looking-at "[ \t]+[^ \t]")
2704 (defun article-date-ut (&optional type highlight header)
2705 "Convert DATE date to universal time in the current article.
2706 If TYPE is `local', convert to local time; if it is `lapsed', output
2707 how much time has lapsed since DATE. For `lapsed', the value of
2708 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2709 should replace the \"Date:\" one, or should be added below it."
2710 (interactive (list 'ut t))
2711 (let* ((header (or header
2712 (message-fetch-field "date")
2714 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2717 ((not gnus-article-date-lapsed-new-header)
2723 (date (if (vectorp header) (mail-header-date header)
2725 (inhibit-point-motion-hooks t)
2730 (article-narrow-to-head)
2731 (when (re-search-forward tdate-regexp nil t)
2732 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2733 date (or (get-text-property (gnus-point-at-bol)
2736 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2738 (when (and date (not (string= date "")))
2739 (goto-char (point-min))
2740 (let ((buffer-read-only nil))
2741 ;; Delete any old Date headers.
2742 (while (re-search-forward date-regexp nil t)
2744 (delete-region (progn (beginning-of-line) (point))
2745 (progn (gnus-article-forward-header)
2747 (delete-region (progn (beginning-of-line) (point))
2748 (progn (gnus-article-forward-header)
2751 (setq pos (point))))
2752 (when (and (not pos)
2753 (re-search-forward tdate-regexp nil t))
2757 (insert (article-make-date-line date (or type 'ut)))
2763 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2764 (put-text-property (match-beginning 1) (1+ (match-end 1))
2765 'original-date date)
2766 (put-text-property (match-beginning 1) (1+ (match-end 1))
2768 (put-text-property (match-beginning 2) (match-end 2)
2771 (defun article-make-date-line (date type)
2772 "Return a DATE line of TYPE."
2773 (unless (memq type '(local ut original user iso8601 lapsed english))
2774 (error "Unknown conversion type: %s" type))
2776 (let ((time (date-to-time date)))
2778 ;; Convert to the local timezone.
2780 (let ((tz (car (current-time-zone time))))
2781 (format "Date: %s %s%02d%02d" (current-time-string time)
2782 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2783 (/ (% (abs tz) 3600) 60))))
2784 ;; Convert to Universal Time.
2787 (current-time-string
2788 (let* ((e (parse-time-string date))
2789 (tm (apply 'encode-time e))
2791 (ls (- (cadr tm) (car (current-time-zone time)))))
2792 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2793 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2796 ;; Get the original date from the article.
2797 ((eq type 'original)
2798 (concat "Date: " (if (string-match "\n+$" date)
2799 (substring date 0 (match-beginning 0))
2801 ;; Let the user define the format.
2803 (let ((format (or (condition-case nil
2804 (with-current-buffer gnus-summary-buffer
2805 gnus-article-time-format)
2807 gnus-article-time-format)))
2808 (if (functionp format)
2809 (funcall format time)
2810 (concat "Date: " (format-time-string format time)))))
2813 (let ((tz (car (current-time-zone time))))
2816 (format-time-string "%Y%m%dT%H%M%S" time)
2817 (format "%s%02d%02d"
2818 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2819 (/ (% (abs tz) 3600) 60)))))
2820 ;; Do an X-Sent lapsed format.
2822 ;; If the date is seriously mangled, the timezone functions are
2823 ;; liable to bug out, so we ignore all errors.
2824 (let* ((now (current-time))
2825 (real-time (subtract-time now time))
2826 (real-sec (and real-time
2827 (+ (* (float (car real-time)) 65536)
2829 (sec (and real-time (abs real-sec)))
2839 ;; This is a bit convoluted, but basically we go
2840 ;; through the time units for years, weeks, etc,
2841 ;; and divide things to see whether that results
2842 ;; in positive answers.
2845 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2846 ;; The (remaining) seconds are too few to
2847 ;; be divided into this time unit.
2849 ;; It's big enough, so we output it.
2850 (setq sec (- sec (* num (cdr unit))))
2852 (concat (if prev ", " "") (int-to-string
2854 " " (symbol-name (car unit))
2855 (if (> num 1) "s" ""))
2857 article-time-units "")
2858 ;; If dates are odd, then it might appear like the
2859 ;; article was sent in the future.
2862 " in the future"))))))
2863 ;; Display the date in proper English
2865 (let ((dtime (decode-time time)))
2868 (number-to-string (nth 3 dtime))
2869 (let ((digit (% (nth 3 dtime) 10)))
2871 ((memq (nth 3 dtime) '(11 12 13)) "th")
2877 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2879 (number-to-string (nth 5 dtime))
2881 (format "%02d" (nth 2 dtime))
2883 (format "%02d" (nth 1 dtime)))))))
2885 (format "Date: %s (from Gnus)" date))))
2887 (defun article-date-local (&optional highlight)
2888 "Convert the current article date to the local timezone."
2889 (interactive (list t))
2890 (article-date-ut 'local highlight))
2892 (defun article-date-english (&optional highlight)
2893 "Convert the current article date to something that is proper English."
2894 (interactive (list t))
2895 (article-date-ut 'english highlight))
2897 (defun article-date-original (&optional highlight)
2898 "Convert the current article date to what it was originally.
2899 This is only useful if you have used some other date conversion
2900 function and want to see what the date was before converting."
2901 (interactive (list t))
2902 (article-date-ut 'original highlight))
2904 (defun article-date-lapsed (&optional highlight)
2905 "Convert the current article date to time lapsed since it was sent."
2906 (interactive (list t))
2907 (article-date-ut 'lapsed highlight))
2909 (defun article-update-date-lapsed ()
2910 "Function to be run from a timer to update the lapsed time line."
2911 (let (deactivate-mark)
2916 (set-buffer (window-buffer w))
2917 (when (eq major-mode 'gnus-article-mode)
2918 (goto-char (point-min))
2919 (when (re-search-forward "^X-Sent:" nil t)
2920 (article-date-lapsed t))))
2923 (defun gnus-start-date-timer (&optional n)
2924 "Start a timer to update the X-Sent header in the article buffers.
2925 The numerical prefix says how frequently (in seconds) the function
2930 (gnus-stop-date-timer)
2931 (setq article-lapsed-timer
2932 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2934 (defun gnus-stop-date-timer ()
2935 "Stop the X-Sent timer."
2937 (when article-lapsed-timer
2938 (nnheader-cancel-timer article-lapsed-timer)
2939 (setq article-lapsed-timer nil)))
2941 (defun article-date-user (&optional highlight)
2942 "Convert the current article date to the user-defined format.
2943 This format is defined by the `gnus-article-time-format' variable."
2944 (interactive (list t))
2945 (article-date-ut 'user highlight))
2947 (defun article-date-iso8601 (&optional highlight)
2948 "Convert the current article date to ISO8601."
2949 (interactive (list t))
2950 (article-date-ut 'iso8601 highlight))
2952 ;; (defun article-show-all ()
2953 ;; "Show all hidden text in the article buffer."
2956 ;; (let ((buffer-read-only nil))
2957 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2959 (defun article-remove-leading-whitespace ()
2960 "Remove excessive whitespace from all headers."
2964 (let ((buffer-read-only nil))
2965 (article-narrow-to-head)
2966 (goto-char (point-min))
2967 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2968 (delete-region (match-beginning 1) (match-end 1)))))))
2970 (defun article-emphasize (&optional arg)
2971 "Emphasize text according to `gnus-emphasis-alist'."
2972 (interactive (gnus-article-hidden-arg))
2973 (unless (gnus-article-check-hidden-text 'emphasis arg)
2977 (with-current-buffer gnus-summary-buffer
2978 gnus-article-emphasis-alist)
2980 gnus-emphasis-alist))
2981 (buffer-read-only nil)
2982 (props (append '(article-type emphasis)
2983 gnus-hidden-properties))
2984 regexp elem beg invisible visible face)
2987 (while (setq elem (pop alist))
2989 (setq regexp (car elem)
2990 invisible (nth 1 elem)
2991 visible (nth 2 elem)
2993 (while (re-search-forward regexp nil t)
2994 (when (and (match-beginning visible) (match-beginning invisible))
2995 (gnus-article-hide-text
2996 (match-beginning invisible) (match-end invisible) props)
2997 (gnus-article-unhide-text-type
2998 (match-beginning visible) (match-end visible) 'emphasis)
2999 (gnus-put-overlay-excluding-newlines
3000 (match-beginning visible) (match-end visible) 'face face)
3001 (gnus-add-wash-type 'emphasis)
3002 (goto-char (match-end invisible)))))))))
3004 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3005 "Setup newsgroup emphasis alist."
3006 (unless gnus-article-emphasis-alist
3007 (let ((name (and gnus-newsgroup-name
3008 (gnus-group-real-name gnus-newsgroup-name))))
3009 (make-local-variable 'gnus-article-emphasis-alist)
3010 (setq gnus-article-emphasis-alist
3012 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3013 (while (setq elem (pop alist))
3014 (when (and name (string-match (car elem) name))
3016 highlight (copy-sequence (cdr elem)))))
3018 (copy-sequence highlight-words)
3019 (if gnus-newsgroup-name
3020 (copy-sequence (gnus-group-find-parameter
3021 gnus-newsgroup-name 'highlight-words t)))
3022 gnus-emphasis-alist)))))
3025 (defvar gnus-summary-article-menu)
3026 (defvar gnus-summary-post-menu))
3028 ;;; Saving functions.
3030 (defun gnus-article-save (save-buffer file &optional num)
3031 "Save the currently selected article."
3032 (unless gnus-save-all-headers
3033 ;; Remove headers according to `gnus-saved-headers'.
3034 (let ((gnus-visible-headers
3035 (or gnus-saved-headers gnus-visible-headers))
3036 (gnus-article-buffer save-buffer))
3038 (set-buffer save-buffer)
3039 (article-hide-headers 1 t))))
3040 (save-window-excursion
3041 (if (not gnus-default-article-saver)
3042 (error "No default saver is defined")
3043 ;; !!! Magic! The saving functions all save
3044 ;; `gnus-save-article-buffer' (or so they think), but we
3045 ;; bind that variable to our save-buffer.
3046 (set-buffer gnus-article-buffer)
3047 (let* ((gnus-save-article-buffer save-buffer)
3050 ((not gnus-prompt-before-saving) 'default)
3051 ((eq gnus-prompt-before-saving 'always) nil)
3053 (gnus-number-of-articles-to-be-saved
3054 (when (eq gnus-prompt-before-saving t)
3056 (set-buffer gnus-article-current-summary)
3057 (funcall gnus-default-article-saver filename)))))
3059 (defun gnus-read-save-file-name (prompt &optional filename
3060 function group headers variable)
3062 (funcall function group headers (symbol-value variable)))
3067 ((eq filename 'default)
3073 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3076 (if (and gnus-number-of-articles-to-be-saved
3077 (> gnus-number-of-articles-to-be-saved 1))
3078 (format "these %d articles"
3079 gnus-number-of-articles-to-be-saved)
3082 ;; Let the split methods have their say.
3084 ;; No split name was found.
3087 (concat prompt " (default "
3088 (file-name-nondirectory default-name) ") ")
3089 (file-name-directory default-name)
3091 ;; A single group name is returned.
3092 ((stringp split-name)
3094 (funcall function split-name headers
3095 (symbol-value variable)))
3097 (concat prompt " (default "
3098 (file-name-nondirectory default-name) ") ")
3099 (file-name-directory default-name)
3101 ;; A single split name was found
3102 ((= 1 (length split-name))
3103 (let* ((name (expand-file-name
3105 gnus-article-save-directory))
3106 (dir (cond ((file-directory-p name)
3107 (file-name-as-directory name))
3108 ((file-exists-p name) name)
3109 (t gnus-article-save-directory))))
3111 (concat prompt " (default " name ") ")
3113 ;; A list of splits was found.
3115 (setq split-name (nreverse split-name))
3117 (let ((file-name-history
3118 (nconc split-name file-name-history)))
3122 (concat prompt " (`M-p' for defaults) ")
3123 gnus-article-save-directory
3125 gnus-article-save-directory)))
3126 (car (push result file-name-history)))))))
3127 ;; Create the directory.
3128 (gnus-make-directory (file-name-directory file))
3129 ;; If we have read a directory, we append the default file name.
3130 (when (file-directory-p file)
3131 (setq file (expand-file-name (file-name-nondirectory
3133 (file-name-as-directory file))))
3134 ;; Possibly translate some characters.
3135 (nnheader-translate-file-chars file))))))
3136 (gnus-make-directory (file-name-directory result))
3137 (set variable result)))
3139 (defun gnus-article-archive-name (group)
3140 "Return the first instance of an \"Archive-name\" in the current buffer."
3141 (let ((case-fold-search t))
3142 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3143 (nnheader-concat gnus-article-save-directory
3144 (match-string 1)))))
3146 (defun gnus-article-nndoc-name (group)
3147 "If GROUP is an nndoc group, return the name of the parent group."
3148 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3149 (gnus-group-get-parameter group 'save-article-group)))
3151 (defun gnus-summary-save-in-rmail (&optional filename)
3152 "Append this article to Rmail file.
3153 Optional argument FILENAME specifies file name.
3154 Directory to save to is default to `gnus-article-save-directory'."
3155 (setq filename (gnus-read-save-file-name
3156 "Save %s in rmail file:" filename
3157 gnus-rmail-save-name gnus-newsgroup-name
3158 gnus-current-headers 'gnus-newsgroup-last-rmail))
3159 (gnus-eval-in-buffer-window gnus-save-article-buffer
3163 (gnus-output-to-rmail filename))))
3166 (defun gnus-summary-save-in-mail (&optional filename)
3167 "Append this article to Unix mail file.
3168 Optional argument FILENAME specifies file name.
3169 Directory to save to is default to `gnus-article-save-directory'."
3170 (setq filename (gnus-read-save-file-name
3171 "Save %s in Unix mail file:" filename
3172 gnus-mail-save-name gnus-newsgroup-name
3173 gnus-current-headers 'gnus-newsgroup-last-mail))
3174 (gnus-eval-in-buffer-window gnus-save-article-buffer
3178 (if (and (file-readable-p filename)
3179 (file-regular-p filename)
3180 (mail-file-babyl-p filename))
3181 (rmail-output-to-rmail-file filename t)
3182 (gnus-output-to-mail filename)))))
3185 (defun gnus-summary-save-in-file (&optional filename overwrite)
3186 "Append this article to file.
3187 Optional argument FILENAME specifies file name.
3188 Directory to save to is default to `gnus-article-save-directory'."
3189 (setq filename (gnus-read-save-file-name
3190 "Save %s in file:" filename
3191 gnus-file-save-name gnus-newsgroup-name
3192 gnus-current-headers 'gnus-newsgroup-last-file))
3193 (gnus-eval-in-buffer-window gnus-save-article-buffer
3197 (when (and overwrite
3198 (file-exists-p filename))
3199 (delete-file filename))
3200 (gnus-output-to-file filename))))
3203 (defun gnus-summary-write-to-file (&optional filename)
3204 "Write this article to a file, overwriting it if the file exists.
3205 Optional argument FILENAME specifies file name.
3206 The directory to save in defaults to `gnus-article-save-directory'."
3207 (gnus-summary-save-in-file nil t))
3209 (defun gnus-summary-save-body-in-file (&optional filename)
3210 "Append this article body to a file.
3211 Optional argument FILENAME specifies file name.
3212 The directory to save in defaults to `gnus-article-save-directory'."
3213 (setq filename (gnus-read-save-file-name
3214 "Save %s body in file:" filename
3215 gnus-file-save-name gnus-newsgroup-name
3216 gnus-current-headers 'gnus-newsgroup-last-file))
3217 (gnus-eval-in-buffer-window gnus-save-article-buffer
3221 (when (article-goto-body)
3222 (narrow-to-region (point) (point-max)))
3223 (gnus-output-to-file filename))))
3226 (defun gnus-summary-save-in-pipe (&optional command)
3227 "Pipe this article to subprocess."
3229 (cond ((and (eq command 'default)
3230 gnus-last-shell-command)
3231 gnus-last-shell-command)
3236 "Shell command on %s: "
3237 (if (and gnus-number-of-articles-to-be-saved
3238 (> gnus-number-of-articles-to-be-saved 1))
3239 (format "these %d articles"
3240 gnus-number-of-articles-to-be-saved)
3242 gnus-last-shell-command))))
3243 (when (string-equal command "")
3244 (if gnus-last-shell-command
3245 (setq command gnus-last-shell-command)
3246 (error "A command is required")))
3247 (gnus-eval-in-buffer-window gnus-article-buffer
3250 (shell-command-on-region (point-min) (point-max) command nil)))
3251 (setq gnus-last-shell-command command))
3253 (defmacro gnus-read-string (prompt &optional initial-contents history
3255 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3256 (if (and (featurep 'xemacs)
3257 (< emacs-minor-version 2))
3258 `(read-string ,prompt ,initial-contents ,history)
3259 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3261 (defun gnus-summary-pipe-to-muttprint (&optional command)
3262 "Pipe this article to muttprint."
3263 (setq command (gnus-read-string
3264 "Print using command: " gnus-summary-muttprint-program
3265 nil gnus-summary-muttprint-program))
3266 (gnus-summary-save-in-pipe command))
3268 ;;; Article file names when saving.
3270 (defun gnus-capitalize-newsgroup (newsgroup)
3271 "Capitalize NEWSGROUP name."
3272 (when (not (zerop (length newsgroup)))
3273 (concat (char-to-string (upcase (aref newsgroup 0)))
3274 (substring newsgroup 1))))
3276 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3277 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3278 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3279 Otherwise, it is like ~/News/news/group/num."
3282 (concat (if (gnus-use-long-file-name 'not-save)
3283 (gnus-capitalize-newsgroup newsgroup)
3284 (gnus-newsgroup-directory-form newsgroup))
3285 "/" (int-to-string (mail-header-number headers)))
3286 gnus-article-save-directory)))
3288 (string-equal (file-name-directory default)
3289 (file-name-directory last-file))
3290 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3292 (or last-file default))))
3294 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3295 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3296 If variable `gnus-use-long-file-name' is non-nil, it is
3297 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3300 (concat (if (gnus-use-long-file-name 'not-save)
3302 (gnus-newsgroup-directory-form newsgroup))
3303 "/" (int-to-string (mail-header-number headers)))
3304 gnus-article-save-directory)))
3306 (string-equal (file-name-directory default)
3307 (file-name-directory last-file))
3308 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3310 (or last-file default))))
3312 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3313 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3314 If variable `gnus-use-long-file-name' is non-nil, it is
3315 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3318 (if (gnus-use-long-file-name 'not-save)
3321 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3323 gnus-article-save-directory)))
3325 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3326 "Generate file name from sender."
3327 (let ((from (mail-header-from headers)))
3329 (if (and from (string-match "\\([^ <]+\\)@" from))
3330 (match-string 1 from)
3332 gnus-article-save-directory)))
3334 (defun article-verify-x-pgp-sig ()
3337 (if (gnus-buffer-live-p gnus-original-article-buffer)
3338 (let ((sig (with-current-buffer gnus-original-article-buffer
3339 (gnus-fetch-field "X-PGP-Sig")))
3343 (mml2015-clear-verify-function))
3345 (insert-buffer-substring gnus-original-article-buffer)
3346 (setq items (split-string sig))
3347 (message-narrow-to-head)
3348 (let ((inhibit-point-motion-hooks t)
3349 (case-fold-search t))
3350 ;; Don't verify multiple headers.
3351 (setq headers (mapconcat (lambda (header)
3353 (mail-fetch-field header)
3355 (split-string (nth 1 items) ",") "")))
3356 (delete-region (point-min) (point-max))
3357 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3358 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3363 (if (looking-at "^-")
3366 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3367 (insert "Version: " (car items) "\n\n")
3368 (insert (mapconcat 'identity (cddr items) "\n"))
3369 (insert "\n-----END PGP SIGNATURE-----\n")
3370 (let ((mm-security-handle (list (format "multipart/signed"))))
3371 (mml2015-clean-buffer)
3372 (let ((coding-system-for-write (or gnus-newsgroup-charset
3374 (funcall (mml2015-clear-verify-function)))
3376 (or (mm-handle-multipart-ctl-parameter
3377 mm-security-handle 'gnus-details)
3378 (mm-handle-multipart-ctl-parameter
3379 mm-security-handle 'gnus-info)))))
3381 (let (buffer-read-only bface eface)
3383 (message-narrow-to-head)
3384 (goto-char (point-max))
3386 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3387 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3388 (message-remove-header "X-Gnus-PGP-Verify")
3389 (if (re-search-forward "^X-PGP-Sig:" nil t)
3391 (goto-char (point-max)))
3392 (narrow-to-region (point) (point))
3393 (insert "X-Gnus-PGP-Verify: " info "\n")
3394 (goto-char (point-min))
3397 (if (not (looking-at "^[ \t]"))
3401 (goto-char (point-min))
3402 (when (looking-at "\\([^:]+\\): *")
3403 (put-text-property (match-beginning 1) (1+ (match-end 1))
3405 (put-text-property (match-end 0) (point-max)
3406 'face eface)))))))))
3408 (defun article-verify-cancel-lock ()
3409 "Verify Cancel-Lock header."
3411 (if (gnus-buffer-live-p gnus-original-article-buffer)
3412 (canlock-verify gnus-original-article-buffer)))
3419 (setq afunc (car func)
3422 gfunc (intern (format "gnus-%s" func))))
3424 (when (fboundp afunc)
3425 `(lambda (&optional interactive &rest args)
3426 ,(documentation afunc t)
3427 (interactive (list t))
3429 (set-buffer gnus-article-buffer)
3431 (call-interactively ',afunc)
3432 (apply ',afunc args))))))))
3433 '(article-hide-headers
3434 article-verify-x-pgp-sig
3435 article-verify-cancel-lock
3436 article-hide-boring-headers
3437 article-treat-overstrike
3438 article-fill-long-lines
3439 article-capitalize-sentences
3441 article-remove-leading-whitespace
3442 article-display-x-face
3443 article-display-face
3444 article-de-quoted-unreadable
3445 article-de-base64-unreadable
3448 article-unsplit-urls
3449 article-hide-list-identifiers
3450 article-strip-banner
3453 article-hide-signature
3454 article-strip-headers-in-body
3455 article-remove-trailing-blank-lines
3456 article-strip-leading-blank-lines
3457 article-strip-multiple-blank-lines
3458 article-strip-leading-space
3459 article-strip-trailing-space
3460 article-strip-blank-lines
3461 article-strip-all-blank-lines
3463 article-date-english
3464 article-date-iso8601
3465 article-date-original
3467 article-decode-mime-words
3468 article-decode-charset
3469 article-decode-encoded-words
3473 article-treat-dumbquotes
3474 article-normalize-headers
3475 ;; (article-show-all . gnus-article-show-all-headers)
3479 ;;; Gnus article mode
3482 (put 'gnus-article-mode 'mode-class 'special)
3484 (set-keymap-parent gnus-article-mode-map widget-keymap)
3486 (gnus-define-keys gnus-article-mode-map
3487 " " gnus-article-goto-next-page
3488 "\177" gnus-article-goto-prev-page
3489 [delete] gnus-article-goto-prev-page
3490 [backspace] gnus-article-goto-prev-page
3491 "\C-c^" gnus-article-refer-article
3492 "h" gnus-article-show-summary
3493 "s" gnus-article-show-summary
3494 "\C-c\C-m" gnus-article-mail
3495 "?" gnus-article-describe-briefly
3496 "e" gnus-summary-edit-article
3497 "<" beginning-of-buffer
3499 "\C-c\C-i" gnus-info-find-node
3501 "R" gnus-article-reply-with-original
3502 "F" gnus-article-followup-with-original
3503 "\C-hk" gnus-article-describe-key
3504 "\C-hc" gnus-article-describe-key-briefly
3506 "\C-d" gnus-article-read-summary-keys
3507 "\M-*" gnus-article-read-summary-keys
3508 "\M-#" gnus-article-read-summary-keys
3509 "\M-^" gnus-article-read-summary-keys
3510 "\M-g" gnus-article-read-summary-keys)
3512 (substitute-key-definition
3513 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3515 (defun gnus-article-make-menu-bar ()
3516 (unless (boundp 'gnus-article-commands-menu)
3517 (gnus-summary-make-menu-bar))
3518 (gnus-turn-off-edit-menu 'article)
3519 (unless (boundp 'gnus-article-article-menu)
3521 gnus-article-article-menu gnus-article-mode-map ""
3523 ["Scroll forwards" gnus-article-goto-next-page t]
3524 ["Scroll backwards" gnus-article-goto-prev-page t]
3525 ["Show summary" gnus-article-show-summary t]
3526 ["Fetch Message-ID at point" gnus-article-refer-article t]
3527 ["Mail to address at point" gnus-article-mail t]
3528 ["Send a bug report" gnus-bug t]))
3531 gnus-article-treatment-menu gnus-article-mode-map ""
3532 ;; Fixme: this should use :active (and maybe :visible).
3534 ["Hide headers" gnus-article-hide-headers t]
3535 ["Hide signature" gnus-article-hide-signature t]
3536 ["Hide citation" gnus-article-hide-citation t]
3537 ["Treat overstrike" gnus-article-treat-overstrike t]
3538 ["Remove carriage return" gnus-article-remove-cr t]
3539 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3540 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3541 ["Remove base64" gnus-article-de-base64-unreadable t]
3542 ["Treat html" gnus-article-wash-html t]
3543 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3544 ["Decode HZ" gnus-article-decode-HZ t]))
3546 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3548 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3550 (gnus-run-hooks 'gnus-article-menu-hook)))
3552 (defun gnus-article-mode ()
3553 "Major mode for displaying an article.
3555 All normal editing commands are switched off.
3557 The following commands are available in addition to all summary mode
3559 \\<gnus-article-mode-map>
3560 \\[gnus-article-next-page]\t Scroll the article one page forwards
3561 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3562 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3563 \\[gnus-article-show-summary]\t Display the summary buffer
3564 \\[gnus-article-mail]\t Send a reply to the address near point
3565 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3566 \\[gnus-info-find-node]\t Go to the Gnus info node"
3568 (gnus-simplify-mode-line)
3569 (setq mode-name "Article")
3570 (setq major-mode 'gnus-article-mode)
3571 (make-local-variable 'minor-mode-alist)
3572 (use-local-map gnus-article-mode-map)
3573 (when (gnus-visual-p 'article-menu 'menu)
3574 (gnus-article-make-menu-bar)
3575 (when gnus-summary-tool-bar-map
3576 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3577 (gnus-update-format-specifications nil 'article-mode)
3578 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3579 (make-local-variable 'gnus-page-broken)
3580 (make-local-variable 'gnus-button-marker-list)
3581 (make-local-variable 'gnus-article-current-summary)
3582 (make-local-variable 'gnus-article-mime-handles)
3583 (make-local-variable 'gnus-article-decoded-p)
3584 (make-local-variable 'gnus-article-mime-handle-alist)
3585 (make-local-variable 'gnus-article-wash-types)
3586 (make-local-variable 'gnus-article-image-alist)
3587 (make-local-variable 'gnus-article-charset)
3588 (make-local-variable 'gnus-article-ignored-charsets)
3589 (gnus-set-default-directory)
3590 (buffer-disable-undo)
3591 (setq buffer-read-only t)
3592 (set-syntax-table gnus-article-mode-syntax-table)
3593 (mm-enable-multibyte)
3594 (gnus-run-hooks 'gnus-article-mode-hook))
3596 (defun gnus-article-setup-buffer ()
3597 "Initialize the article buffer."
3598 (let* ((name (if gnus-single-article-buffer "*Article*"
3599 (concat "*Article " gnus-newsgroup-name "*")))
3601 (progn (string-match "\\*Article" name)
3602 (concat " *Original Article"
3603 (substring name (match-end 0))))))
3604 (setq gnus-article-buffer name)
3605 (setq gnus-original-article-buffer original)
3606 (setq gnus-article-mime-handle-alist nil)
3607 ;; This might be a variable local to the summary buffer.
3608 (unless gnus-single-article-buffer
3610 (set-buffer gnus-summary-buffer)
3611 (setq gnus-article-buffer name)
3612 (setq gnus-original-article-buffer original)
3613 (gnus-set-global-variables)))
3614 (gnus-article-setup-highlight-words)
3615 ;; Init original article buffer.
3617 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3618 (mm-enable-multibyte)
3619 (setq major-mode 'gnus-original-article-mode)
3620 (make-local-variable 'gnus-original-article))
3621 (if (get-buffer name)
3624 (when (and gnus-article-edit-mode
3627 (y-or-n-p "Article mode edit in progress; discard? ")))
3628 (error "Action aborted"))
3629 (set (make-local-variable 'gnus-article-edit-mode) nil)
3630 (when gnus-article-mime-handles
3631 (mm-destroy-parts gnus-article-mime-handles)
3632 (setq gnus-article-mime-handles nil))
3633 ;; Set it to nil in article-buffer!
3634 (setq gnus-article-mime-handle-alist nil)
3635 (buffer-disable-undo)
3636 (setq buffer-read-only t)
3637 ;; This list just keeps growing if we don't reset it.
3638 (setq gnus-button-marker-list nil)
3639 (unless (eq major-mode 'gnus-article-mode)
3640 (gnus-article-mode))
3643 (set-buffer (gnus-get-buffer-create name))
3645 (make-local-variable 'gnus-summary-buffer)
3646 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3647 (current-buffer)))))
3649 ;; Set article window start at LINE, where LINE is the number of lines
3650 ;; from the head of the article.
3651 (defun gnus-article-set-window-start (&optional line)
3653 (gnus-get-buffer-window gnus-article-buffer t)
3655 (set-buffer gnus-article-buffer)
3656 (goto-char (point-min))
3659 (gnus-message 6 "Moved to bookmark")
3660 (search-forward "\n\n" nil t)
3664 (defun gnus-article-prepare (article &optional all-headers header)
3665 "Prepare ARTICLE in article mode buffer.
3666 ARTICLE should either be an article number or a Message-ID.
3667 If ARTICLE is an id, HEADER should be the article headers.
3668 If ALL-HEADERS is non-nil, no headers are hidden."
3670 ;; Make sure we start in a summary buffer.
3671 (unless (eq major-mode 'gnus-summary-mode)
3672 (set-buffer gnus-summary-buffer))
3673 (setq gnus-summary-buffer (current-buffer))
3674 (let* ((gnus-article (if header (mail-header-number header) article))
3675 (summary-buffer (current-buffer))
3676 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3677 (group gnus-newsgroup-name)
3680 (gnus-article-setup-buffer)
3681 (set-buffer gnus-article-buffer)
3682 ;; Deactivate active regions.
3683 (when (and (boundp 'transient-mark-mode)
3684 transient-mark-mode)
3685 (setq mark-active nil))
3686 (if (not (setq result (let ((buffer-read-only nil))
3687 (gnus-request-article-this-buffer
3689 ;; There is no such article.
3691 (when (and (numberp article)
3692 (not (memq article gnus-newsgroup-sparse)))
3693 (setq gnus-article-current
3694 (cons gnus-newsgroup-name article))
3695 (set-buffer gnus-summary-buffer)
3696 (setq gnus-current-article article)
3697 (if (and (memq article gnus-newsgroup-undownloaded)
3698 (not (gnus-online (gnus-find-method-for-group
3699 gnus-newsgroup-name))))
3701 (gnus-summary-set-agent-mark article)
3702 (message "Message marked for downloading"))
3703 (gnus-summary-mark-article article gnus-canceled-mark)
3704 (unless (memq article gnus-newsgroup-sparse)
3705 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3706 (if (or (eq result 'pseudo)
3707 (eq result 'nneething))
3710 (set-buffer summary-buffer)
3711 (push article gnus-newsgroup-history)
3712 (setq gnus-last-article gnus-current-article
3713 gnus-current-article 0
3714 gnus-current-headers nil
3715 gnus-article-current nil)
3716 (if (eq result 'nneething)
3717 (gnus-configure-windows 'summary)
3718 (gnus-configure-windows 'article))
3719 (gnus-set-global-variables))
3720 (let ((gnus-article-mime-handle-alist-1
3721 gnus-article-mime-handle-alist))
3722 (gnus-set-mode-line 'article)))
3723 ;; The result from the `request' was an actual article -
3724 ;; or at least some text that is now displayed in the
3726 (when (and (numberp article)
3727 (not (eq article gnus-current-article)))
3728 ;; Seems like a new article has been selected.
3729 ;; `gnus-current-article' must be an article number.
3731 (set-buffer summary-buffer)
3732 (push article gnus-newsgroup-history)
3733 (setq gnus-last-article gnus-current-article
3734 gnus-current-article article
3735 gnus-current-headers
3736 (gnus-summary-article-header gnus-current-article)
3737 gnus-article-current
3738 (cons gnus-newsgroup-name gnus-current-article))
3739 (unless (vectorp gnus-current-headers)
3740 (setq gnus-current-headers nil))
3741 (gnus-summary-goto-subject gnus-current-article)
3742 (when (gnus-summary-show-thread)
3743 ;; If the summary buffer really was folded, the
3744 ;; previous goto may not actually have gone to
3745 ;; the right article, but the thread root instead.
3747 (gnus-summary-goto-subject gnus-current-article))
3748 (gnus-run-hooks 'gnus-mark-article-hook)
3749 (gnus-set-mode-line 'summary)
3750 (when (gnus-visual-p 'article-highlight 'highlight)
3751 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3752 ;; Set the global newsgroup variables here.
3753 (gnus-set-global-variables)
3754 (setq gnus-have-all-headers
3755 (or all-headers gnus-show-all-headers))))
3757 (gnus-configure-windows 'article))
3758 (when (or (numberp article)
3760 (gnus-article-prepare-display)
3762 (goto-char (point-min))
3763 (setq gnus-page-broken
3764 (when gnus-break-pages
3765 (gnus-narrow-to-page)
3767 (let ((gnus-article-mime-handle-alist-1
3768 gnus-article-mime-handle-alist))
3769 (gnus-set-mode-line 'article))
3773 (set-window-point (get-buffer-window (current-buffer)) (point))
3774 (gnus-configure-windows 'article)
3778 (defun gnus-article-prepare-display ()
3779 "Make the current buffer look like a nice article."
3780 ;; Hooks for getting information from the article.
3781 ;; This hook must be called before being narrowed.
3782 (let ((gnus-article-buffer (current-buffer))
3784 (unless (eq major-mode 'gnus-article-mode)
3785 (gnus-article-mode))
3786 (setq buffer-read-only nil
3787 gnus-article-wash-types nil
3788 gnus-article-image-alist nil)
3789 (gnus-run-hooks 'gnus-tmp-internal-hook)
3790 (when gnus-display-mime-function
3791 (funcall gnus-display-mime-function))
3792 (gnus-run-hooks 'gnus-article-prepare-hook)))
3795 ;;; Gnus MIME viewing functions
3798 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3799 "Format of the MIME buttons.
3801 Valid specifiers include:
3803 %T MIME type, along with additional info
3804 %n The `name' parameter
3805 %d The description, if any
3806 %l The length of the encoded part
3807 %p The part identifier number
3808 %e Dots if the part isn't displayed
3810 General format specifiers can also be used. See Info node
3811 `(gnus)Formatting Variables'.")
3813 (defvar gnus-mime-button-line-format-alist
3814 '((?t gnus-tmp-type ?s)
3815 (?T gnus-tmp-type-long ?s)
3816 (?n gnus-tmp-name ?s)
3817 (?d gnus-tmp-description ?s)
3819 (?l gnus-tmp-length ?d)
3820 (?e gnus-tmp-dots ?s)))
3822 (defvar gnus-mime-button-commands
3823 '((gnus-article-press-button "\r" "Toggle Display")
3824 (gnus-mime-view-part "v" "View Interactively...")
3825 (gnus-mime-view-part-as-type "t" "View As Type...")
3826 (gnus-mime-view-part-as-charset "C" "View As charset...")
3827 (gnus-mime-save-part "o" "Save...")
3828 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3829 (gnus-mime-delete-part "d" "Delete part")
3830 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3831 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3832 (gnus-mime-view-part-internally "E" "View Internally")
3833 (gnus-mime-view-part-externally "e" "View Externally")
3834 (gnus-mime-print-part "p" "Print")
3835 (gnus-mime-pipe-part "|" "Pipe To Command...")
3836 (gnus-mime-action-on-part "." "Take action on the part...")))
3838 (defun gnus-article-mime-part-status ()
3839 (if gnus-article-mime-handle-alist-1
3840 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3842 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3845 (defvar gnus-mime-button-map
3846 (let ((map (make-sparse-keymap)))
3847 (unless (>= (string-to-number emacs-version) 21)
3848 ;; XEmacs doesn't care.
3849 (set-keymap-parent map gnus-article-mode-map))
3850 (define-key map gnus-mouse-2 'gnus-article-push-button)
3851 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3852 (dolist (c gnus-mime-button-commands)
3853 (define-key map (cadr c) (car c)))
3857 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3859 ,@(mapcar (lambda (c)
3860 (vector (caddr c) (car c) :enable t))
3861 gnus-mime-button-commands)))
3864 (define-compiler-macro popup-menu (&whole form
3865 menu &optional position prefix)
3866 (if (and (fboundp 'popup-menu)
3867 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3869 ;; Gnus is probably running under Emacs 20.
3870 `(let* ((menu (cdr ,menu))
3871 (response (x-popup-menu
3873 (cons "" (mapcar (lambda (c)
3874 (cons (caddr c) (car c)))
3877 (call-interactively (nth 3 (assq response menu))))))))
3879 (defun gnus-mime-button-menu (event prefix)
3880 "Construct a context-sensitive menu of MIME commands."
3881 (interactive "e\nP")
3882 (save-window-excursion
3883 (let ((pos (event-start event)))
3884 (select-window (posn-window pos))
3885 (goto-char (posn-point pos))
3886 (gnus-article-check-buffer)
3887 (popup-menu gnus-mime-button-menu nil prefix))))
3889 (defun gnus-mime-view-all-parts (&optional handles)
3890 "View all the MIME parts."
3892 (save-current-buffer
3893 (set-buffer gnus-article-buffer)
3894 (let ((handles (or handles gnus-article-mime-handles))
3895 (mail-parse-charset gnus-newsgroup-charset)
3896 (mail-parse-ignored-charsets
3897 (with-current-buffer gnus-summary-buffer
3898 gnus-newsgroup-ignored-charsets)))
3900 (mm-remove-parts handles)
3901 (goto-char (point-min))
3902 (or (search-forward "\n\n") (goto-char (point-max)))
3903 (let (buffer-read-only)
3904 (delete-region (point) (point-max))
3905 (mm-display-parts handles))))))
3907 (defun gnus-mime-save-part-and-strip ()
3908 "Save the MIME part under point then replace it with an external body."
3910 (gnus-article-check-buffer)
3911 (let* ((data (get-text-property (point) 'gnus-data))
3913 (handles gnus-article-mime-handles))
3914 (if (mm-multiple-handles gnus-article-mime-handles)
3915 (error "This function is not implemented"))
3916 (setq file (and data (mm-save-part data)))
3918 (with-current-buffer (mm-handle-buffer data)
3920 (insert "Content-Type: " (mm-handle-media-type data))
3921 (mml-insert-parameter-string (cdr (mm-handle-type data))
3924 (insert "Content-ID: " (message-make-message-id) "\n")
3925 (insert "Content-Transfer-Encoding: binary\n")
3928 (cdr (mm-make-handle nil
3929 `("message/external-body"
3930 (access-type . "LOCAL-FILE")
3932 (set-buffer gnus-summary-buffer)
3933 (gnus-article-edit-article
3936 (let ((mail-parse-charset (or gnus-article-charset
3937 ',gnus-newsgroup-charset))
3938 (mail-parse-ignored-charsets
3939 (or gnus-article-ignored-charsets
3940 ',gnus-newsgroup-ignored-charsets))
3941 (mbl mml-buffer-list))
3942 (setq mml-buffer-list nil)
3943 (insert-buffer gnus-original-article-buffer)
3944 (mime-to-mml ',handles)
3945 (setq gnus-article-mime-handles nil)
3946 (let ((mbl1 mml-buffer-list))
3947 (setq mml-buffer-list mbl)
3948 (set (make-local-variable 'mml-buffer-list) mbl1))
3949 (gnus-make-local-hook 'kill-buffer-hook)
3950 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3951 `(lambda (no-highlight)
3952 (let ((mail-parse-charset (or gnus-article-charset
3953 ',gnus-newsgroup-charset))
3954 (message-options message-options)
3955 (message-options-set-recipient)
3956 (mail-parse-ignored-charsets
3957 (or gnus-article-ignored-charsets
3958 ',gnus-newsgroup-ignored-charsets)))
3960 (mml-destroy-buffers)
3961 (remove-hook 'kill-buffer-hook
3962 'mml-destroy-buffers t)
3963 (kill-local-variable 'mml-buffer-list))
3964 (gnus-summary-edit-article-done
3965 ,(or (mail-header-references gnus-current-headers) "")
3966 ,(gnus-group-read-only-p)
3967 ,gnus-summary-buffer no-highlight))))))
3969 (defun gnus-mime-delete-part ()
3970 "Delete the MIME part under point.
3971 Replace it with some information about the removed part."
3973 (gnus-article-check-buffer)
3974 (unless (and gnus-novice-user
3975 (not (gnus-yes-or-no-p
3976 "Really delete attachment forever? ")))
3977 (let* ((data (get-text-property (point) 'gnus-data))
3978 (handles gnus-article-mime-handles)
3982 (mail-decode-encoded-word-string (or (mm-handle-description data)
3985 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
3987 (type (mm-handle-media-type data)))
3988 (if (mm-multiple-handles gnus-article-mime-handles)
3989 (error "This function is not implemented"))
3990 (with-current-buffer (mm-handle-buffer data)
3991 (let ((bsize (format "%s" (buffer-size))))
3995 "<#part type=text/plain nofile=yes disposition=attachment"
3996 " description=\"Deleted attachment (" bsize " Byte)\">"
3998 "| The following attachment has been deleted:\n"
4000 "| Type: " type "\n"
4001 "| Filename: " filename "\n"
4002 "| Size (encoded): " bsize " Byte\n"
4003 "| Description: " description "\n"
4007 (cdr (mm-make-handle nil `("text/plain"))))))
4008 (set-buffer gnus-summary-buffer)
4009 ;; FIXME: maybe some of the following code (borrowed from
4010 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4011 (gnus-article-edit-article
4014 (let ((mail-parse-charset (or gnus-article-charset
4015 ',gnus-newsgroup-charset))
4016 (mail-parse-ignored-charsets
4017 (or gnus-article-ignored-charsets
4018 ',gnus-newsgroup-ignored-charsets))
4019 (mbl mml-buffer-list))
4020 (setq mml-buffer-list nil)
4021 (insert-buffer gnus-original-article-buffer)
4022 (mime-to-mml ',handles)
4023 (setq gnus-article-mime-handles nil)
4024 (let ((mbl1 mml-buffer-list))
4025 (setq mml-buffer-list mbl)
4026 (set (make-local-variable 'mml-buffer-list) mbl1))
4027 (gnus-make-local-hook 'kill-buffer-hook)
4028 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4029 `(lambda (no-highlight)
4030 (let ((mail-parse-charset (or gnus-article-charset
4031 ',gnus-newsgroup-charset))
4032 (message-options message-options)
4033 (message-options-set-recipient)
4034 (mail-parse-ignored-charsets
4035 (or gnus-article-ignored-charsets
4036 ',gnus-newsgroup-ignored-charsets)))
4038 (mml-destroy-buffers)
4039 (remove-hook 'kill-buffer-hook
4040 'mml-destroy-buffers t)
4041 (kill-local-variable 'mml-buffer-list))
4042 (gnus-summary-edit-article-done
4043 ,(or (mail-header-references gnus-current-headers) "")
4044 ,(gnus-group-read-only-p)
4045 ,gnus-summary-buffer no-highlight)))))
4046 ;; Not in `gnus-mime-save-part-and-strip':
4047 (gnus-article-edit-done)
4048 (gnus-summary-expand-window)
4049 (gnus-summary-show-article))
4051 (defun gnus-mime-save-part ()
4052 "Save the MIME part under point."
4054 (gnus-article-check-buffer)
4055 (let ((data (get-text-property (point) 'gnus-data)))
4057 (mm-save-part data))))
4059 (defun gnus-mime-pipe-part ()
4060 "Pipe the MIME part under point to a process."
4062 (gnus-article-check-buffer)
4063 (let ((data (get-text-property (point) 'gnus-data)))
4065 (mm-pipe-part data))))
4067 (defun gnus-mime-view-part ()
4068 "Interactively choose a viewing method for the MIME part under point."
4070 (gnus-article-check-buffer)
4071 (let ((data (get-text-property (point) 'gnus-data)))
4073 (setq gnus-article-mime-handles
4075 gnus-article-mime-handles (setq data (copy-sequence data))))
4076 (mm-interactively-view-part data))))
4078 (defun gnus-mime-view-part-as-type-internal ()
4079 (gnus-article-check-buffer)
4080 (let* ((name (mail-content-type-get
4081 (mm-handle-type (get-text-property (point) 'gnus-data))
4083 (def-type (and name (mm-default-file-encoding name))))
4084 (and def-type (cons def-type 0))))
4086 (defun gnus-mime-view-part-as-type (&optional mime-type)
4087 "Choose a MIME media type, and view the part as such."
4090 (setq mime-type (completing-read
4091 "View as MIME type: "
4092 (mapcar #'list (mailcap-mime-types))
4094 (gnus-mime-view-part-as-type-internal))))
4095 (gnus-article-check-buffer)
4096 (let ((handle (get-text-property (point) 'gnus-data)))
4099 (mm-make-handle (mm-handle-buffer handle)
4100 (cons mime-type (cdr (mm-handle-type handle)))
4101 (mm-handle-encoding handle)
4102 (mm-handle-undisplayer handle)
4103 (mm-handle-disposition handle)
4104 (mm-handle-description handle)
4106 (mm-handle-id handle)))
4107 (setq gnus-article-mime-handles
4108 (mm-merge-handles gnus-article-mime-handles handle))
4109 (gnus-mm-display-part handle))))
4112 (require 'jka-compr))
4114 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4115 ;; emacs can do that itself.
4117 (defun gnus-mime-jka-compr-maybe-uncompress ()
4118 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4119 The uncompress method used is derived from `buffer-file-name'."
4120 (when (and (fboundp 'jka-compr-installed-p)
4121 (jka-compr-installed-p))
4122 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4124 (let ((basename (file-name-nondirectory buffer-file-name))
4125 (args (jka-compr-info-uncompress-args info))
4126 (prog (jka-compr-info-uncompress-program info))
4127 (message (jka-compr-info-uncompress-message info))
4128 (err-file (jka-compr-make-temp-name)))
4130 (message "%s %s..." message basename))
4132 (unless (memq (apply 'call-process-region
4133 (point-min) (point-max)
4135 t (list t err-file) nil
4137 jka-compr-acceptable-retval-list)
4138 (jka-compr-error prog args basename message err-file))
4139 (jka-compr-delete-temp-file err-file)))))))
4141 (defun gnus-mime-copy-part (&optional handle)
4142 "Put the MIME part under point into a new buffer.
4143 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4146 (gnus-article-check-buffer)
4147 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4148 (contents (and handle (mm-get-part handle)))
4150 (file-name-nondirectory
4152 (mail-content-type-get (mm-handle-type handle) 'name)
4153 (mail-content-type-get (mm-handle-disposition handle)
4156 (buffer (and base (generate-new-buffer base))))
4158 (switch-to-buffer buffer)
4160 ;; We do it this way to make `normal-mode' set the appropriate mode.
4163 (setq buffer-file-name (expand-file-name base))
4164 (gnus-mime-jka-compr-maybe-uncompress)
4166 (setq buffer-file-name nil))
4167 (goto-char (point-min)))))
4169 (defun gnus-mime-print-part (&optional handle filename)
4170 "Print the MIME part under point."
4171 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4172 (gnus-article-check-buffer)
4173 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4174 (contents (and handle (mm-get-part handle)))
4175 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4176 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4181 (mm-save-part-to-file handle file)
4182 (call-process shell-file-name nil
4183 (generate-new-buffer " *mm*")
4185 shell-command-switch
4187 printer file (mm-handle-type handle))))
4191 (gnus-print-buffer))
4192 (ps-despool filename)))))
4194 (defun gnus-mime-inline-part (&optional handle arg)
4195 "Insert the MIME part under point into the current buffer."
4196 (interactive (list nil current-prefix-arg))
4197 (gnus-article-check-buffer)
4198 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4203 (if (and (not arg) (mm-handle-undisplayer handle))
4204 (mm-remove-part handle)
4205 (setq contents (mm-get-part handle))
4208 (setq charset (or (mail-content-type-get
4209 (mm-handle-type handle) 'charset)
4210 gnus-newsgroup-charset)))
4212 (if (mm-handle-undisplayer handle)
4213 (mm-remove-part handle))
4216 gnus-summary-show-article-charset-alist))
4217 (mm-read-coding-system "Charset: ")))))
4219 (mm-insert-inline handle
4221 (setq charset (mm-charset-to-coding-system
4223 (not (eq charset 'ascii)))
4224 (mm-decode-coding-string contents charset)
4228 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4229 "Insert the MIME part under point into the current buffer using the
4231 (interactive (list nil current-prefix-arg))
4232 (gnus-article-check-buffer)
4233 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4238 (if (mm-handle-undisplayer handle)
4239 (mm-remove-part handle))
4240 (let ((gnus-newsgroup-charset
4242 gnus-summary-show-article-charset-alist))
4243 (mm-read-coding-system "Charset: ")))
4244 (gnus-newsgroup-ignored-charsets 'gnus-all))
4245 (gnus-article-press-button)))))
4247 (defun gnus-mime-view-part-externally (&optional handle)
4248 "View the MIME part under point with an external viewer."
4250 (gnus-article-check-buffer)
4251 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4252 (mm-user-display-methods nil)
4253 (mm-inlined-types nil)
4254 (mail-parse-charset gnus-newsgroup-charset)
4255 (mail-parse-ignored-charsets
4256 (save-excursion (set-buffer gnus-summary-buffer)
4257 gnus-newsgroup-ignored-charsets)))
4259 (if (mm-handle-undisplayer handle)
4260 (mm-remove-part handle)
4261 (mm-display-part handle)))))
4263 (defun gnus-mime-view-part-internally (&optional handle)
4264 "View the MIME part under point with an internal viewer.
4265 If no internal viewer is available, use an external viewer."
4267 (gnus-article-check-buffer)
4268 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4269 (mm-inlined-types '(".*"))
4270 (mm-inline-large-images t)
4271 (mail-parse-charset gnus-newsgroup-charset)
4272 (mail-parse-ignored-charsets
4273 (save-excursion (set-buffer gnus-summary-buffer)
4274 gnus-newsgroup-ignored-charsets))
4277 (if (mm-handle-undisplayer handle)
4278 (mm-remove-part handle)
4279 (mm-display-part handle)))))
4281 (defun gnus-mime-action-on-part (&optional action)
4282 "Do something with the MIME attachment at \(point\)."
4284 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4285 (gnus-article-check-buffer)
4286 (let ((action-pair (assoc action gnus-mime-action-alist)))
4288 (funcall (cdr action-pair)))))
4290 (defun gnus-article-part-wrapper (n function)
4291 (save-current-buffer
4292 (set-buffer gnus-article-buffer)
4293 (when (> n (length gnus-article-mime-handle-alist))
4294 (error "No such part"))
4295 (gnus-article-goto-part n)
4296 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4297 (funcall function handle))))
4299 (defun gnus-article-pipe-part (n)
4300 "Pipe MIME part N, which is the numerical prefix."
4302 (gnus-article-part-wrapper n 'mm-pipe-part))
4304 (defun gnus-article-save-part (n)
4305 "Save MIME part N, which is the numerical prefix."
4307 (gnus-article-part-wrapper n 'mm-save-part))
4309 (defun gnus-article-interactively-view-part (n)
4310 "View MIME part N interactively, which is the numerical prefix."
4312 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4314 (defun gnus-article-copy-part (n)
4315 "Copy MIME part N, which is the numerical prefix."
4317 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4319 (defun gnus-article-view-part-as-charset (n)
4320 "Copy MIME part N, which is the numerical prefix."
4322 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4324 (defun gnus-article-view-part-externally (n)
4325 "View MIME part N externally, which is the numerical prefix."
4327 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4329 (defun gnus-article-inline-part (n)
4330 "Inline MIME part N, which is the numerical prefix."
4332 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4334 (defun gnus-article-mime-match-handle-first (condition)
4336 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4337 (while (setq ihandle (pop alist))
4339 ((functionp condition)
4340 (funcall condition (cdr ihandle)))
4341 ((eq condition 'undisplayed)
4342 (not (or (mm-handle-undisplayer (cdr ihandle))
4343 (equal (mm-handle-media-type (cdr ihandle))
4344 "multipart/alternative"))))
4345 ((eq condition 'undisplayed-alternative)
4346 (not (mm-handle-undisplayer (cdr ihandle))))
4348 (gnus-article-goto-part (car ihandle))
4349 (or (not n) (< (car ihandle) n)))
4350 (setq n (car ihandle))))
4354 (defun gnus-article-view-part (&optional n)
4355 "View MIME part N, which is the numerical prefix."
4357 (save-current-buffer
4358 (set-buffer gnus-article-buffer)
4359 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4360 gnus-article-mime-match-handle-function)))
4361 (when (> n (length gnus-article-mime-handle-alist))
4362 (error "No such part"))
4363 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4364 (when (gnus-article-goto-part n)
4365 (if (equal (car handle) "multipart/alternative")
4366 (gnus-article-press-button)
4367 (when (eq (gnus-mm-display-part handle) 'internal)
4368 (gnus-set-window-start)))))))
4370 (defsubst gnus-article-mime-total-parts ()
4371 (if (bufferp (car gnus-article-mime-handles))
4373 (1- (length gnus-article-mime-handles))))
4375 (defun gnus-mm-display-part (handle)
4376 "Display HANDLE and fix MIME button."
4377 (let ((id (get-text-property (point) 'gnus-part))
4382 (let ((window (selected-window))
4383 (mail-parse-charset gnus-newsgroup-charset)
4384 (mail-parse-ignored-charsets
4385 (if (gnus-buffer-live-p gnus-summary-buffer)
4387 (set-buffer gnus-summary-buffer)
4388 gnus-newsgroup-ignored-charsets)
4392 (let ((win (gnus-get-buffer-window (current-buffer) t))
4395 (select-window win))
4398 (if (mm-handle-displayed-p handle)
4399 ;; This will remove the part.
4400 (mm-display-part handle)
4402 (narrow-to-region (point)
4403 (if (eobp) (point) (1+ (point))))
4404 (mm-display-part handle)
4405 ;; We narrow to the part itself and
4406 ;; then call the treatment functions.
4407 (goto-char (point-min))
4409 (narrow-to-region (point) (point-max))
4412 (gnus-article-mime-total-parts)
4413 (mm-handle-media-type handle)))))
4414 (if (window-live-p window)
4415 (select-window window)))))
4418 (gnus-insert-mime-button
4419 handle id (list (mm-handle-displayed-p handle)))
4420 (goto-char point))))
4422 (defun gnus-article-goto-part (n)
4423 "Go to MIME part N."
4424 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4426 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4427 (let ((gnus-tmp-name
4428 (or (mail-content-type-get (mm-handle-type handle) 'name)
4429 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4430 (mail-content-type-get (mm-handle-type handle) 'url)
4432 (gnus-tmp-type (mm-handle-media-type handle))
4433 (gnus-tmp-description
4434 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4437 (if (if displayed (car displayed)
4438 (mm-handle-displayed-p handle))
4440 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4442 gnus-tmp-type-long b e)
4443 (when (string-match ".*/" gnus-tmp-name)
4444 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4445 (setq gnus-tmp-type-long (concat gnus-tmp-type
4446 (and (not (equal gnus-tmp-name ""))
4447 (concat "; " gnus-tmp-name))))
4448 (unless (equal gnus-tmp-description "")
4449 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4454 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4455 `(,@(gnus-local-map-property gnus-mime-button-map)
4456 gnus-callback gnus-mm-display-part
4457 gnus-part ,gnus-tmp-id
4458 article-type annotation
4461 ;; Exclude a newline.
4464 (widget-convert-button
4467 :action 'gnus-widget-press-button
4468 :button-keymap gnus-mime-button-map
4470 (lambda (widget/window &optional overlay pos)
4471 ;; Needed to properly clear the message due to a bug in
4472 ;; wid-edit (XEmacs only).
4473 (if (boundp 'help-echo-owns-message)
4474 (setq help-echo-owns-message t))
4476 "%S: %s the MIME part; %S: more options"
4477 (aref gnus-mouse-2 0)
4478 ;; XEmacs will get a single widget arg; Emacs 21 will get
4479 ;; window, overlay, position.
4480 (if (mm-handle-displayed-p
4482 (with-current-buffer (gnus-overlay-buffer overlay)
4483 (widget-get (widget-at (gnus-overlay-start overlay))
4485 (widget-get widget/window :mime-handle)))
4487 (aref gnus-down-mouse-3 0))))))
4489 (defun gnus-widget-press-button (elems el)
4490 (goto-char (widget-get elems :from))
4491 (gnus-article-press-button))
4493 (defvar gnus-displaying-mime nil)
4495 (defun gnus-display-mime (&optional ihandles)
4496 "Display the MIME parts."
4498 (save-selected-window
4499 (let ((window (get-buffer-window gnus-article-buffer))
4502 (select-window window)
4503 ;; We have to do this since selecting the window
4504 ;; may change the point. So we set the window point.
4505 (set-window-point window point)))
4506 (let* ((handles (or ihandles
4507 (mm-dissect-buffer nil gnus-article-loose-mime)
4508 (and gnus-article-emulate-mime
4510 buffer-read-only handle name type b e display)
4511 (when (and (not ihandles)
4512 (not gnus-displaying-mime))
4513 ;; Top-level call; we clean up.
4514 (when gnus-article-mime-handles
4515 (mm-destroy-parts gnus-article-mime-handles)
4516 (setq gnus-article-mime-handle-alist nil));; A trick.
4517 (setq gnus-article-mime-handles handles)
4518 ;; We allow users to glean info from the handles.
4519 (when gnus-article-mime-part-function
4520 (gnus-mime-part-function handles)))
4522 (or (not (stringp (car handles)))
4525 (when (and (not ihandles)
4526 (not gnus-displaying-mime))
4527 ;; Clean up for mime parts.
4529 (delete-region (point) (point-max)))
4530 (let ((gnus-displaying-mime t))
4531 (gnus-mime-display-part handles)))
4534 (narrow-to-region (point) (point-max))
4535 (gnus-treat-article nil 1 1)
4538 ;; Highlight the headers.
4542 (narrow-to-region (point-min) (point))
4543 (gnus-treat-article 'head))))))))
4545 (defcustom gnus-mime-display-multipart-as-mixed nil
4546 "Display \"multipart\" parts as \"multipart/mixed\".
4548 If t, it overrides nil values of
4549 `gnus-mime-display-multipart-alternative-as-mixed' and
4550 `gnus-mime-display-multipart-related-as-mixed'."
4551 :group 'gnus-article-mime
4554 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4555 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4556 :group 'gnus-article-mime
4559 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4560 "Display \"multipart/related\" parts as \"multipart/mixed\".
4562 If displaying \"text/html\" is discouraged \(see
4563 `mm-discouraged-alternatives'\) images or other material inside a
4564 \"multipart/related\" part might be overlooked when this variable is nil."
4565 :group 'gnus-article-mime
4568 (defun gnus-mime-display-part (handle)
4571 ((not (stringp (car handle)))
4572 (gnus-mime-display-single handle))
4573 ;; User-defined multipart
4574 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4575 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4577 ;; multipart/alternative
4578 ((and (equal (car handle) "multipart/alternative")
4579 (not (or gnus-mime-display-multipart-as-mixed
4580 gnus-mime-display-multipart-alternative-as-mixed)))
4581 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4582 (push (cons id handle) gnus-article-mime-handle-alist)
4583 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4584 ;; multipart/related
4585 ((and (equal (car handle) "multipart/related")
4586 (not (or gnus-mime-display-multipart-as-mixed
4587 gnus-mime-display-multipart-related-as-mixed)))
4588 ;;;!!!We should find the start part, but we just default
4589 ;;;!!!to the first part.
4590 ;;(gnus-mime-display-part (cadr handle))
4591 ;;;!!! Most multipart/related is an HTML message plus images.
4592 ;;;!!! Unfortunately we are unable to let W3 display those
4593 ;;;!!! included images, so we just display it as a mixed multipart.
4594 ;;(gnus-mime-display-mixed (cdr handle))
4595 ;;;!!! No, w3 can display everything just fine.
4596 (gnus-mime-display-part (cadr handle)))
4597 ((equal (car handle) "multipart/signed")
4598 (gnus-add-wash-type 'signed)
4599 (gnus-mime-display-security handle))
4600 ((equal (car handle) "multipart/encrypted")
4601 (gnus-add-wash-type 'encrypted)
4602 (gnus-mime-display-security handle))
4603 ;; Other multiparts are handled like multipart/mixed.
4605 (gnus-mime-display-mixed (cdr handle)))))
4607 (defun gnus-mime-part-function (handles)
4608 (if (stringp (car handles))
4609 (mapcar 'gnus-mime-part-function (cdr handles))
4610 (funcall gnus-article-mime-part-function handles)))
4612 (defun gnus-mime-display-mixed (handles)
4613 (mapcar 'gnus-mime-display-part handles))
4615 (defun gnus-mime-display-single (handle)
4616 (let ((type (mm-handle-media-type handle))
4617 (ignored gnus-ignored-mime-types)
4624 (when (string-match (pop ignored) type)
4625 (throw 'ignored nil)))
4626 (if (and (setq not-attachment
4627 (and (not (mm-inline-override-p handle))
4628 (or (not (mm-handle-disposition handle))
4629 (equal (car (mm-handle-disposition handle))
4631 (mm-attachment-override-p handle))))
4632 (mm-automatic-display-p handle)
4634 (mm-inlinable-p handle)
4635 (mm-inlined-p handle))
4636 (mm-automatic-external-display-p type)))
4638 (when (equal (mm-handle-media-supertype handle) "text")
4640 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4642 (push (cons id handle) gnus-article-mime-handle-alist)
4643 (when (or (not display)
4644 (not (gnus-unbuttonized-mime-type-p type)))
4645 ;(gnus-article-insert-newline)
4646 (gnus-insert-mime-button
4647 handle id (list (or display (and not-attachment text))))
4648 (gnus-article-insert-newline)
4649 ;(gnus-article-insert-newline)
4650 ;; Remember modify the number of forward lines.
4658 (let ((mail-parse-charset gnus-newsgroup-charset)
4659 (mail-parse-ignored-charsets
4660 (save-excursion (condition-case ()
4661 (set-buffer gnus-summary-buffer)
4663 gnus-newsgroup-ignored-charsets)))
4664 (mm-display-part handle t))
4665 (goto-char (point-max)))
4666 ((and text not-attachment)
4670 (gnus-article-insert-newline)
4671 (mm-insert-inline handle (mm-get-part handle))
4672 (goto-char (point-max))))
4676 (narrow-to-region beg (point))
4679 (gnus-article-mime-total-parts)
4680 (mm-handle-media-type handle)))))))))
4682 (defun gnus-unbuttonized-mime-type-p (type)
4683 "Say whether TYPE is to be unbuttonized."
4684 (unless gnus-inhibit-mime-unbuttonizing
4686 (let ((types gnus-unbuttonized-mime-types))
4688 (when (string-match (pop types) type)
4689 (throw 'found t)))))
4691 (let ((types gnus-buttonized-mime-types))
4693 (when (string-match (pop types) type)
4694 (throw 'found t)))))))))
4696 (defun gnus-article-insert-newline ()
4697 "Insert a newline, but mark it as undeletable."
4698 (gnus-put-text-property
4699 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4701 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4702 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4705 handle buffer-read-only from props begend not-pref)
4706 (save-window-excursion
4709 (narrow-to-region (car ibegend)
4712 (goto-char (car ibegend))
4715 (delete-region (point-min) (point-max))
4716 (mm-remove-parts handles))
4717 (setq begend (list (point-marker)))
4719 (unless (setq not-pref (cadr (member preferred ihandles)))
4720 (setq not-pref (car ihandles)))
4723 (not (gnus-unbuttonized-mime-type-p
4724 "multipart/alternative")))
4725 (gnus-add-text-properties
4728 (insert (format "%d. " id))
4732 (unless ,(not ibegend)
4733 (setq gnus-article-mime-handle-alist
4734 ',gnus-article-mime-handle-alist))
4735 (gnus-mime-display-alternative
4736 ',ihandles ',not-pref ',begend ,id))
4737 ,@(gnus-local-map-property gnus-mime-button-map)
4738 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4739 face ,gnus-article-button-face
4742 (widget-convert-button 'link from (point)
4743 :action 'gnus-widget-press-button
4744 :button-keymap gnus-widget-button-keymap)
4746 (while (setq handle (pop handles))
4747 (gnus-add-text-properties
4750 (insert (format "(%c) %-18s"
4751 (if (equal handle preferred) ?* ? )
4752 (mm-handle-media-type handle)))
4756 (unless ,(not ibegend)
4757 (setq gnus-article-mime-handle-alist
4758 ',gnus-article-mime-handle-alist))
4759 (gnus-mime-display-alternative
4760 ',ihandles ',handle ',begend ,id))
4761 ,@(gnus-local-map-property gnus-mime-button-map)
4762 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4763 face ,gnus-article-button-face
4766 (widget-convert-button 'link from (point)
4767 :action 'gnus-widget-press-button
4768 :button-keymap gnus-widget-button-keymap)
4772 (if (stringp (car preferred))
4773 (gnus-display-mime preferred)
4774 (let ((mail-parse-charset gnus-newsgroup-charset)
4775 (mail-parse-ignored-charsets
4776 (save-excursion (set-buffer gnus-summary-buffer)
4777 gnus-newsgroup-ignored-charsets)))
4778 (mm-display-part preferred)
4782 (narrow-to-region (car begend) (point-max))
4784 nil (length gnus-article-mime-handle-alist)
4785 (gnus-article-mime-total-parts)
4786 (mm-handle-media-type handle))))))
4787 (goto-char (point-max))
4788 (setcdr begend (point-marker)))))
4790 (goto-char point))))
4792 (defconst gnus-article-wash-status-strings
4793 (let ((alist '((cite "c" "Possible hidden citation text"
4794 " " "All citation text visible")
4795 (headers "h" "Hidden headers"
4796 " " "All headers visible.")
4797 (pgp "p" "Encrypted or signed message status hidden"
4798 " " "No hidden encryption nor digital signature status")
4799 (signature "s" "Signature has been hidden"
4800 " " "Signature is visible")
4801 (overstrike "o" "Overstrike (^H) characters applied"
4802 " " "No overstrike characters applied")
4803 (emphasis "e" "/*_Emphasis_*/ characters applied"
4804 " " "No /*_emphasis_*/ characters applied")))
4806 (dolist (entry alist result)
4807 (let ((key (nth 0 entry))
4808 (on (copy-sequence (nth 1 entry)))
4809 (on-help (nth 2 entry))
4810 (off (copy-sequence (nth 3 entry)))
4811 (off-help (nth 4 entry)))
4812 (put-text-property 0 1 'help-echo on-help on)
4813 (put-text-property 0 1 'help-echo off-help off)
4814 (push (list key on off) result))))
4815 "Alist of strings describing wash status in the mode line.
4816 Each entry has the form (KEY ON OF), where the KEY is a symbol
4817 representing the particular washing function, ON is the string to use
4818 in the article mode line when the washing function is active, and OFF
4819 is the string to use when it is inactive.")
4821 (defun gnus-article-wash-status-entry (key value)
4822 (let ((entry (assoc key gnus-article-wash-status-strings)))
4823 (if value (nth 1 entry) (nth 2 entry))))
4825 (defun gnus-article-wash-status ()
4826 "Return a string which display status of article washing."
4828 (set-buffer gnus-article-buffer)
4829 (let ((cite (memq 'cite gnus-article-wash-types))
4830 (headers (memq 'headers gnus-article-wash-types))
4831 (boring (memq 'boring-headers gnus-article-wash-types))
4832 (pgp (memq 'pgp gnus-article-wash-types))
4833 (pem (memq 'pem gnus-article-wash-types))
4834 (signed (memq 'signed gnus-article-wash-types))
4835 (encrypted (memq 'encrypted gnus-article-wash-types))
4836 (signature (memq 'signature gnus-article-wash-types))
4837 (overstrike (memq 'overstrike gnus-article-wash-types))
4838 (emphasis (memq 'emphasis gnus-article-wash-types)))
4840 (gnus-article-wash-status-entry 'cite cite)
4841 (gnus-article-wash-status-entry 'headers (or headers boring))
4842 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4843 (gnus-article-wash-status-entry 'signature signature)
4844 (gnus-article-wash-status-entry 'overstrike overstrike)
4845 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4847 (defun gnus-add-wash-type (type)
4848 "Add a washing of TYPE to the current status."
4849 (add-to-list 'gnus-article-wash-types type))
4851 (defun gnus-delete-wash-type (type)
4852 "Add a washing of TYPE to the current status."
4853 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4855 (defun gnus-add-image (category image)
4856 "Add IMAGE of CATEGORY to the list of displayed images."
4857 (let ((entry (assq category gnus-article-image-alist)))
4859 (setq entry (list category))
4860 (push entry gnus-article-image-alist))
4861 (nconc entry (list image))))
4863 (defun gnus-delete-images (category)
4864 "Delete all images in CATEGORY."
4865 (let ((entry (assq category gnus-article-image-alist)))
4866 (dolist (image (cdr entry))
4867 (gnus-remove-image image category))
4868 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4869 (gnus-delete-wash-type category)))
4871 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4873 (defun gnus-article-maybe-hide-headers ()
4874 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4875 Provided for backwards compatibility."
4876 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4877 (not (save-excursion (set-buffer gnus-summary-buffer)
4878 gnus-have-all-headers)))
4879 (not gnus-inhibit-hiding))
4880 (gnus-article-hide-headers)))
4884 (defun gnus-output-to-file (file-name)
4885 "Append the current article to a file named FILE-NAME."
4886 (let ((artbuf (current-buffer)))
4888 (insert-buffer-substring artbuf)
4889 ;; Append newline at end of the buffer as separator, and then
4891 (goto-char (point-max))
4893 (let ((file-name-coding-system nnmail-pathname-coding-system))
4894 (mm-append-to-file (point-min) (point-max) file-name))
4897 (defun gnus-narrow-to-page (&optional arg)
4898 "Narrow the article buffer to a page.
4899 If given a numerical ARG, move forward ARG pages."
4901 (setq arg (if arg (prefix-numeric-value arg) 0))
4903 (set-buffer gnus-article-buffer)
4904 (goto-char (point-min))
4906 ;; Remove any old next/prev buttons.
4907 (when (gnus-visual-p 'page-marker)
4908 (let ((buffer-read-only nil))
4909 (gnus-remove-text-with-property 'gnus-prev)
4910 (gnus-remove-text-with-property 'gnus-next)))
4913 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4915 (re-search-forward page-delimiter nil 'move arg)))
4916 (goto-char (match-end 0)))
4919 (if (re-search-forward page-delimiter nil 'move)
4922 (when (and (gnus-visual-p 'page-marker)
4923 (not (= (point-min) 1)))
4925 (goto-char (point-min))
4926 (gnus-insert-prev-page-button)))
4927 (when (and (gnus-visual-p 'page-marker)
4928 (< (+ (point-max) 2) (buffer-size)))
4930 (goto-char (point-max))
4931 (gnus-insert-next-page-button)))))
4933 ;; Article mode commands
4935 (defun gnus-article-goto-next-page ()
4936 "Show the next page of the article."
4938 (when (gnus-article-next-page)
4939 (goto-char (point-min))
4940 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4943 (defun gnus-article-goto-prev-page ()
4944 "Show the next page of the article."
4947 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4948 (gnus-article-prev-page nil)))
4950 ;; This is cleaner but currently breaks `gnus-pick-mode':
4952 ;; (defun gnus-article-goto-next-page ()
4953 ;; "Show the next page of the article."
4955 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4956 ;; (gnus-summary-next-page)))
4958 ;; (defun gnus-article-goto-prev-page ()
4959 ;; "Show the next page of the article."
4961 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4962 ;; (gnus-summary-prev-page)))
4964 (defun gnus-article-next-page (&optional lines)
4965 "Show the next page of the current article.
4966 If end of article, return non-nil. Otherwise return nil.
4967 Argument LINES specifies lines to be scrolled up."
4969 (move-to-window-line -1)
4972 (and (pos-visible-in-window-p) ;Not continuation line.
4973 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4974 ;; Nothing in this page.
4975 (if (or (not gnus-page-broken)
4978 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4980 (when gnus-article-over-scroll
4981 (gnus-article-next-page-1 lines))
4983 (gnus-narrow-to-page 1) ;Go to next page.
4985 ;; More in this page.
4986 (gnus-article-next-page-1 lines)
4989 (defun gnus-article-next-page-1 (lines)
4990 (let ((scroll-in-place nil))
4994 ;; Long lines may cause an end-of-buffer error.
4995 (goto-char (point-max)))))
4996 (move-to-window-line 0))
4998 (defun gnus-article-prev-page (&optional lines)
4999 "Show previous page of current article.
5000 Argument LINES specifies lines to be scrolled down."
5002 (move-to-window-line 0)
5003 (if (and gnus-page-broken
5005 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5007 (gnus-narrow-to-page -1) ;Go to previous page.
5008 (goto-char (point-max))
5010 (let ((scroll-in-place nil))
5014 (beginning-of-buffer
5015 (goto-char (point-min))))
5016 (move-to-window-line 0)))))
5018 (defun gnus-article-only-boring-p ()
5019 "Decide whether there is only boring text remaining in the article.
5020 Something \"interesting\" is a word of at least two letters that does
5021 not have a face in `gnus-article-boring-faces'."
5022 (when (and gnus-article-skip-boring
5023 (boundp 'gnus-article-boring-faces)
5024 (symbol-value 'gnus-article-boring-faces))
5027 (while (re-search-forward "\\b\\w\\w" nil t)
5029 (when (not (gnus-intersection
5030 (gnus-faces-at (point))
5031 (symbol-value 'gnus-article-boring-faces)))
5032 (throw 'only-boring nil)))
5033 (throw 'only-boring t)))))
5035 (defun gnus-article-refer-article ()
5036 "Read article specified by message-id around point."
5039 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5040 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5041 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5042 (let ((msg-id (concat "<" (match-string 0) ">")))
5043 (set-buffer gnus-summary-buffer)
5044 (gnus-summary-refer-article msg-id))
5045 (error "No references around point"))))
5047 (defun gnus-article-show-summary ()
5048 "Reconfigure windows to show summary buffer."
5050 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5051 (error "There is no summary buffer for this article buffer")
5052 (gnus-article-set-globals)
5053 (gnus-configure-windows 'article)
5054 (gnus-summary-goto-subject gnus-current-article)
5055 (gnus-summary-position-point)))
5057 (defun gnus-article-describe-briefly ()
5058 "Describe article mode commands briefly."
5060 (gnus-message 6 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
5062 (defun gnus-article-summary-command ()
5063 "Execute the last keystroke in the summary buffer."
5065 (let ((obuf (current-buffer))
5066 (owin (current-window-configuration))
5068 (switch-to-buffer gnus-article-current-summary 'norecord)
5069 (setq func (lookup-key (current-local-map) (this-command-keys)))
5070 (call-interactively func)
5072 (set-window-configuration owin)
5073 (set-window-point (get-buffer-window (current-buffer)) (point))))
5075 (defun gnus-article-summary-command-nosave ()
5076 "Execute the last keystroke in the summary buffer."
5079 (pop-to-buffer gnus-article-current-summary 'norecord)
5080 (setq func (lookup-key (current-local-map) (this-command-keys)))
5081 (call-interactively func)))
5083 (defun gnus-article-check-buffer ()
5084 "Beep if not in an article buffer."
5085 (unless (equal major-mode 'gnus-article-mode)
5086 (error "Command invoked outside of a Gnus article buffer")))
5088 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5089 "Read a summary buffer key sequence and execute it from the article buffer."
5091 (gnus-article-check-buffer)
5093 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5094 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5095 "=" "^" "\M-^" "|"))
5101 '("n" "Gn" "p" "Gp"))
5104 (set-buffer gnus-article-current-summary)
5105 (let (gnus-pick-mode)
5106 (push (or key last-command-event) unread-command-events)
5107 (setq keys (if (featurep 'xemacs)
5108 (events-to-keys (read-key-sequence nil))
5109 (read-key-sequence nil)))))
5113 (if (or (member keys nosaves)
5114 (member keys nosave-but-article)
5115 (member keys nosave-in-article))
5117 (save-window-excursion
5118 (pop-to-buffer gnus-article-current-summary 'norecord)
5119 ;; We disable the pick minor mode commands.
5120 (let (gnus-pick-mode)
5121 (setq func (lookup-key (current-local-map) keys))))
5125 (unless (member keys nosave-in-article)
5126 (set-buffer gnus-article-current-summary))
5127 (call-interactively func)
5128 (setq new-sum-point (point)))
5129 (when (member keys nosave-but-article)
5130 (pop-to-buffer gnus-article-buffer 'norecord)))
5131 ;; These commands should restore window configuration.
5132 (let ((obuf (current-buffer))
5133 (owin (current-window-configuration))
5135 (summary gnus-article-current-summary)
5136 func in-buffer selected)
5137 (if not-restore-window
5138 (pop-to-buffer summary 'norecord)
5139 (switch-to-buffer summary 'norecord))
5140 (setq in-buffer (current-buffer))
5141 ;; We disable the pick minor mode commands.
5142 (if (and (setq func (let (gnus-pick-mode)
5143 (lookup-key (current-local-map) keys)))
5146 (call-interactively func)
5147 (setq new-sum-point (point))
5148 (when (eq in-buffer (current-buffer))
5149 (setq selected (gnus-summary-select-article))
5151 (unless not-restore-window
5152 (set-window-configuration owin))
5153 (when (eq selected 'old)
5155 (set-window-start (get-buffer-window (current-buffer))
5157 (set-window-point (get-buffer-window (current-buffer))
5159 (let ((win (get-buffer-window gnus-article-current-summary)))
5161 (set-window-point win new-sum-point)))) )
5162 (switch-to-buffer gnus-article-buffer)
5165 (defun gnus-article-describe-key (key)
5166 "Display documentation of the function invoked by KEY. KEY is a string."
5167 (interactive "kDescribe key: ")
5168 (gnus-article-check-buffer)
5169 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5171 (set-buffer gnus-article-current-summary)
5172 (let (gnus-pick-mode)
5173 (if (featurep 'xemacs)
5175 (push (elt key 0) unread-command-events)
5176 (setq key (events-to-keys
5177 (read-key-sequence "Describe key: "))))
5178 (setq unread-command-events
5180 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5181 (string-to-list key)))
5182 (setq key (read-key-sequence "Describe key: "))))
5184 (describe-key key)))
5186 (defun gnus-article-describe-key-briefly (key &optional insert)
5187 "Display documentation of the function invoked by KEY. KEY is a string."
5188 (interactive "kDescribe key: \nP")
5189 (gnus-article-check-buffer)
5190 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5192 (set-buffer gnus-article-current-summary)
5193 (let (gnus-pick-mode)
5194 (if (featurep 'xemacs)
5196 (push (elt key 0) unread-command-events)
5197 (setq key (events-to-keys
5198 (read-key-sequence "Describe key: "))))
5199 (setq unread-command-events
5201 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5202 (string-to-list key)))
5203 (setq key (read-key-sequence "Describe key: "))))
5204 (describe-key-briefly key insert))
5205 (describe-key-briefly key insert)))
5207 (defun gnus-article-reply-with-original (&optional wide)
5208 "Start composing a reply mail to the current message.
5209 The text in the region will be yanked. If the region isn't active,
5210 the entire article will be yanked."
5212 (let ((article (cdr gnus-article-current))
5214 (if (not (gnus-mark-active-p))
5215 (with-current-buffer gnus-summary-buffer
5216 (gnus-summary-reply (list (list article)) wide))
5217 (setq contents (buffer-substring (point) (mark t)))
5218 ;; Deactivate active regions.
5219 (when (and (boundp 'transient-mark-mode)
5220 transient-mark-mode)
5221 (setq mark-active nil))
5222 (with-current-buffer gnus-summary-buffer
5224 (list (list article contents)) wide)))))
5226 (defun gnus-article-followup-with-original ()
5227 "Compose a followup to the current article.
5228 The text in the region will be yanked. If the region isn't active,
5229 the entire article will be yanked."
5231 (let ((article (cdr gnus-article-current))
5233 (if (not (gnus-mark-active-p))
5234 (with-current-buffer gnus-summary-buffer
5235 (gnus-summary-followup (list (list article))))
5236 (setq contents (buffer-substring (point) (mark t)))
5237 ;; Deactivate active regions.
5238 (when (and (boundp 'transient-mark-mode)
5239 transient-mark-mode)
5240 (setq mark-active nil))
5241 (with-current-buffer gnus-summary-buffer
5242 (gnus-summary-followup
5243 (list (list article contents)))))))
5245 (defun gnus-article-hide (&optional arg force)
5246 "Hide all the gruft in the current article.
5247 This means that signatures, cited text and (some) headers will be
5249 If given a prefix, show the hidden text instead."
5250 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5251 (gnus-article-hide-headers arg)
5252 (gnus-article-hide-list-identifiers arg)
5253 (gnus-article-hide-citation-maybe arg force)
5254 (gnus-article-hide-signature arg))
5256 (defun gnus-article-maybe-highlight ()
5257 "Do some article highlighting if article highlighting is requested."
5258 (when (gnus-visual-p 'article-highlight 'highlight)
5259 (gnus-article-highlight-some)))
5261 (defun gnus-check-group-server ()
5262 ;; Make sure the connection to the server is alive.
5263 (unless (gnus-server-opened
5264 (gnus-find-method-for-group gnus-newsgroup-name))
5265 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5266 (gnus-request-group gnus-newsgroup-name t)))
5269 (autoload 'nneething-get-file-name "nneething"))
5271 (defun gnus-request-article-this-buffer (article group)
5272 "Get an article and insert it into this buffer."
5273 (let (do-update-line sparse-header)
5277 (gnus-kill-all-overlays)
5278 (setq group (or group gnus-newsgroup-name))
5280 ;; Using `gnus-request-article' directly will insert the article into
5281 ;; `nntp-server-buffer' - so we'll save some time by not having to
5282 ;; copy it from the server buffer into the article buffer.
5284 ;; We only request an article by message-id when we do not have the
5285 ;; headers for it, so we'll have to get those.
5286 (when (stringp article)
5287 (gnus-read-header article))
5289 ;; If the article number is negative, that means that this article
5290 ;; doesn't belong in this newsgroup (possibly), so we find its
5291 ;; message-id and request it by id instead of number.
5292 (when (and (numberp article)
5294 (get-buffer gnus-summary-buffer)
5295 (gnus-buffer-exists-p gnus-summary-buffer))
5297 (set-buffer gnus-summary-buffer)
5298 (let ((header (gnus-summary-article-header article)))
5301 ((memq article gnus-newsgroup-sparse)
5302 ;; This is a sparse gap article.
5303 (setq do-update-line article)
5304 (setq article (mail-header-id header))
5305 (setq sparse-header (gnus-read-header article))
5306 (setq gnus-newsgroup-sparse
5307 (delq article gnus-newsgroup-sparse)))
5309 ;; It's a real article.
5310 (setq article (mail-header-id header)))
5312 ;; It is an extracted pseudo-article.
5313 (setq article 'pseudo)
5314 (gnus-request-pseudo-article header))))
5316 (let ((method (gnus-find-method-for-group
5317 gnus-newsgroup-name)))
5318 (when (and (eq (car method) 'nneething)
5320 (let ((dir (nneething-get-file-name
5321 (mail-header-id header))))
5322 (when (and (stringp dir)
5323 (file-directory-p dir))
5324 (setq article 'nneething)
5325 (gnus-group-enter-directory dir))))))))
5328 ;; Refuse to select canceled articles.
5329 ((and (numberp article)
5331 (get-buffer gnus-summary-buffer)
5332 (gnus-buffer-exists-p gnus-summary-buffer)
5333 (eq (cdr (save-excursion
5334 (set-buffer gnus-summary-buffer)
5335 (assq article gnus-newsgroup-reads)))
5336 gnus-canceled-mark))
5338 ;; We first check `gnus-original-article-buffer'.
5339 ((and (get-buffer gnus-original-article-buffer)
5342 (set-buffer gnus-original-article-buffer)
5343 (and (equal (car gnus-original-article) group)
5344 (eq (cdr gnus-original-article) article))))
5345 (insert-buffer-substring gnus-original-article-buffer)
5347 ;; Check the backlog.
5348 ((and gnus-keep-backlog
5349 (gnus-backlog-request-article group article (current-buffer)))
5351 ;; Check asynchronous pre-fetch.
5352 ((gnus-async-request-fetched-article group article (current-buffer))
5353 (gnus-async-prefetch-next group article gnus-summary-buffer)
5354 (when (and (numberp article) gnus-keep-backlog)
5355 (gnus-backlog-enter-article group article (current-buffer)))
5358 ((and gnus-use-cache
5360 (gnus-cache-request-article article group))
5362 ;; Check the agent cache.
5363 ((gnus-agent-request-article article group)
5365 ;; Get the article and put into the article buffer.
5366 ((or (stringp article)
5368 (let ((gnus-override-method gnus-override-method)
5369 (methods (and (stringp article)
5370 gnus-refer-article-method))
5371 (backend (car (gnus-find-method-for-group
5372 gnus-newsgroup-name)))
5374 (buffer-read-only nil))
5375 (if (or (not (listp methods))
5376 (and (symbolp (car methods))
5377 (assq (car methods) nnoo-definition-alist)))
5378 (setq methods (list methods)))
5379 (when (and (null gnus-override-method)
5381 (setq gnus-override-method (pop methods)))
5383 (when (eq gnus-override-method 'current)
5384 (setq gnus-override-method
5385 (with-current-buffer gnus-summary-buffer
5386 gnus-current-select-method)))
5388 (gnus-kill-all-overlays)
5389 (let ((gnus-newsgroup-name group))
5390 (gnus-check-group-server))
5392 ((gnus-request-article article group (current-buffer))
5393 (when (numberp article)
5394 (gnus-async-prefetch-next group article
5395 gnus-summary-buffer)
5396 (when gnus-keep-backlog
5397 (gnus-backlog-enter-article
5398 group article (current-buffer))))
5399 (setq result 'article))
5401 (setq gnus-override-method (pop methods)))
5402 ((not (string-match "^400 "
5403 (nnheader-get-report backend)))
5404 ;; If we get 400 server disconnect, reconnect and
5405 ;; retry; otherwise, assume the article has expired.
5406 (setq result 'done))))
5407 (and (eq result 'article) 'article)))
5411 ;; Associate this article with the current summary buffer.
5412 (setq gnus-article-current-summary gnus-summary-buffer)
5414 ;; Take the article from the original article buffer
5415 ;; and place it in the buffer it's supposed to be in.
5416 (when (and (get-buffer gnus-article-buffer)
5417 (equal (buffer-name (current-buffer))
5418 (buffer-name (get-buffer gnus-article-buffer))))
5420 (if (get-buffer gnus-original-article-buffer)
5421 (set-buffer gnus-original-article-buffer)
5422 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5423 (buffer-disable-undo)
5424 (setq major-mode 'gnus-original-article-mode)
5425 (setq buffer-read-only t))
5426 (let (buffer-read-only)
5428 (insert-buffer-substring gnus-article-buffer))
5429 (setq gnus-original-article (cons group article)))
5432 (run-hooks 'gnus-article-decode-hook)
5433 ;; Mark article as decoded or not.
5434 (setq gnus-article-decoded-p gnus-article-decode-hook))
5436 ;; Update sparse articles.
5437 (when (and do-update-line
5438 (or (numberp article)
5440 (let ((buf (current-buffer)))
5441 (set-buffer gnus-summary-buffer)
5442 (gnus-summary-update-article do-update-line sparse-header)
5443 (gnus-summary-goto-subject do-update-line nil t)
5444 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5446 (set-buffer buf))))))
5452 (defcustom gnus-article-edit-mode-hook nil
5453 "Hook run in article edit mode buffers."
5454 :group 'gnus-article-various
5457 (defvar gnus-article-edit-done-function nil)
5459 (defvar gnus-article-edit-mode-map nil)
5460 (defvar gnus-article-edit-mode nil)
5462 ;; Should we be using derived.el for this?
5463 (unless gnus-article-edit-mode-map
5464 (setq gnus-article-edit-mode-map (make-keymap))
5465 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5467 (gnus-define-keys gnus-article-edit-mode-map
5468 "\C-c?" describe-mode
5469 "\C-c\C-c" gnus-article-edit-done
5470 "\C-c\C-k" gnus-article-edit-exit
5471 "\C-c\C-f\C-t" message-goto-to
5472 "\C-c\C-f\C-o" message-goto-from
5473 "\C-c\C-f\C-b" message-goto-bcc
5474 ;;"\C-c\C-f\C-w" message-goto-fcc
5475 "\C-c\C-f\C-c" message-goto-cc
5476 "\C-c\C-f\C-s" message-goto-subject
5477 "\C-c\C-f\C-r" message-goto-reply-to
5478 "\C-c\C-f\C-n" message-goto-newsgroups
5479 "\C-c\C-f\C-d" message-goto-distribution
5480 "\C-c\C-f\C-f" message-goto-followup-to
5481 "\C-c\C-f\C-m" message-goto-mail-followup-to
5482 "\C-c\C-f\C-k" message-goto-keywords
5483 "\C-c\C-f\C-u" message-goto-summary
5484 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5485 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5486 "\C-c\C-b" message-goto-body
5487 "\C-c\C-i" message-goto-signature
5489 "\C-c\C-t" message-insert-to
5490 "\C-c\C-n" message-insert-newsgroups
5491 "\C-c\C-o" message-sort-headers
5492 "\C-c\C-e" message-elide-region
5493 "\C-c\C-v" message-delete-not-region
5494 "\C-c\C-z" message-kill-to-signature
5495 "\M-\r" message-newline-and-reformat
5496 "\C-c\C-a" mml-attach-file
5497 "\C-a" message-beginning-of-line
5499 "\M-;" comment-region)
5501 (gnus-define-keys (gnus-article-edit-wash-map
5502 "\C-c\C-w" gnus-article-edit-mode-map)
5503 "f" gnus-article-edit-full-stops))
5506 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5508 ["Fetch To" message-insert-to t]
5509 ["Fetch Newsgroups" message-insert-newsgroups t]
5511 ["To" message-goto-to t]
5512 ["From" message-goto-from t]
5513 ["Subject" message-goto-subject t]
5514 ["Cc" message-goto-cc t]
5515 ["Reply-To" message-goto-reply-to t]
5516 ["Summary" message-goto-summary t]
5517 ["Keywords" message-goto-keywords t]
5518 ["Newsgroups" message-goto-newsgroups t]
5519 ["Followup-To" message-goto-followup-to t]
5520 ["Mail-Followup-To" message-goto-mail-followup-to t]
5521 ["Distribution" message-goto-distribution t]
5522 ["Body" message-goto-body t]
5523 ["Signature" message-goto-signature t]))
5525 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5526 "Major mode for editing articles.
5527 This is an extended text-mode.
5529 \\{gnus-article-edit-mode-map}"
5530 (make-local-variable 'gnus-article-edit-done-function)
5531 (make-local-variable 'gnus-prev-winconf)
5532 (set (make-local-variable 'font-lock-defaults)
5533 '(message-font-lock-keywords t))
5534 (set (make-local-variable 'mail-header-separator) "")
5535 (set (make-local-variable 'gnus-article-edit-mode) t)
5536 (easy-menu-add message-mode-field-menu message-mode-map)
5538 (setq buffer-read-only nil)
5539 (buffer-enable-undo)
5542 (defun gnus-article-edit (&optional force)
5543 "Edit the current article.
5544 This will have permanent effect only in mail groups.
5545 If FORCE is non-nil, allow editing of articles even in read-only
5548 (when (and (not force)
5549 (gnus-group-read-only-p))
5550 (error "The current newsgroup does not support article editing"))
5551 (gnus-article-date-original)
5552 (gnus-article-edit-article
5554 `(lambda (no-highlight)
5556 (gnus-summary-edit-article-done
5557 ,(or (mail-header-references gnus-current-headers) "")
5558 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5560 (defun gnus-article-edit-article (start-func exit-func)
5561 "Start editing the contents of the current article buffer."
5562 (let ((winconf (current-window-configuration)))
5563 (set-buffer gnus-article-buffer)
5564 (gnus-article-edit-mode)
5565 (funcall start-func)
5566 (set-buffer-modified-p nil)
5567 (gnus-configure-windows 'edit-article)
5568 (setq gnus-article-edit-done-function exit-func)
5569 (setq gnus-prev-winconf winconf)
5570 (gnus-message 6 "C-c C-c to end edits")))
5572 (defun gnus-article-edit-done (&optional arg)
5573 "Update the article edits and exit."
5575 (let ((func gnus-article-edit-done-function)
5576 (buf (current-buffer))
5577 (start (window-start))
5579 (winconf gnus-prev-winconf))
5580 (widen) ;; Widen it in case that users narrowed the buffer.
5583 ;; The cache and backlog have to be flushed somewhat.
5584 (when gnus-keep-backlog
5585 (gnus-backlog-remove-article
5586 (car gnus-article-current) (cdr gnus-article-current)))
5587 ;; Flush original article as well.
5589 (when (get-buffer gnus-original-article-buffer)
5590 (set-buffer gnus-original-article-buffer)
5591 (setq gnus-original-article nil)))
5592 (when gnus-use-cache
5593 (gnus-cache-update-article
5594 (car gnus-article-current) (cdr gnus-article-current)))
5595 ;; We remove all text props from the article buffer.
5596 (kill-all-local-variables)
5597 (gnus-set-text-properties (point-min) (point-max) nil)
5599 (set-window-configuration winconf)
5601 (set-window-start (get-buffer-window buf) start)
5602 (set-window-point (get-buffer-window buf) (point)))
5603 (gnus-summary-show-article))
5605 (defun gnus-article-edit-exit ()
5606 "Exit the article editing without updating."
5608 (when (or (not (buffer-modified-p))
5609 (yes-or-no-p "Article modified; kill anyway? "))
5610 (let ((curbuf (current-buffer))
5612 (window-start (window-start)))
5614 (if (gnus-buffer-live-p gnus-original-article-buffer)
5615 (insert-buffer gnus-original-article-buffer))
5616 (let ((winconf gnus-prev-winconf))
5617 (kill-all-local-variables)
5619 (set-window-configuration winconf)
5620 ;; Tippy-toe some to make sure that point remains where it was.
5621 (save-current-buffer
5623 (set-window-start (get-buffer-window (current-buffer)) window-start)
5625 (gnus-summary-show-article)))
5627 (defun gnus-article-edit-full-stops ()
5628 "Interactively repair spacing at end of sentences."
5631 (goto-char (point-min))
5632 (search-forward-regexp "^$" nil t)
5633 (let ((case-fold-search nil))
5634 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5637 ;;; Article highlights
5640 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5642 ;;; Internal Variables:
5644 (defcustom gnus-button-url-regexp
5645 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5646 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5647 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5648 "Regular expression that matches URLs."
5649 :group 'gnus-article-buttons
5652 (defcustom gnus-button-valid-fqdn-regexp
5653 message-valid-fqdn-regexp
5654 "Regular expression that matches a valid FQDN."
5655 :group 'gnus-article-buttons
5658 (defcustom gnus-button-man-handler 'manual-entry
5659 "Function to use for displaying man pages.
5660 The function must take at least one argument with a string naming the
5662 :type '(choice (function-item :tag "Man" manual-entry)
5663 (function-item :tag "Woman" woman)
5664 (function :tag "Other"))
5665 :group 'gnus-article-buttons)
5667 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5668 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5669 If the default site is too slow, try to find a CTAN mirror, see
5670 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5671 the variable `gnus-button-handle-ctan'."
5672 :group 'gnus-article-buttons
5673 :link '(custom-manual "(gnus)Group Parameters")
5674 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5675 (const "http://tug.ctan.org/tex-archive/")
5676 (const "http://www.dante.de/CTAN/")
5677 (string :tag "Other")))
5679 (defcustom gnus-button-ctan-handler 'browse-url
5680 "Function to use for displaying CTAN links.
5681 The function must take one argument, the string naming the URL."
5682 :type '(choice (function-item :tag "Browse Url" browse-url)
5683 (function :tag "Other"))
5684 :group 'gnus-article-buttons)
5686 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5687 "Bogus strings removed from CTAN URLs."
5688 :group 'gnus-article-buttons
5689 :type '(choice (const "^/?tex-archive/\\|/")
5690 (regexp :tag "Other")))
5692 (defcustom gnus-button-ctan-directory-regexp
5694 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5695 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5696 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5697 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5699 "Regular expression for ctan directories.
5700 It should match all directories in the top level of `gnus-ctan-url'."
5701 :group 'gnus-article-buttons
5704 (defcustom gnus-button-mid-or-mail-regexp
5705 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5706 gnus-button-valid-fqdn-regexp
5708 "Regular expression that matches a message ID or a mail address."
5709 :group 'gnus-article-buttons
5712 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5713 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5714 Strings like this can be either a message ID or a mail address. If it is one
5715 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5716 message ID or a mail address, respectively. If this variable is set to the
5717 symbol `ask', always query the user what do do. If it is a function, this
5718 function will be called with the string as it's only argument. The function
5719 must return `mid', `mail', `invalid' or `ask'."
5720 :group 'gnus-article-buttons
5721 :type '(choice (function-item :tag "Heuristic function"
5722 gnus-button-mid-or-mail-heuristic)
5727 (defcustom gnus-button-mid-or-mail-heuristic-alist
5728 '((-10.0 . ".+\\$.+@")
5731 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5732 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5733 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5734 (-1.0 . "^[^a-z]+@")
5736 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5737 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5738 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5739 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5742 (-1.0 . "^[0-9][0-9]")
5744 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5745 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5746 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5747 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5749 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5750 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5753 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5755 ;; compensation for TDMA dated mail addresses:
5756 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5758 (-20.0 . "\\.fsf@") ;; Gnus
5761 (-20.0 . "_-_") ;; Subject change in thread
5763 (-20.0 . "\\.ln@") ;; leafnode
5764 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5765 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5767 ;; (5.0 . "") ;; $local_part_len <= 7
5768 (10.0 . "^[^0-9]+@")
5769 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5770 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5773 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5775 (0.5 . "^[A-Z][a-z]")
5776 (0.5 . "^[A-Z][a-z][a-z]")
5777 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5778 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5779 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5781 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5782 address. The REGEXP is processed with `case-fold-search' set to nil."
5783 :group 'gnus-article-buttons
5784 :type '(repeat (cons (number :tag "Rate")
5785 (regexp :tag "Regexp"))))
5787 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5788 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5789 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5790 address, `ask' if unsure and `invalid' if the string is invalid."
5791 (let ((case-fold-search nil)
5792 (list gnus-button-mid-or-mail-heuristic-alist)
5793 (result 0) rate regexp lpartlen elem)
5795 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5796 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5797 ;; Certain special cases...
5800 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5801 "^[0-9]+\.[0-9]+\@compuserve")
5803 (gnus-message 8 "`%s' is a known mail address.")
5804 (setq result 'mail))
5805 (when (string-match "@.*@\\| " mid-or-mail)
5806 (gnus-message 8 "`%s' is invalid.")
5807 (setq result 'invalid))
5808 ;; Nothing more to do, if result is not a number here...
5809 (when (numberp result)
5811 (setq elem (car list)
5815 (when (string-match regexp mid-or-mail)
5816 (setq result (+ result rate))
5818 9 "`%s' matched `%s', rate `%s', result `%s'."
5819 mid-or-mail regexp rate result)))
5820 (when (<= lpartlen 7)
5821 (setq result (+ result 5.0))
5822 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5823 mid-or-mail result))
5824 (when (>= lpartlen 12)
5825 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5827 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5828 ;; Long local part should contain realname if e-mail address,
5829 ;; too many digits: message-id.
5830 ;; $score -= 5.0 + 0.1 * $local_part_len;
5831 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5832 (setq result (+ result rate))
5834 9 "Many digits in `%s', rate `%s', result `%s'."
5835 mid-or-mail rate result))
5836 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5838 ;; Too few vowels [^aeiouy]{4,}.*\@
5839 (setq result (+ result -5.0))
5841 9 "Few vowels in `%s', rate `%s', result `%s'."
5842 mid-or-mail -5.0 result))
5844 (setq result (+ result 5.0))
5846 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5847 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5849 ;; Maybe we should make this a customizable alist: (condition . 'result)
5850 ((< result -10.0) 'mid)
5851 ((> result 10.0) 'mail)
5854 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5855 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5856 (url-mid (concat "news" ":" mid-or-mail))
5857 (url-mailto (concat "mailto" ":" mid-or-mail)))
5858 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5859 (when (fboundp pref)
5861 ;; get rid of surrounding angles...
5863 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5864 (if (or (eq 'mid guessed) (eq 'mail guessed))
5868 (save-window-excursion
5869 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5872 (cond ((eq pref 'mid)
5873 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5874 (gnus-button-handle-news url-mid))
5876 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5877 (gnus-url-mailto url-mailto))
5878 (t (gnus-message 3 "Invalid string.")))))
5880 (defun gnus-button-handle-custom (url)
5881 "Follow a Custom URL."
5882 (customize-apropos (gnus-url-unhex-string url)))
5884 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5886 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5889 (defun gnus-button-handle-describe-function (url)
5890 "Call `describe-function' when pushing the corresponding URL button."
5893 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5895 (defun gnus-button-handle-describe-variable (url)
5896 "Call `describe-variable' when pushing the corresponding URL button."
5899 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5901 (defun gnus-button-handle-symbol (url)
5902 "Display help on variable or function.
5903 Calls `describe-variable' or `describe-function'."
5904 (let ((sym (intern url)))
5906 ((fboundp sym) (describe-function sym))
5907 ((boundp sym) (describe-variable sym))
5908 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5910 (defun gnus-button-handle-describe-key (url)
5911 "Call `describe-key' when pushing the corresponding URL button."
5913 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5914 (keys (ignore-errors (eval `(kbd ,key-string)))))
5917 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5919 (defun gnus-button-handle-apropos (url)
5920 "Call `apropos' when pushing the corresponding URL button."
5921 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5923 (defun gnus-button-handle-apropos-command (url)
5924 "Call `apropos' when pushing the corresponding URL button."
5926 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5928 (defun gnus-button-handle-apropos-variable (url)
5929 "Call `apropos' when pushing the corresponding URL button."
5931 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5932 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5934 (defun gnus-button-handle-apropos-documentation (url)
5935 "Call `apropos' when pushing the corresponding URL button."
5937 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5938 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5940 (defun gnus-button-handle-library (url)
5941 "Call `locate-library' when pushing the corresponding URL button."
5942 (gnus-message 9 "url=`%s'" url)
5943 (let* ((lib (locate-library url))
5944 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5946 (gnus-message 1 "Cannot locale library `%s'." url)
5947 (find-file-read-only file))))
5949 (defun gnus-button-handle-ctan (url)
5950 "Call `browse-url' when pushing a CTAN URL button."
5952 gnus-button-ctan-handler
5955 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5957 (defcustom gnus-button-tex-level 5
5958 "*Integer that says how many TeX-related buttons Gnus will show.
5959 The higher the number, the more buttons will appear and the more false
5960 positives are possible. Note that you can set this variable local to
5961 specific groups. Setting it higher in TeX groups is probably a good idea.
5962 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5963 how to set variables in specific groups."
5964 :group 'gnus-article-buttons
5965 :link '(custom-manual "(gnus)Group Parameters")
5968 (defcustom gnus-button-man-level 5
5969 "*Integer that says how many man-related buttons Gnus will show.
5970 The higher the number, the more buttons will appear and the more false
5971 positives are possible. Note that you can set this variable local to
5972 specific groups. Setting it higher in Unix groups is probably a good idea.
5973 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5974 how to set variables in specific groups."
5975 :group 'gnus-article-buttons
5976 :link '(custom-manual "(gnus)Group Parameters")
5979 (defcustom gnus-button-emacs-level 5
5980 "*Integer that says how many emacs-related buttons Gnus will show.
5981 The higher the number, the more buttons will appear and the more false
5982 positives are possible. Note that you can set this variable local to
5983 specific groups. Setting it higher in Emacs or Gnus related groups is
5984 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5985 `gnus-parameters' on how to set variables in specific groups."
5986 :group 'gnus-article-buttons
5987 :link '(custom-manual "(gnus)Group Parameters")
5990 (defcustom gnus-button-message-level 5
5991 "*Integer that says how many buttons for news or mail messages will appear.
5992 The higher the number, the more buttons will appear and the more false
5993 positives are possible."
5994 ;; mail addresses, MIDs, URLs for news, ...
5995 :group 'gnus-article-buttons
5998 (defcustom gnus-button-browse-level 5
5999 "*Integer that says how many buttons for browsing will appear.
6000 The higher the number, the more buttons will appear and the more false
6001 positives are possible."
6002 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6003 :group 'gnus-article-buttons
6006 (defcustom gnus-button-alist
6007 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6008 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6009 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6010 gnus-button-handle-news 2)
6011 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6012 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6013 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6014 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6015 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6016 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6017 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6018 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6019 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6020 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6021 ("\\bmailto:\\([^ \n\t]+\\)"
6022 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6024 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6025 gnus-button-ctan-directory-regexp
6026 "[^][>)!;:,'\n\t ]+\\)")
6027 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6028 ((concat "\\btex-archive/\\("
6029 gnus-button-ctan-directory-regexp
6030 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6031 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6034 gnus-button-ctan-directory-regexp
6035 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6036 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6038 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6039 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6040 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6041 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6042 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6043 ;; Info links like `C-h i d m CC Mode RET'
6044 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6046 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6047 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6048 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6049 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6050 ;; Emacs help commands
6051 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6052 ;; regexp doesn't match arguments containing ` '.
6053 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6054 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6055 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6056 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6057 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6058 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6059 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6060 ;; The following entries may lead to many false positives so don't enable
6061 ;; them by default (use a high button level):
6062 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6063 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6064 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6065 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6066 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6067 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6068 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6069 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6070 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6071 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6072 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6073 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6074 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6075 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6076 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6077 ;; Unlike the other regexps we really have to require quoting
6078 ;; here to determine where it ends.
6079 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6080 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6081 ("<URL: *\\([^<>]*\\)>"
6082 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6084 (gnus-button-url-regexp
6085 0 (>= gnus-button-browse-level 0) browse-url 0)
6087 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6088 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6089 gnus-button-handle-man 1)
6090 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6091 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6092 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6093 gnus-button-handle-man 1)
6094 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6095 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6096 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6097 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6098 ;; MID or mail: To avoid too many false positives we don't try to catch
6099 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6100 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6101 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6102 ;; so that non-ambiguous entries (see above) match first.
6103 (gnus-button-mid-or-mail-regexp
6104 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6105 "*Alist of regexps matching buttons in article bodies.
6107 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6108 REGEXP: is the string (case insensitive) matching text around the button (can
6109 also be Lisp expression evaluating to a string),
6110 BUTTON: is the number of the regexp grouping actually matching the button,
6111 FORM: is a Lisp expression which must eval to true for the button to
6113 CALLBACK: is the function to call when the user push this button, and each
6114 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6116 CALLBACK can also be a variable, in that case the value of that
6117 variable it the real callback function."
6118 :group 'gnus-article-buttons
6119 :type '(repeat (list (choice regexp variable sexp)
6120 (integer :tag "Button")
6122 (function :tag "Callback")
6125 (integer :tag "Regexp group")))))
6127 (defcustom gnus-header-button-alist
6128 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6129 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6130 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6131 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6132 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6133 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6134 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6135 0 (>= gnus-button-browse-level 0) browse-url 0)
6136 ("^Subject:" gnus-button-url-regexp
6137 0 (>= gnus-button-browse-level 0) browse-url 0)
6138 ("^[^:]+:" gnus-button-url-regexp
6139 0 (>= gnus-button-browse-level 0) browse-url 0)
6140 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6141 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6142 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6143 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6144 "*Alist of headers and regexps to match buttons in article heads.
6146 This alist is very similar to `gnus-button-alist', except that each
6147 alist has an additional HEADER element first in each entry:
6149 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6151 HEADER is a regexp to match a header. For a fuller explanation, see
6152 `gnus-button-alist'."
6153 :group 'gnus-article-buttons
6154 :group 'gnus-article-headers
6155 :type '(repeat (list (regexp :tag "Header")
6156 (choice regexp variable)
6157 (integer :tag "Button")
6159 (function :tag "Callback")
6162 (integer :tag "Regexp group")))))
6164 (defvar gnus-button-regexp nil)
6165 (defvar gnus-button-marker-list nil)
6166 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6168 (defvar gnus-button-last nil)
6169 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6173 (defun gnus-article-push-button (event)
6174 "Check text under the mouse pointer for a callback function.
6175 If the text under the mouse pointer has a `gnus-callback' property,
6176 call it with the value of the `gnus-data' text property."
6178 (set-buffer (window-buffer (posn-window (event-start event))))
6179 (let* ((pos (posn-point (event-start event)))
6180 (data (get-text-property pos 'gnus-data))
6181 (fun (get-text-property pos 'gnus-callback)))
6184 (funcall fun data))))
6186 (defun gnus-article-press-button ()
6187 "Check text at point for a callback function.
6188 If the text at point has a `gnus-callback' property,
6189 call it with the value of the `gnus-data' text property."
6191 (let ((data (get-text-property (point) 'gnus-data))
6192 (fun (get-text-property (point) 'gnus-callback)))
6194 (funcall fun data))))
6196 (defun gnus-article-highlight (&optional force)
6197 "Highlight current article.
6198 This function calls `gnus-article-highlight-headers',
6199 `gnus-article-highlight-citation',
6200 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6201 do the highlighting. See the documentation for those functions."
6202 (interactive (list 'force))
6203 (gnus-article-highlight-headers)
6204 (gnus-article-highlight-citation force)
6205 (gnus-article-highlight-signature)
6206 (gnus-article-add-buttons force)
6207 (gnus-article-add-buttons-to-head))
6209 (defun gnus-article-highlight-some (&optional force)
6210 "Highlight current article.
6211 This function calls `gnus-article-highlight-headers',
6212 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6213 do the highlighting. See the documentation for those functions."
6214 (interactive (list 'force))
6215 (gnus-article-highlight-headers)
6216 (gnus-article-highlight-signature)
6217 (gnus-article-add-buttons))
6219 (defun gnus-article-highlight-headers ()
6220 "Highlight article headers as specified by `gnus-header-face-alist'."
6223 (set-buffer gnus-article-buffer)
6225 (let ((alist gnus-header-face-alist)
6226 (buffer-read-only nil)
6227 (case-fold-search t)
6228 (inhibit-point-motion-hooks t)
6229 entry regexp header-face field-face from hpoints fpoints)
6230 (article-narrow-to-head)
6231 (while (setq entry (pop alist))
6232 (goto-char (point-min))
6233 (setq regexp (concat "^\\("
6234 (if (string-equal "" (nth 0 entry))
6238 header-face (nth 1 entry)
6239 field-face (nth 2 entry))
6240 (while (and (re-search-forward regexp nil t)
6244 (unless (search-forward ":" nil t)
6246 (when (and header-face
6247 (not (memq (point) hpoints)))
6248 (push (point) hpoints)
6249 (gnus-put-text-property from (point) 'face header-face))
6250 (when (and field-face
6251 (not (memq (setq from (point)) fpoints)))
6253 (if (re-search-forward "^[^ \t]" nil t)
6255 (goto-char (point-max)))
6256 (gnus-put-text-property from (point) 'face field-face))))))))
6258 (defun gnus-article-highlight-signature ()
6259 "Highlight the signature in an article.
6260 It does this by highlighting everything after
6261 `gnus-signature-separator' using `gnus-signature-face'."
6264 (set-buffer gnus-article-buffer)
6265 (let ((buffer-read-only nil)
6266 (inhibit-point-motion-hooks t))
6268 (when (and gnus-signature-face
6269 (gnus-article-narrow-to-signature))
6270 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6271 'face gnus-signature-face)
6273 (gnus-article-search-signature)
6274 (let ((start (match-beginning 0))
6275 (end (set-marker (make-marker) (1+ (match-end 0)))))
6276 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6279 (defun gnus-button-in-region-p (b e prop)
6280 "Say whether PROP exists in the region."
6281 (text-property-not-all b e prop nil))
6283 (defun gnus-article-add-buttons (&optional force)
6284 "Find external references in the article and make buttons of them.
6285 \"External references\" are things like Message-IDs and URLs, as
6286 specified by `gnus-button-alist'."
6287 (interactive (list 'force))
6289 (set-buffer gnus-article-buffer)
6290 (let ((buffer-read-only nil)
6291 (inhibit-point-motion-hooks t)
6292 (case-fold-search t)
6293 (alist gnus-button-alist)
6295 ;; Remove all old markers.
6296 (let (marker entry new-list)
6297 (while (setq marker (pop gnus-button-marker-list))
6298 (if (or (< marker (point-min)) (>= marker (point-max)))
6299 (push marker new-list)
6301 (when (setq entry (gnus-button-entry))
6302 (put-text-property (match-beginning (nth 1 entry))
6303 (match-end (nth 1 entry))
6304 'gnus-callback nil))
6305 (set-marker marker nil)))
6306 (setq gnus-button-marker-list new-list))
6307 ;; We skip the headers.
6310 (while (setq entry (pop alist))
6311 (setq regexp (eval (car entry)))
6313 (while (re-search-forward regexp nil t)
6314 (let* ((start (and entry (match-beginning (nth 1 entry))))
6315 (end (and entry (match-end (nth 1 entry))))
6316 (from (match-beginning 0)))
6317 (when (and (or (eq t (nth 2 entry))
6318 (eval (nth 2 entry)))
6319 (not (gnus-button-in-region-p
6320 start end 'gnus-callback)))
6321 ;; That optional form returned non-nil, so we add the
6323 (gnus-article-add-button
6324 start end 'gnus-button-push
6325 (car (push (set-marker (make-marker) from)
6326 gnus-button-marker-list))))))))))
6328 ;; Add buttons to the head of an article.
6329 (defun gnus-article-add-buttons-to-head ()
6330 "Add buttons to the head of the article."
6333 (set-buffer gnus-article-buffer)
6335 (let ((buffer-read-only nil)
6336 (inhibit-point-motion-hooks t)
6337 (case-fold-search t)
6338 (alist gnus-header-button-alist)
6340 (article-narrow-to-head)
6342 ;; Each alist entry.
6343 (setq entry (car alist)
6345 (goto-char (point-min))
6346 (while (re-search-forward (car entry) nil t)
6347 ;; Each header matching the entry.
6348 (setq beg (match-beginning 0))
6349 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6350 (match-beginning 0))
6353 (while (re-search-forward (eval (nth 1 entry)) end t)
6354 ;; Each match within a header.
6355 (let* ((entry (cdr entry))
6356 (start (match-beginning (nth 1 entry)))
6357 (end (match-end (nth 1 entry)))
6358 (form (nth 2 entry)))
6359 (goto-char (match-end 0))
6361 (gnus-article-add-button
6362 start end (nth 3 entry)
6363 (buffer-substring (match-beginning (nth 4 entry))
6364 (match-end (nth 4 entry)))))))
6365 (goto-char end)))))))
6367 ;;; External functions:
6369 (defun gnus-article-add-button (from to fun &optional data)
6370 "Create a button between FROM and TO with callback FUN and data DATA."
6371 (when gnus-article-button-face
6372 (gnus-overlay-put (gnus-make-overlay from to)
6373 'face gnus-article-button-face))
6374 (gnus-add-text-properties
6376 (nconc (and gnus-article-mouse-face
6377 (list gnus-mouse-face-prop gnus-article-mouse-face))
6378 (list 'gnus-callback fun)
6379 (and data (list 'gnus-data data))))
6380 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6381 :button-keymap gnus-widget-button-keymap))
6383 ;;; Internal functions:
6385 (defun gnus-article-set-globals ()
6387 (set-buffer gnus-summary-buffer)
6388 (gnus-set-global-variables)))
6390 (defun gnus-signature-toggle (end)
6392 (set-buffer gnus-article-buffer)
6393 (let ((buffer-read-only nil)
6394 (inhibit-point-motion-hooks t))
6395 (if (text-property-any end (point-max) 'article-type 'signature)
6397 (gnus-delete-wash-type 'signature)
6398 (gnus-remove-text-properties-when
6399 'article-type 'signature end (point-max)
6400 (cons 'article-type (cons 'signature
6401 gnus-hidden-properties))))
6402 (gnus-add-wash-type 'signature)
6403 (gnus-add-text-properties-when
6404 'article-type nil end (point-max)
6405 (cons 'article-type (cons 'signature
6406 gnus-hidden-properties)))))
6407 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6408 (gnus-set-mode-line 'article))))
6410 (defun gnus-button-entry ()
6411 ;; Return the first entry in `gnus-button-alist' matching this place.
6412 (let ((alist gnus-button-alist)
6415 (setq entry (pop alist))
6416 (if (looking-at (eval (car entry)))
6421 (defun gnus-button-push (marker)
6422 ;; Push button starting at MARKER.
6425 (let* ((entry (gnus-button-entry))
6426 (inhibit-point-motion-hooks t)
6428 (args (mapcar (lambda (group)
6429 (let ((string (match-string group)))
6430 (gnus-set-text-properties
6431 0 (length string) nil string)
6438 (fboundp (symbol-value fun)))
6439 (apply (symbol-value fun) args))
6441 (gnus-message 1 "You must define `%S' to use this button"
6442 (cons fun args)))))))
6444 (defun gnus-parse-news-url (url)
6445 (let (scheme server group message-id articles)
6448 (goto-char (point-min))
6449 (when (looking-at "\\([A-Za-z]+\\):")
6450 (setq scheme (match-string 1))
6451 (goto-char (match-end 0)))
6452 (when (looking-at "//\\([^/]+\\)/")
6453 (setq server (match-string 1))
6454 (goto-char (match-end 0)))
6457 ((looking-at "\\(.*@.*\\)")
6458 (setq message-id (match-string 1)))
6459 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6460 (setq group (match-string 1)
6461 articles (split-string (match-string 2) "-")))
6462 ((looking-at "\\([^/]+\\)/?")
6463 (setq group (match-string 1)))
6465 (error "Unknown news URL syntax"))))
6466 (list scheme server group message-id articles)))
6468 (defun gnus-button-handle-news (url)
6470 (destructuring-bind (scheme server group message-id articles)
6471 (gnus-parse-news-url url)
6475 (set-buffer gnus-summary-buffer)
6477 (let ((gnus-refer-article-method (list (list 'nntp server))))
6478 (gnus-summary-refer-article message-id))
6479 (gnus-summary-refer-article message-id))))
6481 (gnus-button-fetch-group url)))))
6483 (defun gnus-button-handle-man (url)
6485 (funcall gnus-button-man-handler url))
6487 (defun gnus-button-handle-info-url (url)
6488 "Fetch an info URL."
6490 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6491 (gnus-info-find-node
6492 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6494 ")" (gnus-url-unhex-string (match-string 2 url)))))
6495 ((string-match "([^)\"]+)[^\"]+" url)
6497 (gnus-replace-in-string
6498 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6499 (gnus-info-find-node url))
6500 (t (error "Can't parse %s" url))))
6502 (defun gnus-button-handle-info-keystrokes (url)
6503 "Call `info' when pushing the corresponding URL button."
6504 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6509 (defun gnus-button-message-id (message-id)
6512 (set-buffer gnus-summary-buffer)
6513 (gnus-summary-refer-article message-id)))
6515 (defun gnus-button-fetch-group (address)
6516 "Fetch GROUP specified by ADDRESS."
6517 (if (not (string-match "[:/]" address))
6518 ;; This is just a simple group url.
6519 (gnus-group-read-ephemeral-group address gnus-select-method)
6522 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6524 (error "Can't parse %s" address)
6525 (gnus-group-read-ephemeral-group
6526 (match-string 4 address)
6527 `(nntp ,(match-string 1 address)
6528 (nntp-address ,(match-string 1 address))
6529 (nntp-port-number ,(if (match-end 3)
6530 (match-string 3 address)
6533 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6535 (defun gnus-url-parse-query-string (query &optional downcase)
6536 (let (retval pairs cur key val)
6537 (setq pairs (split-string query "&"))
6539 (setq cur (car pairs)
6541 (if (not (string-match "=" cur))
6543 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6544 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6546 (setq key (downcase key)))
6547 (setq cur (assoc key retval))
6549 (setcdr cur (cons val (cdr cur)))
6550 (setq retval (cons (list key val) retval)))))
6553 (defun gnus-url-mailto (url)
6554 ;; Send mail to someone
6555 (when (string-match "mailto:/*\\(.*\\)" url)
6556 (setq url (substring url (match-beginning 1) nil)))
6557 (let (to args subject func)
6558 (if (string-match (regexp-quote "?") url)
6559 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6560 args (gnus-url-parse-query-string
6561 (substring url (match-end 0) nil) t))
6562 (setq to (gnus-url-unhex-string url)))
6563 (setq args (cons (list "to" to) args)
6564 subject (cdr-safe (assoc "subject" args)))
6567 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6570 (message-position-on-field (caar args)))
6571 (insert (mapconcat 'identity (cdar args) ", "))
6572 (setq args (cdr args)))
6575 (message-goto-subject))))
6577 (defun gnus-button-embedded-url (address)
6578 "Activate ADDRESS with `browse-url'."
6579 (browse-url (gnus-strip-whitespace address)))
6581 ;;; Next/prev buttons in the article buffer.
6583 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6584 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6586 (defvar gnus-prev-page-map
6587 (let ((map (make-sparse-keymap)))
6588 (unless (>= emacs-major-version 21)
6589 ;; XEmacs doesn't care.
6590 (set-keymap-parent map gnus-article-mode-map))
6591 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6592 (define-key map "\r" 'gnus-button-prev-page)
6595 (defun gnus-insert-prev-page-button ()
6597 (buffer-read-only nil))
6599 gnus-prev-page-line-format nil
6600 `(,@(gnus-local-map-property gnus-prev-page-map)
6602 gnus-callback gnus-article-button-prev-page
6603 article-type annotation))
6604 (widget-convert-button
6606 ;; Exclude a newline.
6609 :action 'gnus-button-prev-page
6610 :button-keymap gnus-prev-page-map)))
6612 (defvar gnus-prev-page-map
6613 (let ((map (make-sparse-keymap)))
6614 (unless (>= emacs-major-version 21)
6615 ;; XEmacs doesn't care.
6616 (set-keymap-parent map gnus-article-mode-map))
6617 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6618 (define-key map "\r" 'gnus-button-prev-page)
6621 (defvar gnus-next-page-map
6622 (let ((map (make-sparse-keymap)))
6623 (unless (>= emacs-major-version 21)
6624 ;; XEmacs doesn't care.
6625 (set-keymap-parent map gnus-article-mode-map))
6626 (define-key map gnus-mouse-2 'gnus-button-next-page)
6627 (define-key map "\r" 'gnus-button-next-page)
6630 (defun gnus-button-next-page (&optional args more-args)
6631 "Go to the next page."
6633 (let ((win (selected-window)))
6634 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6635 (gnus-article-next-page)
6636 (select-window win)))
6638 (defun gnus-button-prev-page (&optional args more-args)
6639 "Go to the prev page."
6641 (let ((win (selected-window)))
6642 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6643 (gnus-article-prev-page)
6644 (select-window win)))
6646 (defun gnus-insert-next-page-button ()
6648 (buffer-read-only nil))
6649 (gnus-eval-format gnus-next-page-line-format nil
6650 `(,@(gnus-local-map-property gnus-next-page-map)
6652 gnus-callback gnus-article-button-next-page
6653 article-type annotation))
6654 (widget-convert-button
6656 ;; Exclude a newline.
6659 :action 'gnus-button-next-page
6660 :button-keymap gnus-next-page-map)))
6662 (defun gnus-article-button-next-page (arg)
6663 "Go to the next page."
6665 (let ((win (selected-window)))
6666 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6667 (gnus-article-next-page)
6668 (select-window win)))
6670 (defun gnus-article-button-prev-page (arg)
6671 "Go to the prev page."
6673 (let ((win (selected-window)))
6674 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6675 (gnus-article-prev-page)
6676 (select-window win)))
6678 (defvar gnus-decode-header-methods
6679 '(mail-decode-encoded-word-region)
6680 "List of methods used to decode headers.
6682 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6683 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6684 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6685 whose names match REGEXP.
6688 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6689 mail-decode-encoded-word-region
6690 (\"chinese\" . rfc1843-decode-region))
6693 (defvar gnus-decode-header-methods-cache nil)
6695 (defun gnus-multi-decode-header (start end)
6696 "Apply the functions from `gnus-encoded-word-methods' that match."
6697 (unless (and gnus-decode-header-methods-cache
6698 (eq gnus-newsgroup-name
6699 (car gnus-decode-header-methods-cache)))
6700 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6703 (nconc gnus-decode-header-methods-cache (list x))
6704 (if (and gnus-newsgroup-name
6705 (string-match (car x) gnus-newsgroup-name))
6706 (nconc gnus-decode-header-methods-cache
6708 gnus-decode-header-methods))
6709 (let ((xlist gnus-decode-header-methods-cache))
6712 (narrow-to-region start end)
6714 (funcall (pop xlist) (point-min) (point-max))))))
6717 ;;; Treatment top-level handling.
6720 (defun gnus-treat-article (condition &optional part-number total-parts type)
6721 (let ((length (- (point-max) (point-min)))
6722 (alist gnus-treatment-function-alist)
6723 (article-goto-body-goes-to-point-min-p t)
6727 (let ((list gnus-article-treat-types))
6729 (when (string-match (pop list) type)
6730 (throw 'found t)))))))
6731 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6733 (gnus-run-hooks 'gnus-part-display-hook)
6734 (dolist (elem alist)
6737 (when (gnus-buffer-live-p gnus-summary-buffer)
6738 (set-buffer gnus-summary-buffer))
6739 (symbol-value (car elem))))
6740 (when (and (or (consp val)
6742 (gnus-treat-predicate val)
6743 (or (not (get (car elem) 'highlight))
6746 (funcall (cadr elem)))))))
6748 ;; Dynamic variables.
6750 (defvar part-number)
6751 (defvar total-parts)
6756 (defun gnus-treat-predicate (val)
6763 (stringp (car val)))
6764 (apply 'gnus-or (mapcar `(lambda (s)
6765 (string-match s ,(or gnus-newsgroup-name "")))
6768 (let ((pred (pop val)))
6771 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6773 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6775 (not (gnus-treat-predicate (car val))))
6777 (equal (car val) type))
6779 (error "%S is not a valid predicate" pred)))))
6785 (eq part-number total-parts))
6789 (error "%S is not a valid value" val))))
6791 (defun gnus-article-encrypt-body (protocol &optional n)
6792 "Encrypt the article body."
6795 (or gnus-article-encrypt-protocol
6796 (completing-read "Encrypt protocol: "
6797 gnus-article-encrypt-protocol-alist
6799 current-prefix-arg))
6800 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6802 (error (format "Can't find the encrypt protocol %s" protocol)))
6803 (if (member gnus-newsgroup-name '("nndraft:delayed"
6806 (error "Can't encrypt the article in group %s"
6807 gnus-newsgroup-name))
6808 (gnus-summary-iterate n
6810 (set-buffer gnus-summary-buffer)
6811 (let ((mail-parse-charset gnus-newsgroup-charset)
6812 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6813 (summary-buffer gnus-summary-buffer)
6815 (gnus-set-global-variables)
6816 (when (gnus-group-read-only-p)
6817 (error "The current newsgroup does not support article encrypt"))
6818 (gnus-summary-show-article t)
6820 (or (mail-header-references gnus-current-headers) ""))
6821 (set-buffer gnus-article-buffer)
6822 (let* ((buffer-read-only nil)
6824 (mapcar (lambda (field)
6825 (and (save-restriction
6826 (message-narrow-to-head)
6827 (goto-char (point-min))
6828 (search-forward field nil t))
6830 (message-narrow-to-field)
6832 (delete-region (point-min) (point-max))
6834 '("Content-Type:" "Content-Transfer-Encoding:"
6835 "Content-Disposition:"))))
6836 (message-narrow-to-head)
6837 (message-remove-header "MIME-Version")
6838 (goto-char (point-max))
6839 (setq point (point))
6840 (insert (apply 'concat headers))
6842 (narrow-to-region point (point-max))
6843 (let ((message-options message-options))
6844 (message-options-set 'message-sender user-mail-address)
6845 (message-options-set 'message-recipients user-mail-address)
6846 (message-options-set 'message-sign-encrypt 'not)
6848 (goto-char (point-min))
6849 (insert "MIME-Version: 1.0\n")
6851 (gnus-summary-edit-article-done
6852 references nil summary-buffer t))
6853 (when gnus-keep-backlog
6854 (gnus-backlog-remove-article
6855 (car gnus-article-current) (cdr gnus-article-current)))
6857 (when (get-buffer gnus-original-article-buffer)
6858 (set-buffer gnus-original-article-buffer)
6859 (setq gnus-original-article nil)))
6860 (when gnus-use-cache
6861 (gnus-cache-update-article
6862 (car gnus-article-current) (cdr gnus-article-current))))))))
6864 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6865 "The following specs can be used:
6866 %t The security MIME type
6869 %D Details if button is pressed")
6871 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6872 "The following specs can be used:
6873 %t The security MIME type
6876 %D Details if button is pressed")
6878 (defvar gnus-mime-security-button-line-format-alist
6879 '((?t gnus-tmp-type ?s)
6880 (?i gnus-tmp-info ?s)
6881 (?d gnus-tmp-details ?s)
6882 (?D gnus-tmp-pressed-details ?s)))
6884 (defvar gnus-mime-security-button-map
6885 (let ((map (make-sparse-keymap)))
6886 (unless (>= (string-to-number emacs-version) 21)
6887 (set-keymap-parent map gnus-article-mode-map))
6888 (define-key map gnus-mouse-2 'gnus-article-push-button)
6889 (define-key map "\r" 'gnus-article-press-button)
6892 (defvar gnus-mime-security-details-buffer nil)
6894 (defvar gnus-mime-security-button-pressed nil)
6896 (defvar gnus-mime-security-show-details-inline t
6897 "If non-nil, show details in the article buffer.")
6899 (defun gnus-mime-security-verify-or-decrypt (handle)
6900 (mm-remove-parts (cdr handle))
6901 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6902 point buffer-read-only)
6904 (goto-char (car region)))
6906 (narrow-to-region (point) (point))
6907 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6908 (let* ((mm-verify-option 'known)
6909 (mm-decrypt-option 'known)
6910 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6911 (unless (eq nparts (cdr handle))
6912 (mm-destroy-parts (cdr handle))
6913 (setcdr handle nparts))))
6914 (setq point (point))
6915 (gnus-mime-display-security handle)
6916 (goto-char (point-max)))
6918 (delete-region (point) (cdr region))
6919 (set-marker (car region) nil)
6920 (set-marker (cdr region) nil))
6923 (defun gnus-mime-security-show-details (handle)
6924 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6926 (gnus-message 5 "No details.")
6927 (if gnus-mime-security-show-details-inline
6928 (let ((gnus-mime-security-button-pressed
6929 (not (get-text-property (point) 'gnus-mime-details)))
6930 (gnus-mime-security-button-line-format
6931 (get-text-property (point) 'gnus-line-format))
6934 (while (eq (get-text-property (point) 'gnus-line-format)
6935 gnus-mime-security-button-line-format)
6939 (narrow-to-region (point) (point))
6940 (gnus-insert-mime-security-button handle))
6941 (delete-region (point)
6942 (or (text-property-not-all
6945 gnus-mime-security-button-line-format)
6948 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6949 (with-current-buffer gnus-mime-security-details-buffer
6952 (setq gnus-mime-security-details-buffer
6953 (gnus-get-buffer-create "*MIME Security Details*")))
6954 (with-current-buffer gnus-mime-security-details-buffer
6956 (goto-char (point-min)))
6957 (pop-to-buffer gnus-mime-security-details-buffer)))))
6959 (defun gnus-mime-security-press-button (handle)
6961 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6962 (gnus-mime-security-show-details handle)
6963 (gnus-mime-security-verify-or-decrypt handle))))
6965 (defun gnus-insert-mime-security-button (handle &optional displayed)
6966 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6969 (or (nth 2 (assoc protocol mm-verify-function-alist))
6970 (nth 2 (assoc protocol mm-decrypt-function-alist))
6972 (if (equal (car handle) "multipart/signed")
6973 " Signed" " Encrypted")
6976 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6979 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6980 gnus-tmp-pressed-details
6982 (setq gnus-tmp-details
6983 (if gnus-tmp-details
6984 (concat "\n" gnus-tmp-details)
6986 (setq gnus-tmp-pressed-details
6987 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6992 gnus-mime-security-button-line-format
6993 gnus-mime-security-button-line-format-alist
6994 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6995 gnus-callback gnus-mime-security-press-button
6996 gnus-line-format ,gnus-mime-security-button-line-format
6997 gnus-mime-details ,gnus-mime-security-button-pressed
6998 article-type annotation
7001 ;; Exclude a newline.
7004 (widget-convert-button
7007 :action 'gnus-widget-press-button
7008 :button-keymap gnus-mime-security-button-map
7010 (lambda (widget/window &optional overlay pos)
7011 ;; Needed to properly clear the message due to a bug in
7012 ;; wid-edit (XEmacs only).
7013 (when (boundp 'help-echo-owns-message)
7014 (setq help-echo-owns-message t))
7017 (aref gnus-mouse-2 0))))))
7019 (defun gnus-mime-display-security (handle)
7021 (narrow-to-region (point) (point))
7022 (unless (gnus-unbuttonized-mime-type-p (car handle))
7023 (gnus-insert-mime-security-button handle))
7024 (gnus-mime-display-mixed (cdr handle))
7027 (unless (gnus-unbuttonized-mime-type-p (car handle))
7028 (let ((gnus-mime-security-button-line-format
7029 gnus-mime-security-button-end-line-format))
7030 (gnus-insert-mime-security-button handle)))
7031 (mm-set-handle-multipart-parameter
7033 (cons (set-marker (make-marker) (point-min))
7034 (set-marker (make-marker) (point-max))))))
7040 (run-hooks 'gnus-art-load-hook)
7042 ;;; gnus-art.el ends here