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 (executable-find "icontopbm"))
1150 (and (featurep 'xemacs)
1153 "Display X-Face headers.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' and Info node
1156 `(gnus)X-Face' for details."
1157 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :link '(custom-manual "(gnus)X-Face")
1161 :type gnus-article-treat-head-custom)
1162 (put 'gnus-treat-display-xface 'highlight t)
1164 (defcustom gnus-treat-display-face
1165 (and (not noninteractive)
1166 (or (and (fboundp 'image-type-available-p)
1167 (image-type-available-p 'png))
1168 (and (featurep 'xemacs)
1171 "Display Face headers.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' and Info node
1174 `(gnus)X-Face' for details."
1175 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles")
1178 :link '(custom-manual "(gnus)X-Face")
1179 :type gnus-article-treat-head-custom)
1180 (put 'gnus-treat-display-xface 'highlight t)
1182 (defcustom gnus-treat-display-smileys
1183 (if (or (and (featurep 'xemacs)
1185 (and (fboundp 'image-type-available-p)
1186 (image-type-available-p 'pbm)))
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' and Info node
1191 `(gnus)Smileys' for details."
1192 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :link '(custom-manual "(gnus)Smileys")
1196 :type gnus-article-treat-custom)
1197 (put 'gnus-treat-display-smileys 'highlight t)
1199 (defcustom gnus-treat-from-picon
1200 (if (and (gnus-image-type-available-p 'xpm)
1201 (gnus-picons-installed-p))
1203 "Display picons in the From header.
1204 Valid values are nil, t, `head', `last', an integer or a predicate.
1205 See Info node `(gnus)Customizing Articles' and Info node
1206 `(gnus)Picons' for details."
1207 :group 'gnus-article-treat
1209 :link '(custom-manual "(gnus)Customizing Articles")
1210 :link '(custom-manual "(gnus)Picons")
1211 :type gnus-article-treat-head-custom)
1212 (put 'gnus-treat-from-picon 'highlight t)
1214 (defcustom gnus-treat-mail-picon
1215 (if (and (gnus-image-type-available-p 'xpm)
1216 (gnus-picons-installed-p))
1218 "Display picons in To and Cc headers.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' and Info node
1221 `(gnus)Picons' for details."
1222 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :link '(custom-manual "(gnus)Picons")
1226 :type gnus-article-treat-head-custom)
1227 (put 'gnus-treat-mail-picon 'highlight t)
1229 (defcustom gnus-treat-newsgroups-picon
1230 (if (and (gnus-image-type-available-p 'xpm)
1231 (gnus-picons-installed-p))
1233 "Display picons in the Newsgroups and Followup-To headers.
1234 Valid values are nil, t, `head', `last', an integer or a predicate.
1235 See Info node `(gnus)Customizing Articles' and Info node
1236 `(gnus)Picons' for details."
1237 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :link '(custom-manual "(gnus)Picons")
1241 :type gnus-article-treat-head-custom)
1242 (put 'gnus-treat-newsgroups-picon 'highlight t)
1244 (defcustom gnus-treat-body-boundary
1245 (if (or gnus-treat-newsgroups-picon
1246 gnus-treat-mail-picon
1247 gnus-treat-from-picon)
1249 "Draw a boundary at the end of the headers.
1250 Valid values are nil, t, `head', `last', an integer or a predicate.
1251 See Info node `(gnus)Customizing Articles' for details."
1253 :group 'gnus-article-treat
1254 :link '(custom-manual "(gnus)Customizing Articles")
1255 :type gnus-article-treat-custom)
1257 (defcustom gnus-treat-capitalize-sentences nil
1258 "Capitalize sentence-starting words.
1259 Valid values are nil, t, `head', `last', an integer or a predicate.
1260 See Info node `(gnus)Customizing Articles' for details."
1262 :group 'gnus-article-treat
1263 :link '(custom-manual "(gnus)Customizing Articles")
1264 :type gnus-article-treat-custom)
1266 (defcustom gnus-treat-wash-html nil
1268 Valid values are nil, t, `head', `last', an integer or a predicate.
1269 See Info node `(gnus)Customizing Articles' for details."
1270 :group 'gnus-article-treat
1271 :link '(custom-manual "(gnus)Customizing Articles")
1272 :type gnus-article-treat-custom)
1274 (defcustom gnus-treat-fill-long-lines nil
1276 Valid values are nil, t, `head', `last', an integer or a predicate.
1277 See Info node `(gnus)Customizing Articles' for details."
1278 :group 'gnus-article-treat
1279 :link '(custom-manual "(gnus)Customizing Articles")
1280 :type gnus-article-treat-custom)
1282 (defcustom gnus-treat-play-sounds nil
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' for details."
1287 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-custom)
1291 (defcustom gnus-treat-translate nil
1292 "Translate articles from one language to another.
1293 Valid values are nil, t, `head', `last', an integer or a predicate.
1294 See Info node `(gnus)Customizing Articles' for details."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-x-pgp-sig nil
1302 To automatically treat X-PGP-Sig, set it to head.
1303 Valid values are nil, t, `head', `last', an integer or a predicate.
1304 See Info node `(gnus)Customizing Articles' for details."
1305 :group 'gnus-article-treat
1306 :group 'mime-security
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-custom)
1310 (defvar gnus-article-encrypt-protocol-alist
1311 '(("PGP" . mml2015-self-encrypt)))
1313 ;; Set to nil if more than one protocol added to
1314 ;; gnus-article-encrypt-protocol-alist.
1315 (defcustom gnus-article-encrypt-protocol "PGP"
1316 "The protocol used for encrypt articles.
1317 It is a string, such as \"PGP\". If nil, ask user."
1319 :group 'mime-security)
1321 (defvar gnus-article-wash-function nil
1322 "Function used for converting HTML into text.")
1324 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1325 (fboundp 'coding-system-p)
1326 (coding-system-p 'utf-8))
1327 "Whether IDNA decoding of headers is used when viewing messages.
1328 This requires GNU Libidn, and by default only enabled if it is found."
1329 :group 'gnus-article-headers
1332 ;;; Internal variables
1334 (defvar gnus-english-month-names
1335 '("January" "February" "March" "April" "May" "June" "July" "August"
1336 "September" "October" "November" "December"))
1338 (defvar article-goto-body-goes-to-point-min-p nil)
1339 (defvar gnus-article-wash-types nil)
1340 (defvar gnus-article-emphasis-alist nil)
1341 (defvar gnus-article-image-alist nil)
1343 (defvar gnus-article-mime-handle-alist-1 nil)
1344 (defvar gnus-treatment-function-alist
1345 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1346 (gnus-treat-strip-banner gnus-article-strip-banner)
1347 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1348 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1349 (gnus-treat-buttonize gnus-article-add-buttons)
1350 (gnus-treat-fill-article gnus-article-fill-cited-article)
1351 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1352 (gnus-treat-strip-cr gnus-article-remove-cr)
1353 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1354 (gnus-treat-date-ut gnus-article-date-ut)
1355 (gnus-treat-date-local gnus-article-date-local)
1356 (gnus-treat-date-english gnus-article-date-english)
1357 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1358 (gnus-treat-date-original gnus-article-date-original)
1359 (gnus-treat-date-user-defined gnus-article-date-user)
1360 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1361 (gnus-treat-display-xface gnus-article-display-x-face)
1362 (gnus-treat-display-face gnus-article-display-face)
1363 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1364 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1365 (gnus-treat-hide-signature gnus-article-hide-signature)
1366 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1367 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1368 (gnus-treat-strip-pem gnus-article-hide-pem)
1369 (gnus-treat-from-picon gnus-treat-from-picon)
1370 (gnus-treat-mail-picon gnus-treat-mail-picon)
1371 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1372 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1373 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1374 (gnus-treat-strip-trailing-blank-lines
1375 gnus-article-remove-trailing-blank-lines)
1376 (gnus-treat-strip-leading-blank-lines
1377 gnus-article-strip-leading-blank-lines)
1378 (gnus-treat-strip-multiple-blank-lines
1379 gnus-article-strip-multiple-blank-lines)
1380 (gnus-treat-overstrike gnus-article-treat-overstrike)
1381 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1382 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1383 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1384 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1385 (gnus-treat-display-smileys gnus-treat-smiley)
1386 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1387 (gnus-treat-wash-html gnus-article-wash-html)
1388 (gnus-treat-emphasize gnus-article-emphasize)
1389 (gnus-treat-hide-citation gnus-article-hide-citation)
1390 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1391 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1392 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1393 (gnus-treat-play-sounds gnus-earcon-display)))
1395 (defvar gnus-article-mime-handle-alist nil)
1396 (defvar article-lapsed-timer nil)
1397 (defvar gnus-article-current-summary nil)
1399 (defvar gnus-article-mode-syntax-table
1400 (let ((table (copy-syntax-table text-mode-syntax-table)))
1401 ;; This causes the citation match run O(2^n).
1402 ;; (modify-syntax-entry ?- "w" table)
1403 (modify-syntax-entry ?> ")<" table)
1404 (modify-syntax-entry ?< "(>" table)
1405 ;; make M-. in article buffers work for `foo' strings
1406 (modify-syntax-entry ?' " " table)
1407 (modify-syntax-entry ?` " " table)
1409 "Syntax table used in article mode buffers.
1410 Initialized from `text-mode-syntax-table.")
1412 (defvar gnus-save-article-buffer nil)
1414 (defvar gnus-article-mode-line-format-alist
1415 (nconc '((?w (gnus-article-wash-status) ?s)
1416 (?m (gnus-article-mime-part-status) ?s))
1417 gnus-summary-mode-line-format-alist))
1419 (defvar gnus-number-of-articles-to-be-saved nil)
1421 (defvar gnus-inhibit-hiding nil)
1423 ;;; Macros for dealing with the article buffer.
1425 (defmacro gnus-with-article-headers (&rest forms)
1427 (set-buffer gnus-article-buffer)
1429 (let ((buffer-read-only nil)
1430 (inhibit-point-motion-hooks t)
1431 (case-fold-search t))
1432 (article-narrow-to-head)
1435 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1436 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1438 (defmacro gnus-with-article-buffer (&rest forms)
1440 (set-buffer gnus-article-buffer)
1441 (let ((buffer-read-only nil))
1444 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1445 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1447 (defun gnus-article-goto-header (header)
1448 "Go to HEADER, which is a regular expression."
1449 (re-search-forward (concat "^\\(" header "\\):") nil t))
1451 (defsubst gnus-article-hide-text (b e props)
1452 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1453 (gnus-add-text-properties-when 'article-type nil b e props)
1454 (when (memq 'intangible props)
1456 (max (1- b) (point-min))
1457 b 'intangible (cddr (memq 'intangible props)))))
1459 (defsubst gnus-article-unhide-text (b e)
1460 "Remove hidden text properties from region between B and E."
1461 (remove-text-properties b e gnus-hidden-properties)
1462 (when (memq 'intangible gnus-hidden-properties)
1463 (put-text-property (max (1- b) (point-min))
1464 b 'intangible nil)))
1466 (defun gnus-article-hide-text-type (b e type)
1467 "Hide text of TYPE between B and E."
1468 (gnus-add-wash-type type)
1469 (gnus-article-hide-text
1470 b e (cons 'article-type (cons type gnus-hidden-properties))))
1472 (defun gnus-article-unhide-text-type (b e type)
1473 "Unhide text of TYPE between B and E."
1474 (gnus-delete-wash-type type)
1475 (remove-text-properties
1476 b e (cons 'article-type (cons type gnus-hidden-properties)))
1477 (when (memq 'intangible gnus-hidden-properties)
1478 (put-text-property (max (1- b) (point-min))
1479 b 'intangible nil)))
1481 (defun gnus-article-hide-text-of-type (type)
1482 "Hide text of TYPE in the current buffer."
1484 (let ((b (point-min))
1486 (while (setq b (text-property-any b e 'article-type type))
1487 (add-text-properties b (incf b) gnus-hidden-properties)))))
1489 (defun gnus-article-delete-text-of-type (type)
1490 "Delete text of TYPE in the current buffer."
1492 (let ((b (point-min)))
1493 (while (setq b (text-property-any b (point-max) 'article-type type))
1495 b (or (text-property-not-all b (point-max) 'article-type type)
1498 (defun gnus-article-delete-invisible-text ()
1499 "Delete all invisible text in the current buffer."
1501 (let ((b (point-min)))
1502 (while (setq b (text-property-any b (point-max) 'invisible t))
1504 b (or (text-property-not-all b (point-max) 'invisible t)
1507 (defun gnus-article-text-type-exists-p (type)
1508 "Say whether any text of type TYPE exists in the buffer."
1509 (text-property-any (point-min) (point-max) 'article-type type))
1511 (defsubst gnus-article-header-rank ()
1512 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1513 (let ((list gnus-sorted-header-list)
1516 (if (looking-at (car list))
1518 (setq list (cdr list))
1522 (defun article-hide-headers (&optional arg delete)
1523 "Hide unwanted headers and possibly sort them as well."
1525 ;; This function might be inhibited.
1526 (unless gnus-inhibit-hiding
1529 (let ((buffer-read-only nil)
1530 (case-fold-search t)
1531 (max (1+ (length gnus-sorted-header-list)))
1532 (ignored (when (not gnus-visible-headers)
1533 (cond ((stringp gnus-ignored-headers)
1534 gnus-ignored-headers)
1535 ((listp gnus-ignored-headers)
1536 (mapconcat 'identity gnus-ignored-headers
1539 (cond ((stringp gnus-visible-headers)
1540 gnus-visible-headers)
1541 ((and gnus-visible-headers
1542 (listp gnus-visible-headers))
1543 (mapconcat 'identity gnus-visible-headers "\\|"))))
1544 (inhibit-point-motion-hooks t)
1546 ;; First we narrow to just the headers.
1547 (article-narrow-to-head)
1548 ;; Hide any "From " lines at the beginning of (mail) articles.
1549 (while (looking-at "From ")
1552 (delete-region (point-min) (point)))
1553 ;; Then treat the rest of the header lines.
1554 ;; Then we use the two regular expressions
1555 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1556 ;; select which header lines is to remain visible in the
1558 (while (re-search-forward "^[^ \t:]*:" nil t)
1560 ;; Mark the rank of the header.
1562 (point) (1+ (point)) 'message-rank
1563 (if (or (and visible (looking-at visible))
1565 (not (looking-at ignored))))
1566 (gnus-article-header-rank)
1569 (message-sort-headers-1)
1570 (when (setq beg (text-property-any
1571 (point-min) (point-max) 'message-rank (+ 2 max)))
1572 ;; We delete the unwanted headers.
1573 (gnus-add-wash-type 'headers)
1574 (add-text-properties (point-min) (+ 5 (point-min))
1575 '(article-type headers dummy-invisible t))
1576 (delete-region beg (point-max))))))))
1578 (defun article-hide-boring-headers (&optional arg)
1579 "Toggle hiding of headers that aren't very interesting.
1580 If given a negative prefix, always show; if given a positive prefix,
1582 (interactive (gnus-article-hidden-arg))
1583 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1584 (not gnus-show-all-headers))
1587 (let ((buffer-read-only nil)
1588 (list gnus-boring-article-headers)
1589 (inhibit-point-motion-hooks t)
1591 (article-narrow-to-head)
1593 (setq elem (pop list))
1594 (goto-char (point-min))
1596 ;; Hide empty headers.
1598 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1600 (gnus-article-hide-text-type
1604 (if (re-search-forward "^[^ \t]" nil t)
1608 ;; Hide boring Newsgroups header.
1609 ((eq elem 'newsgroups)
1610 (when (gnus-string-equal
1611 (gnus-fetch-field "newsgroups")
1612 (gnus-group-real-name
1613 (if (boundp 'gnus-newsgroup-name)
1616 (gnus-article-hide-header "newsgroups")))
1617 ((eq elem 'to-address)
1618 (let ((to (message-fetch-field "to"))
1620 (gnus-parameter-to-address
1621 (if (boundp 'gnus-newsgroup-name)
1622 gnus-newsgroup-name ""))))
1623 (when (and to to-address
1626 ;; only one address in To
1627 (nth 1 (mail-extract-address-components to))
1629 (gnus-article-hide-header "to"))))
1631 (let ((to (message-fetch-field "to"))
1633 (gnus-parameter-to-list
1634 (if (boundp 'gnus-newsgroup-name)
1635 gnus-newsgroup-name ""))))
1636 (when (and to to-list
1639 ;; only one address in To
1640 (nth 1 (mail-extract-address-components to))
1642 (gnus-article-hide-header "to"))))
1644 (let ((cc (message-fetch-field "cc"))
1646 (gnus-parameter-to-list
1647 (if (boundp 'gnus-newsgroup-name)
1648 gnus-newsgroup-name ""))))
1649 (when (and cc to-list
1652 ;; only one address in CC
1653 (nth 1 (mail-extract-address-components cc))
1655 (gnus-article-hide-header "cc"))))
1656 ((eq elem 'followup-to)
1657 (when (gnus-string-equal
1658 (message-fetch-field "followup-to")
1659 (message-fetch-field "newsgroups"))
1660 (gnus-article-hide-header "followup-to")))
1661 ((eq elem 'reply-to)
1662 (let ((from (message-fetch-field "from"))
1663 (reply-to (message-fetch-field "reply-to")))
1668 (nth 1 (mail-extract-address-components from))
1669 (nth 1 (mail-extract-address-components reply-to)))))
1670 (gnus-article-hide-header "reply-to"))))
1672 (let ((date (message-fetch-field "date")))
1674 (< (days-between (current-time-string) date)
1676 (gnus-article-hide-header "date"))))
1678 (let ((to (message-fetch-field "to"))
1679 (cc (message-fetch-field "cc")))
1680 (when (> (length to) 1024)
1681 (gnus-article-hide-header "to"))
1682 (when (> (length cc) 1024)
1683 (gnus-article-hide-header "cc"))))
1687 (goto-char (point-min))
1688 (while (re-search-forward "^to:" nil t)
1689 (setq to-count (1+ to-count)))
1690 (when (> to-count 1)
1691 (while (> to-count 0)
1692 (goto-char (point-min))
1694 (re-search-forward "^to:" nil nil to-count)
1696 (narrow-to-region (point) (point-max))
1697 (gnus-article-hide-header "to"))
1698 (setq to-count (1- to-count))))
1699 (goto-char (point-min))
1700 (while (re-search-forward "^cc:" nil t)
1701 (setq cc-count (1+ cc-count)))
1702 (when (> cc-count 1)
1703 (while (> cc-count 0)
1704 (goto-char (point-min))
1706 (re-search-forward "^cc:" nil nil cc-count)
1708 (narrow-to-region (point) (point-max))
1709 (gnus-article-hide-header "cc"))
1710 (setq cc-count (1- cc-count)))))))))))))
1712 (defun gnus-article-hide-header (header)
1714 (goto-char (point-min))
1715 (when (re-search-forward (concat "^" header ":") nil t)
1716 (gnus-article-hide-text-type
1720 (if (re-search-forward "^[^ \t]" nil t)
1725 (defvar gnus-article-normalized-header-length 40
1726 "Length of normalized headers.")
1728 (defun article-normalize-headers ()
1729 "Make all header lines 40 characters long."
1731 (let ((buffer-read-only nil)
1735 (article-narrow-to-head)
1738 ((< (setq column (- (gnus-point-at-eol) (point)))
1739 gnus-article-normalized-header-length)
1741 (insert (make-string
1742 (- gnus-article-normalized-header-length column)
1744 ((> column gnus-article-normalized-header-length)
1745 (gnus-put-text-property
1747 (forward-char gnus-article-normalized-header-length)
1754 (forward-line 1))))))
1756 (defun article-treat-dumbquotes ()
1757 "Translate M****s*** sm*rtq**t*s into proper text.
1758 Note that this function guesses whether a character is a sm*rtq**t* or
1759 not, so it should only be used interactively.
1761 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1762 in an attempt to provide more quoting characters. If you see
1763 something like \\222 or \\264 where you're expecting some kind of
1764 apostrophe or quotation mark, then try this wash."
1766 (article-translate-strings gnus-article-dumbquotes-map))
1768 (defun article-translate-characters (from to)
1769 "Translate all characters in the body of the article according to FROM and TO.
1770 FROM is a string of characters to translate from; to is a string of
1771 characters to translate to."
1773 (when (article-goto-body)
1774 (let ((buffer-read-only nil)
1775 (x (make-string 225 ?x))
1777 (while (< (incf i) (length x))
1780 (while (< i (length from))
1781 (aset x (aref from i) (aref to i))
1783 (translate-region (point) (point-max) x)))))
1785 (defun article-translate-strings (map)
1786 "Translate all string in the body of the article according to MAP.
1787 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1789 (when (article-goto-body)
1790 (let ((buffer-read-only nil)
1792 (while (setq elem (pop map))
1794 (while (search-forward (car elem) nil t)
1795 (replace-match (cadr elem)))))))))
1797 (defun article-treat-overstrike ()
1798 "Translate overstrikes into bold text."
1801 (when (article-goto-body)
1802 (let ((buffer-read-only nil))
1803 (while (search-forward "\b" nil t)
1804 (let ((next (char-after))
1805 (previous (char-after (- (point) 2))))
1806 ;; We do the boldification/underlining by hiding the
1807 ;; overstrikes and putting the proper text property
1811 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1812 (put-text-property (point) (1+ (point)) 'face 'bold))
1814 (gnus-article-hide-text-type
1815 (1- (point)) (1+ (point)) 'overstrike)
1817 (- (point) 2) (1- (point)) 'face 'underline))
1819 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1821 (point) (1+ (point)) 'face 'underline)))))))))
1823 (defun gnus-article-treat-unfold-headers ()
1824 "Unfold folded message headers.
1825 Only the headers that fit into the current window width will be
1828 (gnus-with-article-headers
1832 (mail-header-narrow-to-field)
1833 (let ((header (buffer-string)))
1836 (goto-char (point-min))
1837 (while (re-search-forward "\n[\t ]" nil t)
1838 (replace-match " " t t)))
1839 (setq length (- (point-max) (point-min) 1)))
1840 (when (< length (window-width))
1841 (while (re-search-forward "\n[\t ]" nil t)
1842 (replace-match " " t t)))
1843 (goto-char (point-max)))))))
1845 (defun gnus-article-treat-fold-headers ()
1846 "Fold message headers."
1848 (gnus-with-article-headers
1851 (mail-header-narrow-to-field)
1852 (mail-header-fold-field)
1853 (goto-char (point-max))))))
1855 (defun gnus-treat-smiley ()
1856 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1858 (gnus-with-article-buffer
1859 (if (memq 'smiley gnus-article-wash-types)
1860 (gnus-delete-images 'smiley)
1862 (let ((images (smiley-region (point) (point-max))))
1864 (gnus-add-wash-type 'smiley)
1865 (dolist (image images)
1866 (gnus-add-image 'smiley image)))))))
1868 (defun gnus-article-remove-images ()
1869 "Remove all images from the article buffer."
1871 (gnus-with-article-buffer
1872 (dolist (elem gnus-article-image-alist)
1873 (gnus-delete-images (car elem)))))
1875 (defun gnus-article-treat-fold-newsgroups ()
1876 "Unfold folded message headers.
1877 Only the headers that fit into the current window width will be
1880 (gnus-with-article-headers
1881 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1883 (mail-header-narrow-to-field)
1884 (while (re-search-forward ", *" nil t)
1885 (replace-match ", " t t))
1886 (mail-header-fold-field)
1887 (goto-char (point-max))))))
1889 (defun gnus-article-treat-body-boundary ()
1890 "Place a boundary line at the end of the headers."
1892 (when (and gnus-body-boundary-delimiter
1893 (> (length gnus-body-boundary-delimiter) 0))
1894 (gnus-with-article-headers
1895 (goto-char (point-max))
1896 (let ((start (point)))
1897 (insert "X-Boundary: ")
1898 (gnus-add-text-properties start (point) '(invisible t intangible t))
1900 (while (>= (1- (window-width)) (length str))
1901 (setq str (concat str gnus-body-boundary-delimiter)))
1902 (substring str 0 (1- (window-width))))
1904 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1906 (defun article-fill-long-lines ()
1907 "Fill lines that are wider than the window width."
1910 (let ((buffer-read-only nil)
1911 (width (window-width (get-buffer-window (current-buffer)))))
1914 (let ((adaptive-fill-mode nil)) ;Why? -sm
1917 (when (>= (current-column) (min fill-column width))
1918 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1919 (let ((goback (point-marker)))
1920 (fill-paragraph nil)
1921 (goto-char (marker-position goback)))
1923 (forward-line 1)))))))
1925 (defun article-capitalize-sentences ()
1926 "Capitalize the first word in each sentence."
1929 (let ((buffer-read-only nil)
1930 (paragraph-start "^[\n\^L]"))
1934 (forward-sentence)))))
1936 (defun article-remove-cr ()
1937 "Remove trailing CRs and then translate remaining CRs into LFs."
1940 (let ((buffer-read-only nil))
1941 (goto-char (point-min))
1942 (while (re-search-forward "\r+$" nil t)
1943 (replace-match "" t t))
1944 (goto-char (point-min))
1945 (while (search-forward "\r" nil t)
1946 (replace-match "\n" t t)))))
1948 (defun article-remove-trailing-blank-lines ()
1949 "Remove all trailing blank lines from the article."
1952 (let ((buffer-read-only nil))
1953 (goto-char (point-max))
1957 (while (and (not (bobp))
1958 (looking-at "^[ \t]*$")
1959 (not (gnus-annotation-in-region-p
1960 (point) (gnus-point-at-eol))))
1965 (defun article-display-face ()
1966 "Display any Face headers in the header."
1968 (gnus-with-article-headers
1969 (let ((face (message-fetch-field "face")))
1971 (let ((png (gnus-convert-face-to-png face))
1974 (setq image (gnus-create-image png 'png t))
1975 (gnus-article-goto-header "from")
1977 (insert "From: [no `from' set]\n")
1979 (gnus-add-wash-type 'face)
1980 (gnus-add-image 'face image)
1981 (gnus-put-image image)))))))
1983 (defun article-display-x-face (&optional force)
1984 "Look for an X-Face header and display it if present."
1985 (interactive (list 'force))
1986 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1987 (gnus-with-article-headers
1988 ;; Delete the old process, if any.
1989 (when (process-status "article-x-face")
1990 (delete-process "article-x-face"))
1991 (if (memq 'xface gnus-article-wash-types)
1992 ;; We have already displayed X-Faces, so we remove them
1994 (gnus-delete-images 'xface)
1996 (let (x-faces from face)
1998 (when (and wash-face-p
2000 (goto-char (point-min))
2001 (not (re-search-forward
2002 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2003 (gnus-buffer-live-p gnus-original-article-buffer))
2004 ;; If type `W f', use gnus-original-article-buffer,
2005 ;; otherwise use the current buffer because displaying
2006 ;; RFC822 parts calls this function too.
2007 (set-buffer gnus-original-article-buffer))
2009 (mail-narrow-to-head)
2010 (while (gnus-article-goto-header "X-Face")
2011 (push (mail-header-field-value) x-faces))
2012 (setq from (message-fetch-field "from"))))
2013 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2014 ;; single external face.
2015 (when (stringp gnus-article-x-face-command)
2016 (setq x-faces (list (car x-faces))))
2017 (while (and (setq face (pop x-faces))
2018 gnus-article-x-face-command
2020 ;; Check whether this face is censored.
2021 (not gnus-article-x-face-too-ugly)
2022 (and gnus-article-x-face-too-ugly from
2023 (not (string-match gnus-article-x-face-too-ugly
2025 ;; We display the face.
2026 (if (symbolp gnus-article-x-face-command)
2027 ;; The command is a lisp function, so we call it.
2028 (if (gnus-functionp gnus-article-x-face-command)
2029 (funcall gnus-article-x-face-command face)
2030 (error "%s is not a function" gnus-article-x-face-command))
2031 ;; The command is a string, so we interpret the command
2032 ;; as a, well, command, and fork it off.
2033 (let ((process-connection-type nil))
2034 (process-kill-without-query
2036 "article-x-face" nil shell-file-name shell-command-switch
2037 gnus-article-x-face-command))
2040 (process-send-region "article-x-face"
2041 (point-min) (point-max)))
2042 (process-send-eof "article-x-face")))))))))
2044 (defun article-decode-mime-words ()
2045 "Decode all MIME-encoded words in the article."
2048 (set-buffer gnus-article-buffer)
2049 (let ((inhibit-point-motion-hooks t)
2051 (mail-parse-charset gnus-newsgroup-charset)
2052 (mail-parse-ignored-charsets
2053 (save-excursion (set-buffer gnus-summary-buffer)
2054 gnus-newsgroup-ignored-charsets)))
2055 (mail-decode-encoded-word-region (point-min) (point-max)))))
2057 (defun article-decode-charset (&optional prompt)
2058 "Decode charset-encoded text in the article.
2059 If PROMPT (the prefix), prompt for a coding system to use."
2061 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2063 (mail-parse-charset gnus-newsgroup-charset)
2064 (mail-parse-ignored-charsets
2065 (save-excursion (condition-case nil
2066 (set-buffer gnus-summary-buffer)
2068 gnus-newsgroup-ignored-charsets))
2069 ct cte ctl charset format)
2072 (article-narrow-to-head)
2073 (setq ct (message-fetch-field "Content-Type" t)
2074 cte (message-fetch-field "Content-Transfer-Encoding" t)
2075 ctl (and ct (ignore-errors
2076 (mail-header-parse-content-type ct)))
2079 (mm-read-coding-system "Charset to decode: "))
2081 (mail-content-type-get ctl 'charset)))
2082 format (and ctl (mail-content-type-get ctl 'format)))
2084 (setq cte (mail-header-strip cte)))
2085 (if (and ctl (not (string-match "/" (car ctl))))
2087 (goto-char (point-max)))
2090 (narrow-to-region (point) (point-max))
2091 (when (and (eq mail-parse-charset 'gnus-decoded)
2092 (eq (mm-body-7-or-8) '8bit))
2093 ;; The text code could have been decoded.
2094 (setq charset mail-parse-charset))
2095 (when (and (or (not ctl)
2096 (equal (car ctl) "text/plain"))
2097 (not format)) ;; article with format will decode later.
2099 charset (and cte (intern (downcase
2100 (gnus-strip-whitespace cte))))
2101 (car ctl) prompt))))))
2103 (defun article-decode-encoded-words ()
2104 "Remove encoded-word encoding from headers."
2105 (let ((inhibit-point-motion-hooks t)
2106 (mail-parse-charset gnus-newsgroup-charset)
2107 (mail-parse-ignored-charsets
2108 (save-excursion (condition-case nil
2109 (set-buffer gnus-summary-buffer)
2111 gnus-newsgroup-ignored-charsets))
2114 (article-narrow-to-head)
2115 (funcall gnus-decode-header-function (point-min) (point-max)))))
2117 (defun article-decode-group-name ()
2118 "Decode group names in `Newsgroups:'."
2119 (let ((inhibit-point-motion-hooks t)
2121 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2122 (when (and (or gnus-group-name-charset-method-alist
2123 gnus-group-name-charset-group-alist)
2124 (gnus-buffer-live-p gnus-original-article-buffer))
2126 (goto-char (point-min))
2127 (article-narrow-to-head)
2128 (while (re-search-forward (concat "^\\(Newsgroups\\|Followup-To\\): "
2129 "\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]")
2131 (replace-match (save-match-data
2132 (gnus-decode-newsgroups
2133 ;; XXX how to use data in this buffer?
2134 (with-current-buffer gnus-original-article-buffer
2135 (goto-char (point-min))
2137 (concat "^\\(Newsgroups\\|Followup-To\\): "
2138 "\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]")
2141 gnus-newsgroup-name method))
2144 (autoload 'idna-to-unicode "idna")
2146 (defun article-decode-idna-rhs ()
2147 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2150 (let ((inhibit-point-motion-hooks t)
2152 (article-narrow-to-head)
2153 (goto-char (point-min))
2154 (while (re-search-forward "\\(xn--.*\\)[ \t\n\r,>]" nil t)
2156 (when (save-match-data
2157 (and (setq ace (match-string 1))
2159 (and (re-search-backward "^[^ \t]" nil t)
2160 (looking-at "From\\|To\\|Cc")))
2161 (save-excursion (backward-char)
2162 (message-idna-inside-rhs-p))
2163 (setq unicode (idna-to-unicode ace))))
2164 (unless (string= ace unicode)
2165 (replace-match unicode nil nil nil 1)))))))))
2167 (defun article-de-quoted-unreadable (&optional force read-charset)
2168 "Translate a quoted-printable-encoded article.
2169 If FORCE, decode the article whether it is marked as quoted-printable
2171 If READ-CHARSET, ask for a coding system."
2172 (interactive (list 'force current-prefix-arg))
2174 (let ((buffer-read-only nil) type charset)
2175 (if (gnus-buffer-live-p gnus-original-article-buffer)
2176 (with-current-buffer gnus-original-article-buffer
2178 (gnus-fetch-field "content-transfer-encoding"))
2179 (let* ((ct (gnus-fetch-field "content-type"))
2182 (mail-header-parse-content-type ct)))))
2183 (setq charset (and ctl
2184 (mail-content-type-get ctl 'charset)))
2185 (if (stringp charset)
2186 (setq charset (intern (downcase charset)))))))
2188 (setq charset (mm-read-coding-system "Charset: " charset)))
2190 (setq charset gnus-newsgroup-charset))
2192 (and type (let ((case-fold-search t))
2193 (string-match "quoted-printable" type))))
2195 (quoted-printable-decode-region
2196 (point) (point-max) (mm-charset-to-coding-system charset))))))
2198 (defun article-de-base64-unreadable (&optional force read-charset)
2199 "Translate a base64 article.
2200 If FORCE, decode the article whether it is marked as base64 not.
2201 If READ-CHARSET, ask for a coding system."
2202 (interactive (list 'force current-prefix-arg))
2204 (let ((buffer-read-only nil) type charset)
2205 (if (gnus-buffer-live-p gnus-original-article-buffer)
2206 (with-current-buffer gnus-original-article-buffer
2208 (gnus-fetch-field "content-transfer-encoding"))
2209 (let* ((ct (gnus-fetch-field "content-type"))
2212 (mail-header-parse-content-type ct)))))
2213 (setq charset (and ctl
2214 (mail-content-type-get ctl 'charset)))
2215 (if (stringp charset)
2216 (setq charset (intern (downcase charset)))))))
2218 (setq charset (mm-read-coding-system "Charset: " charset)))
2220 (setq charset gnus-newsgroup-charset))
2222 (and type (let ((case-fold-search t))
2223 (string-match "base64" type))))
2226 (narrow-to-region (point) (point-max))
2227 (base64-decode-region (point-min) (point-max))
2228 (mm-decode-coding-region
2229 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2234 (defun article-decode-HZ ()
2235 "Translate a HZ-encoded article."
2239 (let ((buffer-read-only nil))
2240 (rfc1843-decode-region (point-min) (point-max)))))
2242 (defun article-unsplit-urls ()
2243 "Remove the newlines that some other mailers insert into URLs."
2246 (let ((buffer-read-only nil))
2247 (goto-char (point-min))
2248 (while (re-search-forward
2249 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2250 (replace-match "\\1\\3" t)))
2251 (when (and gnus-display-mime-function (interactive-p))
2252 (funcall gnus-display-mime-function))))
2255 (defun article-wash-html (&optional read-charset)
2256 "Format an HTML article.
2257 If READ-CHARSET, ask for a coding system."
2260 (let ((buffer-read-only nil)
2262 (when (gnus-buffer-live-p gnus-original-article-buffer)
2263 (with-current-buffer gnus-original-article-buffer
2264 (let* ((ct (gnus-fetch-field "content-type"))
2267 (mail-header-parse-content-type ct)))))
2268 (setq charset (and ctl
2269 (mail-content-type-get ctl 'charset)))
2270 (when (stringp charset)
2271 (setq charset (intern (downcase charset)))))))
2273 (setq charset (mm-read-coding-system "Charset: " charset)))
2275 (setq charset gnus-newsgroup-charset))
2277 (save-window-excursion
2279 (narrow-to-region (point) (point-max))
2280 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2281 (entry (assq func mm-text-html-washer-alist)))
2283 (setq func (cdr entry)))
2285 ((gnus-functionp func)
2288 (apply (car func) (cdr func))))))))))
2290 (defun gnus-article-wash-html-with-w3 ()
2291 "Wash the current buffer with w3."
2293 (let ((w3-strict-width (window-width))
2294 (url-standalone-mode t)
2295 (url-gateway-unplugged t)
2296 (w3-honor-stylesheets nil))
2298 (w3-region (point-min) (point-max))
2301 (defun gnus-article-wash-html-with-w3m ()
2302 "Wash the current buffer with emacs-w3m."
2305 (narrow-to-region (point) (point-max))
2306 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2309 w3m-force-redisplay)
2310 (w3m-region (point-min) (point-max)))
2311 (when mm-inline-text-html-with-w3m-keymap
2312 (add-text-properties
2313 (point-min) (point-max)
2314 (nconc (mm-w3m-local-map-property)
2315 '(mm-inline-text-html-with-w3m t))))))
2317 (defun article-hide-list-identifiers ()
2318 "Remove list identifies from the Subject header.
2319 The `gnus-list-identifiers' variable specifies what to do."
2321 (let ((inhibit-point-motion-hooks t)
2322 (regexp (if (consp gnus-list-identifiers)
2323 (mapconcat 'identity gnus-list-identifiers " *\\|")
2324 gnus-list-identifiers))
2329 (article-narrow-to-head)
2330 (goto-char (point-min))
2331 (while (re-search-forward
2332 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2334 (delete-region (match-beginning 2) (match-end 0))
2335 (beginning-of-line))
2336 (when (re-search-forward
2337 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2338 (delete-region (match-beginning 1) (match-end 1))))))))
2340 (defun article-hide-pem (&optional arg)
2341 "Toggle hiding of any PEM headers and signatures in the current article.
2342 If given a negative prefix, always show; if given a positive prefix,
2344 (interactive (gnus-article-hidden-arg))
2345 (unless (gnus-article-check-hidden-text 'pem arg)
2347 (let (buffer-read-only end)
2348 (goto-char (point-min))
2349 ;; Hide the horrendously ugly "header".
2350 (when (and (search-forward
2351 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2353 (setq end (1+ (match-beginning 0))))
2354 (gnus-add-wash-type 'pem)
2355 (gnus-article-hide-text-type
2357 (if (search-forward "\n\n" nil t)
2361 ;; Hide the trailer as well
2362 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2364 (gnus-article-hide-text-type
2365 (match-beginning 0) (match-end 0) 'pem)))))))
2367 (defun article-strip-banner ()
2368 "Strip the banners specified by the `banner' group parameter and by
2369 `gnus-article-address-banner-alist'."
2373 (let ((inhibit-point-motion-hooks t))
2374 (when (gnus-parameter-banner gnus-newsgroup-name)
2375 (article-really-strip-banner
2376 (gnus-parameter-banner gnus-newsgroup-name)))
2377 (when gnus-article-address-banner-alist
2378 (article-really-strip-banner
2379 (let ((from (save-restriction
2381 (article-narrow-to-head)
2382 (mail-fetch-field "from"))))
2385 (caar (mail-header-parse-addresses from))))
2387 (dolist (pair gnus-article-address-banner-alist)
2388 (when (string-match (car pair) from)
2389 (throw 'found (cdr pair)))))))))))))
2391 (defun article-really-strip-banner (banner)
2392 "Strip the banner specified by the argument."
2395 (let ((inhibit-point-motion-hooks t)
2396 (gnus-signature-limit nil)
2400 ((eq banner 'signature)
2401 (when (gnus-article-narrow-to-signature)
2404 (delete-region (point) (point-max))))
2406 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2407 (while (re-search-forward banner nil t)
2408 (delete-region (match-beginning 0) (match-end 0)))))
2410 (while (re-search-forward banner nil t)
2411 (delete-region (match-beginning 0) (match-end 0)))))))))
2413 (defun article-babel ()
2414 "Translate article using an online translation service."
2418 (set-buffer gnus-article-buffer)
2419 (when (article-goto-body)
2420 (let* ((buffer-read-only nil)
2423 (orig (buffer-substring start end))
2424 (trans (babel-as-string orig)))
2426 (narrow-to-region start end)
2427 (delete-region start end)
2430 (defun article-hide-signature (&optional arg)
2431 "Hide the signature in the current article.
2432 If given a negative prefix, always show; if given a positive prefix,
2434 (interactive (gnus-article-hidden-arg))
2435 (unless (gnus-article-check-hidden-text 'signature arg)
2438 (let ((buffer-read-only nil))
2439 (when (gnus-article-narrow-to-signature)
2440 (gnus-article-hide-text-type
2441 (point-min) (point-max) 'signature))))))
2442 (gnus-set-mode-line 'article))
2444 (defun article-strip-headers-in-body ()
2445 "Strip offensive headers from bodies."
2449 (let ((case-fold-search t))
2450 (when (looking-at "x-no-archive:")
2451 (gnus-delete-line)))))
2453 (defun article-strip-leading-blank-lines ()
2454 "Remove all blank lines from the beginning of the article."
2457 (let ((inhibit-point-motion-hooks t)
2459 (when (article-goto-body)
2460 (while (and (not (eobp))
2461 (looking-at "[ \t]*$"))
2462 (gnus-delete-line))))))
2464 (defun article-narrow-to-head ()
2465 "Narrow the buffer to the head of the message.
2466 Point is left at the beginning of the narrowed-to region."
2468 (goto-char (point-min))
2469 (if (search-forward "\n\n" nil 1)
2472 (goto-char (point-min)))
2474 (defun article-goto-body ()
2475 "Place point at the start of the body."
2476 (goto-char (point-min))
2478 ;; This variable is only bound when dealing with separate
2480 (article-goto-body-goes-to-point-min-p
2482 ((search-forward "\n\n" nil t)
2485 (goto-char (point-max))
2488 (defun article-strip-multiple-blank-lines ()
2489 "Replace consecutive blank lines with one empty line."
2492 (let ((inhibit-point-motion-hooks t)
2494 ;; First make all blank lines empty.
2496 (while (re-search-forward "^[ \t]+$" nil t)
2497 (unless (gnus-annotation-in-region-p
2498 (match-beginning 0) (match-end 0))
2499 (replace-match "" nil t)))
2500 ;; Then replace multiple empty lines with a single empty line.
2502 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2503 (unless (gnus-annotation-in-region-p
2504 (match-beginning 0) (match-end 0))
2505 (delete-region (match-beginning 1) (match-end 1)))))))
2507 (defun article-strip-leading-space ()
2508 "Remove all white space from the beginning of the lines in the article."
2511 (let ((inhibit-point-motion-hooks t)
2514 (while (re-search-forward "^[ \t]+" nil t)
2515 (replace-match "" t t)))))
2517 (defun article-strip-trailing-space ()
2518 "Remove all white space from the end of the lines in the article."
2521 (let ((inhibit-point-motion-hooks t)
2524 (while (re-search-forward "[ \t]+$" nil t)
2525 (replace-match "" t t)))))
2527 (defun article-strip-blank-lines ()
2528 "Strip leading, trailing and multiple blank lines."
2530 (article-strip-leading-blank-lines)
2531 (article-remove-trailing-blank-lines)
2532 (article-strip-multiple-blank-lines))
2534 (defun article-strip-all-blank-lines ()
2535 "Strip all blank lines."
2538 (let ((inhibit-point-motion-hooks t)
2541 (while (re-search-forward "^[ \t]*\n" nil t)
2542 (replace-match "" t t)))))
2544 (defun gnus-article-narrow-to-signature ()
2545 "Narrow to the signature; return t if a signature is found, else nil."
2546 (let ((inhibit-point-motion-hooks t))
2547 (when (gnus-article-search-signature)
2549 ;; Check whether we have some limits to what we consider
2550 ;; to be a signature.
2551 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2552 (list gnus-signature-limit)))
2554 (while (setq limit (pop limits))
2555 (if (or (and (integerp limit)
2556 (< (- (point-max) (point)) limit))
2558 (< (count-lines (point) (point-max)) limit))
2559 (and (gnus-functionp limit)
2561 (and (stringp limit)
2562 (not (re-search-forward limit nil t))))
2563 () ; This limit did not succeed.
2567 (narrow-to-region (point) (point-max))
2570 (defun gnus-article-search-signature ()
2571 "Search the current buffer for the signature separator.
2572 Put point at the beginning of the signature separator."
2573 (let ((cur (point)))
2574 (goto-char (point-max))
2575 (if (if (stringp gnus-signature-separator)
2576 (re-search-backward gnus-signature-separator nil t)
2577 (let ((seps gnus-signature-separator))
2579 (not (re-search-backward (car seps) nil t)))
2586 (defun gnus-article-hidden-arg ()
2587 "Return the current prefix arg as a number, or 0 if no prefix."
2588 (list (if current-prefix-arg
2589 (prefix-numeric-value current-prefix-arg)
2592 (defun gnus-article-check-hidden-text (type arg)
2593 "Return nil if hiding is necessary.
2594 Arg can be nil or a number. nil and positive means hide, negative
2595 means show, 0 means toggle."
2598 (let ((hide (gnus-article-hidden-text-p type)))
2604 (gnus-article-show-hidden-text type)
2607 (if (eq hide 'hidden)
2609 (gnus-article-show-hidden-text type)
2613 (defun gnus-article-hidden-text-p (type)
2614 "Say whether the current buffer contains hidden text of type TYPE."
2615 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2617 (not (get-text-property pos 'invisible))
2618 (not (get-text-property pos 'dummy-invisible)))
2620 (text-property-any (1+ pos) (point-max) 'article-type type)))
2625 (defun gnus-article-show-hidden-text (type &optional dummy)
2626 "Show all hidden text of type TYPE.
2627 Originally it is hide instead of DUMMY."
2628 (let ((buffer-read-only nil)
2629 (inhibit-point-motion-hooks t))
2630 (gnus-remove-text-properties-when
2632 (point-min) (point-max)
2633 (cons 'article-type (cons type
2634 gnus-hidden-properties)))
2635 (gnus-delete-wash-type type)))
2637 (defconst article-time-units
2638 `((year . ,(* 365.25 24 60 60))
2639 (week . ,(* 7 24 60 60))
2640 (day . ,(* 24 60 60))
2644 "Mapping from time units to seconds.")
2646 (defun gnus-article-forward-header ()
2647 "Move point to the start of the next header.
2648 If the current header is a continuation header, this can be several
2653 (if (looking-at "[ \t]+[^ \t]")
2657 (defun article-date-ut (&optional type highlight header)
2658 "Convert DATE date to universal time in the current article.
2659 If TYPE is `local', convert to local time; if it is `lapsed', output
2660 how much time has lapsed since DATE. For `lapsed', the value of
2661 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2662 should replace the \"Date:\" one, or should be added below it."
2663 (interactive (list 'ut t))
2664 (let* ((header (or header
2665 (message-fetch-field "date")
2667 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2670 ((not gnus-article-date-lapsed-new-header)
2676 (date (if (vectorp header) (mail-header-date header)
2678 (inhibit-point-motion-hooks t)
2683 (article-narrow-to-head)
2684 (when (re-search-forward tdate-regexp nil t)
2685 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2686 date (or (get-text-property (gnus-point-at-bol)
2689 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2691 (when (and date (not (string= date "")))
2692 (goto-char (point-min))
2693 (let ((buffer-read-only nil))
2694 ;; Delete any old Date headers.
2695 (while (re-search-forward date-regexp nil t)
2697 (delete-region (progn (beginning-of-line) (point))
2698 (progn (gnus-article-forward-header)
2700 (delete-region (progn (beginning-of-line) (point))
2701 (progn (gnus-article-forward-header)
2704 (setq pos (point))))
2705 (when (and (not pos)
2706 (re-search-forward tdate-regexp nil t))
2710 (insert (article-make-date-line date (or type 'ut)))
2716 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2717 (put-text-property (match-beginning 1) (1+ (match-end 1))
2718 'original-date date)
2719 (put-text-property (match-beginning 1) (1+ (match-end 1))
2721 (put-text-property (match-beginning 2) (match-end 2)
2724 (defun article-make-date-line (date type)
2725 "Return a DATE line of TYPE."
2726 (unless (memq type '(local ut original user iso8601 lapsed english))
2727 (error "Unknown conversion type: %s" type))
2729 (let ((time (date-to-time date)))
2731 ;; Convert to the local timezone.
2733 (let ((tz (car (current-time-zone time))))
2734 (format "Date: %s %s%02d%02d" (current-time-string time)
2735 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2736 (/ (% (abs tz) 3600) 60))))
2737 ;; Convert to Universal Time.
2740 (current-time-string
2741 (let* ((e (parse-time-string date))
2742 (tm (apply 'encode-time e))
2744 (ls (- (cadr tm) (car (current-time-zone time)))))
2745 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2746 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2749 ;; Get the original date from the article.
2750 ((eq type 'original)
2751 (concat "Date: " (if (string-match "\n+$" date)
2752 (substring date 0 (match-beginning 0))
2754 ;; Let the user define the format.
2756 (let ((format (or (condition-case nil
2757 (with-current-buffer gnus-summary-buffer
2758 gnus-article-time-format)
2760 gnus-article-time-format)))
2761 (if (gnus-functionp format)
2762 (funcall format time)
2763 (concat "Date: " (format-time-string format time)))))
2766 (let ((tz (car (current-time-zone time))))
2769 (format-time-string "%Y%m%dT%H%M%S" time)
2770 (format "%s%02d%02d"
2771 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2772 (/ (% (abs tz) 3600) 60)))))
2773 ;; Do an X-Sent lapsed format.
2775 ;; If the date is seriously mangled, the timezone functions are
2776 ;; liable to bug out, so we ignore all errors.
2777 (let* ((now (current-time))
2778 (real-time (subtract-time now time))
2779 (real-sec (and real-time
2780 (+ (* (float (car real-time)) 65536)
2782 (sec (and real-time (abs real-sec)))
2792 ;; This is a bit convoluted, but basically we go
2793 ;; through the time units for years, weeks, etc,
2794 ;; and divide things to see whether that results
2795 ;; in positive answers.
2798 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2799 ;; The (remaining) seconds are too few to
2800 ;; be divided into this time unit.
2802 ;; It's big enough, so we output it.
2803 (setq sec (- sec (* num (cdr unit))))
2805 (concat (if prev ", " "") (int-to-string
2807 " " (symbol-name (car unit))
2808 (if (> num 1) "s" ""))
2810 article-time-units "")
2811 ;; If dates are odd, then it might appear like the
2812 ;; article was sent in the future.
2815 " in the future"))))))
2816 ;; Display the date in proper English
2818 (let ((dtime (decode-time time)))
2821 (number-to-string (nth 3 dtime))
2822 (let ((digit (% (nth 3 dtime) 10)))
2824 ((memq (nth 3 dtime) '(11 12 13)) "th")
2830 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2832 (number-to-string (nth 5 dtime))
2834 (format "%02d" (nth 2 dtime))
2836 (format "%02d" (nth 1 dtime)))))))
2838 (format "Date: %s (from Gnus)" date))))
2840 (defun article-date-local (&optional highlight)
2841 "Convert the current article date to the local timezone."
2842 (interactive (list t))
2843 (article-date-ut 'local highlight))
2845 (defun article-date-english (&optional highlight)
2846 "Convert the current article date to something that is proper English."
2847 (interactive (list t))
2848 (article-date-ut 'english highlight))
2850 (defun article-date-original (&optional highlight)
2851 "Convert the current article date to what it was originally.
2852 This is only useful if you have used some other date conversion
2853 function and want to see what the date was before converting."
2854 (interactive (list t))
2855 (article-date-ut 'original highlight))
2857 (defun article-date-lapsed (&optional highlight)
2858 "Convert the current article date to time lapsed since it was sent."
2859 (interactive (list t))
2860 (article-date-ut 'lapsed highlight))
2862 (defun article-update-date-lapsed ()
2863 "Function to be run from a timer to update the lapsed time line."
2864 (let (deactivate-mark)
2869 (set-buffer (window-buffer w))
2870 (when (eq major-mode 'gnus-article-mode)
2871 (goto-char (point-min))
2872 (when (re-search-forward "^X-Sent:" nil t)
2873 (article-date-lapsed t))))
2876 (defun gnus-start-date-timer (&optional n)
2877 "Start a timer to update the X-Sent header in the article buffers.
2878 The numerical prefix says how frequently (in seconds) the function
2883 (gnus-stop-date-timer)
2884 (setq article-lapsed-timer
2885 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2887 (defun gnus-stop-date-timer ()
2888 "Stop the X-Sent timer."
2890 (when article-lapsed-timer
2891 (nnheader-cancel-timer article-lapsed-timer)
2892 (setq article-lapsed-timer nil)))
2894 (defun article-date-user (&optional highlight)
2895 "Convert the current article date to the user-defined format.
2896 This format is defined by the `gnus-article-time-format' variable."
2897 (interactive (list t))
2898 (article-date-ut 'user highlight))
2900 (defun article-date-iso8601 (&optional highlight)
2901 "Convert the current article date to ISO8601."
2902 (interactive (list t))
2903 (article-date-ut 'iso8601 highlight))
2905 ;; (defun article-show-all ()
2906 ;; "Show all hidden text in the article buffer."
2909 ;; (let ((buffer-read-only nil))
2910 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2912 (defun article-remove-leading-whitespace ()
2913 "Remove excessive whitespace from all headers."
2917 (let ((buffer-read-only nil))
2918 (article-narrow-to-head)
2919 (goto-char (point-min))
2920 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2921 (delete-region (match-beginning 1) (match-end 1)))))))
2923 (defun article-emphasize (&optional arg)
2924 "Emphasize text according to `gnus-emphasis-alist'."
2925 (interactive (gnus-article-hidden-arg))
2926 (unless (gnus-article-check-hidden-text 'emphasis arg)
2930 (with-current-buffer gnus-summary-buffer
2931 gnus-article-emphasis-alist)
2933 gnus-emphasis-alist))
2934 (buffer-read-only nil)
2935 (props (append '(article-type emphasis)
2936 gnus-hidden-properties))
2937 regexp elem beg invisible visible face)
2940 (while (setq elem (pop alist))
2942 (setq regexp (car elem)
2943 invisible (nth 1 elem)
2944 visible (nth 2 elem)
2946 (while (re-search-forward regexp nil t)
2947 (when (and (match-beginning visible) (match-beginning invisible))
2948 (gnus-article-hide-text
2949 (match-beginning invisible) (match-end invisible) props)
2950 (gnus-article-unhide-text-type
2951 (match-beginning visible) (match-end visible) 'emphasis)
2952 (gnus-put-overlay-excluding-newlines
2953 (match-beginning visible) (match-end visible) 'face face)
2954 (gnus-add-wash-type 'emphasis)
2955 (goto-char (match-end invisible)))))))))
2957 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2958 "Setup newsgroup emphasis alist."
2959 (unless gnus-article-emphasis-alist
2960 (let ((name (and gnus-newsgroup-name
2961 (gnus-group-real-name gnus-newsgroup-name))))
2962 (make-local-variable 'gnus-article-emphasis-alist)
2963 (setq gnus-article-emphasis-alist
2965 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2966 (while (setq elem (pop alist))
2967 (when (and name (string-match (car elem) name))
2969 highlight (copy-sequence (cdr elem)))))
2971 (copy-sequence highlight-words)
2972 (if gnus-newsgroup-name
2973 (copy-sequence (gnus-group-find-parameter
2974 gnus-newsgroup-name 'highlight-words t)))
2975 gnus-emphasis-alist)))))
2978 (defvar gnus-summary-article-menu)
2979 (defvar gnus-summary-post-menu))
2981 ;;; Saving functions.
2983 (defun gnus-article-save (save-buffer file &optional num)
2984 "Save the currently selected article."
2985 (unless gnus-save-all-headers
2986 ;; Remove headers according to `gnus-saved-headers'.
2987 (let ((gnus-visible-headers
2988 (or gnus-saved-headers gnus-visible-headers))
2989 (gnus-article-buffer save-buffer))
2991 (set-buffer save-buffer)
2992 (article-hide-headers 1 t))))
2993 (save-window-excursion
2994 (if (not gnus-default-article-saver)
2995 (error "No default saver is defined")
2996 ;; !!! Magic! The saving functions all save
2997 ;; `gnus-save-article-buffer' (or so they think), but we
2998 ;; bind that variable to our save-buffer.
2999 (set-buffer gnus-article-buffer)
3000 (let* ((gnus-save-article-buffer save-buffer)
3003 ((not gnus-prompt-before-saving) 'default)
3004 ((eq gnus-prompt-before-saving 'always) nil)
3006 (gnus-number-of-articles-to-be-saved
3007 (when (eq gnus-prompt-before-saving t)
3009 (set-buffer gnus-article-current-summary)
3010 (funcall gnus-default-article-saver filename)))))
3012 (defun gnus-read-save-file-name (prompt &optional filename
3013 function group headers variable)
3015 (funcall function group headers (symbol-value variable)))
3020 ((eq filename 'default)
3026 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3029 (if (and gnus-number-of-articles-to-be-saved
3030 (> gnus-number-of-articles-to-be-saved 1))
3031 (format "these %d articles"
3032 gnus-number-of-articles-to-be-saved)
3035 ;; Let the split methods have their say.
3037 ;; No split name was found.
3040 (concat prompt " (default "
3041 (file-name-nondirectory default-name) ") ")
3042 (file-name-directory default-name)
3044 ;; A single group name is returned.
3045 ((stringp split-name)
3047 (funcall function split-name headers
3048 (symbol-value variable)))
3050 (concat prompt " (default "
3051 (file-name-nondirectory default-name) ") ")
3052 (file-name-directory default-name)
3054 ;; A single split name was found
3055 ((= 1 (length split-name))
3056 (let* ((name (expand-file-name
3058 gnus-article-save-directory))
3059 (dir (cond ((file-directory-p name)
3060 (file-name-as-directory name))
3061 ((file-exists-p name) name)
3062 (t gnus-article-save-directory))))
3064 (concat prompt " (default " name ") ")
3066 ;; A list of splits was found.
3068 (setq split-name (nreverse split-name))
3070 (let ((file-name-history
3071 (nconc split-name file-name-history)))
3075 (concat prompt " (`M-p' for defaults) ")
3076 gnus-article-save-directory
3078 gnus-article-save-directory)))
3079 (car (push result file-name-history)))))))
3080 ;; Create the directory.
3081 (gnus-make-directory (file-name-directory file))
3082 ;; If we have read a directory, we append the default file name.
3083 (when (file-directory-p file)
3084 (setq file (expand-file-name (file-name-nondirectory
3086 (file-name-as-directory file))))
3087 ;; Possibly translate some characters.
3088 (nnheader-translate-file-chars file))))))
3089 (gnus-make-directory (file-name-directory result))
3090 (set variable result)))
3092 (defun gnus-article-archive-name (group)
3093 "Return the first instance of an \"Archive-name\" in the current buffer."
3094 (let ((case-fold-search t))
3095 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3096 (nnheader-concat gnus-article-save-directory
3097 (match-string 1)))))
3099 (defun gnus-article-nndoc-name (group)
3100 "If GROUP is an nndoc group, return the name of the parent group."
3101 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3102 (gnus-group-get-parameter group 'save-article-group)))
3104 (defun gnus-summary-save-in-rmail (&optional filename)
3105 "Append this article to Rmail file.
3106 Optional argument FILENAME specifies file name.
3107 Directory to save to is default to `gnus-article-save-directory'."
3108 (setq filename (gnus-read-save-file-name
3109 "Save %s in rmail file:" filename
3110 gnus-rmail-save-name gnus-newsgroup-name
3111 gnus-current-headers 'gnus-newsgroup-last-rmail))
3112 (gnus-eval-in-buffer-window gnus-save-article-buffer
3116 (gnus-output-to-rmail filename))))
3119 (defun gnus-summary-save-in-mail (&optional filename)
3120 "Append this article to Unix mail file.
3121 Optional argument FILENAME specifies file name.
3122 Directory to save to is default to `gnus-article-save-directory'."
3123 (setq filename (gnus-read-save-file-name
3124 "Save %s in Unix mail file:" filename
3125 gnus-mail-save-name gnus-newsgroup-name
3126 gnus-current-headers 'gnus-newsgroup-last-mail))
3127 (gnus-eval-in-buffer-window gnus-save-article-buffer
3131 (if (and (file-readable-p filename)
3132 (file-regular-p filename)
3133 (mail-file-babyl-p filename))
3134 (rmail-output-to-rmail-file filename t)
3135 (gnus-output-to-mail filename)))))
3138 (defun gnus-summary-save-in-file (&optional filename overwrite)
3139 "Append this article to file.
3140 Optional argument FILENAME specifies file name.
3141 Directory to save to is default to `gnus-article-save-directory'."
3142 (setq filename (gnus-read-save-file-name
3143 "Save %s in file:" filename
3144 gnus-file-save-name gnus-newsgroup-name
3145 gnus-current-headers 'gnus-newsgroup-last-file))
3146 (gnus-eval-in-buffer-window gnus-save-article-buffer
3150 (when (and overwrite
3151 (file-exists-p filename))
3152 (delete-file filename))
3153 (gnus-output-to-file filename))))
3156 (defun gnus-summary-write-to-file (&optional filename)
3157 "Write this article to a file, overwriting it if the file exists.
3158 Optional argument FILENAME specifies file name.
3159 The directory to save in defaults to `gnus-article-save-directory'."
3160 (gnus-summary-save-in-file nil t))
3162 (defun gnus-summary-save-body-in-file (&optional filename)
3163 "Append this article body to a file.
3164 Optional argument FILENAME specifies file name.
3165 The directory to save in defaults to `gnus-article-save-directory'."
3166 (setq filename (gnus-read-save-file-name
3167 "Save %s body in file:" filename
3168 gnus-file-save-name gnus-newsgroup-name
3169 gnus-current-headers 'gnus-newsgroup-last-file))
3170 (gnus-eval-in-buffer-window gnus-save-article-buffer
3174 (when (article-goto-body)
3175 (narrow-to-region (point) (point-max)))
3176 (gnus-output-to-file filename))))
3179 (defun gnus-summary-save-in-pipe (&optional command)
3180 "Pipe this article to subprocess."
3182 (cond ((and (eq command 'default)
3183 gnus-last-shell-command)
3184 gnus-last-shell-command)
3189 "Shell command on %s: "
3190 (if (and gnus-number-of-articles-to-be-saved
3191 (> gnus-number-of-articles-to-be-saved 1))
3192 (format "these %d articles"
3193 gnus-number-of-articles-to-be-saved)
3195 gnus-last-shell-command))))
3196 (when (string-equal command "")
3197 (if gnus-last-shell-command
3198 (setq command gnus-last-shell-command)
3199 (error "A command is required")))
3200 (gnus-eval-in-buffer-window gnus-article-buffer
3203 (shell-command-on-region (point-min) (point-max) command nil)))
3204 (setq gnus-last-shell-command command))
3206 (defun gnus-summary-pipe-to-muttprint (&optional command)
3207 "Pipe this article to muttprint."
3208 (setq command (read-string
3209 "Print using command: " gnus-summary-muttprint-program
3210 nil gnus-summary-muttprint-program))
3211 (gnus-summary-save-in-pipe command))
3213 ;;; Article file names when saving.
3215 (defun gnus-capitalize-newsgroup (newsgroup)
3216 "Capitalize NEWSGROUP name."
3217 (when (not (zerop (length newsgroup)))
3218 (concat (char-to-string (upcase (aref newsgroup 0)))
3219 (substring newsgroup 1))))
3221 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3222 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3223 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3224 Otherwise, it is like ~/News/news/group/num."
3227 (concat (if (gnus-use-long-file-name 'not-save)
3228 (gnus-capitalize-newsgroup newsgroup)
3229 (gnus-newsgroup-directory-form newsgroup))
3230 "/" (int-to-string (mail-header-number headers)))
3231 gnus-article-save-directory)))
3233 (string-equal (file-name-directory default)
3234 (file-name-directory last-file))
3235 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3237 (or last-file default))))
3239 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3240 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3241 If variable `gnus-use-long-file-name' is non-nil, it is
3242 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3245 (concat (if (gnus-use-long-file-name 'not-save)
3247 (gnus-newsgroup-directory-form newsgroup))
3248 "/" (int-to-string (mail-header-number headers)))
3249 gnus-article-save-directory)))
3251 (string-equal (file-name-directory default)
3252 (file-name-directory last-file))
3253 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3255 (or last-file default))))
3257 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3258 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3259 If variable `gnus-use-long-file-name' is non-nil, it is
3260 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3263 (if (gnus-use-long-file-name 'not-save)
3266 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3268 gnus-article-save-directory)))
3270 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3271 "Generate file name from sender."
3272 (let ((from (mail-header-from headers)))
3274 (if (and from (string-match "\\([^ <]+\\)@" from))
3275 (match-string 1 from)
3277 gnus-article-save-directory)))
3279 (defun article-verify-x-pgp-sig ()
3282 (if (gnus-buffer-live-p gnus-original-article-buffer)
3283 (let ((sig (with-current-buffer gnus-original-article-buffer
3284 (gnus-fetch-field "X-PGP-Sig")))
3288 (mml2015-clear-verify-function))
3290 (insert-buffer gnus-original-article-buffer)
3291 (setq items (split-string sig))
3292 (message-narrow-to-head)
3293 (let ((inhibit-point-motion-hooks t)
3294 (case-fold-search t))
3295 ;; Don't verify multiple headers.
3296 (setq headers (mapconcat (lambda (header)
3298 (mail-fetch-field header) "\n"))
3299 (split-string (nth 1 items) ",") "")))
3300 (delete-region (point-min) (point-max))
3301 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3302 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3307 (if (looking-at "^-")
3310 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3311 (insert "Version: " (car items) "\n\n")
3312 (insert (mapconcat 'identity (cddr items) "\n"))
3313 (insert "\n-----END PGP SIGNATURE-----\n")
3314 (let ((mm-security-handle (list (format "multipart/signed"))))
3315 (mml2015-clean-buffer)
3316 (let ((coding-system-for-write (or gnus-newsgroup-charset
3318 (funcall (mml2015-clear-verify-function)))
3320 (or (mm-handle-multipart-ctl-parameter
3321 mm-security-handle 'gnus-details)
3322 (mm-handle-multipart-ctl-parameter
3323 mm-security-handle 'gnus-info)))))
3325 (let (buffer-read-only bface eface)
3327 (message-narrow-to-head)
3328 (goto-char (point-max))
3330 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3331 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3332 (message-remove-header "X-Gnus-PGP-Verify")
3333 (if (re-search-forward "^X-PGP-Sig:" nil t)
3335 (goto-char (point-max)))
3336 (narrow-to-region (point) (point))
3337 (insert "X-Gnus-PGP-Verify: " info "\n")
3338 (goto-char (point-min))
3341 (if (not (looking-at "^[ \t]"))
3345 (goto-char (point-min))
3346 (when (looking-at "\\([^:]+\\): *")
3347 (put-text-property (match-beginning 1) (1+ (match-end 1))
3349 (put-text-property (match-end 0) (point-max)
3350 'face eface)))))))))
3352 (defun article-verify-cancel-lock ()
3353 "Verify Cancel-Lock header."
3355 (if (gnus-buffer-live-p gnus-original-article-buffer)
3356 (canlock-verify gnus-original-article-buffer)))
3363 (setq afunc (car func)
3366 gfunc (intern (format "gnus-%s" func))))
3368 (when (fboundp afunc)
3369 `(lambda (&optional interactive &rest args)
3370 ,(documentation afunc t)
3371 (interactive (list t))
3373 (set-buffer gnus-article-buffer)
3375 (call-interactively ',afunc)
3376 (apply ',afunc args))))))))
3377 '(article-hide-headers
3378 article-verify-x-pgp-sig
3379 article-verify-cancel-lock
3380 article-hide-boring-headers
3381 article-treat-overstrike
3382 article-fill-long-lines
3383 article-capitalize-sentences
3385 article-remove-leading-whitespace
3386 article-display-x-face
3387 article-display-face
3388 article-de-quoted-unreadable
3389 article-de-base64-unreadable
3392 article-unsplit-urls
3393 article-hide-list-identifiers
3394 article-strip-banner
3397 article-hide-signature
3398 article-strip-headers-in-body
3399 article-remove-trailing-blank-lines
3400 article-strip-leading-blank-lines
3401 article-strip-multiple-blank-lines
3402 article-strip-leading-space
3403 article-strip-trailing-space
3404 article-strip-blank-lines
3405 article-strip-all-blank-lines
3407 article-date-english
3408 article-date-iso8601
3409 article-date-original
3411 article-decode-mime-words
3412 article-decode-charset
3413 article-decode-encoded-words
3417 article-treat-dumbquotes
3418 article-normalize-headers
3419 ;; (article-show-all . gnus-article-show-all-headers)
3423 ;;; Gnus article mode
3426 (put 'gnus-article-mode 'mode-class 'special)
3428 (set-keymap-parent gnus-article-mode-map widget-keymap)
3430 (gnus-define-keys gnus-article-mode-map
3431 " " gnus-article-goto-next-page
3432 "\177" gnus-article-goto-prev-page
3433 [delete] gnus-article-goto-prev-page
3434 [backspace] gnus-article-goto-prev-page
3435 "\C-c^" gnus-article-refer-article
3436 "h" gnus-article-show-summary
3437 "s" gnus-article-show-summary
3438 "\C-c\C-m" gnus-article-mail
3439 "?" gnus-article-describe-briefly
3440 "e" gnus-summary-edit-article
3441 "<" beginning-of-buffer
3443 "\C-c\C-i" gnus-info-find-node
3445 "R" gnus-article-reply-with-original
3446 "F" gnus-article-followup-with-original
3447 "\C-hk" gnus-article-describe-key
3448 "\C-hc" gnus-article-describe-key-briefly
3450 "\C-d" gnus-article-read-summary-keys
3451 "\M-*" gnus-article-read-summary-keys
3452 "\M-#" gnus-article-read-summary-keys
3453 "\M-^" gnus-article-read-summary-keys
3454 "\M-g" gnus-article-read-summary-keys)
3456 (substitute-key-definition
3457 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3459 (defun gnus-article-make-menu-bar ()
3460 (unless (boundp 'gnus-article-commands-menu)
3461 (gnus-summary-make-menu-bar))
3462 (gnus-turn-off-edit-menu 'article)
3463 (unless (boundp 'gnus-article-article-menu)
3465 gnus-article-article-menu gnus-article-mode-map ""
3467 ["Scroll forwards" gnus-article-goto-next-page t]
3468 ["Scroll backwards" gnus-article-goto-prev-page t]
3469 ["Show summary" gnus-article-show-summary t]
3470 ["Fetch Message-ID at point" gnus-article-refer-article t]
3471 ["Mail to address at point" gnus-article-mail t]
3472 ["Send a bug report" gnus-bug t]))
3475 gnus-article-treatment-menu gnus-article-mode-map ""
3476 ;; Fixme: this should use :active (and maybe :visible).
3478 ["Hide headers" gnus-article-hide-headers t]
3479 ["Hide signature" gnus-article-hide-signature t]
3480 ["Hide citation" gnus-article-hide-citation t]
3481 ["Treat overstrike" gnus-article-treat-overstrike t]
3482 ["Remove carriage return" gnus-article-remove-cr t]
3483 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3484 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3485 ["Remove base64" gnus-article-de-base64-unreadable t]
3486 ["Treat html" gnus-article-wash-html t]
3487 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3488 ["Decode HZ" gnus-article-decode-HZ t]))
3490 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3492 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3494 (gnus-run-hooks 'gnus-article-menu-hook)))
3496 (defun gnus-article-mode ()
3497 "Major mode for displaying an article.
3499 All normal editing commands are switched off.
3501 The following commands are available in addition to all summary mode
3503 \\<gnus-article-mode-map>
3504 \\[gnus-article-next-page]\t Scroll the article one page forwards
3505 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3506 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3507 \\[gnus-article-show-summary]\t Display the summary buffer
3508 \\[gnus-article-mail]\t Send a reply to the address near point
3509 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3510 \\[gnus-info-find-node]\t Go to the Gnus info node"
3512 (gnus-simplify-mode-line)
3513 (setq mode-name "Article")
3514 (setq major-mode 'gnus-article-mode)
3515 (make-local-variable 'minor-mode-alist)
3516 (use-local-map gnus-article-mode-map)
3517 (when (gnus-visual-p 'article-menu 'menu)
3518 (gnus-article-make-menu-bar)
3519 (when gnus-summary-tool-bar-map
3520 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3521 (gnus-update-format-specifications nil 'article-mode)
3522 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3523 (make-local-variable 'gnus-page-broken)
3524 (make-local-variable 'gnus-button-marker-list)
3525 (make-local-variable 'gnus-article-current-summary)
3526 (make-local-variable 'gnus-article-mime-handles)
3527 (make-local-variable 'gnus-article-decoded-p)
3528 (make-local-variable 'gnus-article-mime-handle-alist)
3529 (make-local-variable 'gnus-article-wash-types)
3530 (make-local-variable 'gnus-article-image-alist)
3531 (make-local-variable 'gnus-article-charset)
3532 (make-local-variable 'gnus-article-ignored-charsets)
3533 (gnus-set-default-directory)
3534 (buffer-disable-undo)
3535 (setq buffer-read-only t)
3536 (set-syntax-table gnus-article-mode-syntax-table)
3537 (mm-enable-multibyte)
3538 (gnus-run-hooks 'gnus-article-mode-hook))
3540 (defun gnus-article-setup-buffer ()
3541 "Initialize the article buffer."
3542 (let* ((name (if gnus-single-article-buffer "*Article*"
3543 (concat "*Article " gnus-newsgroup-name "*")))
3545 (progn (string-match "\\*Article" name)
3546 (concat " *Original Article"
3547 (substring name (match-end 0))))))
3548 (setq gnus-article-buffer name)
3549 (setq gnus-original-article-buffer original)
3550 (setq gnus-article-mime-handle-alist nil)
3551 ;; This might be a variable local to the summary buffer.
3552 (unless gnus-single-article-buffer
3554 (set-buffer gnus-summary-buffer)
3555 (setq gnus-article-buffer name)
3556 (setq gnus-original-article-buffer original)
3557 (gnus-set-global-variables)))
3558 (gnus-article-setup-highlight-words)
3559 ;; Init original article buffer.
3561 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3562 (mm-enable-multibyte)
3563 (setq major-mode 'gnus-original-article-mode)
3564 (make-local-variable 'gnus-original-article))
3565 (if (get-buffer name)
3568 (when (and gnus-article-edit-mode
3571 (y-or-n-p "Article mode edit in progress; discard? ")))
3572 (error "Action aborted"))
3573 (set (make-local-variable 'gnus-article-edit-mode) nil)
3574 (when gnus-article-mime-handles
3575 (mm-destroy-parts gnus-article-mime-handles)
3576 (setq gnus-article-mime-handles nil))
3577 ;; Set it to nil in article-buffer!
3578 (setq gnus-article-mime-handle-alist nil)
3579 (buffer-disable-undo)
3580 (setq buffer-read-only t)
3581 ;; This list just keeps growing if we don't reset it.
3582 (setq gnus-button-marker-list nil)
3583 (unless (eq major-mode 'gnus-article-mode)
3584 (gnus-article-mode))
3587 (set-buffer (gnus-get-buffer-create name))
3589 (make-local-variable 'gnus-summary-buffer)
3590 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3591 (current-buffer)))))
3593 ;; Set article window start at LINE, where LINE is the number of lines
3594 ;; from the head of the article.
3595 (defun gnus-article-set-window-start (&optional line)
3597 (gnus-get-buffer-window gnus-article-buffer t)
3599 (set-buffer gnus-article-buffer)
3600 (goto-char (point-min))
3603 (gnus-message 6 "Moved to bookmark")
3604 (search-forward "\n\n" nil t)
3608 (defun gnus-article-prepare (article &optional all-headers header)
3609 "Prepare ARTICLE in article mode buffer.
3610 ARTICLE should either be an article number or a Message-ID.
3611 If ARTICLE is an id, HEADER should be the article headers.
3612 If ALL-HEADERS is non-nil, no headers are hidden."
3614 ;; Make sure we start in a summary buffer.
3615 (unless (eq major-mode 'gnus-summary-mode)
3616 (set-buffer gnus-summary-buffer))
3617 (setq gnus-summary-buffer (current-buffer))
3618 (let* ((gnus-article (if header (mail-header-number header) article))
3619 (summary-buffer (current-buffer))
3620 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3621 (group gnus-newsgroup-name)
3624 (gnus-article-setup-buffer)
3625 (set-buffer gnus-article-buffer)
3626 ;; Deactivate active regions.
3627 (when (and (boundp 'transient-mark-mode)
3628 transient-mark-mode)
3629 (setq mark-active nil))
3630 (if (not (setq result (let ((buffer-read-only nil))
3631 (gnus-request-article-this-buffer
3633 ;; There is no such article.
3635 (when (and (numberp article)
3636 (not (memq article gnus-newsgroup-sparse)))
3637 (setq gnus-article-current
3638 (cons gnus-newsgroup-name article))
3639 (set-buffer gnus-summary-buffer)
3640 (setq gnus-current-article article)
3641 (if (and (memq article gnus-newsgroup-undownloaded)
3642 (not (gnus-online (gnus-find-method-for-group
3643 gnus-newsgroup-name))))
3645 (gnus-summary-set-agent-mark article)
3646 (message "Message marked for downloading"))
3647 (gnus-summary-mark-article article gnus-canceled-mark)
3648 (unless (memq article gnus-newsgroup-sparse)
3649 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3650 (if (or (eq result 'pseudo)
3651 (eq result 'nneething))
3654 (set-buffer summary-buffer)
3655 (push article gnus-newsgroup-history)
3656 (setq gnus-last-article gnus-current-article
3657 gnus-current-article 0
3658 gnus-current-headers nil
3659 gnus-article-current nil)
3660 (if (eq result 'nneething)
3661 (gnus-configure-windows 'summary)
3662 (gnus-configure-windows 'article))
3663 (gnus-set-global-variables))
3664 (let ((gnus-article-mime-handle-alist-1
3665 gnus-article-mime-handle-alist))
3666 (gnus-set-mode-line 'article)))
3667 ;; The result from the `request' was an actual article -
3668 ;; or at least some text that is now displayed in the
3670 (when (and (numberp article)
3671 (not (eq article gnus-current-article)))
3672 ;; Seems like a new article has been selected.
3673 ;; `gnus-current-article' must be an article number.
3675 (set-buffer summary-buffer)
3676 (push article gnus-newsgroup-history)
3677 (setq gnus-last-article gnus-current-article
3678 gnus-current-article article
3679 gnus-current-headers
3680 (gnus-summary-article-header gnus-current-article)
3681 gnus-article-current
3682 (cons gnus-newsgroup-name gnus-current-article))
3683 (unless (vectorp gnus-current-headers)
3684 (setq gnus-current-headers nil))
3685 (gnus-summary-goto-subject gnus-current-article)
3686 (when (gnus-summary-show-thread)
3687 ;; If the summary buffer really was folded, the
3688 ;; previous goto may not actually have gone to
3689 ;; the right article, but the thread root instead.
3691 (gnus-summary-goto-subject gnus-current-article))
3692 (gnus-run-hooks 'gnus-mark-article-hook)
3693 (gnus-set-mode-line 'summary)
3694 (when (gnus-visual-p 'article-highlight 'highlight)
3695 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3696 ;; Set the global newsgroup variables here.
3697 (gnus-set-global-variables)
3698 (setq gnus-have-all-headers
3699 (or all-headers gnus-show-all-headers))))
3701 (gnus-configure-windows 'article))
3702 (when (or (numberp article)
3704 (gnus-article-prepare-display)
3706 (goto-char (point-min))
3707 (setq gnus-page-broken
3708 (when gnus-break-pages
3709 (gnus-narrow-to-page)
3711 (let ((gnus-article-mime-handle-alist-1
3712 gnus-article-mime-handle-alist))
3713 (gnus-set-mode-line 'article))
3717 (set-window-point (get-buffer-window (current-buffer)) (point))
3718 (gnus-configure-windows 'article)
3722 (defun gnus-article-prepare-display ()
3723 "Make the current buffer look like a nice article."
3724 ;; Hooks for getting information from the article.
3725 ;; This hook must be called before being narrowed.
3726 (let ((gnus-article-buffer (current-buffer))
3728 (unless (eq major-mode 'gnus-article-mode)
3729 (gnus-article-mode))
3730 (setq buffer-read-only nil
3731 gnus-article-wash-types nil
3732 gnus-article-image-alist nil)
3733 (gnus-run-hooks 'gnus-tmp-internal-hook)
3734 (when gnus-display-mime-function
3735 (funcall gnus-display-mime-function))
3736 (gnus-run-hooks 'gnus-article-prepare-hook)))
3739 ;;; Gnus MIME viewing functions
3742 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3743 "Format of the MIME buttons.
3745 Valid specifiers include:
3747 %T MIME type, along with additional info
3748 %n The `name' parameter
3749 %d The description, if any
3750 %l The length of the encoded part
3751 %p The part identifier number
3752 %e Dots if the part isn't displayed
3754 General format specifiers can also be used. See Info node
3755 `(gnus)Formatting Variables'.")
3757 (defvar gnus-mime-button-line-format-alist
3758 '((?t gnus-tmp-type ?s)
3759 (?T gnus-tmp-type-long ?s)
3760 (?n gnus-tmp-name ?s)
3761 (?d gnus-tmp-description ?s)
3763 (?l gnus-tmp-length ?d)
3764 (?e gnus-tmp-dots ?s)))
3766 (defvar gnus-mime-button-commands
3767 '((gnus-article-press-button "\r" "Toggle Display")
3768 (gnus-mime-view-part "v" "View Interactively...")
3769 (gnus-mime-view-part-as-type "t" "View As Type...")
3770 (gnus-mime-view-part-as-charset "C" "View As charset...")
3771 (gnus-mime-save-part "o" "Save...")
3772 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3773 (gnus-mime-delete-part "d" "Delete part")
3774 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3775 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3776 (gnus-mime-view-part-internally "E" "View Internally")
3777 (gnus-mime-view-part-externally "e" "View Externally")
3778 (gnus-mime-print-part "p" "Print")
3779 (gnus-mime-pipe-part "|" "Pipe To Command...")
3780 (gnus-mime-action-on-part "." "Take action on the part...")))
3782 (defun gnus-article-mime-part-status ()
3783 (if gnus-article-mime-handle-alist-1
3784 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3786 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3789 (defvar gnus-mime-button-map
3790 (let ((map (make-sparse-keymap)))
3791 (unless (>= (string-to-number emacs-version) 21)
3792 ;; XEmacs doesn't care.
3793 (set-keymap-parent map gnus-article-mode-map))
3794 (define-key map gnus-mouse-2 'gnus-article-push-button)
3795 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3796 (dolist (c gnus-mime-button-commands)
3797 (define-key map (cadr c) (car c)))
3800 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3802 ,@(mapcar (lambda (c)
3803 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
3806 (define-compiler-macro popup-menu (&whole form
3807 menu &optional position prefix)
3808 (if (and (fboundp 'popup-menu)
3809 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3811 ;; Gnus is probably running under Emacs 20.
3812 `(let* ((menu (cdr ,menu))
3813 (response (x-popup-menu
3815 (cons "" (mapcar (lambda (c)
3816 (cons (caddr c) (car c)))
3819 (call-interactively (nth 3 (assq response menu))))))))
3821 (defun gnus-mime-button-menu (event prefix)
3822 "Construct a context-sensitive menu of MIME commands."
3823 (interactive "e\nP")
3824 (save-window-excursion
3825 (let ((pos (event-start event)))
3826 (select-window (posn-window pos))
3827 (goto-char (posn-point pos))
3828 (gnus-article-check-buffer)
3829 (popup-menu gnus-mime-button-menu nil prefix))))
3831 (defun gnus-mime-view-all-parts (&optional handles)
3832 "View all the MIME parts."
3834 (save-current-buffer
3835 (set-buffer gnus-article-buffer)
3836 (let ((handles (or handles gnus-article-mime-handles))
3837 (mail-parse-charset gnus-newsgroup-charset)
3838 (mail-parse-ignored-charsets
3839 (with-current-buffer gnus-summary-buffer
3840 gnus-newsgroup-ignored-charsets)))
3842 (mm-remove-parts handles)
3843 (goto-char (point-min))
3844 (or (search-forward "\n\n") (goto-char (point-max)))
3845 (let (buffer-read-only)
3846 (delete-region (point) (point-max))
3847 (mm-display-parts handles))))))
3849 (defun gnus-mime-save-part-and-strip ()
3850 "Save the MIME part under point then replace it with an external body."
3852 (gnus-article-check-buffer)
3853 (let* ((data (get-text-property (point) 'gnus-data))
3855 (handles gnus-article-mime-handles))
3856 (if (mm-multiple-handles gnus-article-mime-handles)
3857 (error "This function is not implemented"))
3858 (setq file (and data (mm-save-part data)))
3860 (with-current-buffer (mm-handle-buffer data)
3862 (insert "Content-Type: " (mm-handle-media-type data))
3863 (mml-insert-parameter-string (cdr (mm-handle-type data))
3866 (insert "Content-ID: " (message-make-message-id) "\n")
3867 (insert "Content-Transfer-Encoding: binary\n")
3870 (cdr (mm-make-handle nil
3871 `("message/external-body"
3872 (access-type . "LOCAL-FILE")
3874 (set-buffer gnus-summary-buffer)
3875 (gnus-article-edit-article
3878 (let ((mail-parse-charset (or gnus-article-charset
3879 ',gnus-newsgroup-charset))
3880 (mail-parse-ignored-charsets
3881 (or gnus-article-ignored-charsets
3882 ',gnus-newsgroup-ignored-charsets))
3883 (mbl mml-buffer-list))
3884 (setq mml-buffer-list nil)
3885 (insert-buffer gnus-original-article-buffer)
3886 (mime-to-mml ',handles)
3887 (setq gnus-article-mime-handles nil)
3888 (let ((mbl1 mml-buffer-list))
3889 (setq mml-buffer-list mbl)
3890 (set (make-local-variable 'mml-buffer-list) mbl1))
3891 ;; LOCAL argument of add-hook differs between GNU Emacs
3892 ;; and XEmacs. make-local-hook makes sure they are local.
3893 (make-local-hook 'kill-buffer-hook)
3894 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3895 `(lambda (no-highlight)
3896 (let ((mail-parse-charset (or gnus-article-charset
3897 ',gnus-newsgroup-charset))
3898 (message-options message-options)
3899 (message-options-set-recipient)
3900 (mail-parse-ignored-charsets
3901 (or gnus-article-ignored-charsets
3902 ',gnus-newsgroup-ignored-charsets)))
3904 (mml-destroy-buffers)
3905 (remove-hook 'kill-buffer-hook
3906 'mml-destroy-buffers t)
3907 (kill-local-variable 'mml-buffer-list))
3908 (gnus-summary-edit-article-done
3909 ,(or (mail-header-references gnus-current-headers) "")
3910 ,(gnus-group-read-only-p)
3911 ,gnus-summary-buffer no-highlight))))))
3913 (defun gnus-mime-delete-part ()
3914 "Delete the MIME part under point.
3915 Replace it with some information about the removed part."
3917 (gnus-article-check-buffer)
3918 (let* ((data (get-text-property (point) 'gnus-data))
3919 (handles gnus-article-mime-handles)
3923 (mail-decode-encoded-word-string (or (mm-handle-description data)
3926 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
3928 (type (mm-handle-media-type data)))
3929 (if (mm-multiple-handles gnus-article-mime-handles)
3930 (error "This function is not implemented"))
3931 (with-current-buffer (mm-handle-buffer data)
3932 (let ((bsize (format "%s" (buffer-size))))
3936 "<#part type=text/plain nofile=yes disposition=attachment"
3937 " description=\"Deleted attachment (" bsize " Byte)\">"
3939 "| The following attachment has been deleted:\n"
3941 "| Type: " type "\n"
3942 "| Filename: " filename "\n"
3943 "| Size (encoded): " bsize " Byte\n"
3944 "| Description: " description "\n"
3948 (cdr (mm-make-handle nil `("text/plain"))))))
3949 (set-buffer gnus-summary-buffer)
3950 ;; FIXME: maybe some of the following code (borrowed from
3951 ;; `gnus-mime-save-part-and-strip') isn't necessary?
3952 (gnus-article-edit-article
3955 (let ((mail-parse-charset (or gnus-article-charset
3956 ',gnus-newsgroup-charset))
3957 (mail-parse-ignored-charsets
3958 (or gnus-article-ignored-charsets
3959 ',gnus-newsgroup-ignored-charsets))
3960 (mbl mml-buffer-list))
3961 (setq mml-buffer-list nil)
3962 (insert-buffer gnus-original-article-buffer)
3963 (mime-to-mml ',handles)
3964 (setq gnus-article-mime-handles nil)
3965 (let ((mbl1 mml-buffer-list))
3966 (setq mml-buffer-list mbl)
3967 (set (make-local-variable 'mml-buffer-list) mbl1))
3968 ;; LOCAL argument of add-hook differs between GNU Emacs
3969 ;; and XEmacs. make-local-hook makes sure they are local.
3970 (make-local-hook 'kill-buffer-hook)
3971 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3972 `(lambda (no-highlight)
3973 (let ((mail-parse-charset (or gnus-article-charset
3974 ',gnus-newsgroup-charset))
3975 (message-options message-options)
3976 (message-options-set-recipient)
3977 (mail-parse-ignored-charsets
3978 (or gnus-article-ignored-charsets
3979 ',gnus-newsgroup-ignored-charsets)))
3981 (mml-destroy-buffers)
3982 (remove-hook 'kill-buffer-hook
3983 'mml-destroy-buffers t)
3984 (kill-local-variable 'mml-buffer-list))
3985 (gnus-summary-edit-article-done
3986 ,(or (mail-header-references gnus-current-headers) "")
3987 ,(gnus-group-read-only-p)
3988 ,gnus-summary-buffer no-highlight))))
3989 ;; Not in `gnus-mime-save-part-and-strip':
3990 (gnus-article-edit-done)
3991 (gnus-summary-expand-window)
3992 (gnus-summary-show-article))
3994 (defun gnus-mime-save-part ()
3995 "Save the MIME part under point."
3997 (gnus-article-check-buffer)
3998 (let ((data (get-text-property (point) 'gnus-data)))
4000 (mm-save-part data))))
4002 (defun gnus-mime-pipe-part ()
4003 "Pipe the MIME part under point to a process."
4005 (gnus-article-check-buffer)
4006 (let ((data (get-text-property (point) 'gnus-data)))
4008 (mm-pipe-part data))))
4010 (defun gnus-mime-view-part ()
4011 "Interactively choose a viewing method for the MIME part under point."
4013 (gnus-article-check-buffer)
4014 (let ((data (get-text-property (point) 'gnus-data)))
4016 (setq gnus-article-mime-handles
4018 gnus-article-mime-handles (setq data (copy-sequence data))))
4019 (mm-interactively-view-part data))))
4021 (defun gnus-mime-view-part-as-type-internal ()
4022 (gnus-article-check-buffer)
4023 (let* ((name (mail-content-type-get
4024 (mm-handle-type (get-text-property (point) 'gnus-data))
4026 (def-type (and name (mm-default-file-encoding name))))
4027 (and def-type (cons def-type 0))))
4029 (defun gnus-mime-view-part-as-type (&optional mime-type)
4030 "Choose a MIME media type, and view the part as such."
4033 (setq mime-type (completing-read
4034 "View as MIME type: "
4035 (mapcar #'list (mailcap-mime-types))
4037 (gnus-mime-view-part-as-type-internal))))
4038 (gnus-article-check-buffer)
4039 (let ((handle (get-text-property (point) 'gnus-data)))
4042 (mm-make-handle (mm-handle-buffer handle)
4043 (cons mime-type (cdr (mm-handle-type handle)))
4044 (mm-handle-encoding handle)
4045 (mm-handle-undisplayer handle)
4046 (mm-handle-disposition handle)
4047 (mm-handle-description handle)
4049 (mm-handle-id handle)))
4050 (setq gnus-article-mime-handles
4051 (mm-merge-handles gnus-article-mime-handles handle))
4052 (gnus-mm-display-part handle))))
4055 (require 'jka-compr))
4057 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4058 ;; emacs can do that itself.
4060 (defun gnus-mime-jka-compr-maybe-uncompress ()
4061 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4062 The uncompress method used is derived from `buffer-file-name'."
4063 (when (and (fboundp 'jka-compr-installed-p)
4064 (jka-compr-installed-p))
4065 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4067 (let ((basename (file-name-nondirectory buffer-file-name))
4068 (args (jka-compr-info-uncompress-args info))
4069 (prog (jka-compr-info-uncompress-program info))
4070 (message (jka-compr-info-uncompress-message info))
4071 (err-file (jka-compr-make-temp-name)))
4073 (message "%s %s..." message basename))
4075 (unless (memq (apply 'call-process-region
4076 (point-min) (point-max)
4078 t (list t err-file) nil
4080 jka-compr-acceptable-retval-list)
4081 (jka-compr-error prog args basename message err-file))
4082 (jka-compr-delete-temp-file err-file)))))))
4084 (defun gnus-mime-copy-part (&optional handle)
4085 "Put the MIME part under point into a new buffer.
4086 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4089 (gnus-article-check-buffer)
4090 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4091 (contents (and handle (mm-get-part handle)))
4093 (file-name-nondirectory
4095 (mail-content-type-get (mm-handle-type handle) 'name)
4096 (mail-content-type-get (mm-handle-disposition handle)
4099 (buffer (and base (generate-new-buffer base))))
4101 (switch-to-buffer buffer)
4103 ;; We do it this way to make `normal-mode' set the appropriate mode.
4106 (setq buffer-file-name (expand-file-name base))
4107 (gnus-mime-jka-compr-maybe-uncompress)
4109 (setq buffer-file-name nil))
4110 (goto-char (point-min)))))
4112 (defun gnus-mime-print-part (&optional handle filename)
4113 "Print the MIME part under point."
4114 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4115 (gnus-article-check-buffer)
4116 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4117 (contents (and handle (mm-get-part handle)))
4118 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4119 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4124 (mm-save-part-to-file handle file)
4125 (call-process shell-file-name nil
4126 (generate-new-buffer " *mm*")
4128 shell-command-switch
4130 printer file (mm-handle-type handle))))
4134 (gnus-print-buffer))
4135 (ps-despool filename)))))
4137 (defun gnus-mime-inline-part (&optional handle arg)
4138 "Insert the MIME part under point into the current buffer."
4139 (interactive (list nil current-prefix-arg))
4140 (gnus-article-check-buffer)
4141 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4146 (if (and (not arg) (mm-handle-undisplayer handle))
4147 (mm-remove-part handle)
4148 (setq contents (mm-get-part handle))
4151 (setq charset (or (mail-content-type-get
4152 (mm-handle-type handle) 'charset)
4153 gnus-newsgroup-charset)))
4155 (if (mm-handle-undisplayer handle)
4156 (mm-remove-part handle))
4159 gnus-summary-show-article-charset-alist))
4160 (mm-read-coding-system "Charset: ")))))
4162 (mm-insert-inline handle
4164 (setq charset (mm-charset-to-coding-system
4166 (not (eq charset 'ascii)))
4167 (mm-decode-coding-string contents charset)
4171 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4172 "Insert the MIME part under point into the current buffer using the
4174 (interactive (list nil current-prefix-arg))
4175 (gnus-article-check-buffer)
4176 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4181 (if (mm-handle-undisplayer handle)
4182 (mm-remove-part handle))
4183 (let ((gnus-newsgroup-charset
4185 gnus-summary-show-article-charset-alist))
4186 (mm-read-coding-system "Charset: ")))
4187 (gnus-newsgroup-ignored-charsets 'gnus-all))
4188 (gnus-article-press-button)))))
4190 (defun gnus-mime-view-part-externally (&optional handle)
4191 "View the MIME part under point with an external viewer."
4193 (gnus-article-check-buffer)
4194 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4195 (mm-user-display-methods nil)
4196 (mm-inlined-types nil)
4197 (mail-parse-charset gnus-newsgroup-charset)
4198 (mail-parse-ignored-charsets
4199 (save-excursion (set-buffer gnus-summary-buffer)
4200 gnus-newsgroup-ignored-charsets)))
4202 (if (mm-handle-undisplayer handle)
4203 (mm-remove-part handle)
4204 (mm-display-part handle)))))
4206 (defun gnus-mime-view-part-internally (&optional handle)
4207 "View the MIME part under point with an internal viewer.
4208 If no internal viewer is available, use an external viewer."
4210 (gnus-article-check-buffer)
4211 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4212 (mm-inlined-types '(".*"))
4213 (mm-inline-large-images t)
4214 (mail-parse-charset gnus-newsgroup-charset)
4215 (mail-parse-ignored-charsets
4216 (save-excursion (set-buffer gnus-summary-buffer)
4217 gnus-newsgroup-ignored-charsets))
4220 (if (mm-handle-undisplayer handle)
4221 (mm-remove-part handle)
4222 (mm-display-part handle)))))
4224 (defun gnus-mime-action-on-part (&optional action)
4225 "Do something with the MIME attachment at \(point\)."
4227 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4228 (gnus-article-check-buffer)
4229 (let ((action-pair (assoc action gnus-mime-action-alist)))
4231 (funcall (cdr action-pair)))))
4233 (defun gnus-article-part-wrapper (n function)
4234 (save-current-buffer
4235 (set-buffer gnus-article-buffer)
4236 (when (> n (length gnus-article-mime-handle-alist))
4237 (error "No such part"))
4238 (gnus-article-goto-part n)
4239 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4240 (funcall function handle))))
4242 (defun gnus-article-pipe-part (n)
4243 "Pipe MIME part N, which is the numerical prefix."
4245 (gnus-article-part-wrapper n 'mm-pipe-part))
4247 (defun gnus-article-save-part (n)
4248 "Save MIME part N, which is the numerical prefix."
4250 (gnus-article-part-wrapper n 'mm-save-part))
4252 (defun gnus-article-interactively-view-part (n)
4253 "View MIME part N interactively, which is the numerical prefix."
4255 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4257 (defun gnus-article-copy-part (n)
4258 "Copy MIME part N, which is the numerical prefix."
4260 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4262 (defun gnus-article-view-part-as-charset (n)
4263 "Copy MIME part N, which is the numerical prefix."
4265 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4267 (defun gnus-article-view-part-externally (n)
4268 "View MIME part N externally, which is the numerical prefix."
4270 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4272 (defun gnus-article-inline-part (n)
4273 "Inline MIME part N, which is the numerical prefix."
4275 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4277 (defun gnus-article-mime-match-handle-first (condition)
4279 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4280 (while (setq ihandle (pop alist))
4282 ((functionp condition)
4283 (funcall condition (cdr ihandle)))
4284 ((eq condition 'undisplayed)
4285 (not (or (mm-handle-undisplayer (cdr ihandle))
4286 (equal (mm-handle-media-type (cdr ihandle))
4287 "multipart/alternative"))))
4288 ((eq condition 'undisplayed-alternative)
4289 (not (mm-handle-undisplayer (cdr ihandle))))
4291 (gnus-article-goto-part (car ihandle))
4292 (or (not n) (< (car ihandle) n)))
4293 (setq n (car ihandle))))
4297 (defun gnus-article-view-part (&optional n)
4298 "View MIME part N, which is the numerical prefix."
4300 (save-current-buffer
4301 (set-buffer gnus-article-buffer)
4302 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4303 gnus-article-mime-match-handle-function)))
4304 (when (> n (length gnus-article-mime-handle-alist))
4305 (error "No such part"))
4306 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4307 (when (gnus-article-goto-part n)
4308 (if (equal (car handle) "multipart/alternative")
4309 (gnus-article-press-button)
4310 (when (eq (gnus-mm-display-part handle) 'internal)
4311 (gnus-set-window-start)))))))
4313 (defsubst gnus-article-mime-total-parts ()
4314 (if (bufferp (car gnus-article-mime-handles))
4316 (1- (length gnus-article-mime-handles))))
4318 (defun gnus-mm-display-part (handle)
4319 "Display HANDLE and fix MIME button."
4320 (let ((id (get-text-property (point) 'gnus-part))
4325 (let ((window (selected-window))
4326 (mail-parse-charset gnus-newsgroup-charset)
4327 (mail-parse-ignored-charsets
4328 (if (gnus-buffer-live-p gnus-summary-buffer)
4330 (set-buffer gnus-summary-buffer)
4331 gnus-newsgroup-ignored-charsets)
4335 (let ((win (gnus-get-buffer-window (current-buffer) t))
4338 (select-window win))
4341 (if (mm-handle-displayed-p handle)
4342 ;; This will remove the part.
4343 (mm-display-part handle)
4345 (narrow-to-region (point)
4346 (if (eobp) (point) (1+ (point))))
4347 (mm-display-part handle)
4348 ;; We narrow to the part itself and
4349 ;; then call the treatment functions.
4350 (goto-char (point-min))
4352 (narrow-to-region (point) (point-max))
4355 (gnus-article-mime-total-parts)
4356 (mm-handle-media-type handle)))))
4357 (if (window-live-p window)
4358 (select-window window)))))
4361 (gnus-insert-mime-button
4362 handle id (list (mm-handle-displayed-p handle)))
4363 (goto-char point))))
4365 (defun gnus-article-goto-part (n)
4366 "Go to MIME part N."
4367 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4369 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4370 (let ((gnus-tmp-name
4371 (or (mail-content-type-get (mm-handle-type handle) 'name)
4372 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4373 (mail-content-type-get (mm-handle-type handle) 'url)
4375 (gnus-tmp-type (mm-handle-media-type handle))
4376 (gnus-tmp-description
4377 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4380 (if (if displayed (car displayed)
4381 (mm-handle-displayed-p handle))
4383 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4385 gnus-tmp-type-long b e)
4386 (when (string-match ".*/" gnus-tmp-name)
4387 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4388 (setq gnus-tmp-type-long (concat gnus-tmp-type
4389 (and (not (equal gnus-tmp-name ""))
4390 (concat "; " gnus-tmp-name))))
4391 (unless (equal gnus-tmp-description "")
4392 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4397 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4398 `(,@(gnus-local-map-property gnus-mime-button-map)
4399 gnus-callback gnus-mm-display-part
4400 gnus-part ,gnus-tmp-id
4401 article-type annotation
4404 ;; Exclude a newline.
4407 (widget-convert-button
4410 :action 'gnus-widget-press-button
4411 :button-keymap gnus-mime-button-map
4413 (lambda (widget/window &optional overlay pos)
4414 ;; Needed to properly clear the message due to a bug in
4415 ;; wid-edit (XEmacs only).
4416 (if (boundp 'help-echo-owns-message)
4417 (setq help-echo-owns-message t))
4419 "%S: %s the MIME part; %S: more options"
4420 (aref gnus-mouse-2 0)
4421 ;; XEmacs will get a single widget arg; Emacs 21 will get
4422 ;; window, overlay, position.
4423 (if (mm-handle-displayed-p
4425 (with-current-buffer (gnus-overlay-buffer overlay)
4426 (widget-get (widget-at (gnus-overlay-start overlay))
4428 (widget-get widget/window :mime-handle)))
4430 (aref gnus-down-mouse-3 0))))))
4432 (defun gnus-widget-press-button (elems el)
4433 (goto-char (widget-get elems :from))
4434 (gnus-article-press-button))
4436 (defvar gnus-displaying-mime nil)
4438 (defun gnus-display-mime (&optional ihandles)
4439 "Display the MIME parts."
4441 (save-selected-window
4442 (let ((window (get-buffer-window gnus-article-buffer))
4445 (select-window window)
4446 ;; We have to do this since selecting the window
4447 ;; may change the point. So we set the window point.
4448 (set-window-point window point)))
4449 (let* ((handles (or ihandles
4450 (mm-dissect-buffer nil gnus-article-loose-mime)
4451 (and gnus-article-emulate-mime
4453 buffer-read-only handle name type b e display)
4454 (when (and (not ihandles)
4455 (not gnus-displaying-mime))
4456 ;; Top-level call; we clean up.
4457 (when gnus-article-mime-handles
4458 (mm-destroy-parts gnus-article-mime-handles)
4459 (setq gnus-article-mime-handle-alist nil));; A trick.
4460 (setq gnus-article-mime-handles handles)
4461 ;; We allow users to glean info from the handles.
4462 (when gnus-article-mime-part-function
4463 (gnus-mime-part-function handles)))
4465 (or (not (stringp (car handles)))
4468 (when (and (not ihandles)
4469 (not gnus-displaying-mime))
4470 ;; Clean up for mime parts.
4472 (delete-region (point) (point-max)))
4473 (let ((gnus-displaying-mime t))
4474 (gnus-mime-display-part handles)))
4477 (narrow-to-region (point) (point-max))
4478 (gnus-treat-article nil 1 1)
4481 ;; Highlight the headers.
4485 (narrow-to-region (point-min) (point))
4486 (gnus-treat-article 'head))))))))
4488 (defvar gnus-mime-display-multipart-as-mixed nil)
4489 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4490 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4492 (defun gnus-mime-display-part (handle)
4495 ((not (stringp (car handle)))
4496 (gnus-mime-display-single handle))
4497 ;; User-defined multipart
4498 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4499 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4501 ;; multipart/alternative
4502 ((and (equal (car handle) "multipart/alternative")
4503 (not (or gnus-mime-display-multipart-as-mixed
4504 gnus-mime-display-multipart-alternative-as-mixed)))
4505 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4506 (push (cons id handle) gnus-article-mime-handle-alist)
4507 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4508 ;; multipart/related
4509 ((and (equal (car handle) "multipart/related")
4510 (not (or gnus-mime-display-multipart-as-mixed
4511 gnus-mime-display-multipart-related-as-mixed)))
4512 ;;;!!!We should find the start part, but we just default
4513 ;;;!!!to the first part.
4514 ;;(gnus-mime-display-part (cadr handle))
4515 ;;;!!! Most multipart/related is an HTML message plus images.
4516 ;;;!!! Unfortunately we are unable to let W3 display those
4517 ;;;!!! included images, so we just display it as a mixed multipart.
4518 ;;(gnus-mime-display-mixed (cdr handle))
4519 ;;;!!! No, w3 can display everything just fine.
4520 (gnus-mime-display-part (cadr handle)))
4521 ((equal (car handle) "multipart/signed")
4522 (gnus-add-wash-type 'signed)
4523 (gnus-mime-display-security handle))
4524 ((equal (car handle) "multipart/encrypted")
4525 (gnus-add-wash-type 'encrypted)
4526 (gnus-mime-display-security handle))
4527 ;; Other multiparts are handled like multipart/mixed.
4529 (gnus-mime-display-mixed (cdr handle)))))
4531 (defun gnus-mime-part-function (handles)
4532 (if (stringp (car handles))
4533 (mapcar 'gnus-mime-part-function (cdr handles))
4534 (funcall gnus-article-mime-part-function handles)))
4536 (defun gnus-mime-display-mixed (handles)
4537 (mapcar 'gnus-mime-display-part handles))
4539 (defun gnus-mime-display-single (handle)
4540 (let ((type (mm-handle-media-type handle))
4541 (ignored gnus-ignored-mime-types)
4548 (when (string-match (pop ignored) type)
4549 (throw 'ignored nil)))
4550 (if (and (setq not-attachment
4551 (and (not (mm-inline-override-p handle))
4552 (or (not (mm-handle-disposition handle))
4553 (equal (car (mm-handle-disposition handle))
4555 (mm-attachment-override-p handle))))
4556 (mm-automatic-display-p handle)
4558 (mm-inlinable-p handle)
4559 (mm-inlined-p handle))
4560 (mm-automatic-external-display-p type)))
4562 (when (equal (mm-handle-media-supertype handle) "text")
4564 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4566 (push (cons id handle) gnus-article-mime-handle-alist)
4567 (when (or (not display)
4568 (not (gnus-unbuttonized-mime-type-p type)))
4569 ;(gnus-article-insert-newline)
4570 (gnus-insert-mime-button
4571 handle id (list (or display (and not-attachment text))))
4572 (gnus-article-insert-newline)
4573 ;(gnus-article-insert-newline)
4574 ;; Remember modify the number of forward lines.
4582 (let ((mail-parse-charset gnus-newsgroup-charset)
4583 (mail-parse-ignored-charsets
4584 (save-excursion (condition-case ()
4585 (set-buffer gnus-summary-buffer)
4587 gnus-newsgroup-ignored-charsets)))
4588 (mm-display-part handle t))
4589 (goto-char (point-max)))
4590 ((and text not-attachment)
4594 (gnus-article-insert-newline)
4595 (mm-insert-inline handle (mm-get-part handle))
4596 (goto-char (point-max))))
4600 (narrow-to-region beg (point))
4603 (gnus-article-mime-total-parts)
4604 (mm-handle-media-type handle)))))))))
4606 (defun gnus-unbuttonized-mime-type-p (type)
4607 "Say whether TYPE is to be unbuttonized."
4608 (unless gnus-inhibit-mime-unbuttonizing
4610 (let ((types gnus-unbuttonized-mime-types))
4612 (when (string-match (pop types) type)
4613 (throw 'found t)))))
4615 (let ((types gnus-buttonized-mime-types))
4617 (when (string-match (pop types) type)
4618 (throw 'found t)))))))))
4620 (defun gnus-article-insert-newline ()
4621 "Insert a newline, but mark it as undeletable."
4622 (gnus-put-text-property
4623 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4625 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4626 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4629 handle buffer-read-only from props begend not-pref)
4630 (save-window-excursion
4633 (narrow-to-region (car ibegend)
4636 (goto-char (car ibegend))
4639 (delete-region (point-min) (point-max))
4640 (mm-remove-parts handles))
4641 (setq begend (list (point-marker)))
4643 (unless (setq not-pref (cadr (member preferred ihandles)))
4644 (setq not-pref (car ihandles)))
4647 (not (gnus-unbuttonized-mime-type-p
4648 "multipart/alternative")))
4649 (gnus-add-text-properties
4652 (insert (format "%d. " id))
4656 (unless ,(not ibegend)
4657 (setq gnus-article-mime-handle-alist
4658 ',gnus-article-mime-handle-alist))
4659 (gnus-mime-display-alternative
4660 ',ihandles ',not-pref ',begend ,id))
4661 ,@(gnus-local-map-property gnus-mime-button-map)
4662 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4663 face ,gnus-article-button-face
4666 (widget-convert-button 'link from (point)
4667 :action 'gnus-widget-press-button
4668 :button-keymap gnus-widget-button-keymap)
4670 (while (setq handle (pop handles))
4671 (gnus-add-text-properties
4674 (insert (format "(%c) %-18s"
4675 (if (equal handle preferred) ?* ? )
4676 (mm-handle-media-type handle)))
4680 (unless ,(not ibegend)
4681 (setq gnus-article-mime-handle-alist
4682 ',gnus-article-mime-handle-alist))
4683 (gnus-mime-display-alternative
4684 ',ihandles ',handle ',begend ,id))
4685 ,@(gnus-local-map-property gnus-mime-button-map)
4686 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4687 face ,gnus-article-button-face
4690 (widget-convert-button 'link from (point)
4691 :action 'gnus-widget-press-button
4692 :button-keymap gnus-widget-button-keymap)
4696 (if (stringp (car preferred))
4697 (gnus-display-mime preferred)
4698 (let ((mail-parse-charset gnus-newsgroup-charset)
4699 (mail-parse-ignored-charsets
4700 (save-excursion (set-buffer gnus-summary-buffer)
4701 gnus-newsgroup-ignored-charsets)))
4702 (mm-display-part preferred)
4706 (narrow-to-region (car begend) (point-max))
4708 nil (length gnus-article-mime-handle-alist)
4709 (gnus-article-mime-total-parts)
4710 (mm-handle-media-type handle))))))
4711 (goto-char (point-max))
4712 (setcdr begend (point-marker)))))
4714 (goto-char point))))
4716 (defconst gnus-article-wash-status-strings
4717 (let ((alist '((cite "c" "Possible hidden citation text"
4718 " " "All citation text visible")
4719 (headers "h" "Hidden headers"
4720 " " "All headers visible.")
4721 (pgp "p" "Encrypted or signed message status hidden"
4722 " " "No hidden encryption nor digital signature status")
4723 (signature "s" "Signature has been hidden"
4724 " " "Signature is visible")
4725 (overstrike "o" "Overstrike (^H) characters applied"
4726 " " "No overstrike characters applied")
4727 (emphasis "e" "/*_Emphasis_*/ characters applied"
4728 " " "No /*_emphasis_*/ characters applied")))
4730 (dolist (entry alist result)
4731 (let ((key (nth 0 entry))
4732 (on (copy-sequence (nth 1 entry)))
4733 (on-help (nth 2 entry))
4734 (off (copy-sequence (nth 3 entry)))
4735 (off-help (nth 4 entry)))
4736 (put-text-property 0 1 'help-echo on-help on)
4737 (put-text-property 0 1 'help-echo off-help off)
4738 (push (list key on off) result))))
4739 "Alist of strings describing wash status in the mode line.
4740 Each entry has the form (KEY ON OF), where the KEY is a symbol
4741 representing the particular washing function, ON is the string to use
4742 in the article mode line when the washing function is active, and OFF
4743 is the string to use when it is inactive.")
4745 (defun gnus-article-wash-status-entry (key value)
4746 (let ((entry (assoc key gnus-article-wash-status-strings)))
4747 (if value (nth 1 entry) (nth 2 entry))))
4749 (defun gnus-article-wash-status ()
4750 "Return a string which display status of article washing."
4752 (set-buffer gnus-article-buffer)
4753 (let ((cite (memq 'cite gnus-article-wash-types))
4754 (headers (memq 'headers gnus-article-wash-types))
4755 (boring (memq 'boring-headers gnus-article-wash-types))
4756 (pgp (memq 'pgp gnus-article-wash-types))
4757 (pem (memq 'pem gnus-article-wash-types))
4758 (signed (memq 'signed gnus-article-wash-types))
4759 (encrypted (memq 'encrypted gnus-article-wash-types))
4760 (signature (memq 'signature gnus-article-wash-types))
4761 (overstrike (memq 'overstrike gnus-article-wash-types))
4762 (emphasis (memq 'emphasis gnus-article-wash-types)))
4764 (gnus-article-wash-status-entry 'cite cite)
4765 (gnus-article-wash-status-entry 'headers (or headers boring))
4766 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4767 (gnus-article-wash-status-entry 'signature signature)
4768 (gnus-article-wash-status-entry 'overstrike overstrike)
4769 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4771 (defun gnus-add-wash-type (type)
4772 "Add a washing of TYPE to the current status."
4773 (add-to-list 'gnus-article-wash-types type))
4775 (defun gnus-delete-wash-type (type)
4776 "Add a washing of TYPE to the current status."
4777 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4779 (defun gnus-add-image (category image)
4780 "Add IMAGE of CATEGORY to the list of displayed images."
4781 (let ((entry (assq category gnus-article-image-alist)))
4783 (setq entry (list category))
4784 (push entry gnus-article-image-alist))
4785 (nconc entry (list image))))
4787 (defun gnus-delete-images (category)
4788 "Delete all images in CATEGORY."
4789 (let ((entry (assq category gnus-article-image-alist)))
4790 (dolist (image (cdr entry))
4791 (gnus-remove-image image))
4792 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4793 (gnus-delete-wash-type category)))
4795 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4797 (defun gnus-article-maybe-hide-headers ()
4798 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4799 Provided for backwards compatibility."
4800 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4801 (not (save-excursion (set-buffer gnus-summary-buffer)
4802 gnus-have-all-headers)))
4803 (not gnus-inhibit-hiding))
4804 (gnus-article-hide-headers)))
4808 (defun gnus-output-to-file (file-name)
4809 "Append the current article to a file named FILE-NAME."
4810 (let ((artbuf (current-buffer)))
4812 (insert-buffer-substring artbuf)
4813 ;; Append newline at end of the buffer as separator, and then
4815 (goto-char (point-max))
4817 (let ((file-name-coding-system nnmail-pathname-coding-system))
4818 (mm-append-to-file (point-min) (point-max) file-name))
4821 (defun gnus-narrow-to-page (&optional arg)
4822 "Narrow the article buffer to a page.
4823 If given a numerical ARG, move forward ARG pages."
4825 (setq arg (if arg (prefix-numeric-value arg) 0))
4827 (set-buffer gnus-article-buffer)
4828 (goto-char (point-min))
4830 ;; Remove any old next/prev buttons.
4831 (when (gnus-visual-p 'page-marker)
4832 (let ((buffer-read-only nil))
4833 (gnus-remove-text-with-property 'gnus-prev)
4834 (gnus-remove-text-with-property 'gnus-next)))
4837 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4839 (re-search-forward page-delimiter nil 'move arg)))
4840 (goto-char (match-end 0)))
4843 (if (re-search-forward page-delimiter nil 'move)
4846 (when (and (gnus-visual-p 'page-marker)
4847 (not (= (point-min) 1)))
4849 (goto-char (point-min))
4850 (gnus-insert-prev-page-button)))
4851 (when (and (gnus-visual-p 'page-marker)
4852 (< (+ (point-max) 2) (buffer-size)))
4854 (goto-char (point-max))
4855 (gnus-insert-next-page-button)))))
4857 ;; Article mode commands
4859 (defun gnus-article-goto-next-page ()
4860 "Show the next page of the article."
4862 (gnus-eval-in-buffer-window gnus-summary-buffer
4863 (gnus-summary-next-page)))
4865 (defun gnus-article-goto-prev-page ()
4866 "Show the next page of the article."
4868 (gnus-eval-in-buffer-window gnus-summary-buffer
4869 (gnus-summary-prev-page)))
4871 (defun gnus-article-next-page (&optional lines)
4872 "Show the next page of the current article.
4873 If end of article, return non-nil. Otherwise return nil.
4874 Argument LINES specifies lines to be scrolled up."
4876 (move-to-window-line -1)
4879 (and (pos-visible-in-window-p) ;Not continuation line.
4880 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4881 ;; Nothing in this page.
4882 (if (or (not gnus-page-broken)
4885 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4887 (gnus-narrow-to-page 1) ;Go to next page.
4889 ;; More in this page.
4890 (let ((scroll-in-place nil))
4894 ;; Long lines may cause an end-of-buffer error.
4895 (goto-char (point-max)))))
4896 (move-to-window-line 0)
4899 (defun gnus-article-prev-page (&optional lines)
4900 "Show previous page of current article.
4901 Argument LINES specifies lines to be scrolled down."
4903 (move-to-window-line 0)
4904 (if (and gnus-page-broken
4906 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4908 (gnus-narrow-to-page -1) ;Go to previous page.
4909 (goto-char (point-max))
4911 (let ((scroll-in-place nil))
4915 (beginning-of-buffer
4916 (goto-char (point-min))))
4917 (move-to-window-line 0)))))
4919 (defun gnus-article-only-boring-p ()
4920 "Decide whether there is only boring text remaining in the article.
4921 Something \"interesting\" is a word of at least two letters that does
4922 not have a face in `gnus-article-boring-faces'."
4923 (when (and gnus-article-skip-boring
4924 (boundp 'gnus-article-boring-faces)
4925 (symbol-value 'gnus-article-boring-faces))
4928 (while (re-search-forward "\\b\\w\\w" nil t)
4930 (when (not (gnus-intersection
4931 (gnus-faces-at (point))
4932 (symbol-value 'gnus-article-boring-faces)))
4933 (throw 'only-boring nil)))
4934 (throw 'only-boring t)))))
4936 (defun gnus-article-refer-article ()
4937 "Read article specified by message-id around point."
4940 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
4941 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
4942 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
4943 (let ((msg-id (concat "<" (match-string 0) ">")))
4944 (set-buffer gnus-summary-buffer)
4945 (gnus-summary-refer-article msg-id))
4946 (error "No references around point"))))
4948 (defun gnus-article-show-summary ()
4949 "Reconfigure windows to show summary buffer."
4951 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4952 (error "There is no summary buffer for this article buffer")
4953 (gnus-article-set-globals)
4954 (gnus-configure-windows 'article)
4955 (gnus-summary-goto-subject gnus-current-article)
4956 (gnus-summary-position-point)))
4958 (defun gnus-article-describe-briefly ()
4959 "Describe article mode commands briefly."
4961 (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")))
4963 (defun gnus-article-summary-command ()
4964 "Execute the last keystroke in the summary buffer."
4966 (let ((obuf (current-buffer))
4967 (owin (current-window-configuration))
4969 (switch-to-buffer gnus-article-current-summary 'norecord)
4970 (setq func (lookup-key (current-local-map) (this-command-keys)))
4971 (call-interactively func)
4973 (set-window-configuration owin)
4974 (set-window-point (get-buffer-window (current-buffer)) (point))))
4976 (defun gnus-article-summary-command-nosave ()
4977 "Execute the last keystroke in the summary buffer."
4980 (pop-to-buffer gnus-article-current-summary 'norecord)
4981 (setq func (lookup-key (current-local-map) (this-command-keys)))
4982 (call-interactively func)))
4984 (defun gnus-article-check-buffer ()
4985 "Beep if not in an article buffer."
4986 (unless (equal major-mode 'gnus-article-mode)
4987 (error "Command invoked outside of a Gnus article buffer")))
4989 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4990 "Read a summary buffer key sequence and execute it from the article buffer."
4992 (gnus-article-check-buffer)
4994 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4995 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4996 "=" "^" "\M-^" "|"))
5002 '("n" "Gn" "p" "Gp"))
5005 (set-buffer gnus-article-current-summary)
5006 (let (gnus-pick-mode)
5007 (push (or key last-command-event) unread-command-events)
5008 (setq keys (if (featurep 'xemacs)
5009 (events-to-keys (read-key-sequence nil))
5010 (read-key-sequence nil)))))
5014 (if (or (member keys nosaves)
5015 (member keys nosave-but-article)
5016 (member keys nosave-in-article))
5018 (save-window-excursion
5019 (pop-to-buffer gnus-article-current-summary 'norecord)
5020 ;; We disable the pick minor mode commands.
5021 (let (gnus-pick-mode)
5022 (setq func (lookup-key (current-local-map) keys))))
5026 (unless (member keys nosave-in-article)
5027 (set-buffer gnus-article-current-summary))
5028 (call-interactively func)
5029 (setq new-sum-point (point)))
5030 (when (member keys nosave-but-article)
5031 (pop-to-buffer gnus-article-buffer 'norecord)))
5032 ;; These commands should restore window configuration.
5033 (let ((obuf (current-buffer))
5034 (owin (current-window-configuration))
5036 (summary gnus-article-current-summary)
5037 func in-buffer selected)
5038 (if not-restore-window
5039 (pop-to-buffer summary 'norecord)
5040 (switch-to-buffer summary 'norecord))
5041 (setq in-buffer (current-buffer))
5042 ;; We disable the pick minor mode commands.
5043 (if (and (setq func (let (gnus-pick-mode)
5044 (lookup-key (current-local-map) keys)))
5047 (call-interactively func)
5048 (setq new-sum-point (point))
5049 (when (eq in-buffer (current-buffer))
5050 (setq selected (gnus-summary-select-article))
5052 (unless not-restore-window
5053 (set-window-configuration owin))
5054 (when (eq selected 'old)
5056 (set-window-start (get-buffer-window (current-buffer))
5058 (set-window-point (get-buffer-window (current-buffer))
5060 (let ((win (get-buffer-window gnus-article-current-summary)))
5062 (set-window-point win new-sum-point)))) )
5063 (switch-to-buffer gnus-article-buffer)
5066 (defun gnus-article-describe-key (key)
5067 "Display documentation of the function invoked by KEY. KEY is a string."
5068 (interactive "kDescribe key: ")
5069 (gnus-article-check-buffer)
5070 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5072 (set-buffer gnus-article-current-summary)
5073 (let (gnus-pick-mode)
5074 (if (featurep 'xemacs)
5076 (push (elt key 0) unread-command-events)
5077 (setq key (events-to-keys
5078 (read-key-sequence "Describe key: "))))
5079 (setq unread-command-events
5081 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5082 (string-to-list key)))
5083 (setq key (read-key-sequence "Describe key: "))))
5085 (describe-key key)))
5087 (defun gnus-article-describe-key-briefly (key &optional insert)
5088 "Display documentation of the function invoked by KEY. KEY is a string."
5089 (interactive "kDescribe key: \nP")
5090 (gnus-article-check-buffer)
5091 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5093 (set-buffer gnus-article-current-summary)
5094 (let (gnus-pick-mode)
5095 (if (featurep 'xemacs)
5097 (push (elt key 0) unread-command-events)
5098 (setq key (events-to-keys
5099 (read-key-sequence "Describe key: "))))
5100 (setq unread-command-events
5102 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5103 (string-to-list key)))
5104 (setq key (read-key-sequence "Describe key: "))))
5105 (describe-key-briefly key insert))
5106 (describe-key-briefly key insert)))
5108 (defun gnus-article-reply-with-original (&optional wide)
5109 "Start composing a reply mail to the current message.
5110 The text in the region will be yanked. If the region isn't active,
5111 the entire article will be yanked."
5113 (let ((article (cdr gnus-article-current))
5115 (if (not (gnus-mark-active-p))
5116 (with-current-buffer gnus-summary-buffer
5117 (gnus-summary-reply (list (list article)) wide))
5118 (setq contents (buffer-substring (point) (mark t)))
5119 ;; Deactivate active regions.
5120 (when (and (boundp 'transient-mark-mode)
5121 transient-mark-mode)
5122 (setq mark-active nil))
5123 (with-current-buffer gnus-summary-buffer
5125 (list (list article contents)) wide)))))
5127 (defun gnus-article-followup-with-original ()
5128 "Compose a followup to the current article.
5129 The text in the region will be yanked. If the region isn't active,
5130 the entire article will be yanked."
5132 (let ((article (cdr gnus-article-current))
5134 (if (not (gnus-mark-active-p))
5135 (with-current-buffer gnus-summary-buffer
5136 (gnus-summary-followup (list (list article))))
5137 (setq contents (buffer-substring (point) (mark t)))
5138 ;; Deactivate active regions.
5139 (when (and (boundp 'transient-mark-mode)
5140 transient-mark-mode)
5141 (setq mark-active nil))
5142 (with-current-buffer gnus-summary-buffer
5143 (gnus-summary-followup
5144 (list (list article contents)))))))
5146 (defun gnus-article-hide (&optional arg force)
5147 "Hide all the gruft in the current article.
5148 This means that signatures, cited text and (some) headers will be
5150 If given a prefix, show the hidden text instead."
5151 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5152 (gnus-article-hide-headers arg)
5153 (gnus-article-hide-list-identifiers arg)
5154 (gnus-article-hide-citation-maybe arg force)
5155 (gnus-article-hide-signature arg))
5157 (defun gnus-article-maybe-highlight ()
5158 "Do some article highlighting if article highlighting is requested."
5159 (when (gnus-visual-p 'article-highlight 'highlight)
5160 (gnus-article-highlight-some)))
5162 (defun gnus-check-group-server ()
5163 ;; Make sure the connection to the server is alive.
5164 (unless (gnus-server-opened
5165 (gnus-find-method-for-group gnus-newsgroup-name))
5166 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5167 (gnus-request-group gnus-newsgroup-name t)))
5170 (autoload 'nneething-get-file-name "nneething"))
5172 (defun gnus-request-article-this-buffer (article group)
5173 "Get an article and insert it into this buffer."
5174 (let (do-update-line sparse-header)
5178 (gnus-kill-all-overlays)
5179 (setq group (or group gnus-newsgroup-name))
5181 ;; Using `gnus-request-article' directly will insert the article into
5182 ;; `nntp-server-buffer' - so we'll save some time by not having to
5183 ;; copy it from the server buffer into the article buffer.
5185 ;; We only request an article by message-id when we do not have the
5186 ;; headers for it, so we'll have to get those.
5187 (when (stringp article)
5188 (gnus-read-header article))
5190 ;; If the article number is negative, that means that this article
5191 ;; doesn't belong in this newsgroup (possibly), so we find its
5192 ;; message-id and request it by id instead of number.
5193 (when (and (numberp article)
5195 (get-buffer gnus-summary-buffer)
5196 (gnus-buffer-exists-p gnus-summary-buffer))
5198 (set-buffer gnus-summary-buffer)
5199 (let ((header (gnus-summary-article-header article)))
5202 ((memq article gnus-newsgroup-sparse)
5203 ;; This is a sparse gap article.
5204 (setq do-update-line article)
5205 (setq article (mail-header-id header))
5206 (setq sparse-header (gnus-read-header article))
5207 (setq gnus-newsgroup-sparse
5208 (delq article gnus-newsgroup-sparse)))
5210 ;; It's a real article.
5211 (setq article (mail-header-id header)))
5213 ;; It is an extracted pseudo-article.
5214 (setq article 'pseudo)
5215 (gnus-request-pseudo-article header))))
5217 (let ((method (gnus-find-method-for-group
5218 gnus-newsgroup-name)))
5219 (when (and (eq (car method) 'nneething)
5221 (let ((dir (nneething-get-file-name
5222 (mail-header-id header))))
5223 (when (and (stringp dir)
5224 (file-directory-p dir))
5225 (setq article 'nneething)
5226 (gnus-group-enter-directory dir))))))))
5229 ;; Refuse to select canceled articles.
5230 ((and (numberp article)
5232 (get-buffer gnus-summary-buffer)
5233 (gnus-buffer-exists-p gnus-summary-buffer)
5234 (eq (cdr (save-excursion
5235 (set-buffer gnus-summary-buffer)
5236 (assq article gnus-newsgroup-reads)))
5237 gnus-canceled-mark))
5239 ;; We first check `gnus-original-article-buffer'.
5240 ((and (get-buffer gnus-original-article-buffer)
5243 (set-buffer gnus-original-article-buffer)
5244 (and (equal (car gnus-original-article) group)
5245 (eq (cdr gnus-original-article) article))))
5246 (insert-buffer-substring gnus-original-article-buffer)
5248 ;; Check the backlog.
5249 ((and gnus-keep-backlog
5250 (gnus-backlog-request-article group article (current-buffer)))
5252 ;; Check asynchronous pre-fetch.
5253 ((gnus-async-request-fetched-article group article (current-buffer))
5254 (gnus-async-prefetch-next group article gnus-summary-buffer)
5255 (when (and (numberp article) gnus-keep-backlog)
5256 (gnus-backlog-enter-article group article (current-buffer)))
5259 ((and gnus-use-cache
5261 (gnus-cache-request-article article group))
5263 ;; Check the agent cache.
5264 ((gnus-agent-request-article article group)
5266 ;; Get the article and put into the article buffer.
5267 ((or (stringp article)
5269 (let ((gnus-override-method gnus-override-method)
5270 (methods (and (stringp article)
5271 gnus-refer-article-method))
5272 (backend (car (gnus-find-method-for-group
5273 gnus-newsgroup-name)))
5275 (buffer-read-only nil))
5276 (if (or (not (listp methods))
5277 (and (symbolp (car methods))
5278 (assq (car methods) nnoo-definition-alist)))
5279 (setq methods (list methods)))
5280 (when (and (null gnus-override-method)
5282 (setq gnus-override-method (pop methods)))
5284 (when (eq gnus-override-method 'current)
5285 (setq gnus-override-method
5286 (with-current-buffer gnus-summary-buffer
5287 gnus-current-select-method)))
5289 (gnus-kill-all-overlays)
5290 (let ((gnus-newsgroup-name group))
5291 (gnus-check-group-server))
5293 ((gnus-request-article article group (current-buffer))
5294 (when (numberp article)
5295 (gnus-async-prefetch-next group article
5296 gnus-summary-buffer)
5297 (when gnus-keep-backlog
5298 (gnus-backlog-enter-article
5299 group article (current-buffer))))
5300 (setq result 'article))
5302 (setq gnus-override-method (pop methods)))
5303 ((not (string-match "^400 "
5304 (nnheader-get-report backend)))
5305 ;; If we get 400 server disconnect, reconnect and
5306 ;; retry; otherwise, assume the article has expired.
5307 (setq result 'done))))
5308 (and (eq result 'article) 'article)))
5312 ;; Associate this article with the current summary buffer.
5313 (setq gnus-article-current-summary gnus-summary-buffer)
5315 ;; Take the article from the original article buffer
5316 ;; and place it in the buffer it's supposed to be in.
5317 (when (and (get-buffer gnus-article-buffer)
5318 (equal (buffer-name (current-buffer))
5319 (buffer-name (get-buffer gnus-article-buffer))))
5321 (if (get-buffer gnus-original-article-buffer)
5322 (set-buffer gnus-original-article-buffer)
5323 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5324 (buffer-disable-undo)
5325 (setq major-mode 'gnus-original-article-mode)
5326 (setq buffer-read-only t))
5327 (let (buffer-read-only)
5329 (insert-buffer-substring gnus-article-buffer))
5330 (setq gnus-original-article (cons group article)))
5333 (run-hooks 'gnus-article-decode-hook)
5334 ;; Mark article as decoded or not.
5335 (setq gnus-article-decoded-p gnus-article-decode-hook))
5337 ;; Update sparse articles.
5338 (when (and do-update-line
5339 (or (numberp article)
5341 (let ((buf (current-buffer)))
5342 (set-buffer gnus-summary-buffer)
5343 (gnus-summary-update-article do-update-line sparse-header)
5344 (gnus-summary-goto-subject do-update-line nil t)
5345 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5347 (set-buffer buf))))))
5353 (defcustom gnus-article-edit-mode-hook nil
5354 "Hook run in article edit mode buffers."
5355 :group 'gnus-article-various
5358 (defvar gnus-article-edit-done-function nil)
5360 (defvar gnus-article-edit-mode-map nil)
5361 (defvar gnus-article-edit-mode nil)
5363 ;; Should we be using derived.el for this?
5364 (unless gnus-article-edit-mode-map
5365 (setq gnus-article-edit-mode-map (make-keymap))
5366 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5368 (gnus-define-keys gnus-article-edit-mode-map
5369 "\C-c?" describe-mode
5370 "\C-c\C-c" gnus-article-edit-done
5371 "\C-c\C-k" gnus-article-edit-exit
5372 "\C-c\C-f\C-t" message-goto-to
5373 "\C-c\C-f\C-o" message-goto-from
5374 "\C-c\C-f\C-b" message-goto-bcc
5375 ;;"\C-c\C-f\C-w" message-goto-fcc
5376 "\C-c\C-f\C-c" message-goto-cc
5377 "\C-c\C-f\C-s" message-goto-subject
5378 "\C-c\C-f\C-r" message-goto-reply-to
5379 "\C-c\C-f\C-n" message-goto-newsgroups
5380 "\C-c\C-f\C-d" message-goto-distribution
5381 "\C-c\C-f\C-f" message-goto-followup-to
5382 "\C-c\C-f\C-m" message-goto-mail-followup-to
5383 "\C-c\C-f\C-k" message-goto-keywords
5384 "\C-c\C-f\C-u" message-goto-summary
5385 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5386 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5387 "\C-c\C-b" message-goto-body
5388 "\C-c\C-i" message-goto-signature
5390 "\C-c\C-t" message-insert-to
5391 "\C-c\C-n" message-insert-newsgroups
5392 "\C-c\C-o" message-sort-headers
5393 "\C-c\C-e" message-elide-region
5394 "\C-c\C-v" message-delete-not-region
5395 "\C-c\C-z" message-kill-to-signature
5396 "\M-\r" message-newline-and-reformat
5397 "\C-c\C-a" mml-attach-file
5398 "\C-a" message-beginning-of-line
5400 "\M-;" comment-region)
5402 (gnus-define-keys (gnus-article-edit-wash-map
5403 "\C-c\C-w" gnus-article-edit-mode-map)
5404 "f" gnus-article-edit-full-stops))
5407 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5409 ["Fetch To" message-insert-to t]
5410 ["Fetch Newsgroups" message-insert-newsgroups t]
5412 ["To" message-goto-to t]
5413 ["From" message-goto-from t]
5414 ["Subject" message-goto-subject t]
5415 ["Cc" message-goto-cc t]
5416 ["Reply-To" message-goto-reply-to t]
5417 ["Summary" message-goto-summary t]
5418 ["Keywords" message-goto-keywords t]
5419 ["Newsgroups" message-goto-newsgroups t]
5420 ["Followup-To" message-goto-followup-to t]
5421 ["Mail-Followup-To" message-goto-mail-followup-to t]
5422 ["Distribution" message-goto-distribution t]
5423 ["Body" message-goto-body t]
5424 ["Signature" message-goto-signature t]))
5426 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5427 "Major mode for editing articles.
5428 This is an extended text-mode.
5430 \\{gnus-article-edit-mode-map}"
5431 (make-local-variable 'gnus-article-edit-done-function)
5432 (make-local-variable 'gnus-prev-winconf)
5433 (set (make-local-variable 'font-lock-defaults)
5434 '(message-font-lock-keywords t))
5435 (set (make-local-variable 'mail-header-separator) "")
5436 (set (make-local-variable 'gnus-article-edit-mode) t)
5437 (easy-menu-add message-mode-field-menu message-mode-map)
5439 (setq buffer-read-only nil)
5440 (buffer-enable-undo)
5443 (defun gnus-article-edit (&optional force)
5444 "Edit the current article.
5445 This will have permanent effect only in mail groups.
5446 If FORCE is non-nil, allow editing of articles even in read-only
5449 (when (and (not force)
5450 (gnus-group-read-only-p))
5451 (error "The current newsgroup does not support article editing"))
5452 (gnus-article-date-original)
5453 (gnus-article-edit-article
5455 `(lambda (no-highlight)
5457 (gnus-summary-edit-article-done
5458 ,(or (mail-header-references gnus-current-headers) "")
5459 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5461 (defun gnus-article-edit-article (start-func exit-func)
5462 "Start editing the contents of the current article buffer."
5463 (let ((winconf (current-window-configuration)))
5464 (set-buffer gnus-article-buffer)
5465 (gnus-article-edit-mode)
5466 (funcall start-func)
5467 (set-buffer-modified-p nil)
5468 (gnus-configure-windows 'edit-article)
5469 (setq gnus-article-edit-done-function exit-func)
5470 (setq gnus-prev-winconf winconf)
5471 (gnus-message 6 "C-c C-c to end edits")))
5473 (defun gnus-article-edit-done (&optional arg)
5474 "Update the article edits and exit."
5476 (let ((func gnus-article-edit-done-function)
5477 (buf (current-buffer))
5478 (start (window-start))
5480 (winconf gnus-prev-winconf))
5481 (widen) ;; Widen it in case that users narrowed the buffer.
5484 ;; The cache and backlog have to be flushed somewhat.
5485 (when gnus-keep-backlog
5486 (gnus-backlog-remove-article
5487 (car gnus-article-current) (cdr gnus-article-current)))
5488 ;; Flush original article as well.
5490 (when (get-buffer gnus-original-article-buffer)
5491 (set-buffer gnus-original-article-buffer)
5492 (setq gnus-original-article nil)))
5493 (when gnus-use-cache
5494 (gnus-cache-update-article
5495 (car gnus-article-current) (cdr gnus-article-current)))
5496 ;; We remove all text props from the article buffer.
5497 (kill-all-local-variables)
5498 (gnus-set-text-properties (point-min) (point-max) nil)
5500 (set-window-configuration winconf)
5502 (set-window-start (get-buffer-window buf) start)
5503 (set-window-point (get-buffer-window buf) (point))))
5505 (defun gnus-article-edit-exit ()
5506 "Exit the article editing without updating."
5508 (when (or (not (buffer-modified-p))
5509 (yes-or-no-p "Article modified; kill anyway? "))
5510 (let ((curbuf (current-buffer))
5512 (window-start (window-start)))
5514 (if (gnus-buffer-live-p gnus-original-article-buffer)
5515 (insert-buffer gnus-original-article-buffer))
5516 (let ((winconf gnus-prev-winconf))
5517 (kill-all-local-variables)
5519 (set-window-configuration winconf)
5520 ;; Tippy-toe some to make sure that point remains where it was.
5521 (save-current-buffer
5523 (set-window-start (get-buffer-window (current-buffer)) window-start)
5526 (defun gnus-article-edit-full-stops ()
5527 "Interactively repair spacing at end of sentences."
5530 (goto-char (point-min))
5531 (search-forward-regexp "^$" nil t)
5532 (let ((case-fold-search nil))
5533 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5536 ;;; Article highlights
5539 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5541 ;;; Internal Variables:
5543 (defcustom gnus-button-url-regexp
5544 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5545 "\\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:]]\\)"
5546 "\\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\\)\\)")
5547 "Regular expression that matches URLs."
5548 :group 'gnus-article-buttons
5551 (defcustom gnus-button-valid-fqdn-regexp
5552 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5554 "\\([a-z][a-z]" ;; two letter country TDLs
5555 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5556 "\\|aero\\|coop\\|info\\|name\\|museum"
5557 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5559 "Regular expression that matches a valid FQDN."
5560 :group 'gnus-article-buttons
5563 (defcustom gnus-button-man-handler 'manual-entry
5564 "Function to use for displaying man pages.
5565 The function must take at least one argument with a string naming the
5567 :type '(choice (function-item :tag "Man" manual-entry)
5568 (function-item :tag "Woman" woman)
5569 (function :tag "Other"))
5570 :group 'gnus-article-buttons)
5572 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5573 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5574 If the default site is too slow, try to find a CTAN mirror, see
5575 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5576 the variable `gnus-button-handle-ctan'."
5577 :group 'gnus-article-buttons
5578 :link '(custom-manual "(gnus)Group Parameters")
5579 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5580 (const "http://tug.ctan.org/tex-archive/")
5581 (const "http://www.dante.de/CTAN/")
5582 (string :tag "Other")))
5584 (defcustom gnus-button-ctan-handler 'browse-url
5585 "Function to use for displaying CTAN links.
5586 The function must take one argument, the string naming the URL."
5587 :type '(choice (function-item :tag "Browse Url" browse-url)
5588 (function :tag "Other"))
5589 :group 'gnus-article-buttons)
5591 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5592 "Bogus strings removed from CTAN URLs."
5593 :group 'gnus-article-buttons
5594 :type '(choice (const "^/?tex-archive/\\|/")
5595 (regexp :tag "Other")))
5597 (defcustom gnus-button-mid-or-mail-regexp
5598 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5599 gnus-button-valid-fqdn-regexp
5601 "Regular expression that matches a message ID or a mail address."
5602 :group 'gnus-article-buttons
5605 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5606 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5607 Strings like this can be either a message ID or a mail address. If it is one
5608 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5609 message ID or a mail address, respectivly. If this variable is set to the
5610 symbol `ask', always query the user what do do. If it is a function, this
5611 function will be called with the string as it's only argument. The function
5612 must return `mid', `mail', `invalid' or `ask'."
5613 :group 'gnus-article-buttons
5614 :type '(choice (function-item :tag "Heuristic function"
5615 gnus-button-mid-or-mail-heuristic)
5620 (defcustom gnus-button-mid-or-mail-heuristic-alist
5621 '((-10.0 . ".+\\$.+@")
5624 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5625 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5626 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5627 (-1.0 . "^[^a-z]+@")
5629 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5630 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5631 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5632 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5635 (-1.0 . "^[0-9][0-9]")
5637 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5638 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5639 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5640 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5642 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5643 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5646 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5648 ;; compensation for TDMA dated mail addresses:
5649 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5651 (-20.0 . "\\.fsf@") ;; Gnus
5654 (-20.0 . "_-_") ;; Subject change in thread
5656 (-20.0 . "\\.ln@") ;; leafnode
5657 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5658 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5660 ;; (5.0 . "") ;; $local_part_len <= 7
5661 (10.0 . "^[^0-9]+@")
5662 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5663 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5666 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5668 (0.5 . "^[A-Z][a-z]")
5669 (0.5 . "^[A-Z][a-z][a-z]")
5670 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5671 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5672 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5674 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5675 address. The REGEXP is processed with `case-fold-search' set to `nil'."
5676 :group 'gnus-article-buttons
5677 :type '(repeat (cons (number :tag "Rate")
5678 (regexp :tag "Regexp"))))
5680 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5681 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5682 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5683 address, `ask' if unsure and `invalid' if the string is invalid."
5684 (let ((case-fold-search nil)
5685 (list gnus-button-mid-or-mail-heuristic-alist)
5686 (result 0) rate regexp lpartlen elem)
5688 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5689 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5690 ;; Certain special cases...
5693 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5694 "^[0-9]+\.[0-9]+\@compuserve")
5696 (gnus-message 8 "`%s' is a known mail address.")
5697 (setq result 'mail))
5698 (when (string-match "@.*@\\| " mid-or-mail)
5699 (gnus-message 8 "`%s' is invalid.")
5700 (setq result 'invalid))
5701 ;; Nothing more to do, if result is not a number here...
5702 (when (numberp result)
5704 (setq elem (car list)
5708 (when (string-match regexp mid-or-mail)
5709 (setq result (+ result rate))
5711 9 "`%s' matched `%s', rate `%s', result `%s'."
5712 mid-or-mail regexp rate result)))
5713 (when (<= lpartlen 7)
5714 (setq result (+ result 5.0))
5715 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5716 mid-or-mail result))
5717 (when (>= lpartlen 12)
5718 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5720 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5721 ;; Long local part should contain realname if e-mail address,
5722 ;; too many digits: message-id.
5723 ;; $score -= 5.0 + 0.1 * $local_part_len;
5724 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5725 (setq result (+ result rate))
5727 9 "Many digits in `%s', rate `%s', result `%s'."
5728 mid-or-mail rate result))
5729 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5731 ;; Too few vowels [^aeiouy]{4,}.*\@
5732 (setq result (+ result -5.0))
5734 9 "Few vowels in `%s', rate `%s', result `%s'."
5735 mid-or-mail -5.0 result))
5737 (setq result (+ result 5.0))
5739 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5740 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5742 ;; Maybe we should make this a customizable alist: (condition . 'result)
5743 ((< result -10.0) 'mid)
5744 ((> result 10.0) 'mail)
5747 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5748 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5749 (url-mid (concat "news" ":" mid-or-mail))
5750 (url-mailto (concat "mailto" ":" mid-or-mail)))
5751 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5752 (when (fboundp pref)
5754 ;; get rid of surrounding angles...
5756 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5757 (if (or (eq 'mid guessed) (eq 'mail guessed))
5761 (save-window-excursion
5762 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5765 (cond ((eq pref 'mid)
5766 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5767 (gnus-button-handle-news url-mid))
5769 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5770 (gnus-url-mailto url-mailto))
5771 (t (gnus-message 3 "Invalid string.")))))
5773 (defun gnus-button-handle-custom (url)
5774 "Follow a Custom URL."
5775 (customize-apropos (gnus-url-unhex-string url)))
5777 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5779 (defun gnus-button-handle-describe-function (url)
5780 "Call `describe-function' when pushing the corresponding URL button."
5783 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5785 (defun gnus-button-handle-describe-variable (url)
5786 "Call `describe-variable' when pushing the corresponding URL button."
5789 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5791 (defun gnus-button-handle-describe-key (url)
5792 "Call `describe-key' when pushing the corresponding URL button."
5794 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5795 (keys (ignore-errors (eval `(kbd ,key-string)))))
5798 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5800 (defun gnus-button-handle-apropos (url)
5801 "Call `apropos' when pushing the corresponding URL button."
5802 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5804 (defun gnus-button-handle-apropos-command (url)
5805 "Call `apropos' when pushing the corresponding URL button."
5807 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5809 (defun gnus-button-handle-apropos-variable (url)
5810 "Call `apropos' when pushing the corresponding URL button."
5812 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5813 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5815 (defun gnus-button-handle-apropos-documentation (url)
5816 "Call `apropos' when pushing the corresponding URL button."
5818 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5819 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5821 (defun gnus-button-handle-ctan (url)
5822 "Call `browse-url' when pushing a CTAN URL button."
5824 gnus-button-ctan-handler
5827 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5829 (defcustom gnus-button-tex-level 5
5830 "*Integer that says how many TeX-related buttons Gnus will show.
5831 The higher the number, the more buttons will appear and the more false
5832 positives are possible. Note that you can set this variable local to
5833 specifific groups. Setting it higher in TeX groups is probably a good idea.
5834 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5835 how to set variables in specific groups."
5836 :group 'gnus-article-buttons
5837 :link '(custom-manual "(gnus)Group Parameters")
5840 (defcustom gnus-button-man-level 5
5841 "*Integer that says how many man-related buttons Gnus will show.
5842 The higher the number, the more buttons will appear and the more false
5843 positives are possible. Note that you can set this variable local to
5844 specifific groups. Setting it higher in Unix groups is probably a good idea.
5845 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5846 how to set variables in specific groups."
5847 :group 'gnus-article-buttons
5848 :link '(custom-manual "(gnus)Group Parameters")
5851 (defcustom gnus-button-emacs-level 5
5852 "*Integer that says how many emacs-related buttons Gnus will show.
5853 The higher the number, the more buttons will appear and the more false
5854 positives are possible. Note that you can set this variable local to
5855 specifific groups. Setting it higher in Emacs or Gnus related groups is
5856 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5857 `gnus-parameters' on how to set variables in specific groups."
5858 :group 'gnus-article-buttons
5859 :link '(custom-manual "(gnus)Group Parameters")
5862 (defcustom gnus-button-mail-level 5
5863 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5864 The higher the number, the more buttons will appear and the more false
5865 positives are possible."
5866 :group 'gnus-article-buttons
5869 (defcustom gnus-button-alist
5870 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5871 0 t gnus-button-handle-news 3)
5872 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5873 gnus-button-handle-news 2)
5874 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5876 gnus-button-fetch-group 4)
5877 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5878 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5879 t gnus-button-message-id 3)
5880 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5881 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5882 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5884 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5885 gnus-button-handle-ctan 1)
5887 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5888 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5890 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5891 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5892 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5893 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5894 ;; Emacs help commands
5895 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5896 ;; regexp doesn't match arguments containing ` '.
5897 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5898 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5899 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5900 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5901 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5902 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5903 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5904 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5905 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5906 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5907 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5908 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
5909 ;; Unlike the other regexps we really have to require quoting
5910 ;; here to determine where it ends.
5911 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
5912 ;; This is how URLs _should_ be embedded in text...
5913 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5915 (gnus-button-url-regexp 0 t browse-url 0)
5917 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5918 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5919 gnus-button-handle-man 1)
5920 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5921 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
5922 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5923 gnus-button-handle-man 1)
5924 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5925 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5926 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5927 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5928 ;; MID or mail: To avoid too many false positives we don't try to catch
5929 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5930 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5931 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5932 ;; so that non-ambiguous entries (see above) match first.
5933 (gnus-button-mid-or-mail-regexp
5934 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5935 "*Alist of regexps matching buttons in article bodies.
5937 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5938 REGEXP: is the string (case insensitive) matching text around the button (can
5939 also be lisp expression evaluating to a string),
5940 BUTTON: is the number of the regexp grouping actually matching the button,
5941 FORM: is a lisp expression which must eval to true for the button to
5943 CALLBACK: is the function to call when the user push this button, and each
5944 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5946 CALLBACK can also be a variable, in that case the value of that
5947 variable it the real callback function."
5948 :group 'gnus-article-buttons
5949 :type '(repeat (list (choice regexp variable)
5950 (integer :tag "Button")
5952 (function :tag "Callback")
5955 (integer :tag "Regexp group")))))
5957 (defcustom gnus-header-button-alist
5958 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5959 0 t gnus-button-message-id 0)
5960 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5961 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5962 0 t gnus-button-mailto 0)
5963 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5964 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5965 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5966 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5967 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5968 gnus-button-message-id 3))
5969 "*Alist of headers and regexps to match buttons in article heads.
5971 This alist is very similar to `gnus-button-alist', except that each
5972 alist has an additional HEADER element first in each entry:
5974 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5976 HEADER is a regexp to match a header. For a fuller explanation, see
5977 `gnus-button-alist'."
5978 :group 'gnus-article-buttons
5979 :group 'gnus-article-headers
5980 :type '(repeat (list (regexp :tag "Header")
5982 (integer :tag "Button")
5984 (function :tag "Callback")
5987 (integer :tag "Regexp group")))))
5989 (defvar gnus-button-regexp nil)
5990 (defvar gnus-button-marker-list nil)
5991 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5993 (defvar gnus-button-last nil)
5994 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5998 (defun gnus-article-push-button (event)
5999 "Check text under the mouse pointer for a callback function.
6000 If the text under the mouse pointer has a `gnus-callback' property,
6001 call it with the value of the `gnus-data' text property."
6003 (set-buffer (window-buffer (posn-window (event-start event))))
6004 (let* ((pos (posn-point (event-start event)))
6005 (data (get-text-property pos 'gnus-data))
6006 (fun (get-text-property pos 'gnus-callback)))
6009 (funcall fun data))))
6011 (defun gnus-article-press-button ()
6012 "Check text at point for a callback function.
6013 If the text at point has a `gnus-callback' property,
6014 call it with the value of the `gnus-data' text property."
6016 (let ((data (get-text-property (point) 'gnus-data))
6017 (fun (get-text-property (point) 'gnus-callback)))
6019 (funcall fun data))))
6021 (defun gnus-article-highlight (&optional force)
6022 "Highlight current article.
6023 This function calls `gnus-article-highlight-headers',
6024 `gnus-article-highlight-citation',
6025 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6026 do the highlighting. See the documentation for those functions."
6027 (interactive (list 'force))
6028 (gnus-article-highlight-headers)
6029 (gnus-article-highlight-citation force)
6030 (gnus-article-highlight-signature)
6031 (gnus-article-add-buttons force)
6032 (gnus-article-add-buttons-to-head))
6034 (defun gnus-article-highlight-some (&optional force)
6035 "Highlight current article.
6036 This function calls `gnus-article-highlight-headers',
6037 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6038 do the highlighting. See the documentation for those functions."
6039 (interactive (list 'force))
6040 (gnus-article-highlight-headers)
6041 (gnus-article-highlight-signature)
6042 (gnus-article-add-buttons))
6044 (defun gnus-article-highlight-headers ()
6045 "Highlight article headers as specified by `gnus-header-face-alist'."
6048 (set-buffer gnus-article-buffer)
6050 (let ((alist gnus-header-face-alist)
6051 (buffer-read-only nil)
6052 (case-fold-search t)
6053 (inhibit-point-motion-hooks t)
6054 entry regexp header-face field-face from hpoints fpoints)
6055 (article-narrow-to-head)
6056 (while (setq entry (pop alist))
6057 (goto-char (point-min))
6058 (setq regexp (concat "^\\("
6059 (if (string-equal "" (nth 0 entry))
6063 header-face (nth 1 entry)
6064 field-face (nth 2 entry))
6065 (while (and (re-search-forward regexp nil t)
6069 (unless (search-forward ":" nil t)
6071 (when (and header-face
6072 (not (memq (point) hpoints)))
6073 (push (point) hpoints)
6074 (gnus-put-text-property from (point) 'face header-face))
6075 (when (and field-face
6076 (not (memq (setq from (point)) fpoints)))
6078 (if (re-search-forward "^[^ \t]" nil t)
6080 (goto-char (point-max)))
6081 (gnus-put-text-property from (point) 'face field-face))))))))
6083 (defun gnus-article-highlight-signature ()
6084 "Highlight the signature in an article.
6085 It does this by highlighting everything after
6086 `gnus-signature-separator' using `gnus-signature-face'."
6089 (set-buffer gnus-article-buffer)
6090 (let ((buffer-read-only nil)
6091 (inhibit-point-motion-hooks t))
6093 (when (and gnus-signature-face
6094 (gnus-article-narrow-to-signature))
6095 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6096 'face gnus-signature-face)
6098 (gnus-article-search-signature)
6099 (let ((start (match-beginning 0))
6100 (end (set-marker (make-marker) (1+ (match-end 0)))))
6101 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6104 (defun gnus-button-in-region-p (b e prop)
6105 "Say whether PROP exists in the region."
6106 (text-property-not-all b e prop nil))
6108 (defun gnus-article-add-buttons (&optional force)
6109 "Find external references in the article and make buttons of them.
6110 \"External references\" are things like Message-IDs and URLs, as
6111 specified by `gnus-button-alist'."
6112 (interactive (list 'force))
6114 (set-buffer gnus-article-buffer)
6115 (let ((buffer-read-only nil)
6116 (inhibit-point-motion-hooks t)
6117 (case-fold-search t)
6118 (alist gnus-button-alist)
6120 ;; Remove all old markers.
6121 (let (marker entry new-list)
6122 (while (setq marker (pop gnus-button-marker-list))
6123 (if (or (< marker (point-min)) (>= marker (point-max)))
6124 (push marker new-list)
6126 (when (setq entry (gnus-button-entry))
6127 (put-text-property (match-beginning (nth 1 entry))
6128 (match-end (nth 1 entry))
6129 'gnus-callback nil))
6130 (set-marker marker nil)))
6131 (setq gnus-button-marker-list new-list))
6132 ;; We skip the headers.
6135 (while (setq entry (pop alist))
6136 (setq regexp (eval (car entry)))
6138 (while (re-search-forward regexp nil t)
6139 (let* ((start (and entry (match-beginning (nth 1 entry))))
6140 (end (and entry (match-end (nth 1 entry))))
6141 (from (match-beginning 0)))
6142 (when (and (or (eq t (nth 2 entry))
6143 (eval (nth 2 entry)))
6144 (not (gnus-button-in-region-p
6145 start end 'gnus-callback)))
6146 ;; That optional form returned non-nil, so we add the
6148 (gnus-article-add-button
6149 start end 'gnus-button-push
6150 (car (push (set-marker (make-marker) from)
6151 gnus-button-marker-list))))))))))
6153 ;; Add buttons to the head of an article.
6154 (defun gnus-article-add-buttons-to-head ()
6155 "Add buttons to the head of the article."
6158 (set-buffer gnus-article-buffer)
6160 (let ((buffer-read-only nil)
6161 (inhibit-point-motion-hooks t)
6162 (case-fold-search t)
6163 (alist gnus-header-button-alist)
6165 (article-narrow-to-head)
6167 ;; Each alist entry.
6168 (setq entry (car alist)
6170 (goto-char (point-min))
6171 (while (re-search-forward (car entry) nil t)
6172 ;; Each header matching the entry.
6173 (setq beg (match-beginning 0))
6174 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6175 (match-beginning 0))
6178 (while (re-search-forward (eval (nth 1 entry)) end t)
6179 ;; Each match within a header.
6180 (let* ((entry (cdr entry))
6181 (start (match-beginning (nth 1 entry)))
6182 (end (match-end (nth 1 entry)))
6183 (form (nth 2 entry)))
6184 (goto-char (match-end 0))
6186 (gnus-article-add-button
6187 start end (nth 3 entry)
6188 (buffer-substring (match-beginning (nth 4 entry))
6189 (match-end (nth 4 entry)))))))
6190 (goto-char end)))))))
6192 ;;; External functions:
6194 (defun gnus-article-add-button (from to fun &optional data)
6195 "Create a button between FROM and TO with callback FUN and data DATA."
6196 (when gnus-article-button-face
6197 (gnus-overlay-put (gnus-make-overlay from to)
6198 'face gnus-article-button-face))
6199 (gnus-add-text-properties
6201 (nconc (and gnus-article-mouse-face
6202 (list gnus-mouse-face-prop gnus-article-mouse-face))
6203 (list 'gnus-callback fun)
6204 (and data (list 'gnus-data data))))
6205 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6206 :button-keymap gnus-widget-button-keymap))
6208 ;;; Internal functions:
6210 (defun gnus-article-set-globals ()
6212 (set-buffer gnus-summary-buffer)
6213 (gnus-set-global-variables)))
6215 (defun gnus-signature-toggle (end)
6217 (set-buffer gnus-article-buffer)
6218 (let ((buffer-read-only nil)
6219 (inhibit-point-motion-hooks t))
6220 (if (text-property-any end (point-max) 'article-type 'signature)
6222 (gnus-delete-wash-type 'signature)
6223 (gnus-remove-text-properties-when
6224 'article-type 'signature end (point-max)
6225 (cons 'article-type (cons 'signature
6226 gnus-hidden-properties))))
6227 (gnus-add-wash-type 'signature)
6228 (gnus-add-text-properties-when
6229 'article-type nil end (point-max)
6230 (cons 'article-type (cons 'signature
6231 gnus-hidden-properties)))))
6232 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6233 (gnus-set-mode-line 'article))))
6235 (defun gnus-button-entry ()
6236 ;; Return the first entry in `gnus-button-alist' matching this place.
6237 (let ((alist gnus-button-alist)
6240 (setq entry (pop alist))
6241 (if (looking-at (eval (car entry)))
6246 (defun gnus-button-push (marker)
6247 ;; Push button starting at MARKER.
6250 (let* ((entry (gnus-button-entry))
6251 (inhibit-point-motion-hooks t)
6253 (args (mapcar (lambda (group)
6254 (let ((string (match-string group)))
6255 (gnus-set-text-properties
6256 0 (length string) nil string)
6263 (fboundp (symbol-value fun)))
6264 (apply (symbol-value fun) args))
6266 (gnus-message 1 "You must define `%S' to use this button"
6267 (cons fun args)))))))
6269 (defun gnus-parse-news-url (url)
6270 (let (scheme server group message-id articles)
6273 (goto-char (point-min))
6274 (when (looking-at "\\([A-Za-z]+\\):")
6275 (setq scheme (match-string 1))
6276 (goto-char (match-end 0)))
6277 (when (looking-at "//\\([^/]+\\)/")
6278 (setq server (match-string 1))
6279 (goto-char (match-end 0)))
6282 ((looking-at "\\(.*@.*\\)")
6283 (setq message-id (match-string 1)))
6284 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6285 (setq group (match-string 1)
6286 articles (split-string (match-string 2) "-")))
6287 ((looking-at "\\([^/]+\\)/?")
6288 (setq group (match-string 1)))
6290 (error "Unknown news URL syntax"))))
6291 (list scheme server group message-id articles)))
6293 (defun gnus-button-handle-news (url)
6295 (destructuring-bind (scheme server group message-id articles)
6296 (gnus-parse-news-url url)
6300 (set-buffer gnus-summary-buffer)
6302 (let ((gnus-refer-article-method (list (list 'nntp server))))
6303 (gnus-summary-refer-article message-id))
6304 (gnus-summary-refer-article message-id))))
6306 (gnus-button-fetch-group url)))))
6308 (defun gnus-button-handle-man (url)
6310 (funcall gnus-button-man-handler url))
6312 (defun gnus-button-handle-info (url)
6313 "Fetch an info URL."
6315 "^\\([^:/]+\\)?/\\(.*\\)"
6317 (gnus-info-find-node
6318 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6321 (gnus-url-unhex-string (match-string 2 url))))
6322 (error "Can't parse %s" url)))
6324 (defun gnus-button-message-id (message-id)
6327 (set-buffer gnus-summary-buffer)
6328 (gnus-summary-refer-article message-id)))
6330 (defun gnus-button-fetch-group (address)
6331 "Fetch GROUP specified by ADDRESS."
6332 (if (not (string-match "[:/]" address))
6333 ;; This is just a simple group url.
6334 (gnus-group-read-ephemeral-group address gnus-select-method)
6337 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6339 (error "Can't parse %s" address)
6340 (gnus-group-read-ephemeral-group
6341 (match-string 4 address)
6342 `(nntp ,(match-string 1 address)
6343 (nntp-address ,(match-string 1 address))
6344 (nntp-port-number ,(if (match-end 3)
6345 (match-string 3 address)
6348 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6350 (defun gnus-url-parse-query-string (query &optional downcase)
6351 (let (retval pairs cur key val)
6352 (setq pairs (split-string query "&"))
6354 (setq cur (car pairs)
6356 (if (not (string-match "=" cur))
6358 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6359 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6361 (setq key (downcase key)))
6362 (setq cur (assoc key retval))
6364 (setcdr cur (cons val (cdr cur)))
6365 (setq retval (cons (list key val) retval)))))
6368 (defun gnus-url-mailto (url)
6369 ;; Send mail to someone
6370 (when (string-match "mailto:/*\\(.*\\)" url)
6371 (setq url (substring url (match-beginning 1) nil)))
6372 (let (to args subject func)
6373 (if (string-match (regexp-quote "?") url)
6374 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6375 args (gnus-url-parse-query-string
6376 (substring url (match-end 0) nil) t))
6377 (setq to (gnus-url-unhex-string url)))
6378 (setq args (cons (list "to" to) args)
6379 subject (cdr-safe (assoc "subject" args)))
6382 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6385 (message-position-on-field (caar args)))
6386 (insert (mapconcat 'identity (cdar args) ", "))
6387 (setq args (cdr args)))
6390 (message-goto-subject))))
6392 (defun gnus-button-embedded-url (address)
6393 "Activate ADDRESS with `browse-url'."
6394 (browse-url (gnus-strip-whitespace address)))
6396 ;;; Next/prev buttons in the article buffer.
6398 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6399 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6401 (defvar gnus-prev-page-map
6402 (let ((map (make-sparse-keymap)))
6403 (unless (>= emacs-major-version 21)
6404 ;; XEmacs doesn't care.
6405 (set-keymap-parent map gnus-article-mode-map))
6406 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6407 (define-key map "\r" 'gnus-button-prev-page)
6410 (defun gnus-insert-prev-page-button ()
6412 (buffer-read-only nil))
6414 gnus-prev-page-line-format nil
6415 `(,@(gnus-local-map-property gnus-prev-page-map)
6417 gnus-callback gnus-article-button-prev-page
6418 article-type annotation))
6419 (widget-convert-button
6421 ;; Exclude a newline.
6424 :action 'gnus-button-prev-page
6425 :button-keymap gnus-prev-page-map)))
6427 (defvar gnus-prev-page-map
6428 (let ((map (make-sparse-keymap)))
6429 (unless (>= emacs-major-version 21)
6430 ;; XEmacs doesn't care.
6431 (set-keymap-parent map gnus-article-mode-map))
6432 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6433 (define-key map "\r" 'gnus-button-prev-page)
6436 (defvar gnus-next-page-map
6437 (let ((map (make-sparse-keymap)))
6438 (unless (>= emacs-major-version 21)
6439 ;; XEmacs doesn't care.
6440 (set-keymap-parent map gnus-article-mode-map))
6441 (define-key map gnus-mouse-2 'gnus-button-next-page)
6442 (define-key map "\r" 'gnus-button-next-page)
6445 (defun gnus-button-next-page (&optional args more-args)
6446 "Go to the next page."
6448 (let ((win (selected-window)))
6449 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6450 (gnus-article-next-page)
6451 (select-window win)))
6453 (defun gnus-button-prev-page (&optional args more-args)
6454 "Go to the prev page."
6456 (let ((win (selected-window)))
6457 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6458 (gnus-article-prev-page)
6459 (select-window win)))
6461 (defun gnus-insert-next-page-button ()
6463 (buffer-read-only nil))
6464 (gnus-eval-format gnus-next-page-line-format nil
6465 `(,@(gnus-local-map-property gnus-next-page-map)
6467 gnus-callback gnus-article-button-next-page
6468 article-type annotation))
6469 (widget-convert-button
6471 ;; Exclude a newline.
6474 :action 'gnus-button-next-page
6475 :button-keymap gnus-next-page-map)))
6477 (defun gnus-article-button-next-page (arg)
6478 "Go to the next page."
6480 (let ((win (selected-window)))
6481 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6482 (gnus-article-next-page)
6483 (select-window win)))
6485 (defun gnus-article-button-prev-page (arg)
6486 "Go to the prev page."
6488 (let ((win (selected-window)))
6489 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6490 (gnus-article-prev-page)
6491 (select-window win)))
6493 (defvar gnus-decode-header-methods
6494 '(mail-decode-encoded-word-region)
6495 "List of methods used to decode headers.
6497 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6498 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6499 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6500 whose names match REGEXP.
6503 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6504 mail-decode-encoded-word-region
6505 (\"chinese\" . rfc1843-decode-region))
6508 (defvar gnus-decode-header-methods-cache nil)
6510 (defun gnus-multi-decode-header (start end)
6511 "Apply the functions from `gnus-encoded-word-methods' that match."
6512 (unless (and gnus-decode-header-methods-cache
6513 (eq gnus-newsgroup-name
6514 (car gnus-decode-header-methods-cache)))
6515 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6518 (nconc gnus-decode-header-methods-cache (list x))
6519 (if (and gnus-newsgroup-name
6520 (string-match (car x) gnus-newsgroup-name))
6521 (nconc gnus-decode-header-methods-cache
6523 gnus-decode-header-methods))
6524 (let ((xlist gnus-decode-header-methods-cache))
6527 (narrow-to-region start end)
6529 (funcall (pop xlist) (point-min) (point-max))))))
6532 ;;; Treatment top-level handling.
6535 (defun gnus-treat-article (condition &optional part-number total-parts type)
6536 (let ((length (- (point-max) (point-min)))
6537 (alist gnus-treatment-function-alist)
6538 (article-goto-body-goes-to-point-min-p t)
6542 (let ((list gnus-article-treat-types))
6544 (when (string-match (pop list) type)
6545 (throw 'found t)))))))
6546 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6548 (gnus-run-hooks 'gnus-part-display-hook)
6549 (dolist (elem alist)
6552 (when (gnus-buffer-live-p gnus-summary-buffer)
6553 (set-buffer gnus-summary-buffer))
6554 (symbol-value (car elem))))
6555 (when (and (or (consp val)
6557 (gnus-treat-predicate val)
6558 (or (not (get (car elem) 'highlight))
6561 (funcall (cadr elem)))))))
6563 ;; Dynamic variables.
6565 (defvar part-number)
6566 (defvar total-parts)
6571 (defun gnus-treat-predicate (val)
6578 (stringp (car val)))
6579 (apply 'gnus-or (mapcar `(lambda (s)
6580 (string-match s ,(or gnus-newsgroup-name "")))
6583 (let ((pred (pop val)))
6586 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6588 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6590 (not (gnus-treat-predicate (car val))))
6592 (equal (car val) type))
6594 (error "%S is not a valid predicate" pred)))))
6600 (eq part-number total-parts))
6604 (error "%S is not a valid value" val))))
6606 (defun gnus-article-encrypt-body (protocol &optional n)
6607 "Encrypt the article body."
6610 (or gnus-article-encrypt-protocol
6611 (completing-read "Encrypt protocol: "
6612 gnus-article-encrypt-protocol-alist
6614 current-prefix-arg))
6615 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6617 (error (format "Can't find the encrypt protocol %s" protocol)))
6618 (if (member gnus-newsgroup-name '("nndraft:delayed"
6621 (error "Can't encrypt the article in group %s"
6622 gnus-newsgroup-name))
6623 (gnus-summary-iterate n
6625 (set-buffer gnus-summary-buffer)
6626 (let ((mail-parse-charset gnus-newsgroup-charset)
6627 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6628 (summary-buffer gnus-summary-buffer)
6630 (gnus-set-global-variables)
6631 (when (gnus-group-read-only-p)
6632 (error "The current newsgroup does not support article encrypt"))
6633 (gnus-summary-show-article t)
6635 (or (mail-header-references gnus-current-headers) ""))
6636 (set-buffer gnus-article-buffer)
6637 (let* ((buffer-read-only nil)
6639 (mapcar (lambda (field)
6640 (and (save-restriction
6641 (message-narrow-to-head)
6642 (goto-char (point-min))
6643 (search-forward field nil t))
6645 (message-narrow-to-field)
6647 (delete-region (point-min) (point-max))
6649 '("Content-Type:" "Content-Transfer-Encoding:"
6650 "Content-Disposition:"))))
6651 (message-narrow-to-head)
6652 (message-remove-header "MIME-Version")
6653 (goto-char (point-max))
6654 (setq point (point))
6655 (insert (apply 'concat headers))
6657 (narrow-to-region point (point-max))
6658 (let ((message-options message-options))
6659 (message-options-set 'message-sender user-mail-address)
6660 (message-options-set 'message-recipients user-mail-address)
6661 (message-options-set 'message-sign-encrypt 'not)
6663 (goto-char (point-min))
6664 (insert "MIME-Version: 1.0\n")
6666 (gnus-summary-edit-article-done
6667 references nil summary-buffer t))
6668 (when gnus-keep-backlog
6669 (gnus-backlog-remove-article
6670 (car gnus-article-current) (cdr gnus-article-current)))
6672 (when (get-buffer gnus-original-article-buffer)
6673 (set-buffer gnus-original-article-buffer)
6674 (setq gnus-original-article nil)))
6675 (when gnus-use-cache
6676 (gnus-cache-update-article
6677 (car gnus-article-current) (cdr gnus-article-current))))))))
6679 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6680 "The following specs can be used:
6681 %t The security MIME type
6684 %D Details if button is pressed")
6686 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6687 "The following specs can be used:
6688 %t The security MIME type
6691 %D Details if button is pressed")
6693 (defvar gnus-mime-security-button-line-format-alist
6694 '((?t gnus-tmp-type ?s)
6695 (?i gnus-tmp-info ?s)
6696 (?d gnus-tmp-details ?s)
6697 (?D gnus-tmp-pressed-details ?s)))
6699 (defvar gnus-mime-security-button-map
6700 (let ((map (make-sparse-keymap)))
6701 (unless (>= (string-to-number emacs-version) 21)
6702 (set-keymap-parent map gnus-article-mode-map))
6703 (define-key map gnus-mouse-2 'gnus-article-push-button)
6704 (define-key map "\r" 'gnus-article-press-button)
6707 (defvar gnus-mime-security-details-buffer nil)
6709 (defvar gnus-mime-security-button-pressed nil)
6711 (defvar gnus-mime-security-show-details-inline t
6712 "If non-nil, show details in the article buffer.")
6714 (defun gnus-mime-security-verify-or-decrypt (handle)
6715 (mm-remove-parts (cdr handle))
6716 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6717 point buffer-read-only)
6719 (goto-char (car region)))
6721 (narrow-to-region (point) (point))
6722 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6723 (let* ((mm-verify-option 'known)
6724 (mm-decrypt-option 'known)
6725 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6726 (unless (eq nparts (cdr handle))
6727 (mm-destroy-parts (cdr handle))
6728 (setcdr handle nparts))))
6729 (setq point (point))
6730 (gnus-mime-display-security handle)
6731 (goto-char (point-max)))
6733 (delete-region (point) (cdr region))
6734 (set-marker (car region) nil)
6735 (set-marker (cdr region) nil))
6738 (defun gnus-mime-security-show-details (handle)
6739 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6741 (gnus-message 5 "No details.")
6742 (if gnus-mime-security-show-details-inline
6743 (let ((gnus-mime-security-button-pressed
6744 (not (get-text-property (point) 'gnus-mime-details)))
6745 (gnus-mime-security-button-line-format
6746 (get-text-property (point) 'gnus-line-format))
6749 (while (eq (get-text-property (point) 'gnus-line-format)
6750 gnus-mime-security-button-line-format)
6754 (narrow-to-region (point) (point))
6755 (gnus-insert-mime-security-button handle))
6756 (delete-region (point)
6757 (or (text-property-not-all
6760 gnus-mime-security-button-line-format)
6763 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6764 (with-current-buffer gnus-mime-security-details-buffer
6767 (setq gnus-mime-security-details-buffer
6768 (gnus-get-buffer-create "*MIME Security Details*")))
6769 (with-current-buffer gnus-mime-security-details-buffer
6771 (goto-char (point-min)))
6772 (pop-to-buffer gnus-mime-security-details-buffer)))))
6774 (defun gnus-mime-security-press-button (handle)
6776 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6777 (gnus-mime-security-show-details handle)
6778 (gnus-mime-security-verify-or-decrypt handle))))
6780 (defun gnus-insert-mime-security-button (handle &optional displayed)
6781 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6784 (or (nth 2 (assoc protocol mm-verify-function-alist))
6785 (nth 2 (assoc protocol mm-decrypt-function-alist))
6787 (if (equal (car handle) "multipart/signed")
6788 " Signed" " Encrypted")
6791 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6794 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6795 gnus-tmp-pressed-details
6797 (setq gnus-tmp-details
6798 (if gnus-tmp-details
6799 (concat "\n" gnus-tmp-details)
6801 (setq gnus-tmp-pressed-details
6802 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6807 gnus-mime-security-button-line-format
6808 gnus-mime-security-button-line-format-alist
6809 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6810 gnus-callback gnus-mime-security-press-button
6811 gnus-line-format ,gnus-mime-security-button-line-format
6812 gnus-mime-details ,gnus-mime-security-button-pressed
6813 article-type annotation
6816 ;; Exclude a newline.
6819 (widget-convert-button
6822 :action 'gnus-widget-press-button
6823 :button-keymap gnus-mime-security-button-map
6825 (lambda (widget/window &optional overlay pos)
6826 ;; Needed to properly clear the message due to a bug in
6827 ;; wid-edit (XEmacs only).
6828 (when (boundp 'help-echo-owns-message)
6829 (setq help-echo-owns-message t))
6832 (aref gnus-mouse-2 0))))))
6834 (defun gnus-mime-display-security (handle)
6836 (narrow-to-region (point) (point))
6837 (unless (gnus-unbuttonized-mime-type-p (car handle))
6838 (gnus-insert-mime-security-button handle))
6839 (gnus-mime-display-mixed (cdr handle))
6842 (unless (gnus-unbuttonized-mime-type-p (car handle))
6843 (let ((gnus-mime-security-button-line-format
6844 gnus-mime-security-button-end-line-format))
6845 (gnus-insert-mime-security-button handle)))
6846 (mm-set-handle-multipart-parameter
6848 (cons (set-marker (make-marker) (point-min))
6849 (set-marker (make-marker) (point-max))))))
6855 (run-hooks 'gnus-art-load-hook)
6857 ;;; gnus-art.el ends here