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'."
218 :group 'gnus-article-hiding)
220 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
221 "Regexp matching signature separator.
222 This can also be a list of regexps. In that case, it will be checked
223 from head to tail looking for a separator. Searches will be done from
224 the end of the buffer."
225 :type '(repeat string)
226 :group 'gnus-article-signature)
228 (defcustom gnus-signature-limit nil
229 "Provide a limit to what is considered a signature.
230 If it is a number, no signature may not be longer (in characters) than
231 that number. If it is a floating point number, no signature may be
232 longer (in lines) than that number. If it is a function, the function
233 will be called without any parameters, and if it returns nil, there is
234 no signature in the buffer. If it is a string, it will be used as a
235 regexp. If it matches, the text in question is not a signature.
237 This can also be a list of the above values."
238 :type '(choice (integer :value 200)
240 (function :value fun)
241 (regexp :value ".*"))
242 :group 'gnus-article-signature)
244 (defcustom gnus-hidden-properties '(invisible t intangible t)
245 "Property list to use for hiding text."
247 :group 'gnus-article-hiding)
249 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
250 ;; frames in a session.
251 (defcustom gnus-article-x-face-command
252 (if (featurep 'xemacs)
253 (if (or (gnus-image-type-available-p 'xface)
254 (gnus-image-type-available-p 'pbm))
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
257 (if (gnus-image-type-available-p 'pbm)
258 'gnus-display-x-face-in-from
259 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
261 "*String or function to be executed to display an X-Face header.
262 If it is a string, the command will be executed in a sub-shell
263 asynchronously. The compressed face will be piped to this command."
264 :type `(choice string
265 (function-item gnus-display-x-face-in-from)
269 :group 'gnus-article-washing)
271 (defcustom gnus-article-x-face-too-ugly nil
272 "Regexp matching posters whose face shouldn't be shown automatically."
273 :type '(choice regexp (const nil))
274 :group 'gnus-article-washing)
276 (defcustom gnus-article-banner-alist nil
277 "Banner alist for stripping.
279 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
281 :type '(repeat (cons symbol regexp))
282 :group 'gnus-article-washing)
284 (gnus-define-group-parameter
287 "Alist of regexps (to match group names) and banner."
288 :variable-group gnus-article-washing
290 '(choice :tag "Banner"
292 (const :tag "Remove signature" signature)
293 (symbol :tag "Item in `gnus-article-banner-alist'" none)
295 (const :tag "None" nil))
297 "If non-nil, specify how to remove `banners' from articles.
299 Symbol `signature' means to remove signatures delimited by
300 `gnus-signature-separator'. Any other symbol is used to look up a
301 regular expression to match the banner in `gnus-article-banner-alist'.
302 A string is used as a regular expression to match the banner
305 (defcustom gnus-article-address-banner-alist nil
306 "Alist of mail addresses and banners.
307 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
308 to match a mail address in the From: header, BANNER is one of a symbol
309 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
310 If ADDRESS matches author's mail address, it will remove things like
311 advertisements. For example:
313 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
317 (regexp :tag "Address")
318 (choice :tag "Banner" :value nil
319 (const :tag "Remove signature" signature)
320 (symbol :tag "Item in `gnus-article-banner-alist'" none)
322 (const :tag "None" nil))))
323 :group 'gnus-article-washing)
325 (defcustom gnus-emphasis-alist
327 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
332 ("_/" "/_" underline-italic)
333 ("_\\*" "\\*_" underline-bold)
334 ("\\*/" "/\\*" bold-italic)
335 ("_\\*/" "/\\*_" underline-bold-italic))))
339 (format format (car spec) (cadr spec))
340 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
342 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
343 2 3 gnus-emphasis-underline)))
344 "*Alist that says how to fontify certain phrases.
345 Each item looks like this:
347 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
349 The first element is a regular expression to be matched. The second
350 is a number that says what regular expression grouping used to find
351 the entire emphasized word. The third is a number that says what
352 regexp grouping should be displayed and highlighted. The fourth
353 is the face used for highlighting."
354 :type '(repeat (list :value ("" 0 0 default)
356 (integer :tag "Match group")
357 (integer :tag "Emphasize group")
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
362 "A regexp to describe whitespace which should not be emphasized.
363 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
364 The former avoids underlining of leading and trailing whitespace,
365 and the latter avoids underlining any whitespace at all."
367 :group 'gnus-article-emphasis
370 (defface gnus-emphasis-bold '((t (:bold t)))
371 "Face used for displaying strong emphasized text (*word*)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-italic '((t (:italic t)))
375 "Face used for displaying italic emphasized text (/word/)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline '((t (:underline t)))
379 "Face used for displaying underlined emphasized text (_word_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
383 "Face used for displaying underlined bold emphasized text (_*word*_)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
387 "Face used for displaying underlined italic emphasized text (_/word/_)."
388 :group 'gnus-article-emphasis)
390 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
391 "Face used for displaying bold italic emphasized text (/*word*/)."
392 :group 'gnus-article-emphasis)
394 (defface gnus-emphasis-underline-bold-italic
395 '((t (:bold t :italic t :underline t)))
396 "Face used for displaying underlined bold italic emphasized text.
397 Example: (_/*word*/_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
401 '((t (:strikethru t)))
402 '((t (:strike-through t))))
403 "Face used for displaying strike-through text (-word-)."
404 :group 'gnus-article-emphasis)
406 (defface gnus-emphasis-highlight-words
407 '((t (:background "black" :foreground "yellow")))
408 "Face used for displaying highlighted words."
409 :group 'gnus-article-emphasis)
411 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
412 "Format for display of Date headers in article bodies.
413 See `format-time-string' for the possible values.
415 The variable can also be function, which should return a complete Date
416 header. The function is called with one argument, the time, which can
417 be fed to `format-time-string'."
418 :type '(choice string function)
419 :link '(custom-manual "(gnus)Article Date")
420 :group 'gnus-article-washing)
423 (autoload 'mail-extract-address-components "mail-extr"))
425 (defcustom gnus-save-all-headers t
426 "*If non-nil, don't remove any headers before saving."
427 :group 'gnus-article-saving
430 (defcustom gnus-prompt-before-saving 'always
431 "*This variable says how much prompting is to be done when saving articles.
432 If it is nil, no prompting will be done, and the articles will be
433 saved to the default files. If this variable is `always', each and
434 every article that is saved will be preceded by a prompt, even when
435 saving large batches of articles. If this variable is neither nil not
436 `always', there the user will be prompted once for a file name for
437 each invocation of the saving commands."
438 :group 'gnus-article-saving
439 :type '(choice (item always)
440 (item :tag "never" nil)
441 (sexp :tag "once" :format "%t\n" :value t)))
443 (defcustom gnus-saved-headers gnus-visible-headers
444 "Headers to keep if `gnus-save-all-headers' is nil.
445 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
446 If that variable is nil, however, all headers that match this regexp
447 will be kept while the rest will be deleted before saving."
448 :group 'gnus-article-saving
451 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
452 "A function to save articles in your favourite format.
453 The function must be interactively callable (in other words, it must
454 be an Emacs command).
456 Gnus provides the following functions:
458 * gnus-summary-save-in-rmail (Rmail format)
459 * gnus-summary-save-in-mail (Unix mail format)
460 * gnus-summary-save-in-folder (MH folder)
461 * gnus-summary-save-in-file (article format)
462 * gnus-summary-save-body-in-file (article body)
463 * gnus-summary-save-in-vm (use VM's folder format)
464 * gnus-summary-write-to-file (article format -- overwrite)."
465 :group 'gnus-article-saving
466 :type '(radio (function-item gnus-summary-save-in-rmail)
467 (function-item gnus-summary-save-in-mail)
468 (function-item gnus-summary-save-in-folder)
469 (function-item gnus-summary-save-in-file)
470 (function-item gnus-summary-save-body-in-file)
471 (function-item gnus-summary-save-in-vm)
472 (function-item gnus-summary-write-to-file)))
474 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
475 "A function generating a file name to save articles in Rmail format.
476 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
477 :group 'gnus-article-saving
480 (defcustom gnus-mail-save-name 'gnus-plain-save-name
481 "A function generating a file name to save articles in Unix mail format.
482 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
483 :group 'gnus-article-saving
486 (defcustom gnus-folder-save-name 'gnus-folder-save-name
487 "A function generating a file name to save articles in MH folder.
488 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
489 :group 'gnus-article-saving
492 (defcustom gnus-file-save-name 'gnus-numeric-save-name
493 "A function generating a file name to save articles in article format.
494 The function is called with NEWSGROUP, HEADERS, and optional
496 :group 'gnus-article-saving
499 (defcustom gnus-split-methods
500 '((gnus-article-archive-name)
501 (gnus-article-nndoc-name))
502 "*Variable used to suggest where articles are to be saved.
503 For instance, if you would like to save articles related to Gnus in
504 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
505 you could set this variable to something like:
507 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
508 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
510 This variable is an alist where the where the key is the match and the
511 value is a list of possible files to save in if the match is non-nil.
513 If the match is a string, it is used as a regexp match on the
514 article. If the match is a symbol, that symbol will be funcalled
515 from the buffer of the article to be saved with the newsgroup as the
516 parameter. If it is a list, it will be evaled in the same buffer.
518 If this form or function returns a string, this string will be used as
519 a possible file name; and if it returns a non-nil list, that list will
520 be used as possible file names."
521 :group 'gnus-article-saving
522 :type '(repeat (choice (list :value (fun) function)
523 (cons :value ("" "") regexp (repeat string))
526 (defcustom gnus-page-delimiter "^\^L"
527 "*Regexp describing what to use as article page delimiters.
528 The default value is \"^\^L\", which is a form linefeed at the
529 beginning of a line."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
534 "*The format specification for the article mode line.
535 See `gnus-summary-mode-line-format' for a closer description.
537 The following additional specs are available:
539 %w The article washing status.
540 %m The number of MIME parts in the article."
542 :group 'gnus-article-various)
544 (defcustom gnus-article-mode-hook nil
545 "*A hook for Gnus article mode."
547 :group 'gnus-article-various)
549 (when (featurep 'xemacs)
550 ;; Extracted from gnus-xmas-define in order to preserve user settings
551 (when (fboundp 'turn-off-scroll-in-place)
552 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
553 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
554 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
556 (defcustom gnus-article-menu-hook nil
557 "*Hook run after the creation of the article mode menu."
559 :group 'gnus-article-various)
561 (defcustom gnus-article-prepare-hook nil
562 "*A hook called after an article has been prepared in the article buffer."
564 :group 'gnus-article-various)
566 (make-obsolete-variable 'gnus-article-hide-pgp-hook
567 "This variable is obsolete in Gnus 5.10.")
569 (defcustom gnus-article-button-face 'bold
570 "Face used for highlighting buttons in the article buffer.
572 An article button is a piece of text that you can activate by pressing
573 `RET' or `mouse-2' above it."
575 :group 'gnus-article-buttons)
577 (defcustom gnus-article-mouse-face 'highlight
578 "Face used for mouse highlighting in the article buffer.
580 Article buttons will be displayed in this face when the cursor is
583 :group 'gnus-article-buttons)
585 (defcustom gnus-signature-face 'gnus-signature-face
586 "Face used for highlighting a signature in the article buffer.
587 Obsolete; use the face `gnus-signature-face' for customizations instead."
589 :group 'gnus-article-highlight
590 :group 'gnus-article-signature)
592 (defface gnus-signature-face
595 "Face used for highlighting a signature in the article buffer."
596 :group 'gnus-article-highlight
597 :group 'gnus-article-signature)
599 (defface gnus-header-from-face
602 (:foreground "spring green"))
605 (:foreground "red3"))
608 "Face used for displaying from headers."
609 :group 'gnus-article-headers
610 :group 'gnus-article-highlight)
612 (defface gnus-header-subject-face
615 (:foreground "SeaGreen3"))
618 (:foreground "red4"))
620 (:bold t :italic t)))
621 "Face used for displaying subject headers."
622 :group 'gnus-article-headers
623 :group 'gnus-article-highlight)
625 (defface gnus-header-newsgroups-face
628 (:foreground "yellow" :italic t))
631 (:foreground "MidnightBlue" :italic t))
634 "Face used for displaying newsgroups headers.
635 In the default setup this face is only used for crossposted
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-name-face
643 (:foreground "SeaGreen"))
646 (:foreground "maroon"))
649 "Face used for displaying header names."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-content-face
656 (:foreground "forest green" :italic t))
659 (:foreground "indianred4" :italic t))
661 (:italic t))) "Face used for displaying header content."
662 :group 'gnus-article-headers
663 :group 'gnus-article-highlight)
665 (defcustom gnus-header-face-alist
666 '(("From" nil gnus-header-from-face)
667 ("Subject" nil gnus-header-subject-face)
668 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
669 ("" gnus-header-name-face gnus-header-content-face))
670 "*Controls highlighting of article headers.
672 An alist of the form (HEADER NAME CONTENT).
674 HEADER is a regular expression which should match the name of a
675 header and NAME and CONTENT are either face names or nil.
677 The name of each header field will be displayed using the face
678 specified by the first element in the list where HEADER matches
679 the header name and NAME is non-nil. Similarly, the content will
680 be displayed by the first non-nil matching CONTENT face."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight
683 :type '(repeat (list (regexp :tag "Header")
685 (item :tag "skip" nil)
686 (face :value default))
687 (choice :tag "Content"
688 (item :tag "skip" nil)
689 (face :value default)))))
691 (defcustom gnus-article-decode-hook
692 '(article-decode-charset article-decode-encoded-words
693 article-decode-group-name article-decode-idna-rhs)
694 "*Hook run to decode charsets in articles."
695 :group 'gnus-article-headers
698 (defcustom gnus-display-mime-function 'gnus-display-mime
699 "Function to display MIME articles."
700 :group 'gnus-article-mime
703 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
704 "Function used to decode headers.")
706 (defvar gnus-article-dumbquotes-map
726 "Table for MS-to-Latin1 translation.")
728 (defcustom gnus-ignored-mime-types nil
729 "List of MIME types that should be ignored by Gnus."
731 :group 'gnus-article-mime
732 :type '(repeat regexp))
734 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
735 "List of MIME types that should not be given buttons when rendered inline.
736 See also `gnus-buttonized-mime-types' which may override this variable.
737 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
739 :group 'gnus-article-mime
740 :type '(repeat regexp))
742 (defcustom gnus-buttonized-mime-types nil
743 "List of MIME types that should be given buttons when rendered inline.
744 If set, this variable overrides `gnus-unbuttonized-mime-types'.
745 To see e.g. security buttons you could set this to
746 `(\"multipart/signed\")'.
747 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
749 :group 'gnus-article-mime
750 :type '(repeat regexp))
752 (defcustom gnus-inhibit-mime-unbuttonizing nil
753 "If non-nil, all MIME parts get buttons.
754 When nil (the default value), then some MIME parts do not get buttons,
755 as described by the variables `gnus-buttonized-mime-types' and
756 `gnus-unbuttonized-mime-types'."
758 :group 'gnus-article-mime
761 (defcustom gnus-body-boundary-delimiter "_"
762 "String used to delimit header and body.
763 This variable is used by `gnus-article-treat-body-boundary' which can
764 be controlled by `gnus-treat-body-boundary'."
765 :group 'gnus-article-various
766 :type '(choice (item :tag "None" :value nil)
769 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
771 "Defines the location of the faces database.
772 For information on obtaining this database of pretty pictures, please
773 see http://www.cs.indiana.edu/picons/ftp/index.html"
774 :type '(repeat directory)
775 :link '(url-link :tag "download"
776 "http://www.cs.indiana.edu/picons/ftp/index.html")
777 :link '(custom-manual "(gnus)Picons")
780 (defun gnus-picons-installed-p ()
781 "Say whether picons are installed on your machine."
782 (let ((installed nil))
783 (dolist (database gnus-picon-databases)
784 (when (file-exists-p database)
788 (defcustom gnus-article-mime-part-function nil
789 "Function called with a MIME handle as the argument.
790 This is meant for people who want to do something automatic based
791 on parts -- for instance, adding Vcard info to a database."
792 :group 'gnus-article-mime
795 (defcustom gnus-mime-multipart-functions nil
796 "An alist of MIME types to functions to display them."
798 :group 'gnus-article-mime
799 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
801 (defcustom gnus-article-date-lapsed-new-header nil
802 "Whether the X-Sent and Date headers can coexist.
803 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
804 either replace the old \"Date:\" header (if this variable is nil), or
805 be added below it (otherwise)."
807 :group 'gnus-article-headers
810 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
811 "Function called with a MIME handle as the argument.
812 This is meant for people who want to view first matched part.
813 For `undisplayed-alternative' (default), the first undisplayed
814 part or alternative part is used. For `undisplayed', the first
815 undisplayed part is used. For a function, the first part which
816 the function return t is used. For nil, the first part is
819 :group 'gnus-article-mime
821 (item :tag "first" :value nil)
822 (item :tag "undisplayed" :value undisplayed)
823 (item :tag "undisplayed or alternative"
824 :value undisplayed-alternative)
827 (defcustom gnus-mime-action-alist
828 '(("save to file" . gnus-mime-save-part)
829 ("save and strip" . gnus-mime-save-part-and-strip)
830 ("delete part" . gnus-mime-delete-part)
831 ("display as text" . gnus-mime-inline-part)
832 ("view the part" . gnus-mime-view-part)
833 ("pipe to command" . gnus-mime-pipe-part)
834 ("toggle display" . gnus-article-press-button)
835 ("toggle display" . gnus-article-view-part-as-charset)
836 ("view as type" . gnus-mime-view-part-as-type)
837 ("view internally" . gnus-mime-view-part-internally)
838 ("view externally" . gnus-mime-view-part-externally))
839 "An alist of actions that run on the MIME attachment."
840 :group 'gnus-article-mime
841 :type '(repeat (cons (string :tag "name")
845 ;;; The treatment variables
848 (defvar gnus-part-display-hook nil
849 "Hook called on parts that are to receive treatment.")
851 (defvar gnus-article-treat-custom
852 '(choice (const :tag "Off" nil)
854 (const :tag "Header" head)
855 (const :tag "Last" last)
856 (integer :tag "Less")
857 (repeat :tag "Groups" regexp)
858 (sexp :tag "Predicate")))
860 (defvar gnus-article-treat-head-custom
861 '(choice (const :tag "Off" nil)
862 (const :tag "Header" head)))
864 (defvar gnus-article-treat-types '("text/plain")
867 (defvar gnus-inhibit-treatment nil
868 "Whether to inhibit treatment.")
870 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
871 "Highlight the signature.
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See Info node `(gnus)Customizing Articles'."
874 :group 'gnus-article-treat
875 :link '(custom-manual "(gnus)Customizing Articles")
876 :type gnus-article-treat-custom)
877 (put 'gnus-treat-highlight-signature 'highlight t)
879 (defcustom gnus-treat-buttonize 100000
881 Valid values are nil, t, `head', `last', an integer or a predicate.
882 See Info node `(gnus)Customizing Articles'."
883 :group 'gnus-article-treat
884 :link '(custom-manual "(gnus)Customizing Articles")
885 :type gnus-article-treat-custom)
886 (put 'gnus-treat-buttonize 'highlight t)
888 (defcustom gnus-treat-buttonize-head 'head
889 "Add buttons to the head.
890 Valid values are nil, t, `head', `last', an integer or a predicate.
891 See Info node `(gnus)Customizing Articles' for details."
892 :group 'gnus-article-treat
893 :link '(custom-manual "(gnus)Customizing Articles")
894 :type gnus-article-treat-head-custom)
895 (put 'gnus-treat-buttonize-head 'highlight t)
897 (defcustom gnus-treat-emphasize
898 (and (or window-system
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See Info node `(gnus)Customizing Articles' for details."
904 :group 'gnus-article-treat
905 :link '(custom-manual "(gnus)Customizing Articles")
906 :type gnus-article-treat-custom)
907 (put 'gnus-treat-emphasize 'highlight t)
909 (defcustom gnus-treat-strip-cr nil
910 "Remove carriage returns.
911 Valid values are nil, t, `head', `last', an integer or a predicate.
912 See Info node `(gnus)Customizing Articles' for details."
913 :group 'gnus-article-treat
914 :link '(custom-manual "(gnus)Customizing Articles")
915 :type gnus-article-treat-custom)
917 (defcustom gnus-treat-unsplit-urls nil
918 "Remove newlines from within URLs.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See Info node `(gnus)Customizing Articles' for details."
921 :group 'gnus-article-treat
922 :link '(custom-manual "(gnus)Customizing Articles")
923 :type gnus-article-treat-custom)
925 (defcustom gnus-treat-leading-whitespace nil
926 "Remove leading whitespace in headers.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :link '(custom-manual "(gnus)Customizing Articles")
931 :type gnus-article-treat-custom)
933 (defcustom gnus-treat-hide-headers 'head
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
937 :group 'gnus-article-treat
938 :link '(custom-manual "(gnus)Customizing Articles")
939 :type gnus-article-treat-head-custom)
941 (defcustom gnus-treat-hide-boring-headers nil
942 "Hide boring headers.
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See Info node `(gnus)Customizing Articles' for details."
945 :group 'gnus-article-treat
946 :link '(custom-manual "(gnus)Customizing Articles")
947 :type gnus-article-treat-head-custom)
949 (defcustom gnus-treat-hide-signature nil
951 Valid values are nil, t, `head', `last', an integer or a predicate.
952 See Info node `(gnus)Customizing Articles' for details."
953 :group 'gnus-article-treat
954 :link '(custom-manual "(gnus)Customizing Articles")
955 :type gnus-article-treat-custom)
957 (defcustom gnus-treat-fill-article nil
959 Valid values are nil, t, `head', `last', an integer or a predicate.
960 See Info node `(gnus)Customizing Articles' for details."
961 :group 'gnus-article-treat
962 :link '(custom-manual "(gnus)Customizing Articles")
963 :type gnus-article-treat-custom)
965 (defcustom gnus-treat-hide-citation nil
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See Info node `(gnus)Customizing Articles' for details."
969 :group 'gnus-article-treat
970 :link '(custom-manual "(gnus)Customizing Articles")
971 :type gnus-article-treat-custom)
973 (defcustom gnus-treat-hide-citation-maybe nil
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See Info node `(gnus)Customizing Articles' for details."
977 :group 'gnus-article-treat
978 :link '(custom-manual "(gnus)Customizing Articles")
979 :type gnus-article-treat-custom)
981 (defcustom gnus-treat-strip-list-identifiers 'head
982 "Strip list identifiers from `gnus-list-identifiers`.
983 Valid values are nil, t, `head', `last', an integer or a predicate.
984 See Info node `(gnus)Customizing Articles' for details."
986 :group 'gnus-article-treat
987 :link '(custom-manual "(gnus)Customizing Articles")
988 :type gnus-article-treat-custom)
990 (make-obsolete-variable 'gnus-treat-strip-pgp
991 "This option is obsolete in Gnus 5.10.")
993 (defcustom gnus-treat-strip-pem nil
994 "Strip PEM signatures.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-strip-banner t
1002 "Strip banners from articles.
1003 The banner to be stripped is specified in the `banner' group parameter.
1004 Valid values are nil, t, `head', `last', an integer or a predicate.
1005 See Info node `(gnus)Customizing Articles' for details."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-custom)
1010 (defcustom gnus-treat-highlight-headers 'head
1011 "Highlight the headers.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-head-custom)
1017 (put 'gnus-treat-highlight-headers 'highlight t)
1019 (defcustom gnus-treat-highlight-citation t
1020 "Highlight cited text.
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles' for details."
1023 :group 'gnus-article-treat
1024 :link '(custom-manual "(gnus)Customizing Articles")
1025 :type gnus-article-treat-custom)
1026 (put 'gnus-treat-highlight-citation 'highlight t)
1028 (defcustom gnus-treat-date-ut nil
1029 "Display the Date in UT (GMT).
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-head-custom)
1036 (defcustom gnus-treat-date-local nil
1037 "Display the Date in the local timezone.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :link '(custom-manual "(gnus)Customizing Articles")
1042 :type gnus-article-treat-head-custom)
1044 (defcustom gnus-treat-date-english nil
1045 "Display the Date in a format that can be read aloud in English.
1046 Valid values are nil, t, `head', `last', an integer or a predicate.
1047 See Info node `(gnus)Customizing Articles' for details."
1048 :group 'gnus-article-treat
1049 :link '(custom-manual "(gnus)Customizing Articles")
1050 :type gnus-article-treat-head-custom)
1052 (defcustom gnus-treat-date-lapsed nil
1053 "Display the Date header in a way that says how much time has elapsed.
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :link '(custom-manual "(gnus)Customizing Articles")
1058 :type gnus-article-treat-head-custom)
1060 (defcustom gnus-treat-date-original nil
1061 "Display the date in the original timezone.
1062 Valid values are nil, t, `head', `last', an integer or a predicate.
1063 See Info node `(gnus)Customizing Articles' for details."
1064 :group 'gnus-article-treat
1065 :link '(custom-manual "(gnus)Customizing Articles")
1066 :type gnus-article-treat-head-custom)
1068 (defcustom gnus-treat-date-iso8601 nil
1069 "Display the date in the ISO8601 format.
1070 Valid values are nil, t, `head', `last', an integer or a predicate.
1071 See Info node `(gnus)Customizing Articles' for details."
1073 :group 'gnus-article-treat
1074 :link '(custom-manual "(gnus)Customizing Articles")
1075 :type gnus-article-treat-head-custom)
1077 (defcustom gnus-treat-date-user-defined nil
1078 "Display the date in a user-defined format.
1079 The format is defined by the `gnus-article-time-format' variable.
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-head-custom)
1086 (defcustom gnus-treat-strip-headers-in-body t
1087 "Strip the X-No-Archive header line from the beginning of the body.
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-custom)
1095 (defcustom gnus-treat-strip-trailing-blank-lines nil
1096 "Strip trailing blank lines.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-custom)
1103 (defcustom gnus-treat-strip-leading-blank-lines nil
1104 "Strip leading blank lines.
1105 Valid values are nil, t, `head', `last', an integer or a predicate.
1106 See Info node `(gnus)Customizing Articles' for details."
1107 :group 'gnus-article-treat
1108 :link '(custom-manual "(gnus)Customizing Articles")
1109 :type gnus-article-treat-custom)
1111 (defcustom gnus-treat-strip-multiple-blank-lines nil
1112 "Strip multiple blank lines.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1119 (defcustom gnus-treat-unfold-headers 'head
1120 "Unfold folded header lines.
1121 Valid values are nil, t, `head', `last', an integer or a predicate.
1122 See Info node `(gnus)Customizing Articles' for details."
1123 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-custom)
1127 (defcustom gnus-treat-fold-headers nil
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See Info node `(gnus)Customizing Articles' for details."
1131 :group 'gnus-article-treat
1132 :link '(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom)
1135 (defcustom gnus-treat-fold-newsgroups 'head
1136 "Fold the Newsgroups and Followup-To headers.
1137 Valid values are nil, t, `head', `last', an integer or a predicate.
1138 See Info node `(gnus)Customizing Articles' for details."
1139 :group 'gnus-article-treat
1140 :link '(custom-manual "(gnus)Customizing Articles")
1141 :type gnus-article-treat-custom)
1143 (defcustom gnus-treat-overstrike t
1144 "Treat overstrike highlighting.
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1147 :group 'gnus-article-treat
1148 :link '(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-custom)
1150 (put 'gnus-treat-overstrike 'highlight t)
1152 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1153 "Treat ANSI SGR control sequences.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-custom)
1160 (make-obsolete-variable 'gnus-treat-display-xface
1161 'gnus-treat-display-x-face)
1163 (defcustom gnus-treat-display-x-face
1164 (and (not noninteractive)
1165 (or (and (fboundp 'image-type-available-p)
1166 (image-type-available-p 'xbm)
1167 (string-match "^0x" (shell-command-to-string "uncompface"))
1168 (executable-find "icontopbm"))
1169 (and (featurep 'xemacs)
1172 "Display X-Face headers.
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' and Info node
1175 `(gnus)X-Face' for details."
1176 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :link '(custom-manual "(gnus)X-Face")
1180 :type gnus-article-treat-head-custom
1181 :set (lambda (symbol value)
1184 (cond ((or (boundp symbol) (get symbol 'saved-value))
1186 ((boundp 'gnus-treat-display-xface)
1188 ** gnus-treat-display-xface is an obsolete variable;\
1189 use gnus-treat-display-x-face instead")
1190 (default-value 'gnus-treat-display-xface))
1191 ((get 'gnus-treat-display-xface 'saved-value)
1193 ** gnus-treat-display-xface is an obsolete variable;\
1194 use gnus-treat-display-x-face instead")
1195 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1198 (put 'gnus-treat-display-x-face 'highlight t)
1200 (defcustom gnus-treat-display-face
1201 (and (not noninteractive)
1202 (or (and (fboundp 'image-type-available-p)
1203 (image-type-available-p 'png))
1204 (and (featurep 'xemacs)
1207 "Display Face headers.
1208 Valid values are nil, t, `head', `last', an integer or a predicate.
1209 See Info node `(gnus)Customizing Articles' and Info node
1210 `(gnus)X-Face' for details."
1211 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :link '(custom-manual "(gnus)X-Face")
1215 :type gnus-article-treat-head-custom)
1216 (put 'gnus-treat-display-face 'highlight t)
1218 (defcustom gnus-treat-display-smileys
1219 (if (or (and (featurep 'xemacs)
1221 (and (fboundp 'image-type-available-p)
1222 (image-type-available-p 'pbm)))
1225 Valid values are nil, t, `head', `last', an integer or a predicate.
1226 See Info node `(gnus)Customizing Articles' and Info node
1227 `(gnus)Smileys' for details."
1228 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :link '(custom-manual "(gnus)Smileys")
1232 :type gnus-article-treat-custom)
1233 (put 'gnus-treat-display-smileys 'highlight t)
1235 (defcustom gnus-treat-from-picon
1236 (if (and (gnus-image-type-available-p 'xpm)
1237 (gnus-picons-installed-p))
1239 "Display picons in the From header.
1240 Valid values are nil, t, `head', `last', an integer or a predicate.
1241 See Info node `(gnus)Customizing Articles' and Info node
1242 `(gnus)Picons' for details."
1243 :group 'gnus-article-treat
1245 :link '(custom-manual "(gnus)Customizing Articles")
1246 :link '(custom-manual "(gnus)Picons")
1247 :type gnus-article-treat-head-custom)
1248 (put 'gnus-treat-from-picon 'highlight t)
1250 (defcustom gnus-treat-mail-picon
1251 (if (and (gnus-image-type-available-p 'xpm)
1252 (gnus-picons-installed-p))
1254 "Display picons in To and Cc headers.
1255 Valid values are nil, t, `head', `last', an integer or a predicate.
1256 See Info node `(gnus)Customizing Articles' and Info node
1257 `(gnus)Picons' for details."
1258 :group 'gnus-article-treat
1260 :link '(custom-manual "(gnus)Customizing Articles")
1261 :link '(custom-manual "(gnus)Picons")
1262 :type gnus-article-treat-head-custom)
1263 (put 'gnus-treat-mail-picon 'highlight t)
1265 (defcustom gnus-treat-newsgroups-picon
1266 (if (and (gnus-image-type-available-p 'xpm)
1267 (gnus-picons-installed-p))
1269 "Display picons in the Newsgroups and Followup-To headers.
1270 Valid values are nil, t, `head', `last', an integer or a predicate.
1271 See Info node `(gnus)Customizing Articles' and Info node
1272 `(gnus)Picons' for details."
1273 :group 'gnus-article-treat
1275 :link '(custom-manual "(gnus)Customizing Articles")
1276 :link '(custom-manual "(gnus)Picons")
1277 :type gnus-article-treat-head-custom)
1278 (put 'gnus-treat-newsgroups-picon 'highlight t)
1280 (defcustom gnus-treat-body-boundary
1281 (if (or gnus-treat-newsgroups-picon
1282 gnus-treat-mail-picon
1283 gnus-treat-from-picon)
1285 "Draw a boundary at the end of the headers.
1286 Valid values are nil and `head'.
1287 See Info node `(gnus)Customizing Articles' for details."
1289 :group 'gnus-article-treat
1290 :link '(custom-manual "(gnus)Customizing Articles")
1291 :type gnus-article-treat-head-custom)
1293 (defcustom gnus-treat-capitalize-sentences nil
1294 "Capitalize sentence-starting words.
1295 Valid values are nil, t, `head', `last', an integer or a predicate.
1296 See Info node `(gnus)Customizing Articles' for details."
1298 :group 'gnus-article-treat
1299 :link '(custom-manual "(gnus)Customizing Articles")
1300 :type gnus-article-treat-custom)
1302 (defcustom gnus-treat-wash-html nil
1304 Valid values are nil, t, `head', `last', an integer or a predicate.
1305 See Info node `(gnus)Customizing Articles' for details."
1306 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-custom)
1310 (defcustom gnus-treat-fill-long-lines nil
1312 Valid values are nil, t, `head', `last', an integer or a predicate.
1313 See Info node `(gnus)Customizing Articles' for details."
1314 :group 'gnus-article-treat
1315 :link '(custom-manual "(gnus)Customizing Articles")
1316 :type gnus-article-treat-custom)
1318 (defcustom gnus-treat-play-sounds nil
1320 Valid values are nil, t, `head', `last', an integer or a predicate.
1321 See Info node `(gnus)Customizing Articles' for details."
1323 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :type gnus-article-treat-custom)
1327 (defcustom gnus-treat-translate nil
1328 "Translate articles from one language to another.
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' for details."
1332 :group 'gnus-article-treat
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-custom)
1336 (defcustom gnus-treat-x-pgp-sig nil
1338 To automatically treat X-PGP-Sig, set it to head.
1339 Valid values are nil, t, `head', `last', an integer or a predicate.
1340 See Info node `(gnus)Customizing Articles' for details."
1341 :group 'gnus-article-treat
1342 :group 'mime-security
1343 :link '(custom-manual "(gnus)Customizing Articles")
1344 :type gnus-article-treat-custom)
1346 (defvar gnus-article-encrypt-protocol-alist
1347 '(("PGP" . mml2015-self-encrypt)))
1349 ;; Set to nil if more than one protocol added to
1350 ;; gnus-article-encrypt-protocol-alist.
1351 (defcustom gnus-article-encrypt-protocol "PGP"
1352 "The protocol used for encrypt articles.
1353 It is a string, such as \"PGP\". If nil, ask user."
1355 :group 'mime-security)
1357 (defvar gnus-article-wash-function nil
1358 "Function used for converting HTML into text.")
1360 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1361 (mm-coding-system-p 'utf-8)
1362 (executable-find idna-program))
1363 "Whether IDNA decoding of headers is used when viewing messages.
1364 This requires GNU Libidn, and by default only enabled if it is found."
1365 :group 'gnus-article-headers
1368 (defcustom gnus-article-over-scroll nil
1369 "If non-nil, allow scrolling the article buffer even when there no more text."
1370 :group 'gnus-article
1373 ;;; Internal variables
1375 (defvar gnus-english-month-names
1376 '("January" "February" "March" "April" "May" "June" "July" "August"
1377 "September" "October" "November" "December"))
1379 (defvar gnus-button-regexp nil)
1380 (defvar gnus-button-marker-list nil)
1381 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1383 (defvar gnus-button-last nil)
1384 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1386 (defvar article-goto-body-goes-to-point-min-p nil)
1387 (defvar gnus-article-wash-types nil)
1388 (defvar gnus-article-emphasis-alist nil)
1389 (defvar gnus-article-image-alist nil)
1391 (defvar gnus-article-mime-handle-alist-1 nil)
1392 (defvar gnus-treatment-function-alist
1393 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1394 (gnus-treat-strip-banner gnus-article-strip-banner)
1395 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1396 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1397 (gnus-treat-buttonize gnus-article-add-buttons)
1398 (gnus-treat-fill-article gnus-article-fill-cited-article)
1399 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1400 (gnus-treat-strip-cr gnus-article-remove-cr)
1401 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1402 (gnus-treat-date-ut gnus-article-date-ut)
1403 (gnus-treat-date-local gnus-article-date-local)
1404 (gnus-treat-date-english gnus-article-date-english)
1405 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1406 (gnus-treat-date-original gnus-article-date-original)
1407 (gnus-treat-date-user-defined gnus-article-date-user)
1408 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1409 (gnus-treat-display-x-face gnus-article-display-x-face)
1410 (gnus-treat-display-face gnus-article-display-face)
1411 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1412 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1413 (gnus-treat-hide-signature gnus-article-hide-signature)
1414 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1415 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1416 (gnus-treat-strip-pem gnus-article-hide-pem)
1417 (gnus-treat-from-picon gnus-treat-from-picon)
1418 (gnus-treat-mail-picon gnus-treat-mail-picon)
1419 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1420 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1421 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1422 (gnus-treat-strip-trailing-blank-lines
1423 gnus-article-remove-trailing-blank-lines)
1424 (gnus-treat-strip-leading-blank-lines
1425 gnus-article-strip-leading-blank-lines)
1426 (gnus-treat-strip-multiple-blank-lines
1427 gnus-article-strip-multiple-blank-lines)
1428 (gnus-treat-overstrike gnus-article-treat-overstrike)
1429 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1430 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1431 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1432 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1433 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1434 (gnus-treat-display-smileys gnus-treat-smiley)
1435 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1436 (gnus-treat-wash-html gnus-article-wash-html)
1437 (gnus-treat-emphasize gnus-article-emphasize)
1438 (gnus-treat-hide-citation gnus-article-hide-citation)
1439 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1440 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1441 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1442 (gnus-treat-play-sounds gnus-earcon-display)))
1444 (defvar gnus-article-mime-handle-alist nil)
1445 (defvar article-lapsed-timer nil)
1446 (defvar gnus-article-current-summary nil)
1448 (defvar gnus-article-mode-syntax-table
1449 (let ((table (copy-syntax-table text-mode-syntax-table)))
1450 ;; This causes the citation match run O(2^n).
1451 ;; (modify-syntax-entry ?- "w" table)
1452 (modify-syntax-entry ?> ")<" table)
1453 (modify-syntax-entry ?< "(>" table)
1454 ;; make M-. in article buffers work for `foo' strings
1455 (modify-syntax-entry ?' " " table)
1456 (modify-syntax-entry ?` " " table)
1458 "Syntax table used in article mode buffers.
1459 Initialized from `text-mode-syntax-table.")
1461 (defvar gnus-save-article-buffer nil)
1463 (defvar gnus-article-mode-line-format-alist
1464 (nconc '((?w (gnus-article-wash-status) ?s)
1465 (?m (gnus-article-mime-part-status) ?s))
1466 gnus-summary-mode-line-format-alist))
1468 (defvar gnus-number-of-articles-to-be-saved nil)
1470 (defvar gnus-inhibit-hiding nil)
1472 (defvar gnus-article-edit-mode nil)
1474 ;;; Macros for dealing with the article buffer.
1476 (defmacro gnus-with-article-headers (&rest forms)
1478 (set-buffer gnus-article-buffer)
1480 (let ((buffer-read-only nil)
1481 (inhibit-point-motion-hooks t)
1482 (case-fold-search t))
1483 (article-narrow-to-head)
1486 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1487 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1489 (defmacro gnus-with-article-buffer (&rest forms)
1491 (set-buffer gnus-article-buffer)
1492 (let ((buffer-read-only nil))
1495 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1496 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1498 (defun gnus-article-goto-header (header)
1499 "Go to HEADER, which is a regular expression."
1500 (re-search-forward (concat "^\\(" header "\\):") nil t))
1502 (defsubst gnus-article-hide-text (b e props)
1503 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1504 (gnus-add-text-properties-when 'article-type nil b e props)
1505 (when (memq 'intangible props)
1507 (max (1- b) (point-min))
1508 b 'intangible (cddr (memq 'intangible props)))))
1510 (defsubst gnus-article-unhide-text (b e)
1511 "Remove hidden text properties from region between B and E."
1512 (remove-text-properties b e gnus-hidden-properties)
1513 (when (memq 'intangible gnus-hidden-properties)
1514 (put-text-property (max (1- b) (point-min))
1515 b 'intangible nil)))
1517 (defun gnus-article-hide-text-type (b e type)
1518 "Hide text of TYPE between B and E."
1519 (gnus-add-wash-type type)
1520 (gnus-article-hide-text
1521 b e (cons 'article-type (cons type gnus-hidden-properties))))
1523 (defun gnus-article-unhide-text-type (b e type)
1524 "Unhide text of TYPE between B and E."
1525 (gnus-delete-wash-type type)
1526 (remove-text-properties
1527 b e (cons 'article-type (cons type gnus-hidden-properties)))
1528 (when (memq 'intangible gnus-hidden-properties)
1529 (put-text-property (max (1- b) (point-min))
1530 b 'intangible nil)))
1532 (defun gnus-article-hide-text-of-type (type)
1533 "Hide text of TYPE in the current buffer."
1535 (let ((b (point-min))
1537 (while (setq b (text-property-any b e 'article-type type))
1538 (add-text-properties b (incf b) gnus-hidden-properties)))))
1540 (defun gnus-article-delete-text-of-type (type)
1541 "Delete text of TYPE in the current buffer."
1543 (let ((b (point-min)))
1544 (while (setq b (text-property-any b (point-max) 'article-type type))
1546 b (or (text-property-not-all b (point-max) 'article-type type)
1549 (defun gnus-article-delete-invisible-text ()
1550 "Delete all invisible text in the current buffer."
1552 (let ((b (point-min)))
1553 (while (setq b (text-property-any b (point-max) 'invisible t))
1555 b (or (text-property-not-all b (point-max) 'invisible t)
1558 (defun gnus-article-text-type-exists-p (type)
1559 "Say whether any text of type TYPE exists in the buffer."
1560 (text-property-any (point-min) (point-max) 'article-type type))
1562 (defsubst gnus-article-header-rank ()
1563 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1564 (let ((list gnus-sorted-header-list)
1567 (if (looking-at (car list))
1569 (setq list (cdr list))
1573 (defun article-hide-headers (&optional arg delete)
1574 "Hide unwanted headers and possibly sort them as well."
1576 ;; This function might be inhibited.
1577 (unless gnus-inhibit-hiding
1578 (let ((buffer-read-only nil)
1579 (case-fold-search t)
1580 (max (1+ (length gnus-sorted-header-list)))
1581 (inhibit-point-motion-hooks t)
1582 (cur (current-buffer))
1583 ignored visible beg)
1585 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1586 ;; group parameters, so we should go to the summary buffer.
1589 (progn (set-buffer gnus-summary-buffer) t)
1591 (setq ignored (when (not gnus-visible-headers)
1592 (cond ((stringp gnus-ignored-headers)
1593 gnus-ignored-headers)
1594 ((listp gnus-ignored-headers)
1595 (mapconcat 'identity
1596 gnus-ignored-headers
1598 visible (cond ((stringp gnus-visible-headers)
1599 gnus-visible-headers)
1600 ((and gnus-visible-headers
1601 (listp gnus-visible-headers))
1602 (mapconcat 'identity
1603 gnus-visible-headers
1607 ;; First we narrow to just the headers.
1608 (article-narrow-to-head)
1609 ;; Hide any "From " lines at the beginning of (mail) articles.
1610 (while (looking-at "From ")
1613 (delete-region (point-min) (point)))
1614 ;; Then treat the rest of the header lines.
1615 ;; Then we use the two regular expressions
1616 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1617 ;; select which header lines is to remain visible in the
1619 (while (re-search-forward "^[^ \t:]*:" nil t)
1621 ;; Mark the rank of the header.
1623 (point) (1+ (point)) 'message-rank
1624 (if (or (and visible (looking-at visible))
1626 (not (looking-at ignored))))
1627 (gnus-article-header-rank)
1630 (message-sort-headers-1)
1631 (when (setq beg (text-property-any
1632 (point-min) (point-max) 'message-rank (+ 2 max)))
1633 ;; We delete the unwanted headers.
1634 (gnus-add-wash-type 'headers)
1635 (add-text-properties (point-min) (+ 5 (point-min))
1636 '(article-type headers dummy-invisible t))
1637 (delete-region beg (point-max))))))))
1639 (defun article-hide-boring-headers (&optional arg)
1640 "Toggle hiding of headers that aren't very interesting.
1641 If given a negative prefix, always show; if given a positive prefix,
1643 (interactive (gnus-article-hidden-arg))
1644 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1645 (not gnus-show-all-headers))
1648 (let ((buffer-read-only nil)
1649 (list gnus-boring-article-headers)
1650 (inhibit-point-motion-hooks t)
1652 (article-narrow-to-head)
1654 (setq elem (pop list))
1655 (goto-char (point-min))
1657 ;; Hide empty headers.
1659 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1661 (gnus-article-hide-text-type
1665 (if (re-search-forward "^[^ \t]" nil t)
1669 ;; Hide boring Newsgroups header.
1670 ((eq elem 'newsgroups)
1671 (when (gnus-string-equal
1672 (gnus-fetch-field "newsgroups")
1673 (gnus-group-real-name
1674 (if (boundp 'gnus-newsgroup-name)
1677 (gnus-article-hide-header "newsgroups")))
1678 ((eq elem 'to-address)
1679 (let ((to (message-fetch-field "to"))
1681 (gnus-parameter-to-address
1682 (if (boundp 'gnus-newsgroup-name)
1683 gnus-newsgroup-name ""))))
1684 (when (and to to-address
1687 ;; only one address in To
1688 (nth 1 (mail-extract-address-components to))
1690 (gnus-article-hide-header "to"))))
1692 (let ((to (message-fetch-field "to"))
1694 (gnus-parameter-to-list
1695 (if (boundp 'gnus-newsgroup-name)
1696 gnus-newsgroup-name ""))))
1697 (when (and to to-list
1700 ;; only one address in To
1701 (nth 1 (mail-extract-address-components to))
1703 (gnus-article-hide-header "to"))))
1705 (let ((cc (message-fetch-field "cc"))
1707 (gnus-parameter-to-list
1708 (if (boundp 'gnus-newsgroup-name)
1709 gnus-newsgroup-name ""))))
1710 (when (and cc to-list
1713 ;; only one address in CC
1714 (nth 1 (mail-extract-address-components cc))
1716 (gnus-article-hide-header "cc"))))
1717 ((eq elem 'followup-to)
1718 (when (gnus-string-equal
1719 (message-fetch-field "followup-to")
1720 (message-fetch-field "newsgroups"))
1721 (gnus-article-hide-header "followup-to")))
1722 ((eq elem 'reply-to)
1723 (if (gnus-group-find-parameter
1724 gnus-newsgroup-name 'broken-reply-to)
1725 (gnus-article-hide-header "reply-to")
1726 (let ((from (message-fetch-field "from"))
1727 (reply-to (message-fetch-field "reply-to")))
1734 (lambda (x) (downcase (cadr x)))
1735 (mail-extract-address-components from t))
1738 (lambda (x) (downcase (cadr x)))
1739 (mail-extract-address-components reply-to t))
1741 (gnus-article-hide-header "reply-to")))))
1743 (let ((date (message-fetch-field "date")))
1745 (< (days-between (current-time-string) date)
1747 (gnus-article-hide-header "date"))))
1749 (let ((to (message-fetch-field "to"))
1750 (cc (message-fetch-field "cc")))
1751 (when (> (length to) 1024)
1752 (gnus-article-hide-header "to"))
1753 (when (> (length cc) 1024)
1754 (gnus-article-hide-header "cc"))))
1758 (goto-char (point-min))
1759 (while (re-search-forward "^to:" nil t)
1760 (setq to-count (1+ to-count)))
1761 (when (> to-count 1)
1762 (while (> to-count 0)
1763 (goto-char (point-min))
1765 (re-search-forward "^to:" nil nil to-count)
1767 (narrow-to-region (point) (point-max))
1768 (gnus-article-hide-header "to"))
1769 (setq to-count (1- to-count))))
1770 (goto-char (point-min))
1771 (while (re-search-forward "^cc:" nil t)
1772 (setq cc-count (1+ cc-count)))
1773 (when (> cc-count 1)
1774 (while (> cc-count 0)
1775 (goto-char (point-min))
1777 (re-search-forward "^cc:" nil nil cc-count)
1779 (narrow-to-region (point) (point-max))
1780 (gnus-article-hide-header "cc"))
1781 (setq cc-count (1- cc-count)))))))))))))
1783 (defun gnus-article-hide-header (header)
1785 (goto-char (point-min))
1786 (when (re-search-forward (concat "^" header ":") nil t)
1787 (gnus-article-hide-text-type
1791 (if (re-search-forward "^[^ \t]" nil t)
1796 (defvar gnus-article-normalized-header-length 40
1797 "Length of normalized headers.")
1799 (defun article-normalize-headers ()
1800 "Make all header lines 40 characters long."
1802 (let ((buffer-read-only nil)
1806 (article-narrow-to-head)
1809 ((< (setq column (- (point-at-eol) (point)))
1810 gnus-article-normalized-header-length)
1812 (insert (make-string
1813 (- gnus-article-normalized-header-length column)
1815 ((> column gnus-article-normalized-header-length)
1816 (gnus-put-text-property
1818 (forward-char gnus-article-normalized-header-length)
1825 (forward-line 1))))))
1827 (defun article-treat-dumbquotes ()
1828 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1829 Note that this function guesses whether a character is a sm*rtq**t* or
1830 not, so it should only be used interactively.
1832 Sm*rtq**t*s are M****s***'s unilateral extension to the
1833 iso-8859-1 character map in an attempt to provide more quoting
1834 characters. If you see something like \\222 or \\264 where
1835 you're expecting some kind of apostrophe or quotation mark, then
1838 (article-translate-strings gnus-article-dumbquotes-map))
1840 (defun article-translate-characters (from to)
1841 "Translate all characters in the body of the article according to FROM and TO.
1842 FROM is a string of characters to translate from; to is a string of
1843 characters to translate to."
1845 (when (article-goto-body)
1846 (let ((buffer-read-only nil)
1847 (x (make-string 225 ?x))
1849 (while (< (incf i) (length x))
1852 (while (< i (length from))
1853 (aset x (aref from i) (aref to i))
1855 (translate-region (point) (point-max) x)))))
1857 (defun article-translate-strings (map)
1858 "Translate all string in the body of the article according to MAP.
1859 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1861 (when (article-goto-body)
1862 (let ((buffer-read-only nil)
1864 (while (setq elem (pop map))
1866 (while (search-forward (car elem) nil t)
1867 (replace-match (cadr elem)))))))))
1869 (defun article-treat-overstrike ()
1870 "Translate overstrikes into bold text."
1873 (when (article-goto-body)
1874 (let ((buffer-read-only nil))
1875 (while (search-forward "\b" nil t)
1876 (let ((next (char-after))
1877 (previous (char-after (- (point) 2))))
1878 ;; We do the boldification/underlining by hiding the
1879 ;; overstrikes and putting the proper text property
1883 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1884 (put-text-property (point) (1+ (point)) 'face 'bold))
1886 (gnus-article-hide-text-type
1887 (1- (point)) (1+ (point)) 'overstrike)
1889 (- (point) 2) (1- (point)) 'face 'underline))
1891 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1893 (point) (1+ (point)) 'face 'underline)))))))))
1895 (defun article-treat-ansi-sequences ()
1896 "Translate ANSI SGR control sequences into overlays or extents."
1899 (when (article-goto-body)
1900 (let ((buffer-read-only nil))
1901 (ansi-color-apply-on-region (point) (point-max))))))
1903 (defun gnus-article-treat-unfold-headers ()
1904 "Unfold folded message headers.
1905 Only the headers that fit into the current window width will be
1908 (gnus-with-article-headers
1912 (mail-header-narrow-to-field)
1913 (let ((header (buffer-string)))
1916 (goto-char (point-min))
1917 (while (re-search-forward "\n[\t ]" nil t)
1918 (replace-match " " t t)))
1919 (setq length (- (point-max) (point-min) 1)))
1920 (when (< length (window-width))
1921 (while (re-search-forward "\n[\t ]" nil t)
1922 (replace-match " " t t)))
1923 (goto-char (point-max)))))))
1925 (defun gnus-article-treat-fold-headers ()
1926 "Fold message headers."
1928 (gnus-with-article-headers
1931 (mail-header-narrow-to-field)
1932 (mail-header-fold-field)
1933 (goto-char (point-max))))))
1935 (defun gnus-treat-smiley ()
1936 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1938 (gnus-with-article-buffer
1939 (if (memq 'smiley gnus-article-wash-types)
1940 (gnus-delete-images 'smiley)
1942 (let ((images (smiley-region (point) (point-max))))
1944 (gnus-add-wash-type 'smiley)
1945 (dolist (image images)
1946 (gnus-add-image 'smiley image)))))))
1948 (defun gnus-article-remove-images ()
1949 "Remove all images from the article buffer."
1951 (gnus-with-article-buffer
1952 (dolist (elem gnus-article-image-alist)
1953 (gnus-delete-images (car elem)))))
1955 (defun gnus-article-treat-fold-newsgroups ()
1956 "Unfold folded message headers.
1957 Only the headers that fit into the current window width will be
1960 (gnus-with-article-headers
1961 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1963 (mail-header-narrow-to-field)
1964 (while (re-search-forward ", *" nil t)
1965 (replace-match ", " t t))
1966 (mail-header-fold-field)
1967 (goto-char (point-max))))))
1969 (defun gnus-article-treat-body-boundary ()
1970 "Place a boundary line at the end of the headers."
1972 (when (and gnus-body-boundary-delimiter
1973 (> (length gnus-body-boundary-delimiter) 0))
1974 (gnus-with-article-headers
1975 (goto-char (point-max))
1976 (let ((start (point)))
1977 (insert "X-Boundary: ")
1978 (gnus-add-text-properties start (point) '(invisible t intangible t))
1980 (while (>= (1- (window-width)) (length str))
1981 (setq str (concat str gnus-body-boundary-delimiter)))
1982 (substring str 0 (1- (window-width))))
1984 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1986 (defun article-fill-long-lines ()
1987 "Fill lines that are wider than the window width."
1990 (let ((buffer-read-only nil)
1991 (width (window-width (get-buffer-window (current-buffer)))))
1994 (let ((adaptive-fill-mode nil)) ;Why? -sm
1997 (when (>= (current-column) (min fill-column width))
1998 (narrow-to-region (min (1+ (point)) (point-max))
2000 (let ((goback (point-marker)))
2001 (fill-paragraph nil)
2002 (goto-char (marker-position goback)))
2004 (forward-line 1)))))))
2006 (defun article-capitalize-sentences ()
2007 "Capitalize the first word in each sentence."
2010 (let ((buffer-read-only nil)
2011 (paragraph-start "^[\n\^L]"))
2015 (forward-sentence)))))
2017 (defun article-remove-cr ()
2018 "Remove trailing CRs and then translate remaining CRs into LFs."
2021 (let ((buffer-read-only nil))
2022 (goto-char (point-min))
2023 (while (re-search-forward "\r+$" nil t)
2024 (replace-match "" t t))
2025 (goto-char (point-min))
2026 (while (search-forward "\r" nil t)
2027 (replace-match "\n" t t)))))
2029 (defun article-remove-trailing-blank-lines ()
2030 "Remove all trailing blank lines from the article."
2033 (let ((buffer-read-only nil))
2034 (goto-char (point-max))
2038 (while (and (not (bobp))
2039 (looking-at "^[ \t]*$")
2040 (not (gnus-annotation-in-region-p
2041 (point) (point-at-eol))))
2047 (defvar gnus-face-properties-alist))
2049 (defun article-display-face ()
2050 "Display any Face headers in the header."
2052 (let ((wash-face-p buffer-read-only))
2053 (gnus-with-article-headers
2054 ;; When displaying parts, this function can be called several times on
2055 ;; the same article, without any intended toggle semantic (as typing `W
2056 ;; D d' would have). So face deletion must occur only when we come from
2057 ;; an interactive command, that is when the *Article* buffer is
2059 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2060 (gnus-delete-images 'face)
2063 (when (and wash-face-p
2065 (goto-char (point-min))
2066 (not (re-search-forward "^Face:[\t ]*" nil t)))
2067 (gnus-buffer-live-p gnus-original-article-buffer))
2068 (set-buffer gnus-original-article-buffer))
2070 (mail-narrow-to-head)
2071 (while (gnus-article-goto-header "Face")
2072 (setq faces (nconc faces (list (mail-header-field-value)))))))
2073 (while (setq face (pop faces))
2074 (let ((png (gnus-convert-face-to-png face))
2078 (apply 'gnus-create-image png 'png t
2079 (cdr (assq 'png gnus-face-properties-alist))))
2080 (gnus-article-goto-header "from")
2082 (insert "From: [no `from' set]\n")
2084 (gnus-add-wash-type 'face)
2085 (gnus-add-image 'face image)
2086 (gnus-put-image image nil 'face))))))
2089 (defun article-display-x-face (&optional force)
2090 "Look for an X-Face header and display it if present."
2091 (interactive (list 'force))
2092 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2093 (gnus-with-article-headers
2094 ;; Delete the old process, if any.
2095 (when (process-status "article-x-face")
2096 (delete-process "article-x-face"))
2097 ;; See the comment in `article-display-face'.
2098 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2099 ;; We have already displayed X-Faces, so we remove them
2101 (gnus-delete-images 'xface)
2103 (let (x-faces from face)
2105 (when (and wash-face-p
2107 (goto-char (point-min))
2108 (not (re-search-forward
2109 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2110 (gnus-buffer-live-p gnus-original-article-buffer))
2111 ;; If type `W f', use gnus-original-article-buffer,
2112 ;; otherwise use the current buffer because displaying
2113 ;; RFC822 parts calls this function too.
2114 (set-buffer gnus-original-article-buffer))
2116 (mail-narrow-to-head)
2117 (while (gnus-article-goto-header "X-Face")
2118 (push (mail-header-field-value) x-faces))
2119 (setq from (message-fetch-field "from"))))
2120 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2121 ;; single external face.
2122 (when (stringp gnus-article-x-face-command)
2123 (setq x-faces (list (car x-faces))))
2124 (while (and (setq face (pop x-faces))
2125 gnus-article-x-face-command
2127 ;; Check whether this face is censored.
2128 (not gnus-article-x-face-too-ugly)
2129 (and gnus-article-x-face-too-ugly from
2130 (not (string-match gnus-article-x-face-too-ugly
2132 ;; We display the face.
2133 (cond ((stringp gnus-article-x-face-command)
2134 ;; The command is a string, so we interpret the command
2135 ;; as a, well, command, and fork it off.
2136 (let ((process-connection-type nil))
2137 (process-kill-without-query
2139 "article-x-face" nil shell-file-name
2140 shell-command-switch gnus-article-x-face-command))
2143 (process-send-region "article-x-face"
2144 (point-min) (point-max)))
2145 (process-send-eof "article-x-face")))
2146 ((functionp gnus-article-x-face-command)
2147 ;; The command is a lisp function, so we call it.
2148 (funcall gnus-article-x-face-command face))
2150 (error "%s is not a function"
2151 gnus-article-x-face-command)))))))))
2153 (defun article-decode-mime-words ()
2154 "Decode all MIME-encoded words in the article."
2156 (gnus-with-article-buffer
2157 (let ((inhibit-point-motion-hooks t)
2158 (mail-parse-charset gnus-newsgroup-charset)
2159 (mail-parse-ignored-charsets
2160 (with-current-buffer gnus-summary-buffer
2161 gnus-newsgroup-ignored-charsets)))
2162 (mail-decode-encoded-word-region (point-min) (point-max)))))
2164 (defun article-decode-charset (&optional prompt)
2165 "Decode charset-encoded text in the article.
2166 If PROMPT (the prefix), prompt for a coding system to use."
2168 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2170 (mail-parse-charset gnus-newsgroup-charset)
2171 (mail-parse-ignored-charsets
2172 (save-excursion (condition-case nil
2173 (set-buffer gnus-summary-buffer)
2175 gnus-newsgroup-ignored-charsets))
2176 ct cte ctl charset format)
2179 (article-narrow-to-head)
2180 (setq ct (message-fetch-field "Content-Type" t)
2181 cte (message-fetch-field "Content-Transfer-Encoding" t)
2182 ctl (and ct (ignore-errors
2183 (mail-header-parse-content-type ct)))
2186 (mm-read-coding-system "Charset to decode: "))
2188 (mail-content-type-get ctl 'charset)))
2189 format (and ctl (mail-content-type-get ctl 'format)))
2191 (setq cte (mail-header-strip cte)))
2192 (if (and ctl (not (string-match "/" (car ctl))))
2194 (goto-char (point-max)))
2197 (narrow-to-region (point) (point-max))
2198 (when (and (eq mail-parse-charset 'gnus-decoded)
2199 (eq (mm-body-7-or-8) '8bit))
2200 ;; The text code could have been decoded.
2201 (setq charset mail-parse-charset))
2202 (when (and (or (not ctl)
2203 (equal (car ctl) "text/plain"))
2204 (not format)) ;; article with format will decode later.
2206 charset (and cte (intern (downcase
2207 (gnus-strip-whitespace cte))))
2210 (defun article-decode-encoded-words ()
2211 "Remove encoded-word encoding from headers."
2212 (let ((inhibit-point-motion-hooks t)
2213 (mail-parse-charset gnus-newsgroup-charset)
2214 (mail-parse-ignored-charsets
2215 (save-excursion (condition-case nil
2216 (set-buffer gnus-summary-buffer)
2218 gnus-newsgroup-ignored-charsets))
2221 (article-narrow-to-head)
2222 (funcall gnus-decode-header-function (point-min) (point-max)))))
2224 (defun article-decode-group-name ()
2225 "Decode group names in `Newsgroups:'."
2226 (let ((inhibit-point-motion-hooks t)
2228 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2229 (when (and (or gnus-group-name-charset-method-alist
2230 gnus-group-name-charset-group-alist)
2231 (gnus-buffer-live-p gnus-original-article-buffer))
2233 (article-narrow-to-head)
2234 (with-current-buffer gnus-original-article-buffer
2235 (goto-char (point-min)))
2236 (while (re-search-forward
2237 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2238 (replace-match (save-match-data
2239 (gnus-decode-newsgroups
2240 ;; XXX how to use data in article buffer?
2241 (with-current-buffer gnus-original-article-buffer
2243 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2246 gnus-newsgroup-name method))
2248 (goto-char (point-min))
2249 (with-current-buffer gnus-original-article-buffer
2250 (goto-char (point-min)))
2251 (while (re-search-forward
2252 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2253 (replace-match (save-match-data
2254 (gnus-decode-newsgroups
2255 ;; XXX how to use data in article buffer?
2256 (with-current-buffer gnus-original-article-buffer
2258 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2261 gnus-newsgroup-name method))
2264 (autoload 'idna-to-unicode "idna")
2266 (defun article-decode-idna-rhs ()
2267 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2270 (let ((inhibit-point-motion-hooks t)
2272 (article-narrow-to-head)
2273 (goto-char (point-min))
2274 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2276 (when (save-match-data
2277 (and (setq ace (match-string 1))
2279 (and (re-search-backward "^[^ \t]" nil t)
2280 (looking-at "From\\|To\\|Cc")))
2281 (setq unicode (idna-to-unicode ace))))
2282 (unless (string= ace unicode)
2283 (replace-match unicode nil nil nil 1)))))))))
2285 (defun article-de-quoted-unreadable (&optional force read-charset)
2286 "Translate a quoted-printable-encoded article.
2287 If FORCE, decode the article whether it is marked as quoted-printable
2289 If READ-CHARSET, ask for a coding system."
2290 (interactive (list 'force current-prefix-arg))
2292 (let ((buffer-read-only nil) type charset)
2293 (if (gnus-buffer-live-p gnus-original-article-buffer)
2294 (with-current-buffer gnus-original-article-buffer
2296 (gnus-fetch-field "content-transfer-encoding"))
2297 (let* ((ct (gnus-fetch-field "content-type"))
2300 (mail-header-parse-content-type ct)))))
2301 (setq charset (and ctl
2302 (mail-content-type-get ctl 'charset)))
2303 (if (stringp charset)
2304 (setq charset (intern (downcase charset)))))))
2306 (setq charset (mm-read-coding-system "Charset: " charset)))
2308 (setq charset gnus-newsgroup-charset))
2310 (and type (let ((case-fold-search t))
2311 (string-match "quoted-printable" type))))
2313 (quoted-printable-decode-region
2314 (point) (point-max) (mm-charset-to-coding-system charset))))))
2316 (defun article-de-base64-unreadable (&optional force read-charset)
2317 "Translate a base64 article.
2318 If FORCE, decode the article whether it is marked as base64 not.
2319 If READ-CHARSET, ask for a coding system."
2320 (interactive (list 'force current-prefix-arg))
2322 (let ((buffer-read-only nil) type charset)
2323 (if (gnus-buffer-live-p gnus-original-article-buffer)
2324 (with-current-buffer gnus-original-article-buffer
2326 (gnus-fetch-field "content-transfer-encoding"))
2327 (let* ((ct (gnus-fetch-field "content-type"))
2330 (mail-header-parse-content-type ct)))))
2331 (setq charset (and ctl
2332 (mail-content-type-get ctl 'charset)))
2333 (if (stringp charset)
2334 (setq charset (intern (downcase charset)))))))
2336 (setq charset (mm-read-coding-system "Charset: " charset)))
2338 (setq charset gnus-newsgroup-charset))
2340 (and type (let ((case-fold-search t))
2341 (string-match "base64" type))))
2344 (narrow-to-region (point) (point-max))
2345 (base64-decode-region (point-min) (point-max))
2346 (mm-decode-coding-region
2347 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2352 (defun article-decode-HZ ()
2353 "Translate a HZ-encoded article."
2357 (let ((buffer-read-only nil))
2358 (rfc1843-decode-region (point-min) (point-max)))))
2360 (defun article-unsplit-urls ()
2361 "Remove the newlines that some other mailers insert into URLs."
2364 (let ((buffer-read-only nil))
2365 (goto-char (point-min))
2366 (while (re-search-forward
2367 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2368 (replace-match "\\1\\3" t)))
2369 (when (interactive-p)
2370 (gnus-treat-article nil))))
2373 (defun article-wash-html (&optional read-charset)
2374 "Format an HTML article.
2375 If READ-CHARSET, ask for a coding system."
2378 (let ((buffer-read-only nil)
2380 (when (gnus-buffer-live-p gnus-original-article-buffer)
2381 (with-current-buffer gnus-original-article-buffer
2382 (let* ((ct (gnus-fetch-field "content-type"))
2385 (mail-header-parse-content-type ct)))))
2386 (setq charset (and ctl
2387 (mail-content-type-get ctl 'charset)))
2388 (when (stringp charset)
2389 (setq charset (intern (downcase charset)))))))
2391 (setq charset (mm-read-coding-system "Charset: " charset)))
2393 (setq charset gnus-newsgroup-charset))
2395 (save-window-excursion
2397 (narrow-to-region (point) (point-max))
2398 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2399 (entry (assq func mm-text-html-washer-alist)))
2401 (setq func (cdr entry)))
2406 (apply (car func) (cdr func))))))))))
2408 (defun gnus-article-wash-html-with-w3 ()
2409 "Wash the current buffer with w3."
2411 (let ((w3-strict-width (window-width))
2412 (url-standalone-mode t)
2413 (url-gateway-unplugged t)
2414 (w3-honor-stylesheets nil))
2416 (w3-region (point-min) (point-max))
2419 (defun gnus-article-wash-html-with-w3m ()
2420 "Wash the current buffer with emacs-w3m."
2423 (narrow-to-region (point) (point-max))
2424 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2425 w3m-force-redisplay)
2426 (w3m-region (point-min) (point-max)))
2427 (when (and mm-inline-text-html-with-w3m-keymap
2428 (boundp 'w3m-minor-mode-map)
2430 (add-text-properties
2431 (point-min) (point-max)
2432 (list 'keymap w3m-minor-mode-map
2433 ;; Put the mark meaning this part was rendered by emacs-w3m.
2434 'mm-inline-text-html-with-w3m t)))))
2436 (defun article-hide-list-identifiers ()
2437 "Remove list identifies from the Subject header.
2438 The `gnus-list-identifiers' variable specifies what to do."
2440 (let ((inhibit-point-motion-hooks t)
2441 (regexp (if (consp gnus-list-identifiers)
2442 (mapconcat 'identity gnus-list-identifiers " *\\|")
2443 gnus-list-identifiers))
2448 (article-narrow-to-head)
2449 (goto-char (point-min))
2450 (while (re-search-forward
2451 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2453 (delete-region (match-beginning 2) (match-end 0))
2454 (beginning-of-line))
2455 (when (re-search-forward
2456 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2457 (delete-region (match-beginning 1) (match-end 1))))))))
2459 (defun article-hide-pem (&optional arg)
2460 "Toggle hiding of any PEM headers and signatures in the current article.
2461 If given a negative prefix, always show; if given a positive prefix,
2463 (interactive (gnus-article-hidden-arg))
2464 (unless (gnus-article-check-hidden-text 'pem arg)
2466 (let (buffer-read-only end)
2467 (goto-char (point-min))
2468 ;; Hide the horrendously ugly "header".
2469 (when (and (search-forward
2470 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2472 (setq end (1+ (match-beginning 0))))
2473 (gnus-add-wash-type 'pem)
2474 (gnus-article-hide-text-type
2476 (if (search-forward "\n\n" nil t)
2480 ;; Hide the trailer as well
2481 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2483 (gnus-article-hide-text-type
2484 (match-beginning 0) (match-end 0) 'pem)))))))
2486 (defun article-strip-banner ()
2487 "Strip the banners specified by the `banner' group parameter and by
2488 `gnus-article-address-banner-alist'."
2492 (let ((inhibit-point-motion-hooks t))
2493 (when (gnus-parameter-banner gnus-newsgroup-name)
2494 (article-really-strip-banner
2495 (gnus-parameter-banner gnus-newsgroup-name)))
2496 (when gnus-article-address-banner-alist
2497 ;; It is necessary to encode from fields before checking,
2498 ;; because `mail-header-parse-addresses' does not work
2499 ;; (reliably) on decoded headers. And more, it is
2500 ;; impossible to use `gnus-fetch-original-field' here,
2501 ;; because `article-strip-banner' may be called in draft
2502 ;; buffers to preview them.
2503 (let ((from (save-restriction
2505 (article-narrow-to-head)
2506 (mail-fetch-field "from"))))
2509 (caar (mail-header-parse-addresses
2510 (mail-encode-encoded-word-string from)))))
2512 (dolist (pair gnus-article-address-banner-alist)
2513 (when (string-match (car pair) from)
2515 (article-really-strip-banner (cdr pair)))))))))))))
2517 (defun article-really-strip-banner (banner)
2518 "Strip the banner specified by the argument."
2521 (let ((inhibit-point-motion-hooks t)
2522 (gnus-signature-limit nil)
2526 ((eq banner 'signature)
2527 (when (gnus-article-narrow-to-signature)
2530 (delete-region (point) (point-max))))
2532 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2533 (while (re-search-forward banner nil t)
2534 (delete-region (match-beginning 0) (match-end 0)))))
2536 (while (re-search-forward banner nil t)
2537 (delete-region (match-beginning 0) (match-end 0)))))))))
2539 (defun article-babel ()
2540 "Translate article using an online translation service."
2543 (gnus-with-article-buffer
2544 (when (article-goto-body)
2545 (let* ((start (point))
2547 (orig (buffer-substring start end))
2548 (trans (babel-as-string orig)))
2550 (narrow-to-region start end)
2551 (delete-region start end)
2554 (defun article-hide-signature (&optional arg)
2555 "Hide the signature in the current article.
2556 If given a negative prefix, always show; if given a positive prefix,
2558 (interactive (gnus-article-hidden-arg))
2559 (unless (gnus-article-check-hidden-text 'signature arg)
2562 (let ((buffer-read-only nil))
2563 (when (gnus-article-narrow-to-signature)
2564 (gnus-article-hide-text-type
2565 (point-min) (point-max) 'signature))))))
2566 (gnus-set-mode-line 'article))
2568 (defun article-strip-headers-in-body ()
2569 "Strip offensive headers from bodies."
2573 (let ((case-fold-search t))
2574 (when (looking-at "x-no-archive:")
2575 (gnus-delete-line)))))
2577 (defun article-strip-leading-blank-lines ()
2578 "Remove all blank lines from the beginning of the article."
2581 (let ((inhibit-point-motion-hooks t)
2583 (when (article-goto-body)
2584 (while (and (not (eobp))
2585 (looking-at "[ \t]*$"))
2586 (gnus-delete-line))))))
2588 (defun article-narrow-to-head ()
2589 "Narrow the buffer to the head of the message.
2590 Point is left at the beginning of the narrowed-to region."
2592 (goto-char (point-min))
2593 (if (search-forward "\n\n" nil 1)
2596 (goto-char (point-min)))
2598 (defun article-goto-body ()
2599 "Place point at the start of the body."
2600 (goto-char (point-min))
2602 ;; This variable is only bound when dealing with separate
2604 (article-goto-body-goes-to-point-min-p
2606 ((search-forward "\n\n" nil t)
2609 (goto-char (point-max))
2612 (defun article-strip-multiple-blank-lines ()
2613 "Replace consecutive blank lines with one empty line."
2616 (let ((inhibit-point-motion-hooks t)
2618 ;; First make all blank lines empty.
2620 (while (re-search-forward "^[ \t]+$" nil t)
2621 (unless (gnus-annotation-in-region-p
2622 (match-beginning 0) (match-end 0))
2623 (replace-match "" nil t)))
2624 ;; Then replace multiple empty lines with a single empty line.
2626 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2627 (unless (gnus-annotation-in-region-p
2628 (match-beginning 0) (match-end 0))
2629 (delete-region (match-beginning 1) (match-end 1)))))))
2631 (defun article-strip-leading-space ()
2632 "Remove all white space from the beginning of the lines in the article."
2635 (let ((inhibit-point-motion-hooks t)
2638 (while (re-search-forward "^[ \t]+" nil t)
2639 (replace-match "" t t)))))
2641 (defun article-strip-trailing-space ()
2642 "Remove all white space from the end of the lines in the article."
2645 (let ((inhibit-point-motion-hooks t)
2648 (while (re-search-forward "[ \t]+$" nil t)
2649 (replace-match "" t t)))))
2651 (defun article-strip-blank-lines ()
2652 "Strip leading, trailing and multiple blank lines."
2654 (article-strip-leading-blank-lines)
2655 (article-remove-trailing-blank-lines)
2656 (article-strip-multiple-blank-lines))
2658 (defun article-strip-all-blank-lines ()
2659 "Strip all blank lines."
2662 (let ((inhibit-point-motion-hooks t)
2665 (while (re-search-forward "^[ \t]*\n" nil t)
2666 (replace-match "" t t)))))
2668 (defun gnus-article-narrow-to-signature ()
2669 "Narrow to the signature; return t if a signature is found, else nil."
2670 (let ((inhibit-point-motion-hooks t))
2671 (when (gnus-article-search-signature)
2673 ;; Check whether we have some limits to what we consider
2674 ;; to be a signature.
2675 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2676 (list gnus-signature-limit)))
2678 (while (setq limit (pop limits))
2679 (if (or (and (integerp limit)
2680 (< (- (point-max) (point)) limit))
2682 (< (count-lines (point) (point-max)) limit))
2683 (and (functionp limit)
2685 (and (stringp limit)
2686 (not (re-search-forward limit nil t))))
2687 () ; This limit did not succeed.
2691 (narrow-to-region (point) (point-max))
2694 (defun gnus-article-search-signature ()
2695 "Search the current buffer for the signature separator.
2696 Put point at the beginning of the signature separator."
2697 (let ((cur (point)))
2698 (goto-char (point-max))
2699 (if (if (stringp gnus-signature-separator)
2700 (re-search-backward gnus-signature-separator nil t)
2701 (let ((seps gnus-signature-separator))
2703 (not (re-search-backward (car seps) nil t)))
2710 (defun gnus-article-hidden-arg ()
2711 "Return the current prefix arg as a number, or 0 if no prefix."
2712 (list (if current-prefix-arg
2713 (prefix-numeric-value current-prefix-arg)
2716 (defun gnus-article-check-hidden-text (type arg)
2717 "Return nil if hiding is necessary.
2718 Arg can be nil or a number. nil and positive means hide, negative
2719 means show, 0 means toggle."
2722 (let ((hide (gnus-article-hidden-text-p type)))
2728 (gnus-article-show-hidden-text type)
2731 (if (eq hide 'hidden)
2733 (gnus-article-show-hidden-text type)
2737 (defun gnus-article-hidden-text-p (type)
2738 "Say whether the current buffer contains hidden text of type TYPE."
2739 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2741 (not (get-text-property pos 'invisible))
2742 (not (get-text-property pos 'dummy-invisible)))
2744 (text-property-any (1+ pos) (point-max) 'article-type type)))
2749 (defun gnus-article-show-hidden-text (type &optional dummy)
2750 "Show all hidden text of type TYPE.
2751 Originally it is hide instead of DUMMY."
2752 (let ((buffer-read-only nil)
2753 (inhibit-point-motion-hooks t))
2754 (gnus-remove-text-properties-when
2756 (point-min) (point-max)
2757 (cons 'article-type (cons type
2758 gnus-hidden-properties)))
2759 (gnus-delete-wash-type type)))
2761 (defconst article-time-units
2762 `((year . ,(* 365.25 24 60 60))
2763 (week . ,(* 7 24 60 60))
2764 (day . ,(* 24 60 60))
2768 "Mapping from time units to seconds.")
2770 (defun gnus-article-forward-header ()
2771 "Move point to the start of the next header.
2772 If the current header is a continuation header, this can be several
2777 (if (looking-at "[ \t]+[^ \t]")
2781 (defun article-date-ut (&optional type highlight header)
2782 "Convert DATE date to universal time in the current article.
2783 If TYPE is `local', convert to local time; if it is `lapsed', output
2784 how much time has lapsed since DATE. For `lapsed', the value of
2785 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2786 should replace the \"Date:\" one, or should be added below it."
2787 (interactive (list 'ut t))
2788 (let* ((header (or header
2789 (message-fetch-field "date")
2791 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2794 ((not gnus-article-date-lapsed-new-header)
2800 (date (if (vectorp header) (mail-header-date header)
2802 (inhibit-point-motion-hooks t)
2807 (article-narrow-to-head)
2808 (when (re-search-forward tdate-regexp nil t)
2809 (setq bface (get-text-property (point-at-bol) 'face)
2810 date (or (get-text-property (point-at-bol)
2813 eface (get-text-property (1- (point-at-eol)) 'face))
2815 (when (and date (not (string= date "")))
2816 (goto-char (point-min))
2817 (let ((buffer-read-only nil))
2818 ;; Delete any old Date headers.
2819 (while (re-search-forward date-regexp nil t)
2821 (delete-region (point-at-bol)
2822 (progn (gnus-article-forward-header)
2824 (delete-region (point-at-bol)
2825 (progn (gnus-article-forward-header)
2828 (setq pos (point))))
2829 (when (and (not pos)
2830 (re-search-forward tdate-regexp nil t))
2832 (gnus-goto-char pos)
2833 (insert (article-make-date-line date (or type 'ut)))
2839 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2840 (add-text-properties (match-beginning 1) (1+ (match-end 1))
2841 (list 'original-date date 'face bface))
2842 (put-text-property (match-beginning 2) (match-end 2)
2845 (defun article-make-date-line (date type)
2846 "Return a DATE line of TYPE."
2847 (unless (memq type '(local ut original user iso8601 lapsed english))
2848 (error "Unknown conversion type: %s" type))
2850 (let ((time (date-to-time date)))
2852 ;; Convert to the local timezone.
2854 (concat "Date: " (message-make-date time)))
2855 ;; Convert to Universal Time.
2860 (let* ((e (parse-time-string date))
2861 (tm (apply 'encode-time e))
2863 (ls (- (cadr tm) (car (current-time-zone time)))))
2864 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2865 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2869 ;; Get the original date from the article.
2870 ((eq type 'original)
2871 (concat "Date: " (if (string-match "\n+$" date)
2872 (substring date 0 (match-beginning 0))
2874 ;; Let the user define the format.
2876 (let ((format (or (condition-case nil
2877 (with-current-buffer gnus-summary-buffer
2878 gnus-article-time-format)
2880 gnus-article-time-format)))
2881 (if (functionp format)
2882 (funcall format time)
2883 (concat "Date: " (format-time-string format time)))))
2886 (let ((tz (car (current-time-zone time))))
2889 (format-time-string "%Y%m%dT%H%M%S" time)
2890 (format "%s%02d%02d"
2891 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2892 (/ (% (abs tz) 3600) 60)))))
2893 ;; Do an X-Sent lapsed format.
2895 ;; If the date is seriously mangled, the timezone functions are
2896 ;; liable to bug out, so we ignore all errors.
2897 (let* ((now (current-time))
2898 (real-time (subtract-time now time))
2899 (real-sec (and real-time
2900 (+ (* (float (car real-time)) 65536)
2902 (sec (and real-time (abs real-sec)))
2912 ;; This is a bit convoluted, but basically we go
2913 ;; through the time units for years, weeks, etc,
2914 ;; and divide things to see whether that results
2915 ;; in positive answers.
2918 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2919 ;; The (remaining) seconds are too few to
2920 ;; be divided into this time unit.
2922 ;; It's big enough, so we output it.
2923 (setq sec (- sec (* num (cdr unit))))
2925 (concat (if prev ", " "") (int-to-string
2927 " " (symbol-name (car unit))
2928 (if (> num 1) "s" ""))
2930 article-time-units "")
2931 ;; If dates are odd, then it might appear like the
2932 ;; article was sent in the future.
2935 " in the future"))))))
2936 ;; Display the date in proper English
2938 (let ((dtime (decode-time time)))
2941 (number-to-string (nth 3 dtime))
2942 (let ((digit (% (nth 3 dtime) 10)))
2944 ((memq (nth 3 dtime) '(11 12 13)) "th")
2950 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2952 (number-to-string (nth 5 dtime))
2954 (format "%02d" (nth 2 dtime))
2956 (format "%02d" (nth 1 dtime)))))))
2958 (format "Date: %s (from Gnus)" date))))
2960 (defun article-date-local (&optional highlight)
2961 "Convert the current article date to the local timezone."
2962 (interactive (list t))
2963 (article-date-ut 'local highlight))
2965 (defun article-date-english (&optional highlight)
2966 "Convert the current article date to something that is proper English."
2967 (interactive (list t))
2968 (article-date-ut 'english highlight))
2970 (defun article-date-original (&optional highlight)
2971 "Convert the current article date to what it was originally.
2972 This is only useful if you have used some other date conversion
2973 function and want to see what the date was before converting."
2974 (interactive (list t))
2975 (article-date-ut 'original highlight))
2977 (defun article-date-lapsed (&optional highlight)
2978 "Convert the current article date to time lapsed since it was sent."
2979 (interactive (list t))
2980 (article-date-ut 'lapsed highlight))
2982 (defun article-update-date-lapsed ()
2983 "Function to be run from a timer to update the lapsed time line."
2984 (let (deactivate-mark)
2989 (set-buffer (window-buffer w))
2990 (when (eq major-mode 'gnus-article-mode)
2991 (let ((mark (point-marker)))
2992 (goto-char (point-min))
2993 (when (re-search-forward "^X-Sent:" nil t)
2994 (article-date-lapsed t))
2995 (goto-char (marker-position mark))
2996 (move-marker mark nil))))
2999 (defun gnus-start-date-timer (&optional n)
3000 "Start a timer to update the X-Sent header in the article buffers.
3001 The numerical prefix says how frequently (in seconds) the function
3006 (gnus-stop-date-timer)
3007 (setq article-lapsed-timer
3008 (run-at-time 1 n 'article-update-date-lapsed)))
3010 (defun gnus-stop-date-timer ()
3011 "Stop the X-Sent timer."
3013 (when article-lapsed-timer
3014 (nnheader-cancel-timer article-lapsed-timer)
3015 (setq article-lapsed-timer nil)))
3017 (defun article-date-user (&optional highlight)
3018 "Convert the current article date to the user-defined format.
3019 This format is defined by the `gnus-article-time-format' variable."
3020 (interactive (list t))
3021 (article-date-ut 'user highlight))
3023 (defun article-date-iso8601 (&optional highlight)
3024 "Convert the current article date to ISO8601."
3025 (interactive (list t))
3026 (article-date-ut 'iso8601 highlight))
3028 ;; (defun article-show-all ()
3029 ;; "Show all hidden text in the article buffer."
3032 ;; (let ((buffer-read-only nil))
3033 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3035 (defun article-remove-leading-whitespace ()
3036 "Remove excessive whitespace from all headers."
3040 (let ((buffer-read-only nil))
3041 (article-narrow-to-head)
3042 (goto-char (point-min))
3043 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3044 (delete-region (match-beginning 1) (match-end 1)))))))
3046 (defun article-emphasize (&optional arg)
3047 "Emphasize text according to `gnus-emphasis-alist'."
3048 (interactive (gnus-article-hidden-arg))
3049 (unless (gnus-article-check-hidden-text 'emphasis arg)
3053 (with-current-buffer gnus-summary-buffer
3054 gnus-article-emphasis-alist)
3056 gnus-emphasis-alist))
3057 (buffer-read-only nil)
3058 (props (append '(article-type emphasis)
3059 gnus-hidden-properties))
3060 regexp elem beg invisible visible face)
3063 (while (setq elem (pop alist))
3065 (setq regexp (car elem)
3066 invisible (nth 1 elem)
3067 visible (nth 2 elem)
3069 (while (re-search-forward regexp nil t)
3070 (when (and (match-beginning visible) (match-beginning invisible))
3071 (gnus-article-hide-text
3072 (match-beginning invisible) (match-end invisible) props)
3073 (gnus-article-unhide-text-type
3074 (match-beginning visible) (match-end visible) 'emphasis)
3075 (gnus-put-overlay-excluding-newlines
3076 (match-beginning visible) (match-end visible) 'face face)
3077 (gnus-add-wash-type 'emphasis)
3078 (goto-char (match-end invisible)))))))))
3080 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3081 "Setup newsgroup emphasis alist."
3082 (unless gnus-article-emphasis-alist
3083 (let ((name (and gnus-newsgroup-name
3084 (gnus-group-real-name gnus-newsgroup-name))))
3085 (make-local-variable 'gnus-article-emphasis-alist)
3086 (setq gnus-article-emphasis-alist
3088 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3089 (while (setq elem (pop alist))
3090 (when (and name (string-match (car elem) name))
3092 highlight (copy-sequence (cdr elem)))))
3094 (copy-sequence highlight-words)
3095 (if gnus-newsgroup-name
3096 (copy-sequence (gnus-group-find-parameter
3097 gnus-newsgroup-name 'highlight-words t)))
3098 gnus-emphasis-alist)))))
3101 (defvar gnus-summary-article-menu)
3102 (defvar gnus-summary-post-menu))
3104 ;;; Saving functions.
3106 (defun gnus-article-save (save-buffer file &optional num)
3107 "Save the currently selected article."
3108 (unless gnus-save-all-headers
3109 ;; Remove headers according to `gnus-saved-headers'.
3110 (let ((gnus-visible-headers
3111 (or gnus-saved-headers gnus-visible-headers))
3112 (gnus-article-buffer save-buffer))
3114 (set-buffer save-buffer)
3115 (article-hide-headers 1 t))))
3116 (save-window-excursion
3117 (if (not gnus-default-article-saver)
3118 (error "No default saver is defined")
3119 ;; !!! Magic! The saving functions all save
3120 ;; `gnus-save-article-buffer' (or so they think), but we
3121 ;; bind that variable to our save-buffer.
3122 (set-buffer gnus-article-buffer)
3123 (let* ((gnus-save-article-buffer save-buffer)
3126 ((not gnus-prompt-before-saving) 'default)
3127 ((eq gnus-prompt-before-saving 'always) nil)
3129 (gnus-number-of-articles-to-be-saved
3130 (when (eq gnus-prompt-before-saving t)
3132 (set-buffer gnus-article-current-summary)
3133 (funcall gnus-default-article-saver filename)))))
3135 (defun gnus-read-save-file-name (prompt &optional filename
3136 function group headers variable)
3138 (funcall function group headers (symbol-value variable)))
3143 ((eq filename 'default)
3149 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3152 (if (and gnus-number-of-articles-to-be-saved
3153 (> gnus-number-of-articles-to-be-saved 1))
3154 (format "these %d articles"
3155 gnus-number-of-articles-to-be-saved)
3158 ;; Let the split methods have their say.
3160 ;; No split name was found.
3163 (concat prompt " (default "
3164 (file-name-nondirectory default-name) ") ")
3165 (file-name-directory default-name)
3167 ;; A single group name is returned.
3168 ((stringp split-name)
3170 (funcall function split-name headers
3171 (symbol-value variable)))
3173 (concat prompt " (default "
3174 (file-name-nondirectory default-name) ") ")
3175 (file-name-directory default-name)
3177 ;; A single split name was found
3178 ((= 1 (length split-name))
3179 (let* ((name (expand-file-name
3181 gnus-article-save-directory))
3182 (dir (cond ((file-directory-p name)
3183 (file-name-as-directory name))
3184 ((file-exists-p name) name)
3185 (t gnus-article-save-directory))))
3187 (concat prompt " (default " name ") ")
3189 ;; A list of splits was found.
3191 (setq split-name (nreverse split-name))
3193 (let ((file-name-history
3194 (nconc split-name file-name-history)))
3198 (concat prompt " (`M-p' for defaults) ")
3199 gnus-article-save-directory
3201 gnus-article-save-directory)))
3202 (car (push result file-name-history)))))))
3203 ;; Create the directory.
3204 (gnus-make-directory (file-name-directory file))
3205 ;; If we have read a directory, we append the default file name.
3206 (when (file-directory-p file)
3207 (setq file (expand-file-name (file-name-nondirectory
3209 (file-name-as-directory file))))
3210 ;; Possibly translate some characters.
3211 (nnheader-translate-file-chars file))))))
3212 (gnus-make-directory (file-name-directory result))
3213 (set variable result)))
3215 (defun gnus-article-archive-name (group)
3216 "Return the first instance of an \"Archive-name\" in the current buffer."
3217 (let ((case-fold-search t))
3218 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3219 (nnheader-concat gnus-article-save-directory
3220 (match-string 1)))))
3222 (defun gnus-article-nndoc-name (group)
3223 "If GROUP is an nndoc group, return the name of the parent group."
3224 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3225 (gnus-group-get-parameter group 'save-article-group)))
3227 (defun gnus-summary-save-in-rmail (&optional filename)
3228 "Append this article to Rmail file.
3229 Optional argument FILENAME specifies file name.
3230 Directory to save to is default to `gnus-article-save-directory'."
3231 (setq filename (gnus-read-save-file-name
3232 "Save %s in rmail file:" filename
3233 gnus-rmail-save-name gnus-newsgroup-name
3234 gnus-current-headers 'gnus-newsgroup-last-rmail))
3235 (gnus-eval-in-buffer-window gnus-save-article-buffer
3239 (gnus-output-to-rmail filename))))
3242 (defun gnus-summary-save-in-mail (&optional filename)
3243 "Append this article to Unix mail file.
3244 Optional argument FILENAME specifies file name.
3245 Directory to save to is default to `gnus-article-save-directory'."
3246 (setq filename (gnus-read-save-file-name
3247 "Save %s in Unix mail file:" filename
3248 gnus-mail-save-name gnus-newsgroup-name
3249 gnus-current-headers 'gnus-newsgroup-last-mail))
3250 (gnus-eval-in-buffer-window gnus-save-article-buffer
3254 (if (and (file-readable-p filename)
3255 (file-regular-p filename)
3256 (mail-file-babyl-p filename))
3257 (rmail-output-to-rmail-file filename t)
3258 (gnus-output-to-mail filename)))))
3261 (defun gnus-summary-save-in-file (&optional filename overwrite)
3262 "Append this article to file.
3263 Optional argument FILENAME specifies file name.
3264 Directory to save to is default to `gnus-article-save-directory'."
3265 (setq filename (gnus-read-save-file-name
3266 "Save %s in file:" filename
3267 gnus-file-save-name gnus-newsgroup-name
3268 gnus-current-headers 'gnus-newsgroup-last-file))
3269 (gnus-eval-in-buffer-window gnus-save-article-buffer
3273 (when (and overwrite
3274 (file-exists-p filename))
3275 (delete-file filename))
3276 (gnus-output-to-file filename))))
3279 (defun gnus-summary-write-to-file (&optional filename)
3280 "Write this article to a file, overwriting it if the file exists.
3281 Optional argument FILENAME specifies file name.
3282 The directory to save in defaults to `gnus-article-save-directory'."
3283 (gnus-summary-save-in-file nil t))
3285 (defun gnus-summary-save-body-in-file (&optional filename)
3286 "Append this article body to a file.
3287 Optional argument FILENAME specifies file name.
3288 The directory to save in defaults to `gnus-article-save-directory'."
3289 (setq filename (gnus-read-save-file-name
3290 "Save %s body in file:" filename
3291 gnus-file-save-name gnus-newsgroup-name
3292 gnus-current-headers 'gnus-newsgroup-last-file))
3293 (gnus-eval-in-buffer-window gnus-save-article-buffer
3297 (when (article-goto-body)
3298 (narrow-to-region (point) (point-max)))
3299 (gnus-output-to-file filename))))
3302 (defun gnus-summary-save-in-pipe (&optional command)
3303 "Pipe this article to subprocess."
3305 (cond ((and (eq command 'default)
3306 gnus-last-shell-command)
3307 gnus-last-shell-command)
3312 "Shell command on %s: "
3313 (if (and gnus-number-of-articles-to-be-saved
3314 (> gnus-number-of-articles-to-be-saved 1))
3315 (format "these %d articles"
3316 gnus-number-of-articles-to-be-saved)
3318 gnus-last-shell-command))))
3319 (when (string-equal command "")
3320 (if gnus-last-shell-command
3321 (setq command gnus-last-shell-command)
3322 (error "A command is required")))
3323 (gnus-eval-in-buffer-window gnus-article-buffer
3326 (shell-command-on-region (point-min) (point-max) command nil)))
3327 (setq gnus-last-shell-command command))
3329 (defun gnus-summary-pipe-to-muttprint (&optional command)
3330 "Pipe this article to muttprint."
3331 (setq command (read-string
3332 "Print using command: " gnus-summary-muttprint-program
3333 nil gnus-summary-muttprint-program))
3334 (gnus-summary-save-in-pipe command))
3336 ;;; Article file names when saving.
3338 (defun gnus-capitalize-newsgroup (newsgroup)
3339 "Capitalize NEWSGROUP name."
3340 (when (not (zerop (length newsgroup)))
3341 (concat (char-to-string (upcase (aref newsgroup 0)))
3342 (substring newsgroup 1))))
3344 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3345 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3346 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3347 Otherwise, it is like ~/News/news/group/num."
3350 (concat (if (gnus-use-long-file-name 'not-save)
3351 (gnus-capitalize-newsgroup newsgroup)
3352 (gnus-newsgroup-directory-form newsgroup))
3353 "/" (int-to-string (mail-header-number headers)))
3354 gnus-article-save-directory)))
3356 (string-equal (file-name-directory default)
3357 (file-name-directory last-file))
3358 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3360 (or last-file default))))
3362 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3363 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3364 If variable `gnus-use-long-file-name' is non-nil, it is
3365 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3368 (concat (if (gnus-use-long-file-name 'not-save)
3370 (gnus-newsgroup-directory-form newsgroup))
3371 "/" (int-to-string (mail-header-number headers)))
3372 gnus-article-save-directory)))
3374 (string-equal (file-name-directory default)
3375 (file-name-directory last-file))
3376 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3378 (or last-file default))))
3380 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3381 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3382 If variable `gnus-use-long-file-name' is non-nil, it is
3383 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3386 (if (gnus-use-long-file-name 'not-save)
3389 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3391 gnus-article-save-directory)))
3393 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3394 "Generate file name from sender."
3395 (let ((from (mail-header-from headers)))
3397 (if (and from (string-match "\\([^ <]+\\)@" from))
3398 (match-string 1 from)
3400 gnus-article-save-directory)))
3402 (defun article-verify-x-pgp-sig ()
3405 (if (gnus-buffer-live-p gnus-original-article-buffer)
3406 (let ((sig (with-current-buffer gnus-original-article-buffer
3407 (gnus-fetch-field "X-PGP-Sig")))
3411 (mml2015-clear-verify-function))
3413 (insert-buffer-substring gnus-original-article-buffer)
3414 (setq items (split-string sig))
3415 (message-narrow-to-head)
3416 (let ((inhibit-point-motion-hooks t)
3417 (case-fold-search t))
3418 ;; Don't verify multiple headers.
3419 (setq headers (mapconcat (lambda (header)
3421 (mail-fetch-field header)
3423 (split-string (nth 1 items) ",") "")))
3424 (delete-region (point-min) (point-max))
3425 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3426 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3431 (if (looking-at "^-")
3434 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3435 (insert "Version: " (car items) "\n\n")
3436 (insert (mapconcat 'identity (cddr items) "\n"))
3437 (insert "\n-----END PGP SIGNATURE-----\n")
3438 (let ((mm-security-handle (list (format "multipart/signed"))))
3439 (mml2015-clean-buffer)
3440 (let ((coding-system-for-write (or gnus-newsgroup-charset
3442 (funcall (mml2015-clear-verify-function)))
3444 (or (mm-handle-multipart-ctl-parameter
3445 mm-security-handle 'gnus-details)
3446 (mm-handle-multipart-ctl-parameter
3447 mm-security-handle 'gnus-info)))))
3449 (let (buffer-read-only bface eface)
3451 (message-narrow-to-head)
3452 (goto-char (point-max))
3454 (setq bface (get-text-property (point-at-bol) 'face)
3455 eface (get-text-property (1- (point-at-eol)) 'face))
3456 (message-remove-header "X-Gnus-PGP-Verify")
3457 (if (re-search-forward "^X-PGP-Sig:" nil t)
3459 (goto-char (point-max)))
3460 (narrow-to-region (point) (point))
3461 (insert "X-Gnus-PGP-Verify: " info "\n")
3462 (goto-char (point-min))
3465 (if (not (looking-at "^[ \t]"))
3469 (goto-char (point-min))
3470 (when (looking-at "\\([^:]+\\): *")
3471 (put-text-property (match-beginning 1) (1+ (match-end 1))
3473 (put-text-property (match-end 0) (point-max)
3474 'face eface)))))))))
3476 (defun article-verify-cancel-lock ()
3477 "Verify Cancel-Lock header."
3479 (if (gnus-buffer-live-p gnus-original-article-buffer)
3480 (canlock-verify gnus-original-article-buffer)))
3487 (setq afunc (car func)
3490 gfunc (intern (format "gnus-%s" func))))
3492 (when (fboundp afunc)
3493 `(lambda (&optional interactive &rest args)
3494 ,(documentation afunc t)
3495 (interactive (list t))
3497 (set-buffer gnus-article-buffer)
3499 (call-interactively ',afunc)
3500 (apply ',afunc args))))))))
3501 '(article-hide-headers
3502 article-verify-x-pgp-sig
3503 article-verify-cancel-lock
3504 article-hide-boring-headers
3505 article-treat-overstrike
3506 article-treat-ansi-sequences
3507 article-fill-long-lines
3508 article-capitalize-sentences
3510 article-remove-leading-whitespace
3511 article-display-x-face
3512 article-display-face
3513 article-de-quoted-unreadable
3514 article-de-base64-unreadable
3517 article-unsplit-urls
3518 article-hide-list-identifiers
3519 article-strip-banner
3522 article-hide-signature
3523 article-strip-headers-in-body
3524 article-remove-trailing-blank-lines
3525 article-strip-leading-blank-lines
3526 article-strip-multiple-blank-lines
3527 article-strip-leading-space
3528 article-strip-trailing-space
3529 article-strip-blank-lines
3530 article-strip-all-blank-lines
3532 article-date-english
3533 article-date-iso8601
3534 article-date-original
3536 article-decode-mime-words
3537 article-decode-charset
3538 article-decode-encoded-words
3542 article-treat-dumbquotes
3543 article-normalize-headers
3544 ;; (article-show-all . gnus-article-show-all-headers)
3548 ;;; Gnus article mode
3551 (put 'gnus-article-mode 'mode-class 'special)
3553 (set-keymap-parent gnus-article-mode-map widget-keymap)
3555 (gnus-define-keys gnus-article-mode-map
3556 " " gnus-article-goto-next-page
3557 "\177" gnus-article-goto-prev-page
3558 [delete] gnus-article-goto-prev-page
3559 [backspace] gnus-article-goto-prev-page
3560 "\C-c^" gnus-article-refer-article
3561 "h" gnus-article-show-summary
3562 "s" gnus-article-show-summary
3563 "\C-c\C-m" gnus-article-mail
3564 "?" gnus-article-describe-briefly
3565 "e" gnus-summary-edit-article
3566 "<" beginning-of-buffer
3568 "\C-c\C-i" gnus-info-find-node
3570 "R" gnus-article-reply-with-original
3571 "F" gnus-article-followup-with-original
3572 "\C-hk" gnus-article-describe-key
3573 "\C-hc" gnus-article-describe-key-briefly
3575 "\C-d" gnus-article-read-summary-keys
3576 "\M-*" gnus-article-read-summary-keys
3577 "\M-#" gnus-article-read-summary-keys
3578 "\M-^" gnus-article-read-summary-keys
3579 "\M-g" gnus-article-read-summary-keys)
3581 (substitute-key-definition
3582 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3584 (defun gnus-article-make-menu-bar ()
3585 (unless (boundp 'gnus-article-commands-menu)
3586 (gnus-summary-make-menu-bar))
3587 (gnus-turn-off-edit-menu 'article)
3588 (unless (boundp 'gnus-article-article-menu)
3590 gnus-article-article-menu gnus-article-mode-map ""
3592 ["Scroll forwards" gnus-article-goto-next-page t]
3593 ["Scroll backwards" gnus-article-goto-prev-page t]
3594 ["Show summary" gnus-article-show-summary t]
3595 ["Fetch Message-ID at point" gnus-article-refer-article t]
3596 ["Mail to address at point" gnus-article-mail t]
3597 ["Send a bug report" gnus-bug t]))
3600 gnus-article-treatment-menu gnus-article-mode-map ""
3601 ;; Fixme: this should use :active (and maybe :visible).
3603 ["Hide headers" gnus-article-hide-headers t]
3604 ["Hide signature" gnus-article-hide-signature t]
3605 ["Hide citation" gnus-article-hide-citation t]
3606 ["Treat overstrike" gnus-article-treat-overstrike t]
3607 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3608 ["Remove carriage return" gnus-article-remove-cr t]
3609 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3610 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3611 ["Remove base64" gnus-article-de-base64-unreadable t]
3612 ["Treat html" gnus-article-wash-html t]
3613 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3614 ["Decode HZ" gnus-article-decode-HZ t]))
3616 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3618 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3620 (gnus-run-hooks 'gnus-article-menu-hook)))
3622 (defun gnus-article-mode ()
3623 "Major mode for displaying an article.
3625 All normal editing commands are switched off.
3627 The following commands are available in addition to all summary mode
3629 \\<gnus-article-mode-map>
3630 \\[gnus-article-next-page]\t Scroll the article one page forwards
3631 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3632 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3633 \\[gnus-article-show-summary]\t Display the summary buffer
3634 \\[gnus-article-mail]\t Send a reply to the address near point
3635 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3636 \\[gnus-info-find-node]\t Go to the Gnus info node"
3638 (gnus-simplify-mode-line)
3639 (setq mode-name "Article")
3640 (setq major-mode 'gnus-article-mode)
3641 (make-local-variable 'minor-mode-alist)
3642 (use-local-map gnus-article-mode-map)
3643 (when (gnus-visual-p 'article-menu 'menu)
3644 (gnus-article-make-menu-bar)
3645 (when gnus-summary-tool-bar-map
3646 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3647 (gnus-update-format-specifications nil 'article-mode)
3648 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3649 (set (make-local-variable 'gnus-page-broken) nil)
3650 (make-local-variable 'gnus-button-marker-list)
3651 (make-local-variable 'gnus-article-current-summary)
3652 (make-local-variable 'gnus-article-mime-handles)
3653 (make-local-variable 'gnus-article-decoded-p)
3654 (make-local-variable 'gnus-article-mime-handle-alist)
3655 (make-local-variable 'gnus-article-wash-types)
3656 (make-local-variable 'gnus-article-image-alist)
3657 (make-local-variable 'gnus-article-charset)
3658 (make-local-variable 'gnus-article-ignored-charsets)
3659 (gnus-set-default-directory)
3660 (buffer-disable-undo)
3661 (setq buffer-read-only t
3662 show-trailing-whitespace nil)
3663 (set-syntax-table gnus-article-mode-syntax-table)
3664 (mm-enable-multibyte)
3665 (gnus-run-hooks 'gnus-article-mode-hook))
3667 (defun gnus-article-setup-buffer ()
3668 "Initialize the article buffer."
3669 (let* ((name (if gnus-single-article-buffer "*Article*"
3670 (concat "*Article " gnus-newsgroup-name "*")))
3672 (progn (string-match "\\*Article" name)
3673 (concat " *Original Article"
3674 (substring name (match-end 0))))))
3675 (setq gnus-article-buffer name)
3676 (setq gnus-original-article-buffer original)
3677 (setq gnus-article-mime-handle-alist nil)
3678 ;; This might be a variable local to the summary buffer.
3679 (unless gnus-single-article-buffer
3681 (set-buffer gnus-summary-buffer)
3682 (setq gnus-article-buffer name)
3683 (setq gnus-original-article-buffer original)
3684 (gnus-set-global-variables)))
3685 (gnus-article-setup-highlight-words)
3686 ;; Init original article buffer.
3688 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3689 (mm-enable-multibyte)
3690 (setq major-mode 'gnus-original-article-mode)
3691 (make-local-variable 'gnus-original-article))
3692 (if (get-buffer name)
3695 (when (and gnus-article-edit-mode
3698 (y-or-n-p "Article mode edit in progress; discard? ")))
3699 (error "Action aborted"))
3700 (set (make-local-variable 'gnus-article-edit-mode) nil)
3701 (when gnus-article-mime-handles
3702 (mm-destroy-parts gnus-article-mime-handles)
3703 (setq gnus-article-mime-handles nil))
3704 ;; Set it to nil in article-buffer!
3705 (setq gnus-article-mime-handle-alist nil)
3706 (buffer-disable-undo)
3707 (setq buffer-read-only t)
3708 ;; This list just keeps growing if we don't reset it.
3709 (setq gnus-button-marker-list nil)
3710 (unless (eq major-mode 'gnus-article-mode)
3711 (gnus-article-mode))
3714 (set-buffer (gnus-get-buffer-create name))
3716 (make-local-variable 'gnus-summary-buffer)
3717 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3718 (current-buffer)))))
3720 ;; Set article window start at LINE, where LINE is the number of lines
3721 ;; from the head of the article.
3722 (defun gnus-article-set-window-start (&optional line)
3724 (gnus-get-buffer-window gnus-article-buffer t)
3726 (set-buffer gnus-article-buffer)
3727 (goto-char (point-min))
3730 (gnus-message 6 "Moved to bookmark")
3731 (search-forward "\n\n" nil t)
3735 (defun gnus-article-prepare (article &optional all-headers header)
3736 "Prepare ARTICLE in article mode buffer.
3737 ARTICLE should either be an article number or a Message-ID.
3738 If ARTICLE is an id, HEADER should be the article headers.
3739 If ALL-HEADERS is non-nil, no headers are hidden."
3741 ;; Make sure we start in a summary buffer.
3742 (unless (eq major-mode 'gnus-summary-mode)
3743 (set-buffer gnus-summary-buffer))
3744 (setq gnus-summary-buffer (current-buffer))
3745 (let* ((gnus-article (if header (mail-header-number header) article))
3746 (summary-buffer (current-buffer))
3747 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3748 (group gnus-newsgroup-name)
3751 (gnus-article-setup-buffer)
3752 (set-buffer gnus-article-buffer)
3753 ;; Deactivate active regions.
3754 (when (and (boundp 'transient-mark-mode)
3755 transient-mark-mode)
3756 (setq mark-active nil))
3757 (if (not (setq result (let ((buffer-read-only nil))
3758 (gnus-request-article-this-buffer
3760 ;; There is no such article.
3762 (when (and (numberp article)
3763 (not (memq article gnus-newsgroup-sparse)))
3764 (setq gnus-article-current
3765 (cons gnus-newsgroup-name article))
3766 (set-buffer gnus-summary-buffer)
3767 (setq gnus-current-article article)
3768 (if (and (memq article gnus-newsgroup-undownloaded)
3769 (not (gnus-online (gnus-find-method-for-group
3770 gnus-newsgroup-name))))
3772 (gnus-summary-set-agent-mark article)
3773 (message "Message marked for downloading"))
3774 (gnus-summary-mark-article article gnus-canceled-mark)
3775 (unless (memq article gnus-newsgroup-sparse)
3776 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3777 (if (or (eq result 'pseudo)
3778 (eq result 'nneething))
3781 (set-buffer summary-buffer)
3782 (push article gnus-newsgroup-history)
3783 (setq gnus-last-article gnus-current-article
3784 gnus-current-article 0
3785 gnus-current-headers nil
3786 gnus-article-current nil)
3787 (if (eq result 'nneething)
3788 (gnus-configure-windows 'summary)
3789 (gnus-configure-windows 'article))
3790 (gnus-set-global-variables))
3791 (let ((gnus-article-mime-handle-alist-1
3792 gnus-article-mime-handle-alist))
3793 (gnus-set-mode-line 'article)))
3794 ;; The result from the `request' was an actual article -
3795 ;; or at least some text that is now displayed in the
3797 (when (and (numberp article)
3798 (not (eq article gnus-current-article)))
3799 ;; Seems like a new article has been selected.
3800 ;; `gnus-current-article' must be an article number.
3802 (set-buffer summary-buffer)
3803 (push article gnus-newsgroup-history)
3804 (setq gnus-last-article gnus-current-article
3805 gnus-current-article article
3806 gnus-current-headers
3807 (gnus-summary-article-header gnus-current-article)
3808 gnus-article-current
3809 (cons gnus-newsgroup-name gnus-current-article))
3810 (unless (vectorp gnus-current-headers)
3811 (setq gnus-current-headers nil))
3812 (gnus-summary-goto-subject gnus-current-article)
3813 (when (gnus-summary-show-thread)
3814 ;; If the summary buffer really was folded, the
3815 ;; previous goto may not actually have gone to
3816 ;; the right article, but the thread root instead.
3818 (gnus-summary-goto-subject gnus-current-article))
3819 (gnus-run-hooks 'gnus-mark-article-hook)
3820 (gnus-set-mode-line 'summary)
3821 (when (gnus-visual-p 'article-highlight 'highlight)
3822 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3823 ;; Set the global newsgroup variables here.
3824 (gnus-set-global-variables)
3825 (setq gnus-have-all-headers
3826 (or all-headers gnus-show-all-headers))))
3828 (gnus-configure-windows 'article))
3829 (when (or (numberp article)
3831 (gnus-article-prepare-display)
3833 (goto-char (point-min))
3834 (when gnus-break-pages
3835 (gnus-narrow-to-page)))
3836 (let ((gnus-article-mime-handle-alist-1
3837 gnus-article-mime-handle-alist))
3838 (gnus-set-mode-line 'article))
3842 (set-window-point (get-buffer-window (current-buffer)) (point))
3843 (gnus-configure-windows 'article)
3847 (defun gnus-article-prepare-display ()
3848 "Make the current buffer look like a nice article."
3849 ;; Hooks for getting information from the article.
3850 ;; This hook must be called before being narrowed.
3851 (let ((gnus-article-buffer (current-buffer))
3853 (unless (eq major-mode 'gnus-article-mode)
3854 (gnus-article-mode))
3855 (setq buffer-read-only nil
3856 gnus-article-wash-types nil
3857 gnus-article-image-alist nil)
3858 (gnus-run-hooks 'gnus-tmp-internal-hook)
3859 (when gnus-display-mime-function
3860 (funcall gnus-display-mime-function))
3861 (gnus-run-hooks 'gnus-article-prepare-hook)))
3864 ;;; Gnus MIME viewing functions
3867 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3868 "Format of the MIME buttons.
3870 Valid specifiers include:
3872 %T MIME type, along with additional info
3873 %n The `name' parameter
3874 %d The description, if any
3875 %l The length of the encoded part
3876 %p The part identifier number
3877 %e Dots if the part isn't displayed
3879 General format specifiers can also be used. See Info node
3880 `(gnus)Formatting Variables'.")
3882 (defvar gnus-mime-button-line-format-alist
3883 '((?t gnus-tmp-type ?s)
3884 (?T gnus-tmp-type-long ?s)
3885 (?n gnus-tmp-name ?s)
3886 (?d gnus-tmp-description ?s)
3888 (?l gnus-tmp-length ?d)
3889 (?e gnus-tmp-dots ?s)))
3891 (defvar gnus-mime-button-commands
3892 '((gnus-article-press-button "\r" "Toggle Display")
3893 (gnus-mime-view-part "v" "View Interactively...")
3894 (gnus-mime-view-part-as-type "t" "View As Type...")
3895 (gnus-mime-view-part-as-charset "C" "View As charset...")
3896 (gnus-mime-save-part "o" "Save...")
3897 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3898 (gnus-mime-delete-part "d" "Delete part")
3899 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3900 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3901 (gnus-mime-view-part-internally "E" "View Internally")
3902 (gnus-mime-view-part-externally "e" "View Externally")
3903 (gnus-mime-print-part "p" "Print")
3904 (gnus-mime-pipe-part "|" "Pipe To Command...")
3905 (gnus-mime-action-on-part "." "Take action on the part...")))
3907 (defun gnus-article-mime-part-status ()
3908 (if gnus-article-mime-handle-alist-1
3909 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3911 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3914 (defvar gnus-mime-button-map
3915 (let ((map (make-sparse-keymap)))
3916 (define-key map gnus-mouse-2 'gnus-article-push-button)
3917 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3918 (dolist (c gnus-mime-button-commands)
3919 (define-key map (cadr c) (car c)))
3923 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3925 ,@(mapcar (lambda (c)
3926 (vector (caddr c) (car c) :enable t))
3927 gnus-mime-button-commands)))
3929 (defun gnus-mime-button-menu (event prefix)
3930 "Construct a context-sensitive menu of MIME commands."
3931 (interactive "e\nP")
3932 (save-window-excursion
3933 (let ((pos (event-start event)))
3934 (select-window (posn-window pos))
3935 (goto-char (posn-point pos))
3936 (gnus-article-check-buffer)
3937 (popup-menu gnus-mime-button-menu nil prefix))))
3939 (defun gnus-mime-view-all-parts (&optional handles)
3940 "View all the MIME parts."
3942 (with-current-buffer gnus-article-buffer
3943 (let ((handles (or handles gnus-article-mime-handles))
3944 (mail-parse-charset gnus-newsgroup-charset)
3945 (mail-parse-ignored-charsets
3946 (with-current-buffer gnus-summary-buffer
3947 gnus-newsgroup-ignored-charsets)))
3949 (mm-remove-parts handles)
3950 (goto-char (point-min))
3951 (or (search-forward "\n\n") (goto-char (point-max)))
3952 (let (buffer-read-only)
3953 (delete-region (point) (point-max))
3954 (mm-display-parts handles))))))
3957 (defsubst gnus-article-edit-part (handles)
3958 "Edit an article in order to delete a mime part.
3959 This function is exclusively used by `gnus-mime-save-part-and-strip'
3960 and `gnus-mime-delete-part', and not provided at run-time normally."
3961 (gnus-article-edit-article
3964 (let ((mail-parse-charset (or gnus-article-charset
3965 ',gnus-newsgroup-charset))
3966 (mail-parse-ignored-charsets
3967 (or gnus-article-ignored-charsets
3968 ',gnus-newsgroup-ignored-charsets))
3969 (mbl mml-buffer-list))
3970 (setq mml-buffer-list nil)
3971 (insert-buffer gnus-original-article-buffer)
3972 (mime-to-mml ',handles)
3973 (setq gnus-article-mime-handles nil)
3974 (let ((mbl1 mml-buffer-list))
3975 (setq mml-buffer-list mbl)
3976 (set (make-local-variable 'mml-buffer-list) mbl1))
3977 (gnus-make-local-hook 'kill-buffer-hook)
3978 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3979 `(lambda (no-highlight)
3980 (let ((mail-parse-charset (or gnus-article-charset
3981 ',gnus-newsgroup-charset))
3982 (message-options message-options)
3983 (message-options-set-recipient)
3984 (mail-parse-ignored-charsets
3985 (or gnus-article-ignored-charsets
3986 ',gnus-newsgroup-ignored-charsets)))
3988 (mml-destroy-buffers)
3989 (remove-hook 'kill-buffer-hook
3990 'mml-destroy-buffers t)
3991 (kill-local-variable 'mml-buffer-list))
3992 (gnus-summary-edit-article-done
3993 ,(or (mail-header-references gnus-current-headers) "")
3994 ,(gnus-group-read-only-p)
3995 ,gnus-summary-buffer no-highlight)))
3996 (gnus-article-edit-done)
3997 (gnus-summary-expand-window)
3998 (gnus-summary-show-article)))
4000 (defun gnus-mime-save-part-and-strip ()
4001 "Save the MIME part under point then replace it with an external body."
4003 (gnus-article-check-buffer)
4004 (when (gnus-group-read-only-p)
4005 (error "The current group does not support deleting of parts"))
4006 (when (mm-complicated-handles gnus-article-mime-handles)
4008 The current article has a complicated MIME structure, giving up..."))
4009 (when (gnus-yes-or-no-p "\
4010 Deleting parts may malfunction or destroy the article; continue? ")
4011 (let* ((data (get-text-property (point) 'gnus-data))
4013 (handles gnus-article-mime-handles))
4014 (setq file (and data (mm-save-part data)))
4016 (with-current-buffer (mm-handle-buffer data)
4018 (insert "Content-Type: " (mm-handle-media-type data))
4019 (mml-insert-parameter-string (cdr (mm-handle-type data))
4022 (insert "Content-ID: " (message-make-message-id) "\n")
4023 (insert "Content-Transfer-Encoding: binary\n")
4026 (cdr (mm-make-handle nil
4027 `("message/external-body"
4028 (access-type . "LOCAL-FILE")
4030 (set-buffer gnus-summary-buffer)
4031 (gnus-article-edit-part handles)))))
4033 (defun gnus-mime-delete-part ()
4034 "Delete the MIME part under point.
4035 Replace it with some information about the removed part."
4037 (gnus-article-check-buffer)
4038 (when (gnus-group-read-only-p)
4039 (error "The current group does not support deleting of parts"))
4040 (when (mm-complicated-handles gnus-article-mime-handles)
4042 The current article has a complicated MIME structure, giving up..."))
4043 (when (gnus-yes-or-no-p "\
4044 Deleting parts may malfunction or destroy the article; continue? ")
4045 (let* ((data (get-text-property (point) 'gnus-data))
4046 (handles gnus-article-mime-handles)
4050 (mail-decode-encoded-word-string (or (mm-handle-description data)
4053 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4055 (type (mm-handle-media-type data)))
4057 (error "No MIME part under point"))
4058 (with-current-buffer (mm-handle-buffer data)
4059 (let ((bsize (format "%s" (buffer-size))))
4064 "| The following attachment has been deleted:\n"
4066 "| Type: " type "\n"
4067 "| Filename: " filename "\n"
4068 "| Size (encoded): " bsize " Byte\n"
4069 "| Description: " description "\n"
4072 (cdr (mm-make-handle
4073 nil `("text/plain") nil nil
4075 (format "Deleted attachment (%s bytes)" bsize))))))
4076 (set-buffer gnus-summary-buffer)
4077 (gnus-article-edit-part handles))))
4079 (defun gnus-mime-save-part ()
4080 "Save the MIME part under point."
4082 (gnus-article-check-buffer)
4083 (let ((data (get-text-property (point) 'gnus-data)))
4085 (mm-save-part data))))
4087 (defun gnus-mime-pipe-part ()
4088 "Pipe the MIME part under point to a process."
4090 (gnus-article-check-buffer)
4091 (let ((data (get-text-property (point) 'gnus-data)))
4093 (mm-pipe-part data))))
4095 (defun gnus-mime-view-part ()
4096 "Interactively choose a viewing method for the MIME part under point."
4098 (gnus-article-check-buffer)
4099 (let ((data (get-text-property (point) 'gnus-data)))
4101 (setq gnus-article-mime-handles
4103 gnus-article-mime-handles (setq data (copy-sequence data))))
4104 (mm-interactively-view-part data))))
4106 (defun gnus-mime-view-part-as-type-internal ()
4107 (gnus-article-check-buffer)
4108 (let* ((name (mail-content-type-get
4109 (mm-handle-type (get-text-property (point) 'gnus-data))
4111 (def-type (and name (mm-default-file-encoding name))))
4112 (and def-type (cons def-type 0))))
4114 (defun gnus-mime-view-part-as-type (&optional mime-type)
4115 "Choose a MIME media type, and view the part as such."
4118 (setq mime-type (completing-read
4119 "View as MIME type: "
4120 (mapcar #'list (mailcap-mime-types))
4122 (gnus-mime-view-part-as-type-internal))))
4123 (gnus-article-check-buffer)
4124 (let ((handle (get-text-property (point) 'gnus-data)))
4127 (mm-make-handle (mm-handle-buffer handle)
4128 (cons mime-type (cdr (mm-handle-type handle)))
4129 (mm-handle-encoding handle)
4130 (mm-handle-undisplayer handle)
4131 (mm-handle-disposition handle)
4132 (mm-handle-description handle)
4134 (mm-handle-id handle)))
4135 (setq gnus-article-mime-handles
4136 (mm-merge-handles gnus-article-mime-handles handle))
4137 (gnus-mm-display-part handle))))
4140 (require 'jka-compr))
4142 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4143 ;; emacs can do that itself.
4145 (defun gnus-mime-jka-compr-maybe-uncompress ()
4146 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4147 The uncompress method used is derived from `buffer-file-name'."
4148 (when (and (fboundp 'jka-compr-installed-p)
4149 (jka-compr-installed-p))
4150 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4152 (let ((basename (file-name-nondirectory buffer-file-name))
4153 (args (jka-compr-info-uncompress-args info))
4154 (prog (jka-compr-info-uncompress-program info))
4155 (message (jka-compr-info-uncompress-message info))
4156 (err-file (jka-compr-make-temp-name)))
4158 (message "%s %s..." message basename))
4160 (unless (memq (apply 'call-process-region
4161 (point-min) (point-max)
4163 t (list t err-file) nil
4165 jka-compr-acceptable-retval-list)
4166 (jka-compr-error prog args basename message err-file))
4167 (jka-compr-delete-temp-file err-file)))))))
4169 (defun gnus-mime-copy-part (&optional handle)
4170 "Put the MIME part under point into a new buffer.
4171 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4174 (gnus-article-check-buffer)
4175 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4176 (contents (and handle (mm-get-part handle)))
4178 (file-name-nondirectory
4180 (mail-content-type-get (mm-handle-type handle) 'name)
4181 (mail-content-type-get (mm-handle-disposition handle)
4184 (buffer (and base (generate-new-buffer base))))
4186 (switch-to-buffer buffer)
4188 ;; We do it this way to make `normal-mode' set the appropriate mode.
4191 (setq buffer-file-name (expand-file-name base))
4192 (gnus-mime-jka-compr-maybe-uncompress)
4194 (setq buffer-file-name nil))
4195 (goto-char (point-min)))))
4197 (defun gnus-mime-print-part (&optional handle filename)
4198 "Print the MIME part under point."
4199 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4200 (gnus-article-check-buffer)
4201 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4202 (contents (and handle (mm-get-part handle)))
4203 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4204 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4209 (mm-save-part-to-file handle file)
4210 (call-process shell-file-name nil
4211 (generate-new-buffer " *mm*")
4213 shell-command-switch
4215 printer file (mm-handle-type handle))))
4219 (gnus-print-buffer))
4220 (ps-despool filename)))))
4222 (defun gnus-mime-inline-part (&optional handle arg)
4223 "Insert the MIME part under point into the current buffer."
4224 (interactive (list nil current-prefix-arg))
4225 (gnus-article-check-buffer)
4226 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4231 (if (and (not arg) (mm-handle-undisplayer handle))
4232 (mm-remove-part handle)
4233 (setq contents (mm-get-part handle))
4236 (setq charset (or (mail-content-type-get
4237 (mm-handle-type handle) 'charset)
4238 gnus-newsgroup-charset)))
4240 (if (mm-handle-undisplayer handle)
4241 (mm-remove-part handle))
4244 gnus-summary-show-article-charset-alist))
4245 (mm-read-coding-system "Charset: ")))))
4247 (mm-insert-inline handle
4249 (setq charset (mm-charset-to-coding-system
4251 (not (eq charset 'ascii)))
4252 (mm-decode-coding-string contents charset)
4256 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4257 "Insert the MIME part under point into the current buffer using the
4259 (interactive (list nil current-prefix-arg))
4260 (gnus-article-check-buffer)
4261 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4266 (if (mm-handle-undisplayer handle)
4267 (mm-remove-part handle))
4268 (let ((gnus-newsgroup-charset
4270 gnus-summary-show-article-charset-alist))
4271 (mm-read-coding-system "Charset: ")))
4272 (gnus-newsgroup-ignored-charsets 'gnus-all))
4273 (gnus-article-press-button)))))
4275 (defun gnus-mime-view-part-externally (&optional handle)
4276 "View the MIME part under point with an external viewer."
4278 (gnus-article-check-buffer)
4279 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4280 (mm-user-display-methods nil)
4281 (mm-inlined-types nil)
4282 (mail-parse-charset gnus-newsgroup-charset)
4283 (mail-parse-ignored-charsets
4284 (with-current-buffer gnus-summary-buffer
4285 gnus-newsgroup-ignored-charsets)))
4287 (if (mm-handle-undisplayer handle)
4288 (mm-remove-part handle)
4289 (mm-display-part handle)))))
4291 (defun gnus-mime-view-part-internally (&optional handle)
4292 "View the MIME part under point with an internal viewer.
4293 If no internal viewer is available, use an external viewer."
4295 (gnus-article-check-buffer)
4296 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4297 (mm-inlined-types '(".*"))
4298 (mm-inline-large-images t)
4299 (mail-parse-charset gnus-newsgroup-charset)
4300 (mail-parse-ignored-charsets
4301 (with-current-buffer gnus-summary-buffer
4302 gnus-newsgroup-ignored-charsets))
4305 (if (mm-handle-undisplayer handle)
4306 (mm-remove-part handle)
4307 (mm-display-part handle)))))
4309 (defun gnus-mime-action-on-part (&optional action)
4310 "Do something with the MIME attachment at \(point\)."
4312 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4313 (gnus-article-check-buffer)
4314 (let ((action-pair (assoc action gnus-mime-action-alist)))
4316 (funcall (cdr action-pair)))))
4318 (defun gnus-article-part-wrapper (n function)
4319 (with-current-buffer gnus-article-buffer
4320 (when (> n (length gnus-article-mime-handle-alist))
4321 (error "No such part"))
4322 (gnus-article-goto-part n)
4323 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4324 (funcall function handle))))
4326 (defun gnus-article-pipe-part (n)
4327 "Pipe MIME part N, which is the numerical prefix."
4329 (gnus-article-part-wrapper n 'mm-pipe-part))
4331 (defun gnus-article-save-part (n)
4332 "Save MIME part N, which is the numerical prefix."
4334 (gnus-article-part-wrapper n 'mm-save-part))
4336 (defun gnus-article-interactively-view-part (n)
4337 "View MIME part N interactively, which is the numerical prefix."
4339 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4341 (defun gnus-article-copy-part (n)
4342 "Copy MIME part N, which is the numerical prefix."
4344 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4346 (defun gnus-article-view-part-as-charset (n)
4347 "View MIME part N using a specified charset.
4348 N is the numerical prefix."
4350 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4352 (defun gnus-article-view-part-externally (n)
4353 "View MIME part N externally, which is the numerical prefix."
4355 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4357 (defun gnus-article-inline-part (n)
4358 "Inline MIME part N, which is the numerical prefix."
4360 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4362 (defun gnus-article-mime-match-handle-first (condition)
4364 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4365 (while (setq ihandle (pop alist))
4367 ((functionp condition)
4368 (funcall condition (cdr ihandle)))
4369 ((eq condition 'undisplayed)
4370 (not (or (mm-handle-undisplayer (cdr ihandle))
4371 (equal (mm-handle-media-type (cdr ihandle))
4372 "multipart/alternative"))))
4373 ((eq condition 'undisplayed-alternative)
4374 (not (mm-handle-undisplayer (cdr ihandle))))
4376 (gnus-article-goto-part (car ihandle))
4377 (or (not n) (< (car ihandle) n)))
4378 (setq n (car ihandle))))
4382 (defun gnus-article-view-part (&optional n)
4383 "View MIME part N, which is the numerical prefix."
4385 (with-current-buffer gnus-article-buffer
4386 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4387 gnus-article-mime-match-handle-function)))
4388 (when (> n (length gnus-article-mime-handle-alist))
4389 (error "No such part"))
4390 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4391 (when (gnus-article-goto-part n)
4392 (if (equal (car handle) "multipart/alternative")
4393 (gnus-article-press-button)
4394 (when (eq (gnus-mm-display-part handle) 'internal)
4395 (gnus-set-window-start)))))))
4397 (defsubst gnus-article-mime-total-parts ()
4398 (if (bufferp (car gnus-article-mime-handles))
4400 (1- (length gnus-article-mime-handles))))
4402 (defun gnus-mm-display-part (handle)
4403 "Display HANDLE and fix MIME button."
4404 (let ((id (get-text-property (point) 'gnus-part))
4409 (let ((window (selected-window))
4410 (mail-parse-charset gnus-newsgroup-charset)
4411 (mail-parse-ignored-charsets
4412 (if (gnus-buffer-live-p gnus-summary-buffer)
4413 (with-current-buffer gnus-summary-buffer
4414 gnus-newsgroup-ignored-charsets)
4418 (let ((win (gnus-get-buffer-window (current-buffer) t))
4421 (select-window win))
4424 (if (mm-handle-displayed-p handle)
4425 ;; This will remove the part.
4426 (mm-display-part handle)
4428 (narrow-to-region (point)
4429 (if (eobp) (point) (1+ (point))))
4430 (mm-display-part handle)
4431 ;; We narrow to the part itself and
4432 ;; then call the treatment functions.
4433 (goto-char (point-min))
4435 (narrow-to-region (point) (point-max))
4438 (gnus-article-mime-total-parts)
4439 (mm-handle-media-type handle)))))
4440 (if (window-live-p window)
4441 (select-window window)))))
4444 (gnus-insert-mime-button
4445 handle id (list (mm-handle-displayed-p handle)))
4446 (goto-char point))))
4448 (defun gnus-article-goto-part (n)
4449 "Go to MIME part N."
4450 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4452 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4453 (let ((gnus-tmp-name
4454 (or (mail-content-type-get (mm-handle-type handle) 'name)
4455 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4456 (mail-content-type-get (mm-handle-type handle) 'url)
4458 (gnus-tmp-type (mm-handle-media-type handle))
4459 (gnus-tmp-description
4460 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4463 (if (if displayed (car displayed)
4464 (mm-handle-displayed-p handle))
4466 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4468 gnus-tmp-type-long b e)
4469 (when (string-match ".*/" gnus-tmp-name)
4470 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4471 (setq gnus-tmp-type-long (concat gnus-tmp-type
4472 (and (not (equal gnus-tmp-name ""))
4473 (concat "; " gnus-tmp-name))))
4474 (unless (equal gnus-tmp-description "")
4475 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4480 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4481 `(keymap ,gnus-mime-button-map
4482 gnus-callback gnus-mm-display-part
4483 gnus-part ,gnus-tmp-id
4484 article-type annotation
4487 ;; Exclude a newline.
4490 (widget-convert-button
4493 :action 'gnus-widget-press-button
4494 :button-keymap gnus-mime-button-map
4496 (lambda (widget/window &optional overlay pos)
4497 ;; Needed to properly clear the message due to a bug in
4498 ;; wid-edit (XEmacs only).
4499 (if (boundp 'help-echo-owns-message)
4500 (setq help-echo-owns-message t))
4502 "%S: %s the MIME part; %S: more options"
4503 (aref gnus-mouse-2 0)
4504 ;; XEmacs will get a single widget arg; Emacs 21 will get
4505 ;; window, overlay, position.
4506 (if (mm-handle-displayed-p
4508 (with-current-buffer (gnus-overlay-buffer overlay)
4509 (widget-get (widget-at (gnus-overlay-start overlay))
4511 (widget-get widget/window :mime-handle)))
4513 (aref gnus-down-mouse-3 0))))))
4515 (defun gnus-widget-press-button (elems el)
4516 (goto-char (widget-get elems :from))
4517 (gnus-article-press-button))
4519 (defvar gnus-displaying-mime nil)
4521 (defun gnus-display-mime (&optional ihandles)
4522 "Display the MIME parts."
4524 (save-selected-window
4525 (let ((window (get-buffer-window gnus-article-buffer))
4528 (select-window window)
4529 ;; We have to do this since selecting the window
4530 ;; may change the point. So we set the window point.
4531 (set-window-point window point)))
4532 (let* ((handles (or ihandles
4533 (mm-dissect-buffer nil gnus-article-loose-mime)
4534 (and gnus-article-emulate-mime
4536 buffer-read-only handle name type b e display)
4537 (when (and (not ihandles)
4538 (not gnus-displaying-mime))
4539 ;; Top-level call; we clean up.
4540 (when gnus-article-mime-handles
4541 (mm-destroy-parts gnus-article-mime-handles)
4542 (setq gnus-article-mime-handle-alist nil));; A trick.
4543 (setq gnus-article-mime-handles handles)
4544 ;; We allow users to glean info from the handles.
4545 (when gnus-article-mime-part-function
4546 (gnus-mime-part-function handles)))
4548 (or (not (stringp (car handles)))
4551 (when (and (not ihandles)
4552 (not gnus-displaying-mime))
4553 ;; Clean up for mime parts.
4555 (delete-region (point) (point-max)))
4556 (let ((gnus-displaying-mime t))
4557 (gnus-mime-display-part handles)))
4560 (narrow-to-region (point) (point-max))
4561 (gnus-treat-article nil 1 1)
4564 ;; Highlight the headers.
4568 (narrow-to-region (point-min) (point))
4569 (gnus-treat-article 'head))))))))
4571 (defcustom gnus-mime-display-multipart-as-mixed nil
4572 "Display \"multipart\" parts as \"multipart/mixed\".
4574 If t, it overrides nil values of
4575 `gnus-mime-display-multipart-alternative-as-mixed' and
4576 `gnus-mime-display-multipart-related-as-mixed'."
4577 :group 'gnus-article-mime
4580 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4581 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4582 :group 'gnus-article-mime
4585 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4586 "Display \"multipart/related\" parts as \"multipart/mixed\".
4588 If displaying \"text/html\" is discouraged \(see
4589 `mm-discouraged-alternatives'\) images or other material inside a
4590 \"multipart/related\" part might be overlooked when this variable is nil."
4591 :group 'gnus-article-mime
4594 (defun gnus-mime-display-part (handle)
4597 ((not (stringp (car handle)))
4598 (gnus-mime-display-single handle))
4599 ;; User-defined multipart
4600 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4601 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4603 ;; multipart/alternative
4604 ((and (equal (car handle) "multipart/alternative")
4605 (not (or gnus-mime-display-multipart-as-mixed
4606 gnus-mime-display-multipart-alternative-as-mixed)))
4607 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4608 (push (cons id handle) gnus-article-mime-handle-alist)
4609 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4610 ;; multipart/related
4611 ((and (equal (car handle) "multipart/related")
4612 (not (or gnus-mime-display-multipart-as-mixed
4613 gnus-mime-display-multipart-related-as-mixed)))
4614 ;;;!!!We should find the start part, but we just default
4615 ;;;!!!to the first part.
4616 ;;(gnus-mime-display-part (cadr handle))
4617 ;;;!!! Most multipart/related is an HTML message plus images.
4618 ;;;!!! Unfortunately we are unable to let W3 display those
4619 ;;;!!! included images, so we just display it as a mixed multipart.
4620 ;;(gnus-mime-display-mixed (cdr handle))
4621 ;;;!!! No, w3 can display everything just fine.
4622 (gnus-mime-display-part (cadr handle)))
4623 ((equal (car handle) "multipart/signed")
4624 (gnus-add-wash-type 'signed)
4625 (gnus-mime-display-security handle))
4626 ((equal (car handle) "multipart/encrypted")
4627 (gnus-add-wash-type 'encrypted)
4628 (gnus-mime-display-security handle))
4629 ;; Other multiparts are handled like multipart/mixed.
4631 (gnus-mime-display-mixed (cdr handle)))))
4633 (defun gnus-mime-part-function (handles)
4634 (if (stringp (car handles))
4635 (mapcar 'gnus-mime-part-function (cdr handles))
4636 (funcall gnus-article-mime-part-function handles)))
4638 (defun gnus-mime-display-mixed (handles)
4639 (mapcar 'gnus-mime-display-part handles))
4641 (defun gnus-mime-display-single (handle)
4642 (let ((type (mm-handle-media-type handle))
4643 (ignored gnus-ignored-mime-types)
4650 (when (string-match (pop ignored) type)
4651 (throw 'ignored nil)))
4652 (if (and (setq not-attachment
4653 (and (not (mm-inline-override-p handle))
4654 (or (not (mm-handle-disposition handle))
4655 (equal (car (mm-handle-disposition handle))
4657 (mm-attachment-override-p handle))))
4658 (mm-automatic-display-p handle)
4660 (mm-inlinable-p handle)
4661 (mm-inlined-p handle))
4662 (mm-automatic-external-display-p type)))
4664 (when (equal (mm-handle-media-supertype handle) "text")
4666 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4668 (push (cons id handle) gnus-article-mime-handle-alist)
4669 (when (or (not display)
4670 (not (gnus-unbuttonized-mime-type-p type)))
4671 (gnus-insert-mime-button
4672 handle id (list (or display (and not-attachment text))))
4673 (gnus-article-insert-newline)
4674 ;; Remember modify the number of forward lines.
4682 (let ((mail-parse-charset gnus-newsgroup-charset)
4683 (mail-parse-ignored-charsets
4684 (save-excursion (condition-case ()
4685 (set-buffer gnus-summary-buffer)
4687 gnus-newsgroup-ignored-charsets)))
4688 (mm-display-part handle t))
4689 (goto-char (point-max)))
4690 ((and text not-attachment)
4694 (gnus-article-insert-newline)
4695 (mm-insert-inline handle (mm-get-part handle))
4696 (goto-char (point-max))))
4700 (narrow-to-region beg (point))
4703 (gnus-article-mime-total-parts)
4704 (mm-handle-media-type handle)))))))))
4706 (defun gnus-unbuttonized-mime-type-p (type)
4707 "Say whether TYPE is to be unbuttonized."
4708 (unless gnus-inhibit-mime-unbuttonizing
4710 (let ((types gnus-unbuttonized-mime-types))
4712 (when (string-match (pop types) type)
4713 (throw 'found t)))))
4715 (let ((types gnus-buttonized-mime-types))
4717 (when (string-match (pop types) type)
4718 (throw 'found t)))))))))
4720 (defun gnus-article-insert-newline ()
4721 "Insert a newline, but mark it as undeletable."
4722 (gnus-put-text-property
4723 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4725 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4726 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4729 handle buffer-read-only from props begend not-pref)
4730 (save-window-excursion
4733 (narrow-to-region (car ibegend)
4736 (goto-char (car ibegend))
4739 (delete-region (point-min) (point-max))
4740 (mm-remove-parts handles))
4741 (setq begend (list (point-marker)))
4743 (unless (setq not-pref (cadr (member preferred ihandles)))
4744 (setq not-pref (car ihandles)))
4747 (not (gnus-unbuttonized-mime-type-p
4748 "multipart/alternative")))
4749 (gnus-add-text-properties
4752 (insert (format "%d. " id))
4756 (unless ,(not ibegend)
4757 (setq gnus-article-mime-handle-alist
4758 ',gnus-article-mime-handle-alist))
4759 (gnus-mime-display-alternative
4760 ',ihandles ',not-pref ',begend ,id))
4761 keymap ,gnus-mime-button-map
4762 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4763 face ,gnus-article-button-face
4766 (widget-convert-button 'link from (point)
4767 :action 'gnus-widget-press-button
4768 :button-keymap gnus-widget-button-keymap)
4770 (while (setq handle (pop handles))
4771 (gnus-add-text-properties
4774 (insert (format "(%c) %-18s"
4775 (if (equal handle preferred) ?* ? )
4776 (mm-handle-media-type handle)))
4780 (unless ,(not ibegend)
4781 (setq gnus-article-mime-handle-alist
4782 ',gnus-article-mime-handle-alist))
4783 (gnus-mime-display-alternative
4784 ',ihandles ',handle ',begend ,id))
4785 keymap ,gnus-mime-button-map
4786 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4787 face ,gnus-article-button-face
4790 (widget-convert-button 'link from (point)
4791 :action 'gnus-widget-press-button
4792 :button-keymap gnus-widget-button-keymap)
4796 (if (stringp (car preferred))
4797 (gnus-display-mime preferred)
4798 (let ((mail-parse-charset gnus-newsgroup-charset)
4799 (mail-parse-ignored-charsets
4800 (with-current-buffer gnus-summary-buffer
4801 gnus-newsgroup-ignored-charsets)))
4802 (mm-display-part preferred)
4806 (narrow-to-region (car begend) (point-max))
4808 nil (length gnus-article-mime-handle-alist)
4809 (gnus-article-mime-total-parts)
4810 (mm-handle-media-type handle))))))
4811 (goto-char (point-max))
4812 (setcdr begend (point-marker)))))
4814 (goto-char point))))
4816 (defconst gnus-article-wash-status-strings
4817 (let ((alist '((cite "c" "Possible hidden citation text"
4818 " " "All citation text visible")
4819 (headers "h" "Hidden headers"
4820 " " "All headers visible.")
4821 (pgp "p" "Encrypted or signed message status hidden"
4822 " " "No hidden encryption nor digital signature status")
4823 (signature "s" "Signature has been hidden"
4824 " " "Signature is visible")
4825 (overstrike "o" "Overstrike (^H) characters applied"
4826 " " "No overstrike characters applied")
4827 (emphasis "e" "/*_Emphasis_*/ characters applied"
4828 " " "No /*_emphasis_*/ characters applied")))
4830 (dolist (entry alist result)
4831 (let ((key (nth 0 entry))
4832 (on (copy-sequence (nth 1 entry)))
4833 (on-help (nth 2 entry))
4834 (off (copy-sequence (nth 3 entry)))
4835 (off-help (nth 4 entry)))
4836 (put-text-property 0 1 'help-echo on-help on)
4837 (put-text-property 0 1 'help-echo off-help off)
4838 (push (list key on off) result))))
4839 "Alist of strings describing wash status in the mode line.
4840 Each entry has the form (KEY ON OF), where the KEY is a symbol
4841 representing the particular washing function, ON is the string to use
4842 in the article mode line when the washing function is active, and OFF
4843 is the string to use when it is inactive.")
4845 (defun gnus-article-wash-status-entry (key value)
4846 (let ((entry (assoc key gnus-article-wash-status-strings)))
4847 (if value (nth 1 entry) (nth 2 entry))))
4849 (defun gnus-article-wash-status ()
4850 "Return a string which display status of article washing."
4851 (with-current-buffer gnus-article-buffer
4852 (let ((cite (memq 'cite gnus-article-wash-types))
4853 (headers (memq 'headers gnus-article-wash-types))
4854 (boring (memq 'boring-headers gnus-article-wash-types))
4855 (pgp (memq 'pgp gnus-article-wash-types))
4856 (pem (memq 'pem gnus-article-wash-types))
4857 (signed (memq 'signed gnus-article-wash-types))
4858 (encrypted (memq 'encrypted gnus-article-wash-types))
4859 (signature (memq 'signature gnus-article-wash-types))
4860 (overstrike (memq 'overstrike gnus-article-wash-types))
4861 (emphasis (memq 'emphasis gnus-article-wash-types)))
4863 (gnus-article-wash-status-entry 'cite cite)
4864 (gnus-article-wash-status-entry 'headers (or headers boring))
4865 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4866 (gnus-article-wash-status-entry 'signature signature)
4867 (gnus-article-wash-status-entry 'overstrike overstrike)
4868 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4870 (defun gnus-add-wash-type (type)
4871 "Add a washing of TYPE to the current status."
4872 (add-to-list 'gnus-article-wash-types type))
4874 (defun gnus-delete-wash-type (type)
4875 "Add a washing of TYPE to the current status."
4876 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4878 (defun gnus-add-image (category image)
4879 "Add IMAGE of CATEGORY to the list of displayed images."
4880 (let ((entry (assq category gnus-article-image-alist)))
4882 (setq entry (list category))
4883 (push entry gnus-article-image-alist))
4884 (nconc entry (list image))))
4886 (defun gnus-delete-images (category)
4887 "Delete all images in CATEGORY."
4888 (let ((entry (assq category gnus-article-image-alist)))
4889 (dolist (image (cdr entry))
4890 (gnus-remove-image image category))
4891 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4892 (gnus-delete-wash-type category)))
4894 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4896 (defun gnus-article-maybe-hide-headers ()
4897 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4898 Provided for backwards compatibility."
4899 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4900 (not (with-current-buffer gnus-summary-buffer
4901 gnus-have-all-headers)))
4902 (not gnus-inhibit-hiding))
4903 (gnus-article-hide-headers)))
4907 (defun gnus-output-to-file (file-name)
4908 "Append the current article to a file named FILE-NAME."
4909 (let ((artbuf (current-buffer)))
4911 (insert-buffer-substring artbuf)
4912 ;; Append newline at end of the buffer as separator, and then
4914 (goto-char (point-max))
4916 (let ((file-name-coding-system nnmail-pathname-coding-system))
4917 (mm-append-to-file (point-min) (point-max) file-name))
4920 (defun gnus-narrow-to-page (&optional arg)
4921 "Narrow the article buffer to a page.
4922 If given a numerical ARG, move forward ARG pages."
4924 (setq arg (if arg (prefix-numeric-value arg) 0))
4926 (set-buffer gnus-article-buffer)
4927 (goto-char (point-min))
4929 ;; Remove any old next/prev buttons.
4930 (when (gnus-visual-p 'page-marker)
4931 (let ((buffer-read-only nil))
4932 (gnus-remove-text-with-property 'gnus-prev)
4933 (gnus-remove-text-with-property 'gnus-next)))
4936 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4938 (re-search-forward page-delimiter nil 'move arg)))
4939 (goto-char (match-end 0))
4941 (goto-char (point-min))
4942 (setq gnus-page-broken
4943 (and (re-search-forward page-delimiter nil t) t))))
4944 (when gnus-page-broken
4947 (if (re-search-forward page-delimiter nil 'move)
4950 (when (and (gnus-visual-p 'page-marker)
4951 (not (= (point-min) 1)))
4953 (goto-char (point-min))
4954 (gnus-insert-prev-page-button)))
4955 (when (and (gnus-visual-p 'page-marker)
4956 (< (+ (point-max) 2) (buffer-size)))
4958 (goto-char (point-max))
4959 (gnus-insert-next-page-button))))))
4961 ;; Article mode commands
4963 (defun gnus-article-goto-next-page ()
4964 "Show the next page of the article."
4966 (when (gnus-article-next-page)
4967 (goto-char (point-min))
4968 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4971 (defun gnus-article-goto-prev-page ()
4972 "Show the previous page of the article."
4975 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4976 (gnus-article-prev-page nil)))
4978 ;; This is cleaner but currently breaks `gnus-pick-mode':
4980 ;; (defun gnus-article-goto-next-page ()
4981 ;; "Show the next page of the article."
4983 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4984 ;; (gnus-summary-next-page)))
4986 ;; (defun gnus-article-goto-prev-page ()
4987 ;; "Show the next page of the article."
4989 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
4990 ;; (gnus-summary-prev-page)))
4992 (defun gnus-article-next-page (&optional lines)
4993 "Show the next page of the current article.
4994 If end of article, return non-nil. Otherwise return nil.
4995 Argument LINES specifies lines to be scrolled up."
4997 (move-to-window-line -1)
5000 (and (pos-visible-in-window-p) ;Not continuation line.
5001 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5002 ;; Nothing in this page.
5003 (if (or (not gnus-page-broken)
5008 (eobp)))) ;Real end-of-buffer?
5010 (when gnus-article-over-scroll
5011 (gnus-article-next-page-1 lines))
5013 (gnus-narrow-to-page 1) ;Go to next page.
5015 ;; More in this page.
5016 (gnus-article-next-page-1 lines)
5019 (defun gnus-article-next-page-1 (lines)
5020 (let ((scroll-in-place nil))
5024 ;; Long lines may cause an end-of-buffer error.
5025 (goto-char (point-max)))))
5026 (move-to-window-line 0))
5028 (defun gnus-article-prev-page (&optional lines)
5029 "Show previous page of current article.
5030 Argument LINES specifies lines to be scrolled down."
5032 (move-to-window-line 0)
5033 (if (and gnus-page-broken
5035 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5037 (gnus-narrow-to-page -1) ;Go to previous page.
5038 (goto-char (point-max))
5040 (let ((scroll-in-place nil))
5044 (beginning-of-buffer
5045 (goto-char (point-min))))
5046 (move-to-window-line 0)))))
5048 (defun gnus-article-only-boring-p ()
5049 "Decide whether there is only boring text remaining in the article.
5050 Something \"interesting\" is a word of at least two letters that does
5051 not have a face in `gnus-article-boring-faces'."
5052 (when (and gnus-article-skip-boring
5053 (boundp 'gnus-article-boring-faces)
5054 (symbol-value 'gnus-article-boring-faces))
5057 (while (re-search-forward "\\b\\w\\w" nil t)
5059 (when (not (gnus-intersection
5060 (gnus-faces-at (point))
5061 (symbol-value 'gnus-article-boring-faces)))
5062 (throw 'only-boring nil)))
5063 (throw 'only-boring t)))))
5065 (defun gnus-article-refer-article ()
5066 "Read article specified by message-id around point."
5069 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5070 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5071 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5072 (let ((msg-id (concat "<" (match-string 0) ">")))
5073 (set-buffer gnus-summary-buffer)
5074 (gnus-summary-refer-article msg-id))
5075 (error "No references around point"))))
5077 (defun gnus-article-show-summary ()
5078 "Reconfigure windows to show summary buffer."
5080 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5081 (error "There is no summary buffer for this article buffer")
5082 (gnus-article-set-globals)
5083 (gnus-configure-windows 'article)
5084 (gnus-summary-goto-subject gnus-current-article)
5085 (gnus-summary-position-point)))
5087 (defun gnus-article-describe-briefly ()
5088 "Describe article mode commands briefly."
5090 (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")))
5092 (defun gnus-article-summary-command ()
5093 "Execute the last keystroke in the summary buffer."
5095 (let ((obuf (current-buffer))
5096 (owin (current-window-configuration))
5098 (switch-to-buffer gnus-article-current-summary 'norecord)
5099 (setq func (lookup-key (current-local-map) (this-command-keys)))
5100 (call-interactively func)
5102 (set-window-configuration owin)
5103 (set-window-point (get-buffer-window (current-buffer)) (point))))
5105 (defun gnus-article-summary-command-nosave ()
5106 "Execute the last keystroke in the summary buffer."
5109 (pop-to-buffer gnus-article-current-summary 'norecord)
5110 (setq func (lookup-key (current-local-map) (this-command-keys)))
5111 (call-interactively func)))
5113 (defun gnus-article-check-buffer ()
5114 "Beep if not in an article buffer."
5115 (unless (equal major-mode 'gnus-article-mode)
5116 (error "Command invoked outside of a Gnus article buffer")))
5118 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5119 "Read a summary buffer key sequence and execute it from the article buffer."
5121 (gnus-article-check-buffer)
5123 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5124 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5125 "=" "^" "\M-^" "|"))
5131 '("n" "Gn" "p" "Gp"))
5134 (set-buffer gnus-article-current-summary)
5135 (let (gnus-pick-mode)
5136 (push (or key last-command-event) unread-command-events)
5137 (setq keys (if (featurep 'xemacs)
5138 (events-to-keys (read-key-sequence nil))
5139 (read-key-sequence nil)))))
5143 (if (or (member keys nosaves)
5144 (member keys nosave-but-article)
5145 (member keys nosave-in-article))
5147 (save-window-excursion
5148 (pop-to-buffer gnus-article-current-summary 'norecord)
5149 ;; We disable the pick minor mode commands.
5150 (let (gnus-pick-mode)
5151 (setq func (lookup-key (current-local-map) keys))))
5155 (unless (member keys nosave-in-article)
5156 (set-buffer gnus-article-current-summary))
5157 (call-interactively func)
5158 (setq new-sum-point (point)))
5159 (when (member keys nosave-but-article)
5160 (pop-to-buffer gnus-article-buffer 'norecord)))
5161 ;; These commands should restore window configuration.
5162 (let ((obuf (current-buffer))
5163 (owin (current-window-configuration))
5165 win func in-buffer selected new-sum-start new-sum-hscroll)
5166 (cond (not-restore-window
5167 (pop-to-buffer gnus-article-current-summary 'norecord))
5168 ((setq win (get-buffer-window gnus-article-current-summary))
5169 (select-window win))
5171 (switch-to-buffer gnus-article-current-summary 'norecord)))
5172 (setq in-buffer (current-buffer))
5173 ;; We disable the pick minor mode commands.
5174 (if (and (setq func (let (gnus-pick-mode)
5175 (lookup-key (current-local-map) keys)))
5178 (call-interactively func)
5179 (when (eq win (selected-window))
5180 (setq new-sum-point (point)
5181 new-sum-start (window-start win)
5182 new-sum-hscroll (window-hscroll win))
5183 (when (eq in-buffer (current-buffer))
5184 (setq selected (gnus-summary-select-article))
5186 (unless not-restore-window
5187 (set-window-configuration owin))
5188 (when (eq selected 'old)
5190 (set-window-start (get-buffer-window (current-buffer))
5192 (set-window-point (get-buffer-window (current-buffer))
5194 (when (and (not not-restore-window)
5196 (set-window-point win new-sum-point)
5197 (set-window-start win new-sum-start)
5198 (set-window-hscroll win new-sum-hscroll)))))
5199 (set-window-configuration owin)
5202 (defun gnus-article-describe-key (key)
5203 "Display documentation of the function invoked by KEY. KEY is a string."
5204 (interactive "kDescribe key: ")
5205 (gnus-article-check-buffer)
5206 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5208 (set-buffer gnus-article-current-summary)
5209 (let (gnus-pick-mode)
5210 (if (featurep 'xemacs)
5212 (push (elt key 0) unread-command-events)
5213 (setq key (events-to-keys
5214 (read-key-sequence "Describe key: "))))
5215 (setq unread-command-events
5217 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5218 (string-to-list key)))
5219 (setq key (read-key-sequence "Describe key: "))))
5221 (describe-key key)))
5223 (defun gnus-article-describe-key-briefly (key &optional insert)
5224 "Display documentation of the function invoked by KEY. KEY is a string."
5225 (interactive "kDescribe key: \nP")
5226 (gnus-article-check-buffer)
5227 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5229 (set-buffer gnus-article-current-summary)
5230 (let (gnus-pick-mode)
5231 (if (featurep 'xemacs)
5233 (push (elt key 0) unread-command-events)
5234 (setq key (events-to-keys
5235 (read-key-sequence "Describe key: "))))
5236 (setq unread-command-events
5238 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5239 (string-to-list key)))
5240 (setq key (read-key-sequence "Describe key: "))))
5241 (describe-key-briefly key insert))
5242 (describe-key-briefly key insert)))
5244 (defun gnus-article-reply-with-original (&optional wide)
5245 "Start composing a reply mail to the current message.
5246 The text in the region will be yanked. If the region isn't active,
5247 the entire article will be yanked."
5249 (let ((article (cdr gnus-article-current))
5251 (if (not (gnus-region-active-p))
5252 (with-current-buffer gnus-summary-buffer
5253 (gnus-summary-reply (list (list article)) wide))
5254 (setq contents (buffer-substring (point) (mark t)))
5255 ;; Deactivate active regions.
5256 (when (and (boundp 'transient-mark-mode)
5257 transient-mark-mode)
5258 (setq mark-active nil))
5259 (with-current-buffer gnus-summary-buffer
5261 (list (list article contents)) wide)))))
5263 (defun gnus-article-followup-with-original ()
5264 "Compose a followup to the current article.
5265 The text in the region will be yanked. If the region isn't active,
5266 the entire article will be yanked."
5268 (let ((article (cdr gnus-article-current))
5270 (if (not (gnus-region-active-p))
5271 (with-current-buffer gnus-summary-buffer
5272 (gnus-summary-followup (list (list article))))
5273 (setq contents (buffer-substring (point) (mark t)))
5274 ;; Deactivate active regions.
5275 (when (and (boundp 'transient-mark-mode)
5276 transient-mark-mode)
5277 (setq mark-active nil))
5278 (with-current-buffer gnus-summary-buffer
5279 (gnus-summary-followup
5280 (list (list article contents)))))))
5282 (defun gnus-article-hide (&optional arg force)
5283 "Hide all the gruft in the current article.
5284 This means that signatures, cited text and (some) headers will be
5286 If given a prefix, show the hidden text instead."
5287 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5288 (gnus-article-hide-headers arg)
5289 (gnus-article-hide-list-identifiers arg)
5290 (gnus-article-hide-citation-maybe arg force)
5291 (gnus-article-hide-signature arg))
5293 (defun gnus-article-maybe-highlight ()
5294 "Do some article highlighting if article highlighting is requested."
5295 (when (gnus-visual-p 'article-highlight 'highlight)
5296 (gnus-article-highlight-some)))
5298 (defun gnus-check-group-server ()
5299 ;; Make sure the connection to the server is alive.
5300 (unless (gnus-server-opened
5301 (gnus-find-method-for-group gnus-newsgroup-name))
5302 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5303 (gnus-request-group gnus-newsgroup-name t)))
5306 (autoload 'nneething-get-file-name "nneething"))
5308 (defun gnus-request-article-this-buffer (article group)
5309 "Get an article and insert it into this buffer."
5310 (let (do-update-line sparse-header)
5314 (gnus-kill-all-overlays)
5315 (setq group (or group gnus-newsgroup-name))
5317 ;; Using `gnus-request-article' directly will insert the article into
5318 ;; `nntp-server-buffer' - so we'll save some time by not having to
5319 ;; copy it from the server buffer into the article buffer.
5321 ;; We only request an article by message-id when we do not have the
5322 ;; headers for it, so we'll have to get those.
5323 (when (stringp article)
5324 (gnus-read-header article))
5326 ;; If the article number is negative, that means that this article
5327 ;; doesn't belong in this newsgroup (possibly), so we find its
5328 ;; message-id and request it by id instead of number.
5329 (when (and (numberp article)
5331 (get-buffer gnus-summary-buffer)
5332 (gnus-buffer-exists-p gnus-summary-buffer))
5334 (set-buffer gnus-summary-buffer)
5335 (let ((header (gnus-summary-article-header article)))
5338 ((memq article gnus-newsgroup-sparse)
5339 ;; This is a sparse gap article.
5340 (setq do-update-line article)
5341 (setq article (mail-header-id header))
5342 (setq sparse-header (gnus-read-header article))
5343 (setq gnus-newsgroup-sparse
5344 (delq article gnus-newsgroup-sparse)))
5346 ;; It's a real article.
5347 (setq article (mail-header-id header)))
5349 ;; It is an extracted pseudo-article.
5350 (setq article 'pseudo)
5351 (gnus-request-pseudo-article header))))
5353 (let ((method (gnus-find-method-for-group
5354 gnus-newsgroup-name)))
5355 (when (and (eq (car method) 'nneething)
5357 (let ((dir (nneething-get-file-name
5358 (mail-header-id header))))
5359 (when (and (stringp dir)
5360 (file-directory-p dir))
5361 (setq article 'nneething)
5362 (gnus-group-enter-directory dir))))))))
5365 ;; Refuse to select canceled articles.
5366 ((and (numberp article)
5368 (get-buffer gnus-summary-buffer)
5369 (gnus-buffer-exists-p gnus-summary-buffer)
5370 (eq (cdr (with-current-buffer gnus-summary-buffer
5371 (assq article gnus-newsgroup-reads)))
5372 gnus-canceled-mark))
5374 ;; We first check `gnus-original-article-buffer'.
5375 ((and (get-buffer gnus-original-article-buffer)
5377 (with-current-buffer gnus-original-article-buffer
5378 (and (equal (car gnus-original-article) group)
5379 (eq (cdr gnus-original-article) article))))
5380 (insert-buffer-substring gnus-original-article-buffer)
5382 ;; Check the backlog.
5383 ((and gnus-keep-backlog
5384 (gnus-backlog-request-article group article (current-buffer)))
5386 ;; Check asynchronous pre-fetch.
5387 ((gnus-async-request-fetched-article group article (current-buffer))
5388 (gnus-async-prefetch-next group article gnus-summary-buffer)
5389 (when (and (numberp article) gnus-keep-backlog)
5390 (gnus-backlog-enter-article group article (current-buffer)))
5393 ((and gnus-use-cache
5395 (gnus-cache-request-article article group))
5397 ;; Check the agent cache.
5398 ((gnus-agent-request-article article group)
5400 ;; Get the article and put into the article buffer.
5401 ((or (stringp article)
5403 (let ((gnus-override-method gnus-override-method)
5404 (methods (and (stringp article)
5405 gnus-refer-article-method))
5406 (backend (car (gnus-find-method-for-group
5407 gnus-newsgroup-name)))
5409 (buffer-read-only nil))
5410 (if (or (not (listp methods))
5411 (and (symbolp (car methods))
5412 (assq (car methods) nnoo-definition-alist)))
5413 (setq methods (list methods)))
5414 (when (and (null gnus-override-method)
5416 (setq gnus-override-method (pop methods)))
5418 (when (eq gnus-override-method 'current)
5419 (setq gnus-override-method
5420 (with-current-buffer gnus-summary-buffer
5421 gnus-current-select-method)))
5423 (gnus-kill-all-overlays)
5424 (let ((gnus-newsgroup-name group))
5425 (gnus-check-group-server))
5427 ((gnus-request-article article group (current-buffer))
5428 (when (numberp article)
5429 (gnus-async-prefetch-next group article
5430 gnus-summary-buffer)
5431 (when gnus-keep-backlog
5432 (gnus-backlog-enter-article
5433 group article (current-buffer))))
5434 (setq result 'article))
5436 (setq gnus-override-method (pop methods)))
5437 ((not (string-match "^400 "
5438 (nnheader-get-report backend)))
5439 ;; If we get 400 server disconnect, reconnect and
5440 ;; retry; otherwise, assume the article has expired.
5441 (setq result 'done))))
5442 (and (eq result 'article) 'article)))
5446 ;; Associate this article with the current summary buffer.
5447 (setq gnus-article-current-summary gnus-summary-buffer)
5449 ;; Take the article from the original article buffer
5450 ;; and place it in the buffer it's supposed to be in.
5451 (when (and (get-buffer gnus-article-buffer)
5452 (equal (buffer-name (current-buffer))
5453 (buffer-name (get-buffer gnus-article-buffer))))
5455 (if (get-buffer gnus-original-article-buffer)
5456 (set-buffer gnus-original-article-buffer)
5457 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5458 (buffer-disable-undo)
5459 (setq major-mode 'gnus-original-article-mode)
5460 (setq buffer-read-only t))
5461 (let (buffer-read-only)
5463 (insert-buffer-substring gnus-article-buffer))
5464 (setq gnus-original-article (cons group article)))
5467 (run-hooks 'gnus-article-decode-hook)
5468 ;; Mark article as decoded or not.
5469 (setq gnus-article-decoded-p gnus-article-decode-hook))
5471 ;; Update sparse articles.
5472 (when (and do-update-line
5473 (or (numberp article)
5475 (let ((buf (current-buffer)))
5476 (set-buffer gnus-summary-buffer)
5477 (gnus-summary-update-article do-update-line sparse-header)
5478 (gnus-summary-goto-subject do-update-line nil t)
5479 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5481 (set-buffer buf))))))
5487 (defcustom gnus-article-edit-mode-hook nil
5488 "Hook run in article edit mode buffers."
5489 :group 'gnus-article-various
5492 (defvar gnus-article-edit-done-function nil)
5494 (defvar gnus-article-edit-mode-map nil)
5496 ;; Should we be using derived.el for this?
5497 (unless gnus-article-edit-mode-map
5498 (setq gnus-article-edit-mode-map (make-keymap))
5499 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5501 (gnus-define-keys gnus-article-edit-mode-map
5502 "\C-c?" describe-mode
5503 "\C-c\C-c" gnus-article-edit-done
5504 "\C-c\C-k" gnus-article-edit-exit
5505 "\C-c\C-f\C-t" message-goto-to
5506 "\C-c\C-f\C-o" message-goto-from
5507 "\C-c\C-f\C-b" message-goto-bcc
5508 ;;"\C-c\C-f\C-w" message-goto-fcc
5509 "\C-c\C-f\C-c" message-goto-cc
5510 "\C-c\C-f\C-s" message-goto-subject
5511 "\C-c\C-f\C-r" message-goto-reply-to
5512 "\C-c\C-f\C-n" message-goto-newsgroups
5513 "\C-c\C-f\C-d" message-goto-distribution
5514 "\C-c\C-f\C-f" message-goto-followup-to
5515 "\C-c\C-f\C-m" message-goto-mail-followup-to
5516 "\C-c\C-f\C-k" message-goto-keywords
5517 "\C-c\C-f\C-u" message-goto-summary
5518 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5519 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5520 "\C-c\C-b" message-goto-body
5521 "\C-c\C-i" message-goto-signature
5523 "\C-c\C-t" message-insert-to
5524 "\C-c\C-n" message-insert-newsgroups
5525 "\C-c\C-o" message-sort-headers
5526 "\C-c\C-e" message-elide-region
5527 "\C-c\C-v" message-delete-not-region
5528 "\C-c\C-z" message-kill-to-signature
5529 "\M-\r" message-newline-and-reformat
5530 "\C-c\C-a" mml-attach-file
5531 "\C-a" message-beginning-of-line
5533 "\M-;" comment-region)
5535 (gnus-define-keys (gnus-article-edit-wash-map
5536 "\C-c\C-w" gnus-article-edit-mode-map)
5537 "f" gnus-article-edit-full-stops))
5540 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5542 ["Fetch To" message-insert-to t]
5543 ["Fetch Newsgroups" message-insert-newsgroups t]
5545 ["To" message-goto-to t]
5546 ["From" message-goto-from t]
5547 ["Subject" message-goto-subject t]
5548 ["Cc" message-goto-cc t]
5549 ["Reply-To" message-goto-reply-to t]
5550 ["Summary" message-goto-summary t]
5551 ["Keywords" message-goto-keywords t]
5552 ["Newsgroups" message-goto-newsgroups t]
5553 ["Followup-To" message-goto-followup-to t]
5554 ["Mail-Followup-To" message-goto-mail-followup-to t]
5555 ["Distribution" message-goto-distribution t]
5556 ["Body" message-goto-body t]
5557 ["Signature" message-goto-signature t]))
5559 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5560 "Major mode for editing articles.
5561 This is an extended text-mode.
5563 \\{gnus-article-edit-mode-map}"
5564 (make-local-variable 'gnus-article-edit-done-function)
5565 (make-local-variable 'gnus-prev-winconf)
5566 (set (make-local-variable 'font-lock-defaults)
5567 '(message-font-lock-keywords t))
5568 (set (make-local-variable 'mail-header-separator) "")
5569 (set (make-local-variable 'gnus-article-edit-mode) t)
5570 (easy-menu-add message-mode-field-menu message-mode-map)
5572 (setq buffer-read-only nil)
5573 (buffer-enable-undo)
5576 (defun gnus-article-edit (&optional force)
5577 "Edit the current article.
5578 This will have permanent effect only in mail groups.
5579 If FORCE is non-nil, allow editing of articles even in read-only
5582 (when (and (not force)
5583 (gnus-group-read-only-p))
5584 (error "The current newsgroup does not support article editing"))
5585 (gnus-article-date-original)
5586 (gnus-article-edit-article
5588 `(lambda (no-highlight)
5590 (gnus-summary-edit-article-done
5591 ,(or (mail-header-references gnus-current-headers) "")
5592 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5594 (defun gnus-article-edit-article (start-func exit-func)
5595 "Start editing the contents of the current article buffer."
5596 (let ((winconf (current-window-configuration)))
5597 (set-buffer gnus-article-buffer)
5598 (gnus-article-edit-mode)
5599 (funcall start-func)
5600 (set-buffer-modified-p nil)
5601 (gnus-configure-windows 'edit-article)
5602 (setq gnus-article-edit-done-function exit-func)
5603 (setq gnus-prev-winconf winconf)
5604 (gnus-message 6 "C-c C-c to end edits")))
5606 (defun gnus-article-edit-done (&optional arg)
5607 "Update the article edits and exit."
5609 (let ((func gnus-article-edit-done-function)
5610 (buf (current-buffer))
5611 (start (window-start))
5613 (winconf gnus-prev-winconf))
5614 (widen) ;; Widen it in case that users narrowed the buffer.
5617 ;; The cache and backlog have to be flushed somewhat.
5618 (when gnus-keep-backlog
5619 (gnus-backlog-remove-article
5620 (car gnus-article-current) (cdr gnus-article-current)))
5621 ;; Flush original article as well.
5623 (when (get-buffer gnus-original-article-buffer)
5624 (set-buffer gnus-original-article-buffer)
5625 (setq gnus-original-article nil)))
5626 (when gnus-use-cache
5627 (gnus-cache-update-article
5628 (car gnus-article-current) (cdr gnus-article-current)))
5629 ;; We remove all text props from the article buffer.
5630 (kill-all-local-variables)
5631 (set-text-properties (point-min) (point-max) nil)
5633 (set-window-configuration winconf)
5635 (set-window-start (get-buffer-window buf) start)
5636 (set-window-point (get-buffer-window buf) (point)))
5637 (gnus-summary-show-article))
5639 (defun gnus-article-edit-exit ()
5640 "Exit the article editing without updating."
5642 (when (or (not (buffer-modified-p))
5643 (yes-or-no-p "Article modified; kill anyway? "))
5644 (let ((curbuf (current-buffer))
5646 (window-start (window-start)))
5648 (if (gnus-buffer-live-p gnus-original-article-buffer)
5649 (insert-buffer gnus-original-article-buffer))
5650 (let ((winconf gnus-prev-winconf))
5651 (kill-all-local-variables)
5653 (set-window-configuration winconf)
5654 ;; Tippy-toe some to make sure that point remains where it was.
5655 (save-current-buffer
5657 (set-window-start (get-buffer-window (current-buffer)) window-start)
5659 (gnus-summary-show-article)))
5661 (defun gnus-article-edit-full-stops ()
5662 "Interactively repair spacing at end of sentences."
5665 (goto-char (point-min))
5666 (search-forward-regexp "^$" nil t)
5667 (let ((case-fold-search nil))
5668 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5671 ;;; Article highlights
5674 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5676 ;;; Internal Variables:
5678 (defcustom gnus-button-url-regexp
5679 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5680 "\\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:]]\\)"
5681 "\\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\\)\\)")
5682 "Regular expression that matches URLs."
5683 :group 'gnus-article-buttons
5686 (defcustom gnus-button-valid-fqdn-regexp
5687 message-valid-fqdn-regexp
5688 "Regular expression that matches a valid FQDN."
5689 :group 'gnus-article-buttons
5692 (defcustom gnus-button-man-handler 'manual-entry
5693 "Function to use for displaying man pages.
5694 The function must take at least one argument with a string naming the
5696 :type '(choice (function-item :tag "Man" manual-entry)
5697 (function-item :tag "Woman" woman)
5698 (function :tag "Other"))
5699 :group 'gnus-article-buttons)
5701 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5702 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5703 If the default site is too slow, try to find a CTAN mirror, see
5704 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5705 the variable `gnus-button-handle-ctan'."
5706 :group 'gnus-article-buttons
5707 :link '(custom-manual "(gnus)Group Parameters")
5708 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5709 (const "http://tug.ctan.org/tex-archive/")
5710 (const "http://www.dante.de/CTAN/")
5711 (string :tag "Other")))
5713 (defcustom gnus-button-ctan-handler 'browse-url
5714 "Function to use for displaying CTAN links.
5715 The function must take one argument, the string naming the URL."
5716 :type '(choice (function-item :tag "Browse Url" browse-url)
5717 (function :tag "Other"))
5718 :group 'gnus-article-buttons)
5720 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5721 "Bogus strings removed from CTAN URLs."
5722 :group 'gnus-article-buttons
5723 :type '(choice (const "^/?tex-archive/\\|/")
5724 (regexp :tag "Other")))
5726 (defcustom gnus-button-ctan-directory-regexp
5729 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5730 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5731 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5733 "Regular expression for ctan directories.
5734 It should match all directories in the top level of `gnus-ctan-url'."
5735 :group 'gnus-article-buttons
5738 (defcustom gnus-button-mid-or-mail-regexp
5739 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5740 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5741 gnus-button-valid-fqdn-regexp
5743 "Regular expression that matches a message ID or a mail address."
5744 :group 'gnus-article-buttons
5747 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5748 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5749 Strings like this can be either a message ID or a mail address. If it is one
5750 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5751 message ID or a mail address, respectively. If this variable is set to the
5752 symbol `ask', always query the user what do do. If it is a function, this
5753 function will be called with the string as it's only argument. The function
5754 must return `mid', `mail', `invalid' or `ask'."
5755 :group 'gnus-article-buttons
5756 :type '(choice (function-item :tag "Heuristic function"
5757 gnus-button-mid-or-mail-heuristic)
5762 (defcustom gnus-button-mid-or-mail-heuristic-alist
5763 '((-10.0 . ".+\\$.+@")
5766 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5767 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5768 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5769 (-1.0 . "^[^a-z]+@")
5771 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5772 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5773 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5774 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5777 (-1.0 . "^[0-9][0-9]")
5779 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5780 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5781 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5782 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5784 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5785 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5788 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5790 ;; compensation for TDMA dated mail addresses:
5791 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5793 (-20.0 . "\\.fsf@") ;; Gnus
5796 (-20.0 . "_-_") ;; Subject change in thread
5798 (-20.0 . "\\.ln@") ;; leafnode
5799 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5800 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5802 ;; (5.0 . "") ;; $local_part_len <= 7
5803 (10.0 . "^[^0-9]+@")
5804 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5805 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5808 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5810 (0.5 . "^[A-Z][a-z]")
5811 (0.5 . "^[A-Z][a-z][a-z]")
5812 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5813 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5814 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5816 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5817 address. The REGEXP is processed with `case-fold-search' set to nil."
5818 :group 'gnus-article-buttons
5819 :type '(repeat (cons (number :tag "Rate")
5820 (regexp :tag "Regexp"))))
5822 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5823 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5824 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5825 address, `ask' if unsure and `invalid' if the string is invalid."
5826 (let ((case-fold-search nil)
5827 (list gnus-button-mid-or-mail-heuristic-alist)
5828 (result 0) rate regexp lpartlen elem)
5830 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5831 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5832 ;; Certain special cases...
5835 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5836 "^[0-9]+\\.[0-9]+@compuserve\\|"
5837 "@public\\.gmane\\.org")
5839 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5840 (setq result 'mail))
5841 (when (string-match "@.*@\\| " mid-or-mail)
5842 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5843 (setq result 'invalid))
5844 ;; Nothing more to do, if result is not a number here...
5845 (when (numberp result)
5847 (setq elem (car list)
5851 (when (string-match regexp mid-or-mail)
5852 (setq result (+ result rate))
5854 9 "`%s' matched `%s', rate `%s', result `%s'."
5855 mid-or-mail regexp rate result)))
5856 (when (<= lpartlen 7)
5857 (setq result (+ result 5.0))
5858 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5859 mid-or-mail result))
5860 (when (>= lpartlen 12)
5861 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5863 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5864 ;; Long local part should contain realname if e-mail address,
5865 ;; too many digits: message-id.
5866 ;; $score -= 5.0 + 0.1 * $local_part_len;
5867 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5868 (setq result (+ result rate))
5870 9 "Many digits in `%s', rate `%s', result `%s'."
5871 mid-or-mail rate result))
5872 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5874 ;; Too few vowels [^aeiouy]{4,}.*\@
5875 (setq result (+ result -5.0))
5877 9 "Few vowels in `%s', rate `%s', result `%s'."
5878 mid-or-mail -5.0 result))
5880 (setq result (+ result 5.0))
5882 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5883 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5884 ;; Maybe we should make this a customizable alist: (condition . 'result)
5886 ((symbolp result) result)
5887 ;; Now convert number into proper results:
5888 ((< result -10.0) 'mid)
5889 ((> result 10.0) 'mail)
5892 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5893 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5894 (url-mid (concat "news" ":" mid-or-mail))
5895 (url-mailto (concat "mailto" ":" mid-or-mail)))
5896 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5897 (when (fboundp pref)
5899 ;; get rid of surrounding angles...
5901 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5902 (if (or (eq 'mid guessed) (eq 'mail guessed))
5906 (save-window-excursion
5907 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5910 (cond ((eq pref 'mid)
5911 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5912 (gnus-button-handle-news url-mid))
5914 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5915 (gnus-url-mailto url-mailto))
5916 (t (gnus-message 3 "Invalid string.")))))
5918 (defun gnus-button-handle-custom (url)
5919 "Follow a Custom URL."
5920 (customize-apropos (gnus-url-unhex-string url)))
5922 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5924 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5927 (defun gnus-button-handle-describe-function (url)
5928 "Call `describe-function' when pushing the corresponding URL button."
5931 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5933 (defun gnus-button-handle-describe-variable (url)
5934 "Call `describe-variable' when pushing the corresponding URL button."
5937 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5939 (defun gnus-button-handle-symbol (url)
5940 "Display help on variable or function.
5941 Calls `describe-variable' or `describe-function'."
5942 (let ((sym (intern url)))
5944 ((fboundp sym) (describe-function sym))
5945 ((boundp sym) (describe-variable sym))
5946 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5948 (defun gnus-button-handle-describe-key (url)
5949 "Call `describe-key' when pushing the corresponding URL button."
5951 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5952 (keys (ignore-errors (eval `(kbd ,key-string)))))
5955 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5957 (defun gnus-button-handle-apropos (url)
5958 "Call `apropos' when pushing the corresponding URL button."
5959 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5961 (defun gnus-button-handle-apropos-command (url)
5962 "Call `apropos' when pushing the corresponding URL button."
5964 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5966 (defun gnus-button-handle-apropos-variable (url)
5967 "Call `apropos' when pushing the corresponding URL button."
5969 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5970 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5972 (defun gnus-button-handle-apropos-documentation (url)
5973 "Call `apropos' when pushing the corresponding URL button."
5975 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5976 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5978 (defun gnus-button-handle-library (url)
5979 "Call `locate-library' when pushing the corresponding URL button."
5980 (gnus-message 9 "url=`%s'" url)
5981 (let* ((lib (locate-library url))
5982 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
5984 (gnus-message 1 "Cannot locale library `%s'." url)
5985 (find-file-read-only file))))
5987 (defun gnus-button-handle-ctan (url)
5988 "Call `browse-url' when pushing a CTAN URL button."
5990 gnus-button-ctan-handler
5993 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5995 (defcustom gnus-button-tex-level 5
5996 "*Integer that says how many TeX-related buttons Gnus will show.
5997 The higher the number, the more buttons will appear and the more false
5998 positives are possible. Note that you can set this variable local to
5999 specific groups. Setting it higher in TeX groups is probably a good idea.
6000 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6001 how to set variables in specific groups."
6002 :group 'gnus-article-buttons
6003 :link '(custom-manual "(gnus)Group Parameters")
6006 (defcustom gnus-button-man-level 5
6007 "*Integer that says how many man-related buttons Gnus will show.
6008 The higher the number, the more buttons will appear and the more false
6009 positives are possible. Note that you can set this variable local to
6010 specific groups. Setting it higher in Unix groups is probably a good idea.
6011 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6012 how to set variables in specific groups."
6013 :group 'gnus-article-buttons
6014 :link '(custom-manual "(gnus)Group Parameters")
6017 (defcustom gnus-button-emacs-level 5
6018 "*Integer that says how many emacs-related buttons Gnus will show.
6019 The higher the number, the more buttons will appear and the more false
6020 positives are possible. Note that you can set this variable local to
6021 specific groups. Setting it higher in Emacs or Gnus related groups is
6022 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6023 `gnus-parameters' on how to set variables in specific groups."
6024 :group 'gnus-article-buttons
6025 :link '(custom-manual "(gnus)Group Parameters")
6028 (defcustom gnus-button-message-level 5
6029 "*Integer that says how many buttons for news or mail messages will appear.
6030 The higher the number, the more buttons will appear and the more false
6031 positives are possible."
6032 ;; mail addresses, MIDs, URLs for news, ...
6033 :group 'gnus-article-buttons
6036 (defcustom gnus-button-browse-level 5
6037 "*Integer that says how many buttons for browsing will appear.
6038 The higher the number, the more buttons will appear and the more false
6039 positives are possible."
6040 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6041 :group 'gnus-article-buttons
6044 (defcustom gnus-button-alist
6045 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6046 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6047 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6048 gnus-button-handle-news 2)
6049 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6050 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6051 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6052 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6053 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6054 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6055 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6056 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6057 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6058 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6059 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6060 ;; RFC 2368 (The mailto URL scheme)
6061 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6062 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6063 ("\\bmailto:\\([^ \n\t]+\\)"
6064 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6066 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6067 gnus-button-ctan-directory-regexp
6068 "[^][>)!;:,'\n\t ]+\\)")
6069 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6070 ((concat "\\btex-archive/\\("
6071 gnus-button-ctan-directory-regexp
6072 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6073 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6076 gnus-button-ctan-directory-regexp
6077 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6078 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6079 ;; This is info (home-grown style) <info://foo/bar+baz>
6080 ("\\binfo://\\([^'\">\n\t ]+\\)"
6081 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6082 ;; Info GNOME style <info:foo#bar_baz>
6083 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6084 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6085 ;; Info KDE style <info:(foo)bar baz>
6086 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6087 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6088 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6089 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6090 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6091 ;; Info links like `C-h i d m CC Mode RET'
6092 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6094 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6095 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6096 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6097 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6098 ;; Emacs help commands
6099 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6100 ;; regexp doesn't match arguments containing ` '.
6101 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6102 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6103 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6104 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6105 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6106 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6107 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6108 ;; The following entries may lead to many false positives so don't enable
6109 ;; them by default (use a high button level):
6110 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6111 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6112 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6113 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6114 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6115 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6116 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6117 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6118 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6119 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6120 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6121 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6122 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6123 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6124 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6125 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6126 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6127 ;; Unlike the other regexps we really have to require quoting
6128 ;; here to determine where it ends.
6129 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6130 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6131 ("<URL: *\\([^<>]*\\)>"
6132 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6133 ;; RFC 2396 (2.4.3., delims) ...
6134 ("\"URL: *\\([^\"]*\\)\""
6135 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6136 ;; RFC 2396 (2.4.3., delims) ...
6137 ("\"URL: *\\([^\"]*\\)\""
6138 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6140 (gnus-button-url-regexp
6141 0 (>= gnus-button-browse-level 0) browse-url 0)
6143 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6144 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6145 gnus-button-handle-man 1)
6146 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6147 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6148 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6149 gnus-button-handle-man 1)
6150 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6151 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6152 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6153 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6154 ;; MID or mail: To avoid too many false positives we don't try to catch
6155 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6156 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6157 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6158 ;; so that non-ambiguous entries (see above) match first.
6159 (gnus-button-mid-or-mail-regexp
6160 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6161 "*Alist of regexps matching buttons in article bodies.
6163 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6164 REGEXP: is the string (case insensitive) matching text around the button (can
6165 also be Lisp expression evaluating to a string),
6166 BUTTON: is the number of the regexp grouping actually matching the button,
6167 FORM: is a Lisp expression which must eval to true for the button to
6169 CALLBACK: is the function to call when the user push this button, and each
6170 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6172 CALLBACK can also be a variable, in that case the value of that
6173 variable it the real callback function."
6174 :group 'gnus-article-buttons
6175 :type '(repeat (list (choice regexp variable sexp)
6176 (integer :tag "Button")
6178 (function :tag "Callback")
6181 (integer :tag "Regexp group")))))
6183 (defcustom gnus-header-button-alist
6184 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6185 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6186 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6187 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6188 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6189 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6190 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6191 0 (>= gnus-button-browse-level 0) browse-url 0)
6192 ("^Subject:" gnus-button-url-regexp
6193 0 (>= gnus-button-browse-level 0) browse-url 0)
6194 ("^[^:]+:" gnus-button-url-regexp
6195 0 (>= gnus-button-browse-level 0) browse-url 0)
6196 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6197 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6198 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6199 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6200 "*Alist of headers and regexps to match buttons in article heads.
6202 This alist is very similar to `gnus-button-alist', except that each
6203 alist has an additional HEADER element first in each entry:
6205 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6207 HEADER is a regexp to match a header. For a fuller explanation, see
6208 `gnus-button-alist'."
6209 :group 'gnus-article-buttons
6210 :group 'gnus-article-headers
6211 :type '(repeat (list (regexp :tag "Header")
6212 (choice regexp variable)
6213 (integer :tag "Button")
6215 (function :tag "Callback")
6218 (integer :tag "Regexp group")))))
6222 (defun gnus-article-push-button (event)
6223 "Check text under the mouse pointer for a callback function.
6224 If the text under the mouse pointer has a `gnus-callback' property,
6225 call it with the value of the `gnus-data' text property."
6227 (set-buffer (window-buffer (posn-window (event-start event))))
6228 (let* ((pos (posn-point (event-start event)))
6229 (data (get-text-property pos 'gnus-data))
6230 (fun (get-text-property pos 'gnus-callback)))
6233 (funcall fun data))))
6235 (defun gnus-article-press-button ()
6236 "Check text at point for a callback function.
6237 If the text at point has a `gnus-callback' property,
6238 call it with the value of the `gnus-data' text property."
6240 (let ((data (get-text-property (point) 'gnus-data))
6241 (fun (get-text-property (point) 'gnus-callback)))
6243 (funcall fun data))))
6245 (defun gnus-article-highlight (&optional force)
6246 "Highlight current article.
6247 This function calls `gnus-article-highlight-headers',
6248 `gnus-article-highlight-citation',
6249 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6250 do the highlighting. See the documentation for those functions."
6251 (interactive (list 'force))
6252 (gnus-article-highlight-headers)
6253 (gnus-article-highlight-citation force)
6254 (gnus-article-highlight-signature)
6255 (gnus-article-add-buttons force)
6256 (gnus-article-add-buttons-to-head))
6258 (defun gnus-article-highlight-some (&optional force)
6259 "Highlight current article.
6260 This function calls `gnus-article-highlight-headers',
6261 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6262 do the highlighting. See the documentation for those functions."
6263 (interactive (list 'force))
6264 (gnus-article-highlight-headers)
6265 (gnus-article-highlight-signature)
6266 (gnus-article-add-buttons))
6268 (defun gnus-article-highlight-headers ()
6269 "Highlight article headers as specified by `gnus-header-face-alist'."
6271 (gnus-with-article-headers
6272 (let ((alist gnus-header-face-alist)
6273 entry regexp header-face field-face from hpoints fpoints)
6274 (while (setq entry (pop alist))
6275 (goto-char (point-min))
6276 (setq regexp (concat "^\\("
6277 (if (string-equal "" (nth 0 entry))
6281 header-face (nth 1 entry)
6282 field-face (nth 2 entry))
6283 (while (and (re-search-forward regexp nil t)
6287 (unless (search-forward ":" nil t)
6289 (when (and header-face
6290 (not (memq (point) hpoints)))
6291 (push (point) hpoints)
6292 (gnus-put-text-property from (point) 'face header-face))
6293 (when (and field-face
6294 (not (memq (setq from (point)) fpoints)))
6296 (if (re-search-forward "^[^ \t]" nil t)
6298 (goto-char (point-max)))
6299 (gnus-put-text-property from (point) 'face field-face)))))))
6301 (defun gnus-article-highlight-signature ()
6302 "Highlight the signature in an article.
6303 It does this by highlighting everything after
6304 `gnus-signature-separator' using `gnus-signature-face'."
6306 (gnus-with-article-buffer
6307 (let ((inhibit-point-motion-hooks t))
6309 (when (and gnus-signature-face
6310 (gnus-article-narrow-to-signature))
6311 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6312 'face gnus-signature-face)
6314 (gnus-article-search-signature)
6315 (let ((start (match-beginning 0))
6316 (end (set-marker (make-marker) (1+ (match-end 0)))))
6317 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6320 (defun gnus-button-in-region-p (b e prop)
6321 "Say whether PROP exists in the region."
6322 (text-property-not-all b e prop nil))
6324 (defun gnus-article-add-buttons (&optional force)
6325 "Find external references in the article and make buttons of them.
6326 \"External references\" are things like Message-IDs and URLs, as
6327 specified by `gnus-button-alist'."
6328 (interactive (list 'force))
6329 (gnus-with-article-buffer
6330 (let ((inhibit-point-motion-hooks t)
6331 (case-fold-search t)
6332 (alist gnus-button-alist)
6334 ;; Remove all old markers.
6335 (let (marker entry new-list)
6336 (while (setq marker (pop gnus-button-marker-list))
6337 (if (or (< marker (point-min)) (>= marker (point-max)))
6338 (push marker new-list)
6340 (when (setq entry (gnus-button-entry))
6341 (put-text-property (match-beginning (nth 1 entry))
6342 (match-end (nth 1 entry))
6343 'gnus-callback nil))
6344 (set-marker marker nil)))
6345 (setq gnus-button-marker-list new-list))
6346 ;; We skip the headers.
6349 (while (setq entry (pop alist))
6350 (setq regexp (eval (car entry)))
6352 (while (re-search-forward regexp nil t)
6353 (let* ((start (and entry (match-beginning (nth 1 entry))))
6354 (end (and entry (match-end (nth 1 entry))))
6355 (from (match-beginning 0)))
6356 (when (and (or (eq t (nth 2 entry))
6357 (eval (nth 2 entry)))
6358 (not (gnus-button-in-region-p
6359 start end 'gnus-callback)))
6360 ;; That optional form returned non-nil, so we add the
6362 (gnus-article-add-button
6363 start end 'gnus-button-push
6364 (car (push (set-marker (make-marker) from)
6365 gnus-button-marker-list))))))))))
6367 ;; Add buttons to the head of an article.
6368 (defun gnus-article-add-buttons-to-head ()
6369 "Add buttons to the head of the article."
6371 (gnus-with-article-headers
6372 (let ((alist gnus-header-button-alist)
6375 ;; Each alist entry.
6376 (setq entry (pop alist))
6377 (goto-char (point-min))
6378 (while (re-search-forward (car entry) nil t)
6379 ;; Each header matching the entry.
6380 (setq beg (match-beginning 0))
6381 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6382 (match-beginning 0))
6385 (while (re-search-forward (eval (nth 1 entry)) end t)
6386 ;; Each match within a header.
6387 (let* ((entry (cdr entry))
6388 (start (match-beginning (nth 1 entry)))
6389 (end (match-end (nth 1 entry)))
6390 (form (nth 2 entry)))
6391 (goto-char (match-end 0))
6393 (gnus-article-add-button
6394 start end (nth 3 entry)
6395 (buffer-substring (match-beginning (nth 4 entry))
6396 (match-end (nth 4 entry)))))))
6397 (goto-char end))))))
6399 ;;; External functions:
6401 (defun gnus-article-add-button (from to fun &optional data)
6402 "Create a button between FROM and TO with callback FUN and data DATA."
6403 (when gnus-article-button-face
6404 (gnus-overlay-put (gnus-make-overlay from to)
6405 'face gnus-article-button-face))
6406 (gnus-add-text-properties
6408 (nconc (and gnus-article-mouse-face
6409 (list gnus-mouse-face-prop gnus-article-mouse-face))
6410 (list 'gnus-callback fun)
6411 (and data (list 'gnus-data data))))
6412 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6413 :button-keymap gnus-widget-button-keymap))
6415 ;;; Internal functions:
6417 (defun gnus-article-set-globals ()
6418 (with-current-buffer gnus-summary-buffer
6419 (gnus-set-global-variables)))
6421 (defun gnus-signature-toggle (end)
6422 (gnus-with-article-buffer
6423 (let ((inhibit-point-motion-hooks t))
6424 (if (text-property-any end (point-max) 'article-type 'signature)
6426 (gnus-delete-wash-type 'signature)
6427 (gnus-remove-text-properties-when
6428 'article-type 'signature end (point-max)
6429 (cons 'article-type (cons 'signature
6430 gnus-hidden-properties))))
6431 (gnus-add-wash-type 'signature)
6432 (gnus-add-text-properties-when
6433 'article-type nil end (point-max)
6434 (cons 'article-type (cons 'signature
6435 gnus-hidden-properties)))))
6436 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6437 (gnus-set-mode-line 'article))))
6439 (defun gnus-button-entry ()
6440 ;; Return the first entry in `gnus-button-alist' matching this place.
6441 (let ((alist gnus-button-alist)
6444 (setq entry (pop alist))
6445 (if (looking-at (eval (car entry)))
6450 (defun gnus-button-push (marker)
6451 ;; Push button starting at MARKER.
6454 (let* ((entry (gnus-button-entry))
6455 (inhibit-point-motion-hooks t)
6457 (args (mapcar (lambda (group)
6458 (let ((string (match-string group)))
6459 (set-text-properties
6460 0 (length string) nil string)
6467 (fboundp (symbol-value fun)))
6468 (apply (symbol-value fun) args))
6470 (gnus-message 1 "You must define `%S' to use this button"
6471 (cons fun args)))))))
6473 (defun gnus-parse-news-url (url)
6474 (let (scheme server group message-id articles)
6477 (goto-char (point-min))
6478 (when (looking-at "\\([A-Za-z]+\\):")
6479 (setq scheme (match-string 1))
6480 (goto-char (match-end 0)))
6481 (when (looking-at "//\\([^/]+\\)/")
6482 (setq server (match-string 1))
6483 (goto-char (match-end 0)))
6486 ((looking-at "\\(.*@.*\\)")
6487 (setq message-id (match-string 1)))
6488 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6489 (setq group (match-string 1)
6490 articles (split-string (match-string 2) "-")))
6491 ((looking-at "\\([^/]+\\)/?")
6492 (setq group (match-string 1)))
6494 (error "Unknown news URL syntax"))))
6495 (list scheme server group message-id articles)))
6497 (defun gnus-button-handle-news (url)
6499 (destructuring-bind (scheme server group message-id articles)
6500 (gnus-parse-news-url url)
6504 (set-buffer gnus-summary-buffer)
6506 (let ((gnus-refer-article-method (list (list 'nntp server))))
6507 (gnus-summary-refer-article message-id))
6508 (gnus-summary-refer-article message-id))))
6510 (gnus-button-fetch-group url)))))
6512 (defun gnus-button-handle-man (url)
6514 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6515 (when (eq gnus-button-man-handler 'woman)
6516 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6517 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6518 (funcall gnus-button-man-handler url))
6520 (defun gnus-button-handle-info-url (url)
6521 "Fetch an info URL."
6522 (setq url (mm-subst-char-in-string ?+ ?\ url))
6524 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6525 (gnus-info-find-node
6526 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6528 ")" (gnus-url-unhex-string (match-string 2 url)))))
6529 ((string-match "([^)\"]+)[^\"]+" url)
6531 (gnus-replace-in-string
6532 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6533 (gnus-info-find-node url))
6534 (t (error "Can't parse %s" url))))
6536 (defun gnus-button-handle-info-url-gnome (url)
6537 "Fetch GNOME style info URL."
6538 (setq url (mm-subst-char-in-string ?_ ?\ url))
6539 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6540 (gnus-info-find-node
6542 (gnus-url-unhex-string
6543 (match-string 1 url))
6545 (or (gnus-url-unhex-string
6546 (match-string 2 url))
6548 (error "Can't parse %s" url)))
6550 (defun gnus-button-handle-info-url-kde (url)
6551 "Fetch KDE style info URL."
6552 (gnus-info-find-node (gnus-url-unhex-string url)))
6554 (defun gnus-button-handle-info-keystrokes (url)
6555 "Call `info' when pushing the corresponding URL button."
6556 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6561 (defun gnus-button-message-id (message-id)
6563 (with-current-buffer gnus-summary-buffer
6564 (gnus-summary-refer-article message-id)))
6566 (defun gnus-button-fetch-group (address)
6567 "Fetch GROUP specified by ADDRESS."
6568 (if (not (string-match "[:/]" address))
6569 ;; This is just a simple group url.
6570 (gnus-group-read-ephemeral-group address gnus-select-method)
6573 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6575 (error "Can't parse %s" address)
6576 (gnus-group-read-ephemeral-group
6577 (match-string 4 address)
6578 `(nntp ,(match-string 1 address)
6579 (nntp-address ,(match-string 1 address))
6580 (nntp-port-number ,(if (match-end 3)
6581 (match-string 3 address)
6584 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6586 (defun gnus-url-parse-query-string (query &optional downcase)
6587 (let (retval pairs cur key val)
6588 (setq pairs (split-string query "&"))
6590 (setq cur (car pairs)
6592 (if (not (string-match "=" cur))
6594 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6595 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6597 (setq key (downcase key)))
6598 (setq cur (assoc key retval))
6600 (setcdr cur (cons val (cdr cur)))
6601 (setq retval (cons (list key val) retval)))))
6604 (defun gnus-url-mailto (url)
6605 ;; Send mail to someone
6606 (when (string-match "mailto:/*\\(.*\\)" url)
6607 (setq url (substring url (match-beginning 1) nil)))
6608 (let (to args subject func)
6609 (setq args (gnus-url-parse-query-string
6610 (if (string-match "^\\?" url)
6612 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6613 (concat "to=" (match-string 1 url) "&"
6614 (match-string 2 url))
6615 (concat "to=" url)))
6617 subject (cdr-safe (assoc "subject" args)))
6620 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6623 (message-position-on-field (caar args)))
6624 (insert (gnus-replace-in-string
6625 (mapconcat 'identity (reverse (cdar args)) ", ")
6627 (setq args (cdr args)))
6630 (message-goto-subject))))
6632 (defun gnus-button-embedded-url (address)
6633 "Activate ADDRESS with `browse-url'."
6634 (browse-url (gnus-strip-whitespace address)))
6636 ;;; Next/prev buttons in the article buffer.
6638 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6639 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6641 (defvar gnus-prev-page-map
6642 (let ((map (make-sparse-keymap)))
6643 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6644 (define-key map "\r" 'gnus-button-prev-page)
6647 (defvar gnus-next-page-map
6648 (let ((map (make-sparse-keymap)))
6649 (define-key map gnus-mouse-2 'gnus-button-next-page)
6650 (define-key map "\r" 'gnus-button-next-page)
6653 (defun gnus-insert-prev-page-button ()
6655 (buffer-read-only nil))
6657 gnus-prev-page-line-format nil
6658 `(keymap ,gnus-prev-page-map
6660 gnus-callback gnus-article-button-prev-page
6661 article-type annotation))
6662 (widget-convert-button
6664 ;; Exclude a newline.
6667 :action 'gnus-button-prev-page
6668 :button-keymap gnus-prev-page-map)))
6670 (defun gnus-button-next-page (&optional args more-args)
6671 "Go to the next page."
6673 (let ((win (selected-window)))
6674 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6675 (gnus-article-next-page)
6676 (select-window win)))
6678 (defun gnus-button-prev-page (&optional args more-args)
6679 "Go to the prev page."
6681 (let ((win (selected-window)))
6682 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6683 (gnus-article-prev-page)
6684 (select-window win)))
6686 (defun gnus-insert-next-page-button ()
6688 (buffer-read-only nil))
6689 (gnus-eval-format gnus-next-page-line-format nil
6690 `(keymap ,gnus-next-page-map
6692 gnus-callback gnus-article-button-next-page
6693 article-type annotation))
6694 (widget-convert-button
6696 ;; Exclude a newline.
6699 :action 'gnus-button-next-page
6700 :button-keymap gnus-next-page-map)))
6702 (defun gnus-article-button-next-page (arg)
6703 "Go to the next page."
6705 (let ((win (selected-window)))
6706 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6707 (gnus-article-next-page)
6708 (select-window win)))
6710 (defun gnus-article-button-prev-page (arg)
6711 "Go to the prev page."
6713 (let ((win (selected-window)))
6714 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6715 (gnus-article-prev-page)
6716 (select-window win)))
6718 (defvar gnus-decode-header-methods
6719 '(mail-decode-encoded-word-region)
6720 "List of methods used to decode headers.
6722 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6723 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6724 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6725 whose names match REGEXP.
6728 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6729 mail-decode-encoded-word-region
6730 (\"chinese\" . rfc1843-decode-region))
6733 (defvar gnus-decode-header-methods-cache nil)
6735 (defun gnus-multi-decode-header (start end)
6736 "Apply the functions from `gnus-encoded-word-methods' that match."
6737 (unless (and gnus-decode-header-methods-cache
6738 (eq gnus-newsgroup-name
6739 (car gnus-decode-header-methods-cache)))
6740 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6743 (nconc gnus-decode-header-methods-cache (list x))
6744 (if (and gnus-newsgroup-name
6745 (string-match (car x) gnus-newsgroup-name))
6746 (nconc gnus-decode-header-methods-cache
6748 gnus-decode-header-methods))
6749 (let ((xlist gnus-decode-header-methods-cache))
6752 (narrow-to-region start end)
6754 (funcall (pop xlist) (point-min) (point-max))))))
6757 ;;; Treatment top-level handling.
6760 (defun gnus-treat-article (condition &optional part-number total-parts type)
6761 (let ((length (- (point-max) (point-min)))
6762 (alist gnus-treatment-function-alist)
6763 (article-goto-body-goes-to-point-min-p t)
6767 (let ((list gnus-article-treat-types))
6769 (when (string-match (pop list) type)
6770 (throw 'found t)))))))
6771 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6773 (gnus-run-hooks 'gnus-part-display-hook)
6774 (dolist (elem alist)
6777 (when (gnus-buffer-live-p gnus-summary-buffer)
6778 (set-buffer gnus-summary-buffer))
6779 (symbol-value (car elem))))
6780 (when (and (or (consp val)
6782 (gnus-treat-predicate val)
6783 (or (not (get (car elem) 'highlight))
6786 (funcall (cadr elem)))))))
6788 ;; Dynamic variables.
6790 (defvar part-number)
6791 (defvar total-parts)
6796 (defun gnus-treat-predicate (val)
6803 (stringp (car val)))
6804 (apply 'gnus-or (mapcar `(lambda (s)
6805 (string-match s ,(or gnus-newsgroup-name "")))
6808 (let ((pred (pop val)))
6811 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6813 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6815 (not (gnus-treat-predicate (car val))))
6817 (equal (car val) type))
6819 (error "%S is not a valid predicate" pred)))))
6825 (eq part-number total-parts))
6829 (error "%S is not a valid value" val))))
6831 (defun gnus-article-encrypt-body (protocol &optional n)
6832 "Encrypt the article body."
6835 (or gnus-article-encrypt-protocol
6836 (completing-read "Encrypt protocol: "
6837 gnus-article-encrypt-protocol-alist
6839 current-prefix-arg))
6840 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6842 (error (format "Can't find the encrypt protocol %s" protocol)))
6843 (if (member gnus-newsgroup-name '("nndraft:delayed"
6846 (error "Can't encrypt the article in group %s"
6847 gnus-newsgroup-name))
6848 (gnus-summary-iterate n
6850 (set-buffer gnus-summary-buffer)
6851 (let ((mail-parse-charset gnus-newsgroup-charset)
6852 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6853 (summary-buffer gnus-summary-buffer)
6855 (gnus-set-global-variables)
6856 (when (gnus-group-read-only-p)
6857 (error "The current newsgroup does not support article encrypt"))
6858 (gnus-summary-show-article t)
6860 (or (mail-header-references gnus-current-headers) ""))
6861 (set-buffer gnus-article-buffer)
6862 (let* ((buffer-read-only nil)
6864 (mapcar (lambda (field)
6865 (and (save-restriction
6866 (message-narrow-to-head)
6867 (goto-char (point-min))
6868 (search-forward field nil t))
6870 (message-narrow-to-field)
6872 (delete-region (point-min) (point-max))
6874 '("Content-Type:" "Content-Transfer-Encoding:"
6875 "Content-Disposition:"))))
6876 (message-narrow-to-head)
6877 (message-remove-header "MIME-Version")
6878 (goto-char (point-max))
6879 (setq point (point))
6880 (insert (apply 'concat headers))
6882 (narrow-to-region point (point-max))
6883 (let ((message-options message-options))
6884 (message-options-set 'message-sender user-mail-address)
6885 (message-options-set 'message-recipients user-mail-address)
6886 (message-options-set 'message-sign-encrypt 'not)
6888 (goto-char (point-min))
6889 (insert "MIME-Version: 1.0\n")
6891 (gnus-summary-edit-article-done
6892 references nil summary-buffer t))
6893 (when gnus-keep-backlog
6894 (gnus-backlog-remove-article
6895 (car gnus-article-current) (cdr gnus-article-current)))
6897 (when (get-buffer gnus-original-article-buffer)
6898 (set-buffer gnus-original-article-buffer)
6899 (setq gnus-original-article nil)))
6900 (when gnus-use-cache
6901 (gnus-cache-update-article
6902 (car gnus-article-current) (cdr gnus-article-current))))))))
6904 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6905 "The following specs can be used:
6906 %t The security MIME type
6909 %D Details if button is pressed")
6911 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6912 "The following specs can be used:
6913 %t The security MIME type
6916 %D Details if button is pressed")
6918 (defvar gnus-mime-security-button-line-format-alist
6919 '((?t gnus-tmp-type ?s)
6920 (?i gnus-tmp-info ?s)
6921 (?d gnus-tmp-details ?s)
6922 (?D gnus-tmp-pressed-details ?s)))
6924 (defvar gnus-mime-security-button-map
6925 (let ((map (make-sparse-keymap)))
6926 (define-key map gnus-mouse-2 'gnus-article-push-button)
6927 (define-key map "\r" 'gnus-article-press-button)
6930 (defvar gnus-mime-security-details-buffer nil)
6932 (defvar gnus-mime-security-button-pressed nil)
6934 (defvar gnus-mime-security-show-details-inline t
6935 "If non-nil, show details in the article buffer.")
6937 (defun gnus-mime-security-verify-or-decrypt (handle)
6938 (mm-remove-parts (cdr handle))
6939 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6940 point buffer-read-only)
6942 (goto-char (car region)))
6944 (narrow-to-region (point) (point))
6945 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6946 (let* ((mm-verify-option 'known)
6947 (mm-decrypt-option 'known)
6948 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6949 (unless (eq nparts (cdr handle))
6950 (mm-destroy-parts (cdr handle))
6951 (setcdr handle nparts))))
6952 (setq point (point))
6953 (gnus-mime-display-security handle)
6954 (goto-char (point-max)))
6956 (delete-region (point) (cdr region))
6957 (set-marker (car region) nil)
6958 (set-marker (cdr region) nil))
6961 (defun gnus-mime-security-show-details (handle)
6962 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6964 (gnus-message 5 "No details.")
6965 (if gnus-mime-security-show-details-inline
6966 (let ((gnus-mime-security-button-pressed
6967 (not (get-text-property (point) 'gnus-mime-details)))
6968 (gnus-mime-security-button-line-format
6969 (get-text-property (point) 'gnus-line-format))
6972 (while (eq (get-text-property (point) 'gnus-line-format)
6973 gnus-mime-security-button-line-format)
6977 (narrow-to-region (point) (point))
6978 (gnus-insert-mime-security-button handle))
6979 (delete-region (point)
6980 (or (text-property-not-all
6983 gnus-mime-security-button-line-format)
6986 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6987 (with-current-buffer gnus-mime-security-details-buffer
6990 (setq gnus-mime-security-details-buffer
6991 (gnus-get-buffer-create "*MIME Security Details*")))
6992 (with-current-buffer gnus-mime-security-details-buffer
6994 (goto-char (point-min)))
6995 (pop-to-buffer gnus-mime-security-details-buffer)))))
6997 (defun gnus-mime-security-press-button (handle)
6999 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7000 (gnus-mime-security-show-details handle)
7001 (gnus-mime-security-verify-or-decrypt handle))))
7003 (defun gnus-insert-mime-security-button (handle &optional displayed)
7004 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7007 (or (nth 2 (assoc protocol mm-verify-function-alist))
7008 (nth 2 (assoc protocol mm-decrypt-function-alist))
7010 (if (equal (car handle) "multipart/signed")
7011 " Signed" " Encrypted")
7014 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7017 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7018 gnus-tmp-pressed-details
7020 (setq gnus-tmp-details
7021 (if gnus-tmp-details
7022 (concat "\n" gnus-tmp-details)
7024 (setq gnus-tmp-pressed-details
7025 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7030 gnus-mime-security-button-line-format
7031 gnus-mime-security-button-line-format-alist
7032 `(keymap ,gnus-mime-security-button-map
7033 gnus-callback gnus-mime-security-press-button
7034 gnus-line-format ,gnus-mime-security-button-line-format
7035 gnus-mime-details ,gnus-mime-security-button-pressed
7036 article-type annotation
7039 ;; Exclude a newline.
7042 (widget-convert-button
7045 :action 'gnus-widget-press-button
7046 :button-keymap gnus-mime-security-button-map
7048 (lambda (widget/window &optional overlay pos)
7049 ;; Needed to properly clear the message due to a bug in
7050 ;; wid-edit (XEmacs only).
7051 (when (boundp 'help-echo-owns-message)
7052 (setq help-echo-owns-message t))
7055 (aref gnus-mouse-2 0))))))
7057 (defun gnus-mime-display-security (handle)
7059 (narrow-to-region (point) (point))
7060 (unless (gnus-unbuttonized-mime-type-p (car handle))
7061 (gnus-insert-mime-security-button handle))
7062 (gnus-mime-display-mixed (cdr handle))
7065 (unless (gnus-unbuttonized-mime-type-p (car handle))
7066 (let ((gnus-mime-security-button-line-format
7067 gnus-mime-security-button-end-line-format))
7068 (gnus-insert-mime-security-button handle)))
7069 (mm-set-handle-multipart-parameter
7071 (cons (set-marker (make-marker) (point-min))
7072 (set-marker (make-marker) (point-max))))))
7078 (run-hooks 'gnus-art-load-hook)
7080 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7081 ;;; gnus-art.el ends here