1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
49 (autoload 'ansi-color-apply-on-region "ansi-color")
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
115 (concat "^" header ":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type '(choice :custom-show nil
160 :group 'gnus-article-hiding)
162 (defcustom gnus-visible-headers
163 "^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:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type '(repeat :value-to-internal (lambda (widget value)
168 (custom-split-regexp-maybe value))
169 :match (lambda (widget value)
171 (widget-editable-list-match widget value)))
173 :group 'gnus-article-hiding)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type '(repeat regexp)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "To identical to To-list." to-list)
203 (const :tag "CC identical to To-list." cc-list)
204 (const :tag "Followup-to identical to Newsgroups." followup-to)
205 (const :tag "Reply-to identical to From." reply-to)
206 (const :tag "Date less than four days old." date)
207 (const :tag "To and/or Cc longer than 1024 characters." long-to)
208 (const :tag "Multiple To and/or Cc headers." many-to))
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
219 :group 'gnus-article-hiding)
221 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
222 "Regexp matching signature separator.
223 This can also be a list of regexps. In that case, it will be checked
224 from head to tail looking for a separator. Searches will be done from
225 the end of the buffer."
226 :type '(repeat string)
227 :group 'gnus-article-signature)
229 (defcustom gnus-signature-limit nil
230 "Provide a limit to what is considered a signature.
231 If it is a number, no signature may not be longer (in characters) than
232 that number. If it is a floating point number, no signature may be
233 longer (in lines) than that number. If it is a function, the function
234 will be called without any parameters, and if it returns nil, there is
235 no signature in the buffer. If it is a string, it will be used as a
236 regexp. If it matches, the text in question is not a signature.
238 This can also be a list of the above values."
239 :type '(choice (integer :value 200)
241 (function :value fun)
242 (regexp :value ".*"))
243 :group 'gnus-article-signature)
245 (defcustom gnus-hidden-properties '(invisible t intangible t)
246 "Property list to use for hiding text."
248 :group 'gnus-article-hiding)
250 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
251 ;; frames in a session.
252 (defcustom gnus-article-x-face-command
253 (if (featurep 'xemacs)
254 (if (or (gnus-image-type-available-p 'xface)
255 (gnus-image-type-available-p 'pbm))
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
258 (if (gnus-image-type-available-p 'pbm)
259 'gnus-display-x-face-in-from
260 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
262 "*String or function to be executed to display an X-Face header.
263 If it is a string, the command will be executed in a sub-shell
264 asynchronously. The compressed face will be piped to this command."
265 :type `(choice string
266 (function-item gnus-display-x-face-in-from)
270 :group 'gnus-article-washing)
272 (defcustom gnus-article-x-face-too-ugly nil
273 "Regexp matching posters whose face shouldn't be shown automatically."
274 :type '(choice regexp (const nil))
275 :group 'gnus-article-washing)
277 (defcustom gnus-article-banner-alist nil
278 "Banner alist for stripping.
280 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
282 :type '(repeat (cons symbol regexp))
283 :group 'gnus-article-washing)
285 (gnus-define-group-parameter
288 "Alist of regexps (to match group names) and banner."
289 :variable-group gnus-article-washing
291 '(choice :tag "Banner"
293 (const :tag "Remove signature" signature)
294 (symbol :tag "Item in `gnus-article-banner-alist'" none)
296 (const :tag "None" nil))
298 "If non-nil, specify how to remove `banners' from articles.
300 Symbol `signature' means to remove signatures delimited by
301 `gnus-signature-separator'. Any other symbol is used to look up a
302 regular expression to match the banner in `gnus-article-banner-alist'.
303 A string is used as a regular expression to match the banner
306 (defcustom gnus-article-address-banner-alist nil
307 "Alist of mail addresses and banners.
308 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
309 to match a mail address in the From: header, BANNER is one of a symbol
310 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
311 If ADDRESS matches author's mail address, it will remove things like
312 advertisements. For example:
314 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
318 (regexp :tag "Address")
319 (choice :tag "Banner" :value nil
320 (const :tag "Remove signature" signature)
321 (symbol :tag "Item in `gnus-article-banner-alist'" none)
323 (const :tag "None" nil))))
325 :group 'gnus-article-washing)
327 (defcustom gnus-emphasis-alist
329 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
334 ("_/" "/_" underline-italic)
335 ("_\\*" "\\*_" underline-bold)
336 ("\\*/" "/\\*" bold-italic)
337 ("_\\*/" "/\\*_" underline-bold-italic))))
341 (format format (car spec) (cadr spec))
342 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
344 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
345 2 3 gnus-emphasis-underline)))
346 "*Alist that says how to fontify certain phrases.
347 Each item looks like this:
349 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
351 The first element is a regular expression to be matched. The second
352 is a number that says what regular expression grouping used to find
353 the entire emphasized word. The third is a number that says what
354 regexp grouping should be displayed and highlighted. The fourth
355 is the face used for highlighting."
356 :type '(repeat (list :value ("" 0 0 default)
358 (integer :tag "Match group")
359 (integer :tag "Emphasize group")
361 :group 'gnus-article-emphasis)
363 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
364 "A regexp to describe whitespace which should not be emphasized.
365 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
366 The former avoids underlining of leading and trailing whitespace,
367 and the latter avoids underlining any whitespace at all."
369 :group 'gnus-article-emphasis
372 (defface gnus-emphasis-bold '((t (:bold t)))
373 "Face used for displaying strong emphasized text (*word*)."
374 :group 'gnus-article-emphasis)
376 (defface gnus-emphasis-italic '((t (:italic t)))
377 "Face used for displaying italic emphasized text (/word/)."
378 :group 'gnus-article-emphasis)
380 (defface gnus-emphasis-underline '((t (:underline t)))
381 "Face used for displaying underlined emphasized text (_word_)."
382 :group 'gnus-article-emphasis)
384 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
385 "Face used for displaying underlined bold emphasized text (_*word*_)."
386 :group 'gnus-article-emphasis)
388 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
389 "Face used for displaying underlined italic emphasized text (_/word/_)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
393 "Face used for displaying bold italic emphasized text (/*word*/)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-underline-bold-italic
397 '((t (:bold t :italic t :underline t)))
398 "Face used for displaying underlined bold italic emphasized text.
399 Example: (_/*word*/_)."
400 :group 'gnus-article-emphasis)
402 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
403 '((t (:strikethru t)))
404 '((t (:strike-through t))))
405 "Face used for displaying strike-through text (-word-)."
406 :group 'gnus-article-emphasis)
408 (defface gnus-emphasis-highlight-words
409 '((t (:background "black" :foreground "yellow")))
410 "Face used for displaying highlighted words."
411 :group 'gnus-article-emphasis)
413 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
414 "Format for display of Date headers in article bodies.
415 See `format-time-string' for the possible values.
417 The variable can also be function, which should return a complete Date
418 header. The function is called with one argument, the time, which can
419 be fed to `format-time-string'."
420 :type '(choice string function)
421 :link '(custom-manual "(gnus)Article Date")
422 :group 'gnus-article-washing)
425 (autoload 'mail-extract-address-components "mail-extr"))
427 (defcustom gnus-save-all-headers t
428 "*If non-nil, don't remove any headers before saving."
429 :group 'gnus-article-saving
432 (defcustom gnus-prompt-before-saving 'always
433 "*This variable says how much prompting is to be done when saving articles.
434 If it is nil, no prompting will be done, and the articles will be
435 saved to the default files. If this variable is `always', each and
436 every article that is saved will be preceded by a prompt, even when
437 saving large batches of articles. If this variable is neither nil not
438 `always', there the user will be prompted once for a file name for
439 each invocation of the saving commands."
440 :group 'gnus-article-saving
441 :type '(choice (item always)
442 (item :tag "never" nil)
443 (sexp :tag "once" :format "%t\n" :value t)))
445 (defcustom gnus-saved-headers gnus-visible-headers
446 "Headers to keep if `gnus-save-all-headers' is nil.
447 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
448 If that variable is nil, however, all headers that match this regexp
449 will be kept while the rest will be deleted before saving."
450 :group 'gnus-article-saving
453 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
454 "A function to save articles in your favourite format.
455 The function must be interactively callable (in other words, it must
456 be an Emacs command).
458 Gnus provides the following functions:
460 * gnus-summary-save-in-rmail (Rmail format)
461 * gnus-summary-save-in-mail (Unix mail format)
462 * gnus-summary-save-in-folder (MH folder)
463 * gnus-summary-save-in-file (article format)
464 * gnus-summary-save-body-in-file (article body)
465 * gnus-summary-save-in-vm (use VM's folder format)
466 * gnus-summary-write-to-file (article format -- overwrite)."
467 :group 'gnus-article-saving
468 :type '(radio (function-item gnus-summary-save-in-rmail)
469 (function-item gnus-summary-save-in-mail)
470 (function-item gnus-summary-save-in-folder)
471 (function-item gnus-summary-save-in-file)
472 (function-item gnus-summary-save-body-in-file)
473 (function-item gnus-summary-save-in-vm)
474 (function-item gnus-summary-write-to-file)))
476 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
477 "A function generating a file name to save articles in Rmail format.
478 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
479 :group 'gnus-article-saving
482 (defcustom gnus-mail-save-name 'gnus-plain-save-name
483 "A function generating a file name to save articles in Unix mail format.
484 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
485 :group 'gnus-article-saving
488 (defcustom gnus-folder-save-name 'gnus-folder-save-name
489 "A function generating a file name to save articles in MH folder.
490 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
491 :group 'gnus-article-saving
494 (defcustom gnus-file-save-name 'gnus-numeric-save-name
495 "A function generating a file name to save articles in article format.
496 The function is called with NEWSGROUP, HEADERS, and optional
498 :group 'gnus-article-saving
501 (defcustom gnus-split-methods
502 '((gnus-article-archive-name)
503 (gnus-article-nndoc-name))
504 "*Variable used to suggest where articles are to be saved.
505 For instance, if you would like to save articles related to Gnus in
506 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
507 you could set this variable to something like:
509 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
510 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
512 This variable is an alist where the where the key is the match and the
513 value is a list of possible files to save in if the match is non-nil.
515 If the match is a string, it is used as a regexp match on the
516 article. If the match is a symbol, that symbol will be funcalled
517 from the buffer of the article to be saved with the newsgroup as the
518 parameter. If it is a list, it will be evaled in the same buffer.
520 If this form or function returns a string, this string will be used as
521 a possible file name; and if it returns a non-nil list, that list will
522 be used as possible file names."
523 :group 'gnus-article-saving
524 :type '(repeat (choice (list :value (fun) function)
525 (cons :value ("" "") regexp (repeat string))
528 (defcustom gnus-page-delimiter "^\^L"
529 "*Regexp describing what to use as article page delimiters.
530 The default value is \"^\^L\", which is a form linefeed at the
531 beginning of a line."
533 :group 'gnus-article-various)
535 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
536 "*The format specification for the article mode line.
537 See `gnus-summary-mode-line-format' for a closer description.
539 The following additional specs are available:
541 %w The article washing status.
542 %m The number of MIME parts in the article."
544 :group 'gnus-article-various)
546 (defcustom gnus-article-mode-hook nil
547 "*A hook for Gnus article mode."
549 :group 'gnus-article-various)
551 (when (featurep 'xemacs)
552 ;; Extracted from gnus-xmas-define in order to preserve user settings
553 (when (fboundp 'turn-off-scroll-in-place)
554 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
555 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
556 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
558 (defcustom gnus-article-menu-hook nil
559 "*Hook run after the creation of the article mode menu."
561 :group 'gnus-article-various)
563 (defcustom gnus-article-prepare-hook nil
564 "*A hook called after an article has been prepared in the article buffer."
566 :group 'gnus-article-various)
568 (defcustom gnus-copy-article-ignored-headers nil
569 "List of headers to be removed when copying an article.
570 Each element is a regular expression."
571 :version "22.0" ;; No Gnus
572 :type '(repeat regexp)
573 :group 'gnus-article-various)
575 (make-obsolete-variable 'gnus-article-hide-pgp-hook
576 "This variable is obsolete in Gnus 5.10.")
578 (defcustom gnus-article-button-face 'bold
579 "Face used for highlighting buttons in the article buffer.
581 An article button is a piece of text that you can activate by pressing
582 `RET' or `mouse-2' above it."
584 :group 'gnus-article-buttons)
586 (defcustom gnus-article-mouse-face 'highlight
587 "Face used for mouse highlighting in the article buffer.
589 Article buttons will be displayed in this face when the cursor is
592 :group 'gnus-article-buttons)
594 (defcustom gnus-signature-face 'gnus-signature-face
595 "Face used for highlighting a signature in the article buffer.
596 Obsolete; use the face `gnus-signature-face' for customizations instead."
598 :group 'gnus-article-highlight
599 :group 'gnus-article-signature)
601 (defface gnus-signature-face
604 "Face used for highlighting a signature in the article buffer."
605 :group 'gnus-article-highlight
606 :group 'gnus-article-signature)
608 (defface gnus-header-from-face
611 (:foreground "spring green"))
614 (:foreground "red3"))
617 "Face used for displaying from headers."
618 :group 'gnus-article-headers
619 :group 'gnus-article-highlight)
621 (defface gnus-header-subject-face
624 (:foreground "SeaGreen3"))
627 (:foreground "red4"))
629 (:bold t :italic t)))
630 "Face used for displaying subject headers."
631 :group 'gnus-article-headers
632 :group 'gnus-article-highlight)
634 (defface gnus-header-newsgroups-face
637 (:foreground "yellow" :italic t))
640 (:foreground "MidnightBlue" :italic t))
643 "Face used for displaying newsgroups headers.
644 In the default setup this face is only used for crossposted
646 :group 'gnus-article-headers
647 :group 'gnus-article-highlight)
649 (defface gnus-header-name-face
652 (:foreground "SeaGreen"))
655 (:foreground "maroon"))
658 "Face used for displaying header names."
659 :group 'gnus-article-headers
660 :group 'gnus-article-highlight)
662 (defface gnus-header-content-face
665 (:foreground "forest green" :italic t))
668 (:foreground "indianred4" :italic t))
670 (:italic t))) "Face used for displaying header content."
671 :group 'gnus-article-headers
672 :group 'gnus-article-highlight)
674 (defcustom gnus-header-face-alist
675 '(("From" nil gnus-header-from-face)
676 ("Subject" nil gnus-header-subject-face)
677 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
678 ("" gnus-header-name-face gnus-header-content-face))
679 "*Controls highlighting of article headers.
681 An alist of the form (HEADER NAME CONTENT).
683 HEADER is a regular expression which should match the name of a
684 header and NAME and CONTENT are either face names or nil.
686 The name of each header field will be displayed using the face
687 specified by the first element in the list where HEADER matches
688 the header name and NAME is non-nil. Similarly, the content will
689 be displayed by the first non-nil matching CONTENT face."
690 :group 'gnus-article-headers
691 :group 'gnus-article-highlight
692 :type '(repeat (list (regexp :tag "Header")
694 (item :tag "skip" nil)
695 (face :value default))
696 (choice :tag "Content"
697 (item :tag "skip" nil)
698 (face :value default)))))
700 (defcustom gnus-article-decode-hook
701 '(article-decode-charset article-decode-encoded-words
702 article-decode-group-name article-decode-idna-rhs)
703 "*Hook run to decode charsets in articles."
704 :group 'gnus-article-headers
707 (defcustom gnus-display-mime-function 'gnus-display-mime
708 "Function to display MIME articles."
709 :group 'gnus-article-mime
712 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
713 "Function used to decode headers.")
715 (defvar gnus-article-dumbquotes-map
735 "Table for MS-to-Latin1 translation.")
737 (defcustom gnus-ignored-mime-types nil
738 "List of MIME types that should be ignored by Gnus."
740 :group 'gnus-article-mime
741 :type '(repeat regexp))
743 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
744 "List of MIME types that should not be given buttons when rendered inline.
745 See also `gnus-buttonized-mime-types' which may override this variable.
746 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
748 :group 'gnus-article-mime
749 :type '(repeat regexp))
751 (defcustom gnus-buttonized-mime-types nil
752 "List of MIME types that should be given buttons when rendered inline.
753 If set, this variable overrides `gnus-unbuttonized-mime-types'.
754 To see e.g. security buttons you could set this to
755 `(\"multipart/signed\")'.
756 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
758 :group 'gnus-article-mime
759 :type '(repeat regexp))
761 (defcustom gnus-inhibit-mime-unbuttonizing nil
762 "If non-nil, all MIME parts get buttons.
763 When nil (the default value), then some MIME parts do not get buttons,
764 as described by the variables `gnus-buttonized-mime-types' and
765 `gnus-unbuttonized-mime-types'."
767 :group 'gnus-article-mime
770 (defcustom gnus-body-boundary-delimiter "_"
771 "String used to delimit header and body.
772 This variable is used by `gnus-article-treat-body-boundary' which can
773 be controlled by `gnus-treat-body-boundary'."
775 :group 'gnus-article-various
776 :type '(choice (item :tag "None" :value nil)
779 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
781 "Defines the location of the faces database.
782 For information on obtaining this database of pretty pictures, please
783 see http://www.cs.indiana.edu/picons/ftp/index.html"
785 :type '(repeat directory)
786 :link '(url-link :tag "download"
787 "http://www.cs.indiana.edu/picons/ftp/index.html")
788 :link '(custom-manual "(gnus)Picons")
791 (defun gnus-picons-installed-p ()
792 "Say whether picons are installed on your machine."
793 (let ((installed nil))
794 (dolist (database gnus-picon-databases)
795 (when (file-exists-p database)
799 (defcustom gnus-article-mime-part-function nil
800 "Function called with a MIME handle as the argument.
801 This is meant for people who want to do something automatic based
802 on parts -- for instance, adding Vcard info to a database."
803 :group 'gnus-article-mime
806 (defcustom gnus-mime-multipart-functions nil
807 "An alist of MIME types to functions to display them."
809 :group 'gnus-article-mime
810 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
812 (defcustom gnus-article-date-lapsed-new-header nil
813 "Whether the X-Sent and Date headers can coexist.
814 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
815 either replace the old \"Date:\" header (if this variable is nil), or
816 be added below it (otherwise)."
818 :group 'gnus-article-headers
821 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
822 "Function called with a MIME handle as the argument.
823 This is meant for people who want to view first matched part.
824 For `undisplayed-alternative' (default), the first undisplayed
825 part or alternative part is used. For `undisplayed', the first
826 undisplayed part is used. For a function, the first part which
827 the function return t is used. For nil, the first part is
830 :group 'gnus-article-mime
832 (item :tag "first" :value nil)
833 (item :tag "undisplayed" :value undisplayed)
834 (item :tag "undisplayed or alternative"
835 :value undisplayed-alternative)
838 (defcustom gnus-mime-action-alist
839 '(("save to file" . gnus-mime-save-part)
840 ("save and strip" . gnus-mime-save-part-and-strip)
841 ("delete part" . gnus-mime-delete-part)
842 ("display as text" . gnus-mime-inline-part)
843 ("view the part" . gnus-mime-view-part)
844 ("pipe to command" . gnus-mime-pipe-part)
845 ("toggle display" . gnus-article-press-button)
846 ("toggle display" . gnus-article-view-part-as-charset)
847 ("view as type" . gnus-mime-view-part-as-type)
848 ("view internally" . gnus-mime-view-part-internally)
849 ("view externally" . gnus-mime-view-part-externally))
850 "An alist of actions that run on the MIME attachment."
851 :group 'gnus-article-mime
852 :type '(repeat (cons (string :tag "name")
856 ;;; The treatment variables
859 (defvar gnus-part-display-hook nil
860 "Hook called on parts that are to receive treatment.")
862 (defvar gnus-article-treat-custom
863 '(choice (const :tag "Off" nil)
865 (const :tag "Header" head)
866 (const :tag "Last" last)
867 (integer :tag "Less")
868 (repeat :tag "Groups" regexp)
869 (sexp :tag "Predicate")))
871 (defvar gnus-article-treat-head-custom
872 '(choice (const :tag "Off" nil)
873 (const :tag "Header" head)))
875 (defvar gnus-article-treat-types '("text/plain")
878 (defvar gnus-inhibit-treatment nil
879 "Whether to inhibit treatment.")
881 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
882 "Highlight the signature.
883 Valid values are nil, t, `head', `last', an integer or a predicate.
884 See Info node `(gnus)Customizing Articles'."
885 :group 'gnus-article-treat
886 :link '(custom-manual "(gnus)Customizing Articles")
887 :type gnus-article-treat-custom)
888 (put 'gnus-treat-highlight-signature 'highlight t)
890 (defcustom gnus-treat-buttonize 100000
892 Valid values are nil, t, `head', `last', an integer or a predicate.
893 See Info node `(gnus)Customizing Articles'."
894 :group 'gnus-article-treat
895 :link '(custom-manual "(gnus)Customizing Articles")
896 :type gnus-article-treat-custom)
897 (put 'gnus-treat-buttonize 'highlight t)
899 (defcustom gnus-treat-buttonize-head 'head
900 "Add buttons to the head.
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See Info node `(gnus)Customizing Articles' for details."
903 :group 'gnus-article-treat
904 :link '(custom-manual "(gnus)Customizing Articles")
905 :type gnus-article-treat-head-custom)
906 (put 'gnus-treat-buttonize-head 'highlight t)
908 (defcustom gnus-treat-emphasize
909 (and (or window-system
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :link '(custom-manual "(gnus)Customizing Articles")
917 :type gnus-article-treat-custom)
918 (put 'gnus-treat-emphasize 'highlight t)
920 (defcustom gnus-treat-strip-cr nil
921 "Remove carriage returns.
922 Valid values are nil, t, `head', `last', an integer or a predicate.
923 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :link '(custom-manual "(gnus)Customizing Articles")
927 :type gnus-article-treat-custom)
929 (defcustom gnus-treat-unsplit-urls nil
930 "Remove newlines from within URLs.
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles' for details."
934 :group 'gnus-article-treat
935 :link '(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-leading-whitespace nil
939 "Remove leading whitespace in headers.
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-custom)
947 (defcustom gnus-treat-hide-headers 'head
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-head-custom)
955 (defcustom gnus-treat-hide-boring-headers nil
956 "Hide boring headers.
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-head-custom)
963 (defcustom gnus-treat-hide-signature nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-fill-article nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-hide-citation nil
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :link '(custom-manual "(gnus)Customizing Articles")
985 :type gnus-article-treat-custom)
987 (defcustom gnus-treat-hide-citation-maybe nil
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
995 (defcustom gnus-treat-strip-list-identifiers 'head
996 "Strip list identifiers from `gnus-list-identifiers`.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (make-obsolete-variable 'gnus-treat-strip-pgp
1005 "This option is obsolete in Gnus 5.10.")
1007 (defcustom gnus-treat-strip-pem nil
1008 "Strip PEM signatures.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1011 :group 'gnus-article-treat
1012 :link '(custom-manual "(gnus)Customizing Articles")
1013 :type gnus-article-treat-custom)
1015 (defcustom gnus-treat-strip-banner t
1016 "Strip banners from articles.
1017 The banner to be stripped is specified in the `banner' group parameter.
1018 Valid values are nil, t, `head', `last', an integer or a predicate.
1019 See Info node `(gnus)Customizing Articles' for details."
1020 :group 'gnus-article-treat
1021 :link '(custom-manual "(gnus)Customizing Articles")
1022 :type gnus-article-treat-custom)
1024 (defcustom gnus-treat-highlight-headers 'head
1025 "Highlight the headers.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-head-custom)
1031 (put 'gnus-treat-highlight-headers 'highlight t)
1033 (defcustom gnus-treat-highlight-citation t
1034 "Highlight cited text.
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 See Info node `(gnus)Customizing Articles' for details."
1037 :group 'gnus-article-treat
1038 :link '(custom-manual "(gnus)Customizing Articles")
1039 :type gnus-article-treat-custom)
1040 (put 'gnus-treat-highlight-citation 'highlight t)
1042 (defcustom gnus-treat-date-ut nil
1043 "Display the Date in UT (GMT).
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-date-local nil
1051 "Display the Date in the local timezone.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-english nil
1059 "Display the Date in a format that can be read aloud in English.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-head-custom)
1067 (defcustom gnus-treat-date-lapsed nil
1068 "Display the Date header in a way that says how much time has elapsed.
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-date-original nil
1076 "Display the date in the original timezone.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-head-custom)
1083 (defcustom gnus-treat-date-iso8601 nil
1084 "Display the date in the ISO8601 format.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1088 :group 'gnus-article-treat
1089 :link '(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-head-custom)
1092 (defcustom gnus-treat-date-user-defined nil
1093 "Display the date in a user-defined format.
1094 The format is defined by the `gnus-article-time-format' variable.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-head-custom)
1101 (defcustom gnus-treat-strip-headers-in-body t
1102 "Strip the X-No-Archive header line from the beginning of the body.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1110 (defcustom gnus-treat-strip-trailing-blank-lines nil
1111 "Strip trailing blank lines.
1112 Valid values are nil, t, `head', `last', an integer or a predicate.
1113 See Info node `(gnus)Customizing Articles' for details."
1114 :group 'gnus-article-treat
1115 :link '(custom-manual "(gnus)Customizing Articles")
1116 :type gnus-article-treat-custom)
1118 (defcustom gnus-treat-strip-leading-blank-lines nil
1119 "Strip leading blank lines.
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See Info node `(gnus)Customizing Articles' for details."
1122 :group 'gnus-article-treat
1123 :link '(custom-manual "(gnus)Customizing Articles")
1124 :type gnus-article-treat-custom)
1126 (defcustom gnus-treat-strip-multiple-blank-lines nil
1127 "Strip multiple blank lines.
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See Info node `(gnus)Customizing Articles' for details."
1130 :group 'gnus-article-treat
1131 :link '(custom-manual "(gnus)Customizing Articles")
1132 :type gnus-article-treat-custom)
1134 (defcustom gnus-treat-unfold-headers 'head
1135 "Unfold folded header lines.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 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)
1143 (defcustom gnus-treat-fold-headers nil
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-custom)
1152 (defcustom gnus-treat-fold-newsgroups 'head
1153 "Fold the Newsgroups and Followup-To headers.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1157 :group 'gnus-article-treat
1158 :link '(custom-manual "(gnus)Customizing Articles")
1159 :type gnus-article-treat-custom)
1161 (defcustom gnus-treat-overstrike t
1162 "Treat overstrike highlighting.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' for details."
1165 :group 'gnus-article-treat
1166 :link '(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-custom)
1168 (put 'gnus-treat-overstrike 'highlight t)
1170 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1171 "Treat ANSI SGR control sequences.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom)
1178 (make-obsolete-variable 'gnus-treat-display-xface
1179 'gnus-treat-display-x-face)
1181 (defcustom gnus-treat-display-x-face
1182 (and (not noninteractive)
1183 (or (and (fboundp 'image-type-available-p)
1184 (image-type-available-p 'xbm)
1185 (string-match "^0x" (shell-command-to-string "uncompface"))
1186 (executable-find "icontopbm"))
1187 (and (featurep 'xemacs)
1190 "Display X-Face headers.
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' and Info node
1193 `(gnus)X-Face' for details."
1194 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :link '(custom-manual "(gnus)X-Face")
1198 :type gnus-article-treat-head-custom
1199 :set (lambda (symbol value)
1202 (cond ((or (boundp symbol) (get symbol 'saved-value))
1204 ((boundp 'gnus-treat-display-xface)
1206 ** gnus-treat-display-xface is an obsolete variable;\
1207 use gnus-treat-display-x-face instead")
1208 (default-value 'gnus-treat-display-xface))
1209 ((get 'gnus-treat-display-xface 'saved-value)
1211 ** gnus-treat-display-xface is an obsolete variable;\
1212 use gnus-treat-display-x-face instead")
1213 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1216 (put 'gnus-treat-display-x-face 'highlight t)
1218 (defcustom gnus-treat-display-face
1219 (and (not noninteractive)
1220 (or (and (fboundp 'image-type-available-p)
1221 (image-type-available-p 'png))
1222 (and (featurep 'xemacs)
1225 "Display Face headers.
1226 Valid values are nil, t, `head', `last', an integer or a predicate.
1227 See Info node `(gnus)Customizing Articles' and Info node
1228 `(gnus)X-Face' for details."
1229 :group 'gnus-article-treat
1231 :link '(custom-manual "(gnus)Customizing Articles")
1232 :link '(custom-manual "(gnus)X-Face")
1233 :type gnus-article-treat-head-custom)
1234 (put 'gnus-treat-display-face 'highlight t)
1236 (defcustom gnus-treat-display-smileys
1237 (if (or (and (featurep 'xemacs)
1239 (and (fboundp 'image-type-available-p)
1240 (image-type-available-p 'pbm)))
1243 Valid values are nil, t, `head', `last', an integer or a predicate.
1244 See Info node `(gnus)Customizing Articles' and Info node
1245 `(gnus)Smileys' for details."
1246 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :link '(custom-manual "(gnus)Smileys")
1250 :type gnus-article-treat-custom)
1251 (put 'gnus-treat-display-smileys 'highlight t)
1253 (defcustom gnus-treat-from-picon
1254 (if (and (gnus-image-type-available-p 'xpm)
1255 (gnus-picons-installed-p))
1257 "Display picons in the From header.
1258 Valid values are nil, t, `head', `last', an integer or a predicate.
1259 See Info node `(gnus)Customizing Articles' and Info node
1260 `(gnus)Picons' for details."
1262 :group 'gnus-article-treat
1264 :link '(custom-manual "(gnus)Customizing Articles")
1265 :link '(custom-manual "(gnus)Picons")
1266 :type gnus-article-treat-head-custom)
1267 (put 'gnus-treat-from-picon 'highlight t)
1269 (defcustom gnus-treat-mail-picon
1270 (if (and (gnus-image-type-available-p 'xpm)
1271 (gnus-picons-installed-p))
1273 "Display picons in To and Cc headers.
1274 Valid values are nil, t, `head', `last', an integer or a predicate.
1275 See Info node `(gnus)Customizing Articles' and Info node
1276 `(gnus)Picons' for details."
1278 :group 'gnus-article-treat
1280 :link '(custom-manual "(gnus)Customizing Articles")
1281 :link '(custom-manual "(gnus)Picons")
1282 :type gnus-article-treat-head-custom)
1283 (put 'gnus-treat-mail-picon 'highlight t)
1285 (defcustom gnus-treat-newsgroups-picon
1286 (if (and (gnus-image-type-available-p 'xpm)
1287 (gnus-picons-installed-p))
1289 "Display picons in the Newsgroups and Followup-To headers.
1290 Valid values are nil, t, `head', `last', an integer or a predicate.
1291 See Info node `(gnus)Customizing Articles' and Info node
1292 `(gnus)Picons' for details."
1294 :group 'gnus-article-treat
1296 :link '(custom-manual "(gnus)Customizing Articles")
1297 :link '(custom-manual "(gnus)Picons")
1298 :type gnus-article-treat-head-custom)
1299 (put 'gnus-treat-newsgroups-picon 'highlight t)
1301 (defcustom gnus-treat-body-boundary
1302 (if (and (eq window-system 'x)
1303 (or gnus-treat-newsgroups-picon
1304 gnus-treat-mail-picon
1305 gnus-treat-from-picon))
1307 "Draw a boundary at the end of the headers.
1308 Valid values are nil and `head'.
1309 See Info node `(gnus)Customizing Articles' for details."
1311 :group 'gnus-article-treat
1312 :link '(custom-manual "(gnus)Customizing Articles")
1313 :type gnus-article-treat-head-custom)
1315 (defcustom gnus-treat-capitalize-sentences nil
1316 "Capitalize sentence-starting words.
1317 Valid values are nil, t, `head', `last', an integer or a predicate.
1318 See Info node `(gnus)Customizing Articles' for details."
1320 :group 'gnus-article-treat
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :type gnus-article-treat-custom)
1324 (defcustom gnus-treat-wash-html nil
1326 Valid values are nil, t, `head', `last', an integer or a predicate.
1327 See Info node `(gnus)Customizing Articles' for details."
1329 :group 'gnus-article-treat
1330 :link '(custom-manual "(gnus)Customizing Articles")
1331 :type gnus-article-treat-custom)
1333 (defcustom gnus-treat-fill-long-lines nil
1335 Valid values are nil, t, `head', `last', an integer or a predicate.
1336 See Info node `(gnus)Customizing Articles' for details."
1337 :group 'gnus-article-treat
1338 :link '(custom-manual "(gnus)Customizing Articles")
1339 :type gnus-article-treat-custom)
1341 (defcustom gnus-treat-play-sounds nil
1343 Valid values are nil, t, `head', `last', an integer or a predicate.
1344 See Info node `(gnus)Customizing Articles' for details."
1346 :group 'gnus-article-treat
1347 :link '(custom-manual "(gnus)Customizing Articles")
1348 :type gnus-article-treat-custom)
1350 (defcustom gnus-treat-translate nil
1351 "Translate articles from one language to another.
1352 Valid values are nil, t, `head', `last', an integer or a predicate.
1353 See Info node `(gnus)Customizing Articles' for details."
1355 :group 'gnus-article-treat
1356 :link '(custom-manual "(gnus)Customizing Articles")
1357 :type gnus-article-treat-custom)
1359 (defcustom gnus-treat-x-pgp-sig nil
1361 To automatically treat X-PGP-Sig, set it to head.
1362 Valid values are nil, t, `head', `last', an integer or a predicate.
1363 See Info node `(gnus)Customizing Articles' for details."
1365 :group 'gnus-article-treat
1366 :group 'mime-security
1367 :link '(custom-manual "(gnus)Customizing Articles")
1368 :type gnus-article-treat-custom)
1370 (defvar gnus-article-encrypt-protocol-alist
1371 '(("PGP" . mml2015-self-encrypt)))
1373 ;; Set to nil if more than one protocol added to
1374 ;; gnus-article-encrypt-protocol-alist.
1375 (defcustom gnus-article-encrypt-protocol "PGP"
1376 "The protocol used for encrypt articles.
1377 It is a string, such as \"PGP\". If nil, ask user."
1380 :group 'mime-security)
1382 (defvar gnus-article-wash-function nil
1383 "Function used for converting HTML into text.")
1385 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1386 (mm-coding-system-p 'utf-8)
1387 (executable-find idna-program))
1388 "Whether IDNA decoding of headers is used when viewing messages.
1389 This requires GNU Libidn, and by default only enabled if it is found."
1391 :group 'gnus-article-headers
1394 (defcustom gnus-article-over-scroll nil
1395 "If non-nil, allow scrolling the article buffer even when there no more text."
1397 :group 'gnus-article
1400 ;;; Internal variables
1402 (defvar gnus-english-month-names
1403 '("January" "February" "March" "April" "May" "June" "July" "August"
1404 "September" "October" "November" "December"))
1406 (defvar gnus-button-regexp nil)
1407 (defvar gnus-button-marker-list nil)
1408 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1410 (defvar gnus-button-last nil)
1411 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1413 (defvar article-goto-body-goes-to-point-min-p nil)
1414 (defvar gnus-article-wash-types nil)
1415 (defvar gnus-article-emphasis-alist nil)
1416 (defvar gnus-article-image-alist nil)
1418 (defvar gnus-article-mime-handle-alist-1 nil)
1419 (defvar gnus-treatment-function-alist
1420 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1421 (gnus-treat-strip-banner gnus-article-strip-banner)
1422 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1423 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1424 (gnus-treat-buttonize gnus-article-add-buttons)
1425 (gnus-treat-fill-article gnus-article-fill-cited-article)
1426 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1427 (gnus-treat-strip-cr gnus-article-remove-cr)
1428 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1429 (gnus-treat-date-ut gnus-article-date-ut)
1430 (gnus-treat-date-local gnus-article-date-local)
1431 (gnus-treat-date-english gnus-article-date-english)
1432 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1433 (gnus-treat-date-original gnus-article-date-original)
1434 (gnus-treat-date-user-defined gnus-article-date-user)
1435 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1436 (gnus-treat-display-x-face gnus-article-display-x-face)
1437 (gnus-treat-display-face gnus-article-display-face)
1438 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1439 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1440 (gnus-treat-hide-signature gnus-article-hide-signature)
1441 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1442 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1443 (gnus-treat-strip-pem gnus-article-hide-pem)
1444 (gnus-treat-from-picon gnus-treat-from-picon)
1445 (gnus-treat-mail-picon gnus-treat-mail-picon)
1446 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1447 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1448 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1449 (gnus-treat-strip-trailing-blank-lines
1450 gnus-article-remove-trailing-blank-lines)
1451 (gnus-treat-strip-leading-blank-lines
1452 gnus-article-strip-leading-blank-lines)
1453 (gnus-treat-strip-multiple-blank-lines
1454 gnus-article-strip-multiple-blank-lines)
1455 (gnus-treat-overstrike gnus-article-treat-overstrike)
1456 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1457 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1458 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1459 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1460 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1461 (gnus-treat-display-smileys gnus-treat-smiley)
1462 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1463 (gnus-treat-wash-html gnus-article-wash-html)
1464 (gnus-treat-emphasize gnus-article-emphasize)
1465 (gnus-treat-hide-citation gnus-article-hide-citation)
1466 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1467 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1468 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1469 (gnus-treat-play-sounds gnus-earcon-display)))
1471 (defvar gnus-article-mime-handle-alist nil)
1472 (defvar article-lapsed-timer nil)
1473 (defvar gnus-article-current-summary nil)
1475 (defvar gnus-article-mode-syntax-table
1476 (let ((table (copy-syntax-table text-mode-syntax-table)))
1477 ;; This causes the citation match run O(2^n).
1478 ;; (modify-syntax-entry ?- "w" table)
1479 (modify-syntax-entry ?> ")<" table)
1480 (modify-syntax-entry ?< "(>" table)
1481 ;; make M-. in article buffers work for `foo' strings
1482 (modify-syntax-entry ?' " " table)
1483 (modify-syntax-entry ?` " " table)
1485 "Syntax table used in article mode buffers.
1486 Initialized from `text-mode-syntax-table.")
1488 (defvar gnus-save-article-buffer nil)
1490 (defvar gnus-article-mode-line-format-alist
1491 (nconc '((?w (gnus-article-wash-status) ?s)
1492 (?m (gnus-article-mime-part-status) ?s))
1493 gnus-summary-mode-line-format-alist))
1495 (defvar gnus-number-of-articles-to-be-saved nil)
1497 (defvar gnus-inhibit-hiding nil)
1499 (defvar gnus-article-edit-mode nil)
1501 ;;; Macros for dealing with the article buffer.
1503 (defmacro gnus-with-article-headers (&rest forms)
1505 (set-buffer gnus-article-buffer)
1507 (let ((inhibit-read-only t)
1508 (inhibit-point-motion-hooks t)
1509 (case-fold-search t))
1510 (article-narrow-to-head)
1513 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1514 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1516 (defmacro gnus-with-article-buffer (&rest forms)
1518 (set-buffer gnus-article-buffer)
1519 (let ((inhibit-read-only t))
1522 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1523 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1525 (defun gnus-article-goto-header (header)
1526 "Go to HEADER, which is a regular expression."
1527 (re-search-forward (concat "^\\(" header "\\):") nil t))
1529 (defsubst gnus-article-hide-text (b e props)
1530 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1531 (gnus-add-text-properties-when 'article-type nil b e props)
1532 (when (memq 'intangible props)
1534 (max (1- b) (point-min))
1535 b 'intangible (cddr (memq 'intangible props)))))
1537 (defsubst gnus-article-unhide-text (b e)
1538 "Remove hidden text properties from region between B and E."
1539 (remove-text-properties b e gnus-hidden-properties)
1540 (when (memq 'intangible gnus-hidden-properties)
1541 (put-text-property (max (1- b) (point-min))
1542 b 'intangible nil)))
1544 (defun gnus-article-hide-text-type (b e type)
1545 "Hide text of TYPE between B and E."
1546 (gnus-add-wash-type type)
1547 (gnus-article-hide-text
1548 b e (cons 'article-type (cons type gnus-hidden-properties))))
1550 (defun gnus-article-unhide-text-type (b e type)
1551 "Unhide text of TYPE between B and E."
1552 (gnus-delete-wash-type type)
1553 (remove-text-properties
1554 b e (cons 'article-type (cons type gnus-hidden-properties)))
1555 (when (memq 'intangible gnus-hidden-properties)
1556 (put-text-property (max (1- b) (point-min))
1557 b 'intangible nil)))
1559 (defun gnus-article-hide-text-of-type (type)
1560 "Hide text of TYPE in the current buffer."
1562 (let ((b (point-min))
1564 (while (setq b (text-property-any b e 'article-type type))
1565 (add-text-properties b (incf b) gnus-hidden-properties)))))
1567 (defun gnus-article-delete-text-of-type (type)
1568 "Delete text of TYPE in the current buffer."
1570 (let ((b (point-min)))
1571 (while (setq b (text-property-any b (point-max) 'article-type type))
1573 b (or (text-property-not-all b (point-max) 'article-type type)
1576 (defun gnus-article-delete-invisible-text ()
1577 "Delete all invisible text in the current buffer."
1579 (let ((b (point-min)))
1580 (while (setq b (text-property-any b (point-max) 'invisible t))
1582 b (or (text-property-not-all b (point-max) 'invisible t)
1585 (defun gnus-article-text-type-exists-p (type)
1586 "Say whether any text of type TYPE exists in the buffer."
1587 (text-property-any (point-min) (point-max) 'article-type type))
1589 (defsubst gnus-article-header-rank ()
1590 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1591 (let ((list gnus-sorted-header-list)
1594 (if (looking-at (car list))
1596 (setq list (cdr list))
1600 (defun article-hide-headers (&optional arg delete)
1601 "Hide unwanted headers and possibly sort them as well."
1603 ;; This function might be inhibited.
1604 (unless gnus-inhibit-hiding
1605 (let ((inhibit-read-only nil)
1606 (case-fold-search t)
1607 (max (1+ (length gnus-sorted-header-list)))
1608 (inhibit-point-motion-hooks t)
1609 (cur (current-buffer))
1610 ignored visible beg)
1612 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1613 ;; group parameters, so we should go to the summary buffer.
1616 (progn (set-buffer gnus-summary-buffer) t)
1618 (setq ignored (when (not gnus-visible-headers)
1619 (cond ((stringp gnus-ignored-headers)
1620 gnus-ignored-headers)
1621 ((listp gnus-ignored-headers)
1622 (mapconcat 'identity
1623 gnus-ignored-headers
1625 visible (cond ((stringp gnus-visible-headers)
1626 gnus-visible-headers)
1627 ((and gnus-visible-headers
1628 (listp gnus-visible-headers))
1629 (mapconcat 'identity
1630 gnus-visible-headers
1634 ;; First we narrow to just the headers.
1635 (article-narrow-to-head)
1636 ;; Hide any "From " lines at the beginning of (mail) articles.
1637 (while (looking-at "From ")
1640 (delete-region (point-min) (point)))
1641 ;; Then treat the rest of the header lines.
1642 ;; Then we use the two regular expressions
1643 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1644 ;; select which header lines is to remain visible in the
1646 (while (re-search-forward "^[^ \t:]*:" nil t)
1648 ;; Mark the rank of the header.
1650 (point) (1+ (point)) 'message-rank
1651 (if (or (and visible (looking-at visible))
1653 (not (looking-at ignored))))
1654 (gnus-article-header-rank)
1657 (message-sort-headers-1)
1658 (when (setq beg (text-property-any
1659 (point-min) (point-max) 'message-rank (+ 2 max)))
1660 ;; We delete the unwanted headers.
1661 (gnus-add-wash-type 'headers)
1662 (add-text-properties (point-min) (+ 5 (point-min))
1663 '(article-type headers dummy-invisible t))
1664 (delete-region beg (point-max))))))))
1666 (defun article-hide-boring-headers (&optional arg)
1667 "Toggle hiding of headers that aren't very interesting.
1668 If given a negative prefix, always show; if given a positive prefix,
1670 (interactive (gnus-article-hidden-arg))
1671 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1672 (not gnus-show-all-headers))
1675 (let ((inhibit-read-only t)
1676 (inhibit-point-motion-hooks t))
1677 (article-narrow-to-head)
1678 (dolist (elem gnus-boring-article-headers)
1679 (goto-char (point-min))
1681 ;; Hide empty headers.
1683 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1685 (gnus-article-hide-text-type
1689 (if (re-search-forward "^[^ \t]" nil t)
1693 ;; Hide boring Newsgroups header.
1694 ((eq elem 'newsgroups)
1695 (when (gnus-string-equal
1696 (gnus-fetch-field "newsgroups")
1697 (gnus-group-real-name
1698 (if (boundp 'gnus-newsgroup-name)
1701 (gnus-article-hide-header "newsgroups")))
1702 ((eq elem 'to-address)
1703 (let ((to (message-fetch-field "to"))
1705 (gnus-parameter-to-address
1706 (if (boundp 'gnus-newsgroup-name)
1707 gnus-newsgroup-name ""))))
1708 (when (and to to-address
1711 ;; only one address in To
1712 (nth 1 (mail-extract-address-components to))
1714 (gnus-article-hide-header "to"))))
1716 (let ((to (message-fetch-field "to"))
1718 (gnus-parameter-to-list
1719 (if (boundp 'gnus-newsgroup-name)
1720 gnus-newsgroup-name ""))))
1721 (when (and to to-list
1724 ;; only one address in To
1725 (nth 1 (mail-extract-address-components to))
1727 (gnus-article-hide-header "to"))))
1729 (let ((cc (message-fetch-field "cc"))
1731 (gnus-parameter-to-list
1732 (if (boundp 'gnus-newsgroup-name)
1733 gnus-newsgroup-name ""))))
1734 (when (and cc to-list
1737 ;; only one address in CC
1738 (nth 1 (mail-extract-address-components cc))
1740 (gnus-article-hide-header "cc"))))
1741 ((eq elem 'followup-to)
1742 (when (gnus-string-equal
1743 (message-fetch-field "followup-to")
1744 (message-fetch-field "newsgroups"))
1745 (gnus-article-hide-header "followup-to")))
1746 ((eq elem 'reply-to)
1747 (if (gnus-group-find-parameter
1748 gnus-newsgroup-name 'broken-reply-to)
1749 (gnus-article-hide-header "reply-to")
1750 (let ((from (message-fetch-field "from"))
1751 (reply-to (message-fetch-field "reply-to")))
1758 (lambda (x) (downcase (cadr x)))
1759 (mail-extract-address-components from t))
1762 (lambda (x) (downcase (cadr x)))
1763 (mail-extract-address-components reply-to t))
1765 (gnus-article-hide-header "reply-to")))))
1767 (let ((date (message-fetch-field "date")))
1769 (< (days-between (current-time-string) date)
1771 (gnus-article-hide-header "date"))))
1773 (let ((to (message-fetch-field "to"))
1774 (cc (message-fetch-field "cc")))
1775 (when (> (length to) 1024)
1776 (gnus-article-hide-header "to"))
1777 (when (> (length cc) 1024)
1778 (gnus-article-hide-header "cc"))))
1782 (goto-char (point-min))
1783 (while (re-search-forward "^to:" nil t)
1784 (setq to-count (1+ to-count)))
1785 (when (> to-count 1)
1786 (while (> to-count 0)
1787 (goto-char (point-min))
1789 (re-search-forward "^to:" nil nil to-count)
1791 (narrow-to-region (point) (point-max))
1792 (gnus-article-hide-header "to"))
1793 (setq to-count (1- to-count))))
1794 (goto-char (point-min))
1795 (while (re-search-forward "^cc:" nil t)
1796 (setq cc-count (1+ cc-count)))
1797 (when (> cc-count 1)
1798 (while (> cc-count 0)
1799 (goto-char (point-min))
1801 (re-search-forward "^cc:" nil nil cc-count)
1803 (narrow-to-region (point) (point-max))
1804 (gnus-article-hide-header "cc"))
1805 (setq cc-count (1- cc-count)))))))))))))
1807 (defun gnus-article-hide-header (header)
1809 (goto-char (point-min))
1810 (when (re-search-forward (concat "^" header ":") nil t)
1811 (gnus-article-hide-text-type
1815 (if (re-search-forward "^[^ \t]" nil t)
1820 (defvar gnus-article-normalized-header-length 40
1821 "Length of normalized headers.")
1823 (defun article-normalize-headers ()
1824 "Make all header lines 40 characters long."
1826 (let ((inhibit-read-only t)
1830 (article-narrow-to-head)
1833 ((< (setq column (- (point-at-eol) (point)))
1834 gnus-article-normalized-header-length)
1836 (insert (make-string
1837 (- gnus-article-normalized-header-length column)
1839 ((> column gnus-article-normalized-header-length)
1840 (gnus-put-text-property
1842 (forward-char gnus-article-normalized-header-length)
1849 (forward-line 1))))))
1851 (defun article-treat-dumbquotes ()
1852 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1853 Note that this function guesses whether a character is a sm*rtq**t* or
1854 not, so it should only be used interactively.
1856 Sm*rtq**t*s are M****s***'s unilateral extension to the
1857 iso-8859-1 character map in an attempt to provide more quoting
1858 characters. If you see something like \\222 or \\264 where
1859 you're expecting some kind of apostrophe or quotation mark, then
1862 (article-translate-strings gnus-article-dumbquotes-map))
1864 (defun article-translate-characters (from to)
1865 "Translate all characters in the body of the article according to FROM and TO.
1866 FROM is a string of characters to translate from; to is a string of
1867 characters to translate to."
1869 (when (article-goto-body)
1870 (let ((inhibit-read-only t)
1871 (x (make-string 225 ?x))
1873 (while (< (incf i) (length x))
1876 (while (< i (length from))
1877 (aset x (aref from i) (aref to i))
1879 (translate-region (point) (point-max) x)))))
1881 (defun article-translate-strings (map)
1882 "Translate all string in the body of the article according to MAP.
1883 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1885 (when (article-goto-body)
1886 (let ((inhibit-read-only t))
1889 (while (search-forward (car elem) nil t)
1890 (replace-match (cadr elem)))))))))
1892 (defun article-treat-overstrike ()
1893 "Translate overstrikes into bold text."
1896 (when (article-goto-body)
1897 (let ((inhibit-read-only t))
1898 (while (search-forward "\b" nil t)
1899 (let ((next (char-after))
1900 (previous (char-after (- (point) 2))))
1901 ;; We do the boldification/underlining by hiding the
1902 ;; overstrikes and putting the proper text property
1906 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1907 (put-text-property (point) (1+ (point)) 'face 'bold))
1909 (gnus-article-hide-text-type
1910 (1- (point)) (1+ (point)) 'overstrike)
1912 (- (point) 2) (1- (point)) 'face 'underline))
1914 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1916 (point) (1+ (point)) 'face 'underline)))))))))
1918 (defun article-treat-ansi-sequences ()
1919 "Translate ANSI SGR control sequences into overlays or extents."
1922 (when (article-goto-body)
1923 (let ((inhibit-read-only t))
1924 (ansi-color-apply-on-region (point) (point-max))))))
1926 (defun gnus-article-treat-unfold-headers ()
1927 "Unfold folded message headers.
1928 Only the headers that fit into the current window width will be
1931 (gnus-with-article-headers
1935 (mail-header-narrow-to-field)
1936 (let ((header (buffer-string)))
1939 (goto-char (point-min))
1940 (while (re-search-forward "\n[\t ]" nil t)
1941 (replace-match " " t t)))
1942 (setq length (- (point-max) (point-min) 1)))
1943 (when (< length (window-width))
1944 (while (re-search-forward "\n[\t ]" nil t)
1945 (replace-match " " t t)))
1946 (goto-char (point-max)))))))
1948 (defun gnus-article-treat-fold-headers ()
1949 "Fold message headers."
1951 (gnus-with-article-headers
1954 (mail-header-narrow-to-field)
1955 (mail-header-fold-field)
1956 (goto-char (point-max))))))
1958 (defun gnus-treat-smiley ()
1959 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1961 (gnus-with-article-buffer
1962 (if (memq 'smiley gnus-article-wash-types)
1963 (gnus-delete-images 'smiley)
1965 (let ((images (smiley-region (point) (point-max))))
1967 (gnus-add-wash-type 'smiley)
1968 (dolist (image images)
1969 (gnus-add-image 'smiley image)))))))
1971 (defun gnus-article-remove-images ()
1972 "Remove all images from the article buffer."
1974 (gnus-with-article-buffer
1975 (dolist (elem gnus-article-image-alist)
1976 (gnus-delete-images (car elem)))))
1978 (defun gnus-article-treat-fold-newsgroups ()
1979 "Unfold folded message headers.
1980 Only the headers that fit into the current window width will be
1983 (gnus-with-article-headers
1984 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1986 (mail-header-narrow-to-field)
1987 (while (re-search-forward ", *" nil t)
1988 (replace-match ", " t t))
1989 (mail-header-fold-field)
1990 (goto-char (point-max))))))
1992 (defun gnus-article-treat-body-boundary ()
1993 "Place a boundary line at the end of the headers."
1995 (when (and gnus-body-boundary-delimiter
1996 (> (length gnus-body-boundary-delimiter) 0))
1997 (gnus-with-article-headers
1998 (goto-char (point-max))
1999 (let ((start (point)))
2000 (insert "X-Boundary: ")
2001 (gnus-add-text-properties start (point) '(invisible t intangible t))
2003 (while (>= (1- (window-width)) (length str))
2004 (setq str (concat str gnus-body-boundary-delimiter)))
2005 (substring str 0 (1- (window-width))))
2007 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2009 (defun article-fill-long-lines ()
2010 "Fill lines that are wider than the window width."
2013 (let ((inhibit-read-only t)
2014 (width (window-width (get-buffer-window (current-buffer)))))
2017 (let ((adaptive-fill-mode nil)) ;Why? -sm
2020 (when (>= (current-column) (min fill-column width))
2021 (narrow-to-region (min (1+ (point)) (point-max))
2023 (let ((goback (point-marker)))
2024 (fill-paragraph nil)
2025 (goto-char (marker-position goback)))
2027 (forward-line 1)))))))
2029 (defun article-capitalize-sentences ()
2030 "Capitalize the first word in each sentence."
2033 (let ((inhibit-read-only t)
2034 (paragraph-start "^[\n\^L]"))
2038 (forward-sentence)))))
2040 (defun article-remove-cr ()
2041 "Remove trailing CRs and then translate remaining CRs into LFs."
2044 (let ((inhibit-read-only t))
2045 (goto-char (point-min))
2046 (while (re-search-forward "\r+$" nil t)
2047 (replace-match "" t t))
2048 (goto-char (point-min))
2049 (while (search-forward "\r" nil t)
2050 (replace-match "\n" t t)))))
2052 (defun article-remove-trailing-blank-lines ()
2053 "Remove all trailing blank lines from the article."
2056 (let ((inhibit-read-only t))
2057 (goto-char (point-max))
2061 (while (and (not (bobp))
2062 (looking-at "^[ \t]*$")
2063 (not (gnus-annotation-in-region-p
2064 (point) (point-at-eol))))
2070 (defvar gnus-face-properties-alist))
2072 (defun article-display-face ()
2073 "Display any Face headers in the header."
2075 (let ((wash-face-p buffer-read-only))
2076 (gnus-with-article-headers
2077 ;; When displaying parts, this function can be called several times on
2078 ;; the same article, without any intended toggle semantic (as typing `W
2079 ;; D d' would have). So face deletion must occur only when we come from
2080 ;; an interactive command, that is when the *Article* buffer is
2082 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2083 (gnus-delete-images 'face)
2086 (when (and wash-face-p
2088 (goto-char (point-min))
2089 (not (re-search-forward "^Face:[\t ]*" nil t)))
2090 (gnus-buffer-live-p gnus-original-article-buffer))
2091 (set-buffer gnus-original-article-buffer))
2093 (mail-narrow-to-head)
2094 (while (gnus-article-goto-header "Face")
2095 (setq faces (nconc faces (list (mail-header-field-value)))))))
2096 (dolist (face faces)
2097 (let ((png (gnus-convert-face-to-png face))
2101 (apply 'gnus-create-image png 'png t
2102 (cdr (assq 'png gnus-face-properties-alist))))
2103 (gnus-article-goto-header "from")
2105 (insert "From: [no `from' set]\n")
2107 (gnus-add-wash-type 'face)
2108 (gnus-add-image 'face image)
2109 (gnus-put-image image nil 'face))))))
2112 (defun article-display-x-face (&optional force)
2113 "Look for an X-Face header and display it if present."
2114 (interactive (list 'force))
2115 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2116 (gnus-with-article-headers
2117 ;; Delete the old process, if any.
2118 (when (process-status "article-x-face")
2119 (delete-process "article-x-face"))
2120 ;; See the comment in `article-display-face'.
2121 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2122 ;; We have already displayed X-Faces, so we remove them
2124 (gnus-delete-images 'xface)
2126 (let (x-faces from face)
2128 (when (and wash-face-p
2130 (goto-char (point-min))
2131 (not (re-search-forward
2132 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2133 (gnus-buffer-live-p gnus-original-article-buffer))
2134 ;; If type `W f', use gnus-original-article-buffer,
2135 ;; otherwise use the current buffer because displaying
2136 ;; RFC822 parts calls this function too.
2137 (set-buffer gnus-original-article-buffer))
2139 (mail-narrow-to-head)
2140 (while (gnus-article-goto-header "X-Face")
2141 (push (mail-header-field-value) x-faces))
2142 (setq from (message-fetch-field "from"))))
2143 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2144 ;; single external face.
2145 (when (stringp gnus-article-x-face-command)
2146 (setq x-faces (list (car x-faces))))
2147 (while (and (setq face (pop x-faces))
2148 gnus-article-x-face-command
2150 ;; Check whether this face is censored.
2151 (not gnus-article-x-face-too-ugly)
2152 (and gnus-article-x-face-too-ugly from
2153 (not (string-match gnus-article-x-face-too-ugly
2155 ;; We display the face.
2156 (cond ((stringp gnus-article-x-face-command)
2157 ;; The command is a string, so we interpret the command
2158 ;; as a, well, command, and fork it off.
2159 (let ((process-connection-type nil))
2160 (process-kill-without-query
2162 "article-x-face" nil shell-file-name
2163 shell-command-switch gnus-article-x-face-command))
2166 (process-send-region "article-x-face"
2167 (point-min) (point-max)))
2168 (process-send-eof "article-x-face")))
2169 ((functionp gnus-article-x-face-command)
2170 ;; The command is a lisp function, so we call it.
2171 (funcall gnus-article-x-face-command face))
2173 (error "%s is not a function"
2174 gnus-article-x-face-command)))))))))
2176 (defun article-decode-mime-words ()
2177 "Decode all MIME-encoded words in the article."
2179 (gnus-with-article-buffer
2180 (let ((inhibit-point-motion-hooks t)
2181 (mail-parse-charset gnus-newsgroup-charset)
2182 (mail-parse-ignored-charsets
2183 (with-current-buffer gnus-summary-buffer
2184 gnus-newsgroup-ignored-charsets)))
2185 (mail-decode-encoded-word-region (point-min) (point-max)))))
2187 (defun article-decode-charset (&optional prompt)
2188 "Decode charset-encoded text in the article.
2189 If PROMPT (the prefix), prompt for a coding system to use."
2191 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2192 (inhibit-read-only t)
2193 (mail-parse-charset gnus-newsgroup-charset)
2194 (mail-parse-ignored-charsets
2195 (save-excursion (condition-case nil
2196 (set-buffer gnus-summary-buffer)
2198 gnus-newsgroup-ignored-charsets))
2199 ct cte ctl charset format)
2202 (article-narrow-to-head)
2203 (setq ct (message-fetch-field "Content-Type" t)
2204 cte (message-fetch-field "Content-Transfer-Encoding" t)
2205 ctl (and ct (ignore-errors
2206 (mail-header-parse-content-type ct)))
2209 (mm-read-coding-system "Charset to decode: "))
2211 (mail-content-type-get ctl 'charset)))
2212 format (and ctl (mail-content-type-get ctl 'format)))
2214 (setq cte (mail-header-strip cte)))
2215 (if (and ctl (not (string-match "/" (car ctl))))
2217 (goto-char (point-max)))
2220 (narrow-to-region (point) (point-max))
2221 (when (and (eq mail-parse-charset 'gnus-decoded)
2222 (eq (mm-body-7-or-8) '8bit))
2223 ;; The text code could have been decoded.
2224 (setq charset mail-parse-charset))
2225 (when (and (or (not ctl)
2226 (equal (car ctl) "text/plain"))
2227 (not format)) ;; article with format will decode later.
2229 charset (and cte (intern (downcase
2230 (gnus-strip-whitespace cte))))
2233 (defun article-decode-encoded-words ()
2234 "Remove encoded-word encoding from headers."
2235 (let ((inhibit-point-motion-hooks t)
2236 (mail-parse-charset gnus-newsgroup-charset)
2237 (mail-parse-ignored-charsets
2238 (save-excursion (condition-case nil
2239 (set-buffer gnus-summary-buffer)
2241 gnus-newsgroup-ignored-charsets))
2242 (inhibit-read-only t))
2244 (article-narrow-to-head)
2245 (funcall gnus-decode-header-function (point-min) (point-max)))))
2247 (defun article-decode-group-name ()
2248 "Decode group names in `Newsgroups:'."
2249 (let ((inhibit-point-motion-hooks t)
2250 (inhibit-read-only t)
2251 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2252 (when (and (or gnus-group-name-charset-method-alist
2253 gnus-group-name-charset-group-alist)
2254 (gnus-buffer-live-p gnus-original-article-buffer))
2256 (article-narrow-to-head)
2257 (with-current-buffer gnus-original-article-buffer
2258 (goto-char (point-min)))
2259 (while (re-search-forward
2260 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2261 (replace-match (save-match-data
2262 (gnus-decode-newsgroups
2263 ;; XXX how to use data in article buffer?
2264 (with-current-buffer gnus-original-article-buffer
2266 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2269 gnus-newsgroup-name method))
2271 (goto-char (point-min))
2272 (with-current-buffer gnus-original-article-buffer
2273 (goto-char (point-min)))
2274 (while (re-search-forward
2275 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2276 (replace-match (save-match-data
2277 (gnus-decode-newsgroups
2278 ;; XXX how to use data in article buffer?
2279 (with-current-buffer gnus-original-article-buffer
2281 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2284 gnus-newsgroup-name method))
2287 (autoload 'idna-to-unicode "idna")
2289 (defun article-decode-idna-rhs ()
2290 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2293 (let ((inhibit-point-motion-hooks t)
2294 (inhibit-read-only t))
2295 (article-narrow-to-head)
2296 (goto-char (point-min))
2297 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2299 (when (save-match-data
2300 (and (setq ace (match-string 1))
2302 (and (re-search-backward "^[^ \t]" nil t)
2303 (looking-at "From\\|To\\|Cc")))
2304 (setq unicode (idna-to-unicode ace))))
2305 (unless (string= ace unicode)
2306 (replace-match unicode nil nil nil 1)))))))))
2308 (defun article-de-quoted-unreadable (&optional force read-charset)
2309 "Translate a quoted-printable-encoded article.
2310 If FORCE, decode the article whether it is marked as quoted-printable
2312 If READ-CHARSET, ask for a coding system."
2313 (interactive (list 'force current-prefix-arg))
2315 (let ((inhibit-read-only t) type charset)
2316 (if (gnus-buffer-live-p gnus-original-article-buffer)
2317 (with-current-buffer gnus-original-article-buffer
2319 (gnus-fetch-field "content-transfer-encoding"))
2320 (let* ((ct (gnus-fetch-field "content-type"))
2323 (mail-header-parse-content-type ct)))))
2324 (setq charset (and ctl
2325 (mail-content-type-get ctl 'charset)))
2326 (if (stringp charset)
2327 (setq charset (intern (downcase charset)))))))
2329 (setq charset (mm-read-coding-system "Charset: " charset)))
2331 (setq charset gnus-newsgroup-charset))
2333 (and type (let ((case-fold-search t))
2334 (string-match "quoted-printable" type))))
2336 (quoted-printable-decode-region
2337 (point) (point-max) (mm-charset-to-coding-system charset))))))
2339 (defun article-de-base64-unreadable (&optional force read-charset)
2340 "Translate a base64 article.
2341 If FORCE, decode the article whether it is marked as base64 not.
2342 If READ-CHARSET, ask for a coding system."
2343 (interactive (list 'force current-prefix-arg))
2345 (let ((inhibit-read-only t) type charset)
2346 (if (gnus-buffer-live-p gnus-original-article-buffer)
2347 (with-current-buffer gnus-original-article-buffer
2349 (gnus-fetch-field "content-transfer-encoding"))
2350 (let* ((ct (gnus-fetch-field "content-type"))
2353 (mail-header-parse-content-type ct)))))
2354 (setq charset (and ctl
2355 (mail-content-type-get ctl 'charset)))
2356 (if (stringp charset)
2357 (setq charset (intern (downcase charset)))))))
2359 (setq charset (mm-read-coding-system "Charset: " charset)))
2361 (setq charset gnus-newsgroup-charset))
2363 (and type (let ((case-fold-search t))
2364 (string-match "base64" type))))
2367 (narrow-to-region (point) (point-max))
2368 (base64-decode-region (point-min) (point-max))
2369 (mm-decode-coding-region
2370 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2375 (defun article-decode-HZ ()
2376 "Translate a HZ-encoded article."
2380 (let ((inhibit-read-only t))
2381 (rfc1843-decode-region (point-min) (point-max)))))
2383 (defun article-unsplit-urls ()
2384 "Remove the newlines that some other mailers insert into URLs."
2387 (let ((inhibit-read-only t))
2388 (goto-char (point-min))
2389 (while (re-search-forward
2390 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2391 (replace-match "\\1\\3" t)))
2392 (when (interactive-p)
2393 (gnus-treat-article nil))))
2396 (defun article-wash-html (&optional read-charset)
2397 "Format an HTML article.
2398 If READ-CHARSET, ask for a coding system."
2401 (let ((inhibit-read-only t)
2403 (when (gnus-buffer-live-p gnus-original-article-buffer)
2404 (with-current-buffer gnus-original-article-buffer
2405 (let* ((ct (gnus-fetch-field "content-type"))
2408 (mail-header-parse-content-type ct)))))
2409 (setq charset (and ctl
2410 (mail-content-type-get ctl 'charset)))
2411 (when (stringp charset)
2412 (setq charset (intern (downcase charset)))))))
2414 (setq charset (mm-read-coding-system "Charset: " charset)))
2416 (setq charset gnus-newsgroup-charset))
2418 (save-window-excursion
2420 (narrow-to-region (point) (point-max))
2421 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2422 (entry (assq func mm-text-html-washer-alist)))
2424 (setq func (cdr entry)))
2429 (apply (car func) (cdr func))))))))))
2431 (defun gnus-article-wash-html-with-w3 ()
2432 "Wash the current buffer with w3."
2434 (let ((w3-strict-width (window-width))
2435 (url-standalone-mode t)
2436 (url-gateway-unplugged t)
2437 (w3-honor-stylesheets nil))
2439 (w3-region (point-min) (point-max))
2442 (defun gnus-article-wash-html-with-w3m ()
2443 "Wash the current buffer with emacs-w3m."
2446 (narrow-to-region (point) (point-max))
2447 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2448 w3m-force-redisplay)
2449 (w3m-region (point-min) (point-max)))
2450 (when (and mm-inline-text-html-with-w3m-keymap
2451 (boundp 'w3m-minor-mode-map)
2453 (add-text-properties
2454 (point-min) (point-max)
2455 (list 'keymap w3m-minor-mode-map
2456 ;; Put the mark meaning this part was rendered by emacs-w3m.
2457 'mm-inline-text-html-with-w3m t)))))
2459 (defun article-hide-list-identifiers ()
2460 "Remove list identifies from the Subject header.
2461 The `gnus-list-identifiers' variable specifies what to do."
2463 (let ((inhibit-point-motion-hooks t)
2464 (regexp (if (consp gnus-list-identifiers)
2465 (mapconcat 'identity gnus-list-identifiers " *\\|")
2466 gnus-list-identifiers))
2467 (inhibit-read-only t))
2471 (article-narrow-to-head)
2472 (goto-char (point-min))
2473 (while (re-search-forward
2474 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2476 (delete-region (match-beginning 2) (match-end 0))
2477 (beginning-of-line))
2478 (when (re-search-forward
2479 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2480 (delete-region (match-beginning 1) (match-end 1))))))))
2482 (defun article-hide-pem (&optional arg)
2483 "Toggle hiding of any PEM headers and signatures in the current article.
2484 If given a negative prefix, always show; if given a positive prefix,
2486 (interactive (gnus-article-hidden-arg))
2487 (unless (gnus-article-check-hidden-text 'pem arg)
2489 (let ((inhibit-read-only t) end)
2490 (goto-char (point-min))
2491 ;; Hide the horrendously ugly "header".
2492 (when (and (search-forward
2493 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2495 (setq end (1+ (match-beginning 0))))
2496 (gnus-add-wash-type 'pem)
2497 (gnus-article-hide-text-type
2499 (if (search-forward "\n\n" nil t)
2503 ;; Hide the trailer as well
2504 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2506 (gnus-article-hide-text-type
2507 (match-beginning 0) (match-end 0) 'pem)))))))
2509 (defun article-strip-banner ()
2510 "Strip the banners specified by the `banner' group parameter and by
2511 `gnus-article-address-banner-alist'."
2515 (let ((inhibit-point-motion-hooks t))
2516 (when (gnus-parameter-banner gnus-newsgroup-name)
2517 (article-really-strip-banner
2518 (gnus-parameter-banner gnus-newsgroup-name)))
2519 (when gnus-article-address-banner-alist
2520 ;; It is necessary to encode from fields before checking,
2521 ;; because `mail-header-parse-addresses' does not work
2522 ;; (reliably) on decoded headers. And more, it is
2523 ;; impossible to use `gnus-fetch-original-field' here,
2524 ;; because `article-strip-banner' may be called in draft
2525 ;; buffers to preview them.
2526 (let ((from (save-restriction
2528 (article-narrow-to-head)
2529 (mail-fetch-field "from"))))
2532 (caar (mail-header-parse-addresses
2533 (mail-encode-encoded-word-string from)))))
2535 (dolist (pair gnus-article-address-banner-alist)
2536 (when (string-match (car pair) from)
2538 (article-really-strip-banner (cdr pair)))))))))))))
2540 (defun article-really-strip-banner (banner)
2541 "Strip the banner specified by the argument."
2544 (let ((inhibit-point-motion-hooks t)
2545 (gnus-signature-limit nil)
2546 (inhibit-read-only t))
2549 ((eq banner 'signature)
2550 (when (gnus-article-narrow-to-signature)
2553 (delete-region (point) (point-max))))
2555 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2556 (while (re-search-forward banner nil t)
2557 (delete-region (match-beginning 0) (match-end 0)))))
2559 (while (re-search-forward banner nil t)
2560 (delete-region (match-beginning 0) (match-end 0)))))))))
2562 (defun article-babel ()
2563 "Translate article using an online translation service."
2566 (gnus-with-article-buffer
2567 (when (article-goto-body)
2568 (let* ((start (point))
2570 (orig (buffer-substring start end))
2571 (trans (babel-as-string orig)))
2573 (narrow-to-region start end)
2574 (delete-region start end)
2577 (defun article-hide-signature (&optional arg)
2578 "Hide the signature in the current article.
2579 If given a negative prefix, always show; if given a positive prefix,
2581 (interactive (gnus-article-hidden-arg))
2582 (unless (gnus-article-check-hidden-text 'signature arg)
2585 (let ((inhibit-read-only t))
2586 (when (gnus-article-narrow-to-signature)
2587 (gnus-article-hide-text-type
2588 (point-min) (point-max) 'signature))))))
2589 (gnus-set-mode-line 'article))
2591 (defun article-strip-headers-in-body ()
2592 "Strip offensive headers from bodies."
2596 (let ((case-fold-search t))
2597 (when (looking-at "x-no-archive:")
2598 (gnus-delete-line)))))
2600 (defun article-strip-leading-blank-lines ()
2601 "Remove all blank lines from the beginning of the article."
2604 (let ((inhibit-point-motion-hooks t)
2605 (inhibit-read-only t))
2606 (when (article-goto-body)
2607 (while (and (not (eobp))
2608 (looking-at "[ \t]*$"))
2609 (gnus-delete-line))))))
2611 (defun article-narrow-to-head ()
2612 "Narrow the buffer to the head of the message.
2613 Point is left at the beginning of the narrowed-to region."
2615 (goto-char (point-min))
2616 (if (search-forward "\n\n" nil 1)
2619 (goto-char (point-min)))
2621 (defun article-goto-body ()
2622 "Place point at the start of the body."
2623 (goto-char (point-min))
2625 ;; This variable is only bound when dealing with separate
2627 (article-goto-body-goes-to-point-min-p
2629 ((search-forward "\n\n" nil t)
2632 (goto-char (point-max))
2635 (defun article-strip-multiple-blank-lines ()
2636 "Replace consecutive blank lines with one empty line."
2639 (let ((inhibit-point-motion-hooks t)
2640 (inhibit-read-only t))
2641 ;; First make all blank lines empty.
2643 (while (re-search-forward "^[ \t]+$" nil t)
2644 (unless (gnus-annotation-in-region-p
2645 (match-beginning 0) (match-end 0))
2646 (replace-match "" nil t)))
2647 ;; Then replace multiple empty lines with a single empty line.
2649 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2650 (unless (gnus-annotation-in-region-p
2651 (match-beginning 0) (match-end 0))
2652 (delete-region (match-beginning 1) (match-end 1)))))))
2654 (defun article-strip-leading-space ()
2655 "Remove all white space from the beginning of the lines in the article."
2658 (let ((inhibit-point-motion-hooks t)
2659 (inhibit-read-only t))
2661 (while (re-search-forward "^[ \t]+" nil t)
2662 (replace-match "" t t)))))
2664 (defun article-strip-trailing-space ()
2665 "Remove all white space from the end of the lines in the article."
2668 (let ((inhibit-point-motion-hooks t)
2669 (inhibit-read-only t))
2671 (while (re-search-forward "[ \t]+$" nil t)
2672 (replace-match "" t t)))))
2674 (defun article-strip-blank-lines ()
2675 "Strip leading, trailing and multiple blank lines."
2677 (article-strip-leading-blank-lines)
2678 (article-remove-trailing-blank-lines)
2679 (article-strip-multiple-blank-lines))
2681 (defun article-strip-all-blank-lines ()
2682 "Strip all blank lines."
2685 (let ((inhibit-point-motion-hooks t)
2686 (inhibit-read-only t))
2688 (while (re-search-forward "^[ \t]*\n" nil t)
2689 (replace-match "" t t)))))
2691 (defun gnus-article-narrow-to-signature ()
2692 "Narrow to the signature; return t if a signature is found, else nil."
2693 (let ((inhibit-point-motion-hooks t))
2694 (when (gnus-article-search-signature)
2696 ;; Check whether we have some limits to what we consider
2697 ;; to be a signature.
2698 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2699 (list gnus-signature-limit)))
2701 (while (setq limit (pop limits))
2702 (if (or (and (integerp limit)
2703 (< (- (point-max) (point)) limit))
2705 (< (count-lines (point) (point-max)) limit))
2706 (and (functionp limit)
2708 (and (stringp limit)
2709 (not (re-search-forward limit nil t))))
2710 () ; This limit did not succeed.
2714 (narrow-to-region (point) (point-max))
2717 (defun gnus-article-search-signature ()
2718 "Search the current buffer for the signature separator.
2719 Put point at the beginning of the signature separator."
2720 (let ((cur (point)))
2721 (goto-char (point-max))
2722 (if (if (stringp gnus-signature-separator)
2723 (re-search-backward gnus-signature-separator nil t)
2724 (let ((seps gnus-signature-separator))
2726 (not (re-search-backward (car seps) nil t)))
2733 (defun gnus-article-hidden-arg ()
2734 "Return the current prefix arg as a number, or 0 if no prefix."
2735 (list (if current-prefix-arg
2736 (prefix-numeric-value current-prefix-arg)
2739 (defun gnus-article-check-hidden-text (type arg)
2740 "Return nil if hiding is necessary.
2741 Arg can be nil or a number. nil and positive means hide, negative
2742 means show, 0 means toggle."
2745 (let ((hide (gnus-article-hidden-text-p type)))
2751 (gnus-article-show-hidden-text type)
2754 (if (eq hide 'hidden)
2756 (gnus-article-show-hidden-text type)
2760 (defun gnus-article-hidden-text-p (type)
2761 "Say whether the current buffer contains hidden text of type TYPE."
2762 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2764 (not (get-text-property pos 'invisible))
2765 (not (get-text-property pos 'dummy-invisible)))
2767 (text-property-any (1+ pos) (point-max) 'article-type type)))
2772 (defun gnus-article-show-hidden-text (type &optional dummy)
2773 "Show all hidden text of type TYPE.
2774 Originally it is hide instead of DUMMY."
2775 (let ((inhibit-read-only t)
2776 (inhibit-point-motion-hooks t))
2777 (gnus-remove-text-properties-when
2779 (point-min) (point-max)
2780 (cons 'article-type (cons type
2781 gnus-hidden-properties)))
2782 (gnus-delete-wash-type type)))
2784 (defconst article-time-units
2785 `((year . ,(* 365.25 24 60 60))
2786 (week . ,(* 7 24 60 60))
2787 (day . ,(* 24 60 60))
2791 "Mapping from time units to seconds.")
2793 (defun gnus-article-forward-header ()
2794 "Move point to the start of the next header.
2795 If the current header is a continuation header, this can be several
2800 (if (looking-at "[ \t]+[^ \t]")
2804 (defun article-date-ut (&optional type highlight header)
2805 "Convert DATE date to universal time in the current article.
2806 If TYPE is `local', convert to local time; if it is `lapsed', output
2807 how much time has lapsed since DATE. For `lapsed', the value of
2808 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2809 should replace the \"Date:\" one, or should be added below it."
2810 (interactive (list 'ut t))
2811 (let* ((header (or header
2812 (message-fetch-field "date")
2814 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2817 ((not gnus-article-date-lapsed-new-header)
2823 (date (if (vectorp header) (mail-header-date header)
2825 (inhibit-point-motion-hooks t)
2830 (article-narrow-to-head)
2831 (when (re-search-forward tdate-regexp nil t)
2832 (setq bface (get-text-property (point-at-bol) 'face)
2833 date (or (get-text-property (point-at-bol)
2836 eface (get-text-property (1- (point-at-eol)) 'face))
2838 (when (and date (not (string= date "")))
2839 (goto-char (point-min))
2840 (let ((inhibit-read-only t))
2841 ;; Delete any old Date headers.
2842 (while (re-search-forward date-regexp nil t)
2844 (delete-region (point-at-bol)
2845 (progn (gnus-article-forward-header)
2847 (delete-region (point-at-bol)
2848 (progn (gnus-article-forward-header)
2851 (setq pos (point))))
2852 (when (and (not pos)
2853 (re-search-forward tdate-regexp nil t))
2855 (gnus-goto-char pos)
2856 (insert (article-make-date-line date (or type 'ut)))
2862 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2863 (add-text-properties (match-beginning 1) (1+ (match-end 1))
2864 (list 'original-date date 'face bface))
2865 (put-text-property (match-beginning 2) (match-end 2)
2868 (defun article-make-date-line (date type)
2869 "Return a DATE line of TYPE."
2870 (unless (memq type '(local ut original user iso8601 lapsed english))
2871 (error "Unknown conversion type: %s" type))
2873 (let ((time (date-to-time date)))
2875 ;; Convert to the local timezone.
2877 (concat "Date: " (message-make-date time)))
2878 ;; Convert to Universal Time.
2883 (let* ((e (parse-time-string date))
2884 (tm (apply 'encode-time e))
2886 (ls (- (cadr tm) (car (current-time-zone time)))))
2887 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2888 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2892 ;; Get the original date from the article.
2893 ((eq type 'original)
2894 (concat "Date: " (if (string-match "\n+$" date)
2895 (substring date 0 (match-beginning 0))
2897 ;; Let the user define the format.
2899 (let ((format (or (condition-case nil
2900 (with-current-buffer gnus-summary-buffer
2901 gnus-article-time-format)
2903 gnus-article-time-format)))
2904 (if (functionp format)
2905 (funcall format time)
2906 (concat "Date: " (format-time-string format time)))))
2909 (let ((tz (car (current-time-zone time))))
2912 (format-time-string "%Y%m%dT%H%M%S" time)
2913 (format "%s%02d%02d"
2914 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2915 (/ (% (abs tz) 3600) 60)))))
2916 ;; Do an X-Sent lapsed format.
2918 ;; If the date is seriously mangled, the timezone functions are
2919 ;; liable to bug out, so we ignore all errors.
2920 (let* ((now (current-time))
2921 (real-time (subtract-time now time))
2922 (real-sec (and real-time
2923 (+ (* (float (car real-time)) 65536)
2925 (sec (and real-time (abs real-sec)))
2935 ;; This is a bit convoluted, but basically we go
2936 ;; through the time units for years, weeks, etc,
2937 ;; and divide things to see whether that results
2938 ;; in positive answers.
2941 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2942 ;; The (remaining) seconds are too few to
2943 ;; be divided into this time unit.
2945 ;; It's big enough, so we output it.
2946 (setq sec (- sec (* num (cdr unit))))
2948 (concat (if prev ", " "") (int-to-string
2950 " " (symbol-name (car unit))
2951 (if (> num 1) "s" ""))
2953 article-time-units "")
2954 ;; If dates are odd, then it might appear like the
2955 ;; article was sent in the future.
2958 " in the future"))))))
2959 ;; Display the date in proper English
2961 (let ((dtime (decode-time time)))
2964 (number-to-string (nth 3 dtime))
2965 (let ((digit (% (nth 3 dtime) 10)))
2967 ((memq (nth 3 dtime) '(11 12 13)) "th")
2973 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2975 (number-to-string (nth 5 dtime))
2977 (format "%02d" (nth 2 dtime))
2979 (format "%02d" (nth 1 dtime)))))))
2981 (format "Date: %s (from Gnus)" date))))
2983 (defun article-date-local (&optional highlight)
2984 "Convert the current article date to the local timezone."
2985 (interactive (list t))
2986 (article-date-ut 'local highlight))
2988 (defun article-date-english (&optional highlight)
2989 "Convert the current article date to something that is proper English."
2990 (interactive (list t))
2991 (article-date-ut 'english highlight))
2993 (defun article-date-original (&optional highlight)
2994 "Convert the current article date to what it was originally.
2995 This is only useful if you have used some other date conversion
2996 function and want to see what the date was before converting."
2997 (interactive (list t))
2998 (article-date-ut 'original highlight))
3000 (defun article-date-lapsed (&optional highlight)
3001 "Convert the current article date to time lapsed since it was sent."
3002 (interactive (list t))
3003 (article-date-ut 'lapsed highlight))
3005 (defun article-update-date-lapsed ()
3006 "Function to be run from a timer to update the lapsed time line."
3007 (let (deactivate-mark)
3012 (set-buffer (window-buffer w))
3013 (when (eq major-mode 'gnus-article-mode)
3014 (let ((mark (point-marker)))
3015 (goto-char (point-min))
3016 (when (re-search-forward "^X-Sent:" nil t)
3017 (article-date-lapsed t))
3018 (goto-char (marker-position mark))
3019 (move-marker mark nil))))
3022 (defun gnus-start-date-timer (&optional n)
3023 "Start a timer to update the X-Sent header in the article buffers.
3024 The numerical prefix says how frequently (in seconds) the function
3029 (gnus-stop-date-timer)
3030 (setq article-lapsed-timer
3031 (run-at-time 1 n 'article-update-date-lapsed)))
3033 (defun gnus-stop-date-timer ()
3034 "Stop the X-Sent timer."
3036 (when article-lapsed-timer
3037 (nnheader-cancel-timer article-lapsed-timer)
3038 (setq article-lapsed-timer nil)))
3040 (defun article-date-user (&optional highlight)
3041 "Convert the current article date to the user-defined format.
3042 This format is defined by the `gnus-article-time-format' variable."
3043 (interactive (list t))
3044 (article-date-ut 'user highlight))
3046 (defun article-date-iso8601 (&optional highlight)
3047 "Convert the current article date to ISO8601."
3048 (interactive (list t))
3049 (article-date-ut 'iso8601 highlight))
3051 ;; (defun article-show-all ()
3052 ;; "Show all hidden text in the article buffer."
3055 ;; (let ((inhibit-read-only t))
3056 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3058 (defun article-remove-leading-whitespace ()
3059 "Remove excessive whitespace from all headers."
3063 (let ((inhibit-read-only t))
3064 (article-narrow-to-head)
3065 (goto-char (point-min))
3066 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3067 (delete-region (match-beginning 1) (match-end 1)))))))
3069 (defun article-emphasize (&optional arg)
3070 "Emphasize text according to `gnus-emphasis-alist'."
3071 (interactive (gnus-article-hidden-arg))
3072 (unless (gnus-article-check-hidden-text 'emphasis arg)
3076 (with-current-buffer gnus-summary-buffer
3077 gnus-article-emphasis-alist)
3079 gnus-emphasis-alist))
3080 (inhibit-read-only t)
3081 (props (append '(article-type emphasis)
3082 gnus-hidden-properties))
3083 regexp elem beg invisible visible face)
3086 (while (setq elem (pop alist))
3088 (setq regexp (car elem)
3089 invisible (nth 1 elem)
3090 visible (nth 2 elem)
3092 (while (re-search-forward regexp nil t)
3093 (when (and (match-beginning visible) (match-beginning invisible))
3094 (gnus-article-hide-text
3095 (match-beginning invisible) (match-end invisible) props)
3096 (gnus-article-unhide-text-type
3097 (match-beginning visible) (match-end visible) 'emphasis)
3098 (gnus-put-overlay-excluding-newlines
3099 (match-beginning visible) (match-end visible) 'face face)
3100 (gnus-add-wash-type 'emphasis)
3101 (goto-char (match-end invisible)))))))))
3103 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3104 "Setup newsgroup emphasis alist."
3105 (unless gnus-article-emphasis-alist
3106 (let ((name (and gnus-newsgroup-name
3107 (gnus-group-real-name gnus-newsgroup-name))))
3108 (make-local-variable 'gnus-article-emphasis-alist)
3109 (setq gnus-article-emphasis-alist
3111 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3112 (while (setq elem (pop alist))
3113 (when (and name (string-match (car elem) name))
3115 highlight (copy-sequence (cdr elem)))))
3117 (copy-sequence highlight-words)
3118 (if gnus-newsgroup-name
3119 (copy-sequence (gnus-group-find-parameter
3120 gnus-newsgroup-name 'highlight-words t)))
3121 gnus-emphasis-alist)))))
3124 (defvar gnus-summary-article-menu)
3125 (defvar gnus-summary-post-menu))
3127 ;;; Saving functions.
3129 (defun gnus-article-save (save-buffer file &optional num)
3130 "Save the currently selected article."
3131 (unless gnus-save-all-headers
3132 ;; Remove headers according to `gnus-saved-headers'.
3133 (let ((gnus-visible-headers
3134 (or gnus-saved-headers gnus-visible-headers))
3135 (gnus-article-buffer save-buffer))
3137 (set-buffer save-buffer)
3138 (article-hide-headers 1 t))))
3139 (save-window-excursion
3140 (if (not gnus-default-article-saver)
3141 (error "No default saver is defined")
3142 ;; !!! Magic! The saving functions all save
3143 ;; `gnus-save-article-buffer' (or so they think), but we
3144 ;; bind that variable to our save-buffer.
3145 (set-buffer gnus-article-buffer)
3146 (let* ((gnus-save-article-buffer save-buffer)
3149 ((not gnus-prompt-before-saving) 'default)
3150 ((eq gnus-prompt-before-saving 'always) nil)
3152 (gnus-number-of-articles-to-be-saved
3153 (when (eq gnus-prompt-before-saving t)
3155 (set-buffer gnus-article-current-summary)
3156 (funcall gnus-default-article-saver filename)))))
3158 (defun gnus-read-save-file-name (prompt &optional filename
3159 function group headers variable)
3161 (funcall function group headers (symbol-value variable)))
3166 ((eq filename 'default)
3172 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3175 (if (and gnus-number-of-articles-to-be-saved
3176 (> gnus-number-of-articles-to-be-saved 1))
3177 (format "these %d articles"
3178 gnus-number-of-articles-to-be-saved)
3181 ;; Let the split methods have their say.
3183 ;; No split name was found.
3186 (concat prompt " (default "
3187 (file-name-nondirectory default-name) ") ")
3188 (file-name-directory default-name)
3190 ;; A single group name is returned.
3191 ((stringp split-name)
3193 (funcall function split-name headers
3194 (symbol-value variable)))
3196 (concat prompt " (default "
3197 (file-name-nondirectory default-name) ") ")
3198 (file-name-directory default-name)
3200 ;; A single split name was found
3201 ((= 1 (length split-name))
3202 (let* ((name (expand-file-name
3204 gnus-article-save-directory))
3205 (dir (cond ((file-directory-p name)
3206 (file-name-as-directory name))
3207 ((file-exists-p name) name)
3208 (t gnus-article-save-directory))))
3210 (concat prompt " (default " name ") ")
3212 ;; A list of splits was found.
3214 (setq split-name (nreverse split-name))
3216 (let ((file-name-history
3217 (nconc split-name file-name-history)))
3221 (concat prompt " (`M-p' for defaults) ")
3222 gnus-article-save-directory
3224 gnus-article-save-directory)))
3225 (car (push result file-name-history)))))))
3226 ;; Create the directory.
3227 (gnus-make-directory (file-name-directory file))
3228 ;; If we have read a directory, we append the default file name.
3229 (when (file-directory-p file)
3230 (setq file (expand-file-name (file-name-nondirectory
3232 (file-name-as-directory file))))
3233 ;; Possibly translate some characters.
3234 (nnheader-translate-file-chars file))))))
3235 (gnus-make-directory (file-name-directory result))
3236 (set variable result)))
3238 (defun gnus-article-archive-name (group)
3239 "Return the first instance of an \"Archive-name\" in the current buffer."
3240 (let ((case-fold-search t))
3241 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3242 (nnheader-concat gnus-article-save-directory
3243 (match-string 1)))))
3245 (defun gnus-article-nndoc-name (group)
3246 "If GROUP is an nndoc group, return the name of the parent group."
3247 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3248 (gnus-group-get-parameter group 'save-article-group)))
3250 (defun gnus-summary-save-in-rmail (&optional filename)
3251 "Append this article to Rmail file.
3252 Optional argument FILENAME specifies file name.
3253 Directory to save to is default to `gnus-article-save-directory'."
3254 (setq filename (gnus-read-save-file-name
3255 "Save %s in rmail file:" filename
3256 gnus-rmail-save-name gnus-newsgroup-name
3257 gnus-current-headers 'gnus-newsgroup-last-rmail))
3258 (gnus-eval-in-buffer-window gnus-save-article-buffer
3262 (gnus-output-to-rmail filename))))
3265 (defun gnus-summary-save-in-mail (&optional filename)
3266 "Append this article to Unix mail file.
3267 Optional argument FILENAME specifies file name.
3268 Directory to save to is default to `gnus-article-save-directory'."
3269 (setq filename (gnus-read-save-file-name
3270 "Save %s in Unix mail file:" filename
3271 gnus-mail-save-name gnus-newsgroup-name
3272 gnus-current-headers 'gnus-newsgroup-last-mail))
3273 (gnus-eval-in-buffer-window gnus-save-article-buffer
3277 (if (and (file-readable-p filename)
3278 (file-regular-p filename)
3279 (mail-file-babyl-p filename))
3280 (rmail-output-to-rmail-file filename t)
3281 (gnus-output-to-mail filename)))))
3284 (defun gnus-summary-save-in-file (&optional filename overwrite)
3285 "Append this article to file.
3286 Optional argument FILENAME specifies file name.
3287 Directory to save to is default to `gnus-article-save-directory'."
3288 (setq filename (gnus-read-save-file-name
3289 "Save %s in file:" filename
3290 gnus-file-save-name gnus-newsgroup-name
3291 gnus-current-headers 'gnus-newsgroup-last-file))
3292 (gnus-eval-in-buffer-window gnus-save-article-buffer
3296 (when (and overwrite
3297 (file-exists-p filename))
3298 (delete-file filename))
3299 (gnus-output-to-file filename))))
3302 (defun gnus-summary-write-to-file (&optional filename)
3303 "Write this article to a file, overwriting it if the file exists.
3304 Optional argument FILENAME specifies file name.
3305 The directory to save in defaults to `gnus-article-save-directory'."
3306 (gnus-summary-save-in-file nil t))
3308 (defun gnus-summary-save-body-in-file (&optional filename)
3309 "Append this article body to a file.
3310 Optional argument FILENAME specifies file name.
3311 The directory to save in defaults to `gnus-article-save-directory'."
3312 (setq filename (gnus-read-save-file-name
3313 "Save %s body in file:" filename
3314 gnus-file-save-name gnus-newsgroup-name
3315 gnus-current-headers 'gnus-newsgroup-last-file))
3316 (gnus-eval-in-buffer-window gnus-save-article-buffer
3320 (when (article-goto-body)
3321 (narrow-to-region (point) (point-max)))
3322 (gnus-output-to-file filename))))
3325 (defun gnus-summary-save-in-pipe (&optional command)
3326 "Pipe this article to subprocess."
3328 (cond ((and (eq command 'default)
3329 gnus-last-shell-command)
3330 gnus-last-shell-command)
3335 "Shell command on %s: "
3336 (if (and gnus-number-of-articles-to-be-saved
3337 (> gnus-number-of-articles-to-be-saved 1))
3338 (format "these %d articles"
3339 gnus-number-of-articles-to-be-saved)
3341 gnus-last-shell-command))))
3342 (when (string-equal command "")
3343 (if gnus-last-shell-command
3344 (setq command gnus-last-shell-command)
3345 (error "A command is required")))
3346 (gnus-eval-in-buffer-window gnus-article-buffer
3349 (shell-command-on-region (point-min) (point-max) command nil)))
3350 (setq gnus-last-shell-command command))
3352 (defun gnus-summary-pipe-to-muttprint (&optional command)
3353 "Pipe this article to muttprint."
3354 (setq command (read-string
3355 "Print using command: " gnus-summary-muttprint-program
3356 nil gnus-summary-muttprint-program))
3357 (gnus-summary-save-in-pipe command))
3359 ;;; Article file names when saving.
3361 (defun gnus-capitalize-newsgroup (newsgroup)
3362 "Capitalize NEWSGROUP name."
3363 (when (not (zerop (length newsgroup)))
3364 (concat (char-to-string (upcase (aref newsgroup 0)))
3365 (substring newsgroup 1))))
3367 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3368 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3369 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3370 Otherwise, it is like ~/News/news/group/num."
3373 (concat (if (gnus-use-long-file-name 'not-save)
3374 (gnus-capitalize-newsgroup newsgroup)
3375 (gnus-newsgroup-directory-form newsgroup))
3376 "/" (int-to-string (mail-header-number headers)))
3377 gnus-article-save-directory)))
3379 (string-equal (file-name-directory default)
3380 (file-name-directory last-file))
3381 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3383 (or last-file default))))
3385 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3386 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3387 If variable `gnus-use-long-file-name' is non-nil, it is
3388 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3391 (concat (if (gnus-use-long-file-name 'not-save)
3393 (gnus-newsgroup-directory-form newsgroup))
3394 "/" (int-to-string (mail-header-number headers)))
3395 gnus-article-save-directory)))
3397 (string-equal (file-name-directory default)
3398 (file-name-directory last-file))
3399 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3401 (or last-file default))))
3403 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3404 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3405 If variable `gnus-use-long-file-name' is non-nil, it is
3406 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3409 (if (gnus-use-long-file-name 'not-save)
3412 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3414 gnus-article-save-directory)))
3416 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3417 "Generate file name from sender."
3418 (let ((from (mail-header-from headers)))
3420 (if (and from (string-match "\\([^ <]+\\)@" from))
3421 (match-string 1 from)
3423 gnus-article-save-directory)))
3425 (defun article-verify-x-pgp-sig ()
3428 (if (gnus-buffer-live-p gnus-original-article-buffer)
3429 (let ((sig (with-current-buffer gnus-original-article-buffer
3430 (gnus-fetch-field "X-PGP-Sig")))
3434 (mml2015-clear-verify-function))
3436 (insert-buffer-substring gnus-original-article-buffer)
3437 (setq items (split-string sig))
3438 (message-narrow-to-head)
3439 (let ((inhibit-point-motion-hooks t)
3440 (case-fold-search t))
3441 ;; Don't verify multiple headers.
3442 (setq headers (mapconcat (lambda (header)
3444 (mail-fetch-field header)
3446 (split-string (nth 1 items) ",") "")))
3447 (delete-region (point-min) (point-max))
3448 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3449 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3454 (if (looking-at "^-")
3457 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3458 (insert "Version: " (car items) "\n\n")
3459 (insert (mapconcat 'identity (cddr items) "\n"))
3460 (insert "\n-----END PGP SIGNATURE-----\n")
3461 (let ((mm-security-handle (list (format "multipart/signed"))))
3462 (mml2015-clean-buffer)
3463 (let ((coding-system-for-write (or gnus-newsgroup-charset
3465 (funcall (mml2015-clear-verify-function)))
3467 (or (mm-handle-multipart-ctl-parameter
3468 mm-security-handle 'gnus-details)
3469 (mm-handle-multipart-ctl-parameter
3470 mm-security-handle 'gnus-info)))))
3472 (let ((inhibit-read-only t) bface eface)
3474 (message-narrow-to-head)
3475 (goto-char (point-max))
3477 (setq bface (get-text-property (point-at-bol) 'face)
3478 eface (get-text-property (1- (point-at-eol)) 'face))
3479 (message-remove-header "X-Gnus-PGP-Verify")
3480 (if (re-search-forward "^X-PGP-Sig:" nil t)
3482 (goto-char (point-max)))
3483 (narrow-to-region (point) (point))
3484 (insert "X-Gnus-PGP-Verify: " info "\n")
3485 (goto-char (point-min))
3488 (if (not (looking-at "^[ \t]"))
3492 (goto-char (point-min))
3493 (when (looking-at "\\([^:]+\\): *")
3494 (put-text-property (match-beginning 1) (1+ (match-end 1))
3496 (put-text-property (match-end 0) (point-max)
3497 'face eface)))))))))
3499 (defun article-verify-cancel-lock ()
3500 "Verify Cancel-Lock header."
3502 (if (gnus-buffer-live-p gnus-original-article-buffer)
3503 (canlock-verify gnus-original-article-buffer)))
3510 (setq afunc (car func)
3513 gfunc (intern (format "gnus-%s" func))))
3515 (when (fboundp afunc)
3516 `(lambda (&optional interactive &rest args)
3517 ,(documentation afunc t)
3518 (interactive (list t))
3520 (set-buffer gnus-article-buffer)
3522 (call-interactively ',afunc)
3523 (apply ',afunc args))))))))
3524 '(article-hide-headers
3525 article-verify-x-pgp-sig
3526 article-verify-cancel-lock
3527 article-hide-boring-headers
3528 article-treat-overstrike
3529 article-treat-ansi-sequences
3530 article-fill-long-lines
3531 article-capitalize-sentences
3533 article-remove-leading-whitespace
3534 article-display-x-face
3535 article-display-face
3536 article-de-quoted-unreadable
3537 article-de-base64-unreadable
3540 article-unsplit-urls
3541 article-hide-list-identifiers
3542 article-strip-banner
3545 article-hide-signature
3546 article-strip-headers-in-body
3547 article-remove-trailing-blank-lines
3548 article-strip-leading-blank-lines
3549 article-strip-multiple-blank-lines
3550 article-strip-leading-space
3551 article-strip-trailing-space
3552 article-strip-blank-lines
3553 article-strip-all-blank-lines
3555 article-date-english
3556 article-date-iso8601
3557 article-date-original
3559 article-decode-mime-words
3560 article-decode-charset
3561 article-decode-encoded-words
3565 article-treat-dumbquotes
3566 article-normalize-headers
3567 ;; (article-show-all . gnus-article-show-all-headers)
3571 ;;; Gnus article mode
3574 (put 'gnus-article-mode 'mode-class 'special)
3576 (set-keymap-parent gnus-article-mode-map widget-keymap)
3578 (gnus-define-keys gnus-article-mode-map
3579 " " gnus-article-goto-next-page
3580 "\177" gnus-article-goto-prev-page
3581 [delete] gnus-article-goto-prev-page
3582 [backspace] gnus-article-goto-prev-page
3583 "\C-c^" gnus-article-refer-article
3584 "h" gnus-article-show-summary
3585 "s" gnus-article-show-summary
3586 "\C-c\C-m" gnus-article-mail
3587 "?" gnus-article-describe-briefly
3588 "e" gnus-summary-edit-article
3589 "<" beginning-of-buffer
3591 "\C-c\C-i" gnus-info-find-node
3593 "R" gnus-article-reply-with-original
3594 "F" gnus-article-followup-with-original
3595 "\C-hk" gnus-article-describe-key
3596 "\C-hc" gnus-article-describe-key-briefly
3598 "\C-d" gnus-article-read-summary-keys
3599 "\M-*" gnus-article-read-summary-keys
3600 "\M-#" gnus-article-read-summary-keys
3601 "\M-^" gnus-article-read-summary-keys
3602 "\M-g" gnus-article-read-summary-keys)
3604 (substitute-key-definition
3605 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3607 (defun gnus-article-make-menu-bar ()
3608 (unless (boundp 'gnus-article-commands-menu)
3609 (gnus-summary-make-menu-bar))
3610 (gnus-turn-off-edit-menu 'article)
3611 (unless (boundp 'gnus-article-article-menu)
3613 gnus-article-article-menu gnus-article-mode-map ""
3615 ["Scroll forwards" gnus-article-goto-next-page t]
3616 ["Scroll backwards" gnus-article-goto-prev-page t]
3617 ["Show summary" gnus-article-show-summary t]
3618 ["Fetch Message-ID at point" gnus-article-refer-article t]
3619 ["Mail to address at point" gnus-article-mail t]
3620 ["Send a bug report" gnus-bug t]))
3623 gnus-article-treatment-menu gnus-article-mode-map ""
3624 ;; Fixme: this should use :active (and maybe :visible).
3626 ["Hide headers" gnus-article-hide-headers t]
3627 ["Hide signature" gnus-article-hide-signature t]
3628 ["Hide citation" gnus-article-hide-citation t]
3629 ["Treat overstrike" gnus-article-treat-overstrike t]
3630 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3631 ["Remove carriage return" gnus-article-remove-cr t]
3632 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3633 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3634 ["Remove base64" gnus-article-de-base64-unreadable t]
3635 ["Treat html" gnus-article-wash-html t]
3636 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3637 ["Decode HZ" gnus-article-decode-HZ t]))
3639 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3641 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3643 (gnus-run-hooks 'gnus-article-menu-hook)))
3645 (defun gnus-article-mode ()
3646 "Major mode for displaying an article.
3648 All normal editing commands are switched off.
3650 The following commands are available in addition to all summary mode
3652 \\<gnus-article-mode-map>
3653 \\[gnus-article-next-page]\t Scroll the article one page forwards
3654 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3655 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3656 \\[gnus-article-show-summary]\t Display the summary buffer
3657 \\[gnus-article-mail]\t Send a reply to the address near point
3658 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3659 \\[gnus-info-find-node]\t Go to the Gnus info node"
3661 (gnus-simplify-mode-line)
3662 (setq mode-name "Article")
3663 (setq major-mode 'gnus-article-mode)
3664 (make-local-variable 'minor-mode-alist)
3665 (use-local-map gnus-article-mode-map)
3666 (when (gnus-visual-p 'article-menu 'menu)
3667 (gnus-article-make-menu-bar)
3668 (when gnus-summary-tool-bar-map
3669 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3670 (gnus-update-format-specifications nil 'article-mode)
3671 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3672 (set (make-local-variable 'gnus-page-broken) nil)
3673 (make-local-variable 'gnus-button-marker-list)
3674 (make-local-variable 'gnus-article-current-summary)
3675 (make-local-variable 'gnus-article-mime-handles)
3676 (make-local-variable 'gnus-article-decoded-p)
3677 (make-local-variable 'gnus-article-mime-handle-alist)
3678 (make-local-variable 'gnus-article-wash-types)
3679 (make-local-variable 'gnus-article-image-alist)
3680 (make-local-variable 'gnus-article-charset)
3681 (make-local-variable 'gnus-article-ignored-charsets)
3682 (gnus-set-default-directory)
3683 (buffer-disable-undo)
3684 (setq buffer-read-only t
3685 show-trailing-whitespace nil)
3686 (set-syntax-table gnus-article-mode-syntax-table)
3687 (mm-enable-multibyte)
3688 (gnus-run-hooks 'gnus-article-mode-hook))
3690 (defun gnus-article-setup-buffer ()
3691 "Initialize the article buffer."
3692 (let* ((name (if gnus-single-article-buffer "*Article*"
3693 (concat "*Article " gnus-newsgroup-name "*")))
3695 (progn (string-match "\\*Article" name)
3696 (concat " *Original Article"
3697 (substring name (match-end 0))))))
3698 (setq gnus-article-buffer name)
3699 (setq gnus-original-article-buffer original)
3700 (setq gnus-article-mime-handle-alist nil)
3701 ;; This might be a variable local to the summary buffer.
3702 (unless gnus-single-article-buffer
3704 (set-buffer gnus-summary-buffer)
3705 (setq gnus-article-buffer name)
3706 (setq gnus-original-article-buffer original)
3707 (gnus-set-global-variables)))
3708 (gnus-article-setup-highlight-words)
3709 ;; Init original article buffer.
3711 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3712 (mm-enable-multibyte)
3713 (setq major-mode 'gnus-original-article-mode)
3714 (make-local-variable 'gnus-original-article))
3715 (if (get-buffer name)
3718 (when (and gnus-article-edit-mode
3721 (y-or-n-p "Article mode edit in progress; discard? ")))
3722 (error "Action aborted"))
3723 (set (make-local-variable 'gnus-article-edit-mode) nil)
3724 (when gnus-article-mime-handles
3725 (mm-destroy-parts gnus-article-mime-handles)
3726 (setq gnus-article-mime-handles nil))
3727 ;; Set it to nil in article-buffer!
3728 (setq gnus-article-mime-handle-alist nil)
3729 (buffer-disable-undo)
3730 (setq buffer-read-only t)
3731 ;; This list just keeps growing if we don't reset it.
3732 (setq gnus-button-marker-list nil)
3733 (unless (eq major-mode 'gnus-article-mode)
3734 (gnus-article-mode))
3737 (set-buffer (gnus-get-buffer-create name))
3739 (make-local-variable 'gnus-summary-buffer)
3740 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3741 (current-buffer)))))
3743 ;; Set article window start at LINE, where LINE is the number of lines
3744 ;; from the head of the article.
3745 (defun gnus-article-set-window-start (&optional line)
3747 (gnus-get-buffer-window gnus-article-buffer t)
3749 (set-buffer gnus-article-buffer)
3750 (goto-char (point-min))
3753 (gnus-message 6 "Moved to bookmark")
3754 (search-forward "\n\n" nil t)
3758 (defun gnus-article-prepare (article &optional all-headers header)
3759 "Prepare ARTICLE in article mode buffer.
3760 ARTICLE should either be an article number or a Message-ID.
3761 If ARTICLE is an id, HEADER should be the article headers.
3762 If ALL-HEADERS is non-nil, no headers are hidden."
3764 ;; Make sure we start in a summary buffer.
3765 (unless (eq major-mode 'gnus-summary-mode)
3766 (set-buffer gnus-summary-buffer))
3767 (setq gnus-summary-buffer (current-buffer))
3768 (let* ((gnus-article (if header (mail-header-number header) article))
3769 (summary-buffer (current-buffer))
3770 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3771 (group gnus-newsgroup-name)
3774 (gnus-article-setup-buffer)
3775 (set-buffer gnus-article-buffer)
3776 ;; Deactivate active regions.
3777 (when (and (boundp 'transient-mark-mode)
3778 transient-mark-mode)
3779 (setq mark-active nil))
3780 (if (not (setq result (let ((inhibit-read-only t))
3781 (gnus-request-article-this-buffer
3783 ;; There is no such article.
3785 (when (and (numberp article)
3786 (not (memq article gnus-newsgroup-sparse)))
3787 (setq gnus-article-current
3788 (cons gnus-newsgroup-name article))
3789 (set-buffer gnus-summary-buffer)
3790 (setq gnus-current-article article)
3791 (if (and (memq article gnus-newsgroup-undownloaded)
3792 (not (gnus-online (gnus-find-method-for-group
3793 gnus-newsgroup-name))))
3795 (gnus-summary-set-agent-mark article)
3796 (message "Message marked for downloading"))
3797 (gnus-summary-mark-article article gnus-canceled-mark)
3798 (unless (memq article gnus-newsgroup-sparse)
3799 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3800 (if (or (eq result 'pseudo)
3801 (eq result 'nneething))
3804 (set-buffer summary-buffer)
3805 (push article gnus-newsgroup-history)
3806 (setq gnus-last-article gnus-current-article
3807 gnus-current-article 0
3808 gnus-current-headers nil
3809 gnus-article-current nil)
3810 (if (eq result 'nneething)
3811 (gnus-configure-windows 'summary)
3812 (gnus-configure-windows 'article))
3813 (gnus-set-global-variables))
3814 (let ((gnus-article-mime-handle-alist-1
3815 gnus-article-mime-handle-alist))
3816 (gnus-set-mode-line 'article)))
3817 ;; The result from the `request' was an actual article -
3818 ;; or at least some text that is now displayed in the
3820 (when (and (numberp article)
3821 (not (eq article gnus-current-article)))
3822 ;; Seems like a new article has been selected.
3823 ;; `gnus-current-article' must be an article number.
3825 (set-buffer summary-buffer)
3826 (push article gnus-newsgroup-history)
3827 (setq gnus-last-article gnus-current-article
3828 gnus-current-article article
3829 gnus-current-headers
3830 (gnus-summary-article-header gnus-current-article)
3831 gnus-article-current
3832 (cons gnus-newsgroup-name gnus-current-article))
3833 (unless (vectorp gnus-current-headers)
3834 (setq gnus-current-headers nil))
3835 (gnus-summary-goto-subject gnus-current-article)
3836 (when (gnus-summary-show-thread)
3837 ;; If the summary buffer really was folded, the
3838 ;; previous goto may not actually have gone to
3839 ;; the right article, but the thread root instead.
3841 (gnus-summary-goto-subject gnus-current-article))
3842 (gnus-run-hooks 'gnus-mark-article-hook)
3843 (gnus-set-mode-line 'summary)
3844 (when (gnus-visual-p 'article-highlight 'highlight)
3845 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3846 ;; Set the global newsgroup variables here.
3847 (gnus-set-global-variables)
3848 (setq gnus-have-all-headers
3849 (or all-headers gnus-show-all-headers))))
3851 (gnus-configure-windows 'article))
3852 (when (or (numberp article)
3854 (gnus-article-prepare-display)
3856 (goto-char (point-min))
3857 (when gnus-break-pages
3858 (gnus-narrow-to-page)))
3859 (let ((gnus-article-mime-handle-alist-1
3860 gnus-article-mime-handle-alist))
3861 (gnus-set-mode-line 'article))
3865 (set-window-point (get-buffer-window (current-buffer)) (point))
3866 (gnus-configure-windows 'article)
3870 (defun gnus-article-prepare-display ()
3871 "Make the current buffer look like a nice article."
3872 ;; Hooks for getting information from the article.
3873 ;; This hook must be called before being narrowed.
3874 (let ((gnus-article-buffer (current-buffer))
3876 (inhibit-read-only t))
3877 (unless (eq major-mode 'gnus-article-mode)
3878 (gnus-article-mode))
3879 (setq buffer-read-only nil
3880 gnus-article-wash-types nil
3881 gnus-article-image-alist nil)
3882 (gnus-run-hooks 'gnus-tmp-internal-hook)
3883 (when gnus-display-mime-function
3884 (funcall gnus-display-mime-function))
3885 (gnus-run-hooks 'gnus-article-prepare-hook)))
3888 ;;; Gnus MIME viewing functions
3891 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3892 "Format of the MIME buttons.
3894 Valid specifiers include:
3896 %T MIME type, along with additional info
3897 %n The `name' parameter
3898 %d The description, if any
3899 %l The length of the encoded part
3900 %p The part identifier number
3901 %e Dots if the part isn't displayed
3903 General format specifiers can also be used. See Info node
3904 `(gnus)Formatting Variables'.")
3906 (defvar gnus-mime-button-line-format-alist
3907 '((?t gnus-tmp-type ?s)
3908 (?T gnus-tmp-type-long ?s)
3909 (?n gnus-tmp-name ?s)
3910 (?d gnus-tmp-description ?s)
3912 (?l gnus-tmp-length ?d)
3913 (?e gnus-tmp-dots ?s)))
3915 (defvar gnus-mime-button-commands
3916 '((gnus-article-press-button "\r" "Toggle Display")
3917 (gnus-mime-view-part "v" "View Interactively...")
3918 (gnus-mime-view-part-as-type "t" "View As Type...")
3919 (gnus-mime-view-part-as-charset "C" "View As charset...")
3920 (gnus-mime-save-part "o" "Save...")
3921 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3922 (gnus-mime-delete-part "d" "Delete part")
3923 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3924 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3925 (gnus-mime-view-part-internally "E" "View Internally")
3926 (gnus-mime-view-part-externally "e" "View Externally")
3927 (gnus-mime-print-part "p" "Print")
3928 (gnus-mime-pipe-part "|" "Pipe To Command...")
3929 (gnus-mime-action-on-part "." "Take action on the part...")))
3931 (defun gnus-article-mime-part-status ()
3932 (if gnus-article-mime-handle-alist-1
3933 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3935 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3938 (defvar gnus-mime-button-map
3939 (let ((map (make-sparse-keymap)))
3940 (define-key map gnus-mouse-2 'gnus-article-push-button)
3941 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3942 (dolist (c gnus-mime-button-commands)
3943 (define-key map (cadr c) (car c)))
3947 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3949 ,@(mapcar (lambda (c)
3950 (vector (caddr c) (car c) :enable t))
3951 gnus-mime-button-commands)))
3953 (defun gnus-mime-button-menu (event prefix)
3954 "Construct a context-sensitive menu of MIME commands."
3955 (interactive "e\nP")
3956 (save-window-excursion
3957 (let ((pos (event-start event)))
3958 (select-window (posn-window pos))
3959 (goto-char (posn-point pos))
3960 (gnus-article-check-buffer)
3961 (popup-menu gnus-mime-button-menu nil prefix))))
3963 (defun gnus-mime-view-all-parts (&optional handles)
3964 "View all the MIME parts."
3966 (with-current-buffer gnus-article-buffer
3967 (let ((handles (or handles gnus-article-mime-handles))
3968 (mail-parse-charset gnus-newsgroup-charset)
3969 (mail-parse-ignored-charsets
3970 (with-current-buffer gnus-summary-buffer
3971 gnus-newsgroup-ignored-charsets)))
3973 (mm-remove-parts handles)
3974 (goto-char (point-min))
3975 (or (search-forward "\n\n") (goto-char (point-max)))
3976 (let ((inhibit-read-only t))
3977 (delete-region (point) (point-max))
3978 (mm-display-parts handles))))))
3981 (defsubst gnus-article-edit-part (handles)
3982 "Edit an article in order to delete a mime part.
3983 This function is exclusively used by `gnus-mime-save-part-and-strip'
3984 and `gnus-mime-delete-part', and not provided at run-time normally."
3985 (gnus-article-edit-article
3988 (let ((mail-parse-charset (or gnus-article-charset
3989 ',gnus-newsgroup-charset))
3990 (mail-parse-ignored-charsets
3991 (or gnus-article-ignored-charsets
3992 ',gnus-newsgroup-ignored-charsets))
3993 (mbl mml-buffer-list))
3994 (setq mml-buffer-list nil)
3995 (insert-buffer gnus-original-article-buffer)
3996 (mime-to-mml ',handles)
3997 (setq gnus-article-mime-handles nil)
3998 (let ((mbl1 mml-buffer-list))
3999 (setq mml-buffer-list mbl)
4000 (set (make-local-variable 'mml-buffer-list) mbl1))
4001 (gnus-make-local-hook 'kill-buffer-hook)
4002 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4003 `(lambda (no-highlight)
4004 (let ((mail-parse-charset (or gnus-article-charset
4005 ',gnus-newsgroup-charset))
4006 (message-options message-options)
4007 (message-options-set-recipient)
4008 (mail-parse-ignored-charsets
4009 (or gnus-article-ignored-charsets
4010 ',gnus-newsgroup-ignored-charsets)))
4012 (mml-destroy-buffers)
4013 (remove-hook 'kill-buffer-hook
4014 'mml-destroy-buffers t)
4015 (kill-local-variable 'mml-buffer-list))
4016 (gnus-summary-edit-article-done
4017 ,(or (mail-header-references gnus-current-headers) "")
4018 ,(gnus-group-read-only-p)
4019 ,gnus-summary-buffer no-highlight)))
4020 (gnus-article-edit-done)
4021 (gnus-summary-expand-window)
4022 (gnus-summary-show-article)))
4024 (defun gnus-mime-save-part-and-strip ()
4025 "Save the MIME part under point then replace it with an external body."
4027 (gnus-article-check-buffer)
4028 (when (gnus-group-read-only-p)
4029 (error "The current group does not support deleting of parts"))
4030 (when (mm-complicated-handles gnus-article-mime-handles)
4032 The current article has a complicated MIME structure, giving up..."))
4033 (when (gnus-yes-or-no-p "\
4034 Deleting parts may malfunction or destroy the article; continue? ")
4035 (let* ((data (get-text-property (point) 'gnus-data))
4037 (handles gnus-article-mime-handles))
4038 (setq file (and data (mm-save-part data)))
4040 (with-current-buffer (mm-handle-buffer data)
4042 (insert "Content-Type: " (mm-handle-media-type data))
4043 (mml-insert-parameter-string (cdr (mm-handle-type data))
4046 (insert "Content-ID: " (message-make-message-id) "\n")
4047 (insert "Content-Transfer-Encoding: binary\n")
4050 (cdr (mm-make-handle nil
4051 `("message/external-body"
4052 (access-type . "LOCAL-FILE")
4054 (set-buffer gnus-summary-buffer)
4055 (gnus-article-edit-part handles)))))
4057 (defun gnus-mime-delete-part ()
4058 "Delete the MIME part under point.
4059 Replace it with some information about the removed part."
4061 (gnus-article-check-buffer)
4062 (when (gnus-group-read-only-p)
4063 (error "The current group does not support deleting of parts"))
4064 (when (mm-complicated-handles gnus-article-mime-handles)
4066 The current article has a complicated MIME structure, giving up..."))
4067 (when (gnus-yes-or-no-p "\
4068 Deleting parts may malfunction or destroy the article; continue? ")
4069 (let* ((data (get-text-property (point) 'gnus-data))
4070 (handles gnus-article-mime-handles)
4074 (mail-decode-encoded-word-string (or (mm-handle-description data)
4077 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4079 (type (mm-handle-media-type data)))
4081 (error "No MIME part under point"))
4082 (with-current-buffer (mm-handle-buffer data)
4083 (let ((bsize (format "%s" (buffer-size))))
4088 "| The following attachment has been deleted:\n"
4090 "| Type: " type "\n"
4091 "| Filename: " filename "\n"
4092 "| Size (encoded): " bsize " Byte\n"
4093 "| Description: " description "\n"
4096 (cdr (mm-make-handle
4097 nil `("text/plain") nil nil
4099 (format "Deleted attachment (%s bytes)" bsize))))))
4100 (set-buffer gnus-summary-buffer)
4101 (gnus-article-edit-part handles))))
4103 (defun gnus-mime-save-part ()
4104 "Save the MIME part under point."
4106 (gnus-article-check-buffer)
4107 (let ((data (get-text-property (point) 'gnus-data)))
4109 (mm-save-part data))))
4111 (defun gnus-mime-pipe-part ()
4112 "Pipe the MIME part under point to a process."
4114 (gnus-article-check-buffer)
4115 (let ((data (get-text-property (point) 'gnus-data)))
4117 (mm-pipe-part data))))
4119 (defun gnus-mime-view-part ()
4120 "Interactively choose a viewing method for the MIME part under point."
4122 (gnus-article-check-buffer)
4123 (let ((data (get-text-property (point) 'gnus-data)))
4125 (setq gnus-article-mime-handles
4127 gnus-article-mime-handles (setq data (copy-sequence data))))
4128 (mm-interactively-view-part data))))
4130 (defun gnus-mime-view-part-as-type-internal ()
4131 (gnus-article-check-buffer)
4132 (let* ((name (mail-content-type-get
4133 (mm-handle-type (get-text-property (point) 'gnus-data))
4135 (def-type (and name (mm-default-file-encoding name))))
4136 (and def-type (cons def-type 0))))
4138 (defun gnus-mime-view-part-as-type (&optional mime-type)
4139 "Choose a MIME media type, and view the part as such."
4142 (setq mime-type (completing-read
4143 "View as MIME type: "
4144 (mapcar #'list (mailcap-mime-types))
4146 (gnus-mime-view-part-as-type-internal))))
4147 (gnus-article-check-buffer)
4148 (let ((handle (get-text-property (point) 'gnus-data)))
4151 (mm-make-handle (mm-handle-buffer handle)
4152 (cons mime-type (cdr (mm-handle-type handle)))
4153 (mm-handle-encoding handle)
4154 (mm-handle-undisplayer handle)
4155 (mm-handle-disposition handle)
4156 (mm-handle-description handle)
4158 (mm-handle-id handle)))
4159 (setq gnus-article-mime-handles
4160 (mm-merge-handles gnus-article-mime-handles handle))
4161 (gnus-mm-display-part handle))))
4164 (require 'jka-compr))
4166 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4167 ;; emacs can do that itself.
4169 (defun gnus-mime-jka-compr-maybe-uncompress ()
4170 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4171 The uncompress method used is derived from `buffer-file-name'."
4172 (when (and (fboundp 'jka-compr-installed-p)
4173 (jka-compr-installed-p))
4174 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4176 (let ((basename (file-name-nondirectory buffer-file-name))
4177 (args (jka-compr-info-uncompress-args info))
4178 (prog (jka-compr-info-uncompress-program info))
4179 (message (jka-compr-info-uncompress-message info))
4180 (err-file (jka-compr-make-temp-name)))
4182 (message "%s %s..." message basename))
4184 (unless (memq (apply 'call-process-region
4185 (point-min) (point-max)
4187 t (list t err-file) nil
4189 jka-compr-acceptable-retval-list)
4190 (jka-compr-error prog args basename message err-file))
4191 (jka-compr-delete-temp-file err-file)))))))
4193 (defun gnus-mime-copy-part (&optional handle)
4194 "Put the MIME part under point into a new buffer.
4195 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4198 (gnus-article-check-buffer)
4199 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4200 (contents (and handle (mm-get-part handle)))
4202 (file-name-nondirectory
4204 (mail-content-type-get (mm-handle-type handle) 'name)
4205 (mail-content-type-get (mm-handle-disposition handle)
4208 (buffer (and base (generate-new-buffer base))))
4210 (switch-to-buffer buffer)
4212 ;; We do it this way to make `normal-mode' set the appropriate mode.
4215 (setq buffer-file-name (expand-file-name base))
4216 (gnus-mime-jka-compr-maybe-uncompress)
4218 (setq buffer-file-name nil))
4219 (goto-char (point-min)))))
4221 (defun gnus-mime-print-part (&optional handle filename)
4222 "Print the MIME part under point."
4223 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4224 (gnus-article-check-buffer)
4225 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4226 (contents (and handle (mm-get-part handle)))
4227 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4228 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4233 (mm-save-part-to-file handle file)
4234 (call-process shell-file-name nil
4235 (generate-new-buffer " *mm*")
4237 shell-command-switch
4239 printer file (mm-handle-type handle))))
4243 (gnus-print-buffer))
4244 (ps-despool filename)))))
4246 (defun gnus-mime-inline-part (&optional handle arg)
4247 "Insert the MIME part under point into the current buffer."
4248 (interactive (list nil current-prefix-arg))
4249 (gnus-article-check-buffer)
4250 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4253 (inhibit-read-only t))
4255 (if (and (not arg) (mm-handle-undisplayer handle))
4256 (mm-remove-part handle)
4257 (setq contents (mm-get-part handle))
4260 (setq charset (or (mail-content-type-get
4261 (mm-handle-type handle) 'charset)
4262 gnus-newsgroup-charset)))
4264 (if (mm-handle-undisplayer handle)
4265 (mm-remove-part handle))
4268 gnus-summary-show-article-charset-alist))
4269 (mm-read-coding-system "Charset: ")))))
4271 (mm-insert-inline handle
4273 (setq charset (mm-charset-to-coding-system
4275 (not (eq charset 'ascii)))
4276 (mm-decode-coding-string contents charset)
4280 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4281 "Insert the MIME part under point into the current buffer using the
4283 (interactive (list nil current-prefix-arg))
4284 (gnus-article-check-buffer)
4285 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4288 (inhibit-read-only t))
4290 (if (mm-handle-undisplayer handle)
4291 (mm-remove-part handle))
4292 (let ((gnus-newsgroup-charset
4294 gnus-summary-show-article-charset-alist))
4295 (mm-read-coding-system "Charset: ")))
4296 (gnus-newsgroup-ignored-charsets 'gnus-all))
4297 (gnus-article-press-button)))))
4299 (defun gnus-mime-view-part-externally (&optional handle)
4300 "View the MIME part under point with an external viewer."
4302 (gnus-article-check-buffer)
4303 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4304 (mm-user-display-methods nil)
4305 (mm-inlined-types nil)
4306 (mail-parse-charset gnus-newsgroup-charset)
4307 (mail-parse-ignored-charsets
4308 (with-current-buffer gnus-summary-buffer
4309 gnus-newsgroup-ignored-charsets)))
4311 (if (mm-handle-undisplayer handle)
4312 (mm-remove-part handle)
4313 (mm-display-part handle)))))
4315 (defun gnus-mime-view-part-internally (&optional handle)
4316 "View the MIME part under point with an internal viewer.
4317 If no internal viewer is available, use an external viewer."
4319 (gnus-article-check-buffer)
4320 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4321 (mm-inlined-types '(".*"))
4322 (mm-inline-large-images t)
4323 (mail-parse-charset gnus-newsgroup-charset)
4324 (mail-parse-ignored-charsets
4325 (with-current-buffer gnus-summary-buffer
4326 gnus-newsgroup-ignored-charsets))
4327 (inhibit-read-only t))
4329 (if (mm-handle-undisplayer handle)
4330 (mm-remove-part handle)
4331 (mm-display-part handle)))))
4333 (defun gnus-mime-action-on-part (&optional action)
4334 "Do something with the MIME attachment at \(point\)."
4336 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4337 (gnus-article-check-buffer)
4338 (let ((action-pair (assoc action gnus-mime-action-alist)))
4340 (funcall (cdr action-pair)))))
4342 (defun gnus-article-part-wrapper (n function)
4343 (with-current-buffer gnus-article-buffer
4344 (when (> n (length gnus-article-mime-handle-alist))
4345 (error "No such part"))
4346 (gnus-article-goto-part n)
4347 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4348 (funcall function handle))))
4350 (defun gnus-article-pipe-part (n)
4351 "Pipe MIME part N, which is the numerical prefix."
4353 (gnus-article-part-wrapper n 'mm-pipe-part))
4355 (defun gnus-article-save-part (n)
4356 "Save MIME part N, which is the numerical prefix."
4358 (gnus-article-part-wrapper n 'mm-save-part))
4360 (defun gnus-article-interactively-view-part (n)
4361 "View MIME part N interactively, which is the numerical prefix."
4363 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4365 (defun gnus-article-copy-part (n)
4366 "Copy MIME part N, which is the numerical prefix."
4368 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4370 (defun gnus-article-view-part-as-charset (n)
4371 "View MIME part N using a specified charset.
4372 N is the numerical prefix."
4374 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4376 (defun gnus-article-view-part-externally (n)
4377 "View MIME part N externally, which is the numerical prefix."
4379 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4381 (defun gnus-article-inline-part (n)
4382 "Inline MIME part N, which is the numerical prefix."
4384 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4386 (defun gnus-article-mime-match-handle-first (condition)
4389 (dolist (ihandle gnus-article-mime-handle-alist)
4391 ((functionp condition)
4392 (funcall condition (cdr ihandle)))
4393 ((eq condition 'undisplayed)
4394 (not (or (mm-handle-undisplayer (cdr ihandle))
4395 (equal (mm-handle-media-type (cdr ihandle))
4396 "multipart/alternative"))))
4397 ((eq condition 'undisplayed-alternative)
4398 (not (mm-handle-undisplayer (cdr ihandle))))
4400 (gnus-article-goto-part (car ihandle))
4401 (or (not n) (< (car ihandle) n)))
4402 (setq n (car ihandle))))
4406 (defun gnus-article-view-part (&optional n)
4407 "View MIME part N, which is the numerical prefix."
4409 (with-current-buffer gnus-article-buffer
4410 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4411 gnus-article-mime-match-handle-function)))
4412 (when (> n (length gnus-article-mime-handle-alist))
4413 (error "No such part"))
4414 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4415 (when (gnus-article-goto-part n)
4416 (if (equal (car handle) "multipart/alternative")
4417 (gnus-article-press-button)
4418 (when (eq (gnus-mm-display-part handle) 'internal)
4419 (gnus-set-window-start)))))))
4421 (defsubst gnus-article-mime-total-parts ()
4422 (if (bufferp (car gnus-article-mime-handles))
4424 (1- (length gnus-article-mime-handles))))
4426 (defun gnus-mm-display-part (handle)
4427 "Display HANDLE and fix MIME button."
4428 (let ((id (get-text-property (point) 'gnus-part))
4430 (inhibit-read-only t))
4433 (let ((window (selected-window))
4434 (mail-parse-charset gnus-newsgroup-charset)
4435 (mail-parse-ignored-charsets
4436 (if (gnus-buffer-live-p gnus-summary-buffer)
4437 (with-current-buffer gnus-summary-buffer
4438 gnus-newsgroup-ignored-charsets)
4442 (let ((win (gnus-get-buffer-window (current-buffer) t))
4445 (select-window win))
4448 (if (mm-handle-displayed-p handle)
4449 ;; This will remove the part.
4450 (mm-display-part handle)
4452 (narrow-to-region (point)
4453 (if (eobp) (point) (1+ (point))))
4454 (mm-display-part handle)
4455 ;; We narrow to the part itself and
4456 ;; then call the treatment functions.
4457 (goto-char (point-min))
4459 (narrow-to-region (point) (point-max))
4462 (gnus-article-mime-total-parts)
4463 (mm-handle-media-type handle)))))
4464 (if (window-live-p window)
4465 (select-window window)))))
4468 (gnus-insert-mime-button
4469 handle id (list (mm-handle-displayed-p handle)))
4470 (goto-char point))))
4472 (defun gnus-article-goto-part (n)
4473 "Go to MIME part N."
4474 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4476 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4477 (let ((gnus-tmp-name
4478 (or (mail-content-type-get (mm-handle-type handle) 'name)
4479 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4480 (mail-content-type-get (mm-handle-type handle) 'url)
4482 (gnus-tmp-type (mm-handle-media-type handle))
4483 (gnus-tmp-description
4484 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4487 (if (if displayed (car displayed)
4488 (mm-handle-displayed-p handle))
4490 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4492 gnus-tmp-type-long b e)
4493 (when (string-match ".*/" gnus-tmp-name)
4494 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4495 (setq gnus-tmp-type-long (concat gnus-tmp-type
4496 (and (not (equal gnus-tmp-name ""))
4497 (concat "; " gnus-tmp-name))))
4498 (unless (equal gnus-tmp-description "")
4499 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4504 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4505 `(keymap ,gnus-mime-button-map
4506 gnus-callback gnus-mm-display-part
4507 gnus-part ,gnus-tmp-id
4508 article-type annotation
4511 ;; Exclude a newline.
4514 (widget-convert-button
4517 :action 'gnus-widget-press-button
4518 :button-keymap gnus-mime-button-map
4520 (lambda (widget/window &optional overlay pos)
4521 ;; Needed to properly clear the message due to a bug in
4522 ;; wid-edit (XEmacs only).
4523 (if (boundp 'help-echo-owns-message)
4524 (setq help-echo-owns-message t))
4526 "%S: %s the MIME part; %S: more options"
4527 (aref gnus-mouse-2 0)
4528 ;; XEmacs will get a single widget arg; Emacs 21 will get
4529 ;; window, overlay, position.
4530 (if (mm-handle-displayed-p
4532 (with-current-buffer (gnus-overlay-buffer overlay)
4533 (widget-get (widget-at (gnus-overlay-start overlay))
4535 (widget-get widget/window :mime-handle)))
4537 (aref gnus-down-mouse-3 0))))))
4539 (defun gnus-widget-press-button (elems el)
4540 (goto-char (widget-get elems :from))
4541 (gnus-article-press-button))
4543 (defvar gnus-displaying-mime nil)
4545 (defun gnus-display-mime (&optional ihandles)
4546 "Display the MIME parts."
4548 (save-selected-window
4549 (let ((window (get-buffer-window gnus-article-buffer))
4552 (select-window window)
4553 ;; We have to do this since selecting the window
4554 ;; may change the point. So we set the window point.
4555 (set-window-point window point)))
4556 (let ((handles ihandles)
4557 (inhibit-read-only t)
4558 handle name type b e display)
4560 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4561 (when gnus-article-emulate-mime
4562 (mm-uu-dissect-text-parts handles)))
4563 (gnus-article-emulate-mime
4564 (setq handles (mm-uu-dissect))))
4565 (when (and (not ihandles)
4566 (not gnus-displaying-mime))
4567 ;; Top-level call; we clean up.
4568 (when gnus-article-mime-handles
4569 (mm-destroy-parts gnus-article-mime-handles)
4570 (setq gnus-article-mime-handle-alist nil));; A trick.
4571 (setq gnus-article-mime-handles handles)
4572 ;; We allow users to glean info from the handles.
4573 (when gnus-article-mime-part-function
4574 (gnus-mime-part-function handles)))
4576 (or (not (stringp (car handles)))
4579 (when (and (not ihandles)
4580 (not gnus-displaying-mime))
4581 ;; Clean up for mime parts.
4583 (delete-region (point) (point-max)))
4584 (let ((gnus-displaying-mime t))
4585 (gnus-mime-display-part handles)))
4588 (narrow-to-region (point) (point-max))
4589 (gnus-treat-article nil 1 1)
4592 ;; Highlight the headers.
4596 (narrow-to-region (point-min) (point))
4597 (gnus-treat-article 'head))))))))
4599 (defcustom gnus-mime-display-multipart-as-mixed nil
4600 "Display \"multipart\" parts as \"multipart/mixed\".
4602 If t, it overrides nil values of
4603 `gnus-mime-display-multipart-alternative-as-mixed' and
4604 `gnus-mime-display-multipart-related-as-mixed'."
4605 :group 'gnus-article-mime
4608 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4609 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4611 :group 'gnus-article-mime
4614 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4615 "Display \"multipart/related\" parts as \"multipart/mixed\".
4617 If displaying \"text/html\" is discouraged \(see
4618 `mm-discouraged-alternatives'\) images or other material inside a
4619 \"multipart/related\" part might be overlooked when this variable is nil."
4621 :group 'gnus-article-mime
4624 (defun gnus-mime-display-part (handle)
4627 ((not (stringp (car handle)))
4628 (gnus-mime-display-single handle))
4629 ;; User-defined multipart
4630 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4631 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4633 ;; multipart/alternative
4634 ((and (equal (car handle) "multipart/alternative")
4635 (not (or gnus-mime-display-multipart-as-mixed
4636 gnus-mime-display-multipart-alternative-as-mixed)))
4637 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4638 (push (cons id handle) gnus-article-mime-handle-alist)
4639 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4640 ;; multipart/related
4641 ((and (equal (car handle) "multipart/related")
4642 (not (or gnus-mime-display-multipart-as-mixed
4643 gnus-mime-display-multipart-related-as-mixed)))
4644 ;;;!!!We should find the start part, but we just default
4645 ;;;!!!to the first part.
4646 ;;(gnus-mime-display-part (cadr handle))
4647 ;;;!!! Most multipart/related is an HTML message plus images.
4648 ;;;!!! Unfortunately we are unable to let W3 display those
4649 ;;;!!! included images, so we just display it as a mixed multipart.
4650 ;;(gnus-mime-display-mixed (cdr handle))
4651 ;;;!!! No, w3 can display everything just fine.
4652 (gnus-mime-display-part (cadr handle)))
4653 ((equal (car handle) "multipart/signed")
4654 (gnus-add-wash-type 'signed)
4655 (gnus-mime-display-security handle))
4656 ((equal (car handle) "multipart/encrypted")
4657 (gnus-add-wash-type 'encrypted)
4658 (gnus-mime-display-security handle))
4659 ;; Other multiparts are handled like multipart/mixed.
4661 (gnus-mime-display-mixed (cdr handle)))))
4663 (defun gnus-mime-part-function (handles)
4664 (if (stringp (car handles))
4665 (mapcar 'gnus-mime-part-function (cdr handles))
4666 (funcall gnus-article-mime-part-function handles)))
4668 (defun gnus-mime-display-mixed (handles)
4669 (mapcar 'gnus-mime-display-part handles))
4671 (defun gnus-mime-display-single (handle)
4672 (let ((type (mm-handle-media-type handle))
4673 (ignored gnus-ignored-mime-types)
4680 (when (string-match (pop ignored) type)
4681 (throw 'ignored nil)))
4682 (if (and (setq not-attachment
4683 (and (not (mm-inline-override-p handle))
4684 (or (not (mm-handle-disposition handle))
4685 (equal (car (mm-handle-disposition handle))
4687 (mm-attachment-override-p handle))))
4688 (mm-automatic-display-p handle)
4690 (mm-inlinable-p handle)
4691 (mm-inlined-p handle))
4692 (mm-automatic-external-display-p type)))
4694 (when (equal (mm-handle-media-supertype handle) "text")
4696 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4698 (push (cons id handle) gnus-article-mime-handle-alist)
4699 (when (or (not display)
4700 (not (gnus-unbuttonized-mime-type-p type)))
4701 (gnus-insert-mime-button
4702 handle id (list (or display (and not-attachment text))))
4703 (gnus-article-insert-newline)
4704 ;; Remember modify the number of forward lines.
4712 (let ((mail-parse-charset gnus-newsgroup-charset)
4713 (mail-parse-ignored-charsets
4714 (save-excursion (condition-case ()
4715 (set-buffer gnus-summary-buffer)
4717 gnus-newsgroup-ignored-charsets)))
4718 (mm-display-part handle t))
4719 (goto-char (point-max)))
4720 ((and text not-attachment)
4724 (gnus-article-insert-newline)
4725 (mm-display-inline handle)
4726 (goto-char (point-max))))
4730 (narrow-to-region beg (point))
4733 (gnus-article-mime-total-parts)
4734 (mm-handle-media-type handle)))))))))
4736 (defun gnus-unbuttonized-mime-type-p (type)
4737 "Say whether TYPE is to be unbuttonized."
4738 (unless gnus-inhibit-mime-unbuttonizing
4740 (let ((types gnus-unbuttonized-mime-types))
4742 (when (string-match (pop types) type)
4743 (throw 'found t)))))
4745 (let ((types gnus-buttonized-mime-types))
4747 (when (string-match (pop types) type)
4748 (throw 'found t)))))))))
4750 (defun gnus-article-insert-newline ()
4751 "Insert a newline, but mark it as undeletable."
4752 (gnus-put-text-property
4753 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4755 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4756 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4759 handle (inhibit-read-only t) from props begend not-pref)
4760 (save-window-excursion
4763 (narrow-to-region (car ibegend)
4766 (goto-char (car ibegend))
4769 (delete-region (point-min) (point-max))
4770 (mm-remove-parts handles))
4771 (setq begend (list (point-marker)))
4773 (unless (setq not-pref (cadr (member preferred ihandles)))
4774 (setq not-pref (car ihandles)))
4777 (not (gnus-unbuttonized-mime-type-p
4778 "multipart/alternative")))
4779 (gnus-add-text-properties
4782 (insert (format "%d. " id))
4786 (unless ,(not ibegend)
4787 (setq gnus-article-mime-handle-alist
4788 ',gnus-article-mime-handle-alist))
4789 (gnus-mime-display-alternative
4790 ',ihandles ',not-pref ',begend ,id))
4791 keymap ,gnus-mime-button-map
4792 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4793 face ,gnus-article-button-face
4796 (widget-convert-button 'link from (point)
4797 :action 'gnus-widget-press-button
4798 :button-keymap gnus-widget-button-keymap)
4800 (while (setq handle (pop handles))
4801 (gnus-add-text-properties
4804 (insert (format "(%c) %-18s"
4805 (if (equal handle preferred) ?* ? )
4806 (mm-handle-media-type handle)))
4810 (unless ,(not ibegend)
4811 (setq gnus-article-mime-handle-alist
4812 ',gnus-article-mime-handle-alist))
4813 (gnus-mime-display-alternative
4814 ',ihandles ',handle ',begend ,id))
4815 keymap ,gnus-mime-button-map
4816 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4817 face ,gnus-article-button-face
4820 (widget-convert-button 'link from (point)
4821 :action 'gnus-widget-press-button
4822 :button-keymap gnus-widget-button-keymap)
4826 (if (stringp (car preferred))
4827 (gnus-display-mime preferred)
4828 (let ((mail-parse-charset gnus-newsgroup-charset)
4829 (mail-parse-ignored-charsets
4830 (with-current-buffer gnus-summary-buffer
4831 gnus-newsgroup-ignored-charsets)))
4832 (mm-display-part preferred)
4836 (narrow-to-region (car begend) (point-max))
4838 nil (length gnus-article-mime-handle-alist)
4839 (gnus-article-mime-total-parts)
4840 (mm-handle-media-type handle))))))
4841 (goto-char (point-max))
4842 (setcdr begend (point-marker)))))
4844 (goto-char point))))
4846 (defconst gnus-article-wash-status-strings
4847 (let ((alist '((cite "c" "Possible hidden citation text"
4848 " " "All citation text visible")
4849 (headers "h" "Hidden headers"
4850 " " "All headers visible.")
4851 (pgp "p" "Encrypted or signed message status hidden"
4852 " " "No hidden encryption nor digital signature status")
4853 (signature "s" "Signature has been hidden"
4854 " " "Signature is visible")
4855 (overstrike "o" "Overstrike (^H) characters applied"
4856 " " "No overstrike characters applied")
4857 (emphasis "e" "/*_Emphasis_*/ characters applied"
4858 " " "No /*_emphasis_*/ characters applied")))
4860 (dolist (entry alist result)
4861 (let ((key (nth 0 entry))
4862 (on (copy-sequence (nth 1 entry)))
4863 (on-help (nth 2 entry))
4864 (off (copy-sequence (nth 3 entry)))
4865 (off-help (nth 4 entry)))
4866 (put-text-property 0 1 'help-echo on-help on)
4867 (put-text-property 0 1 'help-echo off-help off)
4868 (push (list key on off) result))))
4869 "Alist of strings describing wash status in the mode line.
4870 Each entry has the form (KEY ON OF), where the KEY is a symbol
4871 representing the particular washing function, ON is the string to use
4872 in the article mode line when the washing function is active, and OFF
4873 is the string to use when it is inactive.")
4875 (defun gnus-article-wash-status-entry (key value)
4876 (let ((entry (assoc key gnus-article-wash-status-strings)))
4877 (if value (nth 1 entry) (nth 2 entry))))
4879 (defun gnus-article-wash-status ()
4880 "Return a string which display status of article washing."
4881 (with-current-buffer gnus-article-buffer
4882 (let ((cite (memq 'cite gnus-article-wash-types))
4883 (headers (memq 'headers gnus-article-wash-types))
4884 (boring (memq 'boring-headers gnus-article-wash-types))
4885 (pgp (memq 'pgp gnus-article-wash-types))
4886 (pem (memq 'pem gnus-article-wash-types))
4887 (signed (memq 'signed gnus-article-wash-types))
4888 (encrypted (memq 'encrypted gnus-article-wash-types))
4889 (signature (memq 'signature gnus-article-wash-types))
4890 (overstrike (memq 'overstrike gnus-article-wash-types))
4891 (emphasis (memq 'emphasis gnus-article-wash-types)))
4893 (gnus-article-wash-status-entry 'cite cite)
4894 (gnus-article-wash-status-entry 'headers (or headers boring))
4895 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4896 (gnus-article-wash-status-entry 'signature signature)
4897 (gnus-article-wash-status-entry 'overstrike overstrike)
4898 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4900 (defun gnus-add-wash-type (type)
4901 "Add a washing of TYPE to the current status."
4902 (add-to-list 'gnus-article-wash-types type))
4904 (defun gnus-delete-wash-type (type)
4905 "Add a washing of TYPE to the current status."
4906 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4908 (defun gnus-add-image (category image)
4909 "Add IMAGE of CATEGORY to the list of displayed images."
4910 (let ((entry (assq category gnus-article-image-alist)))
4912 (setq entry (list category))
4913 (push entry gnus-article-image-alist))
4914 (nconc entry (list image))))
4916 (defun gnus-delete-images (category)
4917 "Delete all images in CATEGORY."
4918 (let ((entry (assq category gnus-article-image-alist)))
4919 (dolist (image (cdr entry))
4920 (gnus-remove-image image category))
4921 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4922 (gnus-delete-wash-type category)))
4924 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4926 (defun gnus-article-maybe-hide-headers ()
4927 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4928 Provided for backwards compatibility."
4929 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4930 (not (with-current-buffer gnus-summary-buffer
4931 gnus-have-all-headers)))
4932 (not gnus-inhibit-hiding))
4933 (gnus-article-hide-headers)))
4937 (defun gnus-output-to-file (file-name)
4938 "Append the current article to a file named FILE-NAME."
4939 (let ((artbuf (current-buffer)))
4941 (insert-buffer-substring artbuf)
4942 ;; Append newline at end of the buffer as separator, and then
4944 (goto-char (point-max))
4946 (let ((file-name-coding-system nnmail-pathname-coding-system))
4947 (mm-append-to-file (point-min) (point-max) file-name))
4950 (defun gnus-narrow-to-page (&optional arg)
4951 "Narrow the article buffer to a page.
4952 If given a numerical ARG, move forward ARG pages."
4954 (setq arg (if arg (prefix-numeric-value arg) 0))
4956 (set-buffer gnus-article-buffer)
4957 (goto-char (point-min))
4959 ;; Remove any old next/prev buttons.
4960 (when (gnus-visual-p 'page-marker)
4961 (let ((inhibit-read-only t))
4962 (gnus-remove-text-with-property 'gnus-prev)
4963 (gnus-remove-text-with-property 'gnus-next)))
4966 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4968 (re-search-forward page-delimiter nil 'move arg)))
4969 (goto-char (match-end 0))
4971 (goto-char (point-min))
4972 (setq gnus-page-broken
4973 (and (re-search-forward page-delimiter nil t) t))))
4974 (when gnus-page-broken
4977 (if (re-search-forward page-delimiter nil 'move)
4980 (when (and (gnus-visual-p 'page-marker)
4981 (> (point-min) (save-restriction (widen) (point-min))))
4983 (goto-char (point-min))
4984 (gnus-insert-prev-page-button)))
4985 (when (and (gnus-visual-p 'page-marker)
4986 (< (+ (point-max) 2) (buffer-size)))
4988 (goto-char (point-max))
4989 (gnus-insert-next-page-button))))))
4991 ;; Article mode commands
4993 (defun gnus-article-goto-next-page ()
4994 "Show the next page of the article."
4996 (when (gnus-article-next-page)
4997 (goto-char (point-min))
4998 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5001 (defun gnus-article-goto-prev-page ()
5002 "Show the previous page of the article."
5005 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5006 (gnus-article-prev-page nil)))
5008 ;; This is cleaner but currently breaks `gnus-pick-mode':
5010 ;; (defun gnus-article-goto-next-page ()
5011 ;; "Show the next page of the article."
5013 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5014 ;; (gnus-summary-next-page)))
5016 ;; (defun gnus-article-goto-prev-page ()
5017 ;; "Show the next page of the article."
5019 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5020 ;; (gnus-summary-prev-page)))
5022 (defun gnus-article-next-page (&optional lines)
5023 "Show the next page of the current article.
5024 If end of article, return non-nil. Otherwise return nil.
5025 Argument LINES specifies lines to be scrolled up."
5027 (move-to-window-line -1)
5030 (and (pos-visible-in-window-p) ;Not continuation line.
5031 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5032 ;; Nothing in this page.
5033 (if (or (not gnus-page-broken)
5038 (eobp)))) ;Real end-of-buffer?
5040 (when gnus-article-over-scroll
5041 (gnus-article-next-page-1 lines))
5043 (gnus-narrow-to-page 1) ;Go to next page.
5045 ;; More in this page.
5046 (gnus-article-next-page-1 lines)
5049 (defun gnus-article-next-page-1 (lines)
5050 (let ((scroll-in-place nil))
5054 ;; Long lines may cause an end-of-buffer error.
5055 (goto-char (point-max)))))
5056 (move-to-window-line 0))
5058 (defun gnus-article-prev-page (&optional lines)
5059 "Show previous page of current article.
5060 Argument LINES specifies lines to be scrolled down."
5062 (move-to-window-line 0)
5063 (if (and gnus-page-broken
5065 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5067 (gnus-narrow-to-page -1) ;Go to previous page.
5068 (goto-char (point-max))
5070 (let ((scroll-in-place nil))
5074 (beginning-of-buffer
5075 (goto-char (point-min))))
5076 (move-to-window-line 0)))))
5078 (defun gnus-article-only-boring-p ()
5079 "Decide whether there is only boring text remaining in the article.
5080 Something \"interesting\" is a word of at least two letters that does
5081 not have a face in `gnus-article-boring-faces'."
5082 (when (and gnus-article-skip-boring
5083 (boundp 'gnus-article-boring-faces)
5084 (symbol-value 'gnus-article-boring-faces))
5087 (while (re-search-forward "\\b\\w\\w" nil t)
5089 (when (not (gnus-intersection
5090 (gnus-faces-at (point))
5091 (symbol-value 'gnus-article-boring-faces)))
5092 (throw 'only-boring nil)))
5093 (throw 'only-boring t)))))
5095 (defun gnus-article-refer-article ()
5096 "Read article specified by message-id around point."
5099 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5100 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5101 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5102 (let ((msg-id (concat "<" (match-string 0) ">")))
5103 (set-buffer gnus-summary-buffer)
5104 (gnus-summary-refer-article msg-id))
5105 (error "No references around point"))))
5107 (defun gnus-article-show-summary ()
5108 "Reconfigure windows to show summary buffer."
5110 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5111 (error "There is no summary buffer for this article buffer")
5112 (gnus-article-set-globals)
5113 (gnus-configure-windows 'article)
5114 (gnus-summary-goto-subject gnus-current-article)
5115 (gnus-summary-position-point)))
5117 (defun gnus-article-describe-briefly ()
5118 "Describe article mode commands briefly."
5120 (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")))
5122 (defun gnus-article-summary-command ()
5123 "Execute the last keystroke in the summary buffer."
5125 (let ((obuf (current-buffer))
5126 (owin (current-window-configuration))
5128 (switch-to-buffer gnus-article-current-summary 'norecord)
5129 (setq func (lookup-key (current-local-map) (this-command-keys)))
5130 (call-interactively func)
5132 (set-window-configuration owin)
5133 (set-window-point (get-buffer-window (current-buffer)) (point))))
5135 (defun gnus-article-summary-command-nosave ()
5136 "Execute the last keystroke in the summary buffer."
5139 (pop-to-buffer gnus-article-current-summary 'norecord)
5140 (setq func (lookup-key (current-local-map) (this-command-keys)))
5141 (call-interactively func)))
5143 (defun gnus-article-check-buffer ()
5144 "Beep if not in an article buffer."
5145 (unless (equal major-mode 'gnus-article-mode)
5146 (error "Command invoked outside of a Gnus article buffer")))
5148 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5149 "Read a summary buffer key sequence and execute it from the article buffer."
5151 (gnus-article-check-buffer)
5153 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5154 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5155 "=" "^" "\M-^" "|"))
5161 '("n" "Gn" "p" "Gp"))
5164 (set-buffer gnus-article-current-summary)
5165 (let (gnus-pick-mode)
5166 (push (or key last-command-event) unread-command-events)
5167 (setq keys (if (featurep 'xemacs)
5168 (events-to-keys (read-key-sequence nil))
5169 (read-key-sequence nil)))))
5173 (if (or (member keys nosaves)
5174 (member keys nosave-but-article)
5175 (member keys nosave-in-article))
5177 (save-window-excursion
5178 (pop-to-buffer gnus-article-current-summary 'norecord)
5179 ;; We disable the pick minor mode commands.
5180 (let (gnus-pick-mode)
5181 (setq func (lookup-key (current-local-map) keys))))
5185 (unless (member keys nosave-in-article)
5186 (set-buffer gnus-article-current-summary))
5187 (call-interactively func)
5188 (setq new-sum-point (point)))
5189 (when (member keys nosave-but-article)
5190 (pop-to-buffer gnus-article-buffer 'norecord)))
5191 ;; These commands should restore window configuration.
5192 (let ((obuf (current-buffer))
5193 (owin (current-window-configuration))
5195 win func in-buffer selected new-sum-start new-sum-hscroll)
5196 (cond (not-restore-window
5197 (pop-to-buffer gnus-article-current-summary 'norecord))
5198 ((setq win (get-buffer-window gnus-article-current-summary))
5199 (select-window win))
5201 (switch-to-buffer gnus-article-current-summary 'norecord)))
5202 (setq in-buffer (current-buffer))
5203 ;; We disable the pick minor mode commands.
5204 (if (and (setq func (let (gnus-pick-mode)
5205 (lookup-key (current-local-map) keys)))
5208 (call-interactively func)
5209 (when (eq win (selected-window))
5210 (setq new-sum-point (point)
5211 new-sum-start (window-start win)
5212 new-sum-hscroll (window-hscroll win))
5213 (when (eq in-buffer (current-buffer))
5214 (setq selected (gnus-summary-select-article))
5216 (unless not-restore-window
5217 (set-window-configuration owin))
5218 (when (eq selected 'old)
5220 (set-window-start (get-buffer-window (current-buffer))
5222 (set-window-point (get-buffer-window (current-buffer))
5224 (when (and (not not-restore-window)
5226 (set-window-point win new-sum-point)
5227 (set-window-start win new-sum-start)
5228 (set-window-hscroll win new-sum-hscroll)))))
5229 (set-window-configuration owin)
5232 (defun gnus-article-describe-key (key)
5233 "Display documentation of the function invoked by KEY. KEY is a string."
5234 (interactive "kDescribe key: ")
5235 (gnus-article-check-buffer)
5236 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5238 (set-buffer gnus-article-current-summary)
5239 (let (gnus-pick-mode)
5240 (if (featurep 'xemacs)
5242 (push (elt key 0) unread-command-events)
5243 (setq key (events-to-keys
5244 (read-key-sequence "Describe key: "))))
5245 (setq unread-command-events
5247 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5248 (string-to-list key)))
5249 (setq key (read-key-sequence "Describe key: "))))
5251 (describe-key key)))
5253 (defun gnus-article-describe-key-briefly (key &optional insert)
5254 "Display documentation of the function invoked by KEY. KEY is a string."
5255 (interactive "kDescribe key: \nP")
5256 (gnus-article-check-buffer)
5257 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5259 (set-buffer gnus-article-current-summary)
5260 (let (gnus-pick-mode)
5261 (if (featurep 'xemacs)
5263 (push (elt key 0) unread-command-events)
5264 (setq key (events-to-keys
5265 (read-key-sequence "Describe key: "))))
5266 (setq unread-command-events
5268 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5269 (string-to-list key)))
5270 (setq key (read-key-sequence "Describe key: "))))
5271 (describe-key-briefly key insert))
5272 (describe-key-briefly key insert)))
5274 (defun gnus-article-reply-with-original (&optional wide)
5275 "Start composing a reply mail to the current message.
5276 The text in the region will be yanked. If the region isn't active,
5277 the entire article will be yanked."
5279 (let ((article (cdr gnus-article-current))
5281 (if (not (gnus-region-active-p))
5282 (with-current-buffer gnus-summary-buffer
5283 (gnus-summary-reply (list (list article)) wide))
5284 (setq contents (buffer-substring (point) (mark t)))
5285 ;; Deactivate active regions.
5286 (when (and (boundp 'transient-mark-mode)
5287 transient-mark-mode)
5288 (setq mark-active nil))
5289 (with-current-buffer gnus-summary-buffer
5291 (list (list article contents)) wide)))))
5293 (defun gnus-article-followup-with-original ()
5294 "Compose a followup to the current article.
5295 The text in the region will be yanked. If the region isn't active,
5296 the entire article will be yanked."
5298 (let ((article (cdr gnus-article-current))
5300 (if (not (gnus-region-active-p))
5301 (with-current-buffer gnus-summary-buffer
5302 (gnus-summary-followup (list (list article))))
5303 (setq contents (buffer-substring (point) (mark t)))
5304 ;; Deactivate active regions.
5305 (when (and (boundp 'transient-mark-mode)
5306 transient-mark-mode)
5307 (setq mark-active nil))
5308 (with-current-buffer gnus-summary-buffer
5309 (gnus-summary-followup
5310 (list (list article contents)))))))
5312 (defun gnus-article-hide (&optional arg force)
5313 "Hide all the gruft in the current article.
5314 This means that signatures, cited text and (some) headers will be
5316 If given a prefix, show the hidden text instead."
5317 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5318 (gnus-article-hide-headers arg)
5319 (gnus-article-hide-list-identifiers arg)
5320 (gnus-article-hide-citation-maybe arg force)
5321 (gnus-article-hide-signature arg))
5323 (defun gnus-article-maybe-highlight ()
5324 "Do some article highlighting if article highlighting is requested."
5325 (when (gnus-visual-p 'article-highlight 'highlight)
5326 (gnus-article-highlight-some)))
5328 (defun gnus-check-group-server ()
5329 ;; Make sure the connection to the server is alive.
5330 (unless (gnus-server-opened
5331 (gnus-find-method-for-group gnus-newsgroup-name))
5332 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5333 (gnus-request-group gnus-newsgroup-name t)))
5336 (autoload 'nneething-get-file-name "nneething"))
5338 (defun gnus-request-article-this-buffer (article group)
5339 "Get an article and insert it into this buffer."
5340 (let (do-update-line sparse-header)
5344 (gnus-kill-all-overlays)
5345 (setq group (or group gnus-newsgroup-name))
5347 ;; Using `gnus-request-article' directly will insert the article into
5348 ;; `nntp-server-buffer' - so we'll save some time by not having to
5349 ;; copy it from the server buffer into the article buffer.
5351 ;; We only request an article by message-id when we do not have the
5352 ;; headers for it, so we'll have to get those.
5353 (when (stringp article)
5354 (gnus-read-header article))
5356 ;; If the article number is negative, that means that this article
5357 ;; doesn't belong in this newsgroup (possibly), so we find its
5358 ;; message-id and request it by id instead of number.
5359 (when (and (numberp article)
5361 (get-buffer gnus-summary-buffer)
5362 (gnus-buffer-exists-p gnus-summary-buffer))
5364 (set-buffer gnus-summary-buffer)
5365 (let ((header (gnus-summary-article-header article)))
5368 ((memq article gnus-newsgroup-sparse)
5369 ;; This is a sparse gap article.
5370 (setq do-update-line article)
5371 (setq article (mail-header-id header))
5372 (setq sparse-header (gnus-read-header article))
5373 (setq gnus-newsgroup-sparse
5374 (delq article gnus-newsgroup-sparse)))
5376 ;; It's a real article.
5377 (setq article (mail-header-id header)))
5379 ;; It is an extracted pseudo-article.
5380 (setq article 'pseudo)
5381 (gnus-request-pseudo-article header))))
5383 (let ((method (gnus-find-method-for-group
5384 gnus-newsgroup-name)))
5385 (when (and (eq (car method) 'nneething)
5387 (let ((dir (nneething-get-file-name
5388 (mail-header-id header))))
5389 (when (and (stringp dir)
5390 (file-directory-p dir))
5391 (setq article 'nneething)
5392 (gnus-group-enter-directory dir))))))))
5395 ;; Refuse to select canceled articles.
5396 ((and (numberp article)
5398 (get-buffer gnus-summary-buffer)
5399 (gnus-buffer-exists-p gnus-summary-buffer)
5400 (eq (cdr (with-current-buffer gnus-summary-buffer
5401 (assq article gnus-newsgroup-reads)))
5402 gnus-canceled-mark))
5404 ;; We first check `gnus-original-article-buffer'.
5405 ((and (get-buffer gnus-original-article-buffer)
5407 (with-current-buffer gnus-original-article-buffer
5408 (and (equal (car gnus-original-article) group)
5409 (eq (cdr gnus-original-article) article))))
5410 (insert-buffer-substring gnus-original-article-buffer)
5412 ;; Check the backlog.
5413 ((and gnus-keep-backlog
5414 (gnus-backlog-request-article group article (current-buffer)))
5416 ;; Check asynchronous pre-fetch.
5417 ((gnus-async-request-fetched-article group article (current-buffer))
5418 (gnus-async-prefetch-next group article gnus-summary-buffer)
5419 (when (and (numberp article) gnus-keep-backlog)
5420 (gnus-backlog-enter-article group article (current-buffer)))
5423 ((and gnus-use-cache
5425 (gnus-cache-request-article article group))
5427 ;; Check the agent cache.
5428 ((gnus-agent-request-article article group)
5430 ;; Get the article and put into the article buffer.
5431 ((or (stringp article)
5433 (let ((gnus-override-method gnus-override-method)
5434 (methods (and (stringp article)
5435 gnus-refer-article-method))
5436 (backend (car (gnus-find-method-for-group
5437 gnus-newsgroup-name)))
5439 (inhibit-read-only t))
5440 (if (or (not (listp methods))
5441 (and (symbolp (car methods))
5442 (assq (car methods) nnoo-definition-alist)))
5443 (setq methods (list methods)))
5444 (when (and (null gnus-override-method)
5446 (setq gnus-override-method (pop methods)))
5448 (when (eq gnus-override-method 'current)
5449 (setq gnus-override-method
5450 (with-current-buffer gnus-summary-buffer
5451 gnus-current-select-method)))
5453 (gnus-kill-all-overlays)
5454 (let ((gnus-newsgroup-name group))
5455 (gnus-check-group-server))
5457 ((gnus-request-article article group (current-buffer))
5458 (when (numberp article)
5459 (gnus-async-prefetch-next group article
5460 gnus-summary-buffer)
5461 (when gnus-keep-backlog
5462 (gnus-backlog-enter-article
5463 group article (current-buffer))))
5464 (setq result 'article))
5466 (setq gnus-override-method (pop methods)))
5467 ((not (string-match "^400 "
5468 (nnheader-get-report backend)))
5469 ;; If we get 400 server disconnect, reconnect and
5470 ;; retry; otherwise, assume the article has expired.
5471 (setq result 'done))))
5472 (and (eq result 'article) 'article)))
5476 ;; Associate this article with the current summary buffer.
5477 (setq gnus-article-current-summary gnus-summary-buffer)
5479 ;; Take the article from the original article buffer
5480 ;; and place it in the buffer it's supposed to be in.
5481 (when (and (get-buffer gnus-article-buffer)
5482 (equal (buffer-name (current-buffer))
5483 (buffer-name (get-buffer gnus-article-buffer))))
5485 (if (get-buffer gnus-original-article-buffer)
5486 (set-buffer gnus-original-article-buffer)
5487 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5488 (buffer-disable-undo)
5489 (setq major-mode 'gnus-original-article-mode)
5490 (setq buffer-read-only t))
5491 (let ((inhibit-read-only t))
5493 (insert-buffer-substring gnus-article-buffer))
5494 (setq gnus-original-article (cons group article)))
5497 (run-hooks 'gnus-article-decode-hook)
5498 ;; Mark article as decoded or not.
5499 (setq gnus-article-decoded-p gnus-article-decode-hook))
5501 ;; Update sparse articles.
5502 (when (and do-update-line
5503 (or (numberp article)
5505 (let ((buf (current-buffer)))
5506 (set-buffer gnus-summary-buffer)
5507 (gnus-summary-update-article do-update-line sparse-header)
5508 (gnus-summary-goto-subject do-update-line nil t)
5509 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5511 (set-buffer buf))))))
5517 (defcustom gnus-article-edit-mode-hook nil
5518 "Hook run in article edit mode buffers."
5519 :group 'gnus-article-various
5522 (defvar gnus-article-edit-done-function nil)
5524 (defvar gnus-article-edit-mode-map nil)
5526 ;; Should we be using derived.el for this?
5527 (unless gnus-article-edit-mode-map
5528 (setq gnus-article-edit-mode-map (make-keymap))
5529 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5531 (gnus-define-keys gnus-article-edit-mode-map
5532 "\C-c?" describe-mode
5533 "\C-c\C-c" gnus-article-edit-done
5534 "\C-c\C-k" gnus-article-edit-exit
5535 "\C-c\C-f\C-t" message-goto-to
5536 "\C-c\C-f\C-o" message-goto-from
5537 "\C-c\C-f\C-b" message-goto-bcc
5538 ;;"\C-c\C-f\C-w" message-goto-fcc
5539 "\C-c\C-f\C-c" message-goto-cc
5540 "\C-c\C-f\C-s" message-goto-subject
5541 "\C-c\C-f\C-r" message-goto-reply-to
5542 "\C-c\C-f\C-n" message-goto-newsgroups
5543 "\C-c\C-f\C-d" message-goto-distribution
5544 "\C-c\C-f\C-f" message-goto-followup-to
5545 "\C-c\C-f\C-m" message-goto-mail-followup-to
5546 "\C-c\C-f\C-k" message-goto-keywords
5547 "\C-c\C-f\C-u" message-goto-summary
5548 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5549 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5550 "\C-c\C-b" message-goto-body
5551 "\C-c\C-i" message-goto-signature
5553 "\C-c\C-t" message-insert-to
5554 "\C-c\C-n" message-insert-newsgroups
5555 "\C-c\C-o" message-sort-headers
5556 "\C-c\C-e" message-elide-region
5557 "\C-c\C-v" message-delete-not-region
5558 "\C-c\C-z" message-kill-to-signature
5559 "\M-\r" message-newline-and-reformat
5560 "\C-c\C-a" mml-attach-file
5561 "\C-a" message-beginning-of-line
5563 "\M-;" comment-region)
5565 (gnus-define-keys (gnus-article-edit-wash-map
5566 "\C-c\C-w" gnus-article-edit-mode-map)
5567 "f" gnus-article-edit-full-stops))
5570 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5572 ["Fetch To" message-insert-to t]
5573 ["Fetch Newsgroups" message-insert-newsgroups t]
5575 ["To" message-goto-to t]
5576 ["From" message-goto-from t]
5577 ["Subject" message-goto-subject t]
5578 ["Cc" message-goto-cc t]
5579 ["Reply-To" message-goto-reply-to t]
5580 ["Summary" message-goto-summary t]
5581 ["Keywords" message-goto-keywords t]
5582 ["Newsgroups" message-goto-newsgroups t]
5583 ["Followup-To" message-goto-followup-to t]
5584 ["Mail-Followup-To" message-goto-mail-followup-to t]
5585 ["Distribution" message-goto-distribution t]
5586 ["Body" message-goto-body t]
5587 ["Signature" message-goto-signature t]))
5589 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5590 "Major mode for editing articles.
5591 This is an extended text-mode.
5593 \\{gnus-article-edit-mode-map}"
5594 (make-local-variable 'gnus-article-edit-done-function)
5595 (make-local-variable 'gnus-prev-winconf)
5596 (set (make-local-variable 'font-lock-defaults)
5597 '(message-font-lock-keywords t))
5598 (set (make-local-variable 'mail-header-separator) "")
5599 (set (make-local-variable 'gnus-article-edit-mode) t)
5600 (easy-menu-add message-mode-field-menu message-mode-map)
5602 (setq buffer-read-only nil)
5603 (buffer-enable-undo)
5606 (defun gnus-article-edit (&optional force)
5607 "Edit the current article.
5608 This will have permanent effect only in mail groups.
5609 If FORCE is non-nil, allow editing of articles even in read-only
5612 (when (and (not force)
5613 (gnus-group-read-only-p))
5614 (error "The current newsgroup does not support article editing"))
5615 (gnus-article-date-original)
5616 (gnus-article-edit-article
5618 `(lambda (no-highlight)
5620 (gnus-summary-edit-article-done
5621 ,(or (mail-header-references gnus-current-headers) "")
5622 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5624 (defun gnus-article-edit-article (start-func exit-func)
5625 "Start editing the contents of the current article buffer."
5626 (let ((winconf (current-window-configuration)))
5627 (set-buffer gnus-article-buffer)
5628 (gnus-article-edit-mode)
5629 (funcall start-func)
5630 (set-buffer-modified-p nil)
5631 (gnus-configure-windows 'edit-article)
5632 (setq gnus-article-edit-done-function exit-func)
5633 (setq gnus-prev-winconf winconf)
5634 (gnus-message 6 "C-c C-c to end edits")))
5636 (defun gnus-article-edit-done (&optional arg)
5637 "Update the article edits and exit."
5639 (let ((func gnus-article-edit-done-function)
5640 (buf (current-buffer))
5641 (start (window-start))
5643 (winconf gnus-prev-winconf))
5644 (widen) ;; Widen it in case that users narrowed the buffer.
5647 ;; The cache and backlog have to be flushed somewhat.
5648 (when gnus-keep-backlog
5649 (gnus-backlog-remove-article
5650 (car gnus-article-current) (cdr gnus-article-current)))
5651 ;; Flush original article as well.
5653 (when (get-buffer gnus-original-article-buffer)
5654 (set-buffer gnus-original-article-buffer)
5655 (setq gnus-original-article nil)))
5656 (when gnus-use-cache
5657 (gnus-cache-update-article
5658 (car gnus-article-current) (cdr gnus-article-current)))
5659 ;; We remove all text props from the article buffer.
5660 (kill-all-local-variables)
5661 (set-text-properties (point-min) (point-max) nil)
5663 (set-window-configuration winconf)
5665 (set-window-start (get-buffer-window buf) start)
5666 (set-window-point (get-buffer-window buf) (point)))
5667 (gnus-summary-show-article))
5669 (defun gnus-article-edit-exit ()
5670 "Exit the article editing without updating."
5672 (when (or (not (buffer-modified-p))
5673 (yes-or-no-p "Article modified; kill anyway? "))
5674 (let ((curbuf (current-buffer))
5676 (window-start (window-start)))
5678 (if (gnus-buffer-live-p gnus-original-article-buffer)
5679 (insert-buffer gnus-original-article-buffer))
5680 (let ((winconf gnus-prev-winconf))
5681 (kill-all-local-variables)
5683 (set-window-configuration winconf)
5684 ;; Tippy-toe some to make sure that point remains where it was.
5685 (save-current-buffer
5687 (set-window-start (get-buffer-window (current-buffer)) window-start)
5689 (gnus-summary-show-article)))
5691 (defun gnus-article-edit-full-stops ()
5692 "Interactively repair spacing at end of sentences."
5695 (goto-char (point-min))
5696 (search-forward-regexp "^$" nil t)
5697 (let ((case-fold-search nil))
5698 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5701 ;;; Article highlights
5704 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5706 ;;; Internal Variables:
5708 (defcustom gnus-button-url-regexp
5709 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5710 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5711 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5712 "Regular expression that matches URLs."
5713 :group 'gnus-article-buttons
5716 (defcustom gnus-button-valid-fqdn-regexp
5717 message-valid-fqdn-regexp
5718 "Regular expression that matches a valid FQDN."
5720 :group 'gnus-article-buttons
5723 (defcustom gnus-button-man-handler 'manual-entry
5724 "Function to use for displaying man pages.
5725 The function must take at least one argument with a string naming the
5728 :type '(choice (function-item :tag "Man" manual-entry)
5729 (function-item :tag "Woman" woman)
5730 (function :tag "Other"))
5731 :group 'gnus-article-buttons)
5733 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5734 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5735 If the default site is too slow, try to find a CTAN mirror, see
5736 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5737 the variable `gnus-button-handle-ctan'."
5739 :group 'gnus-article-buttons
5740 :link '(custom-manual "(gnus)Group Parameters")
5741 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5742 (const "http://tug.ctan.org/tex-archive/")
5743 (const "http://www.dante.de/CTAN/")
5744 (string :tag "Other")))
5746 (defcustom gnus-button-ctan-handler 'browse-url
5747 "Function to use for displaying CTAN links.
5748 The function must take one argument, the string naming the URL."
5750 :type '(choice (function-item :tag "Browse Url" browse-url)
5751 (function :tag "Other"))
5752 :group 'gnus-article-buttons)
5754 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5755 "Bogus strings removed from CTAN URLs."
5757 :group 'gnus-article-buttons
5758 :type '(choice (const "^/?tex-archive/\\|/")
5759 (regexp :tag "Other")))
5761 (defcustom gnus-button-ctan-directory-regexp
5764 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5765 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5766 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5768 "Regular expression for ctan directories.
5769 It should match all directories in the top level of `gnus-ctan-url'."
5771 :group 'gnus-article-buttons
5774 (defcustom gnus-button-mid-or-mail-regexp
5775 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5776 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5777 gnus-button-valid-fqdn-regexp
5779 "Regular expression that matches a message ID or a mail address."
5781 :group 'gnus-article-buttons
5784 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5785 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5786 Strings like this can be either a message ID or a mail address. If it is one
5787 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5788 message ID or a mail address, respectively. If this variable is set to the
5789 symbol `ask', always query the user what do do. If it is a function, this
5790 function will be called with the string as it's only argument. The function
5791 must return `mid', `mail', `invalid' or `ask'."
5793 :group 'gnus-article-buttons
5794 :type '(choice (function-item :tag "Heuristic function"
5795 gnus-button-mid-or-mail-heuristic)
5800 (defcustom gnus-button-mid-or-mail-heuristic-alist
5801 '((-10.0 . ".+\\$.+@")
5804 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5805 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5806 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5807 (-1.0 . "^[^a-z]+@")
5809 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5810 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5811 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5812 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5815 (-1.0 . "^[0-9][0-9]")
5817 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5818 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5819 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5820 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5822 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5823 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5826 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5828 ;; compensation for TDMA dated mail addresses:
5829 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5831 (-20.0 . "\\.fsf@") ;; Gnus
5834 (-20.0 . "_-_") ;; Subject change in thread
5836 (-20.0 . "\\.ln@") ;; leafnode
5837 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5838 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5840 ;; (5.0 . "") ;; $local_part_len <= 7
5841 (10.0 . "^[^0-9]+@")
5842 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5843 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5846 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5848 (0.5 . "^[A-Z][a-z]")
5849 (0.5 . "^[A-Z][a-z][a-z]")
5850 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5851 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5852 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5854 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5855 address. The REGEXP is processed with `case-fold-search' set to nil."
5857 :group 'gnus-article-buttons
5858 :type '(repeat (cons (number :tag "Rate")
5859 (regexp :tag "Regexp"))))
5861 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5862 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5863 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5864 address, `ask' if unsure and `invalid' if the string is invalid."
5865 (let ((case-fold-search nil)
5866 (list gnus-button-mid-or-mail-heuristic-alist)
5867 (result 0) rate regexp lpartlen elem)
5869 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5870 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5871 ;; Certain special cases...
5874 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5875 "^[0-9]+\\.[0-9]+@compuserve\\|"
5876 "@public\\.gmane\\.org")
5878 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5879 (setq result 'mail))
5880 (when (string-match "@.*@\\| " mid-or-mail)
5881 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5882 (setq result 'invalid))
5883 ;; Nothing more to do, if result is not a number here...
5884 (when (numberp result)
5886 (setq elem (car list)
5890 (when (string-match regexp mid-or-mail)
5891 (setq result (+ result rate))
5893 9 "`%s' matched `%s', rate `%s', result `%s'."
5894 mid-or-mail regexp rate result)))
5895 (when (<= lpartlen 7)
5896 (setq result (+ result 5.0))
5897 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5898 mid-or-mail result))
5899 (when (>= lpartlen 12)
5900 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5902 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5903 ;; Long local part should contain realname if e-mail address,
5904 ;; too many digits: message-id.
5905 ;; $score -= 5.0 + 0.1 * $local_part_len;
5906 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5907 (setq result (+ result rate))
5909 9 "Many digits in `%s', rate `%s', result `%s'."
5910 mid-or-mail rate result))
5911 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5913 ;; Too few vowels [^aeiouy]{4,}.*\@
5914 (setq result (+ result -5.0))
5916 9 "Few vowels in `%s', rate `%s', result `%s'."
5917 mid-or-mail -5.0 result))
5919 (setq result (+ result 5.0))
5921 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5922 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5923 ;; Maybe we should make this a customizable alist: (condition . 'result)
5925 ((symbolp result) result)
5926 ;; Now convert number into proper results:
5927 ((< result -10.0) 'mid)
5928 ((> result 10.0) 'mail)
5931 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5932 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5933 (url-mid (concat "news" ":" mid-or-mail))
5934 (url-mailto (concat "mailto" ":" mid-or-mail)))
5935 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5936 (when (fboundp pref)
5938 ;; get rid of surrounding angles...
5940 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5941 (if (or (eq 'mid guessed) (eq 'mail guessed))
5945 (save-window-excursion
5946 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5949 (cond ((eq pref 'mid)
5950 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5951 (gnus-button-handle-news url-mid))
5953 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5954 (gnus-url-mailto url-mailto))
5955 (t (gnus-message 3 "Invalid string.")))))
5957 (defun gnus-button-handle-custom (url)
5958 "Follow a Custom URL."
5959 (customize-apropos (gnus-url-unhex-string url)))
5961 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5963 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5966 (defun gnus-button-handle-describe-function (url)
5967 "Call `describe-function' when pushing the corresponding URL button."
5970 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5972 (defun gnus-button-handle-describe-variable (url)
5973 "Call `describe-variable' when pushing the corresponding URL button."
5976 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5978 (defun gnus-button-handle-symbol (url)
5979 "Display help on variable or function.
5980 Calls `describe-variable' or `describe-function'."
5981 (let ((sym (intern url)))
5983 ((fboundp sym) (describe-function sym))
5984 ((boundp sym) (describe-variable sym))
5985 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5987 (defun gnus-button-handle-describe-key (url)
5988 "Call `describe-key' when pushing the corresponding URL button."
5990 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5991 (keys (ignore-errors (eval `(kbd ,key-string)))))
5994 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5996 (defun gnus-button-handle-apropos (url)
5997 "Call `apropos' when pushing the corresponding URL button."
5998 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6000 (defun gnus-button-handle-apropos-command (url)
6001 "Call `apropos' when pushing the corresponding URL button."
6003 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6005 (defun gnus-button-handle-apropos-variable (url)
6006 "Call `apropos' when pushing the corresponding URL button."
6008 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6009 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6011 (defun gnus-button-handle-apropos-documentation (url)
6012 "Call `apropos' when pushing the corresponding URL button."
6014 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6015 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6017 (defun gnus-button-handle-library (url)
6018 "Call `locate-library' when pushing the corresponding URL button."
6019 (gnus-message 9 "url=`%s'" url)
6020 (let* ((lib (locate-library url))
6021 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6023 (gnus-message 1 "Cannot locale library `%s'." url)
6024 (find-file-read-only file))))
6026 (defun gnus-button-handle-ctan (url)
6027 "Call `browse-url' when pushing a CTAN URL button."
6029 gnus-button-ctan-handler
6032 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6034 (defcustom gnus-button-tex-level 5
6035 "*Integer that says how many TeX-related buttons Gnus will show.
6036 The higher the number, the more buttons will appear and the more false
6037 positives are possible. Note that you can set this variable local to
6038 specific groups. Setting it higher in TeX groups is probably a good idea.
6039 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6040 how to set variables in specific groups."
6042 :group 'gnus-article-buttons
6043 :link '(custom-manual "(gnus)Group Parameters")
6046 (defcustom gnus-button-man-level 5
6047 "*Integer that says how many man-related buttons Gnus will show.
6048 The higher the number, the more buttons will appear and the more false
6049 positives are possible. Note that you can set this variable local to
6050 specific groups. Setting it higher in Unix groups is probably a good idea.
6051 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6052 how to set variables in specific groups."
6054 :group 'gnus-article-buttons
6055 :link '(custom-manual "(gnus)Group Parameters")
6058 (defcustom gnus-button-emacs-level 5
6059 "*Integer that says how many emacs-related buttons Gnus will show.
6060 The higher the number, the more buttons will appear and the more false
6061 positives are possible. Note that you can set this variable local to
6062 specific groups. Setting it higher in Emacs or Gnus related groups is
6063 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6064 `gnus-parameters' on how to set variables in specific groups."
6066 :group 'gnus-article-buttons
6067 :link '(custom-manual "(gnus)Group Parameters")
6070 (defcustom gnus-button-message-level 5
6071 "*Integer that says how many buttons for news or mail messages will appear.
6072 The higher the number, the more buttons will appear and the more false
6073 positives are possible."
6074 ;; mail addresses, MIDs, URLs for news, ...
6076 :group 'gnus-article-buttons
6079 (defcustom gnus-button-browse-level 5
6080 "*Integer that says how many buttons for browsing will appear.
6081 The higher the number, the more buttons will appear and the more false
6082 positives are possible."
6083 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6085 :group 'gnus-article-buttons
6088 (defcustom gnus-button-alist
6089 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6090 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6091 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6092 gnus-button-handle-news 2)
6093 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6094 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6095 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6096 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6097 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6098 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6099 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6100 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6101 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6102 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6103 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6104 ;; RFC 2368 (The mailto URL scheme)
6105 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6106 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6107 ("\\bmailto:\\([^ \n\t]+\\)"
6108 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6110 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6111 gnus-button-ctan-directory-regexp
6112 "[^][>)!;:,'\n\t ]+\\)")
6113 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6114 ((concat "\\btex-archive/\\("
6115 gnus-button-ctan-directory-regexp
6116 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6117 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6120 gnus-button-ctan-directory-regexp
6121 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6122 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6123 ;; This is info (home-grown style) <info://foo/bar+baz>
6124 ("\\binfo://\\([^'\">\n\t ]+\\)"
6125 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6126 ;; Info GNOME style <info:foo#bar_baz>
6127 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6128 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6129 ;; Info KDE style <info:(foo)bar baz>
6130 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6131 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6132 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6133 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6134 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6135 ;; Info links like `C-h i d m CC Mode RET'
6136 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6138 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6139 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6140 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6141 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6142 ;; Emacs help commands
6143 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6144 ;; regexp doesn't match arguments containing ` '.
6145 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6146 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6147 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6148 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6149 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6150 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6151 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6152 ;; The following entries may lead to many false positives so don't enable
6153 ;; them by default (use a high button level).
6154 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6155 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6156 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6157 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6158 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6159 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6160 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6161 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6162 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6163 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6164 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6165 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6166 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6167 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6168 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6169 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6170 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6171 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6172 ;; Unlike the other regexps we really have to require quoting
6173 ;; here to determine where it ends.
6174 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6175 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6176 ("<URL: *\\([^<>]*\\)>"
6177 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6178 ;; RFC 2396 (2.4.3., delims) ...
6179 ("\"URL: *\\([^\"]*\\)\""
6180 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6181 ;; RFC 2396 (2.4.3., delims) ...
6182 ("\"URL: *\\([^\"]*\\)\""
6183 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6185 (gnus-button-url-regexp
6186 0 (>= gnus-button-browse-level 0) browse-url 0)
6188 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6189 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6190 gnus-button-handle-man 1)
6191 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6192 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6193 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6194 gnus-button-handle-man 1)
6195 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6196 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6197 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6198 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6199 ;; MID or mail: To avoid too many false positives we don't try to catch
6200 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6201 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6202 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6203 ;; so that non-ambiguous entries (see above) match first.
6204 (gnus-button-mid-or-mail-regexp
6205 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6206 "*Alist of regexps matching buttons in article bodies.
6208 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6209 REGEXP: is the string (case insensitive) matching text around the button (can
6210 also be Lisp expression evaluating to a string),
6211 BUTTON: is the number of the regexp grouping actually matching the button,
6212 FORM: is a Lisp expression which must eval to true for the button to
6214 CALLBACK: is the function to call when the user push this button, and each
6215 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6217 CALLBACK can also be a variable, in that case the value of that
6218 variable it the real callback function."
6219 :group 'gnus-article-buttons
6220 :type '(repeat (list (choice regexp variable sexp)
6221 (integer :tag "Button")
6223 (function :tag "Callback")
6226 (integer :tag "Regexp group")))))
6228 (defcustom gnus-header-button-alist
6229 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6230 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6231 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6232 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6233 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6234 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6235 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6236 0 (>= gnus-button-browse-level 0) browse-url 0)
6237 ("^Subject:" gnus-button-url-regexp
6238 0 (>= gnus-button-browse-level 0) browse-url 0)
6239 ("^[^:]+:" gnus-button-url-regexp
6240 0 (>= gnus-button-browse-level 0) browse-url 0)
6241 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6242 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6243 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6244 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6245 "*Alist of headers and regexps to match buttons in article heads.
6247 This alist is very similar to `gnus-button-alist', except that each
6248 alist has an additional HEADER element first in each entry:
6250 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6252 HEADER is a regexp to match a header. For a fuller explanation, see
6253 `gnus-button-alist'."
6254 :group 'gnus-article-buttons
6255 :group 'gnus-article-headers
6256 :type '(repeat (list (regexp :tag "Header")
6257 (choice regexp variable)
6258 (integer :tag "Button")
6260 (function :tag "Callback")
6263 (integer :tag "Regexp group")))))
6267 (defun gnus-article-push-button (event)
6268 "Check text under the mouse pointer for a callback function.
6269 If the text under the mouse pointer has a `gnus-callback' property,
6270 call it with the value of the `gnus-data' text property."
6272 (set-buffer (window-buffer (posn-window (event-start event))))
6273 (let* ((pos (posn-point (event-start event)))
6274 (data (get-text-property pos 'gnus-data))
6275 (fun (get-text-property pos 'gnus-callback)))
6278 (funcall fun data))))
6280 (defun gnus-article-press-button ()
6281 "Check text at point for a callback function.
6282 If the text at point has a `gnus-callback' property,
6283 call it with the value of the `gnus-data' text property."
6285 (let ((data (get-text-property (point) 'gnus-data))
6286 (fun (get-text-property (point) 'gnus-callback)))
6288 (funcall fun data))))
6290 (defun gnus-article-highlight (&optional force)
6291 "Highlight current article.
6292 This function calls `gnus-article-highlight-headers',
6293 `gnus-article-highlight-citation',
6294 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6295 do the highlighting. See the documentation for those functions."
6296 (interactive (list 'force))
6297 (gnus-article-highlight-headers)
6298 (gnus-article-highlight-citation force)
6299 (gnus-article-highlight-signature)
6300 (gnus-article-add-buttons force)
6301 (gnus-article-add-buttons-to-head))
6303 (defun gnus-article-highlight-some (&optional force)
6304 "Highlight current article.
6305 This function calls `gnus-article-highlight-headers',
6306 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6307 do the highlighting. See the documentation for those functions."
6308 (interactive (list 'force))
6309 (gnus-article-highlight-headers)
6310 (gnus-article-highlight-signature)
6311 (gnus-article-add-buttons))
6313 (defun gnus-article-highlight-headers ()
6314 "Highlight article headers as specified by `gnus-header-face-alist'."
6316 (gnus-with-article-headers
6317 (let (regexp header-face field-face from hpoints fpoints)
6318 (dolist (entry gnus-header-face-alist)
6319 (goto-char (point-min))
6320 (setq regexp (concat "^\\("
6321 (if (string-equal "" (nth 0 entry))
6325 header-face (nth 1 entry)
6326 field-face (nth 2 entry))
6327 (while (and (re-search-forward regexp nil t)
6331 (unless (search-forward ":" nil t)
6333 (when (and header-face
6334 (not (memq (point) hpoints)))
6335 (push (point) hpoints)
6336 (gnus-put-text-property from (point) 'face header-face))
6337 (when (and field-face
6338 (not (memq (setq from (point)) fpoints)))
6340 (if (re-search-forward "^[^ \t]" nil t)
6342 (goto-char (point-max)))
6343 (gnus-put-text-property from (point) 'face field-face)))))))
6345 (defun gnus-article-highlight-signature ()
6346 "Highlight the signature in an article.
6347 It does this by highlighting everything after
6348 `gnus-signature-separator' using `gnus-signature-face'."
6350 (gnus-with-article-buffer
6351 (let ((inhibit-point-motion-hooks t))
6353 (when (and gnus-signature-face
6354 (gnus-article-narrow-to-signature))
6355 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6356 'face gnus-signature-face)
6358 (gnus-article-search-signature)
6359 (let ((start (match-beginning 0))
6360 (end (set-marker (make-marker) (1+ (match-end 0)))))
6361 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6364 (defun gnus-button-in-region-p (b e prop)
6365 "Say whether PROP exists in the region."
6366 (text-property-not-all b e prop nil))
6368 (defun gnus-article-add-buttons (&optional force)
6369 "Find external references in the article and make buttons of them.
6370 \"External references\" are things like Message-IDs and URLs, as
6371 specified by `gnus-button-alist'."
6372 (interactive (list 'force))
6373 (gnus-with-article-buffer
6374 (let ((inhibit-point-motion-hooks t)
6375 (case-fold-search t)
6376 (alist gnus-button-alist)
6378 ;; Remove all old markers.
6379 (let (marker entry new-list)
6380 (while (setq marker (pop gnus-button-marker-list))
6381 (if (or (< marker (point-min)) (>= marker (point-max)))
6382 (push marker new-list)
6384 (when (setq entry (gnus-button-entry))
6385 (put-text-property (match-beginning (nth 1 entry))
6386 (match-end (nth 1 entry))
6387 'gnus-callback nil))
6388 (set-marker marker nil)))
6389 (setq gnus-button-marker-list new-list))
6390 ;; We skip the headers.
6393 (while (setq entry (pop alist))
6394 (setq regexp (eval (car entry)))
6396 (while (re-search-forward regexp nil t)
6397 (let* ((start (and entry (match-beginning (nth 1 entry))))
6398 (end (and entry (match-end (nth 1 entry))))
6399 (from (match-beginning 0)))
6400 (when (and (or (eq t (nth 2 entry))
6401 (eval (nth 2 entry)))
6402 (not (gnus-button-in-region-p
6403 start end 'gnus-callback)))
6404 ;; That optional form returned non-nil, so we add the
6406 (gnus-article-add-button
6407 start end 'gnus-button-push
6408 (car (push (set-marker (make-marker) from)
6409 gnus-button-marker-list))))))))))
6411 ;; Add buttons to the head of an article.
6412 (defun gnus-article-add-buttons-to-head ()
6413 "Add buttons to the head of the article."
6415 (gnus-with-article-headers
6417 (dolist (entry gnus-header-button-alist)
6418 ;; Each alist entry.
6419 (goto-char (point-min))
6420 (while (re-search-forward (car entry) nil t)
6421 ;; Each header matching the entry.
6422 (setq beg (match-beginning 0))
6423 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6424 (match-beginning 0))
6427 (while (re-search-forward (eval (nth 1 entry)) end t)
6428 ;; Each match within a header.
6429 (let* ((entry (cdr entry))
6430 (start (match-beginning (nth 1 entry)))
6431 (end (match-end (nth 1 entry)))
6432 (form (nth 2 entry)))
6433 (goto-char (match-end 0))
6435 (gnus-article-add-button
6436 start end (nth 3 entry)
6437 (buffer-substring (match-beginning (nth 4 entry))
6438 (match-end (nth 4 entry)))))))
6439 (goto-char end))))))
6441 ;;; External functions:
6443 (defun gnus-article-add-button (from to fun &optional data)
6444 "Create a button between FROM and TO with callback FUN and data DATA."
6445 (when gnus-article-button-face
6446 (gnus-overlay-put (gnus-make-overlay from to)
6447 'face gnus-article-button-face))
6448 (gnus-add-text-properties
6450 (nconc (and gnus-article-mouse-face
6451 (list gnus-mouse-face-prop gnus-article-mouse-face))
6452 (list 'gnus-callback fun)
6453 (and data (list 'gnus-data data))))
6454 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6455 :button-keymap gnus-widget-button-keymap))
6457 ;;; Internal functions:
6459 (defun gnus-article-set-globals ()
6460 (with-current-buffer gnus-summary-buffer
6461 (gnus-set-global-variables)))
6463 (defun gnus-signature-toggle (end)
6464 (gnus-with-article-buffer
6465 (let ((inhibit-point-motion-hooks t))
6466 (if (text-property-any end (point-max) 'article-type 'signature)
6468 (gnus-delete-wash-type 'signature)
6469 (gnus-remove-text-properties-when
6470 'article-type 'signature end (point-max)
6471 (cons 'article-type (cons 'signature
6472 gnus-hidden-properties))))
6473 (gnus-add-wash-type 'signature)
6474 (gnus-add-text-properties-when
6475 'article-type nil end (point-max)
6476 (cons 'article-type (cons 'signature
6477 gnus-hidden-properties)))))
6478 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6479 (gnus-set-mode-line 'article))))
6481 (defun gnus-button-entry ()
6482 ;; Return the first entry in `gnus-button-alist' matching this place.
6483 (let ((alist gnus-button-alist)
6486 (setq entry (pop alist))
6487 (if (looking-at (eval (car entry)))
6492 (defun gnus-button-push (marker)
6493 ;; Push button starting at MARKER.
6496 (let* ((entry (gnus-button-entry))
6497 (inhibit-point-motion-hooks t)
6499 (args (mapcar (lambda (group)
6500 (let ((string (match-string group)))
6501 (set-text-properties
6502 0 (length string) nil string)
6509 (fboundp (symbol-value fun)))
6510 (apply (symbol-value fun) args))
6512 (gnus-message 1 "You must define `%S' to use this button"
6513 (cons fun args)))))))
6515 (defun gnus-parse-news-url (url)
6516 (let (scheme server group message-id articles)
6519 (goto-char (point-min))
6520 (when (looking-at "\\([A-Za-z]+\\):")
6521 (setq scheme (match-string 1))
6522 (goto-char (match-end 0)))
6523 (when (looking-at "//\\([^/]+\\)/")
6524 (setq server (match-string 1))
6525 (goto-char (match-end 0)))
6528 ((looking-at "\\(.*@.*\\)")
6529 (setq message-id (match-string 1)))
6530 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6531 (setq group (match-string 1)
6532 articles (split-string (match-string 2) "-")))
6533 ((looking-at "\\([^/]+\\)/?")
6534 (setq group (match-string 1)))
6536 (error "Unknown news URL syntax"))))
6537 (list scheme server group message-id articles)))
6539 (defun gnus-button-handle-news (url)
6541 (destructuring-bind (scheme server group message-id articles)
6542 (gnus-parse-news-url url)
6546 (set-buffer gnus-summary-buffer)
6548 (let ((gnus-refer-article-method (list (list 'nntp server))))
6549 (gnus-summary-refer-article message-id))
6550 (gnus-summary-refer-article message-id))))
6552 (gnus-button-fetch-group url)))))
6554 (defun gnus-button-handle-man (url)
6556 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6557 (when (eq gnus-button-man-handler 'woman)
6558 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6559 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6560 (funcall gnus-button-man-handler url))
6562 (defun gnus-button-handle-info-url (url)
6563 "Fetch an info URL."
6564 (setq url (mm-subst-char-in-string ?+ ?\ url))
6566 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6567 (gnus-info-find-node
6568 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6570 ")" (gnus-url-unhex-string (match-string 2 url)))))
6571 ((string-match "([^)\"]+)[^\"]+" url)
6573 (gnus-replace-in-string
6574 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6575 (gnus-info-find-node url))
6576 (t (error "Can't parse %s" url))))
6578 (defun gnus-button-handle-info-url-gnome (url)
6579 "Fetch GNOME style info URL."
6580 (setq url (mm-subst-char-in-string ?_ ?\ url))
6581 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6582 (gnus-info-find-node
6584 (gnus-url-unhex-string
6585 (match-string 1 url))
6587 (or (gnus-url-unhex-string
6588 (match-string 2 url))
6590 (error "Can't parse %s" url)))
6592 (defun gnus-button-handle-info-url-kde (url)
6593 "Fetch KDE style info URL."
6594 (gnus-info-find-node (gnus-url-unhex-string url)))
6596 (defun gnus-button-handle-info-keystrokes (url)
6597 "Call `info' when pushing the corresponding URL button."
6598 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6603 (defun gnus-button-message-id (message-id)
6605 (with-current-buffer gnus-summary-buffer
6606 (gnus-summary-refer-article message-id)))
6608 (defun gnus-button-fetch-group (address)
6609 "Fetch GROUP specified by ADDRESS."
6610 (if (not (string-match "[:/]" address))
6611 ;; This is just a simple group url.
6612 (gnus-group-read-ephemeral-group address gnus-select-method)
6615 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6617 (error "Can't parse %s" address)
6618 (gnus-group-read-ephemeral-group
6619 (match-string 4 address)
6620 `(nntp ,(match-string 1 address)
6621 (nntp-address ,(match-string 1 address))
6622 (nntp-port-number ,(if (match-end 3)
6623 (match-string 3 address)
6626 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6628 (defun gnus-url-parse-query-string (query &optional downcase)
6629 (let (retval pairs cur key val)
6630 (setq pairs (split-string query "&"))
6632 (setq cur (car pairs)
6634 (if (not (string-match "=" cur))
6636 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6637 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6639 (setq key (downcase key)))
6640 (setq cur (assoc key retval))
6642 (setcdr cur (cons val (cdr cur)))
6643 (setq retval (cons (list key val) retval)))))
6646 (defun gnus-url-mailto (url)
6647 ;; Send mail to someone
6648 (when (string-match "mailto:/*\\(.*\\)" url)
6649 (setq url (substring url (match-beginning 1) nil)))
6650 (let (to args subject func)
6651 (setq args (gnus-url-parse-query-string
6652 (if (string-match "^\\?" url)
6654 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6655 (concat "to=" (match-string 1 url) "&"
6656 (match-string 2 url))
6657 (concat "to=" url)))
6659 subject (cdr-safe (assoc "subject" args)))
6662 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6665 (message-position-on-field (caar args)))
6666 (insert (gnus-replace-in-string
6667 (mapconcat 'identity (reverse (cdar args)) ", ")
6669 (setq args (cdr args)))
6672 (message-goto-subject))))
6674 (defun gnus-button-embedded-url (address)
6675 "Activate ADDRESS with `browse-url'."
6676 (browse-url (gnus-strip-whitespace address)))
6678 ;;; Next/prev buttons in the article buffer.
6680 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6681 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6683 (defvar gnus-prev-page-map
6684 (let ((map (make-sparse-keymap)))
6685 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6686 (define-key map "\r" 'gnus-button-prev-page)
6689 (defvar gnus-next-page-map
6690 (let ((map (make-sparse-keymap)))
6691 (unless (>= emacs-major-version 21)
6692 ;; XEmacs doesn't care.
6693 (set-keymap-parent map gnus-article-mode-map))
6694 (define-key map gnus-mouse-2 'gnus-button-next-page)
6695 (define-key map "\r" 'gnus-button-next-page)
6698 (defun gnus-insert-prev-page-button ()
6700 (inhibit-read-only t))
6702 gnus-prev-page-line-format nil
6703 `(keymap ,gnus-prev-page-map
6705 gnus-callback gnus-article-button-prev-page
6706 article-type annotation))
6707 (widget-convert-button
6709 ;; Exclude a newline.
6712 :action 'gnus-button-prev-page
6713 :button-keymap gnus-prev-page-map)))
6715 (defun gnus-button-next-page (&optional args more-args)
6716 "Go to the next page."
6718 (let ((win (selected-window)))
6719 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6720 (gnus-article-next-page)
6721 (select-window win)))
6723 (defun gnus-button-prev-page (&optional args more-args)
6724 "Go to the prev page."
6726 (let ((win (selected-window)))
6727 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6728 (gnus-article-prev-page)
6729 (select-window win)))
6731 (defun gnus-insert-next-page-button ()
6733 (inhibit-read-only t))
6734 (gnus-eval-format gnus-next-page-line-format nil
6735 `(keymap ,gnus-next-page-map
6737 gnus-callback gnus-article-button-next-page
6738 article-type annotation))
6739 (widget-convert-button
6741 ;; Exclude a newline.
6744 :action 'gnus-button-next-page
6745 :button-keymap gnus-next-page-map)))
6747 (defun gnus-article-button-next-page (arg)
6748 "Go to the next page."
6750 (let ((win (selected-window)))
6751 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6752 (gnus-article-next-page)
6753 (select-window win)))
6755 (defun gnus-article-button-prev-page (arg)
6756 "Go to the prev page."
6758 (let ((win (selected-window)))
6759 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6760 (gnus-article-prev-page)
6761 (select-window win)))
6763 (defvar gnus-decode-header-methods
6764 '(mail-decode-encoded-word-region)
6765 "List of methods used to decode headers.
6767 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6768 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6769 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6770 whose names match REGEXP.
6773 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6774 mail-decode-encoded-word-region
6775 (\"chinese\" . rfc1843-decode-region))
6778 (defvar gnus-decode-header-methods-cache nil)
6780 (defun gnus-multi-decode-header (start end)
6781 "Apply the functions from `gnus-encoded-word-methods' that match."
6782 (unless (and gnus-decode-header-methods-cache
6783 (eq gnus-newsgroup-name
6784 (car gnus-decode-header-methods-cache)))
6785 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6788 (nconc gnus-decode-header-methods-cache (list x))
6789 (if (and gnus-newsgroup-name
6790 (string-match (car x) gnus-newsgroup-name))
6791 (nconc gnus-decode-header-methods-cache
6793 gnus-decode-header-methods))
6794 (let ((xlist gnus-decode-header-methods-cache))
6797 (narrow-to-region start end)
6799 (funcall (pop xlist) (point-min) (point-max))))))
6802 ;;; Treatment top-level handling.
6805 (defun gnus-treat-article (condition &optional part-number total-parts type)
6806 (let ((length (- (point-max) (point-min)))
6807 (alist gnus-treatment-function-alist)
6808 (article-goto-body-goes-to-point-min-p t)
6812 (let ((list gnus-article-treat-types))
6814 (when (string-match (pop list) type)
6815 (throw 'found t)))))))
6816 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6818 (gnus-run-hooks 'gnus-part-display-hook)
6819 (dolist (elem alist)
6822 (when (gnus-buffer-live-p gnus-summary-buffer)
6823 (set-buffer gnus-summary-buffer))
6824 (symbol-value (car elem))))
6825 (when (and (or (consp val)
6827 (gnus-treat-predicate val)
6828 (or (not (get (car elem) 'highlight))
6831 (funcall (cadr elem)))))))
6833 ;; Dynamic variables.
6835 (defvar part-number)
6836 (defvar total-parts)
6841 (defun gnus-treat-predicate (val)
6848 (stringp (car val)))
6849 (apply 'gnus-or (mapcar `(lambda (s)
6850 (string-match s ,(or gnus-newsgroup-name "")))
6853 (let ((pred (pop val)))
6856 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6858 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6860 (not (gnus-treat-predicate (car val))))
6862 (equal (car val) type))
6864 (error "%S is not a valid predicate" pred)))))
6870 (eq part-number total-parts))
6874 (error "%S is not a valid value" val))))
6876 (defun gnus-article-encrypt-body (protocol &optional n)
6877 "Encrypt the article body."
6880 (or gnus-article-encrypt-protocol
6881 (completing-read "Encrypt protocol: "
6882 gnus-article-encrypt-protocol-alist
6884 current-prefix-arg))
6885 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6887 (error (format "Can't find the encrypt protocol %s" protocol)))
6888 (if (member gnus-newsgroup-name '("nndraft:delayed"
6891 (error "Can't encrypt the article in group %s"
6892 gnus-newsgroup-name))
6893 (gnus-summary-iterate n
6895 (set-buffer gnus-summary-buffer)
6896 (let ((mail-parse-charset gnus-newsgroup-charset)
6897 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6898 (summary-buffer gnus-summary-buffer)
6900 (gnus-set-global-variables)
6901 (when (gnus-group-read-only-p)
6902 (error "The current newsgroup does not support article encrypt"))
6903 (gnus-summary-show-article t)
6905 (or (mail-header-references gnus-current-headers) ""))
6906 (set-buffer gnus-article-buffer)
6907 (let* ((inhibit-read-only t)
6909 (mapcar (lambda (field)
6910 (and (save-restriction
6911 (message-narrow-to-head)
6912 (goto-char (point-min))
6913 (search-forward field nil t))
6915 (message-narrow-to-field)
6917 (delete-region (point-min) (point-max))
6919 '("Content-Type:" "Content-Transfer-Encoding:"
6920 "Content-Disposition:"))))
6921 (message-narrow-to-head)
6922 (message-remove-header "MIME-Version")
6923 (goto-char (point-max))
6924 (setq point (point))
6925 (insert (apply 'concat headers))
6927 (narrow-to-region point (point-max))
6928 (let ((message-options message-options))
6929 (message-options-set 'message-sender user-mail-address)
6930 (message-options-set 'message-recipients user-mail-address)
6931 (message-options-set 'message-sign-encrypt 'not)
6933 (goto-char (point-min))
6934 (insert "MIME-Version: 1.0\n")
6936 (gnus-summary-edit-article-done
6937 references nil summary-buffer t))
6938 (when gnus-keep-backlog
6939 (gnus-backlog-remove-article
6940 (car gnus-article-current) (cdr gnus-article-current)))
6942 (when (get-buffer gnus-original-article-buffer)
6943 (set-buffer gnus-original-article-buffer)
6944 (setq gnus-original-article nil)))
6945 (when gnus-use-cache
6946 (gnus-cache-update-article
6947 (car gnus-article-current) (cdr gnus-article-current))))))))
6949 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6950 "The following specs can be used:
6951 %t The security MIME type
6954 %D Details if button is pressed")
6956 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6957 "The following specs can be used:
6958 %t The security MIME type
6961 %D Details if button is pressed")
6963 (defvar gnus-mime-security-button-line-format-alist
6964 '((?t gnus-tmp-type ?s)
6965 (?i gnus-tmp-info ?s)
6966 (?d gnus-tmp-details ?s)
6967 (?D gnus-tmp-pressed-details ?s)))
6969 (defvar gnus-mime-security-button-map
6970 (let ((map (make-sparse-keymap)))
6971 (define-key map gnus-mouse-2 'gnus-article-push-button)
6972 (define-key map "\r" 'gnus-article-press-button)
6975 (defvar gnus-mime-security-details-buffer nil)
6977 (defvar gnus-mime-security-button-pressed nil)
6979 (defvar gnus-mime-security-show-details-inline t
6980 "If non-nil, show details in the article buffer.")
6982 (defun gnus-mime-security-verify-or-decrypt (handle)
6983 (mm-remove-parts (cdr handle))
6984 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6985 point (inhibit-read-only t))
6987 (goto-char (car region)))
6989 (narrow-to-region (point) (point))
6990 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6991 (let* ((mm-verify-option 'known)
6992 (mm-decrypt-option 'known)
6993 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6994 (unless (eq nparts (cdr handle))
6995 (mm-destroy-parts (cdr handle))
6996 (setcdr handle nparts))))
6997 (setq point (point))
6998 (gnus-mime-display-security handle)
6999 (goto-char (point-max)))
7001 (delete-region (point) (cdr region))
7002 (set-marker (car region) nil)
7003 (set-marker (cdr region) nil))
7006 (defun gnus-mime-security-show-details (handle)
7007 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7009 (gnus-message 5 "No details.")
7010 (if gnus-mime-security-show-details-inline
7011 (let ((gnus-mime-security-button-pressed
7012 (not (get-text-property (point) 'gnus-mime-details)))
7013 (gnus-mime-security-button-line-format
7014 (get-text-property (point) 'gnus-line-format))
7015 (inhibit-read-only t))
7017 (while (eq (get-text-property (point) 'gnus-line-format)
7018 gnus-mime-security-button-line-format)
7022 (narrow-to-region (point) (point))
7023 (gnus-insert-mime-security-button handle))
7024 (delete-region (point)
7025 (or (text-property-not-all
7028 gnus-mime-security-button-line-format)
7031 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7032 (with-current-buffer gnus-mime-security-details-buffer
7035 (setq gnus-mime-security-details-buffer
7036 (gnus-get-buffer-create "*MIME Security Details*")))
7037 (with-current-buffer gnus-mime-security-details-buffer
7039 (goto-char (point-min)))
7040 (pop-to-buffer gnus-mime-security-details-buffer)))))
7042 (defun gnus-mime-security-press-button (handle)
7044 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7045 (gnus-mime-security-show-details handle)
7046 (gnus-mime-security-verify-or-decrypt handle))))
7048 (defun gnus-insert-mime-security-button (handle &optional displayed)
7049 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7052 (or (nth 2 (assoc protocol mm-verify-function-alist))
7053 (nth 2 (assoc protocol mm-decrypt-function-alist))
7055 (if (equal (car handle) "multipart/signed")
7056 " Signed" " Encrypted")
7059 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7062 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7063 gnus-tmp-pressed-details
7065 (setq gnus-tmp-details
7066 (if gnus-tmp-details
7067 (concat "\n" gnus-tmp-details)
7069 (setq gnus-tmp-pressed-details
7070 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7075 gnus-mime-security-button-line-format
7076 gnus-mime-security-button-line-format-alist
7077 `(keymap ,gnus-mime-security-button-map
7078 gnus-callback gnus-mime-security-press-button
7079 gnus-line-format ,gnus-mime-security-button-line-format
7080 gnus-mime-details ,gnus-mime-security-button-pressed
7081 article-type annotation
7084 ;; Exclude a newline.
7087 (widget-convert-button
7090 :action 'gnus-widget-press-button
7091 :button-keymap gnus-mime-security-button-map
7093 (lambda (widget/window &optional overlay pos)
7094 ;; Needed to properly clear the message due to a bug in
7095 ;; wid-edit (XEmacs only).
7096 (when (boundp 'help-echo-owns-message)
7097 (setq help-echo-owns-message t))
7100 (aref gnus-mouse-2 0))))))
7102 (defun gnus-mime-display-security (handle)
7104 (narrow-to-region (point) (point))
7105 (unless (gnus-unbuttonized-mime-type-p (car handle))
7106 (gnus-insert-mime-security-button handle))
7107 (gnus-mime-display-mixed (cdr handle))
7110 (unless (gnus-unbuttonized-mime-type-p (car handle))
7111 (let ((gnus-mime-security-button-line-format
7112 gnus-mime-security-button-end-line-format))
7113 (gnus-insert-mime-security-button handle)))
7114 (mm-set-handle-multipart-parameter
7116 (cons (set-marker (make-marker) (point-min))
7117 (set-marker (make-marker) (point-max))))))
7123 (run-hooks 'gnus-art-load-hook)
7125 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7126 ;;; gnus-art.el ends here