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.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
111 (concat "^" header ":"))
112 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
113 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
114 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
115 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
116 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
117 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
118 "X-Attribution" "X-Originating-IP" "Delivered-To"
119 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
120 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
121 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
122 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
123 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
124 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
125 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
126 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
127 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
128 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
129 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
130 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
131 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
132 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
133 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
134 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
135 "List-[A-Za-z]+" "X-Listprocessor-Version"
136 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
137 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
138 "X-Received" "Content-length" "X-precedence"
139 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
140 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
141 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
142 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
143 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
144 "X-Content-length" "X-Posting-Agent" "Original-Received"
145 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
146 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
147 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
148 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
149 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
150 "*All headers that start with this regexp will be hidden.
151 This variable can also be a list of regexps of headers to be ignored.
152 If `gnus-visible-headers' is non-nil, this variable will be ignored."
153 :type '(choice :custom-show nil
156 :group 'gnus-article-hiding)
158 (defcustom gnus-visible-headers
159 "^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:"
160 "*All headers that do not match this regexp will be hidden.
161 This variable can also be a list of regexp of headers to remain visible.
162 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
163 :type '(repeat :value-to-internal (lambda (widget value)
164 (custom-split-regexp-maybe value))
165 :match (lambda (widget value)
167 (widget-editable-list-match widget value)))
169 :group 'gnus-article-hiding)
171 (defcustom gnus-sorted-header-list
172 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
173 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
174 "*This variable is a list of regular expressions.
175 If it is non-nil, headers that match the regular expressions will
176 be placed first in the article buffer in the sequence specified by
178 :type '(repeat regexp)
179 :group 'gnus-article-hiding)
181 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
182 "Headers that are only to be displayed if they have interesting data.
183 Possible values in this list are:
185 'empty Headers with no content.
186 'newsgroups Newsgroup identical to Gnus group.
187 'to-address To identical to To-address.
188 'to-list To identical to To-list.
189 'cc-list CC identical to To-list.
190 'followup-to Followup-to identical to Newsgroups.
191 'reply-to Reply-to identical to From.
192 'date Date less than four days old.
193 'long-to To and/or Cc longer than 1024 characters.
194 'many-to Multiple To and/or Cc."
195 :type '(set (const :tag "Headers with no content." empty)
196 (const :tag "Newsgroups identical to Gnus group." newsgroups)
197 (const :tag "To identical to To-address." to-address)
198 (const :tag "To identical to To-list." to-list)
199 (const :tag "CC identical to To-list." cc-list)
200 (const :tag "Followup-to identical to Newsgroups." followup-to)
201 (const :tag "Reply-to identical to From." reply-to)
202 (const :tag "Date less than four days old." date)
203 (const :tag "To and/or Cc longer than 1024 characters." long-to)
204 (const :tag "Multiple To and/or Cc headers." many-to))
205 :group 'gnus-article-hiding)
207 (defcustom gnus-article-skip-boring nil
208 "Skip over text that is not worth reading.
209 By default, if you set this t, then Gnus will display citations and
210 signatures, but will never scroll down to show you a page consisting
211 only of boring text. Boring text is controlled by
212 `gnus-article-boring-faces'."
214 :group 'gnus-article-hiding)
216 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
217 "Regexp matching signature separator.
218 This can also be a list of regexps. In that case, it will be checked
219 from head to tail looking for a separator. Searches will be done from
220 the end of the buffer."
221 :type '(repeat string)
222 :group 'gnus-article-signature)
224 (defcustom gnus-signature-limit nil
225 "Provide a limit to what is considered a signature.
226 If it is a number, no signature may not be longer (in characters) than
227 that number. If it is a floating point number, no signature may be
228 longer (in lines) than that number. If it is a function, the function
229 will be called without any parameters, and if it returns nil, there is
230 no signature in the buffer. If it is a string, it will be used as a
231 regexp. If it matches, the text in question is not a signature."
232 :type '(choice (integer :value 200)
234 (function :value fun)
235 (regexp :value ".*"))
236 :group 'gnus-article-signature)
238 (defcustom gnus-hidden-properties '(invisible t intangible t)
239 "Property list to use for hiding text."
241 :group 'gnus-article-hiding)
243 ;; Fixme: This isn't the right thing for mixed graphical and and
244 ;; non-graphical frames in a session.
245 (defcustom gnus-article-x-face-command
246 (if (featurep 'xemacs)
247 (if (or (gnus-image-type-available-p 'xface)
248 (gnus-image-type-available-p 'pbm))
249 'gnus-display-x-face-in-from
250 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
251 (if (gnus-image-type-available-p 'pbm)
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
255 "*String or function to be executed to display an X-Face header.
256 If it is a string, the command will be executed in a sub-shell
257 asynchronously. The compressed face will be piped to this command."
258 :type `(choice string
259 (function-item gnus-display-x-face-in-from)
263 :group 'gnus-article-washing)
265 (defcustom gnus-article-x-face-too-ugly nil
266 "Regexp matching posters whose face shouldn't be shown automatically."
267 :type '(choice regexp (const nil))
268 :group 'gnus-article-washing)
270 (defcustom gnus-article-banner-alist nil
271 "Banner alist for stripping.
273 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
275 :type '(repeat (cons symbol regexp))
276 :group 'gnus-article-washing)
278 (gnus-define-group-parameter
281 "Alist of regexps (to match group names) and banner."
282 :variable-group gnus-article-washing
284 '(choice :tag "Banner"
286 (const :tag "Remove signature" signature)
287 (symbol :tag "Item in `gnus-article-banner-alist'" none)
289 (const :tag "None" nil))
291 "If non-nil, specify how to remove `banners' from articles.
293 Symbol `signature' means to remove signatures delimited by
294 `gnus-signature-separator'. Any other symbol is used to look up a
295 regular expression to match the banner in `gnus-article-banner-alist'.
296 A string is used as a regular expression to match the banner
299 (defcustom gnus-article-address-banner-alist nil
300 "Alist of mail addresses and banners.
301 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
302 to match a mail address in the From: header, BANNER is one of a symbol
303 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
304 If ADDRESS matches author's mail address, it will remove things like
305 advertisements. For example:
307 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
311 (regexp :tag "Address")
312 (choice :tag "Banner" :value nil
313 (const :tag "Remove signature" signature)
314 (symbol :tag "Item in `gnus-article-banner-alist'" none)
316 (const :tag "None" nil))))
317 :group 'gnus-article-washing)
319 (defcustom gnus-emphasis-alist
321 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
326 ("_/" "/_" underline-italic)
327 ("_\\*" "\\*_" underline-bold)
328 ("\\*/" "/\\*" bold-italic)
329 ("_\\*/" "/\\*_" underline-bold-italic))))
333 (format format (car spec) (cadr spec))
334 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
336 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
337 2 3 gnus-emphasis-strikethru)
338 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
339 2 3 gnus-emphasis-underline)))
340 "*Alist that says how to fontify certain phrases.
341 Each item looks like this:
343 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
345 The first element is a regular expression to be matched. The second
346 is a number that says what regular expression grouping used to find
347 the entire emphasized word. The third is a number that says what
348 regexp grouping should be displayed and highlighted. The fourth
349 is the face used for highlighting."
350 :type '(repeat (list :value ("" 0 0 default)
352 (integer :tag "Match group")
353 (integer :tag "Emphasize group")
355 :group 'gnus-article-emphasis)
357 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
358 "A regexp to describe whitespace which should not be emphasized.
359 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
360 The former avoids underlining of leading and trailing whitespace,
361 and the latter avoids underlining any whitespace at all."
363 :group 'gnus-article-emphasis
366 (defface gnus-emphasis-bold '((t (:bold t)))
367 "Face used for displaying strong emphasized text (*word*)."
368 :group 'gnus-article-emphasis)
370 (defface gnus-emphasis-italic '((t (:italic t)))
371 "Face used for displaying italic emphasized text (/word/)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-underline '((t (:underline t)))
375 "Face used for displaying underlined emphasized text (_word_)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
379 "Face used for displaying underlined bold emphasized text (_*word*_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
383 "Face used for displaying underlined italic emphasized text (_/word/_)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
387 "Face used for displaying bold italic emphasized text (/*word*/)."
388 :group 'gnus-article-emphasis)
390 (defface gnus-emphasis-underline-bold-italic
391 '((t (:bold t :italic t :underline t)))
392 "Face used for displaying underlined bold italic emphasized text.
393 Example: (_/*word*/_)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
397 "Face used for displaying strike-through text (-word-)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-highlight-words
401 '((t (:background "black" :foreground "yellow")))
402 "Face used for displaying highlighted words."
403 :group 'gnus-article-emphasis)
405 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
406 "Format for display of Date headers in article bodies.
407 See `format-time-string' for the possible values.
409 The variable can also be function, which should return a complete Date
410 header. The function is called with one argument, the time, which can
411 be fed to `format-time-string'."
412 :type '(choice string symbol)
413 :link '(custom-manual "(gnus)Article Date")
414 :group 'gnus-article-washing)
417 (autoload 'mail-extract-address-components "mail-extr"))
419 (defcustom gnus-save-all-headers t
420 "*If non-nil, don't remove any headers before saving."
421 :group 'gnus-article-saving
424 (defcustom gnus-prompt-before-saving 'always
425 "*This variable says how much prompting is to be done when saving articles.
426 If it is nil, no prompting will be done, and the articles will be
427 saved to the default files. If this variable is `always', each and
428 every article that is saved will be preceded by a prompt, even when
429 saving large batches of articles. If this variable is neither nil not
430 `always', there the user will be prompted once for a file name for
431 each invocation of the saving commands."
432 :group 'gnus-article-saving
433 :type '(choice (item always)
434 (item :tag "never" nil)
435 (sexp :tag "once" :format "%t\n" :value t)))
437 (defcustom gnus-saved-headers gnus-visible-headers
438 "Headers to keep if `gnus-save-all-headers' is nil.
439 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
440 If that variable is nil, however, all headers that match this regexp
441 will be kept while the rest will be deleted before saving."
442 :group 'gnus-article-saving
445 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
446 "A function to save articles in your favourite format.
447 The function must be interactively callable (in other words, it must
448 be an Emacs command).
450 Gnus provides the following functions:
452 * gnus-summary-save-in-rmail (Rmail format)
453 * gnus-summary-save-in-mail (Unix mail format)
454 * gnus-summary-save-in-folder (MH folder)
455 * gnus-summary-save-in-file (article format)
456 * gnus-summary-save-body-in-file (article body)
457 * gnus-summary-save-in-vm (use VM's folder format)
458 * gnus-summary-write-to-file (article format -- overwrite)."
459 :group 'gnus-article-saving
460 :type '(radio (function-item gnus-summary-save-in-rmail)
461 (function-item gnus-summary-save-in-mail)
462 (function-item gnus-summary-save-in-folder)
463 (function-item gnus-summary-save-in-file)
464 (function-item gnus-summary-save-body-in-file)
465 (function-item gnus-summary-save-in-vm)
466 (function-item gnus-summary-write-to-file)))
468 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
469 "A function generating a file name to save articles in Rmail format.
470 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
471 :group 'gnus-article-saving
474 (defcustom gnus-mail-save-name 'gnus-plain-save-name
475 "A function generating a file name to save articles in Unix mail format.
476 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
477 :group 'gnus-article-saving
480 (defcustom gnus-folder-save-name 'gnus-folder-save-name
481 "A function generating a file name to save articles in MH folder.
482 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
483 :group 'gnus-article-saving
486 (defcustom gnus-file-save-name 'gnus-numeric-save-name
487 "A function generating a file name to save articles in article format.
488 The function is called with NEWSGROUP, HEADERS, and optional
490 :group 'gnus-article-saving
493 (defcustom gnus-split-methods
494 '((gnus-article-archive-name)
495 (gnus-article-nndoc-name))
496 "*Variable used to suggest where articles are to be saved.
497 For instance, if you would like to save articles related to Gnus in
498 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
499 you could set this variable to something like:
501 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
502 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
504 This variable is an alist where the where the key is the match and the
505 value is a list of possible files to save in if the match is non-nil.
507 If the match is a string, it is used as a regexp match on the
508 article. If the match is a symbol, that symbol will be funcalled
509 from the buffer of the article to be saved with the newsgroup as the
510 parameter. If it is a list, it will be evaled in the same buffer.
512 If this form or function returns a string, this string will be used as
513 a possible file name; and if it returns a non-nil list, that list will
514 be used as possible file names."
515 :group 'gnus-article-saving
516 :type '(repeat (choice (list :value (fun) function)
517 (cons :value ("" "") regexp (repeat string))
520 (defcustom gnus-page-delimiter "^\^L"
521 "*Regexp describing what to use as article page delimiters.
522 The default value is \"^\^L\", which is a form linefeed at the
523 beginning of a line."
525 :group 'gnus-article-various)
527 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
528 "*The format specification for the article mode line.
529 See `gnus-summary-mode-line-format' for a closer description.
531 The following additional specs are available:
533 %w The article washing status.
534 %m The number of MIME parts in the article."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-mode-hook nil
539 "*A hook for Gnus article mode."
541 :group 'gnus-article-various)
543 (when (featurep 'xemacs)
544 ;; Extracted from gnus-xmas-define in order to preserve user settings
545 (when (fboundp 'turn-off-scroll-in-place)
546 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
547 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
548 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
550 (defcustom gnus-article-menu-hook nil
551 "*Hook run after the creation of the article mode menu."
553 :group 'gnus-article-various)
555 (defcustom gnus-article-prepare-hook nil
556 "*A hook called after an article has been prepared in the article buffer."
558 :group 'gnus-article-various)
560 (defvar gnus-article-hide-pgp-hook nil)
561 (make-obsolete-variable 'gnus-article-hide-pgp-hook
562 "This variable is obsolete in Gnus 5.10.")
564 (defcustom gnus-article-button-face 'bold
565 "Face used for highlighting buttons in the article buffer.
567 An article button is a piece of text that you can activate by pressing
568 `RET' or `mouse-2' above it."
570 :group 'gnus-article-buttons)
572 (defcustom gnus-article-mouse-face 'highlight
573 "Face used for mouse highlighting in the article buffer.
575 Article buttons will be displayed in this face when the cursor is
578 :group 'gnus-article-buttons)
580 (defcustom gnus-signature-face 'gnus-signature-face
581 "Face used for highlighting a signature in the article buffer.
582 Obsolete; use the face `gnus-signature-face' for customizations instead."
584 :group 'gnus-article-highlight
585 :group 'gnus-article-signature)
587 (defface gnus-signature-face
590 "Face used for highlighting a signature in the article buffer."
591 :group 'gnus-article-highlight
592 :group 'gnus-article-signature)
594 (defface gnus-header-from-face
597 (:foreground "spring green"))
600 (:foreground "red3"))
603 "Face used for displaying from headers."
604 :group 'gnus-article-headers
605 :group 'gnus-article-highlight)
607 (defface gnus-header-subject-face
610 (:foreground "SeaGreen3"))
613 (:foreground "red4"))
615 (:bold t :italic t)))
616 "Face used for displaying subject headers."
617 :group 'gnus-article-headers
618 :group 'gnus-article-highlight)
620 (defface gnus-header-newsgroups-face
623 (:foreground "yellow" :italic t))
626 (:foreground "MidnightBlue" :italic t))
629 "Face used for displaying newsgroups headers."
630 :group 'gnus-article-headers
631 :group 'gnus-article-highlight)
633 (defface gnus-header-name-face
636 (:foreground "SeaGreen"))
639 (:foreground "maroon"))
642 "Face used for displaying header names."
643 :group 'gnus-article-headers
644 :group 'gnus-article-highlight)
646 (defface gnus-header-content-face
649 (:foreground "forest green" :italic t))
652 (:foreground "indianred4" :italic t))
654 (:italic t))) "Face used for displaying header content."
655 :group 'gnus-article-headers
656 :group 'gnus-article-highlight)
658 (defcustom gnus-header-face-alist
659 '(("From" nil gnus-header-from-face)
660 ("Subject" nil gnus-header-subject-face)
661 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
662 ("" gnus-header-name-face gnus-header-content-face))
663 "*Controls highlighting of article header.
665 An alist of the form (HEADER NAME CONTENT).
667 HEADER is a regular expression which should match the name of an
668 header header and NAME and CONTENT are either face names or nil.
670 The name of each header field will be displayed using the face
671 specified by the first element in the list where HEADER match the
672 header name and NAME is non-nil. Similarly, the content will be
673 displayed by the first non-nil matching CONTENT face."
674 :group 'gnus-article-headers
675 :group 'gnus-article-highlight
676 :type '(repeat (list (regexp :tag "Header")
678 (item :tag "skip" nil)
679 (face :value default))
680 (choice :tag "Content"
681 (item :tag "skip" nil)
682 (face :value default)))))
684 (defcustom gnus-article-decode-hook
685 '(article-decode-charset article-decode-encoded-words
686 article-decode-group-name article-decode-idna-rhs)
687 "*Hook run to decode charsets in articles."
688 :group 'gnus-article-headers
691 (defcustom gnus-display-mime-function 'gnus-display-mime
692 "Function to display MIME articles."
693 :group 'gnus-article-mime
696 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
697 "Function used to decode headers.")
699 (defvar gnus-article-dumbquotes-map
719 "Table for MS-to-Latin1 translation.")
721 (defcustom gnus-ignored-mime-types nil
722 "List of MIME types that should be ignored by Gnus."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
728 "List of MIME types that should not be given buttons when rendered inline.
729 See also `gnus-buttonized-mime-types' which may override this variable.
730 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
732 :group 'gnus-article-mime
733 :type '(repeat regexp))
735 (defcustom gnus-buttonized-mime-types nil
736 "List of MIME types that should be given buttons when rendered inline.
737 If set, this variable overrides `gnus-unbuttonized-mime-types'.
738 To see e.g. security buttons you could set this to
739 `(\"multipart/signed\")'.
740 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
742 :group 'gnus-article-mime
743 :type '(repeat regexp))
745 (defcustom gnus-inhibit-mime-unbuttonizing nil
746 "If non-nil, all MIME parts get buttons.
747 When nil (the default value), then some MIME parts do not get buttons,
748 as described by the variables `gnus-buttonized-mime-types' and
749 `gnus-unbuttonized-mime-types'."
753 (defcustom gnus-body-boundary-delimiter "_"
754 "String used to delimit header and body.
755 This variable is used by `gnus-article-treat-body-boundary' which can
756 be controlled by `gnus-treat-body-boundary'."
757 :group 'gnus-article-various
758 :type '(choice (item :tag "None" :value nil)
761 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
762 "Defines the location of the faces database.
763 For information on obtaining this database of pretty pictures, please
764 see http://www.cs.indiana.edu/picons/ftp/index.html"
765 :type '(repeat directory)
766 :link '(url-link :tag "download"
767 "http://www.cs.indiana.edu/picons/ftp/index.html")
768 :link '(custom-manual "(gnus)Picons")
771 (defun gnus-picons-installed-p ()
772 "Say whether picons are installed on your machine."
773 (let ((installed nil))
774 (dolist (database gnus-picon-databases)
775 (when (file-exists-p database)
779 (defcustom gnus-article-mime-part-function nil
780 "Function called with a MIME handle as the argument.
781 This is meant for people who want to do something automatic based
782 on parts -- for instance, adding Vcard info to a database."
783 :group 'gnus-article-mime
786 (defcustom gnus-mime-multipart-functions nil
787 "An alist of MIME types to functions to display them."
789 :group 'gnus-article-mime
792 (defcustom gnus-article-date-lapsed-new-header nil
793 "Whether the X-Sent and Date headers can coexist.
794 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
795 either replace the old \"Date:\" header (if this variable is nil), or
796 be added below it (otherwise)."
798 :group 'gnus-article-headers
801 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
802 "Function called with a MIME handle as the argument.
803 This is meant for people who want to view first matched part.
804 For `undisplayed-alternative' (default), the first undisplayed
805 part or alternative part is used. For `undisplayed', the first
806 undisplayed part is used. For a function, the first part which
807 the function return t is used. For nil, the first part is
810 :group 'gnus-article-mime
812 (item :tag "first" :value nil)
813 (item :tag "undisplayed" :value undisplayed)
814 (item :tag "undisplayed or alternative"
815 :value undisplayed-alternative)
818 (defcustom gnus-mime-action-alist
819 '(("save to file" . gnus-mime-save-part)
820 ("save and strip" . gnus-mime-save-part-and-strip)
821 ("delete part" . gnus-mime-delete-part)
822 ("display as text" . gnus-mime-inline-part)
823 ("view the part" . gnus-mime-view-part)
824 ("pipe to command" . gnus-mime-pipe-part)
825 ("toggle display" . gnus-article-press-button)
826 ("toggle display" . gnus-article-view-part-as-charset)
827 ("view as type" . gnus-mime-view-part-as-type)
828 ("view internally" . gnus-mime-view-part-internally)
829 ("view externally" . gnus-mime-view-part-externally))
830 "An alist of actions that run on the MIME attachment."
831 :group 'gnus-article-mime
832 :type '(repeat (cons (string :tag "name")
836 ;;; The treatment variables
839 (defvar gnus-part-display-hook nil
840 "Hook called on parts that are to receive treatment.")
842 (defvar gnus-article-treat-custom
843 '(choice (const :tag "Off" nil)
845 (const :tag "Header" head)
846 (const :tag "Last" last)
847 (integer :tag "Less")
848 (repeat :tag "Groups" regexp)
849 (sexp :tag "Predicate")))
851 (defvar gnus-article-treat-head-custom
852 '(choice (const :tag "Off" nil)
853 (const :tag "Header" head)))
855 (defvar gnus-article-treat-types '("text/plain")
858 (defvar gnus-inhibit-treatment nil
859 "Whether to inhibit treatment.")
861 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
862 "Highlight the signature.
863 Valid values are nil, t, `head', `last', an integer or a predicate.
864 See Info node `(gnus)Customizing Articles'."
865 :group 'gnus-article-treat
866 :link '(custom-manual "(gnus)Customizing Articles")
867 :type gnus-article-treat-custom)
868 (put 'gnus-treat-highlight-signature 'highlight t)
870 (defcustom gnus-treat-buttonize 100000
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See Info node `(gnus)Customizing Articles'."
874 :group 'gnus-article-treat
875 :link '(custom-manual "(gnus)Customizing Articles")
876 :type gnus-article-treat-custom)
877 (put 'gnus-treat-buttonize 'highlight t)
879 (defcustom gnus-treat-buttonize-head 'head
880 "Add buttons to the head.
881 Valid values are nil, t, `head', `last', an integer or a predicate.
882 See Info node `(gnus)Customizing Articles' for details."
883 :group 'gnus-article-treat
884 :link '(custom-manual "(gnus)Customizing Articles")
885 :type gnus-article-treat-head-custom)
886 (put 'gnus-treat-buttonize-head 'highlight t)
888 (defcustom gnus-treat-emphasize
889 (and (or window-system
891 (>= (string-to-number emacs-version) 21))
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See Info node `(gnus)Customizing Articles' for details."
896 :group 'gnus-article-treat
897 :link '(custom-manual "(gnus)Customizing Articles")
898 :type gnus-article-treat-custom)
899 (put 'gnus-treat-emphasize 'highlight t)
901 (defcustom gnus-treat-strip-cr nil
902 "Remove carriage returns.
903 Valid values are nil, t, `head', `last', an integer or a predicate.
904 See Info node `(gnus)Customizing Articles' for details."
905 :group 'gnus-article-treat
906 :link '(custom-manual "(gnus)Customizing Articles")
907 :type gnus-article-treat-custom)
909 (defcustom gnus-treat-unsplit-urls nil
910 "Remove newlines from within URLs.
911 Valid values are nil, t, `head', `last', an integer or a predicate.
912 See Info node `(gnus)Customizing Articles' for details."
913 :group 'gnus-article-treat
914 :link '(custom-manual "(gnus)Customizing Articles")
915 :type gnus-article-treat-custom)
917 (defcustom gnus-treat-leading-whitespace nil
918 "Remove leading whitespace in headers.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See Info node `(gnus)Customizing Articles' for details."
921 :group 'gnus-article-treat
922 :link '(custom-manual "(gnus)Customizing Articles")
923 :type gnus-article-treat-custom)
925 (defcustom gnus-treat-hide-headers 'head
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :link '(custom-manual "(gnus)Customizing Articles")
931 :type gnus-article-treat-head-custom)
933 (defcustom gnus-treat-hide-boring-headers nil
934 "Hide boring headers.
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
937 :group 'gnus-article-treat
938 :link '(custom-manual "(gnus)Customizing Articles")
939 :type gnus-article-treat-head-custom)
941 (defcustom gnus-treat-hide-signature nil
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See Info node `(gnus)Customizing Articles' for details."
945 :group 'gnus-article-treat
946 :link '(custom-manual "(gnus)Customizing Articles")
947 :type gnus-article-treat-custom)
949 (defcustom gnus-treat-fill-article nil
951 Valid values are nil, t, `head', `last', an integer or a predicate.
952 See Info node `(gnus)Customizing Articles' for details."
953 :group 'gnus-article-treat
954 :link '(custom-manual "(gnus)Customizing Articles")
955 :type gnus-article-treat-custom)
957 (defcustom gnus-treat-hide-citation nil
959 Valid values are nil, t, `head', `last', an integer or a predicate.
960 See Info node `(gnus)Customizing Articles' for details."
961 :group 'gnus-article-treat
962 :link '(custom-manual "(gnus)Customizing Articles")
963 :type gnus-article-treat-custom)
965 (defcustom gnus-treat-hide-citation-maybe nil
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See Info node `(gnus)Customizing Articles' for details."
969 :group 'gnus-article-treat
970 :link '(custom-manual "(gnus)Customizing Articles")
971 :type gnus-article-treat-custom)
973 (defcustom gnus-treat-strip-list-identifiers 'head
974 "Strip list identifiers from `gnus-list-identifiers`.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See Info node `(gnus)Customizing Articles' for details."
978 :group 'gnus-article-treat
979 :link '(custom-manual "(gnus)Customizing Articles")
980 :type gnus-article-treat-custom)
982 (make-obsolete-variable 'gnus-treat-strip-pgp
983 "This option is obsolete in Gnus 5.10.")
985 (defcustom gnus-treat-strip-pem nil
986 "Strip PEM signatures.
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989 :group 'gnus-article-treat
990 :link '(custom-manual "(gnus)Customizing Articles")
991 :type gnus-article-treat-custom)
993 (defcustom gnus-treat-strip-banner t
994 "Strip banners from articles.
995 The banner to be stripped is specified in the `banner' group parameter.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See Info node `(gnus)Customizing Articles' for details."
998 :group 'gnus-article-treat
999 :link '(custom-manual "(gnus)Customizing Articles")
1000 :type gnus-article-treat-custom)
1002 (defcustom gnus-treat-highlight-headers 'head
1003 "Highlight the headers.
1004 Valid values are nil, t, `head', `last', an integer or a predicate.
1005 See Info node `(gnus)Customizing Articles' for details."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-head-custom)
1009 (put 'gnus-treat-highlight-headers 'highlight t)
1011 (defcustom gnus-treat-highlight-citation t
1012 "Highlight cited text.
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See Info node `(gnus)Customizing Articles' for details."
1015 :group 'gnus-article-treat
1016 :link '(custom-manual "(gnus)Customizing Articles")
1017 :type gnus-article-treat-custom)
1018 (put 'gnus-treat-highlight-citation 'highlight t)
1020 (defcustom gnus-treat-date-ut nil
1021 "Display the Date in UT (GMT).
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-head-custom)
1028 (defcustom gnus-treat-date-local nil
1029 "Display the Date in the local timezone.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-head-custom)
1036 (defcustom gnus-treat-date-english nil
1037 "Display the Date in a format that can be read aloud in English.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :link '(custom-manual "(gnus)Customizing Articles")
1042 :type gnus-article-treat-head-custom)
1044 (defcustom gnus-treat-date-lapsed nil
1045 "Display the Date header in a way that says how much time has elapsed.
1046 Valid values are nil, t, `head', `last', an integer or a predicate.
1047 See Info node `(gnus)Customizing Articles' for details."
1048 :group 'gnus-article-treat
1049 :link '(custom-manual "(gnus)Customizing Articles")
1050 :type gnus-article-treat-head-custom)
1052 (defcustom gnus-treat-date-original nil
1053 "Display the date in the original timezone.
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :link '(custom-manual "(gnus)Customizing Articles")
1058 :type gnus-article-treat-head-custom)
1060 (defcustom gnus-treat-date-iso8601 nil
1061 "Display the date in the ISO8601 format.
1062 Valid values are nil, t, `head', `last', an integer or a predicate.
1063 See Info node `(gnus)Customizing Articles' for details."
1065 :group 'gnus-article-treat
1066 :link '(custom-manual "(gnus)Customizing Articles")
1067 :type gnus-article-treat-head-custom)
1069 (defcustom gnus-treat-date-user-defined nil
1070 "Display the date in a user-defined format.
1071 The format is defined by the `gnus-article-time-format' variable.
1072 Valid values are nil, t, `head', `last', an integer or a predicate.
1073 See Info node `(gnus)Customizing Articles' for details."
1074 :group 'gnus-article-treat
1075 :link '(custom-manual "(gnus)Customizing Articles")
1076 :type gnus-article-treat-head-custom)
1078 (defcustom gnus-treat-strip-headers-in-body t
1079 "Strip the X-No-Archive header line from the beginning of the body.
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-custom)
1087 (defcustom gnus-treat-strip-trailing-blank-lines nil
1088 "Strip trailing blank lines.
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-custom)
1095 (defcustom gnus-treat-strip-leading-blank-lines nil
1096 "Strip leading blank lines.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-custom)
1103 (defcustom gnus-treat-strip-multiple-blank-lines nil
1104 "Strip multiple blank lines.
1105 Valid values are nil, t, `head', `last', an integer or a predicate.
1106 See Info node `(gnus)Customizing Articles' for details."
1107 :group 'gnus-article-treat
1108 :link '(custom-manual "(gnus)Customizing Articles")
1109 :type gnus-article-treat-custom)
1111 (defcustom gnus-treat-unfold-headers 'head
1112 "Unfold folded header lines.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1119 (defcustom gnus-treat-fold-headers nil
1121 Valid values are nil, t, `head', `last', an integer or a predicate.
1122 See Info node `(gnus)Customizing Articles' for details."
1123 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-custom)
1127 (defcustom gnus-treat-fold-newsgroups 'head
1128 "Fold the Newsgroups and Followup-To headers.
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See Info node `(gnus)Customizing Articles' for details."
1131 :group 'gnus-article-treat
1132 :link '(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom)
1135 (defcustom gnus-treat-overstrike t
1136 "Treat overstrike highlighting.
1137 Valid values are nil, t, `head', `last', an integer or a predicate.
1138 See Info node `(gnus)Customizing Articles' for details."
1139 :group 'gnus-article-treat
1140 :link '(custom-manual "(gnus)Customizing Articles")
1141 :type gnus-article-treat-custom)
1142 (put 'gnus-treat-overstrike 'highlight t)
1144 (defcustom gnus-treat-display-xface
1145 (and (not noninteractive)
1146 (or (and (fboundp 'image-type-available-p)
1147 (image-type-available-p 'xbm)
1148 (string-match "^0x" (shell-command-to-string "uncompface")))
1149 (and (featurep 'xemacs)
1152 "Display X-Face headers.
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' and Info node
1155 `(gnus)X-Face' for details."
1156 :group 'gnus-article-treat
1158 :link '(custom-manual "(gnus)Customizing Articles")
1159 :link '(custom-manual "(gnus)X-Face")
1160 :type gnus-article-treat-head-custom)
1161 (put 'gnus-treat-display-xface 'highlight t)
1163 (defcustom gnus-treat-display-face
1164 (and (not noninteractive)
1165 (or (and (fboundp 'image-type-available-p)
1166 (image-type-available-p 'png))
1167 (and (featurep 'xemacs)
1170 "Display Face headers.
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' and Info node
1173 `(gnus)X-Face' for details."
1174 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :link '(custom-manual "(gnus)X-Face")
1178 :type gnus-article-treat-head-custom)
1179 (put 'gnus-treat-display-xface 'highlight t)
1181 (defcustom gnus-treat-display-smileys
1182 (if (or (and (featurep 'xemacs)
1184 (and (fboundp 'image-type-available-p)
1185 (image-type-available-p 'pbm)))
1188 Valid values are nil, t, `head', `last', an integer or a predicate.
1189 See Info node `(gnus)Customizing Articles' and Info node
1190 `(gnus)Smileys' for details."
1191 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :link '(custom-manual "(gnus)Smileys")
1195 :type gnus-article-treat-custom)
1196 (put 'gnus-treat-display-smileys 'highlight t)
1198 (defcustom gnus-treat-from-picon
1199 (if (and (gnus-image-type-available-p 'xpm)
1200 (gnus-picons-installed-p))
1202 "Display picons in the From header.
1203 Valid values are nil, t, `head', `last', an integer or a predicate.
1204 See Info node `(gnus)Customizing Articles' and Info node
1205 `(gnus)Picons' for details."
1206 :group 'gnus-article-treat
1208 :link '(custom-manual "(gnus)Customizing Articles")
1209 :link '(custom-manual "(gnus)Picons")
1210 :type gnus-article-treat-head-custom)
1211 (put 'gnus-treat-from-picon 'highlight t)
1213 (defcustom gnus-treat-mail-picon
1214 (if (and (gnus-image-type-available-p 'xpm)
1215 (gnus-picons-installed-p))
1217 "Display picons in To and Cc headers.
1218 Valid values are nil, t, `head', `last', an integer or a predicate.
1219 See Info node `(gnus)Customizing Articles' and Info node
1220 `(gnus)Picons' for details."
1221 :group 'gnus-article-treat
1223 :link '(custom-manual "(gnus)Customizing Articles")
1224 :link '(custom-manual "(gnus)Picons")
1225 :type gnus-article-treat-head-custom)
1226 (put 'gnus-treat-mail-picon 'highlight t)
1228 (defcustom gnus-treat-newsgroups-picon
1229 (if (and (gnus-image-type-available-p 'xpm)
1230 (gnus-picons-installed-p))
1232 "Display picons in the Newsgroups and Followup-To headers.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' and Info node
1235 `(gnus)Picons' for details."
1236 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :link '(custom-manual "(gnus)Picons")
1240 :type gnus-article-treat-head-custom)
1241 (put 'gnus-treat-newsgroups-picon 'highlight t)
1243 (defcustom gnus-treat-body-boundary
1244 (if (or gnus-treat-newsgroups-picon
1245 gnus-treat-mail-picon
1246 gnus-treat-from-picon)
1248 "Draw a boundary at the end of the headers.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' for details."
1252 :group 'gnus-article-treat
1253 :link '(custom-manual "(gnus)Customizing Articles")
1254 :type gnus-article-treat-custom)
1256 (defcustom gnus-treat-capitalize-sentences nil
1257 "Capitalize sentence-starting words.
1258 Valid values are nil, t, `head', `last', an integer or a predicate.
1259 See Info node `(gnus)Customizing Articles' for details."
1261 :group 'gnus-article-treat
1262 :link '(custom-manual "(gnus)Customizing Articles")
1263 :type gnus-article-treat-custom)
1265 (defcustom gnus-treat-wash-html nil
1267 Valid values are nil, t, `head', `last', an integer or a predicate.
1268 See Info node `(gnus)Customizing Articles' for details."
1269 :group 'gnus-article-treat
1270 :link '(custom-manual "(gnus)Customizing Articles")
1271 :type gnus-article-treat-custom)
1273 (defcustom gnus-treat-fill-long-lines nil
1275 Valid values are nil, t, `head', `last', an integer or a predicate.
1276 See Info node `(gnus)Customizing Articles' for details."
1277 :group 'gnus-article-treat
1278 :link '(custom-manual "(gnus)Customizing Articles")
1279 :type gnus-article-treat-custom)
1281 (defcustom gnus-treat-play-sounds nil
1283 Valid values are nil, t, `head', `last', an integer or a predicate.
1284 See Info node `(gnus)Customizing Articles' for details."
1286 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1290 (defcustom gnus-treat-translate nil
1291 "Translate articles from one language to another.
1292 Valid values are nil, t, `head', `last', an integer or a predicate.
1293 See Info node `(gnus)Customizing Articles' for details."
1295 :group 'gnus-article-treat
1296 :link '(custom-manual "(gnus)Customizing Articles")
1297 :type gnus-article-treat-custom)
1299 (defcustom gnus-treat-x-pgp-sig nil
1301 To automatically treat X-PGP-Sig, set it to head.
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' for details."
1304 :group 'gnus-article-treat
1305 :group 'mime-security
1306 :link '(custom-manual "(gnus)Customizing Articles")
1307 :type gnus-article-treat-custom)
1309 (defvar gnus-article-encrypt-protocol-alist
1310 '(("PGP" . mml2015-self-encrypt)))
1312 ;; Set to nil if more than one protocol added to
1313 ;; gnus-article-encrypt-protocol-alist.
1314 (defcustom gnus-article-encrypt-protocol "PGP"
1315 "The protocol used for encrypt articles.
1316 It is a string, such as \"PGP\". If nil, ask user."
1318 :group 'mime-security)
1320 (defvar gnus-article-wash-function nil
1321 "Function used for converting HTML into text.")
1323 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1324 (fboundp 'coding-system-p)
1325 (coding-system-p 'utf-8))
1326 "Whether IDNA decoding of headers is used when viewing messages.
1327 This requires GNU Libidn, and by default only enabled if it is found."
1328 :group 'gnus-article-headers
1331 ;;; Internal variables
1333 (defvar gnus-english-month-names
1334 '("January" "February" "March" "April" "May" "June" "July" "August"
1335 "September" "October" "November" "December"))
1337 (defvar article-goto-body-goes-to-point-min-p nil)
1338 (defvar gnus-article-wash-types nil)
1339 (defvar gnus-article-emphasis-alist nil)
1340 (defvar gnus-article-image-alist nil)
1342 (defvar gnus-article-mime-handle-alist-1 nil)
1343 (defvar gnus-treatment-function-alist
1344 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1345 (gnus-treat-strip-banner gnus-article-strip-banner)
1346 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1347 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1348 (gnus-treat-buttonize gnus-article-add-buttons)
1349 (gnus-treat-fill-article gnus-article-fill-cited-article)
1350 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1351 (gnus-treat-strip-cr gnus-article-remove-cr)
1352 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1353 (gnus-treat-date-ut gnus-article-date-ut)
1354 (gnus-treat-date-local gnus-article-date-local)
1355 (gnus-treat-date-english gnus-article-date-english)
1356 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1357 (gnus-treat-date-original gnus-article-date-original)
1358 (gnus-treat-date-user-defined gnus-article-date-user)
1359 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1360 (gnus-treat-display-xface gnus-article-display-x-face)
1361 (gnus-treat-display-face gnus-article-display-face)
1362 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1363 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1364 (gnus-treat-hide-signature gnus-article-hide-signature)
1365 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1366 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1367 (gnus-treat-strip-pem gnus-article-hide-pem)
1368 (gnus-treat-from-picon gnus-treat-from-picon)
1369 (gnus-treat-mail-picon gnus-treat-mail-picon)
1370 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1371 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1372 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1373 (gnus-treat-strip-trailing-blank-lines
1374 gnus-article-remove-trailing-blank-lines)
1375 (gnus-treat-strip-leading-blank-lines
1376 gnus-article-strip-leading-blank-lines)
1377 (gnus-treat-strip-multiple-blank-lines
1378 gnus-article-strip-multiple-blank-lines)
1379 (gnus-treat-overstrike gnus-article-treat-overstrike)
1380 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1381 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1382 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1383 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1384 (gnus-treat-display-smileys gnus-treat-smiley)
1385 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1386 (gnus-treat-wash-html gnus-article-wash-html)
1387 (gnus-treat-emphasize gnus-article-emphasize)
1388 (gnus-treat-hide-citation gnus-article-hide-citation)
1389 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1390 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1391 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1392 (gnus-treat-play-sounds gnus-earcon-display)))
1394 (defvar gnus-article-mime-handle-alist nil)
1395 (defvar article-lapsed-timer nil)
1396 (defvar gnus-article-current-summary nil)
1398 (defvar gnus-article-mode-syntax-table
1399 (let ((table (copy-syntax-table text-mode-syntax-table)))
1400 ;; This causes the citation match run O(2^n).
1401 ;; (modify-syntax-entry ?- "w" table)
1402 (modify-syntax-entry ?> ")<" table)
1403 (modify-syntax-entry ?< "(>" table)
1404 ;; make M-. in article buffers work for `foo' strings
1405 (modify-syntax-entry ?' " " table)
1406 (modify-syntax-entry ?` " " table)
1408 "Syntax table used in article mode buffers.
1409 Initialized from `text-mode-syntax-table.")
1411 (defvar gnus-save-article-buffer nil)
1413 (defvar gnus-article-mode-line-format-alist
1414 (nconc '((?w (gnus-article-wash-status) ?s)
1415 (?m (gnus-article-mime-part-status) ?s))
1416 gnus-summary-mode-line-format-alist))
1418 (defvar gnus-number-of-articles-to-be-saved nil)
1420 (defvar gnus-inhibit-hiding nil)
1422 ;;; Macros for dealing with the article buffer.
1424 (defmacro gnus-with-article-headers (&rest forms)
1426 (set-buffer gnus-article-buffer)
1428 (let ((buffer-read-only nil)
1429 (inhibit-point-motion-hooks t)
1430 (case-fold-search t))
1431 (article-narrow-to-head)
1434 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1435 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1437 (defmacro gnus-with-article-buffer (&rest forms)
1439 (set-buffer gnus-article-buffer)
1440 (let ((buffer-read-only nil))
1443 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1444 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1446 (defun gnus-article-goto-header (header)
1447 "Go to HEADER, which is a regular expression."
1448 (re-search-forward (concat "^\\(" header "\\):") nil t))
1450 (defsubst gnus-article-hide-text (b e props)
1451 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1452 (gnus-add-text-properties-when 'article-type nil b e props)
1453 (when (memq 'intangible props)
1455 (max (1- b) (point-min))
1456 b 'intangible (cddr (memq 'intangible props)))))
1458 (defsubst gnus-article-unhide-text (b e)
1459 "Remove hidden text properties from region between B and E."
1460 (remove-text-properties b e gnus-hidden-properties)
1461 (when (memq 'intangible gnus-hidden-properties)
1462 (put-text-property (max (1- b) (point-min))
1463 b 'intangible nil)))
1465 (defun gnus-article-hide-text-type (b e type)
1466 "Hide text of TYPE between B and E."
1467 (gnus-add-wash-type type)
1468 (gnus-article-hide-text
1469 b e (cons 'article-type (cons type gnus-hidden-properties))))
1471 (defun gnus-article-unhide-text-type (b e type)
1472 "Unhide text of TYPE between B and E."
1473 (gnus-delete-wash-type type)
1474 (remove-text-properties
1475 b e (cons 'article-type (cons type gnus-hidden-properties)))
1476 (when (memq 'intangible gnus-hidden-properties)
1477 (put-text-property (max (1- b) (point-min))
1478 b 'intangible nil)))
1480 (defun gnus-article-hide-text-of-type (type)
1481 "Hide text of TYPE in the current buffer."
1483 (let ((b (point-min))
1485 (while (setq b (text-property-any b e 'article-type type))
1486 (add-text-properties b (incf b) gnus-hidden-properties)))))
1488 (defun gnus-article-delete-text-of-type (type)
1489 "Delete text of TYPE in the current buffer."
1491 (let ((b (point-min)))
1492 (while (setq b (text-property-any b (point-max) 'article-type type))
1494 b (or (text-property-not-all b (point-max) 'article-type type)
1497 (defun gnus-article-delete-invisible-text ()
1498 "Delete all invisible text in the current buffer."
1500 (let ((b (point-min)))
1501 (while (setq b (text-property-any b (point-max) 'invisible t))
1503 b (or (text-property-not-all b (point-max) 'invisible t)
1506 (defun gnus-article-text-type-exists-p (type)
1507 "Say whether any text of type TYPE exists in the buffer."
1508 (text-property-any (point-min) (point-max) 'article-type type))
1510 (defsubst gnus-article-header-rank ()
1511 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1512 (let ((list gnus-sorted-header-list)
1515 (if (looking-at (car list))
1517 (setq list (cdr list))
1521 (defun article-hide-headers (&optional arg delete)
1522 "Hide unwanted headers and possibly sort them as well."
1524 ;; This function might be inhibited.
1525 (unless gnus-inhibit-hiding
1528 (let ((buffer-read-only nil)
1529 (case-fold-search t)
1530 (max (1+ (length gnus-sorted-header-list)))
1531 (ignored (when (not gnus-visible-headers)
1532 (cond ((stringp gnus-ignored-headers)
1533 gnus-ignored-headers)
1534 ((listp gnus-ignored-headers)
1535 (mapconcat 'identity gnus-ignored-headers
1538 (cond ((stringp gnus-visible-headers)
1539 gnus-visible-headers)
1540 ((and gnus-visible-headers
1541 (listp gnus-visible-headers))
1542 (mapconcat 'identity gnus-visible-headers "\\|"))))
1543 (inhibit-point-motion-hooks t)
1545 ;; First we narrow to just the headers.
1546 (article-narrow-to-head)
1547 ;; Hide any "From " lines at the beginning of (mail) articles.
1548 (while (looking-at "From ")
1551 (delete-region (point-min) (point)))
1552 ;; Then treat the rest of the header lines.
1553 ;; Then we use the two regular expressions
1554 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1555 ;; select which header lines is to remain visible in the
1557 (while (re-search-forward "^[^ \t:]*:" nil t)
1559 ;; Mark the rank of the header.
1561 (point) (1+ (point)) 'message-rank
1562 (if (or (and visible (looking-at visible))
1564 (not (looking-at ignored))))
1565 (gnus-article-header-rank)
1568 (message-sort-headers-1)
1569 (when (setq beg (text-property-any
1570 (point-min) (point-max) 'message-rank (+ 2 max)))
1571 ;; We delete the unwanted headers.
1572 (gnus-add-wash-type 'headers)
1573 (add-text-properties (point-min) (+ 5 (point-min))
1574 '(article-type headers dummy-invisible t))
1575 (delete-region beg (point-max))))))))
1577 (defun article-hide-boring-headers (&optional arg)
1578 "Toggle hiding of headers that aren't very interesting.
1579 If given a negative prefix, always show; if given a positive prefix,
1581 (interactive (gnus-article-hidden-arg))
1582 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1583 (not gnus-show-all-headers))
1586 (let ((buffer-read-only nil)
1587 (list gnus-boring-article-headers)
1588 (inhibit-point-motion-hooks t)
1590 (article-narrow-to-head)
1592 (setq elem (pop list))
1593 (goto-char (point-min))
1595 ;; Hide empty headers.
1597 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1599 (gnus-article-hide-text-type
1603 (if (re-search-forward "^[^ \t]" nil t)
1607 ;; Hide boring Newsgroups header.
1608 ((eq elem 'newsgroups)
1609 (when (gnus-string-equal
1610 (gnus-fetch-field "newsgroups")
1611 (gnus-group-real-name
1612 (if (boundp 'gnus-newsgroup-name)
1615 (gnus-article-hide-header "newsgroups")))
1616 ((eq elem 'to-address)
1617 (let ((to (message-fetch-field "to"))
1619 (gnus-parameter-to-address
1620 (if (boundp 'gnus-newsgroup-name)
1621 gnus-newsgroup-name ""))))
1622 (when (and to to-address
1625 ;; only one address in To
1626 (nth 1 (mail-extract-address-components to))
1628 (gnus-article-hide-header "to"))))
1630 (let ((to (message-fetch-field "to"))
1632 (gnus-parameter-to-list
1633 (if (boundp 'gnus-newsgroup-name)
1634 gnus-newsgroup-name ""))))
1635 (when (and to to-list
1638 ;; only one address in To
1639 (nth 1 (mail-extract-address-components to))
1641 (gnus-article-hide-header "to"))))
1643 (let ((cc (message-fetch-field "cc"))
1645 (gnus-parameter-to-list
1646 (if (boundp 'gnus-newsgroup-name)
1647 gnus-newsgroup-name ""))))
1648 (when (and cc to-list
1651 ;; only one address in CC
1652 (nth 1 (mail-extract-address-components cc))
1654 (gnus-article-hide-header "cc"))))
1655 ((eq elem 'followup-to)
1656 (when (gnus-string-equal
1657 (message-fetch-field "followup-to")
1658 (message-fetch-field "newsgroups"))
1659 (gnus-article-hide-header "followup-to")))
1660 ((eq elem 'reply-to)
1661 (let ((from (message-fetch-field "from"))
1662 (reply-to (message-fetch-field "reply-to")))
1667 (nth 1 (mail-extract-address-components from))
1668 (nth 1 (mail-extract-address-components reply-to)))))
1669 (gnus-article-hide-header "reply-to"))))
1671 (let ((date (message-fetch-field "date")))
1673 (< (days-between (current-time-string) date)
1675 (gnus-article-hide-header "date"))))
1677 (let ((to (message-fetch-field "to"))
1678 (cc (message-fetch-field "cc")))
1679 (when (> (length to) 1024)
1680 (gnus-article-hide-header "to"))
1681 (when (> (length cc) 1024)
1682 (gnus-article-hide-header "cc"))))
1686 (goto-char (point-min))
1687 (while (re-search-forward "^to:" nil t)
1688 (setq to-count (1+ to-count)))
1689 (when (> to-count 1)
1690 (while (> to-count 0)
1691 (goto-char (point-min))
1693 (re-search-forward "^to:" nil nil to-count)
1695 (narrow-to-region (point) (point-max))
1696 (gnus-article-hide-header "to"))
1697 (setq to-count (1- to-count))))
1698 (goto-char (point-min))
1699 (while (re-search-forward "^cc:" nil t)
1700 (setq cc-count (1+ cc-count)))
1701 (when (> cc-count 1)
1702 (while (> cc-count 0)
1703 (goto-char (point-min))
1705 (re-search-forward "^cc:" nil nil cc-count)
1707 (narrow-to-region (point) (point-max))
1708 (gnus-article-hide-header "cc"))
1709 (setq cc-count (1- cc-count)))))))))))))
1711 (defun gnus-article-hide-header (header)
1713 (goto-char (point-min))
1714 (when (re-search-forward (concat "^" header ":") nil t)
1715 (gnus-article-hide-text-type
1719 (if (re-search-forward "^[^ \t]" nil t)
1724 (defvar gnus-article-normalized-header-length 40
1725 "Length of normalized headers.")
1727 (defun article-normalize-headers ()
1728 "Make all header lines 40 characters long."
1730 (let ((buffer-read-only nil)
1734 (article-narrow-to-head)
1737 ((< (setq column (- (gnus-point-at-eol) (point)))
1738 gnus-article-normalized-header-length)
1740 (insert (make-string
1741 (- gnus-article-normalized-header-length column)
1743 ((> column gnus-article-normalized-header-length)
1744 (gnus-put-text-property
1746 (forward-char gnus-article-normalized-header-length)
1753 (forward-line 1))))))
1755 (defun article-treat-dumbquotes ()
1756 "Translate M****s*** sm*rtq**t*s into proper text.
1757 Note that this function guesses whether a character is a sm*rtq**t* or
1758 not, so it should only be used interactively.
1760 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1761 in an attempt to provide more quoting characters. If you see
1762 something like \\222 or \\264 where you're expecting some kind of
1763 apostrophe or quotation mark, then try this wash."
1765 (article-translate-strings gnus-article-dumbquotes-map))
1767 (defun article-translate-characters (from to)
1768 "Translate all characters in the body of the article according to FROM and TO.
1769 FROM is a string of characters to translate from; to is a string of
1770 characters to translate to."
1772 (when (article-goto-body)
1773 (let ((buffer-read-only nil)
1774 (x (make-string 225 ?x))
1776 (while (< (incf i) (length x))
1779 (while (< i (length from))
1780 (aset x (aref from i) (aref to i))
1782 (translate-region (point) (point-max) x)))))
1784 (defun article-translate-strings (map)
1785 "Translate all string in the body of the article according to MAP.
1786 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1788 (when (article-goto-body)
1789 (let ((buffer-read-only nil)
1791 (while (setq elem (pop map))
1793 (while (search-forward (car elem) nil t)
1794 (replace-match (cadr elem)))))))))
1796 (defun article-treat-overstrike ()
1797 "Translate overstrikes into bold text."
1800 (when (article-goto-body)
1801 (let ((buffer-read-only nil))
1802 (while (search-forward "\b" nil t)
1803 (let ((next (char-after))
1804 (previous (char-after (- (point) 2))))
1805 ;; We do the boldification/underlining by hiding the
1806 ;; overstrikes and putting the proper text property
1810 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1811 (put-text-property (point) (1+ (point)) 'face 'bold))
1813 (gnus-article-hide-text-type
1814 (1- (point)) (1+ (point)) 'overstrike)
1816 (- (point) 2) (1- (point)) 'face 'underline))
1818 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1820 (point) (1+ (point)) 'face 'underline)))))))))
1822 (defun gnus-article-treat-unfold-headers ()
1823 "Unfold folded message headers.
1824 Only the headers that fit into the current window width will be
1827 (gnus-with-article-headers
1831 (mail-header-narrow-to-field)
1832 (let ((header (buffer-string)))
1835 (goto-char (point-min))
1836 (while (re-search-forward "\n[\t ]" nil t)
1837 (replace-match " " t t)))
1838 (setq length (- (point-max) (point-min) 1)))
1839 (when (< length (window-width))
1840 (while (re-search-forward "\n[\t ]" nil t)
1841 (replace-match " " t t)))
1842 (goto-char (point-max)))))))
1844 (defun gnus-article-treat-fold-headers ()
1845 "Fold message headers."
1847 (gnus-with-article-headers
1850 (mail-header-narrow-to-field)
1851 (mail-header-fold-field)
1852 (goto-char (point-max))))))
1854 (defun gnus-treat-smiley ()
1855 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1857 (gnus-with-article-buffer
1858 (if (memq 'smiley gnus-article-wash-types)
1859 (gnus-delete-images 'smiley)
1861 (let ((images (smiley-region (point) (point-max))))
1863 (gnus-add-wash-type 'smiley)
1864 (dolist (image images)
1865 (gnus-add-image 'smiley image)))))))
1867 (defun gnus-article-remove-images ()
1868 "Remove all images from the article buffer."
1870 (gnus-with-article-buffer
1871 (dolist (elem gnus-article-image-alist)
1872 (gnus-delete-images (car elem)))))
1874 (defun gnus-article-treat-fold-newsgroups ()
1875 "Unfold folded message headers.
1876 Only the headers that fit into the current window width will be
1879 (gnus-with-article-headers
1880 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1882 (mail-header-narrow-to-field)
1883 (while (re-search-forward ", *" nil t)
1884 (replace-match ", " t t))
1885 (mail-header-fold-field)
1886 (goto-char (point-max))))))
1888 (defun gnus-article-treat-body-boundary ()
1889 "Place a boundary line at the end of the headers."
1891 (when (and gnus-body-boundary-delimiter
1892 (> (length gnus-body-boundary-delimiter) 0))
1893 (gnus-with-article-headers
1894 (goto-char (point-max))
1895 (let ((start (point)))
1896 (insert "X-Boundary: ")
1897 (gnus-add-text-properties start (point) '(invisible t intangible t))
1899 (while (>= (1- (window-width)) (length str))
1900 (setq str (concat str gnus-body-boundary-delimiter)))
1901 (substring str 0 (1- (window-width))))
1903 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1905 (defun article-fill-long-lines ()
1906 "Fill lines that are wider than the window width."
1909 (let ((buffer-read-only nil)
1910 (width (window-width (get-buffer-window (current-buffer)))))
1913 (let ((adaptive-fill-mode nil)) ;Why? -sm
1916 (when (>= (current-column) (min fill-column width))
1917 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1918 (let ((goback (point-marker)))
1919 (fill-paragraph nil)
1920 (goto-char (marker-position goback)))
1922 (forward-line 1)))))))
1924 (defun article-capitalize-sentences ()
1925 "Capitalize the first word in each sentence."
1928 (let ((buffer-read-only nil)
1929 (paragraph-start "^[\n\^L]"))
1933 (forward-sentence)))))
1935 (defun article-remove-cr ()
1936 "Remove trailing CRs and then translate remaining CRs into LFs."
1939 (let ((buffer-read-only nil))
1940 (goto-char (point-min))
1941 (while (re-search-forward "\r+$" nil t)
1942 (replace-match "" t t))
1943 (goto-char (point-min))
1944 (while (search-forward "\r" nil t)
1945 (replace-match "\n" t t)))))
1947 (defun article-remove-trailing-blank-lines ()
1948 "Remove all trailing blank lines from the article."
1951 (let ((buffer-read-only nil))
1952 (goto-char (point-max))
1956 (while (and (not (bobp))
1957 (looking-at "^[ \t]*$")
1958 (not (gnus-annotation-in-region-p
1959 (point) (gnus-point-at-eol))))
1964 (defun article-display-face ()
1965 "Display any Face headers in the header."
1967 (gnus-with-article-headers
1968 (let ((face (message-fetch-field "face")))
1970 (let ((png (gnus-convert-face-to-png face))
1973 (setq image (gnus-create-image png 'png t))
1974 (gnus-article-goto-header "from")
1976 (insert "From: [no `from' set]\n")
1978 (gnus-add-wash-type 'face)
1979 (gnus-add-image 'face image)
1980 (gnus-put-image image)))))))
1982 (defun article-display-x-face (&optional force)
1983 "Look for an X-Face header and display it if present."
1984 (interactive (list 'force))
1985 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1986 (gnus-with-article-headers
1987 ;; Delete the old process, if any.
1988 (when (process-status "article-x-face")
1989 (delete-process "article-x-face"))
1990 (if (memq 'xface gnus-article-wash-types)
1991 ;; We have already displayed X-Faces, so we remove them
1993 (gnus-delete-images 'xface)
1995 (let (x-faces from face)
1997 (when (and wash-face-p
1999 (goto-char (point-min))
2000 (not (re-search-forward
2001 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2002 (gnus-buffer-live-p gnus-original-article-buffer))
2003 ;; If type `W f', use gnus-original-article-buffer,
2004 ;; otherwise use the current buffer because displaying
2005 ;; RFC822 parts calls this function too.
2006 (set-buffer gnus-original-article-buffer))
2008 (mail-narrow-to-head)
2009 (while (gnus-article-goto-header "X-Face")
2010 (push (mail-header-field-value) x-faces))
2011 (setq from (message-fetch-field "from"))))
2012 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2013 ;; single external face.
2014 (when (stringp gnus-article-x-face-command)
2015 (setq x-faces (list (car x-faces))))
2016 (while (and (setq face (pop x-faces))
2017 gnus-article-x-face-command
2019 ;; Check whether this face is censored.
2020 (not gnus-article-x-face-too-ugly)
2021 (and gnus-article-x-face-too-ugly from
2022 (not (string-match gnus-article-x-face-too-ugly
2024 ;; We display the face.
2025 (if (symbolp gnus-article-x-face-command)
2026 ;; The command is a lisp function, so we call it.
2027 (if (gnus-functionp gnus-article-x-face-command)
2028 (funcall gnus-article-x-face-command face)
2029 (error "%s is not a function" gnus-article-x-face-command))
2030 ;; The command is a string, so we interpret the command
2031 ;; as a, well, command, and fork it off.
2032 (let ((process-connection-type nil))
2033 (process-kill-without-query
2035 "article-x-face" nil shell-file-name shell-command-switch
2036 gnus-article-x-face-command))
2039 (process-send-region "article-x-face"
2040 (point-min) (point-max)))
2041 (process-send-eof "article-x-face")))))))))
2043 (defun article-decode-mime-words ()
2044 "Decode all MIME-encoded words in the article."
2047 (set-buffer gnus-article-buffer)
2048 (let ((inhibit-point-motion-hooks t)
2050 (mail-parse-charset gnus-newsgroup-charset)
2051 (mail-parse-ignored-charsets
2052 (save-excursion (set-buffer gnus-summary-buffer)
2053 gnus-newsgroup-ignored-charsets)))
2054 (mail-decode-encoded-word-region (point-min) (point-max)))))
2056 (defun article-decode-charset (&optional prompt)
2057 "Decode charset-encoded text in the article.
2058 If PROMPT (the prefix), prompt for a coding system to use."
2060 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2062 (mail-parse-charset gnus-newsgroup-charset)
2063 (mail-parse-ignored-charsets
2064 (save-excursion (condition-case nil
2065 (set-buffer gnus-summary-buffer)
2067 gnus-newsgroup-ignored-charsets))
2068 ct cte ctl charset format)
2071 (article-narrow-to-head)
2072 (setq ct (message-fetch-field "Content-Type" t)
2073 cte (message-fetch-field "Content-Transfer-Encoding" t)
2074 ctl (and ct (ignore-errors
2075 (mail-header-parse-content-type ct)))
2078 (mm-read-coding-system "Charset to decode: "))
2080 (mail-content-type-get ctl 'charset)))
2081 format (and ctl (mail-content-type-get ctl 'format)))
2083 (setq cte (mail-header-strip cte)))
2084 (if (and ctl (not (string-match "/" (car ctl))))
2086 (goto-char (point-max)))
2089 (narrow-to-region (point) (point-max))
2090 (when (and (eq mail-parse-charset 'gnus-decoded)
2091 (eq (mm-body-7-or-8) '8bit))
2092 ;; The text code could have been decoded.
2093 (setq charset mail-parse-charset))
2094 (when (and (or (not ctl)
2095 (equal (car ctl) "text/plain"))
2096 (not format)) ;; article with format will decode later.
2098 charset (and cte (intern (downcase
2099 (gnus-strip-whitespace cte))))
2100 (car ctl) prompt))))))
2102 (defun article-decode-encoded-words ()
2103 "Remove encoded-word encoding from headers."
2104 (let ((inhibit-point-motion-hooks t)
2105 (mail-parse-charset gnus-newsgroup-charset)
2106 (mail-parse-ignored-charsets
2107 (save-excursion (condition-case nil
2108 (set-buffer gnus-summary-buffer)
2110 gnus-newsgroup-ignored-charsets))
2113 (article-narrow-to-head)
2114 (funcall gnus-decode-header-function (point-min) (point-max)))))
2116 (defun article-decode-group-name ()
2117 "Decode group names in `Newsgroups:'."
2118 (let ((inhibit-point-motion-hooks t)
2120 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2121 (when (and (or gnus-group-name-charset-method-alist
2122 gnus-group-name-charset-group-alist)
2123 (gnus-buffer-live-p gnus-original-article-buffer))
2124 (when (nnmail-fetch-field "Newsgroups")
2125 (nnheader-replace-header "Newsgroups"
2126 (gnus-decode-newsgroups
2127 (with-current-buffer
2128 gnus-original-article-buffer
2129 (nnmail-fetch-field "Newsgroups"))
2130 gnus-newsgroup-name method)))
2131 (when (nnmail-fetch-field "Followup-To")
2132 (nnheader-replace-header "Followup-To"
2133 (gnus-decode-newsgroups
2134 (with-current-buffer
2135 gnus-original-article-buffer
2136 (nnmail-fetch-field "Followup-To"))
2137 gnus-newsgroup-name method))))))
2139 (defun article-decode-idna-rhs ()
2140 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2143 (let ((inhibit-point-motion-hooks t)
2145 (article-narrow-to-head)
2146 (goto-char (point-min))
2147 (while (re-search-forward "\\(xn--.*\\)[ \t\n\r,>]" nil t)
2149 (when (save-match-data
2150 (and (setq ace (match-string 1))
2152 (and (re-search-backward "^[^ \t]" nil t)
2153 (looking-at "From\\|To\\|Cc")))
2154 (save-excursion (backward-char)
2155 (message-idna-inside-rhs-p))
2156 (setq unicode (idna-to-unicode ace))))
2157 (unless (string= ace unicode)
2158 (replace-match unicode nil nil nil 1)))))))))
2160 (defun article-de-quoted-unreadable (&optional force read-charset)
2161 "Translate a quoted-printable-encoded article.
2162 If FORCE, decode the article whether it is marked as quoted-printable
2164 If READ-CHARSET, ask for a coding system."
2165 (interactive (list 'force current-prefix-arg))
2167 (let ((buffer-read-only nil) type charset)
2168 (if (gnus-buffer-live-p gnus-original-article-buffer)
2169 (with-current-buffer gnus-original-article-buffer
2171 (gnus-fetch-field "content-transfer-encoding"))
2172 (let* ((ct (gnus-fetch-field "content-type"))
2175 (mail-header-parse-content-type ct)))))
2176 (setq charset (and ctl
2177 (mail-content-type-get ctl 'charset)))
2178 (if (stringp charset)
2179 (setq charset (intern (downcase charset)))))))
2181 (setq charset (mm-read-coding-system "Charset: " charset)))
2183 (setq charset gnus-newsgroup-charset))
2185 (and type (let ((case-fold-search t))
2186 (string-match "quoted-printable" type))))
2188 (quoted-printable-decode-region
2189 (point) (point-max) (mm-charset-to-coding-system charset))))))
2191 (defun article-de-base64-unreadable (&optional force read-charset)
2192 "Translate a base64 article.
2193 If FORCE, decode the article whether it is marked as base64 not.
2194 If READ-CHARSET, ask for a coding system."
2195 (interactive (list 'force current-prefix-arg))
2197 (let ((buffer-read-only nil) type charset)
2198 (if (gnus-buffer-live-p gnus-original-article-buffer)
2199 (with-current-buffer gnus-original-article-buffer
2201 (gnus-fetch-field "content-transfer-encoding"))
2202 (let* ((ct (gnus-fetch-field "content-type"))
2205 (mail-header-parse-content-type ct)))))
2206 (setq charset (and ctl
2207 (mail-content-type-get ctl 'charset)))
2208 (if (stringp charset)
2209 (setq charset (intern (downcase charset)))))))
2211 (setq charset (mm-read-coding-system "Charset: " charset)))
2213 (setq charset gnus-newsgroup-charset))
2215 (and type (let ((case-fold-search t))
2216 (string-match "base64" type))))
2219 (narrow-to-region (point) (point-max))
2220 (base64-decode-region (point-min) (point-max))
2221 (mm-decode-coding-region
2222 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2227 (defun article-decode-HZ ()
2228 "Translate a HZ-encoded article."
2232 (let ((buffer-read-only nil))
2233 (rfc1843-decode-region (point-min) (point-max)))))
2235 (defun article-unsplit-urls ()
2236 "Remove the newlines that some other mailers insert into URLs."
2239 (let ((buffer-read-only nil))
2240 (goto-char (point-min))
2241 (while (re-search-forward
2242 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2243 (replace-match "\\1\\3" t)))
2244 (when (and gnus-display-mime-function (interactive-p))
2245 (funcall gnus-display-mime-function))))
2248 (defun article-wash-html (&optional read-charset)
2249 "Format an HTML article.
2250 If READ-CHARSET, ask for a coding system."
2253 (let ((buffer-read-only nil)
2255 (when (gnus-buffer-live-p gnus-original-article-buffer)
2256 (with-current-buffer gnus-original-article-buffer
2257 (let* ((ct (gnus-fetch-field "content-type"))
2260 (mail-header-parse-content-type ct)))))
2261 (setq charset (and ctl
2262 (mail-content-type-get ctl 'charset)))
2263 (when (stringp charset)
2264 (setq charset (intern (downcase charset)))))))
2266 (setq charset (mm-read-coding-system "Charset: " charset)))
2268 (setq charset gnus-newsgroup-charset))
2270 (save-window-excursion
2272 (narrow-to-region (point) (point-max))
2273 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2274 (entry (assq func mm-text-html-washer-alist)))
2276 (setq func (cdr entry)))
2278 ((gnus-functionp func)
2281 (apply (car func) (cdr func))))))))))
2283 (defun gnus-article-wash-html-with-w3 ()
2284 "Wash the current buffer with w3."
2286 (let ((w3-strict-width (window-width))
2287 (url-standalone-mode t)
2288 (url-gateway-unplugged t)
2289 (w3-honor-stylesheets nil))
2291 (w3-region (point-min) (point-max))
2294 (defun gnus-article-wash-html-with-w3m ()
2295 "Wash the current buffer with emacs-w3m."
2298 (narrow-to-region (point) (point-max))
2299 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2302 w3m-force-redisplay)
2303 (w3m-region (point-min) (point-max)))
2304 (when mm-inline-text-html-with-w3m-keymap
2305 (add-text-properties
2306 (point-min) (point-max)
2307 (nconc (mm-w3m-local-map-property)
2308 '(mm-inline-text-html-with-w3m t))))))
2310 (defun article-hide-list-identifiers ()
2311 "Remove list identifies from the Subject header.
2312 The `gnus-list-identifiers' variable specifies what to do."
2314 (let ((inhibit-point-motion-hooks t)
2315 (regexp (if (consp gnus-list-identifiers)
2316 (mapconcat 'identity gnus-list-identifiers " *\\|")
2317 gnus-list-identifiers))
2322 (article-narrow-to-head)
2323 (goto-char (point-min))
2324 (while (re-search-forward
2325 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2327 (delete-region (match-beginning 2) (match-end 0))
2328 (beginning-of-line))
2329 (when (re-search-forward
2330 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2331 (delete-region (match-beginning 1) (match-end 1))))))))
2333 (defun article-hide-pem (&optional arg)
2334 "Toggle hiding of any PEM headers and signatures in the current article.
2335 If given a negative prefix, always show; if given a positive prefix,
2337 (interactive (gnus-article-hidden-arg))
2338 (unless (gnus-article-check-hidden-text 'pem arg)
2340 (let (buffer-read-only end)
2341 (goto-char (point-min))
2342 ;; Hide the horrendously ugly "header".
2343 (when (and (search-forward
2344 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2346 (setq end (1+ (match-beginning 0))))
2347 (gnus-add-wash-type 'pem)
2348 (gnus-article-hide-text-type
2350 (if (search-forward "\n\n" nil t)
2354 ;; Hide the trailer as well
2355 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2357 (gnus-article-hide-text-type
2358 (match-beginning 0) (match-end 0) 'pem)))))))
2360 (defun article-strip-banner ()
2361 "Strip the banners specified by the `banner' group parameter and by
2362 `gnus-article-address-banner-alist'."
2366 (let ((inhibit-point-motion-hooks t))
2367 (when (gnus-parameter-banner gnus-newsgroup-name)
2368 (article-really-strip-banner
2369 (gnus-parameter-banner gnus-newsgroup-name)))
2370 (when gnus-article-address-banner-alist
2371 (article-really-strip-banner
2372 (let ((from (save-restriction
2374 (article-narrow-to-head)
2375 (mail-fetch-field "from"))))
2378 (caar (mail-header-parse-addresses from))))
2380 (dolist (pair gnus-article-address-banner-alist)
2381 (when (string-match (car pair) from)
2382 (throw 'found (cdr pair)))))))))))))
2384 (defun article-really-strip-banner (banner)
2385 "Strip the banner specified by the argument."
2388 (let ((inhibit-point-motion-hooks t)
2389 (gnus-signature-limit nil)
2393 ((eq banner 'signature)
2394 (when (gnus-article-narrow-to-signature)
2397 (delete-region (point) (point-max))))
2399 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2400 (while (re-search-forward banner nil t)
2401 (delete-region (match-beginning 0) (match-end 0)))))
2403 (while (re-search-forward banner nil t)
2404 (delete-region (match-beginning 0) (match-end 0)))))))))
2406 (defun article-babel ()
2407 "Translate article using an online translation service."
2411 (set-buffer gnus-article-buffer)
2412 (when (article-goto-body)
2413 (let* ((buffer-read-only nil)
2416 (orig (buffer-substring start end))
2417 (trans (babel-as-string orig)))
2419 (narrow-to-region start end)
2420 (delete-region start end)
2423 (defun article-hide-signature (&optional arg)
2424 "Hide the signature in the current article.
2425 If given a negative prefix, always show; if given a positive prefix,
2427 (interactive (gnus-article-hidden-arg))
2428 (unless (gnus-article-check-hidden-text 'signature arg)
2431 (let ((buffer-read-only nil))
2432 (when (gnus-article-narrow-to-signature)
2433 (gnus-article-hide-text-type
2434 (point-min) (point-max) 'signature))))))
2435 (gnus-set-mode-line 'article))
2437 (defun article-strip-headers-in-body ()
2438 "Strip offensive headers from bodies."
2442 (let ((case-fold-search t))
2443 (when (looking-at "x-no-archive:")
2444 (gnus-delete-line)))))
2446 (defun article-strip-leading-blank-lines ()
2447 "Remove all blank lines from the beginning of the article."
2450 (let ((inhibit-point-motion-hooks t)
2452 (when (article-goto-body)
2453 (while (and (not (eobp))
2454 (looking-at "[ \t]*$"))
2455 (gnus-delete-line))))))
2457 (defun article-narrow-to-head ()
2458 "Narrow the buffer to the head of the message.
2459 Point is left at the beginning of the narrowed-to region."
2461 (goto-char (point-min))
2462 (if (search-forward "\n\n" nil 1)
2465 (goto-char (point-min)))
2467 (defun article-goto-body ()
2468 "Place point at the start of the body."
2469 (goto-char (point-min))
2471 ;; This variable is only bound when dealing with separate
2473 (article-goto-body-goes-to-point-min-p
2475 ((search-forward "\n\n" nil t)
2478 (goto-char (point-max))
2481 (defun article-strip-multiple-blank-lines ()
2482 "Replace consecutive blank lines with one empty line."
2485 (let ((inhibit-point-motion-hooks t)
2487 ;; First make all blank lines empty.
2489 (while (re-search-forward "^[ \t]+$" nil t)
2490 (unless (gnus-annotation-in-region-p
2491 (match-beginning 0) (match-end 0))
2492 (replace-match "" nil t)))
2493 ;; Then replace multiple empty lines with a single empty line.
2495 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2496 (unless (gnus-annotation-in-region-p
2497 (match-beginning 0) (match-end 0))
2498 (delete-region (match-beginning 1) (match-end 1)))))))
2500 (defun article-strip-leading-space ()
2501 "Remove all white space from the beginning of the lines in the article."
2504 (let ((inhibit-point-motion-hooks t)
2507 (while (re-search-forward "^[ \t]+" nil t)
2508 (replace-match "" t t)))))
2510 (defun article-strip-trailing-space ()
2511 "Remove all white space from the end of the lines in the article."
2514 (let ((inhibit-point-motion-hooks t)
2517 (while (re-search-forward "[ \t]+$" nil t)
2518 (replace-match "" t t)))))
2520 (defun article-strip-blank-lines ()
2521 "Strip leading, trailing and multiple blank lines."
2523 (article-strip-leading-blank-lines)
2524 (article-remove-trailing-blank-lines)
2525 (article-strip-multiple-blank-lines))
2527 (defun article-strip-all-blank-lines ()
2528 "Strip all blank lines."
2531 (let ((inhibit-point-motion-hooks t)
2534 (while (re-search-forward "^[ \t]*\n" nil t)
2535 (replace-match "" t t)))))
2537 (defun gnus-article-narrow-to-signature ()
2538 "Narrow to the signature; return t if a signature is found, else nil."
2539 (let ((inhibit-point-motion-hooks t))
2540 (when (gnus-article-search-signature)
2542 ;; Check whether we have some limits to what we consider
2543 ;; to be a signature.
2544 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2545 (list gnus-signature-limit)))
2547 (while (setq limit (pop limits))
2548 (if (or (and (integerp limit)
2549 (< (- (point-max) (point)) limit))
2551 (< (count-lines (point) (point-max)) limit))
2552 (and (gnus-functionp limit)
2554 (and (stringp limit)
2555 (not (re-search-forward limit nil t))))
2556 () ; This limit did not succeed.
2560 (narrow-to-region (point) (point-max))
2563 (defun gnus-article-search-signature ()
2564 "Search the current buffer for the signature separator.
2565 Put point at the beginning of the signature separator."
2566 (let ((cur (point)))
2567 (goto-char (point-max))
2568 (if (if (stringp gnus-signature-separator)
2569 (re-search-backward gnus-signature-separator nil t)
2570 (let ((seps gnus-signature-separator))
2572 (not (re-search-backward (car seps) nil t)))
2579 (defun gnus-article-hidden-arg ()
2580 "Return the current prefix arg as a number, or 0 if no prefix."
2581 (list (if current-prefix-arg
2582 (prefix-numeric-value current-prefix-arg)
2585 (defun gnus-article-check-hidden-text (type arg)
2586 "Return nil if hiding is necessary.
2587 Arg can be nil or a number. nil and positive means hide, negative
2588 means show, 0 means toggle."
2591 (let ((hide (gnus-article-hidden-text-p type)))
2597 (gnus-article-show-hidden-text type)
2600 (if (eq hide 'hidden)
2602 (gnus-article-show-hidden-text type)
2606 (defun gnus-article-hidden-text-p (type)
2607 "Say whether the current buffer contains hidden text of type TYPE."
2608 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2610 (not (get-text-property pos 'invisible))
2611 (not (get-text-property pos 'dummy-invisible)))
2613 (text-property-any (1+ pos) (point-max) 'article-type type)))
2618 (defun gnus-article-show-hidden-text (type &optional dummy)
2619 "Show all hidden text of type TYPE.
2620 Originally it is hide instead of DUMMY."
2621 (let ((buffer-read-only nil)
2622 (inhibit-point-motion-hooks t))
2623 (gnus-remove-text-properties-when
2625 (point-min) (point-max)
2626 (cons 'article-type (cons type
2627 gnus-hidden-properties)))
2628 (gnus-delete-wash-type type)))
2630 (defconst article-time-units
2631 `((year . ,(* 365.25 24 60 60))
2632 (week . ,(* 7 24 60 60))
2633 (day . ,(* 24 60 60))
2637 "Mapping from time units to seconds.")
2639 (defun gnus-article-forward-header ()
2640 "Move point to the start of the next header.
2641 If the current header is a continuation header, this can be several
2646 (if (looking-at "[ \t]+[^ \t]")
2650 (defun article-date-ut (&optional type highlight header)
2651 "Convert DATE date to universal time in the current article.
2652 If TYPE is `local', convert to local time; if it is `lapsed', output
2653 how much time has lapsed since DATE. For `lapsed', the value of
2654 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2655 should replace the \"Date:\" one, or should be added below it."
2656 (interactive (list 'ut t))
2657 (let* ((header (or header
2658 (message-fetch-field "date")
2660 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2663 ((not gnus-article-date-lapsed-new-header)
2669 (date (if (vectorp header) (mail-header-date header)
2671 (inhibit-point-motion-hooks t)
2676 (article-narrow-to-head)
2677 (when (re-search-forward tdate-regexp nil t)
2678 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2679 date (or (get-text-property (gnus-point-at-bol)
2682 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2684 (when (and date (not (string= date "")))
2685 (goto-char (point-min))
2686 (let ((buffer-read-only nil))
2687 ;; Delete any old Date headers.
2688 (while (re-search-forward date-regexp nil t)
2690 (delete-region (progn (beginning-of-line) (point))
2691 (progn (gnus-article-forward-header)
2693 (delete-region (progn (beginning-of-line) (point))
2694 (progn (gnus-article-forward-header)
2697 (setq pos (point))))
2698 (when (and (not pos)
2699 (re-search-forward tdate-regexp nil t))
2703 (insert (article-make-date-line date (or type 'ut)))
2709 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2710 (put-text-property (match-beginning 1) (1+ (match-end 1))
2711 'original-date date)
2712 (put-text-property (match-beginning 1) (1+ (match-end 1))
2714 (put-text-property (match-beginning 2) (match-end 2)
2717 (defun article-make-date-line (date type)
2718 "Return a DATE line of TYPE."
2719 (unless (memq type '(local ut original user iso8601 lapsed english))
2720 (error "Unknown conversion type: %s" type))
2722 (let ((time (date-to-time date)))
2724 ;; Convert to the local timezone.
2726 (let ((tz (car (current-time-zone time))))
2727 (format "Date: %s %s%02d%02d" (current-time-string time)
2728 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2729 (/ (% (abs tz) 3600) 60))))
2730 ;; Convert to Universal Time.
2733 (current-time-string
2734 (let* ((e (parse-time-string date))
2735 (tm (apply 'encode-time e))
2737 (ls (- (cadr tm) (car (current-time-zone time)))))
2738 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2739 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2742 ;; Get the original date from the article.
2743 ((eq type 'original)
2744 (concat "Date: " (if (string-match "\n+$" date)
2745 (substring date 0 (match-beginning 0))
2747 ;; Let the user define the format.
2749 (let ((format (or (condition-case nil
2750 (with-current-buffer gnus-summary-buffer
2751 gnus-article-time-format)
2753 gnus-article-time-format)))
2754 (if (gnus-functionp format)
2755 (funcall format time)
2756 (concat "Date: " (format-time-string format time)))))
2759 (let ((tz (car (current-time-zone time))))
2762 (format-time-string "%Y%m%dT%H%M%S" time)
2763 (format "%s%02d%02d"
2764 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2765 (/ (% (abs tz) 3600) 60)))))
2766 ;; Do an X-Sent lapsed format.
2768 ;; If the date is seriously mangled, the timezone functions are
2769 ;; liable to bug out, so we ignore all errors.
2770 (let* ((now (current-time))
2771 (real-time (subtract-time now time))
2772 (real-sec (and real-time
2773 (+ (* (float (car real-time)) 65536)
2775 (sec (and real-time (abs real-sec)))
2785 ;; This is a bit convoluted, but basically we go
2786 ;; through the time units for years, weeks, etc,
2787 ;; and divide things to see whether that results
2788 ;; in positive answers.
2791 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2792 ;; The (remaining) seconds are too few to
2793 ;; be divided into this time unit.
2795 ;; It's big enough, so we output it.
2796 (setq sec (- sec (* num (cdr unit))))
2798 (concat (if prev ", " "") (int-to-string
2800 " " (symbol-name (car unit))
2801 (if (> num 1) "s" ""))
2803 article-time-units "")
2804 ;; If dates are odd, then it might appear like the
2805 ;; article was sent in the future.
2808 " in the future"))))))
2809 ;; Display the date in proper English
2811 (let ((dtime (decode-time time)))
2814 (number-to-string (nth 3 dtime))
2815 (let ((digit (% (nth 3 dtime) 10)))
2817 ((memq (nth 3 dtime) '(11 12 13)) "th")
2823 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2825 (number-to-string (nth 5 dtime))
2827 (format "%02d" (nth 2 dtime))
2829 (format "%02d" (nth 1 dtime)))))))
2831 (format "Date: %s (from Gnus)" date))))
2833 (defun article-date-local (&optional highlight)
2834 "Convert the current article date to the local timezone."
2835 (interactive (list t))
2836 (article-date-ut 'local highlight))
2838 (defun article-date-english (&optional highlight)
2839 "Convert the current article date to something that is proper English."
2840 (interactive (list t))
2841 (article-date-ut 'english highlight))
2843 (defun article-date-original (&optional highlight)
2844 "Convert the current article date to what it was originally.
2845 This is only useful if you have used some other date conversion
2846 function and want to see what the date was before converting."
2847 (interactive (list t))
2848 (article-date-ut 'original highlight))
2850 (defun article-date-lapsed (&optional highlight)
2851 "Convert the current article date to time lapsed since it was sent."
2852 (interactive (list t))
2853 (article-date-ut 'lapsed highlight))
2855 (defun article-update-date-lapsed ()
2856 "Function to be run from a timer to update the lapsed time line."
2857 (let (deactivate-mark)
2862 (set-buffer (window-buffer w))
2863 (when (eq major-mode 'gnus-article-mode)
2864 (goto-char (point-min))
2865 (when (re-search-forward "^X-Sent:" nil t)
2866 (article-date-lapsed t))))
2869 (defun gnus-start-date-timer (&optional n)
2870 "Start a timer to update the X-Sent header in the article buffers.
2871 The numerical prefix says how frequently (in seconds) the function
2876 (gnus-stop-date-timer)
2877 (setq article-lapsed-timer
2878 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2880 (defun gnus-stop-date-timer ()
2881 "Stop the X-Sent timer."
2883 (when article-lapsed-timer
2884 (nnheader-cancel-timer article-lapsed-timer)
2885 (setq article-lapsed-timer nil)))
2887 (defun article-date-user (&optional highlight)
2888 "Convert the current article date to the user-defined format.
2889 This format is defined by the `gnus-article-time-format' variable."
2890 (interactive (list t))
2891 (article-date-ut 'user highlight))
2893 (defun article-date-iso8601 (&optional highlight)
2894 "Convert the current article date to ISO8601."
2895 (interactive (list t))
2896 (article-date-ut 'iso8601 highlight))
2898 ;; (defun article-show-all ()
2899 ;; "Show all hidden text in the article buffer."
2902 ;; (let ((buffer-read-only nil))
2903 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2905 (defun article-remove-leading-whitespace ()
2906 "Remove excessive whitespace from all headers."
2910 (let ((buffer-read-only nil))
2911 (article-narrow-to-head)
2912 (goto-char (point-min))
2913 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2914 (delete-region (match-beginning 1) (match-end 1)))))))
2916 (defun article-emphasize (&optional arg)
2917 "Emphasize text according to `gnus-emphasis-alist'."
2918 (interactive (gnus-article-hidden-arg))
2919 (unless (gnus-article-check-hidden-text 'emphasis arg)
2923 (with-current-buffer gnus-summary-buffer
2924 gnus-article-emphasis-alist)
2926 gnus-emphasis-alist))
2927 (buffer-read-only nil)
2928 (props (append '(article-type emphasis)
2929 gnus-hidden-properties))
2930 regexp elem beg invisible visible face)
2933 (while (setq elem (pop alist))
2935 (setq regexp (car elem)
2936 invisible (nth 1 elem)
2937 visible (nth 2 elem)
2939 (while (re-search-forward regexp nil t)
2940 (when (and (match-beginning visible) (match-beginning invisible))
2941 (gnus-article-hide-text
2942 (match-beginning invisible) (match-end invisible) props)
2943 (gnus-article-unhide-text-type
2944 (match-beginning visible) (match-end visible) 'emphasis)
2945 (gnus-put-overlay-excluding-newlines
2946 (match-beginning visible) (match-end visible) 'face face)
2947 (gnus-add-wash-type 'emphasis)
2948 (goto-char (match-end invisible)))))))))
2950 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2951 "Setup newsgroup emphasis alist."
2952 (unless gnus-article-emphasis-alist
2953 (let ((name (and gnus-newsgroup-name
2954 (gnus-group-real-name gnus-newsgroup-name))))
2955 (make-local-variable 'gnus-article-emphasis-alist)
2956 (setq gnus-article-emphasis-alist
2958 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2959 (while (setq elem (pop alist))
2960 (when (and name (string-match (car elem) name))
2962 highlight (copy-sequence (cdr elem)))))
2964 (copy-sequence highlight-words)
2965 (if gnus-newsgroup-name
2966 (copy-sequence (gnus-group-find-parameter
2967 gnus-newsgroup-name 'highlight-words t)))
2968 gnus-emphasis-alist)))))
2971 (defvar gnus-summary-article-menu)
2972 (defvar gnus-summary-post-menu))
2974 ;;; Saving functions.
2976 (defun gnus-article-save (save-buffer file &optional num)
2977 "Save the currently selected article."
2978 (unless gnus-save-all-headers
2979 ;; Remove headers according to `gnus-saved-headers'.
2980 (let ((gnus-visible-headers
2981 (or gnus-saved-headers gnus-visible-headers))
2982 (gnus-article-buffer save-buffer))
2984 (set-buffer save-buffer)
2985 (article-hide-headers 1 t))))
2986 (save-window-excursion
2987 (if (not gnus-default-article-saver)
2988 (error "No default saver is defined")
2989 ;; !!! Magic! The saving functions all save
2990 ;; `gnus-save-article-buffer' (or so they think), but we
2991 ;; bind that variable to our save-buffer.
2992 (set-buffer gnus-article-buffer)
2993 (let* ((gnus-save-article-buffer save-buffer)
2996 ((not gnus-prompt-before-saving) 'default)
2997 ((eq gnus-prompt-before-saving 'always) nil)
2999 (gnus-number-of-articles-to-be-saved
3000 (when (eq gnus-prompt-before-saving t)
3002 (set-buffer gnus-article-current-summary)
3003 (funcall gnus-default-article-saver filename)))))
3005 (defun gnus-read-save-file-name (prompt &optional filename
3006 function group headers variable)
3008 (funcall function group headers (symbol-value variable)))
3013 ((eq filename 'default)
3019 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3022 (if (and gnus-number-of-articles-to-be-saved
3023 (> gnus-number-of-articles-to-be-saved 1))
3024 (format "these %d articles"
3025 gnus-number-of-articles-to-be-saved)
3028 ;; Let the split methods have their say.
3030 ;; No split name was found.
3033 (concat prompt " (default "
3034 (file-name-nondirectory default-name) ") ")
3035 (file-name-directory default-name)
3037 ;; A single group name is returned.
3038 ((stringp split-name)
3040 (funcall function split-name headers
3041 (symbol-value variable)))
3043 (concat prompt " (default "
3044 (file-name-nondirectory default-name) ") ")
3045 (file-name-directory default-name)
3047 ;; A single split name was found
3048 ((= 1 (length split-name))
3049 (let* ((name (expand-file-name
3051 gnus-article-save-directory))
3052 (dir (cond ((file-directory-p name)
3053 (file-name-as-directory name))
3054 ((file-exists-p name) name)
3055 (t gnus-article-save-directory))))
3057 (concat prompt " (default " name ") ")
3059 ;; A list of splits was found.
3061 (setq split-name (nreverse split-name))
3063 (let ((file-name-history
3064 (nconc split-name file-name-history)))
3068 (concat prompt " (`M-p' for defaults) ")
3069 gnus-article-save-directory
3071 gnus-article-save-directory)))
3072 (car (push result file-name-history)))))))
3073 ;; Create the directory.
3074 (gnus-make-directory (file-name-directory file))
3075 ;; If we have read a directory, we append the default file name.
3076 (when (file-directory-p file)
3077 (setq file (expand-file-name (file-name-nondirectory
3079 (file-name-as-directory file))))
3080 ;; Possibly translate some characters.
3081 (nnheader-translate-file-chars file))))))
3082 (gnus-make-directory (file-name-directory result))
3083 (set variable result)))
3085 (defun gnus-article-archive-name (group)
3086 "Return the first instance of an \"Archive-name\" in the current buffer."
3087 (let ((case-fold-search t))
3088 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3089 (nnheader-concat gnus-article-save-directory
3090 (match-string 1)))))
3092 (defun gnus-article-nndoc-name (group)
3093 "If GROUP is an nndoc group, return the name of the parent group."
3094 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3095 (gnus-group-get-parameter group 'save-article-group)))
3097 (defun gnus-summary-save-in-rmail (&optional filename)
3098 "Append this article to Rmail file.
3099 Optional argument FILENAME specifies file name.
3100 Directory to save to is default to `gnus-article-save-directory'."
3101 (setq filename (gnus-read-save-file-name
3102 "Save %s in rmail file:" filename
3103 gnus-rmail-save-name gnus-newsgroup-name
3104 gnus-current-headers 'gnus-newsgroup-last-rmail))
3105 (gnus-eval-in-buffer-window gnus-save-article-buffer
3109 (gnus-output-to-rmail filename))))
3112 (defun gnus-summary-save-in-mail (&optional filename)
3113 "Append this article to Unix mail file.
3114 Optional argument FILENAME specifies file name.
3115 Directory to save to is default to `gnus-article-save-directory'."
3116 (setq filename (gnus-read-save-file-name
3117 "Save %s in Unix mail file:" filename
3118 gnus-mail-save-name gnus-newsgroup-name
3119 gnus-current-headers 'gnus-newsgroup-last-mail))
3120 (gnus-eval-in-buffer-window gnus-save-article-buffer
3124 (if (and (file-readable-p filename)
3125 (file-regular-p filename)
3126 (mail-file-babyl-p filename))
3127 (rmail-output-to-rmail-file filename t)
3128 (gnus-output-to-mail filename)))))
3131 (defun gnus-summary-save-in-file (&optional filename overwrite)
3132 "Append this article to file.
3133 Optional argument FILENAME specifies file name.
3134 Directory to save to is default to `gnus-article-save-directory'."
3135 (setq filename (gnus-read-save-file-name
3136 "Save %s in file:" filename
3137 gnus-file-save-name gnus-newsgroup-name
3138 gnus-current-headers 'gnus-newsgroup-last-file))
3139 (gnus-eval-in-buffer-window gnus-save-article-buffer
3143 (when (and overwrite
3144 (file-exists-p filename))
3145 (delete-file filename))
3146 (gnus-output-to-file filename))))
3149 (defun gnus-summary-write-to-file (&optional filename)
3150 "Write this article to a file, overwriting it if the file exists.
3151 Optional argument FILENAME specifies file name.
3152 The directory to save in defaults to `gnus-article-save-directory'."
3153 (gnus-summary-save-in-file nil t))
3155 (defun gnus-summary-save-body-in-file (&optional filename)
3156 "Append this article body to a file.
3157 Optional argument FILENAME specifies file name.
3158 The directory to save in defaults to `gnus-article-save-directory'."
3159 (setq filename (gnus-read-save-file-name
3160 "Save %s body in file:" filename
3161 gnus-file-save-name gnus-newsgroup-name
3162 gnus-current-headers 'gnus-newsgroup-last-file))
3163 (gnus-eval-in-buffer-window gnus-save-article-buffer
3167 (when (article-goto-body)
3168 (narrow-to-region (point) (point-max)))
3169 (gnus-output-to-file filename))))
3172 (defun gnus-summary-save-in-pipe (&optional command)
3173 "Pipe this article to subprocess."
3175 (cond ((and (eq command 'default)
3176 gnus-last-shell-command)
3177 gnus-last-shell-command)
3182 "Shell command on %s: "
3183 (if (and gnus-number-of-articles-to-be-saved
3184 (> gnus-number-of-articles-to-be-saved 1))
3185 (format "these %d articles"
3186 gnus-number-of-articles-to-be-saved)
3188 gnus-last-shell-command))))
3189 (when (string-equal command "")
3190 (if gnus-last-shell-command
3191 (setq command gnus-last-shell-command)
3192 (error "A command is required")))
3193 (gnus-eval-in-buffer-window gnus-article-buffer
3196 (shell-command-on-region (point-min) (point-max) command nil)))
3197 (setq gnus-last-shell-command command))
3199 (defun gnus-summary-pipe-to-muttprint (&optional command)
3200 "Pipe this article to muttprint."
3201 (setq command (read-string
3202 "Print using command: " gnus-summary-muttprint-program
3203 nil gnus-summary-muttprint-program))
3204 (gnus-summary-save-in-pipe command))
3206 ;;; Article file names when saving.
3208 (defun gnus-capitalize-newsgroup (newsgroup)
3209 "Capitalize NEWSGROUP name."
3210 (when (not (zerop (length newsgroup)))
3211 (concat (char-to-string (upcase (aref newsgroup 0)))
3212 (substring newsgroup 1))))
3214 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3215 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3216 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3217 Otherwise, it is like ~/News/news/group/num."
3220 (concat (if (gnus-use-long-file-name 'not-save)
3221 (gnus-capitalize-newsgroup newsgroup)
3222 (gnus-newsgroup-directory-form newsgroup))
3223 "/" (int-to-string (mail-header-number headers)))
3224 gnus-article-save-directory)))
3226 (string-equal (file-name-directory default)
3227 (file-name-directory last-file))
3228 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3230 (or last-file default))))
3232 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3233 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3234 If variable `gnus-use-long-file-name' is non-nil, it is
3235 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3238 (concat (if (gnus-use-long-file-name 'not-save)
3240 (gnus-newsgroup-directory-form newsgroup))
3241 "/" (int-to-string (mail-header-number headers)))
3242 gnus-article-save-directory)))
3244 (string-equal (file-name-directory default)
3245 (file-name-directory last-file))
3246 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3248 (or last-file default))))
3250 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3251 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3252 If variable `gnus-use-long-file-name' is non-nil, it is
3253 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3256 (if (gnus-use-long-file-name 'not-save)
3259 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3261 gnus-article-save-directory)))
3263 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3264 "Generate file name from sender."
3265 (let ((from (mail-header-from headers)))
3267 (if (and from (string-match "\\([^ <]+\\)@" from))
3268 (match-string 1 from)
3270 gnus-article-save-directory)))
3272 (defun article-verify-x-pgp-sig ()
3275 (if (gnus-buffer-live-p gnus-original-article-buffer)
3276 (let ((sig (with-current-buffer gnus-original-article-buffer
3277 (gnus-fetch-field "X-PGP-Sig")))
3281 (mml2015-clear-verify-function))
3283 (insert-buffer gnus-original-article-buffer)
3284 (setq items (split-string sig))
3285 (message-narrow-to-head)
3286 (let ((inhibit-point-motion-hooks t)
3287 (case-fold-search t))
3288 ;; Don't verify multiple headers.
3289 (setq headers (mapconcat (lambda (header)
3291 (mail-fetch-field header) "\n"))
3292 (split-string (nth 1 items) ",") "")))
3293 (delete-region (point-min) (point-max))
3294 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3295 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3300 (if (looking-at "^-")
3303 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3304 (insert "Version: " (car items) "\n\n")
3305 (insert (mapconcat 'identity (cddr items) "\n"))
3306 (insert "\n-----END PGP SIGNATURE-----\n")
3307 (let ((mm-security-handle (list (format "multipart/signed"))))
3308 (mml2015-clean-buffer)
3309 (let ((coding-system-for-write (or gnus-newsgroup-charset
3311 (funcall (mml2015-clear-verify-function)))
3313 (or (mm-handle-multipart-ctl-parameter
3314 mm-security-handle 'gnus-details)
3315 (mm-handle-multipart-ctl-parameter
3316 mm-security-handle 'gnus-info)))))
3318 (let (buffer-read-only bface eface)
3320 (message-narrow-to-head)
3321 (goto-char (point-max))
3323 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3324 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3325 (message-remove-header "X-Gnus-PGP-Verify")
3326 (if (re-search-forward "^X-PGP-Sig:" nil t)
3328 (goto-char (point-max)))
3329 (narrow-to-region (point) (point))
3330 (insert "X-Gnus-PGP-Verify: " info "\n")
3331 (goto-char (point-min))
3334 (if (not (looking-at "^[ \t]"))
3338 (goto-char (point-min))
3339 (when (looking-at "\\([^:]+\\): *")
3340 (put-text-property (match-beginning 1) (1+ (match-end 1))
3342 (put-text-property (match-end 0) (point-max)
3343 'face eface)))))))))
3345 (defun article-verify-cancel-lock ()
3346 "Verify Cancel-Lock header."
3348 (if (gnus-buffer-live-p gnus-original-article-buffer)
3349 (canlock-verify gnus-original-article-buffer)))
3356 (setq afunc (car func)
3359 gfunc (intern (format "gnus-%s" func))))
3361 (when (fboundp afunc)
3362 `(lambda (&optional interactive &rest args)
3363 ,(documentation afunc t)
3364 (interactive (list t))
3366 (set-buffer gnus-article-buffer)
3368 (call-interactively ',afunc)
3369 (apply ',afunc args))))))))
3370 '(article-hide-headers
3371 article-verify-x-pgp-sig
3372 article-verify-cancel-lock
3373 article-hide-boring-headers
3374 article-treat-overstrike
3375 article-fill-long-lines
3376 article-capitalize-sentences
3378 article-remove-leading-whitespace
3379 article-display-x-face
3380 article-display-face
3381 article-de-quoted-unreadable
3382 article-de-base64-unreadable
3385 article-unsplit-urls
3386 article-hide-list-identifiers
3387 article-strip-banner
3390 article-hide-signature
3391 article-strip-headers-in-body
3392 article-remove-trailing-blank-lines
3393 article-strip-leading-blank-lines
3394 article-strip-multiple-blank-lines
3395 article-strip-leading-space
3396 article-strip-trailing-space
3397 article-strip-blank-lines
3398 article-strip-all-blank-lines
3400 article-date-english
3401 article-date-iso8601
3402 article-date-original
3404 article-decode-mime-words
3405 article-decode-charset
3406 article-decode-encoded-words
3410 article-treat-dumbquotes
3411 article-normalize-headers
3412 ;; (article-show-all . gnus-article-show-all-headers)
3416 ;;; Gnus article mode
3419 (put 'gnus-article-mode 'mode-class 'special)
3421 (set-keymap-parent gnus-article-mode-map widget-keymap)
3423 (gnus-define-keys gnus-article-mode-map
3424 " " gnus-article-goto-next-page
3425 "\177" gnus-article-goto-prev-page
3426 [delete] gnus-article-goto-prev-page
3427 [backspace] gnus-article-goto-prev-page
3428 "\C-c^" gnus-article-refer-article
3429 "h" gnus-article-show-summary
3430 "s" gnus-article-show-summary
3431 "\C-c\C-m" gnus-article-mail
3432 "?" gnus-article-describe-briefly
3433 "e" gnus-summary-edit-article
3434 "<" beginning-of-buffer
3436 "\C-c\C-i" gnus-info-find-node
3438 "R" gnus-article-reply-with-original
3439 "F" gnus-article-followup-with-original
3440 "\C-hk" gnus-article-describe-key
3441 "\C-hc" gnus-article-describe-key-briefly
3443 "\C-d" gnus-article-read-summary-keys
3444 "\M-*" gnus-article-read-summary-keys
3445 "\M-#" gnus-article-read-summary-keys
3446 "\M-^" gnus-article-read-summary-keys
3447 "\M-g" gnus-article-read-summary-keys)
3449 (substitute-key-definition
3450 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3452 (defun gnus-article-make-menu-bar ()
3453 (unless (boundp 'gnus-article-commands-menu)
3454 (gnus-summary-make-menu-bar))
3455 (gnus-turn-off-edit-menu 'article)
3456 (unless (boundp 'gnus-article-article-menu)
3458 gnus-article-article-menu gnus-article-mode-map ""
3460 ["Scroll forwards" gnus-article-goto-next-page t]
3461 ["Scroll backwards" gnus-article-goto-prev-page t]
3462 ["Show summary" gnus-article-show-summary t]
3463 ["Fetch Message-ID at point" gnus-article-refer-article t]
3464 ["Mail to address at point" gnus-article-mail t]
3465 ["Send a bug report" gnus-bug t]))
3468 gnus-article-treatment-menu gnus-article-mode-map ""
3469 ;; Fixme: this should use :active (and maybe :visible).
3471 ["Hide headers" gnus-article-hide-headers t]
3472 ["Hide signature" gnus-article-hide-signature t]
3473 ["Hide citation" gnus-article-hide-citation t]
3474 ["Treat overstrike" gnus-article-treat-overstrike t]
3475 ["Remove carriage return" gnus-article-remove-cr t]
3476 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3477 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3478 ["Remove base64" gnus-article-de-base64-unreadable t]
3479 ["Treat html" gnus-article-wash-html t]
3480 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3481 ["Decode HZ" gnus-article-decode-HZ t]))
3483 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3485 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3487 (gnus-run-hooks 'gnus-article-menu-hook)))
3489 (defun gnus-article-mode ()
3490 "Major mode for displaying an article.
3492 All normal editing commands are switched off.
3494 The following commands are available in addition to all summary mode
3496 \\<gnus-article-mode-map>
3497 \\[gnus-article-next-page]\t Scroll the article one page forwards
3498 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3499 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3500 \\[gnus-article-show-summary]\t Display the summary buffer
3501 \\[gnus-article-mail]\t Send a reply to the address near point
3502 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3503 \\[gnus-info-find-node]\t Go to the Gnus info node"
3505 (gnus-simplify-mode-line)
3506 (setq mode-name "Article")
3507 (setq major-mode 'gnus-article-mode)
3508 (make-local-variable 'minor-mode-alist)
3509 (use-local-map gnus-article-mode-map)
3510 (when (gnus-visual-p 'article-menu 'menu)
3511 (gnus-article-make-menu-bar)
3512 (when gnus-summary-tool-bar-map
3513 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3514 (gnus-update-format-specifications nil 'article-mode)
3515 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3516 (make-local-variable 'gnus-page-broken)
3517 (make-local-variable 'gnus-button-marker-list)
3518 (make-local-variable 'gnus-article-current-summary)
3519 (make-local-variable 'gnus-article-mime-handles)
3520 (make-local-variable 'gnus-article-decoded-p)
3521 (make-local-variable 'gnus-article-mime-handle-alist)
3522 (make-local-variable 'gnus-article-wash-types)
3523 (make-local-variable 'gnus-article-image-alist)
3524 (make-local-variable 'gnus-article-charset)
3525 (make-local-variable 'gnus-article-ignored-charsets)
3526 (gnus-set-default-directory)
3527 (buffer-disable-undo)
3528 (setq buffer-read-only t)
3529 (set-syntax-table gnus-article-mode-syntax-table)
3530 (mm-enable-multibyte)
3531 (gnus-run-hooks 'gnus-article-mode-hook))
3533 (defun gnus-article-setup-buffer ()
3534 "Initialize the article buffer."
3535 (let* ((name (if gnus-single-article-buffer "*Article*"
3536 (concat "*Article " gnus-newsgroup-name "*")))
3538 (progn (string-match "\\*Article" name)
3539 (concat " *Original Article"
3540 (substring name (match-end 0))))))
3541 (setq gnus-article-buffer name)
3542 (setq gnus-original-article-buffer original)
3543 (setq gnus-article-mime-handle-alist nil)
3544 ;; This might be a variable local to the summary buffer.
3545 (unless gnus-single-article-buffer
3547 (set-buffer gnus-summary-buffer)
3548 (setq gnus-article-buffer name)
3549 (setq gnus-original-article-buffer original)
3550 (gnus-set-global-variables)))
3551 (gnus-article-setup-highlight-words)
3552 ;; Init original article buffer.
3554 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3555 (mm-enable-multibyte)
3556 (setq major-mode 'gnus-original-article-mode)
3557 (make-local-variable 'gnus-original-article))
3558 (if (get-buffer name)
3561 (when (and gnus-article-edit-mode
3564 (y-or-n-p "Article mode edit in progress; discard? ")))
3565 (error "Action aborted"))
3566 (set (make-local-variable 'gnus-article-edit-mode) nil)
3567 (when gnus-article-mime-handles
3568 (mm-destroy-parts gnus-article-mime-handles)
3569 (setq gnus-article-mime-handles nil))
3570 ;; Set it to nil in article-buffer!
3571 (setq gnus-article-mime-handle-alist nil)
3572 (buffer-disable-undo)
3573 (setq buffer-read-only t)
3574 ;; This list just keeps growing if we don't reset it.
3575 (setq gnus-button-marker-list nil)
3576 (unless (eq major-mode 'gnus-article-mode)
3577 (gnus-article-mode))
3580 (set-buffer (gnus-get-buffer-create name))
3582 (make-local-variable 'gnus-summary-buffer)
3583 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3584 (current-buffer)))))
3586 ;; Set article window start at LINE, where LINE is the number of lines
3587 ;; from the head of the article.
3588 (defun gnus-article-set-window-start (&optional line)
3590 (gnus-get-buffer-window gnus-article-buffer t)
3592 (set-buffer gnus-article-buffer)
3593 (goto-char (point-min))
3596 (gnus-message 6 "Moved to bookmark")
3597 (search-forward "\n\n" nil t)
3601 (defun gnus-article-prepare (article &optional all-headers header)
3602 "Prepare ARTICLE in article mode buffer.
3603 ARTICLE should either be an article number or a Message-ID.
3604 If ARTICLE is an id, HEADER should be the article headers.
3605 If ALL-HEADERS is non-nil, no headers are hidden."
3607 ;; Make sure we start in a summary buffer.
3608 (unless (eq major-mode 'gnus-summary-mode)
3609 (set-buffer gnus-summary-buffer))
3610 (setq gnus-summary-buffer (current-buffer))
3611 (let* ((gnus-article (if header (mail-header-number header) article))
3612 (summary-buffer (current-buffer))
3613 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3614 (group gnus-newsgroup-name)
3617 (gnus-article-setup-buffer)
3618 (set-buffer gnus-article-buffer)
3619 ;; Deactivate active regions.
3620 (when (and (boundp 'transient-mark-mode)
3621 transient-mark-mode)
3622 (setq mark-active nil))
3623 (if (not (setq result (let ((buffer-read-only nil))
3624 (gnus-request-article-this-buffer
3626 ;; There is no such article.
3628 (when (and (numberp article)
3629 (not (memq article gnus-newsgroup-sparse)))
3630 (setq gnus-article-current
3631 (cons gnus-newsgroup-name article))
3632 (set-buffer gnus-summary-buffer)
3633 (setq gnus-current-article article)
3634 (if (and (memq article gnus-newsgroup-undownloaded)
3635 (not (gnus-online (gnus-find-method-for-group
3636 gnus-newsgroup-name))))
3638 (gnus-summary-set-agent-mark article)
3639 (message "Message marked for downloading"))
3640 (gnus-summary-mark-article article gnus-canceled-mark)
3641 (unless (memq article gnus-newsgroup-sparse)
3642 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3643 (if (or (eq result 'pseudo)
3644 (eq result 'nneething))
3647 (set-buffer summary-buffer)
3648 (push article gnus-newsgroup-history)
3649 (setq gnus-last-article gnus-current-article
3650 gnus-current-article 0
3651 gnus-current-headers nil
3652 gnus-article-current nil)
3653 (if (eq result 'nneething)
3654 (gnus-configure-windows 'summary)
3655 (gnus-configure-windows 'article))
3656 (gnus-set-global-variables))
3657 (let ((gnus-article-mime-handle-alist-1
3658 gnus-article-mime-handle-alist))
3659 (gnus-set-mode-line 'article)))
3660 ;; The result from the `request' was an actual article -
3661 ;; or at least some text that is now displayed in the
3663 (when (and (numberp article)
3664 (not (eq article gnus-current-article)))
3665 ;; Seems like a new article has been selected.
3666 ;; `gnus-current-article' must be an article number.
3668 (set-buffer summary-buffer)
3669 (push article gnus-newsgroup-history)
3670 (setq gnus-last-article gnus-current-article
3671 gnus-current-article article
3672 gnus-current-headers
3673 (gnus-summary-article-header gnus-current-article)
3674 gnus-article-current
3675 (cons gnus-newsgroup-name gnus-current-article))
3676 (unless (vectorp gnus-current-headers)
3677 (setq gnus-current-headers nil))
3678 (gnus-summary-goto-subject gnus-current-article)
3679 (when (gnus-summary-show-thread)
3680 ;; If the summary buffer really was folded, the
3681 ;; previous goto may not actually have gone to
3682 ;; the right article, but the thread root instead.
3684 (gnus-summary-goto-subject gnus-current-article))
3685 (gnus-run-hooks 'gnus-mark-article-hook)
3686 (gnus-set-mode-line 'summary)
3687 (when (gnus-visual-p 'article-highlight 'highlight)
3688 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3689 ;; Set the global newsgroup variables here.
3690 (gnus-set-global-variables)
3691 (setq gnus-have-all-headers
3692 (or all-headers gnus-show-all-headers))))
3694 (gnus-configure-windows 'article))
3695 (when (or (numberp article)
3697 (gnus-article-prepare-display)
3699 (goto-char (point-min))
3700 (setq gnus-page-broken
3701 (when gnus-break-pages
3702 (gnus-narrow-to-page)
3704 (let ((gnus-article-mime-handle-alist-1
3705 gnus-article-mime-handle-alist))
3706 (gnus-set-mode-line 'article))
3710 (set-window-point (get-buffer-window (current-buffer)) (point))
3711 (gnus-configure-windows 'article)
3715 (defun gnus-article-prepare-display ()
3716 "Make the current buffer look like a nice article."
3717 ;; Hooks for getting information from the article.
3718 ;; This hook must be called before being narrowed.
3719 (let ((gnus-article-buffer (current-buffer))
3721 (unless (eq major-mode 'gnus-article-mode)
3722 (gnus-article-mode))
3723 (setq buffer-read-only nil
3724 gnus-article-wash-types nil
3725 gnus-article-image-alist nil)
3726 (gnus-run-hooks 'gnus-tmp-internal-hook)
3727 (when gnus-display-mime-function
3728 (funcall gnus-display-mime-function))
3729 (gnus-run-hooks 'gnus-article-prepare-hook)))
3732 ;;; Gnus MIME viewing functions
3735 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3736 "Format of the MIME buttons.
3738 Valid specifiers include:
3740 %T MIME type, along with additional info
3741 %n The `name' parameter
3742 %d The description, if any
3743 %l The length of the encoded part
3744 %p The part identifier number
3745 %e Dots if the part isn't displayed
3747 General format specifiers can also be used. See Info node
3748 `(gnus)Formatting Variables'.")
3750 (defvar gnus-mime-button-line-format-alist
3751 '((?t gnus-tmp-type ?s)
3752 (?T gnus-tmp-type-long ?s)
3753 (?n gnus-tmp-name ?s)
3754 (?d gnus-tmp-description ?s)
3756 (?l gnus-tmp-length ?d)
3757 (?e gnus-tmp-dots ?s)))
3759 (defvar gnus-mime-button-commands
3760 '((gnus-article-press-button "\r" "Toggle Display")
3761 (gnus-mime-view-part "v" "View Interactively...")
3762 (gnus-mime-view-part-as-type "t" "View As Type...")
3763 (gnus-mime-view-part-as-charset "C" "View As charset...")
3764 (gnus-mime-save-part "o" "Save...")
3765 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3766 (gnus-mime-delete-part "d" "Delete part")
3767 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3768 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3769 (gnus-mime-view-part-internally "E" "View Internally")
3770 (gnus-mime-view-part-externally "e" "View Externally")
3771 (gnus-mime-print-part "p" "Print")
3772 (gnus-mime-pipe-part "|" "Pipe To Command...")
3773 (gnus-mime-action-on-part "." "Take action on the part...")))
3775 (defun gnus-article-mime-part-status ()
3776 (if gnus-article-mime-handle-alist-1
3777 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3779 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3782 (defvar gnus-mime-button-map
3783 (let ((map (make-sparse-keymap)))
3784 (unless (>= (string-to-number emacs-version) 21)
3785 ;; XEmacs doesn't care.
3786 (set-keymap-parent map gnus-article-mode-map))
3787 (define-key map gnus-mouse-2 'gnus-article-push-button)
3788 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3789 (dolist (c gnus-mime-button-commands)
3790 (define-key map (cadr c) (car c)))
3793 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3795 ,@(mapcar (lambda (c)
3796 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
3799 (define-compiler-macro popup-menu (&whole form
3800 menu &optional position prefix)
3801 (if (and (fboundp 'popup-menu)
3802 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3804 ;; Gnus is probably running under Emacs 20.
3805 `(let* ((menu (cdr ,menu))
3806 (response (x-popup-menu
3808 (cons "" (mapcar (lambda (c)
3809 (cons (caddr c) (car c)))
3812 (call-interactively (nth 3 (assq response menu))))))))
3814 (defun gnus-mime-button-menu (event prefix)
3815 "Construct a context-sensitive menu of MIME commands."
3816 (interactive "e\nP")
3817 (save-window-excursion
3818 (let ((pos (event-start event)))
3819 (select-window (posn-window pos))
3820 (goto-char (posn-point pos))
3821 (gnus-article-check-buffer)
3822 (popup-menu gnus-mime-button-menu nil prefix))))
3824 (defun gnus-mime-view-all-parts (&optional handles)
3825 "View all the MIME parts."
3827 (save-current-buffer
3828 (set-buffer gnus-article-buffer)
3829 (let ((handles (or handles gnus-article-mime-handles))
3830 (mail-parse-charset gnus-newsgroup-charset)
3831 (mail-parse-ignored-charsets
3832 (with-current-buffer gnus-summary-buffer
3833 gnus-newsgroup-ignored-charsets)))
3835 (mm-remove-parts handles)
3836 (goto-char (point-min))
3837 (or (search-forward "\n\n") (goto-char (point-max)))
3838 (let (buffer-read-only)
3839 (delete-region (point) (point-max))
3840 (mm-display-parts handles))))))
3842 (defun gnus-mime-save-part-and-strip ()
3843 "Save the MIME part under point then replace it with an external body."
3845 (gnus-article-check-buffer)
3846 (let* ((data (get-text-property (point) 'gnus-data))
3848 (handles gnus-article-mime-handles))
3849 (if (mm-multiple-handles gnus-article-mime-handles)
3850 (error "This function is not implemented"))
3851 (setq file (and data (mm-save-part data)))
3853 (with-current-buffer (mm-handle-buffer data)
3855 (insert "Content-Type: " (mm-handle-media-type data))
3856 (mml-insert-parameter-string (cdr (mm-handle-type data))
3859 (insert "Content-ID: " (message-make-message-id) "\n")
3860 (insert "Content-Transfer-Encoding: binary\n")
3863 (cdr (mm-make-handle nil
3864 `("message/external-body"
3865 (access-type . "LOCAL-FILE")
3867 (set-buffer gnus-summary-buffer)
3868 (gnus-article-edit-article
3871 (let ((mail-parse-charset (or gnus-article-charset
3872 ',gnus-newsgroup-charset))
3873 (mail-parse-ignored-charsets
3874 (or gnus-article-ignored-charsets
3875 ',gnus-newsgroup-ignored-charsets))
3876 (mbl mml-buffer-list))
3877 (setq mml-buffer-list nil)
3878 (insert-buffer gnus-original-article-buffer)
3879 (mime-to-mml ',handles)
3880 (setq gnus-article-mime-handles nil)
3881 (let ((mbl1 mml-buffer-list))
3882 (setq mml-buffer-list mbl)
3883 (set (make-local-variable 'mml-buffer-list) mbl1))
3884 ;; LOCAL argument of add-hook differs between GNU Emacs
3885 ;; and XEmacs. make-local-hook makes sure they are local.
3886 (make-local-hook 'kill-buffer-hook)
3887 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3888 `(lambda (no-highlight)
3889 (let ((mail-parse-charset (or gnus-article-charset
3890 ',gnus-newsgroup-charset))
3891 (message-options message-options)
3892 (message-options-set-recipient)
3893 (mail-parse-ignored-charsets
3894 (or gnus-article-ignored-charsets
3895 ',gnus-newsgroup-ignored-charsets)))
3897 (mml-destroy-buffers)
3898 (remove-hook 'kill-buffer-hook
3899 'mml-destroy-buffers t)
3900 (kill-local-variable 'mml-buffer-list))
3901 (gnus-summary-edit-article-done
3902 ,(or (mail-header-references gnus-current-headers) "")
3903 ,(gnus-group-read-only-p)
3904 ,gnus-summary-buffer no-highlight))))))
3906 (defun gnus-mime-delete-part ()
3907 "Delete the MIME part under point.
3908 Replace it with some information about the removed part."
3910 (gnus-article-check-buffer)
3911 (let* ((data (get-text-property (point) 'gnus-data))
3912 (handles gnus-article-mime-handles)
3916 (mail-decode-encoded-word-string (or (mm-handle-description data)
3919 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
3921 (type (mm-handle-media-type data)))
3922 (if (mm-multiple-handles gnus-article-mime-handles)
3923 (error "This function is not implemented"))
3924 (with-current-buffer (mm-handle-buffer data)
3925 (let ((bsize (format "%s" (buffer-size))))
3929 "<#part type=text/plain nofile=yes disposition=attachment"
3930 " description=\"Deleted attachment (" bsize " Byte)\">"
3932 "| The following attachment has been deleted:\n"
3934 "| Type: " type "\n"
3935 "| Filename: " filename "\n"
3936 "| Size (encoded): " bsize " Byte\n"
3937 "| Description: " description "\n"
3941 (cdr (mm-make-handle nil `("text/plain"))))))
3942 (set-buffer gnus-summary-buffer)
3943 ;; FIXME: maybe some of the following code (borrowed from
3944 ;; `gnus-mime-save-part-and-strip') isn't necessary?
3945 (gnus-article-edit-article
3948 (let ((mail-parse-charset (or gnus-article-charset
3949 ',gnus-newsgroup-charset))
3950 (mail-parse-ignored-charsets
3951 (or gnus-article-ignored-charsets
3952 ',gnus-newsgroup-ignored-charsets))
3953 (mbl mml-buffer-list))
3954 (setq mml-buffer-list nil)
3955 (insert-buffer gnus-original-article-buffer)
3956 (mime-to-mml ',handles)
3957 (setq gnus-article-mime-handles nil)
3958 (let ((mbl1 mml-buffer-list))
3959 (setq mml-buffer-list mbl)
3960 (set (make-local-variable 'mml-buffer-list) mbl1))
3961 ;; LOCAL argument of add-hook differs between GNU Emacs
3962 ;; and XEmacs. make-local-hook makes sure they are local.
3963 (make-local-hook 'kill-buffer-hook)
3964 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3965 `(lambda (no-highlight)
3966 (let ((mail-parse-charset (or gnus-article-charset
3967 ',gnus-newsgroup-charset))
3968 (message-options message-options)
3969 (message-options-set-recipient)
3970 (mail-parse-ignored-charsets
3971 (or gnus-article-ignored-charsets
3972 ',gnus-newsgroup-ignored-charsets)))
3974 (mml-destroy-buffers)
3975 (remove-hook 'kill-buffer-hook
3976 'mml-destroy-buffers t)
3977 (kill-local-variable 'mml-buffer-list))
3978 (gnus-summary-edit-article-done
3979 ,(or (mail-header-references gnus-current-headers) "")
3980 ,(gnus-group-read-only-p)
3981 ,gnus-summary-buffer no-highlight))))
3982 ;; Not in `gnus-mime-save-part-and-strip':
3983 (gnus-article-edit-done)
3984 (gnus-summary-expand-window)
3985 (gnus-summary-show-article))
3987 (defun gnus-mime-save-part ()
3988 "Save the MIME part under point."
3990 (gnus-article-check-buffer)
3991 (let ((data (get-text-property (point) 'gnus-data)))
3993 (mm-save-part data))))
3995 (defun gnus-mime-pipe-part ()
3996 "Pipe the MIME part under point to a process."
3998 (gnus-article-check-buffer)
3999 (let ((data (get-text-property (point) 'gnus-data)))
4001 (mm-pipe-part data))))
4003 (defun gnus-mime-view-part ()
4004 "Interactively choose a viewing method for the MIME part under point."
4006 (gnus-article-check-buffer)
4007 (let ((data (get-text-property (point) 'gnus-data)))
4009 (setq gnus-article-mime-handles
4011 gnus-article-mime-handles (setq data (copy-sequence data))))
4012 (mm-interactively-view-part data))))
4014 (defun gnus-mime-view-part-as-type-internal ()
4015 (gnus-article-check-buffer)
4016 (let* ((name (mail-content-type-get
4017 (mm-handle-type (get-text-property (point) 'gnus-data))
4019 (def-type (and name (mm-default-file-encoding name))))
4020 (and def-type (cons def-type 0))))
4022 (defun gnus-mime-view-part-as-type (&optional mime-type)
4023 "Choose a MIME media type, and view the part as such."
4026 (setq mime-type (completing-read
4027 "View as MIME type: "
4028 (mapcar #'list (mailcap-mime-types))
4030 (gnus-mime-view-part-as-type-internal))))
4031 (gnus-article-check-buffer)
4032 (let ((handle (get-text-property (point) 'gnus-data)))
4035 (mm-make-handle (mm-handle-buffer handle)
4036 (cons mime-type (cdr (mm-handle-type handle)))
4037 (mm-handle-encoding handle)
4038 (mm-handle-undisplayer handle)
4039 (mm-handle-disposition handle)
4040 (mm-handle-description handle)
4042 (mm-handle-id handle)))
4043 (setq gnus-article-mime-handles
4044 (mm-merge-handles gnus-article-mime-handles handle))
4045 (gnus-mm-display-part handle))))
4048 (require 'jka-compr))
4050 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4051 ;; emacs can do that itself.
4053 (defun gnus-mime-jka-compr-maybe-uncompress ()
4054 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4055 The uncompress method used is derived from `buffer-file-name'."
4056 (when (and (fboundp 'jka-compr-installed-p)
4057 (jka-compr-installed-p))
4058 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4060 (let ((basename (file-name-nondirectory buffer-file-name))
4061 (args (jka-compr-info-uncompress-args info))
4062 (prog (jka-compr-info-uncompress-program info))
4063 (message (jka-compr-info-uncompress-message info))
4064 (err-file (jka-compr-make-temp-name)))
4066 (message "%s %s..." message basename))
4068 (unless (memq (apply 'call-process-region
4069 (point-min) (point-max)
4071 t (list t err-file) nil
4073 jka-compr-acceptable-retval-list)
4074 (jka-compr-error prog args basename message err-file))
4075 (jka-compr-delete-temp-file err-file)))))))
4077 (defun gnus-mime-copy-part (&optional handle)
4078 "Put the MIME part under point into a new buffer.
4079 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4082 (gnus-article-check-buffer)
4083 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4084 (contents (and handle (mm-get-part handle)))
4086 (file-name-nondirectory
4088 (mail-content-type-get (mm-handle-type handle) 'name)
4089 (mail-content-type-get (mm-handle-disposition handle)
4092 (buffer (and base (generate-new-buffer base))))
4094 (switch-to-buffer buffer)
4096 ;; We do it this way to make `normal-mode' set the appropriate mode.
4099 (setq buffer-file-name (expand-file-name base))
4100 (gnus-mime-jka-compr-maybe-uncompress)
4102 (setq buffer-file-name nil))
4103 (goto-char (point-min)))))
4105 (defun gnus-mime-print-part (&optional handle filename)
4106 "Print the MIME part under point."
4107 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4108 (gnus-article-check-buffer)
4109 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4110 (contents (and handle (mm-get-part handle)))
4111 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4112 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4117 (mm-save-part-to-file handle file)
4118 (call-process shell-file-name nil
4119 (generate-new-buffer " *mm*")
4121 shell-command-switch
4123 printer file (mm-handle-type handle))))
4127 (gnus-print-buffer))
4128 (ps-despool filename)))))
4130 (defun gnus-mime-inline-part (&optional handle arg)
4131 "Insert the MIME part under point into the current buffer."
4132 (interactive (list nil current-prefix-arg))
4133 (gnus-article-check-buffer)
4134 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4139 (if (and (not arg) (mm-handle-undisplayer handle))
4140 (mm-remove-part handle)
4141 (setq contents (mm-get-part handle))
4144 (setq charset (or (mail-content-type-get
4145 (mm-handle-type handle) 'charset)
4146 gnus-newsgroup-charset)))
4148 (if (mm-handle-undisplayer handle)
4149 (mm-remove-part handle))
4152 gnus-summary-show-article-charset-alist))
4153 (mm-read-coding-system "Charset: ")))))
4155 (mm-insert-inline handle
4157 (setq charset (mm-charset-to-coding-system
4159 (not (eq charset 'ascii)))
4160 (mm-decode-coding-string contents charset)
4164 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4165 "Insert the MIME part under point into the current buffer using the
4167 (interactive (list nil current-prefix-arg))
4168 (gnus-article-check-buffer)
4169 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4174 (if (mm-handle-undisplayer handle)
4175 (mm-remove-part handle))
4176 (let ((gnus-newsgroup-charset
4178 gnus-summary-show-article-charset-alist))
4179 (mm-read-coding-system "Charset: ")))
4180 (gnus-newsgroup-ignored-charsets 'gnus-all))
4181 (gnus-article-press-button)))))
4183 (defun gnus-mime-view-part-externally (&optional handle)
4184 "View the MIME part under point with an external viewer."
4186 (gnus-article-check-buffer)
4187 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4188 (mm-user-display-methods nil)
4189 (mm-inlined-types nil)
4190 (mail-parse-charset gnus-newsgroup-charset)
4191 (mail-parse-ignored-charsets
4192 (save-excursion (set-buffer gnus-summary-buffer)
4193 gnus-newsgroup-ignored-charsets)))
4195 (if (mm-handle-undisplayer handle)
4196 (mm-remove-part handle)
4197 (mm-display-part handle)))))
4199 (defun gnus-mime-view-part-internally (&optional handle)
4200 "View the MIME part under point with an internal viewer.
4201 If no internal viewer is available, use an external viewer."
4203 (gnus-article-check-buffer)
4204 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4205 (mm-inlined-types '(".*"))
4206 (mm-inline-large-images t)
4207 (mail-parse-charset gnus-newsgroup-charset)
4208 (mail-parse-ignored-charsets
4209 (save-excursion (set-buffer gnus-summary-buffer)
4210 gnus-newsgroup-ignored-charsets))
4213 (if (mm-handle-undisplayer handle)
4214 (mm-remove-part handle)
4215 (mm-display-part handle)))))
4217 (defun gnus-mime-action-on-part (&optional action)
4218 "Do something with the MIME attachment at \(point\)."
4220 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4221 (gnus-article-check-buffer)
4222 (let ((action-pair (assoc action gnus-mime-action-alist)))
4224 (funcall (cdr action-pair)))))
4226 (defun gnus-article-part-wrapper (n function)
4227 (save-current-buffer
4228 (set-buffer gnus-article-buffer)
4229 (when (> n (length gnus-article-mime-handle-alist))
4230 (error "No such part"))
4231 (gnus-article-goto-part n)
4232 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4233 (funcall function handle))))
4235 (defun gnus-article-pipe-part (n)
4236 "Pipe MIME part N, which is the numerical prefix."
4238 (gnus-article-part-wrapper n 'mm-pipe-part))
4240 (defun gnus-article-save-part (n)
4241 "Save MIME part N, which is the numerical prefix."
4243 (gnus-article-part-wrapper n 'mm-save-part))
4245 (defun gnus-article-interactively-view-part (n)
4246 "View MIME part N interactively, which is the numerical prefix."
4248 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4250 (defun gnus-article-copy-part (n)
4251 "Copy MIME part N, which is the numerical prefix."
4253 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4255 (defun gnus-article-view-part-as-charset (n)
4256 "Copy MIME part N, which is the numerical prefix."
4258 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4260 (defun gnus-article-view-part-externally (n)
4261 "View MIME part N externally, which is the numerical prefix."
4263 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4265 (defun gnus-article-inline-part (n)
4266 "Inline MIME part N, which is the numerical prefix."
4268 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4270 (defun gnus-article-mime-match-handle-first (condition)
4272 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4273 (while (setq ihandle (pop alist))
4275 ((functionp condition)
4276 (funcall condition (cdr ihandle)))
4277 ((eq condition 'undisplayed)
4278 (not (or (mm-handle-undisplayer (cdr ihandle))
4279 (equal (mm-handle-media-type (cdr ihandle))
4280 "multipart/alternative"))))
4281 ((eq condition 'undisplayed-alternative)
4282 (not (mm-handle-undisplayer (cdr ihandle))))
4284 (gnus-article-goto-part (car ihandle))
4285 (or (not n) (< (car ihandle) n)))
4286 (setq n (car ihandle))))
4290 (defun gnus-article-view-part (&optional n)
4291 "View MIME part N, which is the numerical prefix."
4293 (save-current-buffer
4294 (set-buffer gnus-article-buffer)
4295 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4296 gnus-article-mime-match-handle-function)))
4297 (when (> n (length gnus-article-mime-handle-alist))
4298 (error "No such part"))
4299 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4300 (when (gnus-article-goto-part n)
4301 (if (equal (car handle) "multipart/alternative")
4302 (gnus-article-press-button)
4303 (when (eq (gnus-mm-display-part handle) 'internal)
4304 (gnus-set-window-start)))))))
4306 (defsubst gnus-article-mime-total-parts ()
4307 (if (bufferp (car gnus-article-mime-handles))
4309 (1- (length gnus-article-mime-handles))))
4311 (defun gnus-mm-display-part (handle)
4312 "Display HANDLE and fix MIME button."
4313 (let ((id (get-text-property (point) 'gnus-part))
4318 (let ((window (selected-window))
4319 (mail-parse-charset gnus-newsgroup-charset)
4320 (mail-parse-ignored-charsets
4321 (if (gnus-buffer-live-p gnus-summary-buffer)
4323 (set-buffer gnus-summary-buffer)
4324 gnus-newsgroup-ignored-charsets)
4328 (let ((win (gnus-get-buffer-window (current-buffer) t))
4331 (select-window win))
4334 (if (mm-handle-displayed-p handle)
4335 ;; This will remove the part.
4336 (mm-display-part handle)
4338 (narrow-to-region (point)
4339 (if (eobp) (point) (1+ (point))))
4340 (mm-display-part handle)
4341 ;; We narrow to the part itself and
4342 ;; then call the treatment functions.
4343 (goto-char (point-min))
4345 (narrow-to-region (point) (point-max))
4348 (gnus-article-mime-total-parts)
4349 (mm-handle-media-type handle)))))
4350 (if (window-live-p window)
4351 (select-window window)))))
4354 (gnus-insert-mime-button
4355 handle id (list (mm-handle-displayed-p handle)))
4356 (goto-char point))))
4358 (defun gnus-article-goto-part (n)
4359 "Go to MIME part N."
4360 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4362 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4363 (let ((gnus-tmp-name
4364 (or (mail-content-type-get (mm-handle-type handle) 'name)
4365 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4366 (mail-content-type-get (mm-handle-type handle) 'url)
4368 (gnus-tmp-type (mm-handle-media-type handle))
4369 (gnus-tmp-description
4370 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4373 (if (if displayed (car displayed)
4374 (mm-handle-displayed-p handle))
4376 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4378 gnus-tmp-type-long b e)
4379 (when (string-match ".*/" gnus-tmp-name)
4380 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4381 (setq gnus-tmp-type-long (concat gnus-tmp-type
4382 (and (not (equal gnus-tmp-name ""))
4383 (concat "; " gnus-tmp-name))))
4384 (unless (equal gnus-tmp-description "")
4385 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4390 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4391 `(,@(gnus-local-map-property gnus-mime-button-map)
4392 gnus-callback gnus-mm-display-part
4393 gnus-part ,gnus-tmp-id
4394 article-type annotation
4397 ;; Exclude a newline.
4400 (widget-convert-button
4403 :action 'gnus-widget-press-button
4404 :button-keymap gnus-mime-button-map
4406 (lambda (widget/window &optional overlay pos)
4407 ;; Needed to properly clear the message due to a bug in
4408 ;; wid-edit (XEmacs only).
4409 (if (boundp 'help-echo-owns-message)
4410 (setq help-echo-owns-message t))
4412 "%S: %s the MIME part; %S: more options"
4413 (aref gnus-mouse-2 0)
4414 ;; XEmacs will get a single widget arg; Emacs 21 will get
4415 ;; window, overlay, position.
4416 (if (mm-handle-displayed-p
4418 (with-current-buffer (gnus-overlay-buffer overlay)
4419 (widget-get (widget-at (gnus-overlay-start overlay))
4421 (widget-get widget/window :mime-handle)))
4423 (aref gnus-down-mouse-3 0))))))
4425 (defun gnus-widget-press-button (elems el)
4426 (goto-char (widget-get elems :from))
4427 (gnus-article-press-button))
4429 (defvar gnus-displaying-mime nil)
4431 (defun gnus-display-mime (&optional ihandles)
4432 "Display the MIME parts."
4434 (save-selected-window
4435 (let ((window (get-buffer-window gnus-article-buffer))
4438 (select-window window)
4439 ;; We have to do this since selecting the window
4440 ;; may change the point. So we set the window point.
4441 (set-window-point window point)))
4442 (let* ((handles (or ihandles
4443 (mm-dissect-buffer nil gnus-article-loose-mime)
4444 (and gnus-article-emulate-mime
4446 buffer-read-only handle name type b e display)
4447 (when (and (not ihandles)
4448 (not gnus-displaying-mime))
4449 ;; Top-level call; we clean up.
4450 (when gnus-article-mime-handles
4451 (mm-destroy-parts gnus-article-mime-handles)
4452 (setq gnus-article-mime-handle-alist nil));; A trick.
4453 (setq gnus-article-mime-handles handles)
4454 ;; We allow users to glean info from the handles.
4455 (when gnus-article-mime-part-function
4456 (gnus-mime-part-function handles)))
4458 (or (not (stringp (car handles)))
4461 (when (and (not ihandles)
4462 (not gnus-displaying-mime))
4463 ;; Clean up for mime parts.
4465 (delete-region (point) (point-max)))
4466 (let ((gnus-displaying-mime t))
4467 (gnus-mime-display-part handles)))
4470 (narrow-to-region (point) (point-max))
4471 (gnus-treat-article nil 1 1)
4474 ;; Highlight the headers.
4478 (narrow-to-region (point-min) (point))
4479 (gnus-treat-article 'head))))))))
4481 (defvar gnus-mime-display-multipart-as-mixed nil)
4482 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4483 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4485 (defun gnus-mime-display-part (handle)
4488 ((not (stringp (car handle)))
4489 (gnus-mime-display-single handle))
4490 ;; User-defined multipart
4491 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4492 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4494 ;; multipart/alternative
4495 ((and (equal (car handle) "multipart/alternative")
4496 (not (or gnus-mime-display-multipart-as-mixed
4497 gnus-mime-display-multipart-alternative-as-mixed)))
4498 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4499 (push (cons id handle) gnus-article-mime-handle-alist)
4500 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4501 ;; multipart/related
4502 ((and (equal (car handle) "multipart/related")
4503 (not (or gnus-mime-display-multipart-as-mixed
4504 gnus-mime-display-multipart-related-as-mixed)))
4505 ;;;!!!We should find the start part, but we just default
4506 ;;;!!!to the first part.
4507 ;;(gnus-mime-display-part (cadr handle))
4508 ;;;!!! Most multipart/related is an HTML message plus images.
4509 ;;;!!! Unfortunately we are unable to let W3 display those
4510 ;;;!!! included images, so we just display it as a mixed multipart.
4511 ;;(gnus-mime-display-mixed (cdr handle))
4512 ;;;!!! No, w3 can display everything just fine.
4513 (gnus-mime-display-part (cadr handle)))
4514 ((equal (car handle) "multipart/signed")
4515 (gnus-add-wash-type 'signed)
4516 (gnus-mime-display-security handle))
4517 ((equal (car handle) "multipart/encrypted")
4518 (gnus-add-wash-type 'encrypted)
4519 (gnus-mime-display-security handle))
4520 ;; Other multiparts are handled like multipart/mixed.
4522 (gnus-mime-display-mixed (cdr handle)))))
4524 (defun gnus-mime-part-function (handles)
4525 (if (stringp (car handles))
4526 (mapcar 'gnus-mime-part-function (cdr handles))
4527 (funcall gnus-article-mime-part-function handles)))
4529 (defun gnus-mime-display-mixed (handles)
4530 (mapcar 'gnus-mime-display-part handles))
4532 (defun gnus-mime-display-single (handle)
4533 (let ((type (mm-handle-media-type handle))
4534 (ignored gnus-ignored-mime-types)
4541 (when (string-match (pop ignored) type)
4542 (throw 'ignored nil)))
4543 (if (and (setq not-attachment
4544 (and (not (mm-inline-override-p handle))
4545 (or (not (mm-handle-disposition handle))
4546 (equal (car (mm-handle-disposition handle))
4548 (mm-attachment-override-p handle))))
4549 (mm-automatic-display-p handle)
4551 (mm-inlinable-p handle)
4552 (mm-inlined-p handle))
4553 (mm-automatic-external-display-p type)))
4555 (when (equal (mm-handle-media-supertype handle) "text")
4557 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4559 (push (cons id handle) gnus-article-mime-handle-alist)
4560 (when (or (not display)
4561 (not (gnus-unbuttonized-mime-type-p type)))
4562 ;(gnus-article-insert-newline)
4563 (gnus-insert-mime-button
4564 handle id (list (or display (and not-attachment text))))
4565 (gnus-article-insert-newline)
4566 ;(gnus-article-insert-newline)
4567 ;; Remember modify the number of forward lines.
4575 (let ((mail-parse-charset gnus-newsgroup-charset)
4576 (mail-parse-ignored-charsets
4577 (save-excursion (condition-case ()
4578 (set-buffer gnus-summary-buffer)
4580 gnus-newsgroup-ignored-charsets)))
4581 (mm-display-part handle t))
4582 (goto-char (point-max)))
4583 ((and text not-attachment)
4587 (gnus-article-insert-newline)
4588 (mm-insert-inline handle (mm-get-part handle))
4589 (goto-char (point-max))))
4593 (narrow-to-region beg (point))
4596 (gnus-article-mime-total-parts)
4597 (mm-handle-media-type handle)))))))))
4599 (defun gnus-unbuttonized-mime-type-p (type)
4600 "Say whether TYPE is to be unbuttonized."
4601 (unless gnus-inhibit-mime-unbuttonizing
4603 (let ((types gnus-unbuttonized-mime-types))
4605 (when (string-match (pop types) type)
4606 (throw 'found t)))))
4608 (let ((types gnus-buttonized-mime-types))
4610 (when (string-match (pop types) type)
4611 (throw 'found t)))))))))
4613 (defun gnus-article-insert-newline ()
4614 "Insert a newline, but mark it as undeletable."
4615 (gnus-put-text-property
4616 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4618 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4619 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4622 handle buffer-read-only from props begend not-pref)
4623 (save-window-excursion
4626 (narrow-to-region (car ibegend)
4629 (goto-char (car ibegend))
4632 (delete-region (point-min) (point-max))
4633 (mm-remove-parts handles))
4634 (setq begend (list (point-marker)))
4636 (unless (setq not-pref (cadr (member preferred ihandles)))
4637 (setq not-pref (car ihandles)))
4640 (not (gnus-unbuttonized-mime-type-p
4641 "multipart/alternative")))
4642 (gnus-add-text-properties
4645 (insert (format "%d. " id))
4649 (unless ,(not ibegend)
4650 (setq gnus-article-mime-handle-alist
4651 ',gnus-article-mime-handle-alist))
4652 (gnus-mime-display-alternative
4653 ',ihandles ',not-pref ',begend ,id))
4654 ,@(gnus-local-map-property gnus-mime-button-map)
4655 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4656 face ,gnus-article-button-face
4659 (widget-convert-button 'link from (point)
4660 :action 'gnus-widget-press-button
4661 :button-keymap gnus-widget-button-keymap)
4663 (while (setq handle (pop handles))
4664 (gnus-add-text-properties
4667 (insert (format "(%c) %-18s"
4668 (if (equal handle preferred) ?* ? )
4669 (mm-handle-media-type handle)))
4673 (unless ,(not ibegend)
4674 (setq gnus-article-mime-handle-alist
4675 ',gnus-article-mime-handle-alist))
4676 (gnus-mime-display-alternative
4677 ',ihandles ',handle ',begend ,id))
4678 ,@(gnus-local-map-property gnus-mime-button-map)
4679 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4680 face ,gnus-article-button-face
4683 (widget-convert-button 'link from (point)
4684 :action 'gnus-widget-press-button
4685 :button-keymap gnus-widget-button-keymap)
4689 (if (stringp (car preferred))
4690 (gnus-display-mime preferred)
4691 (let ((mail-parse-charset gnus-newsgroup-charset)
4692 (mail-parse-ignored-charsets
4693 (save-excursion (set-buffer gnus-summary-buffer)
4694 gnus-newsgroup-ignored-charsets)))
4695 (mm-display-part preferred)
4699 (narrow-to-region (car begend) (point-max))
4701 nil (length gnus-article-mime-handle-alist)
4702 (gnus-article-mime-total-parts)
4703 (mm-handle-media-type handle))))))
4704 (goto-char (point-max))
4705 (setcdr begend (point-marker)))))
4707 (goto-char point))))
4709 (defconst gnus-article-wash-status-strings
4710 (let ((alist '((cite "c" "Possible hidden citation text"
4711 " " "All citation text visible")
4712 (headers "h" "Hidden headers"
4713 " " "All headers visible.")
4714 (pgp "p" "Encrypted or signed message status hidden"
4715 " " "No hidden encryption nor digital signature status")
4716 (signature "s" "Signature has been hidden"
4717 " " "Signature is visible")
4718 (overstrike "o" "Overstrike (^H) characters applied"
4719 " " "No overstrike characters applied")
4720 (emphasis "e" "/*_Emphasis_*/ characters applied"
4721 " " "No /*_emphasis_*/ characters applied")))
4723 (dolist (entry alist result)
4724 (let ((key (nth 0 entry))
4725 (on (copy-sequence (nth 1 entry)))
4726 (on-help (nth 2 entry))
4727 (off (copy-sequence (nth 3 entry)))
4728 (off-help (nth 4 entry)))
4729 (put-text-property 0 1 'help-echo on-help on)
4730 (put-text-property 0 1 'help-echo off-help off)
4731 (push (list key on off) result))))
4732 "Alist of strings describing wash status in the mode line.
4733 Each entry has the form (KEY ON OF), where the KEY is a symbol
4734 representing the particular washing function, ON is the string to use
4735 in the article mode line when the washing function is active, and OFF
4736 is the string to use when it is inactive.")
4738 (defun gnus-article-wash-status-entry (key value)
4739 (let ((entry (assoc key gnus-article-wash-status-strings)))
4740 (if value (nth 1 entry) (nth 2 entry))))
4742 (defun gnus-article-wash-status ()
4743 "Return a string which display status of article washing."
4745 (set-buffer gnus-article-buffer)
4746 (let ((cite (memq 'cite gnus-article-wash-types))
4747 (headers (memq 'headers gnus-article-wash-types))
4748 (boring (memq 'boring-headers gnus-article-wash-types))
4749 (pgp (memq 'pgp gnus-article-wash-types))
4750 (pem (memq 'pem gnus-article-wash-types))
4751 (signed (memq 'signed gnus-article-wash-types))
4752 (encrypted (memq 'encrypted gnus-article-wash-types))
4753 (signature (memq 'signature gnus-article-wash-types))
4754 (overstrike (memq 'overstrike gnus-article-wash-types))
4755 (emphasis (memq 'emphasis gnus-article-wash-types)))
4757 (gnus-article-wash-status-entry 'cite cite)
4758 (gnus-article-wash-status-entry 'headers (or headers boring))
4759 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4760 (gnus-article-wash-status-entry 'signature signature)
4761 (gnus-article-wash-status-entry 'overstrike overstrike)
4762 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4764 (defun gnus-add-wash-type (type)
4765 "Add a washing of TYPE to the current status."
4766 (add-to-list 'gnus-article-wash-types type))
4768 (defun gnus-delete-wash-type (type)
4769 "Add a washing of TYPE to the current status."
4770 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4772 (defun gnus-add-image (category image)
4773 "Add IMAGE of CATEGORY to the list of displayed images."
4774 (let ((entry (assq category gnus-article-image-alist)))
4776 (setq entry (list category))
4777 (push entry gnus-article-image-alist))
4778 (nconc entry (list image))))
4780 (defun gnus-delete-images (category)
4781 "Delete all images in CATEGORY."
4782 (let ((entry (assq category gnus-article-image-alist)))
4783 (dolist (image (cdr entry))
4784 (gnus-remove-image image))
4785 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4786 (gnus-delete-wash-type category)))
4788 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4790 (defun gnus-article-maybe-hide-headers ()
4791 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4792 Provided for backwards compatibility."
4793 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4794 (not (save-excursion (set-buffer gnus-summary-buffer)
4795 gnus-have-all-headers)))
4796 (not gnus-inhibit-hiding))
4797 (gnus-article-hide-headers)))
4801 (defun gnus-output-to-file (file-name)
4802 "Append the current article to a file named FILE-NAME."
4803 (let ((artbuf (current-buffer)))
4805 (insert-buffer-substring artbuf)
4806 ;; Append newline at end of the buffer as separator, and then
4808 (goto-char (point-max))
4810 (let ((file-name-coding-system nnmail-pathname-coding-system))
4811 (mm-append-to-file (point-min) (point-max) file-name))
4814 (defun gnus-narrow-to-page (&optional arg)
4815 "Narrow the article buffer to a page.
4816 If given a numerical ARG, move forward ARG pages."
4818 (setq arg (if arg (prefix-numeric-value arg) 0))
4820 (set-buffer gnus-article-buffer)
4821 (goto-char (point-min))
4823 ;; Remove any old next/prev buttons.
4824 (when (gnus-visual-p 'page-marker)
4825 (let ((buffer-read-only nil))
4826 (gnus-remove-text-with-property 'gnus-prev)
4827 (gnus-remove-text-with-property 'gnus-next)))
4830 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4832 (re-search-forward page-delimiter nil 'move arg)))
4833 (goto-char (match-end 0)))
4836 (if (re-search-forward page-delimiter nil 'move)
4839 (when (and (gnus-visual-p 'page-marker)
4840 (not (= (point-min) 1)))
4842 (goto-char (point-min))
4843 (gnus-insert-prev-page-button)))
4844 (when (and (gnus-visual-p 'page-marker)
4845 (< (+ (point-max) 2) (buffer-size)))
4847 (goto-char (point-max))
4848 (gnus-insert-next-page-button)))))
4850 ;; Article mode commands
4852 (defun gnus-article-goto-next-page ()
4853 "Show the next page of the article."
4855 (gnus-eval-in-buffer-window gnus-summary-buffer
4856 (gnus-summary-next-page)))
4858 (defun gnus-article-goto-prev-page ()
4859 "Show the next page of the article."
4861 (gnus-eval-in-buffer-window gnus-summary-buffer
4862 (gnus-summary-prev-page)))
4864 (defun gnus-article-next-page (&optional lines)
4865 "Show the next page of the current article.
4866 If end of article, return non-nil. Otherwise return nil.
4867 Argument LINES specifies lines to be scrolled up."
4869 (move-to-window-line -1)
4872 (and (pos-visible-in-window-p) ;Not continuation line.
4873 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4874 ;; Nothing in this page.
4875 (if (or (not gnus-page-broken)
4878 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4880 (gnus-narrow-to-page 1) ;Go to next page.
4882 ;; More in this page.
4883 (let ((scroll-in-place nil))
4887 ;; Long lines may cause an end-of-buffer error.
4888 (goto-char (point-max)))))
4889 (move-to-window-line 0)
4892 (defun gnus-article-prev-page (&optional lines)
4893 "Show previous page of current article.
4894 Argument LINES specifies lines to be scrolled down."
4896 (move-to-window-line 0)
4897 (if (and gnus-page-broken
4899 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4901 (gnus-narrow-to-page -1) ;Go to previous page.
4902 (goto-char (point-max))
4904 (let ((scroll-in-place nil))
4908 (beginning-of-buffer
4909 (goto-char (point-min))))
4910 (move-to-window-line 0)))))
4912 (defun gnus-article-only-boring-p ()
4913 "Decide whether there is only boring text remaining in the article.
4914 Something \"interesting\" is a word of at least two letters that does
4915 not have a face in `gnus-article-boring-faces'."
4916 (when (and gnus-article-skip-boring
4917 (boundp 'gnus-article-boring-faces)
4918 (symbol-value 'gnus-article-boring-faces))
4921 (while (re-search-forward "\\b\\w\\w" nil t)
4923 (when (not (gnus-intersection
4924 (gnus-faces-at (point))
4925 (symbol-value 'gnus-article-boring-faces)))
4926 (throw 'only-boring nil)))
4927 (throw 'only-boring t)))))
4929 (defun gnus-article-refer-article ()
4930 "Read article specified by message-id around point."
4933 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
4934 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
4935 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
4936 (let ((msg-id (concat "<" (match-string 0) ">")))
4937 (set-buffer gnus-summary-buffer)
4938 (gnus-summary-refer-article msg-id))
4939 (error "No references around point"))))
4941 (defun gnus-article-show-summary ()
4942 "Reconfigure windows to show summary buffer."
4944 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4945 (error "There is no summary buffer for this article buffer")
4946 (gnus-article-set-globals)
4947 (gnus-configure-windows 'article)
4948 (gnus-summary-goto-subject gnus-current-article)
4949 (gnus-summary-position-point)))
4951 (defun gnus-article-describe-briefly ()
4952 "Describe article mode commands briefly."
4954 (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")))
4956 (defun gnus-article-summary-command ()
4957 "Execute the last keystroke in the summary buffer."
4959 (let ((obuf (current-buffer))
4960 (owin (current-window-configuration))
4962 (switch-to-buffer gnus-article-current-summary 'norecord)
4963 (setq func (lookup-key (current-local-map) (this-command-keys)))
4964 (call-interactively func)
4966 (set-window-configuration owin)
4967 (set-window-point (get-buffer-window (current-buffer)) (point))))
4969 (defun gnus-article-summary-command-nosave ()
4970 "Execute the last keystroke in the summary buffer."
4973 (pop-to-buffer gnus-article-current-summary 'norecord)
4974 (setq func (lookup-key (current-local-map) (this-command-keys)))
4975 (call-interactively func)))
4977 (defun gnus-article-check-buffer ()
4978 "Beep if not in an article buffer."
4979 (unless (equal major-mode 'gnus-article-mode)
4980 (error "Command invoked outside of a Gnus article buffer")))
4982 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4983 "Read a summary buffer key sequence and execute it from the article buffer."
4985 (gnus-article-check-buffer)
4987 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4988 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4989 "=" "^" "\M-^" "|"))
4995 '("n" "Gn" "p" "Gp"))
4998 (set-buffer gnus-article-current-summary)
4999 (let (gnus-pick-mode)
5000 (push (or key last-command-event) unread-command-events)
5001 (setq keys (if (featurep 'xemacs)
5002 (events-to-keys (read-key-sequence nil))
5003 (read-key-sequence nil)))))
5007 (if (or (member keys nosaves)
5008 (member keys nosave-but-article)
5009 (member keys nosave-in-article))
5011 (save-window-excursion
5012 (pop-to-buffer gnus-article-current-summary 'norecord)
5013 ;; We disable the pick minor mode commands.
5014 (let (gnus-pick-mode)
5015 (setq func (lookup-key (current-local-map) keys))))
5019 (unless (member keys nosave-in-article)
5020 (set-buffer gnus-article-current-summary))
5021 (call-interactively func)
5022 (setq new-sum-point (point)))
5023 (when (member keys nosave-but-article)
5024 (pop-to-buffer gnus-article-buffer 'norecord)))
5025 ;; These commands should restore window configuration.
5026 (let ((obuf (current-buffer))
5027 (owin (current-window-configuration))
5029 (summary gnus-article-current-summary)
5030 func in-buffer selected)
5031 (if not-restore-window
5032 (pop-to-buffer summary 'norecord)
5033 (switch-to-buffer summary 'norecord))
5034 (setq in-buffer (current-buffer))
5035 ;; We disable the pick minor mode commands.
5036 (if (and (setq func (let (gnus-pick-mode)
5037 (lookup-key (current-local-map) keys)))
5040 (call-interactively func)
5041 (setq new-sum-point (point))
5042 (when (eq in-buffer (current-buffer))
5043 (setq selected (gnus-summary-select-article))
5045 (unless not-restore-window
5046 (set-window-configuration owin))
5047 (when (eq selected 'old)
5049 (set-window-start (get-buffer-window (current-buffer))
5051 (set-window-point (get-buffer-window (current-buffer))
5053 (let ((win (get-buffer-window gnus-article-current-summary)))
5055 (set-window-point win new-sum-point)))) )
5056 (switch-to-buffer gnus-article-buffer)
5059 (defun gnus-article-describe-key (key)
5060 "Display documentation of the function invoked by KEY. KEY is a string."
5061 (interactive "kDescribe key: ")
5062 (gnus-article-check-buffer)
5063 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5065 (set-buffer gnus-article-current-summary)
5066 (let (gnus-pick-mode)
5067 (if (featurep 'xemacs)
5069 (push (elt key 0) unread-command-events)
5070 (setq key (events-to-keys
5071 (read-key-sequence "Describe key: "))))
5072 (setq unread-command-events
5074 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5075 (string-to-list key)))
5076 (setq key (read-key-sequence "Describe key: "))))
5078 (describe-key key)))
5080 (defun gnus-article-describe-key-briefly (key &optional insert)
5081 "Display documentation of the function invoked by KEY. KEY is a string."
5082 (interactive "kDescribe key: \nP")
5083 (gnus-article-check-buffer)
5084 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5086 (set-buffer gnus-article-current-summary)
5087 (let (gnus-pick-mode)
5088 (if (featurep 'xemacs)
5090 (push (elt key 0) unread-command-events)
5091 (setq key (events-to-keys
5092 (read-key-sequence "Describe key: "))))
5093 (setq unread-command-events
5095 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5096 (string-to-list key)))
5097 (setq key (read-key-sequence "Describe key: "))))
5098 (describe-key-briefly key insert))
5099 (describe-key-briefly key insert)))
5101 (defun gnus-article-reply-with-original (&optional wide)
5102 "Start composing a reply mail to the current message.
5103 The text in the region will be yanked. If the region isn't active,
5104 the entire article will be yanked."
5106 (let ((article (cdr gnus-article-current))
5108 (if (not (gnus-mark-active-p))
5109 (with-current-buffer gnus-summary-buffer
5110 (gnus-summary-reply (list (list article)) wide))
5111 (setq contents (buffer-substring (point) (mark t)))
5112 ;; Deactivate active regions.
5113 (when (and (boundp 'transient-mark-mode)
5114 transient-mark-mode)
5115 (setq mark-active nil))
5116 (with-current-buffer gnus-summary-buffer
5118 (list (list article contents)) wide)))))
5120 (defun gnus-article-followup-with-original ()
5121 "Compose a followup to the current article.
5122 The text in the region will be yanked. If the region isn't active,
5123 the entire article will be yanked."
5125 (let ((article (cdr gnus-article-current))
5127 (if (not (gnus-mark-active-p))
5128 (with-current-buffer gnus-summary-buffer
5129 (gnus-summary-followup (list (list article))))
5130 (setq contents (buffer-substring (point) (mark t)))
5131 ;; Deactivate active regions.
5132 (when (and (boundp 'transient-mark-mode)
5133 transient-mark-mode)
5134 (setq mark-active nil))
5135 (with-current-buffer gnus-summary-buffer
5136 (gnus-summary-followup
5137 (list (list article contents)))))))
5139 (defun gnus-article-hide (&optional arg force)
5140 "Hide all the gruft in the current article.
5141 This means that signatures, cited text and (some) headers will be
5143 If given a prefix, show the hidden text instead."
5144 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5145 (gnus-article-hide-headers arg)
5146 (gnus-article-hide-list-identifiers arg)
5147 (gnus-article-hide-citation-maybe arg force)
5148 (gnus-article-hide-signature arg))
5150 (defun gnus-article-maybe-highlight ()
5151 "Do some article highlighting if article highlighting is requested."
5152 (when (gnus-visual-p 'article-highlight 'highlight)
5153 (gnus-article-highlight-some)))
5155 (defun gnus-check-group-server ()
5156 ;; Make sure the connection to the server is alive.
5157 (unless (gnus-server-opened
5158 (gnus-find-method-for-group gnus-newsgroup-name))
5159 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5160 (gnus-request-group gnus-newsgroup-name t)))
5163 (autoload 'nneething-get-file-name "nneething"))
5165 (defun gnus-request-article-this-buffer (article group)
5166 "Get an article and insert it into this buffer."
5167 (let (do-update-line sparse-header)
5171 (gnus-kill-all-overlays)
5172 (setq group (or group gnus-newsgroup-name))
5174 ;; Using `gnus-request-article' directly will insert the article into
5175 ;; `nntp-server-buffer' - so we'll save some time by not having to
5176 ;; copy it from the server buffer into the article buffer.
5178 ;; We only request an article by message-id when we do not have the
5179 ;; headers for it, so we'll have to get those.
5180 (when (stringp article)
5181 (gnus-read-header article))
5183 ;; If the article number is negative, that means that this article
5184 ;; doesn't belong in this newsgroup (possibly), so we find its
5185 ;; message-id and request it by id instead of number.
5186 (when (and (numberp article)
5188 (get-buffer gnus-summary-buffer)
5189 (gnus-buffer-exists-p gnus-summary-buffer))
5191 (set-buffer gnus-summary-buffer)
5192 (let ((header (gnus-summary-article-header article)))
5195 ((memq article gnus-newsgroup-sparse)
5196 ;; This is a sparse gap article.
5197 (setq do-update-line article)
5198 (setq article (mail-header-id header))
5199 (setq sparse-header (gnus-read-header article))
5200 (setq gnus-newsgroup-sparse
5201 (delq article gnus-newsgroup-sparse)))
5203 ;; It's a real article.
5204 (setq article (mail-header-id header)))
5206 ;; It is an extracted pseudo-article.
5207 (setq article 'pseudo)
5208 (gnus-request-pseudo-article header))))
5210 (let ((method (gnus-find-method-for-group
5211 gnus-newsgroup-name)))
5212 (when (and (eq (car method) 'nneething)
5214 (let ((dir (nneething-get-file-name
5215 (mail-header-id header))))
5216 (when (and (stringp dir)
5217 (file-directory-p dir))
5218 (setq article 'nneething)
5219 (gnus-group-enter-directory dir))))))))
5222 ;; Refuse to select canceled articles.
5223 ((and (numberp article)
5225 (get-buffer gnus-summary-buffer)
5226 (gnus-buffer-exists-p gnus-summary-buffer)
5227 (eq (cdr (save-excursion
5228 (set-buffer gnus-summary-buffer)
5229 (assq article gnus-newsgroup-reads)))
5230 gnus-canceled-mark))
5232 ;; We first check `gnus-original-article-buffer'.
5233 ((and (get-buffer gnus-original-article-buffer)
5236 (set-buffer gnus-original-article-buffer)
5237 (and (equal (car gnus-original-article) group)
5238 (eq (cdr gnus-original-article) article))))
5239 (insert-buffer-substring gnus-original-article-buffer)
5241 ;; Check the backlog.
5242 ((and gnus-keep-backlog
5243 (gnus-backlog-request-article group article (current-buffer)))
5245 ;; Check asynchronous pre-fetch.
5246 ((gnus-async-request-fetched-article group article (current-buffer))
5247 (gnus-async-prefetch-next group article gnus-summary-buffer)
5248 (when (and (numberp article) gnus-keep-backlog)
5249 (gnus-backlog-enter-article group article (current-buffer)))
5252 ((and gnus-use-cache
5254 (gnus-cache-request-article article group))
5256 ;; Check the agent cache.
5257 ((gnus-agent-request-article article group)
5259 ;; Get the article and put into the article buffer.
5260 ((or (stringp article)
5262 (let ((gnus-override-method gnus-override-method)
5263 (methods (and (stringp article)
5264 gnus-refer-article-method))
5265 (backend (car (gnus-find-method-for-group
5266 gnus-newsgroup-name)))
5268 (buffer-read-only nil))
5269 (if (or (not (listp methods))
5270 (and (symbolp (car methods))
5271 (assq (car methods) nnoo-definition-alist)))
5272 (setq methods (list methods)))
5273 (when (and (null gnus-override-method)
5275 (setq gnus-override-method (pop methods)))
5277 (when (eq gnus-override-method 'current)
5278 (setq gnus-override-method
5279 (with-current-buffer gnus-summary-buffer
5280 gnus-current-select-method)))
5282 (gnus-kill-all-overlays)
5283 (let ((gnus-newsgroup-name group))
5284 (gnus-check-group-server))
5286 ((gnus-request-article article group (current-buffer))
5287 (when (numberp article)
5288 (gnus-async-prefetch-next group article
5289 gnus-summary-buffer)
5290 (when gnus-keep-backlog
5291 (gnus-backlog-enter-article
5292 group article (current-buffer))))
5293 (setq result 'article))
5295 (setq gnus-override-method (pop methods)))
5296 ((not (string-match "^400 "
5297 (nnheader-get-report backend)))
5298 ;; If we get 400 server disconnect, reconnect and
5299 ;; retry; otherwise, assume the article has expired.
5300 (setq result 'done))))
5301 (and (eq result 'article) 'article)))
5305 ;; Associate this article with the current summary buffer.
5306 (setq gnus-article-current-summary gnus-summary-buffer)
5308 ;; Take the article from the original article buffer
5309 ;; and place it in the buffer it's supposed to be in.
5310 (when (and (get-buffer gnus-article-buffer)
5311 (equal (buffer-name (current-buffer))
5312 (buffer-name (get-buffer gnus-article-buffer))))
5314 (if (get-buffer gnus-original-article-buffer)
5315 (set-buffer gnus-original-article-buffer)
5316 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5317 (buffer-disable-undo)
5318 (setq major-mode 'gnus-original-article-mode)
5319 (setq buffer-read-only t))
5320 (let (buffer-read-only)
5322 (insert-buffer-substring gnus-article-buffer))
5323 (setq gnus-original-article (cons group article)))
5326 (run-hooks 'gnus-article-decode-hook)
5327 ;; Mark article as decoded or not.
5328 (setq gnus-article-decoded-p gnus-article-decode-hook))
5330 ;; Update sparse articles.
5331 (when (and do-update-line
5332 (or (numberp article)
5334 (let ((buf (current-buffer)))
5335 (set-buffer gnus-summary-buffer)
5336 (gnus-summary-update-article do-update-line sparse-header)
5337 (gnus-summary-goto-subject do-update-line nil t)
5338 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5340 (set-buffer buf))))))
5346 (defcustom gnus-article-edit-mode-hook nil
5347 "Hook run in article edit mode buffers."
5348 :group 'gnus-article-various
5351 (defvar gnus-article-edit-done-function nil)
5353 (defvar gnus-article-edit-mode-map nil)
5354 (defvar gnus-article-edit-mode nil)
5356 ;; Should we be using derived.el for this?
5357 (unless gnus-article-edit-mode-map
5358 (setq gnus-article-edit-mode-map (make-keymap))
5359 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5361 (gnus-define-keys gnus-article-edit-mode-map
5362 "\C-c?" describe-mode
5363 "\C-c\C-c" gnus-article-edit-done
5364 "\C-c\C-k" gnus-article-edit-exit
5365 "\C-c\C-f\C-t" message-goto-to
5366 "\C-c\C-f\C-o" message-goto-from
5367 "\C-c\C-f\C-b" message-goto-bcc
5368 ;;"\C-c\C-f\C-w" message-goto-fcc
5369 "\C-c\C-f\C-c" message-goto-cc
5370 "\C-c\C-f\C-s" message-goto-subject
5371 "\C-c\C-f\C-r" message-goto-reply-to
5372 "\C-c\C-f\C-n" message-goto-newsgroups
5373 "\C-c\C-f\C-d" message-goto-distribution
5374 "\C-c\C-f\C-f" message-goto-followup-to
5375 "\C-c\C-f\C-m" message-goto-mail-followup-to
5376 "\C-c\C-f\C-k" message-goto-keywords
5377 "\C-c\C-f\C-u" message-goto-summary
5378 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5379 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5380 "\C-c\C-b" message-goto-body
5381 "\C-c\C-i" message-goto-signature
5383 "\C-c\C-t" message-insert-to
5384 "\C-c\C-n" message-insert-newsgroups
5385 "\C-c\C-o" message-sort-headers
5386 "\C-c\C-e" message-elide-region
5387 "\C-c\C-v" message-delete-not-region
5388 "\C-c\C-z" message-kill-to-signature
5389 "\M-\r" message-newline-and-reformat
5390 "\C-c\C-a" mml-attach-file
5391 "\C-a" message-beginning-of-line
5393 "\M-;" comment-region)
5395 (gnus-define-keys (gnus-article-edit-wash-map
5396 "\C-c\C-w" gnus-article-edit-mode-map)
5397 "f" gnus-article-edit-full-stops))
5400 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5402 ["Fetch To" message-insert-to t]
5403 ["Fetch Newsgroups" message-insert-newsgroups t]
5405 ["To" message-goto-to t]
5406 ["From" message-goto-from t]
5407 ["Subject" message-goto-subject t]
5408 ["Cc" message-goto-cc t]
5409 ["Reply-To" message-goto-reply-to t]
5410 ["Summary" message-goto-summary t]
5411 ["Keywords" message-goto-keywords t]
5412 ["Newsgroups" message-goto-newsgroups t]
5413 ["Followup-To" message-goto-followup-to t]
5414 ["Mail-Followup-To" message-goto-mail-followup-to t]
5415 ["Distribution" message-goto-distribution t]
5416 ["Body" message-goto-body t]
5417 ["Signature" message-goto-signature t]))
5419 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5420 "Major mode for editing articles.
5421 This is an extended text-mode.
5423 \\{gnus-article-edit-mode-map}"
5424 (make-local-variable 'gnus-article-edit-done-function)
5425 (make-local-variable 'gnus-prev-winconf)
5426 (set (make-local-variable 'font-lock-defaults)
5427 '(message-font-lock-keywords t))
5428 (set (make-local-variable 'mail-header-separator) "")
5429 (set (make-local-variable 'gnus-article-edit-mode) t)
5430 (easy-menu-add message-mode-field-menu message-mode-map)
5432 (setq buffer-read-only nil)
5433 (buffer-enable-undo)
5436 (defun gnus-article-edit (&optional force)
5437 "Edit the current article.
5438 This will have permanent effect only in mail groups.
5439 If FORCE is non-nil, allow editing of articles even in read-only
5442 (when (and (not force)
5443 (gnus-group-read-only-p))
5444 (error "The current newsgroup does not support article editing"))
5445 (gnus-article-date-original)
5446 (gnus-article-edit-article
5448 `(lambda (no-highlight)
5450 (gnus-summary-edit-article-done
5451 ,(or (mail-header-references gnus-current-headers) "")
5452 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5454 (defun gnus-article-edit-article (start-func exit-func)
5455 "Start editing the contents of the current article buffer."
5456 (let ((winconf (current-window-configuration)))
5457 (set-buffer gnus-article-buffer)
5458 (gnus-article-edit-mode)
5459 (funcall start-func)
5460 (set-buffer-modified-p nil)
5461 (gnus-configure-windows 'edit-article)
5462 (setq gnus-article-edit-done-function exit-func)
5463 (setq gnus-prev-winconf winconf)
5464 (gnus-message 6 "C-c C-c to end edits")))
5466 (defun gnus-article-edit-done (&optional arg)
5467 "Update the article edits and exit."
5469 (let ((func gnus-article-edit-done-function)
5470 (buf (current-buffer))
5471 (start (window-start))
5473 (winconf gnus-prev-winconf))
5474 (widen) ;; Widen it in case that users narrowed the buffer.
5477 ;; The cache and backlog have to be flushed somewhat.
5478 (when gnus-keep-backlog
5479 (gnus-backlog-remove-article
5480 (car gnus-article-current) (cdr gnus-article-current)))
5481 ;; Flush original article as well.
5483 (when (get-buffer gnus-original-article-buffer)
5484 (set-buffer gnus-original-article-buffer)
5485 (setq gnus-original-article nil)))
5486 (when gnus-use-cache
5487 (gnus-cache-update-article
5488 (car gnus-article-current) (cdr gnus-article-current)))
5489 ;; We remove all text props from the article buffer.
5490 (kill-all-local-variables)
5491 (gnus-set-text-properties (point-min) (point-max) nil)
5493 (set-window-configuration winconf)
5495 (set-window-start (get-buffer-window buf) start)
5496 (set-window-point (get-buffer-window buf) (point))))
5498 (defun gnus-article-edit-exit ()
5499 "Exit the article editing without updating."
5501 (when (or (not (buffer-modified-p))
5502 (yes-or-no-p "Article modified; kill anyway? "))
5503 (let ((curbuf (current-buffer))
5505 (window-start (window-start)))
5507 (if (gnus-buffer-live-p gnus-original-article-buffer)
5508 (insert-buffer gnus-original-article-buffer))
5509 (let ((winconf gnus-prev-winconf))
5510 (kill-all-local-variables)
5512 (set-window-configuration winconf)
5513 ;; Tippy-toe some to make sure that point remains where it was.
5514 (save-current-buffer
5516 (set-window-start (get-buffer-window (current-buffer)) window-start)
5519 (defun gnus-article-edit-full-stops ()
5520 "Interactively repair spacing at end of sentences."
5523 (goto-char (point-min))
5524 (search-forward-regexp "^$" nil t)
5525 (let ((case-fold-search nil))
5526 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5529 ;;; Article highlights
5532 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5534 ;;; Internal Variables:
5536 (defcustom gnus-button-url-regexp
5537 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5538 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5539 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5540 "Regular expression that matches URLs."
5541 :group 'gnus-article-buttons
5544 (defcustom gnus-button-valid-fqdn-regexp
5545 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5547 "\\([a-z][a-z]" ;; two letter country TDLs
5548 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5549 "\\|aero\\|coop\\|info\\|name\\|museum"
5550 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5552 "Regular expression that matches a valid FQDN."
5553 :group 'gnus-article-buttons
5556 (defcustom gnus-button-man-handler 'manual-entry
5557 "Function to use for displaying man pages.
5558 The function must take at least one argument with a string naming the
5560 :type '(choice (function-item :tag "Man" manual-entry)
5561 (function-item :tag "Woman" woman)
5562 (function :tag "Other"))
5563 :group 'gnus-article-buttons)
5565 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5566 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5567 If the default site is too slow, try to find a CTAN mirror, see
5568 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5569 the variable `gnus-button-handle-ctan'."
5570 :group 'gnus-article-buttons
5571 :link '(custom-manual "(gnus)Group Parameters")
5572 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5573 (const "http://tug.ctan.org/tex-archive/")
5574 (const "http://www.dante.de/CTAN/")
5575 (string :tag "Other")))
5577 (defcustom gnus-button-ctan-handler 'browse-url
5578 "Function to use for displaying CTAN links.
5579 The function must take one argument, the string naming the URL."
5580 :type '(choice (function-item :tag "Browse Url" browse-url)
5581 (function :tag "Other"))
5582 :group 'gnus-article-buttons)
5584 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5585 "Bogus strings removed from CTAN URLs."
5586 :group 'gnus-article-buttons
5587 :type '(choice (const "^/?tex-archive/\\|/")
5588 (regexp :tag "Other")))
5590 (defcustom gnus-button-mid-or-mail-regexp
5591 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5592 gnus-button-valid-fqdn-regexp
5594 "Regular expression that matches a message ID or a mail address."
5595 :group 'gnus-article-buttons
5598 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5599 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5600 Strings like this can be either a message ID or a mail address. If it is one
5601 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5602 message ID or a mail address, respectivly. If this variable is set to the
5603 symbol `ask', always query the user what do do. If it is a function, this
5604 function will be called with the string as it's only argument. The function
5605 must return `mid', `mail', `invalid' or `ask'."
5606 :group 'gnus-article-buttons
5607 :type '(choice (function-item :tag "Heuristic function"
5608 gnus-button-mid-or-mail-heuristic)
5613 (defcustom gnus-button-mid-or-mail-heuristic-alist
5614 '((-10.0 . ".+\\$.+@")
5617 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5618 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5619 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5620 (-1.0 . "^[^a-z]+@")
5622 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5623 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5624 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5625 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5628 (-1.0 . "^[0-9][0-9]")
5630 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5631 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5632 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5633 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5635 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5636 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5639 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5641 ;; compensation for TDMA dated mail addresses:
5642 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5644 (-20.0 . "\\.fsf@") ;; Gnus
5647 (-20.0 . "_-_") ;; Subject change in thread
5649 (-20.0 . "\\.ln@") ;; leafnode
5650 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5651 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5653 ;; (5.0 . "") ;; $local_part_len <= 7
5654 (10.0 . "^[^0-9]+@")
5655 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5656 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5659 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5661 (0.5 . "^[A-Z][a-z]")
5662 (0.5 . "^[A-Z][a-z][a-z]")
5663 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5664 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5665 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5667 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5668 address. The REGEXP is processed with `case-fold-search' set to `nil'."
5669 :group 'gnus-article-buttons
5670 :type '(repeat (cons (number :tag "Rate")
5671 (regexp :tag "Regexp"))))
5673 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5674 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5675 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5676 address, `ask' if unsure and `invalid' if the string is invalid."
5677 (let ((case-fold-search nil)
5678 (list gnus-button-mid-or-mail-heuristic-alist)
5679 (result 0) rate regexp lpartlen elem)
5681 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5682 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5683 ;; Certain special cases...
5686 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5687 "^[0-9]+\.[0-9]+\@compuserve")
5689 (gnus-message 8 "`%s' is a known mail address.")
5690 (setq result 'mail))
5691 (when (string-match "@.*@\\| " mid-or-mail)
5692 (gnus-message 8 "`%s' is invalid.")
5693 (setq result 'invalid))
5694 ;; Nothing more to do, if result is not a number here...
5695 (when (numberp result)
5697 (setq elem (car list)
5701 (when (string-match regexp mid-or-mail)
5702 (setq result (+ result rate))
5704 9 "`%s' matched `%s', rate `%s', result `%s'."
5705 mid-or-mail regexp rate result)))
5706 (when (<= lpartlen 7)
5707 (setq result (+ result 5.0))
5708 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5709 mid-or-mail result))
5710 (when (>= lpartlen 12)
5711 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5713 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5714 ;; Long local part should contain realname if e-mail address,
5715 ;; too many digits: message-id.
5716 ;; $score -= 5.0 + 0.1 * $local_part_len;
5717 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5718 (setq result (+ result rate))
5720 9 "Many digits in `%s', rate `%s', result `%s'."
5721 mid-or-mail rate result))
5722 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5724 ;; Too few vowels [^aeiouy]{4,}.*\@
5725 (setq result (+ result -5.0))
5727 9 "Few vowels in `%s', rate `%s', result `%s'."
5728 mid-or-mail -5.0 result))
5730 (setq result (+ result 5.0))
5732 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5733 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5735 ;; Maybe we should make this a customizable alist: (condition . 'result)
5736 ((< result -10.0) 'mid)
5737 ((> result 10.0) 'mail)
5740 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5741 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5742 (url-mid (concat "news" ":" mid-or-mail))
5743 (url-mailto (concat "mailto" ":" mid-or-mail)))
5744 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5745 (when (fboundp pref)
5747 ;; get rid of surrounding angles...
5749 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5750 (if (or (eq 'mid guessed) (eq 'mail guessed))
5754 (save-window-excursion
5755 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5758 (cond ((eq pref 'mid)
5759 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5760 (gnus-button-handle-news url-mid))
5762 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5763 (gnus-url-mailto url-mailto))
5764 (t (gnus-message 3 "Invalid string.")))))
5766 (defun gnus-button-handle-custom (url)
5767 "Follow a Custom URL."
5768 (customize-apropos (gnus-url-unhex-string url)))
5770 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5772 (defun gnus-button-handle-describe-function (url)
5773 "Call `describe-function' when pushing the corresponding URL button."
5776 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5778 (defun gnus-button-handle-describe-variable (url)
5779 "Call `describe-variable' when pushing the corresponding URL button."
5782 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5784 (defun gnus-button-handle-describe-key (url)
5785 "Call `describe-key' when pushing the corresponding URL button."
5787 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5788 (keys (ignore-errors (eval `(kbd ,key-string)))))
5791 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5793 (defun gnus-button-handle-apropos (url)
5794 "Call `apropos' when pushing the corresponding URL button."
5795 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5797 (defun gnus-button-handle-apropos-command (url)
5798 "Call `apropos' when pushing the corresponding URL button."
5800 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5802 (defun gnus-button-handle-apropos-variable (url)
5803 "Call `apropos' when pushing the corresponding URL button."
5805 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5806 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5808 (defun gnus-button-handle-apropos-documentation (url)
5809 "Call `apropos' when pushing the corresponding URL button."
5811 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5812 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5814 (defun gnus-button-handle-ctan (url)
5815 "Call `browse-url' when pushing a CTAN URL button."
5817 gnus-button-ctan-handler
5820 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5822 (defcustom gnus-button-tex-level 5
5823 "*Integer that says how many TeX-related buttons Gnus will show.
5824 The higher the number, the more buttons will appear and the more false
5825 positives are possible. Note that you can set this variable local to
5826 specifific groups. Setting it higher in TeX groups is probably a good idea.
5827 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5828 how to set variables in specific groups."
5829 :group 'gnus-article-buttons
5830 :link '(custom-manual "(gnus)Group Parameters")
5833 (defcustom gnus-button-man-level 5
5834 "*Integer that says how many man-related buttons Gnus will show.
5835 The higher the number, the more buttons will appear and the more false
5836 positives are possible. Note that you can set this variable local to
5837 specifific groups. Setting it higher in Unix groups is probably a good idea.
5838 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5839 how to set variables in specific groups."
5840 :group 'gnus-article-buttons
5841 :link '(custom-manual "(gnus)Group Parameters")
5844 (defcustom gnus-button-emacs-level 5
5845 "*Integer that says how many emacs-related buttons Gnus will show.
5846 The higher the number, the more buttons will appear and the more false
5847 positives are possible. Note that you can set this variable local to
5848 specifific groups. Setting it higher in Emacs or Gnus related groups is
5849 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5850 `gnus-parameters' on how to set variables in specific groups."
5851 :group 'gnus-article-buttons
5852 :link '(custom-manual "(gnus)Group Parameters")
5855 (defcustom gnus-button-mail-level 5
5856 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5857 The higher the number, the more buttons will appear and the more false
5858 positives are possible."
5859 :group 'gnus-article-buttons
5862 (defcustom gnus-button-alist
5863 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5864 0 t gnus-button-handle-news 3)
5865 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5866 gnus-button-handle-news 2)
5867 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5869 gnus-button-fetch-group 4)
5870 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5871 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5872 t gnus-button-message-id 3)
5873 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5874 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5875 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5877 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5878 gnus-button-handle-ctan 1)
5880 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5881 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5883 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5884 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5885 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5886 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5887 ;; Emacs help commands
5888 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5889 ;; regexp doesn't match arguments containing ` '.
5890 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5891 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5892 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5893 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5894 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5895 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5896 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5897 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5898 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5899 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5900 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5901 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
5902 ;; Unlike the other regexps we really have to require quoting
5903 ;; here to determine where it ends.
5904 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
5905 ;; This is how URLs _should_ be embedded in text...
5906 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5908 (gnus-button-url-regexp 0 t browse-url 0)
5910 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5911 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5912 gnus-button-handle-man 1)
5913 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5914 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
5915 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5916 gnus-button-handle-man 1)
5917 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5918 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5919 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5920 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5921 ;; MID or mail: To avoid too many false positives we don't try to catch
5922 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5923 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5924 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5925 ;; so that non-ambiguous entries (see above) match first.
5926 (gnus-button-mid-or-mail-regexp
5927 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5928 "*Alist of regexps matching buttons in article bodies.
5930 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5931 REGEXP: is the string (case insensitive) matching text around the button (can
5932 also be lisp expression evaluating to a string),
5933 BUTTON: is the number of the regexp grouping actually matching the button,
5934 FORM: is a lisp expression which must eval to true for the button to
5936 CALLBACK: is the function to call when the user push this button, and each
5937 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5939 CALLBACK can also be a variable, in that case the value of that
5940 variable it the real callback function."
5941 :group 'gnus-article-buttons
5942 :type '(repeat (list (choice regexp variable)
5943 (integer :tag "Button")
5945 (function :tag "Callback")
5948 (integer :tag "Regexp group")))))
5950 (defcustom gnus-header-button-alist
5951 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5952 0 t gnus-button-message-id 0)
5953 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5954 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5955 0 t gnus-button-mailto 0)
5956 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5957 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5958 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5959 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5960 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5961 gnus-button-message-id 3))
5962 "*Alist of headers and regexps to match buttons in article heads.
5964 This alist is very similar to `gnus-button-alist', except that each
5965 alist has an additional HEADER element first in each entry:
5967 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5969 HEADER is a regexp to match a header. For a fuller explanation, see
5970 `gnus-button-alist'."
5971 :group 'gnus-article-buttons
5972 :group 'gnus-article-headers
5973 :type '(repeat (list (regexp :tag "Header")
5975 (integer :tag "Button")
5977 (function :tag "Callback")
5980 (integer :tag "Regexp group")))))
5982 (defvar gnus-button-regexp nil)
5983 (defvar gnus-button-marker-list nil)
5984 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5986 (defvar gnus-button-last nil)
5987 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5991 (defun gnus-article-push-button (event)
5992 "Check text under the mouse pointer for a callback function.
5993 If the text under the mouse pointer has a `gnus-callback' property,
5994 call it with the value of the `gnus-data' text property."
5996 (set-buffer (window-buffer (posn-window (event-start event))))
5997 (let* ((pos (posn-point (event-start event)))
5998 (data (get-text-property pos 'gnus-data))
5999 (fun (get-text-property pos 'gnus-callback)))
6002 (funcall fun data))))
6004 (defun gnus-article-press-button ()
6005 "Check text at point for a callback function.
6006 If the text at point has a `gnus-callback' property,
6007 call it with the value of the `gnus-data' text property."
6009 (let ((data (get-text-property (point) 'gnus-data))
6010 (fun (get-text-property (point) 'gnus-callback)))
6012 (funcall fun data))))
6014 (defun gnus-article-highlight (&optional force)
6015 "Highlight current article.
6016 This function calls `gnus-article-highlight-headers',
6017 `gnus-article-highlight-citation',
6018 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6019 do the highlighting. See the documentation for those functions."
6020 (interactive (list 'force))
6021 (gnus-article-highlight-headers)
6022 (gnus-article-highlight-citation force)
6023 (gnus-article-highlight-signature)
6024 (gnus-article-add-buttons force)
6025 (gnus-article-add-buttons-to-head))
6027 (defun gnus-article-highlight-some (&optional force)
6028 "Highlight current article.
6029 This function calls `gnus-article-highlight-headers',
6030 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6031 do the highlighting. See the documentation for those functions."
6032 (interactive (list 'force))
6033 (gnus-article-highlight-headers)
6034 (gnus-article-highlight-signature)
6035 (gnus-article-add-buttons))
6037 (defun gnus-article-highlight-headers ()
6038 "Highlight article headers as specified by `gnus-header-face-alist'."
6041 (set-buffer gnus-article-buffer)
6043 (let ((alist gnus-header-face-alist)
6044 (buffer-read-only nil)
6045 (case-fold-search t)
6046 (inhibit-point-motion-hooks t)
6047 entry regexp header-face field-face from hpoints fpoints)
6048 (article-narrow-to-head)
6049 (while (setq entry (pop alist))
6050 (goto-char (point-min))
6051 (setq regexp (concat "^\\("
6052 (if (string-equal "" (nth 0 entry))
6056 header-face (nth 1 entry)
6057 field-face (nth 2 entry))
6058 (while (and (re-search-forward regexp nil t)
6062 (unless (search-forward ":" nil t)
6064 (when (and header-face
6065 (not (memq (point) hpoints)))
6066 (push (point) hpoints)
6067 (gnus-put-text-property from (point) 'face header-face))
6068 (when (and field-face
6069 (not (memq (setq from (point)) fpoints)))
6071 (if (re-search-forward "^[^ \t]" nil t)
6073 (goto-char (point-max)))
6074 (gnus-put-text-property from (point) 'face field-face))))))))
6076 (defun gnus-article-highlight-signature ()
6077 "Highlight the signature in an article.
6078 It does this by highlighting everything after
6079 `gnus-signature-separator' using `gnus-signature-face'."
6082 (set-buffer gnus-article-buffer)
6083 (let ((buffer-read-only nil)
6084 (inhibit-point-motion-hooks t))
6086 (when (and gnus-signature-face
6087 (gnus-article-narrow-to-signature))
6088 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6089 'face gnus-signature-face)
6091 (gnus-article-search-signature)
6092 (let ((start (match-beginning 0))
6093 (end (set-marker (make-marker) (1+ (match-end 0)))))
6094 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6097 (defun gnus-button-in-region-p (b e prop)
6098 "Say whether PROP exists in the region."
6099 (text-property-not-all b e prop nil))
6101 (defun gnus-article-add-buttons (&optional force)
6102 "Find external references in the article and make buttons of them.
6103 \"External references\" are things like Message-IDs and URLs, as
6104 specified by `gnus-button-alist'."
6105 (interactive (list 'force))
6107 (set-buffer gnus-article-buffer)
6108 (let ((buffer-read-only nil)
6109 (inhibit-point-motion-hooks t)
6110 (case-fold-search t)
6111 (alist gnus-button-alist)
6113 ;; Remove all old markers.
6114 (let (marker entry new-list)
6115 (while (setq marker (pop gnus-button-marker-list))
6116 (if (or (< marker (point-min)) (>= marker (point-max)))
6117 (push marker new-list)
6119 (when (setq entry (gnus-button-entry))
6120 (put-text-property (match-beginning (nth 1 entry))
6121 (match-end (nth 1 entry))
6122 'gnus-callback nil))
6123 (set-marker marker nil)))
6124 (setq gnus-button-marker-list new-list))
6125 ;; We skip the headers.
6128 (while (setq entry (pop alist))
6129 (setq regexp (eval (car entry)))
6131 (while (re-search-forward regexp nil t)
6132 (let* ((start (and entry (match-beginning (nth 1 entry))))
6133 (end (and entry (match-end (nth 1 entry))))
6134 (from (match-beginning 0)))
6135 (when (and (or (eq t (nth 2 entry))
6136 (eval (nth 2 entry)))
6137 (not (gnus-button-in-region-p
6138 start end 'gnus-callback)))
6139 ;; That optional form returned non-nil, so we add the
6141 (gnus-article-add-button
6142 start end 'gnus-button-push
6143 (car (push (set-marker (make-marker) from)
6144 gnus-button-marker-list))))))))))
6146 ;; Add buttons to the head of an article.
6147 (defun gnus-article-add-buttons-to-head ()
6148 "Add buttons to the head of the article."
6151 (set-buffer gnus-article-buffer)
6153 (let ((buffer-read-only nil)
6154 (inhibit-point-motion-hooks t)
6155 (case-fold-search t)
6156 (alist gnus-header-button-alist)
6158 (article-narrow-to-head)
6160 ;; Each alist entry.
6161 (setq entry (car alist)
6163 (goto-char (point-min))
6164 (while (re-search-forward (car entry) nil t)
6165 ;; Each header matching the entry.
6166 (setq beg (match-beginning 0))
6167 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6168 (match-beginning 0))
6171 (while (re-search-forward (eval (nth 1 entry)) end t)
6172 ;; Each match within a header.
6173 (let* ((entry (cdr entry))
6174 (start (match-beginning (nth 1 entry)))
6175 (end (match-end (nth 1 entry)))
6176 (form (nth 2 entry)))
6177 (goto-char (match-end 0))
6179 (gnus-article-add-button
6180 start end (nth 3 entry)
6181 (buffer-substring (match-beginning (nth 4 entry))
6182 (match-end (nth 4 entry)))))))
6183 (goto-char end)))))))
6185 ;;; External functions:
6187 (defun gnus-article-add-button (from to fun &optional data)
6188 "Create a button between FROM and TO with callback FUN and data DATA."
6189 (when gnus-article-button-face
6190 (gnus-overlay-put (gnus-make-overlay from to)
6191 'face gnus-article-button-face))
6192 (gnus-add-text-properties
6194 (nconc (and gnus-article-mouse-face
6195 (list gnus-mouse-face-prop gnus-article-mouse-face))
6196 (list 'gnus-callback fun)
6197 (and data (list 'gnus-data data))))
6198 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6199 :button-keymap gnus-widget-button-keymap))
6201 ;;; Internal functions:
6203 (defun gnus-article-set-globals ()
6205 (set-buffer gnus-summary-buffer)
6206 (gnus-set-global-variables)))
6208 (defun gnus-signature-toggle (end)
6210 (set-buffer gnus-article-buffer)
6211 (let ((buffer-read-only nil)
6212 (inhibit-point-motion-hooks t))
6213 (if (text-property-any end (point-max) 'article-type 'signature)
6215 (gnus-delete-wash-type 'signature)
6216 (gnus-remove-text-properties-when
6217 'article-type 'signature end (point-max)
6218 (cons 'article-type (cons 'signature
6219 gnus-hidden-properties))))
6220 (gnus-add-wash-type 'signature)
6221 (gnus-add-text-properties-when
6222 'article-type nil end (point-max)
6223 (cons 'article-type (cons 'signature
6224 gnus-hidden-properties)))))
6225 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6226 (gnus-set-mode-line 'article))))
6228 (defun gnus-button-entry ()
6229 ;; Return the first entry in `gnus-button-alist' matching this place.
6230 (let ((alist gnus-button-alist)
6233 (setq entry (pop alist))
6234 (if (looking-at (eval (car entry)))
6239 (defun gnus-button-push (marker)
6240 ;; Push button starting at MARKER.
6243 (let* ((entry (gnus-button-entry))
6244 (inhibit-point-motion-hooks t)
6246 (args (mapcar (lambda (group)
6247 (let ((string (match-string group)))
6248 (gnus-set-text-properties
6249 0 (length string) nil string)
6256 (fboundp (symbol-value fun)))
6257 (apply (symbol-value fun) args))
6259 (gnus-message 1 "You must define `%S' to use this button"
6260 (cons fun args)))))))
6262 (defun gnus-parse-news-url (url)
6263 (let (scheme server group message-id articles)
6266 (goto-char (point-min))
6267 (when (looking-at "\\([A-Za-z]+\\):")
6268 (setq scheme (match-string 1))
6269 (goto-char (match-end 0)))
6270 (when (looking-at "//\\([^/]+\\)/")
6271 (setq server (match-string 1))
6272 (goto-char (match-end 0)))
6275 ((looking-at "\\(.*@.*\\)")
6276 (setq message-id (match-string 1)))
6277 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6278 (setq group (match-string 1)
6279 articles (split-string (match-string 2) "-")))
6280 ((looking-at "\\([^/]+\\)/?")
6281 (setq group (match-string 1)))
6283 (error "Unknown news URL syntax"))))
6284 (list scheme server group message-id articles)))
6286 (defun gnus-button-handle-news (url)
6288 (destructuring-bind (scheme server group message-id articles)
6289 (gnus-parse-news-url url)
6293 (set-buffer gnus-summary-buffer)
6295 (let ((gnus-refer-article-method (list (list 'nntp server))))
6296 (gnus-summary-refer-article message-id))
6297 (gnus-summary-refer-article message-id))))
6299 (gnus-button-fetch-group url)))))
6301 (defun gnus-button-handle-man (url)
6303 (funcall gnus-button-man-handler url))
6305 (defun gnus-button-handle-info (url)
6306 "Fetch an info URL."
6308 "^\\([^:/]+\\)?/\\(.*\\)"
6310 (gnus-info-find-node
6311 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6314 (gnus-url-unhex-string (match-string 2 url))))
6315 (error "Can't parse %s" url)))
6317 (defun gnus-button-message-id (message-id)
6320 (set-buffer gnus-summary-buffer)
6321 (gnus-summary-refer-article message-id)))
6323 (defun gnus-button-fetch-group (address)
6324 "Fetch GROUP specified by ADDRESS."
6325 (if (not (string-match "[:/]" address))
6326 ;; This is just a simple group url.
6327 (gnus-group-read-ephemeral-group address gnus-select-method)
6330 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6332 (error "Can't parse %s" address)
6333 (gnus-group-read-ephemeral-group
6334 (match-string 4 address)
6335 `(nntp ,(match-string 1 address)
6336 (nntp-address ,(match-string 1 address))
6337 (nntp-port-number ,(if (match-end 3)
6338 (match-string 3 address)
6341 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6343 (defun gnus-url-parse-query-string (query &optional downcase)
6344 (let (retval pairs cur key val)
6345 (setq pairs (split-string query "&"))
6347 (setq cur (car pairs)
6349 (if (not (string-match "=" cur))
6351 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6352 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6354 (setq key (downcase key)))
6355 (setq cur (assoc key retval))
6357 (setcdr cur (cons val (cdr cur)))
6358 (setq retval (cons (list key val) retval)))))
6361 (defun gnus-url-mailto (url)
6362 ;; Send mail to someone
6363 (when (string-match "mailto:/*\\(.*\\)" url)
6364 (setq url (substring url (match-beginning 1) nil)))
6365 (let (to args subject func)
6366 (if (string-match (regexp-quote "?") url)
6367 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6368 args (gnus-url-parse-query-string
6369 (substring url (match-end 0) nil) t))
6370 (setq to (gnus-url-unhex-string url)))
6371 (setq args (cons (list "to" to) args)
6372 subject (cdr-safe (assoc "subject" args)))
6375 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6378 (message-position-on-field (caar args)))
6379 (insert (mapconcat 'identity (cdar args) ", "))
6380 (setq args (cdr args)))
6383 (message-goto-subject))))
6385 (defun gnus-button-embedded-url (address)
6386 "Activate ADDRESS with `browse-url'."
6387 (browse-url (gnus-strip-whitespace address)))
6389 ;;; Next/prev buttons in the article buffer.
6391 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6392 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6394 (defvar gnus-prev-page-map
6395 (let ((map (make-sparse-keymap)))
6396 (unless (>= emacs-major-version 21)
6397 ;; XEmacs doesn't care.
6398 (set-keymap-parent map gnus-article-mode-map))
6399 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6400 (define-key map "\r" 'gnus-button-prev-page)
6403 (defun gnus-insert-prev-page-button ()
6405 (buffer-read-only nil))
6407 gnus-prev-page-line-format nil
6408 `(,@(gnus-local-map-property gnus-prev-page-map)
6410 gnus-callback gnus-article-button-prev-page
6411 article-type annotation))
6412 (widget-convert-button
6414 ;; Exclude a newline.
6417 :action 'gnus-button-prev-page
6418 :button-keymap gnus-prev-page-map)))
6420 (defvar gnus-prev-page-map
6421 (let ((map (make-sparse-keymap)))
6422 (unless (>= emacs-major-version 21)
6423 ;; XEmacs doesn't care.
6424 (set-keymap-parent map gnus-article-mode-map))
6425 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6426 (define-key map "\r" 'gnus-button-prev-page)
6429 (defvar gnus-next-page-map
6430 (let ((map (make-sparse-keymap)))
6431 (unless (>= emacs-major-version 21)
6432 ;; XEmacs doesn't care.
6433 (set-keymap-parent map gnus-article-mode-map))
6434 (define-key map gnus-mouse-2 'gnus-button-next-page)
6435 (define-key map "\r" 'gnus-button-next-page)
6438 (defun gnus-button-next-page (&optional args more-args)
6439 "Go to the next page."
6441 (let ((win (selected-window)))
6442 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6443 (gnus-article-next-page)
6444 (select-window win)))
6446 (defun gnus-button-prev-page (&optional args more-args)
6447 "Go to the prev page."
6449 (let ((win (selected-window)))
6450 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6451 (gnus-article-prev-page)
6452 (select-window win)))
6454 (defun gnus-insert-next-page-button ()
6456 (buffer-read-only nil))
6457 (gnus-eval-format gnus-next-page-line-format nil
6458 `(,@(gnus-local-map-property gnus-next-page-map)
6460 gnus-callback gnus-article-button-next-page
6461 article-type annotation))
6462 (widget-convert-button
6464 ;; Exclude a newline.
6467 :action 'gnus-button-next-page
6468 :button-keymap gnus-next-page-map)))
6470 (defun gnus-article-button-next-page (arg)
6471 "Go to the next page."
6473 (let ((win (selected-window)))
6474 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6475 (gnus-article-next-page)
6476 (select-window win)))
6478 (defun gnus-article-button-prev-page (arg)
6479 "Go to the prev page."
6481 (let ((win (selected-window)))
6482 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6483 (gnus-article-prev-page)
6484 (select-window win)))
6486 (defvar gnus-decode-header-methods
6487 '(mail-decode-encoded-word-region)
6488 "List of methods used to decode headers.
6490 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6491 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6492 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6493 whose names match REGEXP.
6496 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6497 mail-decode-encoded-word-region
6498 (\"chinese\" . rfc1843-decode-region))
6501 (defvar gnus-decode-header-methods-cache nil)
6503 (defun gnus-multi-decode-header (start end)
6504 "Apply the functions from `gnus-encoded-word-methods' that match."
6505 (unless (and gnus-decode-header-methods-cache
6506 (eq gnus-newsgroup-name
6507 (car gnus-decode-header-methods-cache)))
6508 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6511 (nconc gnus-decode-header-methods-cache (list x))
6512 (if (and gnus-newsgroup-name
6513 (string-match (car x) gnus-newsgroup-name))
6514 (nconc gnus-decode-header-methods-cache
6516 gnus-decode-header-methods))
6517 (let ((xlist gnus-decode-header-methods-cache))
6520 (narrow-to-region start end)
6522 (funcall (pop xlist) (point-min) (point-max))))))
6525 ;;; Treatment top-level handling.
6528 (defun gnus-treat-article (condition &optional part-number total-parts type)
6529 (let ((length (- (point-max) (point-min)))
6530 (alist gnus-treatment-function-alist)
6531 (article-goto-body-goes-to-point-min-p t)
6535 (let ((list gnus-article-treat-types))
6537 (when (string-match (pop list) type)
6538 (throw 'found t)))))))
6539 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6541 (gnus-run-hooks 'gnus-part-display-hook)
6542 (dolist (elem alist)
6545 (when (gnus-buffer-live-p gnus-summary-buffer)
6546 (set-buffer gnus-summary-buffer))
6547 (symbol-value (car elem))))
6548 (when (and (or (consp val)
6550 (gnus-treat-predicate val)
6551 (or (not (get (car elem) 'highlight))
6554 (funcall (cadr elem)))))))
6556 ;; Dynamic variables.
6558 (defvar part-number)
6559 (defvar total-parts)
6564 (defun gnus-treat-predicate (val)
6571 (stringp (car val)))
6572 (apply 'gnus-or (mapcar `(lambda (s)
6573 (string-match s ,(or gnus-newsgroup-name "")))
6576 (let ((pred (pop val)))
6579 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6581 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6583 (not (gnus-treat-predicate (car val))))
6585 (equal (car val) type))
6587 (error "%S is not a valid predicate" pred)))))
6593 (eq part-number total-parts))
6597 (error "%S is not a valid value" val))))
6599 (defun gnus-article-encrypt-body (protocol &optional n)
6600 "Encrypt the article body."
6603 (or gnus-article-encrypt-protocol
6604 (completing-read "Encrypt protocol: "
6605 gnus-article-encrypt-protocol-alist
6607 current-prefix-arg))
6608 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6610 (error (format "Can't find the encrypt protocol %s" protocol)))
6611 (if (member gnus-newsgroup-name '("nndraft:delayed"
6614 (error "Can't encrypt the article in group %s"
6615 gnus-newsgroup-name))
6616 (gnus-summary-iterate n
6618 (set-buffer gnus-summary-buffer)
6619 (let ((mail-parse-charset gnus-newsgroup-charset)
6620 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6621 (summary-buffer gnus-summary-buffer)
6623 (gnus-set-global-variables)
6624 (when (gnus-group-read-only-p)
6625 (error "The current newsgroup does not support article encrypt"))
6626 (gnus-summary-show-article t)
6628 (or (mail-header-references gnus-current-headers) ""))
6629 (set-buffer gnus-article-buffer)
6630 (let* ((buffer-read-only nil)
6632 (mapcar (lambda (field)
6633 (and (save-restriction
6634 (message-narrow-to-head)
6635 (goto-char (point-min))
6636 (search-forward field nil t))
6638 (message-narrow-to-field)
6640 (delete-region (point-min) (point-max))
6642 '("Content-Type:" "Content-Transfer-Encoding:"
6643 "Content-Disposition:"))))
6644 (message-narrow-to-head)
6645 (message-remove-header "MIME-Version")
6646 (goto-char (point-max))
6647 (setq point (point))
6648 (insert (apply 'concat headers))
6650 (narrow-to-region point (point-max))
6651 (let ((message-options message-options))
6652 (message-options-set 'message-sender user-mail-address)
6653 (message-options-set 'message-recipients user-mail-address)
6654 (message-options-set 'message-sign-encrypt 'not)
6656 (goto-char (point-min))
6657 (insert "MIME-Version: 1.0\n")
6659 (gnus-summary-edit-article-done
6660 references nil summary-buffer t))
6661 (when gnus-keep-backlog
6662 (gnus-backlog-remove-article
6663 (car gnus-article-current) (cdr gnus-article-current)))
6665 (when (get-buffer gnus-original-article-buffer)
6666 (set-buffer gnus-original-article-buffer)
6667 (setq gnus-original-article nil)))
6668 (when gnus-use-cache
6669 (gnus-cache-update-article
6670 (car gnus-article-current) (cdr gnus-article-current))))))))
6672 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6673 "The following specs can be used:
6674 %t The security MIME type
6677 %D Details if button is pressed")
6679 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6680 "The following specs can be used:
6681 %t The security MIME type
6684 %D Details if button is pressed")
6686 (defvar gnus-mime-security-button-line-format-alist
6687 '((?t gnus-tmp-type ?s)
6688 (?i gnus-tmp-info ?s)
6689 (?d gnus-tmp-details ?s)
6690 (?D gnus-tmp-pressed-details ?s)))
6692 (defvar gnus-mime-security-button-map
6693 (let ((map (make-sparse-keymap)))
6694 (unless (>= (string-to-number emacs-version) 21)
6695 (set-keymap-parent map gnus-article-mode-map))
6696 (define-key map gnus-mouse-2 'gnus-article-push-button)
6697 (define-key map "\r" 'gnus-article-press-button)
6700 (defvar gnus-mime-security-details-buffer nil)
6702 (defvar gnus-mime-security-button-pressed nil)
6704 (defvar gnus-mime-security-show-details-inline t
6705 "If non-nil, show details in the article buffer.")
6707 (defun gnus-mime-security-verify-or-decrypt (handle)
6708 (mm-remove-parts (cdr handle))
6709 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6710 point buffer-read-only)
6712 (goto-char (car region)))
6714 (narrow-to-region (point) (point))
6715 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6716 (let* ((mm-verify-option 'known)
6717 (mm-decrypt-option 'known)
6718 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6719 (unless (eq nparts (cdr handle))
6720 (mm-destroy-parts (cdr handle))
6721 (setcdr handle nparts))))
6722 (setq point (point))
6723 (gnus-mime-display-security handle)
6724 (goto-char (point-max)))
6726 (delete-region (point) (cdr region))
6727 (set-marker (car region) nil)
6728 (set-marker (cdr region) nil))
6731 (defun gnus-mime-security-show-details (handle)
6732 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6734 (gnus-message 5 "No details.")
6735 (if gnus-mime-security-show-details-inline
6736 (let ((gnus-mime-security-button-pressed
6737 (not (get-text-property (point) 'gnus-mime-details)))
6738 (gnus-mime-security-button-line-format
6739 (get-text-property (point) 'gnus-line-format))
6742 (while (eq (get-text-property (point) 'gnus-line-format)
6743 gnus-mime-security-button-line-format)
6747 (narrow-to-region (point) (point))
6748 (gnus-insert-mime-security-button handle))
6749 (delete-region (point)
6750 (or (text-property-not-all
6753 gnus-mime-security-button-line-format)
6756 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6757 (with-current-buffer gnus-mime-security-details-buffer
6760 (setq gnus-mime-security-details-buffer
6761 (gnus-get-buffer-create "*MIME Security Details*")))
6762 (with-current-buffer gnus-mime-security-details-buffer
6764 (goto-char (point-min)))
6765 (pop-to-buffer gnus-mime-security-details-buffer)))))
6767 (defun gnus-mime-security-press-button (handle)
6769 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6770 (gnus-mime-security-show-details handle)
6771 (gnus-mime-security-verify-or-decrypt handle))))
6773 (defun gnus-insert-mime-security-button (handle &optional displayed)
6774 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6777 (or (nth 2 (assoc protocol mm-verify-function-alist))
6778 (nth 2 (assoc protocol mm-decrypt-function-alist))
6780 (if (equal (car handle) "multipart/signed")
6781 " Signed" " Encrypted")
6784 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6787 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6788 gnus-tmp-pressed-details
6790 (setq gnus-tmp-details
6791 (if gnus-tmp-details
6792 (concat "\n" gnus-tmp-details)
6794 (setq gnus-tmp-pressed-details
6795 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6800 gnus-mime-security-button-line-format
6801 gnus-mime-security-button-line-format-alist
6802 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6803 gnus-callback gnus-mime-security-press-button
6804 gnus-line-format ,gnus-mime-security-button-line-format
6805 gnus-mime-details ,gnus-mime-security-button-pressed
6806 article-type annotation
6809 ;; Exclude a newline.
6812 (widget-convert-button
6815 :action 'gnus-widget-press-button
6816 :button-keymap gnus-mime-security-button-map
6818 (lambda (widget/window &optional overlay pos)
6819 ;; Needed to properly clear the message due to a bug in
6820 ;; wid-edit (XEmacs only).
6821 (when (boundp 'help-echo-owns-message)
6822 (setq help-echo-owns-message t))
6825 (aref gnus-mouse-2 0))))))
6827 (defun gnus-mime-display-security (handle)
6829 (narrow-to-region (point) (point))
6830 (unless (gnus-unbuttonized-mime-type-p (car handle))
6831 (gnus-insert-mime-security-button handle))
6832 (gnus-mime-display-mixed (cdr handle))
6835 (unless (gnus-unbuttonized-mime-type-p (car handle))
6836 (let ((gnus-mime-security-button-line-format
6837 gnus-mime-security-button-end-line-format))
6838 (gnus-insert-mime-security-button handle)))
6839 (mm-set-handle-multipart-parameter
6841 (cons (set-marker (make-marker) (point-min))
6842 (set-marker (make-marker) (point-max))))))
6848 (run-hooks 'gnus-art-load-hook)
6850 ;;; gnus-art.el ends here