1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
49 (autoload 'ansi-color-apply-on-region "ansi-color")
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
115 (concat "^" header ":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type '(choice :custom-show nil
160 :group 'gnus-article-hiding)
162 (defcustom gnus-visible-headers
163 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type '(repeat :value-to-internal (lambda (widget value)
168 (custom-split-regexp-maybe value))
169 :match (lambda (widget value)
171 (widget-editable-list-match widget value)))
173 :group 'gnus-article-hiding)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type '(repeat regexp)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "To identical to To-list." to-list)
203 (const :tag "CC identical to To-list." cc-list)
204 (const :tag "Followup-to identical to Newsgroups." followup-to)
205 (const :tag "Reply-to identical to From." reply-to)
206 (const :tag "Date less than four days old." date)
207 (const :tag "To and/or Cc longer than 1024 characters." long-to)
208 (const :tag "Multiple To and/or Cc headers." many-to))
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
219 :group 'gnus-article-hiding)
221 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
222 "Regexp matching signature separator.
223 This can also be a list of regexps. In that case, it will be checked
224 from head to tail looking for a separator. Searches will be done from
225 the end of the buffer."
226 :type '(repeat string)
227 :group 'gnus-article-signature)
229 (defcustom gnus-signature-limit nil
230 "Provide a limit to what is considered a signature.
231 If it is a number, no signature may not be longer (in characters) than
232 that number. If it is a floating point number, no signature may be
233 longer (in lines) than that number. If it is a function, the function
234 will be called without any parameters, and if it returns nil, there is
235 no signature in the buffer. If it is a string, it will be used as a
236 regexp. If it matches, the text in question is not a signature.
238 This can also be a list of the above values."
239 :type '(choice (integer :value 200)
241 (function :value fun)
242 (regexp :value ".*"))
243 :group 'gnus-article-signature)
245 (defcustom gnus-hidden-properties '(invisible t intangible t)
246 "Property list to use for hiding text."
248 :group 'gnus-article-hiding)
250 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
251 ;; frames in a session.
252 (defcustom gnus-article-x-face-command
253 (if (featurep 'xemacs)
254 (if (or (gnus-image-type-available-p 'xface)
255 (gnus-image-type-available-p 'pbm))
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
258 (if (gnus-image-type-available-p 'pbm)
259 'gnus-display-x-face-in-from
260 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
262 "*String or function to be executed to display an X-Face header.
263 If it is a string, the command will be executed in a sub-shell
264 asynchronously. The compressed face will be piped to this command."
265 :type `(choice string
266 (function-item gnus-display-x-face-in-from)
270 :group 'gnus-article-washing)
272 (defcustom gnus-article-x-face-too-ugly nil
273 "Regexp matching posters whose face shouldn't be shown automatically."
274 :type '(choice regexp (const nil))
275 :group 'gnus-article-washing)
277 (defcustom gnus-article-banner-alist nil
278 "Banner alist for stripping.
280 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
282 :type '(repeat (cons symbol regexp))
283 :group 'gnus-article-washing)
285 (gnus-define-group-parameter
288 "Alist of regexps (to match group names) and banner."
289 :variable-group gnus-article-washing
291 '(choice :tag "Banner"
293 (const :tag "Remove signature" signature)
294 (symbol :tag "Item in `gnus-article-banner-alist'" none)
296 (const :tag "None" nil))
298 "If non-nil, specify how to remove `banners' from articles.
300 Symbol `signature' means to remove signatures delimited by
301 `gnus-signature-separator'. Any other symbol is used to look up a
302 regular expression to match the banner in `gnus-article-banner-alist'.
303 A string is used as a regular expression to match the banner
306 (defcustom gnus-article-address-banner-alist nil
307 "Alist of mail addresses and banners.
308 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
309 to match a mail address in the From: header, BANNER is one of a symbol
310 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
311 If ADDRESS matches author's mail address, it will remove things like
312 advertisements. For example:
314 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
318 (regexp :tag "Address")
319 (choice :tag "Banner" :value nil
320 (const :tag "Remove signature" signature)
321 (symbol :tag "Item in `gnus-article-banner-alist'" none)
323 (const :tag "None" nil))))
324 :group 'gnus-article-washing)
326 (defcustom gnus-emphasis-alist
328 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
333 ("_/" "/_" underline-italic)
334 ("_\\*" "\\*_" underline-bold)
335 ("\\*/" "/\\*" bold-italic)
336 ("_\\*/" "/\\*_" underline-bold-italic))))
340 (format format (car spec) (cadr spec))
341 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
343 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
344 2 3 gnus-emphasis-underline)))
345 "*Alist that says how to fontify certain phrases.
346 Each item looks like this:
348 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
350 The first element is a regular expression to be matched. The second
351 is a number that says what regular expression grouping used to find
352 the entire emphasized word. The third is a number that says what
353 regexp grouping should be displayed and highlighted. The fourth
354 is the face used for highlighting."
355 :type '(repeat (list :value ("" 0 0 default)
357 (integer :tag "Match group")
358 (integer :tag "Emphasize group")
360 :group 'gnus-article-emphasis)
362 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
363 "A regexp to describe whitespace which should not be emphasized.
364 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
365 The former avoids underlining of leading and trailing whitespace,
366 and the latter avoids underlining any whitespace at all."
368 :group 'gnus-article-emphasis
371 (defface gnus-emphasis-bold '((t (:bold t)))
372 "Face used for displaying strong emphasized text (*word*)."
373 :group 'gnus-article-emphasis)
375 (defface gnus-emphasis-italic '((t (:italic t)))
376 "Face used for displaying italic emphasized text (/word/)."
377 :group 'gnus-article-emphasis)
379 (defface gnus-emphasis-underline '((t (:underline t)))
380 "Face used for displaying underlined emphasized text (_word_)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
384 "Face used for displaying underlined bold emphasized text (_*word*_)."
385 :group 'gnus-article-emphasis)
387 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
388 "Face used for displaying underlined italic emphasized text (_/word/_)."
389 :group 'gnus-article-emphasis)
391 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
392 "Face used for displaying bold italic emphasized text (/*word*/)."
393 :group 'gnus-article-emphasis)
395 (defface gnus-emphasis-underline-bold-italic
396 '((t (:bold t :italic t :underline t)))
397 "Face used for displaying underlined bold italic emphasized text.
398 Example: (_/*word*/_)."
399 :group 'gnus-article-emphasis)
401 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
402 '((t (:strikethru t)))
403 '((t (:strike-through t))))
404 "Face used for displaying strike-through text (-word-)."
405 :group 'gnus-article-emphasis)
407 (defface gnus-emphasis-highlight-words
408 '((t (:background "black" :foreground "yellow")))
409 "Face used for displaying highlighted words."
410 :group 'gnus-article-emphasis)
412 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
413 "Format for display of Date headers in article bodies.
414 See `format-time-string' for the possible values.
416 The variable can also be function, which should return a complete Date
417 header. The function is called with one argument, the time, which can
418 be fed to `format-time-string'."
419 :type '(choice string function)
420 :link '(custom-manual "(gnus)Article Date")
421 :group 'gnus-article-washing)
424 (autoload 'mail-extract-address-components "mail-extr"))
426 (defcustom gnus-save-all-headers t
427 "*If non-nil, don't remove any headers before saving."
428 :group 'gnus-article-saving
431 (defcustom gnus-prompt-before-saving 'always
432 "*This variable says how much prompting is to be done when saving articles.
433 If it is nil, no prompting will be done, and the articles will be
434 saved to the default files. If this variable is `always', each and
435 every article that is saved will be preceded by a prompt, even when
436 saving large batches of articles. If this variable is neither nil not
437 `always', there the user will be prompted once for a file name for
438 each invocation of the saving commands."
439 :group 'gnus-article-saving
440 :type '(choice (item always)
441 (item :tag "never" nil)
442 (sexp :tag "once" :format "%t\n" :value t)))
444 (defcustom gnus-saved-headers gnus-visible-headers
445 "Headers to keep if `gnus-save-all-headers' is nil.
446 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
447 If that variable is nil, however, all headers that match this regexp
448 will be kept while the rest will be deleted before saving."
449 :group 'gnus-article-saving
452 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
453 "A function to save articles in your favourite format.
454 The function must be interactively callable (in other words, it must
455 be an Emacs command).
457 Gnus provides the following functions:
459 * gnus-summary-save-in-rmail (Rmail format)
460 * gnus-summary-save-in-mail (Unix mail format)
461 * gnus-summary-save-in-folder (MH folder)
462 * gnus-summary-save-in-file (article format)
463 * gnus-summary-save-body-in-file (article body)
464 * gnus-summary-save-in-vm (use VM's folder format)
465 * gnus-summary-write-to-file (article format -- overwrite)."
466 :group 'gnus-article-saving
467 :type '(radio (function-item gnus-summary-save-in-rmail)
468 (function-item gnus-summary-save-in-mail)
469 (function-item gnus-summary-save-in-folder)
470 (function-item gnus-summary-save-in-file)
471 (function-item gnus-summary-save-body-in-file)
472 (function-item gnus-summary-save-in-vm)
473 (function-item gnus-summary-write-to-file)))
475 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
476 "A function generating a file name to save articles in Rmail format.
477 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
478 :group 'gnus-article-saving
481 (defcustom gnus-mail-save-name 'gnus-plain-save-name
482 "A function generating a file name to save articles in Unix mail format.
483 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
484 :group 'gnus-article-saving
487 (defcustom gnus-folder-save-name 'gnus-folder-save-name
488 "A function generating a file name to save articles in MH folder.
489 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
490 :group 'gnus-article-saving
493 (defcustom gnus-file-save-name 'gnus-numeric-save-name
494 "A function generating a file name to save articles in article format.
495 The function is called with NEWSGROUP, HEADERS, and optional
497 :group 'gnus-article-saving
500 (defcustom gnus-split-methods
501 '((gnus-article-archive-name)
502 (gnus-article-nndoc-name))
503 "*Variable used to suggest where articles are to be saved.
504 For instance, if you would like to save articles related to Gnus in
505 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
506 you could set this variable to something like:
508 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
509 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
511 This variable is an alist where the where the key is the match and the
512 value is a list of possible files to save in if the match is non-nil.
514 If the match is a string, it is used as a regexp match on the
515 article. If the match is a symbol, that symbol will be funcalled
516 from the buffer of the article to be saved with the newsgroup as the
517 parameter. If it is a list, it will be evaled in the same buffer.
519 If this form or function returns a string, this string will be used as
520 a possible file name; and if it returns a non-nil list, that list will
521 be used as possible file names."
522 :group 'gnus-article-saving
523 :type '(repeat (choice (list :value (fun) function)
524 (cons :value ("" "") regexp (repeat string))
527 (defcustom gnus-page-delimiter "^\^L"
528 "*Regexp describing what to use as article page delimiters.
529 The default value is \"^\^L\", which is a form linefeed at the
530 beginning of a line."
532 :group 'gnus-article-various)
534 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
535 "*The format specification for the article mode line.
536 See `gnus-summary-mode-line-format' for a closer description.
538 The following additional specs are available:
540 %w The article washing status.
541 %m The number of MIME parts in the article."
543 :group 'gnus-article-various)
545 (defcustom gnus-article-mode-hook nil
546 "*A hook for Gnus article mode."
548 :group 'gnus-article-various)
550 (when (featurep 'xemacs)
551 ;; Extracted from gnus-xmas-define in order to preserve user settings
552 (when (fboundp 'turn-off-scroll-in-place)
553 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
554 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
555 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
557 (defcustom gnus-article-menu-hook nil
558 "*Hook run after the creation of the article mode menu."
560 :group 'gnus-article-various)
562 (defcustom gnus-article-prepare-hook nil
563 "*A hook called after an article has been prepared in the article buffer."
565 :group 'gnus-article-various)
567 (make-obsolete-variable 'gnus-article-hide-pgp-hook
568 "This variable is obsolete in Gnus 5.10.")
570 (defcustom gnus-article-button-face 'bold
571 "Face used for highlighting buttons in the article buffer.
573 An article button is a piece of text that you can activate by pressing
574 `RET' or `mouse-2' above it."
576 :group 'gnus-article-buttons)
578 (defcustom gnus-article-mouse-face 'highlight
579 "Face used for mouse highlighting in the article buffer.
581 Article buttons will be displayed in this face when the cursor is
584 :group 'gnus-article-buttons)
586 (defcustom gnus-signature-face 'gnus-signature-face
587 "Face used for highlighting a signature in the article buffer.
588 Obsolete; use the face `gnus-signature-face' for customizations instead."
590 :group 'gnus-article-highlight
591 :group 'gnus-article-signature)
593 (defface gnus-signature-face
596 "Face used for highlighting a signature in the article buffer."
597 :group 'gnus-article-highlight
598 :group 'gnus-article-signature)
600 (defface gnus-header-from-face
603 (:foreground "spring green"))
606 (:foreground "red3"))
609 "Face used for displaying from headers."
610 :group 'gnus-article-headers
611 :group 'gnus-article-highlight)
613 (defface gnus-header-subject-face
616 (:foreground "SeaGreen3"))
619 (:foreground "red4"))
621 (:bold t :italic t)))
622 "Face used for displaying subject headers."
623 :group 'gnus-article-headers
624 :group 'gnus-article-highlight)
626 (defface gnus-header-newsgroups-face
629 (:foreground "yellow" :italic t))
632 (:foreground "MidnightBlue" :italic t))
635 "Face used for displaying newsgroups headers.
636 In the default setup this face is only used for crossposted
638 :group 'gnus-article-headers
639 :group 'gnus-article-highlight)
641 (defface gnus-header-name-face
644 (:foreground "SeaGreen"))
647 (:foreground "maroon"))
650 "Face used for displaying header names."
651 :group 'gnus-article-headers
652 :group 'gnus-article-highlight)
654 (defface gnus-header-content-face
657 (:foreground "forest green" :italic t))
660 (:foreground "indianred4" :italic t))
662 (:italic t))) "Face used for displaying header content."
663 :group 'gnus-article-headers
664 :group 'gnus-article-highlight)
666 (defcustom gnus-header-face-alist
667 '(("From" nil gnus-header-from-face)
668 ("Subject" nil gnus-header-subject-face)
669 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
670 ("" gnus-header-name-face gnus-header-content-face))
671 "*Controls highlighting of article headers.
673 An alist of the form (HEADER NAME CONTENT).
675 HEADER is a regular expression which should match the name of a
676 header and NAME and CONTENT are either face names or nil.
678 The name of each header field will be displayed using the face
679 specified by the first element in the list where HEADER matches
680 the header name and NAME is non-nil. Similarly, the content will
681 be displayed by the first non-nil matching CONTENT face."
682 :group 'gnus-article-headers
683 :group 'gnus-article-highlight
684 :type '(repeat (list (regexp :tag "Header")
686 (item :tag "skip" nil)
687 (face :value default))
688 (choice :tag "Content"
689 (item :tag "skip" nil)
690 (face :value default)))))
692 (defcustom gnus-article-decode-hook
693 '(article-decode-charset article-decode-encoded-words
694 article-decode-group-name article-decode-idna-rhs)
695 "*Hook run to decode charsets in articles."
696 :group 'gnus-article-headers
699 (defcustom gnus-display-mime-function 'gnus-display-mime
700 "Function to display MIME articles."
701 :group 'gnus-article-mime
704 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
705 "Function used to decode headers.")
707 (defvar gnus-article-dumbquotes-map
727 "Table for MS-to-Latin1 translation.")
729 (defcustom gnus-ignored-mime-types nil
730 "List of MIME types that should be ignored by Gnus."
732 :group 'gnus-article-mime
733 :type '(repeat regexp))
735 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
736 "List of MIME types that should not be given buttons when rendered inline.
737 See also `gnus-buttonized-mime-types' which may override this variable.
738 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
740 :group 'gnus-article-mime
741 :type '(repeat regexp))
743 (defcustom gnus-buttonized-mime-types nil
744 "List of MIME types that should be given buttons when rendered inline.
745 If set, this variable overrides `gnus-unbuttonized-mime-types'.
746 To see e.g. security buttons you could set this to
747 `(\"multipart/signed\")'.
748 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
750 :group 'gnus-article-mime
751 :type '(repeat regexp))
753 (defcustom gnus-inhibit-mime-unbuttonizing nil
754 "If non-nil, all MIME parts get buttons.
755 When nil (the default value), then some MIME parts do not get buttons,
756 as described by the variables `gnus-buttonized-mime-types' and
757 `gnus-unbuttonized-mime-types'."
759 :group 'gnus-article-mime
762 (defcustom gnus-body-boundary-delimiter "_"
763 "String used to delimit header and body.
764 This variable is used by `gnus-article-treat-body-boundary' which can
765 be controlled by `gnus-treat-body-boundary'."
767 :group 'gnus-article-various
768 :type '(choice (item :tag "None" :value nil)
771 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
773 "Defines the location of the faces database.
774 For information on obtaining this database of pretty pictures, please
775 see http://www.cs.indiana.edu/picons/ftp/index.html"
777 :type '(repeat directory)
778 :link '(url-link :tag "download"
779 "http://www.cs.indiana.edu/picons/ftp/index.html")
780 :link '(custom-manual "(gnus)Picons")
783 (defun gnus-picons-installed-p ()
784 "Say whether picons are installed on your machine."
785 (let ((installed nil))
786 (dolist (database gnus-picon-databases)
787 (when (file-exists-p database)
791 (defcustom gnus-article-mime-part-function nil
792 "Function called with a MIME handle as the argument.
793 This is meant for people who want to do something automatic based
794 on parts -- for instance, adding Vcard info to a database."
795 :group 'gnus-article-mime
798 (defcustom gnus-mime-multipart-functions nil
799 "An alist of MIME types to functions to display them."
801 :group 'gnus-article-mime
802 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
804 (defcustom gnus-article-date-lapsed-new-header nil
805 "Whether the X-Sent and Date headers can coexist.
806 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
807 either replace the old \"Date:\" header (if this variable is nil), or
808 be added below it (otherwise)."
810 :group 'gnus-article-headers
813 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
814 "Function called with a MIME handle as the argument.
815 This is meant for people who want to view first matched part.
816 For `undisplayed-alternative' (default), the first undisplayed
817 part or alternative part is used. For `undisplayed', the first
818 undisplayed part is used. For a function, the first part which
819 the function return t is used. For nil, the first part is
822 :group 'gnus-article-mime
824 (item :tag "first" :value nil)
825 (item :tag "undisplayed" :value undisplayed)
826 (item :tag "undisplayed or alternative"
827 :value undisplayed-alternative)
830 (defcustom gnus-mime-action-alist
831 '(("save to file" . gnus-mime-save-part)
832 ("save and strip" . gnus-mime-save-part-and-strip)
833 ("delete part" . gnus-mime-delete-part)
834 ("display as text" . gnus-mime-inline-part)
835 ("view the part" . gnus-mime-view-part)
836 ("pipe to command" . gnus-mime-pipe-part)
837 ("toggle display" . gnus-article-press-button)
838 ("toggle display" . gnus-article-view-part-as-charset)
839 ("view as type" . gnus-mime-view-part-as-type)
840 ("view internally" . gnus-mime-view-part-internally)
841 ("view externally" . gnus-mime-view-part-externally))
842 "An alist of actions that run on the MIME attachment."
843 :group 'gnus-article-mime
844 :type '(repeat (cons (string :tag "name")
848 ;;; The treatment variables
851 (defvar gnus-part-display-hook nil
852 "Hook called on parts that are to receive treatment.")
854 (defvar gnus-article-treat-custom
855 '(choice (const :tag "Off" nil)
857 (const :tag "Header" head)
858 (const :tag "Last" last)
859 (integer :tag "Less")
860 (repeat :tag "Groups" regexp)
861 (sexp :tag "Predicate")))
863 (defvar gnus-article-treat-head-custom
864 '(choice (const :tag "Off" nil)
865 (const :tag "Header" head)))
867 (defvar gnus-article-treat-types '("text/plain")
870 (defvar gnus-inhibit-treatment nil
871 "Whether to inhibit treatment.")
873 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
874 "Highlight the signature.
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See Info node `(gnus)Customizing Articles'."
877 :group 'gnus-article-treat
878 :link '(custom-manual "(gnus)Customizing Articles")
879 :type gnus-article-treat-custom)
880 (put 'gnus-treat-highlight-signature 'highlight t)
882 (defcustom gnus-treat-buttonize 100000
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles'."
886 :group 'gnus-article-treat
887 :link '(custom-manual "(gnus)Customizing Articles")
888 :type gnus-article-treat-custom)
889 (put 'gnus-treat-buttonize 'highlight t)
891 (defcustom gnus-treat-buttonize-head 'head
892 "Add buttons to the head.
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles' for details."
895 :group 'gnus-article-treat
896 :link '(custom-manual "(gnus)Customizing Articles")
897 :type gnus-article-treat-head-custom)
898 (put 'gnus-treat-buttonize-head 'highlight t)
900 (defcustom gnus-treat-emphasize
901 (and (or window-system
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :link '(custom-manual "(gnus)Customizing Articles")
909 :type gnus-article-treat-custom)
910 (put 'gnus-treat-emphasize 'highlight t)
912 (defcustom gnus-treat-strip-cr nil
913 "Remove carriage returns.
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See Info node `(gnus)Customizing Articles' for details."
917 :group 'gnus-article-treat
918 :link '(custom-manual "(gnus)Customizing Articles")
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-unsplit-urls nil
922 "Remove newlines from within URLs.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles' for details."
925 :group 'gnus-article-treat
926 :link '(custom-manual "(gnus)Customizing Articles")
927 :type gnus-article-treat-custom)
929 (defcustom gnus-treat-leading-whitespace nil
930 "Remove leading whitespace in headers.
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles' for details."
934 :group 'gnus-article-treat
935 :link '(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-hide-headers 'head
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-head-custom)
946 (defcustom gnus-treat-hide-boring-headers nil
947 "Hide boring headers.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles' for details."
950 :group 'gnus-article-treat
951 :link '(custom-manual "(gnus)Customizing Articles")
952 :type gnus-article-treat-head-custom)
954 (defcustom gnus-treat-hide-signature nil
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See Info node `(gnus)Customizing Articles' for details."
958 :group 'gnus-article-treat
959 :link '(custom-manual "(gnus)Customizing Articles")
960 :type gnus-article-treat-custom)
962 (defcustom gnus-treat-fill-article nil
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See Info node `(gnus)Customizing Articles' for details."
966 :group 'gnus-article-treat
967 :link '(custom-manual "(gnus)Customizing Articles")
968 :type gnus-article-treat-custom)
970 (defcustom gnus-treat-hide-citation nil
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See Info node `(gnus)Customizing Articles' for details."
974 :group 'gnus-article-treat
975 :link '(custom-manual "(gnus)Customizing Articles")
976 :type gnus-article-treat-custom)
978 (defcustom gnus-treat-hide-citation-maybe nil
980 Valid values are nil, t, `head', `last', an integer or a predicate.
981 See Info node `(gnus)Customizing Articles' for details."
982 :group 'gnus-article-treat
983 :link '(custom-manual "(gnus)Customizing Articles")
984 :type gnus-article-treat-custom)
986 (defcustom gnus-treat-strip-list-identifiers 'head
987 "Strip list identifiers from `gnus-list-identifiers`.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
995 (make-obsolete-variable 'gnus-treat-strip-pgp
996 "This option is obsolete in Gnus 5.10.")
998 (defcustom gnus-treat-strip-pem nil
999 "Strip PEM signatures.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-custom)
1006 (defcustom gnus-treat-strip-banner t
1007 "Strip banners from articles.
1008 The banner to be stripped is specified in the `banner' group parameter.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1011 :group 'gnus-article-treat
1012 :link '(custom-manual "(gnus)Customizing Articles")
1013 :type gnus-article-treat-custom)
1015 (defcustom gnus-treat-highlight-headers 'head
1016 "Highlight the headers.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-head-custom)
1022 (put 'gnus-treat-highlight-headers 'highlight t)
1024 (defcustom gnus-treat-highlight-citation t
1025 "Highlight cited text.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-custom)
1031 (put 'gnus-treat-highlight-citation 'highlight t)
1033 (defcustom gnus-treat-date-ut nil
1034 "Display the Date in UT (GMT).
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 See Info node `(gnus)Customizing Articles' for details."
1037 :group 'gnus-article-treat
1038 :link '(custom-manual "(gnus)Customizing Articles")
1039 :type gnus-article-treat-head-custom)
1041 (defcustom gnus-treat-date-local nil
1042 "Display the Date in the local timezone.
1043 Valid values are nil, t, `head', `last', an integer or a predicate.
1044 See Info node `(gnus)Customizing Articles' for details."
1045 :group 'gnus-article-treat
1046 :link '(custom-manual "(gnus)Customizing Articles")
1047 :type gnus-article-treat-head-custom)
1049 (defcustom gnus-treat-date-english nil
1050 "Display the Date in a format that can be read aloud in English.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-lapsed nil
1059 "Display the Date header in a way that says how much time has elapsed.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-date-original nil
1067 "Display the date in the original timezone.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :link '(custom-manual "(gnus)Customizing Articles")
1072 :type gnus-article-treat-head-custom)
1074 (defcustom gnus-treat-date-iso8601 nil
1075 "Display the date in the ISO8601 format.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-head-custom)
1083 (defcustom gnus-treat-date-user-defined nil
1084 "Display the date in a user-defined format.
1085 The format is defined by the `gnus-article-time-format' variable.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1088 :group 'gnus-article-treat
1089 :link '(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-head-custom)
1092 (defcustom gnus-treat-strip-headers-in-body t
1093 "Strip the X-No-Archive header line from the beginning of the body.
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-trailing-blank-lines nil
1102 "Strip trailing blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-strip-leading-blank-lines nil
1110 "Strip leading blank lines.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-strip-multiple-blank-lines nil
1118 "Strip multiple blank lines.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-unfold-headers 'head
1126 "Unfold folded header lines.
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-fold-headers nil
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-custom)
1142 (defcustom gnus-treat-fold-newsgroups 'head
1143 "Fold the Newsgroups and Followup-To headers.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 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)
1151 (defcustom gnus-treat-overstrike t
1152 "Treat overstrike highlighting.
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' for details."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-custom)
1158 (put 'gnus-treat-overstrike 'highlight t)
1160 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1161 "Treat ANSI SGR control sequences.
1162 Valid values are nil, t, `head', `last', an integer or a predicate.
1163 See Info node `(gnus)Customizing Articles' for details."
1164 :group 'gnus-article-treat
1165 :link '(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-custom)
1168 (make-obsolete-variable 'gnus-treat-display-xface
1169 'gnus-treat-display-x-face)
1171 (defcustom gnus-treat-display-x-face
1172 (and (not noninteractive)
1173 (or (and (fboundp 'image-type-available-p)
1174 (image-type-available-p 'xbm)
1175 (string-match "^0x" (shell-command-to-string "uncompface"))
1176 (executable-find "icontopbm"))
1177 (and (featurep 'xemacs)
1180 "Display X-Face headers.
1181 Valid values are nil, t, `head', `last', an integer or a predicate.
1182 See Info node `(gnus)Customizing Articles' and Info node
1183 `(gnus)X-Face' for details."
1184 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :link '(custom-manual "(gnus)X-Face")
1188 :type gnus-article-treat-head-custom
1189 :set (lambda (symbol value)
1192 (cond ((or (boundp symbol) (get symbol 'saved-value))
1194 ((boundp 'gnus-treat-display-xface)
1196 ** gnus-treat-display-xface is an obsolete variable;\
1197 use gnus-treat-display-x-face instead")
1198 (default-value 'gnus-treat-display-xface))
1199 ((get 'gnus-treat-display-xface 'saved-value)
1201 ** gnus-treat-display-xface is an obsolete variable;\
1202 use gnus-treat-display-x-face instead")
1203 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1206 (put 'gnus-treat-display-x-face 'highlight t)
1208 (defcustom gnus-treat-display-face
1209 (and (not noninteractive)
1210 (or (and (fboundp 'image-type-available-p)
1211 (image-type-available-p 'png))
1212 (and (featurep 'xemacs)
1215 "Display Face headers.
1216 Valid values are nil, t, `head', `last', an integer or a predicate.
1217 See Info node `(gnus)Customizing Articles' and Info node
1218 `(gnus)X-Face' for details."
1219 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :link '(custom-manual "(gnus)X-Face")
1223 :type gnus-article-treat-head-custom)
1224 (put 'gnus-treat-display-face 'highlight t)
1226 (defcustom gnus-treat-display-smileys
1227 (if (or (and (featurep 'xemacs)
1229 (and (fboundp 'image-type-available-p)
1230 (image-type-available-p 'pbm)))
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' and Info node
1235 `(gnus)Smileys' for details."
1236 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :link '(custom-manual "(gnus)Smileys")
1240 :type gnus-article-treat-custom)
1241 (put 'gnus-treat-display-smileys 'highlight t)
1243 (defcustom gnus-treat-from-picon
1244 (if (and (gnus-image-type-available-p 'xpm)
1245 (gnus-picons-installed-p))
1247 "Display picons in the From header.
1248 Valid values are nil, t, `head', `last', an integer or a predicate.
1249 See Info node `(gnus)Customizing Articles' and Info node
1250 `(gnus)Picons' for details."
1251 :group 'gnus-article-treat
1253 :link '(custom-manual "(gnus)Customizing Articles")
1254 :link '(custom-manual "(gnus)Picons")
1255 :type gnus-article-treat-head-custom)
1256 (put 'gnus-treat-from-picon 'highlight t)
1258 (defcustom gnus-treat-mail-picon
1259 (if (and (gnus-image-type-available-p 'xpm)
1260 (gnus-picons-installed-p))
1262 "Display picons in To and Cc headers.
1263 Valid values are nil, t, `head', `last', an integer or a predicate.
1264 See Info node `(gnus)Customizing Articles' and Info node
1265 `(gnus)Picons' for details."
1266 :group 'gnus-article-treat
1268 :link '(custom-manual "(gnus)Customizing Articles")
1269 :link '(custom-manual "(gnus)Picons")
1270 :type gnus-article-treat-head-custom)
1271 (put 'gnus-treat-mail-picon 'highlight t)
1273 (defcustom gnus-treat-newsgroups-picon
1274 (if (and (gnus-image-type-available-p 'xpm)
1275 (gnus-picons-installed-p))
1277 "Display picons in the Newsgroups and Followup-To headers.
1278 Valid values are nil, t, `head', `last', an integer or a predicate.
1279 See Info node `(gnus)Customizing Articles' and Info node
1280 `(gnus)Picons' for details."
1282 :group 'gnus-article-treat
1284 :link '(custom-manual "(gnus)Customizing Articles")
1285 :link '(custom-manual "(gnus)Picons")
1286 :type gnus-article-treat-head-custom)
1287 (put 'gnus-treat-newsgroups-picon 'highlight t)
1289 (defcustom gnus-treat-body-boundary
1290 (if (and (eq window-system 'x)
1291 (or gnus-treat-newsgroups-picon
1292 gnus-treat-mail-picon
1293 gnus-treat-from-picon))
1295 "Draw a boundary at the end of the headers.
1296 Valid values are nil and `head'.
1297 See Info node `(gnus)Customizing Articles' for details."
1299 :group 'gnus-article-treat
1300 :link '(custom-manual "(gnus)Customizing Articles")
1301 :type gnus-article-treat-head-custom)
1303 (defcustom gnus-treat-capitalize-sentences nil
1304 "Capitalize sentence-starting words.
1305 Valid values are nil, t, `head', `last', an integer or a predicate.
1306 See Info node `(gnus)Customizing Articles' for details."
1308 :group 'gnus-article-treat
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :type gnus-article-treat-custom)
1312 (defcustom gnus-treat-wash-html nil
1314 Valid values are nil, t, `head', `last', an integer or a predicate.
1315 See Info node `(gnus)Customizing Articles' for details."
1317 :group 'gnus-article-treat
1318 :link '(custom-manual "(gnus)Customizing Articles")
1319 :type gnus-article-treat-custom)
1321 (defcustom gnus-treat-fill-long-lines nil
1323 Valid values are nil, t, `head', `last', an integer or a predicate.
1324 See Info node `(gnus)Customizing Articles' for details."
1325 :group 'gnus-article-treat
1326 :link '(custom-manual "(gnus)Customizing Articles")
1327 :type gnus-article-treat-custom)
1329 (defcustom gnus-treat-play-sounds nil
1331 Valid values are nil, t, `head', `last', an integer or a predicate.
1332 See Info node `(gnus)Customizing Articles' for details."
1334 :group 'gnus-article-treat
1335 :link '(custom-manual "(gnus)Customizing Articles")
1336 :type gnus-article-treat-custom)
1338 (defcustom gnus-treat-translate nil
1339 "Translate articles from one language to another.
1340 Valid values are nil, t, `head', `last', an integer or a predicate.
1341 See Info node `(gnus)Customizing Articles' for details."
1343 :group 'gnus-article-treat
1344 :link '(custom-manual "(gnus)Customizing Articles")
1345 :type gnus-article-treat-custom)
1347 (defcustom gnus-treat-x-pgp-sig nil
1349 To automatically treat X-PGP-Sig, set it to head.
1350 Valid values are nil, t, `head', `last', an integer or a predicate.
1351 See Info node `(gnus)Customizing Articles' for details."
1352 :group 'gnus-article-treat
1353 :group 'mime-security
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :type gnus-article-treat-custom)
1357 (defvar gnus-article-encrypt-protocol-alist
1358 '(("PGP" . mml2015-self-encrypt)))
1360 ;; Set to nil if more than one protocol added to
1361 ;; gnus-article-encrypt-protocol-alist.
1362 (defcustom gnus-article-encrypt-protocol "PGP"
1363 "The protocol used for encrypt articles.
1364 It is a string, such as \"PGP\". If nil, ask user."
1367 :group 'mime-security)
1369 (defvar gnus-article-wash-function nil
1370 "Function used for converting HTML into text.")
1372 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1373 (mm-coding-system-p 'utf-8)
1374 (executable-find idna-program))
1375 "Whether IDNA decoding of headers is used when viewing messages.
1376 This requires GNU Libidn, and by default only enabled if it is found."
1378 :group 'gnus-article-headers
1381 (defcustom gnus-article-over-scroll nil
1382 "If non-nil, allow scrolling the article buffer even when there no more text."
1384 :group 'gnus-article
1387 ;;; Internal variables
1389 (defvar gnus-english-month-names
1390 '("January" "February" "March" "April" "May" "June" "July" "August"
1391 "September" "October" "November" "December"))
1393 (defvar gnus-button-regexp nil)
1394 (defvar gnus-button-marker-list nil)
1395 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1397 (defvar gnus-button-last nil)
1398 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1400 (defvar article-goto-body-goes-to-point-min-p nil)
1401 (defvar gnus-article-wash-types nil)
1402 (defvar gnus-article-emphasis-alist nil)
1403 (defvar gnus-article-image-alist nil)
1405 (defvar gnus-article-mime-handle-alist-1 nil)
1406 (defvar gnus-treatment-function-alist
1407 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1408 (gnus-treat-strip-banner gnus-article-strip-banner)
1409 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1410 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1411 (gnus-treat-buttonize gnus-article-add-buttons)
1412 (gnus-treat-fill-article gnus-article-fill-cited-article)
1413 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1414 (gnus-treat-strip-cr gnus-article-remove-cr)
1415 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1416 (gnus-treat-date-ut gnus-article-date-ut)
1417 (gnus-treat-date-local gnus-article-date-local)
1418 (gnus-treat-date-english gnus-article-date-english)
1419 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1420 (gnus-treat-date-original gnus-article-date-original)
1421 (gnus-treat-date-user-defined gnus-article-date-user)
1422 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1423 (gnus-treat-display-x-face gnus-article-display-x-face)
1424 (gnus-treat-display-face gnus-article-display-face)
1425 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1426 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1427 (gnus-treat-hide-signature gnus-article-hide-signature)
1428 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1429 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1430 (gnus-treat-strip-pem gnus-article-hide-pem)
1431 (gnus-treat-from-picon gnus-treat-from-picon)
1432 (gnus-treat-mail-picon gnus-treat-mail-picon)
1433 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1434 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1435 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1436 (gnus-treat-strip-trailing-blank-lines
1437 gnus-article-remove-trailing-blank-lines)
1438 (gnus-treat-strip-leading-blank-lines
1439 gnus-article-strip-leading-blank-lines)
1440 (gnus-treat-strip-multiple-blank-lines
1441 gnus-article-strip-multiple-blank-lines)
1442 (gnus-treat-overstrike gnus-article-treat-overstrike)
1443 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1444 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1445 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1446 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1447 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1448 (gnus-treat-display-smileys gnus-treat-smiley)
1449 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1450 (gnus-treat-wash-html gnus-article-wash-html)
1451 (gnus-treat-emphasize gnus-article-emphasize)
1452 (gnus-treat-hide-citation gnus-article-hide-citation)
1453 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1454 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1455 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1456 (gnus-treat-play-sounds gnus-earcon-display)))
1458 (defvar gnus-article-mime-handle-alist nil)
1459 (defvar article-lapsed-timer nil)
1460 (defvar gnus-article-current-summary nil)
1462 (defvar gnus-article-mode-syntax-table
1463 (let ((table (copy-syntax-table text-mode-syntax-table)))
1464 ;; This causes the citation match run O(2^n).
1465 ;; (modify-syntax-entry ?- "w" table)
1466 (modify-syntax-entry ?> ")<" table)
1467 (modify-syntax-entry ?< "(>" table)
1468 ;; make M-. in article buffers work for `foo' strings
1469 (modify-syntax-entry ?' " " table)
1470 (modify-syntax-entry ?` " " table)
1472 "Syntax table used in article mode buffers.
1473 Initialized from `text-mode-syntax-table.")
1475 (defvar gnus-save-article-buffer nil)
1477 (defvar gnus-article-mode-line-format-alist
1478 (nconc '((?w (gnus-article-wash-status) ?s)
1479 (?m (gnus-article-mime-part-status) ?s))
1480 gnus-summary-mode-line-format-alist))
1482 (defvar gnus-number-of-articles-to-be-saved nil)
1484 (defvar gnus-inhibit-hiding nil)
1486 (defvar gnus-article-edit-mode nil)
1488 ;;; Macros for dealing with the article buffer.
1490 (defmacro gnus-with-article-headers (&rest forms)
1492 (set-buffer gnus-article-buffer)
1494 (let ((inhibit-read-only t)
1495 (inhibit-point-motion-hooks t)
1496 (case-fold-search t))
1497 (article-narrow-to-head)
1500 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1501 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1503 (defmacro gnus-with-article-buffer (&rest forms)
1505 (set-buffer gnus-article-buffer)
1506 (let ((inhibit-read-only t))
1509 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1510 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1512 (defun gnus-article-goto-header (header)
1513 "Go to HEADER, which is a regular expression."
1514 (re-search-forward (concat "^\\(" header "\\):") nil t))
1516 (defsubst gnus-article-hide-text (b e props)
1517 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1518 (gnus-add-text-properties-when 'article-type nil b e props)
1519 (when (memq 'intangible props)
1521 (max (1- b) (point-min))
1522 b 'intangible (cddr (memq 'intangible props)))))
1524 (defsubst gnus-article-unhide-text (b e)
1525 "Remove hidden text properties from region between B and E."
1526 (remove-text-properties b e gnus-hidden-properties)
1527 (when (memq 'intangible gnus-hidden-properties)
1528 (put-text-property (max (1- b) (point-min))
1529 b 'intangible nil)))
1531 (defun gnus-article-hide-text-type (b e type)
1532 "Hide text of TYPE between B and E."
1533 (gnus-add-wash-type type)
1534 (gnus-article-hide-text
1535 b e (cons 'article-type (cons type gnus-hidden-properties))))
1537 (defun gnus-article-unhide-text-type (b e type)
1538 "Unhide text of TYPE between B and E."
1539 (gnus-delete-wash-type type)
1540 (remove-text-properties
1541 b e (cons 'article-type (cons type gnus-hidden-properties)))
1542 (when (memq 'intangible gnus-hidden-properties)
1543 (put-text-property (max (1- b) (point-min))
1544 b 'intangible nil)))
1546 (defun gnus-article-hide-text-of-type (type)
1547 "Hide text of TYPE in the current buffer."
1549 (let ((b (point-min))
1551 (while (setq b (text-property-any b e 'article-type type))
1552 (add-text-properties b (incf b) gnus-hidden-properties)))))
1554 (defun gnus-article-delete-text-of-type (type)
1555 "Delete text of TYPE in the current buffer."
1557 (let ((b (point-min)))
1558 (while (setq b (text-property-any b (point-max) 'article-type type))
1560 b (or (text-property-not-all b (point-max) 'article-type type)
1563 (defun gnus-article-delete-invisible-text ()
1564 "Delete all invisible text in the current buffer."
1566 (let ((b (point-min)))
1567 (while (setq b (text-property-any b (point-max) 'invisible t))
1569 b (or (text-property-not-all b (point-max) 'invisible t)
1572 (defun gnus-article-text-type-exists-p (type)
1573 "Say whether any text of type TYPE exists in the buffer."
1574 (text-property-any (point-min) (point-max) 'article-type type))
1576 (defsubst gnus-article-header-rank ()
1577 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1578 (let ((list gnus-sorted-header-list)
1581 (if (looking-at (car list))
1583 (setq list (cdr list))
1587 (defun article-hide-headers (&optional arg delete)
1588 "Hide unwanted headers and possibly sort them as well."
1590 ;; This function might be inhibited.
1591 (unless gnus-inhibit-hiding
1592 (let ((inhibit-read-only nil)
1593 (case-fold-search t)
1594 (max (1+ (length gnus-sorted-header-list)))
1595 (inhibit-point-motion-hooks t)
1596 (cur (current-buffer))
1597 ignored visible beg)
1599 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1600 ;; group parameters, so we should go to the summary buffer.
1603 (progn (set-buffer gnus-summary-buffer) t)
1605 (setq ignored (when (not gnus-visible-headers)
1606 (cond ((stringp gnus-ignored-headers)
1607 gnus-ignored-headers)
1608 ((listp gnus-ignored-headers)
1609 (mapconcat 'identity
1610 gnus-ignored-headers
1612 visible (cond ((stringp gnus-visible-headers)
1613 gnus-visible-headers)
1614 ((and gnus-visible-headers
1615 (listp gnus-visible-headers))
1616 (mapconcat 'identity
1617 gnus-visible-headers
1621 ;; First we narrow to just the headers.
1622 (article-narrow-to-head)
1623 ;; Hide any "From " lines at the beginning of (mail) articles.
1624 (while (looking-at "From ")
1627 (delete-region (point-min) (point)))
1628 ;; Then treat the rest of the header lines.
1629 ;; Then we use the two regular expressions
1630 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1631 ;; select which header lines is to remain visible in the
1633 (while (re-search-forward "^[^ \t:]*:" nil t)
1635 ;; Mark the rank of the header.
1637 (point) (1+ (point)) 'message-rank
1638 (if (or (and visible (looking-at visible))
1640 (not (looking-at ignored))))
1641 (gnus-article-header-rank)
1644 (message-sort-headers-1)
1645 (when (setq beg (text-property-any
1646 (point-min) (point-max) 'message-rank (+ 2 max)))
1647 ;; We delete the unwanted headers.
1648 (gnus-add-wash-type 'headers)
1649 (add-text-properties (point-min) (+ 5 (point-min))
1650 '(article-type headers dummy-invisible t))
1651 (delete-region beg (point-max))))))))
1653 (defun article-hide-boring-headers (&optional arg)
1654 "Toggle hiding of headers that aren't very interesting.
1655 If given a negative prefix, always show; if given a positive prefix,
1657 (interactive (gnus-article-hidden-arg))
1658 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1659 (not gnus-show-all-headers))
1662 (let ((inhibit-read-only t)
1663 (inhibit-point-motion-hooks t))
1664 (article-narrow-to-head)
1665 (dolist (elem gnus-boring-article-headers)
1666 (goto-char (point-min))
1668 ;; Hide empty headers.
1670 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1672 (gnus-article-hide-text-type
1676 (if (re-search-forward "^[^ \t]" nil t)
1680 ;; Hide boring Newsgroups header.
1681 ((eq elem 'newsgroups)
1682 (when (gnus-string-equal
1683 (gnus-fetch-field "newsgroups")
1684 (gnus-group-real-name
1685 (if (boundp 'gnus-newsgroup-name)
1688 (gnus-article-hide-header "newsgroups")))
1689 ((eq elem 'to-address)
1690 (let ((to (message-fetch-field "to"))
1692 (gnus-parameter-to-address
1693 (if (boundp 'gnus-newsgroup-name)
1694 gnus-newsgroup-name ""))))
1695 (when (and to to-address
1698 ;; only one address in To
1699 (nth 1 (mail-extract-address-components to))
1701 (gnus-article-hide-header "to"))))
1703 (let ((to (message-fetch-field "to"))
1705 (gnus-parameter-to-list
1706 (if (boundp 'gnus-newsgroup-name)
1707 gnus-newsgroup-name ""))))
1708 (when (and to to-list
1711 ;; only one address in To
1712 (nth 1 (mail-extract-address-components to))
1714 (gnus-article-hide-header "to"))))
1716 (let ((cc (message-fetch-field "cc"))
1718 (gnus-parameter-to-list
1719 (if (boundp 'gnus-newsgroup-name)
1720 gnus-newsgroup-name ""))))
1721 (when (and cc to-list
1724 ;; only one address in CC
1725 (nth 1 (mail-extract-address-components cc))
1727 (gnus-article-hide-header "cc"))))
1728 ((eq elem 'followup-to)
1729 (when (gnus-string-equal
1730 (message-fetch-field "followup-to")
1731 (message-fetch-field "newsgroups"))
1732 (gnus-article-hide-header "followup-to")))
1733 ((eq elem 'reply-to)
1734 (if (gnus-group-find-parameter
1735 gnus-newsgroup-name 'broken-reply-to)
1736 (gnus-article-hide-header "reply-to")
1737 (let ((from (message-fetch-field "from"))
1738 (reply-to (message-fetch-field "reply-to")))
1745 (lambda (x) (downcase (cadr x)))
1746 (mail-extract-address-components from t))
1749 (lambda (x) (downcase (cadr x)))
1750 (mail-extract-address-components reply-to t))
1752 (gnus-article-hide-header "reply-to")))))
1754 (let ((date (message-fetch-field "date")))
1756 (< (days-between (current-time-string) date)
1758 (gnus-article-hide-header "date"))))
1760 (let ((to (message-fetch-field "to"))
1761 (cc (message-fetch-field "cc")))
1762 (when (> (length to) 1024)
1763 (gnus-article-hide-header "to"))
1764 (when (> (length cc) 1024)
1765 (gnus-article-hide-header "cc"))))
1769 (goto-char (point-min))
1770 (while (re-search-forward "^to:" nil t)
1771 (setq to-count (1+ to-count)))
1772 (when (> to-count 1)
1773 (while (> to-count 0)
1774 (goto-char (point-min))
1776 (re-search-forward "^to:" nil nil to-count)
1778 (narrow-to-region (point) (point-max))
1779 (gnus-article-hide-header "to"))
1780 (setq to-count (1- to-count))))
1781 (goto-char (point-min))
1782 (while (re-search-forward "^cc:" nil t)
1783 (setq cc-count (1+ cc-count)))
1784 (when (> cc-count 1)
1785 (while (> cc-count 0)
1786 (goto-char (point-min))
1788 (re-search-forward "^cc:" nil nil cc-count)
1790 (narrow-to-region (point) (point-max))
1791 (gnus-article-hide-header "cc"))
1792 (setq cc-count (1- cc-count)))))))))))))
1794 (defun gnus-article-hide-header (header)
1796 (goto-char (point-min))
1797 (when (re-search-forward (concat "^" header ":") nil t)
1798 (gnus-article-hide-text-type
1802 (if (re-search-forward "^[^ \t]" nil t)
1807 (defvar gnus-article-normalized-header-length 40
1808 "Length of normalized headers.")
1810 (defun article-normalize-headers ()
1811 "Make all header lines 40 characters long."
1813 (let ((inhibit-read-only t)
1817 (article-narrow-to-head)
1820 ((< (setq column (- (point-at-eol) (point)))
1821 gnus-article-normalized-header-length)
1823 (insert (make-string
1824 (- gnus-article-normalized-header-length column)
1826 ((> column gnus-article-normalized-header-length)
1827 (gnus-put-text-property
1829 (forward-char gnus-article-normalized-header-length)
1836 (forward-line 1))))))
1838 (defun article-treat-dumbquotes ()
1839 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1840 Note that this function guesses whether a character is a sm*rtq**t* or
1841 not, so it should only be used interactively.
1843 Sm*rtq**t*s are M****s***'s unilateral extension to the
1844 iso-8859-1 character map in an attempt to provide more quoting
1845 characters. If you see something like \\222 or \\264 where
1846 you're expecting some kind of apostrophe or quotation mark, then
1849 (article-translate-strings gnus-article-dumbquotes-map))
1851 (defun article-translate-characters (from to)
1852 "Translate all characters in the body of the article according to FROM and TO.
1853 FROM is a string of characters to translate from; to is a string of
1854 characters to translate to."
1856 (when (article-goto-body)
1857 (let ((inhibit-read-only t)
1858 (x (make-string 225 ?x))
1860 (while (< (incf i) (length x))
1863 (while (< i (length from))
1864 (aset x (aref from i) (aref to i))
1866 (translate-region (point) (point-max) x)))))
1868 (defun article-translate-strings (map)
1869 "Translate all string in the body of the article according to MAP.
1870 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1872 (when (article-goto-body)
1873 (let ((inhibit-read-only t))
1876 (while (search-forward (car elem) nil t)
1877 (replace-match (cadr elem)))))))))
1879 (defun article-treat-overstrike ()
1880 "Translate overstrikes into bold text."
1883 (when (article-goto-body)
1884 (let ((inhibit-read-only t))
1885 (while (search-forward "\b" nil t)
1886 (let ((next (char-after))
1887 (previous (char-after (- (point) 2))))
1888 ;; We do the boldification/underlining by hiding the
1889 ;; overstrikes and putting the proper text property
1893 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1894 (put-text-property (point) (1+ (point)) 'face 'bold))
1896 (gnus-article-hide-text-type
1897 (1- (point)) (1+ (point)) 'overstrike)
1899 (- (point) 2) (1- (point)) 'face 'underline))
1901 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1903 (point) (1+ (point)) 'face 'underline)))))))))
1905 (defun article-treat-ansi-sequences ()
1906 "Translate ANSI SGR control sequences into overlays or extents."
1909 (when (article-goto-body)
1910 (let ((inhibit-read-only t))
1911 (ansi-color-apply-on-region (point) (point-max))))))
1913 (defun gnus-article-treat-unfold-headers ()
1914 "Unfold folded message headers.
1915 Only the headers that fit into the current window width will be
1918 (gnus-with-article-headers
1922 (mail-header-narrow-to-field)
1923 (let ((header (buffer-string)))
1926 (goto-char (point-min))
1927 (while (re-search-forward "\n[\t ]" nil t)
1928 (replace-match " " t t)))
1929 (setq length (- (point-max) (point-min) 1)))
1930 (when (< length (window-width))
1931 (while (re-search-forward "\n[\t ]" nil t)
1932 (replace-match " " t t)))
1933 (goto-char (point-max)))))))
1935 (defun gnus-article-treat-fold-headers ()
1936 "Fold message headers."
1938 (gnus-with-article-headers
1941 (mail-header-narrow-to-field)
1942 (mail-header-fold-field)
1943 (goto-char (point-max))))))
1945 (defun gnus-treat-smiley ()
1946 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1948 (gnus-with-article-buffer
1949 (if (memq 'smiley gnus-article-wash-types)
1950 (gnus-delete-images 'smiley)
1952 (let ((images (smiley-region (point) (point-max))))
1954 (gnus-add-wash-type 'smiley)
1955 (dolist (image images)
1956 (gnus-add-image 'smiley image)))))))
1958 (defun gnus-article-remove-images ()
1959 "Remove all images from the article buffer."
1961 (gnus-with-article-buffer
1962 (dolist (elem gnus-article-image-alist)
1963 (gnus-delete-images (car elem)))))
1965 (defun gnus-article-treat-fold-newsgroups ()
1966 "Unfold folded message headers.
1967 Only the headers that fit into the current window width will be
1970 (gnus-with-article-headers
1971 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1973 (mail-header-narrow-to-field)
1974 (while (re-search-forward ", *" nil t)
1975 (replace-match ", " t t))
1976 (mail-header-fold-field)
1977 (goto-char (point-max))))))
1979 (defun gnus-article-treat-body-boundary ()
1980 "Place a boundary line at the end of the headers."
1982 (when (and gnus-body-boundary-delimiter
1983 (> (length gnus-body-boundary-delimiter) 0))
1984 (gnus-with-article-headers
1985 (goto-char (point-max))
1986 (let ((start (point)))
1987 (insert "X-Boundary: ")
1988 (gnus-add-text-properties start (point) '(invisible t intangible t))
1990 (while (>= (1- (window-width)) (length str))
1991 (setq str (concat str gnus-body-boundary-delimiter)))
1992 (substring str 0 (1- (window-width))))
1994 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1996 (defun article-fill-long-lines ()
1997 "Fill lines that are wider than the window width."
2000 (let ((inhibit-read-only t)
2001 (width (window-width (get-buffer-window (current-buffer)))))
2004 (let ((adaptive-fill-mode nil)) ;Why? -sm
2007 (when (>= (current-column) (min fill-column width))
2008 (narrow-to-region (min (1+ (point)) (point-max))
2010 (let ((goback (point-marker)))
2011 (fill-paragraph nil)
2012 (goto-char (marker-position goback)))
2014 (forward-line 1)))))))
2016 (defun article-capitalize-sentences ()
2017 "Capitalize the first word in each sentence."
2020 (let ((inhibit-read-only t)
2021 (paragraph-start "^[\n\^L]"))
2025 (forward-sentence)))))
2027 (defun article-remove-cr ()
2028 "Remove trailing CRs and then translate remaining CRs into LFs."
2031 (let ((inhibit-read-only t))
2032 (goto-char (point-min))
2033 (while (re-search-forward "\r+$" nil t)
2034 (replace-match "" t t))
2035 (goto-char (point-min))
2036 (while (search-forward "\r" nil t)
2037 (replace-match "\n" t t)))))
2039 (defun article-remove-trailing-blank-lines ()
2040 "Remove all trailing blank lines from the article."
2043 (let ((inhibit-read-only t))
2044 (goto-char (point-max))
2048 (while (and (not (bobp))
2049 (looking-at "^[ \t]*$")
2050 (not (gnus-annotation-in-region-p
2051 (point) (point-at-eol))))
2057 (defvar gnus-face-properties-alist))
2059 (defun article-display-face ()
2060 "Display any Face headers in the header."
2062 (let ((wash-face-p buffer-read-only))
2063 (gnus-with-article-headers
2064 ;; When displaying parts, this function can be called several times on
2065 ;; the same article, without any intended toggle semantic (as typing `W
2066 ;; D d' would have). So face deletion must occur only when we come from
2067 ;; an interactive command, that is when the *Article* buffer is
2069 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2070 (gnus-delete-images 'face)
2073 (when (and wash-face-p
2075 (goto-char (point-min))
2076 (not (re-search-forward "^Face:[\t ]*" nil t)))
2077 (gnus-buffer-live-p gnus-original-article-buffer))
2078 (set-buffer gnus-original-article-buffer))
2080 (mail-narrow-to-head)
2081 (while (gnus-article-goto-header "Face")
2082 (setq faces (nconc faces (list (mail-header-field-value)))))))
2083 (dolist (face faces)
2084 (let ((png (gnus-convert-face-to-png face))
2088 (apply 'gnus-create-image png 'png t
2089 (cdr (assq 'png gnus-face-properties-alist))))
2090 (gnus-article-goto-header "from")
2092 (insert "From: [no `from' set]\n")
2094 (gnus-add-wash-type 'face)
2095 (gnus-add-image 'face image)
2096 (gnus-put-image image nil 'face))))))
2099 (defun article-display-x-face (&optional force)
2100 "Look for an X-Face header and display it if present."
2101 (interactive (list 'force))
2102 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2103 (gnus-with-article-headers
2104 ;; Delete the old process, if any.
2105 (when (process-status "article-x-face")
2106 (delete-process "article-x-face"))
2107 ;; See the comment in `article-display-face'.
2108 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2109 ;; We have already displayed X-Faces, so we remove them
2111 (gnus-delete-images 'xface)
2113 (let (x-faces from face)
2115 (when (and wash-face-p
2117 (goto-char (point-min))
2118 (not (re-search-forward
2119 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2120 (gnus-buffer-live-p gnus-original-article-buffer))
2121 ;; If type `W f', use gnus-original-article-buffer,
2122 ;; otherwise use the current buffer because displaying
2123 ;; RFC822 parts calls this function too.
2124 (set-buffer gnus-original-article-buffer))
2126 (mail-narrow-to-head)
2127 (while (gnus-article-goto-header "X-Face")
2128 (push (mail-header-field-value) x-faces))
2129 (setq from (message-fetch-field "from"))))
2130 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2131 ;; single external face.
2132 (when (stringp gnus-article-x-face-command)
2133 (setq x-faces (list (car x-faces))))
2134 (while (and (setq face (pop x-faces))
2135 gnus-article-x-face-command
2137 ;; Check whether this face is censored.
2138 (not gnus-article-x-face-too-ugly)
2139 (and gnus-article-x-face-too-ugly from
2140 (not (string-match gnus-article-x-face-too-ugly
2142 ;; We display the face.
2143 (cond ((stringp gnus-article-x-face-command)
2144 ;; The command is a string, so we interpret the command
2145 ;; as a, well, command, and fork it off.
2146 (let ((process-connection-type nil))
2147 (process-kill-without-query
2149 "article-x-face" nil shell-file-name
2150 shell-command-switch gnus-article-x-face-command))
2153 (process-send-region "article-x-face"
2154 (point-min) (point-max)))
2155 (process-send-eof "article-x-face")))
2156 ((functionp gnus-article-x-face-command)
2157 ;; The command is a lisp function, so we call it.
2158 (funcall gnus-article-x-face-command face))
2160 (error "%s is not a function"
2161 gnus-article-x-face-command)))))))))
2163 (defun article-decode-mime-words ()
2164 "Decode all MIME-encoded words in the article."
2166 (gnus-with-article-buffer
2167 (let ((inhibit-point-motion-hooks t)
2168 (mail-parse-charset gnus-newsgroup-charset)
2169 (mail-parse-ignored-charsets
2170 (with-current-buffer gnus-summary-buffer
2171 gnus-newsgroup-ignored-charsets)))
2172 (mail-decode-encoded-word-region (point-min) (point-max)))))
2174 (defun article-decode-charset (&optional prompt)
2175 "Decode charset-encoded text in the article.
2176 If PROMPT (the prefix), prompt for a coding system to use."
2178 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2179 (inhibit-read-only t)
2180 (mail-parse-charset gnus-newsgroup-charset)
2181 (mail-parse-ignored-charsets
2182 (save-excursion (condition-case nil
2183 (set-buffer gnus-summary-buffer)
2185 gnus-newsgroup-ignored-charsets))
2186 ct cte ctl charset format)
2189 (article-narrow-to-head)
2190 (setq ct (message-fetch-field "Content-Type" t)
2191 cte (message-fetch-field "Content-Transfer-Encoding" t)
2192 ctl (and ct (ignore-errors
2193 (mail-header-parse-content-type ct)))
2196 (mm-read-coding-system "Charset to decode: "))
2198 (mail-content-type-get ctl 'charset)))
2199 format (and ctl (mail-content-type-get ctl 'format)))
2201 (setq cte (mail-header-strip cte)))
2202 (if (and ctl (not (string-match "/" (car ctl))))
2204 (goto-char (point-max)))
2207 (narrow-to-region (point) (point-max))
2208 (when (and (eq mail-parse-charset 'gnus-decoded)
2209 (eq (mm-body-7-or-8) '8bit))
2210 ;; The text code could have been decoded.
2211 (setq charset mail-parse-charset))
2212 (when (and (or (not ctl)
2213 (equal (car ctl) "text/plain"))
2214 (not format)) ;; article with format will decode later.
2216 charset (and cte (intern (downcase
2217 (gnus-strip-whitespace cte))))
2220 (defun article-decode-encoded-words ()
2221 "Remove encoded-word encoding from headers."
2222 (let ((inhibit-point-motion-hooks t)
2223 (mail-parse-charset gnus-newsgroup-charset)
2224 (mail-parse-ignored-charsets
2225 (save-excursion (condition-case nil
2226 (set-buffer gnus-summary-buffer)
2228 gnus-newsgroup-ignored-charsets))
2229 (inhibit-read-only t))
2231 (article-narrow-to-head)
2232 (funcall gnus-decode-header-function (point-min) (point-max)))))
2234 (defun article-decode-group-name ()
2235 "Decode group names in `Newsgroups:'."
2236 (let ((inhibit-point-motion-hooks t)
2237 (inhibit-read-only t)
2238 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2239 (when (and (or gnus-group-name-charset-method-alist
2240 gnus-group-name-charset-group-alist)
2241 (gnus-buffer-live-p gnus-original-article-buffer))
2243 (article-narrow-to-head)
2244 (with-current-buffer gnus-original-article-buffer
2245 (goto-char (point-min)))
2246 (while (re-search-forward
2247 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2248 (replace-match (save-match-data
2249 (gnus-decode-newsgroups
2250 ;; XXX how to use data in article buffer?
2251 (with-current-buffer gnus-original-article-buffer
2253 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2256 gnus-newsgroup-name method))
2258 (goto-char (point-min))
2259 (with-current-buffer gnus-original-article-buffer
2260 (goto-char (point-min)))
2261 (while (re-search-forward
2262 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2263 (replace-match (save-match-data
2264 (gnus-decode-newsgroups
2265 ;; XXX how to use data in article buffer?
2266 (with-current-buffer gnus-original-article-buffer
2268 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2271 gnus-newsgroup-name method))
2274 (autoload 'idna-to-unicode "idna")
2276 (defun article-decode-idna-rhs ()
2277 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2280 (let ((inhibit-point-motion-hooks t)
2281 (inhibit-read-only t))
2282 (article-narrow-to-head)
2283 (goto-char (point-min))
2284 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2286 (when (save-match-data
2287 (and (setq ace (match-string 1))
2289 (and (re-search-backward "^[^ \t]" nil t)
2290 (looking-at "From\\|To\\|Cc")))
2291 (setq unicode (idna-to-unicode ace))))
2292 (unless (string= ace unicode)
2293 (replace-match unicode nil nil nil 1)))))))))
2295 (defun article-de-quoted-unreadable (&optional force read-charset)
2296 "Translate a quoted-printable-encoded article.
2297 If FORCE, decode the article whether it is marked as quoted-printable
2299 If READ-CHARSET, ask for a coding system."
2300 (interactive (list 'force current-prefix-arg))
2302 (let ((inhibit-read-only t) type charset)
2303 (if (gnus-buffer-live-p gnus-original-article-buffer)
2304 (with-current-buffer gnus-original-article-buffer
2306 (gnus-fetch-field "content-transfer-encoding"))
2307 (let* ((ct (gnus-fetch-field "content-type"))
2310 (mail-header-parse-content-type ct)))))
2311 (setq charset (and ctl
2312 (mail-content-type-get ctl 'charset)))
2313 (if (stringp charset)
2314 (setq charset (intern (downcase charset)))))))
2316 (setq charset (mm-read-coding-system "Charset: " charset)))
2318 (setq charset gnus-newsgroup-charset))
2320 (and type (let ((case-fold-search t))
2321 (string-match "quoted-printable" type))))
2323 (quoted-printable-decode-region
2324 (point) (point-max) (mm-charset-to-coding-system charset))))))
2326 (defun article-de-base64-unreadable (&optional force read-charset)
2327 "Translate a base64 article.
2328 If FORCE, decode the article whether it is marked as base64 not.
2329 If READ-CHARSET, ask for a coding system."
2330 (interactive (list 'force current-prefix-arg))
2332 (let ((inhibit-read-only t) type charset)
2333 (if (gnus-buffer-live-p gnus-original-article-buffer)
2334 (with-current-buffer gnus-original-article-buffer
2336 (gnus-fetch-field "content-transfer-encoding"))
2337 (let* ((ct (gnus-fetch-field "content-type"))
2340 (mail-header-parse-content-type ct)))))
2341 (setq charset (and ctl
2342 (mail-content-type-get ctl 'charset)))
2343 (if (stringp charset)
2344 (setq charset (intern (downcase charset)))))))
2346 (setq charset (mm-read-coding-system "Charset: " charset)))
2348 (setq charset gnus-newsgroup-charset))
2350 (and type (let ((case-fold-search t))
2351 (string-match "base64" type))))
2354 (narrow-to-region (point) (point-max))
2355 (base64-decode-region (point-min) (point-max))
2356 (mm-decode-coding-region
2357 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2362 (defun article-decode-HZ ()
2363 "Translate a HZ-encoded article."
2367 (let ((inhibit-read-only t))
2368 (rfc1843-decode-region (point-min) (point-max)))))
2370 (defun article-unsplit-urls ()
2371 "Remove the newlines that some other mailers insert into URLs."
2374 (let ((inhibit-read-only t))
2375 (goto-char (point-min))
2376 (while (re-search-forward
2377 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2378 (replace-match "\\1\\3" t)))
2379 (when (interactive-p)
2380 (gnus-treat-article nil))))
2383 (defun article-wash-html (&optional read-charset)
2384 "Format an HTML article.
2385 If READ-CHARSET, ask for a coding system."
2388 (let ((inhibit-read-only t)
2390 (when (gnus-buffer-live-p gnus-original-article-buffer)
2391 (with-current-buffer gnus-original-article-buffer
2392 (let* ((ct (gnus-fetch-field "content-type"))
2395 (mail-header-parse-content-type ct)))))
2396 (setq charset (and ctl
2397 (mail-content-type-get ctl 'charset)))
2398 (when (stringp charset)
2399 (setq charset (intern (downcase charset)))))))
2401 (setq charset (mm-read-coding-system "Charset: " charset)))
2403 (setq charset gnus-newsgroup-charset))
2405 (save-window-excursion
2407 (narrow-to-region (point) (point-max))
2408 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2409 (entry (assq func mm-text-html-washer-alist)))
2411 (setq func (cdr entry)))
2416 (apply (car func) (cdr func))))))))))
2418 (defun gnus-article-wash-html-with-w3 ()
2419 "Wash the current buffer with w3."
2421 (let ((w3-strict-width (window-width))
2422 (url-standalone-mode t)
2423 (url-gateway-unplugged t)
2424 (w3-honor-stylesheets nil))
2426 (w3-region (point-min) (point-max))
2429 (defun gnus-article-wash-html-with-w3m ()
2430 "Wash the current buffer with emacs-w3m."
2433 (narrow-to-region (point) (point-max))
2434 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2435 w3m-force-redisplay)
2436 (w3m-region (point-min) (point-max)))
2437 (when (and mm-inline-text-html-with-w3m-keymap
2438 (boundp 'w3m-minor-mode-map)
2440 (add-text-properties
2441 (point-min) (point-max)
2442 (list 'keymap w3m-minor-mode-map
2443 ;; Put the mark meaning this part was rendered by emacs-w3m.
2444 'mm-inline-text-html-with-w3m t)))))
2446 (defun article-hide-list-identifiers ()
2447 "Remove list identifies from the Subject header.
2448 The `gnus-list-identifiers' variable specifies what to do."
2450 (let ((inhibit-point-motion-hooks t)
2451 (regexp (if (consp gnus-list-identifiers)
2452 (mapconcat 'identity gnus-list-identifiers " *\\|")
2453 gnus-list-identifiers))
2454 (inhibit-read-only t))
2458 (article-narrow-to-head)
2459 (goto-char (point-min))
2460 (while (re-search-forward
2461 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2463 (delete-region (match-beginning 2) (match-end 0))
2464 (beginning-of-line))
2465 (when (re-search-forward
2466 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2467 (delete-region (match-beginning 1) (match-end 1))))))))
2469 (defun article-hide-pem (&optional arg)
2470 "Toggle hiding of any PEM headers and signatures in the current article.
2471 If given a negative prefix, always show; if given a positive prefix,
2473 (interactive (gnus-article-hidden-arg))
2474 (unless (gnus-article-check-hidden-text 'pem arg)
2476 (let ((inhibit-read-only t) end)
2477 (goto-char (point-min))
2478 ;; Hide the horrendously ugly "header".
2479 (when (and (search-forward
2480 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2482 (setq end (1+ (match-beginning 0))))
2483 (gnus-add-wash-type 'pem)
2484 (gnus-article-hide-text-type
2486 (if (search-forward "\n\n" nil t)
2490 ;; Hide the trailer as well
2491 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2493 (gnus-article-hide-text-type
2494 (match-beginning 0) (match-end 0) 'pem)))))))
2496 (defun article-strip-banner ()
2497 "Strip the banners specified by the `banner' group parameter and by
2498 `gnus-article-address-banner-alist'."
2502 (let ((inhibit-point-motion-hooks t))
2503 (when (gnus-parameter-banner gnus-newsgroup-name)
2504 (article-really-strip-banner
2505 (gnus-parameter-banner gnus-newsgroup-name)))
2506 (when gnus-article-address-banner-alist
2507 ;; It is necessary to encode from fields before checking,
2508 ;; because `mail-header-parse-addresses' does not work
2509 ;; (reliably) on decoded headers. And more, it is
2510 ;; impossible to use `gnus-fetch-original-field' here,
2511 ;; because `article-strip-banner' may be called in draft
2512 ;; buffers to preview them.
2513 (let ((from (save-restriction
2515 (article-narrow-to-head)
2516 (mail-fetch-field "from"))))
2519 (caar (mail-header-parse-addresses
2520 (mail-encode-encoded-word-string from)))))
2522 (dolist (pair gnus-article-address-banner-alist)
2523 (when (string-match (car pair) from)
2525 (article-really-strip-banner (cdr pair)))))))))))))
2527 (defun article-really-strip-banner (banner)
2528 "Strip the banner specified by the argument."
2531 (let ((inhibit-point-motion-hooks t)
2532 (gnus-signature-limit nil)
2533 (inhibit-read-only t))
2536 ((eq banner 'signature)
2537 (when (gnus-article-narrow-to-signature)
2540 (delete-region (point) (point-max))))
2542 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2543 (while (re-search-forward banner nil t)
2544 (delete-region (match-beginning 0) (match-end 0)))))
2546 (while (re-search-forward banner nil t)
2547 (delete-region (match-beginning 0) (match-end 0)))))))))
2549 (defun article-babel ()
2550 "Translate article using an online translation service."
2553 (gnus-with-article-buffer
2554 (when (article-goto-body)
2555 (let* ((start (point))
2557 (orig (buffer-substring start end))
2558 (trans (babel-as-string orig)))
2560 (narrow-to-region start end)
2561 (delete-region start end)
2564 (defun article-hide-signature (&optional arg)
2565 "Hide the signature in the current article.
2566 If given a negative prefix, always show; if given a positive prefix,
2568 (interactive (gnus-article-hidden-arg))
2569 (unless (gnus-article-check-hidden-text 'signature arg)
2572 (let ((inhibit-read-only t))
2573 (when (gnus-article-narrow-to-signature)
2574 (gnus-article-hide-text-type
2575 (point-min) (point-max) 'signature))))))
2576 (gnus-set-mode-line 'article))
2578 (defun article-strip-headers-in-body ()
2579 "Strip offensive headers from bodies."
2583 (let ((case-fold-search t))
2584 (when (looking-at "x-no-archive:")
2585 (gnus-delete-line)))))
2587 (defun article-strip-leading-blank-lines ()
2588 "Remove all blank lines from the beginning of the article."
2591 (let ((inhibit-point-motion-hooks t)
2592 (inhibit-read-only t))
2593 (when (article-goto-body)
2594 (while (and (not (eobp))
2595 (looking-at "[ \t]*$"))
2596 (gnus-delete-line))))))
2598 (defun article-narrow-to-head ()
2599 "Narrow the buffer to the head of the message.
2600 Point is left at the beginning of the narrowed-to region."
2602 (goto-char (point-min))
2603 (if (search-forward "\n\n" nil 1)
2606 (goto-char (point-min)))
2608 (defun article-goto-body ()
2609 "Place point at the start of the body."
2610 (goto-char (point-min))
2612 ;; This variable is only bound when dealing with separate
2614 (article-goto-body-goes-to-point-min-p
2616 ((search-forward "\n\n" nil t)
2619 (goto-char (point-max))
2622 (defun article-strip-multiple-blank-lines ()
2623 "Replace consecutive blank lines with one empty line."
2626 (let ((inhibit-point-motion-hooks t)
2627 (inhibit-read-only t))
2628 ;; First make all blank lines empty.
2630 (while (re-search-forward "^[ \t]+$" nil t)
2631 (unless (gnus-annotation-in-region-p
2632 (match-beginning 0) (match-end 0))
2633 (replace-match "" nil t)))
2634 ;; Then replace multiple empty lines with a single empty line.
2636 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2637 (unless (gnus-annotation-in-region-p
2638 (match-beginning 0) (match-end 0))
2639 (delete-region (match-beginning 1) (match-end 1)))))))
2641 (defun article-strip-leading-space ()
2642 "Remove all white space from the beginning of the lines in the article."
2645 (let ((inhibit-point-motion-hooks t)
2646 (inhibit-read-only t))
2648 (while (re-search-forward "^[ \t]+" nil t)
2649 (replace-match "" t t)))))
2651 (defun article-strip-trailing-space ()
2652 "Remove all white space from the end of the lines in the article."
2655 (let ((inhibit-point-motion-hooks t)
2656 (inhibit-read-only t))
2658 (while (re-search-forward "[ \t]+$" nil t)
2659 (replace-match "" t t)))))
2661 (defun article-strip-blank-lines ()
2662 "Strip leading, trailing and multiple blank lines."
2664 (article-strip-leading-blank-lines)
2665 (article-remove-trailing-blank-lines)
2666 (article-strip-multiple-blank-lines))
2668 (defun article-strip-all-blank-lines ()
2669 "Strip all blank lines."
2672 (let ((inhibit-point-motion-hooks t)
2673 (inhibit-read-only t))
2675 (while (re-search-forward "^[ \t]*\n" nil t)
2676 (replace-match "" t t)))))
2678 (defun gnus-article-narrow-to-signature ()
2679 "Narrow to the signature; return t if a signature is found, else nil."
2680 (let ((inhibit-point-motion-hooks t))
2681 (when (gnus-article-search-signature)
2683 ;; Check whether we have some limits to what we consider
2684 ;; to be a signature.
2685 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2686 (list gnus-signature-limit)))
2688 (while (setq limit (pop limits))
2689 (if (or (and (integerp limit)
2690 (< (- (point-max) (point)) limit))
2692 (< (count-lines (point) (point-max)) limit))
2693 (and (functionp limit)
2695 (and (stringp limit)
2696 (not (re-search-forward limit nil t))))
2697 () ; This limit did not succeed.
2701 (narrow-to-region (point) (point-max))
2704 (defun gnus-article-search-signature ()
2705 "Search the current buffer for the signature separator.
2706 Put point at the beginning of the signature separator."
2707 (let ((cur (point)))
2708 (goto-char (point-max))
2709 (if (if (stringp gnus-signature-separator)
2710 (re-search-backward gnus-signature-separator nil t)
2711 (let ((seps gnus-signature-separator))
2713 (not (re-search-backward (car seps) nil t)))
2720 (defun gnus-article-hidden-arg ()
2721 "Return the current prefix arg as a number, or 0 if no prefix."
2722 (list (if current-prefix-arg
2723 (prefix-numeric-value current-prefix-arg)
2726 (defun gnus-article-check-hidden-text (type arg)
2727 "Return nil if hiding is necessary.
2728 Arg can be nil or a number. nil and positive means hide, negative
2729 means show, 0 means toggle."
2732 (let ((hide (gnus-article-hidden-text-p type)))
2738 (gnus-article-show-hidden-text type)
2741 (if (eq hide 'hidden)
2743 (gnus-article-show-hidden-text type)
2747 (defun gnus-article-hidden-text-p (type)
2748 "Say whether the current buffer contains hidden text of type TYPE."
2749 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2751 (not (get-text-property pos 'invisible))
2752 (not (get-text-property pos 'dummy-invisible)))
2754 (text-property-any (1+ pos) (point-max) 'article-type type)))
2759 (defun gnus-article-show-hidden-text (type &optional dummy)
2760 "Show all hidden text of type TYPE.
2761 Originally it is hide instead of DUMMY."
2762 (let ((inhibit-read-only t)
2763 (inhibit-point-motion-hooks t))
2764 (gnus-remove-text-properties-when
2766 (point-min) (point-max)
2767 (cons 'article-type (cons type
2768 gnus-hidden-properties)))
2769 (gnus-delete-wash-type type)))
2771 (defconst article-time-units
2772 `((year . ,(* 365.25 24 60 60))
2773 (week . ,(* 7 24 60 60))
2774 (day . ,(* 24 60 60))
2778 "Mapping from time units to seconds.")
2780 (defun gnus-article-forward-header ()
2781 "Move point to the start of the next header.
2782 If the current header is a continuation header, this can be several
2787 (if (looking-at "[ \t]+[^ \t]")
2791 (defun article-date-ut (&optional type highlight header)
2792 "Convert DATE date to universal time in the current article.
2793 If TYPE is `local', convert to local time; if it is `lapsed', output
2794 how much time has lapsed since DATE. For `lapsed', the value of
2795 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2796 should replace the \"Date:\" one, or should be added below it."
2797 (interactive (list 'ut t))
2798 (let* ((header (or header
2799 (message-fetch-field "date")
2801 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2804 ((not gnus-article-date-lapsed-new-header)
2810 (date (if (vectorp header) (mail-header-date header)
2812 (inhibit-point-motion-hooks t)
2817 (article-narrow-to-head)
2818 (when (re-search-forward tdate-regexp nil t)
2819 (setq bface (get-text-property (point-at-bol) 'face)
2820 date (or (get-text-property (point-at-bol)
2823 eface (get-text-property (1- (point-at-eol)) 'face))
2825 (when (and date (not (string= date "")))
2826 (goto-char (point-min))
2827 (let ((inhibit-read-only t))
2828 ;; Delete any old Date headers.
2829 (while (re-search-forward date-regexp nil t)
2831 (delete-region (point-at-bol)
2832 (progn (gnus-article-forward-header)
2834 (delete-region (point-at-bol)
2835 (progn (gnus-article-forward-header)
2838 (setq pos (point))))
2839 (when (and (not pos)
2840 (re-search-forward tdate-regexp nil t))
2842 (gnus-goto-char pos)
2843 (insert (article-make-date-line date (or type 'ut)))
2849 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2850 (add-text-properties (match-beginning 1) (1+ (match-end 1))
2851 (list 'original-date date 'face bface))
2852 (put-text-property (match-beginning 2) (match-end 2)
2855 (defun article-make-date-line (date type)
2856 "Return a DATE line of TYPE."
2857 (unless (memq type '(local ut original user iso8601 lapsed english))
2858 (error "Unknown conversion type: %s" type))
2860 (let ((time (date-to-time date)))
2862 ;; Convert to the local timezone.
2864 (concat "Date: " (message-make-date time)))
2865 ;; Convert to Universal Time.
2870 (let* ((e (parse-time-string date))
2871 (tm (apply 'encode-time e))
2873 (ls (- (cadr tm) (car (current-time-zone time)))))
2874 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2875 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2879 ;; Get the original date from the article.
2880 ((eq type 'original)
2881 (concat "Date: " (if (string-match "\n+$" date)
2882 (substring date 0 (match-beginning 0))
2884 ;; Let the user define the format.
2886 (let ((format (or (condition-case nil
2887 (with-current-buffer gnus-summary-buffer
2888 gnus-article-time-format)
2890 gnus-article-time-format)))
2891 (if (functionp format)
2892 (funcall format time)
2893 (concat "Date: " (format-time-string format time)))))
2896 (let ((tz (car (current-time-zone time))))
2899 (format-time-string "%Y%m%dT%H%M%S" time)
2900 (format "%s%02d%02d"
2901 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2902 (/ (% (abs tz) 3600) 60)))))
2903 ;; Do an X-Sent lapsed format.
2905 ;; If the date is seriously mangled, the timezone functions are
2906 ;; liable to bug out, so we ignore all errors.
2907 (let* ((now (current-time))
2908 (real-time (subtract-time now time))
2909 (real-sec (and real-time
2910 (+ (* (float (car real-time)) 65536)
2912 (sec (and real-time (abs real-sec)))
2922 ;; This is a bit convoluted, but basically we go
2923 ;; through the time units for years, weeks, etc,
2924 ;; and divide things to see whether that results
2925 ;; in positive answers.
2928 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2929 ;; The (remaining) seconds are too few to
2930 ;; be divided into this time unit.
2932 ;; It's big enough, so we output it.
2933 (setq sec (- sec (* num (cdr unit))))
2935 (concat (if prev ", " "") (int-to-string
2937 " " (symbol-name (car unit))
2938 (if (> num 1) "s" ""))
2940 article-time-units "")
2941 ;; If dates are odd, then it might appear like the
2942 ;; article was sent in the future.
2945 " in the future"))))))
2946 ;; Display the date in proper English
2948 (let ((dtime (decode-time time)))
2951 (number-to-string (nth 3 dtime))
2952 (let ((digit (% (nth 3 dtime) 10)))
2954 ((memq (nth 3 dtime) '(11 12 13)) "th")
2960 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2962 (number-to-string (nth 5 dtime))
2964 (format "%02d" (nth 2 dtime))
2966 (format "%02d" (nth 1 dtime)))))))
2968 (format "Date: %s (from Gnus)" date))))
2970 (defun article-date-local (&optional highlight)
2971 "Convert the current article date to the local timezone."
2972 (interactive (list t))
2973 (article-date-ut 'local highlight))
2975 (defun article-date-english (&optional highlight)
2976 "Convert the current article date to something that is proper English."
2977 (interactive (list t))
2978 (article-date-ut 'english highlight))
2980 (defun article-date-original (&optional highlight)
2981 "Convert the current article date to what it was originally.
2982 This is only useful if you have used some other date conversion
2983 function and want to see what the date was before converting."
2984 (interactive (list t))
2985 (article-date-ut 'original highlight))
2987 (defun article-date-lapsed (&optional highlight)
2988 "Convert the current article date to time lapsed since it was sent."
2989 (interactive (list t))
2990 (article-date-ut 'lapsed highlight))
2992 (defun article-update-date-lapsed ()
2993 "Function to be run from a timer to update the lapsed time line."
2994 (let (deactivate-mark)
2999 (set-buffer (window-buffer w))
3000 (when (eq major-mode 'gnus-article-mode)
3001 (let ((mark (point-marker)))
3002 (goto-char (point-min))
3003 (when (re-search-forward "^X-Sent:" nil t)
3004 (article-date-lapsed t))
3005 (goto-char (marker-position mark))
3006 (move-marker mark nil))))
3009 (defun gnus-start-date-timer (&optional n)
3010 "Start a timer to update the X-Sent header in the article buffers.
3011 The numerical prefix says how frequently (in seconds) the function
3016 (gnus-stop-date-timer)
3017 (setq article-lapsed-timer
3018 (run-at-time 1 n 'article-update-date-lapsed)))
3020 (defun gnus-stop-date-timer ()
3021 "Stop the X-Sent timer."
3023 (when article-lapsed-timer
3024 (nnheader-cancel-timer article-lapsed-timer)
3025 (setq article-lapsed-timer nil)))
3027 (defun article-date-user (&optional highlight)
3028 "Convert the current article date to the user-defined format.
3029 This format is defined by the `gnus-article-time-format' variable."
3030 (interactive (list t))
3031 (article-date-ut 'user highlight))
3033 (defun article-date-iso8601 (&optional highlight)
3034 "Convert the current article date to ISO8601."
3035 (interactive (list t))
3036 (article-date-ut 'iso8601 highlight))
3038 ;; (defun article-show-all ()
3039 ;; "Show all hidden text in the article buffer."
3042 ;; (let ((inhibit-read-only t))
3043 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3045 (defun article-remove-leading-whitespace ()
3046 "Remove excessive whitespace from all headers."
3050 (let ((inhibit-read-only t))
3051 (article-narrow-to-head)
3052 (goto-char (point-min))
3053 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3054 (delete-region (match-beginning 1) (match-end 1)))))))
3056 (defun article-emphasize (&optional arg)
3057 "Emphasize text according to `gnus-emphasis-alist'."
3058 (interactive (gnus-article-hidden-arg))
3059 (unless (gnus-article-check-hidden-text 'emphasis arg)
3063 (with-current-buffer gnus-summary-buffer
3064 gnus-article-emphasis-alist)
3066 gnus-emphasis-alist))
3067 (inhibit-read-only t)
3068 (props (append '(article-type emphasis)
3069 gnus-hidden-properties))
3070 regexp elem beg invisible visible face)
3073 (while (setq elem (pop alist))
3075 (setq regexp (car elem)
3076 invisible (nth 1 elem)
3077 visible (nth 2 elem)
3079 (while (re-search-forward regexp nil t)
3080 (when (and (match-beginning visible) (match-beginning invisible))
3081 (gnus-article-hide-text
3082 (match-beginning invisible) (match-end invisible) props)
3083 (gnus-article-unhide-text-type
3084 (match-beginning visible) (match-end visible) 'emphasis)
3085 (gnus-put-overlay-excluding-newlines
3086 (match-beginning visible) (match-end visible) 'face face)
3087 (gnus-add-wash-type 'emphasis)
3088 (goto-char (match-end invisible)))))))))
3090 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3091 "Setup newsgroup emphasis alist."
3092 (unless gnus-article-emphasis-alist
3093 (let ((name (and gnus-newsgroup-name
3094 (gnus-group-real-name gnus-newsgroup-name))))
3095 (make-local-variable 'gnus-article-emphasis-alist)
3096 (setq gnus-article-emphasis-alist
3098 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3099 (while (setq elem (pop alist))
3100 (when (and name (string-match (car elem) name))
3102 highlight (copy-sequence (cdr elem)))))
3104 (copy-sequence highlight-words)
3105 (if gnus-newsgroup-name
3106 (copy-sequence (gnus-group-find-parameter
3107 gnus-newsgroup-name 'highlight-words t)))
3108 gnus-emphasis-alist)))))
3111 (defvar gnus-summary-article-menu)
3112 (defvar gnus-summary-post-menu))
3114 ;;; Saving functions.
3116 (defun gnus-article-save (save-buffer file &optional num)
3117 "Save the currently selected article."
3118 (unless gnus-save-all-headers
3119 ;; Remove headers according to `gnus-saved-headers'.
3120 (let ((gnus-visible-headers
3121 (or gnus-saved-headers gnus-visible-headers))
3122 (gnus-article-buffer save-buffer))
3124 (set-buffer save-buffer)
3125 (article-hide-headers 1 t))))
3126 (save-window-excursion
3127 (if (not gnus-default-article-saver)
3128 (error "No default saver is defined")
3129 ;; !!! Magic! The saving functions all save
3130 ;; `gnus-save-article-buffer' (or so they think), but we
3131 ;; bind that variable to our save-buffer.
3132 (set-buffer gnus-article-buffer)
3133 (let* ((gnus-save-article-buffer save-buffer)
3136 ((not gnus-prompt-before-saving) 'default)
3137 ((eq gnus-prompt-before-saving 'always) nil)
3139 (gnus-number-of-articles-to-be-saved
3140 (when (eq gnus-prompt-before-saving t)
3142 (set-buffer gnus-article-current-summary)
3143 (funcall gnus-default-article-saver filename)))))
3145 (defun gnus-read-save-file-name (prompt &optional filename
3146 function group headers variable)
3148 (funcall function group headers (symbol-value variable)))
3153 ((eq filename 'default)
3159 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3162 (if (and gnus-number-of-articles-to-be-saved
3163 (> gnus-number-of-articles-to-be-saved 1))
3164 (format "these %d articles"
3165 gnus-number-of-articles-to-be-saved)
3168 ;; Let the split methods have their say.
3170 ;; No split name was found.
3173 (concat prompt " (default "
3174 (file-name-nondirectory default-name) ") ")
3175 (file-name-directory default-name)
3177 ;; A single group name is returned.
3178 ((stringp split-name)
3180 (funcall function split-name headers
3181 (symbol-value variable)))
3183 (concat prompt " (default "
3184 (file-name-nondirectory default-name) ") ")
3185 (file-name-directory default-name)
3187 ;; A single split name was found
3188 ((= 1 (length split-name))
3189 (let* ((name (expand-file-name
3191 gnus-article-save-directory))
3192 (dir (cond ((file-directory-p name)
3193 (file-name-as-directory name))
3194 ((file-exists-p name) name)
3195 (t gnus-article-save-directory))))
3197 (concat prompt " (default " name ") ")
3199 ;; A list of splits was found.
3201 (setq split-name (nreverse split-name))
3203 (let ((file-name-history
3204 (nconc split-name file-name-history)))
3208 (concat prompt " (`M-p' for defaults) ")
3209 gnus-article-save-directory
3211 gnus-article-save-directory)))
3212 (car (push result file-name-history)))))))
3213 ;; Create the directory.
3214 (gnus-make-directory (file-name-directory file))
3215 ;; If we have read a directory, we append the default file name.
3216 (when (file-directory-p file)
3217 (setq file (expand-file-name (file-name-nondirectory
3219 (file-name-as-directory file))))
3220 ;; Possibly translate some characters.
3221 (nnheader-translate-file-chars file))))))
3222 (gnus-make-directory (file-name-directory result))
3223 (set variable result)))
3225 (defun gnus-article-archive-name (group)
3226 "Return the first instance of an \"Archive-name\" in the current buffer."
3227 (let ((case-fold-search t))
3228 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3229 (nnheader-concat gnus-article-save-directory
3230 (match-string 1)))))
3232 (defun gnus-article-nndoc-name (group)
3233 "If GROUP is an nndoc group, return the name of the parent group."
3234 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3235 (gnus-group-get-parameter group 'save-article-group)))
3237 (defun gnus-summary-save-in-rmail (&optional filename)
3238 "Append this article to Rmail file.
3239 Optional argument FILENAME specifies file name.
3240 Directory to save to is default to `gnus-article-save-directory'."
3241 (setq filename (gnus-read-save-file-name
3242 "Save %s in rmail file:" filename
3243 gnus-rmail-save-name gnus-newsgroup-name
3244 gnus-current-headers 'gnus-newsgroup-last-rmail))
3245 (gnus-eval-in-buffer-window gnus-save-article-buffer
3249 (gnus-output-to-rmail filename))))
3252 (defun gnus-summary-save-in-mail (&optional filename)
3253 "Append this article to Unix mail file.
3254 Optional argument FILENAME specifies file name.
3255 Directory to save to is default to `gnus-article-save-directory'."
3256 (setq filename (gnus-read-save-file-name
3257 "Save %s in Unix mail file:" filename
3258 gnus-mail-save-name gnus-newsgroup-name
3259 gnus-current-headers 'gnus-newsgroup-last-mail))
3260 (gnus-eval-in-buffer-window gnus-save-article-buffer
3264 (if (and (file-readable-p filename)
3265 (file-regular-p filename)
3266 (mail-file-babyl-p filename))
3267 (rmail-output-to-rmail-file filename t)
3268 (gnus-output-to-mail filename)))))
3271 (defun gnus-summary-save-in-file (&optional filename overwrite)
3272 "Append this article to file.
3273 Optional argument FILENAME specifies file name.
3274 Directory to save to is default to `gnus-article-save-directory'."
3275 (setq filename (gnus-read-save-file-name
3276 "Save %s in file:" filename
3277 gnus-file-save-name gnus-newsgroup-name
3278 gnus-current-headers 'gnus-newsgroup-last-file))
3279 (gnus-eval-in-buffer-window gnus-save-article-buffer
3283 (when (and overwrite
3284 (file-exists-p filename))
3285 (delete-file filename))
3286 (gnus-output-to-file filename))))
3289 (defun gnus-summary-write-to-file (&optional filename)
3290 "Write this article to a file, overwriting it if the file exists.
3291 Optional argument FILENAME specifies file name.
3292 The directory to save in defaults to `gnus-article-save-directory'."
3293 (gnus-summary-save-in-file nil t))
3295 (defun gnus-summary-save-body-in-file (&optional filename)
3296 "Append this article body to a file.
3297 Optional argument FILENAME specifies file name.
3298 The directory to save in defaults to `gnus-article-save-directory'."
3299 (setq filename (gnus-read-save-file-name
3300 "Save %s body in file:" filename
3301 gnus-file-save-name gnus-newsgroup-name
3302 gnus-current-headers 'gnus-newsgroup-last-file))
3303 (gnus-eval-in-buffer-window gnus-save-article-buffer
3307 (when (article-goto-body)
3308 (narrow-to-region (point) (point-max)))
3309 (gnus-output-to-file filename))))
3312 (defun gnus-summary-save-in-pipe (&optional command)
3313 "Pipe this article to subprocess."
3315 (cond ((and (eq command 'default)
3316 gnus-last-shell-command)
3317 gnus-last-shell-command)
3322 "Shell command on %s: "
3323 (if (and gnus-number-of-articles-to-be-saved
3324 (> gnus-number-of-articles-to-be-saved 1))
3325 (format "these %d articles"
3326 gnus-number-of-articles-to-be-saved)
3328 gnus-last-shell-command))))
3329 (when (string-equal command "")
3330 (if gnus-last-shell-command
3331 (setq command gnus-last-shell-command)
3332 (error "A command is required")))
3333 (gnus-eval-in-buffer-window gnus-article-buffer
3336 (shell-command-on-region (point-min) (point-max) command nil)))
3337 (setq gnus-last-shell-command command))
3339 (defun gnus-summary-pipe-to-muttprint (&optional command)
3340 "Pipe this article to muttprint."
3341 (setq command (read-string
3342 "Print using command: " gnus-summary-muttprint-program
3343 nil gnus-summary-muttprint-program))
3344 (gnus-summary-save-in-pipe command))
3346 ;;; Article file names when saving.
3348 (defun gnus-capitalize-newsgroup (newsgroup)
3349 "Capitalize NEWSGROUP name."
3350 (when (not (zerop (length newsgroup)))
3351 (concat (char-to-string (upcase (aref newsgroup 0)))
3352 (substring newsgroup 1))))
3354 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3355 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3356 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3357 Otherwise, it is like ~/News/news/group/num."
3360 (concat (if (gnus-use-long-file-name 'not-save)
3361 (gnus-capitalize-newsgroup newsgroup)
3362 (gnus-newsgroup-directory-form newsgroup))
3363 "/" (int-to-string (mail-header-number headers)))
3364 gnus-article-save-directory)))
3366 (string-equal (file-name-directory default)
3367 (file-name-directory last-file))
3368 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3370 (or last-file default))))
3372 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3373 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3374 If variable `gnus-use-long-file-name' is non-nil, it is
3375 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3378 (concat (if (gnus-use-long-file-name 'not-save)
3380 (gnus-newsgroup-directory-form newsgroup))
3381 "/" (int-to-string (mail-header-number headers)))
3382 gnus-article-save-directory)))
3384 (string-equal (file-name-directory default)
3385 (file-name-directory last-file))
3386 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3388 (or last-file default))))
3390 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3391 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3392 If variable `gnus-use-long-file-name' is non-nil, it is
3393 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3396 (if (gnus-use-long-file-name 'not-save)
3399 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3401 gnus-article-save-directory)))
3403 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3404 "Generate file name from sender."
3405 (let ((from (mail-header-from headers)))
3407 (if (and from (string-match "\\([^ <]+\\)@" from))
3408 (match-string 1 from)
3410 gnus-article-save-directory)))
3412 (defun article-verify-x-pgp-sig ()
3415 (if (gnus-buffer-live-p gnus-original-article-buffer)
3416 (let ((sig (with-current-buffer gnus-original-article-buffer
3417 (gnus-fetch-field "X-PGP-Sig")))
3421 (mml2015-clear-verify-function))
3423 (insert-buffer-substring gnus-original-article-buffer)
3424 (setq items (split-string sig))
3425 (message-narrow-to-head)
3426 (let ((inhibit-point-motion-hooks t)
3427 (case-fold-search t))
3428 ;; Don't verify multiple headers.
3429 (setq headers (mapconcat (lambda (header)
3431 (mail-fetch-field header)
3433 (split-string (nth 1 items) ",") "")))
3434 (delete-region (point-min) (point-max))
3435 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3436 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3441 (if (looking-at "^-")
3444 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3445 (insert "Version: " (car items) "\n\n")
3446 (insert (mapconcat 'identity (cddr items) "\n"))
3447 (insert "\n-----END PGP SIGNATURE-----\n")
3448 (let ((mm-security-handle (list (format "multipart/signed"))))
3449 (mml2015-clean-buffer)
3450 (let ((coding-system-for-write (or gnus-newsgroup-charset
3452 (funcall (mml2015-clear-verify-function)))
3454 (or (mm-handle-multipart-ctl-parameter
3455 mm-security-handle 'gnus-details)
3456 (mm-handle-multipart-ctl-parameter
3457 mm-security-handle 'gnus-info)))))
3459 (let ((inhibit-read-only t) bface eface)
3461 (message-narrow-to-head)
3462 (goto-char (point-max))
3464 (setq bface (get-text-property (point-at-bol) 'face)
3465 eface (get-text-property (1- (point-at-eol)) 'face))
3466 (message-remove-header "X-Gnus-PGP-Verify")
3467 (if (re-search-forward "^X-PGP-Sig:" nil t)
3469 (goto-char (point-max)))
3470 (narrow-to-region (point) (point))
3471 (insert "X-Gnus-PGP-Verify: " info "\n")
3472 (goto-char (point-min))
3475 (if (not (looking-at "^[ \t]"))
3479 (goto-char (point-min))
3480 (when (looking-at "\\([^:]+\\): *")
3481 (put-text-property (match-beginning 1) (1+ (match-end 1))
3483 (put-text-property (match-end 0) (point-max)
3484 'face eface)))))))))
3486 (defun article-verify-cancel-lock ()
3487 "Verify Cancel-Lock header."
3489 (if (gnus-buffer-live-p gnus-original-article-buffer)
3490 (canlock-verify gnus-original-article-buffer)))
3497 (setq afunc (car func)
3500 gfunc (intern (format "gnus-%s" func))))
3502 (when (fboundp afunc)
3503 `(lambda (&optional interactive &rest args)
3504 ,(documentation afunc t)
3505 (interactive (list t))
3507 (set-buffer gnus-article-buffer)
3509 (call-interactively ',afunc)
3510 (apply ',afunc args))))))))
3511 '(article-hide-headers
3512 article-verify-x-pgp-sig
3513 article-verify-cancel-lock
3514 article-hide-boring-headers
3515 article-treat-overstrike
3516 article-treat-ansi-sequences
3517 article-fill-long-lines
3518 article-capitalize-sentences
3520 article-remove-leading-whitespace
3521 article-display-x-face
3522 article-display-face
3523 article-de-quoted-unreadable
3524 article-de-base64-unreadable
3527 article-unsplit-urls
3528 article-hide-list-identifiers
3529 article-strip-banner
3532 article-hide-signature
3533 article-strip-headers-in-body
3534 article-remove-trailing-blank-lines
3535 article-strip-leading-blank-lines
3536 article-strip-multiple-blank-lines
3537 article-strip-leading-space
3538 article-strip-trailing-space
3539 article-strip-blank-lines
3540 article-strip-all-blank-lines
3542 article-date-english
3543 article-date-iso8601
3544 article-date-original
3546 article-decode-mime-words
3547 article-decode-charset
3548 article-decode-encoded-words
3552 article-treat-dumbquotes
3553 article-normalize-headers
3554 ;; (article-show-all . gnus-article-show-all-headers)
3558 ;;; Gnus article mode
3561 (put 'gnus-article-mode 'mode-class 'special)
3563 (set-keymap-parent gnus-article-mode-map widget-keymap)
3565 (gnus-define-keys gnus-article-mode-map
3566 " " gnus-article-goto-next-page
3567 "\177" gnus-article-goto-prev-page
3568 [delete] gnus-article-goto-prev-page
3569 [backspace] gnus-article-goto-prev-page
3570 "\C-c^" gnus-article-refer-article
3571 "h" gnus-article-show-summary
3572 "s" gnus-article-show-summary
3573 "\C-c\C-m" gnus-article-mail
3574 "?" gnus-article-describe-briefly
3575 "e" gnus-summary-edit-article
3576 "<" beginning-of-buffer
3578 "\C-c\C-i" gnus-info-find-node
3580 "R" gnus-article-reply-with-original
3581 "F" gnus-article-followup-with-original
3582 "\C-hk" gnus-article-describe-key
3583 "\C-hc" gnus-article-describe-key-briefly
3585 "\C-d" gnus-article-read-summary-keys
3586 "\M-*" gnus-article-read-summary-keys
3587 "\M-#" gnus-article-read-summary-keys
3588 "\M-^" gnus-article-read-summary-keys
3589 "\M-g" gnus-article-read-summary-keys)
3591 (substitute-key-definition
3592 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3594 (defun gnus-article-make-menu-bar ()
3595 (unless (boundp 'gnus-article-commands-menu)
3596 (gnus-summary-make-menu-bar))
3597 (gnus-turn-off-edit-menu 'article)
3598 (unless (boundp 'gnus-article-article-menu)
3600 gnus-article-article-menu gnus-article-mode-map ""
3602 ["Scroll forwards" gnus-article-goto-next-page t]
3603 ["Scroll backwards" gnus-article-goto-prev-page t]
3604 ["Show summary" gnus-article-show-summary t]
3605 ["Fetch Message-ID at point" gnus-article-refer-article t]
3606 ["Mail to address at point" gnus-article-mail t]
3607 ["Send a bug report" gnus-bug t]))
3610 gnus-article-treatment-menu gnus-article-mode-map ""
3611 ;; Fixme: this should use :active (and maybe :visible).
3613 ["Hide headers" gnus-article-hide-headers t]
3614 ["Hide signature" gnus-article-hide-signature t]
3615 ["Hide citation" gnus-article-hide-citation t]
3616 ["Treat overstrike" gnus-article-treat-overstrike t]
3617 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3618 ["Remove carriage return" gnus-article-remove-cr t]
3619 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3620 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3621 ["Remove base64" gnus-article-de-base64-unreadable t]
3622 ["Treat html" gnus-article-wash-html t]
3623 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3624 ["Decode HZ" gnus-article-decode-HZ t]))
3626 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3628 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3630 (gnus-run-hooks 'gnus-article-menu-hook)))
3632 (defun gnus-article-mode ()
3633 "Major mode for displaying an article.
3635 All normal editing commands are switched off.
3637 The following commands are available in addition to all summary mode
3639 \\<gnus-article-mode-map>
3640 \\[gnus-article-next-page]\t Scroll the article one page forwards
3641 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3642 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3643 \\[gnus-article-show-summary]\t Display the summary buffer
3644 \\[gnus-article-mail]\t Send a reply to the address near point
3645 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3646 \\[gnus-info-find-node]\t Go to the Gnus info node"
3648 (gnus-simplify-mode-line)
3649 (setq mode-name "Article")
3650 (setq major-mode 'gnus-article-mode)
3651 (make-local-variable 'minor-mode-alist)
3652 (use-local-map gnus-article-mode-map)
3653 (when (gnus-visual-p 'article-menu 'menu)
3654 (gnus-article-make-menu-bar)
3655 (when gnus-summary-tool-bar-map
3656 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3657 (gnus-update-format-specifications nil 'article-mode)
3658 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3659 (set (make-local-variable 'gnus-page-broken) nil)
3660 (make-local-variable 'gnus-button-marker-list)
3661 (make-local-variable 'gnus-article-current-summary)
3662 (make-local-variable 'gnus-article-mime-handles)
3663 (make-local-variable 'gnus-article-decoded-p)
3664 (make-local-variable 'gnus-article-mime-handle-alist)
3665 (make-local-variable 'gnus-article-wash-types)
3666 (make-local-variable 'gnus-article-image-alist)
3667 (make-local-variable 'gnus-article-charset)
3668 (make-local-variable 'gnus-article-ignored-charsets)
3669 (gnus-set-default-directory)
3670 (buffer-disable-undo)
3671 (setq buffer-read-only t
3672 show-trailing-whitespace nil)
3673 (set-syntax-table gnus-article-mode-syntax-table)
3674 (mm-enable-multibyte)
3675 (gnus-run-hooks 'gnus-article-mode-hook))
3677 (defun gnus-article-setup-buffer ()
3678 "Initialize the article buffer."
3679 (let* ((name (if gnus-single-article-buffer "*Article*"
3680 (concat "*Article " gnus-newsgroup-name "*")))
3682 (progn (string-match "\\*Article" name)
3683 (concat " *Original Article"
3684 (substring name (match-end 0))))))
3685 (setq gnus-article-buffer name)
3686 (setq gnus-original-article-buffer original)
3687 (setq gnus-article-mime-handle-alist nil)
3688 ;; This might be a variable local to the summary buffer.
3689 (unless gnus-single-article-buffer
3691 (set-buffer gnus-summary-buffer)
3692 (setq gnus-article-buffer name)
3693 (setq gnus-original-article-buffer original)
3694 (gnus-set-global-variables)))
3695 (gnus-article-setup-highlight-words)
3696 ;; Init original article buffer.
3698 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3699 (mm-enable-multibyte)
3700 (setq major-mode 'gnus-original-article-mode)
3701 (make-local-variable 'gnus-original-article))
3702 (if (get-buffer name)
3705 (when (and gnus-article-edit-mode
3708 (y-or-n-p "Article mode edit in progress; discard? ")))
3709 (error "Action aborted"))
3710 (set (make-local-variable 'gnus-article-edit-mode) nil)
3711 (when gnus-article-mime-handles
3712 (mm-destroy-parts gnus-article-mime-handles)
3713 (setq gnus-article-mime-handles nil))
3714 ;; Set it to nil in article-buffer!
3715 (setq gnus-article-mime-handle-alist nil)
3716 (buffer-disable-undo)
3717 (setq buffer-read-only t)
3718 ;; This list just keeps growing if we don't reset it.
3719 (setq gnus-button-marker-list nil)
3720 (unless (eq major-mode 'gnus-article-mode)
3721 (gnus-article-mode))
3724 (set-buffer (gnus-get-buffer-create name))
3726 (make-local-variable 'gnus-summary-buffer)
3727 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3728 (current-buffer)))))
3730 ;; Set article window start at LINE, where LINE is the number of lines
3731 ;; from the head of the article.
3732 (defun gnus-article-set-window-start (&optional line)
3734 (gnus-get-buffer-window gnus-article-buffer t)
3736 (set-buffer gnus-article-buffer)
3737 (goto-char (point-min))
3740 (gnus-message 6 "Moved to bookmark")
3741 (search-forward "\n\n" nil t)
3745 (defun gnus-article-prepare (article &optional all-headers header)
3746 "Prepare ARTICLE in article mode buffer.
3747 ARTICLE should either be an article number or a Message-ID.
3748 If ARTICLE is an id, HEADER should be the article headers.
3749 If ALL-HEADERS is non-nil, no headers are hidden."
3751 ;; Make sure we start in a summary buffer.
3752 (unless (eq major-mode 'gnus-summary-mode)
3753 (set-buffer gnus-summary-buffer))
3754 (setq gnus-summary-buffer (current-buffer))
3755 (let* ((gnus-article (if header (mail-header-number header) article))
3756 (summary-buffer (current-buffer))
3757 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3758 (group gnus-newsgroup-name)
3761 (gnus-article-setup-buffer)
3762 (set-buffer gnus-article-buffer)
3763 ;; Deactivate active regions.
3764 (when (and (boundp 'transient-mark-mode)
3765 transient-mark-mode)
3766 (setq mark-active nil))
3767 (if (not (setq result (let ((inhibit-read-only t))
3768 (gnus-request-article-this-buffer
3770 ;; There is no such article.
3772 (when (and (numberp article)
3773 (not (memq article gnus-newsgroup-sparse)))
3774 (setq gnus-article-current
3775 (cons gnus-newsgroup-name article))
3776 (set-buffer gnus-summary-buffer)
3777 (setq gnus-current-article article)
3778 (if (and (memq article gnus-newsgroup-undownloaded)
3779 (not (gnus-online (gnus-find-method-for-group
3780 gnus-newsgroup-name))))
3782 (gnus-summary-set-agent-mark article)
3783 (message "Message marked for downloading"))
3784 (gnus-summary-mark-article article gnus-canceled-mark)
3785 (unless (memq article gnus-newsgroup-sparse)
3786 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3787 (if (or (eq result 'pseudo)
3788 (eq result 'nneething))
3791 (set-buffer summary-buffer)
3792 (push article gnus-newsgroup-history)
3793 (setq gnus-last-article gnus-current-article
3794 gnus-current-article 0
3795 gnus-current-headers nil
3796 gnus-article-current nil)
3797 (if (eq result 'nneething)
3798 (gnus-configure-windows 'summary)
3799 (gnus-configure-windows 'article))
3800 (gnus-set-global-variables))
3801 (let ((gnus-article-mime-handle-alist-1
3802 gnus-article-mime-handle-alist))
3803 (gnus-set-mode-line 'article)))
3804 ;; The result from the `request' was an actual article -
3805 ;; or at least some text that is now displayed in the
3807 (when (and (numberp article)
3808 (not (eq article gnus-current-article)))
3809 ;; Seems like a new article has been selected.
3810 ;; `gnus-current-article' must be an article number.
3812 (set-buffer summary-buffer)
3813 (push article gnus-newsgroup-history)
3814 (setq gnus-last-article gnus-current-article
3815 gnus-current-article article
3816 gnus-current-headers
3817 (gnus-summary-article-header gnus-current-article)
3818 gnus-article-current
3819 (cons gnus-newsgroup-name gnus-current-article))
3820 (unless (vectorp gnus-current-headers)
3821 (setq gnus-current-headers nil))
3822 (gnus-summary-goto-subject gnus-current-article)
3823 (when (gnus-summary-show-thread)
3824 ;; If the summary buffer really was folded, the
3825 ;; previous goto may not actually have gone to
3826 ;; the right article, but the thread root instead.
3828 (gnus-summary-goto-subject gnus-current-article))
3829 (gnus-run-hooks 'gnus-mark-article-hook)
3830 (gnus-set-mode-line 'summary)
3831 (when (gnus-visual-p 'article-highlight 'highlight)
3832 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3833 ;; Set the global newsgroup variables here.
3834 (gnus-set-global-variables)
3835 (setq gnus-have-all-headers
3836 (or all-headers gnus-show-all-headers))))
3838 (gnus-configure-windows 'article))
3839 (when (or (numberp article)
3841 (gnus-article-prepare-display)
3843 (goto-char (point-min))
3844 (when gnus-break-pages
3845 (gnus-narrow-to-page)))
3846 (let ((gnus-article-mime-handle-alist-1
3847 gnus-article-mime-handle-alist))
3848 (gnus-set-mode-line 'article))
3852 (set-window-point (get-buffer-window (current-buffer)) (point))
3853 (gnus-configure-windows 'article)
3857 (defun gnus-article-prepare-display ()
3858 "Make the current buffer look like a nice article."
3859 ;; Hooks for getting information from the article.
3860 ;; This hook must be called before being narrowed.
3861 (let ((gnus-article-buffer (current-buffer))
3863 (inhibit-read-only t))
3864 (unless (eq major-mode 'gnus-article-mode)
3865 (gnus-article-mode))
3866 (setq buffer-read-only nil
3867 gnus-article-wash-types nil
3868 gnus-article-image-alist nil)
3869 (gnus-run-hooks 'gnus-tmp-internal-hook)
3870 (when gnus-display-mime-function
3871 (funcall gnus-display-mime-function))
3872 (gnus-run-hooks 'gnus-article-prepare-hook)))
3875 ;;; Gnus MIME viewing functions
3878 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3879 "Format of the MIME buttons.
3881 Valid specifiers include:
3883 %T MIME type, along with additional info
3884 %n The `name' parameter
3885 %d The description, if any
3886 %l The length of the encoded part
3887 %p The part identifier number
3888 %e Dots if the part isn't displayed
3890 General format specifiers can also be used. See Info node
3891 `(gnus)Formatting Variables'.")
3893 (defvar gnus-mime-button-line-format-alist
3894 '((?t gnus-tmp-type ?s)
3895 (?T gnus-tmp-type-long ?s)
3896 (?n gnus-tmp-name ?s)
3897 (?d gnus-tmp-description ?s)
3899 (?l gnus-tmp-length ?d)
3900 (?e gnus-tmp-dots ?s)))
3902 (defvar gnus-mime-button-commands
3903 '((gnus-article-press-button "\r" "Toggle Display")
3904 (gnus-mime-view-part "v" "View Interactively...")
3905 (gnus-mime-view-part-as-type "t" "View As Type...")
3906 (gnus-mime-view-part-as-charset "C" "View As charset...")
3907 (gnus-mime-save-part "o" "Save...")
3908 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3909 (gnus-mime-delete-part "d" "Delete part")
3910 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3911 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3912 (gnus-mime-view-part-internally "E" "View Internally")
3913 (gnus-mime-view-part-externally "e" "View Externally")
3914 (gnus-mime-print-part "p" "Print")
3915 (gnus-mime-pipe-part "|" "Pipe To Command...")
3916 (gnus-mime-action-on-part "." "Take action on the part...")))
3918 (defun gnus-article-mime-part-status ()
3919 (if gnus-article-mime-handle-alist-1
3920 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3922 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3925 (defvar gnus-mime-button-map
3926 (let ((map (make-sparse-keymap)))
3927 (define-key map gnus-mouse-2 'gnus-article-push-button)
3928 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3929 (dolist (c gnus-mime-button-commands)
3930 (define-key map (cadr c) (car c)))
3934 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3936 ,@(mapcar (lambda (c)
3937 (vector (caddr c) (car c) :enable t))
3938 gnus-mime-button-commands)))
3940 (defun gnus-mime-button-menu (event prefix)
3941 "Construct a context-sensitive menu of MIME commands."
3942 (interactive "e\nP")
3943 (save-window-excursion
3944 (let ((pos (event-start event)))
3945 (select-window (posn-window pos))
3946 (goto-char (posn-point pos))
3947 (gnus-article-check-buffer)
3948 (popup-menu gnus-mime-button-menu nil prefix))))
3950 (defun gnus-mime-view-all-parts (&optional handles)
3951 "View all the MIME parts."
3953 (with-current-buffer gnus-article-buffer
3954 (let ((handles (or handles gnus-article-mime-handles))
3955 (mail-parse-charset gnus-newsgroup-charset)
3956 (mail-parse-ignored-charsets
3957 (with-current-buffer gnus-summary-buffer
3958 gnus-newsgroup-ignored-charsets)))
3960 (mm-remove-parts handles)
3961 (goto-char (point-min))
3962 (or (search-forward "\n\n") (goto-char (point-max)))
3963 (let ((inhibit-read-only t))
3964 (delete-region (point) (point-max))
3965 (mm-display-parts handles))))))
3968 (defsubst gnus-article-edit-part (handles)
3969 "Edit an article in order to delete a mime part.
3970 This function is exclusively used by `gnus-mime-save-part-and-strip'
3971 and `gnus-mime-delete-part', and not provided at run-time normally."
3972 (gnus-article-edit-article
3975 (let ((mail-parse-charset (or gnus-article-charset
3976 ',gnus-newsgroup-charset))
3977 (mail-parse-ignored-charsets
3978 (or gnus-article-ignored-charsets
3979 ',gnus-newsgroup-ignored-charsets))
3980 (mbl mml-buffer-list))
3981 (setq mml-buffer-list nil)
3982 (insert-buffer gnus-original-article-buffer)
3983 (mime-to-mml ',handles)
3984 (setq gnus-article-mime-handles nil)
3985 (let ((mbl1 mml-buffer-list))
3986 (setq mml-buffer-list mbl)
3987 (set (make-local-variable 'mml-buffer-list) mbl1))
3988 (gnus-make-local-hook 'kill-buffer-hook)
3989 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3990 `(lambda (no-highlight)
3991 (let ((mail-parse-charset (or gnus-article-charset
3992 ',gnus-newsgroup-charset))
3993 (message-options message-options)
3994 (message-options-set-recipient)
3995 (mail-parse-ignored-charsets
3996 (or gnus-article-ignored-charsets
3997 ',gnus-newsgroup-ignored-charsets)))
3999 (mml-destroy-buffers)
4000 (remove-hook 'kill-buffer-hook
4001 'mml-destroy-buffers t)
4002 (kill-local-variable 'mml-buffer-list))
4003 (gnus-summary-edit-article-done
4004 ,(or (mail-header-references gnus-current-headers) "")
4005 ,(gnus-group-read-only-p)
4006 ,gnus-summary-buffer no-highlight)))
4007 (gnus-article-edit-done)
4008 (gnus-summary-expand-window)
4009 (gnus-summary-show-article)))
4011 (defun gnus-mime-save-part-and-strip ()
4012 "Save the MIME part under point then replace it with an external body."
4014 (gnus-article-check-buffer)
4015 (when (gnus-group-read-only-p)
4016 (error "The current group does not support deleting of parts"))
4017 (when (mm-complicated-handles gnus-article-mime-handles)
4019 The current article has a complicated MIME structure, giving up..."))
4020 (when (gnus-yes-or-no-p "\
4021 Deleting parts may malfunction or destroy the article; continue? ")
4022 (let* ((data (get-text-property (point) 'gnus-data))
4024 (handles gnus-article-mime-handles))
4025 (setq file (and data (mm-save-part data)))
4027 (with-current-buffer (mm-handle-buffer data)
4029 (insert "Content-Type: " (mm-handle-media-type data))
4030 (mml-insert-parameter-string (cdr (mm-handle-type data))
4033 (insert "Content-ID: " (message-make-message-id) "\n")
4034 (insert "Content-Transfer-Encoding: binary\n")
4037 (cdr (mm-make-handle nil
4038 `("message/external-body"
4039 (access-type . "LOCAL-FILE")
4041 (set-buffer gnus-summary-buffer)
4042 (gnus-article-edit-part handles)))))
4044 (defun gnus-mime-delete-part ()
4045 "Delete the MIME part under point.
4046 Replace it with some information about the removed part."
4048 (gnus-article-check-buffer)
4049 (when (gnus-group-read-only-p)
4050 (error "The current group does not support deleting of parts"))
4051 (when (mm-complicated-handles gnus-article-mime-handles)
4053 The current article has a complicated MIME structure, giving up..."))
4054 (when (gnus-yes-or-no-p "\
4055 Deleting parts may malfunction or destroy the article; continue? ")
4056 (let* ((data (get-text-property (point) 'gnus-data))
4057 (handles gnus-article-mime-handles)
4061 (mail-decode-encoded-word-string (or (mm-handle-description data)
4064 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4066 (type (mm-handle-media-type data)))
4068 (error "No MIME part under point"))
4069 (with-current-buffer (mm-handle-buffer data)
4070 (let ((bsize (format "%s" (buffer-size))))
4075 "| The following attachment has been deleted:\n"
4077 "| Type: " type "\n"
4078 "| Filename: " filename "\n"
4079 "| Size (encoded): " bsize " Byte\n"
4080 "| Description: " description "\n"
4083 (cdr (mm-make-handle
4084 nil `("text/plain") nil nil
4086 (format "Deleted attachment (%s bytes)" bsize))))))
4087 (set-buffer gnus-summary-buffer)
4088 (gnus-article-edit-part handles))))
4090 (defun gnus-mime-save-part ()
4091 "Save the MIME part under point."
4093 (gnus-article-check-buffer)
4094 (let ((data (get-text-property (point) 'gnus-data)))
4096 (mm-save-part data))))
4098 (defun gnus-mime-pipe-part ()
4099 "Pipe the MIME part under point to a process."
4101 (gnus-article-check-buffer)
4102 (let ((data (get-text-property (point) 'gnus-data)))
4104 (mm-pipe-part data))))
4106 (defun gnus-mime-view-part ()
4107 "Interactively choose a viewing method for the MIME part under point."
4109 (gnus-article-check-buffer)
4110 (let ((data (get-text-property (point) 'gnus-data)))
4112 (setq gnus-article-mime-handles
4114 gnus-article-mime-handles (setq data (copy-sequence data))))
4115 (mm-interactively-view-part data))))
4117 (defun gnus-mime-view-part-as-type-internal ()
4118 (gnus-article-check-buffer)
4119 (let* ((name (mail-content-type-get
4120 (mm-handle-type (get-text-property (point) 'gnus-data))
4122 (def-type (and name (mm-default-file-encoding name))))
4123 (and def-type (cons def-type 0))))
4125 (defun gnus-mime-view-part-as-type (&optional mime-type)
4126 "Choose a MIME media type, and view the part as such."
4129 (setq mime-type (completing-read
4130 "View as MIME type: "
4131 (mapcar #'list (mailcap-mime-types))
4133 (gnus-mime-view-part-as-type-internal))))
4134 (gnus-article-check-buffer)
4135 (let ((handle (get-text-property (point) 'gnus-data)))
4138 (mm-make-handle (mm-handle-buffer handle)
4139 (cons mime-type (cdr (mm-handle-type handle)))
4140 (mm-handle-encoding handle)
4141 (mm-handle-undisplayer handle)
4142 (mm-handle-disposition handle)
4143 (mm-handle-description handle)
4145 (mm-handle-id handle)))
4146 (setq gnus-article-mime-handles
4147 (mm-merge-handles gnus-article-mime-handles handle))
4148 (gnus-mm-display-part handle))))
4151 (require 'jka-compr))
4153 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4154 ;; emacs can do that itself.
4156 (defun gnus-mime-jka-compr-maybe-uncompress ()
4157 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4158 The uncompress method used is derived from `buffer-file-name'."
4159 (when (and (fboundp 'jka-compr-installed-p)
4160 (jka-compr-installed-p))
4161 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4163 (let ((basename (file-name-nondirectory buffer-file-name))
4164 (args (jka-compr-info-uncompress-args info))
4165 (prog (jka-compr-info-uncompress-program info))
4166 (message (jka-compr-info-uncompress-message info))
4167 (err-file (jka-compr-make-temp-name)))
4169 (message "%s %s..." message basename))
4171 (unless (memq (apply 'call-process-region
4172 (point-min) (point-max)
4174 t (list t err-file) nil
4176 jka-compr-acceptable-retval-list)
4177 (jka-compr-error prog args basename message err-file))
4178 (jka-compr-delete-temp-file err-file)))))))
4180 (defun gnus-mime-copy-part (&optional handle)
4181 "Put the MIME part under point into a new buffer.
4182 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4185 (gnus-article-check-buffer)
4186 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4187 (contents (and handle (mm-get-part handle)))
4189 (file-name-nondirectory
4191 (mail-content-type-get (mm-handle-type handle) 'name)
4192 (mail-content-type-get (mm-handle-disposition handle)
4195 (buffer (and base (generate-new-buffer base))))
4197 (switch-to-buffer buffer)
4199 ;; We do it this way to make `normal-mode' set the appropriate mode.
4202 (setq buffer-file-name (expand-file-name base))
4203 (gnus-mime-jka-compr-maybe-uncompress)
4205 (setq buffer-file-name nil))
4206 (goto-char (point-min)))))
4208 (defun gnus-mime-print-part (&optional handle filename)
4209 "Print the MIME part under point."
4210 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4211 (gnus-article-check-buffer)
4212 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4213 (contents (and handle (mm-get-part handle)))
4214 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4215 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4220 (mm-save-part-to-file handle file)
4221 (call-process shell-file-name nil
4222 (generate-new-buffer " *mm*")
4224 shell-command-switch
4226 printer file (mm-handle-type handle))))
4230 (gnus-print-buffer))
4231 (ps-despool filename)))))
4233 (defun gnus-mime-inline-part (&optional handle arg)
4234 "Insert the MIME part under point into the current buffer."
4235 (interactive (list nil current-prefix-arg))
4236 (gnus-article-check-buffer)
4237 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4240 (inhibit-read-only t))
4242 (if (and (not arg) (mm-handle-undisplayer handle))
4243 (mm-remove-part handle)
4244 (setq contents (mm-get-part handle))
4247 (setq charset (or (mail-content-type-get
4248 (mm-handle-type handle) 'charset)
4249 gnus-newsgroup-charset)))
4251 (if (mm-handle-undisplayer handle)
4252 (mm-remove-part handle))
4255 gnus-summary-show-article-charset-alist))
4256 (mm-read-coding-system "Charset: ")))))
4258 (mm-insert-inline handle
4260 (setq charset (mm-charset-to-coding-system
4262 (not (eq charset 'ascii)))
4263 (mm-decode-coding-string contents charset)
4267 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4268 "Insert the MIME part under point into the current buffer using the
4270 (interactive (list nil current-prefix-arg))
4271 (gnus-article-check-buffer)
4272 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4275 (inhibit-read-only t))
4277 (if (mm-handle-undisplayer handle)
4278 (mm-remove-part handle))
4279 (let ((gnus-newsgroup-charset
4281 gnus-summary-show-article-charset-alist))
4282 (mm-read-coding-system "Charset: ")))
4283 (gnus-newsgroup-ignored-charsets 'gnus-all))
4284 (gnus-article-press-button)))))
4286 (defun gnus-mime-view-part-externally (&optional handle)
4287 "View the MIME part under point with an external viewer."
4289 (gnus-article-check-buffer)
4290 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4291 (mm-user-display-methods nil)
4292 (mm-inlined-types nil)
4293 (mail-parse-charset gnus-newsgroup-charset)
4294 (mail-parse-ignored-charsets
4295 (with-current-buffer gnus-summary-buffer
4296 gnus-newsgroup-ignored-charsets)))
4298 (if (mm-handle-undisplayer handle)
4299 (mm-remove-part handle)
4300 (mm-display-part handle)))))
4302 (defun gnus-mime-view-part-internally (&optional handle)
4303 "View the MIME part under point with an internal viewer.
4304 If no internal viewer is available, use an external viewer."
4306 (gnus-article-check-buffer)
4307 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4308 (mm-inlined-types '(".*"))
4309 (mm-inline-large-images t)
4310 (mail-parse-charset gnus-newsgroup-charset)
4311 (mail-parse-ignored-charsets
4312 (with-current-buffer gnus-summary-buffer
4313 gnus-newsgroup-ignored-charsets))
4314 (inhibit-read-only t))
4316 (if (mm-handle-undisplayer handle)
4317 (mm-remove-part handle)
4318 (mm-display-part handle)))))
4320 (defun gnus-mime-action-on-part (&optional action)
4321 "Do something with the MIME attachment at \(point\)."
4323 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4324 (gnus-article-check-buffer)
4325 (let ((action-pair (assoc action gnus-mime-action-alist)))
4327 (funcall (cdr action-pair)))))
4329 (defun gnus-article-part-wrapper (n function)
4330 (with-current-buffer gnus-article-buffer
4331 (when (> n (length gnus-article-mime-handle-alist))
4332 (error "No such part"))
4333 (gnus-article-goto-part n)
4334 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4335 (funcall function handle))))
4337 (defun gnus-article-pipe-part (n)
4338 "Pipe MIME part N, which is the numerical prefix."
4340 (gnus-article-part-wrapper n 'mm-pipe-part))
4342 (defun gnus-article-save-part (n)
4343 "Save MIME part N, which is the numerical prefix."
4345 (gnus-article-part-wrapper n 'mm-save-part))
4347 (defun gnus-article-interactively-view-part (n)
4348 "View MIME part N interactively, which is the numerical prefix."
4350 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4352 (defun gnus-article-copy-part (n)
4353 "Copy MIME part N, which is the numerical prefix."
4355 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4357 (defun gnus-article-view-part-as-charset (n)
4358 "View MIME part N using a specified charset.
4359 N is the numerical prefix."
4361 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4363 (defun gnus-article-view-part-externally (n)
4364 "View MIME part N externally, which is the numerical prefix."
4366 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4368 (defun gnus-article-inline-part (n)
4369 "Inline MIME part N, which is the numerical prefix."
4371 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4373 (defun gnus-article-mime-match-handle-first (condition)
4376 (dolist (ihandle gnus-article-mime-handle-alist)
4378 ((functionp condition)
4379 (funcall condition (cdr ihandle)))
4380 ((eq condition 'undisplayed)
4381 (not (or (mm-handle-undisplayer (cdr ihandle))
4382 (equal (mm-handle-media-type (cdr ihandle))
4383 "multipart/alternative"))))
4384 ((eq condition 'undisplayed-alternative)
4385 (not (mm-handle-undisplayer (cdr ihandle))))
4387 (gnus-article-goto-part (car ihandle))
4388 (or (not n) (< (car ihandle) n)))
4389 (setq n (car ihandle))))
4393 (defun gnus-article-view-part (&optional n)
4394 "View MIME part N, which is the numerical prefix."
4396 (with-current-buffer gnus-article-buffer
4397 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4398 gnus-article-mime-match-handle-function)))
4399 (when (> n (length gnus-article-mime-handle-alist))
4400 (error "No such part"))
4401 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4402 (when (gnus-article-goto-part n)
4403 (if (equal (car handle) "multipart/alternative")
4404 (gnus-article-press-button)
4405 (when (eq (gnus-mm-display-part handle) 'internal)
4406 (gnus-set-window-start)))))))
4408 (defsubst gnus-article-mime-total-parts ()
4409 (if (bufferp (car gnus-article-mime-handles))
4411 (1- (length gnus-article-mime-handles))))
4413 (defun gnus-mm-display-part (handle)
4414 "Display HANDLE and fix MIME button."
4415 (let ((id (get-text-property (point) 'gnus-part))
4417 (inhibit-read-only t))
4420 (let ((window (selected-window))
4421 (mail-parse-charset gnus-newsgroup-charset)
4422 (mail-parse-ignored-charsets
4423 (if (gnus-buffer-live-p gnus-summary-buffer)
4424 (with-current-buffer gnus-summary-buffer
4425 gnus-newsgroup-ignored-charsets)
4429 (let ((win (gnus-get-buffer-window (current-buffer) t))
4432 (select-window win))
4435 (if (mm-handle-displayed-p handle)
4436 ;; This will remove the part.
4437 (mm-display-part handle)
4439 (narrow-to-region (point)
4440 (if (eobp) (point) (1+ (point))))
4441 (mm-display-part handle)
4442 ;; We narrow to the part itself and
4443 ;; then call the treatment functions.
4444 (goto-char (point-min))
4446 (narrow-to-region (point) (point-max))
4449 (gnus-article-mime-total-parts)
4450 (mm-handle-media-type handle)))))
4451 (if (window-live-p window)
4452 (select-window window)))))
4455 (gnus-insert-mime-button
4456 handle id (list (mm-handle-displayed-p handle)))
4457 (goto-char point))))
4459 (defun gnus-article-goto-part (n)
4460 "Go to MIME part N."
4461 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4463 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4464 (let ((gnus-tmp-name
4465 (or (mail-content-type-get (mm-handle-type handle) 'name)
4466 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4467 (mail-content-type-get (mm-handle-type handle) 'url)
4469 (gnus-tmp-type (mm-handle-media-type handle))
4470 (gnus-tmp-description
4471 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4474 (if (if displayed (car displayed)
4475 (mm-handle-displayed-p handle))
4477 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4479 gnus-tmp-type-long b e)
4480 (when (string-match ".*/" gnus-tmp-name)
4481 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4482 (setq gnus-tmp-type-long (concat gnus-tmp-type
4483 (and (not (equal gnus-tmp-name ""))
4484 (concat "; " gnus-tmp-name))))
4485 (unless (equal gnus-tmp-description "")
4486 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4491 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4492 `(keymap ,gnus-mime-button-map
4493 gnus-callback gnus-mm-display-part
4494 gnus-part ,gnus-tmp-id
4495 article-type annotation
4498 ;; Exclude a newline.
4501 (widget-convert-button
4504 :action 'gnus-widget-press-button
4505 :button-keymap gnus-mime-button-map
4507 (lambda (widget/window &optional overlay pos)
4508 ;; Needed to properly clear the message due to a bug in
4509 ;; wid-edit (XEmacs only).
4510 (if (boundp 'help-echo-owns-message)
4511 (setq help-echo-owns-message t))
4513 "%S: %s the MIME part; %S: more options"
4514 (aref gnus-mouse-2 0)
4515 ;; XEmacs will get a single widget arg; Emacs 21 will get
4516 ;; window, overlay, position.
4517 (if (mm-handle-displayed-p
4519 (with-current-buffer (gnus-overlay-buffer overlay)
4520 (widget-get (widget-at (gnus-overlay-start overlay))
4522 (widget-get widget/window :mime-handle)))
4524 (aref gnus-down-mouse-3 0))))))
4526 (defun gnus-widget-press-button (elems el)
4527 (goto-char (widget-get elems :from))
4528 (gnus-article-press-button))
4530 (defvar gnus-displaying-mime nil)
4532 (defun gnus-display-mime (&optional ihandles)
4533 "Display the MIME parts."
4535 (save-selected-window
4536 (let ((window (get-buffer-window gnus-article-buffer))
4539 (select-window window)
4540 ;; We have to do this since selecting the window
4541 ;; may change the point. So we set the window point.
4542 (set-window-point window point)))
4543 (let ((handles ihandles)
4544 (inhibit-read-only t)
4545 handle name type b e display)
4547 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4548 (when gnus-article-emulate-mime
4549 (mm-uu-dissect-text-parts handles)))
4550 (gnus-article-emulate-mime
4551 (setq handles (mm-uu-dissect))))
4552 (when (and (not ihandles)
4553 (not gnus-displaying-mime))
4554 ;; Top-level call; we clean up.
4555 (when gnus-article-mime-handles
4556 (mm-destroy-parts gnus-article-mime-handles)
4557 (setq gnus-article-mime-handle-alist nil));; A trick.
4558 (setq gnus-article-mime-handles handles)
4559 ;; We allow users to glean info from the handles.
4560 (when gnus-article-mime-part-function
4561 (gnus-mime-part-function handles)))
4563 (or (not (stringp (car handles)))
4566 (when (and (not ihandles)
4567 (not gnus-displaying-mime))
4568 ;; Clean up for mime parts.
4570 (delete-region (point) (point-max)))
4571 (let ((gnus-displaying-mime t))
4572 (gnus-mime-display-part handles)))
4575 (narrow-to-region (point) (point-max))
4576 (gnus-treat-article nil 1 1)
4579 ;; Highlight the headers.
4583 (narrow-to-region (point-min) (point))
4584 (gnus-treat-article 'head))))))))
4586 (defcustom gnus-mime-display-multipart-as-mixed nil
4587 "Display \"multipart\" parts as \"multipart/mixed\".
4589 If t, it overrides nil values of
4590 `gnus-mime-display-multipart-alternative-as-mixed' and
4591 `gnus-mime-display-multipart-related-as-mixed'."
4592 :group 'gnus-article-mime
4595 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4596 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4598 :group 'gnus-article-mime
4601 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4602 "Display \"multipart/related\" parts as \"multipart/mixed\".
4604 If displaying \"text/html\" is discouraged \(see
4605 `mm-discouraged-alternatives'\) images or other material inside a
4606 \"multipart/related\" part might be overlooked when this variable is nil."
4608 :group 'gnus-article-mime
4611 (defun gnus-mime-display-part (handle)
4614 ((not (stringp (car handle)))
4615 (gnus-mime-display-single handle))
4616 ;; User-defined multipart
4617 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4618 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4620 ;; multipart/alternative
4621 ((and (equal (car handle) "multipart/alternative")
4622 (not (or gnus-mime-display-multipart-as-mixed
4623 gnus-mime-display-multipart-alternative-as-mixed)))
4624 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4625 (push (cons id handle) gnus-article-mime-handle-alist)
4626 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4627 ;; multipart/related
4628 ((and (equal (car handle) "multipart/related")
4629 (not (or gnus-mime-display-multipart-as-mixed
4630 gnus-mime-display-multipart-related-as-mixed)))
4631 ;;;!!!We should find the start part, but we just default
4632 ;;;!!!to the first part.
4633 ;;(gnus-mime-display-part (cadr handle))
4634 ;;;!!! Most multipart/related is an HTML message plus images.
4635 ;;;!!! Unfortunately we are unable to let W3 display those
4636 ;;;!!! included images, so we just display it as a mixed multipart.
4637 ;;(gnus-mime-display-mixed (cdr handle))
4638 ;;;!!! No, w3 can display everything just fine.
4639 (gnus-mime-display-part (cadr handle)))
4640 ((equal (car handle) "multipart/signed")
4641 (gnus-add-wash-type 'signed)
4642 (gnus-mime-display-security handle))
4643 ((equal (car handle) "multipart/encrypted")
4644 (gnus-add-wash-type 'encrypted)
4645 (gnus-mime-display-security handle))
4646 ;; Other multiparts are handled like multipart/mixed.
4648 (gnus-mime-display-mixed (cdr handle)))))
4650 (defun gnus-mime-part-function (handles)
4651 (if (stringp (car handles))
4652 (mapcar 'gnus-mime-part-function (cdr handles))
4653 (funcall gnus-article-mime-part-function handles)))
4655 (defun gnus-mime-display-mixed (handles)
4656 (mapcar 'gnus-mime-display-part handles))
4658 (defun gnus-mime-display-single (handle)
4659 (let ((type (mm-handle-media-type handle))
4660 (ignored gnus-ignored-mime-types)
4667 (when (string-match (pop ignored) type)
4668 (throw 'ignored nil)))
4669 (if (and (setq not-attachment
4670 (and (not (mm-inline-override-p handle))
4671 (or (not (mm-handle-disposition handle))
4672 (equal (car (mm-handle-disposition handle))
4674 (mm-attachment-override-p handle))))
4675 (mm-automatic-display-p handle)
4677 (mm-inlinable-p handle)
4678 (mm-inlined-p handle))
4679 (mm-automatic-external-display-p type)))
4681 (when (equal (mm-handle-media-supertype handle) "text")
4683 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4685 (push (cons id handle) gnus-article-mime-handle-alist)
4686 (when (or (not display)
4687 (not (gnus-unbuttonized-mime-type-p type)))
4688 (gnus-insert-mime-button
4689 handle id (list (or display (and not-attachment text))))
4690 (gnus-article-insert-newline)
4691 ;; Remember modify the number of forward lines.
4699 (let ((mail-parse-charset gnus-newsgroup-charset)
4700 (mail-parse-ignored-charsets
4701 (save-excursion (condition-case ()
4702 (set-buffer gnus-summary-buffer)
4704 gnus-newsgroup-ignored-charsets)))
4705 (mm-display-part handle t))
4706 (goto-char (point-max)))
4707 ((and text not-attachment)
4711 (gnus-article-insert-newline)
4712 (mm-insert-inline handle (mm-get-part handle))
4713 (goto-char (point-max))))
4717 (narrow-to-region beg (point))
4720 (gnus-article-mime-total-parts)
4721 (mm-handle-media-type handle)))))))))
4723 (defun gnus-unbuttonized-mime-type-p (type)
4724 "Say whether TYPE is to be unbuttonized."
4725 (unless gnus-inhibit-mime-unbuttonizing
4727 (let ((types gnus-unbuttonized-mime-types))
4729 (when (string-match (pop types) type)
4730 (throw 'found t)))))
4732 (let ((types gnus-buttonized-mime-types))
4734 (when (string-match (pop types) type)
4735 (throw 'found t)))))))))
4737 (defun gnus-article-insert-newline ()
4738 "Insert a newline, but mark it as undeletable."
4739 (gnus-put-text-property
4740 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4742 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4743 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4746 handle (inhibit-read-only t) from props begend not-pref)
4747 (save-window-excursion
4750 (narrow-to-region (car ibegend)
4753 (goto-char (car ibegend))
4756 (delete-region (point-min) (point-max))
4757 (mm-remove-parts handles))
4758 (setq begend (list (point-marker)))
4760 (unless (setq not-pref (cadr (member preferred ihandles)))
4761 (setq not-pref (car ihandles)))
4764 (not (gnus-unbuttonized-mime-type-p
4765 "multipart/alternative")))
4766 (gnus-add-text-properties
4769 (insert (format "%d. " id))
4773 (unless ,(not ibegend)
4774 (setq gnus-article-mime-handle-alist
4775 ',gnus-article-mime-handle-alist))
4776 (gnus-mime-display-alternative
4777 ',ihandles ',not-pref ',begend ,id))
4778 keymap ,gnus-mime-button-map
4779 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4780 face ,gnus-article-button-face
4783 (widget-convert-button 'link from (point)
4784 :action 'gnus-widget-press-button
4785 :button-keymap gnus-widget-button-keymap)
4787 (while (setq handle (pop handles))
4788 (gnus-add-text-properties
4791 (insert (format "(%c) %-18s"
4792 (if (equal handle preferred) ?* ? )
4793 (mm-handle-media-type handle)))
4797 (unless ,(not ibegend)
4798 (setq gnus-article-mime-handle-alist
4799 ',gnus-article-mime-handle-alist))
4800 (gnus-mime-display-alternative
4801 ',ihandles ',handle ',begend ,id))
4802 keymap ,gnus-mime-button-map
4803 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4804 face ,gnus-article-button-face
4807 (widget-convert-button 'link from (point)
4808 :action 'gnus-widget-press-button
4809 :button-keymap gnus-widget-button-keymap)
4813 (if (stringp (car preferred))
4814 (gnus-display-mime preferred)
4815 (let ((mail-parse-charset gnus-newsgroup-charset)
4816 (mail-parse-ignored-charsets
4817 (with-current-buffer gnus-summary-buffer
4818 gnus-newsgroup-ignored-charsets)))
4819 (mm-display-part preferred)
4823 (narrow-to-region (car begend) (point-max))
4825 nil (length gnus-article-mime-handle-alist)
4826 (gnus-article-mime-total-parts)
4827 (mm-handle-media-type handle))))))
4828 (goto-char (point-max))
4829 (setcdr begend (point-marker)))))
4831 (goto-char point))))
4833 (defconst gnus-article-wash-status-strings
4834 (let ((alist '((cite "c" "Possible hidden citation text"
4835 " " "All citation text visible")
4836 (headers "h" "Hidden headers"
4837 " " "All headers visible.")
4838 (pgp "p" "Encrypted or signed message status hidden"
4839 " " "No hidden encryption nor digital signature status")
4840 (signature "s" "Signature has been hidden"
4841 " " "Signature is visible")
4842 (overstrike "o" "Overstrike (^H) characters applied"
4843 " " "No overstrike characters applied")
4844 (emphasis "e" "/*_Emphasis_*/ characters applied"
4845 " " "No /*_emphasis_*/ characters applied")))
4847 (dolist (entry alist result)
4848 (let ((key (nth 0 entry))
4849 (on (copy-sequence (nth 1 entry)))
4850 (on-help (nth 2 entry))
4851 (off (copy-sequence (nth 3 entry)))
4852 (off-help (nth 4 entry)))
4853 (put-text-property 0 1 'help-echo on-help on)
4854 (put-text-property 0 1 'help-echo off-help off)
4855 (push (list key on off) result))))
4856 "Alist of strings describing wash status in the mode line.
4857 Each entry has the form (KEY ON OF), where the KEY is a symbol
4858 representing the particular washing function, ON is the string to use
4859 in the article mode line when the washing function is active, and OFF
4860 is the string to use when it is inactive.")
4862 (defun gnus-article-wash-status-entry (key value)
4863 (let ((entry (assoc key gnus-article-wash-status-strings)))
4864 (if value (nth 1 entry) (nth 2 entry))))
4866 (defun gnus-article-wash-status ()
4867 "Return a string which display status of article washing."
4868 (with-current-buffer gnus-article-buffer
4869 (let ((cite (memq 'cite gnus-article-wash-types))
4870 (headers (memq 'headers gnus-article-wash-types))
4871 (boring (memq 'boring-headers gnus-article-wash-types))
4872 (pgp (memq 'pgp gnus-article-wash-types))
4873 (pem (memq 'pem gnus-article-wash-types))
4874 (signed (memq 'signed gnus-article-wash-types))
4875 (encrypted (memq 'encrypted gnus-article-wash-types))
4876 (signature (memq 'signature gnus-article-wash-types))
4877 (overstrike (memq 'overstrike gnus-article-wash-types))
4878 (emphasis (memq 'emphasis gnus-article-wash-types)))
4880 (gnus-article-wash-status-entry 'cite cite)
4881 (gnus-article-wash-status-entry 'headers (or headers boring))
4882 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4883 (gnus-article-wash-status-entry 'signature signature)
4884 (gnus-article-wash-status-entry 'overstrike overstrike)
4885 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4887 (defun gnus-add-wash-type (type)
4888 "Add a washing of TYPE to the current status."
4889 (add-to-list 'gnus-article-wash-types type))
4891 (defun gnus-delete-wash-type (type)
4892 "Add a washing of TYPE to the current status."
4893 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4895 (defun gnus-add-image (category image)
4896 "Add IMAGE of CATEGORY to the list of displayed images."
4897 (let ((entry (assq category gnus-article-image-alist)))
4899 (setq entry (list category))
4900 (push entry gnus-article-image-alist))
4901 (nconc entry (list image))))
4903 (defun gnus-delete-images (category)
4904 "Delete all images in CATEGORY."
4905 (let ((entry (assq category gnus-article-image-alist)))
4906 (dolist (image (cdr entry))
4907 (gnus-remove-image image category))
4908 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4909 (gnus-delete-wash-type category)))
4911 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4913 (defun gnus-article-maybe-hide-headers ()
4914 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4915 Provided for backwards compatibility."
4916 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4917 (not (with-current-buffer gnus-summary-buffer
4918 gnus-have-all-headers)))
4919 (not gnus-inhibit-hiding))
4920 (gnus-article-hide-headers)))
4924 (defun gnus-output-to-file (file-name)
4925 "Append the current article to a file named FILE-NAME."
4926 (let ((artbuf (current-buffer)))
4928 (insert-buffer-substring artbuf)
4929 ;; Append newline at end of the buffer as separator, and then
4931 (goto-char (point-max))
4933 (let ((file-name-coding-system nnmail-pathname-coding-system))
4934 (mm-append-to-file (point-min) (point-max) file-name))
4937 (defun gnus-narrow-to-page (&optional arg)
4938 "Narrow the article buffer to a page.
4939 If given a numerical ARG, move forward ARG pages."
4941 (setq arg (if arg (prefix-numeric-value arg) 0))
4943 (set-buffer gnus-article-buffer)
4944 (goto-char (point-min))
4946 ;; Remove any old next/prev buttons.
4947 (when (gnus-visual-p 'page-marker)
4948 (let ((inhibit-read-only t))
4949 (gnus-remove-text-with-property 'gnus-prev)
4950 (gnus-remove-text-with-property 'gnus-next)))
4953 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4955 (re-search-forward page-delimiter nil 'move arg)))
4956 (goto-char (match-end 0))
4958 (goto-char (point-min))
4959 (setq gnus-page-broken
4960 (and (re-search-forward page-delimiter nil t) t))))
4961 (when gnus-page-broken
4964 (if (re-search-forward page-delimiter nil 'move)
4967 (when (and (gnus-visual-p 'page-marker)
4968 (> (point-min) (save-restriction (widen) (point-min))))
4970 (goto-char (point-min))
4971 (gnus-insert-prev-page-button)))
4972 (when (and (gnus-visual-p 'page-marker)
4973 (< (+ (point-max) 2) (buffer-size)))
4975 (goto-char (point-max))
4976 (gnus-insert-next-page-button))))))
4978 ;; Article mode commands
4980 (defun gnus-article-goto-next-page ()
4981 "Show the next page of the article."
4983 (when (gnus-article-next-page)
4984 (goto-char (point-min))
4985 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4988 (defun gnus-article-goto-prev-page ()
4989 "Show the previous page of the article."
4992 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4993 (gnus-article-prev-page nil)))
4995 ;; This is cleaner but currently breaks `gnus-pick-mode':
4997 ;; (defun gnus-article-goto-next-page ()
4998 ;; "Show the next page of the article."
5000 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5001 ;; (gnus-summary-next-page)))
5003 ;; (defun gnus-article-goto-prev-page ()
5004 ;; "Show the next page of the article."
5006 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5007 ;; (gnus-summary-prev-page)))
5009 (defun gnus-article-next-page (&optional lines)
5010 "Show the next page of the current article.
5011 If end of article, return non-nil. Otherwise return nil.
5012 Argument LINES specifies lines to be scrolled up."
5014 (move-to-window-line -1)
5017 (and (pos-visible-in-window-p) ;Not continuation line.
5018 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5019 ;; Nothing in this page.
5020 (if (or (not gnus-page-broken)
5025 (eobp)))) ;Real end-of-buffer?
5027 (when gnus-article-over-scroll
5028 (gnus-article-next-page-1 lines))
5030 (gnus-narrow-to-page 1) ;Go to next page.
5032 ;; More in this page.
5033 (gnus-article-next-page-1 lines)
5036 (defun gnus-article-next-page-1 (lines)
5037 (let ((scroll-in-place nil))
5041 ;; Long lines may cause an end-of-buffer error.
5042 (goto-char (point-max)))))
5043 (move-to-window-line 0))
5045 (defun gnus-article-prev-page (&optional lines)
5046 "Show previous page of current article.
5047 Argument LINES specifies lines to be scrolled down."
5049 (move-to-window-line 0)
5050 (if (and gnus-page-broken
5052 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5054 (gnus-narrow-to-page -1) ;Go to previous page.
5055 (goto-char (point-max))
5057 (let ((scroll-in-place nil))
5061 (beginning-of-buffer
5062 (goto-char (point-min))))
5063 (move-to-window-line 0)))))
5065 (defun gnus-article-only-boring-p ()
5066 "Decide whether there is only boring text remaining in the article.
5067 Something \"interesting\" is a word of at least two letters that does
5068 not have a face in `gnus-article-boring-faces'."
5069 (when (and gnus-article-skip-boring
5070 (boundp 'gnus-article-boring-faces)
5071 (symbol-value 'gnus-article-boring-faces))
5074 (while (re-search-forward "\\b\\w\\w" nil t)
5076 (when (not (gnus-intersection
5077 (gnus-faces-at (point))
5078 (symbol-value 'gnus-article-boring-faces)))
5079 (throw 'only-boring nil)))
5080 (throw 'only-boring t)))))
5082 (defun gnus-article-refer-article ()
5083 "Read article specified by message-id around point."
5086 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5087 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5088 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5089 (let ((msg-id (concat "<" (match-string 0) ">")))
5090 (set-buffer gnus-summary-buffer)
5091 (gnus-summary-refer-article msg-id))
5092 (error "No references around point"))))
5094 (defun gnus-article-show-summary ()
5095 "Reconfigure windows to show summary buffer."
5097 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5098 (error "There is no summary buffer for this article buffer")
5099 (gnus-article-set-globals)
5100 (gnus-configure-windows 'article)
5101 (gnus-summary-goto-subject gnus-current-article)
5102 (gnus-summary-position-point)))
5104 (defun gnus-article-describe-briefly ()
5105 "Describe article mode commands briefly."
5107 (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")))
5109 (defun gnus-article-summary-command ()
5110 "Execute the last keystroke in the summary buffer."
5112 (let ((obuf (current-buffer))
5113 (owin (current-window-configuration))
5115 (switch-to-buffer gnus-article-current-summary 'norecord)
5116 (setq func (lookup-key (current-local-map) (this-command-keys)))
5117 (call-interactively func)
5119 (set-window-configuration owin)
5120 (set-window-point (get-buffer-window (current-buffer)) (point))))
5122 (defun gnus-article-summary-command-nosave ()
5123 "Execute the last keystroke in the summary buffer."
5126 (pop-to-buffer gnus-article-current-summary 'norecord)
5127 (setq func (lookup-key (current-local-map) (this-command-keys)))
5128 (call-interactively func)))
5130 (defun gnus-article-check-buffer ()
5131 "Beep if not in an article buffer."
5132 (unless (equal major-mode 'gnus-article-mode)
5133 (error "Command invoked outside of a Gnus article buffer")))
5135 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5136 "Read a summary buffer key sequence and execute it from the article buffer."
5138 (gnus-article-check-buffer)
5140 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5141 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5142 "=" "^" "\M-^" "|"))
5148 '("n" "Gn" "p" "Gp"))
5151 (set-buffer gnus-article-current-summary)
5152 (let (gnus-pick-mode)
5153 (push (or key last-command-event) unread-command-events)
5154 (setq keys (if (featurep 'xemacs)
5155 (events-to-keys (read-key-sequence nil))
5156 (read-key-sequence nil)))))
5160 (if (or (member keys nosaves)
5161 (member keys nosave-but-article)
5162 (member keys nosave-in-article))
5164 (save-window-excursion
5165 (pop-to-buffer gnus-article-current-summary 'norecord)
5166 ;; We disable the pick minor mode commands.
5167 (let (gnus-pick-mode)
5168 (setq func (lookup-key (current-local-map) keys))))
5172 (unless (member keys nosave-in-article)
5173 (set-buffer gnus-article-current-summary))
5174 (call-interactively func)
5175 (setq new-sum-point (point)))
5176 (when (member keys nosave-but-article)
5177 (pop-to-buffer gnus-article-buffer 'norecord)))
5178 ;; These commands should restore window configuration.
5179 (let ((obuf (current-buffer))
5180 (owin (current-window-configuration))
5182 win func in-buffer selected new-sum-start new-sum-hscroll)
5183 (cond (not-restore-window
5184 (pop-to-buffer gnus-article-current-summary 'norecord))
5185 ((setq win (get-buffer-window gnus-article-current-summary))
5186 (select-window win))
5188 (switch-to-buffer gnus-article-current-summary 'norecord)))
5189 (setq in-buffer (current-buffer))
5190 ;; We disable the pick minor mode commands.
5191 (if (and (setq func (let (gnus-pick-mode)
5192 (lookup-key (current-local-map) keys)))
5195 (call-interactively func)
5196 (when (eq win (selected-window))
5197 (setq new-sum-point (point)
5198 new-sum-start (window-start win)
5199 new-sum-hscroll (window-hscroll win))
5200 (when (eq in-buffer (current-buffer))
5201 (setq selected (gnus-summary-select-article))
5203 (unless not-restore-window
5204 (set-window-configuration owin))
5205 (when (eq selected 'old)
5207 (set-window-start (get-buffer-window (current-buffer))
5209 (set-window-point (get-buffer-window (current-buffer))
5211 (when (and (not not-restore-window)
5213 (set-window-point win new-sum-point)
5214 (set-window-start win new-sum-start)
5215 (set-window-hscroll win new-sum-hscroll)))))
5216 (set-window-configuration owin)
5219 (defun gnus-article-describe-key (key)
5220 "Display documentation of the function invoked by KEY. KEY is a string."
5221 (interactive "kDescribe key: ")
5222 (gnus-article-check-buffer)
5223 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5225 (set-buffer gnus-article-current-summary)
5226 (let (gnus-pick-mode)
5227 (if (featurep 'xemacs)
5229 (push (elt key 0) unread-command-events)
5230 (setq key (events-to-keys
5231 (read-key-sequence "Describe key: "))))
5232 (setq unread-command-events
5234 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5235 (string-to-list key)))
5236 (setq key (read-key-sequence "Describe key: "))))
5238 (describe-key key)))
5240 (defun gnus-article-describe-key-briefly (key &optional insert)
5241 "Display documentation of the function invoked by KEY. KEY is a string."
5242 (interactive "kDescribe key: \nP")
5243 (gnus-article-check-buffer)
5244 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5246 (set-buffer gnus-article-current-summary)
5247 (let (gnus-pick-mode)
5248 (if (featurep 'xemacs)
5250 (push (elt key 0) unread-command-events)
5251 (setq key (events-to-keys
5252 (read-key-sequence "Describe key: "))))
5253 (setq unread-command-events
5255 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5256 (string-to-list key)))
5257 (setq key (read-key-sequence "Describe key: "))))
5258 (describe-key-briefly key insert))
5259 (describe-key-briefly key insert)))
5261 (defun gnus-article-reply-with-original (&optional wide)
5262 "Start composing a reply mail to the current message.
5263 The text in the region will be yanked. If the region isn't active,
5264 the entire article will be yanked."
5266 (let ((article (cdr gnus-article-current))
5268 (if (not (gnus-region-active-p))
5269 (with-current-buffer gnus-summary-buffer
5270 (gnus-summary-reply (list (list article)) wide))
5271 (setq contents (buffer-substring (point) (mark t)))
5272 ;; Deactivate active regions.
5273 (when (and (boundp 'transient-mark-mode)
5274 transient-mark-mode)
5275 (setq mark-active nil))
5276 (with-current-buffer gnus-summary-buffer
5278 (list (list article contents)) wide)))))
5280 (defun gnus-article-followup-with-original ()
5281 "Compose a followup to the current article.
5282 The text in the region will be yanked. If the region isn't active,
5283 the entire article will be yanked."
5285 (let ((article (cdr gnus-article-current))
5287 (if (not (gnus-region-active-p))
5288 (with-current-buffer gnus-summary-buffer
5289 (gnus-summary-followup (list (list article))))
5290 (setq contents (buffer-substring (point) (mark t)))
5291 ;; Deactivate active regions.
5292 (when (and (boundp 'transient-mark-mode)
5293 transient-mark-mode)
5294 (setq mark-active nil))
5295 (with-current-buffer gnus-summary-buffer
5296 (gnus-summary-followup
5297 (list (list article contents)))))))
5299 (defun gnus-article-hide (&optional arg force)
5300 "Hide all the gruft in the current article.
5301 This means that signatures, cited text and (some) headers will be
5303 If given a prefix, show the hidden text instead."
5304 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5305 (gnus-article-hide-headers arg)
5306 (gnus-article-hide-list-identifiers arg)
5307 (gnus-article-hide-citation-maybe arg force)
5308 (gnus-article-hide-signature arg))
5310 (defun gnus-article-maybe-highlight ()
5311 "Do some article highlighting if article highlighting is requested."
5312 (when (gnus-visual-p 'article-highlight 'highlight)
5313 (gnus-article-highlight-some)))
5315 (defun gnus-check-group-server ()
5316 ;; Make sure the connection to the server is alive.
5317 (unless (gnus-server-opened
5318 (gnus-find-method-for-group gnus-newsgroup-name))
5319 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5320 (gnus-request-group gnus-newsgroup-name t)))
5323 (autoload 'nneething-get-file-name "nneething"))
5325 (defun gnus-request-article-this-buffer (article group)
5326 "Get an article and insert it into this buffer."
5327 (let (do-update-line sparse-header)
5331 (gnus-kill-all-overlays)
5332 (setq group (or group gnus-newsgroup-name))
5334 ;; Using `gnus-request-article' directly will insert the article into
5335 ;; `nntp-server-buffer' - so we'll save some time by not having to
5336 ;; copy it from the server buffer into the article buffer.
5338 ;; We only request an article by message-id when we do not have the
5339 ;; headers for it, so we'll have to get those.
5340 (when (stringp article)
5341 (gnus-read-header article))
5343 ;; If the article number is negative, that means that this article
5344 ;; doesn't belong in this newsgroup (possibly), so we find its
5345 ;; message-id and request it by id instead of number.
5346 (when (and (numberp article)
5348 (get-buffer gnus-summary-buffer)
5349 (gnus-buffer-exists-p gnus-summary-buffer))
5351 (set-buffer gnus-summary-buffer)
5352 (let ((header (gnus-summary-article-header article)))
5355 ((memq article gnus-newsgroup-sparse)
5356 ;; This is a sparse gap article.
5357 (setq do-update-line article)
5358 (setq article (mail-header-id header))
5359 (setq sparse-header (gnus-read-header article))
5360 (setq gnus-newsgroup-sparse
5361 (delq article gnus-newsgroup-sparse)))
5363 ;; It's a real article.
5364 (setq article (mail-header-id header)))
5366 ;; It is an extracted pseudo-article.
5367 (setq article 'pseudo)
5368 (gnus-request-pseudo-article header))))
5370 (let ((method (gnus-find-method-for-group
5371 gnus-newsgroup-name)))
5372 (when (and (eq (car method) 'nneething)
5374 (let ((dir (nneething-get-file-name
5375 (mail-header-id header))))
5376 (when (and (stringp dir)
5377 (file-directory-p dir))
5378 (setq article 'nneething)
5379 (gnus-group-enter-directory dir))))))))
5382 ;; Refuse to select canceled articles.
5383 ((and (numberp article)
5385 (get-buffer gnus-summary-buffer)
5386 (gnus-buffer-exists-p gnus-summary-buffer)
5387 (eq (cdr (with-current-buffer gnus-summary-buffer
5388 (assq article gnus-newsgroup-reads)))
5389 gnus-canceled-mark))
5391 ;; We first check `gnus-original-article-buffer'.
5392 ((and (get-buffer gnus-original-article-buffer)
5394 (with-current-buffer gnus-original-article-buffer
5395 (and (equal (car gnus-original-article) group)
5396 (eq (cdr gnus-original-article) article))))
5397 (insert-buffer-substring gnus-original-article-buffer)
5399 ;; Check the backlog.
5400 ((and gnus-keep-backlog
5401 (gnus-backlog-request-article group article (current-buffer)))
5403 ;; Check asynchronous pre-fetch.
5404 ((gnus-async-request-fetched-article group article (current-buffer))
5405 (gnus-async-prefetch-next group article gnus-summary-buffer)
5406 (when (and (numberp article) gnus-keep-backlog)
5407 (gnus-backlog-enter-article group article (current-buffer)))
5410 ((and gnus-use-cache
5412 (gnus-cache-request-article article group))
5414 ;; Check the agent cache.
5415 ((gnus-agent-request-article article group)
5417 ;; Get the article and put into the article buffer.
5418 ((or (stringp article)
5420 (let ((gnus-override-method gnus-override-method)
5421 (methods (and (stringp article)
5422 gnus-refer-article-method))
5423 (backend (car (gnus-find-method-for-group
5424 gnus-newsgroup-name)))
5426 (inhibit-read-only t))
5427 (if (or (not (listp methods))
5428 (and (symbolp (car methods))
5429 (assq (car methods) nnoo-definition-alist)))
5430 (setq methods (list methods)))
5431 (when (and (null gnus-override-method)
5433 (setq gnus-override-method (pop methods)))
5435 (when (eq gnus-override-method 'current)
5436 (setq gnus-override-method
5437 (with-current-buffer gnus-summary-buffer
5438 gnus-current-select-method)))
5440 (gnus-kill-all-overlays)
5441 (let ((gnus-newsgroup-name group))
5442 (gnus-check-group-server))
5444 ((gnus-request-article article group (current-buffer))
5445 (when (numberp article)
5446 (gnus-async-prefetch-next group article
5447 gnus-summary-buffer)
5448 (when gnus-keep-backlog
5449 (gnus-backlog-enter-article
5450 group article (current-buffer))))
5451 (setq result 'article))
5453 (setq gnus-override-method (pop methods)))
5454 ((not (string-match "^400 "
5455 (nnheader-get-report backend)))
5456 ;; If we get 400 server disconnect, reconnect and
5457 ;; retry; otherwise, assume the article has expired.
5458 (setq result 'done))))
5459 (and (eq result 'article) 'article)))
5463 ;; Associate this article with the current summary buffer.
5464 (setq gnus-article-current-summary gnus-summary-buffer)
5466 ;; Take the article from the original article buffer
5467 ;; and place it in the buffer it's supposed to be in.
5468 (when (and (get-buffer gnus-article-buffer)
5469 (equal (buffer-name (current-buffer))
5470 (buffer-name (get-buffer gnus-article-buffer))))
5472 (if (get-buffer gnus-original-article-buffer)
5473 (set-buffer gnus-original-article-buffer)
5474 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5475 (buffer-disable-undo)
5476 (setq major-mode 'gnus-original-article-mode)
5477 (setq buffer-read-only t))
5478 (let ((inhibit-read-only t))
5480 (insert-buffer-substring gnus-article-buffer))
5481 (setq gnus-original-article (cons group article)))
5484 (run-hooks 'gnus-article-decode-hook)
5485 ;; Mark article as decoded or not.
5486 (setq gnus-article-decoded-p gnus-article-decode-hook))
5488 ;; Update sparse articles.
5489 (when (and do-update-line
5490 (or (numberp article)
5492 (let ((buf (current-buffer)))
5493 (set-buffer gnus-summary-buffer)
5494 (gnus-summary-update-article do-update-line sparse-header)
5495 (gnus-summary-goto-subject do-update-line nil t)
5496 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5498 (set-buffer buf))))))
5504 (defcustom gnus-article-edit-mode-hook nil
5505 "Hook run in article edit mode buffers."
5506 :group 'gnus-article-various
5509 (defvar gnus-article-edit-done-function nil)
5511 (defvar gnus-article-edit-mode-map nil)
5513 ;; Should we be using derived.el for this?
5514 (unless gnus-article-edit-mode-map
5515 (setq gnus-article-edit-mode-map (make-keymap))
5516 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5518 (gnus-define-keys gnus-article-edit-mode-map
5519 "\C-c?" describe-mode
5520 "\C-c\C-c" gnus-article-edit-done
5521 "\C-c\C-k" gnus-article-edit-exit
5522 "\C-c\C-f\C-t" message-goto-to
5523 "\C-c\C-f\C-o" message-goto-from
5524 "\C-c\C-f\C-b" message-goto-bcc
5525 ;;"\C-c\C-f\C-w" message-goto-fcc
5526 "\C-c\C-f\C-c" message-goto-cc
5527 "\C-c\C-f\C-s" message-goto-subject
5528 "\C-c\C-f\C-r" message-goto-reply-to
5529 "\C-c\C-f\C-n" message-goto-newsgroups
5530 "\C-c\C-f\C-d" message-goto-distribution
5531 "\C-c\C-f\C-f" message-goto-followup-to
5532 "\C-c\C-f\C-m" message-goto-mail-followup-to
5533 "\C-c\C-f\C-k" message-goto-keywords
5534 "\C-c\C-f\C-u" message-goto-summary
5535 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5536 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5537 "\C-c\C-b" message-goto-body
5538 "\C-c\C-i" message-goto-signature
5540 "\C-c\C-t" message-insert-to
5541 "\C-c\C-n" message-insert-newsgroups
5542 "\C-c\C-o" message-sort-headers
5543 "\C-c\C-e" message-elide-region
5544 "\C-c\C-v" message-delete-not-region
5545 "\C-c\C-z" message-kill-to-signature
5546 "\M-\r" message-newline-and-reformat
5547 "\C-c\C-a" mml-attach-file
5548 "\C-a" message-beginning-of-line
5550 "\M-;" comment-region)
5552 (gnus-define-keys (gnus-article-edit-wash-map
5553 "\C-c\C-w" gnus-article-edit-mode-map)
5554 "f" gnus-article-edit-full-stops))
5557 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5559 ["Fetch To" message-insert-to t]
5560 ["Fetch Newsgroups" message-insert-newsgroups t]
5562 ["To" message-goto-to t]
5563 ["From" message-goto-from t]
5564 ["Subject" message-goto-subject t]
5565 ["Cc" message-goto-cc t]
5566 ["Reply-To" message-goto-reply-to t]
5567 ["Summary" message-goto-summary t]
5568 ["Keywords" message-goto-keywords t]
5569 ["Newsgroups" message-goto-newsgroups t]
5570 ["Followup-To" message-goto-followup-to t]
5571 ["Mail-Followup-To" message-goto-mail-followup-to t]
5572 ["Distribution" message-goto-distribution t]
5573 ["Body" message-goto-body t]
5574 ["Signature" message-goto-signature t]))
5576 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5577 "Major mode for editing articles.
5578 This is an extended text-mode.
5580 \\{gnus-article-edit-mode-map}"
5581 (make-local-variable 'gnus-article-edit-done-function)
5582 (make-local-variable 'gnus-prev-winconf)
5583 (set (make-local-variable 'font-lock-defaults)
5584 '(message-font-lock-keywords t))
5585 (set (make-local-variable 'mail-header-separator) "")
5586 (set (make-local-variable 'gnus-article-edit-mode) t)
5587 (easy-menu-add message-mode-field-menu message-mode-map)
5589 (setq buffer-read-only nil)
5590 (buffer-enable-undo)
5593 (defun gnus-article-edit (&optional force)
5594 "Edit the current article.
5595 This will have permanent effect only in mail groups.
5596 If FORCE is non-nil, allow editing of articles even in read-only
5599 (when (and (not force)
5600 (gnus-group-read-only-p))
5601 (error "The current newsgroup does not support article editing"))
5602 (gnus-article-date-original)
5603 (gnus-article-edit-article
5605 `(lambda (no-highlight)
5607 (gnus-summary-edit-article-done
5608 ,(or (mail-header-references gnus-current-headers) "")
5609 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5611 (defun gnus-article-edit-article (start-func exit-func)
5612 "Start editing the contents of the current article buffer."
5613 (let ((winconf (current-window-configuration)))
5614 (set-buffer gnus-article-buffer)
5615 (gnus-article-edit-mode)
5616 (funcall start-func)
5617 (set-buffer-modified-p nil)
5618 (gnus-configure-windows 'edit-article)
5619 (setq gnus-article-edit-done-function exit-func)
5620 (setq gnus-prev-winconf winconf)
5621 (gnus-message 6 "C-c C-c to end edits")))
5623 (defun gnus-article-edit-done (&optional arg)
5624 "Update the article edits and exit."
5626 (let ((func gnus-article-edit-done-function)
5627 (buf (current-buffer))
5628 (start (window-start))
5630 (winconf gnus-prev-winconf))
5631 (widen) ;; Widen it in case that users narrowed the buffer.
5634 ;; The cache and backlog have to be flushed somewhat.
5635 (when gnus-keep-backlog
5636 (gnus-backlog-remove-article
5637 (car gnus-article-current) (cdr gnus-article-current)))
5638 ;; Flush original article as well.
5640 (when (get-buffer gnus-original-article-buffer)
5641 (set-buffer gnus-original-article-buffer)
5642 (setq gnus-original-article nil)))
5643 (when gnus-use-cache
5644 (gnus-cache-update-article
5645 (car gnus-article-current) (cdr gnus-article-current)))
5646 ;; We remove all text props from the article buffer.
5647 (kill-all-local-variables)
5648 (set-text-properties (point-min) (point-max) nil)
5650 (set-window-configuration winconf)
5652 (set-window-start (get-buffer-window buf) start)
5653 (set-window-point (get-buffer-window buf) (point)))
5654 (gnus-summary-show-article))
5656 (defun gnus-article-edit-exit ()
5657 "Exit the article editing without updating."
5659 (when (or (not (buffer-modified-p))
5660 (yes-or-no-p "Article modified; kill anyway? "))
5661 (let ((curbuf (current-buffer))
5663 (window-start (window-start)))
5665 (if (gnus-buffer-live-p gnus-original-article-buffer)
5666 (insert-buffer gnus-original-article-buffer))
5667 (let ((winconf gnus-prev-winconf))
5668 (kill-all-local-variables)
5670 (set-window-configuration winconf)
5671 ;; Tippy-toe some to make sure that point remains where it was.
5672 (save-current-buffer
5674 (set-window-start (get-buffer-window (current-buffer)) window-start)
5676 (gnus-summary-show-article)))
5678 (defun gnus-article-edit-full-stops ()
5679 "Interactively repair spacing at end of sentences."
5682 (goto-char (point-min))
5683 (search-forward-regexp "^$" nil t)
5684 (let ((case-fold-search nil))
5685 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5688 ;;; Article highlights
5691 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5693 ;;; Internal Variables:
5695 (defcustom gnus-button-url-regexp
5696 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5697 "\\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:]]\\)"
5698 "\\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\\)\\)")
5699 "Regular expression that matches URLs."
5700 :group 'gnus-article-buttons
5703 (defcustom gnus-button-valid-fqdn-regexp
5704 message-valid-fqdn-regexp
5705 "Regular expression that matches a valid FQDN."
5707 :group 'gnus-article-buttons
5710 (defcustom gnus-button-man-handler 'manual-entry
5711 "Function to use for displaying man pages.
5712 The function must take at least one argument with a string naming the
5715 :type '(choice (function-item :tag "Man" manual-entry)
5716 (function-item :tag "Woman" woman)
5717 (function :tag "Other"))
5718 :group 'gnus-article-buttons)
5720 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5721 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5722 If the default site is too slow, try to find a CTAN mirror, see
5723 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5724 the variable `gnus-button-handle-ctan'."
5726 :group 'gnus-article-buttons
5727 :link '(custom-manual "(gnus)Group Parameters")
5728 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5729 (const "http://tug.ctan.org/tex-archive/")
5730 (const "http://www.dante.de/CTAN/")
5731 (string :tag "Other")))
5733 (defcustom gnus-button-ctan-handler 'browse-url
5734 "Function to use for displaying CTAN links.
5735 The function must take one argument, the string naming the URL."
5737 :type '(choice (function-item :tag "Browse Url" browse-url)
5738 (function :tag "Other"))
5739 :group 'gnus-article-buttons)
5741 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5742 "Bogus strings removed from CTAN URLs."
5744 :group 'gnus-article-buttons
5745 :type '(choice (const "^/?tex-archive/\\|/")
5746 (regexp :tag "Other")))
5748 (defcustom gnus-button-ctan-directory-regexp
5751 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5752 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5753 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5755 "Regular expression for ctan directories.
5756 It should match all directories in the top level of `gnus-ctan-url'."
5758 :group 'gnus-article-buttons
5761 (defcustom gnus-button-mid-or-mail-regexp
5762 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5763 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5764 gnus-button-valid-fqdn-regexp
5766 "Regular expression that matches a message ID or a mail address."
5768 :group 'gnus-article-buttons
5771 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5772 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5773 Strings like this can be either a message ID or a mail address. If it is one
5774 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5775 message ID or a mail address, respectively. If this variable is set to the
5776 symbol `ask', always query the user what do do. If it is a function, this
5777 function will be called with the string as it's only argument. The function
5778 must return `mid', `mail', `invalid' or `ask'."
5780 :group 'gnus-article-buttons
5781 :type '(choice (function-item :tag "Heuristic function"
5782 gnus-button-mid-or-mail-heuristic)
5787 (defcustom gnus-button-mid-or-mail-heuristic-alist
5788 '((-10.0 . ".+\\$.+@")
5791 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5792 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5793 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5794 (-1.0 . "^[^a-z]+@")
5796 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5797 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5798 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5799 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5802 (-1.0 . "^[0-9][0-9]")
5804 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5805 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5806 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5807 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5809 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5810 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5813 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5815 ;; compensation for TDMA dated mail addresses:
5816 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5818 (-20.0 . "\\.fsf@") ;; Gnus
5821 (-20.0 . "_-_") ;; Subject change in thread
5823 (-20.0 . "\\.ln@") ;; leafnode
5824 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5825 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5827 ;; (5.0 . "") ;; $local_part_len <= 7
5828 (10.0 . "^[^0-9]+@")
5829 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5830 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5833 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5835 (0.5 . "^[A-Z][a-z]")
5836 (0.5 . "^[A-Z][a-z][a-z]")
5837 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5838 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5839 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5841 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5842 address. The REGEXP is processed with `case-fold-search' set to nil."
5844 :group 'gnus-article-buttons
5845 :type '(repeat (cons (number :tag "Rate")
5846 (regexp :tag "Regexp"))))
5848 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5849 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5850 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5851 address, `ask' if unsure and `invalid' if the string is invalid."
5852 (let ((case-fold-search nil)
5853 (list gnus-button-mid-or-mail-heuristic-alist)
5854 (result 0) rate regexp lpartlen elem)
5856 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5857 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5858 ;; Certain special cases...
5861 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5862 "^[0-9]+\\.[0-9]+@compuserve\\|"
5863 "@public\\.gmane\\.org")
5865 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5866 (setq result 'mail))
5867 (when (string-match "@.*@\\| " mid-or-mail)
5868 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5869 (setq result 'invalid))
5870 ;; Nothing more to do, if result is not a number here...
5871 (when (numberp result)
5873 (setq elem (car list)
5877 (when (string-match regexp mid-or-mail)
5878 (setq result (+ result rate))
5880 9 "`%s' matched `%s', rate `%s', result `%s'."
5881 mid-or-mail regexp rate result)))
5882 (when (<= lpartlen 7)
5883 (setq result (+ result 5.0))
5884 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5885 mid-or-mail result))
5886 (when (>= lpartlen 12)
5887 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5889 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5890 ;; Long local part should contain realname if e-mail address,
5891 ;; too many digits: message-id.
5892 ;; $score -= 5.0 + 0.1 * $local_part_len;
5893 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5894 (setq result (+ result rate))
5896 9 "Many digits in `%s', rate `%s', result `%s'."
5897 mid-or-mail rate result))
5898 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5900 ;; Too few vowels [^aeiouy]{4,}.*\@
5901 (setq result (+ result -5.0))
5903 9 "Few vowels in `%s', rate `%s', result `%s'."
5904 mid-or-mail -5.0 result))
5906 (setq result (+ result 5.0))
5908 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5909 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5910 ;; Maybe we should make this a customizable alist: (condition . 'result)
5912 ((symbolp result) result)
5913 ;; Now convert number into proper results:
5914 ((< result -10.0) 'mid)
5915 ((> result 10.0) 'mail)
5918 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5919 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5920 (url-mid (concat "news" ":" mid-or-mail))
5921 (url-mailto (concat "mailto" ":" mid-or-mail)))
5922 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5923 (when (fboundp pref)
5925 ;; get rid of surrounding angles...
5927 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5928 (if (or (eq 'mid guessed) (eq 'mail guessed))
5932 (save-window-excursion
5933 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5936 (cond ((eq pref 'mid)
5937 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5938 (gnus-button-handle-news url-mid))
5940 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5941 (gnus-url-mailto url-mailto))
5942 (t (gnus-message 3 "Invalid string.")))))
5944 (defun gnus-button-handle-custom (url)
5945 "Follow a Custom URL."
5946 (customize-apropos (gnus-url-unhex-string url)))
5948 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5950 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5953 (defun gnus-button-handle-describe-function (url)
5954 "Call `describe-function' when pushing the corresponding URL button."
5957 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5959 (defun gnus-button-handle-describe-variable (url)
5960 "Call `describe-variable' when pushing the corresponding URL button."
5963 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5965 (defun gnus-button-handle-symbol (url)
5966 "Display help on variable or function.
5967 Calls `describe-variable' or `describe-function'."
5968 (let ((sym (intern url)))
5970 ((fboundp sym) (describe-function sym))
5971 ((boundp sym) (describe-variable sym))
5972 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5974 (defun gnus-button-handle-describe-key (url)
5975 "Call `describe-key' when pushing the corresponding URL button."
5977 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5978 (keys (ignore-errors (eval `(kbd ,key-string)))))
5981 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5983 (defun gnus-button-handle-apropos (url)
5984 "Call `apropos' when pushing the corresponding URL button."
5985 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5987 (defun gnus-button-handle-apropos-command (url)
5988 "Call `apropos' when pushing the corresponding URL button."
5990 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5992 (defun gnus-button-handle-apropos-variable (url)
5993 "Call `apropos' when pushing the corresponding URL button."
5995 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5996 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5998 (defun gnus-button-handle-apropos-documentation (url)
5999 "Call `apropos' when pushing the corresponding URL button."
6001 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6002 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6004 (defun gnus-button-handle-library (url)
6005 "Call `locate-library' when pushing the corresponding URL button."
6006 (gnus-message 9 "url=`%s'" url)
6007 (let* ((lib (locate-library url))
6008 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6010 (gnus-message 1 "Cannot locale library `%s'." url)
6011 (find-file-read-only file))))
6013 (defun gnus-button-handle-ctan (url)
6014 "Call `browse-url' when pushing a CTAN URL button."
6016 gnus-button-ctan-handler
6019 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6021 (defcustom gnus-button-tex-level 5
6022 "*Integer that says how many TeX-related buttons Gnus will show.
6023 The higher the number, the more buttons will appear and the more false
6024 positives are possible. Note that you can set this variable local to
6025 specific groups. Setting it higher in TeX groups is probably a good idea.
6026 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6027 how to set variables in specific groups."
6029 :group 'gnus-article-buttons
6030 :link '(custom-manual "(gnus)Group Parameters")
6033 (defcustom gnus-button-man-level 5
6034 "*Integer that says how many man-related buttons Gnus will show.
6035 The higher the number, the more buttons will appear and the more false
6036 positives are possible. Note that you can set this variable local to
6037 specific groups. Setting it higher in Unix groups is probably a good idea.
6038 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6039 how to set variables in specific groups."
6041 :group 'gnus-article-buttons
6042 :link '(custom-manual "(gnus)Group Parameters")
6045 (defcustom gnus-button-emacs-level 5
6046 "*Integer that says how many emacs-related buttons Gnus will show.
6047 The higher the number, the more buttons will appear and the more false
6048 positives are possible. Note that you can set this variable local to
6049 specific groups. Setting it higher in Emacs or Gnus related groups is
6050 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6051 `gnus-parameters' on how to set variables in specific groups."
6053 :group 'gnus-article-buttons
6054 :link '(custom-manual "(gnus)Group Parameters")
6057 (defcustom gnus-button-message-level 5
6058 "*Integer that says how many buttons for news or mail messages will appear.
6059 The higher the number, the more buttons will appear and the more false
6060 positives are possible."
6061 ;; mail addresses, MIDs, URLs for news, ...
6063 :group 'gnus-article-buttons
6066 (defcustom gnus-button-browse-level 5
6067 "*Integer that says how many buttons for browsing will appear.
6068 The higher the number, the more buttons will appear and the more false
6069 positives are possible."
6070 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6072 :group 'gnus-article-buttons
6075 (defcustom gnus-button-alist
6076 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6077 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6078 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6079 gnus-button-handle-news 2)
6080 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6081 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6082 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6083 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6084 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6085 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6086 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6087 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6088 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6089 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6090 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6091 ;; RFC 2368 (The mailto URL scheme)
6092 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6093 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6094 ("\\bmailto:\\([^ \n\t]+\\)"
6095 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6097 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6098 gnus-button-ctan-directory-regexp
6099 "[^][>)!;:,'\n\t ]+\\)")
6100 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6101 ((concat "\\btex-archive/\\("
6102 gnus-button-ctan-directory-regexp
6103 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6104 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6107 gnus-button-ctan-directory-regexp
6108 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6109 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6110 ;; This is info (home-grown style) <info://foo/bar+baz>
6111 ("\\binfo://\\([^'\">\n\t ]+\\)"
6112 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6113 ;; Info GNOME style <info:foo#bar_baz>
6114 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6115 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6116 ;; Info KDE style <info:(foo)bar baz>
6117 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6118 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6119 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6120 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6121 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6122 ;; Info links like `C-h i d m CC Mode RET'
6123 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6125 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6126 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6127 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6128 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6129 ;; Emacs help commands
6130 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6131 ;; regexp doesn't match arguments containing ` '.
6132 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6133 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6134 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6135 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6136 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6137 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6138 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6139 ;; The following entries may lead to many false positives so don't enable
6140 ;; them by default (use a high button level).
6141 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6142 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6143 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6144 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6145 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6146 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6147 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6148 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6149 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6150 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6151 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6152 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6153 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6154 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6155 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6156 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6157 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6158 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6159 ;; Unlike the other regexps we really have to require quoting
6160 ;; here to determine where it ends.
6161 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6162 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6163 ("<URL: *\\([^<>]*\\)>"
6164 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6165 ;; RFC 2396 (2.4.3., delims) ...
6166 ("\"URL: *\\([^\"]*\\)\""
6167 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6168 ;; RFC 2396 (2.4.3., delims) ...
6169 ("\"URL: *\\([^\"]*\\)\""
6170 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6172 (gnus-button-url-regexp
6173 0 (>= gnus-button-browse-level 0) browse-url 0)
6175 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6176 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6177 gnus-button-handle-man 1)
6178 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6179 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6180 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6181 gnus-button-handle-man 1)
6182 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6183 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6184 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6185 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6186 ;; MID or mail: To avoid too many false positives we don't try to catch
6187 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6188 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6189 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6190 ;; so that non-ambiguous entries (see above) match first.
6191 (gnus-button-mid-or-mail-regexp
6192 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6193 "*Alist of regexps matching buttons in article bodies.
6195 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6196 REGEXP: is the string (case insensitive) matching text around the button (can
6197 also be Lisp expression evaluating to a string),
6198 BUTTON: is the number of the regexp grouping actually matching the button,
6199 FORM: is a Lisp expression which must eval to true for the button to
6201 CALLBACK: is the function to call when the user push this button, and each
6202 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6204 CALLBACK can also be a variable, in that case the value of that
6205 variable it the real callback function."
6206 :group 'gnus-article-buttons
6207 :type '(repeat (list (choice regexp variable sexp)
6208 (integer :tag "Button")
6210 (function :tag "Callback")
6213 (integer :tag "Regexp group")))))
6215 (defcustom gnus-header-button-alist
6216 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6217 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6218 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6219 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6220 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6221 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6222 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6223 0 (>= gnus-button-browse-level 0) browse-url 0)
6224 ("^Subject:" gnus-button-url-regexp
6225 0 (>= gnus-button-browse-level 0) browse-url 0)
6226 ("^[^:]+:" gnus-button-url-regexp
6227 0 (>= gnus-button-browse-level 0) browse-url 0)
6228 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6229 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6230 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6231 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6232 "*Alist of headers and regexps to match buttons in article heads.
6234 This alist is very similar to `gnus-button-alist', except that each
6235 alist has an additional HEADER element first in each entry:
6237 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6239 HEADER is a regexp to match a header. For a fuller explanation, see
6240 `gnus-button-alist'."
6241 :group 'gnus-article-buttons
6242 :group 'gnus-article-headers
6243 :type '(repeat (list (regexp :tag "Header")
6244 (choice regexp variable)
6245 (integer :tag "Button")
6247 (function :tag "Callback")
6250 (integer :tag "Regexp group")))))
6254 (defun gnus-article-push-button (event)
6255 "Check text under the mouse pointer for a callback function.
6256 If the text under the mouse pointer has a `gnus-callback' property,
6257 call it with the value of the `gnus-data' text property."
6259 (set-buffer (window-buffer (posn-window (event-start event))))
6260 (let* ((pos (posn-point (event-start event)))
6261 (data (get-text-property pos 'gnus-data))
6262 (fun (get-text-property pos 'gnus-callback)))
6265 (funcall fun data))))
6267 (defun gnus-article-press-button ()
6268 "Check text at point for a callback function.
6269 If the text at point has a `gnus-callback' property,
6270 call it with the value of the `gnus-data' text property."
6272 (let ((data (get-text-property (point) 'gnus-data))
6273 (fun (get-text-property (point) 'gnus-callback)))
6275 (funcall fun data))))
6277 (defun gnus-article-highlight (&optional force)
6278 "Highlight current article.
6279 This function calls `gnus-article-highlight-headers',
6280 `gnus-article-highlight-citation',
6281 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6282 do the highlighting. See the documentation for those functions."
6283 (interactive (list 'force))
6284 (gnus-article-highlight-headers)
6285 (gnus-article-highlight-citation force)
6286 (gnus-article-highlight-signature)
6287 (gnus-article-add-buttons force)
6288 (gnus-article-add-buttons-to-head))
6290 (defun gnus-article-highlight-some (&optional force)
6291 "Highlight current article.
6292 This function calls `gnus-article-highlight-headers',
6293 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6294 do the highlighting. See the documentation for those functions."
6295 (interactive (list 'force))
6296 (gnus-article-highlight-headers)
6297 (gnus-article-highlight-signature)
6298 (gnus-article-add-buttons))
6300 (defun gnus-article-highlight-headers ()
6301 "Highlight article headers as specified by `gnus-header-face-alist'."
6303 (gnus-with-article-headers
6304 (let (regexp header-face field-face from hpoints fpoints)
6305 (dolist (entry gnus-header-face-alist)
6306 (goto-char (point-min))
6307 (setq regexp (concat "^\\("
6308 (if (string-equal "" (nth 0 entry))
6312 header-face (nth 1 entry)
6313 field-face (nth 2 entry))
6314 (while (and (re-search-forward regexp nil t)
6318 (unless (search-forward ":" nil t)
6320 (when (and header-face
6321 (not (memq (point) hpoints)))
6322 (push (point) hpoints)
6323 (gnus-put-text-property from (point) 'face header-face))
6324 (when (and field-face
6325 (not (memq (setq from (point)) fpoints)))
6327 (if (re-search-forward "^[^ \t]" nil t)
6329 (goto-char (point-max)))
6330 (gnus-put-text-property from (point) 'face field-face)))))))
6332 (defun gnus-article-highlight-signature ()
6333 "Highlight the signature in an article.
6334 It does this by highlighting everything after
6335 `gnus-signature-separator' using `gnus-signature-face'."
6337 (gnus-with-article-buffer
6338 (let ((inhibit-point-motion-hooks t))
6340 (when (and gnus-signature-face
6341 (gnus-article-narrow-to-signature))
6342 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6343 'face gnus-signature-face)
6345 (gnus-article-search-signature)
6346 (let ((start (match-beginning 0))
6347 (end (set-marker (make-marker) (1+ (match-end 0)))))
6348 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6351 (defun gnus-button-in-region-p (b e prop)
6352 "Say whether PROP exists in the region."
6353 (text-property-not-all b e prop nil))
6355 (defun gnus-article-add-buttons (&optional force)
6356 "Find external references in the article and make buttons of them.
6357 \"External references\" are things like Message-IDs and URLs, as
6358 specified by `gnus-button-alist'."
6359 (interactive (list 'force))
6360 (gnus-with-article-buffer
6361 (let ((inhibit-point-motion-hooks t)
6362 (case-fold-search t)
6363 (alist gnus-button-alist)
6365 ;; Remove all old markers.
6366 (let (marker entry new-list)
6367 (while (setq marker (pop gnus-button-marker-list))
6368 (if (or (< marker (point-min)) (>= marker (point-max)))
6369 (push marker new-list)
6371 (when (setq entry (gnus-button-entry))
6372 (put-text-property (match-beginning (nth 1 entry))
6373 (match-end (nth 1 entry))
6374 'gnus-callback nil))
6375 (set-marker marker nil)))
6376 (setq gnus-button-marker-list new-list))
6377 ;; We skip the headers.
6380 (while (setq entry (pop alist))
6381 (setq regexp (eval (car entry)))
6383 (while (re-search-forward regexp nil t)
6384 (let* ((start (and entry (match-beginning (nth 1 entry))))
6385 (end (and entry (match-end (nth 1 entry))))
6386 (from (match-beginning 0)))
6387 (when (and (or (eq t (nth 2 entry))
6388 (eval (nth 2 entry)))
6389 (not (gnus-button-in-region-p
6390 start end 'gnus-callback)))
6391 ;; That optional form returned non-nil, so we add the
6393 (gnus-article-add-button
6394 start end 'gnus-button-push
6395 (car (push (set-marker (make-marker) from)
6396 gnus-button-marker-list))))))))))
6398 ;; Add buttons to the head of an article.
6399 (defun gnus-article-add-buttons-to-head ()
6400 "Add buttons to the head of the article."
6402 (gnus-with-article-headers
6404 (dolist (entry gnus-header-button-alist)
6405 ;; Each alist entry.
6406 (goto-char (point-min))
6407 (while (re-search-forward (car entry) nil t)
6408 ;; Each header matching the entry.
6409 (setq beg (match-beginning 0))
6410 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6411 (match-beginning 0))
6414 (while (re-search-forward (eval (nth 1 entry)) end t)
6415 ;; Each match within a header.
6416 (let* ((entry (cdr entry))
6417 (start (match-beginning (nth 1 entry)))
6418 (end (match-end (nth 1 entry)))
6419 (form (nth 2 entry)))
6420 (goto-char (match-end 0))
6422 (gnus-article-add-button
6423 start end (nth 3 entry)
6424 (buffer-substring (match-beginning (nth 4 entry))
6425 (match-end (nth 4 entry)))))))
6426 (goto-char end))))))
6428 ;;; External functions:
6430 (defun gnus-article-add-button (from to fun &optional data)
6431 "Create a button between FROM and TO with callback FUN and data DATA."
6432 (when gnus-article-button-face
6433 (gnus-overlay-put (gnus-make-overlay from to)
6434 'face gnus-article-button-face))
6435 (gnus-add-text-properties
6437 (nconc (and gnus-article-mouse-face
6438 (list gnus-mouse-face-prop gnus-article-mouse-face))
6439 (list 'gnus-callback fun)
6440 (and data (list 'gnus-data data))))
6441 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6442 :button-keymap gnus-widget-button-keymap))
6444 ;;; Internal functions:
6446 (defun gnus-article-set-globals ()
6447 (with-current-buffer gnus-summary-buffer
6448 (gnus-set-global-variables)))
6450 (defun gnus-signature-toggle (end)
6451 (gnus-with-article-buffer
6452 (let ((inhibit-point-motion-hooks t))
6453 (if (text-property-any end (point-max) 'article-type 'signature)
6455 (gnus-delete-wash-type 'signature)
6456 (gnus-remove-text-properties-when
6457 'article-type 'signature end (point-max)
6458 (cons 'article-type (cons 'signature
6459 gnus-hidden-properties))))
6460 (gnus-add-wash-type 'signature)
6461 (gnus-add-text-properties-when
6462 'article-type nil end (point-max)
6463 (cons 'article-type (cons 'signature
6464 gnus-hidden-properties)))))
6465 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6466 (gnus-set-mode-line 'article))))
6468 (defun gnus-button-entry ()
6469 ;; Return the first entry in `gnus-button-alist' matching this place.
6470 (let ((alist gnus-button-alist)
6473 (setq entry (pop alist))
6474 (if (looking-at (eval (car entry)))
6479 (defun gnus-button-push (marker)
6480 ;; Push button starting at MARKER.
6483 (let* ((entry (gnus-button-entry))
6484 (inhibit-point-motion-hooks t)
6486 (args (mapcar (lambda (group)
6487 (let ((string (match-string group)))
6488 (set-text-properties
6489 0 (length string) nil string)
6496 (fboundp (symbol-value fun)))
6497 (apply (symbol-value fun) args))
6499 (gnus-message 1 "You must define `%S' to use this button"
6500 (cons fun args)))))))
6502 (defun gnus-parse-news-url (url)
6503 (let (scheme server group message-id articles)
6506 (goto-char (point-min))
6507 (when (looking-at "\\([A-Za-z]+\\):")
6508 (setq scheme (match-string 1))
6509 (goto-char (match-end 0)))
6510 (when (looking-at "//\\([^/]+\\)/")
6511 (setq server (match-string 1))
6512 (goto-char (match-end 0)))
6515 ((looking-at "\\(.*@.*\\)")
6516 (setq message-id (match-string 1)))
6517 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6518 (setq group (match-string 1)
6519 articles (split-string (match-string 2) "-")))
6520 ((looking-at "\\([^/]+\\)/?")
6521 (setq group (match-string 1)))
6523 (error "Unknown news URL syntax"))))
6524 (list scheme server group message-id articles)))
6526 (defun gnus-button-handle-news (url)
6528 (destructuring-bind (scheme server group message-id articles)
6529 (gnus-parse-news-url url)
6533 (set-buffer gnus-summary-buffer)
6535 (let ((gnus-refer-article-method (list (list 'nntp server))))
6536 (gnus-summary-refer-article message-id))
6537 (gnus-summary-refer-article message-id))))
6539 (gnus-button-fetch-group url)))))
6541 (defun gnus-button-handle-man (url)
6543 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6544 (when (eq gnus-button-man-handler 'woman)
6545 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6546 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6547 (funcall gnus-button-man-handler url))
6549 (defun gnus-button-handle-info-url (url)
6550 "Fetch an info URL."
6551 (setq url (mm-subst-char-in-string ?+ ?\ url))
6553 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6554 (gnus-info-find-node
6555 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6557 ")" (gnus-url-unhex-string (match-string 2 url)))))
6558 ((string-match "([^)\"]+)[^\"]+" url)
6560 (gnus-replace-in-string
6561 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6562 (gnus-info-find-node url))
6563 (t (error "Can't parse %s" url))))
6565 (defun gnus-button-handle-info-url-gnome (url)
6566 "Fetch GNOME style info URL."
6567 (setq url (mm-subst-char-in-string ?_ ?\ url))
6568 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6569 (gnus-info-find-node
6571 (gnus-url-unhex-string
6572 (match-string 1 url))
6574 (or (gnus-url-unhex-string
6575 (match-string 2 url))
6577 (error "Can't parse %s" url)))
6579 (defun gnus-button-handle-info-url-kde (url)
6580 "Fetch KDE style info URL."
6581 (gnus-info-find-node (gnus-url-unhex-string url)))
6583 (defun gnus-button-handle-info-keystrokes (url)
6584 "Call `info' when pushing the corresponding URL button."
6585 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6590 (defun gnus-button-message-id (message-id)
6592 (with-current-buffer gnus-summary-buffer
6593 (gnus-summary-refer-article message-id)))
6595 (defun gnus-button-fetch-group (address)
6596 "Fetch GROUP specified by ADDRESS."
6597 (if (not (string-match "[:/]" address))
6598 ;; This is just a simple group url.
6599 (gnus-group-read-ephemeral-group address gnus-select-method)
6602 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6604 (error "Can't parse %s" address)
6605 (gnus-group-read-ephemeral-group
6606 (match-string 4 address)
6607 `(nntp ,(match-string 1 address)
6608 (nntp-address ,(match-string 1 address))
6609 (nntp-port-number ,(if (match-end 3)
6610 (match-string 3 address)
6613 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6615 (defun gnus-url-parse-query-string (query &optional downcase)
6616 (let (retval pairs cur key val)
6617 (setq pairs (split-string query "&"))
6619 (setq cur (car pairs)
6621 (if (not (string-match "=" cur))
6623 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6624 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6626 (setq key (downcase key)))
6627 (setq cur (assoc key retval))
6629 (setcdr cur (cons val (cdr cur)))
6630 (setq retval (cons (list key val) retval)))))
6633 (defun gnus-url-mailto (url)
6634 ;; Send mail to someone
6635 (when (string-match "mailto:/*\\(.*\\)" url)
6636 (setq url (substring url (match-beginning 1) nil)))
6637 (let (to args subject func)
6638 (setq args (gnus-url-parse-query-string
6639 (if (string-match "^\\?" url)
6641 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6642 (concat "to=" (match-string 1 url) "&"
6643 (match-string 2 url))
6644 (concat "to=" url)))
6646 subject (cdr-safe (assoc "subject" args)))
6649 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6652 (message-position-on-field (caar args)))
6653 (insert (gnus-replace-in-string
6654 (mapconcat 'identity (reverse (cdar args)) ", ")
6656 (setq args (cdr args)))
6659 (message-goto-subject))))
6661 (defun gnus-button-embedded-url (address)
6662 "Activate ADDRESS with `browse-url'."
6663 (browse-url (gnus-strip-whitespace address)))
6665 ;;; Next/prev buttons in the article buffer.
6667 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6668 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6670 (defvar gnus-prev-page-map
6671 (let ((map (make-sparse-keymap)))
6672 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6673 (define-key map "\r" 'gnus-button-prev-page)
6676 (defvar gnus-next-page-map
6677 (let ((map (make-sparse-keymap)))
6678 (unless (>= emacs-major-version 21)
6679 ;; XEmacs doesn't care.
6680 (set-keymap-parent map gnus-article-mode-map))
6681 (define-key map gnus-mouse-2 'gnus-button-next-page)
6682 (define-key map "\r" 'gnus-button-next-page)
6685 (defun gnus-insert-prev-page-button ()
6687 (inhibit-read-only t))
6689 gnus-prev-page-line-format nil
6690 `(keymap ,gnus-prev-page-map
6692 gnus-callback gnus-article-button-prev-page
6693 article-type annotation))
6694 (widget-convert-button
6696 ;; Exclude a newline.
6699 :action 'gnus-button-prev-page
6700 :button-keymap gnus-prev-page-map)))
6702 (defun gnus-button-next-page (&optional args more-args)
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-button-prev-page (&optional args more-args)
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 (defun gnus-insert-next-page-button ()
6720 (inhibit-read-only t))
6721 (gnus-eval-format gnus-next-page-line-format nil
6722 `(keymap ,gnus-next-page-map
6724 gnus-callback gnus-article-button-next-page
6725 article-type annotation))
6726 (widget-convert-button
6728 ;; Exclude a newline.
6731 :action 'gnus-button-next-page
6732 :button-keymap gnus-next-page-map)))
6734 (defun gnus-article-button-next-page (arg)
6735 "Go to the next page."
6737 (let ((win (selected-window)))
6738 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6739 (gnus-article-next-page)
6740 (select-window win)))
6742 (defun gnus-article-button-prev-page (arg)
6743 "Go to the prev page."
6745 (let ((win (selected-window)))
6746 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6747 (gnus-article-prev-page)
6748 (select-window win)))
6750 (defvar gnus-decode-header-methods
6751 '(mail-decode-encoded-word-region)
6752 "List of methods used to decode headers.
6754 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6755 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6756 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6757 whose names match REGEXP.
6760 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6761 mail-decode-encoded-word-region
6762 (\"chinese\" . rfc1843-decode-region))
6765 (defvar gnus-decode-header-methods-cache nil)
6767 (defun gnus-multi-decode-header (start end)
6768 "Apply the functions from `gnus-encoded-word-methods' that match."
6769 (unless (and gnus-decode-header-methods-cache
6770 (eq gnus-newsgroup-name
6771 (car gnus-decode-header-methods-cache)))
6772 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6775 (nconc gnus-decode-header-methods-cache (list x))
6776 (if (and gnus-newsgroup-name
6777 (string-match (car x) gnus-newsgroup-name))
6778 (nconc gnus-decode-header-methods-cache
6780 gnus-decode-header-methods))
6781 (let ((xlist gnus-decode-header-methods-cache))
6784 (narrow-to-region start end)
6786 (funcall (pop xlist) (point-min) (point-max))))))
6789 ;;; Treatment top-level handling.
6792 (defun gnus-treat-article (condition &optional part-number total-parts type)
6793 (let ((length (- (point-max) (point-min)))
6794 (alist gnus-treatment-function-alist)
6795 (article-goto-body-goes-to-point-min-p t)
6799 (let ((list gnus-article-treat-types))
6801 (when (string-match (pop list) type)
6802 (throw 'found t)))))))
6803 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6805 (gnus-run-hooks 'gnus-part-display-hook)
6806 (dolist (elem alist)
6809 (when (gnus-buffer-live-p gnus-summary-buffer)
6810 (set-buffer gnus-summary-buffer))
6811 (symbol-value (car elem))))
6812 (when (and (or (consp val)
6814 (gnus-treat-predicate val)
6815 (or (not (get (car elem) 'highlight))
6818 (funcall (cadr elem)))))))
6820 ;; Dynamic variables.
6822 (defvar part-number)
6823 (defvar total-parts)
6828 (defun gnus-treat-predicate (val)
6835 (stringp (car val)))
6836 (apply 'gnus-or (mapcar `(lambda (s)
6837 (string-match s ,(or gnus-newsgroup-name "")))
6840 (let ((pred (pop val)))
6843 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6845 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6847 (not (gnus-treat-predicate (car val))))
6849 (equal (car val) type))
6851 (error "%S is not a valid predicate" pred)))))
6857 (eq part-number total-parts))
6861 (error "%S is not a valid value" val))))
6863 (defun gnus-article-encrypt-body (protocol &optional n)
6864 "Encrypt the article body."
6867 (or gnus-article-encrypt-protocol
6868 (completing-read "Encrypt protocol: "
6869 gnus-article-encrypt-protocol-alist
6871 current-prefix-arg))
6872 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6874 (error (format "Can't find the encrypt protocol %s" protocol)))
6875 (if (member gnus-newsgroup-name '("nndraft:delayed"
6878 (error "Can't encrypt the article in group %s"
6879 gnus-newsgroup-name))
6880 (gnus-summary-iterate n
6882 (set-buffer gnus-summary-buffer)
6883 (let ((mail-parse-charset gnus-newsgroup-charset)
6884 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6885 (summary-buffer gnus-summary-buffer)
6887 (gnus-set-global-variables)
6888 (when (gnus-group-read-only-p)
6889 (error "The current newsgroup does not support article encrypt"))
6890 (gnus-summary-show-article t)
6892 (or (mail-header-references gnus-current-headers) ""))
6893 (set-buffer gnus-article-buffer)
6894 (let* ((inhibit-read-only t)
6896 (mapcar (lambda (field)
6897 (and (save-restriction
6898 (message-narrow-to-head)
6899 (goto-char (point-min))
6900 (search-forward field nil t))
6902 (message-narrow-to-field)
6904 (delete-region (point-min) (point-max))
6906 '("Content-Type:" "Content-Transfer-Encoding:"
6907 "Content-Disposition:"))))
6908 (message-narrow-to-head)
6909 (message-remove-header "MIME-Version")
6910 (goto-char (point-max))
6911 (setq point (point))
6912 (insert (apply 'concat headers))
6914 (narrow-to-region point (point-max))
6915 (let ((message-options message-options))
6916 (message-options-set 'message-sender user-mail-address)
6917 (message-options-set 'message-recipients user-mail-address)
6918 (message-options-set 'message-sign-encrypt 'not)
6920 (goto-char (point-min))
6921 (insert "MIME-Version: 1.0\n")
6923 (gnus-summary-edit-article-done
6924 references nil summary-buffer t))
6925 (when gnus-keep-backlog
6926 (gnus-backlog-remove-article
6927 (car gnus-article-current) (cdr gnus-article-current)))
6929 (when (get-buffer gnus-original-article-buffer)
6930 (set-buffer gnus-original-article-buffer)
6931 (setq gnus-original-article nil)))
6932 (when gnus-use-cache
6933 (gnus-cache-update-article
6934 (car gnus-article-current) (cdr gnus-article-current))))))))
6936 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6937 "The following specs can be used:
6938 %t The security MIME type
6941 %D Details if button is pressed")
6943 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6944 "The following specs can be used:
6945 %t The security MIME type
6948 %D Details if button is pressed")
6950 (defvar gnus-mime-security-button-line-format-alist
6951 '((?t gnus-tmp-type ?s)
6952 (?i gnus-tmp-info ?s)
6953 (?d gnus-tmp-details ?s)
6954 (?D gnus-tmp-pressed-details ?s)))
6956 (defvar gnus-mime-security-button-map
6957 (let ((map (make-sparse-keymap)))
6958 (define-key map gnus-mouse-2 'gnus-article-push-button)
6959 (define-key map "\r" 'gnus-article-press-button)
6962 (defvar gnus-mime-security-details-buffer nil)
6964 (defvar gnus-mime-security-button-pressed nil)
6966 (defvar gnus-mime-security-show-details-inline t
6967 "If non-nil, show details in the article buffer.")
6969 (defun gnus-mime-security-verify-or-decrypt (handle)
6970 (mm-remove-parts (cdr handle))
6971 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6972 point (inhibit-read-only t))
6974 (goto-char (car region)))
6976 (narrow-to-region (point) (point))
6977 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6978 (let* ((mm-verify-option 'known)
6979 (mm-decrypt-option 'known)
6980 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6981 (unless (eq nparts (cdr handle))
6982 (mm-destroy-parts (cdr handle))
6983 (setcdr handle nparts))))
6984 (setq point (point))
6985 (gnus-mime-display-security handle)
6986 (goto-char (point-max)))
6988 (delete-region (point) (cdr region))
6989 (set-marker (car region) nil)
6990 (set-marker (cdr region) nil))
6993 (defun gnus-mime-security-show-details (handle)
6994 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6996 (gnus-message 5 "No details.")
6997 (if gnus-mime-security-show-details-inline
6998 (let ((gnus-mime-security-button-pressed
6999 (not (get-text-property (point) 'gnus-mime-details)))
7000 (gnus-mime-security-button-line-format
7001 (get-text-property (point) 'gnus-line-format))
7002 (inhibit-read-only t))
7004 (while (eq (get-text-property (point) 'gnus-line-format)
7005 gnus-mime-security-button-line-format)
7009 (narrow-to-region (point) (point))
7010 (gnus-insert-mime-security-button handle))
7011 (delete-region (point)
7012 (or (text-property-not-all
7015 gnus-mime-security-button-line-format)
7018 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7019 (with-current-buffer gnus-mime-security-details-buffer
7022 (setq gnus-mime-security-details-buffer
7023 (gnus-get-buffer-create "*MIME Security Details*")))
7024 (with-current-buffer gnus-mime-security-details-buffer
7026 (goto-char (point-min)))
7027 (pop-to-buffer gnus-mime-security-details-buffer)))))
7029 (defun gnus-mime-security-press-button (handle)
7031 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7032 (gnus-mime-security-show-details handle)
7033 (gnus-mime-security-verify-or-decrypt handle))))
7035 (defun gnus-insert-mime-security-button (handle &optional displayed)
7036 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7039 (or (nth 2 (assoc protocol mm-verify-function-alist))
7040 (nth 2 (assoc protocol mm-decrypt-function-alist))
7042 (if (equal (car handle) "multipart/signed")
7043 " Signed" " Encrypted")
7046 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7049 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7050 gnus-tmp-pressed-details
7052 (setq gnus-tmp-details
7053 (if gnus-tmp-details
7054 (concat "\n" gnus-tmp-details)
7056 (setq gnus-tmp-pressed-details
7057 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7062 gnus-mime-security-button-line-format
7063 gnus-mime-security-button-line-format-alist
7064 `(keymap ,gnus-mime-security-button-map
7065 gnus-callback gnus-mime-security-press-button
7066 gnus-line-format ,gnus-mime-security-button-line-format
7067 gnus-mime-details ,gnus-mime-security-button-pressed
7068 article-type annotation
7071 ;; Exclude a newline.
7074 (widget-convert-button
7077 :action 'gnus-widget-press-button
7078 :button-keymap gnus-mime-security-button-map
7080 (lambda (widget/window &optional overlay pos)
7081 ;; Needed to properly clear the message due to a bug in
7082 ;; wid-edit (XEmacs only).
7083 (when (boundp 'help-echo-owns-message)
7084 (setq help-echo-owns-message t))
7087 (aref gnus-mouse-2 0))))))
7089 (defun gnus-mime-display-security (handle)
7091 (narrow-to-region (point) (point))
7092 (unless (gnus-unbuttonized-mime-type-p (car handle))
7093 (gnus-insert-mime-security-button handle))
7094 (gnus-mime-display-mixed (cdr handle))
7097 (unless (gnus-unbuttonized-mime-type-p (car handle))
7098 (let ((gnus-mime-security-button-line-format
7099 gnus-mime-security-button-end-line-format))
7100 (gnus-insert-mime-security-button handle)))
7101 (mm-set-handle-multipart-parameter
7103 (cons (set-marker (make-marker) (point-min))
7104 (set-marker (make-marker) (point-max))))))
7110 (run-hooks 'gnus-art-load-hook)
7112 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7113 ;;; gnus-art.el ends here