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 (defcustom gnus-copy-article-ignored-headers nil
568 "List of headers to be removed when copying an article.
569 Each element is a regular expression."
570 :version "22.0" ;; No Gnus
571 :type '(repeat regexp)
572 :group 'gnus-article-various)
574 (make-obsolete-variable 'gnus-article-hide-pgp-hook
575 "This variable is obsolete in Gnus 5.10.")
577 (defcustom gnus-article-button-face 'bold
578 "Face used for highlighting buttons in the article buffer.
580 An article button is a piece of text that you can activate by pressing
581 `RET' or `mouse-2' above it."
583 :group 'gnus-article-buttons)
585 (defcustom gnus-article-mouse-face 'highlight
586 "Face used for mouse highlighting in the article buffer.
588 Article buttons will be displayed in this face when the cursor is
591 :group 'gnus-article-buttons)
593 (defcustom gnus-signature-face 'gnus-signature-face
594 "Face used for highlighting a signature in the article buffer.
595 Obsolete; use the face `gnus-signature-face' for customizations instead."
597 :group 'gnus-article-highlight
598 :group 'gnus-article-signature)
600 (defface gnus-signature-face
603 "Face used for highlighting a signature in the article buffer."
604 :group 'gnus-article-highlight
605 :group 'gnus-article-signature)
607 (defface gnus-header-from-face
610 (:foreground "spring green"))
613 (:foreground "red3"))
616 "Face used for displaying from headers."
617 :group 'gnus-article-headers
618 :group 'gnus-article-highlight)
620 (defface gnus-header-subject-face
623 (:foreground "SeaGreen3"))
626 (:foreground "red4"))
628 (:bold t :italic t)))
629 "Face used for displaying subject headers."
630 :group 'gnus-article-headers
631 :group 'gnus-article-highlight)
633 (defface gnus-header-newsgroups-face
636 (:foreground "yellow" :italic t))
639 (:foreground "MidnightBlue" :italic t))
642 "Face used for displaying newsgroups headers.
643 In the default setup this face is only used for crossposted
645 :group 'gnus-article-headers
646 :group 'gnus-article-highlight)
648 (defface gnus-header-name-face
651 (:foreground "SeaGreen"))
654 (:foreground "maroon"))
657 "Face used for displaying header names."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight)
661 (defface gnus-header-content-face
664 (:foreground "forest green" :italic t))
667 (:foreground "indianred4" :italic t))
669 (:italic t))) "Face used for displaying header content."
670 :group 'gnus-article-headers
671 :group 'gnus-article-highlight)
673 (defcustom gnus-header-face-alist
674 '(("From" nil gnus-header-from-face)
675 ("Subject" nil gnus-header-subject-face)
676 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
677 ("" gnus-header-name-face gnus-header-content-face))
678 "*Controls highlighting of article headers.
680 An alist of the form (HEADER NAME CONTENT).
682 HEADER is a regular expression which should match the name of a
683 header and NAME and CONTENT are either face names or nil.
685 The name of each header field will be displayed using the face
686 specified by the first element in the list where HEADER matches
687 the header name and NAME is non-nil. Similarly, the content will
688 be displayed by the first non-nil matching CONTENT face."
689 :group 'gnus-article-headers
690 :group 'gnus-article-highlight
691 :type '(repeat (list (regexp :tag "Header")
693 (item :tag "skip" nil)
694 (face :value default))
695 (choice :tag "Content"
696 (item :tag "skip" nil)
697 (face :value default)))))
699 (defcustom gnus-article-decode-hook
700 '(article-decode-charset article-decode-encoded-words
701 article-decode-group-name article-decode-idna-rhs)
702 "*Hook run to decode charsets in articles."
703 :group 'gnus-article-headers
706 (defcustom gnus-display-mime-function 'gnus-display-mime
707 "Function to display MIME articles."
708 :group 'gnus-article-mime
711 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
712 "Function used to decode headers.")
714 (defvar gnus-article-dumbquotes-map
734 "Table for MS-to-Latin1 translation.")
736 (defcustom gnus-ignored-mime-types nil
737 "List of MIME types that should be ignored by Gnus."
739 :group 'gnus-article-mime
740 :type '(repeat regexp))
742 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
743 "List of MIME types that should not be given buttons when rendered inline.
744 See also `gnus-buttonized-mime-types' which may override this variable.
745 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
747 :group 'gnus-article-mime
748 :type '(repeat regexp))
750 (defcustom gnus-buttonized-mime-types nil
751 "List of MIME types that should be given buttons when rendered inline.
752 If set, this variable overrides `gnus-unbuttonized-mime-types'.
753 To see e.g. security buttons you could set this to
754 `(\"multipart/signed\")'.
755 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
757 :group 'gnus-article-mime
758 :type '(repeat regexp))
760 (defcustom gnus-inhibit-mime-unbuttonizing nil
761 "If non-nil, all MIME parts get buttons.
762 When nil (the default value), then some MIME parts do not get buttons,
763 as described by the variables `gnus-buttonized-mime-types' and
764 `gnus-unbuttonized-mime-types'."
766 :group 'gnus-article-mime
769 (defcustom gnus-body-boundary-delimiter "_"
770 "String used to delimit header and body.
771 This variable is used by `gnus-article-treat-body-boundary' which can
772 be controlled by `gnus-treat-body-boundary'."
774 :group 'gnus-article-various
775 :type '(choice (item :tag "None" :value nil)
778 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
780 "Defines the location of the faces database.
781 For information on obtaining this database of pretty pictures, please
782 see http://www.cs.indiana.edu/picons/ftp/index.html"
784 :type '(repeat directory)
785 :link '(url-link :tag "download"
786 "http://www.cs.indiana.edu/picons/ftp/index.html")
787 :link '(custom-manual "(gnus)Picons")
790 (defun gnus-picons-installed-p ()
791 "Say whether picons are installed on your machine."
792 (let ((installed nil))
793 (dolist (database gnus-picon-databases)
794 (when (file-exists-p database)
798 (defcustom gnus-article-mime-part-function nil
799 "Function called with a MIME handle as the argument.
800 This is meant for people who want to do something automatic based
801 on parts -- for instance, adding Vcard info to a database."
802 :group 'gnus-article-mime
805 (defcustom gnus-mime-multipart-functions nil
806 "An alist of MIME types to functions to display them."
808 :group 'gnus-article-mime
809 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
811 (defcustom gnus-article-date-lapsed-new-header nil
812 "Whether the X-Sent and Date headers can coexist.
813 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
814 either replace the old \"Date:\" header (if this variable is nil), or
815 be added below it (otherwise)."
817 :group 'gnus-article-headers
820 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
821 "Function called with a MIME handle as the argument.
822 This is meant for people who want to view first matched part.
823 For `undisplayed-alternative' (default), the first undisplayed
824 part or alternative part is used. For `undisplayed', the first
825 undisplayed part is used. For a function, the first part which
826 the function return t is used. For nil, the first part is
829 :group 'gnus-article-mime
831 (item :tag "first" :value nil)
832 (item :tag "undisplayed" :value undisplayed)
833 (item :tag "undisplayed or alternative"
834 :value undisplayed-alternative)
837 (defcustom gnus-mime-action-alist
838 '(("save to file" . gnus-mime-save-part)
839 ("save and strip" . gnus-mime-save-part-and-strip)
840 ("delete part" . gnus-mime-delete-part)
841 ("display as text" . gnus-mime-inline-part)
842 ("view the part" . gnus-mime-view-part)
843 ("pipe to command" . gnus-mime-pipe-part)
844 ("toggle display" . gnus-article-press-button)
845 ("toggle display" . gnus-article-view-part-as-charset)
846 ("view as type" . gnus-mime-view-part-as-type)
847 ("view internally" . gnus-mime-view-part-internally)
848 ("view externally" . gnus-mime-view-part-externally))
849 "An alist of actions that run on the MIME attachment."
850 :group 'gnus-article-mime
851 :type '(repeat (cons (string :tag "name")
855 ;;; The treatment variables
858 (defvar gnus-part-display-hook nil
859 "Hook called on parts that are to receive treatment.")
861 (defvar gnus-article-treat-custom
862 '(choice (const :tag "Off" nil)
864 (const :tag "Header" head)
865 (const :tag "Last" last)
866 (integer :tag "Less")
867 (repeat :tag "Groups" regexp)
868 (sexp :tag "Predicate")))
870 (defvar gnus-article-treat-head-custom
871 '(choice (const :tag "Off" nil)
872 (const :tag "Header" head)))
874 (defvar gnus-article-treat-types '("text/plain")
877 (defvar gnus-inhibit-treatment nil
878 "Whether to inhibit treatment.")
880 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
881 "Highlight the signature.
882 Valid values are nil, t, `head', `last', an integer or a predicate.
883 See Info node `(gnus)Customizing Articles'."
884 :group 'gnus-article-treat
885 :link '(custom-manual "(gnus)Customizing Articles")
886 :type gnus-article-treat-custom)
887 (put 'gnus-treat-highlight-signature 'highlight t)
889 (defcustom gnus-treat-buttonize 100000
891 Valid values are nil, t, `head', `last', an integer or a predicate.
892 See Info node `(gnus)Customizing Articles'."
893 :group 'gnus-article-treat
894 :link '(custom-manual "(gnus)Customizing Articles")
895 :type gnus-article-treat-custom)
896 (put 'gnus-treat-buttonize 'highlight t)
898 (defcustom gnus-treat-buttonize-head 'head
899 "Add buttons to the head.
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-head-custom)
905 (put 'gnus-treat-buttonize-head 'highlight t)
907 (defcustom gnus-treat-emphasize
908 (and (or window-system
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See Info node `(gnus)Customizing Articles' for details."
914 :group 'gnus-article-treat
915 :link '(custom-manual "(gnus)Customizing Articles")
916 :type gnus-article-treat-custom)
917 (put 'gnus-treat-emphasize 'highlight t)
919 (defcustom gnus-treat-strip-cr nil
920 "Remove carriage returns.
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See Info node `(gnus)Customizing Articles' for details."
924 :group 'gnus-article-treat
925 :link '(custom-manual "(gnus)Customizing Articles")
926 :type gnus-article-treat-custom)
928 (defcustom gnus-treat-unsplit-urls nil
929 "Remove newlines from within URLs.
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See Info node `(gnus)Customizing Articles' for details."
932 :group 'gnus-article-treat
933 :link '(custom-manual "(gnus)Customizing Articles")
934 :type gnus-article-treat-custom)
936 (defcustom gnus-treat-leading-whitespace nil
937 "Remove leading whitespace in headers.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
941 :group 'gnus-article-treat
942 :link '(custom-manual "(gnus)Customizing Articles")
943 :type gnus-article-treat-custom)
945 (defcustom gnus-treat-hide-headers 'head
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :link '(custom-manual "(gnus)Customizing Articles")
951 :type gnus-article-treat-head-custom)
953 (defcustom gnus-treat-hide-boring-headers nil
954 "Hide boring headers.
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-head-custom)
961 (defcustom gnus-treat-hide-signature nil
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-fill-article nil
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-custom)
977 (defcustom gnus-treat-hide-citation nil
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-custom)
985 (defcustom gnus-treat-hide-citation-maybe nil
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989 :group 'gnus-article-treat
990 :link '(custom-manual "(gnus)Customizing Articles")
991 :type gnus-article-treat-custom)
993 (defcustom gnus-treat-strip-list-identifiers 'head
994 "Strip list identifiers from `gnus-list-identifiers`.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
998 :group 'gnus-article-treat
999 :link '(custom-manual "(gnus)Customizing Articles")
1000 :type gnus-article-treat-custom)
1002 (make-obsolete-variable 'gnus-treat-strip-pgp
1003 "This option is obsolete in Gnus 5.10.")
1005 (defcustom gnus-treat-strip-pem nil
1006 "Strip PEM signatures.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :link '(custom-manual "(gnus)Customizing Articles")
1011 :type gnus-article-treat-custom)
1013 (defcustom gnus-treat-strip-banner t
1014 "Strip banners from articles.
1015 The banner to be stripped is specified in the `banner' group parameter.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-custom)
1022 (defcustom gnus-treat-highlight-headers 'head
1023 "Highlight the headers.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-head-custom)
1029 (put 'gnus-treat-highlight-headers 'highlight t)
1031 (defcustom gnus-treat-highlight-citation t
1032 "Highlight cited text.
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-custom)
1038 (put 'gnus-treat-highlight-citation 'highlight t)
1040 (defcustom gnus-treat-date-ut nil
1041 "Display the Date in UT (GMT).
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-head-custom)
1048 (defcustom gnus-treat-date-local nil
1049 "Display the Date in the local timezone.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-head-custom)
1056 (defcustom gnus-treat-date-english nil
1057 "Display the Date in a format that can be read aloud in English.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-head-custom)
1065 (defcustom gnus-treat-date-lapsed nil
1066 "Display the Date header in a way that says how much time has elapsed.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1073 (defcustom gnus-treat-date-original nil
1074 "Display the date in the original timezone.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-head-custom)
1081 (defcustom gnus-treat-date-iso8601 nil
1082 "Display the date in the ISO8601 format.
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-head-custom)
1090 (defcustom gnus-treat-date-user-defined nil
1091 "Display the date in a user-defined format.
1092 The format is defined by the `gnus-article-time-format' variable.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-head-custom)
1099 (defcustom gnus-treat-strip-headers-in-body t
1100 "Strip the X-No-Archive header line from the beginning of the body.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :link '(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-custom)
1108 (defcustom gnus-treat-strip-trailing-blank-lines nil
1109 "Strip trailing blank lines.
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-custom)
1116 (defcustom gnus-treat-strip-leading-blank-lines nil
1117 "Strip leading blank lines.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-custom)
1124 (defcustom gnus-treat-strip-multiple-blank-lines nil
1125 "Strip multiple blank lines.
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1128 :group 'gnus-article-treat
1129 :link '(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-custom)
1132 (defcustom gnus-treat-unfold-headers 'head
1133 "Unfold folded header lines.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1136 :group 'gnus-article-treat
1137 :link '(custom-manual "(gnus)Customizing Articles")
1138 :type gnus-article-treat-custom)
1140 (defcustom gnus-treat-fold-headers nil
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1149 (defcustom gnus-treat-fold-newsgroups 'head
1150 "Fold the Newsgroups and Followup-To headers.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-overstrike t
1159 "Treat overstrike highlighting.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-custom)
1165 (put 'gnus-treat-overstrike 'highlight t)
1167 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1168 "Treat ANSI SGR control sequences.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1171 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :type gnus-article-treat-custom)
1175 (make-obsolete-variable 'gnus-treat-display-xface
1176 'gnus-treat-display-x-face)
1178 (defcustom gnus-treat-display-x-face
1179 (and (not noninteractive)
1180 (or (and (fboundp 'image-type-available-p)
1181 (image-type-available-p 'xbm)
1182 (string-match "^0x" (shell-command-to-string "uncompface"))
1183 (executable-find "icontopbm"))
1184 (and (featurep 'xemacs)
1187 "Display X-Face headers.
1188 Valid values are nil, t, `head', `last', an integer or a predicate.
1189 See Info node `(gnus)Customizing Articles' and Info node
1190 `(gnus)X-Face' for details."
1191 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :link '(custom-manual "(gnus)X-Face")
1195 :type gnus-article-treat-head-custom
1196 :set (lambda (symbol value)
1199 (cond ((or (boundp symbol) (get symbol 'saved-value))
1201 ((boundp 'gnus-treat-display-xface)
1203 ** gnus-treat-display-xface is an obsolete variable;\
1204 use gnus-treat-display-x-face instead")
1205 (default-value 'gnus-treat-display-xface))
1206 ((get 'gnus-treat-display-xface 'saved-value)
1208 ** gnus-treat-display-xface is an obsolete variable;\
1209 use gnus-treat-display-x-face instead")
1210 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1213 (put 'gnus-treat-display-x-face 'highlight t)
1215 (defcustom gnus-treat-display-face
1216 (and (not noninteractive)
1217 (or (and (fboundp 'image-type-available-p)
1218 (image-type-available-p 'png))
1219 (and (featurep 'xemacs)
1222 "Display Face headers.
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' and Info node
1225 `(gnus)X-Face' for details."
1226 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :link '(custom-manual "(gnus)X-Face")
1230 :type gnus-article-treat-head-custom)
1231 (put 'gnus-treat-display-face 'highlight t)
1233 (defcustom gnus-treat-display-smileys
1234 (if (or (and (featurep 'xemacs)
1236 (and (fboundp 'image-type-available-p)
1237 (image-type-available-p 'pbm)))
1240 Valid values are nil, t, `head', `last', an integer or a predicate.
1241 See Info node `(gnus)Customizing Articles' and Info node
1242 `(gnus)Smileys' for details."
1243 :group 'gnus-article-treat
1245 :link '(custom-manual "(gnus)Customizing Articles")
1246 :link '(custom-manual "(gnus)Smileys")
1247 :type gnus-article-treat-custom)
1248 (put 'gnus-treat-display-smileys 'highlight t)
1250 (defcustom gnus-treat-from-picon
1251 (if (and (gnus-image-type-available-p 'xpm)
1252 (gnus-picons-installed-p))
1254 "Display picons in the From header.
1255 Valid values are nil, t, `head', `last', an integer or a predicate.
1256 See Info node `(gnus)Customizing Articles' and Info node
1257 `(gnus)Picons' for details."
1258 :group 'gnus-article-treat
1260 :link '(custom-manual "(gnus)Customizing Articles")
1261 :link '(custom-manual "(gnus)Picons")
1262 :type gnus-article-treat-head-custom)
1263 (put 'gnus-treat-from-picon 'highlight t)
1265 (defcustom gnus-treat-mail-picon
1266 (if (and (gnus-image-type-available-p 'xpm)
1267 (gnus-picons-installed-p))
1269 "Display picons in To and Cc headers.
1270 Valid values are nil, t, `head', `last', an integer or a predicate.
1271 See Info node `(gnus)Customizing Articles' and Info node
1272 `(gnus)Picons' for details."
1273 :group 'gnus-article-treat
1275 :link '(custom-manual "(gnus)Customizing Articles")
1276 :link '(custom-manual "(gnus)Picons")
1277 :type gnus-article-treat-head-custom)
1278 (put 'gnus-treat-mail-picon 'highlight t)
1280 (defcustom gnus-treat-newsgroups-picon
1281 (if (and (gnus-image-type-available-p 'xpm)
1282 (gnus-picons-installed-p))
1284 "Display picons in the Newsgroups and Followup-To headers.
1285 Valid values are nil, t, `head', `last', an integer or a predicate.
1286 See Info node `(gnus)Customizing Articles' and Info node
1287 `(gnus)Picons' for details."
1289 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :link '(custom-manual "(gnus)Picons")
1293 :type gnus-article-treat-head-custom)
1294 (put 'gnus-treat-newsgroups-picon 'highlight t)
1296 (defcustom gnus-treat-body-boundary
1297 (if (and (eq window-system 'x)
1298 (or gnus-treat-newsgroups-picon
1299 gnus-treat-mail-picon
1300 gnus-treat-from-picon))
1302 "Draw a boundary at the end of the headers.
1303 Valid values are nil and `head'.
1304 See Info node `(gnus)Customizing Articles' for details."
1306 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-head-custom)
1310 (defcustom gnus-treat-capitalize-sentences nil
1311 "Capitalize sentence-starting words.
1312 Valid values are nil, t, `head', `last', an integer or a predicate.
1313 See Info node `(gnus)Customizing Articles' for details."
1315 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-custom)
1319 (defcustom gnus-treat-wash-html nil
1321 Valid values are nil, t, `head', `last', an integer or a predicate.
1322 See Info node `(gnus)Customizing Articles' for details."
1324 :group 'gnus-article-treat
1325 :link '(custom-manual "(gnus)Customizing Articles")
1326 :type gnus-article-treat-custom)
1328 (defcustom gnus-treat-fill-long-lines nil
1330 Valid values are nil, t, `head', `last', an integer or a predicate.
1331 See Info node `(gnus)Customizing Articles' for details."
1332 :group 'gnus-article-treat
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-custom)
1336 (defcustom gnus-treat-play-sounds nil
1338 Valid values are nil, t, `head', `last', an integer or a predicate.
1339 See Info node `(gnus)Customizing Articles' for details."
1341 :group 'gnus-article-treat
1342 :link '(custom-manual "(gnus)Customizing Articles")
1343 :type gnus-article-treat-custom)
1345 (defcustom gnus-treat-translate nil
1346 "Translate articles from one language to another.
1347 Valid values are nil, t, `head', `last', an integer or a predicate.
1348 See Info node `(gnus)Customizing Articles' for details."
1350 :group 'gnus-article-treat
1351 :link '(custom-manual "(gnus)Customizing Articles")
1352 :type gnus-article-treat-custom)
1354 (defcustom gnus-treat-x-pgp-sig nil
1356 To automatically treat X-PGP-Sig, set it to head.
1357 Valid values are nil, t, `head', `last', an integer or a predicate.
1358 See Info node `(gnus)Customizing Articles' for details."
1359 :group 'gnus-article-treat
1360 :group 'mime-security
1361 :link '(custom-manual "(gnus)Customizing Articles")
1362 :type gnus-article-treat-custom)
1364 (defvar gnus-article-encrypt-protocol-alist
1365 '(("PGP" . mml2015-self-encrypt)))
1367 ;; Set to nil if more than one protocol added to
1368 ;; gnus-article-encrypt-protocol-alist.
1369 (defcustom gnus-article-encrypt-protocol "PGP"
1370 "The protocol used for encrypt articles.
1371 It is a string, such as \"PGP\". If nil, ask user."
1374 :group 'mime-security)
1376 (defvar gnus-article-wash-function nil
1377 "Function used for converting HTML into text.")
1379 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1380 (mm-coding-system-p 'utf-8)
1381 (executable-find idna-program))
1382 "Whether IDNA decoding of headers is used when viewing messages.
1383 This requires GNU Libidn, and by default only enabled if it is found."
1385 :group 'gnus-article-headers
1388 (defcustom gnus-article-over-scroll nil
1389 "If non-nil, allow scrolling the article buffer even when there no more text."
1391 :group 'gnus-article
1394 ;;; Internal variables
1396 (defvar gnus-english-month-names
1397 '("January" "February" "March" "April" "May" "June" "July" "August"
1398 "September" "October" "November" "December"))
1400 (defvar gnus-button-regexp nil)
1401 (defvar gnus-button-marker-list nil)
1402 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1404 (defvar gnus-button-last nil)
1405 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1407 (defvar article-goto-body-goes-to-point-min-p nil)
1408 (defvar gnus-article-wash-types nil)
1409 (defvar gnus-article-emphasis-alist nil)
1410 (defvar gnus-article-image-alist nil)
1412 (defvar gnus-article-mime-handle-alist-1 nil)
1413 (defvar gnus-treatment-function-alist
1414 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1415 (gnus-treat-strip-banner gnus-article-strip-banner)
1416 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1417 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1418 (gnus-treat-buttonize gnus-article-add-buttons)
1419 (gnus-treat-fill-article gnus-article-fill-cited-article)
1420 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1421 (gnus-treat-strip-cr gnus-article-remove-cr)
1422 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1423 (gnus-treat-date-ut gnus-article-date-ut)
1424 (gnus-treat-date-local gnus-article-date-local)
1425 (gnus-treat-date-english gnus-article-date-english)
1426 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1427 (gnus-treat-date-original gnus-article-date-original)
1428 (gnus-treat-date-user-defined gnus-article-date-user)
1429 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1430 (gnus-treat-display-x-face gnus-article-display-x-face)
1431 (gnus-treat-display-face gnus-article-display-face)
1432 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1433 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1434 (gnus-treat-hide-signature gnus-article-hide-signature)
1435 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1436 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1437 (gnus-treat-strip-pem gnus-article-hide-pem)
1438 (gnus-treat-from-picon gnus-treat-from-picon)
1439 (gnus-treat-mail-picon gnus-treat-mail-picon)
1440 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1441 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1442 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1443 (gnus-treat-strip-trailing-blank-lines
1444 gnus-article-remove-trailing-blank-lines)
1445 (gnus-treat-strip-leading-blank-lines
1446 gnus-article-strip-leading-blank-lines)
1447 (gnus-treat-strip-multiple-blank-lines
1448 gnus-article-strip-multiple-blank-lines)
1449 (gnus-treat-overstrike gnus-article-treat-overstrike)
1450 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1451 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1452 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1453 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1454 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1455 (gnus-treat-display-smileys gnus-treat-smiley)
1456 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1457 (gnus-treat-wash-html gnus-article-wash-html)
1458 (gnus-treat-emphasize gnus-article-emphasize)
1459 (gnus-treat-hide-citation gnus-article-hide-citation)
1460 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1461 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1462 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1463 (gnus-treat-play-sounds gnus-earcon-display)))
1465 (defvar gnus-article-mime-handle-alist nil)
1466 (defvar article-lapsed-timer nil)
1467 (defvar gnus-article-current-summary nil)
1469 (defvar gnus-article-mode-syntax-table
1470 (let ((table (copy-syntax-table text-mode-syntax-table)))
1471 ;; This causes the citation match run O(2^n).
1472 ;; (modify-syntax-entry ?- "w" table)
1473 (modify-syntax-entry ?> ")<" table)
1474 (modify-syntax-entry ?< "(>" table)
1475 ;; make M-. in article buffers work for `foo' strings
1476 (modify-syntax-entry ?' " " table)
1477 (modify-syntax-entry ?` " " table)
1479 "Syntax table used in article mode buffers.
1480 Initialized from `text-mode-syntax-table.")
1482 (defvar gnus-save-article-buffer nil)
1484 (defvar gnus-article-mode-line-format-alist
1485 (nconc '((?w (gnus-article-wash-status) ?s)
1486 (?m (gnus-article-mime-part-status) ?s))
1487 gnus-summary-mode-line-format-alist))
1489 (defvar gnus-number-of-articles-to-be-saved nil)
1491 (defvar gnus-inhibit-hiding nil)
1493 (defvar gnus-article-edit-mode nil)
1495 ;;; Macros for dealing with the article buffer.
1497 (defmacro gnus-with-article-headers (&rest forms)
1499 (set-buffer gnus-article-buffer)
1501 (let ((inhibit-read-only t)
1502 (inhibit-point-motion-hooks t)
1503 (case-fold-search t))
1504 (article-narrow-to-head)
1507 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1508 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1510 (defmacro gnus-with-article-buffer (&rest forms)
1512 (set-buffer gnus-article-buffer)
1513 (let ((inhibit-read-only t))
1516 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1517 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1519 (defun gnus-article-goto-header (header)
1520 "Go to HEADER, which is a regular expression."
1521 (re-search-forward (concat "^\\(" header "\\):") nil t))
1523 (defsubst gnus-article-hide-text (b e props)
1524 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1525 (gnus-add-text-properties-when 'article-type nil b e props)
1526 (when (memq 'intangible props)
1528 (max (1- b) (point-min))
1529 b 'intangible (cddr (memq 'intangible props)))))
1531 (defsubst gnus-article-unhide-text (b e)
1532 "Remove hidden text properties from region between B and E."
1533 (remove-text-properties b e gnus-hidden-properties)
1534 (when (memq 'intangible gnus-hidden-properties)
1535 (put-text-property (max (1- b) (point-min))
1536 b 'intangible nil)))
1538 (defun gnus-article-hide-text-type (b e type)
1539 "Hide text of TYPE between B and E."
1540 (gnus-add-wash-type type)
1541 (gnus-article-hide-text
1542 b e (cons 'article-type (cons type gnus-hidden-properties))))
1544 (defun gnus-article-unhide-text-type (b e type)
1545 "Unhide text of TYPE between B and E."
1546 (gnus-delete-wash-type type)
1547 (remove-text-properties
1548 b e (cons 'article-type (cons type gnus-hidden-properties)))
1549 (when (memq 'intangible gnus-hidden-properties)
1550 (put-text-property (max (1- b) (point-min))
1551 b 'intangible nil)))
1553 (defun gnus-article-hide-text-of-type (type)
1554 "Hide text of TYPE in the current buffer."
1556 (let ((b (point-min))
1558 (while (setq b (text-property-any b e 'article-type type))
1559 (add-text-properties b (incf b) gnus-hidden-properties)))))
1561 (defun gnus-article-delete-text-of-type (type)
1562 "Delete text of TYPE in the current buffer."
1564 (let ((b (point-min)))
1565 (while (setq b (text-property-any b (point-max) 'article-type type))
1567 b (or (text-property-not-all b (point-max) 'article-type type)
1570 (defun gnus-article-delete-invisible-text ()
1571 "Delete all invisible text in the current buffer."
1573 (let ((b (point-min)))
1574 (while (setq b (text-property-any b (point-max) 'invisible t))
1576 b (or (text-property-not-all b (point-max) 'invisible t)
1579 (defun gnus-article-text-type-exists-p (type)
1580 "Say whether any text of type TYPE exists in the buffer."
1581 (text-property-any (point-min) (point-max) 'article-type type))
1583 (defsubst gnus-article-header-rank ()
1584 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1585 (let ((list gnus-sorted-header-list)
1588 (if (looking-at (car list))
1590 (setq list (cdr list))
1594 (defun article-hide-headers (&optional arg delete)
1595 "Hide unwanted headers and possibly sort them as well."
1597 ;; This function might be inhibited.
1598 (unless gnus-inhibit-hiding
1599 (let ((inhibit-read-only nil)
1600 (case-fold-search t)
1601 (max (1+ (length gnus-sorted-header-list)))
1602 (inhibit-point-motion-hooks t)
1603 (cur (current-buffer))
1604 ignored visible beg)
1606 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1607 ;; group parameters, so we should go to the summary buffer.
1610 (progn (set-buffer gnus-summary-buffer) t)
1612 (setq ignored (when (not gnus-visible-headers)
1613 (cond ((stringp gnus-ignored-headers)
1614 gnus-ignored-headers)
1615 ((listp gnus-ignored-headers)
1616 (mapconcat 'identity
1617 gnus-ignored-headers
1619 visible (cond ((stringp gnus-visible-headers)
1620 gnus-visible-headers)
1621 ((and gnus-visible-headers
1622 (listp gnus-visible-headers))
1623 (mapconcat 'identity
1624 gnus-visible-headers
1628 ;; First we narrow to just the headers.
1629 (article-narrow-to-head)
1630 ;; Hide any "From " lines at the beginning of (mail) articles.
1631 (while (looking-at "From ")
1634 (delete-region (point-min) (point)))
1635 ;; Then treat the rest of the header lines.
1636 ;; Then we use the two regular expressions
1637 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1638 ;; select which header lines is to remain visible in the
1640 (while (re-search-forward "^[^ \t:]*:" nil t)
1642 ;; Mark the rank of the header.
1644 (point) (1+ (point)) 'message-rank
1645 (if (or (and visible (looking-at visible))
1647 (not (looking-at ignored))))
1648 (gnus-article-header-rank)
1651 (message-sort-headers-1)
1652 (when (setq beg (text-property-any
1653 (point-min) (point-max) 'message-rank (+ 2 max)))
1654 ;; We delete the unwanted headers.
1655 (gnus-add-wash-type 'headers)
1656 (add-text-properties (point-min) (+ 5 (point-min))
1657 '(article-type headers dummy-invisible t))
1658 (delete-region beg (point-max))))))))
1660 (defun article-hide-boring-headers (&optional arg)
1661 "Toggle hiding of headers that aren't very interesting.
1662 If given a negative prefix, always show; if given a positive prefix,
1664 (interactive (gnus-article-hidden-arg))
1665 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1666 (not gnus-show-all-headers))
1669 (let ((inhibit-read-only t)
1670 (inhibit-point-motion-hooks t))
1671 (article-narrow-to-head)
1672 (dolist (elem gnus-boring-article-headers)
1673 (goto-char (point-min))
1675 ;; Hide empty headers.
1677 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1679 (gnus-article-hide-text-type
1683 (if (re-search-forward "^[^ \t]" nil t)
1687 ;; Hide boring Newsgroups header.
1688 ((eq elem 'newsgroups)
1689 (when (gnus-string-equal
1690 (gnus-fetch-field "newsgroups")
1691 (gnus-group-real-name
1692 (if (boundp 'gnus-newsgroup-name)
1695 (gnus-article-hide-header "newsgroups")))
1696 ((eq elem 'to-address)
1697 (let ((to (message-fetch-field "to"))
1699 (gnus-parameter-to-address
1700 (if (boundp 'gnus-newsgroup-name)
1701 gnus-newsgroup-name ""))))
1702 (when (and to to-address
1705 ;; only one address in To
1706 (nth 1 (mail-extract-address-components to))
1708 (gnus-article-hide-header "to"))))
1710 (let ((to (message-fetch-field "to"))
1712 (gnus-parameter-to-list
1713 (if (boundp 'gnus-newsgroup-name)
1714 gnus-newsgroup-name ""))))
1715 (when (and to to-list
1718 ;; only one address in To
1719 (nth 1 (mail-extract-address-components to))
1721 (gnus-article-hide-header "to"))))
1723 (let ((cc (message-fetch-field "cc"))
1725 (gnus-parameter-to-list
1726 (if (boundp 'gnus-newsgroup-name)
1727 gnus-newsgroup-name ""))))
1728 (when (and cc to-list
1731 ;; only one address in CC
1732 (nth 1 (mail-extract-address-components cc))
1734 (gnus-article-hide-header "cc"))))
1735 ((eq elem 'followup-to)
1736 (when (gnus-string-equal
1737 (message-fetch-field "followup-to")
1738 (message-fetch-field "newsgroups"))
1739 (gnus-article-hide-header "followup-to")))
1740 ((eq elem 'reply-to)
1741 (if (gnus-group-find-parameter
1742 gnus-newsgroup-name 'broken-reply-to)
1743 (gnus-article-hide-header "reply-to")
1744 (let ((from (message-fetch-field "from"))
1745 (reply-to (message-fetch-field "reply-to")))
1752 (lambda (x) (downcase (cadr x)))
1753 (mail-extract-address-components from t))
1756 (lambda (x) (downcase (cadr x)))
1757 (mail-extract-address-components reply-to t))
1759 (gnus-article-hide-header "reply-to")))))
1761 (let ((date (message-fetch-field "date")))
1763 (< (days-between (current-time-string) date)
1765 (gnus-article-hide-header "date"))))
1767 (let ((to (message-fetch-field "to"))
1768 (cc (message-fetch-field "cc")))
1769 (when (> (length to) 1024)
1770 (gnus-article-hide-header "to"))
1771 (when (> (length cc) 1024)
1772 (gnus-article-hide-header "cc"))))
1776 (goto-char (point-min))
1777 (while (re-search-forward "^to:" nil t)
1778 (setq to-count (1+ to-count)))
1779 (when (> to-count 1)
1780 (while (> to-count 0)
1781 (goto-char (point-min))
1783 (re-search-forward "^to:" nil nil to-count)
1785 (narrow-to-region (point) (point-max))
1786 (gnus-article-hide-header "to"))
1787 (setq to-count (1- to-count))))
1788 (goto-char (point-min))
1789 (while (re-search-forward "^cc:" nil t)
1790 (setq cc-count (1+ cc-count)))
1791 (when (> cc-count 1)
1792 (while (> cc-count 0)
1793 (goto-char (point-min))
1795 (re-search-forward "^cc:" nil nil cc-count)
1797 (narrow-to-region (point) (point-max))
1798 (gnus-article-hide-header "cc"))
1799 (setq cc-count (1- cc-count)))))))))))))
1801 (defun gnus-article-hide-header (header)
1803 (goto-char (point-min))
1804 (when (re-search-forward (concat "^" header ":") nil t)
1805 (gnus-article-hide-text-type
1809 (if (re-search-forward "^[^ \t]" nil t)
1814 (defvar gnus-article-normalized-header-length 40
1815 "Length of normalized headers.")
1817 (defun article-normalize-headers ()
1818 "Make all header lines 40 characters long."
1820 (let ((inhibit-read-only t)
1824 (article-narrow-to-head)
1827 ((< (setq column (- (point-at-eol) (point)))
1828 gnus-article-normalized-header-length)
1830 (insert (make-string
1831 (- gnus-article-normalized-header-length column)
1833 ((> column gnus-article-normalized-header-length)
1834 (gnus-put-text-property
1836 (forward-char gnus-article-normalized-header-length)
1843 (forward-line 1))))))
1845 (defun article-treat-dumbquotes ()
1846 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1847 Note that this function guesses whether a character is a sm*rtq**t* or
1848 not, so it should only be used interactively.
1850 Sm*rtq**t*s are M****s***'s unilateral extension to the
1851 iso-8859-1 character map in an attempt to provide more quoting
1852 characters. If you see something like \\222 or \\264 where
1853 you're expecting some kind of apostrophe or quotation mark, then
1856 (article-translate-strings gnus-article-dumbquotes-map))
1858 (defun article-translate-characters (from to)
1859 "Translate all characters in the body of the article according to FROM and TO.
1860 FROM is a string of characters to translate from; to is a string of
1861 characters to translate to."
1863 (when (article-goto-body)
1864 (let ((inhibit-read-only t)
1865 (x (make-string 225 ?x))
1867 (while (< (incf i) (length x))
1870 (while (< i (length from))
1871 (aset x (aref from i) (aref to i))
1873 (translate-region (point) (point-max) x)))))
1875 (defun article-translate-strings (map)
1876 "Translate all string in the body of the article according to MAP.
1877 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1879 (when (article-goto-body)
1880 (let ((inhibit-read-only t))
1883 (while (search-forward (car elem) nil t)
1884 (replace-match (cadr elem)))))))))
1886 (defun article-treat-overstrike ()
1887 "Translate overstrikes into bold text."
1890 (when (article-goto-body)
1891 (let ((inhibit-read-only t))
1892 (while (search-forward "\b" nil t)
1893 (let ((next (char-after))
1894 (previous (char-after (- (point) 2))))
1895 ;; We do the boldification/underlining by hiding the
1896 ;; overstrikes and putting the proper text property
1900 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1901 (put-text-property (point) (1+ (point)) 'face 'bold))
1903 (gnus-article-hide-text-type
1904 (1- (point)) (1+ (point)) 'overstrike)
1906 (- (point) 2) (1- (point)) 'face 'underline))
1908 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1910 (point) (1+ (point)) 'face 'underline)))))))))
1912 (defun article-treat-ansi-sequences ()
1913 "Translate ANSI SGR control sequences into overlays or extents."
1916 (when (article-goto-body)
1917 (let ((inhibit-read-only t))
1918 (ansi-color-apply-on-region (point) (point-max))))))
1920 (defun gnus-article-treat-unfold-headers ()
1921 "Unfold folded message headers.
1922 Only the headers that fit into the current window width will be
1925 (gnus-with-article-headers
1929 (mail-header-narrow-to-field)
1930 (let ((header (buffer-string)))
1933 (goto-char (point-min))
1934 (while (re-search-forward "\n[\t ]" nil t)
1935 (replace-match " " t t)))
1936 (setq length (- (point-max) (point-min) 1)))
1937 (when (< length (window-width))
1938 (while (re-search-forward "\n[\t ]" nil t)
1939 (replace-match " " t t)))
1940 (goto-char (point-max)))))))
1942 (defun gnus-article-treat-fold-headers ()
1943 "Fold message headers."
1945 (gnus-with-article-headers
1948 (mail-header-narrow-to-field)
1949 (mail-header-fold-field)
1950 (goto-char (point-max))))))
1952 (defun gnus-treat-smiley ()
1953 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1955 (gnus-with-article-buffer
1956 (if (memq 'smiley gnus-article-wash-types)
1957 (gnus-delete-images 'smiley)
1959 (let ((images (smiley-region (point) (point-max))))
1961 (gnus-add-wash-type 'smiley)
1962 (dolist (image images)
1963 (gnus-add-image 'smiley image)))))))
1965 (defun gnus-article-remove-images ()
1966 "Remove all images from the article buffer."
1968 (gnus-with-article-buffer
1969 (dolist (elem gnus-article-image-alist)
1970 (gnus-delete-images (car elem)))))
1972 (defun gnus-article-treat-fold-newsgroups ()
1973 "Unfold folded message headers.
1974 Only the headers that fit into the current window width will be
1977 (gnus-with-article-headers
1978 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1980 (mail-header-narrow-to-field)
1981 (while (re-search-forward ", *" nil t)
1982 (replace-match ", " t t))
1983 (mail-header-fold-field)
1984 (goto-char (point-max))))))
1986 (defun gnus-article-treat-body-boundary ()
1987 "Place a boundary line at the end of the headers."
1989 (when (and gnus-body-boundary-delimiter
1990 (> (length gnus-body-boundary-delimiter) 0))
1991 (gnus-with-article-headers
1992 (goto-char (point-max))
1993 (let ((start (point)))
1994 (insert "X-Boundary: ")
1995 (gnus-add-text-properties start (point) '(invisible t intangible t))
1997 (while (>= (1- (window-width)) (length str))
1998 (setq str (concat str gnus-body-boundary-delimiter)))
1999 (substring str 0 (1- (window-width))))
2001 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2003 (defun article-fill-long-lines ()
2004 "Fill lines that are wider than the window width."
2007 (let ((inhibit-read-only t)
2008 (width (window-width (get-buffer-window (current-buffer)))))
2011 (let ((adaptive-fill-mode nil)) ;Why? -sm
2014 (when (>= (current-column) (min fill-column width))
2015 (narrow-to-region (min (1+ (point)) (point-max))
2017 (let ((goback (point-marker)))
2018 (fill-paragraph nil)
2019 (goto-char (marker-position goback)))
2021 (forward-line 1)))))))
2023 (defun article-capitalize-sentences ()
2024 "Capitalize the first word in each sentence."
2027 (let ((inhibit-read-only t)
2028 (paragraph-start "^[\n\^L]"))
2032 (forward-sentence)))))
2034 (defun article-remove-cr ()
2035 "Remove trailing CRs and then translate remaining CRs into LFs."
2038 (let ((inhibit-read-only t))
2039 (goto-char (point-min))
2040 (while (re-search-forward "\r+$" nil t)
2041 (replace-match "" t t))
2042 (goto-char (point-min))
2043 (while (search-forward "\r" nil t)
2044 (replace-match "\n" t t)))))
2046 (defun article-remove-trailing-blank-lines ()
2047 "Remove all trailing blank lines from the article."
2050 (let ((inhibit-read-only t))
2051 (goto-char (point-max))
2055 (while (and (not (bobp))
2056 (looking-at "^[ \t]*$")
2057 (not (gnus-annotation-in-region-p
2058 (point) (point-at-eol))))
2064 (defvar gnus-face-properties-alist))
2066 (defun article-display-face ()
2067 "Display any Face headers in the header."
2069 (let ((wash-face-p buffer-read-only))
2070 (gnus-with-article-headers
2071 ;; When displaying parts, this function can be called several times on
2072 ;; the same article, without any intended toggle semantic (as typing `W
2073 ;; D d' would have). So face deletion must occur only when we come from
2074 ;; an interactive command, that is when the *Article* buffer is
2076 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2077 (gnus-delete-images 'face)
2080 (when (and wash-face-p
2082 (goto-char (point-min))
2083 (not (re-search-forward "^Face:[\t ]*" nil t)))
2084 (gnus-buffer-live-p gnus-original-article-buffer))
2085 (set-buffer gnus-original-article-buffer))
2087 (mail-narrow-to-head)
2088 (while (gnus-article-goto-header "Face")
2089 (setq faces (nconc faces (list (mail-header-field-value)))))))
2090 (dolist (face faces)
2091 (let ((png (gnus-convert-face-to-png face))
2095 (apply 'gnus-create-image png 'png t
2096 (cdr (assq 'png gnus-face-properties-alist))))
2097 (gnus-article-goto-header "from")
2099 (insert "From: [no `from' set]\n")
2101 (gnus-add-wash-type 'face)
2102 (gnus-add-image 'face image)
2103 (gnus-put-image image nil 'face))))))
2106 (defun article-display-x-face (&optional force)
2107 "Look for an X-Face header and display it if present."
2108 (interactive (list 'force))
2109 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2110 (gnus-with-article-headers
2111 ;; Delete the old process, if any.
2112 (when (process-status "article-x-face")
2113 (delete-process "article-x-face"))
2114 ;; See the comment in `article-display-face'.
2115 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2116 ;; We have already displayed X-Faces, so we remove them
2118 (gnus-delete-images 'xface)
2120 (let (x-faces from face)
2122 (when (and wash-face-p
2124 (goto-char (point-min))
2125 (not (re-search-forward
2126 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2127 (gnus-buffer-live-p gnus-original-article-buffer))
2128 ;; If type `W f', use gnus-original-article-buffer,
2129 ;; otherwise use the current buffer because displaying
2130 ;; RFC822 parts calls this function too.
2131 (set-buffer gnus-original-article-buffer))
2133 (mail-narrow-to-head)
2134 (while (gnus-article-goto-header "X-Face")
2135 (push (mail-header-field-value) x-faces))
2136 (setq from (message-fetch-field "from"))))
2137 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2138 ;; single external face.
2139 (when (stringp gnus-article-x-face-command)
2140 (setq x-faces (list (car x-faces))))
2141 (while (and (setq face (pop x-faces))
2142 gnus-article-x-face-command
2144 ;; Check whether this face is censored.
2145 (not gnus-article-x-face-too-ugly)
2146 (and gnus-article-x-face-too-ugly from
2147 (not (string-match gnus-article-x-face-too-ugly
2149 ;; We display the face.
2150 (cond ((stringp gnus-article-x-face-command)
2151 ;; The command is a string, so we interpret the command
2152 ;; as a, well, command, and fork it off.
2153 (let ((process-connection-type nil))
2154 (process-kill-without-query
2156 "article-x-face" nil shell-file-name
2157 shell-command-switch gnus-article-x-face-command))
2160 (process-send-region "article-x-face"
2161 (point-min) (point-max)))
2162 (process-send-eof "article-x-face")))
2163 ((functionp gnus-article-x-face-command)
2164 ;; The command is a lisp function, so we call it.
2165 (funcall gnus-article-x-face-command face))
2167 (error "%s is not a function"
2168 gnus-article-x-face-command)))))))))
2170 (defun article-decode-mime-words ()
2171 "Decode all MIME-encoded words in the article."
2173 (gnus-with-article-buffer
2174 (let ((inhibit-point-motion-hooks t)
2175 (mail-parse-charset gnus-newsgroup-charset)
2176 (mail-parse-ignored-charsets
2177 (with-current-buffer gnus-summary-buffer
2178 gnus-newsgroup-ignored-charsets)))
2179 (mail-decode-encoded-word-region (point-min) (point-max)))))
2181 (defun article-decode-charset (&optional prompt)
2182 "Decode charset-encoded text in the article.
2183 If PROMPT (the prefix), prompt for a coding system to use."
2185 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2186 (inhibit-read-only t)
2187 (mail-parse-charset gnus-newsgroup-charset)
2188 (mail-parse-ignored-charsets
2189 (save-excursion (condition-case nil
2190 (set-buffer gnus-summary-buffer)
2192 gnus-newsgroup-ignored-charsets))
2193 ct cte ctl charset format)
2196 (article-narrow-to-head)
2197 (setq ct (message-fetch-field "Content-Type" t)
2198 cte (message-fetch-field "Content-Transfer-Encoding" t)
2199 ctl (and ct (ignore-errors
2200 (mail-header-parse-content-type ct)))
2203 (mm-read-coding-system "Charset to decode: "))
2205 (mail-content-type-get ctl 'charset)))
2206 format (and ctl (mail-content-type-get ctl 'format)))
2208 (setq cte (mail-header-strip cte)))
2209 (if (and ctl (not (string-match "/" (car ctl))))
2211 (goto-char (point-max)))
2214 (narrow-to-region (point) (point-max))
2215 (when (and (eq mail-parse-charset 'gnus-decoded)
2216 (eq (mm-body-7-or-8) '8bit))
2217 ;; The text code could have been decoded.
2218 (setq charset mail-parse-charset))
2219 (when (and (or (not ctl)
2220 (equal (car ctl) "text/plain"))
2221 (not format)) ;; article with format will decode later.
2223 charset (and cte (intern (downcase
2224 (gnus-strip-whitespace cte))))
2227 (defun article-decode-encoded-words ()
2228 "Remove encoded-word encoding from headers."
2229 (let ((inhibit-point-motion-hooks t)
2230 (mail-parse-charset gnus-newsgroup-charset)
2231 (mail-parse-ignored-charsets
2232 (save-excursion (condition-case nil
2233 (set-buffer gnus-summary-buffer)
2235 gnus-newsgroup-ignored-charsets))
2236 (inhibit-read-only t))
2238 (article-narrow-to-head)
2239 (funcall gnus-decode-header-function (point-min) (point-max)))))
2241 (defun article-decode-group-name ()
2242 "Decode group names in `Newsgroups:'."
2243 (let ((inhibit-point-motion-hooks t)
2244 (inhibit-read-only t)
2245 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2246 (when (and (or gnus-group-name-charset-method-alist
2247 gnus-group-name-charset-group-alist)
2248 (gnus-buffer-live-p gnus-original-article-buffer))
2250 (article-narrow-to-head)
2251 (with-current-buffer gnus-original-article-buffer
2252 (goto-char (point-min)))
2253 (while (re-search-forward
2254 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2255 (replace-match (save-match-data
2256 (gnus-decode-newsgroups
2257 ;; XXX how to use data in article buffer?
2258 (with-current-buffer gnus-original-article-buffer
2260 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2263 gnus-newsgroup-name method))
2265 (goto-char (point-min))
2266 (with-current-buffer gnus-original-article-buffer
2267 (goto-char (point-min)))
2268 (while (re-search-forward
2269 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2270 (replace-match (save-match-data
2271 (gnus-decode-newsgroups
2272 ;; XXX how to use data in article buffer?
2273 (with-current-buffer gnus-original-article-buffer
2275 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2278 gnus-newsgroup-name method))
2281 (autoload 'idna-to-unicode "idna")
2283 (defun article-decode-idna-rhs ()
2284 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2287 (let ((inhibit-point-motion-hooks t)
2288 (inhibit-read-only t))
2289 (article-narrow-to-head)
2290 (goto-char (point-min))
2291 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2293 (when (save-match-data
2294 (and (setq ace (match-string 1))
2296 (and (re-search-backward "^[^ \t]" nil t)
2297 (looking-at "From\\|To\\|Cc")))
2298 (setq unicode (idna-to-unicode ace))))
2299 (unless (string= ace unicode)
2300 (replace-match unicode nil nil nil 1)))))))))
2302 (defun article-de-quoted-unreadable (&optional force read-charset)
2303 "Translate a quoted-printable-encoded article.
2304 If FORCE, decode the article whether it is marked as quoted-printable
2306 If READ-CHARSET, ask for a coding system."
2307 (interactive (list 'force current-prefix-arg))
2309 (let ((inhibit-read-only t) type charset)
2310 (if (gnus-buffer-live-p gnus-original-article-buffer)
2311 (with-current-buffer gnus-original-article-buffer
2313 (gnus-fetch-field "content-transfer-encoding"))
2314 (let* ((ct (gnus-fetch-field "content-type"))
2317 (mail-header-parse-content-type ct)))))
2318 (setq charset (and ctl
2319 (mail-content-type-get ctl 'charset)))
2320 (if (stringp charset)
2321 (setq charset (intern (downcase charset)))))))
2323 (setq charset (mm-read-coding-system "Charset: " charset)))
2325 (setq charset gnus-newsgroup-charset))
2327 (and type (let ((case-fold-search t))
2328 (string-match "quoted-printable" type))))
2330 (quoted-printable-decode-region
2331 (point) (point-max) (mm-charset-to-coding-system charset))))))
2333 (defun article-de-base64-unreadable (&optional force read-charset)
2334 "Translate a base64 article.
2335 If FORCE, decode the article whether it is marked as base64 not.
2336 If READ-CHARSET, ask for a coding system."
2337 (interactive (list 'force current-prefix-arg))
2339 (let ((inhibit-read-only t) type charset)
2340 (if (gnus-buffer-live-p gnus-original-article-buffer)
2341 (with-current-buffer gnus-original-article-buffer
2343 (gnus-fetch-field "content-transfer-encoding"))
2344 (let* ((ct (gnus-fetch-field "content-type"))
2347 (mail-header-parse-content-type ct)))))
2348 (setq charset (and ctl
2349 (mail-content-type-get ctl 'charset)))
2350 (if (stringp charset)
2351 (setq charset (intern (downcase charset)))))))
2353 (setq charset (mm-read-coding-system "Charset: " charset)))
2355 (setq charset gnus-newsgroup-charset))
2357 (and type (let ((case-fold-search t))
2358 (string-match "base64" type))))
2361 (narrow-to-region (point) (point-max))
2362 (base64-decode-region (point-min) (point-max))
2363 (mm-decode-coding-region
2364 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2369 (defun article-decode-HZ ()
2370 "Translate a HZ-encoded article."
2374 (let ((inhibit-read-only t))
2375 (rfc1843-decode-region (point-min) (point-max)))))
2377 (defun article-unsplit-urls ()
2378 "Remove the newlines that some other mailers insert into URLs."
2381 (let ((inhibit-read-only t))
2382 (goto-char (point-min))
2383 (while (re-search-forward
2384 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2385 (replace-match "\\1\\3" t)))
2386 (when (interactive-p)
2387 (gnus-treat-article nil))))
2390 (defun article-wash-html (&optional read-charset)
2391 "Format an HTML article.
2392 If READ-CHARSET, ask for a coding system."
2395 (let ((inhibit-read-only t)
2397 (when (gnus-buffer-live-p gnus-original-article-buffer)
2398 (with-current-buffer gnus-original-article-buffer
2399 (let* ((ct (gnus-fetch-field "content-type"))
2402 (mail-header-parse-content-type ct)))))
2403 (setq charset (and ctl
2404 (mail-content-type-get ctl 'charset)))
2405 (when (stringp charset)
2406 (setq charset (intern (downcase charset)))))))
2408 (setq charset (mm-read-coding-system "Charset: " charset)))
2410 (setq charset gnus-newsgroup-charset))
2412 (save-window-excursion
2414 (narrow-to-region (point) (point-max))
2415 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2416 (entry (assq func mm-text-html-washer-alist)))
2418 (setq func (cdr entry)))
2423 (apply (car func) (cdr func))))))))))
2425 (defun gnus-article-wash-html-with-w3 ()
2426 "Wash the current buffer with w3."
2428 (let ((w3-strict-width (window-width))
2429 (url-standalone-mode t)
2430 (url-gateway-unplugged t)
2431 (w3-honor-stylesheets nil))
2433 (w3-region (point-min) (point-max))
2436 (defun gnus-article-wash-html-with-w3m ()
2437 "Wash the current buffer with emacs-w3m."
2440 (narrow-to-region (point) (point-max))
2441 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2442 w3m-force-redisplay)
2443 (w3m-region (point-min) (point-max)))
2444 (when (and mm-inline-text-html-with-w3m-keymap
2445 (boundp 'w3m-minor-mode-map)
2447 (add-text-properties
2448 (point-min) (point-max)
2449 (list 'keymap w3m-minor-mode-map
2450 ;; Put the mark meaning this part was rendered by emacs-w3m.
2451 'mm-inline-text-html-with-w3m t)))))
2453 (defun article-hide-list-identifiers ()
2454 "Remove list identifies from the Subject header.
2455 The `gnus-list-identifiers' variable specifies what to do."
2457 (let ((inhibit-point-motion-hooks t)
2458 (regexp (if (consp gnus-list-identifiers)
2459 (mapconcat 'identity gnus-list-identifiers " *\\|")
2460 gnus-list-identifiers))
2461 (inhibit-read-only t))
2465 (article-narrow-to-head)
2466 (goto-char (point-min))
2467 (while (re-search-forward
2468 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2470 (delete-region (match-beginning 2) (match-end 0))
2471 (beginning-of-line))
2472 (when (re-search-forward
2473 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2474 (delete-region (match-beginning 1) (match-end 1))))))))
2476 (defun article-hide-pem (&optional arg)
2477 "Toggle hiding of any PEM headers and signatures in the current article.
2478 If given a negative prefix, always show; if given a positive prefix,
2480 (interactive (gnus-article-hidden-arg))
2481 (unless (gnus-article-check-hidden-text 'pem arg)
2483 (let ((inhibit-read-only t) end)
2484 (goto-char (point-min))
2485 ;; Hide the horrendously ugly "header".
2486 (when (and (search-forward
2487 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2489 (setq end (1+ (match-beginning 0))))
2490 (gnus-add-wash-type 'pem)
2491 (gnus-article-hide-text-type
2493 (if (search-forward "\n\n" nil t)
2497 ;; Hide the trailer as well
2498 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2500 (gnus-article-hide-text-type
2501 (match-beginning 0) (match-end 0) 'pem)))))))
2503 (defun article-strip-banner ()
2504 "Strip the banners specified by the `banner' group parameter and by
2505 `gnus-article-address-banner-alist'."
2509 (let ((inhibit-point-motion-hooks t))
2510 (when (gnus-parameter-banner gnus-newsgroup-name)
2511 (article-really-strip-banner
2512 (gnus-parameter-banner gnus-newsgroup-name)))
2513 (when gnus-article-address-banner-alist
2514 ;; It is necessary to encode from fields before checking,
2515 ;; because `mail-header-parse-addresses' does not work
2516 ;; (reliably) on decoded headers. And more, it is
2517 ;; impossible to use `gnus-fetch-original-field' here,
2518 ;; because `article-strip-banner' may be called in draft
2519 ;; buffers to preview them.
2520 (let ((from (save-restriction
2522 (article-narrow-to-head)
2523 (mail-fetch-field "from"))))
2526 (caar (mail-header-parse-addresses
2527 (mail-encode-encoded-word-string from)))))
2529 (dolist (pair gnus-article-address-banner-alist)
2530 (when (string-match (car pair) from)
2532 (article-really-strip-banner (cdr pair)))))))))))))
2534 (defun article-really-strip-banner (banner)
2535 "Strip the banner specified by the argument."
2538 (let ((inhibit-point-motion-hooks t)
2539 (gnus-signature-limit nil)
2540 (inhibit-read-only t))
2543 ((eq banner 'signature)
2544 (when (gnus-article-narrow-to-signature)
2547 (delete-region (point) (point-max))))
2549 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2550 (while (re-search-forward banner nil t)
2551 (delete-region (match-beginning 0) (match-end 0)))))
2553 (while (re-search-forward banner nil t)
2554 (delete-region (match-beginning 0) (match-end 0)))))))))
2556 (defun article-babel ()
2557 "Translate article using an online translation service."
2560 (gnus-with-article-buffer
2561 (when (article-goto-body)
2562 (let* ((start (point))
2564 (orig (buffer-substring start end))
2565 (trans (babel-as-string orig)))
2567 (narrow-to-region start end)
2568 (delete-region start end)
2571 (defun article-hide-signature (&optional arg)
2572 "Hide the signature in the current article.
2573 If given a negative prefix, always show; if given a positive prefix,
2575 (interactive (gnus-article-hidden-arg))
2576 (unless (gnus-article-check-hidden-text 'signature arg)
2579 (let ((inhibit-read-only t))
2580 (when (gnus-article-narrow-to-signature)
2581 (gnus-article-hide-text-type
2582 (point-min) (point-max) 'signature))))))
2583 (gnus-set-mode-line 'article))
2585 (defun article-strip-headers-in-body ()
2586 "Strip offensive headers from bodies."
2590 (let ((case-fold-search t))
2591 (when (looking-at "x-no-archive:")
2592 (gnus-delete-line)))))
2594 (defun article-strip-leading-blank-lines ()
2595 "Remove all blank lines from the beginning of the article."
2598 (let ((inhibit-point-motion-hooks t)
2599 (inhibit-read-only t))
2600 (when (article-goto-body)
2601 (while (and (not (eobp))
2602 (looking-at "[ \t]*$"))
2603 (gnus-delete-line))))))
2605 (defun article-narrow-to-head ()
2606 "Narrow the buffer to the head of the message.
2607 Point is left at the beginning of the narrowed-to region."
2609 (goto-char (point-min))
2610 (if (search-forward "\n\n" nil 1)
2613 (goto-char (point-min)))
2615 (defun article-goto-body ()
2616 "Place point at the start of the body."
2617 (goto-char (point-min))
2619 ;; This variable is only bound when dealing with separate
2621 (article-goto-body-goes-to-point-min-p
2623 ((search-forward "\n\n" nil t)
2626 (goto-char (point-max))
2629 (defun article-strip-multiple-blank-lines ()
2630 "Replace consecutive blank lines with one empty line."
2633 (let ((inhibit-point-motion-hooks t)
2634 (inhibit-read-only t))
2635 ;; First make all blank lines empty.
2637 (while (re-search-forward "^[ \t]+$" nil t)
2638 (unless (gnus-annotation-in-region-p
2639 (match-beginning 0) (match-end 0))
2640 (replace-match "" nil t)))
2641 ;; Then replace multiple empty lines with a single empty line.
2643 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2644 (unless (gnus-annotation-in-region-p
2645 (match-beginning 0) (match-end 0))
2646 (delete-region (match-beginning 1) (match-end 1)))))))
2648 (defun article-strip-leading-space ()
2649 "Remove all white space from the beginning of the lines in the article."
2652 (let ((inhibit-point-motion-hooks t)
2653 (inhibit-read-only t))
2655 (while (re-search-forward "^[ \t]+" nil t)
2656 (replace-match "" t t)))))
2658 (defun article-strip-trailing-space ()
2659 "Remove all white space from the end of the lines in the article."
2662 (let ((inhibit-point-motion-hooks t)
2663 (inhibit-read-only t))
2665 (while (re-search-forward "[ \t]+$" nil t)
2666 (replace-match "" t t)))))
2668 (defun article-strip-blank-lines ()
2669 "Strip leading, trailing and multiple blank lines."
2671 (article-strip-leading-blank-lines)
2672 (article-remove-trailing-blank-lines)
2673 (article-strip-multiple-blank-lines))
2675 (defun article-strip-all-blank-lines ()
2676 "Strip all blank lines."
2679 (let ((inhibit-point-motion-hooks t)
2680 (inhibit-read-only t))
2682 (while (re-search-forward "^[ \t]*\n" nil t)
2683 (replace-match "" t t)))))
2685 (defun gnus-article-narrow-to-signature ()
2686 "Narrow to the signature; return t if a signature is found, else nil."
2687 (let ((inhibit-point-motion-hooks t))
2688 (when (gnus-article-search-signature)
2690 ;; Check whether we have some limits to what we consider
2691 ;; to be a signature.
2692 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2693 (list gnus-signature-limit)))
2695 (while (setq limit (pop limits))
2696 (if (or (and (integerp limit)
2697 (< (- (point-max) (point)) limit))
2699 (< (count-lines (point) (point-max)) limit))
2700 (and (functionp limit)
2702 (and (stringp limit)
2703 (not (re-search-forward limit nil t))))
2704 () ; This limit did not succeed.
2708 (narrow-to-region (point) (point-max))
2711 (defun gnus-article-search-signature ()
2712 "Search the current buffer for the signature separator.
2713 Put point at the beginning of the signature separator."
2714 (let ((cur (point)))
2715 (goto-char (point-max))
2716 (if (if (stringp gnus-signature-separator)
2717 (re-search-backward gnus-signature-separator nil t)
2718 (let ((seps gnus-signature-separator))
2720 (not (re-search-backward (car seps) nil t)))
2727 (defun gnus-article-hidden-arg ()
2728 "Return the current prefix arg as a number, or 0 if no prefix."
2729 (list (if current-prefix-arg
2730 (prefix-numeric-value current-prefix-arg)
2733 (defun gnus-article-check-hidden-text (type arg)
2734 "Return nil if hiding is necessary.
2735 Arg can be nil or a number. nil and positive means hide, negative
2736 means show, 0 means toggle."
2739 (let ((hide (gnus-article-hidden-text-p type)))
2745 (gnus-article-show-hidden-text type)
2748 (if (eq hide 'hidden)
2750 (gnus-article-show-hidden-text type)
2754 (defun gnus-article-hidden-text-p (type)
2755 "Say whether the current buffer contains hidden text of type TYPE."
2756 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2758 (not (get-text-property pos 'invisible))
2759 (not (get-text-property pos 'dummy-invisible)))
2761 (text-property-any (1+ pos) (point-max) 'article-type type)))
2766 (defun gnus-article-show-hidden-text (type &optional dummy)
2767 "Show all hidden text of type TYPE.
2768 Originally it is hide instead of DUMMY."
2769 (let ((inhibit-read-only t)
2770 (inhibit-point-motion-hooks t))
2771 (gnus-remove-text-properties-when
2773 (point-min) (point-max)
2774 (cons 'article-type (cons type
2775 gnus-hidden-properties)))
2776 (gnus-delete-wash-type type)))
2778 (defconst article-time-units
2779 `((year . ,(* 365.25 24 60 60))
2780 (week . ,(* 7 24 60 60))
2781 (day . ,(* 24 60 60))
2785 "Mapping from time units to seconds.")
2787 (defun gnus-article-forward-header ()
2788 "Move point to the start of the next header.
2789 If the current header is a continuation header, this can be several
2794 (if (looking-at "[ \t]+[^ \t]")
2798 (defun article-date-ut (&optional type highlight header)
2799 "Convert DATE date to universal time in the current article.
2800 If TYPE is `local', convert to local time; if it is `lapsed', output
2801 how much time has lapsed since DATE. For `lapsed', the value of
2802 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2803 should replace the \"Date:\" one, or should be added below it."
2804 (interactive (list 'ut t))
2805 (let* ((header (or header
2806 (message-fetch-field "date")
2808 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2811 ((not gnus-article-date-lapsed-new-header)
2817 (date (if (vectorp header) (mail-header-date header)
2819 (inhibit-point-motion-hooks t)
2824 (article-narrow-to-head)
2825 (when (re-search-forward tdate-regexp nil t)
2826 (setq bface (get-text-property (point-at-bol) 'face)
2827 date (or (get-text-property (point-at-bol)
2830 eface (get-text-property (1- (point-at-eol)) 'face))
2832 (when (and date (not (string= date "")))
2833 (goto-char (point-min))
2834 (let ((inhibit-read-only t))
2835 ;; Delete any old Date headers.
2836 (while (re-search-forward date-regexp nil t)
2838 (delete-region (point-at-bol)
2839 (progn (gnus-article-forward-header)
2841 (delete-region (point-at-bol)
2842 (progn (gnus-article-forward-header)
2845 (setq pos (point))))
2846 (when (and (not pos)
2847 (re-search-forward tdate-regexp nil t))
2849 (gnus-goto-char pos)
2850 (insert (article-make-date-line date (or type 'ut)))
2856 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2857 (add-text-properties (match-beginning 1) (1+ (match-end 1))
2858 (list 'original-date date 'face bface))
2859 (put-text-property (match-beginning 2) (match-end 2)
2862 (defun article-make-date-line (date type)
2863 "Return a DATE line of TYPE."
2864 (unless (memq type '(local ut original user iso8601 lapsed english))
2865 (error "Unknown conversion type: %s" type))
2867 (let ((time (date-to-time date)))
2869 ;; Convert to the local timezone.
2871 (concat "Date: " (message-make-date time)))
2872 ;; Convert to Universal Time.
2877 (let* ((e (parse-time-string date))
2878 (tm (apply 'encode-time e))
2880 (ls (- (cadr tm) (car (current-time-zone time)))))
2881 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2882 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2886 ;; Get the original date from the article.
2887 ((eq type 'original)
2888 (concat "Date: " (if (string-match "\n+$" date)
2889 (substring date 0 (match-beginning 0))
2891 ;; Let the user define the format.
2893 (let ((format (or (condition-case nil
2894 (with-current-buffer gnus-summary-buffer
2895 gnus-article-time-format)
2897 gnus-article-time-format)))
2898 (if (functionp format)
2899 (funcall format time)
2900 (concat "Date: " (format-time-string format time)))))
2903 (let ((tz (car (current-time-zone time))))
2906 (format-time-string "%Y%m%dT%H%M%S" time)
2907 (format "%s%02d%02d"
2908 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2909 (/ (% (abs tz) 3600) 60)))))
2910 ;; Do an X-Sent lapsed format.
2912 ;; If the date is seriously mangled, the timezone functions are
2913 ;; liable to bug out, so we ignore all errors.
2914 (let* ((now (current-time))
2915 (real-time (subtract-time now time))
2916 (real-sec (and real-time
2917 (+ (* (float (car real-time)) 65536)
2919 (sec (and real-time (abs real-sec)))
2929 ;; This is a bit convoluted, but basically we go
2930 ;; through the time units for years, weeks, etc,
2931 ;; and divide things to see whether that results
2932 ;; in positive answers.
2935 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2936 ;; The (remaining) seconds are too few to
2937 ;; be divided into this time unit.
2939 ;; It's big enough, so we output it.
2940 (setq sec (- sec (* num (cdr unit))))
2942 (concat (if prev ", " "") (int-to-string
2944 " " (symbol-name (car unit))
2945 (if (> num 1) "s" ""))
2947 article-time-units "")
2948 ;; If dates are odd, then it might appear like the
2949 ;; article was sent in the future.
2952 " in the future"))))))
2953 ;; Display the date in proper English
2955 (let ((dtime (decode-time time)))
2958 (number-to-string (nth 3 dtime))
2959 (let ((digit (% (nth 3 dtime) 10)))
2961 ((memq (nth 3 dtime) '(11 12 13)) "th")
2967 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2969 (number-to-string (nth 5 dtime))
2971 (format "%02d" (nth 2 dtime))
2973 (format "%02d" (nth 1 dtime)))))))
2975 (format "Date: %s (from Gnus)" date))))
2977 (defun article-date-local (&optional highlight)
2978 "Convert the current article date to the local timezone."
2979 (interactive (list t))
2980 (article-date-ut 'local highlight))
2982 (defun article-date-english (&optional highlight)
2983 "Convert the current article date to something that is proper English."
2984 (interactive (list t))
2985 (article-date-ut 'english highlight))
2987 (defun article-date-original (&optional highlight)
2988 "Convert the current article date to what it was originally.
2989 This is only useful if you have used some other date conversion
2990 function and want to see what the date was before converting."
2991 (interactive (list t))
2992 (article-date-ut 'original highlight))
2994 (defun article-date-lapsed (&optional highlight)
2995 "Convert the current article date to time lapsed since it was sent."
2996 (interactive (list t))
2997 (article-date-ut 'lapsed highlight))
2999 (defun article-update-date-lapsed ()
3000 "Function to be run from a timer to update the lapsed time line."
3001 (let (deactivate-mark)
3006 (set-buffer (window-buffer w))
3007 (when (eq major-mode 'gnus-article-mode)
3008 (let ((mark (point-marker)))
3009 (goto-char (point-min))
3010 (when (re-search-forward "^X-Sent:" nil t)
3011 (article-date-lapsed t))
3012 (goto-char (marker-position mark))
3013 (move-marker mark nil))))
3016 (defun gnus-start-date-timer (&optional n)
3017 "Start a timer to update the X-Sent header in the article buffers.
3018 The numerical prefix says how frequently (in seconds) the function
3023 (gnus-stop-date-timer)
3024 (setq article-lapsed-timer
3025 (run-at-time 1 n 'article-update-date-lapsed)))
3027 (defun gnus-stop-date-timer ()
3028 "Stop the X-Sent timer."
3030 (when article-lapsed-timer
3031 (nnheader-cancel-timer article-lapsed-timer)
3032 (setq article-lapsed-timer nil)))
3034 (defun article-date-user (&optional highlight)
3035 "Convert the current article date to the user-defined format.
3036 This format is defined by the `gnus-article-time-format' variable."
3037 (interactive (list t))
3038 (article-date-ut 'user highlight))
3040 (defun article-date-iso8601 (&optional highlight)
3041 "Convert the current article date to ISO8601."
3042 (interactive (list t))
3043 (article-date-ut 'iso8601 highlight))
3045 ;; (defun article-show-all ()
3046 ;; "Show all hidden text in the article buffer."
3049 ;; (let ((inhibit-read-only t))
3050 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3052 (defun article-remove-leading-whitespace ()
3053 "Remove excessive whitespace from all headers."
3057 (let ((inhibit-read-only t))
3058 (article-narrow-to-head)
3059 (goto-char (point-min))
3060 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3061 (delete-region (match-beginning 1) (match-end 1)))))))
3063 (defun article-emphasize (&optional arg)
3064 "Emphasize text according to `gnus-emphasis-alist'."
3065 (interactive (gnus-article-hidden-arg))
3066 (unless (gnus-article-check-hidden-text 'emphasis arg)
3070 (with-current-buffer gnus-summary-buffer
3071 gnus-article-emphasis-alist)
3073 gnus-emphasis-alist))
3074 (inhibit-read-only t)
3075 (props (append '(article-type emphasis)
3076 gnus-hidden-properties))
3077 regexp elem beg invisible visible face)
3080 (while (setq elem (pop alist))
3082 (setq regexp (car elem)
3083 invisible (nth 1 elem)
3084 visible (nth 2 elem)
3086 (while (re-search-forward regexp nil t)
3087 (when (and (match-beginning visible) (match-beginning invisible))
3088 (gnus-article-hide-text
3089 (match-beginning invisible) (match-end invisible) props)
3090 (gnus-article-unhide-text-type
3091 (match-beginning visible) (match-end visible) 'emphasis)
3092 (gnus-put-overlay-excluding-newlines
3093 (match-beginning visible) (match-end visible) 'face face)
3094 (gnus-add-wash-type 'emphasis)
3095 (goto-char (match-end invisible)))))))))
3097 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3098 "Setup newsgroup emphasis alist."
3099 (unless gnus-article-emphasis-alist
3100 (let ((name (and gnus-newsgroup-name
3101 (gnus-group-real-name gnus-newsgroup-name))))
3102 (make-local-variable 'gnus-article-emphasis-alist)
3103 (setq gnus-article-emphasis-alist
3105 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3106 (while (setq elem (pop alist))
3107 (when (and name (string-match (car elem) name))
3109 highlight (copy-sequence (cdr elem)))))
3111 (copy-sequence highlight-words)
3112 (if gnus-newsgroup-name
3113 (copy-sequence (gnus-group-find-parameter
3114 gnus-newsgroup-name 'highlight-words t)))
3115 gnus-emphasis-alist)))))
3118 (defvar gnus-summary-article-menu)
3119 (defvar gnus-summary-post-menu))
3121 ;;; Saving functions.
3123 (defun gnus-article-save (save-buffer file &optional num)
3124 "Save the currently selected article."
3125 (unless gnus-save-all-headers
3126 ;; Remove headers according to `gnus-saved-headers'.
3127 (let ((gnus-visible-headers
3128 (or gnus-saved-headers gnus-visible-headers))
3129 (gnus-article-buffer save-buffer))
3131 (set-buffer save-buffer)
3132 (article-hide-headers 1 t))))
3133 (save-window-excursion
3134 (if (not gnus-default-article-saver)
3135 (error "No default saver is defined")
3136 ;; !!! Magic! The saving functions all save
3137 ;; `gnus-save-article-buffer' (or so they think), but we
3138 ;; bind that variable to our save-buffer.
3139 (set-buffer gnus-article-buffer)
3140 (let* ((gnus-save-article-buffer save-buffer)
3143 ((not gnus-prompt-before-saving) 'default)
3144 ((eq gnus-prompt-before-saving 'always) nil)
3146 (gnus-number-of-articles-to-be-saved
3147 (when (eq gnus-prompt-before-saving t)
3149 (set-buffer gnus-article-current-summary)
3150 (funcall gnus-default-article-saver filename)))))
3152 (defun gnus-read-save-file-name (prompt &optional filename
3153 function group headers variable)
3155 (funcall function group headers (symbol-value variable)))
3160 ((eq filename 'default)
3166 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3169 (if (and gnus-number-of-articles-to-be-saved
3170 (> gnus-number-of-articles-to-be-saved 1))
3171 (format "these %d articles"
3172 gnus-number-of-articles-to-be-saved)
3175 ;; Let the split methods have their say.
3177 ;; No split name was found.
3180 (concat prompt " (default "
3181 (file-name-nondirectory default-name) ") ")
3182 (file-name-directory default-name)
3184 ;; A single group name is returned.
3185 ((stringp split-name)
3187 (funcall function split-name headers
3188 (symbol-value variable)))
3190 (concat prompt " (default "
3191 (file-name-nondirectory default-name) ") ")
3192 (file-name-directory default-name)
3194 ;; A single split name was found
3195 ((= 1 (length split-name))
3196 (let* ((name (expand-file-name
3198 gnus-article-save-directory))
3199 (dir (cond ((file-directory-p name)
3200 (file-name-as-directory name))
3201 ((file-exists-p name) name)
3202 (t gnus-article-save-directory))))
3204 (concat prompt " (default " name ") ")
3206 ;; A list of splits was found.
3208 (setq split-name (nreverse split-name))
3210 (let ((file-name-history
3211 (nconc split-name file-name-history)))
3215 (concat prompt " (`M-p' for defaults) ")
3216 gnus-article-save-directory
3218 gnus-article-save-directory)))
3219 (car (push result file-name-history)))))))
3220 ;; Create the directory.
3221 (gnus-make-directory (file-name-directory file))
3222 ;; If we have read a directory, we append the default file name.
3223 (when (file-directory-p file)
3224 (setq file (expand-file-name (file-name-nondirectory
3226 (file-name-as-directory file))))
3227 ;; Possibly translate some characters.
3228 (nnheader-translate-file-chars file))))))
3229 (gnus-make-directory (file-name-directory result))
3230 (set variable result)))
3232 (defun gnus-article-archive-name (group)
3233 "Return the first instance of an \"Archive-name\" in the current buffer."
3234 (let ((case-fold-search t))
3235 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3236 (nnheader-concat gnus-article-save-directory
3237 (match-string 1)))))
3239 (defun gnus-article-nndoc-name (group)
3240 "If GROUP is an nndoc group, return the name of the parent group."
3241 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3242 (gnus-group-get-parameter group 'save-article-group)))
3244 (defun gnus-summary-save-in-rmail (&optional filename)
3245 "Append this article to Rmail file.
3246 Optional argument FILENAME specifies file name.
3247 Directory to save to is default to `gnus-article-save-directory'."
3248 (setq filename (gnus-read-save-file-name
3249 "Save %s in rmail file:" filename
3250 gnus-rmail-save-name gnus-newsgroup-name
3251 gnus-current-headers 'gnus-newsgroup-last-rmail))
3252 (gnus-eval-in-buffer-window gnus-save-article-buffer
3256 (gnus-output-to-rmail filename))))
3259 (defun gnus-summary-save-in-mail (&optional filename)
3260 "Append this article to Unix mail file.
3261 Optional argument FILENAME specifies file name.
3262 Directory to save to is default to `gnus-article-save-directory'."
3263 (setq filename (gnus-read-save-file-name
3264 "Save %s in Unix mail file:" filename
3265 gnus-mail-save-name gnus-newsgroup-name
3266 gnus-current-headers 'gnus-newsgroup-last-mail))
3267 (gnus-eval-in-buffer-window gnus-save-article-buffer
3271 (if (and (file-readable-p filename)
3272 (file-regular-p filename)
3273 (mail-file-babyl-p filename))
3274 (rmail-output-to-rmail-file filename t)
3275 (gnus-output-to-mail filename)))))
3278 (defun gnus-summary-save-in-file (&optional filename overwrite)
3279 "Append this article to file.
3280 Optional argument FILENAME specifies file name.
3281 Directory to save to is default to `gnus-article-save-directory'."
3282 (setq filename (gnus-read-save-file-name
3283 "Save %s in file:" filename
3284 gnus-file-save-name gnus-newsgroup-name
3285 gnus-current-headers 'gnus-newsgroup-last-file))
3286 (gnus-eval-in-buffer-window gnus-save-article-buffer
3290 (when (and overwrite
3291 (file-exists-p filename))
3292 (delete-file filename))
3293 (gnus-output-to-file filename))))
3296 (defun gnus-summary-write-to-file (&optional filename)
3297 "Write this article to a file, overwriting it if the file exists.
3298 Optional argument FILENAME specifies file name.
3299 The directory to save in defaults to `gnus-article-save-directory'."
3300 (gnus-summary-save-in-file nil t))
3302 (defun gnus-summary-save-body-in-file (&optional filename)
3303 "Append this article body to a file.
3304 Optional argument FILENAME specifies file name.
3305 The directory to save in defaults to `gnus-article-save-directory'."
3306 (setq filename (gnus-read-save-file-name
3307 "Save %s body in file:" filename
3308 gnus-file-save-name gnus-newsgroup-name
3309 gnus-current-headers 'gnus-newsgroup-last-file))
3310 (gnus-eval-in-buffer-window gnus-save-article-buffer
3314 (when (article-goto-body)
3315 (narrow-to-region (point) (point-max)))
3316 (gnus-output-to-file filename))))
3319 (defun gnus-summary-save-in-pipe (&optional command)
3320 "Pipe this article to subprocess."
3322 (cond ((and (eq command 'default)
3323 gnus-last-shell-command)
3324 gnus-last-shell-command)
3329 "Shell command on %s: "
3330 (if (and gnus-number-of-articles-to-be-saved
3331 (> gnus-number-of-articles-to-be-saved 1))
3332 (format "these %d articles"
3333 gnus-number-of-articles-to-be-saved)
3335 gnus-last-shell-command))))
3336 (when (string-equal command "")
3337 (if gnus-last-shell-command
3338 (setq command gnus-last-shell-command)
3339 (error "A command is required")))
3340 (gnus-eval-in-buffer-window gnus-article-buffer
3343 (shell-command-on-region (point-min) (point-max) command nil)))
3344 (setq gnus-last-shell-command command))
3346 (defun gnus-summary-pipe-to-muttprint (&optional command)
3347 "Pipe this article to muttprint."
3348 (setq command (read-string
3349 "Print using command: " gnus-summary-muttprint-program
3350 nil gnus-summary-muttprint-program))
3351 (gnus-summary-save-in-pipe command))
3353 ;;; Article file names when saving.
3355 (defun gnus-capitalize-newsgroup (newsgroup)
3356 "Capitalize NEWSGROUP name."
3357 (when (not (zerop (length newsgroup)))
3358 (concat (char-to-string (upcase (aref newsgroup 0)))
3359 (substring newsgroup 1))))
3361 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3362 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3363 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3364 Otherwise, it is like ~/News/news/group/num."
3367 (concat (if (gnus-use-long-file-name 'not-save)
3368 (gnus-capitalize-newsgroup newsgroup)
3369 (gnus-newsgroup-directory-form newsgroup))
3370 "/" (int-to-string (mail-header-number headers)))
3371 gnus-article-save-directory)))
3373 (string-equal (file-name-directory default)
3374 (file-name-directory last-file))
3375 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3377 (or last-file default))))
3379 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3380 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3381 If variable `gnus-use-long-file-name' is non-nil, it is
3382 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3385 (concat (if (gnus-use-long-file-name 'not-save)
3387 (gnus-newsgroup-directory-form newsgroup))
3388 "/" (int-to-string (mail-header-number headers)))
3389 gnus-article-save-directory)))
3391 (string-equal (file-name-directory default)
3392 (file-name-directory last-file))
3393 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3395 (or last-file default))))
3397 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3398 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3399 If variable `gnus-use-long-file-name' is non-nil, it is
3400 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3403 (if (gnus-use-long-file-name 'not-save)
3406 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3408 gnus-article-save-directory)))
3410 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3411 "Generate file name from sender."
3412 (let ((from (mail-header-from headers)))
3414 (if (and from (string-match "\\([^ <]+\\)@" from))
3415 (match-string 1 from)
3417 gnus-article-save-directory)))
3419 (defun article-verify-x-pgp-sig ()
3422 (if (gnus-buffer-live-p gnus-original-article-buffer)
3423 (let ((sig (with-current-buffer gnus-original-article-buffer
3424 (gnus-fetch-field "X-PGP-Sig")))
3428 (mml2015-clear-verify-function))
3430 (insert-buffer-substring gnus-original-article-buffer)
3431 (setq items (split-string sig))
3432 (message-narrow-to-head)
3433 (let ((inhibit-point-motion-hooks t)
3434 (case-fold-search t))
3435 ;; Don't verify multiple headers.
3436 (setq headers (mapconcat (lambda (header)
3438 (mail-fetch-field header)
3440 (split-string (nth 1 items) ",") "")))
3441 (delete-region (point-min) (point-max))
3442 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3443 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3448 (if (looking-at "^-")
3451 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3452 (insert "Version: " (car items) "\n\n")
3453 (insert (mapconcat 'identity (cddr items) "\n"))
3454 (insert "\n-----END PGP SIGNATURE-----\n")
3455 (let ((mm-security-handle (list (format "multipart/signed"))))
3456 (mml2015-clean-buffer)
3457 (let ((coding-system-for-write (or gnus-newsgroup-charset
3459 (funcall (mml2015-clear-verify-function)))
3461 (or (mm-handle-multipart-ctl-parameter
3462 mm-security-handle 'gnus-details)
3463 (mm-handle-multipart-ctl-parameter
3464 mm-security-handle 'gnus-info)))))
3466 (let ((inhibit-read-only t) bface eface)
3468 (message-narrow-to-head)
3469 (goto-char (point-max))
3471 (setq bface (get-text-property (point-at-bol) 'face)
3472 eface (get-text-property (1- (point-at-eol)) 'face))
3473 (message-remove-header "X-Gnus-PGP-Verify")
3474 (if (re-search-forward "^X-PGP-Sig:" nil t)
3476 (goto-char (point-max)))
3477 (narrow-to-region (point) (point))
3478 (insert "X-Gnus-PGP-Verify: " info "\n")
3479 (goto-char (point-min))
3482 (if (not (looking-at "^[ \t]"))
3486 (goto-char (point-min))
3487 (when (looking-at "\\([^:]+\\): *")
3488 (put-text-property (match-beginning 1) (1+ (match-end 1))
3490 (put-text-property (match-end 0) (point-max)
3491 'face eface)))))))))
3493 (defun article-verify-cancel-lock ()
3494 "Verify Cancel-Lock header."
3496 (if (gnus-buffer-live-p gnus-original-article-buffer)
3497 (canlock-verify gnus-original-article-buffer)))
3504 (setq afunc (car func)
3507 gfunc (intern (format "gnus-%s" func))))
3509 (when (fboundp afunc)
3510 `(lambda (&optional interactive &rest args)
3511 ,(documentation afunc t)
3512 (interactive (list t))
3514 (set-buffer gnus-article-buffer)
3516 (call-interactively ',afunc)
3517 (apply ',afunc args))))))))
3518 '(article-hide-headers
3519 article-verify-x-pgp-sig
3520 article-verify-cancel-lock
3521 article-hide-boring-headers
3522 article-treat-overstrike
3523 article-treat-ansi-sequences
3524 article-fill-long-lines
3525 article-capitalize-sentences
3527 article-remove-leading-whitespace
3528 article-display-x-face
3529 article-display-face
3530 article-de-quoted-unreadable
3531 article-de-base64-unreadable
3534 article-unsplit-urls
3535 article-hide-list-identifiers
3536 article-strip-banner
3539 article-hide-signature
3540 article-strip-headers-in-body
3541 article-remove-trailing-blank-lines
3542 article-strip-leading-blank-lines
3543 article-strip-multiple-blank-lines
3544 article-strip-leading-space
3545 article-strip-trailing-space
3546 article-strip-blank-lines
3547 article-strip-all-blank-lines
3549 article-date-english
3550 article-date-iso8601
3551 article-date-original
3553 article-decode-mime-words
3554 article-decode-charset
3555 article-decode-encoded-words
3559 article-treat-dumbquotes
3560 article-normalize-headers
3561 ;; (article-show-all . gnus-article-show-all-headers)
3565 ;;; Gnus article mode
3568 (put 'gnus-article-mode 'mode-class 'special)
3570 (set-keymap-parent gnus-article-mode-map widget-keymap)
3572 (gnus-define-keys gnus-article-mode-map
3573 " " gnus-article-goto-next-page
3574 "\177" gnus-article-goto-prev-page
3575 [delete] gnus-article-goto-prev-page
3576 [backspace] gnus-article-goto-prev-page
3577 "\C-c^" gnus-article-refer-article
3578 "h" gnus-article-show-summary
3579 "s" gnus-article-show-summary
3580 "\C-c\C-m" gnus-article-mail
3581 "?" gnus-article-describe-briefly
3582 "e" gnus-summary-edit-article
3583 "<" beginning-of-buffer
3585 "\C-c\C-i" gnus-info-find-node
3587 "R" gnus-article-reply-with-original
3588 "F" gnus-article-followup-with-original
3589 "\C-hk" gnus-article-describe-key
3590 "\C-hc" gnus-article-describe-key-briefly
3592 "\C-d" gnus-article-read-summary-keys
3593 "\M-*" gnus-article-read-summary-keys
3594 "\M-#" gnus-article-read-summary-keys
3595 "\M-^" gnus-article-read-summary-keys
3596 "\M-g" gnus-article-read-summary-keys)
3598 (substitute-key-definition
3599 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3601 (defun gnus-article-make-menu-bar ()
3602 (unless (boundp 'gnus-article-commands-menu)
3603 (gnus-summary-make-menu-bar))
3604 (gnus-turn-off-edit-menu 'article)
3605 (unless (boundp 'gnus-article-article-menu)
3607 gnus-article-article-menu gnus-article-mode-map ""
3609 ["Scroll forwards" gnus-article-goto-next-page t]
3610 ["Scroll backwards" gnus-article-goto-prev-page t]
3611 ["Show summary" gnus-article-show-summary t]
3612 ["Fetch Message-ID at point" gnus-article-refer-article t]
3613 ["Mail to address at point" gnus-article-mail t]
3614 ["Send a bug report" gnus-bug t]))
3617 gnus-article-treatment-menu gnus-article-mode-map ""
3618 ;; Fixme: this should use :active (and maybe :visible).
3620 ["Hide headers" gnus-article-hide-headers t]
3621 ["Hide signature" gnus-article-hide-signature t]
3622 ["Hide citation" gnus-article-hide-citation t]
3623 ["Treat overstrike" gnus-article-treat-overstrike t]
3624 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3625 ["Remove carriage return" gnus-article-remove-cr t]
3626 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3627 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3628 ["Remove base64" gnus-article-de-base64-unreadable t]
3629 ["Treat html" gnus-article-wash-html t]
3630 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3631 ["Decode HZ" gnus-article-decode-HZ t]))
3633 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3635 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3637 (gnus-run-hooks 'gnus-article-menu-hook)))
3639 (defun gnus-article-mode ()
3640 "Major mode for displaying an article.
3642 All normal editing commands are switched off.
3644 The following commands are available in addition to all summary mode
3646 \\<gnus-article-mode-map>
3647 \\[gnus-article-next-page]\t Scroll the article one page forwards
3648 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3649 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3650 \\[gnus-article-show-summary]\t Display the summary buffer
3651 \\[gnus-article-mail]\t Send a reply to the address near point
3652 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3653 \\[gnus-info-find-node]\t Go to the Gnus info node"
3655 (gnus-simplify-mode-line)
3656 (setq mode-name "Article")
3657 (setq major-mode 'gnus-article-mode)
3658 (make-local-variable 'minor-mode-alist)
3659 (use-local-map gnus-article-mode-map)
3660 (when (gnus-visual-p 'article-menu 'menu)
3661 (gnus-article-make-menu-bar)
3662 (when gnus-summary-tool-bar-map
3663 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3664 (gnus-update-format-specifications nil 'article-mode)
3665 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3666 (set (make-local-variable 'gnus-page-broken) nil)
3667 (make-local-variable 'gnus-button-marker-list)
3668 (make-local-variable 'gnus-article-current-summary)
3669 (make-local-variable 'gnus-article-mime-handles)
3670 (make-local-variable 'gnus-article-decoded-p)
3671 (make-local-variable 'gnus-article-mime-handle-alist)
3672 (make-local-variable 'gnus-article-wash-types)
3673 (make-local-variable 'gnus-article-image-alist)
3674 (make-local-variable 'gnus-article-charset)
3675 (make-local-variable 'gnus-article-ignored-charsets)
3676 (gnus-set-default-directory)
3677 (buffer-disable-undo)
3678 (setq buffer-read-only t
3679 show-trailing-whitespace nil)
3680 (set-syntax-table gnus-article-mode-syntax-table)
3681 (mm-enable-multibyte)
3682 (gnus-run-hooks 'gnus-article-mode-hook))
3684 (defun gnus-article-setup-buffer ()
3685 "Initialize the article buffer."
3686 (let* ((name (if gnus-single-article-buffer "*Article*"
3687 (concat "*Article " gnus-newsgroup-name "*")))
3689 (progn (string-match "\\*Article" name)
3690 (concat " *Original Article"
3691 (substring name (match-end 0))))))
3692 (setq gnus-article-buffer name)
3693 (setq gnus-original-article-buffer original)
3694 (setq gnus-article-mime-handle-alist nil)
3695 ;; This might be a variable local to the summary buffer.
3696 (unless gnus-single-article-buffer
3698 (set-buffer gnus-summary-buffer)
3699 (setq gnus-article-buffer name)
3700 (setq gnus-original-article-buffer original)
3701 (gnus-set-global-variables)))
3702 (gnus-article-setup-highlight-words)
3703 ;; Init original article buffer.
3705 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3706 (mm-enable-multibyte)
3707 (setq major-mode 'gnus-original-article-mode)
3708 (make-local-variable 'gnus-original-article))
3709 (if (get-buffer name)
3712 (when (and gnus-article-edit-mode
3715 (y-or-n-p "Article mode edit in progress; discard? ")))
3716 (error "Action aborted"))
3717 (set (make-local-variable 'gnus-article-edit-mode) nil)
3718 (when gnus-article-mime-handles
3719 (mm-destroy-parts gnus-article-mime-handles)
3720 (setq gnus-article-mime-handles nil))
3721 ;; Set it to nil in article-buffer!
3722 (setq gnus-article-mime-handle-alist nil)
3723 (buffer-disable-undo)
3724 (setq buffer-read-only t)
3725 ;; This list just keeps growing if we don't reset it.
3726 (setq gnus-button-marker-list nil)
3727 (unless (eq major-mode 'gnus-article-mode)
3728 (gnus-article-mode))
3731 (set-buffer (gnus-get-buffer-create name))
3733 (make-local-variable 'gnus-summary-buffer)
3734 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3735 (current-buffer)))))
3737 ;; Set article window start at LINE, where LINE is the number of lines
3738 ;; from the head of the article.
3739 (defun gnus-article-set-window-start (&optional line)
3741 (gnus-get-buffer-window gnus-article-buffer t)
3743 (set-buffer gnus-article-buffer)
3744 (goto-char (point-min))
3747 (gnus-message 6 "Moved to bookmark")
3748 (search-forward "\n\n" nil t)
3752 (defun gnus-article-prepare (article &optional all-headers header)
3753 "Prepare ARTICLE in article mode buffer.
3754 ARTICLE should either be an article number or a Message-ID.
3755 If ARTICLE is an id, HEADER should be the article headers.
3756 If ALL-HEADERS is non-nil, no headers are hidden."
3758 ;; Make sure we start in a summary buffer.
3759 (unless (eq major-mode 'gnus-summary-mode)
3760 (set-buffer gnus-summary-buffer))
3761 (setq gnus-summary-buffer (current-buffer))
3762 (let* ((gnus-article (if header (mail-header-number header) article))
3763 (summary-buffer (current-buffer))
3764 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3765 (group gnus-newsgroup-name)
3768 (gnus-article-setup-buffer)
3769 (set-buffer gnus-article-buffer)
3770 ;; Deactivate active regions.
3771 (when (and (boundp 'transient-mark-mode)
3772 transient-mark-mode)
3773 (setq mark-active nil))
3774 (if (not (setq result (let ((inhibit-read-only t))
3775 (gnus-request-article-this-buffer
3777 ;; There is no such article.
3779 (when (and (numberp article)
3780 (not (memq article gnus-newsgroup-sparse)))
3781 (setq gnus-article-current
3782 (cons gnus-newsgroup-name article))
3783 (set-buffer gnus-summary-buffer)
3784 (setq gnus-current-article article)
3785 (if (and (memq article gnus-newsgroup-undownloaded)
3786 (not (gnus-online (gnus-find-method-for-group
3787 gnus-newsgroup-name))))
3789 (gnus-summary-set-agent-mark article)
3790 (message "Message marked for downloading"))
3791 (gnus-summary-mark-article article gnus-canceled-mark)
3792 (unless (memq article gnus-newsgroup-sparse)
3793 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3794 (if (or (eq result 'pseudo)
3795 (eq result 'nneething))
3798 (set-buffer summary-buffer)
3799 (push article gnus-newsgroup-history)
3800 (setq gnus-last-article gnus-current-article
3801 gnus-current-article 0
3802 gnus-current-headers nil
3803 gnus-article-current nil)
3804 (if (eq result 'nneething)
3805 (gnus-configure-windows 'summary)
3806 (gnus-configure-windows 'article))
3807 (gnus-set-global-variables))
3808 (let ((gnus-article-mime-handle-alist-1
3809 gnus-article-mime-handle-alist))
3810 (gnus-set-mode-line 'article)))
3811 ;; The result from the `request' was an actual article -
3812 ;; or at least some text that is now displayed in the
3814 (when (and (numberp article)
3815 (not (eq article gnus-current-article)))
3816 ;; Seems like a new article has been selected.
3817 ;; `gnus-current-article' must be an article number.
3819 (set-buffer summary-buffer)
3820 (push article gnus-newsgroup-history)
3821 (setq gnus-last-article gnus-current-article
3822 gnus-current-article article
3823 gnus-current-headers
3824 (gnus-summary-article-header gnus-current-article)
3825 gnus-article-current
3826 (cons gnus-newsgroup-name gnus-current-article))
3827 (unless (vectorp gnus-current-headers)
3828 (setq gnus-current-headers nil))
3829 (gnus-summary-goto-subject gnus-current-article)
3830 (when (gnus-summary-show-thread)
3831 ;; If the summary buffer really was folded, the
3832 ;; previous goto may not actually have gone to
3833 ;; the right article, but the thread root instead.
3835 (gnus-summary-goto-subject gnus-current-article))
3836 (gnus-run-hooks 'gnus-mark-article-hook)
3837 (gnus-set-mode-line 'summary)
3838 (when (gnus-visual-p 'article-highlight 'highlight)
3839 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3840 ;; Set the global newsgroup variables here.
3841 (gnus-set-global-variables)
3842 (setq gnus-have-all-headers
3843 (or all-headers gnus-show-all-headers))))
3845 (gnus-configure-windows 'article))
3846 (when (or (numberp article)
3848 (gnus-article-prepare-display)
3850 (goto-char (point-min))
3851 (when gnus-break-pages
3852 (gnus-narrow-to-page)))
3853 (let ((gnus-article-mime-handle-alist-1
3854 gnus-article-mime-handle-alist))
3855 (gnus-set-mode-line 'article))
3859 (set-window-point (get-buffer-window (current-buffer)) (point))
3860 (gnus-configure-windows 'article)
3864 (defun gnus-article-prepare-display ()
3865 "Make the current buffer look like a nice article."
3866 ;; Hooks for getting information from the article.
3867 ;; This hook must be called before being narrowed.
3868 (let ((gnus-article-buffer (current-buffer))
3870 (inhibit-read-only t))
3871 (unless (eq major-mode 'gnus-article-mode)
3872 (gnus-article-mode))
3873 (setq buffer-read-only nil
3874 gnus-article-wash-types nil
3875 gnus-article-image-alist nil)
3876 (gnus-run-hooks 'gnus-tmp-internal-hook)
3877 (when gnus-display-mime-function
3878 (funcall gnus-display-mime-function))
3879 (gnus-run-hooks 'gnus-article-prepare-hook)))
3882 ;;; Gnus MIME viewing functions
3885 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3886 "Format of the MIME buttons.
3888 Valid specifiers include:
3890 %T MIME type, along with additional info
3891 %n The `name' parameter
3892 %d The description, if any
3893 %l The length of the encoded part
3894 %p The part identifier number
3895 %e Dots if the part isn't displayed
3897 General format specifiers can also be used. See Info node
3898 `(gnus)Formatting Variables'.")
3900 (defvar gnus-mime-button-line-format-alist
3901 '((?t gnus-tmp-type ?s)
3902 (?T gnus-tmp-type-long ?s)
3903 (?n gnus-tmp-name ?s)
3904 (?d gnus-tmp-description ?s)
3906 (?l gnus-tmp-length ?d)
3907 (?e gnus-tmp-dots ?s)))
3909 (defvar gnus-mime-button-commands
3910 '((gnus-article-press-button "\r" "Toggle Display")
3911 (gnus-mime-view-part "v" "View Interactively...")
3912 (gnus-mime-view-part-as-type "t" "View As Type...")
3913 (gnus-mime-view-part-as-charset "C" "View As charset...")
3914 (gnus-mime-save-part "o" "Save...")
3915 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3916 (gnus-mime-delete-part "d" "Delete part")
3917 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3918 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3919 (gnus-mime-view-part-internally "E" "View Internally")
3920 (gnus-mime-view-part-externally "e" "View Externally")
3921 (gnus-mime-print-part "p" "Print")
3922 (gnus-mime-pipe-part "|" "Pipe To Command...")
3923 (gnus-mime-action-on-part "." "Take action on the part...")))
3925 (defun gnus-article-mime-part-status ()
3926 (if gnus-article-mime-handle-alist-1
3927 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3929 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3932 (defvar gnus-mime-button-map
3933 (let ((map (make-sparse-keymap)))
3934 (define-key map gnus-mouse-2 'gnus-article-push-button)
3935 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3936 (dolist (c gnus-mime-button-commands)
3937 (define-key map (cadr c) (car c)))
3941 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3943 ,@(mapcar (lambda (c)
3944 (vector (caddr c) (car c) :enable t))
3945 gnus-mime-button-commands)))
3947 (defun gnus-mime-button-menu (event prefix)
3948 "Construct a context-sensitive menu of MIME commands."
3949 (interactive "e\nP")
3950 (save-window-excursion
3951 (let ((pos (event-start event)))
3952 (select-window (posn-window pos))
3953 (goto-char (posn-point pos))
3954 (gnus-article-check-buffer)
3955 (popup-menu gnus-mime-button-menu nil prefix))))
3957 (defun gnus-mime-view-all-parts (&optional handles)
3958 "View all the MIME parts."
3960 (with-current-buffer gnus-article-buffer
3961 (let ((handles (or handles gnus-article-mime-handles))
3962 (mail-parse-charset gnus-newsgroup-charset)
3963 (mail-parse-ignored-charsets
3964 (with-current-buffer gnus-summary-buffer
3965 gnus-newsgroup-ignored-charsets)))
3967 (mm-remove-parts handles)
3968 (goto-char (point-min))
3969 (or (search-forward "\n\n") (goto-char (point-max)))
3970 (let ((inhibit-read-only t))
3971 (delete-region (point) (point-max))
3972 (mm-display-parts handles))))))
3975 (defsubst gnus-article-edit-part (handles)
3976 "Edit an article in order to delete a mime part.
3977 This function is exclusively used by `gnus-mime-save-part-and-strip'
3978 and `gnus-mime-delete-part', and not provided at run-time normally."
3979 (gnus-article-edit-article
3982 (let ((mail-parse-charset (or gnus-article-charset
3983 ',gnus-newsgroup-charset))
3984 (mail-parse-ignored-charsets
3985 (or gnus-article-ignored-charsets
3986 ',gnus-newsgroup-ignored-charsets))
3987 (mbl mml-buffer-list))
3988 (setq mml-buffer-list nil)
3989 (insert-buffer gnus-original-article-buffer)
3990 (mime-to-mml ',handles)
3991 (setq gnus-article-mime-handles nil)
3992 (let ((mbl1 mml-buffer-list))
3993 (setq mml-buffer-list mbl)
3994 (set (make-local-variable 'mml-buffer-list) mbl1))
3995 (gnus-make-local-hook 'kill-buffer-hook)
3996 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3997 `(lambda (no-highlight)
3998 (let ((mail-parse-charset (or gnus-article-charset
3999 ',gnus-newsgroup-charset))
4000 (message-options message-options)
4001 (message-options-set-recipient)
4002 (mail-parse-ignored-charsets
4003 (or gnus-article-ignored-charsets
4004 ',gnus-newsgroup-ignored-charsets)))
4006 (mml-destroy-buffers)
4007 (remove-hook 'kill-buffer-hook
4008 'mml-destroy-buffers t)
4009 (kill-local-variable 'mml-buffer-list))
4010 (gnus-summary-edit-article-done
4011 ,(or (mail-header-references gnus-current-headers) "")
4012 ,(gnus-group-read-only-p)
4013 ,gnus-summary-buffer no-highlight)))
4014 (gnus-article-edit-done)
4015 (gnus-summary-expand-window)
4016 (gnus-summary-show-article)))
4018 (defun gnus-mime-save-part-and-strip ()
4019 "Save the MIME part under point then replace it with an external body."
4021 (gnus-article-check-buffer)
4022 (when (gnus-group-read-only-p)
4023 (error "The current group does not support deleting of parts"))
4024 (when (mm-complicated-handles gnus-article-mime-handles)
4026 The current article has a complicated MIME structure, giving up..."))
4027 (when (gnus-yes-or-no-p "\
4028 Deleting parts may malfunction or destroy the article; continue? ")
4029 (let* ((data (get-text-property (point) 'gnus-data))
4031 (handles gnus-article-mime-handles))
4032 (setq file (and data (mm-save-part data)))
4034 (with-current-buffer (mm-handle-buffer data)
4036 (insert "Content-Type: " (mm-handle-media-type data))
4037 (mml-insert-parameter-string (cdr (mm-handle-type data))
4040 (insert "Content-ID: " (message-make-message-id) "\n")
4041 (insert "Content-Transfer-Encoding: binary\n")
4044 (cdr (mm-make-handle nil
4045 `("message/external-body"
4046 (access-type . "LOCAL-FILE")
4048 (set-buffer gnus-summary-buffer)
4049 (gnus-article-edit-part handles)))))
4051 (defun gnus-mime-delete-part ()
4052 "Delete the MIME part under point.
4053 Replace it with some information about the removed part."
4055 (gnus-article-check-buffer)
4056 (when (gnus-group-read-only-p)
4057 (error "The current group does not support deleting of parts"))
4058 (when (mm-complicated-handles gnus-article-mime-handles)
4060 The current article has a complicated MIME structure, giving up..."))
4061 (when (gnus-yes-or-no-p "\
4062 Deleting parts may malfunction or destroy the article; continue? ")
4063 (let* ((data (get-text-property (point) 'gnus-data))
4064 (handles gnus-article-mime-handles)
4068 (mail-decode-encoded-word-string (or (mm-handle-description data)
4071 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4073 (type (mm-handle-media-type data)))
4075 (error "No MIME part under point"))
4076 (with-current-buffer (mm-handle-buffer data)
4077 (let ((bsize (format "%s" (buffer-size))))
4082 "| The following attachment has been deleted:\n"
4084 "| Type: " type "\n"
4085 "| Filename: " filename "\n"
4086 "| Size (encoded): " bsize " Byte\n"
4087 "| Description: " description "\n"
4090 (cdr (mm-make-handle
4091 nil `("text/plain") nil nil
4093 (format "Deleted attachment (%s bytes)" bsize))))))
4094 (set-buffer gnus-summary-buffer)
4095 (gnus-article-edit-part handles))))
4097 (defun gnus-mime-save-part ()
4098 "Save the MIME part under point."
4100 (gnus-article-check-buffer)
4101 (let ((data (get-text-property (point) 'gnus-data)))
4103 (mm-save-part data))))
4105 (defun gnus-mime-pipe-part ()
4106 "Pipe the MIME part under point to a process."
4108 (gnus-article-check-buffer)
4109 (let ((data (get-text-property (point) 'gnus-data)))
4111 (mm-pipe-part data))))
4113 (defun gnus-mime-view-part ()
4114 "Interactively choose a viewing method for the MIME part under point."
4116 (gnus-article-check-buffer)
4117 (let ((data (get-text-property (point) 'gnus-data)))
4119 (setq gnus-article-mime-handles
4121 gnus-article-mime-handles (setq data (copy-sequence data))))
4122 (mm-interactively-view-part data))))
4124 (defun gnus-mime-view-part-as-type-internal ()
4125 (gnus-article-check-buffer)
4126 (let* ((name (mail-content-type-get
4127 (mm-handle-type (get-text-property (point) 'gnus-data))
4129 (def-type (and name (mm-default-file-encoding name))))
4130 (and def-type (cons def-type 0))))
4132 (defun gnus-mime-view-part-as-type (&optional mime-type)
4133 "Choose a MIME media type, and view the part as such."
4136 (setq mime-type (completing-read
4137 "View as MIME type: "
4138 (mapcar #'list (mailcap-mime-types))
4140 (gnus-mime-view-part-as-type-internal))))
4141 (gnus-article-check-buffer)
4142 (let ((handle (get-text-property (point) 'gnus-data)))
4145 (mm-make-handle (mm-handle-buffer handle)
4146 (cons mime-type (cdr (mm-handle-type handle)))
4147 (mm-handle-encoding handle)
4148 (mm-handle-undisplayer handle)
4149 (mm-handle-disposition handle)
4150 (mm-handle-description handle)
4152 (mm-handle-id handle)))
4153 (setq gnus-article-mime-handles
4154 (mm-merge-handles gnus-article-mime-handles handle))
4155 (gnus-mm-display-part handle))))
4158 (require 'jka-compr))
4160 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4161 ;; emacs can do that itself.
4163 (defun gnus-mime-jka-compr-maybe-uncompress ()
4164 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4165 The uncompress method used is derived from `buffer-file-name'."
4166 (when (and (fboundp 'jka-compr-installed-p)
4167 (jka-compr-installed-p))
4168 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4170 (let ((basename (file-name-nondirectory buffer-file-name))
4171 (args (jka-compr-info-uncompress-args info))
4172 (prog (jka-compr-info-uncompress-program info))
4173 (message (jka-compr-info-uncompress-message info))
4174 (err-file (jka-compr-make-temp-name)))
4176 (message "%s %s..." message basename))
4178 (unless (memq (apply 'call-process-region
4179 (point-min) (point-max)
4181 t (list t err-file) nil
4183 jka-compr-acceptable-retval-list)
4184 (jka-compr-error prog args basename message err-file))
4185 (jka-compr-delete-temp-file err-file)))))))
4187 (defun gnus-mime-copy-part (&optional handle)
4188 "Put the MIME part under point into a new buffer.
4189 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4192 (gnus-article-check-buffer)
4193 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4194 (contents (and handle (mm-get-part handle)))
4196 (file-name-nondirectory
4198 (mail-content-type-get (mm-handle-type handle) 'name)
4199 (mail-content-type-get (mm-handle-disposition handle)
4202 (buffer (and base (generate-new-buffer base))))
4204 (switch-to-buffer buffer)
4206 ;; We do it this way to make `normal-mode' set the appropriate mode.
4209 (setq buffer-file-name (expand-file-name base))
4210 (gnus-mime-jka-compr-maybe-uncompress)
4212 (setq buffer-file-name nil))
4213 (goto-char (point-min)))))
4215 (defun gnus-mime-print-part (&optional handle filename)
4216 "Print the MIME part under point."
4217 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4218 (gnus-article-check-buffer)
4219 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4220 (contents (and handle (mm-get-part handle)))
4221 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4222 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4227 (mm-save-part-to-file handle file)
4228 (call-process shell-file-name nil
4229 (generate-new-buffer " *mm*")
4231 shell-command-switch
4233 printer file (mm-handle-type handle))))
4237 (gnus-print-buffer))
4238 (ps-despool filename)))))
4240 (defun gnus-mime-inline-part (&optional handle arg)
4241 "Insert the MIME part under point into the current buffer."
4242 (interactive (list nil current-prefix-arg))
4243 (gnus-article-check-buffer)
4244 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4247 (inhibit-read-only t))
4249 (if (and (not arg) (mm-handle-undisplayer handle))
4250 (mm-remove-part handle)
4251 (setq contents (mm-get-part handle))
4254 (setq charset (or (mail-content-type-get
4255 (mm-handle-type handle) 'charset)
4256 gnus-newsgroup-charset)))
4258 (if (mm-handle-undisplayer handle)
4259 (mm-remove-part handle))
4262 gnus-summary-show-article-charset-alist))
4263 (mm-read-coding-system "Charset: ")))))
4265 (mm-insert-inline handle
4267 (setq charset (mm-charset-to-coding-system
4269 (not (eq charset 'ascii)))
4270 (mm-decode-coding-string contents charset)
4274 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4275 "Insert the MIME part under point into the current buffer using the
4277 (interactive (list nil current-prefix-arg))
4278 (gnus-article-check-buffer)
4279 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4282 (inhibit-read-only t))
4284 (if (mm-handle-undisplayer handle)
4285 (mm-remove-part handle))
4286 (let ((gnus-newsgroup-charset
4288 gnus-summary-show-article-charset-alist))
4289 (mm-read-coding-system "Charset: ")))
4290 (gnus-newsgroup-ignored-charsets 'gnus-all))
4291 (gnus-article-press-button)))))
4293 (defun gnus-mime-view-part-externally (&optional handle)
4294 "View the MIME part under point with an external viewer."
4296 (gnus-article-check-buffer)
4297 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4298 (mm-user-display-methods nil)
4299 (mm-inlined-types nil)
4300 (mail-parse-charset gnus-newsgroup-charset)
4301 (mail-parse-ignored-charsets
4302 (with-current-buffer gnus-summary-buffer
4303 gnus-newsgroup-ignored-charsets)))
4305 (if (mm-handle-undisplayer handle)
4306 (mm-remove-part handle)
4307 (mm-display-part handle)))))
4309 (defun gnus-mime-view-part-internally (&optional handle)
4310 "View the MIME part under point with an internal viewer.
4311 If no internal viewer is available, use an external viewer."
4313 (gnus-article-check-buffer)
4314 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4315 (mm-inlined-types '(".*"))
4316 (mm-inline-large-images t)
4317 (mail-parse-charset gnus-newsgroup-charset)
4318 (mail-parse-ignored-charsets
4319 (with-current-buffer gnus-summary-buffer
4320 gnus-newsgroup-ignored-charsets))
4321 (inhibit-read-only t))
4323 (if (mm-handle-undisplayer handle)
4324 (mm-remove-part handle)
4325 (mm-display-part handle)))))
4327 (defun gnus-mime-action-on-part (&optional action)
4328 "Do something with the MIME attachment at \(point\)."
4330 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4331 (gnus-article-check-buffer)
4332 (let ((action-pair (assoc action gnus-mime-action-alist)))
4334 (funcall (cdr action-pair)))))
4336 (defun gnus-article-part-wrapper (n function)
4337 (with-current-buffer gnus-article-buffer
4338 (when (> n (length gnus-article-mime-handle-alist))
4339 (error "No such part"))
4340 (gnus-article-goto-part n)
4341 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4342 (funcall function handle))))
4344 (defun gnus-article-pipe-part (n)
4345 "Pipe MIME part N, which is the numerical prefix."
4347 (gnus-article-part-wrapper n 'mm-pipe-part))
4349 (defun gnus-article-save-part (n)
4350 "Save MIME part N, which is the numerical prefix."
4352 (gnus-article-part-wrapper n 'mm-save-part))
4354 (defun gnus-article-interactively-view-part (n)
4355 "View MIME part N interactively, which is the numerical prefix."
4357 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4359 (defun gnus-article-copy-part (n)
4360 "Copy MIME part N, which is the numerical prefix."
4362 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4364 (defun gnus-article-view-part-as-charset (n)
4365 "View MIME part N using a specified charset.
4366 N is the numerical prefix."
4368 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4370 (defun gnus-article-view-part-externally (n)
4371 "View MIME part N externally, which is the numerical prefix."
4373 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4375 (defun gnus-article-inline-part (n)
4376 "Inline MIME part N, which is the numerical prefix."
4378 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4380 (defun gnus-article-mime-match-handle-first (condition)
4383 (dolist (ihandle gnus-article-mime-handle-alist)
4385 ((functionp condition)
4386 (funcall condition (cdr ihandle)))
4387 ((eq condition 'undisplayed)
4388 (not (or (mm-handle-undisplayer (cdr ihandle))
4389 (equal (mm-handle-media-type (cdr ihandle))
4390 "multipart/alternative"))))
4391 ((eq condition 'undisplayed-alternative)
4392 (not (mm-handle-undisplayer (cdr ihandle))))
4394 (gnus-article-goto-part (car ihandle))
4395 (or (not n) (< (car ihandle) n)))
4396 (setq n (car ihandle))))
4400 (defun gnus-article-view-part (&optional n)
4401 "View MIME part N, which is the numerical prefix."
4403 (with-current-buffer gnus-article-buffer
4404 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4405 gnus-article-mime-match-handle-function)))
4406 (when (> n (length gnus-article-mime-handle-alist))
4407 (error "No such part"))
4408 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4409 (when (gnus-article-goto-part n)
4410 (if (equal (car handle) "multipart/alternative")
4411 (gnus-article-press-button)
4412 (when (eq (gnus-mm-display-part handle) 'internal)
4413 (gnus-set-window-start)))))))
4415 (defsubst gnus-article-mime-total-parts ()
4416 (if (bufferp (car gnus-article-mime-handles))
4418 (1- (length gnus-article-mime-handles))))
4420 (defun gnus-mm-display-part (handle)
4421 "Display HANDLE and fix MIME button."
4422 (let ((id (get-text-property (point) 'gnus-part))
4424 (inhibit-read-only t))
4427 (let ((window (selected-window))
4428 (mail-parse-charset gnus-newsgroup-charset)
4429 (mail-parse-ignored-charsets
4430 (if (gnus-buffer-live-p gnus-summary-buffer)
4431 (with-current-buffer gnus-summary-buffer
4432 gnus-newsgroup-ignored-charsets)
4436 (let ((win (gnus-get-buffer-window (current-buffer) t))
4439 (select-window win))
4442 (if (mm-handle-displayed-p handle)
4443 ;; This will remove the part.
4444 (mm-display-part handle)
4446 (narrow-to-region (point)
4447 (if (eobp) (point) (1+ (point))))
4448 (mm-display-part handle)
4449 ;; We narrow to the part itself and
4450 ;; then call the treatment functions.
4451 (goto-char (point-min))
4453 (narrow-to-region (point) (point-max))
4456 (gnus-article-mime-total-parts)
4457 (mm-handle-media-type handle)))))
4458 (if (window-live-p window)
4459 (select-window window)))))
4462 (gnus-insert-mime-button
4463 handle id (list (mm-handle-displayed-p handle)))
4464 (goto-char point))))
4466 (defun gnus-article-goto-part (n)
4467 "Go to MIME part N."
4468 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4470 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4471 (let ((gnus-tmp-name
4472 (or (mail-content-type-get (mm-handle-type handle) 'name)
4473 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4474 (mail-content-type-get (mm-handle-type handle) 'url)
4476 (gnus-tmp-type (mm-handle-media-type handle))
4477 (gnus-tmp-description
4478 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4481 (if (if displayed (car displayed)
4482 (mm-handle-displayed-p handle))
4484 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4486 gnus-tmp-type-long b e)
4487 (when (string-match ".*/" gnus-tmp-name)
4488 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4489 (setq gnus-tmp-type-long (concat gnus-tmp-type
4490 (and (not (equal gnus-tmp-name ""))
4491 (concat "; " gnus-tmp-name))))
4492 (unless (equal gnus-tmp-description "")
4493 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4498 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4499 `(keymap ,gnus-mime-button-map
4500 gnus-callback gnus-mm-display-part
4501 gnus-part ,gnus-tmp-id
4502 article-type annotation
4505 ;; Exclude a newline.
4508 (widget-convert-button
4511 :action 'gnus-widget-press-button
4512 :button-keymap gnus-mime-button-map
4514 (lambda (widget/window &optional overlay pos)
4515 ;; Needed to properly clear the message due to a bug in
4516 ;; wid-edit (XEmacs only).
4517 (if (boundp 'help-echo-owns-message)
4518 (setq help-echo-owns-message t))
4520 "%S: %s the MIME part; %S: more options"
4521 (aref gnus-mouse-2 0)
4522 ;; XEmacs will get a single widget arg; Emacs 21 will get
4523 ;; window, overlay, position.
4524 (if (mm-handle-displayed-p
4526 (with-current-buffer (gnus-overlay-buffer overlay)
4527 (widget-get (widget-at (gnus-overlay-start overlay))
4529 (widget-get widget/window :mime-handle)))
4531 (aref gnus-down-mouse-3 0))))))
4533 (defun gnus-widget-press-button (elems el)
4534 (goto-char (widget-get elems :from))
4535 (gnus-article-press-button))
4537 (defvar gnus-displaying-mime nil)
4539 (defun gnus-display-mime (&optional ihandles)
4540 "Display the MIME parts."
4542 (save-selected-window
4543 (let ((window (get-buffer-window gnus-article-buffer))
4546 (select-window window)
4547 ;; We have to do this since selecting the window
4548 ;; may change the point. So we set the window point.
4549 (set-window-point window point)))
4550 (let ((handles ihandles)
4551 (inhibit-read-only t)
4552 handle name type b e display)
4554 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4555 (when gnus-article-emulate-mime
4556 (mm-uu-dissect-text-parts handles)))
4557 (gnus-article-emulate-mime
4558 (setq handles (mm-uu-dissect))))
4559 (when (and (not ihandles)
4560 (not gnus-displaying-mime))
4561 ;; Top-level call; we clean up.
4562 (when gnus-article-mime-handles
4563 (mm-destroy-parts gnus-article-mime-handles)
4564 (setq gnus-article-mime-handle-alist nil));; A trick.
4565 (setq gnus-article-mime-handles handles)
4566 ;; We allow users to glean info from the handles.
4567 (when gnus-article-mime-part-function
4568 (gnus-mime-part-function handles)))
4570 (or (not (stringp (car handles)))
4573 (when (and (not ihandles)
4574 (not gnus-displaying-mime))
4575 ;; Clean up for mime parts.
4577 (delete-region (point) (point-max)))
4578 (let ((gnus-displaying-mime t))
4579 (gnus-mime-display-part handles)))
4582 (narrow-to-region (point) (point-max))
4583 (gnus-treat-article nil 1 1)
4586 ;; Highlight the headers.
4590 (narrow-to-region (point-min) (point))
4591 (gnus-treat-article 'head))))))))
4593 (defcustom gnus-mime-display-multipart-as-mixed nil
4594 "Display \"multipart\" parts as \"multipart/mixed\".
4596 If t, it overrides nil values of
4597 `gnus-mime-display-multipart-alternative-as-mixed' and
4598 `gnus-mime-display-multipart-related-as-mixed'."
4599 :group 'gnus-article-mime
4602 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4603 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4605 :group 'gnus-article-mime
4608 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4609 "Display \"multipart/related\" parts as \"multipart/mixed\".
4611 If displaying \"text/html\" is discouraged \(see
4612 `mm-discouraged-alternatives'\) images or other material inside a
4613 \"multipart/related\" part might be overlooked when this variable is nil."
4615 :group 'gnus-article-mime
4618 (defun gnus-mime-display-part (handle)
4621 ((not (stringp (car handle)))
4622 (gnus-mime-display-single handle))
4623 ;; User-defined multipart
4624 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4625 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4627 ;; multipart/alternative
4628 ((and (equal (car handle) "multipart/alternative")
4629 (not (or gnus-mime-display-multipart-as-mixed
4630 gnus-mime-display-multipart-alternative-as-mixed)))
4631 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4632 (push (cons id handle) gnus-article-mime-handle-alist)
4633 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4634 ;; multipart/related
4635 ((and (equal (car handle) "multipart/related")
4636 (not (or gnus-mime-display-multipart-as-mixed
4637 gnus-mime-display-multipart-related-as-mixed)))
4638 ;;;!!!We should find the start part, but we just default
4639 ;;;!!!to the first part.
4640 ;;(gnus-mime-display-part (cadr handle))
4641 ;;;!!! Most multipart/related is an HTML message plus images.
4642 ;;;!!! Unfortunately we are unable to let W3 display those
4643 ;;;!!! included images, so we just display it as a mixed multipart.
4644 ;;(gnus-mime-display-mixed (cdr handle))
4645 ;;;!!! No, w3 can display everything just fine.
4646 (gnus-mime-display-part (cadr handle)))
4647 ((equal (car handle) "multipart/signed")
4648 (gnus-add-wash-type 'signed)
4649 (gnus-mime-display-security handle))
4650 ((equal (car handle) "multipart/encrypted")
4651 (gnus-add-wash-type 'encrypted)
4652 (gnus-mime-display-security handle))
4653 ;; Other multiparts are handled like multipart/mixed.
4655 (gnus-mime-display-mixed (cdr handle)))))
4657 (defun gnus-mime-part-function (handles)
4658 (if (stringp (car handles))
4659 (mapcar 'gnus-mime-part-function (cdr handles))
4660 (funcall gnus-article-mime-part-function handles)))
4662 (defun gnus-mime-display-mixed (handles)
4663 (mapcar 'gnus-mime-display-part handles))
4665 (defun gnus-mime-display-single (handle)
4666 (let ((type (mm-handle-media-type handle))
4667 (ignored gnus-ignored-mime-types)
4674 (when (string-match (pop ignored) type)
4675 (throw 'ignored nil)))
4676 (if (and (setq not-attachment
4677 (and (not (mm-inline-override-p handle))
4678 (or (not (mm-handle-disposition handle))
4679 (equal (car (mm-handle-disposition handle))
4681 (mm-attachment-override-p handle))))
4682 (mm-automatic-display-p handle)
4684 (mm-inlinable-p handle)
4685 (mm-inlined-p handle))
4686 (mm-automatic-external-display-p type)))
4688 (when (equal (mm-handle-media-supertype handle) "text")
4690 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4692 (push (cons id handle) gnus-article-mime-handle-alist)
4693 (when (or (not display)
4694 (not (gnus-unbuttonized-mime-type-p type)))
4695 (gnus-insert-mime-button
4696 handle id (list (or display (and not-attachment text))))
4697 (gnus-article-insert-newline)
4698 ;; Remember modify the number of forward lines.
4706 (let ((mail-parse-charset gnus-newsgroup-charset)
4707 (mail-parse-ignored-charsets
4708 (save-excursion (condition-case ()
4709 (set-buffer gnus-summary-buffer)
4711 gnus-newsgroup-ignored-charsets)))
4712 (mm-display-part handle t))
4713 (goto-char (point-max)))
4714 ((and text not-attachment)
4718 (gnus-article-insert-newline)
4719 (mm-display-inline handle)
4720 (goto-char (point-max))))
4724 (narrow-to-region beg (point))
4727 (gnus-article-mime-total-parts)
4728 (mm-handle-media-type handle)))))))))
4730 (defun gnus-unbuttonized-mime-type-p (type)
4731 "Say whether TYPE is to be unbuttonized."
4732 (unless gnus-inhibit-mime-unbuttonizing
4734 (let ((types gnus-unbuttonized-mime-types))
4736 (when (string-match (pop types) type)
4737 (throw 'found t)))))
4739 (let ((types gnus-buttonized-mime-types))
4741 (when (string-match (pop types) type)
4742 (throw 'found t)))))))))
4744 (defun gnus-article-insert-newline ()
4745 "Insert a newline, but mark it as undeletable."
4746 (gnus-put-text-property
4747 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4749 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4750 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4753 handle (inhibit-read-only t) from props begend not-pref)
4754 (save-window-excursion
4757 (narrow-to-region (car ibegend)
4760 (goto-char (car ibegend))
4763 (delete-region (point-min) (point-max))
4764 (mm-remove-parts handles))
4765 (setq begend (list (point-marker)))
4767 (unless (setq not-pref (cadr (member preferred ihandles)))
4768 (setq not-pref (car ihandles)))
4771 (not (gnus-unbuttonized-mime-type-p
4772 "multipart/alternative")))
4773 (gnus-add-text-properties
4776 (insert (format "%d. " id))
4780 (unless ,(not ibegend)
4781 (setq gnus-article-mime-handle-alist
4782 ',gnus-article-mime-handle-alist))
4783 (gnus-mime-display-alternative
4784 ',ihandles ',not-pref ',begend ,id))
4785 keymap ,gnus-mime-button-map
4786 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4787 face ,gnus-article-button-face
4790 (widget-convert-button 'link from (point)
4791 :action 'gnus-widget-press-button
4792 :button-keymap gnus-widget-button-keymap)
4794 (while (setq handle (pop handles))
4795 (gnus-add-text-properties
4798 (insert (format "(%c) %-18s"
4799 (if (equal handle preferred) ?* ? )
4800 (mm-handle-media-type handle)))
4804 (unless ,(not ibegend)
4805 (setq gnus-article-mime-handle-alist
4806 ',gnus-article-mime-handle-alist))
4807 (gnus-mime-display-alternative
4808 ',ihandles ',handle ',begend ,id))
4809 keymap ,gnus-mime-button-map
4810 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4811 face ,gnus-article-button-face
4814 (widget-convert-button 'link from (point)
4815 :action 'gnus-widget-press-button
4816 :button-keymap gnus-widget-button-keymap)
4820 (if (stringp (car preferred))
4821 (gnus-display-mime preferred)
4822 (let ((mail-parse-charset gnus-newsgroup-charset)
4823 (mail-parse-ignored-charsets
4824 (with-current-buffer gnus-summary-buffer
4825 gnus-newsgroup-ignored-charsets)))
4826 (mm-display-part preferred)
4830 (narrow-to-region (car begend) (point-max))
4832 nil (length gnus-article-mime-handle-alist)
4833 (gnus-article-mime-total-parts)
4834 (mm-handle-media-type handle))))))
4835 (goto-char (point-max))
4836 (setcdr begend (point-marker)))))
4838 (goto-char point))))
4840 (defconst gnus-article-wash-status-strings
4841 (let ((alist '((cite "c" "Possible hidden citation text"
4842 " " "All citation text visible")
4843 (headers "h" "Hidden headers"
4844 " " "All headers visible.")
4845 (pgp "p" "Encrypted or signed message status hidden"
4846 " " "No hidden encryption nor digital signature status")
4847 (signature "s" "Signature has been hidden"
4848 " " "Signature is visible")
4849 (overstrike "o" "Overstrike (^H) characters applied"
4850 " " "No overstrike characters applied")
4851 (emphasis "e" "/*_Emphasis_*/ characters applied"
4852 " " "No /*_emphasis_*/ characters applied")))
4854 (dolist (entry alist result)
4855 (let ((key (nth 0 entry))
4856 (on (copy-sequence (nth 1 entry)))
4857 (on-help (nth 2 entry))
4858 (off (copy-sequence (nth 3 entry)))
4859 (off-help (nth 4 entry)))
4860 (put-text-property 0 1 'help-echo on-help on)
4861 (put-text-property 0 1 'help-echo off-help off)
4862 (push (list key on off) result))))
4863 "Alist of strings describing wash status in the mode line.
4864 Each entry has the form (KEY ON OF), where the KEY is a symbol
4865 representing the particular washing function, ON is the string to use
4866 in the article mode line when the washing function is active, and OFF
4867 is the string to use when it is inactive.")
4869 (defun gnus-article-wash-status-entry (key value)
4870 (let ((entry (assoc key gnus-article-wash-status-strings)))
4871 (if value (nth 1 entry) (nth 2 entry))))
4873 (defun gnus-article-wash-status ()
4874 "Return a string which display status of article washing."
4875 (with-current-buffer gnus-article-buffer
4876 (let ((cite (memq 'cite gnus-article-wash-types))
4877 (headers (memq 'headers gnus-article-wash-types))
4878 (boring (memq 'boring-headers gnus-article-wash-types))
4879 (pgp (memq 'pgp gnus-article-wash-types))
4880 (pem (memq 'pem gnus-article-wash-types))
4881 (signed (memq 'signed gnus-article-wash-types))
4882 (encrypted (memq 'encrypted gnus-article-wash-types))
4883 (signature (memq 'signature gnus-article-wash-types))
4884 (overstrike (memq 'overstrike gnus-article-wash-types))
4885 (emphasis (memq 'emphasis gnus-article-wash-types)))
4887 (gnus-article-wash-status-entry 'cite cite)
4888 (gnus-article-wash-status-entry 'headers (or headers boring))
4889 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4890 (gnus-article-wash-status-entry 'signature signature)
4891 (gnus-article-wash-status-entry 'overstrike overstrike)
4892 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4894 (defun gnus-add-wash-type (type)
4895 "Add a washing of TYPE to the current status."
4896 (add-to-list 'gnus-article-wash-types type))
4898 (defun gnus-delete-wash-type (type)
4899 "Add a washing of TYPE to the current status."
4900 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4902 (defun gnus-add-image (category image)
4903 "Add IMAGE of CATEGORY to the list of displayed images."
4904 (let ((entry (assq category gnus-article-image-alist)))
4906 (setq entry (list category))
4907 (push entry gnus-article-image-alist))
4908 (nconc entry (list image))))
4910 (defun gnus-delete-images (category)
4911 "Delete all images in CATEGORY."
4912 (let ((entry (assq category gnus-article-image-alist)))
4913 (dolist (image (cdr entry))
4914 (gnus-remove-image image category))
4915 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4916 (gnus-delete-wash-type category)))
4918 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4920 (defun gnus-article-maybe-hide-headers ()
4921 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4922 Provided for backwards compatibility."
4923 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4924 (not (with-current-buffer gnus-summary-buffer
4925 gnus-have-all-headers)))
4926 (not gnus-inhibit-hiding))
4927 (gnus-article-hide-headers)))
4931 (defun gnus-output-to-file (file-name)
4932 "Append the current article to a file named FILE-NAME."
4933 (let ((artbuf (current-buffer)))
4935 (insert-buffer-substring artbuf)
4936 ;; Append newline at end of the buffer as separator, and then
4938 (goto-char (point-max))
4940 (let ((file-name-coding-system nnmail-pathname-coding-system))
4941 (mm-append-to-file (point-min) (point-max) file-name))
4944 (defun gnus-narrow-to-page (&optional arg)
4945 "Narrow the article buffer to a page.
4946 If given a numerical ARG, move forward ARG pages."
4948 (setq arg (if arg (prefix-numeric-value arg) 0))
4950 (set-buffer gnus-article-buffer)
4951 (goto-char (point-min))
4953 ;; Remove any old next/prev buttons.
4954 (when (gnus-visual-p 'page-marker)
4955 (let ((inhibit-read-only t))
4956 (gnus-remove-text-with-property 'gnus-prev)
4957 (gnus-remove-text-with-property 'gnus-next)))
4960 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4962 (re-search-forward page-delimiter nil 'move arg)))
4963 (goto-char (match-end 0))
4965 (goto-char (point-min))
4966 (setq gnus-page-broken
4967 (and (re-search-forward page-delimiter nil t) t))))
4968 (when gnus-page-broken
4971 (if (re-search-forward page-delimiter nil 'move)
4974 (when (and (gnus-visual-p 'page-marker)
4975 (> (point-min) (save-restriction (widen) (point-min))))
4977 (goto-char (point-min))
4978 (gnus-insert-prev-page-button)))
4979 (when (and (gnus-visual-p 'page-marker)
4980 (< (+ (point-max) 2) (buffer-size)))
4982 (goto-char (point-max))
4983 (gnus-insert-next-page-button))))))
4985 ;; Article mode commands
4987 (defun gnus-article-goto-next-page ()
4988 "Show the next page of the article."
4990 (when (gnus-article-next-page)
4991 (goto-char (point-min))
4992 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4995 (defun gnus-article-goto-prev-page ()
4996 "Show the previous page of the article."
4999 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5000 (gnus-article-prev-page nil)))
5002 ;; This is cleaner but currently breaks `gnus-pick-mode':
5004 ;; (defun gnus-article-goto-next-page ()
5005 ;; "Show the next page of the article."
5007 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5008 ;; (gnus-summary-next-page)))
5010 ;; (defun gnus-article-goto-prev-page ()
5011 ;; "Show the next page of the article."
5013 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5014 ;; (gnus-summary-prev-page)))
5016 (defun gnus-article-next-page (&optional lines)
5017 "Show the next page of the current article.
5018 If end of article, return non-nil. Otherwise return nil.
5019 Argument LINES specifies lines to be scrolled up."
5021 (move-to-window-line -1)
5024 (and (pos-visible-in-window-p) ;Not continuation line.
5025 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5026 ;; Nothing in this page.
5027 (if (or (not gnus-page-broken)
5032 (eobp)))) ;Real end-of-buffer?
5034 (when gnus-article-over-scroll
5035 (gnus-article-next-page-1 lines))
5037 (gnus-narrow-to-page 1) ;Go to next page.
5039 ;; More in this page.
5040 (gnus-article-next-page-1 lines)
5043 (defun gnus-article-next-page-1 (lines)
5044 (let ((scroll-in-place nil))
5048 ;; Long lines may cause an end-of-buffer error.
5049 (goto-char (point-max)))))
5050 (move-to-window-line 0))
5052 (defun gnus-article-prev-page (&optional lines)
5053 "Show previous page of current article.
5054 Argument LINES specifies lines to be scrolled down."
5056 (move-to-window-line 0)
5057 (if (and gnus-page-broken
5059 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5061 (gnus-narrow-to-page -1) ;Go to previous page.
5062 (goto-char (point-max))
5064 (let ((scroll-in-place nil))
5068 (beginning-of-buffer
5069 (goto-char (point-min))))
5070 (move-to-window-line 0)))))
5072 (defun gnus-article-only-boring-p ()
5073 "Decide whether there is only boring text remaining in the article.
5074 Something \"interesting\" is a word of at least two letters that does
5075 not have a face in `gnus-article-boring-faces'."
5076 (when (and gnus-article-skip-boring
5077 (boundp 'gnus-article-boring-faces)
5078 (symbol-value 'gnus-article-boring-faces))
5081 (while (re-search-forward "\\b\\w\\w" nil t)
5083 (when (not (gnus-intersection
5084 (gnus-faces-at (point))
5085 (symbol-value 'gnus-article-boring-faces)))
5086 (throw 'only-boring nil)))
5087 (throw 'only-boring t)))))
5089 (defun gnus-article-refer-article ()
5090 "Read article specified by message-id around point."
5093 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5094 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5095 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5096 (let ((msg-id (concat "<" (match-string 0) ">")))
5097 (set-buffer gnus-summary-buffer)
5098 (gnus-summary-refer-article msg-id))
5099 (error "No references around point"))))
5101 (defun gnus-article-show-summary ()
5102 "Reconfigure windows to show summary buffer."
5104 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5105 (error "There is no summary buffer for this article buffer")
5106 (gnus-article-set-globals)
5107 (gnus-configure-windows 'article)
5108 (gnus-summary-goto-subject gnus-current-article)
5109 (gnus-summary-position-point)))
5111 (defun gnus-article-describe-briefly ()
5112 "Describe article mode commands briefly."
5114 (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")))
5116 (defun gnus-article-summary-command ()
5117 "Execute the last keystroke in the summary buffer."
5119 (let ((obuf (current-buffer))
5120 (owin (current-window-configuration))
5122 (switch-to-buffer gnus-article-current-summary 'norecord)
5123 (setq func (lookup-key (current-local-map) (this-command-keys)))
5124 (call-interactively func)
5126 (set-window-configuration owin)
5127 (set-window-point (get-buffer-window (current-buffer)) (point))))
5129 (defun gnus-article-summary-command-nosave ()
5130 "Execute the last keystroke in the summary buffer."
5133 (pop-to-buffer gnus-article-current-summary 'norecord)
5134 (setq func (lookup-key (current-local-map) (this-command-keys)))
5135 (call-interactively func)))
5137 (defun gnus-article-check-buffer ()
5138 "Beep if not in an article buffer."
5139 (unless (equal major-mode 'gnus-article-mode)
5140 (error "Command invoked outside of a Gnus article buffer")))
5142 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5143 "Read a summary buffer key sequence and execute it from the article buffer."
5145 (gnus-article-check-buffer)
5147 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5148 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5149 "=" "^" "\M-^" "|"))
5155 '("n" "Gn" "p" "Gp"))
5158 (set-buffer gnus-article-current-summary)
5159 (let (gnus-pick-mode)
5160 (push (or key last-command-event) unread-command-events)
5161 (setq keys (if (featurep 'xemacs)
5162 (events-to-keys (read-key-sequence nil))
5163 (read-key-sequence nil)))))
5167 (if (or (member keys nosaves)
5168 (member keys nosave-but-article)
5169 (member keys nosave-in-article))
5171 (save-window-excursion
5172 (pop-to-buffer gnus-article-current-summary 'norecord)
5173 ;; We disable the pick minor mode commands.
5174 (let (gnus-pick-mode)
5175 (setq func (lookup-key (current-local-map) keys))))
5179 (unless (member keys nosave-in-article)
5180 (set-buffer gnus-article-current-summary))
5181 (call-interactively func)
5182 (setq new-sum-point (point)))
5183 (when (member keys nosave-but-article)
5184 (pop-to-buffer gnus-article-buffer 'norecord)))
5185 ;; These commands should restore window configuration.
5186 (let ((obuf (current-buffer))
5187 (owin (current-window-configuration))
5189 win func in-buffer selected new-sum-start new-sum-hscroll)
5190 (cond (not-restore-window
5191 (pop-to-buffer gnus-article-current-summary 'norecord))
5192 ((setq win (get-buffer-window gnus-article-current-summary))
5193 (select-window win))
5195 (switch-to-buffer gnus-article-current-summary 'norecord)))
5196 (setq in-buffer (current-buffer))
5197 ;; We disable the pick minor mode commands.
5198 (if (and (setq func (let (gnus-pick-mode)
5199 (lookup-key (current-local-map) keys)))
5202 (call-interactively func)
5203 (when (eq win (selected-window))
5204 (setq new-sum-point (point)
5205 new-sum-start (window-start win)
5206 new-sum-hscroll (window-hscroll win))
5207 (when (eq in-buffer (current-buffer))
5208 (setq selected (gnus-summary-select-article))
5210 (unless not-restore-window
5211 (set-window-configuration owin))
5212 (when (eq selected 'old)
5214 (set-window-start (get-buffer-window (current-buffer))
5216 (set-window-point (get-buffer-window (current-buffer))
5218 (when (and (not not-restore-window)
5220 (set-window-point win new-sum-point)
5221 (set-window-start win new-sum-start)
5222 (set-window-hscroll win new-sum-hscroll)))))
5223 (set-window-configuration owin)
5226 (defun gnus-article-describe-key (key)
5227 "Display documentation of the function invoked by KEY. KEY is a string."
5228 (interactive "kDescribe key: ")
5229 (gnus-article-check-buffer)
5230 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5232 (set-buffer gnus-article-current-summary)
5233 (let (gnus-pick-mode)
5234 (if (featurep 'xemacs)
5236 (push (elt key 0) unread-command-events)
5237 (setq key (events-to-keys
5238 (read-key-sequence "Describe key: "))))
5239 (setq unread-command-events
5241 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5242 (string-to-list key)))
5243 (setq key (read-key-sequence "Describe key: "))))
5245 (describe-key key)))
5247 (defun gnus-article-describe-key-briefly (key &optional insert)
5248 "Display documentation of the function invoked by KEY. KEY is a string."
5249 (interactive "kDescribe key: \nP")
5250 (gnus-article-check-buffer)
5251 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5253 (set-buffer gnus-article-current-summary)
5254 (let (gnus-pick-mode)
5255 (if (featurep 'xemacs)
5257 (push (elt key 0) unread-command-events)
5258 (setq key (events-to-keys
5259 (read-key-sequence "Describe key: "))))
5260 (setq unread-command-events
5262 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5263 (string-to-list key)))
5264 (setq key (read-key-sequence "Describe key: "))))
5265 (describe-key-briefly key insert))
5266 (describe-key-briefly key insert)))
5268 (defun gnus-article-reply-with-original (&optional wide)
5269 "Start composing a reply mail to the current message.
5270 The text in the region will be yanked. If the region isn't active,
5271 the entire article will be yanked."
5273 (let ((article (cdr gnus-article-current))
5275 (if (not (gnus-region-active-p))
5276 (with-current-buffer gnus-summary-buffer
5277 (gnus-summary-reply (list (list article)) wide))
5278 (setq contents (buffer-substring (point) (mark t)))
5279 ;; Deactivate active regions.
5280 (when (and (boundp 'transient-mark-mode)
5281 transient-mark-mode)
5282 (setq mark-active nil))
5283 (with-current-buffer gnus-summary-buffer
5285 (list (list article contents)) wide)))))
5287 (defun gnus-article-followup-with-original ()
5288 "Compose a followup to the current article.
5289 The text in the region will be yanked. If the region isn't active,
5290 the entire article will be yanked."
5292 (let ((article (cdr gnus-article-current))
5294 (if (not (gnus-region-active-p))
5295 (with-current-buffer gnus-summary-buffer
5296 (gnus-summary-followup (list (list article))))
5297 (setq contents (buffer-substring (point) (mark t)))
5298 ;; Deactivate active regions.
5299 (when (and (boundp 'transient-mark-mode)
5300 transient-mark-mode)
5301 (setq mark-active nil))
5302 (with-current-buffer gnus-summary-buffer
5303 (gnus-summary-followup
5304 (list (list article contents)))))))
5306 (defun gnus-article-hide (&optional arg force)
5307 "Hide all the gruft in the current article.
5308 This means that signatures, cited text and (some) headers will be
5310 If given a prefix, show the hidden text instead."
5311 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5312 (gnus-article-hide-headers arg)
5313 (gnus-article-hide-list-identifiers arg)
5314 (gnus-article-hide-citation-maybe arg force)
5315 (gnus-article-hide-signature arg))
5317 (defun gnus-article-maybe-highlight ()
5318 "Do some article highlighting if article highlighting is requested."
5319 (when (gnus-visual-p 'article-highlight 'highlight)
5320 (gnus-article-highlight-some)))
5322 (defun gnus-check-group-server ()
5323 ;; Make sure the connection to the server is alive.
5324 (unless (gnus-server-opened
5325 (gnus-find-method-for-group gnus-newsgroup-name))
5326 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5327 (gnus-request-group gnus-newsgroup-name t)))
5330 (autoload 'nneething-get-file-name "nneething"))
5332 (defun gnus-request-article-this-buffer (article group)
5333 "Get an article and insert it into this buffer."
5334 (let (do-update-line sparse-header)
5338 (gnus-kill-all-overlays)
5339 (setq group (or group gnus-newsgroup-name))
5341 ;; Using `gnus-request-article' directly will insert the article into
5342 ;; `nntp-server-buffer' - so we'll save some time by not having to
5343 ;; copy it from the server buffer into the article buffer.
5345 ;; We only request an article by message-id when we do not have the
5346 ;; headers for it, so we'll have to get those.
5347 (when (stringp article)
5348 (gnus-read-header article))
5350 ;; If the article number is negative, that means that this article
5351 ;; doesn't belong in this newsgroup (possibly), so we find its
5352 ;; message-id and request it by id instead of number.
5353 (when (and (numberp article)
5355 (get-buffer gnus-summary-buffer)
5356 (gnus-buffer-exists-p gnus-summary-buffer))
5358 (set-buffer gnus-summary-buffer)
5359 (let ((header (gnus-summary-article-header article)))
5362 ((memq article gnus-newsgroup-sparse)
5363 ;; This is a sparse gap article.
5364 (setq do-update-line article)
5365 (setq article (mail-header-id header))
5366 (setq sparse-header (gnus-read-header article))
5367 (setq gnus-newsgroup-sparse
5368 (delq article gnus-newsgroup-sparse)))
5370 ;; It's a real article.
5371 (setq article (mail-header-id header)))
5373 ;; It is an extracted pseudo-article.
5374 (setq article 'pseudo)
5375 (gnus-request-pseudo-article header))))
5377 (let ((method (gnus-find-method-for-group
5378 gnus-newsgroup-name)))
5379 (when (and (eq (car method) 'nneething)
5381 (let ((dir (nneething-get-file-name
5382 (mail-header-id header))))
5383 (when (and (stringp dir)
5384 (file-directory-p dir))
5385 (setq article 'nneething)
5386 (gnus-group-enter-directory dir))))))))
5389 ;; Refuse to select canceled articles.
5390 ((and (numberp article)
5392 (get-buffer gnus-summary-buffer)
5393 (gnus-buffer-exists-p gnus-summary-buffer)
5394 (eq (cdr (with-current-buffer gnus-summary-buffer
5395 (assq article gnus-newsgroup-reads)))
5396 gnus-canceled-mark))
5398 ;; We first check `gnus-original-article-buffer'.
5399 ((and (get-buffer gnus-original-article-buffer)
5401 (with-current-buffer gnus-original-article-buffer
5402 (and (equal (car gnus-original-article) group)
5403 (eq (cdr gnus-original-article) article))))
5404 (insert-buffer-substring gnus-original-article-buffer)
5406 ;; Check the backlog.
5407 ((and gnus-keep-backlog
5408 (gnus-backlog-request-article group article (current-buffer)))
5410 ;; Check asynchronous pre-fetch.
5411 ((gnus-async-request-fetched-article group article (current-buffer))
5412 (gnus-async-prefetch-next group article gnus-summary-buffer)
5413 (when (and (numberp article) gnus-keep-backlog)
5414 (gnus-backlog-enter-article group article (current-buffer)))
5417 ((and gnus-use-cache
5419 (gnus-cache-request-article article group))
5421 ;; Check the agent cache.
5422 ((gnus-agent-request-article article group)
5424 ;; Get the article and put into the article buffer.
5425 ((or (stringp article)
5427 (let ((gnus-override-method gnus-override-method)
5428 (methods (and (stringp article)
5429 gnus-refer-article-method))
5430 (backend (car (gnus-find-method-for-group
5431 gnus-newsgroup-name)))
5433 (inhibit-read-only t))
5434 (if (or (not (listp methods))
5435 (and (symbolp (car methods))
5436 (assq (car methods) nnoo-definition-alist)))
5437 (setq methods (list methods)))
5438 (when (and (null gnus-override-method)
5440 (setq gnus-override-method (pop methods)))
5442 (when (eq gnus-override-method 'current)
5443 (setq gnus-override-method
5444 (with-current-buffer gnus-summary-buffer
5445 gnus-current-select-method)))
5447 (gnus-kill-all-overlays)
5448 (let ((gnus-newsgroup-name group))
5449 (gnus-check-group-server))
5451 ((gnus-request-article article group (current-buffer))
5452 (when (numberp article)
5453 (gnus-async-prefetch-next group article
5454 gnus-summary-buffer)
5455 (when gnus-keep-backlog
5456 (gnus-backlog-enter-article
5457 group article (current-buffer))))
5458 (setq result 'article))
5460 (setq gnus-override-method (pop methods)))
5461 ((not (string-match "^400 "
5462 (nnheader-get-report backend)))
5463 ;; If we get 400 server disconnect, reconnect and
5464 ;; retry; otherwise, assume the article has expired.
5465 (setq result 'done))))
5466 (and (eq result 'article) 'article)))
5470 ;; Associate this article with the current summary buffer.
5471 (setq gnus-article-current-summary gnus-summary-buffer)
5473 ;; Take the article from the original article buffer
5474 ;; and place it in the buffer it's supposed to be in.
5475 (when (and (get-buffer gnus-article-buffer)
5476 (equal (buffer-name (current-buffer))
5477 (buffer-name (get-buffer gnus-article-buffer))))
5479 (if (get-buffer gnus-original-article-buffer)
5480 (set-buffer gnus-original-article-buffer)
5481 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5482 (buffer-disable-undo)
5483 (setq major-mode 'gnus-original-article-mode)
5484 (setq buffer-read-only t))
5485 (let ((inhibit-read-only t))
5487 (insert-buffer-substring gnus-article-buffer))
5488 (setq gnus-original-article (cons group article)))
5491 (run-hooks 'gnus-article-decode-hook)
5492 ;; Mark article as decoded or not.
5493 (setq gnus-article-decoded-p gnus-article-decode-hook))
5495 ;; Update sparse articles.
5496 (when (and do-update-line
5497 (or (numberp article)
5499 (let ((buf (current-buffer)))
5500 (set-buffer gnus-summary-buffer)
5501 (gnus-summary-update-article do-update-line sparse-header)
5502 (gnus-summary-goto-subject do-update-line nil t)
5503 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5505 (set-buffer buf))))))
5511 (defcustom gnus-article-edit-mode-hook nil
5512 "Hook run in article edit mode buffers."
5513 :group 'gnus-article-various
5516 (defvar gnus-article-edit-done-function nil)
5518 (defvar gnus-article-edit-mode-map nil)
5520 ;; Should we be using derived.el for this?
5521 (unless gnus-article-edit-mode-map
5522 (setq gnus-article-edit-mode-map (make-keymap))
5523 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5525 (gnus-define-keys gnus-article-edit-mode-map
5526 "\C-c?" describe-mode
5527 "\C-c\C-c" gnus-article-edit-done
5528 "\C-c\C-k" gnus-article-edit-exit
5529 "\C-c\C-f\C-t" message-goto-to
5530 "\C-c\C-f\C-o" message-goto-from
5531 "\C-c\C-f\C-b" message-goto-bcc
5532 ;;"\C-c\C-f\C-w" message-goto-fcc
5533 "\C-c\C-f\C-c" message-goto-cc
5534 "\C-c\C-f\C-s" message-goto-subject
5535 "\C-c\C-f\C-r" message-goto-reply-to
5536 "\C-c\C-f\C-n" message-goto-newsgroups
5537 "\C-c\C-f\C-d" message-goto-distribution
5538 "\C-c\C-f\C-f" message-goto-followup-to
5539 "\C-c\C-f\C-m" message-goto-mail-followup-to
5540 "\C-c\C-f\C-k" message-goto-keywords
5541 "\C-c\C-f\C-u" message-goto-summary
5542 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5543 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5544 "\C-c\C-b" message-goto-body
5545 "\C-c\C-i" message-goto-signature
5547 "\C-c\C-t" message-insert-to
5548 "\C-c\C-n" message-insert-newsgroups
5549 "\C-c\C-o" message-sort-headers
5550 "\C-c\C-e" message-elide-region
5551 "\C-c\C-v" message-delete-not-region
5552 "\C-c\C-z" message-kill-to-signature
5553 "\M-\r" message-newline-and-reformat
5554 "\C-c\C-a" mml-attach-file
5555 "\C-a" message-beginning-of-line
5557 "\M-;" comment-region)
5559 (gnus-define-keys (gnus-article-edit-wash-map
5560 "\C-c\C-w" gnus-article-edit-mode-map)
5561 "f" gnus-article-edit-full-stops))
5564 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5566 ["Fetch To" message-insert-to t]
5567 ["Fetch Newsgroups" message-insert-newsgroups t]
5569 ["To" message-goto-to t]
5570 ["From" message-goto-from t]
5571 ["Subject" message-goto-subject t]
5572 ["Cc" message-goto-cc t]
5573 ["Reply-To" message-goto-reply-to t]
5574 ["Summary" message-goto-summary t]
5575 ["Keywords" message-goto-keywords t]
5576 ["Newsgroups" message-goto-newsgroups t]
5577 ["Followup-To" message-goto-followup-to t]
5578 ["Mail-Followup-To" message-goto-mail-followup-to t]
5579 ["Distribution" message-goto-distribution t]
5580 ["Body" message-goto-body t]
5581 ["Signature" message-goto-signature t]))
5583 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5584 "Major mode for editing articles.
5585 This is an extended text-mode.
5587 \\{gnus-article-edit-mode-map}"
5588 (make-local-variable 'gnus-article-edit-done-function)
5589 (make-local-variable 'gnus-prev-winconf)
5590 (set (make-local-variable 'font-lock-defaults)
5591 '(message-font-lock-keywords t))
5592 (set (make-local-variable 'mail-header-separator) "")
5593 (set (make-local-variable 'gnus-article-edit-mode) t)
5594 (easy-menu-add message-mode-field-menu message-mode-map)
5596 (setq buffer-read-only nil)
5597 (buffer-enable-undo)
5600 (defun gnus-article-edit (&optional force)
5601 "Edit the current article.
5602 This will have permanent effect only in mail groups.
5603 If FORCE is non-nil, allow editing of articles even in read-only
5606 (when (and (not force)
5607 (gnus-group-read-only-p))
5608 (error "The current newsgroup does not support article editing"))
5609 (gnus-article-date-original)
5610 (gnus-article-edit-article
5612 `(lambda (no-highlight)
5614 (gnus-summary-edit-article-done
5615 ,(or (mail-header-references gnus-current-headers) "")
5616 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5618 (defun gnus-article-edit-article (start-func exit-func)
5619 "Start editing the contents of the current article buffer."
5620 (let ((winconf (current-window-configuration)))
5621 (set-buffer gnus-article-buffer)
5622 (gnus-article-edit-mode)
5623 (funcall start-func)
5624 (set-buffer-modified-p nil)
5625 (gnus-configure-windows 'edit-article)
5626 (setq gnus-article-edit-done-function exit-func)
5627 (setq gnus-prev-winconf winconf)
5628 (gnus-message 6 "C-c C-c to end edits")))
5630 (defun gnus-article-edit-done (&optional arg)
5631 "Update the article edits and exit."
5633 (let ((func gnus-article-edit-done-function)
5634 (buf (current-buffer))
5635 (start (window-start))
5637 (winconf gnus-prev-winconf))
5638 (widen) ;; Widen it in case that users narrowed the buffer.
5641 ;; The cache and backlog have to be flushed somewhat.
5642 (when gnus-keep-backlog
5643 (gnus-backlog-remove-article
5644 (car gnus-article-current) (cdr gnus-article-current)))
5645 ;; Flush original article as well.
5647 (when (get-buffer gnus-original-article-buffer)
5648 (set-buffer gnus-original-article-buffer)
5649 (setq gnus-original-article nil)))
5650 (when gnus-use-cache
5651 (gnus-cache-update-article
5652 (car gnus-article-current) (cdr gnus-article-current)))
5653 ;; We remove all text props from the article buffer.
5654 (kill-all-local-variables)
5655 (set-text-properties (point-min) (point-max) nil)
5657 (set-window-configuration winconf)
5659 (set-window-start (get-buffer-window buf) start)
5660 (set-window-point (get-buffer-window buf) (point)))
5661 (gnus-summary-show-article))
5663 (defun gnus-article-edit-exit ()
5664 "Exit the article editing without updating."
5666 (when (or (not (buffer-modified-p))
5667 (yes-or-no-p "Article modified; kill anyway? "))
5668 (let ((curbuf (current-buffer))
5670 (window-start (window-start)))
5672 (if (gnus-buffer-live-p gnus-original-article-buffer)
5673 (insert-buffer gnus-original-article-buffer))
5674 (let ((winconf gnus-prev-winconf))
5675 (kill-all-local-variables)
5677 (set-window-configuration winconf)
5678 ;; Tippy-toe some to make sure that point remains where it was.
5679 (save-current-buffer
5681 (set-window-start (get-buffer-window (current-buffer)) window-start)
5683 (gnus-summary-show-article)))
5685 (defun gnus-article-edit-full-stops ()
5686 "Interactively repair spacing at end of sentences."
5689 (goto-char (point-min))
5690 (search-forward-regexp "^$" nil t)
5691 (let ((case-fold-search nil))
5692 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5695 ;;; Article highlights
5698 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5700 ;;; Internal Variables:
5702 (defcustom gnus-button-url-regexp
5703 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5704 "\\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:]]\\)"
5705 "\\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\\)\\)")
5706 "Regular expression that matches URLs."
5707 :group 'gnus-article-buttons
5710 (defcustom gnus-button-valid-fqdn-regexp
5711 message-valid-fqdn-regexp
5712 "Regular expression that matches a valid FQDN."
5714 :group 'gnus-article-buttons
5717 (defcustom gnus-button-man-handler 'manual-entry
5718 "Function to use for displaying man pages.
5719 The function must take at least one argument with a string naming the
5722 :type '(choice (function-item :tag "Man" manual-entry)
5723 (function-item :tag "Woman" woman)
5724 (function :tag "Other"))
5725 :group 'gnus-article-buttons)
5727 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5728 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5729 If the default site is too slow, try to find a CTAN mirror, see
5730 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5731 the variable `gnus-button-handle-ctan'."
5733 :group 'gnus-article-buttons
5734 :link '(custom-manual "(gnus)Group Parameters")
5735 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5736 (const "http://tug.ctan.org/tex-archive/")
5737 (const "http://www.dante.de/CTAN/")
5738 (string :tag "Other")))
5740 (defcustom gnus-button-ctan-handler 'browse-url
5741 "Function to use for displaying CTAN links.
5742 The function must take one argument, the string naming the URL."
5744 :type '(choice (function-item :tag "Browse Url" browse-url)
5745 (function :tag "Other"))
5746 :group 'gnus-article-buttons)
5748 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5749 "Bogus strings removed from CTAN URLs."
5751 :group 'gnus-article-buttons
5752 :type '(choice (const "^/?tex-archive/\\|/")
5753 (regexp :tag "Other")))
5755 (defcustom gnus-button-ctan-directory-regexp
5758 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5759 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5760 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5762 "Regular expression for ctan directories.
5763 It should match all directories in the top level of `gnus-ctan-url'."
5765 :group 'gnus-article-buttons
5768 (defcustom gnus-button-mid-or-mail-regexp
5769 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5770 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5771 gnus-button-valid-fqdn-regexp
5773 "Regular expression that matches a message ID or a mail address."
5775 :group 'gnus-article-buttons
5778 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5779 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5780 Strings like this can be either a message ID or a mail address. If it is one
5781 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5782 message ID or a mail address, respectively. If this variable is set to the
5783 symbol `ask', always query the user what do do. If it is a function, this
5784 function will be called with the string as it's only argument. The function
5785 must return `mid', `mail', `invalid' or `ask'."
5787 :group 'gnus-article-buttons
5788 :type '(choice (function-item :tag "Heuristic function"
5789 gnus-button-mid-or-mail-heuristic)
5794 (defcustom gnus-button-mid-or-mail-heuristic-alist
5795 '((-10.0 . ".+\\$.+@")
5798 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5799 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5800 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5801 (-1.0 . "^[^a-z]+@")
5803 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5804 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5805 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5806 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5809 (-1.0 . "^[0-9][0-9]")
5811 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5812 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5813 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5814 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5816 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5817 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5820 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5822 ;; compensation for TDMA dated mail addresses:
5823 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5825 (-20.0 . "\\.fsf@") ;; Gnus
5828 (-20.0 . "_-_") ;; Subject change in thread
5830 (-20.0 . "\\.ln@") ;; leafnode
5831 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5832 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5834 ;; (5.0 . "") ;; $local_part_len <= 7
5835 (10.0 . "^[^0-9]+@")
5836 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5837 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5840 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5842 (0.5 . "^[A-Z][a-z]")
5843 (0.5 . "^[A-Z][a-z][a-z]")
5844 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5845 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5846 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5848 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5849 address. The REGEXP is processed with `case-fold-search' set to nil."
5851 :group 'gnus-article-buttons
5852 :type '(repeat (cons (number :tag "Rate")
5853 (regexp :tag "Regexp"))))
5855 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5856 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5857 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5858 address, `ask' if unsure and `invalid' if the string is invalid."
5859 (let ((case-fold-search nil)
5860 (list gnus-button-mid-or-mail-heuristic-alist)
5861 (result 0) rate regexp lpartlen elem)
5863 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5864 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5865 ;; Certain special cases...
5868 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
5869 "^[0-9]+\\.[0-9]+@compuserve\\|"
5870 "@public\\.gmane\\.org")
5872 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
5873 (setq result 'mail))
5874 (when (string-match "@.*@\\| " mid-or-mail)
5875 (gnus-message 8 "`%s' is invalid." mid-or-mail)
5876 (setq result 'invalid))
5877 ;; Nothing more to do, if result is not a number here...
5878 (when (numberp result)
5880 (setq elem (car list)
5884 (when (string-match regexp mid-or-mail)
5885 (setq result (+ result rate))
5887 9 "`%s' matched `%s', rate `%s', result `%s'."
5888 mid-or-mail regexp rate result)))
5889 (when (<= lpartlen 7)
5890 (setq result (+ result 5.0))
5891 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5892 mid-or-mail result))
5893 (when (>= lpartlen 12)
5894 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5896 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5897 ;; Long local part should contain realname if e-mail address,
5898 ;; too many digits: message-id.
5899 ;; $score -= 5.0 + 0.1 * $local_part_len;
5900 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5901 (setq result (+ result rate))
5903 9 "Many digits in `%s', rate `%s', result `%s'."
5904 mid-or-mail rate result))
5905 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5907 ;; Too few vowels [^aeiouy]{4,}.*\@
5908 (setq result (+ result -5.0))
5910 9 "Few vowels in `%s', rate `%s', result `%s'."
5911 mid-or-mail -5.0 result))
5913 (setq result (+ result 5.0))
5915 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5916 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5917 ;; Maybe we should make this a customizable alist: (condition . 'result)
5919 ((symbolp result) result)
5920 ;; Now convert number into proper results:
5921 ((< result -10.0) 'mid)
5922 ((> result 10.0) 'mail)
5925 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5926 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5927 (url-mid (concat "news" ":" mid-or-mail))
5928 (url-mailto (concat "mailto" ":" mid-or-mail)))
5929 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5930 (when (fboundp pref)
5932 ;; get rid of surrounding angles...
5934 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5935 (if (or (eq 'mid guessed) (eq 'mail guessed))
5939 (save-window-excursion
5940 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5943 (cond ((eq pref 'mid)
5944 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5945 (gnus-button-handle-news url-mid))
5947 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5948 (gnus-url-mailto url-mailto))
5949 (t (gnus-message 3 "Invalid string.")))))
5951 (defun gnus-button-handle-custom (url)
5952 "Follow a Custom URL."
5953 (customize-apropos (gnus-url-unhex-string url)))
5955 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5957 ;; FIXME: Maybe we should merge some of the functions that do quite similar
5960 (defun gnus-button-handle-describe-function (url)
5961 "Call `describe-function' when pushing the corresponding URL button."
5964 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5966 (defun gnus-button-handle-describe-variable (url)
5967 "Call `describe-variable' when pushing the corresponding URL button."
5970 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5972 (defun gnus-button-handle-symbol (url)
5973 "Display help on variable or function.
5974 Calls `describe-variable' or `describe-function'."
5975 (let ((sym (intern url)))
5977 ((fboundp sym) (describe-function sym))
5978 ((boundp sym) (describe-variable sym))
5979 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
5981 (defun gnus-button-handle-describe-key (url)
5982 "Call `describe-key' when pushing the corresponding URL button."
5984 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5985 (keys (ignore-errors (eval `(kbd ,key-string)))))
5988 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5990 (defun gnus-button-handle-apropos (url)
5991 "Call `apropos' when pushing the corresponding URL button."
5992 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5994 (defun gnus-button-handle-apropos-command (url)
5995 "Call `apropos' when pushing the corresponding URL button."
5997 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5999 (defun gnus-button-handle-apropos-variable (url)
6000 "Call `apropos' when pushing the corresponding URL button."
6002 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6003 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6005 (defun gnus-button-handle-apropos-documentation (url)
6006 "Call `apropos' when pushing the corresponding URL button."
6008 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6009 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6011 (defun gnus-button-handle-library (url)
6012 "Call `locate-library' when pushing the corresponding URL button."
6013 (gnus-message 9 "url=`%s'" url)
6014 (let* ((lib (locate-library url))
6015 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6017 (gnus-message 1 "Cannot locale library `%s'." url)
6018 (find-file-read-only file))))
6020 (defun gnus-button-handle-ctan (url)
6021 "Call `browse-url' when pushing a CTAN URL button."
6023 gnus-button-ctan-handler
6026 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6028 (defcustom gnus-button-tex-level 5
6029 "*Integer that says how many TeX-related buttons Gnus will show.
6030 The higher the number, the more buttons will appear and the more false
6031 positives are possible. Note that you can set this variable local to
6032 specific groups. Setting it higher in TeX groups is probably a good idea.
6033 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6034 how to set variables in specific groups."
6036 :group 'gnus-article-buttons
6037 :link '(custom-manual "(gnus)Group Parameters")
6040 (defcustom gnus-button-man-level 5
6041 "*Integer that says how many man-related buttons Gnus will show.
6042 The higher the number, the more buttons will appear and the more false
6043 positives are possible. Note that you can set this variable local to
6044 specific groups. Setting it higher in Unix groups is probably a good idea.
6045 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6046 how to set variables in specific groups."
6048 :group 'gnus-article-buttons
6049 :link '(custom-manual "(gnus)Group Parameters")
6052 (defcustom gnus-button-emacs-level 5
6053 "*Integer that says how many emacs-related buttons Gnus will show.
6054 The higher the number, the more buttons will appear and the more false
6055 positives are possible. Note that you can set this variable local to
6056 specific groups. Setting it higher in Emacs or Gnus related groups is
6057 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6058 `gnus-parameters' on how to set variables in specific groups."
6060 :group 'gnus-article-buttons
6061 :link '(custom-manual "(gnus)Group Parameters")
6064 (defcustom gnus-button-message-level 5
6065 "*Integer that says how many buttons for news or mail messages will appear.
6066 The higher the number, the more buttons will appear and the more false
6067 positives are possible."
6068 ;; mail addresses, MIDs, URLs for news, ...
6070 :group 'gnus-article-buttons
6073 (defcustom gnus-button-browse-level 5
6074 "*Integer that says how many buttons for browsing will appear.
6075 The higher the number, the more buttons will appear and the more false
6076 positives are possible."
6077 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6079 :group 'gnus-article-buttons
6082 (defcustom gnus-button-alist
6083 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6084 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6085 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6086 gnus-button-handle-news 2)
6087 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6088 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6089 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6090 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6091 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6092 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6093 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6094 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6095 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6096 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6097 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6098 ;; RFC 2368 (The mailto URL scheme)
6099 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6100 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6101 ("\\bmailto:\\([^ \n\t]+\\)"
6102 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6104 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6105 gnus-button-ctan-directory-regexp
6106 "[^][>)!;:,'\n\t ]+\\)")
6107 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6108 ((concat "\\btex-archive/\\("
6109 gnus-button-ctan-directory-regexp
6110 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6111 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6114 gnus-button-ctan-directory-regexp
6115 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6116 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6117 ;; This is info (home-grown style) <info://foo/bar+baz>
6118 ("\\binfo://\\([^'\">\n\t ]+\\)"
6119 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6120 ;; Info GNOME style <info:foo#bar_baz>
6121 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6122 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6123 ;; Info KDE style <info:(foo)bar baz>
6124 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6125 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6126 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6127 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6128 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6129 ;; Info links like `C-h i d m CC Mode RET'
6130 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6132 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6133 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6134 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6135 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6136 ;; Emacs help commands
6137 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6138 ;; regexp doesn't match arguments containing ` '.
6139 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6140 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6141 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6142 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6143 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6144 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6145 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6146 ;; The following entries may lead to many false positives so don't enable
6147 ;; them by default (use a high button level).
6148 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6149 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6150 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6151 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6152 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6153 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6154 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6155 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6156 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6157 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6158 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6159 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6160 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6161 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6162 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6163 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6164 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6165 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6166 ;; Unlike the other regexps we really have to require quoting
6167 ;; here to determine where it ends.
6168 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6169 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6170 ("<URL: *\\([^<>]*\\)>"
6171 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6172 ;; RFC 2396 (2.4.3., delims) ...
6173 ("\"URL: *\\([^\"]*\\)\""
6174 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6175 ;; RFC 2396 (2.4.3., delims) ...
6176 ("\"URL: *\\([^\"]*\\)\""
6177 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6179 (gnus-button-url-regexp
6180 0 (>= gnus-button-browse-level 0) browse-url 0)
6182 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6183 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6184 gnus-button-handle-man 1)
6185 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6186 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6187 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6188 gnus-button-handle-man 1)
6189 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6190 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6191 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6192 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6193 ;; MID or mail: To avoid too many false positives we don't try to catch
6194 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6195 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6196 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6197 ;; so that non-ambiguous entries (see above) match first.
6198 (gnus-button-mid-or-mail-regexp
6199 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6200 "*Alist of regexps matching buttons in article bodies.
6202 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6203 REGEXP: is the string (case insensitive) matching text around the button (can
6204 also be Lisp expression evaluating to a string),
6205 BUTTON: is the number of the regexp grouping actually matching the button,
6206 FORM: is a Lisp expression which must eval to true for the button to
6208 CALLBACK: is the function to call when the user push this button, and each
6209 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6211 CALLBACK can also be a variable, in that case the value of that
6212 variable it the real callback function."
6213 :group 'gnus-article-buttons
6214 :type '(repeat (list (choice regexp variable sexp)
6215 (integer :tag "Button")
6217 (function :tag "Callback")
6220 (integer :tag "Regexp group")))))
6222 (defcustom gnus-header-button-alist
6223 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6224 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6225 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6226 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6227 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6228 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6229 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6230 0 (>= gnus-button-browse-level 0) browse-url 0)
6231 ("^Subject:" gnus-button-url-regexp
6232 0 (>= gnus-button-browse-level 0) browse-url 0)
6233 ("^[^:]+:" gnus-button-url-regexp
6234 0 (>= gnus-button-browse-level 0) browse-url 0)
6235 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6236 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6237 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6238 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6239 "*Alist of headers and regexps to match buttons in article heads.
6241 This alist is very similar to `gnus-button-alist', except that each
6242 alist has an additional HEADER element first in each entry:
6244 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6246 HEADER is a regexp to match a header. For a fuller explanation, see
6247 `gnus-button-alist'."
6248 :group 'gnus-article-buttons
6249 :group 'gnus-article-headers
6250 :type '(repeat (list (regexp :tag "Header")
6251 (choice regexp variable)
6252 (integer :tag "Button")
6254 (function :tag "Callback")
6257 (integer :tag "Regexp group")))))
6261 (defun gnus-article-push-button (event)
6262 "Check text under the mouse pointer for a callback function.
6263 If the text under the mouse pointer has a `gnus-callback' property,
6264 call it with the value of the `gnus-data' text property."
6266 (set-buffer (window-buffer (posn-window (event-start event))))
6267 (let* ((pos (posn-point (event-start event)))
6268 (data (get-text-property pos 'gnus-data))
6269 (fun (get-text-property pos 'gnus-callback)))
6272 (funcall fun data))))
6274 (defun gnus-article-press-button ()
6275 "Check text at point for a callback function.
6276 If the text at point has a `gnus-callback' property,
6277 call it with the value of the `gnus-data' text property."
6279 (let ((data (get-text-property (point) 'gnus-data))
6280 (fun (get-text-property (point) 'gnus-callback)))
6282 (funcall fun data))))
6284 (defun gnus-article-highlight (&optional force)
6285 "Highlight current article.
6286 This function calls `gnus-article-highlight-headers',
6287 `gnus-article-highlight-citation',
6288 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6289 do the highlighting. See the documentation for those functions."
6290 (interactive (list 'force))
6291 (gnus-article-highlight-headers)
6292 (gnus-article-highlight-citation force)
6293 (gnus-article-highlight-signature)
6294 (gnus-article-add-buttons force)
6295 (gnus-article-add-buttons-to-head))
6297 (defun gnus-article-highlight-some (&optional force)
6298 "Highlight current article.
6299 This function calls `gnus-article-highlight-headers',
6300 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6301 do the highlighting. See the documentation for those functions."
6302 (interactive (list 'force))
6303 (gnus-article-highlight-headers)
6304 (gnus-article-highlight-signature)
6305 (gnus-article-add-buttons))
6307 (defun gnus-article-highlight-headers ()
6308 "Highlight article headers as specified by `gnus-header-face-alist'."
6310 (gnus-with-article-headers
6311 (let (regexp header-face field-face from hpoints fpoints)
6312 (dolist (entry gnus-header-face-alist)
6313 (goto-char (point-min))
6314 (setq regexp (concat "^\\("
6315 (if (string-equal "" (nth 0 entry))
6319 header-face (nth 1 entry)
6320 field-face (nth 2 entry))
6321 (while (and (re-search-forward regexp nil t)
6325 (unless (search-forward ":" nil t)
6327 (when (and header-face
6328 (not (memq (point) hpoints)))
6329 (push (point) hpoints)
6330 (gnus-put-text-property from (point) 'face header-face))
6331 (when (and field-face
6332 (not (memq (setq from (point)) fpoints)))
6334 (if (re-search-forward "^[^ \t]" nil t)
6336 (goto-char (point-max)))
6337 (gnus-put-text-property from (point) 'face field-face)))))))
6339 (defun gnus-article-highlight-signature ()
6340 "Highlight the signature in an article.
6341 It does this by highlighting everything after
6342 `gnus-signature-separator' using `gnus-signature-face'."
6344 (gnus-with-article-buffer
6345 (let ((inhibit-point-motion-hooks t))
6347 (when (and gnus-signature-face
6348 (gnus-article-narrow-to-signature))
6349 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6350 'face gnus-signature-face)
6352 (gnus-article-search-signature)
6353 (let ((start (match-beginning 0))
6354 (end (set-marker (make-marker) (1+ (match-end 0)))))
6355 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6358 (defun gnus-button-in-region-p (b e prop)
6359 "Say whether PROP exists in the region."
6360 (text-property-not-all b e prop nil))
6362 (defun gnus-article-add-buttons (&optional force)
6363 "Find external references in the article and make buttons of them.
6364 \"External references\" are things like Message-IDs and URLs, as
6365 specified by `gnus-button-alist'."
6366 (interactive (list 'force))
6367 (gnus-with-article-buffer
6368 (let ((inhibit-point-motion-hooks t)
6369 (case-fold-search t)
6370 (alist gnus-button-alist)
6372 ;; Remove all old markers.
6373 (let (marker entry new-list)
6374 (while (setq marker (pop gnus-button-marker-list))
6375 (if (or (< marker (point-min)) (>= marker (point-max)))
6376 (push marker new-list)
6378 (when (setq entry (gnus-button-entry))
6379 (put-text-property (match-beginning (nth 1 entry))
6380 (match-end (nth 1 entry))
6381 'gnus-callback nil))
6382 (set-marker marker nil)))
6383 (setq gnus-button-marker-list new-list))
6384 ;; We skip the headers.
6387 (while (setq entry (pop alist))
6388 (setq regexp (eval (car entry)))
6390 (while (re-search-forward regexp nil t)
6391 (let* ((start (and entry (match-beginning (nth 1 entry))))
6392 (end (and entry (match-end (nth 1 entry))))
6393 (from (match-beginning 0)))
6394 (when (and (or (eq t (nth 2 entry))
6395 (eval (nth 2 entry)))
6396 (not (gnus-button-in-region-p
6397 start end 'gnus-callback)))
6398 ;; That optional form returned non-nil, so we add the
6400 (gnus-article-add-button
6401 start end 'gnus-button-push
6402 (car (push (set-marker (make-marker) from)
6403 gnus-button-marker-list))))))))))
6405 ;; Add buttons to the head of an article.
6406 (defun gnus-article-add-buttons-to-head ()
6407 "Add buttons to the head of the article."
6409 (gnus-with-article-headers
6411 (dolist (entry gnus-header-button-alist)
6412 ;; Each alist entry.
6413 (goto-char (point-min))
6414 (while (re-search-forward (car entry) nil t)
6415 ;; Each header matching the entry.
6416 (setq beg (match-beginning 0))
6417 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6418 (match-beginning 0))
6421 (while (re-search-forward (eval (nth 1 entry)) end t)
6422 ;; Each match within a header.
6423 (let* ((entry (cdr entry))
6424 (start (match-beginning (nth 1 entry)))
6425 (end (match-end (nth 1 entry)))
6426 (form (nth 2 entry)))
6427 (goto-char (match-end 0))
6429 (gnus-article-add-button
6430 start end (nth 3 entry)
6431 (buffer-substring (match-beginning (nth 4 entry))
6432 (match-end (nth 4 entry)))))))
6433 (goto-char end))))))
6435 ;;; External functions:
6437 (defun gnus-article-add-button (from to fun &optional data)
6438 "Create a button between FROM and TO with callback FUN and data DATA."
6439 (when gnus-article-button-face
6440 (gnus-overlay-put (gnus-make-overlay from to)
6441 'face gnus-article-button-face))
6442 (gnus-add-text-properties
6444 (nconc (and gnus-article-mouse-face
6445 (list gnus-mouse-face-prop gnus-article-mouse-face))
6446 (list 'gnus-callback fun)
6447 (and data (list 'gnus-data data))))
6448 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6449 :button-keymap gnus-widget-button-keymap))
6451 ;;; Internal functions:
6453 (defun gnus-article-set-globals ()
6454 (with-current-buffer gnus-summary-buffer
6455 (gnus-set-global-variables)))
6457 (defun gnus-signature-toggle (end)
6458 (gnus-with-article-buffer
6459 (let ((inhibit-point-motion-hooks t))
6460 (if (text-property-any end (point-max) 'article-type 'signature)
6462 (gnus-delete-wash-type 'signature)
6463 (gnus-remove-text-properties-when
6464 'article-type 'signature end (point-max)
6465 (cons 'article-type (cons 'signature
6466 gnus-hidden-properties))))
6467 (gnus-add-wash-type 'signature)
6468 (gnus-add-text-properties-when
6469 'article-type nil end (point-max)
6470 (cons 'article-type (cons 'signature
6471 gnus-hidden-properties)))))
6472 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6473 (gnus-set-mode-line 'article))))
6475 (defun gnus-button-entry ()
6476 ;; Return the first entry in `gnus-button-alist' matching this place.
6477 (let ((alist gnus-button-alist)
6480 (setq entry (pop alist))
6481 (if (looking-at (eval (car entry)))
6486 (defun gnus-button-push (marker)
6487 ;; Push button starting at MARKER.
6490 (let* ((entry (gnus-button-entry))
6491 (inhibit-point-motion-hooks t)
6493 (args (mapcar (lambda (group)
6494 (let ((string (match-string group)))
6495 (set-text-properties
6496 0 (length string) nil string)
6503 (fboundp (symbol-value fun)))
6504 (apply (symbol-value fun) args))
6506 (gnus-message 1 "You must define `%S' to use this button"
6507 (cons fun args)))))))
6509 (defun gnus-parse-news-url (url)
6510 (let (scheme server group message-id articles)
6513 (goto-char (point-min))
6514 (when (looking-at "\\([A-Za-z]+\\):")
6515 (setq scheme (match-string 1))
6516 (goto-char (match-end 0)))
6517 (when (looking-at "//\\([^/]+\\)/")
6518 (setq server (match-string 1))
6519 (goto-char (match-end 0)))
6522 ((looking-at "\\(.*@.*\\)")
6523 (setq message-id (match-string 1)))
6524 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6525 (setq group (match-string 1)
6526 articles (split-string (match-string 2) "-")))
6527 ((looking-at "\\([^/]+\\)/?")
6528 (setq group (match-string 1)))
6530 (error "Unknown news URL syntax"))))
6531 (list scheme server group message-id articles)))
6533 (defun gnus-button-handle-news (url)
6535 (destructuring-bind (scheme server group message-id articles)
6536 (gnus-parse-news-url url)
6540 (set-buffer gnus-summary-buffer)
6542 (let ((gnus-refer-article-method (list (list 'nntp server))))
6543 (gnus-summary-refer-article message-id))
6544 (gnus-summary-refer-article message-id))))
6546 (gnus-button-fetch-group url)))))
6548 (defun gnus-button-handle-man (url)
6550 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6551 (when (eq gnus-button-man-handler 'woman)
6552 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6553 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6554 (funcall gnus-button-man-handler url))
6556 (defun gnus-button-handle-info-url (url)
6557 "Fetch an info URL."
6558 (setq url (mm-subst-char-in-string ?+ ?\ url))
6560 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6561 (gnus-info-find-node
6562 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6564 ")" (gnus-url-unhex-string (match-string 2 url)))))
6565 ((string-match "([^)\"]+)[^\"]+" url)
6567 (gnus-replace-in-string
6568 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6569 (gnus-info-find-node url))
6570 (t (error "Can't parse %s" url))))
6572 (defun gnus-button-handle-info-url-gnome (url)
6573 "Fetch GNOME style info URL."
6574 (setq url (mm-subst-char-in-string ?_ ?\ url))
6575 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6576 (gnus-info-find-node
6578 (gnus-url-unhex-string
6579 (match-string 1 url))
6581 (or (gnus-url-unhex-string
6582 (match-string 2 url))
6584 (error "Can't parse %s" url)))
6586 (defun gnus-button-handle-info-url-kde (url)
6587 "Fetch KDE style info URL."
6588 (gnus-info-find-node (gnus-url-unhex-string url)))
6590 (defun gnus-button-handle-info-keystrokes (url)
6591 "Call `info' when pushing the corresponding URL button."
6592 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6597 (defun gnus-button-message-id (message-id)
6599 (with-current-buffer gnus-summary-buffer
6600 (gnus-summary-refer-article message-id)))
6602 (defun gnus-button-fetch-group (address)
6603 "Fetch GROUP specified by ADDRESS."
6604 (if (not (string-match "[:/]" address))
6605 ;; This is just a simple group url.
6606 (gnus-group-read-ephemeral-group address gnus-select-method)
6609 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6611 (error "Can't parse %s" address)
6612 (gnus-group-read-ephemeral-group
6613 (match-string 4 address)
6614 `(nntp ,(match-string 1 address)
6615 (nntp-address ,(match-string 1 address))
6616 (nntp-port-number ,(if (match-end 3)
6617 (match-string 3 address)
6620 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6622 (defun gnus-url-parse-query-string (query &optional downcase)
6623 (let (retval pairs cur key val)
6624 (setq pairs (split-string query "&"))
6626 (setq cur (car pairs)
6628 (if (not (string-match "=" cur))
6630 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6631 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6633 (setq key (downcase key)))
6634 (setq cur (assoc key retval))
6636 (setcdr cur (cons val (cdr cur)))
6637 (setq retval (cons (list key val) retval)))))
6640 (defun gnus-url-mailto (url)
6641 ;; Send mail to someone
6642 (when (string-match "mailto:/*\\(.*\\)" url)
6643 (setq url (substring url (match-beginning 1) nil)))
6644 (let (to args subject func)
6645 (setq args (gnus-url-parse-query-string
6646 (if (string-match "^\\?" url)
6648 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6649 (concat "to=" (match-string 1 url) "&"
6650 (match-string 2 url))
6651 (concat "to=" url)))
6653 subject (cdr-safe (assoc "subject" args)))
6656 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6659 (message-position-on-field (caar args)))
6660 (insert (gnus-replace-in-string
6661 (mapconcat 'identity (reverse (cdar args)) ", ")
6663 (setq args (cdr args)))
6666 (message-goto-subject))))
6668 (defun gnus-button-embedded-url (address)
6669 "Activate ADDRESS with `browse-url'."
6670 (browse-url (gnus-strip-whitespace address)))
6672 ;;; Next/prev buttons in the article buffer.
6674 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6675 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6677 (defvar gnus-prev-page-map
6678 (let ((map (make-sparse-keymap)))
6679 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6680 (define-key map "\r" 'gnus-button-prev-page)
6683 (defvar gnus-next-page-map
6684 (let ((map (make-sparse-keymap)))
6685 (unless (>= emacs-major-version 21)
6686 ;; XEmacs doesn't care.
6687 (set-keymap-parent map gnus-article-mode-map))
6688 (define-key map gnus-mouse-2 'gnus-button-next-page)
6689 (define-key map "\r" 'gnus-button-next-page)
6692 (defun gnus-insert-prev-page-button ()
6694 (inhibit-read-only t))
6696 gnus-prev-page-line-format nil
6697 `(keymap ,gnus-prev-page-map
6699 gnus-callback gnus-article-button-prev-page
6700 article-type annotation))
6701 (widget-convert-button
6703 ;; Exclude a newline.
6706 :action 'gnus-button-prev-page
6707 :button-keymap gnus-prev-page-map)))
6709 (defun gnus-button-next-page (&optional args more-args)
6710 "Go to the next page."
6712 (let ((win (selected-window)))
6713 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6714 (gnus-article-next-page)
6715 (select-window win)))
6717 (defun gnus-button-prev-page (&optional args more-args)
6718 "Go to the prev page."
6720 (let ((win (selected-window)))
6721 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6722 (gnus-article-prev-page)
6723 (select-window win)))
6725 (defun gnus-insert-next-page-button ()
6727 (inhibit-read-only t))
6728 (gnus-eval-format gnus-next-page-line-format nil
6729 `(keymap ,gnus-next-page-map
6731 gnus-callback gnus-article-button-next-page
6732 article-type annotation))
6733 (widget-convert-button
6735 ;; Exclude a newline.
6738 :action 'gnus-button-next-page
6739 :button-keymap gnus-next-page-map)))
6741 (defun gnus-article-button-next-page (arg)
6742 "Go to the next page."
6744 (let ((win (selected-window)))
6745 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6746 (gnus-article-next-page)
6747 (select-window win)))
6749 (defun gnus-article-button-prev-page (arg)
6750 "Go to the prev page."
6752 (let ((win (selected-window)))
6753 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6754 (gnus-article-prev-page)
6755 (select-window win)))
6757 (defvar gnus-decode-header-methods
6758 '(mail-decode-encoded-word-region)
6759 "List of methods used to decode headers.
6761 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6762 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6763 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6764 whose names match REGEXP.
6767 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6768 mail-decode-encoded-word-region
6769 (\"chinese\" . rfc1843-decode-region))
6772 (defvar gnus-decode-header-methods-cache nil)
6774 (defun gnus-multi-decode-header (start end)
6775 "Apply the functions from `gnus-encoded-word-methods' that match."
6776 (unless (and gnus-decode-header-methods-cache
6777 (eq gnus-newsgroup-name
6778 (car gnus-decode-header-methods-cache)))
6779 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6782 (nconc gnus-decode-header-methods-cache (list x))
6783 (if (and gnus-newsgroup-name
6784 (string-match (car x) gnus-newsgroup-name))
6785 (nconc gnus-decode-header-methods-cache
6787 gnus-decode-header-methods))
6788 (let ((xlist gnus-decode-header-methods-cache))
6791 (narrow-to-region start end)
6793 (funcall (pop xlist) (point-min) (point-max))))))
6796 ;;; Treatment top-level handling.
6799 (defun gnus-treat-article (condition &optional part-number total-parts type)
6800 (let ((length (- (point-max) (point-min)))
6801 (alist gnus-treatment-function-alist)
6802 (article-goto-body-goes-to-point-min-p t)
6806 (let ((list gnus-article-treat-types))
6808 (when (string-match (pop list) type)
6809 (throw 'found t)))))))
6810 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6812 (gnus-run-hooks 'gnus-part-display-hook)
6813 (dolist (elem alist)
6816 (when (gnus-buffer-live-p gnus-summary-buffer)
6817 (set-buffer gnus-summary-buffer))
6818 (symbol-value (car elem))))
6819 (when (and (or (consp val)
6821 (gnus-treat-predicate val)
6822 (or (not (get (car elem) 'highlight))
6825 (funcall (cadr elem)))))))
6827 ;; Dynamic variables.
6829 (defvar part-number)
6830 (defvar total-parts)
6835 (defun gnus-treat-predicate (val)
6842 (stringp (car val)))
6843 (apply 'gnus-or (mapcar `(lambda (s)
6844 (string-match s ,(or gnus-newsgroup-name "")))
6847 (let ((pred (pop val)))
6850 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6852 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6854 (not (gnus-treat-predicate (car val))))
6856 (equal (car val) type))
6858 (error "%S is not a valid predicate" pred)))))
6864 (eq part-number total-parts))
6868 (error "%S is not a valid value" val))))
6870 (defun gnus-article-encrypt-body (protocol &optional n)
6871 "Encrypt the article body."
6874 (or gnus-article-encrypt-protocol
6875 (completing-read "Encrypt protocol: "
6876 gnus-article-encrypt-protocol-alist
6878 current-prefix-arg))
6879 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6881 (error (format "Can't find the encrypt protocol %s" protocol)))
6882 (if (member gnus-newsgroup-name '("nndraft:delayed"
6885 (error "Can't encrypt the article in group %s"
6886 gnus-newsgroup-name))
6887 (gnus-summary-iterate n
6889 (set-buffer gnus-summary-buffer)
6890 (let ((mail-parse-charset gnus-newsgroup-charset)
6891 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6892 (summary-buffer gnus-summary-buffer)
6894 (gnus-set-global-variables)
6895 (when (gnus-group-read-only-p)
6896 (error "The current newsgroup does not support article encrypt"))
6897 (gnus-summary-show-article t)
6899 (or (mail-header-references gnus-current-headers) ""))
6900 (set-buffer gnus-article-buffer)
6901 (let* ((inhibit-read-only t)
6903 (mapcar (lambda (field)
6904 (and (save-restriction
6905 (message-narrow-to-head)
6906 (goto-char (point-min))
6907 (search-forward field nil t))
6909 (message-narrow-to-field)
6911 (delete-region (point-min) (point-max))
6913 '("Content-Type:" "Content-Transfer-Encoding:"
6914 "Content-Disposition:"))))
6915 (message-narrow-to-head)
6916 (message-remove-header "MIME-Version")
6917 (goto-char (point-max))
6918 (setq point (point))
6919 (insert (apply 'concat headers))
6921 (narrow-to-region point (point-max))
6922 (let ((message-options message-options))
6923 (message-options-set 'message-sender user-mail-address)
6924 (message-options-set 'message-recipients user-mail-address)
6925 (message-options-set 'message-sign-encrypt 'not)
6927 (goto-char (point-min))
6928 (insert "MIME-Version: 1.0\n")
6930 (gnus-summary-edit-article-done
6931 references nil summary-buffer t))
6932 (when gnus-keep-backlog
6933 (gnus-backlog-remove-article
6934 (car gnus-article-current) (cdr gnus-article-current)))
6936 (when (get-buffer gnus-original-article-buffer)
6937 (set-buffer gnus-original-article-buffer)
6938 (setq gnus-original-article nil)))
6939 (when gnus-use-cache
6940 (gnus-cache-update-article
6941 (car gnus-article-current) (cdr gnus-article-current))))))))
6943 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%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-end-line-format "%{%([[End of %t]%D]%)%}\n"
6951 "The following specs can be used:
6952 %t The security MIME type
6955 %D Details if button is pressed")
6957 (defvar gnus-mime-security-button-line-format-alist
6958 '((?t gnus-tmp-type ?s)
6959 (?i gnus-tmp-info ?s)
6960 (?d gnus-tmp-details ?s)
6961 (?D gnus-tmp-pressed-details ?s)))
6963 (defvar gnus-mime-security-button-map
6964 (let ((map (make-sparse-keymap)))
6965 (define-key map gnus-mouse-2 'gnus-article-push-button)
6966 (define-key map "\r" 'gnus-article-press-button)
6969 (defvar gnus-mime-security-details-buffer nil)
6971 (defvar gnus-mime-security-button-pressed nil)
6973 (defvar gnus-mime-security-show-details-inline t
6974 "If non-nil, show details in the article buffer.")
6976 (defun gnus-mime-security-verify-or-decrypt (handle)
6977 (mm-remove-parts (cdr handle))
6978 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6979 point (inhibit-read-only t))
6981 (goto-char (car region)))
6983 (narrow-to-region (point) (point))
6984 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6985 (let* ((mm-verify-option 'known)
6986 (mm-decrypt-option 'known)
6987 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6988 (unless (eq nparts (cdr handle))
6989 (mm-destroy-parts (cdr handle))
6990 (setcdr handle nparts))))
6991 (setq point (point))
6992 (gnus-mime-display-security handle)
6993 (goto-char (point-max)))
6995 (delete-region (point) (cdr region))
6996 (set-marker (car region) nil)
6997 (set-marker (cdr region) nil))
7000 (defun gnus-mime-security-show-details (handle)
7001 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7003 (gnus-message 5 "No details.")
7004 (if gnus-mime-security-show-details-inline
7005 (let ((gnus-mime-security-button-pressed
7006 (not (get-text-property (point) 'gnus-mime-details)))
7007 (gnus-mime-security-button-line-format
7008 (get-text-property (point) 'gnus-line-format))
7009 (inhibit-read-only t))
7011 (while (eq (get-text-property (point) 'gnus-line-format)
7012 gnus-mime-security-button-line-format)
7016 (narrow-to-region (point) (point))
7017 (gnus-insert-mime-security-button handle))
7018 (delete-region (point)
7019 (or (text-property-not-all
7022 gnus-mime-security-button-line-format)
7025 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7026 (with-current-buffer gnus-mime-security-details-buffer
7029 (setq gnus-mime-security-details-buffer
7030 (gnus-get-buffer-create "*MIME Security Details*")))
7031 (with-current-buffer gnus-mime-security-details-buffer
7033 (goto-char (point-min)))
7034 (pop-to-buffer gnus-mime-security-details-buffer)))))
7036 (defun gnus-mime-security-press-button (handle)
7038 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7039 (gnus-mime-security-show-details handle)
7040 (gnus-mime-security-verify-or-decrypt handle))))
7042 (defun gnus-insert-mime-security-button (handle &optional displayed)
7043 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7046 (or (nth 2 (assoc protocol mm-verify-function-alist))
7047 (nth 2 (assoc protocol mm-decrypt-function-alist))
7049 (if (equal (car handle) "multipart/signed")
7050 " Signed" " Encrypted")
7053 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7056 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7057 gnus-tmp-pressed-details
7059 (setq gnus-tmp-details
7060 (if gnus-tmp-details
7061 (concat "\n" gnus-tmp-details)
7063 (setq gnus-tmp-pressed-details
7064 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7069 gnus-mime-security-button-line-format
7070 gnus-mime-security-button-line-format-alist
7071 `(keymap ,gnus-mime-security-button-map
7072 gnus-callback gnus-mime-security-press-button
7073 gnus-line-format ,gnus-mime-security-button-line-format
7074 gnus-mime-details ,gnus-mime-security-button-pressed
7075 article-type annotation
7078 ;; Exclude a newline.
7081 (widget-convert-button
7084 :action 'gnus-widget-press-button
7085 :button-keymap gnus-mime-security-button-map
7087 (lambda (widget/window &optional overlay pos)
7088 ;; Needed to properly clear the message due to a bug in
7089 ;; wid-edit (XEmacs only).
7090 (when (boundp 'help-echo-owns-message)
7091 (setq help-echo-owns-message t))
7094 (aref gnus-mouse-2 0))))))
7096 (defun gnus-mime-display-security (handle)
7098 (narrow-to-region (point) (point))
7099 (unless (gnus-unbuttonized-mime-type-p (car handle))
7100 (gnus-insert-mime-security-button handle))
7101 (gnus-mime-display-mixed (cdr handle))
7104 (unless (gnus-unbuttonized-mime-type-p (car handle))
7105 (let ((gnus-mime-security-button-line-format
7106 gnus-mime-security-button-end-line-format))
7107 (gnus-insert-mime-security-button handle)))
7108 (mm-set-handle-multipart-parameter
7110 (cons (set-marker (make-marker) (point-min))
7111 (set-marker (make-marker) (point-max))))))
7117 (run-hooks 'gnus-art-load-hook)
7119 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7120 ;;; gnus-art.el ends here