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 (autoload 'idna-to-unicode "idna")
2141 (defun article-decode-idna-rhs ()
2142 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2145 (let ((inhibit-point-motion-hooks t)
2147 (article-narrow-to-head)
2148 (goto-char (point-min))
2149 (while (re-search-forward "\\(xn--.*\\)[ \t\n\r,>]" nil t)
2151 (when (save-match-data
2152 (and (setq ace (match-string 1))
2154 (and (re-search-backward "^[^ \t]" nil t)
2155 (looking-at "From\\|To\\|Cc")))
2156 (save-excursion (backward-char)
2157 (message-idna-inside-rhs-p))
2158 (setq unicode (idna-to-unicode ace))))
2159 (unless (string= ace unicode)
2160 (replace-match unicode nil nil nil 1)))))))))
2162 (defun article-de-quoted-unreadable (&optional force read-charset)
2163 "Translate a quoted-printable-encoded article.
2164 If FORCE, decode the article whether it is marked as quoted-printable
2166 If READ-CHARSET, ask for a coding system."
2167 (interactive (list 'force current-prefix-arg))
2169 (let ((buffer-read-only nil) type charset)
2170 (if (gnus-buffer-live-p gnus-original-article-buffer)
2171 (with-current-buffer gnus-original-article-buffer
2173 (gnus-fetch-field "content-transfer-encoding"))
2174 (let* ((ct (gnus-fetch-field "content-type"))
2177 (mail-header-parse-content-type ct)))))
2178 (setq charset (and ctl
2179 (mail-content-type-get ctl 'charset)))
2180 (if (stringp charset)
2181 (setq charset (intern (downcase charset)))))))
2183 (setq charset (mm-read-coding-system "Charset: " charset)))
2185 (setq charset gnus-newsgroup-charset))
2187 (and type (let ((case-fold-search t))
2188 (string-match "quoted-printable" type))))
2190 (quoted-printable-decode-region
2191 (point) (point-max) (mm-charset-to-coding-system charset))))))
2193 (defun article-de-base64-unreadable (&optional force read-charset)
2194 "Translate a base64 article.
2195 If FORCE, decode the article whether it is marked as base64 not.
2196 If READ-CHARSET, ask for a coding system."
2197 (interactive (list 'force current-prefix-arg))
2199 (let ((buffer-read-only nil) type charset)
2200 (if (gnus-buffer-live-p gnus-original-article-buffer)
2201 (with-current-buffer gnus-original-article-buffer
2203 (gnus-fetch-field "content-transfer-encoding"))
2204 (let* ((ct (gnus-fetch-field "content-type"))
2207 (mail-header-parse-content-type ct)))))
2208 (setq charset (and ctl
2209 (mail-content-type-get ctl 'charset)))
2210 (if (stringp charset)
2211 (setq charset (intern (downcase charset)))))))
2213 (setq charset (mm-read-coding-system "Charset: " charset)))
2215 (setq charset gnus-newsgroup-charset))
2217 (and type (let ((case-fold-search t))
2218 (string-match "base64" type))))
2221 (narrow-to-region (point) (point-max))
2222 (base64-decode-region (point-min) (point-max))
2223 (mm-decode-coding-region
2224 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2229 (defun article-decode-HZ ()
2230 "Translate a HZ-encoded article."
2234 (let ((buffer-read-only nil))
2235 (rfc1843-decode-region (point-min) (point-max)))))
2237 (defun article-unsplit-urls ()
2238 "Remove the newlines that some other mailers insert into URLs."
2241 (let ((buffer-read-only nil))
2242 (goto-char (point-min))
2243 (while (re-search-forward
2244 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2245 (replace-match "\\1\\3" t)))
2246 (when (and gnus-display-mime-function (interactive-p))
2247 (funcall gnus-display-mime-function))))
2250 (defun article-wash-html (&optional read-charset)
2251 "Format an HTML article.
2252 If READ-CHARSET, ask for a coding system."
2255 (let ((buffer-read-only nil)
2257 (when (gnus-buffer-live-p gnus-original-article-buffer)
2258 (with-current-buffer gnus-original-article-buffer
2259 (let* ((ct (gnus-fetch-field "content-type"))
2262 (mail-header-parse-content-type ct)))))
2263 (setq charset (and ctl
2264 (mail-content-type-get ctl 'charset)))
2265 (when (stringp charset)
2266 (setq charset (intern (downcase charset)))))))
2268 (setq charset (mm-read-coding-system "Charset: " charset)))
2270 (setq charset gnus-newsgroup-charset))
2272 (save-window-excursion
2274 (narrow-to-region (point) (point-max))
2275 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2276 (entry (assq func mm-text-html-washer-alist)))
2278 (setq func (cdr entry)))
2280 ((gnus-functionp func)
2283 (apply (car func) (cdr func))))))))))
2285 (defun gnus-article-wash-html-with-w3 ()
2286 "Wash the current buffer with w3."
2288 (let ((w3-strict-width (window-width))
2289 (url-standalone-mode t)
2290 (url-gateway-unplugged t)
2291 (w3-honor-stylesheets nil))
2293 (w3-region (point-min) (point-max))
2296 (defun gnus-article-wash-html-with-w3m ()
2297 "Wash the current buffer with emacs-w3m."
2300 (narrow-to-region (point) (point-max))
2301 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2304 w3m-force-redisplay)
2305 (w3m-region (point-min) (point-max)))
2306 (when mm-inline-text-html-with-w3m-keymap
2307 (add-text-properties
2308 (point-min) (point-max)
2309 (nconc (mm-w3m-local-map-property)
2310 '(mm-inline-text-html-with-w3m t))))))
2312 (defun article-hide-list-identifiers ()
2313 "Remove list identifies from the Subject header.
2314 The `gnus-list-identifiers' variable specifies what to do."
2316 (let ((inhibit-point-motion-hooks t)
2317 (regexp (if (consp gnus-list-identifiers)
2318 (mapconcat 'identity gnus-list-identifiers " *\\|")
2319 gnus-list-identifiers))
2324 (article-narrow-to-head)
2325 (goto-char (point-min))
2326 (while (re-search-forward
2327 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2329 (delete-region (match-beginning 2) (match-end 0))
2330 (beginning-of-line))
2331 (when (re-search-forward
2332 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2333 (delete-region (match-beginning 1) (match-end 1))))))))
2335 (defun article-hide-pem (&optional arg)
2336 "Toggle hiding of any PEM headers and signatures in the current article.
2337 If given a negative prefix, always show; if given a positive prefix,
2339 (interactive (gnus-article-hidden-arg))
2340 (unless (gnus-article-check-hidden-text 'pem arg)
2342 (let (buffer-read-only end)
2343 (goto-char (point-min))
2344 ;; Hide the horrendously ugly "header".
2345 (when (and (search-forward
2346 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2348 (setq end (1+ (match-beginning 0))))
2349 (gnus-add-wash-type 'pem)
2350 (gnus-article-hide-text-type
2352 (if (search-forward "\n\n" nil t)
2356 ;; Hide the trailer as well
2357 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2359 (gnus-article-hide-text-type
2360 (match-beginning 0) (match-end 0) 'pem)))))))
2362 (defun article-strip-banner ()
2363 "Strip the banners specified by the `banner' group parameter and by
2364 `gnus-article-address-banner-alist'."
2368 (let ((inhibit-point-motion-hooks t))
2369 (when (gnus-parameter-banner gnus-newsgroup-name)
2370 (article-really-strip-banner
2371 (gnus-parameter-banner gnus-newsgroup-name)))
2372 (when gnus-article-address-banner-alist
2373 (article-really-strip-banner
2374 (let ((from (save-restriction
2376 (article-narrow-to-head)
2377 (mail-fetch-field "from"))))
2380 (caar (mail-header-parse-addresses from))))
2382 (dolist (pair gnus-article-address-banner-alist)
2383 (when (string-match (car pair) from)
2384 (throw 'found (cdr pair)))))))))))))
2386 (defun article-really-strip-banner (banner)
2387 "Strip the banner specified by the argument."
2390 (let ((inhibit-point-motion-hooks t)
2391 (gnus-signature-limit nil)
2395 ((eq banner 'signature)
2396 (when (gnus-article-narrow-to-signature)
2399 (delete-region (point) (point-max))))
2401 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2402 (while (re-search-forward banner nil t)
2403 (delete-region (match-beginning 0) (match-end 0)))))
2405 (while (re-search-forward banner nil t)
2406 (delete-region (match-beginning 0) (match-end 0)))))))))
2408 (defun article-babel ()
2409 "Translate article using an online translation service."
2413 (set-buffer gnus-article-buffer)
2414 (when (article-goto-body)
2415 (let* ((buffer-read-only nil)
2418 (orig (buffer-substring start end))
2419 (trans (babel-as-string orig)))
2421 (narrow-to-region start end)
2422 (delete-region start end)
2425 (defun article-hide-signature (&optional arg)
2426 "Hide the signature in the current article.
2427 If given a negative prefix, always show; if given a positive prefix,
2429 (interactive (gnus-article-hidden-arg))
2430 (unless (gnus-article-check-hidden-text 'signature arg)
2433 (let ((buffer-read-only nil))
2434 (when (gnus-article-narrow-to-signature)
2435 (gnus-article-hide-text-type
2436 (point-min) (point-max) 'signature))))))
2437 (gnus-set-mode-line 'article))
2439 (defun article-strip-headers-in-body ()
2440 "Strip offensive headers from bodies."
2444 (let ((case-fold-search t))
2445 (when (looking-at "x-no-archive:")
2446 (gnus-delete-line)))))
2448 (defun article-strip-leading-blank-lines ()
2449 "Remove all blank lines from the beginning of the article."
2452 (let ((inhibit-point-motion-hooks t)
2454 (when (article-goto-body)
2455 (while (and (not (eobp))
2456 (looking-at "[ \t]*$"))
2457 (gnus-delete-line))))))
2459 (defun article-narrow-to-head ()
2460 "Narrow the buffer to the head of the message.
2461 Point is left at the beginning of the narrowed-to region."
2463 (goto-char (point-min))
2464 (if (search-forward "\n\n" nil 1)
2467 (goto-char (point-min)))
2469 (defun article-goto-body ()
2470 "Place point at the start of the body."
2471 (goto-char (point-min))
2473 ;; This variable is only bound when dealing with separate
2475 (article-goto-body-goes-to-point-min-p
2477 ((search-forward "\n\n" nil t)
2480 (goto-char (point-max))
2483 (defun article-strip-multiple-blank-lines ()
2484 "Replace consecutive blank lines with one empty line."
2487 (let ((inhibit-point-motion-hooks t)
2489 ;; First make all blank lines empty.
2491 (while (re-search-forward "^[ \t]+$" nil t)
2492 (unless (gnus-annotation-in-region-p
2493 (match-beginning 0) (match-end 0))
2494 (replace-match "" nil t)))
2495 ;; Then replace multiple empty lines with a single empty line.
2497 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2498 (unless (gnus-annotation-in-region-p
2499 (match-beginning 0) (match-end 0))
2500 (delete-region (match-beginning 1) (match-end 1)))))))
2502 (defun article-strip-leading-space ()
2503 "Remove all white space from the beginning of the lines in the article."
2506 (let ((inhibit-point-motion-hooks t)
2509 (while (re-search-forward "^[ \t]+" nil t)
2510 (replace-match "" t t)))))
2512 (defun article-strip-trailing-space ()
2513 "Remove all white space from the end of the lines in the article."
2516 (let ((inhibit-point-motion-hooks t)
2519 (while (re-search-forward "[ \t]+$" nil t)
2520 (replace-match "" t t)))))
2522 (defun article-strip-blank-lines ()
2523 "Strip leading, trailing and multiple blank lines."
2525 (article-strip-leading-blank-lines)
2526 (article-remove-trailing-blank-lines)
2527 (article-strip-multiple-blank-lines))
2529 (defun article-strip-all-blank-lines ()
2530 "Strip all blank lines."
2533 (let ((inhibit-point-motion-hooks t)
2536 (while (re-search-forward "^[ \t]*\n" nil t)
2537 (replace-match "" t t)))))
2539 (defun gnus-article-narrow-to-signature ()
2540 "Narrow to the signature; return t if a signature is found, else nil."
2541 (let ((inhibit-point-motion-hooks t))
2542 (when (gnus-article-search-signature)
2544 ;; Check whether we have some limits to what we consider
2545 ;; to be a signature.
2546 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2547 (list gnus-signature-limit)))
2549 (while (setq limit (pop limits))
2550 (if (or (and (integerp limit)
2551 (< (- (point-max) (point)) limit))
2553 (< (count-lines (point) (point-max)) limit))
2554 (and (gnus-functionp limit)
2556 (and (stringp limit)
2557 (not (re-search-forward limit nil t))))
2558 () ; This limit did not succeed.
2562 (narrow-to-region (point) (point-max))
2565 (defun gnus-article-search-signature ()
2566 "Search the current buffer for the signature separator.
2567 Put point at the beginning of the signature separator."
2568 (let ((cur (point)))
2569 (goto-char (point-max))
2570 (if (if (stringp gnus-signature-separator)
2571 (re-search-backward gnus-signature-separator nil t)
2572 (let ((seps gnus-signature-separator))
2574 (not (re-search-backward (car seps) nil t)))
2581 (defun gnus-article-hidden-arg ()
2582 "Return the current prefix arg as a number, or 0 if no prefix."
2583 (list (if current-prefix-arg
2584 (prefix-numeric-value current-prefix-arg)
2587 (defun gnus-article-check-hidden-text (type arg)
2588 "Return nil if hiding is necessary.
2589 Arg can be nil or a number. nil and positive means hide, negative
2590 means show, 0 means toggle."
2593 (let ((hide (gnus-article-hidden-text-p type)))
2599 (gnus-article-show-hidden-text type)
2602 (if (eq hide 'hidden)
2604 (gnus-article-show-hidden-text type)
2608 (defun gnus-article-hidden-text-p (type)
2609 "Say whether the current buffer contains hidden text of type TYPE."
2610 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2612 (not (get-text-property pos 'invisible))
2613 (not (get-text-property pos 'dummy-invisible)))
2615 (text-property-any (1+ pos) (point-max) 'article-type type)))
2620 (defun gnus-article-show-hidden-text (type &optional dummy)
2621 "Show all hidden text of type TYPE.
2622 Originally it is hide instead of DUMMY."
2623 (let ((buffer-read-only nil)
2624 (inhibit-point-motion-hooks t))
2625 (gnus-remove-text-properties-when
2627 (point-min) (point-max)
2628 (cons 'article-type (cons type
2629 gnus-hidden-properties)))
2630 (gnus-delete-wash-type type)))
2632 (defconst article-time-units
2633 `((year . ,(* 365.25 24 60 60))
2634 (week . ,(* 7 24 60 60))
2635 (day . ,(* 24 60 60))
2639 "Mapping from time units to seconds.")
2641 (defun gnus-article-forward-header ()
2642 "Move point to the start of the next header.
2643 If the current header is a continuation header, this can be several
2648 (if (looking-at "[ \t]+[^ \t]")
2652 (defun article-date-ut (&optional type highlight header)
2653 "Convert DATE date to universal time in the current article.
2654 If TYPE is `local', convert to local time; if it is `lapsed', output
2655 how much time has lapsed since DATE. For `lapsed', the value of
2656 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2657 should replace the \"Date:\" one, or should be added below it."
2658 (interactive (list 'ut t))
2659 (let* ((header (or header
2660 (message-fetch-field "date")
2662 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2665 ((not gnus-article-date-lapsed-new-header)
2671 (date (if (vectorp header) (mail-header-date header)
2673 (inhibit-point-motion-hooks t)
2678 (article-narrow-to-head)
2679 (when (re-search-forward tdate-regexp nil t)
2680 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2681 date (or (get-text-property (gnus-point-at-bol)
2684 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2686 (when (and date (not (string= date "")))
2687 (goto-char (point-min))
2688 (let ((buffer-read-only nil))
2689 ;; Delete any old Date headers.
2690 (while (re-search-forward date-regexp nil t)
2692 (delete-region (progn (beginning-of-line) (point))
2693 (progn (gnus-article-forward-header)
2695 (delete-region (progn (beginning-of-line) (point))
2696 (progn (gnus-article-forward-header)
2699 (setq pos (point))))
2700 (when (and (not pos)
2701 (re-search-forward tdate-regexp nil t))
2705 (insert (article-make-date-line date (or type 'ut)))
2711 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2712 (put-text-property (match-beginning 1) (1+ (match-end 1))
2713 'original-date date)
2714 (put-text-property (match-beginning 1) (1+ (match-end 1))
2716 (put-text-property (match-beginning 2) (match-end 2)
2719 (defun article-make-date-line (date type)
2720 "Return a DATE line of TYPE."
2721 (unless (memq type '(local ut original user iso8601 lapsed english))
2722 (error "Unknown conversion type: %s" type))
2724 (let ((time (date-to-time date)))
2726 ;; Convert to the local timezone.
2728 (let ((tz (car (current-time-zone time))))
2729 (format "Date: %s %s%02d%02d" (current-time-string time)
2730 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2731 (/ (% (abs tz) 3600) 60))))
2732 ;; Convert to Universal Time.
2735 (current-time-string
2736 (let* ((e (parse-time-string date))
2737 (tm (apply 'encode-time e))
2739 (ls (- (cadr tm) (car (current-time-zone time)))))
2740 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2741 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2744 ;; Get the original date from the article.
2745 ((eq type 'original)
2746 (concat "Date: " (if (string-match "\n+$" date)
2747 (substring date 0 (match-beginning 0))
2749 ;; Let the user define the format.
2751 (let ((format (or (condition-case nil
2752 (with-current-buffer gnus-summary-buffer
2753 gnus-article-time-format)
2755 gnus-article-time-format)))
2756 (if (gnus-functionp format)
2757 (funcall format time)
2758 (concat "Date: " (format-time-string format time)))))
2761 (let ((tz (car (current-time-zone time))))
2764 (format-time-string "%Y%m%dT%H%M%S" time)
2765 (format "%s%02d%02d"
2766 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2767 (/ (% (abs tz) 3600) 60)))))
2768 ;; Do an X-Sent lapsed format.
2770 ;; If the date is seriously mangled, the timezone functions are
2771 ;; liable to bug out, so we ignore all errors.
2772 (let* ((now (current-time))
2773 (real-time (subtract-time now time))
2774 (real-sec (and real-time
2775 (+ (* (float (car real-time)) 65536)
2777 (sec (and real-time (abs real-sec)))
2787 ;; This is a bit convoluted, but basically we go
2788 ;; through the time units for years, weeks, etc,
2789 ;; and divide things to see whether that results
2790 ;; in positive answers.
2793 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2794 ;; The (remaining) seconds are too few to
2795 ;; be divided into this time unit.
2797 ;; It's big enough, so we output it.
2798 (setq sec (- sec (* num (cdr unit))))
2800 (concat (if prev ", " "") (int-to-string
2802 " " (symbol-name (car unit))
2803 (if (> num 1) "s" ""))
2805 article-time-units "")
2806 ;; If dates are odd, then it might appear like the
2807 ;; article was sent in the future.
2810 " in the future"))))))
2811 ;; Display the date in proper English
2813 (let ((dtime (decode-time time)))
2816 (number-to-string (nth 3 dtime))
2817 (let ((digit (% (nth 3 dtime) 10)))
2819 ((memq (nth 3 dtime) '(11 12 13)) "th")
2825 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2827 (number-to-string (nth 5 dtime))
2829 (format "%02d" (nth 2 dtime))
2831 (format "%02d" (nth 1 dtime)))))))
2833 (format "Date: %s (from Gnus)" date))))
2835 (defun article-date-local (&optional highlight)
2836 "Convert the current article date to the local timezone."
2837 (interactive (list t))
2838 (article-date-ut 'local highlight))
2840 (defun article-date-english (&optional highlight)
2841 "Convert the current article date to something that is proper English."
2842 (interactive (list t))
2843 (article-date-ut 'english highlight))
2845 (defun article-date-original (&optional highlight)
2846 "Convert the current article date to what it was originally.
2847 This is only useful if you have used some other date conversion
2848 function and want to see what the date was before converting."
2849 (interactive (list t))
2850 (article-date-ut 'original highlight))
2852 (defun article-date-lapsed (&optional highlight)
2853 "Convert the current article date to time lapsed since it was sent."
2854 (interactive (list t))
2855 (article-date-ut 'lapsed highlight))
2857 (defun article-update-date-lapsed ()
2858 "Function to be run from a timer to update the lapsed time line."
2859 (let (deactivate-mark)
2864 (set-buffer (window-buffer w))
2865 (when (eq major-mode 'gnus-article-mode)
2866 (goto-char (point-min))
2867 (when (re-search-forward "^X-Sent:" nil t)
2868 (article-date-lapsed t))))
2871 (defun gnus-start-date-timer (&optional n)
2872 "Start a timer to update the X-Sent header in the article buffers.
2873 The numerical prefix says how frequently (in seconds) the function
2878 (gnus-stop-date-timer)
2879 (setq article-lapsed-timer
2880 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2882 (defun gnus-stop-date-timer ()
2883 "Stop the X-Sent timer."
2885 (when article-lapsed-timer
2886 (nnheader-cancel-timer article-lapsed-timer)
2887 (setq article-lapsed-timer nil)))
2889 (defun article-date-user (&optional highlight)
2890 "Convert the current article date to the user-defined format.
2891 This format is defined by the `gnus-article-time-format' variable."
2892 (interactive (list t))
2893 (article-date-ut 'user highlight))
2895 (defun article-date-iso8601 (&optional highlight)
2896 "Convert the current article date to ISO8601."
2897 (interactive (list t))
2898 (article-date-ut 'iso8601 highlight))
2900 ;; (defun article-show-all ()
2901 ;; "Show all hidden text in the article buffer."
2904 ;; (let ((buffer-read-only nil))
2905 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2907 (defun article-remove-leading-whitespace ()
2908 "Remove excessive whitespace from all headers."
2912 (let ((buffer-read-only nil))
2913 (article-narrow-to-head)
2914 (goto-char (point-min))
2915 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2916 (delete-region (match-beginning 1) (match-end 1)))))))
2918 (defun article-emphasize (&optional arg)
2919 "Emphasize text according to `gnus-emphasis-alist'."
2920 (interactive (gnus-article-hidden-arg))
2921 (unless (gnus-article-check-hidden-text 'emphasis arg)
2925 (with-current-buffer gnus-summary-buffer
2926 gnus-article-emphasis-alist)
2928 gnus-emphasis-alist))
2929 (buffer-read-only nil)
2930 (props (append '(article-type emphasis)
2931 gnus-hidden-properties))
2932 regexp elem beg invisible visible face)
2935 (while (setq elem (pop alist))
2937 (setq regexp (car elem)
2938 invisible (nth 1 elem)
2939 visible (nth 2 elem)
2941 (while (re-search-forward regexp nil t)
2942 (when (and (match-beginning visible) (match-beginning invisible))
2943 (gnus-article-hide-text
2944 (match-beginning invisible) (match-end invisible) props)
2945 (gnus-article-unhide-text-type
2946 (match-beginning visible) (match-end visible) 'emphasis)
2947 (gnus-put-overlay-excluding-newlines
2948 (match-beginning visible) (match-end visible) 'face face)
2949 (gnus-add-wash-type 'emphasis)
2950 (goto-char (match-end invisible)))))))))
2952 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2953 "Setup newsgroup emphasis alist."
2954 (unless gnus-article-emphasis-alist
2955 (let ((name (and gnus-newsgroup-name
2956 (gnus-group-real-name gnus-newsgroup-name))))
2957 (make-local-variable 'gnus-article-emphasis-alist)
2958 (setq gnus-article-emphasis-alist
2960 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2961 (while (setq elem (pop alist))
2962 (when (and name (string-match (car elem) name))
2964 highlight (copy-sequence (cdr elem)))))
2966 (copy-sequence highlight-words)
2967 (if gnus-newsgroup-name
2968 (copy-sequence (gnus-group-find-parameter
2969 gnus-newsgroup-name 'highlight-words t)))
2970 gnus-emphasis-alist)))))
2973 (defvar gnus-summary-article-menu)
2974 (defvar gnus-summary-post-menu))
2976 ;;; Saving functions.
2978 (defun gnus-article-save (save-buffer file &optional num)
2979 "Save the currently selected article."
2980 (unless gnus-save-all-headers
2981 ;; Remove headers according to `gnus-saved-headers'.
2982 (let ((gnus-visible-headers
2983 (or gnus-saved-headers gnus-visible-headers))
2984 (gnus-article-buffer save-buffer))
2986 (set-buffer save-buffer)
2987 (article-hide-headers 1 t))))
2988 (save-window-excursion
2989 (if (not gnus-default-article-saver)
2990 (error "No default saver is defined")
2991 ;; !!! Magic! The saving functions all save
2992 ;; `gnus-save-article-buffer' (or so they think), but we
2993 ;; bind that variable to our save-buffer.
2994 (set-buffer gnus-article-buffer)
2995 (let* ((gnus-save-article-buffer save-buffer)
2998 ((not gnus-prompt-before-saving) 'default)
2999 ((eq gnus-prompt-before-saving 'always) nil)
3001 (gnus-number-of-articles-to-be-saved
3002 (when (eq gnus-prompt-before-saving t)
3004 (set-buffer gnus-article-current-summary)
3005 (funcall gnus-default-article-saver filename)))))
3007 (defun gnus-read-save-file-name (prompt &optional filename
3008 function group headers variable)
3010 (funcall function group headers (symbol-value variable)))
3015 ((eq filename 'default)
3021 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3024 (if (and gnus-number-of-articles-to-be-saved
3025 (> gnus-number-of-articles-to-be-saved 1))
3026 (format "these %d articles"
3027 gnus-number-of-articles-to-be-saved)
3030 ;; Let the split methods have their say.
3032 ;; No split name was found.
3035 (concat prompt " (default "
3036 (file-name-nondirectory default-name) ") ")
3037 (file-name-directory default-name)
3039 ;; A single group name is returned.
3040 ((stringp split-name)
3042 (funcall function split-name headers
3043 (symbol-value variable)))
3045 (concat prompt " (default "
3046 (file-name-nondirectory default-name) ") ")
3047 (file-name-directory default-name)
3049 ;; A single split name was found
3050 ((= 1 (length split-name))
3051 (let* ((name (expand-file-name
3053 gnus-article-save-directory))
3054 (dir (cond ((file-directory-p name)
3055 (file-name-as-directory name))
3056 ((file-exists-p name) name)
3057 (t gnus-article-save-directory))))
3059 (concat prompt " (default " name ") ")
3061 ;; A list of splits was found.
3063 (setq split-name (nreverse split-name))
3065 (let ((file-name-history
3066 (nconc split-name file-name-history)))
3070 (concat prompt " (`M-p' for defaults) ")
3071 gnus-article-save-directory
3073 gnus-article-save-directory)))
3074 (car (push result file-name-history)))))))
3075 ;; Create the directory.
3076 (gnus-make-directory (file-name-directory file))
3077 ;; If we have read a directory, we append the default file name.
3078 (when (file-directory-p file)
3079 (setq file (expand-file-name (file-name-nondirectory
3081 (file-name-as-directory file))))
3082 ;; Possibly translate some characters.
3083 (nnheader-translate-file-chars file))))))
3084 (gnus-make-directory (file-name-directory result))
3085 (set variable result)))
3087 (defun gnus-article-archive-name (group)
3088 "Return the first instance of an \"Archive-name\" in the current buffer."
3089 (let ((case-fold-search t))
3090 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3091 (nnheader-concat gnus-article-save-directory
3092 (match-string 1)))))
3094 (defun gnus-article-nndoc-name (group)
3095 "If GROUP is an nndoc group, return the name of the parent group."
3096 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3097 (gnus-group-get-parameter group 'save-article-group)))
3099 (defun gnus-summary-save-in-rmail (&optional filename)
3100 "Append this article to Rmail file.
3101 Optional argument FILENAME specifies file name.
3102 Directory to save to is default to `gnus-article-save-directory'."
3103 (setq filename (gnus-read-save-file-name
3104 "Save %s in rmail file:" filename
3105 gnus-rmail-save-name gnus-newsgroup-name
3106 gnus-current-headers 'gnus-newsgroup-last-rmail))
3107 (gnus-eval-in-buffer-window gnus-save-article-buffer
3111 (gnus-output-to-rmail filename))))
3114 (defun gnus-summary-save-in-mail (&optional filename)
3115 "Append this article to Unix mail file.
3116 Optional argument FILENAME specifies file name.
3117 Directory to save to is default to `gnus-article-save-directory'."
3118 (setq filename (gnus-read-save-file-name
3119 "Save %s in Unix mail file:" filename
3120 gnus-mail-save-name gnus-newsgroup-name
3121 gnus-current-headers 'gnus-newsgroup-last-mail))
3122 (gnus-eval-in-buffer-window gnus-save-article-buffer
3126 (if (and (file-readable-p filename)
3127 (file-regular-p filename)
3128 (mail-file-babyl-p filename))
3129 (rmail-output-to-rmail-file filename t)
3130 (gnus-output-to-mail filename)))))
3133 (defun gnus-summary-save-in-file (&optional filename overwrite)
3134 "Append this article to file.
3135 Optional argument FILENAME specifies file name.
3136 Directory to save to is default to `gnus-article-save-directory'."
3137 (setq filename (gnus-read-save-file-name
3138 "Save %s in file:" filename
3139 gnus-file-save-name gnus-newsgroup-name
3140 gnus-current-headers 'gnus-newsgroup-last-file))
3141 (gnus-eval-in-buffer-window gnus-save-article-buffer
3145 (when (and overwrite
3146 (file-exists-p filename))
3147 (delete-file filename))
3148 (gnus-output-to-file filename))))
3151 (defun gnus-summary-write-to-file (&optional filename)
3152 "Write this article to a file, overwriting it if the file exists.
3153 Optional argument FILENAME specifies file name.
3154 The directory to save in defaults to `gnus-article-save-directory'."
3155 (gnus-summary-save-in-file nil t))
3157 (defun gnus-summary-save-body-in-file (&optional filename)
3158 "Append this article body to a file.
3159 Optional argument FILENAME specifies file name.
3160 The directory to save in defaults to `gnus-article-save-directory'."
3161 (setq filename (gnus-read-save-file-name
3162 "Save %s body in file:" filename
3163 gnus-file-save-name gnus-newsgroup-name
3164 gnus-current-headers 'gnus-newsgroup-last-file))
3165 (gnus-eval-in-buffer-window gnus-save-article-buffer
3169 (when (article-goto-body)
3170 (narrow-to-region (point) (point-max)))
3171 (gnus-output-to-file filename))))
3174 (defun gnus-summary-save-in-pipe (&optional command)
3175 "Pipe this article to subprocess."
3177 (cond ((and (eq command 'default)
3178 gnus-last-shell-command)
3179 gnus-last-shell-command)
3184 "Shell command on %s: "
3185 (if (and gnus-number-of-articles-to-be-saved
3186 (> gnus-number-of-articles-to-be-saved 1))
3187 (format "these %d articles"
3188 gnus-number-of-articles-to-be-saved)
3190 gnus-last-shell-command))))
3191 (when (string-equal command "")
3192 (if gnus-last-shell-command
3193 (setq command gnus-last-shell-command)
3194 (error "A command is required")))
3195 (gnus-eval-in-buffer-window gnus-article-buffer
3198 (shell-command-on-region (point-min) (point-max) command nil)))
3199 (setq gnus-last-shell-command command))
3201 (defun gnus-summary-pipe-to-muttprint (&optional command)
3202 "Pipe this article to muttprint."
3203 (setq command (read-string
3204 "Print using command: " gnus-summary-muttprint-program
3205 nil gnus-summary-muttprint-program))
3206 (gnus-summary-save-in-pipe command))
3208 ;;; Article file names when saving.
3210 (defun gnus-capitalize-newsgroup (newsgroup)
3211 "Capitalize NEWSGROUP name."
3212 (when (not (zerop (length newsgroup)))
3213 (concat (char-to-string (upcase (aref newsgroup 0)))
3214 (substring newsgroup 1))))
3216 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3217 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3218 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3219 Otherwise, it is like ~/News/news/group/num."
3222 (concat (if (gnus-use-long-file-name 'not-save)
3223 (gnus-capitalize-newsgroup newsgroup)
3224 (gnus-newsgroup-directory-form newsgroup))
3225 "/" (int-to-string (mail-header-number headers)))
3226 gnus-article-save-directory)))
3228 (string-equal (file-name-directory default)
3229 (file-name-directory last-file))
3230 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3232 (or last-file default))))
3234 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3235 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3236 If variable `gnus-use-long-file-name' is non-nil, it is
3237 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3240 (concat (if (gnus-use-long-file-name 'not-save)
3242 (gnus-newsgroup-directory-form newsgroup))
3243 "/" (int-to-string (mail-header-number headers)))
3244 gnus-article-save-directory)))
3246 (string-equal (file-name-directory default)
3247 (file-name-directory last-file))
3248 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3250 (or last-file default))))
3252 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3253 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3254 If variable `gnus-use-long-file-name' is non-nil, it is
3255 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3258 (if (gnus-use-long-file-name 'not-save)
3261 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3263 gnus-article-save-directory)))
3265 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3266 "Generate file name from sender."
3267 (let ((from (mail-header-from headers)))
3269 (if (and from (string-match "\\([^ <]+\\)@" from))
3270 (match-string 1 from)
3272 gnus-article-save-directory)))
3274 (defun article-verify-x-pgp-sig ()
3277 (if (gnus-buffer-live-p gnus-original-article-buffer)
3278 (let ((sig (with-current-buffer gnus-original-article-buffer
3279 (gnus-fetch-field "X-PGP-Sig")))
3283 (mml2015-clear-verify-function))
3285 (insert-buffer gnus-original-article-buffer)
3286 (setq items (split-string sig))
3287 (message-narrow-to-head)
3288 (let ((inhibit-point-motion-hooks t)
3289 (case-fold-search t))
3290 ;; Don't verify multiple headers.
3291 (setq headers (mapconcat (lambda (header)
3293 (mail-fetch-field header) "\n"))
3294 (split-string (nth 1 items) ",") "")))
3295 (delete-region (point-min) (point-max))
3296 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3297 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3302 (if (looking-at "^-")
3305 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3306 (insert "Version: " (car items) "\n\n")
3307 (insert (mapconcat 'identity (cddr items) "\n"))
3308 (insert "\n-----END PGP SIGNATURE-----\n")
3309 (let ((mm-security-handle (list (format "multipart/signed"))))
3310 (mml2015-clean-buffer)
3311 (let ((coding-system-for-write (or gnus-newsgroup-charset
3313 (funcall (mml2015-clear-verify-function)))
3315 (or (mm-handle-multipart-ctl-parameter
3316 mm-security-handle 'gnus-details)
3317 (mm-handle-multipart-ctl-parameter
3318 mm-security-handle 'gnus-info)))))
3320 (let (buffer-read-only bface eface)
3322 (message-narrow-to-head)
3323 (goto-char (point-max))
3325 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3326 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3327 (message-remove-header "X-Gnus-PGP-Verify")
3328 (if (re-search-forward "^X-PGP-Sig:" nil t)
3330 (goto-char (point-max)))
3331 (narrow-to-region (point) (point))
3332 (insert "X-Gnus-PGP-Verify: " info "\n")
3333 (goto-char (point-min))
3336 (if (not (looking-at "^[ \t]"))
3340 (goto-char (point-min))
3341 (when (looking-at "\\([^:]+\\): *")
3342 (put-text-property (match-beginning 1) (1+ (match-end 1))
3344 (put-text-property (match-end 0) (point-max)
3345 'face eface)))))))))
3347 (defun article-verify-cancel-lock ()
3348 "Verify Cancel-Lock header."
3350 (if (gnus-buffer-live-p gnus-original-article-buffer)
3351 (canlock-verify gnus-original-article-buffer)))
3358 (setq afunc (car func)
3361 gfunc (intern (format "gnus-%s" func))))
3363 (when (fboundp afunc)
3364 `(lambda (&optional interactive &rest args)
3365 ,(documentation afunc t)
3366 (interactive (list t))
3368 (set-buffer gnus-article-buffer)
3370 (call-interactively ',afunc)
3371 (apply ',afunc args))))))))
3372 '(article-hide-headers
3373 article-verify-x-pgp-sig
3374 article-verify-cancel-lock
3375 article-hide-boring-headers
3376 article-treat-overstrike
3377 article-fill-long-lines
3378 article-capitalize-sentences
3380 article-remove-leading-whitespace
3381 article-display-x-face
3382 article-display-face
3383 article-de-quoted-unreadable
3384 article-de-base64-unreadable
3387 article-unsplit-urls
3388 article-hide-list-identifiers
3389 article-strip-banner
3392 article-hide-signature
3393 article-strip-headers-in-body
3394 article-remove-trailing-blank-lines
3395 article-strip-leading-blank-lines
3396 article-strip-multiple-blank-lines
3397 article-strip-leading-space
3398 article-strip-trailing-space
3399 article-strip-blank-lines
3400 article-strip-all-blank-lines
3402 article-date-english
3403 article-date-iso8601
3404 article-date-original
3406 article-decode-mime-words
3407 article-decode-charset
3408 article-decode-encoded-words
3412 article-treat-dumbquotes
3413 article-normalize-headers
3414 ;; (article-show-all . gnus-article-show-all-headers)
3418 ;;; Gnus article mode
3421 (put 'gnus-article-mode 'mode-class 'special)
3423 (set-keymap-parent gnus-article-mode-map widget-keymap)
3425 (gnus-define-keys gnus-article-mode-map
3426 " " gnus-article-goto-next-page
3427 "\177" gnus-article-goto-prev-page
3428 [delete] gnus-article-goto-prev-page
3429 [backspace] gnus-article-goto-prev-page
3430 "\C-c^" gnus-article-refer-article
3431 "h" gnus-article-show-summary
3432 "s" gnus-article-show-summary
3433 "\C-c\C-m" gnus-article-mail
3434 "?" gnus-article-describe-briefly
3435 "e" gnus-summary-edit-article
3436 "<" beginning-of-buffer
3438 "\C-c\C-i" gnus-info-find-node
3440 "R" gnus-article-reply-with-original
3441 "F" gnus-article-followup-with-original
3442 "\C-hk" gnus-article-describe-key
3443 "\C-hc" gnus-article-describe-key-briefly
3445 "\C-d" gnus-article-read-summary-keys
3446 "\M-*" gnus-article-read-summary-keys
3447 "\M-#" gnus-article-read-summary-keys
3448 "\M-^" gnus-article-read-summary-keys
3449 "\M-g" gnus-article-read-summary-keys)
3451 (substitute-key-definition
3452 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3454 (defun gnus-article-make-menu-bar ()
3455 (unless (boundp 'gnus-article-commands-menu)
3456 (gnus-summary-make-menu-bar))
3457 (gnus-turn-off-edit-menu 'article)
3458 (unless (boundp 'gnus-article-article-menu)
3460 gnus-article-article-menu gnus-article-mode-map ""
3462 ["Scroll forwards" gnus-article-goto-next-page t]
3463 ["Scroll backwards" gnus-article-goto-prev-page t]
3464 ["Show summary" gnus-article-show-summary t]
3465 ["Fetch Message-ID at point" gnus-article-refer-article t]
3466 ["Mail to address at point" gnus-article-mail t]
3467 ["Send a bug report" gnus-bug t]))
3470 gnus-article-treatment-menu gnus-article-mode-map ""
3471 ;; Fixme: this should use :active (and maybe :visible).
3473 ["Hide headers" gnus-article-hide-headers t]
3474 ["Hide signature" gnus-article-hide-signature t]
3475 ["Hide citation" gnus-article-hide-citation t]
3476 ["Treat overstrike" gnus-article-treat-overstrike t]
3477 ["Remove carriage return" gnus-article-remove-cr t]
3478 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3479 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3480 ["Remove base64" gnus-article-de-base64-unreadable t]
3481 ["Treat html" gnus-article-wash-html t]
3482 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3483 ["Decode HZ" gnus-article-decode-HZ t]))
3485 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3487 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3489 (gnus-run-hooks 'gnus-article-menu-hook)))
3491 (defun gnus-article-mode ()
3492 "Major mode for displaying an article.
3494 All normal editing commands are switched off.
3496 The following commands are available in addition to all summary mode
3498 \\<gnus-article-mode-map>
3499 \\[gnus-article-next-page]\t Scroll the article one page forwards
3500 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3501 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3502 \\[gnus-article-show-summary]\t Display the summary buffer
3503 \\[gnus-article-mail]\t Send a reply to the address near point
3504 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3505 \\[gnus-info-find-node]\t Go to the Gnus info node"
3507 (gnus-simplify-mode-line)
3508 (setq mode-name "Article")
3509 (setq major-mode 'gnus-article-mode)
3510 (make-local-variable 'minor-mode-alist)
3511 (use-local-map gnus-article-mode-map)
3512 (when (gnus-visual-p 'article-menu 'menu)
3513 (gnus-article-make-menu-bar)
3514 (when gnus-summary-tool-bar-map
3515 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3516 (gnus-update-format-specifications nil 'article-mode)
3517 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3518 (make-local-variable 'gnus-page-broken)
3519 (make-local-variable 'gnus-button-marker-list)
3520 (make-local-variable 'gnus-article-current-summary)
3521 (make-local-variable 'gnus-article-mime-handles)
3522 (make-local-variable 'gnus-article-decoded-p)
3523 (make-local-variable 'gnus-article-mime-handle-alist)
3524 (make-local-variable 'gnus-article-wash-types)
3525 (make-local-variable 'gnus-article-image-alist)
3526 (make-local-variable 'gnus-article-charset)
3527 (make-local-variable 'gnus-article-ignored-charsets)
3528 (gnus-set-default-directory)
3529 (buffer-disable-undo)
3530 (setq buffer-read-only t)
3531 (set-syntax-table gnus-article-mode-syntax-table)
3532 (mm-enable-multibyte)
3533 (gnus-run-hooks 'gnus-article-mode-hook))
3535 (defun gnus-article-setup-buffer ()
3536 "Initialize the article buffer."
3537 (let* ((name (if gnus-single-article-buffer "*Article*"
3538 (concat "*Article " gnus-newsgroup-name "*")))
3540 (progn (string-match "\\*Article" name)
3541 (concat " *Original Article"
3542 (substring name (match-end 0))))))
3543 (setq gnus-article-buffer name)
3544 (setq gnus-original-article-buffer original)
3545 (setq gnus-article-mime-handle-alist nil)
3546 ;; This might be a variable local to the summary buffer.
3547 (unless gnus-single-article-buffer
3549 (set-buffer gnus-summary-buffer)
3550 (setq gnus-article-buffer name)
3551 (setq gnus-original-article-buffer original)
3552 (gnus-set-global-variables)))
3553 (gnus-article-setup-highlight-words)
3554 ;; Init original article buffer.
3556 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3557 (mm-enable-multibyte)
3558 (setq major-mode 'gnus-original-article-mode)
3559 (make-local-variable 'gnus-original-article))
3560 (if (get-buffer name)
3563 (when (and gnus-article-edit-mode
3566 (y-or-n-p "Article mode edit in progress; discard? ")))
3567 (error "Action aborted"))
3568 (set (make-local-variable 'gnus-article-edit-mode) nil)
3569 (when gnus-article-mime-handles
3570 (mm-destroy-parts gnus-article-mime-handles)
3571 (setq gnus-article-mime-handles nil))
3572 ;; Set it to nil in article-buffer!
3573 (setq gnus-article-mime-handle-alist nil)
3574 (buffer-disable-undo)
3575 (setq buffer-read-only t)
3576 ;; This list just keeps growing if we don't reset it.
3577 (setq gnus-button-marker-list nil)
3578 (unless (eq major-mode 'gnus-article-mode)
3579 (gnus-article-mode))
3582 (set-buffer (gnus-get-buffer-create name))
3584 (make-local-variable 'gnus-summary-buffer)
3585 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3586 (current-buffer)))))
3588 ;; Set article window start at LINE, where LINE is the number of lines
3589 ;; from the head of the article.
3590 (defun gnus-article-set-window-start (&optional line)
3592 (gnus-get-buffer-window gnus-article-buffer t)
3594 (set-buffer gnus-article-buffer)
3595 (goto-char (point-min))
3598 (gnus-message 6 "Moved to bookmark")
3599 (search-forward "\n\n" nil t)
3603 (defun gnus-article-prepare (article &optional all-headers header)
3604 "Prepare ARTICLE in article mode buffer.
3605 ARTICLE should either be an article number or a Message-ID.
3606 If ARTICLE is an id, HEADER should be the article headers.
3607 If ALL-HEADERS is non-nil, no headers are hidden."
3609 ;; Make sure we start in a summary buffer.
3610 (unless (eq major-mode 'gnus-summary-mode)
3611 (set-buffer gnus-summary-buffer))
3612 (setq gnus-summary-buffer (current-buffer))
3613 (let* ((gnus-article (if header (mail-header-number header) article))
3614 (summary-buffer (current-buffer))
3615 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3616 (group gnus-newsgroup-name)
3619 (gnus-article-setup-buffer)
3620 (set-buffer gnus-article-buffer)
3621 ;; Deactivate active regions.
3622 (when (and (boundp 'transient-mark-mode)
3623 transient-mark-mode)
3624 (setq mark-active nil))
3625 (if (not (setq result (let ((buffer-read-only nil))
3626 (gnus-request-article-this-buffer
3628 ;; There is no such article.
3630 (when (and (numberp article)
3631 (not (memq article gnus-newsgroup-sparse)))
3632 (setq gnus-article-current
3633 (cons gnus-newsgroup-name article))
3634 (set-buffer gnus-summary-buffer)
3635 (setq gnus-current-article article)
3636 (if (and (memq article gnus-newsgroup-undownloaded)
3637 (not (gnus-online (gnus-find-method-for-group
3638 gnus-newsgroup-name))))
3640 (gnus-summary-set-agent-mark article)
3641 (message "Message marked for downloading"))
3642 (gnus-summary-mark-article article gnus-canceled-mark)
3643 (unless (memq article gnus-newsgroup-sparse)
3644 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3645 (if (or (eq result 'pseudo)
3646 (eq result 'nneething))
3649 (set-buffer summary-buffer)
3650 (push article gnus-newsgroup-history)
3651 (setq gnus-last-article gnus-current-article
3652 gnus-current-article 0
3653 gnus-current-headers nil
3654 gnus-article-current nil)
3655 (if (eq result 'nneething)
3656 (gnus-configure-windows 'summary)
3657 (gnus-configure-windows 'article))
3658 (gnus-set-global-variables))
3659 (let ((gnus-article-mime-handle-alist-1
3660 gnus-article-mime-handle-alist))
3661 (gnus-set-mode-line 'article)))
3662 ;; The result from the `request' was an actual article -
3663 ;; or at least some text that is now displayed in the
3665 (when (and (numberp article)
3666 (not (eq article gnus-current-article)))
3667 ;; Seems like a new article has been selected.
3668 ;; `gnus-current-article' must be an article number.
3670 (set-buffer summary-buffer)
3671 (push article gnus-newsgroup-history)
3672 (setq gnus-last-article gnus-current-article
3673 gnus-current-article article
3674 gnus-current-headers
3675 (gnus-summary-article-header gnus-current-article)
3676 gnus-article-current
3677 (cons gnus-newsgroup-name gnus-current-article))
3678 (unless (vectorp gnus-current-headers)
3679 (setq gnus-current-headers nil))
3680 (gnus-summary-goto-subject gnus-current-article)
3681 (when (gnus-summary-show-thread)
3682 ;; If the summary buffer really was folded, the
3683 ;; previous goto may not actually have gone to
3684 ;; the right article, but the thread root instead.
3686 (gnus-summary-goto-subject gnus-current-article))
3687 (gnus-run-hooks 'gnus-mark-article-hook)
3688 (gnus-set-mode-line 'summary)
3689 (when (gnus-visual-p 'article-highlight 'highlight)
3690 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3691 ;; Set the global newsgroup variables here.
3692 (gnus-set-global-variables)
3693 (setq gnus-have-all-headers
3694 (or all-headers gnus-show-all-headers))))
3696 (gnus-configure-windows 'article))
3697 (when (or (numberp article)
3699 (gnus-article-prepare-display)
3701 (goto-char (point-min))
3702 (setq gnus-page-broken
3703 (when gnus-break-pages
3704 (gnus-narrow-to-page)
3706 (let ((gnus-article-mime-handle-alist-1
3707 gnus-article-mime-handle-alist))
3708 (gnus-set-mode-line 'article))
3712 (set-window-point (get-buffer-window (current-buffer)) (point))
3713 (gnus-configure-windows 'article)
3717 (defun gnus-article-prepare-display ()
3718 "Make the current buffer look like a nice article."
3719 ;; Hooks for getting information from the article.
3720 ;; This hook must be called before being narrowed.
3721 (let ((gnus-article-buffer (current-buffer))
3723 (unless (eq major-mode 'gnus-article-mode)
3724 (gnus-article-mode))
3725 (setq buffer-read-only nil
3726 gnus-article-wash-types nil
3727 gnus-article-image-alist nil)
3728 (gnus-run-hooks 'gnus-tmp-internal-hook)
3729 (when gnus-display-mime-function
3730 (funcall gnus-display-mime-function))
3731 (gnus-run-hooks 'gnus-article-prepare-hook)))
3734 ;;; Gnus MIME viewing functions
3737 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3738 "Format of the MIME buttons.
3740 Valid specifiers include:
3742 %T MIME type, along with additional info
3743 %n The `name' parameter
3744 %d The description, if any
3745 %l The length of the encoded part
3746 %p The part identifier number
3747 %e Dots if the part isn't displayed
3749 General format specifiers can also be used. See Info node
3750 `(gnus)Formatting Variables'.")
3752 (defvar gnus-mime-button-line-format-alist
3753 '((?t gnus-tmp-type ?s)
3754 (?T gnus-tmp-type-long ?s)
3755 (?n gnus-tmp-name ?s)
3756 (?d gnus-tmp-description ?s)
3758 (?l gnus-tmp-length ?d)
3759 (?e gnus-tmp-dots ?s)))
3761 (defvar gnus-mime-button-commands
3762 '((gnus-article-press-button "\r" "Toggle Display")
3763 (gnus-mime-view-part "v" "View Interactively...")
3764 (gnus-mime-view-part-as-type "t" "View As Type...")
3765 (gnus-mime-view-part-as-charset "C" "View As charset...")
3766 (gnus-mime-save-part "o" "Save...")
3767 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3768 (gnus-mime-delete-part "d" "Delete part")
3769 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3770 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3771 (gnus-mime-view-part-internally "E" "View Internally")
3772 (gnus-mime-view-part-externally "e" "View Externally")
3773 (gnus-mime-print-part "p" "Print")
3774 (gnus-mime-pipe-part "|" "Pipe To Command...")
3775 (gnus-mime-action-on-part "." "Take action on the part...")))
3777 (defun gnus-article-mime-part-status ()
3778 (if gnus-article-mime-handle-alist-1
3779 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3781 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3784 (defvar gnus-mime-button-map
3785 (let ((map (make-sparse-keymap)))
3786 (unless (>= (string-to-number emacs-version) 21)
3787 ;; XEmacs doesn't care.
3788 (set-keymap-parent map gnus-article-mode-map))
3789 (define-key map gnus-mouse-2 'gnus-article-push-button)
3790 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3791 (dolist (c gnus-mime-button-commands)
3792 (define-key map (cadr c) (car c)))
3795 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3797 ,@(mapcar (lambda (c)
3798 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
3801 (define-compiler-macro popup-menu (&whole form
3802 menu &optional position prefix)
3803 (if (and (fboundp 'popup-menu)
3804 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3806 ;; Gnus is probably running under Emacs 20.
3807 `(let* ((menu (cdr ,menu))
3808 (response (x-popup-menu
3810 (cons "" (mapcar (lambda (c)
3811 (cons (caddr c) (car c)))
3814 (call-interactively (nth 3 (assq response menu))))))))
3816 (defun gnus-mime-button-menu (event prefix)
3817 "Construct a context-sensitive menu of MIME commands."
3818 (interactive "e\nP")
3819 (save-window-excursion
3820 (let ((pos (event-start event)))
3821 (select-window (posn-window pos))
3822 (goto-char (posn-point pos))
3823 (gnus-article-check-buffer)
3824 (popup-menu gnus-mime-button-menu nil prefix))))
3826 (defun gnus-mime-view-all-parts (&optional handles)
3827 "View all the MIME parts."
3829 (save-current-buffer
3830 (set-buffer gnus-article-buffer)
3831 (let ((handles (or handles gnus-article-mime-handles))
3832 (mail-parse-charset gnus-newsgroup-charset)
3833 (mail-parse-ignored-charsets
3834 (with-current-buffer gnus-summary-buffer
3835 gnus-newsgroup-ignored-charsets)))
3837 (mm-remove-parts handles)
3838 (goto-char (point-min))
3839 (or (search-forward "\n\n") (goto-char (point-max)))
3840 (let (buffer-read-only)
3841 (delete-region (point) (point-max))
3842 (mm-display-parts handles))))))
3844 (defun gnus-mime-save-part-and-strip ()
3845 "Save the MIME part under point then replace it with an external body."
3847 (gnus-article-check-buffer)
3848 (let* ((data (get-text-property (point) 'gnus-data))
3850 (handles gnus-article-mime-handles))
3851 (if (mm-multiple-handles gnus-article-mime-handles)
3852 (error "This function is not implemented"))
3853 (setq file (and data (mm-save-part data)))
3855 (with-current-buffer (mm-handle-buffer data)
3857 (insert "Content-Type: " (mm-handle-media-type data))
3858 (mml-insert-parameter-string (cdr (mm-handle-type data))
3861 (insert "Content-ID: " (message-make-message-id) "\n")
3862 (insert "Content-Transfer-Encoding: binary\n")
3865 (cdr (mm-make-handle nil
3866 `("message/external-body"
3867 (access-type . "LOCAL-FILE")
3869 (set-buffer gnus-summary-buffer)
3870 (gnus-article-edit-article
3873 (let ((mail-parse-charset (or gnus-article-charset
3874 ',gnus-newsgroup-charset))
3875 (mail-parse-ignored-charsets
3876 (or gnus-article-ignored-charsets
3877 ',gnus-newsgroup-ignored-charsets))
3878 (mbl mml-buffer-list))
3879 (setq mml-buffer-list nil)
3880 (insert-buffer gnus-original-article-buffer)
3881 (mime-to-mml ',handles)
3882 (setq gnus-article-mime-handles nil)
3883 (let ((mbl1 mml-buffer-list))
3884 (setq mml-buffer-list mbl)
3885 (set (make-local-variable 'mml-buffer-list) mbl1))
3886 ;; LOCAL argument of add-hook differs between GNU Emacs
3887 ;; and XEmacs. make-local-hook makes sure they are local.
3888 (make-local-hook 'kill-buffer-hook)
3889 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3890 `(lambda (no-highlight)
3891 (let ((mail-parse-charset (or gnus-article-charset
3892 ',gnus-newsgroup-charset))
3893 (message-options message-options)
3894 (message-options-set-recipient)
3895 (mail-parse-ignored-charsets
3896 (or gnus-article-ignored-charsets
3897 ',gnus-newsgroup-ignored-charsets)))
3899 (mml-destroy-buffers)
3900 (remove-hook 'kill-buffer-hook
3901 'mml-destroy-buffers t)
3902 (kill-local-variable 'mml-buffer-list))
3903 (gnus-summary-edit-article-done
3904 ,(or (mail-header-references gnus-current-headers) "")
3905 ,(gnus-group-read-only-p)
3906 ,gnus-summary-buffer no-highlight))))))
3908 (defun gnus-mime-delete-part ()
3909 "Delete the MIME part under point.
3910 Replace it with some information about the removed part."
3912 (gnus-article-check-buffer)
3913 (let* ((data (get-text-property (point) 'gnus-data))
3914 (handles gnus-article-mime-handles)
3918 (mail-decode-encoded-word-string (or (mm-handle-description data)
3921 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
3923 (type (mm-handle-media-type data)))
3924 (if (mm-multiple-handles gnus-article-mime-handles)
3925 (error "This function is not implemented"))
3926 (with-current-buffer (mm-handle-buffer data)
3927 (let ((bsize (format "%s" (buffer-size))))
3931 "<#part type=text/plain nofile=yes disposition=attachment"
3932 " description=\"Deleted attachment (" bsize " Byte)\">"
3934 "| The following attachment has been deleted:\n"
3936 "| Type: " type "\n"
3937 "| Filename: " filename "\n"
3938 "| Size (encoded): " bsize " Byte\n"
3939 "| Description: " description "\n"
3943 (cdr (mm-make-handle nil `("text/plain"))))))
3944 (set-buffer gnus-summary-buffer)
3945 ;; FIXME: maybe some of the following code (borrowed from
3946 ;; `gnus-mime-save-part-and-strip') isn't necessary?
3947 (gnus-article-edit-article
3950 (let ((mail-parse-charset (or gnus-article-charset
3951 ',gnus-newsgroup-charset))
3952 (mail-parse-ignored-charsets
3953 (or gnus-article-ignored-charsets
3954 ',gnus-newsgroup-ignored-charsets))
3955 (mbl mml-buffer-list))
3956 (setq mml-buffer-list nil)
3957 (insert-buffer gnus-original-article-buffer)
3958 (mime-to-mml ',handles)
3959 (setq gnus-article-mime-handles nil)
3960 (let ((mbl1 mml-buffer-list))
3961 (setq mml-buffer-list mbl)
3962 (set (make-local-variable 'mml-buffer-list) mbl1))
3963 ;; LOCAL argument of add-hook differs between GNU Emacs
3964 ;; and XEmacs. make-local-hook makes sure they are local.
3965 (make-local-hook 'kill-buffer-hook)
3966 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3967 `(lambda (no-highlight)
3968 (let ((mail-parse-charset (or gnus-article-charset
3969 ',gnus-newsgroup-charset))
3970 (message-options message-options)
3971 (message-options-set-recipient)
3972 (mail-parse-ignored-charsets
3973 (or gnus-article-ignored-charsets
3974 ',gnus-newsgroup-ignored-charsets)))
3976 (mml-destroy-buffers)
3977 (remove-hook 'kill-buffer-hook
3978 'mml-destroy-buffers t)
3979 (kill-local-variable 'mml-buffer-list))
3980 (gnus-summary-edit-article-done
3981 ,(or (mail-header-references gnus-current-headers) "")
3982 ,(gnus-group-read-only-p)
3983 ,gnus-summary-buffer no-highlight))))
3984 ;; Not in `gnus-mime-save-part-and-strip':
3985 (gnus-article-edit-done)
3986 (gnus-summary-expand-window)
3987 (gnus-summary-show-article))
3989 (defun gnus-mime-save-part ()
3990 "Save the MIME part under point."
3992 (gnus-article-check-buffer)
3993 (let ((data (get-text-property (point) 'gnus-data)))
3995 (mm-save-part data))))
3997 (defun gnus-mime-pipe-part ()
3998 "Pipe the MIME part under point to a process."
4000 (gnus-article-check-buffer)
4001 (let ((data (get-text-property (point) 'gnus-data)))
4003 (mm-pipe-part data))))
4005 (defun gnus-mime-view-part ()
4006 "Interactively choose a viewing method for the MIME part under point."
4008 (gnus-article-check-buffer)
4009 (let ((data (get-text-property (point) 'gnus-data)))
4011 (setq gnus-article-mime-handles
4013 gnus-article-mime-handles (setq data (copy-sequence data))))
4014 (mm-interactively-view-part data))))
4016 (defun gnus-mime-view-part-as-type-internal ()
4017 (gnus-article-check-buffer)
4018 (let* ((name (mail-content-type-get
4019 (mm-handle-type (get-text-property (point) 'gnus-data))
4021 (def-type (and name (mm-default-file-encoding name))))
4022 (and def-type (cons def-type 0))))
4024 (defun gnus-mime-view-part-as-type (&optional mime-type)
4025 "Choose a MIME media type, and view the part as such."
4028 (setq mime-type (completing-read
4029 "View as MIME type: "
4030 (mapcar #'list (mailcap-mime-types))
4032 (gnus-mime-view-part-as-type-internal))))
4033 (gnus-article-check-buffer)
4034 (let ((handle (get-text-property (point) 'gnus-data)))
4037 (mm-make-handle (mm-handle-buffer handle)
4038 (cons mime-type (cdr (mm-handle-type handle)))
4039 (mm-handle-encoding handle)
4040 (mm-handle-undisplayer handle)
4041 (mm-handle-disposition handle)
4042 (mm-handle-description handle)
4044 (mm-handle-id handle)))
4045 (setq gnus-article-mime-handles
4046 (mm-merge-handles gnus-article-mime-handles handle))
4047 (gnus-mm-display-part handle))))
4050 (require 'jka-compr))
4052 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4053 ;; emacs can do that itself.
4055 (defun gnus-mime-jka-compr-maybe-uncompress ()
4056 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4057 The uncompress method used is derived from `buffer-file-name'."
4058 (when (and (fboundp 'jka-compr-installed-p)
4059 (jka-compr-installed-p))
4060 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4062 (let ((basename (file-name-nondirectory buffer-file-name))
4063 (args (jka-compr-info-uncompress-args info))
4064 (prog (jka-compr-info-uncompress-program info))
4065 (message (jka-compr-info-uncompress-message info))
4066 (err-file (jka-compr-make-temp-name)))
4068 (message "%s %s..." message basename))
4070 (unless (memq (apply 'call-process-region
4071 (point-min) (point-max)
4073 t (list t err-file) nil
4075 jka-compr-acceptable-retval-list)
4076 (jka-compr-error prog args basename message err-file))
4077 (jka-compr-delete-temp-file err-file)))))))
4079 (defun gnus-mime-copy-part (&optional handle)
4080 "Put the MIME part under point into a new buffer.
4081 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4084 (gnus-article-check-buffer)
4085 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4086 (contents (and handle (mm-get-part handle)))
4088 (file-name-nondirectory
4090 (mail-content-type-get (mm-handle-type handle) 'name)
4091 (mail-content-type-get (mm-handle-disposition handle)
4094 (buffer (and base (generate-new-buffer base))))
4096 (switch-to-buffer buffer)
4098 ;; We do it this way to make `normal-mode' set the appropriate mode.
4101 (setq buffer-file-name (expand-file-name base))
4102 (gnus-mime-jka-compr-maybe-uncompress)
4104 (setq buffer-file-name nil))
4105 (goto-char (point-min)))))
4107 (defun gnus-mime-print-part (&optional handle filename)
4108 "Print the MIME part under point."
4109 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4110 (gnus-article-check-buffer)
4111 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4112 (contents (and handle (mm-get-part handle)))
4113 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4114 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4119 (mm-save-part-to-file handle file)
4120 (call-process shell-file-name nil
4121 (generate-new-buffer " *mm*")
4123 shell-command-switch
4125 printer file (mm-handle-type handle))))
4129 (gnus-print-buffer))
4130 (ps-despool filename)))))
4132 (defun gnus-mime-inline-part (&optional handle arg)
4133 "Insert the MIME part under point into the current buffer."
4134 (interactive (list nil current-prefix-arg))
4135 (gnus-article-check-buffer)
4136 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4141 (if (and (not arg) (mm-handle-undisplayer handle))
4142 (mm-remove-part handle)
4143 (setq contents (mm-get-part handle))
4146 (setq charset (or (mail-content-type-get
4147 (mm-handle-type handle) 'charset)
4148 gnus-newsgroup-charset)))
4150 (if (mm-handle-undisplayer handle)
4151 (mm-remove-part handle))
4154 gnus-summary-show-article-charset-alist))
4155 (mm-read-coding-system "Charset: ")))))
4157 (mm-insert-inline handle
4159 (setq charset (mm-charset-to-coding-system
4161 (not (eq charset 'ascii)))
4162 (mm-decode-coding-string contents charset)
4166 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4167 "Insert the MIME part under point into the current buffer using the
4169 (interactive (list nil current-prefix-arg))
4170 (gnus-article-check-buffer)
4171 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4176 (if (mm-handle-undisplayer handle)
4177 (mm-remove-part handle))
4178 (let ((gnus-newsgroup-charset
4180 gnus-summary-show-article-charset-alist))
4181 (mm-read-coding-system "Charset: ")))
4182 (gnus-newsgroup-ignored-charsets 'gnus-all))
4183 (gnus-article-press-button)))))
4185 (defun gnus-mime-view-part-externally (&optional handle)
4186 "View the MIME part under point with an external viewer."
4188 (gnus-article-check-buffer)
4189 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4190 (mm-user-display-methods nil)
4191 (mm-inlined-types nil)
4192 (mail-parse-charset gnus-newsgroup-charset)
4193 (mail-parse-ignored-charsets
4194 (save-excursion (set-buffer gnus-summary-buffer)
4195 gnus-newsgroup-ignored-charsets)))
4197 (if (mm-handle-undisplayer handle)
4198 (mm-remove-part handle)
4199 (mm-display-part handle)))))
4201 (defun gnus-mime-view-part-internally (&optional handle)
4202 "View the MIME part under point with an internal viewer.
4203 If no internal viewer is available, use an external viewer."
4205 (gnus-article-check-buffer)
4206 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4207 (mm-inlined-types '(".*"))
4208 (mm-inline-large-images t)
4209 (mail-parse-charset gnus-newsgroup-charset)
4210 (mail-parse-ignored-charsets
4211 (save-excursion (set-buffer gnus-summary-buffer)
4212 gnus-newsgroup-ignored-charsets))
4215 (if (mm-handle-undisplayer handle)
4216 (mm-remove-part handle)
4217 (mm-display-part handle)))))
4219 (defun gnus-mime-action-on-part (&optional action)
4220 "Do something with the MIME attachment at \(point\)."
4222 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4223 (gnus-article-check-buffer)
4224 (let ((action-pair (assoc action gnus-mime-action-alist)))
4226 (funcall (cdr action-pair)))))
4228 (defun gnus-article-part-wrapper (n function)
4229 (save-current-buffer
4230 (set-buffer gnus-article-buffer)
4231 (when (> n (length gnus-article-mime-handle-alist))
4232 (error "No such part"))
4233 (gnus-article-goto-part n)
4234 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4235 (funcall function handle))))
4237 (defun gnus-article-pipe-part (n)
4238 "Pipe MIME part N, which is the numerical prefix."
4240 (gnus-article-part-wrapper n 'mm-pipe-part))
4242 (defun gnus-article-save-part (n)
4243 "Save MIME part N, which is the numerical prefix."
4245 (gnus-article-part-wrapper n 'mm-save-part))
4247 (defun gnus-article-interactively-view-part (n)
4248 "View MIME part N interactively, which is the numerical prefix."
4250 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4252 (defun gnus-article-copy-part (n)
4253 "Copy MIME part N, which is the numerical prefix."
4255 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4257 (defun gnus-article-view-part-as-charset (n)
4258 "Copy MIME part N, which is the numerical prefix."
4260 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4262 (defun gnus-article-view-part-externally (n)
4263 "View MIME part N externally, which is the numerical prefix."
4265 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4267 (defun gnus-article-inline-part (n)
4268 "Inline MIME part N, which is the numerical prefix."
4270 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4272 (defun gnus-article-mime-match-handle-first (condition)
4274 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4275 (while (setq ihandle (pop alist))
4277 ((functionp condition)
4278 (funcall condition (cdr ihandle)))
4279 ((eq condition 'undisplayed)
4280 (not (or (mm-handle-undisplayer (cdr ihandle))
4281 (equal (mm-handle-media-type (cdr ihandle))
4282 "multipart/alternative"))))
4283 ((eq condition 'undisplayed-alternative)
4284 (not (mm-handle-undisplayer (cdr ihandle))))
4286 (gnus-article-goto-part (car ihandle))
4287 (or (not n) (< (car ihandle) n)))
4288 (setq n (car ihandle))))
4292 (defun gnus-article-view-part (&optional n)
4293 "View MIME part N, which is the numerical prefix."
4295 (save-current-buffer
4296 (set-buffer gnus-article-buffer)
4297 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4298 gnus-article-mime-match-handle-function)))
4299 (when (> n (length gnus-article-mime-handle-alist))
4300 (error "No such part"))
4301 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4302 (when (gnus-article-goto-part n)
4303 (if (equal (car handle) "multipart/alternative")
4304 (gnus-article-press-button)
4305 (when (eq (gnus-mm-display-part handle) 'internal)
4306 (gnus-set-window-start)))))))
4308 (defsubst gnus-article-mime-total-parts ()
4309 (if (bufferp (car gnus-article-mime-handles))
4311 (1- (length gnus-article-mime-handles))))
4313 (defun gnus-mm-display-part (handle)
4314 "Display HANDLE and fix MIME button."
4315 (let ((id (get-text-property (point) 'gnus-part))
4320 (let ((window (selected-window))
4321 (mail-parse-charset gnus-newsgroup-charset)
4322 (mail-parse-ignored-charsets
4323 (if (gnus-buffer-live-p gnus-summary-buffer)
4325 (set-buffer gnus-summary-buffer)
4326 gnus-newsgroup-ignored-charsets)
4330 (let ((win (gnus-get-buffer-window (current-buffer) t))
4333 (select-window win))
4336 (if (mm-handle-displayed-p handle)
4337 ;; This will remove the part.
4338 (mm-display-part handle)
4340 (narrow-to-region (point)
4341 (if (eobp) (point) (1+ (point))))
4342 (mm-display-part handle)
4343 ;; We narrow to the part itself and
4344 ;; then call the treatment functions.
4345 (goto-char (point-min))
4347 (narrow-to-region (point) (point-max))
4350 (gnus-article-mime-total-parts)
4351 (mm-handle-media-type handle)))))
4352 (if (window-live-p window)
4353 (select-window window)))))
4356 (gnus-insert-mime-button
4357 handle id (list (mm-handle-displayed-p handle)))
4358 (goto-char point))))
4360 (defun gnus-article-goto-part (n)
4361 "Go to MIME part N."
4362 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4364 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4365 (let ((gnus-tmp-name
4366 (or (mail-content-type-get (mm-handle-type handle) 'name)
4367 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4368 (mail-content-type-get (mm-handle-type handle) 'url)
4370 (gnus-tmp-type (mm-handle-media-type handle))
4371 (gnus-tmp-description
4372 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4375 (if (if displayed (car displayed)
4376 (mm-handle-displayed-p handle))
4378 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4380 gnus-tmp-type-long b e)
4381 (when (string-match ".*/" gnus-tmp-name)
4382 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4383 (setq gnus-tmp-type-long (concat gnus-tmp-type
4384 (and (not (equal gnus-tmp-name ""))
4385 (concat "; " gnus-tmp-name))))
4386 (unless (equal gnus-tmp-description "")
4387 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4392 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4393 `(,@(gnus-local-map-property gnus-mime-button-map)
4394 gnus-callback gnus-mm-display-part
4395 gnus-part ,gnus-tmp-id
4396 article-type annotation
4399 ;; Exclude a newline.
4402 (widget-convert-button
4405 :action 'gnus-widget-press-button
4406 :button-keymap gnus-mime-button-map
4408 (lambda (widget/window &optional overlay pos)
4409 ;; Needed to properly clear the message due to a bug in
4410 ;; wid-edit (XEmacs only).
4411 (if (boundp 'help-echo-owns-message)
4412 (setq help-echo-owns-message t))
4414 "%S: %s the MIME part; %S: more options"
4415 (aref gnus-mouse-2 0)
4416 ;; XEmacs will get a single widget arg; Emacs 21 will get
4417 ;; window, overlay, position.
4418 (if (mm-handle-displayed-p
4420 (with-current-buffer (gnus-overlay-buffer overlay)
4421 (widget-get (widget-at (gnus-overlay-start overlay))
4423 (widget-get widget/window :mime-handle)))
4425 (aref gnus-down-mouse-3 0))))))
4427 (defun gnus-widget-press-button (elems el)
4428 (goto-char (widget-get elems :from))
4429 (gnus-article-press-button))
4431 (defvar gnus-displaying-mime nil)
4433 (defun gnus-display-mime (&optional ihandles)
4434 "Display the MIME parts."
4436 (save-selected-window
4437 (let ((window (get-buffer-window gnus-article-buffer))
4440 (select-window window)
4441 ;; We have to do this since selecting the window
4442 ;; may change the point. So we set the window point.
4443 (set-window-point window point)))
4444 (let* ((handles (or ihandles
4445 (mm-dissect-buffer nil gnus-article-loose-mime)
4446 (and gnus-article-emulate-mime
4448 buffer-read-only handle name type b e display)
4449 (when (and (not ihandles)
4450 (not gnus-displaying-mime))
4451 ;; Top-level call; we clean up.
4452 (when gnus-article-mime-handles
4453 (mm-destroy-parts gnus-article-mime-handles)
4454 (setq gnus-article-mime-handle-alist nil));; A trick.
4455 (setq gnus-article-mime-handles handles)
4456 ;; We allow users to glean info from the handles.
4457 (when gnus-article-mime-part-function
4458 (gnus-mime-part-function handles)))
4460 (or (not (stringp (car handles)))
4463 (when (and (not ihandles)
4464 (not gnus-displaying-mime))
4465 ;; Clean up for mime parts.
4467 (delete-region (point) (point-max)))
4468 (let ((gnus-displaying-mime t))
4469 (gnus-mime-display-part handles)))
4472 (narrow-to-region (point) (point-max))
4473 (gnus-treat-article nil 1 1)
4476 ;; Highlight the headers.
4480 (narrow-to-region (point-min) (point))
4481 (gnus-treat-article 'head))))))))
4483 (defvar gnus-mime-display-multipart-as-mixed nil)
4484 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4485 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4487 (defun gnus-mime-display-part (handle)
4490 ((not (stringp (car handle)))
4491 (gnus-mime-display-single handle))
4492 ;; User-defined multipart
4493 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4494 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4496 ;; multipart/alternative
4497 ((and (equal (car handle) "multipart/alternative")
4498 (not (or gnus-mime-display-multipart-as-mixed
4499 gnus-mime-display-multipart-alternative-as-mixed)))
4500 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4501 (push (cons id handle) gnus-article-mime-handle-alist)
4502 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4503 ;; multipart/related
4504 ((and (equal (car handle) "multipart/related")
4505 (not (or gnus-mime-display-multipart-as-mixed
4506 gnus-mime-display-multipart-related-as-mixed)))
4507 ;;;!!!We should find the start part, but we just default
4508 ;;;!!!to the first part.
4509 ;;(gnus-mime-display-part (cadr handle))
4510 ;;;!!! Most multipart/related is an HTML message plus images.
4511 ;;;!!! Unfortunately we are unable to let W3 display those
4512 ;;;!!! included images, so we just display it as a mixed multipart.
4513 ;;(gnus-mime-display-mixed (cdr handle))
4514 ;;;!!! No, w3 can display everything just fine.
4515 (gnus-mime-display-part (cadr handle)))
4516 ((equal (car handle) "multipart/signed")
4517 (gnus-add-wash-type 'signed)
4518 (gnus-mime-display-security handle))
4519 ((equal (car handle) "multipart/encrypted")
4520 (gnus-add-wash-type 'encrypted)
4521 (gnus-mime-display-security handle))
4522 ;; Other multiparts are handled like multipart/mixed.
4524 (gnus-mime-display-mixed (cdr handle)))))
4526 (defun gnus-mime-part-function (handles)
4527 (if (stringp (car handles))
4528 (mapcar 'gnus-mime-part-function (cdr handles))
4529 (funcall gnus-article-mime-part-function handles)))
4531 (defun gnus-mime-display-mixed (handles)
4532 (mapcar 'gnus-mime-display-part handles))
4534 (defun gnus-mime-display-single (handle)
4535 (let ((type (mm-handle-media-type handle))
4536 (ignored gnus-ignored-mime-types)
4543 (when (string-match (pop ignored) type)
4544 (throw 'ignored nil)))
4545 (if (and (setq not-attachment
4546 (and (not (mm-inline-override-p handle))
4547 (or (not (mm-handle-disposition handle))
4548 (equal (car (mm-handle-disposition handle))
4550 (mm-attachment-override-p handle))))
4551 (mm-automatic-display-p handle)
4553 (mm-inlinable-p handle)
4554 (mm-inlined-p handle))
4555 (mm-automatic-external-display-p type)))
4557 (when (equal (mm-handle-media-supertype handle) "text")
4559 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4561 (push (cons id handle) gnus-article-mime-handle-alist)
4562 (when (or (not display)
4563 (not (gnus-unbuttonized-mime-type-p type)))
4564 ;(gnus-article-insert-newline)
4565 (gnus-insert-mime-button
4566 handle id (list (or display (and not-attachment text))))
4567 (gnus-article-insert-newline)
4568 ;(gnus-article-insert-newline)
4569 ;; Remember modify the number of forward lines.
4577 (let ((mail-parse-charset gnus-newsgroup-charset)
4578 (mail-parse-ignored-charsets
4579 (save-excursion (condition-case ()
4580 (set-buffer gnus-summary-buffer)
4582 gnus-newsgroup-ignored-charsets)))
4583 (mm-display-part handle t))
4584 (goto-char (point-max)))
4585 ((and text not-attachment)
4589 (gnus-article-insert-newline)
4590 (mm-insert-inline handle (mm-get-part handle))
4591 (goto-char (point-max))))
4595 (narrow-to-region beg (point))
4598 (gnus-article-mime-total-parts)
4599 (mm-handle-media-type handle)))))))))
4601 (defun gnus-unbuttonized-mime-type-p (type)
4602 "Say whether TYPE is to be unbuttonized."
4603 (unless gnus-inhibit-mime-unbuttonizing
4605 (let ((types gnus-unbuttonized-mime-types))
4607 (when (string-match (pop types) type)
4608 (throw 'found t)))))
4610 (let ((types gnus-buttonized-mime-types))
4612 (when (string-match (pop types) type)
4613 (throw 'found t)))))))))
4615 (defun gnus-article-insert-newline ()
4616 "Insert a newline, but mark it as undeletable."
4617 (gnus-put-text-property
4618 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4620 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4621 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4624 handle buffer-read-only from props begend not-pref)
4625 (save-window-excursion
4628 (narrow-to-region (car ibegend)
4631 (goto-char (car ibegend))
4634 (delete-region (point-min) (point-max))
4635 (mm-remove-parts handles))
4636 (setq begend (list (point-marker)))
4638 (unless (setq not-pref (cadr (member preferred ihandles)))
4639 (setq not-pref (car ihandles)))
4642 (not (gnus-unbuttonized-mime-type-p
4643 "multipart/alternative")))
4644 (gnus-add-text-properties
4647 (insert (format "%d. " id))
4651 (unless ,(not ibegend)
4652 (setq gnus-article-mime-handle-alist
4653 ',gnus-article-mime-handle-alist))
4654 (gnus-mime-display-alternative
4655 ',ihandles ',not-pref ',begend ,id))
4656 ,@(gnus-local-map-property gnus-mime-button-map)
4657 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4658 face ,gnus-article-button-face
4661 (widget-convert-button 'link from (point)
4662 :action 'gnus-widget-press-button
4663 :button-keymap gnus-widget-button-keymap)
4665 (while (setq handle (pop handles))
4666 (gnus-add-text-properties
4669 (insert (format "(%c) %-18s"
4670 (if (equal handle preferred) ?* ? )
4671 (mm-handle-media-type handle)))
4675 (unless ,(not ibegend)
4676 (setq gnus-article-mime-handle-alist
4677 ',gnus-article-mime-handle-alist))
4678 (gnus-mime-display-alternative
4679 ',ihandles ',handle ',begend ,id))
4680 ,@(gnus-local-map-property gnus-mime-button-map)
4681 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4682 face ,gnus-article-button-face
4685 (widget-convert-button 'link from (point)
4686 :action 'gnus-widget-press-button
4687 :button-keymap gnus-widget-button-keymap)
4691 (if (stringp (car preferred))
4692 (gnus-display-mime preferred)
4693 (let ((mail-parse-charset gnus-newsgroup-charset)
4694 (mail-parse-ignored-charsets
4695 (save-excursion (set-buffer gnus-summary-buffer)
4696 gnus-newsgroup-ignored-charsets)))
4697 (mm-display-part preferred)
4701 (narrow-to-region (car begend) (point-max))
4703 nil (length gnus-article-mime-handle-alist)
4704 (gnus-article-mime-total-parts)
4705 (mm-handle-media-type handle))))))
4706 (goto-char (point-max))
4707 (setcdr begend (point-marker)))))
4709 (goto-char point))))
4711 (defconst gnus-article-wash-status-strings
4712 (let ((alist '((cite "c" "Possible hidden citation text"
4713 " " "All citation text visible")
4714 (headers "h" "Hidden headers"
4715 " " "All headers visible.")
4716 (pgp "p" "Encrypted or signed message status hidden"
4717 " " "No hidden encryption nor digital signature status")
4718 (signature "s" "Signature has been hidden"
4719 " " "Signature is visible")
4720 (overstrike "o" "Overstrike (^H) characters applied"
4721 " " "No overstrike characters applied")
4722 (emphasis "e" "/*_Emphasis_*/ characters applied"
4723 " " "No /*_emphasis_*/ characters applied")))
4725 (dolist (entry alist result)
4726 (let ((key (nth 0 entry))
4727 (on (copy-sequence (nth 1 entry)))
4728 (on-help (nth 2 entry))
4729 (off (copy-sequence (nth 3 entry)))
4730 (off-help (nth 4 entry)))
4731 (put-text-property 0 1 'help-echo on-help on)
4732 (put-text-property 0 1 'help-echo off-help off)
4733 (push (list key on off) result))))
4734 "Alist of strings describing wash status in the mode line.
4735 Each entry has the form (KEY ON OF), where the KEY is a symbol
4736 representing the particular washing function, ON is the string to use
4737 in the article mode line when the washing function is active, and OFF
4738 is the string to use when it is inactive.")
4740 (defun gnus-article-wash-status-entry (key value)
4741 (let ((entry (assoc key gnus-article-wash-status-strings)))
4742 (if value (nth 1 entry) (nth 2 entry))))
4744 (defun gnus-article-wash-status ()
4745 "Return a string which display status of article washing."
4747 (set-buffer gnus-article-buffer)
4748 (let ((cite (memq 'cite gnus-article-wash-types))
4749 (headers (memq 'headers gnus-article-wash-types))
4750 (boring (memq 'boring-headers gnus-article-wash-types))
4751 (pgp (memq 'pgp gnus-article-wash-types))
4752 (pem (memq 'pem gnus-article-wash-types))
4753 (signed (memq 'signed gnus-article-wash-types))
4754 (encrypted (memq 'encrypted gnus-article-wash-types))
4755 (signature (memq 'signature gnus-article-wash-types))
4756 (overstrike (memq 'overstrike gnus-article-wash-types))
4757 (emphasis (memq 'emphasis gnus-article-wash-types)))
4759 (gnus-article-wash-status-entry 'cite cite)
4760 (gnus-article-wash-status-entry 'headers (or headers boring))
4761 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4762 (gnus-article-wash-status-entry 'signature signature)
4763 (gnus-article-wash-status-entry 'overstrike overstrike)
4764 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4766 (defun gnus-add-wash-type (type)
4767 "Add a washing of TYPE to the current status."
4768 (add-to-list 'gnus-article-wash-types type))
4770 (defun gnus-delete-wash-type (type)
4771 "Add a washing of TYPE to the current status."
4772 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4774 (defun gnus-add-image (category image)
4775 "Add IMAGE of CATEGORY to the list of displayed images."
4776 (let ((entry (assq category gnus-article-image-alist)))
4778 (setq entry (list category))
4779 (push entry gnus-article-image-alist))
4780 (nconc entry (list image))))
4782 (defun gnus-delete-images (category)
4783 "Delete all images in CATEGORY."
4784 (let ((entry (assq category gnus-article-image-alist)))
4785 (dolist (image (cdr entry))
4786 (gnus-remove-image image))
4787 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4788 (gnus-delete-wash-type category)))
4790 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4792 (defun gnus-article-maybe-hide-headers ()
4793 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4794 Provided for backwards compatibility."
4795 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4796 (not (save-excursion (set-buffer gnus-summary-buffer)
4797 gnus-have-all-headers)))
4798 (not gnus-inhibit-hiding))
4799 (gnus-article-hide-headers)))
4803 (defun gnus-output-to-file (file-name)
4804 "Append the current article to a file named FILE-NAME."
4805 (let ((artbuf (current-buffer)))
4807 (insert-buffer-substring artbuf)
4808 ;; Append newline at end of the buffer as separator, and then
4810 (goto-char (point-max))
4812 (let ((file-name-coding-system nnmail-pathname-coding-system))
4813 (mm-append-to-file (point-min) (point-max) file-name))
4816 (defun gnus-narrow-to-page (&optional arg)
4817 "Narrow the article buffer to a page.
4818 If given a numerical ARG, move forward ARG pages."
4820 (setq arg (if arg (prefix-numeric-value arg) 0))
4822 (set-buffer gnus-article-buffer)
4823 (goto-char (point-min))
4825 ;; Remove any old next/prev buttons.
4826 (when (gnus-visual-p 'page-marker)
4827 (let ((buffer-read-only nil))
4828 (gnus-remove-text-with-property 'gnus-prev)
4829 (gnus-remove-text-with-property 'gnus-next)))
4832 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4834 (re-search-forward page-delimiter nil 'move arg)))
4835 (goto-char (match-end 0)))
4838 (if (re-search-forward page-delimiter nil 'move)
4841 (when (and (gnus-visual-p 'page-marker)
4842 (not (= (point-min) 1)))
4844 (goto-char (point-min))
4845 (gnus-insert-prev-page-button)))
4846 (when (and (gnus-visual-p 'page-marker)
4847 (< (+ (point-max) 2) (buffer-size)))
4849 (goto-char (point-max))
4850 (gnus-insert-next-page-button)))))
4852 ;; Article mode commands
4854 (defun gnus-article-goto-next-page ()
4855 "Show the next page of the article."
4857 (gnus-eval-in-buffer-window gnus-summary-buffer
4858 (gnus-summary-next-page)))
4860 (defun gnus-article-goto-prev-page ()
4861 "Show the next page of the article."
4863 (gnus-eval-in-buffer-window gnus-summary-buffer
4864 (gnus-summary-prev-page)))
4866 (defun gnus-article-next-page (&optional lines)
4867 "Show the next page of the current article.
4868 If end of article, return non-nil. Otherwise return nil.
4869 Argument LINES specifies lines to be scrolled up."
4871 (move-to-window-line -1)
4874 (and (pos-visible-in-window-p) ;Not continuation line.
4875 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4876 ;; Nothing in this page.
4877 (if (or (not gnus-page-broken)
4880 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4882 (gnus-narrow-to-page 1) ;Go to next page.
4884 ;; More in this page.
4885 (let ((scroll-in-place nil))
4889 ;; Long lines may cause an end-of-buffer error.
4890 (goto-char (point-max)))))
4891 (move-to-window-line 0)
4894 (defun gnus-article-prev-page (&optional lines)
4895 "Show previous page of current article.
4896 Argument LINES specifies lines to be scrolled down."
4898 (move-to-window-line 0)
4899 (if (and gnus-page-broken
4901 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4903 (gnus-narrow-to-page -1) ;Go to previous page.
4904 (goto-char (point-max))
4906 (let ((scroll-in-place nil))
4910 (beginning-of-buffer
4911 (goto-char (point-min))))
4912 (move-to-window-line 0)))))
4914 (defun gnus-article-only-boring-p ()
4915 "Decide whether there is only boring text remaining in the article.
4916 Something \"interesting\" is a word of at least two letters that does
4917 not have a face in `gnus-article-boring-faces'."
4918 (when (and gnus-article-skip-boring
4919 (boundp 'gnus-article-boring-faces)
4920 (symbol-value 'gnus-article-boring-faces))
4923 (while (re-search-forward "\\b\\w\\w" nil t)
4925 (when (not (gnus-intersection
4926 (gnus-faces-at (point))
4927 (symbol-value 'gnus-article-boring-faces)))
4928 (throw 'only-boring nil)))
4929 (throw 'only-boring t)))))
4931 (defun gnus-article-refer-article ()
4932 "Read article specified by message-id around point."
4935 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
4936 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
4937 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
4938 (let ((msg-id (concat "<" (match-string 0) ">")))
4939 (set-buffer gnus-summary-buffer)
4940 (gnus-summary-refer-article msg-id))
4941 (error "No references around point"))))
4943 (defun gnus-article-show-summary ()
4944 "Reconfigure windows to show summary buffer."
4946 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4947 (error "There is no summary buffer for this article buffer")
4948 (gnus-article-set-globals)
4949 (gnus-configure-windows 'article)
4950 (gnus-summary-goto-subject gnus-current-article)
4951 (gnus-summary-position-point)))
4953 (defun gnus-article-describe-briefly ()
4954 "Describe article mode commands briefly."
4956 (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")))
4958 (defun gnus-article-summary-command ()
4959 "Execute the last keystroke in the summary buffer."
4961 (let ((obuf (current-buffer))
4962 (owin (current-window-configuration))
4964 (switch-to-buffer gnus-article-current-summary 'norecord)
4965 (setq func (lookup-key (current-local-map) (this-command-keys)))
4966 (call-interactively func)
4968 (set-window-configuration owin)
4969 (set-window-point (get-buffer-window (current-buffer)) (point))))
4971 (defun gnus-article-summary-command-nosave ()
4972 "Execute the last keystroke in the summary buffer."
4975 (pop-to-buffer gnus-article-current-summary 'norecord)
4976 (setq func (lookup-key (current-local-map) (this-command-keys)))
4977 (call-interactively func)))
4979 (defun gnus-article-check-buffer ()
4980 "Beep if not in an article buffer."
4981 (unless (equal major-mode 'gnus-article-mode)
4982 (error "Command invoked outside of a Gnus article buffer")))
4984 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4985 "Read a summary buffer key sequence and execute it from the article buffer."
4987 (gnus-article-check-buffer)
4989 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4990 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4991 "=" "^" "\M-^" "|"))
4997 '("n" "Gn" "p" "Gp"))
5000 (set-buffer gnus-article-current-summary)
5001 (let (gnus-pick-mode)
5002 (push (or key last-command-event) unread-command-events)
5003 (setq keys (if (featurep 'xemacs)
5004 (events-to-keys (read-key-sequence nil))
5005 (read-key-sequence nil)))))
5009 (if (or (member keys nosaves)
5010 (member keys nosave-but-article)
5011 (member keys nosave-in-article))
5013 (save-window-excursion
5014 (pop-to-buffer gnus-article-current-summary 'norecord)
5015 ;; We disable the pick minor mode commands.
5016 (let (gnus-pick-mode)
5017 (setq func (lookup-key (current-local-map) keys))))
5021 (unless (member keys nosave-in-article)
5022 (set-buffer gnus-article-current-summary))
5023 (call-interactively func)
5024 (setq new-sum-point (point)))
5025 (when (member keys nosave-but-article)
5026 (pop-to-buffer gnus-article-buffer 'norecord)))
5027 ;; These commands should restore window configuration.
5028 (let ((obuf (current-buffer))
5029 (owin (current-window-configuration))
5031 (summary gnus-article-current-summary)
5032 func in-buffer selected)
5033 (if not-restore-window
5034 (pop-to-buffer summary 'norecord)
5035 (switch-to-buffer summary 'norecord))
5036 (setq in-buffer (current-buffer))
5037 ;; We disable the pick minor mode commands.
5038 (if (and (setq func (let (gnus-pick-mode)
5039 (lookup-key (current-local-map) keys)))
5042 (call-interactively func)
5043 (setq new-sum-point (point))
5044 (when (eq in-buffer (current-buffer))
5045 (setq selected (gnus-summary-select-article))
5047 (unless not-restore-window
5048 (set-window-configuration owin))
5049 (when (eq selected 'old)
5051 (set-window-start (get-buffer-window (current-buffer))
5053 (set-window-point (get-buffer-window (current-buffer))
5055 (let ((win (get-buffer-window gnus-article-current-summary)))
5057 (set-window-point win new-sum-point)))) )
5058 (switch-to-buffer gnus-article-buffer)
5061 (defun gnus-article-describe-key (key)
5062 "Display documentation of the function invoked by KEY. KEY is a string."
5063 (interactive "kDescribe key: ")
5064 (gnus-article-check-buffer)
5065 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5067 (set-buffer gnus-article-current-summary)
5068 (let (gnus-pick-mode)
5069 (if (featurep 'xemacs)
5071 (push (elt key 0) unread-command-events)
5072 (setq key (events-to-keys
5073 (read-key-sequence "Describe key: "))))
5074 (setq unread-command-events
5076 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5077 (string-to-list key)))
5078 (setq key (read-key-sequence "Describe key: "))))
5080 (describe-key key)))
5082 (defun gnus-article-describe-key-briefly (key &optional insert)
5083 "Display documentation of the function invoked by KEY. KEY is a string."
5084 (interactive "kDescribe key: \nP")
5085 (gnus-article-check-buffer)
5086 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5088 (set-buffer gnus-article-current-summary)
5089 (let (gnus-pick-mode)
5090 (if (featurep 'xemacs)
5092 (push (elt key 0) unread-command-events)
5093 (setq key (events-to-keys
5094 (read-key-sequence "Describe key: "))))
5095 (setq unread-command-events
5097 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5098 (string-to-list key)))
5099 (setq key (read-key-sequence "Describe key: "))))
5100 (describe-key-briefly key insert))
5101 (describe-key-briefly key insert)))
5103 (defun gnus-article-reply-with-original (&optional wide)
5104 "Start composing a reply mail to the current message.
5105 The text in the region will be yanked. If the region isn't active,
5106 the entire article will be yanked."
5108 (let ((article (cdr gnus-article-current))
5110 (if (not (gnus-mark-active-p))
5111 (with-current-buffer gnus-summary-buffer
5112 (gnus-summary-reply (list (list article)) wide))
5113 (setq contents (buffer-substring (point) (mark t)))
5114 ;; Deactivate active regions.
5115 (when (and (boundp 'transient-mark-mode)
5116 transient-mark-mode)
5117 (setq mark-active nil))
5118 (with-current-buffer gnus-summary-buffer
5120 (list (list article contents)) wide)))))
5122 (defun gnus-article-followup-with-original ()
5123 "Compose a followup to the current article.
5124 The text in the region will be yanked. If the region isn't active,
5125 the entire article will be yanked."
5127 (let ((article (cdr gnus-article-current))
5129 (if (not (gnus-mark-active-p))
5130 (with-current-buffer gnus-summary-buffer
5131 (gnus-summary-followup (list (list article))))
5132 (setq contents (buffer-substring (point) (mark t)))
5133 ;; Deactivate active regions.
5134 (when (and (boundp 'transient-mark-mode)
5135 transient-mark-mode)
5136 (setq mark-active nil))
5137 (with-current-buffer gnus-summary-buffer
5138 (gnus-summary-followup
5139 (list (list article contents)))))))
5141 (defun gnus-article-hide (&optional arg force)
5142 "Hide all the gruft in the current article.
5143 This means that signatures, cited text and (some) headers will be
5145 If given a prefix, show the hidden text instead."
5146 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5147 (gnus-article-hide-headers arg)
5148 (gnus-article-hide-list-identifiers arg)
5149 (gnus-article-hide-citation-maybe arg force)
5150 (gnus-article-hide-signature arg))
5152 (defun gnus-article-maybe-highlight ()
5153 "Do some article highlighting if article highlighting is requested."
5154 (when (gnus-visual-p 'article-highlight 'highlight)
5155 (gnus-article-highlight-some)))
5157 (defun gnus-check-group-server ()
5158 ;; Make sure the connection to the server is alive.
5159 (unless (gnus-server-opened
5160 (gnus-find-method-for-group gnus-newsgroup-name))
5161 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5162 (gnus-request-group gnus-newsgroup-name t)))
5165 (autoload 'nneething-get-file-name "nneething"))
5167 (defun gnus-request-article-this-buffer (article group)
5168 "Get an article and insert it into this buffer."
5169 (let (do-update-line sparse-header)
5173 (gnus-kill-all-overlays)
5174 (setq group (or group gnus-newsgroup-name))
5176 ;; Using `gnus-request-article' directly will insert the article into
5177 ;; `nntp-server-buffer' - so we'll save some time by not having to
5178 ;; copy it from the server buffer into the article buffer.
5180 ;; We only request an article by message-id when we do not have the
5181 ;; headers for it, so we'll have to get those.
5182 (when (stringp article)
5183 (gnus-read-header article))
5185 ;; If the article number is negative, that means that this article
5186 ;; doesn't belong in this newsgroup (possibly), so we find its
5187 ;; message-id and request it by id instead of number.
5188 (when (and (numberp article)
5190 (get-buffer gnus-summary-buffer)
5191 (gnus-buffer-exists-p gnus-summary-buffer))
5193 (set-buffer gnus-summary-buffer)
5194 (let ((header (gnus-summary-article-header article)))
5197 ((memq article gnus-newsgroup-sparse)
5198 ;; This is a sparse gap article.
5199 (setq do-update-line article)
5200 (setq article (mail-header-id header))
5201 (setq sparse-header (gnus-read-header article))
5202 (setq gnus-newsgroup-sparse
5203 (delq article gnus-newsgroup-sparse)))
5205 ;; It's a real article.
5206 (setq article (mail-header-id header)))
5208 ;; It is an extracted pseudo-article.
5209 (setq article 'pseudo)
5210 (gnus-request-pseudo-article header))))
5212 (let ((method (gnus-find-method-for-group
5213 gnus-newsgroup-name)))
5214 (when (and (eq (car method) 'nneething)
5216 (let ((dir (nneething-get-file-name
5217 (mail-header-id header))))
5218 (when (and (stringp dir)
5219 (file-directory-p dir))
5220 (setq article 'nneething)
5221 (gnus-group-enter-directory dir))))))))
5224 ;; Refuse to select canceled articles.
5225 ((and (numberp article)
5227 (get-buffer gnus-summary-buffer)
5228 (gnus-buffer-exists-p gnus-summary-buffer)
5229 (eq (cdr (save-excursion
5230 (set-buffer gnus-summary-buffer)
5231 (assq article gnus-newsgroup-reads)))
5232 gnus-canceled-mark))
5234 ;; We first check `gnus-original-article-buffer'.
5235 ((and (get-buffer gnus-original-article-buffer)
5238 (set-buffer gnus-original-article-buffer)
5239 (and (equal (car gnus-original-article) group)
5240 (eq (cdr gnus-original-article) article))))
5241 (insert-buffer-substring gnus-original-article-buffer)
5243 ;; Check the backlog.
5244 ((and gnus-keep-backlog
5245 (gnus-backlog-request-article group article (current-buffer)))
5247 ;; Check asynchronous pre-fetch.
5248 ((gnus-async-request-fetched-article group article (current-buffer))
5249 (gnus-async-prefetch-next group article gnus-summary-buffer)
5250 (when (and (numberp article) gnus-keep-backlog)
5251 (gnus-backlog-enter-article group article (current-buffer)))
5254 ((and gnus-use-cache
5256 (gnus-cache-request-article article group))
5258 ;; Check the agent cache.
5259 ((gnus-agent-request-article article group)
5261 ;; Get the article and put into the article buffer.
5262 ((or (stringp article)
5264 (let ((gnus-override-method gnus-override-method)
5265 (methods (and (stringp article)
5266 gnus-refer-article-method))
5267 (backend (car (gnus-find-method-for-group
5268 gnus-newsgroup-name)))
5270 (buffer-read-only nil))
5271 (if (or (not (listp methods))
5272 (and (symbolp (car methods))
5273 (assq (car methods) nnoo-definition-alist)))
5274 (setq methods (list methods)))
5275 (when (and (null gnus-override-method)
5277 (setq gnus-override-method (pop methods)))
5279 (when (eq gnus-override-method 'current)
5280 (setq gnus-override-method
5281 (with-current-buffer gnus-summary-buffer
5282 gnus-current-select-method)))
5284 (gnus-kill-all-overlays)
5285 (let ((gnus-newsgroup-name group))
5286 (gnus-check-group-server))
5288 ((gnus-request-article article group (current-buffer))
5289 (when (numberp article)
5290 (gnus-async-prefetch-next group article
5291 gnus-summary-buffer)
5292 (when gnus-keep-backlog
5293 (gnus-backlog-enter-article
5294 group article (current-buffer))))
5295 (setq result 'article))
5297 (setq gnus-override-method (pop methods)))
5298 ((not (string-match "^400 "
5299 (nnheader-get-report backend)))
5300 ;; If we get 400 server disconnect, reconnect and
5301 ;; retry; otherwise, assume the article has expired.
5302 (setq result 'done))))
5303 (and (eq result 'article) 'article)))
5307 ;; Associate this article with the current summary buffer.
5308 (setq gnus-article-current-summary gnus-summary-buffer)
5310 ;; Take the article from the original article buffer
5311 ;; and place it in the buffer it's supposed to be in.
5312 (when (and (get-buffer gnus-article-buffer)
5313 (equal (buffer-name (current-buffer))
5314 (buffer-name (get-buffer gnus-article-buffer))))
5316 (if (get-buffer gnus-original-article-buffer)
5317 (set-buffer gnus-original-article-buffer)
5318 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5319 (buffer-disable-undo)
5320 (setq major-mode 'gnus-original-article-mode)
5321 (setq buffer-read-only t))
5322 (let (buffer-read-only)
5324 (insert-buffer-substring gnus-article-buffer))
5325 (setq gnus-original-article (cons group article)))
5328 (run-hooks 'gnus-article-decode-hook)
5329 ;; Mark article as decoded or not.
5330 (setq gnus-article-decoded-p gnus-article-decode-hook))
5332 ;; Update sparse articles.
5333 (when (and do-update-line
5334 (or (numberp article)
5336 (let ((buf (current-buffer)))
5337 (set-buffer gnus-summary-buffer)
5338 (gnus-summary-update-article do-update-line sparse-header)
5339 (gnus-summary-goto-subject do-update-line nil t)
5340 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5342 (set-buffer buf))))))
5348 (defcustom gnus-article-edit-mode-hook nil
5349 "Hook run in article edit mode buffers."
5350 :group 'gnus-article-various
5353 (defvar gnus-article-edit-done-function nil)
5355 (defvar gnus-article-edit-mode-map nil)
5356 (defvar gnus-article-edit-mode nil)
5358 ;; Should we be using derived.el for this?
5359 (unless gnus-article-edit-mode-map
5360 (setq gnus-article-edit-mode-map (make-keymap))
5361 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5363 (gnus-define-keys gnus-article-edit-mode-map
5364 "\C-c?" describe-mode
5365 "\C-c\C-c" gnus-article-edit-done
5366 "\C-c\C-k" gnus-article-edit-exit
5367 "\C-c\C-f\C-t" message-goto-to
5368 "\C-c\C-f\C-o" message-goto-from
5369 "\C-c\C-f\C-b" message-goto-bcc
5370 ;;"\C-c\C-f\C-w" message-goto-fcc
5371 "\C-c\C-f\C-c" message-goto-cc
5372 "\C-c\C-f\C-s" message-goto-subject
5373 "\C-c\C-f\C-r" message-goto-reply-to
5374 "\C-c\C-f\C-n" message-goto-newsgroups
5375 "\C-c\C-f\C-d" message-goto-distribution
5376 "\C-c\C-f\C-f" message-goto-followup-to
5377 "\C-c\C-f\C-m" message-goto-mail-followup-to
5378 "\C-c\C-f\C-k" message-goto-keywords
5379 "\C-c\C-f\C-u" message-goto-summary
5380 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5381 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5382 "\C-c\C-b" message-goto-body
5383 "\C-c\C-i" message-goto-signature
5385 "\C-c\C-t" message-insert-to
5386 "\C-c\C-n" message-insert-newsgroups
5387 "\C-c\C-o" message-sort-headers
5388 "\C-c\C-e" message-elide-region
5389 "\C-c\C-v" message-delete-not-region
5390 "\C-c\C-z" message-kill-to-signature
5391 "\M-\r" message-newline-and-reformat
5392 "\C-c\C-a" mml-attach-file
5393 "\C-a" message-beginning-of-line
5395 "\M-;" comment-region)
5397 (gnus-define-keys (gnus-article-edit-wash-map
5398 "\C-c\C-w" gnus-article-edit-mode-map)
5399 "f" gnus-article-edit-full-stops))
5402 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5404 ["Fetch To" message-insert-to t]
5405 ["Fetch Newsgroups" message-insert-newsgroups t]
5407 ["To" message-goto-to t]
5408 ["From" message-goto-from t]
5409 ["Subject" message-goto-subject t]
5410 ["Cc" message-goto-cc t]
5411 ["Reply-To" message-goto-reply-to t]
5412 ["Summary" message-goto-summary t]
5413 ["Keywords" message-goto-keywords t]
5414 ["Newsgroups" message-goto-newsgroups t]
5415 ["Followup-To" message-goto-followup-to t]
5416 ["Mail-Followup-To" message-goto-mail-followup-to t]
5417 ["Distribution" message-goto-distribution t]
5418 ["Body" message-goto-body t]
5419 ["Signature" message-goto-signature t]))
5421 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5422 "Major mode for editing articles.
5423 This is an extended text-mode.
5425 \\{gnus-article-edit-mode-map}"
5426 (make-local-variable 'gnus-article-edit-done-function)
5427 (make-local-variable 'gnus-prev-winconf)
5428 (set (make-local-variable 'font-lock-defaults)
5429 '(message-font-lock-keywords t))
5430 (set (make-local-variable 'mail-header-separator) "")
5431 (set (make-local-variable 'gnus-article-edit-mode) t)
5432 (easy-menu-add message-mode-field-menu message-mode-map)
5434 (setq buffer-read-only nil)
5435 (buffer-enable-undo)
5438 (defun gnus-article-edit (&optional force)
5439 "Edit the current article.
5440 This will have permanent effect only in mail groups.
5441 If FORCE is non-nil, allow editing of articles even in read-only
5444 (when (and (not force)
5445 (gnus-group-read-only-p))
5446 (error "The current newsgroup does not support article editing"))
5447 (gnus-article-date-original)
5448 (gnus-article-edit-article
5450 `(lambda (no-highlight)
5452 (gnus-summary-edit-article-done
5453 ,(or (mail-header-references gnus-current-headers) "")
5454 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5456 (defun gnus-article-edit-article (start-func exit-func)
5457 "Start editing the contents of the current article buffer."
5458 (let ((winconf (current-window-configuration)))
5459 (set-buffer gnus-article-buffer)
5460 (gnus-article-edit-mode)
5461 (funcall start-func)
5462 (set-buffer-modified-p nil)
5463 (gnus-configure-windows 'edit-article)
5464 (setq gnus-article-edit-done-function exit-func)
5465 (setq gnus-prev-winconf winconf)
5466 (gnus-message 6 "C-c C-c to end edits")))
5468 (defun gnus-article-edit-done (&optional arg)
5469 "Update the article edits and exit."
5471 (let ((func gnus-article-edit-done-function)
5472 (buf (current-buffer))
5473 (start (window-start))
5475 (winconf gnus-prev-winconf))
5476 (widen) ;; Widen it in case that users narrowed the buffer.
5479 ;; The cache and backlog have to be flushed somewhat.
5480 (when gnus-keep-backlog
5481 (gnus-backlog-remove-article
5482 (car gnus-article-current) (cdr gnus-article-current)))
5483 ;; Flush original article as well.
5485 (when (get-buffer gnus-original-article-buffer)
5486 (set-buffer gnus-original-article-buffer)
5487 (setq gnus-original-article nil)))
5488 (when gnus-use-cache
5489 (gnus-cache-update-article
5490 (car gnus-article-current) (cdr gnus-article-current)))
5491 ;; We remove all text props from the article buffer.
5492 (kill-all-local-variables)
5493 (gnus-set-text-properties (point-min) (point-max) nil)
5495 (set-window-configuration winconf)
5497 (set-window-start (get-buffer-window buf) start)
5498 (set-window-point (get-buffer-window buf) (point))))
5500 (defun gnus-article-edit-exit ()
5501 "Exit the article editing without updating."
5503 (when (or (not (buffer-modified-p))
5504 (yes-or-no-p "Article modified; kill anyway? "))
5505 (let ((curbuf (current-buffer))
5507 (window-start (window-start)))
5509 (if (gnus-buffer-live-p gnus-original-article-buffer)
5510 (insert-buffer gnus-original-article-buffer))
5511 (let ((winconf gnus-prev-winconf))
5512 (kill-all-local-variables)
5514 (set-window-configuration winconf)
5515 ;; Tippy-toe some to make sure that point remains where it was.
5516 (save-current-buffer
5518 (set-window-start (get-buffer-window (current-buffer)) window-start)
5521 (defun gnus-article-edit-full-stops ()
5522 "Interactively repair spacing at end of sentences."
5525 (goto-char (point-min))
5526 (search-forward-regexp "^$" nil t)
5527 (let ((case-fold-search nil))
5528 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5531 ;;; Article highlights
5534 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5536 ;;; Internal Variables:
5538 (defcustom gnus-button-url-regexp
5539 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5540 "\\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:]]\\)"
5541 "\\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\\)\\)")
5542 "Regular expression that matches URLs."
5543 :group 'gnus-article-buttons
5546 (defcustom gnus-button-valid-fqdn-regexp
5547 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5549 "\\([a-z][a-z]" ;; two letter country TDLs
5550 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5551 "\\|aero\\|coop\\|info\\|name\\|museum"
5552 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5554 "Regular expression that matches a valid FQDN."
5555 :group 'gnus-article-buttons
5558 (defcustom gnus-button-man-handler 'manual-entry
5559 "Function to use for displaying man pages.
5560 The function must take at least one argument with a string naming the
5562 :type '(choice (function-item :tag "Man" manual-entry)
5563 (function-item :tag "Woman" woman)
5564 (function :tag "Other"))
5565 :group 'gnus-article-buttons)
5567 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5568 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5569 If the default site is too slow, try to find a CTAN mirror, see
5570 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5571 the variable `gnus-button-handle-ctan'."
5572 :group 'gnus-article-buttons
5573 :link '(custom-manual "(gnus)Group Parameters")
5574 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5575 (const "http://tug.ctan.org/tex-archive/")
5576 (const "http://www.dante.de/CTAN/")
5577 (string :tag "Other")))
5579 (defcustom gnus-button-ctan-handler 'browse-url
5580 "Function to use for displaying CTAN links.
5581 The function must take one argument, the string naming the URL."
5582 :type '(choice (function-item :tag "Browse Url" browse-url)
5583 (function :tag "Other"))
5584 :group 'gnus-article-buttons)
5586 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5587 "Bogus strings removed from CTAN URLs."
5588 :group 'gnus-article-buttons
5589 :type '(choice (const "^/?tex-archive/\\|/")
5590 (regexp :tag "Other")))
5592 (defcustom gnus-button-mid-or-mail-regexp
5593 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5594 gnus-button-valid-fqdn-regexp
5596 "Regular expression that matches a message ID or a mail address."
5597 :group 'gnus-article-buttons
5600 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5601 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5602 Strings like this can be either a message ID or a mail address. If it is one
5603 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5604 message ID or a mail address, respectivly. If this variable is set to the
5605 symbol `ask', always query the user what do do. If it is a function, this
5606 function will be called with the string as it's only argument. The function
5607 must return `mid', `mail', `invalid' or `ask'."
5608 :group 'gnus-article-buttons
5609 :type '(choice (function-item :tag "Heuristic function"
5610 gnus-button-mid-or-mail-heuristic)
5615 (defcustom gnus-button-mid-or-mail-heuristic-alist
5616 '((-10.0 . ".+\\$.+@")
5619 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5620 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5621 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5622 (-1.0 . "^[^a-z]+@")
5624 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5625 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5626 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5627 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5630 (-1.0 . "^[0-9][0-9]")
5632 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5633 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5634 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5635 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5637 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5638 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5641 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5643 ;; compensation for TDMA dated mail addresses:
5644 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5646 (-20.0 . "\\.fsf@") ;; Gnus
5649 (-20.0 . "_-_") ;; Subject change in thread
5651 (-20.0 . "\\.ln@") ;; leafnode
5652 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5653 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5655 ;; (5.0 . "") ;; $local_part_len <= 7
5656 (10.0 . "^[^0-9]+@")
5657 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5658 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5661 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5663 (0.5 . "^[A-Z][a-z]")
5664 (0.5 . "^[A-Z][a-z][a-z]")
5665 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5666 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5667 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5669 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5670 address. The REGEXP is processed with `case-fold-search' set to `nil'."
5671 :group 'gnus-article-buttons
5672 :type '(repeat (cons (number :tag "Rate")
5673 (regexp :tag "Regexp"))))
5675 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5676 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5677 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5678 address, `ask' if unsure and `invalid' if the string is invalid."
5679 (let ((case-fold-search nil)
5680 (list gnus-button-mid-or-mail-heuristic-alist)
5681 (result 0) rate regexp lpartlen elem)
5683 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5684 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5685 ;; Certain special cases...
5688 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5689 "^[0-9]+\.[0-9]+\@compuserve")
5691 (gnus-message 8 "`%s' is a known mail address.")
5692 (setq result 'mail))
5693 (when (string-match "@.*@\\| " mid-or-mail)
5694 (gnus-message 8 "`%s' is invalid.")
5695 (setq result 'invalid))
5696 ;; Nothing more to do, if result is not a number here...
5697 (when (numberp result)
5699 (setq elem (car list)
5703 (when (string-match regexp mid-or-mail)
5704 (setq result (+ result rate))
5706 9 "`%s' matched `%s', rate `%s', result `%s'."
5707 mid-or-mail regexp rate result)))
5708 (when (<= lpartlen 7)
5709 (setq result (+ result 5.0))
5710 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5711 mid-or-mail result))
5712 (when (>= lpartlen 12)
5713 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5715 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5716 ;; Long local part should contain realname if e-mail address,
5717 ;; too many digits: message-id.
5718 ;; $score -= 5.0 + 0.1 * $local_part_len;
5719 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5720 (setq result (+ result rate))
5722 9 "Many digits in `%s', rate `%s', result `%s'."
5723 mid-or-mail rate result))
5724 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5726 ;; Too few vowels [^aeiouy]{4,}.*\@
5727 (setq result (+ result -5.0))
5729 9 "Few vowels in `%s', rate `%s', result `%s'."
5730 mid-or-mail -5.0 result))
5732 (setq result (+ result 5.0))
5734 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5735 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5737 ;; Maybe we should make this a customizable alist: (condition . 'result)
5738 ((< result -10.0) 'mid)
5739 ((> result 10.0) 'mail)
5742 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5743 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5744 (url-mid (concat "news" ":" mid-or-mail))
5745 (url-mailto (concat "mailto" ":" mid-or-mail)))
5746 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5747 (when (fboundp pref)
5749 ;; get rid of surrounding angles...
5751 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5752 (if (or (eq 'mid guessed) (eq 'mail guessed))
5756 (save-window-excursion
5757 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5760 (cond ((eq pref 'mid)
5761 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5762 (gnus-button-handle-news url-mid))
5764 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5765 (gnus-url-mailto url-mailto))
5766 (t (gnus-message 3 "Invalid string.")))))
5768 (defun gnus-button-handle-custom (url)
5769 "Follow a Custom URL."
5770 (customize-apropos (gnus-url-unhex-string url)))
5772 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5774 (defun gnus-button-handle-describe-function (url)
5775 "Call `describe-function' when pushing the corresponding URL button."
5778 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5780 (defun gnus-button-handle-describe-variable (url)
5781 "Call `describe-variable' when pushing the corresponding URL button."
5784 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5786 (defun gnus-button-handle-describe-key (url)
5787 "Call `describe-key' when pushing the corresponding URL button."
5789 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5790 (keys (ignore-errors (eval `(kbd ,key-string)))))
5793 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5795 (defun gnus-button-handle-apropos (url)
5796 "Call `apropos' when pushing the corresponding URL button."
5797 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5799 (defun gnus-button-handle-apropos-command (url)
5800 "Call `apropos' when pushing the corresponding URL button."
5802 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5804 (defun gnus-button-handle-apropos-variable (url)
5805 "Call `apropos' when pushing the corresponding URL button."
5807 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5808 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5810 (defun gnus-button-handle-apropos-documentation (url)
5811 "Call `apropos' when pushing the corresponding URL button."
5813 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5814 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5816 (defun gnus-button-handle-ctan (url)
5817 "Call `browse-url' when pushing a CTAN URL button."
5819 gnus-button-ctan-handler
5822 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5824 (defcustom gnus-button-tex-level 5
5825 "*Integer that says how many TeX-related buttons Gnus will show.
5826 The higher the number, the more buttons will appear and the more false
5827 positives are possible. Note that you can set this variable local to
5828 specifific groups. Setting it higher in TeX groups is probably a good idea.
5829 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5830 how to set variables in specific groups."
5831 :group 'gnus-article-buttons
5832 :link '(custom-manual "(gnus)Group Parameters")
5835 (defcustom gnus-button-man-level 5
5836 "*Integer that says how many man-related buttons Gnus will show.
5837 The higher the number, the more buttons will appear and the more false
5838 positives are possible. Note that you can set this variable local to
5839 specifific groups. Setting it higher in Unix groups is probably a good idea.
5840 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5841 how to set variables in specific groups."
5842 :group 'gnus-article-buttons
5843 :link '(custom-manual "(gnus)Group Parameters")
5846 (defcustom gnus-button-emacs-level 5
5847 "*Integer that says how many emacs-related buttons Gnus will show.
5848 The higher the number, the more buttons will appear and the more false
5849 positives are possible. Note that you can set this variable local to
5850 specifific groups. Setting it higher in Emacs or Gnus related groups is
5851 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5852 `gnus-parameters' on how to set variables in specific groups."
5853 :group 'gnus-article-buttons
5854 :link '(custom-manual "(gnus)Group Parameters")
5857 (defcustom gnus-button-mail-level 5
5858 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5859 The higher the number, the more buttons will appear and the more false
5860 positives are possible."
5861 :group 'gnus-article-buttons
5864 (defcustom gnus-button-alist
5865 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5866 0 t gnus-button-handle-news 3)
5867 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5868 gnus-button-handle-news 2)
5869 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5871 gnus-button-fetch-group 4)
5872 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5873 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5874 t gnus-button-message-id 3)
5875 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5876 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5877 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5879 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5880 gnus-button-handle-ctan 1)
5882 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5883 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5885 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5886 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5887 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5888 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5889 ;; Emacs help commands
5890 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5891 ;; regexp doesn't match arguments containing ` '.
5892 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5893 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5894 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5895 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5896 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5897 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5898 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5899 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5900 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5901 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5902 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5903 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
5904 ;; Unlike the other regexps we really have to require quoting
5905 ;; here to determine where it ends.
5906 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
5907 ;; This is how URLs _should_ be embedded in text...
5908 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5910 (gnus-button-url-regexp 0 t browse-url 0)
5912 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5913 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5914 gnus-button-handle-man 1)
5915 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5916 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
5917 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5918 gnus-button-handle-man 1)
5919 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5920 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5921 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5922 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5923 ;; MID or mail: To avoid too many false positives we don't try to catch
5924 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5925 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5926 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5927 ;; so that non-ambiguous entries (see above) match first.
5928 (gnus-button-mid-or-mail-regexp
5929 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5930 "*Alist of regexps matching buttons in article bodies.
5932 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5933 REGEXP: is the string (case insensitive) matching text around the button (can
5934 also be lisp expression evaluating to a string),
5935 BUTTON: is the number of the regexp grouping actually matching the button,
5936 FORM: is a lisp expression which must eval to true for the button to
5938 CALLBACK: is the function to call when the user push this button, and each
5939 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5941 CALLBACK can also be a variable, in that case the value of that
5942 variable it the real callback function."
5943 :group 'gnus-article-buttons
5944 :type '(repeat (list (choice regexp variable)
5945 (integer :tag "Button")
5947 (function :tag "Callback")
5950 (integer :tag "Regexp group")))))
5952 (defcustom gnus-header-button-alist
5953 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5954 0 t gnus-button-message-id 0)
5955 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5956 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5957 0 t gnus-button-mailto 0)
5958 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5959 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5960 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5961 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5962 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5963 gnus-button-message-id 3))
5964 "*Alist of headers and regexps to match buttons in article heads.
5966 This alist is very similar to `gnus-button-alist', except that each
5967 alist has an additional HEADER element first in each entry:
5969 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5971 HEADER is a regexp to match a header. For a fuller explanation, see
5972 `gnus-button-alist'."
5973 :group 'gnus-article-buttons
5974 :group 'gnus-article-headers
5975 :type '(repeat (list (regexp :tag "Header")
5977 (integer :tag "Button")
5979 (function :tag "Callback")
5982 (integer :tag "Regexp group")))))
5984 (defvar gnus-button-regexp nil)
5985 (defvar gnus-button-marker-list nil)
5986 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5988 (defvar gnus-button-last nil)
5989 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5993 (defun gnus-article-push-button (event)
5994 "Check text under the mouse pointer for a callback function.
5995 If the text under the mouse pointer has a `gnus-callback' property,
5996 call it with the value of the `gnus-data' text property."
5998 (set-buffer (window-buffer (posn-window (event-start event))))
5999 (let* ((pos (posn-point (event-start event)))
6000 (data (get-text-property pos 'gnus-data))
6001 (fun (get-text-property pos 'gnus-callback)))
6004 (funcall fun data))))
6006 (defun gnus-article-press-button ()
6007 "Check text at point for a callback function.
6008 If the text at point has a `gnus-callback' property,
6009 call it with the value of the `gnus-data' text property."
6011 (let ((data (get-text-property (point) 'gnus-data))
6012 (fun (get-text-property (point) 'gnus-callback)))
6014 (funcall fun data))))
6016 (defun gnus-article-highlight (&optional force)
6017 "Highlight current article.
6018 This function calls `gnus-article-highlight-headers',
6019 `gnus-article-highlight-citation',
6020 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6021 do the highlighting. See the documentation for those functions."
6022 (interactive (list 'force))
6023 (gnus-article-highlight-headers)
6024 (gnus-article-highlight-citation force)
6025 (gnus-article-highlight-signature)
6026 (gnus-article-add-buttons force)
6027 (gnus-article-add-buttons-to-head))
6029 (defun gnus-article-highlight-some (&optional force)
6030 "Highlight current article.
6031 This function calls `gnus-article-highlight-headers',
6032 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6033 do the highlighting. See the documentation for those functions."
6034 (interactive (list 'force))
6035 (gnus-article-highlight-headers)
6036 (gnus-article-highlight-signature)
6037 (gnus-article-add-buttons))
6039 (defun gnus-article-highlight-headers ()
6040 "Highlight article headers as specified by `gnus-header-face-alist'."
6043 (set-buffer gnus-article-buffer)
6045 (let ((alist gnus-header-face-alist)
6046 (buffer-read-only nil)
6047 (case-fold-search t)
6048 (inhibit-point-motion-hooks t)
6049 entry regexp header-face field-face from hpoints fpoints)
6050 (article-narrow-to-head)
6051 (while (setq entry (pop alist))
6052 (goto-char (point-min))
6053 (setq regexp (concat "^\\("
6054 (if (string-equal "" (nth 0 entry))
6058 header-face (nth 1 entry)
6059 field-face (nth 2 entry))
6060 (while (and (re-search-forward regexp nil t)
6064 (unless (search-forward ":" nil t)
6066 (when (and header-face
6067 (not (memq (point) hpoints)))
6068 (push (point) hpoints)
6069 (gnus-put-text-property from (point) 'face header-face))
6070 (when (and field-face
6071 (not (memq (setq from (point)) fpoints)))
6073 (if (re-search-forward "^[^ \t]" nil t)
6075 (goto-char (point-max)))
6076 (gnus-put-text-property from (point) 'face field-face))))))))
6078 (defun gnus-article-highlight-signature ()
6079 "Highlight the signature in an article.
6080 It does this by highlighting everything after
6081 `gnus-signature-separator' using `gnus-signature-face'."
6084 (set-buffer gnus-article-buffer)
6085 (let ((buffer-read-only nil)
6086 (inhibit-point-motion-hooks t))
6088 (when (and gnus-signature-face
6089 (gnus-article-narrow-to-signature))
6090 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6091 'face gnus-signature-face)
6093 (gnus-article-search-signature)
6094 (let ((start (match-beginning 0))
6095 (end (set-marker (make-marker) (1+ (match-end 0)))))
6096 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6099 (defun gnus-button-in-region-p (b e prop)
6100 "Say whether PROP exists in the region."
6101 (text-property-not-all b e prop nil))
6103 (defun gnus-article-add-buttons (&optional force)
6104 "Find external references in the article and make buttons of them.
6105 \"External references\" are things like Message-IDs and URLs, as
6106 specified by `gnus-button-alist'."
6107 (interactive (list 'force))
6109 (set-buffer gnus-article-buffer)
6110 (let ((buffer-read-only nil)
6111 (inhibit-point-motion-hooks t)
6112 (case-fold-search t)
6113 (alist gnus-button-alist)
6115 ;; Remove all old markers.
6116 (let (marker entry new-list)
6117 (while (setq marker (pop gnus-button-marker-list))
6118 (if (or (< marker (point-min)) (>= marker (point-max)))
6119 (push marker new-list)
6121 (when (setq entry (gnus-button-entry))
6122 (put-text-property (match-beginning (nth 1 entry))
6123 (match-end (nth 1 entry))
6124 'gnus-callback nil))
6125 (set-marker marker nil)))
6126 (setq gnus-button-marker-list new-list))
6127 ;; We skip the headers.
6130 (while (setq entry (pop alist))
6131 (setq regexp (eval (car entry)))
6133 (while (re-search-forward regexp nil t)
6134 (let* ((start (and entry (match-beginning (nth 1 entry))))
6135 (end (and entry (match-end (nth 1 entry))))
6136 (from (match-beginning 0)))
6137 (when (and (or (eq t (nth 2 entry))
6138 (eval (nth 2 entry)))
6139 (not (gnus-button-in-region-p
6140 start end 'gnus-callback)))
6141 ;; That optional form returned non-nil, so we add the
6143 (gnus-article-add-button
6144 start end 'gnus-button-push
6145 (car (push (set-marker (make-marker) from)
6146 gnus-button-marker-list))))))))))
6148 ;; Add buttons to the head of an article.
6149 (defun gnus-article-add-buttons-to-head ()
6150 "Add buttons to the head of the article."
6153 (set-buffer gnus-article-buffer)
6155 (let ((buffer-read-only nil)
6156 (inhibit-point-motion-hooks t)
6157 (case-fold-search t)
6158 (alist gnus-header-button-alist)
6160 (article-narrow-to-head)
6162 ;; Each alist entry.
6163 (setq entry (car alist)
6165 (goto-char (point-min))
6166 (while (re-search-forward (car entry) nil t)
6167 ;; Each header matching the entry.
6168 (setq beg (match-beginning 0))
6169 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6170 (match-beginning 0))
6173 (while (re-search-forward (eval (nth 1 entry)) end t)
6174 ;; Each match within a header.
6175 (let* ((entry (cdr entry))
6176 (start (match-beginning (nth 1 entry)))
6177 (end (match-end (nth 1 entry)))
6178 (form (nth 2 entry)))
6179 (goto-char (match-end 0))
6181 (gnus-article-add-button
6182 start end (nth 3 entry)
6183 (buffer-substring (match-beginning (nth 4 entry))
6184 (match-end (nth 4 entry)))))))
6185 (goto-char end)))))))
6187 ;;; External functions:
6189 (defun gnus-article-add-button (from to fun &optional data)
6190 "Create a button between FROM and TO with callback FUN and data DATA."
6191 (when gnus-article-button-face
6192 (gnus-overlay-put (gnus-make-overlay from to)
6193 'face gnus-article-button-face))
6194 (gnus-add-text-properties
6196 (nconc (and gnus-article-mouse-face
6197 (list gnus-mouse-face-prop gnus-article-mouse-face))
6198 (list 'gnus-callback fun)
6199 (and data (list 'gnus-data data))))
6200 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6201 :button-keymap gnus-widget-button-keymap))
6203 ;;; Internal functions:
6205 (defun gnus-article-set-globals ()
6207 (set-buffer gnus-summary-buffer)
6208 (gnus-set-global-variables)))
6210 (defun gnus-signature-toggle (end)
6212 (set-buffer gnus-article-buffer)
6213 (let ((buffer-read-only nil)
6214 (inhibit-point-motion-hooks t))
6215 (if (text-property-any end (point-max) 'article-type 'signature)
6217 (gnus-delete-wash-type 'signature)
6218 (gnus-remove-text-properties-when
6219 'article-type 'signature end (point-max)
6220 (cons 'article-type (cons 'signature
6221 gnus-hidden-properties))))
6222 (gnus-add-wash-type 'signature)
6223 (gnus-add-text-properties-when
6224 'article-type nil end (point-max)
6225 (cons 'article-type (cons 'signature
6226 gnus-hidden-properties)))))
6227 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6228 (gnus-set-mode-line 'article))))
6230 (defun gnus-button-entry ()
6231 ;; Return the first entry in `gnus-button-alist' matching this place.
6232 (let ((alist gnus-button-alist)
6235 (setq entry (pop alist))
6236 (if (looking-at (eval (car entry)))
6241 (defun gnus-button-push (marker)
6242 ;; Push button starting at MARKER.
6245 (let* ((entry (gnus-button-entry))
6246 (inhibit-point-motion-hooks t)
6248 (args (mapcar (lambda (group)
6249 (let ((string (match-string group)))
6250 (gnus-set-text-properties
6251 0 (length string) nil string)
6258 (fboundp (symbol-value fun)))
6259 (apply (symbol-value fun) args))
6261 (gnus-message 1 "You must define `%S' to use this button"
6262 (cons fun args)))))))
6264 (defun gnus-parse-news-url (url)
6265 (let (scheme server group message-id articles)
6268 (goto-char (point-min))
6269 (when (looking-at "\\([A-Za-z]+\\):")
6270 (setq scheme (match-string 1))
6271 (goto-char (match-end 0)))
6272 (when (looking-at "//\\([^/]+\\)/")
6273 (setq server (match-string 1))
6274 (goto-char (match-end 0)))
6277 ((looking-at "\\(.*@.*\\)")
6278 (setq message-id (match-string 1)))
6279 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6280 (setq group (match-string 1)
6281 articles (split-string (match-string 2) "-")))
6282 ((looking-at "\\([^/]+\\)/?")
6283 (setq group (match-string 1)))
6285 (error "Unknown news URL syntax"))))
6286 (list scheme server group message-id articles)))
6288 (defun gnus-button-handle-news (url)
6290 (destructuring-bind (scheme server group message-id articles)
6291 (gnus-parse-news-url url)
6295 (set-buffer gnus-summary-buffer)
6297 (let ((gnus-refer-article-method (list (list 'nntp server))))
6298 (gnus-summary-refer-article message-id))
6299 (gnus-summary-refer-article message-id))))
6301 (gnus-button-fetch-group url)))))
6303 (defun gnus-button-handle-man (url)
6305 (funcall gnus-button-man-handler url))
6307 (defun gnus-button-handle-info (url)
6308 "Fetch an info URL."
6310 "^\\([^:/]+\\)?/\\(.*\\)"
6312 (gnus-info-find-node
6313 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6316 (gnus-url-unhex-string (match-string 2 url))))
6317 (error "Can't parse %s" url)))
6319 (defun gnus-button-message-id (message-id)
6322 (set-buffer gnus-summary-buffer)
6323 (gnus-summary-refer-article message-id)))
6325 (defun gnus-button-fetch-group (address)
6326 "Fetch GROUP specified by ADDRESS."
6327 (if (not (string-match "[:/]" address))
6328 ;; This is just a simple group url.
6329 (gnus-group-read-ephemeral-group address gnus-select-method)
6332 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6334 (error "Can't parse %s" address)
6335 (gnus-group-read-ephemeral-group
6336 (match-string 4 address)
6337 `(nntp ,(match-string 1 address)
6338 (nntp-address ,(match-string 1 address))
6339 (nntp-port-number ,(if (match-end 3)
6340 (match-string 3 address)
6343 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6345 (defun gnus-url-parse-query-string (query &optional downcase)
6346 (let (retval pairs cur key val)
6347 (setq pairs (split-string query "&"))
6349 (setq cur (car pairs)
6351 (if (not (string-match "=" cur))
6353 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6354 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6356 (setq key (downcase key)))
6357 (setq cur (assoc key retval))
6359 (setcdr cur (cons val (cdr cur)))
6360 (setq retval (cons (list key val) retval)))))
6363 (defun gnus-url-mailto (url)
6364 ;; Send mail to someone
6365 (when (string-match "mailto:/*\\(.*\\)" url)
6366 (setq url (substring url (match-beginning 1) nil)))
6367 (let (to args subject func)
6368 (if (string-match (regexp-quote "?") url)
6369 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6370 args (gnus-url-parse-query-string
6371 (substring url (match-end 0) nil) t))
6372 (setq to (gnus-url-unhex-string url)))
6373 (setq args (cons (list "to" to) args)
6374 subject (cdr-safe (assoc "subject" args)))
6377 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6380 (message-position-on-field (caar args)))
6381 (insert (mapconcat 'identity (cdar args) ", "))
6382 (setq args (cdr args)))
6385 (message-goto-subject))))
6387 (defun gnus-button-embedded-url (address)
6388 "Activate ADDRESS with `browse-url'."
6389 (browse-url (gnus-strip-whitespace address)))
6391 ;;; Next/prev buttons in the article buffer.
6393 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6394 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6396 (defvar gnus-prev-page-map
6397 (let ((map (make-sparse-keymap)))
6398 (unless (>= emacs-major-version 21)
6399 ;; XEmacs doesn't care.
6400 (set-keymap-parent map gnus-article-mode-map))
6401 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6402 (define-key map "\r" 'gnus-button-prev-page)
6405 (defun gnus-insert-prev-page-button ()
6407 (buffer-read-only nil))
6409 gnus-prev-page-line-format nil
6410 `(,@(gnus-local-map-property gnus-prev-page-map)
6412 gnus-callback gnus-article-button-prev-page
6413 article-type annotation))
6414 (widget-convert-button
6416 ;; Exclude a newline.
6419 :action 'gnus-button-prev-page
6420 :button-keymap gnus-prev-page-map)))
6422 (defvar gnus-prev-page-map
6423 (let ((map (make-sparse-keymap)))
6424 (unless (>= emacs-major-version 21)
6425 ;; XEmacs doesn't care.
6426 (set-keymap-parent map gnus-article-mode-map))
6427 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6428 (define-key map "\r" 'gnus-button-prev-page)
6431 (defvar gnus-next-page-map
6432 (let ((map (make-sparse-keymap)))
6433 (unless (>= emacs-major-version 21)
6434 ;; XEmacs doesn't care.
6435 (set-keymap-parent map gnus-article-mode-map))
6436 (define-key map gnus-mouse-2 'gnus-button-next-page)
6437 (define-key map "\r" 'gnus-button-next-page)
6440 (defun gnus-button-next-page (&optional args more-args)
6441 "Go to the next page."
6443 (let ((win (selected-window)))
6444 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6445 (gnus-article-next-page)
6446 (select-window win)))
6448 (defun gnus-button-prev-page (&optional args more-args)
6449 "Go to the prev page."
6451 (let ((win (selected-window)))
6452 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6453 (gnus-article-prev-page)
6454 (select-window win)))
6456 (defun gnus-insert-next-page-button ()
6458 (buffer-read-only nil))
6459 (gnus-eval-format gnus-next-page-line-format nil
6460 `(,@(gnus-local-map-property gnus-next-page-map)
6462 gnus-callback gnus-article-button-next-page
6463 article-type annotation))
6464 (widget-convert-button
6466 ;; Exclude a newline.
6469 :action 'gnus-button-next-page
6470 :button-keymap gnus-next-page-map)))
6472 (defun gnus-article-button-next-page (arg)
6473 "Go to the next page."
6475 (let ((win (selected-window)))
6476 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6477 (gnus-article-next-page)
6478 (select-window win)))
6480 (defun gnus-article-button-prev-page (arg)
6481 "Go to the prev page."
6483 (let ((win (selected-window)))
6484 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6485 (gnus-article-prev-page)
6486 (select-window win)))
6488 (defvar gnus-decode-header-methods
6489 '(mail-decode-encoded-word-region)
6490 "List of methods used to decode headers.
6492 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6493 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6494 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6495 whose names match REGEXP.
6498 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6499 mail-decode-encoded-word-region
6500 (\"chinese\" . rfc1843-decode-region))
6503 (defvar gnus-decode-header-methods-cache nil)
6505 (defun gnus-multi-decode-header (start end)
6506 "Apply the functions from `gnus-encoded-word-methods' that match."
6507 (unless (and gnus-decode-header-methods-cache
6508 (eq gnus-newsgroup-name
6509 (car gnus-decode-header-methods-cache)))
6510 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6513 (nconc gnus-decode-header-methods-cache (list x))
6514 (if (and gnus-newsgroup-name
6515 (string-match (car x) gnus-newsgroup-name))
6516 (nconc gnus-decode-header-methods-cache
6518 gnus-decode-header-methods))
6519 (let ((xlist gnus-decode-header-methods-cache))
6522 (narrow-to-region start end)
6524 (funcall (pop xlist) (point-min) (point-max))))))
6527 ;;; Treatment top-level handling.
6530 (defun gnus-treat-article (condition &optional part-number total-parts type)
6531 (let ((length (- (point-max) (point-min)))
6532 (alist gnus-treatment-function-alist)
6533 (article-goto-body-goes-to-point-min-p t)
6537 (let ((list gnus-article-treat-types))
6539 (when (string-match (pop list) type)
6540 (throw 'found t)))))))
6541 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6543 (gnus-run-hooks 'gnus-part-display-hook)
6544 (dolist (elem alist)
6547 (when (gnus-buffer-live-p gnus-summary-buffer)
6548 (set-buffer gnus-summary-buffer))
6549 (symbol-value (car elem))))
6550 (when (and (or (consp val)
6552 (gnus-treat-predicate val)
6553 (or (not (get (car elem) 'highlight))
6556 (funcall (cadr elem)))))))
6558 ;; Dynamic variables.
6560 (defvar part-number)
6561 (defvar total-parts)
6566 (defun gnus-treat-predicate (val)
6573 (stringp (car val)))
6574 (apply 'gnus-or (mapcar `(lambda (s)
6575 (string-match s ,(or gnus-newsgroup-name "")))
6578 (let ((pred (pop val)))
6581 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6583 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6585 (not (gnus-treat-predicate (car val))))
6587 (equal (car val) type))
6589 (error "%S is not a valid predicate" pred)))))
6595 (eq part-number total-parts))
6599 (error "%S is not a valid value" val))))
6601 (defun gnus-article-encrypt-body (protocol &optional n)
6602 "Encrypt the article body."
6605 (or gnus-article-encrypt-protocol
6606 (completing-read "Encrypt protocol: "
6607 gnus-article-encrypt-protocol-alist
6609 current-prefix-arg))
6610 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6612 (error (format "Can't find the encrypt protocol %s" protocol)))
6613 (if (member gnus-newsgroup-name '("nndraft:delayed"
6616 (error "Can't encrypt the article in group %s"
6617 gnus-newsgroup-name))
6618 (gnus-summary-iterate n
6620 (set-buffer gnus-summary-buffer)
6621 (let ((mail-parse-charset gnus-newsgroup-charset)
6622 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6623 (summary-buffer gnus-summary-buffer)
6625 (gnus-set-global-variables)
6626 (when (gnus-group-read-only-p)
6627 (error "The current newsgroup does not support article encrypt"))
6628 (gnus-summary-show-article t)
6630 (or (mail-header-references gnus-current-headers) ""))
6631 (set-buffer gnus-article-buffer)
6632 (let* ((buffer-read-only nil)
6634 (mapcar (lambda (field)
6635 (and (save-restriction
6636 (message-narrow-to-head)
6637 (goto-char (point-min))
6638 (search-forward field nil t))
6640 (message-narrow-to-field)
6642 (delete-region (point-min) (point-max))
6644 '("Content-Type:" "Content-Transfer-Encoding:"
6645 "Content-Disposition:"))))
6646 (message-narrow-to-head)
6647 (message-remove-header "MIME-Version")
6648 (goto-char (point-max))
6649 (setq point (point))
6650 (insert (apply 'concat headers))
6652 (narrow-to-region point (point-max))
6653 (let ((message-options message-options))
6654 (message-options-set 'message-sender user-mail-address)
6655 (message-options-set 'message-recipients user-mail-address)
6656 (message-options-set 'message-sign-encrypt 'not)
6658 (goto-char (point-min))
6659 (insert "MIME-Version: 1.0\n")
6661 (gnus-summary-edit-article-done
6662 references nil summary-buffer t))
6663 (when gnus-keep-backlog
6664 (gnus-backlog-remove-article
6665 (car gnus-article-current) (cdr gnus-article-current)))
6667 (when (get-buffer gnus-original-article-buffer)
6668 (set-buffer gnus-original-article-buffer)
6669 (setq gnus-original-article nil)))
6670 (when gnus-use-cache
6671 (gnus-cache-update-article
6672 (car gnus-article-current) (cdr gnus-article-current))))))))
6674 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6675 "The following specs can be used:
6676 %t The security MIME type
6679 %D Details if button is pressed")
6681 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6682 "The following specs can be used:
6683 %t The security MIME type
6686 %D Details if button is pressed")
6688 (defvar gnus-mime-security-button-line-format-alist
6689 '((?t gnus-tmp-type ?s)
6690 (?i gnus-tmp-info ?s)
6691 (?d gnus-tmp-details ?s)
6692 (?D gnus-tmp-pressed-details ?s)))
6694 (defvar gnus-mime-security-button-map
6695 (let ((map (make-sparse-keymap)))
6696 (unless (>= (string-to-number emacs-version) 21)
6697 (set-keymap-parent map gnus-article-mode-map))
6698 (define-key map gnus-mouse-2 'gnus-article-push-button)
6699 (define-key map "\r" 'gnus-article-press-button)
6702 (defvar gnus-mime-security-details-buffer nil)
6704 (defvar gnus-mime-security-button-pressed nil)
6706 (defvar gnus-mime-security-show-details-inline t
6707 "If non-nil, show details in the article buffer.")
6709 (defun gnus-mime-security-verify-or-decrypt (handle)
6710 (mm-remove-parts (cdr handle))
6711 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6712 point buffer-read-only)
6714 (goto-char (car region)))
6716 (narrow-to-region (point) (point))
6717 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6718 (let* ((mm-verify-option 'known)
6719 (mm-decrypt-option 'known)
6720 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6721 (unless (eq nparts (cdr handle))
6722 (mm-destroy-parts (cdr handle))
6723 (setcdr handle nparts))))
6724 (setq point (point))
6725 (gnus-mime-display-security handle)
6726 (goto-char (point-max)))
6728 (delete-region (point) (cdr region))
6729 (set-marker (car region) nil)
6730 (set-marker (cdr region) nil))
6733 (defun gnus-mime-security-show-details (handle)
6734 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6736 (gnus-message 5 "No details.")
6737 (if gnus-mime-security-show-details-inline
6738 (let ((gnus-mime-security-button-pressed
6739 (not (get-text-property (point) 'gnus-mime-details)))
6740 (gnus-mime-security-button-line-format
6741 (get-text-property (point) 'gnus-line-format))
6744 (while (eq (get-text-property (point) 'gnus-line-format)
6745 gnus-mime-security-button-line-format)
6749 (narrow-to-region (point) (point))
6750 (gnus-insert-mime-security-button handle))
6751 (delete-region (point)
6752 (or (text-property-not-all
6755 gnus-mime-security-button-line-format)
6758 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6759 (with-current-buffer gnus-mime-security-details-buffer
6762 (setq gnus-mime-security-details-buffer
6763 (gnus-get-buffer-create "*MIME Security Details*")))
6764 (with-current-buffer gnus-mime-security-details-buffer
6766 (goto-char (point-min)))
6767 (pop-to-buffer gnus-mime-security-details-buffer)))))
6769 (defun gnus-mime-security-press-button (handle)
6771 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6772 (gnus-mime-security-show-details handle)
6773 (gnus-mime-security-verify-or-decrypt handle))))
6775 (defun gnus-insert-mime-security-button (handle &optional displayed)
6776 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6779 (or (nth 2 (assoc protocol mm-verify-function-alist))
6780 (nth 2 (assoc protocol mm-decrypt-function-alist))
6782 (if (equal (car handle) "multipart/signed")
6783 " Signed" " Encrypted")
6786 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6789 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6790 gnus-tmp-pressed-details
6792 (setq gnus-tmp-details
6793 (if gnus-tmp-details
6794 (concat "\n" gnus-tmp-details)
6796 (setq gnus-tmp-pressed-details
6797 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6802 gnus-mime-security-button-line-format
6803 gnus-mime-security-button-line-format-alist
6804 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6805 gnus-callback gnus-mime-security-press-button
6806 gnus-line-format ,gnus-mime-security-button-line-format
6807 gnus-mime-details ,gnus-mime-security-button-pressed
6808 article-type annotation
6811 ;; Exclude a newline.
6814 (widget-convert-button
6817 :action 'gnus-widget-press-button
6818 :button-keymap gnus-mime-security-button-map
6820 (lambda (widget/window &optional overlay pos)
6821 ;; Needed to properly clear the message due to a bug in
6822 ;; wid-edit (XEmacs only).
6823 (when (boundp 'help-echo-owns-message)
6824 (setq help-echo-owns-message t))
6827 (aref gnus-mouse-2 0))))))
6829 (defun gnus-mime-display-security (handle)
6831 (narrow-to-region (point) (point))
6832 (unless (gnus-unbuttonized-mime-type-p (car handle))
6833 (gnus-insert-mime-security-button handle))
6834 (gnus-mime-display-mixed (cdr handle))
6837 (unless (gnus-unbuttonized-mime-type-p (car handle))
6838 (let ((gnus-mime-security-button-line-format
6839 gnus-mime-security-button-end-line-format))
6840 (gnus-insert-mime-security-button handle)))
6841 (mm-set-handle-multipart-parameter
6843 (cons (set-marker (make-marker) (point-min))
6844 (set-marker (make-marker) (point-max))))))
6850 (run-hooks 'gnus-art-load-hook)
6852 ;;; gnus-art.el ends here